From dfb0e3b03e3bc279676867c218e1722087aeca3e Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Mon, 30 Mar 2026 16:25:52 +1100 Subject: [PATCH] refactor: replace NULL with nullptr across C++ codebase Excludes vendored C libs (zlib, Miles, DirectXMath, boost, Iggy). --- Minecraft.Client/Commands/TeleportCommand.cpp | 2 +- Minecraft.Client/GameState/CreativeMode.cpp | 4 +- Minecraft.Client/GameState/CreativeMode.h | 2 +- Minecraft.Client/GameState/GameMode.cpp | 6 +- Minecraft.Client/GameState/GameMode.h | 4 +- Minecraft.Client/GameState/Options.cpp | 6 +- Minecraft.Client/GameState/SurvivalMode.cpp | 8 +- Minecraft.Client/GameState/SurvivalMode.h | 2 +- Minecraft.Client/Level/DerivedServerLevel.cpp | 4 +- Minecraft.Client/Level/MultiPlayerLevel.cpp | 18 +- Minecraft.Client/Level/ServerLevel.cpp | 36 +- .../Level/ServerLevelListener.cpp | 2 +- Minecraft.Client/Minecraft.cpp | 408 +++++++++--------- Minecraft.Client/Minecraft.h | 4 +- Minecraft.Client/MinecraftServer.cpp | 80 ++-- Minecraft.Client/MinecraftServer.h | 8 +- Minecraft.Client/Network/ClientConnection.cpp | 198 ++++----- .../Network/MultiPlayerChunkCache.cpp | 14 +- .../Network/PendingConnection.cpp | 12 +- Minecraft.Client/Network/PlayerChunkMap.cpp | 38 +- Minecraft.Client/Network/PlayerConnection.cpp | 94 ++-- Minecraft.Client/Network/PlayerList.cpp | 126 +++--- Minecraft.Client/Network/ServerChunkCache.cpp | 42 +- Minecraft.Client/Network/ServerConnection.cpp | 4 +- Minecraft.Client/Network/ServerScoreboard.cpp | 10 +- .../Platform/Common/Audio/SoundEngine.cpp | 22 +- .../Platform/Common/C4JMemoryPool.h | 12 +- .../Platform/Common/Consoles_App.cpp | 144 +++---- .../Platform/Common/Consoles_App.h | 4 +- .../Platform/Common/DLC/DLCAudioFile.cpp | 4 +- .../Common/DLC/DLCColourTableFile.cpp | 4 +- .../Platform/Common/DLC/DLCFile.h | 2 +- .../Platform/Common/DLC/DLCGameRulesFile.cpp | 2 +- .../Common/DLC/DLCGameRulesHeader.cpp | 4 +- .../Common/DLC/DLCLocalisationFile.cpp | 2 +- .../Platform/Common/DLC/DLCManager.cpp | 56 +-- .../Platform/Common/DLC/DLCPack.cpp | 26 +- .../Platform/Common/DLC/DLCTextureFile.cpp | 2 +- .../Platform/Common/DLC/DLCUIDataFile.cpp | 4 +- .../AddEnchantmentRuleDefinition.cpp | 4 +- .../GameRules/AddItemRuleDefinition.cpp | 6 +- .../ApplySchematicRuleDefinition.cpp | 14 +- .../GameRules/CollectItemRuleDefinition.cpp | 8 +- .../GameRules/CompleteAllRuleDefinition.cpp | 6 +- .../GameRules/CompoundGameRuleDefinition.cpp | 8 +- .../GameRules/ConsoleGenerateStructure.cpp | 6 +- .../Common/GameRules/ConsoleSchematicFile.cpp | 40 +- .../Platform/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 | 8 +- .../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 | 62 +-- .../Common/Network/GameNetworkManager.cpp | 106 ++--- .../Common/Network/GameNetworkManager.h | 8 +- .../Common/Network/NetworkPlayerQNet.cpp | 2 +- .../Network/PlatformNetworkManagerInterface.h | 2 +- .../Network/PlatformNetworkManagerStub.cpp | 38 +- .../Network/PlatformNetworkManagerStub.h | 2 +- .../Platform/Common/Network/SessionInfo.h | 4 +- .../Common/Telemetry/TelemetryManager.cpp | 4 +- .../Common/Tutorial/ChangeStateConstraint.cpp | 14 +- .../Common/Tutorial/ChangeStateConstraint.h | 2 +- .../Platform/Common/Tutorial/ChoiceTask.cpp | 2 +- .../Common/Tutorial/CompleteUsingItemTask.cpp | 2 +- .../Common/Tutorial/ControllerTask.cpp | 2 +- .../Platform/Common/Tutorial/ControllerTask.h | 4 +- .../Platform/Common/Tutorial/CraftTask.cpp | 4 +- .../Platform/Common/Tutorial/CraftTask.h | 4 +- .../Common/Tutorial/DiggerItemHint.cpp | 4 +- .../Common/Tutorial/EffectChangedTask.cpp | 2 +- .../Platform/Common/Tutorial/FullTutorial.cpp | 78 ++-- .../Tutorial/FullTutorialActiveTask.cpp | 2 +- .../Platform/Common/Tutorial/InfoTask.cpp | 2 +- .../Platform/Common/Tutorial/PickupTask.h | 2 +- .../Common/Tutorial/ProcedureCompoundTask.cpp | 2 +- .../Common/Tutorial/ProcedureCompoundTask.h | 2 +- .../Common/Tutorial/ProgressFlagTask.h | 2 +- .../Platform/Common/Tutorial/RideEntityTask.h | 2 +- .../Platform/Common/Tutorial/StatTask.cpp | 2 +- .../Common/Tutorial/StateChangeTask.h | 2 +- .../Platform/Common/Tutorial/TakeItemHint.cpp | 2 +- .../Platform/Common/Tutorial/Tutorial.cpp | 92 ++-- .../Platform/Common/Tutorial/Tutorial.h | 2 +- .../Platform/Common/Tutorial/TutorialHint.cpp | 2 +- .../Platform/Common/Tutorial/TutorialMode.cpp | 8 +- .../Platform/Common/Tutorial/TutorialMode.h | 2 +- .../Platform/Common/Tutorial/TutorialTask.cpp | 2 +- .../Platform/Common/Tutorial/UseItemTask.h | 2 +- .../Platform/Common/Tutorial/UseTileTask.h | 4 +- .../Common/Tutorial/XuiCraftingTask.cpp | 4 +- .../Common/Tutorial/XuiCraftingTask.h | 4 +- .../Platform/Common/UI/IUIController.h | 2 +- .../UI/IUIScene_AbstractContainerMenu.cpp | 50 +-- .../Platform/Common/UI/IUIScene_AnvilMenu.cpp | 10 +- .../Common/UI/IUIScene_BeaconMenu.cpp | 10 +- .../Common/UI/IUIScene_CraftingMenu.cpp | 24 +- .../Common/UI/IUIScene_CreativeMenu.cpp | 38 +- .../Common/UI/IUIScene_CreativeMenu.h | 4 +- .../Platform/Common/UI/IUIScene_HUD.cpp | 6 +- .../Platform/Common/UI/IUIScene_PauseMenu.cpp | 18 +- .../Platform/Common/UI/IUIScene_StartGame.cpp | 14 +- .../Common/UI/IUIScene_TradingMenu.cpp | 30 +- .../Platform/Common/UI/UIBitmapFont.cpp | 2 +- .../Platform/Common/UI/UIComponent_Chat.cpp | 2 +- .../Common/UI/UIComponent_Panorama.cpp | 2 +- .../Common/UI/UIComponent_Tooltips.cpp | 2 +- .../Common/UI/UIComponent_TutorialPopup.cpp | 18 +- .../Platform/Common/UI/UIControl.cpp | 18 +- .../Platform/Common/UI/UIControl_Base.cpp | 2 +- .../Common/UI/UIControl_ButtonList.cpp | 2 +- .../Platform/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 +- .../Platform/Common/UI/UIControl_Slider.cpp | 2 +- .../Common/UI/UIControl_TexturePackList.cpp | 4 +- .../Platform/Common/UI/UIController.cpp | 86 ++-- .../Platform/Common/UI/UIController.h | 20 +- .../Platform/Common/UI/UIFontData.cpp | 6 +- .../Platform/Common/UI/UIGroup.cpp | 12 +- .../Platform/Common/UI/UILayer.cpp | 20 +- Minecraft.Client/Platform/Common/UI/UILayer.h | 2 +- .../Platform/Common/UI/UIScene.cpp | 36 +- Minecraft.Client/Platform/Common/UI/UIScene.h | 2 +- .../UI/UIScene_AbstractContainerMenu.cpp | 18 +- .../Common/UI/UIScene_AbstractContainerMenu.h | 2 +- .../Platform/Common/UI/UIScene_AnvilMenu.cpp | 6 +- .../Platform/Common/UI/UIScene_BeaconMenu.cpp | 12 +- .../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 | 20 +- .../Common/UI/UIScene_CreateWorldMenu.cpp | 10 +- .../Common/UI/UIScene_CreativeMenu.cpp | 6 +- .../Platform/Common/UI/UIScene_Credits.cpp | 2 +- .../Common/UI/UIScene_DLCOffersMenu.cpp | 2 +- .../Platform/Common/UI/UIScene_DeathMenu.cpp | 6 +- .../Common/UI/UIScene_DebugOverlay.cpp | 14 +- .../Common/UI/UIScene_DebugSetCamera.cpp | 2 +- .../Common/UI/UIScene_DispenserMenu.cpp | 6 +- .../Common/UI/UIScene_EnchantingMenu.cpp | 10 +- .../Platform/Common/UI/UIScene_EndPoem.cpp | 6 +- .../Common/UI/UIScene_FireworksMenu.cpp | 6 +- .../Common/UI/UIScene_FullscreenProgress.cpp | 6 +- .../Common/UI/UIScene_FurnaceMenu.cpp | 6 +- .../Platform/Common/UI/UIScene_HUD.cpp | 20 +- .../Common/UI/UIScene_HelpAndOptionsMenu.cpp | 8 +- .../Platform/Common/UI/UIScene_HopperMenu.cpp | 6 +- .../Common/UI/UIScene_HorseInventoryMenu.cpp | 10 +- .../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 | 14 +- .../Platform/Common/UI/UIScene_JoinMenu.cpp | 10 +- .../Platform/Common/UI/UIScene_Keyboard.cpp | 14 +- .../Common/UI/UIScene_LanguageSelector.cpp | 2 +- .../UI/UIScene_LaunchMoreOptionsMenu.cpp | 2 +- .../Common/UI/UIScene_LeaderboardsMenu.cpp | 2 +- .../Platform/Common/UI/UIScene_LoadMenu.cpp | 22 +- .../Common/UI/UIScene_LoadOrJoinMenu.cpp | 54 +-- .../Platform/Common/UI/UIScene_MainMenu.cpp | 12 +- .../Platform/Common/UI/UIScene_MessageBox.cpp | 4 +- .../Platform/Common/UI/UIScene_PauseMenu.cpp | 12 +- .../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 | 52 +-- .../Common/UI/UIScene_TeleportMenu.cpp | 12 +- .../Common/UI/UIScene_TradingMenu.cpp | 14 +- .../Platform/Common/UI/UIString.cpp | 8 +- .../Platform/Common/UI/UIStructs.h | 24 +- .../Platform/Common/UI/UITTFFont.cpp | 4 +- .../Platform/Common/XML/ATGXmlParser.cpp | 22 +- .../Platform/Common/XML/ATGXmlParser.h | 2 +- .../Platform/Common/XML/xmlFilesCallback.h | 12 +- Minecraft.Client/Platform/Extrax64Stubs.cpp | 20 +- Minecraft.Client/Platform/Linux/Linux_App.cpp | 4 +- Minecraft.Client/Platform/Linux/Linux_App.h | 2 +- .../Platform/Linux/Linux_Minecraft.cpp | 42 +- .../Platform/Linux/Stubs/winapi_stubs.h | 26 +- .../Platform/Windows64/4JLibs/inc/4J_Input.h | 4 +- .../Windows64/4JLibs/inc/4J_Profile.h | 2 +- .../Platform/Windows64/4JLibs/inc/4J_Render.h | 4 +- .../Windows64/4JLibs/inc/4J_Storage.h | 18 +- .../Platform/Windows64/Windows64_App.cpp | 4 +- .../Platform/Windows64/Windows64_App.h | 2 +- .../Windows64/Windows64_Minecraft.cpp | 32 +- .../Windows64/Windows64_UIController.cpp | 4 +- .../Platform/Windows64/XML/ATGXmlParser.h | 2 +- Minecraft.Client/Platform/stubs.h | 6 +- Minecraft.Client/Player/EntityTracker.cpp | 12 +- Minecraft.Client/Player/LocalPlayer.cpp | 52 +-- .../Player/MultiPlayerGameMode.cpp | 28 +- Minecraft.Client/Player/MultiPlayerGameMode.h | 4 +- .../Player/MultiPlayerLocalPlayer.cpp | 22 +- Minecraft.Client/Player/RemotePlayer.cpp | 2 +- Minecraft.Client/Player/ServerPlayer.cpp | 68 +-- .../Player/ServerPlayerGameMode.cpp | 26 +- .../Player/ServerPlayerGameMode.h | 2 +- Minecraft.Client/Player/TrackedEntity.cpp | 42 +- Minecraft.Client/Rendering/Chunk.cpp | 4 +- .../EntityRenderers/ChestRenderer.cpp | 14 +- .../EntityRenderers/DefaultRenderer.h | 2 +- .../EntityRenderers/EnderDragonRenderer.cpp | 2 +- .../EntityRenderDispatcher.cpp | 4 +- .../EntityRenderers/EntityRenderer.cpp | 6 +- .../EntityRenderers/FallingTileRenderer.cpp | 2 +- .../EntityRenderers/FishingHookRenderer.cpp | 2 +- .../EntityRenderers/HumanoidMobRenderer.cpp | 22 +- .../EntityRenderers/ItemFrameRenderer.cpp | 4 +- .../EntityRenderers/ItemInHandRenderer.cpp | 22 +- .../EntityRenderers/ItemRenderer.cpp | 18 +- .../EntityRenderers/ItemSpriteRenderer.cpp | 2 +- .../EntityRenderers/LivingEntityRenderer.cpp | 10 +- .../EntityRenderers/MinecartRenderer.cpp | 2 +- .../Rendering/EntityRenderers/MobRenderer.cpp | 2 +- .../EntityRenderers/MobSpawnerRenderer.cpp | 2 +- .../EntityRenderers/PistonPieceRenderer.cpp | 4 +- .../EntityRenderers/PlayerRenderer.cpp | 28 +- .../EntityRenderers/SkullTileRenderer.cpp | 2 +- .../EntityRenderers/SnowManRenderer.cpp | 2 +- .../TileEntityRenderDispatcher.cpp | 20 +- .../EntityRenderers/TileEntityRenderer.cpp | 4 +- .../EntityRenderers/TileRenderer.cpp | 22 +- .../EntityRenderers/WitchRenderer.cpp | 4 +- .../EntityRenderers/ZombieRenderer.cpp | 8 +- Minecraft.Client/Rendering/GameRenderer.cpp | 56 +-- Minecraft.Client/Rendering/LevelRenderer.cpp | 96 ++--- Minecraft.Client/Rendering/Minimap.cpp | 14 +- .../Rendering/Models/HumanoidModel.cpp | 8 +- Minecraft.Client/Rendering/Models/Model.h | 2 +- .../Rendering/Models/ModelHorse.cpp | 4 +- .../Rendering/Models/ModelPart.cpp | 10 +- .../Rendering/Models/SlimeModel.cpp | 8 +- .../Particles/BreakingItemParticle.cpp | 2 +- .../Particles/FireworksParticles.cpp | 16 +- .../Particles/HugeExplosionSeedParticle.cpp | 2 +- .../Rendering/Particles/Particle.cpp | 4 +- .../Rendering/Particles/ParticleEngine.cpp | 6 +- .../Particles/PlayerCloudParticle.cpp | 2 +- .../Rendering/Particles/TerrainParticle.cpp | 2 +- Minecraft.Client/Textures/BufferedImage.h | 2 +- Minecraft.Client/Textures/ClockTexture.cpp | 14 +- Minecraft.Client/Textures/CompassTexture.cpp | 20 +- Minecraft.Client/Textures/MemTexture.cpp | 2 +- .../Textures/MobSkinMemTextureProcessor.cpp | 4 +- .../Textures/MobSkinTextureProcessor.cpp | 4 +- .../Textures/Packs/AbstractTexturePack.cpp | 22 +- .../Textures/Packs/AbstractTexturePack.h | 2 +- .../Textures/Packs/DLCTexturePack.cpp | 42 +- .../Textures/Packs/DLCTexturePack.h | 2 +- .../Textures/Packs/DefaultTexturePack.cpp | 4 +- .../Textures/Packs/DefaultTexturePack.h | 2 +- .../Textures/Packs/FileTexturePack.cpp | 2 +- .../Textures/Packs/FolderTexturePack.cpp | 2 +- .../Textures/Packs/FolderTexturePack.h | 2 +- .../Textures/Packs/TexturePack.cpp | 2 +- Minecraft.Client/Textures/Packs/TexturePack.h | 4 +- .../Textures/Packs/TexturePackRepository.cpp | 26 +- .../Stitching/PreStitchedTextureMap.cpp | 22 +- .../Textures/Stitching/StitchSlot.cpp | 14 +- .../Textures/Stitching/StitchedTexture.cpp | 28 +- .../Textures/Stitching/Stitcher.cpp | 4 +- .../Textures/Stitching/TextureMap.cpp | 22 +- Minecraft.Client/Textures/Texture.cpp | 16 +- Minecraft.Client/Textures/Texture.h | 2 +- Minecraft.Client/Textures/TextureManager.cpp | 12 +- Minecraft.Client/Textures/Textures.cpp | 70 +-- Minecraft.Client/UI/Font.cpp | 4 +- Minecraft.Client/UI/Font.h | 2 +- Minecraft.Client/UI/Gui.cpp | 22 +- Minecraft.Client/UI/Screen.cpp | 16 +- .../UI/Screens/AbstractContainerScreen.cpp | 18 +- .../UI/Screens/AchievementPopup.cpp | 4 +- .../UI/Screens/AchievementScreen.cpp | 4 +- Minecraft.Client/UI/Screens/ChatScreen.cpp | 6 +- Minecraft.Client/UI/Screens/ConnectScreen.cpp | 8 +- .../UI/Screens/CreateWorldScreen.cpp | 2 +- .../UI/Screens/CreativeInventoryScreen.cpp | 12 +- Minecraft.Client/UI/Screens/DeathScreen.cpp | 6 +- .../UI/Screens/DisconnectedScreen.cpp | 2 +- .../UI/Screens/JoinMultiplayerScreen.cpp | 2 +- .../UI/Screens/NameEntryScreen.cpp | 2 +- Minecraft.Client/UI/Screens/OptionsScreen.cpp | 2 +- Minecraft.Client/UI/Screens/PauseScreen.cpp | 4 +- .../UI/Screens/ReceivingLevelScreen.cpp | 2 +- .../UI/Screens/RenameWorldScreen.cpp | 2 +- Minecraft.Client/UI/Screens/RepairScreen.cpp | 6 +- .../UI/Screens/SelectWorldScreen.cpp | 16 +- Minecraft.Client/UI/Screens/StatsScreen.cpp | 18 +- .../UI/Screens/TextEditScreen.cpp | 2 +- Minecraft.Client/UI/Screens/TitleScreen.cpp | 4 +- .../UI/Screens/VideoSettingsScreen.cpp | 2 +- Minecraft.Client/UI/SmallButton.cpp | 4 +- Minecraft.Client/Utils/ArchiveFile.cpp | 6 +- .../AI/Attributes/AttributeModifier.cpp | 2 +- .../AI/Attributes/BaseAttributeMap.cpp | 6 +- .../ModifiableAttributeInstance.cpp | 6 +- .../AI/Attributes/ServersideAttributeMap.cpp | 4 +- Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp | 14 +- Minecraft.World/AI/Goals/BegGoal.cpp | 6 +- Minecraft.World/AI/Goals/BreedGoal.cpp | 12 +- .../AI/Goals/ControlledByPlayerGoal.cpp | 8 +- .../AI/Goals/DefendVillageTargetGoal.cpp | 2 +- Minecraft.World/AI/Goals/DoorInteractGoal.cpp | 10 +- Minecraft.World/AI/Goals/FollowOwnerGoal.cpp | 4 +- Minecraft.World/AI/Goals/FollowParentGoal.cpp | 4 +- Minecraft.World/AI/Goals/HurtByTargetGoal.cpp | 2 +- Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp | 4 +- Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp | 6 +- Minecraft.World/AI/Goals/MakeLoveGoal.cpp | 8 +- Minecraft.World/AI/Goals/MeleeAttackGoal.cpp | 6 +- Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp | 8 +- .../AI/Goals/MoveThroughVillageGoal.cpp | 20 +- .../AI/Goals/MoveTowardsTargetGoal.cpp | 4 +- .../AI/Goals/NearestAttackableTargetGoal.cpp | 6 +- .../AI/Goals/NearestAttackableTargetGoal.h | 2 +- Minecraft.World/AI/Goals/OcelotAttackGoal.cpp | 4 +- Minecraft.World/AI/Goals/OfferFlowerGoal.cpp | 4 +- .../AI/Goals/OwnerHurtByTargetGoal.cpp | 4 +- .../AI/Goals/OwnerHurtTargetGoal.cpp | 4 +- Minecraft.World/AI/Goals/PanicGoal.cpp | 2 +- Minecraft.World/AI/Goals/PlayGoal.cpp | 8 +- Minecraft.World/AI/Goals/RangedAttackGoal.cpp | 4 +- .../AI/Goals/RestrictOpenDoorGoal.cpp | 6 +- .../AI/Goals/RunAroundLikeCrazyGoal.cpp | 4 +- Minecraft.World/AI/Goals/SitGoal.cpp | 4 +- Minecraft.World/AI/Goals/SwellGoal.cpp | 4 +- Minecraft.World/AI/Goals/TakeFlowerGoal.cpp | 4 +- Minecraft.World/AI/Goals/TargetGoal.cpp | 14 +- Minecraft.World/AI/Goals/TemptGoal.cpp | 6 +- .../AI/Goals/TradeWithPlayerGoal.cpp | 2 +- Minecraft.World/AI/Navigation/Node.cpp | 4 +- Minecraft.World/AI/Navigation/Path.cpp | 8 +- Minecraft.World/AI/Navigation/PathFinder.cpp | 28 +- .../AI/Navigation/PathNavigation.cpp | 26 +- Minecraft.World/AI/Navigation/RandomPos.cpp | 4 +- Minecraft.World/Blocks/AnvilTile.cpp | 2 +- Minecraft.World/Blocks/BaseEntityTile.cpp | 2 +- Minecraft.World/Blocks/BaseRailTile.cpp | 12 +- Minecraft.World/Blocks/BeaconTile.cpp | 2 +- Minecraft.World/Blocks/BedTile.cpp | 10 +- Minecraft.World/Blocks/BrewingStandTile.cpp | 10 +- Minecraft.World/Blocks/CactusTile.cpp | 4 +- Minecraft.World/Blocks/CakeTile.cpp | 6 +- Minecraft.World/Blocks/CauldronTile.cpp | 10 +- Minecraft.World/Blocks/ChestTile.cpp | 10 +- Minecraft.World/Blocks/CommandBlock.cpp | 10 +- Minecraft.World/Blocks/ComparatorTile.cpp | 2 +- Minecraft.World/Blocks/CropTile.cpp | 2 +- Minecraft.World/Blocks/DeadBushTile.cpp | 2 +- Minecraft.World/Blocks/DetectorRailTile.cpp | 2 +- Minecraft.World/Blocks/DiodeTile.cpp | 2 +- Minecraft.World/Blocks/DispenserTile.cpp | 12 +- Minecraft.World/Blocks/DropperTile.cpp | 8 +- .../Blocks/EnchantmentTableTile.cpp | 4 +- Minecraft.World/Blocks/EnderChestTile.cpp | 2 +- Minecraft.World/Blocks/FallingTile.cpp | 8 +- Minecraft.World/Blocks/FarmTile.cpp | 4 +- Minecraft.World/Blocks/FenceGateTile.cpp | 2 +- Minecraft.World/Blocks/FenceTile.cpp | 2 +- Minecraft.World/Blocks/FireTile.cpp | 2 +- Minecraft.World/Blocks/FlowerPotTile.cpp | 8 +- Minecraft.World/Blocks/FurnaceTile.cpp | 12 +- Minecraft.World/Blocks/GrassTile.cpp | 6 +- Minecraft.World/Blocks/HopperTile.cpp | 8 +- Minecraft.World/Blocks/HugeMushroomTile.cpp | 6 +- Minecraft.World/Blocks/IceTile.cpp | 2 +- Minecraft.World/Blocks/JukeboxTile.cpp | 10 +- Minecraft.World/Blocks/LeafTile.cpp | 6 +- Minecraft.World/Blocks/LiquidTile.cpp | 2 +- Minecraft.World/Blocks/Material.cpp | 66 +-- Minecraft.World/Blocks/MaterialColor.cpp | 28 +- Minecraft.World/Blocks/MelonTile.cpp | 2 +- Minecraft.World/Blocks/MobSpawner.cpp | 10 +- Minecraft.World/Blocks/MushroomPlantTile.cpp | 8 +- Minecraft.World/Blocks/MycelTile.cpp | 4 +- Minecraft.World/Blocks/NotGateTile.cpp | 2 +- Minecraft.World/Blocks/NoteBlockTile.cpp | 6 +- Minecraft.World/Blocks/PistonBaseTile.cpp | 18 +- .../Blocks/PistonExtensionTile.cpp | 6 +- .../Blocks/PistonMovingTileEntity.cpp | 20 +- Minecraft.World/Blocks/PortalTile.cpp | 4 +- Minecraft.World/Blocks/PressurePlateTile.cpp | 4 +- Minecraft.World/Blocks/PumpkinTile.cpp | 4 +- Minecraft.World/Blocks/RedStoneDustTile.cpp | 10 +- Minecraft.World/Blocks/SandStoneTile.cpp | 6 +- Minecraft.World/Blocks/SaplingPlantTile.cpp | 10 +- Minecraft.World/Blocks/SkullTile.cpp | 4 +- .../Blocks/SmoothStoneBrickTile.cpp | 2 +- Minecraft.World/Blocks/StairTile.cpp | 10 +- Minecraft.World/Blocks/StemTile.cpp | 4 +- Minecraft.World/Blocks/TallGrassPlantTile.cpp | 2 +- .../Blocks/TheEndPortalFrameTile.cpp | 4 +- Minecraft.World/Blocks/TheEndPortalTile.cpp | 2 +- Minecraft.World/Blocks/ThinFenceTile.cpp | 2 +- Minecraft.World/Blocks/Tile.cpp | 380 ++++++++-------- .../Blocks/TileEntities/BeaconTileEntity.cpp | 10 +- .../TileEntities/BrewingStandTileEntity.cpp | 36 +- .../Blocks/TileEntities/ChestTileEntity.cpp | 40 +- .../DaylightDetectorTileEntity.cpp | 4 +- .../TileEntities/DispenserTileEntity.cpp | 22 +- .../EnchantmentTableTileEntity.cpp | 2 +- .../Blocks/TileEntities/FurnaceTileEntity.cpp | 28 +- .../Blocks/TileEntities/HopperTileEntity.cpp | 60 +-- .../TileEntities/MobSpawnerTileEntity.cpp | 2 +- .../TileEntities/PistonPieceTileEntity.cpp | 2 +- .../Blocks/TileEntities/PotionBrewing.cpp | 10 +- .../Blocks/TileEntities/TileEntity.cpp | 16 +- Minecraft.World/Blocks/TntTile.cpp | 6 +- Minecraft.World/Blocks/TrapDoorTile.cpp | 6 +- Minecraft.World/Blocks/TripWireTile.cpp | 2 +- Minecraft.World/Blocks/VineTile.cpp | 4 +- Minecraft.World/Blocks/WallTile.cpp | 2 +- Minecraft.World/Blocks/WaterLilyTile.cpp | 2 +- Minecraft.World/Blocks/WoodTile.cpp | 2 +- Minecraft.World/Blocks/WorkbenchTile.cpp | 4 +- Minecraft.World/Commands/Command.cpp | 4 +- .../Commands/EnchantItemCommand.cpp | 12 +- Minecraft.World/Commands/GameModeCommand.cpp | 2 +- Minecraft.World/Commands/GiveItemCommand.cpp | 4 +- .../Containers/AbstractContainerMenu.cpp | 70 +-- Minecraft.World/Containers/AnvilMenu.cpp | 16 +- Minecraft.World/Containers/ArmorSlot.cpp | 8 +- Minecraft.World/Containers/BeaconMenu.cpp | 4 +- .../Containers/BrewingStandMenu.cpp | 6 +- .../Containers/ClientSideMerchant.cpp | 4 +- .../Containers/CompoundContainer.cpp | 4 +- Minecraft.World/Containers/ContainerMenu.cpp | 4 +- .../Containers/CraftingContainer.cpp | 4 +- Minecraft.World/Containers/CraftingMenu.cpp | 4 +- .../Containers/EnchantmentMenu.cpp | 10 +- Minecraft.World/Containers/FireworksMenu.cpp | 6 +- Minecraft.World/Containers/FurnaceMenu.cpp | 4 +- Minecraft.World/Containers/HopperMenu.cpp | 2 +- .../Containers/HorseInventoryMenu.cpp | 2 +- Minecraft.World/Containers/Inventory.cpp | 88 ++-- Minecraft.World/Containers/InventoryMenu.cpp | 6 +- .../Containers/MerchantContainer.cpp | 22 +- Minecraft.World/Containers/MerchantMenu.cpp | 6 +- Minecraft.World/Containers/MerchantRecipe.cpp | 10 +- .../Containers/MerchantRecipeList.cpp | 20 +- .../Containers/MerchantResultSlot.cpp | 8 +- .../Containers/RepairResultSlot.cpp | 2 +- .../Containers/ResultContainer.cpp | 4 +- Minecraft.World/Containers/ResultSlot.cpp | 4 +- .../Containers/SimpleContainer.cpp | 12 +- Minecraft.World/Containers/Slot.cpp | 22 +- Minecraft.World/Containers/TrapMenu.cpp | 2 +- .../Core/ItemDispenseBehaviors.cpp | 2 +- .../Enchantments/DamageEnchantment.cpp | 2 +- Minecraft.World/Enchantments/Enchantment.cpp | 48 +-- .../Enchantments/EnchantmentCategory.cpp | 8 +- .../Enchantments/EnchantmentHelper.cpp | 34 +- .../Enchantments/ProtectionEnchantment.cpp | 2 +- .../Enchantments/ThornsEnchantment.cpp | 4 +- Minecraft.World/Entities/Enemy.cpp | 2 +- Minecraft.World/Entities/Entity.cpp | 42 +- .../Entities/EntityDamageSource.cpp | 6 +- Minecraft.World/Entities/EntityPos.cpp | 2 +- Minecraft.World/Entities/EntitySelector.cpp | 4 +- .../Entities/FireworksRocketEntity.cpp | 16 +- Minecraft.World/Entities/HangingEntity.cpp | 10 +- .../Entities/IndirectEntityDamageSource.cpp | 6 +- Minecraft.World/Entities/ItemEntity.cpp | 12 +- Minecraft.World/Entities/LargeFireball.cpp | 2 +- .../Entities/LeashFenceKnotEntity.cpp | 10 +- Minecraft.World/Entities/LivingEntity.cpp | 72 ++-- Minecraft.World/Entities/LivingEntity.h | 2 +- .../Entities/MinecartContainer.cpp | 12 +- Minecraft.World/Entities/MinecartFurnace.cpp | 2 +- Minecraft.World/Entities/MinecartRideable.cpp | 4 +- Minecraft.World/Entities/Mob.cpp | 78 ++-- Minecraft.World/Entities/Mob.h | 2 +- Minecraft.World/Entities/MobCategory.cpp | 14 +- Minecraft.World/Entities/MobEffect.cpp | 24 +- Minecraft.World/Entities/Mobs/AgeableMob.cpp | 6 +- Minecraft.World/Entities/Mobs/Animal.cpp | 20 +- Minecraft.World/Entities/Mobs/Arrow.cpp | 26 +- Minecraft.World/Entities/Mobs/Bat.cpp | 10 +- Minecraft.World/Entities/Mobs/Blaze.cpp | 2 +- Minecraft.World/Entities/Mobs/Boat.cpp | 18 +- Minecraft.World/Entities/Mobs/Cow.cpp | 2 +- Minecraft.World/Entities/Mobs/Creeper.cpp | 8 +- .../Entities/Mobs/DragonFireball.cpp | 2 +- .../Entities/Mobs/EnderCrystal.cpp | 4 +- Minecraft.World/Entities/Mobs/EnderDragon.cpp | 84 ++-- Minecraft.World/Entities/Mobs/EnderDragon.h | 2 +- Minecraft.World/Entities/Mobs/EnderMan.cpp | 14 +- Minecraft.World/Entities/Mobs/EntityHorse.cpp | 62 +-- .../Entities/Mobs/ExperienceOrb.cpp | 4 +- Minecraft.World/Entities/Mobs/Fireball.cpp | 14 +- Minecraft.World/Entities/Mobs/FishingHook.cpp | 18 +- Minecraft.World/Entities/Mobs/Ghast.cpp | 10 +- Minecraft.World/Entities/Mobs/ItemFrame.cpp | 18 +- Minecraft.World/Entities/Mobs/Minecart.cpp | 48 +-- Minecraft.World/Entities/Mobs/MushroomCow.cpp | 4 +- Minecraft.World/Entities/Mobs/Ocelot.cpp | 6 +- Minecraft.World/Entities/Mobs/Painting.cpp | 6 +- Minecraft.World/Entities/Mobs/Pig.cpp | 8 +- Minecraft.World/Entities/Mobs/PigZombie.cpp | 4 +- .../Entities/Mobs/SharedMonsterAttributes.cpp | 4 +- Minecraft.World/Entities/Mobs/Sheep.cpp | 4 +- Minecraft.World/Entities/Mobs/Silverfish.cpp | 8 +- Minecraft.World/Entities/Mobs/Skeleton.cpp | 16 +- Minecraft.World/Entities/Mobs/Slime.cpp | 4 +- .../Entities/Mobs/SmallFireball.cpp | 2 +- Minecraft.World/Entities/Mobs/Snowball.cpp | 2 +- Minecraft.World/Entities/Mobs/Spider.cpp | 8 +- Minecraft.World/Entities/Mobs/ThrownEgg.cpp | 2 +- .../Entities/Mobs/ThrownEnderPearl.cpp | 4 +- .../Entities/Mobs/ThrownPotion.cpp | 12 +- Minecraft.World/Entities/Mobs/Villager.cpp | 32 +- .../Entities/Mobs/VillagerGolem.cpp | 8 +- Minecraft.World/Entities/Mobs/Witch.cpp | 8 +- Minecraft.World/Entities/Mobs/WitherBoss.cpp | 12 +- Minecraft.World/Entities/Mobs/Wolf.cpp | 24 +- Minecraft.World/Entities/Mobs/Zombie.cpp | 26 +- Minecraft.World/Entities/Monster.cpp | 2 +- Minecraft.World/Entities/Monster.h | 2 +- Minecraft.World/Entities/PathfinderMob.cpp | 30 +- Minecraft.World/Entities/SyncedEntityData.cpp | 28 +- Minecraft.World/Entities/TamableAnimal.cpp | 6 +- Minecraft.World/Entities/Throwable.cpp | 14 +- Minecraft.World/Entities/WitherSkull.cpp | 4 +- Minecraft.World/IO/Files/ConsoleSaveFile.h | 4 +- .../IO/Files/ConsoleSaveFileConverter.cpp | 2 +- .../IO/Files/ConsoleSaveFileInputStream.cpp | 4 +- .../IO/Files/ConsoleSaveFileOriginal.cpp | 58 +-- .../IO/Files/ConsoleSaveFileOriginal.h | 4 +- .../IO/Files/ConsoleSaveFileOutputStream.cpp | 4 +- .../IO/Files/ConsoleSaveFileSplit.cpp | 68 +-- .../IO/Files/ConsoleSaveFileSplit.h | 8 +- Minecraft.World/IO/Files/File.cpp | 12 +- Minecraft.World/IO/Files/FileHeader.cpp | 8 +- Minecraft.World/IO/Files/FileInputStream.cpp | 18 +- Minecraft.World/IO/Files/FileOutputStream.cpp | 18 +- Minecraft.World/IO/NBT/ByteArrayTag.h | 4 +- Minecraft.World/IO/NBT/CompoundTag.h | 2 +- Minecraft.World/IO/NBT/IntArrayTag.h | 4 +- Minecraft.World/IO/NBT/NbtIO.cpp | 4 +- Minecraft.World/IO/NBT/NbtSlotFile.cpp | 8 +- Minecraft.World/IO/NBT/Tag.cpp | 4 +- .../IO/Streams/BufferedOutputStream.cpp | 8 +- .../IO/Streams/ByteArrayInputStream.cpp | 2 +- .../IO/Streams/ByteArrayOutputStream.cpp | 2 +- Minecraft.World/IO/Streams/Compression.cpp | 14 +- .../IO/Streams/DataInputStream.cpp | 64 +-- .../IO/Streams/DataOutputStream.cpp | 20 +- Minecraft.World/IO/Streams/InputStream.cpp | 2 +- Minecraft.World/Items/ArmorItem.cpp | 10 +- Minecraft.World/Items/BoatItem.cpp | 4 +- Minecraft.World/Items/BottleItem.cpp | 4 +- Minecraft.World/Items/BowItem.cpp | 2 +- Minecraft.World/Items/BucketItem.cpp | 6 +- Minecraft.World/Items/ClockItem.cpp | 4 +- Minecraft.World/Items/CompassItem.cpp | 4 +- Minecraft.World/Items/DyePowderItem.cpp | 8 +- Minecraft.World/Items/EnchantedBookItem.cpp | 6 +- Minecraft.World/Items/EnderEyeItem.cpp | 10 +- Minecraft.World/Items/EnderPearlItem.cpp | 2 +- Minecraft.World/Items/FireChargeItem.cpp | 2 +- Minecraft.World/Items/FireworksChargeItem.cpp | 8 +- Minecraft.World/Items/FireworksItem.cpp | 4 +- Minecraft.World/Items/FishingRodItem.cpp | 4 +- Minecraft.World/Items/HangingEntityItem.cpp | 2 +- Minecraft.World/Items/HatchetItem.cpp | 4 +- Minecraft.World/Items/Item.cpp | 348 +++++++-------- Minecraft.World/Items/ItemInstance.cpp | 90 ++-- Minecraft.World/Items/LeashItem.cpp | 8 +- Minecraft.World/Items/MapItem.cpp | 8 +- Minecraft.World/Items/NameTagItem.cpp | 2 +- Minecraft.World/Items/PickaxeItem.cpp | 2 +- Minecraft.World/Items/PotionItem.cpp | 36 +- Minecraft.World/Items/RecordingItem.cpp | 2 +- Minecraft.World/Items/SaddleItem.cpp | 2 +- Minecraft.World/Items/ShovelItem.cpp | 2 +- Minecraft.World/Items/SignItem.cpp | 2 +- Minecraft.World/Items/SpawnEggItem.cpp | 20 +- .../Items/TileItems/ColoredTileItem.cpp | 6 +- Minecraft.World/Items/TileItems/SkullItem.cpp | 2 +- Minecraft.World/Items/TileItems/TileItem.cpp | 8 +- .../Items/TileItems/WaterLilyTileItem.cpp | 4 +- Minecraft.World/Level/BaseMobSpawner.cpp | 50 +-- Minecraft.World/Level/BlockReplacements.cpp | 2 +- Minecraft.World/Level/ChunkSource.h | 2 +- Minecraft.World/Level/CustomLevelSource.cpp | 34 +- .../Level/Dimensions/Dimension.cpp | 8 +- .../Level/Dimensions/SkyIslandDimension.cpp | 2 +- .../Level/Dimensions/TheEndDimension.cpp | 2 +- Minecraft.World/Level/Events/VillageSiege.cpp | 8 +- Minecraft.World/Level/Explosion.cpp | 10 +- Minecraft.World/Level/Explosion.h | 2 +- Minecraft.World/Level/Level.cpp | 182 ++++---- Minecraft.World/Level/Level.h | 4 +- Minecraft.World/Level/LevelChunk.cpp | 126 +++--- Minecraft.World/Level/LevelData.cpp | 8 +- Minecraft.World/Level/RandomLevelSource.cpp | 22 +- .../Level/Storage/CompressedTileStorage.cpp | 28 +- Minecraft.World/Level/Storage/DataLayer.cpp | 2 +- .../Level/Storage/DirectoryLevelStorage.cpp | 16 +- .../Storage/DirectoryLevelStorageSource.cpp | 2 +- Minecraft.World/Level/Storage/EntityIO.cpp | 20 +- .../Level/Storage/LevelSettings.cpp | 8 +- Minecraft.World/Level/Storage/LevelStorage.h | 2 +- Minecraft.World/Level/Storage/LevelType.cpp | 14 +- .../Level/Storage/MapItemSavedData.cpp | 8 +- .../Level/Storage/McRegionChunkStorage.cpp | 24 +- .../Level/Storage/McRegionLevelStorage.cpp | 8 +- .../Storage/McRegionLevelStorageSource.cpp | 4 +- .../Level/Storage/MemoryChunkStorage.cpp | 2 +- .../Level/Storage/MemoryLevelStorage.cpp | 4 +- .../Storage/MemoryLevelStorageSource.cpp | 2 +- .../Level/Storage/MockedLevelStorage.cpp | 6 +- .../Level/Storage/MockedLevelStorage.h | 2 +- .../Level/Storage/OldChunkStorage.cpp | 22 +- .../Level/Storage/PortalForcer.cpp | 2 +- .../Level/Storage/ReadOnlyChunkCache.cpp | 8 +- Minecraft.World/Level/Storage/Region.cpp | 22 +- Minecraft.World/Level/Storage/RegionFile.cpp | 12 +- .../Level/Storage/RegionFileCache.cpp | 6 +- .../Level/Storage/SavedDataStorage.cpp | 16 +- .../Level/Storage/SparseDataStorage.cpp | 2 +- .../Level/Storage/SparseLightStorage.cpp | 2 +- Minecraft.World/Level/Storage/ZoneFile.cpp | 8 +- .../Level/Storage/ZonedChunkStorage.cpp | 16 +- Minecraft.World/Level/TickNextTickData.cpp | 2 +- Minecraft.World/Level/WaterLevelChunk.cpp | 2 +- Minecraft.World/Network/Connection.cpp | 40 +- .../Network/Packets/AddMobPacket.cpp | 10 +- .../Network/Packets/AddPlayerPacket.cpp | 14 +- .../Network/Packets/AwardStatPacket.cpp | 8 +- .../Packets/ContainerSetContentPacket.cpp | 2 +- .../Packets/ContainerSetSlotPacket.cpp | 2 +- .../Network/Packets/CustomPayloadPacket.cpp | 6 +- .../Network/Packets/ExplodePacket.cpp | 4 +- .../Network/Packets/GameCommandPacket.cpp | 6 +- .../Network/Packets/LoginPacket.cpp | 10 +- .../Network/Packets/MoveEntityPacket.cpp | 2 +- .../Network/Packets/MoveEntityPacketSmall.cpp | 2 +- Minecraft.World/Network/Packets/Packet.cpp | 10 +- .../Network/Packets/PlayerInfoPacket.cpp | 4 +- .../Network/Packets/PreLoginPacket.cpp | 6 +- .../Network/Packets/RespawnPacket.cpp | 10 +- .../Packets/SetDisplayObjectivePacket.cpp | 2 +- .../Network/Packets/SetEntityDataPacket.cpp | 2 +- .../Network/Packets/SetEntityLinkPacket.cpp | 2 +- .../Network/Packets/SetEquippedItemPacket.cpp | 2 +- .../Network/Packets/SetPlayerTeamPacket.cpp | 2 +- .../Packets/TextureAndGeometryPacket.cpp | 16 +- .../Network/Packets/TexturePacket.cpp | 4 +- .../Network/Packets/TileEntityDataPacket.cpp | 2 +- Minecraft.World/Network/Socket.cpp | 38 +- Minecraft.World/Platform/System.cpp | 2 +- .../Platform/x64headers/extraX64.h | 2 +- Minecraft.World/Player/Player.cpp | 132 +++--- .../Player/PlayerEnderChestContainer.cpp | 6 +- Minecraft.World/Recipes/ArmorDyeRecipe.cpp | 18 +- Minecraft.World/Recipes/FireworksRecipe.cpp | 14 +- Minecraft.World/Recipes/FurnaceRecipes.cpp | 4 +- Minecraft.World/Recipes/Recipes.cpp | 28 +- Minecraft.World/Recipes/Recipes.h | 2 +- Minecraft.World/Recipes/ShapedRecipy.cpp | 16 +- Minecraft.World/Recipes/ShapelessRecipy.cpp | 4 +- Minecraft.World/Scores/PlayerTeam.cpp | 2 +- Minecraft.World/Scores/Scoreboard.cpp | 44 +- Minecraft.World/Scores/Team.cpp | 2 +- Minecraft.World/Stats/Achievement.cpp | 2 +- Minecraft.World/Stats/Achievements.cpp | 158 +++---- Minecraft.World/Stats/CommonStats.cpp | 22 +- Minecraft.World/Stats/GenericStats.cpp | 126 +++--- Minecraft.World/Stats/Stats.cpp | 50 +-- Minecraft.World/Util/ArrayWithLength.h | 6 +- Minecraft.World/Util/BinaryHeap.cpp | 6 +- Minecraft.World/Util/BoundingBox.cpp | 2 +- Minecraft.World/Util/CombatEntry.cpp | 6 +- Minecraft.World/Util/CombatTracker.cpp | 42 +- Minecraft.World/Util/DamageSource.cpp | 6 +- Minecraft.World/Util/Hasher.cpp | 2 +- Minecraft.World/Util/HtmlString.cpp | 2 +- Minecraft.World/Util/Mth.cpp | 6 +- Minecraft.World/Util/PortableFileIO.h | 6 +- Minecraft.World/Util/Pos.cpp | 4 +- Minecraft.World/Util/WeighedRandom.cpp | 4 +- Minecraft.World/Util/libdivide.h | 12 +- Minecraft.World/WorldGen/Biomes/Biome.cpp | 52 +-- .../WorldGen/Biomes/BiomeCache.cpp | 2 +- .../WorldGen/Biomes/BiomeDecorator.cpp | 14 +- .../WorldGen/Biomes/BiomeSource.cpp | 32 +- .../WorldGen/Biomes/FixedBiomeSource.cpp | 14 +- .../WorldGen/Features/BasicTreeFeature.cpp | 6 +- .../WorldGen/Features/BirchFeature.cpp | 2 +- .../WorldGen/Features/BonusChestFeature.cpp | 2 +- .../WorldGen/Features/CaveFeature.cpp | 2 +- .../WorldGen/Features/FlowerFeature.cpp | 2 +- .../WorldGen/Features/LakeFeature.cpp | 4 +- .../WorldGen/Features/MegaTreeFeature.cpp | 2 +- .../WorldGen/Features/MineShaftFeature.cpp | 2 +- .../WorldGen/Features/MonsterRoomFeature.cpp | 4 +- .../WorldGen/Features/NetherBridgeFeature.cpp | 6 +- .../WorldGen/Features/OreFeature.cpp | 6 +- .../WorldGen/Features/PineFeature.cpp | 2 +- .../Features/RandomScatteredLargeFeature.cpp | 8 +- .../WorldGen/Features/ReedsFeature.cpp | 2 +- .../WorldGen/Features/SandFeature.cpp | 2 +- .../WorldGen/Features/SpringFeature.cpp | 2 +- .../WorldGen/Features/SpruceFeature.cpp | 2 +- .../WorldGen/Features/StrongholdFeature.cpp | 10 +- .../WorldGen/Features/StructureFeature.cpp | 18 +- .../WorldGen/Features/SwampTreeFeature.cpp | 2 +- .../WorldGen/Features/TreeFeature.cpp | 2 +- .../WorldGen/Features/VillageFeature.cpp | 4 +- .../WorldGen/Flat/FlatGeneratorInfo.cpp | 6 +- .../WorldGen/Layers/BiomeOverrideLayer.cpp | 12 +- Minecraft.World/WorldGen/Layers/Layer.cpp | 2 +- Minecraft.World/WorldGen/Noise/FastNoise.cpp | 2 +- .../WorldGen/Noise/PerlinNoise.cpp | 2 +- .../WorldGen/Noise/PerlinSimplexNoise.cpp | 4 +- .../WorldGen/Sources/FlatLevelSource.cpp | 6 +- .../WorldGen/Sources/HellFlatLevelSource.cpp | 6 +- .../Sources/HellRandomLevelSource.cpp | 8 +- .../Sources/TheEndLevelRandomLevelSource.cpp | 8 +- .../WorldGen/StructureFeatureIO.cpp | 8 +- .../WorldGen/Structures/MineShaftPieces.cpp | 36 +- .../Structures/NetherBridgePieces.cpp | 132 +++--- .../Structures/ScatteredFeaturePieces.cpp | 4 +- .../WorldGen/Structures/StrongholdPieces.cpp | 132 +++--- .../WorldGen/Structures/StructurePiece.cpp | 16 +- .../WorldGen/Structures/StructureStart.cpp | 4 +- .../WorldGen/Structures/Village.cpp | 10 +- .../WorldGen/Structures/VillagePieces.cpp | 90 ++-- .../WorldGen/Structures/Villages.cpp | 6 +- 752 files changed, 5396 insertions(+), 5396 deletions(-) diff --git a/Minecraft.Client/Commands/TeleportCommand.cpp b/Minecraft.Client/Commands/TeleportCommand.cpp index 8919ec833..15a3dd445 100644 --- a/Minecraft.Client/Commands/TeleportCommand.cpp +++ b/Minecraft.Client/Commands/TeleportCommand.cpp @@ -27,7 +27,7 @@ void TeleportCommand::execute(std::shared_ptr source, std::shared_ptr destination = players->getPlayer(destinationID); - if (subject != NULL && destination != NULL && + if (subject != nullptr && destination != nullptr && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive()) { subject->ride(nullptr); diff --git a/Minecraft.Client/GameState/CreativeMode.cpp b/Minecraft.Client/GameState/CreativeMode.cpp index 54632e602..d36b340f9 100644 --- a/Minecraft.Client/GameState/CreativeMode.cpp +++ b/Minecraft.Client/GameState/CreativeMode.cpp @@ -35,7 +35,7 @@ void CreativeMode::adjustPlayer(std::shared_ptr player) { enableCreativeForPlayer(player); for (int i = 0; i < 9; i++) { - if (player->inventory->items[i] == NULL) { + if (player->inventory->items[i] == nullptr) { player->inventory->items[i] = std::shared_ptr( new ItemInstance(User::allowedTiles[i])); } else { @@ -61,7 +61,7 @@ bool CreativeMode::useItemOn(std::shared_ptr player, Level* level, if (t > 0) { if (Tile::tiles[t]->use(level, x, y, z, player)) return true; } - if (item == NULL) return false; + if (item == nullptr) return false; int aux = item->getAuxValue(); int count = item->count; bool success = item->useOn(player, level, x, y, z, face); diff --git a/Minecraft.Client/GameState/CreativeMode.h b/Minecraft.Client/GameState/CreativeMode.h index f98fd38e3..bd166cf23 100644 --- a/Minecraft.Client/GameState/CreativeMode.h +++ b/Minecraft.Client/GameState/CreativeMode.h @@ -16,7 +16,7 @@ public: virtual bool useItemOn(std::shared_ptr player, Level* level, std::shared_ptr item, int x, int y, int z, int face, bool bTestUseOnOnly = false, - bool* pbUsedItem = NULL); + bool* pbUsedItem = nullptr); virtual void startDestroyBlock(int x, int y, int z, int face); virtual void continueDestroyBlock(int x, int y, int z, int face); virtual void stopDestroyBlock(); diff --git a/Minecraft.Client/GameState/GameMode.cpp b/Minecraft.Client/GameState/GameMode.cpp index 2b1790ca3..432687223 100644 --- a/Minecraft.Client/GameState/GameMode.cpp +++ b/Minecraft.Client/GameState/GameMode.cpp @@ -20,7 +20,7 @@ void GameMode::initLevel(Level* level) {} bool GameMode::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; // 4J - Let the rendering side of thing know we are about to destroy the // tile, so we can synchronise collision with async render data upates. @@ -37,7 +37,7 @@ bool GameMode::destroyBlock(int x, int y, int z, int face) { level->getChunkAt(x, z)->recalcHeightmapOnly(); bool changed = level->setTile(x, y, z, 0); - if (oldTile != NULL && changed) { + if (oldTile != nullptr && changed) { oldTile->destroy(level, x, y, z, data); } return changed; @@ -91,7 +91,7 @@ void GameMode::adjustPlayer(std::shared_ptr player) {} // } // } // -// if (item == NULL) return false; +// if (item == nullptr) return false; // return item->useOn(player, level, x, y, z, face, bTestUseOnOnly); // } diff --git a/Minecraft.Client/GameState/GameMode.h b/Minecraft.Client/GameState/GameMode.h index e1c14b467..f253849af 100644 --- a/Minecraft.Client/GameState/GameMode.h +++ b/Minecraft.Client/GameState/GameMode.h @@ -35,7 +35,7 @@ public: virtual bool useItemOn(std::shared_ptr player, Level* level, std::shared_ptr item, int x, int y, int z, int face, bool bTestUseOnOnly = false, - bool* pbUsedItem = NULL) = 0; + bool* pbUsedItem = nullptr) = 0; virtual std::shared_ptr createPlayer(Level* level); virtual bool interact(std::shared_ptr player, @@ -68,5 +68,5 @@ public: // 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; } }; diff --git a/Minecraft.Client/GameState/Options.cpp b/Minecraft.Client/GameState/Options.cpp index 9013e52b6..082afb702 100644 --- a/Minecraft.Client/GameState/Options.cpp +++ b/Minecraft.Client/GameState/Options.cpp @@ -155,8 +155,8 @@ void Options::init() { keyMappings[12] = keyPickItem; keyMappings[13] = keyToggleFog; - minecraft = NULL; - // optionsFile = NULL; + minecraft = nullptr; + // optionsFile = nullptr; difficulty = 2; hideGui = false; @@ -370,7 +370,7 @@ void Options::load() { std::wstring line = L""; while ((line = br->readLine()) != - L"") // 4J - was check against NULL - do we need to distinguish + L"") // 4J - was check against nullptr - do we need to distinguish // between empty lines and a fail here? { // 4J - removed try/catch diff --git a/Minecraft.Client/GameState/SurvivalMode.cpp b/Minecraft.Client/GameState/SurvivalMode.cpp index cbbdba9c0..69aa0b251 100644 --- a/Minecraft.Client/GameState/SurvivalMode.cpp +++ b/Minecraft.Client/GameState/SurvivalMode.cpp @@ -20,7 +20,7 @@ SurvivalMode::SurvivalMode(Minecraft* minecraft) : GameMode(minecraft) { destroyDelay = 0; if (ClientConstants::IS_DEMO_VERSION) { - if (dynamic_cast(this) == NULL) { + if (dynamic_cast(this) == nullptr) { assert(false); // throw new IllegalStateException("Invalid game mode"); // // 4J - removed @@ -55,7 +55,7 @@ bool SurvivalMode::destroyBlock(int x, int y, int z, int face) { std::shared_ptr item = minecraft->player->getSelectedItem(); bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]); - if (item != NULL) { + if (item != nullptr) { item->mineBlock(t, x, y, z, minecraft->player); if (item->count == 0) { minecraft->player->removeSelectedItem(); @@ -98,7 +98,7 @@ void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face) { destroyProgress += tile->getDestroyProgress(minecraft->player); if (destroyTicks % 4 == 0) { - if (tile != NULL) { + if (tile != nullptr) { minecraft->soundEngine->play( tile->soundType->getStepSound(), x + 0.5f, y + 0.5f, z + 0.5f, (tile->soundType->getVolume() + 1) / 8, @@ -164,7 +164,7 @@ bool SurvivalMode::useItemOn(std::shared_ptr player, Level* level, if (t > 0) { if (Tile::tiles[t]->use(level, x, y, z, player)) return true; } - if (item == NULL) return false; + if (item == nullptr) return false; return item->useOn(player, level, x, y, z, face); } diff --git a/Minecraft.Client/GameState/SurvivalMode.h b/Minecraft.Client/GameState/SurvivalMode.h index 406cdcc1e..b7e194fa1 100644 --- a/Minecraft.Client/GameState/SurvivalMode.h +++ b/Minecraft.Client/GameState/SurvivalMode.h @@ -29,6 +29,6 @@ public: virtual bool useItemOn(std::shared_ptr player, Level* level, std::shared_ptr item, int x, int y, int z, int face, bool bTestUseOnOnly = false, - bool* pbUsedItem = NULL); + bool* pbUsedItem = nullptr); virtual bool hasExperience(); }; \ No newline at end of file diff --git a/Minecraft.Client/Level/DerivedServerLevel.cpp b/Minecraft.Client/Level/DerivedServerLevel.cpp index 0038111b3..7aa81864f 100644 --- a/Minecraft.Client/Level/DerivedServerLevel.cpp +++ b/Minecraft.Client/Level/DerivedServerLevel.cpp @@ -12,7 +12,7 @@ DerivedServerLevel::DerivedServerLevel( // delete the current one if (this->savedDataStorage) { delete this->savedDataStorage; - this->savedDataStorage = NULL; + this->savedDataStorage = nullptr; } this->savedDataStorage = wrapped->savedDataStorage; levelData = new DerivedLevelData(wrapped->getLevelData()); @@ -21,7 +21,7 @@ DerivedServerLevel::DerivedServerLevel( DerivedServerLevel::~DerivedServerLevel() { // we didn't allocate savedDataStorage here, so we don't want the level // destructor to delete it - this->savedDataStorage = NULL; + this->savedDataStorage = nullptr; } void DerivedServerLevel::saveLevelData() { diff --git a/Minecraft.Client/Level/MultiPlayerLevel.cpp b/Minecraft.Client/Level/MultiPlayerLevel.cpp index 071f81fa2..22bdbb304 100644 --- a/Minecraft.Client/Level/MultiPlayerLevel.cpp +++ b/Minecraft.Client/Level/MultiPlayerLevel.cpp @@ -45,7 +45,7 @@ MultiPlayerLevel::MultiPlayerLevel(ClientConnection* connection, levelData->setInitialized(true); } - if (connection != NULL) { + if (connection != nullptr) { this->connections.push_back(connection); } this->difficulty = difficulty; @@ -57,7 +57,7 @@ MultiPlayerLevel::MultiPlayerLevel(ClientConnection* connection, // 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; } unshareCheckX = 0; @@ -73,7 +73,7 @@ MultiPlayerLevel::MultiPlayerLevel(ClientConnection* connection, 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) { @@ -459,7 +459,7 @@ void MultiPlayerLevel::entityRemoved(std::shared_ptr e) { void MultiPlayerLevel::putEntity(int id, std::shared_ptr e) { std::shared_ptr old = getEntity(id); - if (old != NULL) { + if (old != nullptr) { removeEntity(old); } @@ -626,7 +626,7 @@ void MultiPlayerLevel::disconnect(bool sendDisconnect /*= true*/) { Tickable* MultiPlayerLevel::makeSoundUpdater( std::shared_ptr minecart) { - return NULL; // new MinecartSoundUpdater(minecraft->soundEngine, minecart, + return nullptr; // new MinecartSoundUpdater(minecraft->soundEngine, minecart, // minecraft->player); } @@ -730,7 +730,7 @@ void MultiPlayerLevel::animateTickDoWork() { } } - Minecraft::GetInstance()->animateTickLevel = NULL; + Minecraft::GetInstance()->animateTickLevel = nullptr; delete animateRandom; chunksToAnimate.clear(); @@ -850,7 +850,7 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals() { while (it != entities.end()) { std::shared_ptr e = *it; // entities.at(i); - if (e->riding != NULL) { + if (e->riding != nullptr) { if (e->riding->removed || e->riding->rider.lock() != e) { e->riding->rider = std::weak_ptr(); e->riding = nullptr; @@ -915,11 +915,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 || + if (Tile::tiles[tileId] == nullptr || !Tile::tiles[tileId]->isEntityTile()) { tileEntityList[i] = tileEntityList.back(); tileEntityList.pop_back(); diff --git a/Minecraft.Client/Level/ServerLevel.cpp b/Minecraft.Client/Level/ServerLevel.cpp index 00e943a91..065db15d6 100644 --- a/Minecraft.Client/Level/ServerLevel.cpp +++ b/Minecraft.Client/Level/ServerLevel.cpp @@ -43,7 +43,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); m_updateThread->Run(); @@ -141,7 +141,7 @@ ServerLevel::ServerLevel(MinecraftServer* server, // shared_ptr scoreboardSaveData = // std::dynamic_pointer_cast( // savedDataStorage->get(typeid(ScoreboardSaveData), - // ScoreboardSaveData::FILE_ID) ); if (scoreboardSaveData == NULL) + // ScoreboardSaveData::FILE_ID) ); if (scoreboardSaveData == nullptr) //{ // scoreboardSaveData = shared_ptr( new // ScoreboardSaveData() ); @@ -292,7 +292,7 @@ void ServerLevel::tick() { { // app.DebugPrintf("Incremental save\n"); PIXBeginNamedEvent(0, "Incremental save"); - save(false, NULL); + save(false, nullptr); PIXEndNamedEvent(); } @@ -351,7 +351,7 @@ Biome::MobSpawnerData* ServerLevel::getRandomMobSpawnAt( MobCategory* mobCategory, int x, int y, int z) { std::vector* mobList = getChunkSource()->getMobsAt(mobCategory, x, y, z); - if (mobList == NULL || mobList->empty()) return NULL; + if (mobList == nullptr || mobList->empty()) return nullptr; return (Biome::MobSpawnerData*)WeighedRandom::getRandomItem( random, (std::vector*)mobList); @@ -462,7 +462,7 @@ void ServerLevel::tickTiles() { int z = m_updateTileZ[iLev][i]; 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; else ++otherTicks;*/ @@ -759,7 +759,7 @@ void ServerLevel::tick(std::shared_ptr e, bool actual) { e->remove(); } if (!server->isNpcsEnabled() && - (std::dynamic_pointer_cast(e) != NULL)) { + (std::dynamic_pointer_cast(e) != nullptr)) { e->remove(); } Level::tick(e, actual); @@ -838,7 +838,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; delete findBiome; @@ -888,7 +888,7 @@ void ServerLevel::generateBonusItemsNearSpawn() { std::shared_ptr chest = std::dynamic_pointer_cast( getTileEntity(x, y, z)); - if (chest != NULL) { + if (chest != nullptr) { if (chest->isBonusChest) { return; } @@ -929,7 +929,7 @@ void ServerLevel::save(bool force, ProgressListener* progressListener, // 4J-PB - check that saves are enabled if (StorageManager.GetSaveDisabled()) return; - if (progressListener != NULL) { + if (progressListener != nullptr) { if (bAutosave) { progressListener->progressStartNoAbort( IDS_PROGRESS_AUTOSAVING_LEVEL); @@ -941,7 +941,7 @@ void ServerLevel::save(bool force, ProgressListener* progressListener, saveLevelData(); PIXEndNamedEvent(); - if (progressListener != NULL) + if (progressListener != nullptr) progressListener->progressStage(IDS_PROGRESS_SAVING_CHUNKS); { @@ -967,7 +967,7 @@ void ServerLevel::save(bool force, ProgressListener* progressListener, // if( force && !isClientSide ) //{ - // if (progressListener != NULL) + // if (progressListener != nullptr) // progressListener->progressStage(IDS_PROGRESS_SAVING_TO_DISC); // levelStorage->flushSaveFile(); // } @@ -992,7 +992,7 @@ void ServerLevel::saveToDisc(ProgressListener* progressListener, } } - if (progressListener != NULL) + if (progressListener != nullptr) progressListener->progressStage(IDS_PROGRESS_SAVING_TO_DISC); levelStorage->flushSaveFile(autosave); } @@ -1008,7 +1008,7 @@ void ServerLevel::entityAdded(std::shared_ptr e) { Level::entityAdded(e); entitiesById[e->entityId] = e; std::vector >* es = e->getSubEntities(); - if (es != NULL) { + if (es != nullptr) { // for (int i = 0; i < es.length; i++) for (AUTO_VAR(it, es->begin()); it != es->end(); ++it) { entitiesById.insert( @@ -1022,7 +1022,7 @@ void ServerLevel::entityRemoved(std::shared_ptr e) { Level::entityRemoved(e); entitiesById.erase(e->entityId); std::vector >* es = e->getSubEntities(); - if (es != NULL) { + if (es != nullptr) { // for (int i = 0; i < es.length; i++) for (AUTO_VAR(it, es->begin()); it != es->end(); ++it) { entitiesById.erase((*it)->entityId); @@ -1078,14 +1078,14 @@ std::shared_ptr ServerLevel::explode(std::shared_ptr source, bool knockbackOnly = false; if (sentTo.size()) { INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer(); - if (thisPlayer == NULL) { + if (thisPlayer == nullptr) { continue; } else { for (unsigned int j = 0; j < sentTo.size(); j++) { std::shared_ptr player2 = sentTo[j]; INetworkPlayer* otherPlayer = player2->connection->getNetworkPlayer(); - if (otherPlayer != NULL && + if (otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer)) { knockbackOnly = true; } @@ -1530,7 +1530,7 @@ int ServerLevel::runUpdate(void* lpParam) { // 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 && + if (Tile::tiles[id] != nullptr && Tile::tiles[id]->isTicking() && Tile::tiles[id]->shouldTileTick( m_level[iLev], x + (cx * 16), y, z + (cz * 16))) { diff --git a/Minecraft.Client/Level/ServerLevelListener.cpp b/Minecraft.Client/Level/ServerLevelListener.cpp index a421a76db..668e90392 100644 --- a/Minecraft.Client/Level/ServerLevelListener.cpp +++ b/Minecraft.Client/Level/ServerLevelListener.cpp @@ -123,7 +123,7 @@ void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, for (AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it) { std::shared_ptr p = *it; - if (p == NULL || p->level != level || p->entityId == id) continue; + 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; diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 58677c90a..a30857dda 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -84,7 +84,7 @@ // 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_t Minecraft::frameTimes[512]; int64_t Minecraft::tickTimes[512]; int Minecraft::frameTimePos = 0; @@ -100,34 +100,34 @@ 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; exitingWorldRightNow = 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 @@ -138,20 +138,20 @@ Minecraft::Minecraft(Component* mouseComponent, Canvas* parent, 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 @@ -168,7 +168,7 @@ Minecraft::Minecraft(Component* mouseComponent, Canvas* parent, 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 @@ -193,12 +193,12 @@ Minecraft::Minecraft(Component* mouseComponent, Canvas* parent, TextureManager::createInstance(); for (int i = 0; i < XUSER_MAX_COUNT; i++) { - m_pendingLocalConnections[i] = NULL; + m_pendingLocalConnections[i] = nullptr; m_connectionFailed[i] = false; - localgameModes[i] = NULL; + localgameModes[i] = nullptr; } - animateTickLevel = NULL; // 4J added + animateTickLevel = nullptr; // 4J added m_inFullTutorialBits = 0; // 4J Added reloadTextures = false; @@ -208,7 +208,7 @@ Minecraft::Minecraft(Component* mouseComponent, Canvas* parent, // 4J-PB - Removed it from here on Orbis due to it causing a crash with the // network init. We should work out why... - this->soundEngine->init(NULL); + this->soundEngine->init(nullptr); #if !defined(DISABLE_LEVELTICK_THREAD) levelTickEventQueue = @@ -272,7 +272,7 @@ void Minecraft::init() { for (int i = 0; i < 4; ++i) 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)); @@ -332,7 +332,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 @@ -452,23 +452,23 @@ File Minecraft::getWorkingDirectory(const std::wstring& applicationName) { LevelStorageSource* Minecraft::getLevelSource() { return levelSource; } void Minecraft::setScreen(Screen* screen) { - if (dynamic_cast(this->screen) != NULL) return; + if (dynamic_cast(this->screen) != nullptr) return; - if (this->screen != NULL) { + if (this->screen != nullptr) { this->screen->removed(); } // 4J Gordon: Do not force a stats save here - /*if (dynamic_cast(screen)!=NULL) + /*if (dynamic_cast(screen)!=nullptr) { stats->forceSend(); } stats->forceSave();*/ this->screen = screen; - if (screen == NULL && level == NULL) { + if (screen == nullptr && level == nullptr) { screen = new TitleScreen(); - } else if (player != NULL && !ui.GetMenuDisplayed(player->GetXboxPad()) && + } else if (player != nullptr && !ui.GetMenuDisplayed(player->GetXboxPad()) && player->getHealth() <= 0) { #if defined(ENABLE_JAVA_GUIS) screen = new DeathScreen(); @@ -480,17 +480,17 @@ void Minecraft::setScreen(Screen* screen) { if (ticks == 0) { player->respawn(); } else { - ui.NavigateToScene(player->GetXboxPad(), eUIScene_DeathMenu, NULL); + ui.NavigateToScene(player->GetXboxPad(), eUIScene_DeathMenu, nullptr); } #endif } - if (dynamic_cast(screen) != NULL) { + if (dynamic_cast(screen) != nullptr) { options->renderDebug = false; gui->clearMessages(); } - if (screen != NULL) { + if (screen != nullptr) { // releaseMouse(); // 4J - removed ScreenSizeCalculator ssc(options, width, height); int screenWidth = ssc.getWidth(); @@ -505,11 +505,11 @@ void Minecraft::setScreen(Screen* screen) { // it's possible that player doesn't exist here yet // 4jcraft: reuse this for the java GUI #if defined(ENABLE_JAVA_GUIS) - if (screen != NULL && player != NULL) { + if (screen != nullptr && player != nullptr) { if (player && player->GetXboxPad() != -1) { InputManager.SetMenuDisplayed(player->GetXboxPad(), true); } - } else if (player != NULL) { + } else if (player != nullptr) { if (player && player->GetXboxPad() != -1) { InputManager.SetMenuDisplayed(player->GetXboxPad(), false); } @@ -528,20 +528,20 @@ void Minecraft::destroy() { // 4J - all try/catch/finally things in here removed // try { - if (this->bgLoader != NULL) { + if (this->bgLoader != nullptr) { bgLoader->halt(); } // } catch (Exception e) { // } // try { - setLevel(NULL); + setLevel(nullptr); // } catch (Throwable e) { // } - if (screen == NULL && level == NULL) { + if (screen == nullptr && level == nullptr) { screen = new TitleScreen(); - } else if (player != NULL && !ui.GetMenuDisplayed(player->GetXboxPad()) && + } else if (player != nullptr && !ui.GetMenuDisplayed(player->GetXboxPad()) && player->getHealth() <= 0) { #if defined(ENABLE_JAVA_GUIS) screen = new DeathScreen(); @@ -553,17 +553,17 @@ void Minecraft::destroy() { if (ticks == 0) { player->respawn(); } else { - ui.NavigateToScene(player->GetXboxPad(), eUIScene_DeathMenu, NULL); + ui.NavigateToScene(player->GetXboxPad(), eUIScene_DeathMenu, nullptr); } #endif } - if (screen != NULL && dynamic_cast(screen) != NULL) { + if (screen != nullptr && dynamic_cast(screen) != nullptr) { options->renderDebug = false; gui->clearMessages(); } - if (screen != NULL) { + if (screen != nullptr) { // releaseMouse(); // 4J - removed ScreenSizeCalculator ssc(options, width, height); int screenWidth = ssc.getWidth(); @@ -577,7 +577,7 @@ void Minecraft::destroy() { // 4J-PB - if a screen has been set, go into menu mode // it's possible that player doesn't exist here yet #if defined(ENABLE_JAVA_GUIS) - if (screen != NULL) { + if (screen != nullptr) { if (player && player->GetXboxPad() != -1) { InputManager.SetMenuDisplayed(player->GetXboxPad(), true); } @@ -624,7 +624,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]; @@ -643,7 +643,7 @@ void Minecraft::updatePlayerViewportAssignments() { // Find out how many viewports we'll be needing 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; @@ -651,7 +651,7 @@ void Minecraft::updatePlayerViewportAssignments() { if (viewportsRequired == 1) { // Single viewport for (int i = 0; i < XUSER_MAX_COUNT; i++) { - if (localplayers[i] != NULL) + if (localplayers[i] != nullptr) localplayers[i]->m_iScreenSection = C4JRender::VIEWPORT_TYPE_FULLSCREEN; } @@ -659,7 +659,7 @@ void Minecraft::updatePlayerViewportAssignments() { // Split screen - TODO - option for vertical/horizontal split 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)) { @@ -679,7 +679,7 @@ void Minecraft::updatePlayerViewportAssignments() { bool quadrantsAllocated[4] = {false, false, false, false}; 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) This fixes // an issue with the primary player being the 4th controller @@ -705,7 +705,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 > @@ -740,21 +740,21 @@ void Minecraft::updatePlayerViewportAssignments() { // player to the game session 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] = std::shared_ptr( - new MultiplayerLocalPlayer(this, level, user, NULL)); - localgameModes[idx] = NULL; + new MultiplayerLocalPlayer(this, level, user, nullptr)); + localgameModes[idx] = nullptr; updatePlayerViewportAssignments(); @@ -782,13 +782,13 @@ void Minecraft::addPendingLocalConnection(int idx, std::shared_ptr Minecraft::createExtraLocalPlayer( int idx, const std::wstring& name, int iPad, int iDimension, - ClientConnection* clientConnection /*= NULL*/, + 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; } @@ -796,7 +796,7 @@ std::shared_ptr Minecraft::createExtraLocalPlayer( 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 @@ -845,7 +845,7 @@ std::shared_ptr Minecraft::createExtraLocalPlayer( localplayers[idx]->m_iScreenSection = tempScreenSection; - if (levelpassedin == NULL) + if (levelpassedin == nullptr) level->addEntity( localplayers[idx]); // Don't add if we're passing the level in, // we only do this from the client @@ -854,7 +854,7 @@ std::shared_ptr Minecraft::createExtraLocalPlayer( 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(); @@ -885,7 +885,7 @@ std::shared_ptr Minecraft::createExtraLocalPlayer( 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)) { @@ -896,13 +896,13 @@ 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) { std::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]); @@ -914,14 +914,14 @@ void Minecraft::removeLocalPlayerIdx(int idx) { playerLeftTutorial(idx); delete localgameModes[idx]; - localgameModes[idx] = NULL; - } else if (m_pendingLocalConnections[idx] != NULL) { + localgameModes[idx] = nullptr; + } else if (m_pendingLocalConnections[idx] != nullptr) { m_pendingLocalConnections[idx]->sendAndDisconnect( std::shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting))); ; delete m_pendingLocalConnections[idx]; - m_pendingLocalConnections[idx] = NULL; + m_pendingLocalConnections[idx] = nullptr; g_NetworkManager.RemoveLocalPlayerByUserIndex(idx); } else { // Not sure how this works on qnet, but for other platforms, calling @@ -939,16 +939,16 @@ 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(); @@ -1001,14 +1001,14 @@ void Minecraft::run_middle() { // if (minecraftApplet != null && // !minecraftApplet.isActive()) break; // 4J - removed - // if (parent == NULL && Display.isCloseRequested()) { + // 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() && + if (level != nullptr && ProfileManager.IsFullVersion() && g_NetworkManager.IsHost()) { /*if(!bAutosaveTimerSet) { @@ -1145,7 +1145,7 @@ void Minecraft::run_middle() { // 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 && + if (level != nullptr && bFirstTimeIntoGame && g_NetworkManager.SessionHasSpace()) { // have a short delay before the display if (iFirstTimeCountdown == 0) { @@ -1153,7 +1153,7 @@ void Minecraft::run_middle() { if (app.IsLocalMultiplayerAvailable()) { for (int i = 0; i < XUSER_MAX_COUNT; i++) { - if ((localplayers[i] == NULL) && + if ((localplayers[i] == nullptr) && InputManager.IsPadConnected(i)) { if (!ui.PressStartPlaying(i)) { ui.ShowPressStart(i); @@ -1355,7 +1355,7 @@ void Minecraft::run_middle() { // create the localplayer std::shared_ptr player = localplayers[i]; - if (player == NULL) { + if (player == nullptr) { player = createExtraLocalPlayer( i, (convStringToWstring( @@ -1431,7 +1431,7 @@ void Minecraft::run_middle() { } - if (pause && level != NULL) { + if (pause && level != nullptr) { float lastA = timer->a; timer->advanceTime(); timer->a = lastA; @@ -1458,12 +1458,12 @@ void Minecraft::run_middle() { // 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) != @@ -1497,7 +1497,7 @@ void Minecraft::run_middle() { // clear the stored button downs since the tick for this // player will now have actioned them player->ullButtonsPressed = 0LL; - } else if (screen != NULL) { + } else if (screen != nullptr) { screen->updateEvents(); // 4jcraft: this fixes the title screen panorama running // faster than it should @@ -1546,7 +1546,7 @@ void Minecraft::run_middle() { PIXBeginNamedEvent(0, "Light update"); - // if (level != NULL) level->updateLights(); + // if (level != nullptr) level->updateLights(); glEnable(GL_TEXTURE_2D); PIXEndNamedEvent(); @@ -1555,9 +1555,9 @@ void Minecraft::run_middle() { // Display.update(); // 4J - removed // 4J-PB - changing this to be per player - // if (player != NULL && player->isInWall()) + // if (player != nullptr && player->isInWall()) // options->thirdPersonView = false; - if (player != NULL && player->isInWall()) + if (player != nullptr && player->isInWall()) player->SetThirdPersonView(0); if (!noRender) { @@ -1673,7 +1673,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) { @@ -1690,7 +1690,7 @@ void Minecraft::run_middle() { checkGlError(L"Post render"); MemSect(0); frames++; - // pause = !isClientSide() && screen != NULL && + // pause = !isClientSide() && screen != nullptr && // screen->isPauseScreen(); #if defined(ENABLE_JAVA_GUIS) pause = g_NetworkManager.IsLocalGame() && @@ -1742,7 +1742,7 @@ void Minecraft::run_end() { destroy(); } void Minecraft::emergencySave() { // 4J - lots of try/catches removed here, and garbage collector things levelRenderer->clear(); - setLevel(NULL); + setLevel(nullptr); } void Minecraft::renderFpsMeter(int64_t tickTime) { @@ -1843,7 +1843,7 @@ void Minecraft::stop() { } void Minecraft::pauseGame() { - if (screen != NULL) { + if (screen != nullptr) { // 4jcraft: Pass the keypress to the screen // normally this would've been done in updateEvents(), but it works // better here (for now atleast) @@ -1879,7 +1879,7 @@ void Minecraft::resize(int width, int height) { } this->height = height; - if (screen != NULL) { + if (screen != nullptr) { // 4jcraft: use adjusted logical width instead of raw width for correct // screen size calculation. ScreenSizeCalculator ssc(options, this->width, height); @@ -1943,7 +1943,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")); @@ -1961,35 +1961,35 @@ 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); - } else if (player->isSleeping() && level != NULL && + setScreen(nullptr); + } else if (player->isSleeping() && level != nullptr && level->isClientSide) { // setScreen(new InBedChatScreen()); // 4J - // TODO put back in } - } else if (screen != NULL && - (dynamic_cast(screen) != NULL) && + } 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(); } } - if (screen == NULL && !ui.GetMenuDisplayed(iPad)) { + if (screen == nullptr && !ui.GetMenuDisplayed(iPad)) { // 4J-PB - add some tooltips if required int iA = -1, iB = -1, iX, iY = IDS_CONTROLS_INVENTORY, iLT = -1, iRT = -1, iLB = -1, iRB = -1, iLS = -1, iRS = -1; @@ -2090,7 +2090,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; } else { if (player->isRiding()) { @@ -2145,7 +2145,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // item { FoodItem* food = (FoodItem*)itemInstance->getItem(); - if (food != NULL && food->canEat(player)) { + if (food != nullptr && food->canEat(player)) { *piUse = IDS_TOOLTIPS_EAT; } } @@ -2227,7 +2227,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { } } - if (hitResult != NULL) { + if (hitResult != nullptr) { switch (hitResult->type) { case HitResult::TILE: { int x, y, z; @@ -2239,8 +2239,8 @@ 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 @@ -2258,7 +2258,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { * flowerpots in case of non-standard items. (ie. ignite * behaviour) */ - if (bUseItemOn && itemInstance != NULL) { + if (bUseItemOn && itemInstance != nullptr) { switch (itemInstance->getItem()->id) { case Tile::mushroom_brown_Id: case Tile::mushroom_red_Id: @@ -2350,7 +2350,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) + z) != nullptr) ? IDS_TOOLTIPS_OPEN : -1; break; @@ -2424,7 +2424,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)) { @@ -2443,7 +2443,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { break; case Tile::flowerPot_Id: - if (!bUseItemOn && (itemInstance != NULL) && + if (!bUseItemOn && (itemInstance != nullptr) && (iData == 0)) { int iID = itemInstance->getItem()->id; if (iID < 256) // is it a tile? @@ -2504,8 +2504,8 @@ 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 @@ -2518,7 +2518,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { heldItem = player->inventory->getSelected(); } int heldItemId = - heldItem != NULL ? heldItem->getItem()->id : -1; + heldItem != nullptr ? heldItem->getItem()->id : -1; switch (entityType) { case eTYPE_CHICKEN: { @@ -2976,7 +2976,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { hitResult->entity); // is the frame occupied? - if (itemFrame->getItem() != NULL) { + if (itemFrame->getItem() != nullptr) { // rotate the item *piUse = IDS_TOOLTIPS_ROTATE; } else { @@ -3165,7 +3165,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { if (wheel != 0) { 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( @@ -3308,7 +3308,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { options->renderDebug = !options->renderDebug; // 4J Stu - The xbox uses a completely different way of // navigating to this scene - ui.NavigateToScene(0, eUIScene_DebugOverlay, NULL, + ui.NavigateToScene(0, eUIScene_DebugOverlay, nullptr, eUILayer_Debug); #endif } @@ -3384,7 +3384,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { } // 4J-PB - Microsoft request that we use the 3x3 crafting if someone // presses X while at the workbench - else if ((hitResult != NULL) && + else if ((hitResult != nullptr) && (hitResult->type == HitResult::TILE) && (level->getTile(hitResult->x, hitResult->y, hitResult->z) == Tile::workBench_Id)) { @@ -3409,7 +3409,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { player->GetXboxPad()); ui.PlayUISFX(eSFX_Press); #if !defined(ENABLE_JAVA_GUIS) - ui.NavigateToScene(iPad, eUIScene_PauseMenu, NULL, eUILayer_Scene); + ui.NavigateToScene(iPad, eUIScene_PauseMenu, nullptr, eUILayer_Scene); #endif } @@ -3437,21 +3437,21 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // assume that we dropped it and should hide the item int iCount = 0; - if (selectedItem != NULL) iCount = selectedItem->GetCount(); - if (selectedItem != NULL && !((player->ullButtonsPressed & + if (selectedItem != nullptr) iCount = selectedItem->GetCount(); + if (selectedItem != nullptr && !((player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_DROP)) && selectedItem->GetCount() == 1)) { itemName = selectedItem->getHoverName(); } if (!(player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_DROP)) || - (selectedItem != NULL && selectedItem->GetCount() <= 1)) + (selectedItem != nullptr && selectedItem->GetCount() <= 1)) ui.SetSelectedItem(iPad, itemName); } } else { // 4J-PB // if (InputManager.GetValue(iPad, ACTION_MENU_CANCEL) > 0 && // gameMode->isInputAllowed(ACTION_MENU_CANCEL)) { - // setScreen(NULL); + // setScreen(nullptr); // } } @@ -3474,8 +3474,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // #endif - if (level != NULL) { - if (player != NULL) { + if (level != nullptr) { + if (player != nullptr) { recheckPlayerIn++; if (recheckPlayerIn == 30) { recheckPlayerIn = 0; @@ -3525,7 +3525,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // 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) + if (!pause && levels[i] != nullptr) levels[i]->animateTick(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z)); @@ -3543,7 +3543,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // level.addEntity(player); // } // } - if (levels[i] != NULL) { + if (levels[i] != nullptr) { if (!pause) { if (levels[i]->skyFlashTime > 0) levels[i]->skyFlashTime--; PIXBeginNamedEvent(0, "Level entity tick"); @@ -3598,7 +3598,7 @@ void Minecraft::reloadSound() { bgLoader->forceReload(); } -bool Minecraft::isClientSide() { return level != NULL && level->isClientSide; } +bool Minecraft::isClientSide() { return level != nullptr && level->isClientSide; } void Minecraft::selectLevel(ConsoleSaveFile* saveFile, const std::wstring& levelId, @@ -3612,8 +3612,8 @@ bool Minecraft::loadSlot(const std::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 @@ -3644,7 +3644,7 @@ 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 @@ -3653,7 +3653,7 @@ MultiPlayerLevel* Minecraft::getLevel(int dimension) { // 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) { @@ -3667,14 +3667,14 @@ void Minecraft::forceaddLevel(MultiPlayerLevel* level) { } void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, - std::shared_ptr forceInsertPlayer /*=NULL*/, + std::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); } @@ -3684,66 +3684,66 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, // 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 + // 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 If we ever go back to making single player only then + // 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 + // 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 != NULL) { + if (levelRenderer != nullptr) { for (unsigned int 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 + // 4J If we are setting the level to nullptr then we are exiting, so delete the // levels - if (level == NULL) { - if (levels[0] != NULL) { + if (level == nullptr) { + 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) { std::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; @@ -3751,7 +3751,7 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, // 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; @@ -3760,7 +3760,7 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, } this->level = level; - if (level != NULL) { + if (level != nullptr) { int dimId = level->dimension->id; if (dimId == -1) levels[1] = level; @@ -3771,7 +3771,7 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, // 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(); player = gameMode->createPlayer(level); @@ -3792,31 +3792,31 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, player->SetXboxPad(iPrimaryPlayer); for (int i = 0; i < XUSER_MAX_COUNT; i++) { - m_pendingLocalConnections[i] = NULL; - if (i != iPrimaryPlayer) localgameModes[i] = NULL; + m_pendingLocalConnections[i] = nullptr; + if (i != iPrimaryPlayer) localgameModes[i] = nullptr; } } - if (player != NULL) { + if (player != nullptr) { player->resetPos(); // 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) + if (levelRenderer != nullptr) levelRenderer->setLevel(player->GetXboxPad(), level); - if (particleEngine != NULL) particleEngine->setLevel(level); + if (particleEngine != nullptr) particleEngine->setLevel(level); gameMode->adjustPlayer(player); for (int i = 0; i < XUSER_MAX_COUNT; i++) { - m_pendingLocalConnections[i] = NULL; + m_pendingLocalConnections[i] = nullptr; } updatePlayerViewportAssignments(); @@ -3829,13 +3829,13 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, levelSource->clearAll(); player = nullptr; - // Clear all players if the new level is NULL + // Clear all players if the new level is nullptr for (int i = 0; i < XUSER_MAX_COUNT; i++) { - if (m_pendingLocalConnections[i] != NULL) + if (m_pendingLocalConnections[i] != nullptr) m_pendingLocalConnections[i]->close(); - m_pendingLocalConnections[i] = NULL; + m_pendingLocalConnections[i] = nullptr; localplayers[i] = nullptr; - localgameModes[i] = NULL; + localgameModes[i] = nullptr; } } @@ -3846,7 +3846,7 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, } void Minecraft::prepareLevel(int title) { - if (progressRenderer != NULL) { + if (progressRenderer != nullptr) { this->progressRenderer->progressStart(title); this->progressRenderer->progressStage(IDS_PROGRESS_BUILDING_TERRAIN); } @@ -3858,7 +3858,7 @@ void Minecraft::prepareLevel(int title) { ChunkSource* cs = level->getChunkSource(); Pos* spawnPos = level->getSharedSpawnPos(); - if (player != NULL) { + if (player != nullptr) { spawnPos->x = (int)player->x; spawnPos->z = (int)player->z; } @@ -3866,7 +3866,7 @@ void Minecraft::prepareLevel(int title) { for (int x = -r; x <= r; x += 16) { for (int z = -r; z <= r; z += 16) { - if (progressRenderer != NULL) + if (progressRenderer != nullptr) this->progressRenderer->progressStagePercentage((pp++) * 100 / max); level->getTile(spawnPos->x + x, 64, spawnPos->z + z); @@ -3877,7 +3877,7 @@ void Minecraft::prepareLevel(int title) { } delete spawnPos; if (!gameMode->isCutScene()) { - if (progressRenderer != NULL) + if (progressRenderer != nullptr) this->progressRenderer->progressStage( IDS_PROGRESS_SIMULATING_WORLD); max = 2000; @@ -3932,7 +3932,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) { level->validateSpawn(); level->removeAllPendingEntityRemovals(); - if (localPlayer != NULL) { + if (localPlayer != nullptr) { level->removeEntity(localPlayer); } @@ -4005,7 +4005,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(); @@ -4021,7 +4021,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(); } @@ -4053,9 +4053,9 @@ void Minecraft::startAndConnectTo(const std::wstring& name, */ 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 { @@ -4078,7 +4078,7 @@ void Minecraft::startAndConnectTo(const std::wstring& name, // if (ProfileManager.IsFullVersion()) { if (userName != L"" && - sid != L"") // 4J - username & side were compared with NULL rather + sid != L"") // 4J - username & side were compared with nullptr rather // than empty strings { minecraft->user = new User(userName, sid); @@ -4094,7 +4094,7 @@ void Minecraft::startAndConnectTo(const std::wstring& name, // } /* 4J - TODO - if (url != NULL) + if (url != nullptr) { String[] tokens = url.split(":"); minecraft.connectTo(tokens[0], Integer.parseInt(tokens[1])); @@ -4175,23 +4175,23 @@ void Minecraft::main() { } bool Minecraft::renderNames() { - if (m_instance == NULL || !m_instance->options->hideGui) { + if (m_instance == nullptr || !m_instance->options->hideGui) { return true; } return false; } 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 && + 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 std::wstring& chatMessage) { @@ -4226,7 +4226,7 @@ if (gameMode->instaBuild) return; if (!down) missTime = 0; if (button == 0 && missTime > 0) return; -if (down && hitResult != NULL && hitResult->type == HitResult::TILE && button == +if (down && hitResult != nullptr && hitResult->type == HitResult::TILE && button == 0) { int x = hitResult->x; @@ -4260,7 +4260,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 = std::dynamic_pointer_cast( player ); @@ -4277,9 +4277,9 @@ PlayerCommandPacket.STOP_SLEEPING)); //} } -if (hitResult == NULL) +if (hitResult == nullptr) { -if (button == 0 && !(dynamic_cast(gameMode) != NULL)) missTime = +if (button == 0 && !(dynamic_cast(gameMode) != nullptr)) missTime = 10; } else if (hitResult->type == HitResult::ENTITY) @@ -4316,21 +4316,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) { @@ -4342,7 +4342,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)) { @@ -4359,7 +4359,7 @@ Screen* Minecraft::getScreen() { return screen; } bool Minecraft::isTutorial() { return m_inFullTutorialBits > 0; - /*if( gameMode != NULL && gameMode->isTutorial() ) + /*if( gameMode != nullptr && gameMode->isTutorial() ) { return true; } @@ -4391,7 +4391,7 @@ void Minecraft::playerLeftTutorial(int iPad) { // 4J Stu -This telemetry event means something different on XboxOne, so // we don't call it for simple state changes like this for (unsigned int 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, @@ -4420,7 +4420,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) { + 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)) { @@ -4440,7 +4440,7 @@ int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) // create the local player for the iPad std::shared_ptr player = pMinecraftClass->localplayers[iPad]; - if (player == NULL) { + if (player == nullptr) { player = pMinecraftClass->createExtraLocalPlayer( iPad, (convStringToWstring( @@ -4510,7 +4510,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 6bf2fb96d..a6c45b2e5 100644 --- a/Minecraft.Client/Minecraft.h +++ b/Minecraft.Client/Minecraft.h @@ -123,8 +123,8 @@ public: std::shared_ptr createExtraLocalPlayer( int idx, const std::wstring& name, int pad, int iDimension, - ClientConnection* clientConnection = NULL, - MultiPlayerLevel* levelpassedin = NULL); + 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 144419181..a7e4c23d0 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -53,7 +53,7 @@ #define DEBUG_SERVER_DONT_SPAWN_MOBS 0 // 4J Added -MinecraftServer* MinecraftServer::server = NULL; +MinecraftServer* MinecraftServer::server = nullptr; bool MinecraftServer::setTimeAtEndOfTick = false; int64_t MinecraftServer::setTime = 0; bool MinecraftServer::setTimeOfDayAtEndOfTick = false; @@ -75,10 +75,10 @@ std::unordered_map MinecraftServer::ironTimers; 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; @@ -97,7 +97,7 @@ MinecraftServer::MinecraftServer() { m_texturePackId = 0; maxBuildHeight = Level::maxBuildHeight; playerIdleTimeout = 0; - m_postUpdateThread = NULL; + m_postUpdateThread = nullptr; forceGameType = false; commandDispatcher = new ServerCommandDispatcher(); @@ -165,11 +165,11 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData* initData, setPlayers(new PlayerList(this)); // 4J-JEV: Need to wait for levelGenerationOptions to load. - while (app.getLevelGenerationOptions() != NULL && + while (app.getLevelGenerationOptions() != nullptr && !app.getLevelGenerationOptions()->hasLoadedData()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); - if (app.getLevelGenerationOptions() != NULL && + if (app.getLevelGenerationOptions() != nullptr && !app.getLevelGenerationOptions()->ready()) { // TODO: Stop loading, add error message. } @@ -180,7 +180,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData* initData, std::wstring levelTypeString; bool gameRuleUseFlatWorld = false; - if (app.getLevelGenerationOptions() != NULL) { + if (app.getLevelGenerationOptions() != nullptr) { gameRuleUseFlatWorld = app.getLevelGenerationOptions()->getuseFlatWorld(); } @@ -192,7 +192,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData* initData, } LevelType* pLevelType = LevelType::getLevelType(levelTypeString); - if (pLevelType == NULL) { + if (pLevelType == nullptr) { pLevelType = LevelType::lvl_normal; } @@ -318,7 +318,7 @@ void MinecraftServer::postProcessTerminate(ProgressRenderer* mcprogress) { } } while (status == WAIT_TIMEOUT); delete m_postUpdateThread; - m_postUpdateThread = NULL; + m_postUpdateThread = nullptr; DeleteCriticalSection(&m_postProcessCS); } @@ -353,7 +353,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, // 4J - temp - load existing level std::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 #if defined(SPLIT_SAVES) @@ -381,12 +381,12 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, #if defined(SPLIT_SAVES) bool bLevelGenBaseSave = false; LevelGenerationOptions* levelGen = app.getLevelGenerationOptions(); - if (levelGen != NULL && levelGen->requiresBaseSave()) { + if (levelGen != nullptr && levelGen->requiresBaseSave()) { unsigned int fileSize = 0; std::uint8_t* pvSaveData = levelGen->getBaseSaveData(fileSize); if (pvSaveData && fileSize != 0) bLevelGenBaseSave = true; } - ConsoleSaveFileSplit* newFormatSave = NULL; + ConsoleSaveFileSplit* newFormatSave = nullptr; if (bLevelGenBaseSave) { ConsoleSaveFileOriginal oldFormatSave(L""); newFormatSave = new ConsoleSaveFileSplit(&oldFormatSave); @@ -420,11 +420,11 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, 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); } @@ -457,7 +457,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, #endif levels[i]->getLevelData()->setGameType(gameType); - if (app.getLevelGenerationOptions() != NULL) { + if (app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* mapOptions = app.getLevelGenerationOptions(); levels[i]->getLevelData()->setHasBeenInCreative( @@ -778,7 +778,7 @@ void MinecraftServer::saveAllChunks() { // 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 + 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); @@ -804,10 +804,10 @@ 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 = @@ -835,8 +835,8 @@ void MinecraftServer::Suspend() { QueryPerformanceCounter(&qwTime); if (m_bLoaded && ProfileManager.IsFullVersion() && (!StorageManager.GetSaveDisabled())) { - if (players != NULL) { - players->saveAll(NULL); + if (players != nullptr) { + players->saveAll(nullptr); } for (unsigned int j = 0; j < levels.length; j++) { if (s_bServerHalted) break; @@ -849,7 +849,7 @@ void MinecraftServer::Suspend() { } if (!s_bServerHalted) { saveGameRules(); - levels[0]->saveToDisc(NULL, true); + levels[0]->saveToDisc(nullptr, true); } } QueryPerformanceCounter(&qwNewTime); @@ -896,7 +896,7 @@ void MinecraftServer::stopServer(bool didInit) { // initialisation. if (m_saveOnExit && ProfileManager.IsFullVersion() && (!StorageManager.GetSaveDisabled()) && didInit) { - if (players != NULL) { + if (players != nullptr) { players->saveAll(Minecraft::GetInstance()->progressRenderer, true); } @@ -907,7 +907,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(); // } @@ -915,7 +915,7 @@ void MinecraftServer::stopServer(bool didInit) { saveGameRules(); app.m_gameRules.unloadCurrentGameRules(); - if (levels[0] != NULL) // This can be null if stopServer happens + if (levels[0] != nullptr) // This can be null if stopServer happens // very quickly due to network error { levels[0]->saveToDisc( @@ -936,19 +936,19 @@ void MinecraftServer::stopServer(bool didInit) { // 4J-PB remove the server levels 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; } } delete connection; - connection = NULL; + connection = nullptr; delete players; - players = NULL; + players = nullptr; delete settings; - settings = NULL; + settings = nullptr; g_NetworkManager.ServerStopped(); } @@ -1047,10 +1047,10 @@ void MinecraftServer::setPlayerIdleTimeout(int playerIdleTimeout) { extern int c0a, c0b, c1a, c1b, c1c, c2a, c2b; void MinecraftServer::run(int64_t seed, void* lpParameter) { - NetworkGameInitData* initData = NULL; + NetworkGameInitData* initData = nullptr; std::uint32_t initSettings = 0; bool findSeed = false; - if (lpParameter != NULL) { + if (lpParameter != nullptr) { initData = (NetworkGameInitData*)lpParameter; initSettings = app.GetGameHostOption(eGameHostOption_All); findSeed = initData->findSeed; @@ -1178,7 +1178,7 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { case eXuiServerAction_AutoSaveGame: case eXuiServerAction_SaveGame: app.EnterSaveNotificationSection(); - if (players != NULL) { + if (players != nullptr) { players->saveAll( Minecraft::GetInstance()->progressRenderer); } @@ -1525,13 +1525,13 @@ void MinecraftServer::main(int64_t 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(); } @@ -1569,7 +1569,7 @@ void MinecraftServer::setLevel(int dimension, ServerLevel* level) { #if defined(_ACK_CHUNK_SEND_THROTTLING) 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++) { if (s_sentTo[i]->IsSameSystem(player)) { @@ -1637,7 +1637,7 @@ void MinecraftServer::chunkPacketManagement_PostTick() {} #else // 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 && @@ -1681,7 +1681,7 @@ void MinecraftServer::cycleSlowQueueIndex() { if (!g_NetworkManager.IsInSession()) return; int startingIndex = s_slowQueuePlayerIndex; - INetworkPlayer* currentPlayer = NULL; + INetworkPlayer* currentPlayer = nullptr; int currentPlayerCount = 0; do { currentPlayerCount = g_NetworkManager.GetPlayerCount(); @@ -1700,7 +1700,7 @@ void MinecraftServer::cycleSlowQueueIndex() { s_slowQueuePlayerIndex = 0; } } while (g_NetworkManager.IsInSession() && currentPlayerCount > 0 && - s_slowQueuePlayerIndex != startingIndex && currentPlayer != NULL && + s_slowQueuePlayerIndex != startingIndex && 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 a18275a89..84ecf085f 100644 --- a/Minecraft.Client/MinecraftServer.h +++ b/Minecraft.Client/MinecraftServer.h @@ -45,9 +45,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; @@ -254,10 +254,10 @@ public: public: static PlayerList* getPlayerList() { - if (server != NULL) + if (server != nullptr) return server->players; else - return NULL; + return nullptr; } static void SetTimeOfDay(int64_t time) { setTimeOfDayAtEndOfTick = true; diff --git a/Minecraft.Client/Network/ClientConnection.cpp b/Minecraft.Client/Network/ClientConnection.cpp index 2daccb624..8f46f8b43 100644 --- a/Minecraft.Client/Network/ClientConnection.cpp +++ b/Minecraft.Client/Network/ClientConnection.cpp @@ -62,9 +62,9 @@ ClientConnection::ClientConnection(Minecraft* minecraft, Socket* socket, // 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; @@ -75,7 +75,7 @@ ClientConnection::ClientConnection(Minecraft* minecraft, Socket* socket, m_userIndex = iUserIndex; } - if (socket == NULL) { + if (socket == nullptr) { socket = new Socket(); // 4J - Local connection } @@ -83,7 +83,7 @@ ClientConnection::ClientConnection(Minecraft* minecraft, Socket* socket, if (createdOk) { connection = new Connection(socket, L"Client", this); } else { - connection = NULL; + connection = nullptr; // TODO 4J Stu - This will cause issues since the session player owns // the socket // delete socket; @@ -104,10 +104,10 @@ void ClientConnection::tick() { } INetworkPlayer* ClientConnection::getNetworkPlayer() { - if (connection != NULL && connection->getSocket() != NULL) + if (connection != nullptr && connection->getSocket() != nullptr) return connection->getSocket()->getPlayer(); else - return NULL; + return nullptr; } void ClientConnection::handleLogin(std::shared_ptr packet) { @@ -115,7 +115,7 @@ void ClientConnection::handleLogin(std::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()) { pMojangData = app.GetMojangDataForXuid(OnlineXuid); @@ -151,7 +151,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { } if (iUserID != -1) { - std::uint8_t* pBuffer = NULL; + std::uint8_t* pBuffer = nullptr; unsigned int dwSize = 0; bool bRes; @@ -208,7 +208,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { } Level* dimensionLevel = minecraft->getLevel(packet->dimension); - if (dimensionLevel == NULL) { + if (dimensionLevel == nullptr) { level = new MultiPlayerLevel( this, new LevelSettings( @@ -220,10 +220,10 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { // 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 + // if( level->savedDataStorage != nullptr ) delete // level->savedDataStorage; level->savedDataStorage = activeLevel->savedDataStorage; } @@ -272,12 +272,12 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { level = (MultiPlayerLevel*)minecraft->getLevel(packet->dimension); std::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); @@ -381,7 +381,7 @@ void ClientConnection::handleAddEntity( std::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++) { if (minecraft->localplayers[i]) { if (minecraft->localplayers[i]->entityId == @@ -511,7 +511,7 @@ void ClientConnection::handleAddEntity( from fishing std::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++ ) { @@ -528,7 +528,7 @@ void ClientConnection::handleAddEntity( } } std::shared_ptr player = - std::dynamic_pointer_cast(owner); if (player != NULL) + std::dynamic_pointer_cast(owner); if (player != nullptr) { std::shared_ptr hook = std::shared_ptr( new FishingHook(level, x, y, z, player) ); @@ -585,7 +585,7 @@ void ClientConnection::handleAddEntity( */ - if (e != NULL) { + if (e != nullptr) { e->xp = packet->x; e->yp = packet->y; e->zp = packet->z; @@ -602,7 +602,7 @@ void ClientConnection::handleAddEntity( std::vector >* subEntities = e->getSubEntities(); - if (subEntities != NULL) { + if (subEntities != nullptr) { int offs = packet->id - e->entityId; // for (int i = 0; i < subEntities.length; i++) for (AUTO_VAR(it, subEntities->begin()); it != subEntities->end(); @@ -636,7 +636,7 @@ void ClientConnection::handleAddEntity( std::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++) { if (minecraft->localplayers[i]) { if (minecraft->localplayers[i]->entityId == @@ -648,7 +648,7 @@ void ClientConnection::handleAddEntity( } } - if (owner != NULL && owner->instanceof(eTYPE_LIVINGENTITY)) { + if (owner != nullptr && owner->instanceof(eTYPE_LIVINGENTITY)) { std::dynamic_pointer_cast(e)->owner = std::dynamic_pointer_cast(owner); } @@ -685,7 +685,7 @@ void ClientConnection::handleAddGlobalEntity( std::shared_ptr e; // = nullptr; if (packet->type == AddGlobalEntityPacket::LIGHTNING) e = std::shared_ptr(new LightningBolt(level, x, y, z)); - if (e != NULL) { + if (e != nullptr) { e->xp = packet->x; e->yp = packet->y; e->zp = packet->z; @@ -706,7 +706,7 @@ void ClientConnection::handleAddPainting( void ClientConnection::handleSetEntityMotion( std::shared_ptr packet) { std::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); } @@ -714,7 +714,7 @@ void ClientConnection::handleSetEntityMotion( void ClientConnection::handleSetEntityData( std::shared_ptr packet) { std::shared_ptr e = getEntity(packet->id); - if (e != NULL && packet->getUnpackedData() != NULL) { + if (e != nullptr && packet->getUnpackedData() != nullptr) { e->getEntityData()->assignValues(packet->getUnpackedData()); } } @@ -763,7 +763,7 @@ void ClientConnection::handleAddPlayer( int item = packet->carriedItem; if (item == 0) { player->inventory->items[player->inventory->selected] = - std::shared_ptr(); // NULL; + std::shared_ptr(); // nullptr; } else { player->inventory->items[player->inventory->selected] = std::shared_ptr(new ItemInstance(item, 1, 0)); @@ -787,13 +787,13 @@ void ClientConnection::handleAddPlayer( player->customTextureUrl.c_str(), player->name.c_str()); send(std::shared_ptr( - new TextureAndGeometryPacket(player->customTextureUrl, NULL, + 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(), @@ -809,12 +809,12 @@ void ClientConnection::handleAddPlayer( "player %ls\n", player->customTextureUrl2.c_str(), player->name.c_str()); send(std::shared_ptr( - new TexturePacket(player->customTextureUrl2, NULL, 0))); + 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(), @@ -824,7 +824,7 @@ void ClientConnection::handleAddPlayer( std::vector >* unpackedData = packet->getUnpackedData(); - if (unpackedData != NULL) { + if (unpackedData != nullptr) { player->getEntityData()->assignValues(unpackedData); } } @@ -832,7 +832,7 @@ void ClientConnection::handleAddPlayer( void ClientConnection::handleTeleportEntity( std::shared_ptr packet) { std::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; @@ -865,7 +865,7 @@ void ClientConnection::handleSetCarriedItem( void ClientConnection::handleMoveEntity( std::shared_ptr packet) { std::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; @@ -887,7 +887,7 @@ void ClientConnection::handleMoveEntity( void ClientConnection::handleRotateMob( std::shared_ptr packet) { std::shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; float yHeadRot = packet->yHeadRot * 360 / 256.f; e->setYHeadRot(yHeadRot); } @@ -895,7 +895,7 @@ void ClientConnection::handleRotateMob( void ClientConnection::handleMoveEntitySmall( std::shared_ptr packet) { std::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; @@ -966,7 +966,7 @@ void ClientConnection::handleMovePlayer( 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 @@ -1230,7 +1230,7 @@ void ClientConnection::handleDisconnect( 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)); } @@ -1256,12 +1256,12 @@ void ClientConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, uiIDA[0] = IDS_CONFIRM_OK; ui.RequestErrorMessage(IDS_EXITING_GAME, IDS_GENERIC_ERROR, uiIDA, 1, ProfileManager.GetPrimaryPad(), - &ClientConnection::HostDisconnectReturned, NULL); + &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)); } @@ -1296,7 +1296,7 @@ void ClientConnection::handleTakeItemEntity( } } - 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 @@ -1304,7 +1304,7 @@ void ClientConnection::handleTakeItemEntity( 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 @@ -1321,7 +1321,7 @@ void ClientConnection::handleTakeItemEntity( // 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) { float fPitch = @@ -1766,7 +1766,7 @@ void ClientConnection::handleChat(std::shared_ptr packet) { void ClientConnection::handleAnimate(std::shared_ptr packet) { std::shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; if (packet->action == AnimatePacket::SWING) { if (e->instanceof(eTYPE_LIVINGENTITY)) std::dynamic_pointer_cast(e)->swing(); @@ -1797,7 +1797,7 @@ void ClientConnection::handleAnimate(std::shared_ptr packet) { void ClientConnection::handleEntityActionAtPosition( std::shared_ptr packet) { std::shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; if (packet->action == EntityActionAtPositionPacket::START_SLEEP) { std::shared_ptr player = std::dynamic_pointer_cast(e); player->startSleepInBed(packet->x, packet->y, packet->z); @@ -2000,7 +2000,7 @@ void ClientConnection::handleAddMob(std::shared_ptr packet) { mob->xRotp = packet->xRot; std::vector >* subEntities = mob->getSubEntities(); - if (subEntities != NULL) { + if (subEntities != nullptr) { int offs = packet->id - mob->entityId; // for (int i = 0; i < subEntities.length; i++) for (AUTO_VAR(it, subEntities->begin()); it != subEntities->end(); @@ -2022,7 +2022,7 @@ void ClientConnection::handleAddMob(std::shared_ptr packet) { std::vector >* unpackedData = packet->getUnpackedData(); - if (unpackedData != NULL) { + if (unpackedData != nullptr) { mob->getEntityData()->assignValues(unpackedData); } @@ -2057,9 +2057,9 @@ void ClientConnection::handleEntityLinkPacket( // 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; @@ -2073,16 +2073,16 @@ void ClientConnection::handleEntityLinkPacket( ->entityId) { sourceEntity = Minecraft::GetInstance()->localplayers[m_userIndex]; - if (destEntity != NULL && destEntity->instanceof(eTYPE_BOAT)) + if (destEntity != nullptr && destEntity->instanceof(eTYPE_BOAT)) (std::dynamic_pointer_cast(destEntity))->setDoLerp(false); displayMountMessage = - (sourceEntity->riding == NULL && destEntity != NULL); - } else if (destEntity != NULL && destEntity->instanceof(eTYPE_BOAT)) { + (sourceEntity->riding == nullptr && destEntity != nullptr); + } else if (destEntity != nullptr && destEntity->instanceof(eTYPE_BOAT)) { (std::dynamic_pointer_cast(destEntity))->setDoLerp(true); } - if (sourceEntity == NULL) return; + if (sourceEntity == nullptr) return; sourceEntity->ride(destEntity); @@ -2095,8 +2095,8 @@ void ClientConnection::handleEntityLinkPacket( } */ } else if (packet->type == SetEntityLinkPacket::LEASH) { - if ((sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_MOB)) { - if (destEntity != NULL) { + if ((sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_MOB)) { + if (destEntity != nullptr) { (std::dynamic_pointer_cast(sourceEntity)) ->setLeashedTo(destEntity, false); } else { @@ -2110,7 +2110,7 @@ void ClientConnection::handleEntityLinkPacket( void ClientConnection::handleEntityEvent( std::shared_ptr packet) { std::shared_ptr e = getEntity(packet->entityId); - if (e != NULL) e->handleEntityEvent(packet->eventId); + if (e != nullptr) e->handleEntityEvent(packet->eventId); } std::shared_ptr ClientConnection::getEntity(int entityId) { @@ -2134,7 +2134,7 @@ void ClientConnection::handleSetHealth( // We need food if (packet->food < FoodConstants::HEAL_LEVEL - 1) { - if (minecraft->localgameModes[m_userIndex] != NULL && + if (minecraft->localgameModes[m_userIndex] != nullptr && !minecraft->localgameModes[m_userIndex]->hasInfiniteItems()) { minecraft->localgameModes[m_userIndex] ->getTutorial() @@ -2162,7 +2162,7 @@ void ClientConnection::handleTexture(std::shared_ptr packet) { wprintf(L"Client received request for custom texture %ls\n", packet->textureName.c_str()); #endif - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; app.GetMemFileDetails(packet->textureName, &pbData, &dwBytes); @@ -2197,7 +2197,7 @@ void ClientConnection::handleTextureAndGeometry( L"Client received request for custom texture and geometry %ls\n", packet->textureName.c_str()); #endif - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; app.GetMemFileDetails(packet->textureName, &pbData, &dwBytes); DLCSkinFile* pDLCSkinFile = @@ -2253,7 +2253,7 @@ void ClientConnection::handleTextureAndGeometry( void ClientConnection::handleTextureChange( std::shared_ptr packet) { std::shared_ptr e = getEntity(packet->id); - if ((e == NULL) || !e->instanceof(eTYPE_PLAYER)) return; + if ((e == nullptr) || !e->instanceof(eTYPE_PLAYER)) return; std::shared_ptr player = std::dynamic_pointer_cast(e); bool isLocalPlayer = false; @@ -2297,21 +2297,21 @@ void ClientConnection::handleTextureChange( packet->path.c_str(), player->name.c_str()); #endif send(std::shared_ptr( - new TexturePacket(packet->path, NULL, 0))); + 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( std::shared_ptr packet) { std::shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; std::shared_ptr player = std::dynamic_pointer_cast(e); - if (e == NULL) return; + if (e == nullptr) return; bool isLocalPlayer = false; for (int i = 0; i < XUSER_MAX_COUNT; i++) { @@ -2344,12 +2344,12 @@ void ClientConnection::handleTextureAndGeometryChange( packet->path.c_str(), player->name.c_str()); #endif send(std::shared_ptr( - new TextureAndGeometryPacket(packet->path, NULL, 0))); + 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); } } @@ -2366,7 +2366,7 @@ void ClientConnection::handleRespawn(std::shared_ptr packet) { MultiPlayerLevel* dimensionLevel = (MultiPlayerLevel*)minecraft->getLevel(packet->dimension); - if (dimensionLevel == NULL) { + if (dimensionLevel == nullptr) { dimensionLevel = new MultiPlayerLevel( this, new LevelSettings( @@ -2378,7 +2378,7 @@ void ClientConnection::handleRespawn(std::shared_ptr packet) { // 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 @@ -2417,7 +2417,7 @@ void ClientConnection::handleRespawn(std::shared_ptr packet) { // minecraft->addPendingLocalConnection(m_userIndex, this); - if (minecraft->localgameModes[m_userIndex] != NULL) { + if (minecraft->localgameModes[m_userIndex] != nullptr) { TutorialMode* gameMode = (TutorialMode*)minecraft->localgameModes[m_userIndex]; gameMode->getTutorial()->showTutorialPopup(false); @@ -2718,8 +2718,8 @@ void ClientConnection::handleContainerSetSlot( if (packet->slot >= 36 && packet->slot < 36 + 9) { std::shared_ptr lastItem = player->inventoryMenu->getSlot(packet->slot)->getItem(); - if (packet->item != NULL) { - if (lastItem == NULL || + if (packet->item != nullptr) { + if (lastItem == nullptr || lastItem->count < packet->item->count) { packet->item->popTime = Inventory::POP_TIME_DURATION; } @@ -2736,13 +2736,13 @@ void ClientConnection::handleContainerAck( std::shared_ptr packet) { std::shared_ptr player = minecraft->localplayers[m_userIndex]; - AbstractContainerMenu* menu = NULL; + AbstractContainerMenu* menu = nullptr; if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_INVENTORY) { menu = player->inventoryMenu; } else if (packet->containerId == player->containerMenu->containerId) { menu = player->containerMenu; } - if (menu != NULL) { + if (menu != nullptr) { if (!packet->accepted) { send(std::shared_ptr(new ContainerAckPacket( packet->containerId, packet->uid, true))); @@ -2765,7 +2765,7 @@ void ClientConnection::handleTileEditorOpen( std::shared_ptr packet) { std::shared_ptr tileEntity = level->getTileEntity(packet->x, packet->y, packet->z); - if (tileEntity != NULL) { + if (tileEntity != nullptr) { minecraft->localplayers[m_userIndex]->openTextEdit(tileEntity); } else if (packet->editorType == TileEditorOpenPacket::SIGN) { std::shared_ptr localSignDummy = @@ -2786,7 +2786,7 @@ void ClientConnection::handleSignUpdate( minecraft->level->getTileEntity(packet->x, packet->y, packet->z); // 4J-PB - on a client connecting, the line below fails - if (std::dynamic_pointer_cast(te) != NULL) { + if (std::dynamic_pointer_cast(te) != nullptr) { std::shared_ptr ste = std::dynamic_pointer_cast(te); for (int i = 0; i < MAX_SIGN_LINES; i++) { @@ -2801,7 +2801,7 @@ void ClientConnection::handleSignUpdate( ste->setChanged(); } else { app.DebugPrintf( - "std::dynamic_pointer_cast(te) == NULL\n"); + "std::dynamic_pointer_cast(te) == nullptr\n"); } } else { app.DebugPrintf("hasChunkAt failed\n"); @@ -2814,23 +2814,23 @@ void ClientConnection::handleTileEntityData( std::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 && - std::dynamic_pointer_cast(te) != NULL) { + std::dynamic_pointer_cast(te) != nullptr) { std::dynamic_pointer_cast(te)->load( packet->tag); } else if (packet->type == TileEntityDataPacket::TYPE_ADV_COMMAND && std::dynamic_pointer_cast(te) != - NULL) { + nullptr) { std::dynamic_pointer_cast(te)->load( packet->tag); } else if (packet->type == TileEntityDataPacket::TYPE_BEACON && std::dynamic_pointer_cast(te) != - NULL) { + nullptr) { std::dynamic_pointer_cast(te)->load( packet->tag); } else if (packet->type == TileEntityDataPacket::TYPE_SKULL && - std::dynamic_pointer_cast(te) != NULL) { + std::dynamic_pointer_cast(te) != nullptr) { std::dynamic_pointer_cast(te)->load( packet->tag); } @@ -2841,7 +2841,7 @@ void ClientConnection::handleTileEntityData( void ClientConnection::handleContainerSetData( std::shared_ptr packet) { onUnhandledPacket(packet); - if (minecraft->localplayers[m_userIndex]->containerMenu != NULL && + if (minecraft->localplayers[m_userIndex]->containerMenu != nullptr && minecraft->localplayers[m_userIndex]->containerMenu->containerId == packet->containerId) { minecraft->localplayers[m_userIndex]->containerMenu->setData( @@ -2852,7 +2852,7 @@ void ClientConnection::handleContainerSetData( void ClientConnection::handleSetEquippedItem( std::shared_ptr packet) { std::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 @@ -2881,8 +2881,8 @@ void ClientConnection::handleTileDestruction( } 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( @@ -2891,7 +2891,7 @@ void ClientConnection::handleGameEvent( int param = gameEventPacket->param; if (event >= 0 && event < GameEventPacket::EVENT_LANGUAGE_ID_LENGTH) { if (GameEventPacket::EVENT_LANGUAGE_ID[event] > - 0) // 4J - was NULL check + 0) // 4J - was nullptr check { minecraft->localplayers[m_userIndex]->displayClientMessage( GameEventPacket::EVENT_LANGUAGE_ID[event]); @@ -2912,12 +2912,12 @@ void ClientConnection::handleGameEvent( app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", m_userIndex); // This just allows it to be shown - if (minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) + if (minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) minecraft->localgameModes[ProfileManager.GetPrimaryPad()] ->getTutorial() ->showTutorialPopup(false); ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_EndPoem, - NULL, eUILayer_Scene, eUIGroup_Fullscreen); + nullptr, eUILayer_Scene, eUIGroup_Fullscreen); } else if (event == GameEventPacket::START_SAVING) { if (!g_NetworkManager.IsHost()) { // Move app started to here so that it happens immediately otherwise @@ -2953,8 +2953,8 @@ void ClientConnection::handleLevelEvent( std::shared_ptr packet) { if (packet->type == LevelEvent::SOUND_DRAGON_DEATH) { for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if (minecraft->localplayers[i] != NULL && - minecraft->localplayers[i]->level != NULL && + if (minecraft->localplayers[i] != nullptr && + minecraft->localplayers[i]->level != nullptr && minecraft->localplayers[i]->level->dimension->id == 1) { minecraft->localplayers[i]->awardStat( GenericStats::completeTheEnd(), @@ -2984,7 +2984,7 @@ void ClientConnection::handleAwardStat( void ClientConnection::handleUpdateMobEffect( std::shared_ptr packet) { std::shared_ptr e = getEntity(packet->entityId); - if ((e == NULL) || !e->instanceof(eTYPE_LIVINGENTITY)) return; + if ((e == nullptr) || !e->instanceof(eTYPE_LIVINGENTITY)) return; //( std::dynamic_pointer_cast(e) )->addEffect(new // MobEffectInstance(packet->effectId, packet->effectDurationTicks, @@ -2999,7 +2999,7 @@ void ClientConnection::handleUpdateMobEffect( void ClientConnection::handleRemoveMobEffect( std::shared_ptr packet) { std::shared_ptr e = getEntity(packet->entityId); - if ((e == NULL) || !e->instanceof(eTYPE_LIVINGENTITY)) return; + if ((e == nullptr) || !e->instanceof(eTYPE_LIVINGENTITY)) return; (std::dynamic_pointer_cast(e)) ->removeEffectNoUpdate(packet->effectId); @@ -3015,7 +3015,7 @@ void ClientConnection::handlePlayerInfo( 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); Player::setPlayerGamePrivilege(startingPrivileges, @@ -3027,17 +3027,17 @@ void ClientConnection::handlePlayerInfo( packet->m_playerPrivileges); std::shared_ptr entity = getEntity(packet->m_entityId); - if (entity != NULL && entity->instanceof(eTYPE_PLAYER)) { + if (entity != nullptr && entity->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::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) { std::shared_ptr localPlayer = minecraft->localplayers[i]; - if (localPlayer != NULL && localPlayer->connection != NULL && + if (localPlayer != nullptr && localPlayer->connection != nullptr && localPlayer->connection->getNetworkPlayer() == networkPlayer) { localPlayer->setPlayerGamePrivilege( Player::ePlayerGamePrivilege_All, @@ -3272,7 +3272,7 @@ void ClientConnection::handleServerSettingsChanged( app.SetGameHostOption(eGameHostOption_All, packet->data); } else if (packet->action == ServerSettingsChangedPacket::HOST_DIFFICULTY) { for (unsigned int i = 0; i < minecraft->levels.length; ++i) { - if (minecraft->levels[i] != NULL) { + if (minecraft->levels[i] != nullptr) { app.DebugPrintf( "ClientConnection::handleServerSettingsChanged - " "Difficulty = %d", @@ -3305,12 +3305,12 @@ void ClientConnection::handleUpdateProgress( void ClientConnection::handleUpdateGameRuleProgressPacket( std::shared_ptr packet) { const wchar_t* string = app.GetGameRulesString(packet->m_messageId); - if (string != NULL) { + if (string != nullptr) { std::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); } @@ -3361,7 +3361,7 @@ int ClientConnection::HostDisconnectReturned( ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(), &ClientConnection::ExitGameAndSaveReturned, - NULL); + nullptr); } else { MinecraftServer::getInstance()->setSaveOnExit(true); @@ -3433,7 +3433,7 @@ void ClientConnection::handleParticleEvent( void ClientConnection::handleUpdateAttributes( std::shared_ptr packet) { std::shared_ptr entity = getEntity(packet->getEntityId()); - if (entity == NULL) return; + if (entity == nullptr) return; if (!entity->instanceof(eTYPE_LIVINGENTITY)) { // Entity is not a living entity! @@ -3450,7 +3450,7 @@ void ClientConnection::handleUpdateAttributes( AttributeInstance* instance = attributes->getInstance(attribute->getId()); - if (instance == NULL) { + if (instance == nullptr) { // 4J - TODO: revisit, not familiar with the attribute system, why // are we passing in MIN_NORMAL (Java's smallest non-zero value // conforming to IEEE Standard 754 (?)) and MAX_VALUE diff --git a/Minecraft.Client/Network/MultiPlayerChunkCache.cpp b/Minecraft.Client/Network/MultiPlayerChunkCache.cpp index e20b87291..cdeac60e8 100644 --- a/Minecraft.Client/Network/MultiPlayerChunkCache.cpp +++ b/Minecraft.Client/Network/MultiPlayerChunkCache.cpp @@ -82,7 +82,7 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) { } } } else { - waterChunk = NULL; + waterChunk = nullptr; } this->level = level; @@ -121,7 +121,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; } return hasData[idx]; @@ -157,7 +157,7 @@ LevelChunk* MultiPlayerChunkCache::create(int x, int z) { LevelChunk* chunk = cache[idx]; LevelChunk* lastChunk = chunk; - if (chunk == NULL) { + if (chunk == nullptr) { EnterCriticalSection(&m_csLoadCreate); // LevelChunk *chunk; @@ -165,7 +165,7 @@ LevelChunk* MultiPlayerChunkCache::create(int x, int z) { { // 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 @@ -249,7 +249,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; } else { return chunk; @@ -269,12 +269,12 @@ void MultiPlayerChunkCache::postProcess(ChunkSource* parent, int x, int z) {} std::vector* MultiPlayerChunkCache::getMobsAt( MobCategory* mobCategory, int x, int y, int z) { - return NULL; + return nullptr; } TilePos* MultiPlayerChunkCache::findNearestMapFeature( Level* level, const std::wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } void MultiPlayerChunkCache::recreateLogicStructuresForChunk(int chunkX, diff --git a/Minecraft.Client/Network/PendingConnection.cpp b/Minecraft.Client/Network/PendingConnection.cpp index 26889858b..208555dd3 100644 --- a/Minecraft.Client/Network/PendingConnection.cpp +++ b/Minecraft.Client/Network/PendingConnection.cpp @@ -38,7 +38,7 @@ PendingConnection::PendingConnection(MinecraftServer* server, Socket* socket, PendingConnection::~PendingConnection() { delete connection; } void PendingConnection::tick() { - if (acceptedLogin != NULL) { + if (acceptedLogin != nullptr) { this->handleAcceptedLogin(acceptedLogin); acceptedLogin = nullptr; } @@ -104,7 +104,7 @@ void PendingConnection::sendPreLoginResponse() { // PADDY - this is failing when a local player with chat restrictions // joins an online game - if (player != NULL && + if (player != nullptr && player->connection->m_offlineXUID != INVALID_XUID && player->connection->m_onlineXUID != INVALID_XUID) { if (player->connection->m_friendsOnlyUGC) { @@ -114,7 +114,7 @@ void PendingConnection::sendPreLoginResponse() { // the client ugcXuids[ugcXuidCount] = player->connection->m_onlineXUID; - if (player->connection->getNetworkPlayer() != NULL && + if (player->connection->getNetworkPlayer() != nullptr && player->connection->getNetworkPlayer()->IsHost()) hostIndex = ugcXuidCount; @@ -178,10 +178,10 @@ void PendingConnection::handleAcceptedLogin( std::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 + 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/Network/PlayerChunkMap.cpp b/Minecraft.Client/Network/PlayerChunkMap.cpp index be55d0174..d1f8cc505 100644 --- a/Minecraft.Client/Network/PlayerChunkMap.cpp +++ b/Minecraft.Client/Network/PlayerChunkMap.cpp @@ -85,7 +85,7 @@ void PlayerChunkMap::PlayerChunk::add(std::shared_ptr player, } void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr player) { - PlayerChunkMap::PlayerChunk* toDelete = NULL; + PlayerChunkMap::PlayerChunk* toDelete = nullptr; // app.DebugPrintf("--- PlayerChunkMap::PlayerChunk::remove // x=%d\tz=%d\n",x,z); @@ -129,17 +129,17 @@ void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr player) { // 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 && + if (player->connection != nullptr && player->seenChunks.find(pos) != player->seenChunks.end()) { INetworkPlayer* thisNetPlayer = player->connection->getNetworkPlayer(); bool noOtherPlayersFound = true; - if (thisNetPlayer != NULL) { + if (thisNetPlayer != nullptr) { for (AUTO_VAR(it, players.begin()); it < players.end(); ++it) { std::shared_ptr currPlayer = *it; INetworkPlayer* currNetPlayer = currPlayer->connection->getNetworkPlayer(); - if (currNetPlayer != NULL && + if (currNetPlayer != nullptr && currNetPlayer->IsSameSystem(thisNetPlayer) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end()) { @@ -155,7 +155,7 @@ void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr player) { } } else { // app.DebugPrintf("PlayerChunkMap::PlayerChunk::remove - QNetPlayer - // is NULL\n"); + // is nullptr\n"); } } @@ -221,14 +221,14 @@ void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr packet) { bool dontSend = false; if (sentTo.size()) { INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer(); - if (thisPlayer == NULL) { + if (thisPlayer == nullptr) { dontSend = true; } else { for (unsigned int j = 0; j < sentTo.size(); j++) { std::shared_ptr player2 = sentTo[j]; INetworkPlayer* otherPlayer = player2->connection->getNetworkPlayer(); - if (otherPlayer != NULL && + if (otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer)) { dontSend = true; } @@ -275,7 +275,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr packet) { 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 @@ -291,14 +291,14 @@ void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr packet) { bool dontSend = false; if (sentTo.size()) { INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer(); - if (thisPlayer == NULL) { + if (thisPlayer == nullptr) { dontSend = true; } else { for (unsigned int j = 0; j < sentTo.size(); j++) { std::shared_ptr player2 = sentTo[j]; INetworkPlayer* otherPlayer = player2->connection->getNetworkPlayer(); - if (otherPlayer != NULL && + if (otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer)) { dontSend = true; } @@ -387,9 +387,9 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) { } void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr te) { - if (te != NULL) { + if (te != nullptr) { std::shared_ptr p = te->getUpdatePacket(); - if (p != NULL) { + if (p != nullptr) { broadcast(p); } } @@ -473,7 +473,7 @@ PlayerChunkMap::PlayerChunk* PlayerChunkMap::getChunk(int x, int z, int64_t id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32); AUTO_VAR(it, chunks.find(id)); - PlayerChunk* chunk = NULL; + PlayerChunk* chunk = nullptr; if (it != chunks.end()) { chunk = it->second; } else if (create) { @@ -552,7 +552,7 @@ void PlayerChunkMap::broadcastTileUpdate(std::shared_ptr packet, int x, int xc = x >> 4; int zc = z >> 4; PlayerChunk* chunk = getChunk(xc, zc, false); - if (chunk != NULL) { + if (chunk != nullptr) { chunk->broadcast(packet); } } @@ -561,7 +561,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); } } @@ -580,7 +580,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(); } } @@ -690,7 +690,7 @@ void PlayerChunkMap::remove(std::shared_ptr player) { for (int x = xc - radius; x <= xc + radius; x++) 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_VAR(it, find(players.begin(), players.end(), player)); @@ -761,7 +761,7 @@ bool PlayerChunkMap::isPlayerIn(std::shared_ptr player, int xChunk, int zChunk) { PlayerChunk* chunk = getChunk(xChunk, zChunk, false); - if (chunk == NULL) { + if (chunk == nullptr) { return false; } else { AUTO_VAR(it1, @@ -771,7 +771,7 @@ bool PlayerChunkMap::isPlayerIn(std::shared_ptr player, return it1 != chunk->players.end() && it2 == player->chunksToSend.end(); } - // return chunk == NULL ? false : chunk->players->contains(player) && + // return chunk == nullptr ? false : chunk->players->contains(player) && // !player->chunksToSend->contains(chunk->pos); } diff --git a/Minecraft.Client/Network/PlayerConnection.cpp b/Minecraft.Client/Network/PlayerConnection.cpp index e5323972e..f8b7c9eda 100644 --- a/Minecraft.Client/Network/PlayerConnection.cpp +++ b/Minecraft.Client/Network/PlayerConnection.cpp @@ -162,7 +162,7 @@ void PlayerConnection::handleMovePlayer( } if (synched) { - if (player->riding != NULL) { + if (player->riding != nullptr) { float yRotT = player->yRot; float xRotT = player->xRot; player->riding->positionRider(); @@ -180,7 +180,7 @@ void PlayerConnection::handleMovePlayer( 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 @@ -467,7 +467,7 @@ void PlayerConnection::handleUseItem(std::shared_ptr packet) { 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 && @@ -524,15 +524,15 @@ void PlayerConnection::handleUseItem(std::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( @@ -582,7 +582,7 @@ void PlayerConnection::onUnhandledPacket(std::shared_ptr packet) { } void PlayerConnection::send(std::shared_ptr packet) { - if (connection->getSocket() != NULL) { + if (connection->getSocket() != nullptr) { if (!server->getPlayers()->canReceiveAllPackets(player)) { // Check if we are allowed to send this packet type if (!Packet::canSendToAnyClient(packet)) { @@ -598,7 +598,7 @@ void PlayerConnection::send(std::shared_ptr packet) { // 4J Added void PlayerConnection::queueSend(std::shared_ptr packet) { - if (connection->getSocket() != NULL) { + if (connection->getSocket() != nullptr) { if (!server->getPlayers()->canReceiveAllPackets(player)) { // Check if we are allowed to send this packet type if (!Packet::canSendToAnyClient(packet)) { @@ -654,14 +654,14 @@ void PlayerConnection::handlePlayerCommand( synched = false; } else if (packet->action == PlayerCommandPacket::RIDING_JUMP) { // currently only supported by horses... - if ((player->riding != NULL) && + if ((player->riding != nullptr) && player->riding->GetType() == eTYPE_HORSE) { std::dynamic_pointer_cast(player->riding) ->onPlayerJump(packet->data); } } else if (packet->action == PlayerCommandPacket::OPEN_INVENTORY) { // also only supported by horses... - if ((player->riding != NULL) && + if ((player->riding != nullptr) && player->riding->instanceof(eTYPE_HORSE)) { std::dynamic_pointer_cast(player->riding) ->openInventory(player); @@ -711,7 +711,7 @@ void PlayerConnection::handleInteract(std::shared_ptr packet) { // 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) && + if (target != nullptr) // && player->canSee(target) && // player->distanceToSqr(target) < 6 * 6) { // boole canSee = player->canSee(target); @@ -752,7 +752,7 @@ void PlayerConnection::handleTexture(std::shared_ptr packet) { wprintf(L"Server received request for custom texture %ls\n", packet->textureName.c_str()); #endif - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; app.GetMemFileDetails(packet->textureName, &pbData, &dwBytes); @@ -785,7 +785,7 @@ void PlayerConnection::handleTextureAndGeometry( wprintf(L"Server received request for custom texture %ls\n", packet->textureName.c_str()); #endif - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; unsigned int dwTextureBytes = 0; app.GetMemFileDetails(packet->textureName, &pbData, &dwTextureBytes); DLCSkinFile* pDLCSkinFile = @@ -854,7 +854,7 @@ void PlayerConnection::handleTextureReceived(const std::wstring& textureName) { AUTO_VAR(it, find(m_texturesRequested.begin(), m_texturesRequested.end(), textureName)); if (it != m_texturesRequested.end()) { - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; app.GetMemFileDetails(textureName, &pbData, &dwBytes); @@ -873,7 +873,7 @@ void PlayerConnection::handleTextureAndGeometryReceived( AUTO_VAR(it, find(m_texturesRequested.begin(), m_texturesRequested.end(), textureName)); if (it != m_texturesRequested.end()) { - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; unsigned int dwTextureBytes = 0; app.GetMemFileDetails(textureName, &pbData, &dwTextureBytes); DLCSkinFile* pDLCSkinFile = app.m_dlcManager.getSkinFile(textureName); @@ -933,12 +933,12 @@ void PlayerConnection::handleTextureChange( packet->path.c_str(), player->name.c_str()); #endif send(std::shared_ptr( - new TexturePacket(packet->path, NULL, 0))); + 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( std::shared_ptr( @@ -968,12 +968,12 @@ void PlayerConnection::handleTextureAndGeometryChange( packet->path.c_str(), player->name.c_str()); #endif send(std::shared_ptr( - new TextureAndGeometryPacket(packet->path, NULL, 0))); + 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); @@ -995,7 +995,7 @@ void PlayerConnection::handleServerSettingsChanged( // individual setting? INetworkPlayer* networkPlayer = getNetworkPlayer(); - if ((networkPlayer != NULL && networkPlayer->IsHost()) || + if ((networkPlayer != nullptr && networkPlayer->IsHost()) || player->isModerator()) { app.SetGameHostOption( eGameHostOption_FireSpreads, @@ -1047,7 +1047,7 @@ void PlayerConnection::handleServerSettingsChanged( void PlayerConnection::handleKickPlayer( std::shared_ptr packet) { INetworkPlayer* networkPlayer = getNetworkPlayer(); - if ((networkPlayer != NULL && networkPlayer->IsHost()) || + if ((networkPlayer != nullptr && networkPlayer->IsHost()) || player->isModerator()) { server->getPlayers()->kickPlayerByShortId(packet->m_networkSmallId); } @@ -1111,8 +1111,8 @@ void PlayerConnection::handleContainerSetSlot( packet->slot >= 36 && packet->slot < 36 + 9) { std::shared_ptr lastItem = player->inventoryMenu->getSlot(packet->slot)->getItem(); - if (packet->item != NULL) { - if (lastItem == NULL || lastItem->count < packet->item->count) { + if (packet->item != nullptr) { + if (lastItem == nullptr || lastItem->count < packet->item->count) { packet->item->popTime = Inventory::POP_TIME_DURATION; } } @@ -1185,7 +1185,7 @@ void PlayerConnection::handleSetCreativeModeSlot( bool drop = packet->slotNum < 0; std::shared_ptr item = packet->item; - if (item != NULL && item->id == Item::map_Id) { + if (item != nullptr && item->id == Item::map_Id) { int mapScale = 3; #if defined(_LARGE_WORLDS) int scale = MapItemSavedData::MAP_SIZE * 2 * (1 << mapScale); @@ -1208,7 +1208,7 @@ void PlayerConnection::handleSetCreativeModeSlot( wchar_t buf[64]; swprintf(buf, 64, L"map_%d", item->getAuxValue()); std::wstring id = std::wstring(buf); - if (data == NULL) { + if (data == nullptr) { data = std::shared_ptr(new MapItemSavedData(id)); } @@ -1227,13 +1227,13 @@ void PlayerConnection::handleSetCreativeModeSlot( 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 == 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); } else { player->inventoryMenu->setItem(packet->slotNum, item); @@ -1247,13 +1247,13 @@ void PlayerConnection::handleSetCreativeModeSlot( dropSpamTickCount += SharedConstants::TICKS_PER_SECOND; // drop item std::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 @@ -1289,7 +1289,7 @@ void PlayerConnection::handleSignUpdate( std::shared_ptr te = level->getTileEntity(packet->x, packet->y, packet->z); - if (std::dynamic_pointer_cast(te) != NULL) { + if (std::dynamic_pointer_cast(te) != nullptr) { std::shared_ptr ste = std::dynamic_pointer_cast(te); if (!ste->isEditable() || ste->getPlayerWhoMayEdit() != player) { @@ -1300,7 +1300,7 @@ void PlayerConnection::handleSignUpdate( } // 4J-JEV: Changed to allow characters to display as a []. - if (std::dynamic_pointer_cast(te) != NULL) { + if (std::dynamic_pointer_cast(te) != nullptr) { int x = packet->x; int y = packet->y; int z = packet->z; @@ -1331,14 +1331,14 @@ void PlayerConnection::handlePlayerInfo( // setting? INetworkPlayer* networkPlayer = getNetworkPlayer(); - if ((networkPlayer != NULL && networkPlayer->IsHost()) || + if ((networkPlayer != nullptr && networkPlayer->IsHost()) || player->isModerator()) { std::shared_ptr serverPlayer; // Find the player being edited for (AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it) { std::shared_ptr checkingPlayer = *it; - if (checkingPlayer->connection->getNetworkPlayer() != NULL && + if (checkingPlayer->connection->getNetworkPlayer() != nullptr && checkingPlayer->connection->getNetworkPlayer()->GetSmallId() == packet->m_networkSmallId) { serverPlayer = checkingPlayer; @@ -1346,7 +1346,7 @@ void PlayerConnection::handlePlayerInfo( } } - if (serverPlayer != NULL) { + if (serverPlayer != nullptr) { unsigned int origPrivs = serverPlayer->getAllPlayerGamePrivileges(); bool trustPlayers = @@ -1564,7 +1564,7 @@ void PlayerConnection::handleCustomPayload( player->level->getTileEntity(x, y, z); std::shared_ptr cbe = std::dynamic_pointer_cast(tileEntity); - if (tileEntity != NULL && cbe != NULL) { + if (tileEntity != nullptr && cbe != nullptr) { cbe->setCommand(command); player->level->sendTileUpdated(x, y, z); // player->sendMessage(ChatMessageComponent.forTranslation("advMode.setCommand.success", @@ -1575,7 +1575,7 @@ void PlayerConnection::handleCustomPayload( } } 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); int primary = input.readInt(); @@ -1596,7 +1596,7 @@ void PlayerConnection::handleCustomPayload( customPayloadPacket->identifier) == 0) { AnvilMenu* menu = dynamic_cast(player->containerMenu); if (menu) { - if (customPayloadPacket->data.data == NULL || + if (customPayloadPacket->data.data == nullptr || customPayloadPacket->data.length < 1) { menu->setItemName(L""); } else { @@ -1680,7 +1680,7 @@ void PlayerConnection::handleCraftItem( // 4J Stu - Fix for #13097 - Bug: Milk Buckets are removed when // crafting Cake - if (ingItemInst != NULL) { + if (ingItemInst != nullptr) { if (ingItemInst->getItem()->hasCraftingRemainingItem()) { // replace item with remaining result player->inventory->add( @@ -1795,8 +1795,8 @@ void PlayerConnection::handleTradeItem( 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); // Remove the items we are purchasing with @@ -1825,14 +1825,14 @@ void PlayerConnection::handleTradeItem( } INetworkPlayer* PlayerConnection::getNetworkPlayer() { - if (connection != NULL && connection->getSocket() != NULL) + if (connection != nullptr && connection->getSocket() != nullptr) return connection->getSocket()->getPlayer(); else - return NULL; + return nullptr; } bool PlayerConnection::isLocal() { - if (connection->getSocket() == NULL) { + if (connection->getSocket() == nullptr) { return false; } else { bool isLocal = connection->getSocket()->isLocal(); @@ -1841,12 +1841,12 @@ bool PlayerConnection::isLocal() { } bool PlayerConnection::isGuest() { - if (connection->getSocket() == NULL) { + if (connection->getSocket() == nullptr) { return false; } else { INetworkPlayer* networkPlayer = connection->getSocket()->getPlayer(); bool isGuest = false; - if (networkPlayer != NULL) { + if (networkPlayer != nullptr) { isGuest = networkPlayer->IsGuest() == TRUE; } return isGuest; diff --git a/Minecraft.Client/Network/PlayerList.cpp b/Minecraft.Client/Network/PlayerList.cpp index 74e1c4fa9..a3aad94bc 100644 --- a/Minecraft.Client/Network/PlayerList.cpp +++ b/Minecraft.Client/Network/PlayerList.cpp @@ -30,12 +30,12 @@ // point in porting code for banning, whitelisting, ops etc. PlayerList::PlayerList(MinecraftServer* server) { - playerIo = NULL; + playerIo = nullptr; this->server = server; sendAllPlayerInfoIn = 0; - overrideGameMode = NULL; + overrideGameMode = nullptr; allowCheatsForAllPlayers = false; #if defined(_LARGE_WORLDS) @@ -59,7 +59,7 @@ PlayerList::~PlayerList() { // else there is a circular dependency delete (*it)->gameMode; // Gamemode also needs deleted as it references // back to this player - (*it)->gameMode = NULL; + (*it)->gameMode = nullptr; } DeleteCriticalSection(&m_kickPlayersCS); @@ -71,14 +71,14 @@ void PlayerList::placeNewPlayer(Connection* connection, std::shared_ptr packet) { CompoundTag* playerTag = load(player); - bool newPlayer = playerTag == NULL; + bool newPlayer = playerTag == nullptr; player->setLevel(server->getLevel(player->dimension)); player->gameMode->setLevel((ServerLevel*)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); } @@ -140,7 +140,7 @@ void PlayerList::placeNewPlayer(Connection* connection, Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(), 0, centreXC, centreZC, mapScale)))); - if (app.getGameRuleDefinitions() != NULL) { + if (app.getGameRuleDefinitions() != nullptr) { app.getGameRuleDefinitions()->postProcessPlayer(player); } } @@ -157,13 +157,13 @@ void PlayerList::placeNewPlayer(Connection* connection, player->customTextureUrl.c_str(), player->name.c_str()); #endif playerConnection->send(std::shared_ptr( - new TextureAndGeometryPacket(player->customTextureUrl, NULL, + 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() && @@ -178,12 +178,12 @@ void PlayerList::placeNewPlayer(Connection* connection, player->customTextureUrl2.c_str(), player->name.c_str()); #endif playerConnection->send(std::shared_ptr( - new TexturePacket(player->customTextureUrl2, NULL, 0))); + 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); @@ -277,11 +277,11 @@ void PlayerList::placeNewPlayer(Connection* connection, 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 std::shared_ptr mount = EntityIO::loadStatic( playerTag->getCompound(Entity::RIDING_TAG), level); - if (mount != NULL) { + if (mount != nullptr) { mount->forcedLoading = true; level->addEntity(mount); player->ride(mount); @@ -293,12 +293,12 @@ void PlayerList::placeNewPlayer(Connection* connection, // is travelling through the win portal, then we should set our wonGame flag // to true so that respawning works when the EndPoem is closed INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer(); - if (thisPlayer != NULL) { + if (thisPlayer != nullptr) { for (AUTO_VAR(it, players.begin()); it != players.end(); ++it) { std::shared_ptr servPlayer = *it; INetworkPlayer* checkPlayer = servPlayer->connection->getNetworkPlayer(); - if (thisPlayer != checkPlayer && checkPlayer != NULL && + if (thisPlayer != checkPlayer && checkPlayer != nullptr && thisPlayer->IsSameSystem(checkPlayer) && servPlayer->wonGame) { player->wonGame = true; break; @@ -321,7 +321,7 @@ void PlayerList::updateEntireScoreboard(ServerScoreboard* scoreboard, //{ // Objective objective = scoreboard->getDisplayObjective(slot); - // if (objective != NULL && !objectives->contains(objective)) + // if (objective != nullptr && !objectives->contains(objective)) // { // vector > *packets = // scoreboard->getStartTrackingPackets(objective); @@ -344,7 +344,7 @@ void PlayerList::changeDimension(std::shared_ptr player, ServerLevel* from) { 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(((int)player->x) >> 4, ((int)player->z) >> 4); @@ -427,10 +427,10 @@ void PlayerList::validatePlayerSpawnPosition( 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); @@ -472,7 +472,7 @@ void PlayerList::add(std::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++) { @@ -490,7 +490,7 @@ void PlayerList::add(std::shared_ptr player) { for (unsigned int i = 0; i < players.size(); i++) { std::shared_ptr thisPlayer = players[i]; if (thisPlayer->isSleeping()) { - if (firstSleepingPlayer == NULL) + if (firstSleepingPlayer == nullptr) firstSleepingPlayer = thisPlayer; thisPlayer->connection->send( std::shared_ptr(new ChatPacket( @@ -512,7 +512,7 @@ void PlayerList::remove(std::shared_ptr player) { // 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) { // remove mount first because the player unmounts when being // removed, also remove mount because it's saved in the player's // save tag @@ -533,11 +533,11 @@ void PlayerList::remove(std::shared_ptr player) { // 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); } std::shared_ptr PlayerList::getPlayerForLogin( @@ -559,14 +559,14 @@ std::shared_ptr PlayerList::getPlayerForLogin( // 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, @@ -602,7 +602,7 @@ std::shared_ptr PlayerList::respawn( 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; @@ -704,7 +704,7 @@ std::shared_ptr PlayerList::respawn( // 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; } @@ -712,11 +712,11 @@ std::shared_ptr PlayerList::respawn( // 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); @@ -807,7 +807,7 @@ void PlayerList::toggleDimension(std::shared_ptr player, 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; @@ -1006,11 +1006,11 @@ void PlayerList::tick() { for (unsigned int i = 0; i < players.size(); i++) { std::shared_ptr p = players.at(i); - // 4J Stu - May be being a bit overprotective with all the NULL + // 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 != NULL && p->connection != NULL && - p->connection->connection != NULL && - p->connection->connection->getSocket() != NULL && + if (p != nullptr && p->connection != nullptr && + p->connection->connection != nullptr && + p->connection->connection->getSocket() != nullptr && p->connection->connection->getSocket()->getSmallId() == smallId) { player = p; @@ -1018,7 +1018,7 @@ void PlayerList::tick() { } } - if (player != NULL) { + if (player != nullptr) { player->connection->disconnect( DisconnectPacket::eDisconnect_Closed); } @@ -1031,7 +1031,7 @@ void PlayerList::tick() { m_smallIdsToKick.pop_front(); INetworkPlayer* selectedPlayer = g_NetworkManager.GetPlayerBySmallId(smallId); - if (selectedPlayer != NULL) { + if (selectedPlayer != nullptr) { if (selectedPlayer->IsLocal() != TRUE) { // #if 0 PlayerUID xuid = selectedPlayer->GetUID(); @@ -1041,14 +1041,14 @@ void PlayerList::tick() { for (unsigned int i = 0; i < players.size(); i++) { std::shared_ptr p = players.at(i); PlayerUID playersXuid = p->getOnlineXuid(); - if (p != NULL && + 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 @@ -1074,7 +1074,7 @@ void PlayerList::tick() { if (currentPlayer->removed) { std::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 " @@ -1132,7 +1132,7 @@ bool PlayerList::isOp(std::shared_ptr player) { INetworkPlayer* networkPlayer = player->connection->getNetworkPlayer(); bool isOp = cheatsEnabled && (player->isModerator() || - (networkPlayer != NULL && networkPlayer->IsHost())); + (networkPlayer != nullptr && networkPlayer->IsHost())); return isOp; } @@ -1167,7 +1167,7 @@ std::shared_ptr PlayerList::getPlayer(PlayerUID uid) { std::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); std::shared_ptr current = nullptr; double dist = -1; int rangeSqr = range * range; @@ -1194,9 +1194,9 @@ std::vector* PlayerList::getPlayers( const std::wstring& playerName, const std::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("!"); bool @@ -1282,7 +1282,7 @@ bool PlayerList::meetsScoreRequirements( void PlayerList::sendMessage(const std::wstring& name, const std::wstring& message) { std::shared_ptr player = getPlayer(name); - if (player != NULL) { + if (player != nullptr) { player->connection->send( std::shared_ptr(new ChatPacket(message))); } @@ -1300,7 +1300,7 @@ void PlayerList::broadcast(std::shared_ptr except, double x, double y, // Add the source player to the machines we have "sent" to as it doesn't // need to go to that machine either std::vector > sentTo; - if (except != NULL) { + if (except != nullptr) { sentTo.push_back(std::dynamic_pointer_cast(except)); } @@ -1313,14 +1313,14 @@ void PlayerList::broadcast(std::shared_ptr except, double x, double y, bool dontSend = false; if (sentTo.size()) { INetworkPlayer* thisPlayer = p->connection->getNetworkPlayer(); - if (thisPlayer == NULL) { + if (thisPlayer == nullptr) { dontSend = true; } else { for (unsigned int j = 0; j < sentTo.size(); j++) { std::shared_ptr player2 = sentTo[j]; INetworkPlayer* otherPlayer = player2->connection->getNetworkPlayer(); - if (otherPlayer != NULL && + if (otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer)) { dontSend = true; } @@ -1343,9 +1343,9 @@ void PlayerList::broadcast(std::shared_ptr except, double x, double y, void PlayerList::saveAll(ProgressListener* progressListener, bool bDeleteGuestMaps /*= false*/) { - if (progressListener != NULL) + if (progressListener != nullptr) progressListener->progressStart(IDS_PROGRESS_SAVING_PLAYERS); - // 4J - playerIo can be NULL if we have have to exit a game really early on + // 4J - playerIo can be nullptr if we have have to exit a game really early on // due to network failure if (playerIo) { playerIo->saveAllCachedData(); @@ -1357,7 +1357,7 @@ void PlayerList::saveAll(ProgressListener* progressListener, if (bDeleteGuestMaps && players[i]->isGuest()) playerIo->deleteMapFilesForPlayer(players[i]); - if (progressListener != NULL) + if (progressListener != nullptr) progressListener->progressStagePercentage( (i * 100) / ((int)players.size())); } @@ -1431,10 +1431,10 @@ void PlayerList::updatePlayerGameMode(std::shared_ptr newPlayer, Level* level) { // 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); } newPlayer->gameMode->updateGameMode(level->getLevelData()->getGameType()); @@ -1454,7 +1454,7 @@ std::shared_ptr PlayerList::findAlivePlayerOnSystem( dimIndex = 2; INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer(); - if (thisPlayer != NULL) { + if (thisPlayer != nullptr) { for (AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP) { std::shared_ptr newPlayer = *itP; @@ -1462,7 +1462,7 @@ std::shared_ptr PlayerList::findAlivePlayerOnSystem( newPlayer->connection->getNetworkPlayer(); if (!newPlayer->removed && newPlayer != player && - newPlayer->dimension == playerDim && otherPlayer != NULL && + newPlayer->dimension == playerDim && otherPlayer != nullptr && otherPlayer->IsSameSystem(thisPlayer)) { return newPlayer; } @@ -1501,7 +1501,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, } INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer(); - if (thisPlayer != NULL && playerRemoved) { + if (thisPlayer != nullptr && playerRemoved) { for (AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP) { std::shared_ptr newPlayer = *itP; @@ -1509,7 +1509,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, newPlayer->connection->getNetworkPlayer(); if (newPlayer != player && newPlayer->dimension == playerDim && - otherPlayer != NULL && otherPlayer->IsSameSystem(thisPlayer)) { + otherPlayer != nullptr && otherPlayer->IsSameSystem(thisPlayer)) { #if !defined(_CONTENT_PACKAGE) app.DebugPrintf( "Remove: Adding player %ls as primary in dimension %d\n", @@ -1519,10 +1519,10 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, break; } } - } else if (thisPlayer == NULL) { + } else if (thisPlayer == nullptr) { #if !defined(_CONTENT_PACKAGE) app.DebugPrintf( - "Remove: Qnet player for %ls was NULL so re-checking all players\n", + "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 @@ -1533,7 +1533,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, INetworkPlayer* checkingPlayer = newPlayer->connection->getNetworkPlayer(); - if (checkingPlayer != NULL) { + if (checkingPlayer != nullptr) { int newPlayerDim = 0; if (newPlayer->dimension == -1) newPlayerDim = 1; @@ -1545,7 +1545,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, std::shared_ptr primaryPlayer = *it; INetworkPlayer* primPlayer = primaryPlayer->connection->getNetworkPlayer(); - if (primPlayer != NULL && + if (primPlayer != nullptr && checkingPlayer->IsSameSystem(primPlayer)) { foundPrimary = true; break; @@ -1581,10 +1581,10 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr player) { INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer(); - if (thisPlayer == NULL) { + if (thisPlayer == nullptr) { #if !defined(_CONTENT_PACKAGE) app.DebugPrintf( - "Add: Qnet player for player %ls is NULL so not adding them\n", + "Add: Qnet player for player %ls is nullptr so not adding them\n", player->name.c_str()); #endif shouldAddPlayer = false; @@ -1594,7 +1594,7 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr player) { std::shared_ptr oldPlayer = *it; INetworkPlayer* checkingPlayer = oldPlayer->connection->getNetworkPlayer(); - if (checkingPlayer != NULL && + if (checkingPlayer != nullptr && checkingPlayer->IsSameSystem(thisPlayer)) { shouldAddPlayer = false; break; diff --git a/Minecraft.Client/Network/ServerChunkCache.cpp b/Minecraft.Client/Network/ServerChunkCache.cpp index b72c07d57..34e3f4d0f 100644 --- a/Minecraft.Client/Network/ServerChunkCache.cpp +++ b/Minecraft.Client/Network/ServerChunkCache.cpp @@ -73,7 +73,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; } @@ -145,17 +145,17 @@ LevelChunk* ServerChunkCache::create( 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 (source == NULL) { + if (chunk == nullptr) { + if (source == nullptr) { chunk = emptyChunk; } else { chunk = source->getChunk(x, z); } } - if (chunk != NULL) { + if (chunk != nullptr) { chunk->load(); } @@ -349,7 +349,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) { @@ -418,35 +418,35 @@ void ServerChunkCache::dontDrop(int x, int z) { #endif LevelChunk* ServerChunkCache::load(int x, int z) { - if (storage == NULL) return NULL; + if (storage == nullptr) return nullptr; - LevelChunk* levelChunk = NULL; + LevelChunk* levelChunk = nullptr; #if defined(_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(); } return levelChunk; } 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); @@ -584,7 +584,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); PIXEndNamedEvent(); @@ -675,7 +675,7 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) { // 4J - added this to support progressListner int count = 0; - if (progressListener != NULL) { + if (progressListener != nullptr) { AUTO_VAR(itEnd, m_loadedChunkList.end()); for (AUTO_VAR(it, m_loadedChunkList.begin()); it != itEnd; it++) { LevelChunk* chunk = *it; @@ -706,7 +706,7 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) { } // 4J - added this to support progressListener - if (progressListener != NULL) { + if (progressListener != nullptr) { if (++cc % 10 == 0) { progressListener->progressStagePercentage(cc * 100 / count); @@ -756,7 +756,7 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) { } // 4J - added this to support progressListener - if (progressListener != NULL) { + if (progressListener != nullptr) { if (++cc % 10 == 0) { progressListener->progressStagePercentage(cc * 100 / count); @@ -775,7 +775,7 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) { } if (force) { - if (storage == NULL) { + if (storage == nullptr) { LeaveCriticalSection(&m_csLoadCreate); return true; } @@ -822,14 +822,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(); @@ -872,7 +872,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"); if (params->saveEntities) diff --git a/Minecraft.Client/Network/ServerConnection.cpp b/Minecraft.Client/Network/ServerConnection.cpp index 18dc87556..807e1d811 100644 --- a/Minecraft.Client/Network/ServerConnection.cpp +++ b/Minecraft.Client/Network/ServerConnection.cpp @@ -71,7 +71,7 @@ void ServerConnection::tick() { // logger.log(Level.WARNING, "Failed to handle packet: " // + e, e); // } - if (uc->connection != NULL) uc->connection->flush(); + if (uc->connection != nullptr) uc->connection->flush(); } } @@ -153,7 +153,7 @@ void ServerConnection::handleServerSettingsChanged( if (packet->action == ServerSettingsChangedPacket::HOST_DIFFICULTY) { for (unsigned int i = 0; i < pMinecraft->levels.length; ++i) { - if (pMinecraft->levels[i] != NULL) { + if (pMinecraft->levels[i] != nullptr) { app.DebugPrintf( "ClientConnection::handleServerSettingsChanged - " "Difficulty = %d", diff --git a/Minecraft.Client/Network/ServerScoreboard.cpp b/Minecraft.Client/Network/ServerScoreboard.cpp index f1eb63ec6..5f93e8ae7 100644 --- a/Minecraft.Client/Network/ServerScoreboard.cpp +++ b/Minecraft.Client/Network/ServerScoreboard.cpp @@ -31,7 +31,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) // { @@ -45,7 +45,7 @@ void ServerScoreboard::setDisplayObjective(int slot, Objective* objective) { // } // } - // if (objective != NULL) + // if (objective != nullptr) //{ // if (trackedObjectives.contains(objective)) // { @@ -144,7 +144,7 @@ void ServerScoreboard::setSaveData(ScoreboardSaveData* data) { } void ServerScoreboard::setDirty() { - // if (saveData != NULL) + // if (saveData != nullptr) //{ // saveData->setDirty(); // } @@ -152,7 +152,7 @@ void ServerScoreboard::setDirty() { std::vector >* ServerScoreboard::getStartTrackingPackets(Objective* objective) { - return NULL; + return nullptr; // vector > *packets = new vector >(); // packets.push_back( shared_ptr( new @@ -191,7 +191,7 @@ void ServerScoreboard::startTrackingObjective(Objective* objective) { std::vector >* ServerScoreboard::getStopTrackingPackets( Objective* objective) { - return NULL; + return nullptr; // vector > *packets = new ArrayList(); // packets->push_back( shared_ptr* players, float a) { if (players) { bool bListenerPostionSet = false; for (int i = 0; i < MAX_LOCAL_PLAYERS; i++) { - if (players[i] != NULL) { + if (players[i] != nullptr) { m_ListenerA[i].bValid = true; F32 x, y, z; x = players[i]->xo + (players[i]->x - players[i]->xo) * a; @@ -1157,7 +1157,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, @@ -1350,7 +1350,7 @@ void SoundEngine::playStreaming(const std::wstring& name, float x, float y, bool playerInNether = false; 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) { playerInEnd = true; @@ -1511,7 +1511,7 @@ void SoundEngine::playMusicUpdate() { // proceed to actually playing if (!m_openStreamThread->isRunning()) { delete m_openStreamThread; - m_openStreamThread = NULL; + m_openStreamThread = nullptr; HSAMPLE hSample = AIL_stream_sample_handle(m_hStream); @@ -1593,7 +1593,7 @@ void SoundEngine::playMusicUpdate() { case eMusicStreamState_OpeningCancel: if (!m_openStreamThread->isRunning()) { delete m_openStreamThread; - m_openStreamThread = NULL; + m_openStreamThread = nullptr; m_StreamState = eMusicStreamState_Stop; } break; @@ -1612,13 +1612,13 @@ void SoundEngine::playMusicUpdate() { break; case eMusicStreamState_Playing: 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) { playerInEnd = true; @@ -1750,7 +1750,7 @@ void SoundEngine::playMusicUpdate() { bool playerInNether = false; 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) { playerInEnd = true; @@ -1901,7 +1901,7 @@ bool SoundEngine::isStreamingWavebankReady() { return true; } // This is unused by the linux version, it'll need to be changed char* SoundEngine::ConvertSoundPathToName(const std::wstring& name, bool bConvertSpaces) { - return NULL; + return nullptr; } void ConsoleSoundEngine::tick() { diff --git a/Minecraft.Client/Platform/Common/C4JMemoryPool.h b/Minecraft.Client/Platform/Common/C4JMemoryPool.h index e1e795ec2..9e9b4db95 100644 --- a/Minecraft.Client/Platform/Common/C4JMemoryPool.h +++ b/Minecraft.Client/Platform/Common/C4JMemoryPool.h @@ -36,8 +36,8 @@ public: m_sizeOfEachBlock = 0; m_numFreeBlocks = 0; m_numInitialized = 0; - m_memStart = NULL; - m_memEnd = NULL; + m_memStart = nullptr; + m_memEnd = nullptr; m_next = 0; } @@ -65,7 +65,7 @@ public: void DestroyPool() { delete[] m_memStart; - m_memStart = NULL; + m_memStart = nullptr; } uchar* AddrFromIndex(uint i) const @@ -89,7 +89,7 @@ public: *p = m_numInitialized + 1; m_numInitialized++; } - void* ret = NULL; + void* ret = nullptr; if ( m_numFreeBlocks > 0 ) { ret = (void*)m_next; @@ -100,7 +100,7 @@ public: } else { - m_next = NULL; + m_next = nullptr; } } // LeaveCriticalSection(&m_CS); @@ -115,7 +115,7 @@ public: return; } // EnterCriticalSection(&m_CS); - if (m_next != NULL) + if (m_next != nullptr) { (*(uint*)ptr) = IndexFromAddr( m_next ); m_next = (uchar*)ptr; diff --git a/Minecraft.Client/Platform/Common/Consoles_App.cpp b/Minecraft.Client/Platform/Common/Consoles_App.cpp index 77c72401e..1c3036c28 100644 --- a/Minecraft.Client/Platform/Common/Consoles_App.cpp +++ b/Minecraft.Client/Platform/Common/Consoles_App.cpp @@ -149,9 +149,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; @@ -708,7 +708,7 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings, 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); } @@ -1032,7 +1032,7 @@ void CMinecraftApp::ActionGameSettings(int iPad, eGameSetting eVal) { 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) @@ -1111,7 +1111,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() && @@ -1149,7 +1149,7 @@ void CMinecraftApp::ActionGameSettings(int iPad, eGameSetting eVal) { case eGameSetting_DisplaySplitscreenGamertags: for (std::uint8_t 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) { ui.DisplayGamertag(idx, false); @@ -1188,7 +1188,7 @@ void CMinecraftApp::ActionGameSettings(int iPad, eGameSetting eVal) { // nothing to do here break; case eGameSetting_BedrockFog: { - bool bInGame = pMinecraft->level != NULL; + bool bInGame = pMinecraft->level != nullptr; // Game Host only if (bInGame && g_NetworkManager.IsHost() && @@ -1249,7 +1249,7 @@ void CMinecraftApp::SetPlayerSkin(int iPad, std::uint32_t dwSkinId) { TelemetryManager->RecordSkinChanged(iPad, GameSettingsA[iPad]->dwSelectedSkin); - if (Minecraft::GetInstance()->localplayers[iPad] != NULL) + if (Minecraft::GetInstance()->localplayers[iPad] != nullptr) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomSkin( dwSkinId); } @@ -1261,8 +1261,8 @@ std::wstring CMinecraftApp::GetPlayerSkinName(int iPad) { std::uint32_t 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; std::uint32_t dwSkin = GameSettingsA[iPad]->dwSelectedSkin; wchar_t chars[256]; @@ -1312,7 +1312,7 @@ void CMinecraftApp::SetPlayerCape(int iPad, std::uint32_t dwCapeId) { // SentientManager.RecordSkinChanged(iPad, // GameSettingsA[iPad]->dwSelectedSkin); - if (Minecraft::GetInstance()->localplayers[iPad] != NULL) + if (Minecraft::GetInstance()->localplayers[iPad] != nullptr) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomCape( dwCapeId); } @@ -1373,7 +1373,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 @@ -1416,7 +1416,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; } else { return GameSettingsA[iPad]->ucLanguage; @@ -1430,7 +1430,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; } else { return GameSettingsA[iPad]->ucLocale; @@ -2044,7 +2044,7 @@ unsigned int CMinecraftApp::GetGameSettingsDebugMask( std::shared_ptr player = Minecraft::GetInstance()->localplayers[iPad]; - if (bOverridePlayer || player == NULL) { + if (bOverridePlayer || player == nullptr) { return GameSettingsA[iPad]->uiDebugBitmask; } else { return player->GetDebugOptions(); @@ -2311,7 +2311,7 @@ void CMinecraftApp::HandleXuiActions(void) { // 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); } @@ -2385,7 +2385,7 @@ void CMinecraftApp::HandleXuiActions(void) { // This just allows it to be shown if (pMinecraft ->localgameModes[ProfileManager.GetPrimaryPad()] != - NULL) + nullptr) pMinecraft ->localgameModes[ProfileManager.GetPrimaryPad()] ->getTutorial() @@ -2699,8 +2699,8 @@ void CMinecraftApp::HandleXuiActions(void) { // 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; + FALSE; //(param != nullptr) ? TRUE : FALSE; + completionData->bShowTips = (param != nullptr) ? FALSE : TRUE; completionData->bShowBackground = TRUE; completionData->bShowLogo = TRUE; completionData->type = @@ -2823,7 +2823,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); if (ui.IsSceneInStack(i, eUIScene_EndPoem)) { @@ -2842,7 +2842,7 @@ void CMinecraftApp::HandleXuiActions(void) { break; case eAppAction_WaitForDimensionChangeComplete: player = pMinecraft->localplayers[i]; - if (player != NULL && player->connection && + if (player != nullptr && player->connection && player->connection->isStarted()) { SetAction(i, eAppAction_Idle); ui.CloseUIScenes(i); @@ -2930,7 +2930,7 @@ void CMinecraftApp::HandleXuiActions(void) { bool gameStarted = false; for (int j = 0; j < pMinecraft->levels.length; j++) { - if (pMinecraft->levels.data[j] != NULL) { + if (pMinecraft->levels.data[j] != nullptr) { gameStarted = true; break; } @@ -3187,7 +3187,7 @@ void CMinecraftApp::HandleXuiActions(void) { // unmount the pack TexturePack* pTexPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack* pDLCTexPack = NULL; + DLCTexturePack* pDLCTexPack = nullptr; if (pTexPack->hasAudio()) { // get the dlc texture pack, and store it @@ -3328,7 +3328,7 @@ void CMinecraftApp::HandleXuiActions(void) { loadingParams->func = &CGameNetworkManager:: ChangeSessionTypeThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = nullptr; UIFullscreenProgressCompletionData* completionData = new UIFullscreenProgressCompletionData(); @@ -3391,7 +3391,7 @@ void CMinecraftApp::HandleXuiActions(void) { LoadingInputParams* loadingParams = new LoadingInputParams(); loadingParams->func = &CMinecraftApp::RemoteSaveThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = nullptr; UIFullscreenProgressCompletionData* completionData = new UIFullscreenProgressCompletionData(); @@ -3707,7 +3707,7 @@ void CMinecraftApp::loadMediaArchive() { void CMinecraftApp::loadStringTable() { - if (m_stringTable != NULL) { + if (m_stringTable != nullptr) { // we need to unload the current std::string table, this is a reload delete m_stringTable; } @@ -3717,7 +3717,7 @@ void CMinecraftApp::loadStringTable() { m_stringTable = new StringTable(locFile.data, locFile.length); delete[] locFile.data; } else { - m_stringTable = NULL; + m_stringTable = nullptr; assert(false); // AHHHHHHHHH. } @@ -3729,7 +3729,7 @@ int CMinecraftApp::PrimaryPlayerSignedOutReturned( // 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 @@ -3748,7 +3748,7 @@ int CMinecraftApp::EthernetDisconnectReturned( 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); } else { @@ -3772,7 +3772,7 @@ int CMinecraftApp::SignoutExitWorldThreadProc(void* lpParameter) { bool saveStats = false; if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession()) { - if (lpParameter != NULL) { + if (lpParameter != nullptr) { switch (app.GetDisconnectReason()) { case DisconnectPacket::eDisconnect_Kicked: exitReasonStringId = IDS_DISCONNECTED_KICKED; @@ -3801,18 +3801,18 @@ int CMinecraftApp::SignoutExitWorldThreadProc(void* lpParameter) { exitReasonStringId); // 4J - Force a disconnection, this handles the situation that the // server has already disconnected - if (pMinecraft->levels[0] != NULL) + if (pMinecraft->levels[0] != nullptr) pMinecraft->levels[0]->disconnect(false); - if (pMinecraft->levels[1] != NULL) + 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) + if (pMinecraft->levels[0] != nullptr) pMinecraft->levels[0]->disconnect(); - if (pMinecraft->levels[1] != NULL) + if (pMinecraft->levels[1] != nullptr) pMinecraft->levels[1]->disconnect(); } @@ -3828,7 +3828,7 @@ int CMinecraftApp::SignoutExitWorldThreadProc(void* lpParameter) { // 4J Stu - Leave the session once the disconnect packet has been sent g_NetworkManager.LeaveGame(FALSE); } else { - if (lpParameter != NULL) { + if (lpParameter != nullptr) { switch (app.GetDisconnectReason()) { case DisconnectPacket::eDisconnect_Kicked: exitReasonStringId = IDS_DISCONNECTED_KICKED; @@ -3853,7 +3853,7 @@ int CMinecraftApp::SignoutExitWorldThreadProc(void* lpParameter) { 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 @@ -3882,7 +3882,7 @@ int CMinecraftApp::UnlockFullInviteReturned(void* pParam, int iPad, // 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; } @@ -4083,7 +4083,7 @@ void CMinecraftApp::SignInChangeCallback(void* pParam, // invalidates all the guest players we have in the game if (hasGuestIdChanged && pApp->m_currentSigninInfo[i].dwGuestNumber != 0 && - g_NetworkManager.GetLocalPlayerByUserIndex(i) != NULL) { + g_NetworkManager.GetLocalPlayerByUserIndex(i) != nullptr) { pApp->DebugPrintf( "Recommending removal of player at index %d " "because their guest id changed\n", @@ -4123,9 +4123,9 @@ void CMinecraftApp::SignInChangeCallback(void* pParam, // manager or in the game, need to exit player // TODO: Do we need to check the network manager? if (g_NetworkManager.GetLocalPlayerByUserIndex(i) != - NULL || + nullptr || Minecraft::GetInstance()->localplayers[i] != - NULL) { + nullptr) { pApp->DebugPrintf("Player %d signed out\n", i); pApp->SetAction(i, eAppAction_ExitPlayer); } @@ -4200,7 +4200,7 @@ void CMinecraftApp::NotificationsCallback(void* pParam, if (app.GetGameStarted() && g_NetworkManager.IsInSession()) { 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); @@ -4296,7 +4296,7 @@ int CMinecraftApp::GetLocalPlayerCount(void) { int iPlayerC = 0; Minecraft* pMinecraft = Minecraft::GetInstance(); for (int i = 0; i < XUSER_MAX_COUNT; i++) { - if (pMinecraft != NULL && pMinecraft->localplayers[i] != NULL) { + if (pMinecraft != nullptr && pMinecraft->localplayers[i] != nullptr) { iPlayerC++; } } @@ -4420,16 +4420,16 @@ int CMinecraftApp::DLCMountedCallback(void* pParam, int iPad, 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)); @@ -4480,7 +4480,7 @@ int CMinecraftApp::DLCMountedCallback(void* pParam, int iPad, // // if the file is not already in the memory textures, then read // it from TMS if(!bRes) // { -// std::uint8_t *pBuffer=NULL; +// std::uint8_t *pBuffer=nullptr; // std::uint32_t dwSize=0; // // 4J-PB - out for now for DaveK so he doesn't get the // birthday cape #ifdef _CONTENT_PACKAGE @@ -4581,7 +4581,7 @@ void CMinecraftApp::AddMemoryTextureFile(const std::wstring& wName, unsigned int byteCount) { EnterCriticalSection(&csMemFilesLock); // check it's not already in - PMEMDATA pData = NULL; + PMEMDATA pData = nullptr; AUTO_VAR(it, m_MEM_Files.find(wName)); if (it != m_MEM_Files.end()) { #if !defined(_CONTENT_PACKAGE) @@ -4591,8 +4591,8 @@ void CMinecraftApp::AddMemoryTextureFile(const std::wstring& wName, pData = (*it).second; if (pData->byteCount == 0 && byteCount != 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->byteCount = byteCount; @@ -4685,7 +4685,7 @@ void CMinecraftApp::AddMemoryTPDFile(int iConfig, std::uint8_t* pbData, unsigned int byteCount) { EnterCriticalSection(&csMemTPDLock); // check it's not already in - PMEMDATA pData = NULL; + PMEMDATA pData = nullptr; AUTO_VAR(it, m_MEM_TPD.find(iConfig)); if (it == m_MEM_TPD.end()) { pData = new MEMDATA(); @@ -4702,7 +4702,7 @@ void CMinecraftApp::AddMemoryTPDFile(int iConfig, std::uint8_t* pbData, void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) { EnterCriticalSection(&csMemTPDLock); // check it's not already in - PMEMDATA pData = NULL; + PMEMDATA pData = nullptr; AUTO_VAR(it, m_MEM_TPD.find(iConfig)); if (it != m_MEM_TPD.end()) { pData = m_MEM_TPD[iConfig]; @@ -4908,7 +4908,7 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned( ui.RequestErrorMessage( IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad, - &CMinecraftApp::WarningTrialTexturePackReturned, NULL); + &CMinecraftApp::WarningTrialTexturePackReturned, nullptr); return S_OK; } @@ -5438,10 +5438,10 @@ HRESULT CMinecraftApp::RegisterMojangData(WCHAR* pXuidName, PlayerUID xuid, WCHAR* pSkin, WCHAR* pCape) { 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) { eTempXuid = eXUID_Notch; // might be needed for the apple at some point @@ -5473,7 +5473,7 @@ HRESULT CMinecraftApp::RegisterConfigValues(WCHAR* pType, int iValue) { HRESULT hr = S_OK; // #ifdef 0 - // if(pType!=NULL) + // if(pType!=nullptr) // { // if(wcscmp(pType,L"XboxOneTransfer")==0) // { @@ -5523,7 +5523,7 @@ HRESULT CMinecraftApp::RegisterDLCData(WCHAR* pType, WCHAR* pBannerName, wcsncpy_s(pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE); } - if (pType != NULL) { + if (pType != nullptr) { if (wcscmp(pType, L"Skin") == 0) { pDLCData->eDLCType = e_DLC_SkinPack; } else if (wcscmp(pType, L"Gamerpic") == 0) { @@ -5630,18 +5630,18 @@ bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID, } } DLC_INFO* CMinecraftApp::GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial) { - // DLC_INFO *pDLCInfo=NULL; + // DLC_INFO *pDLCInfo=nullptr; if (DLCInfo_Trial.size() > 0) { AUTO_VAR(it, DLCInfo_Trial.find(ullOfferID_Trial)); if (it == DLCInfo_Trial.end()) { // nothing for this - return NULL; + return nullptr; } else { return it->second; } } else - return NULL; + return nullptr; } DLC_INFO* CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) { @@ -5682,12 +5682,12 @@ 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; + return nullptr; } void CMinecraftApp::EnterSaveNotificationSection() { @@ -5786,7 +5786,7 @@ void CMinecraftApp::ExitGameFromRemoteSave(void* lpParameter) { ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, primaryPad, - &CMinecraftApp::ExitGameFromRemoteSaveDialogReturned, NULL); + &CMinecraftApp::ExitGameFromRemoteSaveDialogReturned, nullptr); } int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned( @@ -5811,7 +5811,7 @@ int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned( } 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 << index); } } @@ -5832,7 +5832,7 @@ void CMinecraftApp::InvalidateBannedList(int iPad) { if (BannedListA[iPad].pBannedList) { delete[] BannedListA[iPad].pBannedList; - BannedListA[iPad].pBannedList = NULL; + BannedListA[iPad].pBannedList = nullptr; } } } @@ -5900,7 +5900,7 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, it != m_vBannedListA[iPad]->end();) { PBANNEDLISTDATA pBannedListData = *it; - if (pBannedListData != NULL) { + if (pBannedListData != nullptr) { if (IsEqualXUID(pBannedListData->xuid, xuid) && (strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) { @@ -6321,7 +6321,7 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, } bool CMinecraftApp::CanRecordStatsAndAchievements() { - bool isTutorial = Minecraft::GetInstance() != NULL && + 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 @@ -6983,7 +6983,7 @@ int CMinecraftApp::TMSPPFileReturned(void* pParam, int iPad, int iUserData, // set this to retrieved whether it found it or not pCurrent->eState = e_TMS_ContentState_Retrieved; - if (pFileData != NULL) { + if (pFileData != nullptr) { switch (pCurrent->eType) { case e_DLC_TexturePackData: { app.DebugPrintf("--- Got texturepack data %ls\n", @@ -7190,7 +7190,7 @@ std::vector* CMinecraftApp::SetAdditionalSkinBoxes( std::vector* CMinecraftApp::GetAdditionalModelParts( std::uint32_t dwSkinID) { EnterCriticalSection(&csAdditionalModelParts); - std::vector* pvModelParts = NULL; + std::vector* pvModelParts = nullptr; if (m_AdditionalModelParts.size() > 0) { AUTO_VAR(it, m_AdditionalModelParts.find(dwSkinID)); if (it != m_AdditionalModelParts.end()) { @@ -7205,7 +7205,7 @@ std::vector* CMinecraftApp::GetAdditionalModelParts( std::vector* CMinecraftApp::GetAdditionalSkinBoxes( std::uint32_t dwSkinID) { EnterCriticalSection(&csAdditionalSkinBoxes); - std::vector* pvSkinBoxes = NULL; + std::vector* pvSkinBoxes = nullptr; if (m_AdditionalSkinBoxes.size() > 0) { AUTO_VAR(it, m_AdditionalSkinBoxes.find(dwSkinID)); if (it != m_AdditionalSkinBoxes.end()) { @@ -7305,7 +7305,7 @@ int CMinecraftApp::TexturePackDialogReturned( } int CMinecraftApp::getArchiveFileSize(const std::wstring& filename) { - TexturePack* tPack = NULL; + TexturePack* tPack = nullptr; Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); @@ -7317,7 +7317,7 @@ int CMinecraftApp::getArchiveFileSize(const std::wstring& filename) { } bool CMinecraftApp::hasArchiveFile(const std::wstring& filename) { - TexturePack* tPack = NULL; + TexturePack* tPack = nullptr; Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); @@ -7329,7 +7329,7 @@ bool CMinecraftApp::hasArchiveFile(const std::wstring& filename) { } byteArray CMinecraftApp::getArchiveFile(const std::wstring& filename) { - TexturePack* tPack = NULL; + TexturePack* tPack = nullptr; Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); diff --git a/Minecraft.Client/Platform/Common/Consoles_App.h b/Minecraft.Client/Platform/Common/Consoles_App.h index 778c5f29b..6c6c15cef 100644 --- a/Minecraft.Client/Platform/Common/Consoles_App.h +++ b/Minecraft.Client/Platform/Common/Consoles_App.h @@ -950,7 +950,7 @@ public: m_bRead_BannedListA[iPad] = bVal; } void ClearBanList(int iPad) { - BannedListA[iPad].pBannedList = NULL; + BannedListA[iPad].pBannedList = nullptr; BannedListA[iPad].byteCount = 0; } @@ -964,7 +964,7 @@ public: virtual void GetFileFromTPD(eTPDFileType eType, std::uint8_t* pbData, unsigned int byteCount, std::uint8_t** ppbData, unsigned int* pByteCount) { - *ppbData = NULL; + *ppbData = nullptr; *pByteCount = 0; } diff --git a/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.cpp index 1550d88e2..660c49f54 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.cpp @@ -64,7 +64,7 @@ inline std::wstring ReadAudioParamString(const std::uint8_t* data, DLCAudioFile::DLCAudioFile(const std::wstring& path) : DLCFile(DLCManager::e_DLCType_Audio, path) { - m_pbData = NULL; + m_pbData = nullptr; m_dataBytes = 0; } @@ -181,7 +181,7 @@ bool DLCAudioFile::processDLCDataFile(std::uint8_t* pbData, uiCurrentByte += sizeof(int); 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/Platform/Common/DLC/DLCColourTableFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.cpp index b315c25ff..2c0ce4980 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.cpp @@ -7,11 +7,11 @@ DLCColourTableFile::DLCColourTableFile(const std::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/Platform/Common/DLC/DLCFile.h b/Minecraft.Client/Platform/Common/DLC/DLCFile.h index 73466a5b1..c6f5da912 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCFile.h @@ -19,7 +19,7 @@ public: virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes) {} virtual std::uint8_t* getData(std::uint32_t& dataBytes) { dataBytes = 0; - return NULL; + return nullptr; } virtual void addParameter(DLCManager::EDLCParameterType type, const std::wstring& value) {} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.cpp index 9af3bee97..9c1aa397b 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.cpp @@ -4,7 +4,7 @@ DLCGameRulesFile::DLCGameRulesFile(const std::wstring& path) : DLCGameRules(DLCManager::e_DLCType_GameRules, path) { - m_pbData = NULL; + m_pbData = nullptr; m_dataBytes = 0; } diff --git a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.cpp b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.cpp index 44851c826..566e6f204 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.cpp @@ -11,14 +11,14 @@ DLCGameRulesHeader::DLCGameRulesHeader(const std::wstring& path) : DLCGameRules(DLCManager::e_DLCType_GameRulesHeader, path) { - m_pbData = NULL; + m_pbData = nullptr; m_dataBytes = 0; m_hasData = false; m_grfPath = path.substr(0, path.length() - 4) + L".grf"; - lgo = NULL; + lgo = nullptr; } void DLCGameRulesHeader::addData(std::uint8_t* pbData, diff --git a/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.cpp index 2c36c7455..8c835e553 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.cpp @@ -5,7 +5,7 @@ DLCLocalisationFile::DLCLocalisationFile(const std::wstring& path) : DLCFile(DLCManager::e_DLCType_LocalisationData, path) { - m_strings = NULL; + m_strings = nullptr; } void DLCLocalisationFile::addData(std::uint8_t* pbData, diff --git a/Minecraft.Client/Platform/Common/DLC/DLCManager.cpp b/Minecraft.Client/Platform/Common/DLC/DLCManager.cpp index 868c47855..a4ecb3a22 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCManager.cpp @@ -87,12 +87,12 @@ std::wstring getMountedDlcReadPath(const std::string& path) { bool readOwnedDlcFile(const std::string& path, std::uint8_t** ppData, unsigned int* pBytesRead) { - *ppData = NULL; + *ppData = nullptr; *pBytesRead = 0; const std::wstring readPath = getMountedDlcReadPath(path); std::FILE* file = PortableFileIO::OpenBinaryFileForRead(readPath); - if (file == NULL) { + if (file == nullptr) { return false; } @@ -189,7 +189,7 @@ unsigned int DLCManager::getPackCount(EDLCType type /*= e_DLCType_All*/) { void DLCManager::addPack(DLCPack* pack) { m_packs.push_back(pack); } void DLCManager::removePack(DLCPack* pack) { - if (pack != NULL) { + if (pack != nullptr) { AUTO_VAR(it, find(m_packs.begin(), m_packs.end(), pack)); if (it != m_packs.end()) m_packs.erase(it); delete pack; @@ -214,9 +214,9 @@ void DLCManager::LanguageChanged(void) { } DLCPack* DLCManager::getPack(const std::wstring& name) { - DLCPack* pack = NULL; + DLCPack* pack = nullptr; // DWORD currentIndex = 0; - DLCPack* currentPack = NULL; + DLCPack* currentPack = nullptr; for (AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) { currentPack = *it; std::wstring wsName = currentPack->getName(); @@ -232,10 +232,10 @@ DLCPack* DLCManager::getPack(const std::wstring& name) { DLCPack* DLCManager::getPack(unsigned int index, EDLCType type /*= e_DLCType_All*/) { - DLCPack* pack = NULL; + DLCPack* pack = nullptr; if (type != e_DLCType_All) { unsigned int currentIndex = 0; - DLCPack* currentPack = NULL; + DLCPack* currentPack = nullptr; for (AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) { currentPack = *it; if (currentPack->getDLCItemsCount(type) > 0) { @@ -263,9 +263,9 @@ unsigned int DLCManager::getPackIndex(DLCPack* pack, bool& found, EDLCType type /*= e_DLCType_All*/) { unsigned int foundIndex = 0; found = false; - if (pack == NULL) { + if (pack == nullptr) { app.DebugPrintf( - "DLCManager: Attempting to find the index for a NULL pack\n"); + "DLCManager: Attempting to find the index for a nullptr pack\n"); //__debugbreak(); return foundIndex; } @@ -317,7 +317,7 @@ unsigned int DLCManager::getPackIndexContainingSkin(const std::wstring& path, } DLCPack* DLCManager::getPackContainingSkin(const std::wstring& path) { - DLCPack* foundPack = NULL; + DLCPack* foundPack = nullptr; for (AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) { DLCPack* pack = *it; if (pack->getDLCItemsCount(e_DLCType_Skin) > 0) { @@ -331,11 +331,11 @@ DLCPack* DLCManager::getPackContainingSkin(const std::wstring& path) { } DLCSkinFile* DLCManager::getSkinFile(const std::wstring& path) { - DLCSkinFile* foundSkinfile = NULL; + DLCSkinFile* foundSkinfile = nullptr; for (AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) { DLCPack* pack = *it; foundSkinfile = pack->getSkinFile(path); - if (foundSkinfile != NULL) { + if (foundSkinfile != nullptr) { break; } } @@ -345,14 +345,14 @@ DLCSkinFile* DLCManager::getSkinFile(const std::wstring& path) { unsigned int DLCManager::checkForCorruptDLCAndAlert( bool showMessage /*= true*/) { unsigned int corruptDLCCount = m_dwUnnamedCorruptDLCCount; - DLCPack* pack = NULL; - DLCPack* firstCorruptPack = NULL; + DLCPack* pack = nullptr; + DLCPack* firstCorruptPack = nullptr; for (AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) { pack = *it; if (pack->IsCorrupt()) { ++corruptDLCCount; - if (firstCorruptPack == NULL) firstCorruptPack = pack; + if (firstCorruptPack == nullptr) firstCorruptPack = pack; } } @@ -360,7 +360,7 @@ unsigned int DLCManager::checkForCorruptDLCAndAlert( if (corruptDLCCount > 0 && showMessage) { unsigned int 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", @@ -368,7 +368,7 @@ unsigned int DLCManager::checkForCorruptDLCAndAlert( C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, wchFormat); + ProfileManager.GetPrimaryPad(), nullptr, nullptr, wchFormat); } else { C4JStorage::EMessageResult result = ui.RequestErrorMessage( @@ -401,7 +401,7 @@ bool DLCManager::readDLCDataFile(unsigned int& dwFilesProcessed, return false; unsigned int bytesRead = 0; - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; if (!readOwnedDlcFile(path, &pbData, &bytesRead)) { app.DebugPrintf("Failed to open DLC data file %s\n", path.c_str()); pack->SetIsCorrupt(true); @@ -462,7 +462,7 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed, uiCurrentByte += sizeof(int); 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; } @@ -508,8 +508,8 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed, for (unsigned int i = 0; i < uiFileCount; i++) { DLCManager::EDLCType type = (DLCManager::EDLCType)fileBuf.dwType; - DLCFile* dlcFile = NULL; - DLCPack* dlcTexturePack = NULL; + DLCFile* dlcFile = nullptr; + DLCPack* dlcTexturePack = nullptr; if (type == e_DLCType_TexturePack) { dlcTexturePack = @@ -535,10 +535,10 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed, if (type == e_DLCType_PackConfig) { pack->addParameter(it->second, DLC_PARAM_WSTR(pbTemp, 0)); } else { - if (dlcFile != NULL) + if (dlcFile != nullptr) dlcFile->addParameter(it->second, DLC_PARAM_WSTR(pbTemp, 0)); - else if (dlcTexturePack != NULL) + else if (dlcTexturePack != nullptr) dlcTexturePack->addParameter(it->second, DLC_PARAM_WSTR(pbTemp, 0)); } @@ -548,16 +548,16 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed, } // pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM); - if (dlcTexturePack != NULL) { + if (dlcTexturePack != nullptr) { unsigned int texturePackFilesProcessed = 0; bool validPack = processDLCDataFile(texturePackFilesProcessed, pbTemp, fileBuf.uiFileSize, dlcTexturePack); pack->SetDataPointer( - NULL); // If it's a child pack, it doesn't own the data + nullptr); // If it's a child pack, it doesn't own the data if (!validPack || texturePackFilesProcessed == 0) { delete dlcTexturePack; - dlcTexturePack = NULL; + dlcTexturePack = nullptr; } else { pack->addChildPack(dlcTexturePack); @@ -568,7 +568,7 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed, } } ++dwFilesProcessed; - } else if (dlcFile != NULL) { + } else if (dlcFile != nullptr) { // Data dlcFile->addData(pbTemp, fileBuf.uiFileSize); @@ -610,7 +610,7 @@ std::uint32_t DLCManager::retrievePackIDFromDLCDataFile(const std::string& path, std::uint32_t packId = 0; unsigned int bytesRead = 0; - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; if (!readOwnedDlcFile(path, &pbData, &bytesRead)) { return 0; } diff --git a/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp b/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp index f85153f14..8af40e08f 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp @@ -19,12 +19,12 @@ DLCPack::DLCPack(const std::wstring& name, std::uint32_t dwLicenseMask) { 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; } @@ -48,21 +48,21 @@ DLCPack::~DLCPack() { // 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; } } } int DLCPack::GetDLCMountIndex() { - if (m_parentPack != NULL) { + if (m_parentPack != nullptr) { return m_parentPack->GetDLCMountIndex(); } return m_dlcMountIndex; } XCONTENTDEVICEID DLCPack::GetDLCDeviceID() { - if (m_parentPack != NULL) { + if (m_parentPack != nullptr) { return m_parentPack->GetDLCDeviceID(); } return m_dlcDeviceID; @@ -141,7 +141,7 @@ bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type, } DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::wstring& path) { - DLCFile* newFile = NULL; + DLCFile* newFile = nullptr; switch (type) { case DLCManager::e_DLCType_Skin: { @@ -187,7 +187,7 @@ DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::wstring& path) { break; }; - if (newFile != NULL) { + if (newFile != nullptr) { m_files[newFile->getType()].push_back(newFile); } @@ -196,7 +196,7 @@ DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::wstring& path) { // MGH - added this comp func, as the embedded func in find_if was confusing the // PS3 compiler -static const std::wstring* g_pathCmpString = NULL; +static const std::wstring* g_pathCmpString = nullptr; static bool pathCmp(DLCFile* val) { return (g_pathCmpString->compare(val->getPath()) == 0); } @@ -224,13 +224,13 @@ bool DLCPack::doesPackContainFile(DLCManager::EDLCType type, } DLCFile* DLCPack::getFile(DLCManager::EDLCType type, unsigned int index) { - DLCFile* file = NULL; + DLCFile* file = nullptr; if (type == DLCManager::e_DLCType_All) { for (DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1)) { file = getFile(currentType, index); - if (file != NULL) break; + if (file != nullptr) break; } } else { if (m_files[type].size() > index) file = m_files[type][index]; @@ -242,13 +242,13 @@ DLCFile* DLCPack::getFile(DLCManager::EDLCType type, unsigned int index) { } DLCFile* DLCPack::getFile(DLCManager::EDLCType type, const std::wstring& path) { - DLCFile* file = NULL; + DLCFile* file = nullptr; if (type == DLCManager::e_DLCType_All) { for (DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1)) { file = getFile(currentType, path); - if (file != NULL) break; + if (file != nullptr) break; } } else { g_pathCmpString = &path; @@ -257,7 +257,7 @@ DLCFile* DLCPack::getFile(DLCManager::EDLCType type, const std::wstring& path) { if (it == m_files[type].end()) { // Not found - file = NULL; + file = nullptr; } else { file = *it; } diff --git a/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.cpp index 2b01d492d..ed6b9fcce 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.cpp @@ -7,7 +7,7 @@ DLCTextureFile::DLCTextureFile(const std::wstring& path) m_bIsAnim = false; m_animString = L""; - m_pbData = NULL; + m_pbData = nullptr; m_dataBytes = 0; } diff --git a/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.cpp index 4ea2138c0..4acc5fae2 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.cpp @@ -4,13 +4,13 @@ DLCUIDataFile::DLCUIDataFile(const std::wstring& path) : DLCFile(DLCManager::e_DLCType_UIData, path) { - m_pbData = NULL; + m_pbData = nullptr; m_dataBytes = 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/Platform/Common/GameRules/AddEnchantmentRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.cpp index 7183d4e29..4a1d27bf7 100644 --- a/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.cpp @@ -46,7 +46,7 @@ void AddEnchantmentRuleDefinition::addAttribute( bool AddEnchantmentRuleDefinition::enchantItem( std::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 if (item->id == Item::enchantedBook_Id) { @@ -56,7 +56,7 @@ bool AddEnchantmentRuleDefinition::enchantItem( } else if (item->isEnchantable()) { Enchantment* e = Enchantment::enchantments[m_enchantmentId]; - if (e != NULL && e->category->canEnchant(item->getItem())) { + if (e != nullptr && e->category->canEnchant(item->getItem())) { int level = std::min(e->getMaxLevel(), m_enchantmentLevel); item->enchant(e, m_enchantmentLevel); enchanted = true; diff --git a/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.cpp index 94e5ee596..872cd02f1 100644 --- a/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.cpp @@ -40,7 +40,7 @@ void AddItemRuleDefinition::getChildren( GameRuleDefinition* AddItemRuleDefinition::addChild( ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition* rule = NULL; + GameRuleDefinition* rule = nullptr; if (ruleType == ConsoleGameRules::eGameRuleType_AddEnchantment) { rule = new AddEnchantmentRuleDefinition(); m_enchantments.push_back((AddEnchantmentRuleDefinition*)rule); @@ -88,7 +88,7 @@ void AddItemRuleDefinition::addAttribute(const std::wstring& attributeName, bool AddItemRuleDefinition::addItemToContainer( std::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()); std::shared_ptr newItem = std::shared_ptr( @@ -106,7 +106,7 @@ bool AddItemRuleDefinition::addItemToContainer( } else if (slotId >= 0 && slotId < container->getContainerSize()) { container->setItem(slotId, newItem); added = true; - } else if (std::dynamic_pointer_cast(container) != NULL) { + } else if (std::dynamic_pointer_cast(container) != nullptr) { added = std::dynamic_pointer_cast(container)->add(newItem); } diff --git a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp index 2101756d7..d6d049b59 100644 --- a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp @@ -20,13 +20,13 @@ ApplySchematicRuleDefinition::ApplySchematicRuleDefinition( 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; } void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream* dos, @@ -128,7 +128,7 @@ void ApplySchematicRuleDefinition::addAttribute( } void ApplySchematicRuleDefinition::updateLocationBox() { - if (m_schematic == NULL) + if (m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); m_locationBox = AABB(0, 0, 0, 0, 0, 0); @@ -160,7 +160,7 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox, if (chunk->level->dimension->id != m_dimension) return; PIXBeginNamedEvent(0, "Processing ApplySchematicRuleDefinition"); - if (m_schematic == NULL) + if (m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); if (!m_locationBox.has_value()) updateLocationBox(); @@ -192,7 +192,7 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox, (m_totalBlocksChangedLighting == targetBlocks)) { m_completed = true; // m_levelGenOptions->releaseSchematicFile(m_schematicName); - // m_schematic = NULL; + // m_schematic = nullptr; } } PIXEndNamedEvent(); @@ -204,7 +204,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox, if (chunk->level->dimension->id != m_dimension) return; PIXBeginNamedEvent(0, "Processing ApplySchematicRuleDefinition (lighting)"); - if (m_schematic == NULL) + if (m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); if (!m_locationBox.has_value()) updateLocationBox(); @@ -230,7 +230,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox, (m_totalBlocksChangedLighting == targetBlocks)) { m_completed = true; // m_levelGenOptions->releaseSchematicFile(m_schematicName); - // m_schematic = NULL; + // m_schematic = nullptr; } } PIXEndNamedEvent(); diff --git a/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.cpp index f3f601ab6..89c778954 100644 --- a/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.cpp @@ -66,7 +66,7 @@ void CollectItemRuleDefinition::populateGameRule( bool CollectItemRuleDefinition::onCollectItem( GameRule* rule, std::shared_ptr item) { bool statusChanged = false; - if (item != NULL && item->id == m_itemId && + if (item != nullptr && item->id == m_itemId && item->getAuxValue() == m_auxValue && item->get4JData() == m_4JDataValue) { if (!getComplete(rule)) { @@ -83,12 +83,12 @@ bool CollectItemRuleDefinition::onCollectItem( "auxValue:%d, quantity:%d, dataTag:%d\n", m_itemId, m_auxValue, m_quantity, m_4JDataValue); - if (rule->getConnection() != NULL) { + if (rule->getConnection() != nullptr) { rule->getConnection()->send( std::shared_ptr( new UpdateGameRuleProgressPacket( getActionType(), this->m_descriptionId, - m_itemId, m_auxValue, this->m_4JDataValue, NULL, + m_itemId, m_auxValue, this->m_4JDataValue, nullptr, 0))); } } @@ -101,7 +101,7 @@ std::wstring CollectItemRuleDefinition::generateXml( std::shared_ptr item) { // 4J Stu - This should be kept in sync with the GameRulesDefinition.xsd std::wstring xml = L""; - if (item != NULL) { + if (item != nullptr) { xml = L"(item->id) + L"\" quantity=\"SET\" descriptionName=\"OPTIONAL\" " L"promptName=\"OPTIONAL\""; diff --git a/Minecraft.Client/Platform/Common/GameRules/CompleteAllRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/CompleteAllRuleDefinition.cpp index 82d8fb5dd..7cc8e6723 100644 --- a/Minecraft.Client/Platform/Common/GameRules/CompleteAllRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/CompleteAllRuleDefinition.cpp @@ -36,7 +36,7 @@ void CompleteAllRuleDefinition::updateStatus(GameRule* rule) { it->second.gr); } } - if (rule->getConnection() != NULL) { + if (rule->getConnection() != nullptr) { PacketData data; data.goal = goal; data.progress = progress; @@ -44,10 +44,10 @@ 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( std::shared_ptr( diff --git a/Minecraft.Client/Platform/Common/GameRules/CompoundGameRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/CompoundGameRuleDefinition.cpp index cd21388e4..8a0642052 100644 --- a/Minecraft.Client/Platform/Common/GameRules/CompoundGameRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/CompoundGameRuleDefinition.cpp @@ -5,7 +5,7 @@ #include "ConsoleGameRules.h" CompoundGameRuleDefinition::CompoundGameRuleDefinition() { - m_lastRuleStatusChanged = NULL; + m_lastRuleStatusChanged = nullptr; } CompoundGameRuleDefinition::~CompoundGameRuleDefinition() { @@ -23,7 +23,7 @@ void CompoundGameRuleDefinition::getChildren( GameRuleDefinition* CompoundGameRuleDefinition::addChild( ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition* rule = NULL; + GameRuleDefinition* rule = nullptr; if (ruleType == ConsoleGameRules::eGameRuleType_CompleteAllRule) { rule = new CompleteAllRuleDefinition(); } else if (ruleType == ConsoleGameRules::eGameRuleType_CollectItemRule) { @@ -40,13 +40,13 @@ GameRuleDefinition* CompoundGameRuleDefinition::addChild( 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_VAR(it, m_children.begin()); it != m_children.end(); ++it) { newRule = new GameRule(*it, rule->getConnection()); diff --git a/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.cpp b/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.cpp index cec5b1214..32912aaba 100644 --- a/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.cpp @@ -9,7 +9,7 @@ ConsoleGenerateStructure::ConsoleGenerateStructure() : StructurePiece(0) { m_x = m_y = m_z = 0; - boundingBox = NULL; + boundingBox = nullptr; orientation = Direction::NORTH; m_dimension = 0; } @@ -24,7 +24,7 @@ void ConsoleGenerateStructure::getChildren( GameRuleDefinition* ConsoleGenerateStructure::addChild( ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition* rule = NULL; + GameRuleDefinition* rule = nullptr; if (ruleType == ConsoleGameRules::eGameRuleType_GenerateBox) { rule = new XboxStructureActionGenerateBox(); m_actions.push_back((XboxStructureActionGenerateBox*)rule); @@ -100,7 +100,7 @@ void ConsoleGenerateStructure::addAttribute( } BoundingBox* ConsoleGenerateStructure::getBoundingBox() { - if (boundingBox == NULL) { + if (boundingBox == nullptr) { // Find the max bounds int maxX, maxY, maxZ; maxX = maxY = maxZ = 1; diff --git a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp index 3ba460f65..8af41d83e 100644 --- a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp @@ -15,16 +15,16 @@ 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); dos->writeByte(APPROPRIATE_COMPRESSION_TYPE); @@ -47,7 +47,7 @@ void ConsoleSchematicFile::save(DataOutputStream* dos) { } void ConsoleSchematicFile::load(DataInputStream* dis) { - if (dis != NULL) { + if (dis != nullptr) { // VERSION CHECK // int version = dis->readInt(); @@ -70,9 +70,9 @@ 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) { @@ -114,15 +114,15 @@ void ConsoleSchematicFile::load(DataInputStream* dis) { // and cast it to CompoundTag inside the loop CompoundTag* tag = NbtIo::read(dis); ListTag* tileEntityTags = tag->getList(L"TileEntities"); - if (tileEntityTags != NULL) { + if (tileEntityTags != nullptr) { for (int i = 0; i < tileEntityTags->size(); i++) { CompoundTag* teTag = (CompoundTag*)tileEntityTags->get(i); std::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"); + "ConsoleSchematicFile has read a nullptr tile entity\n"); __debugbreak(); #endif } else { @@ -134,7 +134,7 @@ void ConsoleSchematicFile::load(DataInputStream* dis) { // 4jcraft, fixed cast of templated List to get the tag list // and cast it to CompoundTag inside the loop ListTag* entityTags = tag->getList(L"Entities"); - if (entityTags != NULL) { + if (entityTags != nullptr) { for (int i = 0; i < entityTags->size(); i++) { CompoundTag* eTag = (CompoundTag*)entityTags->get(i); eINSTANCEOF type = EntityIO::getType(eTag->getString(L"id")); @@ -468,7 +468,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk* chunk, AABB* chunkBox, std::shared_ptr teCopy = chunk->getTileEntity( (int)targetX & 15, (int)targetY & 15, (int)targetZ & 15); - if (teCopy != NULL) { + if (teCopy != nullptr) { CompoundTag* teData = new CompoundTag(); te->save(teData); @@ -517,7 +517,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk* chunk, AABB* chunkBox, } CompoundTag* eTag = it->second; - std::shared_ptr e = EntityIO::loadStatic(eTag, NULL); + std::shared_ptr e = EntityIO::loadStatic(eTag, nullptr); if (e->GetType() == eTYPE_PAINTING) { std::shared_ptr painting = @@ -615,18 +615,18 @@ void ConsoleSchematicFile::generateSchematicFile( "%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); @@ -695,8 +695,8 @@ void ConsoleSchematicFile::generateSchematicFile( 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; @@ -783,7 +783,7 @@ void ConsoleSchematicFile::generateSchematicFile( 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, diff --git a/Minecraft.Client/Platform/Common/GameRules/GameRule.h b/Minecraft.Client/Platform/Common/GameRules/GameRule.h index 51265967d..5c9dccd56 100644 --- a/Minecraft.Client/Platform/Common/GameRules/GameRule.h +++ b/Minecraft.Client/Platform/Common/GameRules/GameRule.h @@ -38,7 +38,7 @@ public: // 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/Platform/Common/GameRules/GameRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.cpp index 0cf38789b..eb10ef92f 100644 --- a/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.cpp @@ -52,7 +52,7 @@ GameRuleDefinition* GameRuleDefinition::addChild( wprintf(L"GameRuleDefinition: Attempted to add invalid child rule - %d\n", ruleType); #endif - return NULL; + return nullptr; } void GameRuleDefinition::addAttribute(const std::wstring& attributeName, diff --git a/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.h index 6480d6936..1459a9c62 100644 --- a/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.h +++ b/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.h @@ -77,5 +77,5 @@ public: Connection* connection); static std::wstring generateDescriptionString( ConsoleGameRules::EGameRuleType defType, - const std::wstring& description, void* data = NULL, int dataLength = 0); + const std::wstring& description, void* data = nullptr, int dataLength = 0); }; diff --git a/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.cpp b/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.cpp index e51ff9d2c..b25468802 100644 --- a/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.cpp @@ -82,12 +82,12 @@ const 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")) { @@ -240,10 +240,10 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions* lgo, uint8_t* dIn, // 4J-JEV: Reverse of loadGameRules. void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* 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; } @@ -269,7 +269,7 @@ void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* 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); compr_dos.writeByte( @@ -281,9 +281,9 @@ void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* dSize) { } else { StringTable* st = m_currentGameRuleDefinitions->getStringTable(); - if (st == NULL) { + if (st == nullptr) { app.DebugPrintf( - "GameRuleManager::saveGameRules: StringTable == NULL!"); + "GameRuleManager::saveGameRules: StringTable == nullptr!"); } else { // Write string table. byteArray stba; @@ -322,7 +322,7 @@ void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* dSize) { *dSize = baos.buf.length; *dOut = baos.buf.data; - baos.buf.data = NULL; + baos.buf.data = nullptr; dos.close(); baos.close(); @@ -403,8 +403,8 @@ bool GameRuleManager::readRuleFile( 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) { // No compression @@ -531,7 +531,7 @@ bool GameRuleManager::readRuleFile( AUTO_VAR(it, tagIdMap.find(tagId)); if (it != tagIdMap.end()) tagVal = it->second; - GameRuleDefinition* rule = NULL; + GameRuleDefinition* rule = nullptr; if (tagVal == ConsoleGameRules::eGameRuleType_LevelGenerationOptions) { rule = levelGenerator; @@ -554,14 +554,14 @@ bool GameRuleManager::readRuleFile( if (compressionType != 0) { // 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; @@ -587,7 +587,7 @@ void GameRuleManager::readAttributes(DataInputStream* dis, int attID = dis->readInt(); std::wstring value = dis->readUTF(); - if (rule != NULL) rule->addAttribute(tagsAndAtts->at(attID), value); + if (rule != nullptr) rule->addAttribute(tagsAndAtts->at(attID), value); } } @@ -604,8 +604,8 @@ void GameRuleManager::readChildren( AUTO_VAR(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); @@ -613,14 +613,14 @@ void GameRuleManager::readChildren( } void GameRuleManager::processSchematics(LevelChunk* levelChunk) { - if (getLevelGenerationOptions() != NULL) { + if (getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = getLevelGenerationOptions(); levelGenOptions->processSchematics(levelChunk); } } void GameRuleManager::processSchematicsLighting(LevelChunk* levelChunk) { - if (getLevelGenerationOptions() != NULL) { + if (getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = getLevelGenerationOptions(); levelGenOptions->processSchematicsLighting(levelChunk); } @@ -680,21 +680,21 @@ void GameRuleManager::setLevelGenerationOptions( LevelGenerationOptions* levelGen) { unloadCurrentGameRules(); - m_currentGameRuleDefinitions = NULL; + m_currentGameRuleDefinitions = nullptr; m_currentLevelGenerationOptions = levelGen; - if (m_currentLevelGenerationOptions != NULL && + if (m_currentLevelGenerationOptions != nullptr && m_currentLevelGenerationOptions->requiresGameRules()) { m_currentGameRuleDefinitions = m_currentLevelGenerationOptions->getRequiredGameRules(); } - if (m_currentLevelGenerationOptions != NULL) + if (m_currentLevelGenerationOptions != nullptr) m_currentLevelGenerationOptions->reset_start(); } const wchar_t* GameRuleManager::GetGameRulesString(const std::wstring& key) { - if (m_currentGameRuleDefinitions != NULL && !key.empty()) { + if (m_currentGameRuleDefinitions != nullptr && !key.empty()) { return m_currentGameRuleDefinitions->getString(key); } else { return L""; @@ -714,8 +714,8 @@ LEVEL_GEN_ID GameRuleManager::addLevelGenerationOptions( } void GameRuleManager::unloadCurrentGameRules() { - if (m_currentLevelGenerationOptions != NULL) { - if (m_currentGameRuleDefinitions != NULL && + if (m_currentLevelGenerationOptions != nullptr) { + if (m_currentGameRuleDefinitions != nullptr && m_currentLevelGenerationOptions->isFromSave()) m_levelRules.removeLevelRule(m_currentGameRuleDefinitions); @@ -729,6 +729,6 @@ void GameRuleManager::unloadCurrentGameRules() { } } - m_currentGameRuleDefinitions = NULL; - m_currentLevelGenerationOptions = NULL; + m_currentGameRuleDefinitions = nullptr; + m_currentLevelGenerationOptions = nullptr; } diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp index f8e13ae50..a67b604a9 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp @@ -52,8 +52,8 @@ void JustGrSource::setBaseSavePath(const std::wstring& x) { bool JustGrSource::ready() { return true; } LevelGenerationOptions::LevelGenerationOptions(DLCPack* parentPack) { - m_spawnPos = NULL; - m_stringTable = NULL; + m_spawnPos = nullptr; + m_stringTable = nullptr; m_hasLoadedData = false; @@ -64,7 +64,7 @@ LevelGenerationOptions::LevelGenerationOptions(DLCPack* parentPack) { m_minY = INT_MAX; m_bRequiresGameRules = false; - m_pbBaseSaveData = NULL; + m_pbBaseSaveData = nullptr; m_baseSaveSize = 0; m_parentDLCPack = parentPack; @@ -73,7 +73,7 @@ LevelGenerationOptions::LevelGenerationOptions(DLCPack* parentPack) { LevelGenerationOptions::~LevelGenerationOptions() { clearSchematics(); - if (m_spawnPos != NULL) delete m_spawnPos; + if (m_spawnPos != nullptr) delete m_spawnPos; for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end(); ++it) { delete *it; @@ -143,7 +143,7 @@ void LevelGenerationOptions::getChildren( GameRuleDefinition* LevelGenerationOptions::addChild( ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition* rule = NULL; + GameRuleDefinition* rule = nullptr; if (ruleType == ConsoleGameRules::eGameRuleType_ApplySchematic) { rule = new ApplySchematicRuleDefinition(this); m_schematicRules.push_back((ApplySchematicRuleDefinition*)rule); @@ -174,19 +174,19 @@ void LevelGenerationOptions::addAttribute(const std::wstring& attributeName, app.DebugPrintf( "LevelGenerationOptions: Adding parameter m_seed=%I64d\n", m_seed); } 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", @@ -271,7 +271,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; } } @@ -363,7 +363,7 @@ ConsoleSchematicFile* LevelGenerationOptions::loadSchematicFile( return it->second; } - ConsoleSchematicFile* schematic = NULL; + ConsoleSchematicFile* schematic = nullptr; byteArray data(pbData, dataLength); ByteArrayInputStream bais(data); DataInputStream dis(&bais); @@ -376,7 +376,7 @@ ConsoleSchematicFile* LevelGenerationOptions::loadSchematicFile( ConsoleSchematicFile* LevelGenerationOptions::getSchematicFile( const std::wstring& filename) { - ConsoleSchematicFile* schematic = NULL; + ConsoleSchematicFile* schematic = nullptr; // If we have already loaded this, just return AUTO_VAR(it, m_schematics.find(filename)); if (it != m_schematics.end()) { @@ -407,7 +407,7 @@ void LevelGenerationOptions::loadStringTable(StringTable* table) { } const wchar_t* LevelGenerationOptions::getString(const std::wstring& key) { - if (m_stringTable == NULL) { + if (m_stringTable == nullptr) { return L""; } else { return m_stringTable->getString(key); @@ -462,7 +462,7 @@ LevelGenerationOptions::getUnfinishedSchematicFiles() { void LevelGenerationOptions::loadBaseSaveData() { int mountIndex = -1; - if (m_parentDLCPack != NULL) + if (m_parentDLCPack != nullptr) mountIndex = m_parentDLCPack->GetDLCMountIndex(); if (mountIndex > -1) { @@ -518,12 +518,12 @@ int LevelGenerationOptions::packMounted(LPVOID pParam, int iPad, DWORD dwErr, 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()); @@ -532,12 +532,12 @@ int LevelGenerationOptions::packMounted(LPVOID pParam, int iPad, DWORD dwErr, 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 @@ -546,7 +546,7 @@ int LevelGenerationOptions::packMounted(LPVOID pParam, int iPad, DWORD dwErr, DWORD bytesRead; PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; BOOL bSuccess = ReadFile(fileHandle, pbData, dwFileSize, - &bytesRead, NULL); + &bytesRead, nullptr); if (bSuccess == FALSE) { app.FatalLoadError(); } @@ -576,12 +576,12 @@ int LevelGenerationOptions::packMounted(LPVOID pParam, int iPad, DWORD dwErr, 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()); @@ -590,20 +590,20 @@ int LevelGenerationOptions::packMounted(LPVOID pParam, int iPad, DWORD dwErr, 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); + &bytesRead, nullptr); if (bSuccess == FALSE) { app.FatalLoadError(); } @@ -632,8 +632,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; } + // = nullptr; } if (m_stringTable) { delete m_stringTable; + // m_stringTable = nullptr; } if (isFromDLC()) { m_hasLoadedData = false; @@ -739,11 +739,11 @@ std::uint8_t* LevelGenerationOptions::getBaseSaveData(unsigned int& size) { return m_pbBaseSaveData; } bool LevelGenerationOptions::hasBaseSaveData() { - return m_baseSaveSize > 0 && m_pbBaseSaveData != NULL; + return m_baseSaveSize > 0 && m_pbBaseSaveData != nullptr; } void LevelGenerationOptions::deleteBaseSaveData() { delete[] m_pbBaseSaveData; - m_pbBaseSaveData = NULL; + m_pbBaseSaveData = nullptr; m_baseSaveSize = 0; } diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.h b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.h index 0777d85dd..046fac0f5 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.h +++ b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.h @@ -167,7 +167,7 @@ private: bool m_bLoadingData; public: - LevelGenerationOptions(DLCPack* parentPack = NULL); + LevelGenerationOptions(DLCPack* parentPack = nullptr); ~LevelGenerationOptions(); virtual ConsoleGameRules::EGameRuleType getActionType(); @@ -210,7 +210,7 @@ public: std::uint8_t& topTile); bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature, - int* orientation = NULL); + int* orientation = nullptr); void loadStringTable(StringTable* table); const wchar_t* getString(const std::wstring& key); diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp b/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp index 30bc16254..4276d3008 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp @@ -4,7 +4,7 @@ #include "ConsoleGameRules.h" #include "LevelRuleset.h" -LevelRuleset::LevelRuleset() { m_stringTable = NULL; } +LevelRuleset::LevelRuleset() { m_stringTable = nullptr; } LevelRuleset::~LevelRuleset() { for (AUTO_VAR(it, m_areas.begin()); it != m_areas.end(); ++it) { @@ -20,7 +20,7 @@ void LevelRuleset::getChildren(std::vector* children) { GameRuleDefinition* LevelRuleset::addChild( ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition* rule = NULL; + GameRuleDefinition* rule = nullptr; if (ruleType == ConsoleGameRules::eGameRuleType_NamedArea) { rule = new NamedAreaRuleDefinition(); m_areas.push_back((NamedAreaRuleDefinition*)rule); @@ -35,7 +35,7 @@ void LevelRuleset::loadStringTable(StringTable* table) { } const wchar_t* LevelRuleset::getString(const std::wstring& key) { - if (m_stringTable == NULL) { + if (m_stringTable == nullptr) { return L""; } else { return m_stringTable->getString(key); @@ -43,7 +43,7 @@ const wchar_t* LevelRuleset::getString(const std::wstring& key) { } AABB* LevelRuleset::getNamedArea(const std::wstring& areaName) { - AABB* area = NULL; + AABB* area = nullptr; for (AUTO_VAR(it, m_areas.begin()); it != m_areas.end(); ++it) { if ((*it)->getName().compare(areaName) == 0) { area = (*it)->getArea(); diff --git a/Minecraft.Client/Platform/Common/GameRules/StartFeature.cpp b/Minecraft.Client/Platform/Common/GameRules/StartFeature.cpp index e1d316ea4..293e4ca84 100644 --- a/Minecraft.Client/Platform/Common/GameRules/StartFeature.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/StartFeature.cpp @@ -51,6 +51,6 @@ void StartFeature::addAttribute(const std::wstring& attributeName, 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/Platform/Common/GameRules/UpdatePlayerRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.cpp index 1a160a017..51d85a94b 100644 --- a/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.cpp @@ -12,7 +12,7 @@ UpdatePlayerRuleDefinition::UpdatePlayerRuleDefinition() { ; m_health = 0; m_food = 0; - m_spawnPos = NULL; + m_spawnPos = nullptr; m_yRot = 0.0f; } @@ -60,7 +60,7 @@ void UpdatePlayerRuleDefinition::getChildren( GameRuleDefinition* UpdatePlayerRuleDefinition::addChild( ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition* rule = NULL; + GameRuleDefinition* rule = nullptr; if (ruleType == ConsoleGameRules::eGameRuleType_AddItem) { rule = new AddItemRuleDefinition(); m_items.push_back((AddItemRuleDefinition*)rule); @@ -78,19 +78,19 @@ GameRuleDefinition* UpdatePlayerRuleDefinition::addChild( void UpdatePlayerRuleDefinition::addAttribute( const std::wstring& attributeName, const std::wstring& attributeValue) { 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( @@ -134,7 +134,7 @@ void UpdatePlayerRuleDefinition::postProcessPlayer( 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; z = m_spawnPos->z; @@ -144,7 +144,7 @@ void UpdatePlayerRuleDefinition::postProcessPlayer( yRot = m_yRot; } - if (m_spawnPos != NULL || m_bUpdateYRot) + if (m_spawnPos != nullptr || m_bUpdateYRot) player->absMoveTo(x, y, z, yRot, xRot); for (AUTO_VAR(it, m_items.begin()); it != m_items.end(); ++it) { diff --git a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.cpp b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.cpp index 2a8f5950b..afa3d3e8d 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.cpp @@ -30,7 +30,7 @@ void XboxStructureActionPlaceContainer::getChildren( GameRuleDefinition* XboxStructureActionPlaceContainer::addChild( ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition* rule = NULL; + GameRuleDefinition* rule = nullptr; if (ruleType == ConsoleGameRules::eGameRuleType_AddItem) { rule = new AddItemRuleDefinition(); m_items.push_back((AddItemRuleDefinition*)rule); @@ -66,7 +66,7 @@ bool XboxStructureActionPlaceContainer::placeContainerInLevel( int worldZ = structure->getWorldZ(m_x, m_z); 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); level->setTileAndData(worldX, worldY, worldZ, 0, 0, @@ -83,7 +83,7 @@ bool XboxStructureActionPlaceContainer::placeContainerInLevel( "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/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.cpp b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.cpp index 843f0e8f2..670528169 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.cpp @@ -42,7 +42,7 @@ bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel( int worldZ = structure->getWorldZ(m_x, m_z); 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); level->setTileAndData(worldX, worldY, worldZ, 0, 0, @@ -61,7 +61,7 @@ bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel( L"(%d,%d,%d)\n", m_entityId.c_str(), worldX, worldY, worldZ); #endif - if (entity != NULL) { + if (entity != nullptr) { entity->setEntityId(m_entityId); } return true; diff --git a/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardInterface.cpp b/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardInterface.cpp index 94c320420..d7f331577 100644 --- a/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardInterface.cpp +++ b/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardInterface.cpp @@ -6,7 +6,7 @@ LeaderboardInterface::LeaderboardInterface(LeaderboardManager* man) { m_pending = false; m_filter = (LeaderboardManager::EFilterMode)-1; - m_callback = NULL; + m_callback = nullptr; m_difficulty = 0; m_type = LeaderboardManager::eStatsType_UNDEFINED; m_startIndex = 0; diff --git a/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardManager.cpp b/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardManager.cpp index b9a29cc43..5b0560c19 100644 --- a/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardManager.cpp +++ b/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardManager.cpp @@ -12,7 +12,7 @@ const std::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/Platform/Common/Leaderboards/SonyLeaderboardManager.cpp b/Minecraft.Client/Platform/Common/Leaderboards/SonyLeaderboardManager.cpp index 03cba8312..e1c8d8253 100644 --- a/Minecraft.Client/Platform/Common/Leaderboards/SonyLeaderboardManager.cpp +++ b/Minecraft.Client/Platform/Common/Leaderboards/SonyLeaderboardManager.cpp @@ -24,7 +24,7 @@ SonyLeaderboardManager::SonyLeaderboardManager() { m_myXUID = INVALID_XUID; - m_scores = NULL; + m_scores = nullptr; m_statsType = eStatsType_Kills; m_difficulty = 0; @@ -36,7 +36,7 @@ SonyLeaderboardManager::SonyLeaderboardManager() { InitializeCriticalSection(&m_csViewsLock); m_running = false; - m_threadScoreboard = NULL; + m_threadScoreboard = nullptr; } SonyLeaderboardManager::~SonyLeaderboardManager() { @@ -204,7 +204,7 @@ bool SonyLeaderboardManager::getScoreByIds() { SonyRtcTick last_sort_date; SceNpScoreRankNumber mTotalRecord; - SceNpId* npIds = NULL; + SceNpId* npIds = nullptr; int ret; uint32_t num = 0; @@ -236,8 +236,8 @@ bool SonyLeaderboardManager::getScoreByIds() { /* 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", transaction, npId, friendCount, + 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 ); */ @@ -254,9 +254,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; } else if (ret < 0) { @@ -268,9 +268,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; } else { @@ -287,13 +287,13 @@ bool SonyLeaderboardManager::getScoreByIds() { ptr, sizeof(SceNpScorePlayerRankData) * tmpNum, // OUT: Rank Data 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) { @@ -322,7 +322,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; @@ -352,7 +352,7 @@ error3: 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; @@ -406,7 +406,7 @@ bool SonyLeaderboardManager::getScoreByRange() { comments, sizeof(SceNpScoreComment) * num, // OUT: Comment Data - NULL, 0, // GameData. + nullptr, 0, // GameData. num, @@ -414,7 +414,7 @@ bool SonyLeaderboardManager::getScoreByRange() { &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) { @@ -437,7 +437,7 @@ bool SonyLeaderboardManager::getScoreByRange() { delete[] ptr; delete[] comments; - m_scores = NULL; + m_scores = nullptr; m_readCount = 0; m_eStatsState = eStatsState_Ready; @@ -457,7 +457,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 < m_readCount; i++) { @@ -544,13 +544,13 @@ bool SonyLeaderboardManager::setScore() { rscore.m_score, // IN: new score, &comment, // Comments - NULL, // GameInfo + nullptr, // GameInfo &tmp, // OUT: current rank, - NULL, // compareDate + nullptr, // compareDate - NULL // Reserved, specify null. + nullptr // Reserved, specify null. ); if (ret == SCE_NP_COMMUNITY_SERVER_ERROR_NOT_BEST_SCORE) // 0x8002A415 @@ -593,7 +593,7 @@ void SonyLeaderboardManager::Tick() { switch (m_eStatsState) { case eStatsState_Ready: { - assert(m_scores != NULL || m_readCount == 0); + assert(m_scores != nullptr || m_readCount == 0); view.m_numQueries = m_readCount; view.m_queries = m_scores; @@ -604,7 +604,7 @@ void SonyLeaderboardManager::Tick() { eStatsReturn ret = eStatsReturn_NoResults; if (view.m_numQueries > 0) ret = eStatsReturn_Success; - if (m_readListener != NULL) { + if (m_readListener != nullptr) { app.DebugPrintf( "[SonyLeaderboardManager] OnStatsReadComplete(%i, %i, _), " "m_readCount=%i.\n", @@ -615,14 +615,14 @@ 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); @@ -640,7 +640,7 @@ void SonyLeaderboardManager::Tick() { 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); @@ -748,7 +748,7 @@ bool SonyLeaderboardManager::ReadStats_TopRank( void SonyLeaderboardManager::FlushStats() {} void SonyLeaderboardManager::CancelOperation() { - m_readListener = NULL; + m_readListener = nullptr; m_eStatsState = eStatsState_Canceled; if (m_requestId != 0) { @@ -898,7 +898,7 @@ void SonyLeaderboardManager::fromBase32(void* out, SceNpScoreComment* in) { char ch[2] = {0, 0}; 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; @@ -943,7 +943,7 @@ bool SonyLeaderboardManager::test_string(std::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) { app.DebugPrintf("\n[TEST_STRING]: REJECTED "); diff --git a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp index 4b9a519cc..c05da75ed 100644 --- a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp @@ -115,13 +115,13 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, void* lpParameter) { int64_t seed = 0; - if (lpParameter != NULL) { + if (lpParameter != nullptr) { NetworkGameInitData* param = (NetworkGameInitData*)lpParameter; seed = param->seed; app.setLevelGenerationOptions(param->levelGen); - if (param->levelGen != NULL) { - if (app.getLevelGenerationOptions() == NULL) { + if (param->levelGen != nullptr) { + if (app.getLevelGenerationOptions() == nullptr) { app.DebugPrintf( "Game rule was not loaded, and seed is required. " "Exiting.\n"); @@ -156,13 +156,13 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, 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 = @@ -172,23 +172,23 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, 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); + dwFileSize = GetFileSize(fileHandle, nullptr); PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; BOOL bSuccess = ReadFile(fileHandle, pbData, dwFileSize, - &bytesRead, NULL); + &bytesRead, nullptr); if (bSuccess == FALSE) { app.FatalLoadError(); } @@ -231,7 +231,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, // printf("Server ready to go!\n"); } else { - Socket::Initialise(NULL); + Socket::Initialise(nullptr); } Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -286,17 +286,17 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, ClientConnection* connection; if (g_NetworkManager.IsHost()) { - connection = new ClientConnection(minecraft, NULL); + connection = new ClientConnection(minecraft, nullptr); app.DebugPrintf("[NET] ClientConnection created, createdOk=%d\n", connection->createdOk); } 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 + // If the player is nullptr here then something went wrong in the // session setup, and continuing will end up in a crash return false; } @@ -305,10 +305,10 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, // 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 + // If the socket is nullptr here then something went wrong in the // session setup, and continuing will end up in a crash return false; } @@ -319,7 +319,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, if (!connection->createdOk) { assert(false); delete connection; - connection = NULL; + connection = nullptr; MinecraftServer::HaltServer(); return false; } @@ -395,7 +395,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, // Already have setup the primary pad if (idx == ProfileManager.GetPrimaryPad()) continue; - if (GetLocalPlayerByUserIndex(idx) != NULL && + if (GetLocalPlayerByUserIndex(idx) != nullptr && !ProfileManager.IsSignedIn(idx)) { INetworkPlayer* pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx); @@ -416,7 +416,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, // them later INetworkPlayer* pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx); - if (pNetworkPlayer == NULL) continue; + if (pNetworkPlayer == nullptr) continue; ClientConnection* connection; @@ -827,7 +827,7 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) { } // If we failed before the server started, clear the game rules. // Otherwise the server will clear it up. - if (MinecraftServer::getInstance() == NULL) + if (MinecraftServer::getInstance() == nullptr) app.m_gameRules.unloadCurrentGameRules(); Tile::ReleaseThreadStorage(); return -1; @@ -840,14 +840,14 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) { int CGameNetworkManager::ServerThreadProc(void* lpParameter) { int64_t seed = 0; - if (lpParameter != NULL) { + if (lpParameter != nullptr) { NetworkGameInitData* param = (NetworkGameInitData*)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 && + if (param->levelGen != nullptr && (param->texturePackId == 0 || param->levelGen->getRequiredTexturePackId() != param->texturePackId)) { @@ -874,7 +874,7 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) { Tile::ReleaseThreadStorage(); Level::destroyLightingCache(); - if (lpParameter != NULL) delete (NetworkGameInitData*)lpParameter; + if (lpParameter != nullptr) delete (NetworkGameInitData*)lpParameter; return S_OK; } @@ -885,7 +885,7 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc(void* lpParam) { Compression::UseDefaultThreadStorage(); // app.SetGameStarted(false); - UIScene_PauseMenu::_ExitWorld(NULL); + UIScene_PauseMenu::_ExitWorld(nullptr); while (g_NetworkManager.IsInSession()) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); @@ -938,7 +938,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc(void* lpParam) { // 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_VAR(it, players->players.begin()); it < players->players.end(); ++it) { @@ -946,7 +946,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc(void* lpParam) { if (servPlayer->connection->isLocal() && !servPlayer->connection->isGuest()) { servPlayer->connection->connection->getSocket()->setPlayer( - NULL); + nullptr); } } } @@ -981,7 +981,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) { + pMinecraft->localplayers[index] != nullptr) { numLocalPlayers++; localUsersMask |= GetLocalPlayerMask(index); } @@ -997,10 +997,10 @@ 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) { + pMinecraft->localplayers[index] != nullptr) { PlayerUID localPlayerXuid = pMinecraft->localplayers[index]->getXuid(); @@ -1017,7 +1017,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() @@ -1129,7 +1129,7 @@ void CGameNetworkManager::StateChange_AnyToStarting() { if (!g_NetworkManager.IsHost()) { LoadingInputParams* loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = nullptr; UIFullscreenProgressCompletionData* completionData = new UIFullscreenProgressCompletionData(); @@ -1151,7 +1151,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", @@ -1190,10 +1190,10 @@ void CGameNetworkManager::CreateSocket(INetworkPlayer* pNetworkPlayer, bool localPlayer) { Minecraft* pMinecraft = Minecraft::GetInstance(); - Socket* socket = NULL; + Socket* socket = nullptr; std::shared_ptr mpPlayer = pMinecraft->localplayers[pNetworkPlayer->GetUserIndex()]; - 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(); @@ -1233,7 +1233,7 @@ void CGameNetworkManager::CreateSocket(INetworkPlayer* pNetworkPlayer, idx, DisconnectPacket::eDisconnect_ConnectionCreationFailed); delete connection; - connection = NULL; + connection = nullptr; } } } @@ -1241,9 +1241,9 @@ void CGameNetworkManager::CreateSocket(INetworkPlayer* pNetworkPlayer, 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()); } @@ -1261,7 +1261,7 @@ void CGameNetworkManager::PlayerJoining(INetworkPlayer* pNetworkPlayer) { for (int iPad = 0; iPad < XUSER_MAX_COUNT; ++iPad) { INetworkPlayer* pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(iPad); - if (pNetworkPlayer == NULL) continue; + if (pNetworkPlayer == nullptr) continue; app.SetRichPresenceContext(iPad, CONTEXT_GAME_STATE_BLANK); if (multiplayer) { @@ -1321,7 +1321,7 @@ void CGameNetworkManager::GameInviteReceived(int userIndex, // 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; @@ -1357,7 +1357,7 @@ void CGameNetworkManager::GameInviteReceived(int userIndex, // invite from the dashboard // StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, // IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, - // uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, + // uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, // app.GetStringTable()); ui.RequestErrorMessage(IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA, 1, @@ -1507,49 +1507,49 @@ 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() { - if (m_hServerReadyEvent != NULL) { + if (m_hServerReadyEvent != nullptr) { m_hServerReadyEvent->Set(); } else { app.DebugPrintf( "[NET] Warning: ServerReady() called but m_hServerReadyEvent is " - "NULL\n"); + "nullptr\n"); } } void CGameNetworkManager::ServerReadyWait() { - if (m_hServerReadyEvent != NULL) { + if (m_hServerReadyEvent != nullptr) { m_hServerReadyEvent->WaitForSignal(INFINITE); } else { app.DebugPrintf( "[NET] Warning: ServerReadyWait() called but m_hServerReadyEvent " - "is NULL\n"); + "is nullptr\n"); } } 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() { - if (m_hServerStoppedEvent != NULL) { + if (m_hServerStoppedEvent != nullptr) { m_hServerStoppedEvent->Set(); } else { app.DebugPrintf( "[NET] Warning: ServerStopped() called but m_hServerStoppedEvent " - "is NULL\n"); + "is nullptr\n"); } } @@ -1574,23 +1574,23 @@ void CGameNetworkManager::ServerStoppedWait() { RenderManager.Present(); } while (result == WAIT_TIMEOUT); } else { - if (m_hServerStoppedEvent != NULL) { + if (m_hServerStoppedEvent != nullptr) { m_hServerStoppedEvent->WaitForSignal(INFINITE); } else { app.DebugPrintf( "[NET] Warning: ServerStoppedWait() called but " - "m_hServerStoppedEvent is NULL\n"); + "m_hServerStoppedEvent is nullptr\n"); } } } 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/Platform/Common/Network/GameNetworkManager.h b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.h index 295111c6e..c0b313d3c 100644 --- a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.h +++ b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.h @@ -111,7 +111,7 @@ public: static int JoinFromInvite_SignInReturned(void* pParam, bool bContinue, int iPad); void UpdateAndSetGameSessionData( - INetworkPlayer* pNetworkPlayerLeaving = NULL); + INetworkPlayer* pNetworkPlayerLeaving = nullptr); void SendInviteGUI(int iPad); void ResetLeavingGame(); @@ -133,17 +133,17 @@ public: // 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 // Debug output diff --git a/Minecraft.Client/Platform/Common/Network/NetworkPlayerQNet.cpp b/Minecraft.Client/Platform/Common/Network/NetworkPlayerQNet.cpp index 9a498b577..6a9b26e32 100644 --- a/Minecraft.Client/Platform/Common/Network/NetworkPlayerQNet.cpp +++ b/Minecraft.Client/Platform/Common/Network/NetworkPlayerQNet.cpp @@ -3,7 +3,7 @@ NetworkPlayerQNet::NetworkPlayerQNet(IQNetPlayer* qnetPlayer) { m_qnetPlayer = qnetPlayer; - m_pSocket = NULL; + m_pSocket = nullptr; } unsigned char NetworkPlayerQNet::GetSmallId() { diff --git a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerInterface.h b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerInterface.h index 90e8bc536..d780d859c 100644 --- a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerInterface.h +++ b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerInterface.h @@ -107,7 +107,7 @@ private: public: virtual void UpdateAndSetGameSessionData( - INetworkPlayer* pNetworkPlayerLeaving = NULL) = 0; + INetworkPlayer* pNetworkPlayerLeaving = nullptr) = 0; private: virtual bool RemoveLocalPlayer(INetworkPlayer* pNetworkPlayer) = 0; diff --git a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp index 929351a85..b8be5030f 100644 --- a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp @@ -80,7 +80,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); } @@ -88,7 +88,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer* pQNetPlayer) { if (m_pIQNet->GetState() == QNET_STATE_GAME_PLAY) { int localPlayerCount = 0; for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if (m_pIQNet->GetLocalPlayerByUserIndex(idx) != NULL) + if (m_pIQNet->GetLocalPlayerByUserIndex(idx) != nullptr) ++localPlayerCount; } @@ -107,7 +107,7 @@ bool CPlatformNetworkManagerStub::Initialise( // 4jcraft added this, as it was never called m_pIQNet = new IQNet(); for (int i = 0; i < XUSER_MAX_COUNT; i++) { - playerChangedCallback[i] = NULL; + playerChangedCallback[i] = nullptr; } m_bLeavingGame = false; @@ -126,10 +126,10 @@ bool CPlatformNetworkManagerStub::Initialise( 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; } @@ -266,8 +266,8 @@ void CPlatformNetworkManagerStub::UnRegisterPlayerChangedCallback( bool leaving), void* callbackParam) { if (playerChangedCallbackParam[iPad] == callbackParam) { - playerChangedCallback[iPad] = NULL; - playerChangedCallbackParam[iPad] = NULL; + playerChangedCallback[iPad] = nullptr; + playerChangedCallbackParam[iPad] = nullptr; } } @@ -276,13 +276,13 @@ void CPlatformNetworkManagerStub::HandleSignInChange() { return; } bool CPlatformNetworkManagerStub::_RunNetworkGame() { return true; } void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData( - INetworkPlayer* pNetworkPlayerLeaving /*= NULL*/) { + 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) @@ -305,13 +305,13 @@ void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData( // } // 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); // } // } @@ -328,13 +328,13 @@ int CPlatformNetworkManagerStub::RemovePlayerOnSocketClosedThreadProc( 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; } @@ -404,7 +404,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++) { if (pNetworkPlayer->IsSameSystem(m_playerFlags[i]->m_pNetworkPlayer)) { @@ -419,7 +419,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; } @@ -497,7 +497,7 @@ void CPlatformNetworkManagerStub::ForceFriendsSessionRefresh() { m_searchResultsCount[i] = 0; m_lastSearchStartTime[i] = 0; delete m_pSearchResults[i]; - m_pSearchResults[i] = NULL; + m_pSearchResults[i] = nullptr; } } @@ -524,7 +524,7 @@ void CPlatformNetworkManagerStub::removeNetworkPlayer( INetworkPlayer* CPlatformNetworkManagerStub::getNetworkPlayer( IQNetPlayer* pQNetPlayer) { return pQNetPlayer ? (INetworkPlayer*)(pQNetPlayer->GetCustomDataValue()) - : NULL; + : nullptr; } INetworkPlayer* CPlatformNetworkManagerStub::GetLocalPlayerByUserIndex( diff --git a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.h b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.h index 7392ac585..895f9820f 100644 --- a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.h +++ b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.h @@ -100,7 +100,7 @@ private: public: virtual void UpdateAndSetGameSessionData( - INetworkPlayer* pNetworkPlayerLeaving = NULL); + 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/Platform/Common/Network/SessionInfo.h b/Minecraft.Client/Platform/Common/Network/SessionInfo.h index 497cd17ca..cf8fa2d64 100644 --- a/Minecraft.Client/Platform/Common/Network/SessionInfo.h +++ b/Minecraft.Client/Platform/Common/Network/SessionInfo.h @@ -29,13 +29,13 @@ public: bool hasPartyMember; FriendSessionInfo() { - displayLabel = NULL; + displayLabel = nullptr; displayLabelLength = 0; displayLabelViewableStartIndex = 0; hasPartyMember = false; } ~FriendSessionInfo() { - if (displayLabel != NULL) delete displayLabel; + if (displayLabel != nullptr) delete displayLabel; } }; diff --git a/Minecraft.Client/Platform/Common/Telemetry/TelemetryManager.cpp b/Minecraft.Client/Platform/Common/Telemetry/TelemetryManager.cpp index 2fd26bbfc..240d2960f 100644 --- a/Minecraft.Client/Platform/Common/Telemetry/TelemetryManager.cpp +++ b/Minecraft.Client/Platform/Common/Telemetry/TelemetryManager.cpp @@ -163,7 +163,7 @@ int CTelemetryManager::GetMode(int userId) Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localplayers[userId] != NULL && pMinecraft->localplayers[userId]->level != NULL && pMinecraft->localplayers[userId]->level->getLevelData() != NULL ) + if( pMinecraft->localplayers[userId] != nullptr && pMinecraft->localplayers[userId]->level != nullptr && pMinecraft->localplayers[userId]->level->getLevelData() != nullptr ) { GameType *gameType = pMinecraft->localplayers[userId]->level->getLevelData()->getGameType(); @@ -235,7 +235,7 @@ int CTelemetryManager::GetSubLevelId(int userId) Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[userId] != NULL) + if(pMinecraft->localplayers[userId] != nullptr) { switch(pMinecraft->localplayers[userId]->dimension) { diff --git a/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.cpp b/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.cpp index 4296a04bd..ebcc44bcc 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.cpp @@ -62,8 +62,8 @@ void ChangeStateConstraint::tick(int iPad) { Minecraft* pMinecraft = Minecraft::GetInstance(); std::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( std::shared_ptr(new PlayerInfoPacket( player->connection->getNetworkPlayer() @@ -94,7 +94,7 @@ void ChangeStateConstraint::tick(int iPad) { m_tutorial->changeTutorialState(m_targetState); if (m_changeGameMode) { - if (minecraft->localgameModes[iPad] != NULL) { + if (minecraft->localgameModes[iPad] != nullptr) { m_changedFromGameMode = minecraft->localplayers[iPad]->abilities.instabuild ? GameType::CREATIVE @@ -113,8 +113,8 @@ void ChangeStateConstraint::tick(int iPad) { Minecraft* pMinecraft = Minecraft::GetInstance(); std::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( std::shared_ptr( new PlayerInfoPacket( @@ -144,8 +144,8 @@ void ChangeStateConstraint::tick(int iPad) { Minecraft* pMinecraft = Minecraft::GetInstance(); std::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( std::shared_ptr(new PlayerInfoPacket( player->connection->getNetworkPlayer() diff --git a/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.h b/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.h index 44c9b410b..4be844890 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.h +++ b/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.h @@ -37,7 +37,7 @@ public: std::size_t sourceStatesCount, double x0, double y0, double z0, double x1, double y1, double z1, bool contains = true, bool changeGameMode = false, - GameType* targetGameMode = NULL); + GameType* targetGameMode = nullptr); ~ChangeStateConstraint(); virtual void tick(int iPad); diff --git a/Minecraft.Client/Platform/Common/Tutorial/ChoiceTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/ChoiceTask.cpp index 8349199dc..7a2bd4eb2 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/ChoiceTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/ChoiceTask.cpp @@ -14,7 +14,7 @@ ChoiceTask::ChoiceTask( 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) { constraints.push_back(new InputConstraint(iConfirmMapping)); constraints.push_back(new InputConstraint(iCancelMapping)); diff --git a/Minecraft.Client/Platform/Common/Tutorial/CompleteUsingItemTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/CompleteUsingItemTask.cpp index 74300bf8f..bcf5b2002 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/CompleteUsingItemTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/CompleteUsingItemTask.cpp @@ -6,7 +6,7 @@ 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 < itemIdsLength; i++) { m_iValidItemsA[i] = itemIds[i]; diff --git a/Minecraft.Client/Platform/Common/Tutorial/ControllerTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/ControllerTask.cpp index 02c1a3eb3..1a82e615f 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/ControllerTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/ControllerTask.cpp @@ -14,7 +14,7 @@ ControllerTask::ControllerTask(Tutorial* tutorial, int descriptionId, int iCompletionMaskACount, int iSouthpawMappings[], unsigned int uiSouthpawMappingsCount) - : TutorialTask(tutorial, descriptionId, enablePreCompletion, NULL, + : TutorialTask(tutorial, descriptionId, enablePreCompletion, nullptr, showMinimumTime) { for (unsigned int i = 0; i < mappingsLength; ++i) { constraints.push_back(new InputConstraint(mappings[i])); diff --git a/Minecraft.Client/Platform/Common/Tutorial/ControllerTask.h b/Minecraft.Client/Platform/Common/Tutorial/ControllerTask.h index 535c8b4c5..2fd63e751 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/ControllerTask.h +++ b/Minecraft.Client/Platform/Common/Tutorial/ControllerTask.h @@ -23,8 +23,8 @@ public: ControllerTask(Tutorial* tutorial, int descriptionId, bool enablePreCompletion, bool showMinimumTime, int mappings[], unsigned int mappingsLength, - int iCompletionMaskA[] = NULL, int iCompletionMaskACount = 0, - int iSouthpawMappings[] = NULL, + int iCompletionMaskA[] = nullptr, int iCompletionMaskACount = 0, + int iSouthpawMappings[] = nullptr, unsigned int uiSouthpawMappingsCount = 0); ~ControllerTask(); virtual bool isCompleted(); diff --git a/Minecraft.Client/Platform/Common/Tutorial/CraftTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/CraftTask.cpp index 59d3f9597..d3bc59fc7 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/CraftTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/CraftTask.cpp @@ -4,7 +4,7 @@ CraftTask::CraftTask(int itemId, int auxValue, int quantity, Tutorial* tutorial, int descriptionId, bool enablePreCompletion /*= true*/, - std::vector* inConstraints /*= NULL*/, + std::vector* inConstraints /*= nullptr*/, bool bShowMinimumTime /*=false*/, bool bAllowFade /*=true*/, bool m_bTaskReminders /*=true*/) : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, @@ -21,7 +21,7 @@ CraftTask::CraftTask(int itemId, int auxValue, int quantity, Tutorial* tutorial, CraftTask::CraftTask(int* items, int* auxValues, int numItems, int quantity, Tutorial* tutorial, int descriptionId, bool enablePreCompletion /*= true*/, - std::vector* inConstraints /*= NULL*/, + std::vector* inConstraints /*= nullptr*/, bool bShowMinimumTime /*=false*/, bool bAllowFade /*=true*/, bool m_bTaskReminders /*=true*/) : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, diff --git a/Minecraft.Client/Platform/Common/Tutorial/CraftTask.h b/Minecraft.Client/Platform/Common/Tutorial/CraftTask.h index 20f4f16b8..3729d49b9 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/CraftTask.h +++ b/Minecraft.Client/Platform/Common/Tutorial/CraftTask.h @@ -5,13 +5,13 @@ class CraftTask : public TutorialTask { public: CraftTask(int itemId, int auxValue, int quantity, Tutorial* tutorial, int descriptionId, bool enablePreCompletion = true, - std::vector* inConstraints = NULL, + std::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, - std::vector* inConstraints = NULL, + std::vector* inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool m_bTaskReminders = true); diff --git a/Minecraft.Client/Platform/Common/Tutorial/DiggerItemHint.cpp b/Minecraft.Client/Platform/Common/Tutorial/DiggerItemHint.cpp index d28b027a9..a23dc4853 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/DiggerItemHint.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/DiggerItemHint.cpp @@ -21,7 +21,7 @@ DiggerItemHint::DiggerItemHint(eTutorial_Hint id, Tutorial* tutorial, int DiggerItemHint::startDestroyBlock(std::shared_ptr item, Tile* tile) { - if (item != NULL) { + if (item != nullptr) { bool itemFound = false; for (unsigned int i = 0; i < m_iItemsCount; i++) { if (item->id == m_iItems[i]) { @@ -42,7 +42,7 @@ int DiggerItemHint::startDestroyBlock(std::shared_ptr item, int DiggerItemHint::attack(std::shared_ptr item, std::shared_ptr entity) { - if (item != NULL) { + if (item != nullptr) { bool itemFound = false; for (unsigned int i = 0; i < m_iItemsCount; i++) { if (item->id == m_iItems[i]) { diff --git a/Minecraft.Client/Platform/Common/Tutorial/EffectChangedTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/EffectChangedTask.cpp index 6a36d34b3..e07d075fb 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/EffectChangedTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/EffectChangedTask.cpp @@ -7,7 +7,7 @@ EffectChangedTask::EffectChangedTask(Tutorial* tutorial, int descriptionId, bool enablePreCompletion, bool bShowMinimumTime, bool bAllowFade, bool bTaskReminders) - : TutorialTask(tutorial, descriptionId, enablePreCompletion, NULL, + : TutorialTask(tutorial, descriptionId, enablePreCompletion, nullptr, bShowMinimumTime, bAllowFade, bTaskReminders) { m_effect = effect; m_apply = apply; diff --git a/Minecraft.Client/Platform/Common/Tutorial/FullTutorial.cpp b/Minecraft.Client/Platform/Common/Tutorial/FullTutorial.cpp index 4686a4055..48259ceae 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/FullTutorial.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/FullTutorial.cpp @@ -267,10 +267,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) 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) { std::vector* areaConstraints = new std::vector(); areaConstraints->push_back(new AreaConstraint( @@ -483,10 +483,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, @@ -502,9 +502,9 @@ 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, @@ -520,9 +520,9 @@ 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, @@ -538,10 +538,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, @@ -558,9 +558,9 @@ 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( @@ -614,9 +614,9 @@ 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, @@ -659,10 +659,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, @@ -701,7 +701,7 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) AABB* exitArea = app.getGameRuleDefinitions()->getNamedArea(L"creativeExitArea"); - if (exitArea != NULL) { + if (exitArea != nullptr) { std::vector* creativeExitAreaConstraints = new std::vector(); creativeExitAreaConstraints->push_back(new AreaConstraint( @@ -737,9 +737,9 @@ 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, @@ -800,10 +800,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, @@ -852,9 +852,9 @@ 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, @@ -902,9 +902,9 @@ 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, @@ -950,10 +950,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, @@ -989,9 +989,9 @@ 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, @@ -1027,9 +1027,9 @@ 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, @@ -1077,10 +1077,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, @@ -1116,9 +1116,9 @@ 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, @@ -1184,10 +1184,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, @@ -1247,9 +1247,9 @@ 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, diff --git a/Minecraft.Client/Platform/Common/Tutorial/FullTutorialActiveTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/FullTutorialActiveTask.cpp index 775617c5d..4acc3698b 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/FullTutorialActiveTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/FullTutorialActiveTask.cpp @@ -5,7 +5,7 @@ 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/Platform/Common/Tutorial/InfoTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/InfoTask.cpp index 2149d03e3..2442a083c 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/InfoTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/InfoTask.cpp @@ -12,7 +12,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) { constraints.push_back(new InputConstraint(iMapping)); } diff --git a/Minecraft.Client/Platform/Common/Tutorial/PickupTask.h b/Minecraft.Client/Platform/Common/Tutorial/PickupTask.h index b5f070416..d9a1cdc41 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/PickupTask.h +++ b/Minecraft.Client/Platform/Common/Tutorial/PickupTask.h @@ -9,7 +9,7 @@ public: PickupTask(int itemId, unsigned int quantity, int auxValue, Tutorial* tutorial, int descriptionId, bool enablePreCompletion = true, - std::vector* inConstraints = NULL, + std::vector* inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool m_bTaskReminders = true) : TutorialTask(tutorial, descriptionId, enablePreCompletion, diff --git a/Minecraft.Client/Platform/Common/Tutorial/ProcedureCompoundTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/ProcedureCompoundTask.cpp index 5850ee83f..f5a8ddbab 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/ProcedureCompoundTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/ProcedureCompoundTask.cpp @@ -9,7 +9,7 @@ ProcedureCompoundTask::~ProcedureCompoundTask() { } void ProcedureCompoundTask::AddTask(TutorialTask* task) { - if (task != NULL) { + if (task != nullptr) { m_taskSequence.push_back(task); } } diff --git a/Minecraft.Client/Platform/Common/Tutorial/ProcedureCompoundTask.h b/Minecraft.Client/Platform/Common/Tutorial/ProcedureCompoundTask.h index 2e0ea82e5..1cf44db38 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/ProcedureCompoundTask.h +++ b/Minecraft.Client/Platform/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/Platform/Common/Tutorial/ProgressFlagTask.h b/Minecraft.Client/Platform/Common/Tutorial/ProgressFlagTask.h index 2d12cb11a..5b14e216d 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/ProgressFlagTask.h +++ b/Minecraft.Client/Platform/Common/Tutorial/ProgressFlagTask.h @@ -18,7 +18,7 @@ private: 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/Platform/Common/Tutorial/RideEntityTask.h b/Minecraft.Client/Platform/Common/Tutorial/RideEntityTask.h index 014979f1a..1c04e1a6a 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/RideEntityTask.h +++ b/Minecraft.Client/Platform/Common/Tutorial/RideEntityTask.h @@ -12,7 +12,7 @@ protected: public: RideEntityTask(const int eTYPE, Tutorial* tutorial, int descriptionId, bool enablePreCompletion = false, - std::vector* inConstraints = NULL, + std::vector* inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true); diff --git a/Minecraft.Client/Platform/Common/Tutorial/StatTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/StatTask.cpp index dfa321daf..321c93c19 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/StatTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/StatTask.cpp @@ -7,7 +7,7 @@ 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; Minecraft* minecraft = Minecraft::GetInstance(); diff --git a/Minecraft.Client/Platform/Common/Tutorial/StateChangeTask.h b/Minecraft.Client/Platform/Common/Tutorial/StateChangeTask.h index a6e9b3cee..9a5e7a83a 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/StateChangeTask.h +++ b/Minecraft.Client/Platform/Common/Tutorial/StateChangeTask.h @@ -10,7 +10,7 @@ private: public: StateChangeTask(eTutorial_State state, Tutorial* tutorial, int descriptionId = -1, bool enablePreCompletion = false, - std::vector* inConstraints = NULL, + std::vector* inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool m_bTaskReminders = true) : TutorialTask(tutorial, descriptionId, enablePreCompletion, diff --git a/Minecraft.Client/Platform/Common/Tutorial/TakeItemHint.cpp b/Minecraft.Client/Platform/Common/Tutorial/TakeItemHint.cpp index ef2b973b0..ca2dac44b 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/TakeItemHint.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/TakeItemHint.cpp @@ -16,7 +16,7 @@ TakeItemHint::TakeItemHint(eTutorial_Hint id, Tutorial* tutorial, int items[], } bool TakeItemHint::onTake(std::shared_ptr item) { - if (item != NULL) { + if (item != nullptr) { bool itemFound = false; for (unsigned int i = 0; i < m_iItemsCount; i++) { if (item->id == m_iItems[i]) { diff --git a/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp b/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp index 0b4e6fbea..c0d28f0b5 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp @@ -30,7 +30,7 @@ int Tutorial::m_iTutorialConstraintDelayRemoveTicks = 15; int Tutorial::m_iTutorialFreezeTimeValue = 8000; bool Tutorial::PopupMessageDetails::isSameContent(PopupMessageDetails* other) { - if (other == NULL) return false; + if (other == nullptr) return false; bool textTheSame = (m_messageId == other->m_messageId) && (m_messageString.compare(other->m_messageString) == 0); @@ -362,7 +362,7 @@ 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; @@ -370,7 +370,7 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad(iPad) { // 4jcraft added, not initialized m_bSceneIsSplitscreen = false; - m_lastMessage = NULL; + m_lastMessage = nullptr; lastMessageTime = 0; m_iTaskReminders = 0; @@ -380,8 +380,8 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad(iPad) { m_hasStateChanged = false; 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 @@ -1683,7 +1683,7 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad(iPad) { if (isFullTutorial) addTask(e_Tutorial_State_Horse, new RideEntityTask(eTYPE_HORSE, this, - IDS_TUTORIAL_TASK_HORSE_RIDE, true, NULL, + IDS_TUTORIAL_TASK_HORSE_RIDE, true, nullptr, false, false, false)); else addTask(e_Tutorial_State_Horse, @@ -1947,8 +1947,8 @@ Tutorial::~Tutorial() { delete (*it); } - currentTask[i] = NULL; - currentFailedConstraint[i] = NULL; + currentTask[i] = nullptr; + currentFailedConstraint[i] = nullptr; } } @@ -2115,7 +2115,7 @@ void Tutorial::tick() { } if (!m_allowShow) { - if (currentTask[m_CurrentState] != NULL && + if (currentTask[m_CurrentState] != nullptr && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime) > GetTickCount())) { @@ -2136,7 +2136,7 @@ void Tutorial::tick() { } if (ui.IsPauseMenuDisplayed(m_iPad)) { - if (currentTask[m_CurrentState] != NULL && + if (currentTask[m_CurrentState] != nullptr && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime) > GetTickCount())) { @@ -2186,14 +2186,14 @@ 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] == nullptr || currentFailedConstraint[m_CurrentState]->isConstraintSatisfied( m_iPad))) { - if (currentFailedConstraint[m_CurrentState] != NULL && + if (currentFailedConstraint[m_CurrentState] != nullptr && currentFailedConstraint[m_CurrentState]->isConstraintSatisfied( m_iPad)) { constraintChanged = true; - currentFailedConstraint[m_CurrentState] = NULL; + currentFailedConstraint[m_CurrentState] = nullptr; } for (AUTO_VAR(it, constraints[m_CurrentState].begin()); it < constraints[m_CurrentState].end(); ++it) { @@ -2207,7 +2207,7 @@ void Tutorial::tick() { } if (!m_allTutorialsComplete && - currentFailedConstraint[m_CurrentState] == NULL) { + currentFailedConstraint[m_CurrentState] == nullptr) { // Update tasks bool isCurrentTask = true; AUTO_VAR(it, activeTasks[m_CurrentState].begin()); @@ -2225,7 +2225,7 @@ void Tutorial::tick() { task->getCompletionAction(); it = activeTasks[m_CurrentState].erase(it); delete task; - task = NULL; + task = nullptr; if (activeTasks[m_CurrentState].size() > 0) { switch (compAction) { @@ -2297,20 +2297,20 @@ void Tutorial::tick() { } else { 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 && + if (currentTask[m_CurrentState] != nullptr && currentTask[m_CurrentState]->isPreCompletionEnabled()) { isCurrentTask = true; } } else { ++it; } - if (task != NULL && task->ShowMinimumTime() && + if (task != nullptr && task->ShowMinimumTime() && task->hasBeenActivated() && (lastMessageTime + m_iTutorialMinimumDisplayMessageTime) < GetTickCount()) { @@ -2331,7 +2331,7 @@ void Tutorial::tick() { } } - if (currentTask[m_CurrentState] == NULL && + if (currentTask[m_CurrentState] == nullptr && activeTasks[m_CurrentState].size() > 0) { currentTask[m_CurrentState] = activeTasks[m_CurrentState][0]; currentTask[m_CurrentState]->setAsCurrentTask(); @@ -2355,19 +2355,19 @@ void Tutorial::tick() { } if (constraintChanged || taskChanged || m_hasStateChanged || - (currentFailedConstraint[m_CurrentState] == NULL && - currentTask[m_CurrentState] != NULL && - (m_lastMessage == NULL || + (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(); @@ -2377,7 +2377,7 @@ void Tutorial::tick() { currentTask[m_CurrentState]->TaskReminders() ? m_iTaskReminders = 1 : m_iTaskReminders = 0; } else { - setMessage(NULL); + setMessage(nullptr); } } @@ -2386,8 +2386,8 @@ void Tutorial::tick() { m_hintDisplayed = false; } - if (currentFailedConstraint[m_CurrentState] == NULL && - currentTask[m_CurrentState] != NULL && (m_iTaskReminders != 0) && + if (currentFailedConstraint[m_CurrentState] == nullptr && + currentTask[m_CurrentState] != nullptr && (m_iTaskReminders != 0) && (lastMessageTime + (m_iTaskReminders * m_iTutorialReminderTime)) < GetTickCount()) { // Reminder @@ -2413,7 +2413,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 || @@ -2423,7 +2423,7 @@ bool Tutorial::setMessage(PopupMessageDetails* message) { return false; } - if (message != NULL && + if (message != nullptr && (message->m_messageId > 0 || !message->m_messageString.empty())) { m_lastMessageState = m_CurrentState; @@ -2434,7 +2434,7 @@ bool Tutorial::setMessage(PopupMessageDetails* message) { text = message->m_messageString; } else { AUTO_VAR(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 = std::wstring(messageString->getMessageForDisplay()); @@ -2458,7 +2458,7 @@ bool Tutorial::setMessage(PopupMessageDetails* message) { text.append(message->m_promptString); } else if (message->m_promptId >= 0) { AUTO_VAR(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()); } @@ -2484,7 +2484,7 @@ bool Tutorial::setMessage(PopupMessageDetails* message) { } else { ui.SetTutorialDescription(m_iPad, &popupInfo); } - } else if ((m_lastMessage != NULL && + } else if ((m_lastMessage != nullptr && m_lastMessage->m_messageId != -1)) //&& (lastMessageTime + m_iTutorialReminderTime ) > // GetTickCount() ) @@ -2496,7 +2496,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; @@ -2511,7 +2511,7 @@ bool Tutorial::setMessage(TutorialHint* hint, PopupMessageDetails* message) { bool messageShown = false; std::uint32_t 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) || @@ -2522,7 +2522,7 @@ bool Tutorial::setMessage(TutorialHint* hint, PopupMessageDetails* message) { if (messageShown) { m_lastHintDisplayedTime = time; m_hintDisplayed = true; - if (hint != NULL) setHintCompleted(hint); + if (hint != nullptr) setHintCompleted(hint); } } return messageShown; @@ -2543,7 +2543,7 @@ void Tutorial::showTutorialPopup(bool show) { m_allowShow = show; if (!show) { - if (currentTask[m_CurrentState] != NULL && + if (currentTask[m_CurrentState] != nullptr && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime) > GetTickCount())) { @@ -2660,7 +2660,7 @@ void Tutorial::handleUIInput(int iAction) { // TutorialTask *task = *it; // task->handleUIInput(iAction); // } - if (currentTask[m_CurrentState] != NULL) + if (currentTask[m_CurrentState] != nullptr) currentTask[m_CurrentState]->handleUIInput(iAction); } @@ -2719,7 +2719,7 @@ void Tutorial::onSelectedItemChanged(std::shared_ptr item) { // the selected item Menus and states like riding in a minecart will NOT // allow this if (isSelectedItemState()) { - if (item != NULL) { + if (item != nullptr) { switch (item->id) { case Item::fishingRod_Id: changeTutorialState(e_Tutorial_State_Fishing); @@ -2871,7 +2871,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()) { // If it is already queued for removal, remove it on the next tick @@ -2934,12 +2934,12 @@ void Tutorial::addMessage( } void Tutorial::changeTutorialState(eTutorial_State newState, - UIScene* scene /*= NULL*/) + UIScene* scene /*= nullptr*/) { if (newState == m_CurrentState) { // If clearing the scene, make sure that the tutorial popup has its // reference to this scene removed - if (scene == NULL) { + if (scene == nullptr) { ui.RemoveInteractSceneReference(m_iPad, m_UIScene); } m_UIScene = scene; @@ -2960,7 +2960,7 @@ void Tutorial::changeTutorialState(eTutorial_State newState, // The action that caused the change of state may also have completed // the current task - if (currentTask[m_CurrentState] != NULL && + if (currentTask[m_CurrentState] != nullptr && currentTask[m_CurrentState]->isCompleted()) { activeTasks[m_CurrentState].erase( find(activeTasks[m_CurrentState].begin(), @@ -2971,20 +2971,20 @@ void Tutorial::changeTutorialState(eTutorial_State newState, currentTask[m_CurrentState] = activeTasks[m_CurrentState][0]; currentTask[m_CurrentState]->setAsCurrentTask(); } 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 - if (scene == NULL) { + if (scene == nullptr) { ui.RemoveInteractSceneReference(m_iPad, m_UIScene); } m_UIScene = scene; diff --git a/Minecraft.Client/Platform/Common/Tutorial/Tutorial.h b/Minecraft.Client/Platform/Common/Tutorial/Tutorial.h index 94e027447..a7bb5177c 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/Tutorial.h +++ b/Minecraft.Client/Platform/Common/Tutorial/Tutorial.h @@ -135,7 +135,7 @@ public: void setCompleted(int completableId); bool getCompleted(int completableId); - void changeTutorialState(eTutorial_State newState, UIScene* scene = NULL); + void changeTutorialState(eTutorial_State newState, UIScene* scene = nullptr); bool isSelectedItemState(); bool setMessage(PopupMessageDetails* message); diff --git a/Minecraft.Client/Platform/Common/Tutorial/TutorialHint.cpp b/Minecraft.Client/Platform/Common/Tutorial/TutorialHint.cpp index e45fa4358..91a4797f3 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/TutorialHint.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/TutorialHint.cpp @@ -15,7 +15,7 @@ TutorialHint::TutorialHint(eTutorial_Hint id, Tutorial* tutorial, m_descriptionId(descriptionId), m_type(type), m_counter(0), - m_lastTile(NULL), + m_lastTile(nullptr), m_hintNeeded(true), m_allowFade(allowFade) { tutorial->addMessage(descriptionId, type != e_Hint_NoIngredients); diff --git a/Minecraft.Client/Platform/Common/Tutorial/TutorialMode.cpp b/Minecraft.Client/Platform/Common/Tutorial/TutorialMode.cpp index a51d6030e..e6c74cc5b 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/TutorialMode.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/TutorialMode.cpp @@ -14,7 +14,7 @@ TutorialMode::TutorialMode(int iPad, Minecraft* minecraft, : MultiPlayerGameMode(minecraft, connection), m_iPad(iPad) {} TutorialMode::~TutorialMode() { - if (tutorial != NULL) delete tutorial; + if (tutorial != nullptr) delete tutorial; } void TutorialMode::startDestroyBlock(int x, int y, int z, int face) { @@ -33,13 +33,13 @@ bool TutorialMode::destroyBlock(int x, int y, int z, int face) { } std::shared_ptr item = minecraft->player->getSelectedItem(); int damageBefore; - if (item != NULL) { + if (item != nullptr) { damageBefore = item->getDamageValue(); } bool changed = MultiPlayerGameMode::destroyBlock(x, y, z, face); if (!tutorial->m_allTutorialsComplete) { - if (item != NULL && item->isDamageableItem()) { + if (item != nullptr && item->isDamageableItem()) { int max = item->getMaxDamage(); int damageNow = item->getDamageValue(); @@ -78,7 +78,7 @@ bool TutorialMode::useItemOn(std::shared_ptr player, Level* level, tutorial->useItemOn(level, item, x, y, z, bTestUseOnly); if (!bTestUseOnly) { - if (item != NULL) { + if (item != nullptr) { haveItem = true; itemCount = item->count; } diff --git a/Minecraft.Client/Platform/Common/Tutorial/TutorialMode.h b/Minecraft.Client/Platform/Common/Tutorial/TutorialMode.h index e8448ed91..6ddad5d79 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/TutorialMode.h +++ b/Minecraft.Client/Platform/Common/Tutorial/TutorialMode.h @@ -22,7 +22,7 @@ public: virtual bool useItemOn(std::shared_ptr player, Level* level, std::shared_ptr item, int x, int y, int z, int face, Vec3* hit, - bool bTestUseOnly = false, bool* pbUsedItem = NULL); + bool bTestUseOnly = false, bool* pbUsedItem = nullptr); virtual void attack(std::shared_ptr player, std::shared_ptr entity); diff --git a/Minecraft.Client/Platform/Common/Tutorial/TutorialTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/TutorialTask.cpp index 1d37ce30b..ffafcb72e 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/TutorialTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/TutorialTask.cpp @@ -19,7 +19,7 @@ TutorialTask::TutorialTask(Tutorial* tutorial, int descriptionId, m_bTaskReminders(bTaskReminders), m_bShowMinimumTime(bShowMinimumTime), m_bShownForMinimumTime(false) { - if (inConstraints != NULL) { + if (inConstraints != nullptr) { for (AUTO_VAR(it, inConstraints->begin()); it < inConstraints->end(); ++it) { TutorialConstraint* constraint = *it; diff --git a/Minecraft.Client/Platform/Common/Tutorial/UseItemTask.h b/Minecraft.Client/Platform/Common/Tutorial/UseItemTask.h index 25ca6db56..ba7c73ef7 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/UseItemTask.h +++ b/Minecraft.Client/Platform/Common/Tutorial/UseItemTask.h @@ -13,7 +13,7 @@ private: public: UseItemTask(const int itemId, Tutorial* tutorial, int descriptionId, bool enablePreCompletion = false, - std::vector* inConstraints = NULL, + std::vector* inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true); virtual bool isCompleted(); diff --git a/Minecraft.Client/Platform/Common/Tutorial/UseTileTask.h b/Minecraft.Client/Platform/Common/Tutorial/UseTileTask.h index fe1d26be3..e6747701c 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/UseTileTask.h +++ b/Minecraft.Client/Platform/Common/Tutorial/UseTileTask.h @@ -17,12 +17,12 @@ private: public: UseTileTask(const int tileId, int x, int y, int z, Tutorial* tutorial, int descriptionId, bool enablePreCompletion = false, - std::vector* inConstraints = NULL, + std::vector* inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true); UseTileTask(const int tileId, Tutorial* tutorial, int descriptionId, bool enablePreCompletion = false, - std::vector* inConstraints = NULL, + std::vector* inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true); virtual bool isCompleted(); diff --git a/Minecraft.Client/Platform/Common/Tutorial/XuiCraftingTask.cpp b/Minecraft.Client/Platform/Common/Tutorial/XuiCraftingTask.cpp index 0259d192b..e27f9e052 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/XuiCraftingTask.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/XuiCraftingTask.cpp @@ -15,13 +15,13 @@ bool XuiCraftingTask::isCompleted() { switch (m_type) { case e_Crafting_SelectGroup: - if (craftScene != NULL && + 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; } break; diff --git a/Minecraft.Client/Platform/Common/Tutorial/XuiCraftingTask.h b/Minecraft.Client/Platform/Common/Tutorial/XuiCraftingTask.h index 14c94c033..3ed6b6d96 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/XuiCraftingTask.h +++ b/Minecraft.Client/Platform/Common/Tutorial/XuiCraftingTask.h @@ -13,7 +13,7 @@ public: XuiCraftingTask(Tutorial* tutorial, int descriptionId, Recipy::_eGroupType groupToSelect, bool enablePreCompletion = false, - std::vector* inConstraints = NULL, + std::vector* inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool m_bTaskReminders = true) : TutorialTask(tutorial, descriptionId, enablePreCompletion, @@ -25,7 +25,7 @@ public: // Select Item XuiCraftingTask(Tutorial* tutorial, int descriptionId, int itemId, bool enablePreCompletion = false, - std::vector* inConstraints = NULL, + std::vector* inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool m_bTaskReminders = true) : TutorialTask(tutorial, descriptionId, enablePreCompletion, diff --git a/Minecraft.Client/Platform/Common/UI/IUIController.h b/Minecraft.Client/Platform/Common/UI/IUIController.h index 60d79ccef..72749780e 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIController.h +++ b/Minecraft.Client/Platform/Common/UI/IUIController.h @@ -13,7 +13,7 @@ public: virtual bool IsReloadingSkin() = 0; virtual void CleanUpSkinReload() = 0; virtual bool NavigateToScene(int iPad, EUIScene scene, - void* initData = NULL, + void* initData = nullptr, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD) = 0; virtual bool NavigateBack(int iPad, bool forceUsePad = false, diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp index db0aa476d..40d9f016b 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -11,9 +11,9 @@ 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; @@ -30,7 +30,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; @@ -210,10 +210,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)) { return; @@ -619,16 +619,16 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { std::shared_ptr player = Minecraft::GetInstance()->localplayers[getPad()]; std::shared_ptr carriedItem = nullptr; - if (player != NULL) carriedItem = player->inventory->getCarried(); + if (player != nullptr) carriedItem = player->inventory->getCarried(); std::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. @@ -648,7 +648,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { 0; // How many more items can be stacked on this slot. if (bPointerIsOverSlot) { slotItem = slot->getItem(); - bSlotHasItem = slotItem != NULL; + bSlotHasItem = slotItem != nullptr; if (bSlotHasItem) { iSlotCount = slotItem->GetCount(); @@ -690,11 +690,11 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { std::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; @@ -833,7 +833,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { bool bValidFuel = FurnaceTileEntity::isFuel(item); bool bValidIngredient = FurnaceRecipes::getInstance()->getResult( - item->getItem()->id) != NULL; + item->getItem()->id) != nullptr; if (bValidIngredient) { // is there already something in the ingredient slot? @@ -845,7 +845,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { buttonY = eToolTipQuickMoveIngredient; } else { if (FurnaceRecipes::getInstance()->getResult( - item->id) == NULL) { + item->id) == nullptr) { buttonY = eToolTipQuickMove; } else { buttonY = eToolTipQuickMoveIngredient; @@ -874,7 +874,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { buttonY = eToolTipQuickMoveIngredient; } else { if (FurnaceRecipes::getInstance() - ->getResult(item->id) == NULL) { + ->getResult(item->id) == nullptr) { buttonY = eToolTipQuickMove; } else { buttonY = eToolTipQuickMoveIngredient; @@ -1080,10 +1080,10 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, 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)) { @@ -1210,12 +1210,12 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, std::shared_ptr item = getSlotItem(m_eCurrSection, currentIndex); if (Minecraft::GetInstance()->localgameModes[iPad] != - NULL) { + nullptr) { Tutorial::PopupMessageDetails* message = new Tutorial::PopupMessageDetails; message->m_messageId = item->getUseDescriptionId(); - if (Item::items[item->id] != NULL) + if (Item::items[item->id] != nullptr) message->m_titleString = Item::items[item->id]->getHoverName(item); message->m_titleId = item->getDescriptionId(); @@ -1227,7 +1227,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, TutorialMode* gameMode = (TutorialMode*)Minecraft::GetInstance() ->localgameModes[iPad]; - gameMode->getTutorial()->setMessage(NULL, message); + gameMode->getTutorial()->setMessage(nullptr, message); ui.PlayUISFX(eSFX_Press); } } @@ -1329,7 +1329,7 @@ void IUIScene_AbstractContainerMenu::handleSlotListClicked( 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( @@ -1347,7 +1347,7 @@ int IUIScene_AbstractContainerMenu::getCurrentIndex(ESceneSection eSection) { bool IUIScene_AbstractContainerMenu::IsSameItemAs( std::shared_ptr itemA, std::shared_ptr itemB) { - if (itemA == NULL || itemB == NULL) return false; + if (itemA == nullptr || itemB == nullptr) return false; return (itemA->id == itemB->id && (!itemB->isStackedByData() || @@ -1358,7 +1358,7 @@ bool IUIScene_AbstractContainerMenu::IsSameItemAs( int IUIScene_AbstractContainerMenu::GetEmptyStackSpace(Slot* slot) { int iResult = 0; - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr item = slot->getItem(); if (item->isStackable()) { int iCount = item->GetCount(); @@ -1376,7 +1376,7 @@ int IUIScene_AbstractContainerMenu::GetEmptyStackSpace(Slot* slot) { std::vector* IUIScene_AbstractContainerMenu::GetItemDescription( Slot* slot) { - if (slot == NULL) return NULL; + if (slot == nullptr) return nullptr; std::vector* lines = slot->getItem()->getHoverText(nullptr, false); @@ -1395,5 +1395,5 @@ std::vector* IUIScene_AbstractContainerMenu::GetItemDescription( std::vector* IUIScene_AbstractContainerMenu::GetSectionHoverText( ESceneSection eSection) { - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp index 90022c2e0..9b45900f9 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp @@ -9,7 +9,7 @@ IUIScene_AnvilMenu::IUIScene_AnvilMenu() { m_inventory = nullptr; - m_repairMenu = NULL; + m_repairMenu = nullptr; m_itemName = L""; } @@ -189,7 +189,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) { m_itemName = L""; @@ -218,10 +218,10 @@ void IUIScene_AnvilMenu::slotChanged(AbstractContainerMenu* container, int slotIndex, std::shared_ptr item) { 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/Platform/Common/UI/IUIScene_BeaconMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp index 6869ce689..58276e3d9 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp @@ -202,7 +202,7 @@ void IUIScene_BeaconMenu::handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey) { switch (eSection) { case eSectionBeaconConfirm: { - if ((m_beacon->getItem(0) == NULL) || + if ((m_beacon->getItem(0) == nullptr) || (m_beacon->getPrimaryPower() <= 0)) return; ByteArrayOutputStream baos; @@ -271,7 +271,7 @@ void IUIScene_BeaconMenu::handleTick() { int totalWidth = count * 22 + (count - 1) * 2; 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(); @@ -298,7 +298,7 @@ void IUIScene_BeaconMenu::handleTick() { int totalWidth = count * 22 + (count - 1) * 2; 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(); @@ -335,7 +335,7 @@ void IUIScene_BeaconMenu::handleTick() { } } - SetConfirmButtonEnabled((m_beacon->getItem(0) != NULL) && + SetConfirmButtonEnabled((m_beacon->getItem(0) != nullptr) && (m_beacon->getPrimaryPower() > 0)); } @@ -345,7 +345,7 @@ int IUIScene_BeaconMenu::GetId(int tier, int effectId) { std::vector* IUIScene_BeaconMenu::GetSectionHoverText( ESceneSection eSection) { - std::vector* desc = NULL; + std::vector* desc = nullptr; switch (eSection) { case eSectionBeaconSecondaryTwo: if (GetPowerButtonId(eSectionBeaconSecondaryTwo) == 0) { diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp index c398b7379..9bd972dd4 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp @@ -130,10 +130,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)) { @@ -188,10 +188,10 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) { // 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); } } @@ -223,10 +223,10 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) { // 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] @@ -296,7 +296,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()) { // replace item with remaining @@ -616,7 +616,7 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() { /* 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) { std::wstring itemstring=m_pPlayer->inventory->items[k]->toString(); @@ -638,8 +638,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() { // for (int i = 0; i < iRecipeC; i++) // { // std::shared_ptr - // pTempItemInst=pRecipeIngredientsRequired[i].pRecipy->assemble(NULL); - // if (pTempItemInst != NULL) + // pTempItemInst=pRecipeIngredientsRequired[i].pRecipy->assemble(nullptr); + // if (pTempItemInst != nullptr) // { // std::wstring // itemstring=pTempItemInst->toString(); @@ -697,7 +697,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 == @@ -725,7 +725,7 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() { l < m_pPlayer->inventory->items.length; l++) { if (m_pPlayer->inventory->items[l] != - NULL) { + nullptr) { if ((m_pPlayer->inventory->items[l] ->id == pRecipeIngredientsRequired[i] diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp index 47c28d4c6..3a6d9f5f7 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp @@ -13,7 +13,7 @@ #include "../../Minecraft.World/Util/JavaMath.h" // 4J JEV - Images for each tab. -IUIScene_CreativeMenu::TabSpec** IUIScene_CreativeMenu::specs = NULL; +IUIScene_CreativeMenu::TabSpec** IUIScene_CreativeMenu::specs = nullptr; std::vector > IUIScene_CreativeMenu::categoryGroups[eCreativeInventoryGroupsCount]; @@ -508,7 +508,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()))); } @@ -803,7 +803,7 @@ void IUIScene_CreativeMenu::staticCtor() { eCreativeInventory_ArtToolsDecorations}; specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, - decorationsGroup, 0, NULL, 1, debugDecorationsGroup); + decorationsGroup, 0, nullptr, 1, debugDecorationsGroup); #else ECreative_Inventory_Groups decorationsGroup[] = { eCreativeInventory_Decoration}; @@ -862,7 +862,7 @@ void IUIScene_CreativeMenu::staticCtor() { ECreative_Inventory_Groups debugMiscGroup[] = { eCreativeInventory_ArtToolsMisc}; specs[eCreativeInventoryTab_Misc] = - new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, NULL, + new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, nullptr, 1, debugMiscGroup); #else ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc}; @@ -926,14 +926,14 @@ IUIScene_CreativeMenu::TabSpec::TabSpec( const wchar_t* icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups* staticGroups, int dynamicGroupsCount, ECreative_Inventory_Groups* dynamicGroups, int debugGroupsCount /*= 0*/, - ECreative_Inventory_Groups* debugGroups /*= NULL*/) + 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; @@ -946,7 +946,7 @@ IUIScene_CreativeMenu::TabSpec::TabSpec( } } - m_debugGroupsA = NULL; + m_debugGroupsA = nullptr; m_debugItems = 0; if (debugGroupsCount > 0) { m_debugGroupsA = new ECreative_Inventory_Groups[debugGroupsCount]; @@ -956,8 +956,8 @@ IUIScene_CreativeMenu::TabSpec::TabSpec( } } - 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) { m_dynamicGroupsA[i] = dynamicGroups[i]; @@ -970,9 +970,9 @@ IUIScene_CreativeMenu::TabSpec::TabSpec( } 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, @@ -981,7 +981,7 @@ void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu* menu, int lastSlotIndex = 0; // Fill the dynamic group - if (m_dynamicGroupsCount > 0 && m_dynamicGroupsA != NULL) { + if (m_dynamicGroupsCount > 0 && m_dynamicGroupsA != nullptr) { for (AUTO_VAR(it, categoryGroups[m_dynamicGroupsA[dynamicIndex]].rbegin()); it != categoryGroups[m_dynamicGroupsA[dynamicIndex]].rend() && @@ -1101,7 +1101,7 @@ IUIScene_CreativeMenu::ItemPickerMenu::ItemPickerMenu( // int startLength = slots->size(); - Slot* slot = NULL; + Slot* slot = nullptr; for (int i = 0; i < TabSpec::MAX_SIZE; i++) { // 4J JEV - These values get set by addSlot anyway. slot = new Slot(creativeContainer, i, -1, -1); @@ -1181,7 +1181,7 @@ bool IUIScene_CreativeMenu::handleValidKeyPress(int iPad, int buttonNum, std::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 pMinecraft->localgameModes[iPad]->handleCreativeModeItemAdd( @@ -1201,7 +1201,7 @@ void IUIScene_CreativeMenu::handleOutsideClicked(int iPad, int buttonNum, std::shared_ptr playerInventory = pMinecraft->localplayers[iPad]->inventory; - if (playerInventory->getCarried() != NULL) { + if (playerInventory->getCarried() != nullptr) { if (buttonNum == 0) { pMinecraft->localgameModes[iPad]->handleCreativeModeItemDrop( playerInventory->getCarried()); @@ -1283,7 +1283,7 @@ void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, playerInventory->getCarried(); std::shared_ptr clicked = m_menu->getSlot(currentIndex)->getItem(); - if (clicked != NULL) { + if (clicked != nullptr) { playerInventory->setCarried(ItemInstance::clone(clicked)); carried = playerInventory->getCarried(); if (quickKeyHeld) { @@ -1366,7 +1366,7 @@ bool IUIScene_CreativeMenu::getEmptyInventorySlot( // Jump to the slot with this item already on it, if we can stack more for (unsigned int i = TabSpec::MAX_SIZE; i < TabSpec::MAX_SIZE + 9; ++i) { std::shared_ptr slotItem = m_menu->getSlot(i)->getItem(); - if (slotItem != NULL && slotItem->sameItemWithTags(item) && + if (slotItem != nullptr && slotItem->sameItemWithTags(item) && (slotItem->GetCount() + item->GetCount() <= item->getMaxStackSize())) { sameItemFound = true; @@ -1379,7 +1379,7 @@ bool IUIScene_CreativeMenu::getEmptyInventorySlot( // 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; break; diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h index fc2cb071e..21f1e40d9 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h @@ -77,9 +77,9 @@ public: TabSpec(const wchar_t* icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups* staticGroups, int dynamicGroupsCount = 0, - ECreative_Inventory_Groups* dynamicGroups = NULL, + ECreative_Inventory_Groups* dynamicGroups = nullptr, int debugGroupsCount = 0, - ECreative_Inventory_Groups* debugGroups = NULL); + ECreative_Inventory_Groups* debugGroups = nullptr); ~TabSpec(); void populateMenu(AbstractContainerMenu* menu, int dynamicIndex, diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.cpp index 88a6d46a6..61109d231 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.cpp @@ -74,7 +74,7 @@ void IUIScene_HUD::updateFrameTick() { } else { // SetRidingHorse(false, 0); std::shared_ptr riding = pMinecraft->localplayers[iPad]->riding; - if (riding == NULL) { + if (riding == nullptr) { SetRidingHorse(false, false, 0); } else { SetRidingHorse( @@ -157,7 +157,7 @@ void IUIScene_HUD::updateFrameTick() { !(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); } else { SetVisible(false); @@ -205,7 +205,7 @@ void IUIScene_HUD::renderPlayerHealth() { std::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); ShowFood(true); diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp index 6c51d1bfb..46832a3a9 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp @@ -261,7 +261,7 @@ void IUIScene_PauseMenu::_ExitWorld(void* 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) { @@ -336,21 +336,21 @@ void IUIScene_PauseMenu::_ExitWorld(void* lpParameter) { // 4J - Force a disconnection, this handles the situation that the // server has already disconnected - if (pMinecraft->levels[0] != NULL) + if (pMinecraft->levels[0] != nullptr) pMinecraft->levels[0]->disconnect(false); - if (pMinecraft->levels[1] != NULL) + if (pMinecraft->levels[1] != nullptr) pMinecraft->levels[1]->disconnect(false); - if (pMinecraft->levels[2] != NULL) + 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) + if (pMinecraft->levels[0] != nullptr) pMinecraft->levels[0]->disconnect(); - if (pMinecraft->levels[1] != NULL) + if (pMinecraft->levels[1] != nullptr) pMinecraft->levels[1]->disconnect(); - if (pMinecraft->levels[2] != NULL) + if (pMinecraft->levels[2] != nullptr) pMinecraft->levels[2]->disconnect(); } @@ -366,7 +366,7 @@ void IUIScene_PauseMenu::_ExitWorld(void* lpParameter) { // 4J Stu - Leave the session once the disconnect packet has been sent g_NetworkManager.LeaveGame(FALSE); } else { - if (lpParameter != NULL && + if (lpParameter != nullptr && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) { switch (app.GetDisconnectReason()) { case DisconnectPacket::eDisconnect_Kicked: @@ -419,7 +419,7 @@ void IUIScene_PauseMenu::_ExitWorld(void* lpParameter) { while (g_NetworkManager.IsNetworkThreadRunning()) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); } - pMinecraft->setLevel(NULL, exitReasonStringId, nullptr, saveStats); + pMinecraft->setLevel(nullptr, exitReasonStringId, nullptr, saveStats); TelemetryManager->Flush(); diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp index daa700ae9..98f11f749 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp @@ -42,7 +42,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; @@ -71,7 +71,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; } m_iConfigA = new int[m_iTexturePacksNotInstalled]; @@ -113,14 +113,14 @@ 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 unsigned int dwBytes = 0; unsigned int dwFileBytes = 0; - std::uint8_t* pbData = NULL; - std::uint8_t* pbFileData = NULL; + std::uint8_t* pbData = nullptr; + std::uint8_t* pbFileData = nullptr; CXuiCtrl4JList::LIST_ITEM_INFO ListItem; // get the current index of the list, and then get the data @@ -153,7 +153,7 @@ void IUIScene_StartGame::UpdateTexturePackDescription(int index) { &m_hTexturePackComparisonBrush); m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush); } else { - m_texturePackComparison->UseBrush(NULL); + m_texturePackComparison->UseBrush(nullptr); } #endif } else { @@ -192,7 +192,7 @@ void IUIScene_StartGame::UpdateCurrentTexturePack(int iSlot) { 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 diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.cpp index 002725781..90964fa3d 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.cpp @@ -11,7 +11,7 @@ IUIScene_TradingMenu::IUIScene_TradingMenu() { m_validOffersCount = 0; m_selectedSlot = 0; m_offersStartIndex = 0; - m_menu = NULL; + m_menu = nullptr; m_bHasUpdatedOnce = false; } @@ -28,10 +28,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)) { @@ -70,9 +70,9 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) { player->inventory->countMatches(buyAItem); int buyBMatches = player->inventory->countMatches(buyBItem); - if ((buyAItem != NULL && + if ((buyAItem != nullptr && buyAMatches >= buyAItem->count) && - (buyBItem == NULL || + (buyBItem == nullptr || buyBMatches >= buyBItem->count)) { // 4J-JEV: Fix for PS4 #7111: [PATCH 1.12] Trading // Librarian villagers for multiple �Enchanted @@ -158,7 +158,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(); if (!m_bHasUpdatedOnce) { @@ -176,7 +176,7 @@ void IUIScene_TradingMenu::updateDisplay() { MerchantRecipeList* unfilteredOffers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]); - if (unfilteredOffers != NULL) { + if (unfilteredOffers != nullptr) { m_activeOffers.clear(); int unfilteredIndex = 0; int firstValidTrade = INT_MAX; @@ -255,12 +255,12 @@ void IUIScene_TradingMenu::updateDisplay() { setRequest1Item(buyAItem); setRequest2Item(buyBItem); - if (buyAItem != NULL) + if (buyAItem != nullptr) setRequest1Name(buyAItem->getHoverName()); else setRequest1Name(L""); - if (buyBItem != NULL) + if (buyBItem != nullptr) setRequest2Name(buyBItem->getHoverName()); else setRequest2Name(L""); @@ -283,12 +283,12 @@ void IUIScene_TradingMenu::updateDisplay() { setRequest2RedBox(buyBMatches < buyBItem->count); canMake = canMake && buyBMatches > buyBItem->count; } 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; } } @@ -313,7 +313,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; std::shared_ptr buyAItem = recipe->getBuyAItem(); @@ -325,14 +325,14 @@ bool IUIScene_TradingMenu::canMake(MerchantRecipe* recipe) { if (buyAMatches > 0) { canMake = buyAMatches >= buyAItem->count; } else { - canMake = buyAItem == NULL; + canMake = buyAItem == nullptr; } int buyBMatches = player->inventory->countMatches(buyBItem); if (buyBMatches > 0) { canMake = canMake && buyBMatches >= buyBItem->count; } else { - canMake = canMake && buyBItem == NULL; + canMake = canMake && buyBItem == nullptr; } } return canMake; diff --git a/Minecraft.Client/Platform/Common/UI/UIBitmapFont.cpp b/Minecraft.Client/Platform/Common/UI/UIBitmapFont.cpp index 6a4a639fe..c6e5b9e0f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIBitmapFont.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIBitmapFont.cpp @@ -379,7 +379,7 @@ bitmap->pixel_scale_max = actualScale * glyphScaleMax * 1.001f; */ 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/Platform/Common/UI/UIComponent_Chat.cpp b/Minecraft.Client/Platform/Common/UI/UIComponent_Chat.cpp index 04f16773f..fb15bf2f5 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_Chat.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_Chat.cpp @@ -43,7 +43,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 = std::min( CHAT_LINES_COUNT, // pGui->getMessagesCount(m_iPad) ); diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp b/Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp index 9dfcbc053..035c58958 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp @@ -43,7 +43,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/Platform/Common/UI/UIComponent_Tooltips.cpp b/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.cpp index 3b3f7a743..356f2b9a3 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.cpp @@ -310,7 +310,7 @@ void UIComponent_Tooltips::_Relayout() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcUpdateLayout, 0, NULL); + m_funcUpdateLayout, 0, nullptr); } diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp index 9f24a1357..6ba5e9c97 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp @@ -13,8 +13,8 @@ UIComponent_TutorialPopup::UIComponent_TutorialPopup(int iPad, void* initData, // 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; @@ -27,7 +27,7 @@ UIComponent_TutorialPopup::UIComponent_TutorialPopup(int iPad, void* initData, m_labelDescription.init(L""); // 4jcraft added - m_tutorial = NULL; + m_tutorial = nullptr; } std::wstring UIComponent_TutorialPopup::getMoviePath() { @@ -104,7 +104,7 @@ void UIComponent_TutorialPopup::SetTutorialDescription( void UIComponent_TutorialPopup::RemoveInteractSceneReference(UIScene* scene) { if (m_interactScene == scene) { - m_interactScene = NULL; + m_interactScene = nullptr; } } @@ -152,7 +152,7 @@ void UIComponent_TutorialPopup::_SetDescription(UIScene* interactScene, m_interactScene = interactScene; app.DebugPrintf("Setting m_interactScene to %08x\n", m_interactScene); if (interactScene != m_lastInteractSceneMoved) - m_lastInteractSceneMoved = NULL; + m_lastInteractSceneMoved = nullptr; if (desc.empty()) { SetVisible(false); app.DebugPrintf( @@ -335,8 +335,8 @@ std::wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, 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; } @@ -382,7 +382,7 @@ std::wstring UIComponent_TutorialPopup::ParseDescription(int iPad, } 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 @@ -486,7 +486,7 @@ void UIComponent_TutorialPopup::render(S32 width, S32 height, void UIComponent_TutorialPopup::customDraw( IggyCustomDrawCallbackRegion* region) { - if (m_iconItem != NULL) + if (m_iconItem != nullptr) customDrawSlotControl(region, m_iPad, m_iconItem, 1.0f, m_iconItem->isFoil() || m_iconIsFoil, false); } diff --git a/Minecraft.Client/Platform/Common/UI/UIControl.cpp b/Minecraft.Client/Platform/Common/UI/UIControl.cpp index f915cf574..e45d57bcd 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl.cpp @@ -5,7 +5,7 @@ #include "../../Minecraft.World/Util/JavaMath.h" UIControl::UIControl() { - m_parentScene = NULL; + m_parentScene = nullptr; m_lastOpacity = 1.0f; m_controlName = ""; m_isVisible = true; @@ -37,7 +37,7 @@ bool UIControl::setupControl(UIScene* scene, IggyValuePath* parent, if (m_isValid) { IggyDatatype controlType = IGGY_DATATYPE__invalid_request; IggyResult typeResult = - IggyValueGetTypeRS(getIggyValuePath(), 0, NULL, &controlType); + IggyValueGetTypeRS(getIggyValuePath(), 0, nullptr, &controlType); m_isValid = typeResult == IGGY_RESULT_SUCCESS && controlType != IGGY_DATATYPE__invalid_request && controlType != IGGY_DATATYPE_undefined; @@ -45,10 +45,10 @@ bool UIControl::setupControl(UIScene* scene, IggyValuePath* parent, if (m_isValid) { 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 = (S32)fx; m_y = (S32)fy; @@ -86,7 +86,7 @@ void UIControl::ReInit() { m_funcSetAlpha, 2, value); } - IggyValueSetBooleanRS(getIggyValuePath(), m_nameVisible, NULL, m_isVisible); + IggyValueSetBooleanRS(getIggyValuePath(), m_nameVisible, nullptr, m_isVisible); } IggyValuePath* UIControl::getIggyValuePath() { return &m_iggyPath; } @@ -130,7 +130,7 @@ void UIControl::setVisible(bool visible) { } rrbool succ = IggyValueSetBooleanRS(getIggyValuePath(), m_nameVisible, - NULL, visible); + nullptr, visible); if (succ) m_isVisible = visible; else @@ -144,7 +144,7 @@ bool UIControl::getVisible() { rrbool bVisible = false; IggyResult result = IggyValueGetBooleanRS(getIggyValuePath(), m_nameVisible, - NULL, &bVisible); + nullptr, &bVisible); m_isVisible = bVisible; diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp index 9b5f75e8a..82fc597c3 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp @@ -79,7 +79,7 @@ const wchar_t* UIControl_Base::getLabel() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, - getIggyValuePath(), m_funcGetLabel, 0, NULL); + getIggyValuePath(), m_funcGetLabel, 0, nullptr); if (result.type == IGGY_DATATYPE_string_UTF16) { m_label = u16string_to_wstring(result.string16.string); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.cpp index fbb845b13..889cd8413 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.cpp @@ -48,7 +48,7 @@ void UIControl_ButtonList::clearList() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), - m_removeAllItemsFunc, 0, NULL); + m_removeAllItemsFunc, 0, nullptr); m_itemCount = 0; } diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_CheckBox.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_CheckBox.cpp index 6aff18ebb..8f15cbbb6 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_CheckBox.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_CheckBox.cpp @@ -49,7 +49,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); + IggyValueGetBooleanRS(&m_iggyPath, m_checkedProp, nullptr, &checked); m_bChecked = checked; return checked; } diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_DynamicLabel.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_DynamicLabel.cpp index 99788e345..d65bd9c48 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_DynamicLabel.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_DynamicLabel.cpp @@ -62,7 +62,7 @@ S32 UIControl_DynamicLabel::GetRealWidth() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, - getIggyValuePath(), m_funcGetRealWidth, 0, NULL); + getIggyValuePath(), m_funcGetRealWidth, 0, nullptr); S32 iRealWidth = m_width; if (result.type == IGGY_DATATYPE_number) { @@ -75,7 +75,7 @@ S32 UIControl_DynamicLabel::GetRealHeight() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), - m_funcGetRealHeight, 0, NULL); + m_funcGetRealHeight, 0, nullptr); S32 iRealHeight = m_height; if (result.type == IGGY_DATATYPE_number) { diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentBook.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentBook.cpp index faf8c7fa1..dc6c4540f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentBook.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentBook.cpp @@ -11,7 +11,7 @@ UIControl_EnchantmentBook::UIControl_EnchantmentBook() { UIControl::setControlType(UIControl::eEnchantmentBook); - model = NULL; + model = nullptr; last = nullptr; time = 0; @@ -68,13 +68,13 @@ void UIControl_EnchantmentBook::render(IggyCustomDrawCallbackRegion* region) { 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; } else { model = new BookModel(); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_HTMLLabel.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_HTMLLabel.cpp index 7391db915..8be9c4c49 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_HTMLLabel.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_HTMLLabel.cpp @@ -22,7 +22,7 @@ void UIControl_HTMLLabel::startAutoScroll() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), - m_funcStartAutoScroll, 0, NULL); + m_funcStartAutoScroll, 0, nullptr); } void UIControl_HTMLLabel::ReInit() { @@ -68,7 +68,7 @@ S32 UIControl_HTMLLabel::GetRealWidth() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, - getIggyValuePath(), m_funcGetRealWidth, 0, NULL); + getIggyValuePath(), m_funcGetRealWidth, 0, nullptr); S32 iRealWidth = m_width; if (result.type == IGGY_DATATYPE_number) { @@ -81,7 +81,7 @@ S32 UIControl_HTMLLabel::GetRealHeight() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), - m_funcGetRealHeight, 0, NULL); + m_funcGetRealHeight, 0, nullptr); S32 iRealHeight = m_height; if (result.type == IGGY_DATATYPE_number) { diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_LeaderboardList.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_LeaderboardList.cpp index 029ddab23..273d72452 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_LeaderboardList.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_LeaderboardList.cpp @@ -41,7 +41,7 @@ void UIControl_LeaderboardList::clearList() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), - m_funcResetLeaderboard, 0, NULL); + m_funcResetLeaderboard, 0, nullptr); } void UIControl_LeaderboardList::setupTitles(const std::wstring& rank, diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp index f0b94d8db..8ed1ff9aa 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp +++ b/Minecraft.Client/Platform/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; } @@ -207,7 +207,7 @@ void UIControl_PlayerSkinPreview::render(IggyCustomDrawCallbackRegion* region) { // 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) // std::vector @@ -254,9 +254,9 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer* renderer, double x, HumanoidModel* model = (HumanoidModel*)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 diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Slider.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_Slider.cpp index 6b21ad0c2..b584ca53b 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Slider.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Slider.cpp @@ -82,7 +82,7 @@ S32 UIControl_Slider::GetRealWidth() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, - getIggyValuePath(), m_funcGetRealWidth, 0, NULL); + getIggyValuePath(), m_funcGetRealWidth, 0, nullptr); S32 iRealWidth = m_width; if (result.type == IGGY_DATATYPE_number) { diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_TexturePackList.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_TexturePackList.cpp index 415111a6b..1d1d5e7fb 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_TexturePackList.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_TexturePackList.cpp @@ -79,7 +79,7 @@ void UIControl_TexturePackList::clearSlots() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, - getIggyValuePath(), m_clearSlotsFunc, 0, NULL); + getIggyValuePath(), m_clearSlotsFunc, 0, nullptr); } void UIControl_TexturePackList::setEnabled(bool enable) { @@ -132,7 +132,7 @@ S32 UIControl_TexturePackList::GetRealHeight() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), - m_funcGetRealHeight, 0, NULL); + m_funcGetRealHeight, 0, nullptr); S32 iRealHeight = m_height; if (result.type == IGGY_DATATYPE_number) { diff --git a/Minecraft.Client/Platform/Common/UI/UIController.cpp b/Minecraft.Client/Platform/Common/UI/UIController.cpp index 9f1ea23a3..eb8965823 100644 --- a/Minecraft.Client/Platform/Common/UI/UIController.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIController.cpp @@ -63,12 +63,12 @@ static void RADLINK WarningCallback(void* user_callback_data, Iggy* player, // IGGY_RESULT_Error_UndefinedEntity = 504, // IGGY_RESULT_Error_OutOfMemory = 1001,}; - if (message != NULL) { + if (message != nullptr) { // 4jcraft: Some Linux movie variants do not ship these optional // hooks/controls. We guard the call sites, so drop the residual Iggy // warning noise. - if (strstr(message, "LabelGamertag") != NULL || - strstr(message, "Method SetSafeZone was not a function") != NULL) { + if (strstr(message, "LabelGamertag") != nullptr || + strstr(message, "Method SetSafeZone was not a function") != nullptr) { return; } } @@ -158,15 +158,15 @@ static void RADLINK DeallocateFunction(void* alloc_callback_user_data, } 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. @@ -282,7 +282,7 @@ void UIController::postInit() { #if defined(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?"); @@ -293,7 +293,7 @@ void UIController::postInit() { #if defined(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 @@ -330,7 +330,7 @@ UITTFFont* UIController::createFont(EFont fontLanguage) { // 4J-JEV, Cyrillic characters have been added to this font now, // (4/July/14) XC_LANGUAGE_RUSSIAN and XC_LANGUAGE_GREEK: default: - return NULL; + return nullptr; } } @@ -364,15 +364,15 @@ void UIController::SetupFont() { 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) + 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 @@ -544,7 +544,7 @@ IggyLibrary UIController::loadSkin(const std::wstring& skinPath, const std::u16string convSkinName = wstring_to_u16string(skinName); lib = IggyLibraryCreateFromMemoryUTF16( - convSkinName.data(), (void*)baFile.data, baFile.length, NULL); + convSkinName.data(), (void*)baFile.data, baFile.length, nullptr); delete[] baFile.data; #if defined(_DEBUG) @@ -552,7 +552,7 @@ IggyLibrary UIController::loadSkin(const std::wstring& skinPath, rrbool res; int iteration = 0; int64_t totalStatic = 0; - while ((res = IggyDebugGetMemoryUseInfo(NULL, lib, "", 0, iteration, + while ((res = IggyDebugGetMemoryUseInfo(nullptr, lib, "", 0, iteration, &memoryInfo))) { totalStatic += memoryInfo.static_allocation_bytes; app.DebugPrintf( @@ -658,7 +658,7 @@ bool UIController::IsExpectingOrReloadingSkin() { void UIController::CleanUpSkinReload() { delete m_reloadSkinThread; - m_reloadSkinThread = NULL; + m_reloadSkinThread = nullptr; if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { if (!Minecraft::GetInstance()->skins->getSelected()->hasAudio()) { @@ -791,7 +791,7 @@ UIController::ExternalFunctionCallback(void* user_callback_data, Iggy* player, IggyExternalFunctionCallUTF16* call) { UIScene* scene = (UIScene*)IggyPlayerGetUserdata(player); - if (scene != NULL) { + if (scene != nullptr) { scene->externalCallback(call); } @@ -1009,7 +1009,7 @@ void UIController::setupCustomDrawMatrices(UIScene* scene, if (!m_bScreenWidthSetup) { Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft != NULL) { + if (pMinecraft != nullptr) { m_fScreenWidth = (float)pMinecraft->width_phys; m_fScreenHeight = (float)pMinecraft->height_phys; m_bScreenWidthSetup = true; @@ -1061,7 +1061,7 @@ UIController::CustomDrawCallback(void* user_callback_data, Iggy* player, IggyCustomDrawCallbackRegion* region) { UIScene* scene = (UIScene*)IggyPlayerGetUserdata(player); - if (scene != NULL) { + if (scene != nullptr) { scene->customDraw(region); } } @@ -1082,7 +1082,7 @@ UIController::CustomDrawCallback(void* user_callback_data, Iggy* player, // 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 +// texture handle provided by GDraw, or nullptr (nullptr with throw an ActionScript 3 // ArgumentError that the Flash developer can catch) Use by calling // IggySetTextureSubstitutionCallbacks. // @@ -1103,7 +1103,7 @@ GDrawTexture* RADLINK UIController::TextureSubstitutionCreateCallback( (wchar_t*)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; int id = t->getTexture(&image, C4JRender::TEXTURE_FORMAT_RxGyBzAw, @@ -1122,12 +1122,12 @@ GDrawTexture* RADLINK UIController::TextureSubstitutionCreateCallback( image.getHeight()); return ui.getSubstitutionTexture(id); } else { - return NULL; + return nullptr; } } else { app.DebugPrintf("Could not find substitution texture %ls\n", (wchar_t*)texture_name); - return NULL; + return nullptr; } } @@ -1318,7 +1318,7 @@ void UIController::NavigateToHomeMenu() { // 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()) { // get the dlc texture pack, and store it pDLCTexPack = (DLCTexturePack*)pTexPack; @@ -1337,11 +1337,11 @@ void UIController::NavigateToHomeMenu() { eStream_Nether4, eStream_end_dragon, eStream_end_end, 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(); // } @@ -1401,7 +1401,7 @@ void UIController::UnregisterCallbackId(size_t id) { } UIScene* UIController::GetSceneFromCallbackId(size_t id) { - UIScene* scene = NULL; + UIScene* scene = nullptr; AUTO_VAR(it, m_registeredCallbackScenes.find(id)); if (it != m_registeredCallbackScenes.end()) { scene = it->second; @@ -1837,7 +1837,7 @@ void UIController::HandleInventoryUpdated(int iPad) { group = (EUIGroup)(iPad + 1); } - m_groups[group]->HandleMessage(eUIMessage_InventoryUpdated, NULL); + m_groups[group]->HandleMessage(eUIMessage_InventoryUpdated, nullptr); } void UIController::HandleGameTick() { @@ -1934,7 +1934,7 @@ void UIController::UpdatePlayerBasePositions() { Minecraft* pMinecraft = Minecraft::GetInstance(); for (int 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) { DisplayGamertag(idx, false); @@ -2019,7 +2019,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); } @@ -2091,7 +2091,7 @@ void UIController::ShowUIDebugConsole(bool show) { } else { m_groups[eUIGroup_Fullscreen]->removeComponent( eUIComponent_DebugUIConsole, eUILayer_Debug); - m_uiDebugConsole = NULL; + m_uiDebugConsole = nullptr; } #endif } @@ -2107,7 +2107,7 @@ void UIController::ShowUIDebugMarketingGuide(bool show) { } else { m_groups[eUIGroup_Fullscreen]->removeComponent( eUIComponent_DebugUIMarketingGuide, eUILayer_Debug); - m_uiDebugMarketingGuide = NULL; + m_uiDebugMarketingGuide = nullptr; } #endif } @@ -2206,8 +2206,8 @@ C4JStorage::EMessageResult UIController::RequestMessageBox( C4JStorage::EMessageResult UIController::RequestUGCMessageBox( int title /* = -1 */, int message /* = -1 */, int iPad /* = -1*/, - int (*Func)(void*, int, const C4JStorage::EMessageResult) /* = NULL*/, - void* lpParam /* = NULL*/) { + int (*Func)(void*, int, const C4JStorage::EMessageResult) /* = nullptr*/, + void* lpParam /* = nullptr*/) { // Default title / messages if (title == -1) { title = IDS_FAILED_TO_CREATE_GAME_TITLE; @@ -2228,8 +2228,8 @@ C4JStorage::EMessageResult UIController::RequestUGCMessageBox( C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox( int title /* = -1 */, int message /* = -1 */, int iPad /* = -1*/, - int (*Func)(void*, int, const C4JStorage::EMessageResult) /* = NULL*/, - void* lpParam /* = NULL*/) { + int (*Func)(void*, int, const C4JStorage::EMessageResult) /* = nullptr*/, + void* lpParam /* = nullptr*/) { // Default title / messages if (title == -1) { title = IDS_FAILED_TO_CREATE_GAME_TITLE; @@ -2255,7 +2255,7 @@ C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox( 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 @@ -2268,9 +2268,9 @@ 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) + if (m_defaultBuffer == nullptr) m_defaultBuffer = new char[CHAR_SIZE * 5000]; IggySetFontCachingCalculationBuffer(5000, m_defaultBuffer, CHAR_SIZE * 5000); @@ -2281,9 +2281,9 @@ 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); diff --git a/Minecraft.Client/Platform/Common/UI/UIController.h b/Minecraft.Client/Platform/Common/UI/UIController.h index 218204bc3..b49f6ed5f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIController.h +++ b/Minecraft.Client/Platform/Common/UI/UIController.h @@ -283,7 +283,7 @@ protected: 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) {} @@ -296,7 +296,7 @@ public: public: // NAVIGATION - bool NavigateToScene(int iPad, EUIScene scene, void* initData = NULL, + bool NavigateToScene(int iPad, EUIScene scene, void* initData = nullptr, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD); bool NavigateBack(int iPad, bool forceUsePad = false, @@ -390,13 +390,13 @@ public: 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); + 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) = NULL, - LPVOID lpParam = NULL, WCHAR* pwchFormatString = NULL); + int (*Func)(LPVOID, int, const C4JStorage::EMessageResult) = nullptr, + LPVOID lpParam = nullptr, WCHAR* pwchFormatString = nullptr); private: virtual C4JStorage::EMessageResult RequestMessageBox( @@ -408,12 +408,12 @@ private: public: C4JStorage::EMessageResult RequestUGCMessageBox( int title = -1, int message = -1, int iPad = -1, - int (*Func)(void*, int, const C4JStorage::EMessageResult) = NULL, - void* lpParam = NULL); + int (*Func)(void*, int, const C4JStorage::EMessageResult) = nullptr, + void* lpParam = nullptr); C4JStorage::EMessageResult RequestContentRestrictedMessageBox( int title = -1, int message = -1, int iPad = -1, - int (*Func)(void*, int, const C4JStorage::EMessageResult) = NULL, - void* lpParam = NULL); + int (*Func)(void*, int, const C4JStorage::EMessageResult) = nullptr, + void* lpParam = nullptr); virtual void SetWinUserIndex(unsigned int iPad); unsigned int GetWinUserIndex(); diff --git a/Minecraft.Client/Platform/Common/UI/UIFontData.cpp b/Minecraft.Client/Platform/Common/UI/UIFontData.cpp index 85f96687e..51dee10e7 100644 --- a/Minecraft.Client/Platform/Common/UI/UIFontData.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIFontData.cpp @@ -649,9 +649,9 @@ unsigned short SFontData::Codepoints[FONTSIZE] = { CFontData::CFontData() { m_unicodeMap = std::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/Platform/Common/UI/UIGroup.cpp b/Minecraft.Client/Platform/Common/UI/UIGroup.cpp index a9c0d3316..cf9bf1656 100644 --- a/Minecraft.Client/Platform/Common/UI/UIGroup.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIGroup.cpp @@ -23,9 +23,9 @@ UIGroup::UIGroup(EUIGroup group, int iPad) { (UIComponent_Tooltips*)m_layers[(int)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[(int)eUILayer_Popup] @@ -141,7 +141,7 @@ bool UIGroup::NavigateBack(int iPad, EUIScene eScene, EUILayer eLayer) { 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 = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; @@ -339,9 +339,9 @@ void UIGroup::PrintTotalMemoryUsage(int64_t& totalStatic, 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); diff --git a/Minecraft.Client/Platform/Common/UI/UILayer.cpp b/Minecraft.Client/Platform/Common/UI/UILayer.cpp index 204852864..0e6ef12f0 100644 --- a/Minecraft.Client/Platform/Common/UI/UILayer.cpp +++ b/Minecraft.Client/Platform/Common/UI/UILayer.cpp @@ -170,7 +170,7 @@ void UILayer::ReloadAll(bool force) { bool UILayer::GetMenuDisplayed() { return m_bMenuDisplayed; } bool UILayer::NavigateToScene(int iPad, EUIScene scene, void* initData) { - UIScene* newScene = NULL; + UIScene* newScene = nullptr; switch (scene) { // Debug #if defined(_DEBUG_MENUS_ENABLED) @@ -383,7 +383,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", @@ -409,7 +409,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(); if (scene->getSceneType() == eScene) { @@ -465,9 +465,9 @@ UIScene* UILayer::addComponent(int iPad, EUIScene scene, void* initData) { return *itComp; } } - return NULL; + return nullptr; } - UIScene* newScene = NULL; + UIScene* newScene = nullptr; switch (scene) { case eUIComponent_Panorama: @@ -517,7 +517,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); @@ -586,10 +586,10 @@ 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 { return m_sceneStack[m_sceneStack.size() - 1]; } @@ -769,7 +769,7 @@ void UILayer::PrintTotalMemoryUsage(int64_t& totalStatic, 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++) { if (m_sceneStack[i]->getSceneType() == sceneType) { @@ -777,5 +777,5 @@ UIScene* UILayer::FindScene(EUIScene sceneType) { } } - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UILayer.h b/Minecraft.Client/Platform/Common/UI/UILayer.h index 4be635713..daeef7c87 100644 --- a/Minecraft.Client/Platform/Common/UI/UILayer.h +++ b/Minecraft.Client/Platform/Common/UI/UILayer.h @@ -62,7 +62,7 @@ public: // 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/Platform/Common/UI/UIScene.cpp b/Minecraft.Client/Platform/Common/UI/UIScene.cpp index 5173bb516..833a16933 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene.cpp @@ -10,8 +10,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; @@ -47,13 +47,13 @@ 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; m_hasSetSafeZoneMethod = false; // Clear out the controls collection (doesn't delete the controls, and they @@ -113,7 +113,7 @@ void UIScene::reloadMovie(bool force) { bool UIScene::needsReloaded() { return !swf && (!stealsFocus() || bHasFocus); } -bool UIScene::hasMovie() { return swf != NULL; } +bool UIScene::hasMovie() { return swf != nullptr; } F64 UIScene::getSafeZoneHalfHeight() { float height = ui.getScreenHeight(); @@ -238,7 +238,7 @@ bool UIScene::mapElementsAndNames() { IggyDatatype safeZoneType = IGGY_DATATYPE__invalid_request; IggyResult safeZoneResult = IggyValueGetTypeRS( - m_rootPath, m_funcSetSafeZone, NULL, &safeZoneType); + m_rootPath, m_funcSetSafeZone, nullptr, &safeZoneType); m_hasSetSafeZoneMethod = safeZoneResult == IGGY_RESULT_SUCCESS && safeZoneType == IGGY_DATATYPE_function; @@ -293,7 +293,7 @@ void UIScene::loadMovie() { byteArray baFile = ui.getMovieData(moviePath.c_str()); int64_t beforeLoad = ui.iggyAllocCount; - swf = IggyPlayerCreateFromMemory(baFile.data, baFile.length, NULL); + swf = IggyPlayerCreateFromMemory(baFile.data, baFile.length, nullptr); int64_t afterLoad = ui.iggyAllocCount; IggyPlayerInitializeAndTickRS(swf); int64_t afterTick = ui.iggyAllocCount; @@ -385,7 +385,7 @@ void UIScene::tick() { } } -UIControl* UIScene::GetMainPanel() { return NULL; } +UIControl* UIScene::GetMainPanel() { return nullptr; } void UIScene::addTimer(int id, int ms) { int currentTime = System::currentTimeMillis(); @@ -459,21 +459,21 @@ void UIScene::slideLeft() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcSlideLeft, 0, NULL); + m_funcSlideLeft, 0, nullptr); } void UIScene::slideRight() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcSlideRight, 0, NULL); + m_funcSlideRight, 0, nullptr); } void UIScene::doHorizontalResizeCheck() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS( getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcHorizontalResizeCheck, 0, NULL); + m_funcHorizontalResizeCheck, 0, nullptr); } void UIScene::render(S32 width, S32 height, C4JRender::eViewportType viewport) { @@ -514,7 +514,7 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region, std::shared_ptr item, float fAlpha, bool isFoil, bool bDecorations) { - if (item != NULL) { + if (item != nullptr) { if (m_cacheSlotRenders) { if ((m_cachedSlotDraw.size() + 1) == m_expectedCachedSlotCount) { // Make sure that pMinecraft->player is the correct player so @@ -663,7 +663,7 @@ void UIScene::_customDrawSlotControl(CustomDrawData* region, int iPad, } PIXBeginNamedEvent(0, "Render and decorate"); - if (m_pItemRenderer == NULL) m_pItemRenderer = new ItemRenderer(); + if (m_pItemRenderer == nullptr) m_pItemRenderer = new ItemRenderer(); m_pItemRenderer->renderAndDecorateItem( pMinecraft->font, pMinecraft->textures, item, x, y, scaleX, scaleY, fAlpha, isFoil, false, !usingCommandBuffer); @@ -701,10 +701,10 @@ void UIScene::_customDrawSlotControl(CustomDrawData* region, int iPad, // 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"); #ifndef _CONTENT_PACKAGE +// it's parent layer is nullptr!\n"); #ifndef _CONTENT_PACKAGE // __debugbreak(); // #endif // } @@ -720,9 +720,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"); +// parent layer is nullptr!\n"); #if !defined(_CONTENT_PACKAGE) // __debugbreak(); #endif diff --git a/Minecraft.Client/Platform/Common/UI/UIScene.h b/Minecraft.Client/Platform/Common/UI/UIScene.h index f52d73ac4..70a05840e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene.h @@ -255,7 +255,7 @@ public: // 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/Platform/Common/UI/UIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.cpp index 79abdad25..eb4a3dd08 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.cpp @@ -34,10 +34,10 @@ UIScene_AbstractContainerMenu::~UIScene_AbstractContainerMenu() { void UIScene_AbstractContainerMenu::handleDestroy() { app.DebugPrintf("UIScene_AbstractContainerMenu::handleDestroy\n"); Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[m_iPad] != NULL) { + if (pMinecraft->localgameModes[m_iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; - if (gameMode != NULL) + if (gameMode != nullptr) gameMode->getTutorial()->changeTutorialState( m_previousTutorialState); } @@ -47,7 +47,7 @@ void UIScene_AbstractContainerMenu::handleDestroy() { // 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 && + if (pMinecraft->localplayers[m_iPad] != nullptr && pMinecraft->localplayers[m_iPad]->containerMenu->containerId == m_menu->containerId) { pMinecraft->localplayers[m_iPad]->closeContainer(); @@ -119,8 +119,8 @@ void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, 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; @@ -201,8 +201,8 @@ void UIScene_AbstractContainerMenu::render(S32 width, S32 height, void UIScene_AbstractContainerMenu::customDraw( IggyCustomDrawCallbackRegion* region) { 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; int slotId = parseSlotId(region->name); @@ -221,7 +221,7 @@ void UIScene_AbstractContainerMenu::customDraw( } } - if (item != NULL) + if (item != nullptr) customDrawSlotControl( region, m_iPad, item, m_menu->isValidIngredient(item, slotId) ? 1.0f : 0.5f, @@ -288,7 +288,7 @@ Slot* UIScene_AbstractContainerMenu::getSlot(ESceneSection eSection, if (slot) return slot; else - return NULL; + return nullptr; } bool UIScene_AbstractContainerMenu::isSlotEmpty(ESceneSection eSection, diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.h index 5dd27f54c..6af568230 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.h @@ -56,7 +56,7 @@ protected: 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/Platform/Common/UI/UIScene_AnvilMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp index bc8cfaa79..e4dfa177f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp @@ -22,7 +22,7 @@ UIScene_AnvilMenu::UIScene_AnvilMenu(int iPad, void* _initData, m_inventory = initData->inventory; Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[iPad] != NULL) { + if (pMinecraft->localgameModes[iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -239,7 +239,7 @@ void UIScene_AnvilMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionAnvilItem1: slotList = &m_slotListItem1; @@ -265,7 +265,7 @@ void UIScene_AnvilMenu::setSectionSelectedSlot(ESceneSection eSection, int x, } UIControl* UIScene_AnvilMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionAnvilItem1: control = &m_slotListItem1; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp index 7ef5b3768..6ffe67f7c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp @@ -25,7 +25,7 @@ UIScene_BeaconMenu::UIScene_BeaconMenu(int iPad, void* _initData, BeaconScreenInput* initData = (BeaconScreenInput*)_initData; Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[initData->iPad] != NULL) { + if (pMinecraft->localgameModes[initData->iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -244,7 +244,7 @@ void UIScene_BeaconMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionBeaconItem: slotList = &m_slotListActivator; @@ -264,7 +264,7 @@ void UIScene_BeaconMenu::setSectionSelectedSlot(ESceneSection eSection, int x, } UIControl* UIScene_BeaconMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionBeaconItem: control = &m_slotListActivator; @@ -310,8 +310,8 @@ 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) + if (pMinecraft->localplayers[m_iPad] == nullptr || + pMinecraft->localgameModes[m_iPad] == nullptr) return; std::shared_ptr item = nullptr; @@ -340,7 +340,7 @@ void UIScene_BeaconMenu::customDraw(IggyCustomDrawCallbackRegion* region) { assert(false); break; }; - if (item != NULL) + if (item != nullptr) customDrawSlotControl(region, m_iPad, item, 1.0f, item->isFoil(), true); } else { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_BrewingStandMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_BrewingStandMenu.cpp index 5e2f80728..58c7f32c9 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_BrewingStandMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_BrewingStandMenu.cpp @@ -24,7 +24,7 @@ UIScene_BrewingStandMenu::UIScene_BrewingStandMenu(int iPad, void* _initData, m_labelBrewingStand.init(m_brewingStand->getName()); Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[initData->iPad] != NULL) { + if (pMinecraft->localgameModes[initData->iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -246,7 +246,7 @@ void UIScene_BrewingStandMenu::setSectionSelectedSlot(ESceneSection eSection, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionBrewingBottle1: slotList = &m_slotListBottles[0]; @@ -275,7 +275,7 @@ void UIScene_BrewingStandMenu::setSectionSelectedSlot(ESceneSection eSection, } UIControl* UIScene_BrewingStandMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionBrewingBottle1: control = &m_slotListBottles[0]; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp index 2acf72e7d..dd5417a56 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp @@ -173,7 +173,7 @@ void UIScene_ConnectingProgress::handleInput(int iPad, int key, bool repeat, // 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/Platform/Common/UI/UIScene_ContainerMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_ContainerMenu.cpp index ae5a7effb..24d866e0e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ContainerMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ContainerMenu.cpp @@ -27,7 +27,7 @@ UIScene_ContainerMenu::UIScene_ContainerMenu(int iPad, void* _initData, new ContainerMenu(initData->inventory, initData->container); Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[iPad] != NULL) { + if (pMinecraft->localgameModes[iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -172,7 +172,7 @@ void UIScene_ContainerMenu::setSectionSelectedSlot(ESceneSection eSection, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionContainerChest: slotList = &m_slotListContainer; @@ -192,7 +192,7 @@ void UIScene_ContainerMenu::setSectionSelectedSlot(ESceneSection eSection, } UIControl* UIScene_ContainerMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionContainerChest: control = &m_slotListContainer; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp index 7fb7e28a6..586d1daef 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp @@ -20,7 +20,7 @@ UIScene_ControlsMenu::UIScene_ControlsMenu(int iPad, void* initData, IggyPlayerRootPath(getMovie()), m_funcSetPlatform, 1, value); - bool bNotInGame = (Minecraft::GetInstance()->level == NULL); + bool bNotInGame = (Minecraft::GetInstance()->level == nullptr); if (bNotInGame) { LPWSTR layoutString = new wchar_t[128]; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp index 3f493b6b8..7b8600110 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp @@ -104,7 +104,7 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void* _initData, // Update the tutorial state Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[m_iPad] != NULL) { + if (pMinecraft->localgameModes[m_iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -176,10 +176,10 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void* _initData, void UIScene_CraftingMenu::handleDestroy() { Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[m_iPad] != NULL) { + if (pMinecraft->localgameModes[m_iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; - if (gameMode != NULL) + if (gameMode != nullptr) gameMode->getTutorial()->changeTutorialState( m_previousTutorialState); } @@ -187,7 +187,7 @@ void UIScene_CraftingMenu::handleDestroy() { // 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 && + if (Minecraft::GetInstance()->localplayers[m_iPad] != nullptr && Minecraft::GetInstance() ->localplayers[m_iPad] ->containerMenu->containerId == m_menu->containerId) { @@ -287,8 +287,8 @@ 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) + if (pMinecraft->localplayers[m_iPad] == nullptr || + pMinecraft->localgameModes[m_iPad] == nullptr) return; std::shared_ptr item = nullptr; @@ -351,7 +351,7 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion* region) { } } - if (item != NULL) { + if (item != nullptr) { if (!inventoryItem) { if (item->id == Item::clock_Id || item->id == Item::compass_Id) { // 4J Stu - For clocks and compasses we set the aux value to a @@ -458,7 +458,7 @@ void UIScene_CraftingMenu::setCraftingOutputSlotItem( int iPad, std::shared_ptr item) { m_craftingOutputSlotInfo.item = item; m_craftingOutputSlotInfo.alpha = 31; - m_craftingOutputSlotInfo.show = item != NULL; + m_craftingOutputSlotInfo.show = item != nullptr; } void UIScene_CraftingMenu::setCraftingOutputSlotRedBox(bool show) { @@ -469,7 +469,7 @@ void UIScene_CraftingMenu::setIngredientSlotItem( int iPad, int index, std::shared_ptr item) { m_ingredientsSlotsInfo[index].item = item; m_ingredientsSlotsInfo[index].alpha = 31; - m_ingredientsSlotsInfo[index].show = item != NULL; + m_ingredientsSlotsInfo[index].show = item != nullptr; } void UIScene_CraftingMenu::setIngredientSlotRedBox(int index, bool show) { @@ -480,7 +480,7 @@ void UIScene_CraftingMenu::setIngredientDescriptionItem( int iPad, int index, std::shared_ptr item) { m_ingredientsInfo[index].item = item; m_ingredientsInfo[index].alpha = 31; - m_ingredientsInfo[index].show = item != NULL; + m_ingredientsInfo[index].show = item != nullptr; IggyDataValue result; IggyDataValue value[2]; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp index dc232054c..a4633245a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp @@ -83,7 +83,7 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void* initData, m_bGameModeCreative = false; m_iGameModeId = GameType::SURVIVAL->getId(); - m_pDLCPack = NULL; + m_pDLCPack = nullptr; m_bRebuildTouchBoxes = false; m_bMultiplayerAllowed = ProfileManager.IsSignedInLive(m_iPad) && @@ -101,7 +101,7 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void* initData, // setting in the More Options #ifdef 0 // if(ProfileManager.IsSignedInLive( m_iPad )) // { - // ProfileManager.GetChatAndContentRestrictions(m_iPad,true,&bChatRestricted,&bContentRestricted,NULL); + // ProfileManager.GetChatAndContentRestrictions(m_iPad,true,&bChatRestricted,&bContentRestricted,nullptr); // } // #endif @@ -183,7 +183,7 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void* initData, // 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; @@ -379,7 +379,7 @@ void UIScene_CreateWorldMenu::StartSharedLaunchFlow() { 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 // upsell @@ -749,7 +749,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, } param->seed = seedValue; - param->saveData = NULL; + param->saveData = nullptr; param->texturePackId = pClass->m_MoreOptionsParams.dwTexturePack; Minecraft* pMinecraft = Minecraft::GetInstance(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.cpp index 449a27945..652d67a28 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.cpp @@ -42,7 +42,7 @@ UIScene_CreativeMenu::UIScene_CreativeMenu(int iPad, void* _initData, } Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[initData->iPad] != NULL) { + if (pMinecraft->localgameModes[initData->iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -335,7 +335,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: slotList = &m_slotListContainer; @@ -352,7 +352,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: control = &m_slotListContainer; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_Credits.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_Credits.cpp index dff150ff5..13435ea97 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_Credits.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_Credits.cpp @@ -215,7 +215,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 + 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/Platform/Common/UI/UIScene_DLCOffersMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp index 0ccc9baa2..ed92c137b 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp @@ -181,7 +181,7 @@ void UIScene_DLCOffersMenu::handlePress(F64 controlId, F64 childId) { uint64_t ullIndexA[1]; ullIndexA[0] = StorageManager.GetOffer(iIndex).qwOfferID; - StorageManager.InstallOffer(1, ullIndexA, NULL, NULL); + StorageManager.InstallOffer(1, ullIndexA, nullptr, nullptr); } break; } } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DeathMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DeathMenu.cpp index c5668671c..da44baba2 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DeathMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DeathMenu.cpp @@ -19,7 +19,7 @@ UIScene_DeathMenu::UIScene_DeathMenu(int iPad, void* initData, m_bIgnoreInput = false; Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL) { + if (pMinecraft != nullptr && pMinecraft->localgameModes[iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[iPad]; @@ -30,7 +30,7 @@ UIScene_DeathMenu::UIScene_DeathMenu(int iPad, void* initData, 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 = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; @@ -88,7 +88,7 @@ void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) { if (m_iPad == ProfileManager.GetPrimaryPad()) { unsigned int uiIDA[3]; int playTime = -1; - if (pMinecraft->localplayers[m_iPad] != NULL) { + if (pMinecraft->localplayers[m_iPad] != nullptr) { playTime = (int)pMinecraft->localplayers[m_iPad] ->getSessionTimer(); } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp index 3aa2d2619..a72291a74 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp @@ -48,7 +48,7 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void* initData, int listId = 0; for (unsigned int i = 0; i < Item::items.length; ++i) { - if (Item::items[i] != NULL) { + if (Item::items[i] != nullptr) { m_itemIds.push_back(i); m_buttonListItems.addItem( app.GetString(Item::items[i]->getDescriptionId()), listId); @@ -120,20 +120,20 @@ std::wstring UIScene_DebugOverlay::getMoviePath() { return L"DebugMenu"; } void UIScene_DebugOverlay::customDraw(IggyCustomDrawCallbackRegion* region) { 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; int itemId = -1; // 4jcraft TODO: UB on our platform since this casts char16_t* to wchar_t* swscanf((wchar_t*)region->name, L"item_%d", &itemId); if (itemId == -1 || itemId > Item::ITEM_NUM_COUNT || - Item::items[itemId] == NULL) { + Item::items[itemId] == nullptr) { app.DebugPrintf("This is not the control we are looking for\n"); } else { std::shared_ptr item = std::shared_ptr(new ItemInstance(itemId, 1, 0)); - if (item != NULL) + if (item != nullptr) customDrawSlotControl(region, m_iPad, item, 1.0f, false, false); } } @@ -202,14 +202,14 @@ void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId) { case eControl_Schematic: { #ifndef _CONTENT_PACKAGE ui.NavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_DebugCreateSchematic, NULL, + eUIScene_DebugCreateSchematic, nullptr, eUILayer_Debug); #endif } break; case eControl_SetCamera: { #ifndef _CONTENT_PACKAGE ui.NavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_DebugSetCamera, NULL, eUILayer_Debug); + eUIScene_DebugSetCamera, nullptr, eUILayer_Debug); #endif } break; case eControl_Rain: { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp index 74787f726..12f1b689f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp @@ -18,7 +18,7 @@ UIScene_DebugSetCamera::UIScene_DebugSetCamera(int iPad, void* initData, currentPosition->player = playerNo; Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft != NULL) { + if (pMinecraft != nullptr) { Vec3 vec = pMinecraft->localplayers[playerNo]->getPos(1.0); currentPosition->m_camX = vec.x; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DispenserMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DispenserMenu.cpp index b295d5cfe..00bec865d 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DispenserMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DispenserMenu.cpp @@ -16,7 +16,7 @@ UIScene_DispenserMenu::UIScene_DispenserMenu(int iPad, void* _initData, m_labelDispenser.init(initData->trap->getName()); Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[initData->iPad] != NULL) { + if (pMinecraft->localgameModes[initData->iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -151,7 +151,7 @@ void UIScene_DispenserMenu::setSectionSelectedSlot(ESceneSection eSection, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionTrapTrap: slotList = &m_slotListTrap; @@ -170,7 +170,7 @@ void UIScene_DispenserMenu::setSectionSelectedSlot(ESceneSection eSection, } UIControl* UIScene_DispenserMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionTrapTrap: control = &m_slotListTrap; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_EnchantingMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_EnchantingMenu.cpp index a04cc003b..1582d2965 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_EnchantingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_EnchantingMenu.cpp @@ -22,7 +22,7 @@ UIScene_EnchantingMenu::UIScene_EnchantingMenu(int iPad, void* _initData, : initData->name); Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[initData->iPad] != NULL) { + if (pMinecraft->localgameModes[initData->iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -190,7 +190,7 @@ void UIScene_EnchantingMenu::setSectionSelectedSlot(ESceneSection eSection, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionEnchantSlot: slotList = &m_slotListIngredient; @@ -210,7 +210,7 @@ void UIScene_EnchantingMenu::setSectionSelectedSlot(ESceneSection eSection, } UIControl* UIScene_EnchantingMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionEnchantSlot: control = &m_slotListIngredient; @@ -239,8 +239,8 @@ 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) + if (pMinecraft->localplayers[m_iPad] == nullptr || + pMinecraft->localgameModes[m_iPad] == nullptr) return; if (std::char_traits::compare(region->name, u"EnchantmentBook", diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_EndPoem.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_EndPoem.cpp index 16e547d48..0a10ec554 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_EndPoem.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_EndPoem.cpp @@ -38,7 +38,7 @@ UIScene_EndPoem::UIScene_EndPoem(int iPad, void* initData, UILayer* parentLayer) Minecraft* pMinecraft = Minecraft::GetInstance(); std::wstring playerName = L""; - if (pMinecraft->localplayers[ui.GetWinUserIndex()] != NULL) { + if (pMinecraft->localplayers[ui.GetWinUserIndex()] != nullptr) { playerName = escapeXML( pMinecraft->localplayers[ui.GetWinUserIndex()]->getDisplayName()); } else { @@ -142,7 +142,7 @@ void UIScene_EndPoem::handleInput(int iPad, int key, bool repeat, bool pressed, m_bIgnoreInput = true; 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); } } @@ -150,7 +150,7 @@ void UIScene_EndPoem::handleInput(int iPad, int key, bool repeat, bool pressed, // This just allows it to be shown if (pMinecraft ->localgameModes[ProfileManager.GetPrimaryPad()] != - NULL) + nullptr) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] ->getTutorial() ->showTutorialPopup(true); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.cpp index 644a216c9..958ed53b1 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.cpp @@ -17,7 +17,7 @@ UIScene_FireworksMenu::UIScene_FireworksMenu(int iPad, void* _initData, 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 = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -171,7 +171,7 @@ void UIScene_FireworksMenu::setSectionSelectedSlot(ESceneSection eSection, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionFireworksIngredients: slotList = &m_slotList3x3; @@ -193,7 +193,7 @@ void UIScene_FireworksMenu::setSectionSelectedSlot(ESceneSection eSection, } UIControl* UIScene_FireworksMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionFireworksIngredients: control = &m_slotList3x3; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp index dd36a0bec..f63603d6e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp @@ -99,7 +99,7 @@ void UIScene_FullscreenProgress::handleDestroy() { // 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); } @@ -216,7 +216,7 @@ void UIScene_FullscreenProgress::tick() { // This just allows it to be shown Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft->localgameModes - [ProfileManager.GetPrimaryPad()] != NULL) + [ProfileManager.GetPrimaryPad()] != nullptr) pMinecraft ->localgameModes[ProfileManager .GetPrimaryPad()] @@ -284,7 +284,7 @@ void UIScene_FullscreenProgress::handleInput(int iPad, int key, bool repeat, 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/Platform/Common/UI/UIScene_FurnaceMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_FurnaceMenu.cpp index 51b1a272c..f75c21615 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_FurnaceMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_FurnaceMenu.cpp @@ -22,7 +22,7 @@ UIScene_FurnaceMenu::UIScene_FurnaceMenu(int iPad, void* _initData, 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 = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -195,7 +195,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: slotList = &m_slotListResult; @@ -221,7 +221,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: control = &m_slotListResult; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HUD.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HUD.cpp index 19febdda2..aa5cd94a6 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HUD.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HUD.cpp @@ -109,8 +109,8 @@ void UIScene_HUD::tick() { UIScene::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; } @@ -142,8 +142,8 @@ 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) + if (pMinecraft->localplayers[m_iPad] == nullptr || + pMinecraft->localgameModes[m_iPad] == nullptr) return; int slot = parseSlotId(region->name); @@ -154,7 +154,7 @@ void UIScene_HUD::customDraw(IggyCustomDrawCallbackRegion* region) { pMinecraft->localplayers[m_iPad]->inventoryMenu->getSlot( InventoryMenu::USE_ROW_SLOT_START + slot); std::shared_ptr item = invSlot->getItem(); - if (item != NULL) { + if (item != nullptr) { unsigned char ucAlpha = app.GetGameSettings( ProfileManager.GetPrimaryPad(), eGameSetting_InterfaceOpacity); float fVal; @@ -235,7 +235,7 @@ void UIScene_HUD::handleReload() { int iGuiScale; Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localplayers[m_iPad] == NULL || + if (pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localplayers[m_iPad]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN) { iGuiScale = app.GetGameSettings(m_iPad, eGameSetting_UISize); @@ -580,7 +580,7 @@ void UIScene_HUD::HideSelectedLabel() { IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcHideSelectedLabel, 0, NULL); + m_funcHideSelectedLabel, 0, nullptr); } void UIScene_HUD::SetRidingHorse(bool ridingHorse, bool bIsJumpable, @@ -724,7 +724,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 = std::min( CHAT_LINES_COUNT, // pGui->getMessagesCount(m_iPad) ); @@ -835,8 +835,8 @@ void UIScene_HUD::SetTooltipsEnabled(bool bEnabled) { 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/Platform/Common/UI/UIScene_HelpAndOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HelpAndOptionsMenu.cpp index ce63aa6ca..35559b817 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HelpAndOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HelpAndOptionsMenu.cpp @@ -9,7 +9,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); @@ -36,7 +36,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) { @@ -87,7 +87,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); @@ -111,7 +111,7 @@ void UIScene_HelpAndOptionsMenu::handleReload() { // 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/Platform/Common/UI/UIScene_HopperMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HopperMenu.cpp index 330d17a42..7dc4d3132 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HopperMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HopperMenu.cpp @@ -16,7 +16,7 @@ UIScene_HopperMenu::UIScene_HopperMenu(int iPad, void* _initData, m_labelDispenser.init(initData->hopper->getName()); Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[initData->iPad] != NULL) { + if (pMinecraft->localgameModes[initData->iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -150,7 +150,7 @@ void UIScene_HopperMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionHopperContents: slotList = &m_slotListTrap; @@ -169,7 +169,7 @@ void UIScene_HopperMenu::setSectionSelectedSlot(ESceneSection eSection, int x, } UIControl* UIScene_HopperMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionHopperContents: control = &m_slotListTrap; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.cpp index 79a850f95..74b6af17e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.cpp @@ -20,7 +20,7 @@ UIScene_HorseInventoryMenu::UIScene_HorseInventoryMenu(int iPad, m_horse = initData->horse; Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[iPad] != NULL) { + if (pMinecraft->localgameModes[iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -228,7 +228,7 @@ void UIScene_HorseInventoryMenu::setSectionSelectedSlot(ESceneSection eSection, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionHorseArmor: slotList = &m_slotArmor; @@ -254,7 +254,7 @@ void UIScene_HorseInventoryMenu::setSectionSelectedSlot(ESceneSection eSection, } UIControl* UIScene_HorseInventoryMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionHorseArmor: control = &m_slotArmor; @@ -281,8 +281,8 @@ 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) + if (pMinecraft->localplayers[m_iPad] == nullptr || + pMinecraft->localgameModes[m_iPad] == nullptr) return; if (std::char_traits::compare(region->name, u"horse", 5) == 0) { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp index 54854d4fe..5cd34da5f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp @@ -83,7 +83,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp index 132b0182c..a94f00155 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp @@ -24,7 +24,7 @@ UIScene_InGameInfoMenu::UIScene_InGameInfoMenu(int iPad, void* initData, for (int i = 0; i < playerCount; ++i) { INetworkPlayer* player = g_NetworkManager.GetPlayerByIndex(i); - if (player != NULL) { + if (player != nullptr) { PlayerInfo* info = BuildPlayerInfo(player); m_players.push_back(info); @@ -39,7 +39,7 @@ UIScene_InGameInfoMenu::UIScene_InGameInfoMenu(int iPad, void* initData, 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(); std::shared_ptr localPlayer = @@ -104,7 +104,7 @@ void UIScene_InGameInfoMenu::updateTooltips() { if (isOp) { if (m_buttonGameOptions.hasFocus()) { 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)) @@ -125,7 +125,7 @@ void UIScene_InGameInfoMenu::updateTooltips() { if (!m_buttonGameOptions.hasFocus()) { // if the player is me, then view gamer profile - if (selectedPlayer != NULL && selectedPlayer->IsLocal() && + if (selectedPlayer != nullptr && selectedPlayer->IsLocal() && selectedPlayer->GetUserIndex() == m_iPad) { ikeyY = IDS_TOOLTIPS_VIEW_GAMERPROFILE; } else { @@ -161,7 +161,7 @@ void UIScene_InGameInfoMenu::handleReload() { for (DWORD i = 0; i < playerCount; ++i) { INetworkPlayer* player = g_NetworkManager.GetPlayerByIndex(i); - if (player != NULL) { + if (player != nullptr) { PlayerInfo* info = BuildPlayerInfo(player); m_players.push_back(info); @@ -173,7 +173,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(); std::shared_ptr localPlayer = @@ -196,7 +196,7 @@ void UIScene_InGameInfoMenu::tick() { for (DWORD i = 0; i < m_players.size(); ++i) { INetworkPlayer* player = g_NetworkManager.GetPlayerByIndex(i); - if (player != NULL) { + if (player != nullptr) { PlayerInfo* info = BuildPlayerInfo(player); m_players[i]->m_smallId = info->m_smallId; @@ -243,7 +243,7 @@ void UIScene_InGameInfoMenu::handleInput(int iPad, int key, bool repeat, (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) { ProfileManager.ShowProfileCard(iPad, uid); @@ -291,7 +291,7 @@ void UIScene_InGameInfoMenu::handlePress(F64 controlId, F64 childId) { 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)) @@ -444,7 +444,7 @@ UIScene_InGameInfoMenu::PlayerInfo* UIScene_InGameInfoMenu::BuildPlayerInfo( } int voiceStatus = 0; - if (player != NULL && player->HasVoice()) { + if (player != nullptr && player->HasVoice()) { if (player->IsMutedByLocalUser(m_iPad)) { // Muted image voiceStatus = 3; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp index 6afad8866..4d87f55d1 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp @@ -27,14 +27,14 @@ UIScene_InGamePlayerOptionsMenu::UIScene_InGamePlayerOptionsMenu( 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()) { removeControl(&m_checkboxes[eControl_BuildAndMine], true); @@ -304,7 +304,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()) { removeControl(&m_checkboxes[eControl_BuildAndMine], true); @@ -463,7 +463,7 @@ void UIScene_InGamePlayerOptionsMenu::handleInput(int iPad, int key, INetworkPlayer* editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); if (!trustPlayers && - (editingPlayer != NULL && !editingPlayer->IsHost())) { + (editingPlayer != nullptr && !editingPlayer->IsHost())) { Player::setPlayerGamePrivilege( m_playerPrivileges, Player::ePlayerGamePrivilege_CannotMine, @@ -603,10 +603,10 @@ void UIScene_InGamePlayerOptionsMenu::OnPlayerChanged(void* callbackParam, UIScene_InGameInfoMenu* infoScene = (UIScene_InGameInfoMenu*)scene->getBackScene(); - if (infoScene != NULL) + if (infoScene != nullptr) UIScene_InGameInfoMenu::OnPlayerChanged(infoScene, pPlayer, leaving); - if (leaving && pPlayer != NULL && + if (leaving && pPlayer != nullptr && pPlayer->GetSmallId() == scene->m_networkSmallId) { scene->m_bShouldNavBack = true; } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp index ac1e4cfa3..c610c7a02 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp @@ -29,10 +29,10 @@ int UIScene_InGameSaveManagementMenu::LoadSaveDataThumbnailReturned( .dwThumbnailSize = dwThumbnailBytes; } else { pClass->m_saveDetails[pClass->m_iRequestingThumbnailId] - .pbThumbnailData = NULL; + .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; @@ -62,9 +62,9 @@ UIScene_InGameSaveManagementMenu::UIScene_InGameSaveManagementMenu( 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; @@ -176,14 +176,14 @@ void UIScene_InGameSaveManagementMenu::tick() { // Display the saves if we have them 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; } } @@ -331,9 +331,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, (char*)"save"); + StorageManager.GetSavesInfo(m_iPad, nullptr, this, (char*)"save"); } return; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InventoryMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InventoryMenu.cpp index d5d389975..5b7a8b210 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InventoryMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InventoryMenu.cpp @@ -27,7 +27,7 @@ UIScene_InventoryMenu::UIScene_InventoryMenu(int iPad, void* _initData, InventoryScreenInput* initData = (InventoryScreenInput*)_initData; Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[initData->iPad] != NULL) { + if (pMinecraft->localgameModes[initData->iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -182,7 +182,7 @@ void UIScene_InventoryMenu::setSectionSelectedSlot(ESceneSection eSection, int index = (y * cols) + x; - UIControl_SlotList* slotList = NULL; + UIControl_SlotList* slotList = nullptr; switch (eSection) { case eSectionInventoryArmor: slotList = &m_slotListArmor; @@ -197,13 +197,13 @@ void UIScene_InventoryMenu::setSectionSelectedSlot(ESceneSection eSection, break; } - if (slotList != NULL) { + if (slotList != nullptr) { slotList->setHighlightSlot(index); } } UIControl* UIScene_InventoryMenu::getSection(ESceneSection eSection) { - UIControl* control = NULL; + UIControl* control = nullptr; switch (eSection) { case eSectionInventoryArmor: control = &m_slotListArmor; @@ -222,8 +222,8 @@ 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) + if (pMinecraft->localplayers[m_iPad] == nullptr || + pMinecraft->localgameModes[m_iPad] == nullptr) return; if (std::char_traits::compare(region->name, u"player", 6) == 0) { @@ -252,7 +252,7 @@ void UIScene_InventoryMenu::updateEffectsDisplay() { std::shared_ptr player = pMinecraft->localplayers[m_iPad]; - if (player == NULL) return; + if (player == nullptr) return; std::vector* activeEffects = player->getActiveEffects(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp index 49c139366..72f7971c6 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp @@ -295,16 +295,16 @@ int UIScene_JoinMenu::StartGame_SignInReturned(void* pParam, bool bContinue, int iPad) { UIScene_JoinMenu* pClass = (UIScene_JoinMenu*)ui.GetSceneFromCallbackId( reinterpret_cast(pParam)); - if (pClass == NULL) { + if (pClass == nullptr) { pClass = (UIScene_JoinMenu*)pParam; } - if (bContinue == true && pClass != NULL && + if (bContinue == true && pClass != nullptr && ProfileManager.IsSignedIn(iPad)) { JoinGame(pClass); } - if (pClass != NULL) { + if (pClass != nullptr) { pClass->m_bIgnoreInput = false; } @@ -443,7 +443,7 @@ void UIScene_JoinMenu::handleTimerComplete(int id) { playersList.DeleteItems(0, playersList.GetItemCount()); 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; @@ -462,7 +462,7 @@ void UIScene_JoinMenu::handleTimerComplete(int id) { .c_str()); } } 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/Platform/Common/UI/UIScene_Keyboard.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_Keyboard.cpp index 799eaff03..bacec1e67 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_Keyboard.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_Keyboard.cpp @@ -93,44 +93,44 @@ void UIScene_Keyboard::handleInput(int iPad, int key, bool repeat, bool pressed, case ACTION_MENU_X: // X out = IggyPlayerCallMethodRS( getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcBackspaceButtonPressed, 0, NULL); + m_funcBackspaceButtonPressed, 0, nullptr); handled = true; break; case ACTION_MENU_PAGEUP: // LT out = IggyPlayerCallMethodRS( getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcSymbolButtonPressed, 0, NULL); + m_funcSymbolButtonPressed, 0, nullptr); handled = true; break; case ACTION_MENU_Y: // Y out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcSpaceButtonPressed, 0, NULL); + m_funcSpaceButtonPressed, 0, nullptr); handled = true; break; case ACTION_MENU_STICK_PRESS: // LS out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcCapsButtonPressed, 0, NULL); + m_funcCapsButtonPressed, 0, nullptr); handled = true; break; case ACTION_MENU_LEFT_SCROLL: // LB out = IggyPlayerCallMethodRS( getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcCursorLeftButtonPressed, 0, NULL); + m_funcCursorLeftButtonPressed, 0, nullptr); handled = true; break; case ACTION_MENU_RIGHT_SCROLL: // RB out = IggyPlayerCallMethodRS( getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcCursorRightButtonPressed, 0, NULL); + 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); + m_funcDoneButtonPressed, 0, nullptr); // kick off done timer addTimer(KEYBOARD_DONE_TIMER_ID, KEYBOARD_DONE_TIMER_TIME); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.cpp index d32aed2b8..821d638a2 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.cpp @@ -53,7 +53,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index 96bd32945..7d53484a7 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -317,7 +317,7 @@ void UIScene_LaunchMoreOptionsMenu::handleInput(int iPad, int key, bool repeat, IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS( getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcChangeTab, 0, NULL); + m_funcChangeTab, 0, nullptr); } break; } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp index aeac47186..964d996b9 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp @@ -474,7 +474,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 ) diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp index be6778cef..4069ec101 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp @@ -39,7 +39,7 @@ int UIScene_LoadMenu::LoadSaveDataThumbnailReturned( pClass->m_uiThumbnailSize = dwThumbnailBytes; pClass->m_bSaveThumbnailReady = true; } 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; @@ -98,7 +98,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void* initData, m_bSaveThumbnailReady = false; m_bRetrievingSaveThumbnail = true; m_bShowTimer = false; - m_pDLCPack = NULL; + m_pDLCPack = nullptr; m_bAvailableTexturePacksChecked = false; m_bRequestQuadrantSignin = false; m_iTexturePacksNotInstalled = 0; @@ -280,10 +280,10 @@ 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); + // 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 @@ -538,7 +538,7 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() { 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 // upsell @@ -754,7 +754,7 @@ void UIScene_LoadMenu::LaunchGame(void) { // 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); } else { @@ -805,7 +805,7 @@ void UIScene_LoadMenu::LaunchGame(void) { 2, m_iPad, &UIScene_LoadMenu::ConfirmLoadReturned, this); } } else { - if (m_levelGen != NULL) { + if (m_levelGen != nullptr) { m_bIsCorrupt = false; LoadDataComplete(this); } else { @@ -864,7 +864,7 @@ int UIScene_LoadMenu::ConfirmLoadReturned(void* pParam, int iPad, UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; if (result == C4JStorage::EMessage_ResultAccept) { - if (pClass->m_levelGen != NULL) { + if (pClass->m_levelGen != nullptr) { pClass->m_bIsCorrupt = false; pClass->LoadDataComplete(pClass); } else { @@ -1058,7 +1058,7 @@ int UIScene_LoadMenu::DeleteSaveDataReturned(void* pParam, bool bSuccess) { // sign-in or not void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, int localUsersMask) { - if (pClass->m_levelGen == NULL) { + if (pClass->m_levelGen == nullptr) { INT saveOrCheckpointId = 0; bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); @@ -1088,7 +1088,7 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, 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; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp index 71cb594c6..13a553907 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp @@ -54,10 +54,10 @@ int UIScene_LoadOrJoinMenu::LoadSaveDataThumbnailReturned( .dwThumbnailSize = dwThumbnailBytes; } else { pClass->m_saveDetails[pClass->m_iRequestingThumbnailId] - .pbThumbnailData = NULL; + .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; @@ -85,7 +85,7 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void* initData, m_bIgnoreInput = false; m_bShowingPartyGamesOnly = false; m_bInParty = false; - m_currentSessions = NULL; + m_currentSessions = nullptr; m_iState = e_SavesIdle; // m_bRetrievingSaveInfo=false; @@ -105,9 +105,9 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void* initData, 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; @@ -162,7 +162,7 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void* initData, } UIScene_LoadOrJoinMenu::~UIScene_LoadOrJoinMenu() { - g_NetworkManager.SetSessionsUpdatedCallback(NULL, NULL); + g_NetworkManager.SetSessionsUpdatedCallback(nullptr, nullptr); app.SetLiveLinkRequired(false); if (m_currentSessions) { @@ -396,16 +396,16 @@ void UIScene_LoadOrJoinMenu::tick() { // Display the saves if we have them if (!m_bSavesDisplayed) { m_pSaveDetails = StorageManager.ReturnSavesInfo(); - if (m_pSaveDetails != NULL) { + if (m_pSaveDetails != nullptr) { // CD - Fix - Adding define for ORBIS/XBOXONE AddDefaultButtons(); 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; } } @@ -614,9 +614,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, (char*)"save"); + StorageManager.GetSavesInfo(m_iPad, nullptr, this, (char*)"save"); } #if TO_BE_IMPLEMENTED @@ -925,7 +925,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(), @@ -948,7 +948,7 @@ void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId) { params->iSaveGameInfoIndex = ((int)childId) - m_iDefaultButtonsC; // params->pbSaveRenamed=&m_bSaveRenamed; - params->levelGen = NULL; + params->levelGen = nullptr; params->saveDetails = &m_saveDetails[((int)childId) - m_iDefaultButtonsC]; @@ -1062,7 +1062,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; @@ -1093,7 +1093,7 @@ void UIScene_LoadOrJoinMenu::LoadLevelGen(LevelGenerationOptions* levelGen) { } void UIScene_LoadOrJoinMenu::UpdateGamesListCallback(void* pParam) { - if (pParam != NULL) { + if (pParam != nullptr) { UIScene_LoadOrJoinMenu* pScene = (UIScene_LoadOrJoinMenu*)pParam; pScene->UpdateGamesList(); } @@ -1116,7 +1116,7 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() { return; } - FriendSessionInfo* pSelectedSession = NULL; + FriendSessionInfo* pSelectedSession = nullptr; if (DoesGamesListHaveFocus() && m_buttonListGames.getItemCount() > 0) { const int nIndex = m_buttonListGames.getCurrentSelection(); pSelectedSession = m_currentSessions->at(nIndex); @@ -1124,9 +1124,9 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() { SessionID selectedSessionId; ZeroMemory(&selectedSessionId, sizeof(SessionID)); - if (pSelectedSession != NULL) + if (pSelectedSession != nullptr) selectedSessionId = pSelectedSession->sessionId; - pSelectedSession = NULL; + pSelectedSession = nullptr; m_controlJoinTimer.setVisible(false); @@ -1191,11 +1191,11 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() { HRESULT hr; std::uint32_t imageBytes = 0; - std::uint8_t* imageData = NULL; + std::uint8_t* imageData = nullptr; - if (tp == NULL) { + if (tp == nullptr) { unsigned int dwBytes = 0; - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; app.GetTPD(sessionInfo->data.texturePackParentId, &pbData, &dwBytes); @@ -1675,7 +1675,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { pMinecraft->progressRenderer->progressStage( IDS_TOOLTIPS_SAVETRANSFER_DOWNLOAD); - ConsoleSaveFile* pSave = NULL; + ConsoleSaveFile* pSave = nullptr; pClass->m_eSaveTransferState = eSaveTransfer_GetRemoteSaveInfo; @@ -1733,10 +1733,10 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { mbstowcs(wSaveName, pNameUTF8, strlen(pNameUTF8) + 1); // plus null StorageManager.SetSaveTitle(wSaveName); - std::uint8_t* pbThumbnailData = NULL; + std::uint8_t* pbThumbnailData = nullptr; unsigned int dwThumbnailDataSize = 0; - std::uint8_t* pbDataSaveImage = NULL; + std::uint8_t* pbDataSaveImage = nullptr; unsigned int dwDataSizeSaveImage = 0; StorageManager.GetDefaultSaveImage( @@ -1908,10 +1908,10 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { StorageManager.ResetSaveData(); { - std::uint8_t* pbThumbnailData = NULL; + std::uint8_t* pbThumbnailData = nullptr; unsigned int dwThumbnailDataSize = 0; - std::uint8_t* pbDataSaveImage = NULL; + std::uint8_t* pbDataSaveImage = nullptr; unsigned int dwDataSizeSaveImage = 0; StorageManager.GetDefaultSaveImage( @@ -2142,7 +2142,7 @@ void UIScene_LoadOrJoinMenu::SaveTransferReturned(void* lpParam, error_code); } } -ConsoleSaveFile* UIScene_LoadOrJoinMenu::SonyCrossSaveConvert() { return NULL; } +ConsoleSaveFile* UIScene_LoadOrJoinMenu::SonyCrossSaveConvert() { return nullptr; } void UIScene_LoadOrJoinMenu::CancelSaveTransferCallback(void* lpParam) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)lpParam; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp index 2dbd0e729..1c709a17b 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp @@ -75,7 +75,7 @@ UIScene_MainMenu::UIScene_MainMenu(int iPad, void* initData, 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 @@ -210,7 +210,7 @@ void UIScene_MainMenu::handleInput(int iPad, int key, bool repeat, bool pressed, void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) { int primaryPad = ProfileManager.GetPrimaryPad(); - int (*signInReturnedFunc)(void*, const bool, const int iPad) = NULL; + int (*signInReturnedFunc)(void*, const bool, const int iPad) = nullptr; switch ((int)controlId) { case eControl_PlayGame: @@ -269,7 +269,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)) { if (confirmUser) { ProfileManager.RequestSignInUI(false, false, true, false, true, @@ -888,7 +888,7 @@ void UIScene_MainMenu::RunLeaderboards(int iPad) { uiIDA[0] = IDS_CONFIRM_OK; ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, this); + ProfileManager.GetPrimaryPad(), nullptr, this); #endif } else { ProfileManager.SetLockedProfile(iPad); @@ -930,7 +930,7 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { uiIDA[0] = IDS_CONFIRM_OK; ui.RequestErrorMessage( IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, - uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, + uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, this); #endif } else { @@ -1109,7 +1109,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); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.cpp index 441578776..4a4544317 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.cpp @@ -47,7 +47,7 @@ UIScene_MessageBox::UIScene_MessageBox(int iPad, void* initData, out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcAutoResize, 0, NULL); + m_funcAutoResize, 0, nullptr); m_Func = param->Func; m_lpParam = param->lpParam; @@ -89,7 +89,7 @@ void UIScene_MessageBox::handleReload() { out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcAutoResize, 0, NULL); + m_funcAutoResize, 0, nullptr); } void UIScene_MessageBox::handleInput(int iPad, int key, bool repeat, diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_PauseMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_PauseMenu.cpp index 023e6aada..2005dbd87 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_PauseMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_PauseMenu.cpp @@ -59,7 +59,7 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void* initData, TelemetryManager->RecordPauseOrInactive(m_iPad); Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL) { + if (pMinecraft != nullptr && pMinecraft->localgameModes[iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[iPad]; @@ -71,7 +71,7 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void* initData, 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 = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; @@ -348,7 +348,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { // is it the primary player exiting? if (m_iPad == ProfileManager.GetPrimaryPad()) { int playTime = -1; - if (pMinecraft->localplayers[m_iPad] != NULL) { + if (pMinecraft->localplayers[m_iPad] != nullptr) { playTime = (int)pMinecraft->localplayers[m_iPad] ->getSessionTimer(); } @@ -396,7 +396,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 = (int)pMinecraft->localplayers[m_iPad] ->getSessionTimer(); } @@ -411,7 +411,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { // is it the primary player exiting? if (m_iPad == ProfileManager.GetPrimaryPad()) { int playTime = -1; - if (pMinecraft->localplayers[m_iPad] != NULL) { + if (pMinecraft->localplayers[m_iPad] != nullptr) { playTime = (int)pMinecraft->localplayers[m_iPad] ->getSessionTimer(); } @@ -431,7 +431,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 = (int)pMinecraft->localplayers[m_iPad] ->getSessionTimer(); } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp index 0103a4525..815477352 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp @@ -194,7 +194,7 @@ int UIScene_QuadrantSignin::AvatarReturned(void* lpParam, unsigned int dwThumbnailBytes) { UIScene_QuadrantSignin* pClass = (UIScene_QuadrantSignin*)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/Platform/Common/UI/UIScene_ReinstallMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_ReinstallMenu.cpp index 207722ed5..b44c7ab0b 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ReinstallMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ReinstallMenu.cpp @@ -38,7 +38,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp index e96cd5698..e534def3a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp @@ -22,7 +22,7 @@ UIScene_SaveMessage::UIScene_SaveMessage(int iPad, void* initData, // Russian needs to resize the box IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcAutoResize, 0, NULL); + 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/Platform/Common/UI/UIScene_SettingsAudioMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsAudioMenu.cpp index 984d90d79..fa2c36d02 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsAudioMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsAudioMenu.cpp @@ -43,7 +43,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsControlMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsControlMenu.cpp index 742ef223b..e2147cec4 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsControlMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsControlMenu.cpp @@ -48,7 +48,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsGraphicsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsGraphicsMenu.cpp index 75cd2e8e3..c080340b4 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsGraphicsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsGraphicsMenu.cpp @@ -9,7 +9,7 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, // Setup all the Iggy references we need for this scene initialiseMovie(); - m_bNotInGame = (Minecraft::GetInstance()->level == NULL); + m_bNotInGame = (Minecraft::GetInstance()->level == nullptr); m_checkboxClouds.init( app.GetString(IDS_CHECKBOX_RENDER_CLOUDS), eControl_Clouds, @@ -37,7 +37,7 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, 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) { @@ -81,7 +81,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp index d8a7c2081..2f425a3af 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp @@ -9,7 +9,7 @@ UIScene_SettingsMenu::UIScene_SettingsMenu(int iPad, void* initData, // 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); @@ -44,7 +44,7 @@ std::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); @@ -59,7 +59,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp index d8e3f4ad8..553435c72 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp @@ -20,7 +20,7 @@ UIScene_SettingsOptionsMenu::UIScene_SettingsOptionsMenu(int iPad, // 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, @@ -97,7 +97,7 @@ UIScene_SettingsOptionsMenu::UIScene_SettingsOptionsMenu(int iPad, 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) { bRemoveDifficulty = true; @@ -176,7 +176,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); @@ -302,7 +302,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) { bRemoveDifficulty = true; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsUIMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsUIMenu.cpp index 5a7b3625e..0dca8b89c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsUIMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsUIMenu.cpp @@ -8,7 +8,7 @@ UIScene_SettingsUIMenu::UIScene_SettingsUIMenu(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_checkboxDisplayHUD.init( app.GetString(IDS_CHECKBOX_DISPLAY_HUD), eControl_DisplayHUD, @@ -49,7 +49,7 @@ UIScene_SettingsUIMenu::UIScene_SettingsUIMenu(int iPad, void* initData, 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 @@ -75,7 +75,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); m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp index 474fe4446..9547588fa 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp @@ -92,7 +92,7 @@ void UIScene_SignEntryMenu::tick() { if (pMinecraft->level->isClientSide) { std::shared_ptr player = pMinecraft->localplayers[m_iPad]; - if (player != NULL && player->connection && + if (player != nullptr && player->connection && player->connection->isStarted()) { player->connection->send( std::shared_ptr(new SignUpdatePacket( diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp index 473f38bf0..c583b3732 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp @@ -32,7 +32,7 @@ UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void* initData, m_bIgnoreInput = false; m_bNoSkinsToShow = false; - m_currentPack = NULL; + m_currentPack = nullptr; m_packIndex = SKIN_SELECT_PACK_DEFAULT; m_skinIndex = 0; @@ -40,7 +40,7 @@ UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void* initData, m_currentSkinPath = app.GetPlayerSkinName(iPad); m_selectedSkinPath = L""; m_selectedCapePath = L""; - m_vAdditionalSkinBoxes = NULL; + m_vAdditionalSkinBoxes = nullptr; m_bSlidingSkins = false; m_bAnimatingMove = false; @@ -100,7 +100,7 @@ UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void* initData, 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) + @@ -385,7 +385,7 @@ void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad) { } break; default: - if (m_currentPack != NULL) { + if (m_currentPack != nullptr) { bool renableInputAfterOperation = true; m_bIgnoreInput = true; @@ -524,8 +524,8 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { std::wstring skinOrigin = L""; bool bSkinIsFree = false; bool bLicensed = false; - DLCSkinFile* skinFile = NULL; - DLCPack* Pack = NULL; + DLCSkinFile* skinFile = nullptr; + DLCPack* Pack = nullptr; int sidePreviewControlsL, sidePreviewControlsR; m_bNoSkinsToShow = false; @@ -535,7 +535,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(); m_selectedCapePath = @@ -563,7 +563,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { } else { m_selectedSkinPath = L""; m_selectedCapePath = L""; - m_vAdditionalSkinBoxes = NULL; + m_vAdditionalSkinBoxes = nullptr; switch (m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: @@ -643,13 +643,13 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { std::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()); } @@ -665,7 +665,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { std::wstring otherSkinPath = L""; std::wstring otherCapePath = L""; - std::vector* othervAdditionalSkinBoxes = NULL; + std::vector* othervAdditionalSkinBoxes = nullptr; wchar_t chars[256]; // turn off all displays @@ -698,11 +698,11 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { for (int i = 0; i < sidePreviewControlsR; ++i) { 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(); otherCapePath = skinFile->getParameterAsString( @@ -712,7 +712,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { } else { otherSkinPath = L""; otherCapePath = L""; - othervAdditionalSkinBoxes = NULL; + othervAdditionalSkinBoxes = nullptr; switch (m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: backupTexture = getTextureId(nextIndex); @@ -746,13 +746,13 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { othervAdditionalSkinBoxes->size() != 0) { std::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()); } @@ -766,11 +766,11 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { for (int i = 0; i < sidePreviewControlsL; ++i) { 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(); otherCapePath = skinFile->getParameterAsString( @@ -780,7 +780,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { } else { otherSkinPath = L""; otherCapePath = L""; - othervAdditionalSkinBoxes = NULL; + othervAdditionalSkinBoxes = nullptr; switch (m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: backupTexture = getTextureId(previousIndex); @@ -815,7 +815,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { othervAdditionalSkinBoxes->size() != 0) { std::vector* pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); - if (pAdditionalModelParts == NULL) { + if (pAdditionalModelParts == nullptr) { pAdditionalModelParts = app.SetAdditionalSkinBoxes( skinFile->getSkinID(), othervAdditionalSkinBoxes); } @@ -888,7 +888,7 @@ int UIScene_SkinSelectMenu::getNextSkinIndex(int sourceIndex) { if (m_packIndex == SKIN_SELECT_PACK_DEFAULT && nextSkin >= eDefaultSkins_Count) { nextSkin = eDefaultSkins_ServerSelected; - } else if (m_currentPack != NULL && + } else if (m_currentPack != nullptr && nextSkin >= m_currentPack->getSkinCount()) { nextSkin = 0; } @@ -912,7 +912,7 @@ int UIScene_SkinSelectMenu::getPreviousSkinIndex(int sourceIndex) { if (previousSkin == 0) { if (m_packIndex == SKIN_SELECT_PACK_DEFAULT) { previousSkin = eDefaultSkins_Count - 1; - } else if (m_currentPack != NULL) { + } else if (m_currentPack != nullptr) { previousSkin = m_currentPack->getSkinCount() - 1; } } else { @@ -929,10 +929,10 @@ void UIScene_SkinSelectMenu::handlePackIndexChanged() { m_currentPack = app.m_dlcManager.getPack( m_packIndex - SKIN_SELECT_MAX_DEFAULTS, DLCManager::e_DLCType_Skin); } else { - m_currentPack = NULL; + m_currentPack = nullptr; } m_skinIndex = 0; - if (m_currentPack != NULL) { + if (m_currentPack != nullptr) { bool found; int currentSkinIndex = m_currentPack->getSkinIndexAt(m_currentSkinPath, found); @@ -1178,7 +1178,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, @@ -1200,7 +1200,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); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.cpp index 1c4b36906..0d17a2828 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.cpp @@ -37,7 +37,7 @@ UIScene_TeleportMenu::UIScene_TeleportMenu(int iPad, void* initData, for (int i = 0; i < playerCount; ++i) { INetworkPlayer* player = g_NetworkManager.GetPlayerByIndex(i); - if (player != NULL && + if (player != nullptr && !(player->IsLocal() && player->GetUserIndex() == m_iPad)) { m_players[m_playersCount] = player->GetSmallId(); ++m_playersCount; @@ -55,7 +55,7 @@ UIScene_TeleportMenu::UIScene_TeleportMenu(int iPad, void* initData, } int voiceStatus = 0; - if (player != NULL && player->HasVoice()) { + if (player != nullptr && player->HasVoice()) { if (player->IsMutedByLocalUser(m_iPad)) { // Muted image voiceStatus = 3; @@ -119,7 +119,7 @@ void UIScene_TeleportMenu::handleReload() { for (int i = 0; i < playerCount; ++i) { INetworkPlayer* player = g_NetworkManager.GetPlayerByIndex(i); - if (player != NULL && + if (player != nullptr && !(player->IsLocal() && player->GetUserIndex() == m_iPad)) { m_players[m_playersCount] = player->GetSmallId(); ++m_playersCount; @@ -137,7 +137,7 @@ void UIScene_TeleportMenu::handleReload() { } int voiceStatus = 0; - if (player != NULL && player->HasVoice()) { + if (player != nullptr && player->HasVoice()) { if (player->IsMutedByLocalUser(m_iPad)) { // Muted image voiceStatus = 3; @@ -172,7 +172,7 @@ void UIScene_TeleportMenu::tick() { INetworkPlayer* player = g_NetworkManager.GetPlayerBySmallId(m_players[i]); - if (player != NULL) { + if (player != nullptr) { m_players[i] = player->GetSmallId(); short icon = app.GetPlayerColour(m_players[i]); @@ -298,7 +298,7 @@ void UIScene_TeleportMenu::OnPlayerChanged(void* callbackParam, } int voiceStatus = 0; - if (pPlayer != NULL && pPlayer->HasVoice()) { + if (pPlayer != nullptr && pPlayer->HasVoice()) { if (pPlayer->IsMutedByLocalUser(scene->m_iPad)) { // Muted image voiceStatus = 3; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp index 9c2c91211..6ddad94a6 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp @@ -30,7 +30,7 @@ UIScene_TradingMenu::UIScene_TradingMenu(int iPad, void* _initData, m_merchant = initData->trader; Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[iPad] != NULL) { + if (pMinecraft->localgameModes[iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -82,10 +82,10 @@ void UIScene_TradingMenu::updateTooltips() { 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 = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; - if (gameMode != NULL) + if (gameMode != nullptr) gameMode->getTutorial()->changeTutorialState( m_previousTutorialState); } @@ -95,7 +95,7 @@ void UIScene_TradingMenu::handleDestroy() { // 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) + if (pMinecraft->localplayers[m_iPad] != nullptr) pMinecraft->localplayers[m_iPad]->closeContainer(); ui.OverrideSFX(m_iPad, ACTION_MENU_A, false); @@ -153,8 +153,8 @@ void UIScene_TradingMenu::handleInput(int iPad, int key, bool repeat, void UIScene_TradingMenu::customDraw(IggyCustomDrawCallbackRegion* region) { 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; std::shared_ptr item = nullptr; @@ -181,7 +181,7 @@ void UIScene_TradingMenu::customDraw(IggyCustomDrawCallbackRegion* region) { }; } } - if (item != NULL) + if (item != nullptr) customDrawSlotControl(region, m_iPad, item, 1.0f, item->isFoil(), true); } diff --git a/Minecraft.Client/Platform/Common/UI/UIString.cpp b/Minecraft.Client/Platform/Common/UI/UIString.cpp index 75a532663..ac5b40975 100644 --- a/Minecraft.Client/Platform/Common/UI/UIString.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIString.cpp @@ -113,26 +113,26 @@ UIString::~UIString() { m_core = nullptr; } -bool UIString::empty() { return m_core.get() == NULL; } +bool UIString::empty() { return m_core.get() == nullptr; } bool UIString::compare(const UIString& uiString) { return m_core.get() != uiString.m_core.get(); } bool UIString::needsUpdating() { - if (m_core != NULL) + 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(); } std::wstring& UIString::getString() { static std::wstring blank(L""); - if (m_core != NULL) + if (m_core != nullptr) return m_core->getString(); else return blank; diff --git a/Minecraft.Client/Platform/Common/UI/UIStructs.h b/Minecraft.Client/Platform/Common/UI/UIStructs.h index 1e69d976d..69a3e6860 100644 --- a/Minecraft.Client/Platform/Common/UI/UIStructs.h +++ b/Minecraft.Client/Platform/Common/UI/UIStructs.h @@ -174,8 +174,8 @@ typedef struct _ConnectionProgressParams { showTooltips = false; setFailTimer = false; timerTime = 0; - cancelFunc = NULL; - cancelFuncParam = NULL; + cancelFunc = nullptr; + cancelFuncParam = nullptr; } } ConnectionProgressParams; @@ -215,7 +215,7 @@ typedef struct _SaveListDetails { _SaveListDetails() { saveId = 0; - pbThumbnailData = NULL; + pbThumbnailData = nullptr; dwThumbnailSize = 0; ZeroMemory(UTF8SaveName, 128); ZeroMemory(UTF8SaveFilename, MAX_SAVEFILENAME_LENGTH); @@ -328,15 +328,15 @@ typedef struct _LoadingInputParams { bool waitForThreadToDelete; _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; @@ -356,7 +356,7 @@ typedef struct _TutorialPopupInfo { Tutorial* tutorial; _TutorialPopupInfo() { - interactScene = NULL; + interactScene = nullptr; desc = L""; title = L""; icon = -1; @@ -364,7 +364,7 @@ typedef struct _TutorialPopupInfo { isFoil = false; allowFade = true; isReminder = false; - tutorial = NULL; + tutorial = nullptr; } } TutorialPopupInfo; diff --git a/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp b/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp index c9ef6c4ff..6d3ab8d15 100644 --- a/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp +++ b/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp @@ -7,11 +7,11 @@ UITTFFont::UITTFFont(const std::string& name, const std::string& path, S32 fallbackCharacter) : m_strFontName(name) { app.DebugPrintf("UITTFFont opening %s\n", path.c_str()); - pbData = NULL; + pbData = nullptr; std::wstring wPath = convStringToWstring(path); std::FILE* file = PortableFileIO::OpenBinaryFileForRead(wPath); - if (file == NULL) { + if (file == nullptr) { app.DebugPrintf("Failed to open TTF file\n"); assert(false); } diff --git a/Minecraft.Client/Platform/Common/XML/ATGXmlParser.cpp b/Minecraft.Client/Platform/Common/XML/ATGXmlParser.cpp index f4ac09d4b..34f93065a 100644 --- a/Minecraft.Client/Platform/Common/XML/ATGXmlParser.cpp +++ b/Minecraft.Client/Platform/Common/XML/ATGXmlParser.cpp @@ -29,7 +29,7 @@ XMLParser::XMLParser() { m_pWritePtr = m_pWriteBuf; m_pReadPtr = m_pReadBuf; - m_pISAXCallback = NULL; + m_pISAXCallback = nullptr; m_hFile = INVALID_HANDLE_VALUE; } @@ -51,7 +51,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; @@ -64,7 +64,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; } @@ -361,7 +361,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 ) @@ -863,7 +863,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; @@ -876,9 +876,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 ) { @@ -901,7 +901,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; } @@ -914,7 +914,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; @@ -927,7 +927,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; @@ -936,7 +936,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/Platform/Common/XML/ATGXmlParser.h b/Minecraft.Client/Platform/Common/XML/ATGXmlParser.h index 75142e3e3..12f597372 100644 --- a/Minecraft.Client/Platform/Common/XML/ATGXmlParser.h +++ b/Minecraft.Client/Platform/Common/XML/ATGXmlParser.h @@ -138,7 +138,7 @@ private: 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/Platform/Common/XML/xmlFilesCallback.h b/Minecraft.Client/Platform/Common/XML/xmlFilesCallback.h index 351a0d487..7ed172b77 100644 --- a/Minecraft.Client/Platform/Common/XML/xmlFilesCallback.h +++ b/Minecraft.Client/Platform/Common/XML/xmlFilesCallback.h @@ -47,7 +47,7 @@ public: { 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) @@ -135,7 +135,7 @@ public: { wcsncpy_s( wValue, pAttributes[i].strValue, pAttributes[i].ValueLen); - iValue=wcstol(wValue, NULL, 10); + iValue=wcstol(wValue, nullptr, 10); } } } @@ -216,7 +216,7 @@ public: { 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) @@ -232,7 +232,7 @@ public: { 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) @@ -241,7 +241,7 @@ public: { 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) @@ -279,7 +279,7 @@ public: { wcsncpy_s( wConfig, pAttributes[i].strValue, pAttributes[i].ValueLen); - iConfig=wcstol(wConfig, NULL, 10); + iConfig=wcstol(wConfig, nullptr, 10); } } else if (_wcsicmp(wAttName,L"DataFile")==0) diff --git a/Minecraft.Client/Platform/Extrax64Stubs.cpp b/Minecraft.Client/Platform/Extrax64Stubs.cpp index e4e144ce0..16bc61a70 100644 --- a/Minecraft.Client/Platform/Extrax64Stubs.cpp +++ b/Minecraft.Client/Platform/Extrax64Stubs.cpp @@ -40,7 +40,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) {}; #endif @@ -91,7 +91,7 @@ void PIXEndNamedEvent() } void PIXSetMarkerDeprecated(int a, char *b, ...) {} -// void *D3DXBUFFER::GetBufferPointer() { return NULL; } +// void *D3DXBUFFER::GetBufferPointer() { return nullptr; } // int D3DXBUFFER::GetBufferSize() { return 0; } // void D3DXBUFFER::Release() {} @@ -253,11 +253,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; @@ -274,11 +274,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; @@ -410,8 +410,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)(void *), void *lpParam) {} -int( *defaultOptionsCallback)(void *,C_4JProfile::PROFILESETTINGS *, const int iPad) = NULL; -void *lpProfileParam = NULL; +int( *defaultOptionsCallback)(void *,C_4JProfile::PROFILESETTINGS *, const int iPad) = nullptr; +void *lpProfileParam = nullptr; int C_4JProfile::SetDefaultOptionsCallback(int( *Func)(void *,PROFILESETTINGS *, const int iPad),void *lpParam) { defaultOptionsCallback = Func; @@ -489,7 +489,7 @@ void C4JStorage::GetSaveCacheFileInfo(unsigned int fileIndex,XCONTENT_DAT void C4JStorage::GetSaveCacheFileInfo(unsigned int fileIndex, std::uint8_t * *ppbImageData, unsigned int *pImageBytes) {} 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) {} @@ -511,7 +511,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 #endif diff --git a/Minecraft.Client/Platform/Linux/Linux_App.cpp b/Minecraft.Client/Platform/Linux/Linux_App.cpp index 14b2cc82d..7a4f07515 100644 --- a/Minecraft.Client/Platform/Linux/Linux_App.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_App.cpp @@ -46,7 +46,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { ////////////////////////////////////////////////////////////////////////////////////////////// ///From CScene_Main::OnInit - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // From CScene_Main::RunPlayGame Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -80,7 +80,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/Platform/Linux/Linux_App.h b/Minecraft.Client/Platform/Linux/Linux_App.h index bdbe65d95..4549f2d54 100644 --- a/Minecraft.Client/Platform/Linux/Linux_App.h +++ b/Minecraft.Client/Platform/Linux/Linux_App.h @@ -29,7 +29,7 @@ public: 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/Platform/Linux/Linux_Minecraft.cpp b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp index ca55472dd..20d2cfbec 100644 --- a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp @@ -419,16 +419,16 @@ void MemSect(int sect) {} #endif #if !defined(__linux__) -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) @@ -489,7 +489,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"; @@ -512,8 +512,8 @@ 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) { return FALSE; @@ -573,7 +573,7 @@ HRESULT InitDevice() { driverTypeIndex++) { g_driverType = driverTypes[driverTypeIndex]; hr = D3D11CreateDeviceAndSwapChain( - NULL, g_driverType, NULL, createDeviceFlags, featureLevels, + nullptr, g_driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext); if (HRESULT_SUCCEEDED(hr)) break; @@ -581,7 +581,7 @@ HRESULT InitDevice() { if (FAILED(hr)) 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; @@ -601,7 +601,7 @@ HRESULT InitDevice() { descDepth.CPUAccessFlags = 0; descDepth.MiscFlags = 0; hr = - g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer); + g_pd3dDevice->CreateTexture2D(&descDepth, nullptr, &g_pDepthStencilBuffer); D3D11_DEPTH_STENCIL_VIEW_DESC descDSView; descDSView.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; @@ -611,7 +611,7 @@ HRESULT InitDevice() { hr = g_pd3dDevice->CreateDepthStencilView( g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView); - hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, + hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &g_pRenderTargetView); pBackBuffer->Release(); if (FAILED(hr)) return hr; @@ -664,10 +664,10 @@ int main(int argc, const char* argv[]) { sa.sa_handler = sigsegv_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESETHAND; - sigaction(SIGSEGV, &sa, NULL); - sigaction(SIGABRT, &sa, NULL); - sigaction(SIGBUS, &sa, NULL); - sigaction(SIGTRAP, &sa, NULL); + sigaction(SIGSEGV, &sa, nullptr); + sigaction(SIGABRT, &sa, nullptr); + sigaction(SIGBUS, &sa, nullptr); + sigaction(SIGTRAP, &sa, nullptr); #endif app.DebugPrintf("---main()\n"); @@ -829,7 +829,7 @@ int main(int argc, const char* argv[]) { ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())); } else { MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->tick(nullptr, 0.0f); MemSect(0); pMinecraft->textures->tick(true, false); if (app.GetReallyChangingSessionType()) { @@ -1022,7 +1022,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); } return strUtf8; diff --git a/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h b/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h index ca2741f9c..11d12bceb 100644 --- a/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h +++ b/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h @@ -587,7 +587,7 @@ static inline HANDLE FindFirstFileA(const char* lpFileName, strncpy(fh->pattern, pattern, MAX_PATH - 1); struct dirent* ent; - while ((ent = readdir(fh->dir)) != NULL) { + while ((ent = readdir(fh->dir)) != nullptr) { if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; if (fnmatch(fh->pattern, ent->d_name, 0) == 0) { @@ -622,7 +622,7 @@ static inline BOOL FindNextFileA(HANDLE hFindFile, _LINUXSTUBS_FIND_HANDLE* fh = (_LINUXSTUBS_FIND_HANDLE*)hFindFile; struct dirent* ent; - while ((ent = readdir(fh->dir)) != NULL) { + while ((ent = readdir(fh->dir)) != nullptr) { if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; if (fnmatch(fh->pattern, ent->d_name, 0) == 0) { @@ -672,7 +672,7 @@ static inline void _CurrentTimeSpec(struct timespec* ts) { clock_gettime(CLOCK_REALTIME, ts); #else struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); ts->tv_sec = tv.tv_sec; ts->tv_nsec = tv.tv_usec * 1000; #endif @@ -793,8 +793,8 @@ typedef struct { static inline HANDLE CreateEvent(int manual_reset, int initial_state) { Event* ev = (Event*)malloc(sizeof(Event)); - pthread_mutex_init(&ev->mutex, NULL); - pthread_cond_init(&ev->cond, NULL); + pthread_mutex_init(&ev->mutex, nullptr); + pthread_cond_init(&ev->cond, nullptr); ev->signaled = initial_state; ev->manual_reset = manual_reset; return (HANDLE)ev; @@ -933,7 +933,7 @@ static inline void* _linux_thread_entry(void* arg) { lt->completed = 1; pthread_cond_broadcast(<->completionCond); pthread_mutex_unlock(<->completionMutex); - return NULL; + return nullptr; } static inline DWORD _WaitForThread(struct LinuxThread* lt, @@ -985,10 +985,10 @@ static inline HANDLE CreateThread(void*, SIZE_T stackSize, lt->suspended = (dwCreationFlags & CREATE_SUSPENDED) ? 1 : 0; lt->completed = 0; lt->threadId = __sync_fetch_and_add(&g_nextThreadId, 1); - pthread_mutex_init(<->suspendMutex, NULL); - pthread_cond_init(<->suspendCond, NULL); - pthread_mutex_init(<->completionMutex, NULL); - pthread_cond_init(<->completionCond, NULL); + pthread_mutex_init(<->suspendMutex, nullptr); + pthread_cond_init(<->suspendCond, nullptr); + pthread_mutex_init(<->completionMutex, nullptr); + pthread_cond_init(<->completionCond, nullptr); if (lpThreadId) *lpThreadId = lt->threadId; pthread_attr_t attr; pthread_attr_init(&attr); @@ -1079,16 +1079,16 @@ static inline LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, prot = PROT_READ | PROT_WRITE; // default int flags = MAP_PRIVATE | MAP_ANONYMOUS; - if (lpAddress != NULL) flags |= MAP_FIXED; + if (lpAddress != nullptr) flags |= MAP_FIXED; void* p = mmap(lpAddress, dwSize, prot, flags, -1, 0); - if (p == MAP_FAILED) return NULL; + if (p == MAP_FAILED) return nullptr; return p; } static inline BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) { - if (lpAddress == NULL) return FALSE; + if (lpAddress == nullptr) return FALSE; // MEM_RELEASE (0x8000) frees the whole region if (dwFreeType == 0x8000 /*MEM_RELEASE*/) { // dwSize should be 0 for MEM_RELEASE per Win32 API, but we don't track diff --git a/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h index 51e79b098..8886beba7 100644 --- a/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h @@ -107,8 +107,8 @@ public: 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(const wchar_t *Title, const wchar_t *Text, int iPad, unsigned int uiMaxChars, int( *Func)(void *,const bool), void *lpParam, C_4JInput::EKeyboardMode eMode); void GetText(uint16_t *UTF16String); diff --git a/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Profile.h b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Profile.h index 4e6fc606c..7fd928c94 100644 --- a/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Profile.h +++ b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Profile.h @@ -100,7 +100,7 @@ public: // 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/Platform/Windows64/4JLibs/inc/4J_Render.h b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Render.h index ac84ac97d..b5c2d6c9e 100644 --- a/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Render.h +++ b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Render.h @@ -18,8 +18,8 @@ public: 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 diff --git a/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h index 22486cbf9..cc4dc87ac 100644 --- a/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h +++ b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h @@ -239,7 +239,7 @@ public: // 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,25 +296,25 @@ public: 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++ - // 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 std::wstring &Filename); // unsigned int CRC(unsigned char *buf, int len); diff --git a/Minecraft.Client/Platform/Windows64/Windows64_App.cpp b/Minecraft.Client/Platform/Windows64/Windows64_App.cpp index 41382f270..1838c6f95 100644 --- a/Minecraft.Client/Platform/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Platform/Windows64/Windows64_App.cpp @@ -52,7 +52,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // From CScene_Main::RunPlayGame Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -81,7 +81,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/Platform/Windows64/Windows64_App.h b/Minecraft.Client/Platform/Windows64/Windows64_App.h index f15afd928..bccded1a6 100644 --- a/Minecraft.Client/Platform/Windows64/Windows64_App.h +++ b/Minecraft.Client/Platform/Windows64/Windows64_App.h @@ -25,7 +25,7 @@ public: // 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/Platform/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp index 06a0aa2d0..f90b5bd95 100644 --- a/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp @@ -386,16 +386,16 @@ void MemPixStuff(); 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) @@ -457,7 +457,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"; @@ -487,7 +487,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { CW_USEDEFAULT, 0, wr.right - wr.left, // width of the window wr.bottom - wr.top, // height of the window - NULL, NULL, hInstance, NULL); + nullptr, nullptr, hInstance, nullptr); if (!g_hWnd) { return FALSE; @@ -591,7 +591,7 @@ HRESULT InitDevice() { driverTypeIndex++) { g_driverType = driverTypes[driverTypeIndex]; hr = D3D11CreateDeviceAndSwapChain( - NULL, g_driverType, NULL, createDeviceFlags, featureLevels, + nullptr, g_driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext); if (HRESULT_SUCCEEDED(hr)) break; @@ -599,7 +599,7 @@ HRESULT InitDevice() { if (FAILED(hr)) 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; @@ -619,7 +619,7 @@ HRESULT InitDevice() { descDepth.CPUAccessFlags = 0; descDepth.MiscFlags = 0; hr = - g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer); + g_pd3dDevice->CreateTexture2D(&descDepth, nullptr, &g_pDepthStencilBuffer); D3D11_DEPTH_STENCIL_VIEW_DESC descDSView; descDSView.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; @@ -629,7 +629,7 @@ HRESULT InitDevice() { hr = g_pd3dDevice->CreateDepthStencilView( g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView); - hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, + hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &g_pRenderTargetView); pBackBuffer->Release(); if (FAILED(hr)) return hr; @@ -793,7 +793,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // Sleep(10000); 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); continue; @@ -847,7 +847,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())); } else { MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->tick(nullptr, 0.0f); MemSect(0); pMinecraft->textures->tick(true, false); if (app.GetReallyChangingSessionType()) { diff --git a/Minecraft.Client/Platform/Windows64/Windows64_UIController.cpp b/Minecraft.Client/Platform/Windows64/Windows64_UIController.cpp index 257176a9b..87388425f 100644 --- a/Minecraft.Client/Platform/Windows64/Windows64_UIController.cpp +++ b/Minecraft.Client/Platform/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/Platform/Windows64/XML/ATGXmlParser.h b/Minecraft.Client/Platform/Windows64/XML/ATGXmlParser.h index 75142e3e3..12f597372 100644 --- a/Minecraft.Client/Platform/Windows64/XML/ATGXmlParser.h +++ b/Minecraft.Client/Platform/Windows64/XML/ATGXmlParser.h @@ -138,7 +138,7 @@ private: 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/Platform/stubs.h b/Minecraft.Client/Platform/stubs.h index 9841637ca..622d3dc9e 100644 --- a/Minecraft.Client/Platform/stubs.h +++ b/Minecraft.Client/Platform/stubs.h @@ -220,14 +220,14 @@ class File; class ZipFile { public: ZipFile(File* file) {} - InputStream* getInputStream(ZipEntry* entry) { return NULL; } - ZipEntry* getEntry(const std::wstring& name) { return NULL; } + InputStream* getInputStream(ZipEntry* entry) { return nullptr; } + ZipEntry* getEntry(const std::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/Player/EntityTracker.cpp b/Minecraft.Client/Player/EntityTracker.cpp index 901054c14..94faeae4e 100644 --- a/Minecraft.Client/Player/EntityTracker.cpp +++ b/Minecraft.Client/Player/EntityTracker.cpp @@ -71,7 +71,7 @@ void EntityTracker::addEntity(std::shared_ptr e) { addEntity(e, 16 * 5, 3, false); else if (e->instanceof(eTYPE_BAT)) addEntity(e, 16 * 5, 3, false); - else if (std::dynamic_pointer_cast(e) != NULL) + else if (std::dynamic_pointer_cast(e) != nullptr) addEntity(e, 16 * 5, 3, true); else if (e->instanceof(eTYPE_ENDERDRAGON)) addEntity(e, 16 * 10, 3, true); @@ -159,9 +159,9 @@ void EntityTracker::tick() { std::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++) { @@ -169,9 +169,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; } @@ -181,7 +181,7 @@ void EntityTracker::tick() { for (unsigned int i = 0; i < movedPlayers.size(); i++) { std::shared_ptr player = movedPlayers[i]; - if (player->connection == NULL) continue; + if (player->connection == nullptr) continue; for (AUTO_VAR(it, entities.begin()); it != entities.end(); it++) { std::shared_ptr te = *it; if (te->e != player) { diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index 56049fef4..90cb94336 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -83,11 +83,11 @@ LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user, 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() ); // check to see if this player's xuid is in the list of special players @@ -96,7 +96,7 @@ LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user, customTextureUrl = pMojangData->wchSkin; } } - input = NULL; + input = nullptr; m_iPad = -1; m_iScreenSection = C4JRender::VIEWPORT_TYPE_FULLSCREEN; // assume singleplayer default @@ -125,7 +125,7 @@ LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user, } LocalPlayer::~LocalPlayer() { - if (this->input != NULL) delete input; + if (this->input != nullptr) delete input; } void LocalPlayer::calculateFlight(float xa, float ya, float za) { @@ -205,9 +205,9 @@ void LocalPlayer::aiStep() { oPortalTime = portalTime; if (isInsidePortal) { 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) { minecraft->soundEngine->playUI(eSoundType_PORTAL_TRIGGER, 1, @@ -543,7 +543,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 @@ -772,7 +772,7 @@ void LocalPlayer::hurtTo(float newHealth, ETelemetryChallenges damageSource) { int deathTime = (int)(level->getGameTime() % Level::TICKS_PER_DAY) / 1000; int carriedId = - inventory->getSelected() == NULL ? 0 : inventory->getSelected()->id; + inventory->getSelected() == nullptr ? 0 : inventory->getSelected()->id; TelemetryManager->RecordPlayerDiedOrFailed(GetXboxPad(), 0, y, 0, 0, carriedId, 0, damageSource); @@ -801,7 +801,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()) { Achievement* ach = (Achievement*)stat; @@ -1183,7 +1183,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() { return jumpRidingScale; } @@ -1195,7 +1195,7 @@ bool LocalPlayer::hasPermission(EGameCommand command) { } void LocalPlayer::onCrafted(std::shared_ptr item) { - if (minecraft->localgameModes[m_iPad] != NULL) { + if (minecraft->localgameModes[m_iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)minecraft->localgameModes[m_iPad]; gameMode->getTutorial()->onCrafted(item); @@ -1253,13 +1253,13 @@ 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 && + if (down && minecraft->hitResult != nullptr && minecraft->hitResult->type == HitResult::TILE && button == 0) { int x = minecraft->hitResult->x; int y = minecraft->hitResult->y; @@ -1445,7 +1445,7 @@ bool LocalPlayer::handleMouseClick(int button) { // 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; std::shared_ptr mplp = @@ -1456,13 +1456,13 @@ 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; } std::shared_ptr oldItem = inventory->getSelected(); - if (minecraft->hitResult == NULL) { + if (minecraft->hitResult == nullptr) { if (button == 0 && minecraft->localgameModes[GetXboxPad()]->hasMissTime()) missTime = 10; @@ -1508,7 +1508,7 @@ bool LocalPlayer::handleMouseClick(int button) { } } else { std::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, @@ -1522,7 +1522,7 @@ bool LocalPlayer::handleMouseClick(int button) { // app.DebugPrintf("Player %d is swinging\n",GetXboxPad()); swing(); } - if (item == NULL) { + if (item == nullptr) { return false; } @@ -1538,7 +1538,7 @@ bool LocalPlayer::handleMouseClick(int button) { if (mayUse && button == 1) { std::shared_ptr item = inventory->getSelected(); - if (item != NULL) { + if (item != nullptr) { if (minecraft->gameMode->useItem( minecraft->localplayers[GetXboxPad()], level, item)) { minecraft->gameRenderer->itemInHandRenderer->itemUsed(); @@ -1551,16 +1551,16 @@ bool LocalPlayer::handleMouseClick(int button) { void LocalPlayer::updateRichPresence() { if ((m_iPad != -1) /* && !ui.GetMenuDisplayed(m_iPad)*/) { std::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); } else if (this->dimension == -1) { app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_NETHER); @@ -1590,11 +1590,11 @@ float LocalPlayer::getAndResetChangeDimensionTimer() { } void LocalPlayer::handleCollectItem(std::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) { unsigned int quantity = inventory->items[k]->GetCount(); diff --git a/Minecraft.Client/Player/MultiPlayerGameMode.cpp b/Minecraft.Client/Player/MultiPlayerGameMode.cpp index bbd7e2a91..99ba16e67 100644 --- a/Minecraft.Client/Player/MultiPlayerGameMode.cpp +++ b/Minecraft.Client/Player/MultiPlayerGameMode.cpp @@ -65,9 +65,9 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) { } if (localPlayerMode->isCreative()) { - if (minecraft->player->getCarriedItem() != NULL && + if (minecraft->player->getCarriedItem() != nullptr && dynamic_cast( - minecraft->player->getCarriedItem()->getItem()) != NULL) { + minecraft->player->getCarriedItem()->getItem()) != nullptr) { return false; } } @@ -75,7 +75,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, @@ -91,7 +91,7 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) { if (!localPlayerMode->isCreative()) { std::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) { minecraft->player->removeSelectedItem(); @@ -201,7 +201,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) { minecraft->player, minecraft->player->level, x, y, z); if (destroyTicks % 4 == 0) { - if (tile != NULL) { + if (tile != nullptr) { int iStepSound = tile->soundType->getStepSound(); minecraft->soundEngine->play( @@ -247,8 +247,8 @@ void MultiPlayerGameMode::tick() { bool MultiPlayerGameMode::sameDestroyTarget(int x, int y, int z) { std::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 && ItemInstance::tagMatches(selected, destroyingItem) && (selected->isDamageableItem() || @@ -283,7 +283,7 @@ bool MultiPlayerGameMode::useItemOn(std::shared_ptr player, float clickZ = (float)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])) { if (bTestUseOnly) { @@ -313,16 +313,16 @@ bool MultiPlayerGameMode::useItemOn(std::shared_ptr player, } } - if (!didSomething && item != NULL && + 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 so the following never gets executed but the packet still gets + // 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)) { if (localPlayerMode->isCreative()) { int aux = item->getAuxValue(); @@ -394,8 +394,8 @@ bool MultiPlayerGameMode::useItem(std::shared_ptr player, Level* level, } else { int oldCount = item->count; std::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) { @@ -467,7 +467,7 @@ void MultiPlayerGameMode::handleCreativeModeItemAdd( void MultiPlayerGameMode::handleCreativeModeItemDrop( std::shared_ptr clicked) { - if (localPlayerMode->isCreative() && clicked != NULL) { + if (localPlayerMode->isCreative() && clicked != nullptr) { connection->send(std::shared_ptr( new SetCreativeModeSlotPacket(-1, clicked))); } diff --git a/Minecraft.Client/Player/MultiPlayerGameMode.h b/Minecraft.Client/Player/MultiPlayerGameMode.h index becc93ce5..1343cceb7 100644 --- a/Minecraft.Client/Player/MultiPlayerGameMode.h +++ b/Minecraft.Client/Player/MultiPlayerGameMode.h @@ -48,7 +48,7 @@ public: virtual bool useItemOn(std::shared_ptr player, Level* level, std::shared_ptr item, int x, int y, int z, int face, Vec3* hit, - bool bTestUseOnly = false, bool* pbUsedItem = NULL); + bool bTestUseOnly = false, bool* pbUsedItem = nullptr); virtual bool useItem(std::shared_ptr player, Level* level, std::shared_ptr item, bool bTestUseOnly = false); @@ -80,5 +80,5 @@ public: // 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/Player/MultiPlayerLocalPlayer.cpp b/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp index 54e00b811..ca5d90dc9 100644 --- a/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp +++ b/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp @@ -149,7 +149,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( std::shared_ptr(new MovePlayerPacket::PosRot( xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying))); @@ -221,7 +221,7 @@ void MultiplayerLocalPlayer::actuallyHurt(DamageSource* source, float dmg) { // 4J Added override to capture event for tutorial messages 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 = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; Tutorial* tutorial = gameMode->getTutorial(); @@ -232,7 +232,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 = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; Tutorial* tutorial = gameMode->getTutorial(); @@ -244,7 +244,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 = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; Tutorial* tutorial = gameMode->getTutorial(); @@ -255,7 +255,7 @@ void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance* effect, void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance* effect) { Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[m_iPad] != NULL) { + if (pMinecraft->localgameModes[m_iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; Tutorial* tutorial = gameMode->getTutorial(); @@ -287,7 +287,7 @@ void MultiplayerLocalPlayer::hurtTo(float newHealth, } void MultiplayerLocalPlayer::awardStat(Stat* stat, byteArray param) { - if (stat == NULL) { + if (stat == nullptr) { delete[] param.data; return; } @@ -301,7 +301,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); } else delete[] param.data; @@ -328,9 +328,9 @@ void MultiplayerLocalPlayer::sendOpenInventory() { } void MultiplayerLocalPlayer::ride(std::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) { @@ -340,7 +340,7 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr e) { if (isRiding) { ETelemetryChallenges eventType = eTelemetryChallenges_Unknown; - if (this->riding != NULL) { + if (this->riding != nullptr) { switch (riding->GetType()) { case eTYPE_BOAT: eventType = eTelemetryInGame_Ride_Boat; @@ -363,7 +363,7 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr e) { Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft->localgameModes[m_iPad] != NULL) { + if (pMinecraft->localgameModes[m_iPad] != nullptr) { TutorialMode* gameMode = (TutorialMode*)pMinecraft->localgameModes[m_iPad]; if (wasRiding && !isRiding) { diff --git a/Minecraft.Client/Player/RemotePlayer.cpp b/Minecraft.Client/Player/RemotePlayer.cpp index 86f3e993d..f437ca8b1 100644 --- a/Minecraft.Client/Player/RemotePlayer.cpp +++ b/Minecraft.Client/Player/RemotePlayer.cpp @@ -52,7 +52,7 @@ void RemotePlayer::tick() { walkAnimPos += walkAnimSpeed; if (!hasStartedUsingItem && isUsingItemFlag() && - inventory->items[inventory->selected] != NULL) { + inventory->items[inventory->selected] != nullptr) { std::shared_ptr item = inventory->items[inventory->selected]; startUsingItem(inventory->items[inventory->selected], diff --git a/Minecraft.Client/Player/ServerPlayer.cpp b/Minecraft.Client/Player/ServerPlayer.cpp index 6780660a2..154dfa113 100644 --- a/Minecraft.Client/Player/ServerPlayer.cpp +++ b/Minecraft.Client/Player/ServerPlayer.cpp @@ -103,7 +103,7 @@ ServerPlayer::ServerPlayer(MinecraftServer* server, Level* level, } attemptCount++; playerNear = - (level->getNearestPlayer(xx + 0.5, yy, zz + 0.5, 3) != NULL); + (level->getNearestPlayer(xx + 0.5, yy, zz + 0.5, 3) != nullptr); } while ((waterDepth > 1) && (!playerNear) && (attemptCount < 20)); xx = xx2; yy = yy2; @@ -184,7 +184,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); DataInputStream dis(&bais); @@ -199,12 +199,12 @@ 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(); } @@ -292,7 +292,7 @@ void ServerPlayer::doTickA() { for (unsigned int i = 0; i < inventory->getContainerSize(); i++) { std::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 @@ -307,7 +307,7 @@ void ServerPlayer::doTickA() { ->getUpdatePacket(ie, level, std::dynamic_pointer_cast( shared_from_this()))); - if (packet != NULL) { + if (packet != nullptr) { connection->send(packet); } } @@ -344,7 +344,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { } } - // if (nearest != NULL) // 4J - removed as we don't have + // if (nearest != nullptr) // 4J - removed as we don't have // references here if (nearestValid) { bool okToSend = false; @@ -368,7 +368,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { // canSendToPlayer, // connection->countDelayedPackets(), // g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages( - // NULL, true ), + // nullptr, true ), // connection->done); // } @@ -376,7 +376,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { (canSendToPlayer && (connection->countDelayedPackets() < 4) && (g_NetworkManager.GetHostPlayer() - ->GetSendQueueSizeMessages(NULL, true) < 4) && + ->GetSendQueueSizeMessages(nullptr, true) < 4) && //(tickCount - lastBrupSendTickCount) > //(connection->getNetworkPlayer()->GetCurrentRtt()>>4) && !connection->done)) { @@ -619,7 +619,7 @@ void ServerPlayer::die(DamageSource* source) { } std::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); } @@ -636,11 +636,11 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, float dmg) { 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. + // sometimes nullptr. std::shared_ptr source = dmgSource->getDirectEntity(); if (source->instanceof @@ -650,10 +650,10 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, float dmg) { return false; } - if ((source != NULL) && source->instanceof (eTYPE_ARROW)) { + if ((source != nullptr) && source->instanceof (eTYPE_ARROW)) { std::shared_ptr arrow = std::dynamic_pointer_cast(source); - if ((arrow->owner != NULL) && arrow->owner->instanceof + if ((arrow->owner != nullptr) && arrow->owner->instanceof (eTYPE_PLAYER) && !canHarmPlayer( std::dynamic_pointer_cast(arrow->owner))) { @@ -684,7 +684,7 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, float dmg) { m_lastDamageSource = eTelemetryPlayerDeathSource_Cactus; else { std::shared_ptr source = dmgSource->getEntity(); - if (source != NULL) { + if (source != nullptr) { switch (source->GetType()) { case eTYPE_PLAYER: case eTYPE_SERVERPLAYER: @@ -724,11 +724,11 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, float dmg) { break; case eTYPE_ARROW: if ((std::dynamic_pointer_cast(source))->owner != - NULL) { + nullptr) { std::shared_ptr attacker = (std::dynamic_pointer_cast(source)) ->owner; - if (attacker != NULL) { + if (attacker != nullptr) { switch (attacker->GetType()) { case eTYPE_SKELETON: m_lastDamageSource = @@ -771,7 +771,7 @@ bool ServerPlayer::canHarmPlayer(std::wstring targetName) { std::shared_ptr owner = server->getPlayers()->getPlayer(targetName); - if (owner != NULL) { + if (owner != nullptr) { if ((shared_from_this() != owner) && canHarmPlayer(owner)) canHarm = false; } else { @@ -805,7 +805,7 @@ void ServerPlayer::changeDimension(int i) { app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex()); } - if (thisPlayer != NULL) { + if (thisPlayer != nullptr) { for (AUTO_VAR(it, MinecraftServer::getInstance() ->getPlayers() ->players.begin()); @@ -815,7 +815,7 @@ void ServerPlayer::changeDimension(int i) { std::shared_ptr servPlayer = *it; INetworkPlayer* checkPlayer = servPlayer->connection->getNetworkPlayer(); - if (thisPlayer != checkPlayer && checkPlayer != NULL && + if (thisPlayer != checkPlayer && checkPlayer != nullptr && thisPlayer->IsSameSystem(checkPlayer) && !servPlayer->wonGame) { servPlayer->wonGame = true; @@ -834,7 +834,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; } @@ -855,9 +855,9 @@ void ServerPlayer::changeDimension(int i) { // 4J Added delay param void ServerPlayer::broadcast(std::shared_ptr te, bool delay /*= false*/) { - if (te != NULL) { + if (te != nullptr) { std::shared_ptr p = te->getUpdatePacket(); - if (p != NULL) { + if (p != nullptr) { p->shouldDelay = delay; if (delay) connection->queueSend(p); @@ -897,7 +897,7 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, 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(std::shared_ptr e) { @@ -923,7 +923,7 @@ void ServerPlayer::doCheckFallDamage(double ya, bool onGround) { void ServerPlayer::openTextEdit(std::shared_ptr sign) { std::shared_ptr signTE = std::dynamic_pointer_cast(sign); - if (signTE != NULL) { + if (signTE != nullptr) { signTE->setAllowedPlayerEditor( std::dynamic_pointer_cast(shared_from_this())); connection->send( @@ -965,7 +965,7 @@ bool ServerPlayer::openFireworks(int x, int y, int z) { containerMenu = new FireworksMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); - } else if (dynamic_cast(containerMenu) != NULL) { + } else if (dynamic_cast(containerMenu) != nullptr) { closeContainer(); nextContainerCounter(); @@ -1190,7 +1190,7 @@ bool ServerPlayer::openTrading(std::shared_ptr traderTarget, MerchantRecipeList* offers = traderTarget->getOffers( std::dynamic_pointer_cast(shared_from_this())); - if (offers != NULL) { + if (offers != nullptr) { ByteArrayOutputStream rawOutput; DataOutputStream output(&rawOutput); @@ -1304,7 +1304,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; this->jumping = jumping; @@ -1313,7 +1313,7 @@ void ServerPlayer::setPlayerInput(float xxa, float yya, bool jumping, } void ServerPlayer::awardStat(Stat* stat, byteArray param) { - if (stat == NULL) { + if (stat == nullptr) { delete[] param.data; return; } @@ -1329,7 +1329,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); } @@ -1633,7 +1633,7 @@ void ServerPlayer::startUsingItem(std::shared_ptr instance, int duration) { Player::startUsingItem(instance, duration); - if (instance != NULL && instance->getItem() != NULL && + if (instance != nullptr && instance->getItem() != nullptr && instance->getItem()->getUseAnimation(instance) == UseAnim_eat) { getLevel()->getTracker()->broadcastAndSend( shared_from_this(), @@ -1688,7 +1688,7 @@ void ServerPlayer::magicCrit(std::shared_ptr entity) { } void ServerPlayer::onUpdateAbilities() { - if (connection == NULL) return; + if (connection == nullptr) return; connection->send(std::shared_ptr( new PlayerAbilitiesPacket(&abilities))); } @@ -1788,7 +1788,7 @@ int ServerPlayer::getPlayerViewDistanceModifier() { if (!connection->isLocal()) { INetworkPlayer* player = connection->getNetworkPlayer(); - if (player != NULL) { + if (player != nullptr) { int rtt = player->GetCurrentRtt(); value = rtt >> 6; @@ -1801,7 +1801,7 @@ int ServerPlayer::getPlayerViewDistanceModifier() { } void ServerPlayer::handleCollectItem(std::shared_ptr item) { - if (gameMode->getGameRules() != NULL) + if (gameMode->getGameRules() != nullptr) gameMode->getGameRules()->onCollectItem(item); } diff --git a/Minecraft.Client/Player/ServerPlayerGameMode.cpp b/Minecraft.Client/Player/ServerPlayerGameMode.cpp index 9da479e6f..f00ed0335 100644 --- a/Minecraft.Client/Player/ServerPlayerGameMode.cpp +++ b/Minecraft.Client/Player/ServerPlayerGameMode.cpp @@ -28,11 +28,11 @@ 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) { @@ -93,7 +93,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; @@ -202,12 +202,12 @@ 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); } return changed; @@ -221,9 +221,9 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z) { } if (gameModeForPlayer->isCreative()) { - if (player->getCarriedItem() != NULL && + if (player->getCarriedItem() != nullptr && dynamic_cast(player->getCarriedItem()->getItem()) != - NULL) { + nullptr) { return false; } } @@ -287,7 +287,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z) { } else { std::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) { player->removeSelectedItem(); @@ -309,7 +309,7 @@ bool ServerPlayerGameMode::useItem(std::shared_ptr player, Level* level, int oldAux = item->getAuxValue(); std::shared_ptr itemInstance = item->use(level, player); if (itemInstance != item || - (itemInstance != NULL && (itemInstance->count != oldCount || + (itemInstance != nullptr && (itemInstance->count != oldCount || itemInstance->getUseDuration() > 0 || itemInstance->getAuxValue() != oldAux))) { player->inventory->items[player->inventory->selected] = itemInstance; @@ -338,21 +338,21 @@ bool ServerPlayerGameMode::useItemOn(std::shared_ptr player, bool bTestUseOnOnly, bool* pbUsedItem) { // 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])) { if (bTestUseOnOnly) { if (Tile::tiles[t]->TestUse()) return true; } else { 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(); int count = item->count; @@ -371,6 +371,6 @@ void ServerPlayerGameMode::setLevel(ServerLevel* newLevel) { level = 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/Player/ServerPlayerGameMode.h b/Minecraft.Client/Player/ServerPlayerGameMode.h index 74440c69a..c414defcb 100644 --- a/Minecraft.Client/Player/ServerPlayerGameMode.h +++ b/Minecraft.Client/Player/ServerPlayerGameMode.h @@ -58,7 +58,7 @@ public: bool useItemOn(std::shared_ptr player, Level* level, std::shared_ptr item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, - bool bTestUseOnOnly = false, bool* pbUsedItem = NULL); + bool bTestUseOnOnly = false, bool* pbUsedItem = nullptr); void setLevel(ServerLevel* newLevel); }; \ No newline at end of file diff --git a/Minecraft.Client/Player/TrackedEntity.cpp b/Minecraft.Client/Player/TrackedEntity.cpp index b7d96a3e1..e03156314 100644 --- a/Minecraft.Client/Player/TrackedEntity.cpp +++ b/Minecraft.Client/Player/TrackedEntity.cpp @@ -63,7 +63,7 @@ void TrackedEntity::tick(EntityTracker* tracker, } if (lastRidingEntity != e->riding || - (e->riding != NULL && + (e->riding != nullptr && tickCount % (SharedConstants::TICKS_PER_SECOND * 3) == 0)) { lastRidingEntity = e->riding; broadcast(std::shared_ptr(new SetEntityLinkPacket( @@ -76,7 +76,7 @@ void TrackedEntity::tick(EntityTracker* tracker, std::dynamic_pointer_cast(e); std::shared_ptr item = frame->getItem(); - if (item != NULL && item->getItem()->id == Item::map_Id && + if (item != nullptr && item->getItem()->id == Item::map_Id && !e->removed) { std::shared_ptr data = Item::map->getSavedData(item, e->level); @@ -89,7 +89,7 @@ void TrackedEntity::tick(EntityTracker* tracker, player->connection->countDelayedPackets() <= 5) { std::shared_ptr packet = Item::map->getUpdatePacket(item, e->level, player); - if (packet != NULL) player->connection->send(packet); + if (packet != nullptr) player->connection->send(packet); } } } @@ -110,7 +110,7 @@ void TrackedEntity::tick(EntityTracker* tracker, int yRota = yRotn - yRotp; int xRota = xRotn - xRotp; - if (e->riding == NULL) { + if (e->riding == nullptr) { teleportDelay++; int xn = Mth::floor(e->x * 32.0); @@ -281,7 +281,7 @@ void TrackedEntity::tick(EntityTracker* tracker, } } - if (packet != NULL) { + if (packet != nullptr) { broadcast(packet); } @@ -384,14 +384,14 @@ void TrackedEntity::broadcast(std::shared_ptr packet) { if (sentTo.size()) { INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer(); - if (thisPlayer == NULL) { + if (thisPlayer == nullptr) { dontSend = true; } else { for (unsigned int j = 0; j < sentTo.size(); j++) { std::shared_ptr player2 = sentTo[j]; INetworkPlayer* otherPlayer = player2->connection->getNetworkPlayer(); - if (otherPlayer != NULL && + if (otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer)) { dontSend = true; // #ifdef _DEBUG @@ -399,7 +399,7 @@ void TrackedEntity::broadcast(std::shared_ptr packet) { // emp= // std::dynamic_pointer_cast // (packet); - // if(emp!=NULL) + // if(emp!=nullptr) // { // app.DebugPrintf("Not // sending this SetEntityMotionPacket to player - @@ -435,7 +435,7 @@ void TrackedEntity::broadcastAndSend(std::shared_ptr packet) { e->instanceof(eTYPE_SERVERPLAYER) ? std::dynamic_pointer_cast(e) : nullptr; - if (sp != NULL && sp->connection) { + if (sp != nullptr && sp->connection) { sp->connection->send(packet); } } @@ -503,7 +503,7 @@ TrackedEntity::eVisibility TrackedEntity::isVisible( INetworkPlayer* otherPlayer = ep->connection->getNetworkPlayer(); - if (otherPlayer != NULL && + 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 @@ -530,7 +530,7 @@ TrackedEntity::eVisibility TrackedEntity::isVisible( // 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); } else if (canBeSeenBy && bVisible) return eVisibility_SeenAndVisible; @@ -562,11 +562,11 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker, "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 = - std::dynamic_pointer_cast(packet) != NULL; + std::dynamic_pointer_cast(packet) != nullptr; // 4J Stu brought forward to fix when Item Frames if (!e->getEntityData()->isEmpty() && !isAddMobPacket) { @@ -595,13 +595,13 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker, new SetEntityMotionPacket(e->entityId, e->xd, e->yd, e->zd))); } - if (e->riding != NULL) { + if (e->riding != nullptr) { sp->connection->send( std::shared_ptr(new SetEntityLinkPacket( SetEntityLinkPacket::RIDING, e, e->riding))); } if (e->instanceof(eTYPE_MOB) && - std::dynamic_pointer_cast(e)->getLeashHolder() != NULL) { + std::dynamic_pointer_cast(e)->getLeashHolder() != nullptr) { sp->connection->send( std::shared_ptr(new SetEntityLinkPacket( SetEntityLinkPacket::LEASH, e, @@ -612,7 +612,7 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker, for (int i = 0; i < 5; i++) { std::shared_ptr item = std::dynamic_pointer_cast(e)->getCarried(i); - if (item != NULL) + if (item != nullptr) sp->connection->send(std::shared_ptr( new SetEquippedItemPacket(e->entityId, i, item))); } @@ -680,7 +680,7 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { } // 4J-PB - replacing with a switch, rather than tons of ifs - if (std::dynamic_pointer_cast(e) != NULL) { + if (std::dynamic_pointer_cast(e) != nullptr) { yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); return std::shared_ptr( new AddMobPacket(std::dynamic_pointer_cast(e), yRotp, xRotp, @@ -698,7 +698,7 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { PlayerUID xuid = INVALID_XUID; PlayerUID OnlineXuid = INVALID_XUID; - if (player != NULL) { + if (player != nullptr) { xuid = player->getXuid(); OnlineXuid = player->getOnlineXuid(); } @@ -726,14 +726,14 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { std::dynamic_pointer_cast(e)->owner; return std::shared_ptr( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, - owner != NULL ? owner->entityId : e->entityId, + owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp)); } else if (e->instanceof(eTYPE_ARROW)) { std::shared_ptr owner = (std::dynamic_pointer_cast(e))->owner; return std::shared_ptr( new AddEntityPacket(e, AddEntityPacket::ARROW, - owner != NULL ? owner->entityId : e->entityId, + owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp)); } else if (e->instanceof(eTYPE_SNOWBALL)) { return std::shared_ptr(new AddEntityPacket( @@ -768,7 +768,7 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { std::shared_ptr fb = std::dynamic_pointer_cast(e); std::shared_ptr aep = nullptr; - if (fb->owner != NULL) { + if (fb->owner != nullptr) { aep = std::shared_ptr(new AddEntityPacket( e, type, fb->owner->entityId, yRotp, xRotp, xp, yp, zp)); } else { diff --git a/Minecraft.Client/Rendering/Chunk.cpp b/Minecraft.Client/Rendering/Chunk.cpp index e2716cb5f..25621e9ce 100644 --- a/Minecraft.Client/Rendering/Chunk.cpp +++ b/Minecraft.Client/Rendering/Chunk.cpp @@ -197,7 +197,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 = @@ -742,7 +742,7 @@ void Chunk::reset() { void Chunk::_delete() { reset(); - level = NULL; + level = nullptr; } int Chunk::getList(int layer) { diff --git a/Minecraft.Client/Rendering/EntityRenderers/ChestRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ChestRenderer.cpp index 80bac57e1..8d33aa0a2 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ChestRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ChestRenderer.cpp @@ -49,7 +49,7 @@ void ChestRenderer::render(std::shared_ptr _chest, double x, Tile* tile = chest->getTile(); data = chest->getData(); - if (dynamic_cast(tile) != NULL && data == 0) { + if (dynamic_cast(tile) != nullptr && data == 0) { ((ChestTile*)tile) ->recalcLockDir(chest->getLevel(), chest->x, chest->y, chest->z); @@ -58,10 +58,10 @@ void ChestRenderer::render(std::shared_ptr _chest, double x, 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; if (chest->getType() == ChestTile::TYPE_TRAP) { @@ -102,23 +102,23 @@ void ChestRenderer::render(std::shared_ptr _chest, double x, 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); } glRotatef(rot, 0, 1, 0); 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; diff --git a/Minecraft.Client/Rendering/EntityRenderers/DefaultRenderer.h b/Minecraft.Client/Rendering/EntityRenderers/DefaultRenderer.h index bcf5b42a8..81449a59f 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/DefaultRenderer.h +++ b/Minecraft.Client/Rendering/EntityRenderers/DefaultRenderer.h @@ -6,6 +6,6 @@ public: virtual void render(std::shared_ptr entity, double x, double y, double z, float rot, float a); virtual ResourceLocation* getTextureLocation(std::shared_ptr mob) { - return NULL; + return nullptr; }; }; \ No newline at end of file diff --git a/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.cpp index e96104861..f71c07234 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.cpp @@ -102,7 +102,7 @@ void EnderDragonRenderer::render(std::shared_ptr _mob, double x, std::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; hh = (hh * hh + hh) * 0.2f; diff --git a/Minecraft.Client/Rendering/EntityRenderers/EntityRenderDispatcher.cpp b/Minecraft.Client/Rendering/EntityRenderers/EntityRenderDispatcher.cpp index 264e80488..916d3c0f3 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/EntityRenderDispatcher.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/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() { instance = new EntityRenderDispatcher(); @@ -284,7 +284,7 @@ void EntityRenderDispatcher::render(std::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); renderer->render(entity, x, y, z, rot, a); diff --git a/Minecraft.Client/Rendering/EntityRenderers/EntityRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/EntityRenderer.cpp index 86c76a334..f98c8881c 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/EntityRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/EntityRenderer.cpp @@ -18,7 +18,7 @@ ResourceLocation EntityRenderer::SHADOW_LOCATION = // 4J - added EntityRenderer::EntityRenderer() { - model = NULL; + model = nullptr; tileRenderer = new TileRenderer(); shadowRadius = 0; shadowStrength = 1.0f; @@ -101,7 +101,7 @@ void EntityRenderer::renderFlame(std::shared_ptr e, double x, double y, int ss = 0; t->begin(); while (h > 0) { - Icon* tex = NULL; + Icon* tex = nullptr; if (ss % 2 == 0) { tex = fire1; } else { @@ -393,5 +393,5 @@ void EntityRenderer::registerTerrainTextures(IconRegister* iconRegister) {} ResourceLocation* EntityRenderer::getTextureLocation( std::shared_ptr mob) { - return NULL; + return nullptr; } diff --git a/Minecraft.Client/Rendering/EntityRenderers/FallingTileRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/FallingTileRenderer.cpp index 83544880c..a89a08cd7 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/FallingTileRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/FallingTileRenderer.cpp @@ -57,7 +57,7 @@ void FallingTileRenderer::render(std::shared_ptr _tile, double x, Mth::floor(tile->z)); 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), diff --git a/Minecraft.Client/Rendering/EntityRenderers/FishingHookRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/FishingHookRenderer.cpp index 1bd178e64..b07539ca4 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/FishingHookRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/FishingHookRenderer.cpp @@ -54,7 +54,7 @@ void FishingHookRenderer::render(std::shared_ptr _hook, double x, glDisable(GL_RESCALE_NORMAL); 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/Rendering/EntityRenderers/HumanoidMobRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/HumanoidMobRenderer.cpp index fb461b221..b1f94d370 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/HumanoidMobRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/HumanoidMobRenderer.cpp @@ -18,8 +18,8 @@ std::map void HumanoidMobRenderer::_init(HumanoidModel* humanoidModel, float scale) { this->humanoidModel = humanoidModel; this->_scale = scale; - armorParts1 = NULL; - armorParts2 = NULL; + armorParts1 = nullptr; + armorParts2 = nullptr; createArmorParts(); } @@ -83,9 +83,9 @@ ResourceLocation* HumanoidMobRenderer::getArmorLocation(ArmorItem* armorItem, void HumanoidMobRenderer::prepareSecondPassArmor( std::shared_ptr mob, int layer, float a) { std::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)); @@ -107,9 +107,9 @@ int HumanoidMobRenderer::prepareArmor(std::shared_ptr _mob, std::dynamic_pointer_cast(_mob); std::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)); @@ -181,13 +181,13 @@ void HumanoidMobRenderer::render(std::shared_ptr _mob, double x, ResourceLocation* HumanoidMobRenderer::getTextureLocation( std::shared_ptr mob) { // TODO -- Figure out of we need some data in here - return NULL; + return nullptr; } void HumanoidMobRenderer::prepareCarriedItem( std::shared_ptr mob, std::shared_ptr item) { armorParts1->holdingRightHand = armorParts2->holdingRightHand = - humanoidModel->holdingRightHand = item != NULL ? 1 : 0; + humanoidModel->holdingRightHand = item != nullptr ? 1 : 0; armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking = mob->isSneaking(); } @@ -200,7 +200,7 @@ void HumanoidMobRenderer::additionalRendering(std::shared_ptr mob, std::shared_ptr item = mob->getCarriedItem(); std::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) @@ -211,7 +211,7 @@ void HumanoidMobRenderer::additionalRendering(std::shared_ptr mob, humanoidModel->head->translateTo(1 / 16.0f); if (headGear->getItem()->id < 256) { - if (Tile::tiles[headGear->id] != NULL && + if (Tile::tiles[headGear->id] != nullptr && TileRenderer::canRender( Tile::tiles[headGear->id]->getRenderShape())) { float s = 10 / 16.0f; @@ -240,7 +240,7 @@ void HumanoidMobRenderer::additionalRendering(std::shared_ptr mob, } } - if (item != NULL) { + if (item != nullptr) { glPushMatrix(); if (model->young) { diff --git a/Minecraft.Client/Rendering/EntityRenderers/ItemFrameRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ItemFrameRenderer.cpp index 1db85e589..9d46d6e63 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ItemFrameRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ItemFrameRenderer.cpp @@ -120,7 +120,7 @@ void ItemFrameRenderer::drawItem(std::shared_ptr entity) { Minecraft* pMinecraft = Minecraft::GetInstance(); std::shared_ptr instance = entity->getItem(); - if (instance == NULL) return; + if (instance == nullptr) return; std::shared_ptr itemEntity = std::shared_ptr( new ItemEntity(entity->level, 0, 0, 0, instance)); @@ -165,7 +165,7 @@ void ItemFrameRenderer::drawItem(std::shared_ptr entity) { std::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/Rendering/EntityRenderers/ItemInHandRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ItemInHandRenderer.cpp index b17bffd3e..c7b1bf6cd 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ItemInHandRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ItemInHandRenderer.cpp @@ -231,7 +231,7 @@ void ItemInHandRenderer::renderItem(std::shared_ptr mob, // 4J - code borrowed from render method below, although not factoring in // brightness as that should already be being taken into account by texture // lighting. This is for colourising things held in 3rd person view. - if ((setColor) && (item != NULL)) { + if ((setColor) && (item != nullptr)) { int col = Item::items[item->id]->getColor(item, 0); float red = ((col >> 16) & 0xff) / 255.0f; float g = ((col >> 8) & 0xff) / 255.0f; @@ -242,7 +242,7 @@ void ItemInHandRenderer::renderItem(std::shared_ptr mob, glPushMatrix(); Tile* tile = Tile::tiles[item->id]; - if (item->getIconType() == Icon::TYPE_TERRAIN && tile != NULL && + if (item->getIconType() == Icon::TYPE_TERRAIN && tile != nullptr && TileRenderer::canRender(tile->getRenderShape())) { MemSect(31); minecraft->textures->bindTexture( @@ -257,7 +257,7 @@ void ItemInHandRenderer::renderItem(std::shared_ptr mob, } else { MemSect(31); Icon* icon = mob->getItemInHandIcon(item, layer); - if (icon == NULL) { + if (icon == nullptr) { glPopMatrix(); MemSect(0); return; @@ -308,7 +308,7 @@ void ItemInHandRenderer::renderItem(std::shared_ptr mob, renderItem3D(t, u0, v0, u1, v1, icon->getSourceWidth(), 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); minecraft->textures->bindTexture(&ENCHANT_GLINT_LOCATION); @@ -453,7 +453,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; float g = ((col >> 8) & 0xff) / 255.0f; @@ -464,7 +464,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; @@ -578,13 +578,13 @@ void ItemInHandRenderer::render(float a) { std::shared_ptr data = Item::map->getSavedData(item, minecraft->level); PIXBeginNamedEvent(0, "Minimap render"); - if (data != NULL) + 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; @@ -793,7 +793,7 @@ void ItemInHandRenderer::renderScreenEffect(float a) { } } - if (Tile::tiles[tile] != NULL) + if (Tile::tiles[tile] != nullptr) renderTex(a, Tile::tiles[tile]->getTexture(2)); } @@ -943,10 +943,10 @@ void ItemInHandRenderer::tick() { 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 && + if (nextTile != nullptr && selectedItem != nullptr && nextTile != selectedItem && nextTile->id == selectedItem->id && nextTile->getAuxValue() == selectedItem->getAuxValue()) { selectedItem = nextTile; diff --git a/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp index 4662c2632..6ec3c8286 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp @@ -52,7 +52,7 @@ void ItemRenderer::render(std::shared_ptr _itemEntity, double x, random->setSeed(187); std::shared_ptr item = itemEntity->getItem(); - if (item->getItem() == NULL) return; + if (item->getItem() == nullptr) return; glPushMatrix(); float bob = @@ -72,7 +72,7 @@ void ItemRenderer::render(std::shared_ptr _itemEntity, double x, Tile* tile = Tile::tiles[item->id]; - if (item->getIconType() == Icon::TYPE_TERRAIN && tile != NULL && + if (item->getIconType() == Icon::TYPE_TERRAIN && tile != nullptr && TileRenderer::canRender(tile->getRenderShape())) { glRotatef(spin, 0, 1, 0); @@ -181,7 +181,7 @@ void ItemRenderer::renderItemBillboard(std::shared_ptr entity, float red, float green, float blue) { Tesselator* t = Tesselator::getInstance(); - if (icon == NULL) + if (icon == nullptr) icon = entityRenderDispatcher->textures->getMissingIcon( entity->getItem()->getIconType()); float u0 = icon->getU0(); @@ -238,7 +238,7 @@ void ItemRenderer::renderItemBillboard(std::shared_ptr entity, bool bIsTerrain = false; if (item->getIconType() == Icon::TYPE_TERRAIN && - Tile::tiles[item->id] != NULL) { + Tile::tiles[item->id] != nullptr) { bIsTerrain = true; bindTexture(&TextureAtlas::LOCATION_BLOCKS); // TODO: Do this // sanely by Icon @@ -255,7 +255,7 @@ void ItemRenderer::renderItemBillboard(std::shared_ptr entity, 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); entityRenderDispatcher->textures->bindTexture( @@ -408,7 +408,7 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, } MemSect(0); - if (itemIcon == NULL) { + if (itemIcon == nullptr) { itemIcon = textures->getMissingIcon(item->getIconType()); } @@ -444,7 +444,7 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, void ItemRenderer::renderAndDecorateItem( Font* font, Textures* textures, const std::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); } @@ -458,7 +458,7 @@ void ItemRenderer::renderAndDecorateItem( Font* font, Textures* textures, const std::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; } @@ -578,7 +578,7 @@ void ItemRenderer::renderGuiItemDecorations(Font* font, Textures* textures, int x, int y, const std::wstring& countText, float fAlpha) { - if (item == NULL) { + if (item == nullptr) { return; } diff --git a/Minecraft.Client/Rendering/EntityRenderers/ItemSpriteRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ItemSpriteRenderer.cpp index 79171fc78..e530b1b2f 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ItemSpriteRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ItemSpriteRenderer.cpp @@ -24,7 +24,7 @@ void ItemSpriteRenderer::render(std::shared_ptr e, double x, double y, // 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/Rendering/EntityRenderers/LivingEntityRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp index 33e7ba4ab..820f6f24e 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp @@ -16,7 +16,7 @@ int LivingEntityRenderer::MAX_ARMOR_LAYERS = 4; LivingEntityRenderer::LivingEntityRenderer(Model* model, float shadow) { this->model = model; shadowRadius = shadow; - armor = NULL; + armor = nullptr; } void LivingEntityRenderer::setArmor(Model* armor) { this->armor = armor; } @@ -37,11 +37,11 @@ void LivingEntityRenderer::render(std::shared_ptr _mob, double x, 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*/ { @@ -426,7 +426,7 @@ bool LivingEntityRenderer::shouldShowName(std::shared_ptr mob) { return Minecraft::renderNames() && mob != entityRenderDispatcher->cameraEntity && !mob->isInvisibleTo(Minecraft::GetInstance()->player) && - mob->rider.lock() == NULL; + mob->rider.lock() == nullptr; } void LivingEntityRenderer::renderNameTags(std::shared_ptr mob, diff --git a/Minecraft.Client/Rendering/EntityRenderers/MinecartRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/MinecartRenderer.cpp index 5868a654e..82f808e09 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/MinecartRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/MinecartRenderer.cpp @@ -80,7 +80,7 @@ void MinecartRenderer::render(std::shared_ptr _cart, double x, double y, Tile* tile = cart->getDisplayTile(); int tileData = cart->getDisplayData(); - if (tile != NULL) { + if (tile != nullptr) { glPushMatrix(); bindTexture(&TextureAtlas::LOCATION_BLOCKS); diff --git a/Minecraft.Client/Rendering/EntityRenderers/MobRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/MobRenderer.cpp index 8055bab43..838892f99 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/MobRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/MobRenderer.cpp @@ -31,7 +31,7 @@ void MobRenderer::renderLeash(std::shared_ptr entity, double x, double y, double z, float rot, float a) { std::shared_ptr roper = entity->getLeashHolder(); // roper = entityRenderDispatcher.cameraEntity; - if (roper != NULL) { + if (roper != nullptr) { glColor4f(1.0f, 1.0f, 1.0f, 1.0f); y -= (1.6 - entity->bbHeight) * .5; diff --git a/Minecraft.Client/Rendering/EntityRenderers/MobSpawnerRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/MobSpawnerRenderer.cpp index 1787410d6..6207ee94b 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/MobSpawnerRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/MobSpawnerRenderer.cpp @@ -22,7 +22,7 @@ void MobSpawnerRenderer::render(BaseMobSpawner* spawner, double x, double y, glTranslatef((float)x + 0.5f, (float)y, (float)z + 0.5f); std::shared_ptr e = spawner->getDisplayEntity(); - if (e != NULL) { + if (e != nullptr) { e->setLevel(spawner->getLevel()); float s = 7 / 16.0f; glTranslatef(0, 0.4f, 0); diff --git a/Minecraft.Client/Rendering/EntityRenderers/PistonPieceRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/PistonPieceRenderer.cpp index 77fe5f46a..903091602 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/PistonPieceRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/PistonPieceRenderer.cpp @@ -11,7 +11,7 @@ ResourceLocation PistonPieceRenderer::SIGN_LOCATION = ResourceLocation(TN_ITEM_SIGN); -PistonPieceRenderer::PistonPieceRenderer() { tileRenderer = NULL; } +PistonPieceRenderer::PistonPieceRenderer() { tileRenderer = nullptr; } void PistonPieceRenderer::render(std::shared_ptr _entity, double x, double y, double z, float a, bool setColor, @@ -22,7 +22,7 @@ void PistonPieceRenderer::render(std::shared_ptr _entity, double x, std::dynamic_pointer_cast(_entity); Tile* tile = Tile::tiles[entity->getId()]; - if (tile != NULL && + 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 diff --git a/Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp index 804672296..7c3dcd83b 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp @@ -59,7 +59,7 @@ int PlayerRenderer::prepareArmor(std::shared_ptr _player, std::shared_ptr itemInstance = player->inventory->getArmor(3 - layer); - if (itemInstance != NULL) { + if (itemInstance != nullptr) { Item* item = itemInstance->getItem(); if (dynamic_cast(item)) { ArmorItem* armorItem = dynamic_cast(item); @@ -77,9 +77,9 @@ int PlayerRenderer::prepareArmor(std::shared_ptr _player, 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 @@ -113,7 +113,7 @@ void PlayerRenderer::prepareSecondPassArmor( std::shared_ptr player = std::dynamic_pointer_cast(_player); std::shared_ptr itemInstance = player->inventory->getArmor(3 - layer); - if (itemInstance != NULL) { + if (itemInstance != nullptr) { Item* item = itemInstance->getItem(); if (dynamic_cast(item)) { ArmorItem* armorItem = dynamic_cast(item); @@ -138,8 +138,8 @@ void PlayerRenderer::render(std::shared_ptr _mob, double x, double y, std::shared_ptr item = mob->inventory->getSelected(); armorParts1->holdingRightHand = armorParts2->holdingRightHand = - humanoidModel->holdingRightHand = item != NULL ? 1 : 0; - if (item != NULL) { + humanoidModel->holdingRightHand = item != nullptr ? 1 : 0; + if (item != nullptr) { if (mob->getUseItemDuration() > 0) { UseAnim anim = item->getUseAnimation(); if (anim == UseAnim_block) { @@ -152,7 +152,7 @@ void PlayerRenderer::render(std::shared_ptr _mob, double x, double y, } } // 4J added, for 3rd person view of eating - if (item != NULL && mob->getUseItemDuration() > 0 && + 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 @@ -198,7 +198,7 @@ void PlayerRenderer::render(std::shared_ptr _mob, double x, double y, std::vector* pAdditionalModelParts = mob->GetAdditionalModelParts(); // turn them on - if (pAdditionalModelParts != NULL) { + if (pAdditionalModelParts != nullptr) { for (AUTO_VAR(it, pAdditionalModelParts->begin()); it != pAdditionalModelParts->end(); ++it) { ModelPart* pModelPart = *it; @@ -240,7 +240,7 @@ void PlayerRenderer::additionalRendering(std::shared_ptr _mob, std::shared_ptr mob = std::dynamic_pointer_cast(_mob); std::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()); @@ -280,7 +280,7 @@ void PlayerRenderer::additionalRendering(std::shared_ptr _mob, } // need to add a custom texture for deadmau5 - if (mob != NULL && app.isXuidDeadmau5(mob->getXuid()) && + if (mob != nullptr && app.isXuidDeadmau5(mob->getXuid()) && bindTexture(mob->customTextureUrl, L"")) { for (int i = 0; i < 2; i++) { float yr = (mob->yRotO + (mob->yRot - mob->yRotO) * a) - @@ -352,12 +352,12 @@ boolean b2 = !mob->isCapeHidden();*/ std::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 = std::shared_ptr(new ItemInstance(Item::stick)); } @@ -504,7 +504,7 @@ void PlayerRenderer::renderShadow(std::shared_ptr e, double x, double y, double z, float pow, float a) { if (app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) > 0) { std::shared_ptr player = std::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/Rendering/EntityRenderers/SkullTileRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/SkullTileRenderer.cpp index 71a8265c7..22fc1763b 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/SkullTileRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/SkullTileRenderer.cpp @@ -6,7 +6,7 @@ #include "../../../Minecraft.World/Headers/net.minecraft.h" #include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h" -SkullTileRenderer* SkullTileRenderer::instance = NULL; +SkullTileRenderer* SkullTileRenderer::instance = nullptr; ResourceLocation SkullTileRenderer::SKELETON_LOCATION = ResourceLocation(TN_MOB_SKELETON); diff --git a/Minecraft.Client/Rendering/EntityRenderers/SnowManRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/SnowManRenderer.cpp index 06cae1fef..3394d7d10 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/SnowManRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/SnowManRenderer.cpp @@ -25,7 +25,7 @@ void SnowManRenderer::additionalRendering(std::shared_ptr _mob, MobRenderer::additionalRendering(mob, a); std::shared_ptr headGear = std::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/Rendering/EntityRenderers/TileEntityRenderDispatcher.cpp b/Minecraft.Client/Rendering/EntityRenderers/TileEntityRenderDispatcher.cpp index 4568dc500..4c51405e2 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/TileEntityRenderDispatcher.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/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; @@ -26,9 +26,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; @@ -44,7 +44,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); @@ -56,13 +56,13 @@ TileEntityRenderDispatcher::TileEntityRenderDispatcher() { } TileEntityRenderer* TileEntityRenderDispatcher::getRenderer(eINSTANCEOF e) { - TileEntityRenderer* r = NULL; + TileEntityRenderer* r = nullptr; // TileEntityRenderer *r = renderers[e]; AUTO_VAR(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 @@ -84,12 +84,12 @@ TileEntityRenderer* TileEntityRenderDispatcher::getRenderer(eINSTANCEOF e) { } bool TileEntityRenderDispatcher::hasRenderer(std::shared_ptr e) { - return getRenderer(e) != NULL; + return getRenderer(e) != nullptr; } TileEntityRenderer* TileEntityRenderDispatcher::getRenderer( std::shared_ptr e) { - if (e == NULL) return NULL; + if (e == nullptr) return nullptr; return getRenderer(e->GetType()); } @@ -135,7 +135,7 @@ void TileEntityRenderDispatcher::render(std::shared_ptr entity, 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/Rendering/EntityRenderers/TileEntityRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/TileEntityRenderer.cpp index e265a5e8c..97d660a73 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/TileEntityRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/TileEntityRenderer.cpp @@ -4,13 +4,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 std::wstring& urlTexture, ResourceLocation* location) { Textures* t = tileEntityRenderDispatcher->textures; - if (t != NULL) + if (t != nullptr) t->bind(t->loadHttpTexture(urlTexture, location->getTexture())); } diff --git a/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp index 90d2e0854..550296b45 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp @@ -20,7 +20,7 @@ bool TileRenderer::fancy = true; const float smallUV = (1.0f / 16.0f); void TileRenderer::_init() { - fixedTexture = NULL; + fixedTexture = nullptr; xFlipTexture = false; noCulling = false; applyAmbienceOcclusion = false; @@ -45,7 +45,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) { @@ -173,7 +173,7 @@ TileRenderer::TileRenderer(LevelSource* level) { } TileRenderer::TileRenderer() { - this->level = NULL; + this->level = nullptr; _init(); } @@ -181,11 +181,11 @@ void TileRenderer::setFixedTexture(Icon* fixedTexture) { this->fixedTexture = fixedTexture; } -void TileRenderer::clearFixedTexture() { this->fixedTexture = NULL; } +void TileRenderer::clearFixedTexture() { this->fixedTexture = nullptr; } bool TileRenderer::hasFixedTexture() { - return fixedTexture != NULL; + return fixedTexture != nullptr; } void TileRenderer::setShape(float x0, float y0, float z0, float x1, float y1, @@ -881,7 +881,7 @@ bool TileRenderer::tesselateFlowerPotInWorld(FlowerPotTile* tt, int x, int y, float xOff = 0; float yOff = 4; float zOff = 0; - Tile* plant = NULL; + Tile* plant = nullptr; switch (type) { case FlowerPotTile::TYPE_FLOWER_RED: @@ -900,7 +900,7 @@ bool TileRenderer::tesselateFlowerPotInWorld(FlowerPotTile* tt, int x, int y, t->addOffset(xOff / 16.0f, yOff / 16.0f, zOff / 16.0f); - if (plant != NULL) { + if (plant != nullptr) { tesselateInWorld(plant, x, y, z); } else { if (type == FlowerPotTile::TYPE_CACTUS) { @@ -3245,7 +3245,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; edgeTex = fixedTexture; @@ -5123,7 +5123,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( // 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) { uniformTex = getTexture(tt, level, pX, pY, pZ, 0); @@ -5174,7 +5174,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Tesselator* t = Tesselator::getInstance(); t->tex2(0xf000f); - if (uniformTex == NULL) { + if (uniformTex == nullptr) { if (getTexture(tt)->getFlags() == Icon::IS_GRASS_TOP) tintSides = false; } else if (hasFixedTexture()) { tintSides = false; @@ -8330,7 +8330,7 @@ Icon* TileRenderer::getTexture(Tile* tile) { } Icon* TileRenderer::getTextureOrMissing(Icon* icon) { - if (icon == NULL) + if (icon == nullptr) return minecraft->textures->getMissingIcon(Icon::TYPE_TERRAIN); diff --git a/Minecraft.Client/Rendering/EntityRenderers/WitchRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/WitchRenderer.cpp index ca5aafab4..2c25af985 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/WitchRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/WitchRenderer.cpp @@ -17,7 +17,7 @@ void WitchRenderer::render(std::shared_ptr entity, double x, double y, std::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(std::shared_ptr entity, std::shared_ptr item = mob->getCarriedItem(); - if (item != NULL) { + if (item != nullptr) { glPushMatrix(); if (model->young) { diff --git a/Minecraft.Client/Rendering/EntityRenderers/ZombieRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ZombieRenderer.cpp index e3ed0cb03..46c79e157 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ZombieRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ZombieRenderer.cpp @@ -15,11 +15,11 @@ ZombieRenderer::ZombieRenderer() 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/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 979d578c1..4a7a93601 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -109,8 +109,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(); @@ -141,7 +141,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 @@ -171,7 +171,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"); m_updateThread->SetProcessor(CPU_CORE_CHUNK_UPDATE); m_updateThread->Run(); #endif @@ -179,8 +179,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 @@ -209,7 +209,7 @@ void GameRenderer::tick(bool first) // 4J - add bFirst accumulatedSmoothYO = 0; } - if (mc->cameraTargetPlayer == NULL) { + if (mc->cameraTargetPlayer == nullptr) { mc->cameraTargetPlayer = std::dynamic_pointer_cast(mc->player); } @@ -247,8 +247,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; @@ -279,7 +279,7 @@ void GameRenderer::pick(float a) { if ((hitx < minxz) || (hitx > maxxz) || (hitz < minxz) || (hitz > maxxz)) { delete mc->hitResult; - mc->hitResult = NULL; + mc->hitResult = nullptr; } } @@ -293,7 +293,7 @@ void GameRenderer::pick(float a) { range = dist; } - if (mc->hitResult != NULL) { + if (mc->hitResult != nullptr) { dist = mc->hitResult->pos.distanceTo(from); } @@ -323,7 +323,7 @@ void GameRenderer::pick(float a) { hovered = e; nearest = 0; } - } else if (p != NULL) { + } else if (p != nullptr) { double dd = from.distanceTo(p->pos); std::shared_ptr ridingEntity = mc->cameraTargetPlayer->riding; @@ -341,9 +341,9 @@ void GameRenderer::pick(float a) { delete p; } - if (hovered != NULL) { - if (nearest < dist || (mc->hitResult == NULL)) { - if (mc->hitResult != NULL) delete mc->hitResult; + if (hovered != nullptr) { + if (nearest < dist || (mc->hitResult == nullptr)) { + if (mc->hitResult != nullptr) delete mc->hitResult; mc->hitResult = new HitResult(hovered); if (hovered->instanceof(eTYPE_LIVINGENTITY)) { mc->crosshairPickMob = @@ -521,7 +521,7 @@ void GameRenderer::moveCameraToPlayer(float a) { Vec3 a(x + xo, y + yo, z + zo); Vec3 b(x - xd + xo, y - yd + yo, z - zd + zo); HitResult* hr = mc->level->clip(&a, &b); - if (hr != NULL) { + if (hr != nullptr) { Vec3 p(x, y, z); double dist = hr->pos.distanceTo(p); if (dist < cameraDist) cameraDist = dist; @@ -681,7 +681,7 @@ void GameRenderer::renderItemInHand(float a, int eye) { // 4J-PB - to turn off the hand for screenshots, but not when the item held // is a map - if (localplayer != NULL) { + if (localplayer != nullptr) { std::shared_ptr item = localplayer->inventory->getSelected(); if (!(item && item->getItem()->id == Item::map_Id) && @@ -844,7 +844,7 @@ void GameRenderer::updateLightTexture(float a) { // Loop over all the players std::shared_ptr player = Minecraft::GetInstance()->localplayers[j]; - if (player == NULL) continue; + if (player == nullptr) continue; if (!s_lightTexDirty[j]) continue; s_lightTexDirty[j] = false; @@ -1003,7 +1003,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 #ifndef ENABLE_VSYNC || mc->options->framerateLimit == 3 @@ -1016,9 +1016,9 @@ void GameRenderer::render(float a, bool bFirst) { lastNsTime = System::nanoTime(); - if (!mc->options->hideGui || mc->screen != NULL) { + if (!mc->options->hideGui || mc->screen != nullptr) { FRAME_PROFILE_SCOPE(UIHud); - mc->gui->render(a, mc->screen != NULL, xMouse, yMouse); + mc->gui->render(a, mc->screen != nullptr, xMouse, yMouse); } } else { glViewport(0, 0, mc->width, mc->height); @@ -1031,11 +1031,11 @@ void GameRenderer::render(float a, bool bFirst) { lastNsTime = System::nanoTime(); } - if (mc->screen != NULL) { + if (mc->screen != nullptr) { FRAME_PROFILE_SCOPE(UIHud); glClear(GL_DEPTH_BUFFER_BIT); mc->screen->render(xMouse, yMouse, a); - if (mc->screen != NULL && mc->screen->particles != NULL) + if (mc->screen != nullptr && mc->screen->particles != nullptr) mc->screen->particles->render(a); } } @@ -1197,7 +1197,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { bool updateChunks = (mc->player == mc->localplayers[ProfileManager.GetPrimaryPad()]); - // if (mc->cameraTargetPlayer == NULL) // 4J - removed condition as we + // 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; @@ -1352,7 +1352,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { PIXEndNamedEvent(); turnOffLightLayer(a); // 4J - brought forward from 1.8.2 - if ((mc->hitResult != NULL) && + if ((mc->hitResult != nullptr) && cameraEntity->isUnderLiquid(Material::water) && cameraEntity->instanceof( eTYPE_PLAYER)) //&& !mc->options.hideGui) @@ -1440,7 +1440,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { if ((zoom == 1) && cameraEntity->instanceof(eTYPE_PLAYER)) //&& !mc->options.hideGui) { - if (mc->hitResult != NULL && + if (mc->hitResult != nullptr && !cameraEntity->isUnderLiquid(Material::water)) { std::shared_ptr player = std::dynamic_pointer_cast(cameraEntity); @@ -1601,7 +1601,7 @@ void GameRenderer::renderSnowAndRain(float a) { turnOnLightLayer(a); - if (rainXa == NULL) { + if (rainXa == nullptr) { rainXa = new float[32 * 32]; rainZa = new float[32 * 32]; @@ -1873,7 +1873,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; fg = fg * (1 - d) + c[1] * d; diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index da8d28fa8..05111a503 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -127,11 +127,11 @@ const int LevelRenderer::DIMENSION_OFFSETS[3] = { #endif 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; @@ -157,7 +157,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 + // sortedChunks[i] = nullptr; // 4J - removed - not sorting // our chunks anymore chunks[i] = ClipChunkArray(); lastPlayerCount[i] = 0; @@ -339,7 +339,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]; @@ -357,11 +357,11 @@ 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; @@ -376,24 +376,24 @@ 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++) { chunks[playerIndex][i].chunk->_delete(); 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 + // 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 + // level to nullptr if (playerIndex == ProfileManager.GetPrimaryPad()) { EnterCriticalSection(&m_csRenderableTileEntities); renderableTileEntities.clear(); @@ -429,7 +429,7 @@ void LevelRenderer::allChanged(int playerIndex) { // called then (on 360 at least) we can get a deadlock when starting a game // in splitscreen. // EnterCriticalSection(&m_csDirtyChunks); - if (level[playerIndex] == NULL) { + if (level[playerIndex] == nullptr) { return; } @@ -450,7 +450,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++) { chunks[playerIndex][i].chunk->_delete(); delete chunks[playerIndex][i].chunk; @@ -474,7 +474,7 @@ void LevelRenderer::allChanged(int playerIndex) { 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 + // level to nullptr). Apart from that, the chunk rebuilding is responsible for // maintaining this // renderableTileEntities.clear(); @@ -502,9 +502,9 @@ void LevelRenderer::allChanged(int playerIndex) { } nonStackDirtyChunksAdded(); - if (level[playerIndex] != NULL) { + if (level[playerIndex] != nullptr) { std::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(), @@ -584,7 +584,7 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) { // Render the mob if the mob's leash holder is within the culler if (!shouldRender && entity->instanceof(eTYPE_MOB)) { std::shared_ptr mob = std::dynamic_pointer_cast(entity); - if (mob->isLeashed() && (mob->getLeashHolder() != NULL)) { + if (mob->isLeashed() && (mob->getLeashHolder() != nullptr)) { std::shared_ptr leashHolder = mob->getLeashHolder(); shouldRender = culler->isVisible(&leashHolder->bb); } @@ -757,7 +757,7 @@ int LevelRenderer::render(std::shared_ptr player, int layer, int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) { int playerIndex = mc->player->GetXboxPad(); - if (chunks[playerIndex].data == NULL) return 0; + if (chunks[playerIndex].data == nullptr) return 0; mc->gameRenderer->turnOnLightLayer(alpha); std::shared_ptr player = mc->cameraTargetPlayer; double xOff = player->xOld + (player->x - player->xOld) * alpha; @@ -947,7 +947,7 @@ void LevelRenderer::renderSky(float alpha) { float* c = level[playerIndex]->dimension->getSunriseColor( level[playerIndex]->getTimeOfDay(alpha), alpha); - if (c != NULL) { + if (c != nullptr) { glDisable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); @@ -1709,7 +1709,7 @@ bool LevelRenderer::updateDirtyChunks() { } 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 @@ -1783,14 +1783,14 @@ 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 + // 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 std::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 = (int)player->x; @@ -1920,7 +1920,7 @@ bool LevelRenderer::updateDirtyChunks() { } } - Chunk* chunk = NULL; + Chunk* chunk = nullptr; #if defined(_LARGE_WORLDS) if (!nearestClipChunks.empty()) { int index = 0; @@ -2114,7 +2114,7 @@ void LevelRenderer::renderHit(std::shared_ptr player, HitResult* h, ((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); @@ -2167,8 +2167,8 @@ void LevelRenderer::renderDestroyAnimation(Tesselator* t, 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 @@ -2294,7 +2294,7 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, // 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); @@ -2320,7 +2320,7 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, // 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. We + // 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 @@ -2389,11 +2389,11 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, } 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, @@ -2821,7 +2821,7 @@ void LevelRenderer::playSoundExceptPlayer(std::shared_ptr player, 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) +if (mc == nullptr || mc->cameraTargetPlayer == nullptr || mc->particleEngine == nullptr) return; double xd = mc->cameraTargetPlayer->x - x; @@ -2876,8 +2876,8 @@ void LevelRenderer::addParticle(ePARTICLE_TYPE eParticleType, double x, std::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; } @@ -2915,7 +2915,7 @@ std::shared_ptr LevelRenderer::addParticleInternal( } // 4J - this is a bit of hack to get communication through from the level - // itself, but if Minecraft::animateTickLevel is NULL then we are to behave + // 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 @@ -2923,7 +2923,7 @@ std::shared_ptr LevelRenderer::addParticleInternal( // 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; double yd = 0.0f; @@ -2935,7 +2935,7 @@ std::shared_ptr LevelRenderer::addParticleInternal( bool inRange = false; for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { std::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; zd = thisPlayer->z - z; @@ -3180,7 +3180,7 @@ std::shared_ptr LevelRenderer::addParticleInternal( } } - if (particle != NULL) { + if (particle != nullptr) { mc->particleEngine->add(particle); } @@ -3235,7 +3235,7 @@ void LevelRenderer::globalLevelEvent(int type, int sourceX, int sourceY, switch (type) { 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; double dy = sourceY - mc->cameraTargetPlayer->y; @@ -3271,7 +3271,7 @@ void LevelRenderer::levelEvent(std::shared_ptr source, int type, int x, switch (type) { // 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; double dy = y - mc->cameraTargetPlayer->y; @@ -3380,7 +3380,7 @@ void LevelRenderer::levelEvent(std::shared_ptr source, int type, int x, std::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, @@ -3410,7 +3410,7 @@ void LevelRenderer::levelEvent(std::shared_ptr source, int type, int x, std::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((float)dist); } @@ -3492,7 +3492,7 @@ void LevelRenderer::levelEvent(std::shared_ptr source, int type, int x, 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); } else { // 4J-PB - only play streaming music if there isn't already some @@ -3500,7 +3500,7 @@ void LevelRenderer::levelEvent(std::shared_ptr source, int type, int x, // started playing already if (!mc->soundEngine->GetIsPlayingStreamingGameMusic()) { level[playerIndex]->playStreamingMusic( - L"", x, y, z); // 4J - used to pass NULL, but using + L"", x, y, z); // 4J - used to pass nullptr, but using // empty string here now instead } } @@ -3585,12 +3585,12 @@ void LevelRenderer::destroyTileProgress(int id, int x, int y, int z, } // destroyingBlocks.remove(id); } else { - BlockDestructionProgress* entry = NULL; + BlockDestructionProgress* entry = nullptr; AUTO_VAR(it, destroyingBlocks.find(id)); if (it != destroyingBlocks.end()) entry = it->second; - if (entry == NULL || entry->getX() != x || entry->getY() != y || + if (entry == nullptr || entry->getX() != x || entry->getY() != y || entry->getZ() != z) { entry = new BlockDestructionProgress(id, x, y, z); destroyingBlocks.insert( @@ -3923,7 +3923,7 @@ void LevelRenderer::DestroyedTileManager::destroyingTileAt(Level* level, int x, (float)(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/Rendering/Minimap.cpp b/Minecraft.Client/Rendering/Minimap.cpp index 3b8170557..2765562fc 100644 --- a/Minecraft.Client/Rendering/Minimap.cpp +++ b/Minecraft.Client/Rendering/Minimap.cpp @@ -148,11 +148,11 @@ void Minimap::render(std::shared_ptr player, Textures* textures, } #endif - // 4J Stu - For item frame renders, the player is NULL. We do not want + // 4J Stu - For item frame renders, the player is nullptr. We do not want // to show player icons on the frames. - if (player == NULL && (imgIndex != 12)) + if (player == nullptr && (imgIndex != 12)) continue; - else if (player != NULL && imgIndex == 12) + else if (player != nullptr && imgIndex == 12) continue; else if (imgIndex == 12 && dec->entityId != entityId) continue; @@ -194,11 +194,11 @@ void Minimap::render(std::shared_ptr player, Textures* textures, char imgIndex = dec->img; imgIndex -= 16; - // 4J Stu - For item frame renders, the player is NULL. We do not want + // 4J Stu - For item frame renders, the player is nullptr. We do not want // to show player icons on the frames. - if (player == NULL && (imgIndex != 12)) + if (player == nullptr && (imgIndex != 12)) continue; - else if (player != NULL && imgIndex == 12) + else if (player != nullptr && imgIndex == 12) continue; else if (imgIndex == 12 && dec->entityId != entityId) continue; @@ -241,7 +241,7 @@ void Minimap::render(std::shared_ptr player, Textures* textures, // #else // 4J Stu - TU-1 hotfix // DCR: Render the players current position here instead - if (player != NULL) { + if (player != nullptr) { wchar_t playerPosText[32]; ZeroMemory(&playerPosText, sizeof(wchar_t) * 32); int posx = floor(player->x); diff --git a/Minecraft.Client/Rendering/Models/HumanoidModel.cpp b/Minecraft.Client/Rendering/Models/HumanoidModel.cpp index 926fe5195..6734b8388 100644 --- a/Minecraft.Client/Rendering/Models/HumanoidModel.cpp +++ b/Minecraft.Client/Rendering/Models/HumanoidModel.cpp @@ -7,7 +7,7 @@ // 4J added ModelPart* HumanoidModel::AddOrRetrievePart(SKIN_BOX* pBox) { - ModelPart* pAttachTo = NULL; + ModelPart* pAttachTo = nullptr; switch (pBox->ePart) { case eBodyPart_Unknown: @@ -41,10 +41,10 @@ ModelPart* HumanoidModel::AddOrRetrievePart(SKIN_BOX* pBox) { 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"); @@ -141,7 +141,7 @@ HumanoidModel::HumanoidModel(float g, float yOffset, int texWidth, void HumanoidModel::render(std::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/Rendering/Models/Model.h b/Minecraft.Client/Rendering/Models/Model.h index 59190bdf1..129eab6b5 100644 --- a/Minecraft.Client/Rendering/Models/Model.h +++ b/Minecraft.Client/Rendering/Models/Model.h @@ -30,7 +30,7 @@ public: virtual ModelPart* getRandomModelPart(Random random) { return cubes.at(random.nextInt((int)cubes.size())); } - virtual ModelPart* AddOrRetrievePart(SKIN_BOX* pBox) { return NULL; } + virtual ModelPart* AddOrRetrievePart(SKIN_BOX* pBox) { return nullptr; } void setMapTex(std::wstring id, int x, int y); TexOffs* getMapTex(std::wstring id); diff --git a/Minecraft.Client/Rendering/Models/ModelHorse.cpp b/Minecraft.Client/Rendering/Models/ModelHorse.cpp index e71ccfd2a..f036f6082 100644 --- a/Minecraft.Client/Rendering/Models/ModelHorse.cpp +++ b/Minecraft.Client/Rendering/Models/ModelHorse.cpp @@ -293,7 +293,7 @@ void ModelHorse::render(std::shared_ptr entity, float time, float r, 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) { HeadSaddle->render(scale, usecompiled); @@ -428,7 +428,7 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, 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/Rendering/Models/ModelPart.cpp b/Minecraft.Client/Rendering/Models/ModelPart.cpp index 0e8ccec9f..067331536 100644 --- a/Minecraft.Client/Rendering/Models/ModelPart.cpp +++ b/Minecraft.Client/Rendering/Models/ModelPart.cpp @@ -50,7 +50,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); } @@ -73,7 +73,7 @@ ModelPart* ModelPart::retrieveChild(SKIN_BOX* pBox) { } } - return NULL; + return nullptr; } ModelPart* ModelPart::mirror() { @@ -158,7 +158,7 @@ void ModelPart::render(float scale, bool usecompiled, } } } - // if (children != NULL) + // if (children != nullptr) { for (unsigned int i = 0; i < children.size(); i++) { children.at(i)->render(scale, usecompiled); @@ -178,7 +178,7 @@ void ModelPart::render(float scale, bool usecompiled, } } } - // if (children != NULL) + // if (children != nullptr) { for (unsigned int i = 0; i < children.size(); i++) { children.at(i)->render(scale, usecompiled); @@ -196,7 +196,7 @@ void ModelPart::render(float scale, bool usecompiled, } } } - // if (children != NULL) + // if (children != nullptr) { for (unsigned int i = 0; i < children.size(); i++) { children.at(i)->render(scale, usecompiled); diff --git a/Minecraft.Client/Rendering/Models/SlimeModel.cpp b/Minecraft.Client/Rendering/Models/SlimeModel.cpp index 91eac953d..4c8cb0afc 100644 --- a/Minecraft.Client/Rendering/Models/SlimeModel.cpp +++ b/Minecraft.Client/Rendering/Models/SlimeModel.cpp @@ -24,9 +24,9 @@ SlimeModel::SlimeModel(int vOffs) { eye1->compile(1.0f / 16.0f); mouth->compile(1.0f / 16.0f); } else { - eye0 = NULL; - eye1 = NULL; - mouth = NULL; + eye0 = nullptr; + eye1 = nullptr; + mouth = nullptr; } cube->compile(1.0f / 16.0f); } @@ -37,7 +37,7 @@ void SlimeModel::render(std::shared_ptr entity, float time, float r, 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); mouth->render(scale, usecompiled); diff --git a/Minecraft.Client/Rendering/Particles/BreakingItemParticle.cpp b/Minecraft.Client/Rendering/Particles/BreakingItemParticle.cpp index c7655ec0c..9ee928679 100644 --- a/Minecraft.Client/Rendering/Particles/BreakingItemParticle.cpp +++ b/Minecraft.Client/Rendering/Particles/BreakingItemParticle.cpp @@ -45,7 +45,7 @@ void BreakingItemParticle::render(Tesselator* t, float a, float xa, float ya, 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); v0 = tex->getV((vo / 4.0f) * SharedConstants::WORLD_RESOLUTION); diff --git a/Minecraft.Client/Rendering/Particles/FireworksParticles.cpp b/Minecraft.Client/Rendering/Particles/FireworksParticles.cpp index d891865ab..00a3c0daa 100644 --- a/Minecraft.Client/Rendering/Particles/FireworksParticles.cpp +++ b/Minecraft.Client/Rendering/Particles/FireworksParticles.cpp @@ -17,12 +17,12 @@ FireworksParticles::FireworksStarter::FireworksStarter( this->engine = engine; lifetime = 8; - if (infoTag != NULL) { + if (infoTag != nullptr) { explosions = (ListTag*)infoTag ->getList(FireworksItem::TAG_EXPLOSIONS) ->copy(); if (explosions->size() == 0) { - explosions = NULL; + explosions = nullptr; } else { lifetime = explosions->size() * 2 - 1; @@ -38,7 +38,7 @@ FireworksParticles::FireworksStarter::FireworksStarter( } } else { // 4J: - explosions = NULL; + explosions = nullptr; } } @@ -49,7 +49,7 @@ void FireworksParticles::FireworksStarter::render(Tesselator* t, float a, } void FireworksParticles::FireworksStarter::tick() { - if (life == 0 && explosions != NULL) { + if (life == 0 && explosions != nullptr) { bool farEffect = isFarAwayFromCamera(); bool largeExplosion = false; @@ -82,7 +82,7 @@ void FireworksParticles::FireworksStarter::tick() { .95f + random->nextFloat() * .1f, true, 100.0f); } - if ((life % 2) == 0 && explosions != NULL && + if ((life % 2) == 0 && explosions != nullptr && (life / 2) < explosions->size()) { int eIndex = life / 2; CompoundTag* compoundTag = explosions->get(eIndex); @@ -177,7 +177,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) { return false; } @@ -197,7 +197,7 @@ void FireworksParticles::FireworksStarter::createParticle( 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)]); } @@ -344,7 +344,7 @@ void FireworksParticles::FireworksSparkParticle::setFadeColor(int rgb) { } AABB* FireworksParticles::FireworksSparkParticle::getCollideBox() { - return NULL; + return nullptr; } bool FireworksParticles::FireworksSparkParticle::isPushable() { return false; } diff --git a/Minecraft.Client/Rendering/Particles/HugeExplosionSeedParticle.cpp b/Minecraft.Client/Rendering/Particles/HugeExplosionSeedParticle.cpp index 2bfc541be..0dad12558 100644 --- a/Minecraft.Client/Rendering/Particles/HugeExplosionSeedParticle.cpp +++ b/Minecraft.Client/Rendering/Particles/HugeExplosionSeedParticle.cpp @@ -31,7 +31,7 @@ void HugeExplosionSeedParticle::tick() { level->addParticle(eParticleType_largeexplode, xx, yy, zz, life / (float)lifeTime, 0, 0); } - Minecraft::GetInstance()->animateTickLevel = NULL; + Minecraft::GetInstance()->animateTickLevel = nullptr; life++; if (life == lifeTime) remove(); } diff --git a/Minecraft.Client/Rendering/Particles/Particle.cpp b/Minecraft.Client/Rendering/Particles/Particle.cpp index 3fa94b9d3..fb4b7f0c8 100644 --- a/Minecraft.Client/Rendering/Particles/Particle.cpp +++ b/Minecraft.Client/Rendering/Particles/Particle.cpp @@ -18,7 +18,7 @@ double Particle::zOff = 0; 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); @@ -132,7 +132,7 @@ void Particle::render(Tesselator* t, float a, float xa, float ya, float za, float v1 = v0 + 0.999f / 16.0f; float r = 0.1f * size; - if (tex != NULL) { + if (tex != nullptr) { u0 = tex->getU0(); u1 = tex->getU1(); v0 = tex->getV0(); diff --git a/Minecraft.Client/Rendering/Particles/ParticleEngine.cpp b/Minecraft.Client/Rendering/Particles/ParticleEngine.cpp index 1959ad349..12ca16013 100644 --- a/Minecraft.Client/Rendering/Particles/ParticleEngine.cpp +++ b/Minecraft.Client/Rendering/Particles/ParticleEngine.cpp @@ -17,7 +17,7 @@ ResourceLocation ParticleEngine::PARTICLES_LOCATION = ResourceLocation(TN_PARTICLES); ParticleEngine::ParticleEngine(Level* level, Textures* textures) { - // if (level != NULL) // 4J - removed - we want level to be + // if (level != nullptr) // 4J - removed - we want level to be // initialised to *something* { this->level = level; @@ -185,8 +185,8 @@ void ParticleEngine::renderLit(std::shared_ptr player, float a, 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) { + // clearing them when its game over & the level is set to nullptr + if (level == nullptr) { for (int l = 0; l < 3; l++) { for (int tt = 0; tt < TEXTURE_COUNT; tt++) { for (int list = 0; list < LIST_COUNT; list++) { diff --git a/Minecraft.Client/Rendering/Particles/PlayerCloudParticle.cpp b/Minecraft.Client/Rendering/Particles/PlayerCloudParticle.cpp index a38775947..adcbc1989 100644 --- a/Minecraft.Client/Rendering/Particles/PlayerCloudParticle.cpp +++ b/Minecraft.Client/Rendering/Particles/PlayerCloudParticle.cpp @@ -51,7 +51,7 @@ void PlayerCloudParticle::tick() { yd *= 0.96f; zd *= 0.96f; std::shared_ptr p = level->getNearestPlayer(shared_from_this(), 2); - if (p != NULL) { + if (p != nullptr) { if (y > p->bb.y0) { y += (p->bb.y0 - y) * 0.2; yd += (p->yd - yd) * 0.2; diff --git a/Minecraft.Client/Rendering/Particles/TerrainParticle.cpp b/Minecraft.Client/Rendering/Particles/TerrainParticle.cpp index 3dcff7e57..5cc4f9697 100644 --- a/Minecraft.Client/Rendering/Particles/TerrainParticle.cpp +++ b/Minecraft.Client/Rendering/Particles/TerrainParticle.cpp @@ -54,7 +54,7 @@ void TerrainParticle::render(Tesselator* t, float a, float xa, float ya, 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); v0 = tex->getV((vo / 4.0f) * SharedConstants::WORLD_RESOLUTION); diff --git a/Minecraft.Client/Textures/BufferedImage.h b/Minecraft.Client/Textures/BufferedImage.h index fbbf39283..23e82ab81 100644 --- a/Minecraft.Client/Textures/BufferedImage.h +++ b/Minecraft.Client/Textures/BufferedImage.h @@ -6,7 +6,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/Textures/ClockTexture.cpp b/Minecraft.Client/Textures/ClockTexture.cpp index 7029246a1..adecbd545 100644 --- a/Minecraft.Client/Textures/ClockTexture.cpp +++ b/Minecraft.Client/Textures/ClockTexture.cpp @@ -9,7 +9,7 @@ ClockTexture::ClockTexture() : StitchedTexture(L"clock", L"clock") { rot = rota = 0.0; - m_dataTexture = NULL; + m_dataTexture = nullptr; m_iPad = XUSER_INDEX_ANY; } @@ -24,8 +24,8 @@ 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; if (!mc->localplayers[m_iPad]->level->dimension->isNaturalDimension()) { @@ -48,7 +48,7 @@ void ClockTexture::cycleFrames() { rot += rota; // 4J Stu - We share data with another texture - if (m_dataTexture != NULL) { + if (m_dataTexture != nullptr) { int newFrame = (int)((rot + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size(); while (newFrame < 0) { @@ -77,7 +77,7 @@ int ClockTexture::getSourceWidth() const { return source->getWidth(); } int ClockTexture::getSourceHeight() const { return source->getHeight(); } int ClockTexture::getFrames() { - if (m_dataTexture == NULL) { + if (m_dataTexture == nullptr) { return StitchedTexture::getFrames(); } else { return m_dataTexture->getFrames(); @@ -85,9 +85,9 @@ int ClockTexture::getFrames() { } void ClockTexture::freeFrameTextures() { - if (m_dataTexture == NULL) { + if (m_dataTexture == nullptr) { StitchedTexture::freeFrameTextures(); } } -bool ClockTexture::hasOwnData() { return m_dataTexture == NULL; } \ No newline at end of file +bool ClockTexture::hasOwnData() { return m_dataTexture == nullptr; } \ No newline at end of file diff --git a/Minecraft.Client/Textures/CompassTexture.cpp b/Minecraft.Client/Textures/CompassTexture.cpp index 715f496e2..857ceeeb5 100644 --- a/Minecraft.Client/Textures/CompassTexture.cpp +++ b/Minecraft.Client/Textures/CompassTexture.cpp @@ -7,12 +7,12 @@ #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; @@ -29,15 +29,15 @@ CompassTexture::CompassTexture(int iPad, CompassTexture* dataTexture) 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); } } @@ -45,7 +45,7 @@ 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; double za = spawnPos->z - z; @@ -71,7 +71,7 @@ void CompassTexture::updateFromPosition(Level* level, double x, double z, } // 4J Stu - We share data with another texture - if (m_dataTexture != NULL) { + if (m_dataTexture != nullptr) { int newFrame = (int)(((rot / (PI * 2)) + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size(); @@ -103,7 +103,7 @@ int CompassTexture::getSourceWidth() const { return source->getWidth(); } int CompassTexture::getSourceHeight() const { return source->getHeight(); } int CompassTexture::getFrames() { - if (m_dataTexture == NULL) { + if (m_dataTexture == nullptr) { return StitchedTexture::getFrames(); } else { return m_dataTexture->getFrames(); @@ -111,9 +111,9 @@ int CompassTexture::getFrames() { } void CompassTexture::freeFrameTextures() { - if (m_dataTexture == NULL) { + if (m_dataTexture == nullptr) { StitchedTexture::freeFrameTextures(); } } -bool CompassTexture::hasOwnData() { return m_dataTexture == NULL; } \ No newline at end of file +bool CompassTexture::hasOwnData() { return m_dataTexture == nullptr; } \ No newline at end of file diff --git a/Minecraft.Client/Textures/MemTexture.cpp b/Minecraft.Client/Textures/MemTexture.cpp index c6e337639..3beec4a65 100644 --- a/Minecraft.Client/Textures/MemTexture.cpp +++ b/Minecraft.Client/Textures/MemTexture.cpp @@ -17,7 +17,7 @@ MemTexture::MemTexture(const std::wstring& _url, std::uint8_t* pbData, // 4J - remember to add deletes in here for any created BufferedImages when // implemented loadedImage = new BufferedImage(pbData, dataBytes); - if (processor == NULL) { + if (processor == nullptr) { } else { // loadedImage=processor.process(ImageIO.read(huc.getInputStream())); } diff --git a/Minecraft.Client/Textures/MobSkinMemTextureProcessor.cpp b/Minecraft.Client/Textures/MobSkinMemTextureProcessor.cpp index 81e0d69d0..c82be9800 100644 --- a/Minecraft.Client/Textures/MobSkinMemTextureProcessor.cpp +++ b/Minecraft.Client/Textures/MobSkinMemTextureProcessor.cpp @@ -2,7 +2,7 @@ #include "MobSkinMemTextureProcessor.h" BufferedImage* MobSkinMemTextureProcessor::process(BufferedImage* in) { - if (in == NULL) return NULL; + if (in == nullptr) return nullptr; width = 64; height = 32; @@ -10,7 +10,7 @@ BufferedImage* MobSkinMemTextureProcessor::process(BufferedImage* in) { 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/Textures/MobSkinTextureProcessor.cpp b/Minecraft.Client/Textures/MobSkinTextureProcessor.cpp index ee2962f70..ff52d1594 100644 --- a/Minecraft.Client/Textures/MobSkinTextureProcessor.cpp +++ b/Minecraft.Client/Textures/MobSkinTextureProcessor.cpp @@ -2,7 +2,7 @@ #include "MobSkinTextureProcessor.h" BufferedImage* MobSkinTextureProcessor::process(BufferedImage* in) { - if (in == NULL) return NULL; + if (in == nullptr) return nullptr; width = 64; height = 32; @@ -10,7 +10,7 @@ BufferedImage* MobSkinTextureProcessor::process(BufferedImage* in) { 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/Textures/Packs/AbstractTexturePack.cpp b/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp index a77888b66..d9e096672 100644 --- a/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp @@ -12,15 +12,15 @@ AbstractTexturePack::AbstractTexturePack(std::uint32_t id, File* file, : id(id), name(name) { // 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 @@ -52,7 +52,7 @@ InputStream* AbstractTexturePack::getResource( { 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); } @@ -67,13 +67,13 @@ InputStream* AbstractTexturePack::getResource( //} void AbstractTexturePack::unload(Textures* textures) { - if (iconImage != NULL && textureId != -1) { + if (iconImage != nullptr && textureId != -1) { textures->releaseTexture(textureId); } } void AbstractTexturePack::load(Textures* textures) { - if (iconImage != NULL) { + if (iconImage != nullptr) { if (textureId == -1) { textureId = textures->getTexture(iconImage); } @@ -89,7 +89,7 @@ bool AbstractTexturePack::hasFile(const std::wstring& name, bool allowFallback) { bool hasFile = this->hasFile(name); - return !hasFile && (allowFallback && fallback != NULL) + return !hasFile && (allowFallback && fallback != nullptr) ? fallback->hasFile(name, allowFallback) : hasFile; } @@ -178,7 +178,7 @@ void AbstractTexturePack::loadDefaultColourTable() { FileInputStream fis(coloursFile); fis.read(data, 0, dataLength); fis.close(); - if (m_colourTable != NULL) delete m_colourTable; + if (m_colourTable != nullptr) delete m_colourTable; m_colourTable = new ColourTable(data.data, dataLength); delete[] data.data; @@ -209,7 +209,7 @@ void AbstractTexturePack::unloadUI() { } std::wstring AbstractTexturePack::getXuiRootPath() { - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); // Load new skin constexpr int LOCATOR_SIZE = @@ -222,14 +222,14 @@ std::wstring AbstractTexturePack::getXuiRootPath() { } std::uint8_t* AbstractTexturePack::getPackIcon(std::uint32_t& imageBytes) { - if (m_iconSize == 0 || m_iconData == NULL) loadIcon(); + if (m_iconSize == 0 || m_iconData == nullptr) loadIcon(); imageBytes = m_iconSize; return m_iconData; } std::uint8_t* AbstractTexturePack::getPackComparison( std::uint32_t& imageBytes) { - if (m_comparisonSize == 0 || m_comparisonData == NULL) loadComparison(); + if (m_comparisonSize == 0 || m_comparisonData == nullptr) loadComparison(); imageBytes = m_comparisonSize; return m_comparisonData; diff --git a/Minecraft.Client/Textures/Packs/AbstractTexturePack.h b/Minecraft.Client/Textures/Packs/AbstractTexturePack.h index a4f1939b1..3bdd333e2 100644 --- a/Minecraft.Client/Textures/Packs/AbstractTexturePack.h +++ b/Minecraft.Client/Textures/Packs/AbstractTexturePack.h @@ -93,5 +93,5 @@ public: 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/Textures/Packs/DLCTexturePack.cpp b/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp index b3286e0da..2dbc6e0e7 100644 --- a/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp @@ -27,7 +27,7 @@ bool ReadPortableBinaryFile(File& file, std::uint8_t*& data, if (fileLength < 0 || fileLength > static_cast<__int64>(std::numeric_limits::max())) { - data = NULL; + data = nullptr; size = 0; return false; } @@ -39,7 +39,7 @@ bool ReadPortableBinaryFile(File& file, std::uint8_t*& data, if (readResult.status != PortableFileIO::BinaryReadStatus::ok || readResult.fileSize > std::numeric_limits::max()) { delete[] buffer; - data = NULL; + data = nullptr; size = 0; return false; } @@ -52,18 +52,18 @@ bool ReadPortableBinaryFile(File& file, std::uint8_t*& data, DLCTexturePack::DLCTexturePack(std::uint32_t id, DLCPack* pack, TexturePack* fallback) - : AbstractTexturePack(id, NULL, pack->getName(), 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; if (m_dlcInfoPack->doesPackContainFile( @@ -109,12 +109,12 @@ void DLCTexturePack::loadName() { texname = L""; 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"); } } else { - if (m_stringTable != NULL) { + if (m_stringTable != nullptr) { texname = m_stringTable->getString(L"IDS_DISPLAY_NAME"); } } @@ -123,7 +123,7 @@ void DLCTexturePack::loadName() { void DLCTexturePack::loadDescription() { desc1 = L""; - if (m_stringTable != NULL) { + if (m_stringTable != nullptr) { desc1 = m_stringTable->getString(L"IDS_TP_DESCRIPTION"); } } @@ -142,14 +142,14 @@ InputStream* DLCTexturePack::getResourceImplementation( // 4J Stu - We should never call this function #if !defined(_CONTENT_PACKAGE) __debugbreak(); - if (hasFile(name)) return NULL; + if (hasFile(name)) return nullptr; #endif - return NULL; // resource; + return nullptr; // resource; } bool DLCTexturePack::hasFile(const std::wstring& name) { bool hasFile = false; - if (m_dlcDataPack != NULL) + if (m_dlcDataPack != nullptr) hasFile = m_dlcDataPack->doesPackContainFile( DLCManager::e_DLCType_Texture, name); return hasFile; @@ -190,7 +190,7 @@ DLCPack* DLCTexturePack::getDLCPack() { return m_dlcDataPack; } void DLCTexturePack::loadColourTable() { // Load the game colours - if (m_dlcDataPack != NULL && + if (m_dlcDataPack != nullptr && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_ColourTable, L"colours.col")) { DLCColourTableFile* colourFile = @@ -201,7 +201,7 @@ 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; } @@ -275,11 +275,11 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, 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) { File archivePath( getFilePath(texturePack->m_dlcInfoPack->GetPackID(), std::wstring(L"media.arc"))); @@ -293,7 +293,7 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, 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) { @@ -306,7 +306,7 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, texturePack->m_dlcInfoPack->GetPackID(), dlcFile->getGrfPath())); if (grf.exists()) { - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; unsigned int fileSize = 0; if (ReadPortableBinaryFile(grf, pbData, fileSize)) { @@ -333,7 +333,7 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, getFilePath(texturePack->m_dlcInfoPack->GetPackID(), levelGen->getBaseSavePath())); if (grf.exists()) { - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; unsigned int fileSize = 0; if (ReadPortableBinaryFile(grf, pbData, fileSize)) { // 4J-PB - is it possible that we can get here @@ -414,7 +414,7 @@ void DLCTexturePack::unloadUI() { AbstractTexturePack::unloadUI(); app.m_dlcManager.removePack(m_dlcDataPack); - m_dlcDataPack = NULL; + m_dlcDataPack = nullptr; delete m_archiveFile; m_bHasLoadedData = false; @@ -423,7 +423,7 @@ void DLCTexturePack::unloadUI() { std::wstring DLCTexturePack::getXuiRootPath() { std::wstring path = L""; - if (m_dlcDataPack != NULL && + if (m_dlcDataPack != nullptr && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")) { DLCUIDataFile* dataFile = (DLCUIDataFile*)m_dlcDataPack->getFile( diff --git a/Minecraft.Client/Textures/Packs/DLCTexturePack.h b/Minecraft.Client/Textures/Packs/DLCTexturePack.h index 2d7db8443..d6508a6eb 100644 --- a/Minecraft.Client/Textures/Packs/DLCTexturePack.h +++ b/Minecraft.Client/Textures/Packs/DLCTexturePack.h @@ -51,7 +51,7 @@ public: // 4J Added virtual std::wstring getPath(bool bTitleUpdateTexture = false, - const char* pchBDPatchFilename = NULL); + const char* pchBDPatchFilename = nullptr); virtual std::wstring getAnimationString(const std::wstring& textureName, const std::wstring& path); virtual BufferedImage* getImageResource(const std::wstring& File, diff --git a/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp b/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp index 413fcd9e1..2b1aace90 100644 --- a/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp @@ -4,7 +4,7 @@ #include "../../../Minecraft.World/Util/StringHelpers.h" DefaultTexturePack::DefaultTexturePack() - : AbstractTexturePack(0, NULL, L"Minecraft", NULL) { + : AbstractTexturePack(0, nullptr, L"Minecraft", nullptr) { // 4J Stu - These calls need to be in the most derived version of the class loadIcon(); loadName(); // 4J-PB - added so the PS3 can have localised texture names' @@ -41,7 +41,7 @@ InputStream* DefaultTexturePack::getResourceImplementation( InputStream* resource = InputStream::getResourceAsStream(wDrive + name); // InputStream *stream = - // DefaultTexturePack::class->getResourceAsStream(name); if (stream == NULL) + // DefaultTexturePack::class->getResourceAsStream(name); if (stream == nullptr) //{ // throw new FileNotFoundException(name); // } diff --git a/Minecraft.Client/Textures/Packs/DefaultTexturePack.h b/Minecraft.Client/Textures/Packs/DefaultTexturePack.h index a3f5f9efb..dde080438 100644 --- a/Minecraft.Client/Textures/Packs/DefaultTexturePack.h +++ b/Minecraft.Client/Textures/Packs/DefaultTexturePack.h @@ -4,7 +4,7 @@ class DefaultTexturePack : public AbstractTexturePack { public: DefaultTexturePack(); - DLCPack* getDLCPack() { return NULL; } + DLCPack* getDLCPack() { return nullptr; } protected: //@Override diff --git a/Minecraft.Client/Textures/Packs/FileTexturePack.cpp b/Minecraft.Client/Textures/Packs/FileTexturePack.cpp index a7fa5f268..ee009f7cb 100644 --- a/Minecraft.Client/Textures/Packs/FileTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/FileTexturePack.cpp @@ -16,7 +16,7 @@ void FileTexturePack::unload(Textures* textures) { InputStream* FileTexturePack::getResourceImplementation( const std::wstring& name) // throws IOException { - return NULL; + return nullptr; } bool FileTexturePack::hasFile(const std::wstring& name) { diff --git a/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp b/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp index ba449e746..a0dc9236a 100644 --- a/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp @@ -21,7 +21,7 @@ InputStream* FolderTexturePack::getResourceImplementation( wDrive = L"Common\\DummyTexturePack\\res"; InputStream* resource = InputStream::getResourceAsStream(wDrive + name); // InputStream *stream = - // DefaultTexturePack::class->getResourceAsStream(name); if (stream == NULL) + // DefaultTexturePack::class->getResourceAsStream(name); if (stream == nullptr) //{ // throw new FileNotFoundException(name); // } diff --git a/Minecraft.Client/Textures/Packs/FolderTexturePack.h b/Minecraft.Client/Textures/Packs/FolderTexturePack.h index e53d6d077..362434ec6 100644 --- a/Minecraft.Client/Textures/Packs/FolderTexturePack.h +++ b/Minecraft.Client/Textures/Packs/FolderTexturePack.h @@ -22,7 +22,7 @@ public: // 4J Added virtual std::wstring getPath(bool bTitleUpdateTexture = false, - const char* pchBDPatchFilename = NULL); + const char* pchBDPatchFilename = nullptr); virtual void loadUI(); virtual void unloadUI(); }; \ No newline at end of file diff --git a/Minecraft.Client/Textures/Packs/TexturePack.cpp b/Minecraft.Client/Textures/Packs/TexturePack.cpp index 3501dea30..aefa78618 100644 --- a/Minecraft.Client/Textures/Packs/TexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/TexturePack.cpp @@ -2,7 +2,7 @@ #include "TexturePack.h" std::wstring TexturePack::getPath(bool bTitleUpdateTexture /*= false*/, - const char* pchBDPatchFileName /*= NULL*/) { + const char* pchBDPatchFileName /*= nullptr*/) { std::wstring wDrive; if (bTitleUpdateTexture) { diff --git a/Minecraft.Client/Textures/Packs/TexturePack.h b/Minecraft.Client/Textures/Packs/TexturePack.h index dc18576ee..4c2de6925 100644 --- a/Minecraft.Client/Textures/Packs/TexturePack.h +++ b/Minecraft.Client/Textures/Packs/TexturePack.h @@ -40,11 +40,11 @@ return TexturePack.class.getResourceAsStream(name); */ return name; } - virtual DLCPack* getDLCPack() { return NULL; } + virtual DLCPack* getDLCPack() { return nullptr; } // 4J Added virtual std::wstring getPath(bool bTitleUpdateTexture = false, - const char* pchBDPatchFilename = NULL); + const char* pchBDPatchFilename = nullptr); virtual std::wstring getAnimationString(const std::wstring& textureName, const std::wstring& path, bool allowFallback) = 0; diff --git a/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp b/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp index dc4e4decb..ccc4afffd 100644 --- a/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp +++ b/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp @@ -9,7 +9,7 @@ #include "../../../Minecraft.World/Util/StringHelpers.h" #include "../../Rendering/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, // 4J - added usingWeb = false; - selected = NULL; + selected = nullptr; texturePacks = new std::vector; this->minecraft = minecraft; @@ -28,9 +28,9 @@ TexturePackRepository::TexturePackRepository(File workingDirectory, DEFAULT_TEXTURE_PACK->loadColourTable(); - m_dummyTexturePack = NULL; - m_dummyDLCTexturePack = NULL; - lastSelected = NULL; + m_dummyTexturePack = nullptr; + m_dummyDLCTexturePack = nullptr; + lastSelected = nullptr; updateList(); } @@ -182,19 +182,19 @@ TexturePack* TexturePackRepository::getTexturePackById(std::uint32_t id) { return it->second; } - return NULL; + return nullptr; } TexturePack* TexturePackRepository::addTexturePackFromDLC(DLCPack* dlcPack, std::uint32_t 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 const std::uint32_t parentId = id & 0xFFFFFFu; // child id is <<24 and Or'd with parent - if (dlcPack != NULL) { + if (dlcPack != nullptr) { newPack = new DLCTexturePack(parentId, dlcPack, DEFAULT_TEXTURE_PACK); texturePacks->push_back(newPack); cacheById[parentId] = newPack; @@ -229,7 +229,7 @@ void TexturePackRepository::removeTexturePackById(std::uint32_t id) { if (it2 != texturePacks->end()) { texturePacks->erase(it2); if (lastSelected == oldPack) { - lastSelected = NULL; + lastSelected = nullptr; } } m_texturePacksToDelete.push_back(oldPack); @@ -237,17 +237,17 @@ void TexturePackRepository::removeTexturePackById(std::uint32_t 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() { @@ -255,7 +255,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/Stitching/PreStitchedTextureMap.cpp b/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp index 574a3c733..d2d72bfa4 100644 --- a/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp +++ b/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp @@ -29,8 +29,8 @@ PreStitchedTextureMap::PreStitchedTextureMap(int type, const std::wstring& name, this->missingTexture = missingTexture; // 4J Initialisers - missingPosition = NULL; - stitchResult = NULL; + missingPosition = nullptr; + stitchResult = nullptr; m_mipMap = mipmap; missingPosition = (StitchedTexture*)(new SimpleIcon( @@ -51,7 +51,7 @@ void PreStitchedTextureMap::stitch() { if (iconType == Icon::TYPE_TERRAIN) { // 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); } } @@ -63,7 +63,7 @@ void PreStitchedTextureMap::stitch() { // for (Item item : Item.items) 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); } } @@ -108,7 +108,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; } @@ -128,7 +128,7 @@ void PreStitchedTextureMap::stitch() { int width = (preStitched->getU1() * stitchResult->getWidth()) - x; int height = (preStitched->getV1() * stitchResult->getHeight()) - y; - preStitched->init(stitchResult, NULL, x, y, width, height, false); + preStitched->init(stitchResult, nullptr, x, y, width, height, false); } MemSect(52); @@ -166,7 +166,7 @@ void PreStitchedTextureMap::makeTextureAnimated(TexturePack* texturePack, // hack std::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 } @@ -199,7 +199,7 @@ StitchedTexture* PreStitchedTextureMap::getTexture(const std::wstring& name) { app.DebugPrintf("Not implemented!\n"); __debugbreak(); #endif - return NULL; + return nullptr; } void PreStitchedTextureMap::cycleAnimationFrames() { @@ -215,9 +215,9 @@ Texture* PreStitchedTextureMap::getStitchedTexture() { return stitchResult; } // 4J Stu - register is a reserved keyword in C++ Icon* PreStitchedTextureMap::registerIcon(const std::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"); #if !defined(_CONTENT_PACKAGE) __debugbreak(); #endif @@ -228,7 +228,7 @@ Icon* PreStitchedTextureMap::registerIcon(const std::wstring& name) { AUTO_VAR(it, texturesByName.find(name)); if (it != texturesByName.end()) result = it->second; - if (result == NULL) { + if (result == nullptr) { #if !defined(_CONTENT_PACKAGE) app.DebugPrintf("Could not find uv data for icon %ls\n", name.c_str()); __debugbreak(); diff --git a/Minecraft.Client/Textures/Stitching/StitchSlot.cpp b/Minecraft.Client/Textures/Stitching/StitchSlot.cpp index 4186ddde9..c886c6db2 100644 --- a/Minecraft.Client/Textures/Stitching/StitchSlot.cpp +++ b/Minecraft.Client/Textures/Stitching/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() { return textureHolder; } @@ -17,7 +17,7 @@ int StitchSlot::getY() { return originY; } bool StitchSlot::add(TextureHolder* textureHolder) { // Already holding a texture -- doesn't account for subslots. - if (this->textureHolder != NULL) { + if (this->textureHolder != nullptr) { return false; } @@ -30,14 +30,14 @@ 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; return true; } // See if we're already divided before, if not, setup subSlots - if (subSlots == NULL) { + if (subSlots == nullptr) { subSlots = new std::vector(); // First slot is for the new texture @@ -120,9 +120,9 @@ bool StitchSlot::add(TextureHolder* textureHolder) { } void StitchSlot::collectAssignments(std::vector* result) { - if (textureHolder != NULL) { + if (textureHolder != nullptr) { result->push_back(this); - } else if (subSlots != NULL) { + } else if (subSlots != nullptr) { // for (StitchSlot subSlot : subSlots) for (AUTO_VAR(it, subSlots->begin()); it != subSlots->end(); ++it) { StitchSlot* subSlot = *it; diff --git a/Minecraft.Client/Textures/Stitching/StitchedTexture.cpp b/Minecraft.Client/Textures/Stitching/StitchedTexture.cpp index c4eb5c316..aa1e5e40d 100644 --- a/Minecraft.Client/Textures/Stitching/StitchedTexture.cpp +++ b/Minecraft.Client/Textures/Stitching/StitchedTexture.cpp @@ -21,7 +21,7 @@ StitchedTexture::StitchedTexture(const std::wstring& name, const std::wstring& filename) : name(name) { // 4J Initialisers - source = NULL; + source = nullptr; rotated = false; x = 0; y = 0; @@ -35,35 +35,35 @@ StitchedTexture::StitchedTexture(const std::wstring& name, heightTranslation = 0.0f; frame = 0; subFrame = 0; - frameOverride = NULL; + frameOverride = nullptr; flags = 0; - frames = NULL; + frames = nullptr; m_fileName = filename; } void StitchedTexture::freeFrameTextures() { - if (frames != NULL) { + if (frames != nullptr) { for (AUTO_VAR(it, frames->begin()); it != frames->end(); ++it) { TextureManager::getInstance()->unregisterTexture(L"", *it); delete *it; } delete frames; - frames = NULL; + frames = nullptr; } } StitchedTexture::~StitchedTexture() { - if (frames != NULL) { + if (frames != nullptr) { for (AUTO_VAR(it, frames->begin()); it != frames->end(); ++it) { delete *it; } delete frames; - frames = NULL; + frames = nullptr; } - if (frameOverride != NULL) { + if (frameOverride != nullptr) { delete frameOverride; - frameOverride = NULL; + frameOverride = nullptr; } } @@ -159,7 +159,7 @@ int StitchedTexture::getSourceWidth() const { return source->getWidth(); } int StitchedTexture::getSourceHeight() const { return source->getHeight(); } void StitchedTexture::cycleFrames() { - if (frameOverride != NULL) { + if (frameOverride != nullptr) { std::pair current = frameOverride->at(frame); subFrame++; if (subFrame >= current.second) { @@ -202,9 +202,9 @@ int StitchedTexture::getFrames() { return frames ? frames->size() : 0; } * @param bufferedReader */ void StitchedTexture::loadAnimationFrames(BufferedReader* bufferedReader) { - if (frameOverride != NULL) { + if (frameOverride != nullptr) { delete frameOverride; - frameOverride = NULL; + frameOverride = nullptr; } frame = 0; subFrame = 0; @@ -247,9 +247,9 @@ void StitchedTexture::loadAnimationFrames(BufferedReader* bufferedReader) { } void StitchedTexture::loadAnimationFrames(const std::wstring& string) { - if (frameOverride != NULL) { + if (frameOverride != nullptr) { delete frameOverride; - frameOverride = NULL; + frameOverride = nullptr; } frame = 0; subFrame = 0; diff --git a/Minecraft.Client/Textures/Stitching/Stitcher.cpp b/Minecraft.Client/Textures/Stitching/Stitcher.cpp index 24f3332d1..0ffed99a6 100644 --- a/Minecraft.Client/Textures/Stitching/Stitcher.cpp +++ b/Minecraft.Client/Textures/Stitching/Stitcher.cpp @@ -17,7 +17,7 @@ void Stitcher::_init(const std::wstring& name, int maxWidth, int maxHeight, // 4J init storageX = 0; storageY = 0; - stitchedTexture = NULL; + stitchedTexture = nullptr; } Stitcher::Stitcher(const std::wstring& name, int maxWidth, int maxHeight, @@ -70,7 +70,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 (AUTO_VAR(it, texturesToBeStitched.begin()); diff --git a/Minecraft.Client/Textures/Stitching/TextureMap.cpp b/Minecraft.Client/Textures/Stitching/TextureMap.cpp index a0af280bb..cc8637e27 100644 --- a/Minecraft.Client/Textures/Stitching/TextureMap.cpp +++ b/Minecraft.Client/Textures/Stitching/TextureMap.cpp @@ -24,8 +24,8 @@ TextureMap::TextureMap(int type, const std::wstring& name, this->missingTexture = missingTexture; // 4J Initialisers - missingPosition = NULL; - stitchResult = NULL; + missingPosition = nullptr; + stitchResult = nullptr; m_mipMap = mipmap; } @@ -36,7 +36,7 @@ void TextureMap::stitch() { if (iconType == Icon::TYPE_TERRAIN) { // 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); } } @@ -48,7 +48,7 @@ void TextureMap::stitch() { // for (Item item : Item.items) 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); } } @@ -94,7 +94,7 @@ void TextureMap::stitch() { std::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 } @@ -131,7 +131,7 @@ void TextureMap::stitch() { std::vector* frames = textures.find(textureHolder)->second; - StitchedTexture* stored = NULL; + StitchedTexture* stored = nullptr; AUTO_VAR(itTex, texturesToRegister.find(textureName)); if (itTex != texturesToRegister.end()) stored = itTex->second; @@ -139,7 +139,7 @@ void TextureMap::stitch() { // [EB]: What is this code for? debug warnings for when during // transition? bool missing = false; - if (stored == NULL) { + if (stored == nullptr) { missing = true; stored = StitchedTexture::create(textureName); @@ -206,7 +206,7 @@ void TextureMap::stitch() { StitchedTexture* TextureMap::getTexture(const std::wstring& name) { StitchedTexture* result = texturesByName.find(name)->second; - if (result == NULL) result = missingPosition; + if (result == nullptr) result = missingPosition; return result; } @@ -224,7 +224,7 @@ Texture* TextureMap::getStitchedTexture() { return stitchResult; } // 4J Stu - register is a reserved keyword in C++ Icon* TextureMap::registerIcon(const std::wstring& name) { if (name.empty()) { - app.DebugPrintf("Don't register NULL\n"); + app.DebugPrintf("Don't register nullptr\n"); #ifndef _CONTENT_PACKAGE __debugbreak(); #endif @@ -232,11 +232,11 @@ Icon* TextureMap::registerIcon(const std::wstring& name) { } // TODO: [EB]: Why do we allow multiple registrations? - StitchedTexture* result = NULL; + StitchedTexture* result = nullptr; AUTO_VAR(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/Textures/Texture.cpp b/Minecraft.Client/Textures/Texture.cpp index 9cf70cb5a..58fa9082b 100644 --- a/Minecraft.Client/Textures/Texture.cpp +++ b/Minecraft.Client/Textures/Texture.cpp @@ -29,7 +29,7 @@ void Texture::_init(const std::wstring& name, int mode, int width, int height, immediateUpdate = false; m_bInitialised = false; for (int i = 0; i < 10; i++) { - data[i] = NULL; + data[i] = nullptr; } rect = new Rect2i(0, 0, width, height); @@ -86,7 +86,7 @@ void Texture::_init(const std::wstring& name, int mode, int width, int height, 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) { valid = false; } else { @@ -156,7 +156,7 @@ Texture::~Texture() { delete rect; for (int i = 0; i < 10; i++) { - if (data[i] != NULL) delete data[i]; + if (data[i] != nullptr) delete data[i]; } if (glId >= 0) { @@ -220,7 +220,7 @@ void Texture::blit(int x, int y, Texture* source, bool rotated) { for (unsigned int level = 0; level < m_iMipLevels; ++level) { ByteBuffer* srcBuffer = source->getData(level); - if (srcBuffer == NULL) break; + if (srcBuffer == nullptr) break; int yy = y >> level; int xx = x >> level; @@ -380,9 +380,9 @@ 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; } } @@ -395,7 +395,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) { int ww = width >> level; @@ -561,7 +561,7 @@ void Texture::updateOnGPU() { data[0]->flip(); if (mipmapped) { 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/Textures/Texture.h b/Minecraft.Client/Textures/Texture.h index ce43a4862..c8d4bf4da 100644 --- a/Minecraft.Client/Textures/Texture.h +++ b/Minecraft.Client/Textures/Texture.h @@ -55,7 +55,7 @@ private: bool immediateUpdate; bool updated; int m_iMipLevels; - ByteBuffer* data[10]; // Arrays for mipmaps - NULL if not used + ByteBuffer* data[10]; // Arrays for mipmaps - nullptr if not used public: bool m_bInitialised; // 4J Added diff --git a/Minecraft.Client/Textures/TextureManager.cpp b/Minecraft.Client/Textures/TextureManager.cpp index 77195f4df..79849f81f 100644 --- a/Minecraft.Client/Textures/TextureManager.cpp +++ b/Minecraft.Client/Textures/TextureManager.cpp @@ -7,7 +7,7 @@ #include "TextureManager.h" #include "../../Minecraft.World/Util/StringHelpers.h" -TextureManager* TextureManager::instance = NULL; +TextureManager* TextureManager::instance = nullptr; void TextureManager::createInstance() { instance = new TextureManager(); } @@ -22,7 +22,7 @@ Texture* TextureManager::getTexture(const std::wstring& name) { return idToTextureMap.find(stringToIDMap.find(name)->second)->second; } - return NULL; + return nullptr; } void TextureManager::registerName(const std::wstring& name, Texture* texture) { @@ -119,7 +119,7 @@ std::vector* TextureManager::createTextures( Texture* texture = createTexture(texName, mode, frameWidth, frameHeight, clamp, format, minFilter, magFilter, - mipmap || image->getData(1) != NULL, subImage); + mipmap || image->getData(1) != nullptr, subImage); delete subImage; result->push_back(texture); } @@ -129,7 +129,7 @@ std::vector* TextureManager::createTextures( if (width == height) { result->push_back(createTexture( texName, mode, width, height, clamp, format, minFilter, - magFilter, mipmap || image->getData(1) != NULL, image)); + magFilter, mipmap || image->getData(1) != nullptr, image)); } else { // Minecraft.getInstance().getLogger().warning("TextureManager.createTexture: // Skipping " + filename + " because of broken aspect ratio and not @@ -187,8 +187,8 @@ Texture* TextureManager::createTexture(const std::wstring& name, int mode, // 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); + // 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, - NULL); + nullptr); } \ No newline at end of file diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index ed06047ba..8c3ac36d2 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -338,15 +338,15 @@ intArray Textures::loadTexturePixels(TEXTURE_NAME texId, 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; + // 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); } else { @@ -616,7 +616,7 @@ int Textures::loadTexture(TEXTURE_NAME texId, 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); } else { @@ -701,7 +701,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); } @@ -841,7 +841,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); } @@ -852,7 +852,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); int bb = (r * 30 + b * 70) / (100); @@ -928,8 +928,8 @@ void Textures::releaseTexture(int id) { int Textures::loadHttpTexture(const std::wstring& url, const std::wstring& backup) { HttpTexture* texture = httpTextures[url]; - if (texture != NULL) { - if (texture->loadedImage != NULL && !texture->isLoaded) { + if (texture != nullptr) { + if (texture->loadedImage != nullptr && !texture->isLoaded) { if (texture->id < 0) { texture->id = getTexture(texture->loadedImage); } else { @@ -938,7 +938,7 @@ int Textures::loadHttpTexture(const std::wstring& url, 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); } @@ -947,8 +947,8 @@ int Textures::loadHttpTexture(const std::wstring& url, int Textures::loadHttpTexture(const std::wstring& url, int backup) { HttpTexture* texture = httpTextures[url]; - if (texture != NULL) { - if (texture->loadedImage != NULL && !texture->isLoaded) { + if (texture != nullptr) { + if (texture->loadedImage != nullptr && !texture->isLoaded) { if (texture->id < 0) { texture->id = getTexture(texture->loadedImage); } else { @@ -957,7 +957,7 @@ int Textures::loadHttpTexture(const std::wstring& url, int backup) { texture->isLoaded = true; } } - if (texture == NULL || texture->id < 0) { + if (texture == nullptr || texture->id < 0) { return loadTexture(backup); } return texture->id; @@ -970,7 +970,7 @@ bool Textures::hasHttpTexture(const std::wstring& url) { HttpTexture* Textures::addHttpTexture(const std::wstring& url, HttpTextureProcessor* processor) { HttpTexture* texture = httpTextures[url]; - if (texture == NULL) { + if (texture == nullptr) { httpTextures[url] = new HttpTexture(url, processor); } else { texture->count++; @@ -980,7 +980,7 @@ HttpTexture* Textures::addHttpTexture(const std::wstring& url, void Textures::removeHttpTexture(const std::wstring& url) { HttpTexture* texture = httpTextures[url]; - if (texture != NULL) { + if (texture != nullptr) { texture->count--; if (texture->count == 0) { if (texture->id >= 0) releaseTexture(texture->id); @@ -992,17 +992,17 @@ void Textures::removeHttpTexture(const std::wstring& url) { // 4J-PB - adding for texture in memory (from global title storage) int Textures::loadMemTexture(const std::wstring& url, const std::wstring& backup) { - MemTexture* texture = NULL; + MemTexture* texture = nullptr; AUTO_VAR(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->loadedImage != NULL && !texture->isLoaded) { + if (texture != nullptr) { + 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") || @@ -1021,7 +1021,7 @@ int Textures::loadMemTexture(const std::wstring& url, MIPMAP = true; } } - if (texture == NULL || texture->id < 0) { + if (texture == nullptr || texture->id < 0) { if (backup.empty()) return -1; return loadTexture(TN_COUNT, backup); } @@ -1029,18 +1029,18 @@ int Textures::loadMemTexture(const std::wstring& url, } int Textures::loadMemTexture(const std::wstring& url, int backup) { - MemTexture* texture = NULL; + MemTexture* texture = nullptr; AUTO_VAR(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") || @@ -1058,7 +1058,7 @@ int Textures::loadMemTexture(const std::wstring& url, int backup) { MIPMAP = true; } } - if (texture == NULL || texture->id < 0) { + if (texture == nullptr || texture->id < 0) { return loadTexture(backup); } return texture->id; @@ -1066,14 +1066,14 @@ int Textures::loadMemTexture(const std::wstring& url, int backup) { MemTexture* Textures::addMemTexture(const std::wstring& name, MemTextureProcessor* processor) { - MemTexture* texture = NULL; + MemTexture* texture = nullptr; AUTO_VAR(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? - std::uint8_t* pbData = NULL; + std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; app.GetMemFileDetails(name, &pbData, &dwBytes); @@ -1083,7 +1083,7 @@ MemTexture* Textures::addMemTexture(const std::wstring& name, } else { // 4J Stu - Make an entry for this anyway and we can populate it // later - memTextures[name] = NULL; + memTextures[name] = nullptr; } } else { texture->count++; @@ -1098,7 +1098,7 @@ MemTexture* Textures::addMemTexture(const std::wstring& name, // *processor) // { // MemTexture *texture = memTextures[url]; -// if (texture != NULL) +// if (texture != nullptr) // { // texture->count++; // } @@ -1106,15 +1106,15 @@ MemTexture* Textures::addMemTexture(const std::wstring& name, // } void Textures::removeMemTexture(const std::wstring& url) { - MemTexture* texture = NULL; + MemTexture* texture = nullptr; AUTO_VAR(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) { if (texture->id >= 0) releaseTexture(texture->id); @@ -1214,7 +1214,7 @@ Icon* Textures::getMissingIcon(int type) { BufferedImage* Textures::readImage( TEXTURE_NAME texId, const std::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); diff --git a/Minecraft.Client/UI/Font.cpp b/Minecraft.Client/UI/Font.cpp index daaa769bb..dbb70d87f 100644 --- a/Minecraft.Client/UI/Font.cpp +++ b/Minecraft.Client/UI/Font.cpp @@ -33,7 +33,7 @@ Font::Font(Options* options, const std::wstring& name, Textures* textures, m_textureLocation = textureLocation; // Build character map - if (charMap != NULL) { + if (charMap != nullptr) { for (int i = 0; i < charC; i++) { m_charMap.insert(std::make_pair(charMap[i], i)); } @@ -245,7 +245,7 @@ void Font::draw(const std::wstring& str, int x, int y, int color, int Font::width(const std::wstring& str) { std::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/UI/Font.h b/Minecraft.Client/UI/Font.h index b37693fdb..248d0ed9a 100644 --- a/Minecraft.Client/UI/Font.h +++ b/Minecraft.Client/UI/Font.h @@ -35,7 +35,7 @@ public: Font(Options* options, const std::wstring& name, Textures* textures, bool enforceUnicode, ResourceLocation* textureLocation, int cols, int rows, int charWidth, int charHeight, - unsigned short charMap[] = NULL); + unsigned short charMap[] = nullptr); // 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/UI/Gui.cpp b/Minecraft.Client/UI/Gui.cpp index 4dd7f056f..48828f0ad 100644 --- a/Minecraft.Client/UI/Gui.cpp +++ b/Minecraft.Client/UI/Gui.cpp @@ -273,10 +273,10 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { minecraft->player->inventory->getArmor(3); // 4J-PB - changing this to be per player - // if (!minecraft->options->thirdPersonView && headGear != NULL && + // if (!minecraft->options->thirdPersonView && headGear != nullptr && // headGear->id == Tile::pumpkin_Id) renderPumpkin(screenWidth, // screenHeight); - if ((minecraft->player->ThirdPersonView() == 0) && headGear != NULL && + if ((minecraft->player->ThirdPersonView() == 0) && headGear != nullptr && headGear->id == Tile::pumpkin_Id) renderPumpkin(screenWidth, screenHeight); if (!minecraft->player->hasEffect(MobEffect::confusion)) { @@ -579,7 +579,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { 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++) { int yo = yLine1; @@ -1020,7 +1020,7 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth 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 && + if (minecraft->level != nullptr && minecraft->level->hasChunkAt(px, py, pz)) { LevelChunk* chunkAt = minecraft->level->getChunkAt(px, pz); Biome* biome = chunkAt->getBiome( @@ -1078,7 +1078,7 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth unsigned int max = 10; bool isChatting = false; - if (dynamic_cast(minecraft->screen) != NULL) { + if (dynamic_cast(minecraft->screen) != nullptr) { max = 20; isChatting = true; } @@ -1151,10 +1151,10 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth // Moved to the xui base scene void Gui::renderBossHealth(void) { - // if (EnderDragonRenderer::bossInstance == NULL) return; + // if (EnderDragonRenderer::bossInstance == nullptr) return; // std::shared_ptr boss = EnderDragonRenderer::bossInstance; - // EnderDragonRenderer::bossInstance = NULL; + // EnderDragonRenderer::bossInstance = nullptr; // Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -1277,7 +1277,7 @@ void Gui::renderTp(float br, int w, int h) { void Gui::renderSlot(int slot, int x, int y, float a) { std::shared_ptr item = minecraft->player->inventory->items[slot]; - if (item == NULL) return; + if (item == nullptr) return; float pop = item->popTime - a; if (pop > 0) { @@ -1512,7 +1512,7 @@ void Gui::renderGraph(int dataLength, int dataPos, __int64* dataA, 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); @@ -1534,7 +1534,7 @@ void Gui::renderGraph(int dataLength, int dataPos, __int64* dataA, int cc2 = cc * cc / 255; cc2 = cc2 * cc2 / 255; - if (dataA != NULL) { + if (dataA != nullptr) { if (dataA[i] > dataAWarning) { t->color(0xff000000 + cc * 65536); } else { @@ -1549,7 +1549,7 @@ void Gui::renderGraph(int dataLength, int dataPos, __int64* dataA, (float)(0)); } - if (dataB != NULL) { + if (dataB != nullptr) { if (dataB[i] > dataBWarning) { t->color(0xff000000 + cc * 65536 + cc * 256 + cc * 1); } else { diff --git a/Minecraft.Client/UI/Screen.cpp b/Minecraft.Client/UI/Screen.cpp index d0d0a744c..5dd11484c 100644 --- a/Minecraft.Client/UI/Screen.cpp +++ b/Minecraft.Client/UI/Screen.cpp @@ -8,13 +8,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) { @@ -27,7 +27,7 @@ void Screen::render(int xm, int ym, float a) { void Screen::keyPressed(wchar_t eventCharacter, int eventKey) { if (eventKey == Keyboard::KEY_ESCAPE) { - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J - removed // 4jcraft: moved here from PauseScreen to ensure that serverside // unpausing is done in all scenarios @@ -62,9 +62,9 @@ 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; } } @@ -166,7 +166,7 @@ void Screen::removed() {} void Screen::renderBackground() { renderBackground(0); } void Screen::renderBackground(int vo) { - if (minecraft->level != NULL) { + if (minecraft->level != nullptr) { fillGradient(0, 0, width, height, 0xc0101010, 0xd0101010); } else { renderDirtBackground(vo); diff --git a/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp b/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp index 00a7e81f1..379638ae4 100644 --- a/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp +++ b/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp @@ -47,7 +47,7 @@ void AbstractContainerScreen::render(int xm, int ym, float a) { glEnable(GL_RESCALE_NORMAL); Lighting::turnOnGui(); - Slot* hoveredSlot = NULL; + Slot* hoveredSlot = nullptr; AUTO_VAR(itEnd, menu->slots.end()); for (AUTO_VAR(it, menu->slots.begin()); it != itEnd; it++) { @@ -70,7 +70,7 @@ void AbstractContainerScreen::render(int xm, int ym, float a) { } std::shared_ptr inventory = minecraft->player->inventory; - if (inventory->getCarried() != NULL) { + if (inventory->getCarried() != nullptr) { glTranslatef(0, 0, 32); // Slot old = carriedSlot; // carriedSlot = null; @@ -91,7 +91,7 @@ void AbstractContainerScreen::render(int xm, int ym, float a) { renderLabels(); // 4jcraft: newer tooltips backported from java edition 1.3.x (MCP 7.x) - if (inventory->getCarried() == NULL && hoveredSlot != NULL && + if (inventory->getCarried() == nullptr && hoveredSlot != nullptr && hoveredSlot->hasItem()) { std::shared_ptr item = hoveredSlot->getItem(); @@ -182,7 +182,7 @@ void AbstractContainerScreen::renderTooltip(std::shared_ptr item, std::vector* tooltipLines = item->getHoverText(minecraft->player, false, elementName); - if (tooltipLines != NULL && tooltipLines->size() > 0) { + if (tooltipLines != nullptr && tooltipLines->size() > 0) { std::vector cleanedLines; std::vector lineColors; @@ -276,7 +276,7 @@ void AbstractContainerScreen::renderSlot(Slot* slot) { int y = slot->y; std::shared_ptr item = slot->getItem(); - // if (item == NULL) + // if (item == nullptr) // { // int icon = slot->getNoItemIcon(); // if (icon >= 0) @@ -289,7 +289,7 @@ void AbstractContainerScreen::renderSlot(Slot* slot) { // } // } - if (item == NULL) { + if (item == nullptr) { return; } @@ -305,7 +305,7 @@ Slot* AbstractContainerScreen::findSlot(int x, int y) { Slot* slot = *it; // menu->slots.at(i); if (isHovering(slot, x, y)) return slot; } - return NULL; + return nullptr; } // 4jcraft: equivalent to MCP 8.11 (1.6.x)'s GuiContainer.isPointInRegion() for @@ -335,7 +335,7 @@ void AbstractContainerScreen::mouseClicked(int x, int y, int buttonNum) { (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) { slotId = AbstractContainerMenu::SLOT_CLICKED_OUTSIDE; @@ -366,7 +366,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( diff --git a/Minecraft.Client/UI/Screens/AchievementPopup.cpp b/Minecraft.Client/UI/Screens/AchievementPopup.cpp index 512533c81..7e4ef16b3 100644 --- a/Minecraft.Client/UI/Screens/AchievementPopup.cpp +++ b/Minecraft.Client/UI/Screens/AchievementPopup.cpp @@ -13,7 +13,7 @@ AchievementPopup::AchievementPopup(Minecraft* mc) { // 4J - added initialisers width = 0; height = 0; - ach = NULL; + ach = nullptr; startTime = 0; isHelper = false; @@ -85,7 +85,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/UI/Screens/AchievementScreen.cpp b/Minecraft.Client/UI/Screens/AchievementScreen.cpp index 31c179622..4754bcbbb 100644 --- a/Minecraft.Client/UI/Screens/AchievementScreen.cpp +++ b/Minecraft.Client/UI/Screens/AchievementScreen.cpp @@ -49,7 +49,7 @@ void AchievementScreen::init() { void AchievementScreen::buttonClicked(Button* button) { if (button->id == 1) { - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J removed } Screen::buttonClicked(button); @@ -57,7 +57,7 @@ void AchievementScreen::buttonClicked(Button* button) { void AchievementScreen::keyPressed(char eventCharacter, int eventKey) { if (eventKey == minecraft->options->keyBuild->key) { - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J removed } else { Screen::keyPressed(eventCharacter, eventKey); diff --git a/Minecraft.Client/UI/Screens/ChatScreen.cpp b/Minecraft.Client/UI/Screens/ChatScreen.cpp index 371ac6b47..35e3cf6f9 100644 --- a/Minecraft.Client/UI/Screens/ChatScreen.cpp +++ b/Minecraft.Client/UI/Screens/ChatScreen.cpp @@ -17,7 +17,7 @@ void ChatScreen::tick() { frame++; } 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) { @@ -28,7 +28,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) @@ -49,7 +49,7 @@ void ChatScreen::render(int xm, int ym, float a) { 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' ') { message += L" "; diff --git a/Minecraft.Client/UI/Screens/ConnectScreen.cpp b/Minecraft.Client/UI/Screens/ConnectScreen.cpp index e09dffb18..9b861b78a 100644 --- a/Minecraft.Client/UI/Screens/ConnectScreen.cpp +++ b/Minecraft.Client/UI/Screens/ConnectScreen.cpp @@ -11,7 +11,7 @@ ConnectScreen::ConnectScreen(Minecraft* minecraft, const std::wstring& ip, int port) { aborted = false; // System.out.println("Connecting to " + ip + ", " + port); - minecraft->setLevel(NULL); + minecraft->setLevel(nullptr); // 4J - removed from separate thread, but need to investigate what we // actually need here connection = new ClientConnection(minecraft, ip, port); @@ -21,7 +21,7 @@ ConnectScreen::ConnectScreen(Minecraft* minecraft, const std::wstring& ip, } void ConnectScreen::tick() { - if (connection != NULL) { + if (connection != nullptr) { connection->tick(); } } @@ -39,7 +39,7 @@ void ConnectScreen::init() { 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()); } } @@ -49,7 +49,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/UI/Screens/CreateWorldScreen.cpp b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp index 9de1625fb..8c77d0af5 100644 --- a/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp +++ b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp @@ -232,7 +232,7 @@ void CreateWorldScreen::buttonClicked(Button* button) { } param->seed = seedValue; - param->saveData = NULL; + param->saveData = nullptr; param->texturePackId = 0; param->settings = 0; diff --git a/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp b/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp index ac8481673..741835b54 100644 --- a/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp +++ b/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp @@ -98,7 +98,7 @@ CreativeInventoryScreen::ContainerCreative::clicked( // Handle clicks outside the GUI if (slotIndex == SLOT_CLICKED_OUTSIDE) { // Drop the carried item - if (carried != NULL) { + if (carried != nullptr) { if (buttonNum == 0) { player->drop(carried, true); inventory->setCarried(std::shared_ptr()); @@ -128,7 +128,7 @@ CreativeInventoryScreen::ContainerCreative::clicked( // Handle SWAP (number key) - copy item to hotbar if (clickType == CLICK_SWAP) { - if (slotItem != NULL && buttonNum >= 0 && buttonNum < 9) { + if (slotItem != nullptr && buttonNum >= 0 && buttonNum < 9) { std::shared_ptr copy = slotItem->copy(); copy->count = copy->getMaxStackSize(); inventory->setItem(buttonNum, copy); @@ -138,7 +138,7 @@ CreativeInventoryScreen::ContainerCreative::clicked( // Handle CLONE (middle click) if (clickType == CLICK_CLONE) { - if (slotItem != NULL) { + if (slotItem != nullptr) { std::shared_ptr copy = slotItem->copy(); copy->count = copy->getMaxStackSize(); inventory->setCarried(copy); @@ -147,7 +147,7 @@ CreativeInventoryScreen::ContainerCreative::clicked( } // Handle normal clicks - if (slotItem != NULL) { + if (slotItem != nullptr) { if (buttonNum == 0) // Left click { std::shared_ptr copy = slotItem->copy(); @@ -159,7 +159,7 @@ CreativeInventoryScreen::ContainerCreative::clicked( copy->count = 1; inventory->setCarried(copy); } - } else if (carried != NULL) { + } else if (carried != nullptr) { // Clicking on empty creative slot with item - clear the carried // item inventory->setCarried(std::shared_ptr()); @@ -289,7 +289,7 @@ void CreativeInventoryScreen::mouseClicked(int x, int y, int buttonNum) { (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) slotId = AbstractContainerMenu::SLOT_CLICKED_OUTSIDE; diff --git a/Minecraft.Client/UI/Screens/DeathScreen.cpp b/Minecraft.Client/UI/Screens/DeathScreen.cpp index 2ac5f8960..c4765fcad 100644 --- a/Minecraft.Client/UI/Screens/DeathScreen.cpp +++ b/Minecraft.Client/UI/Screens/DeathScreen.cpp @@ -13,7 +13,7 @@ void DeathScreen::init() { 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; } } @@ -27,11 +27,11 @@ 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()); // 4jcraft: use the static method from PauseScreen to exit diff --git a/Minecraft.Client/UI/Screens/DisconnectedScreen.cpp b/Minecraft.Client/UI/Screens/DisconnectedScreen.cpp index eae962c84..d23211a80 100644 --- a/Minecraft.Client/UI/Screens/DisconnectedScreen.cpp +++ b/Minecraft.Client/UI/Screens/DisconnectedScreen.cpp @@ -10,7 +10,7 @@ DisconnectedScreen::DisconnectedScreen(const std::wstring& title, Language* language = Language::getInstance(); this->title = language->getElement(title); - if (reasonObjects != NULL) { + if (reasonObjects != nullptr) { this->reason = language->getElement(reason, reasonObjects); } else { this->reason = language->getElement(reason); diff --git a/Minecraft.Client/UI/Screens/JoinMultiplayerScreen.cpp b/Minecraft.Client/UI/Screens/JoinMultiplayerScreen.cpp index 408fa3b7a..b25a3d1ab 100644 --- a/Minecraft.Client/UI/Screens/JoinMultiplayerScreen.cpp +++ b/Minecraft.Client/UI/Screens/JoinMultiplayerScreen.cpp @@ -6,7 +6,7 @@ #include "../../../Minecraft.World/Headers/net.minecraft.locale.h" JoinMultiplayerScreen::JoinMultiplayerScreen(Screen* lastScreen) { - ipEdit = NULL; + ipEdit = nullptr; this->lastScreen = lastScreen; } diff --git a/Minecraft.Client/UI/Screens/NameEntryScreen.cpp b/Minecraft.Client/UI/Screens/NameEntryScreen.cpp index 10f9baa28..c5a0d62f2 100644 --- a/Minecraft.Client/UI/Screens/NameEntryScreen.cpp +++ b/Minecraft.Client/UI/Screens/NameEntryScreen.cpp @@ -36,7 +36,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/UI/Screens/OptionsScreen.cpp b/Minecraft.Client/UI/Screens/OptionsScreen.cpp index da27c5ddc..b20a9ee21 100644 --- a/Minecraft.Client/UI/Screens/OptionsScreen.cpp +++ b/Minecraft.Client/UI/Screens/OptionsScreen.cpp @@ -54,7 +54,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(((SmallButton*)button)->getOption(), 1); button->msg = options->getMessage(Options::Option::getItem(button->id)); } diff --git a/Minecraft.Client/UI/Screens/PauseScreen.cpp b/Minecraft.Client/UI/Screens/PauseScreen.cpp index 1837a5a99..e55fc2790 100644 --- a/Minecraft.Client/UI/Screens/PauseScreen.cpp +++ b/Minecraft.Client/UI/Screens/PauseScreen.cpp @@ -76,7 +76,7 @@ void PauseScreen::buttonClicked(Button* button) { // minecraft->level->disconnect(); // } - // minecraft->setLevel(NULL); + // minecraft->setLevel(nullptr); // minecraft->setScreen(new TitleScreen()); // 4jcraft: exit with our new exitWorld method @@ -85,7 +85,7 @@ void PauseScreen::buttonClicked(Button* button) { if (button->id == 4) { app.SetXuiServerAction(ProfileManager.GetPrimaryPad(), eXuiServerAction_PauseServer, (void*)FALSE); - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J - removed } diff --git a/Minecraft.Client/UI/Screens/ReceivingLevelScreen.cpp b/Minecraft.Client/UI/Screens/ReceivingLevelScreen.cpp index 154517261..013d3a675 100644 --- a/Minecraft.Client/UI/Screens/ReceivingLevelScreen.cpp +++ b/Minecraft.Client/UI/Screens/ReceivingLevelScreen.cpp @@ -18,7 +18,7 @@ void ReceivingLevelScreen::tick() { connection->send( std::shared_ptr(new KeepAlivePacket())); } - if (connection != NULL) { + if (connection != nullptr) { connection->tick(); } } diff --git a/Minecraft.Client/UI/Screens/RenameWorldScreen.cpp b/Minecraft.Client/UI/Screens/RenameWorldScreen.cpp index 7c6b7712b..5448489a5 100644 --- a/Minecraft.Client/UI/Screens/RenameWorldScreen.cpp +++ b/Minecraft.Client/UI/Screens/RenameWorldScreen.cpp @@ -8,7 +8,7 @@ RenameWorldScreen::RenameWorldScreen(Screen* lastScreen, const std::wstring& levelId) { - nameEdit = NULL; + nameEdit = nullptr; this->lastScreen = lastScreen; this->levelId = levelId; } diff --git a/Minecraft.Client/UI/Screens/RepairScreen.cpp b/Minecraft.Client/UI/Screens/RepairScreen.cpp index 6fc1e8697..54b18362b 100644 --- a/Minecraft.Client/UI/Screens/RepairScreen.cpp +++ b/Minecraft.Client/UI/Screens/RepairScreen.cpp @@ -147,7 +147,7 @@ void RepairScreen::mouseClicked(int mouseX, int mouseY, int buttonNum) { void RepairScreen::updateItemName() { std::wstring itemName; Slot* slot = repairMenu->getSlot(0); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { if (!slot->getItem()->hasCustomHoverName() && itemName == slot->getItem()->getHoverName()) { itemName = L""; @@ -176,9 +176,9 @@ void RepairScreen::refreshContainer( void RepairScreen::slotChanged(AbstractContainerMenu* container, int slotIndex, std::shared_ptr item) { if (slotIndex == AnvilMenu::INPUT_SLOT) { - std::wstring itemName = item == NULL ? L"" : item->getHoverName(); + std::wstring itemName = item == nullptr ? L"" : item->getHoverName(); editName->setValue(itemName); - if (item != NULL) { + if (item != nullptr) { editName->focus(true); updateItemName(); } else { diff --git a/Minecraft.Client/UI/Screens/SelectWorldScreen.cpp b/Minecraft.Client/UI/Screens/SelectWorldScreen.cpp index 0557435a5..0eee5b9ab 100644 --- a/Minecraft.Client/UI/Screens/SelectWorldScreen.cpp +++ b/Minecraft.Client/UI/Screens/SelectWorldScreen.cpp @@ -14,11 +14,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; } @@ -113,7 +113,7 @@ void SelectWorldScreen::buttonClicked(Button* button) { minecraft->setScreen(new CreateWorldScreen(this)); } 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 @@ -132,13 +132,13 @@ 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); std::wstring worldFolderName = getWorldId(id); - if (worldFolderName == L"") // 4J - was NULL comparison + if (worldFolderName == L"") // 4J - was nullptr comparison { worldFolderName = L"World" + _toString(id); } diff --git a/Minecraft.Client/UI/Screens/StatsScreen.cpp b/Minecraft.Client/UI/Screens/StatsScreen.cpp index 9f310f029..9d267a279 100644 --- a/Minecraft.Client/UI/Screens/StatsScreen.cpp +++ b/Minecraft.Client/UI/Screens/StatsScreen.cpp @@ -10,14 +10,14 @@ #include "../../../Minecraft.World/Headers/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; } @@ -235,7 +235,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) { std::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); @@ -326,12 +326,12 @@ StatsScreen::ItemStatisticsList::ItemStatisticsList(StatsScreen* ss) { addToList = true; } - else if (Stats::itemBroke[id] != NULL && + else if (Stats::itemBroke[id] != nullptr && parent->stats->getTotalValue(Stats::itemBroke[id]) > 0) { addToList = true; } - else if (Stats::itemCrafted[id] != NULL && + else if (Stats::itemCrafted[id] != nullptr && parent->stats->getTotalValue(Stats::itemCrafted[id]) > 0) { addToList = true; @@ -450,12 +450,12 @@ StatsScreen::BlockStatisticsList::BlockStatisticsList(StatsScreen* ss) { addToList = true; } - else if (Stats::itemUsed[id] != NULL && + else if (Stats::itemUsed[id] != nullptr && parent->stats->getTotalValue(Stats::itemUsed[id]) > 0) { addToList = true; } - else if (Stats::itemCrafted[id] != NULL && + else if (Stats::itemCrafted[id] != nullptr && parent->stats->getTotalValue(Stats::itemCrafted[id]) > 0) { addToList = true; diff --git a/Minecraft.Client/UI/Screens/TextEditScreen.cpp b/Minecraft.Client/UI/Screens/TextEditScreen.cpp index 0b9d3f637..3e9053710 100644 --- a/Minecraft.Client/UI/Screens/TextEditScreen.cpp +++ b/Minecraft.Client/UI/Screens/TextEditScreen.cpp @@ -45,7 +45,7 @@ void TextEditScreen::buttonClicked(Button* button) { if (button->id == 0) { sign->setChanged(); - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); } } diff --git a/Minecraft.Client/UI/Screens/TitleScreen.cpp b/Minecraft.Client/UI/Screens/TitleScreen.cpp index 8aac613d5..5df54e275 100644 --- a/Minecraft.Client/UI/Screens/TitleScreen.cpp +++ b/Minecraft.Client/UI/Screens/TitleScreen.cpp @@ -19,7 +19,7 @@ Random* TitleScreen::random = new Random(); TitleScreen::TitleScreen() { // 4J - added initialisers vo = 0; - multiplayerButton = NULL; + multiplayerButton = nullptr; splash = L"missingno"; // try { // 4J - removed try/catch @@ -122,7 +122,7 @@ if (c.get(Calendar.MONTH) + 1 == 11 && c.get(Calendar.DAY_OF_MONTH) == 9) { language->getElement(L"menu.quit"))); } - if (minecraft->user == NULL) { + if (minecraft->user == nullptr) { multiplayerButton->active = false; } } diff --git a/Minecraft.Client/UI/Screens/VideoSettingsScreen.cpp b/Minecraft.Client/UI/Screens/VideoSettingsScreen.cpp index e97aa1f54..bab30504c 100644 --- a/Minecraft.Client/UI/Screens/VideoSettingsScreen.cpp +++ b/Minecraft.Client/UI/Screens/VideoSettingsScreen.cpp @@ -56,7 +56,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(((SmallButton*)button)->getOption(), 1); button->msg = options->getMessage(Options::Option::getItem(button->id)); return; diff --git a/Minecraft.Client/UI/SmallButton.cpp b/Minecraft.Client/UI/SmallButton.cpp index 33da86174..4b7a05612 100644 --- a/Minecraft.Client/UI/SmallButton.cpp +++ b/Minecraft.Client/UI/SmallButton.cpp @@ -3,13 +3,13 @@ SmallButton::SmallButton(int id, int x, int y, const std::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 std::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, diff --git a/Minecraft.Client/Utils/ArchiveFile.cpp b/Minecraft.Client/Utils/ArchiveFile.cpp index 81a0b9def..e475886c3 100644 --- a/Minecraft.Client/Utils/ArchiveFile.cpp +++ b/Minecraft.Client/Utils/ArchiveFile.cpp @@ -28,7 +28,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"); #if !defined(_CONTENT_PACKAGE) @@ -121,7 +121,7 @@ byteArray ArchiveFile::getFile(const std::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 * initialized it will crash here (Compression::getCompression). @@ -145,7 +145,7 @@ byteArray ArchiveFile::getFile(const std::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! } return out; diff --git a/Minecraft.World/AI/Attributes/AttributeModifier.cpp b/Minecraft.World/AI/Attributes/AttributeModifier.cpp index 854e24c90..4c505e231 100644 --- a/Minecraft.World/AI/Attributes/AttributeModifier.cpp +++ b/Minecraft.World/AI/Attributes/AttributeModifier.cpp @@ -44,7 +44,7 @@ AttributeModifier* AttributeModifier::setSerialize(bool serialize) { bool AttributeModifier::equals(AttributeModifier* modifier) { if (this == modifier) return true; - if (modifier == NULL) + if (modifier == nullptr) return false; //|| getClass() != o.getClass()) return false; if (id != modifier->id) return false; diff --git a/Minecraft.World/AI/Attributes/BaseAttributeMap.cpp b/Minecraft.World/AI/Attributes/BaseAttributeMap.cpp index 71e3384d5..b68534d29 100644 --- a/Minecraft.World/AI/Attributes/BaseAttributeMap.cpp +++ b/Minecraft.World/AI/Attributes/BaseAttributeMap.cpp @@ -18,7 +18,7 @@ AttributeInstance* BaseAttributeMap::getInstance(eATTRIBUTE_ID id) { if (it != attributesById.end()) { return it->second; } else { - return NULL; + return nullptr; } } @@ -39,7 +39,7 @@ void BaseAttributeMap::removeItemModifiers(std::shared_ptr item) { AttributeInstance* attribute = getInstance(it->first); AttributeModifier* modifier = it->second; - if (attribute != NULL) { + if (attribute != nullptr) { attribute->removeModifier(modifier); } @@ -56,7 +56,7 @@ void BaseAttributeMap::addItemModifiers(std::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/AI/Attributes/ModifiableAttributeInstance.cpp b/Minecraft.World/AI/Attributes/ModifiableAttributeInstance.cpp index 8abb926c8..6a26baa49 100644 --- a/Minecraft.World/AI/Attributes/ModifiableAttributeInstance.cpp +++ b/Minecraft.World/AI/Attributes/ModifiableAttributeInstance.cpp @@ -53,7 +53,7 @@ void ModifiableAttributeInstance::getModifiers( } AttributeModifier* ModifiableAttributeInstance::getModifier(eMODIFIER_ID id) { - AttributeModifier* modifier = NULL; + AttributeModifier* modifier = nullptr; AUTO_VAR(it, modifierById.find(id)); if (it != modifierById.end()) { @@ -74,7 +74,7 @@ void ModifiableAttributeInstance::addModifiers( void ModifiableAttributeInstance::addModifier(AttributeModifier* modifier) { // Can't add modifiers with the same ID (unless the modifier is anonymous) if (modifier->getId() != eModifierId_ANONYMOUS && - getModifier(modifier->getId()) != NULL) { + getModifier(modifier->getId()) != nullptr) { assert(0); // throw new IllegalArgumentException("Modifier is already applied on // this attribute!"); @@ -110,7 +110,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/AI/Attributes/ServersideAttributeMap.cpp b/Minecraft.World/AI/Attributes/ServersideAttributeMap.cpp index 9bbd1f02d..97a45e54b 100644 --- a/Minecraft.World/AI/Attributes/ServersideAttributeMap.cpp +++ b/Minecraft.World/AI/Attributes/ServersideAttributeMap.cpp @@ -15,7 +15,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_VAR(it, attributesByLegacy.find(name)); if(it != attributesByLegacy.end()) @@ -42,7 +42,7 @@ AttributeInstance* ServersideAttributeMap::registerAttribute( // 4J: Removed legacy name // If this is a ranged attribute also add to legacy name map /*RangedAttribute *rangedAttribute = - dynamic_cast(attribute); if (rangedAttribute != NULL && + dynamic_cast(attribute); if (rangedAttribute != nullptr && rangedAttribute->getImportLegacyName() != L"") { attributesByLegacy.insert(std::pair(); - path = NULL; + path = nullptr; } AvoidPlayerGoal::~AvoidPlayerGoal() { - if (path != NULL) delete path; + if (path != nullptr) delete path; delete entitySelector; } @@ -48,10 +48,10 @@ bool AvoidPlayerGoal::canUse() { if (avoidType == typeid(Player)) { std::shared_ptr tamableAnimal = std::dynamic_pointer_cast(mob->shared_from_this()); - if (tamableAnimal != NULL && tamableAnimal->isTame()) return false; + if (tamableAnimal != nullptr && tamableAnimal->isTame()) return false; toAvoid = std::weak_ptr( mob->level->getNearestPlayer(mob->shared_from_this(), maxDist)); - if (toAvoid.lock() == NULL) return false; + if (toAvoid.lock() == nullptr) return false; } else { AABB grown_bb = mob->bb.grow(maxDist, 3, maxDist); std::vector >* entities = @@ -75,18 +75,18 @@ bool AvoidPlayerGoal::canUse() { 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() { toAvoid = std::weak_ptr(); } diff --git a/Minecraft.World/AI/Goals/BegGoal.cpp b/Minecraft.World/AI/Goals/BegGoal.cpp index 4c8c2bd28..2f31740bb 100644 --- a/Minecraft.World/AI/Goals/BegGoal.cpp +++ b/Minecraft.World/AI/Goals/BegGoal.cpp @@ -19,13 +19,13 @@ BegGoal::BegGoal(Wolf* wolf, float lookDistance) { bool BegGoal::canUse() { player = std::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(); @@ -51,7 +51,7 @@ void BegGoal::tick() { bool BegGoal::playerHoldingInteresting(std::shared_ptr player) { std::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); } diff --git a/Minecraft.World/AI/Goals/BreedGoal.cpp b/Minecraft.World/AI/Goals/BreedGoal.cpp index 7c9fc4ce7..d4ce15724 100644 --- a/Minecraft.World/AI/Goals/BreedGoal.cpp +++ b/Minecraft.World/AI/Goals/BreedGoal.cpp @@ -24,11 +24,11 @@ BreedGoal::BreedGoal(Animal* animal, double speedModifier) { bool BreedGoal::canUse() { if (!animal->isInLove()) return false; partner = std::weak_ptr(getFreePartner()); - return partner.lock() != NULL; + return partner.lock() != nullptr; } bool BreedGoal::canContinueToUse() { - return partner.lock() != NULL && partner.lock()->isAlive() && + return partner.lock() != nullptr && partner.lock()->isAlive() && partner.lock()->isInLove() && loveTime < 20 * 3; } @@ -69,8 +69,8 @@ void BreedGoal::breed() { animal->getBreedOffspring(partner.lock()); animal->setDespawnProtected(); partner.lock()->setDespawnProtected(); - if (offspring == NULL) { - // This will be NULL if we've hit our limits for spawning any particular + if (offspring == nullptr) { + // 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(); @@ -79,11 +79,11 @@ void BreedGoal::breed() { } std::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()), diff --git a/Minecraft.World/AI/Goals/ControlledByPlayerGoal.cpp b/Minecraft.World/AI/Goals/ControlledByPlayerGoal.cpp index 8ccfee86e..784ccc958 100644 --- a/Minecraft.World/AI/Goals/ControlledByPlayerGoal.cpp +++ b/Minecraft.World/AI/Goals/ControlledByPlayerGoal.cpp @@ -36,7 +36,7 @@ void ControlledByPlayerGoal::stop() { } bool ControlledByPlayerGoal::canUse() { - return mob->isAlive() && mob->rider.lock() != NULL && + return mob->isAlive() && mob->rider.lock() != nullptr && mob->rider.lock()->instanceof(eTYPE_PLAYER) && (boosting || mob->canBeControlledByRider()); } @@ -117,7 +117,7 @@ void ControlledByPlayerGoal::tick() { mob->getRandom()->nextFloat() < 0.006f && !boosting) { std::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); if (carriedItem->count == 0) { @@ -135,9 +135,9 @@ void ControlledByPlayerGoal::tick() { } bool ControlledByPlayerGoal::isNoJumpTile(int tile) { - return Tile::tiles[tile] != NULL && + return Tile::tiles[tile] != nullptr && (Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_STAIRS || - (dynamic_cast(Tile::tiles[tile]) != NULL)); + (dynamic_cast(Tile::tiles[tile]) != nullptr)); } bool ControlledByPlayerGoal::isBoosting() { return boosting; } diff --git a/Minecraft.World/AI/Goals/DefendVillageTargetGoal.cpp b/Minecraft.World/AI/Goals/DefendVillageTargetGoal.cpp index 3c7c7180b..09de68a5a 100644 --- a/Minecraft.World/AI/Goals/DefendVillageTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/DefendVillageTargetGoal.cpp @@ -11,7 +11,7 @@ DefendVillageTargetGoal::DefendVillageTargetGoal(VillagerGolem* golem) bool DefendVillageTargetGoal::canUse() { std::shared_ptr village = golem->getVillage(); - if (village == NULL) return false; + if (village == nullptr) return false; potentialTarget = std::weak_ptr(village->getClosestAggressor( std::dynamic_pointer_cast(golem->shared_from_this()))); std::shared_ptr potTarget = potentialTarget.lock(); diff --git a/Minecraft.World/AI/Goals/DoorInteractGoal.cpp b/Minecraft.World/AI/Goals/DoorInteractGoal.cpp index 23be94098..117c3fb66 100644 --- a/Minecraft.World/AI/Goals/DoorInteractGoal.cpp +++ b/Minecraft.World/AI/Goals/DoorInteractGoal.cpp @@ -8,7 +8,7 @@ DoorInteractGoal::DoorInteractGoal(Mob* mob) { doorX = doorY = doorZ = 0; - doorTile = NULL; + doorTile = nullptr; passed = false; doorOpenDirX = doorOpenDirZ = 0.0f; @@ -19,7 +19,7 @@ bool DoorInteractGoal::canUse() { if (!mob->horizontalCollision) return false; PathNavigation* pathNav = mob->getNavigation(); Path* path = pathNav->getPath(); - if (path == NULL || path->isDone() || !pathNav->canOpenDoors()) + if (path == nullptr || path->isDone() || !pathNav->canOpenDoors()) return false; for (int i = 0; i < std::min(path->getIndex() + 2, path->getSize()); ++i) { @@ -29,7 +29,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; } @@ -37,7 +37,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() { return !passed; } @@ -59,6 +59,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 (DoorTile*)Tile::tiles[tileId]; } \ No newline at end of file diff --git a/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp b/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp index 62c0431ab..627823b09 100644 --- a/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp +++ b/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp @@ -26,7 +26,7 @@ FollowOwnerGoal::FollowOwnerGoal(TamableAnimal* tamable, double speedModifier, bool FollowOwnerGoal::canUse() { std::shared_ptr owner = std::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; @@ -35,7 +35,7 @@ bool FollowOwnerGoal::canUse() { } bool FollowOwnerGoal::canContinueToUse() { - return owner.lock() != NULL && !navigation->isDone() && + return owner.lock() != nullptr && !navigation->isDone() && tamable->distanceToSqr(owner.lock()) > stopDistance * stopDistance && !tamable->isSitting(); } diff --git a/Minecraft.World/AI/Goals/FollowParentGoal.cpp b/Minecraft.World/AI/Goals/FollowParentGoal.cpp index bcdc860ae..5037a6da2 100644 --- a/Minecraft.World/AI/Goals/FollowParentGoal.cpp +++ b/Minecraft.World/AI/Goals/FollowParentGoal.cpp @@ -32,14 +32,14 @@ bool FollowParentGoal::canUse() { } delete parents; - if (closest == NULL) return false; + if (closest == nullptr) return false; if (closestDistSqr < 3 * 3) return false; parent = std::weak_ptr(closest); return true; } 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/AI/Goals/HurtByTargetGoal.cpp b/Minecraft.World/AI/Goals/HurtByTargetGoal.cpp index 00a3e838d..ad97f35cb 100644 --- a/Minecraft.World/AI/Goals/HurtByTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/HurtByTargetGoal.cpp @@ -30,7 +30,7 @@ void HurtByTargetGoal::start() { std::shared_ptr other = std::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/AI/Goals/LeapAtTargetGoal.cpp b/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp index fc59fda1f..deeabe955 100644 --- a/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp @@ -14,7 +14,7 @@ LeapAtTargetGoal::LeapAtTargetGoal(Mob* mob, float yd) { bool LeapAtTargetGoal::canUse() { target = std::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; @@ -23,7 +23,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/AI/Goals/LookAtPlayerGoal.cpp b/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp index 8ab999411..6f81859ff 100644 --- a/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp +++ b/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp @@ -30,7 +30,7 @@ LookAtPlayerGoal::LookAtPlayerGoal(Mob* mob, const std::type_info& lookAtType, bool LookAtPlayerGoal::canUse() { if (mob->getRandom()->nextFloat() >= probability) return false; - if (mob->getTarget() != NULL) { + if (mob->getTarget() != nullptr) { lookAt = mob->getTarget(); } if (lookAtType == typeid(Player)) { @@ -41,11 +41,11 @@ bool LookAtPlayerGoal::canUse() { lookAt = std::weak_ptr(mob->level->getClosestEntityOfClass( lookAtType, &mob_bb, 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/AI/Goals/MakeLoveGoal.cpp b/Minecraft.World/AI/Goals/MakeLoveGoal.cpp index af3dd10e3..4aa24c0db 100644 --- a/Minecraft.World/AI/Goals/MakeLoveGoal.cpp +++ b/Minecraft.World/AI/Goals/MakeLoveGoal.cpp @@ -26,13 +26,13 @@ bool MakeLoveGoal::canUse() { 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; AABB villager_bb = villager->bb.grow(8, 3, 8); std::shared_ptr mate = level->getClosestEntityOfClass( typeid(Villager), &villager_bb, villager->shared_from_this()); - if (mate == NULL) return false; + if (mate == nullptr) return false; partner = std::weak_ptr(std::dynamic_pointer_cast(mate)); @@ -53,7 +53,7 @@ void MakeLoveGoal::stop() { } bool MakeLoveGoal::canContinueToUse() { - return partner.lock() != NULL && loveMakingTime >= 0 && + return partner.lock() != nullptr && loveMakingTime >= 0 && villageNeedsMoreVillagers() && villager->getAge() == 0; } @@ -74,7 +74,7 @@ void MakeLoveGoal::tick() { bool MakeLoveGoal::villageNeedsMoreVillagers() { std::shared_ptr _village = village.lock(); - if (_village == NULL) return false; + if (_village == nullptr) return false; if (!_village->isBreedTimerOk()) { return false; diff --git a/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp b/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp index 3c9b28244..989a355b6 100644 --- a/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp +++ b/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp @@ -39,7 +39,7 @@ MeleeAttackGoal::~MeleeAttackGoal() = default; bool MeleeAttackGoal::canUse() { std::shared_ptr target = mob->getTarget(); - if (target == NULL) return false; + if (target == nullptr) return false; if (!target->isAlive()) return false; if (attackType != eTYPE_NOTSET && !target->instanceof(attackType)) return false; @@ -49,7 +49,7 @@ bool MeleeAttackGoal::canUse() { bool MeleeAttackGoal::canContinueToUse() { std::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), @@ -84,6 +84,6 @@ void MeleeAttackGoal::tick() { 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/AI/Goals/MoveIndoorsGoal.cpp b/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp index 6451e21e4..d9eddea58 100644 --- a/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp +++ b/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp @@ -24,11 +24,11 @@ bool MoveIndoorsGoal::canUse() { return false; std::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; std::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() { @@ -38,7 +38,7 @@ bool MoveIndoorsGoal::canContinueToUse() { void MoveIndoorsGoal::start() { insideX = -1; std::shared_ptr _doorInfo = doorInfo.lock(); - if (_doorInfo == NULL) { + if (_doorInfo == nullptr) { doorInfo = std::weak_ptr(); return; } @@ -59,7 +59,7 @@ void MoveIndoorsGoal::start() { void MoveIndoorsGoal::stop() { std::shared_ptr _doorInfo = doorInfo.lock(); - if (_doorInfo == NULL) { + if (_doorInfo == nullptr) { doorInfo = std::weak_ptr(); return; } diff --git a/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp b/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp index 03fe6795a..0518d1c4c 100644 --- a/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp +++ b/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp @@ -12,7 +12,7 @@ MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob* mob, double speedModifier, bool onlyAtNight) { - path = NULL; + path = nullptr; doorInfo = std::weak_ptr(); this->mob = mob; @@ -22,7 +22,7 @@ MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob* mob, } MoveThroughVillageGoal::~MoveThroughVillageGoal() { - if (path != NULL) delete path; + if (path != nullptr) delete path; } bool MoveThroughVillageGoal::canUse() { @@ -32,10 +32,10 @@ bool MoveThroughVillageGoal::canUse() { std::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; std::shared_ptr _doorInfo = getNextDoorInfo(village); - if (_doorInfo == NULL) return false; + if (_doorInfo == nullptr) return false; doorInfo = _doorInfo; bool oldCanOpenDoors = mob->getNavigation()->canOpenDoors(); @@ -45,7 +45,7 @@ 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 towards(_doorInfo->x, _doorInfo->y, _doorInfo->z); auto pos = RandomPos::getPosTowards( @@ -56,14 +56,14 @@ bool MoveThroughVillageGoal::canUse() { 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() { if (mob->getNavigation()->isDone()) return false; float dist = mob->bbWidth + 4.f; std::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; @@ -71,12 +71,12 @@ bool MoveThroughVillageGoal::canContinueToUse() { void MoveThroughVillageGoal::start() { mob->getNavigation()->moveTo(path, speedModifier); - path = NULL; + path = nullptr; } void MoveThroughVillageGoal::stop() { std::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) { @@ -108,7 +108,7 @@ bool MoveThroughVillageGoal::hasVisited(std::shared_ptr di) { // for (DoorInfo di2 : visited) for (AUTO_VAR(it, visited.begin()); it != visited.end();) { std::shared_ptr di2 = (*it).lock(); - if (di2 == NULL) { + if (di2 == nullptr) { it = visited.erase(it); } else { if (di->x == di2->x && di->y == di2->y && di->z == di2->z) diff --git a/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp b/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp index 22babe6ca..613cbfd3f 100644 --- a/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp @@ -17,7 +17,7 @@ MoveTowardsTargetGoal::MoveTowardsTargetGoal(PathfinderMob* mob, bool MoveTowardsTargetGoal::canUse() { target = std::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 towards(target.lock()->x, target.lock()->y, target.lock()->z); @@ -32,7 +32,7 @@ bool MoveTowardsTargetGoal::canUse() { } bool MoveTowardsTargetGoal::canContinueToUse() { - return target.lock() != NULL && !mob->getNavigation()->isDone() && + return target.lock() != nullptr && !mob->getNavigation()->isDone() && target.lock()->isAlive() && target.lock()->distanceToSqr(mob->shared_from_this()) < within * within; diff --git a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp index a1126b45e..b4f30c952 100644 --- a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp @@ -14,7 +14,7 @@ SubselectEntitySelector::~SubselectEntitySelector() { delete m_subselector; } bool SubselectEntitySelector::matches(std::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(std::dynamic_pointer_cast(entity), false); } @@ -36,7 +36,7 @@ bool NearestAttackableTargetGoal::DistComp::operator()( NearestAttackableTargetGoal::NearestAttackableTargetGoal( PathfinderMob* mob, const std::type_info& targetType, int randomInterval, bool mustSee, bool mustReach /*= false*/, - EntitySelector* entitySelector /* =NULL */) + EntitySelector* entitySelector /* =nullptr */) : TargetGoal(mob, mustSee, mustReach), targetType(targetType) { this->randomInterval = randomInterval; this->distComp = new DistComp(mob); @@ -60,7 +60,7 @@ bool NearestAttackableTargetGoal::canUse() { mob->level->getEntitiesOfClass(targetType, &mob_bb, selector); bool result = false; - if (entities != NULL && !entities->empty()) { + if (entities != nullptr && !entities->empty()) { std::sort(entities->begin(), entities->end(), *distComp); target = std::weak_ptr( std::dynamic_pointer_cast(entities->at(0))); diff --git a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.h b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.h index d7e55b85c..cb023afcb 100644 --- a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.h +++ b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.h @@ -44,7 +44,7 @@ public: const std::type_info& targetType, int randomInterval, bool mustSee, bool mustReach = false, - EntitySelector* entitySelector = NULL); + EntitySelector* entitySelector = nullptr); virtual ~NearestAttackableTargetGoal(); diff --git a/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp b/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp index 6753e64e3..5169093d3 100644 --- a/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp +++ b/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp @@ -20,13 +20,13 @@ OcelotAttackGoal::OcelotAttackGoal(Mob* mob) { bool OcelotAttackGoal::canUse() { std::shared_ptr bestTarget = mob->getTarget(); - if (bestTarget == NULL) return false; + if (bestTarget == nullptr) return false; target = std::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/AI/Goals/OfferFlowerGoal.cpp b/Minecraft.World/AI/Goals/OfferFlowerGoal.cpp index f78623fec..7d6b64a37 100644 --- a/Minecraft.World/AI/Goals/OfferFlowerGoal.cpp +++ b/Minecraft.World/AI/Goals/OfferFlowerGoal.cpp @@ -19,11 +19,11 @@ bool OfferFlowerGoal::canUse() { villager = std::weak_ptr(std::dynamic_pointer_cast( golem->level->getClosestEntityOfClass(typeid(Villager), &golem_bb, 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/AI/Goals/OwnerHurtByTargetGoal.cpp b/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.cpp index 3b7169126..d23375fb2 100644 --- a/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.cpp @@ -14,7 +14,7 @@ bool OwnerHurtByTargetGoal::canUse() { if (!tameAnimal->isTame()) return false; std::shared_ptr owner = std::dynamic_pointer_cast(tameAnimal->getOwner()); - if (owner == NULL) return false; + if (owner == nullptr) return false; ownerLastHurtBy = std::weak_ptr(owner->getLastHurtByMob()); int ts = owner->getLastHurtByMobTimestamp(); @@ -28,7 +28,7 @@ void OwnerHurtByTargetGoal::start() { std::shared_ptr owner = std::dynamic_pointer_cast(tameAnimal->getOwner()); - if (owner != NULL) { + if (owner != nullptr) { timestamp = owner->getLastHurtByMobTimestamp(); } diff --git a/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.cpp b/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.cpp index 55bf6c8c3..10b0a040f 100644 --- a/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.cpp @@ -14,7 +14,7 @@ bool OwnerHurtTargetGoal::canUse() { if (!tameAnimal->isTame()) return false; std::shared_ptr owner = std::dynamic_pointer_cast(tameAnimal->getOwner()); - if (owner == NULL) return false; + if (owner == nullptr) return false; ownerLastHurt = std::weak_ptr(owner->getLastHurtMob()); int ts = owner->getLastHurtMobTimestamp(); std::shared_ptr locked = ownerLastHurt.lock(); @@ -27,7 +27,7 @@ void OwnerHurtTargetGoal::start() { std::shared_ptr owner = std::dynamic_pointer_cast(tameAnimal->getOwner()); - if (owner != NULL) { + if (owner != nullptr) { timestamp = owner->getLastHurtMobTimestamp(); TargetGoal::start(); diff --git a/Minecraft.World/AI/Goals/PanicGoal.cpp b/Minecraft.World/AI/Goals/PanicGoal.cpp index ec47e765f..23f3e7213 100644 --- a/Minecraft.World/AI/Goals/PanicGoal.cpp +++ b/Minecraft.World/AI/Goals/PanicGoal.cpp @@ -13,7 +13,7 @@ PanicGoal::PanicGoal(PathfinderMob* mob, double speedModifier) { } bool PanicGoal::canUse() { - if (mob->getLastHurtByMob() == NULL && !mob->isOnFire()) return false; + if (mob->getLastHurtByMob() == nullptr && !mob->isOnFire()) return false; // 4jcraft: stop entities from being eternally scared (referenced from // smartcmd/MinecraftConsoles #519) diff --git a/Minecraft.World/AI/Goals/PlayGoal.cpp b/Minecraft.World/AI/Goals/PlayGoal.cpp index b748d7519..b5df3a524 100644 --- a/Minecraft.World/AI/Goals/PlayGoal.cpp +++ b/Minecraft.World/AI/Goals/PlayGoal.cpp @@ -42,7 +42,7 @@ bool PlayGoal::canUse() { } delete children; - if (followFriend.lock() == NULL) { + if (followFriend.lock() == nullptr) { auto pos = RandomPos::getPos( std::dynamic_pointer_cast(mob->shared_from_this()), 16, 3); @@ -52,11 +52,11 @@ bool PlayGoal::canUse() { } 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; } @@ -67,7 +67,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); } else { diff --git a/Minecraft.World/AI/Goals/RangedAttackGoal.cpp b/Minecraft.World/AI/Goals/RangedAttackGoal.cpp index 2c7f22d9e..f0d3e109a 100644 --- a/Minecraft.World/AI/Goals/RangedAttackGoal.cpp +++ b/Minecraft.World/AI/Goals/RangedAttackGoal.cpp @@ -46,7 +46,7 @@ RangedAttackGoal::RangedAttackGoal(RangedAttackMob* rangedMob, Mob* mob, bool RangedAttackGoal::canUse() { std::shared_ptr bestTarget = mob->getTarget(); - if (bestTarget == NULL) return false; + if (bestTarget == nullptr) return false; target = std::weak_ptr(bestTarget); return true; } @@ -64,7 +64,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); diff --git a/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.cpp b/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.cpp index f43ee13e1..d8b5d0241 100644 --- a/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.cpp +++ b/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.cpp @@ -13,10 +13,10 @@ bool RestrictOpenDoorGoal::canUse() { if (mob->level->isDay()) return false; std::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; std::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), @@ -26,7 +26,7 @@ bool RestrictOpenDoorGoal::canUse() { bool RestrictOpenDoorGoal::canContinueToUse() { if (mob->level->isDay()) return false; std::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/AI/Goals/RunAroundLikeCrazyGoal.cpp b/Minecraft.World/AI/Goals/RunAroundLikeCrazyGoal.cpp index c24d376cd..a8d7a2623 100644 --- a/Minecraft.World/AI/Goals/RunAroundLikeCrazyGoal.cpp +++ b/Minecraft.World/AI/Goals/RunAroundLikeCrazyGoal.cpp @@ -16,7 +16,7 @@ RunAroundLikeCrazyGoal::RunAroundLikeCrazyGoal(EntityHorse* mob, } bool RunAroundLikeCrazyGoal::canUse() { - if (horse->isTamed() || horse->rider.lock() == NULL) return false; + if (horse->isTamed() || horse->rider.lock() == nullptr) return false; auto pos = RandomPos::getPos( std::dynamic_pointer_cast(horse->shared_from_this()), 5, 4); @@ -32,7 +32,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/AI/Goals/SitGoal.cpp b/Minecraft.World/AI/Goals/SitGoal.cpp index 2ec85aff7..16c31c420 100644 --- a/Minecraft.World/AI/Goals/SitGoal.cpp +++ b/Minecraft.World/AI/Goals/SitGoal.cpp @@ -21,11 +21,11 @@ bool SitGoal::canUse() { std::shared_ptr owner = std::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) + owner->getLastHurtByMob() != nullptr) return false; return _wantToSit; diff --git a/Minecraft.World/AI/Goals/SwellGoal.cpp b/Minecraft.World/AI/Goals/SwellGoal.cpp index bf3db4e80..37b0b3011 100644 --- a/Minecraft.World/AI/Goals/SwellGoal.cpp +++ b/Minecraft.World/AI/Goals/SwellGoal.cpp @@ -15,7 +15,7 @@ SwellGoal::SwellGoal(Creeper* creeper) { bool SwellGoal::canUse() { std::shared_ptr target = creeper->getTarget(); return creeper->getSwellDir() > 0 || - (target != NULL && (creeper->distanceToSqr(target) < 3 * 3)); + (target != nullptr && (creeper->distanceToSqr(target) < 3 * 3)); } void SwellGoal::start() { @@ -26,7 +26,7 @@ void SwellGoal::start() { void SwellGoal::stop() { target = std::weak_ptr(); } void SwellGoal::tick() { - if (target.lock() == NULL) { + if (target.lock() == nullptr) { creeper->setSwellDir(-1); return; } diff --git a/Minecraft.World/AI/Goals/TakeFlowerGoal.cpp b/Minecraft.World/AI/Goals/TakeFlowerGoal.cpp index 7c3a49f44..d521b4c39 100644 --- a/Minecraft.World/AI/Goals/TakeFlowerGoal.cpp +++ b/Minecraft.World/AI/Goals/TakeFlowerGoal.cpp @@ -41,11 +41,11 @@ bool TakeFlowerGoal::canUse() { } } delete golems; - return golem.lock() != NULL; + return golem.lock() != nullptr; } 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/AI/Goals/TargetGoal.cpp b/Minecraft.World/AI/Goals/TargetGoal.cpp index 5d7751ee7..1804e676f 100644 --- a/Minecraft.World/AI/Goals/TargetGoal.cpp +++ b/Minecraft.World/AI/Goals/TargetGoal.cpp @@ -30,7 +30,7 @@ TargetGoal::TargetGoal(PathfinderMob* mob, bool mustSee, bool mustReach) { bool TargetGoal::canContinueToUse() { std::shared_ptr target = mob->getTarget(); - if (target == NULL) return false; + if (target == nullptr) return false; if (!target->isAlive()) return false; double within = getFollowDistance(); @@ -48,7 +48,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() { @@ -61,16 +61,16 @@ void TargetGoal::stop() { mob->setTarget(nullptr); } bool TargetGoal::canAttack(std::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()) { std::shared_ptr ownableTarget = std::dynamic_pointer_cast(target); - if (ownableTarget != NULL && ownableMob->getOwnerUUID().compare( + if (ownableTarget != nullptr && ownableMob->getOwnerUUID().compare( ownableTarget->getOwnerUUID()) == 0) { // We're attacking something owned by the same person... return false; @@ -105,9 +105,9 @@ bool TargetGoal::canAttack(std::shared_ptr target, bool TargetGoal::canReach(std::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/AI/Goals/TemptGoal.cpp b/Minecraft.World/AI/Goals/TemptGoal.cpp index c0b06eb93..679924d6b 100644 --- a/Minecraft.World/AI/Goals/TemptGoal.cpp +++ b/Minecraft.World/AI/Goals/TemptGoal.cpp @@ -29,19 +29,19 @@ bool TemptGoal::canUse() { } player = std::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 std::shared_ptr item = player.lock()->getSelectedItem(); - if (item == NULL) return false; + if (item == nullptr) return false; if (item->id != itemId) return false; return true; } 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/AI/Goals/TradeWithPlayerGoal.cpp b/Minecraft.World/AI/Goals/TradeWithPlayerGoal.cpp index 61219b4d5..7de227116 100644 --- a/Minecraft.World/AI/Goals/TradeWithPlayerGoal.cpp +++ b/Minecraft.World/AI/Goals/TradeWithPlayerGoal.cpp @@ -18,7 +18,7 @@ bool TradeWithPlayerGoal::canUse() { if (mob->hurtMarked) return false; std::shared_ptr trader = mob->getTradingPlayer(); - if (trader == NULL) { + if (trader == nullptr) { // no interaction return false; } diff --git a/Minecraft.World/AI/Navigation/Node.cpp b/Minecraft.World/AI/Navigation/Node.cpp index 436e4ef30..7a06742e4 100644 --- a/Minecraft.World/AI/Navigation/Node.cpp +++ b/Minecraft.World/AI/Navigation/Node.cpp @@ -9,7 +9,7 @@ void Node::_init() { closed = false; - cameFrom = NULL; + cameFrom = nullptr; } Node::Node(const int x, const int y, const int z) @@ -46,7 +46,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/AI/Navigation/Path.cpp b/Minecraft.World/AI/Navigation/Path.cpp index 672839665..bd05f06ff 100644 --- a/Minecraft.World/AI/Navigation/Path.cpp +++ b/Minecraft.World/AI/Navigation/Path.cpp @@ -35,7 +35,7 @@ Node* Path::last() { if (length > 0) { return nodes[length - 1]; } - return NULL; + return nullptr; } Node* Path::get(int i) { return nodes[i]; } @@ -62,7 +62,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 || @@ -74,13 +74,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 == (int)pos->x && lastNode->y == (int)pos->y && lastNode->z == (int)pos->z; } bool Path::endsInXZ(Vec3* pos) { Node* lastNode = last(); - if (lastNode == NULL) return false; + if (lastNode == nullptr) return false; return lastNode->x == (int)pos->x && lastNode->z == (int)pos->z; } diff --git a/Minecraft.World/AI/Navigation/PathFinder.cpp b/Minecraft.World/AI/Navigation/PathFinder.cpp index 429b99302..b5727bc1d 100644 --- a/Minecraft.World/AI/Navigation/PathFinder.cpp +++ b/Minecraft.World/AI/Navigation/PathFinder.cpp @@ -118,7 +118,7 @@ Path* PathFinder::findPath(Entity* e, Node* from, Node* to, Node* size, } } - if (closest == from) return NULL; + if (closest == from) return nullptr; return reconstruct_path(from, closest); } @@ -135,13 +135,13 @@ int PathFinder::getNeighbors(Entity* entity, Node* pos, Node* size, 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) + if (n != nullptr && !n->closed && n->distanceTo(target) < maxDist) neighbors->data[p++] = n; - if (w != NULL && !w->closed && w->distanceTo(target) < maxDist) + if (w != nullptr && !w->closed && w->distanceTo(target) < maxDist) neighbors->data[p++] = w; - if (e != NULL && !e->closed && e->distanceTo(target) < maxDist) + if (e != nullptr && !e->closed && e->distanceTo(target) < maxDist) neighbors->data[p++] = e; - if (s != NULL && !s->closed && s->distanceTo(target) < maxDist) + if (s != nullptr && !s->closed && s->distanceTo(target) < maxDist) neighbors->data[p++] = s; return p; @@ -149,37 +149,37 @@ int PathFinder::getNeighbors(Entity* entity, Node* pos, Node* size, 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 && + 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 + 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 NULL; + // 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; @@ -268,7 +268,7 @@ int PathFinder::isFree(Entity* entity, int x, int y, int z, Node* size, 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; } @@ -276,7 +276,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/AI/Navigation/PathNavigation.cpp b/Minecraft.World/AI/Navigation/PathNavigation.cpp index fc03d1948..811ba923b 100644 --- a/Minecraft.World/AI/Navigation/PathNavigation.cpp +++ b/Minecraft.World/AI/Navigation/PathNavigation.cpp @@ -15,7 +15,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; @@ -28,7 +28,7 @@ PathNavigation::PathNavigation(Mob* mob, Level* level) { } PathNavigation::~PathNavigation() { - if (path != NULL) delete path; + if (path != nullptr) delete path; } void PathNavigation::setAvoidWater(bool avoidWater) { @@ -58,7 +58,7 @@ void PathNavigation::setCanFloat(bool canFloat) { this->canFloat = canFloat; } float PathNavigation::getMaxDist() { return (float)dist->getValue(); } 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), (int)y, Mth::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat); @@ -75,7 +75,7 @@ bool PathNavigation::moveTo(double x, double y, double z, } Path* PathNavigation::createPath(std::shared_ptr target) { - if (!canUpdatePath()) return NULL; + if (!canUpdatePath()) return nullptr; return level->findPath(mob->shared_from_this(), target, getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat); } @@ -87,20 +87,20 @@ bool PathNavigation::moveTo(std::shared_ptr 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) + if (newPath != nullptr) return moveTo(newPath, speedModifier); else return false; } bool PathNavigation::moveTo(Path* newPath, double speedModifier) { - if (newPath == NULL) { - if (path != NULL) delete path; - path = NULL; + if (newPath == nullptr) { + 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 { delete newPath; @@ -137,7 +137,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 ((int)path->get(i)->y != (int)mobPos.y) { firstElevation = i; break; @@ -176,11 +176,11 @@ void PathNavigation::updatePath() { } } -bool PathNavigation::isDone() { return path == NULL || path->isDone(); } +bool PathNavigation::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/AI/Navigation/RandomPos.cpp b/Minecraft.World/AI/Navigation/RandomPos.cpp index 4025cc9f3..3b9528e17 100644 --- a/Minecraft.World/AI/Navigation/RandomPos.cpp +++ b/Minecraft.World/AI/Navigation/RandomPos.cpp @@ -10,7 +10,7 @@ std::optional RandomPos::getPos( std::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); } std::optional RandomPos::getPosTowards(std::shared_ptr mob, @@ -68,7 +68,7 @@ std::optional RandomPos::generateRandomPos( } 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); diff --git a/Minecraft.World/Blocks/AnvilTile.cpp b/Minecraft.World/Blocks/AnvilTile.cpp index 5e158ed19..f490bf2d0 100644 --- a/Minecraft.World/Blocks/AnvilTile.cpp +++ b/Minecraft.World/Blocks/AnvilTile.cpp @@ -20,7 +20,7 @@ AnvilTile::AnvilTile(int id) : HeavyTile(id, Material::heavyMetal, false) { part = PART_BASE; setLightBlock(0); - icons = NULL; + icons = nullptr; } bool AnvilTile::isCubeShaped() { return false; } diff --git a/Minecraft.World/Blocks/BaseEntityTile.cpp b/Minecraft.World/Blocks/BaseEntityTile.cpp index 9bd4763da..c3344201f 100644 --- a/Minecraft.World/Blocks/BaseEntityTile.cpp +++ b/Minecraft.World/Blocks/BaseEntityTile.cpp @@ -25,7 +25,7 @@ bool BaseEntityTile::triggerEvent(Level* level, int x, int y, int z, int b0, int b1) { Tile::triggerEvent(level, x, y, z, b0, b1); std::shared_ptr te = level->getTileEntity(x, y, z); - if (te != NULL) { + if (te != nullptr) { return te->triggerEvent(b0, b1); } return false; diff --git a/Minecraft.World/Blocks/BaseRailTile.cpp b/Minecraft.World/Blocks/BaseRailTile.cpp index 31332510e..f5542a5e7 100644 --- a/Minecraft.World/Blocks/BaseRailTile.cpp +++ b/Minecraft.World/Blocks/BaseRailTile.cpp @@ -81,7 +81,7 @@ void BaseRailTile::Rail::removeSoftConnections() { if (m_bValidRail) { 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); i--; @@ -105,14 +105,14 @@ 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; } bool BaseRailTile::Rail::connectsTo(Rail* rail) { @@ -213,7 +213,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; @@ -281,7 +281,7 @@ void BaseRailTile::Rail::place(bool hasSignal, bool first) { AUTO_VAR(itEnd, connections.end()); for (AUTO_VAR(it, connections.begin()); it != itEnd; it++) { Rail* neighbor = getRail(*it); - if (neighbor == NULL) continue; + if (neighbor == nullptr) continue; neighbor->removeSoftConnections(); if (neighbor->canConnectTo(this)) { @@ -307,7 +307,7 @@ BaseRailTile::BaseRailTile(int id, bool usesDataBit) this->usesDataBit = usesDataBit; setShape(0, 0, 0, 1, 2 / 16.0f, 1); - iconTurn = NULL; + iconTurn = nullptr; } bool BaseRailTile::isUsesDataBit() { return usesDataBit; } diff --git a/Minecraft.World/Blocks/BeaconTile.cpp b/Minecraft.World/Blocks/BeaconTile.cpp index 641dbc0fa..7dbd6aa35 100644 --- a/Minecraft.World/Blocks/BeaconTile.cpp +++ b/Minecraft.World/Blocks/BeaconTile.cpp @@ -21,7 +21,7 @@ bool BeaconTile::use(Level* level, int x, int y, int z, std::shared_ptr beacon = std::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/Blocks/BedTile.cpp b/Minecraft.World/Blocks/BedTile.cpp index 372e4105f..1dc8fe393 100644 --- a/Minecraft.World/Blocks/BedTile.cpp +++ b/Minecraft.World/Blocks/BedTile.cpp @@ -13,9 +13,9 @@ BedTile::BedTile(int id) : DirectionalTile(id, Material::cloth, false) { setShape(); - iconEnd = NULL; - iconSide = NULL; - iconTop = NULL; + iconEnd = nullptr; + iconSide = nullptr; + iconTop = nullptr; } // 4J Added override @@ -108,7 +108,7 @@ bool BedTile::use(Level* level, int x, int y, int z, } } - if (sleepingPlayer == NULL) { + if (sleepingPlayer == nullptr) { setOccupied(level, x, y, z, false); } else { player->displayClientMessage(IDS_TILE_BED_OCCUPIED); @@ -262,7 +262,7 @@ Pos* BedTile::findStandUpPosition(Level* level, int x, int y, int z, } } - return NULL; + return nullptr; } void BedTile::spawnResources(Level* level, int x, int y, int z, int data, diff --git a/Minecraft.World/Blocks/BrewingStandTile.cpp b/Minecraft.World/Blocks/BrewingStandTile.cpp index 67fdbe3fb..d901e8472 100644 --- a/Minecraft.World/Blocks/BrewingStandTile.cpp +++ b/Minecraft.World/Blocks/BrewingStandTile.cpp @@ -10,7 +10,7 @@ BrewingStandTile::BrewingStandTile(int id) : BaseEntityTile(id, Material::metal, false) { random = new Random(); - iconBase = NULL; + iconBase = nullptr; } BrewingStandTile::~BrewingStandTile() { delete random; } @@ -52,7 +52,7 @@ bool BrewingStandTile::use( std::shared_ptr brewingStand = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (brewingStand != NULL) player->openBrewingStand(brewingStand); + if (brewingStand != nullptr) player->openBrewingStand(brewingStand); return true; } @@ -79,14 +79,14 @@ void BrewingStandTile::animateTick(Level* level, int xt, int yt, int zt, void BrewingStandTile::onRemove(Level* level, int x, int y, int z, int id, int data) { std::shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && + if (tileEntity != nullptr && (std::dynamic_pointer_cast(tileEntity) != - NULL)) { + nullptr)) { std::shared_ptr container = std::dynamic_pointer_cast(tileEntity); for (int i = 0; i < container->getContainerSize(); i++) { std::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; float zo = random->nextFloat() * 0.8f + 0.1f; diff --git a/Minecraft.World/Blocks/CactusTile.cpp b/Minecraft.World/Blocks/CactusTile.cpp index 229c52e6a..62cfb7b2f 100644 --- a/Minecraft.World/Blocks/CactusTile.cpp +++ b/Minecraft.World/Blocks/CactusTile.cpp @@ -10,8 +10,8 @@ CactusTile::CactusTile(int id) : Tile(id, Material::cactus, false) { setTicking(true); - iconTop = NULL; - iconBottom = NULL; + iconTop = nullptr; + iconBottom = nullptr; } void CactusTile::tick(Level* level, int x, int y, int z, Random* random) { diff --git a/Minecraft.World/Blocks/CakeTile.cpp b/Minecraft.World/Blocks/CakeTile.cpp index 53e2e41e3..ad687e6b2 100644 --- a/Minecraft.World/Blocks/CakeTile.cpp +++ b/Minecraft.World/Blocks/CakeTile.cpp @@ -11,9 +11,9 @@ CakeTile::CakeTile(int id) : Tile(id, Material::cake, false) { setTicking(true); - iconTop = NULL; - iconBottom = NULL; - iconInner = NULL; + iconTop = nullptr; + iconBottom = nullptr; + iconInner = nullptr; } void CakeTile::updateShape( diff --git a/Minecraft.World/Blocks/CauldronTile.cpp b/Minecraft.World/Blocks/CauldronTile.cpp index 7c040383c..d8589e61f 100644 --- a/Minecraft.World/Blocks/CauldronTile.cpp +++ b/Minecraft.World/Blocks/CauldronTile.cpp @@ -13,9 +13,9 @@ const std::wstring CauldronTile::TEXTURE_BOTTOM = L"cauldron_bottom"; CauldronTile::CauldronTile(int id) : Tile(id, Material::metal, false) { - iconInner = NULL; - iconTop = NULL; - iconBottom = NULL; + iconInner = nullptr; + iconTop = nullptr; + iconBottom = nullptr; } Icon* CauldronTile::getTexture(int face, int data) { @@ -38,7 +38,7 @@ void CauldronTile::registerIcons(IconRegister* iconRegister) { Icon* CauldronTile::getTexture(const std::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, @@ -78,7 +78,7 @@ bool CauldronTile::use(Level* level, int x, int y, int z, } std::shared_ptr item = player->inventory->getSelected(); - if (item == NULL) { + if (item == nullptr) { return true; } diff --git a/Minecraft.World/Blocks/ChestTile.cpp b/Minecraft.World/Blocks/ChestTile.cpp index 4a866151c..fb87fb809 100644 --- a/Minecraft.World/Blocks/ChestTile.cpp +++ b/Minecraft.World/Blocks/ChestTile.cpp @@ -192,17 +192,17 @@ void ChestTile::neighborChanged(Level* level, int x, int y, int z, int type) { std::shared_ptr(cte) = std::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) { std::shared_ptr container = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (container != NULL) { + if (container != nullptr) { for (unsigned int i = 0; i < container->getContainerSize(); i++) { std::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; float zo = random->nextFloat() * 0.8f + 0.1f; @@ -256,7 +256,7 @@ bool ChestTile::use(Level* level, int x, int y, int z, } std::shared_ptr container = getContainer(level, x, y, z); - if (container != NULL) { + if (container != nullptr) { player->openContainer(container); } @@ -268,7 +268,7 @@ std::shared_ptr ChestTile::getContainer(Level* level, int x, int y, std::shared_ptr container = std::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/Blocks/CommandBlock.cpp b/Minecraft.World/Blocks/CommandBlock.cpp index ce5c1e63c..3666dd549 100644 --- a/Minecraft.World/Blocks/CommandBlock.cpp +++ b/Minecraft.World/Blocks/CommandBlock.cpp @@ -30,8 +30,8 @@ void CommandBlock::neighborChanged(Level* level, int x, int y, int z, void CommandBlock::tick(Level* level, int x, int y, int z, Random* random) { std::shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && - std::dynamic_pointer_cast(tileEntity) != NULL) { + if (tileEntity != nullptr && + std::dynamic_pointer_cast(tileEntity) != nullptr) { std::shared_ptr commandBlock = std::dynamic_pointer_cast(tileEntity); commandBlock->setSuccessCount(commandBlock->performCommand(level)); @@ -49,7 +49,7 @@ bool CommandBlock::use(Level* level, int x, int y, int z, std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (amce != NULL) { + if (amce != nullptr) { player->openTextEdit(amce); } @@ -62,8 +62,8 @@ int CommandBlock::getAnalogOutputSignal(Level* level, int x, int y, int z, int dir) { std::shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && - std::dynamic_pointer_cast(tileEntity) != NULL) { + if (tileEntity != nullptr && + std::dynamic_pointer_cast(tileEntity) != nullptr) { return std::dynamic_pointer_cast(tileEntity) ->getSuccessCount(); } diff --git a/Minecraft.World/Blocks/ComparatorTile.cpp b/Minecraft.World/Blocks/ComparatorTile.cpp index e4e5d4b75..a236a93a5 100644 --- a/Minecraft.World/Blocks/ComparatorTile.cpp +++ b/Minecraft.World/Blocks/ComparatorTile.cpp @@ -202,7 +202,7 @@ bool ComparatorTile::triggerEvent(Level* level, int x, int y, int z, int b0, int b1) { DiodeTile::triggerEvent(level, x, y, z, b0, b1); std::shared_ptr te = level->getTileEntity(x, y, z); - if (te != NULL) { + if (te != nullptr) { return te->triggerEvent(b0, b1); } return false; diff --git a/Minecraft.World/Blocks/CropTile.cpp b/Minecraft.World/Blocks/CropTile.cpp index 474a54f25..736404696 100644 --- a/Minecraft.World/Blocks/CropTile.cpp +++ b/Minecraft.World/Blocks/CropTile.cpp @@ -8,7 +8,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/Blocks/DeadBushTile.cpp b/Minecraft.World/Blocks/DeadBushTile.cpp index 1d1097671..288f0ac1e 100644 --- a/Minecraft.World/Blocks/DeadBushTile.cpp +++ b/Minecraft.World/Blocks/DeadBushTile.cpp @@ -23,7 +23,7 @@ int DeadBushTile::getResource(int data, Random* random, int playerBonusLevel) { void DeadBushTile::playerDestroy(Level* level, std::shared_ptr player, int x, int y, int z, int data) { - if (!level->isClientSide && player->getSelectedItem() != NULL && + if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears_Id) { player->awardStat(GenericStats::blocksMined(id), GenericStats::param_blocksMined(id, data, 1)); diff --git a/Minecraft.World/Blocks/DetectorRailTile.cpp b/Minecraft.World/Blocks/DetectorRailTile.cpp index b7bd2d4e5..722e0eef4 100644 --- a/Minecraft.World/Blocks/DetectorRailTile.cpp +++ b/Minecraft.World/Blocks/DetectorRailTile.cpp @@ -11,7 +11,7 @@ DetectorRailTile::DetectorRailTile(int id) : BaseRailTile(id, true) { setTicking(true); - icons = NULL; + icons = nullptr; } int DetectorRailTile::getTickDelay(Level* level) { return 20; } diff --git a/Minecraft.World/Blocks/DiodeTile.cpp b/Minecraft.World/Blocks/DiodeTile.cpp index f5d324ab5..3d5753752 100644 --- a/Minecraft.World/Blocks/DiodeTile.cpp +++ b/Minecraft.World/Blocks/DiodeTile.cpp @@ -256,7 +256,7 @@ bool DiodeTile::isSolidRender(bool isServerLevel) { return false; } 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, diff --git a/Minecraft.World/Blocks/DispenserTile.cpp b/Minecraft.World/Blocks/DispenserTile.cpp index b6133a5d8..bb29a41dd 100644 --- a/Minecraft.World/Blocks/DispenserTile.cpp +++ b/Minecraft.World/Blocks/DispenserTile.cpp @@ -18,9 +18,9 @@ BehaviorRegistry DispenserTile::REGISTRY = 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) { return 4; } @@ -101,7 +101,7 @@ void DispenserTile::dispenseFrom(Level* level, int x, int y, int z) { BlockSourceImpl source(level, x, y, z); std::shared_ptr trap = std::dynamic_pointer_cast(source.getEntity()); - if (trap == NULL) return; + if (trap == nullptr) return; int slot = trap->getRandomSlot(); if (slot < 0) { @@ -170,10 +170,10 @@ void DispenserTile::onRemove(Level* level, int x, int y, int z, int id, std::shared_ptr container = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (container != NULL) { + if (container != nullptr) { for (unsigned int i = 0; i < container->getContainerSize(); i++) { std::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; float zo = random->nextFloat() * 0.8f + 0.1f; diff --git a/Minecraft.World/Blocks/DropperTile.cpp b/Minecraft.World/Blocks/DropperTile.cpp index a25d620c4..b7e1f13c6 100644 --- a/Minecraft.World/Blocks/DropperTile.cpp +++ b/Minecraft.World/Blocks/DropperTile.cpp @@ -33,7 +33,7 @@ void DropperTile::dispenseFrom(Level* level, int x, int y, int z) { BlockSourceImpl source(level, x, y, z); std::shared_ptr trap = std::dynamic_pointer_cast(source.getEntity()); - if (trap == NULL) return; + if (trap == nullptr) return; int slot = trap->getRandomSlot(); if (slot < 0) { @@ -46,12 +46,12 @@ void DropperTile::dispenseFrom(Level* level, int x, int y, int z) { z + Facing::STEP_Z[face]); std::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; } else { @@ -60,7 +60,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/Blocks/EnchantmentTableTile.cpp b/Minecraft.World/Blocks/EnchantmentTableTile.cpp index d337dd0ee..9cd0c39be 100644 --- a/Minecraft.World/Blocks/EnchantmentTableTile.cpp +++ b/Minecraft.World/Blocks/EnchantmentTableTile.cpp @@ -14,8 +14,8 @@ EnchantmentTableTile::EnchantmentTableTile(int id) updateDefaultShape(); setLightBlock(0); - iconTop = NULL; - iconBottom = NULL; + iconTop = nullptr; + iconBottom = nullptr; } // 4J Added override diff --git a/Minecraft.World/Blocks/EnderChestTile.cpp b/Minecraft.World/Blocks/EnderChestTile.cpp index 5a1b60f15..36c4185bf 100644 --- a/Minecraft.World/Blocks/EnderChestTile.cpp +++ b/Minecraft.World/Blocks/EnderChestTile.cpp @@ -55,7 +55,7 @@ bool EnderChestTile::use(Level* level, int x, int y, int z, std::shared_ptr enderChest = std::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/Blocks/FallingTile.cpp b/Minecraft.World/Blocks/FallingTile.cpp index eb7adda42..df4028903 100644 --- a/Minecraft.World/Blocks/FallingTile.cpp +++ b/Minecraft.World/Blocks/FallingTile.cpp @@ -21,7 +21,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 @@ -114,11 +114,11 @@ void FallingTile::tick() { if (hv) { hv->onLand(level, xt, yt, zt, data); } - if (tileData != NULL && Tile::tiles[tile]->isEntityTile()) { + if (tileData != nullptr && Tile::tiles[tile]->isEntityTile()) { std::shared_ptr tileEntity = level->getTileEntity(xt, yt, zt); - if (tileEntity != NULL) { + if (tileEntity != nullptr) { CompoundTag* swap = new CompoundTag(); tileEntity->save(swap); std::vector* allTags = tileData->getAllTags(); @@ -203,7 +203,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/Blocks/FarmTile.cpp b/Minecraft.World/Blocks/FarmTile.cpp index 191f0963c..732103c05 100644 --- a/Minecraft.World/Blocks/FarmTile.cpp +++ b/Minecraft.World/Blocks/FarmTile.cpp @@ -6,8 +6,8 @@ #include "FarmTile.h" FarmTile::FarmTile(int id) : Tile(id, Material::dirt, false) { - iconWet = NULL; - iconDry = NULL; + iconWet = nullptr; + iconDry = nullptr; setTicking(true); updateDefaultShape(); diff --git a/Minecraft.World/Blocks/FenceGateTile.cpp b/Minecraft.World/Blocks/FenceGateTile.cpp index 2b947b0e8..bdb608dda 100644 --- a/Minecraft.World/Blocks/FenceGateTile.cpp +++ b/Minecraft.World/Blocks/FenceGateTile.cpp @@ -85,7 +85,7 @@ bool FenceGateTile::use(Level* level, int x, int y, int z, // 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 + 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/Blocks/FenceTile.cpp b/Minecraft.World/Blocks/FenceTile.cpp index bbdc24b61..b8084d0d5 100644 --- a/Minecraft.World/Blocks/FenceTile.cpp +++ b/Minecraft.World/Blocks/FenceTile.cpp @@ -101,7 +101,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()) { return tileInstance->material != Material::vegetable; diff --git a/Minecraft.World/Blocks/FireTile.cpp b/Minecraft.World/Blocks/FireTile.cpp index bfa27e540..ce4ff7b81 100644 --- a/Minecraft.World/Blocks/FireTile.cpp +++ b/Minecraft.World/Blocks/FireTile.cpp @@ -23,7 +23,7 @@ FireTile::FireTile(int id) : Tile(id, Material::fire, false) { burnOdds = new int[256]; memset(burnOdds, 0, sizeof(int) * 256); - icons = NULL; + icons = nullptr; setTicking(true); } diff --git a/Minecraft.World/Blocks/FlowerPotTile.cpp b/Minecraft.World/Blocks/FlowerPotTile.cpp index 118ae8948..4e1dc5599 100644 --- a/Minecraft.World/Blocks/FlowerPotTile.cpp +++ b/Minecraft.World/Blocks/FlowerPotTile.cpp @@ -28,7 +28,7 @@ bool FlowerPotTile::use(Level* level, int x, int y, int z, float clickX, float clickY, float clickZ, bool soundOnly) { std::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); @@ -52,7 +52,7 @@ int FlowerPotTile::cloneTileId(Level* level, int x, int y, int z) { std::shared_ptr item = getItemFromType(level->getData(x, y, z)); - if (item == NULL) { + if (item == nullptr) { return Item::flowerPot_Id; } else { return item->id; @@ -63,7 +63,7 @@ int FlowerPotTile::cloneTileData(Level* level, int x, int y, int z) { std::shared_ptr item = getItemFromType(level->getData(x, y, z)); - if (item == NULL) { + if (item == nullptr) { return Item::flowerPot_Id; } else { return item->getAuxValue(); @@ -92,7 +92,7 @@ void FlowerPotTile::spawnResources(Level* level, int x, int y, int z, int data, if (data > 0) { std::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/Blocks/FurnaceTile.cpp b/Minecraft.World/Blocks/FurnaceTile.cpp index 296fab281..d9dc2092f 100644 --- a/Minecraft.World/Blocks/FurnaceTile.cpp +++ b/Minecraft.World/Blocks/FurnaceTile.cpp @@ -17,8 +17,8 @@ FurnaceTile::FurnaceTile(int id, bool lit) random = new Random(); this->lit = lit; - iconTop = NULL; - iconFront = NULL; + iconTop = nullptr; + iconFront = nullptr; } int FurnaceTile::getResource(int data, Random* random, int playerBonusLevel) { @@ -106,7 +106,7 @@ bool FurnaceTile::use(Level* level, int x, int y, int z, std::shared_ptr furnace = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (furnace != NULL) player->openFurnace(furnace); + if (furnace != nullptr) player->openFurnace(furnace); return true; } @@ -122,7 +122,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); } @@ -155,10 +155,10 @@ void FurnaceTile::onRemove(Level* level, int x, int y, int z, int id, std::shared_ptr container = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (container != NULL) { + if (container != nullptr) { for (unsigned int i = 0; i < container->getContainerSize(); i++) { std::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; float zo = random->nextFloat() * 0.8f + 0.1f; diff --git a/Minecraft.World/Blocks/GrassTile.cpp b/Minecraft.World/Blocks/GrassTile.cpp index 2c4a7347c..b1a41e2d5 100644 --- a/Minecraft.World/Blocks/GrassTile.cpp +++ b/Minecraft.World/Blocks/GrassTile.cpp @@ -11,9 +11,9 @@ #include "../../Minecraft.Client/Rendering/Tesselator.h" 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/Blocks/HopperTile.cpp b/Minecraft.World/Blocks/HopperTile.cpp index a4c6f4319..7915cc05e 100644 --- a/Minecraft.World/Blocks/HopperTile.cpp +++ b/Minecraft.World/Blocks/HopperTile.cpp @@ -74,7 +74,7 @@ bool HopperTile::use(Level* level, int x, int y, int z, return true; } std::shared_ptr hopper = getHopper(level, x, y, z); - if (hopper != NULL) player->openHopper(hopper); + if (hopper != nullptr) player->openHopper(hopper); return true; } @@ -98,10 +98,10 @@ void HopperTile::onRemove(Level* level, int x, int y, int z, int id, int data) { std::shared_ptr container = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (container != NULL) { + if (container != nullptr) { for (int i = 0; i < container->getContainerSize(); i++) { std::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; float zo = random.nextFloat() * 0.8f + 0.1f; @@ -177,7 +177,7 @@ void HopperTile::registerIcons(IconRegister* iconRegister) { Icon* HopperTile::getTexture(const std::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; } std::wstring HopperTile::getTileItemIconName() { return L"hopper"; } diff --git a/Minecraft.World/Blocks/HugeMushroomTile.cpp b/Minecraft.World/Blocks/HugeMushroomTile.cpp index 039816c8e..8b727baba 100644 --- a/Minecraft.World/Blocks/HugeMushroomTile.cpp +++ b/Minecraft.World/Blocks/HugeMushroomTile.cpp @@ -10,9 +10,9 @@ const std::wstring HugeMushroomTile::TEXTURE_TYPE[] = {L"skin_brown", 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/Blocks/IceTile.cpp b/Minecraft.World/Blocks/IceTile.cpp index 37c08ed2a..7d6e660c5 100644 --- a/Minecraft.World/Blocks/IceTile.cpp +++ b/Minecraft.World/Blocks/IceTile.cpp @@ -27,7 +27,7 @@ void IceTile::playerDestroy(Level* level, std::shared_ptr player, int x, if (isSilkTouchable() && EnchantmentHelper::hasSilkTouch(player)) { std::shared_ptr item = getSilkTouchItemInstance(data); - if (item != NULL) { + if (item != nullptr) { popResource(level, x, y, z, item); } } else { diff --git a/Minecraft.World/Blocks/JukeboxTile.cpp b/Minecraft.World/Blocks/JukeboxTile.cpp index 0abc7fbe1..3897b5a48 100644 --- a/Minecraft.World/Blocks/JukeboxTile.cpp +++ b/Minecraft.World/Blocks/JukeboxTile.cpp @@ -24,7 +24,7 @@ void JukeboxTile::Entity::load(CompoundTag* tag) { void JukeboxTile::Entity::save(CompoundTag* tag) { TileEntity::save(tag); - if (getRecord() != NULL) { + if (getRecord() != nullptr) { tag->putCompound(L"RecordItem", getRecord()->save(new CompoundTag())); tag->putInt(L"Record", getRecord()->id); @@ -52,7 +52,7 @@ void JukeboxTile::Entity::setRecord(std::shared_ptr record) { } JukeboxTile::JukeboxTile(int id) : BaseEntityTile(id, Material::wood) { - iconTop = NULL; + iconTop = nullptr; } Icon* JukeboxTile::getTexture(int face, int data) { @@ -100,10 +100,10 @@ void JukeboxTile::dropRecording(Level* level, int x, int y, int z) { std::shared_ptr rte = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (rte == NULL) return; + if (rte == nullptr) return; std::shared_ptr oldRecord = rte->getRecord(); - if (oldRecord == NULL) return; + if (oldRecord == nullptr) return; level->levelEvent(LevelEvent::SOUND_PLAY_RECORDING, x, y, z, 0); // 4J-PB- the level event will play the music @@ -154,6 +154,6 @@ int JukeboxTile::getAnalogOutputSignal(Level* level, int x, int y, int z, std::dynamic_pointer_cast( level->getTileEntity(x, y, z)) ->getRecord(); - return record == NULL ? Redstone::SIGNAL_NONE + return record == nullptr ? Redstone::SIGNAL_NONE : record->id + 1 - Item::record_01_Id; } \ No newline at end of file diff --git a/Minecraft.World/Blocks/LeafTile.cpp b/Minecraft.World/Blocks/LeafTile.cpp index e4c158500..ae12b03a2 100644 --- a/Minecraft.World/Blocks/LeafTile.cpp +++ b/Minecraft.World/Blocks/LeafTile.cpp @@ -26,7 +26,7 @@ const std::wstring LeafTile::TEXTURES[2][4] = { // setting isSolidRender to true by default totally correct. LeafTile::LeafTile(int id) : TransparentTile(id, Material::leaves, false, true) { - checkBuffer = NULL; + checkBuffer = nullptr; fancyTextureSet = 0; setTicking(true); } @@ -120,7 +120,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]; } @@ -264,7 +264,7 @@ void LeafTile::spawnResources(Level* level, int x, int y, int z, int data, void LeafTile::playerDestroy(Level* level, std::shared_ptr player, int x, int y, int z, int data) { - if (!level->isClientSide && player->getSelectedItem() != NULL && + if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id) { player->awardStat(GenericStats::blocksMined(id), GenericStats::param_blocksMined(id, data, 1)); diff --git a/Minecraft.World/Blocks/LiquidTile.cpp b/Minecraft.World/Blocks/LiquidTile.cpp index 1c94595f9..cda40aa15 100644 --- a/Minecraft.World/Blocks/LiquidTile.cpp +++ b/Minecraft.World/Blocks/LiquidTile.cpp @@ -379,5 +379,5 @@ Icon* LiquidTile::getTexture(const std::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/Blocks/Material.cpp b/Minecraft.World/Blocks/Material.cpp index 6daeb824a..d80d9ae91 100644 --- a/Minecraft.World/Blocks/Material.cpp +++ b/Minecraft.World/Blocks/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() { Material::air = new GasMaterial(MaterialColor::none); diff --git a/Minecraft.World/Blocks/MaterialColor.cpp b/Minecraft.World/Blocks/MaterialColor.cpp index 456c7969a..2b4fd5e34 100644 --- a/Minecraft.World/Blocks/MaterialColor.cpp +++ b/Minecraft.World/Blocks/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() { MaterialColor::colors = new MaterialColor*[16]; diff --git a/Minecraft.World/Blocks/MelonTile.cpp b/Minecraft.World/Blocks/MelonTile.cpp index 434ab847d..b18f6be12 100644 --- a/Minecraft.World/Blocks/MelonTile.cpp +++ b/Minecraft.World/Blocks/MelonTile.cpp @@ -4,7 +4,7 @@ #include "../Headers/net.minecraft.world.h" #include "../Util/Facing.h" -MelonTile::MelonTile(int id) : Tile(id, Material::vegetable) { iconTop = NULL; } +MelonTile::MelonTile(int id) : Tile(id, Material::vegetable) { iconTop = nullptr; } Icon* MelonTile::getTexture(int face, int data) { if (face == Facing::UP || face == Facing::DOWN) return iconTop; diff --git a/Minecraft.World/Blocks/MobSpawner.cpp b/Minecraft.World/Blocks/MobSpawner.cpp index 1b868aceb..5fdcfde01 100644 --- a/Minecraft.World/Blocks/MobSpawner.cpp +++ b/Minecraft.World/Blocks/MobSpawner.cpp @@ -164,8 +164,8 @@ const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies, 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++) { x += @@ -186,7 +186,7 @@ const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies, float yy = (float)y; float zz = z + 0.5f; if (level->getNearestPlayer( - xx, yy, zz, MIN_SPAWN_DISTANCE) != NULL) { + xx, yy, zz, MIN_SPAWN_DISTANCE) != nullptr) { continue; } else { float xd = xx - spawnPos->x; @@ -198,10 +198,10 @@ const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies, } } - if (currentMobType == NULL) { + if (currentMobType == nullptr) { currentMobType = level->getRandomMobSpawnAt( mobCategory, x, y, z); - if (currentMobType == NULL) { + if (currentMobType == nullptr) { break; } } diff --git a/Minecraft.World/Blocks/MushroomPlantTile.cpp b/Minecraft.World/Blocks/MushroomPlantTile.cpp index c55636729..7b5e272d2 100644 --- a/Minecraft.World/Blocks/MushroomPlantTile.cpp +++ b/Minecraft.World/Blocks/MushroomPlantTile.cpp @@ -65,7 +65,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) { f = new HugeMushroomFeature(0); @@ -73,11 +73,11 @@ 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) delete f; + if (f != nullptr) delete f; return false; } - if (f != NULL) delete f; + if (f != nullptr) delete f; return true; } \ No newline at end of file diff --git a/Minecraft.World/Blocks/MycelTile.cpp b/Minecraft.World/Blocks/MycelTile.cpp index dc7cc96e3..842c2a746 100644 --- a/Minecraft.World/Blocks/MycelTile.cpp +++ b/Minecraft.World/Blocks/MycelTile.cpp @@ -5,8 +5,8 @@ #include "../Headers/net.minecraft.world.h" MycelTile::MycelTile(int id) : Tile(id, Material::grass) { - iconTop = NULL; - iconSnowSide = NULL; + iconTop = nullptr; + iconSnowSide = nullptr; setTicking(true); } diff --git a/Minecraft.World/Blocks/NotGateTile.cpp b/Minecraft.World/Blocks/NotGateTile.cpp index a71e12c2b..45395fce1 100644 --- a/Minecraft.World/Blocks/NotGateTile.cpp +++ b/Minecraft.World/Blocks/NotGateTile.cpp @@ -206,7 +206,7 @@ void NotGateTile::levelTimeChanged(Level* level, int64_t delta, int64_t newTime) { std::deque* toggles = recentToggles[level]; - if (toggles != NULL) { + if (toggles != nullptr) { for (AUTO_VAR(it, toggles->begin()); it != toggles->end(); ++it) { (*it).when += delta; } diff --git a/Minecraft.World/Blocks/NoteBlockTile.cpp b/Minecraft.World/Blocks/NoteBlockTile.cpp index 8592a2ce9..0a87ae3f9 100644 --- a/Minecraft.World/Blocks/NoteBlockTile.cpp +++ b/Minecraft.World/Blocks/NoteBlockTile.cpp @@ -15,7 +15,7 @@ void NoteBlockTile::neighborChanged(Level* level, int x, int y, int z, 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) { mte->playNote(level, x, y, z); } @@ -36,7 +36,7 @@ bool NoteBlockTile::use(Level* level, int x, int y, int z, std::shared_ptr mte = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (mte != NULL) { + if (mte != nullptr) { mte->tune(); mte->playNote(level, x, y, z); } @@ -49,7 +49,7 @@ void NoteBlockTile::attack(Level* level, int x, int y, int z, std::shared_ptr mte = std::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); } std::shared_ptr NoteBlockTile::newTileEntity(Level* level) { diff --git a/Minecraft.World/Blocks/PistonBaseTile.cpp b/Minecraft.World/Blocks/PistonBaseTile.cpp index 8a85152cc..d128d911c 100644 --- a/Minecraft.World/Blocks/PistonBaseTile.cpp +++ b/Minecraft.World/Blocks/PistonBaseTile.cpp @@ -47,9 +47,9 @@ PistonBaseTile::PistonBaseTile(int id, bool isSticky) setSoundType(SOUND_STONE); setDestroyTime(0.5f); - iconInside = NULL; - iconBack = NULL; - iconPlatform = NULL; + iconInside = nullptr; + iconBack = nullptr; + iconPlatform = nullptr; } Icon* PistonBaseTile::getPlatformTexture() { return iconPlatform; } @@ -92,7 +92,7 @@ Icon* PistonBaseTile::getTexture(const std::wstring& name) { return Tile::pistonStickyBase->iconPlatform; if (name.compare(INSIDE_TEX) == 0) return Tile::pistonBase->iconInside; - return NULL; + return nullptr; } //@Override @@ -135,7 +135,7 @@ void PistonBaseTile::neighborChanged(Level* level, int x, int y, int z, } void PistonBaseTile::onPlace(Level* level, int x, int y, int z) { - if (!level->isClientSide && level->getTileEntity(x, y, z) == NULL && + if (!level->isClientSide && level->getTileEntity(x, y, z) == nullptr && !ignoreUpdate()) { checkIfExtend(level, x, y, z); } @@ -252,9 +252,9 @@ bool PistonBaseTile::triggerEvent(Level* level, int x, int y, int z, int param1, std::shared_ptr prevTileEntity = level->getTileEntity( x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], z + Facing::STEP_Z[facing]); - if (prevTileEntity != NULL && + if (prevTileEntity != nullptr && std::dynamic_pointer_cast(prevTileEntity) != - NULL) { + nullptr) { std::dynamic_pointer_cast(prevTileEntity) ->finalTick(); } @@ -287,9 +287,9 @@ bool PistonBaseTile::triggerEvent(Level* level, int x, int y, int z, int param1, // piston which is changing too fast std::shared_ptr tileEntity = level->getTileEntity(twoX, twoY, twoZ); - if (tileEntity != NULL && + if (tileEntity != nullptr && std::dynamic_pointer_cast(tileEntity) != - NULL) { + nullptr) { std::shared_ptr ppe = std::dynamic_pointer_cast( tileEntity); diff --git a/Minecraft.World/Blocks/PistonExtensionTile.cpp b/Minecraft.World/Blocks/PistonExtensionTile.cpp index 1f7b0d52e..3658c575a 100644 --- a/Minecraft.World/Blocks/PistonExtensionTile.cpp +++ b/Minecraft.World/Blocks/PistonExtensionTile.cpp @@ -7,7 +7,7 @@ PistonExtensionTile::PistonExtensionTile(int id) : Tile(id, Material::piston, false) { // 4J added initialiser - overrideTopTexture = NULL; + overrideTopTexture = nullptr; setSoundType(SOUND_STONE); setDestroyTime(0.5f); @@ -18,7 +18,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, @@ -61,7 +61,7 @@ Icon* PistonExtensionTile::getTexture(int face, int data) { int facing = getFacing(data); if (face == facing) { - if (overrideTopTexture != NULL) { + if (overrideTopTexture != nullptr) { return overrideTopTexture; } if ((data & STICKY_BIT) != 0) { diff --git a/Minecraft.World/Blocks/PistonMovingTileEntity.cpp b/Minecraft.World/Blocks/PistonMovingTileEntity.cpp index f4109695d..a104299e6 100644 --- a/Minecraft.World/Blocks/PistonMovingTileEntity.cpp +++ b/Minecraft.World/Blocks/PistonMovingTileEntity.cpp @@ -21,8 +21,8 @@ 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) { std::shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && - std::dynamic_pointer_cast(tileEntity) != NULL) { + if (tileEntity != nullptr && + std::dynamic_pointer_cast(tileEntity) != nullptr) { std::dynamic_pointer_cast(tileEntity)->finalTick(); } else { BaseEntityTile::onRemove(level, x, y, z, id, data); @@ -51,7 +51,7 @@ bool PistonMovingPiece::use( if (soundOnly) return false; // this is a special case in order to help removing invisible, unbreakable, // blocks in the world - if (!level->isClientSide && 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); return true; @@ -69,7 +69,7 @@ void PistonMovingPiece::spawnResources(Level* level, int x, int y, int z, if (level->isClientSide) return; std::shared_ptr entity = getEntity(level, x, y, z); - if (entity == NULL) { + if (entity == nullptr) { return; } @@ -95,7 +95,7 @@ std::shared_ptr PistonMovingPiece::newMovingPieceEntity( std::optional PistonMovingPiece::getAABB(Level* level, int x, int y, int z) { std::shared_ptr entity = getEntity(level, x, y, z); - if (entity == NULL) { + if (entity == nullptr) { return std::nullopt; } @@ -115,10 +115,10 @@ void PistonMovingPiece::updateShape( { std::shared_ptr entity = std::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; } tile->updateShape(level, x, y, z); @@ -175,8 +175,8 @@ std::optional PistonMovingPiece::getAABB(Level* level, int x, int y, std::shared_ptr PistonMovingPiece::getEntity( LevelSource* level, int x, int y, int z) { std::shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && - std::dynamic_pointer_cast(tileEntity) != NULL) { + if (tileEntity != nullptr && + std::dynamic_pointer_cast(tileEntity) != nullptr) { return std::dynamic_pointer_cast(tileEntity); } return nullptr; diff --git a/Minecraft.World/Blocks/PortalTile.cpp b/Minecraft.World/Blocks/PortalTile.cpp index bd4f199b3..0629d13dc 100644 --- a/Minecraft.World/Blocks/PortalTile.cpp +++ b/Minecraft.World/Blocks/PortalTile.cpp @@ -29,7 +29,7 @@ void PortalTile::tick(Level* level, int x, int y, int z, Random* random) { int iResult = 0; std::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(); } @@ -184,7 +184,7 @@ void PortalTile::entityInside(Level* level, int x, int y, int z, std::shared_ptr entity) { if (entity->GetType() == eTYPE_EXPERIENCEORB) return; // 4J added - if (entity->riding == NULL && entity->rider.lock() == NULL) + if (entity->riding == nullptr && entity->rider.lock() == nullptr) entity->handleInsidePortal(); } diff --git a/Minecraft.World/Blocks/PressurePlateTile.cpp b/Minecraft.World/Blocks/PressurePlateTile.cpp index 48a273f0d..4aac68a96 100644 --- a/Minecraft.World/Blocks/PressurePlateTile.cpp +++ b/Minecraft.World/Blocks/PressurePlateTile.cpp @@ -23,7 +23,7 @@ int PressurePlateTile::getSignalForData(int data) { } int PressurePlateTile::getSignalStrength(Level* level, int x, int y, int z) { - std::vector >* entities = NULL; + std::vector >* entities = nullptr; AABB at_bb = getSensitiveAABB(x, y, z); if (sensitivity == everything) entities = level->getEntities(nullptr, &at_bb); @@ -35,7 +35,7 @@ int PressurePlateTile::getSignalStrength(Level* level, int x, int y, int z) { __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_VAR(it, entities->begin()); it != entities->end(); ++it) { std::shared_ptr e = *it; if (!e->isIgnoringTileTriggers()) { diff --git a/Minecraft.World/Blocks/PumpkinTile.cpp b/Minecraft.World/Blocks/PumpkinTile.cpp index 3b8da7a74..6ad35cc18 100644 --- a/Minecraft.World/Blocks/PumpkinTile.cpp +++ b/Minecraft.World/Blocks/PumpkinTile.cpp @@ -13,8 +13,8 @@ const std::wstring PumpkinTile::TEXTURE_LANTERN = L"pumpkin_jack"; PumpkinTile::PumpkinTile(int id, bool lit) : DirectionalTile(id, Material::vegetable, false) { - iconTop = NULL; - iconFace = NULL; + iconTop = nullptr; + iconFace = nullptr; setTicking(true); this->lit = lit; } diff --git a/Minecraft.World/Blocks/RedStoneDustTile.cpp b/Minecraft.World/Blocks/RedStoneDustTile.cpp index 02aceb79b..3550b5edd 100644 --- a/Minecraft.World/Blocks/RedStoneDustTile.cpp +++ b/Minecraft.World/Blocks/RedStoneDustTile.cpp @@ -28,10 +28,10 @@ RedStoneDustTile::RedStoneDustTile(int id) updateDefaultShape(); - iconCross = NULL; - iconLine = NULL; - iconCrossOver = NULL; - iconLineOver = NULL; + iconCross = nullptr; + iconLine = nullptr; + iconCrossOver = nullptr; + iconLineOver = nullptr; } // 4J Added override @@ -430,5 +430,5 @@ Icon* RedStoneDustTile::getTexture(const std::wstring& name) { return Tile::redStoneDust->iconCrossOver; if (name.compare(TEXTURE_LINE_OVERLAY) == 0) return Tile::redStoneDust->iconLineOver; - return NULL; + return nullptr; } diff --git a/Minecraft.World/Blocks/SandStoneTile.cpp b/Minecraft.World/Blocks/SandStoneTile.cpp index c9a5f8b7d..25bd067eb 100644 --- a/Minecraft.World/Blocks/SandStoneTile.cpp +++ b/Minecraft.World/Blocks/SandStoneTile.cpp @@ -13,9 +13,9 @@ int SandStoneTile::SANDSTONE_NAMES[SANDSTONE_BLOCK_NAMES] = { IDS_TILE_SANDSTONE, IDS_TILE_SANDSTONE_CHISELED, IDS_TILE_SANDSTONE_SMOOTH}; 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/Blocks/SaplingPlantTile.cpp b/Minecraft.World/Blocks/SaplingPlantTile.cpp index 951107a3c..c0c1ecdbd 100644 --- a/Minecraft.World/Blocks/SaplingPlantTile.cpp +++ b/Minecraft.World/Blocks/SaplingPlantTile.cpp @@ -15,7 +15,7 @@ const std::wstring Sapling::TEXTURE_NAMES[] = { Sapling::Sapling(int id) : Bush(id) { this->updateDefaultShape(); - icons = NULL; + icons = nullptr; } // 4J Added override @@ -53,7 +53,7 @@ void Sapling::advanceTree(Level* level, int x, int y, int z, Random* random) { 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; @@ -77,11 +77,11 @@ 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, @@ -117,7 +117,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) delete f; + if (f != nullptr) delete f; } unsigned int Sapling::getDescriptionId(int iData /*= -1*/) { diff --git a/Minecraft.World/Blocks/SkullTile.cpp b/Minecraft.World/Blocks/SkullTile.cpp index 1a0340b7d..002868bcd 100644 --- a/Minecraft.World/Blocks/SkullTile.cpp +++ b/Minecraft.World/Blocks/SkullTile.cpp @@ -72,7 +72,7 @@ int SkullTile::cloneTileData(Level* level, int x, int y, int z) { std::shared_ptr tileEntity = level->getTileEntity(x, y, z); std::shared_ptr skull = std::dynamic_pointer_cast(tileEntity); - if (skull != NULL) { + if (skull != nullptr) { return skull->getSkullType(); } return BaseEntityTile::cloneTileData(level, x, y, z); @@ -300,7 +300,7 @@ bool SkullTile::isSkullAt(Level* level, int x, int y, int z, int skullType) { std::shared_ptr te = level->getTileEntity(x, y, z); std::shared_ptr skull = std::dynamic_pointer_cast(te); - if (skull == NULL) { + if (skull == nullptr) { return false; } return skull->getSkullType() == skullType; diff --git a/Minecraft.World/Blocks/SmoothStoneBrickTile.cpp b/Minecraft.World/Blocks/SmoothStoneBrickTile.cpp index 154dbc550..76faab042 100644 --- a/Minecraft.World/Blocks/SmoothStoneBrickTile.cpp +++ b/Minecraft.World/Blocks/SmoothStoneBrickTile.cpp @@ -12,7 +12,7 @@ const unsigned int SmoothStoneBrickTile::SMOOTH_STONE_BRICK_NAMES IDS_TILE_STONE_BRICK_SMOOTH_CHISELED}; SmoothStoneBrickTile::SmoothStoneBrickTile(int id) : Tile(id, Material::stone) { - icons = NULL; + icons = nullptr; } Icon* SmoothStoneBrickTile::getTexture(int face, int data) { diff --git a/Minecraft.World/Blocks/StairTile.cpp b/Minecraft.World/Blocks/StairTile.cpp index 244c58895..7cf98ba3f 100644 --- a/Minecraft.World/Blocks/StairTile.cpp +++ b/Minecraft.World/Blocks/StairTile.cpp @@ -53,7 +53,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, @@ -415,7 +415,7 @@ HitResult* StairTile::clip(Level* level, int xt, int yt, int zt, Vec3* a, Vec3* b) { 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; @@ -434,15 +434,15 @@ HitResult* StairTile::clip(Level* level, int xt, int yt, int zt, Vec3* a, } 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); if (dist > closestDist) { diff --git a/Minecraft.World/Blocks/StemTile.cpp b/Minecraft.World/Blocks/StemTile.cpp index 890a34be5..4f8665136 100644 --- a/Minecraft.World/Blocks/StemTile.cpp +++ b/Minecraft.World/Blocks/StemTile.cpp @@ -16,7 +16,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) { return tile == Tile::farmland_Id; } @@ -175,7 +175,7 @@ void StemTile::spawnResources(Level* level, int x, int y, int z, int data, 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/Blocks/TallGrassPlantTile.cpp b/Minecraft.World/Blocks/TallGrassPlantTile.cpp index ac0379d20..3367d28ca 100644 --- a/Minecraft.World/Blocks/TallGrassPlantTile.cpp +++ b/Minecraft.World/Blocks/TallGrassPlantTile.cpp @@ -76,7 +76,7 @@ int TallGrass::getResourceCountForLootBonus(int bonusLevel, Random* random) { void TallGrass::playerDestroy(Level* level, std::shared_ptr player, int x, int y, int z, int data) { - if (!level->isClientSide && player->getSelectedItem() != NULL && + if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id) { player->awardStat(GenericStats::blocksMined(id), GenericStats::param_blocksMined(id, data, 1)); diff --git a/Minecraft.World/Blocks/TheEndPortalFrameTile.cpp b/Minecraft.World/Blocks/TheEndPortalFrameTile.cpp index a576f123c..2c531b244 100644 --- a/Minecraft.World/Blocks/TheEndPortalFrameTile.cpp +++ b/Minecraft.World/Blocks/TheEndPortalFrameTile.cpp @@ -9,8 +9,8 @@ const std::wstring TheEndPortalFrameTile::TEXTURE_EYE = L"endframe_eye"; TheEndPortalFrameTile::TheEndPortalFrameTile(int id) : Tile(id, Material::glass, false) { - iconTop = NULL; - iconEye = NULL; + iconTop = nullptr; + iconEye = nullptr; } Icon* TheEndPortalFrameTile::getTexture(int face, int data) { diff --git a/Minecraft.World/Blocks/TheEndPortalTile.cpp b/Minecraft.World/Blocks/TheEndPortalTile.cpp index 89a41c0dc..f83226946 100644 --- a/Minecraft.World/Blocks/TheEndPortalTile.cpp +++ b/Minecraft.World/Blocks/TheEndPortalTile.cpp @@ -54,7 +54,7 @@ void TheEndPortal::entityInside(Level* level, int x, int y, int z, std::shared_ptr entity) { if (entity->GetType() == eTYPE_EXPERIENCEORB) return; // 4J added - if (entity->riding == NULL && entity->rider.lock() == NULL) { + if (entity->riding == nullptr && entity->rider.lock() == nullptr) { if (!level->isClientSide) { if (entity->instanceof(eTYPE_PLAYER)) { // 4J Stu - Update the level data position so that the diff --git a/Minecraft.World/Blocks/ThinFenceTile.cpp b/Minecraft.World/Blocks/ThinFenceTile.cpp index 7e407a231..b11a29bfa 100644 --- a/Minecraft.World/Blocks/ThinFenceTile.cpp +++ b/Minecraft.World/Blocks/ThinFenceTile.cpp @@ -7,7 +7,7 @@ ThinFenceTile::ThinFenceTile(int id, const std::wstring& tex, const std::wstring& edgeTex, Material* material, bool dropsResources) : Tile(id, material, false) { - iconSide = NULL; + iconSide = nullptr; edgeTexture = edgeTex; this->dropsResources = dropsResources; this->texture = tex; diff --git a/Minecraft.World/Blocks/Tile.cpp b/Minecraft.World/Blocks/Tile.cpp index f29a77a6f..f312d74d7 100644 --- a/Minecraft.World/Blocks/Tile.cpp +++ b/Minecraft.World/Blocks/Tile.cpp @@ -23,18 +23,18 @@ std::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]; @@ -47,182 +47,182 @@ unsigned char bool Tile::mipmapEnable[TILE_NUM_COUNT]; bool Tile::propagate[TILE_NUM_COUNT]; -Tile** Tile::tiles = NULL; +Tile** Tile::tiles = nullptr; -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::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 = 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; +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 = 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; +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::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 = NULL; -Tile* Tile::enderChest = NULL; -TripWireSourceTile* Tile::tripWireSource = NULL; -Tile* Tile::tripWire = NULL; -Tile* Tile::emeraldBlock = NULL; +Tile* Tile::emeraldOre = nullptr; +Tile* Tile::enderChest = nullptr; +TripWireSourceTile* Tile::tripWireSource = nullptr; +Tile* Tile::tripWire = nullptr; +Tile* Tile::emeraldBlock = nullptr; -Tile* Tile::cocoa = NULL; -Tile* Tile::skull = NULL; +Tile* Tile::cocoa = nullptr; +Tile* Tile::skull = nullptr; -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; +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 = NULL; -Tile* Tile::redstoneBlock = NULL; +DaylightDetectorTile* Tile::daylightDetector = nullptr; +Tile* Tile::redstoneBlock = nullptr; -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::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 = NULL; -Tile* Tile::woolCarpet = NULL; -Tile* Tile::clayHardened = NULL; -Tile* Tile::coalBlock = NULL; +Tile* Tile::hayBlock = nullptr; +Tile* Tile::woolCarpet = nullptr; +Tile* Tile::clayHardened = nullptr; +Tile* Tile::coalBlock = nullptr; thread_local Tile::ThreadStorage* Tile::m_tlsShape = nullptr; @@ -1704,8 +1704,8 @@ void Tile::staticCtor() { ->setUseDescriptionId(IDS_DESC_ANVIL); for (int i = 0; i < 256; i++) { - if (Tile::tiles[i] != NULL) { - if (Item::items[i] == NULL) { + if (Tile::tiles[i] != nullptr) { + if (Item::items[i] == nullptr) { Item::items[i] = new TileItem(i - 256); Tile::tiles[i]->init(); } @@ -1713,7 +1713,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; } if (i == Tile::farmland_Id) propagate = true; @@ -1774,7 +1774,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*/) { @@ -1821,7 +1821,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(); } @@ -1982,13 +1982,13 @@ Icon* Tile::getTexture(LevelSource* level, int x, int y, int z, int face) { int azo[6] = {0, 0, 0, 0, 1, -1}; 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) || + 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); icon = getTexture(face, tileData); @@ -2343,15 +2343,15 @@ void Tile::playerDestroy(Level* level, std::shared_ptr player, int x, int y, int z, int data) { // 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)); } 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)); } 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)); } else { @@ -2369,7 +2369,7 @@ void Tile::playerDestroy(Level* level, std::shared_ptr player, int x, if (isSilkTouchable() && EnchantmentHelper::hasSilkTouch(player)) { std::shared_ptr item = getSilkTouchItemInstance(data); - if (item != NULL) { + if (item != nullptr) { popResource(level, x, y, z, item); } } else { @@ -2469,8 +2469,8 @@ bool Tile::isMatching(int tileIdA, int tileIdB) { if (tileIdA == 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; } return tiles[tileIdA]->isMatching(tileIdB); diff --git a/Minecraft.World/Blocks/TileEntities/BeaconTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/BeaconTileEntity.cpp index 738303f3c..01b84798d 100644 --- a/Minecraft.World/Blocks/TileEntities/BeaconTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/BeaconTileEntity.cpp @@ -28,7 +28,7 @@ void BeaconTileEntity::staticCtor() { for (unsigned int tier = 0; tier < BEACON_EFFECTS_TIERS; ++tier) { 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; @@ -172,7 +172,7 @@ void BeaconTileEntity::setPrimaryPower(int primaryPower) { for (int tier = 0; tier < levels && tier < 3; tier++) { 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) { this->primaryPower = primaryPower; @@ -190,7 +190,7 @@ void BeaconTileEntity::setSecondaryPower(int secondaryPower) { for (int tier = 0; tier < 4; tier++) { 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) { this->secondaryPower = secondaryPower; @@ -238,7 +238,7 @@ std::shared_ptr BeaconTileEntity::getItem(unsigned int slot) { std::shared_ptr BeaconTileEntity::removeItem(unsigned int slot, int count) { - if (slot == 0 && paymentItem != NULL) { + if (slot == 0 && paymentItem != nullptr) { if (count >= paymentItem->count) { std::shared_ptr returnItem = paymentItem; paymentItem = nullptr; @@ -253,7 +253,7 @@ std::shared_ptr BeaconTileEntity::removeItem(unsigned int slot, } std::shared_ptr BeaconTileEntity::removeItemNoUpdate(int slot) { - if (slot == 0 && paymentItem != NULL) { + if (slot == 0 && paymentItem != nullptr) { std::shared_ptr returnItem = paymentItem; paymentItem = nullptr; return returnItem; diff --git a/Minecraft.World/Blocks/TileEntities/BrewingStandTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/BrewingStandTileEntity.cpp index 09d36fc35..795ef0afa 100644 --- a/Minecraft.World/Blocks/TileEntities/BrewingStandTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/BrewingStandTileEntity.cpp @@ -71,7 +71,7 @@ void BrewingStandTileEntity::tick() { int BrewingStandTileEntity::getBrewTime() { return brewTime; } 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; } std::shared_ptr ingredient = items[INGREDIENT_SLOT]; @@ -82,7 +82,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)); @@ -103,7 +103,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()) { if (std::equal(currentEffects->begin(), currentEffects->end(), @@ -114,8 +114,8 @@ bool BrewingStandTileEntity::isBrewable() { } if ((currentBrew > 0 && currentEffects == newEffects) || - (currentEffects != NULL && - (equals || newEffects == NULL))) { + (currentEffects != nullptr && + (equals || newEffects == nullptr))) { } else if (currentBrew != newBrew) { oneResult = true; break; @@ -135,7 +135,7 @@ bool BrewingStandTileEntity::isBrewable() { // at least one destination potion must have a result 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)); @@ -143,7 +143,7 @@ bool BrewingStandTileEntity::isBrewable() { oneResult = true; break; } - } else if (isWater && items[dest] != NULL && + } else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id) { oneResult = true; break; @@ -162,7 +162,7 @@ void BrewingStandTileEntity::doBrew() { if (PotionBrewing::SIMPLIFIED_BREWING) { 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)); @@ -177,7 +177,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()) { if (std::equal(currentEffects->begin(), currentEffects->end(), @@ -188,8 +188,8 @@ 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)) { items[dest]->setAuxValue(newBrew); @@ -205,12 +205,12 @@ void BrewingStandTileEntity::doBrew() { bool isWater = ingredient->id == Item::bucket_water_Id; 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 && + } else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id) { items[dest] = std::shared_ptr( new ItemInstance(Item::potion)); @@ -231,7 +231,7 @@ void BrewingStandTileEntity::doBrew() { int BrewingStandTileEntity::applyIngredient( int currentBrew, std::shared_ptr ingredient) { - if (ingredient == NULL) { + if (ingredient == nullptr) { return currentBrew; } if (!PotionBrewing::SIMPLIFIED_BREWING) { @@ -279,7 +279,7 @@ void BrewingStandTileEntity::save(CompoundTag* base) { ListTag* listTag = new ListTag(); for (int i = 0; i < items.length; i++) { - if (items[i] != NULL) { + if (items[i] != nullptr) { CompoundTag* tag = new CompoundTag(); tag->putByte(L"Slot", (uint8_t)i); items[i]->save(tag); @@ -305,7 +305,7 @@ std::shared_ptr BrewingStandTileEntity::removeItem( // 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) { std::shared_ptr item = items[slot]; items[slot] = nullptr; @@ -377,7 +377,7 @@ void BrewingStandTileEntity::setBrewTime(int value) { brewTime = value; } int BrewingStandTileEntity::getPotionBits() { int newCount = 0; for (int potion = 0; potion < 3; potion++) { - if (items[potion] != NULL) { + if (items[potion] != nullptr) { newCount |= (1 << potion); } } @@ -413,7 +413,7 @@ std::shared_ptr BrewingStandTileEntity::clone() { result->ingredientId = ingredientId; 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/Blocks/TileEntities/ChestTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp index d66c15c24..9bb649074 100644 --- a/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp @@ -60,7 +60,7 @@ std::shared_ptr ChestTileEntity::getItem(unsigned int slot) { std::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) { std::shared_ptr item = items->data[slot]; items->data[slot] = nullptr; @@ -81,7 +81,7 @@ std::shared_ptr ChestTileEntity::removeItem(unsigned int slot, } std::shared_ptr ChestTileEntity::removeItemNoUpdate(int slot) { - if (items->data[slot] != NULL) { + if (items->data[slot] != nullptr) { std::shared_ptr item = items->data[slot]; items->data[slot] = nullptr; return item; @@ -92,7 +92,7 @@ std::shared_ptr ChestTileEntity::removeItemNoUpdate(int slot) { void ChestTileEntity::setItem(unsigned int slot, std::shared_ptr item) { items->data[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); this->setChanged(); } @@ -135,7 +135,7 @@ void ChestTileEntity::save(CompoundTag* base) { ListTag* listTag = new ListTag; 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", (uint8_t)i); items->data[i]->save(tag); @@ -214,17 +214,17 @@ void ChestTileEntity::checkNeighbors() { std::shared_ptr cteThis = std::dynamic_pointer_cast(shared_from_this()); - if (n.lock() != NULL) + if (n.lock() != nullptr) n.lock()->heyImYourNeighbor(cteThis, Direction::SOUTH); - if (s.lock() != NULL) + if (s.lock() != nullptr) 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 (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 ((ChestTile*)tile)->type == getType(); } @@ -252,7 +252,7 @@ void ChestTileEntity::tick() { ContainerMenu* containerMenu = dynamic_cast(player->containerMenu); - if (containerMenu != NULL) { + if (containerMenu != nullptr) { std::shared_ptr container = containerMenu->getContainer(); std::shared_ptr thisContainer = @@ -260,7 +260,7 @@ void ChestTileEntity::tick() { std::shared_ptr compoundContainer = std::dynamic_pointer_cast(container); if ((container == thisContainer) || - (compoundContainer != NULL && + (compoundContainer != nullptr && compoundContainer->contains(thisContainer))) { openCount++; } @@ -273,11 +273,11 @@ 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 @@ -299,11 +299,11 @@ 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 @@ -338,7 +338,7 @@ void ChestTileEntity::startOpen() { } void ChestTileEntity::stopOpen() { - if (getTile() == NULL || !(dynamic_cast(getTile()) != NULL)) + if (getTile() == nullptr || !(dynamic_cast(getTile()) != nullptr)) return; openCount--; level->tileEvent(x, y, z, getTile()->id, ChestTile::EVENT_SET_OPEN_COUNT, @@ -360,7 +360,7 @@ void ChestTileEntity::setRemoved() { int ChestTileEntity::getType() { if (type == -1) { - if (level != NULL && dynamic_cast(getTile()) != NULL) { + if (level != nullptr && dynamic_cast(getTile()) != nullptr) { type = ((ChestTile*)getTile())->type; } else { return ChestTile::TYPE_BASIC; @@ -377,7 +377,7 @@ std::shared_ptr ChestTileEntity::clone() { TileEntity::clone(result); 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/Blocks/TileEntities/DaylightDetectorTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/DaylightDetectorTileEntity.cpp index 745c99a4a..b342c3d61 100644 --- a/Minecraft.World/Blocks/TileEntities/DaylightDetectorTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/DaylightDetectorTileEntity.cpp @@ -6,10 +6,10 @@ DaylightDetectorTileEntity::DaylightDetectorTileEntity() {} void DaylightDetectorTileEntity::tick() { - if (level != NULL && !level->isClientSide && + 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) { ((DaylightDetectorTile*)tile)->updateSignalStrength(level, x, y, z); } } diff --git a/Minecraft.World/Blocks/TileEntities/DispenserTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/DispenserTileEntity.cpp index b87e7dd56..57052df4d 100644 --- a/Minecraft.World/Blocks/TileEntities/DispenserTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/DispenserTileEntity.cpp @@ -27,7 +27,7 @@ std::shared_ptr DispenserTileEntity::getItem(unsigned int slot) { std::shared_ptr DispenserTileEntity::removeItem(unsigned int slot, int count) { - if (items[slot] != NULL) { + if (items[slot] != nullptr) { if (items[slot]->count <= count) { std::shared_ptr item = items[slot]; items[slot] = nullptr; @@ -49,7 +49,7 @@ std::shared_ptr DispenserTileEntity::removeItem(unsigned int slot, std::shared_ptr DispenserTileEntity::removeItemNoUpdate( int slot) { - if (items[slot] != NULL) { + if (items[slot] != nullptr) { std::shared_ptr item = items[slot]; items[slot] = nullptr; return item; @@ -61,7 +61,7 @@ std::shared_ptr DispenserTileEntity::removeItemNoUpdate( // again void DispenserTileEntity::AddItemBack(std::shared_ptr item, unsigned int slot) { - if (items[slot] != NULL) { + if (items[slot] != nullptr) { // just increment the count of the items if (item->id == items[slot]->id) { items[slot]->count++; @@ -69,7 +69,7 @@ void DispenserTileEntity::AddItemBack(std::shared_ptr item, } } else { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); setChanged(); } @@ -82,9 +82,9 @@ void DispenserTileEntity::AddItemBack(std::shared_ptr item, */ 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) { std::shared_ptr removedItem = removeItem(i, 1); - return removedItem != NULL; + return removedItem != nullptr; } } return false; @@ -94,7 +94,7 @@ int DispenserTileEntity::getRandomSlot() { int replaceSlot = -1; 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; } } @@ -105,14 +105,14 @@ int DispenserTileEntity::getRandomSlot() { void DispenserTileEntity::setItem(unsigned int slot, std::shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); setChanged(); } int DispenserTileEntity::addItem(std::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; } @@ -155,7 +155,7 @@ void DispenserTileEntity::save(CompoundTag* base) { ListTag* listTag = new 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", (uint8_t)i); items[i]->save(tag); @@ -194,7 +194,7 @@ std::shared_ptr DispenserTileEntity::clone() { TileEntity::clone(result); 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/Blocks/TileEntities/EnchantmentTableTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/EnchantmentTableTileEntity.cpp index 08def292b..75407395e 100644 --- a/Minecraft.World/Blocks/TileEntities/EnchantmentTableTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/EnchantmentTableTileEntity.cpp @@ -38,7 +38,7 @@ void EnchantmentTableEntity::tick() { std::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/Blocks/TileEntities/FurnaceTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/FurnaceTileEntity.cpp index 6961fa0eb..c3ac0ed33 100644 --- a/Minecraft.World/Blocks/TileEntities/FurnaceTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/FurnaceTileEntity.cpp @@ -45,7 +45,7 @@ std::shared_ptr FurnaceTileEntity::removeItem(unsigned int slot, int count) { m_charcoalUsed = false; - if (items[slot] != NULL) { + if (items[slot] != nullptr) { if (items[slot]->count <= count) { std::shared_ptr item = items[slot]; items[slot] = nullptr; @@ -66,7 +66,7 @@ std::shared_ptr FurnaceTileEntity::removeItem(unsigned int slot, std::shared_ptr FurnaceTileEntity::removeItemNoUpdate(int slot) { m_charcoalUsed = false; - if (items[slot] != NULL) { + if (items[slot] != nullptr) { std::shared_ptr item = items[slot]; items[slot] = nullptr; return item; @@ -77,7 +77,7 @@ std::shared_ptr FurnaceTileEntity::removeItemNoUpdate(int slot) { void FurnaceTileEntity::setItem(unsigned int slot, std::shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); } @@ -122,7 +122,7 @@ void FurnaceTileEntity::save(CompoundTag* base) { ListTag* listTag = new 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", (uint8_t)i); items[i]->save(tag); @@ -156,12 +156,12 @@ void FurnaceTileEntity::tick() { litTime--; } - if (level != NULL && !level->isClientSide) { + if (level != nullptr && !level->isClientSide) { if (litTime == 0 && canBurn()) { litDuration = litTime = getBurnDuration(items[SLOT_FUEL]); 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 && @@ -176,7 +176,7 @@ void FurnaceTileEntity::tick() { ->getItem() ->getCraftingRemainingItem(); items[SLOT_FUEL] = - remaining != NULL ? std::shared_ptr( + remaining != nullptr ? std::shared_ptr( new ItemInstance(remaining)) : nullptr; } @@ -205,11 +205,11 @@ void FurnaceTileEntity::tick() { } bool FurnaceTileEntity::canBurn() { - if (items[SLOT_INPUT] == NULL) return false; + if (items[SLOT_INPUT] == nullptr) return false; 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()) @@ -223,7 +223,7 @@ void FurnaceTileEntity::burn() { ItemInstance* result = FurnaceRecipes::getInstance()->getResult( items[SLOT_INPUT]->getItem()->id); - if (items[SLOT_RESULT] == NULL) + if (items[SLOT_RESULT] == nullptr) items[SLOT_RESULT] = result->copy(); else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++; @@ -234,12 +234,12 @@ void FurnaceTileEntity::burn() { int FurnaceTileEntity::getBurnDuration( std::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]; if (tile == Tile::woodSlabHalf) { @@ -339,7 +339,7 @@ std::shared_ptr FurnaceTileEntity::clone() { result->litDuration = litDuration; 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/Blocks/TileEntities/HopperTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/HopperTileEntity.cpp index 26ed8f516..e4645eb39 100644 --- a/Minecraft.World/Blocks/TileEntities/HopperTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/HopperTileEntity.cpp @@ -40,7 +40,7 @@ void HopperTileEntity::save(CompoundTag* base) { ListTag* listTag = new ListTag(); for (int i = 0; i < items.length; i++) { - if (items[i] != NULL) { + if (items[i] != nullptr) { CompoundTag* tag = new CompoundTag(); tag->putByte(L"Slot", (uint8_t)i); items[i]->save(tag); @@ -62,7 +62,7 @@ std::shared_ptr HopperTileEntity::getItem(unsigned int slot) { std::shared_ptr HopperTileEntity::removeItem(unsigned int slot, int count) { - if (items[slot] != NULL) { + if (items[slot] != nullptr) { if (items[slot]->count <= count) { std::shared_ptr item = items[slot]; items[slot] = nullptr; @@ -77,7 +77,7 @@ std::shared_ptr HopperTileEntity::removeItem(unsigned int slot, } std::shared_ptr HopperTileEntity::removeItemNoUpdate(int slot) { - if (items[slot] != NULL) { + if (items[slot] != nullptr) { std::shared_ptr item = items[slot]; items[slot] = nullptr; return item; @@ -88,7 +88,7 @@ std::shared_ptr HopperTileEntity::removeItemNoUpdate(int slot) { void HopperTileEntity::setItem(unsigned int slot, std::shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); } @@ -126,7 +126,7 @@ bool HopperTileEntity::canPlaceItem(int slot, } void HopperTileEntity::tick() { - if (level == NULL || level->isClientSide) return; + if (level == nullptr || level->isClientSide) return; cooldownTime--; @@ -137,7 +137,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())) { bool changed = ejectItems(); @@ -155,19 +155,19 @@ bool HopperTileEntity::tryMoveItems() { bool HopperTileEntity::ejectItems() { std::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; std::shared_ptr original = getItem(slot)->copy(); std::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; } else { @@ -181,12 +181,12 @@ bool HopperTileEntity::ejectItems() { bool HopperTileEntity::suckInItems(Hopper* hopper) { std::shared_ptr container = getSourceContainer(hopper); - if (container != NULL) { + if (container != nullptr) { int face = Facing::DOWN; std::shared_ptr worldly = std::dynamic_pointer_cast(container); - if ((worldly != NULL) && (face > -1)) { + if ((worldly != nullptr) && (face > -1)) { intArray slots = worldly->getSlotsForFace(face); for (int i = 0; i < slots.length; i++) { @@ -206,7 +206,7 @@ bool HopperTileEntity::suckInItems(Hopper* hopper) { getItemAt(hopper->getLevel(), hopper->getLevelX(), hopper->getLevelY() + 1, hopper->getLevelZ()); - if (above != NULL) { + if (above != nullptr) { return addItem(hopper, above); } } @@ -219,12 +219,12 @@ bool HopperTileEntity::tryTakeInItemFromSlot(Hopper* hopper, int face) { std::shared_ptr item = container->getItem(slot); - if (item != NULL && canTakeItemFromContainer(container, item, slot, face)) { + if (item != nullptr && canTakeItemFromContainer(container, item, slot, face)) { std::shared_ptr original = item->copy(); std::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; } else { @@ -238,12 +238,12 @@ bool HopperTileEntity::tryTakeInItemFromSlot(Hopper* hopper, bool HopperTileEntity::addItem(Container* container, std::shared_ptr item) { bool changed = false; - if (item == NULL) return false; + if (item == nullptr) return false; std::shared_ptr copy = item->getItem()->copy(); std::shared_ptr result = addItem(container, copy, -1); - if (result == NULL || result->count == 0) { + if (result == nullptr || result->count == 0) { changed = true; item->remove(); @@ -256,22 +256,22 @@ bool HopperTileEntity::addItem(Container* container, std::shared_ptr HopperTileEntity::addItem( Container* container, std::shared_ptr item, int face) { - if (dynamic_cast(container) != NULL && face > -1) { + if (dynamic_cast(container) != nullptr && face > -1) { WorldlyContainer* worldly = (WorldlyContainer*)container; intArray slots = worldly->getSlotsForFace(face); - for (int i = 0; i < slots.length && item != NULL && item->count > 0; + for (int i = 0; i < slots.length && item != nullptr && item->count > 0; i++) { item = tryMoveInItem(container, item, slots[i], face); } } 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; } @@ -282,7 +282,7 @@ bool HopperTileEntity::canPlaceItemInContainer( Container* container, std::shared_ptr item, int slot, int face) { if (!container->canPlaceItem(slot, item)) return false; - if (dynamic_cast(container) != NULL && + if (dynamic_cast(container) != nullptr && !dynamic_cast(container)->canPlaceItemThroughFace( slot, item, face)) return false; @@ -292,7 +292,7 @@ bool HopperTileEntity::canPlaceItemInContainer( bool HopperTileEntity::canTakeItemFromContainer( Container* container, std::shared_ptr item, int slot, int face) { - if (dynamic_cast(container) != NULL && + if (dynamic_cast(container) != nullptr && !dynamic_cast(container)->canTakeItemThroughFace( slot, item, face)) return false; @@ -306,7 +306,7 @@ std::shared_ptr HopperTileEntity::tryMoveInItem( if (canPlaceItemInContainer(container, item, slot, face)) { bool success = false; - if (current == NULL) { + if (current == nullptr) { container->setItem(slot, item); item = nullptr; success = true; @@ -321,7 +321,7 @@ std::shared_ptr HopperTileEntity::tryMoveInItem( if (success) { HopperTileEntity* hopper = dynamic_cast(container); - if (hopper != NULL) { + if (hopper != nullptr) { hopper->setCooldown(MOVE_ITEM_SPEED); container->setChanged(); } @@ -373,23 +373,23 @@ std::shared_ptr HopperTileEntity::getContainerAt(Level* level, std::shared_ptr entity = level->getTileEntity(xt, yt, zt); result = std::dynamic_pointer_cast(entity); - if (result != NULL) { - if (std::dynamic_pointer_cast(result) != NULL) { + if (result != nullptr) { + if (std::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 = ((ChestTile*)tile)->getContainer(level, xt, yt, zt); } } } - if (result == NULL) { + if (result == nullptr) { AABB block_above{x, y, z, x + 1, y + 1, z + 1}; std::vector >* entities = level->getEntities( nullptr, &block_above, EntitySelector::CONTAINER_ENTITY_SELECTOR); - if ((entities != NULL) && (entities->size() > 0)) { + if ((entities != nullptr) && (entities->size() > 0)) { result = std::dynamic_pointer_cast( entities->at(level->random->nextInt(entities->size()))); } @@ -428,7 +428,7 @@ std::shared_ptr HopperTileEntity::clone() { result->name = name; 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/Blocks/TileEntities/MobSpawnerTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/MobSpawnerTileEntity.cpp index 0cc85500d..351a2ed8b 100644 --- a/Minecraft.World/Blocks/TileEntities/MobSpawnerTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/MobSpawnerTileEntity.cpp @@ -27,7 +27,7 @@ int MobSpawnerTileEntity::TileEntityMobSpawner::getZ() { return m_parent->z; } void MobSpawnerTileEntity::TileEntityMobSpawner::setNextSpawnData( BaseMobSpawner::SpawnData* nextSpawnData) { BaseMobSpawner::setNextSpawnData(nextSpawnData); - if (getLevel() != NULL) + if (getLevel() != nullptr) getLevel()->sendTileUpdated(m_parent->x, m_parent->y, m_parent->z); } diff --git a/Minecraft.World/Blocks/TileEntities/PistonPieceTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/PistonPieceTileEntity.cpp index 84d73b9c7..a442e1773 100644 --- a/Minecraft.World/Blocks/TileEntities/PistonPieceTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/PistonPieceTileEntity.cpp @@ -104,7 +104,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); setRemoved(); diff --git a/Minecraft.World/Blocks/TileEntities/PotionBrewing.cpp b/Minecraft.World/Blocks/TileEntities/PotionBrewing.cpp index 3c3ccf249..62491ef36 100644 --- a/Minecraft.World/Blocks/TileEntities/PotionBrewing.cpp +++ b/Minecraft.World/Blocks/TileEntities/PotionBrewing.cpp @@ -195,7 +195,7 @@ int PotionBrewing::getColorValue(std::vector* effects) { int baseColor = colourTable->getColor(eMinecraftColour_Potion_BaseColour); - if (effects == NULL || effects->empty()) { + if (effects == nullptr || effects->empty()) { return baseColor; } @@ -243,7 +243,7 @@ int PotionBrewing::getColorValue(int brew, bool includeDisabledEffects) { } std::vector* effects = getEffects(brew, false); int color = getColorValue(effects); - if (effects != NULL) { + if (effects != nullptr) { for (AUTO_VAR(it, effects->begin()); it != effects->end(); ++it) { MobEffectInstance* effect = *it; delete effect; @@ -518,12 +518,12 @@ int PotionBrewing::parseEffectFormulaValue(const std::wstring& definition, std::vector* PotionBrewing::getEffects( int brew, bool includeDisabledEffects) { - std::vector* list = NULL; + std::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 || + if (effect == nullptr || (effect->isDisabled() && !includeDisabledEffects)) { continue; } @@ -563,7 +563,7 @@ std::vector* PotionBrewing::getEffects( } } - if (list == NULL) { + if (list == nullptr) { list = new std::vector(); } MobEffectInstance* instance = diff --git a/Minecraft.World/Blocks/TileEntities/TileEntity.cpp b/Minecraft.World/Blocks/TileEntities/TileEntity.cpp index 66ae1afac..61c314cb8 100644 --- a/Minecraft.World/Blocks/TileEntities/TileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/TileEntity.cpp @@ -62,11 +62,11 @@ void TileEntity::setId(tileEntityCreateFn createFn, eINSTANCEOF clas, } TileEntity::TileEntity() { - level = NULL; + level = nullptr; x = y = z = 0; remove = false; data = -1; - tile = NULL; + tile = nullptr; renderRemoveStage = e_RenderRemoveStageKeep; } @@ -74,7 +74,7 @@ Level* TileEntity::getLevel() { return level; } void TileEntity::setLevel(Level* level) { this->level = level; } -bool TileEntity::hasLevel() { return level != NULL; } +bool TileEntity::hasLevel() { return level != nullptr; } void TileEntity::load(CompoundTag* tag) { x = tag->getInt(L"x"); @@ -112,7 +112,7 @@ std::shared_ptr TileEntity::loadStatic(CompoundTag* tag) { // TODO 4J Stu - Exception handling? // e->printStackTrace(); //} - if (entity != NULL) { + if (entity != nullptr) { entity->load(tag); } else { #ifdef _DEBUG @@ -135,10 +135,10 @@ 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) + if (getTile() != nullptr) level->updateNeighbourForOutputSignal(x, y, z, getTile()->id); } } @@ -154,7 +154,7 @@ double TileEntity::distanceToSqr(double xPlayer, double yPlayer, double TileEntity::getViewDistance() { return 64 * 64; } 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; } @@ -169,7 +169,7 @@ void TileEntity::clearRemoved() { remove = false; } bool TileEntity::triggerEvent(int b0, int b1) { return false; } void TileEntity::clearCache() { - tile = NULL; + tile = nullptr; data = -1; } diff --git a/Minecraft.World/Blocks/TntTile.cpp b/Minecraft.World/Blocks/TntTile.cpp index cbcba160b..e067d0569 100644 --- a/Minecraft.World/Blocks/TntTile.cpp +++ b/Minecraft.World/Blocks/TntTile.cpp @@ -10,8 +10,8 @@ #include "../Util/SoundTypes.h" 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 @@ bool TntTile::use(Level* level, int x, int y, int z, bool soundOnly /*=false*/) // 4J added soundOnly param { if (soundOnly) return false; - if (player->getSelectedItem() != NULL && + 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/Blocks/TrapDoorTile.cpp b/Minecraft.World/Blocks/TrapDoorTile.cpp index 7a6e46e5a..97efb0390 100644 --- a/Minecraft.World/Blocks/TrapDoorTile.cpp +++ b/Minecraft.World/Blocks/TrapDoorTile.cpp @@ -171,9 +171,9 @@ bool TrapDoorTile::attachesTo(int id) { } Tile* tile = Tile::tiles[id]; - return tile != NULL && + return tile != nullptr && (tile->material->isSolidBlocking() && tile->isCubeShaped()) || tile == Tile::glowstone || - (dynamic_cast(tile) != NULL) || - (dynamic_cast(tile) != NULL); + (dynamic_cast(tile) != nullptr) || + (dynamic_cast(tile) != nullptr); } diff --git a/Minecraft.World/Blocks/TripWireTile.cpp b/Minecraft.World/Blocks/TripWireTile.cpp index e72ea5cdd..d44bbd885 100644 --- a/Minecraft.World/Blocks/TripWireTile.cpp +++ b/Minecraft.World/Blocks/TripWireTile.cpp @@ -79,7 +79,7 @@ void TripWireTile::playerWillDestroy(Level* level, int x, int y, int z, int data, std::shared_ptr player) { if (level->isClientSide) return; - if (player->getSelectedItem() != NULL && + 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/Blocks/VineTile.cpp b/Minecraft.World/Blocks/VineTile.cpp index 787fb4588..57de96e58 100644 --- a/Minecraft.World/Blocks/VineTile.cpp +++ b/Minecraft.World/Blocks/VineTile.cpp @@ -218,7 +218,7 @@ void VineTile::tick(Level* level, int x, int y, int z, Random* random) { 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 int left = (testDirection + 1) & 3; @@ -363,7 +363,7 @@ int VineTile::getResourceCount(Random* random) { return 0; } void VineTile::playerDestroy(Level* level, std::shared_ptr player, int x, int y, int z, int data) { - if (!level->isClientSide && player->getSelectedItem() != NULL && + if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id) { player->awardStat(GenericStats::blocksMined(id), GenericStats::param_blocksMined(id, data, 1)); diff --git a/Minecraft.World/Blocks/WallTile.cpp b/Minecraft.World/Blocks/WallTile.cpp index a072b82c8..8ebe33a39 100644 --- a/Minecraft.World/Blocks/WallTile.cpp +++ b/Minecraft.World/Blocks/WallTile.cpp @@ -134,7 +134,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()) { return tileInstance->material != Material::vegetable; diff --git a/Minecraft.World/Blocks/WaterLilyTile.cpp b/Minecraft.World/Blocks/WaterLilyTile.cpp index ce0a7d2be..3110a2452 100644 --- a/Minecraft.World/Blocks/WaterLilyTile.cpp +++ b/Minecraft.World/Blocks/WaterLilyTile.cpp @@ -18,7 +18,7 @@ int WaterlilyTile::getRenderShape() { return Tile::SHAPE_LILYPAD; } void WaterlilyTile::addAABBs(Level* level, int x, int y, int z, AABB* box, AABBList* boxes, std::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/Blocks/WoodTile.cpp b/Minecraft.World/Blocks/WoodTile.cpp index 59142c2de..39c6def5a 100644 --- a/Minecraft.World/Blocks/WoodTile.cpp +++ b/Minecraft.World/Blocks/WoodTile.cpp @@ -21,7 +21,7 @@ const std::wstring WoodTile::TEXTURE_NAMES[] = {L"oak", L"spruce", L"birch", // "oak", "spruce", "birch", "jungle" // }; -WoodTile::WoodTile(int id) : Tile(id, Material::wood) { icons = NULL; } +WoodTile::WoodTile(int id) : Tile(id, Material::wood) { icons = nullptr; } unsigned int WoodTile::getDescriptionId(int iData) { if (iData < 0 || iData >= WOOD_NAMES_LENGTH) iData = 0; diff --git a/Minecraft.World/Blocks/WorkbenchTile.cpp b/Minecraft.World/Blocks/WorkbenchTile.cpp index f266f7ed2..8929f2116 100644 --- a/Minecraft.World/Blocks/WorkbenchTile.cpp +++ b/Minecraft.World/Blocks/WorkbenchTile.cpp @@ -6,8 +6,8 @@ #include "WorkbenchTile.h" 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/Commands/Command.cpp b/Minecraft.World/Commands/Command.cpp index 16cc7a5fd..443678861 100644 --- a/Minecraft.World/Commands/Command.cpp +++ b/Minecraft.World/Commands/Command.cpp @@ -25,7 +25,7 @@ void Command::logAdminAction(std::shared_ptr source, int type, ChatPacket::EChatPacketMessage messageType, const std::wstring& message, int customData, const std::wstring& additionalMessage) { - if (logger != NULL) { + if (logger != nullptr) { logger->logAdminCommand(source, type, messageType, message, customData, additionalMessage); } @@ -37,7 +37,7 @@ std::shared_ptr Command::getPlayer(PlayerUID playerId) { std::shared_ptr player = MinecraftServer::getInstance()->getPlayers()->getPlayer(playerId); - if (player == NULL) { + if (player == nullptr) { return nullptr; } else { return player; diff --git a/Minecraft.World/Commands/EnchantItemCommand.cpp b/Minecraft.World/Commands/EnchantItemCommand.cpp index 7fd8a14c2..13e1df281 100644 --- a/Minecraft.World/Commands/EnchantItemCommand.cpp +++ b/Minecraft.World/Commands/EnchantItemCommand.cpp @@ -22,15 +22,15 @@ void EnchantItemCommand::execute(std::shared_ptr source, std::shared_ptr player = getPlayer(uid); - if (player == NULL) return; + if (player == nullptr) return; std::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()) @@ -41,12 +41,12 @@ void EnchantItemCommand::execute(std::shared_ptr source, 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)) { return; @@ -69,7 +69,7 @@ void EnchantItemCommand::execute(std::shared_ptr source, std::shared_ptr EnchantItemCommand::preparePacket( std::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/Commands/GameModeCommand.cpp b/Minecraft.World/Commands/GameModeCommand.cpp index 631d1682f..06a5fdb34 100644 --- a/Minecraft.World/Commands/GameModeCommand.cpp +++ b/Minecraft.World/Commands/GameModeCommand.cpp @@ -37,7 +37,7 @@ void GameModeCommand::execute(std::shared_ptr source, GameType* GameModeCommand::getModeForString( std::shared_ptr source, const std::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()) || diff --git a/Minecraft.World/Commands/GiveItemCommand.cpp b/Minecraft.World/Commands/GiveItemCommand.cpp index b44d20136..2ab658c7c 100644 --- a/Minecraft.World/Commands/GiveItemCommand.cpp +++ b/Minecraft.World/Commands/GiveItemCommand.cpp @@ -24,7 +24,7 @@ void GiveItemCommand::execute(std::shared_ptr source, bais.reset(); std::shared_ptr player = getPlayer(uid); - if (player != NULL && item > 0 && Item::items[item] != NULL) { + if (player != nullptr && item > 0 && Item::items[item] != nullptr) { std::shared_ptr itemInstance = std::shared_ptr(new ItemInstance(item, amount, aux)); std::shared_ptr drop = player->drop(itemInstance); @@ -40,7 +40,7 @@ void GiveItemCommand::execute(std::shared_ptr source, std::shared_ptr GiveItemCommand::preparePacket( std::shared_ptr player, int item, int amount, int aux, const std::wstring& tag) { - if (player == NULL) return nullptr; + if (player == nullptr) return nullptr; ByteArrayOutputStream baos; DataOutputStream dos(&baos); diff --git a/Minecraft.World/Containers/AbstractContainerMenu.cpp b/Minecraft.World/Containers/AbstractContainerMenu.cpp index 8da2a07af..f26ddffd7 100644 --- a/Minecraft.World/Containers/AbstractContainerMenu.cpp +++ b/Minecraft.World/Containers/AbstractContainerMenu.cpp @@ -73,7 +73,7 @@ void AbstractContainerMenu::broadcastChanges() { // 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) + expected = (current == nullptr || current->count == 0) ? nullptr : current->copy(); lastSlots[i] = expected; @@ -95,7 +95,7 @@ bool AbstractContainerMenu::needsRendered() { std::shared_ptr current = slots.at(i)->getItem(); std::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; } @@ -118,7 +118,7 @@ Slot* AbstractContainerMenu::getSlotFor(std::shared_ptr c, return slot; } } - return NULL; + return nullptr; } Slot* AbstractContainerMenu::getSlot(int index) { return slots.at(index); } @@ -126,7 +126,7 @@ Slot* AbstractContainerMenu::getSlot(int index) { return slots.at(index); } std::shared_ptr AbstractContainerMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { Slot* slot = slots.at(slotIndex); - if (slot != NULL) { + if (slot != nullptr) { return slot->getItem(); } return nullptr; @@ -147,7 +147,7 @@ std::shared_ptr AbstractContainerMenu::clicked( quickcraftStatus != QUICKCRAFT_HEADER_END) && expectedStatus != quickcraftStatus) { resetQuickCraft(); - } else if (inventory->getCarried() == NULL) { + } else if (inventory->getCarried() == nullptr) { resetQuickCraft(); } else if (quickcraftStatus == QUICKCRAFT_HEADER_START) { quickcraftType = getQuickcraftType(buttonNum); @@ -161,7 +161,7 @@ std::shared_ptr AbstractContainerMenu::clicked( } else if (quickcraftStatus == QUICKCRAFT_HEADER_CONTINUE) { Slot* slot = slots.at(slotIndex); - if (slot != NULL && + if (slot != nullptr && canItemQuickReplace(slot, inventory->getCarried(), true) && slot->mayPlace(inventory->getCarried()) && inventory->getCarried()->count > quickcraftSlots.size() && @@ -177,7 +177,7 @@ std::shared_ptr AbstractContainerMenu::clicked( for (AUTO_VAR(it, quickcraftSlots.begin()); it != quickcraftSlots.end(); ++it) { Slot* slot = *it; - if (slot != NULL && + if (slot != nullptr && canItemQuickReplace(slot, inventory->getCarried(), true) && slot->mayPlace(inventory->getCarried()) && @@ -216,7 +216,7 @@ std::shared_ptr AbstractContainerMenu::clicked( } else if ((clickType == CLICK_PICKUP || clickType == CLICK_QUICK_MOVE) && (buttonNum == 0 || buttonNum == 1)) { if (slotIndex == SLOT_CLICKED_OUTSIDE) { - if (inventory->getCarried() != NULL) { + if (inventory->getCarried() != nullptr) { if (slotIndex == SLOT_CLICKED_OUTSIDE) { if (buttonNum == 0) { player->drop(inventory->getCarried()); @@ -232,10 +232,10 @@ std::shared_ptr AbstractContainerMenu::clicked( } else if (clickType == CLICK_QUICK_MOVE) { if (slotIndex < 0) return nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->mayPickup(player)) { + if (slot != nullptr && slot->mayPickup(player)) { std::shared_ptr piiClicked = quickMoveStack(player, slotIndex); - if (piiClicked != NULL) { + if (piiClicked != nullptr) { int oldType = piiClicked->id; // 4J Stu - We ignore the return value for loopClicks, so @@ -248,8 +248,8 @@ std::shared_ptr AbstractContainerMenu::clicked( // recursive loop piiClicked = nullptr; - if (slot != NULL) { - if (slot->getItem() != NULL && + if (slot != nullptr) { + if (slot->getItem() != nullptr && slot->getItem()->id == oldType) { if (looped) { // Return a non-null value to indicate that we @@ -269,16 +269,16 @@ std::shared_ptr AbstractContainerMenu::clicked( if (slotIndex < 0) return nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL) { + if (slot != nullptr) { std::shared_ptr clicked = slot->getItem(); std::shared_ptr carried = inventory->getCarried(); - if (clicked != NULL) { + if (clicked != nullptr) { clickedEntity = clicked->copy(); } - if (clicked == NULL) { - if (carried != NULL && slot->mayPlace(carried)) { + if (clicked == nullptr) { + if (carried != nullptr && slot->mayPlace(carried)) { int c = buttonNum == 0 ? carried->count : 1; if (c > slot->getMaxStackSize()) { c = slot->getMaxStackSize(); @@ -295,7 +295,7 @@ std::shared_ptr AbstractContainerMenu::clicked( else if (buttonNum == 1 && mayCombine(slot, carried)) { std::shared_ptr combined = slot->combine(carried); - if (combined != NULL) { + if (combined != nullptr) { slot->set(combined); if (!player->abilities.instabuild) carried->remove(1); if (carried->count == 0) { @@ -303,7 +303,7 @@ std::shared_ptr AbstractContainerMenu::clicked( } } } 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; @@ -367,7 +367,7 @@ std::shared_ptr AbstractContainerMenu::clicked( if (slot->mayPickup(player)) { std::shared_ptr current = inventory->getItem(buttonNum); - bool canMove = current == NULL || (slot->container == inventory && + bool canMove = current == nullptr || (slot->container == inventory && slot->mayPlace(current)); int freeSlot = -1; @@ -381,7 +381,7 @@ std::shared_ptr AbstractContainerMenu::clicked( inventory->setItem(buttonNum, taking); if ((slot->container == inventory && slot->mayPlace(current)) || - current == NULL) { + current == nullptr) { slot->remove(taking->count); slot->set(current); slot->onTake(player, taking); @@ -391,24 +391,24 @@ std::shared_ptr AbstractContainerMenu::clicked( slot->set(nullptr); slot->onTake(player, taking); } - } else if (!slot->hasItem() && current != NULL && + } 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) { + inventory->getCarried() == nullptr && slotIndex >= 0) { Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr copy = slot->getItem()->copy(); copy->count = copy->getMaxStackSize(); inventory->setCarried(copy); } - } else if (clickType == CLICK_THROW && inventory->getCarried() == NULL && + } 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)) { std::shared_ptr item = slot->remove(buttonNum == 0 ? 1 : slot->getItem()->count); slot->onTake(player, item); @@ -418,8 +418,8 @@ std::shared_ptr AbstractContainerMenu::clicked( Slot* slot = slots.at(slotIndex); std::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; @@ -469,7 +469,7 @@ void AbstractContainerMenu::loopClick(int slotIndex, int buttonNum, bool quickKeyHeld, std::shared_ptr player) { while (clicked(slotIndex, buttonNum, CLICK_QUICK_MOVE, player, true) != - NULL) { + nullptr) { } } @@ -480,7 +480,7 @@ bool AbstractContainerMenu::mayCombine(Slot* slot, void AbstractContainerMenu::removed(std::shared_ptr player) { std::shared_ptr inventory = player->inventory; - if (inventory->getCarried() != NULL) { + if (inventory->getCarried() != nullptr) { player->drop(inventory->getCarried()); inventory->setCarried(nullptr); } @@ -546,7 +546,7 @@ bool AbstractContainerMenu::moveItemStackTo( (backwards && destSlot >= startSlot))) { Slot* slot = slots.at(destSlot); std::shared_ptr target = slot->getItem(); - if (target != NULL && target->id == itemStack->id && + if (target != nullptr && target->id == itemStack->id && (!itemStack->isStackedByData() || itemStack->getAuxValue() == target->getAuxValue()) && ItemInstance::tagMatches(itemStack, target)) { @@ -585,7 +585,7 @@ bool AbstractContainerMenu::moveItemStackTo( Slot* slot = slots.at(destSlot); std::shared_ptr target = slot->getItem(); - if (target == NULL) { + if (target == nullptr) { slot->set(itemStack->copy()); slot->setChanged(); itemStack->count = 0; @@ -628,9 +628,9 @@ void AbstractContainerMenu::resetQuickCraft() { bool AbstractContainerMenu::canItemQuickReplace( Slot* slot, std::shared_ptr item, bool ignoreSize) { - bool canReplace = slot == NULL || !slot->hasItem(); + bool canReplace = slot == nullptr || !slot->hasItem(); - if (slot != NULL && slot->hasItem() && item != NULL && + if (slot != nullptr && slot->hasItem() && item != nullptr && item->sameItem(slot->getItem()) && ItemInstance::tagMatches(slot->getItem(), item)) { canReplace |= slot->getItem()->count + (ignoreSize ? 0 : item->count) <= @@ -660,14 +660,14 @@ bool AbstractContainerMenu::canDragTo(Slot* slot) { return true; } int AbstractContainerMenu::getRedstoneSignalFromContainer( std::shared_ptr container) { - if (container == NULL) return 0; + if (container == nullptr) return 0; int count = 0; float totalPct = 0; for (int i = 0; i < container->getContainerSize(); i++) { std::shared_ptr item = container->getItem(i); - if (item != NULL) { + if (item != nullptr) { totalPct += item->count / (float)std::min(container->getMaxStackSize(), item->getMaxStackSize()); diff --git a/Minecraft.World/Containers/AnvilMenu.cpp b/Minecraft.World/Containers/AnvilMenu.cpp index fb4628255..692148756 100644 --- a/Minecraft.World/Containers/AnvilMenu.cpp +++ b/Minecraft.World/Containers/AnvilMenu.cpp @@ -53,7 +53,7 @@ void AnvilMenu::createResult() { if (DEBUG_COST) app.DebugPrintf("----"); - if (input == NULL) { + if (input == nullptr) { resultSlots->setItem(0, nullptr); cost = 0; return; @@ -66,17 +66,17 @@ void AnvilMenu::createResult() { bool usingBook = false; tax += input->getBaseRepairCost() + - (addition == NULL ? 0 : addition->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())); + (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; @@ -295,9 +295,9 @@ void AnvilMenu::createResult() { result = nullptr; } - if (result != NULL) { + if (result != nullptr) { int baseCost = result->getBaseRepairCost(); - if (addition != NULL && baseCost < addition->getBaseRepairCost()) + if (addition != nullptr && baseCost < addition->getBaseRepairCost()) baseCost = addition->getBaseRepairCost(); if (result->hasCustomHoverName()) baseCost -= 9; if (baseCost < 0) baseCost = 0; @@ -342,7 +342,7 @@ void AnvilMenu::removed(std::shared_ptr player) { for (int i = 0; i < repairSlots->getContainerSize(); i++) { std::shared_ptr item = repairSlots->removeItemNoUpdate(i); - if (item != NULL) { + if (item != nullptr) { player->drop(item); } } @@ -358,7 +358,7 @@ std::shared_ptr AnvilMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { std::shared_ptr clicked = nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/Containers/ArmorSlot.cpp b/Minecraft.World/Containers/ArmorSlot.cpp index 843112db3..d2d182c4f 100644 --- a/Minecraft.World/Containers/ArmorSlot.cpp +++ b/Minecraft.World/Containers/ArmorSlot.cpp @@ -13,10 +13,10 @@ ArmorSlot::ArmorSlot(int slotNum, std::shared_ptr container, int id, int ArmorSlot::getMaxStackSize() { return 1; } bool ArmorSlot::mayPlace(std::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; } if (item->getItem()->id == Tile::pumpkin_Id || @@ -32,7 +32,7 @@ Icon* ArmorSlot::getNoItemIcon() { return ArmorItem::getEmptyIcon(slotNum); } // 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() == @@ -43,7 +43,7 @@ Icon* ArmorSlot::getNoItemIcon() { return ArmorItem::getEmptyIcon(slotNum); } // shared_ptr ArmorSlot::combine(shared_ptr item) //{ // shared_ptr craftSlots = -// shared_ptr( new CraftingContainer(NULL, 2, 2) ); +// shared_ptr( new CraftingContainer(nullptr, 2, 2) ); // craftSlots->setItem(0, item); // craftSlots->setItem(1, getItem()); // Armour item needs to go second // shared_ptr result = diff --git a/Minecraft.World/Containers/BeaconMenu.cpp b/Minecraft.World/Containers/BeaconMenu.cpp index 0992c4749..b27776e83 100644 --- a/Minecraft.World/Containers/BeaconMenu.cpp +++ b/Minecraft.World/Containers/BeaconMenu.cpp @@ -52,7 +52,7 @@ std::shared_ptr BeaconMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { std::shared_ptr clicked = nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -103,7 +103,7 @@ BeaconMenu::PaymentSlot::PaymentSlot(std::shared_ptr container, : Slot(container, slot, x, y) {} bool BeaconMenu::PaymentSlot::mayPlace(std::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/Containers/BrewingStandMenu.cpp b/Minecraft.World/Containers/BrewingStandMenu.cpp index a832870ab..e7013dd1e 100644 --- a/Minecraft.World/Containers/BrewingStandMenu.cpp +++ b/Minecraft.World/Containers/BrewingStandMenu.cpp @@ -71,7 +71,7 @@ std::shared_ptr BrewingStandMenu::quickMoveStack( 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()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -191,7 +191,7 @@ bool BrewingStandMenu::PotionSlot::mayCombine( bool BrewingStandMenu::PotionSlot::mayPlaceItem( std::shared_ptr item) { - return item != NULL && + return item != nullptr && (item->id == Item::potion_Id || item->id == Item::glassBottle_Id); } @@ -201,7 +201,7 @@ BrewingStandMenu::IngredientsSlot::IngredientsSlot( bool BrewingStandMenu::IngredientsSlot::mayPlace( std::shared_ptr item) { - if (item != NULL) { + if (item != nullptr) { if (PotionBrewing::SIMPLIFIED_BREWING) { return Item::items[item->id]->hasPotionBrewingFormula(); } else { diff --git a/Minecraft.World/Containers/ClientSideMerchant.cpp b/Minecraft.World/Containers/ClientSideMerchant.cpp index 7394b6eb1..f8763ca0b 100644 --- a/Minecraft.World/Containers/ClientSideMerchant.cpp +++ b/Minecraft.World/Containers/ClientSideMerchant.cpp @@ -7,8 +7,8 @@ ClientSideMerchant::ClientSideMerchant(std::shared_ptr source, const std::wstring& name) { 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/Containers/CompoundContainer.cpp b/Minecraft.World/Containers/CompoundContainer.cpp index d450b64a9..2a5c37f99 100644 --- a/Minecraft.World/Containers/CompoundContainer.cpp +++ b/Minecraft.World/Containers/CompoundContainer.cpp @@ -6,8 +6,8 @@ CompoundContainer::CompoundContainer(int name, std::shared_ptr c1, std::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/Containers/ContainerMenu.cpp b/Minecraft.World/Containers/ContainerMenu.cpp index 7e6d7b5ee..0dd0c1956 100644 --- a/Minecraft.World/Containers/ContainerMenu.cpp +++ b/Minecraft.World/Containers/ContainerMenu.cpp @@ -42,7 +42,7 @@ std::shared_ptr ContainerMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { std::shared_ptr clicked = nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -86,7 +86,7 @@ std::shared_ptr ContainerMenu::clicked( std::dynamic_pointer_cast(player); if (localPlayer != - NULL) // 4J-JEV: For "Chestful o'Cobblestone" achievement. + nullptr) // 4J-JEV: For "Chestful o'Cobblestone" achievement. { int cobblecount = 0; for (int i = 0; i < container->getContainerSize(); i++) { diff --git a/Minecraft.World/Containers/CraftingContainer.cpp b/Minecraft.World/Containers/CraftingContainer.cpp index 69617969a..8b0ef17ec 100644 --- a/Minecraft.World/Containers/CraftingContainer.cpp +++ b/Minecraft.World/Containers/CraftingContainer.cpp @@ -39,7 +39,7 @@ std::wstring CraftingContainer::getCustomName() { return L""; } bool CraftingContainer::hasCustomName() { return false; } std::shared_ptr CraftingContainer::removeItemNoUpdate(int slot) { - if ((*items)[slot] != NULL) { + if ((*items)[slot] != nullptr) { std::shared_ptr item = (*items)[slot]; (*items)[slot] = nullptr; return item; @@ -49,7 +49,7 @@ std::shared_ptr CraftingContainer::removeItemNoUpdate(int slot) { std::shared_ptr CraftingContainer::removeItem(unsigned int slot, int count) { - if ((*items)[slot] != NULL) { + if ((*items)[slot] != nullptr) { if ((*items)[slot]->count <= count) { std::shared_ptr item = (*items)[slot]; (*items)[slot] = nullptr; diff --git a/Minecraft.World/Containers/CraftingMenu.cpp b/Minecraft.World/Containers/CraftingMenu.cpp index 2f5da7042..e433bcaa3 100644 --- a/Minecraft.World/Containers/CraftingMenu.cpp +++ b/Minecraft.World/Containers/CraftingMenu.cpp @@ -64,7 +64,7 @@ void CraftingMenu::removed(std::shared_ptr player) { for (int i = 0; i < 9; i++) { std::shared_ptr item = craftSlots->removeItemNoUpdate(i); - if (item != NULL) { + if (item != nullptr) { player->drop(item); } } @@ -80,7 +80,7 @@ std::shared_ptr CraftingMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { std::shared_ptr clicked = nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/Containers/EnchantmentMenu.cpp b/Minecraft.World/Containers/EnchantmentMenu.cpp index 4d481081e..c60469ea2 100644 --- a/Minecraft.World/Containers/EnchantmentMenu.cpp +++ b/Minecraft.World/Containers/EnchantmentMenu.cpp @@ -74,7 +74,7 @@ void EnchantmentMenu::slotsChanged() // 4J used to take a shared_ptr { std::shared_ptr item = enchantSlots->getItem(0); - if (item == NULL || !item->isEnchantable()) { + if (item == nullptr || !item->isEnchantable()) { for (int i = 0; i < 3; i++) { costs[i] = 0; } @@ -136,14 +136,14 @@ void EnchantmentMenu::slotsChanged() // 4J used to take a shared_ptr bool EnchantmentMenu::clickMenuButton(std::shared_ptr player, int i) { std::shared_ptr item = enchantSlots->getItem(0); - if (costs[i] > 0 && item != NULL && + if (costs[i] > 0 && item != nullptr && (player->experienceLevel >= costs[i] || player->abilities.instabuild)) { if (!level->isClientSide) { bool isBook = item->id == Item::book_Id; std::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; int randomIndex = @@ -176,7 +176,7 @@ void EnchantmentMenu::removed(std::shared_ptr player) { if (level->isClientSide) return; std::shared_ptr item = enchantSlots->removeItemNoUpdate(0); - if (item != NULL) { + if (item != nullptr) { player->drop(item); } } @@ -193,7 +193,7 @@ std::shared_ptr EnchantmentMenu::quickMoveStack( Slot* slot = slots.at(slotIndex); Slot* IngredientSlot = slots.at(INGREDIENT_SLOT); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/Containers/FireworksMenu.cpp b/Minecraft.World/Containers/FireworksMenu.cpp index 8ae25c7e9..3a47b2c8a 100644 --- a/Minecraft.World/Containers/FireworksMenu.cpp +++ b/Minecraft.World/Containers/FireworksMenu.cpp @@ -62,7 +62,7 @@ void FireworksMenu::removed(std::shared_ptr player) { for (int i = 0; i < 9; i++) { std::shared_ptr item = craftSlots->removeItemNoUpdate(i); - if (item != NULL) { + if (item != nullptr) { player->drop(item); } } @@ -74,7 +74,7 @@ std::shared_ptr FireworksMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { std::shared_ptr clicked = nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -130,7 +130,7 @@ bool FireworksMenu::canTakeItemForPickAll(std::shared_ptr carried, bool FireworksMenu::isValidIngredient(std::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/Containers/FurnaceMenu.cpp b/Minecraft.World/Containers/FurnaceMenu.cpp index 986b1e389..5fa14df30 100644 --- a/Minecraft.World/Containers/FurnaceMenu.cpp +++ b/Minecraft.World/Containers/FurnaceMenu.cpp @@ -81,7 +81,7 @@ std::shared_ptr FurnaceMenu::quickMoveStack( bool charcoalUsed = furnace->wasCharcoalUsed(); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -105,7 +105,7 @@ std::shared_ptr FurnaceMenu::quickMoveStack( return nullptr; } } else if (FurnaceRecipes::getInstance()->getResult( - stack->getItem()->id) != NULL) { + stack->getItem()->id) != nullptr) { if (!moveItemStackTo(stack, INGREDIENT_SLOT, INGREDIENT_SLOT + 1, false)) { return nullptr; diff --git a/Minecraft.World/Containers/HopperMenu.cpp b/Minecraft.World/Containers/HopperMenu.cpp index ad1fdc301..6f7d24f5a 100644 --- a/Minecraft.World/Containers/HopperMenu.cpp +++ b/Minecraft.World/Containers/HopperMenu.cpp @@ -31,7 +31,7 @@ std::shared_ptr HopperMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { std::shared_ptr clicked = nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/Containers/HorseInventoryMenu.cpp b/Minecraft.World/Containers/HorseInventoryMenu.cpp index a492bb442..084b11807 100644 --- a/Minecraft.World/Containers/HorseInventoryMenu.cpp +++ b/Minecraft.World/Containers/HorseInventoryMenu.cpp @@ -68,7 +68,7 @@ std::shared_ptr HorseInventoryMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { std::shared_ptr clicked = nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/Containers/Inventory.cpp b/Minecraft.World/Containers/Inventory.cpp index 3e518fdd0..3ce081614 100644 --- a/Minecraft.World/Containers/Inventory.cpp +++ b/Minecraft.World/Containers/Inventory.cpp @@ -57,14 +57,14 @@ int Inventory::getSelectionSize() { return SELECTION_SIZE; } 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; } int Inventory::getSlot(int tileId, int data) { for (int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->id == tileId && + if (items[i] != nullptr && items[i]->id == tileId && items[i]->getAuxValue() == data) return i; } @@ -73,7 +73,7 @@ int Inventory::getSlot(int tileId, int data) { int Inventory::getSlotWithRemainingSpace(std::shared_ptr item) { for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->id == item->id && + if (items[i] != nullptr && items[i]->id == item->id && items[i]->isStackable() && items[i]->count < items[i]->getMaxStackSize() && items[i]->count < getMaxStackSize() && @@ -88,7 +88,7 @@ int Inventory::getSlotWithRemainingSpace(std::shared_ptr item) { 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; } @@ -132,7 +132,7 @@ int Inventory::clearInventory(int id, int data) { int count = 0; for (int i = 0; i < items.length; i++) { std::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; @@ -141,7 +141,7 @@ int Inventory::clearInventory(int id, int data) { } for (int i = 0; i < armor.length; i++) { std::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; @@ -149,7 +149,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; @@ -161,9 +161,9 @@ 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() && + if (heldItem != nullptr && heldItem->isEnchantable() && getSlot(heldItem->id, heldItem->getDamageValue()) == selected) { return; } @@ -189,7 +189,7 @@ int Inventory::addResource(std::shared_ptr itemInstance) { if (itemInstance->getMaxStackSize() == 1) { int slot = getFreeSlot(); if (slot < 0) return count; - if (items[slot] == NULL) { + if (items[slot] == nullptr) { items[slot] = ItemInstance::clone(itemInstance); player->handleCollectItem(itemInstance); } @@ -199,7 +199,7 @@ int Inventory::addResource(std::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] = std::shared_ptr( new ItemInstance(type, 0, itemInstance->getAuxValue())); // 4J Stu - Brought forward from 1.2 @@ -228,7 +228,7 @@ int Inventory::addResource(std::shared_ptr itemInstance) { 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); } @@ -252,11 +252,11 @@ bool Inventory::removeResource(int type, int iAuxVal) { } void Inventory::removeResources(std::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; if (slotCount < countToRemove) { @@ -296,7 +296,7 @@ void Inventory::swapSlots(int from, int to) { } bool Inventory::add(std::shared_ptr item) { - if (item == NULL) return false; + if (item == nullptr) return false; if (item->count == 0) return false; if (!item->isDamaged()) { @@ -350,7 +350,7 @@ std::shared_ptr Inventory::removeItem(unsigned int slot, slot -= items.length; } - if (pile[slot] != NULL) { + if (pile[slot] != nullptr) { if (pile[slot]->count <= count) { std::shared_ptr item = pile[slot]; pile[slot] = nullptr; @@ -371,7 +371,7 @@ std::shared_ptr Inventory::removeItemNoUpdate(int slot) { slot -= items.length; } - if (pile[slot] != NULL) { + if (pile[slot] != nullptr) { std::shared_ptr item = pile[slot]; pile[slot] = nullptr; return item; @@ -381,7 +381,7 @@ std::shared_ptr Inventory::removeItemNoUpdate(int slot) { void Inventory::setItem(unsigned int slot, std::shared_ptr item) { #ifdef _DEBUG - if (item != NULL) { + if (item != nullptr) { std::wstring itemstring = item->toString(); app.DebugPrintf("Inventory::setItem - slot = %d,\t item = %d ", slot, item->id); @@ -389,7 +389,7 @@ void Inventory::setItem(unsigned int slot, std::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()); @@ -416,14 +416,14 @@ void Inventory::setItem(unsigned int slot, std::shared_ptr item) { float Inventory::getDestroySpeed(Tile* tile) { float speed = 1.0f; - if (items[selected] != NULL) + if (items[selected] != nullptr) speed *= items[selected]->getDestroySpeed(tile); return speed; } 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", (uint8_t)i); items[i]->save(tag); @@ -431,7 +431,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", (uint8_t)(i + 100)); armor[i]->save(tag); @@ -442,13 +442,13 @@ 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); armor = ItemInstanceArray(4); @@ -457,7 +457,7 @@ void Inventory::load(ListTag* inventoryList) { unsigned int slot = tag->getByte(L"Slot") & 0xff; std::shared_ptr item = std::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; @@ -498,7 +498,7 @@ bool Inventory::canDestroy(Tile* tile) { if (tile->material->isAlwaysDestroyable()) return true; std::shared_ptr item = getItem(selected); - if (item != NULL) return item->canDestroySpecial(tile); + if (item != nullptr) return item->canDestroySpecial(tile); return false; } @@ -509,8 +509,8 @@ std::shared_ptr Inventory::getArmor(int layer) { 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; @@ -526,8 +526,8 @@ void Inventory::hurtArmor(float dmg) { dmg = 1; } 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((int)dmg, std::dynamic_pointer_cast( player->shared_from_this())); @@ -540,13 +540,13 @@ void Inventory::hurtArmor(float dmg) { 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; } } 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; } @@ -567,8 +567,8 @@ bool Inventory::isSame(std::shared_ptr copy) { bool Inventory::isSame(std::shared_ptr a, std::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(); @@ -576,12 +576,12 @@ bool Inventory::isSame(std::shared_ptr a, std::shared_ptr Inventory::copy() { std::shared_ptr copy = - std::shared_ptr(new Inventory(NULL)); + std::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; } @@ -602,10 +602,10 @@ bool Inventory::stillValid(std::shared_ptr player) { bool Inventory::contains(std::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; } @@ -634,15 +634,15 @@ void Inventory::replaceWith(std::shared_ptr other) { } int Inventory::countMatches(std::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 += + // 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)) + if (items[i] != nullptr && items[i]->sameItemWithTags(itemInstance)) count += items[i]->count; } return count; diff --git a/Minecraft.World/Containers/InventoryMenu.cpp b/Minecraft.World/Containers/InventoryMenu.cpp index ffc027a2b..07b9e29cf 100644 --- a/Minecraft.World/Containers/InventoryMenu.cpp +++ b/Minecraft.World/Containers/InventoryMenu.cpp @@ -79,7 +79,7 @@ void InventoryMenu::removed(std::shared_ptr player) { AbstractContainerMenu::removed(player); for (int i = 0; i < 4; i++) { std::shared_ptr item = craftSlots->removeItemNoUpdate(i); - if (item != NULL) { + if (item != nullptr) { player->drop(item); craftSlots->setItem(i, nullptr); } @@ -99,7 +99,7 @@ std::shared_ptr InventoryMenu::quickMoveStack( Slot* LeggingsSlot = slots.at(ARMOR_SLOT_START + 2); Slot* BootsSlot = slots.at(ARMOR_SLOT_START + 3); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -230,7 +230,7 @@ std::shared_ptr InventoryMenu::clicked( Item::leggings_iron_Id, Item::boots_iron_Id}; for (int i = ARMOR_SLOT_START; i < ARMOR_SLOT_END; i++) { Slot* slot = slots.at(i); - if ((slot == NULL) || (!slot->hasItem()) || + if ((slot == nullptr) || (!slot->hasItem()) || (slot->getItem()->getItem()->id != ironItems[i - ARMOR_SLOT_START])) { return out; diff --git a/Minecraft.World/Containers/MerchantContainer.cpp b/Minecraft.World/Containers/MerchantContainer.cpp index b4d5986ed..09636249d 100644 --- a/Minecraft.World/Containers/MerchantContainer.cpp +++ b/Minecraft.World/Containers/MerchantContainer.cpp @@ -11,7 +11,7 @@ MerchantContainer::MerchantContainer(std::shared_ptr player, items[0] = nullptr; items[1] = nullptr; items[2] = nullptr; - activeRecipe = NULL; + activeRecipe = nullptr; selectionHint = 0; } @@ -25,7 +25,7 @@ std::shared_ptr MerchantContainer::getItem(unsigned int slot) { std::shared_ptr MerchantContainer::removeItem(unsigned int slot, int count) { - if (items[slot] != NULL) { + if (items[slot] != nullptr) { if (slot == MerchantMenu::RESULT_SLOT) { std::shared_ptr item = items[slot]; items[slot] = nullptr; @@ -56,7 +56,7 @@ bool MerchantContainer::isPaymentSlot(int slot) { } std::shared_ptr MerchantContainer::removeItemNoUpdate(int slot) { - if (items[slot] != NULL) { + if (items[slot] != nullptr) { std::shared_ptr item = items[slot]; items[slot] = nullptr; return item; @@ -67,7 +67,7 @@ std::shared_ptr MerchantContainer::removeItemNoUpdate(int slot) { void MerchantContainer::setItem(unsigned int slot, std::shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); if (isPaymentSlot(slot)) { updateSellItem(); @@ -100,32 +100,32 @@ bool MerchantContainer::canPlaceItem(int slot, void MerchantContainer::setChanged() { updateSellItem(); } void MerchantContainer::updateSellItem() { - activeRecipe = NULL; + activeRecipe = nullptr; std::shared_ptr buyItem1 = items[MerchantMenu::PAYMENT1_SLOT]; std::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/Containers/MerchantMenu.cpp b/Minecraft.World/Containers/MerchantMenu.cpp index 637f6b289..807b26a7a 100644 --- a/Minecraft.World/Containers/MerchantMenu.cpp +++ b/Minecraft.World/Containers/MerchantMenu.cpp @@ -62,10 +62,10 @@ bool MerchantMenu::stillValid(std::shared_ptr player) { std::shared_ptr MerchantMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { std::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()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -118,7 +118,7 @@ void MerchantMenu::removed(std::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/Containers/MerchantRecipe.cpp b/Minecraft.World/Containers/MerchantRecipe.cpp index aaa29e7a9..614b081e4 100644 --- a/Minecraft.World/Containers/MerchantRecipe.cpp +++ b/Minecraft.World/Containers/MerchantRecipe.cpp @@ -46,7 +46,7 @@ std::shared_ptr MerchantRecipe::getBuyAItem() { return buyA; } std::shared_ptr MerchantRecipe::getBuyBItem() { return buyB; } -bool MerchantRecipe::hasSecondaryBuyItem() { return buyB != NULL; } +bool MerchantRecipe::hasSecondaryBuyItem() { return buyB != nullptr; } std::shared_ptr MerchantRecipe::getSellItem() { return sell; } @@ -54,15 +54,15 @@ bool MerchantRecipe::isSame(MerchantRecipe* other) { if (buyA->id != other->buyA->id || sell->id != other->sell->id) { 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)); + (buyB != nullptr && buyB->count < other->buyB->count)); } int MerchantRecipe::getUses() { return uses; } @@ -99,7 +99,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"))); } tag->putInt(L"uses", uses); diff --git a/Minecraft.World/Containers/MerchantRecipeList.cpp b/Minecraft.World/Containers/MerchantRecipeList.cpp index 3e0426032..9485b6dff 100644 --- a/Minecraft.World/Containers/MerchantRecipeList.cpp +++ b/Minecraft.World/Containers/MerchantRecipeList.cpp @@ -19,8 +19,8 @@ MerchantRecipe* MerchantRecipeList::getRecipeFor( // 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 && + ((buyB == nullptr && !r->hasSecondaryBuyItem()) || + (r->hasSecondaryBuyItem() && buyB != nullptr && r->getBuyBItem()->id == buyB->id))) { if (buyA->count >= r->getBuyAItem()->count && (!r->hasSecondaryBuyItem() || @@ -28,20 +28,20 @@ MerchantRecipe* MerchantRecipeList::getRecipeFor( 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->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) { @@ -70,13 +70,13 @@ MerchantRecipe* MerchantRecipeList::getMatchingRecipeFor( buy->count >= r->getBuyAItem()->count && sell->id == r->getSellItem()->id) { if (!r->hasSecondaryBuyItem() || - (buyB != NULL && buyB->id == r->getBuyBItem()->id && + (buyB != nullptr && buyB->id == r->getBuyBItem()->id && buyB->count >= r->getBuyBItem()->count)) { return r; } } } - return NULL; + return nullptr; } void MerchantRecipeList::writeToStream(DataOutputStream* stream) { @@ -87,8 +87,8 @@ void MerchantRecipeList::writeToStream(DataOutputStream* stream) { Packet::writeItem(r->getSellItem(), stream); std::shared_ptr buyBItem = r->getBuyBItem(); - stream->writeBoolean(buyBItem != NULL); - if (buyBItem != NULL) { + stream->writeBoolean(buyBItem != nullptr); + if (buyBItem != nullptr) { Packet::writeItem(buyBItem, stream); } stream->writeBoolean(r->isDeprecated()); diff --git a/Minecraft.World/Containers/MerchantResultSlot.cpp b/Minecraft.World/Containers/MerchantResultSlot.cpp index a778447e0..289f90788 100644 --- a/Minecraft.World/Containers/MerchantResultSlot.cpp +++ b/Minecraft.World/Containers/MerchantResultSlot.cpp @@ -45,7 +45,7 @@ void MerchantResultSlot::onTake(std::shared_ptr player, checkTakeAchievements(carried); MerchantRecipe* activeRecipe = slots->getActiveRecipe(); - if (activeRecipe != NULL) { + if (activeRecipe != nullptr) { std::shared_ptr item1 = slots->getItem(MerchantMenu::PAYMENT1_SLOT); std::shared_ptr item2 = @@ -78,12 +78,12 @@ bool MerchantResultSlot::removePaymentItemsIfMatching( std::shared_ptr buyA = activeRecipe->getBuyAItem(); std::shared_ptr buyB = activeRecipe->getBuyBItem(); - if (a != NULL && a->id == buyA->id) { - if (buyB != NULL && b != NULL && buyB->id == b->id) { + if (a != nullptr && a->id == buyA->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/Containers/RepairResultSlot.cpp b/Minecraft.World/Containers/RepairResultSlot.cpp index 5291605c2..d8f0a6f49 100644 --- a/Minecraft.World/Containers/RepairResultSlot.cpp +++ b/Minecraft.World/Containers/RepairResultSlot.cpp @@ -33,7 +33,7 @@ void RepairResultSlot::onTake(std::shared_ptr player, if (m_menu->repairItemCountCost > 0) { std::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); } else { diff --git a/Minecraft.World/Containers/ResultContainer.cpp b/Minecraft.World/Containers/ResultContainer.cpp index 722d60e58..c95258bd2 100644 --- a/Minecraft.World/Containers/ResultContainer.cpp +++ b/Minecraft.World/Containers/ResultContainer.cpp @@ -18,7 +18,7 @@ bool ResultContainer::hasCustomName() { return false; } std::shared_ptr ResultContainer::removeItem(unsigned int slot, int count) { - if (items[0] != NULL) { + if (items[0] != nullptr) { std::shared_ptr item = items[0]; items[0] = nullptr; return item; @@ -27,7 +27,7 @@ std::shared_ptr ResultContainer::removeItem(unsigned int slot, } std::shared_ptr ResultContainer::removeItemNoUpdate(int slot) { - if (items[0] != NULL) { + if (items[0] != nullptr) { std::shared_ptr item = items[0]; items[0] = nullptr; return item; diff --git a/Minecraft.World/Containers/ResultSlot.cpp b/Minecraft.World/Containers/ResultSlot.cpp index 30bdbb60f..21ba38854 100644 --- a/Minecraft.World/Containers/ResultSlot.cpp +++ b/Minecraft.World/Containers/ResultSlot.cpp @@ -79,7 +79,7 @@ void ResultSlot::onTake(std::shared_ptr player, for (unsigned int i = 0; i < craftSlots->getContainerSize(); i++) { std::shared_ptr item = craftSlots->getItem(i); - if (item != NULL) { + if (item != nullptr) { craftSlots->removeItem(i, 1); if (item->getItem()->hasCraftingRemainingItem()) { @@ -98,7 +98,7 @@ void ResultSlot::onTake(std::shared_ptr player, } // 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); } else { // Finally, if nothing else, just drop the item diff --git a/Minecraft.World/Containers/SimpleContainer.cpp b/Minecraft.World/Containers/SimpleContainer.cpp index 2651ca487..59f7a0d39 100644 --- a/Minecraft.World/Containers/SimpleContainer.cpp +++ b/Minecraft.World/Containers/SimpleContainer.cpp @@ -13,12 +13,12 @@ SimpleContainer::SimpleContainer(int name, std::wstring stringName, this->size = size; items = new ItemInstanceArray(size); - listeners = NULL; + listeners = nullptr; } void SimpleContainer::addListener( net_minecraft_world::ContainerListener* listener) { - if (listeners == NULL) + if (listeners == nullptr) listeners = new std::vector(); listeners->push_back(listener); } @@ -43,7 +43,7 @@ std::shared_ptr SimpleContainer::getItem(unsigned int slot) { std::shared_ptr SimpleContainer::removeItem(unsigned int slot, int count) { - if ((*items)[slot] != NULL) { + if ((*items)[slot] != nullptr) { if ((*items)[slot]->count <= count) { std::shared_ptr item = (*items)[slot]; (*items)[slot] = nullptr; @@ -60,7 +60,7 @@ std::shared_ptr SimpleContainer::removeItem(unsigned int slot, } std::shared_ptr SimpleContainer::removeItemNoUpdate(int slot) { - if ((*items)[slot] != NULL) { + if ((*items)[slot] != nullptr) { std::shared_ptr item = (*items)[slot]; (*items)[slot] = nullptr; return item; @@ -71,7 +71,7 @@ std::shared_ptr SimpleContainer::removeItemNoUpdate(int slot) { void SimpleContainer::setItem(unsigned int slot, std::shared_ptr item) { (*items)[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); setChanged(); } @@ -98,7 +98,7 @@ int SimpleContainer::getMaxStackSize() { } void SimpleContainer::setChanged() { - if (listeners != NULL) + if (listeners != nullptr) for (unsigned int i = 0; i < listeners->size(); i++) { listeners->at(i)->containerChanged(); // shared_from_this()); } diff --git a/Minecraft.World/Containers/Slot.cpp b/Minecraft.World/Containers/Slot.cpp index 5eee6da94..1ecdd27aa 100644 --- a/Minecraft.World/Containers/Slot.cpp +++ b/Minecraft.World/Containers/Slot.cpp @@ -15,7 +15,7 @@ Slot::Slot(std::shared_ptr container, int slot, int x, int y) void Slot::onQuickCraft(std::shared_ptr picked, std::shared_ptr original) { - if (picked == NULL || original == NULL) { + if (picked == nullptr || original == nullptr) { return; } if (picked->id != original->id) { @@ -36,12 +36,12 @@ void Slot::swap(Slot* other) { std::shared_ptr item2 = other->container->getItem(other->slot); - if (item1 != NULL && item1->count > other->getMaxStackSize()) { - if (item2 != NULL) return; + if (item1 != nullptr && item1->count > other->getMaxStackSize()) { + if (item2 != nullptr) return; item2 = item1->remove(item1->count - other->getMaxStackSize()); } - if (item2 != NULL && item2->count > getMaxStackSize()) { - if (item1 != NULL) return; + if (item2 != nullptr && item2->count > getMaxStackSize()) { + if (item1 != nullptr) return; item1 = item2->remove(item2->count - getMaxStackSize()); } other->container->setItem(other->slot, item1); @@ -61,7 +61,7 @@ std::shared_ptr Slot::getItem() { return container->getItem(slot); } -bool Slot::hasItem() { return getItem() != NULL; } +bool Slot::hasItem() { return getItem() != nullptr; } void Slot::set(std::shared_ptr item) { container->setItem(slot, item); @@ -72,7 +72,7 @@ void Slot::setChanged() { container->setChanged(); } int Slot::getMaxStackSize() { return container->getMaxStackSize(); } -Icon* Slot::getNoItemIcon() { return NULL; } +Icon* Slot::getNoItemIcon() { return nullptr; } std::shared_ptr Slot::remove(int c) { return container->removeItem(slot, c); @@ -89,7 +89,7 @@ bool Slot::isActive() { return true; } bool Slot::mayCombine(std::shared_ptr second) { std::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) { @@ -100,7 +100,7 @@ bool Slot::mayCombine(std::shared_ptr second) { } // 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 && + 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())) { @@ -117,7 +117,7 @@ std::shared_ptr Slot::combine( std::shared_ptr first = getItem(); std::shared_ptr craftSlots = - std::shared_ptr(new CraftingContainer(NULL, 2, 2)); + std::shared_ptr(new CraftingContainer(nullptr, 2, 2)); craftSlots->setItem(0, item); craftSlots->setItem(1, first); @@ -125,7 +125,7 @@ std::shared_ptr Slot::combine( if (thisItem) { result = ArmorDyeRecipe::assembleDyedArmor(craftSlots); } else { - result = Recipes::getInstance()->getItemFor(craftSlots, NULL); + result = Recipes::getInstance()->getItemFor(craftSlots, nullptr); } craftSlots->setItem(0, nullptr); diff --git a/Minecraft.World/Containers/TrapMenu.cpp b/Minecraft.World/Containers/TrapMenu.cpp index a48c7648c..206ca0048 100644 --- a/Minecraft.World/Containers/TrapMenu.cpp +++ b/Minecraft.World/Containers/TrapMenu.cpp @@ -35,7 +35,7 @@ std::shared_ptr TrapMenu::quickMoveStack( std::shared_ptr player, int slotIndex) { std::shared_ptr clicked = nullptr; Slot* slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) { + if (slot != nullptr && slot->hasItem()) { std::shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/Core/ItemDispenseBehaviors.cpp b/Minecraft.World/Core/ItemDispenseBehaviors.cpp index 20d3cca88..b15a58c9e 100644 --- a/Minecraft.World/Core/ItemDispenseBehaviors.cpp +++ b/Minecraft.World/Core/ItemDispenseBehaviors.cpp @@ -101,7 +101,7 @@ std::shared_ptr SpawnEggDispenseBehavior::execute( 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/Enchantments/DamageEnchantment.cpp b/Minecraft.World/Enchantments/DamageEnchantment.cpp index c04e344ed..782e7f718 100644 --- a/Minecraft.World/Enchantments/DamageEnchantment.cpp +++ b/Minecraft.World/Enchantments/DamageEnchantment.cpp @@ -40,7 +40,7 @@ float DamageEnchantment::getDamageBonus(int level, int DamageEnchantment::getDescriptionId() { return names[type]; } bool DamageEnchantment::isCompatibleWith(Enchantment* other) const { - return dynamic_cast(other) == NULL; + return dynamic_cast(other) == nullptr; } bool DamageEnchantment::canEnchant(std::shared_ptr item) { diff --git a/Minecraft.World/Enchantments/Enchantment.cpp b/Minecraft.World/Enchantments/Enchantment.cpp index 2213c435b..eb7be03a7 100644 --- a/Minecraft.World/Enchantments/Enchantment.cpp +++ b/Minecraft.World/Enchantments/Enchantment.cpp @@ -7,34 +7,34 @@ EnchantmentArray Enchantment::enchantments = EnchantmentArray(256); std::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() { allDamageProtection = @@ -78,14 +78,14 @@ 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); } } } void Enchantment::_init(int id) { - if (enchantments[id] != NULL) { + if (enchantments[id] != nullptr) { app.DebugPrintf("Duplicate enchantment id!"); #ifndef _CONTENT_PACKAGE __debugbreak(); diff --git a/Minecraft.World/Enchantments/EnchantmentCategory.cpp b/Minecraft.World/Enchantments/EnchantmentCategory.cpp index 41657390c..90fd58a42 100644 --- a/Minecraft.World/Enchantments/EnchantmentCategory.cpp +++ b/Minecraft.World/Enchantments/EnchantmentCategory.cpp @@ -22,7 +22,7 @@ const EnchantmentCategory* EnchantmentCategory::bow = new EnchantmentCategory(); 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 = (ArmorItem*)item; if (ai->slot == ArmorItem::SLOT_HEAD) return this == armor_head; @@ -30,11 +30,11 @@ bool EnchantmentCategory::canEnchant(Item* item) const { if (ai->slot == ArmorItem::SLOT_TORSO) return this == armor_torso; 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; } return false; diff --git a/Minecraft.World/Enchantments/EnchantmentHelper.cpp b/Minecraft.World/Enchantments/EnchantmentHelper.cpp index 53ec1c6de..88e6a3090 100644 --- a/Minecraft.World/Enchantments/EnchantmentHelper.cpp +++ b/Minecraft.World/Enchantments/EnchantmentHelper.cpp @@ -11,11 +11,11 @@ Random EnchantmentHelper::random; int EnchantmentHelper::getEnchantmentLevel( int enchantmentId, std::shared_ptr piece) { - if (piece == NULL) { + if (piece == nullptr) { return 0; } ListTag* enchantmentTags = piece->getEnchantmentTags(); - if (enchantmentTags == NULL) { + if (enchantmentTags == nullptr) { return 0; } for (int i = 0; i < enchantmentTags->size(); i++) { @@ -39,7 +39,7 @@ std::unordered_map* EnchantmentHelper::getEnchantments( ? Item::enchantedBook->getEnchantments(item) : item->getEnchantmentTags(); - if (list != NULL) { + if (list != nullptr) { for (int i = 0; i < list->size(); i++) { int type = list->get(i)->getShort((wchar_t*)ItemInstance::TAG_ENCH_ID); @@ -87,7 +87,7 @@ void EnchantmentHelper::setEnchantments( 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) { @@ -101,11 +101,11 @@ int EnchantmentHelper::getEnchantmentLevel(int enchantmentId, void EnchantmentHelper::runIterationOnItem( EnchantmentIterationMethod& method, std::shared_ptr piece) { - if (piece == NULL) { + if (piece == nullptr) { return; } ListTag* enchantmentTags = piece->getEnchantmentTags(); - if (enchantmentTags == NULL) { + if (enchantmentTags == nullptr) { return; } for (int i = 0; i < enchantmentTags->size(); i++) { @@ -114,7 +114,7 @@ void EnchantmentHelper::runIterationOnItem( 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); } } @@ -242,7 +242,7 @@ std::shared_ptr EnchantmentHelper::getRandomItemWith( ItemInstanceArray items = source->getEquipmentSlots(); for (unsigned int i = 0; i < items.length; ++i) { std::shared_ptr item = items[i]; - if (item != NULL && getEnchantmentLevel(enchantment->id, item) > 0) { + if (item != nullptr && getEnchantmentLevel(enchantment->id, item) > 0) { return item; } } @@ -298,7 +298,7 @@ std::shared_ptr EnchantmentHelper::enchantItem( if (isBook) itemInstance->id = Item::enchantedBook_Id; - if (newEnchantment != NULL) { + if (newEnchantment != nullptr) { for (AUTO_VAR(it, newEnchantment->begin()); it != newEnchantment->end(); ++it) { EnchantmentInstance* e = *it; @@ -329,7 +329,7 @@ std::vector* EnchantmentHelper::selectEnchantment( int itemBonus = item->getEnchantmentValue(); if (itemBonus <= 0) { - return NULL; + return nullptr; } // 4J Stu - Update function to 1.3 version for TU7 itemBonus /= 2; @@ -345,11 +345,11 @@ std::vector* EnchantmentHelper::selectEnchantment( realValue = 1; } - std::vector* results = NULL; + std::vector* results = nullptr; std::unordered_map* availableEnchantments = getAvailableEnchantmentResults(realValue, itemInstance); - if (availableEnchantments != NULL && !availableEnchantments->empty()) { + if (availableEnchantments != nullptr && !availableEnchantments->empty()) { std::vector values; for (AUTO_VAR(it, availableEnchantments->begin()); it != availableEnchantments->end(); ++it) { @@ -359,7 +359,7 @@ std::vector* EnchantmentHelper::selectEnchantment( (EnchantmentInstance*)WeighedRandom::getRandomItem(random, &values); values.clear(); - if (instance != NULL) { + if (instance != nullptr) { results = new std::vector(); results->push_back( instance->copy()); // 4J Stu - Inserting a copy so we can clear @@ -415,7 +415,7 @@ std::vector* EnchantmentHelper::selectEnchantment( } } } - if (availableEnchantments != NULL) { + if (availableEnchantments != nullptr) { for (AUTO_VAR(it, availableEnchantments->begin()); it != availableEnchantments->end(); ++it) { delete it->second; @@ -430,14 +430,14 @@ std::unordered_map* EnchantmentHelper::getAvailableEnchantmentResults( int value, std::shared_ptr itemInstance) { Item* item = itemInstance->getItem(); - std::unordered_map* results = NULL; + std::unordered_map* results = nullptr; bool isBook = itemInstance->id == Item::book_Id; // for (Enchantment e : Enchantment.enchantments) for (unsigned int i = 0; i < Enchantment::enchantments.length; ++i) { Enchantment* e = Enchantment::enchantments[i]; - if (e == NULL) { + if (e == nullptr) { continue; } @@ -449,7 +449,7 @@ EnchantmentHelper::getAvailableEnchantmentResults( for (int level = e->getMinLevel(); level <= e->getMaxLevel(); level++) { if (value >= e->getMinCost(level) && value <= e->getMaxCost(level)) { - if (results == NULL) { + if (results == nullptr) { results = new std::unordered_map(); } diff --git a/Minecraft.World/Enchantments/ProtectionEnchantment.cpp b/Minecraft.World/Enchantments/ProtectionEnchantment.cpp index d9765a651..12b0042f1 100644 --- a/Minecraft.World/Enchantments/ProtectionEnchantment.cpp +++ b/Minecraft.World/Enchantments/ProtectionEnchantment.cpp @@ -50,7 +50,7 @@ int ProtectionEnchantment::getDescriptionId() { return names[type]; } bool ProtectionEnchantment::isCompatibleWith(Enchantment* other) const { ProtectionEnchantment* pe = dynamic_cast(other); - if (pe != NULL) { + if (pe != nullptr) { if (pe->type == type) { return false; } diff --git a/Minecraft.World/Enchantments/ThornsEnchantment.cpp b/Minecraft.World/Enchantments/ThornsEnchantment.cpp index e00308ed4..30842b5b8 100644 --- a/Minecraft.World/Enchantments/ThornsEnchantment.cpp +++ b/Minecraft.World/Enchantments/ThornsEnchantment.cpp @@ -50,11 +50,11 @@ void ThornsEnchantment::doThornsAfterAttack( 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/Entities/Enemy.cpp b/Minecraft.World/Entities/Enemy.cpp index ec2c5bcdc..3ca407447 100644 --- a/Minecraft.World/Entities/Enemy.cpp +++ b/Minecraft.World/Entities/Enemy.cpp @@ -4,5 +4,5 @@ EntitySelector* Enemy::ENEMY_SELECTOR = new Enemy::EnemyEntitySelector(); bool Enemy::EnemyEntitySelector::matches(std::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/Entities/Entity.cpp b/Minecraft.World/Entities/Entity.cpp index 64e5a0bb4..6a34a9bdd 100644 --- a/Minecraft.World/Entities/Entity.cpp +++ b/Minecraft.World/Entities/Entity.cpp @@ -44,7 +44,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 @@ -262,7 +262,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; @@ -354,7 +354,7 @@ Entity::Entity(Level* level, // resetPos(); setPos(0, 0, 0); - if (level != NULL) { + if (level != nullptr) { dimension = level->dimension->id; } @@ -396,7 +396,7 @@ return entityId; */ void Entity::resetPos() { - if (level == NULL) return; + if (level == nullptr) return; std::shared_ptr sharedThis = shared_from_this(); while (true && y > 0) { @@ -492,7 +492,7 @@ void Entity::baseTick() { // 4J Stu - Not needed // util.Timer.push("entityBaseTick"); - if (riding != NULL && riding->removed) { + if (riding != nullptr && riding->removed) { riding = nullptr; } @@ -514,7 +514,7 @@ void Entity::baseTick() { if (isInsidePortal) { if (server->isNetherEnabled()) { - if (riding == NULL) { + if (riding == nullptr) { if (portalTime++ >= waitTime) { portalTime = waitTime; changingDimensionDelay = @@ -852,7 +852,7 @@ void Entity::move(double xa, double ya, double za, double ym = y - yo; 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); int zt = Mth::floor(z); @@ -976,7 +976,7 @@ void Entity::checkFallDamage(double ya, bool onGround) { } } -AABB* Entity::getCollideBox() { return NULL; } +AABB* Entity::getCollideBox() { return nullptr; } void Entity::burn(int dmg) { if (!fireImmune) { @@ -987,7 +987,7 @@ void Entity::burn(int dmg) { bool Entity::isFireImmune() { return fireImmune; } void Entity::causeFallDamage(float distance) { - if (rider.lock() != NULL) rider.lock()->causeFallDamage(distance); + if (rider.lock() != nullptr) rider.lock()->causeFallDamage(distance); } bool Entity::isInWaterOrRain() { @@ -1240,7 +1240,7 @@ bool Entity::saveAsMount(CompoundTag* entityTag) { bool Entity::save(CompoundTag* entityTag) { std::wstring id = getEncodeId(); - if (removed || id.empty() || (rider.lock() != NULL)) { + if (removed || id.empty() || (rider.lock() != nullptr)) { return false; } // TODO Is this fine to be casting to a non-const char pointer? @@ -1266,7 +1266,7 @@ void Entity::saveWithoutId(CompoundTag* entityTag) { addAdditonalSaveData(entityTag); - if (riding != NULL) { + if (riding != nullptr) { CompoundTag* ridingTag = new CompoundTag(RIDING_TAG); if (riding->saveAsMount(ridingTag)) { entityTag->put(L"Riding", ridingTag); @@ -1428,7 +1428,7 @@ bool Entity::isInWall() { bool Entity::interact(std::shared_ptr player) { return false; } AABB* Entity::getCollideAgainstBox(std::shared_ptr entity) { - return NULL; + return nullptr; } void Entity::rideTick() { @@ -1439,7 +1439,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). @@ -1477,7 +1477,7 @@ void Entity::rideTick() { void Entity::positionRider() { std::shared_ptr lockedRider = rider.lock(); - if (lockedRider == NULL) { + if (lockedRider == nullptr) { return; } lockedRider->setPos(x, y + getRideHeight() + lockedRider->getRidingHeight(), @@ -1492,8 +1492,8 @@ void Entity::ride(std::shared_ptr e) { xRideRotA = 0; yRideRotA = 0; - if (e == NULL) { - if (riding != NULL) { + if (e == nullptr) { + if (riding != nullptr) { // 4J Stu - Position should already be updated before the // SetEntityLinkPacket comes in if (!level->isClientSide) @@ -1504,7 +1504,7 @@ void Entity::ride(std::shared_ptr e) { riding = nullptr; return; } - if (riding != NULL) { + if (riding != nullptr) { riding->rider = std::weak_ptr(); } riding = e; @@ -1571,7 +1571,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 @@ -1583,7 +1583,7 @@ bool Entity::isOnFire() { return !fireImmune && (onFire > 0 || getSharedFlag(FLAG_ONFIRE)); } -bool Entity::isRiding() { return riding != NULL; } +bool Entity::isRiding() { return riding != nullptr; } bool Entity::isSneaking() { return getSharedFlag(FLAG_SNEAKING); } @@ -1730,7 +1730,7 @@ std::wstring Entity::getAName() { #endif } -std::vector >* Entity::getSubEntities() { return NULL; } +std::vector >* Entity::getSubEntities() { return nullptr; } bool Entity::is(std::shared_ptr other) { return shared_from_this() == other; @@ -1802,7 +1802,7 @@ void Entity::changeDimension(int i) { std::shared_ptr newEntity = EntityIO::newEntity( EntityIO::getEncodeId(shared_from_this()), newLevel); - if (newEntity != NULL) { + if (newEntity != nullptr) { newEntity->restoreFrom(shared_from_this(), true); if (lastDimension == 1 && i == 1) { diff --git a/Minecraft.World/Entities/EntityDamageSource.cpp b/Minecraft.World/Entities/EntityDamageSource.cpp index a455a4a59..ea5f0afd0 100644 --- a/Minecraft.World/Entities/EntityDamageSource.cpp +++ b/Minecraft.World/Entities/EntityDamageSource.cpp @@ -26,7 +26,7 @@ std::shared_ptr EntityDamageSource::getEntity() { return entity; } std::shared_ptr EntityDamageSource::getDeathMessagePacket( std::shared_ptr player) { std::shared_ptr held = - (entity != NULL) && entity->instanceof(eTYPE_LIVINGENTITY) + (entity != nullptr) && entity->instanceof(eTYPE_LIVINGENTITY) ? std::dynamic_pointer_cast(entity)->getCarriedItem() : nullptr; std::wstring additional = L""; @@ -40,7 +40,7 @@ std::shared_ptr EntityDamageSource::getDeathMessagePacket( } } - if ((held != NULL) && held->hasCustomHoverName()) { + if ((held != nullptr) && held->hasCustomHoverName()) { return std::shared_ptr(new ChatPacket( player->getNetworkName(), m_msgWithItemId, entity->GetType(), additional, held->getHoverName())); @@ -51,7 +51,7 @@ std::shared_ptr EntityDamageSource::getDeathMessagePacket( } bool EntityDamageSource::scalesWithDifficulty() { - return (entity != NULL) && entity->instanceof(eTYPE_LIVINGENTITY) && + return (entity != nullptr) && entity->instanceof(eTYPE_LIVINGENTITY) && !entity->instanceof(eTYPE_PLAYER); } diff --git a/Minecraft.World/Entities/EntityPos.cpp b/Minecraft.World/Entities/EntityPos.cpp index 2535900aa..bd5813f5d 100644 --- a/Minecraft.World/Entities/EntityPos.cpp +++ b/Minecraft.World/Entities/EntityPos.cpp @@ -51,5 +51,5 @@ EntityPos* EntityPos::lerp(std::shared_ptr e, float f) { if (rot) { return new EntityPos(yrd, xrd); } - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.World/Entities/EntitySelector.cpp b/Minecraft.World/Entities/EntitySelector.cpp index 18ee52af4..a4e79f855 100644 --- a/Minecraft.World/Entities/EntitySelector.cpp +++ b/Minecraft.World/Entities/EntitySelector.cpp @@ -12,7 +12,7 @@ bool AliveEntitySelector::matches(std::shared_ptr entity) const { } bool ContainerEntitySelector::matches(std::shared_ptr entity) const { - return (std::dynamic_pointer_cast(entity) != NULL) && + return (std::dynamic_pointer_cast(entity) != nullptr) && entity->isAlive(); } @@ -29,7 +29,7 @@ bool MobCanWearArmourEntitySelector::matches( std::shared_ptr mob = std::dynamic_pointer_cast(entity); - if (mob->getCarried(Mob::getEquipmentSlotForItem(item)) != NULL) + if (mob->getCarried(Mob::getEquipmentSlotForItem(item)) != nullptr) return false; if (mob->instanceof(eTYPE_MOB)) { diff --git a/Minecraft.World/Entities/FireworksRocketEntity.cpp b/Minecraft.World/Entities/FireworksRocketEntity.cpp index 44f118599..ee8ed0a72 100644 --- a/Minecraft.World/Entities/FireworksRocketEntity.cpp +++ b/Minecraft.World/Entities/FireworksRocketEntity.cpp @@ -13,7 +13,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) { @@ -34,12 +34,12 @@ FireworksRocketEntity::FireworksRocketEntity( 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); } } @@ -110,8 +110,8 @@ void FireworksRocketEntity::handleEntityEvent(uint8_t eventId) { if (eventId == EntityEvent::FIREWORKS_EXPLODE && level->isClientSide) { std::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); } @@ -125,7 +125,7 @@ void FireworksRocketEntity::addAdditonalSaveData(CompoundTag* tag) { tag->putInt(L"LifeTime", lifetime); std::shared_ptr itemInstance = entityData->getItemInstance(DATA_ID_FIREWORKS_ITEM); - if (itemInstance != NULL) { + if (itemInstance != nullptr) { CompoundTag* itemTag = new CompoundTag(); itemInstance->save(itemTag); tag->putCompound(L"FireworksItem", itemTag); @@ -137,9 +137,9 @@ void FireworksRocketEntity::readAdditionalSaveData(CompoundTag* tag) { lifetime = tag->getInt(L"LifeTime"); CompoundTag* itemTag = tag->getCompound(L"FireworksItem"); - if (itemTag != NULL) { + if (itemTag != nullptr) { std::shared_ptr fromTag = ItemInstance::fromTag(itemTag); - if (fromTag != NULL) { + if (fromTag != nullptr) { entityData->set(DATA_ID_FIREWORKS_ITEM, fromTag); } } diff --git a/Minecraft.World/Entities/HangingEntity.cpp b/Minecraft.World/Entities/HangingEntity.cpp index aa693de88..421f6ba26 100644 --- a/Minecraft.World/Entities/HangingEntity.cpp +++ b/Minecraft.World/Entities/HangingEntity.cpp @@ -130,7 +130,7 @@ bool HangingEntity::survives() { std::vector >* entities = level->getEntities(shared_from_this(), &bb); - if (entities != NULL && entities->size() > 0) { + if (entities != nullptr && entities->size() > 0) { AUTO_VAR(itEnd, entities->end()); for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) { std::shared_ptr e = (*it); @@ -158,10 +158,10 @@ bool HangingEntity::skipAttackInteraction(std::shared_ptr source) { 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) { std::shared_ptr sourceEntity = source->getDirectEntity(); - if ((sourceEntity != NULL) && + if ((sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_PLAYER) && !std::dynamic_pointer_cast(sourceEntity) ->isAllowedToHurtEntity(shared_from_this())) { @@ -174,14 +174,14 @@ bool HangingEntity::hurt(DamageSource* source, float damage) { std::shared_ptr player = nullptr; std::shared_ptr e = source->getEntity(); - if ((e != NULL) && + if ((e != nullptr) && e->instanceof( eTYPE_PLAYER)) // check if it's serverplayer or player { player = std::dynamic_pointer_cast(e); } - if (player != NULL && player->abilities.instabuild) { + if (player != nullptr && player->abilities.instabuild) { return true; } diff --git a/Minecraft.World/Entities/IndirectEntityDamageSource.cpp b/Minecraft.World/Entities/IndirectEntityDamageSource.cpp index 326ed1757..5b3695493 100644 --- a/Minecraft.World/Entities/IndirectEntityDamageSource.cpp +++ b/Minecraft.World/Entities/IndirectEntityDamageSource.cpp @@ -40,17 +40,17 @@ std::shared_ptr IndirectEntityDamageSource::getDeathMessagePacket( : nullptr; std::wstring additional = L""; int type; - if (owner != NULL) { + if (owner != nullptr) { type = owner->GetType(); if (type == eTYPE_SERVERPLAYER) { std::shared_ptr sourcePlayer = std::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 std::shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId, type, additional, held->getHoverName())); diff --git a/Minecraft.World/Entities/ItemEntity.cpp b/Minecraft.World/Entities/ItemEntity.cpp index 8d4706e39..9a03bca8d 100644 --- a/Minecraft.World/Entities/ItemEntity.cpp +++ b/Minecraft.World/Entities/ItemEntity.cpp @@ -56,7 +56,7 @@ bool ItemEntity::makeStepSound() { return false; } ItemEntity::ItemEntity(Level* level) : Entity(level) { _init(); } void ItemEntity::defineSynchedData() { - getEntityData()->defineNULL(DATA_ITEM, NULL); + getEntityData()->defineNULL(DATA_ITEM, nullptr); } void ItemEntity::tick() { @@ -179,7 +179,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 && + if (getItem() != nullptr && getItem()->id == Item::netherStar_Id && source->isExplosion()) return false; markHurt(); @@ -193,7 +193,7 @@ bool ItemEntity::hurt(DamageSource* source, float damage) { void ItemEntity::addAdditonalSaveData(CompoundTag* entityTag) { entityTag->putShort(L"Health", (uint8_t)health); entityTag->putShort(L"Age", (short)age); - if (getItem() != NULL) + if (getItem() != nullptr) entityTag->putCompound(L"Item", getItem()->save(new CompoundTag())); } @@ -202,7 +202,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(std::shared_ptr player) { @@ -267,8 +267,8 @@ std::shared_ptr ItemEntity::getItem() { std::shared_ptr result = getEntityData()->getItemInstance(DATA_ITEM); - if (result == NULL) { - if (level != NULL) { + if (result == nullptr) { + 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/Entities/LargeFireball.cpp b/Minecraft.World/Entities/LargeFireball.cpp index 5c2eb50a6..e99c7c0a1 100644 --- a/Minecraft.World/Entities/LargeFireball.cpp +++ b/Minecraft.World/Entities/LargeFireball.cpp @@ -22,7 +22,7 @@ LargeFireball::LargeFireball(Level* level, std::shared_ptr mob, void LargeFireball::onHit(HitResult* res) { if (!level->isClientSide) { - if (res->entity != NULL) { + if (res->entity != nullptr) { DamageSource* damageSource = DamageSource::fireball( std::dynamic_pointer_cast(shared_from_this()), owner); res->entity->hurt(damageSource, 6); diff --git a/Minecraft.World/Entities/LeashFenceKnotEntity.cpp b/Minecraft.World/Entities/LeashFenceKnotEntity.cpp index d86972cad..fcb5c9f31 100644 --- a/Minecraft.World/Entities/LeashFenceKnotEntity.cpp +++ b/Minecraft.World/Entities/LeashFenceKnotEntity.cpp @@ -50,7 +50,7 @@ bool LeashFenceKnotEntity::interact(std::shared_ptr player) { std::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; @@ -58,7 +58,7 @@ bool LeashFenceKnotEntity::interact(std::shared_ptr player) { x + range, y + range, z + range}; std::vector >* mobs = level->getEntitiesOfClass(typeid(Mob), &mob_aabb); - if (mobs != NULL) { + if (mobs != nullptr) { for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) { std::shared_ptr mob = std::dynamic_pointer_cast(*it); @@ -82,7 +82,7 @@ bool LeashFenceKnotEntity::interact(std::shared_ptr player) { x + range, y + range, z + range}; std::vector >* mobs = level->getEntitiesOfClass(typeid(Mob), &mob_aabb); - if (mobs != NULL) { + if (mobs != nullptr) { for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) { std::shared_ptr mob = std::dynamic_pointer_cast(*it); @@ -101,7 +101,7 @@ bool LeashFenceKnotEntity::interact(std::shared_ptr player) { bool LeashFenceKnotEntity::survives() { // knots are placed on top of fence tiles int tile = level->getTile(xTile, yTile, zTile); - if (Tile::tiles[tile] != NULL && + if (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE) { return true; } @@ -124,7 +124,7 @@ std::shared_ptr LeashFenceKnotEntity::findKnotAt( x + 1.0, y + 1.0, z + 1.0}; std::vector >* knots = level->getEntitiesOfClass( typeid(LeashFenceKnotEntity), &leash_fence_knot_entity_aabb); - if (knots != NULL) { + if (knots != nullptr) { for (AUTO_VAR(it, knots->begin()); it != knots->end(); ++it) { std::shared_ptr knot = std::dynamic_pointer_cast(*it); diff --git a/Minecraft.World/Entities/LivingEntity.cpp b/Minecraft.World/Entities/LivingEntity.cpp index 4013c2cc3..16af9402c 100644 --- a/Minecraft.World/Entities/LivingEntity.cpp +++ b/Minecraft.World/Entities/LivingEntity.cpp @@ -42,7 +42,7 @@ AttributeModifier* LivingEntity::SPEED_MODIFIER_SPRINTING = ->setSerialize(false); void LivingEntity::_init() { - attributes = NULL; + attributes = nullptr; combatTracker = new CombatTracker(this); lastEquipment = ItemInstanceArray(5); @@ -127,7 +127,7 @@ LivingEntity::~LivingEntity() { delete attributes; delete combatTracker; - if (lastEquipment.data != NULL) delete[] lastEquipment.data; + if (lastEquipment.data != nullptr) delete[] lastEquipment.data; } void LivingEntity::defineSynchedData() { @@ -192,7 +192,7 @@ void LivingEntity::baseTick() { std::shared_ptr thisPlayer = std::dynamic_pointer_cast(shared_from_this()); bool isInvulnerable = - (thisPlayer != NULL && thisPlayer->abilities.invulnerable); + (thisPlayer != nullptr && thisPlayer->abilities.invulnerable); if (isAlive() && isUnderLiquid(Material::water)) { if (!isWaterMob() && !hasEffect(MobEffect::waterBreathing->id) && @@ -241,12 +241,12 @@ 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); } @@ -360,7 +360,7 @@ void LivingEntity::addAdditonalSaveData(CompoundTag* entityTag) { ItemInstanceArray items = getEquipmentSlots(); for (unsigned int i = 0; i < items.length; ++i) { std::shared_ptr item = items[i]; - if (item != NULL) { + if (item != nullptr) { attributes->removeItemModifiers(item); } } @@ -370,7 +370,7 @@ void LivingEntity::addAdditonalSaveData(CompoundTag* entityTag) { for (unsigned int i = 0; i < items.length; ++i) { std::shared_ptr item = items[i]; - if (item != NULL) { + if (item != nullptr) { attributes->addItemModifiers(item); } } @@ -390,7 +390,7 @@ void LivingEntity::addAdditonalSaveData(CompoundTag* entityTag) { 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")); @@ -412,7 +412,7 @@ void LivingEntity::readAdditionalSaveData(CompoundTag* tag) { setHealth(tag->getFloat(L"HealF")); } else { Tag* healthTag = tag->get(L"Health"); - if (healthTag == NULL) { + if (healthTag == nullptr) { setHealth(getMaxHealth()); } else if (healthTag->getId() == Tag::TAG_Float) { setHealth(((FloatTag*)healthTag)->data); @@ -552,7 +552,7 @@ bool LivingEntity::hasEffect(MobEffect* effect) { } MobEffectInstance* LivingEntity::getEffect(MobEffect* effect) { - MobEffectInstance* effectInst = NULL; + MobEffectInstance* effectInst = nullptr; AUTO_VAR(it, activeEffects.find(effect->id)); if (it != activeEffects.end()) effectInst = it->second; @@ -614,7 +614,7 @@ void LivingEntity::removeEffectNoUpdate(int effectId) { AUTO_VAR(it, activeEffects.find(effectId)); if (it != activeEffects.end()) { MobEffectInstance* effect = it->second; - if (effect != NULL) { + if (effect != nullptr) { delete effect; } activeEffects.erase(it); @@ -625,7 +625,7 @@ void LivingEntity::removeEffect(int effectId) { AUTO_VAR(it, activeEffects.find(effectId)); if (it != activeEffects.end()) { MobEffectInstance* effect = it->second; - if (effect != NULL) { + if (effect != nullptr) { onEffectRemoved(effect); delete effect; } @@ -684,9 +684,9 @@ bool LivingEntity::hurt(DamageSource* source, float dmg) { // 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 + // source is never nullptr due to changes in 1.8.2 to what source actually is if (level->isClientSide && - dynamic_cast(source) == NULL) + dynamic_cast(source) == nullptr) return false; noActionTime = 0; if (getHealth() <= 0) return false; @@ -708,7 +708,7 @@ bool LivingEntity::hurt(DamageSource* source, float dmg) { if ((source == DamageSource::anvil || source == DamageSource::fallingBlock) && - getCarried(SLOT_HELM) != NULL) { + getCarried(SLOT_HELM) != nullptr) { getCarried(SLOT_HELM)->hurtAndBreak( (int)(dmg * 4 + random->nextFloat() * dmg * 2.0f), std::dynamic_pointer_cast(shared_from_this())); @@ -734,7 +734,7 @@ bool LivingEntity::hurt(DamageSource* source, float dmg) { hurtDir = 0; std::shared_ptr sourceEntity = source->getEntity(); - if (sourceEntity != NULL) { + if (sourceEntity != nullptr) { if (sourceEntity->instanceof(eTYPE_LIVINGENTITY)) { setLastHurtByMob( std::dynamic_pointer_cast(sourceEntity)); @@ -760,7 +760,7 @@ bool LivingEntity::hurt(DamageSource* source, float dmg) { if (sound) { 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; while (xd * xd + zd * zd < 0.0001) { @@ -811,10 +811,10 @@ void LivingEntity::breakItem(std::shared_ptr itemInstance) { void LivingEntity::die(DamageSource* source) { std::shared_ptr sourceEntity = source->getEntity(); std::shared_ptr killer = getKillCredit(); - if (deathScore >= 0 && killer != NULL) + if (deathScore >= 0 && killer != nullptr) killer->awardKillScore(shared_from_this(), deathScore); - if (sourceEntity != NULL) + if (sourceEntity != nullptr) sourceEntity->killed( std::dynamic_pointer_cast(shared_from_this())); @@ -824,7 +824,7 @@ void LivingEntity::die(DamageSource* source) { int playerBonus = 0; std::shared_ptr player = nullptr; - if ((sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_PLAYER)) { + if ((sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_PLAYER)) { player = std::dynamic_pointer_cast(sourceEntity); playerBonus = EnchantmentHelper::getKillingLootBonus( std::dynamic_pointer_cast(player)); @@ -843,7 +843,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( @@ -912,7 +912,7 @@ bool LivingEntity::isAlive() { return !removed && getHealth() > 0; } 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 = (int)ceil(distance - 3 - padding); if (dmg > 0) { @@ -952,7 +952,7 @@ int LivingEntity::getArmorValue() { ItemInstanceArray items = getEquipmentSlots(); for (unsigned int i = 0; i < items.length; ++i) { std::shared_ptr item = items[i]; - if (item != NULL && dynamic_cast(item->getItem()) != NULL) { + if (item != nullptr && dynamic_cast(item->getItem()) != nullptr) { int baseProtection = ((ArmorItem*)item->getItem())->defense; val += baseProtection; } @@ -1023,9 +1023,9 @@ void LivingEntity::actuallyHurt(DamageSource* source, float dmg) { CombatTracker* LivingEntity::getCombatTracker() { return combatTracker; } std::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; } @@ -1059,7 +1059,7 @@ void LivingEntity::swing() { swingTime = -1; swinging = true; - if (dynamic_cast(level) != NULL) { + if (dynamic_cast(level) != nullptr) { ((ServerLevel*)level) ->getTracker() ->broadcast(shared_from_this(), @@ -1126,7 +1126,7 @@ AttributeInstance* LivingEntity::getAttribute(Attribute* attribute) { } BaseAttributeMap* LivingEntity::getAttributes() { - if (attributes == NULL) { + if (attributes == nullptr) { attributes = new ServersideAttributeMap(); } @@ -1140,7 +1140,7 @@ void LivingEntity::setSprinting(bool 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); } if (value) { @@ -1411,9 +1411,9 @@ void LivingEntity::tick() { shared_from_this(), std::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(); } } } @@ -1576,7 +1576,7 @@ void LivingEntity::pushEntities() { AABB grown = bb.grow(0.2, 0, 0.2); std::vector >* entities = level->getEntities(shared_from_this(), &grown); - if (entities != NULL && !entities->empty()) { + if (entities != nullptr && !entities->empty()) { AUTO_VAR(itEnd, entities->end()); for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) { std::shared_ptr e = *it; // entities->at(i); @@ -1638,7 +1638,7 @@ bool LivingEntity::canSee(std::shared_ptr target) { Vec3 b{target->x, target->y + target->getHeadHeight(), target->z}; HitResult* hres = level->clip(&a, &b); - bool retVal = (hres == NULL); + bool retVal = (hres == nullptr); delete hres; return retVal; } @@ -1715,14 +1715,14 @@ void LivingEntity::setAbsorptionAmount(float absorptionAmount) { this->absorptionAmount = absorptionAmount; } -Team* LivingEntity::getTeam() { return NULL; } +Team* LivingEntity::getTeam() { return nullptr; } bool LivingEntity::isAlliedTo(std::shared_ptr other) { return isAlliedTo(other->getTeam()); } bool LivingEntity::isAlliedTo(Team* other) { - if (getTeam() != NULL) { + if (getTeam() != nullptr) { return getTeam()->isAlliedTo(other); } return false; diff --git a/Minecraft.World/Entities/LivingEntity.h b/Minecraft.World/Entities/LivingEntity.h index 30ad389b3..ec20a24a9 100644 --- a/Minecraft.World/Entities/LivingEntity.h +++ b/Minecraft.World/Entities/LivingEntity.h @@ -27,7 +27,7 @@ protected: 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/Entities/MinecartContainer.cpp b/Minecraft.World/Entities/MinecartContainer.cpp index ca25f81df..0a1a5f0ab 100644 --- a/Minecraft.World/Entities/MinecartContainer.cpp +++ b/Minecraft.World/Entities/MinecartContainer.cpp @@ -29,7 +29,7 @@ void MinecartContainer::destroy(DamageSource* source) { for (int i = 0; i < getContainerSize(); i++) { std::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; float zo = random->nextFloat() * 0.8f + 0.1f; @@ -60,7 +60,7 @@ std::shared_ptr MinecartContainer::getItem(unsigned int slot) { std::shared_ptr MinecartContainer::removeItem(unsigned int slot, int count) { - if (items[slot] != NULL) { + if (items[slot] != nullptr) { if (items[slot]->count <= count) { std::shared_ptr item = items[slot]; items[slot] = nullptr; @@ -75,7 +75,7 @@ std::shared_ptr MinecartContainer::removeItem(unsigned int slot, } std::shared_ptr MinecartContainer::removeItemNoUpdate(int slot) { - if (items[slot] != NULL) { + if (items[slot] != nullptr) { std::shared_ptr item = items[slot]; items[slot] = nullptr; return item; @@ -86,7 +86,7 @@ std::shared_ptr MinecartContainer::removeItemNoUpdate(int slot) { void MinecartContainer::setItem(unsigned int slot, std::shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); } @@ -125,7 +125,7 @@ void MinecartContainer::remove() { if (dropEquipment) { for (int i = 0; i < getContainerSize(); i++) { std::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; float zo = random->nextFloat() * 0.8f + 0.1f; @@ -165,7 +165,7 @@ void MinecartContainer::addAdditonalSaveData(CompoundTag* base) { ListTag* listTag = new ListTag(); for (int i = 0; i < items.length; i++) { - if (items[i] != NULL) { + if (items[i] != nullptr) { CompoundTag* tag = new CompoundTag(); tag->putByte(L"Slot", (uint8_t)i); items[i]->save(tag); diff --git a/Minecraft.World/Entities/MinecartFurnace.cpp b/Minecraft.World/Entities/MinecartFurnace.cpp index 87d95a868..b075af545 100644 --- a/Minecraft.World/Entities/MinecartFurnace.cpp +++ b/Minecraft.World/Entities/MinecartFurnace.cpp @@ -104,7 +104,7 @@ void MinecartFurnace::applyNaturalSlowdown() { bool MinecartFurnace::interact(std::shared_ptr player) { std::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/Entities/MinecartRideable.cpp b/Minecraft.World/Entities/MinecartRideable.cpp index de59c8f4c..1e04c5f94 100644 --- a/Minecraft.World/Entities/MinecartRideable.cpp +++ b/Minecraft.World/Entities/MinecartRideable.cpp @@ -18,10 +18,10 @@ MinecartRideable::MinecartRideable(Level* level, double x, double y, double z) } bool MinecartRideable::interact(std::shared_ptr player) { - if (rider.lock() != NULL && rider.lock()->instanceof(eTYPE_PLAYER) && + if (rider.lock() != nullptr && 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() != player) return false; if (!level->isClientSide) { player->ride(shared_from_this()); } diff --git a/Minecraft.World/Entities/Mob.cpp b/Minecraft.World/Entities/Mob.cpp index 4ebcf21ac..7fa3dfa74 100644 --- a/Minecraft.World/Entities/Mob.cpp +++ b/Minecraft.World/Entities/Mob.cpp @@ -41,7 +41,7 @@ void Mob::_init() { lookingAt = nullptr; lookTime = 0; target = nullptr; - sensing = NULL; + sensing = nullptr; equipment = ItemInstanceArray(5); dropChances = floatArray(5); @@ -55,7 +55,7 @@ void Mob::_init() { _isLeashed = false; leashHolder = nullptr; - leashInfoTag = NULL; + leashInfoTag = nullptr; } Mob::Mob(Level* level) : LivingEntity(level) { @@ -82,16 +82,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; } @@ -159,7 +159,7 @@ int Mob::getExperienceReward(std::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); } } @@ -224,7 +224,7 @@ void Mob::addAdditonalSaveData(CompoundTag* entityTag) { ListTag* gear = new ListTag(); 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); @@ -239,7 +239,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)) { // a walking, talking, leash holder @@ -307,7 +307,7 @@ void Mob::aiStep() { for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) { std::shared_ptr entity = std::dynamic_pointer_cast(*it); - if (entity->removed || entity->getItem() == NULL) continue; + if (entity->removed || entity->getItem() == nullptr) continue; std::shared_ptr item = entity->getItem(); int slot = getEquipmentSlotForItem(item); @@ -315,15 +315,15 @@ void Mob::aiStep() { bool replace = true; std::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()) { replace = item->getAuxValue() > @@ -341,9 +341,9 @@ void Mob::aiStep() { 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) { replace = item->getAuxValue() > current->getAuxValue() || @@ -358,7 +358,7 @@ void Mob::aiStep() { } if (replace) { - if (current != NULL && + if (current != nullptr && random->nextFloat() - 0.1f < dropChances[slot]) { spawnAtLocation(current, 0); } @@ -386,7 +386,7 @@ void Mob::checkDespawn() { } std::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; double zd = player->z - z; @@ -459,7 +459,7 @@ void Mob::serverAiStep() { if (random->nextFloat() < 0.02f) { std::shared_ptr player = level->getNearestPlayer(shared_from_this(), lookDistance); - if (player != NULL) { + if (player != nullptr) { lookingAt = player; lookTime = 10 + random->nextInt(20); } else { @@ -467,7 +467,7 @@ void Mob::serverAiStep() { } } - if (lookingAt != NULL) { + if (lookingAt != nullptr) { lookAt(lookingAt, 10.0f, (float)getMaxHeadXRot()); if (lookTime-- <= 0 || lookingAt->removed || lookingAt->distanceToSqr(shared_from_this()) > @@ -510,7 +510,7 @@ void Mob::lookAt(std::shared_ptr e, float yMax, float xMax) { yRot = rotlerp(yRot, yRotD, yMax); } -bool Mob::isLookingAtAnEntity() { return lookingAt != NULL; } +bool Mob::isLookingAtAnEntity() { return lookingAt != nullptr; } std::shared_ptr Mob::getLookingAt() { return lookingAt; } @@ -539,7 +539,7 @@ float Mob::getHeadSizeScale() { return 1.0f; } int Mob::getMaxSpawnClusterSize() { return 4; } int Mob::getMaxFallDistance() { - if (getTarget() == NULL) return 3; + if (getTarget() == nullptr) return 3; int sacrifice = (int)(getHealth() - (getMaxHealth() * 0.33f)); sacrifice -= (3 - level->difficulty) * 4; if (sacrifice < 0) sacrifice = 0; @@ -569,7 +569,7 @@ void Mob::dropEquipment(bool byPlayer, int playerBonusLevel) { std::shared_ptr item = getCarried(slot); bool preserve = dropChances[slot] > 1; - if (item != NULL && (byPlayer || preserve) && + if (item != nullptr && (byPlayer || preserve) && random->nextFloat() - playerBonusLevel * 0.01f < dropChances[slot]) { if (!preserve && item->isDamageableItem()) { @@ -598,9 +598,9 @@ void Mob::populateDefaultEquipmentSlots() { for (int i = 3; i >= 0; i--) { std::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) + if (equip != nullptr) setEquippedSlot(i + 1, std::shared_ptr( new ItemInstance(equip))); } @@ -614,7 +614,7 @@ int Mob::getEquipmentSlotForItem(std::shared_ptr item) { } ArmorItem* armorItem = dynamic_cast(item->getItem()); - if (armorItem != NULL) { + if (armorItem != nullptr) { switch (armorItem->slot) { case ArmorItem::SLOT_FEET: return SLOT_BOOTS; @@ -658,13 +658,13 @@ 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 && + if (getCarriedItem() != nullptr && random->nextFloat() < MAX_ENCHANTED_WEAPON_CHANCE * difficulty) { EnchantmentHelper::enchantItem( random, getCarriedItem(), @@ -673,7 +673,7 @@ void Mob::populateDefaultEquipmentEnchantments() { for (int i = 0; i < 4; i++) { std::shared_ptr item = getArmor(i); - if (item != NULL && + if (item != nullptr && random->nextFloat() < MAX_ENCHANTED_ARMOR_CHANCE * difficulty) { EnchantmentHelper::enchantItem( random, item, (int)(5 + difficulty * random->nextInt(18))); @@ -752,7 +752,7 @@ bool Mob::interact(std::shared_ptr player) { } std::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 // item.interact(mob) @@ -791,14 +791,14 @@ bool Mob::interact(std::shared_ptr player) { bool Mob::mobInteract(std::shared_ptr player) { return false; } void Mob::tickLeash() { - if (leashInfoTag != NULL) { + if (leashInfoTag != nullptr) { restoreLeashFromSave(); } if (!_isLeashed) { return; } - if (leashHolder == NULL || leashHolder->removed) { + if (leashHolder == nullptr || leashHolder->removed) { dropLeash(true, true); return; } @@ -813,7 +813,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(), std::shared_ptr(new SetEntityLinkPacket( @@ -845,7 +845,7 @@ void Mob::setLeashedTo(std::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")) { std::wstring leashUuid = leashInfoTag->getString(L"UUID"); AABB grown = bb.grow(10, 10, 10); @@ -872,7 +872,7 @@ void Mob::restoreLeashFromSave() { std::shared_ptr activeKnot = LeashFenceKnotEntity::findKnotAt(level, x, y, z); - if (activeKnot == NULL) { + if (activeKnot == nullptr) { activeKnot = LeashFenceKnotEntity::createAndAddKnot(level, x, y, z); } @@ -882,7 +882,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 diff --git a/Minecraft.World/Entities/Mob.h b/Minecraft.World/Entities/Mob.h index 1b64d6a18..28723d342 100644 --- a/Minecraft.World/Entities/Mob.h +++ b/Minecraft.World/Entities/Mob.h @@ -26,7 +26,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/Entities/MobCategory.cpp b/Minecraft.World/Entities/MobCategory.cpp index b55f6c21a..9f3c15840 100644 --- a/Minecraft.World/Entities/MobCategory.cpp +++ b/Minecraft.World/Entities/MobCategory.cpp @@ -5,14 +5,14 @@ #include "../Blocks/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/Entities/MobEffect.cpp b/Minecraft.World/Entities/MobEffect.cpp index 828b5a4e3..d38d72361 100644 --- a/Minecraft.World/Entities/MobEffect.cpp +++ b/Minecraft.World/Entities/MobEffect.cpp @@ -45,7 +45,7 @@ MobEffect* MobEffect::reserved_30; MobEffect* MobEffect::reserved_31; void MobEffect::staticCtor() { - voidEffect = NULL; + voidEffect = nullptr; movementSpeed = (new MobEffect(1, false, eMinecraftColour_Effect_MovementSpeed)) ->setDescriptionId(IDS_POTION_MOVESPEED) @@ -191,14 +191,14 @@ void MobEffect::staticCtor() { 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) @@ -281,7 +281,7 @@ void MobEffect::applyInstantenousEffect(std::shared_ptr source, } else if ((id == harm->id && !mob->isInvertedHealAndHarm()) || (id == heal->id && mob->isInvertedHealAndHarm())) { int amount = (int)(scale * (double)(6 << amplification) + .5); - if (source == NULL) { + if (source == nullptr) { mob->hurt(DamageSource::magic, amount); } else { DamageSource* damageSource = @@ -416,7 +416,7 @@ void MobEffect::removeAttributeModifiers(std::shared_ptr entity, it != attributeModifiers.end(); ++it) { AttributeInstance* attribute = attributes->getInstance(it->first); - if (attribute != NULL) { + if (attribute != nullptr) { attribute->removeModifier(it->second); } } @@ -429,7 +429,7 @@ void MobEffect::addAttributeModifiers(std::shared_ptr entity, it != attributeModifiers.end(); ++it) { AttributeInstance* attribute = attributes->getInstance(it->first); - if (attribute != NULL) { + if (attribute != nullptr) { AttributeModifier* original = it->second; attribute->removeModifier(original); attribute->addModifier(new AttributeModifier( diff --git a/Minecraft.World/Entities/Mobs/AgeableMob.cpp b/Minecraft.World/Entities/Mobs/AgeableMob.cpp index ff04e017f..7069b991e 100644 --- a/Minecraft.World/Entities/Mobs/AgeableMob.cpp +++ b/Minecraft.World/Entities/Mobs/AgeableMob.cpp @@ -15,7 +15,7 @@ AgableMob::AgableMob(Level* level) : PathfinderMob(level) { bool AgableMob::mobInteract(std::shared_ptr player) { std::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) { eINSTANCEOF classToSpawn = EntityIO::getClass(item->getAuxValue()); if (classToSpawn != eTYPE_NOTSET && @@ -27,11 +27,11 @@ bool AgableMob::mobInteract(std::shared_ptr player) { std::shared_ptr result = SpawnEggItem::canSpawn(item->getAuxValue(), level, &error); - if (result != NULL) { + if (result != nullptr) { std::shared_ptr offspring = getBreedOffspring(std::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/Entities/Mobs/Animal.cpp b/Minecraft.World/Entities/Mobs/Animal.cpp index a2ce25b5b..09ec08def 100644 --- a/Minecraft.World/Entities/Mobs/Animal.cpp +++ b/Minecraft.World/Entities/Mobs/Animal.cpp @@ -71,7 +71,7 @@ void Animal::checkHurtTarget(std::shared_ptr target, float d) { } std::shared_ptr p = std::dynamic_pointer_cast(target); - if (p->getSelectedItem() == NULL || !isFood(p->getSelectedItem())) { + if (p->getSelectedItem() == nullptr || !isFood(p->getSelectedItem())) { attackTarget = nullptr; } @@ -84,7 +84,7 @@ void Animal::checkHurtTarget(std::shared_ptr target, float d) { holdGround = true; } } 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) { a->setInLoveValue(a->getInLoveValue() + 1); @@ -119,10 +119,10 @@ void Animal::breedWith(std::shared_ptr target) { target->loveTime = 0; target->setInLoveValue(0); - // 4J - we have offspring of NULL returned when we have hit our limits of + // 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. @@ -158,7 +158,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) { std::shared_ptr source = dmgSource->getDirectEntity(); // 4J-JEV: Changed from dynamic cast to use eINSTANCEOF @@ -168,13 +168,13 @@ bool Animal::hurt(DamageSource* dmgSource, float dmg) { return false; } - if ((source != NULL) && source->instanceof(eTYPE_ARROW)) { + if ((source != nullptr) && source->instanceof(eTYPE_ARROW)) { std::shared_ptr arrow = std::dynamic_pointer_cast(source); // 4J: Check that the arrow's owner can attack animals (dispenser // arrows are not owned) - if (arrow->owner != NULL && + if (arrow->owner != nullptr && arrow->owner->instanceof(eTYPE_PLAYER) && !std::dynamic_pointer_cast(arrow->owner) ->isAllowedToAttackAnimals()) { @@ -188,7 +188,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)); } @@ -239,7 +239,7 @@ std::shared_ptr Animal::findAttackTarget() { std::shared_ptr p = std::dynamic_pointer_cast(*it); - if (p->getSelectedItem() != NULL && + if (p->getSelectedItem() != nullptr && this->isFood(p->getSelectedItem())) { delete players; return p; @@ -290,7 +290,7 @@ bool Animal::isFood(std::shared_ptr itemInstance) { bool Animal::mobInteract(std::shared_ptr player) { std::shared_ptr item = player->inventory->getSelected(); - if (item != NULL && isFood(item) && getAge() == 0 && + if (item != nullptr && isFood(item) && getAge() == 0 && getInLoveValue() <= 0) { if (!player->abilities.instabuild) { item->count--; diff --git a/Minecraft.World/Entities/Mobs/Arrow.cpp b/Minecraft.World/Entities/Mobs/Arrow.cpp index 4c8977b66..28a8425a9 100644 --- a/Minecraft.World/Entities/Mobs/Arrow.cpp +++ b/Minecraft.World/Entities/Mobs/Arrow.cpp @@ -225,7 +225,7 @@ void Arrow::tick() { from = Vec3{x, y, z}; to = Vec3{x + xd, y + yd, z + zd}; - if (res != NULL) { + if (res != nullptr) { to = Vec3{res->pos.x, res->pos.y, res->pos.z}; } @@ -242,7 +242,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) { hitEntity = e; @@ -252,34 +252,34 @@ void Arrow::tick() { } } - if (hitEntity != NULL) { + if (hitEntity != nullptr) { delete res; res = new HitResult(hitEntity); } - if ((res != NULL) && (res->entity != NULL) && + if ((res != nullptr) && (res->entity != nullptr) && res->entity->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(res->entity); // 4J: Check for owner being null if (player->abilities.invulnerable || - ((owner != NULL) && + ((owner != nullptr) && (owner->instanceof(eTYPE_PLAYER) && !std::dynamic_pointer_cast(owner)->canHarmPlayer( player)))) { - res = NULL; + res = nullptr; } } - if (res != NULL) { - if (res->entity != NULL) { + if (res != nullptr) { + if (res->entity != nullptr) { float pow = Mth::sqrt(xd * xd + yd * yd + zd * zd); int dmg = (int)Mth::ceil((float)(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( std::dynamic_pointer_cast(shared_from_this()), shared_from_this()); @@ -316,12 +316,12 @@ void Arrow::tick() { } } - if (owner != NULL) { + if (owner != nullptr) { ThornsEnchantment::doThornsAfterAttack(owner, mob, random); } - if (owner != NULL && res->entity != owner && + if (owner != nullptr && res->entity != owner && owner->GetType() == eTYPE_SERVERPLAYER) { std::dynamic_pointer_cast(owner) ->connection->send(std::shared_ptr( @@ -332,7 +332,7 @@ void Arrow::tick() { // 4J : WESTY : For award, need to track if creeper was killed // by arrow from the player. - if (owner != NULL && + if (owner != nullptr && owner->instanceof(eTYPE_PLAYER) // arrow owner is a player && !res->entity->isAlive() // target is now dead && (res->entity->GetType() == diff --git a/Minecraft.World/Entities/Mobs/Bat.cpp b/Minecraft.World/Entities/Mobs/Bat.cpp index 5835875af..3a9e61d42 100644 --- a/Minecraft.World/Entities/Mobs/Bat.cpp +++ b/Minecraft.World/Entities/Mobs/Bat.cpp @@ -14,7 +14,7 @@ Bat::Bat(Level* level) : AmbientCreature(level) { registerAttributes(); setHealth(getMaxHealth()); - targetPosition = NULL; + targetPosition = nullptr; setSize(.5f, .9f); setResting(true); @@ -106,21 +106,21 @@ 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, (int)x, (int)y, (int)z, 0); } } } else { - if (targetPosition != NULL && + 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 || + if (targetPosition == nullptr || random->nextInt(30) == 0 || targetPosition->distSqr((int)x, (int)y, (int)z) < 4) { delete targetPosition; targetPosition = diff --git a/Minecraft.World/Entities/Mobs/Blaze.cpp b/Minecraft.World/Entities/Mobs/Blaze.cpp index ce7fec922..6766d7c83 100644 --- a/Minecraft.World/Entities/Mobs/Blaze.cpp +++ b/Minecraft.World/Entities/Mobs/Blaze.cpp @@ -64,7 +64,7 @@ void Blaze::aiStep() { allowedHeightOffset = .5f + (float)random->nextGaussian() * 3; } - if (getAttackTarget() != NULL && + if (getAttackTarget() != nullptr && (getAttackTarget()->y + getAttackTarget()->getHeadHeight()) > (y + getHeadHeight() + allowedHeightOffset)) { yd = yd + (.3f - yd) * .3f; diff --git a/Minecraft.World/Entities/Mobs/Boat.cpp b/Minecraft.World/Entities/Mobs/Boat.cpp index aafb09124..a674f1e07 100644 --- a/Minecraft.World/Entities/Mobs/Boat.cpp +++ b/Minecraft.World/Entities/Mobs/Boat.cpp @@ -72,7 +72,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) { std::shared_ptr attacker = source->getDirectEntity(); if (attacker->instanceof(eTYPE_PLAYER) && @@ -89,7 +89,7 @@ bool Boat::hurt(DamageSource* source, float hurtDamage) { // 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()) + if (rider.lock() != nullptr && rider.lock() == source->getEntity()) hurtDamage += 1; setDamage(getDamage() + hurtDamage * 10); @@ -99,13 +99,13 @@ bool Boat::hurt(DamageSource* source, float hurtDamage) { // 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) && + bool creativePlayer = (source->getEntity() != nullptr) && source->getEntity()->instanceof(eTYPE_PLAYER) && std::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(); } @@ -241,7 +241,7 @@ void Boat::tick() { yd += 0.007f; } - if (rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY)) { + if (rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_LIVINGENTITY)) { std::shared_ptr livingRider = std::dynamic_pointer_cast(rider.lock()); double forward = livingRider->yya; @@ -316,7 +316,7 @@ void Boat::tick() { AABB grown = bb.grow(0.2, 0, 0.2); std::vector >* entities = level->getEntities(shared_from_this(), &grown); - if (entities != NULL && !entities->empty()) { + if (entities != nullptr && !entities->empty()) { AUTO_VAR(itEnd, entities->end()); for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) { std::shared_ptr e = (*it); // entities->at(i); @@ -343,13 +343,13 @@ void Boat::tick() { } } - if (rider.lock() != NULL) { + if (rider.lock() != nullptr) { if (rider.lock()->removed) rider = std::weak_ptr(); } } 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; @@ -366,7 +366,7 @@ float Boat::getShadowHeightOffs() { return 0; } std::wstring Boat::getName() { return L"Boat"; } bool Boat::interact(std::shared_ptr player) { - if ((rider.lock() != NULL) && rider.lock()->instanceof(eTYPE_PLAYER) && + if ((rider.lock() != nullptr) && rider.lock()->instanceof(eTYPE_PLAYER) && (rider.lock() != player)) return true; if (!level->isClientSide) { diff --git a/Minecraft.World/Entities/Mobs/Cow.cpp b/Minecraft.World/Entities/Mobs/Cow.cpp index 217570612..add30a92f 100644 --- a/Minecraft.World/Entities/Mobs/Cow.cpp +++ b/Minecraft.World/Entities/Mobs/Cow.cpp @@ -76,7 +76,7 @@ void Cow::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) { bool Cow::mobInteract(std::shared_ptr player) { std::shared_ptr item = player->inventory->getSelected(); - if (item != NULL && item->id == Item::bucket_empty->id && + if (item != nullptr && item->id == Item::bucket_empty->id && !player->abilities.instabuild) { player->awardStat(GenericStats::cowsMilked(), GenericStats::param_cowsMilked()); diff --git a/Minecraft.World/Entities/Mobs/Creeper.cpp b/Minecraft.World/Entities/Mobs/Creeper.cpp index 404ae4a41..a89674da1 100644 --- a/Minecraft.World/Entities/Mobs/Creeper.cpp +++ b/Minecraft.World/Entities/Mobs/Creeper.cpp @@ -57,7 +57,7 @@ void Creeper::registerAttributes() { bool Creeper::useNewAi() { return true; } 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 + (int)(getHealth() - 1); } @@ -127,7 +127,7 @@ int Creeper::getDeathSound() { return eSoundType_MOB_CREEPER_DEATH; } void Creeper::die(DamageSource* source) { Monster::die(source); - if (source->getEntity() != NULL && + if (source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_SKELETON)) { int recordId = Item::record_01_Id + @@ -135,9 +135,9 @@ void Creeper::die(DamageSource* source) { spawnAtLocation(recordId, 1); } - if (source->getDirectEntity() != NULL && + if (source->getDirectEntity() != nullptr && source->getDirectEntity()->instanceof(eTYPE_ARROW) && - source->getEntity() != NULL && + source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(source->getEntity()); diff --git a/Minecraft.World/Entities/Mobs/DragonFireball.cpp b/Minecraft.World/Entities/Mobs/DragonFireball.cpp index 19486ffbe..b5baf730a 100644 --- a/Minecraft.World/Entities/Mobs/DragonFireball.cpp +++ b/Minecraft.World/Entities/Mobs/DragonFireball.cpp @@ -33,7 +33,7 @@ void DragonFireball::onHit(HitResult* res) { std::vector >* entitiesOfClass = level->getEntitiesOfClass(typeid(LivingEntity), &aoe); - if (entitiesOfClass != NULL && !entitiesOfClass->empty()) { + if (entitiesOfClass != nullptr && !entitiesOfClass->empty()) { // for (Entity e : entitiesOfClass) for (AUTO_VAR(it, entitiesOfClass->begin()); it != entitiesOfClass->end(); ++it) { diff --git a/Minecraft.World/Entities/Mobs/EnderCrystal.cpp b/Minecraft.World/Entities/Mobs/EnderCrystal.cpp index 45924f472..4802dcbc1 100644 --- a/Minecraft.World/Entities/Mobs/EnderCrystal.cpp +++ b/Minecraft.World/Entities/Mobs/EnderCrystal.cpp @@ -68,7 +68,7 @@ bool EnderCrystal::hurt(DamageSource* source, float damage) { // 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 && + if (source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_ENDERDRAGON)) { return false; } @@ -87,7 +87,7 @@ bool EnderCrystal::hurt(DamageSource* source, float damage) { for (AUTO_VAR(it, entities.begin()); it != itEnd; it++) { std::shared_ptr e = *it; // entities->at(i); dragon = std::dynamic_pointer_cast(e); - if (dragon != NULL) { + if (dragon != nullptr) { dragon->handleCrystalDestroyed(source); break; } diff --git a/Minecraft.World/Entities/Mobs/EnderDragon.cpp b/Minecraft.World/Entities/Mobs/EnderDragon.cpp index 7aa192c13..fa5b27936 100644 --- a/Minecraft.World/Entities/Mobs/EnderDragon.cpp +++ b/Minecraft.World/Entities/Mobs/EnderDragon.cpp @@ -84,7 +84,7 @@ void EnderDragon::_init() { m_nodes = new NodeArray(24); openSet = new BinaryHeap(); - m_currentPath = NULL; + m_currentPath = nullptr; } EnderDragon::EnderDragon(Level* level) : Mob(level) { @@ -141,14 +141,14 @@ 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() { @@ -406,7 +406,7 @@ void EnderDragon::aiStep() { SITTING_ATTACK_Y_VIEW_RANGE); ++m_actionTicks; - if (attackTarget != NULL) { + if (attackTarget != nullptr) { if (m_actionTicks > SITTING_SCANNING_IDLE_TICKS / 4) { setSynchedAction(e_EnderdragonAction_Sitting_Attacking); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES @@ -478,7 +478,7 @@ void EnderDragon::aiStep() { if (getSynchedAction() == e_EnderdragonAction_Sitting_Flaming) { // No movement } else if (getSynchedAction() == e_EnderdragonAction_Sitting_Scanning) { - if (attackTarget != NULL) { + if (attackTarget != nullptr) { Vec3 aim = Vec3((attackTarget->x - x), 0, (attackTarget->z - z)) .normalize(); @@ -531,7 +531,7 @@ void EnderDragon::aiStep() { // double yTargetO = yTarget; // double zTargetO = zTarget; if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && - attackTarget != NULL && m_currentPath != NULL && + attackTarget != nullptr && m_currentPath != nullptr && m_currentPath->isDone()) { xTarget = attackTarget->x; zTarget = attackTarget->z; @@ -732,7 +732,7 @@ void EnderDragon::aiStep() { if (!level->isClientSide) { double maxDist = 64.0f; if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && - attackTarget != NULL && + attackTarget != nullptr && attackTarget->distanceToSqr(shared_from_this()) < maxDist * maxDist) { if (this->canSee(attackTarget)) { @@ -776,7 +776,7 @@ void EnderDragon::aiStep() { app.DebugPrintf( "Finding new target due to having fired a fireball\n"); - if (m_currentPath != NULL) { + if (m_currentPath != nullptr) { while (!m_currentPath->isDone()) { m_currentPath->next(); } @@ -800,10 +800,10 @@ 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; @@ -892,7 +892,7 @@ void EnderDragon::findNewTarget() { switch (getSynchedAction()) { case e_EnderdragonAction_Takeoff: case e_EnderdragonAction_HoldingPattern: { - if (!newTarget && m_currentPath != NULL && + if (!newTarget && m_currentPath != nullptr && m_currentPath->isDone()) { // Distance is 64, which is the radius of the circle int eggHeight = @@ -903,7 +903,7 @@ void EnderDragon::findNewTarget() { 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); @@ -918,7 +918,7 @@ void EnderDragon::findNewTarget() { } // More likely to strafe a player if they are close to the egg, // or there are not many crystals remaining - else if (playerNearestToEgg != NULL && + else if (playerNearestToEgg != nullptr && (random->nextInt(abs(dist) + 2) == 0 || random->nextInt(m_remainingCrystalsCount + 2) == 0)) { setSynchedAction(e_EnderdragonAction_StrafePlayer); @@ -930,7 +930,7 @@ void EnderDragon::findNewTarget() { } break; case e_EnderdragonAction_StrafePlayer: // Always return to the holding pattern after strafing - if (m_currentPath == NULL || + if (m_currentPath == nullptr || (m_currentPath->isDone() && newTarget)) { setSynchedAction(e_EnderdragonAction_HoldingPattern); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES @@ -963,12 +963,12 @@ void EnderDragon::findNewTarget() { // if (random->nextInt(2) == 0 && level->players.size() > 0) if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && - playerNearestToEgg != NULL) { + playerNearestToEgg != nullptr) { attackTarget = playerNearestToEgg; strafeAttackTarget(); } 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(); // To get the angle to the player correct when landing, head to a @@ -981,7 +981,7 @@ void EnderDragon::findNewTarget() { PODIUM_X_POS, eggHeight, PODIUM_Z_POS, 128.0); int targetNodeIndex = 0; - if (playerNearestToEgg != NULL) { + if (playerNearestToEgg != nullptr) { Vec3 aim = Vec3(playerNearestToEgg->x, 0, playerNearestToEgg->z) .normalize(); @@ -994,19 +994,19 @@ 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 app.DebugPrintf("Dragon action is now: Landing\n"); @@ -1019,7 +1019,7 @@ void EnderDragon::findNewTarget() { } else { // 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; // if(random->nextInt(4) == 0) m_holdingPatternClockwise = @@ -1054,11 +1054,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(); @@ -1124,9 +1124,9 @@ bool EnderDragon::hurt(std::shared_ptr MultiEntityMobPart, // 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 && + if (source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) || source->isExplosion()) { int healthBefore = getHealth(); @@ -1141,7 +1141,7 @@ bool EnderDragon::hurt(std::shared_ptr MultiEntityMobPart, setHealth(1); if (setSynchedAction(e_EnderdragonAction_LandingApproach)) { - if (m_currentPath != NULL) { + if (m_currentPath != nullptr) { while (!m_currentPath->isDone()) { m_currentPath->next(); } @@ -1214,7 +1214,7 @@ void EnderDragon::tickDeath() { yBodyRot = yRot += 20.0f; if (dragonDeathTime == 200 && !level->isClientSide) { - // level->levelEvent(NULL, LevelEvent::ENDERDRAGON_KILLED, (int) x, + // level->levelEvent(nullptr, LevelEvent::ENDERDRAGON_KILLED, (int) x, // (int) y, (int) z, 0); int xpCount = 2000; @@ -1438,7 +1438,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource* source) { if (m_remainingCrystalsCount % 2 == 0) { if (setSynchedAction(e_EnderdragonAction_LandingApproach)) { - if (m_currentPath != NULL) { + if (m_currentPath != nullptr) { while (!m_currentPath->isDone()) { m_currentPath->next(); } @@ -1448,7 +1448,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource* source) { app.DebugPrintf("Dragon action is now: LandingApproach\n"); #endif } - } else if (source->getEntity() != NULL && + } else if (source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER)) { if (setSynchedAction(e_EnderdragonAction_StrafePlayer)) { attackTarget = @@ -1479,10 +1479,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(); @@ -1491,7 +1491,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(); m_currentPath->next(); @@ -1517,7 +1517,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 // 12 - 19 are the middle ring at 40 blocks from centre @@ -1607,7 +1607,7 @@ int EnderDragon::findClosestNode(double tX, double tY, double tZ) { startIndex = 12; } 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) { closestDist = dist; @@ -1621,14 +1621,14 @@ 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 */) { + Node* finalNode /* = nullptr */) { for (unsigned int i = 0; i < 24; ++i) { Node* n = m_nodes->data[i]; n->closed = false; n->f = 0; n->g = 0; n->h = 0; - n->cameFrom = NULL; + n->cameFrom = nullptr; n->heapIdx = -1; } @@ -1656,7 +1656,7 @@ Path* EnderDragon::findPath(int startIndex, int endIndex, 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; } @@ -1698,10 +1698,10 @@ Path* EnderDragon::findPath(int startIndex, int endIndex, } } - 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; } @@ -1712,7 +1712,7 @@ Path* EnderDragon::findPath(int startIndex, int endIndex, 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; } @@ -1720,7 +1720,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; } diff --git a/Minecraft.World/Entities/Mobs/EnderDragon.h b/Minecraft.World/Entities/Mobs/EnderDragon.h index 1e8479407..907ffe3fe 100644 --- a/Minecraft.World/Entities/Mobs/EnderDragon.h +++ b/Minecraft.World/Entities/Mobs/EnderDragon.h @@ -168,7 +168,7 @@ private: 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/Entities/Mobs/EnderMan.cpp b/Minecraft.World/Entities/Mobs/EnderMan.cpp index c83c478f5..d87427e23 100644 --- a/Minecraft.World/Entities/Mobs/EnderMan.cpp +++ b/Minecraft.World/Entities/Mobs/EnderMan.cpp @@ -92,7 +92,7 @@ std::shared_ptr EnderMan::findAttackTarget() { std::shared_ptr player = level->getNearestAttackablePlayer(shared_from_this(), 64); - if (player != NULL) { + if (player != nullptr) { if (isLookingAtMe(player)) { aggroedByPlayer = true; if (aggroTime == 0) @@ -112,7 +112,7 @@ std::shared_ptr EnderMan::findAttackTarget() { bool EnderMan::isLookingAtMe(std::shared_ptr player) { std::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(); @@ -137,7 +137,7 @@ void EnderMan::aiStep() { getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); speed->removeModifier(SPEED_MODIFIER_ATTACKING); - if (attackTarget != NULL) { + if (attackTarget != nullptr) { speed->addModifier( new AttributeModifier(*SPEED_MODIFIER_ATTACKING)); } @@ -212,12 +212,12 @@ 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( std::dynamic_pointer_cast(attackTarget))) { @@ -358,12 +358,12 @@ bool EnderMan::hurt(DamageSource* source, float damage) { if (isInvulnerable()) return false; setCreepy(true); - if (dynamic_cast(source) != NULL && + 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++) { if (teleport()) { diff --git a/Minecraft.World/Entities/Mobs/EntityHorse.cpp b/Minecraft.World/Entities/Mobs/EntityHorse.cpp index 2692045da..622b84f6d 100644 --- a/Minecraft.World/Entities/Mobs/EntityHorse.cpp +++ b/Minecraft.World/Entities/Mobs/EntityHorse.cpp @@ -225,7 +225,7 @@ int EntityHorse::getArmorType() { } int EntityHorse::getArmorTypeForItem(std::shared_ptr armorItem) { - if (armorItem == NULL) { + if (armorItem == nullptr) { return ARMOR_NONE; } if (armorItem->id == Item::horseArmorMetal_Id) { @@ -276,7 +276,7 @@ bool EntityHorse::hurt(DamageSource* damagesource, float dmg) { // 4J: Protect owned horses from untrusted players if (isTamed()) { std::shared_ptr entity = damagesource->getDirectEntity(); - if (entity != NULL && entity->instanceof(eTYPE_PLAYER)) { + if (entity != nullptr && entity->instanceof(eTYPE_PLAYER)) { std::shared_ptr attacker = std::dynamic_pointer_cast(entity); attacker->canHarmPlayer(getOwnerName()); @@ -284,7 +284,7 @@ bool EntityHorse::hurt(DamageSource* damagesource, float dmg) { } std::shared_ptr attacker = damagesource->getEntity(); - if (rider.lock() != NULL && (rider.lock() == (attacker))) { + if (rider.lock() != nullptr && (rider.lock() == (attacker))) { return false; } @@ -293,7 +293,7 @@ bool EntityHorse::hurt(DamageSource* damagesource, float dmg) { int EntityHorse::getArmorValue() { return ARMOR_PROTECTION[getArmorType()]; } -bool EntityHorse::isPushable() { return rider.lock() == NULL; } +bool EntityHorse::isPushable() { return rider.lock() == nullptr; } // TODO: [EB]: Explain why this is being done - what side effect does getBiome // have? @@ -337,7 +337,7 @@ void EntityHorse::causeFallDamage(float fallDistance) { hurt(DamageSource::fall, dmg); - if (rider.lock() != NULL) { + if (rider.lock() != nullptr) { rider.lock()->hurt(DamageSource::fall, dmg); } @@ -369,14 +369,14 @@ void EntityHorse::createInventory() { inventory = std::shared_ptr( new AnimalChest(L"HorseChest", getInventorySize())); inventory->setCustomName(getAName()); - if (old != NULL) { + if (old != nullptr) { old->removeListener(this); int max = std::min(old->getContainerSize(), inventory->getContainerSize()); for (int slot = 0; slot < max; slot++) { std::shared_ptr item = old->getItem(slot); - if (item != NULL) { + if (item != nullptr) { inventory->setItem(slot, item->copy()); } } @@ -388,7 +388,7 @@ void EntityHorse::createInventory() { void EntityHorse::updateEquipment() { if (!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))); @@ -538,7 +538,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) { playSound(eSoundType_MOB_HORSE_GALLOP, @@ -639,7 +639,7 @@ intArray EntityHorse::getLayeredTextureLayers() { void EntityHorse::openInventory(std::shared_ptr player) { if (!level->isClientSide && - (rider.lock() == NULL || rider.lock() == player) && isTamed()) { + (rider.lock() == nullptr || rider.lock() == player) && isTamed()) { inventory->setCustomName(getAName()); player->openHorseInventory( std::dynamic_pointer_cast(shared_from_this()), @@ -650,7 +650,7 @@ void EntityHorse::openInventory(std::shared_ptr player) { bool EntityHorse::mobInteract(std::shared_ptr player) { std::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); } @@ -665,12 +665,12 @@ bool EntityHorse::mobInteract(std::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; if (canWearArmor()) { @@ -754,7 +754,7 @@ bool EntityHorse::mobInteract(std::shared_ptr player) { } if (!isTamed() && !itemUsed) { - if (itemstack != NULL && + if (itemstack != nullptr && itemstack->interactEnemy( player, std::dynamic_pointer_cast( shared_from_this()))) { @@ -793,10 +793,10 @@ bool EntityHorse::mobInteract(std::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 && + if (itemstack != nullptr && itemstack->interactEnemy( player, std::dynamic_pointer_cast(shared_from_this()))) { @@ -846,7 +846,7 @@ bool EntityHorse::canWearBags() { } bool EntityHorse::isImmobile() { - if (rider.lock() != NULL && isSaddled()) { + if (rider.lock() != nullptr && isSaddled()) { return true; } return isEating() || isStanding(); @@ -904,7 +904,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) { setEating(true); @@ -919,7 +919,7 @@ void EntityHorse::aiStep() { if (isBred() && !isAdult() && !isEating()) { std::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); @@ -1012,12 +1012,12 @@ void EntityHorse::openMouth() { } bool EntityHorse::isReadyForParenting() { - return rider.lock() == NULL && riding == NULL && isTamed() && isAdult() && + 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() { return true; } @@ -1055,11 +1055,11 @@ void EntityHorse::dropMyStuff() { void EntityHorse::dropInventory(std::shared_ptr entity, std::shared_ptr animalchest) { - if (animalchest == NULL || level->isClientSide) return; + if (animalchest == nullptr || level->isClientSide) return; for (int i = 0; i < animalchest->getContainerSize(); i++) { std::shared_ptr itemstack = animalchest->getItem(i); - if (itemstack == NULL) { + if (itemstack == nullptr) { continue; } spawnAtLocation(itemstack, 0); @@ -1079,7 +1079,7 @@ bool EntityHorse::tameWithName(std::shared_ptr player) { 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; Animal::travel(xa, ya); @@ -1173,7 +1173,7 @@ void EntityHorse::addAdditonalSaveData(CompoundTag* tag) { for (int i = INV_BASE_COUNT; i < inventory->getContainerSize(); i++) { std::shared_ptr stack = inventory->getItem(i); - if (stack != NULL) { + if (stack != nullptr) { CompoundTag* compoundTag = new CompoundTag(); compoundTag->putByte(L"Slot", (uint8_t)i); @@ -1185,11 +1185,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"))); } @@ -1213,7 +1213,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag* tag) { /*AttributeInstance *oldSpeedAttribute = getAttributes()->getInstance(SharedMonsterAttributes::MOVEMENT_SPEED); - if (oldSpeedAttribute != NULL) + if (oldSpeedAttribute != nullptr) { getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(oldSpeedAttribute->getBaseValue() * 0.25f); @@ -1238,7 +1238,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag* tag) { if (tag->contains(L"ArmorItem")) { std::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); } } @@ -1246,7 +1246,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag* tag) { if (tag->contains(L"SaddleItem")) { std::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); } } else if (tag->getBoolean(L"Saddle")) { @@ -1350,7 +1350,7 @@ MobGroupData* EntityHorse::finalizeMobSpawn( int type = 0; int variant = 0; - if (dynamic_cast(groupData) != NULL) { + if (dynamic_cast(groupData) != nullptr) { type = ((HorseGroupData*)groupData)->horseType; variant = ((HorseGroupData*)groupData)->horseVariant & 0xff | (random->nextInt(MARKINGS) << 8); diff --git a/Minecraft.World/Entities/Mobs/ExperienceOrb.cpp b/Minecraft.World/Entities/Mobs/ExperienceOrb.cpp index fb7755f52..92f648e9b 100644 --- a/Minecraft.World/Entities/Mobs/ExperienceOrb.cpp +++ b/Minecraft.World/Entities/Mobs/ExperienceOrb.cpp @@ -92,7 +92,7 @@ void ExperienceOrb::tick() { // lagspikes if (followingTime < tickCount - SharedConstants::TICKS_PER_SECOND + (entityId % 100)) { - if (followingPlayer == NULL || + if (followingPlayer == nullptr || followingPlayer->distanceToSqr(shared_from_this()) > maxDist * maxDist) { followingPlayer = @@ -100,7 +100,7 @@ void ExperienceOrb::tick() { } followingTime = tickCount; } - if (followingPlayer != NULL) { + if (followingPlayer != nullptr) { double xdd = (followingPlayer->x - x) / maxDist; double ydd = (followingPlayer->y + followingPlayer->getHeadHeight() - y) / diff --git a/Minecraft.World/Entities/Mobs/Fireball.cpp b/Minecraft.World/Entities/Mobs/Fireball.cpp index 86ebfd150..ee658d163 100644 --- a/Minecraft.World/Entities/Mobs/Fireball.cpp +++ b/Minecraft.World/Entities/Mobs/Fireball.cpp @@ -114,9 +114,9 @@ Fireball::Fireball(Level* level, std::shared_ptr mob, double xa, 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) || + if ((owner != nullptr && owner->removed) || !level->hasChunkAt((int)x, (int)y, (int)z)) { app.DebugPrintf( "Fireball removed - owner is null or removed is true for " @@ -172,7 +172,7 @@ void Fireball::tick() { from = Vec3(x, y, z); to = Vec3(x + xd, y + yd, z + zd); - if (res != NULL) { + if (res != nullptr) { to = Vec3{res->pos.x, res->pos.y, res->pos.z}; } std::shared_ptr hitEntity = nullptr; @@ -190,7 +190,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) { hitEntity = e; @@ -200,13 +200,13 @@ 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); } delete res; @@ -300,7 +300,7 @@ bool Fireball::hurt(DamageSource* source, float damage) { if (isInvulnerable()) return false; markHurt(); - if (source->getEntity() != NULL) { + if (source->getEntity() != nullptr) { auto lookAngle = source->getEntity()->getLookAngle(); if (lookAngle.has_value()) { xd = lookAngle->x; diff --git a/Minecraft.World/Entities/Mobs/FishingHook.cpp b/Minecraft.World/Entities/Mobs/FishingHook.cpp index 617f363e8..63d6f3c88 100644 --- a/Minecraft.World/Entities/Mobs/FishingHook.cpp +++ b/Minecraft.World/Entities/Mobs/FishingHook.cpp @@ -162,7 +162,7 @@ void FishingHook::tick() { if (!level->isClientSide) { std::shared_ptr selectedItem = owner->getSelectedItem(); - if (owner->removed || !owner->isAlive() || selectedItem == NULL || + if (owner->removed || !owner->isAlive() || selectedItem == nullptr || selectedItem->getItem() != Item::fishingRod || distanceToSqr(owner) > 32 * 32) { remove(); @@ -170,7 +170,7 @@ void FishingHook::tick() { return; } - if (hookedIn != NULL) { + if (hookedIn != nullptr) { if (hookedIn->removed) hookedIn = nullptr; else { @@ -209,7 +209,7 @@ void FishingHook::tick() { from = Vec3(x, y, z); to = Vec3(x + xd, y + yd, z + zd); - if (res != NULL) { + if (res != nullptr) { to = Vec3(res->pos.x, res->pos.y, res->pos.z); } std::shared_ptr hitEntity = nullptr; @@ -225,7 +225,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) { hitEntity = e; @@ -235,13 +235,13 @@ void FishingHook::tick() { } } - if (hitEntity != NULL) { + if (hitEntity != nullptr) { delete res; res = new HitResult(hitEntity); } - if (res != NULL) { - if (res->entity != NULL) { + if (res != nullptr) { + 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 @@ -370,7 +370,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; double za = owner->z - z; @@ -412,5 +412,5 @@ int FishingHook::retrieve() { // 4J Stu - Brought forward from 1.4 void FishingHook::remove() { Entity::remove(); - if (owner != NULL) owner->fishing = nullptr; + if (owner != nullptr) owner->fishing = nullptr; } diff --git a/Minecraft.World/Entities/Mobs/Ghast.cpp b/Minecraft.World/Entities/Mobs/Ghast.cpp index 7808df292..eed316638 100644 --- a/Minecraft.World/Entities/Mobs/Ghast.cpp +++ b/Minecraft.World/Entities/Mobs/Ghast.cpp @@ -47,7 +47,7 @@ bool Ghast::isCharging() { return entityData->getByte(DATA_IS_CHARGING) != 0; } bool Ghast::hurt(DamageSource* source, float dmg) { if (isInvulnerable()) return false; if (source->getMsgId() == ChatPacket::e_ChatDeathFireball) { - if ((source->getEntity() != NULL) && + if ((source->getEntity() != nullptr) && source->getEntity()->instanceof(eTYPE_PLAYER)) { // reflected fireball, kill the ghast FlyingMob::hurt(source, 1000); @@ -106,16 +106,16 @@ 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 && + if (target != nullptr && target->distanceToSqr(shared_from_this()) < maxDist * maxDist) { double xdd = target->x - x; double ydd = diff --git a/Minecraft.World/Entities/Mobs/ItemFrame.cpp b/Minecraft.World/Entities/Mobs/ItemFrame.cpp index 66f173cd9..2485a3ab6 100644 --- a/Minecraft.World/Entities/Mobs/ItemFrame.cpp +++ b/Minecraft.World/Entities/Mobs/ItemFrame.cpp @@ -29,7 +29,7 @@ ItemFrame::ItemFrame(Level* level, int xTile, int yTile, int zTile, int dir) } void ItemFrame::defineSynchedData() { - getEntityData()->defineNULL(DATA_ITEM, NULL); + getEntityData()->defineNULL(DATA_ITEM, nullptr); getEntityData()->define(DATA_ROTATION, (uint8_t)0); } @@ -42,7 +42,7 @@ bool ItemFrame::shouldRenderAtSqrDistance(double distance) { void ItemFrame::dropItem(std::shared_ptr causedBy) { std::shared_ptr item = getItem(); - if (causedBy != NULL && causedBy->instanceof(eTYPE_PLAYER)) { + if (causedBy != nullptr && causedBy->instanceof(eTYPE_PLAYER)) { if (std::dynamic_pointer_cast(causedBy)->abilities.instabuild) { removeFramedMap(item); return; @@ -51,7 +51,7 @@ void ItemFrame::dropItem(std::shared_ptr causedBy) { spawnAtLocation( std::shared_ptr(new ItemInstance(Item::frame)), 0); - if ((item != NULL) && (random->nextFloat() < dropChance)) { + if ((item != nullptr) && (random->nextFloat() < dropChance)) { item = item->copy(); removeFramedMap(item); spawnAtLocation(item, 0); @@ -59,7 +59,7 @@ void ItemFrame::dropItem(std::shared_ptr causedBy) { } void ItemFrame::removeFramedMap(std::shared_ptr item) { - if (item == NULL) return; + if (item == nullptr) return; if (item->id == Item::map_Id) { std::shared_ptr mapItemSavedData = Item::map->getSavedData(item, level); @@ -74,7 +74,7 @@ std::shared_ptr ItemFrame::getItem() { } void ItemFrame::setItem(std::shared_ptr item) { - if (item != NULL) { + if (item != nullptr) { item = item->copy(); item->count = 1; @@ -92,7 +92,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", (uint8_t)getRotation()); tag->putFloat(L"ItemDropChance", dropChance); @@ -102,7 +102,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")); @@ -117,10 +117,10 @@ bool ItemFrame::interact(std::shared_ptr player) { return false; } - if (getItem() == NULL) { + if (getItem() == nullptr) { std::shared_ptr item = player->getCarriedItem(); - if (item != NULL) { + if (item != nullptr) { if (!level->isClientSide) // isClientSide) { setItem(item); diff --git a/Minecraft.World/Entities/Mobs/Minecart.cpp b/Minecraft.World/Entities/Mobs/Minecart.cpp index 7c6b1e24c..24c01246e 100644 --- a/Minecraft.World/Entities/Mobs/Minecart.cpp +++ b/Minecraft.World/Entities/Mobs/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""; // @@ -55,7 +55,7 @@ void Minecart::_init() { Minecart::Minecart(Level* level) : Entity(level) { _init(); - // soundUpdater = level != NULL ? level->makeSoundUpdater(this) : NULL; + // soundUpdater = level != nullptr ? level->makeSoundUpdater(this) : nullptr; } Minecart::~Minecart() {} @@ -100,10 +100,10 @@ AABB* Minecart::getCollideAgainstBox(std::shared_ptr entity) { if (entity->isPushable()) { return &entity->bb; } - return NULL; + return nullptr; } -AABB* Minecart::getCollideBox() { return NULL; } +AABB* Minecart::getCollideBox() { return nullptr; } bool Minecart::isPushable() { return true; } @@ -128,7 +128,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) { std::shared_ptr attacker = source->getDirectEntity(); if (attacker->instanceof(eTYPE_PLAYER) && @@ -147,10 +147,10 @@ bool Minecart::hurt(DamageSource* source, float hurtDamage) { // 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()) + if (rider.lock() != nullptr && rider.lock() == source->getEntity()) hurtDamage += 1; - bool creativePlayer = source->getEntity() != NULL && + bool creativePlayer = source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) && std::dynamic_pointer_cast(source->getEntity()) ->abilities.instabuild; @@ -158,7 +158,7 @@ bool Minecart::hurt(DamageSource* source, float hurtDamage) { 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()) { destroy(source); @@ -187,11 +187,11 @@ bool Minecart::isPickable() { return !removed; } 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++) { @@ -201,13 +201,13 @@ void Minecart::tick() { outOfWorld(); } - if (!level->isClientSide && dynamic_cast(level) != NULL) { + if (!level->isClientSide && dynamic_cast(level) != nullptr) { MinecraftServer* server = ((ServerLevel*)level)->getServer(); int waitTime = getPortalWaitTime(); if (isInsidePortal) { if (server->isNetherEnabled()) { - if (riding == NULL) { + if (riding == nullptr) { if (portalTime++ >= waitTime) { portalTime = waitTime; changingDimensionDelay = @@ -308,7 +308,7 @@ void Minecart::tick() { AABB grown = bb.grow(0.2, 0, 0.2); std::vector >* entities = level->getEntities(shared_from_this(), &grown); - if (entities != NULL && !entities->empty()) { + if (entities != nullptr && !entities->empty()) { AUTO_VAR(itEnd, entities->end()); for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) { std::shared_ptr e = (*it); // entities->at(i); @@ -328,7 +328,7 @@ void Minecart::tick() { } } - if (rider.lock() != NULL) { + if (rider.lock() != nullptr) { if (rider.lock()->removed) { if (rider.lock()->riding == shared_from_this()) { rider.lock()->riding = nullptr; @@ -407,7 +407,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, xd = pow * xD / dd; zd = pow * zD / dd; - if (rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY)) { + if (rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_LIVINGENTITY)) { std::shared_ptr living = std::dynamic_pointer_cast(rider.lock()); @@ -471,7 +471,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double xdd = xd; double zdd = zd; - if (rider.lock() != NULL) { + if (rider.lock() != nullptr) { xdd *= 0.75; zdd *= 0.75; } @@ -541,7 +541,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, } void Minecart::applyNaturalSlowdown() { - if (rider.lock() != NULL) { + if (rider.lock() != nullptr) { xd *= 0.997f; yd *= 0; zd *= 0.997f; @@ -680,7 +680,7 @@ void Minecart::addAdditonalSaveData(CompoundTag* tag) { if (hasCustomDisplay()) { tag->putBoolean(L"CustomDisplayTile", true); tag->putInt(L"DisplayTile", - getDisplayTile() == NULL ? 0 : getDisplayTile()->id); + getDisplayTile() == nullptr ? 0 : getDisplayTile()->id); tag->putInt(L"DisplayData", getDisplayData()); tag->putInt(L"DisplayOffset", getDisplayOffset()); } @@ -697,7 +697,7 @@ void Minecart::push(std::shared_ptr e) { 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()); } } @@ -747,7 +747,7 @@ void Minecart::push(std::shared_ptr e) { std::shared_ptr cart = std::dynamic_pointer_cast(e); - if (cart != NULL && cart->getType() == TYPE_FURNACE && + if (cart != nullptr && cart->getType() == TYPE_FURNACE && getType() != TYPE_FURNACE) { xd *= 0.2f; zd *= 0.2f; @@ -755,7 +755,7 @@ void Minecart::push(std::shared_ptr e) { e->xd *= 0.95f; e->zd *= 0.95f; m_bHasPushedCartThisTick = true; - } else if (cart != NULL && cart->getType() != TYPE_FURNACE && + } else if (cart != nullptr && cart->getType() != TYPE_FURNACE && getType() == TYPE_FURNACE) { e->xd *= 0.2f; e->zd *= 0.2f; @@ -843,10 +843,10 @@ int Minecart::getHurtDir() { return entityData->getInteger(DATA_ID_HURTDIR); } 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; } +Tile* Minecart::getDefaultDisplayTile() { return nullptr; } int Minecart::getDisplayData() { if (!hasCustomDisplay()) return getDefaultDisplayData(); @@ -870,7 +870,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/Entities/Mobs/MushroomCow.cpp b/Minecraft.World/Entities/Mobs/MushroomCow.cpp index 5ab441782..d4b2ab30d 100644 --- a/Minecraft.World/Entities/Mobs/MushroomCow.cpp +++ b/Minecraft.World/Entities/Mobs/MushroomCow.cpp @@ -20,7 +20,7 @@ MushroomCow::MushroomCow(Level* level) : Cow(level) { bool MushroomCow::mobInteract(std::shared_ptr player) { std::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) { player->inventory->setItem( player->inventory->selected, @@ -37,7 +37,7 @@ bool MushroomCow::mobInteract(std::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 && + 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, diff --git a/Minecraft.World/Entities/Mobs/Ocelot.cpp b/Minecraft.World/Entities/Mobs/Ocelot.cpp index ea104f5e5..53dfbd5a8 100644 --- a/Minecraft.World/Entities/Mobs/Ocelot.cpp +++ b/Minecraft.World/Entities/Mobs/Ocelot.cpp @@ -160,7 +160,7 @@ bool Ocelot::mobInteract(std::shared_ptr player) { } } } else { - if (temptGoal->isRunning() && item != NULL && + 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 @@ -215,7 +215,7 @@ std::shared_ptr Ocelot::getBreedOffspring( } bool Ocelot::isFood(std::shared_ptr itemInstance) { - return itemInstance != NULL && itemInstance->id == Item::fish_raw_Id; + return itemInstance != nullptr && itemInstance->id == Item::fish_raw_Id; } bool Ocelot::canMate(std::shared_ptr animal) { @@ -223,7 +223,7 @@ bool Ocelot::canMate(std::shared_ptr animal) { if (!isTame()) return false; std::shared_ptr partner = std::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/Entities/Mobs/Painting.cpp b/Minecraft.World/Entities/Mobs/Painting.cpp index c244eaee5..534a1169f 100644 --- a/Minecraft.World/Entities/Mobs/Painting.cpp +++ b/Minecraft.World/Entities/Mobs/Painting.cpp @@ -51,7 +51,7 @@ const int Painting::Motive::MAX_MOTIVE_NAME_LENGTH = 13; // JAVA: "SkullAndRoses".length(); // 4J - added for common ctor code -void Painting::_init(Level* level) { motive = NULL; }; +void Painting::_init(Level* level) { motive = nullptr; }; Painting::Painting(Level* level) : HangingEntity(level) { // 4J Stu - This function call had to be moved here from the Entity ctor to @@ -124,7 +124,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); } @@ -134,7 +134,7 @@ int Painting::getWidth() { return motive->w; } int Painting::getHeight() { return motive->h; } void Painting::dropItem(std::shared_ptr causedBy) { - if ((causedBy != NULL) && causedBy->instanceof(eTYPE_PLAYER)) { + if ((causedBy != nullptr) && causedBy->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(causedBy); if (player->abilities.instabuild) { diff --git a/Minecraft.World/Entities/Mobs/Pig.cpp b/Minecraft.World/Entities/Mobs/Pig.cpp index 70b9c2090..5300ff040 100644 --- a/Minecraft.World/Entities/Mobs/Pig.cpp +++ b/Minecraft.World/Entities/Mobs/Pig.cpp @@ -56,7 +56,7 @@ bool Pig::canBeControlledByRider() { std::shared_ptr item = std::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() { @@ -87,7 +87,7 @@ void Pig::playStepSound(int xt, int yt, int zt, int t) { bool Pig::mobInteract(std::shared_ptr player) { if (!Animal::mobInteract(player)) { if (hasSaddle() && !level->isClientSide && - (rider.lock() == NULL || rider.lock() == player)) { + (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()); @@ -137,7 +137,7 @@ void Pig::thunderHit(const LightningBolt* lightningBolt) { void Pig::causeFallDamage(float distance) { Animal::causeFallDamage(distance); - if ((distance > 5) && rider.lock() != NULL && + if ((distance > 5) && rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_PLAYER)) { (std::dynamic_pointer_cast(rider.lock())) ->awardStat(GenericStats::flyPig(), GenericStats::param_flyPig()); @@ -155,7 +155,7 @@ std::shared_ptr Pig::getBreedOffspring( } bool Pig::isFood(std::shared_ptr itemInstance) { - return itemInstance != NULL && itemInstance->id == Item::carrots_Id; + return itemInstance != nullptr && itemInstance->id == Item::carrots_Id; } ControlledByPlayerGoal* Pig::getControlGoal() { return controlGoal; } diff --git a/Minecraft.World/Entities/Mobs/PigZombie.cpp b/Minecraft.World/Entities/Mobs/PigZombie.cpp index f88d30044..4b6b8c59e 100644 --- a/Minecraft.World/Entities/Mobs/PigZombie.cpp +++ b/Minecraft.World/Entities/Mobs/PigZombie.cpp @@ -49,7 +49,7 @@ void PigZombie::tick() { getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); speed->removeModifier(SPEED_MODIFIER_ATTACKING); - if (attackTarget != NULL) { + if (attackTarget != nullptr) { speed->addModifier( new AttributeModifier(*SPEED_MODIFIER_ATTACKING)); } @@ -99,7 +99,7 @@ std::shared_ptr PigZombie::findAttackTarget() { bool PigZombie::hurt(DamageSource* source, float dmg) { std::shared_ptr sourceEntity = source->getEntity(); - if (sourceEntity != NULL && sourceEntity->instanceof(eTYPE_PLAYER)) { + if (sourceEntity != nullptr && sourceEntity->instanceof(eTYPE_PLAYER)) { AABB grown = bb.grow(32, 32, 32); std::vector >* nearby = level->getEntities(shared_from_this(), &grown); diff --git a/Minecraft.World/Entities/Mobs/SharedMonsterAttributes.cpp b/Minecraft.World/Entities/Mobs/SharedMonsterAttributes.cpp index 426862dd5..8e6357319 100644 --- a/Minecraft.World/Entities/Mobs/SharedMonsterAttributes.cpp +++ b/Minecraft.World/Entities/Mobs/SharedMonsterAttributes.cpp @@ -78,7 +78,7 @@ void SharedMonsterAttributes::loadAttributes(BaseAttributeMap* attributes, AttributeInstance* instance = attributes->getInstance( static_cast(tag->getInt(L"ID"))); - if (instance != NULL) { + if (instance != nullptr) { loadAttribute(instance, tag); } else { app.DebugPrintf("Ignoring unknown attribute '%d'", @@ -98,7 +98,7 @@ void SharedMonsterAttributes::loadAttribute(AttributeInstance* instance, for (int i = 0; i < list->size(); i++) { 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/Entities/Mobs/Sheep.cpp b/Minecraft.World/Entities/Mobs/Sheep.cpp index 730bfe04a..75c3216bc 100644 --- a/Minecraft.World/Entities/Mobs/Sheep.cpp +++ b/Minecraft.World/Entities/Mobs/Sheep.cpp @@ -151,7 +151,7 @@ bool Sheep::mobInteract(std::shared_ptr player) { if (!player->isAllowedToInteract(shared_from_this())) return false; // Animal::interact(player); - if (item != NULL && item->id == Item::shears->id && !isSheared() && + if (item != nullptr && item->id == Item::shears->id && !isSheared() && !isBaby()) { if (!level->isClientSide) { setSheared(true); @@ -281,7 +281,7 @@ int Sheep::getOffspringColor(std::shared_ptr animal, 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(); } else { color = diff --git a/Minecraft.World/Entities/Mobs/Silverfish.cpp b/Minecraft.World/Entities/Mobs/Silverfish.cpp index ec0e014da..b99fa8c5e 100644 --- a/Minecraft.World/Entities/Mobs/Silverfish.cpp +++ b/Minecraft.World/Entities/Mobs/Silverfish.cpp @@ -59,7 +59,7 @@ int Silverfish::getDeathSound() { bool Silverfish::hurt(DamageSource* source, float dmg) { if (isInvulnerable()) return false; if (lookForFriends <= 0 && - (dynamic_cast(source) != NULL || + (dynamic_cast(source) != nullptr || source == DamageSource::magic)) { // look for friends lookForFriends = 20; @@ -149,7 +149,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 int tileX = Mth::floor(x), tileY = Mth::floor(y + .5f), @@ -170,7 +170,7 @@ void Silverfish::serverAiStep() { findRandomStrollLocation(); } - } else if (attackTarget != NULL && !isPathFinding()) { + } else if (attackTarget != nullptr && !isPathFinding()) { attackTarget = nullptr; } } @@ -187,7 +187,7 @@ bool Silverfish::canSpawn() { if (Monster::canSpawn()) { std::shared_ptr nearestPlayer = level->getNearestPlayer(shared_from_this(), 5.0); - return nearestPlayer == NULL; + return nearestPlayer == nullptr; } return false; } diff --git a/Minecraft.World/Entities/Mobs/Skeleton.cpp b/Minecraft.World/Entities/Mobs/Skeleton.cpp index 51c3b7e48..ac8cb3b03 100644 --- a/Minecraft.World/Entities/Mobs/Skeleton.cpp +++ b/Minecraft.World/Entities/Mobs/Skeleton.cpp @@ -45,7 +45,7 @@ Skeleton::Skeleton(Level* level) : Monster(level) { targetSelector.addGoal( 2, new NearestAttackableTargetGoal(this, typeid(Player), 0, true)); - if (level != NULL && !level->isClientSide) reassessWeaponGoal(); + if (level != nullptr && !level->isClientSide) reassessWeaponGoal(); } Skeleton::~Skeleton() { @@ -101,7 +101,7 @@ void Skeleton::aiStep() { bool burn = true; std::shared_ptr helmet = getCarried(SLOT_HELM); - if (helmet != NULL) { + if (helmet != nullptr) { if (helmet->isDamageableItem()) { helmet->setAuxValue(helmet->getDamageValue() + random->nextInt(2)); @@ -131,7 +131,7 @@ void Skeleton::aiStep() { void Skeleton::rideTick() { Monster::rideTick(); - if (riding != NULL && riding->instanceof(eTYPE_PATHFINDER_MOB)) { + if (riding != nullptr && riding->instanceof(eTYPE_PATHFINDER_MOB)) { yBodyRot = std::dynamic_pointer_cast(riding)->yBodyRot; } } @@ -139,9 +139,9 @@ void Skeleton::rideTick() { void Skeleton::die(DamageSource* source) { Monster::die(source); - if (source->getDirectEntity() != NULL && + if (source->getDirectEntity() != nullptr && source->getDirectEntity()->instanceof(eTYPE_ARROW) && - source->getEntity() != NULL && + source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(source->getEntity()); @@ -199,7 +199,7 @@ MobGroupData* Skeleton::finalizeMobSpawn( { groupData = Monster::finalizeMobSpawn(groupData); - if (dynamic_cast(level->dimension) != NULL && + if (dynamic_cast(level->dimension) != nullptr && getRandom()->nextInt(5) > 0) { goalSelector.addGoal(4, meleeGoal, false); @@ -217,7 +217,7 @@ MobGroupData* Skeleton::finalizeMobSpawn( 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) { // Halloween! OooOOo! 25% of all skeletons/zombies can wear pumpkins @@ -238,7 +238,7 @@ void Skeleton::reassessWeaponGoal() { std::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); } else { goalSelector.addGoal(4, meleeGoal, false); diff --git a/Minecraft.World/Entities/Mobs/Slime.cpp b/Minecraft.World/Entities/Mobs/Slime.cpp index de4816ea7..35d8d96cd 100644 --- a/Minecraft.World/Entities/Mobs/Slime.cpp +++ b/Minecraft.World/Entities/Mobs/Slime.cpp @@ -119,12 +119,12 @@ void Slime::serverAiStep() { checkDespawn(); std::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; } jumping = true; diff --git a/Minecraft.World/Entities/Mobs/SmallFireball.cpp b/Minecraft.World/Entities/Mobs/SmallFireball.cpp index 139b1de69..e20063a8f 100644 --- a/Minecraft.World/Entities/Mobs/SmallFireball.cpp +++ b/Minecraft.World/Entities/Mobs/SmallFireball.cpp @@ -24,7 +24,7 @@ SmallFireball::SmallFireball(Level* level, double x, double y, double z, void SmallFireball::onHit(HitResult* res) { if (!level->isClientSide) { - if (res->entity != NULL) { + if (res->entity != nullptr) { DamageSource* damageSource = DamageSource::fireball( std::dynamic_pointer_cast(shared_from_this()), owner); if (!res->entity->isFireImmune() && diff --git a/Minecraft.World/Entities/Mobs/Snowball.cpp b/Minecraft.World/Entities/Mobs/Snowball.cpp index 5c64cc1a5..81df4ebdc 100644 --- a/Minecraft.World/Entities/Mobs/Snowball.cpp +++ b/Minecraft.World/Entities/Mobs/Snowball.cpp @@ -24,7 +24,7 @@ Snowball::Snowball(Level* level, double x, double y, double z) } void Snowball::onHit(HitResult* res) { - if (res->entity != NULL) { + if (res->entity != nullptr) { int damage = 0; if (res->entity->instanceof(eTYPE_BLAZE)) { damage = 3; diff --git a/Minecraft.World/Entities/Mobs/Spider.cpp b/Minecraft.World/Entities/Mobs/Spider.cpp index 085eb2d49..8cef7de42 100644 --- a/Minecraft.World/Entities/Mobs/Spider.cpp +++ b/Minecraft.World/Entities/Mobs/Spider.cpp @@ -155,12 +155,12 @@ MobGroupData* Spider::finalizeMobSpawn( std::shared_ptr skeleton = std::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(); if (level->difficulty > Difficulty::NORMAL && @@ -170,9 +170,9 @@ MobGroupData* Spider::finalizeMobSpawn( ->setRandomEffect(level->random); } } - if (dynamic_cast(groupData) != NULL) { + if (dynamic_cast(groupData) != nullptr) { int effect = ((SpiderEffectsGroupData*)groupData)->effectId; - if (effect > 0 && MobEffect::effects[effect] != NULL) { + if (effect > 0 && MobEffect::effects[effect] != nullptr) { addEffect( new MobEffectInstance(effect, std::numeric_limits::max())); } diff --git a/Minecraft.World/Entities/Mobs/ThrownEgg.cpp b/Minecraft.World/Entities/Mobs/ThrownEgg.cpp index 0850e2705..a85425169 100644 --- a/Minecraft.World/Entities/Mobs/ThrownEgg.cpp +++ b/Minecraft.World/Entities/Mobs/ThrownEgg.cpp @@ -26,7 +26,7 @@ ThrownEgg::ThrownEgg(Level* level, double x, double y, double z) } 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/Entities/Mobs/ThrownEnderPearl.cpp b/Minecraft.World/Entities/Mobs/ThrownEnderPearl.cpp index 1c5c0eb0a..e7cfe2adf 100644 --- a/Minecraft.World/Entities/Mobs/ThrownEnderPearl.cpp +++ b/Minecraft.World/Entities/Mobs/ThrownEnderPearl.cpp @@ -29,7 +29,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); @@ -48,7 +48,7 @@ void ThrownEnderpearl::onHit(HitResult* res) { // the ground. If the owner has been removed, then ignore // 4J-JEV: Cheap type check first. - if ((getOwner() != NULL) && + if ((getOwner() != nullptr) && getOwner()->instanceof(eTYPE_SERVERPLAYER)) { std::shared_ptr serverPlayer = std::dynamic_pointer_cast(getOwner()); diff --git a/Minecraft.World/Entities/Mobs/ThrownPotion.cpp b/Minecraft.World/Entities/Mobs/ThrownPotion.cpp index 71020e479..0cd3086dc 100644 --- a/Minecraft.World/Entities/Mobs/ThrownPotion.cpp +++ b/Minecraft.World/Entities/Mobs/ThrownPotion.cpp @@ -63,14 +63,14 @@ float ThrownPotion::getThrowPower() { return 0.5f; } float ThrownPotion::getThrowUpAngleOffset() { return -20; } void ThrownPotion::setPotionValue(int potionValue) { - if (potionItem == NULL) + if (potionItem == nullptr) potionItem = std::shared_ptr(new ItemInstance(Item::potion, 1, 0)); potionItem->setAuxValue(potionValue); } int ThrownPotion::getPotionValue() { - if (potionItem == NULL) + if (potionItem == nullptr) potionItem = std::shared_ptr(new ItemInstance(Item::potion, 1, 0)); return potionItem->getAuxValue(); @@ -81,12 +81,12 @@ void ThrownPotion::onHit(HitResult* res) { std::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); std::vector >* entitiesOfClass = level->getEntitiesOfClass(typeid(LivingEntity), &aoe); - if (entitiesOfClass != NULL && !entitiesOfClass->empty()) { + if (entitiesOfClass != nullptr && !entitiesOfClass->empty()) { // for (Entity e : entitiesOfClass) for (AUTO_VAR(it, entitiesOfClass->begin()); it != entitiesOfClass->end(); ++it) { @@ -143,12 +143,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) + if (potionItem != nullptr) tag->putCompound(L"Potion", potionItem->save(new CompoundTag())); } diff --git a/Minecraft.World/Entities/Mobs/Villager.cpp b/Minecraft.World/Entities/Mobs/Villager.cpp index 0c790add7..352212cdd 100644 --- a/Minecraft.World/Entities/Mobs/Villager.cpp +++ b/Minecraft.World/Entities/Mobs/Villager.cpp @@ -53,7 +53,7 @@ void Villager::_init(int profession) { village = std::weak_ptr(); tradingPlayer = std::weak_ptr(); - offers = NULL; + offers = nullptr; updateMerchantTimer = 0; addRecipeOnUpdate = false; riches = 0; @@ -107,7 +107,7 @@ void Villager::serverAiMobStep() { std::shared_ptr _village = level->villages->getClosestVillage( Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist); village = _village; - if (_village == NULL) + if (_village == nullptr) clearRestriction(); else { Pos* center = _village->getCenter(); @@ -139,7 +139,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); @@ -157,7 +157,7 @@ void Villager::serverAiMobStep() { bool Villager::mobInteract(std::shared_ptr player) { // [EB]: Truly dislike this code but I don't see another easy way std::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()) { if (!level->isClientSide) { @@ -183,7 +183,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()); } } @@ -231,7 +231,7 @@ bool Villager::isChasing() { return chasing; } void Villager::setLastHurtByMob(std::shared_ptr mob) { AgableMob::setLastHurtByMob(mob); std::shared_ptr _village = village.lock(); - if (_village != NULL && mob != NULL) { + if (_village != nullptr && mob != nullptr) { _village->addAggressor(mob); if (mob->instanceof (eTYPE_PLAYER)) { @@ -251,9 +251,9 @@ void Villager::setLastHurtByMob(std::shared_ptr mob) { void Villager::die(DamageSource* source) { std::shared_ptr _village = village.lock(); - if (_village != NULL) { + if (_village != nullptr) { std::shared_ptr sourceEntity = source->getEntity(); - if (sourceEntity != NULL) { + if (sourceEntity != nullptr) { if (sourceEntity->instanceof (eTYPE_PLAYER)) { _village->modifyStanding( std::dynamic_pointer_cast(sourceEntity)->getName(), @@ -261,12 +261,12 @@ void Villager::die(DamageSource* source) { } else if (sourceEntity->instanceof (eTYPE_ENEMY)) { _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 std::shared_ptr nearestPlayer = level->getNearestPlayer(shared_from_this(), 16.0f); - if (nearestPlayer != NULL) { + if (nearestPlayer != nullptr) { _village->resetNoBreedTimer(); } } @@ -283,7 +283,7 @@ std::shared_ptr Villager::getTradingPlayer() { return tradingPlayer.lock(); } -bool Villager::isTrading() { return tradingPlayer.lock() != NULL; } +bool Villager::isTrading() { return tradingPlayer.lock() != nullptr; } void Villager::notifyTrade(MerchantRecipe* activeRecipe) { activeRecipe->increaseUses(); @@ -295,7 +295,7 @@ void Villager::notifyTrade(MerchantRecipe* activeRecipe) { if (activeRecipe->isSame(offers->at(offers->size() - 1))) { updateMerchantTimer = SharedConstants::TICKS_PER_SECOND * 2; addRecipeOnUpdate = true; - if (tradingPlayer.lock() != NULL) { + if (tradingPlayer.lock() != nullptr) { lastPlayerTradeName = tradingPlayer.lock()->getName(); } else { lastPlayerTradeName = L""; @@ -312,7 +312,7 @@ void Villager::notifyTradeUpdated(std::shared_ptr item) { (ambientSoundTime > (-getAmbientSoundInterval() + SharedConstants::TICKS_PER_SECOND))) { ambientSoundTime = -getAmbientSoundInterval(); - if (item != NULL) { + if (item != nullptr) { playSound(eSoundType_MOB_VILLAGER_YES, getSoundVolume(), getVoicePitch()); } else { @@ -323,7 +323,7 @@ void Villager::notifyTradeUpdated(std::shared_ptr item) { } MerchantRecipeList* Villager::getOffers(std::shared_ptr forPlayer) { - if (offers == NULL) { + if (offers == nullptr) { addOffers(1); } return offers; @@ -528,7 +528,7 @@ void Villager::addOffers(int addCount) { std::shuffle(newOffers->begin(), newOffers->end(), VillagerShuffleRandom(random)); - if (offers == NULL) { + if (offers == nullptr) { offers = new MerchantRecipeList(); } for (int i = 0; i < addCount && i < newOffers->size(); i++) { @@ -730,7 +730,7 @@ std::shared_ptr Villager::getBreedOffspring( if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) { std::shared_ptr villager = std::shared_ptr(new Villager(level)); - villager->finalizeMobSpawn(NULL); + villager->finalizeMobSpawn(nullptr); return villager; } else { return nullptr; diff --git a/Minecraft.World/Entities/Mobs/VillagerGolem.cpp b/Minecraft.World/Entities/Mobs/VillagerGolem.cpp index a9811005d..9cb942151 100644 --- a/Minecraft.World/Entities/Mobs/VillagerGolem.cpp +++ b/Minecraft.World/Entities/Mobs/VillagerGolem.cpp @@ -64,7 +64,7 @@ void VillagerGolem::serverAiMobStep() { std::shared_ptr _village = level->villages->getClosestVillage( Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist); village = _village; - if (_village == NULL) + if (_village == nullptr) clearRestriction(); else { Pos* center = _village->getCenter(); @@ -207,8 +207,8 @@ 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); } Golem::die(source); @@ -218,7 +218,7 @@ bool VillagerGolem::hurt(DamageSource* source, float dmg) { // 4J: Protect owned golem from untrusted players if (isPlayerCreated()) { std::shared_ptr entity = source->getDirectEntity(); - if (entity != NULL && entity->instanceof(eTYPE_PLAYER)) { + if (entity != nullptr && entity->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(entity); if (!player->isAllowedToAttackPlayers()) return false; diff --git a/Minecraft.World/Entities/Mobs/Witch.cpp b/Minecraft.World/Entities/Mobs/Witch.cpp index f8e970389..9840bdfbb 100644 --- a/Minecraft.World/Entities/Mobs/Witch.cpp +++ b/Minecraft.World/Entities/Mobs/Witch.cpp @@ -89,10 +89,10 @@ void Witch::aiStep() { std::shared_ptr item = getCarriedItem(); setEquippedSlot(SLOT_WEAPON, nullptr); - if (item != NULL && item->id == Item::potion_Id) { + if (item != nullptr && item->id == Item::potion_Id) { std::vector* effects = Item::potion->getMobEffects(item); - if (effects != NULL) { + if (effects != nullptr) { for (AUTO_VAR(it, effects->begin()); it != effects->end(); ++it) { addEffect(new MobEffectInstance(*it)); @@ -113,12 +113,12 @@ void Witch::aiStep() { } else if (random->nextFloat() < 0.05f && getHealth() < getMaxHealth()) { potion = PotionBrewing::POTION_ID_HEAL; - } else if (random->nextFloat() < 0.25f && getTarget() != NULL && + } 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 && + } else if (random->nextFloat() < 0.25f && getTarget() != nullptr && !hasEffect(MobEffect::movementSpeed) && getTarget()->distanceToSqr(shared_from_this()) > 11 * 11) { diff --git a/Minecraft.World/Entities/Mobs/WitherBoss.cpp b/Minecraft.World/Entities/Mobs/WitherBoss.cpp index 1263662d9..01822a75a 100644 --- a/Minecraft.World/Entities/Mobs/WitherBoss.cpp +++ b/Minecraft.World/Entities/Mobs/WitherBoss.cpp @@ -112,7 +112,7 @@ void WitherBoss::aiStep() { if (!level->isClientSide && getAlternativeTarget(0) > 0) { std::shared_ptr e = level->getEntity(getAlternativeTarget(0)); - if (e != NULL) { + if (e != nullptr) { if ((y < e->y) || (!isPowered() && y < (e->y + 5))) { if (yd < 0) { yd = 0; @@ -146,7 +146,7 @@ void WitherBoss::aiStep() { if (entityId > 0) { e = level->getEntity(entityId); } - if (e != NULL) { + if (e != nullptr) { double hx = getHeadX(i + 1); double hy = getHeadY(i + 1); double hz = getHeadZ(i + 1); @@ -237,7 +237,7 @@ void WitherBoss::newServerAiStep() { // 4J: Added check for instance of living entity, had a problem // with IDs being recycled to other entities - if (current == NULL || + if (current == nullptr || !current->instanceof(eTYPE_LIVINGENTITY) || !current->isAlive() || distanceToSqr(current) > 30 * 30 || !canSee(current)) { @@ -287,7 +287,7 @@ void WitherBoss::newServerAiStep() { } } } - if (getTarget() != NULL) { + if (getTarget() != nullptr) { assert(getTarget()->instanceof(eTYPE_LIVINGENTITY)); setAlternativeTarget(0, getTarget()->entityId); } else { @@ -426,13 +426,13 @@ bool WitherBoss::hurt(DamageSource* source, float dmg) { if (isPowered()) { std::shared_ptr directEntity = source->getDirectEntity(); - if (directEntity != NULL && directEntity->GetType() == eTYPE_ARROW) { + if (directEntity != nullptr && directEntity->GetType() == eTYPE_ARROW) { return false; } } std::shared_ptr sourceEntity = source->getEntity(); - if (sourceEntity != NULL) { + if (sourceEntity != nullptr) { if (sourceEntity->instanceof(eTYPE_PLAYER)) { } else if (sourceEntity->instanceof(eTYPE_LIVINGENTITY) && std::dynamic_pointer_cast(sourceEntity) diff --git a/Minecraft.World/Entities/Mobs/Wolf.cpp b/Minecraft.World/Entities/Mobs/Wolf.cpp index bccbe462e..db23fd439 100644 --- a/Minecraft.World/Entities/Mobs/Wolf.cpp +++ b/Minecraft.World/Entities/Mobs/Wolf.cpp @@ -73,7 +73,7 @@ bool Wolf::useNewAi() { return true; } void Wolf::setTarget(std::shared_ptr target) { TamableAnimal::setTarget(target); - if (target == NULL) { + if (target == nullptr) { setAngry(false); } else if (!isTame()) { setAngry(true); @@ -232,7 +232,7 @@ bool Wolf::hurt(DamageSource* source, float dmg) { // 4J: Protect owned wolves from untrusted players if (isTame()) { std::shared_ptr entity = source->getDirectEntity(); - if (entity != NULL && entity->instanceof(eTYPE_PLAYER)) { + if (entity != nullptr && entity->instanceof(eTYPE_PLAYER)) { std::shared_ptr attacker = std::dynamic_pointer_cast(entity); attacker->canHarmPlayer(getOwnerUUID()); @@ -242,7 +242,7 @@ bool Wolf::hurt(DamageSource* source, float dmg) { if (isInvulnerable()) return false; std::shared_ptr sourceEntity = source->getEntity(); sitGoal->wantToSit(false); - if (sourceEntity != NULL && !(sourceEntity->instanceof(eTYPE_PLAYER) || + if (sourceEntity != nullptr && !(sourceEntity->instanceof(eTYPE_PLAYER) || sourceEntity->instanceof(eTYPE_ARROW))) { // Take half damage from non-players and arrows dmg = (dmg + 1) / 2; @@ -272,7 +272,7 @@ void Wolf::setTame(bool value) { void Wolf::tame(const std::wstring& wsOwnerUUID, bool bDisplayTamingParticles, bool bSetSitting) { setTame(true); - setPath(NULL); + setPath(nullptr); setTarget(nullptr); sitGoal->wantToSit(bSetSitting); setHealth(TAME_HEALTH); @@ -287,8 +287,8 @@ bool Wolf::mobInteract(std::shared_ptr player) { std::shared_ptr item = player->inventory->getSelected(); if (isTame()) { - if (item != NULL) { - if (dynamic_cast(Item::items[item->id]) != NULL) { + if (item != nullptr) { + if (dynamic_cast(Item::items[item->id]) != nullptr) { FoodItem* food = dynamic_cast(Item::items[item->id]); if (food->isMeat() && @@ -323,13 +323,13 @@ bool Wolf::mobInteract(std::shared_ptr player) { if (!level->isClientSide && !isFood(item)) { sitGoal->wantToSit(!isSitting()); jumping = false; - setPath(NULL); + setPath(nullptr); setAttackTarget(nullptr); setTarget(nullptr); } } } 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) { item->count--; @@ -363,7 +363,7 @@ bool Wolf::mobInteract(std::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; } } @@ -392,8 +392,8 @@ float Wolf::getTailAngle() { } bool Wolf::isFood(std::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 ((FoodItem*)Item::items[item->id])->isMeat(); } @@ -461,7 +461,7 @@ bool Wolf::canMate(std::shared_ptr animal) { if (!animal->instanceof(eTYPE_WOLF)) return false; std::shared_ptr partner = std::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/Entities/Mobs/Zombie.cpp b/Minecraft.World/Entities/Mobs/Zombie.cpp index c67e1ccfd..3fbd91058 100644 --- a/Minecraft.World/Entities/Mobs/Zombie.cpp +++ b/Minecraft.World/Entities/Mobs/Zombie.cpp @@ -93,7 +93,7 @@ bool Zombie::isBaby() { void Zombie::setBaby(bool baby) { getEntityData()->set(DATA_BABY_ID, (uint8_t)(baby ? 1 : 0)); - if (level != NULL && !level->isClientSide) { + if (level != nullptr && !level->isClientSide) { AttributeInstance* speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); speed->removeModifier(SPEED_MODIFIER_BABY); @@ -120,7 +120,7 @@ void Zombie::aiStep() { bool burn = true; std::shared_ptr helmet = getCarried(SLOT_HELM); - if (helmet != NULL) { + if (helmet != nullptr) { if (helmet->isDamageableItem()) { helmet->setAuxValue(helmet->getDamageValue() + random->nextInt(2)); @@ -144,15 +144,15 @@ void Zombie::aiStep() { bool Zombie::hurt(DamageSource* source, float dmg) { if (Monster::hurt(source, dmg)) { std::shared_ptr target = getTarget(); - if ((target == NULL) && getAttackTarget() != NULL && + if ((target == nullptr) && getAttackTarget() != nullptr && getAttackTarget()->instanceof(eTYPE_LIVINGENTITY)) target = std::dynamic_pointer_cast(getAttackTarget()); - if ((target == NULL) && source->getEntity() != NULL && + if ((target == nullptr) && source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_LIVINGENTITY)) target = std::dynamic_pointer_cast(source->getEntity()); - if ((target != NULL) && level->difficulty >= Difficulty::HARD && + if ((target != nullptr) && level->difficulty >= Difficulty::HARD && random->nextFloat() < getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->getValue()) { int x = Mth::floor(this->x); @@ -182,7 +182,7 @@ bool Zombie::hurt(DamageSource* source, float dmg) { !level->containsAnyLiquid(&reinforcement->bb)) { level->addEntity(reinforcement); reinforcement->setTarget(target); - reinforcement->finalizeMobSpawn(NULL); + reinforcement->finalizeMobSpawn(nullptr); getAttribute(SPAWN_REINFORCEMENTS_CHANCE) ->addModifier(new AttributeModifier( @@ -220,7 +220,7 @@ bool Zombie::doHurtTarget(std::shared_ptr target) { bool result = Monster::doHurtTarget(target); if (result) { - if (getCarriedItem() == NULL && isOnFire() && + if (getCarriedItem() == nullptr && isOnFire() && random->nextFloat() < level->difficulty * 0.3f) { target->setOnFire(2 * level->difficulty); } @@ -308,7 +308,7 @@ void Zombie::killed(std::shared_ptr mob) { std::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); @@ -326,12 +326,12 @@ MobGroupData* Zombie::finalizeMobSpawn( 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 = (ZombieGroupData*)groupData; if (zombieData->isVillager) { @@ -346,7 +346,7 @@ MobGroupData* Zombie::finalizeMobSpawn( 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? if (Calendar::GetMonth() + 1 == 10 && Calendar::GetDayOfMonth() == 31 && @@ -389,7 +389,7 @@ MobGroupData* Zombie::finalizeMobSpawn( bool Zombie::mobInteract(std::shared_ptr player) { std::shared_ptr item = player->getSelectedItem(); - if (item != NULL && item->getItem() == Item::apple_gold && + if (item != nullptr && item->getItem() == Item::apple_gold && item->getAuxValue() == 0 && isVillager() && hasEffect(MobEffect::weakness)) { if (!player->abilities.instabuild) item->count--; @@ -446,7 +446,7 @@ void Zombie::finishConversion() { std::shared_ptr villager = std::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/Entities/Monster.cpp b/Minecraft.World/Entities/Monster.cpp index a0e98c5d5..8cccb5c9e 100644 --- a/Minecraft.World/Entities/Monster.cpp +++ b/Minecraft.World/Entities/Monster.cpp @@ -42,7 +42,7 @@ std::shared_ptr Monster::findAttackTarget() { std::shared_ptr player = level->getNearestAttackablePlayer(shared_from_this(), 16); - if (player != NULL && canSee(player)) return player; + if (player != nullptr && canSee(player)) return player; return std::shared_ptr(); } diff --git a/Minecraft.World/Entities/Monster.h b/Minecraft.World/Entities/Monster.h index 0e8d5baa9..8b83b2c59 100644 --- a/Minecraft.World/Entities/Monster.h +++ b/Minecraft.World/Entities/Monster.h @@ -10,7 +10,7 @@ class DamageSource; 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/Entities/PathfinderMob.cpp b/Minecraft.World/Entities/PathfinderMob.cpp index b2dbbdca6..eb51a8760 100644 --- a/Minecraft.World/Entities/PathfinderMob.cpp +++ b/Minecraft.World/Entities/PathfinderMob.cpp @@ -17,7 +17,7 @@ AttributeModifier* PathfinderMob::SPEED_MODIFIER_FLEEING = ->setSerialize(false); PathfinderMob::PathfinderMob(Level* level) : Mob(level) { - path = NULL; + path = nullptr; attackTarget = nullptr; holdGround = false; fleeTime = 0; @@ -47,9 +47,9 @@ 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 = @@ -80,17 +80,17 @@ void PathfinderMob::serverAiStep() { // these can keep doing random strolling. if (!holdGround && - (attackTarget != NULL && (path == NULL || random->nextInt(20) == 0))) { + (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) || + ((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()) { // This entity wouldn't normally be randomly strolling. However, if @@ -114,9 +114,9 @@ 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; } @@ -125,7 +125,7 @@ void PathfinderMob::serverAiStep() { while (target.distanceToSqr(x, target.y, z) < r * r) { path->next(); if (path->isDone()) { - setPath(NULL); // 4J - changed to setPath from path = + setPath(nullptr); // 4J - changed to setPath from path = break; } else target = path->currentPos(shared_from_this()); @@ -134,7 +134,7 @@ void PathfinderMob::serverAiStep() { jumping = false; // 4jcraft - refactoring Vec3 shows this branch never hits /* - if (target != NULL) { + if (target != nullptr) { double xd = target->x - x; double zd = target->z - z; double yd = target->y - yFloor; @@ -151,7 +151,7 @@ void PathfinderMob::serverAiStep() { yRot += rotDiff; if (holdGround) { - if (attackTarget != NULL) { + if (attackTarget != nullptr) { double xd2 = attackTarget->x - x; double zd2 = attackTarget->z - z; @@ -169,7 +169,7 @@ void PathfinderMob::serverAiStep() { } */ - if (attackTarget != NULL) { + if (attackTarget != nullptr) { lookAt(attackTarget, 30, 30); } @@ -231,7 +231,7 @@ bool PathfinderMob::canSpawn() { return this->Mob::canSpawn() && getWalkTargetValue(xt, yt, zt) >= 0; } -bool PathfinderMob::isPathFinding() { return path != NULL; } +bool PathfinderMob::isPathFinding() { return path != nullptr; } void PathfinderMob::setPath(Path* path) { delete this->path; @@ -272,7 +272,7 @@ bool PathfinderMob::hasRestriction() { return restrictRadius != -1; } void PathfinderMob::tickLeash() { Mob::tickLeash(); - if (isLeashed() && getLeashHolder() != NULL && + if (isLeashed() && getLeashHolder() != nullptr && getLeashHolder()->level == this->level) { // soft restriction std::shared_ptr leashHolder = getLeashHolder(); @@ -285,7 +285,7 @@ void PathfinderMob::tickLeash() { shared_from_this()->instanceof(eTYPE_TAMABLE_ANIMAL) ? std::dynamic_pointer_cast(shared_from_this()) : nullptr; - if ((tamabaleAnimal != NULL) && tamabaleAnimal->isSitting()) { + if ((tamabaleAnimal != nullptr) && tamabaleAnimal->isSitting()) { if (_distanceTo > 10) { dropLeash(true, true); } diff --git a/Minecraft.World/Entities/SyncedEntityData.cpp b/Minecraft.World/Entities/SyncedEntityData.cpp index cf99e7aec..ed94187dd 100644 --- a/Minecraft.World/Entities/SyncedEntityData.cpp +++ b/Minecraft.World/Entities/SyncedEntityData.cpp @@ -107,7 +107,7 @@ std::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) { @@ -187,7 +187,7 @@ void SynchedEntityData::pack( std::vector >* items, DataOutputStream* output) // TODO throws IOException { - if (items != NULL) { + if (items != nullptr) { AUTO_VAR(itEnd, items->end()); for (AUTO_VAR(it, items->begin()); it != itEnd; it++) { std::shared_ptr dataItem = *it; @@ -201,15 +201,15 @@ void SynchedEntityData::pack( std::vector >* SynchedEntityData::packDirty() { - std::vector >* result = NULL; + std::vector >* result = nullptr; if (m_isDirty) { for (int i = 0; i <= MAX_ID_VALUE; i++) { std::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 std::vector >(); } result->push_back(dataItem); @@ -225,7 +225,7 @@ void SynchedEntityData::packAll(DataOutputStream* output) // throws IOException { for (int i = 0; i <= MAX_ID_VALUE; i++) { std::shared_ptr dataItem = itemsById[i]; - if (dataItem != NULL) { + if (dataItem != nullptr) { writeDataItem(output, dataItem); } } @@ -236,12 +236,12 @@ void SynchedEntityData::packAll(DataOutputStream* output) // throws IOException std::vector >* SynchedEntityData::getAll() { - std::vector >* result = NULL; + std::vector >* result = nullptr; for (int i = 0; i <= MAX_ID_VALUE; i++) { std::shared_ptr dataItem = itemsById[i]; - if (dataItem != NULL) { - if (result == NULL) { + if (dataItem != nullptr) { + if (result == nullptr) { result = new std::vector >(); } result->push_back(dataItem); @@ -294,12 +294,12 @@ void SynchedEntityData::writeDataItem( std::vector >* SynchedEntityData::unpack(DataInputStream* input) // throws IOException { - std::vector >* result = NULL; + std::vector >* result = nullptr; int currentHeader = input->readByte(); while (currentHeader != EOF_MARKER) { - if (result == NULL) { + if (result == nullptr) { result = new std::vector >(); } @@ -344,7 +344,7 @@ SynchedEntityData::unpack(DataInputStream* input) // throws IOException " ------ garbage data, or early end of stream due to an " "incomplete packet\n"); delete result; - return NULL; + return nullptr; break; } result->push_back(item); @@ -368,7 +368,7 @@ void SynchedEntityData::assignValues( std::shared_ptr item = *it; std::shared_ptr itemFromId = itemsById[item->getId()]; - if (itemFromId != NULL) { + if (itemFromId != nullptr) { switch (item->getType()) { case TYPE_BYTE: itemFromId->setValue(item->getValue_byte()); @@ -408,7 +408,7 @@ int SynchedEntityData::getSizeInBytes() { for (int i = 0; i <= MAX_ID_VALUE; i++) { std::shared_ptr dataItem = itemsById[i]; - if (dataItem != NULL) { + if (dataItem != nullptr) { size += 1; // write value diff --git a/Minecraft.World/Entities/TamableAnimal.cpp b/Minecraft.World/Entities/TamableAnimal.cpp index 5cff600cc..858ccf63c 100644 --- a/Minecraft.World/Entities/TamableAnimal.cpp +++ b/Minecraft.World/Entities/TamableAnimal.cpp @@ -11,7 +11,7 @@ TamableAnimal::TamableAnimal(Level* level) : Animal(level) { } TamableAnimal::~TamableAnimal() { - if (sitGoal != NULL) delete sitGoal; + if (sitGoal != nullptr) delete sitGoal; } void TamableAnimal::defineSynchedData() { @@ -116,7 +116,7 @@ Team* TamableAnimal::getTeam() { if (isTame()) { std::shared_ptr owner = std::dynamic_pointer_cast(getOwner()); - if (owner != NULL) { + if (owner != nullptr) { return owner->getTeam(); } } @@ -130,7 +130,7 @@ bool TamableAnimal::isAlliedTo(std::shared_ptr other) { if (other == owner) { return true; } - if (owner != NULL) { + if (owner != nullptr) { return owner->isAlliedTo(other); } } diff --git a/Minecraft.World/Entities/Throwable.cpp b/Minecraft.World/Entities/Throwable.cpp index 973c7d8d7..922104799 100644 --- a/Minecraft.World/Entities/Throwable.cpp +++ b/Minecraft.World/Entities/Throwable.cpp @@ -141,7 +141,7 @@ void Throwable::tick() { from = Vec3(x, y, z); to = Vec3(x + xd, y + yd, z + zd); - if (res != NULL) { + if (res != nullptr) { to = Vec3(res->pos.x, res->pos.y, res->pos.z); } @@ -159,7 +159,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; if (dd < nearest || nearest == 0) { @@ -169,13 +169,13 @@ void Throwable::tick() { } } - if (hitEntity != NULL) { - if (res != NULL) delete res; + if (hitEntity != nullptr) { + 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)) { handleInsidePortal(); @@ -231,7 +231,7 @@ void Throwable::addAdditonalSaveData(CompoundTag* tag) { tag->putByte(L"shake", (uint8_t)shakeTime); tag->putByte(L"inGround", (uint8_t)(inGround ? 1 : 0)); - if (ownerName.empty() && (owner != NULL) && + if (ownerName.empty() && (owner != nullptr) && owner->instanceof(eTYPE_PLAYER)) { ownerName = owner->getAName(); } @@ -253,7 +253,7 @@ void Throwable::readAdditionalSaveData(CompoundTag* tag) { float Throwable::getShadowHeightOffs() { return 0; } std::shared_ptr Throwable::getOwner() { - if (owner == NULL && !ownerName.empty()) { + if (owner == nullptr && !ownerName.empty()) { owner = level->getPlayerByName(ownerName); } return owner; diff --git a/Minecraft.World/Entities/WitherSkull.cpp b/Minecraft.World/Entities/WitherSkull.cpp index 049309c04..2291341db 100644 --- a/Minecraft.World/Entities/WitherSkull.cpp +++ b/Minecraft.World/Entities/WitherSkull.cpp @@ -52,8 +52,8 @@ float WitherSkull::getTileExplosionResistance(Explosion* explosion, void WitherSkull::onHit(HitResult* res) { if (!level->isClientSide) { - if (res->entity != NULL) { - if (owner != NULL) { + if (res->entity != nullptr) { + if (owner != nullptr) { DamageSource* damageSource = DamageSource::mobAttack(owner); if (res->entity->hurt(damageSource, 8)) { if (!res->entity->isAlive()) { diff --git a/Minecraft.World/IO/Files/ConsoleSaveFile.h b/Minecraft.World/IO/Files/ConsoleSaveFile.h index 78c8b56e1..7627b2116 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFile.h +++ b/Minecraft.World/IO/Files/ConsoleSaveFile.h @@ -30,7 +30,7 @@ public: virtual void Flush(bool autosave, bool updateThumbnail = true) = 0; #if !defined(_CONTENT_PACKAGE) - virtual void DebugFlushToFile(void* compressedData = NULL, + virtual void DebugFlushToFile(void* compressedData = nullptr, unsigned int compressedDataSize = 0) = 0; #endif virtual unsigned int getSizeOnDisk() = 0; @@ -58,5 +58,5 @@ public: 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/IO/Files/ConsoleSaveFileConverter.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileConverter.cpp index 85361c7ed..dc65fe8f9 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileConverter.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileConverter.cpp @@ -83,7 +83,7 @@ void ConsoleSaveFileConverter::ConvertSave(ConsoleSaveFile* sourceSave, std::vector* playerFiles = sourceSave->getFilesWithPrefix(DirectoryLevelStorage::getPlayerDir()); - if (playerFiles != NULL) { + if (playerFiles != nullptr) { for (int fileIdx = 0; fileIdx < playerFiles->size(); fileIdx++) { ConsoleSavePath sourcePlayerDatPath( playerFiles->at(fileIdx)->data.filename); diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileInputStream.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileInputStream.cpp index 73cba98ad..1a612dc05 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileInputStream.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileInputStream.cpp @@ -107,7 +107,7 @@ int ConsoleSaveFileInputStream::read(byteArray b, unsigned int offset, // with the stream. 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); if (!result) { @@ -115,6 +115,6 @@ void ConsoleSaveFileInputStream::close() { } // Stop the dtor from trying to close it again - m_saveFile = NULL; + m_saveFile = nullptr; } } diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.cpp index 8ae4310f0..367f5a08a 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.cpp @@ -22,14 +22,14 @@ #define COMMIT_ALLOCATION MEM_COMMIT unsigned int ConsoleSaveFileOriginal::pagesCommitted = 0; -void* ConsoleSaveFileOriginal::pvHeap = NULL; +void* ConsoleSaveFileOriginal::pvHeap = nullptr; ConsoleSaveFileOriginal::ConsoleSaveFileOriginal( - const std::wstring& fileName, void* pvSaveData /*= NULL*/, + const std::wstring& fileName, void* pvSaveData /*= nullptr*/, unsigned int initialFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/) { // 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 the storage to grow without having to use @@ -39,7 +39,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal( // 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, + pvHeap = VirtualAlloc(nullptr, MAX_PAGE_COUNT * CSF_PAGE_SIZE, RESERVE_ALLOCATION, PAGE_READWRITE); } @@ -51,13 +51,13 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal( // Load a save from the game rules bool bLevelGenBaseSave = false; LevelGenerationOptions* levelGen = app.getLevelGenerationOptions(); - if (pvSaveData == NULL && levelGen != NULL && + 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) fileSize = 0; @@ -82,7 +82,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal( 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 __debugbreak(); @@ -91,7 +91,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal( pagesCommitted = pagesRequired; if (fileSize > 0) { - if (pvSaveData != NULL) { + if (pvSaveData != nullptr) { memcpy(pvSaveMem, pvSaveData, fileSize); if (bLevelGenBaseSave) { levelGen->deleteBaseSaveData(); @@ -143,7 +143,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal( pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE); - if (pvRet == NULL) { + if (pvRet == nullptr) { // Out of physical memory __debugbreak(); } @@ -180,7 +180,7 @@ FileEntry* ConsoleSaveFileOriginal::createFile( } void ConsoleSaveFileOriginal::deleteFile(FileEntry* file) { - if (file == NULL) return; + if (file == nullptr) return; LockSaveAccess(); @@ -278,8 +278,8 @@ void ConsoleSaveFileOriginal::PrepareForWrite( bool ConsoleSaveFileOriginal::writeFile(FileEntry* file, const void* lpBuffer, unsigned int nNumberOfBytesToWrite, unsigned int* lpNumberOfBytesWritten) { - assert(pvSaveMem != NULL); - if (pvSaveMem == NULL) { + assert(pvSaveMem != nullptr); + if (pvSaveMem == nullptr) { return false; } @@ -312,8 +312,8 @@ bool ConsoleSaveFileOriginal::writeFile(FileEntry* file, const void* lpBuffer, bool ConsoleSaveFileOriginal::zeroFile(FileEntry* file, unsigned int nNumberOfBytesToWrite, unsigned int* lpNumberOfBytesWritten) { - assert(pvSaveMem != NULL); - if (pvSaveMem == NULL) { + assert(pvSaveMem != nullptr); + if (pvSaveMem == nullptr) { return false; } @@ -347,8 +347,8 @@ bool ConsoleSaveFileOriginal::readFile(FileEntry* file, void* lpBuffer, unsigned int nNumberOfBytesToRead, unsigned int* lpNumberOfBytesRead) { unsigned int actualBytesToRead; - assert(pvSaveMem != NULL); - if (pvSaveMem == NULL) { + assert(pvSaveMem != nullptr); + if (pvSaveMem == nullptr) { return false; } @@ -419,7 +419,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond( (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(); } @@ -574,10 +574,10 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { std::uint8_t* compData = (std::uint8_t*)StorageManager.AllocateSaveData(compLength); - // 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; @@ -586,7 +586,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { PIXBeginNamedEvent(0, "Pre-calc save compression"); // Save the start time const auto startTime = std::chrono::steady_clock::now(); - Compression::getCompression()->Compress(NULL, &compLength, pvSaveMem, + Compression::getCompression()->Compress(nullptr, &compLength, pvSaveMem, fileSize); fElapsedTime = std::chrono::duration(std::chrono::steady_clock::now() - @@ -604,7 +604,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { compData = (std::uint8_t*)StorageManager.AllocateSaveData(compLength); } - if (compData != NULL) { + if (compData != nullptr) { // Re-compress all save data before we save it to disk PIXBeginNamedEvent(0, "Actual save compression"); // Save the start time @@ -627,10 +627,10 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { app.DebugPrintf("Save data compressed from %d to %d\n", fileSize, compLength); - std::uint8_t* pbThumbnailData = NULL; + std::uint8_t* pbThumbnailData = nullptr; unsigned int dwThumbnailDataSize = 0; - std::uint8_t* pbDataSaveImage = NULL; + std::uint8_t* pbDataSaveImage = nullptr; unsigned int dwDataSizeSaveImage = 0; #ifdef _WINDOWS64 @@ -642,8 +642,8 @@ 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() @@ -701,7 +701,7 @@ int ConsoleSaveFileOriginal::SaveSaveDataCallback(void* lpParam, bool bRes) { #ifndef _CONTENT_PACKAGE void ConsoleSaveFileOriginal::DebugFlushToFile( - void* compressedData /*= NULL*/, unsigned int compressedDataSize /*= 0*/) { + void* compressedData /*= nullptr*/, unsigned int compressedDataSize /*= 0*/) { LockSaveAccess(); finalizeWrite(); @@ -715,7 +715,7 @@ void ConsoleSaveFileOriginal::DebugFlushToFile( wchar_t* fileName = new wchar_t[XCONTENT_MAX_FILENAME_LENGTH + 1]; - std::time_t now = std::time(NULL); + std::time_t now = std::time(nullptr); std::tm t = *std::gmtime(&now); // 14 chars for the digits @@ -734,7 +734,7 @@ void ConsoleSaveFileOriginal::DebugFlushToFile( targetFileDir.getPath() + std::wstring(fileName); bool writeSucceeded = false; - if (compressedData != NULL && compressedDataSize > 0) { + if (compressedData != nullptr && compressedDataSize > 0) { writeSucceeded = PortableFileIO::WriteBinaryFile( outputPath, compressedData, compressedDataSize); numberOfBytesWritten = writeSucceeded ? compressedDataSize : 0; @@ -765,7 +765,7 @@ std::vector* ConsoleSaveFileOriginal::getFilesWithPrefix( std::vector* ConsoleSaveFileOriginal::getRegionFilesByDimension( unsigned int dimensionIndex) { - return NULL; + return nullptr; } int ConsoleSaveFileOriginal::getSaveVersion() { diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h b/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h index 4c9dee376..f5f4777fd 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h +++ b/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h @@ -33,7 +33,7 @@ public: static int SaveSaveDataCallback(void* lpParam, bool bRes); #endif ConsoleSaveFileOriginal(const std::wstring& fileName, - void* pvSaveData = NULL, unsigned int fileSize = 0, + void* pvSaveData = nullptr, unsigned int fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL); virtual ~ConsoleSaveFileOriginal(); @@ -63,7 +63,7 @@ public: virtual void Flush(bool autosave, bool updateThumbnail = true); #if !defined(_CONTENT_PACKAGE) - virtual void DebugFlushToFile(void* compressedData = NULL, + virtual void DebugFlushToFile(void* compressedData = nullptr, unsigned int compressedDataSize = 0); #endif virtual unsigned int getSizeOnDisk(); diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileOutputStream.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileOutputStream.cpp index adde9fa11..951ecde10 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileOutputStream.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileOutputStream.cpp @@ -103,7 +103,7 @@ void ConsoleSaveFileOutputStream::write(byteArray b, unsigned int offset, // bytes. 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); if (!result) { @@ -111,6 +111,6 @@ void ConsoleSaveFileOutputStream::close() { } // Stop the dtor from trying to close it again - m_saveFile = NULL; + m_saveFile = nullptr; } } diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileSplit.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileSplit.cpp index 0c3641815..34382baa0 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileSplit.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileSplit.cpp @@ -21,11 +21,11 @@ #define COMMIT_ALLOCATION MEM_COMMIT unsigned int ConsoleSaveFileSplit::pagesCommitted = 0; -void* ConsoleSaveFileSplit::pvHeap = NULL; +void* ConsoleSaveFileSplit::pvHeap = nullptr; ConsoleSaveFileSplit::RegionFileReference::RegionFileReference( int index, unsigned int regionIndex, unsigned int length /*=0*/, - unsigned char* data /*=NULL*/) { + unsigned char* data /*=nullptr*/) { fileEntry = new FileEntry(); fileEntry->currentFilePointer = 0; fileEntry->data.length = 0; @@ -250,7 +250,7 @@ void ConsoleSaveFileSplit::RegionFileReference::Decompress() { if ((dataOut - data) != fileEntry->data.length) { free(data); fileEntry->data.length = 0; - data = NULL; + data = nullptr; assert(0); } // std::int64_t endTime = System::currentTimeMillis(); @@ -317,7 +317,7 @@ void ConsoleSaveFileSplit::RegionFileReference::ReleaseCompressed() { // app.DebugPrintf("Releasing compressed data for region file from //0x%.8x\n", fileEntry->data.regionIndex ); free(dataCompressed); - dataCompressed = NULL; + dataCompressed = nullptr; dataCompressedSize = 0; } @@ -337,7 +337,7 @@ FileEntry* ConsoleSaveFileSplit::GetRegionFileEntry(unsigned int regionIndex) { } ConsoleSaveFileSplit::ConsoleSaveFileSplit( - const std::wstring& fileName, void* pvSaveData /*= NULL*/, + const std::wstring& fileName, void* pvSaveData /*= nullptr*/, unsigned int initialFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/) { unsigned int fileSize = initialFileSize; @@ -345,13 +345,13 @@ ConsoleSaveFileSplit::ConsoleSaveFileSplit( // Load a save from the game rules bool bLevelGenBaseSave = false; LevelGenerationOptions* levelGen = app.getLevelGenerationOptions(); - if (pvSaveData == NULL && levelGen != NULL && + 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) fileSize = 0; @@ -366,7 +366,7 @@ ConsoleSaveFileSplit::ConsoleSaveFileSplit( ConsoleSaveFileSplit::ConsoleSaveFileSplit(ConsoleSaveFile* sourceSave, bool alreadySmallRegions, ProgressListener* progress) { - _init(sourceSave->getFilename(), NULL, 0, sourceSave->getSavePlatform()); + _init(sourceSave->getFilename(), nullptr, 0, sourceSave->getSavePlatform()); header.setOriginalSaveVersion(sourceSave->getOriginalSaveVersion()); header.setSaveVersion(sourceSave->getSaveVersion()); @@ -402,12 +402,12 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, m_lastTickTime = 0; // 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 the storage to grow without having to use // realloc. - pvHeap = VirtualAlloc(NULL, MAX_PAGE_COUNT * CSF_PAGE_SIZE, + pvHeap = VirtualAlloc(nullptr, MAX_PAGE_COUNT * CSF_PAGE_SIZE, RESERVE_ALLOCATION, PAGE_READWRITE); } @@ -457,7 +457,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, void* pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE); - if (pvRet == NULL) { + if (pvRet == nullptr) { #if !defined(_CONTENT_PACKAGE) // Out of physical memory __debugbreak(); @@ -466,7 +466,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, pagesCommitted = pagesRequired; if (fileSize > 0) { - if (pvSaveData != NULL) { + if (pvSaveData != nullptr) { memcpy(pvSaveMem, pvSaveData, fileSize); } else { unsigned int storageLength; @@ -507,7 +507,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, void* pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE); - if (pvRet == NULL) { + if (pvRet == nullptr) { // Out of physical memory __debugbreak(); } @@ -582,7 +582,7 @@ FileEntry* ConsoleSaveFileSplit::createFile(const ConsoleSavePath& fileName) { } void ConsoleSaveFileSplit::deleteFile(FileEntry* file) { - if (file == NULL) return; + if (file == nullptr) return; assert(file->isRegionFile() == false); @@ -684,8 +684,8 @@ void ConsoleSaveFileSplit::PrepareForWrite(FileEntry* file, bool ConsoleSaveFileSplit::writeFile(FileEntry* file, const void* lpBuffer, unsigned int nNumberOfBytesToWrite, unsigned int* lpNumberOfBytesWritten) { - assert(pvSaveMem != NULL); - if (pvSaveMem == NULL) { + assert(pvSaveMem != nullptr); + if (pvSaveMem == nullptr) { return false; } @@ -742,12 +742,12 @@ bool ConsoleSaveFileSplit::writeFile(FileEntry* file, const void* lpBuffer, bool ConsoleSaveFileSplit::zeroFile(FileEntry* file, unsigned int nNumberOfBytesToWrite, unsigned int* lpNumberOfBytesWritten) { - assert(pvSaveMem != NULL); - if (pvSaveMem == NULL) { + assert(pvSaveMem != nullptr); + if (pvSaveMem == nullptr) { return false; } - // 4jcraft added: memset(NULL + 0, 0, 0); was called + // 4jcraft added: memset(nullptr + 0, 0, 0); was called // no bytes need to be written, hence there you go if (nNumberOfBytesToWrite == 0) { if (lpNumberOfBytesWritten) { @@ -810,8 +810,8 @@ bool ConsoleSaveFileSplit::readFile(FileEntry* file, void* lpBuffer, unsigned int nNumberOfBytesToRead, unsigned int* lpNumberOfBytesRead) { unsigned int actualBytesToRead; - assert(pvSaveMem != NULL); - if (pvSaveMem == NULL) { + assert(pvSaveMem != nullptr); + if (pvSaveMem == nullptr) { return false; } @@ -1014,7 +1014,7 @@ void ConsoleSaveFileSplit::MoveDataBeyond(FileEntry* file, (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(); } @@ -1288,10 +1288,10 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { std::uint8_t* compData = (std::uint8_t*)StorageManager.AllocateSaveData(compLength); - // 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; @@ -1300,7 +1300,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { PIXBeginNamedEvent(0, "Pre-calc save compression"); // Save the start time QueryPerformanceCounter(&qwTime); - Compression::getCompression()->Compress(NULL, &compLength, pvSaveMem, + Compression::getCompression()->Compress(nullptr, &compLength, pvSaveMem, fileSize); QueryPerformanceCounter(&qwNewTime); @@ -1318,7 +1318,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { compData = (std::uint8_t*)StorageManager.AllocateSaveData(compLength); } - if (compData != NULL) { + if (compData != nullptr) { // Re-compress all save data before we save it to disk PIXBeginNamedEvent(0, "Actual save compression"); // Save the start time @@ -1342,10 +1342,10 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { compLength); if (updateThumbnail) { - std::uint8_t* pbThumbnailData = NULL; + std::uint8_t* pbThumbnailData = nullptr; unsigned int dwThumbnailDataSize = 0; - std::uint8_t* pbDataSaveImage = NULL; + std::uint8_t* pbDataSaveImage = nullptr; unsigned int dwDataSizeSaveImage = 0; @@ -1354,8 +1354,8 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { int64_t 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() @@ -1419,7 +1419,7 @@ int ConsoleSaveFileSplit::SaveRegionFilesCallback(void* lpParam, bool bRes) { #if !defined(_CONTENT_PACKAGE) void ConsoleSaveFileSplit::DebugFlushToFile( - void* compressedData /*= NULL*/, unsigned int compressedDataSize /*= 0*/) { + void* compressedData /*= nullptr*/, unsigned int compressedDataSize /*= 0*/) { LockSaveAccess(); finalizeWrite(); @@ -1453,7 +1453,7 @@ void ConsoleSaveFileSplit::DebugFlushToFile( targetFileDir.getPath() + std::wstring(fileName); bool writeSucceeded = false; - if (compressedData != NULL && compressedDataSize > 0) { + if (compressedData != nullptr && compressedDataSize > 0) { writeSucceeded = PortableFileIO::WriteBinaryFile( outputPath, compressedData, compressedDataSize); numberOfBytesWritten = writeSucceeded ? compressedDataSize : 0; @@ -1484,13 +1484,13 @@ std::vector* ConsoleSaveFileSplit::getFilesWithPrefix( std::vector* ConsoleSaveFileSplit::getRegionFilesByDimension( unsigned int dimensionIndex) { - std::vector* files = NULL; + std::vector* files = nullptr; for (AUTO_VAR(it, regionFiles.begin()); it != regionFiles.end(); ++it) { unsigned int entryDimension = ((it->first) >> 16) & 0xFF; if (entryDimension == dimensionIndex) { - if (files == NULL) { + if (files == nullptr) { files = new std::vector(); } diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileSplit.h b/Minecraft.World/IO/Files/ConsoleSaveFileSplit.h index 7653b83ef..a5f1025e9 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileSplit.h +++ b/Minecraft.World/IO/Files/ConsoleSaveFileSplit.h @@ -42,7 +42,7 @@ private: public: RegionFileReference(int index, unsigned int regionIndex, unsigned int length = 0, - unsigned char* data = NULL); + unsigned char* data = nullptr); ~RegionFileReference(); void Compress(); // Compress from data to dataCompressed void Decompress(); // Decompress from dataCompressed -> data @@ -99,12 +99,12 @@ private: unsigned int fileSize, ESavePlatform plat); public: - ConsoleSaveFileSplit(const std::wstring& fileName, void* pvSaveData = NULL, + ConsoleSaveFileSplit(const std::wstring& fileName, void* pvSaveData = nullptr, unsigned int fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL); ConsoleSaveFileSplit(ConsoleSaveFile* sourceSave, bool alreadySmallRegions = true, - ProgressListener* progress = NULL); + ProgressListener* progress = nullptr); virtual ~ConsoleSaveFileSplit(); // 4J Stu - Initial implementation is intended to have a similar interface @@ -133,7 +133,7 @@ public: virtual void Flush(bool autosave, bool updateThumbnail = true); #if !defined(_CONTENT_PACKAGE) - virtual void DebugFlushToFile(void* compressedData = NULL, + virtual void DebugFlushToFile(void* compressedData = nullptr, unsigned int compressedDataSize = 0); #endif virtual unsigned int getSizeOnDisk(); diff --git a/Minecraft.World/IO/Files/File.cpp b/Minecraft.World/IO/Files/File.cpp index 1755ca92d..d0b4ce2eb 100644 --- a/Minecraft.World/IO/Files/File.cpp +++ b/Minecraft.World/IO/Files/File.cpp @@ -113,7 +113,7 @@ File::File(const std::wstring& pathname) { if( path.back().compare( pathRoot ) != 0 ) this->parent = new File( &path ); else - this->parent = NULL; + this->parent = nullptr; } */ } @@ -129,7 +129,7 @@ File::File(const std::wstring& parent, // Creates a new File instance by converting the given path vector into an // abstract pathname. /* -File::File( std::vector *path ) : parent( NULL ) +File::File( std::vector *path ) : parent( nullptr ) { m_abstractPathName = path->back(); path->pop_back(); @@ -140,7 +140,7 @@ if( path->size() > 0 ) if( path->back().compare( pathRoot ) != 0 ) this->parent = new File( path ); else -this->parent = NULL; +this->parent = nullptr; } } */ @@ -298,7 +298,7 @@ std::vector* File::listFiles() const { // or if an I/O error occurs. std::vector* File::listFiles(FileFilter* filter) const { // TODO 4J Stu - Also need to check for I/O errors? - if (!isDirectory()) return NULL; + if (!isDirectory()) return nullptr; std::vector* vOutput = new std::vector(); @@ -362,7 +362,7 @@ __int64 File::lastModified() { const std::wstring File::getPath() const { /* std::wstring path; - if ( parent != NULL) + if ( parent != nullptr) path = parent->getPath(); else path = std::wstring(pathRoot); @@ -387,7 +387,7 @@ bool File::eq_test(const File& x, const File& y) { 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/IO/Files/FileHeader.cpp b/Minecraft.World/IO/Files/FileHeader.cpp index c790bfe58..2a26e0bdf 100644 --- a/Minecraft.World/IO/Files/FileHeader.cpp +++ b/Minecraft.World/IO/Files/FileHeader.cpp @@ -6,7 +6,7 @@ extern CConsoleMinecraftApp app; FileHeader::FileHeader() { - lastFile = NULL; + lastFile = nullptr; m_saveVersion = 0; // New saves should have an original version set to the latest version. This @@ -47,7 +47,7 @@ FileEntry* FileHeader::AddFile(const std::wstring& name, } void FileHeader::RemoveFile(FileEntry* file) { - if (file == NULL) return; + if (file == nullptr) return; AdjustStartOffsets(file, file->getFileSize(), true); @@ -322,12 +322,12 @@ bool FileHeader::fileExists(const std::wstring& name) { std::vector* FileHeader::getFilesWithPrefix( const std::wstring& prefix) { - std::vector* files = NULL; + std::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 std::vector(); } diff --git a/Minecraft.World/IO/Files/FileInputStream.cpp b/Minecraft.World/IO/Files/FileInputStream.cpp index dd494a7b6..3b45921b8 100644 --- a/Minecraft.World/IO/Files/FileInputStream.cpp +++ b/Minecraft.World/IO/Files/FileInputStream.cpp @@ -41,7 +41,7 @@ bool FileSeek(std::FILE* file, int64_t offset, int origin) { // than a regular file, or for some other reason cannot be opened for reading. // SecurityException - if a security manager exists and its checkRead method // denies read access to the file. -FileInputStream::FileInputStream(const File& file) : m_fileHandle(NULL) { +FileInputStream::FileInputStream(const File& file) : m_fileHandle(nullptr) { #if defined(_WIN32) m_fileHandle = _wfopen(file.getPath().c_str(), L"rb"); #else @@ -49,7 +49,7 @@ FileInputStream::FileInputStream(const File& file) : m_fileHandle(NULL) { m_fileHandle = std::fopen(nativePath.c_str(), "rb"); #endif - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { // TODO 4J Stu - Any form of error/exception handling //__debugbreak(); app.FatalLoadError(); @@ -57,7 +57,7 @@ FileInputStream::FileInputStream(const File& file) : m_fileHandle(NULL) { } FileInputStream::~FileInputStream() { - if (m_fileHandle != NULL) { + if (m_fileHandle != nullptr) { std::fclose(m_fileHandle); } } @@ -66,7 +66,7 @@ FileInputStream::~FileInputStream() { // is yet available. Returns: the next byte of data, or -1 if the end of the // file is reached. int FileInputStream::read() { - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { return -1; } @@ -91,7 +91,7 @@ int FileInputStream::read() { // into the buffer, or -1 if there is no more data because the end of the file // has been reached. int FileInputStream::read(byteArray b) { - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { return -1; } @@ -122,7 +122,7 @@ int FileInputStream::read(byteArray b, unsigned int offset, // 4J Stu - We don't want to read any more than the array buffer can hold assert(length <= (b.length - offset)); - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { return -1; } @@ -145,7 +145,7 @@ int FileInputStream::read(byteArray b, unsigned int offset, // with the stream. If this stream has an associated channel then the channel is // closed as well. void FileInputStream::close() { - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { // printf("\n\nFileInputStream::close - TRYING TO CLOSE AN INVALID FILE // HANDLE\n\n"); return; @@ -158,7 +158,7 @@ void FileInputStream::close() { } // Stop the dtor from trying to close it again - m_fileHandle = NULL; + m_fileHandle = nullptr; } // Skips n bytes of input from this input stream. Fewer bytes might be skipped @@ -168,7 +168,7 @@ void FileInputStream::close() { // the number of bytes to be skipped. Returns: the actual number of bytes // skipped. int64_t FileInputStream::skip(int64_t n) { - if (m_fileHandle == NULL || n <= 0) { + if (m_fileHandle == nullptr || n <= 0) { return 0; } diff --git a/Minecraft.World/IO/Files/FileOutputStream.cpp b/Minecraft.World/IO/Files/FileOutputStream.cpp index 8f55a851b..bc7685228 100644 --- a/Minecraft.World/IO/Files/FileOutputStream.cpp +++ b/Minecraft.World/IO/Files/FileOutputStream.cpp @@ -14,7 +14,7 @@ // // Parameters: // file - the file to be opened for writing. -FileOutputStream::FileOutputStream(const File& file) : m_fileHandle(NULL) { +FileOutputStream::FileOutputStream(const File& file) : m_fileHandle(nullptr) { if (file.exists() && file.isDirectory()) { // TODO 4J Stu - FileNotFoundException return; @@ -27,14 +27,14 @@ FileOutputStream::FileOutputStream(const File& file) : m_fileHandle(NULL) { m_fileHandle = std::fopen(nativePath.c_str(), "wb"); #endif - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { // TODO 4J Stu - Any form of error/exception handling perror("FileOutputStream::FileOutputStream"); } } FileOutputStream::~FileOutputStream() { - if (m_fileHandle != NULL) { + if (m_fileHandle != nullptr) { std::fclose(m_fileHandle); } } @@ -42,7 +42,7 @@ FileOutputStream::~FileOutputStream() { // Writes the specified byte to this file output stream. Implements the write // method of OutputStream. Parameters: b - the byte to be written. void FileOutputStream::write(unsigned int b) { - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { return; } @@ -60,7 +60,7 @@ void FileOutputStream::write(unsigned int b) { // Writes b.length bytes from the specified byte array to this file output // stream. Parameters: b - the data. void FileOutputStream::write(byteArray b) { - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { return; } @@ -83,7 +83,7 @@ void FileOutputStream::write(byteArray b, unsigned int offset, // 4J Stu - We don't want to write any more than the array buffer holds assert(length <= (b.length - offset)); - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { return; } @@ -103,7 +103,7 @@ void FileOutputStream::write(byteArray b, unsigned int offset, // bytes. If this stream has an associated channel then the channel is closed as // well. void FileOutputStream::close() { - if (m_fileHandle == NULL) { + if (m_fileHandle == nullptr) { return; } @@ -113,11 +113,11 @@ void FileOutputStream::close() { } // Stop the dtor from trying to close it again - m_fileHandle = NULL; + m_fileHandle = nullptr; } void FileOutputStream::flush() { - if (m_fileHandle != NULL) { + if (m_fileHandle != nullptr) { std::fflush(m_fileHandle); } } diff --git a/Minecraft.World/IO/NBT/ByteArrayTag.h b/Minecraft.World/IO/NBT/ByteArrayTag.h index fe9aa6597..63170e585 100644 --- a/Minecraft.World/IO/NBT/ByteArrayTag.h +++ b/Minecraft.World/IO/NBT/ByteArrayTag.h @@ -41,8 +41,8 @@ public: bool equals(Tag* obj) { if (Tag::equals(obj)) { ByteArrayTag* o = (ByteArrayTag*)obj; - return ((data.data == NULL && o->data.data == NULL) || - (data.data != NULL && data.length == o->data.length && + 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/IO/NBT/CompoundTag.h b/Minecraft.World/IO/NBT/CompoundTag.h index c80a52c94..2a819de6d 100644 --- a/Minecraft.World/IO/NBT/CompoundTag.h +++ b/Minecraft.World/IO/NBT/CompoundTag.h @@ -111,7 +111,7 @@ public: Tag* get(const std::wstring& name) { AUTO_VAR(it, tags.find(name)); if (it != tags.end()) return it->second; - return NULL; + return nullptr; } bool contains(const std::wstring& name) { diff --git a/Minecraft.World/IO/NBT/IntArrayTag.h b/Minecraft.World/IO/NBT/IntArrayTag.h index a95519b05..626d042d7 100644 --- a/Minecraft.World/IO/NBT/IntArrayTag.h +++ b/Minecraft.World/IO/NBT/IntArrayTag.h @@ -43,8 +43,8 @@ public: bool equals(Tag* obj) { if (Tag::equals(obj)) { IntArrayTag* o = (IntArrayTag*)obj; - return ((data.data == NULL && o->data.data == NULL) || - (data.data != NULL && data.length == o->data.length && + 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)); } diff --git a/Minecraft.World/IO/NBT/NbtIO.cpp b/Minecraft.World/IO/NBT/NbtIO.cpp index fa51e350c..f6c39040c 100644 --- a/Minecraft.World/IO/NBT/NbtIO.cpp +++ b/Minecraft.World/IO/NBT/NbtIO.cpp @@ -56,9 +56,9 @@ CompoundTag* NbtIo::read(DataInput* dis) { if (tag->getId() == Tag::TAG_Compound) return (CompoundTag*)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/IO/NBT/NbtSlotFile.cpp b/Minecraft.World/IO/NBT/NbtSlotFile.cpp index ce4d42f84..6fde82fad 100644 --- a/Minecraft.World/IO/NBT/NbtSlotFile.cpp +++ b/Minecraft.World/IO/NBT/NbtSlotFile.cpp @@ -6,13 +6,13 @@ namespace { std::FILE* OpenBinaryFileForReadWrite(const File& file) { #if defined(_WIN32) std::FILE* stream = _wfopen(file.getPath().c_str(), L"r+b"); - if (stream == NULL) { + if (stream == nullptr) { stream = _wfopen(file.getPath().c_str(), L"w+b"); } #else const std::string nativePath = wstringtofilename(file.getPath()); std::FILE* stream = std::fopen(nativePath.c_str(), "r+b"); - if (stream == NULL) { + if (stream == nullptr) { stream = std::fopen(nativePath.c_str(), "w+b"); } #endif @@ -250,8 +250,8 @@ void NbtSlotFile::replaceSlot(int slot, std::vector* tags) { } void NbtSlotFile::close() { - if (raf != NULL) { + if (raf != nullptr) { std::fclose(raf); - raf = NULL; + raf = nullptr; } } diff --git a/Minecraft.World/IO/NBT/Tag.cpp b/Minecraft.World/IO/NBT/Tag.cpp index 955adf6c7..14115ae3a 100644 --- a/Minecraft.World/IO/NBT/Tag.cpp +++ b/Minecraft.World/IO/NBT/Tag.cpp @@ -22,7 +22,7 @@ Tag::Tag(const std::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; } @@ -127,7 +127,7 @@ Tag* Tag::newTag(uint8_t type, const std::wstring& name) { case TAG_Compound: return new CompoundTag(name); } - return NULL; + return nullptr; } const wchar_t* Tag::getTagName(uint8_t type) { diff --git a/Minecraft.World/IO/Streams/BufferedOutputStream.cpp b/Minecraft.World/IO/Streams/BufferedOutputStream.cpp index 627c423c6..5e41fb5c2 100644 --- a/Minecraft.World/IO/Streams/BufferedOutputStream.cpp +++ b/Minecraft.World/IO/Streams/BufferedOutputStream.cpp @@ -22,10 +22,10 @@ BufferedOutputStream::~BufferedOutputStream() { // Flushes this buffered output stream. This forces any buffered output bytes to // be written out to the underlying output stream. void BufferedOutputStream::flush() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "BufferedOutputStream::flush() called but underlying stream is " - "NULL\n"); + "nullptr\n"); return; } @@ -40,10 +40,10 @@ void BufferedOutputStream::flush() { // and then calls the close method of its underlying output stream. void BufferedOutputStream::close() { flush(); - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "BufferedOutputStream::close() called but underlying stream is " - "NULL\n"); + "nullptr\n"); return; } stream->close(); diff --git a/Minecraft.World/IO/Streams/ByteArrayInputStream.cpp b/Minecraft.World/IO/Streams/ByteArrayInputStream.cpp index adcf9fc30..f4b317b18 100644 --- a/Minecraft.World/IO/Streams/ByteArrayInputStream.cpp +++ b/Minecraft.World/IO/Streams/ByteArrayInputStream.cpp @@ -107,5 +107,5 @@ int64_t ByteArrayInputStream::skip(int64_t n) { } ByteArrayInputStream::~ByteArrayInputStream() { - if (buf.data != NULL) delete[] buf.data; + if (buf.data != nullptr) delete[] buf.data; } diff --git a/Minecraft.World/IO/Streams/ByteArrayOutputStream.cpp b/Minecraft.World/IO/Streams/ByteArrayOutputStream.cpp index 2a9ba4297..7cc8b4efb 100644 --- a/Minecraft.World/IO/Streams/ByteArrayOutputStream.cpp +++ b/Minecraft.World/IO/Streams/ByteArrayOutputStream.cpp @@ -17,7 +17,7 @@ ByteArrayOutputStream::ByteArrayOutputStream(unsigned int size) { } ByteArrayOutputStream::~ByteArrayOutputStream() { - if (buf.data != NULL) delete[] buf.data; + if (buf.data != nullptr) delete[] buf.data; } // Writes the specified byte to this byte array output stream. diff --git a/Minecraft.World/IO/Streams/Compression.cpp b/Minecraft.World/IO/Streams/Compression.cpp index 0088c886d..2778f995c 100644 --- a/Minecraft.World/IO/Streams/Compression.cpp +++ b/Minecraft.World/IO/Streams/Compression.cpp @@ -156,12 +156,12 @@ HRESULT Compression::DecompressLZXRLE(void* pDestination, // 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) { rleSize = *pDestSize; @@ -201,7 +201,7 @@ HRESULT Compression::DecompressLZXRLE(void* pDestination, // 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; @@ -344,12 +344,12 @@ HRESULT Compression::DecompressWithType(void* pDestination, } break; case eCompressionType_ZLIBRLE: #if defined(_WIN64) || defined(__linux__) - if (pDestination != NULL) + if (pDestination != nullptr) return ::uncompress( (Bytef*)pDestination, (unsigned long*)pDestSize, (const Bytef*)pSource, SrcSize); // Decompress else - break; // Cannot decompress when destination is NULL + break; // Cannot decompress when destination is nullptr #else assert(0); break; @@ -359,7 +359,7 @@ HRESULT Compression::DecompressWithType(void* pDestination, // 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 std::uint8_t* pbDestSize = reinterpret_cast(pDestSize); @@ -411,7 +411,7 @@ HRESULT Compression::DecompressWithType(void* pDestination, delete uncompr.data; return S_OK; } else - break; // Cannot decompress when destination is NULL + break; // Cannot decompress when destination is nullptr #else assert(0); #endif diff --git a/Minecraft.World/IO/Streams/DataInputStream.cpp b/Minecraft.World/IO/Streams/DataInputStream.cpp index 6393b4e4c..55666f209 100644 --- a/Minecraft.World/IO/Streams/DataInputStream.cpp +++ b/Minecraft.World/IO/Streams/DataInputStream.cpp @@ -16,9 +16,9 @@ DataInputStream::DataInputStream(InputStream* in) : stream(in) {} // an exception is thrown. This method simply performs in.read() and returns the // result. int DataInputStream::read() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::read() called but underlying stream is NULL\n"); + "DataInputStream::read() called but underlying stream is nullptr\n"); return -1; } return stream->read(); @@ -50,10 +50,10 @@ int DataInputStream::read() { // the total number of bytes read into the buffer, or -1 if there is no more // data because the end of the stream has been reached. int DataInputStream::read(byteArray b) { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "DataInputStream::read(byteArray) called but underlying stream is " - "NULL\n"); + "nullptr\n"); return -1; } return read(b, 0, b.length); @@ -90,10 +90,10 @@ int DataInputStream::read(byteArray b) { // data because the end of the stream has been reached. int DataInputStream::read(byteArray b, unsigned int offset, unsigned int length) { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "DataInputStream::read(byteArray,offset,length) called but " - "underlying stream is NULL\n"); + "underlying stream is nullptr\n"); return -1; } return stream->read(b, offset, length); @@ -102,9 +102,9 @@ int DataInputStream::read(byteArray b, unsigned int offset, // Closes this input stream and releases any system resources associated with // the stream. This method simply performs in.close() void DataInputStream::close() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::close() called but underlying stream is NULL\n"); + "DataInputStream::close() called but underlying stream is nullptr\n"); return; } stream->close(); @@ -114,9 +114,9 @@ void DataInputStream::close() { // byte is zero. This method is suitable for reading the byte written by the // writeBoolean method of interface DataOutput. Returns: the boolean value read. bool DataInputStream::readBoolean() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::readBoolean() but underlying stream is NULL\n"); + "DataInputStream::readBoolean() but underlying stream is nullptr\n"); return false; } return stream->read() != 0; @@ -127,19 +127,19 @@ bool DataInputStream::readBoolean() { // the byte written by the writeByte method of interface DataOutput. Returns: // the 8-bit value read. uint8_t DataInputStream::readByte() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::readByte() but underlying stream is NULL\n"); + "DataInputStream::readByte() but underlying stream is nullptr\n"); return 0; } return (uint8_t)stream->read(); } unsigned char DataInputStream::readUnsignedByte() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "DataInputStream::readUnsignedByte() but underlying stream is " - "NULL\n"); + "nullptr\n"); return 0; } return (unsigned char)stream->read(); @@ -152,9 +152,9 @@ unsigned char DataInputStream::readUnsignedByte() { // This method is suitable for reading bytes written by the writeChar method of // interface DataOutput. Returns: the char value read. wchar_t DataInputStream::readChar() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::readChar() but underlying stream is NULL\n"); + "DataInputStream::readChar() but underlying stream is nullptr\n"); return 0; } int a = stream->read(); @@ -182,10 +182,10 @@ bool DataInputStream::readFully(byteArray b) { // of the Java library // TODO 4J Stu - Need to handle exceptions here is we throw them in other // InputStreams - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "DataInputStream::readFully(byteArray) but underlying stream is " - "NULL\n"); + "nullptr\n"); return false; } for (unsigned int i = 0; i < b.length; i++) { @@ -204,10 +204,10 @@ bool DataInputStream::readFully(charArray b) { // of the Java library // TODO 4J Stu - Need to handle exceptions here is we throw them in other // InputStreams - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "DataInputStream::readFully(charArray) but underlying stream is " - "NULL\n"); + "nullptr\n"); return false; } for (unsigned int i = 0; i < b.length; i++) { @@ -253,9 +253,9 @@ float DataInputStream::readFloat() { // This method is suitable for reading bytes written by the writeInt method of // interface DataOutput. Returns: the int value read. int DataInputStream::readInt() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::readInt() but underlying stream is NULL\n"); + "DataInputStream::readInt() but underlying stream is nullptr\n"); return 0; } int a = stream->read(); @@ -285,9 +285,9 @@ int DataInputStream::readInt() { // Returns: // the long value read. int64_t DataInputStream::readLong() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::readLong() but underlying stream is NULL\n"); + "DataInputStream::readLong() but underlying stream is nullptr\n"); return 0; } int64_t a = stream->read(); @@ -314,9 +314,9 @@ int64_t DataInputStream::readLong() { // This method is suitable for reading the bytes written by the writeShort // method of interface DataOutput. Returns: the 16-bit value read. short DataInputStream::readShort() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::readShort() but underlying stream is NULL\n"); + "DataInputStream::readShort() but underlying stream is nullptr\n"); return 0; } int a = stream->read(); @@ -325,10 +325,10 @@ short DataInputStream::readShort() { } unsigned short DataInputStream::readUnsignedShort() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "DataInputStream::readUnsignedShort() but underlying stream is " - "NULL\n"); + "nullptr\n"); return 0; } int a = stream->read(); @@ -384,9 +384,9 @@ unsigned short DataInputStream::readUnsignedShort() { // a Unicode string. std::wstring DataInputStream::readUTF() { std::wstring outputString; - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::readUTF() but underlying stream is NULL\n"); + "DataInputStream::readUTF() but underlying stream is nullptr\n"); return outputString; } int a = stream->read(); @@ -511,9 +511,9 @@ std::wstring DataInputStream::readUTF() { int DataInputStream::readUTFChar() { int returnValue = -1; - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataInputStream::readUTFChar() but underlying stream is NULL\n"); + "DataInputStream::readUTFChar() but underlying stream is nullptr\n"); return returnValue; } int firstByte = stream->read(); diff --git a/Minecraft.World/IO/Streams/DataOutputStream.cpp b/Minecraft.World/IO/Streams/DataOutputStream.cpp index 3a5bd8a12..a3a2e3376 100644 --- a/Minecraft.World/IO/Streams/DataOutputStream.cpp +++ b/Minecraft.World/IO/Streams/DataOutputStream.cpp @@ -20,10 +20,10 @@ void DataOutputStream::deleteChildStream() { delete stream; } // incremented by 1. Implements the write method of OutputStream. Parameters: b // - the byte to be written. void DataOutputStream::write(unsigned int b) { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "DataOutputStream::write(unsigned int) called but underlying " - "stream is NULL\n"); + "stream is nullptr\n"); return; } stream->write(b); @@ -32,9 +32,9 @@ void DataOutputStream::write(unsigned int b) { } void DataOutputStream::flush() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataOutputStream::flush() called but underlying stream is NULL\n"); + "DataOutputStream::flush() called but underlying stream is nullptr\n"); return; } stream->flush(); @@ -51,10 +51,10 @@ void DataOutputStream::write(byteArray b) { write(b, 0, b.length); } // data. len - the number of bytes to write. void DataOutputStream::write(byteArray b, unsigned int offset, unsigned int length) { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "DataOutputStream::write(byteArray,...) called but underlying " - "stream is NULL\n"); + "stream is nullptr\n"); return; } stream->write(b, offset, length); @@ -66,9 +66,9 @@ void DataOutputStream::write(byteArray b, unsigned int offset, // the stream. The close method of FilterOutputStream calls its flush method, // and then calls the close method of its underlying output stream. void DataOutputStream::close() { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( - "DataOutputStream::close() called but underlying stream is NULL\n"); + "DataOutputStream::close() called but underlying stream is nullptr\n"); return; } stream->close(); @@ -148,10 +148,10 @@ void DataOutputStream::writeShort(short a) { } void DataOutputStream::writeUnsignedShort(unsigned short a) { - if (stream == NULL) { + if (stream == nullptr) { app.DebugPrintf( "DataOutputStream::writeUnsignedShort() but underlying stream is " - "NULL\n"); + "nullptr\n"); return; } stream->write(static_cast((a >> 8) & 0xff)); diff --git a/Minecraft.World/IO/Streams/InputStream.cpp b/Minecraft.World/IO/Streams/InputStream.cpp index 28a732662..bcb6ff928 100644 --- a/Minecraft.World/IO/Streams/InputStream.cpp +++ b/Minecraft.World/IO/Streams/InputStream.cpp @@ -5,5 +5,5 @@ InputStream* InputStream::getResourceAsStream(const std::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/Items/ArmorItem.cpp b/Minecraft.World/Items/ArmorItem.cpp index 2f4173530..e171e062d 100644 --- a/Minecraft.World/Items/ArmorItem.cpp +++ b/Minecraft.World/Items/ArmorItem.cpp @@ -153,11 +153,11 @@ int ArmorItem::getColor(std::shared_ptr item) { if (armorType != ArmorMaterial::CLOTH) return -1; CompoundTag* tag = item->getTag(); - if (tag == NULL) + if (tag == nullptr) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR); CompoundTag* display = tag->getCompound(L"display"); - if (display == NULL) + if (display == nullptr) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR); @@ -179,7 +179,7 @@ Icon* ArmorItem::getLayerIcon(int auxValue, int spriteLayer) { void ArmorItem::clearColor(std::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"); } @@ -195,7 +195,7 @@ void ArmorItem::setColor(std::shared_ptr item, int color) { CompoundTag* tag = item->getTag(); - if (tag == NULL) { + if (tag == nullptr) { tag = new CompoundTag(); item->setTag(tag); } @@ -236,5 +236,5 @@ Icon* ArmorItem::getEmptyIcon(int slot) { return Item::boots_diamond->iconEmpty; } - return NULL; + return nullptr; } diff --git a/Minecraft.World/Items/BoatItem.cpp b/Minecraft.World/Items/BoatItem.cpp index 313b658e1..a7aa1b274 100644 --- a/Minecraft.World/Items/BoatItem.cpp +++ b/Minecraft.World/Items/BoatItem.cpp @@ -40,7 +40,7 @@ bool BoatItem::TestUse(std::shared_ptr itemInstance, Level* level, Vec3 to(xa * range, ya * range, za * range); to = to.add(from.x, from.y, from.z); HitResult* hr = level->clip(&from, &to, true); - if (hr == NULL) return false; + if (hr == nullptr) return false; if (hr->type == HitResult::TILE) { delete hr; @@ -77,7 +77,7 @@ std::shared_ptr BoatItem::use( Vec3 to(xa * range, ya * range, za * range); to = to.add(from.x, from.y, from.z); 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/Items/BottleItem.cpp b/Minecraft.World/Items/BottleItem.cpp index ee6d12132..8a6b26160 100644 --- a/Minecraft.World/Items/BottleItem.cpp +++ b/Minecraft.World/Items/BottleItem.cpp @@ -14,7 +14,7 @@ std::shared_ptr BottleItem::use( std::shared_ptr itemInstance, Level* level, std::shared_ptr player) { HitResult* hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) return itemInstance; + if (hr == nullptr) return itemInstance; if (hr->type == HitResult::TILE) { int xt = hr->x; @@ -52,7 +52,7 @@ std::shared_ptr BottleItem::use( bool BottleItem::TestUse(std::shared_ptr itemInstance, Level* level, std::shared_ptr player) { HitResult* hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) return false; + if (hr == nullptr) return false; if (hr->type == HitResult::TILE) { int xt = hr->x; diff --git a/Minecraft.World/Items/BowItem.cpp b/Minecraft.World/Items/BowItem.cpp index 20ba0d448..dae94bb4f 100644 --- a/Minecraft.World/Items/BowItem.cpp +++ b/Minecraft.World/Items/BowItem.cpp @@ -15,7 +15,7 @@ BowItem::BowItem(int id) : Item(id) { maxStackSize = 1; setMaxDamage(384); - icons = NULL; + icons = nullptr; } void BowItem::releaseUsing(std::shared_ptr itemInstance, diff --git a/Minecraft.World/Items/BucketItem.cpp b/Minecraft.World/Items/BucketItem.cpp index 4ce9f8f0b..405989b78 100644 --- a/Minecraft.World/Items/BucketItem.cpp +++ b/Minecraft.World/Items/BucketItem.cpp @@ -27,7 +27,7 @@ bool BucketItem::TestUse(std::shared_ptr itemInstance, Level* level, std::shared_ptr player) { 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) { int xt = hr->x; @@ -97,7 +97,7 @@ std::shared_ptr BucketItem::use( 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) { int xt = hr->x; @@ -108,7 +108,7 @@ std::shared_ptr BucketItem::use( app.DebugPrintf("!!!!!!!!!!! Can't place that here\n"); std::shared_ptr servPlayer = std::dynamic_pointer_cast(player); - if (servPlayer != NULL) { + if (servPlayer != nullptr) { app.DebugPrintf( "Sending ChatPacket::e_ChatCannotPlaceLava to player\n"); servPlayer->connection->send(std::shared_ptr( diff --git a/Minecraft.World/Items/ClockItem.cpp b/Minecraft.World/Items/ClockItem.cpp index f8b83b397..c8e04d544 100644 --- a/Minecraft.World/Items/ClockItem.cpp +++ b/Minecraft.World/Items/ClockItem.cpp @@ -7,7 +7,7 @@ const std::wstring ClockItem::TEXTURE_PLAYER_ICON[XUSER_MAX_COUNT] = { L"clockP0", L"clockP1", L"clockP2", L"clockP3"}; -ClockItem::ClockItem(int id) : Item(id) { icons = NULL; } +ClockItem::ClockItem(int id) : Item(id) { icons = nullptr; } // 4J Added so that we can override the icon id used to calculate the texture // UV's for each player @@ -15,7 +15,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()]; } return icon; diff --git a/Minecraft.World/Items/CompassItem.cpp b/Minecraft.World/Items/CompassItem.cpp index 8bfde3fc1..78237eadf 100644 --- a/Minecraft.World/Items/CompassItem.cpp +++ b/Minecraft.World/Items/CompassItem.cpp @@ -7,7 +7,7 @@ const std::wstring CompassItem::TEXTURE_PLAYER_ICON[XUSER_MAX_COUNT] = { L"compassP0", L"compassP1", L"compassP2", L"compassP3"}; -CompassItem::CompassItem(int id) : Item(id) { icons = NULL; } +CompassItem::CompassItem(int id) : Item(id) { icons = nullptr; } // 4J Added so that we can override the icon id used to calculate the texture // UV's for each player @@ -16,7 +16,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()]; } return icon; diff --git a/Minecraft.World/Items/DyePowderItem.cpp b/Minecraft.World/Items/DyePowderItem.cpp index 943de2359..c4c8ac6cc 100644 --- a/Minecraft.World/Items/DyePowderItem.cpp +++ b/Minecraft.World/Items/DyePowderItem.cpp @@ -16,7 +16,7 @@ DyePowderItem::DyePowderItem(int id) : Item(id) { setStackedByData(true); setMaxDamage(0); - icons = NULL; + icons = nullptr; } const unsigned int DyePowderItem::COLOR_DESCS[] = { @@ -247,9 +247,9 @@ void DyePowderItem::addGrowthParticles(Level* level, int x, int y, int z, int count) { 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++) { @@ -266,7 +266,7 @@ void DyePowderItem::addGrowthParticles(Level* level, int x, int y, int z, bool DyePowderItem::interactEnemy(std::shared_ptr itemInstance, std::shared_ptr player, std::shared_ptr mob) { - if (std::dynamic_pointer_cast(mob) != NULL) { + if (std::dynamic_pointer_cast(mob) != nullptr) { std::shared_ptr sheep = std::dynamic_pointer_cast(mob); // convert to tile-based color value (0 is white instead of black) int newColor = ColoredTile::getTileDataForItemAuxValue( diff --git a/Minecraft.World/Items/EnchantedBookItem.cpp b/Minecraft.World/Items/EnchantedBookItem.cpp index 88e8850f3..6428aae14 100644 --- a/Minecraft.World/Items/EnchantedBookItem.cpp +++ b/Minecraft.World/Items/EnchantedBookItem.cpp @@ -30,7 +30,7 @@ const Rarity* EnchantedBookItem::getRarity( ListTag* EnchantedBookItem::getEnchantments( std::shared_ptr item) { - if (item->tag == NULL || + if (item->tag == nullptr || !item->tag->contains((wchar_t*)TAG_STORED_ENCHANTMENTS.c_str())) { return new ListTag(); } @@ -46,7 +46,7 @@ void EnchantedBookItem::appendHoverText( ListTag* list = getEnchantments(itemInstance); - if (list != NULL) { + if (list != nullptr) { std::wstring unformatted = L""; for (int i = 0; i < list->size(); i++) { int type = @@ -54,7 +54,7 @@ void EnchantedBookItem::appendHoverText( 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/Items/EnderEyeItem.cpp b/Minecraft.World/Items/EnderEyeItem.cpp index f3dd572ea..df1c7f915 100644 --- a/Minecraft.World/Items/EnderEyeItem.cpp +++ b/Minecraft.World/Items/EnderEyeItem.cpp @@ -131,13 +131,13 @@ bool EnderEyeItem::useOn(std::shared_ptr instance, bool EnderEyeItem::TestUse(std::shared_ptr itemInstance, Level* level, std::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; if (tile == Tile::endPortalFrameTile_Id) { return false; } - } else if (hr != NULL) { + } else if (hr != nullptr) { delete hr; } @@ -171,7 +171,7 @@ bool EnderEyeItem::TestUse(std::shared_ptr itemInstance, // level->findNearestMapFeature(LargeFeature::STRONGHOLD, (int) // player->x, (int) player->y, (int) player->z); if // (nearestMapFeature - // != NULL) + // != nullptr) // { // delete nearestMapFeature; // return true; @@ -184,13 +184,13 @@ std::shared_ptr EnderEyeItem::use( std::shared_ptr instance, Level* level, std::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; if (tile == Tile::endPortalFrameTile_Id) { return instance; } - } else if (hr != NULL) { + } else if (hr != nullptr) { delete hr; } diff --git a/Minecraft.World/Items/EnderPearlItem.cpp b/Minecraft.World/Items/EnderPearlItem.cpp index 589403f72..6cc7684a9 100644 --- a/Minecraft.World/Items/EnderPearlItem.cpp +++ b/Minecraft.World/Items/EnderPearlItem.cpp @@ -18,7 +18,7 @@ std::shared_ptr EnderpearlItem::use( // 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/Items/FireChargeItem.cpp b/Minecraft.World/Items/FireChargeItem.cpp index 0e5cff79a..dd7dbab76 100644 --- a/Minecraft.World/Items/FireChargeItem.cpp +++ b/Minecraft.World/Items/FireChargeItem.cpp @@ -9,7 +9,7 @@ #include "../Blocks/Tile.h" FireChargeItem::FireChargeItem(int id) : Item(id) { - m_dragonFireballIcon = NULL; + m_dragonFireballIcon = nullptr; } bool FireChargeItem::useOn(std::shared_ptr instance, diff --git a/Minecraft.World/Items/FireworksChargeItem.cpp b/Minecraft.World/Items/FireworksChargeItem.cpp index a6c2cc5b2..69dc4036d 100644 --- a/Minecraft.World/Items/FireworksChargeItem.cpp +++ b/Minecraft.World/Items/FireworksChargeItem.cpp @@ -16,7 +16,7 @@ int FireworksChargeItem::getColor(std::shared_ptr item, int spriteLayer) { if (spriteLayer == 1) { Tag* colorTag = getExplosionTagField(item, FireworksItem::TAG_E_COLORS); - if (colorTag != NULL) { + if (colorTag != nullptr) { IntArrayTag* colors = (IntArrayTag*)colorTag; if (colors->data.length == 1) { return colors->data[0]; @@ -47,11 +47,11 @@ Tag* FireworksChargeItem::getExplosionTagField( 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( @@ -60,7 +60,7 @@ void FireworksChargeItem::appendHoverText( 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/Items/FireworksItem.cpp b/Minecraft.World/Items/FireworksItem.cpp index 42cd0c133..53e413a8b 100644 --- a/Minecraft.World/Items/FireworksItem.cpp +++ b/Minecraft.World/Items/FireworksItem.cpp @@ -48,7 +48,7 @@ void FireworksItem::appendHoverText(std::shared_ptr itemInstance, return; } CompoundTag* fireTag = itemInstance->getTag()->getCompound(TAG_FIREWORKS); - if (fireTag == NULL) { + if (fireTag == nullptr) { return; } if (fireTag->contains(TAG_FLIGHT)) { @@ -59,7 +59,7 @@ void FireworksItem::appendHoverText(std::shared_ptr itemInstance, 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++) { CompoundTag* expTag = explosions->get(i); diff --git a/Minecraft.World/Items/FishingRodItem.cpp b/Minecraft.World/Items/FishingRodItem.cpp index d95db92e7..94632cc6c 100644 --- a/Minecraft.World/Items/FishingRodItem.cpp +++ b/Minecraft.World/Items/FishingRodItem.cpp @@ -16,7 +16,7 @@ FishingRodItem::FishingRodItem(int id) : Item(id) { setMaxDamage(64); setMaxStackSize(1); - emptyIcon = NULL; + emptyIcon = nullptr; } bool FishingRodItem::isHandEquipped() { return true; } @@ -26,7 +26,7 @@ bool FishingRodItem::isMirroredArt() { return true; } std::shared_ptr FishingRodItem::use( std::shared_ptr instance, Level* level, std::shared_ptr player) { - if (player->fishing != NULL) { + if (player->fishing != nullptr) { int dmg = player->fishing->retrieve(); instance->hurtAndBreak(dmg, player); player->swing(); diff --git a/Minecraft.World/Items/HangingEntityItem.cpp b/Minecraft.World/Items/HangingEntityItem.cpp index fe4367f2f..2fb62c6d0 100644 --- a/Minecraft.World/Items/HangingEntityItem.cpp +++ b/Minecraft.World/Items/HangingEntityItem.cpp @@ -36,7 +36,7 @@ bool HangingEntityItem::useOn(std::shared_ptr instance, if (!player->mayUseItemAt(xt, yt, zt, face, instance)) return false; - if (entity != NULL && entity->survives()) { + if (entity != nullptr && entity->survives()) { if (!level->isClientSide) { if (level->addEntity(entity) == TRUE) { // 4J-JEV: Hook for durango 'BlockPlaced' event. diff --git a/Minecraft.World/Items/HatchetItem.cpp b/Minecraft.World/Items/HatchetItem.cpp index a91931373..f763ed0e3 100644 --- a/Minecraft.World/Items/HatchetItem.cpp +++ b/Minecraft.World/Items/HatchetItem.cpp @@ -2,7 +2,7 @@ #include "../Headers/net.minecraft.world.level.tile.h" #include "HatchetItem.h" -TileArray* HatchetItem::diggables = NULL; +TileArray* HatchetItem::diggables = nullptr; void HatchetItem::staticCtor() { HatchetItem::diggables = new TileArray(HATCHET_DIGGABLES); @@ -23,7 +23,7 @@ HatchetItem::HatchetItem(int id, const Tier* tier) // 4J - brought forward from 1.2.3 float HatchetItem::getDestroySpeed(std::shared_ptr itemInstance, Tile* tile) { - if (tile != NULL && (tile->material == Material::wood || + if (tile != nullptr && (tile->material == Material::wood || tile->material == Material::plant || tile->material == Material::replaceable_plant)) { return speed; diff --git a/Minecraft.World/Items/Item.cpp b/Minecraft.World/Items/Item.cpp index 0cc1a2e5d..eabbe97d7 100644 --- a/Minecraft.World/Items/Item.cpp +++ b/Minecraft.World/Items/Item.cpp @@ -34,223 +34,223 @@ 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::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 = NULL; -Item* Item::shovel_wood = NULL; -Item* Item::pickAxe_wood = NULL; -Item* Item::hatchet_wood = NULL; +Item* Item::sword_wood = nullptr; +Item* Item::shovel_wood = nullptr; +Item* Item::pickAxe_wood = nullptr; +Item* Item::hatchet_wood = nullptr; -Item* Item::sword_stone = NULL; -Item* Item::shovel_stone = NULL; -Item* Item::pickAxe_stone = NULL; -Item* Item::hatchet_stone = NULL; +Item* Item::sword_stone = nullptr; +Item* Item::shovel_stone = nullptr; +Item* Item::pickAxe_stone = nullptr; +Item* Item::hatchet_stone = nullptr; -Item* Item::sword_diamond = NULL; -Item* Item::shovel_diamond = NULL; -Item* Item::pickAxe_diamond = NULL; -Item* Item::hatchet_diamond = NULL; +Item* Item::sword_diamond = nullptr; +Item* Item::shovel_diamond = nullptr; +Item* Item::pickAxe_diamond = nullptr; +Item* Item::hatchet_diamond = nullptr; -Item* Item::stick = NULL; -Item* Item::bowl = NULL; -Item* Item::mushroomStew = NULL; +Item* Item::stick = nullptr; +Item* Item::bowl = nullptr; +Item* Item::mushroomStew = nullptr; -Item* Item::sword_gold = NULL; -Item* Item::shovel_gold = NULL; -Item* Item::pickAxe_gold = NULL; -Item* Item::hatchet_gold = NULL; +Item* Item::sword_gold = nullptr; +Item* Item::shovel_gold = nullptr; +Item* Item::pickAxe_gold = nullptr; +Item* Item::hatchet_gold = nullptr; -Item* Item::string = NULL; -Item* Item::feather = NULL; -Item* Item::gunpowder = NULL; +Item* Item::string = nullptr; +Item* Item::feather = nullptr; +Item* Item::gunpowder = nullptr; -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::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 = NULL; -Item* Item::wheat = NULL; -Item* Item::bread = NULL; +Item* Item::seeds_wheat = nullptr; +Item* Item::wheat = nullptr; +Item* Item::bread = nullptr; -ArmorItem* Item::helmet_leather = NULL; -ArmorItem* Item::chestplate_leather = NULL; -ArmorItem* Item::leggings_leather = NULL; -ArmorItem* Item::boots_leather = NULL; +ArmorItem* Item::helmet_leather = nullptr; +ArmorItem* Item::chestplate_leather = nullptr; +ArmorItem* Item::leggings_leather = nullptr; +ArmorItem* Item::boots_leather = nullptr; -ArmorItem* Item::helmet_chain = NULL; -ArmorItem* Item::chestplate_chain = NULL; -ArmorItem* Item::leggings_chain = NULL; -ArmorItem* Item::boots_chain = NULL; +ArmorItem* Item::helmet_chain = nullptr; +ArmorItem* Item::chestplate_chain = nullptr; +ArmorItem* Item::leggings_chain = nullptr; +ArmorItem* Item::boots_chain = nullptr; -ArmorItem* Item::helmet_iron = NULL; -ArmorItem* Item::chestplate_iron = NULL; -ArmorItem* Item::leggings_iron = NULL; -ArmorItem* Item::boots_iron = NULL; +ArmorItem* Item::helmet_iron = nullptr; +ArmorItem* Item::chestplate_iron = nullptr; +ArmorItem* Item::leggings_iron = nullptr; +ArmorItem* Item::boots_iron = nullptr; -ArmorItem* Item::helmet_diamond = NULL; -ArmorItem* Item::chestplate_diamond = NULL; -ArmorItem* Item::leggings_diamond = NULL; -ArmorItem* Item::boots_diamond = NULL; +ArmorItem* Item::helmet_diamond = nullptr; +ArmorItem* Item::chestplate_diamond = nullptr; +ArmorItem* Item::leggings_diamond = nullptr; +ArmorItem* Item::boots_diamond = nullptr; -ArmorItem* Item::helmet_gold = NULL; -ArmorItem* Item::chestplate_gold = NULL; -ArmorItem* Item::leggings_gold = NULL; -ArmorItem* Item::boots_gold = NULL; +ArmorItem* Item::helmet_gold = nullptr; +ArmorItem* Item::chestplate_gold = nullptr; +ArmorItem* Item::leggings_gold = nullptr; +ArmorItem* Item::boots_gold = nullptr; -Item* Item::flint = NULL; -Item* Item::porkChop_raw = NULL; -Item* Item::porkChop_cooked = NULL; -Item* Item::painting = NULL; +Item* Item::flint = nullptr; +Item* Item::porkChop_raw = nullptr; +Item* Item::porkChop_cooked = nullptr; +Item* Item::painting = nullptr; -Item* Item::apple_gold = NULL; +Item* Item::apple_gold = nullptr; -Item* Item::sign = NULL; -Item* Item::door_wood = NULL; +Item* Item::sign = nullptr; +Item* Item::door_wood = nullptr; -Item* Item::bucket_empty = NULL; -Item* Item::bucket_water = NULL; -Item* Item::bucket_lava = NULL; +Item* Item::bucket_empty = nullptr; +Item* Item::bucket_water = nullptr; +Item* Item::bucket_lava = nullptr; -Item* Item::minecart = NULL; -Item* Item::saddle = NULL; -Item* Item::door_iron = NULL; -Item* Item::redStone = NULL; -Item* Item::snowBall = NULL; +Item* Item::minecart = nullptr; +Item* Item::saddle = nullptr; +Item* Item::door_iron = nullptr; +Item* Item::redStone = nullptr; +Item* Item::snowBall = nullptr; -Item* Item::boat = NULL; +Item* Item::boat = nullptr; -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::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 = NULL; -Item* Item::bone = NULL; -Item* Item::sugar = NULL; -Item* Item::cake = NULL; +Item* Item::dye_powder = nullptr; +Item* Item::bone = nullptr; +Item* Item::sugar = nullptr; +Item* Item::cake = nullptr; -Item* Item::bed = NULL; +Item* Item::bed = nullptr; -Item* Item::repeater = NULL; -Item* Item::cookie = NULL; +Item* Item::repeater = nullptr; +Item* Item::cookie = nullptr; -MapItem* Item::map = NULL; +MapItem* Item::map = nullptr; -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; +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 = NULL; +ShearsItem* Item::shears = nullptr; -Item* Item::melon = NULL; +Item* Item::melon = nullptr; -Item* Item::seeds_pumpkin = NULL; -Item* Item::seeds_melon = NULL; +Item* Item::seeds_pumpkin = nullptr; +Item* Item::seeds_melon = nullptr; -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::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 = NULL; +Item* Item::enderPearl = nullptr; -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::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 = NULL; +Item* Item::spawnEgg = nullptr; -Item* Item::expBottle = NULL; +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() { Item::sword_wood = @@ -1316,11 +1316,11 @@ int _Tier::getTierItemId() const { 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; @@ -1331,7 +1331,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); } @@ -1519,7 +1519,7 @@ bool Item::shouldOverrideMultiplayerNBT() { return true; } Item* Item::getCraftingRemainingItem() { return craftingRemainingItem; } -bool Item::hasCraftingRemainingItem() { return craftingRemainingItem != NULL; } +bool Item::hasCraftingRemainingItem() { return craftingRemainingItem != nullptr; } std::wstring Item::getName() { return L""; // I18n::get(getDescriptionId() + L".name"); diff --git a/Minecraft.World/Items/ItemInstance.cpp b/Minecraft.World/Items/ItemInstance.cpp index 64703f347..43e2e29e3 100644 --- a/Minecraft.World/Items/ItemInstance.cpp +++ b/Minecraft.World/Items/ItemInstance.cpp @@ -24,7 +24,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; @@ -61,17 +61,17 @@ std::shared_ptr ItemInstance::fromTag(CompoundTag* itemTag) { std::shared_ptr itemInstance = std::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; } std::shared_ptr ItemInstance::remove(int count) { std::shared_ptr ii = std::shared_ptr(new ItemInstance(id, count, auxValue)); - if (tag != NULL) ii->tag = (CompoundTag*)tag->copy(); + if (tag != nullptr) ii->tag = (CompoundTag*)tag->copy(); this->count -= count; // 4J Stu Fix for duplication glitch, make sure that item count is in range @@ -117,7 +117,7 @@ CompoundTag* ItemInstance::save(CompoundTag* compoundTag) { compoundTag->putShort(L"id", (short)id); compoundTag->putByte(L"Count", (uint8_t)count); compoundTag->putShort(L"Damage", (short)auxValue); - if (tag != NULL) compoundTag->put(L"tag", tag->copy()); + if (tag != nullptr) compoundTag->put(L"tag", tag->copy()); return compoundTag; } @@ -199,16 +199,16 @@ bool ItemInstance::hurt(int dmg, Random* random) { void ItemInstance::hurtAndBreak(int dmg, std::shared_ptr owner) { std::shared_ptr player = std::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())) { 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(); } } @@ -241,7 +241,7 @@ bool ItemInstance::interactEnemy(std::shared_ptr player, std::shared_ptr ItemInstance::copy() const { std::shared_ptr copy = std::shared_ptr(new ItemInstance(id, count, auxValue)); - if (tag != NULL) { + if (tag != nullptr) { copy->tag = (CompoundTag*)tag->copy(); } return copy; @@ -250,7 +250,7 @@ std::shared_ptr ItemInstance::copy() const { // 4J Stu - Added this as we need it in the recipe code ItemInstance* ItemInstance::copy_not_shared() const { ItemInstance* copy = new ItemInstance(id, count, auxValue); - if (tag != NULL) { + if (tag != nullptr) { copy->tag = (CompoundTag*)tag->copy(); if (!copy->tag->equals(tag)) { return copy; @@ -262,13 +262,13 @@ ItemInstance* ItemInstance::copy_not_shared() const { // 4J Brought forward from 1.2 bool ItemInstance::tagMatches(std::shared_ptr a, std::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; } return true; @@ -276,8 +276,8 @@ bool ItemInstance::tagMatches(std::shared_ptr a, bool ItemInstance::matches(std::shared_ptr a, std::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); } @@ -285,10 +285,10 @@ bool ItemInstance::matches(std::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; } return true; @@ -308,10 +308,10 @@ bool ItemInstance::sameItem(std::shared_ptr b) { bool ItemInstance::sameItemWithTags(std::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; } return true; @@ -340,7 +340,7 @@ ItemInstance* ItemInstance::setDescriptionId(unsigned int id) { std::shared_ptr ItemInstance::clone( std::shared_ptr item) { - return item == NULL ? nullptr : item->copy(); + return item == nullptr ? nullptr : item->copy(); } std::wstring ItemInstance::toString() { @@ -349,8 +349,8 @@ std::wstring ItemInstance::toString() { std::wostringstream oss; // 4J-PB - TODO - temp fix until ore recipe issue is fixed - if (Item::items[id] == NULL) { - oss << std::dec << count << L"x" << L" Item::items[id] is NULL " << L"@" + if (Item::items[id] == nullptr) { + oss << std::dec << count << L"x" << L" Item::items[id] is nullptr " << L"@" << auxValue; } else { oss << std::dec << count << L"x" @@ -397,13 +397,13 @@ void ItemInstance::releaseUsing(Level* level, std::shared_ptr player, } // 4J Stu - Brought forward these functions for enchanting/game rules -bool ItemInstance::hasTag() { return tag != NULL; } +bool ItemInstance::hasTag() { return tag != nullptr; } CompoundTag* ItemInstance::getTag() { return tag; } ListTag* ItemInstance::getEnchantmentTags() { - if (tag == NULL) { - return NULL; + if (tag == nullptr) { + return nullptr; } return (ListTag*)tag->get(L"ench"); } @@ -416,7 +416,7 @@ void ItemInstance::setTag(CompoundTag* tag) { std::wstring ItemInstance::getHoverName() { std::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"); if (display->contains(L"Name")) { @@ -428,14 +428,14 @@ std::wstring ItemInstance::getHoverName() { } void ItemInstance::setHoverName(const std::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"); @@ -444,13 +444,13 @@ void ItemInstance::resetHoverName() { tag->remove(L"display"); 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"); } @@ -505,12 +505,12 @@ std::vector* ItemInstance::getHoverText( 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) { std::wstring unformatted = L""; lines->push_back( Enchantment::enchantments[type]->getFullname( @@ -568,12 +568,12 @@ std::vector* ItemInstance::getHoverText( 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) { std::wstring unformatted = L""; lines->push_back( Enchantment::enchantments[type]->getFullname(level)); @@ -660,12 +660,12 @@ std::vector* ItemInstance::getHoverTextOnly( 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) { std::wstring unformatted = L""; lines->push_back( Enchantment::enchantments[type]->getFullname(level)); @@ -689,7 +689,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")); @@ -701,12 +701,12 @@ 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(std::wstring name, Tag* tag) { - if (this->tag == NULL) { + if (this->tag == nullptr) { setTag(new CompoundTag()); } this->tag->put((wchar_t*)name.c_str(), tag); @@ -716,7 +716,7 @@ bool ItemInstance::mayBePlacedInAdventureMode() { return getItem()->mayBePlacedInAdventureMode(); } -bool ItemInstance::isFramed() { return frame != NULL; } +bool ItemInstance::isFramed() { return frame != nullptr; } void ItemInstance::setFramed(std::shared_ptr frame) { this->frame = frame; @@ -738,7 +738,7 @@ void ItemInstance::setRepairCost(int cost) { } attrAttrModMap* ItemInstance::getAttributeModifiers() { - attrAttrModMap* result = NULL; + attrAttrModMap* result = nullptr; if (hasTag() && tag->contains(L"AttributeModifiers")) { result = new attrAttrModMap(); @@ -767,8 +767,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")) { IntTag* dataTag = (IntTag*)tag->get(L"4jdata"); @@ -779,7 +779,7 @@ void ItemInstance::set4JData(int data) { } int ItemInstance::get4JData() { - if (tag == NULL || !tag->contains(L"4jdata")) + if (tag == nullptr || !tag->contains(L"4jdata")) return 0; else { IntTag* dataTag = (IntTag*)tag->get(L"4jdata"); diff --git a/Minecraft.World/Items/LeashItem.cpp b/Minecraft.World/Items/LeashItem.cpp index 1139a5d86..e36ddf2ce 100644 --- a/Minecraft.World/Items/LeashItem.cpp +++ b/Minecraft.World/Items/LeashItem.cpp @@ -13,7 +13,7 @@ bool LeashItem::useOn(std::shared_ptr itemInstance, 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 && + if (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE) { if (bTestUseOnOnly) return bindPlayerMobsTest(player, level, x, y, z); @@ -39,11 +39,11 @@ bool LeashItem::bindPlayerMobs(std::shared_ptr player, Level* level, AABB mob_bb = AABB(x, y, z, x, y, z).grow(range, range, range); std::vector >* mobs = level->getEntitiesOfClass(typeid(Mob), &mob_bb); - if (mobs != NULL) { + if (mobs != nullptr) { for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) { std::shared_ptr mob = std::dynamic_pointer_cast(*it); if (mob->isLeashed() && mob->getLeashHolder() == player) { - if (activeKnot == NULL) { + if (activeKnot == nullptr) { activeKnot = LeashFenceKnotEntity::createAndAddKnot(level, x, y, z); } @@ -64,7 +64,7 @@ bool LeashItem::bindPlayerMobsTest(std::shared_ptr player, Level* level, std::vector >* mobs = level->getEntitiesOfClass(typeid(Mob), &mob_bb); - if (mobs != NULL) { + if (mobs != nullptr) { for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) { std::shared_ptr mob = std::dynamic_pointer_cast(*it); if (mob->isLeashed() && mob->getLeashHolder() == player) diff --git a/Minecraft.World/Items/MapItem.cpp b/Minecraft.World/Items/MapItem.cpp index d482f0b67..1dc1a0bbd 100644 --- a/Minecraft.World/Items/MapItem.cpp +++ b/Minecraft.World/Items/MapItem.cpp @@ -23,7 +23,7 @@ std::shared_ptr MapItem::getSavedData(short idNum, std::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 @@ -51,7 +51,7 @@ std::shared_ptr MapItem::getSavedData( 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 @@ std::shared_ptr MapItem::getUpdatePacket( 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; std::shared_ptr retval = std::shared_ptr(new ComplexItemDataPacket( @@ -330,7 +330,7 @@ void MapItem::onCraftedBy(std::shared_ptr itemInstance, 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 = std::shared_ptr(new MapItemSavedData(id)); } level->setSavedData(id, (std::shared_ptr)data); diff --git a/Minecraft.World/Items/NameTagItem.cpp b/Minecraft.World/Items/NameTagItem.cpp index 1b3f7938d..0890b8f35 100644 --- a/Minecraft.World/Items/NameTagItem.cpp +++ b/Minecraft.World/Items/NameTagItem.cpp @@ -9,7 +9,7 @@ bool NameTagItem::interactEnemy(std::shared_ptr itemInstance, std::shared_ptr target) { if (!itemInstance->hasCustomHoverName()) return false; - if ((target != NULL) && target->instanceof(eTYPE_MOB)) { + if ((target != nullptr) && target->instanceof(eTYPE_MOB)) { std::shared_ptr mob = std::dynamic_pointer_cast(target); mob->setCustomName(itemInstance->getHoverName()); mob->setPersistenceRequired(); diff --git a/Minecraft.World/Items/PickaxeItem.cpp b/Minecraft.World/Items/PickaxeItem.cpp index 88076ff22..03c19a4e4 100644 --- a/Minecraft.World/Items/PickaxeItem.cpp +++ b/Minecraft.World/Items/PickaxeItem.cpp @@ -57,7 +57,7 @@ bool PickaxeItem::canDestroySpecial(Tile* tile) { // 4J - brought forward from 1.2.3 float PickaxeItem::getDestroySpeed(std::shared_ptr itemInstance, Tile* tile) { - if (tile != NULL && (tile->material == Material::metal || + if (tile != nullptr && (tile->material == Material::metal || tile->material == Material::heavyMetal || tile->material == Material::stone)) { return speed; diff --git a/Minecraft.World/Items/PotionItem.cpp b/Minecraft.World/Items/PotionItem.cpp index 15fd1e77f..be2552ddb 100644 --- a/Minecraft.World/Items/PotionItem.cpp +++ b/Minecraft.World/Items/PotionItem.cpp @@ -25,25 +25,25 @@ PotionItem::PotionItem(int id) : Item(id) { setStackedByData(true); setMaxDamage(0); - iconThrowable = NULL; - iconDrinkable = NULL; - iconOverlay = NULL; + iconThrowable = nullptr; + iconDrinkable = nullptr; + iconOverlay = nullptr; } std::vector* PotionItem::getMobEffects( std::shared_ptr potion) { if (!potion->hasTag() || !potion->getTag()->contains(L"CustomPotionEffects")) { - std::vector* effects = NULL; + std::vector* effects = nullptr; AUTO_VAR(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 + return effects == nullptr ? nullptr : new std::vector(*effects); } else { std::vector* effects = @@ -62,12 +62,12 @@ std::vector* PotionItem::getMobEffects( } std::vector* PotionItem::getMobEffects(int auxValue) { - std::vector* effects = NULL; + std::vector* effects = nullptr; AUTO_VAR(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) + if (effects != nullptr) cachedMobEffects.insert( std::pair*>(auxValue, effects)); @@ -82,7 +82,7 @@ std::shared_ptr PotionItem::useTimeDepleted( if (!level->isClientSide) { std::vector* effects = getMobEffects(instance); - if (effects != NULL) { + if (effects != nullptr) { // for (MobEffectInstance effect : effects) for (AUTO_VAR(it, effects->begin()); it != effects->end(); ++it) { player->addEffect(new MobEffectInstance(*it)); @@ -172,7 +172,7 @@ bool PotionItem::hasMultipleSpriteLayers() { return true; } bool PotionItem::hasInstantenousEffects(int itemAuxValue) { std::vector* mobEffects = getMobEffects(itemAuxValue); - if (mobEffects == NULL || mobEffects->empty()) { + if (mobEffects == nullptr || mobEffects->empty()) { return false; } // for (MobEffectInstance effect : mobEffects) { @@ -204,7 +204,7 @@ std::wstring PotionItem::getHoverName( std::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"; // return elementName + " " + I18n.get(postfixString).trim(); @@ -236,7 +236,7 @@ void PotionItem::appendHoverText(std::shared_ptr itemInstance, std::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_VAR(it, effects->begin()); it != effects->end(); ++it) { MobEffectInstance* effect = *it; @@ -247,7 +247,7 @@ void PotionItem::appendHoverText(std::shared_ptr itemInstance, std::unordered_map* effectModifiers = mobEffect->getAttributeModifiers(); - if (effectModifiers != NULL && effectModifiers->size() > 0) { + if (effectModifiers != nullptr && effectModifiers->size() > 0) { for (AUTO_VAR(it, effectModifiers->begin()); it != effectModifiers->end(); ++it) { // 4J - anonymous modifiers added here are destroyed @@ -327,7 +327,7 @@ void PotionItem::appendHoverText(std::shared_ptr itemInstance, bool PotionItem::isFoil(std::shared_ptr itemInstance) { std::vector* mobEffects = getMobEffects(itemInstance); - return mobEffects != NULL && !mobEffects->empty(); + return mobEffects != nullptr && !mobEffects->empty(); } unsigned int PotionItem::getUseDescriptionId( @@ -370,7 +370,7 @@ Icon* PotionItem::getTexture(const std::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; } // 4J Stu - Based loosely on a function that gets added in java much later on @@ -381,7 +381,7 @@ std::vector >* PotionItem::getUniquePotionValues() { std::vector* effects = PotionBrewing::getEffects(brew, false); - if (effects != NULL) { + if (effects != nullptr) { if (!effects->empty()) { // 4J Stu - Based on implementation of Java List.hashCode() // at @@ -392,7 +392,7 @@ std::vector >* PotionItem::getUniquePotionValues() { ++it) { MobEffectInstance* mei = *it; effectsHashCode = 31 * effectsHashCode + - (mei == NULL ? 0 : mei->hashCode()); + (mei == nullptr ? 0 : mei->hashCode()); delete (*it); } diff --git a/Minecraft.World/Items/RecordingItem.cpp b/Minecraft.World/Items/RecordingItem.cpp index 3a9a280d0..0b0998ec7 100644 --- a/Minecraft.World/Items/RecordingItem.cpp +++ b/Minecraft.World/Items/RecordingItem.cpp @@ -68,6 +68,6 @@ RecordingItem* RecordingItem::getByName(const std::wstring& name) { if (it != BY_NAME.end()) { return it->second; } else { - return NULL; + return nullptr; } } \ No newline at end of file diff --git a/Minecraft.World/Items/SaddleItem.cpp b/Minecraft.World/Items/SaddleItem.cpp index 811878ba6..a7a1544ff 100644 --- a/Minecraft.World/Items/SaddleItem.cpp +++ b/Minecraft.World/Items/SaddleItem.cpp @@ -9,7 +9,7 @@ SaddleItem::SaddleItem(int id) : Item(id) { maxStackSize = 1; } bool SaddleItem::interactEnemy(std::shared_ptr itemInstance, std::shared_ptr player, std::shared_ptr mob) { - if ((mob != NULL) && mob->instanceof(eTYPE_PIG)) { + if ((mob != nullptr) && mob->instanceof(eTYPE_PIG)) { std::shared_ptr pig = std::dynamic_pointer_cast(mob); if (!pig->hasSaddle() && !pig->isBaby()) { pig->setSaddle(true); diff --git a/Minecraft.World/Items/ShovelItem.cpp b/Minecraft.World/Items/ShovelItem.cpp index a96fa3c47..cebb309a7 100644 --- a/Minecraft.World/Items/ShovelItem.cpp +++ b/Minecraft.World/Items/ShovelItem.cpp @@ -3,7 +3,7 @@ #include "../Headers/net.minecraft.world.level.tile.h" #include "ShovelItem.h" -TileArray* ShovelItem::diggables = NULL; +TileArray* ShovelItem::diggables = nullptr; void ShovelItem::staticCtor() { ShovelItem::diggables = new TileArray(SHOVEL_DIGGABLES); diff --git a/Minecraft.World/Items/SignItem.cpp b/Minecraft.World/Items/SignItem.cpp index eb07576f3..f24b7d206 100644 --- a/Minecraft.World/Items/SignItem.cpp +++ b/Minecraft.World/Items/SignItem.cpp @@ -48,7 +48,7 @@ bool SignItem::useOn(std::shared_ptr instance, std::shared_ptr ste = std::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(GenericStats::blocksPlaced( diff --git a/Minecraft.World/Items/SpawnEggItem.cpp b/Minecraft.World/Items/SpawnEggItem.cpp index bf6b24582..f9c5f4b22 100644 --- a/Minecraft.World/Items/SpawnEggItem.cpp +++ b/Minecraft.World/Items/SpawnEggItem.cpp @@ -15,7 +15,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; } std::wstring SpawnEggItem::getHoverName( @@ -62,7 +62,7 @@ Icon* SpawnEggItem::getLayerIcon(int auxValue, int spriteLayer) { std::shared_ptr SpawnEggItem::canSpawn(int iAuxVal, Level* level, int* piResult) { std::shared_ptr newEntity = EntityIO::newById(iAuxVal, level); - if (newEntity != NULL) { + if (newEntity != nullptr) { bool canSpawn = false; switch (newEntity->GetType()) { @@ -172,7 +172,7 @@ bool SpawnEggItem::useOn(std::shared_ptr itemInstance, std::shared_ptr mste = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (mste != NULL) { + if (mste != nullptr) { mste->setEntityId( EntityIO::getEncodeId(itemInstance->getAuxValue())); return true; @@ -186,7 +186,7 @@ bool SpawnEggItem::useOn(std::shared_ptr itemInstance, double yOff = 0; if (face == Facing::UP && - (Tile::tiles[tile] != NULL && + (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE)) { // special case yOff = .5; @@ -197,10 +197,10 @@ bool SpawnEggItem::useOn(std::shared_ptr itemInstance, level, itemInstance->getAuxValue(), x + .5, y + yOff, z + .5, &iResult); if (bTestUseOnOnly) { - return result != NULL; + return result != nullptr; } - 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) && @@ -224,7 +224,7 @@ std::shared_ptr SpawnEggItem::use( if (level->isClientSide) return itemInstance; HitResult* hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) { + if (hr == nullptr) { delete hr; return itemInstance; } @@ -245,7 +245,7 @@ std::shared_ptr SpawnEggItem::use( int iResult = 0; std::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) && @@ -286,7 +286,7 @@ std::shared_ptr SpawnEggItem::spawnMobAt(Level* level, int auxVal, // 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)) { std::shared_ptr mob = std::dynamic_pointer_cast(newEntity); newEntity->moveTo( @@ -298,7 +298,7 @@ std::shared_ptr SpawnEggItem::spawnMobAt(Level* level, int auxVal, 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/Items/TileItems/ColoredTileItem.cpp b/Minecraft.World/Items/TileItems/ColoredTileItem.cpp index 06cb241e0..0cebe5356 100644 --- a/Minecraft.World/Items/TileItems/ColoredTileItem.cpp +++ b/Minecraft.World/Items/TileItems/ColoredTileItem.cpp @@ -12,7 +12,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(std::shared_ptr item, @@ -28,7 +28,7 @@ int ColoredTileItem::getLevelDataForAuxValue(int auxValue) { return auxValue; } ColoredTileItem* ColoredTileItem::setDescriptionPostfixes( intArray descriptionPostfixes) { - if (this->descriptionPostfixes.data != NULL) + if (this->descriptionPostfixes.data != nullptr) delete this->descriptionPostfixes.data; this->descriptionPostfixes = intArray(descriptionPostfixes.length); for (unsigned int i = 0; i < descriptionPostfixes.length; ++i) { @@ -40,7 +40,7 @@ ColoredTileItem* ColoredTileItem::setDescriptionPostfixes( unsigned int ColoredTileItem::getDescriptionId( std::shared_ptr instance) { - if (descriptionPostfixes.data == NULL) { + if (descriptionPostfixes.data == nullptr) { return TileItem::getDescriptionId(instance); } int id = instance->getAuxValue(); diff --git a/Minecraft.World/Items/TileItems/SkullItem.cpp b/Minecraft.World/Items/TileItems/SkullItem.cpp index 8679b57b7..fb7a581be 100644 --- a/Minecraft.World/Items/TileItems/SkullItem.cpp +++ b/Minecraft.World/Items/TileItems/SkullItem.cpp @@ -54,7 +54,7 @@ bool SkullItem::useOn( std::shared_ptr skull = std::dynamic_pointer_cast(skullTE); - if (skull != NULL) { + if (skull != nullptr) { std::wstring extra = L""; if (instance->hasTag() && instance->getTag()->contains(L"SkullOwner")) { diff --git a/Minecraft.World/Items/TileItems/TileItem.cpp b/Minecraft.World/Items/TileItems/TileItem.cpp index 97af95d78..df2924593 100644 --- a/Minecraft.World/Items/TileItems/TileItem.cpp +++ b/Minecraft.World/Items/TileItems/TileItem.cpp @@ -18,7 +18,7 @@ TileItem::TileItem(int id) : Item(id) { this->tileId = id + 256; - itemIcon = NULL; + itemIcon = nullptr; } int TileItem::getTileId() { return tileId; } @@ -31,7 +31,7 @@ int TileItem::getIconType() { } Icon* TileItem::getIcon(int auxValue) { - if (itemIcon != NULL) { + if (itemIcon != nullptr) { return itemIcon; } return Tile::tiles[tileId]->getTexture(Facing::UP, auxValue); @@ -135,7 +135,7 @@ bool TileItem::useOn(std::shared_ptr instance, // // if(iPlaceSound==-1) // { - // strcpy(szPlaceSoundName,"NULL"); + // strcpy(szPlaceSoundName,"nullptr"); // } // else // { @@ -143,7 +143,7 @@ bool TileItem::useOn(std::shared_ptr instance, // } // if(iStepSound==-1) // { - // strcpy(szStepSoundName,"NULL"); + // strcpy(szStepSoundName,"nullptr"); // } // else // { diff --git a/Minecraft.World/Items/TileItems/WaterLilyTileItem.cpp b/Minecraft.World/Items/TileItems/WaterLilyTileItem.cpp index 8cc59b628..ce6c6bd54 100644 --- a/Minecraft.World/Items/TileItems/WaterLilyTileItem.cpp +++ b/Minecraft.World/Items/TileItems/WaterLilyTileItem.cpp @@ -11,7 +11,7 @@ WaterLilyTileItem::WaterLilyTileItem(int id) : ColoredTileItem(id, false) {} bool WaterLilyTileItem::TestUse(std::shared_ptr itemInstance, Level* level, std::shared_ptr player) { HitResult* hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) return false; + if (hr == nullptr) return false; if (hr->type == HitResult::TILE) { int xt = hr->x; @@ -42,7 +42,7 @@ std::shared_ptr WaterLilyTileItem::use( std::shared_ptr itemInstance, Level* level, std::shared_ptr player) { HitResult* hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) return itemInstance; + if (hr == nullptr) return itemInstance; if (hr->type == HitResult::TILE) { int xt = hr->x; diff --git a/Minecraft.World/Level/BaseMobSpawner.cpp b/Minecraft.World/Level/BaseMobSpawner.cpp index bf6fcb51c..53835dcaa 100644 --- a/Minecraft.World/Level/BaseMobSpawner.cpp +++ b/Minecraft.World/Level/BaseMobSpawner.cpp @@ -7,10 +7,10 @@ #include "BaseMobSpawner.h" 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; @@ -33,7 +33,7 @@ BaseMobSpawner::~BaseMobSpawner() { } std::wstring BaseMobSpawner::getEntityId() { - if (getNextSpawnData() == NULL) { + if (getNextSpawnData() == nullptr) { if (entityId.compare(L"Minecart") == 0) { entityId = L"MinecartRideable"; } @@ -50,7 +50,7 @@ void BaseMobSpawner::setEntityId(const std::wstring& entityId) { bool BaseMobSpawner::isNearPlayer() { return getLevel()->getNearestPlayer(getX() + 0.5, getY() + 0.5, getZ() + 0.5, - requiredPlayerRange) != NULL; + requiredPlayerRange) != nullptr; } void BaseMobSpawner::tick() { @@ -81,7 +81,7 @@ void BaseMobSpawner::tick() { for (int c = 0; c < spawnCount; c++) { std::shared_ptr entity = EntityIO::newEntity(getEntityId(), getLevel()); - if (entity == NULL) return; + if (entity == nullptr) return; AABB grown = AABB(getX(), getY(), getZ(), getX() + 1, getY() + 1, getZ() + 1) @@ -110,12 +110,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(); } @@ -129,7 +129,7 @@ void BaseMobSpawner::tick() { std::shared_ptr BaseMobSpawner::loadDataAndAddEntity( std::shared_ptr entity) { - if (getNextSpawnData() != NULL) { + if (getNextSpawnData() != nullptr) { CompoundTag* data = new CompoundTag(); entity->save(data); @@ -141,7 +141,7 @@ std::shared_ptr BaseMobSpawner::loadDataAndAddEntity( delete tags; entity->load(data); - if (entity->level != NULL) entity->level->addEntity(entity); + if (entity->level != nullptr) entity->level->addEntity(entity); // add mounts std::shared_ptr rider = entity; @@ -149,7 +149,7 @@ std::shared_ptr BaseMobSpawner::loadDataAndAddEntity( CompoundTag* ridingTag = data->getCompound(Entity::RIDING_TAG); std::shared_ptr mount = EntityIO::newEntity(ridingTag->getString(L"id"), entity->level); - if (mount != NULL) { + if (mount != nullptr) { CompoundTag* mountData = new CompoundTag(); mount->save(mountData); @@ -164,7 +164,7 @@ std::shared_ptr BaseMobSpawner::loadDataAndAddEntity( 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; @@ -172,8 +172,8 @@ std::shared_ptr BaseMobSpawner::loadDataAndAddEntity( } } else if (entity->instanceof(eTYPE_LIVINGENTITY) && - entity->level != NULL) { - std::dynamic_pointer_cast(entity)->finalizeMobSpawn(NULL); + entity->level != nullptr) { + std::dynamic_pointer_cast(entity)->finalizeMobSpawn(nullptr); getLevel()->addEntity(entity); } @@ -188,7 +188,7 @@ void BaseMobSpawner::delay() { getLevel()->random->nextInt(maxSpawnDelay - minSpawnDelay); } - if ((spawnPotentials != NULL) && (spawnPotentials->size() > 0)) { + if ((spawnPotentials != nullptr) && (spawnPotentials->size() > 0)) { setNextSpawnData((SpawnData*)WeighedRandom::getRandomItem( (Random*)getLevel()->random, (std::vector*)spawnPotentials)); @@ -210,14 +210,14 @@ void BaseMobSpawner::load(CompoundTag* tag) { spawnPotentials->push_back(new SpawnData(potentials->get(i))); } } else { - spawnPotentials = NULL; + spawnPotentials = nullptr; } if (tag->contains(L"SpawnData")) { setNextSpawnData( new SpawnData(tag->getCompound(L"SpawnData"), entityId)); } else { - setNextSpawnData(NULL); + setNextSpawnData(nullptr); } if (tag->contains(L"MinSpawnDelay")) { @@ -233,7 +233,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; } } @@ -248,16 +248,16 @@ void BaseMobSpawner::save(CompoundTag* tag) { tag->putShort(L"RequiredPlayerRange", (short)requiredPlayerRange); tag->putShort(L"SpawnRange", (short)spawnRange); - if (getNextSpawnData() != NULL) { + if (getNextSpawnData() != nullptr) { tag->putCompound(L"SpawnData", (CompoundTag*)getNextSpawnData()->tag->copy()); } - if (getNextSpawnData() != NULL || - (spawnPotentials != NULL && spawnPotentials->size() > 0)) { + if (getNextSpawnData() != nullptr || + (spawnPotentials != nullptr && spawnPotentials->size() > 0)) { ListTag* list = new ListTag(); - if (spawnPotentials != NULL && spawnPotentials->size() > 0) { + if (spawnPotentials != nullptr && spawnPotentials->size() > 0) { for (AUTO_VAR(it, spawnPotentials->begin()); it != spawnPotentials->end(); ++it) { SpawnData* data = *it; @@ -272,8 +272,8 @@ void BaseMobSpawner::save(CompoundTag* tag) { } std::shared_ptr BaseMobSpawner::getDisplayEntity() { - if (displayEntity == NULL) { - std::shared_ptr e = EntityIO::newEntity(getEntityId(), NULL); + if (displayEntity == nullptr) { + std::shared_ptr e = EntityIO::newEntity(getEntityId(), nullptr); e = loadDataAndAddEntity(e); displayEntity = e; } @@ -303,7 +303,7 @@ BaseMobSpawner::SpawnData::SpawnData(CompoundTag* base) std::wstring _type = base->getString(L"Type"); if (_type.compare(L"Minecart") == 0) { - if (tag != NULL) { + if (tag != nullptr) { switch (tag->getInt(L"Type")) { case Minecart::TYPE_CHEST: type = L"MinecartChest"; @@ -327,7 +327,7 @@ BaseMobSpawner::SpawnData::SpawnData(CompoundTag* base) BaseMobSpawner::SpawnData::SpawnData(CompoundTag* tag, std::wstring _type) : WeighedRandomItem(1) { if (_type.compare(L"Minecart") == 0) { - if (tag != NULL) { + if (tag != nullptr) { switch (tag->getInt(L"Type")) { case Minecart::TYPE_CHEST: _type = L"MinecartChest"; diff --git a/Minecraft.World/Level/BlockReplacements.cpp b/Minecraft.World/Level/BlockReplacements.cpp index 1dd785ece..94a9e26dc 100644 --- a/Minecraft.World/Level/BlockReplacements.cpp +++ b/Minecraft.World/Level/BlockReplacements.cpp @@ -7,7 +7,7 @@ byteArray BlockReplacements::replacements = byteArray(256); void BlockReplacements::staticCtor() { for (int i = 0; i < 256; i++) { uint8_t b = (uint8_t)i; - if (b != 0 && Tile::tiles[b & 0xff] == NULL) { + if (b != 0 && Tile::tiles[b & 0xff] == nullptr) { b = 0; } BlockReplacements::replacements[i] = b; diff --git a/Minecraft.World/Level/ChunkSource.h b/Minecraft.World/Level/ChunkSource.h index 335ef94f6..24215175a 100644 --- a/Minecraft.World/Level/ChunkSource.h +++ b/Minecraft.World/Level/ChunkSource.h @@ -73,7 +73,7 @@ public: 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/Level/CustomLevelSource.cpp b/Minecraft.World/Level/CustomLevelSource.cpp index 107082b74..c4becd6e7 100644 --- a/Minecraft.World/Level/CustomLevelSource.cpp +++ b/Minecraft.World/Level/CustomLevelSource.cpp @@ -31,20 +31,20 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed, std::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(); DWORD error = GetLastError(); assert(false); } else { - DWORD bytesRead, dwFileSize = GetFileSize(file, NULL); + DWORD bytesRead, dwFileSize = GetFileSize(file, nullptr); if (dwFileSize > m_heightmapOverride.length) { app.DebugPrintf("Heightmap binary is too large!!\n"); __debugbreak(); } BOOL bSuccess = ReadFile(file, m_heightmapOverride.data, dwFileSize, - &bytesRead, NULL); + &bytesRead, nullptr); if (bSuccess == FALSE) { app.FatalLoadError(); @@ -64,21 +64,21 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed, std::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(); // assert(false); memset(m_waterheightOverride.data, level->seaLevel, m_waterheightOverride.length); } else { - DWORD bytesRead, dwFileSize = GetFileSize(file, NULL); + DWORD bytesRead, dwFileSize = GetFileSize(file, nullptr); if (dwFileSize > m_waterheightOverride.length) { app.DebugPrintf("waterheight binary is too large!!\n"); __debugbreak(); } BOOL bSuccess = ReadFile(file, m_waterheightOverride.data, dwFileSize, - &bytesRead, NULL); + &bytesRead, nullptr); if (bSuccess == FALSE) { app.FatalLoadError(); @@ -270,7 +270,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, uint8_t material = b->material; LevelGenerationOptions* lgo = app.getLevelGenerationOptions(); - if (lgo != NULL) { + if (lgo != nullptr) { lgo->getBiomeOverride(b->id, material, top); } @@ -306,7 +306,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, y <= waterHeight + 1) { top = b->topMaterial; material = b->material; - if (lgo != NULL) { + if (lgo != nullptr) { lgo->getBiomeOverride(b->id, material, top); } } @@ -348,7 +348,7 @@ LevelChunk* CustomLevelSource::create(int x, int z) { #if defined(_OVERRIDE_HEIGHTMAP) return getChunk(x, z); #else - return NULL; + return nullptr; #endif } @@ -408,7 +408,7 @@ LevelChunk* CustomLevelSource::getChunk(int xOffs, int zOffs) { return levelChunk; #else - return NULL; + return nullptr; #endif } @@ -590,8 +590,8 @@ std::vector* CustomLevelSource::getMobsAt( MobCategory* mobCategory, int x, int y, int z) { #if defined(_OVERRIDE_HEIGHTMAP) Biome* biome = level->getBiome(x, z); - if (biome == NULL) { - return NULL; + if (biome == nullptr) { + return nullptr; } if (mobCategory == MobCategory::monster && scatteredFeature->isSwamphut(x, y, z)) { @@ -599,18 +599,18 @@ std::vector* CustomLevelSource::getMobsAt( } return biome->getMobs(mobCategory); #else - return NULL; + return nullptr; #endif } TilePos* CustomLevelSource::findNearestMapFeature( Level* level, const std::wstring& featureName, int x, int y, int z) { #if defined(_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, diff --git a/Minecraft.World/Level/Dimensions/Dimension.cpp b/Minecraft.World/Level/Dimensions/Dimension.cpp index 0af723d87..881405671 100644 --- a/Minecraft.World/Level/Dimensions/Dimension.cpp +++ b/Minecraft.World/Level/Dimensions/Dimension.cpp @@ -66,7 +66,7 @@ Dimension::Dimension() { Dimension::~Dimension() { delete[] brightnessRamp; - if (biomeSource != NULL) delete biomeSource; + if (biomeSource != nullptr) delete biomeSource; } ChunkSource* Dimension::createRandomLevelSource() const { @@ -154,7 +154,7 @@ float* Dimension::getSunriseColor(float td, float a) { return sunriseCol; } - return NULL; + return nullptr; } Vec3 Dimension::getFogColor(float td, float a) const { @@ -182,14 +182,14 @@ Dimension* Dimension::getNew(int id) { if (id == 0) return new NormalDimension(); if (id == 1) return new TheEndDimension(); - return NULL; + return nullptr; } float Dimension::getCloudHeight() { return (float)Level::genDepth; } bool Dimension::hasGround() { return true; } -Pos* Dimension::getSpawnPos() { return NULL; } +Pos* Dimension::getSpawnPos() { return nullptr; } int Dimension::getSpawnYPosition() { if (levelType == LevelType::lvl_flat) { diff --git a/Minecraft.World/Level/Dimensions/SkyIslandDimension.cpp b/Minecraft.World/Level/Dimensions/SkyIslandDimension.cpp index 07cb4fe4b..cb7c8ad56 100644 --- a/Minecraft.World/Level/Dimensions/SkyIslandDimension.cpp +++ b/Minecraft.World/Level/Dimensions/SkyIslandDimension.cpp @@ -18,7 +18,7 @@ float SkyIslandDimension::getTimeOfDay(int64_t time, float a) const { return 0.0f; } -float* SkyIslandDimension::getSunriseColor(float td, float a) { return NULL; } +float* SkyIslandDimension::getSunriseColor(float td, float a) { return nullptr; } Vec3 SkyIslandDimension::getFogColor(float td, float a) const { int fogColor = 0x8080a0; diff --git a/Minecraft.World/Level/Dimensions/TheEndDimension.cpp b/Minecraft.World/Level/Dimensions/TheEndDimension.cpp index d1b40addb..ed6bf28bf 100644 --- a/Minecraft.World/Level/Dimensions/TheEndDimension.cpp +++ b/Minecraft.World/Level/Dimensions/TheEndDimension.cpp @@ -21,7 +21,7 @@ float TheEndDimension::getTimeOfDay(int64_t time, float a) const { return 0.0f; } -float* TheEndDimension::getSunriseColor(float td, float a) { return NULL; } +float* TheEndDimension::getSunriseColor(float td, float a) { return nullptr; } Vec3 TheEndDimension::getFogColor(float td, float a) const { int fogColor = Minecraft::GetInstance()->getColourTable()->getColor( diff --git a/Minecraft.World/Level/Events/VillageSiege.cpp b/Minecraft.World/Level/Events/VillageSiege.cpp index abf2dc517..ed1f597fd 100644 --- a/Minecraft.World/Level/Events/VillageSiege.cpp +++ b/Minecraft.World/Level/Events/VillageSiege.cpp @@ -74,7 +74,7 @@ bool VillageSiege::tryToSetupSiege() { (int)player->x, (int)player->y, (int)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; @@ -126,7 +126,7 @@ bool VillageSiege::trySpawn() { // try { mob = std::shared_ptr(new Zombie(level)); - mob->finalizeMobSpawn(NULL); + mob->finalizeMobSpawn(nullptr); mob->setVillager(false); } // catch (Exception e) { @@ -137,7 +137,7 @@ bool VillageSiege::trySpawn() { level->random->nextFloat() * 360, 0); level->addEntity(mob); std::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()); @@ -146,7 +146,7 @@ bool VillageSiege::trySpawn() { std::optional VillageSiege::findRandomSpawnPos(int x, int y, int z) { std::shared_ptr _village = village.lock(); - if (_village == NULL) return std::nullopt; + if (_village == nullptr) return std::nullopt; for (int i = 0; i < 10; ++i) { int xx = x + level->random->nextInt(16) - 8; diff --git a/Minecraft.World/Level/Explosion.cpp b/Minecraft.World/Level/Explosion.cpp index 9be40d49b..3624f6e12 100644 --- a/Minecraft.World/Level/Explosion.cpp +++ b/Minecraft.World/Level/Explosion.cpp @@ -64,14 +64,14 @@ void Explosion::explode() { if (t > 0) { Tile* tile = Tile::tiles[t]; float resistance = - source != NULL + source != nullptr ? source->getTileExplosionResistance( this, level, xt, yt, zt, tile) : tile->getExplosionResistance(source); remainingPower -= (resistance + 0.3f) * stepSize; } if (remainingPower > 0 && - (source == NULL || + (source == nullptr || source->shouldTileExplode(this, level, xt, yt, zt, t, remainingPower))) { toBlow.insert(TilePos(xt, yt, zt)); @@ -173,7 +173,7 @@ void Explosion::explode() { void Explosion::finalizeExplosion( bool generateParticles, std::vector* - toBlowDirect /*=NULL*/) // 4J - added toBlowDirect parameter + toBlowDirect /*=nullptr*/) // 4J - added toBlowDirect parameter { level->playSound( x, y, z, eSoundType_RANDOM_EXPLODE, 4, @@ -276,7 +276,7 @@ void Explosion::finalizeExplosion( } PIXEndNamedEvent(); - if (toBlowDirect == NULL) delete toBlowArray; + if (toBlowDirect == nullptr) delete toBlowArray; } Explosion::playerVec3Map* Explosion::getHitPlayers() { return &hitPlayers; } @@ -290,7 +290,7 @@ Vec3 Explosion::getHitPlayerKnockback(std::shared_ptr player) { } std::shared_ptr Explosion::getSourceMob() { - if (source == NULL) return nullptr; + if (source == nullptr) return nullptr; if (source->instanceof(eTYPE_PRIMEDTNT)) return std::dynamic_pointer_cast(source)->getOwner(); if (source->instanceof(eTYPE_LIVINGENTITY)) diff --git a/Minecraft.World/Level/Explosion.h b/Minecraft.World/Level/Explosion.h index 1c250e6b3..36ab53016 100644 --- a/Minecraft.World/Level/Explosion.h +++ b/Minecraft.World/Level/Explosion.h @@ -40,7 +40,7 @@ public: public: void finalizeExplosion(bool generateParticles, std::vector* toBlowDirect = - NULL); // 4J - added toBlow parameter + nullptr); // 4J - added toBlow parameter playerVec3Map* getHitPlayers(); Vec3 getHitPlayerKnockback(std::shared_ptr player); std::shared_ptr getSourceMob(); diff --git a/Minecraft.World/Level/Level.cpp b/Minecraft.World/Level/Level.cpp index 567eb8e2d..4beb65038 100644 --- a/Minecraft.World/Level/Level.cpp +++ b/Minecraft.World/Level/Level.cpp @@ -113,7 +113,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)) { @@ -175,7 +175,7 @@ void Level::initCacheComplete(lightCache_t* cache, int xc, int yc, int zc) { void inline Level::setBrightnessCached(lightCache_t* cache, uint64_t* 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; } @@ -235,7 +235,7 @@ void inline Level::setBrightnessCached(lightCache_t* cache, uint64_t* cacheUse, 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, @@ -298,7 +298,7 @@ inline int Level::getBrightnessCached(lightCache_t* cache, // 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) | (z & 15); lightCache_t posbits = @@ -362,7 +362,7 @@ inline int Level::getEmissionCached(lightCache_t* cache, int ct, int x, int y, 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; return Tile::lightBlock[t]; @@ -519,17 +519,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; @@ -561,8 +561,8 @@ void Level::_init() { Biome* Level::getBiome(int x, int z) { if (hasChunkAt(x, 0, z)) { LevelChunk* lc = getChunkAt(x, z); - if (lc != NULL) { - // Water chunks at the edge of the world return NULL for their biome + if (lc != nullptr) { + // 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 = @@ -593,7 +593,7 @@ Level::Level(std::shared_ptr levelStorage, std::shared_ptr savedVillages = std::dynamic_pointer_cast( savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID)); - if (savedVillages == NULL) { + if (savedVillages == nullptr) { villages = std::shared_ptr(new Villages(this)); savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages); } else { @@ -602,7 +602,7 @@ Level::Level(std::shared_ptr levelStorage, } dimension->init(this); - chunkSource = NULL; // 4J - added flag so chunk source can be called from + chunkSource = nullptr; // 4J - added flag so chunk source can be called from // derived class instead updateSkyBrightness(); @@ -612,7 +612,7 @@ Level::Level(std::shared_ptr levelStorage, Level::Level(std::shared_ptr levelStorage, const std::wstring& levelName, LevelSettings* levelSettings) : seaLevel(constSeaLevel) { - _init(levelStorage, levelName, levelSettings, NULL, true); + _init(levelStorage, levelName, levelSettings, nullptr, true); } Level::Level(std::shared_ptr levelStorage, @@ -634,7 +634,7 @@ void Level::_init(std::shared_ptr levelStorage, std::shared_ptr savedVillages = std::dynamic_pointer_cast( savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID)); - if (savedVillages == NULL) { + if (savedVillages == nullptr) { villages = std::shared_ptr(new Villages(this)); savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages); } else { @@ -643,14 +643,14 @@ void Level::_init(std::shared_ptr levelStorage, } 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()); //} @@ -658,7 +658,7 @@ void Level::_init(std::shared_ptr levelStorage, dimension = Dimension::getNew(0); } - if (levelData == NULL) { + if (levelData == nullptr) { levelData = new LevelData(levelSettings, levelName); } else { levelData->setLevelName(levelName); @@ -672,7 +672,7 @@ void Level::_init(std::shared_ptr levelStorage, chunkSource = doCreateChunkSource ? createChunkSource() - : NULL; // 4J - added flag so chunk source can be called + : nullptr; // 4J - added flag so chunk source can be called // from derived class instead // 4J Stu- Moved to derived classes @@ -704,7 +704,7 @@ Level::~Level() { // 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); @@ -760,7 +760,7 @@ bool Level::isEmptyTile(int x, int y, int z) { return getTile(x, y, z) == 0; } 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; } return false; @@ -768,7 +768,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(); } return Tile::SHAPE_INVISIBLE; @@ -777,7 +777,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(); } return Tile::SHAPE_INVISIBLE; @@ -883,7 +883,7 @@ bool Level::setTileAndData(int x, int y, int z, int tile, int data, if (!isClientSide && (updateFlags & Tile::UPDATE_NEIGHBORS) != 0) { tileUpdated(x, y, z, oldTile); Tile* tobj = Tile::tiles[tile]; - if (tobj != NULL && tobj->hasAnalogOutputSignal()) + if (tobj != nullptr && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile); } } @@ -947,7 +947,7 @@ bool Level::setData(int x, int y, int z, int data, int updateFlags, (forceUpdate || (updateFlags & Tile::UPDATE_NEIGHBORS) != 0)) { tileUpdated(x, y, z, tile); Tile* tobj = Tile::tiles[tile]; - if (tobj != NULL && tobj->hasAnalogOutputSignal()) + if (tobj != nullptr && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile); } } @@ -1066,7 +1066,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); } } @@ -1239,7 +1239,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; @@ -1290,7 +1290,7 @@ void Level::getNeighbourBrightnesses(int* brightnesses, // "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++) { brightnesses[i] = (int)layer; } @@ -1377,8 +1377,8 @@ HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid) { } HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid, bool solidOnly) { - if (std::isnan(a->x) || std::isnan(a->y) || std::isnan(a->z)) return NULL; - if (std::isnan(b->x) || std::isnan(b->y) || std::isnan(b->z)) return NULL; + if (std::isnan(a->x) || std::isnan(a->y) || std::isnan(a->z)) return nullptr; + if (std::isnan(b->x) || std::isnan(b->y) || std::isnan(b->z)) return nullptr; int xTile1 = Mth::floor(b->x); int yTile1 = Mth::floor(b->y); @@ -1392,22 +1392,22 @@ 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 && + if (solidOnly && tile != nullptr && !tile->getAABB(this, xTile0, yTile0, zTile0).has_value()) { // No collision } 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 (std::isnan(a->x) || std::isnan(a->y) || std::isnan(a->z)) - return NULL; + return nullptr; if (xTile0 == xTile1 && yTile0 == yTile1 && zTile0 == zTile1) - return NULL; + return nullptr; bool xClipped = true; bool yClipped = true; @@ -1500,21 +1500,21 @@ 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 && + if (solidOnly && tile != nullptr && !tile->getAABB(this, xTile0, yTile0, zTile0).has_value()) { // No collision } 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(std::shared_ptr entity, int iSound, float volume, float pitch) { - if (entity == NULL) return; + if (entity == nullptr) return; AUTO_VAR(itEnd, listeners.end()); for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++) { // 4J-PB - if the entity is a local player, don't play the sound @@ -1534,7 +1534,7 @@ void Level::playEntitySound(std::shared_ptr entity, int iSound, void Level::playPlayerSound(std::shared_ptr entity, int iSound, float volume, float pitch) { - if (entity == NULL) return; + if (entity == nullptr) return; AUTO_VAR(itEnd, listeners.end()); for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++) { (*it)->playSoundExceptPlayer(entity, iSound, entity->x, @@ -1597,7 +1597,7 @@ bool Level::addEntity(std::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; } @@ -1660,10 +1660,10 @@ void Level::playerRemoved(std::shared_ptr e) { } void Level::removeEntity(std::shared_ptr e) { - if (e->rider.lock() != NULL) { + if (e->rider.lock() != nullptr) { e->rider.lock()->ride(nullptr); } - if (e->riding != NULL) { + if (e->riding != nullptr) { e->ride(nullptr); } e->remove(); @@ -1758,7 +1758,7 @@ AABBList* Level::getCubes(std::shared_ptr source, AABB* box, if (hasChunkAt(x, 64, z)) { 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); } } @@ -1806,12 +1806,12 @@ AABBList* Level::getCubes(std::shared_ptr source, AABB* box, std::vector >::iterator itEnd = ee->end(); for (AUTO_VAR(it, ee->begin()); it != itEnd; it++) { 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); } } @@ -1841,7 +1841,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); @@ -1944,7 +1944,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 @@ -2130,7 +2130,7 @@ void Level::tickEntities() { for (unsigned int i = 0; i < entities.size();) { std::shared_ptr e = entities.at(i); - if (e->riding != NULL) { + if (e->riding != nullptr) { if (e->riding->removed || e->riding->rider.lock() != e) { e->riding->rider = std::weak_ptr(); e->riding = nullptr; @@ -2195,7 +2195,7 @@ void Level::tickEntities() { it = tileEntityList.erase(it); if (hasChunk(te->x >> 4, te->z >> 4)) { LevelChunk* lc = getChunk(te->x >> 4, te->z >> 4); - if (lc != NULL) + if (lc != nullptr) lc->removeTileEntity(te->x & 15, te->y, te->z & 15); } } else { @@ -2234,7 +2234,7 @@ void Level::tickEntities() { } if (hasChunk(e->x >> 4, e->z >> 4)) { LevelChunk* lc = getChunk(e->x >> 4, e->z >> 4); - if (lc != NULL) + if (lc != nullptr) lc->setTileEntity(e->x & 15, e->y, e->z & 15, e); } @@ -2281,7 +2281,7 @@ void Level::tick(std::shared_ptr e, bool actual) { if (actual && e->inChunk) { e->tickCount++; - if (e->riding != NULL) { + if (e->riding != nullptr) { e->rideTick(); } else { e->tick(); @@ -2318,7 +2318,7 @@ void Level::tick(std::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) { e->rider.lock()->riding = nullptr; e->rider = std::weak_ptr(); @@ -2357,7 +2357,7 @@ bool Level::containsAnyBlocks(AABB* box) { for (int y = y0; y < y1; y++) for (int z = z0; z < z1; z++) { Tile* tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL) { + if (tile != nullptr) { return true; } } @@ -2380,7 +2380,7 @@ bool Level::containsAnyLiquid(AABB* box) { for (int y = y0; y < y1; y++) 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; } } @@ -2410,7 +2410,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; } } @@ -2460,7 +2460,7 @@ bool Level::checkAndHandleWater(AABB* box, Material* material, for (int y = y0; y < y1; y++) { 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) { double yt0 = y + 1 - LiquidTile::getHeight(getData(x, y, z)); if (y1 >= yt0) { @@ -2493,7 +2493,7 @@ bool Level::containsMaterial(AABB* box, Material* material) { for (int y = y0; y < y1; y++) { 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; } } @@ -2514,7 +2514,7 @@ bool Level::containsLiquid(AABB* box, Material* material) { for (int y = y0; y < y1; y++) { 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; if (data < 8) { @@ -2564,7 +2564,7 @@ float Level::getSeenPercent(Vec3* center, AABB* bb) { double z = bb->z0 + (bb->z1 - bb->z0) * zz; Vec3 a(x, y, z); HitResult* res = clip(&a, center); - if (res == NULL) hits++; + if (res == nullptr) hits++; delete res; count++; } @@ -2626,14 +2626,14 @@ std::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_VAR(it, pendingTileEntities.begin()); it != pendingTileEntities.end(); it++) { @@ -2651,7 +2651,7 @@ std::shared_ptr Level::getTileEntity(int x, int y, int z) { void Level::setTileEntity(int x, int y, int z, std::shared_ptr tileEntity) { - if (tileEntity != NULL && !tileEntity->isRemoved()) { + if (tileEntity != nullptr && !tileEntity->isRemoved()) { EnterCriticalSection(&m_tileEntityListCS); if (updatingTileEntities) { tileEntity->x = x; @@ -2675,7 +2675,7 @@ void Level::setTileEntity(int x, int y, int z, 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); } @@ -2684,7 +2684,7 @@ void Level::setTileEntity(int x, int y, int z, void Level::removeTileEntity(int x, int y, int z) { EnterCriticalSection(&m_tileEntityListCS); std::shared_ptr te = getTileEntity(x, y, z); - if (te != NULL && updatingTileEntities) { + if (te != nullptr && updatingTileEntities) { te->setRemoved(); AUTO_VAR(it, find(pendingTileEntities.begin(), pendingTileEntities.end(), te)); @@ -2692,7 +2692,7 @@ void Level::removeTileEntity(int x, int y, int z) { pendingTileEntities.erase(it); } } else { - if (te != NULL) { + if (te != nullptr) { AUTO_VAR(it, find(pendingTileEntities.begin(), pendingTileEntities.end(), te)); if (it != pendingTileEntities.end()) { @@ -2705,7 +2705,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); } @@ -2718,7 +2718,7 @@ void Level::markForRemoval(std::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 @@ -2737,7 +2737,7 @@ bool Level::isSolidRenderTile(int x, int y, int z) { int azo[6] = {0, 0, 0, 0, 1, -1}; 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) || + if ((t != Tile::leaves_Id) && ((Tile::tiles[t] == nullptr) || !Tile::tiles[t]->isSolidRender())) { return false; } @@ -2765,18 +2765,18 @@ bool Level::isSolidBlockingTileInLoadedChunk(int x, int y, int z, 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; } auto aabb = Tile::tiles[tile]->getAABB(this, x, y, z); @@ -2790,18 +2790,18 @@ 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) + if (dynamic_cast(tile) != nullptr) return true; + if (dynamic_cast(tile) != nullptr) return (data & TopSnowTile::HEIGHT_MASK) == TopSnowTile::MAX_HEIGHT + 1; return false; } @@ -2976,7 +2976,7 @@ void Level::tickClientSideTiles(int xo, int zo, LevelChunk* lc) { getBrightness(LightLayer::Sky, x, y, z) <= 0) { std::shared_ptr player = getNearestPlayer(x + 0.5, y + 0.5, z + 0.5, 8); - if (player != NULL && + 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 @@ -3119,7 +3119,7 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, // cached data sit on the CPU L2 cache better. int* toCheck; - if (cache == NULL) { + if (cache == nullptr) { toCheck = toCheckLevel; } else { toCheck = (int*)(cache + (16 * 16 * 16)); @@ -3203,7 +3203,7 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, // 4J - some changes here brought forward // from 1.2.3 int block = std::max( - 1, getBlockingCached(cache, layer, NULL, + 1, getBlockingCached(cache, layer, nullptr, xx, yy, zz)); current = getBrightnessCached(cache, layer, xx, yy, zz); @@ -3345,12 +3345,12 @@ bool Level::tickPendingTicks(bool force) { return false; } std::vector* Level::fetchTicksInChunk(LevelChunk* chunk, bool remove) { - return NULL; + return nullptr; } std::vector >* Level::getEntities( std::shared_ptr except, AABB* bb) { - return getEntities(except, bb, NULL); + return getEntities(except, bb, nullptr); } std::vector >* Level::getEntities( @@ -3377,7 +3377,7 @@ std::vector >* Level::getEntities( std::vector >* Level::getEntitiesOfClass( const std::type_info& baseClass, AABB* bb) { - return getEntitiesOfClass(baseClass, bb, NULL); + return getEntitiesOfClass(baseClass, bb, nullptr); } std::vector >* Level::getEntitiesOfClass( @@ -3442,8 +3442,8 @@ void Level::tileEntityChanged(int x, int y, int z, // 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*/) { + eINSTANCEOF clas, bool singleType, unsigned int* protectedCount /* = nullptr*/, + unsigned int* couldWanderCount /* = nullptr*/) { unsigned int count = 0; if (protectedCount) *protectedCount = 0; if (couldWanderCount) *couldWanderCount = 0; @@ -3547,16 +3547,16 @@ bool Level::mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, auto aabb = tile->getAABB(this, x, y, z); if (ignoreEntities) aabb = std::nullopt; if (aabb.has_value() && !isUnobstructed(&*aabb, ignoreEntity)) return false; - if (targetTile != NULL && + 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 && + if (targetTile != nullptr && targetTile->material == Material::decoration && tile == Tile::anvil) return true; - if (tileId > 0 && targetTile == NULL) { + if (tileId > 0 && targetTile == nullptr) { if (tile->mayPlace(this, x, y, z, face, item)) { return true; } @@ -4053,7 +4053,7 @@ int Level::getHeight() { } Tickable* Level::makeSoundUpdater(std::shared_ptr minecart) { - return NULL; + return nullptr; } Random* Level::getRandomFor(int x, int z, int blend) { diff --git a/Minecraft.World/Level/Level.h b/Minecraft.World/Level/Level.h index 567d9aff4..a5992f429 100644 --- a/Minecraft.World/Level/Level.h +++ b/Minecraft.World/Level/Level.h @@ -511,8 +511,8 @@ public: void tileEntityChanged(int x, int y, int z, std::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 + 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 diff --git a/Minecraft.World/Level/LevelChunk.cpp b/Minecraft.World/Level/LevelChunk.cpp index ce4fc5acf..4c2f6f542 100644 --- a/Minecraft.World/Level/LevelChunk.cpp +++ b/Minecraft.World/Level/LevelChunk.cpp @@ -119,7 +119,7 @@ void LevelChunk::init(Level* level, int x, int z) { #if defined(_LARGE_WORLDS) m_bUnloaded = false; // 4J Added - m_unloadedEntitiesTag = NULL; + m_unloadedEntitiesTag = nullptr; #endif } @@ -128,10 +128,10 @@ LevelChunk::LevelChunk(Level* level, int x, int z) : ENTITY_BLOCKS_LENGTH(Level::maxBuildHeight / 16) { 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) { // Create all these as empty, as we may not be loading any data into @@ -141,10 +141,10 @@ LevelChunk::LevelChunk(Level* level, int x, int z) upperSkyLight = new SparseLightStorage(true, true); upperBlockLight = new SparseLightStorage(false, true); } else { - upperBlocks = NULL; - upperData = NULL; - upperSkyLight = NULL; - upperBlockLight = NULL; + upperBlocks = nullptr; + upperData = nullptr; + upperSkyLight = nullptr; + upperBlockLight = nullptr; } #if defined(SHARING_ENABLED) @@ -165,7 +165,7 @@ LevelChunk::LevelChunk(Level* level, byteArray blocks, int x, int z) // 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) { lowerBlocks = new CompressedTileStorage(true); @@ -194,13 +194,13 @@ LevelChunk::LevelChunk(Level* level, byteArray blocks, int x, int z) upperSkyLight = new SparseLightStorage(true, true); upperBlockLight = new SparseLightStorage(false, true); } else { - upperBlocks = NULL; - upperData = NULL; - upperSkyLight = NULL; - upperBlockLight = NULL; + upperBlocks = nullptr; + upperData = nullptr; + upperSkyLight = nullptr; + upperBlockLight = nullptr; } - serverTerrainPopulated = NULL; + serverTerrainPopulated = nullptr; #if defined(SHARING_ENABLED) sharingTilesAndData = false; #endif @@ -234,7 +234,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 } @@ -295,8 +295,8 @@ void LevelChunk::stopSharingTilesAndData() { upperBlocks = new CompressedTileStorage(upperBlocks); upperData = new SparseDataStorage(upperData); } else { - upperBlocks = NULL; - upperData = NULL; + upperBlocks = nullptr; + upperData = nullptr; } /* @@ -898,7 +898,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 std::shared_ptr te = getTileEntity(x, y, z); - if (te != NULL) { + if (te != nullptr) { te->clearCache(); } @@ -982,11 +982,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 // if (_tile > 0 && dynamic_cast(Tile::tiles[_tile]) != NULL) - if (_tile > 0 && Tile::tiles[_tile] != NULL && + //*>(Tile::tiles[_tile]) != nullptr) + if (_tile > 0 && Tile::tiles[_tile] != nullptr && Tile::tiles[_tile]->isEntityTile()) { std::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 @@ -994,7 +994,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) { // 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()); @@ -1005,11 +1005,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 && + // nullptr) + else if (old > 0 && Tile::tiles[_tile] != nullptr && Tile::tiles[_tile]->isEntityTile()) { std::shared_ptr te = getTileEntity(x, y, z); - if (te != NULL) { + if (te != nullptr) { te->clearCache(); } } @@ -1045,9 +1045,9 @@ bool LevelChunk::setData(int x, int y, int z, int val, int mask, 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) { std::shared_ptr te = getTileEntity(x, y, z); - if (te != NULL) { + if (te != nullptr) { te->clearCache(); te->data = val; } @@ -1278,7 +1278,7 @@ std::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); @@ -1299,7 +1299,7 @@ std::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); LeaveCriticalSection(&m_csTileEntities); @@ -1364,7 +1364,7 @@ void LevelChunk::removeTileEntity(int x, int y, int z) { if (it != tileEntities.end()) { std::shared_ptr te = tileEntities[pos]; tileEntities.erase(pos); - if (te != NULL) { + if (te != nullptr) { if (level->isClientSide) { app.DebugPrintf("Removing tile entity of type %d\n", te->GetType()); @@ -1385,12 +1385,12 @@ void LevelChunk::load() { 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); std::shared_ptr ent = EntityIO::loadStatic(teTag, level); - if (ent != NULL) { + if (ent != nullptr) { ent->onLoadedFromSave(); addEntity(ent); } @@ -1400,18 +1400,18 @@ 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); std::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 @@ -1587,15 +1587,15 @@ void LevelChunk::getEntities(std::shared_ptr except, AABB* bb, for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) { std::shared_ptr e = *it; // entities->at(i); if (e != except && e->bb.intersects(*bb) && - (selector == NULL || selector->matches(e))) { + (selector == nullptr || selector->matches(e))) { es.push_back(e); std::vector >* subs = e->getSubEntities(); - if (subs != NULL) { + if (subs != nullptr) { for (int j = 0; j < subs->size(); j++) { e = subs->at(j); if (e != except && e->bb.intersects(*bb) && - (selector == NULL || selector->matches(e))) { + (selector == nullptr || selector->matches(e))) { es.push_back(e); } } @@ -1654,10 +1654,10 @@ void LevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB* bb, else if (ec == typeid(Zombie)) isAssignableFrom = e->instanceof(eTYPE_ZOMBIE); else if (Entity* entity = e.get(); - entity != NULL && ec == typeid(*entity)) + entity != nullptr && ec == typeid(*entity)) isAssignableFrom = true; if (isAssignableFrom && e->bb.intersects(*bb)) { - if (selector == NULL || selector->matches(e)) { + if (selector == nullptr || selector->matches(e)) { es.push_back(e); } } @@ -1838,12 +1838,12 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1, if (y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->setDataRegion( data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p, - includeLighting ? NULL : tileUpdatedCallback, this, 0); + includeLighting ? nullptr : tileUpdatedCallback, this, 0); if (y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->setDataRegion( data, x0, std::max(y0 - compressedHeight, 0), z0, x1, y1 - Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, - includeLighting ? NULL : tileUpdatedCallback, this, + includeLighting ? nullptr : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT); /* for (int x = x0; x < x1; x++) @@ -1861,12 +1861,12 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1, if (y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->setDataRegion( data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p, - includeLighting ? NULL : tileUpdatedCallback, this, 0); + includeLighting ? nullptr : tileUpdatedCallback, this, 0); if (y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->setDataRegion( data, x0, std::max(y0 - compressedHeight, 0), z0, x1, y1 - Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, - includeLighting ? NULL : tileUpdatedCallback, this, + includeLighting ? nullptr : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT); if (includeLighting) { @@ -2054,7 +2054,7 @@ Biome* LevelChunk::getBiome(int x, int z, BiomeSource* biomeSource) { value = biome->id; biomes[((unsigned)z << 4) | x] = (uint8_t)(value & 0xff); } - if (Biome::biomes[value] == NULL) { + if (Biome::biomes[value] == nullptr) { return Biome::plains; } return Biome::biomes[value]; @@ -2063,7 +2063,7 @@ Biome* LevelChunk::getBiome(int x, int z, BiomeSource* biomeSource) { byteArray LevelChunk::getBiomes() { return biomes; } 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; } @@ -2142,8 +2142,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); @@ -2169,8 +2169,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) + 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) @@ -2180,9 +2180,9 @@ 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) + if (lowerBlockLight == nullptr) lowerBlockLight = new SparseLightStorage(false); - if (upperBlockLight == NULL) + if (upperBlockLight == nullptr) upperBlockLight = new SparseLightStorage(false, true); lowerBlockLight->setData(data, 0); if (data.length > Level::COMPRESSED_CHUNK_SECTION_TILES / 2) @@ -2213,8 +2213,8 @@ void LevelChunk::compressLighting() { void LevelChunk::compressBlocks() { #if defined(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 @@ -2284,24 +2284,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) + 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) + if (lowerBlockLight == nullptr) lowerBlockLight = new SparseLightStorage(false); - if (upperBlockLight == NULL) + if (upperBlockLight == nullptr) upperBlockLight = new SparseLightStorage(false, true); lowerBlockLight->read(dis); upperBlockLight->read(dis); @@ -2312,8 +2312,8 @@ void LevelChunk::readCompressedBlockLightData(DataInputStream* dis) { // update it from another thread. void LevelChunk::compressData() { #if defined(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 diff --git a/Minecraft.World/Level/LevelData.cpp b/Minecraft.World/Level/LevelData.cpp index e2a937f47..490e30f70 100644 --- a/Minecraft.World/Level/LevelData.cpp +++ b/Minecraft.World/Level/LevelData.cpp @@ -14,7 +14,7 @@ LevelData::LevelData(CompoundTag* tag) { if (tag->contains(L"generatorName")) { std::wstring generatorName = tag->getString(L"generatorName"); m_pGenerator = LevelType::getLevelType(generatorName); - if (m_pGenerator == NULL) { + if (m_pGenerator == nullptr) { m_pGenerator = LevelType::lvl_normal; } else if (m_pGenerator->hasReplacement()) { int generatorVersion = 0; @@ -184,7 +184,7 @@ LevelData::LevelData(CompoundTag* tag) { } else { - this->loadedPlayerTag = NULL; + this->loadedPlayerTag = nullptr; } */ dimension = 0; @@ -210,7 +210,7 @@ LevelData::LevelData(LevelSettings* levelSettings, 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; @@ -392,7 +392,7 @@ int64_t LevelData::getDayTime() { return dayTime; } int64_t LevelData::getSizeOnDisk() { return sizeOnDisk; } 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/Level/RandomLevelSource.cpp b/Minecraft.World/Level/RandomLevelSource.cpp index d3a9574d7..8424090a2 100644 --- a/Minecraft.World/Level/RandomLevelSource.cpp +++ b/Minecraft.World/Level/RandomLevelSource.cpp @@ -47,8 +47,8 @@ RandomLevelSource::RandomLevelSource(Level* level, int64_t seed, floatingIslandScale = new PerlinNoise(random, 10); floatingIslandNoise = new PerlinNoise(random, 16); } else { - floatingIslandScale = NULL; - floatingIslandNoise = NULL; + floatingIslandScale = nullptr; + floatingIslandNoise = nullptr; } forestNoise = new PerlinNoise(random, 8); @@ -79,7 +79,7 @@ RandomLevelSource::~RandomLevelSource() { delete forestNoise; - if (pows.data != NULL) delete[] pows.data; + if (pows.data != nullptr) delete[] pows.data; } int g_numPrepareHeightCalls = 0; @@ -395,7 +395,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, uint8_t material = b->material; LevelGenerationOptions* lgo = app.getLevelGenerationOptions(); - if (lgo != NULL) { + if (lgo != nullptr) { lgo->getBiomeOverride(b->id, material, top); } @@ -423,7 +423,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, y <= waterHeight + 1) { top = b->topMaterial; material = b->material; - if (lgo != NULL) { + if (lgo != nullptr) { lgo->getBiomeOverride(b->id, material, top); } } @@ -530,10 +530,10 @@ void RandomLevelSource::lightChunk(LevelChunk* lc) { lc->recalcHeightmap(); } 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++) { for (int zb = -2; zb <= 2; zb++) { @@ -849,8 +849,8 @@ std::wstring RandomLevelSource::gatherStats() { return L"RandomLevelSource"; } std::vector* RandomLevelSource::getMobsAt( MobCategory* mobCategory, int x, int y, int z) { Biome* biome = level->getBiome(x, z); - if (biome == NULL) { - return NULL; + if (biome == nullptr) { + return nullptr; } if (mobCategory == MobCategory::monster && scatteredFeature->isSwamphut(x, y, z)) { @@ -861,10 +861,10 @@ std::vector* RandomLevelSource::getMobsAt( TilePos* RandomLevelSource::findNearestMapFeature( Level* level, const std::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, diff --git a/Minecraft.World/Level/Storage/CompressedTileStorage.cpp b/Minecraft.World/Level/Storage/CompressedTileStorage.cpp index fe7c580bd..015b3c6cf 100644 --- a/Minecraft.World/Level/Storage/CompressedTileStorage.cpp +++ b/Minecraft.World/Level/Storage/CompressedTileStorage.cpp @@ -12,10 +12,10 @@ CRITICAL_SECTION CompressedTileStorage::cs_write; #if defined(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) { int index = ((j & 0x30) << 7) | ((j & 0x0c) << 5) | (j & 0x03); @@ -26,7 +26,7 @@ void CompressedTileStorage_InitTable() { #endif CompressedTileStorage::CompressedTileStorage() { - indicesAndData = NULL; + indicesAndData = nullptr; allocatedSize = 0; #if defined(PSVITA_PRECOMPUTED_TABLE) @@ -43,7 +43,7 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage* copyFrom) { PAGE_READWRITE); //(unsigned char *)malloc(allocatedSize); XMemCpy(indicesAndData, copyFrom->indicesAndData, allocatedSize); } else { - indicesAndData = NULL; + indicesAndData = nullptr; } LeaveCriticalSection(&cs_write); @@ -54,7 +54,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 @@ -98,7 +98,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 @@ -362,7 +362,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) @@ -765,7 +765,7 @@ void CompressedTileStorage::tick() { // 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(); // if( toFree ) printf("Deleting 0x%x\n", toFree); @@ -802,7 +802,7 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) { for (int i = 0; i < 512; i++) { 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 @@ -956,7 +956,7 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) { unsigned char* newIndicesAndData = (unsigned char*)XPhysicalAlloc( memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE); //(unsigned char *)malloc( memToAlloc ); - if (newIndicesAndData == NULL) { + if (newIndicesAndData == nullptr) { DWORD lastError = GetLastError(); MEMORYSTATUS memStatus; GlobalMemoryStatus(&memStatus); @@ -1014,9 +1014,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) { unpacked_data = tempdata; @@ -1065,7 +1065,7 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) { ucMappings[j] = 255; } - unsigned char* repacked = NULL; + unsigned char* repacked = nullptr; if (indexTypeNew == INDEX_TYPE_0_OR_8_BIT) { if (_blockIndices[i] & INDEX_TYPE_0_BIT_FLAG) { diff --git a/Minecraft.World/Level/Storage/DataLayer.cpp b/Minecraft.World/Level/Storage/DataLayer.cpp index c8e2b264a..e52287c09 100644 --- a/Minecraft.World/Level/Storage/DataLayer.cpp +++ b/Minecraft.World/Level/Storage/DataLayer.cpp @@ -38,7 +38,7 @@ void DataLayer::set(int x, int y, int z, int val) { } } -bool DataLayer::isValid() { return data.data != NULL; } +bool DataLayer::isValid() { return data.data != nullptr; } void DataLayer::setAll(int br) { uint8_t val = (uint8_t)(br & (br << 4)); diff --git a/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp b/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp index ed9ed16f2..29f1cc3b5 100644 --- a/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp +++ b/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp @@ -208,12 +208,12 @@ void DirectoryLevelStorage::checkSession() { 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 return new OldChunkStorage(dir2, true); @@ -318,7 +318,7 @@ LevelData* DirectoryLevelStorage::prepareLevel() { return ret; } - return NULL; + return nullptr; } void DirectoryLevelStorage::saveLevelData( @@ -394,7 +394,7 @@ void DirectoryLevelStorage::save(std::shared_ptr player) { // 4J Changed return val to bool to check if new player or loaded player CompoundTag* DirectoryLevelStorage::load(std::shared_ptr player) { CompoundTag* tag = loadPlayerDataTag(player->getXuid()); - if (tag != NULL) { + if (tag != nullptr) { player->load(tag); } return tag; @@ -418,7 +418,7 @@ CompoundTag* DirectoryLevelStorage::loadPlayerDataTag(PlayerUID xuid) { ConsoleSaveFileInputStream(m_saveFile, realFile); return NbtIo::readCompressed(&fis); } - return NULL; + return nullptr; } // 4J Added function @@ -428,7 +428,7 @@ void DirectoryLevelStorage::clearOldPlayerFiles() { std::vector* playerFiles = m_saveFile->getFilesWithPrefix(playerDir.getName()); - if (playerFiles != NULL) { + if (playerFiles != nullptr) { #if !defined(_FINAL_BUILD) if (app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & @@ -496,14 +496,14 @@ void DirectoryLevelStorage::resetNetherPlayerPositions() { std::vector* playerFiles = m_saveFile->getFilesWithPrefix(playerDir.getName()); - if (playerFiles != NULL) { + if (playerFiles != nullptr) { for (AUTO_VAR(it, playerFiles->begin()); it != playerFiles->end(); ++it) { FileEntry* realFile = *it; ConsoleSaveFileInputStream fis = ConsoleSaveFileInputStream(m_saveFile, realFile); CompoundTag* tag = NbtIo::readCompressed(&fis); - if (tag != NULL) { + if (tag != nullptr) { // If the player is in the nether, set their y position // above the top of the nether This will force the player to // be spawned in a valid position in the overworld when they diff --git a/Minecraft.World/Level/Storage/DirectoryLevelStorageSource.cpp b/Minecraft.World/Level/Storage/DirectoryLevelStorageSource.cpp index 4f1e54619..e1329eef2 100644 --- a/Minecraft.World/Level/Storage/DirectoryLevelStorageSource.cpp +++ b/Minecraft.World/Level/Storage/DirectoryLevelStorageSource.cpp @@ -41,7 +41,7 @@ LevelData* DirectoryLevelStorageSource::getDataTagFor( return ret; } - return NULL; + return nullptr; } void DirectoryLevelStorageSource::renameLevel( diff --git a/Minecraft.World/Level/Storage/EntityIO.cpp b/Minecraft.World/Level/Storage/EntityIO.cpp index ab377ff89..6ac077070 100644 --- a/Minecraft.World/Level/Storage/EntityIO.cpp +++ b/Minecraft.World/Level/Storage/EntityIO.cpp @@ -234,8 +234,8 @@ std::shared_ptr EntityIO::newEntity(const std::wstring& id, AUTO_VAR(it, idCreateMap->find(id)); if (it != idCreateMap->end()) { entityCreateFn create = it->second; - if (create != NULL) entity = std::shared_ptr(create(level)); - if ((entity != NULL) && entity->GetType() == eTYPE_ENDERDRAGON) { + if (create != nullptr) entity = std::shared_ptr(create(level)); + if ((entity != nullptr) && entity->GetType() == eTYPE_ENDERDRAGON) { std::dynamic_pointer_cast(entity) ->AddParts(); // 4J added to finalise creation } @@ -268,14 +268,14 @@ std::shared_ptr EntityIO::loadStatic(CompoundTag* tag, Level* level) { AUTO_VAR(it, idCreateMap->find(tag->getString(L"id"))); if (it != idCreateMap->end()) { entityCreateFn create = it->second; - if (create != NULL) entity = std::shared_ptr(create(level)); - if ((entity != NULL) && entity->GetType() == eTYPE_ENDERDRAGON) { + if (create != nullptr) entity = std::shared_ptr(create(level)); + if ((entity != nullptr) && entity->GetType() == eTYPE_ENDERDRAGON) { std::dynamic_pointer_cast(entity) ->AddParts(); // 4J added to finalise creation } } - if (entity != NULL) { + if (entity != nullptr) { entity->load(tag); } else { #ifdef _DEBUG @@ -292,14 +292,14 @@ std::shared_ptr EntityIO::newById(int id, Level* level) { AUTO_VAR(it, numCreateMap->find(id)); if (it != numCreateMap->end()) { entityCreateFn create = it->second; - if (create != NULL) entity = std::shared_ptr(create(level)); - if ((entity != NULL) && entity->GetType() == eTYPE_ENDERDRAGON) { + if (create != nullptr) entity = std::shared_ptr(create(level)); + if ((entity != nullptr) && entity->GetType() == eTYPE_ENDERDRAGON) { std::dynamic_pointer_cast(entity) ->AddParts(); // 4J added to finalise creation } } - if (entity != NULL) { + if (entity != nullptr) { } else { // printf("Skipping Entity with id %d\n", id ) ; } @@ -317,8 +317,8 @@ std::shared_ptr EntityIO::newByEnumType(eINSTANCEOF eType, AUTO_VAR(it2, numCreateMap->find(it->second)); if (it2 != numCreateMap->end()) { entityCreateFn create = it2->second; - if (create != NULL) entity = std::shared_ptr(create(level)); - if ((entity != NULL) && entity->GetType() == eTYPE_ENDERDRAGON) { + if (create != nullptr) entity = std::shared_ptr(create(level)); + if ((entity != nullptr) && entity->GetType() == eTYPE_ENDERDRAGON) { std::dynamic_pointer_cast(entity) ->AddParts(); // 4J added to finalise creation } diff --git a/Minecraft.World/Level/Storage/LevelSettings.cpp b/Minecraft.World/Level/Storage/LevelSettings.cpp index 5c0542cfe..cd0120eff 100644 --- a/Minecraft.World/Level/Storage/LevelSettings.cpp +++ b/Minecraft.World/Level/Storage/LevelSettings.cpp @@ -3,10 +3,10 @@ #include "../../Headers/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() { NOT_SET = new GameType(-1, L""); diff --git a/Minecraft.World/Level/Storage/LevelStorage.h b/Minecraft.World/Level/Storage/LevelStorage.h index 9029934ce..a8a2f0cc0 100644 --- a/Minecraft.World/Level/Storage/LevelStorage.h +++ b/Minecraft.World/Level/Storage/LevelStorage.h @@ -30,7 +30,7 @@ public: virtual std::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/Level/Storage/LevelType.cpp b/Minecraft.World/Level/Storage/LevelType.cpp index 4143a8e2b..a734cb236 100644 --- a/Minecraft.World/Level/Storage/LevelType.cpp +++ b/Minecraft.World/Level/Storage/LevelType.cpp @@ -14,15 +14,15 @@ 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"); + nullptr; // = new LevelType(0, "default", 1).setHasReplacement(); +LevelType* LevelType::lvl_flat = nullptr; // = new LevelType(1, "flat"); LevelType* LevelType::lvl_largeBiomes = - NULL; // = new LevelType(2, "largeBiomes"); + nullptr; // = new LevelType(2, "largeBiomes"); LevelType* LevelType::lvl_normal_1_1 = - NULL; // = new LevelType(8, "default_1_1", 0).setSelectableByUser(false); + 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"); @@ -84,12 +84,12 @@ LevelType* LevelType::getLevelType(std::wstring name) { for (int i = 0; i < 16; i++) { std::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() { return id; } \ No newline at end of file diff --git a/Minecraft.World/Level/Storage/MapItemSavedData.cpp b/Minecraft.World/Level/Storage/MapItemSavedData.cpp index 4b5eb99f0..676a1e9db 100644 --- a/Minecraft.World/Level/Storage/MapItemSavedData.cpp +++ b/Minecraft.World/Level/Storage/MapItemSavedData.cpp @@ -112,7 +112,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket( ++dataIndex; } bool thesame = !itemInstance->isFramed(); - if (lastSentDecorations.data == NULL || + if (lastSentDecorations.data == nullptr || lastSentDecorations.length != data.length) { thesame = false; } else { @@ -125,7 +125,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket( } if (!thesame) { - if (lastSentDecorations.data != NULL) { + if (lastSentDecorations.data != nullptr) { delete[] lastSentDecorations.data; } // Make a copy of data, as the calling function presumes it can @@ -190,7 +190,7 @@ void MapItemSavedData::load(CompoundTag* tag) { } else { byteArray newColors = tag->getByteArray(L"colors"); // 4J - if (colors.data != NULL) { + if (colors.data != nullptr) { delete[] colors.data; } // End4J @@ -370,7 +370,7 @@ void MapItemSavedData::tickCarriedBy(std::shared_ptr player, for (AUTO_VAR(it3, players->players.begin()); it3 != players->players.end(); ++it3) { std::shared_ptr decorationPlayer = *it3; - if (decorationPlayer != NULL && + if (decorationPlayer != nullptr && decorationPlayer->dimension == this->dimension) { float xd = (float)(decorationPlayer->x - x) / (1 << scale); diff --git a/Minecraft.World/Level/Storage/McRegionChunkStorage.cpp b/Minecraft.World/Level/Storage/McRegionChunkStorage.cpp index c8ddae142..869a73ca6 100644 --- a/Minecraft.World/Level/Storage/McRegionChunkStorage.cpp +++ b/Minecraft.World/Level/Storage/McRegionChunkStorage.cpp @@ -79,7 +79,7 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { #if defined(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) { // 4jcraft fixed cast from int to int64 and taking the mask of the upper // bits and cast to unsigned uint64_t index = @@ -93,11 +93,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); loadEntities(level, levelChunk); @@ -107,12 +107,12 @@ 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) { z); app.DebugPrintf(buf); delete chunkData; - return NULL; + return nullptr; } if (!chunkData->getCompound(L"Level")->contains(L"Blocks")) { char buf[256]; @@ -134,7 +134,7 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { z); app.DebugPrintf(buf); delete chunkData; - return NULL; + return nullptr; } MemSect(9); levelChunk = @@ -149,7 +149,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 @@ -329,8 +329,8 @@ void McRegionChunkStorage::staticCtor() { SetThreadName(0, threadName); // saveThreads[j] = - // CreateThread(NULL,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]); - s_saveThreads[i] = new C4JThread(runSaveThreadProc, NULL, threadName); + // 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); @@ -353,7 +353,7 @@ int McRegionChunkStorage::runSaveThreadProc(void* lpParam) { bool running = true; size_t lastQueueSize = 0; - DataOutputStream* dos = NULL; + DataOutputStream* dos = nullptr; while (running) { if (TryEnterCriticalSection(&cs_memory)) { lastQueueSize = s_chunkDataQueue.size(); @@ -373,7 +373,7 @@ int McRegionChunkStorage::runSaveThreadProc(void* lpParam) { PIXEndNamedEvent(); } delete dos; - dos = NULL; + dos = nullptr; EnterCriticalSection(&cs_memory); s_runningThreadCount--; diff --git a/Minecraft.World/Level/Storage/McRegionLevelStorage.cpp b/Minecraft.World/Level/Storage/McRegionLevelStorage.cpp index 6fdbad8fc..2fb1981b9 100644 --- a/Minecraft.World/Level/Storage/McRegionLevelStorage.cpp +++ b/Minecraft.World/Level/Storage/McRegionLevelStorage.cpp @@ -24,12 +24,12 @@ McRegionLevelStorage::~McRegionLevelStorage() { ChunkStorage* McRegionLevelStorage::createChunkStorage(Dimension* dimension) { // File folder = getFolder(); - if (dynamic_cast(dimension) != NULL) { + if (dynamic_cast(dimension) != nullptr) { if (app.GetResetNether()) { #ifdef SPLIT_SAVES std::vector* netherFiles = m_saveFile->getRegionFilesByDimension(1); - if (netherFiles != NULL) { + if (netherFiles != nullptr) { DWORD bytesWritten = 0; for (AUTO_VAR(it, netherFiles->begin()); it != netherFiles->end(); ++it) { @@ -41,7 +41,7 @@ ChunkStorage* McRegionLevelStorage::createChunkStorage(Dimension* dimension) { #else std::vector* netherFiles = m_saveFile->getFilesWithPrefix(LevelStorage::NETHER_FOLDER); - if (netherFiles != NULL) { + if (netherFiles != nullptr) { for (AUTO_VAR(it, netherFiles->begin()); it != netherFiles->end(); ++it) { m_saveFile->deleteFile(*it); @@ -77,7 +77,7 @@ ChunkStorage* McRegionLevelStorage::createChunkStorage(Dimension* dimension) { m_saveFile->getFilesWithPrefix(LevelStorage::ENDER_FOLDER); // 4J-PB - There will be no End in early saves - if (endFiles != NULL) { + if (endFiles != nullptr) { for (AUTO_VAR(it, endFiles->begin()); it != endFiles->end(); ++it) { m_saveFile->deleteFile(*it); diff --git a/Minecraft.World/Level/Storage/McRegionLevelStorageSource.cpp b/Minecraft.World/Level/Storage/McRegionLevelStorageSource.cpp index 204a45823..b4ae46969 100644 --- a/Minecraft.World/Level/Storage/McRegionLevelStorageSource.cpp +++ b/Minecraft.World/Level/Storage/McRegionLevelStorageSource.cpp @@ -40,7 +40,7 @@ bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile* saveFile, const std::wstring& levelId) { // 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; } @@ -52,7 +52,7 @@ bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile* saveFile, bool McRegionLevelStorageSource::requiresConversion( ConsoleSaveFile* saveFile, const std::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/Level/Storage/MemoryChunkStorage.cpp b/Minecraft.World/Level/Storage/MemoryChunkStorage.cpp index 529a21899..f5bb9977d 100644 --- a/Minecraft.World/Level/Storage/MemoryChunkStorage.cpp +++ b/Minecraft.World/Level/Storage/MemoryChunkStorage.cpp @@ -6,7 +6,7 @@ LevelChunk* MemoryChunkStorage::load(Level* level, int x, int z) // throws IOException { - return NULL; + return nullptr; } void MemoryChunkStorage::save(Level* level, diff --git a/Minecraft.World/Level/Storage/MemoryLevelStorage.cpp b/Minecraft.World/Level/Storage/MemoryLevelStorage.cpp index c35a58279..cea06ca68 100644 --- a/Minecraft.World/Level/Storage/MemoryLevelStorage.cpp +++ b/Minecraft.World/Level/Storage/MemoryLevelStorage.cpp @@ -10,7 +10,7 @@ MemoryLevelStorage::MemoryLevelStorage() {} -LevelData* MemoryLevelStorage::prepareLevel() { return NULL; } +LevelData* MemoryLevelStorage::prepareLevel() { return nullptr; } void MemoryLevelStorage::checkSession() {} @@ -33,7 +33,7 @@ bool MemoryLevelStorage::load(std::shared_ptr player) { return false; } CompoundTag* MemoryLevelStorage::loadPlayerDataTag( const std::wstring& playerName) { - return NULL; + return nullptr; } ConsoleSavePath MemoryLevelStorage::getDataFile(const std::wstring& id) { diff --git a/Minecraft.World/Level/Storage/MemoryLevelStorageSource.cpp b/Minecraft.World/Level/Storage/MemoryLevelStorageSource.cpp index c51a10ebb..c172511ec 100644 --- a/Minecraft.World/Level/Storage/MemoryLevelStorageSource.cpp +++ b/Minecraft.World/Level/Storage/MemoryLevelStorageSource.cpp @@ -21,7 +21,7 @@ void MemoryLevelStorageSource::clearAll() {} LevelData* MemoryLevelStorageSource::getDataTagFor( const std::wstring& levelId) { - return NULL; + return nullptr; } bool MemoryLevelStorageSource::isNewLevelIdAcceptable( diff --git a/Minecraft.World/Level/Storage/MockedLevelStorage.cpp b/Minecraft.World/Level/Storage/MockedLevelStorage.cpp index de6255ab1..2da239af1 100644 --- a/Minecraft.World/Level/Storage/MockedLevelStorage.cpp +++ b/Minecraft.World/Level/Storage/MockedLevelStorage.cpp @@ -7,12 +7,12 @@ #include "../../IO/Files/ConsoleSaveFileIO.h" -LevelData* MockedLevelStorage::prepareLevel() { return NULL; } +LevelData* MockedLevelStorage::prepareLevel() { return nullptr; } void MockedLevelStorage::checkSession() {} ChunkStorage* MockedLevelStorage::createChunkStorage(Dimension* dimension) { - return NULL; + return nullptr; } void MockedLevelStorage::saveLevelData( @@ -20,7 +20,7 @@ void MockedLevelStorage::saveLevelData( void MockedLevelStorage::saveLevelData(LevelData* levelData) {} -PlayerIO* MockedLevelStorage::getPlayerIO() { return NULL; } +PlayerIO* MockedLevelStorage::getPlayerIO() { return nullptr; } void MockedLevelStorage::closeAll() {} diff --git a/Minecraft.World/Level/Storage/MockedLevelStorage.h b/Minecraft.World/Level/Storage/MockedLevelStorage.h index fcab5ec42..324410fb7 100644 --- a/Minecraft.World/Level/Storage/MockedLevelStorage.h +++ b/Minecraft.World/Level/Storage/MockedLevelStorage.h @@ -18,5 +18,5 @@ public: virtual std::wstring getLevelId(); public: - virtual ConsoleSaveFile* getSaveFile() { return NULL; } + virtual ConsoleSaveFile* getSaveFile() { return nullptr; } }; \ No newline at end of file diff --git a/Minecraft.World/Level/Storage/OldChunkStorage.cpp b/Minecraft.World/Level/Storage/OldChunkStorage.cpp index 496caeea7..b00a8e85e 100644 --- a/Minecraft.World/Level/Storage/OldChunkStorage.cpp +++ b/Minecraft.World/Level/Storage/OldChunkStorage.cpp @@ -116,7 +116,7 @@ LevelChunk* OldChunkStorage::load(Level* level, int x, int z) { "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]; @@ -124,7 +124,7 @@ LevelChunk* OldChunkStorage::load(Level* level, int x, int z) { "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")); @@ -146,7 +146,7 @@ LevelChunk* OldChunkStorage::load(Level* level, int x, int z) { // e.printStackTrace(); // } } - return NULL; + return nullptr; } void OldChunkStorage::save(Level* level, LevelChunk* levelChunk) { @@ -275,7 +275,7 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, PIXBeginNamedEvent(0, "Saving tile tick data"); std::vector* ticksInChunk = level->fetchTicksInChunk(lc, false); - if (ticksInChunk != NULL) { + if (ticksInChunk != nullptr) { int64_t levelTime = level->getGameTime(); ListTag* tickTags = new ListTag(); @@ -373,7 +373,7 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) { PIXBeginNamedEvent(0, "Saving tile tick data"); std::vector* ticksInChunk = level->fetchTicksInChunk(lc, false); - if (ticksInChunk != NULL) { + if (ticksInChunk != nullptr) { int64_t levelTime = level->getGameTime(); ListTag* tickTags = new ListTag(); @@ -400,12 +400,12 @@ 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); std::shared_ptr te = EntityIO::loadStatic(teTag, level); lc->lastSaveHadEntities = true; - if (te != NULL) { + if (te != nullptr) { lc->addEntity(te); } } @@ -413,11 +413,11 @@ void OldChunkStorage::loadEntities(LevelChunk* lc, Level* level, 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); std::shared_ptr te = TileEntity::loadStatic(teTag); - if (te != NULL) { + if (te != nullptr) { lc->addTileEntity(te); } } @@ -479,7 +479,7 @@ LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) { ListTag* tileTicks = (ListTag*)tag->getList(L"TileTicks"); - if (tileTicks != NULL) { + if (tileTicks != nullptr) { for (int i = 0; i < tileTicks->size(); i++) { CompoundTag* teTag = tileTicks->get(i); @@ -584,7 +584,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++) { CompoundTag* teTag = tileTicks->get(i); diff --git a/Minecraft.World/Level/Storage/PortalForcer.cpp b/Minecraft.World/Level/Storage/PortalForcer.cpp index 85d813ef3..b7f877007 100644 --- a/Minecraft.World/Level/Storage/PortalForcer.cpp +++ b/Minecraft.World/Level/Storage/PortalForcer.cpp @@ -483,7 +483,7 @@ void PortalForcer::tick(int64_t time) { int64_t key = *it; PortalPosition* pos = cachedPortals[key]; - if (pos == NULL || pos->lastUsed < cutoff) { + if (pos == nullptr || pos->lastUsed < cutoff) { delete pos; it = cachedPortalKeys.erase(it); cachedPortals.erase(key); diff --git a/Minecraft.World/Level/Storage/ReadOnlyChunkCache.cpp b/Minecraft.World/Level/Storage/ReadOnlyChunkCache.cpp index 169308b4b..41f8c72e3 100644 --- a/Minecraft.World/Level/Storage/ReadOnlyChunkCache.cpp +++ b/Minecraft.World/Level/Storage/ReadOnlyChunkCache.cpp @@ -21,7 +21,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) { return getChunk(x, z); } @@ -32,7 +32,7 @@ LevelChunk* ReadOnlyChunkCache::getChunk(int x, int z) { // try { if (!hasChunk(x, z)) { LevelChunk* newChunk = load(x, z); - if (newChunk == NULL) { + if (newChunk == nullptr) { newChunk = new EmptyLevelChunk(level, emptyPixels, x, z); } chunks[slot] = newChunk; @@ -68,10 +68,10 @@ std::wstring ReadOnlyChunkCache::gatherStats() { return L"ReadOnlyChunkCache"; } std::vector* ReadOnlyChunkCache::getMobsAt( MobCategory* mobCategory, int x, int y, int z) { - return NULL; + return nullptr; } TilePos* ReadOnlyChunkCache::findNearestMapFeature( Level* level, const std::wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } diff --git a/Minecraft.World/Level/Storage/Region.cpp b/Minecraft.World/Level/Storage/Region.cpp index 9d1962f7a..2c4cf90a4 100644 --- a/Minecraft.World/Level/Storage/Region.cpp +++ b/Minecraft.World/Level/Storage/Region.cpp @@ -39,7 +39,7 @@ Region::Region(Level* level, int x1, int y1, int z1, int x2, int y2, int z2, for (int xc = xc1; xc <= xc2; xc++) { 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; } @@ -49,7 +49,7 @@ Region::Region(Level* level, int x1, int y1, int z1, int x2, int y2, int z2, for (int zc = (z1 >> 4); zc <= (z2 >> 4); zc++) { LevelChunkArray* lca = (*chunks)[xc - xc1]; LevelChunk* chunk = lca->data[zc - zc1]; - if (chunk != NULL) { + if (chunk != nullptr) { if (!chunk->isYSpaceEmpty(y1, y2)) { allEmpty = false; } @@ -60,7 +60,7 @@ Region::Region(Level* level, int x1, int y1, int z1, int x2, int y2, int z2, // AP - added a caching system for Chunk::rebuild to take advantage of xcCached = -1; zcCached = -1; - CachedTiles = NULL; + CachedTiles = nullptr; } bool Region::isAllEmpty() { return allEmpty; } @@ -82,7 +82,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); } @@ -92,7 +92,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 = (unsigned char*)malloc(size); } memcpy(CachedTiles, tiles, size); @@ -100,14 +100,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 >= (int)chunks->length || zc < 0 || zc >= (int)(*chunks)[xc]->length) { - return NULL; + return nullptr; } LevelChunk* lc = (*chunks)[xc]->data[zc]; @@ -205,7 +205,7 @@ Biome* Region::getBiome(int x, int z) { return level->getBiome(x, 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 @@ -223,7 +223,7 @@ bool Region::isSolidRenderTile(int x, int y, int z) { int azo[6] = {0, 0, 0, 0, 1, -1}; 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) || + if ((t != Tile::leaves_Id) && ((Tile::tiles[t] == nullptr) || !Tile::tiles[t]->isSolidRender())) { return false; } @@ -237,7 +237,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(); } @@ -248,7 +248,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); } // 4J - brought forward from 1.8.2 diff --git a/Minecraft.World/Level/Storage/RegionFile.cpp b/Minecraft.World/Level/Storage/RegionFile.cpp index 46f87ed69..043bc1ec0 100644 --- a/Minecraft.World/Level/Storage/RegionFile.cpp +++ b/Minecraft.World/Level/Storage/RegionFile.cpp @@ -52,7 +52,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) { // std::uint8_t zero = 0; unsigned int numberOfBytesWritten = 0; @@ -172,7 +172,7 @@ DataInputStream* RegionFile::getChunkDataInputStream( { if (outOfBounds(x, z)) { // debugln("READ", x, z, "out of bounds"); - return NULL; + return nullptr; } // 4J - removed try/catch @@ -180,7 +180,7 @@ DataInputStream* RegionFile::getChunkDataInputStream( int offset = getOffset(x, z); if (offset == 0) { // debugln("READ", x, z, "miss"); - return NULL; + return nullptr; } unsigned int sectorNumber = offset >> 8; @@ -188,7 +188,7 @@ DataInputStream* RegionFile::getChunkDataInputStream( if (sectorNumber + numSectors > sectorFree->size()) { // debugln("READ", x, z, "invalid sector"); - return NULL; + return nullptr; } m_saveFile->LockSaveAccess(); @@ -228,7 +228,7 @@ DataInputStream* RegionFile::getChunkDataInputStream( // " + numSectors); m_saveFile->ReleaseSaveAccess(); - return NULL; + return nullptr; } MemSect(50); @@ -392,7 +392,7 @@ void RegionFile::write(int x, int z, std::uint8_t* data, #endif unsigned int 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); diff --git a/Minecraft.World/Level/Storage/RegionFileCache.cpp b/Minecraft.World/Level/Storage/RegionFileCache.cpp index 357eeaa3a..5d7da2a24 100644 --- a/Minecraft.World/Level/Storage/RegionFileCache.cpp +++ b/Minecraft.World/Level/Storage/RegionFileCache.cpp @@ -38,12 +38,12 @@ RegionFile* RegionFileCache::_getRegionFile( } MemSect(0); - RegionFile* ref = NULL; + RegionFile* ref = nullptr; AUTO_VAR(it, cache.find(file)); if (it != cache.end()) ref = it->second; // 4J Jev, put back in. - if (ref != NULL) { + if (ref != nullptr) { return ref; } @@ -70,7 +70,7 @@ void RegionFileCache::_clear() // 4J - TODO was synchronized // 4J - removed try/catch // try { RegionFile* regionFile = it->second; - if (regionFile != NULL) { + if (regionFile != nullptr) { regionFile->close(); } delete regionFile; diff --git a/Minecraft.World/Level/Storage/SavedDataStorage.cpp b/Minecraft.World/Level/Storage/SavedDataStorage.cpp index 3490d30f7..ebfa9efaf 100644 --- a/Minecraft.World/Level/Storage/SavedDataStorage.cpp +++ b/Minecraft.World/Level/Storage/SavedDataStorage.cpp @@ -25,7 +25,7 @@ std::shared_ptr SavedDataStorage::get(const std::type_info& clazz, if (it != cache.end()) return (*it).second; std::shared_ptr data = nullptr; - if (levelStorage != NULL) { + if (levelStorage != nullptr) { // File file = levelStorage->getDataFile(id); ConsoleSavePath file = levelStorage->getDataFile(id); if (!file.getName().empty() && @@ -60,7 +60,7 @@ std::shared_ptr SavedDataStorage::get(const std::type_info& clazz, } } - if (data != NULL) { + if (data != nullptr) { cache.insert( std::unordered_map >::value_type(id, @@ -72,7 +72,7 @@ std::shared_ptr SavedDataStorage::get(const std::type_info& clazz, void SavedDataStorage::set(const std::wstring& id, std::shared_ptr data) { - if (data == NULL) { + if (data == nullptr) { // TODO 4J Stu - throw new RuntimeException("Can't set null data"); assert(false); } @@ -100,7 +100,7 @@ void SavedDataStorage::save() { } void SavedDataStorage::save(std::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()) { @@ -122,7 +122,7 @@ void SavedDataStorage::save(std::shared_ptr data) { 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() && @@ -139,7 +139,7 @@ void SavedDataStorage::loadAuxValues() { for (AUTO_VAR(it, allTags->begin()); it != itEnd; it++) { tag = *it; // tags->getAllTags()->at(i); - if (dynamic_cast(tag) != NULL) { + if (dynamic_cast(tag) != nullptr) { ShortTag* sTag = (ShortTag*)tag; std::wstring id = sTag->getName(); short val = sTag->data; @@ -159,7 +159,7 @@ int SavedDataStorage::getFreeAuxValueFor(const std::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()) { @@ -186,7 +186,7 @@ int SavedDataStorage::getFreeAuxValueFor(const std::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) { case -1: return MAP_NETHER_DEFAULT_INDEX; diff --git a/Minecraft.World/Level/Storage/SparseDataStorage.cpp b/Minecraft.World/Level/Storage/SparseDataStorage.cpp index f621d3fe7..2dfdef0ab 100644 --- a/Minecraft.World/Level/Storage/SparseDataStorage.cpp +++ b/Minecraft.World/Level/Storage/SparseDataStorage.cpp @@ -458,7 +458,7 @@ void SparseDataStorage::tick() { // 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(); // if( toFree ) printf("Deleting 0x%x\n", toFree); diff --git a/Minecraft.World/Level/Storage/SparseLightStorage.cpp b/Minecraft.World/Level/Storage/SparseLightStorage.cpp index 03c872179..aa262052a 100644 --- a/Minecraft.World/Level/Storage/SparseLightStorage.cpp +++ b/Minecraft.World/Level/Storage/SparseLightStorage.cpp @@ -461,7 +461,7 @@ void SparseLightStorage::tick() { // 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(); // if( toFree ) printf("Deleting 0x%x\n", toFree); diff --git a/Minecraft.World/Level/Storage/ZoneFile.cpp b/Minecraft.World/Level/Storage/ZoneFile.cpp index bcb0764ca..b89fc2c49 100644 --- a/Minecraft.World/Level/Storage/ZoneFile.cpp +++ b/Minecraft.World/Level/Storage/ZoneFile.cpp @@ -7,13 +7,13 @@ namespace { std::FILE* OpenBinaryFileForReadWrite(const File& file) { #if defined(_WIN32) std::FILE* stream = _wfopen(file.getPath().c_str(), L"r+b"); - if (stream == NULL) { + if (stream == nullptr) { stream = _wfopen(file.getPath().c_str(), L"w+b"); } #else const std::string nativePath = wstringtofilename(file.getPath()); std::FILE* stream = std::fopen(nativePath.c_str(), "r+b"); - if (stream == NULL) { + if (stream == nullptr) { stream = std::fopen(nativePath.c_str(), "w+b"); } #endif @@ -85,9 +85,9 @@ void ZoneFile::writeHeader() { } void ZoneFile::close() { - if (channel != NULL) { + if (channel != nullptr) { std::fclose(channel); - channel = NULL; + channel = nullptr; } entityFile->close(); } diff --git a/Minecraft.World/Level/Storage/ZonedChunkStorage.cpp b/Minecraft.World/Level/Storage/ZonedChunkStorage.cpp index fcdc90cd2..4cc0157ca 100644 --- a/Minecraft.World/Level/Storage/ZonedChunkStorage.cpp +++ b/Minecraft.World/Level/Storage/ZonedChunkStorage.cpp @@ -63,10 +63,10 @@ ZoneFile* ZonedChunkStorage::getZoneFile(int x, int z, bool create) { L"_" + _toString(zRadix36) + L".dat"); if (!file.exists()) { - if (!create) return NULL; + if (!create) return nullptr; HANDLE ch = CreateFile(wstringtofilename(file.getPath()), - GENERIC_READ | GENERIC_WRITE, 0, NULL, - OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + GENERIC_READ | GENERIC_WRITE, 0, nullptr, + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); CloseHandle(ch); } @@ -80,20 +80,20 @@ ZoneFile* ZonedChunkStorage::getZoneFile(int x, int z, bool create) { ZoneFile* zoneFile = zoneFiles[key]; zoneFile->lastUse = tickCount; if (!zoneFile->containsSlot(slot)) { - if (!create) return NULL; + if (!create) return nullptr; } return zoneFile; } 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; @@ -200,10 +200,10 @@ void ZonedChunkStorage::loadEntities(Level* level, LevelChunk* lc) { int type = tag->getInt(L"_TYPE"); if (type == 0) { std::shared_ptr e = EntityIO::loadStatic(tag, level); - if (e != NULL) lc->addEntity(e); + if (e != nullptr) lc->addEntity(e); } else if (type == 1) { std::shared_ptr te = TileEntity::loadStatic(tag); - if (te != NULL) lc->addTileEntity(te); + if (te != nullptr) lc->addTileEntity(te); } } } diff --git a/Minecraft.World/Level/TickNextTickData.cpp b/Minecraft.World/Level/TickNextTickData.cpp index e20d27d14..999a1c18b 100644 --- a/Minecraft.World/Level/TickNextTickData.cpp +++ b/Minecraft.World/Level/TickNextTickData.cpp @@ -18,7 +18,7 @@ TickNextTickData::TickNextTickData(int x, int y, int z, int tileId) { 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/Level/WaterLevelChunk.cpp b/Minecraft.World/Level/WaterLevelChunk.cpp index 00102b2b3..27a64e93e 100644 --- a/Minecraft.World/Level/WaterLevelChunk.cpp +++ b/Minecraft.World/Level/WaterLevelChunk.cpp @@ -118,5 +118,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/Network/Connection.cpp b/Minecraft.World/Network/Connection.cpp index 709c53e2f..cb7ab6c61 100644 --- a/Minecraft.World/Network/Connection.cpp +++ b/Minecraft.World/Network/Connection.cpp @@ -30,7 +30,7 @@ void Connection::_init() { quitting = false; disconnected = false; disconnectReason = DisconnectPacket::eDisconnect_None; - disconnectReasonObjects = NULL; + disconnectReasonObjects = nullptr; noInputTicks = 0; estimatedRemaining = 0; fakeLag = 0; @@ -64,16 +64,16 @@ 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 std::wstring& id, @@ -180,7 +180,7 @@ bool Connection::writeTick() { // 4J Stu - If the connection is closed and the output stream has been // deleted - if (bufferedDos == NULL || byteArrayDos == NULL) return didSomething; + if (bufferedDos == nullptr || byteArrayDos == nullptr) return didSomething; // try { if (!outgoing.empty() && @@ -320,14 +320,14 @@ bool Connection::readTick() { // 4J Stu - If the connection has closed and the input stream has been // deleted - if (dis == NULL) return didSomething; + if (dis == nullptr) return didSomething; // try { std::shared_ptr packet = Packet::readPacket(dis, packetListener->isServerPacketListener()); - if (packet != NULL) { + if (packet != nullptr) { readSizes[packet->getId()] += packet->getEstimatedSize() + 1; EnterCriticalSection(&incoming_cs); if (!quitting) { @@ -368,7 +368,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason) { disconnected = true; disconnectReason = reason; // va_arg( input, const wstring ); - disconnectReasonObjects = NULL; + disconnectReasonObjects = nullptr; // int count = 0, sum = 0, i = first; // va_list marker; @@ -383,7 +383,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason) { // va_end( marker ); // return( sum ? (sum / count) : 0 ); - // CreateThread(NULL, 0, runClose, this, 0, &closeThreadID); + // CreateThread(nullptr, 0, runClose, this, 0, &closeThreadID); running = false; @@ -398,21 +398,21 @@ 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; } } @@ -534,7 +534,7 @@ int Connection::runRead(void* lpParam) { ShutdownManager::HasStarted(ShutdownManager::eConnectionReadThreads); Connection* con = (Connection*)lpParam; - if (con == NULL) { + if (con == nullptr) { return 0; } @@ -580,7 +580,7 @@ int Connection::runWrite(void* lpParam) { ShutdownManager::HasStarted(ShutdownManager::eConnectionWriteThreads); Connection* con = dynamic_cast((Connection*)lpParam); - if (con == NULL) { + if (con == nullptr) { ShutdownManager::HasFinished(ShutdownManager::eConnectionWriteThreads); return 0; } @@ -609,8 +609,8 @@ int Connection::runWrite(void* lpParam) { // 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(); } // 4J was in a finally block. @@ -625,7 +625,7 @@ int Connection::runWrite(void* lpParam) { int Connection::runClose(void* lpParam) { Connection* con = dynamic_cast((Connection*)lpParam); - if (con == NULL) return 0; + if (con == nullptr) return 0; // try { @@ -647,7 +647,7 @@ int Connection::runSendAndQuit(void* lpParam) { Connection* con = dynamic_cast((Connection*)lpParam); // printf("Con:0x%x runSendAndQuit\n",con); - if (con == NULL) return 0; + if (con == nullptr) return 0; // try { diff --git a/Minecraft.World/Network/Packets/AddMobPacket.cpp b/Minecraft.World/Network/Packets/AddMobPacket.cpp index cc407caca..b6ce8b268 100644 --- a/Minecraft.World/Network/Packets/AddMobPacket.cpp +++ b/Minecraft.World/Network/Packets/AddMobPacket.cpp @@ -14,7 +14,7 @@ AddMobPacket::AddMobPacket() { yRot = static_cast(0); xRot = static_cast(0); entityData = nullptr; - unpack = NULL; + unpack = nullptr; } AddMobPacket::~AddMobPacket() { delete unpack; } @@ -56,7 +56,7 @@ AddMobPacket::AddMobPacket(std::shared_ptr mob, int yRotp, // printf("%d: New add mob rot %d\n",id,yRot); entityData = mob->getEntityData(); - unpack = NULL; + unpack = nullptr; } void AddMobPacket::read(DataInputStream* dis) // throws IOException @@ -111,9 +111,9 @@ 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 @@ -123,7 +123,7 @@ int AddMobPacket::getEstimatedSize() { std::vector >* AddMobPacket::getUnpackedData() { - if (unpack == NULL) { + if (unpack == nullptr) { unpack = entityData->getAll(); } return unpack; diff --git a/Minecraft.World/Network/Packets/AddPlayerPacket.cpp b/Minecraft.World/Network/Packets/AddPlayerPacket.cpp index fb2a6520a..6f9c943d5 100644 --- a/Minecraft.World/Network/Packets/AddPlayerPacket.cpp +++ b/Minecraft.World/Network/Packets/AddPlayerPacket.cpp @@ -21,11 +21,11 @@ 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(std::shared_ptr player, PlayerUID xuid, @@ -52,7 +52,7 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr player, PlayerUID xuid, std::shared_ptr itemInstance = player->inventory->getSelected(); - carriedItem = itemInstance == NULL ? 0 : itemInstance->id; + carriedItem = itemInstance == nullptr ? 0 : itemInstance->id; this->xuid = xuid; this->OnlineXuid = OnlineXuid; @@ -62,7 +62,7 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr player, PlayerUID xuid, m_uiGamePrivileges = player->getAllPlayerGamePrivileges(); entityData = player->getEntityData(); - unpack = NULL; + unpack = nullptr; } void AddPlayerPacket::read(DataInputStream* dis) // throws IOException @@ -121,9 +121,9 @@ int AddPlayerPacket::getEstimatedSize() { sizeof(int) + sizeof(BYTE) + sizeof(unsigned int) + sizeof(uint8_t); - 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() { std::vector >* AddPlayerPacket::getUnpackedData() { - if (unpack == NULL) { + if (unpack == nullptr) { unpack = entityData->getAll(); } return unpack; diff --git a/Minecraft.World/Network/Packets/AwardStatPacket.cpp b/Minecraft.World/Network/Packets/AwardStatPacket.cpp index de9caf776..b87aebca3 100644 --- a/Minecraft.World/Network/Packets/AwardStatPacket.cpp +++ b/Minecraft.World/Network/Packets/AwardStatPacket.cpp @@ -5,7 +5,7 @@ #include "AwardStatPacket.h" AwardStatPacket::AwardStatPacket() { - this->m_paramData.data = NULL; + this->m_paramData.data = nullptr; this->m_paramData.length = 0; } @@ -28,15 +28,15 @@ 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/Network/Packets/ContainerSetContentPacket.cpp b/Minecraft.World/Network/Packets/ContainerSetContentPacket.cpp index be8ed676c..b25b11f2d 100644 --- a/Minecraft.World/Network/Packets/ContainerSetContentPacket.cpp +++ b/Minecraft.World/Network/Packets/ContainerSetContentPacket.cpp @@ -15,7 +15,7 @@ ContainerSetContentPacket::ContainerSetContentPacket( items = ItemInstanceArray((int)newItems->size()); for (unsigned int i = 0; i < items.length; i++) { std::shared_ptr item = newItems->at(i); - items[i] = item == NULL ? nullptr : item->copy(); + items[i] = item == nullptr ? nullptr : item->copy(); } } diff --git a/Minecraft.World/Network/Packets/ContainerSetSlotPacket.cpp b/Minecraft.World/Network/Packets/ContainerSetSlotPacket.cpp index 27ca694d8..5483c1a90 100644 --- a/Minecraft.World/Network/Packets/ContainerSetSlotPacket.cpp +++ b/Minecraft.World/Network/Packets/ContainerSetSlotPacket.cpp @@ -19,7 +19,7 @@ ContainerSetSlotPacket::ContainerSetSlotPacket( int containerId, int slot, std::shared_ptr item) { 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/Network/Packets/CustomPayloadPacket.cpp b/Minecraft.World/Network/Packets/CustomPayloadPacket.cpp index 795a4a96e..87e9af094 100644 --- a/Minecraft.World/Network/Packets/CustomPayloadPacket.cpp +++ b/Minecraft.World/Network/Packets/CustomPayloadPacket.cpp @@ -22,7 +22,7 @@ CustomPayloadPacket::CustomPayloadPacket(const std::wstring& identifier, this->identifier = identifier; this->data = data; - if (data.data != NULL) { + if (data.data != nullptr) { length = data.length; if (length > std::numeric_limits::max()) { @@ -41,7 +41,7 @@ void CustomPayloadPacket::read(DataInputStream* dis) { length = dis->readShort(); if (length > 0 && length < std::numeric_limits::max()) { - if (data.data != NULL) { + if (data.data != nullptr) { delete[] data.data; } data = byteArray(length); @@ -52,7 +52,7 @@ void CustomPayloadPacket::read(DataInputStream* dis) { void CustomPayloadPacket::write(DataOutputStream* dos) { writeUtf(identifier, dos); dos->writeShort((short)length); - if (data.data != NULL) { + if (data.data != nullptr) { dos->write(data); } } diff --git a/Minecraft.World/Network/Packets/ExplodePacket.cpp b/Minecraft.World/Network/Packets/ExplodePacket.cpp index d636edd13..99419040c 100644 --- a/Minecraft.World/Network/Packets/ExplodePacket.cpp +++ b/Minecraft.World/Network/Packets/ExplodePacket.cpp @@ -26,7 +26,7 @@ ExplodePacket::ExplodePacket( this->r = r; m_bKnockbackOnly = knockBackOnly; - if (toBlow != NULL) { + if (toBlow != nullptr) { this->toBlow.assign(toBlow->begin(), toBlow->end()); // for( AUTO_VAR(it, toBlow->begin()); it != toBlow->end(); it++ ) //{ @@ -34,7 +34,7 @@ ExplodePacket::ExplodePacket( // } } - if (knockback != NULL) { + if (knockback != nullptr) { knockbackX = (float)knockback->x; knockbackY = (float)knockback->y; knockbackZ = (float)knockback->z; diff --git a/Minecraft.World/Network/Packets/GameCommandPacket.cpp b/Minecraft.World/Network/Packets/GameCommandPacket.cpp index f662e5c29..33d1ebbf7 100644 --- a/Minecraft.World/Network/Packets/GameCommandPacket.cpp +++ b/Minecraft.World/Network/Packets/GameCommandPacket.cpp @@ -11,7 +11,7 @@ GameCommandPacket::GameCommandPacket(EGameCommand command, byteArray data) { this->data = data; length = 0; - if (data.data != NULL) { + if (data.data != nullptr) { length = data.length; if (length > std::numeric_limits::max()) { @@ -32,7 +32,7 @@ void GameCommandPacket::read(DataInputStream* dis) { length = dis->readShort(); if (length > 0 && length < std::numeric_limits::max()) { - if (data.data != NULL) { + if (data.data != nullptr) { delete[] data.data; } data = byteArray(length); @@ -43,7 +43,7 @@ void GameCommandPacket::read(DataInputStream* dis) { void GameCommandPacket::write(DataOutputStream* dos) { dos->writeInt(command); dos->writeShort((short)length); - if (data.data != NULL) { + if (data.data != nullptr) { dos->write(data); } } diff --git a/Minecraft.World/Network/Packets/LoginPacket.cpp b/Minecraft.World/Network/Packets/LoginPacket.cpp index d46ba8a1b..da4a00667 100644 --- a/Minecraft.World/Network/Packets/LoginPacket.cpp +++ b/Minecraft.World/Network/Packets/LoginPacket.cpp @@ -28,7 +28,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; @@ -60,7 +60,7 @@ LoginPacket::LoginPacket(const std::wstring& userName, int clientVersion, 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; @@ -106,7 +106,7 @@ void LoginPacket::read(DataInputStream* dis) // throws IOException userName = readUtf(dis, Player::MAX_NAME_LENGTH); std::wstring typeName = readUtf(dis, 16); m_pLevelType = LevelType::getLevelType(typeName); - if (m_pLevelType == NULL) { + if (m_pLevelType == nullptr) { m_pLevelType = LevelType::lvl_normal; } seed = dis->readLong(); @@ -137,7 +137,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); } else { writeUtf(m_pLevelType->getGeneratorName(), dos); @@ -171,7 +171,7 @@ void LoginPacket::handle(PacketListener* listener) { int LoginPacket::getEstimatedSize() { int length = 0; - if (m_pLevelType != NULL) { + if (m_pLevelType != nullptr) { length = (int)m_pLevelType->getGeneratorName().length(); } diff --git a/Minecraft.World/Network/Packets/MoveEntityPacket.cpp b/Minecraft.World/Network/Packets/MoveEntityPacket.cpp index 30ca1b905..1d4d114b2 100644 --- a/Minecraft.World/Network/Packets/MoveEntityPacket.cpp +++ b/Minecraft.World/Network/Packets/MoveEntityPacket.cpp @@ -52,7 +52,7 @@ bool MoveEntityPacket::canBeInvalidated() { return true; } bool MoveEntityPacket::isInvalidatedBy(std::shared_ptr packet) { std::shared_ptr target = std::dynamic_pointer_cast(packet); - return target != NULL && target->id == id; + return target != nullptr && target->id == id; } MoveEntityPacket::PosRot::PosRot() { hasRot = true; } diff --git a/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp b/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp index 085ff3152..844e400ba 100644 --- a/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp +++ b/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp @@ -58,7 +58,7 @@ bool MoveEntityPacketSmall::canBeInvalidated() { return true; } bool MoveEntityPacketSmall::isInvalidatedBy(std::shared_ptr packet) { std::shared_ptr target = std::dynamic_pointer_cast(packet); - return target != NULL && target->id == id; + return target != nullptr && target->id == id; } MoveEntityPacketSmall::PosRot::PosRot() { hasRot = true; } diff --git a/Minecraft.World/Network/Packets/Packet.cpp b/Minecraft.World/Network/Packets/Packet.cpp index 276cdd8a2..f1562112e 100644 --- a/Minecraft.World/Network/Packets/Packet.cpp +++ b/Minecraft.World/Network/Packets/Packet.cpp @@ -424,7 +424,7 @@ std::shared_ptr Packet::readPacket( } packet = getPacket(id); - if (packet == NULL) + if (packet == nullptr) assert(false); // throw new IOException(wstring(L"Bad packet id ") + // _toString(id)); @@ -436,7 +436,7 @@ std::shared_ptr Packet::readPacket( // { // // reached end of stream // OutputDebugString("Reached end of stream"); - // return NULL; + // return nullptr; // } // 4J - Don't bother tracking stats in a content package @@ -588,7 +588,7 @@ std::shared_ptr Packet::readItem(DataInputStream* dis) { void Packet::writeItem(std::shared_ptr item, DataOutputStream* dos) { - if (item == NULL) { + if (item == nullptr) { dos->writeShort(-1); } else { dos->writeShort(item->id); @@ -605,7 +605,7 @@ void Packet::writeItem(std::shared_ptr item, 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); @@ -614,7 +614,7 @@ CompoundTag* Packet::readNbt(DataInputStream* dis) { } void Packet::writeNbt(CompoundTag* tag, DataOutputStream* dos) { - if (tag == NULL) { + if (tag == nullptr) { dos->writeShort(-1); } else { byteArray buff = NbtIo::compress(tag); diff --git a/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp b/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp index 4dc58d535..30b80762b 100644 --- a/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp +++ b/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp @@ -27,8 +27,8 @@ PlayerInfoPacket::PlayerInfoPacket(std::uint8_t networkSmallId, PlayerInfoPacket::PlayerInfoPacket(std::shared_ptr player) { m_networkSmallId = 0; - if (player->connection != NULL && - player->connection->getNetworkPlayer() != NULL) + if (player->connection != nullptr && + player->connection->getNetworkPlayer() != nullptr) m_networkSmallId = player->connection->getNetworkPlayer()->GetSmallId(); m_playerColourIndex = player->getPlayerIndex(); m_playerPrivileges = player->getAllPlayerGamePrivileges(); diff --git a/Minecraft.World/Network/Packets/PreLoginPacket.cpp b/Minecraft.World/Network/Packets/PreLoginPacket.cpp index 55459bffd..4173fd6a8 100644 --- a/Minecraft.World/Network/Packets/PreLoginPacket.cpp +++ b/Minecraft.World/Network/Packets/PreLoginPacket.cpp @@ -8,7 +8,7 @@ PreLoginPacket::PreLoginPacket() { loginKey = L""; - m_playerXuids = NULL; + m_playerXuids = nullptr; m_dwPlayerCount = 0; m_friendsOnlyBits = 0; m_ugcPlayersVersion = 0; @@ -21,7 +21,7 @@ PreLoginPacket::PreLoginPacket() { PreLoginPacket::PreLoginPacket(std::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( } 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/Network/Packets/RespawnPacket.cpp b/Minecraft.World/Network/Packets/RespawnPacket.cpp index ba4678979..494648da5 100644 --- a/Minecraft.World/Network/Packets/RespawnPacket.cpp +++ b/Minecraft.World/Network/Packets/RespawnPacket.cpp @@ -10,9 +10,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; @@ -46,7 +46,7 @@ void RespawnPacket::read(DataInputStream* dis) // throws IOException mapHeight = dis->readShort(); std::wstring typeName = readUtf(dis, 16); m_pLevelType = LevelType::getLevelType(typeName); - if (m_pLevelType == NULL) { + if (m_pLevelType == nullptr) { m_pLevelType = LevelType::lvl_normal; } mapSeed = dis->readLong(); @@ -65,7 +65,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); } else { writeUtf(m_pLevelType->getGeneratorName(), dos); @@ -82,7 +82,7 @@ void RespawnPacket::write(DataOutputStream* dos) // throws IOException int RespawnPacket::getEstimatedSize() { int length = 0; - if (m_pLevelType != NULL) { + if (m_pLevelType != nullptr) { length = (int)m_pLevelType->getGeneratorName().length(); } return 13 + length; diff --git a/Minecraft.World/Network/Packets/SetDisplayObjectivePacket.cpp b/Minecraft.World/Network/Packets/SetDisplayObjectivePacket.cpp index ba62aff85..266c8130d 100644 --- a/Minecraft.World/Network/Packets/SetDisplayObjectivePacket.cpp +++ b/Minecraft.World/Network/Packets/SetDisplayObjectivePacket.cpp @@ -12,7 +12,7 @@ SetDisplayObjectivePacket::SetDisplayObjectivePacket(int slot, Objective* objective) { this->slot = slot; - if (objective == NULL) { + if (objective == nullptr) { objectiveName = L""; } else { objectiveName = objective->getName(); diff --git a/Minecraft.World/Network/Packets/SetEntityDataPacket.cpp b/Minecraft.World/Network/Packets/SetEntityDataPacket.cpp index c8765b1a5..74598842e 100644 --- a/Minecraft.World/Network/Packets/SetEntityDataPacket.cpp +++ b/Minecraft.World/Network/Packets/SetEntityDataPacket.cpp @@ -7,7 +7,7 @@ SetEntityDataPacket::SetEntityDataPacket() { id = -1; - packedItems = NULL; + packedItems = nullptr; } SetEntityDataPacket::~SetEntityDataPacket() { delete packedItems; } diff --git a/Minecraft.World/Network/Packets/SetEntityLinkPacket.cpp b/Minecraft.World/Network/Packets/SetEntityLinkPacket.cpp index 6ba2bd235..4172e3eba 100644 --- a/Minecraft.World/Network/Packets/SetEntityLinkPacket.cpp +++ b/Minecraft.World/Network/Packets/SetEntityLinkPacket.cpp @@ -16,7 +16,7 @@ SetEntityLinkPacket::SetEntityLinkPacket(int linkType, std::shared_ptr destEntity) { type = linkType; this->sourceId = sourceEntity->entityId; - this->destId = destEntity != NULL ? destEntity->entityId : -1; + this->destId = destEntity != nullptr ? destEntity->entityId : -1; } int SetEntityLinkPacket::getEstimatedSize() { return 8; } diff --git a/Minecraft.World/Network/Packets/SetEquippedItemPacket.cpp b/Minecraft.World/Network/Packets/SetEquippedItemPacket.cpp index 866ff47a7..1e47d66cb 100644 --- a/Minecraft.World/Network/Packets/SetEquippedItemPacket.cpp +++ b/Minecraft.World/Network/Packets/SetEquippedItemPacket.cpp @@ -19,7 +19,7 @@ SetEquippedItemPacket::SetEquippedItemPacket( // 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/Network/Packets/SetPlayerTeamPacket.cpp b/Minecraft.World/Network/Packets/SetPlayerTeamPacket.cpp index 2c7afe20c..e0e77c0db 100644 --- a/Minecraft.World/Network/Packets/SetPlayerTeamPacket.cpp +++ b/Minecraft.World/Network/Packets/SetPlayerTeamPacket.cpp @@ -38,7 +38,7 @@ SetPlayerTeamPacket::SetPlayerTeamPacket(PlayerTeam* team, __debugbreak(); #endif } - if (playerNames == NULL || playerNames->empty()) { + if (playerNames == nullptr || playerNames->empty()) { app.DebugPrintf("Players cannot be null/empty"); #ifndef _CONTENT_PACKAGE __debugbreak(); diff --git a/Minecraft.World/Network/Packets/TextureAndGeometryPacket.cpp b/Minecraft.World/Network/Packets/TextureAndGeometryPacket.cpp index 4d94ba74c..03638e8e5 100644 --- a/Minecraft.World/Network/Packets/TextureAndGeometryPacket.cpp +++ b/Minecraft.World/Network/Packets/TextureAndGeometryPacket.cpp @@ -7,20 +7,20 @@ 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; // } @@ -40,7 +40,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket( this->pbData = pbData; this->dwTextureBytes = dataBytes; this->dwBoxC = 0; - this->BoxDataA = NULL; + this->BoxDataA = nullptr; this->uiAnimOverrideBitmask = 0; } @@ -70,7 +70,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket( this->BoxDataA[iCount++] = *pSkinBox; } } else { - this->BoxDataA = NULL; + this->BoxDataA = nullptr; } } @@ -90,9 +90,9 @@ TextureAndGeometryPacket::TextureAndGeometryPacket( this->pbData = pbData; this->dwTextureBytes = dataBytes; this->uiAnimOverrideBitmask = uiAnimOverrideBitmask; - if (pvSkinBoxes == NULL) { + if (pvSkinBoxes == nullptr) { this->dwBoxC = 0; - this->BoxDataA = NULL; + this->BoxDataA = nullptr; } else { this->dwBoxC = (std::uint32_t)pvSkinBoxes->size(); this->BoxDataA = new SKIN_BOX[this->dwBoxC]; diff --git a/Minecraft.World/Network/Packets/TexturePacket.cpp b/Minecraft.World/Network/Packets/TexturePacket.cpp index 6764f0301..2d5a10f78 100644 --- a/Minecraft.World/Network/Packets/TexturePacket.cpp +++ b/Minecraft.World/Network/Packets/TexturePacket.cpp @@ -7,12 +7,12 @@ TexturePacket::TexturePacket() { this->textureName = L""; this->dataBytes = 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/Network/Packets/TileEntityDataPacket.cpp b/Minecraft.World/Network/Packets/TileEntityDataPacket.cpp index b456d5d5b..0e2b129be 100644 --- a/Minecraft.World/Network/Packets/TileEntityDataPacket.cpp +++ b/Minecraft.World/Network/Packets/TileEntityDataPacket.cpp @@ -7,7 +7,7 @@ void TileEntityDataPacket::_init() { x = y = z = 0; type = TYPE_MOB_SPAWNER; - tag = NULL; + tag = nullptr; } TileEntityDataPacket::TileEntityDataPacket() { diff --git a/Minecraft.World/Network/Socket.cpp b/Minecraft.World/Network/Socket.cpp index cc10e4882..0153af75a 100644 --- a/Minecraft.World/Network/Socket.cpp +++ b/Minecraft.World/Network/Socket.cpp @@ -18,7 +18,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::EnsureStreamsInitialised() { // Thread-safe one-time initialisation via C++11 magic-statics guarantee. @@ -71,19 +71,19 @@ Socket::Socket(bool response) { } else { m_end = SOCKET_CLIENT_END; Socket* socket = new Socket(1); - if (s_serverConnection != NULL) { + if (s_serverConnection != nullptr) { s_serverConnection->NewIncomingSocket(socket); } else { app.DebugPrintf( "SOCKET: Warning - attempted to notify server of new incoming " - "socket but s_serverConnection is NULL\n"); + "socket but s_serverConnection is nullptr\n"); } } for (int i = 0; i < 2; i++) { m_endClosed[i] = false; } - m_socketClosedEvent = NULL; + m_socketClosedEvent = nullptr; createdOk = true; networkPlayerSmallId = g_NetworkManager.GetHostPlayer()->GetSmallId(); } @@ -95,8 +95,8 @@ Socket::Socket(INetworkPlayer* player, bool response /* = false*/, 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; } @@ -116,14 +116,14 @@ Socket::Socket(INetworkPlayer* player, bool response /* = false*/, createdOk = true; } -SocketAddress* Socket::getRemoteSocketAddress() { return NULL; } +SocketAddress* Socket::getRemoteSocketAddress() { return nullptr; } INetworkPlayer* Socket::getPlayer() { return g_NetworkManager.GetPlayerBySmallId(networkPlayerSmallId); } void Socket::setPlayer(INetworkPlayer* player) { - if (player != NULL) { + if (player != nullptr) { networkPlayerSmallId = player->GetSmallId(); } else { networkPlayerSmallId = 0; @@ -151,7 +151,7 @@ void Socket::pushDataToQueue(const std::uint8_t* pbData, std::size_t dataSize, } void Socket::addIncomingSocket(Socket* socket) { - if (s_serverConnection != NULL) { + if (s_serverConnection != nullptr) { s_serverConnection->NewIncomingSocket(socket); } } @@ -168,9 +168,9 @@ InputStream* Socket::getInputStream(bool isServerConnection) { return m_inputStream[m_end]; } } else { - if (s_hostInStream[m_end] == NULL) { + if (s_hostInStream[m_end] == nullptr) { app.DebugPrintf( - "SOCKET: Warning - s_hostInStream[%d] is NULL in " + "SOCKET: Warning - s_hostInStream[%d] is nullptr in " "getInputStream(); calling EnsureStreamsInitialised()\n", m_end); EnsureStreamsInitialised(); @@ -196,9 +196,9 @@ Socket::SocketOutputStream* Socket::getOutputStream(bool isServerConnection) { } } else { int outIdx = 1 - m_end; - if (s_hostOutStream[outIdx] == NULL) { + if (s_hostOutStream[outIdx] == nullptr) { app.DebugPrintf( - "SOCKET: Warning - s_hostOutStream[%d] is NULL in " + "SOCKET: Warning - s_hostOutStream[%d] is nullptr in " "getOutputStream(); calling EnsureStreamsInitialised()\n", outIdx); EnsureStreamsInitialised(); @@ -225,7 +225,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(); } if (allClosed) createdOk = false; @@ -452,15 +452,15 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(byteArray b, 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"); + "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"); + "Trying to write to network, but the socketPlayer is nullptr\n"); return; } @@ -477,7 +477,7 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(byteArray b, hostPlayer->SendData(socketPlayer, buffer.pbyData, buffer.dwDataSize, lowPriority, requireAck); - // DWORD queueSize = hostPlayer->GetSendQueueSize( NULL, + // DWORD queueSize = hostPlayer->GetSendQueueSize( nullptr, // QNET_GETSENDQUEUESIZE_BYTES ); if( queueSize > 24000 ) // { // //printf("Queue size is: %d, forcing diff --git a/Minecraft.World/Platform/System.cpp b/Minecraft.World/Platform/System.cpp index d0dfd3d97..9a9639817 100644 --- a/Minecraft.World/Platform/System.cpp +++ b/Minecraft.World/Platform/System.cpp @@ -83,7 +83,7 @@ int64_t System::nanoTime() { int64_t System::currentTimeMillis() { #if defined(__linux__) struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); // Convert to milliseconds since unix epoch instead of windows file time // time is expecting calculation to be between 10-30 ms. return (int64_t)tv.tv_sec * 1000LL + tv.tv_usec / 1000; diff --git a/Minecraft.World/Platform/x64headers/extraX64.h b/Minecraft.World/Platform/x64headers/extraX64.h index 7b6fadc9a..70714f24b 100644 --- a/Minecraft.World/Platform/x64headers/extraX64.h +++ b/Minecraft.World/Platform/x64headers/extraX64.h @@ -53,7 +53,7 @@ public: return ret; } - return NULL; + return nullptr; } }; diff --git a/Minecraft.World/Player/Player.cpp b/Minecraft.World/Player/Player.cpp index 131db939e..dec45701a 100644 --- a/Minecraft.World/Player/Player.cpp +++ b/Minecraft.World/Player/Player.cpp @@ -63,17 +63,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; @@ -180,7 +180,7 @@ std::shared_ptr Player::getUseItem() { return useItem; } int Player::getUseItemDuration() { return useItemDuration; } -bool Player::isUsingItem() { return useItem != NULL; } +bool Player::isUsingItem() { return useItem != nullptr; } int Player::getTicksUsingItem() { if (isUsingItem()) { @@ -190,7 +190,7 @@ int Player::getTicksUsingItem() { } void Player::releaseUsingItem() { - if (useItem != NULL) { + if (useItem != nullptr) { useItem->releaseUsing( level, std::dynamic_pointer_cast(shared_from_this()), useItemDuration); @@ -220,16 +220,16 @@ 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) { std::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) This is because the useItem and item could + // 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(); } else { if (useItemDuration <= 25 && useItemDuration % 4 == 0) { @@ -283,7 +283,7 @@ void Player::tick() { LivingEntity::tick(); if (!level->isClientSide) { - if (containerMenu != NULL && + if (containerMenu != nullptr && !containerMenu->stillValid( std::dynamic_pointer_cast(shared_from_this()))) { closeContainer(); @@ -315,10 +315,10 @@ void Player::tick() { zCloak += zca * 0.25; yCloak += yca * 0.25; - if (riding == NULL) { - if (minecartAchievementPos != NULL) { + if (riding == nullptr) { + if (minecartAchievementPos != nullptr) { delete minecartAchievementPos; - minecartAchievementPos = NULL; + minecartAchievementPos = nullptr; } } @@ -445,14 +445,14 @@ void Player::spawnEatParticles(std::shared_ptr useItem, } void Player::completeUsingItem() { - if (useItem != NULL) { + if (useItem != nullptr) { spawnEatParticles(useItem, 16); int oldCount = useItem->count; std::shared_ptr itemInstance = useItem->useTimeDepleted( level, std::dynamic_pointer_cast(shared_from_this())); if (itemInstance != useItem || - (itemInstance != NULL && itemInstance->count != oldCount)) { + (itemInstance != nullptr && itemInstance->count != oldCount)) { inventory->items[inventory->selected] = itemInstance; if (itemInstance->count == 0) { inventory->items[inventory->selected] = nullptr; @@ -475,10 +475,10 @@ bool Player::isImmobile() { return getHealth() <= 0 || isSleeping(); } void Player::closeContainer() { containerMenu = inventoryMenu; } void Player::ride(std::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 = std::weak_ptr(); } riding = nullptr; @@ -531,7 +531,7 @@ void Player::setCustomSkin(std::uint32_t 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); @@ -540,7 +540,7 @@ void Player::setCustomSkin(std::uint32_t skinId) { DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(this->customTextureUrl); - if(pDLCSkinFile!=NULL) + if(pDLCSkinFile!=nullptr) { const int additionalBoxCount = pDLCSkinFile->getAdditionalBoxesCount(); if(additionalBoxCount != 0) @@ -551,13 +551,13 @@ void Player::setCustomSkin(std::uint32_t skinId) { } else { - this->SetAdditionalModelParts(NULL); + this->SetAdditionalModelParts(nullptr); } app.SetAnimOverrideBitmask(pDLCSkinFile->getSkinID(),pDLCSkinFile->getAnimOverrideBitmask()); } else { - this->SetAdditionalModelParts(NULL); + this->SetAdditionalModelParts(nullptr); } } else @@ -571,7 +571,7 @@ void Player::setCustomSkin(std::uint32_t skinId) { // reset the check for model parts m_bCheckedForModelParts = false; m_bCheckedDLCForModelParts = false; - this->SetAdditionalModelParts(NULL); + this->SetAdditionalModelParts(nullptr); } unsigned int Player::getSkinAnimOverrideBitmask(std::uint32_t skinId) { @@ -781,7 +781,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; @@ -850,7 +850,7 @@ void Player::aiStep() { if (getHealth() > 0) { AABB pickupArea; - if (riding != NULL && !riding->removed) { + if (riding != nullptr && !riding->removed) { // if the player is riding, also touch entities under the // pig/horse pickupArea = bb.minmax(riding->bb).grow(1, 0, 1); @@ -860,7 +860,7 @@ void Player::aiStep() { std::vector >* entities = level->getEntities(shared_from_this(), &pickupArea); - if (entities != NULL) { + if (entities != nullptr) { AUTO_VAR(itEnd, entities->end()); for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) { std::shared_ptr e = *it; // entities->at(i); @@ -900,7 +900,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; } else { @@ -940,7 +940,7 @@ bool Player::isCreativeModeAllowed() { return true; } std::shared_ptr Player::drop(bool all) { return drop(inventory->removeItem(inventory->selected, - all && inventory->getSelected() != NULL + all && inventory->getSelected() != nullptr ? inventory->getSelected()->count : 1), false); @@ -952,7 +952,7 @@ std::shared_ptr Player::drop(std::shared_ptr item) { std::shared_ptr Player::drop(std::shared_ptr item, bool randomly) { - if (item == NULL) return nullptr; + if (item == nullptr) return nullptr; if (item->count == 0) return nullptr; std::shared_ptr thrownItem = std::shared_ptr( @@ -1000,7 +1000,7 @@ float Player::getDestroySpeed(Tile* tile, bool hasProperTool) { std::dynamic_pointer_cast(shared_from_this())); std::shared_ptr item = inventory->getSelected(); - if (efficiency > 0 && item != NULL) { + if (efficiency > 0 && item != nullptr) { float boost = efficiency * efficiency + 1; if (item->canDestroySpecial(tile) || speed > 1) { @@ -1087,7 +1087,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); entityTag->putInt(L"SpawnZ", respawnPosition->z); @@ -1161,10 +1161,10 @@ bool Player::hurt(DamageSource* source, float dmg) { if (dmg == 0) return false; std::shared_ptr attacker = source->getEntity(); - if (attacker != NULL && attacker->instanceof(eTYPE_ARROW)) { + if (attacker != nullptr && attacker->instanceof(eTYPE_ARROW)) { std::shared_ptr arrow = std::dynamic_pointer_cast(attacker); - if (arrow->owner != NULL) { + if (arrow->owner != nullptr) { attacker = arrow->owner; } } @@ -1176,7 +1176,7 @@ bool Player::canHarmPlayer(std::shared_ptr target) { Team* team = getTeam(); Team* otherTeam = target->getTeam(); - if (team == NULL) { + if (team == nullptr) { return true; } if (!team->isAlliedTo(otherTeam)) { @@ -1194,7 +1194,7 @@ int Player::getArmorValue() { return inventory->getArmorValue(); } 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++; } } @@ -1257,12 +1257,12 @@ bool Player::interact(std::shared_ptr entity) { std::shared_ptr item = getSelectedItem(); std::shared_ptr itemClone = - (item != NULL) ? item->copy() : nullptr; + (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) { removeSelectedItem(); } else if (item->count < itemClone->count && abilities.instabuild) { @@ -1272,7 +1272,7 @@ bool Player::interact(std::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 // the ability to instabuild @@ -1331,7 +1331,7 @@ void Player::attack(std::shared_ptr entity) { if (dmg > 0 || magicBoost > 0) { bool bCrit = fallDistance > 0 && !onGround && !onLadder() && !isInWater() && !hasEffect(MobEffect::blindness) && - (riding == NULL) && entity->instanceof(eTYPE_LIVINGENTITY); + (riding == nullptr) && entity->instanceof(eTYPE_LIVINGENTITY); if (bCrit && dmg > 0) { dmg *= 1.5f; } @@ -1389,12 +1389,12 @@ void Player::attack(std::shared_ptr entity) { std::dynamic_pointer_cast( (std::dynamic_pointer_cast(entity)) ->parentMob.lock()); - if ((multiMob != NULL) && + if ((multiMob != nullptr) && multiMob->instanceof(eTYPE_LIVINGENTITY)) { hurtTarget = std::dynamic_pointer_cast(multiMob); } } - if ((item != NULL) && hurtTarget->instanceof(eTYPE_LIVINGENTITY)) { + if ((item != nullptr) && hurtTarget->instanceof(eTYPE_LIVINGENTITY)) { item->hurtEnemy( std::dynamic_pointer_cast(hurtTarget), std::dynamic_pointer_cast(shared_from_this())); @@ -1440,13 +1440,13 @@ void Player::animateRespawn(std::shared_ptr player, Level* level) { } } -Slot* Player::getInventorySlot(int slotId) { return NULL; } +Slot* Player::getInventorySlot(int slotId) { return nullptr; } void Player::remove() { LivingEntity::remove(); inventoryMenu->removed( std::dynamic_pointer_cast(shared_from_this())); - if (containerMenu != NULL) { + if (containerMenu != nullptr) { containerMenu->removed( std::dynamic_pointer_cast(shared_from_this())); } @@ -1591,12 +1591,12 @@ void Player::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, 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); } setPos(standUp->x + .5f, standUp->y + heightOffset + .1f, @@ -1641,7 +1641,7 @@ Pos* Player::checkBedValidRespawnPosition(Level* level, Pos* pos, bool forced) { if (forced && freeFeet && freeHead) { return pos; } - return NULL; + return nullptr; } // make sure the bed still has a stand-up position Pos* standUp = @@ -1650,7 +1650,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); @@ -1707,17 +1707,17 @@ Pos* Player::getRespawnPosition() { return respawnPosition; } bool Player::isRespawnForced() { return respawnForced; } 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; } } @@ -1738,7 +1738,7 @@ void Player::jumpFromGround() { 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; flyingSpeed = abilities.getFlyingSpeed(); @@ -1758,7 +1758,7 @@ float Player::getSpeed() { } void Player::checkMovementStatistiscs(double dx, double dy, double dz) { - if (riding != NULL) { + if (riding != nullptr) { return; } if (isUnderLiquid(Material::water)) { @@ -1816,7 +1816,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 = (int)Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f); if (distance > 0) { @@ -1831,7 +1831,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)); } @@ -1908,7 +1908,7 @@ void Player::killed(std::shared_ptr mob) { GenericStats::param_noArgs()); break; case eTYPE_SPIDER: - if (mob->rider.lock() != NULL && + if (mob->rider.lock() != nullptr && mob->rider.lock()->GetType() == eTYPE_SKELETON) awardStat(GenericStats::killsSpiderJockey(), GenericStats::param_noArgs()); @@ -1954,11 +1954,11 @@ void Player::makeStuckInWeb() { Icon* Player::getItemInHandIcon(std::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(); } else if (item->getItem()->hasMultipleSpriteLayers()) { 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) { return Item::bow->getDrawnIcon(2); @@ -2090,7 +2090,7 @@ bool Player::mayDestroyBlockAt(int x, int y, int z) { if (tile->material->isDestroyedByHand()) { return true; - } else if (getSelectedItem() != NULL) { + } else if (getSelectedItem() != nullptr) { std::shared_ptr carried = getSelectedItem(); if (carried->canDestroySpecial(tile) || @@ -2107,7 +2107,7 @@ bool Player::mayUseItemAt(int x, int y, int z, int face, if (abilities.mayBuild) { return true; } - if (item != NULL) { + if (item != nullptr) { return item->mayBePlacedInAdventureMode(); } return false; @@ -2341,7 +2341,7 @@ void Player::setPlayerGamePrivilege(unsigned int& uiGamePrivileges, bool Player::isAllowedToUse(Tile* tile) { bool allowed = true; - if (tile != NULL && + if (tile != nullptr && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { allowed = false; @@ -2412,7 +2412,7 @@ bool Player::isAllowedToUse(Tile* tile) { bool Player::isAllowedToUse(std::shared_ptr item) { bool allowed = true; - if (item != NULL && + if (item != nullptr && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { if (getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotBuild) != 0) { @@ -2620,7 +2620,7 @@ void Player::enableAllPlayerPrivileges(bool enable) { bool Player::canCreateParticles() { return !hasInvisiblePrivilege(); } std::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; @@ -2632,11 +2632,11 @@ std::vector* Player::GetAdditionalModelParts() { // 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 || + m_ppAdditionalModelParts != nullptr || app.IsFileInMemoryTextures(customTextureUrl)) { m_bCheckedForModelParts = true; } - if (m_ppAdditionalModelParts == NULL && !m_bCheckedDLCForModelParts) { + if (m_ppAdditionalModelParts == nullptr && !m_bCheckedDLCForModelParts) { m_bCheckedDLCForModelParts = true; // we don't have the data from the dlc skin yet @@ -2649,7 +2649,7 @@ std::vector* Player::GetAdditionalModelParts() { DLCSkinFile* pDLCSkinFile = app.m_dlcManager.getSkinFile(this->customTextureUrl); - if (pDLCSkinFile != NULL) { + if (pDLCSkinFile != nullptr) { const int additionalBoxCount = pDLCSkinFile->getAdditionalBoxesCount(); if (additionalBoxCount != 0) { diff --git a/Minecraft.World/Player/PlayerEnderChestContainer.cpp b/Minecraft.World/Player/PlayerEnderChestContainer.cpp index 9fe66f554..eaae3ba2c 100644 --- a/Minecraft.World/Player/PlayerEnderChestContainer.cpp +++ b/Minecraft.World/Player/PlayerEnderChestContainer.cpp @@ -34,7 +34,7 @@ ListTag* PlayerEnderChestContainer::createTag() { ListTag* items = new ListTag(L"EnderItems"); for (int i = 0; i < getContainerSize(); i++) { std::shared_ptr item = getItem(i); - if (item != NULL) { + if (item != nullptr) { CompoundTag* tag = new CompoundTag(); tag->putByte(L"Slot", (uint8_t)i); item->save(tag); @@ -45,14 +45,14 @@ ListTag* PlayerEnderChestContainer::createTag() { } bool PlayerEnderChestContainer::stillValid(std::shared_ptr player) { - if (activeChest != NULL && !activeChest->stillValid(player)) { + if (activeChest != nullptr && !activeChest->stillValid(player)) { return false; } return SimpleContainer::stillValid(player); } void PlayerEnderChestContainer::startOpen() { - if (activeChest != NULL) { + if (activeChest != nullptr) { activeChest->startOpen(); } SimpleContainer::startOpen(); diff --git a/Minecraft.World/Recipes/ArmorDyeRecipe.cpp b/Minecraft.World/Recipes/ArmorDyeRecipe.cpp index 0d4fe97ba..e0f34ae6d 100644 --- a/Minecraft.World/Recipes/ArmorDyeRecipe.cpp +++ b/Minecraft.World/Recipes/ArmorDyeRecipe.cpp @@ -12,12 +12,12 @@ bool ArmorDyeRecipe::matches(std::shared_ptr craftSlots, for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { std::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) { + target == nullptr) { target = item; } else { return false; @@ -29,7 +29,7 @@ bool ArmorDyeRecipe::matches(std::shared_ptr craftSlots, } } - return target != NULL && !dyes.empty(); + return target != nullptr && !dyes.empty(); } std::shared_ptr ArmorDyeRecipe::assembleDyedArmor( @@ -38,17 +38,17 @@ std::shared_ptr ArmorDyeRecipe::assembleDyedArmor( int colorTotals[3] = {0, 0, 0}; int intensityTotal = 0; int colourCounts = 0; - ArmorItem* armor = NULL; + ArmorItem* armor = nullptr; - if (craftSlots != NULL) { + if (craftSlots != nullptr) { for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { std::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) { + target == nullptr) { target = item->copy(); target->count = 1; @@ -88,7 +88,7 @@ std::shared_ptr ArmorDyeRecipe::assembleDyedArmor( } } - if (armor == NULL) return nullptr; + if (armor == nullptr) return nullptr; int red = (colorTotals[0] / colourCounts); int green = (colorTotals[1] / colourCounts); @@ -117,7 +117,7 @@ std::shared_ptr ArmorDyeRecipe::assemble( int ArmorDyeRecipe::size() { return 10; } -const ItemInstance* ArmorDyeRecipe::getResultItem() { return NULL; } +const ItemInstance* ArmorDyeRecipe::getResultItem() { return nullptr; } const int ArmorDyeRecipe::getGroup() { return ShapedRecipy::eGroupType_Armour; } diff --git a/Minecraft.World/Recipes/FireworksRecipe.cpp b/Minecraft.World/Recipes/FireworksRecipe.cpp index 7039e6b25..f546810ef 100644 --- a/Minecraft.World/Recipes/FireworksRecipe.cpp +++ b/Minecraft.World/Recipes/FireworksRecipe.cpp @@ -50,7 +50,7 @@ bool FireworksRecipe::matches(std::shared_ptr craftSlots, for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { std::shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; if (item->id == Item::gunpowder_Id) { sulphurCount++; @@ -103,7 +103,7 @@ bool FireworksRecipe::matches(std::shared_ptr craftSlots, for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { std::shared_ptr item = craftSlots->getItem(slot); - if (item == NULL || item->id != Item::fireworksCharge_Id) + if (item == nullptr || item->id != Item::fireworksCharge_Id) continue; if (item->hasTag() && @@ -136,7 +136,7 @@ bool FireworksRecipe::matches(std::shared_ptr craftSlots, std::vector colors; for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { std::shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; if (item->id == Item::dye_powder_Id) { colors.push_back(DyePowderItem::COLOR_RGB[item->getAuxValue()]); @@ -176,7 +176,7 @@ bool FireworksRecipe::matches(std::shared_ptr craftSlots, std::vector colors; for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { std::shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; if (item->id == Item::dye_powder_Id) { colors.push_back(DyePowderItem::COLOR_RGB[item->getAuxValue()]); @@ -189,10 +189,10 @@ bool FireworksRecipe::matches(std::shared_ptr craftSlots, 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; setResultItem(resultItem); @@ -243,7 +243,7 @@ void FireworksRecipe::updatePossibleRecipes( for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { std::shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; if (item->id == Item::gunpowder_Id) { sulphurCount++; diff --git a/Minecraft.World/Recipes/FurnaceRecipes.cpp b/Minecraft.World/Recipes/FurnaceRecipes.cpp index eaa5e9e7e..b95b2f7de 100644 --- a/Minecraft.World/Recipes/FurnaceRecipes.cpp +++ b/Minecraft.World/Recipes/FurnaceRecipes.cpp @@ -3,7 +3,7 @@ #include "../Blocks/Tile.h" #include "FurnaceRecipes.h" -FurnaceRecipes* FurnaceRecipes::instance = NULL; +FurnaceRecipes* FurnaceRecipes::instance = nullptr; void FurnaceRecipes::staticCtor() { FurnaceRecipes::instance = new FurnaceRecipes(); @@ -67,7 +67,7 @@ ItemInstance* FurnaceRecipes::getResult(int itemId) { if (it != recipies.end()) { return it->second; } - return NULL; + return nullptr; } std::unordered_map* FurnaceRecipes::getRecipies() { diff --git a/Minecraft.World/Recipes/Recipes.cpp b/Minecraft.World/Recipes/Recipes.cpp index de4235894..fb6b56b7a 100644 --- a/Minecraft.World/Recipes/Recipes.cpp +++ b/Minecraft.World/Recipes/Recipes.cpp @@ -8,15 +8,15 @@ #include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/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() { Recipes::instance = new Recipes(); } @@ -939,7 +939,7 @@ ShapedRecipy* Recipes::addShapedRecipy(ItemInstance* result, ...) { Item* pItem; wchar_t wchFrom; int iCount; - ItemInstance** ids = NULL; + ItemInstance** ids = nullptr; myMap* mappings = new std::unordered_map(); @@ -1047,7 +1047,7 @@ ShapedRecipy* Recipes::addShapedRecipy(ItemInstance* result, ...) { if (it != mappings->end()) { ids[j] = it->second; } else { - ids[j] = NULL; + ids[j] = nullptr; } } } @@ -1130,13 +1130,13 @@ void Recipes::addShapelessRecipy(ItemInstance* result, ...) { std::shared_ptr Recipes::getItemFor( std::shared_ptr craftSlots, Level* level, - Recipy* recipesClass /*= NULL*/) { + Recipy* recipesClass /*= nullptr*/) { int count = 0; std::shared_ptr first = nullptr; std::shared_ptr second = nullptr; for (int i = 0; i < craftSlots->getContainerSize(); i++) { std::shared_ptr item = craftSlots->getItem(i); - if (item != NULL) { + if (item != nullptr) { if (count == 0) first = item; if (count == 1) second = item; count++; @@ -1156,7 +1156,7 @@ std::shared_ptr Recipes::getItemFor( new ItemInstance(first->id, 1, resultDamage)); } - if (recipesClass != NULL) { + if (recipesClass != nullptr) { if (recipesClass->matches(craftSlots, level)) return recipesClass->assemble(craftSlots); } else { diff --git a/Minecraft.World/Recipes/Recipes.h b/Minecraft.World/Recipes/Recipes.h index 328a3692f..2c9c9a655 100644 --- a/Minecraft.World/Recipes/Recipes.h +++ b/Minecraft.World/Recipes/Recipes.h @@ -100,7 +100,7 @@ public: std::shared_ptr getItemFor( std::shared_ptr craftSlots, Level* level, - Recipy* recipesClass = NULL); // 4J Added recipesClass param + Recipy* recipesClass = nullptr); // 4J Added recipesClass param std::vector* getRecipies(); // 4J-PB - Added all below for new Xbox 'crafting' diff --git a/Minecraft.World/Recipes/ShapedRecipy.cpp b/Minecraft.World/Recipes/ShapedRecipy.cpp index 37e6b0755..ce1a75f3b 100644 --- a/Minecraft.World/Recipes/ShapedRecipy.cpp +++ b/Minecraft.World/Recipes/ShapedRecipy.cpp @@ -45,7 +45,7 @@ bool ShapedRecipy::matches(std::shared_ptr craftSlots, 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]; @@ -53,11 +53,11 @@ bool ShapedRecipy::matches(std::shared_ptr craftSlots, expected = recipeItems[xs + ys * width]; } std::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; } if (expected->id != item->id) { @@ -76,11 +76,11 @@ std::shared_ptr ShapedRecipy::assemble( std::shared_ptr craftSlots) { std::shared_ptr result = getResultItem()->copy(); - if (_keepTag && craftSlots != NULL) { + if (_keepTag && craftSlots != nullptr) { for (int i = 0; i < craftSlots->getContainerSize(); i++) { std::shared_ptr item = craftSlots->getItem(i); - if (item != NULL && item->hasTag()) { + if (item != nullptr && item->hasTag()) { result->setTag((CompoundTag*)item->tag->copy()); } } @@ -99,7 +99,7 @@ bool ShapedRecipy::requiresRecipe(int iRecipe) { for (int y = 0; y < 3; y++) { 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); } } @@ -135,7 +135,7 @@ void ShapedRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) { if (x < width && y < height) { 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/Recipes/ShapelessRecipy.cpp b/Minecraft.World/Recipes/ShapelessRecipy.cpp index d8e436bf1..150c00943 100644 --- a/Minecraft.World/Recipes/ShapelessRecipy.cpp +++ b/Minecraft.World/Recipes/ShapelessRecipy.cpp @@ -29,7 +29,7 @@ bool ShapelessRecipy::matches(std::shared_ptr craftSlots, for (int x = 0; x < 3; x++) { std::shared_ptr item = craftSlots->getItem(x, y); - if (item != NULL) { + if (item != nullptr) { bool found = false; AUTO_VAR(citEnd, ingredients->end()); @@ -114,7 +114,7 @@ void ShapelessRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) { ingredient != citEnd; ingredient++) { ItemInstance* expected = *ingredient; - if (expected != NULL) { + if (expected != nullptr) { int iAuxVal = (*ingredient)->getAuxValue(); TempIngReq.uiGridA[iCount++] = expected->id | iAuxVal << 24; // 4J-PB - put the ingredients in boxes 1,2,4,5 so we can see them diff --git a/Minecraft.World/Scores/PlayerTeam.cpp b/Minecraft.World/Scores/PlayerTeam.cpp index 6d3558222..553be6bfa 100644 --- a/Minecraft.World/Scores/PlayerTeam.cpp +++ b/Minecraft.World/Scores/PlayerTeam.cpp @@ -56,7 +56,7 @@ std::wstring PlayerTeam::formatNameForTeam(PlayerTeam* team) { std::wstring PlayerTeam::formatNameForTeam(Team* team, const std::wstring& name) { - if (team == NULL) return name; + if (team == nullptr) return name; return team->getFormattedName(name); } diff --git a/Minecraft.World/Scores/Scoreboard.cpp b/Minecraft.World/Scores/Scoreboard.cpp index 9ce6338cb..b79245b5c 100644 --- a/Minecraft.World/Scores/Scoreboard.cpp +++ b/Minecraft.World/Scores/Scoreboard.cpp @@ -3,15 +3,15 @@ #include "Scoreboard.h" Objective* Scoreboard::getObjective(const std::wstring& name) { - return NULL; + return nullptr; // return objectivesByName.find(name)->second; } Objective* Scoreboard::addObjective(const std::wstring& name, ObjectiveCriteria* criteria) { - return NULL; + return nullptr; // Objective *objective = getObjective(name); - // if (objective != NULL) + // if (objective != nullptr) // { // #indef _CONTENT_PACKAGE // __debugbreak(); @@ -25,7 +25,7 @@ Objective* Scoreboard::addObjective(const std::wstring& name, // vector *criteriaList = // objectivesByCriteria.find(criteria)->second; // - // if (criteriaList == NULL) + // if (criteriaList == nullptr) // { // criteriaList = new vector(); // objectivesByCriteria[criteria] = criteriaList; @@ -40,21 +40,21 @@ Objective* Scoreboard::addObjective(const std::wstring& name, std::vector* Scoreboard::findObjectiveFor( ObjectiveCriteria* criteria) { - return NULL; + return nullptr; // vector *objectives = // objectivesByCriteria.find(criteria)->second; - // return objectives == NULL ? new vector() : new + // return objectives == nullptr ? new vector() : new // vector(objectives); } Score* Scoreboard::getPlayerScore(const std::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); @@ -62,7 +62,7 @@ Score* Scoreboard::getPlayerScore(const std::wstring& name, // Score *score = scores->get(objective); - // if (score == NULL) + // if (score == nullptr) //{ // score = new Score(this, objective, name); // scores->put(objective, score); @@ -72,7 +72,7 @@ Score* Scoreboard::getPlayerScore(const std::wstring& name, } std::vector* Scoreboard::getPlayerScores(Objective* objective) { - return NULL; + return nullptr; // vector *result = new vector(); // for (Map scores : playerScores.values()) @@ -87,12 +87,12 @@ std::vector* Scoreboard::getPlayerScores(Objective* objective) { } std::vector* Scoreboard::getObjectives() { - return NULL; + return nullptr; // return objectivesByName.values(); } std::vector* Scoreboard::getTrackedPlayers() { - return NULL; + return nullptr; // return playerScores.keySet(); } @@ -100,14 +100,14 @@ void Scoreboard::resetPlayerScore(const std::wstring& player) { // unordered_map *removed = // playerScores.remove(player); - // if (removed != NULL) + // if (removed != nullptr) //{ // onPlayerRemoved(player); // } } std::vector* Scoreboard::getScores() { - return NULL; + return nullptr; // Collection> values = playerScores.values(); // List result = new ArrayList(); @@ -120,7 +120,7 @@ std::vector* Scoreboard::getScores() { } std::vector* Scoreboard::getScores(Objective* objective) { - return NULL; + return nullptr; // Collection> values = playerScores.values(); // List result = new ArrayList(); @@ -134,7 +134,7 @@ std::vector* Scoreboard::getScores(Objective* objective) { std::unordered_map* Scoreboard::getPlayerScores( const std::wstring& player) { - return NULL; + return nullptr; // Map result = playerScores.get(player); // if (result == null) result = new HashMap(); // return result; @@ -163,17 +163,17 @@ void Scoreboard::setDisplayObjective(int slot, Objective* objective) { } Objective* Scoreboard::getDisplayObjective(int slot) { - return NULL; + return nullptr; // return displayObjectives[slot]; } PlayerTeam* Scoreboard::getPlayerTeam(const std::wstring& name) { - return NULL; + return nullptr; // return teamsByName.get(name); } PlayerTeam* Scoreboard::addPlayerTeam(const std::wstring& name) { - return NULL; + return nullptr; // PlayerTeam team = getPlayerTeam(name); // if (team != null) throw new IllegalArgumentException("An objective with // the name '" + name + "' already exists!"); @@ -230,12 +230,12 @@ void Scoreboard::removePlayerFromTeam(const std::wstring& player, } std::vector* Scoreboard::getTeamNames() { - return NULL; + return nullptr; // return teamsByName.keySet(); } std::vector* Scoreboard::getPlayerTeams() { - return NULL; + return nullptr; // return teamsByName.values(); } @@ -245,7 +245,7 @@ std::shared_ptr Scoreboard::getPlayer(const std::wstring& name) { } PlayerTeam* Scoreboard::getPlayersTeam(const std::wstring& name) { - return NULL; + return nullptr; // return teamsByPlayer.get(name); } diff --git a/Minecraft.World/Scores/Team.cpp b/Minecraft.World/Scores/Team.cpp index a27b372bf..eaec14ae3 100644 --- a/Minecraft.World/Scores/Team.cpp +++ b/Minecraft.World/Scores/Team.cpp @@ -3,7 +3,7 @@ #include "Team.h" bool Team::isAlliedTo(Team* other) { - if (other == NULL) { + if (other == nullptr) { return false; } if (this == other) { diff --git a/Minecraft.World/Stats/Achievement.cpp b/Minecraft.World/Stats/Achievement.cpp index cc623157e..2376d85c8 100644 --- a/Minecraft.World/Stats/Achievement.cpp +++ b/Minecraft.World/Stats/Achievement.cpp @@ -122,7 +122,7 @@ bool Achievement::isAchievement() { return true; } * @return wstring **/ std::wstring Achievement::getDescription() { - if (descFormatter != NULL) { + if (descFormatter != nullptr) { return descFormatter->format(desc); } return desc; diff --git a/Minecraft.World/Stats/Achievements.cpp b/Minecraft.World/Stats/Achievements.cpp index 206d055f2..8348b7a83 100644 --- a/Minecraft.World/Stats/Achievements.cpp +++ b/Minecraft.World/Stats/Achievements.cpp @@ -18,80 +18,80 @@ int Achievements::yMax = 0; std::vector* Achievements::achievements = new std::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::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 = 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::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; #if defined(_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)) + Item::book, nullptr)) ->setAwardLocallyOnly() ->postConstruct(); Achievements::mineWood = @@ -291,86 +291,86 @@ void Achievements::staticCtor() { Achievements::adventuringTime = (new Achievement(eAward_adventuringTime, L"adventuringTime", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->setAwardLocallyOnly() ->postConstruct(); Achievements::repopulation = (new Achievement(eAward_repopulation, L"repopulation", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->postConstruct(); // Achievements::porkChoop // // // // // // // Achievements::diamondsToYou = (new Achievement(eAward_diamondsToYou, L"diamondsToYou", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->postConstruct(); // Achievements::passingTheTime = (new // Achievement(eAward_play100Days, L"passingTheTime", - // 0,0, Tile::bookshelf, (Achievement*) NULL) + // 0,0, Tile::bookshelf, (Achievement*) nullptr) // )->postConstruct(); Achievements::archer = (new // Achievement(eAward_arrowKillCreeper, L"archer", - // 0,0, Tile::bookshelf, (Achievement*) NULL) + // 0,0, Tile::bookshelf, (Achievement*) nullptr) // )->postConstruct(); Achievements::theHaggler = (new Achievement(eAward_theHaggler, L"theHaggler", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->setAwardLocallyOnly() ->postConstruct(); Achievements::potPlanter = (new Achievement(eAward_potPlanter, L"potPlanter", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->setAwardLocallyOnly() ->postConstruct(); Achievements::itsASign = (new Achievement(eAward_itsASign, L"itsASign", 0, 0, Tile::bookshelf, - (Achievement*)NULL)) + (Achievement*)nullptr)) ->setAwardLocallyOnly() ->postConstruct(); Achievements::ironBelly = (new Achievement(eAward_ironBelly, L"ironBelly", 0, 0, Tile::bookshelf, - (Achievement*)NULL)) + (Achievement*)nullptr)) ->postConstruct(); Achievements::haveAShearfulDay = (new Achievement(eAward_haveAShearfulDay, L"haveAShearfulDay", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->postConstruct(); Achievements::rainbowCollection = (new Achievement(eAward_rainbowCollection, L"rainbowCollection", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->setAwardLocallyOnly() ->postConstruct(); Achievements::stayinFrosty = (new Achievement(eAward_stayinFrosty, L"stayingFrosty", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->postConstruct(); Achievements::chestfulOfCobblestone = (new Achievement(eAward_chestfulOfCobblestone, L"chestfulOfCobblestone", - 0, 0, Tile::bookshelf, (Achievement*)NULL)) + 0, 0, Tile::bookshelf, (Achievement*)nullptr)) ->setAwardLocallyOnly() ->postConstruct(); Achievements::renewableEnergy = (new Achievement(eAward_renewableEnergy, L"renewableEnergy", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->postConstruct(); Achievements::musicToMyEars = (new Achievement(eAward_musicToMyEars, L"musicToMyEars", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->postConstruct(); Achievements::bodyGuard = (new Achievement(eAward_bodyGuard, L"bodyGuard", 0, 0, Tile::bookshelf, - (Achievement*)NULL)) + (Achievement*)nullptr)) ->postConstruct(); Achievements::ironMan = (new Achievement(eAward_ironMan, L"ironMan", 0, 0, Tile::bookshelf, - (Achievement*)NULL)) + (Achievement*)nullptr)) ->postConstruct(); Achievements::zombieDoctor = (new Achievement(eAward_zombieDoctor, L"zombieDoctor", 0, 0, - Tile::bookshelf, (Achievement*)NULL)) + Tile::bookshelf, (Achievement*)nullptr)) ->postConstruct(); Achievements::lionTamer = (new Achievement(eAward_lionTamer, L"lionTamer", 0, 0, Tile::bookshelf, - (Achievement*)NULL)) + (Achievement*)nullptr)) ->postConstruct(); #endif } diff --git a/Minecraft.World/Stats/CommonStats.cpp b/Minecraft.World/Stats/CommonStats.cpp index d4e509c14..2930a070b 100644 --- a/Minecraft.World/Stats/CommonStats.cpp +++ b/Minecraft.World/Stats/CommonStats.cpp @@ -52,7 +52,7 @@ Stat* CommonStats::get_breedEntity(eINSTANCEOF mobType) { if (mobType == eTYPE_COW) return GenericStats::repopulation(); else - return NULL; + return nullptr; } Stat* CommonStats::get_tamedEntity(eINSTANCEOF mobType) { @@ -61,21 +61,21 @@ Stat* CommonStats::get_tamedEntity(eINSTANCEOF mobType) { else if (mobType == eTYPE_WOLF) return Stats::befriendsWolf; else - return NULL; + return nullptr; } Stat* CommonStats::get_craftedEntity(eINSTANCEOF mobType) { if (mobType == eTYPE_VILLAGERGOLEM) return GenericStats::bodyGuard(); else - return NULL; + return nullptr; } Stat* CommonStats::get_shearedEntity(eINSTANCEOF mobType) { if (mobType == eTYPE_SHEEP) return GenericStats::haveAShearfulDay(); else - return NULL; + return nullptr; } Stat* CommonStats::get_totalBlocksMined() { return Stats::totalBlocksMined; } @@ -86,7 +86,7 @@ Stat* CommonStats::get_blocksPlaced(int blockId) { #if defined(_EXTENDED_ACHIEVEMENTS) return Stats::blocksPlaced[blockId]; #else - return NULL; + return nullptr; #endif } @@ -105,7 +105,7 @@ Stat* CommonStats::get_itemsCollected(int itemId, int itemAux) { if (itemId != Item::emerald_Id) return Stats::itemsCollected[itemId]; else - return NULL; + return nullptr; } Stat* CommonStats::get_itemsCrafted(int itemId) { @@ -122,7 +122,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) { @@ -133,7 +133,7 @@ Stat* CommonStats::get_itemsBought(int itemId) { if (itemId == Item::emerald_Id) return Stats::itemsCollected[itemId]; else - return NULL; + return nullptr; } Stat* CommonStats::get_killsEnderdragon() { return Stats::killsEnderdragon; } @@ -144,7 +144,7 @@ Stat* CommonStats::get_enteredBiome(int biomeId) { #if defined(_EXTENDED_ACHIEVEMENTS) return Stats::biomesVisisted[biomeId]; #else - return NULL; + return nullptr; #endif } @@ -208,7 +208,7 @@ Stat* CommonStats::get_achievement(eAward achievementId) { case eAward_diamonds: return (Stat*)Achievements::diamonds; case eAward_portal: - return (Stat*)NULL; // TODO + return (Stat*)nullptr; // TODO case eAward_ghast: return (Stat*)Achievements::ghast; case eAward_blazeRod: @@ -268,7 +268,7 @@ Stat* CommonStats::get_achievement(eAward achievementId) { #endif default: - return (Stat*)NULL; + return (Stat*)nullptr; } } diff --git a/Minecraft.World/Stats/GenericStats.cpp b/Minecraft.World/Stats/GenericStats.cpp index 0ee832055..4013931a7 100644 --- a/Minecraft.World/Stats/GenericStats.cpp +++ b/Minecraft.World/Stats/GenericStats.cpp @@ -4,87 +4,87 @@ #include "GenericStats.h" -GenericStats* GenericStats::instance = NULL; +GenericStats* GenericStats::instance = nullptr; -Stat* GenericStats::get_walkOneM() { return NULL; } +Stat* GenericStats::get_walkOneM() { return nullptr; } -Stat* GenericStats::get_swimOneM() { return NULL; } +Stat* GenericStats::get_swimOneM() { return nullptr; } -Stat* GenericStats::get_fallOneM() { return NULL; } +Stat* GenericStats::get_fallOneM() { return nullptr; } -Stat* GenericStats::get_climbOneM() { return NULL; } +Stat* GenericStats::get_climbOneM() { return nullptr; } -Stat* GenericStats::get_minecartOneM() { return NULL; } +Stat* GenericStats::get_minecartOneM() { return nullptr; } -Stat* GenericStats::get_boatOneM() { return NULL; } +Stat* GenericStats::get_boatOneM() { return nullptr; } -Stat* GenericStats::get_pigOneM() { return NULL; } +Stat* GenericStats::get_pigOneM() { return nullptr; } -Stat* GenericStats::get_portalsCreated() { return NULL; } +Stat* GenericStats::get_portalsCreated() { return nullptr; } -Stat* GenericStats::get_cowsMilked() { return NULL; } +Stat* GenericStats::get_cowsMilked() { return nullptr; } -Stat* GenericStats::get_netherLavaCollected() { return NULL; } +Stat* GenericStats::get_netherLavaCollected() { return nullptr; } -Stat* GenericStats::get_killMob() { return NULL; } +Stat* GenericStats::get_killMob() { return nullptr; } -Stat* GenericStats::get_killsZombie() { return NULL; } +Stat* GenericStats::get_killsZombie() { return nullptr; } -Stat* GenericStats::get_killsSkeleton() { return NULL; } +Stat* GenericStats::get_killsSkeleton() { return nullptr; } -Stat* GenericStats::get_killsCreeper() { return NULL; } +Stat* GenericStats::get_killsCreeper() { return nullptr; } -Stat* GenericStats::get_killsSpider() { return NULL; } +Stat* GenericStats::get_killsSpider() { return nullptr; } -Stat* GenericStats::get_killsSpiderJockey() { return NULL; } +Stat* GenericStats::get_killsSpiderJockey() { return nullptr; } -Stat* GenericStats::get_killsZombiePigman() { return NULL; } +Stat* GenericStats::get_killsZombiePigman() { return nullptr; } -Stat* GenericStats::get_killsSlime() { return NULL; } +Stat* GenericStats::get_killsSlime() { return nullptr; } -Stat* GenericStats::get_killsGhast() { return NULL; } +Stat* GenericStats::get_killsGhast() { return nullptr; } -Stat* GenericStats::get_killsNetherZombiePigman() { return NULL; } +Stat* GenericStats::get_killsNetherZombiePigman() { return nullptr; } -Stat* GenericStats::get_breedEntity(eINSTANCEOF entityId) { return NULL; } +Stat* GenericStats::get_breedEntity(eINSTANCEOF entityId) { return nullptr; } -Stat* GenericStats::get_tamedEntity(eINSTANCEOF entityId) { return NULL; } +Stat* GenericStats::get_tamedEntity(eINSTANCEOF entityId) { return nullptr; } -Stat* GenericStats::get_curedEntity(eINSTANCEOF entityId) { return NULL; } +Stat* GenericStats::get_curedEntity(eINSTANCEOF entityId) { return nullptr; } -Stat* GenericStats::get_craftedEntity(eINSTANCEOF entityId) { return NULL; } +Stat* GenericStats::get_craftedEntity(eINSTANCEOF entityId) { return nullptr; } -Stat* GenericStats::get_shearedEntity(eINSTANCEOF entityId) { return NULL; } +Stat* GenericStats::get_shearedEntity(eINSTANCEOF entityId) { return nullptr; } -Stat* GenericStats::get_totalBlocksMined() { return NULL; } +Stat* GenericStats::get_totalBlocksMined() { return nullptr; } -Stat* GenericStats::get_timePlayed() { return NULL; } +Stat* GenericStats::get_timePlayed() { return nullptr; } -Stat* GenericStats::get_blocksPlaced(int blockId) { return NULL; } +Stat* GenericStats::get_blocksPlaced(int blockId) { return nullptr; } -Stat* GenericStats::get_blocksMined(int blockId) { return NULL; } +Stat* GenericStats::get_blocksMined(int blockId) { return nullptr; } -Stat* GenericStats::get_itemsCollected(int itemId, int itemAux) { return NULL; } +Stat* GenericStats::get_itemsCollected(int itemId, int itemAux) { return nullptr; } -Stat* GenericStats::get_itemsCrafted(int itemId) { return NULL; } +Stat* GenericStats::get_itemsCrafted(int itemId) { return nullptr; } Stat* GenericStats::get_itemsSmelted(int itemId) { return this->get_itemsCrafted(itemId); } -Stat* GenericStats::get_itemsUsed(int itemId) { return NULL; } +Stat* GenericStats::get_itemsUsed(int itemId) { return nullptr; } -Stat* GenericStats::get_itemsBought(int itemId) { return NULL; } +Stat* GenericStats::get_itemsBought(int itemId) { return nullptr; } -Stat* GenericStats::get_killsEnderdragon() { return NULL; } +Stat* GenericStats::get_killsEnderdragon() { return nullptr; } -Stat* GenericStats::get_completeTheEnd() { return NULL; } +Stat* GenericStats::get_completeTheEnd() { return nullptr; } -Stat* GenericStats::get_changedDimension(int from, int to) { return NULL; } +Stat* GenericStats::get_changedDimension(int from, int to) { return nullptr; } -Stat* GenericStats::get_enteredBiome(int biomeId) { return NULL; } +Stat* GenericStats::get_enteredBiome(int biomeId) { return nullptr; } -Stat* GenericStats::get_achievement(eAward achievementId) { return NULL; } +Stat* GenericStats::get_achievement(eAward achievementId) { return nullptr; } Stat* GenericStats::openInventory() { return instance->get_achievement(eAward_TakingInventory); @@ -186,7 +186,7 @@ Stat* GenericStats::overkill() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_overkill); #else - return NULL; + return nullptr; #endif } @@ -194,7 +194,7 @@ Stat* GenericStats::bookcase() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_bookcase); #else - return NULL; + return nullptr; #endif } @@ -242,7 +242,7 @@ Stat* GenericStats::adventuringTime() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_adventuringTime); #else - return NULL; + return nullptr; #endif } @@ -250,7 +250,7 @@ Stat* GenericStats::repopulation() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_repopulation); #else - return NULL; + return nullptr; #endif } @@ -258,7 +258,7 @@ Stat* GenericStats::porkChop() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_eatPorkChop); #else - return NULL; + return nullptr; #endif } @@ -266,7 +266,7 @@ Stat* GenericStats::diamondsToYou() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_diamondsToYou); #else - return NULL; + return nullptr; #endif } @@ -274,7 +274,7 @@ Stat* GenericStats::passingTheTime() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_play100Days); #else - return NULL; + return nullptr; #endif } @@ -282,7 +282,7 @@ Stat* GenericStats::archer() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_arrowKillCreeper); #else - return NULL; + return nullptr; #endif } @@ -290,7 +290,7 @@ Stat* GenericStats::theHaggler() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_theHaggler); #else - return NULL; + return nullptr; #endif } @@ -298,7 +298,7 @@ Stat* GenericStats::potPlanter() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_potPlanter); #else - return NULL; + return nullptr; #endif } @@ -306,7 +306,7 @@ Stat* GenericStats::itsASign() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_itsASign); #else - return NULL; + return nullptr; #endif } @@ -314,7 +314,7 @@ Stat* GenericStats::ironBelly() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_ironBelly); #else - return NULL; + return nullptr; #endif } @@ -322,7 +322,7 @@ Stat* GenericStats::haveAShearfulDay() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_haveAShearfulDay); #else - return NULL; + return nullptr; #endif } @@ -330,7 +330,7 @@ Stat* GenericStats::rainbowCollection() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_rainbowCollection); #else - return NULL; + return nullptr; #endif } @@ -338,7 +338,7 @@ Stat* GenericStats::stayinFrosty() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_stayinFrosty); #else - return NULL; + return nullptr; #endif } @@ -346,7 +346,7 @@ Stat* GenericStats::chestfulOfCobblestone() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_chestfulOfCobblestone); #else - return NULL; + return nullptr; #endif } @@ -354,7 +354,7 @@ Stat* GenericStats::renewableEnergy() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_renewableEnergy); #else - return NULL; + return nullptr; #endif } @@ -362,7 +362,7 @@ Stat* GenericStats::musicToMyEars() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_musicToMyEars); #else - return NULL; + return nullptr; #endif } @@ -370,7 +370,7 @@ Stat* GenericStats::bodyGuard() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_bodyGuard); #else - return NULL; + return nullptr; #endif } @@ -378,7 +378,7 @@ Stat* GenericStats::ironMan() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_ironMan); #else - return NULL; + return nullptr; #endif } @@ -386,7 +386,7 @@ Stat* GenericStats::zombieDoctor() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_zombieDoctor); #else - return NULL; + return nullptr; #endif } @@ -394,7 +394,7 @@ Stat* GenericStats::lionTamer() { #if defined(_EXTENDED_ACHIEVEMENTS) return instance->get_achievement(eAward_lionTamer); #else - return NULL; + return nullptr; #endif } @@ -585,7 +585,7 @@ byteArray GenericStats::param_itemsSmelted(int id, int aux, int count) { byteArray GenericStats::param_itemsUsed(std::shared_ptr plr, std::shared_ptr itm) { - if ((plr != NULL) && (itm != NULL)) + if ((plr != nullptr) && (itm != nullptr)) return instance->getParam_itemsUsed(plr, itm); else return instance->getParam_noArgs(); @@ -598,7 +598,7 @@ byteArray GenericStats::param_itemsBought(int id, int aux, int count) { byteArray GenericStats::param_mobKill(std::shared_ptr plr, std::shared_ptr mob, DamageSource* dmgSrc) { - if ((plr != NULL) && (mob != NULL)) + if ((plr != nullptr) && (mob != nullptr)) return instance->getParam_mobKill(plr, mob, dmgSrc); else return instance->getParam_noArgs(); diff --git a/Minecraft.World/Stats/Stats.cpp b/Minecraft.World/Stats/Stats.cpp index 7459fca62..91c375404 100644 --- a/Minecraft.World/Stats/Stats.cpp +++ b/Minecraft.World/Stats/Stats.cpp @@ -30,30 +30,30 @@ std::vector* Stats::itemsCraftedStats = new std::vector; std::vector* Stats::blocksPlacedStats = new std::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; @@ -66,9 +66,9 @@ StatArray Stats::biomesVisisted; #endif Stat* Stats::killsEnderdragon = - NULL; // The number of times this player has dealt the killing blow to the + nullptr; // 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 +Stat* Stats::completeTheEnd = nullptr; // The number of times this player has been // present when the Enderdragon has died void Stats::staticCtor() { @@ -611,7 +611,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/Util/ArrayWithLength.h b/Minecraft.World/Util/ArrayWithLength.h index c476a372f..d46f390f6 100644 --- a/Minecraft.World/Util/ArrayWithLength.h +++ b/Minecraft.World/Util/ArrayWithLength.h @@ -13,7 +13,7 @@ public: T* data; unsigned int length; arrayWithLength() { - data = NULL; + data = nullptr; length = 0; } arrayWithLength(unsigned int elements, bool bClearArray = true) { @@ -39,7 +39,7 @@ public: T* temp = new T[elements]; memset((void*)temp, 0, sizeof(T) * elements); - if (data != NULL) { + if (data != nullptr) { std::copy(data, data + length, temp); delete[] data; @@ -61,7 +61,7 @@ public: _parrayWithLength* data; unsigned int length; array2DWithLength() { - data = NULL; + data = nullptr; length = 0; } array2DWithLength(unsigned int dimA, unsigned int dimB) { diff --git a/Minecraft.World/Util/BinaryHeap.cpp b/Minecraft.World/Util/BinaryHeap.cpp index 51254f1d1..8f08f0a90 100644 --- a/Minecraft.World/Util/BinaryHeap.cpp +++ b/Minecraft.World/Util/BinaryHeap.cpp @@ -44,7 +44,7 @@ Node* BinaryHeap::peek() { return heap[0]; } 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; @@ -53,7 +53,7 @@ Node* BinaryHeap::pop() { 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) { upHeap(node->heapIdx); @@ -113,7 +113,7 @@ void BinaryHeap::downHeap(int idx) { if (rightIdx >= sizeVar) { // Only need to compare with left. - rightNode = NULL; + rightNode = nullptr; rightCost = std::numeric_limits::infinity(); } else { rightNode = heap[rightIdx]; diff --git a/Minecraft.World/Util/BoundingBox.cpp b/Minecraft.World/Util/BoundingBox.cpp index 7ee4589b4..ebb442316 100644 --- a/Minecraft.World/Util/BoundingBox.cpp +++ b/Minecraft.World/Util/BoundingBox.cpp @@ -121,7 +121,7 @@ void BoundingBox::expand(BoundingBox* other) { 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/Util/CombatEntry.cpp b/Minecraft.World/Util/CombatEntry.cpp index 485f5512e..ddc933b3c 100644 --- a/Minecraft.World/Util/CombatEntry.cpp +++ b/Minecraft.World/Util/CombatEntry.cpp @@ -7,8 +7,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(); } @@ -39,7 +39,7 @@ bool CombatEntry::isCombatRelated() { CombatTracker::eLOCATION CombatEntry::getLocation() { return location; } std::wstring CombatEntry::getAttackerName() { - return getSource()->getEntity() == NULL + return getSource()->getEntity() == nullptr ? L"" : getSource()->getEntity()->getNetworkName(); } diff --git a/Minecraft.World/Util/CombatTracker.cpp b/Minecraft.World/Util/CombatTracker.cpp index 80b0a3072..e6e089c76 100644 --- a/Minecraft.World/Util/CombatTracker.cpp +++ b/Minecraft.World/Util/CombatTracker.cpp @@ -58,7 +58,7 @@ std::shared_ptr CombatTracker::getDeathMessagePacket() { std::shared_ptr killingEntity = killingBlow->getSource()->getEntity(); - if (knockOffEntry != NULL && + if (knockOffEntry != nullptr && killingBlow->getSource()->equals(DamageSource::fall)) { std::shared_ptr attackerEntity = knockOffEntry->getSource()->getEntity(); @@ -87,8 +87,8 @@ std::shared_ptr CombatTracker::getDeathMessagePacket() { result = std::shared_ptr( new ChatPacket(mob->getNetworkName(), message)); - } else if (attackerEntity != NULL && - (killingEntity == NULL || attackerEntity != killingEntity)) { + } else if (attackerEntity != nullptr && + (killingEntity == nullptr || attackerEntity != killingEntity)) { std::shared_ptr attackerItem = attackerEntity->instanceof (eTYPE_LIVINGENTITY) @@ -96,7 +96,7 @@ std::shared_ptr CombatTracker::getDeathMessagePacket() { ->getCarriedItem() : nullptr; - if (attackerItem != NULL && attackerItem->hasCustomHoverName()) { + if (attackerItem != nullptr && attackerItem->hasCustomHoverName()) { result = std::shared_ptr(new ChatPacket( mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssistItem, @@ -108,13 +108,13 @@ std::shared_ptr CombatTracker::getDeathMessagePacket() { attackerEntity->GetType(), attackerEntity->getNetworkName())); } - } else if (killingEntity != NULL) { + } else if (killingEntity != nullptr) { std::shared_ptr killerItem = killingEntity->instanceof (eTYPE_LIVINGENTITY) ? std::dynamic_pointer_cast(killingEntity) ->getCarriedItem() : nullptr; - if (killerItem != NULL && killerItem->hasCustomHoverName()) { + if (killerItem != nullptr && killerItem->hasCustomHoverName()) { result = std::shared_ptr(new ChatPacket( mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinishItem, @@ -145,28 +145,28 @@ std::shared_ptr CombatTracker::getKiller() { for (AUTO_VAR(it, entries.begin()); it != entries.end(); ++it) { CombatEntry* entry = *it; - if (entry->getSource() != NULL && - entry->getSource()->getEntity() != NULL && + if (entry->getSource() != nullptr && + entry->getSource()->getEntity() != nullptr && entry->getSource()->getEntity()->instanceof (eTYPE_PLAYER) && - (bestPlayer == NULL || entry->getDamage() > bestPlayerDamage)) { + (bestPlayer == nullptr || entry->getDamage() > bestPlayerDamage)) { bestPlayerDamage = entry->getDamage(); bestPlayer = std::dynamic_pointer_cast( entry->getSource()->getEntity()); } - if (entry->getSource() != NULL && - entry->getSource()->getEntity() != NULL && + if (entry->getSource() != nullptr && + entry->getSource()->getEntity() != nullptr && entry->getSource()->getEntity()->instanceof (eTYPE_LIVINGENTITY) && - (bestMob == NULL || entry->getDamage() > bestMobDamage)) { + (bestMob == nullptr || entry->getDamage() > bestMobDamage)) { bestMobDamage = entry->getDamage(); bestMob = std::dynamic_pointer_cast( entry->getSource()->getEntity()); } } - if (bestPlayer != NULL && bestPlayerDamage >= bestMobDamage / 3) { + if (bestPlayer != nullptr && bestPlayerDamage >= bestMobDamage / 3) { return bestPlayer; } else { return bestMob; @@ -174,21 +174,21 @@ std::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)) { + (result == nullptr || entry->getFallDistance() > bestFall)) { if (i > 0) { result = previous; } else { @@ -198,17 +198,17 @@ CombatEntry* CombatTracker::getMostSignificantFall() { } if (entry->getLocation() != eLocation_GENERIC && - (alternative == NULL || entry->getDamage() > altDamage)) { + (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/Util/DamageSource.cpp b/Minecraft.World/Util/DamageSource.cpp index 2f2c6e7fc..c5c8271f5 100644 --- a/Minecraft.World/Util/DamageSource.cpp +++ b/Minecraft.World/Util/DamageSource.cpp @@ -69,7 +69,7 @@ DamageSource* DamageSource::arrow(std::shared_ptr arrow, DamageSource* DamageSource::fireball(std::shared_ptr fireball, std::shared_ptr owner) { - if (owner == NULL) { + if (owner == nullptr) { return (new IndirectEntityDamageSource(ChatPacket::e_ChatDeathOnFire, ChatPacket::e_ChatDeathOnFire, fireball, fireball)) @@ -108,7 +108,7 @@ DamageSource* DamageSource::thorns(std::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())) @@ -205,7 +205,7 @@ DamageSource* DamageSource::setMagic() { std::shared_ptr DamageSource::getDeathMessagePacket( std::shared_ptr player) { std::shared_ptr source = player->getKillCredit(); - if (source != NULL) { + if (source != nullptr) { return std::shared_ptr(new ChatPacket( player->getNetworkName(), m_msgWithItemId != ChatPacket::e_ChatCustom ? m_msgWithItemId diff --git a/Minecraft.World/Util/Hasher.cpp b/Minecraft.World/Util/Hasher.cpp index 78a3f8483..4a0da53b4 100644 --- a/Minecraft.World/Util/Hasher.cpp +++ b/Minecraft.World/Util/Hasher.cpp @@ -35,7 +35,7 @@ std::wstring Hasher::getHash(std::wstring& name) { std::string combined_str(combined.begin(), combined.end()); unsigned char result[EVP_MAX_MD_SIZE]; EVP_MD_CTX* md5_ctx = EVP_MD_CTX_new(); - EVP_DigestInit_ex(md5_ctx, EVP_md5(), NULL); + EVP_DigestInit_ex(md5_ctx, EVP_md5(), nullptr); EVP_DigestUpdate(md5_ctx, combined_str.c_str(), combined_str.size()); unsigned int result_len; EVP_DigestFinal_ex(md5_ctx, result, &result_len); diff --git a/Minecraft.World/Util/HtmlString.cpp b/Minecraft.World/Util/HtmlString.cpp index 8e0d06b95..078f5d2fd 100644 --- a/Minecraft.World/Util/HtmlString.cpp +++ b/Minecraft.World/Util/HtmlString.cpp @@ -35,7 +35,7 @@ std::wstring HtmlString::ToString() { } std::wstring HtmlString::Compose(std::vector* strings) { - if (strings == NULL) return L""; + if (strings == nullptr) return L""; std::wstringstream ss; diff --git a/Minecraft.World/Util/Mth.cpp b/Minecraft.World/Util/Mth.cpp index cff6d8a96..611e53a05 100644 --- a/Minecraft.World/Util/Mth.cpp +++ b/Minecraft.World/Util/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; // 4jcraft for clarity constexpr size_t SIN_TAB_CNT = 65536; @@ -25,7 +25,7 @@ void Mth::init() { } float Mth::sin(float i) { - if (_sin == NULL) init(); // 4J - added + if (_sin == nullptr) init(); // 4J - added // 4jcraft changed, what ever this was, it was not safe // fmodf returns between -65536 and 65536 (casted) @@ -36,7 +36,7 @@ float Mth::sin(float i) { } float Mth::cos(float i) { - if (_sin == NULL) init(); // 4J - added + if (_sin == nullptr) init(); // 4J - added // 4jcraft same thing as ::sin but shift by SIN_TAB_CNT / 4 // which is aquivalent to shift by pi / 2 // and again the same modulo logic to cramp and map it onto the computed diff --git a/Minecraft.World/Util/PortableFileIO.h b/Minecraft.World/Util/PortableFileIO.h index fe6925143..75dd2ed6d 100644 --- a/Minecraft.World/Util/PortableFileIO.h +++ b/Minecraft.World/Util/PortableFileIO.h @@ -48,7 +48,7 @@ inline int64_t Tell(std::FILE* file) { inline BinaryReadResult ReadBinaryFile(const std::wstring& path, void* buffer, std::size_t capacity) { std::FILE* stream = OpenBinaryFileForRead(path); - if (stream == NULL) { + if (stream == nullptr) { return {BinaryReadStatus::not_found, 0, 0}; } @@ -88,7 +88,7 @@ inline BinaryReadResult ReadBinaryFileSegment(const std::wstring& path, std::size_t offset, void* buffer, std::size_t bytesToRead) { std::FILE* stream = OpenBinaryFileForRead(path); - if (stream == NULL) { + if (stream == nullptr) { return {BinaryReadStatus::not_found, 0, 0}; } @@ -132,7 +132,7 @@ inline bool WriteBinaryFile(const std::wstring& path, const void* buffer, const std::string nativePath = wstringtofilename(path); std::FILE* stream = std::fopen(nativePath.c_str(), "wb"); #endif - if (stream == NULL) { + if (stream == nullptr) { return false; } diff --git a/Minecraft.World/Util/Pos.cpp b/Minecraft.World/Util/Pos.cpp index 2775cecfa..7e6c2b0ca 100644 --- a/Minecraft.World/Util/Pos.cpp +++ b/Minecraft.World/Util/Pos.cpp @@ -20,9 +20,9 @@ Pos::Pos(Pos* position) { // public boolean equals(Object other) 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 + // 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((Pos*)other) != NULL)) { + if (!(dynamic_cast((Pos*)other) != nullptr)) { return false; } diff --git a/Minecraft.World/Util/WeighedRandom.cpp b/Minecraft.World/Util/WeighedRandom.cpp index 47f61897d..7a609af5a 100644 --- a/Minecraft.World/Util/WeighedRandom.cpp +++ b/Minecraft.World/Util/WeighedRandom.cpp @@ -23,7 +23,7 @@ WeighedRandomItem* WeighedRandom::getRandomItem( return *it; } } - return NULL; + return nullptr; } WeighedRandomItem* WeighedRandom::getRandomItem( @@ -53,7 +53,7 @@ WeighedRandomItem* WeighedRandom::getRandomItem(Random* random, return items[i]; } } - return NULL; + return nullptr; } WeighedRandomItem* WeighedRandom::getRandomItem(Random* random, diff --git a/Minecraft.World/Util/libdivide.h b/Minecraft.World/Util/libdivide.h index 201030185..bdcebf9ea 100644 --- a/Minecraft.World/Util/libdivide.h +++ b/Minecraft.World/Util/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 = (uint64_t)(-1); // and return the largest return (uint64_t)(-1);} // possible quotient. @@ -513,7 +513,7 @@ again2: 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 *(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 *(uint32_t *)nullptr; } + uint64_t crash_u64(uint64_t, const libdivide_u64_t *) { abort(); return *(uint64_t *)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.World/WorldGen/Biomes/Biome.cpp b/Minecraft.World/WorldGen/Biomes/Biome.cpp index ebcb1ce16..8adde11c2 100644 --- a/Minecraft.World/WorldGen/Biomes/Biome.cpp +++ b/Minecraft.World/WorldGen/Biomes/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() { // public static final Biome[] biomes = new Biome[256]; @@ -302,7 +302,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; @@ -339,7 +339,7 @@ Biome::Biome(int id) : id(id) { } Biome::~Biome() { - if (decorator != NULL) delete decorator; + if (decorator != nullptr) delete decorator; } BiomeDecorator* Biome::createDecorator() { return new BiomeDecorator(this); } @@ -430,7 +430,7 @@ std::vector* Biome::getMobs(MobCategory* category) { 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/WorldGen/Biomes/BiomeCache.cpp b/Minecraft.World/WorldGen/Biomes/BiomeCache.cpp index bc4f1109c..1e8609adb 100644 --- a/Minecraft.World/WorldGen/Biomes/BiomeCache.cpp +++ b/Minecraft.World/WorldGen/Biomes/BiomeCache.cpp @@ -88,7 +88,7 @@ BiomeCache::Block* BiomeCache::getBlockAt(int x, int z) { int64_t slot = (((int64_t)x) & 0xffffffffl) | ((((int64_t)z) & 0xffffffffl) << 32l); AUTO_VAR(it, cached.find(slot)); - Block* block = NULL; + Block* block = nullptr; if (it == cached.end()) { MemSect(48); block = new Block(x, z, this); diff --git a/Minecraft.World/WorldGen/Biomes/BiomeDecorator.cpp b/Minecraft.World/WorldGen/Biomes/BiomeDecorator.cpp index 696ec40af..27349e494 100644 --- a/Minecraft.World/WorldGen/Biomes/BiomeDecorator.cpp +++ b/Minecraft.World/WorldGen/Biomes/BiomeDecorator.cpp @@ -8,8 +8,8 @@ BiomeDecorator::BiomeDecorator(Biome* biome) { _init(); // 4J inits - level = NULL; - random = NULL; + level = nullptr; + random = nullptr; xo = 0; zo = 0; @@ -17,7 +17,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 __debugbreak(); @@ -31,8 +31,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; } void BiomeDecorator::_init() { @@ -150,7 +150,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++) { @@ -161,7 +161,7 @@ void BiomeDecorator::decorate() { // 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++) { int x = xo + random->nextInt(16) + 8; diff --git a/Minecraft.World/WorldGen/Biomes/BiomeSource.cpp b/Minecraft.World/WorldGen/Biomes/BiomeSource.cpp index 2336c3eab..e79dfa75b 100644 --- a/Minecraft.World/WorldGen/Biomes/BiomeSource.cpp +++ b/Minecraft.World/WorldGen/Biomes/BiomeSource.cpp @@ -75,9 +75,9 @@ floatArray BiomeSource::getDownfallBlock(int x, int z, int w, int h) const { // downfall layers brought forward from 1.2.3 void BiomeSource::getDownfallBlock(floatArray& downfalls, int x, int z, int w, int h) const { - // if (downfalls == NULL || downfalls->length < w * h) - if (downfalls.data == NULL || downfalls.length < w * h) { - if (downfalls.data != NULL) delete[] downfalls.data; + // if (downfalls == nullptr || downfalls->length < w * h) + if (downfalls.data == nullptr || downfalls.length < w * h) { + if (downfalls.data != nullptr) delete[] downfalls.data; downfalls = floatArray(w * h); } @@ -112,8 +112,8 @@ floatArray BiomeSource::getTemperatureBlock(int x, int z, int w, int h) const { void BiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z, int w, int h) const { // if (temperatures == null || temperatures.length < w * h) { - if (temperatures.data == NULL || temperatures.length < w * h) { - if (temperatures.data != NULL) delete[] temperatures.data; + if (temperatures.data == nullptr || temperatures.length < w * h) { + if (temperatures.data != nullptr) delete[] temperatures.data; temperatures = floatArray(w * h); } @@ -145,8 +145,8 @@ void BiomeSource::getRawBiomeIndices(intArray& biomes, int x, int z, int w, void BiomeSource::getRawBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h) const { // if (biomes == null || biomes.length < w * h) - if (biomes.data == NULL || biomes.length < w * h) { - if (biomes.data != NULL) delete[] biomes.data; + if (biomes.data == nullptr || biomes.length < w * h) { + if (biomes.data != nullptr) delete[] biomes.data; biomes = BiomeArray(w * h); } @@ -154,7 +154,7 @@ void BiomeSource::getRawBiomeBlock(BiomeArray& biomes, int x, int z, int w, for (int i = 0; i < w * h; i++) { biomes[i] = Biome::biomes[result[i]]; #if !defined(_CONTENT_PACKAGE) - if (biomes[i] == NULL) { + if (biomes[i] == nullptr) { app.DebugPrintf("Tried to assign null biome %d\n", result[i]); __debugbreak(); } @@ -175,8 +175,8 @@ BiomeArray BiomeSource::getBiomeBlock(int x, int z, int w, int h) const { void BiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h, bool useCache) const { // if (biomes == null || biomes.length < w * h) - if (biomes.data == NULL || biomes.length < w * h) { - if (biomes.data != NULL) delete[] biomes.data; + if (biomes.data == nullptr || biomes.length < w * h) { + if (biomes.data != nullptr) delete[] biomes.data; biomes = BiomeArray(w * h); } @@ -207,8 +207,8 @@ byteArray BiomeSource::getBiomeIndexBlock(int x, int z, int w, int h) const { void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, int w, int h, bool useCache) const { // if (biomes == null || biomes.length < w * h) - if (biomeIndices.data == NULL || biomeIndices.length < w * h) { - if (biomeIndices.data != NULL) delete[] biomeIndices.data; + if (biomeIndices.data == nullptr || biomeIndices.length < w * h) { + if (biomeIndices.data != nullptr) delete[] biomeIndices.data; biomeIndices = byteArray(w * h); } @@ -292,7 +292,7 @@ TilePos* BiomeSource::findBiome(int x, int z, int r, Biome* toFind, 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++) { @@ -300,7 +300,7 @@ TilePos* BiomeSource::findBiome(int x, int z, int r, Biome* toFind, int zz = z0 + i / w; 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++; } @@ -327,14 +327,14 @@ TilePos* BiomeSource::findBiome(int x, int z, int r, 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++) { int xx = (x0 + i % w) << 2; int zz = (z0 + i / w) << 2; 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); found++; diff --git a/Minecraft.World/WorldGen/Biomes/FixedBiomeSource.cpp b/Minecraft.World/WorldGen/Biomes/FixedBiomeSource.cpp index 473fb1d1d..d0f2ea0f7 100644 --- a/Minecraft.World/WorldGen/Biomes/FixedBiomeSource.cpp +++ b/Minecraft.World/WorldGen/Biomes/FixedBiomeSource.cpp @@ -17,8 +17,8 @@ float FixedBiomeSource::getTemperature(int x, int z) { return temperature; } 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 != NULL) delete[] temperatures.data; + if (temperatures.data == nullptr || temperatures.length < w * h) { + if (temperatures.data != nullptr) delete[] temperatures.data; temperatures = floatArray(w * h); } @@ -43,8 +43,8 @@ void FixedBiomeSource::getTemperatureBlock(doubleArray& temperatures, int x, 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 != NULL) delete[] downfalls.data; + if (downfalls.data == nullptr || downfalls.length < w * h) { + if (downfalls.data != nullptr) delete[] downfalls.data; downfalls = floatArray(w * h); } Arrays::fill(downfalls, 0, w * h, downfall); @@ -61,8 +61,8 @@ float FixedBiomeSource::getDownfall(int x, int z) const { return downfall; } void FixedBiomeSource::getDownfallBlock(doubleArray downfalls, int x, int z, int w, int h) { - if (downfalls.data == NULL || downfalls.length < w * h) { - if (downfalls.data != NULL) delete[] downfalls.data; + if (downfalls.data == nullptr || downfalls.length < w * h) { + 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, 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/WorldGen/Features/BasicTreeFeature.cpp b/Minecraft.World/WorldGen/Features/BasicTreeFeature.cpp index f8c8d9007..8dc6e212b 100644 --- a/Minecraft.World/WorldGen/Features/BasicTreeFeature.cpp +++ b/Minecraft.World/WorldGen/Features/BasicTreeFeature.cpp @@ -31,7 +31,7 @@ BasicTree::BasicTree(bool doUpdate) : Feature(doUpdate) { trunkWidth = 1; heightVariance = 12; foliageHeight = 4; - foliageCoords = NULL; + foliageCoords = nullptr; foliageCoordsLength = 0; } @@ -118,7 +118,7 @@ void BasicTree::prepare() { // Delete the rest of the array whilst we still know how big it was 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 @@ -445,7 +445,7 @@ bool BasicTree::checkLocation() { // 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( diff --git a/Minecraft.World/WorldGen/Features/BirchFeature.cpp b/Minecraft.World/WorldGen/Features/BirchFeature.cpp index 3c3b9174c..63dc21c46 100644 --- a/Minecraft.World/WorldGen/Features/BirchFeature.cpp +++ b/Minecraft.World/WorldGen/Features/BirchFeature.cpp @@ -36,7 +36,7 @@ bool BirchFeature::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(); int radius = 3; diff --git a/Minecraft.World/WorldGen/Features/BonusChestFeature.cpp b/Minecraft.World/WorldGen/Features/BonusChestFeature.cpp index 56bd1b709..1e2b488c5 100644 --- a/Minecraft.World/WorldGen/Features/BonusChestFeature.cpp +++ b/Minecraft.World/WorldGen/Features/BonusChestFeature.cpp @@ -65,7 +65,7 @@ bool BonusChestFeature::place(Level* level, Random* random, int x, int y, int z, std::shared_ptr chest = std::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/WorldGen/Features/CaveFeature.cpp b/Minecraft.World/WorldGen/Features/CaveFeature.cpp index ecdce794c..dbaf54da8 100644 --- a/Minecraft.World/WorldGen/Features/CaveFeature.cpp +++ b/Minecraft.World/WorldGen/Features/CaveFeature.cpp @@ -33,7 +33,7 @@ bool CaveFeature::place(Level* level, Random* random, int x, int y, int z) { // 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( diff --git a/Minecraft.World/WorldGen/Features/FlowerFeature.cpp b/Minecraft.World/WorldGen/Features/FlowerFeature.cpp index 1ba254ecc..f59bcbd5b 100644 --- a/Minecraft.World/WorldGen/Features/FlowerFeature.cpp +++ b/Minecraft.World/WorldGen/Features/FlowerFeature.cpp @@ -9,7 +9,7 @@ FlowerFeature::FlowerFeature(int tile) { this->tile = 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, diff --git a/Minecraft.World/WorldGen/Features/LakeFeature.cpp b/Minecraft.World/WorldGen/Features/LakeFeature.cpp index 28dd11011..685aebda5 100644 --- a/Minecraft.World/WorldGen/Features/LakeFeature.cpp +++ b/Minecraft.World/WorldGen/Features/LakeFeature.cpp @@ -18,8 +18,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(); int minX = x; diff --git a/Minecraft.World/WorldGen/Features/MegaTreeFeature.cpp b/Minecraft.World/WorldGen/Features/MegaTreeFeature.cpp index 71ef87df6..1dfaf4991 100644 --- a/Minecraft.World/WorldGen/Features/MegaTreeFeature.cpp +++ b/Minecraft.World/WorldGen/Features/MegaTreeFeature.cpp @@ -18,7 +18,7 @@ bool MegaTreeFeature::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) { PIXBeginNamedEvent(0, "MegaTreeFeature Checking intersects"); LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); diff --git a/Minecraft.World/WorldGen/Features/MineShaftFeature.cpp b/Minecraft.World/WorldGen/Features/MineShaftFeature.cpp index f8287e4e2..796b3f1eb 100644 --- a/Minecraft.World/WorldGen/Features/MineShaftFeature.cpp +++ b/Minecraft.World/WorldGen/Features/MineShaftFeature.cpp @@ -23,7 +23,7 @@ MineShaftFeature::MineShaftFeature( 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/WorldGen/Features/MonsterRoomFeature.cpp b/Minecraft.World/WorldGen/Features/MonsterRoomFeature.cpp index 6bb4fc08b..b6545c4db 100644 --- a/Minecraft.World/WorldGen/Features/MonsterRoomFeature.cpp +++ b/Minecraft.World/WorldGen/Features/MonsterRoomFeature.cpp @@ -104,7 +104,7 @@ bool MonsterRoomFeature::place(Level* level, Random* random, int x, int y, std::shared_ptr chest = std::dynamic_pointer_cast( level->getTileEntity(xc, yc, zc)); - if (chest != NULL) { + if (chest != nullptr) { WeighedTreasure::addChestItems(random, treasure, chest, 8); } @@ -117,7 +117,7 @@ bool MonsterRoomFeature::place(Level* level, Random* random, int x, int y, std::shared_ptr entity = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (entity != NULL) { + if (entity != nullptr) { entity->getSpawner()->setEntityId(randomEntityId(random)); } diff --git a/Minecraft.World/WorldGen/Features/NetherBridgeFeature.cpp b/Minecraft.World/WorldGen/Features/NetherBridgeFeature.cpp index 468a96df9..8f8980b07 100644 --- a/Minecraft.World/WorldGen/Features/NetherBridgeFeature.cpp +++ b/Minecraft.World/WorldGen/Features/NetherBridgeFeature.cpp @@ -16,11 +16,11 @@ NetherBridgeFeature::NetherBridgeFeature() : StructureFeature() { 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; } std::wstring NetherBridgeFeature::getFeatureName() { return L"Fortress"; } @@ -51,7 +51,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/WorldGen/Features/OreFeature.cpp b/Minecraft.World/WorldGen/Features/OreFeature.cpp index 6f3b776d9..d3fd028ac 100644 --- a/Minecraft.World/WorldGen/Features/OreFeature.cpp +++ b/Minecraft.World/WorldGen/Features/OreFeature.cpp @@ -31,8 +31,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(); // 4J Stu - Optimise schematic intersection checks by first checking the @@ -79,7 +79,7 @@ bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { // 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/WorldGen/Features/PineFeature.cpp b/Minecraft.World/WorldGen/Features/PineFeature.cpp index db74d9ac9..fec11fc17 100644 --- a/Minecraft.World/WorldGen/Features/PineFeature.cpp +++ b/Minecraft.World/WorldGen/Features/PineFeature.cpp @@ -18,7 +18,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( diff --git a/Minecraft.World/WorldGen/Features/RandomScatteredLargeFeature.cpp b/Minecraft.World/WorldGen/Features/RandomScatteredLargeFeature.cpp index afc1599fd..48276d104 100644 --- a/Minecraft.World/WorldGen/Features/RandomScatteredLargeFeature.cpp +++ b/Minecraft.World/WorldGen/Features/RandomScatteredLargeFeature.cpp @@ -58,7 +58,7 @@ bool RandomScatteredLargeFeature::isFeatureChunk(int x, int z, bool forcePlacement = false; LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); - if (levelGenOptions != NULL) { + if (levelGenOptions != nullptr) { forcePlacement = levelGenOptions->isFeatureChunk(x, z, eFeature_Temples); } @@ -114,15 +114,15 @@ RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart( bool RandomScatteredLargeFeature::isSwamphut(int cellX, int cellY, int cellZ) { StructureStart* structureAt = getStructureAt(cellX, cellY, cellZ); - if (structureAt == NULL || + if (structureAt == nullptr || !(dynamic_cast(structureAt)) || structureAt->pieces.empty()) { return false; } - StructurePiece* first = NULL; + StructurePiece* first = nullptr; AUTO_VAR(it, structureAt->pieces.begin()); if (it != structureAt->pieces.end()) first = *it; - return dynamic_cast(first) != NULL; + return dynamic_cast(first) != nullptr; } std::vector* diff --git a/Minecraft.World/WorldGen/Features/ReedsFeature.cpp b/Minecraft.World/WorldGen/Features/ReedsFeature.cpp index 12f73394c..744953e03 100644 --- a/Minecraft.World/WorldGen/Features/ReedsFeature.cpp +++ b/Minecraft.World/WorldGen/Features/ReedsFeature.cpp @@ -11,7 +11,7 @@ bool ReedsFeature::place(Level* level, Random* random, int x, int y, int z) { // 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 = diff --git a/Minecraft.World/WorldGen/Features/SandFeature.cpp b/Minecraft.World/WorldGen/Features/SandFeature.cpp index fe9f015eb..00e3df65d 100644 --- a/Minecraft.World/WorldGen/Features/SandFeature.cpp +++ b/Minecraft.World/WorldGen/Features/SandFeature.cpp @@ -22,7 +22,7 @@ bool SandFeature::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( diff --git a/Minecraft.World/WorldGen/Features/SpringFeature.cpp b/Minecraft.World/WorldGen/Features/SpringFeature.cpp index 69b4f46af..34906fd7e 100644 --- a/Minecraft.World/WorldGen/Features/SpringFeature.cpp +++ b/Minecraft.World/WorldGen/Features/SpringFeature.cpp @@ -8,7 +8,7 @@ SpringFeature::SpringFeature(int tile) { this->tile = 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/WorldGen/Features/SpruceFeature.cpp b/Minecraft.World/WorldGen/Features/SpruceFeature.cpp index 730c69ed2..dba9aa12d 100644 --- a/Minecraft.World/WorldGen/Features/SpruceFeature.cpp +++ b/Minecraft.World/WorldGen/Features/SpruceFeature.cpp @@ -20,7 +20,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( diff --git a/Minecraft.World/WorldGen/Features/StrongholdFeature.cpp b/Minecraft.World/WorldGen/Features/StrongholdFeature.cpp index 60cbf19b5..35d0cd537 100644 --- a/Minecraft.World/WorldGen/Features/StrongholdFeature.cpp +++ b/Minecraft.World/WorldGen/Features/StrongholdFeature.cpp @@ -36,7 +36,7 @@ void StrongholdFeature::_init() { // 4J added initialisers for (int i = 0; i < strongholdPos_length; i++) { - strongholdPos[i] = NULL; + strongholdPos[i] = nullptr; } isSpotSelected = false; } @@ -131,7 +131,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { ((unsigned int)selectedX << 4) + 8, ((unsigned int)selectedZ << 4) + 8, 7 << 4, allowedBiomes, &random); - if (position != NULL) { + if (position != nullptr) { selectedX = position->x >> 4; selectedZ = position->z >> 4; @@ -188,7 +188,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); } @@ -205,7 +205,7 @@ std::vector* StrongholdFeature::getGuesstimatedFeaturePositions() { std::vector* positions = new std::vector(); for (int i = 0; i < strongholdPos_length; i++) { ChunkPos* chunkPos = strongholdPos[i]; - if (chunkPos != NULL) { + if (chunkPos != nullptr) { positions->push_back(chunkPos->getMiddleBlockPosition(64)); } } @@ -218,7 +218,7 @@ StructureStart* StrongholdFeature::createStructureStart(int x, int z) { // 4J - front() was get(0) while (start->getPieces()->empty() || ((StrongholdPieces::StartPiece*)start->getPieces()->front()) - ->portalRoomPiece == NULL) { + ->portalRoomPiece == nullptr) { delete start; // regenerate stronghold without changing seed start = new StrongholdStart(level, random, x, z); diff --git a/Minecraft.World/WorldGen/Features/StructureFeature.cpp b/Minecraft.World/WorldGen/Features/StructureFeature.cpp index 5599c2705..4c71d642e 100644 --- a/Minecraft.World/WorldGen/Features/StructureFeature.cpp +++ b/Minecraft.World/WorldGen/Features/StructureFeature.cpp @@ -110,7 +110,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, @@ -145,7 +145,7 @@ StructureStart* StructureFeature::getStructureAt(int cellX, int cellY, } } } - return NULL; + return nullptr; } bool StructureFeature::isInsideBoundingFeature(int cellX, int cellY, @@ -181,7 +181,7 @@ TilePos* StructureFeature::getNearestGeneratedFeature(Level* level, int cellX, addFeature(level, cellX >> 4, cellZ >> 4, 0, 0, byteArray()); double minDistance = DBL_MAX; - TilePos* selected = NULL; + TilePos* selected = nullptr; for (AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it) { @@ -205,12 +205,12 @@ TilePos* StructureFeature::getNearestGeneratedFeature(Level* level, int cellX, } } } - if (selected != NULL) { + if (selected != nullptr) { return selected; } else { std::vector* guesstimatedFeaturePositions = getGuesstimatedFeaturePositions(); - if (guesstimatedFeaturePositions != NULL) { + if (guesstimatedFeaturePositions != nullptr) { TilePos* pSelectedPos = new TilePos(0, 0, 0); for (AUTO_VAR(it, guesstimatedFeaturePositions->begin()); @@ -231,21 +231,21 @@ TilePos* StructureFeature::getNearestGeneratedFeature(Level* level, int cellX, return pSelectedPos; } } - return NULL; + return nullptr; } std::vector* StructureFeature::getGuesstimatedFeaturePositions() { - return NULL; + return nullptr; } void StructureFeature::restoreSavedData(Level* level) { #ifdef ENABLE_STRUCTURE_SAVING - if (savedData == NULL) { + if (savedData == nullptr) { savedData = std::dynamic_pointer_cast( level->getSavedData(typeid(StructureFeatureSavedData), getFeatureName())); - if (savedData == NULL) { + if (savedData == nullptr) { savedData = std::shared_ptr( new StructureFeatureSavedData(getFeatureName())); level->setSavedData(getFeatureName(), savedData); diff --git a/Minecraft.World/WorldGen/Features/SwampTreeFeature.cpp b/Minecraft.World/WorldGen/Features/SwampTreeFeature.cpp index ac3007d9f..31f1c621d 100644 --- a/Minecraft.World/WorldGen/Features/SwampTreeFeature.cpp +++ b/Minecraft.World/WorldGen/Features/SwampTreeFeature.cpp @@ -14,7 +14,7 @@ bool SwampTreeFeature::place(Level* level, Random* random, int x, int y, // 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( diff --git a/Minecraft.World/WorldGen/Features/TreeFeature.cpp b/Minecraft.World/WorldGen/Features/TreeFeature.cpp index e9c4bd399..13d3e8ecd 100644 --- a/Minecraft.World/WorldGen/Features/TreeFeature.cpp +++ b/Minecraft.World/WorldGen/Features/TreeFeature.cpp @@ -26,7 +26,7 @@ bool TreeFeature::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) { PIXBeginNamedEvent(0, "TreeFeature checking intersects"); LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); diff --git a/Minecraft.World/WorldGen/Features/VillageFeature.cpp b/Minecraft.World/WorldGen/Features/VillageFeature.cpp index 7987c0216..986e68997 100644 --- a/Minecraft.World/WorldGen/Features/VillageFeature.cpp +++ b/Minecraft.World/WorldGen/Features/VillageFeature.cpp @@ -71,7 +71,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); } @@ -144,7 +144,7 @@ VillageFeature::VillageStart::VillageStart(Level* level, Random* random, int count = 0; for (AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++) { StructurePiece* piece = *it; - if (dynamic_cast(piece) == NULL) { + if (dynamic_cast(piece) == nullptr) { count++; } } diff --git a/Minecraft.World/WorldGen/Flat/FlatGeneratorInfo.cpp b/Minecraft.World/WorldGen/Flat/FlatGeneratorInfo.cpp index cfc889433..22ed5fcc3 100644 --- a/Minecraft.World/WorldGen/Flat/FlatGeneratorInfo.cpp +++ b/Minecraft.World/WorldGen/Flat/FlatGeneratorInfo.cpp @@ -50,12 +50,12 @@ std::wstring FlatGeneratorInfo::toString() { FlatLayerInfo* FlatGeneratorInfo::getLayerFromString(const std::wstring& input, int yOffset) { - return NULL; + return nullptr; } std::vector* FlatGeneratorInfo::getLayersFromString( const std::wstring& input) { - if (input.empty()) return NULL; + if (input.empty()) return nullptr; std::vector* result = new std::vector(); std::vector depths = stringSplit(input, L','); @@ -64,7 +64,7 @@ std::vector* FlatGeneratorInfo::getLayersFromString( for (AUTO_VAR(it, depths.begin()); it != depths.end(); ++it) { FlatLayerInfo* layer = getLayerFromString(*it, yOffset); - if (layer == NULL) return NULL; + if (layer == nullptr) return nullptr; result->push_back(layer); yOffset += layer->getHeight(); } diff --git a/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp b/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp index cc56b9491..89735789a 100644 --- a/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp @@ -9,16 +9,16 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) { #if defined(_UNICODE) std::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 #if defined(_WINDOWS64) std::string path = "GameRules\\biomemap.bin"; #else std::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) { DWORD error = GetLastError(); @@ -27,13 +27,13 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) { memset(m_biomeOverride.data, Biome::plains->id, m_biomeOverride.length); } else { - DWORD bytesRead, dwFileSize = GetFileSize(file, NULL); + DWORD bytesRead, dwFileSize = GetFileSize(file, nullptr); if (dwFileSize > m_biomeOverride.length) { app.DebugPrintf("Biomemap binary is too large!!\n"); __debugbreak(); } BOOL bSuccess = - ReadFile(file, m_biomeOverride.data, dwFileSize, &bytesRead, NULL); + ReadFile(file, m_biomeOverride.data, dwFileSize, &bytesRead, nullptr); if (bSuccess == FALSE) { app.FatalLoadError(); diff --git a/Minecraft.World/WorldGen/Layers/Layer.cpp b/Minecraft.World/WorldGen/Layers/Layer.cpp index b9438c094..66983ff80 100644 --- a/Minecraft.World/WorldGen/Layers/Layer.cpp +++ b/Minecraft.World/WorldGen/Layers/Layer.cpp @@ -133,7 +133,7 @@ Layer::Layer(int64_t seedMixup) { void Layer::init(int64_t seed) { this->seed = seed; - if (parent != NULL) parent->init(seed); + if (parent != nullptr) parent->init(seed); // 4jcraft added casts to prevent signed int overflow this->seed *= (uint64_t)this->seed * 6364136223846793005l + 1442695040888963407l; diff --git a/Minecraft.World/WorldGen/Noise/FastNoise.cpp b/Minecraft.World/WorldGen/Noise/FastNoise.cpp index 6c1483345..1b44de282 100644 --- a/Minecraft.World/WorldGen/Noise/FastNoise.cpp +++ b/Minecraft.World/WorldGen/Noise/FastNoise.cpp @@ -27,7 +27,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) + 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/WorldGen/Noise/PerlinNoise.cpp b/Minecraft.World/WorldGen/Noise/PerlinNoise.cpp index 8e6d3456a..2f4db10ae 100644 --- a/Minecraft.World/WorldGen/Noise/PerlinNoise.cpp +++ b/Minecraft.World/WorldGen/Noise/PerlinNoise.cpp @@ -54,7 +54,7 @@ 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) + 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/WorldGen/Noise/PerlinSimplexNoise.cpp b/Minecraft.World/WorldGen/Noise/PerlinSimplexNoise.cpp index c19fac8e6..40d2f10f3 100644 --- a/Minecraft.World/WorldGen/Noise/PerlinSimplexNoise.cpp +++ b/Minecraft.World/WorldGen/Noise/PerlinSimplexNoise.cpp @@ -67,7 +67,7 @@ doubleArray PerlinSimplexNoise::getRegion(doubleArray buffer, double x, xScale /= 1.5; yScale /= 1.5; - if (buffer.data == NULL || (int)buffer.length < xSize * ySize) { + if (buffer.data == nullptr || (int)buffer.length < xSize * ySize) { if (buffer.data) delete[] buffer.data; buffer = doubleArray(xSize * ySize); } else @@ -92,7 +92,7 @@ doubleArray PerlinSimplexNoise::getRegion(doubleArray buffer, double x, xScale /= 1.5; yScale /= 1.5; - if (buffer.data == NULL) + 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/WorldGen/Sources/FlatLevelSource.cpp b/Minecraft.World/WorldGen/Sources/FlatLevelSource.cpp index 9cbdc7f6d..5b4f429b8 100644 --- a/Minecraft.World/WorldGen/Sources/FlatLevelSource.cpp +++ b/Minecraft.World/WorldGen/Sources/FlatLevelSource.cpp @@ -113,8 +113,8 @@ std::wstring FlatLevelSource::gatherStats() { return L"FlatLevelSource"; } std::vector* FlatLevelSource::getMobsAt( MobCategory* mobCategory, int x, int y, int z) { Biome* biome = level->getBiome(x, z); - if (biome == NULL) { - return NULL; + if (biome == nullptr) { + return nullptr; } return biome->getMobs(mobCategory); } @@ -122,7 +122,7 @@ std::vector* FlatLevelSource::getMobsAt( TilePos* FlatLevelSource::findNearestMapFeature(Level* level, const std::wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } void FlatLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) { diff --git a/Minecraft.World/WorldGen/Sources/HellFlatLevelSource.cpp b/Minecraft.World/WorldGen/Sources/HellFlatLevelSource.cpp index e4b16fd1b..9bec242f3 100644 --- a/Minecraft.World/WorldGen/Sources/HellFlatLevelSource.cpp +++ b/Minecraft.World/WorldGen/Sources/HellFlatLevelSource.cpp @@ -184,15 +184,15 @@ std::wstring HellFlatLevelSource::gatherStats() { std::vector* HellFlatLevelSource::getMobsAt( MobCategory* mobCategory, int x, int y, int z) { Biome* biome = level->getBiome(x, z); - if (biome == NULL) { - return NULL; + if (biome == nullptr) { + return nullptr; } return biome->getMobs(mobCategory); } TilePos* HellFlatLevelSource::findNearestMapFeature( Level* level, const std::wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } void HellFlatLevelSource::recreateLogicStructuresForChunk(int chunkX, diff --git a/Minecraft.World/WorldGen/Sources/HellRandomLevelSource.cpp b/Minecraft.World/WorldGen/Sources/HellRandomLevelSource.cpp index 905804fef..316b6a023 100644 --- a/Minecraft.World/WorldGen/Sources/HellRandomLevelSource.cpp +++ b/Minecraft.World/WorldGen/Sources/HellRandomLevelSource.cpp @@ -328,7 +328,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); } @@ -548,15 +548,15 @@ std::vector* HellRandomLevelSource::getMobsAt( } Biome* biome = level->getBiome(x, z); - if (biome == NULL) { - return NULL; + if (biome == nullptr) { + return nullptr; } return biome->getMobs(mobCategory); } TilePos* HellRandomLevelSource::findNearestMapFeature( Level* level, const std::wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } void HellRandomLevelSource::recreateLogicStructuresForChunk(int chunkX, diff --git a/Minecraft.World/WorldGen/Sources/TheEndLevelRandomLevelSource.cpp b/Minecraft.World/WorldGen/Sources/TheEndLevelRandomLevelSource.cpp index 47690fd44..5170267bf 100644 --- a/Minecraft.World/WorldGen/Sources/TheEndLevelRandomLevelSource.cpp +++ b/Minecraft.World/WorldGen/Sources/TheEndLevelRandomLevelSource.cpp @@ -208,7 +208,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); } @@ -422,15 +422,15 @@ std::wstring TheEndLevelRandomLevelSource::gatherStats() { std::vector* TheEndLevelRandomLevelSource::getMobsAt( MobCategory* mobCategory, int x, int y, int z) { Biome* biome = level->getBiome(x, z); - if (biome == NULL) { - return NULL; + if (biome == nullptr) { + return nullptr; } return biome->getMobs(mobCategory); } TilePos* TheEndLevelRandomLevelSource::findNearestMapFeature( Level* level, const std::wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } void TheEndLevelRandomLevelSource::recreateLogicStructuresForChunk(int chunkX, diff --git a/Minecraft.World/WorldGen/StructureFeatureIO.cpp b/Minecraft.World/WorldGen/StructureFeatureIO.cpp index 9e91abe94..d89397969 100644 --- a/Minecraft.World/WorldGen/StructureFeatureIO.cpp +++ b/Minecraft.World/WorldGen/StructureFeatureIO.cpp @@ -66,14 +66,14 @@ std::wstring StructureFeatureIO::getEncodeId(StructurePiece* piece) { StructureStart* StructureFeatureIO::loadStaticStart(CompoundTag* tag, Level* level) { - StructureStart* start = NULL; + StructureStart* start = nullptr; AUTO_VAR(it, startIdClassMap.find(tag->getString(L"id"))); if (it != startIdClassMap.end()) { start = (it->second)(); } - if (start != NULL) { + if (start != nullptr) { start->load(level, tag); } else { app.DebugPrintf("Skipping Structure with id %ls", @@ -84,14 +84,14 @@ StructureStart* StructureFeatureIO::loadStaticStart(CompoundTag* tag, StructurePiece* StructureFeatureIO::loadStaticPiece(CompoundTag* tag, Level* level) { - StructurePiece* piece = NULL; + StructurePiece* piece = nullptr; AUTO_VAR(it, pieceIdClassMap.find(tag->getString(L"id"))); if (it != pieceIdClassMap.end()) { piece = (it->second)(); } - if (piece != NULL) { + if (piece != nullptr) { piece->load(level, tag); } else { app.DebugPrintf("Skipping Piece with id %ls", diff --git a/Minecraft.World/WorldGen/Structures/MineShaftPieces.cpp b/Minecraft.World/WorldGen/Structures/MineShaftPieces.cpp index 53b5b6cdd..dc93026c8 100644 --- a/Minecraft.World/WorldGen/Structures/MineShaftPieces.cpp +++ b/Minecraft.World/WorldGen/Structures/MineShaftPieces.cpp @@ -55,43 +55,43 @@ StructurePiece* MineShaftPieces::createRandomShaftPiece( 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); } } 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); } } 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, std::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); MemSect(0); @@ -142,7 +142,7 @@ void MineShaftPieces::MineShaftRoom::addChildren( 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, @@ -161,7 +161,7 @@ void MineShaftPieces::MineShaftRoom::addChildren( 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, @@ -180,7 +180,7 @@ void MineShaftPieces::MineShaftRoom::addChildren( 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, @@ -199,7 +199,7 @@ void MineShaftPieces::MineShaftRoom::addChildren( 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, @@ -327,7 +327,7 @@ BoundingBox* MineShaftPieces::MineShaftCorridor::findCorridorSize( break; } - if (StructurePiece::findCollisionPiece(pieces, box) != NULL) { + if (StructurePiece::findCollisionPiece(pieces, box) != nullptr) { corridorLength--; } else { break; @@ -339,7 +339,7 @@ BoundingBox* MineShaftPieces::MineShaftCorridor::findCorridorSize( } delete box; // unable to place corridor here - return NULL; + return nullptr; } void MineShaftPieces::MineShaftCorridor::addChildren( @@ -579,7 +579,7 @@ bool MineShaftPieces::MineShaftCorridor::postProcess(Level* level, std::shared_ptr entity = std::dynamic_pointer_cast( level->getTileEntity(x, y, newZ)); - if (entity != NULL) + if (entity != nullptr) entity->getSpawner()->setEntityId(L"CaveSpider"); } } @@ -669,9 +669,9 @@ BoundingBox* MineShaftPieces::MineShaftCrossing::findCrossing( break; } - if (StructurePiece::findCollisionPiece(pieces, box) != NULL) { + if (StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return box; @@ -864,9 +864,9 @@ BoundingBox* MineShaftPieces::MineShaftStairs::findStairs( 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/WorldGen/Structures/NetherBridgePieces.cpp b/Minecraft.World/WorldGen/Structures/NetherBridgePieces.cpp index 450100a37..ee6182298 100644 --- a/Minecraft.World/WorldGen/Structures/NetherBridgePieces.cpp +++ b/Minecraft.World/WorldGen/Structures/NetherBridgePieces.cpp @@ -108,7 +108,7 @@ NetherBridgePieces::findAndCreateBridgePieceFactory( NetherBridgePieces::PieceWeight* piece, std::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) { structurePiece = BridgeStraight::createPiece( @@ -227,7 +227,7 @@ NetherBridgePieces::NetherBridgePiece::generatePiece( findAndCreateBridgePieceFactory(piece, pieces, random, footX, footY, footZ, direction, depth); - if (structurePiece != NULL) { + if (structurePiece != nullptr) { piece->placeCount++; startPiece->previousPiece = piece; @@ -261,7 +261,7 @@ StructurePiece* NetherBridgePieces::NetherBridgePiece::generateAndAddPiece( 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); } @@ -293,7 +293,7 @@ StructurePiece* NetherBridgePieces::NetherBridgePiece::generateChildForward( boundingBox->y0 + yOff, boundingBox->z0 + xOff, orientation, getGenDepth(), isCastle); } - return NULL; + return nullptr; } StructurePiece* NetherBridgePieces::NetherBridgePiece::generateChildLeft( @@ -321,7 +321,7 @@ StructurePiece* NetherBridgePieces::NetherBridgePiece::generateChildLeft( boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth(), isCastle); } - return NULL; + return nullptr; } StructurePiece* NetherBridgePieces::NetherBridgePiece::generateChildRight( @@ -349,14 +349,14 @@ StructurePiece* NetherBridgePieces::NetherBridgePiece::generateChildRight( 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() @@ -448,14 +448,14 @@ NetherBridgePieces::BridgeStraight::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new BridgeStraight(genDepth, random, box, direction); @@ -535,14 +535,14 @@ NetherBridgePieces::BridgeEndFiller::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new BridgeEndFiller(genDepth, random, box, direction); @@ -652,14 +652,14 @@ NetherBridgePieces::BridgeCrossing::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -8, -3, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new BridgeCrossing(genDepth, random, box, direction); @@ -732,13 +732,13 @@ bool NetherBridgePieces::BridgeCrossing::postProcess(Level* level, 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++) { @@ -788,14 +788,14 @@ 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* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new RoomCrossing(genDepth, random, box, direction); @@ -877,14 +877,14 @@ NetherBridgePieces::StairsRoom* NetherBridgePieces::StairsRoom::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new StairsRoom(genDepth, random, box, direction); @@ -969,14 +969,14 @@ NetherBridgePieces::MonsterThrone::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new MonsterThrone(genDepth, random, box, direction); @@ -1046,7 +1046,7 @@ bool NetherBridgePieces::MonsterThrone::postProcess(Level* level, std::shared_ptr entity = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (entity != NULL) entity->getSpawner()->setEntityId(L"Blaze"); + if (entity != nullptr) entity->getSpawner()->setEntityId(L"Blaze"); } } @@ -1084,14 +1084,14 @@ NetherBridgePieces::CastleEntrance::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleEntrance(genDepth, random, box, direction); @@ -1240,14 +1240,14 @@ NetherBridgePieces::CastleStalkRoom::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleStalkRoom(genDepth, random, box, direction); @@ -1444,14 +1444,14 @@ NetherBridgePieces::CastleSmallCorridorPiece::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleSmallCorridorPiece(genDepth, random, box, direction); @@ -1521,14 +1521,14 @@ NetherBridgePieces::CastleSmallCorridorCrossingPiece::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleSmallCorridorCrossingPiece(genDepth, random, box, @@ -1609,14 +1609,14 @@ NetherBridgePieces::CastleSmallCorridorRightTurnPiece::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleSmallCorridorRightTurnPiece(genDepth, random, box, @@ -1717,14 +1717,14 @@ NetherBridgePieces::CastleSmallCorridorLeftTurnPiece::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleSmallCorridorLeftTurnPiece(genDepth, random, box, @@ -1807,14 +1807,14 @@ NetherBridgePieces::CastleCorridorStairsPiece::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, -7, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleCorridorStairsPiece(genDepth, random, box, direction); @@ -1900,14 +1900,14 @@ NetherBridgePieces::CastleCorridorTBalconyPiece::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -3, 0, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((NetherBridgePieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleCorridorTBalconyPiece(genDepth, random, box, direction); diff --git a/Minecraft.World/WorldGen/Structures/ScatteredFeaturePieces.cpp b/Minecraft.World/WorldGen/Structures/ScatteredFeaturePieces.cpp index 359c9aded..aea34d0cd 100644 --- a/Minecraft.World/WorldGen/Structures/ScatteredFeaturePieces.cpp +++ b/Minecraft.World/WorldGen/Structures/ScatteredFeaturePieces.cpp @@ -38,7 +38,7 @@ ScatteredFeaturePieces::ScatteredFeaturePiece::ScatteredFeaturePiece( 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, @@ -932,7 +932,7 @@ bool ScatteredFeaturePieces::SwamplandHut::postProcess(Level* level, std::shared_ptr witch = std::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/WorldGen/Structures/StrongholdPieces.cpp b/Minecraft.World/WorldGen/Structures/StrongholdPieces.cpp index 51af77a16..1a1f4f41a 100644 --- a/Minecraft.World/WorldGen/Structures/StrongholdPieces.cpp +++ b/Minecraft.World/WorldGen/Structures/StrongholdPieces.cpp @@ -102,7 +102,7 @@ bool StrongholdPieces::updatePieceWeight() { StrongholdPieces::StrongholdPiece* StrongholdPieces::findAndCreatePieceFactory( EPieceClass pieceClass, std::list* pieces, Random* random, int footX, int footY, int footZ, int direction, int depth) { - StrongholdPiece* strongholdPiece = NULL; + StrongholdPiece* strongholdPiece = nullptr; if (pieceClass == EPieceClass_Straight) { strongholdPiece = Straight::createPiece(pieces, random, footX, footY, @@ -146,7 +146,7 @@ StrongholdPieces::StrongholdPiece* StrongholdPieces::generatePieceFromSmallDoor( StartPiece* startPiece, std::list* pieces, Random* random, int footX, int footY, int footZ, int direction, int depth) { if (!updatePieceWeight()) { - return NULL; + return nullptr; } if (imposedPiece != EPieceClass_NULL) { @@ -155,7 +155,7 @@ StrongholdPieces::StrongholdPiece* StrongholdPieces::generatePieceFromSmallDoor( footY, footZ, direction, depth); imposedPiece = EPieceClass_NULL; - if (strongholdPiece != NULL) { + if (strongholdPiece != nullptr) { return strongholdPiece; } } @@ -178,7 +178,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; @@ -193,20 +193,20 @@ 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, std::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) { @@ -225,7 +225,7 @@ StructurePiece* StrongholdPieces::generateAndAddPiece( #endif StrongholdPiece* strongholdPiece = PortalRoom::createPiece( pieces, random, footX, footY, footZ, direction, depth); - if (strongholdPiece != NULL) { + if (strongholdPiece != nullptr) { piece->placeCount++; startPiece->previousPiece = piece; @@ -239,12 +239,12 @@ StructurePiece* StrongholdPieces::generateAndAddPiece( } } } - 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); // newPiece.addChildren(startPiece, pieces, random, depth + @@ -393,7 +393,7 @@ StrongholdPieces::StrongholdPiece::generateSmallDoorChildForward( boundingBox->y0 + yOff, boundingBox->z0 + xOff, orientation, getGenDepth()); } - return NULL; + return nullptr; } StructurePiece* StrongholdPieces::StrongholdPiece::generateSmallDoorChildLeft( @@ -421,7 +421,7 @@ StructurePiece* StrongholdPieces::StrongholdPiece::generateSmallDoorChildLeft( boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); } - return NULL; + return nullptr; } StructurePiece* StrongholdPieces::StrongholdPiece::generateSmallDoorChildRight( @@ -449,19 +449,19 @@ StructurePiece* StrongholdPieces::StrongholdPiece::generateSmallDoorChildRight( 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() >= + 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; @@ -513,11 +513,11 @@ BoundingBox* StrongholdPieces::FillerCorridor::findPieceBox( StructurePiece* collisionPiece = StructurePiece::findCollisionPiece(pieces, box); - if (collisionPiece == NULL) { + if (collisionPiece == nullptr) { delete box; // the filler must collide with something in order to be // generated - return NULL; + return nullptr; } if (collisionPiece->getBoundingBox()->y0 == box->y0) { @@ -537,7 +537,7 @@ BoundingBox* StrongholdPieces::FillerCorridor::findPieceBox( } } - return NULL; + return nullptr; } bool StrongholdPieces::FillerCorridor::postProcess(Level* level, Random* random, @@ -631,14 +631,14 @@ StrongholdPieces::StairsDown* StrongholdPieces::StairsDown::createPiece( BoundingBox::orientBox(footX, footY, footZ, -1, 4 - height, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new StairsDown(genDepth, random, box, direction); @@ -696,14 +696,14 @@ StrongholdPieces::StartPiece::StartPiece(int genDepth, Random* random, int west, : StairsDown(0, random, west, north) { // 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(); } return StairsDown::getLocatorPosition(); @@ -754,14 +754,14 @@ StrongholdPieces::Straight* StrongholdPieces::Straight::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new Straight(genDepth, random, box, direction); @@ -857,14 +857,14 @@ StrongholdPieces::ChestCorridor* StrongholdPieces::ChestCorridor::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new ChestCorridor(genDepth, random, box, direction); @@ -947,14 +947,14 @@ StrongholdPieces::StraightStairsDown::createPiece( BoundingBox::orientBox(footX, footY, footZ, -1, 4 - height, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new StraightStairsDown(genDepth, random, box, direction); @@ -1028,14 +1028,14 @@ StrongholdPieces::LeftTurn* StrongholdPieces::LeftTurn::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new LeftTurn(genDepth, random, box, direction); @@ -1143,14 +1143,14 @@ StrongholdPieces::RoomCrossing* StrongholdPieces::RoomCrossing::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -4, -1, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new RoomCrossing(genDepth, random, box, direction); @@ -1301,14 +1301,14 @@ StrongholdPieces::PrisonHall* StrongholdPieces::PrisonHall::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new PrisonHall(genDepth, random, box, direction); @@ -1391,21 +1391,21 @@ StrongholdPieces::Library* StrongholdPieces::Library::createPiece( BoundingBox* box = BoundingBox::orientBox( footX, footY, footZ, -4, -1, 0, width, tallHeight, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + 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) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } } @@ -1651,14 +1651,14 @@ StrongholdPieces::FiveCrossing* StrongholdPieces::FiveCrossing::createPiece( BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, -4, -3, 0, width, height, depth, direction); - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new FiveCrossing(genDepth, random, box, direction); @@ -1748,7 +1748,7 @@ void StrongholdPieces::PortalRoom::readAdditonalSaveData(CompoundTag* tag) { void StrongholdPieces::PortalRoom::addChildren( StructurePiece* startPiece, std::list* pieces, Random* random) { - if (startPiece != NULL) { + if (startPiece != nullptr) { ((StartPiece*)startPiece)->portalRoomPiece = this; } } @@ -1761,14 +1761,14 @@ StrongholdPieces::PortalRoom* StrongholdPieces::PortalRoom::createPiece( // 4J Added so that we can check that Portals stay within the bounds of the // world (which they ALWAYS should anyway) - StartPiece* startPiece = NULL; - if (pieces != NULL) + StartPiece* startPiece = nullptr; + if (pieces != nullptr) startPiece = ((StrongholdPieces::StartPiece*)pieces->front()); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new PortalRoom(genDepth, random, box, direction); @@ -1946,7 +1946,7 @@ bool StrongholdPieces::PortalRoom::postProcess(Level* level, Random* random, std::shared_ptr entity = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - if (entity != NULL) + if (entity != nullptr) entity->getSpawner()->setEntityId(L"Silverfish"); } } diff --git a/Minecraft.World/WorldGen/Structures/StructurePiece.cpp b/Minecraft.World/WorldGen/Structures/StructurePiece.cpp index 06ed98963..73452b9fe 100644 --- a/Minecraft.World/WorldGen/Structures/StructurePiece.cpp +++ b/Minecraft.World/WorldGen/Structures/StructurePiece.cpp @@ -43,20 +43,20 @@ */ StructurePiece::StructurePiece() { - boundingBox = NULL; + boundingBox = nullptr; orientation = 0; genDepth = 0; // for reflection } 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() { @@ -101,12 +101,12 @@ StructurePiece* StructurePiece::findCollisionPiece( std::list* pieces, BoundingBox* box) { for (AUTO_VAR(it, pieces->begin()); it != pieces->end(); it++) { StructurePiece* piece = *it; - if (piece->getBoundingBox() != NULL && + if (piece->getBoundingBox() != nullptr && piece->getBoundingBox()->intersects(box)) { return piece; } } - return NULL; + return nullptr; } // 4J-PB - Added from 1.2.3 @@ -340,7 +340,7 @@ int StructurePiece::getOrientationData(int tile, int data) { } } } else if (tile == Tile::tripWireSource_Id || - (Tile::tiles[tile] != NULL && + (Tile::tiles[tile] != nullptr && dynamic_cast(Tile::tiles[tile]))) { if (orientation == Direction::SOUTH) { if (data == Direction::SOUTH || data == Direction::NORTH) { @@ -661,7 +661,7 @@ bool StructurePiece::createChest(Level* level, BoundingBox* chunkBB, std::shared_ptr chest = std::dynamic_pointer_cast( level->getTileEntity(worldX, worldY, worldZ)); - if (chest != NULL) + if (chest != nullptr) WeighedTreasure::addChestItems(random, treasure, chest, numRolls); return true; @@ -687,7 +687,7 @@ bool StructurePiece::createDispenser(Level* level, BoundingBox* chunkBB, std::shared_ptr dispenser = std::dynamic_pointer_cast( level->getTileEntity(worldX, worldY, worldZ)); - if (dispenser != NULL) + if (dispenser != nullptr) WeighedTreasure::addDispenserItems(random, items, dispenser, numRolls); return true; diff --git a/Minecraft.World/WorldGen/Structures/StructureStart.cpp b/Minecraft.World/WorldGen/Structures/StructureStart.cpp index d378e9c33..8127cf027 100644 --- a/Minecraft.World/WorldGen/Structures/StructureStart.cpp +++ b/Minecraft.World/WorldGen/Structures/StructureStart.cpp @@ -7,13 +7,13 @@ 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/WorldGen/Structures/Village.cpp b/Minecraft.World/WorldGen/Structures/Village.cpp index 03a079387..ae1f28dfa 100644 --- a/Minecraft.World/WorldGen/Structures/Village.cpp +++ b/Minecraft.World/WorldGen/Structures/Village.cpp @@ -25,7 +25,7 @@ Village::Village() { golemCount = 0; noBreedTimer = 0; - level = NULL; + level = nullptr; } Village::Village(Level* level) { @@ -197,7 +197,7 @@ std::shared_ptr Village::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; } std::shared_ptr Village::getDoorInfo(int x, int y, int z) { @@ -236,7 +236,7 @@ void Village::addAggressor(std::shared_ptr mob) { std::shared_ptr Village::getClosestAggressor( std::shared_ptr from) { double closestSqr = std::numeric_limits::max(); - Aggressor* closest = NULL; + Aggressor* closest = nullptr; // for (int i = 0; i < aggressors.size(); ++i) for (AUTO_VAR(it, aggressors.begin()); it != aggressors.end(); ++it) { Aggressor* a = *it; // aggressors.get(i); @@ -245,7 +245,7 @@ std::shared_ptr Village::getClosestAggressor( closest = a; closestSqr = distSqr; } - return closest != NULL ? closest->mob : nullptr; + return closest != nullptr ? closest->mob : nullptr; } std::shared_ptr Village::getClosestBadStandingPlayer( @@ -259,7 +259,7 @@ std::shared_ptr Village::getClosestBadStandingPlayer( std::wstring player = it->first; if (isVeryBadStanding(player)) { std::shared_ptr mob = level->getPlayerByName(player); - if (mob != NULL) { + if (mob != nullptr) { double distSqr = mob->distanceToSqr(from); if (distSqr > closestSqr) continue; closest = mob; diff --git a/Minecraft.World/WorldGen/Structures/VillagePieces.cpp b/Minecraft.World/WorldGen/Structures/VillagePieces.cpp index d1b4fefdf..bf442ae38 100644 --- a/Minecraft.World/WorldGen/Structures/VillagePieces.cpp +++ b/Minecraft.World/WorldGen/Structures/VillagePieces.cpp @@ -127,7 +127,7 @@ VillagePieces::VillagePiece* VillagePieces::findAndCreatePieceFactory( std::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) { villagePiece = SimpleHouse::createPiece( @@ -166,7 +166,7 @@ VillagePieces::VillagePiece* VillagePieces::generatePieceFromSmallDoor( int footX, int footY, int footZ, int direction, int depth) { int totalWeight = updatePieceWeight(startPiece->pieceSet); if (totalWeight <= 0) { - return NULL; + return nullptr; } int numAttempts = 0; @@ -188,7 +188,7 @@ VillagePieces::VillagePiece* VillagePieces::generatePieceFromSmallDoor( VillagePiece* villagePiece = findAndCreatePieceFactory( startPiece, piece, pieces, random, footX, footY, footZ, direction, depth); - if (villagePiece != NULL) { + if (villagePiece != nullptr) { piece->placeCount++; startPiece->previousPiece = piece; @@ -205,29 +205,29 @@ VillagePieces::VillagePiece* VillagePieces::generatePieceFromSmallDoor( { 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, std::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; int xs = newPiece->boundingBox->x1 - newPiece->boundingBox->x0; @@ -241,23 +241,23 @@ StructurePiece* VillagePieces::generateAndAddPiece( } delete newPiece; } - return NULL; + return nullptr; } StructurePiece* VillagePieces::generateAndAddRoadPiece( StartPiece* startPiece, std::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; @@ -273,18 +273,18 @@ StructurePiece* VillagePieces::generateAndAddRoadPiece( } // 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() { heightPosition = -1; spawnedVillagerCount = 0; isDesertVillage = false; - startPiece = NULL; + startPiece = nullptr; // for reflection } @@ -294,7 +294,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; } } @@ -336,7 +336,7 @@ StructurePiece* VillagePieces::VillagePiece::generateHouseNorthernLeft( boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); } - return NULL; + return nullptr; } StructurePiece* VillagePieces::VillagePiece::generateHouseNorthernRight( @@ -364,7 +364,7 @@ StructurePiece* VillagePieces::VillagePiece::generateHouseNorthernRight( boundingBox->y0 + yOff, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); } - return NULL; + return nullptr; } int VillagePieces::VillagePiece::getAverageGroundHeight(Level* level, @@ -391,7 +391,7 @@ bool VillagePieces::VillagePiece::isOkBox(BoundingBox* box, StartPiece* startRoom) { bool bIsOk = false; - if (box != NULL) { + if (box != nullptr) { if (box->y0 > LOWEST_Y_POSITION) bIsOk = true; int xzSize = startRoom->m_level->getLevelData()->getXZSize(); @@ -598,9 +598,9 @@ VillagePieces::StartPiece::StartPiece(BiomeSource* biomeSource, int genDepth, Random* random, int west, int north, std::list* pieceSet, int villageSize, Level* level) - : Well(NULL, 0, random, west, north) { + : 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; @@ -652,7 +652,7 @@ void VillagePieces::StraightRoad::addChildren( while (depth < length - 8) { StructurePiece* piece = generateHouseNorthernLeft( (StartPiece*)startPiece, pieces, random, 0, depth); - if (piece != NULL) { + if (piece != nullptr) { depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan()); hasHouses = true; @@ -665,7 +665,7 @@ void VillagePieces::StraightRoad::addChildren( while (depth < length - 8) { StructurePiece* piece = generateHouseNorthernRight( (StartPiece*)startPiece, pieces, random, 0, depth); - if (piece != NULL) { + if (piece != nullptr) { depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan()); hasHouses = true; @@ -741,14 +741,14 @@ BoundingBox* VillagePieces::StraightRoad::findPieceBox( width, 3, length, direction); if (isOkBox(box, startPiece) && - StructurePiece::findCollisionPiece(pieces, box) == NULL) { + StructurePiece::findCollisionPiece(pieces, box) == nullptr) { return box; } delete box; length -= 7; } - return NULL; + return nullptr; } bool VillagePieces::StraightRoad::postProcess(Level* level, Random* random, @@ -796,9 +796,9 @@ VillagePieces::SimpleHouse* VillagePieces::SimpleHouse::createPiece( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new SimpleHouse(startPiece, genDepth, random, box, direction); @@ -928,9 +928,9 @@ VillagePieces::SmallTemple* VillagePieces::SmallTemple::createPiece( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new SmallTemple(startPiece, genDepth, random, box, direction); @@ -1084,9 +1084,9 @@ VillagePieces::BookHouse* VillagePieces::BookHouse::createPiece( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new BookHouse(startPiece, genDepth, random, box, direction); @@ -1262,9 +1262,9 @@ VillagePieces::SmallHut* VillagePieces::SmallHut::createPiece( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new SmallHut(startPiece, genDepth, random, box, direction); @@ -1381,9 +1381,9 @@ VillagePieces::PigHouse* VillagePieces::PigHouse::createPiece( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new PigHouse(startPiece, genDepth, random, box, direction); @@ -1543,9 +1543,9 @@ VillagePieces::TwoRoomHouse* VillagePieces::TwoRoomHouse::createPiece( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new TwoRoomHouse(startPiece, genDepth, random, box, direction); @@ -1753,9 +1753,9 @@ VillagePieces::Smithy* VillagePieces::Smithy::createPiece( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new Smithy(startPiece, genDepth, random, box, direction); @@ -1931,9 +1931,9 @@ VillagePieces::Farmland* VillagePieces::Farmland::createPiece( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new Farmland(startPiece, genDepth, random, box, direction); @@ -2044,9 +2044,9 @@ VillagePieces::DoubleFarmland* VillagePieces::DoubleFarmland::createPiece( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new DoubleFarmland(startPiece, genDepth, random, box, direction); @@ -2134,9 +2134,9 @@ BoundingBox* VillagePieces::LightPost::findPieceBox( width, height, depth, direction); if (!isOkBox(box, startPiece) || - StructurePiece::findCollisionPiece(pieces, box) != NULL) { + StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return box; diff --git a/Minecraft.World/WorldGen/Structures/Villages.cpp b/Minecraft.World/WorldGen/Structures/Villages.cpp index db20bd608..55735f397 100644 --- a/Minecraft.World/WorldGen/Structures/Villages.cpp +++ b/Minecraft.World/WorldGen/Structures/Villages.cpp @@ -10,7 +10,7 @@ const std::wstring Villages::VILLAGE_FILE_ID = L"villages"; Villages::Villages(const std::wstring& id) : SavedData(id) { _tick = 0; - level = NULL; + level = nullptr; } Villages::Villages(Level* level) : SavedData(VILLAGE_FILE_ID) { @@ -135,7 +135,7 @@ void Villages::addDoorInfos(Pos* pos) { if (isDoor(xx, yy, zz)) { std::shared_ptr currentDoor = getDoorInfo(xx, yy, zz); - if (currentDoor == NULL) + if (currentDoor == nullptr) createDoorInfo(xx, yy, zz); else currentDoor->timeStamp = _tick; @@ -155,7 +155,7 @@ std::shared_ptr Villages::getDoorInfo(int x, int y, int z) { for (AUTO_VAR(it, villages.begin()); it != villages.end(); ++it) { std::shared_ptr v = *it; std::shared_ptr di = v->getDoorInfo(x, y, z); - if (di != NULL) return di; + if (di != nullptr) return di; } return nullptr; }