aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.World')
-rw-r--r--Minecraft.World/AABB.cpp42
-rw-r--r--Minecraft.World/AbstractContainerMenu.cpp94
-rw-r--r--Minecraft.World/AbstractContainerMenu.h4
-rw-r--r--Minecraft.World/Achievement.cpp2
-rw-r--r--Minecraft.World/Achievements.cpp160
-rw-r--r--Minecraft.World/AddEntityPacket.cpp6
-rw-r--r--Minecraft.World/AddEntityPacket.h2
-rw-r--r--Minecraft.World/AddExperienceOrbPacket.h2
-rw-r--r--Minecraft.World/AddGlobalEntityPacket.h2
-rw-r--r--Minecraft.World/AddMobPacket.cpp18
-rw-r--r--Minecraft.World/AddMobPacket.h2
-rw-r--r--Minecraft.World/AddPaintingPacket.h2
-rw-r--r--Minecraft.World/AddPlayerPacket.cpp16
-rw-r--r--Minecraft.World/AddPlayerPacket.h2
-rw-r--r--Minecraft.World/AgableMob.cpp6
-rw-r--r--Minecraft.World/Animal.cpp24
-rw-r--r--Minecraft.World/AnimatePacket.h2
-rw-r--r--Minecraft.World/AnvilMenu.cpp20
-rw-r--r--Minecraft.World/AnvilTile.cpp2
-rw-r--r--Minecraft.World/ArmorDyeRecipe.cpp42
-rw-r--r--Minecraft.World/ArmorItem.cpp10
-rw-r--r--Minecraft.World/ArmorSlot.cpp8
-rw-r--r--Minecraft.World/ArrayWithLength.h6
-rw-r--r--Minecraft.World/Arrow.cpp88
-rw-r--r--Minecraft.World/AttributeModifier.cpp4
-rw-r--r--Minecraft.World/AvoidPlayerGoal.cpp16
-rw-r--r--Minecraft.World/AwardStatPacket.cpp8
-rw-r--r--Minecraft.World/AwardStatPacket.h2
-rw-r--r--Minecraft.World/BaseAttributeMap.cpp6
-rw-r--r--Minecraft.World/BaseEntityTile.cpp2
-rw-r--r--Minecraft.World/BaseMobSpawner.cpp68
-rw-r--r--Minecraft.World/BasePressurePlateTile.cpp2
-rw-r--r--Minecraft.World/BaseRailTile.cpp20
-rw-r--r--Minecraft.World/BasicTree.cpp42
-rw-r--r--Minecraft.World/BasicTypeContainers.cpp2
-rw-r--r--Minecraft.World/Bat.cpp26
-rw-r--r--Minecraft.World/BeachBiome.cpp4
-rw-r--r--Minecraft.World/BeaconMenu.cpp4
-rw-r--r--Minecraft.World/BeaconTile.cpp4
-rw-r--r--Minecraft.World/BeaconTileEntity.cpp22
-rw-r--r--Minecraft.World/BedItem.cpp2
-rw-r--r--Minecraft.World/BedTile.cpp10
-rw-r--r--Minecraft.World/BegGoal.cpp6
-rw-r--r--Minecraft.World/BinaryHeap.cpp6
-rw-r--r--Minecraft.World/Biome.cpp60
-rw-r--r--Minecraft.World/BiomeCache.cpp26
-rw-r--r--Minecraft.World/BiomeDecorator.cpp14
-rw-r--r--Minecraft.World/BiomeOverrideLayer.cpp8
-rw-r--r--Minecraft.World/BiomeSource.cpp40
-rw-r--r--Minecraft.World/BirchFeature.cpp2
-rw-r--r--Minecraft.World/Blaze.cpp12
-rw-r--r--Minecraft.World/BlockRegionUpdatePacket.h2
-rw-r--r--Minecraft.World/BlockReplacements.cpp4
-rw-r--r--Minecraft.World/Boat.cpp115
-rw-r--r--Minecraft.World/BoatItem.cpp6
-rw-r--r--Minecraft.World/BonusChestFeature.cpp2
-rw-r--r--Minecraft.World/BottleItem.cpp10
-rw-r--r--Minecraft.World/BoundingBox.cpp2
-rw-r--r--Minecraft.World/BowItem.cpp8
-rw-r--r--Minecraft.World/BowlFoodItem.cpp2
-rw-r--r--Minecraft.World/BreakDoorGoal.cpp2
-rw-r--r--Minecraft.World/BreedGoal.cpp14
-rw-r--r--Minecraft.World/BrewingStandMenu.cpp6
-rw-r--r--Minecraft.World/BrewingStandTile.cpp20
-rw-r--r--Minecraft.World/BrewingStandTileEntity.cpp42
-rw-r--r--Minecraft.World/BucketItem.cpp24
-rw-r--r--Minecraft.World/BufferedOutputStream.cpp2
-rw-r--r--Minecraft.World/Bush.cpp2
-rw-r--r--Minecraft.World/ButtonTile.cpp4
-rw-r--r--Minecraft.World/ByteArrayInputStream.cpp2
-rw-r--r--Minecraft.World/ByteArrayOutputStream.cpp4
-rw-r--r--Minecraft.World/ByteArrayTag.h4
-rw-r--r--Minecraft.World/ByteTag.h2
-rw-r--r--Minecraft.World/C4JThread.cpp80
-rw-r--r--Minecraft.World/CactusTile.cpp4
-rw-r--r--Minecraft.World/CakeTile.cpp6
-rw-r--r--Minecraft.World/CanyonFeature.cpp6
-rw-r--r--Minecraft.World/CarrotOnAStickItem.cpp2
-rw-r--r--Minecraft.World/CauldronTile.cpp16
-rw-r--r--Minecraft.World/CaveFeature.cpp8
-rw-r--r--Minecraft.World/ChatPacket.cpp8
-rw-r--r--Minecraft.World/ChatPacket.h2
-rw-r--r--Minecraft.World/ChestTile.cpp32
-rw-r--r--Minecraft.World/ChestTileEntity.cpp46
-rw-r--r--Minecraft.World/Chicken.cpp2
-rw-r--r--Minecraft.World/ChunkPos.cpp4
-rw-r--r--Minecraft.World/ChunkSource.h2
-rw-r--r--Minecraft.World/ChunkStorageProfileDecorator.cpp4
-rw-r--r--Minecraft.World/ChunkTilesUpdatePacket.cpp4
-rw-r--r--Minecraft.World/ChunkTilesUpdatePacket.h2
-rw-r--r--Minecraft.World/ChunkVisibilityAreaPacket.h2
-rw-r--r--Minecraft.World/ChunkVisibilityPacket.h2
-rw-r--r--Minecraft.World/ClientCommandPacket.h2
-rw-r--r--Minecraft.World/ClientSideMerchant.cpp4
-rw-r--r--Minecraft.World/ClockItem.cpp4
-rw-r--r--Minecraft.World/CocoaTile.cpp2
-rw-r--r--Minecraft.World/Color.cpp42
-rw-r--r--Minecraft.World/ColoredTileItem.cpp6
-rw-r--r--Minecraft.World/CombatEntry.cpp6
-rw-r--r--Minecraft.World/CombatTracker.cpp48
-rw-r--r--Minecraft.World/Command.cpp4
-rw-r--r--Minecraft.World/CommandBlock.cpp8
-rw-r--r--Minecraft.World/CommandBlockEntity.cpp6
-rw-r--r--Minecraft.World/CommonStats.cpp24
-rw-r--r--Minecraft.World/ComparatorTile.cpp4
-rw-r--r--Minecraft.World/ComparatorTileEntity.cpp2
-rw-r--r--Minecraft.World/CompassItem.cpp4
-rw-r--r--Minecraft.World/ComplexItemDataPacket.h2
-rw-r--r--Minecraft.World/CompoundContainer.cpp4
-rw-r--r--Minecraft.World/CompoundTag.h28
-rw-r--r--Minecraft.World/CompressedTileStorage.cpp48
-rw-r--r--Minecraft.World/Connection.cpp60
-rw-r--r--Minecraft.World/ConsoleSaveFile.h4
-rw-r--r--Minecraft.World/ConsoleSaveFileConverter.cpp2
-rw-r--r--Minecraft.World/ConsoleSaveFileInputStream.cpp8
-rw-r--r--Minecraft.World/ConsoleSaveFileOriginal.cpp116
-rw-r--r--Minecraft.World/ConsoleSaveFileOriginal.h4
-rw-r--r--Minecraft.World/ConsoleSaveFileOutputStream.cpp10
-rw-r--r--Minecraft.World/ContainerAckPacket.h2
-rw-r--r--Minecraft.World/ContainerButtonClickPacket.h2
-rw-r--r--Minecraft.World/ContainerClickPacket.h2
-rw-r--r--Minecraft.World/ContainerClosePacket.h2
-rw-r--r--Minecraft.World/ContainerMenu.cpp6
-rw-r--r--Minecraft.World/ContainerOpenPacket.h2
-rw-r--r--Minecraft.World/ContainerSetContentPacket.cpp4
-rw-r--r--Minecraft.World/ContainerSetContentPacket.h2
-rw-r--r--Minecraft.World/ContainerSetDataPacket.h2
-rw-r--r--Minecraft.World/ContainerSetSlotPacket.cpp2
-rw-r--r--Minecraft.World/ContainerSetSlotPacket.h2
-rw-r--r--Minecraft.World/ControlledByPlayerGoal.cpp12
-rw-r--r--Minecraft.World/Cow.cpp10
-rw-r--r--Minecraft.World/CraftItemPacket.h2
-rw-r--r--Minecraft.World/CraftingContainer.cpp4
-rw-r--r--Minecraft.World/CraftingMenu.cpp8
-rw-r--r--Minecraft.World/Creeper.cpp24
-rw-r--r--Minecraft.World/CropTile.cpp6
-rw-r--r--Minecraft.World/CustomLevelSource.cpp58
-rw-r--r--Minecraft.World/CustomPayloadPacket.cpp8
-rw-r--r--Minecraft.World/CustomPayloadPacket.h2
-rw-r--r--Minecraft.World/DamageEnchantment.cpp2
-rw-r--r--Minecraft.World/DamageSource.cpp10
-rw-r--r--Minecraft.World/DataInputStream.cpp18
-rw-r--r--Minecraft.World/DataLayer.cpp8
-rw-r--r--Minecraft.World/DataOutputStream.cpp22
-rw-r--r--Minecraft.World/DaylightDetectorTile.cpp4
-rw-r--r--Minecraft.World/DaylightDetectorTileEntity.cpp8
-rw-r--r--Minecraft.World/DeadBushTile.cpp4
-rw-r--r--Minecraft.World/DebugOptionsPacket.cpp4
-rw-r--r--Minecraft.World/DebugOptionsPacket.h2
-rw-r--r--Minecraft.World/DefaultDispenseItemBehavior.cpp2
-rw-r--r--Minecraft.World/DefendVillageTargetGoal.cpp2
-rw-r--r--Minecraft.World/DesertBiome.cpp4
-rw-r--r--Minecraft.World/DetectorRailTile.cpp2
-rw-r--r--Minecraft.World/Dimension.cpp16
-rw-r--r--Minecraft.World/DiodeTile.cpp2
-rw-r--r--Minecraft.World/Direction.cpp2
-rw-r--r--Minecraft.World/DirectoryLevelStorage.cpp96
-rw-r--r--Minecraft.World/DirectoryLevelStorageSource.cpp6
-rw-r--r--Minecraft.World/DisconnectPacket.cpp2
-rw-r--r--Minecraft.World/DisconnectPacket.h2
-rw-r--r--Minecraft.World/DispenserTile.cpp26
-rw-r--r--Minecraft.World/DispenserTileEntity.cpp26
-rw-r--r--Minecraft.World/DoorInfo.cpp2
-rw-r--r--Minecraft.World/DoorInteractGoal.cpp20
-rw-r--r--Minecraft.World/DoubleTag.h2
-rw-r--r--Minecraft.World/DragonFireball.cpp2
-rw-r--r--Minecraft.World/DropperTile.cpp10
-rw-r--r--Minecraft.World/DropperTileEntity.cpp2
-rw-r--r--Minecraft.World/DungeonFeature.cpp6
-rw-r--r--Minecraft.World/DurangoStats.cpp32
-rw-r--r--Minecraft.World/DurangoStats.h2
-rw-r--r--Minecraft.World/DyePowderItem.cpp18
-rw-r--r--Minecraft.World/EggItem.cpp2
-rw-r--r--Minecraft.World/EggTile.cpp2
-rw-r--r--Minecraft.World/EmptyMapItem.cpp2
-rw-r--r--Minecraft.World/EnchantItemCommand.cpp14
-rw-r--r--Minecraft.World/EnchantedBookItem.cpp20
-rw-r--r--Minecraft.World/Enchantment.cpp48
-rw-r--r--Minecraft.World/EnchantmentCategory.cpp10
-rw-r--r--Minecraft.World/EnchantmentHelper.cpp36
-rw-r--r--Minecraft.World/EnchantmentInstance.cpp2
-rw-r--r--Minecraft.World/EnchantmentMenu.cpp25
-rw-r--r--Minecraft.World/EnchantmentTableEntity.cpp6
-rw-r--r--Minecraft.World/EnchantmentTableTile.cpp6
-rw-r--r--Minecraft.World/EnderChestTile.cpp4
-rw-r--r--Minecraft.World/EnderChestTileEntity.cpp2
-rw-r--r--Minecraft.World/EnderCrystal.cpp2
-rw-r--r--Minecraft.World/EnderDragon.cpp134
-rw-r--r--Minecraft.World/EnderDragon.h2
-rw-r--r--Minecraft.World/EnderEyeItem.cpp14
-rw-r--r--Minecraft.World/EnderMan.cpp32
-rw-r--r--Minecraft.World/EnderpearlItem.cpp4
-rw-r--r--Minecraft.World/Enemy.cpp2
-rw-r--r--Minecraft.World/Entity.cpp74
-rw-r--r--Minecraft.World/EntityActionAtPositionPacket.h2
-rw-r--r--Minecraft.World/EntityDamageSource.cpp10
-rw-r--r--Minecraft.World/EntityEventPacket.h2
-rw-r--r--Minecraft.World/EntityHorse.cpp88
-rw-r--r--Minecraft.World/EntityIO.cpp20
-rw-r--r--Minecraft.World/EntityPos.cpp2
-rw-r--r--Minecraft.World/EntitySelector.cpp4
-rw-r--r--Minecraft.World/ExperienceItem.cpp2
-rw-r--r--Minecraft.World/ExperienceOrb.cpp20
-rw-r--r--Minecraft.World/ExplodePacket.cpp28
-rw-r--r--Minecraft.World/ExplodePacket.h2
-rw-r--r--Minecraft.World/Explosion.cpp14
-rw-r--r--Minecraft.World/Explosion.h2
-rw-r--r--Minecraft.World/EyeOfEnderSignal.cpp20
-rw-r--r--Minecraft.World/FallingTile.cpp18
-rw-r--r--Minecraft.World/FarmTile.cpp4
-rw-r--r--Minecraft.World/FastNoise.cpp14
-rw-r--r--Minecraft.World/FenceGateTile.cpp4
-rw-r--r--Minecraft.World/FenceTile.cpp2
-rw-r--r--Minecraft.World/File.cpp40
-rw-r--r--Minecraft.World/FileHeader.cpp52
-rw-r--r--Minecraft.World/FileInputStream.cpp14
-rw-r--r--Minecraft.World/FileOutputStream.cpp16
-rw-r--r--Minecraft.World/FireChargeItem.cpp2
-rw-r--r--Minecraft.World/FireTile.cpp4
-rw-r--r--Minecraft.World/Fireball.cpp30
-rw-r--r--Minecraft.World/FireworksChargeItem.cpp10
-rw-r--r--Minecraft.World/FireworksItem.cpp8
-rw-r--r--Minecraft.World/FireworksMenu.cpp10
-rw-r--r--Minecraft.World/FireworksRecipe.cpp42
-rw-r--r--Minecraft.World/FireworksRocketEntity.cpp24
-rw-r--r--Minecraft.World/FishingHook.cpp50
-rw-r--r--Minecraft.World/FishingRodItem.cpp6
-rw-r--r--Minecraft.World/FixedBiomeSource.cpp16
-rw-r--r--Minecraft.World/FlatGeneratorInfo.cpp12
-rw-r--r--Minecraft.World/FlatLevelSource.cpp10
-rw-r--r--Minecraft.World/FleeSunGoal.cpp6
-rw-r--r--Minecraft.World/FlippedIcon.cpp4
-rw-r--r--Minecraft.World/FloatTag.h2
-rw-r--r--Minecraft.World/FlowerFeature.cpp2
-rw-r--r--Minecraft.World/FlowerPotTile.cpp30
-rw-r--r--Minecraft.World/FlyingMob.cpp2
-rw-r--r--Minecraft.World/FollowOwnerGoal.cpp4
-rw-r--r--Minecraft.World/FollowParentGoal.cpp4
-rw-r--r--Minecraft.World/FoodConstants.cpp4
-rw-r--r--Minecraft.World/FoodItem.h2
-rw-r--r--Minecraft.World/FurnaceMenu.cpp4
-rw-r--r--Minecraft.World/FurnaceRecipes.cpp4
-rw-r--r--Minecraft.World/FurnaceResultSlot.cpp6
-rw-r--r--Minecraft.World/FurnaceTile.cpp26
-rw-r--r--Minecraft.World/FurnaceTileEntity.cpp42
-rw-r--r--Minecraft.World/FuzzyZoomLayer.cpp2
-rw-r--r--Minecraft.World/GameCommandPacket.cpp10
-rw-r--r--Minecraft.World/GameCommandPacket.h2
-rw-r--r--Minecraft.World/GameEventPacket.h2
-rw-r--r--Minecraft.World/GameModeCommand.cpp2
-rw-r--r--Minecraft.World/GenericStats.cpp142
-rw-r--r--Minecraft.World/GetInfoPacket.h2
-rw-r--r--Minecraft.World/Ghast.cpp24
-rw-r--r--Minecraft.World/GiveItemCommand.cpp8
-rw-r--r--Minecraft.World/GrassTile.cpp6
-rw-r--r--Minecraft.World/HangingEntity.cpp22
-rw-r--r--Minecraft.World/HangingEntityItem.cpp6
-rw-r--r--Minecraft.World/HatchetItem.cpp4
-rw-r--r--Minecraft.World/HeavyTile.cpp2
-rw-r--r--Minecraft.World/HellDimension.cpp10
-rw-r--r--Minecraft.World/HellFlatLevelSource.cpp24
-rw-r--r--Minecraft.World/HellRandomLevelSource.cpp54
-rw-r--r--Minecraft.World/HopperMenu.cpp2
-rw-r--r--Minecraft.World/HopperTile.cpp20
-rw-r--r--Minecraft.World/HopperTileEntity.cpp68
-rw-r--r--Minecraft.World/HorseInventoryMenu.cpp2
-rw-r--r--Minecraft.World/HouseFeature.cpp2
-rw-r--r--Minecraft.World/HtmlString.cpp2
-rw-r--r--Minecraft.World/HugeMushroomTile.cpp6
-rw-r--r--Minecraft.World/HurtByTargetGoal.cpp2
-rw-r--r--Minecraft.World/IceTile.cpp2
-rw-r--r--Minecraft.World/ImprovedNoise.cpp16
-rw-r--r--Minecraft.World/IndirectEntityDamageSource.cpp10
-rw-r--r--Minecraft.World/InputStream.cpp2
-rw-r--r--Minecraft.World/InputStreamReader.cpp2
-rw-r--r--Minecraft.World/IntArrayTag.h4
-rw-r--r--Minecraft.World/IntCache.cpp26
-rw-r--r--Minecraft.World/IntTag.h2
-rw-r--r--Minecraft.World/InteractPacket.h2
-rw-r--r--Minecraft.World/Inventory.cpp100
-rw-r--r--Minecraft.World/InventoryMenu.cpp10
-rw-r--r--Minecraft.World/Item.cpp470
-rw-r--r--Minecraft.World/ItemDispenseBehaviors.cpp26
-rw-r--r--Minecraft.World/ItemEntity.cpp28
-rw-r--r--Minecraft.World/ItemFrame.cpp26
-rw-r--r--Minecraft.World/ItemInstance.cpp114
-rw-r--r--Minecraft.World/JavaIntHash.h4
-rw-r--r--Minecraft.World/JavaMath.cpp2
-rw-r--r--Minecraft.World/JukeboxTile.cpp18
-rw-r--r--Minecraft.World/KeepAlivePacket.h2
-rw-r--r--Minecraft.World/KickPlayerPacket.h2
-rw-r--r--Minecraft.World/LakeFeature.cpp4
-rw-r--r--Minecraft.World/LargeCaveFeature.cpp4
-rw-r--r--Minecraft.World/LargeFireball.cpp2
-rw-r--r--Minecraft.World/LargeHellCaveFeature.cpp2
-rw-r--r--Minecraft.World/LavaSlime.cpp2
-rw-r--r--Minecraft.World/Layer.cpp54
-rw-r--r--Minecraft.World/LeafTile.cpp14
-rw-r--r--Minecraft.World/LeapAtTargetGoal.cpp4
-rw-r--r--Minecraft.World/LeashFenceKnotEntity.cpp12
-rw-r--r--Minecraft.World/LeashItem.cpp8
-rw-r--r--Minecraft.World/Level.cpp235
-rw-r--r--Minecraft.World/Level.h2
-rw-r--r--Minecraft.World/LevelChunk.cpp146
-rw-r--r--Minecraft.World/LevelData.cpp13
-rw-r--r--Minecraft.World/LevelEventPacket.h2
-rw-r--r--Minecraft.World/LevelParticlesPacket.h2
-rw-r--r--Minecraft.World/LevelSettings.cpp8
-rw-r--r--Minecraft.World/LevelSoundPacket.cpp6
-rw-r--r--Minecraft.World/LevelSoundPacket.h2
-rw-r--r--Minecraft.World/LevelStorage.h2
-rw-r--r--Minecraft.World/LevelType.cpp14
-rw-r--r--Minecraft.World/LeverTile.cpp2
-rw-r--r--Minecraft.World/LightningBolt.cpp8
-rw-r--r--Minecraft.World/LiquidTile.cpp8
-rw-r--r--Minecraft.World/ListTag.h10
-rw-r--r--Minecraft.World/LivingEntity.cpp162
-rw-r--r--Minecraft.World/LivingEntity.h2
-rw-r--r--Minecraft.World/LoginPacket.cpp14
-rw-r--r--Minecraft.World/LoginPacket.h2
-rw-r--r--Minecraft.World/LongTag.h2
-rw-r--r--Minecraft.World/LookAtPlayerGoal.cpp6
-rw-r--r--Minecraft.World/LookAtTradingPlayerGoal.cpp2
-rw-r--r--Minecraft.World/LookControl.cpp4
-rw-r--r--Minecraft.World/MakeLoveGoal.cpp10
-rw-r--r--Minecraft.World/MapItem.cpp30
-rw-r--r--Minecraft.World/MapItemSavedData.cpp86
-rw-r--r--Minecraft.World/Material.cpp66
-rw-r--r--Minecraft.World/MaterialColor.cpp28
-rw-r--r--Minecraft.World/McRegionChunkStorage.cpp24
-rw-r--r--Minecraft.World/McRegionLevelStorage.cpp8
-rw-r--r--Minecraft.World/McRegionLevelStorageSource.cpp12
-rw-r--r--Minecraft.World/MegaTreeFeature.cpp10
-rw-r--r--Minecraft.World/MeleeAttackGoal.cpp16
-rw-r--r--Minecraft.World/MelonTile.cpp2
-rw-r--r--Minecraft.World/MemoryChunkStorage.cpp2
-rw-r--r--Minecraft.World/MemoryLevelStorage.cpp4
-rw-r--r--Minecraft.World/MemoryLevelStorageSource.cpp2
-rw-r--r--Minecraft.World/MenuBackup.cpp2
-rw-r--r--Minecraft.World/MerchantContainer.cpp22
-rw-r--r--Minecraft.World/MerchantMenu.cpp8
-rw-r--r--Minecraft.World/MerchantRecipe.cpp12
-rw-r--r--Minecraft.World/MerchantRecipeList.cpp39
-rw-r--r--Minecraft.World/MerchantResultSlot.cpp8
-rw-r--r--Minecraft.World/MilkBucketItem.cpp2
-rw-r--r--Minecraft.World/MilkBucketItem.h2
-rw-r--r--Minecraft.World/MineShaftFeature.cpp2
-rw-r--r--Minecraft.World/MineShaftPieces.cpp38
-rw-r--r--Minecraft.World/Minecart.cpp86
-rw-r--r--Minecraft.World/MinecartContainer.cpp32
-rw-r--r--Minecraft.World/MinecartFurnace.cpp12
-rw-r--r--Minecraft.World/MinecartItem.cpp2
-rw-r--r--Minecraft.World/MinecartRideable.cpp4
-rw-r--r--Minecraft.World/MinecartSpawner.cpp2
-rw-r--r--Minecraft.World/MinecartTNT.cpp4
-rw-r--r--Minecraft.World/Mob.cpp100
-rw-r--r--Minecraft.World/Mob.h2
-rw-r--r--Minecraft.World/MobCategory.cpp14
-rw-r--r--Minecraft.World/MobEffect.cpp28
-rw-r--r--Minecraft.World/MobEffectInstance.cpp4
-rw-r--r--Minecraft.World/MobSpawner.cpp16
-rw-r--r--Minecraft.World/MobSpawnerTile.cpp2
-rw-r--r--Minecraft.World/MobSpawnerTileEntity.cpp6
-rw-r--r--Minecraft.World/MockedLevelStorage.cpp6
-rw-r--r--Minecraft.World/MockedLevelStorage.h2
-rw-r--r--Minecraft.World/ModifiableAttributeInstance.cpp6
-rw-r--r--Minecraft.World/Monster.cpp4
-rw-r--r--Minecraft.World/Monster.h2
-rw-r--r--Minecraft.World/MonsterRoomFeature.cpp4
-rw-r--r--Minecraft.World/MoveControl.cpp4
-rw-r--r--Minecraft.World/MoveEntityPacket.cpp4
-rw-r--r--Minecraft.World/MoveEntityPacket.h8
-rw-r--r--Minecraft.World/MoveEntityPacketSmall.cpp6
-rw-r--r--Minecraft.World/MoveEntityPacketSmall.h8
-rw-r--r--Minecraft.World/MoveIndoorsGoal.cpp10
-rw-r--r--Minecraft.World/MovePlayerPacket.h8
-rw-r--r--Minecraft.World/MoveThroughVillageGoal.cpp20
-rw-r--r--Minecraft.World/MoveTowardsRestrictionGoal.cpp2
-rw-r--r--Minecraft.World/MoveTowardsTargetGoal.cpp6
-rw-r--r--Minecraft.World/Mth.cpp24
-rw-r--r--Minecraft.World/Mushroom.cpp8
-rw-r--r--Minecraft.World/MushroomCow.cpp14
-rw-r--r--Minecraft.World/MushroomIslandBiome.cpp2
-rw-r--r--Minecraft.World/MusicTileEntity.cpp4
-rw-r--r--Minecraft.World/MycelTile.cpp4
-rw-r--r--Minecraft.World/NameTagItem.cpp2
-rw-r--r--Minecraft.World/NbtIo.cpp6
-rw-r--r--Minecraft.World/NbtSlotFile.cpp40
-rw-r--r--Minecraft.World/NearestAttackableTargetGoal.cpp6
-rw-r--r--Minecraft.World/NearestAttackableTargetGoal.h2
-rw-r--r--Minecraft.World/NetherBridgeFeature.cpp8
-rw-r--r--Minecraft.World/NetherBridgePieces.cpp172
-rw-r--r--Minecraft.World/NetherWartTile.cpp2
-rw-r--r--Minecraft.World/Node.cpp10
-rw-r--r--Minecraft.World/NotGateTile.cpp2
-rw-r--r--Minecraft.World/NoteBlockTile.cpp10
-rw-r--r--Minecraft.World/Ocelot.cpp16
-rw-r--r--Minecraft.World/OcelotAttackGoal.cpp4
-rw-r--r--Minecraft.World/OcelotSitOnTileGoal.cpp10
-rw-r--r--Minecraft.World/OfferFlowerGoal.cpp4
-rw-r--r--Minecraft.World/OldChunkStorage.cpp36
-rw-r--r--Minecraft.World/OreFeature.cpp6
-rw-r--r--Minecraft.World/OwnerHurtByTargetGoal.cpp4
-rw-r--r--Minecraft.World/OwnerHurtTargetGoal.cpp4
-rw-r--r--Minecraft.World/Packet.cpp18
-rw-r--r--Minecraft.World/Painting.cpp10
-rw-r--r--Minecraft.World/Path.cpp16
-rw-r--r--Minecraft.World/PathFinder.cpp36
-rw-r--r--Minecraft.World/PathNavigation.cpp52
-rw-r--r--Minecraft.World/PathfinderMob.cpp42
-rw-r--r--Minecraft.World/PerformanceTimer.cpp4
-rw-r--r--Minecraft.World/PerlinNoise.cpp2
-rw-r--r--Minecraft.World/PerlinSimplexNoise.cpp4
-rw-r--r--Minecraft.World/PickaxeItem.cpp2
-rw-r--r--Minecraft.World/Pig.cpp18
-rw-r--r--Minecraft.World/PigZombie.cpp8
-rw-r--r--Minecraft.World/PineFeature.cpp2
-rw-r--r--Minecraft.World/PistonBaseTile.cpp20
-rw-r--r--Minecraft.World/PistonExtensionTile.cpp6
-rw-r--r--Minecraft.World/PistonMovingPiece.cpp30
-rw-r--r--Minecraft.World/PistonPieceEntity.cpp6
-rw-r--r--Minecraft.World/PlayGoal.cpp12
-rw-r--r--Minecraft.World/Player.cpp182
-rw-r--r--Minecraft.World/PlayerAbilitiesPacket.h2
-rw-r--r--Minecraft.World/PlayerActionPacket.h2
-rw-r--r--Minecraft.World/PlayerCommandPacket.h2
-rw-r--r--Minecraft.World/PlayerEnderChestContainer.cpp8
-rw-r--r--Minecraft.World/PlayerInfoPacket.cpp2
-rw-r--r--Minecraft.World/PlayerInfoPacket.h2
-rw-r--r--Minecraft.World/PlayerInputPacket.h2
-rw-r--r--Minecraft.World/PlayerTeam.cpp2
-rw-r--r--Minecraft.World/PortalForcer.cpp2
-rw-r--r--Minecraft.World/PortalTile.cpp6
-rw-r--r--Minecraft.World/Pos.cpp6
-rw-r--r--Minecraft.World/PotatoTile.cpp2
-rw-r--r--Minecraft.World/PotionBrewing.cpp50
-rw-r--r--Minecraft.World/PotionItem.cpp40
-rw-r--r--Minecraft.World/PotionItem.h2
-rw-r--r--Minecraft.World/PreLoginPacket.cpp10
-rw-r--r--Minecraft.World/PreLoginPacket.h2
-rw-r--r--Minecraft.World/PressurePlateTile.cpp4
-rw-r--r--Minecraft.World/PrimedTnt.cpp4
-rw-r--r--Minecraft.World/ProtectionEnchantment.cpp2
-rw-r--r--Minecraft.World/PumpkinTile.cpp8
-rw-r--r--Minecraft.World/QuartzBlockTile.cpp2
-rw-r--r--Minecraft.World/Random.cpp14
-rw-r--r--Minecraft.World/RandomLevelSource.cpp56
-rw-r--r--Minecraft.World/RandomPos.cpp6
-rw-r--r--Minecraft.World/RandomScatteredLargeFeature.cpp8
-rw-r--r--Minecraft.World/RandomStrollGoal.cpp4
-rw-r--r--Minecraft.World/RangedAttackGoal.cpp4
-rw-r--r--Minecraft.World/ReadOnlyChunkCache.cpp8
-rw-r--r--Minecraft.World/Recipes.cpp42
-rw-r--r--Minecraft.World/Recipes.h2
-rw-r--r--Minecraft.World/RecordingItem.cpp4
-rw-r--r--Minecraft.World/RedStoneDustTile.cpp12
-rw-r--r--Minecraft.World/RedStoneOreTile.cpp2
-rw-r--r--Minecraft.World/ReedTile.cpp2
-rw-r--r--Minecraft.World/ReedsFeature.cpp2
-rw-r--r--Minecraft.World/Region.cpp28
-rw-r--r--Minecraft.World/RegionFile.cpp43
-rw-r--r--Minecraft.World/RegionFileCache.cpp6
-rw-r--r--Minecraft.World/RemoveEntitiesPacket.h2
-rw-r--r--Minecraft.World/RemoveMobEffectPacket.cpp2
-rw-r--r--Minecraft.World/RemoveMobEffectPacket.h2
-rw-r--r--Minecraft.World/RepairResultSlot.cpp2
-rw-r--r--Minecraft.World/RespawnPacket.cpp12
-rw-r--r--Minecraft.World/RespawnPacket.h2
-rw-r--r--Minecraft.World/RestrictOpenDoorGoal.cpp6
-rw-r--r--Minecraft.World/ResultContainer.cpp4
-rw-r--r--Minecraft.World/ResultSlot.cpp6
-rw-r--r--Minecraft.World/RotateHeadPacket.h2
-rw-r--r--Minecraft.World/RotatedPillarTile.cpp2
-rw-r--r--Minecraft.World/RunAroundLikeCrazyGoal.cpp6
-rw-r--r--Minecraft.World/SaddleItem.cpp2
-rw-r--r--Minecraft.World/SandFeature.cpp2
-rw-r--r--Minecraft.World/SandStoneTile.cpp6
-rw-r--r--Minecraft.World/Sapling.cpp10
-rw-r--r--Minecraft.World/SavedDataStorage.cpp20
-rw-r--r--Minecraft.World/ScatteredFeaturePieces.cpp6
-rw-r--r--Minecraft.World/Scoreboard.cpp44
-rw-r--r--Minecraft.World/ServerSettingsChangedPacket.h2
-rw-r--r--Minecraft.World/ServersideAttributeMap.cpp10
-rw-r--r--Minecraft.World/SetCarriedItemPacket.h2
-rw-r--r--Minecraft.World/SetCreativeModeSlotPacket.h2
-rw-r--r--Minecraft.World/SetDisplayObjectivePacket.cpp2
-rw-r--r--Minecraft.World/SetDisplayObjectivePacket.h2
-rw-r--r--Minecraft.World/SetEntityDataPacket.cpp2
-rw-r--r--Minecraft.World/SetEntityDataPacket.h2
-rw-r--r--Minecraft.World/SetEntityLinkPacket.cpp2
-rw-r--r--Minecraft.World/SetEntityLinkPacket.h2
-rw-r--r--Minecraft.World/SetEntityMotionPacket.cpp12
-rw-r--r--Minecraft.World/SetEntityMotionPacket.h2
-rw-r--r--Minecraft.World/SetEquippedItemPacket.cpp2
-rw-r--r--Minecraft.World/SetEquippedItemPacket.h2
-rw-r--r--Minecraft.World/SetExperiencePacket.h2
-rw-r--r--Minecraft.World/SetHealthPacket.cpp2
-rw-r--r--Minecraft.World/SetHealthPacket.h2
-rw-r--r--Minecraft.World/SetObjectivePacket.h2
-rw-r--r--Minecraft.World/SetPlayerTeamPacket.cpp2
-rw-r--r--Minecraft.World/SetPlayerTeamPacket.h2
-rw-r--r--Minecraft.World/SetScorePacket.h2
-rw-r--r--Minecraft.World/SetSpawnPositionPacket.h2
-rw-r--r--Minecraft.World/SetTimePacket.h2
-rw-r--r--Minecraft.World/ShapedRecipy.cpp16
-rw-r--r--Minecraft.World/ShapelessRecipy.cpp2
-rw-r--r--Minecraft.World/SharedMonsterAttributes.cpp6
-rw-r--r--Minecraft.World/Sheep.cpp32
-rw-r--r--Minecraft.World/ShortTag.h2
-rw-r--r--Minecraft.World/ShovelItem.cpp2
-rw-r--r--Minecraft.World/SignItem.cpp2
-rw-r--r--Minecraft.World/SignTile.cpp4
-rw-r--r--Minecraft.World/SignTileEntity.cpp8
-rw-r--r--Minecraft.World/SignUpdatePacket.cpp2
-rw-r--r--Minecraft.World/SignUpdatePacket.h2
-rw-r--r--Minecraft.World/Silverfish.cpp8
-rw-r--r--Minecraft.World/SimpleContainer.cpp12
-rw-r--r--Minecraft.World/SimplexNoise.cpp2
-rw-r--r--Minecraft.World/SitGoal.cpp4
-rw-r--r--Minecraft.World/Skeleton.cpp34
-rw-r--r--Minecraft.World/SkullItem.cpp4
-rw-r--r--Minecraft.World/SkullTile.cpp20
-rw-r--r--Minecraft.World/SkullTileEntity.cpp8
-rw-r--r--Minecraft.World/SkyIslandDimension.cpp2
-rw-r--r--Minecraft.World/Slime.cpp12
-rw-r--r--Minecraft.World/Slot.cpp22
-rw-r--r--Minecraft.World/SmallFireball.cpp2
-rw-r--r--Minecraft.World/SmoothStoneBrickTile.cpp2
-rw-r--r--Minecraft.World/SmoothZoomLayer.cpp2
-rw-r--r--Minecraft.World/SnowMan.cpp2
-rw-r--r--Minecraft.World/Snowball.cpp2
-rw-r--r--Minecraft.World/SnowballItem.cpp2
-rw-r--r--Minecraft.World/Socket.cpp30
-rw-r--r--Minecraft.World/SparseDataStorage.cpp134
-rw-r--r--Minecraft.World/SparseLightStorage.cpp36
-rw-r--r--Minecraft.World/SpawnEggItem.cpp20
-rw-r--r--Minecraft.World/Spider.cpp18
-rw-r--r--Minecraft.World/SpikeFeature.cpp4
-rw-r--r--Minecraft.World/SpringFeature.cpp2
-rw-r--r--Minecraft.World/SpruceFeature.cpp2
-rw-r--r--Minecraft.World/Squid.cpp6
-rw-r--r--Minecraft.World/StairTile.cpp10
-rw-r--r--Minecraft.World/Stats.cpp64
-rw-r--r--Minecraft.World/StemTile.cpp14
-rw-r--r--Minecraft.World/StoneMonsterTile.cpp4
-rw-r--r--Minecraft.World/StoneSlabTile.cpp2
-rw-r--r--Minecraft.World/StringHelpers.cpp10
-rw-r--r--Minecraft.World/StringTag.h2
-rw-r--r--Minecraft.World/StrongholdFeature.cpp20
-rw-r--r--Minecraft.World/StrongholdPieces.cpp174
-rw-r--r--Minecraft.World/StructureFeature.cpp18
-rw-r--r--Minecraft.World/StructureFeatureIO.cpp8
-rw-r--r--Minecraft.World/StructurePiece.cpp22
-rw-r--r--Minecraft.World/StructureRecipies.cpp2
-rw-r--r--Minecraft.World/StructureStart.cpp4
-rw-r--r--Minecraft.World/SwampTreeFeature.cpp2
-rw-r--r--Minecraft.World/SwellGoal.cpp4
-rw-r--r--Minecraft.World/SynchedEntityData.cpp52
-rw-r--r--Minecraft.World/Tag.cpp4
-rw-r--r--Minecraft.World/TakeFlowerGoal.cpp4
-rw-r--r--Minecraft.World/TakeItemEntityPacket.h2
-rw-r--r--Minecraft.World/TallGrass.cpp4
-rw-r--r--Minecraft.World/TamableAnimal.cpp16
-rw-r--r--Minecraft.World/TargetGoal.cpp14
-rw-r--r--Minecraft.World/Team.cpp2
-rw-r--r--Minecraft.World/TeleportEntityPacket.cpp4
-rw-r--r--Minecraft.World/TeleportEntityPacket.h2
-rw-r--r--Minecraft.World/TemptGoal.cpp6
-rw-r--r--Minecraft.World/TextureAndGeometryChangePacket.cpp2
-rw-r--r--Minecraft.World/TextureAndGeometryChangePacket.h2
-rw-r--r--Minecraft.World/TextureAndGeometryPacket.cpp32
-rw-r--r--Minecraft.World/TextureChangePacket.cpp4
-rw-r--r--Minecraft.World/TextureChangePacket.h2
-rw-r--r--Minecraft.World/TexturePacket.cpp8
-rw-r--r--Minecraft.World/TheEndBiome.cpp4
-rw-r--r--Minecraft.World/TheEndBiomeDecorator.cpp2
-rw-r--r--Minecraft.World/TheEndDimension.cpp2
-rw-r--r--Minecraft.World/TheEndLevelRandomLevelSource.cpp20
-rw-r--r--Minecraft.World/TheEndPortal.cpp6
-rw-r--r--Minecraft.World/TheEndPortalFrameTile.cpp4
-rw-r--r--Minecraft.World/TheEndPortalTileEntity.cpp2
-rw-r--r--Minecraft.World/ThinFenceTile.cpp4
-rw-r--r--Minecraft.World/ThornsEnchantment.cpp4
-rw-r--r--Minecraft.World/Throwable.cpp46
-rw-r--r--Minecraft.World/ThrownEgg.cpp4
-rw-r--r--Minecraft.World/ThrownEnderpearl.cpp4
-rw-r--r--Minecraft.World/ThrownExpBottle.cpp4
-rw-r--r--Minecraft.World/ThrownPotion.cpp20
-rw-r--r--Minecraft.World/TickNextTickData.cpp2
-rw-r--r--Minecraft.World/Tile.cpp532
-rw-r--r--Minecraft.World/TileDestructionPacket.h2
-rw-r--r--Minecraft.World/TileEditorOpenPacket.h2
-rw-r--r--Minecraft.World/TileEntity.cpp16
-rw-r--r--Minecraft.World/TileEntityDataPacket.cpp4
-rw-r--r--Minecraft.World/TileEntityDataPacket.h2
-rw-r--r--Minecraft.World/TileEventPacket.h2
-rw-r--r--Minecraft.World/TileItem.cpp8
-rw-r--r--Minecraft.World/TileUpdatePacket.cpp2
-rw-r--r--Minecraft.World/TileUpdatePacket.h2
-rw-r--r--Minecraft.World/TimeCommand.cpp2
-rw-r--r--Minecraft.World/TntTile.cpp10
-rw-r--r--Minecraft.World/ToggleDownfallCommand.cpp2
-rw-r--r--Minecraft.World/ToolRecipies.cpp2
-rw-r--r--Minecraft.World/TopSnowTile.cpp4
-rw-r--r--Minecraft.World/TorchTile.cpp2
-rw-r--r--Minecraft.World/TradeItemPacket.h2
-rw-r--r--Minecraft.World/TradeWithPlayerGoal.cpp2
-rw-r--r--Minecraft.World/TrapDoorTile.cpp2
-rw-r--r--Minecraft.World/TrapMenu.cpp2
-rw-r--r--Minecraft.World/TreeFeature.cpp2
-rw-r--r--Minecraft.World/TreeTile.cpp2
-rw-r--r--Minecraft.World/TripWireSourceTile.cpp2
-rw-r--r--Minecraft.World/TripWireTile.cpp6
-rw-r--r--Minecraft.World/UpdateAttributesPacket.h2
-rw-r--r--Minecraft.World/UpdateGameRuleProgressPacket.cpp12
-rw-r--r--Minecraft.World/UpdateMobEffectPacket.cpp6
-rw-r--r--Minecraft.World/UpdateMobEffectPacket.h2
-rw-r--r--Minecraft.World/UpdateProgressPacket.h2
-rw-r--r--Minecraft.World/UseItemPacket.cpp6
-rw-r--r--Minecraft.World/UseItemPacket.h2
-rw-r--r--Minecraft.World/Vec3.cpp20
-rw-r--r--Minecraft.World/Village.cpp18
-rw-r--r--Minecraft.World/VillageFeature.cpp6
-rw-r--r--Minecraft.World/VillagePieces.cpp120
-rw-r--r--Minecraft.World/VillageSiege.cpp22
-rw-r--r--Minecraft.World/Villager.cpp56
-rw-r--r--Minecraft.World/VillagerGolem.cpp14
-rw-r--r--Minecraft.World/Villages.cpp16
-rw-r--r--Minecraft.World/VineTile.cpp8
-rw-r--r--Minecraft.World/WallTile.cpp2
-rw-r--r--Minecraft.World/WaterLevelChunk.cpp2
-rw-r--r--Minecraft.World/WaterLilyTile.cpp4
-rw-r--r--Minecraft.World/WaterLilyTileItem.cpp4
-rw-r--r--Minecraft.World/WebTile.cpp2
-rw-r--r--Minecraft.World/WeighedRandom.cpp4
-rw-r--r--Minecraft.World/WeighedTreasure.cpp6
-rw-r--r--Minecraft.World/WeightedPressurePlateTile.cpp2
-rw-r--r--Minecraft.World/Witch.cpp16
-rw-r--r--Minecraft.World/WitherBoss.cpp26
-rw-r--r--Minecraft.World/WitherSkull.cpp8
-rw-r--r--Minecraft.World/Wolf.cpp48
-rw-r--r--Minecraft.World/WoodSlabTile.cpp2
-rw-r--r--Minecraft.World/WoodTile.cpp2
-rw-r--r--Minecraft.World/WoolCarpetTile.cpp2
-rw-r--r--Minecraft.World/WorkbenchTile.cpp4
-rw-r--r--Minecraft.World/XZPacket.h2
-rw-r--r--Minecraft.World/Zombie.cpp68
-rw-r--r--Minecraft.World/ZoneFile.cpp2
-rw-r--r--Minecraft.World/ZoneIo.cpp8
-rw-r--r--Minecraft.World/ZonedChunkStorage.cpp10
-rw-r--r--Minecraft.World/ZoomLayer.cpp2
-rw-r--r--Minecraft.World/compression.cpp104
-rw-r--r--Minecraft.World/system.cpp2
-rw-r--r--Minecraft.World/x64headers/extraX64.h10
654 files changed, 5242 insertions, 5184 deletions
diff --git a/Minecraft.World/AABB.cpp b/Minecraft.World/AABB.cpp
index f8e13497..af0501b4 100644
--- a/Minecraft.World/AABB.cpp
+++ b/Minecraft.World/AABB.cpp
@@ -8,7 +8,7 @@
#include "HitResult.h"
DWORD AABB::tlsIdx = 0;
-AABB::ThreadStorage *AABB::tlsDefault = NULL;
+AABB::ThreadStorage *AABB::tlsDefault = nullptr;
AABB::ThreadStorage::ThreadStorage()
{
@@ -25,7 +25,7 @@ AABB::ThreadStorage::~ThreadStorage()
void AABB::CreateNewThreadStorage()
{
ThreadStorage *tls = new ThreadStorage();
- if(tlsDefault == NULL )
+ if(tlsDefault == nullptr )
{
tlsIdx = TlsAlloc();
tlsDefault = tls;
@@ -41,7 +41,7 @@ void AABB::UseDefaultThreadStorage()
void AABB::ReleaseThreadStorage()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
if( tls == tlsDefault ) return;
delete tls;
@@ -62,7 +62,7 @@ void AABB::resetPool()
AABB *AABB::newTemp(double x0, double y0, double z0, double x1, double y1, double z1)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
AABB *thisAABB = &tls->pool[tls->poolPointer];
thisAABB->set(x0, y0, z0, x1, y1, z1);
tls->poolPointer = ( tls->poolPointer + 1 ) % ThreadStorage::POOL_SIZE;
@@ -286,23 +286,23 @@ HitResult *AABB::clip(Vec3 *a, Vec3 *b)
Vec3 *zh0 = a->clipZ(b, z0);
Vec3 *zh1 = a->clipZ(b, z1);
- if (!containsX(xh0)) xh0 = NULL;
- if (!containsX(xh1)) xh1 = NULL;
- if (!containsY(yh0)) yh0 = NULL;
- if (!containsY(yh1)) yh1 = NULL;
- if (!containsZ(zh0)) zh0 = NULL;
- if (!containsZ(zh1)) zh1 = NULL;
+ if (!containsX(xh0)) xh0 = nullptr;
+ if (!containsX(xh1)) xh1 = nullptr;
+ if (!containsY(yh0)) yh0 = nullptr;
+ if (!containsY(yh1)) yh1 = nullptr;
+ if (!containsZ(zh0)) zh0 = nullptr;
+ if (!containsZ(zh1)) zh1 = nullptr;
- Vec3 *closest = NULL;
+ Vec3 *closest = nullptr;
- if (xh0 != NULL && (closest == NULL || a->distanceToSqr(xh0) < a->distanceToSqr(closest))) closest = xh0;
- if (xh1 != NULL && (closest == NULL || a->distanceToSqr(xh1) < a->distanceToSqr(closest))) closest = xh1;
- if (yh0 != NULL && (closest == NULL || a->distanceToSqr(yh0) < a->distanceToSqr(closest))) closest = yh0;
- if (yh1 != NULL && (closest == NULL || a->distanceToSqr(yh1) < a->distanceToSqr(closest))) closest = yh1;
- if (zh0 != NULL && (closest == NULL || a->distanceToSqr(zh0) < a->distanceToSqr(closest))) closest = zh0;
- if (zh1 != NULL && (closest == NULL || a->distanceToSqr(zh1) < a->distanceToSqr(closest))) closest = zh1;
+ if (xh0 != nullptr && (closest == nullptr || a->distanceToSqr(xh0) < a->distanceToSqr(closest))) closest = xh0;
+ if (xh1 != nullptr && (closest == nullptr || a->distanceToSqr(xh1) < a->distanceToSqr(closest))) closest = xh1;
+ if (yh0 != nullptr && (closest == nullptr || a->distanceToSqr(yh0) < a->distanceToSqr(closest))) closest = yh0;
+ if (yh1 != nullptr && (closest == nullptr || a->distanceToSqr(yh1) < a->distanceToSqr(closest))) closest = yh1;
+ if (zh0 != nullptr && (closest == nullptr || a->distanceToSqr(zh0) < a->distanceToSqr(closest))) closest = zh0;
+ if (zh1 != nullptr && (closest == nullptr || a->distanceToSqr(zh1) < a->distanceToSqr(closest))) closest = zh1;
- if (closest == NULL) return NULL;
+ if (closest == nullptr) return nullptr;
int face = -1;
@@ -319,19 +319,19 @@ HitResult *AABB::clip(Vec3 *a, Vec3 *b)
bool AABB::containsX(Vec3 *v)
{
- if (v == NULL) return false;
+ if (v == nullptr) return false;
return v->y >= y0 && v->y <= y1 && v->z >= z0 && v->z <= z1;
}
bool AABB::containsY(Vec3 *v)
{
- if (v == NULL) return false;
+ if (v == nullptr) return false;
return v->x >= x0 && v->x <= x1 && v->z >= z0 && v->z <= z1;
}
bool AABB::containsZ(Vec3 *v)
{
- if (v == NULL) return false;
+ if (v == nullptr) return false;
return v->x >= x0 && v->x <= x1 && v->y >= y0 && v->y <= y1;
}
diff --git a/Minecraft.World/AbstractContainerMenu.cpp b/Minecraft.World/AbstractContainerMenu.cpp
index 57b0b177..10d8afdc 100644
--- a/Minecraft.World/AbstractContainerMenu.cpp
+++ b/Minecraft.World/AbstractContainerMenu.cpp
@@ -29,7 +29,7 @@ AbstractContainerMenu::~AbstractContainerMenu()
Slot *AbstractContainerMenu::addSlot(Slot *slot)
{
- slot->index = (int)slots.size();
+ slot->index = static_cast<int>(slots.size());
slots.push_back(slot);
lastSlots.push_back(nullptr);
return slot;
@@ -80,7 +80,7 @@ void AbstractContainerMenu::broadcastChanges()
{
// 4J Stu - Added 0 count check. There is a bug in the Java with anvils that means this broadcast
// happens while we are in the middle of quickmoving, and before the slot properly gets set to null
- expected = (current == NULL || current->count == 0) ? nullptr : current->copy();
+ expected = (current == nullptr || current->count == 0) ? nullptr : current->copy();
lastSlots[i] = expected;
m_bNeedsRendered = true;
@@ -103,7 +103,7 @@ bool AbstractContainerMenu::needsRendered()
shared_ptr<ItemInstance> expected = lastSlots.at(i);
if (!ItemInstance::matches(expected, current))
{
- expected = current == NULL ? nullptr : current->copy();
+ expected = current == nullptr ? nullptr : current->copy();
lastSlots[i] = expected;
needsRendered = true;
}
@@ -126,18 +126,26 @@ Slot *AbstractContainerMenu::getSlotFor(shared_ptr<Container> c, int index)
return slot;
}
}
- return NULL;
+ return nullptr;
}
Slot *AbstractContainerMenu::getSlot(int index)
{
+ if (index < 0 || index >= static_cast<int>(slots.size()))
+ {
+ return nullptr;
+ }
return slots.at(index);
}
shared_ptr<ItemInstance> AbstractContainerMenu::quickMoveStack(shared_ptr<Player> player, int slotIndex)
{
+ if (slotIndex < 0 || slotIndex >= static_cast<int>(slots.size()))
+ {
+ return nullptr;
+ }
Slot *slot = slots.at(slotIndex);
- if (slot != NULL)
+ if (slot != nullptr)
{
return slot->getItem();
}
@@ -158,7 +166,7 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
{
resetQuickCraft();
}
- else if (inventory->getCarried() == NULL)
+ else if (inventory->getCarried() == nullptr)
{
resetQuickCraft();
}
@@ -180,7 +188,7 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
{
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && canItemQuickReplace(slot, inventory->getCarried(), true) && slot->mayPlace(inventory->getCarried()) && inventory->getCarried()->count > quickcraftSlots.size() && canDragTo(slot))
+ if (slot != nullptr && canItemQuickReplace(slot, inventory->getCarried(), true) && slot->mayPlace(inventory->getCarried()) && inventory->getCarried()->count > quickcraftSlots.size() && canDragTo(slot))
{
quickcraftSlots.insert(slot);
}
@@ -231,7 +239,7 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
{
if (slotIndex == SLOT_CLICKED_OUTSIDE)
{
- if (inventory->getCarried() != NULL)
+ if (inventory->getCarried() != nullptr)
{
if (slotIndex == SLOT_CLICKED_OUTSIDE)
{
@@ -251,12 +259,12 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
}
else if (clickType == CLICK_QUICK_MOVE)
{
- if (slotIndex < 0) return nullptr;
+ if (slotIndex < 0 || slotIndex >= static_cast<int>(slots.size())) return nullptr;
Slot *slot = slots.at(slotIndex);
- if(slot != NULL && slot->mayPickup(player))
+ if(slot != nullptr && slot->mayPickup(player))
{
shared_ptr<ItemInstance> piiClicked = quickMoveStack(player, slotIndex);
- if (piiClicked != NULL)
+ if (piiClicked != nullptr)
{
int oldType = piiClicked->id;
@@ -269,14 +277,14 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
// 4J Stu - Remove the reference to this before we start a recursive loop
piiClicked = nullptr;
- if (slot != NULL)
+ if (slot != nullptr)
{
- if (slot->getItem() != NULL && slot->getItem()->id == oldType)
+ if (slot->getItem() != nullptr && slot->getItem()->id == oldType)
{
if(looped)
{
// Return a non-null value to indicate that we want to loop more
- clickedEntity = shared_ptr<ItemInstance>(new ItemInstance(0,1,0));
+ clickedEntity = std::make_shared<ItemInstance>(0, 1, 0);
}
else
{
@@ -293,19 +301,19 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
if (slotIndex < 0) return nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL)
+ if (slot != nullptr)
{
shared_ptr<ItemInstance> clicked = slot->getItem();
shared_ptr<ItemInstance> carried = inventory->getCarried();
- if (clicked != NULL)
+ if (clicked != nullptr)
{
clickedEntity = clicked->copy();
}
- if (clicked == NULL)
+ if (clicked == nullptr)
{
- if (carried != NULL && slot->mayPlace(carried))
+ if (carried != nullptr && slot->mayPlace(carried))
{
int c = buttonNum == 0 ? carried->count : 1;
if (c > slot->getMaxStackSize())
@@ -326,7 +334,7 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
else if (buttonNum == 1 && mayCombine(slot, carried))
{
shared_ptr<ItemInstance> combined = slot->combine(carried);
- if(combined != NULL)
+ if(combined != nullptr)
{
slot->set(combined);
if(!player->abilities.instabuild) carried->remove(1);
@@ -338,7 +346,7 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
}
else if (slot->mayPickup(player))
{
- if (carried == NULL)
+ if (carried == nullptr)
{
// pick up to empty hand
int c = buttonNum == 0 ? clicked->count : (clicked->count + 1) / 2;
@@ -408,11 +416,12 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
}
else if (clickType == CLICK_SWAP && buttonNum >= 0 && buttonNum < 9)
{
+ if (slotIndex < 0 || slotIndex >= static_cast<int>(slots.size())) return nullptr;
Slot *slot = slots.at(slotIndex);
if (slot->mayPickup(player))
{
shared_ptr<ItemInstance> current = inventory->getItem(buttonNum);
- bool canMove = current == NULL || (slot->container == inventory && slot->mayPlace(current));
+ bool canMove = current == nullptr || (slot->container == inventory && slot->mayPlace(current));
int freeSlot = -1;
if (!canMove)
@@ -426,7 +435,7 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
shared_ptr<ItemInstance> taking = slot->getItem();
inventory->setItem(buttonNum, taking);
- if ((slot->container == inventory && slot->mayPlace(current)) || current == NULL)
+ if ((slot->container == inventory && slot->mayPlace(current)) || current == nullptr)
{
slot->remove(taking->count);
slot->set(current);
@@ -440,47 +449,50 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
slot->onTake(player, taking);
}
}
- else if (!slot->hasItem() && current != NULL && slot->mayPlace(current))
+ else if (!slot->hasItem() && current != nullptr && slot->mayPlace(current))
{
inventory->setItem(buttonNum, nullptr);
slot->set(current);
}
}
}
- else if (clickType == CLICK_CLONE && player->abilities.instabuild && inventory->getCarried() == NULL && slotIndex >= 0)
+ else if (clickType == CLICK_CLONE && player->abilities.instabuild && inventory->getCarried() == nullptr && slotIndex >= 0)
{
+ if (slotIndex >= static_cast<int>(slots.size())) return nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> copy = slot->getItem()->copy();
copy->count = copy->getMaxStackSize();
inventory->setCarried(copy);
}
}
- else if (clickType == CLICK_THROW && inventory->getCarried() == NULL && slotIndex >= 0)
+ else if (clickType == CLICK_THROW && inventory->getCarried() == nullptr && slotIndex >= 0)
{
+ if (slotIndex >= static_cast<int>(slots.size())) return nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem() && slot->mayPickup(player))
+ if (slot != nullptr && slot->hasItem() && slot->mayPickup(player))
{
shared_ptr<ItemInstance> item = slot->remove(buttonNum == 0 ? 1 : slot->getItem()->count);
slot->onTake(player, item);
player->drop(item);
}
}
- else if (clickType == CLICK_PICKUP_ALL && slotIndex >= 0)
+ else if (clickType == CLICK_PICKUP_ALL && slotIndex >= 0)
{
+ if (slotIndex >= static_cast<int>(slots.size())) return nullptr;
Slot *slot = slots.at(slotIndex);
shared_ptr<ItemInstance> 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 start = buttonNum == 0 ? 0 : static_cast<int>(slots.size()) - 1;
int step = buttonNum == 0 ? 1 : -1;
for (int pass = 0; pass < 2; pass++ )
{
// In the first pass, we only get partial stacks.
- for (int i = start; i >= 0 && i < slots.size() && carried->count < carried->getMaxStackSize(); i += step)
+ for (size_t i = start; i >= 0 && i < static_cast<int>(slots.size()) && carried->count < carried->getMaxStackSize(); i += step)
{
Slot *target = slots.at(i);
@@ -514,7 +526,7 @@ bool AbstractContainerMenu::canTakeItemForPickAll(shared_ptr<ItemInstance> carri
// 4J Stu - Brought forward from 1.2 to fix infinite recursion bug in creative
void AbstractContainerMenu::loopClick(int slotIndex, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player)
{
- while( clicked(slotIndex, buttonNum, CLICK_QUICK_MOVE, player, true) != NULL)
+ while( clicked(slotIndex, buttonNum, CLICK_QUICK_MOVE, player, true) != nullptr)
{
}
}
@@ -527,7 +539,7 @@ bool AbstractContainerMenu::mayCombine(Slot *slot, shared_ptr<ItemInstance> item
void AbstractContainerMenu::removed(shared_ptr<Player> player)
{
shared_ptr<Inventory> inventory = player->inventory;
- if (inventory->getCarried() != NULL)
+ if (inventory->getCarried() != nullptr)
{
player->drop(inventory->getCarried());
inventory->setCarried(nullptr);
@@ -605,7 +617,7 @@ bool AbstractContainerMenu::moveItemStackTo(shared_ptr<ItemInstance> itemStack,
Slot *slot = slots.at(destSlot);
shared_ptr<ItemInstance> target = slot->getItem();
- if (target != NULL && target->id == itemStack->id && (!itemStack->isStackedByData() || itemStack->getAuxValue() == target->getAuxValue())
+ if (target != nullptr && target->id == itemStack->id && (!itemStack->isStackedByData() || itemStack->getAuxValue() == target->getAuxValue())
&& ItemInstance::tagMatches(itemStack, target) )
{
int totalStack = target->count + itemStack->count;
@@ -652,7 +664,7 @@ bool AbstractContainerMenu::moveItemStackTo(shared_ptr<ItemInstance> itemStack,
Slot *slot = slots.at(destSlot);
shared_ptr<ItemInstance> target = slot->getItem();
- if (target == NULL)
+ if (target == nullptr)
{
slot->set(itemStack->copy());
slot->setChanged();
@@ -707,9 +719,9 @@ void AbstractContainerMenu::resetQuickCraft()
bool AbstractContainerMenu::canItemQuickReplace(Slot *slot, shared_ptr<ItemInstance> item, bool ignoreSize)
{
- bool canReplace = slot == NULL || !slot->hasItem();
+ bool canReplace = slot == nullptr || !slot->hasItem();
- if (slot != NULL && slot->hasItem() && item != NULL && item->sameItem(slot->getItem()) && ItemInstance::tagMatches(slot->getItem(), item))
+ if (slot != nullptr && slot->hasItem() && item != nullptr && item->sameItem(slot->getItem()) && ItemInstance::tagMatches(slot->getItem(), item))
{
canReplace |= slot->getItem()->count + (ignoreSize ? 0 : item->count) <= item->getMaxStackSize();
}
@@ -722,7 +734,7 @@ void AbstractContainerMenu::getQuickCraftSlotCount(unordered_set<Slot *> *quickC
switch (quickCraftingType)
{
case QUICKCRAFT_TYPE_CHARITABLE:
- item->count = Mth::floor(item->count / (float) quickCraftSlots->size());
+ item->count = Mth::floor(item->count / static_cast<float>(quickCraftSlots->size()));
break;
case QUICKCRAFT_TYPE_GREEDY:
item->count = 1;
@@ -739,7 +751,7 @@ bool AbstractContainerMenu::canDragTo(Slot *slot)
int AbstractContainerMenu::getRedstoneSignalFromContainer(shared_ptr<Container> container)
{
- if (container == NULL) return 0;
+ if (container == nullptr) return 0;
int count = 0;
float totalPct = 0;
@@ -747,9 +759,9 @@ int AbstractContainerMenu::getRedstoneSignalFromContainer(shared_ptr<Container>
{
shared_ptr<ItemInstance> item = container->getItem(i);
- if (item != NULL)
+ if (item != nullptr)
{
- totalPct += item->count / (float) min(container->getMaxStackSize(), item->getMaxStackSize());
+ totalPct += item->count / static_cast<float>(min(container->getMaxStackSize(), item->getMaxStackSize()));
count++;
}
}
diff --git a/Minecraft.World/AbstractContainerMenu.h b/Minecraft.World/AbstractContainerMenu.h
index 5ac115de..9c7600ce 100644
--- a/Minecraft.World/AbstractContainerMenu.h
+++ b/Minecraft.World/AbstractContainerMenu.h
@@ -35,7 +35,7 @@ public:
static const int CONTAINER_ID_INVENTORY = 0;
static const int CONTAINER_ID_CREATIVE = -2;
- vector<shared_ptr<ItemInstance> > lastSlots;
+ vector<shared_ptr<ItemInstance>> lastSlots;
vector<Slot *> slots;
int containerId;
@@ -95,7 +95,7 @@ public:
virtual bool stillValid(shared_ptr<Player> player) = 0;
// 4J Stu Added for UI
- unsigned int getSize() { return (unsigned int)slots.size(); }
+ unsigned int getSize() { return static_cast<unsigned int>(slots.size()); }
protected:
diff --git a/Minecraft.World/Achievement.cpp b/Minecraft.World/Achievement.cpp
index 2c0d85d4..e449f776 100644
--- a/Minecraft.World/Achievement.cpp
+++ b/Minecraft.World/Achievement.cpp
@@ -58,7 +58,7 @@ bool Achievement::isAchievement()
wstring Achievement::getDescription()
{
- if (descFormatter != NULL)
+ if (descFormatter != nullptr)
{
return descFormatter->format(desc);
}
diff --git a/Minecraft.World/Achievements.cpp b/Minecraft.World/Achievements.cpp
index a3d33cbd..1b00acc0 100644
--- a/Minecraft.World/Achievements.cpp
+++ b/Minecraft.World/Achievements.cpp
@@ -17,79 +17,79 @@ int Achievements::yMax = 0;
vector<Achievement *> *Achievements::achievements = new vector<Achievement *>;
-Achievement *Achievements::openInventory = NULL;
-Achievement *Achievements::mineWood = NULL;
-Achievement *Achievements::buildWorkbench = NULL;
-Achievement *Achievements::buildPickaxe = NULL;
-Achievement *Achievements::buildFurnace = NULL;
-Achievement *Achievements::acquireIron = NULL;
-Achievement *Achievements::buildHoe = NULL;
-Achievement *Achievements::makeBread = NULL;
-Achievement *Achievements::bakeCake = NULL;
-Achievement *Achievements::buildBetterPickaxe = NULL;
-Achievement *Achievements::cookFish = NULL;
-Achievement *Achievements::onARail = NULL;
-Achievement *Achievements::buildSword = NULL;
-Achievement *Achievements::killEnemy = NULL;
-Achievement *Achievements::killCow = NULL;
-Achievement *Achievements::flyPig = NULL;
-
-Achievement *Achievements::snipeSkeleton = NULL;
-Achievement *Achievements::diamonds = NULL;
-//Achievement *Achievements::portal = NULL;
-Achievement *Achievements::ghast = NULL;
-Achievement *Achievements::blazeRod = NULL;
-Achievement *Achievements::potion = NULL;
-Achievement *Achievements::theEnd = NULL;
-Achievement *Achievements::winGame = NULL;
-Achievement *Achievements::enchantments = NULL;
-//Achievement *Achievements::overkill = NULL;
-//Achievement *Achievements::bookcase = NULL;
+Achievement *Achievements::openInventory = nullptr;
+Achievement *Achievements::mineWood = nullptr;
+Achievement *Achievements::buildWorkbench = nullptr;
+Achievement *Achievements::buildPickaxe = nullptr;
+Achievement *Achievements::buildFurnace = nullptr;
+Achievement *Achievements::acquireIron = nullptr;
+Achievement *Achievements::buildHoe = nullptr;
+Achievement *Achievements::makeBread = nullptr;
+Achievement *Achievements::bakeCake = nullptr;
+Achievement *Achievements::buildBetterPickaxe = nullptr;
+Achievement *Achievements::cookFish = nullptr;
+Achievement *Achievements::onARail = nullptr;
+Achievement *Achievements::buildSword = nullptr;
+Achievement *Achievements::killEnemy = nullptr;
+Achievement *Achievements::killCow = nullptr;
+Achievement *Achievements::flyPig = nullptr;
+
+Achievement *Achievements::snipeSkeleton = nullptr;
+Achievement *Achievements::diamonds = nullptr;
+//Achievement *Achievements::portal = nullptr;
+Achievement *Achievements::ghast = nullptr;
+Achievement *Achievements::blazeRod = nullptr;
+Achievement *Achievements::potion = nullptr;
+Achievement *Achievements::theEnd = nullptr;
+Achievement *Achievements::winGame = nullptr;
+Achievement *Achievements::enchantments = nullptr;
+//Achievement *Achievements::overkill = nullptr;
+//Achievement *Achievements::bookcase = nullptr;
// 4J : WESTY : Added new acheivements.
-Achievement *Achievements::leaderOfThePack = NULL;
-Achievement *Achievements::MOARTools = NULL;
-Achievement *Achievements::dispenseWithThis = NULL;
-Achievement *Achievements::InToTheNether = NULL;
+Achievement *Achievements::leaderOfThePack = nullptr;
+Achievement *Achievements::MOARTools = nullptr;
+Achievement *Achievements::dispenseWithThis = nullptr;
+Achievement *Achievements::InToTheNether = nullptr;
// 4J : WESTY : Added other awards.
-Achievement *Achievements::socialPost = NULL;
-Achievement *Achievements::eatPorkChop = NULL;
-Achievement *Achievements::play100Days = NULL;
-Achievement *Achievements::arrowKillCreeper = NULL;
-Achievement *Achievements::mine100Blocks = NULL;
-Achievement *Achievements::kill10Creepers = NULL;
+Achievement *Achievements::socialPost = nullptr;
+Achievement *Achievements::eatPorkChop = nullptr;
+Achievement *Achievements::play100Days = nullptr;
+Achievement *Achievements::arrowKillCreeper = nullptr;
+Achievement *Achievements::mine100Blocks = nullptr;
+Achievement *Achievements::kill10Creepers = nullptr;
#ifdef _EXTENDED_ACHIEVEMENTS
-Achievement *Achievements::overkill = NULL; // Restored old achivements.
-Achievement *Achievements::bookcase = NULL; // Restored old achivements.
+Achievement *Achievements::overkill = nullptr; // Restored old achivements.
+Achievement *Achievements::bookcase = nullptr; // Restored old achivements.
// 4J-JEV: New Achievements for Orbis.
-Achievement *Achievements::adventuringTime = NULL;
-Achievement *Achievements::repopulation = NULL;
-//Achievement *Achievements::porkChop = NULL;
-Achievement *Achievements::diamondsToYou = NULL;
-//Achievement *Achievements::passingTheTime = NULL;
-//Achievement *Achievements::archer = NULL;
-Achievement *Achievements::theHaggler = NULL;
-Achievement *Achievements::potPlanter = NULL;
-Achievement *Achievements::itsASign = NULL;
-Achievement *Achievements::ironBelly = NULL;
-Achievement *Achievements::haveAShearfulDay = NULL;
-Achievement *Achievements::rainbowCollection = NULL;
-Achievement *Achievements::stayinFrosty = NULL;
-Achievement *Achievements::chestfulOfCobblestone = NULL;
-Achievement *Achievements::renewableEnergy = NULL;
-Achievement *Achievements::musicToMyEars = NULL;
-Achievement *Achievements::bodyGuard = NULL;
-Achievement *Achievements::ironMan = NULL;
-Achievement *Achievements::zombieDoctor = NULL;
-Achievement *Achievements::lionTamer = NULL;
+Achievement *Achievements::adventuringTime = nullptr;
+Achievement *Achievements::repopulation = nullptr;
+//Achievement *Achievements::porkChop = nullptr;
+Achievement *Achievements::diamondsToYou = nullptr;
+//Achievement *Achievements::passingTheTime = nullptr;
+//Achievement *Achievements::archer = nullptr;
+Achievement *Achievements::theHaggler = nullptr;
+Achievement *Achievements::potPlanter = nullptr;
+Achievement *Achievements::itsASign = nullptr;
+Achievement *Achievements::ironBelly = nullptr;
+Achievement *Achievements::haveAShearfulDay = nullptr;
+Achievement *Achievements::rainbowCollection = nullptr;
+Achievement *Achievements::stayinFrosty = nullptr;
+Achievement *Achievements::chestfulOfCobblestone = nullptr;
+Achievement *Achievements::renewableEnergy = nullptr;
+Achievement *Achievements::musicToMyEars = nullptr;
+Achievement *Achievements::bodyGuard = nullptr;
+Achievement *Achievements::ironMan = nullptr;
+Achievement *Achievements::zombieDoctor = nullptr;
+Achievement *Achievements::lionTamer = nullptr;
#endif
void Achievements::staticCtor()
{
- Achievements::openInventory = (new Achievement(eAward_TakingInventory, L"openInventory", 0, 0, Item::book, NULL))->setAwardLocallyOnly()->postConstruct();
+ Achievements::openInventory = (new Achievement(eAward_TakingInventory, L"openInventory", 0, 0, Item::book, nullptr))->setAwardLocallyOnly()->postConstruct();
Achievements::mineWood = (new Achievement(eAward_GettingWood, L"mineWood", 2, 1, Tile::treeTrunk, (Achievement *) openInventory))->postConstruct();
Achievements::buildWorkbench = (new Achievement(eAward_Benchmarking, L"buildWorkBench", 4, -1, Tile::workBench, (Achievement *) mineWood))->postConstruct();
Achievements::buildPickaxe = (new Achievement(eAward_TimeToMine, L"buildPickaxe", 4, 2, Item::pickAxe_wood, (Achievement *) buildWorkbench))->postConstruct();
@@ -152,26 +152,26 @@ void Achievements::staticCtor()
Achievements::overkill = (new Achievement(eAward_overkill, L"overkill", -4,1, Item::sword_diamond, (Achievement *)enchantments) )->setGolden()->postConstruct();
Achievements::bookcase = (new Achievement(eAward_bookcase, L"bookcase", -3,6, Tile::bookshelf, (Achievement *)enchantments) )->postConstruct();
- Achievements::adventuringTime = (new Achievement(eAward_adventuringTime, L"adventuringTime", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct();
- Achievements::repopulation = (new Achievement(eAward_repopulation, L"repopulation", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
+ Achievements::adventuringTime = (new Achievement(eAward_adventuringTime, L"adventuringTime", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct();
+ Achievements::repopulation = (new Achievement(eAward_repopulation, L"repopulation", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
//Achievements::porkChoop // // // // // //
- Achievements::diamondsToYou = (new Achievement(eAward_diamondsToYou, L"diamondsToYou", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- //Achievements::passingTheTime = (new Achievement(eAward_play100Days, L"passingTheTime", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- //Achievements::archer = (new Achievement(eAward_arrowKillCreeper, L"archer", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- Achievements::theHaggler = (new Achievement(eAward_theHaggler, L"theHaggler", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct();
- Achievements::potPlanter = (new Achievement(eAward_potPlanter, L"potPlanter", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct();
- Achievements::itsASign = (new Achievement(eAward_itsASign, L"itsASign", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct();
- Achievements::ironBelly = (new Achievement(eAward_ironBelly, L"ironBelly", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- Achievements::haveAShearfulDay = (new Achievement(eAward_haveAShearfulDay, L"haveAShearfulDay", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- Achievements::rainbowCollection = (new Achievement(eAward_rainbowCollection, L"rainbowCollection", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct();
- Achievements::stayinFrosty = (new Achievement(eAward_stayinFrosty, L"stayingFrosty", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- Achievements::chestfulOfCobblestone = (new Achievement(eAward_chestfulOfCobblestone, L"chestfulOfCobblestone", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct();
- Achievements::renewableEnergy = (new Achievement(eAward_renewableEnergy, L"renewableEnergy", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- Achievements::musicToMyEars = (new Achievement(eAward_musicToMyEars, L"musicToMyEars", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- Achievements::bodyGuard = (new Achievement(eAward_bodyGuard, L"bodyGuard", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- Achievements::ironMan = (new Achievement(eAward_ironMan, L"ironMan", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- Achievements::zombieDoctor = (new Achievement(eAward_zombieDoctor, L"zombieDoctor", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
- Achievements::lionTamer = (new Achievement(eAward_lionTamer, L"lionTamer", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct();
+ Achievements::diamondsToYou = (new Achievement(eAward_diamondsToYou, L"diamondsToYou", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ //Achievements::passingTheTime = (new Achievement(eAward_play100Days, L"passingTheTime", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ //Achievements::archer = (new Achievement(eAward_arrowKillCreeper, L"archer", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ Achievements::theHaggler = (new Achievement(eAward_theHaggler, L"theHaggler", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct();
+ Achievements::potPlanter = (new Achievement(eAward_potPlanter, L"potPlanter", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct();
+ Achievements::itsASign = (new Achievement(eAward_itsASign, L"itsASign", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct();
+ Achievements::ironBelly = (new Achievement(eAward_ironBelly, L"ironBelly", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ Achievements::haveAShearfulDay = (new Achievement(eAward_haveAShearfulDay, L"haveAShearfulDay", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ Achievements::rainbowCollection = (new Achievement(eAward_rainbowCollection, L"rainbowCollection", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct();
+ Achievements::stayinFrosty = (new Achievement(eAward_stayinFrosty, L"stayingFrosty", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ Achievements::chestfulOfCobblestone = (new Achievement(eAward_chestfulOfCobblestone, L"chestfulOfCobblestone", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct();
+ Achievements::renewableEnergy = (new Achievement(eAward_renewableEnergy, L"renewableEnergy", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ Achievements::musicToMyEars = (new Achievement(eAward_musicToMyEars, L"musicToMyEars", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ Achievements::bodyGuard = (new Achievement(eAward_bodyGuard, L"bodyGuard", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ Achievements::ironMan = (new Achievement(eAward_ironMan, L"ironMan", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ Achievements::zombieDoctor = (new Achievement(eAward_zombieDoctor, L"zombieDoctor", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
+ Achievements::lionTamer = (new Achievement(eAward_lionTamer, L"lionTamer", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct();
#endif
}
diff --git a/Minecraft.World/AddEntityPacket.cpp b/Minecraft.World/AddEntityPacket.cpp
index 6231537d..f70082b8 100644
--- a/Minecraft.World/AddEntityPacket.cpp
+++ b/Minecraft.World/AddEntityPacket.cpp
@@ -32,9 +32,9 @@ void AddEntityPacket::_init(shared_ptr<Entity> e, int type, int data, int xp, in
if (xd > m) xd = m;
if (yd > m) yd = m;
if (zd > m) zd = m;
- xa = (int) (xd * 8000.0);
- ya = (int) (yd * 8000.0);
- za = (int) (zd * 8000.0);
+ xa = static_cast<int>(xd * 8000.0);
+ ya = static_cast<int>(yd * 8000.0);
+ za = static_cast<int>(zd * 8000.0);
}
}
diff --git a/Minecraft.World/AddEntityPacket.h b/Minecraft.World/AddEntityPacket.h
index 29396479..d40a8437 100644
--- a/Minecraft.World/AddEntityPacket.h
+++ b/Minecraft.World/AddEntityPacket.h
@@ -52,6 +52,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new AddEntityPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<AddEntityPacket>(); }
virtual int getId() { return 23; }
}; \ No newline at end of file
diff --git a/Minecraft.World/AddExperienceOrbPacket.h b/Minecraft.World/AddExperienceOrbPacket.h
index 59accfb3..f955a8bd 100644
--- a/Minecraft.World/AddExperienceOrbPacket.h
+++ b/Minecraft.World/AddExperienceOrbPacket.h
@@ -19,6 +19,6 @@ public:
virtual void handle(PacketListener *listener);
virtual int getEstimatedSize();
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new AddExperienceOrbPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<AddExperienceOrbPacket>(); }
virtual int getId() { return 26; }
}; \ No newline at end of file
diff --git a/Minecraft.World/AddGlobalEntityPacket.h b/Minecraft.World/AddGlobalEntityPacket.h
index 80c10db2..9959dc77 100644
--- a/Minecraft.World/AddGlobalEntityPacket.h
+++ b/Minecraft.World/AddGlobalEntityPacket.h
@@ -20,6 +20,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new AddGlobalEntityPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<AddGlobalEntityPacket>(); }
virtual int getId() { return 71; }
}; \ No newline at end of file
diff --git a/Minecraft.World/AddMobPacket.cpp b/Minecraft.World/AddMobPacket.cpp
index 878e2ee7..d5ccfe08 100644
--- a/Minecraft.World/AddMobPacket.cpp
+++ b/Minecraft.World/AddMobPacket.cpp
@@ -17,7 +17,7 @@ AddMobPacket::AddMobPacket()
yRot = 0;
xRot = 0;
entityData = nullptr;
- unpack = NULL;
+ unpack = nullptr;
}
AddMobPacket::~AddMobPacket()
@@ -29,7 +29,7 @@ AddMobPacket::AddMobPacket(shared_ptr<LivingEntity> mob, int yRotp, int xRotp, i
{
id = mob->entityId;
- type = (byte) EntityIO::getId(mob);
+ type = static_cast<byte>(EntityIO::getId(mob));
// 4J Stu - We should add entities at their "last sent" position so that the relative update packets
// put them in the correct place
x = xp;//Mth::floor(mob->x * 32);
@@ -54,14 +54,14 @@ AddMobPacket::AddMobPacket(shared_ptr<LivingEntity> mob, int yRotp, int xRotp, i
if (xd > m) xd = m;
if (yd > m) yd = m;
if (zd > m) zd = m;
- this->xd = (int) (xd * 8000.0);
- this->yd = (int) (yd * 8000.0);
- this->zd = (int) (zd * 8000.0);
+ this->xd = static_cast<int>(xd * 8000.0);
+ this->yd = static_cast<int>(yd * 8000.0);
+ this->zd = static_cast<int>(zd * 8000.0);
// printf("%d: New add mob rot %d\n",id,yRot);
entityData = mob->getEntityData();
- unpack = NULL;
+ unpack = nullptr;
}
void AddMobPacket::read(DataInputStream *dis) //throws IOException
@@ -118,11 +118,11 @@ void AddMobPacket::handle(PacketListener *listener)
int AddMobPacket::getEstimatedSize()
{
int size = 11;
- if( entityData != NULL )
+ if( entityData != nullptr )
{
size += entityData->getSizeInBytes();
}
- else if( unpack != NULL )
+ else if( unpack != nullptr )
{
// 4J Stu - This is an incoming value which we aren't currently analysing
//size += unpack->get
@@ -132,7 +132,7 @@ int AddMobPacket::getEstimatedSize()
vector<shared_ptr<SynchedEntityData::DataItem> > *AddMobPacket::getUnpackedData()
{
- if (unpack == NULL)
+ if (unpack == nullptr)
{
unpack = entityData->getAll();
}
diff --git a/Minecraft.World/AddMobPacket.h b/Minecraft.World/AddMobPacket.h
index 6af72655..9f7c1e1c 100644
--- a/Minecraft.World/AddMobPacket.h
+++ b/Minecraft.World/AddMobPacket.h
@@ -32,6 +32,6 @@ public:
vector<shared_ptr<SynchedEntityData::DataItem> > *getUnpackedData();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new AddMobPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<AddMobPacket>(); }
virtual int getId() { return 24; }
};
diff --git a/Minecraft.World/AddPaintingPacket.h b/Minecraft.World/AddPaintingPacket.h
index a5694b74..a50c1b77 100644
--- a/Minecraft.World/AddPaintingPacket.h
+++ b/Minecraft.World/AddPaintingPacket.h
@@ -22,6 +22,6 @@ public:
virtual void handle(PacketListener *listener);
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new AddPaintingPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<AddPaintingPacket>(); }
virtual int getId() { return 25; }
};
diff --git a/Minecraft.World/AddPlayerPacket.cpp b/Minecraft.World/AddPlayerPacket.cpp
index 93984367..fbee1fc5 100644
--- a/Minecraft.World/AddPlayerPacket.cpp
+++ b/Minecraft.World/AddPlayerPacket.cpp
@@ -24,12 +24,12 @@ AddPlayerPacket::AddPlayerPacket()
m_capeId = 0;
m_uiGamePrivileges = 0;
entityData = nullptr;
- unpack = NULL;
+ unpack = nullptr;
}
AddPlayerPacket::~AddPlayerPacket()
{
- if(unpack != NULL) delete unpack;
+ if(unpack != nullptr) delete unpack;
}
AddPlayerPacket::AddPlayerPacket(shared_ptr<Player> player, PlayerUID xuid, PlayerUID OnlineXuid,int xp, int yp, int zp, int yRotp, int xRotp, int yHeadRotp)
@@ -51,17 +51,17 @@ AddPlayerPacket::AddPlayerPacket(shared_ptr<Player> player, PlayerUID xuid, Play
//printf("%d: New add player (%f,%f,%f) : (%d,%d,%d) : xRot %d, yRot %d\n",id,player->x,player->y,player->z,x,y,z,xRot,yRot);
shared_ptr<ItemInstance> itemInstance = player->inventory->getSelected();
- carriedItem = itemInstance == NULL ? 0 : itemInstance->id;
+ carriedItem = itemInstance == nullptr ? 0 : itemInstance->id;
this->xuid = xuid;
this->OnlineXuid = OnlineXuid;
- m_playerIndex = (BYTE)player->getPlayerIndex();
+ m_playerIndex = static_cast<BYTE>(player->getPlayerIndex());
m_skinId = player->getCustomSkin();
m_capeId = player->getCustomCape();
m_uiGamePrivileges = player->getAllPlayerGamePrivileges();
entityData = player->getEntityData();
- unpack = NULL;
+ unpack = nullptr;
}
void AddPlayerPacket::read(DataInputStream *dis) //throws IOException
@@ -119,11 +119,11 @@ int AddPlayerPacket::getEstimatedSize()
{
int iSize= sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(BYTE) + sizeof(BYTE) +sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) + sizeof(int) + sizeof(BYTE) + sizeof(unsigned int) + sizeof(byte);
- if( entityData != NULL )
+ if( entityData != nullptr )
{
iSize += entityData->getSizeInBytes();
}
- else if( unpack != NULL )
+ else if( unpack != nullptr )
{
// 4J Stu - This is an incoming value which we aren't currently analysing
//iSize += unpack->get
@@ -134,7 +134,7 @@ int AddPlayerPacket::getEstimatedSize()
vector<shared_ptr<SynchedEntityData::DataItem> > *AddPlayerPacket::getUnpackedData()
{
- if (unpack == NULL)
+ if (unpack == nullptr)
{
unpack = entityData->getAll();
}
diff --git a/Minecraft.World/AddPlayerPacket.h b/Minecraft.World/AddPlayerPacket.h
index 30f6bcdd..af90c97d 100644
--- a/Minecraft.World/AddPlayerPacket.h
+++ b/Minecraft.World/AddPlayerPacket.h
@@ -38,6 +38,6 @@ public:
vector<shared_ptr<SynchedEntityData::DataItem> > *getUnpackedData();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new AddPlayerPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<AddPlayerPacket>(); }
virtual int getId() { return 20; }
};
diff --git a/Minecraft.World/AgableMob.cpp b/Minecraft.World/AgableMob.cpp
index 307aa767..892a14e5 100644
--- a/Minecraft.World/AgableMob.cpp
+++ b/Minecraft.World/AgableMob.cpp
@@ -17,7 +17,7 @@ bool AgableMob::mobInteract(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> item = player->inventory->getSelected();
- if (item != NULL && item->id == Item::spawnEgg_Id)
+ if (item != nullptr && item->id == Item::spawnEgg_Id)
{
if (!level->isClientSide)
{
@@ -27,10 +27,10 @@ bool AgableMob::mobInteract(shared_ptr<Player> player)
int error;
shared_ptr<Entity> result = SpawnEggItem::canSpawn(item->getAuxValue(), level, &error);
- if (result != NULL)
+ if (result != nullptr)
{
shared_ptr<AgableMob> offspring = getBreedOffspring(dynamic_pointer_cast<AgableMob>(shared_from_this()));
- if (offspring != NULL)
+ if (offspring != nullptr)
{
offspring->setAge(BABY_START_AGE);
offspring->moveTo(x, y, z, 0, 0);
diff --git a/Minecraft.World/Animal.cpp b/Minecraft.World/Animal.cpp
index ecda8fc5..68278162 100644
--- a/Minecraft.World/Animal.cpp
+++ b/Minecraft.World/Animal.cpp
@@ -72,13 +72,13 @@ void Animal::checkHurtTarget(shared_ptr<Entity> target, float d)
{
double xd = target->x - x;
double zd = target->z - z;
- yRot = (float) (atan2(zd, xd) * 180 / PI) - 90;
+ yRot = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
holdGround = true;
}
shared_ptr<Player> p = dynamic_pointer_cast<Player>(target);
- if (p->getSelectedItem() == NULL || !isFood(p->getSelectedItem()))
+ if (p->getSelectedItem() == nullptr || !isFood(p->getSelectedItem()))
{
attackTarget = nullptr;
}
@@ -97,7 +97,7 @@ void Animal::checkHurtTarget(shared_ptr<Entity> target, float d)
}
else if (getInLoveValue() > 0 && a->getInLoveValue() > 0)
{
- if (a->attackTarget == NULL) a->attackTarget = shared_from_this();
+ if (a->attackTarget == nullptr) a->attackTarget = shared_from_this();
if (a->attackTarget == shared_from_this() && d < 3.5)
{
@@ -134,9 +134,9 @@ void Animal::breedWith(shared_ptr<Animal> target)
target->loveTime = 0;
target->setInLoveValue(0);
- // 4J - we have offspring of NULL returned when we have hit our limits of spawning any particular type of animal. In these cases try and do everything we can apart from actually
+ // 4J - we have offspring of nullptr returned when we have hit our limits of spawning any particular type of animal. In these cases try and do everything we can apart from actually
// spawning the entity.
- if (offspring != NULL)
+ if (offspring != nullptr)
{
// Only want to set the age to this +ve value if something is actually spawned, as during this period the animal will attempt to follow offspring and ignore players.
setAge(5 * 60 * 20);
@@ -154,7 +154,7 @@ void Animal::breedWith(shared_ptr<Animal> target)
}
level->addEntity(offspring);
- level->addEntity( shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x, y, z, random->nextInt(4) + 1) ) );
+ level->addEntity(std::make_shared<ExperienceOrb>(level, x, y, z, random->nextInt(4) + 1));
}
setDespawnProtected();
@@ -169,7 +169,7 @@ float Animal::getWalkTargetValue(int x, int y, int z)
bool Animal::hurt(DamageSource *dmgSource, float dmg)
{
if (isInvulnerable()) return false;
- if (dynamic_cast<EntityDamageSource *>(dmgSource) != NULL)
+ if (dynamic_cast<EntityDamageSource *>(dmgSource) != nullptr)
{
shared_ptr<Entity> source = dmgSource->getDirectEntity();
@@ -179,12 +179,12 @@ bool Animal::hurt(DamageSource *dmgSource, float dmg)
return false;
}
- if ( (source != NULL) && source->instanceof(eTYPE_ARROW) )
+ if ( (source != nullptr) && source->instanceof(eTYPE_ARROW) )
{
shared_ptr<Arrow> arrow = dynamic_pointer_cast<Arrow>(source);
// 4J: Check that the arrow's owner can attack animals (dispenser arrows are not owned)
- if (arrow->owner != NULL && arrow->owner->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(arrow->owner)->isAllowedToAttackAnimals() )
+ if (arrow->owner != nullptr && arrow->owner->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(arrow->owner)->isAllowedToAttackAnimals() )
{
return false;
}
@@ -196,7 +196,7 @@ bool Animal::hurt(DamageSource *dmgSource, float dmg)
if (!useNewAi())
{
AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED);
- if (speed->getModifier(eModifierId_MOB_FLEEING) == NULL)
+ if (speed->getModifier(eModifierId_MOB_FLEEING) == nullptr)
{
speed->addModifier(new AttributeModifier(*Animal::SPEED_MODIFIER_FLEEING));
}
@@ -255,7 +255,7 @@ shared_ptr<Entity> Animal::findAttackTarget()
setDespawnProtected();
shared_ptr<Player> p = dynamic_pointer_cast<Player>(it);
- if (p->getSelectedItem() != NULL && this->isFood(p->getSelectedItem()))
+ if (p->getSelectedItem() != nullptr && this->isFood(p->getSelectedItem()))
{
delete players;
return p;
@@ -317,7 +317,7 @@ bool Animal::isFood(shared_ptr<ItemInstance> itemInstance)
bool Animal::mobInteract(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> item = player->inventory->getSelected();
- if (item != NULL && isFood(item) && getAge() == 0 && getInLoveValue() <= 0)
+ if (item != nullptr && isFood(item) && getAge() == 0 && getInLoveValue() <= 0)
{
if (!player->abilities.instabuild)
{
diff --git a/Minecraft.World/AnimatePacket.h b/Minecraft.World/AnimatePacket.h
index 0287b9a6..7075ffab 100644
--- a/Minecraft.World/AnimatePacket.h
+++ b/Minecraft.World/AnimatePacket.h
@@ -26,6 +26,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new AnimatePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<AnimatePacket>(); }
virtual int getId() { return 18; }
}; \ No newline at end of file
diff --git a/Minecraft.World/AnvilMenu.cpp b/Minecraft.World/AnvilMenu.cpp
index 83d38142..78d72daf 100644
--- a/Minecraft.World/AnvilMenu.cpp
+++ b/Minecraft.World/AnvilMenu.cpp
@@ -8,8 +8,8 @@
AnvilMenu::AnvilMenu(shared_ptr<Inventory> inventory, Level *level, int xt, int yt, int zt, shared_ptr<Player> player)
{
- resultSlots = shared_ptr<ResultContainer>( new ResultContainer() );
- repairSlots = shared_ptr<RepairContainer>( new RepairContainer(this,IDS_REPAIR_AND_NAME, true, 2) );
+ resultSlots = std::make_shared<ResultContainer>();
+ repairSlots = std::make_shared<RepairContainer>(this,IDS_REPAIR_AND_NAME, true, 2);
cost = 0;
repairItemCountCost = 0;
@@ -55,7 +55,7 @@ void AnvilMenu::createResult()
if (DEBUG_COST) app.DebugPrintf("----");
- if (input == NULL)
+ if (input == nullptr)
{
resultSlots->setItem(0, nullptr);
cost = 0;
@@ -68,15 +68,15 @@ void AnvilMenu::createResult()
unordered_map<int,int> *enchantments = EnchantmentHelper::getEnchantments(result);
bool usingBook = false;
- tax += input->getBaseRepairCost() + (addition == NULL ? 0 : addition->getBaseRepairCost());
+ tax += input->getBaseRepairCost() + (addition == nullptr ? 0 : addition->getBaseRepairCost());
if (DEBUG_COST)
{
- app.DebugPrintf("Starting with base repair tax of %d (%d + %d)\n", tax, input->getBaseRepairCost(), (addition == NULL ? 0 : addition->getBaseRepairCost()));
+ app.DebugPrintf("Starting with base repair tax of %d (%d + %d)\n", tax, input->getBaseRepairCost(), (addition == nullptr ? 0 : addition->getBaseRepairCost()));
}
repairItemCountCost = 0;
- if (addition != NULL)
+ if (addition != nullptr)
{
usingBook = addition->id == Item::enchantedBook_Id && Item::enchantedBook->getEnchantments(addition)->size() > 0;
@@ -290,10 +290,10 @@ void AnvilMenu::createResult()
result = nullptr;
}
- if (result != NULL)
+ if (result != nullptr)
{
int baseCost = result->getBaseRepairCost();
- if (addition != NULL && baseCost < addition->getBaseRepairCost()) baseCost = addition->getBaseRepairCost();
+ if (addition != nullptr && baseCost < addition->getBaseRepairCost()) baseCost = addition->getBaseRepairCost();
if (result->hasCustomHoverName()) baseCost -= 9;
if (baseCost < 0) baseCost = 0;
baseCost += 2;
@@ -344,7 +344,7 @@ void AnvilMenu::removed(shared_ptr<Player> player)
for (int i = 0; i < repairSlots->getContainerSize(); i++)
{
shared_ptr<ItemInstance> item = repairSlots->removeItemNoUpdate(i);
- if (item != NULL)
+ if (item != nullptr)
{
player->drop(item);
}
@@ -362,7 +362,7 @@ shared_ptr<ItemInstance> AnvilMenu::quickMoveStack(shared_ptr<Player> player, in
{
shared_ptr<ItemInstance> clicked = nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
diff --git a/Minecraft.World/AnvilTile.cpp b/Minecraft.World/AnvilTile.cpp
index 8789cb7c..5d186c28 100644
--- a/Minecraft.World/AnvilTile.cpp
+++ b/Minecraft.World/AnvilTile.cpp
@@ -21,7 +21,7 @@ AnvilTile::AnvilTile(int id) : HeavyTile(id, Material::heavyMetal, isSolidRender
{
part = PART_BASE;
setLightBlock(0);
- icons = NULL;
+ icons = nullptr;
}
bool AnvilTile::isCubeShaped()
diff --git a/Minecraft.World/ArmorDyeRecipe.cpp b/Minecraft.World/ArmorDyeRecipe.cpp
index 46d43868..d4581182 100644
--- a/Minecraft.World/ArmorDyeRecipe.cpp
+++ b/Minecraft.World/ArmorDyeRecipe.cpp
@@ -13,12 +13,12 @@ bool ArmorDyeRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *le
for (int slot = 0; slot < craftSlots->getContainerSize(); slot++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(slot);
- if (item == NULL) continue;
+ if (item == nullptr) continue;
ArmorItem *armor = dynamic_cast<ArmorItem *>(item->getItem());
if (armor)
{
- if (armor->getMaterial() == ArmorItem::ArmorMaterial::CLOTH && target == NULL)
+ if (armor->getMaterial() == ArmorItem::ArmorMaterial::CLOTH && target == nullptr)
{
target = item;
}
@@ -37,7 +37,7 @@ bool ArmorDyeRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *le
}
}
- return target != NULL && !dyes.empty();
+ return target != nullptr && !dyes.empty();
}
shared_ptr<ItemInstance> ArmorDyeRecipe::assembleDyedArmor(shared_ptr<CraftingContainer> craftSlots)
@@ -46,19 +46,19 @@ shared_ptr<ItemInstance> ArmorDyeRecipe::assembleDyedArmor(shared_ptr<CraftingCo
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++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(slot);
- if (item == NULL) continue;
+ if (item == nullptr) continue;
armor = dynamic_cast<ArmorItem *>(item->getItem());
if (armor)
{
- if (armor->getMaterial() == ArmorItem::ArmorMaterial::CLOTH && target == NULL)
+ if (armor->getMaterial() == ArmorItem::ArmorMaterial::CLOTH && target == nullptr)
{
target = item->copy();
target->count = 1;
@@ -66,9 +66,9 @@ shared_ptr<ItemInstance> ArmorDyeRecipe::assembleDyedArmor(shared_ptr<CraftingCo
if (armor->hasCustomColor(item))
{
int color = armor->getColor(target);
- float red = (float) ((color >> 16) & 0xFF) / 0xFF;
- float green = (float) ((color >> 8) & 0xFF) / 0xFF;
- float blue = (float) (color & 0xFF) / 0xFF;
+ float red = static_cast<float>((color >> 16) & 0xFF) / 0xFF;
+ float green = static_cast<float>((color >> 8) & 0xFF) / 0xFF;
+ float blue = static_cast<float>(color & 0xFF) / 0xFF;
intensityTotal += max(red, max(green, blue)) * 0xFF;
@@ -86,9 +86,9 @@ shared_ptr<ItemInstance> ArmorDyeRecipe::assembleDyedArmor(shared_ptr<CraftingCo
else if (item->id == Item::dye_powder_Id)
{
int tileData = ColoredTile::getTileDataForItemAuxValue(item->getAuxValue());
- int red = (int) (Sheep::COLOR[tileData][0] * 0xFF);
- int green = (int) (Sheep::COLOR[tileData][1] * 0xFF);
- int blue = (int) (Sheep::COLOR[tileData][2] * 0xFF);
+ int red = static_cast<int>(Sheep::COLOR[tileData][0] * 0xFF);
+ int green = static_cast<int>(Sheep::COLOR[tileData][1] * 0xFF);
+ int blue = static_cast<int>(Sheep::COLOR[tileData][2] * 0xFF);
intensityTotal += max(red, max(green, blue));
@@ -104,19 +104,19 @@ shared_ptr<ItemInstance> ArmorDyeRecipe::assembleDyedArmor(shared_ptr<CraftingCo
}
}
- if (armor == NULL) return nullptr;
+ if (armor == nullptr) return nullptr;
int red = (colorTotals[0] / colourCounts);
int green = (colorTotals[1] / colourCounts);
int blue = (colorTotals[2] / colourCounts);
- float averageIntensity = (float) intensityTotal / colourCounts;
- float resultIntensity = (float) max(red, max(green, blue));
+ float averageIntensity = static_cast<float>(intensityTotal) / colourCounts;
+ float resultIntensity = static_cast<float>(max(red, max(green, blue)));
// System.out.println(averageIntensity + ", " + resultIntensity);
- red = (int) ((float) red * averageIntensity / resultIntensity);
- green = (int) ((float) green * averageIntensity / resultIntensity);
- blue = (int) ((float) blue * averageIntensity / resultIntensity);
+ red = static_cast<int>((float)red * averageIntensity / resultIntensity);
+ green = static_cast<int>((float)green * averageIntensity / resultIntensity);
+ blue = static_cast<int>((float)blue * averageIntensity / resultIntensity);
int rgb = red;
rgb = (rgb << 8) + green;
@@ -138,7 +138,7 @@ int ArmorDyeRecipe::size()
const ItemInstance *ArmorDyeRecipe::getResultItem()
{
- return NULL;
+ return nullptr;
}
const int ArmorDyeRecipe::getGroup()
@@ -175,7 +175,7 @@ void ArmorDyeRecipe::reqs(INGREDIENTS_REQUIRED *pIngReq)
#if 0
for ( ItemInstance *expected : *ingredients )
{
- if (expected!=NULL)
+ if (expected!=nullptr)
{
int iAuxVal = expected->getAuxValue();
TempIngReq.uiGridA[iCount++]=expected->id | iAuxVal<<24;
diff --git a/Minecraft.World/ArmorItem.cpp b/Minecraft.World/ArmorItem.cpp
index 114b200b..93d58cdd 100644
--- a/Minecraft.World/ArmorItem.cpp
+++ b/Minecraft.World/ArmorItem.cpp
@@ -170,9 +170,9 @@ int ArmorItem::getColor(shared_ptr<ItemInstance> item)
if (armorType != ArmorMaterial::CLOTH) return -1;
CompoundTag *tag = item->getTag();
- if (tag == NULL) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR );
+ if (tag == nullptr) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR );
CompoundTag *display = tag->getCompound(L"display");
- if (display == NULL) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR );
+ if (display == nullptr) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR );
if (display->contains(L"color"))
{
@@ -197,7 +197,7 @@ void ArmorItem::clearColor(shared_ptr<ItemInstance> item)
{
if (armorType != ArmorMaterial::CLOTH) return;
CompoundTag *tag = item->getTag();
- if (tag == NULL) return;
+ if (tag == nullptr) return;
CompoundTag *display = tag->getCompound(L"display");
if (display->contains(L"color")) display->remove(L"color");
}
@@ -215,7 +215,7 @@ void ArmorItem::setColor(shared_ptr<ItemInstance> item, int color)
CompoundTag *tag = item->getTag();
- if (tag == NULL)
+ if (tag == nullptr)
{
tag = new CompoundTag();
item->setTag(tag);
@@ -262,5 +262,5 @@ Icon *ArmorItem::getEmptyIcon(int slot)
return Item::boots_diamond->iconEmpty;
}
- return NULL;
+ return nullptr;
} \ No newline at end of file
diff --git a/Minecraft.World/ArmorSlot.cpp b/Minecraft.World/ArmorSlot.cpp
index 7707635a..2e85fed3 100644
--- a/Minecraft.World/ArmorSlot.cpp
+++ b/Minecraft.World/ArmorSlot.cpp
@@ -19,11 +19,11 @@ int ArmorSlot::getMaxStackSize() const
bool ArmorSlot::mayPlace(shared_ptr<ItemInstance> item)
{
- if (item == NULL)
+ if (item == nullptr)
{
return false;
}
- if ( dynamic_cast<ArmorItem *>( item->getItem() ) != NULL)
+ if ( dynamic_cast<ArmorItem *>( item->getItem() ) != nullptr)
{
return dynamic_cast<ArmorItem *>( item->getItem() )->slot == slotNum;
}
@@ -43,7 +43,7 @@ Icon *ArmorSlot::getNoItemIcon()
//bool ArmorSlot::mayCombine(shared_ptr<ItemInstance> item)
//{
// shared_ptr<ItemInstance> thisItemI = getItem();
-// if(thisItemI == NULL || item == NULL) return false;
+// if(thisItemI == nullptr || item == nullptr) return false;
//
// ArmorItem *thisItem = (ArmorItem *)thisItemI->getItem();
// bool thisIsDyableArmor = thisItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH;
@@ -53,7 +53,7 @@ Icon *ArmorSlot::getNoItemIcon()
//
//shared_ptr<ItemInstance> ArmorSlot::combine(shared_ptr<ItemInstance> item)
//{
-// shared_ptr<CraftingContainer> craftSlots = shared_ptr<CraftingContainer>( new CraftingContainer(NULL, 2, 2) );
+// shared_ptr<CraftingContainer> craftSlots = shared_ptr<CraftingContainer>( new CraftingContainer(nullptr, 2, 2) );
// craftSlots->setItem(0, item);
// craftSlots->setItem(1, getItem()); // Armour item needs to go second
// shared_ptr<ItemInstance> result = ArmorDyeRecipe::assembleDyedArmor(craftSlots);
diff --git a/Minecraft.World/ArrayWithLength.h b/Minecraft.World/ArrayWithLength.h
index e22724c6..ab491aa8 100644
--- a/Minecraft.World/ArrayWithLength.h
+++ b/Minecraft.World/ArrayWithLength.h
@@ -10,7 +10,7 @@ template <class T> class arrayWithLength
public:
T *data;
unsigned int length;
- arrayWithLength() { data = NULL; length = 0; }
+ arrayWithLength() { data = nullptr; length = 0; }
arrayWithLength(unsigned int elements, bool bClearArray=true) { assert(elements!=0); data = new T[elements]; if(bClearArray){ memset( data,0,sizeof(T)*elements); } this->length = elements; }
// 4J Stu Added this ctor so I static init arrays in the Item derivation tree
@@ -24,7 +24,7 @@ public:
T *temp = new T[elements];
memset( temp,0,sizeof(T)*elements);
- if( data != NULL )
+ if( data != nullptr )
{
std::copy( data, data+length, temp );
@@ -45,7 +45,7 @@ template <class T> class array2DWithLength
public:
_parrayWithLength *data;
unsigned int length;
- array2DWithLength() { data = NULL; length = 0; }
+ array2DWithLength() { data = nullptr; length = 0; }
array2DWithLength(unsigned int dimA, unsigned int dimB)
{
data = new _parrayWithLength[dimA];
diff --git a/Minecraft.World/Arrow.cpp b/Minecraft.World/Arrow.cpp
index f7253ca6..ae30c057 100644
--- a/Minecraft.World/Arrow.cpp
+++ b/Minecraft.World/Arrow.cpp
@@ -72,15 +72,15 @@ Arrow::Arrow(Level *level, shared_ptr<LivingEntity> mob, shared_ptr<LivingEntity
double sd = sqrt(xd * xd + zd * zd);
if (sd < 0.0000001) return;
- float yRot = (float) (atan2(zd, xd) * 180 / PI) - 90;
- float xRot = (float) -(atan2(yd, sd) * 180 / PI);
+ float yRot = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
+ float xRot = static_cast<float>(-(atan2(yd, sd) * 180 / PI));
double xdn = xd / sd;
double zdn = zd / sd;
moveTo(mob->x + xdn, y, mob->z + zdn, yRot, xRot);
heightOffset = 0;
- float yo = (float) sd * 0.2f;
+ float yo = static_cast<float>(sd) * 0.2f;
shoot(xd, yd + yo, zd, power, uncertainty);
}
@@ -123,13 +123,13 @@ Arrow::Arrow(Level *level, shared_ptr<LivingEntity> mob, float power) : Entity(
void Arrow::defineSynchedData()
{
- entityData->define(ID_FLAGS, (byte) 0);
+ entityData->define(ID_FLAGS, static_cast<byte>(0));
}
void Arrow::shoot(double xd, double yd, double zd, float pow, float uncertainty)
{
- float dist = (float) sqrt(xd * xd + yd * yd + zd * zd);
+ float dist = static_cast<float>(sqrt(xd * xd + yd * yd + zd * zd));
xd /= dist;
yd /= dist;
@@ -149,8 +149,8 @@ void Arrow::shoot(double xd, double yd, double zd, float pow, float uncertainty)
double sd = sqrt(xd * xd + zd * zd);
- yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRotO = xRot = (float) (atan2(yd, sd) * 180 / PI);
+ yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRotO = xRot = static_cast<float>(atan2(yd, sd) * 180 / PI);
life = 0;
}
@@ -168,8 +168,8 @@ void Arrow::lerpMotion(double xd, double yd, double zd)
if (xRotO == 0 && yRotO == 0)
{
double sd = sqrt(xd * xd + zd * zd);
- yRotO = yRot = (float) (atan2( xd, zd) * 180 / PI);
- xRotO = xRot = (float) (atan2( yd, sd) * 180 / PI);
+ yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRotO = xRot = static_cast<float>(atan2(yd, sd) * 180 / PI);
xRotO = xRot;
yRotO = yRot;
app.DebugPrintf("%f %f : 0x%x\n",xRot,yRot,&yRot);
@@ -186,8 +186,8 @@ void Arrow::tick()
if (xRotO == 0 && yRotO == 0)
{
double sd = sqrt(xd * xd + zd * zd);
- yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRotO = xRot = (float) (atan2(yd, sd) * 180 / PI);
+ yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRotO = xRot = static_cast<float>(atan2(yd, sd) * 180 / PI);
}
@@ -197,7 +197,7 @@ void Arrow::tick()
{
Tile::tiles[t]->updateShape(level, xTile, yTile, zTile);
AABB *aabb = Tile::tiles[t]->getAABB(level, xTile, yTile, zTile);
- if (aabb != NULL && aabb->contains(Vec3::newTemp(x, y, z)))
+ if (aabb != nullptr && aabb->contains(Vec3::newTemp(x, y, z)))
{
inGround = true;
}
@@ -242,7 +242,7 @@ void Arrow::tick()
from = Vec3::newTemp(x, y, z);
to = Vec3::newTemp(x + xd, y + yd, z + zd);
- if (res != NULL)
+ if (res != nullptr)
{
to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z);
}
@@ -256,7 +256,7 @@ void Arrow::tick()
float rr = 0.3f;
AABB *bb = e->bb->grow(rr, rr, rr);
HitResult *p = bb->clip(from, to);
- if (p != NULL)
+ if (p != nullptr)
{
double dd = from->distanceTo(p->pos);
if (dd < nearest || nearest == 0)
@@ -268,33 +268,33 @@ void Arrow::tick()
}
}
- if (hitEntity != NULL)
+ if (hitEntity != nullptr)
{
delete res;
res = new HitResult(hitEntity);
}
- if ( (res != NULL) && (res->entity != NULL) && res->entity->instanceof(eTYPE_PLAYER))
+ if ( (res != nullptr) && (res->entity != nullptr) && res->entity->instanceof(eTYPE_PLAYER))
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(res->entity);
// 4J: Check for owner being null
- if ( player->abilities.invulnerable || ((owner != NULL) && (owner->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(owner)->canHarmPlayer(player))))
+ if ( player->abilities.invulnerable || ((owner != nullptr) && (owner->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(owner)->canHarmPlayer(player))))
{
- res = NULL;
+ res = nullptr;
}
}
- if (res != NULL)
+ if (res != nullptr)
{
- if (res->entity != NULL)
+ if (res->entity != nullptr)
{
float pow = Mth::sqrt(xd * xd + yd * yd + zd * zd);
- int dmg = (int) Mth::ceil((float)(pow * baseDamage));
+ int dmg = (int) Mth::ceil(static_cast<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(dynamic_pointer_cast<Arrow>(shared_from_this()), shared_from_this());
}
@@ -335,19 +335,19 @@ void Arrow::tick()
}
}
- if (owner != NULL)
+ if (owner != nullptr)
{
ThornsEnchantment::doThornsAfterAttack(owner, mob, random);
}
- if (owner != NULL && res->entity != owner && owner->GetType() == eTYPE_SERVERPLAYER)
+ if (owner != nullptr && res->entity != owner && owner->GetType() == eTYPE_SERVERPLAYER)
{
- dynamic_pointer_cast<ServerPlayer>(owner)->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::SUCCESSFUL_BOW_HIT, 0)) );
+ dynamic_pointer_cast<ServerPlayer>(owner)->connection->send(std::make_shared<GameEventPacket>(GameEventPacket::SUCCESSFUL_BOW_HIT, 0));
}
}
// 4J : WESTY : For award, need to track if creeper was killed by arrow from the player.
- if (owner != NULL && owner->instanceof(eTYPE_PLAYER) // arrow owner is a player
+ if (owner != nullptr && owner->instanceof(eTYPE_PLAYER) // arrow owner is a player
&& !res->entity->isAlive() // target is now dead
&& (res->entity->GetType() == eTYPE_CREEPER)) // target is a creeper
@@ -380,10 +380,10 @@ void Arrow::tick()
zTile = res->z;
lastTile = level->getTile(xTile, yTile, zTile);
lastData = level->getData(xTile, yTile, zTile);
- xd = (float) (res->pos->x - x);
- yd = (float) (res->pos->y - y);
- zd = (float) (res->pos->z - z);
- float dd = (float) sqrt(xd * xd + yd * yd + zd * zd);
+ xd = static_cast<float>(res->pos->x - x);
+ yd = static_cast<float>(res->pos->y - y);
+ zd = static_cast<float>(res->pos->z - z);
+ float dd = static_cast<float>(sqrt(xd * xd + yd * yd + zd * zd));
// 4J added check - zero dd here was creating NaNs
if( dd > 0.0001f )
{
@@ -418,8 +418,8 @@ void Arrow::tick()
z += zd;
double sd = sqrt(xd * xd + zd * zd);
- yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRot = (float) (atan2(yd, sd) * 180 / PI);
+ yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRot = static_cast<float>(atan2(yd, sd) * 180 / PI);
while (xRot - xRotO < -180)
xRotO -= 360;
@@ -460,14 +460,14 @@ void Arrow::tick()
void Arrow::addAdditonalSaveData(CompoundTag *tag)
{
- tag->putShort(L"xTile", (short) xTile);
- tag->putShort(L"yTile", (short) yTile);
- tag->putShort(L"zTile", (short) zTile);
- tag->putByte(L"inTile", (byte) lastTile);
- tag->putByte(L"inData", (byte) lastData);
- tag->putByte(L"shake", (byte) shakeTime);
- tag->putByte(L"inGround", (byte) (inGround ? 1 : 0));
- tag->putByte(L"pickup", (byte) pickup);
+ tag->putShort(L"xTile", static_cast<short>(xTile));
+ tag->putShort(L"yTile", static_cast<short>(yTile));
+ tag->putShort(L"zTile", static_cast<short>(zTile));
+ tag->putByte(L"inTile", static_cast<byte>(lastTile));
+ tag->putByte(L"inData", static_cast<byte>(lastData));
+ tag->putByte(L"shake", static_cast<byte>(shakeTime));
+ tag->putByte(L"inGround", static_cast<byte>(inGround ? 1 : 0));
+ tag->putByte(L"pickup", static_cast<byte>(pickup));
tag->putDouble(L"damage", baseDamage);
}
@@ -503,7 +503,7 @@ void Arrow::playerTouch(shared_ptr<Player> player)
if (pickup == PICKUP_ALLOWED)
{
- if (!player->inventory->add( shared_ptr<ItemInstance>( new ItemInstance(Item::arrow, 1) ) ))
+ if (!player->inventory->add(std::make_shared<ItemInstance>(Item::arrow, 1)))
{
bRemove = false;
}
@@ -552,11 +552,11 @@ void Arrow::setCritArrow(bool critArrow)
byte flags = entityData->getByte(ID_FLAGS);
if (critArrow)
{
- entityData->set(ID_FLAGS, (byte) (flags | FLAG_CRIT));
+ entityData->set(ID_FLAGS, static_cast<byte>(flags | FLAG_CRIT));
}
else
{
- entityData->set(ID_FLAGS, (byte) (flags & ~FLAG_CRIT));
+ entityData->set(ID_FLAGS, static_cast<byte>(flags & ~FLAG_CRIT));
}
}
diff --git a/Minecraft.World/AttributeModifier.cpp b/Minecraft.World/AttributeModifier.cpp
index c479853d..17090289 100644
--- a/Minecraft.World/AttributeModifier.cpp
+++ b/Minecraft.World/AttributeModifier.cpp
@@ -61,7 +61,7 @@ AttributeModifier *AttributeModifier::setSerialize(bool serialize)
bool AttributeModifier::equals(AttributeModifier *modifier)
{
if (this == modifier) return true;
- if (modifier == NULL) return false; //|| getClass() != o.getClass()) return false;
+ if (modifier == nullptr) return false; //|| getClass() != o.getClass()) return false;
if (id != modifier->id) return false;
@@ -123,7 +123,7 @@ HtmlString AttributeModifier::getHoverText(eATTRIBUTE_ID attribute)
}
wchar_t formatted[256];
- swprintf(formatted, 256, L"%ls%d%ls %ls", (amount > 0 ? L"+" : L"-"), (int) displayAmount, (percentage ? L"%" : L""), app.GetString(Attribute::getName(attribute)));
+ swprintf(formatted, 256, L"%ls%d%ls %ls", (amount > 0 ? L"+" : L"-"), static_cast<int>(displayAmount), (percentage ? L"%" : L""), app.GetString(Attribute::getName(attribute)));
return HtmlString(formatted, color);
} \ No newline at end of file
diff --git a/Minecraft.World/AvoidPlayerGoal.cpp b/Minecraft.World/AvoidPlayerGoal.cpp
index 53aebe89..f9c6641a 100644
--- a/Minecraft.World/AvoidPlayerGoal.cpp
+++ b/Minecraft.World/AvoidPlayerGoal.cpp
@@ -33,12 +33,12 @@ AvoidPlayerGoal::AvoidPlayerGoal(PathfinderMob *mob, const type_info& avoidType,
entitySelector = new AvoidPlayerGoalEntitySelector(this);
toAvoid = weak_ptr<Entity>();
- path = NULL;
+ path = nullptr;
}
AvoidPlayerGoal::~AvoidPlayerGoal()
{
- if(path != NULL) delete path;
+ if(path != nullptr) delete path;
delete entitySelector;
}
@@ -47,9 +47,9 @@ bool AvoidPlayerGoal::canUse()
if (avoidType == typeid(Player))
{
shared_ptr<TamableAnimal> tamableAnimal = dynamic_pointer_cast<TamableAnimal>(mob->shared_from_this());
- if (tamableAnimal != NULL && tamableAnimal->isTame()) return false;
+ if (tamableAnimal != nullptr && tamableAnimal->isTame()) return false;
toAvoid = weak_ptr<Entity>(mob->level->getNearestPlayer(mob->shared_from_this(), maxDist));
- if (toAvoid.lock() == NULL) return false;
+ if (toAvoid.lock() == nullptr) return false;
}
else
{
@@ -64,24 +64,24 @@ bool AvoidPlayerGoal::canUse()
}
Vec3 *pos = RandomPos::getPosAvoid(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16, 7, Vec3::newTemp(toAvoid.lock()->x, toAvoid.lock()->y, toAvoid.lock()->z));
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
if (toAvoid.lock()->distanceToSqr(pos->x, pos->y, pos->z) < toAvoid.lock()->distanceToSqr(mob->shared_from_this())) return false;
delete path;
path = pathNav->createPath(pos->x, pos->y, pos->z);
- if (path == NULL) return false;
+ if (path == nullptr) return false;
if (!path->endsInXZ(pos)) return false;
return true;
}
bool AvoidPlayerGoal::canContinueToUse()
{
- return toAvoid.lock() != NULL && !pathNav->isDone();
+ return toAvoid.lock() != nullptr && !pathNav->isDone();
}
void AvoidPlayerGoal::start()
{
pathNav->moveTo(path, walkSpeedModifier);
- path = NULL;
+ path = nullptr;
}
void AvoidPlayerGoal::stop()
diff --git a/Minecraft.World/AwardStatPacket.cpp b/Minecraft.World/AwardStatPacket.cpp
index 43328794..07888541 100644
--- a/Minecraft.World/AwardStatPacket.cpp
+++ b/Minecraft.World/AwardStatPacket.cpp
@@ -8,7 +8,7 @@
AwardStatPacket::AwardStatPacket()
{
- this->m_paramData.data = NULL;
+ this->m_paramData.data = nullptr;
this->m_paramData.length = 0;
}
@@ -28,17 +28,17 @@ AwardStatPacket::AwardStatPacket(int statId, byteArray paramData)
AwardStatPacket::~AwardStatPacket()
{
- if (m_paramData.data != NULL)
+ if (m_paramData.data != nullptr)
{
delete [] m_paramData.data;
- m_paramData.data = NULL;
+ m_paramData.data = nullptr;
}
}
void AwardStatPacket::handle(PacketListener *listener)
{
listener->handleAwardStat(shared_from_this());
- m_paramData.data = NULL;
+ m_paramData.data = nullptr;
}
void AwardStatPacket::read(DataInputStream *dis) //throws IOException
diff --git a/Minecraft.World/AwardStatPacket.h b/Minecraft.World/AwardStatPacket.h
index 6b79c023..01cad26d 100644
--- a/Minecraft.World/AwardStatPacket.h
+++ b/Minecraft.World/AwardStatPacket.h
@@ -24,7 +24,7 @@ public:
virtual int getEstimatedSize();
virtual bool isAync();
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new AwardStatPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<AwardStatPacket>(); }
virtual int getId() { return 200; }
public:
diff --git a/Minecraft.World/BaseAttributeMap.cpp b/Minecraft.World/BaseAttributeMap.cpp
index 8fb1b1f1..151448b5 100644
--- a/Minecraft.World/BaseAttributeMap.cpp
+++ b/Minecraft.World/BaseAttributeMap.cpp
@@ -24,7 +24,7 @@ AttributeInstance *BaseAttributeMap::getInstance(eATTRIBUTE_ID id)
}
else
{
- return NULL;
+ return nullptr;
}
}
@@ -50,7 +50,7 @@ void BaseAttributeMap::removeItemModifiers(shared_ptr<ItemInstance> item)
AttributeInstance* attribute = getInstance(it.first);
AttributeModifier* modifier = it.second;
- if (attribute != NULL)
+ if (attribute != nullptr)
{
attribute->removeModifier(modifier);
}
@@ -72,7 +72,7 @@ void BaseAttributeMap::addItemModifiers(shared_ptr<ItemInstance> item)
AttributeInstance* attribute = getInstance(it.first);
AttributeModifier* modifier = it.second;
- if (attribute != NULL)
+ if (attribute != nullptr)
{
attribute->removeModifier(modifier);
attribute->addModifier(new AttributeModifier(*modifier));
diff --git a/Minecraft.World/BaseEntityTile.cpp b/Minecraft.World/BaseEntityTile.cpp
index 2edfbf92..7dc06f77 100644
--- a/Minecraft.World/BaseEntityTile.cpp
+++ b/Minecraft.World/BaseEntityTile.cpp
@@ -25,7 +25,7 @@ bool BaseEntityTile::triggerEvent(Level *level, int x, int y, int z, int b0, int
{
Tile::triggerEvent(level, x, y, z, b0, b1);
shared_ptr<TileEntity> te = level->getTileEntity(x, y, z);
- if (te != NULL)
+ if (te != nullptr)
{
return te->triggerEvent(b0, b1);
}
diff --git a/Minecraft.World/BaseMobSpawner.cpp b/Minecraft.World/BaseMobSpawner.cpp
index 0e37e444..b01aeb09 100644
--- a/Minecraft.World/BaseMobSpawner.cpp
+++ b/Minecraft.World/BaseMobSpawner.cpp
@@ -8,10 +8,10 @@
BaseMobSpawner::BaseMobSpawner()
{
- spawnPotentials = NULL;
+ spawnPotentials = nullptr;
spawnDelay = 20;
entityId = L"Pig";
- nextSpawnData = NULL;
+ nextSpawnData = nullptr;
spin = oSpin = 0.0;
minSpawnDelay = SharedConstants::TICKS_PER_SECOND * 10;
@@ -37,7 +37,7 @@ BaseMobSpawner::~BaseMobSpawner()
wstring BaseMobSpawner::getEntityId()
{
- if (getNextSpawnData() == NULL)
+ if (getNextSpawnData() == nullptr)
{
if (entityId.compare(L"Minecart") == 0)
{
@@ -58,7 +58,7 @@ void BaseMobSpawner::setEntityId(const wstring &entityId)
bool BaseMobSpawner::isNearPlayer()
{
- return getLevel()->getNearestPlayer(getX() + 0.5, getY() + 0.5, getZ() + 0.5, requiredPlayerRange) != NULL;
+ return getLevel()->getNearestPlayer(getX() + 0.5, getY() + 0.5, getZ() + 0.5, requiredPlayerRange) != nullptr;
}
void BaseMobSpawner::tick()
@@ -78,7 +78,7 @@ void BaseMobSpawner::tick()
if (spawnDelay > 0) spawnDelay--;
oSpin = spin;
- spin = (int)(spin + 1000 / (spawnDelay + 200.0f)) % 360;
+ spin = static_cast<int>(spin + 1000 / (spawnDelay + 200.0f)) % 360;
}
else
{
@@ -95,7 +95,7 @@ void BaseMobSpawner::tick()
for (int c = 0; c < spawnCount; c++)
{
shared_ptr<Entity> entity = EntityIO::newEntity(getEntityId(), getLevel());
- if (entity == NULL) return;
+ if (entity == nullptr) return;
int nearBy = getLevel()->getEntitiesOfClass( typeid(entity.get()), AABB::newTemp(getX(), getY(), getZ(), getX() + 1, getY() + 1, getZ() + 1)->grow(spawnRange * 2, 4, spawnRange * 2))->size();
if (nearBy >= maxNearbyEntities)
@@ -111,12 +111,12 @@ void BaseMobSpawner::tick()
entity->moveTo(xp, yp, zp, getLevel()->random->nextFloat() * 360, 0);
- if (mob == NULL || mob->canSpawn())
+ if (mob == nullptr || mob->canSpawn())
{
loadDataAndAddEntity(entity);
getLevel()->levelEvent(LevelEvent::PARTICLES_MOBTILE_SPAWN, getX(), getY(), getZ(), 0);
- if (mob != NULL)
+ if (mob != nullptr)
{
mob->spawnAnim();
}
@@ -131,7 +131,7 @@ void BaseMobSpawner::tick()
shared_ptr<Entity> BaseMobSpawner::loadDataAndAddEntity(shared_ptr<Entity> entity)
{
- if (getNextSpawnData() != NULL)
+ if (getNextSpawnData() != nullptr)
{
CompoundTag *data = new CompoundTag();
entity->save(data);
@@ -147,7 +147,7 @@ shared_ptr<Entity> BaseMobSpawner::loadDataAndAddEntity(shared_ptr<Entity> entit
}
entity->load(data);
- if (entity->level != NULL) entity->level->addEntity(entity);
+ if (entity->level != nullptr) entity->level->addEntity(entity);
// add mounts
shared_ptr<Entity> rider = entity;
@@ -155,7 +155,7 @@ shared_ptr<Entity> BaseMobSpawner::loadDataAndAddEntity(shared_ptr<Entity> entit
{
CompoundTag *ridingTag = data->getCompound(Entity::RIDING_TAG);
shared_ptr<Entity> mount = EntityIO::newEntity(ridingTag->getString(L"id"), entity->level);
- if (mount != NULL)
+ if (mount != nullptr)
{
CompoundTag *mountData = new CompoundTag();
mount->save(mountData);
@@ -172,7 +172,7 @@ shared_ptr<Entity> BaseMobSpawner::loadDataAndAddEntity(shared_ptr<Entity> entit
mount->load(mountData);
mount->moveTo(rider->x, rider->y, rider->z, rider->yRot, rider->xRot);
- if (entity->level != NULL) entity->level->addEntity(mount);
+ if (entity->level != nullptr) entity->level->addEntity(mount);
rider->ride(mount);
}
rider = mount;
@@ -180,9 +180,9 @@ shared_ptr<Entity> BaseMobSpawner::loadDataAndAddEntity(shared_ptr<Entity> entit
}
}
- else if (entity->instanceof(eTYPE_LIVINGENTITY) && entity->level != NULL)
+ else if (entity->instanceof(eTYPE_LIVINGENTITY) && entity->level != nullptr)
{
- dynamic_pointer_cast<Mob>( entity )->finalizeMobSpawn(NULL);
+ dynamic_pointer_cast<Mob>( entity )->finalizeMobSpawn(nullptr);
getLevel()->addEntity(entity);
}
@@ -200,9 +200,9 @@ void BaseMobSpawner::delay()
spawnDelay = minSpawnDelay + getLevel()->random->nextInt(maxSpawnDelay - minSpawnDelay);
}
- if ( (spawnPotentials != NULL) && (spawnPotentials->size() > 0) )
+ if ( (spawnPotentials != nullptr) && (spawnPotentials->size() > 0) )
{
- setNextSpawnData( (SpawnData*) WeighedRandom::getRandomItem((Random*)getLevel()->random, (vector<WeighedRandomItem*>*)spawnPotentials) );
+ setNextSpawnData( static_cast<SpawnData *>(WeighedRandom::getRandomItem((Random *)getLevel()->random, (vector<WeighedRandomItem *> *)spawnPotentials)) );
}
broadcastEvent(EVENT_SPAWN);
@@ -225,7 +225,7 @@ void BaseMobSpawner::load(CompoundTag *tag)
}
else
{
- spawnPotentials = NULL;
+ spawnPotentials = nullptr;
}
if (tag->contains(L"SpawnData"))
@@ -234,7 +234,7 @@ void BaseMobSpawner::load(CompoundTag *tag)
}
else
{
- setNextSpawnData(NULL);
+ setNextSpawnData(nullptr);
}
if (tag->contains(L"MinSpawnDelay"))
@@ -252,7 +252,7 @@ void BaseMobSpawner::load(CompoundTag *tag)
if (tag->contains(L"SpawnRange")) spawnRange = tag->getShort(L"SpawnRange");
- if (getLevel() != NULL && getLevel()->isClientSide)
+ if (getLevel() != nullptr && getLevel()->isClientSide)
{
displayEntity = nullptr;
}
@@ -261,20 +261,20 @@ void BaseMobSpawner::load(CompoundTag *tag)
void BaseMobSpawner::save(CompoundTag *tag)
{
tag->putString(L"EntityId", getEntityId());
- tag->putShort(L"Delay", (short) spawnDelay);
- tag->putShort(L"MinSpawnDelay", (short) minSpawnDelay);
- tag->putShort(L"MaxSpawnDelay", (short) maxSpawnDelay);
- tag->putShort(L"SpawnCount", (short) spawnCount);
- tag->putShort(L"MaxNearbyEntities", (short) maxNearbyEntities);
- tag->putShort(L"RequiredPlayerRange", (short) requiredPlayerRange);
- tag->putShort(L"SpawnRange", (short) spawnRange);
-
- if (getNextSpawnData() != NULL)
+ tag->putShort(L"Delay", static_cast<short>(spawnDelay));
+ tag->putShort(L"MinSpawnDelay", static_cast<short>(minSpawnDelay));
+ tag->putShort(L"MaxSpawnDelay", static_cast<short>(maxSpawnDelay));
+ tag->putShort(L"SpawnCount", static_cast<short>(spawnCount));
+ tag->putShort(L"MaxNearbyEntities", static_cast<short>(maxNearbyEntities));
+ tag->putShort(L"RequiredPlayerRange", static_cast<short>(requiredPlayerRange));
+ tag->putShort(L"SpawnRange", static_cast<short>(spawnRange));
+
+ if (getNextSpawnData() != nullptr)
{
- tag->putCompound(L"SpawnData", (CompoundTag *) getNextSpawnData()->tag->copy());
+ tag->putCompound(L"SpawnData", static_cast<CompoundTag *>(getNextSpawnData()->tag->copy()));
}
- if (getNextSpawnData() != NULL || (spawnPotentials != NULL && spawnPotentials->size() > 0))
+ if (getNextSpawnData() != nullptr || (spawnPotentials != nullptr && spawnPotentials->size() > 0))
{
ListTag<CompoundTag> *list = new ListTag<CompoundTag>();
@@ -296,9 +296,9 @@ void BaseMobSpawner::save(CompoundTag *tag)
shared_ptr<Entity> BaseMobSpawner::getDisplayEntity()
{
- if (displayEntity == NULL)
+ if (displayEntity == nullptr)
{
- shared_ptr<Entity> e = EntityIO::newEntity(getEntityId(), NULL);
+ shared_ptr<Entity> e = EntityIO::newEntity(getEntityId(), nullptr);
e = loadDataAndAddEntity(e);
displayEntity = e;
}
@@ -333,7 +333,7 @@ BaseMobSpawner::SpawnData::SpawnData(CompoundTag *base) : WeighedRandomItem(base
if (_type.compare(L"Minecart") == 0)
{
- if (tag != NULL)
+ if (tag != nullptr)
{
switch (tag->getInt(L"Type"))
{
@@ -362,7 +362,7 @@ BaseMobSpawner::SpawnData::SpawnData(CompoundTag *tag, wstring _type) : WeighedR
{
if (_type.compare(L"Minecart") == 0)
{
- if (tag != NULL)
+ if (tag != nullptr)
{
switch (tag->getInt(L"Type"))
{
diff --git a/Minecraft.World/BasePressurePlateTile.cpp b/Minecraft.World/BasePressurePlateTile.cpp
index 128a4216..cd4c821c 100644
--- a/Minecraft.World/BasePressurePlateTile.cpp
+++ b/Minecraft.World/BasePressurePlateTile.cpp
@@ -43,7 +43,7 @@ int BasePressurePlateTile::getTickDelay(Level *level)
AABB *BasePressurePlateTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
bool BasePressurePlateTile::isSolidRender(bool isServerLevel)
diff --git a/Minecraft.World/BaseRailTile.cpp b/Minecraft.World/BaseRailTile.cpp
index db854bb3..0494e266 100644
--- a/Minecraft.World/BaseRailTile.cpp
+++ b/Minecraft.World/BaseRailTile.cpp
@@ -19,7 +19,7 @@ BaseRailTile::Rail::Rail(Level *level, int x, int y, int z)
if(m_bValidRail)
{
int direction = level->getData(x, y, z);
- if (((BaseRailTile *) Tile::tiles[id])->usesDataBit)
+ if (static_cast<BaseRailTile *>(Tile::tiles[id])->usesDataBit)
{
usesDataBit = true;
direction = direction & ~RAIL_DATA_BIT;
@@ -34,7 +34,7 @@ BaseRailTile::Rail::Rail(Level *level, int x, int y, int z)
BaseRailTile::Rail::~Rail()
{
- for( int i = 0; i < connections.size(); i++ )
+ for( size_t i = 0; i < connections.size(); i++ )
{
delete connections[i];
}
@@ -44,7 +44,7 @@ void BaseRailTile::Rail::updateConnections(int direction)
{
if(m_bValidRail)
{
- for( int i = 0; i < connections.size(); i++ )
+ for( size_t i = 0; i < connections.size(); i++ )
{
delete connections[i];
}
@@ -102,7 +102,7 @@ void BaseRailTile::Rail::removeSoftConnections()
for (unsigned int i = 0; i < connections.size(); i++)
{
Rail *rail = getRail(connections[i]);
- if (rail == NULL || !rail->connectsTo(this))
+ if (rail == nullptr || !rail->connectsTo(this))
{
delete connections[i];
connections.erase(connections.begin()+i);
@@ -130,11 +130,11 @@ bool BaseRailTile::Rail::hasRail(int x, int y, int z)
BaseRailTile::Rail *BaseRailTile::Rail::getRail(TilePos *p)
{
- if(!m_bValidRail) return NULL;
+ if(!m_bValidRail) return nullptr;
if (isRail(level, p->x, p->y, p->z)) return new Rail(level, p->x, p->y, p->z);
if (isRail(level, p->x, p->y + 1, p->z)) return new Rail(level, p->x, p->y + 1, p->z);
if (isRail(level, p->x, p->y - 1, p->z)) return new Rail(level, p->x, p->y - 1, p->z);
- return NULL;
+ return nullptr;
}
@@ -253,7 +253,7 @@ bool BaseRailTile::Rail::hasNeighborRail(int x, int y, int z)
if(!m_bValidRail) return false;
TilePos tp(x,y,z);
Rail *neighbor = getRail( &tp );
- if (neighbor == NULL) return false;
+ if (neighbor == nullptr) return false;
neighbor->removeSoftConnections();
bool retval = neighbor->canConnectTo(this);
delete neighbor;
@@ -331,7 +331,7 @@ void BaseRailTile::Rail::place(bool hasSignal, bool first)
for ( auto& it : connections )
{
Rail *neighbor = getRail(it);
- if (neighbor == NULL) continue;
+ if (neighbor == nullptr) continue;
neighbor->removeSoftConnections();
if (neighbor->canConnectTo(this))
@@ -359,7 +359,7 @@ BaseRailTile::BaseRailTile(int id, bool usesDataBit) : Tile(id, Material::decora
this->usesDataBit = usesDataBit;
setShape(0, 0, 0, 1, 2 / 16.0f, 1);
- iconTurn = NULL;
+ iconTurn = nullptr;
}
bool BaseRailTile::isUsesDataBit()
@@ -369,7 +369,7 @@ bool BaseRailTile::isUsesDataBit()
AABB *BaseRailTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
bool BaseRailTile::blocksLight()
diff --git a/Minecraft.World/BasicTree.cpp b/Minecraft.World/BasicTree.cpp
index c1c92287..fc08a5f7 100644
--- a/Minecraft.World/BasicTree.cpp
+++ b/Minecraft.World/BasicTree.cpp
@@ -34,7 +34,7 @@ BasicTree::BasicTree(bool doUpdate) : Feature(doUpdate)
trunkWidth = 1;
heightVariance = 12;
foliageHeight = 4;
- foliageCoords = NULL;
+ foliageCoords = nullptr;
foliageCoordsLength = 0;
}
@@ -44,9 +44,9 @@ void BasicTree::prepare()
// Populate the list of foliage cluster locations.
// Designed to be overridden in child classes to change basic
// tree properties (trunk width, branch angle, foliage density, etc..).
- trunkHeight = (int) (height * trunkHeightScale);
+ trunkHeight = static_cast<int>(height * trunkHeightScale);
if (trunkHeight >= height) trunkHeight = height - 1;
- int clustersPerY = (int) (1.382 + pow(foliageDensity * height / 13.0, 2));
+ int clustersPerY = static_cast<int>(1.382 + pow(foliageDensity * height / 13.0, 2));
if (clustersPerY < 1) clustersPerY = 1;
// The foliage coordinates are a list of [x,y,z,y of branch base] values for each cluster
int **tempFoliageCoords = new int *[clustersPerY * height];
@@ -100,7 +100,7 @@ void BasicTree::prepare()
}
else
{
- checkBranchBase[1] = (int) (checkStart[1] - branchHeight);
+ checkBranchBase[1] = static_cast<int>(checkStart[1] - branchHeight);
}
// Now check the branch path
if (checkLine(checkBranchBase, checkStart) == -1)
@@ -126,7 +126,7 @@ void BasicTree::prepare()
for( int i = clusterCount; i < clustersPerY * height; i++ )
{
delete [] tempFoliageCoords[i];
- tempFoliageCoords[i] = NULL;
+ tempFoliageCoords[i] = nullptr;
}
// 4J - original code for above is the following, it isn't obvious to me why it is doing a copy of the array, so let's not for now
// foliageCoords = new int[clusterCount][4];
@@ -147,7 +147,7 @@ void BasicTree::crossection(int x, int y, int z, float radius, byte direction, i
// radius is the radius of the section from the center
// direction is the direction the cross section is pointed, 0 for x, 1 for y, 2 for z
// material is the index number for the material to use
- int rad = (int) (radius + 0.618);
+ int rad = static_cast<int>(radius + 0.618);
byte secidx1 = axisConversionArray[direction];
byte secidx2 = axisConversionArray[direction + 3];
int center[] = { x, y, z };
@@ -197,15 +197,15 @@ float BasicTree::treeShape(int y)
// This method is intended for overriding in child classes, allowing
// different shaped trees.
// This method should return a consistent value for each y (don't randomize).
- if (y < (((float) height) * 0.3)) return (float) -1.618;
- float radius = ((float) height) / ((float) 2.0);
- float adjacent = (((float) height) / ((float) 2.0)) - y;
+ if (y < (static_cast<float>(height) * 0.3)) return (float) -1.618;
+ float radius = static_cast<float>(height) / static_cast<float>(2.0);
+ float adjacent = (static_cast<float>(height) / static_cast<float>(2.0)) - y;
float distance;
if (adjacent == 0) distance = radius;
- else if (abs(adjacent) >= radius) distance = (float) 0.0;
- else distance = (float) sqrt(pow(abs(radius), 2) - pow(abs(adjacent), 2));
+ else if (abs(adjacent) >= radius) distance = static_cast<float>(0.0);
+ else distance = static_cast<float>(sqrt(pow(abs(radius), 2) - pow(abs(adjacent), 2)));
// Alter this factor to change the overall width of the tree.
- distance *= (float) 0.5;
+ distance *= static_cast<float>(0.5);
return distance;
}
@@ -216,9 +216,9 @@ float BasicTree::foliageShape(int y)
// Return a negative number if no foliage should be created at this level
// this method is intended for overriding in child classes, allowing
// foliage of different sizes and shapes.
- if ((y < 0) || (y >= foliageHeight)) return (float) -1;
- else if ((y == 0) || (y == (foliageHeight - 1))) return (float) 2;
- else return (float) 3;
+ if ((y < 0) || (y >= foliageHeight)) return static_cast<float>(-1);
+ else if ((y == 0) || (y == (foliageHeight - 1))) return static_cast<float>(2);
+ else return static_cast<float>(3);
}
void BasicTree::foliageCluster(int x, int y, int z)
@@ -270,8 +270,8 @@ void BasicTree::limb(int *start, int *end, int material)
if (delta[primidx] > 0) primsign = 1;
else primsign = -1;
// Initilize the per-step movement for the non-primary axies.
- double secfac1 = ((double) delta[secidx1]) / ((double) delta[primidx]);
- double secfac2 = ((double) delta[secidx2]) / ((double) delta[primidx]);
+ double secfac1 = static_cast<double>(delta[secidx1]) / static_cast<double>(delta[primidx]);
+ double secfac2 = static_cast<double>(delta[secidx2]) / static_cast<double>(delta[primidx]);
// Initialize the coordinates.
int coordinate[] = { 0, 0, 0 };
// Loop through each crossection along the primary axis, from start to end
@@ -411,8 +411,8 @@ int BasicTree::checkLine(int *start, int *end)
if (delta[primidx] > 0) primsign = 1;
else primsign = -1;
// Initilize the per-step movement for the non-primary axies.
- double secfac1 = ((double) delta[secidx1]) / ((double) delta[primidx]);
- double secfac2 = ((double) delta[secidx2]) / ((double) delta[primidx]);
+ double secfac1 = static_cast<double>(delta[secidx1]) / static_cast<double>(delta[primidx]);
+ double secfac2 = static_cast<double>(delta[secidx2]) / static_cast<double>(delta[primidx]);
// Initialize the coordinates.
int coordinate[] = { 0, 0, 0 };
// Loop through each crossection along the primary axis, from start to end
@@ -460,7 +460,7 @@ bool BasicTree::checkLocation()
int endPosition[] = { origin[0], origin[1] + height - 1, origin[2] };
// 4J Stu Added to stop tree features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
bool intersects = levelGenOptions->checkIntersects(startPosition[0], startPosition[1], startPosition[2], endPosition[0], endPosition[1], endPosition[2]);
@@ -507,7 +507,7 @@ void BasicTree::init(double heightInit, double widthInit, double foliageDensityI
//
// Note, you can call "place" without calling "init".
// This is the same as calling init(1.0,1.0,1.0) and then calling place.
- heightVariance = (int) (heightInit * 12);
+ heightVariance = static_cast<int>(heightInit * 12);
if (heightInit > 0.5) foliageHeight = 5;
widthScale = widthInit;
foliageDensity = foliageDensityInit;
diff --git a/Minecraft.World/BasicTypeContainers.cpp b/Minecraft.World/BasicTypeContainers.cpp
index 9ecc865c..ba2359d8 100644
--- a/Minecraft.World/BasicTypeContainers.cpp
+++ b/Minecraft.World/BasicTypeContainers.cpp
@@ -18,5 +18,5 @@ const double Double::MIN_NORMAL = DBL_MIN;
int Integer::parseInt(wstring &str, int radix /* = 10*/)
{
- return wcstol( str.c_str(), NULL, radix );
+ return wcstol( str.c_str(), nullptr, radix );
} \ No newline at end of file
diff --git a/Minecraft.World/Bat.cpp b/Minecraft.World/Bat.cpp
index d3bd3521..462fef57 100644
--- a/Minecraft.World/Bat.cpp
+++ b/Minecraft.World/Bat.cpp
@@ -15,7 +15,7 @@ Bat::Bat(Level *level) : AmbientCreature(level)
registerAttributes();
setHealth(getMaxHealth());
- targetPosition = NULL;
+ targetPosition = nullptr;
setSize(.5f, .9f);
setResting(true);
@@ -90,11 +90,11 @@ void Bat::setResting(bool value)
char current = entityData->getByte(DATA_ID_FLAGS);
if (value)
{
- entityData->set(DATA_ID_FLAGS, (char) (current | FLAG_RESTING));
+ entityData->set(DATA_ID_FLAGS, static_cast<char>(current | FLAG_RESTING));
}
else
{
- entityData->set(DATA_ID_FLAGS, (char) (current & ~FLAG_RESTING));
+ entityData->set(DATA_ID_FLAGS, static_cast<char>(current & ~FLAG_RESTING));
}
}
@@ -128,10 +128,10 @@ void Bat::newServerAiStep()
if (isResting())
{
- if (!level->isSolidBlockingTile(Mth::floor(x), (int) y + 1, Mth::floor(z)))
+ if (!level->isSolidBlockingTile(Mth::floor(x), static_cast<int>(y) + 1, Mth::floor(z)))
{
setResting(false);
- level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, (int) x, (int) y, (int) z, 0);
+ level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
}
else
{
@@ -141,25 +141,25 @@ 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);
+ level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
}
}
}
else
{
- if (targetPosition != NULL && (!level->isEmptyTile(targetPosition->x, targetPosition->y, targetPosition->z) || targetPosition->y < 1))
+ if (targetPosition != nullptr && (!level->isEmptyTile(targetPosition->x, targetPosition->y, targetPosition->z) || targetPosition->y < 1))
{
delete targetPosition;
- targetPosition = NULL;
+ targetPosition = nullptr;
}
- if (targetPosition == NULL || random->nextInt(30) == 0 || targetPosition->distSqr((int) x, (int) y, (int) z) < 4)
+ if (targetPosition == nullptr || random->nextInt(30) == 0 || targetPosition->distSqr(static_cast<int>(x), static_cast<int>(y), static_cast<int>(z)) < 4)
{
delete targetPosition;
- targetPosition = new Pos((int) x + random->nextInt(7) - random->nextInt(7), (int) y + random->nextInt(6) - 2, (int) z + random->nextInt(7) - random->nextInt(7));
+ targetPosition = new Pos(static_cast<int>(x) + random->nextInt(7) - random->nextInt(7), static_cast<int>(y) + random->nextInt(6) - 2, static_cast<int>(z) + random->nextInt(7) - random->nextInt(7));
}
double dx = (targetPosition->x + .5) - x;
@@ -170,12 +170,12 @@ void Bat::newServerAiStep()
yd = yd + (signum(dy) * .7f - yd) * .1f;
zd = zd + (signum(dz) * .5f - zd) * .1f;
- float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90;
+ float yRotD = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
float rotDiff = Mth::wrapDegrees(yRotD - yRot);
yya = .5f;
yRot += rotDiff;
- if (random->nextInt(100) == 0 && level->isSolidBlockingTile(Mth::floor(x), (int) y + 1, Mth::floor(z)))
+ if (random->nextInt(100) == 0 && level->isSolidBlockingTile(Mth::floor(x), static_cast<int>(y) + 1, Mth::floor(z)))
{
setResting(true);
}
diff --git a/Minecraft.World/BeachBiome.cpp b/Minecraft.World/BeachBiome.cpp
index 50e7cc1c..475f8468 100644
--- a/Minecraft.World/BeachBiome.cpp
+++ b/Minecraft.World/BeachBiome.cpp
@@ -8,8 +8,8 @@ BeachBiome::BeachBiome(int id) : Biome(id)
// remove default mob spawn settings
friendlies.clear();
friendlies_chicken.clear(); // 4J added
- topMaterial = (byte) Tile::sand_Id;
- material = (byte) Tile::sand_Id;
+ topMaterial = static_cast<byte>(Tile::sand_Id);
+ material = static_cast<byte>(Tile::sand_Id);
decorator->treeCount = -999;
decorator->deadBushCount = 0;
diff --git a/Minecraft.World/BeaconMenu.cpp b/Minecraft.World/BeaconMenu.cpp
index 62908b4f..0d7e54b4 100644
--- a/Minecraft.World/BeaconMenu.cpp
+++ b/Minecraft.World/BeaconMenu.cpp
@@ -60,7 +60,7 @@ shared_ptr<ItemInstance> BeaconMenu::quickMoveStack(shared_ptr<Player> player, i
{
shared_ptr<ItemInstance> clicked = nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
@@ -127,7 +127,7 @@ BeaconMenu::PaymentSlot::PaymentSlot(shared_ptr<Container> container, int slot,
bool BeaconMenu::PaymentSlot::mayPlace(shared_ptr<ItemInstance> item)
{
- if (item != NULL)
+ if (item != nullptr)
{
return (item->id == Item::emerald_Id || item->id == Item::diamond_Id || item->id == Item::goldIngot_Id || item->id == Item::ironIngot_Id);
}
diff --git a/Minecraft.World/BeaconTile.cpp b/Minecraft.World/BeaconTile.cpp
index f002cbe2..04b17d11 100644
--- a/Minecraft.World/BeaconTile.cpp
+++ b/Minecraft.World/BeaconTile.cpp
@@ -11,7 +11,7 @@ BeaconTile::BeaconTile(int id) : BaseEntityTile(id, Material::glass, isSolidRend
shared_ptr<TileEntity> BeaconTile::newTileEntity(Level *level)
{
- return shared_ptr<BeaconTileEntity>( new BeaconTileEntity() );
+ return std::make_shared<BeaconTileEntity>();
}
bool BeaconTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly)
@@ -19,7 +19,7 @@ bool BeaconTile::use(Level *level, int x, int y, int z, shared_ptr<Player> playe
if (level->isClientSide) return true;
shared_ptr<BeaconTileEntity> beacon = dynamic_pointer_cast<BeaconTileEntity>( level->getTileEntity(x, y, z) );
- if (beacon != NULL) player->openBeacon(beacon);
+ if (beacon != nullptr) player->openBeacon(beacon);
return true;
}
diff --git a/Minecraft.World/BeaconTileEntity.cpp b/Minecraft.World/BeaconTileEntity.cpp
index d80eb906..633930f4 100644
--- a/Minecraft.World/BeaconTileEntity.cpp
+++ b/Minecraft.World/BeaconTileEntity.cpp
@@ -10,7 +10,7 @@
shared_ptr<TileEntity> BeaconTileEntity::clone()
{
- shared_ptr<BeaconTileEntity> result = shared_ptr<BeaconTileEntity>( new BeaconTileEntity() );
+ shared_ptr<BeaconTileEntity> result = std::make_shared<BeaconTileEntity>();
TileEntity::clone(result);
result->primaryPower = primaryPower;
@@ -28,7 +28,7 @@ void BeaconTileEntity::staticCtor()
{
for(unsigned int effect = 0; effect < BEACON_EFFECTS_EFFECTS; ++effect)
{
- BEACON_EFFECTS[tier][effect] = NULL;
+ BEACON_EFFECTS[tier][effect] = nullptr;
}
}
BEACON_EFFECTS[0][0] = MobEffect::movementSpeed;
@@ -163,18 +163,18 @@ float BeaconTileEntity::getAndUpdateClientSideScale()
return 0;
}
- int renderDelta = (int) (level->getGameTime() - clientSideRenderTick);
+ int renderDelta = static_cast<int>(level->getGameTime() - clientSideRenderTick);
clientSideRenderTick = level->getGameTime();
if (renderDelta > 1)
{
- clientSideRenderScale -= ((float) renderDelta / (float) SCALE_TIME);
+ clientSideRenderScale -= (static_cast<float>(renderDelta) / static_cast<float>(SCALE_TIME));
if (clientSideRenderScale < 0)
{
clientSideRenderScale = 0;
}
}
- clientSideRenderScale += (1.0f / (float) SCALE_TIME);
+ clientSideRenderScale += (1.0f / static_cast<float>(SCALE_TIME));
if (clientSideRenderScale > 1)
{
clientSideRenderScale = 1;
@@ -213,7 +213,7 @@ void BeaconTileEntity::setPrimaryPower(int primaryPower)
for(unsigned int e = 0; e < BEACON_EFFECTS_EFFECTS; ++e)
{
MobEffect *effect = BEACON_EFFECTS[tier][e];
- if(effect == NULL) break;
+ if(effect == nullptr) break;
if (effect->id == primaryPower)
{
@@ -236,7 +236,7 @@ void BeaconTileEntity::setSecondaryPower(int secondaryPower)
for(unsigned int e = 0; e < BEACON_EFFECTS_EFFECTS; ++e)
{
MobEffect *effect = BEACON_EFFECTS[tier][e];
- if(effect == NULL) break;
+ if(effect == nullptr) break;
if (effect->id == secondaryPower)
{
@@ -252,7 +252,7 @@ shared_ptr<Packet> BeaconTileEntity::getUpdatePacket()
{
CompoundTag *tag = new CompoundTag();
save(tag);
- return shared_ptr<TileEntityDataPacket>( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_BEACON, tag) );
+ return std::make_shared<TileEntityDataPacket>(x, y, z, TileEntityDataPacket::TYPE_BEACON, tag);
}
double BeaconTileEntity::getViewDistance()
@@ -295,7 +295,7 @@ shared_ptr<ItemInstance> BeaconTileEntity::getItem(unsigned int slot)
shared_ptr<ItemInstance> BeaconTileEntity::removeItem(unsigned int slot, int count)
{
- if (slot == 0 && paymentItem != NULL)
+ if (slot == 0 && paymentItem != nullptr)
{
if (count >= paymentItem->count)
{
@@ -306,7 +306,7 @@ shared_ptr<ItemInstance> BeaconTileEntity::removeItem(unsigned int slot, int cou
else
{
paymentItem->count -= count;
- return shared_ptr<ItemInstance>( new ItemInstance(paymentItem->id, count, paymentItem->getAuxValue()) );
+ return std::make_shared<ItemInstance>(paymentItem->id, count, paymentItem->getAuxValue());
}
}
return nullptr;
@@ -314,7 +314,7 @@ shared_ptr<ItemInstance> BeaconTileEntity::removeItem(unsigned int slot, int cou
shared_ptr<ItemInstance> BeaconTileEntity::removeItemNoUpdate(int slot)
{
- if (slot == 0 && paymentItem != NULL)
+ if (slot == 0 && paymentItem != nullptr)
{
shared_ptr<ItemInstance> returnItem = paymentItem;
paymentItem = nullptr;
diff --git a/Minecraft.World/BedItem.cpp b/Minecraft.World/BedItem.cpp
index a55f277e..c8765b74 100644
--- a/Minecraft.World/BedItem.cpp
+++ b/Minecraft.World/BedItem.cpp
@@ -24,7 +24,7 @@ bool BedItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> pl
// place on top of tile
y = y + 1;
- BedTile *tile = (BedTile *) Tile::bed;
+ BedTile *tile = static_cast<BedTile *>(Tile::bed);
int dir = ( Mth::floor(player->yRot * 4 / (360) + 0.5f) ) & 3;
int xra = 0;
diff --git a/Minecraft.World/BedTile.cpp b/Minecraft.World/BedTile.cpp
index 039943bd..5597f740 100644
--- a/Minecraft.World/BedTile.cpp
+++ b/Minecraft.World/BedTile.cpp
@@ -16,9 +16,9 @@ BedTile::BedTile(int id) : DirectionalTile(id, Material::cloth, isSolidRender())
{
setShape();
- iconEnd = NULL;
- iconSide = NULL;
- iconTop = NULL;
+ iconEnd = nullptr;
+ iconSide = nullptr;
+ iconTop = nullptr;
}
// 4J Added override
@@ -120,7 +120,7 @@ bool BedTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player,
}
}
- if (sleepingPlayer == NULL)
+ if (sleepingPlayer == nullptr)
{
setOccupied(level, x, y, z, false);
}
@@ -309,7 +309,7 @@ Pos *BedTile::findStandUpPosition(Level *level, int x, int y, int z, int skipCou
}
}
- return NULL;
+ return nullptr;
}
void BedTile::spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonus)
diff --git a/Minecraft.World/BegGoal.cpp b/Minecraft.World/BegGoal.cpp
index 97553928..3f059b66 100644
--- a/Minecraft.World/BegGoal.cpp
+++ b/Minecraft.World/BegGoal.cpp
@@ -20,14 +20,14 @@ BegGoal::BegGoal(Wolf *wolf, float lookDistance)
bool BegGoal::canUse()
{
player = weak_ptr<Player>(level->getNearestPlayer(wolf->shared_from_this(), lookDistance));
- if (player.lock() == NULL) return false;
+ if (player.lock() == nullptr) return false;
wolf->setDespawnProtected();
return playerHoldingInteresting(player.lock());
}
bool BegGoal::canContinueToUse()
{
- if (player.lock() == NULL || !player.lock()->isAlive()) return false;
+ if (player.lock() == nullptr || !player.lock()->isAlive()) return false;
if (wolf->distanceToSqr(player.lock()) > lookDistance * lookDistance) return false;
wolf->setDespawnProtected();
return lookTime > 0 && playerHoldingInteresting(player.lock());
@@ -54,7 +54,7 @@ void BegGoal::tick()
bool BegGoal::playerHoldingInteresting(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> item = player->inventory->getSelected();
- if (item == NULL) return false;
+ if (item == nullptr) return false;
if (!wolf->isTame() && item->id == Item::bone_Id) return true;
return wolf->isFood(item);
} \ No newline at end of file
diff --git a/Minecraft.World/BinaryHeap.cpp b/Minecraft.World/BinaryHeap.cpp
index 3a3d1c1e..4fc5ce45 100644
--- a/Minecraft.World/BinaryHeap.cpp
+++ b/Minecraft.World/BinaryHeap.cpp
@@ -58,7 +58,7 @@ Node *BinaryHeap::pop()
{
Node *popped = heap[0];
heap[0] = heap[--sizeVar];
- heap[sizeVar] = NULL;
+ heap[sizeVar] = nullptr;
if (sizeVar > 0) downHeap(0);
popped->heapIdx=-1;
return popped;
@@ -68,7 +68,7 @@ void BinaryHeap::remove(Node *node)
{
// This is what node.heapIdx is for.
heap[node->heapIdx] = heap[--sizeVar];
- heap[sizeVar] = NULL;
+ heap[sizeVar] = nullptr;
if (sizeVar > node->heapIdx)
{
if (heap[node->heapIdx]->f < node->f)
@@ -145,7 +145,7 @@ void BinaryHeap::downHeap(int idx)
if (rightIdx >= sizeVar)
{
// Only need to compare with left.
- rightNode = NULL;
+ rightNode = nullptr;
rightCost = Float::POSITIVE_INFINITY;
}
else
diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp
index 169db77e..66265765 100644
--- a/Minecraft.World/Biome.cpp
+++ b/Minecraft.World/Biome.cpp
@@ -13,34 +13,34 @@
//public static final Biome[] biomes = new Biome[256];
Biome *Biome::biomes[256];
-Biome *Biome::ocean = NULL;
-Biome *Biome::plains = NULL;
-Biome *Biome::desert = NULL;
+Biome *Biome::ocean = nullptr;
+Biome *Biome::plains = nullptr;
+Biome *Biome::desert = nullptr;
-Biome *Biome::extremeHills = NULL;
-Biome *Biome::forest = NULL;
-Biome *Biome::taiga = NULL;
+Biome *Biome::extremeHills = nullptr;
+Biome *Biome::forest = nullptr;
+Biome *Biome::taiga = nullptr;
-Biome *Biome::swampland = NULL;
-Biome *Biome::river = NULL;
+Biome *Biome::swampland = nullptr;
+Biome *Biome::river = nullptr;
-Biome *Biome::hell = NULL;
-Biome *Biome::sky = NULL;
+Biome *Biome::hell = nullptr;
+Biome *Biome::sky = nullptr;
-Biome *Biome::frozenOcean = NULL;
-Biome *Biome::frozenRiver = NULL;
-Biome *Biome::iceFlats = NULL;
-Biome *Biome::iceMountains = NULL;
-Biome *Biome::mushroomIsland = NULL;
-Biome *Biome::mushroomIslandShore = NULL;
-Biome *Biome::beaches = NULL;
-Biome *Biome::desertHills = NULL;
-Biome *Biome::forestHills = NULL;
-Biome *Biome::taigaHills = NULL;
-Biome *Biome::smallerExtremeHills = NULL;
+Biome *Biome::frozenOcean = nullptr;
+Biome *Biome::frozenRiver = nullptr;
+Biome *Biome::iceFlats = nullptr;
+Biome *Biome::iceMountains = nullptr;
+Biome *Biome::mushroomIsland = nullptr;
+Biome *Biome::mushroomIslandShore = nullptr;
+Biome *Biome::beaches = nullptr;
+Biome *Biome::desertHills = nullptr;
+Biome *Biome::forestHills = nullptr;
+Biome *Biome::taigaHills = nullptr;
+Biome *Biome::smallerExtremeHills = nullptr;
-Biome *Biome::jungle = NULL;
-Biome *Biome::jungleHills = NULL;
+Biome *Biome::jungle = nullptr;
+Biome *Biome::jungleHills = nullptr;
void Biome::staticCtor()
@@ -86,8 +86,8 @@ Biome::Biome(int id) : id(id)
color = 0;
// snowCovered = false; // 4J - this isn't set by the java game any more so removing to save confusion
- topMaterial = (byte) Tile::grass_Id;
- material = (byte) Tile::dirt_Id;
+ topMaterial = static_cast<byte>(Tile::grass_Id);
+ material = static_cast<byte>(Tile::dirt_Id);
leafColor = 0x4EE031;
_hasRain = true;
depth = 0.1f;
@@ -95,7 +95,7 @@ Biome::Biome(int id) : id(id)
temperature = 0.5f;
downfall = 0.5f;
//waterColor = 0xffffff; // 4J Stu - Not used
- decorator = NULL;
+ decorator = nullptr;
m_grassColor = eMinecraftColour_NOT_SET;
m_foliageColor = eMinecraftColour_NOT_SET;
@@ -132,7 +132,7 @@ Biome::Biome(int id) : id(id)
Biome::~Biome()
{
- if(decorator != NULL) delete decorator;
+ if(decorator != nullptr) delete decorator;
}
BiomeDecorator *Biome::createDecorator()
@@ -228,7 +228,7 @@ vector<Biome::MobSpawnerData *> *Biome::getMobs(MobCategory *category)
if (category == MobCategory::creature_wolf) return &friendlies_wolf;
if (category == MobCategory::creature_mushroomcow) return &friendlies_mushroomcow;
if (category == MobCategory::ambient) return &ambientFriendlies;
- return NULL;
+ return nullptr;
}
bool Biome::hasSnow()
@@ -261,12 +261,12 @@ float Biome::getCreatureProbability()
int Biome::getDownfallInt()
{
- return (int) (downfall * 65536);
+ return static_cast<int>(downfall * 65536);
}
int Biome::getTemperatureInt()
{
- return (int) (temperature * 65536);
+ return static_cast<int>(temperature * 65536);
}
// 4J - brought forward from 1.2.3
diff --git a/Minecraft.World/BiomeCache.cpp b/Minecraft.World/BiomeCache.cpp
index 54be445c..286e2f7e 100644
--- a/Minecraft.World/BiomeCache.cpp
+++ b/Minecraft.World/BiomeCache.cpp
@@ -10,7 +10,7 @@ BiomeCache::Block::Block(int x, int z, BiomeCache *parent)
// temps = floatArray(ZONE_SIZE * ZONE_SIZE, false); // MGH - added "no clear" flag to arrayWithLength
// downfall = floatArray(ZONE_SIZE * ZONE_SIZE, false);
// biomes = BiomeArray(ZONE_SIZE * ZONE_SIZE, false);
- biomeIndices = byteArray(ZONE_SIZE * ZONE_SIZE, false);
+ biomeIndices = byteArray(static_cast<unsigned int>(ZONE_SIZE * ZONE_SIZE), false);
lastUse = 0;
this->x = x;
@@ -34,7 +34,7 @@ Biome *BiomeCache::Block::getBiome(int x, int z)
{
// return biomes[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)];
- int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)];
+ const int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)];
return Biome::biomes[biomeIndex];
}
@@ -42,7 +42,7 @@ float BiomeCache::Block::getTemperature(int x, int z)
{
// return temps[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)];
- int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)];
+ const int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)];
return Biome::biomes[biomeIndex]->getTemperature();
}
@@ -51,7 +51,7 @@ float BiomeCache::Block::getDownfall(int x, int z)
{
// return downfall[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)];
- int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)];
+ const int biomeIndex = biomeIndices[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << ZONE_SIZE_BITS)];
return Biome::biomes[biomeIndex]->getDownfall();
}
@@ -72,7 +72,7 @@ BiomeCache::~BiomeCache()
// 4J Stu - Delete source?
// delete source;
- for( auto& it : all )
+ for(const auto& it : all )
{
delete it;
}
@@ -85,9 +85,9 @@ BiomeCache::Block *BiomeCache::getBlockAt(int x, int z)
EnterCriticalSection(&m_CS);
x >>= ZONE_SIZE_BITS;
z >>= ZONE_SIZE_BITS;
- int64_t slot = (((int64_t) x) & 0xffffffffl) | ((((int64_t) z) & 0xffffffffl) << 32l);
- auto it = cached.find(slot);
- Block *block = NULL;
+ const int64_t slot = (static_cast<int64_t>(x) & 0xffffffffl) | ((static_cast<int64_t>(z) & 0xffffffffl) << 32l);
+ const auto it = cached.find(slot);
+ Block *block = nullptr;
if (it == cached.end())
{
MemSect(48);
@@ -124,20 +124,20 @@ float BiomeCache::getDownfall(int x, int z)
void BiomeCache::update()
{
EnterCriticalSection(&m_CS);
- int64_t now = app.getAppTime();
- int64_t utime = now - lastUpdateTime;
+ const int64_t now = app.getAppTime();
+ const int64_t utime = now - lastUpdateTime;
if (utime > DECAY_TIME / 4 || utime < 0)
{
lastUpdateTime = now;
for (auto it = all.begin(); it != all.end();)
{
- Block *block = *it;
- int64_t time = now - block->lastUse;
+ const Block *block = *it;
+ const int64_t time = now - block->lastUse;
if (time > DECAY_TIME || time < 0)
{
it = all.erase(it);
- int64_t slot = (((int64_t) block->x) & 0xffffffffl) | ((((int64_t) block->z) & 0xffffffffl) << 32l);
+ int64_t slot = (static_cast<int64_t>(block->x) & 0xffffffffl) | ((static_cast<int64_t>(block->z) & 0xffffffffl) << 32l);
cached.erase(slot);
delete block;
}
diff --git a/Minecraft.World/BiomeDecorator.cpp b/Minecraft.World/BiomeDecorator.cpp
index a3cbf546..add156e8 100644
--- a/Minecraft.World/BiomeDecorator.cpp
+++ b/Minecraft.World/BiomeDecorator.cpp
@@ -9,8 +9,8 @@ BiomeDecorator::BiomeDecorator(Biome *biome)
_init();
// 4J inits
- level = NULL;
- random = NULL;
+ level = nullptr;
+ random = nullptr;
xo = 0;
zo = 0;
@@ -19,7 +19,7 @@ BiomeDecorator::BiomeDecorator(Biome *biome)
void BiomeDecorator::decorate(Level *level, Random *random, int xo, int zo)
{
- if (this->level != NULL)
+ if (this->level != nullptr)
{
app.DebugPrintf("BiomeDecorator::decorate - Already decorating!!\n");
#ifndef _CONTENT_PACKAGE
@@ -34,8 +34,8 @@ void BiomeDecorator::decorate(Level *level, Random *random, int xo, int zo)
decorate();
- this->level = NULL;
- this->random = NULL;
+ this->level = nullptr;
+ this->random = nullptr;
}
@@ -164,7 +164,7 @@ void BiomeDecorator::decorate()
// 4J Stu - For some reason this was created each time round in the loop
// I assume there is a case where deadBushCount could be 0
- DeadBushFeature *deadBushFeature = NULL;
+ DeadBushFeature *deadBushFeature = nullptr;
if(deadBushCount > 0) deadBushFeature = new DeadBushFeature(Tile::deadBush_Id);
for (int i = 0; i < deadBushCount; i++)
{
@@ -174,7 +174,7 @@ void BiomeDecorator::decorate()
//new DeadBushFeature(Tile::deadBush_Id)->place(level, random, x, y, z);
deadBushFeature->place(level, random, x, y, z);
}
- if(deadBushFeature != NULL)delete deadBushFeature;
+ if(deadBushFeature != nullptr)delete deadBushFeature;
for (int i = 0; i < waterlilyCount; i++)
{
diff --git a/Minecraft.World/BiomeOverrideLayer.cpp b/Minecraft.World/BiomeOverrideLayer.cpp
index a44295dc..84605740 100644
--- a/Minecraft.World/BiomeOverrideLayer.cpp
+++ b/Minecraft.World/BiomeOverrideLayer.cpp
@@ -11,14 +11,14 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup)
#ifdef _UNICODE
wstring path = L"GAME:\\GameRules\\biomemap.bin";
- HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
#else
#ifdef _WINDOWS64
string path = "GameRules\\biomemap.bin";
#else
string path = "GAME:\\GameRules\\biomemap.bin";
#endif
- HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
#endif
if( file == INVALID_HANDLE_VALUE )
{
@@ -35,14 +35,14 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup)
__debugbreak(); // TODO
DWORD bytesRead,dwFileSize = 0;
#else
- DWORD bytesRead,dwFileSize = GetFileSize(file,NULL);
+ DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr);
#endif
if(dwFileSize > m_biomeOverride.length)
{
app.DebugPrintf("Biomemap binary is too large!!\n");
__debugbreak();
}
- BOOL bSuccess = ReadFile(file,m_biomeOverride.data,dwFileSize,&bytesRead,NULL);
+ BOOL bSuccess = ReadFile(file,m_biomeOverride.data,dwFileSize,&bytesRead,nullptr);
if(bSuccess==FALSE)
{
diff --git a/Minecraft.World/BiomeSource.cpp b/Minecraft.World/BiomeSource.cpp
index 2ab6182e..89422677 100644
--- a/Minecraft.World/BiomeSource.cpp
+++ b/Minecraft.World/BiomeSource.cpp
@@ -87,17 +87,17 @@ floatArray BiomeSource::getDownfallBlock(int x, int z, int w, int h) const
void BiomeSource::getDownfallBlock(floatArray &downfalls, int x, int z, int w, int h) const
{
IntCache::releaseAll();
- //if (downfalls == NULL || downfalls->length < w * h)
- if (downfalls.data == NULL || downfalls.length < w * h)
+ //if (downfalls == nullptr || downfalls->length < w * h)
+ if (downfalls.data == nullptr || downfalls.length < w * h)
{
- if(downfalls.data != NULL) delete [] downfalls.data;
+ if(downfalls.data != nullptr) delete [] downfalls.data;
downfalls = floatArray(w * h);
}
intArray result = zoomedLayer->getArea(x, z, w, h);
for (int i = 0; i < w * h; i++)
{
- float d = (float) Biome::biomes[result[i]]->getDownfallInt() / 65536.0f;
+ float d = static_cast<float>(Biome::biomes[result[i]]->getDownfallInt()) / 65536.0f;
if (d > 1) d = 1;
downfalls[i] = d;
}
@@ -132,16 +132,16 @@ void BiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z, in
{
IntCache::releaseAll();
//if (temperatures == null || temperatures.length < w * h) {
- if (temperatures.data == NULL || temperatures.length < w * h)
+ if (temperatures.data == nullptr || temperatures.length < w * h)
{
- if( temperatures.data != NULL ) delete [] temperatures.data;
+ if( temperatures.data != nullptr ) delete [] temperatures.data;
temperatures = floatArray(w * h);
}
intArray result = zoomedLayer->getArea(x, z, w, h);
for (int i = 0; i < w * h; i++)
{
- float t = (float) Biome::biomes[result[i]]->getTemperatureInt() / 65536.0f;
+ float t = static_cast<float>(Biome::biomes[result[i]]->getTemperatureInt()) / 65536.0f;
if (t > 1) t = 1;
temperatures[i] = t;
}
@@ -170,9 +170,9 @@ void BiomeSource::getRawBiomeBlock(BiomeArray &biomes, int x, int z, int w, int
{
IntCache::releaseAll();
//if (biomes == null || biomes.length < w * h)
- if (biomes.data == NULL || biomes.length < w * h)
+ if (biomes.data == nullptr || biomes.length < w * h)
{
- if(biomes.data != NULL) delete [] biomes.data;
+ if(biomes.data != nullptr) delete [] biomes.data;
biomes = BiomeArray(w * h);
}
@@ -181,7 +181,7 @@ void BiomeSource::getRawBiomeBlock(BiomeArray &biomes, int x, int z, int w, int
{
biomes[i] = Biome::biomes[result[i]];
#ifndef _CONTENT_PACKAGE
- if(biomes[i] == NULL)
+ if(biomes[i] == nullptr)
{
app.DebugPrintf("Tried to assign null biome %d\n", result[i]);
__debugbreak();
@@ -208,9 +208,9 @@ void BiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h,
{
IntCache::releaseAll();
//if (biomes == null || biomes.length < w * h)
- if (biomes.data == NULL || biomes.length < w * h)
+ if (biomes.data == nullptr || biomes.length < w * h)
{
- if(biomes.data != NULL) delete [] biomes.data;
+ if(biomes.data != nullptr) delete [] biomes.data;
biomes = BiomeArray(w * h);
}
@@ -248,9 +248,9 @@ void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, int
{
IntCache::releaseAll();
//if (biomes == null || biomes.length < w * h)
- if (biomeIndices.data == NULL || biomeIndices.length < w * h)
+ if (biomeIndices.data == nullptr || biomeIndices.length < w * h)
{
- if(biomeIndices.data != NULL) delete [] biomeIndices.data;
+ if(biomeIndices.data != nullptr) delete [] biomeIndices.data;
biomeIndices = byteArray(w * h);
}
@@ -264,7 +264,7 @@ void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, int
intArray result = zoomedLayer->getArea(x, z, w, h);
for (int i = 0; i < w * h; i++)
{
- biomeIndices[i] = (byte)result[i];
+ biomeIndices[i] = static_cast<byte>(result[i]);
}
}
@@ -341,7 +341,7 @@ TilePos *BiomeSource::findBiome(int x, int z, int r, Biome *toFind, Random *rand
int w = x1 - x0 + 1;
int h = z1 - z0 + 1;
intArray biomes = layer->getArea(x0, z0, w, h);
- TilePos *res = NULL;
+ TilePos *res = nullptr;
int found = 0;
int biomesCount = w*h;
for (unsigned int i = 0; i < biomesCount; i++)
@@ -351,7 +351,7 @@ TilePos *BiomeSource::findBiome(int x, int z, int r, Biome *toFind, Random *rand
Biome *b = Biome::biomes[biomes[i]];
if (b == toFind)
{
- if (res == NULL || random->nextInt(found + 1) == 0)
+ if (res == nullptr || random->nextInt(found + 1) == 0)
{
res = new TilePos(xx, 0, zz);
found++;
@@ -380,7 +380,7 @@ TilePos *BiomeSource::findBiome(int x, int z, int r, vector<Biome *> allowed, Ra
int h = z1 - z0 + 1;
MemSect(50);
intArray biomes = layer->getArea(x0, z0, w, h);
- TilePos *res = NULL;
+ TilePos *res = nullptr;
int found = 0;
for (unsigned int i = 0; i < w * h; i++)
{
@@ -389,7 +389,7 @@ TilePos *BiomeSource::findBiome(int x, int z, int r, vector<Biome *> allowed, Ra
Biome *b = Biome::biomes[biomes[i]];
if (find(allowed.begin(), allowed.end(), b) != allowed.end())
{
- if (res == NULL || random->nextInt(found + 1) == 0)
+ if (res == nullptr || random->nextInt(found + 1) == 0)
{
delete res;
res = new TilePos(xx, 0, zz);
@@ -553,7 +553,7 @@ void BiomeSource::getFracs(intArray indices, float *fracs)
for( int i = 0; i < Biome::BIOME_COUNT; i++ )
{
- fracs[i] /= (float)(indices.length);
+ fracs[i] /= static_cast<float>(indices.length);
}
}
diff --git a/Minecraft.World/BirchFeature.cpp b/Minecraft.World/BirchFeature.cpp
index d7a57514..3c423564 100644
--- a/Minecraft.World/BirchFeature.cpp
+++ b/Minecraft.World/BirchFeature.cpp
@@ -42,7 +42,7 @@ bool BirchFeature::place(Level *level, Random *random, int x, int y, int z)
if ((belowTile != Tile::grass_Id && belowTile != Tile::dirt_Id) || y >= Level::maxBuildHeight - treeHeight - 1) return false;
// 4J Stu Added to stop tree features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
int radius = 3;
diff --git a/Minecraft.World/Blaze.cpp b/Minecraft.World/Blaze.cpp
index d87a83b2..ec72dfcb 100644
--- a/Minecraft.World/Blaze.cpp
+++ b/Minecraft.World/Blaze.cpp
@@ -42,7 +42,7 @@ void Blaze::defineSynchedData()
{
Monster::defineSynchedData();
- entityData->define(DATA_FLAGS_ID, (byte) 0);
+ entityData->define(DATA_FLAGS_ID, static_cast<byte>(0));
}
int Blaze::getAmbientSound()
@@ -84,10 +84,10 @@ void Blaze::aiStep()
if (nextHeightOffsetChangeTick <= 0)
{
nextHeightOffsetChangeTick = SharedConstants::TICKS_PER_SECOND * 5;
- allowedHeightOffset = .5f + (float) random->nextGaussian() * 3;
+ allowedHeightOffset = .5f + static_cast<float>(random->nextGaussian()) * 3;
}
- if (getAttackTarget() != NULL && (getAttackTarget()->y + getAttackTarget()->getHeadHeight()) > (y + getHeadHeight() + allowedHeightOffset))
+ if (getAttackTarget() != nullptr && (getAttackTarget()->y + getAttackTarget()->getHeadHeight()) > (y + getHeadHeight() + allowedHeightOffset))
{
yd = yd + (.3f - yd) * .3f;
}
@@ -149,10 +149,10 @@ void Blaze::checkHurtTarget(shared_ptr<Entity> target, float d)
{
float sqd = sqrt(d) * .5f;
- level->levelEvent(nullptr, LevelEvent::SOUND_BLAZE_FIREBALL, (int) x, (int) y, (int) z, 0);
+ level->levelEvent(nullptr, LevelEvent::SOUND_BLAZE_FIREBALL, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
// level.playSound(this, "mob.ghast.fireball", getSoundVolume(), (random.nextFloat() - random.nextFloat()) * 0.2f + 1.0f);
for (int i = 0; i < 1; i++) {
- shared_ptr<SmallFireball> ie = shared_ptr<SmallFireball>( new SmallFireball(level, dynamic_pointer_cast<Mob>( shared_from_this() ), xd + random->nextGaussian() * sqd, yd, zd + random->nextGaussian() * sqd) );
+ shared_ptr<SmallFireball> ie = std::make_shared<SmallFireball>(level, dynamic_pointer_cast<Mob>(shared_from_this()), xd + random->nextGaussian() * sqd, yd, zd + random->nextGaussian() * sqd);
// Vec3 v = getViewVector(1);
// ie.x = x + v.x * 1.5;
ie->y = y + bbHeight / 2 + 0.5f;
@@ -162,7 +162,7 @@ void Blaze::checkHurtTarget(shared_ptr<Entity> target, float d)
}
}
- yRot = (float) (atan2(zd, xd) * 180 / PI) - 90;
+ yRot = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
holdGround = true;
}
diff --git a/Minecraft.World/BlockRegionUpdatePacket.h b/Minecraft.World/BlockRegionUpdatePacket.h
index 54dfea4e..d823acaf 100644
--- a/Minecraft.World/BlockRegionUpdatePacket.h
+++ b/Minecraft.World/BlockRegionUpdatePacket.h
@@ -28,6 +28,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new BlockRegionUpdatePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<BlockRegionUpdatePacket>(); }
virtual int getId() { return 51; }
};
diff --git a/Minecraft.World/BlockReplacements.cpp b/Minecraft.World/BlockReplacements.cpp
index 7b8aee51..f60d9e2a 100644
--- a/Minecraft.World/BlockReplacements.cpp
+++ b/Minecraft.World/BlockReplacements.cpp
@@ -8,8 +8,8 @@ void BlockReplacements::staticCtor()
{
for (int i = 0; i < 256; i++)
{
- byte b = (byte) i;
- if (b != 0 && Tile::tiles[b & 0xff] == NULL)
+ byte b = static_cast<byte>(i);
+ if (b != 0 && Tile::tiles[b & 0xff] == nullptr)
{
b = 0;
}
diff --git a/Minecraft.World/Boat.cpp b/Minecraft.World/Boat.cpp
index e3387581..a470936a 100644
--- a/Minecraft.World/Boat.cpp
+++ b/Minecraft.World/Boat.cpp
@@ -74,7 +74,7 @@ bool Boat::isPushable()
Boat::Boat(Level *level, double x, double y, double z) : Entity( level )
{
_init();
- setPos(x, y + heightOffset + 0.1, z);
+ setPos(x, y + heightOffset, z);
xd = 0;
yd = 0;
@@ -97,7 +97,7 @@ bool Boat::hurt(DamageSource *source, float hurtDamage)
// 4J-JEV: Fix for #88212,
// Untrusted players shouldn't be able to damage minecarts or boats.
- if (dynamic_cast<EntityDamageSource *>(source) != NULL)
+ if (dynamic_cast<EntityDamageSource *>(source) != nullptr)
{
shared_ptr<Entity> attacker = source->getDirectEntity();
@@ -113,18 +113,18 @@ bool Boat::hurt(DamageSource *source, float hurtDamage)
// 4J Stu - If someone is riding in this, then it can tick multiple times which causes the damage to
// decrease too quickly. So just make the damage a bit higher to start with for similar behaviour
// to an unridden one. Only do this change if the riding player is attacking it.
- if( rider.lock() != NULL && rider.lock() == source->getEntity() ) hurtDamage += 1;
+ if( rider.lock() != nullptr && rider.lock() == source->getEntity() ) hurtDamage += 1;
setDamage(getDamage() + hurtDamage * 10);
markHurt();
// 4J Stu - Brought froward from 12w36 to fix #46611 - TU5: Gameplay: Minecarts and boat requires more hits than one to be destroyed in creative mode
// 4J-PB - Fix for XB1 #175735 - [CRASH] [Multi-Plat]: Code: Gameplay: Placing a boat on harmful surfaces causes the game to crash
- bool creativePlayer = (source->getEntity() != NULL) && source->getEntity()->instanceof(eTYPE_PLAYER) && dynamic_pointer_cast<Player>(source->getEntity())->abilities.instabuild;
+ bool creativePlayer = (source->getEntity() != nullptr) && source->getEntity()->instanceof(eTYPE_PLAYER) && dynamic_pointer_cast<Player>(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();
}
@@ -209,9 +209,30 @@ void Boat::tick()
}
double lastSpeed = sqrt(xd * xd + zd * zd);
- if (lastSpeed > MAX_COLLISION_SPEED && waterPercentage > 1)
+ if (lastSpeed > MAX_COLLISION_SPEED)
{
- createSplash(lastSpeed);
+ double xa = cos(yRot * PI / 180);
+ double za = sin(yRot * PI / 180);
+
+ for (int i = 0; i < 1 + lastSpeed * 60; i++)
+ {
+
+ double side = (random->nextFloat() * 2 - 1);
+
+ double side2 = (random->nextInt(2) * 2 - 1) * 0.7;
+ if (random->nextBoolean())
+ {
+ double xx = x - xa * side * 0.8 + za * side2;
+ double zz = z - za * side * 0.8 - xa * side2;
+ level->addParticle(eParticleType_splash, xx, y - 2 / 16.0f, zz, +xd, yd, +zd);
+ }
+ else
+ {
+ double xx = x + xa + za * side * 0.7;
+ double zz = z + za - xa * side * 0.7;
+ level->addParticle(eParticleType_splash, xx, y - 2 / 16.0f, zz, +xd, yd, +zd);
+ }
+ }
}
if (level->isClientSide && doLerp)
@@ -233,6 +254,7 @@ void Boat::tick()
}
else
{
+#if 1
// Original
//double xt = x + xd;
//double yt = y + yd;
@@ -251,24 +273,52 @@ void Boat::tick()
xd *= 0.99f;
yd *= 0.95f;
zd *= 0.99f;
+#else
+ // 4J Stu - Fix for #8280 - Gameplay : Boats behave erratically when exited next to land.
+ // The client shouldn't change the position of the boat
+ double xt = x;// + xd;
+ double yt = y + yd;
+ double zt = z;// + zd;
+ this->setPos(xt, yt, zt);
+
+ // 4J Stu - Fix for #9579 - GAMEPLAY: Boats with a player in them slowly sink under the water over time, and with no player in them they float into the sky.
+ // Just make the boats bob up and down rather than any other client-side movement when not receiving packets from server
+ if (waterPercentage > 0)
+ {
+ double bob = waterPercentage * 2 - 1;
+ yd += 0.04f * bob;
+ }
+ else
+ {
+ if (yd < 0) yd /= 2;
+ yd += 0.007f;
+ }
+ //if (onGround)
+ //{
+ xd *= 0.5f;
+ yd *= 0.5f;
+ zd *= 0.5f;
+ //}
+ //xd *= 0.99f;
+ //yd *= 0.95f;
+ //zd *= 0.99f;
+#endif
}
return;
}
- // Bob on water
if (waterPercentage > 0)
{
double bob = waterPercentage * 2 - 1;
yd += 0.04f * bob;
}
-
- // Reimplement "gravity"
- if (level->getTile(x, Mth::floor(y - 0.15), z) == 0 && !onGround) {
- yd += 0.04f * -1.0; // -1.0 is what bob should return in this situation, just hardcoded.
+ else
+ {
+ yd = 0;
}
- // Rider Controls
- if ( rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY) )
+
+ if ( rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_LIVINGENTITY) )
{
shared_ptr<LivingEntity> livingRider = dynamic_pointer_cast<LivingEntity>(rider.lock());
double forward = livingRider->yya;
@@ -284,7 +334,6 @@ void Boat::tick()
double curSpeed = sqrt(xd * xd + zd * zd);
- // Speed Clamp
if (curSpeed > MAX_SPEED)
{
double ratio = MAX_SPEED / curSpeed;
@@ -305,15 +354,14 @@ void Boat::tick()
if (acceleration < MIN_ACCELERATION) acceleration = MIN_ACCELERATION;
}
- // Slow speed on ground
if (onGround)
{
xd *= 0.5f;
+ yd *= 0.5f;
zd *= 0.5f;
}
move(xd, yd, zd);
- // Break boat
if ((horizontalCollision && lastSpeed > 0.20))
{
if (!level->isClientSide && !removed)
@@ -353,7 +401,6 @@ void Boat::tick()
yRot += (float) rotDiff;
setRot(yRot, xRot);
- // Server only code below
if(level->isClientSide) return;
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), bb->grow(0.2f, 0, 0.2f));
@@ -391,43 +438,19 @@ void Boat::tick()
}
- if (rider.lock() != NULL)
+ if (rider.lock() != nullptr)
{
if (rider.lock()->removed) rider = weak_ptr<Entity>();
}
}
-void Boat::createSplash(double particleStrengh) {
- double xa = cos(yRot * PI / 180);
- double za = sin(yRot * PI / 180);
-
- for (int i = 0; i < 1 + particleStrengh * 60; i++)
- {
- double side = (random->nextFloat() * 2 - 1);
-
- double side2 = (random->nextInt(2) * 2 - 1) * 0.7;
- if (random->nextBoolean())
- {
- double xx = x - xa * side * 0.8 + za * side2;
- double zz = z - za * side * 0.8 - xa * side2;
- level->addParticle(eParticleType_splash, xx, y - 2 / 16.0f, zz, +xd, yd, +zd);
- }
- else
- {
- double xx = x + xa + za * side * 0.7;
- double zz = z + za - xa * side * 0.7;
- level->addParticle(eParticleType_splash, xx, y - 2 / 16.0f, zz, +xd, yd, +zd);
- }
- }
-}
-
void Boat::positionRider()
{
- if (rider.lock() == NULL) return;
+ if (rider.lock() == nullptr) return;
double xa = cos(yRot * PI / 180) * 0.4;
double za = sin(yRot * PI / 180) * 0.4;
- rider.lock()->setPos(x + xa, y + getRideHeight() + rider.lock()->getRidingHeight()-0.5, z + za);
+ rider.lock()->setPos(x + xa, y + getRideHeight() + rider.lock()->getRidingHeight(), z + za);
}
@@ -452,7 +475,7 @@ wstring Boat::getName()
bool Boat::interact(shared_ptr<Player> player)
{
- if ( (rider.lock() != NULL) && rider.lock()->instanceof(eTYPE_PLAYER) && (rider.lock() != player) ) return true;
+ if ( (rider.lock() != nullptr) && rider.lock()->instanceof(eTYPE_PLAYER) && (rider.lock() != player) ) return true;
if (!level->isClientSide)
{
// 4J HEG - Fixed issue with player not being able to dismount boat (issue #4446)
diff --git a/Minecraft.World/BoatItem.cpp b/Minecraft.World/BoatItem.cpp
index d2bb75b5..5cf2cd38 100644
--- a/Minecraft.World/BoatItem.cpp
+++ b/Minecraft.World/BoatItem.cpp
@@ -39,7 +39,7 @@ bool BoatItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shar
double range = 5;
Vec3 *to = from->add(xa * range, ya * range, za * range);
HitResult *hr = level->clip(from, to, true);
- if (hr == NULL) return false;
+ if (hr == nullptr) return false;
if (hr->type == HitResult::TILE)
{
@@ -74,7 +74,7 @@ shared_ptr<ItemInstance> BoatItem::use(shared_ptr<ItemInstance> itemInstance, Le
double range = 5;
Vec3 *to = from->add(xa * range, ya * range, za * range);
HitResult *hr = level->clip(from, to, true);
- if (hr == NULL) return itemInstance;
+ if (hr == nullptr) return itemInstance;
// check entity collision
Vec3 *b = player->getViewVector(a);
@@ -107,7 +107,7 @@ shared_ptr<ItemInstance> BoatItem::use(shared_ptr<ItemInstance> itemInstance, Le
if (level->getTile(xt, yt, zt) == Tile::topSnow_Id) yt--;
if( level->countInstanceOf(eTYPE_BOAT, true) < Level::MAX_XBOX_BOATS ) // 4J - added limit
{
- shared_ptr<Boat> boat = shared_ptr<Boat>( new Boat(level, xt + 0.5f, yt + 1.0f, zt + 0.5f) );
+ shared_ptr<Boat> boat = std::make_shared<Boat>(level, xt + 0.5f, yt + 1.0f, zt + 0.5f);
boat->yRot = ((Mth::floor(player->yRot * 4.0F / 360.0F + 0.5) & 0x3) - 1) * 90;
if (!level->getCubes(boat, boat->bb->grow(-.1, -.1, -.1))->empty())
{
diff --git a/Minecraft.World/BonusChestFeature.cpp b/Minecraft.World/BonusChestFeature.cpp
index 6d083f54..cd33e60a 100644
--- a/Minecraft.World/BonusChestFeature.cpp
+++ b/Minecraft.World/BonusChestFeature.cpp
@@ -59,7 +59,7 @@ bool BonusChestFeature::place(Level *level, Random *random, int x, int y, int z,
{
level->setTileAndData(x2, y2, z2, Tile::chest_Id, 0, Tile::UPDATE_CLIENTS);
shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(level->getTileEntity(x2, y2, z2));
- if (chest != NULL)
+ if (chest != nullptr)
{
WeighedTreasure::addChestItems(random, treasureList, chest, numRolls);
chest->isBonusChest = true; // 4J added
diff --git a/Minecraft.World/BottleItem.cpp b/Minecraft.World/BottleItem.cpp
index 0f8e3c35..3e526b2a 100644
--- a/Minecraft.World/BottleItem.cpp
+++ b/Minecraft.World/BottleItem.cpp
@@ -18,7 +18,7 @@ Icon *BottleItem::getIcon(int auxValue)
shared_ptr<ItemInstance> BottleItem::use(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
{
HitResult *hr = getPlayerPOVHitResult(level, player, true);
- if (hr == NULL) return itemInstance;
+ if (hr == nullptr) return itemInstance;
if (hr->type == HitResult::TILE)
{
@@ -40,13 +40,13 @@ shared_ptr<ItemInstance> BottleItem::use(shared_ptr<ItemInstance> itemInstance,
itemInstance->count--;
if (itemInstance->count <= 0)
{
- return shared_ptr<ItemInstance>( new ItemInstance( (Item *)Item::potion) );
+ return std::make_shared<ItemInstance>(static_cast<Item *>(Item::potion));
}
else
{
- if (!player->inventory->add(shared_ptr<ItemInstance>( new ItemInstance( (Item *)Item::potion) )))
+ if (!player->inventory->add(std::make_shared<ItemInstance>(static_cast<Item *>(Item::potion))))
{
- player->drop( shared_ptr<ItemInstance>( new ItemInstance(Item::potion_Id, 1, 0) ));
+ player->drop(std::make_shared<ItemInstance>(Item::potion_Id, 1, 0));
}
}
}
@@ -63,7 +63,7 @@ shared_ptr<ItemInstance> BottleItem::use(shared_ptr<ItemInstance> itemInstance,
bool BottleItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
{
HitResult *hr = getPlayerPOVHitResult(level, player, true);
- if (hr == NULL) return false;
+ if (hr == nullptr) return false;
if (hr->type == HitResult::TILE)
{
diff --git a/Minecraft.World/BoundingBox.cpp b/Minecraft.World/BoundingBox.cpp
index 74dba470..e93158f2 100644
--- a/Minecraft.World/BoundingBox.cpp
+++ b/Minecraft.World/BoundingBox.cpp
@@ -115,7 +115,7 @@ BoundingBox *BoundingBox::getIntersection(BoundingBox *other)
{
if (!intersects(other))
{
- return NULL;
+ return nullptr;
}
BoundingBox *result = new BoundingBox();
result->x0 = Math::_max(x0, other->x0);
diff --git a/Minecraft.World/BowItem.cpp b/Minecraft.World/BowItem.cpp
index 949b71e7..a2d34b89 100644
--- a/Minecraft.World/BowItem.cpp
+++ b/Minecraft.World/BowItem.cpp
@@ -15,7 +15,7 @@ BowItem::BowItem(int id) : Item( id )
maxStackSize = 1;
setMaxDamage(384);
- icons = NULL;
+ icons = nullptr;
}
void BowItem::releaseUsing(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player, int durationLeft)
@@ -25,17 +25,17 @@ void BowItem::releaseUsing(shared_ptr<ItemInstance> itemInstance, Level *level,
if (infiniteArrows || player->inventory->hasResource(Item::arrow_Id))
{
int timeHeld = getUseDuration(itemInstance) - durationLeft;
- float pow = timeHeld / (float) MAX_DRAW_DURATION;
+ float pow = timeHeld / static_cast<float>(MAX_DRAW_DURATION);
pow = ((pow * pow) + pow * 2) / 3;
if (pow < 0.1) return;
if (pow > 1) pow = 1;
- shared_ptr<Arrow> arrow = shared_ptr<Arrow>( new Arrow(level, player, pow * 2.0f) );
+ shared_ptr<Arrow> arrow = std::make_shared<Arrow>(level, player, pow * 2.0f);
if (pow == 1) arrow->setCritArrow(true);
int damageBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowBonus->id, itemInstance);
if (damageBonus > 0)
{
- arrow->setBaseDamage(arrow->getBaseDamage() + (double) damageBonus * .5 + .5);
+ arrow->setBaseDamage(arrow->getBaseDamage() + static_cast<double>(damageBonus) * .5 + .5);
}
int knockbackBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowKnockback->id, itemInstance);
if (knockbackBonus > 0)
diff --git a/Minecraft.World/BowlFoodItem.cpp b/Minecraft.World/BowlFoodItem.cpp
index f8ab0605..66e1dbb1 100644
--- a/Minecraft.World/BowlFoodItem.cpp
+++ b/Minecraft.World/BowlFoodItem.cpp
@@ -12,5 +12,5 @@ shared_ptr<ItemInstance> BowlFoodItem::useTimeDepleted(shared_ptr<ItemInstance>
{
FoodItem::useTimeDepleted(instance, level, player);
- return shared_ptr<ItemInstance>(new ItemInstance(Item::bowl));
+ return std::make_shared<ItemInstance>(Item::bowl);
} \ No newline at end of file
diff --git a/Minecraft.World/BreakDoorGoal.cpp b/Minecraft.World/BreakDoorGoal.cpp
index f63b4eb0..ea00f500 100644
--- a/Minecraft.World/BreakDoorGoal.cpp
+++ b/Minecraft.World/BreakDoorGoal.cpp
@@ -47,7 +47,7 @@ void BreakDoorGoal::tick()
breakTime++;
- int progress = (int) (breakTime / (float) DOOR_BREAK_TIME * 10);
+ int progress = static_cast<int>(breakTime / (float)DOOR_BREAK_TIME * 10);
if (progress != lastBreakProgress)
{
mob->level->destroyTileProgress(mob->entityId, doorX, doorY, doorZ, progress);
diff --git a/Minecraft.World/BreedGoal.cpp b/Minecraft.World/BreedGoal.cpp
index 1c46fd90..10aa6844 100644
--- a/Minecraft.World/BreedGoal.cpp
+++ b/Minecraft.World/BreedGoal.cpp
@@ -25,12 +25,12 @@ bool BreedGoal::canUse()
{
if (!animal->isInLove()) return false;
partner = weak_ptr<Animal>(getFreePartner());
- return partner.lock() != NULL;
+ return partner.lock() != nullptr;
}
bool BreedGoal::canContinueToUse()
{
- return partner.lock() != NULL && partner.lock()->isAlive() && partner.lock()->isInLove() && loveTime < 20 * 3;
+ return partner.lock() != nullptr && partner.lock()->isAlive() && partner.lock()->isInLove() && loveTime < 20 * 3;
}
void BreedGoal::stop()
@@ -74,21 +74,21 @@ void BreedGoal::breed()
shared_ptr<AgableMob> offspring = animal->getBreedOffspring(partner.lock());
animal->setDespawnProtected();
partner.lock()->setDespawnProtected();
- if (offspring == NULL)
+ if (offspring == nullptr)
{
- // This will be NULL if we've hit our limits for spawning any particular type of animal... reset things as normally as we can, without actually producing any offspring
+ // This will be nullptr if we've hit our limits for spawning any particular type of animal... reset things as normally as we can, without actually producing any offspring
animal->resetLove();
partner.lock()->resetLove();
return;
}
shared_ptr<Player> loveCause = animal->getLoveCause();
- if (loveCause == NULL && partner.lock()->getLoveCause() != NULL)
+ if (loveCause == nullptr && partner.lock()->getLoveCause() != nullptr)
{
loveCause = partner.lock()->getLoveCause();
}
- if (loveCause != NULL)
+ if (loveCause != nullptr)
{
// Record mob bred stat.
loveCause->awardStat(GenericStats::breedEntity(offspring->GetType()),GenericStats::param_breedEntity(offspring->GetType()));
@@ -118,5 +118,5 @@ void BreedGoal::breed()
* animal->bbWidth * 2 - animal->bbWidth, xa, ya, za);
}
// 4J-PB - Fix for 106869- Customer Encountered: TU12: Content: Gameplay: Breeding animals does not give any Experience Orbs.
- level->addEntity( shared_ptr<ExperienceOrb>( new ExperienceOrb(level, animal->x, animal->y, animal->z, random->nextInt(7) + 1) ) );
+ level->addEntity(std::make_shared<ExperienceOrb>(level, animal->x, animal->y, animal->z, random->nextInt(7) + 1));
}
diff --git a/Minecraft.World/BrewingStandMenu.cpp b/Minecraft.World/BrewingStandMenu.cpp
index 4f9e2ac3..2200f47c 100644
--- a/Minecraft.World/BrewingStandMenu.cpp
+++ b/Minecraft.World/BrewingStandMenu.cpp
@@ -69,7 +69,7 @@ shared_ptr<ItemInstance> BrewingStandMenu::quickMoveStack(shared_ptr<Player> pla
Slot *PotionSlot2 = slots.at(BOTTLE_SLOT_START+1);
Slot *PotionSlot3 = slots.at(BOTTLE_SLOT_START+2);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
@@ -199,7 +199,7 @@ bool BrewingStandMenu::PotionSlot::mayCombine(shared_ptr<ItemInstance> second)
bool BrewingStandMenu::PotionSlot::mayPlaceItem(shared_ptr<ItemInstance> item)
{
- return item != NULL && (item->id == Item::potion_Id || item->id == Item::glassBottle_Id);
+ return item != nullptr && (item->id == Item::potion_Id || item->id == Item::glassBottle_Id);
}
@@ -210,7 +210,7 @@ BrewingStandMenu::IngredientsSlot::IngredientsSlot(shared_ptr<Container> contain
bool BrewingStandMenu::IngredientsSlot::mayPlace(shared_ptr<ItemInstance> item)
{
- if (item != NULL)
+ if (item != nullptr)
{
if (PotionBrewing::SIMPLIFIED_BREWING)
{
diff --git a/Minecraft.World/BrewingStandTile.cpp b/Minecraft.World/BrewingStandTile.cpp
index 1aeb52d8..ec7242c8 100644
--- a/Minecraft.World/BrewingStandTile.cpp
+++ b/Minecraft.World/BrewingStandTile.cpp
@@ -10,7 +10,7 @@
BrewingStandTile::BrewingStandTile(int id) : BaseEntityTile(id, Material::metal, isSolidRender())
{
random = new Random();
- iconBase = NULL;
+ iconBase = nullptr;
}
BrewingStandTile::~BrewingStandTile()
@@ -30,7 +30,7 @@ int BrewingStandTile::getRenderShape()
shared_ptr<TileEntity> BrewingStandTile::newTileEntity(Level *level)
{
- return shared_ptr<TileEntity>(new BrewingStandTileEntity());
+ return std::make_shared<BrewingStandTileEntity>();
}
bool BrewingStandTile::isCubeShaped()
@@ -60,7 +60,7 @@ bool BrewingStandTile::use(Level *level, int x, int y, int z, shared_ptr<Player>
return true;
}
shared_ptr<BrewingStandTileEntity> brewingStand = dynamic_pointer_cast<BrewingStandTileEntity>(level->getTileEntity(x, y, z));
- if (brewingStand != NULL) player->openBrewingStand(brewingStand);
+ if (brewingStand != nullptr) player->openBrewingStand(brewingStand);
return true;
}
@@ -86,13 +86,13 @@ void BrewingStandTile::animateTick(Level *level, int xt, int yt, int zt, Random
void BrewingStandTile::onRemove(Level *level, int x, int y, int z, int id, int data)
{
shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
- if (tileEntity != NULL && ( dynamic_pointer_cast<BrewingStandTileEntity>(tileEntity) != NULL) )
+ if (tileEntity != nullptr && ( dynamic_pointer_cast<BrewingStandTileEntity>(tileEntity) != nullptr) )
{
shared_ptr<BrewingStandTileEntity> container = dynamic_pointer_cast<BrewingStandTileEntity>(tileEntity);
for (int i = 0; i < container->getContainerSize(); i++)
{
shared_ptr<ItemInstance> 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;
@@ -104,14 +104,14 @@ void BrewingStandTile::onRemove(Level *level, int x, int y, int z, int id, int d
if (count > item->count) count = item->count;
item->count -= count;
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>(new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue()))));
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>(new ItemInstance(item->id, count, item->getAuxValue())));
float pow = 0.05f;
- itemEntity->xd = (float) random->nextGaussian() * pow;
- itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f;
- itemEntity->zd = (float) random->nextGaussian() * pow;
+ itemEntity->xd = static_cast<float>(random->nextGaussian()) * pow;
+ itemEntity->yd = static_cast<float>(random->nextGaussian()) * pow + 0.2f;
+ itemEntity->zd = static_cast<float>(random->nextGaussian()) * pow;
if (item->hasTag())
{
- itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy());
+ itemEntity->getItem()->setTag(static_cast<CompoundTag *>(item->getTag()->copy()));
}
level->addEntity(itemEntity);
}
diff --git a/Minecraft.World/BrewingStandTileEntity.cpp b/Minecraft.World/BrewingStandTileEntity.cpp
index 5bc6fd27..3d081bae 100644
--- a/Minecraft.World/BrewingStandTileEntity.cpp
+++ b/Minecraft.World/BrewingStandTileEntity.cpp
@@ -96,7 +96,7 @@ int BrewingStandTileEntity::getBrewTime()
bool BrewingStandTileEntity::isBrewable()
{
- if (items[INGREDIENT_SLOT] == NULL || items[INGREDIENT_SLOT]->count <= 0)
+ if (items[INGREDIENT_SLOT] == nullptr || items[INGREDIENT_SLOT]->count <= 0)
{
return false;
}
@@ -111,7 +111,7 @@ bool BrewingStandTileEntity::isBrewable()
bool oneResult = false;
for (int dest = 0; dest < 3; dest++)
{
- if (items[dest] != NULL && items[dest]->id == Item::potion_Id)
+ if (items[dest] != nullptr && items[dest]->id == Item::potion_Id)
{
int currentBrew = items[dest]->getAuxValue();
int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) );
@@ -129,7 +129,7 @@ bool BrewingStandTileEntity::isBrewable()
// TODO - find out whether actually checking pointers to MobEffectInstance classes for equality
// is of any use
bool equals = false;
- if( ( currentEffects != NULL ) && ( newEffects != NULL ) )
+ if( ( currentEffects != nullptr ) && ( newEffects != nullptr ) )
{
if( currentEffects->size() == newEffects->size() )
{
@@ -141,7 +141,7 @@ bool BrewingStandTileEntity::isBrewable()
}
if ((currentBrew > 0 && currentEffects == newEffects) ||
- (currentEffects != NULL && (equals || newEffects == NULL)))
+ (currentEffects != nullptr && (equals || newEffects == nullptr)))
{
}
else if (currentBrew != newBrew)
@@ -166,7 +166,7 @@ bool BrewingStandTileEntity::isBrewable()
bool oneResult = false;
for (int dest = 0; dest < 3; dest++)
{
- if (items[dest] != NULL && items[dest]->id == Item::potion_Id)
+ if (items[dest] != nullptr && items[dest]->id == Item::potion_Id)
{
int currentBrew = items[dest]->getAuxValue();
int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) );
@@ -176,7 +176,7 @@ bool BrewingStandTileEntity::isBrewable()
break;
}
}
- else if (isWater && items[dest] != NULL && items[dest]->id == Item::glassBottle_Id)
+ else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id)
{
oneResult = true;
break;
@@ -199,7 +199,7 @@ void BrewingStandTileEntity::doBrew()
{
for (int dest = 0; dest < 3; dest++)
{
- if (items[dest] != NULL && items[dest]->id == Item::potion_Id)
+ if (items[dest] != nullptr && items[dest]->id == Item::potion_Id)
{
int currentBrew = items[dest]->getAuxValue();
int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) );
@@ -211,7 +211,7 @@ void BrewingStandTileEntity::doBrew()
// TODO - find out whether actually checking pointers to MobEffectInstance classes for equality
// is of any use
bool equals = false;
- if( ( currentEffects != NULL ) && ( newEffects != NULL ) )
+ if( ( currentEffects != nullptr ) && ( newEffects != nullptr ) )
{
if( currentEffects->size() == newEffects->size() )
{
@@ -223,7 +223,7 @@ void BrewingStandTileEntity::doBrew()
}
if ((currentBrew > 0 && currentEffects == newEffects) ||
- (currentEffects != NULL && (equals || newEffects == NULL)))
+ (currentEffects != nullptr && (equals || newEffects == nullptr)))
{
if (!PotionItem::isThrowable(currentBrew) && PotionItem::isThrowable(newBrew))
{
@@ -246,22 +246,22 @@ void BrewingStandTileEntity::doBrew()
for (int dest = 0; dest < 3; dest++)
{
- if (items[dest] != NULL && items[dest]->id == Item::potion_Id)
+ if (items[dest] != nullptr && items[dest]->id == Item::potion_Id)
{
int currentBrew = items[dest]->getAuxValue();
int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) );
items[dest]->setAuxValue(newBrew);
}
- else if (isWater && items[dest] != NULL && items[dest]->id == Item::glassBottle_Id)
+ else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id)
{
- items[dest] = shared_ptr<ItemInstance>(new ItemInstance(Item::potion));
+ items[dest] = std::make_shared<ItemInstance>(Item::potion);
}
}
}
if (Item::items[ingredient->id]->hasCraftingRemainingItem())
{
- items[INGREDIENT_SLOT] = shared_ptr<ItemInstance>(new ItemInstance(Item::items[ingredient->id]->getCraftingRemainingItem()));
+ items[INGREDIENT_SLOT] = std::make_shared<ItemInstance>(Item::items[ingredient->id]->getCraftingRemainingItem());
}
else
{
@@ -275,7 +275,7 @@ void BrewingStandTileEntity::doBrew()
int BrewingStandTileEntity::applyIngredient(int currentBrew, shared_ptr<ItemInstance> ingredient)
{
- if (ingredient == NULL)
+ if (ingredient == nullptr)
{
return currentBrew;
}
@@ -322,15 +322,15 @@ void BrewingStandTileEntity::save(CompoundTag *base)
{
TileEntity::save(base);
- base->putShort(L"BrewTime", (short) (brewTime));
+ base->putShort(L"BrewTime", static_cast<short>(brewTime));
ListTag<CompoundTag> *listTag = new ListTag<CompoundTag>();
for (int i = 0; i < items.length; i++)
{
- if (items[i] != NULL)
+ if (items[i] != nullptr)
{
CompoundTag *tag = new CompoundTag();
- tag->putByte(L"Slot", (byte) i);
+ tag->putByte(L"Slot", static_cast<byte>(i));
items[i]->save(tag);
listTag->add(tag);
}
@@ -354,7 +354,7 @@ shared_ptr<ItemInstance> BrewingStandTileEntity::removeItem(unsigned int slot, i
// option on the ingredients slot
// Fix for #65373 - TU8: Content: UI: Command "Take Half" in the Brewing Stand interface doesn't work as intended.
- if (slot >= 0 && slot < items.length && items[slot] != NULL)
+ if (slot >= 0 && slot < items.length && items[slot] != nullptr)
{
if (items[slot]->count <= count)
{
@@ -445,7 +445,7 @@ int BrewingStandTileEntity::getPotionBits()
int newCount = 0;
for (int potion = 0; potion < 3; potion++)
{
- if (items[potion] != NULL)
+ if (items[potion] != nullptr)
{
newCount |= (1 << potion);
}
@@ -476,7 +476,7 @@ bool BrewingStandTileEntity::canTakeItemThroughFace(int slot, shared_ptr<ItemIns
// 4J Added
shared_ptr<TileEntity> BrewingStandTileEntity::clone()
{
- shared_ptr<BrewingStandTileEntity> result = shared_ptr<BrewingStandTileEntity>( new BrewingStandTileEntity() );
+ shared_ptr<BrewingStandTileEntity> result = std::make_shared<BrewingStandTileEntity>();
TileEntity::clone(result);
result->brewTime = brewTime;
@@ -485,7 +485,7 @@ shared_ptr<TileEntity> BrewingStandTileEntity::clone()
for (unsigned int i = 0; i < items.length; i++)
{
- if (items.data[i] != NULL)
+ if (items.data[i] != nullptr)
{
result->items.data[i] = ItemInstance::clone(items.data[i]);
}
diff --git a/Minecraft.World/BucketItem.cpp b/Minecraft.World/BucketItem.cpp
index a3bd7bee..cb9d54b6 100644
--- a/Minecraft.World/BucketItem.cpp
+++ b/Minecraft.World/BucketItem.cpp
@@ -28,7 +28,7 @@ bool BucketItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, sh
{
bool pickLiquid = content == 0;
HitResult *hr = getPlayerPOVHitResult(level, player, pickLiquid);
- if (hr == NULL) return false;
+ if (hr == nullptr) return false;
if (hr->type == HitResult::TILE)
{
@@ -105,7 +105,7 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
bool pickLiquid = content == 0;
HitResult *hr = getPlayerPOVHitResult(level, player, pickLiquid);
- if (hr == NULL) return itemInstance;
+ if (hr == nullptr) return itemInstance;
if (hr->type == HitResult::TILE)
{
@@ -117,10 +117,10 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
{
app.DebugPrintf("!!!!!!!!!!! Can't place that here\n");
shared_ptr<ServerPlayer> servPlayer = dynamic_pointer_cast<ServerPlayer>(player);
- if( servPlayer != NULL )
+ if( servPlayer != nullptr )
{
app.DebugPrintf("Sending ChatPacket::e_ChatCannotPlaceLava to player\n");
- servPlayer->connection->send( shared_ptr<ChatPacket>( new ChatPacket(L"", ChatPacket::e_ChatCannotPlaceLava ) ) );
+ servPlayer->connection->send(std::make_shared<ChatPacket>(L"", ChatPacket::e_ChatCannotPlaceLava));
}
delete hr;
@@ -141,13 +141,13 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
if (--itemInstance->count <= 0)
{
- return shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_water) );
+ return std::make_shared<ItemInstance>(Item::bucket_water);
}
else
{
- if (!player->inventory->add(shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_water))))
+ if (!player->inventory->add(std::make_shared<ItemInstance>(Item::bucket_water)))
{
- player->drop(shared_ptr<ItemInstance>(new ItemInstance(Item::bucket_water_Id, 1, 0)));
+ player->drop(std::make_shared<ItemInstance>(Item::bucket_water_Id, 1, 0));
}
return itemInstance;
}
@@ -168,13 +168,13 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
}
if (--itemInstance->count <= 0)
{
- return shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_lava) );
+ return std::make_shared<ItemInstance>(Item::bucket_lava);
}
else
{
- if (!player->inventory->add(shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_lava))))
+ if (!player->inventory->add(std::make_shared<ItemInstance>(Item::bucket_lava)))
{
- player->drop(shared_ptr<ItemInstance>(new ItemInstance(Item::bucket_lava_Id, 1, 0)));
+ player->drop(std::make_shared<ItemInstance>(Item::bucket_lava_Id, 1, 0));
}
return itemInstance;
}
@@ -183,7 +183,7 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
else if (content < 0)
{
delete hr;
- return shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_empty) );
+ return std::make_shared<ItemInstance>(Item::bucket_empty);
}
else
{
@@ -199,7 +199,7 @@ shared_ptr<ItemInstance> BucketItem::use(shared_ptr<ItemInstance> itemInstance,
if (emptyBucket(level, xt, yt, zt) && !player->abilities.instabuild)
{
- return shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_empty) );
+ return std::make_shared<ItemInstance>(Item::bucket_empty);
}
}
diff --git a/Minecraft.World/BufferedOutputStream.cpp b/Minecraft.World/BufferedOutputStream.cpp
index 19fc95af..4f9edbf6 100644
--- a/Minecraft.World/BufferedOutputStream.cpp
+++ b/Minecraft.World/BufferedOutputStream.cpp
@@ -79,7 +79,7 @@ void BufferedOutputStream::write(byteArray b)
//b - the byte to be written.
void BufferedOutputStream::write(unsigned int b)
{
- buf[count++] = (byte) b;
+ buf[count++] = static_cast<byte>(b);
if( count == buf.length )
{
flush();
diff --git a/Minecraft.World/Bush.cpp b/Minecraft.World/Bush.cpp
index 6f8e8d91..5575c837 100644
--- a/Minecraft.World/Bush.cpp
+++ b/Minecraft.World/Bush.cpp
@@ -63,7 +63,7 @@ bool Bush::canSurvive(Level *level, int x, int y, int z)
AABB *Bush::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
bool Bush::blocksLight()
diff --git a/Minecraft.World/ButtonTile.cpp b/Minecraft.World/ButtonTile.cpp
index 045d5597..b05d597d 100644
--- a/Minecraft.World/ButtonTile.cpp
+++ b/Minecraft.World/ButtonTile.cpp
@@ -21,7 +21,7 @@ Icon *ButtonTile::getTexture(int face, int data)
AABB *ButtonTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
int ButtonTile::getTickDelay(Level *level)
@@ -302,7 +302,7 @@ void ButtonTile::checkPressed(Level *level, int x, int y, int z)
bool shouldBePressed;
updateShape(data);
- Tile::ThreadStorage *tls = (Tile::ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ Tile::ThreadStorage *tls = static_cast<Tile::ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
vector<shared_ptr<Entity> > *entities = level->getEntitiesOfClass(typeid(Arrow), AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1));
shouldBePressed = !entities->empty();
delete entities;
diff --git a/Minecraft.World/ByteArrayInputStream.cpp b/Minecraft.World/ByteArrayInputStream.cpp
index b0167300..d79eff36 100644
--- a/Minecraft.World/ByteArrayInputStream.cpp
+++ b/Minecraft.World/ByteArrayInputStream.cpp
@@ -114,5 +114,5 @@ int64_t ByteArrayInputStream::skip(int64_t n)
ByteArrayInputStream::~ByteArrayInputStream()
{
- if(buf.data != NULL) delete [] buf.data;
+ if(buf.data != nullptr) delete [] buf.data;
} \ No newline at end of file
diff --git a/Minecraft.World/ByteArrayOutputStream.cpp b/Minecraft.World/ByteArrayOutputStream.cpp
index 9296fe5e..a9f36e04 100644
--- a/Minecraft.World/ByteArrayOutputStream.cpp
+++ b/Minecraft.World/ByteArrayOutputStream.cpp
@@ -20,7 +20,7 @@ ByteArrayOutputStream::ByteArrayOutputStream(unsigned int size)
ByteArrayOutputStream::~ByteArrayOutputStream()
{
- if (buf.data != NULL)
+ if (buf.data != nullptr)
delete[] buf.data;
}
@@ -33,7 +33,7 @@ void ByteArrayOutputStream::write(unsigned int b)
if( count + 1 >= buf.length )
buf.resize( buf.length * 2 );
- buf[count] = (byte) b;
+ buf[count] = static_cast<byte>(b);
count++;
}
diff --git a/Minecraft.World/ByteArrayTag.h b/Minecraft.World/ByteArrayTag.h
index 598515ac..1d3e3875 100644
--- a/Minecraft.World/ByteArrayTag.h
+++ b/Minecraft.World/ByteArrayTag.h
@@ -40,8 +40,8 @@ public:
{
if (Tag::equals(obj))
{
- ByteArrayTag *o = (ByteArrayTag *) obj;
- return ((data.data == NULL && o->data.data == NULL) || (data.data != NULL && data.length == o->data.length && memcmp(data.data, o->data.data, data.length) == 0) );
+ ByteArrayTag *o = static_cast<ByteArrayTag *>(obj);
+ 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/ByteTag.h b/Minecraft.World/ByteTag.h
index 6b319c0b..ef236472 100644
--- a/Minecraft.World/ByteTag.h
+++ b/Minecraft.World/ByteTag.h
@@ -23,7 +23,7 @@ public:
{
if (Tag::equals(obj))
{
- ByteTag *o = (ByteTag *) obj;
+ ByteTag *o = static_cast<ByteTag *>(obj);
return data == o->data;
}
return false;
diff --git a/Minecraft.World/C4JThread.cpp b/Minecraft.World/C4JThread.cpp
index d0794f06..7993a0f6 100644
--- a/Minecraft.World/C4JThread.cpp
+++ b/Minecraft.World/C4JThread.cpp
@@ -21,7 +21,7 @@ CRITICAL_SECTION C4JThread::ms_threadListCS;
#ifdef _XBOX_ONE
// 4J Stu - On XboxOne the main thread is not the one that does all the static init, so we have to set this up later
-C4JThread *C4JThread::m_mainThread = NULL;
+C4JThread *C4JThread::m_mainThread = nullptr;
void C4JThread::StaticInit()
{
@@ -109,12 +109,12 @@ C4JThread::C4JThread( C4JThreadStartFunc* startFunc, void* param, const char* th
CPU = SCE_KERNEL_CPU_MASK_USER_1;
}
- m_threadID = sceKernelCreateThread(m_threadName, entryPoint, g_DefaultPriority, m_stackSize, 0, CPU, NULL);
+ m_threadID = sceKernelCreateThread(m_threadName, entryPoint, g_DefaultPriority, m_stackSize, 0, CPU, nullptr);
app.DebugPrintf("***************************** start thread %s **************************\n", m_threadName);
#else
m_threadID = 0;
m_threadHandle = 0;
- m_threadHandle = CreateThread(NULL, m_stackSize, entryPoint, this, CREATE_SUSPENDED, &m_threadID);
+ m_threadHandle = CreateThread(nullptr, m_stackSize, entryPoint, this, CREATE_SUSPENDED, &m_threadID);
#endif
EnterCriticalSection(&ms_threadListCS);
ms_threadList.push_back(this);
@@ -128,8 +128,8 @@ C4JThread::C4JThread( const char* mainThreadName)
user_registerthread();
#endif
- m_startFunc = NULL;
- m_threadParam = NULL;
+ m_startFunc = nullptr;
+ m_threadParam = nullptr;
m_stackSize = 0;
#ifdef __PS3__
@@ -178,7 +178,7 @@ C4JThread::~C4JThread()
#endif
#if defined __ORBIS__
- scePthreadJoin(m_threadID, NULL);
+ scePthreadJoin(m_threadID, nullptr);
#endif
EnterCriticalSection(&ms_threadListCS);
@@ -212,7 +212,7 @@ void * C4JThread::entryPoint(void *param)
pThread->m_exitCode = (*pThread->m_startFunc)(pThread->m_threadParam);
pThread->m_completionFlag->Set();
pThread->m_isRunning = false;
- scePthreadExit(NULL);
+ scePthreadExit(nullptr);
}
#elif defined __PSVITA__
struct StrArg {
@@ -233,14 +233,14 @@ SceInt32 C4JThread::entryPoint(SceSize argSize, void *pArgBlock)
PSVitaTLSStorage::RemoveThread(pThread->m_threadID);
user_removethread();
- sceKernelExitDeleteThread(NULL);
+ sceKernelExitDeleteThread(nullptr);
return pThread->m_exitCode;
}
#else
DWORD WINAPI C4JThread::entryPoint(LPVOID lpParam)
{
- C4JThread* pThread = (C4JThread*)lpParam;
+ C4JThread* pThread = static_cast<C4JThread *>(lpParam);
SetThreadName(-1, pThread->m_threadName);
pThread->m_exitCode = (*pThread->m_startFunc)(pThread->m_threadParam);
pThread->m_isRunning = false;
@@ -270,7 +270,7 @@ void C4JThread::Run()
scePthreadAttrDestroy(&m_threadAttr);
#elif defined __PSVITA__
StrArg strArg = {this};
-// m_threadID = sceKernelCreateThread(m_threadName, entryPoint, m_priority, m_stackSize, 0, m_CPUMask, NULL);
+// m_threadID = sceKernelCreateThread(m_threadName, entryPoint, m_priority, m_stackSize, 0, m_CPUMask, nullptr);
sceKernelStartThread( m_threadID, sizeof(strArg), &strArg);
#else
ResumeThread(m_threadHandle);
@@ -439,7 +439,7 @@ C4JThread* C4JThread::getCurrentThread()
#endif //__PS3__
EnterCriticalSection(&ms_threadListCS);
- for(int i=0;i<ms_threadList.size(); i++)
+ for(size_t i=0;i<ms_threadList.size(); i++)
{
if(currThreadID == ms_threadList[i]->m_threadID)
{
@@ -450,7 +450,7 @@ C4JThread* C4JThread::getCurrentThread()
LeaveCriticalSection(&ms_threadListCS);
- return NULL;
+ return nullptr;
}
bool C4JThread::isMainThread()
@@ -480,12 +480,12 @@ C4JThread::Event::Event(EMode mode/* = e_modeAutoClear*/)
#elif defined __ORBIS__
char name[1] = {0};
- sceKernelCreateEventFlag( &m_event, name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, NULL);
+ sceKernelCreateEventFlag( &m_event, name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, nullptr);
#elif defined __PSVITA__
char name[1] = {0};
- m_event = sceKernelCreateEventFlag( name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, NULL);
+ m_event = sceKernelCreateEventFlag( name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, nullptr);
#else
- m_event = CreateEvent( NULL, (m_mode == e_modeManualClear), FALSE, NULL );
+ m_event = CreateEvent( nullptr, (m_mode == e_modeManualClear), FALSE, nullptr );
#endif //__PS3__
}
@@ -554,7 +554,7 @@ DWORD C4JThread::Event::WaitForSignal( int timeoutMs )
SceKernelUseconds *pTimeoutMicrosecs;
if( timeoutMs == INFINITE )
{
- pTimeoutMicrosecs = NULL;
+ pTimeoutMicrosecs = nullptr;
}
else
{
@@ -566,7 +566,7 @@ DWORD C4JThread::Event::WaitForSignal( int timeoutMs )
{
waitMode |= SCE_KERNEL_EVF_WAITMODE_CLEAR_PAT;
}
- int err = sceKernelWaitEventFlag(m_event, 1, waitMode, NULL, pTimeoutMicrosecs);
+ int err = sceKernelWaitEventFlag(m_event, 1, waitMode, nullptr, pTimeoutMicrosecs);
switch(err)
{
case SCE_OK: return WAIT_OBJECT_0;
@@ -579,7 +579,7 @@ DWORD C4JThread::Event::WaitForSignal( int timeoutMs )
SceUInt32 *pTimeoutMicrosecs;
if( timeoutMs == INFINITE )
{
- pTimeoutMicrosecs = NULL;
+ pTimeoutMicrosecs = nullptr;
}
else
{
@@ -591,7 +591,7 @@ DWORD C4JThread::Event::WaitForSignal( int timeoutMs )
{
waitMode |= SCE_KERNEL_EVF_WAITMODE_CLEAR_ALL;
}
- int err = sceKernelWaitEventFlag(m_event, 1, waitMode, NULL, pTimeoutMicrosecs);
+ int err = sceKernelWaitEventFlag(m_event, 1, waitMode, nullptr, pTimeoutMicrosecs);
switch(err)
{
case SCE_OK: return WAIT_OBJECT_0;
@@ -623,15 +623,15 @@ C4JThread::EventArray::EventArray( int size, EMode mode/* = e_modeAutoClear*/)
assert(err == CELL_OK);
#elif defined __ORBIS__
char name[1] = {0};
- sceKernelCreateEventFlag( &m_events, name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, NULL);
+ sceKernelCreateEventFlag( &m_events, name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, nullptr);
#elif defined __PSVITA__
char name[1] = {0};
- m_events = sceKernelCreateEventFlag( name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, NULL);
+ m_events = sceKernelCreateEventFlag( name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, nullptr);
#else
m_events = new HANDLE[size];
for(int i=0;i<size;i++)
{
- m_events[i] = CreateEvent(NULL, (m_mode == e_modeManualClear), FALSE, NULL );
+ m_events[i] = CreateEvent(nullptr, (m_mode == e_modeManualClear), FALSE, nullptr );
}
#endif // __PS3__
}
@@ -713,7 +713,7 @@ DWORD C4JThread::EventArray::WaitForSingle(int index, int timeoutMs )
SceKernelUseconds *pTimeoutMicrosecs;
if( timeoutMs == INFINITE )
{
- pTimeoutMicrosecs = NULL;
+ pTimeoutMicrosecs = nullptr;
}
else
{
@@ -748,7 +748,7 @@ DWORD C4JThread::EventArray::WaitForSingle(int index, int timeoutMs )
SceUInt32 *pTimeoutMicrosecs;
if( timeoutMs == INFINITE )
{
- pTimeoutMicrosecs = NULL;
+ pTimeoutMicrosecs = nullptr;
}
else
{
@@ -760,7 +760,7 @@ DWORD C4JThread::EventArray::WaitForSingle(int index, int timeoutMs )
{
waitMode |= SCE_KERNEL_EVF_WAITMODE_CLEAR_ALL;
}
- int err = sceKernelWaitEventFlag(m_events, 1<<index, waitMode, NULL, pTimeoutMicrosecs);
+ int err = sceKernelWaitEventFlag(m_events, 1<<index, waitMode, nullptr, pTimeoutMicrosecs);
switch(err)
{
case SCE_OK: return WAIT_OBJECT_0;
@@ -814,7 +814,7 @@ DWORD C4JThread::EventArray::WaitForAll(int timeoutMs )
SceKernelUseconds *pTimeoutMicrosecs;
if( timeoutMs == INFINITE )
{
- pTimeoutMicrosecs = NULL;
+ pTimeoutMicrosecs = nullptr;
}
else
{
@@ -829,7 +829,7 @@ DWORD C4JThread::EventArray::WaitForAll(int timeoutMs )
{
waitMode |= SCE_KERNEL_EVF_WAITMODE_CLEAR_PAT;
}
- int err = sceKernelWaitEventFlag(m_events, bitmask, waitMode, NULL, pTimeoutMicrosecs);
+ int err = sceKernelWaitEventFlag(m_events, bitmask, waitMode, nullptr, pTimeoutMicrosecs);
switch(err)
{
case SCE_OK:
@@ -850,7 +850,7 @@ DWORD C4JThread::EventArray::WaitForAll(int timeoutMs )
SceUInt32 *pTimeoutMicrosecs;
if( timeoutMs == INFINITE )
{
- pTimeoutMicrosecs = NULL;
+ pTimeoutMicrosecs = nullptr;
}
else
{
@@ -865,7 +865,7 @@ DWORD C4JThread::EventArray::WaitForAll(int timeoutMs )
{
waitMode |= SCE_KERNEL_EVF_WAITMODE_CLEAR_ALL;
}
- int err = sceKernelWaitEventFlag(m_events, bitmask, waitMode, NULL, pTimeoutMicrosecs);
+ int err = sceKernelWaitEventFlag(m_events, bitmask, waitMode, nullptr, pTimeoutMicrosecs);
switch(err)
{
case SCE_OK: return WAIT_OBJECT_0;
@@ -911,7 +911,7 @@ DWORD C4JThread::EventArray::WaitForAny(int timeoutMs )
SceKernelUseconds *pTimeoutMicrosecs;
if( timeoutMs == INFINITE )
{
- pTimeoutMicrosecs = NULL;
+ pTimeoutMicrosecs = nullptr;
}
else
{
@@ -926,7 +926,7 @@ DWORD C4JThread::EventArray::WaitForAny(int timeoutMs )
{
waitMode |= SCE_KERNEL_EVF_WAITMODE_CLEAR_PAT;
}
- int err = sceKernelWaitEventFlag(m_events, bitmask, waitMode, NULL, pTimeoutMicrosecs);
+ int err = sceKernelWaitEventFlag(m_events, bitmask, waitMode, nullptr, pTimeoutMicrosecs);
switch(err)
{
case SCE_OK: return WAIT_OBJECT_0;
@@ -939,7 +939,7 @@ DWORD C4JThread::EventArray::WaitForAny(int timeoutMs )
SceUInt32 *pTimeoutMicrosecs;
if( timeoutMs == INFINITE )
{
- pTimeoutMicrosecs = NULL;
+ pTimeoutMicrosecs = nullptr;
}
else
{
@@ -954,7 +954,7 @@ DWORD C4JThread::EventArray::WaitForAny(int timeoutMs )
{
waitMode |= SCE_KERNEL_EVF_WAITMODE_CLEAR_ALL;
}
- int err = sceKernelWaitEventFlag(m_events, bitmask, waitMode, NULL, pTimeoutMicrosecs);
+ int err = sceKernelWaitEventFlag(m_events, bitmask, waitMode, nullptr, pTimeoutMicrosecs);
switch(err)
{
case SCE_OK: return WAIT_OBJECT_0;
@@ -970,7 +970,7 @@ DWORD C4JThread::EventArray::WaitForAny(int timeoutMs )
#ifdef __PS3__
void C4JThread::EventArray::Cancel()
{
- sys_event_flag_cancel(m_events, NULL);
+ sys_event_flag_cancel(m_events, nullptr);
}
#endif
@@ -982,9 +982,9 @@ C4JThread::EventQueue::EventQueue( UpdateFunc* updateFunc, ThreadInitFunc thread
m_updateFunc = updateFunc;
m_threadInitFunc = threadInitFunc;
strcpy(m_threadName, szThreadName);
- m_thread = NULL;
- m_startEvent = NULL;
- m_finishedEvent = NULL;
+ m_thread = nullptr;
+ m_startEvent = nullptr;
+ m_finishedEvent = nullptr;
m_processor = -1;
m_priority = THREAD_PRIORITY_HIGHEST+1;
}
@@ -1004,7 +1004,7 @@ void C4JThread::EventQueue::init()
void C4JThread::EventQueue::sendEvent( Level* pLevel )
{
- if(m_thread == NULL)
+ if(m_thread == nullptr)
init();
EnterCriticalSection(&m_critSect);
m_queue.push(pLevel);
@@ -1015,7 +1015,7 @@ void C4JThread::EventQueue::sendEvent( Level* pLevel )
void C4JThread::EventQueue::waitForFinish()
{
- if(m_thread == NULL)
+ if(m_thread == nullptr)
init();
EnterCriticalSection(&m_critSect);
if(m_queue.empty())
@@ -1029,7 +1029,7 @@ void C4JThread::EventQueue::waitForFinish()
int C4JThread::EventQueue::threadFunc( void* lpParam )
{
- EventQueue* p = (EventQueue*)lpParam;
+ EventQueue* p = static_cast<EventQueue *>(lpParam);
p->threadPoll();
return 0;
}
diff --git a/Minecraft.World/CactusTile.cpp b/Minecraft.World/CactusTile.cpp
index cdce293c..c306f11a 100644
--- a/Minecraft.World/CactusTile.cpp
+++ b/Minecraft.World/CactusTile.cpp
@@ -11,8 +11,8 @@
CactusTile::CactusTile(int id) : Tile(id, Material::cactus,isSolidRender())
{
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/CakeTile.cpp b/Minecraft.World/CakeTile.cpp
index 55dff176..0ef4fe18 100644
--- a/Minecraft.World/CakeTile.cpp
+++ b/Minecraft.World/CakeTile.cpp
@@ -13,9 +13,9 @@ CakeTile::CakeTile(int id) : Tile(id, Material::cake,isSolidRender())
{
setTicking(true);
- iconTop = NULL;
- iconBottom = NULL;
- iconInner = NULL;
+ iconTop = nullptr;
+ iconBottom = nullptr;
+ iconInner = nullptr;
}
void CakeTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
diff --git a/Minecraft.World/CanyonFeature.cpp b/Minecraft.World/CanyonFeature.cpp
index a375db7d..d25def53 100644
--- a/Minecraft.World/CanyonFeature.cpp
+++ b/Minecraft.World/CanyonFeature.cpp
@@ -141,11 +141,11 @@ void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs, byteArray bloc
{
if (yy < 10)
{
- blocks[p] = (byte) Tile::lava_Id;
+ blocks[p] = static_cast<byte>(Tile::lava_Id);
}
else
{
- blocks[p] = (byte) 0;
+ blocks[p] = static_cast<byte>(0);
if (hasGrass && blocks[p - 1] == Tile::dirt_Id) blocks[p - 1] = (byte) level->getBiome(xx + xOffs * 16, zz + zOffs * 16)->topMaterial;
}
}
@@ -179,7 +179,7 @@ void CanyonFeature::addFeature(Level *level, int x, int z, int xOffs, int zOffs,
addTunnel(random->nextLong(), xOffs, zOffs, blocks, xCave, yCave, zCave, thickness, yRot, xRot, 0, 0, 3.0);
// 4J Add to feature list
- app.AddTerrainFeaturePosition(eTerrainFeature_Ravine,(int)(xCave/16.0),(int)(yCave/16.0));
+ app.AddTerrainFeaturePosition(eTerrainFeature_Ravine,static_cast<int>(xCave / 16.0),static_cast<int>(yCave / 16.0));
}
} \ No newline at end of file
diff --git a/Minecraft.World/CarrotOnAStickItem.cpp b/Minecraft.World/CarrotOnAStickItem.cpp
index 3701fce1..cc39196c 100644
--- a/Minecraft.World/CarrotOnAStickItem.cpp
+++ b/Minecraft.World/CarrotOnAStickItem.cpp
@@ -35,7 +35,7 @@ shared_ptr<ItemInstance> CarrotOnAStickItem::use(shared_ptr<ItemInstance> itemIn
if (itemInstance->count == 0)
{
- shared_ptr<ItemInstance> replacement = shared_ptr<ItemInstance>(new ItemInstance(Item::fishingRod));
+ shared_ptr<ItemInstance> replacement = std::make_shared<ItemInstance>(Item::fishingRod);
replacement->setTag(itemInstance->tag);
return replacement;
}
diff --git a/Minecraft.World/CauldronTile.cpp b/Minecraft.World/CauldronTile.cpp
index f7a8d044..c77ebd28 100644
--- a/Minecraft.World/CauldronTile.cpp
+++ b/Minecraft.World/CauldronTile.cpp
@@ -13,9 +13,9 @@ const wstring CauldronTile::TEXTURE_BOTTOM = L"cauldron_bottom";
CauldronTile::CauldronTile(int id) : Tile(id, Material::metal, isSolidRender())
{
- iconInner = NULL;
- iconTop = NULL;
- iconBottom = NULL;
+ iconInner = nullptr;
+ iconTop = nullptr;
+ iconBottom = nullptr;
}
Icon *CauldronTile::getTexture(int face, int data)
@@ -43,7 +43,7 @@ Icon *CauldronTile::getTexture(const wstring &name)
{
if (name.compare(TEXTURE_INSIDE) == 0) return Tile::cauldron->iconInner;
if (name.compare(TEXTURE_BOTTOM) == 0) return Tile::cauldron->iconBottom;
- return NULL;
+ return nullptr;
}
void CauldronTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source)
@@ -93,7 +93,7 @@ bool CauldronTile::use(Level *level, int x, int y, int z, shared_ptr<Player> pla
}
shared_ptr<ItemInstance> item = player->inventory->getSelected();
- if (item == NULL)
+ if (item == nullptr)
{
return true;
}
@@ -107,7 +107,7 @@ bool CauldronTile::use(Level *level, int x, int y, int z, shared_ptr<Player> pla
{
if (!player->abilities.instabuild)
{
- player->inventory->setItem(player->inventory->selected, shared_ptr<ItemInstance>(new ItemInstance(Item::bucket_empty)));
+ player->inventory->setItem(player->inventory->selected, std::make_shared<ItemInstance>(Item::bucket_empty));
}
level->setData(x, y, z, 3, Tile::UPDATE_CLIENTS);
@@ -119,10 +119,10 @@ bool CauldronTile::use(Level *level, int x, int y, int z, shared_ptr<Player> pla
{
if (fillLevel > 0)
{
- shared_ptr<ItemInstance> potion = shared_ptr<ItemInstance>(new ItemInstance(Item::potion, 1, 0));
+ shared_ptr<ItemInstance> potion = std::make_shared<ItemInstance>(Item::potion, 1, 0);
if (!player->inventory->add(potion))
{
- level->addEntity(shared_ptr<ItemEntity>(new ItemEntity(level, x + 0.5, y + 1.5, z + 0.5, potion)));
+ level->addEntity(std::make_shared<ItemEntity>(level, x + 0.5, y + 1.5, z + 0.5, potion));
}
// 4J Stu - Brought forward change to update inventory when filling bottles with water
else if (player->instanceof(eTYPE_SERVERPLAYER))
diff --git a/Minecraft.World/CaveFeature.cpp b/Minecraft.World/CaveFeature.cpp
index 8183fbdf..edd81788 100644
--- a/Minecraft.World/CaveFeature.cpp
+++ b/Minecraft.World/CaveFeature.cpp
@@ -35,7 +35,7 @@ bool CaveFeature::place(Level *level, Random *random, int x, int y, int z)
double hr = (Mth::sin(d / 16.0f * PI) * radius + 1) * ss + 1;
// 4J Stu Added to stop cave features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
bool intersects = levelGenOptions->checkIntersects((xx - r / 2), (yy - hr / 2), (zz - r / 2), (xx + r / 2), (yy + hr / 2), (zz + r / 2));
@@ -46,9 +46,9 @@ bool CaveFeature::place(Level *level, Random *random, int x, int y, int z)
}
}
- for (int x2 = (int) (xx - r / 2); x2 <= (int) (xx + r / 2); x2++)
- for (int y2 = (int) (yy - hr / 2); y2 <= (int) (yy + hr / 2); y2++)
- for (int z2 = (int) (zz - r / 2); z2 <= (int) (zz + r / 2); z2++)
+ for (int x2 = static_cast<int>(xx - r / 2); x2 <= static_cast<int>(xx + r / 2); x2++)
+ for (int y2 = static_cast<int>(yy - hr / 2); y2 <= static_cast<int>(yy + hr / 2); y2++)
+ for (int z2 = static_cast<int>(zz - r / 2); z2 <= static_cast<int>(zz + r / 2); z2++)
{
double xd = ((x2 + 0.5) - xx) / (r / 2);
double yd = ((y2 + 0.5) - yy) / (hr / 2);
diff --git a/Minecraft.World/ChatPacket.cpp b/Minecraft.World/ChatPacket.cpp
index 2988962e..c4a3ca7c 100644
--- a/Minecraft.World/ChatPacket.cpp
+++ b/Minecraft.World/ChatPacket.cpp
@@ -43,7 +43,7 @@ ChatPacket::ChatPacket(const wstring& message, EChatPacketMessage type, int sour
// Read chat packet (throws IOException)
void ChatPacket::read(DataInputStream *dis)
{
- m_messageType = (EChatPacketMessage) dis->readShort();
+ m_messageType = static_cast<EChatPacketMessage>(dis->readShort());
short packedCounts = dis->readShort();
int stringCount = (packedCounts >> 4) & 0xF;
@@ -71,12 +71,12 @@ void ChatPacket::write(DataOutputStream *dos)
dos->writeShort(packedCounts);
- for(int i = 0; i < m_stringArgs.size(); i++)
+ for(size_t i = 0; i < m_stringArgs.size(); i++)
{
writeUtf(m_stringArgs[i], dos);
}
- for(int i = 0; i < m_intArgs.size(); i++)
+ for(size_t i = 0; i < m_intArgs.size(); i++)
{
dos->writeInt(m_intArgs[i]);
}
@@ -92,7 +92,7 @@ void ChatPacket::handle(PacketListener *listener)
int ChatPacket::getEstimatedSize()
{
int stringsSize = 0;
- for(int i = 0; i < m_stringArgs.size(); i++)
+ for(size_t i = 0; i < m_stringArgs.size(); i++)
{
stringsSize += m_stringArgs[i].length();
}
diff --git a/Minecraft.World/ChatPacket.h b/Minecraft.World/ChatPacket.h
index ca9e4955..ea9b3806 100644
--- a/Minecraft.World/ChatPacket.h
+++ b/Minecraft.World/ChatPacket.h
@@ -119,7 +119,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ChatPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ChatPacket>(); }
virtual int getId() { return 3; }
};
diff --git a/Minecraft.World/ChestTile.cpp b/Minecraft.World/ChestTile.cpp
index 11178b8a..ff3c0b40 100644
--- a/Minecraft.World/ChestTile.cpp
+++ b/Minecraft.World/ChestTile.cpp
@@ -208,18 +208,18 @@ void ChestTile::neighborChanged(Level *level, int x, int y, int z, int type)
{
BaseEntityTile::neighborChanged(level, x, y, z, type);
shared_ptr<ChestTileEntity>(cte) = dynamic_pointer_cast<ChestTileEntity>(level->getTileEntity(x, y, z));
- if (cte != NULL) cte->clearCache();
+ if (cte != nullptr) cte->clearCache();
}
void ChestTile::onRemove(Level *level, int x, int y, int z, int id, int data)
{
shared_ptr<Container> container = dynamic_pointer_cast<ChestTileEntity>( level->getTileEntity(x, y, z) );
- if (container != NULL )
+ if (container != nullptr )
{
for (unsigned int i = 0; i < container->getContainerSize(); i++)
{
shared_ptr<ItemInstance> 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;
@@ -231,16 +231,16 @@ void ChestTile::onRemove(Level *level, int x, int y, int z, int id, int data)
if (count > item->count) count = item->count;
item->count -= count;
- shared_ptr<ItemInstance> newItem = shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue()) );
+ shared_ptr<ItemInstance> newItem = std::make_shared<ItemInstance>(item->id, count, item->getAuxValue());
newItem->set4JData( item->get4JData() );
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>(new ItemEntity(level, x + xo, y + yo, z + zo, newItem ) );
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, newItem);
float pow = 0.05f;
- itemEntity->xd = (float) random->nextGaussian() * pow;
- itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f;
- itemEntity->zd = (float) random->nextGaussian() * pow;
+ itemEntity->xd = static_cast<float>(random->nextGaussian()) * pow;
+ itemEntity->yd = static_cast<float>(random->nextGaussian()) * pow + 0.2f;
+ itemEntity->zd = static_cast<float>(random->nextGaussian()) * pow;
if (item->hasTag())
{
- itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy());
+ itemEntity->getItem()->setTag(static_cast<CompoundTag *>(item->getTag()->copy()));
}
level->addEntity(itemEntity);
@@ -272,7 +272,7 @@ bool ChestTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player
}
shared_ptr<Container> container = getContainer(level, x, y, z);
- if (container != NULL)
+ if (container != nullptr)
{
player->openContainer(container);
}
@@ -283,7 +283,7 @@ bool ChestTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player
shared_ptr<Container> ChestTile::getContainer(Level *level, int x, int y, int z)
{
shared_ptr<Container> container = dynamic_pointer_cast<ChestTileEntity>( 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;
@@ -293,10 +293,10 @@ shared_ptr<Container> ChestTile::getContainer(Level *level, int x, int y, int z)
if (level->getTile(x, y, z - 1) == id && (level->isSolidBlockingTile(x, y + 1, z - 1) || isCatSittingOnChest(level, x, y, z - 1))) return nullptr;
if (level->getTile(x, y, z + 1) == id && (level->isSolidBlockingTile(x, y + 1, z + 1) || isCatSittingOnChest(level, x, y, z + 1))) return nullptr;
- if (level->getTile(x - 1, y, z) == id) container = shared_ptr<Container>( new CompoundContainer(IDS_CHEST_LARGE, dynamic_pointer_cast<ChestTileEntity>( level->getTileEntity(x - 1, y, z) ), container) );
- if (level->getTile(x + 1, y, z) == id) container = shared_ptr<Container>( new CompoundContainer(IDS_CHEST_LARGE, container, dynamic_pointer_cast<ChestTileEntity>( level->getTileEntity(x + 1, y, z) )) );
- if (level->getTile(x, y, z - 1) == id) container = shared_ptr<Container>( new CompoundContainer(IDS_CHEST_LARGE, dynamic_pointer_cast<ChestTileEntity>( level->getTileEntity(x, y, z - 1) ), container) );
- if (level->getTile(x, y, z + 1) == id) container = shared_ptr<Container>( new CompoundContainer(IDS_CHEST_LARGE, container, dynamic_pointer_cast<ChestTileEntity>( level->getTileEntity(x, y, z + 1) )) );
+ if (level->getTile(x - 1, y, z) == id) container = std::make_shared<CompoundContainer>(IDS_CHEST_LARGE, dynamic_pointer_cast<ChestTileEntity>(level->getTileEntity(x - 1, y, z)), container);
+ if (level->getTile(x + 1, y, z) == id) container = std::make_shared<CompoundContainer>(IDS_CHEST_LARGE, container, dynamic_pointer_cast<ChestTileEntity>(level->getTileEntity(x + 1, y, z)));
+ if (level->getTile(x, y, z - 1) == id) container = std::make_shared<CompoundContainer>(IDS_CHEST_LARGE, dynamic_pointer_cast<ChestTileEntity>(level->getTileEntity(x, y, z - 1)), container);
+ if (level->getTile(x, y, z + 1) == id) container = std::make_shared<CompoundContainer>(IDS_CHEST_LARGE, container, dynamic_pointer_cast<ChestTileEntity>(level->getTileEntity(x, y, z + 1)));
return container;
}
@@ -304,7 +304,7 @@ shared_ptr<Container> ChestTile::getContainer(Level *level, int x, int y, int z)
shared_ptr<TileEntity> ChestTile::newTileEntity(Level *level)
{
MemSect(50);
- shared_ptr<TileEntity> retval = shared_ptr<TileEntity>( new ChestTileEntity() );
+ shared_ptr<TileEntity> retval = std::make_shared<ChestTileEntity>();
MemSect(0);
return retval;
}
diff --git a/Minecraft.World/ChestTileEntity.cpp b/Minecraft.World/ChestTileEntity.cpp
index b8f323f4..ba277e24 100644
--- a/Minecraft.World/ChestTileEntity.cpp
+++ b/Minecraft.World/ChestTileEntity.cpp
@@ -65,7 +65,7 @@ shared_ptr<ItemInstance> ChestTileEntity::getItem(unsigned int slot)
shared_ptr<ItemInstance> ChestTileEntity::removeItem(unsigned int slot, int count)
{
- if (items->data[slot] != NULL)
+ if (items->data[slot] != nullptr)
{
if (items->data[slot]->count <= count)
{
@@ -91,7 +91,7 @@ shared_ptr<ItemInstance> ChestTileEntity::removeItem(unsigned int slot, int coun
shared_ptr<ItemInstance> ChestTileEntity::removeItemNoUpdate(int slot)
{
- if (items->data[slot] != NULL)
+ if (items->data[slot] != nullptr)
{
shared_ptr<ItemInstance> item = items->data[slot];
items->data[slot] = nullptr;
@@ -103,7 +103,7 @@ shared_ptr<ItemInstance> ChestTileEntity::removeItemNoUpdate(int slot)
void ChestTileEntity::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
items->data[slot] = item;
- if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize();
+ if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize();
this->setChanged();
}
@@ -154,10 +154,10 @@ void ChestTileEntity::save(CompoundTag *base)
for (unsigned int i = 0; i < items->length; i++)
{
- if (items->data[i] != NULL)
+ if (items->data[i] != nullptr)
{
CompoundTag *tag = new CompoundTag();
- tag->putByte(L"Slot", (byte) i);
+ tag->putByte(L"Slot", static_cast<byte>(i));
items->data[i]->save(tag);
listTag->add(tag);
}
@@ -244,17 +244,17 @@ void ChestTileEntity::checkNeighbors()
}
shared_ptr<ChestTileEntity> cteThis = dynamic_pointer_cast<ChestTileEntity>(shared_from_this());
- if (n.lock() != NULL) n.lock()->heyImYourNeighbor(cteThis, Direction::SOUTH);
- if (s.lock() != NULL) s.lock()->heyImYourNeighbor(cteThis, Direction::NORTH);
- if (e.lock() != NULL) e.lock()->heyImYourNeighbor(cteThis, Direction::WEST);
- if (w.lock() != NULL) w.lock()->heyImYourNeighbor(cteThis, Direction::EAST);
+ if (n.lock() != nullptr) n.lock()->heyImYourNeighbor(cteThis, Direction::SOUTH);
+ if (s.lock() != nullptr) s.lock()->heyImYourNeighbor(cteThis, Direction::NORTH);
+ if (e.lock() != nullptr) e.lock()->heyImYourNeighbor(cteThis, Direction::WEST);
+ if (w.lock() != nullptr) w.lock()->heyImYourNeighbor(cteThis, Direction::EAST);
}
bool ChestTileEntity::isSameChest(int x, int y, int z)
{
Tile *tile = Tile::tiles[level->getTile(x, y, z)];
- if (tile == NULL || !(dynamic_cast<ChestTile *>(tile) != NULL)) return false;
- return ((ChestTile *) tile)->type == getType();
+ if (tile == nullptr || !(dynamic_cast<ChestTile *>(tile) != nullptr)) return false;
+ return static_cast<ChestTile *>(tile)->type == getType();
}
void ChestTileEntity::tick()
@@ -283,7 +283,7 @@ void ChestTileEntity::tick()
shared_ptr<Container> container = containerMenu->getContainer();
shared_ptr<Container> thisContainer = dynamic_pointer_cast<Container>(shared_from_this());
shared_ptr<CompoundContainer> compoundContainer = dynamic_pointer_cast<CompoundContainer>(container);
- if ((container == thisContainer) || (compoundContainer != NULL && compoundContainer->contains(thisContainer)))
+ if ((container == thisContainer) || (compoundContainer != nullptr && compoundContainer->contains(thisContainer)))
{
openCount++;
}
@@ -298,12 +298,12 @@ void ChestTileEntity::tick()
float speed = 0.10f;
if (openCount > 0 && openness == 0)
{
- if (n.lock() == NULL && w.lock() == NULL)
+ if (n.lock() == nullptr && w.lock() == nullptr)
{
double xc = x + 0.5;
double zc = z + 0.5;
- if (s.lock() != NULL) zc += 0.5;
- if (e.lock() != NULL) xc += 0.5;
+ if (s.lock() != nullptr) zc += 0.5;
+ if (e.lock() != nullptr) xc += 0.5;
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_OPEN, 0.2f, level->random->nextFloat() * 0.1f + 0.9f);
@@ -323,12 +323,12 @@ void ChestTileEntity::tick()
{
// Fix for #64546 - Customer Encountered: TU7: Chests placed by the Player are closing too fast.
//openness = 0;
- if (n.lock() == NULL && w.lock() == NULL)
+ if (n.lock() == nullptr && w.lock() == nullptr)
{
double xc = x + 0.5;
double zc = z + 0.5;
- if (s.lock() != NULL) zc += 0.5;
- if (e.lock() != NULL) xc += 0.5;
+ if (s.lock() != nullptr) zc += 0.5;
+ if (e.lock() != nullptr) xc += 0.5;
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_CLOSE, 0.2f, level->random->nextFloat() * 0.1f + 0.9f);
@@ -366,7 +366,7 @@ void ChestTileEntity::startOpen()
void ChestTileEntity::stopOpen()
{
- if (getTile() == NULL || !( dynamic_cast<ChestTile *>( getTile() ) != NULL)) return;
+ if (getTile() == nullptr || !( dynamic_cast<ChestTile *>( getTile() ) != nullptr)) return;
openCount--;
level->tileEvent(x, y, z, getTile()->id, ChestTile::EVENT_SET_OPEN_COUNT, openCount);
level->updateNeighborsAt(x, y, z, getTile()->id);
@@ -389,9 +389,9 @@ int ChestTileEntity::getType()
{
if (type == -1)
{
- if (level != NULL && dynamic_cast<ChestTile *>( getTile() ) != NULL)
+ if (level != nullptr && dynamic_cast<ChestTile *>( getTile() ) != nullptr)
{
- type = ((ChestTile *) getTile())->type;
+ type = static_cast<ChestTile *>(getTile())->type;
}
else
{
@@ -405,12 +405,12 @@ int ChestTileEntity::getType()
// 4J Added
shared_ptr<TileEntity> ChestTileEntity::clone()
{
- shared_ptr<ChestTileEntity> result = shared_ptr<ChestTileEntity>( new ChestTileEntity() );
+ shared_ptr<ChestTileEntity> result = std::make_shared<ChestTileEntity>();
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/Chicken.cpp b/Minecraft.World/Chicken.cpp
index 5f4cf2a7..355d8a25 100644
--- a/Minecraft.World/Chicken.cpp
+++ b/Minecraft.World/Chicken.cpp
@@ -143,7 +143,7 @@ shared_ptr<AgableMob> Chicken::getBreedOffspring(shared_ptr<AgableMob> target)
// 4J - added limit to chickens that can be bred
if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) )
{
- return shared_ptr<Chicken>(new Chicken(level));
+ return std::make_shared<Chicken>(level);
}
else
{
diff --git a/Minecraft.World/ChunkPos.cpp b/Minecraft.World/ChunkPos.cpp
index acf885c0..6d37a446 100644
--- a/Minecraft.World/ChunkPos.cpp
+++ b/Minecraft.World/ChunkPos.cpp
@@ -16,8 +16,8 @@ int64_t ChunkPos::hashCode(int x, int z)
int ChunkPos::hashCode()
{
int64_t hash = hashCode(x, z);
- int h1 = (int) (hash);
- int h2 = (int) (hash >> 32l);
+ const int h1 = static_cast<int>(hash);
+ const int h2 = static_cast<int>(hash >> 32l);
return h1 ^ h2;
}
diff --git a/Minecraft.World/ChunkSource.h b/Minecraft.World/ChunkSource.h
index c537651c..37b0ecc3 100644
--- a/Minecraft.World/ChunkSource.h
+++ b/Minecraft.World/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/ChunkStorageProfileDecorator.cpp b/Minecraft.World/ChunkStorageProfileDecorator.cpp
index 5d757811..375048db 100644
--- a/Minecraft.World/ChunkStorageProfileDecorator.cpp
+++ b/Minecraft.World/ChunkStorageProfileDecorator.cpp
@@ -45,7 +45,7 @@ void ChunkStorageProfilerDecorator::tick()
#ifdef __PSVITA__
sprintf(buf,"Average load time: %f (%lld)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount);
#else
- sprintf(buf,"Average load time: %f (%I64d)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount);
+ sprintf(buf,"Average load time: %f (%I64d)",0.000001 * static_cast<double>(timeSpentLoading) / static_cast<double>(loadCount), loadCount);
#endif
app.DebugPrintf(buf);
#endif
@@ -56,7 +56,7 @@ void ChunkStorageProfilerDecorator::tick()
#ifdef __PSVITA__
sprintf(buf,"Average save time: %f (%lld)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount);
#else
- sprintf(buf,"Average save time: %f (%I64d)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount);
+ sprintf(buf,"Average save time: %f (%I64d)",0.000001 * static_cast<double>(timeSpentSaving) / static_cast<double>(loadCount), loadCount);
#endif
app.DebugPrintf(buf);
#endif
diff --git a/Minecraft.World/ChunkTilesUpdatePacket.cpp b/Minecraft.World/ChunkTilesUpdatePacket.cpp
index d90e6b2f..de5abea1 100644
--- a/Minecraft.World/ChunkTilesUpdatePacket.cpp
+++ b/Minecraft.World/ChunkTilesUpdatePacket.cpp
@@ -42,8 +42,8 @@ ChunkTilesUpdatePacket::ChunkTilesUpdatePacket(int xc, int zc, shortArray positi
int y = (positions[i]) & 255;
this->positions[i] = positions[i];
- blocks[i] = (byte) levelChunk->getTile(x, y, z);
- data[i] = (byte) levelChunk->getData(x, y, z);
+ blocks[i] = static_cast<byte>(levelChunk->getTile(x, y, z));
+ data[i] = static_cast<byte>(levelChunk->getData(x, y, z));
}
levelIdx = ( ( level->dimension->id == 0 ) ? 0 : ( (level->dimension->id == -1) ? 1 : 2 ) );
}
diff --git a/Minecraft.World/ChunkTilesUpdatePacket.h b/Minecraft.World/ChunkTilesUpdatePacket.h
index a97f49a3..7cbc3c65 100644
--- a/Minecraft.World/ChunkTilesUpdatePacket.h
+++ b/Minecraft.World/ChunkTilesUpdatePacket.h
@@ -25,7 +25,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ChunkTilesUpdatePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ChunkTilesUpdatePacket>(); }
virtual int getId() { return 52; }
};
diff --git a/Minecraft.World/ChunkVisibilityAreaPacket.h b/Minecraft.World/ChunkVisibilityAreaPacket.h
index 33087497..9442b6f7 100644
--- a/Minecraft.World/ChunkVisibilityAreaPacket.h
+++ b/Minecraft.World/ChunkVisibilityAreaPacket.h
@@ -25,6 +25,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ChunkVisibilityAreaPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ChunkVisibilityAreaPacket>(); }
virtual int getId() { return 155; }
};
diff --git a/Minecraft.World/ChunkVisibilityPacket.h b/Minecraft.World/ChunkVisibilityPacket.h
index 8c5856c7..74af7f4d 100644
--- a/Minecraft.World/ChunkVisibilityPacket.h
+++ b/Minecraft.World/ChunkVisibilityPacket.h
@@ -22,7 +22,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ChunkVisibilityPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ChunkVisibilityPacket>(); }
virtual int getId() { return 50; }
};
diff --git a/Minecraft.World/ClientCommandPacket.h b/Minecraft.World/ClientCommandPacket.h
index 2f614ddf..b3578a10 100644
--- a/Minecraft.World/ClientCommandPacket.h
+++ b/Minecraft.World/ClientCommandPacket.h
@@ -19,6 +19,6 @@ public:
int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ClientCommandPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ClientCommandPacket>(); }
virtual int getId() { return 205; }
}; \ No newline at end of file
diff --git a/Minecraft.World/ClientSideMerchant.cpp b/Minecraft.World/ClientSideMerchant.cpp
index ba179300..1b54580b 100644
--- a/Minecraft.World/ClientSideMerchant.cpp
+++ b/Minecraft.World/ClientSideMerchant.cpp
@@ -7,8 +7,8 @@ ClientSideMerchant::ClientSideMerchant(shared_ptr<Player> source, const wstring
{
this->source = source;
// 4J Stu - Need to do this after creating as a shared_ptr
- container = NULL; //new MerchantContainer(source, this);
- currentOffers = NULL;
+ container = nullptr; //new MerchantContainer(source, this);
+ currentOffers = nullptr;
m_name = name;
}
diff --git a/Minecraft.World/ClockItem.cpp b/Minecraft.World/ClockItem.cpp
index afe0544d..83b8e7a4 100644
--- a/Minecraft.World/ClockItem.cpp
+++ b/Minecraft.World/ClockItem.cpp
@@ -12,7 +12,7 @@ const wstring ClockItem::TEXTURE_PLAYER_ICON[XUSER_MAX_COUNT] = {L"clockP0",L"cl
ClockItem::ClockItem(int id) : Item(id)
{
- icons = NULL;
+ icons = nullptr;
}
// 4J Added so that we can override the icon id used to calculate the texture UV's for each player
@@ -21,7 +21,7 @@ Icon *ClockItem::getIcon(int auxValue)
Icon *icon = Item::getIcon(auxValue);
Minecraft *pMinecraft = Minecraft::GetInstance();
- if( pMinecraft->player != NULL && auxValue == 0 )
+ if( pMinecraft->player != nullptr && auxValue == 0 )
{
icon = icons[pMinecraft->player->GetXboxPad()];
}
diff --git a/Minecraft.World/CocoaTile.cpp b/Minecraft.World/CocoaTile.cpp
index 095f9b52..3df58eb8 100644
--- a/Minecraft.World/CocoaTile.cpp
+++ b/Minecraft.World/CocoaTile.cpp
@@ -151,7 +151,7 @@ void CocoaTile::spawnResources(Level *level, int x, int y, int z, int data, floa
}
for (int i = 0; i < count; i++)
{
- popResource(level, x, y, z, shared_ptr<ItemInstance>( new ItemInstance(Item::dye_powder, 1, DyePowderItem::BROWN) ));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(Item::dye_powder, 1, DyePowderItem::BROWN));
}
}
diff --git a/Minecraft.World/Color.cpp b/Minecraft.World/Color.cpp
index 256e9017..554ee379 100644
--- a/Minecraft.World/Color.cpp
+++ b/Minecraft.World/Color.cpp
@@ -18,7 +18,7 @@ Color::Color( float r, float g, float b)
assert( b >= 0.0f && b <= 1.0f );
//argb
- colour = ( (0xFF<<24) | ( (int)(r*255)<<16 ) | ( (int)(g*255)<<8 ) | ( (int)(b*255) ) );
+ colour = ( (0xFF<<24) | ( static_cast<int>(r * 255)<<16 ) | ( static_cast<int>(g * 255)<<8 ) | static_cast<int>(b * 255) );
}
Color::Color( int r, int g, int b)
@@ -43,7 +43,7 @@ Color Color::getHSBColor(float hue, float saturation, float brightness)
int r = 0, g = 0, b = 0;
if (saturation == 0)
{
- r = g = b = (int) (brightness * 255.0f + 0.5f);
+ r = g = b = static_cast<int>(brightness * 255.0f + 0.5f);
}
else
{
@@ -52,37 +52,37 @@ Color Color::getHSBColor(float hue, float saturation, float brightness)
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
- switch ((int) h)
+ switch (static_cast<int>(h))
{
case 0:
- r = (int) (brightness * 255.0f + 0.5f);
- g = (int) (t * 255.0f + 0.5f);
- b = (int) (p * 255.0f + 0.5f);
+ r = static_cast<int>(brightness * 255.0f + 0.5f);
+ g = static_cast<int>(t * 255.0f + 0.5f);
+ b = static_cast<int>(p * 255.0f + 0.5f);
break;
case 1:
- r = (int) (q * 255.0f + 0.5f);
- g = (int) (brightness * 255.0f + 0.5f);
- b = (int) (p * 255.0f + 0.5f);
+ r = static_cast<int>(q * 255.0f + 0.5f);
+ g = static_cast<int>(brightness * 255.0f + 0.5f);
+ b = static_cast<int>(p * 255.0f + 0.5f);
break;
case 2:
- r = (int) (p * 255.0f + 0.5f);
- g = (int) (brightness * 255.0f + 0.5f);
- b = (int) (t * 255.0f + 0.5f);
+ r = static_cast<int>(p * 255.0f + 0.5f);
+ g = static_cast<int>(brightness * 255.0f + 0.5f);
+ b = static_cast<int>(t * 255.0f + 0.5f);
break;
case 3:
- r = (int) (p * 255.0f + 0.5f);
- g = (int) (q * 255.0f + 0.5f);
- b = (int) (brightness * 255.0f + 0.5f);
+ r = static_cast<int>(p * 255.0f + 0.5f);
+ g = static_cast<int>(q * 255.0f + 0.5f);
+ b = static_cast<int>(brightness * 255.0f + 0.5f);
break;
case 4:
- r = (int) (t * 255.0f + 0.5f);
- g = (int) (p * 255.0f + 0.5f);
- b = (int) (brightness * 255.0f + 0.5f);
+ r = static_cast<int>(t * 255.0f + 0.5f);
+ g = static_cast<int>(p * 255.0f + 0.5f);
+ b = static_cast<int>(brightness * 255.0f + 0.5f);
break;
case 5:
- r = (int) (brightness * 255.0f + 0.5f);
- g = (int) (p * 255.0f + 0.5f);
- b = (int) (q * 255.0f + 0.5f);
+ r = static_cast<int>(brightness * 255.0f + 0.5f);
+ g = static_cast<int>(p * 255.0f + 0.5f);
+ b = static_cast<int>(q * 255.0f + 0.5f);
break;
}
}
diff --git a/Minecraft.World/ColoredTileItem.cpp b/Minecraft.World/ColoredTileItem.cpp
index 37ea4c63..f659d7a5 100644
--- a/Minecraft.World/ColoredTileItem.cpp
+++ b/Minecraft.World/ColoredTileItem.cpp
@@ -15,7 +15,7 @@ ColoredTileItem::ColoredTileItem(int id, bool stackedByData) : TileItem(id)
ColoredTileItem::~ColoredTileItem()
{
- if(descriptionPostfixes.data != NULL) delete [] descriptionPostfixes.data;
+ if(descriptionPostfixes.data != nullptr) delete [] descriptionPostfixes.data;
}
int ColoredTileItem::getColor(shared_ptr<ItemInstance> item, int spriteLayer)
@@ -35,7 +35,7 @@ int ColoredTileItem::getLevelDataForAuxValue(int auxValue)
ColoredTileItem *ColoredTileItem::setDescriptionPostfixes(intArray descriptionPostfixes)
{
- if(this->descriptionPostfixes.data != NULL) delete this->descriptionPostfixes.data;
+ if(this->descriptionPostfixes.data != nullptr) delete this->descriptionPostfixes.data;
this->descriptionPostfixes = intArray(descriptionPostfixes.length);
for(unsigned int i = 0; i < descriptionPostfixes.length; ++i )
{
@@ -47,7 +47,7 @@ ColoredTileItem *ColoredTileItem::setDescriptionPostfixes(intArray descriptionPo
unsigned int ColoredTileItem::getDescriptionId(shared_ptr<ItemInstance> instance)
{
- if (descriptionPostfixes.data == NULL)
+ if (descriptionPostfixes.data == nullptr)
{
return TileItem::getDescriptionId(instance);
}
diff --git a/Minecraft.World/CombatEntry.cpp b/Minecraft.World/CombatEntry.cpp
index 903d95bb..5fe2e6d3 100644
--- a/Minecraft.World/CombatEntry.cpp
+++ b/Minecraft.World/CombatEntry.cpp
@@ -6,8 +6,8 @@
CombatEntry::CombatEntry(DamageSource *source, int time, float health, float damage, CombatTracker::eLOCATION location, float fallDistance)
{
- this->source = NULL;
- if(source != NULL)
+ this->source = nullptr;
+ if(source != nullptr)
{
// 4J: this might actually be a derived damage source so use copy func
this->source = source->copy();
@@ -61,7 +61,7 @@ CombatTracker::eLOCATION CombatEntry::getLocation()
wstring CombatEntry::getAttackerName()
{
- return getSource()->getEntity() == NULL ? L"" : getSource()->getEntity()->getNetworkName();
+ return getSource()->getEntity() == nullptr ? L"" : getSource()->getEntity()->getNetworkName();
}
float CombatEntry::getFallDistance()
diff --git a/Minecraft.World/CombatTracker.cpp b/Minecraft.World/CombatTracker.cpp
index 2d35913c..69029115 100644
--- a/Minecraft.World/CombatTracker.cpp
+++ b/Minecraft.World/CombatTracker.cpp
@@ -58,7 +58,7 @@ void CombatTracker::recordDamage(DamageSource *source, float health, float damag
shared_ptr<ChatPacket> CombatTracker::getDeathMessagePacket()
{
- if (entries.size() == 0) return shared_ptr<ChatPacket>(new ChatPacket(mob->getNetworkName()));
+ if (entries.size() == 0) return std::make_shared<ChatPacket>(mob->getNetworkName());
CombatEntry *knockOffEntry = getMostSignificantFall();
CombatEntry *killingBlow = entries[entries.size() - 1];
@@ -67,7 +67,7 @@ shared_ptr<ChatPacket> CombatTracker::getDeathMessagePacket()
shared_ptr<Entity> killingEntity = killingBlow->getSource()->getEntity();
- if (knockOffEntry != NULL && killingBlow->getSource()->equals(DamageSource::fall))
+ if (knockOffEntry != nullptr && killingBlow->getSource()->equals(DamageSource::fall))
{
shared_ptr<Entity> attackerEntity = knockOffEntry->getSource()->getEntity();
@@ -91,36 +91,36 @@ shared_ptr<ChatPacket> CombatTracker::getDeathMessagePacket()
break;
}
- result = shared_ptr<ChatPacket>(new ChatPacket(mob->getNetworkName(), message));
+ result = std::make_shared<ChatPacket>(mob->getNetworkName(), message);
}
- else if (attackerEntity != NULL && (killingEntity == NULL || attackerEntity != killingEntity))
+ else if (attackerEntity != nullptr && (killingEntity == nullptr || attackerEntity != killingEntity))
{
shared_ptr<ItemInstance> attackerItem = attackerEntity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast<LivingEntity>(attackerEntity)->getCarriedItem() : nullptr;
- if (attackerItem != NULL && attackerItem->hasCustomHoverName())
+ if (attackerItem != nullptr && attackerItem->hasCustomHoverName())
{
- result = shared_ptr<ChatPacket>(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssistItem, attackerEntity->GetType(), attackerEntity->getNetworkName(), attackerItem->getHoverName()));
+ result = std::make_shared<ChatPacket>(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssistItem, attackerEntity->GetType(), attackerEntity->getNetworkName(), attackerItem->getHoverName());
}
else
{
- result = shared_ptr<ChatPacket>(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssist, attackerEntity->GetType(), attackerEntity->getNetworkName()));
+ result = std::make_shared<ChatPacket>(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssist, attackerEntity->GetType(), attackerEntity->getNetworkName());
}
}
- else if (killingEntity != NULL)
+ else if (killingEntity != nullptr)
{
shared_ptr<ItemInstance> killerItem = killingEntity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast<LivingEntity>(killingEntity)->getCarriedItem() : nullptr;
- if (killerItem != NULL && killerItem->hasCustomHoverName())
+ if (killerItem != nullptr && killerItem->hasCustomHoverName())
{
- result = shared_ptr<ChatPacket>(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinishItem, killingEntity->GetType(), killingEntity->getNetworkName(), killerItem->getHoverName()));
+ result = std::make_shared<ChatPacket>(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinishItem, killingEntity->GetType(), killingEntity->getNetworkName(), killerItem->getHoverName());
}
else
{
- result = shared_ptr<ChatPacket>(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinish, killingEntity->GetType(), killingEntity->getNetworkName()));
+ result = std::make_shared<ChatPacket>(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinish, killingEntity->GetType(), killingEntity->getNetworkName());
}
}
else
{
- result = shared_ptr<ChatPacket>(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellKiller));
+ result = std::make_shared<ChatPacket>(mob->getNetworkName(), ChatPacket::e_ChatDeathFellKiller);
}
}
else
@@ -140,20 +140,20 @@ shared_ptr<LivingEntity> CombatTracker::getKiller()
for ( CombatEntry *entry : entries )
{
- if ( entry->getSource() != NULL && entry->getSource()->getEntity() != NULL && entry->getSource()->getEntity()->instanceof(eTYPE_PLAYER) && (bestPlayer == NULL || entry->getDamage() > bestPlayerDamage))
+ if ( entry->getSource() != nullptr && entry->getSource()->getEntity() != nullptr && entry->getSource()->getEntity()->instanceof(eTYPE_PLAYER) && (bestPlayer == nullptr || entry->getDamage() > bestPlayerDamage))
{
bestPlayerDamage = entry->getDamage();
bestPlayer = dynamic_pointer_cast<Player>(entry->getSource()->getEntity());
}
- if ( entry->getSource() != NULL && entry->getSource()->getEntity() != NULL && entry->getSource()->getEntity()->instanceof(eTYPE_LIVINGENTITY) && (bestMob == NULL || entry->getDamage() > bestMobDamage))
+ if ( entry->getSource() != nullptr && entry->getSource()->getEntity() != nullptr && entry->getSource()->getEntity()->instanceof(eTYPE_LIVINGENTITY) && (bestMob == nullptr || entry->getDamage() > bestMobDamage))
{
bestMobDamage = entry->getDamage();
bestMob = dynamic_pointer_cast<LivingEntity>(entry->getSource()->getEntity());
}
}
- if (bestPlayer != NULL && bestPlayerDamage >= bestMobDamage / 3)
+ if (bestPlayer != nullptr && bestPlayerDamage >= bestMobDamage / 3)
{
return bestPlayer;
}
@@ -165,20 +165,20 @@ shared_ptr<LivingEntity> 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++)
+ for (size_t i = 0; i < entries.size(); i++)
{
CombatEntry *entry = entries.at(i);
- CombatEntry *previous = i > 0 ? entries.at(i - 1) : NULL;
+ CombatEntry *previous = i > 0 ? entries.at(i - 1) : nullptr;
bool isFall = entry->getSource()->equals(DamageSource::fall);
bool isOutOfWorld = entry->getSource()->equals(DamageSource::outOfWorld);
- if ((isFall || isOutOfWorld) && (entry->getFallDistance() > 0) && (result == NULL || entry->getFallDistance() > bestFall))
+ if ((isFall || isOutOfWorld) && (entry->getFallDistance() > 0) && (result == nullptr || entry->getFallDistance() > bestFall))
{
if (i > 0)
{
@@ -191,23 +191,23 @@ CombatEntry *CombatTracker::getMostSignificantFall()
bestFall = entry->getFallDistance();
}
- if (entry->getLocation() != eLocation_GENERIC && (alternative == NULL || entry->getDamage() > altDamage))
+ if (entry->getLocation() != eLocation_GENERIC && (alternative == nullptr || entry->getDamage() > altDamage))
{
alternative = entry;
}
}
- if (bestFall > 5 && result != NULL)
+ if (bestFall > 5 && result != nullptr)
{
return result;
}
- else if (altDamage > 5 && alternative != NULL)
+ else if (altDamage > 5 && alternative != nullptr)
{
return alternative;
}
else
{
- return NULL;
+ return nullptr;
}
}
diff --git a/Minecraft.World/Command.cpp b/Minecraft.World/Command.cpp
index bf546f6e..2ec6853c 100644
--- a/Minecraft.World/Command.cpp
+++ b/Minecraft.World/Command.cpp
@@ -24,7 +24,7 @@ void Command::logAdminAction(shared_ptr<CommandSender> source, ChatPacket::EChat
void Command::logAdminAction(shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const wstring& message, int customData, const wstring& additionalMessage)
{
- if (logger != NULL)
+ if (logger != nullptr)
{
logger->logAdminCommand(source, type, messageType, message, customData, additionalMessage);
}
@@ -39,7 +39,7 @@ shared_ptr<ServerPlayer> Command::getPlayer(PlayerUID playerId)
{
shared_ptr<ServerPlayer> player = MinecraftServer::getInstance()->getPlayers()->getPlayer(playerId);
- if (player == NULL)
+ if (player == nullptr)
{
return nullptr;
}
diff --git a/Minecraft.World/CommandBlock.cpp b/Minecraft.World/CommandBlock.cpp
index e1b6b8dd..c151172e 100644
--- a/Minecraft.World/CommandBlock.cpp
+++ b/Minecraft.World/CommandBlock.cpp
@@ -10,7 +10,7 @@ CommandBlock::CommandBlock(int id) : BaseEntityTile(id, Material::metal, isSolid
shared_ptr<TileEntity> CommandBlock::newTileEntity(Level *level)
{
- return shared_ptr<CommandBlockEntity>( new CommandBlockEntity() );
+ return std::make_shared<CommandBlockEntity>();
}
void CommandBlock::neighborChanged(Level *level, int x, int y, int z, int type)
@@ -38,7 +38,7 @@ void CommandBlock::tick(Level *level, int x, int y, int z, Random *random)
{
shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
- if (tileEntity != NULL && dynamic_pointer_cast<CommandBlockEntity>( tileEntity ) != NULL)
+ if (tileEntity != nullptr && dynamic_pointer_cast<CommandBlockEntity>( tileEntity ) != nullptr)
{
shared_ptr<CommandBlockEntity> commandBlock = dynamic_pointer_cast<CommandBlockEntity>( tileEntity );
commandBlock->setSuccessCount(commandBlock->performCommand(level));
@@ -55,7 +55,7 @@ bool CommandBlock::use(Level *level, int x, int y, int z, shared_ptr<Player> pla
{
shared_ptr<CommandBlockEntity> amce = dynamic_pointer_cast<CommandBlockEntity>( level->getTileEntity(x, y, z) );
- if (amce != NULL)
+ if (amce != nullptr)
{
player->openTextEdit(amce);
}
@@ -72,7 +72,7 @@ int CommandBlock::getAnalogOutputSignal(Level *level, int x, int y, int z, int d
{
shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
- if (tileEntity != NULL && dynamic_pointer_cast<CommandBlockEntity>( tileEntity ) != NULL)
+ if (tileEntity != nullptr && dynamic_pointer_cast<CommandBlockEntity>( tileEntity ) != nullptr)
{
return dynamic_pointer_cast<CommandBlockEntity>( tileEntity )->getSuccessCount();
}
diff --git a/Minecraft.World/CommandBlockEntity.cpp b/Minecraft.World/CommandBlockEntity.cpp
index 1c518f4f..00870ee4 100644
--- a/Minecraft.World/CommandBlockEntity.cpp
+++ b/Minecraft.World/CommandBlockEntity.cpp
@@ -32,7 +32,7 @@ int CommandBlockEntity::performCommand(Level *level)
}
MinecraftServer *instance = MinecraftServer::getInstance();
- if (instance != NULL && instance->isCommandBlockEnabled())
+ if (instance != nullptr && instance->isCommandBlockEnabled())
{
CommandDispatcher *commandDispatcher = instance->getCommandDispatcher();
return commandDispatcher->performCommand(dynamic_pointer_cast<CommandSender>(shared_from_this()), command, byteArray() );
@@ -94,7 +94,7 @@ shared_ptr<Packet> CommandBlockEntity::getUpdatePacket()
{
CompoundTag *tag = new CompoundTag();
save(tag);
- return shared_ptr<TileEntityDataPacket>( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_ADV_COMMAND, tag) );
+ return std::make_shared<TileEntityDataPacket>(x, y, z, TileEntityDataPacket::TYPE_ADV_COMMAND, tag);
}
int CommandBlockEntity::getSuccessCount()
@@ -110,7 +110,7 @@ void CommandBlockEntity::setSuccessCount(int successCount)
// 4J Added
shared_ptr<TileEntity> CommandBlockEntity::clone()
{
- shared_ptr<CommandBlockEntity> result = shared_ptr<CommandBlockEntity>( new CommandBlockEntity() );
+ shared_ptr<CommandBlockEntity> result = std::make_shared<CommandBlockEntity>();
TileEntity::clone(result);
result->successCount = successCount;
diff --git a/Minecraft.World/CommonStats.cpp b/Minecraft.World/CommonStats.cpp
index abef92aa..5ad0e35b 100644
--- a/Minecraft.World/CommonStats.cpp
+++ b/Minecraft.World/CommonStats.cpp
@@ -50,26 +50,26 @@ Stat* CommonStats::get_killsNetherZombiePigman() { return Stats::killsNetherZomb
Stat *CommonStats::get_breedEntity(eINSTANCEOF mobType)
{
if (mobType == eTYPE_COW) return GenericStats::repopulation();
- else return NULL;
+ else return nullptr;
}
Stat *CommonStats::get_tamedEntity(eINSTANCEOF mobType)
{
if (mobType == eTYPE_OCELOT) return GenericStats::lionTamer();
else if (mobType == eTYPE_WOLF) return Stats::befriendsWolf;
- else return NULL;
+ else return nullptr;
}
Stat *CommonStats::get_craftedEntity(eINSTANCEOF mobType)
{
if (mobType == eTYPE_VILLAGERGOLEM) return GenericStats::bodyGuard();
- else return NULL;
+ else return nullptr;
}
Stat *CommonStats::get_shearedEntity(eINSTANCEOF mobType)
{
if (mobType == eTYPE_SHEEP) return GenericStats::haveAShearfulDay();
- else return NULL;
+ else return nullptr;
}
Stat *CommonStats::get_totalBlocksMined() { return Stats::totalBlocksMined; }
@@ -81,7 +81,7 @@ Stat* CommonStats::get_blocksPlaced(int blockId)
#if (defined _EXTENDED_ACHIEVEMENTS) && (!defined _XBOX_ONE)
return Stats::blocksPlaced[blockId];
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -97,7 +97,7 @@ Stat *CommonStats::get_itemsCollected(int itemId, int itemAux)
#endif
if (itemId != Item::emerald_Id) return Stats::itemsCollected[itemId];
- else return NULL;
+ else return nullptr;
}
Stat *CommonStats::get_itemsCrafted(int itemId) { return Stats::itemsCrafted[itemId]; }
@@ -111,7 +111,7 @@ Stat *CommonStats::get_itemsUsed(int itemId)
if (itemId == Item::porkChop_cooked_Id) return Stats::blocksPlaced[itemId];
#endif
- return NULL;
+ return nullptr;
}
Stat *CommonStats::get_itemsBought(int itemId)
@@ -121,7 +121,7 @@ Stat *CommonStats::get_itemsBought(int itemId)
// StatArray for Items Bought.
if (itemId == Item::emerald_Id) return Stats::itemsCollected[itemId];
- else return NULL;
+ else return nullptr;
}
Stat *CommonStats::get_killsEnderdragon() { return Stats::killsEnderdragon; }
@@ -133,7 +133,7 @@ Stat *CommonStats::get_enteredBiome(int biomeId)
#if (defined _EXTENDED_ACHIEVEMENTS) && (!defined _XBOX_ONE)
return Stats::biomesVisisted[biomeId];
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -171,7 +171,7 @@ Stat *CommonStats::get_achievement(eAward achievementId)
#ifndef _XBOX
case eAward_snipeSkeleton: return (Stat *) Achievements::snipeSkeleton;
case eAward_diamonds: return (Stat *) Achievements::diamonds;
- case eAward_portal: return (Stat *) NULL; // TODO
+ case eAward_portal: return (Stat *) nullptr; // TODO
case eAward_ghast: return (Stat *) Achievements::ghast;
case eAward_blazeRod: return (Stat *) Achievements::blazeRod;
case eAward_potion: return (Stat *) Achievements::potion;
@@ -205,7 +205,7 @@ Stat *CommonStats::get_achievement(eAward achievementId)
case eAward_lionTamer: return (Stat *) Achievements::lionTamer;
#endif
- default: return (Stat *) NULL;
+ default: return (Stat *) nullptr;
}
}
@@ -286,7 +286,7 @@ byteArray CommonStats::getParam_noArgs()
byteArray CommonStats::makeParam(int count)
{
- byteArray out( sizeof(int) );
+ byteArray out( static_cast<unsigned int>(sizeof(int)) );
memcpy(out.data,&count,sizeof(int));
return out;
}
diff --git a/Minecraft.World/ComparatorTile.cpp b/Minecraft.World/ComparatorTile.cpp
index f611424d..e7d8f178 100644
--- a/Minecraft.World/ComparatorTile.cpp
+++ b/Minecraft.World/ComparatorTile.cpp
@@ -235,7 +235,7 @@ bool ComparatorTile::triggerEvent(Level *level, int x, int y, int z, int b0, int
{
DiodeTile::triggerEvent(level, x, y, z, b0, b1);
shared_ptr<TileEntity> te = level->getTileEntity(x, y, z);
- if (te != NULL)
+ if (te != nullptr)
{
return te->triggerEvent(b0, b1);
}
@@ -244,7 +244,7 @@ bool ComparatorTile::triggerEvent(Level *level, int x, int y, int z, int b0, int
shared_ptr<TileEntity> ComparatorTile::newTileEntity(Level *level)
{
- return shared_ptr<ComparatorTileEntity>( new ComparatorTileEntity() );
+ return std::make_shared<ComparatorTileEntity>();
}
bool ComparatorTile::TestUse()
diff --git a/Minecraft.World/ComparatorTileEntity.cpp b/Minecraft.World/ComparatorTileEntity.cpp
index 9a58d23c..7cd1f064 100644
--- a/Minecraft.World/ComparatorTileEntity.cpp
+++ b/Minecraft.World/ComparatorTileEntity.cpp
@@ -27,7 +27,7 @@ void ComparatorTileEntity::setOutputSignal(int value)
// 4J Added
shared_ptr<TileEntity> ComparatorTileEntity::clone()
{
- shared_ptr<ComparatorTileEntity> result = shared_ptr<ComparatorTileEntity>( new ComparatorTileEntity() );
+ shared_ptr<ComparatorTileEntity> result = std::make_shared<ComparatorTileEntity>();
TileEntity::clone(result);
result->output = output;
diff --git a/Minecraft.World/CompassItem.cpp b/Minecraft.World/CompassItem.cpp
index 57ad65d0..99d18ed0 100644
--- a/Minecraft.World/CompassItem.cpp
+++ b/Minecraft.World/CompassItem.cpp
@@ -12,7 +12,7 @@ const wstring CompassItem::TEXTURE_PLAYER_ICON[XUSER_MAX_COUNT] = {L"compassP0",
CompassItem::CompassItem(int id) : Item(id)
{
- icons = NULL;
+ icons = nullptr;
}
// 4J Added so that we can override the icon id used to calculate the texture UV's for each player
@@ -22,7 +22,7 @@ Icon *CompassItem::getIcon(int auxValue)
Icon *icon = Item::getIcon(auxValue);
Minecraft *pMinecraft = Minecraft::GetInstance();
- if( pMinecraft->player != NULL && auxValue == 0 )
+ if( pMinecraft->player != nullptr && auxValue == 0 )
{
icon = icons[pMinecraft->player->GetXboxPad()];
}
diff --git a/Minecraft.World/ComplexItemDataPacket.h b/Minecraft.World/ComplexItemDataPacket.h
index 52de8f49..1e41c3e9 100644
--- a/Minecraft.World/ComplexItemDataPacket.h
+++ b/Minecraft.World/ComplexItemDataPacket.h
@@ -20,7 +20,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ComplexItemDataPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ComplexItemDataPacket>(); }
virtual int getId() { return 131; }
};
diff --git a/Minecraft.World/CompoundContainer.cpp b/Minecraft.World/CompoundContainer.cpp
index 39da0e58..50bfcc34 100644
--- a/Minecraft.World/CompoundContainer.cpp
+++ b/Minecraft.World/CompoundContainer.cpp
@@ -6,8 +6,8 @@
CompoundContainer::CompoundContainer(int name, shared_ptr<Container> c1, shared_ptr<Container> c2)
{
this->name = name;
- if (c1 == NULL) c1 = c2;
- if (c2 == NULL) c2 = c1;
+ if (c1 == nullptr) c1 = c2;
+ if (c2 == nullptr) c2 = c1;
this->c1 = c1;
this->c2 = c2;
}
diff --git a/Minecraft.World/CompoundTag.h b/Minecraft.World/CompoundTag.h
index 83a6108f..5eaa2a05 100644
--- a/Minecraft.World/CompoundTag.h
+++ b/Minecraft.World/CompoundTag.h
@@ -123,14 +123,14 @@ public:
void putBoolean(const wstring &name, bool val)
{
- putByte(name, val?(byte)1:0);
+ putByte(name, val?static_cast<byte>(1):0);
}
Tag *get(const wstring &name)
{
auto it = tags.find(name);
if(it != tags.end()) return it->second;
- return NULL;
+ return nullptr;
}
bool contains(const wstring &name)
@@ -141,19 +141,19 @@ public:
byte getByte(const wstring &name)
{
if (tags.find(name) == tags.end()) return (byte)0;
- return ((ByteTag *) tags[name])->data;
+ return static_cast<ByteTag *>(tags[name])->data;
}
short getShort(const wstring &name)
{
if (tags.find(name) == tags.end()) return (short)0;
- return ((ShortTag *) tags[name])->data;
+ return static_cast<ShortTag *>(tags[name])->data;
}
int getInt(const wstring &name)
{
if (tags.find(name) == tags.end()) return (int)0;
- return ((IntTag *) tags[name])->data;
+ return static_cast<IntTag *>(tags[name])->data;
}
int64_t getLong(const wstring &name)
@@ -164,44 +164,44 @@ public:
float getFloat(const wstring &name)
{
- if (tags.find(name) == tags.end()) return (float)0;
- return ((FloatTag *) tags[name])->data;
+ if (tags.find(name) == tags.end()) return static_cast<float>(0);
+ return static_cast<FloatTag *>(tags[name])->data;
}
double getDouble(const wstring &name)
{
if (tags.find(name) == tags.end()) return (double)0;
- return ((DoubleTag *) tags[name])->data;
+ return static_cast<DoubleTag *>(tags[name])->data;
}
wstring getString(const wstring &name)
{
if (tags.find(name) == tags.end()) return wstring( L"" );
- return ((StringTag *) tags[name])->data;
+ return static_cast<StringTag *>(tags[name])->data;
}
byteArray getByteArray(const wstring &name)
{
if (tags.find(name) == tags.end()) return byteArray();
- return ((ByteArrayTag *) tags[name])->data;
+ return static_cast<ByteArrayTag *>(tags[name])->data;
}
intArray getIntArray(const wstring &name)
{
if (tags.find(name) == tags.end()) return intArray();
- return ((IntArrayTag *) tags[name])->data;
+ return static_cast<IntArrayTag *>(tags[name])->data;
}
CompoundTag *getCompound(const wstring &name)
{
if (tags.find(name) == tags.end()) return new CompoundTag(name);
- return (CompoundTag *) tags[name];
+ return static_cast<CompoundTag *>(tags[name]);
}
ListTag<Tag> *getList(const wstring &name)
{
if (tags.find(name) == tags.end()) return new ListTag<Tag>(name);
- return (ListTag<Tag> *) tags[name];
+ return static_cast<ListTag<Tag> *>(tags[name]);
}
bool getBoolean(const wstring &string)
@@ -271,7 +271,7 @@ public:
{
if (Tag::equals(obj))
{
- CompoundTag *o = (CompoundTag *) obj;
+ CompoundTag *o = static_cast<CompoundTag *>(obj);
if(tags.size() == o->tags.size())
{
diff --git a/Minecraft.World/CompressedTileStorage.cpp b/Minecraft.World/CompressedTileStorage.cpp
index 5ba46dee..1c387eeb 100644
--- a/Minecraft.World/CompressedTileStorage.cpp
+++ b/Minecraft.World/CompressedTileStorage.cpp
@@ -23,11 +23,11 @@ CRITICAL_SECTION CompressedTileStorage::cs_write;
#ifdef PSVITA_PRECOMPUTED_TABLE
// AP - this will create a precomputed table to speed up getData
-static int *CompressedTile_StorageIndexTable = NULL;
+static int *CompressedTile_StorageIndexTable = nullptr;
void CompressedTileStorage_InitTable()
{
- if( CompressedTile_StorageIndexTable == NULL )
+ if( CompressedTile_StorageIndexTable == nullptr )
{
CompressedTile_StorageIndexTable = (int*) malloc(sizeof(int) * 64);
for(int j = 0;j < 64;j += 1 )
@@ -41,7 +41,7 @@ void CompressedTileStorage_InitTable()
CompressedTileStorage::CompressedTileStorage()
{
- indicesAndData = NULL;
+ indicesAndData = nullptr;
allocatedSize = 0;
#ifdef PSVITA_PRECOMPUTED_TABLE
@@ -55,12 +55,12 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage *copyFrom)
allocatedSize = copyFrom->allocatedSize;
if(allocatedSize > 0)
{
- indicesAndData = (unsigned char *)XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc(allocatedSize);
+ indicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc(allocatedSize);
XMemCpy(indicesAndData, copyFrom->indicesAndData, allocatedSize);
}
else
{
- indicesAndData = NULL;
+ indicesAndData = nullptr;
}
LeaveCriticalSection(&cs_write);
@@ -71,11 +71,11 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage *copyFrom)
CompressedTileStorage::CompressedTileStorage(byteArray initFrom, unsigned int initOffset)
{
- indicesAndData = NULL;
+ indicesAndData = nullptr;
allocatedSize = 0;
// We need 32768 bytes for a fully uncompressed chunk, plus 1024 for the index. Rounding up to nearest 4096 bytes for allocation
- indicesAndData = (unsigned char *)XPhysicalAlloc(32768+4096, MAXULONG_PTR, 4096, PAGE_READWRITE);
+ indicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(32768 + 4096, MAXULONG_PTR, 4096, PAGE_READWRITE));
unsigned short *indices = (unsigned short *)indicesAndData;
unsigned char *data = indicesAndData + 1024;
@@ -117,7 +117,7 @@ bool CompressedTileStorage::isCompressed()
CompressedTileStorage::CompressedTileStorage(bool isEmpty)
{
- indicesAndData = NULL;
+ indicesAndData = nullptr;
allocatedSize = 0;
// Empty and already compressed, so we only need 1K. Rounding up to nearest 4096 bytes for allocation
@@ -125,7 +125,7 @@ CompressedTileStorage::CompressedTileStorage(bool isEmpty)
// XPhysicalAlloc just maps to malloc on PS3, so allocate the smallest amount
indicesAndData = (unsigned char *)XPhysicalAlloc(1024, MAXULONG_PTR, 4096, PAGE_READWRITE);
#else
- indicesAndData = (unsigned char *)XPhysicalAlloc(4096, MAXULONG_PTR, 4096, PAGE_READWRITE);
+ indicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(4096, MAXULONG_PTR, 4096, PAGE_READWRITE));
#endif //__PS3__
unsigned short *indices = (unsigned short *)indicesAndData;
//unsigned char *data = indicesAndData + 1024;
@@ -388,7 +388,7 @@ void CompressedTileStorage::setData(byteArray dataIn, unsigned int inOffset)
// printf("%d: %d (0) %d (1) %d (2) %d (4) %d (8)\n", chunkTotal, type0 / chunkTotal, type1 / chunkTotal, type2 / chunkTotal, type4 / chunkTotal, type8 / chunkTotal);
memToAlloc += 1024; // For the indices
- unsigned char *newIndicesAndData = (unsigned char *)XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc( memToAlloc );
+ unsigned char *newIndicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc( memToAlloc );
unsigned char *pucData = newIndicesAndData + 1024;
unsigned short usDataOffset = 0;
unsigned short *newIndices = (unsigned short *) newIndicesAndData;
@@ -403,7 +403,7 @@ void CompressedTileStorage::setData(byteArray dataIn, unsigned int inOffset)
{
if( _blockIndices[i] & INDEX_TYPE_0_BIT_FLAG )
{
- newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (((unsigned short)data[getIndex(i,0)]) << INDEX_TILE_SHIFT);
+ newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (static_cast<unsigned short>(data[getIndex(i, 0)]) << INDEX_TILE_SHIFT);
}
else
{
@@ -425,7 +425,7 @@ void CompressedTileStorage::setData(byteArray dataIn, unsigned int inOffset)
ucMappings[j] = 255;
}
- unsigned char *repacked = NULL;
+ unsigned char *repacked = nullptr;
int bitspertile = 1 << indexTypeNew; // will be 1, 2 or 4 (from index values of 0, 1, 2)
int tiletypecount = 1 << bitspertile; // will be 2, 4 or 16 (from index values of 0, 1, 2)
@@ -747,7 +747,7 @@ int CompressedTileStorage::setDataRegion(byteArray dataIn, int x0, int y0, int
}
ptrdiff_t count = pucIn - &dataIn.data[offset];
- return (int)count;
+ return static_cast<int>(count);
}
// Tests whether setting data would actually change anything
@@ -786,7 +786,7 @@ int CompressedTileStorage::getDataRegion(byteArray dataInOut, int x0, int y0, i
}
ptrdiff_t count = pucOut - &dataInOut.data[offset];
- return (int)count;
+ return static_cast<int>(count);
}
void CompressedTileStorage::staticCtor()
@@ -815,7 +815,7 @@ void CompressedTileStorage::tick()
int freeIndex = ( deleteQueueIndex + 1 ) % 3;
// printf("Free queue: %d, %d\n",deleteQueue[freeIndex].GetEntryCount(),deleteQueue[freeIndex].GetAllocated());
- unsigned char *toFree = NULL;
+ unsigned char *toFree = nullptr;
do
{
toFree = deleteQueue[freeIndex].Pop();
@@ -896,7 +896,7 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/)
{
unsigned short indexType = blockIndices[i] & INDEX_TYPE_MASK;
- unsigned char *unpacked_data = NULL;
+ unsigned char *unpacked_data = nullptr;
unsigned char *packed_data;
// First task is to find out what type of storage each block needs. Need to unpack each where required.
@@ -1058,8 +1058,8 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/)
if( needsCompressed )
{
memToAlloc += 1024; // For the indices
- unsigned char *newIndicesAndData = (unsigned char *)XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc( memToAlloc );
- if( newIndicesAndData == NULL )
+ unsigned char *newIndicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc( memToAlloc );
+ if( newIndicesAndData == nullptr )
{
DWORD lastError = GetLastError();
#ifndef _DURANGO
@@ -1120,9 +1120,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 )
@@ -1168,13 +1168,13 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/)
}
#endif
- unsigned char *repacked = NULL;
+ unsigned char *repacked = nullptr;
if( indexTypeNew == INDEX_TYPE_0_OR_8_BIT )
{
if( _blockIndices[i] & INDEX_TYPE_0_BIT_FLAG )
{
- newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (((unsigned short)unpacked_data[0]) << INDEX_TILE_SHIFT);
+ newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (static_cast<unsigned short>(unpacked_data[0]) << INDEX_TILE_SHIFT);
}
else
{
@@ -1360,7 +1360,7 @@ void CompressedTileStorage::read(DataInputStream *dis)
{
XPhysicalFree(indicesAndData);
}
- indicesAndData = (unsigned char *)XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
+ indicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE));
byteArray wrapper(indicesAndData, allocatedSize);
dis->readFully(wrapper);
diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp
index 5058baa7..7f10dc4a 100644
--- a/Minecraft.World/Connection.cpp
+++ b/Minecraft.World/Connection.cpp
@@ -61,17 +61,17 @@ Connection::~Connection()
// These should all have been destroyed in close() but no harm in checking again
delete byteArrayDos;
- byteArrayDos = NULL;
+ byteArrayDos = nullptr;
delete baos;
- baos = NULL;
+ baos = nullptr;
if( bufferedDos )
{
bufferedDos->deleteChildStream();
delete bufferedDos;
- bufferedDos = NULL;
+ bufferedDos = nullptr;
}
delete dis;
- dis = NULL;
+ dis = nullptr;
}
Connection::Connection(Socket *socket, const wstring& id, PacketListener *packetListener) // throws IOException
@@ -111,7 +111,7 @@ Connection::Connection(Socket *socket, const wstring& id, PacketListener *packet
sprintf(readThreadName,"%s read\n",szId);
sprintf(writeThreadName,"%s write\n",szId);
- readThread = new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE);
+ readThread = new C4JThread(runRead, static_cast<void *>(this), readThreadName, READ_STACK_SIZE);
writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE);
readThread->SetProcessor(CPU_CORE_CONNECTIONS);
writeThread->SetProcessor(CPU_CORE_CONNECTIONS );
@@ -185,7 +185,7 @@ bool Connection::writeTick()
bool didSomething = false;
// 4J Stu - If the connection is closed and the output stream has been deleted
- if(bufferedDos==NULL || byteArrayDos==NULL)
+ if(bufferedDos==nullptr || byteArrayDos==nullptr)
return didSomething;
// try {
@@ -326,14 +326,14 @@ bool Connection::readTick()
bool didSomething = false;
// 4J Stu - If the connection has closed and the input stream has been deleted
- if(dis==NULL)
+ if(dis==nullptr)
return didSomething;
//try {
shared_ptr<Packet> packet = Packet::readPacket(dis, packetListener->isServerPacketListener());
- if (packet != NULL)
+ if (packet != nullptr)
{
readSizes[packet->getId()] += packet->getEstimatedSize() + 1;
EnterCriticalSection(&incoming_cs);
@@ -385,8 +385,8 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
disconnectReason = reason;//va_arg( input, const wstring );
vector<void *> objs = vector<void *>();
- void *i = NULL;
- while (i != NULL)
+ void *i = nullptr;
+ while (i != nullptr)
{
i = va_arg( input, void* );
objs.push_back(i);
@@ -398,7 +398,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
}
else
{
- disconnectReasonObjects = NULL;
+ disconnectReasonObjects = nullptr;
}
// int count = 0, sum = 0, i = first;
@@ -415,7 +415,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
// return( sum ? (sum / count) : 0 );
-// CreateThread(NULL, 0, runClose, this, 0, &closeThreadID);
+// CreateThread(nullptr, 0, runClose, this, 0, &closeThreadID);
running = false;
@@ -427,24 +427,24 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
writeThread->WaitForCompletion(INFINITE);
delete dis;
- dis = NULL;
+ dis = nullptr;
if( bufferedDos )
{
bufferedDos->close();
bufferedDos->deleteChildStream();
delete bufferedDos;
- bufferedDos = NULL;
+ bufferedDos = nullptr;
}
if( byteArrayDos )
{
byteArrayDos->close();
delete byteArrayDos;
- byteArrayDos = NULL;
+ byteArrayDos = nullptr;
}
if( socket )
{
socket->close(packetListener->isServerPacketListener());
- socket = NULL;
+ socket = nullptr;
}
}
@@ -481,7 +481,7 @@ void Connection::tick()
tickCount++;
if (tickCount % 20 == 0)
{
- send( shared_ptr<KeepAlivePacket>( new KeepAlivePacket() ) );
+ send(std::make_shared<KeepAlivePacket>());
}
// 4J Stu - 1.8.2 changed from 100 to 1000
@@ -506,7 +506,7 @@ void Connection::tick()
LeaveCriticalSection(&incoming_cs);
// MGH - moved the packet handling outside of the incoming_cs block, as it was locking up sometimes when disconnecting
- for(int i=0; i<packetsToHandle.size();i++)
+ for(size_t i = 0; i < packetsToHandle.size(); i++)
{
PIXBeginNamedEvent(0,"Handling packet %d\n",packetsToHandle[i]->getId());
packetsToHandle[i]->handle(packetListener);
@@ -560,22 +560,22 @@ void Connection::sendAndQuit()
close(DisconnectPacket::eDisconnect_Closed);
}
#else
- CreateThread(NULL, 0, runSendAndQuit, this, 0, &saqThreadID);
+ CreateThread(nullptr, 0, runSendAndQuit, this, 0, &saqThreadID);
#endif
}
int Connection::countDelayedPackets()
{
- return (int)outgoing_slow.size();
+ return static_cast<int>(outgoing_slow.size());
}
int Connection::runRead(void* lpParam)
{
ShutdownManager::HasStarted(ShutdownManager::eConnectionReadThreads);
- Connection *con = (Connection *)lpParam;
+ Connection *con = static_cast<Connection *>(lpParam);
- if (con == NULL)
+ if (con == nullptr)
{
#ifdef __PS3__
ShutdownManager::HasFinished(ShutdownManager::eConnectionReadThreads);
@@ -623,9 +623,9 @@ int Connection::runRead(void* lpParam)
int Connection::runWrite(void* lpParam)
{
ShutdownManager::HasStarted(ShutdownManager::eConnectionWriteThreads);
- Connection *con = dynamic_cast<Connection *>((Connection *) lpParam);
+ Connection *con = dynamic_cast<Connection *>(static_cast<Connection *>(lpParam));
- if (con == NULL)
+ if (con == nullptr)
{
ShutdownManager::HasFinished(ShutdownManager::eConnectionWriteThreads);
return 0;
@@ -652,8 +652,8 @@ int Connection::runWrite(void* lpParam)
// TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well
waitResult = con->m_hWakeWriteThread->WaitForSignal(100L);
- if (con->bufferedDos != NULL) con->bufferedDos->flush();
- //if (con->byteArrayDos != NULL) con->byteArrayDos->flush();
+ if (con->bufferedDos != nullptr) con->bufferedDos->flush();
+ //if (con->byteArrayDos != nullptr) con->byteArrayDos->flush();
}
@@ -668,9 +668,9 @@ int Connection::runWrite(void* lpParam)
int Connection::runClose(void* lpParam)
{
- Connection *con = dynamic_cast<Connection *>((Connection *) lpParam);
+ Connection *con = dynamic_cast<Connection *>(static_cast<Connection *>(lpParam));
- if (con == NULL) return 0;
+ if (con == nullptr) return 0;
//try {
@@ -691,10 +691,10 @@ int Connection::runClose(void* lpParam)
int Connection::runSendAndQuit(void* lpParam)
{
- Connection *con = dynamic_cast<Connection *>((Connection *) lpParam);
+ Connection *con = dynamic_cast<Connection *>(static_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/ConsoleSaveFile.h b/Minecraft.World/ConsoleSaveFile.h
index 39c1ec89..0f7c451e 100644
--- a/Minecraft.World/ConsoleSaveFile.h
+++ b/Minecraft.World/ConsoleSaveFile.h
@@ -23,7 +23,7 @@ public:
virtual void Flush(bool autosave, bool updateThumbnail = true) = 0;
#ifndef _CONTENT_PACKAGE
- virtual void DebugFlushToFile(void *compressedData = NULL, unsigned int compressedDataSize = 0) = 0;
+ virtual void DebugFlushToFile(void *compressedData = nullptr, unsigned int compressedDataSize = 0) = 0;
#endif
virtual unsigned int getSizeOnDisk() = 0;
virtual wstring getFilename() = 0;
@@ -53,5 +53,5 @@ 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/ConsoleSaveFileConverter.cpp b/Minecraft.World/ConsoleSaveFileConverter.cpp
index 21de3cbe..f7d8d0ee 100644
--- a/Minecraft.World/ConsoleSaveFileConverter.cpp
+++ b/Minecraft.World/ConsoleSaveFileConverter.cpp
@@ -84,7 +84,7 @@ void ConsoleSaveFileConverter::ConvertSave(ConsoleSaveFile *sourceSave, ConsoleS
vector<FileEntry *> *playerFiles = sourceSave->getFilesWithPrefix( DirectoryLevelStorage::getPlayerDir() );
#endif
- if(playerFiles != NULL)
+ if(playerFiles != nullptr)
{
for(int fileIdx = 0; fileIdx < playerFiles->size();fileIdx++)
{
diff --git a/Minecraft.World/ConsoleSaveFileInputStream.cpp b/Minecraft.World/ConsoleSaveFileInputStream.cpp
index 93d49956..db997918 100644
--- a/Minecraft.World/ConsoleSaveFileInputStream.cpp
+++ b/Minecraft.World/ConsoleSaveFileInputStream.cpp
@@ -9,7 +9,7 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile
m_saveFile = saveFile;
m_file = m_saveFile->createFile( file );
- m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( m_file, 0, nullptr, FILE_BEGIN );
}
ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile, FileEntry *file)
@@ -17,7 +17,7 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile
m_saveFile = saveFile;
m_file = file;
- m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( m_file, 0, nullptr, FILE_BEGIN );
}
//Reads a byte of data from this input stream. This method blocks if no input is yet available.
@@ -119,7 +119,7 @@ int ConsoleSaveFileInputStream::read(byteArray b, unsigned int offset, unsigned
//If this stream has an associated channel then the channel is closed as well.
void ConsoleSaveFileInputStream::close()
{
- if( m_saveFile != NULL )
+ if( m_saveFile != nullptr )
{
BOOL result = m_saveFile->closeHandle( m_file );
@@ -129,6 +129,6 @@ void ConsoleSaveFileInputStream::close()
}
// Stop the dtor from trying to close it again
- m_saveFile = NULL;
+ m_saveFile = nullptr;
}
}
diff --git a/Minecraft.World/ConsoleSaveFileOriginal.cpp b/Minecraft.World/ConsoleSaveFileOriginal.cpp
index 0b7c8d66..8a7d1f9e 100644
--- a/Minecraft.World/ConsoleSaveFileOriginal.cpp
+++ b/Minecraft.World/ConsoleSaveFileOriginal.cpp
@@ -22,14 +22,14 @@
#endif
unsigned int ConsoleSaveFileOriginal::pagesCommitted = 0;
-void *ConsoleSaveFileOriginal::pvHeap = NULL;
+void *ConsoleSaveFileOriginal::pvHeap = nullptr;
-ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID pvSaveData /*= NULL*/, DWORD dFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/)
+ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID pvSaveData /*= nullptr*/, DWORD dFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/)
{
InitializeCriticalSectionAndSpinCount(&m_lock,5120);
// One time initialise of static stuff required for our storage
- if( pvHeap == NULL )
+ if( pvHeap == nullptr )
{
// Reserve a chunk of 64MB of virtual address space for our saves, using 64KB pages.
// We'll only be committing these as required to grow the storage we need, which will
@@ -38,7 +38,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
// AP - The Vita doesn't have virtual memory so a pretend system has been implemented in PSVitaStubs.cpp.
// All access to the memory must be done via the access function as the pointer returned from VirtualAlloc
// can't be used directly.
- pvHeap = VirtualAlloc(NULL, MAX_PAGE_COUNT * CSF_PAGE_SIZE, RESERVE_ALLOCATION, PAGE_READWRITE );
+ pvHeap = VirtualAlloc(nullptr, MAX_PAGE_COUNT * CSF_PAGE_SIZE, RESERVE_ALLOCATION, PAGE_READWRITE );
}
pvSaveMem = pvHeap;
@@ -49,13 +49,13 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
// Load a save from the game rules
bool bLevelGenBaseSave = false;
LevelGenerationOptions *levelGen = app.getLevelGenerationOptions();
- if( pvSaveData == NULL && levelGen != NULL && levelGen->requiresBaseSave())
+ if( pvSaveData == nullptr && levelGen != nullptr && levelGen->requiresBaseSave())
{
pvSaveData = levelGen->getBaseSaveData(fileSize);
if(pvSaveData && fileSize != 0) bLevelGenBaseSave = true;
}
- if( pvSaveData == NULL || fileSize == 0)
+ if( pvSaveData == nullptr || fileSize == 0)
fileSize = StorageManager.GetSaveSize();
if( forceCleanSave )
@@ -75,7 +75,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
unsigned int pagesRequired = ( heapSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE;
void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE);
- if( pvRet == NULL )
+ if( pvRet == nullptr )
{
#ifndef _CONTENT_PACKAGE
// Out of physical memory
@@ -87,7 +87,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
if( fileSize > 0)
{
bool AllocData = false;
- if(pvSaveData != NULL)
+ if(pvSaveData != nullptr)
{
#ifdef __PSVITA__
// AP - use this to access the virtual memory
@@ -141,10 +141,10 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
#else
void* pvSourceData = pvSaveMem;
#endif
- int compressed = *(int*)pvSourceData;
+ int compressed = *static_cast<int *>(pvSourceData);
if( compressed == 0 )
{
- unsigned int decompSize = *( (int*)pvSourceData+1 );
+ unsigned int decompSize = *( static_cast<int *>(pvSourceData)+1 );
if(isLocalEndianDifferent(plat)) System::ReverseULONG(&decompSize);
// An invalid save, so clear the memory and start from scratch
@@ -162,13 +162,13 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
#ifndef _XBOX
if(plat == SAVE_FILE_PLATFORM_PSVITA)
{
- Compression::VitaVirtualDecompress(buf, &decompSize, (unsigned char *)pvSourceData+8, fileSize-8 );
+ Compression::VitaVirtualDecompress(buf, &decompSize, static_cast<unsigned char *>(pvSourceData)+8, fileSize-8 );
}
else
#endif
{
Compression::getCompression()->SetDecompressionType(plat); // if this save is from another platform, set the correct decompression type
- Compression::getCompression()->Decompress(buf, &decompSize, (unsigned char *)pvSourceData+8, fileSize-8 );
+ Compression::getCompression()->Decompress(buf, &decompSize, static_cast<unsigned char *>(pvSourceData)+8, fileSize-8 );
Compression::getCompression()->SetDecompressionType(SAVE_FILE_PLATFORM_LOCAL); // and then set the decompression back to the local machine's standard type
}
@@ -181,7 +181,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
{
unsigned int pagesRequired = ( desiredSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE;
void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE);
- if( pvRet == NULL )
+ if( pvRet == nullptr )
{
// Out of physical memory
__debugbreak();
@@ -216,7 +216,7 @@ ConsoleSaveFileOriginal::~ConsoleSaveFileOriginal()
#if defined _XBOX
app.GetSaveThumbnail(NULL,NULL);
#elif defined __PS3__
- app.GetSaveThumbnail(NULL,NULL, NULL,NULL);
+ app.GetSaveThumbnail(nullptr,nullptr, nullptr,nullptr);
#endif
DeleteCriticalSection(&m_lock);
@@ -235,7 +235,7 @@ FileEntry *ConsoleSaveFileOriginal::createFile( const ConsoleSavePath &fileName
void ConsoleSaveFileOriginal::deleteFile( FileEntry *file )
{
- if( file == NULL ) return;
+ if( file == nullptr ) return;
LockSaveAccess();
@@ -248,18 +248,18 @@ void ConsoleSaveFileOriginal::deleteFile( FileEntry *file )
DWORD bufferDataSize = 0;
- char *readStartOffset = (char *)pvSaveMem + file->data.startOffset + file->getFileSize();
+ char *readStartOffset = static_cast<char *>(pvSaveMem) + file->data.startOffset + file->getFileSize();
- char *writeStartOffset = (char *)pvSaveMem + file->data.startOffset;
+ char *writeStartOffset = static_cast<char *>(pvSaveMem) + file->data.startOffset;
- char *endOfDataOffset = (char *)pvSaveMem + header.GetStartOfNextData();
+ char *endOfDataOffset = static_cast<char *>(pvSaveMem) + header.GetStartOfNextData();
while(true)
{
// Fill buffer from file
if( readStartOffset + bufferSize > endOfDataOffset )
{
- amountToRead = (int)(endOfDataOffset - readStartOffset);
+ amountToRead = static_cast<int>(endOfDataOffset - readStartOffset);
}
else
{
@@ -339,8 +339,8 @@ void ConsoleSaveFileOriginal::PrepareForWrite( FileEntry *file, DWORD nNumberOfB
BOOL ConsoleSaveFileOriginal::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten)
{
- assert( pvSaveMem != NULL );
- if( pvSaveMem == NULL )
+ assert( pvSaveMem != nullptr );
+ if( pvSaveMem == nullptr )
{
return 0;
}
@@ -349,7 +349,7 @@ BOOL ConsoleSaveFileOriginal::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD
PrepareForWrite( file, nNumberOfBytesToWrite );
- char *writeStartOffset = (char *)pvSaveMem + file->currentFilePointer;
+ char *writeStartOffset = static_cast<char *>(pvSaveMem) + file->currentFilePointer;
//printf("Write: pvSaveMem = %0xd, currentFilePointer = %d, writeStartOffset = %0xd\n", pvSaveMem, file->currentFilePointer, writeStartOffset);
#ifdef __PSVITA__
@@ -376,8 +376,8 @@ BOOL ConsoleSaveFileOriginal::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD
BOOL ConsoleSaveFileOriginal::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten)
{
- assert( pvSaveMem != NULL );
- if( pvSaveMem == NULL )
+ assert( pvSaveMem != nullptr );
+ if( pvSaveMem == nullptr )
{
return 0;
}
@@ -386,7 +386,7 @@ BOOL ConsoleSaveFileOriginal::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWr
PrepareForWrite( file, nNumberOfBytesToWrite );
- char *writeStartOffset = (char *)pvSaveMem + file->currentFilePointer;
+ char *writeStartOffset = static_cast<char *>(pvSaveMem) + file->currentFilePointer;
//printf("Write: pvSaveMem = %0xd, currentFilePointer = %d, writeStartOffset = %0xd\n", pvSaveMem, file->currentFilePointer, writeStartOffset);
#ifdef __PSVITA__
@@ -414,15 +414,15 @@ BOOL ConsoleSaveFileOriginal::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWr
BOOL ConsoleSaveFileOriginal::readFile( FileEntry *file, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead)
{
DWORD actualBytesToRead;
- assert( pvSaveMem != NULL );
- if( pvSaveMem == NULL )
+ assert( pvSaveMem != nullptr );
+ if( pvSaveMem == nullptr )
{
return 0;
}
LockSaveAccess();
- char *readStartOffset = (char *)pvSaveMem + file->currentFilePointer;
+ char *readStartOffset = static_cast<char *>(pvSaveMem) + file->currentFilePointer;
//printf("Read: pvSaveMem = %0xd, currentFilePointer = %d, readStartOffset = %0xd\n", pvSaveMem, file->currentFilePointer, readStartOffset);
assert( nNumberOfBytesToRead <= file->getFileSize() );
@@ -506,7 +506,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt
{
unsigned int pagesRequired = ( desiredSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE;
void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE);
- if( pvRet == NULL )
+ if( pvRet == nullptr )
{
// Out of physical memory
__debugbreak();
@@ -515,13 +515,13 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt
}
// This is the start of where we want the space to be, and the start of the data that we need to move
- char *spaceStartOffset = (char *)pvSaveMem + file->data.startOffset + file->getFileSize();
+ char *spaceStartOffset = static_cast<char *>(pvSaveMem) + file->data.startOffset + file->getFileSize();
// This is the end of where we want the space to be
char *spaceEndOffset = spaceStartOffset + nNumberOfBytesToWrite;
// This is the current end of the data that we want to move
- char *beginEndOfDataOffset = (char *)pvSaveMem + header.GetStartOfNextData();
+ char *beginEndOfDataOffset = static_cast<char *>(pvSaveMem) + header.GetStartOfNextData();
// This is where the end of the data is going to be
char *finishEndOfDataOffset = beginEndOfDataOffset + nNumberOfBytesToWrite;
@@ -547,8 +547,8 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt
uintptr_t uiFromEnd = (uintptr_t)beginEndOfDataOffset;
// Round both of these values to get 4096 byte chunks that we will need to at least partially move
- uintptr_t uiFromStartChunk = uiFromStart & ~((uintptr_t)4095);
- uintptr_t uiFromEndChunk = (uiFromEnd - 1 ) & ~((uintptr_t)4095);
+ uintptr_t uiFromStartChunk = uiFromStart & ~static_cast<uintptr_t>(4095);
+ uintptr_t uiFromEndChunk = (uiFromEnd - 1 ) & ~static_cast<uintptr_t>(4095);
// Loop through all the affected source 4096 chunks, going backwards so we don't overwrite anything we'll need in the future
for( uintptr_t uiCurrentChunk = uiFromEndChunk; uiCurrentChunk >= uiFromStartChunk; uiCurrentChunk -= 4096 )
@@ -587,7 +587,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt
// Fill buffer 1 from file
if( (readStartOffset - bufferSize) < spaceStartOffset )
{
- amountToRead = (DWORD)(readStartOffset - spaceStartOffset);
+ amountToRead = static_cast<DWORD>(readStartOffset - spaceStartOffset);
}
else
{
@@ -669,7 +669,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
LARGE_INTEGER qwTicksPerSec, qwTime, qwNewTime, qwDeltaTime;
float fElapsedTime = 0.0f;
QueryPerformanceFrequency( &qwTicksPerSec );
- float fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart;
+ float fSecsPerTick = 1.0f / static_cast<float>(qwTicksPerSec.QuadPart);
unsigned int fileSize = header.GetFileSize();
@@ -688,17 +688,17 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
#else
// Attempt to allocate the required memory
// We do not own this, it belongs to the StorageManager
- byte *compData = (byte *)StorageManager.AllocateSaveData( compLength );
+ byte *compData = static_cast<byte *>(StorageManager.AllocateSaveData(compLength));
#ifdef __PSVITA__
// AP - make sure we always allocate just what is needed so it will only SAVE what is needed.
// If we don't do this the StorageManager will save a file of uncompressed size unnecessarily.
- compData = NULL;
+ compData = nullptr;
#endif
- // If we failed to allocate then compData will be NULL
+ // If we failed to allocate then compData will be nullptr
// Pre-calculate the compressed data size so that we can attempt to allocate a smaller buffer
- if(compData == NULL)
+ if(compData == nullptr)
{
// Length should be 0 here so that the compression call knows that we want to know the length back
compLength = 0;
@@ -709,14 +709,14 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
QueryPerformanceCounter( &qwTime );
#ifdef __PSVITA__
// AP - get the compressed size via the access function. This uses a special RLE format
- VirtualCompress(NULL,&compLength,pvSaveMem,fileSize);
+ VirtualCompress(nullptr,&compLength,pvSaveMem,fileSize);
#else
- Compression::getCompression()->Compress(NULL,&compLength,pvSaveMem,fileSize);
+ Compression::getCompression()->Compress(nullptr,&compLength,pvSaveMem,fileSize);
#endif
QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
- fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart));
+ fElapsedTime = fSecsPerTick * static_cast<FLOAT>(qwDeltaTime.QuadPart);
app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime);
PIXEndNamedEvent();
@@ -726,11 +726,11 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
compLength = compLength+8;
// Attempt to allocate the required memory
- compData = (byte *)StorageManager.AllocateSaveData( compLength );
+ compData = static_cast<byte *>(StorageManager.AllocateSaveData(compLength));
}
#endif
- if(compData != NULL)
+ if(compData != nullptr)
{
// No compression on PS3 - see comment above
#ifndef __PS3__
@@ -747,7 +747,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
- fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart));
+ fElapsedTime = fSecsPerTick * static_cast<FLOAT>(qwDeltaTime.QuadPart);
app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime);
PIXEndNamedEvent();
@@ -760,10 +760,10 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
app.DebugPrintf("Save data compressed from %d to %d\n", fileSize, compLength);
#endif
- PBYTE pbThumbnailData=NULL;
+ PBYTE pbThumbnailData=nullptr;
DWORD dwThumbnailDataSize=0;
- PBYTE pbDataSaveImage=NULL;
+ PBYTE pbDataSaveImage=nullptr;
DWORD dwDataSizeSaveImage=0;
#if ( defined _XBOX || defined _DURANGO || defined _WINDOWS64 )
@@ -777,7 +777,7 @@ void ConsoleSaveFileOriginal::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()->getSeed();
hasSeed = true;
@@ -836,7 +836,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes)
{
- ConsoleSaveFile *pClass=(ConsoleSaveFile *)lpParam;
+ ConsoleSaveFile *pClass=static_cast<ConsoleSaveFile *>(lpParam);
return 0;
}
@@ -844,7 +844,7 @@ int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes)
#endif
#ifndef _CONTENT_PACKAGE
-void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, unsigned int compressedDataSize /*= 0*/)
+void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= nullptr*/, unsigned int compressedDataSize /*= 0*/)
{
LockSaveAccess();
@@ -884,16 +884,16 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/,
LPCSTR lpFileName = wstringtofilename( targetFileDir.getPath() + wstring(fileName) );
#endif
#ifndef __PSVITA__
- HANDLE hSaveFile = CreateFile( lpFileName, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL);
+ HANDLE hSaveFile = CreateFile( lpFileName, GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, nullptr);
#endif
- if(compressedData != NULL && compressedDataSize > 0)
+ if(compressedData != nullptr && compressedDataSize > 0)
{
#ifdef __PSVITA__
// AP - Use the access function to save
- VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL);
+ VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, nullptr);
#else
- WriteFile( hSaveFile,compressedData,compressedDataSize,&numberOfBytesWritten,NULL);
+ WriteFile( hSaveFile,compressedData,compressedDataSize,&numberOfBytesWritten,nullptr);
#endif
assert(numberOfBytesWritten == compressedDataSize);
}
@@ -901,9 +901,9 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/,
{
#ifdef __PSVITA__
// AP - Use the access function to save
- VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL);
+ VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, nullptr);
#else
- WriteFile(hSaveFile,pvSaveMem,fileSize,&numberOfBytesWritten,NULL);
+ WriteFile(hSaveFile,pvSaveMem,fileSize,&numberOfBytesWritten,nullptr);
#endif
assert(numberOfBytesWritten == fileSize);
}
@@ -934,7 +934,7 @@ vector<FileEntry *> *ConsoleSaveFileOriginal::getFilesWithPrefix(const wstring &
vector<FileEntry *> *ConsoleSaveFileOriginal::getRegionFilesByDimension(unsigned int dimensionIndex)
{
- return NULL;
+ return nullptr;
}
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
@@ -1083,5 +1083,5 @@ void ConsoleSaveFileOriginal::ConvertToLocalPlatform()
void *ConsoleSaveFileOriginal::getWritePointer(FileEntry *file)
{
- return (char *)pvSaveMem + file->currentFilePointer;;
+ return static_cast<char *>(pvSaveMem) + file->currentFilePointer;;
}
diff --git a/Minecraft.World/ConsoleSaveFileOriginal.h b/Minecraft.World/ConsoleSaveFileOriginal.h
index fd35aa1d..9c91fafc 100644
--- a/Minecraft.World/ConsoleSaveFileOriginal.h
+++ b/Minecraft.World/ConsoleSaveFileOriginal.h
@@ -35,7 +35,7 @@ public:
#if (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WINDOWS64)
static int SaveSaveDataCallback(LPVOID lpParam,bool bRes);
#endif
- ConsoleSaveFileOriginal(const wstring &fileName, LPVOID pvSaveData = NULL, DWORD fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL);
+ ConsoleSaveFileOriginal(const wstring &fileName, LPVOID pvSaveData = nullptr, DWORD fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL);
virtual ~ConsoleSaveFileOriginal();
// 4J Stu - Initial implementation is intended to have a similar interface to the standard Xbox file access functions
@@ -56,7 +56,7 @@ public:
virtual void Flush(bool autosave, bool updateThumbnail = true);
#ifndef _CONTENT_PACKAGE
- virtual void DebugFlushToFile(void *compressedData = NULL, unsigned int compressedDataSize = 0);
+ virtual void DebugFlushToFile(void *compressedData = nullptr, unsigned int compressedDataSize = 0);
#endif
virtual unsigned int getSizeOnDisk();
diff --git a/Minecraft.World/ConsoleSaveFileOutputStream.cpp b/Minecraft.World/ConsoleSaveFileOutputStream.cpp
index 3d8bb3f7..c4812a73 100644
--- a/Minecraft.World/ConsoleSaveFileOutputStream.cpp
+++ b/Minecraft.World/ConsoleSaveFileOutputStream.cpp
@@ -19,7 +19,7 @@ ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFi
m_file = m_saveFile->createFile(file);
- m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( m_file, 0, nullptr, FILE_BEGIN );
}
ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFile, FileEntry *file)
@@ -28,7 +28,7 @@ ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFi
m_file = file;
- m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( m_file, 0, nullptr, FILE_BEGIN );
}
//Writes the specified byte to this file output stream. Implements the write method of OutputStream.
@@ -38,7 +38,7 @@ void ConsoleSaveFileOutputStream::write(unsigned int b)
{
DWORD numberOfBytesWritten;
- byte value = (byte) b;
+ byte value = static_cast<byte>(b);
BOOL result = m_saveFile->writeFile(
m_file,
@@ -115,7 +115,7 @@ void ConsoleSaveFileOutputStream::write(byteArray b, unsigned int offset, unsign
//If this stream has an associated channel then the channel is closed as well.
void ConsoleSaveFileOutputStream::close()
{
- if( m_saveFile != NULL )
+ if( m_saveFile != nullptr )
{
BOOL result = m_saveFile->closeHandle( m_file );
@@ -125,6 +125,6 @@ void ConsoleSaveFileOutputStream::close()
}
// Stop the dtor from trying to close it again
- m_saveFile = NULL;
+ m_saveFile = nullptr;
}
}
diff --git a/Minecraft.World/ContainerAckPacket.h b/Minecraft.World/ContainerAckPacket.h
index 00f3592e..be028774 100644
--- a/Minecraft.World/ContainerAckPacket.h
+++ b/Minecraft.World/ContainerAckPacket.h
@@ -23,7 +23,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ContainerAckPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ContainerAckPacket>(); }
virtual int getId() { return 106; }
};
diff --git a/Minecraft.World/ContainerButtonClickPacket.h b/Minecraft.World/ContainerButtonClickPacket.h
index 522c5f86..01e8deb8 100644
--- a/Minecraft.World/ContainerButtonClickPacket.h
+++ b/Minecraft.World/ContainerButtonClickPacket.h
@@ -17,6 +17,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ContainerButtonClickPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ContainerButtonClickPacket>(); }
virtual int getId() { return 108; }
}; \ No newline at end of file
diff --git a/Minecraft.World/ContainerClickPacket.h b/Minecraft.World/ContainerClickPacket.h
index 51686166..dee255b4 100644
--- a/Minecraft.World/ContainerClickPacket.h
+++ b/Minecraft.World/ContainerClickPacket.h
@@ -23,7 +23,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ContainerClickPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ContainerClickPacket>(); }
virtual int getId() { return 102; }
};
diff --git a/Minecraft.World/ContainerClosePacket.h b/Minecraft.World/ContainerClosePacket.h
index bf032a97..c4b78570 100644
--- a/Minecraft.World/ContainerClosePacket.h
+++ b/Minecraft.World/ContainerClosePacket.h
@@ -17,7 +17,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ContainerClosePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ContainerClosePacket>(); }
virtual int getId() { return 101; }
};
diff --git a/Minecraft.World/ContainerMenu.cpp b/Minecraft.World/ContainerMenu.cpp
index b1fd4d6b..3dcae136 100644
--- a/Minecraft.World/ContainerMenu.cpp
+++ b/Minecraft.World/ContainerMenu.cpp
@@ -46,14 +46,14 @@ shared_ptr<ItemInstance> ContainerMenu::quickMoveStack(shared_ptr<Player> player
{
shared_ptr<ItemInstance> clicked = nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
if (slotIndex < containerRows * 9)
{
- if(!moveItemStackTo(stack, containerRows * 9, (int)slots.size(), true))
+ if(!moveItemStackTo(stack, containerRows * 9, static_cast<int>(slots.size()), true))
{
// 4J Stu - Brought forward from 1.2
return nullptr;
@@ -97,7 +97,7 @@ shared_ptr<ItemInstance> ContainerMenu::clicked(int slotIndex, int buttonNum, in
#ifdef _EXTENDED_ACHIEVEMENTS
shared_ptr<LocalPlayer> localPlayer = dynamic_pointer_cast<LocalPlayer>(player);
- if (localPlayer != NULL) // 4J-JEV: For "Chestful o'Cobblestone" achievement.
+ if (localPlayer != nullptr) // 4J-JEV: For "Chestful o'Cobblestone" achievement.
{
int cobblecount = 0;
for (int i = 0; i < container->getContainerSize(); i++)
diff --git a/Minecraft.World/ContainerOpenPacket.h b/Minecraft.World/ContainerOpenPacket.h
index 896b7dd9..fac0e981 100644
--- a/Minecraft.World/ContainerOpenPacket.h
+++ b/Minecraft.World/ContainerOpenPacket.h
@@ -46,7 +46,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ContainerOpenPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ContainerOpenPacket>(); }
virtual int getId() { return 100; }
};
diff --git a/Minecraft.World/ContainerSetContentPacket.cpp b/Minecraft.World/ContainerSetContentPacket.cpp
index 13cfebd7..ae76e0f0 100644
--- a/Minecraft.World/ContainerSetContentPacket.cpp
+++ b/Minecraft.World/ContainerSetContentPacket.cpp
@@ -20,11 +20,11 @@ ContainerSetContentPacket::ContainerSetContentPacket()
ContainerSetContentPacket::ContainerSetContentPacket(int containerId, vector<shared_ptr<ItemInstance> > *newItems)
{
this->containerId = containerId;
- items = ItemInstanceArray((int)newItems->size());
+ items = ItemInstanceArray(static_cast<int>(newItems->size()));
for (unsigned int i = 0; i < items.length; i++)
{
shared_ptr<ItemInstance> item = newItems->at(i);
- items[i] = item == NULL ? nullptr : item->copy();
+ items[i] = item == nullptr ? nullptr : item->copy();
}
}
diff --git a/Minecraft.World/ContainerSetContentPacket.h b/Minecraft.World/ContainerSetContentPacket.h
index 10315f58..3159085b 100644
--- a/Minecraft.World/ContainerSetContentPacket.h
+++ b/Minecraft.World/ContainerSetContentPacket.h
@@ -19,7 +19,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ContainerSetContentPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ContainerSetContentPacket>(); }
virtual int getId() { return 104; }
};
diff --git a/Minecraft.World/ContainerSetDataPacket.h b/Minecraft.World/ContainerSetDataPacket.h
index ce075e00..c5d52a97 100644
--- a/Minecraft.World/ContainerSetDataPacket.h
+++ b/Minecraft.World/ContainerSetDataPacket.h
@@ -19,6 +19,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ContainerSetDataPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ContainerSetDataPacket>(); }
virtual int getId() { return 105; }
}; \ No newline at end of file
diff --git a/Minecraft.World/ContainerSetSlotPacket.cpp b/Minecraft.World/ContainerSetSlotPacket.cpp
index 42892f3c..6a038244 100644
--- a/Minecraft.World/ContainerSetSlotPacket.cpp
+++ b/Minecraft.World/ContainerSetSlotPacket.cpp
@@ -22,7 +22,7 @@ ContainerSetSlotPacket::ContainerSetSlotPacket(int containerId, int slot, shared
{
this->containerId = containerId;
this->slot = slot;
- this->item = item == NULL ? item : item->copy();
+ this->item = item == nullptr ? item : item->copy();
}
void ContainerSetSlotPacket::handle(PacketListener *listener)
diff --git a/Minecraft.World/ContainerSetSlotPacket.h b/Minecraft.World/ContainerSetSlotPacket.h
index 61269df0..86bca334 100644
--- a/Minecraft.World/ContainerSetSlotPacket.h
+++ b/Minecraft.World/ContainerSetSlotPacket.h
@@ -23,7 +23,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ContainerSetSlotPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ContainerSetSlotPacket>(); }
virtual int getId() { return 103; }
};
diff --git a/Minecraft.World/ControlledByPlayerGoal.cpp b/Minecraft.World/ControlledByPlayerGoal.cpp
index cea227cd..c5203e6e 100644
--- a/Minecraft.World/ControlledByPlayerGoal.cpp
+++ b/Minecraft.World/ControlledByPlayerGoal.cpp
@@ -36,13 +36,13 @@ void ControlledByPlayerGoal::stop()
bool ControlledByPlayerGoal::canUse()
{
- return mob->isAlive() && mob->rider.lock() != NULL && mob->rider.lock()->instanceof(eTYPE_PLAYER) && (boosting || mob->canBeControlledByRider());
+ return mob->isAlive() && mob->rider.lock() != nullptr && mob->rider.lock()->instanceof(eTYPE_PLAYER) && (boosting || mob->canBeControlledByRider());
}
void ControlledByPlayerGoal::tick()
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(mob->rider.lock());
- PathfinderMob *pig = (PathfinderMob *)mob;
+ PathfinderMob *pig = static_cast<PathfinderMob *>(mob);
float yrd = Mth::wrapDegrees(player->yRot - mob->yRot) * 0.5f;
if (yrd > 5) yrd = 5;
@@ -62,7 +62,7 @@ void ControlledByPlayerGoal::tick()
{
boosting = false;
}
- moveSpeed += moveSpeed * 1.15f * Mth::sin((float) boostTime / boostTimeTotal * PI);
+ moveSpeed += moveSpeed * 1.15f * Mth::sin(static_cast<float>(boostTime) / boostTimeTotal * PI);
}
float friction = 0.91f;
@@ -117,13 +117,13 @@ void ControlledByPlayerGoal::tick()
{
shared_ptr<ItemInstance> 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)
{
- shared_ptr<ItemInstance> replacement = shared_ptr<ItemInstance>(new ItemInstance(Item::fishingRod));
+ shared_ptr<ItemInstance> replacement = std::make_shared<ItemInstance>(Item::fishingRod);
replacement->setTag(carriedItem->tag);
player->inventory->items[player->inventory->selected] = replacement;
}
@@ -135,7 +135,7 @@ void ControlledByPlayerGoal::tick()
bool ControlledByPlayerGoal::isNoJumpTile(int tile)
{
- return Tile::tiles[tile] != NULL && (Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_STAIRS || (dynamic_cast<HalfSlabTile *>(Tile::tiles[tile]) != NULL) );
+ return Tile::tiles[tile] != nullptr && (Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_STAIRS || (dynamic_cast<HalfSlabTile *>(Tile::tiles[tile]) != nullptr) );
}
bool ControlledByPlayerGoal::isBoosting()
diff --git a/Minecraft.World/Cow.cpp b/Minecraft.World/Cow.cpp
index 05e70102..69628d64 100644
--- a/Minecraft.World/Cow.cpp
+++ b/Minecraft.World/Cow.cpp
@@ -106,17 +106,17 @@ void Cow::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
bool Cow::mobInteract(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> item = player->inventory->getSelected();
- if (item != NULL && item->id == Item::bucket_empty->id && !player->abilities.instabuild)
+ if (item != nullptr && item->id == Item::bucket_empty->id && !player->abilities.instabuild)
{
player->awardStat(GenericStats::cowsMilked(),GenericStats::param_cowsMilked());
if (item->count-- == 0)
{
- player->inventory->setItem(player->inventory->selected, shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_milk) ) );
+ player->inventory->setItem(player->inventory->selected, std::make_shared<ItemInstance>(Item::bucket_milk));
}
- else if (!player->inventory->add(shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_milk) )))
+ else if (!player->inventory->add(std::make_shared<ItemInstance>(Item::bucket_milk)))
{
- player->drop(shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_milk) ));
+ player->drop(std::make_shared<ItemInstance>(Item::bucket_milk));
}
return true;
@@ -129,7 +129,7 @@ shared_ptr<AgableMob> Cow::getBreedOffspring(shared_ptr<AgableMob> target)
// 4J - added limit to number of animals that can be bred
if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) )
{
- return shared_ptr<Cow>( new Cow(level) );
+ return std::make_shared<Cow>(level);
}
else
{
diff --git a/Minecraft.World/CraftItemPacket.h b/Minecraft.World/CraftItemPacket.h
index 9793d593..f6cbdd3d 100644
--- a/Minecraft.World/CraftItemPacket.h
+++ b/Minecraft.World/CraftItemPacket.h
@@ -22,6 +22,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new CraftItemPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<CraftItemPacket>(); }
virtual int getId() { return 150; }
}; \ No newline at end of file
diff --git a/Minecraft.World/CraftingContainer.cpp b/Minecraft.World/CraftingContainer.cpp
index 47a11eb4..3ec1b039 100644
--- a/Minecraft.World/CraftingContainer.cpp
+++ b/Minecraft.World/CraftingContainer.cpp
@@ -58,7 +58,7 @@ bool CraftingContainer::hasCustomName()
shared_ptr<ItemInstance> CraftingContainer::removeItemNoUpdate(int slot)
{
- if ((*items)[slot] != NULL)
+ if ((*items)[slot] != nullptr)
{
shared_ptr<ItemInstance> item = (*items)[slot];
(*items)[slot] = nullptr;
@@ -69,7 +69,7 @@ shared_ptr<ItemInstance> CraftingContainer::removeItemNoUpdate(int slot)
shared_ptr<ItemInstance> CraftingContainer::removeItem(unsigned int slot, int count)
{
- if ((*items)[slot] != NULL)
+ if ((*items)[slot] != nullptr)
{
if ((*items)[slot]->count <= count)
{
diff --git a/Minecraft.World/CraftingMenu.cpp b/Minecraft.World/CraftingMenu.cpp
index c104bbec..6f24d310 100644
--- a/Minecraft.World/CraftingMenu.cpp
+++ b/Minecraft.World/CraftingMenu.cpp
@@ -19,8 +19,8 @@ const int CraftingMenu::USE_ROW_SLOT_END = CraftingMenu::USE_ROW_SLOT_START + 9;
CraftingMenu::CraftingMenu(shared_ptr<Inventory> inventory, Level *level, int xt, int yt, int zt) : AbstractContainerMenu()
{
- craftSlots = shared_ptr<CraftingContainer>( new CraftingContainer(this, 3, 3) );
- resultSlots = shared_ptr<ResultContainer>( new ResultContainer() );
+ craftSlots = std::make_shared<CraftingContainer>(this, 3, 3);
+ resultSlots = std::make_shared<ResultContainer>();
this->level = level;
x = xt;
@@ -64,7 +64,7 @@ void CraftingMenu::removed(shared_ptr<Player> player)
for (int i = 0; i < 9; i++)
{
shared_ptr<ItemInstance> item = craftSlots->removeItemNoUpdate(i);
- if (item != NULL)
+ if (item != nullptr)
{
player->drop(item);
}
@@ -82,7 +82,7 @@ shared_ptr<ItemInstance> CraftingMenu::quickMoveStack(shared_ptr<Player> player,
{
shared_ptr<ItemInstance> clicked = nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
diff --git a/Minecraft.World/Creeper.cpp b/Minecraft.World/Creeper.cpp
index 29be2c0c..0cd6b534 100644
--- a/Minecraft.World/Creeper.cpp
+++ b/Minecraft.World/Creeper.cpp
@@ -64,9 +64,9 @@ bool Creeper::useNewAi()
int Creeper::getMaxFallDistance()
{
- if (getTarget() == NULL) return 3;
+ if (getTarget() == nullptr) return 3;
// As long as they survive the fall they should try.
- return 3 + (int) (getHealth() - 1);
+ return 3 + static_cast<int>(getHealth() - 1);
}
void Creeper::causeFallDamage(float distance)
@@ -81,22 +81,22 @@ void Creeper::defineSynchedData()
{
Monster::defineSynchedData();
- entityData->define(DATA_SWELL_DIR, (byte) -1);
- entityData->define(DATA_IS_POWERED, (byte) 0);
+ entityData->define(DATA_SWELL_DIR, static_cast<byte>(-1));
+ entityData->define(DATA_IS_POWERED, static_cast<byte>(0));
}
void Creeper::addAdditonalSaveData(CompoundTag *entityTag)
{
Monster::addAdditonalSaveData(entityTag);
if (entityData->getByte(DATA_IS_POWERED) == 1) entityTag->putBoolean(L"powered", true);
- entityTag->putShort(L"Fuse", (short) maxSwell);
- entityTag->putByte(L"ExplosionRadius", (byte) explosionRadius);
+ entityTag->putShort(L"Fuse", static_cast<short>(maxSwell));
+ entityTag->putByte(L"ExplosionRadius", static_cast<byte>(explosionRadius));
}
void Creeper::readAdditionalSaveData(CompoundTag *tag)
{
Monster::readAdditionalSaveData(tag);
- entityData->set(DATA_IS_POWERED, (byte) (tag->getBoolean(L"powered") ? 1 : 0));
+ entityData->set(DATA_IS_POWERED, static_cast<byte>(tag->getBoolean(L"powered") ? 1 : 0));
if (tag->contains(L"Fuse")) maxSwell = tag->getShort(L"Fuse");
if (tag->contains(L"ExplosionRadius")) explosionRadius = tag->getByte(L"ExplosionRadius");
}
@@ -142,13 +142,13 @@ void Creeper::die(DamageSource *source)
{
Monster::die(source);
- if ( source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_SKELETON) )
+ if ( source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_SKELETON) )
{
int recordId = Item::record_01_Id + random->nextInt(Item::record_12_Id - Item::record_01_Id + 1);
spawnAtLocation(recordId, 1);
}
- if ( source->getDirectEntity() != NULL && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER) )
+ if ( source->getDirectEntity() != nullptr && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) )
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(source->getEntity());
player->awardStat(GenericStats::archer(), GenericStats::param_archer());
@@ -177,16 +177,16 @@ int Creeper::getDeathLoot()
int Creeper::getSwellDir()
{
- return (int) (char) entityData->getByte(DATA_SWELL_DIR);
+ return (int) static_cast<char>(entityData->getByte(DATA_SWELL_DIR));
}
void Creeper::setSwellDir(int dir)
{
- entityData->set(DATA_SWELL_DIR, (byte) dir);
+ entityData->set(DATA_SWELL_DIR, static_cast<byte>(dir));
}
void Creeper::thunderHit(const LightningBolt *lightningBolt)
{
Monster::thunderHit(lightningBolt);
- entityData->set(DATA_IS_POWERED, (byte) 1);
+ entityData->set(DATA_IS_POWERED, static_cast<byte>(1));
}
diff --git a/Minecraft.World/CropTile.cpp b/Minecraft.World/CropTile.cpp
index 0df71924..1a161199 100644
--- a/Minecraft.World/CropTile.cpp
+++ b/Minecraft.World/CropTile.cpp
@@ -9,7 +9,7 @@ CropTile::CropTile(int id) : Bush(id)
{
setTicking(true);
updateDefaultShape();
- icons = NULL;
+ icons = nullptr;
setDestroyTime(0.0f);
setSoundType(SOUND_GRASS);
@@ -40,7 +40,7 @@ void CropTile::tick(Level *level, int x, int y, int z, Random *random)
{
float growthSpeed = getGrowthSpeed(level, x, y, z);
- if (random->nextInt((int) (25 / growthSpeed) + 1) == 0)
+ if (random->nextInt(static_cast<int>(25 / growthSpeed) + 1) == 0)
{
age++;
level->setData(x, y, z, age, Tile::UPDATE_CLIENTS);
@@ -136,7 +136,7 @@ void CropTile::spawnResources(Level *level, int x, int y, int z, int data, float
for (int i = 0; i < count; i++)
{
if (level->random->nextInt(5 * 3) > data) continue;
- popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(getBaseSeedId(), 1, 0)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(getBaseSeedId(), 1, 0));
}
}
}
diff --git a/Minecraft.World/CustomLevelSource.cpp b/Minecraft.World/CustomLevelSource.cpp
index 0f4c6479..7281d298 100644
--- a/Minecraft.World/CustomLevelSource.cpp
+++ b/Minecraft.World/CustomLevelSource.cpp
@@ -30,7 +30,7 @@ CustomLevelSource::CustomLevelSource(Level *level, int64_t seed, bool generateSt
string path = "GAME:\\GameRules\\heightmap.bin";
#endif
#endif
- HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if( file == INVALID_HANDLE_VALUE )
{
app.FatalLoadError();
@@ -44,14 +44,14 @@ CustomLevelSource::CustomLevelSource(Level *level, int64_t seed, bool generateSt
__debugbreak(); // TODO
DWORD bytesRead,dwFileSize = 0;
#else
- DWORD bytesRead,dwFileSize = GetFileSize(file,NULL);
+ DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr);
#endif
if(dwFileSize > m_heightmapOverride.length)
{
app.DebugPrintf("Heightmap binary is too large!!\n");
__debugbreak();
}
- BOOL bSuccess = ReadFile(file,m_heightmapOverride.data,dwFileSize,&bytesRead,NULL);
+ BOOL bSuccess = ReadFile(file,m_heightmapOverride.data,dwFileSize,&bytesRead,nullptr);
if(bSuccess==FALSE)
{
@@ -72,7 +72,7 @@ CustomLevelSource::CustomLevelSource(Level *level, int64_t seed, bool generateSt
string waterHeightPath = "GAME:\\GameRules\\waterheight.bin";
#endif
#endif
- file = CreateFile(waterHeightPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ file = CreateFile(waterHeightPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if( file == INVALID_HANDLE_VALUE )
{
DWORD error = GetLastError();
@@ -86,14 +86,14 @@ CustomLevelSource::CustomLevelSource(Level *level, int64_t seed, bool generateSt
__debugbreak(); // TODO
DWORD bytesRead,dwFileSize = 0;
#else
- DWORD bytesRead,dwFileSize = GetFileSize(file,NULL);
+ DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr);
#endif
if(dwFileSize > m_waterheightOverride.length)
{
app.DebugPrintf("waterheight binary is too large!!\n");
__debugbreak();
}
- BOOL bSuccess = ReadFile(file,m_waterheightOverride.data,dwFileSize,&bytesRead,NULL);
+ BOOL bSuccess = ReadFile(file,m_waterheightOverride.data,dwFileSize,&bytesRead,nullptr);
if(bSuccess==FALSE)
{
@@ -196,7 +196,7 @@ void CustomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
if( emin < falloffStart )
{
int falloff = falloffStart - emin;
- comp = ((float)falloff / (float)falloffStart ) * falloffMax;
+ comp = (static_cast<float>(falloff) / static_cast<float>(falloffStart) ) * falloffMax;
}
// 4J - end of extra code
///////////////////////////////////////////////////////////////////
@@ -204,11 +204,11 @@ void CustomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
// 4J - this comparison used to just be with 0.0f but is now varied by block above
if (yc * CHUNK_HEIGHT + y < mapHeight)
{
- tileId = (byte) Tile::stone_Id;
+ tileId = static_cast<byte>(Tile::stone_Id);
}
else if (yc * CHUNK_HEIGHT + y < waterHeight)
{
- tileId = (byte) Tile::calmWater_Id;
+ tileId = static_cast<byte>(Tile::calmWater_Id);
}
// 4J - more extra code to make sure that the column at the edge of the world is just water & rock, to match the infinite sea that
@@ -262,7 +262,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
Biome *b = biomes[z + x * 16];
float temp = b->getTemperature();
- int runDepth = (int) (depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25);
+ int runDepth = static_cast<int>(depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25);
int run = -1;
@@ -270,7 +270,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
byte material = b->material;
LevelGenerationOptions *lgo = app.getLevelGenerationOptions();
- if(lgo != NULL)
+ if(lgo != nullptr)
{
lgo->getBiomeOverride(b->id,material,top);
}
@@ -290,7 +290,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (y <= 1 + random->nextInt(2)) // 4J - changed to make the bedrock not have bits you can get stuck in
// if (y <= 0 + random->nextInt(5))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
}
else
{
@@ -307,13 +307,13 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (runDepth <= 0)
{
top = 0;
- material = (byte) Tile::stone_Id;
+ material = static_cast<byte>(Tile::stone_Id);
}
else if (y >= waterHeight - 4 && y <= waterHeight + 1)
{
top = b->topMaterial;
material = b->material;
- if(lgo != NULL)
+ if(lgo != nullptr)
{
lgo->getBiomeOverride(b->id,material,top);
}
@@ -321,8 +321,8 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (y < waterHeight && top == 0)
{
- if (temp < 0.15f) top = (byte) Tile::ice_Id;
- else top = (byte) Tile::calmWater_Id;
+ if (temp < 0.15f) top = static_cast<byte>(Tile::ice_Id);
+ else top = static_cast<byte>(Tile::calmWater_Id);
}
run = runDepth;
@@ -339,7 +339,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (run == 0 && material == Tile::sand_Id)
{
run = random->nextInt(4);
- material = (byte) Tile::sandStone_Id;
+ material = static_cast<byte>(Tile::sandStone_Id);
}
}
}
@@ -357,7 +357,7 @@ LevelChunk *CustomLevelSource::create(int x, int z)
#ifdef _OVERRIDE_HEIGHTMAP
return getChunk(x,z);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -368,7 +368,7 @@ LevelChunk *CustomLevelSource::getChunk(int xOffs, int zOffs)
// 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed
int blocksSize = Level::maxBuildHeight * 16 * 16;
- byte *tileData = (byte *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
+ byte *tileData = static_cast<byte *>(XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE));
XMemSet128(tileData,0,blocksSize);
byteArray blocks = byteArray(tileData,blocksSize);
// byteArray blocks = byteArray(16 * level->depth * 16);
@@ -411,7 +411,7 @@ LevelChunk *CustomLevelSource::getChunk(int xOffs, int zOffs)
return levelChunk;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -622,9 +622,9 @@ vector<Biome::MobSpawnerData *> *CustomLevelSource::getMobsAt(MobCategory *mobCa
{
#ifdef _OVERRIDE_HEIGHTMAP
Biome *biome = level->getBiome(x, z);
- if (biome == NULL)
+ if (biome == nullptr)
{
- return NULL;
+ return nullptr;
}
if (mobCategory == MobCategory::monster && scatteredFeature->isSwamphut(x, y, z))
{
@@ -632,19 +632,19 @@ vector<Biome::MobSpawnerData *> *CustomLevelSource::getMobsAt(MobCategory *mobCa
}
return biome->getMobs(mobCategory);
#else
- return NULL;
+ return nullptr;
#endif
}
TilePos *CustomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
{
#ifdef _OVERRIDE_HEIGHTMAP
- if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != NULL)
+ if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != nullptr)
{
return strongholdFeature->getNearestGeneratedFeature(level, x, y, z);
}
#endif
- return NULL;
+ return nullptr;
}
void CustomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ)
@@ -652,10 +652,10 @@ void CustomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ)
if (generateStructures)
{
#ifdef _OVERRIDE_HEIGHTMAP
- mineShaftFeature->apply(this, level, chunkX, chunkZ, NULL);
- villageFeature->apply(this, level, chunkX, chunkZ, NULL);
- strongholdFeature->apply(this, level, chunkX, chunkZ, NULL);
- scatteredFeature->apply(this, level, chunkX, chunkZ, NULL);
+ mineShaftFeature->apply(this, level, chunkX, chunkZ, byteArray());
+ villageFeature->apply(this, level, chunkX, chunkZ, byteArray());
+ strongholdFeature->apply(this, level, chunkX, chunkZ, byteArray());
+ scatteredFeature->apply(this, level, chunkX, chunkZ, byteArray());
#endif
}
} \ No newline at end of file
diff --git a/Minecraft.World/CustomPayloadPacket.cpp b/Minecraft.World/CustomPayloadPacket.cpp
index 29e2828e..46fde5aa 100644
--- a/Minecraft.World/CustomPayloadPacket.cpp
+++ b/Minecraft.World/CustomPayloadPacket.cpp
@@ -23,7 +23,7 @@ CustomPayloadPacket::CustomPayloadPacket(const wstring &identifier, byteArray da
this->identifier = identifier;
this->data = data;
- if (data.data != NULL)
+ if (data.data != nullptr)
{
length = data.length;
@@ -45,7 +45,7 @@ void CustomPayloadPacket::read(DataInputStream *dis)
if (length > 0 && length < Short::MAX_VALUE)
{
- if(data.data != NULL)
+ if(data.data != nullptr)
{
delete [] data.data;
}
@@ -57,8 +57,8 @@ void CustomPayloadPacket::read(DataInputStream *dis)
void CustomPayloadPacket::write(DataOutputStream *dos)
{
writeUtf(identifier, dos);
- dos->writeShort((short) length);
- if (data.data != NULL)
+ dos->writeShort(static_cast<short>(length));
+ if (data.data != nullptr)
{
dos->write(data);
}
diff --git a/Minecraft.World/CustomPayloadPacket.h b/Minecraft.World/CustomPayloadPacket.h
index 95c5e708..82a3f6e2 100644
--- a/Minecraft.World/CustomPayloadPacket.h
+++ b/Minecraft.World/CustomPayloadPacket.h
@@ -30,6 +30,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new CustomPayloadPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<CustomPayloadPacket>(); }
virtual int getId() { return 250; }
}; \ No newline at end of file
diff --git a/Minecraft.World/DamageEnchantment.cpp b/Minecraft.World/DamageEnchantment.cpp
index ce5a7c1f..4ca8c9a6 100644
--- a/Minecraft.World/DamageEnchantment.cpp
+++ b/Minecraft.World/DamageEnchantment.cpp
@@ -51,7 +51,7 @@ int DamageEnchantment::getDescriptionId()
bool DamageEnchantment::isCompatibleWith(Enchantment *other) const
{
- return dynamic_cast<DamageEnchantment *>(other) == NULL;
+ return dynamic_cast<DamageEnchantment *>(other) == nullptr;
}
bool DamageEnchantment::canEnchant(shared_ptr<ItemInstance> item)
diff --git a/Minecraft.World/DamageSource.cpp b/Minecraft.World/DamageSource.cpp
index 1ed1c65f..bc3adc80 100644
--- a/Minecraft.World/DamageSource.cpp
+++ b/Minecraft.World/DamageSource.cpp
@@ -40,7 +40,7 @@ DamageSource *DamageSource::arrow(shared_ptr<Arrow> arrow, shared_ptr<Entity> ow
DamageSource *DamageSource::fireball(shared_ptr<Fireball> fireball, shared_ptr<Entity> owner)
{
- if (owner == NULL)
+ if (owner == nullptr)
{
return (new IndirectEntityDamageSource(ChatPacket::e_ChatDeathOnFire, ChatPacket::e_ChatDeathOnFire, fireball, fireball))->setIsFire()->setProjectile();
}
@@ -64,7 +64,7 @@ DamageSource *DamageSource::thorns(shared_ptr<Entity> source)
DamageSource *DamageSource::explosion(Explosion *explosion)
{
- if ( (explosion != NULL) && (explosion->getSourceMob() != NULL) )
+ if ( (explosion != nullptr) && (explosion->getSourceMob() != nullptr) )
{
return (new EntityDamageSource(ChatPacket::e_ChatDeathExplosionPlayer, ChatPacket::e_ChatDeathExplosionPlayer, explosion->getSourceMob()))->setScalesWithDifficulty()->setExplosion();
}
@@ -191,13 +191,13 @@ DamageSource *DamageSource::setMagic()
shared_ptr<ChatPacket> DamageSource::getDeathMessagePacket(shared_ptr<LivingEntity> player)
{
shared_ptr<LivingEntity> source = player->getKillCredit();
- if(source != NULL)
+ if(source != nullptr)
{
- return shared_ptr<ChatPacket>( new ChatPacket(player->getNetworkName(), m_msgWithItemId != ChatPacket::e_ChatCustom ? m_msgWithItemId : m_msgId, source->GetType(), source->getNetworkName() ) );
+ return std::make_shared<ChatPacket>(player->getNetworkName(), m_msgWithItemId != ChatPacket::e_ChatCustom ? m_msgWithItemId : m_msgId, source->GetType(), source->getNetworkName());
}
else
{
- return shared_ptr<ChatPacket>( new ChatPacket(player->getNetworkName(), m_msgId ) );
+ return std::make_shared<ChatPacket>(player->getNetworkName(), m_msgId);
}
}
diff --git a/Minecraft.World/DataInputStream.cpp b/Minecraft.World/DataInputStream.cpp
index 18deed39..4e4f5cd1 100644
--- a/Minecraft.World/DataInputStream.cpp
+++ b/Minecraft.World/DataInputStream.cpp
@@ -92,12 +92,12 @@ bool DataInputStream::readBoolean()
//the 8-bit value read.
byte DataInputStream::readByte()
{
- return (byte) stream->read();
+ return static_cast<byte>(stream->read());
}
unsigned char DataInputStream::readUnsignedByte()
{
- return (unsigned char) stream->read();
+ return static_cast<unsigned char>(stream->read());
}
//Reads two input bytes and returns a char value. Let a be the first byte read and b be the second byte. The value returned is:
@@ -110,7 +110,7 @@ wchar_t DataInputStream::readChar()
{
int a = stream->read();
int b = stream->read();
- return (wchar_t)((a << 8) | (b & 0xff));
+ return static_cast<wchar_t>((a << 8) | (b & 0xff));
}
//Reads some bytes from an input stream and stores them into the buffer array b. The number of bytes read is equal to the length of b.
@@ -254,14 +254,14 @@ short DataInputStream::readShort()
{
int a = stream->read();
int b = stream->read();
- return (short)((a << 8) | (b & 0xff));
+ return static_cast<short>((a << 8) | (b & 0xff));
}
unsigned short DataInputStream::readUnsignedShort()
{
int a = stream->read();
int b = stream->read();
- return (unsigned short)((a << 8) | (b & 0xff));
+ return static_cast<unsigned short>((a << 8) | (b & 0xff));
}
//Reads in a string that has been encoded using a modified UTF-8 format. The general contract of readUTF is that it reads a representation
@@ -301,7 +301,7 @@ wstring DataInputStream::readUTF()
wstring outputString;
int a = stream->read();
int b = stream->read();
- unsigned short UTFLength = (unsigned short) (((a & 0xff) << 8) | (b & 0xff));
+ unsigned short UTFLength = static_cast<unsigned short>(((a & 0xff) << 8) | (b & 0xff));
//// 4J Stu - I decided while writing DataOutputStream that we didn't need to bother using the UTF8 format
//// used in the java libs, and just write in/out as wchar_t all the time
@@ -343,7 +343,7 @@ wstring DataInputStream::readUTF()
else if( (firstByte & 0x80) == 0x00 )
{
// One byte UTF
- wchar_t readChar = (wchar_t)firstByte;
+ wchar_t readChar = static_cast<wchar_t>(firstByte);
outputString.push_back( readChar );
continue;
}
@@ -374,7 +374,7 @@ wstring DataInputStream::readUTF()
break;
}
- wchar_t readChar = (wchar_t)( ((firstByte& 0x1F) << 6) | (secondByte & 0x3F) );
+ wchar_t readChar = static_cast<wchar_t>(((firstByte & 0x1F) << 6) | (secondByte & 0x3F));
outputString.push_back( readChar );
continue;
}
@@ -422,7 +422,7 @@ wstring DataInputStream::readUTF()
break;
}
- wchar_t readChar = (wchar_t)(((firstByte & 0x0F) << 12) | ((secondByte & 0x3F) << 6) | (thirdByte & 0x3F));
+ wchar_t readChar = static_cast<wchar_t>(((firstByte & 0x0F) << 12) | ((secondByte & 0x3F) << 6) | (thirdByte & 0x3F));
outputString.push_back( readChar );
continue;
}
diff --git a/Minecraft.World/DataLayer.cpp b/Minecraft.World/DataLayer.cpp
index a5e7d088..f3916320 100644
--- a/Minecraft.World/DataLayer.cpp
+++ b/Minecraft.World/DataLayer.cpp
@@ -40,21 +40,21 @@ void DataLayer::set(int x, int y, int z, int val)
if (part == 0)
{
- data[slot] = (byte) ((data[slot] & 0xf0) | (val & 0xf));
+ data[slot] = static_cast<byte>((data[slot] & 0xf0) | (val & 0xf));
} else
{
- data[slot] = (byte) ((data[slot] & 0x0f) | ((val & 0xf) << 4));
+ data[slot] = static_cast<byte>((data[slot] & 0x0f) | ((val & 0xf) << 4));
}
}
bool DataLayer::isValid()
{
- return data.data != NULL;
+ return data.data != nullptr;
}
void DataLayer::setAll(int br)
{
- byte val = (byte) (br & (br << 4));
+ byte val = static_cast<byte>(br & (br << 4));
for (unsigned int i = 0; i < data.length; i++)
{
data[i] = val;
diff --git a/Minecraft.World/DataOutputStream.cpp b/Minecraft.World/DataOutputStream.cpp
index 1a24e31a..1a3931cf 100644
--- a/Minecraft.World/DataOutputStream.cpp
+++ b/Minecraft.World/DataOutputStream.cpp
@@ -184,7 +184,7 @@ void DataOutputStream::writeChars(const wstring& str)
//v - a boolean value to be written.
void DataOutputStream::writeBoolean(bool b)
{
- stream->write( b ? (byte)1 : (byte)0 );
+ stream->write( b ? static_cast<byte>(1) : static_cast<byte>(0) );
// TODO 4J Stu - Error handling?
written += 1;
}
@@ -199,7 +199,7 @@ void DataOutputStream::writeBoolean(bool b)
//str - a string to be written.
void DataOutputStream::writeUTF(const wstring& str)
{
- int strlen = (int)str.length();
+ int strlen = static_cast<int>(str.length());
int utflen = 0;
int c, count = 0;
@@ -227,15 +227,15 @@ void DataOutputStream::writeUTF(const wstring& str)
byteArray bytearr(utflen+2);
- bytearr[count++] = (byte) ((utflen >> 8) & 0xFF);
- bytearr[count++] = (byte) ((utflen >> 0) & 0xFF);
+ bytearr[count++] = static_cast<byte>((utflen >> 8) & 0xFF);
+ bytearr[count++] = static_cast<byte>((utflen >> 0) & 0xFF);
int i=0;
for (i=0; i<strlen; i++)
{
c = str.at(i);
if (!((c >= 0x0001) && (c <= 0x007F))) break;
- bytearr[count++] = (byte) c;
+ bytearr[count++] = static_cast<byte>(c);
}
for (;i < strlen; i++)
@@ -243,19 +243,19 @@ void DataOutputStream::writeUTF(const wstring& str)
c = str.at(i);
if ((c >= 0x0001) && (c <= 0x007F))
{
- bytearr[count++] = (byte) c;
+ bytearr[count++] = static_cast<byte>(c);
}
else if (c > 0x07FF)
{
- bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
- bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
- bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ bytearr[count++] = static_cast<byte>(0xE0 | ((c >> 12) & 0x0F));
+ bytearr[count++] = static_cast<byte>(0x80 | ((c >> 6) & 0x3F));
+ bytearr[count++] = static_cast<byte>(0x80 | ((c >> 0) & 0x3F));
}
else
{
- bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
- bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ bytearr[count++] = static_cast<byte>(0xC0 | ((c >> 6) & 0x1F));
+ bytearr[count++] = static_cast<byte>(0x80 | ((c >> 0) & 0x3F));
}
}
write(bytearr, 0, utflen+2);
diff --git a/Minecraft.World/DaylightDetectorTile.cpp b/Minecraft.World/DaylightDetectorTile.cpp
index 1bc9943e..0bfc949b 100644
--- a/Minecraft.World/DaylightDetectorTile.cpp
+++ b/Minecraft.World/DaylightDetectorTile.cpp
@@ -62,7 +62,7 @@ void DaylightDetectorTile::updateSignalStrength(Level *level, int x, int y, int
sunAngle = sunAngle + (PI * 2.0f - sunAngle) * .2f;
}
- target = Math::round((float) target * Mth::cos(sunAngle));
+ target = Math::round(static_cast<float>(target) * Mth::cos(sunAngle));
if (target < 0)
{
target = 0;
@@ -95,7 +95,7 @@ bool DaylightDetectorTile::isSignalSource()
shared_ptr<TileEntity> DaylightDetectorTile::newTileEntity(Level *level)
{
- return shared_ptr<DaylightDetectorTileEntity>( new DaylightDetectorTileEntity() );
+ return std::make_shared<DaylightDetectorTileEntity>();
}
Icon *DaylightDetectorTile::getTexture(int face, int data)
diff --git a/Minecraft.World/DaylightDetectorTileEntity.cpp b/Minecraft.World/DaylightDetectorTileEntity.cpp
index 5a329413..0cf1cec3 100644
--- a/Minecraft.World/DaylightDetectorTileEntity.cpp
+++ b/Minecraft.World/DaylightDetectorTileEntity.cpp
@@ -9,12 +9,12 @@ DaylightDetectorTileEntity::DaylightDetectorTileEntity()
void DaylightDetectorTileEntity::tick()
{
- if (level != NULL && !level->isClientSide && (level->getGameTime() % SharedConstants::TICKS_PER_SECOND) == 0)
+ if (level != nullptr && !level->isClientSide && (level->getGameTime() % SharedConstants::TICKS_PER_SECOND) == 0)
{
tile = getTile();
- if (tile != NULL && dynamic_cast<DaylightDetectorTile *>(tile) != NULL)
+ if (tile != nullptr && dynamic_cast<DaylightDetectorTile *>(tile) != nullptr)
{
- ((DaylightDetectorTile *) tile)->updateSignalStrength(level, x, y, z);
+ static_cast<DaylightDetectorTile *>(tile)->updateSignalStrength(level, x, y, z);
}
}
}
@@ -22,7 +22,7 @@ void DaylightDetectorTileEntity::tick()
// 4J Added
shared_ptr<TileEntity> DaylightDetectorTileEntity::clone()
{
- shared_ptr<DaylightDetectorTileEntity> result = shared_ptr<DaylightDetectorTileEntity>( new DaylightDetectorTileEntity() );
+ shared_ptr<DaylightDetectorTileEntity> result = std::make_shared<DaylightDetectorTileEntity>();
TileEntity::clone(result);
return result;
diff --git a/Minecraft.World/DeadBushTile.cpp b/Minecraft.World/DeadBushTile.cpp
index 33fdfe6c..7f22f747 100644
--- a/Minecraft.World/DeadBushTile.cpp
+++ b/Minecraft.World/DeadBushTile.cpp
@@ -29,7 +29,7 @@ int DeadBushTile::getResource(int data, Random *random, int playerBonusLevel)
void DeadBushTile::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y, int z, int data)
{
- if (!level->isClientSide && player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears_Id)
+ if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears_Id)
{
player->awardStat(
GenericStats::blocksMined(id),
@@ -37,7 +37,7 @@ void DeadBushTile::playerDestroy(Level *level, shared_ptr<Player> player, int x,
);
// drop leaf block instead of sapling
- popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Tile::deadBush, 1, data)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(Tile::deadBush, 1, data));
}
else
{
diff --git a/Minecraft.World/DebugOptionsPacket.cpp b/Minecraft.World/DebugOptionsPacket.cpp
index f287efcd..e62fb2eb 100644
--- a/Minecraft.World/DebugOptionsPacket.cpp
+++ b/Minecraft.World/DebugOptionsPacket.cpp
@@ -28,12 +28,12 @@ void DebugOptionsPacket::handle(PacketListener *listener)
void DebugOptionsPacket::read(DataInputStream *dis) //throws IOException
{
- m_uiVal = (unsigned int)dis->readInt();
+ m_uiVal = static_cast<unsigned int>(dis->readInt());
}
void DebugOptionsPacket::write(DataOutputStream *dos) // throws IOException
{
- dos->writeInt((int)m_uiVal);
+ dos->writeInt(static_cast<int>(m_uiVal));
}
int DebugOptionsPacket::getEstimatedSize()
diff --git a/Minecraft.World/DebugOptionsPacket.h b/Minecraft.World/DebugOptionsPacket.h
index 9ac5ef2f..09167f8c 100644
--- a/Minecraft.World/DebugOptionsPacket.h
+++ b/Minecraft.World/DebugOptionsPacket.h
@@ -21,6 +21,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new DebugOptionsPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<DebugOptionsPacket>(); }
virtual int getId() { return 152; }
};
diff --git a/Minecraft.World/DefaultDispenseItemBehavior.cpp b/Minecraft.World/DefaultDispenseItemBehavior.cpp
index 8fd13282..8563ef56 100644
--- a/Minecraft.World/DefaultDispenseItemBehavior.cpp
+++ b/Minecraft.World/DefaultDispenseItemBehavior.cpp
@@ -38,7 +38,7 @@ void DefaultDispenseItemBehavior::spawnItem(Level *world, shared_ptr<ItemInstanc
double spawnY = position->getY();
double spawnZ = position->getZ();
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>(new ItemEntity(world, spawnX, spawnY - 0.3, spawnZ, item));
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(world, spawnX, spawnY - 0.3, spawnZ, item);
double pow = world->random->nextDouble() * 0.1 + 0.2;
itemEntity->xd = facing->getStepX() * pow;
diff --git a/Minecraft.World/DefendVillageTargetGoal.cpp b/Minecraft.World/DefendVillageTargetGoal.cpp
index 6ed6af53..201738a3 100644
--- a/Minecraft.World/DefendVillageTargetGoal.cpp
+++ b/Minecraft.World/DefendVillageTargetGoal.cpp
@@ -12,7 +12,7 @@ DefendVillageTargetGoal::DefendVillageTargetGoal(VillagerGolem *golem) : TargetG
bool DefendVillageTargetGoal::canUse()
{
shared_ptr<Village> village = golem->getVillage();
- if (village == NULL) return false;
+ if (village == nullptr) return false;
potentialTarget = weak_ptr<LivingEntity>(village->getClosestAggressor(dynamic_pointer_cast<LivingEntity>(golem->shared_from_this())));
shared_ptr<LivingEntity> potTarget = potentialTarget.lock();
if (!canAttack(potTarget, false))
diff --git a/Minecraft.World/DesertBiome.cpp b/Minecraft.World/DesertBiome.cpp
index c36b0908..e67faef5 100644
--- a/Minecraft.World/DesertBiome.cpp
+++ b/Minecraft.World/DesertBiome.cpp
@@ -10,8 +10,8 @@ DesertBiome::DesertBiome(int id) : Biome(id)
friendlies.clear();
friendlies_chicken.clear(); // 4J added
friendlies_wolf.clear(); // 4J added
- topMaterial = (BYTE) Tile::sand_Id;
- material = (BYTE) Tile::sand_Id;
+ topMaterial = static_cast<BYTE>(Tile::sand_Id);
+ material = static_cast<BYTE>(Tile::sand_Id);
decorator->treeCount = -999;
decorator->deadBushCount = 2;
diff --git a/Minecraft.World/DetectorRailTile.cpp b/Minecraft.World/DetectorRailTile.cpp
index 16265ceb..ce35a592 100644
--- a/Minecraft.World/DetectorRailTile.cpp
+++ b/Minecraft.World/DetectorRailTile.cpp
@@ -12,7 +12,7 @@
DetectorRailTile::DetectorRailTile(int id) : BaseRailTile(id, true)
{
setTicking(true);
- icons = NULL;
+ icons = nullptr;
}
int DetectorRailTile::getTickDelay(Level *level)
diff --git a/Minecraft.World/Dimension.cpp b/Minecraft.World/Dimension.cpp
index 479edae8..b7a2ea7c 100644
--- a/Minecraft.World/Dimension.cpp
+++ b/Minecraft.World/Dimension.cpp
@@ -30,7 +30,7 @@ void Dimension::updateLightRamp()
float ambientLight = 0.00f;
for (int i = 0; i <= Level::MAX_BRIGHTNESS; i++)
{
- float v = (1 - i / (float) (Level::MAX_BRIGHTNESS));
+ float v = (1 - i / static_cast<float>(Level::MAX_BRIGHTNESS));
brightnessRamp[i] = ((1 - v) / (v * 3 + 1)) * (1 - ambientLight) + ambientLight;
}
}
@@ -70,7 +70,7 @@ Dimension::~Dimension()
{
delete[] brightnessRamp;
- if(biomeSource != NULL)
+ if(biomeSource != nullptr)
delete biomeSource;
}
@@ -115,7 +115,7 @@ bool Dimension::isValidSpawn(int x, int z) const
float Dimension::getTimeOfDay(int64_t time, float a) const
{
- int dayStep = (int) (time % Level::TICKS_PER_DAY);
+ int dayStep = static_cast<int>(time % Level::TICKS_PER_DAY);
float td = (dayStep + a) / Level::TICKS_PER_DAY - 0.25f;
if (td < 0) td += 1;
if (td > 1) td -= 1;
@@ -127,7 +127,7 @@ float Dimension::getTimeOfDay(int64_t time, float a) const
int Dimension::getMoonPhase(int64_t time) const
{
- return ((int) (time / Level::TICKS_PER_DAY)) % 8;
+ return static_cast<int>(time / Level::TICKS_PER_DAY) % 8;
}
bool Dimension::isNaturalDimension()
@@ -161,7 +161,7 @@ float *Dimension::getSunriseColor(float td, float a)
return sunriseCol;
}
- return NULL;
+ return nullptr;
}
Vec3 *Dimension::getFogColor(float td, float a) const
@@ -192,12 +192,12 @@ 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;
+ return static_cast<float>(Level::genDepth);
}
bool Dimension::hasGround()
@@ -207,7 +207,7 @@ bool Dimension::hasGround()
Pos *Dimension::getSpawnPos()
{
- return NULL;
+ return nullptr;
}
int Dimension::getSpawnYPosition()
diff --git a/Minecraft.World/DiodeTile.cpp b/Minecraft.World/DiodeTile.cpp
index e5bbfede..b40a5af5 100644
--- a/Minecraft.World/DiodeTile.cpp
+++ b/Minecraft.World/DiodeTile.cpp
@@ -299,7 +299,7 @@ bool DiodeTile::isSolidRender(bool isServerLevel)
bool DiodeTile::isAlternateInput(int tile)
{
Tile *tt = Tile::tiles[tile];
- return tt != NULL && tt->isSignalSource();
+ return tt != nullptr && tt->isSignalSource();
}
int DiodeTile::getOutputSignal(LevelSource *level, int x, int y, int z, int data)
diff --git a/Minecraft.World/Direction.cpp b/Minecraft.World/Direction.cpp
index f758798b..c9ac93c7 100644
--- a/Minecraft.World/Direction.cpp
+++ b/Minecraft.World/Direction.cpp
@@ -65,7 +65,7 @@ int Direction::RELATIVE_DIRECTION_FACING[4][6] =
int Direction::getDirection(double xd, double zd)
{
- if (Mth::abs((float) xd) > Mth::abs((float) zd))
+ if (Mth::abs(static_cast<float>(xd)) > Mth::abs(static_cast<float>(zd)))
{
if (xd > 0)
{
diff --git a/Minecraft.World/DirectoryLevelStorage.cpp b/Minecraft.World/DirectoryLevelStorage.cpp
index 150df216..c557e37a 100644
--- a/Minecraft.World/DirectoryLevelStorage.cpp
+++ b/Minecraft.World/DirectoryLevelStorage.cpp
@@ -24,8 +24,8 @@ _MapDataMappings::_MapDataMappings()
int _MapDataMappings::getDimension(int id)
{
- int offset = (2*(id%4));
- int val = (dimensions[id>>2] & (3 << offset))>>offset;
+ const int offset = (2*(id%4));
+ const int val = (dimensions[id>>2] & (3 << offset))>>offset;
int returnVal=0;
@@ -54,7 +54,7 @@ void _MapDataMappings::setMapping(int id, PlayerUID xuid, int dimension)
{
xuids[id] = xuid;
- int offset = (2*(id%4));
+ const int offset = (2*(id%4));
// Reset it first
dimensions[id>>2] &= ~( 2 << offset );
@@ -108,7 +108,7 @@ void _MapDataMappings_old::setMapping(int id, PlayerUID xuid, int dimension)
#ifdef _LARGE_WORLDS
void DirectoryLevelStorage::PlayerMappings::addMapping(int id, int centreX, int centreZ, int dimension, int scale)
{
- int64_t index = ( ((int64_t)(centreZ & 0x1FFFFFFF)) << 34) | ( ((int64_t)(centreX & 0x1FFFFFFF)) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3);
+ const int64_t index = ( static_cast<int64_t>(centreZ & 0x1FFFFFFF) << 34) | ( static_cast<int64_t>(centreX & 0x1FFFFFFF) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3);
m_mappings[index] = id;
//app.DebugPrintf("Adding mapping: %d - (%d,%d)/%d/%d [%I64d - 0x%016llx]\n", id, centreX, centreZ, dimension, scale, index, index);
}
@@ -120,8 +120,8 @@ bool DirectoryLevelStorage::PlayerMappings::getMapping(int &id, int centreX, int
//int64_t zShifted = zMasked << 34;
//int64_t xShifted = xMasked << 5;
//app.DebugPrintf("xShifted = %d (0x%016x), zShifted = %I64d (0x%016llx)\n", xShifted, xShifted, zShifted, zShifted);
- int64_t index = ( ((int64_t)(centreZ & 0x1FFFFFFF)) << 34) | ( ((int64_t)(centreX & 0x1FFFFFFF)) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3);
- auto it = m_mappings.find(index);
+ const int64_t index = ( static_cast<int64_t>(centreZ & 0x1FFFFFFF) << 34) | ( static_cast<int64_t>(centreX & 0x1FFFFFFF) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3);
+ const auto it = m_mappings.find(index);
if(it != m_mappings.end())
{
id = it->second;
@@ -138,7 +138,7 @@ bool DirectoryLevelStorage::PlayerMappings::getMapping(int &id, int centreX, int
void DirectoryLevelStorage::PlayerMappings::writeMappings(DataOutputStream *dos)
{
dos->writeInt(m_mappings.size());
- for ( auto& it : m_mappings )
+ for (const auto& it : m_mappings )
{
app.DebugPrintf(" -- %lld (0x%016llx) = %d\n", it.first, it.first, it.second);
dos->writeLong(it.first);
@@ -148,11 +148,11 @@ void DirectoryLevelStorage::PlayerMappings::writeMappings(DataOutputStream *dos)
void DirectoryLevelStorage::PlayerMappings::readMappings(DataInputStream *dis)
{
- int count = dis->readInt();
+ const int count = dis->readInt();
for(unsigned int i = 0; i < count; ++i)
{
int64_t index = dis->readLong();
- int id = dis->readInt();
+ const int id = dis->readInt();
m_mappings[index] = id;
app.DebugPrintf(" -- %lld (0x%016llx) = %d\n", index, index, id);
}
@@ -174,7 +174,7 @@ DirectoryLevelStorage::~DirectoryLevelStorage()
{
delete m_saveFile;
- for( auto& it : m_cachedSaveData )
+ for(const auto& it : m_cachedSaveData )
{
delete it.second;
}
@@ -188,7 +188,7 @@ void DirectoryLevelStorage::initiateSession()
{
// 4J Jev, removed try/catch.
- File dataFile = File( dir, wstring(L"session.lock") );
+ const File dataFile = File( dir, wstring(L"session.lock") );
FileOutputStream fos = FileOutputStream(dataFile);
DataOutputStream dos = DataOutputStream(&fos);
dos.writeLong(sessionId);
@@ -217,15 +217,15 @@ ChunkStorage *DirectoryLevelStorage::createChunkStorage(Dimension *dimension)
{
// 4J Jev, removed try/catch.
- if (dynamic_cast<HellDimension *>(dimension) != NULL)
+ if (dynamic_cast<HellDimension *>(dimension) != nullptr)
{
- File dir2 = File(dir, LevelStorage::NETHER_FOLDER);
+ const File dir2 = File(dir, LevelStorage::NETHER_FOLDER);
//dir2.mkdirs(); // 4J Removed
return new OldChunkStorage(dir2, true);
}
- if (dynamic_cast<TheEndDimension *>(dimension) != NULL)
+ if (dynamic_cast<TheEndDimension *>(dimension) != nullptr)
{
- File dir2 = File(dir, LevelStorage::ENDER_FOLDER);
+ const File dir2 = File(dir, LevelStorage::ENDER_FOLDER);
//dir2.mkdirs(); // 4J Removed
return new OldChunkStorage(dir2, true);
}
@@ -237,7 +237,7 @@ LevelData *DirectoryLevelStorage::prepareLevel()
{
// 4J Stu Added
#ifdef _LARGE_WORLDS
- ConsoleSavePath mapFile = getDataFile(L"largeMapDataMappings");
+ const ConsoleSavePath mapFile = getDataFile(L"largeMapDataMappings");
#else
ConsoleSavePath mapFile = getDataFile(L"mapDataMappings");
#endif
@@ -270,16 +270,16 @@ LevelData *DirectoryLevelStorage::prepareLevel()
else
#endif
{
- getSaveFile()->setFilePointer(fileEntry,0,NULL, FILE_BEGIN);
+ getSaveFile()->setFilePointer(fileEntry,0,nullptr, FILE_BEGIN);
#ifdef _LARGE_WORLDS
- byteArray data(fileEntry->getFileSize());
+ const byteArray data(fileEntry->getFileSize());
getSaveFile()->readFile( fileEntry, data.data, fileEntry->getFileSize(), &NumberOfBytesRead);
assert( NumberOfBytesRead == fileEntry->getFileSize() );
ByteArrayInputStream bais(data);
DataInputStream dis(&bais);
- int count = dis.readInt();
+ const int count = dis.readInt();
app.DebugPrintf("Loading %d mappings\n", count);
for(unsigned int i = 0; i < count; ++i)
{
@@ -332,7 +332,7 @@ LevelData *DirectoryLevelStorage::prepareLevel()
// 4J Jev, removed try/catch
- ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) );
+ const ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) );
if ( m_saveFile->doesFileExist( dataFile ) )
{
@@ -344,7 +344,7 @@ LevelData *DirectoryLevelStorage::prepareLevel()
return ret;
}
- return NULL;
+ return nullptr;
}
void DirectoryLevelStorage::saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players)
@@ -356,7 +356,7 @@ void DirectoryLevelStorage::saveLevelData(LevelData *levelData, vector<shared_pt
CompoundTag *root = new CompoundTag();
root->put(L"Data", dataTag);
- ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) );
+ const ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) );
ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream( m_saveFile, currentFile );
NbtIo::writeCompressed(root, &fos);
@@ -373,7 +373,7 @@ void DirectoryLevelStorage::saveLevelData(LevelData *levelData)
CompoundTag *root = new CompoundTag();
root->put(L"Data", dataTag);
- ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) );
+ const ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) );
ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream( m_saveFile, currentFile );
NbtIo::writeCompressed(root, &fos);
@@ -398,7 +398,7 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
#elif defined(_DURANGO)
ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + player->getXuid().toString() + L".dat" );
#else
- ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( player->getXuid() ) + L".dat" );
+ const ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( player->getXuid() ) + L".dat" );
#endif
// If saves are disabled (e.g. because we are writing the save buffer to disk) then cache this player data
if(StorageManager.GetSaveDisabled())
@@ -406,7 +406,7 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
ByteArrayOutputStream *bos = new ByteArrayOutputStream();
NbtIo::writeCompressed(tag,bos);
- auto it = m_cachedSaveData.find(realFile.getName());
+ const auto it = m_cachedSaveData.find(realFile.getName());
if(it != m_cachedSaveData.end() )
{
delete it->second;
@@ -432,7 +432,7 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
CompoundTag *DirectoryLevelStorage::load(shared_ptr<Player> player)
{
CompoundTag *tag = loadPlayerDataTag( player->getXuid() );
- if (tag != NULL)
+ if (tag != nullptr)
{
player->load(tag);
}
@@ -447,9 +447,9 @@ CompoundTag *DirectoryLevelStorage::loadPlayerDataTag(PlayerUID xuid)
#elif defined(_DURANGO)
ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + xuid.toString() + L".dat" );
#else
- ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( xuid ) + L".dat" );
+ const ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( xuid ) + L".dat" );
#endif
- auto it = m_cachedSaveData.find(realFile.getName());
+ const auto it = m_cachedSaveData.find(realFile.getName());
if(it != m_cachedSaveData.end() )
{
ByteArrayOutputStream *bos = it->second;
@@ -464,7 +464,7 @@ CompoundTag *DirectoryLevelStorage::loadPlayerDataTag(PlayerUID xuid)
ConsoleSaveFileInputStream fis = ConsoleSaveFileInputStream(m_saveFile, realFile);
return NbtIo::readCompressed(&fis);
}
- return NULL;
+ return nullptr;
}
// 4J Added function
@@ -478,19 +478,19 @@ void DirectoryLevelStorage::clearOldPlayerFiles()
vector<FileEntry *> *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() );
#endif
- if( playerFiles != NULL )
+ if( playerFiles != nullptr )
{
#ifndef _FINAL_BUILD
if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_DistributableSave))
{
for(unsigned int i = 0; i < playerFiles->size(); ++i )
{
- FileEntry *file = playerFiles->at(i);
+ const FileEntry *file = playerFiles->at(i);
wstring xuidStr = replaceAll( replaceAll(file->data.filename,playerDir.getName(),L""),L".dat",L"");
#if defined(__PS3__) || defined(__ORBIS__) || defined(_DURANGO)
PlayerUID xuid(xuidStr);
#else
- PlayerUID xuid = _fromString<PlayerUID>(xuidStr);
+ const PlayerUID xuid = _fromString<PlayerUID>(xuidStr);
#endif
deleteMapFilesForPlayer(xuid);
m_saveFile->deleteFile( playerFiles->at(i) );
@@ -504,12 +504,12 @@ void DirectoryLevelStorage::clearOldPlayerFiles()
for(unsigned int i = MAX_PLAYER_DATA_SAVES; i < playerFiles->size(); ++i )
{
- FileEntry *file = playerFiles->at(i);
+ const FileEntry *file = playerFiles->at(i);
wstring xuidStr = replaceAll( replaceAll(file->data.filename,playerDir.getName(),L""),L".dat",L"");
#if defined(__PS3__) || defined(__ORBIS__) || defined(_DURANGO)
PlayerUID xuid(xuidStr);
#else
- PlayerUID xuid = _fromString<PlayerUID>(xuidStr);
+ const PlayerUID xuid = _fromString<PlayerUID>(xuidStr);
#endif
deleteMapFilesForPlayer(xuid);
m_saveFile->deleteFile( playerFiles->at(i) );
@@ -545,7 +545,7 @@ void DirectoryLevelStorage::flushSaveFile(bool autosave)
if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_DistributableSave))
{
// Delete gamerules files if it exists
- ConsoleSavePath gameRulesFiles(GAME_RULE_SAVENAME);
+ const ConsoleSavePath gameRulesFiles(GAME_RULE_SAVENAME);
if(m_saveFile->doesFileExist(gameRulesFiles))
{
FileEntry *fe = m_saveFile->createFile(gameRulesFiles);
@@ -564,7 +564,7 @@ void DirectoryLevelStorage::resetNetherPlayerPositions()
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
vector<FileEntry *> *playerFiles = m_saveFile->getValidPlayerDatFiles();
#else
- vector<FileEntry *> *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() );
+ const vector<FileEntry *> *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() );
#endif
if ( playerFiles )
@@ -573,7 +573,7 @@ void DirectoryLevelStorage::resetNetherPlayerPositions()
{
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 are loaded
@@ -599,7 +599,7 @@ int DirectoryLevelStorage::getAuxValueForMap(PlayerUID xuid, int dimension, int
bool foundMapping = false;
#ifdef _LARGE_WORLDS
- auto it = m_playerMappings.find(xuid);
+ const auto it = m_playerMappings.find(xuid);
if(it != m_playerMappings.end())
{
foundMapping = it->second.getMapping(mapId, centreXC, centreZC, dimension, scale);
@@ -666,7 +666,7 @@ void DirectoryLevelStorage::saveMapIdLookup()
if(StorageManager.GetSaveDisabled() ) return;
#ifdef _LARGE_WORLDS
- ConsoleSavePath file = getDataFile(L"largeMapDataMappings");
+ const ConsoleSavePath file = getDataFile(L"largeMapDataMappings");
#else
ConsoleSavePath file = getDataFile(L"mapDataMappings");
#endif
@@ -675,7 +675,7 @@ void DirectoryLevelStorage::saveMapIdLookup()
{
DWORD NumberOfBytesWritten;
FileEntry *fileEntry = m_saveFile->createFile(file);
- m_saveFile->setFilePointer(fileEntry,0,NULL, FILE_BEGIN);
+ m_saveFile->setFilePointer(fileEntry,0,nullptr, FILE_BEGIN);
#ifdef _LARGE_WORLDS
ByteArrayOutputStream baos;
@@ -712,13 +712,13 @@ void DirectoryLevelStorage::saveMapIdLookup()
void DirectoryLevelStorage::dontSaveMapMappingForPlayer(PlayerUID xuid)
{
#ifdef _LARGE_WORLDS
- auto it = m_playerMappings.find(xuid);
+ const auto it = m_playerMappings.find(xuid);
if(it != m_playerMappings.end())
{
for (auto itMap = it->second.m_mappings.begin(); itMap != it->second.m_mappings.end(); ++itMap)
{
- int index = itMap->second / 8;
- int offset = itMap->second % 8;
+ const int index = itMap->second / 8;
+ const int offset = itMap->second % 8;
m_usedMappings[index] &= ~(1<<offset);
}
m_playerMappings.erase(it);
@@ -736,14 +736,14 @@ void DirectoryLevelStorage::dontSaveMapMappingForPlayer(PlayerUID xuid)
void DirectoryLevelStorage::deleteMapFilesForPlayer(shared_ptr<Player> player)
{
- PlayerUID playerXuid = player->getXuid();
+ const PlayerUID playerXuid = player->getXuid();
if(playerXuid != INVALID_XUID) deleteMapFilesForPlayer(playerXuid);
}
void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid)
{
#ifdef _LARGE_WORLDS
- auto it = m_playerMappings.find(xuid);
+ const auto it = m_playerMappings.find(xuid);
if(it != m_playerMappings.end())
{
for (auto itMap = it->second.m_mappings.begin(); itMap != it->second.m_mappings.end(); ++itMap)
@@ -758,8 +758,8 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid)
else m_saveFile->deleteFile( m_saveFile->createFile(file) );
}
- int index = itMap->second / 8;
- int offset = itMap->second % 8;
+ const int index = itMap->second / 8;
+ const int offset = itMap->second % 8;
m_usedMappings[index] &= ~(1<<offset);
}
m_playerMappings.erase(it);
@@ -807,7 +807,7 @@ void DirectoryLevelStorage::saveAllCachedData()
}
m_cachedSaveData.clear();
- for (auto& it : m_mapFilesToDelete )
+ for (const auto& it : m_mapFilesToDelete )
{
std::wstring id = wstring( L"map_" ) + std::to_wstring(it);
ConsoleSavePath file = getDataFile(id);
diff --git a/Minecraft.World/DirectoryLevelStorageSource.cpp b/Minecraft.World/DirectoryLevelStorageSource.cpp
index e229232b..9176b0d5 100644
--- a/Minecraft.World/DirectoryLevelStorageSource.cpp
+++ b/Minecraft.World/DirectoryLevelStorageSource.cpp
@@ -32,7 +32,7 @@ vector<LevelSummary *> *DirectoryLevelStorageSource::getLevelList()
wstring levelId = wstring(L"World").append( std::to_wstring( (i+1) ) );
LevelData *levelData = getDataTagFor(saveFile, levelId);
- if (levelData != NULL)
+ if (levelData != nullptr)
{
levels->push_back(new LevelSummary(levelId, L"", levelData->getLastPlayed(), levelData->getSizeOnDisk(), levelData.getGameType(), false, levelData->isHardcore()));
}
@@ -59,7 +59,7 @@ LevelData *DirectoryLevelStorageSource::getDataTagFor(ConsoleSaveFile *saveFile,
return ret;
}
- return NULL;
+ return nullptr;
}
void DirectoryLevelStorageSource::renameLevel(const wstring& levelId, const wstring& newLevelName)
@@ -121,7 +121,7 @@ void DirectoryLevelStorageSource::deleteRecursive(vector<File *> *files)
shared_ptr<LevelStorage> DirectoryLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir)
{
- return shared_ptr<LevelStorage> (new DirectoryLevelStorage(saveFile, baseDir, levelId, createPlayerDir));
+ return std::make_shared<DirectoryLevelStorage>(saveFile, baseDir, levelId, createPlayerDir);
}
bool DirectoryLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId)
diff --git a/Minecraft.World/DisconnectPacket.cpp b/Minecraft.World/DisconnectPacket.cpp
index da20686a..0b6f6bf8 100644
--- a/Minecraft.World/DisconnectPacket.cpp
+++ b/Minecraft.World/DisconnectPacket.cpp
@@ -19,7 +19,7 @@ DisconnectPacket::DisconnectPacket(eDisconnectReason reason)
void DisconnectPacket::read(DataInputStream *dis) //throws IOException
{
- reason = (eDisconnectReason)dis->readInt();
+ reason = static_cast<eDisconnectReason>(dis->readInt());
}
void DisconnectPacket::write(DataOutputStream *dos) //throws IOException
diff --git a/Minecraft.World/DisconnectPacket.h b/Minecraft.World/DisconnectPacket.h
index 34983754..3c96a429 100644
--- a/Minecraft.World/DisconnectPacket.h
+++ b/Minecraft.World/DisconnectPacket.h
@@ -66,7 +66,7 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new DisconnectPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<DisconnectPacket>(); }
virtual int getId() { return 255; }
};
diff --git a/Minecraft.World/DispenserTile.cpp b/Minecraft.World/DispenserTile.cpp
index 8758b3c5..5098fe30 100644
--- a/Minecraft.World/DispenserTile.cpp
+++ b/Minecraft.World/DispenserTile.cpp
@@ -18,9 +18,9 @@ DispenserTile::DispenserTile(int id) : BaseEntityTile(id, Material::stone)
{
random = new Random();
- iconTop = NULL;
- iconFront = NULL;
- iconFrontVertical = NULL;
+ iconTop = nullptr;
+ iconFront = nullptr;
+ iconFrontVertical = nullptr;
}
int DispenserTile::getTickDelay(Level *level)
@@ -115,7 +115,7 @@ void DispenserTile::dispenseFrom(Level *level, int x, int y, int z)
{
BlockSourceImpl source(level, x, y, z);
shared_ptr<DispenserTileEntity> trap = dynamic_pointer_cast<DispenserTileEntity>( source.getEntity() );
- if (trap == NULL) return;
+ if (trap == nullptr) return;
int slot = trap->getRandomSlot();
if (slot < 0)
@@ -168,7 +168,7 @@ void DispenserTile::tick(Level *level, int x, int y, int z, Random *random)
shared_ptr<TileEntity> DispenserTile::newTileEntity(Level *level)
{
- return shared_ptr<DispenserTileEntity>( new DispenserTileEntity() );
+ return std::make_shared<DispenserTileEntity>();
}
void DispenserTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance)
@@ -186,12 +186,12 @@ void DispenserTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<Li
void DispenserTile::onRemove(Level *level, int x, int y, int z, int id, int data)
{
shared_ptr<Container> container = dynamic_pointer_cast<DispenserTileEntity>( level->getTileEntity(x, y, z) );
- if (container != NULL )
+ if (container != nullptr )
{
for (unsigned int i = 0; i < container->getContainerSize(); i++)
{
shared_ptr<ItemInstance> 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;
@@ -203,16 +203,16 @@ void DispenserTile::onRemove(Level *level, int x, int y, int z, int id, int data
if (count > item->count) count = item->count;
item->count -= count;
- shared_ptr<ItemInstance> newItem = shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue()) );
+ shared_ptr<ItemInstance> newItem = std::make_shared<ItemInstance>(item->id, count, item->getAuxValue());
newItem->set4JData( item->get4JData() );
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, newItem ) );
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, newItem);
float pow = 0.05f;
- itemEntity->xd = (float) random->nextGaussian() * pow;
- itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f;
- itemEntity->zd = (float) random->nextGaussian() * pow;
+ itemEntity->xd = static_cast<float>(random->nextGaussian()) * pow;
+ itemEntity->yd = static_cast<float>(random->nextGaussian()) * pow + 0.2f;
+ itemEntity->zd = static_cast<float>(random->nextGaussian()) * pow;
if (item->hasTag())
{
- itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy());
+ itemEntity->getItem()->setTag(static_cast<CompoundTag *>(item->getTag()->copy()));
}
level->addEntity(itemEntity);
}
diff --git a/Minecraft.World/DispenserTileEntity.cpp b/Minecraft.World/DispenserTileEntity.cpp
index 3e743e22..b1d8ecde 100644
--- a/Minecraft.World/DispenserTileEntity.cpp
+++ b/Minecraft.World/DispenserTileEntity.cpp
@@ -35,7 +35,7 @@ shared_ptr<ItemInstance> DispenserTileEntity::getItem(unsigned int slot)
shared_ptr<ItemInstance> DispenserTileEntity::removeItem(unsigned int slot, int count)
{
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
if (items[slot]->count <= count)
{
@@ -61,7 +61,7 @@ shared_ptr<ItemInstance> DispenserTileEntity::removeItem(unsigned int slot, int
shared_ptr<ItemInstance> DispenserTileEntity::removeItemNoUpdate(int slot)
{
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
shared_ptr<ItemInstance> item = items[slot];
items[slot] = nullptr;
@@ -73,7 +73,7 @@ shared_ptr<ItemInstance> DispenserTileEntity::removeItemNoUpdate(int slot)
// 4J-PB added for spawn eggs not being useable due to limits, so add them in again
void DispenserTileEntity::AddItemBack(shared_ptr<ItemInstance>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)
@@ -85,7 +85,7 @@ void DispenserTileEntity::AddItemBack(shared_ptr<ItemInstance>item, unsigned int
else
{
items[slot] = item;
- if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize();
+ if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize();
setChanged();
}
}
@@ -99,10 +99,10 @@ bool DispenserTileEntity::removeProjectile(int itemId)
{
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL && items[i]->id == itemId)
+ if (items[i] != nullptr && items[i]->id == itemId)
{
shared_ptr<ItemInstance> removedItem = removeItem(i, 1);
- return removedItem != NULL;
+ return removedItem != nullptr;
}
}
return false;
@@ -114,7 +114,7 @@ int DispenserTileEntity::getRandomSlot()
int replaceOdds = 1;
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL && random->nextInt(replaceOdds++) == 0)
+ if (items[i] != nullptr && random->nextInt(replaceOdds++) == 0)
{
replaceSlot = i;
}
@@ -126,7 +126,7 @@ int DispenserTileEntity::getRandomSlot()
void DispenserTileEntity::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
items[slot] = item;
- if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize();
+ if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize();
setChanged();
}
@@ -134,7 +134,7 @@ int DispenserTileEntity::addItem(shared_ptr<ItemInstance> item)
{
for (int i = 0; i < items.length; i++)
{
- if (items[i] == NULL || items[i]->id == 0)
+ if (items[i] == nullptr || items[i]->id == 0)
{
setItem(i, item);
return i;
@@ -186,10 +186,10 @@ void DispenserTileEntity::save(CompoundTag *base)
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL)
+ if (items[i] != nullptr)
{
CompoundTag *tag = new CompoundTag();
- tag->putByte(L"Slot", (byte) i);
+ tag->putByte(L"Slot", static_cast<byte>(i));
items[i]->save(tag);
listTag->add(tag);
}
@@ -231,12 +231,12 @@ bool DispenserTileEntity::canPlaceItem(int slot, shared_ptr<ItemInstance> item)
// 4J Added
shared_ptr<TileEntity> DispenserTileEntity::clone()
{
- shared_ptr<DispenserTileEntity> result = shared_ptr<DispenserTileEntity>( new DispenserTileEntity() );
+ shared_ptr<DispenserTileEntity> result = std::make_shared<DispenserTileEntity>();
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/DoorInfo.cpp b/Minecraft.World/DoorInfo.cpp
index 0c61b635..177b8885 100644
--- a/Minecraft.World/DoorInfo.cpp
+++ b/Minecraft.World/DoorInfo.cpp
@@ -12,7 +12,7 @@ DoorInfo::DoorInfo(int x, int y, int z, int insideDx, int insideDy, int timeStam
int DoorInfo::distanceTo(int x2, int y2, int z2)
{
- return (int) sqrt((float)distanceToSqr(x2, y2, z2));
+ return static_cast<int>(sqrt((float)distanceToSqr(x2, y2, z2)));
}
int DoorInfo::distanceToSqr(int x2, int y2, int z2)
diff --git a/Minecraft.World/DoorInteractGoal.cpp b/Minecraft.World/DoorInteractGoal.cpp
index 1e3bfe11..45805744 100644
--- a/Minecraft.World/DoorInteractGoal.cpp
+++ b/Minecraft.World/DoorInteractGoal.cpp
@@ -9,7 +9,7 @@
DoorInteractGoal::DoorInteractGoal(Mob *mob)
{
doorX = doorY = doorZ = 0;
- doorTile = NULL;
+ doorTile = nullptr;
passed = false;
doorOpenDirX = doorOpenDirZ = 0.0f;
@@ -21,7 +21,7 @@ bool DoorInteractGoal::canUse()
if (!mob->horizontalCollision) return false;
PathNavigation *pathNav = mob->getNavigation();
Path *path = pathNav->getPath();
- if (path == NULL || path->isDone() || !pathNav->canOpenDoors()) return false;
+ if (path == nullptr || path->isDone() || !pathNav->canOpenDoors()) return false;
for (int i = 0; i < min(path->getIndex() + 2, path->getSize()); ++i)
{
@@ -31,7 +31,7 @@ bool DoorInteractGoal::canUse()
doorZ = n->z;
if (mob->distanceToSqr(doorX, mob->y, doorZ) > 1.5 * 1.5) continue;
doorTile = getDoorTile(doorX, doorY, doorZ);
- if (doorTile == NULL) continue;
+ if (doorTile == nullptr) continue;
return true;
}
@@ -39,7 +39,7 @@ bool DoorInteractGoal::canUse()
doorY = Mth::floor(mob->y + 1);
doorZ = Mth::floor(mob->z);
doorTile = getDoorTile(doorX, doorY, doorZ);
- return doorTile != NULL;
+ return doorTile != nullptr;
}
bool DoorInteractGoal::canContinueToUse()
@@ -50,14 +50,14 @@ bool DoorInteractGoal::canContinueToUse()
void DoorInteractGoal::start()
{
passed = false;
- doorOpenDirX = (float) (doorX + 0.5f - mob->x);
- doorOpenDirZ = (float) (doorZ + 0.5f - mob->z);
+ doorOpenDirX = static_cast<float>(doorX + 0.5f - mob->x);
+ doorOpenDirZ = static_cast<float>(doorZ + 0.5f - mob->z);
}
void DoorInteractGoal::tick()
{
- float newDoorDirX = (float) (doorX + 0.5f - mob->x);
- float newDoorDirZ = (float) (doorZ + 0.5f - mob->z);
+ float newDoorDirX = static_cast<float>(doorX + 0.5f - mob->x);
+ float newDoorDirZ = static_cast<float>(doorZ + 0.5f - mob->z);
float dot = doorOpenDirX * newDoorDirX + doorOpenDirZ * newDoorDirZ;
if (dot < 0)
{
@@ -68,6 +68,6 @@ void DoorInteractGoal::tick()
DoorTile *DoorInteractGoal::getDoorTile(int x, int y, int z)
{
int tileId = mob->level->getTile(x, y, z);
- if (tileId != Tile::door_wood_Id) return NULL;
- return (DoorTile *) Tile::tiles[tileId];
+ if (tileId != Tile::door_wood_Id) return nullptr;
+ return static_cast<DoorTile *>(Tile::tiles[tileId]);
} \ No newline at end of file
diff --git a/Minecraft.World/DoubleTag.h b/Minecraft.World/DoubleTag.h
index 1f768d5b..60e5808a 100644
--- a/Minecraft.World/DoubleTag.h
+++ b/Minecraft.World/DoubleTag.h
@@ -29,7 +29,7 @@ public:
{
if (Tag::equals(obj))
{
- DoubleTag *o = (DoubleTag *) obj;
+ DoubleTag *o = static_cast<DoubleTag *>(obj);
return data == o->data;
}
return false;
diff --git a/Minecraft.World/DragonFireball.cpp b/Minecraft.World/DragonFireball.cpp
index 335b345f..348bc53e 100644
--- a/Minecraft.World/DragonFireball.cpp
+++ b/Minecraft.World/DragonFireball.cpp
@@ -54,7 +54,7 @@ void DragonFireball::onHit(HitResult *res)
}
delete entitiesOfClass;
}
- level->levelEvent(LevelEvent::ENDERDRAGON_FIREBALL_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), 0);
+ level->levelEvent(LevelEvent::ENDERDRAGON_FIREBALL_SPLASH, static_cast<int>(Math::round(x)), static_cast<int>(Math::round(y)), static_cast<int>(Math::round(z)), 0);
remove();
}
diff --git a/Minecraft.World/DropperTile.cpp b/Minecraft.World/DropperTile.cpp
index a28228c9..180aec2a 100644
--- a/Minecraft.World/DropperTile.cpp
+++ b/Minecraft.World/DropperTile.cpp
@@ -27,14 +27,14 @@ DispenseItemBehavior *DropperTile::getDispenseMethod(shared_ptr<ItemInstance> it
shared_ptr<TileEntity> DropperTile::newTileEntity(Level *level)
{
- return shared_ptr<DropperTileEntity>( new DropperTileEntity() );
+ return std::make_shared<DropperTileEntity>();
}
void DropperTile::dispenseFrom(Level *level, int x, int y, int z)
{
BlockSourceImpl source(level, x, y, z);
shared_ptr<DispenserTileEntity> trap = dynamic_pointer_cast<DispenserTileEntity>( source.getEntity() );
- if (trap == NULL) return;
+ if (trap == nullptr) return;
int slot = trap->getRandomSlot();
if (slot < 0)
@@ -48,11 +48,11 @@ void DropperTile::dispenseFrom(Level *level, int x, int y, int z)
shared_ptr<Container> into = HopperTileEntity::getContainerAt(level, x + Facing::STEP_X[face], y + Facing::STEP_Y[face], z + Facing::STEP_Z[face]);
shared_ptr<ItemInstance> remaining = nullptr;
- if (into != NULL)
+ if (into != nullptr)
{
remaining = HopperTileEntity::addItem(into.get(), item->copy()->remove(1), Facing::OPPOSITE_FACING[face]);
- if (remaining == NULL)
+ if (remaining == nullptr)
{
remaining = item->copy();
if (--remaining->count == 0) remaining = nullptr;
@@ -66,7 +66,7 @@ void DropperTile::dispenseFrom(Level *level, int x, int y, int z)
else
{
remaining = DISPENSE_BEHAVIOUR->dispense(&source, item);
- if (remaining != NULL && remaining->count == 0) remaining = nullptr;
+ if (remaining != nullptr && remaining->count == 0) remaining = nullptr;
}
trap->setItem(slot, remaining);
diff --git a/Minecraft.World/DropperTileEntity.cpp b/Minecraft.World/DropperTileEntity.cpp
index 51bf6abf..ad2a0e83 100644
--- a/Minecraft.World/DropperTileEntity.cpp
+++ b/Minecraft.World/DropperTileEntity.cpp
@@ -10,7 +10,7 @@ wstring DropperTileEntity::getName()
// 4J Added
shared_ptr<TileEntity> DropperTileEntity::clone()
{
- shared_ptr<DropperTileEntity> result = shared_ptr<DropperTileEntity>( new DropperTileEntity() );
+ shared_ptr<DropperTileEntity> result = std::make_shared<DropperTileEntity>();
TileEntity::clone(result);
result->name = name;
diff --git a/Minecraft.World/DungeonFeature.cpp b/Minecraft.World/DungeonFeature.cpp
index 6c7dc673..8c9abbe5 100644
--- a/Minecraft.World/DungeonFeature.cpp
+++ b/Minecraft.World/DungeonFeature.cpp
@@ -142,12 +142,12 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, byteArray blocks, double xC
{
if (yy < 10)
{
- blocks[p] = (byte) Tile::lava_Id;
+ blocks[p] = static_cast<byte>(Tile::lava_Id);
}
else
{
- blocks[p] = (byte) 0;
- if (hasGrass && blocks[p - 1] == Tile::dirt_Id) blocks[p - 1] = (byte) Tile::grass_Id;
+ blocks[p] = static_cast<byte>(0);
+ if (hasGrass && blocks[p - 1] == Tile::dirt_Id) blocks[p - 1] = static_cast<byte>(Tile::grass_Id);
}
}
}
diff --git a/Minecraft.World/DurangoStats.cpp b/Minecraft.World/DurangoStats.cpp
index 6e50fd20..7302d9ed 100644
--- a/Minecraft.World/DurangoStats.cpp
+++ b/Minecraft.World/DurangoStats.cpp
@@ -267,11 +267,11 @@ byteArray DsMobKilled::createParamBlob(shared_ptr<Player> player, shared_ptr<Mob
// 4J-JEV: Get the id we use for Durango Server Stats.
int mob_networking_id;
eINSTANCEOF mobEType = mob->GetType();
- if ( (mobEType == eTYPE_SPIDER) && (mob->rider.lock() != NULL) && (mob->rider.lock()->GetType() == eTYPE_SKELETON) && mob->rider.lock()->isAlive() )
+ if ( (mobEType == eTYPE_SPIDER) && (mob->rider.lock() != nullptr) && (mob->rider.lock()->GetType() == eTYPE_SKELETON) && mob->rider.lock()->isAlive() )
{
mob_networking_id = SPIDER_JOCKEY_ID; // Spider jockey only a concept for leaderboards.
}
- else if ( (mobEType == eTYPE_SKELETON) && (mob->riding != NULL) && (mob->riding->GetType() == eTYPE_SPIDER) && mob->riding->isAlive() )
+ else if ( (mobEType == eTYPE_SKELETON) && (mob->riding != nullptr) && (mob->riding->GetType() == eTYPE_SPIDER) && mob->riding->isAlive() )
{
mob_networking_id = SPIDER_JOCKEY_ID; // Spider jockey only a concept for leaderboards.
}
@@ -303,7 +303,7 @@ byteArray DsMobKilled::createParamBlob(shared_ptr<Player> player, shared_ptr<Mob
Param param = {
DsMobKilled::MELEE,
mob_networking_id,
- (item != NULL ? item->getItem()->id : 0),
+ (item != nullptr ? item->getItem()->id : 0),
mob->distanceTo(player->x, player->y, player->z),
0/*not needed*/
};
@@ -345,7 +345,7 @@ void DsMobInteract::handleParamBlob(shared_ptr<LocalPlayer> player, byteArray pa
byteArray DsMobInteract::createParamBlob(eInteract interactionId, int entityId)
{
byteArray output;
- Param param = { interactionId, EntityIO::eTypeToIoid((eINSTANCEOF)entityId) };
+ Param param = { interactionId, EntityIO::eTypeToIoid(static_cast<eINSTANCEOF>(entityId)) };
output.data = (byte*) new Param(param);
output.length = sizeof(Param);
return output;
@@ -423,7 +423,7 @@ void DsTravel::flush(shared_ptr<LocalPlayer> player)
{
if (param_cache[iPad][i] > 0)
{
- write( player, (eMethod) i, param_cache[iPad][i] );
+ write( player, static_cast<eMethod>(i), param_cache[iPad][i] );
param_cache[iPad][i] = 0;
}
}
@@ -729,7 +729,7 @@ Stat *DurangoStats::get_stat(int i)
default: assert(false); break;
}
- return NULL;
+ return nullptr;
}
Stat* DurangoStats::get_walkOneM()
@@ -833,7 +833,7 @@ Stat* DurangoStats::get_itemsCrafted(int itemId)
case Item::diamond_Id:
case Item::redStone_Id:
case Item::emerald_Id:
- return NULL;
+ return nullptr;
case Item::dye_powder_Id:
default:
@@ -890,7 +890,7 @@ Stat* DurangoStats::get_achievement(eAward achievementId)
}
// Other achievements awarded through more detailed generic events.
- return NULL;
+ return nullptr;
}
byteArray DurangoStats::getParam_walkOneM(int distance)
@@ -1093,25 +1093,25 @@ bool DurangoStats::enhancedAchievement(eAward achievementId)
void DurangoStats::generatePlayerSession()
{
- DurangoStats *dsInstance = (DurangoStats *) GenericStats::getInstance();
+ DurangoStats *dsInstance = static_cast<DurangoStats *>(GenericStats::getInstance());
CoCreateGuid( &dsInstance->playerSessionId );
}
LPCGUID DurangoStats::getPlayerSession()
{
- DurangoStats *dsInstance = (DurangoStats *) GenericStats::getInstance();
+ DurangoStats *dsInstance = static_cast<DurangoStats *>(GenericStats::getInstance());
LPCGUID lpcguid = &dsInstance->playerSessionId;
return lpcguid;
}
void DurangoStats::setMultiplayerCorrelationId(Platform::String^ mcpId)
{
- ((DurangoStats*)GenericStats::getInstance())->multiplayerCorrelationId = mcpId;
+ static_cast<DurangoStats *>(GenericStats::getInstance())->multiplayerCorrelationId = mcpId;
}
LPCWSTR DurangoStats::getMultiplayerCorrelationId()
{
- return ((DurangoStats*)GenericStats::getInstance())->multiplayerCorrelationId->Data();
+ return static_cast<DurangoStats *>(GenericStats::getInstance())->multiplayerCorrelationId->Data();
}
LPCWSTR DurangoStats::getUserId(shared_ptr<LocalPlayer> player)
@@ -1130,7 +1130,7 @@ LPCWSTR DurangoStats::getUserId(int iPad)
void DurangoStats::playerSessionStart(PlayerUID uid, shared_ptr<Player> plr)
{
- if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL)
+ if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr)
{
//wprintf(uid.toString().c_str());
@@ -1164,7 +1164,7 @@ void DurangoStats::playerSessionStart(int iPad)
void DurangoStats::playerSessionPause(int iPad)
{
shared_ptr<MultiplayerLocalPlayer> plr = Minecraft::GetInstance()->localplayers[iPad];
- if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL)
+ if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr)
{
PlayerUID puid;
ProfileManager.GetXUID(iPad, &puid, true);
@@ -1187,7 +1187,7 @@ void DurangoStats::playerSessionPause(int iPad)
void DurangoStats::playerSessionResume(int iPad)
{
shared_ptr<MultiplayerLocalPlayer> plr = Minecraft::GetInstance()->localplayers[iPad];
- if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL)
+ if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr)
{
PlayerUID puid;
ProfileManager.GetXUID(iPad, &puid, true);
@@ -1214,7 +1214,7 @@ void DurangoStats::playerSessionResume(int iPad)
void DurangoStats::playerSessionEnd(int iPad)
{
shared_ptr<MultiplayerLocalPlayer> plr = Minecraft::GetInstance()->localplayers[iPad];
- if (plr != NULL)
+ if (plr != nullptr)
{
DurangoStats::getInstance()->travel->flush(plr);
}
diff --git a/Minecraft.World/DurangoStats.h b/Minecraft.World/DurangoStats.h
index 1b2f7723..b2f24643 100644
--- a/Minecraft.World/DurangoStats.h
+++ b/Minecraft.World/DurangoStats.h
@@ -165,7 +165,7 @@ public:
class DurangoStats : public GenericStats
{
public:
- static DurangoStats *getInstance() { return (DurangoStats*) GenericStats::getInstance(); }
+ static DurangoStats *getInstance() { return static_cast<DurangoStats *>(GenericStats::getInstance()); }
protected:
enum {
diff --git a/Minecraft.World/DyePowderItem.cpp b/Minecraft.World/DyePowderItem.cpp
index b4ab86fa..3392da98 100644
--- a/Minecraft.World/DyePowderItem.cpp
+++ b/Minecraft.World/DyePowderItem.cpp
@@ -18,7 +18,7 @@ DyePowderItem::DyePowderItem(int id) : Item( id )
{
setStackedByData(true);
setMaxDamage(0);
- icons = NULL;
+ icons = nullptr;
}
const unsigned int DyePowderItem::COLOR_DESCS[] =
@@ -177,7 +177,7 @@ bool DyePowderItem::growCrop(shared_ptr<ItemInstance> itemInstance, Level *level
{
if (!level->isClientSide)
{
- if (level->random->nextFloat() < 0.45) ((Sapling *) Tile::sapling)->advanceTree(level, x, y, z, level->random);
+ if (level->random->nextFloat() < 0.45) static_cast<Sapling *>(Tile::sapling)->advanceTree(level, x, y, z, level->random);
itemInstance->count--;
}
}
@@ -189,7 +189,7 @@ bool DyePowderItem::growCrop(shared_ptr<ItemInstance> itemInstance, Level *level
{
if (!level->isClientSide)
{
- if (level->random->nextFloat() < 0.4) ((Mushroom *) Tile::tiles[tile])->growTree(level, x, y, z, level->random);
+ if (level->random->nextFloat() < 0.4) static_cast<Mushroom *>(Tile::tiles[tile])->growTree(level, x, y, z, level->random);
itemInstance->count--;
}
}
@@ -202,7 +202,7 @@ bool DyePowderItem::growCrop(shared_ptr<ItemInstance> itemInstance, Level *level
{
if (!level->isClientSide)
{
- ((StemTile *) Tile::tiles[tile])->growCrops(level, x, y, z);
+ static_cast<StemTile *>(Tile::tiles[tile])->growCrops(level, x, y, z);
itemInstance->count--;
}
}
@@ -215,7 +215,7 @@ bool DyePowderItem::growCrop(shared_ptr<ItemInstance> itemInstance, Level *level
{
if (!level->isClientSide)
{
- ((CropTile *) Tile::tiles[tile])->growCrops(level, x, y, z);
+ static_cast<CropTile *>(Tile::tiles[tile])->growCrops(level, x, y, z);
itemInstance->count--;
}
}
@@ -228,7 +228,7 @@ bool DyePowderItem::growCrop(shared_ptr<ItemInstance> itemInstance, Level *level
{
if (!level->isClientSide)
{
- ((CropTile *) Tile::tiles[tile])->growCrops(level, x, y, z);
+ static_cast<CropTile *>(Tile::tiles[tile])->growCrops(level, x, y, z);
itemInstance->count--;
}
}
@@ -306,9 +306,9 @@ void DyePowderItem::addGrowthParticles(Level *level, int x, int y, int z, int co
{
int id = level->getTile(x, y, z);
if (count == 0) count = 15;
- Tile *tile = id > 0 && id < Tile::TILE_NUM_COUNT ? Tile::tiles[id] : NULL;
+ Tile *tile = id > 0 && id < Tile::TILE_NUM_COUNT ? Tile::tiles[id] : nullptr;
- if (tile == NULL) return;
+ if (tile == nullptr) return;
tile->updateShape(level, x, y, z);
for (int i = 0; i < count; i++)
@@ -322,7 +322,7 @@ void DyePowderItem::addGrowthParticles(Level *level, int x, int y, int z, int co
bool DyePowderItem::interactEnemy(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, shared_ptr<LivingEntity> mob)
{
- if (dynamic_pointer_cast<Sheep>( mob ) != NULL)
+ if (dynamic_pointer_cast<Sheep>( mob ) != nullptr)
{
shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(mob);
// convert to tile-based color value (0 is white instead of black)
diff --git a/Minecraft.World/EggItem.cpp b/Minecraft.World/EggItem.cpp
index 0655a2fa..3f3d123e 100644
--- a/Minecraft.World/EggItem.cpp
+++ b/Minecraft.World/EggItem.cpp
@@ -26,6 +26,6 @@ shared_ptr<ItemInstance> EggItem::use(shared_ptr<ItemInstance> instance, Level *
instance->count--;
}
level->playEntitySound( player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f));
- if (!level->isClientSide) level->addEntity( shared_ptr<ThrownEgg>(new ThrownEgg(level, player)) );
+ if (!level->isClientSide) level->addEntity(std::make_shared<ThrownEgg>(level, player));
return instance;
}
diff --git a/Minecraft.World/EggTile.cpp b/Minecraft.World/EggTile.cpp
index 3a11c0d1..7052fac9 100644
--- a/Minecraft.World/EggTile.cpp
+++ b/Minecraft.World/EggTile.cpp
@@ -40,7 +40,7 @@ void EggTile::checkSlide(Level *level, int x, int y, int z)
}
else
{
- shared_ptr<FallingTile> e = shared_ptr<FallingTile>(new FallingTile(level, x + 0.5f, y + 0.5f, z + 0.5f, id));
+ shared_ptr<FallingTile> e = std::make_shared<FallingTile>(level, x + 0.5f, y + 0.5f, z + 0.5f, id);
level->addEntity(e);
}
}
diff --git a/Minecraft.World/EmptyMapItem.cpp b/Minecraft.World/EmptyMapItem.cpp
index 42adc304..9c46938a 100644
--- a/Minecraft.World/EmptyMapItem.cpp
+++ b/Minecraft.World/EmptyMapItem.cpp
@@ -23,7 +23,7 @@ shared_ptr<ItemInstance> EmptyMapItem::use(shared_ptr<ItemInstance> itemInstance
//data.setDirty();
- shared_ptr<ItemInstance> map = shared_ptr<ItemInstance>( new ItemInstance(Item::map, 1, -1) );
+ shared_ptr<ItemInstance> map = std::make_shared<ItemInstance>(Item::map, 1, -1);
Item::map->onCraftedBy(map, level, player);
itemInstance->count--;
diff --git a/Minecraft.World/EnchantItemCommand.cpp b/Minecraft.World/EnchantItemCommand.cpp
index 7ec57563..c8411709 100644
--- a/Minecraft.World/EnchantItemCommand.cpp
+++ b/Minecraft.World/EnchantItemCommand.cpp
@@ -28,15 +28,15 @@ void EnchantItemCommand::execute(shared_ptr<CommandSender> source, byteArray com
shared_ptr<ServerPlayer> player = getPlayer(uid);
- if(player == NULL) return;
+ if(player == nullptr) return;
shared_ptr<ItemInstance> selectedItem = player->getSelectedItem();
- if(selectedItem == NULL) return;
+ if(selectedItem == nullptr) return;
Enchantment *e = Enchantment::enchantments[enchantmentId];
- if(e == NULL) return;
+ if(e == nullptr) return;
if(!e->canEnchant(selectedItem)) return;
if(enchantmentLevel < e->getMinLevel()) enchantmentLevel = e->getMinLevel();
@@ -45,13 +45,13 @@ void EnchantItemCommand::execute(shared_ptr<CommandSender> source, byteArray com
if (selectedItem->hasTag())
{
ListTag<CompoundTag> *enchantmentTags = selectedItem->getEnchantmentTags();
- if (enchantmentTags != NULL)
+ if (enchantmentTags != nullptr)
{
for (int i = 0; i < enchantmentTags->size(); i++)
{
int type = enchantmentTags->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_ID);
- if (Enchantment::enchantments[type] != NULL)
+ if (Enchantment::enchantments[type] != nullptr)
{
Enchantment *other = Enchantment::enchantments[type];
if (!other->isCompatibleWith(e))
@@ -72,7 +72,7 @@ void EnchantItemCommand::execute(shared_ptr<CommandSender> source, byteArray com
shared_ptr<GameCommandPacket> EnchantItemCommand::preparePacket(shared_ptr<Player> player, int enchantmentId, int enchantmentLevel)
{
- if(player == NULL) return nullptr;
+ if(player == nullptr) return nullptr;
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
@@ -81,5 +81,5 @@ shared_ptr<GameCommandPacket> EnchantItemCommand::preparePacket(shared_ptr<Playe
dos.writeInt(enchantmentId);
dos.writeInt(enchantmentLevel);
- return shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_EnchantItem, baos.toByteArray() ));
+ return std::make_shared<GameCommandPacket>(eGameCommand_EnchantItem, baos.toByteArray());
} \ No newline at end of file
diff --git a/Minecraft.World/EnchantedBookItem.cpp b/Minecraft.World/EnchantedBookItem.cpp
index 88776c18..70b15be4 100644
--- a/Minecraft.World/EnchantedBookItem.cpp
+++ b/Minecraft.World/EnchantedBookItem.cpp
@@ -35,12 +35,12 @@ const Rarity *EnchantedBookItem::getRarity(shared_ptr<ItemInstance> itemInstance
ListTag<CompoundTag> *EnchantedBookItem::getEnchantments(shared_ptr<ItemInstance> item)
{
- if (item->tag == NULL || !item->tag->contains((wchar_t *)TAG_STORED_ENCHANTMENTS.c_str()))
+ if (item->tag == nullptr || !item->tag->contains((wchar_t *)TAG_STORED_ENCHANTMENTS.c_str()))
{
return new ListTag<CompoundTag>();
}
- return (ListTag<CompoundTag> *) item->tag->get((wchar_t *)TAG_STORED_ENCHANTMENTS.c_str());
+ return static_cast<ListTag<CompoundTag> *>(item->tag->get((wchar_t *)TAG_STORED_ENCHANTMENTS.c_str()));
}
void EnchantedBookItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, vector<HtmlString> *lines, bool advanced)
@@ -49,7 +49,7 @@ void EnchantedBookItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, s
ListTag<CompoundTag> *list = getEnchantments(itemInstance);
- if (list != NULL)
+ if (list != nullptr)
{
wstring unformatted = L"";
for (int i = 0; i < list->size(); i++)
@@ -57,7 +57,7 @@ void EnchantedBookItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, s
int type = list->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_ID);
int level = list->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL);
- if (Enchantment::enchantments[type] != NULL)
+ if (Enchantment::enchantments[type] != nullptr)
{
lines->push_back(Enchantment::enchantments[type]->getFullname(level));
}
@@ -78,7 +78,7 @@ void EnchantedBookItem::addEnchantment(shared_ptr<ItemInstance> item, Enchantmen
{
if (tag->getShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL) < enchantment->level)
{
- tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, (short) enchantment->level);
+ tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, static_cast<short>(enchantment->level));
}
add = false;
@@ -90,8 +90,8 @@ void EnchantedBookItem::addEnchantment(shared_ptr<ItemInstance> item, Enchantmen
{
CompoundTag *tag = new CompoundTag();
- tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_ID, (short) enchantment->enchantment->id);
- tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, (short) enchantment->level);
+ tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_ID, static_cast<short>(enchantment->enchantment->id));
+ tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, static_cast<short>(enchantment->level));
enchantments->add(tag);
}
@@ -102,7 +102,7 @@ void EnchantedBookItem::addEnchantment(shared_ptr<ItemInstance> item, Enchantmen
shared_ptr<ItemInstance> EnchantedBookItem::createForEnchantment(EnchantmentInstance *enchant)
{
- shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>(new ItemInstance(this));
+ shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(this);
addEnchantment(item, enchant);
return item;
}
@@ -118,7 +118,7 @@ void EnchantedBookItem::createForEnchantment(Enchantment *enchant, vector<shared
shared_ptr<ItemInstance> EnchantedBookItem::createForRandomLoot(Random *random)
{
Enchantment *enchantment = Enchantment::validEnchantments[random->nextInt(Enchantment::validEnchantments.size())];
- shared_ptr<ItemInstance> book = shared_ptr<ItemInstance>(new ItemInstance(id, 1, 0));
+ shared_ptr<ItemInstance> book = std::make_shared<ItemInstance>(id, 1, 0);
int level = Mth::nextInt(random, enchantment->getMinLevel(), enchantment->getMaxLevel());
addEnchantment(book, new EnchantmentInstance(enchantment, level));
@@ -134,7 +134,7 @@ WeighedTreasure *EnchantedBookItem::createForRandomTreasure(Random *random)
WeighedTreasure *EnchantedBookItem::createForRandomTreasure(Random *random, int minCount, int maxCount, int weight)
{
Enchantment *enchantment = Enchantment::validEnchantments[random->nextInt(Enchantment::validEnchantments.size())];
- shared_ptr<ItemInstance> book = shared_ptr<ItemInstance>(new ItemInstance(id, 1, 0));
+ shared_ptr<ItemInstance> book = std::make_shared<ItemInstance>(id, 1, 0);
int level = Mth::nextInt(random, enchantment->getMinLevel(), enchantment->getMaxLevel());
addEnchantment(book, new EnchantmentInstance(enchantment, level));
diff --git a/Minecraft.World/Enchantment.cpp b/Minecraft.World/Enchantment.cpp
index ae638b27..c2f981a6 100644
--- a/Minecraft.World/Enchantment.cpp
+++ b/Minecraft.World/Enchantment.cpp
@@ -7,34 +7,34 @@
EnchantmentArray Enchantment::enchantments = EnchantmentArray( 256 );
vector<Enchantment *> Enchantment::validEnchantments;
-Enchantment *Enchantment::allDamageProtection = NULL;
-Enchantment *Enchantment::fireProtection = NULL;
-Enchantment *Enchantment::fallProtection = NULL;
-Enchantment *Enchantment::explosionProtection = NULL;
-Enchantment *Enchantment::projectileProtection = NULL;
-Enchantment *Enchantment::drownProtection = NULL;
-Enchantment *Enchantment::waterWorker = NULL;
-Enchantment *Enchantment::thorns = NULL;
+Enchantment *Enchantment::allDamageProtection = nullptr;
+Enchantment *Enchantment::fireProtection = nullptr;
+Enchantment *Enchantment::fallProtection = nullptr;
+Enchantment *Enchantment::explosionProtection = nullptr;
+Enchantment *Enchantment::projectileProtection = nullptr;
+Enchantment *Enchantment::drownProtection = nullptr;
+Enchantment *Enchantment::waterWorker = nullptr;
+Enchantment *Enchantment::thorns = nullptr;
// weapon
-Enchantment *Enchantment::damageBonus = NULL;
-Enchantment *Enchantment::damageBonusUndead = NULL;
-Enchantment *Enchantment::damageBonusArthropods = NULL;
-Enchantment *Enchantment::knockback = NULL;
-Enchantment *Enchantment::fireAspect = NULL;
-Enchantment *Enchantment::lootBonus = NULL;
+Enchantment *Enchantment::damageBonus = nullptr;
+Enchantment *Enchantment::damageBonusUndead = nullptr;
+Enchantment *Enchantment::damageBonusArthropods = nullptr;
+Enchantment *Enchantment::knockback = nullptr;
+Enchantment *Enchantment::fireAspect = nullptr;
+Enchantment *Enchantment::lootBonus = nullptr;
// digger
-Enchantment *Enchantment::diggingBonus = NULL;
-Enchantment *Enchantment::untouching = NULL;
-Enchantment *Enchantment::digDurability = NULL;
-Enchantment *Enchantment::resourceBonus = NULL;
+Enchantment *Enchantment::diggingBonus = nullptr;
+Enchantment *Enchantment::untouching = nullptr;
+Enchantment *Enchantment::digDurability = nullptr;
+Enchantment *Enchantment::resourceBonus = nullptr;
// bows
-Enchantment *Enchantment::arrowBonus = NULL;
-Enchantment *Enchantment::arrowKnockback = NULL;
-Enchantment *Enchantment::arrowFire = NULL;
-Enchantment *Enchantment::arrowInfinite = NULL;
+Enchantment *Enchantment::arrowBonus = nullptr;
+Enchantment *Enchantment::arrowKnockback = nullptr;
+Enchantment *Enchantment::arrowFire = nullptr;
+Enchantment *Enchantment::arrowInfinite = nullptr;
void Enchantment::staticCtor()
{
@@ -70,7 +70,7 @@ void Enchantment::staticCtor()
for(unsigned int i = 0; i < 256; ++i)
{
Enchantment *enchantment = enchantments[i];
- if (enchantment != NULL)
+ if (enchantment != nullptr)
{
validEnchantments.push_back(enchantment);
}
@@ -79,7 +79,7 @@ void Enchantment::staticCtor()
void Enchantment::_init(int id)
{
- if (enchantments[id] != NULL)
+ if (enchantments[id] != nullptr)
{
app.DebugPrintf("Duplicate enchantment id!");
#ifndef _CONTENT_PACKAGE
diff --git a/Minecraft.World/EnchantmentCategory.cpp b/Minecraft.World/EnchantmentCategory.cpp
index 7fb44481..b1c951ee 100644
--- a/Minecraft.World/EnchantmentCategory.cpp
+++ b/Minecraft.World/EnchantmentCategory.cpp
@@ -16,25 +16,25 @@ bool EnchantmentCategory::canEnchant(Item *item) const
{
if (this == all) return true;
- if (dynamic_cast<ArmorItem *>( item ) != NULL)
+ if (dynamic_cast<ArmorItem *>( item ) != nullptr)
{
if (this == armor) return true;
- ArmorItem *ai = (ArmorItem *) item;
+ ArmorItem *ai = static_cast<ArmorItem *>(item);
if (ai->slot == ArmorItem::SLOT_HEAD) return this == armor_head;
if (ai->slot == ArmorItem::SLOT_LEGS) return this == armor_legs;
if (ai->slot == ArmorItem::SLOT_TORSO) return this == armor_torso;
if (ai->slot == ArmorItem::SLOT_FEET) return this == armor_feet;
return false;
}
- else if (dynamic_cast<WeaponItem *>(item) != NULL)
+ else if (dynamic_cast<WeaponItem *>(item) != nullptr)
{
return this == weapon;
}
- else if (dynamic_cast<DiggerItem *>(item) != NULL)
+ else if (dynamic_cast<DiggerItem *>(item) != nullptr)
{
return this == digger;
}
- else if (dynamic_cast<BowItem *>(item) != NULL)
+ else if (dynamic_cast<BowItem *>(item) != nullptr)
{
return this == bow;
}
diff --git a/Minecraft.World/EnchantmentHelper.cpp b/Minecraft.World/EnchantmentHelper.cpp
index 7abc9856..995670c8 100644
--- a/Minecraft.World/EnchantmentHelper.cpp
+++ b/Minecraft.World/EnchantmentHelper.cpp
@@ -11,12 +11,12 @@ Random EnchantmentHelper::random;
int EnchantmentHelper::getEnchantmentLevel(int enchantmentId, shared_ptr<ItemInstance> piece)
{
- if (piece == NULL)
+ if (piece == nullptr)
{
return 0;
}
ListTag<CompoundTag> *enchantmentTags = piece->getEnchantmentTags();
- if (enchantmentTags == NULL)
+ if (enchantmentTags == nullptr)
{
return 0;
}
@@ -38,7 +38,7 @@ unordered_map<int, int> *EnchantmentHelper::getEnchantments(shared_ptr<ItemInsta
unordered_map<int, int> *result = new unordered_map<int, int>();
ListTag<CompoundTag> *list = item->id == Item::enchantedBook_Id ? Item::enchantedBook->getEnchantments(item) : item->getEnchantmentTags();
- if (list != NULL)
+ if (list != nullptr)
{
for (int i = 0; i < list->size(); i++)
{
@@ -62,8 +62,8 @@ void EnchantmentHelper::setEnchantments(unordered_map<int, int> *enchantments, s
int id = it.first;
CompoundTag *tag = new CompoundTag();
- tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_ID, (short) id);
- tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, (short)(int)it.second);
+ tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_ID, static_cast<short>(id));
+ tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, static_cast<short>((int)it.second));
list->add(tag);
@@ -88,7 +88,7 @@ void EnchantmentHelper::setEnchantments(unordered_map<int, int> *enchantments, s
int EnchantmentHelper::getEnchantmentLevel(int enchantmentId, ItemInstanceArray inventory)
{
- if (inventory.data == NULL) return 0;
+ if (inventory.data == nullptr) return 0;
int bestLevel = 0;
//for (ItemInstance piece : inventory)
for(unsigned int i = 0; i < inventory.length; ++i)
@@ -104,12 +104,12 @@ int EnchantmentHelper::getEnchantmentLevel(int enchantmentId, ItemInstanceArray
void EnchantmentHelper::runIterationOnItem(EnchantmentIterationMethod &method, shared_ptr<ItemInstance> piece)
{
- if (piece == NULL)
+ if (piece == nullptr)
{
return;
}
ListTag<CompoundTag> *enchantmentTags = piece->getEnchantmentTags();
- if (enchantmentTags == NULL)
+ if (enchantmentTags == nullptr)
{
return;
}
@@ -118,7 +118,7 @@ void EnchantmentHelper::runIterationOnItem(EnchantmentIterationMethod &method, s
int type = enchantmentTags->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_ID);
int level = enchantmentTags->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL);
- if (Enchantment::enchantments[type] != NULL)
+ if (Enchantment::enchantments[type] != nullptr)
{
method.doEnchantment(Enchantment::enchantments[type], level);
}
@@ -245,7 +245,7 @@ shared_ptr<ItemInstance> EnchantmentHelper::getRandomItemWith(Enchantment *encha
for(unsigned int i = 0; i < items.length; ++i)
{
shared_ptr<ItemInstance> item = items[i];
- if (item != NULL && getEnchantmentLevel(enchantment->id, item) > 0)
+ if (item != nullptr && getEnchantmentLevel(enchantment->id, item) > 0)
{
return item;
}
@@ -338,7 +338,7 @@ vector<EnchantmentInstance *> *EnchantmentHelper::selectEnchantment(Random *rand
if (itemBonus <= 0)
{
- return NULL;
+ return nullptr;
}
// 4J Stu - Update function to 1.3 version for TU7
itemBonus /= 2;
@@ -348,13 +348,13 @@ vector<EnchantmentInstance *> *EnchantmentHelper::selectEnchantment(Random *rand
// the final enchantment cost will have another random span of +- 15%
float deviation = (random->nextFloat() + random->nextFloat() - 1.0f) * .15f;
- int realValue = (int) ((float) enchantmentValue * (1.0f + deviation) + .5f);
+ int realValue = static_cast<int>((float)enchantmentValue * (1.0f + deviation) + .5f);
if (realValue < 1)
{
realValue = 1;
}
- vector<EnchantmentInstance *> *results = NULL;
+ vector<EnchantmentInstance *> *results = nullptr;
unordered_map<int, EnchantmentInstance *> *availableEnchantments = getAvailableEnchantmentResults(realValue, itemInstance);
if (availableEnchantments && !availableEnchantments->empty())
@@ -364,7 +364,7 @@ vector<EnchantmentInstance *> *EnchantmentHelper::selectEnchantment(Random *rand
{
values.push_back(it.second);
}
- EnchantmentInstance *instance = (EnchantmentInstance *) WeighedRandom::getRandomItem(random, &values);
+ EnchantmentInstance *instance = static_cast<EnchantmentInstance *>(WeighedRandom::getRandomItem(random, &values));
values.clear();
if (instance)
@@ -409,7 +409,7 @@ vector<EnchantmentInstance *> *EnchantmentHelper::selectEnchantment(Random *rand
{
values.push_back(it.second);
}
- EnchantmentInstance *nextInstance = (EnchantmentInstance *) WeighedRandom::getRandomItem(random, &values);
+ EnchantmentInstance *nextInstance = static_cast<EnchantmentInstance *>(WeighedRandom::getRandomItem(random, &values));
values.clear();
results->push_back( nextInstance->copy() ); // 4J Stu - Inserting a copy so we can clear memory from the availableEnchantments collection
}
@@ -433,7 +433,7 @@ vector<EnchantmentInstance *> *EnchantmentHelper::selectEnchantment(Random *rand
unordered_map<int, EnchantmentInstance *> *EnchantmentHelper::getAvailableEnchantmentResults(int value, shared_ptr<ItemInstance> itemInstance)
{
Item *item = itemInstance->getItem();
- unordered_map<int, EnchantmentInstance *> *results = NULL;
+ unordered_map<int, EnchantmentInstance *> *results = nullptr;
bool isBook = itemInstance->id == Item::book_Id;
@@ -441,7 +441,7 @@ unordered_map<int, EnchantmentInstance *> *EnchantmentHelper::getAvailableEnchan
for(unsigned int i = 0; i < Enchantment::enchantments.length; ++i)
{
Enchantment *e = Enchantment::enchantments[i];
- if (e == NULL)
+ if (e == nullptr)
{
continue;
}
@@ -456,7 +456,7 @@ unordered_map<int, EnchantmentInstance *> *EnchantmentHelper::getAvailableEnchan
{
if (value >= e->getMinCost(level) && value <= e->getMaxCost(level))
{
- if (results == NULL)
+ if (results == nullptr)
{
results = new unordered_map<int, EnchantmentInstance *>();
}
diff --git a/Minecraft.World/EnchantmentInstance.cpp b/Minecraft.World/EnchantmentInstance.cpp
index 973cd220..89a8bdd2 100644
--- a/Minecraft.World/EnchantmentInstance.cpp
+++ b/Minecraft.World/EnchantmentInstance.cpp
@@ -13,5 +13,5 @@ EnchantmentInstance::EnchantmentInstance(int id, int level) : WeighedRandomItem(
// 4J Added
EnchantmentInstance *EnchantmentInstance::copy()
{
- return new EnchantmentInstance((Enchantment *)enchantment, (int)level);
+ return new EnchantmentInstance((Enchantment *)enchantment, static_cast<int>(level));
} \ No newline at end of file
diff --git a/Minecraft.World/EnchantmentMenu.cpp b/Minecraft.World/EnchantmentMenu.cpp
index fa769bf9..6af7113a 100644
--- a/Minecraft.World/EnchantmentMenu.cpp
+++ b/Minecraft.World/EnchantmentMenu.cpp
@@ -9,7 +9,7 @@
EnchantmentMenu::EnchantmentMenu(shared_ptr<Inventory> inventory, Level *level, int xt, int yt, int zt)
{
- enchantSlots = shared_ptr<EnchantmentContainer>( new EnchantmentContainer(this) );
+ enchantSlots = std::make_shared<EnchantmentContainer>(this);
for(int i = 0; i < 3; ++i)
{
@@ -53,7 +53,7 @@ void EnchantmentMenu::broadcastChanges()
// 4J Added m_costsChanged to stop continually sending update packets even when no changes have been made
if(m_costsChanged)
{
- for (int i = 0; i < containerListeners.size(); i++)
+ for (size_t i = 0; i < containerListeners.size(); i++)
{
ContainerListener *listener = containerListeners.at(i);
listener->setContainerData(this, 0, costs[0]);
@@ -81,7 +81,7 @@ void EnchantmentMenu::slotsChanged() // 4J used to take a shared_ptr<Container>
{
shared_ptr<ItemInstance> item = enchantSlots->getItem(0);
- if (item == NULL || !item->isEnchantable())
+ if (item == nullptr || !item->isEnchantable())
{
for (int i = 0; i < 3; i++)
{
@@ -153,14 +153,14 @@ void EnchantmentMenu::slotsChanged() // 4J used to take a shared_ptr<Container>
bool EnchantmentMenu::clickMenuButton(shared_ptr<Player> player, int i)
{
shared_ptr<ItemInstance> item = enchantSlots->getItem(0);
- if (costs[i] > 0 && item != NULL && (player->experienceLevel >= costs[i] || player->abilities.instabuild) )
+ if (costs[i] > 0 && item != nullptr && (player->experienceLevel >= costs[i] || player->abilities.instabuild) )
{
if (!level->isClientSide)
{
bool isBook = item->id == Item::book_Id;
vector<EnchantmentInstance *> *newEnchantment = EnchantmentHelper::selectEnchantment(&random, item, costs[i]);
- if (newEnchantment != NULL)
+ if (newEnchantment != nullptr)
{
player->giveExperienceLevels(-costs[i]);
if (isBook) item->id = Item::enchantedBook_Id;
@@ -200,7 +200,7 @@ void EnchantmentMenu::removed(shared_ptr<Player> player)
if (level->isClientSide) return;
shared_ptr<ItemInstance> item = enchantSlots->removeItemNoUpdate(0);
- if (item != NULL)
+ if (item != nullptr)
{
player->drop(item);
}
@@ -215,11 +215,20 @@ bool EnchantmentMenu::stillValid(shared_ptr<Player> player)
shared_ptr<ItemInstance> EnchantmentMenu::quickMoveStack(shared_ptr<Player> player, int slotIndex)
{
+ if (slotIndex < 0 || slotIndex >= static_cast<int>(slots.size()))
+ {
+ return nullptr;
+ }
+
shared_ptr<ItemInstance> clicked = nullptr;
Slot *slot = slots.at(slotIndex);
- Slot *IngredientSlot = slots.at(INGREDIENT_SLOT);
+ Slot *IngredientSlot = nullptr;
+ if (INGREDIENT_SLOT >= 0 && INGREDIENT_SLOT < static_cast<int>(slots.size()))
+ {
+ IngredientSlot = slots.at(INGREDIENT_SLOT);
+ }
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
diff --git a/Minecraft.World/EnchantmentTableEntity.cpp b/Minecraft.World/EnchantmentTableEntity.cpp
index 15131aa2..dd9b6ad2 100644
--- a/Minecraft.World/EnchantmentTableEntity.cpp
+++ b/Minecraft.World/EnchantmentTableEntity.cpp
@@ -46,12 +46,12 @@ void EnchantmentTableEntity::tick()
oRot = rot;
shared_ptr<Player> 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);
- tRot = (float) atan2(zd, xd);
+ tRot = static_cast<float>(atan2(zd, xd));
open += 0.1f;
@@ -124,7 +124,7 @@ void EnchantmentTableEntity::setCustomName(const wstring &name)
shared_ptr<TileEntity> EnchantmentTableEntity::clone()
{
- shared_ptr<EnchantmentTableEntity> result = shared_ptr<EnchantmentTableEntity>( new EnchantmentTableEntity() );
+ shared_ptr<EnchantmentTableEntity> result = std::make_shared<EnchantmentTableEntity>();
TileEntity::clone(result);
result->time = time;
diff --git a/Minecraft.World/EnchantmentTableTile.cpp b/Minecraft.World/EnchantmentTableTile.cpp
index d50fe5f5..a5c51849 100644
--- a/Minecraft.World/EnchantmentTableTile.cpp
+++ b/Minecraft.World/EnchantmentTableTile.cpp
@@ -14,8 +14,8 @@ EnchantmentTableTile::EnchantmentTableTile(int id) : BaseEntityTile(id, Material
updateDefaultShape();
setLightBlock(0);
- iconTop = NULL;
- iconBottom = NULL;
+ iconTop = nullptr;
+ iconBottom = nullptr;
}
// 4J Added override
@@ -69,7 +69,7 @@ Icon *EnchantmentTableTile::getTexture(int face, int data)
shared_ptr<TileEntity> EnchantmentTableTile::newTileEntity(Level *level)
{
- return shared_ptr<TileEntity>(new EnchantmentTableEntity());
+ return std::make_shared<EnchantmentTableEntity>();
}
bool EnchantmentTableTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param
diff --git a/Minecraft.World/EnderChestTile.cpp b/Minecraft.World/EnderChestTile.cpp
index ef3c2046..f1b4738f 100644
--- a/Minecraft.World/EnderChestTile.cpp
+++ b/Minecraft.World/EnderChestTile.cpp
@@ -65,7 +65,7 @@ bool EnderChestTile::use(Level *level, int x, int y, int z, shared_ptr<Player> p
{
shared_ptr<PlayerEnderChestContainer> container = player->getEnderChestInventory();
shared_ptr<EnderChestTileEntity> enderChest = dynamic_pointer_cast<EnderChestTileEntity>(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;
@@ -82,7 +82,7 @@ bool EnderChestTile::use(Level *level, int x, int y, int z, shared_ptr<Player> p
shared_ptr<TileEntity> EnderChestTile::newTileEntity(Level *level)
{
- return shared_ptr<EnderChestTileEntity>(new EnderChestTileEntity());
+ return std::make_shared<EnderChestTileEntity>();
}
void EnderChestTile::animateTick(Level *level, int xt, int yt, int zt, Random *random)
diff --git a/Minecraft.World/EnderChestTileEntity.cpp b/Minecraft.World/EnderChestTileEntity.cpp
index 8169c029..1ad682ae 100644
--- a/Minecraft.World/EnderChestTileEntity.cpp
+++ b/Minecraft.World/EnderChestTileEntity.cpp
@@ -94,7 +94,7 @@ bool EnderChestTileEntity::stillValid(shared_ptr<Player> player)
// 4J Added
shared_ptr<TileEntity> EnderChestTileEntity::clone()
{
- shared_ptr<EnderChestTileEntity> result = shared_ptr<EnderChestTileEntity>( new EnderChestTileEntity() );
+ shared_ptr<EnderChestTileEntity> result = std::make_shared<EnderChestTileEntity>();
TileEntity::clone(result);
return result;
diff --git a/Minecraft.World/EnderCrystal.cpp b/Minecraft.World/EnderCrystal.cpp
index 5e7a9edb..40a82c3b 100644
--- a/Minecraft.World/EnderCrystal.cpp
+++ b/Minecraft.World/EnderCrystal.cpp
@@ -93,7 +93,7 @@ bool EnderCrystal::hurt(DamageSource *source, float damage)
if (isInvulnerable()) return false;
// 4J-PB - if the owner of the source is the enderdragon, then ignore it (where the dragon's fireball hits an endercrystal)
- if ( source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_ENDERDRAGON) )
+ if ( source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_ENDERDRAGON) )
{
return false;
}
diff --git a/Minecraft.World/EnderDragon.cpp b/Minecraft.World/EnderDragon.cpp
index e1dea172..f8e4871f 100644
--- a/Minecraft.World/EnderDragon.cpp
+++ b/Minecraft.World/EnderDragon.cpp
@@ -78,7 +78,7 @@ void EnderDragon::_init()
m_nodes = new NodeArray(24);
openSet = new BinaryHeap();
- m_currentPath = NULL;
+ m_currentPath = nullptr;
}
EnderDragon::EnderDragon(Level *level) : Mob(level)
@@ -100,14 +100,14 @@ EnderDragon::EnderDragon(Level *level) : Mob(level)
// 4J - split off from ctor so we can use shared_from_this()
void EnderDragon::AddParts()
{
- head = shared_ptr<MultiEntityMobPart>( new MultiEntityMobPart(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"head", 6, 6) );
- neck = shared_ptr<MultiEntityMobPart>( new MultiEntityMobPart(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"neck", 6, 6) ); // 4J Added
- body = shared_ptr<MultiEntityMobPart>( new MultiEntityMobPart(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"body", 8, 8) );
- tail1 = shared_ptr<MultiEntityMobPart>( new MultiEntityMobPart(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"tail", 4, 4) );
- tail2 = shared_ptr<MultiEntityMobPart>( new MultiEntityMobPart(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"tail", 4, 4) );
- tail3 = shared_ptr<MultiEntityMobPart>( new MultiEntityMobPart(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"tail", 4, 4) );
- wing1 = shared_ptr<MultiEntityMobPart>( new MultiEntityMobPart(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"wing", 4, 4) );
- wing2 = shared_ptr<MultiEntityMobPart>( new MultiEntityMobPart(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"wing", 4, 4) );
+ head = std::make_shared<MultiEntityMobPart>(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"head", 6, 6);
+ neck = std::make_shared<MultiEntityMobPart>(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"neck", 6, 6); // 4J Added
+ body = std::make_shared<MultiEntityMobPart>(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"body", 8, 8);
+ tail1 = std::make_shared<MultiEntityMobPart>(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"tail", 4, 4);
+ tail2 = std::make_shared<MultiEntityMobPart>(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"tail", 4, 4);
+ tail3 = std::make_shared<MultiEntityMobPart>(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"tail", 4, 4);
+ wing1 = std::make_shared<MultiEntityMobPart>(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"wing", 4, 4);
+ wing2 = std::make_shared<MultiEntityMobPart>(dynamic_pointer_cast<MultiEntityMob>(shared_from_this()), L"wing", 4, 4);
subEntities.push_back(head);
subEntities.push_back(neck); // 4J Added
@@ -121,16 +121,16 @@ void EnderDragon::AddParts()
EnderDragon::~EnderDragon()
{
- if(m_nodes->data != NULL)
+ if(m_nodes->data != nullptr)
{
for(unsigned int i = 0; i < m_nodes->length; ++i)
{
- if(m_nodes->data[i]!=NULL) delete m_nodes->data[i];
+ if(m_nodes->data[i]!=nullptr) delete m_nodes->data[i];
}
delete [] m_nodes->data;
}
delete openSet;
- if( m_currentPath != NULL ) delete m_currentPath;
+ if( m_currentPath != nullptr ) delete m_currentPath;
}
void EnderDragon::registerAttributes()
@@ -220,7 +220,7 @@ void EnderDragon::aiStep()
checkCrystals();
float flapSpeed = 0.2f / (sqrt(xd * xd + zd * zd) * 10.0f + 1);
- flapSpeed *= (float) pow(2.0, yd);
+ flapSpeed *= static_cast<float>(pow(2.0, yd));
if ( getSynchedAction() == e_EnderdragonAction_Sitting_Flaming ||
getSynchedAction() == e_EnderdragonAction_Sitting_Scanning ||
getSynchedAction() == e_EnderdragonAction_Sitting_Attacking)
@@ -383,7 +383,7 @@ void EnderDragon::aiStep()
attackTarget = level->getNearestPlayer( shared_from_this(), SITTING_ATTACK_VIEW_RANGE, SITTING_ATTACK_Y_VIEW_RANGE );
++m_actionTicks;
- if( attackTarget != NULL )
+ if( attackTarget != nullptr )
{
if(m_actionTicks > SITTING_SCANNING_IDLE_TICKS/4)
{
@@ -464,11 +464,11 @@ void EnderDragon::aiStep()
}
else if( getSynchedAction() == e_EnderdragonAction_Sitting_Scanning )
{
- if( attackTarget != NULL)
+ if( attackTarget != nullptr)
{
Vec3 *aim = Vec3::newTemp((attackTarget->x - x), 0, (attackTarget->z - z))->normalize();
Vec3 *dir = Vec3::newTemp(sin(yRot * PI / 180), 0, -cos(yRot * PI / 180))->normalize();
- float dot = (float)dir->dot(aim);
+ float dot = static_cast<float>(dir->dot(aim));
float angleDegs = acos(dot)*180/PI;
angleDegs = angleDegs + 0.5f;
@@ -519,7 +519,7 @@ void EnderDragon::aiStep()
// double xTargetO = xTarget;
// double yTargetO = yTarget;
// double zTargetO = zTarget;
- if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && attackTarget != NULL && m_currentPath != NULL && m_currentPath->isDone())
+ if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && attackTarget != nullptr && m_currentPath != nullptr && m_currentPath->isDone())
{
xTarget = attackTarget->x;
zTarget = attackTarget->z;
@@ -561,7 +561,7 @@ void EnderDragon::aiStep()
Vec3 *aim = Vec3::newTemp((xTarget - x), (yTarget - y), (zTarget - z))->normalize();
Vec3 *dir = Vec3::newTemp(sin(yRot * PI / 180), yd, -cos(yRot * PI / 180))->normalize();
- float dot = (float) (dir->dot(aim) + 0.5f) / 1.5f;
+ float dot = static_cast<float>(dir->dot(aim) + 0.5f) / 1.5f;
if (dot < 0) dot = 0;
yRotA *= 0.80f;
@@ -579,7 +579,7 @@ void EnderDragon::aiStep()
}
yRot += yRotA * 0.1f;
- float span = (float) (2.0f / (distToTarget + 1));
+ float span = static_cast<float>(2.0f / (distToTarget + 1));
float speed = 0.06f;
moveRelative(0, -1, speed * (dot * span + (1 - span)));
if (inWall)
@@ -593,7 +593,7 @@ void EnderDragon::aiStep()
}
Vec3 *actual = Vec3::newTemp(xd, yd, zd)->normalize();
- float slide = (float) (actual->dot(dir) + 1) / 2.0f;
+ float slide = static_cast<float>(actual->dot(dir) + 1) / 2.0f;
slide = 0.8f + 0.15f * slide;
@@ -715,14 +715,14 @@ void EnderDragon::aiStep()
if (!level->isClientSide)
{
double maxDist = 64.0f;
- if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && attackTarget != NULL && attackTarget->distanceToSqr(shared_from_this()) < maxDist * maxDist)
+ if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && attackTarget != nullptr && attackTarget->distanceToSqr(shared_from_this()) < maxDist * maxDist)
{
if (this->canSee(attackTarget))
{
m_fireballCharge++;
Vec3 *aim = Vec3::newTemp((attackTarget->x - x), 0, (attackTarget->z - z))->normalize();
Vec3 *dir = Vec3::newTemp(sin(yRot * PI / 180), 0, -cos(yRot * PI / 180))->normalize();
- float dot = (float)dir->dot(aim);
+ float dot = static_cast<float>(dir->dot(aim));
float angleDegs = acos(dot)*180/PI;
angleDegs = angleDegs + 0.5f;
@@ -738,8 +738,8 @@ void EnderDragon::aiStep()
double ydd = (attackTarget->bb->y0 + attackTarget->bbHeight / 2) - (startingY + head->bbHeight / 2);
double zdd = attackTarget->z - startingZ;
- level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, (int) x, (int) y, (int) z, 0);
- shared_ptr<DragonFireball> ie = shared_ptr<DragonFireball>( new DragonFireball(level, dynamic_pointer_cast<Mob>( shared_from_this() ), xdd, ydd, zdd) );
+ level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
+ shared_ptr<DragonFireball> ie = std::make_shared<DragonFireball>(level, dynamic_pointer_cast<Mob>(shared_from_this()), xdd, ydd, zdd);
ie->x = startingX;
ie->y = startingY;
ie->z = startingZ;
@@ -747,7 +747,7 @@ void EnderDragon::aiStep()
m_fireballCharge = 0;
app.DebugPrintf("Finding new target due to having fired a fireball\n");
- if( m_currentPath != NULL )
+ if( m_currentPath != nullptr )
{
while(!m_currentPath->isDone())
{
@@ -778,13 +778,13 @@ void EnderDragon::aiStep()
void EnderDragon::checkCrystals()
{
- if (nearestCrystal != NULL)
+ if (nearestCrystal != nullptr)
{
if (nearestCrystal->removed)
{
if (!level->isClientSide)
{
- hurt(head, DamageSource::explosion(NULL), 10);
+ hurt(head, DamageSource::explosion(nullptr), 10);
}
nearestCrystal = nullptr;
@@ -888,13 +888,13 @@ void EnderDragon::findNewTarget()
case e_EnderdragonAction_Takeoff:
case e_EnderdragonAction_HoldingPattern:
{
- if(!newTarget && m_currentPath != NULL && m_currentPath->isDone())
+ if(!newTarget && m_currentPath != nullptr && m_currentPath->isDone())
{
// Distance is 64, which is the radius of the circle
int eggHeight = max(level->seaLevel + 5, level->getTopSolidBlock(PODIUM_X_POS,PODIUM_Z_POS)); //level->getHeightmap(4,4);
playerNearestToEgg = level->getNearestPlayer(PODIUM_X_POS, eggHeight, PODIUM_Z_POS, 64.0);
double dist = 64.0f;
- if(playerNearestToEgg != NULL)
+ if(playerNearestToEgg != nullptr)
{
dist = playerNearestToEgg->distanceToSqr(PODIUM_X_POS, eggHeight, PODIUM_Z_POS);
dist /= (8*8*8);
@@ -909,7 +909,7 @@ void EnderDragon::findNewTarget()
#endif
}
// More likely to strafe a player if they are close to the egg, or there are not many crystals remaining
- else if( playerNearestToEgg != NULL && (random->nextInt( abs(dist) + 2 ) == 0 || random->nextInt( m_remainingCrystalsCount + 2 ) == 0) )
+ else if( playerNearestToEgg != nullptr && (random->nextInt( abs(dist) + 2 ) == 0 || random->nextInt( m_remainingCrystalsCount + 2 ) == 0) )
{
setSynchedAction(e_EnderdragonAction_StrafePlayer);
#if PRINT_DRAGON_STATE_CHANGE_MESSAGES
@@ -921,7 +921,7 @@ void EnderDragon::findNewTarget()
break;
case e_EnderdragonAction_StrafePlayer:
// Always return to the holding pattern after strafing
- if(m_currentPath == NULL || (m_currentPath->isDone() && newTarget) )
+ if(m_currentPath == nullptr || (m_currentPath->isDone() && newTarget) )
{
setSynchedAction(e_EnderdragonAction_HoldingPattern);
#if PRINT_DRAGON_STATE_CHANGE_MESSAGES
@@ -949,7 +949,7 @@ void EnderDragon::findNewTarget()
newTarget = false;
//if (random->nextInt(2) == 0 && level->players.size() > 0)
- if(getSynchedAction() == e_EnderdragonAction_StrafePlayer && playerNearestToEgg != NULL)
+ if(getSynchedAction() == e_EnderdragonAction_StrafePlayer && playerNearestToEgg != nullptr)
{
attackTarget = playerNearestToEgg;
strafeAttackTarget();
@@ -957,7 +957,7 @@ void EnderDragon::findNewTarget()
else if(getSynchedAction() == e_EnderdragonAction_LandingApproach)
{
// Generate a new path if we don't currently have one
- if( m_currentPath == NULL || m_currentPath->isDone() )
+ if( m_currentPath == nullptr || m_currentPath->isDone() )
{
int currentNodeIndex = findClosestNode();
@@ -966,7 +966,7 @@ void EnderDragon::findNewTarget()
playerNearestToEgg = level->getNearestPlayer(PODIUM_X_POS, eggHeight, PODIUM_Z_POS, 128.0);
int targetNodeIndex = 0 ;
- if(playerNearestToEgg != NULL)
+ if(playerNearestToEgg != nullptr)
{
Vec3 *aim = Vec3::newTemp(playerNearestToEgg->x, 0, playerNearestToEgg->z)->normalize();
//app.DebugPrintf("Final marker node near (%f,%d,%f)\n", -aim->x*40,105,-aim->z*40 );
@@ -978,18 +978,18 @@ void EnderDragon::findNewTarget()
}
Node finalNode(PODIUM_X_POS, eggHeight, PODIUM_Z_POS);
- if(m_currentPath != NULL) delete m_currentPath;
+ if(m_currentPath != nullptr) delete m_currentPath;
m_currentPath = findPath(currentNodeIndex,targetNodeIndex, &finalNode);
// Always skip the first node (as that's where we are already)
- if(m_currentPath != NULL) m_currentPath->next();
+ if(m_currentPath != nullptr) m_currentPath->next();
}
m_actionTicks = 0;
navigateToNextPathNode();
- if(m_currentPath != NULL && m_currentPath->isDone())
+ if(m_currentPath != nullptr && m_currentPath->isDone())
{
setSynchedAction(e_EnderdragonAction_Landing);
#if PRINT_DRAGON_STATE_CHANGE_MESSAGES
@@ -1007,7 +1007,7 @@ void EnderDragon::findNewTarget()
{
// Default is e_EnderdragonAction_HoldingPattern
// Generate a new path if we don't currently have one
- if(m_currentPath == NULL || m_currentPath->isDone() )
+ if(m_currentPath == nullptr || m_currentPath->isDone() )
{
int currentNodeIndex = findClosestNode();
int targetNodeIndex = currentNodeIndex;
@@ -1044,11 +1044,11 @@ void EnderDragon::findNewTarget()
if(targetNodeIndex < 0) targetNodeIndex += 12;
}
- if(m_currentPath != NULL) delete m_currentPath;
+ if(m_currentPath != nullptr) delete m_currentPath;
m_currentPath = findPath(currentNodeIndex,targetNodeIndex);
// Always skip the first node (as that's where we are already)
- if(m_currentPath != NULL) m_currentPath->next();
+ if(m_currentPath != nullptr) m_currentPath->next();
}
navigateToNextPathNode();
@@ -1063,7 +1063,7 @@ float EnderDragon::rotWrap(double d)
d -= 360;
while (d < -180)
d += 360;
- return (float) d;
+ return static_cast<float>(d);
}
bool EnderDragon::checkWalls(AABB *bb)
@@ -1125,9 +1125,9 @@ bool EnderDragon::hurt(shared_ptr<MultiEntityMobPart> MultiEntityMobPart, Damage
//xTarget = x + ss1 * 5 + (random->nextFloat() - 0.5f) * 2;
//yTarget = y + random->nextFloat() * 3 + 1;
//zTarget = z - cc1 * 5 + (random->nextFloat() - 0.5f) * 2;
- //attackTarget = NULL;
+ //attackTarget = nullptr;
- if ( source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER) || source->isExplosion() )
+ if ( source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) || source->isExplosion() )
{
int healthBefore = getHealth();
reallyHurt(source, damage);
@@ -1142,7 +1142,7 @@ bool EnderDragon::hurt(shared_ptr<MultiEntityMobPart> MultiEntityMobPart, Damage
if( setSynchedAction(e_EnderdragonAction_LandingApproach) )
{
- if( m_currentPath != NULL )
+ if( m_currentPath != nullptr )
{
while(!m_currentPath->isDone())
{
@@ -1214,12 +1214,12 @@ void EnderDragon::tickDeath()
{
int newCount = ExperienceOrb::getExperienceValue(xpCount);
xpCount -= newCount;
- level->addEntity(shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x, y, z, newCount) ));
+ level->addEntity(std::make_shared<ExperienceOrb>(level, x, y, z, newCount));
}
}
if (dragonDeathTime == 1)
{
- level->globalLevelEvent(LevelEvent::SOUND_DRAGON_DEATH, (int) x, (int) y, (int) z, 0);
+ level->globalLevelEvent(LevelEvent::SOUND_DRAGON_DEATH, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
}
}
move(0, 0.1f, 0);
@@ -1227,14 +1227,14 @@ void EnderDragon::tickDeath()
if (dragonDeathTime == 200 && !level->isClientSide)
{
- //level->levelEvent(NULL, LevelEvent::ENDERDRAGON_KILLED, (int) x, (int) y, (int) z, 0);
+ //level->levelEvent(nullptr, LevelEvent::ENDERDRAGON_KILLED, (int) x, (int) y, (int) z, 0);
int xpCount = 2000;
while (xpCount > 0)
{
int newCount = ExperienceOrb::getExperienceValue(xpCount);
xpCount -= newCount;
- level->addEntity(shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x, y, z, newCount)));
+ level->addEntity(std::make_shared<ExperienceOrb>(level, x, y, z, newCount));
}
int xo = 5 + random->nextInt(2) * 2 - 1;
int zo = 5 + random->nextInt(2) * 2 - 1;
@@ -1458,14 +1458,14 @@ bool EnderDragon::setSynchedAction(EEnderdragonAction action, bool force /*= fal
EnderDragon::EEnderdragonAction EnderDragon::getSynchedAction()
{
- return (EEnderdragonAction)entityData->getInteger(DATA_ID_SYNCHED_ACTION);
+ return static_cast<EEnderdragonAction>(entityData->getInteger(DATA_ID_SYNCHED_ACTION));
}
void EnderDragon::handleCrystalDestroyed(DamageSource *source)
{
AABB *tempBB = AABB::newTemp(PODIUM_X_POS,84.0,PODIUM_Z_POS,PODIUM_X_POS+1.0,85.0,PODIUM_Z_POS+1.0);
vector<shared_ptr<Entity> > *crystals = level->getEntitiesOfClass(typeid(EnderCrystal), tempBB->grow(48, 40, 48));
- m_remainingCrystalsCount = (int)crystals->size() - 1;
+ m_remainingCrystalsCount = static_cast<int>(crystals->size()) - 1;
if(m_remainingCrystalsCount < 0) m_remainingCrystalsCount = 0;
delete crystals;
@@ -1477,7 +1477,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource *source)
{
if(setSynchedAction(e_EnderdragonAction_LandingApproach))
{
- if( m_currentPath != NULL )
+ if( m_currentPath != nullptr )
{
while(!m_currentPath->isDone())
{
@@ -1490,7 +1490,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource *source)
#endif
}
}
- else if(source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER))
+ else if(source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER))
{
if(setSynchedAction(e_EnderdragonAction_StrafePlayer))
{
@@ -1521,10 +1521,10 @@ void EnderDragon::strafeAttackTarget()
Node finalNode(finalXTarget, finalYTarget, finalZTarget);
- if(m_currentPath != NULL) delete m_currentPath;
+ if(m_currentPath != nullptr) delete m_currentPath;
m_currentPath = findPath(currentNodeIndex,targetNodeIndex, &finalNode);
- if(m_currentPath != NULL)
+ if(m_currentPath != nullptr)
{
// Always skip the first node (as that's where we are already)
m_currentPath->next();
@@ -1535,7 +1535,7 @@ void EnderDragon::strafeAttackTarget()
void EnderDragon::navigateToNextPathNode()
{
- if(m_currentPath != NULL && !m_currentPath->isDone())
+ if(m_currentPath != nullptr && !m_currentPath->isDone())
{
Vec3 *curr = m_currentPath->currentPos();
@@ -1563,7 +1563,7 @@ void EnderDragon::navigateToNextPathNode()
int EnderDragon::findClosestNode()
{
// Setup all the nodes on the first time this is called
- if(m_nodes->data[0] == NULL)
+ if(m_nodes->data[0] == nullptr)
{
// Path nodes for navigation
// 0 - 11 are the outer ring at 60 blocks from centre
@@ -1641,7 +1641,7 @@ int EnderDragon::findClosestNode(double tX, double tY, double tZ)
{
float closestDist = 100.0f;
int closestIndex = 0;
- Node *currentPos = new Node((int) floor(tX), (int) floor(tY), (int) floor(tZ));
+ Node *currentPos = new Node(static_cast<int>(floor(tX)), static_cast<int>(floor(tY)), static_cast<int>(floor(tZ)));
int startIndex = 0;
if(m_remainingCrystalsCount <= 0)
{
@@ -1650,7 +1650,7 @@ int EnderDragon::findClosestNode(double tX, double tY, double tZ)
}
for(unsigned int i = startIndex; i < 24; ++i)
{
- if( m_nodes->data[i] != NULL )
+ if( m_nodes->data[i] != nullptr )
{
float dist = m_nodes->data[i]->distanceTo(currentPos);
if(dist < closestDist)
@@ -1665,7 +1665,7 @@ int EnderDragon::findClosestNode(double tX, double tY, double tZ)
}
// 4J Stu - A* taken from PathFinder and modified
-Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = NULL */)
+Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = nullptr */)
{
for(unsigned int i = 0; i < 24; ++i)
{
@@ -1674,7 +1674,7 @@ Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = N
n->f = 0;
n->g = 0;
n->h = 0;
- n->cameFrom = NULL;
+ n->cameFrom = nullptr;
n->heapIdx = -1;
}
@@ -1704,7 +1704,7 @@ Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = N
if (x->equals(to))
{
app.DebugPrintf("Found path from %d to %d\n", startIndex, endIndex);
- if(finalNode != NULL)
+ if(finalNode != nullptr)
{
finalNode->cameFrom = to;
to = finalNode;
@@ -1756,9 +1756,9 @@ Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = N
}
}
- if (closest == from) return NULL;
+ if (closest == from) return nullptr;
app.DebugPrintf("Failed to find path from %d to %d\n", startIndex, endIndex);
- if(finalNode != NULL)
+ if(finalNode != nullptr)
{
finalNode->cameFrom = closest;
closest = finalNode;
@@ -1771,7 +1771,7 @@ Path *EnderDragon::reconstruct_path(Node *from, Node *to)
{
int count = 1;
Node *n = to;
- while (n->cameFrom != NULL)
+ while (n->cameFrom != nullptr)
{
count++;
n = n->cameFrom;
@@ -1780,7 +1780,7 @@ Path *EnderDragon::reconstruct_path(Node *from, Node *to)
NodeArray nodes = NodeArray(count);
n = to;
nodes.data[--count] = n;
- while (n->cameFrom != NULL)
+ while (n->cameFrom != nullptr)
{
n = n->cameFrom;
nodes.data[--count] = n;
@@ -1805,7 +1805,7 @@ void EnderDragon::readAdditionalSaveData(CompoundTag *tag)
m_remainingCrystalsCount = tag->getShort(L"RemainingCrystals");
if(!tag->contains(L"RemainingCrystals")) m_remainingCrystalsCount = CRYSTAL_COUNT;
- if(tag->contains(L"DragonState")) setSynchedAction( (EEnderdragonAction)tag->getInt(L"DragonState"), true);
+ if(tag->contains(L"DragonState")) setSynchedAction( static_cast<EEnderdragonAction>(tag->getInt(L"DragonState")), true);
Mob::readAdditionalSaveData(tag);
}
@@ -1923,7 +1923,7 @@ double EnderDragon::getHeadPartYRotDiff(int partIndex, doubleArray bodyPos, doub
Vec3 *EnderDragon::getHeadLookVector(float a)
{
- Vec3 *result = NULL;
+ Vec3 *result = nullptr;
if( getSynchedAction() == e_EnderdragonAction_Landing || getSynchedAction() == e_EnderdragonAction_Takeoff )
{
diff --git a/Minecraft.World/EnderDragon.h b/Minecraft.World/EnderDragon.h
index a13ecaa2..9f39767e 100644
--- a/Minecraft.World/EnderDragon.h
+++ b/Minecraft.World/EnderDragon.h
@@ -163,7 +163,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/EnderEyeItem.cpp b/Minecraft.World/EnderEyeItem.cpp
index 063e1408..25b16d05 100644
--- a/Minecraft.World/EnderEyeItem.cpp
+++ b/Minecraft.World/EnderEyeItem.cpp
@@ -136,7 +136,7 @@ bool EnderEyeItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> p
bool EnderEyeItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
{
HitResult *hr = getPlayerPOVHitResult(level, player, false);
- if (hr != NULL && hr->type == HitResult::TILE)
+ if (hr != nullptr && hr->type == HitResult::TILE)
{
int tile = level->getTile(hr->x, hr->y, hr->z);
delete hr;
@@ -145,7 +145,7 @@ bool EnderEyeItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level,
return false;
}
}
- else if( hr != NULL )
+ else if( hr != nullptr )
{
delete hr;
}
@@ -177,7 +177,7 @@ bool EnderEyeItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level,
}
// TilePos *nearestMapFeature = level->findNearestMapFeature(LargeFeature::STRONGHOLD, (int) player->x, (int) player->y, (int) player->z);
-// if (nearestMapFeature != NULL)
+// if (nearestMapFeature != nullptr)
// {
// delete nearestMapFeature;
// return true;
@@ -189,7 +189,7 @@ bool EnderEyeItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level,
shared_ptr<ItemInstance> EnderEyeItem::use(shared_ptr<ItemInstance> instance, Level *level, shared_ptr<Player> player)
{
HitResult *hr = getPlayerPOVHitResult(level, player, false);
- if (hr != NULL && hr->type == HitResult::TILE)
+ if (hr != nullptr && hr->type == HitResult::TILE)
{
int tile = level->getTile(hr->x, hr->y, hr->z);
delete hr;
@@ -198,7 +198,7 @@ shared_ptr<ItemInstance> EnderEyeItem::use(shared_ptr<ItemInstance> instance, Le
return instance;
}
}
- else if( hr != NULL )
+ else if( hr != nullptr )
{
delete hr;
}
@@ -207,12 +207,12 @@ shared_ptr<ItemInstance> EnderEyeItem::use(shared_ptr<ItemInstance> instance, Le
{
if((level->dimension->id==LevelData::DIMENSION_OVERWORLD) && level->getLevelData()->getHasStronghold())
{
- shared_ptr<EyeOfEnderSignal> eyeOfEnderSignal = shared_ptr<EyeOfEnderSignal>( new EyeOfEnderSignal(level, player->x, player->y + 1.62 - player->heightOffset, player->z) );
+ shared_ptr<EyeOfEnderSignal> eyeOfEnderSignal = std::make_shared<EyeOfEnderSignal>(level, player->x, player->y + 1.62 - player->heightOffset, player->z);
eyeOfEnderSignal->signalTo(level->getLevelData()->getXStronghold()<<4, player->y + 1.62 - player->heightOffset, level->getLevelData()->getZStronghold()<<4);
level->addEntity(eyeOfEnderSignal);
level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f));
- level->levelEvent(nullptr, LevelEvent::SOUND_LAUNCH, (int) player->x, (int) player->y, (int) player->z, 0);
+ level->levelEvent(nullptr, LevelEvent::SOUND_LAUNCH, static_cast<int>(player->x), static_cast<int>(player->y), static_cast<int>(player->z), 0);
if (!player->abilities.instabuild)
{
instance->count--;
diff --git a/Minecraft.World/EnderMan.cpp b/Minecraft.World/EnderMan.cpp
index d099911c..e1231818 100644
--- a/Minecraft.World/EnderMan.cpp
+++ b/Minecraft.World/EnderMan.cpp
@@ -67,16 +67,16 @@ void EnderMan::defineSynchedData()
{
Monster::defineSynchedData();
- entityData->define(DATA_CARRY_ITEM_ID, (byte) 0);
- entityData->define(DATA_CARRY_ITEM_DATA, (byte) 0);
- entityData->define(DATA_CREEPY, (byte) 0);
+ entityData->define(DATA_CARRY_ITEM_ID, static_cast<byte>(0));
+ entityData->define(DATA_CARRY_ITEM_DATA, static_cast<byte>(0));
+ entityData->define(DATA_CREEPY, static_cast<byte>(0));
}
void EnderMan::addAdditonalSaveData(CompoundTag *tag)
{
Monster::addAdditonalSaveData(tag);
- tag->putShort(L"carried", (short) getCarryingTile());
- tag->putShort(L"carriedData", (short) getCarryingData());
+ tag->putShort(L"carried", static_cast<short>(getCarryingTile()));
+ tag->putShort(L"carriedData", static_cast<short>(getCarryingData()));
}
void EnderMan::readAdditionalSaveData(CompoundTag *tag)
@@ -96,7 +96,7 @@ shared_ptr<Entity> EnderMan::findAttackTarget()
#endif
shared_ptr<Player> player = level->getNearestAttackablePlayer(shared_from_this(), 64);
- if (player != NULL)
+ if (player != nullptr)
{
if (isLookingAtMe(player))
{
@@ -120,7 +120,7 @@ shared_ptr<Entity> EnderMan::findAttackTarget()
bool EnderMan::isLookingAtMe(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> helmet = player->inventory->armor[3];
- if (helmet != NULL && helmet->id == Tile::pumpkin_Id) return false;
+ if (helmet != nullptr && helmet->id == Tile::pumpkin_Id) return false;
Vec3 *look = player->getViewVector(1)->normalize();
Vec3 *dir = Vec3::newTemp(x - player->x, (bb->y0 + bbHeight / 2) - (player->y + player->getHeadHeight()), z - player->z);
@@ -143,7 +143,7 @@ void EnderMan::aiStep()
AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED);
speed->removeModifier(SPEED_MODIFIER_ATTACKING);
- if (attackTarget != NULL)
+ if (attackTarget != nullptr)
{
speed->addModifier(new AttributeModifier(*SPEED_MODIFIER_ATTACKING));
}
@@ -202,7 +202,7 @@ void EnderMan::aiStep()
float br = getBrightness(1);
if (br > 0.5f)
{
- if (level->canSeeSky(Mth::floor(x), (int)floor( y + 0.5 ), Mth::floor(z)) && random->nextFloat() * 30 < (br - 0.4f) * 2)
+ if (level->canSeeSky(Mth::floor(x), static_cast<int>(floor(y + 0.5)), Mth::floor(z)) && random->nextFloat() * 30 < (br - 0.4f) * 2)
{
attackTarget = nullptr;
setCreepy(false);
@@ -226,14 +226,14 @@ void EnderMan::aiStep()
}
jumping = false;
- if (attackTarget != NULL)
+ if (attackTarget != nullptr)
{
lookAt(attackTarget, 100, 100);
}
if (!level->isClientSide && isAlive())
{
- if (attackTarget != NULL)
+ if (attackTarget != nullptr)
{
if ( attackTarget->instanceof(eTYPE_PLAYER) && isLookingAtMe(dynamic_pointer_cast<Player>(attackTarget)))
{
@@ -385,7 +385,7 @@ void EnderMan::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
// 4J Brought forward from 1.2.3 to help fix Enderman behaviour
void EnderMan::setCarryingTile(int carryingTile)
{
- entityData->set(DATA_CARRY_ITEM_ID, (byte) (carryingTile & 0xff));
+ entityData->set(DATA_CARRY_ITEM_ID, static_cast<byte>(carryingTile & 0xff));
}
int EnderMan::getCarryingTile()
@@ -395,7 +395,7 @@ int EnderMan::getCarryingTile()
void EnderMan::setCarryingData(int carryingData)
{
- entityData->set(DATA_CARRY_ITEM_DATA, (byte) (carryingData & 0xff));
+ entityData->set(DATA_CARRY_ITEM_DATA, static_cast<byte>(carryingData & 0xff));
}
int EnderMan::getCarryingData()
@@ -408,12 +408,12 @@ bool EnderMan::hurt(DamageSource *source, float damage)
if (isInvulnerable()) return false;
setCreepy(true);
- if ( dynamic_cast<EntityDamageSource *>(source) != NULL && source->getEntity()->instanceof(eTYPE_PLAYER))
+ if ( dynamic_cast<EntityDamageSource *>(source) != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER))
{
aggroedByPlayer = true;
}
- if (dynamic_cast<IndirectEntityDamageSource *>(source) != NULL)
+ if (dynamic_cast<IndirectEntityDamageSource *>(source) != nullptr)
{
aggroedByPlayer = false;
for (int i = 0; i < 64; i++)
@@ -435,5 +435,5 @@ bool EnderMan::isCreepy()
void EnderMan::setCreepy(bool creepy)
{
- entityData->set(DATA_CREEPY, (byte)(creepy ? 1 : 0));
+ entityData->set(DATA_CREEPY, static_cast<byte>(creepy ? 1 : 0));
} \ No newline at end of file
diff --git a/Minecraft.World/EnderpearlItem.cpp b/Minecraft.World/EnderpearlItem.cpp
index e1ed693b..c024190b 100644
--- a/Minecraft.World/EnderpearlItem.cpp
+++ b/Minecraft.World/EnderpearlItem.cpp
@@ -19,7 +19,7 @@ shared_ptr<ItemInstance> EnderpearlItem::use(shared_ptr<ItemInstance> instance,
{
// 4J-PB - Not sure why this was disabled for creative mode, so commenting out
//if (player->abilities.instabuild) return instance;
- if (player->riding != NULL) return instance;
+ if (player->riding != nullptr) return instance;
if (!player->abilities.instabuild)
{
instance->count--;
@@ -28,7 +28,7 @@ shared_ptr<ItemInstance> EnderpearlItem::use(shared_ptr<ItemInstance> instance,
level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f));
if (!level->isClientSide)
{
- level->addEntity( shared_ptr<ThrownEnderpearl>( new ThrownEnderpearl(level, player) ) );
+ level->addEntity(std::make_shared<ThrownEnderpearl>(level, player));
}
return instance;
} \ No newline at end of file
diff --git a/Minecraft.World/Enemy.cpp b/Minecraft.World/Enemy.cpp
index b9aa3e20..5dd54846 100644
--- a/Minecraft.World/Enemy.cpp
+++ b/Minecraft.World/Enemy.cpp
@@ -5,5 +5,5 @@ EntitySelector *Enemy::ENEMY_SELECTOR = new Enemy::EnemyEntitySelector();
bool Enemy::EnemyEntitySelector::matches(shared_ptr<Entity> entity) const
{
- return (entity != NULL) && entity->instanceof(eTYPE_ENEMY);
+ return (entity != nullptr) && entity->instanceof(eTYPE_ENEMY);
} \ No newline at end of file
diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp
index e8233140..d754330b 100644
--- a/Minecraft.World/Entity.cpp
+++ b/Minecraft.World/Entity.cpp
@@ -41,7 +41,7 @@ int Entity::extraWanderCount = 0;
int Entity::getSmallId()
{
unsigned int *puiUsedFlags = entityIdUsedFlags;
- unsigned int *puiRemovedFlags = NULL;
+ unsigned int *puiRemovedFlags = nullptr;
// If we are the server (we should be, if we are allocating small Ids), then check with the server if there are any small Ids which are
// still in the ServerPlayer's vectors of entities to be removed - these are used to gather up a set of entities into one network packet
@@ -260,7 +260,7 @@ void Entity::_init(bool useSmallId, Level *level)
riding = nullptr;
forcedLoading = false;
- //level = NULL; // Level is assigned to in the original c_tor code
+ //level = nullptr; // Level is assigned to in the original c_tor code
xo = yo = zo = 0.0;
x = y = z = 0.0;
xd = yd = zd = 0.0;
@@ -312,7 +312,7 @@ void Entity::_init(bool useSmallId, Level *level)
// values that need to be sent to clients in SMP
if( useSmallId )
{
- entityData = shared_ptr<SynchedEntityData>(new SynchedEntityData());
+ entityData = std::make_shared<SynchedEntityData>();
}
else
{
@@ -355,14 +355,14 @@ Entity::Entity(Level *level, bool useSmallId) // 4J - added useSmallId parameter
// resetPos();
setPos(0, 0, 0);
- if (level != NULL)
+ if (level != nullptr)
{
dimension = level->dimension->id;
}
if( entityData )
{
- entityData->define(DATA_SHARED_FLAGS_ID, (byte) 0);
+ entityData->define(DATA_SHARED_FLAGS_ID, static_cast<byte>(0));
entityData->define(DATA_AIR_SUPPLY_ID, TOTAL_AIR_SUPPLY); // 4J Stu - Brought forward from 1.2.3 to fix 38654 - Gameplay: Player will take damage when air bubbles are present if resuming game from load/autosave underwater.
}
@@ -398,7 +398,7 @@ return entityId;
void Entity::resetPos()
{
- if (level == NULL) return;
+ if (level == nullptr) return;
shared_ptr<Entity> sharedThis = shared_from_this();
while (true && y > 0)
@@ -510,7 +510,7 @@ void Entity::baseTick()
// 4J Stu - Not needed
//util.Timer.push("entityBaseTick");
- if (riding != NULL && riding->removed)
+ if (riding != nullptr && riding->removed)
{
riding = nullptr;
}
@@ -533,7 +533,7 @@ void Entity::baseTick()
{
if (server->isNetherEnabled())
{
- if (riding == NULL)
+ if (riding == nullptr)
{
if (portalTime++ >= waitTime)
{
@@ -883,7 +883,7 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
double zm = z - zo;
- if (makeStepSound() && !isPlayerSneaking && riding == NULL)
+ if (makeStepSound() && !isPlayerSneaking && riding == nullptr)
{
int xt = Mth::floor(x);
int yt = Mth::floor(y - 0.2f - heightOffset);
@@ -907,7 +907,7 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
if (moveDist > nextStep && t > 0)
{
- nextStep = (int) moveDist + 1;
+ nextStep = static_cast<int>(moveDist) + 1;
if (isInWater())
{
float speed = Mth::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * 0.35f;
@@ -1023,13 +1023,13 @@ void Entity::checkFallDamage(double ya, bool onGround)
}
else
{
- if (ya < 0) fallDistance -= (float) ya;
+ if (ya < 0) fallDistance -= static_cast<float>(ya);
}
}
AABB *Entity::getCollideBox()
{
- return NULL;
+ return nullptr;
}
void Entity::burn(int dmg)
@@ -1047,7 +1047,7 @@ bool Entity::isFireImmune()
void Entity::causeFallDamage(float distance)
{
- if (rider.lock() != NULL) rider.lock()->causeFallDamage(distance);
+ if (rider.lock() != nullptr) rider.lock()->causeFallDamage(distance);
}
@@ -1072,7 +1072,7 @@ bool Entity::updateInWaterState()
MemSect(31);
playSound(eSoundType_RANDOM_SPLASH, speed, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f);
MemSect(0);
- float yt = (float) Mth::floor(bb->y0);
+ float yt = static_cast<float>(Mth::floor(bb->y0));
for (int i = 0; i < 1 + bbWidth * 20; i++)
{
float xo = (random->nextFloat() * 2 - 1) * bbWidth;
@@ -1202,9 +1202,9 @@ void Entity::moveTo(double x, double y, double z, float yRot, float xRot)
float Entity::distanceTo(shared_ptr<Entity> e)
{
- float xd = (float) (x - e->x);
- float yd = (float) (y - e->y);
- float zd = (float) (z - e->z);
+ float xd = static_cast<float>(x - e->x);
+ float yd = static_cast<float>(y - e->y);
+ float zd = static_cast<float>(z - e->z);
return sqrt(xd * xd + yd * yd + zd * zd);
}
@@ -1348,7 +1348,7 @@ bool Entity::saveAsMount(CompoundTag *entityTag)
bool Entity::save(CompoundTag *entityTag)
{
wstring id = getEncodeId();
- if (removed || id.empty() || (rider.lock() != NULL) )
+ if (removed || id.empty() || (rider.lock() != nullptr) )
{
return false;
}
@@ -1365,8 +1365,8 @@ void Entity::saveWithoutId(CompoundTag *entityTag)
entityTag->put(L"Rotation", newFloatList(2, yRot, xRot));
entityTag->putFloat(L"FallDistance", fallDistance);
- entityTag->putShort(L"Fire", (short) onFire);
- entityTag->putShort(L"Air", (short) getAirSupply());
+ entityTag->putShort(L"Fire", static_cast<short>(onFire));
+ entityTag->putShort(L"Air", static_cast<short>(getAirSupply()));
entityTag->putBoolean(L"OnGround", onGround);
entityTag->putInt(L"Dimension", dimension);
entityTag->putBoolean(L"Invulnerable", invulnerable);
@@ -1376,7 +1376,7 @@ void Entity::saveWithoutId(CompoundTag *entityTag)
addAdditonalSaveData(entityTag);
- if (riding != NULL)
+ if (riding != nullptr)
{
CompoundTag *ridingTag = new CompoundTag(RIDING_TAG);
if (riding->saveAsMount(ridingTag))
@@ -1511,7 +1511,7 @@ shared_ptr<ItemEntity> Entity::spawnAtLocation(int resource, int count)
shared_ptr<ItemEntity> Entity::spawnAtLocation(int resource, int count, float yOffs)
{
- return spawnAtLocation(shared_ptr<ItemInstance>( new ItemInstance(resource, count, 0) ), yOffs);
+ return spawnAtLocation(std::make_shared<ItemInstance>(resource, count, 0), yOffs);
}
shared_ptr<ItemEntity> Entity::spawnAtLocation(shared_ptr<ItemInstance> itemInstance, float yOffs)
@@ -1520,7 +1520,7 @@ shared_ptr<ItemEntity> Entity::spawnAtLocation(shared_ptr<ItemInstance> itemInst
{
return nullptr;
}
- shared_ptr<ItemEntity> ie = shared_ptr<ItemEntity>( new ItemEntity(level, x, y + yOffs, z, itemInstance) );
+ shared_ptr<ItemEntity> ie = std::make_shared<ItemEntity>(level, x, y + yOffs, z, itemInstance);
ie->throwTime = 10;
level->addEntity(ie);
return ie;
@@ -1556,7 +1556,7 @@ bool Entity::interact(shared_ptr<Player> player)
AABB *Entity::getCollideAgainstBox(shared_ptr<Entity> entity)
{
- return NULL;
+ return nullptr;
}
void Entity::rideTick()
@@ -1569,7 +1569,7 @@ void Entity::rideTick()
xd = yd = zd = 0;
tick();
- if (riding == NULL) return;
+ if (riding == nullptr) return;
// Sets riders old&new position to it's mount's old&new position (plus the ride y-seperatation).
riding->positionRider();
@@ -1605,7 +1605,7 @@ void Entity::rideTick()
void Entity::positionRider()
{
shared_ptr<Entity> lockedRider = rider.lock();
- if( lockedRider == NULL)
+ if( lockedRider == nullptr)
{
return;
}
@@ -1627,9 +1627,9 @@ void Entity::ride(shared_ptr<Entity> e)
xRideRotA = 0;
yRideRotA = 0;
- if (e == NULL)
+ if (e == nullptr)
{
- if (riding != NULL)
+ if (riding != nullptr)
{
// 4J Stu - Position should already be updated before the SetEntityLinkPacket comes in
if(!level->isClientSide) moveTo(riding->x, riding->bb->y0 + riding->bbHeight, riding->z, yRot, xRot);
@@ -1638,7 +1638,7 @@ void Entity::ride(shared_ptr<Entity> e)
riding = nullptr;
return;
}
- if (riding != NULL)
+ if (riding != nullptr)
{
riding->rider = weak_ptr<Entity>();
}
@@ -1677,7 +1677,7 @@ float Entity::getPickRadius()
Vec3 *Entity::getLookAngle()
{
- return NULL;
+ return nullptr;
}
void Entity::handleInsidePortal()
@@ -1721,7 +1721,7 @@ void Entity::animateHurt()
ItemInstanceArray Entity::getEquipmentSlots() // ItemInstance[]
{
- return ItemInstanceArray(); // Default ctor creates NULL internal array
+ return ItemInstanceArray(); // Default ctor creates nullptr internal array
}
// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
@@ -1736,7 +1736,7 @@ bool Entity::isOnFire()
bool Entity::isRiding()
{
- return riding != NULL;
+ return riding != nullptr;
}
bool Entity::isSneaking()
@@ -1823,11 +1823,11 @@ void Entity::setSharedFlag(int flag, bool value)
byte currentValue = entityData->getByte(DATA_SHARED_FLAGS_ID);
if (value)
{
- entityData->set(DATA_SHARED_FLAGS_ID, (byte) (currentValue | (1 << flag)));
+ entityData->set(DATA_SHARED_FLAGS_ID, static_cast<byte>(currentValue | (1 << flag)));
}
else
{
- entityData->set(DATA_SHARED_FLAGS_ID, (byte) (currentValue & ~(1 << flag)));
+ entityData->set(DATA_SHARED_FLAGS_ID, static_cast<byte>(currentValue & ~(1 << flag)));
}
}
}
@@ -1841,7 +1841,7 @@ int Entity::getAirSupply()
// 4J Stu - Brought forward from 1.2.3 to fix 38654 - Gameplay: Player will take damage when air bubbles are present if resuming game from load/autosave underwater.
void Entity::setAirSupply(int supply)
{
- entityData->set(DATA_AIR_SUPPLY_ID, (short) supply);
+ entityData->set(DATA_AIR_SUPPLY_ID, static_cast<short>(supply));
}
void Entity::thunderHit(const LightningBolt *lightningBolt)
@@ -1937,7 +1937,7 @@ wstring Entity::getAName()
vector<shared_ptr<Entity> > *Entity::getSubEntities()
{
- return NULL;
+ return nullptr;
}
bool Entity::is(shared_ptr<Entity> other)
@@ -2023,7 +2023,7 @@ void Entity::changeDimension(int i)
server->getPlayers()->repositionAcrossDimension(shared_from_this(), lastDimension, oldLevel, newLevel);
shared_ptr<Entity> newEntity = EntityIO::newEntity(EntityIO::getEncodeId(shared_from_this()), newLevel);
- if (newEntity != NULL)
+ if (newEntity != nullptr)
{
newEntity->restoreFrom(shared_from_this(), true);
diff --git a/Minecraft.World/EntityActionAtPositionPacket.h b/Minecraft.World/EntityActionAtPositionPacket.h
index 35202017..788c764b 100644
--- a/Minecraft.World/EntityActionAtPositionPacket.h
+++ b/Minecraft.World/EntityActionAtPositionPacket.h
@@ -18,6 +18,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new EntityActionAtPositionPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<EntityActionAtPositionPacket>(); }
virtual int getId() { return 17; }
}; \ No newline at end of file
diff --git a/Minecraft.World/EntityDamageSource.cpp b/Minecraft.World/EntityDamageSource.cpp
index 22237bf1..8639156d 100644
--- a/Minecraft.World/EntityDamageSource.cpp
+++ b/Minecraft.World/EntityDamageSource.cpp
@@ -23,7 +23,7 @@ shared_ptr<Entity> EntityDamageSource::getEntity()
shared_ptr<ChatPacket> EntityDamageSource::getDeathMessagePacket(shared_ptr<LivingEntity> player)
{
- shared_ptr<ItemInstance> held = (entity != NULL) && entity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast<LivingEntity>(entity)->getCarriedItem() : nullptr;
+ shared_ptr<ItemInstance> held = (entity != nullptr) && entity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast<LivingEntity>(entity)->getCarriedItem() : nullptr;
wstring additional = L"";
if (entity->instanceof(eTYPE_SERVERPLAYER))
@@ -39,19 +39,19 @@ shared_ptr<ChatPacket> EntityDamageSource::getDeathMessagePacket(shared_ptr<Livi
}
}
- if ( (held != NULL) && held->hasCustomHoverName())
+ if ( (held != nullptr) && held->hasCustomHoverName())
{
- return shared_ptr<ChatPacket>( new ChatPacket(player->getNetworkName(), m_msgWithItemId, entity->GetType(), additional, held->getHoverName() ) );
+ return std::make_shared<ChatPacket>(player->getNetworkName(), m_msgWithItemId, entity->GetType(), additional, held->getHoverName());
}
else
{
- return shared_ptr<ChatPacket>( new ChatPacket(player->getNetworkName(), m_msgId, entity->GetType(), additional ) );
+ return std::make_shared<ChatPacket>(player->getNetworkName(), m_msgId, entity->GetType(), additional);
}
}
bool EntityDamageSource::scalesWithDifficulty()
{
- return (entity != NULL) && entity->instanceof(eTYPE_LIVINGENTITY) && !entity->instanceof(eTYPE_PLAYER);
+ return (entity != nullptr) && entity->instanceof(eTYPE_LIVINGENTITY) && !entity->instanceof(eTYPE_PLAYER);
}
// 4J: Copy function
diff --git a/Minecraft.World/EntityEventPacket.h b/Minecraft.World/EntityEventPacket.h
index a151dbdb..2b32dc29 100644
--- a/Minecraft.World/EntityEventPacket.h
+++ b/Minecraft.World/EntityEventPacket.h
@@ -18,7 +18,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new EntityEventPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<EntityEventPacket>(); }
virtual int getId() { return 38; }
};
diff --git a/Minecraft.World/EntityHorse.cpp b/Minecraft.World/EntityHorse.cpp
index 90c2a6b9..32c9eb2d 100644
--- a/Minecraft.World/EntityHorse.cpp
+++ b/Minecraft.World/EntityHorse.cpp
@@ -100,7 +100,7 @@ void EntityHorse::defineSynchedData()
{
Animal::defineSynchedData();
entityData->define(DATA_ID_HORSE_FLAGS, 0);
- entityData->define(DATA_ID_TYPE, (byte) 0);
+ entityData->define(DATA_ID_TYPE, static_cast<byte>(0));
entityData->define(DATA_ID_TYPE_VARIANT, 0);
entityData->define(DATA_ID_OWNER_NAME, L"");
entityData->define(DATA_ID_ARMOR, 0);
@@ -108,7 +108,7 @@ void EntityHorse::defineSynchedData()
void EntityHorse::setType(int i)
{
- entityData->set(DATA_ID_TYPE, (byte) i);
+ entityData->set(DATA_ID_TYPE, static_cast<byte>(i));
clearLayeredTextureInfo();
}
@@ -202,7 +202,7 @@ float EntityHorse::getFoalScale()
{
return 1.0f;
}
- return .5f + (float) (BABY_START_AGE - age) / (float) BABY_START_AGE * .5f;
+ return .5f + static_cast<float>(BABY_START_AGE - age) / static_cast<float>(BABY_START_AGE) * .5f;
}
@@ -259,7 +259,7 @@ int EntityHorse::getArmorType()
int EntityHorse::getArmorTypeForItem(shared_ptr<ItemInstance> armorItem)
{
- if (armorItem == NULL)
+ if (armorItem == nullptr)
{
return ARMOR_NONE;
}
@@ -350,7 +350,7 @@ bool EntityHorse::hurt(DamageSource *damagesource, float dmg)
if (isTamed())
{
shared_ptr<Entity> entity = damagesource->getDirectEntity();
- if (entity != NULL && entity->instanceof(eTYPE_PLAYER))
+ if (entity != nullptr && entity->instanceof(eTYPE_PLAYER))
{
shared_ptr<Player> attacker = dynamic_pointer_cast<Player>(entity);
attacker->canHarmPlayer(getOwnerName());
@@ -358,7 +358,7 @@ bool EntityHorse::hurt(DamageSource *damagesource, float dmg)
}
shared_ptr<Entity> attacker = damagesource->getEntity();
- if (rider.lock() != NULL && (rider.lock() == (attacker) ))
+ if (rider.lock() != nullptr && (rider.lock() == (attacker) ))
{
return false;
}
@@ -375,7 +375,7 @@ int EntityHorse::getArmorValue()
bool EntityHorse::isPushable()
{
- return rider.lock() == NULL;
+ return rider.lock() == nullptr;
}
// TODO: [EB]: Explain why this is being done - what side effect does getBiome have?
@@ -424,7 +424,7 @@ void EntityHorse::causeFallDamage(float fallDistance)
hurt(DamageSource::fall, dmg);
- if (rider.lock() != NULL)
+ if (rider.lock() != nullptr)
{
rider.lock()->hurt(DamageSource::fall, dmg);
}
@@ -456,9 +456,9 @@ int EntityHorse::getInventorySize()
void EntityHorse::createInventory()
{
shared_ptr<AnimalChest> old = inventory;
- inventory = shared_ptr<AnimalChest>( new AnimalChest(L"HorseChest", getInventorySize()) );
+ inventory = std::make_shared<AnimalChest>(L"HorseChest", getInventorySize());
inventory->setCustomName(getAName());
- if (old != NULL)
+ if (old != nullptr)
{
old->removeListener(this);
@@ -466,7 +466,7 @@ void EntityHorse::createInventory()
for (int slot = 0; slot < max; slot++)
{
shared_ptr<ItemInstance> item = old->getItem(slot);
- if (item != NULL)
+ if (item != nullptr)
{
inventory->setItem(slot, item->copy());
}
@@ -481,7 +481,7 @@ void EntityHorse::updateEquipment()
{
if (level && !level->isClientSide)
{
- setSaddled(inventory->getItem(INV_SLOT_SADDLE) != NULL);
+ setSaddled(inventory->getItem(INV_SLOT_SADDLE) != nullptr);
if (canWearArmor())
{
setArmorType(getArmorTypeForItem(inventory->getItem(INV_SLOT_ARMOR)));
@@ -666,7 +666,7 @@ void EntityHorse::playStepSound(int xt, int yt, int zt, int t)
if (!Tile::tiles[t]->material->isLiquid())
{
int type = getType();
- if (rider.lock() != NULL && type != TYPE_DONKEY && type != TYPE_MULE)
+ if (rider.lock() != nullptr && type != TYPE_DONKEY && type != TYPE_MULE)
{
gallopSoundCounter++;
if (gallopSoundCounter > 5 && gallopSoundCounter % 3 == 0)
@@ -795,7 +795,7 @@ intArray EntityHorse::getLayeredTextureLayers()
void EntityHorse::openInventory(shared_ptr<Player> player)
{
- if (!level->isClientSide && (rider.lock() == NULL || rider.lock() == player) && isTamed())
+ if (!level->isClientSide && (rider.lock() == nullptr || rider.lock() == player) && isTamed())
{
inventory->setCustomName(getAName());
player->openHorseInventory(dynamic_pointer_cast<EntityHorse>(shared_from_this()), inventory);
@@ -806,7 +806,7 @@ bool EntityHorse::mobInteract(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> itemstack = player->inventory->getSelected();
- if (itemstack != NULL && itemstack->id == Item::spawnEgg_Id)
+ if (itemstack != nullptr && itemstack->id == Item::spawnEgg_Id)
{
return Animal::mobInteract(player);
}
@@ -825,13 +825,13 @@ bool EntityHorse::mobInteract(shared_ptr<Player> player)
return true;
}
- if (isRidable() && rider.lock() != NULL)
+ if (isRidable() && rider.lock() != nullptr)
{
return Animal::mobInteract(player);
}
// consumables
- if (itemstack != NULL)
+ if (itemstack != nullptr)
{
bool itemUsed = false;
@@ -944,7 +944,7 @@ bool EntityHorse::mobInteract(shared_ptr<Player> player)
if (!isTamed() && !itemUsed)
{
- if (itemstack != NULL && itemstack->interactEnemy(player, dynamic_pointer_cast<LivingEntity>(shared_from_this())))
+ if (itemstack != nullptr && itemstack->interactEnemy(player, dynamic_pointer_cast<LivingEntity>(shared_from_this())))
{
return true;
}
@@ -985,17 +985,17 @@ bool EntityHorse::mobInteract(shared_ptr<Player> player)
}
}
- if (isRidable() && rider.lock() == NULL)
+ if (isRidable() && rider.lock() == nullptr)
{
// for name tag items and such, we must call the item's interaction
// method before riding
- if (itemstack != NULL && itemstack->interactEnemy(player, dynamic_pointer_cast<LivingEntity>(shared_from_this())))
+ if (itemstack != nullptr && itemstack->interactEnemy(player, dynamic_pointer_cast<LivingEntity>(shared_from_this())))
{
return true;
}
doPlayerRide(player);
- app.DebugPrintf("<EntityHorse::mobInteract> Horse speed: %f\n", (float) (getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue()));
+ app.DebugPrintf("<EntityHorse::mobInteract> Horse speed: %f\n", static_cast<float>(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue()));
return true;
}
@@ -1046,7 +1046,7 @@ bool EntityHorse::canWearBags()
bool EntityHorse::isImmobile()
{
- if (rider.lock() != NULL && isSaddled())
+ if (rider.lock() != nullptr && isSaddled())
{
return true;
}
@@ -1098,7 +1098,7 @@ int EntityHorse::nameYOffset()
}
else
{
- return (int) (-5 - getFoalScale() * 80.0f);
+ return static_cast<int>(-5 - getFoalScale() * 80.0f);
}
}
@@ -1127,7 +1127,7 @@ void EntityHorse::aiStep()
heal(1);
}
- if (!isEating() && rider.lock() == NULL && random->nextInt(300) == 0)
+ if (!isEating() && rider.lock() == nullptr && random->nextInt(300) == 0)
{
if (level->getTile(Mth::floor(x), Mth::floor(y) - 1, Mth::floor(z)) == Tile::grass_Id)
{
@@ -1144,7 +1144,7 @@ void EntityHorse::aiStep()
if (isBred() && !isAdult() && !isEating())
{
shared_ptr<EntityHorse> mommy = getClosestMommy(shared_from_this(), 16);
- if (mommy != NULL && distanceToSqr(mommy) > 4.0)
+ if (mommy != nullptr && distanceToSqr(mommy) > 4.0)
{
Path *pathentity = level->findPath(shared_from_this(), mommy, 16.0f, true, false, false, true);
setPath(pathentity);
@@ -1263,12 +1263,12 @@ void EntityHorse::openMouth()
bool EntityHorse::isReadyForParenting()
{
- return rider.lock() == NULL && riding == NULL && isTamed() && isAdult() && !isSterile() && getHealth() >= getMaxHealth();
+ return rider.lock() == nullptr && riding == nullptr && isTamed() && isAdult() && !isSterile() && getHealth() >= getMaxHealth();
}
bool EntityHorse::renderName()
{
- return hasCustomName() && rider.lock() == NULL;
+ return hasCustomName() && rider.lock() == nullptr;
}
bool EntityHorse::rideableEntity()
@@ -1320,12 +1320,12 @@ void EntityHorse::dropMyStuff()
void EntityHorse::dropInventory(shared_ptr<Entity> entity, shared_ptr<AnimalChest> animalchest)
{
- if (animalchest == NULL || level->isClientSide) return;
+ if (animalchest == nullptr || level->isClientSide) return;
for (int i = 0; i < animalchest->getContainerSize(); i++)
{
shared_ptr<ItemInstance> itemstack = animalchest->getItem(i);
- if (itemstack == NULL)
+ if (itemstack == nullptr)
{
continue;
}
@@ -1349,7 +1349,7 @@ void EntityHorse::travel(float xa, float ya)
{
// If the entity is not ridden by Player, then execute the normal
// Entityliving code
- if (rider.lock() == NULL || !isSaddled())
+ if (rider.lock() == nullptr || !isSaddled())
{
footSize = .5f;
flyingSpeed = .02f;
@@ -1407,7 +1407,7 @@ void EntityHorse::travel(float xa, float ya)
flyingSpeed = getSpeed() * .1f;
if (!level->isClientSide)
{
- setSpeed((float) (getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue()));
+ setSpeed(static_cast<float>(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue()));
Animal::travel(xa, ya);
}
@@ -1455,11 +1455,11 @@ void EntityHorse::addAdditonalSaveData(CompoundTag *tag)
{
shared_ptr<ItemInstance> stack = inventory->getItem(i);
- if (stack != NULL)
+ if (stack != nullptr)
{
CompoundTag *compoundTag = new CompoundTag();
- compoundTag->putByte(L"Slot", (byte) i);
+ compoundTag->putByte(L"Slot", static_cast<byte>(i));
stack->save(compoundTag);
listTag->add(compoundTag);
@@ -1468,11 +1468,11 @@ void EntityHorse::addAdditonalSaveData(CompoundTag *tag)
tag->put(L"Items", listTag);
}
- if (inventory->getItem(INV_SLOT_ARMOR) != NULL)
+ if (inventory->getItem(INV_SLOT_ARMOR) != nullptr)
{
tag->put(L"ArmorItem", inventory->getItem(INV_SLOT_ARMOR)->save(new CompoundTag(L"ArmorItem")));
}
- if (inventory->getItem(INV_SLOT_SADDLE) != NULL)
+ if (inventory->getItem(INV_SLOT_SADDLE) != nullptr)
{
tag->put(L"SaddleItem", inventory->getItem(INV_SLOT_SADDLE)->save(new CompoundTag(L"SaddleItem")));
}
@@ -1498,7 +1498,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag *tag)
// 4J: This is for handling old save data, not needed on console
/*AttributeInstance *oldSpeedAttribute = getAttributes()->getInstance(SharedMonsterAttributes::MOVEMENT_SPEED);
- if (oldSpeedAttribute != NULL)
+ if (oldSpeedAttribute != nullptr)
{
getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(oldSpeedAttribute->getBaseValue() * 0.25f);
}*/
@@ -1523,7 +1523,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag *tag)
if (tag->contains(L"ArmorItem"))
{
shared_ptr<ItemInstance> armor = ItemInstance::fromTag(tag->getCompound(L"ArmorItem"));
- if (armor != NULL && isHorseArmor(armor->id))
+ if (armor != nullptr && isHorseArmor(armor->id))
{
inventory->setItem(INV_SLOT_ARMOR, armor);
}
@@ -1532,14 +1532,14 @@ void EntityHorse::readAdditionalSaveData(CompoundTag *tag)
if (tag->contains(L"SaddleItem"))
{
shared_ptr<ItemInstance> 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"))
{
- inventory->setItem(INV_SLOT_SADDLE, shared_ptr<ItemInstance>( new ItemInstance(Item::saddle)));
+ inventory->setItem(INV_SLOT_SADDLE, std::make_shared<ItemInstance>(Item::saddle));
}
updateEquipment();
}
@@ -1566,7 +1566,7 @@ bool EntityHorse::canMate(shared_ptr<Animal> partner)
shared_ptr<AgableMob> EntityHorse::getBreedOffspring(shared_ptr<AgableMob> partner)
{
shared_ptr<EntityHorse> horsePartner = dynamic_pointer_cast<EntityHorse>(partner);
- shared_ptr<EntityHorse> baby = shared_ptr<EntityHorse>( new EntityHorse(level) );
+ shared_ptr<EntityHorse> baby = std::make_shared<EntityHorse>(level);
int type = getType();
int partnerType = horsePartner->getType();
@@ -1637,10 +1637,10 @@ MobGroupData *EntityHorse::finalizeMobSpawn(MobGroupData *groupData, int extraDa
int type = 0;
int variant = 0;
- if ( dynamic_cast<HorseGroupData *>(groupData) != NULL )
+ if ( dynamic_cast<HorseGroupData *>(groupData) != nullptr )
{
- type = ((HorseGroupData *) groupData)->horseType;
- variant = ((HorseGroupData *) groupData)->horseVariant & 0xff | (random->nextInt(MARKINGS) << 8);
+ type = static_cast<HorseGroupData *>(groupData)->horseType;
+ variant = static_cast<HorseGroupData *>(groupData)->horseVariant & 0xff | (random->nextInt(MARKINGS) << 8);
}
else
{
@@ -1744,7 +1744,7 @@ void EntityHorse::onPlayerJump(int jumpAmount)
}
else
{
- playerJumpPendingScale = .4f + .4f * (float) jumpAmount / 90.0f;
+ playerJumpPendingScale = .4f + .4f * static_cast<float>(jumpAmount) / 90.0f;
}
}
}
diff --git a/Minecraft.World/EntityIO.cpp b/Minecraft.World/EntityIO.cpp
index 086015dc..9c7c64d4 100644
--- a/Minecraft.World/EntityIO.cpp
+++ b/Minecraft.World/EntityIO.cpp
@@ -135,8 +135,8 @@ shared_ptr<Entity> EntityIO::newEntity(const wstring& id, Level *level)
if(it != idCreateMap->end() )
{
entityCreateFn create = it->second;
- if (create != NULL) entity = shared_ptr<Entity>(create(level));
- if( ( entity != NULL ) && entity->GetType() == eTYPE_ENDERDRAGON )
+ if (create != nullptr) entity = shared_ptr<Entity>(create(level));
+ if( ( entity != nullptr ) && entity->GetType() == eTYPE_ENDERDRAGON )
{
dynamic_pointer_cast<EnderDragon>(entity)->AddParts(); // 4J added to finalise creation
}
@@ -173,14 +173,14 @@ shared_ptr<Entity> EntityIO::loadStatic(CompoundTag *tag, Level *level)
if(it != idCreateMap->end() )
{
entityCreateFn create = it->second;
- if (create != NULL) entity = shared_ptr<Entity>(create(level));
- if( ( entity != NULL ) && entity->GetType() == eTYPE_ENDERDRAGON )
+ if (create != nullptr) entity = shared_ptr<Entity>(create(level));
+ if( ( entity != nullptr ) && entity->GetType() == eTYPE_ENDERDRAGON )
{
dynamic_pointer_cast<EnderDragon>(entity)->AddParts(); // 4J added to finalise creation
}
}
- if (entity != NULL)
+ if (entity != nullptr)
{
entity->load(tag);
}
@@ -201,14 +201,14 @@ shared_ptr<Entity> EntityIO::newById(int id, Level *level)
if(it != numCreateMap->end() )
{
entityCreateFn create = it->second;
- if (create != NULL) entity = shared_ptr<Entity>(create(level));
- if( ( entity != NULL ) && entity->GetType() == eTYPE_ENDERDRAGON )
+ if (create != nullptr) entity = shared_ptr<Entity>(create(level));
+ if( ( entity != nullptr ) && entity->GetType() == eTYPE_ENDERDRAGON )
{
dynamic_pointer_cast<EnderDragon>(entity)->AddParts(); // 4J added to finalise creation
}
}
- if (entity != NULL)
+ if (entity != nullptr)
{
}
else
@@ -229,8 +229,8 @@ shared_ptr<Entity> EntityIO::newByEnumType(eINSTANCEOF eType, Level *level)
if(it2 != numCreateMap->end() )
{
entityCreateFn create = it2->second;
- if (create != NULL) entity = shared_ptr<Entity>(create(level));
- if( ( entity != NULL ) && entity->GetType() == eTYPE_ENDERDRAGON )
+ if (create != nullptr) entity = shared_ptr<Entity>(create(level));
+ if( ( entity != nullptr ) && entity->GetType() == eTYPE_ENDERDRAGON )
{
dynamic_pointer_cast<EnderDragon>(entity)->AddParts(); // 4J added to finalise creation
}
diff --git a/Minecraft.World/EntityPos.cpp b/Minecraft.World/EntityPos.cpp
index 38b50573..02f716ed 100644
--- a/Minecraft.World/EntityPos.cpp
+++ b/Minecraft.World/EntityPos.cpp
@@ -58,5 +58,5 @@ EntityPos *EntityPos::lerp(shared_ptr<Entity> e, float f)
{
return new EntityPos(yrd, xrd);
}
- return NULL;
+ return nullptr;
} \ No newline at end of file
diff --git a/Minecraft.World/EntitySelector.cpp b/Minecraft.World/EntitySelector.cpp
index 36c7bf88..0f575c73 100644
--- a/Minecraft.World/EntitySelector.cpp
+++ b/Minecraft.World/EntitySelector.cpp
@@ -12,7 +12,7 @@ bool AliveEntitySelector::matches(shared_ptr<Entity> entity) const
bool ContainerEntitySelector::matches(shared_ptr<Entity> entity) const
{
- return (dynamic_pointer_cast<Container>(entity) != NULL) && entity->isAlive();
+ return (dynamic_pointer_cast<Container>(entity) != nullptr) && entity->isAlive();
}
MobCanWearArmourEntitySelector::MobCanWearArmourEntitySelector(shared_ptr<ItemInstance> item)
@@ -27,7 +27,7 @@ bool MobCanWearArmourEntitySelector::matches(shared_ptr<Entity> entity) const
shared_ptr<LivingEntity> mob = dynamic_pointer_cast<LivingEntity>(entity);
- if (mob->getCarried(Mob::getEquipmentSlotForItem(item)) != NULL) return false;
+ if (mob->getCarried(Mob::getEquipmentSlotForItem(item)) != nullptr) return false;
if ( mob->instanceof(eTYPE_MOB) )
{
diff --git a/Minecraft.World/ExperienceItem.cpp b/Minecraft.World/ExperienceItem.cpp
index 433c1207..a28a5859 100644
--- a/Minecraft.World/ExperienceItem.cpp
+++ b/Minecraft.World/ExperienceItem.cpp
@@ -27,6 +27,6 @@ shared_ptr<ItemInstance> ExperienceItem::use(shared_ptr<ItemInstance> itemInstan
itemInstance->count--;
}
level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f));
- if (!level->isClientSide) level->addEntity( shared_ptr<ThrownExpBottle>( new ThrownExpBottle(level, player) ));
+ if (!level->isClientSide) level->addEntity(std::make_shared<ThrownExpBottle>(level, player));
return itemInstance;
} \ No newline at end of file
diff --git a/Minecraft.World/ExperienceOrb.cpp b/Minecraft.World/ExperienceOrb.cpp
index 9fed6d71..cc4b12bc 100644
--- a/Minecraft.World/ExperienceOrb.cpp
+++ b/Minecraft.World/ExperienceOrb.cpp
@@ -35,11 +35,11 @@ ExperienceOrb::ExperienceOrb(Level *level, double x, double y, double z, int cou
heightOffset = bbHeight / 2.0f;
setPos(x, y, z);
- yRot = (float) (Math::random() * 360);
+ yRot = static_cast<float>(Math::random() * 360);
- xd = (float) (Math::random() * 0.2f - 0.1f) * 2;
- yd = (float) (Math::random() * 0.2) * 2;
- zd = (float) (Math::random() * 0.2f - 0.1f) * 2;
+ xd = static_cast<float>(Math::random() * 0.2f - 0.1f) * 2;
+ yd = static_cast<float>(Math::random() * 0.2) * 2;
+ zd = static_cast<float>(Math::random() * 0.2f - 0.1f) * 2;
value = count;
}
@@ -70,7 +70,7 @@ int ExperienceOrb::getLightColor(float a)
int br1 = (br) & 0xff;
int br2 = (br >> 16) & 0xff;
- br1 += (int) (l * 15 * 16);
+ br1 += static_cast<int>(l * 15 * 16);
if (br1 > 15 * 16) br1 = 15 * 16;
// br2 = 15*16;
return br1 | br2 << 16;
@@ -99,13 +99,13 @@ void ExperienceOrb::tick()
// Usually exp orbs will get created at the same time so smoothen the lagspikes
if (followingTime < tickCount - SharedConstants::TICKS_PER_SECOND + (entityId % 100))
{
- if (followingPlayer == NULL || followingPlayer->distanceToSqr(shared_from_this()) > maxDist * maxDist)
+ if (followingPlayer == nullptr || followingPlayer->distanceToSqr(shared_from_this()) > maxDist * maxDist)
{
followingPlayer = level->getNearestPlayer(shared_from_this(), maxDist);
}
followingTime = tickCount;
}
- if (followingPlayer != NULL)
+ if (followingPlayer != nullptr)
{
double xdd = (followingPlayer->x - x) / maxDist;
double ydd = (followingPlayer->y + followingPlayer->getHeadHeight() - y) / maxDist;
@@ -176,9 +176,9 @@ bool ExperienceOrb::hurt(DamageSource *source, float damage)
void ExperienceOrb::addAdditonalSaveData(CompoundTag *entityTag)
{
- entityTag->putShort(L"Health", (byte) health);
- entityTag->putShort(L"Age", (short) age);
- entityTag->putShort(L"Value", (short) value);
+ entityTag->putShort(L"Health", static_cast<byte>(health));
+ entityTag->putShort(L"Age", static_cast<short>(age));
+ entityTag->putShort(L"Value", static_cast<short>(value));
}
void ExperienceOrb::readAdditionalSaveData(CompoundTag *tag)
diff --git a/Minecraft.World/ExplodePacket.cpp b/Minecraft.World/ExplodePacket.cpp
index 30d09e46..07626161 100644
--- a/Minecraft.World/ExplodePacket.cpp
+++ b/Minecraft.World/ExplodePacket.cpp
@@ -34,9 +34,9 @@ ExplodePacket::ExplodePacket(double x, double y, double z, float r, unordered_se
if (knockback != nullptr)
{
- knockbackX = (float) knockback->x;
- knockbackY = (float) knockback->y;
- knockbackZ = (float) knockback->z;
+ knockbackX = static_cast<float>(knockback->x);
+ knockbackY = static_cast<float>(knockback->y);
+ knockbackZ = static_cast<float>(knockback->z);
}
}
@@ -52,14 +52,14 @@ void ExplodePacket::read(DataInputStream *dis) //throws IOException
r = dis->readFloat();
int count = dis->readInt();
- int xp = (int)x;
- int yp = (int)y;
- int zp = (int)z;
+ int xp = static_cast<int>(x);
+ int yp = static_cast<int>(y);
+ int zp = static_cast<int>(z);
for (int i=0; i<count; i++)
{
- int xx = ((signed char)dis->readByte())+xp;
- int yy = ((signed char)dis->readByte())+yp;
- int zz = ((signed char)dis->readByte())+zp;
+ int xx = static_cast<signed char>(dis->readByte())+xp;
+ int yy = static_cast<signed char>(dis->readByte())+yp;
+ int zz = static_cast<signed char>(dis->readByte())+zp;
toBlow.push_back( TilePos(xx, yy, zz) );
}
}
@@ -79,11 +79,11 @@ void ExplodePacket::write(DataOutputStream *dos) //throws IOException
dos->writeDouble(y);
dos->writeDouble(z);
dos->writeFloat(r);
- dos->writeInt((int)toBlow.size());
+ dos->writeInt(static_cast<int>(toBlow.size()));
- int xp = (int)x;
- int yp = (int)y;
- int zp = (int)z;
+ int xp = static_cast<int>(x);
+ int yp = static_cast<int>(y);
+ int zp = static_cast<int>(z);
for ( const TilePos& tp : toBlow )
{
@@ -108,7 +108,7 @@ void ExplodePacket::handle(PacketListener *listener)
int ExplodePacket::getEstimatedSize()
{
- return 8*3+4+4+(int)toBlow.size()*3+12;
+ return 8*3+4+4+static_cast<int>(toBlow.size())*3+12;
}
float ExplodePacket::getKnockbackX()
diff --git a/Minecraft.World/ExplodePacket.h b/Minecraft.World/ExplodePacket.h
index d4d8b3f9..caf77c77 100644
--- a/Minecraft.World/ExplodePacket.h
+++ b/Minecraft.World/ExplodePacket.h
@@ -32,6 +32,6 @@ public:
float getKnockbackZ();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ExplodePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ExplodePacket>(); }
virtual int getId() { return 60; }
}; \ No newline at end of file
diff --git a/Minecraft.World/Explosion.cpp b/Minecraft.World/Explosion.cpp
index ab305a02..65e719e4 100644
--- a/Minecraft.World/Explosion.cpp
+++ b/Minecraft.World/Explosion.cpp
@@ -72,10 +72,10 @@ void Explosion::explode()
if (t > 0)
{
Tile *tile = Tile::tiles[t];
- float resistance = source != NULL ? source->getTileExplosionResistance(this, level, xt, yt, zt, tile) : tile->getExplosionResistance(source);
+ float resistance = source != nullptr ? source->getTileExplosionResistance(this, level, xt, yt, zt, tile) : tile->getExplosionResistance(source);
remainingPower -= (resistance + 0.3f) * stepSize;
}
- if (remainingPower > 0&& (source == NULL || source->shouldTileExplode(this, level, xt, yt, zt, t, remainingPower)))
+ if (remainingPower > 0&& (source == nullptr || source->shouldTileExplode(this, level, xt, yt, zt, t, remainingPower)))
{
toBlow.insert(TilePos(xt, yt, zt));
}
@@ -143,7 +143,7 @@ void Explosion::explode()
double sp = level->getSeenPercent(center, e->bb);
double pow = (1 - dist) * sp;
- if(canDamage) e->hurt(DamageSource::explosion(this), (int) ((pow * pow + pow) / 2 * 8 * r + 1));
+ if(canDamage) e->hurt(DamageSource::explosion(this), static_cast<int>((pow * pow + pow) / 2 * 8 * r + 1));
double kbPower = ProtectionEnchantment::getExplosionKnockbackAfterDampener(e, pow);
e->xd += xa *kbPower;
@@ -163,7 +163,7 @@ void Explosion::explode()
}
-void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect/*=NULL*/) // 4J - added toBlowDirect parameter
+void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect/*=nullptr*/) // 4J - added toBlowDirect parameter
{
level->playSound(x, y, z, eSoundType_RANDOM_EXPLODE, 4, (1 + (level->random->nextFloat() - level->random->nextFloat()) * 0.2f) * 0.7f);
if (r < 2 || !destroyBlocks)
@@ -185,7 +185,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlo
app.DebugPrintf("Finalizing explosion size %d\n",toBlow.size());
static const int MAX_EXPLODE_PARTICLES = 50;
// 4J - try and make at most MAX_EXPLODE_PARTICLES pairs of particles
- int fraction = (int)toBlowArray->size() / MAX_EXPLODE_PARTICLES;
+ int fraction = static_cast<int>(toBlowArray->size()) / MAX_EXPLODE_PARTICLES;
if( fraction == 0 ) fraction = 1;
size_t j = toBlowArray->size() - 1;
//for (size_t j = toBlowArray->size() - 1; j >= 0; j--)
@@ -262,7 +262,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlo
}
PIXEndNamedEvent();
- if( toBlowDirect == NULL ) delete toBlowArray;
+ if( toBlowDirect == nullptr ) delete toBlowArray;
}
Explosion::playerVec3Map *Explosion::getHitPlayers()
@@ -281,7 +281,7 @@ Vec3 *Explosion::getHitPlayerKnockback( shared_ptr<Player> player )
shared_ptr<LivingEntity> Explosion::getSourceMob()
{
- if (source == NULL) return nullptr;
+ if (source == nullptr) return nullptr;
if (source->instanceof(eTYPE_PRIMEDTNT)) return dynamic_pointer_cast<PrimedTnt>(source)->getOwner();
if (source->instanceof(eTYPE_LIVINGENTITY)) return dynamic_pointer_cast<LivingEntity>(source);
return nullptr;
diff --git a/Minecraft.World/Explosion.h b/Minecraft.World/Explosion.h
index 1fe1e57b..7cefb44b 100644
--- a/Minecraft.World/Explosion.h
+++ b/Minecraft.World/Explosion.h
@@ -36,7 +36,7 @@ public:
void explode();
public:
- void finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect = NULL); // 4J - added toBlow parameter
+ void finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect = nullptr); // 4J - added toBlow parameter
playerVec3Map *getHitPlayers();
Vec3 *getHitPlayerKnockback( shared_ptr<Player> player );
shared_ptr<LivingEntity> getSourceMob();
diff --git a/Minecraft.World/EyeOfEnderSignal.cpp b/Minecraft.World/EyeOfEnderSignal.cpp
index 95747a89..ca76b272 100644
--- a/Minecraft.World/EyeOfEnderSignal.cpp
+++ b/Minecraft.World/EyeOfEnderSignal.cpp
@@ -80,9 +80,9 @@ void EyeOfEnderSignal::lerpMotion(double xd, double yd, double zd)
this->zd = zd;
if (xRotO == 0 && yRotO == 0)
{
- float sd = (float) sqrt(xd * xd + zd * zd);
- yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRotO = xRot = (float) (atan2(yd, (double)sd) * 180 / PI);
+ float sd = static_cast<float>(sqrt(xd * xd + zd * zd));
+ yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRotO = xRot = static_cast<float>(atan2(yd, (double)sd) * 180 / PI);
}
}
@@ -97,9 +97,9 @@ void EyeOfEnderSignal::tick()
y += yd;
z += zd;
- float sd = (float) sqrt(xd * xd + zd * zd);
- yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRot = (float) (atan2(yd, (double)sd) * 180 / PI);
+ float sd = static_cast<float>(sqrt(xd * xd + zd * zd));
+ yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRot = static_cast<float>(atan2(yd, (double)sd) * 180 / PI);
while (xRot - xRotO < -180)
xRotO -= 360;
@@ -117,8 +117,8 @@ void EyeOfEnderSignal::tick()
if (!level->isClientSide)
{
double dx = tx - x, dz = tz - z;
- float tdist = (float) sqrt(dx * dx + dz * dz);
- float angle = (float) atan2(dz, dx);
+ float tdist = static_cast<float>(sqrt(dx * dx + dz * dz));
+ float angle = static_cast<float>(atan2(dz, dx));
double tspeed = (sd + (tdist - sd) * .0025);
if (tdist < 1)
{
@@ -163,11 +163,11 @@ void EyeOfEnderSignal::tick()
remove();
if (surviveAfterDeath)
{
- level->addEntity(shared_ptr<ItemEntity>( new ItemEntity(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Item::eyeOfEnder)))));
+ level->addEntity(std::make_shared<ItemEntity>(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Item::eyeOfEnder))));
}
else
{
- level->levelEvent(LevelEvent::PARTICLES_EYE_OF_ENDER_DEATH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), 0);
+ level->levelEvent(LevelEvent::PARTICLES_EYE_OF_ENDER_DEATH, static_cast<int>(Math::round(x)), static_cast<int>(Math::round(y)), static_cast<int>(Math::round(z)), 0);
}
}
}
diff --git a/Minecraft.World/FallingTile.cpp b/Minecraft.World/FallingTile.cpp
index c0eb7d22..0ff776fd 100644
--- a/Minecraft.World/FallingTile.cpp
+++ b/Minecraft.World/FallingTile.cpp
@@ -24,7 +24,7 @@ void FallingTile::_init()
hurtEntities = false;
fallDamageMax = 40;
fallDamageAmount = 2;
- tileData = NULL;
+ tileData = nullptr;
// 4J Added so that client-side falling tiles can fall through blocks
// This fixes a bug on the host where the tile update from the server comes in before the client-side falling tile
@@ -136,11 +136,11 @@ void FallingTile::tick()
{
hv->onLand(level, xt, yt, zt, data);
}
- if (tileData != NULL && Tile::tiles[tile]->isEntityTile())
+ if (tileData != nullptr && Tile::tiles[tile]->isEntityTile())
{
shared_ptr<TileEntity> tileEntity = level->getTileEntity(xt, yt, zt);
- if (tileEntity != NULL)
+ if (tileEntity != nullptr)
{
CompoundTag *swap = new CompoundTag();
tileEntity->save(swap);
@@ -161,13 +161,13 @@ void FallingTile::tick()
}
else
{
- if(dropItem && !cancelDrop) spawnAtLocation( shared_ptr<ItemInstance>(new ItemInstance(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data))), 0);
+ if(dropItem && !cancelDrop) spawnAtLocation(std::make_shared<ItemInstance>(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data)), 0);
}
}
}
else if ( (time > 20 * 5 && !level->isClientSide && (yt < 1 || yt > Level::maxBuildHeight)) || (time > 20 * 30))
{
- if(dropItem) spawnAtLocation( shared_ptr<ItemInstance>( new ItemInstance(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data) )), 0);
+ if(dropItem) spawnAtLocation(std::make_shared<ItemInstance>(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data)), 0);
remove();
}
}
@@ -212,15 +212,15 @@ void FallingTile::causeFallDamage(float distance)
void FallingTile::addAdditonalSaveData(CompoundTag *tag)
{
- tag->putByte(L"Tile", (byte) tile);
+ tag->putByte(L"Tile", static_cast<byte>(tile));
tag->putInt(L"TileID", tile);
- tag->putByte(L"Data", (byte) data);
- tag->putByte(L"Time", (byte) time);
+ tag->putByte(L"Data", static_cast<byte>(data));
+ tag->putByte(L"Time", static_cast<byte>(time));
tag->putBoolean(L"DropItem", dropItem);
tag->putBoolean(L"HurtEntities", hurtEntities);
tag->putFloat(L"FallHurtAmount", fallDamageAmount);
tag->putInt(L"FallHurtMax", fallDamageMax);
- if (tileData != NULL) tag->putCompound(L"TileEntityData", tileData);
+ if (tileData != nullptr) tag->putCompound(L"TileEntityData", tileData);
}
void FallingTile::readAdditionalSaveData(CompoundTag *tag)
diff --git a/Minecraft.World/FarmTile.cpp b/Minecraft.World/FarmTile.cpp
index 6cbe40ac..39bf685f 100644
--- a/Minecraft.World/FarmTile.cpp
+++ b/Minecraft.World/FarmTile.cpp
@@ -8,8 +8,8 @@
FarmTile::FarmTile(int id) : Tile(id, Material::dirt,isSolidRender())
{
- iconWet = NULL;
- iconDry = NULL;
+ iconWet = nullptr;
+ iconDry = nullptr;
setTicking(true);
updateDefaultShape();
diff --git a/Minecraft.World/FastNoise.cpp b/Minecraft.World/FastNoise.cpp
index 91d039b3..399c427f 100644
--- a/Minecraft.World/FastNoise.cpp
+++ b/Minecraft.World/FastNoise.cpp
@@ -34,7 +34,7 @@ FastNoise::~FastNoise()
doubleArray FastNoise::getRegion(doubleArray buffer, double x, double y, double z, int xSize, int ySize, int zSize, double xScale, double yScale, double zScale)
{
- if (buffer.data == NULL) buffer = doubleArray(xSize * ySize * zSize);
+ if (buffer.data == nullptr) buffer = doubleArray(xSize * ySize * zSize);
else for (unsigned int i = 0; i < buffer.length; i++)
buffer[i] = 0;
@@ -50,23 +50,23 @@ doubleArray FastNoise::getRegion(doubleArray buffer, double x, double y, double
for (int zp = 0; zp < zSize; zp++)
{
double zz = (z + zp) * zScale;
- int Z = (int) zz;
+ int Z = static_cast<int>(zz);
if (zz < Z) Z -= 1;
- int zl = (int) ((zz - Z) * 65536);
+ int zl = static_cast<int>((zz - Z) * 65536);
for (int yp = 0; yp < ySize; yp++)
{
double yy = (y + yp) * yScale;
- int Y = (int) yy;
+ int Y = static_cast<int>(yy);
if (yy < Y) Y -= 1;
- int yl = (int) ((yy - Y) * 65536);
+ int yl = static_cast<int>((yy - Y) * 65536);
for (int xp = 0; xp < xSize; xp++)
{
double xx = (x + xp) * xScale;
- int X = (int) xx;
+ int X = static_cast<int>(xx);
if (xx < X) X -= 1;
- int xl = (int) ((xx - X) * 65536);
+ int xl = static_cast<int>((xx - X) * 65536);
int X0 = (X + 0) * AA;
int X1 = (X + 1) * AA;
diff --git a/Minecraft.World/FenceGateTile.cpp b/Minecraft.World/FenceGateTile.cpp
index a8de450e..bd1326a9 100644
--- a/Minecraft.World/FenceGateTile.cpp
+++ b/Minecraft.World/FenceGateTile.cpp
@@ -25,7 +25,7 @@ AABB *FenceGateTile::getAABB(Level *level, int x, int y, int z)
int data = level->getData(x, y, z);
if (isOpen(data))
{
- return NULL;
+ return nullptr;
}
// 4J Brought forward change from 1.2.3 to fix hit box rotation
if (data == Direction::NORTH || data == Direction::SOUTH)
@@ -86,7 +86,7 @@ bool FenceGateTile::use(Level *level, int x, int y, int z, shared_ptr<Player> pl
if (soundOnly)
{
// 4J - added - just do enough to play the sound
- level->levelEvent(player, LevelEvent::SOUND_OPEN_DOOR, x, y, z, 0); // 4J - changed event to pass player rather than NULL as the source of the event so we can filter the broadcast properly
+ level->levelEvent(player, LevelEvent::SOUND_OPEN_DOOR, x, y, z, 0); // 4J - changed event to pass player rather than nullptr as the source of the event so we can filter the broadcast properly
return false;
}
diff --git a/Minecraft.World/FenceTile.cpp b/Minecraft.World/FenceTile.cpp
index 39f4aac1..83c31167 100644
--- a/Minecraft.World/FenceTile.cpp
+++ b/Minecraft.World/FenceTile.cpp
@@ -122,7 +122,7 @@ bool FenceTile::connectsTo(LevelSource *level, int x, int y, int z)
return true;
}
Tile *tileInstance = Tile::tiles[tile];
- if (tileInstance != NULL)
+ if (tileInstance != nullptr)
{
if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped())
{
diff --git a/Minecraft.World/File.cpp b/Minecraft.World/File.cpp
index 82e593dc..11871e42 100644
--- a/Minecraft.World/File.cpp
+++ b/Minecraft.World/File.cpp
@@ -24,7 +24,7 @@ File::File( const File &parent, const std::wstring& child )
}
//Creates a new File instance by converting the given pathname string into an abstract pathname.
-File::File( const wstring& pathname ) //: parent( NULL )
+File::File( const wstring& pathname ) //: parent( nullptr )
{
// #ifndef _CONTENT_PACKAGE
// char buf[256];
@@ -62,7 +62,7 @@ File::File( const wstring& pathname ) //: parent( NULL )
if( path.back().compare( pathRoot ) != 0 )
this->parent = new File( &path );
else
- this->parent = NULL;
+ this->parent = nullptr;
}
*/
}
@@ -75,7 +75,7 @@ File::File( const std::wstring& parent, const std::wstring& child ) //: m_abstr
//Creates a new File instance by converting the given path vector into an abstract pathname.
/*
-File::File( vector<wstring> *path ) : parent( NULL )
+File::File( vector<wstring> *path ) : parent( nullptr )
{
m_abstractPathName = path->back();
path->pop_back();
@@ -86,7 +86,7 @@ if( path->size() > 0 )
if( path->back().compare( pathRoot ) != 0 )
this->parent = new File( path );
else
-this->parent = NULL;
+this->parent = nullptr;
}
}
*/
@@ -120,10 +120,10 @@ bool File::_delete()
bool File::mkdir() const
{
#ifdef _UNICODE
- return CreateDirectory( getPath().c_str(), NULL) != 0;
+ return CreateDirectory( getPath().c_str(), nullptr) != 0;
#else
- return CreateDirectory( wstringtofilename(getPath()), NULL) != 0;
+ return CreateDirectory( wstringtofilename(getPath()), nullptr) != 0;
#endif
}
@@ -167,7 +167,7 @@ bool File::mkdirs() const
#ifdef _UNICODE
if( GetFileAttributes( pathToHere.c_str() ) == -1 )
{
- DWORD result = CreateDirectory( pathToHere.c_str(), NULL);
+ DWORD result = CreateDirectory( pathToHere.c_str(), nullptr);
if( result == 0 )
{
// Failed to create
@@ -177,7 +177,7 @@ bool File::mkdirs() const
#else
if( GetFileAttributes( wstringtofilename(pathToHere) ) == -1 )
{
- DWORD result = CreateDirectory( wstringtofilename(pathToHere), NULL);
+ DWORD result = CreateDirectory( wstringtofilename(pathToHere), nullptr);
if( result == 0 )
{
// Failed to create
@@ -321,7 +321,7 @@ std::vector<File *> *File::listFiles() const
else
sprintf(filePath,"%s/%s",getUsrDirPath(), lpFileName );
- bool exists = sceFiosDirectoryExistsSync( NULL, filePath );
+ bool exists = sceFiosDirectoryExistsSync( nullptr, filePath );
if( !exists )
{
app.DebugPrintf("\nsceFiosDirectoryExistsSync - Directory doesn't exist\n");
@@ -334,7 +334,7 @@ std::vector<File *> *File::listFiles() const
SceFiosDH dh = SCE_FIOS_DH_INVALID;
SceFiosBuffer buf;
buf.length = 0;
- SceFiosOp op = sceFiosDHOpen(NULL, &dh, filePath, buf);
+ SceFiosOp op = sceFiosDHOpen(nullptr, &dh, filePath, buf);
int err = sceFiosOpWait(op);
if( err != SCE_FIOS_OK )
@@ -346,24 +346,24 @@ std::vector<File *> *File::listFiles() const
buf.set(pBuf, (size_t)size);
sceFiosOpDelete( op );
- sceFiosDHClose(NULL, dh);
+ sceFiosDHClose(nullptr, dh);
- err = sceFiosDHOpenSync(NULL, &dh, filePath, buf);
+ err = sceFiosDHOpenSync(nullptr, &dh, filePath, buf);
if( err != SCE_FIOS_OK )
{
app.DebugPrintf("\nsceFiosDHOpenSync = 0x%x\n",err);
}
SceFiosDirEntry entry;
ZeroMemory(&entry, sizeof(SceFiosDirEntry));
- err = sceFiosDHReadSync(NULL, dh, &entry);
+ err = sceFiosDHReadSync(nullptr, dh, &entry);
while( err == SCE_FIOS_OK)
{
vOutput->push_back( new File( *this, filenametowstring( entry.fullPath + entry.offsetToName ) ) );
ZeroMemory(&entry, sizeof(SceFiosDirEntry));
- err = sceFiosDHReadSync(NULL, dh, &entry);
+ err = sceFiosDHReadSync(nullptr, dh, &entry);
};
- sceFiosDHClose(NULL, dh);
+ sceFiosDHClose(nullptr, dh);
delete pBuf;
#else
@@ -418,7 +418,7 @@ std::vector<File *> *File::listFiles(FileFilter *filter) const
{
// TODO 4J Stu - Also need to check for I/O errors?
if( !isDirectory() )
- return NULL;
+ return nullptr;
std::vector<File *> *vOutput = new std::vector<File *>();
@@ -576,7 +576,7 @@ int64_t File::length()
// check if the file exists first
SceFiosStat statData;
- if(sceFiosStatSync(NULL, filePath, &statData) != SCE_FIOS_OK)
+ if(sceFiosStatSync(nullptr, filePath, &statData) != SCE_FIOS_OK)
{
return 0;
}
@@ -660,7 +660,7 @@ const std::wstring File::getPath() const
{
/*
wstring path;
- if ( parent != NULL)
+ if ( parent != nullptr)
path = parent->getPath();
else
path = wstring(pathRoot);
@@ -673,7 +673,7 @@ const std::wstring File::getPath() const
std::wstring File::getName() const
{
- unsigned int sep = (unsigned int )(m_abstractPathName.find_last_of( this->pathSeparator ));
+ size_t sep = m_abstractPathName.find_last_of(this->pathSeparator);
return m_abstractPathName.substr( sep + 1, m_abstractPathName.length() );
}
@@ -687,7 +687,7 @@ int File::hash_fnct(const File &k)
{
int hashCode = 0;
- //if (k->parent != NULL)
+ //if (k->parent != nullptr)
// hashCode = hash_fnct(k->getParent());
wchar_t *ref = (wchar_t *) k.m_abstractPathName.c_str();
diff --git a/Minecraft.World/FileHeader.cpp b/Minecraft.World/FileHeader.cpp
index 0a47e043..a7bdbc90 100644
--- a/Minecraft.World/FileHeader.cpp
+++ b/Minecraft.World/FileHeader.cpp
@@ -5,7 +5,7 @@
FileHeader::FileHeader()
{
- lastFile = NULL;
+ lastFile = nullptr;
m_saveVersion = 0;
// New saves should have an original version set to the latest version. This will be overridden when we load a save
@@ -49,7 +49,7 @@ FileEntry *FileHeader::AddFile( const wstring &name, unsigned int length /* = 0
void FileHeader::RemoveFile( FileEntry *file )
{
- if( file == NULL ) return;
+ if( file == nullptr ) return;
AdjustStartOffsets(file, file->getFileSize(), true);
@@ -72,13 +72,13 @@ void FileHeader::WriteHeader( LPVOID saveMem )
unsigned int headerOffset = GetStartOfNextData();
// 4J Changed for save version 2 to be the number of files rather than the size in bytes
- unsigned int headerSize = (int)(fileTable.size());
+ unsigned int headerSize = static_cast<int>(fileTable.size());
//DWORD numberOfBytesWritten = 0;
// Write the offset of the header
//assert(numberOfBytesWritten == 4);
- int *begin = (int *)saveMem;
+ int *begin = static_cast<int *>(saveMem);
#ifdef __PSVITA__
VirtualCopyTo(begin, &headerOffset, sizeof(headerOffset));
#else
@@ -115,7 +115,7 @@ void FileHeader::WriteHeader( LPVOID saveMem )
app.DebugPrintf("Write save file with original version: %d, and current version %d\n", m_originalSaveVersion, versionNumber);
#endif
- char *headerPosition = (char *)saveMem + headerOffset;
+ char *headerPosition = static_cast<char *>(saveMem) + headerOffset;
#ifdef _DEBUG_FILE_HEADER
app.DebugPrintf("\n\nWrite file Header: Offset = %d, Size = %d\n", headerOffset, headerSize);
@@ -164,7 +164,7 @@ void FileHeader::ReadHeader( LPVOID saveMem, ESavePlatform plat /*= SAVE_FILE_PL
// Read the offset of the header
//assert(numberOfBytesRead == 4);
- int *begin = (int *)saveMem;
+ int *begin = static_cast<int *>(saveMem);
#ifdef __PSVITA__
VirtualCopyFrom(&headerOffset, begin, sizeof(headerOffset));
#else
@@ -205,7 +205,7 @@ void FileHeader::ReadHeader( LPVOID saveMem, ESavePlatform plat /*= SAVE_FILE_PL
app.DebugPrintf("\n\nRead file Header: Offset = %d, Size = %d\n", headerOffset, headerSize);
#endif
- char *headerPosition = (char *)saveMem + headerOffset;
+ char *headerPosition = static_cast<char *>(saveMem) + headerOffset;
switch( m_saveVersion )
{
@@ -321,7 +321,7 @@ unsigned int FileHeader::GetStartOfNextData()
unsigned int FileHeader::GetFileSize()
{
- return GetStartOfNextData() + ( sizeof(FileEntrySaveData) * (unsigned int)fileTable.size() );
+ return GetStartOfNextData() + ( sizeof(FileEntrySaveData) * static_cast<unsigned int>(fileTable.size()) );
}
void FileHeader::AdjustStartOffsets(FileEntry *file, DWORD nNumberOfBytesToWrite, bool subtract /*= false*/)
@@ -364,13 +364,13 @@ bool FileHeader::fileExists( const wstring &name )
vector<FileEntry *> *FileHeader::getFilesWithPrefix(const wstring &prefix)
{
- vector<FileEntry *> *files = NULL;
+ vector<FileEntry *> *files = nullptr;
for( unsigned int i = 0; i < fileTable.size(); ++i )
{
if( wcsncmp( fileTable[i]->data.filename, prefix.c_str(), prefix.size() ) == 0 )
{
- if( files == NULL )
+ if( files == nullptr )
{
files = new vector<FileEntry *>();
}
@@ -479,7 +479,7 @@ wstring FileHeader::getPlayerDataFilenameForSave(const PlayerUID& pUID)
vector<FileEntry *> *FileHeader::getValidPlayerDatFiles()
{
- vector<FileEntry *> *files = NULL;
+ vector<FileEntry *> *files = nullptr;
// find filenames that match this pattern
// P_5e7ff8372ea9_00000004_Mark_4J
@@ -509,7 +509,7 @@ vector<FileEntry *> *FileHeader::getValidPlayerDatFiles()
continue;
// if we get here, it must be a valid filename
- if( files == NULL )
+ if( files == nullptr )
{
files = new vector<FileEntry *>();
}
@@ -524,21 +524,21 @@ vector<FileEntry *> *FileHeader::getValidPlayerDatFiles()
vector<FileEntry *> *FileHeader::getDatFilesWithOnlineID(const PlayerUID& pUID)
{
if(pUID.isSignedIntoPSN() == false)
- return NULL;
+ return nullptr;
vector<FileEntry *>* datFiles = getValidPlayerDatFiles();
- if(datFiles == NULL)
- return NULL;
+ if(datFiles == nullptr)
+ return nullptr;
// we're looking for the online name from the pUID in these types of filenames -
// P_5e7ff8372ea9_00000004_Mark_4J
wchar_t onlineIDW[64];
mbstowcs(onlineIDW, pUID.getOnlineID(), 64);
- vector<FileEntry *> *files = NULL;
+ vector<FileEntry *> *files = nullptr;
int onlineIDSize = wcslen(onlineIDW);
if(onlineIDSize == 0)
- return NULL;
+ return nullptr;
wcscat(onlineIDW, L".dat");
@@ -564,7 +564,7 @@ vector<FileEntry *> *FileHeader::getDatFilesWithOnlineID(const PlayerUID& pUID)
{
if(wcsncmp(&filenameOnly[onlineIDStart], onlineIDW, onlineIDSize) == 0)
{
- if( files == NULL )
+ if( files == nullptr )
{
files = new vector<FileEntry *>();
}
@@ -582,8 +582,8 @@ vector<FileEntry *> *FileHeader::getDatFilesWithMacAndUserID(const PlayerUID& pU
{
vector<FileEntry *>* datFiles = getValidPlayerDatFiles();
- if(datFiles == NULL)
- return NULL;
+ if(datFiles == nullptr)
+ return nullptr;
// we're looking for the mac address and userIDfrom the pUID in these types of filenames -
// P_5e7ff8372ea9_00000004_Mark_4J
@@ -592,7 +592,7 @@ vector<FileEntry *> *FileHeader::getDatFilesWithMacAndUserID(const PlayerUID& pU
const wchar_t* pMacStr = macStr.c_str();
const wchar_t* pUserStr = userStr.c_str();
- vector<FileEntry *> *files = NULL;
+ vector<FileEntry *> *files = nullptr;
static const int macAddrStart = 2; // 2 characters into the filename
static const int userIDStart = 15; // 15 characters into the filename
@@ -609,7 +609,7 @@ vector<FileEntry *> *FileHeader::getDatFilesWithMacAndUserID(const PlayerUID& pU
// check the userID matches
if(wcsncmp(&filenameOnly[userIDStart], pUserStr, userStr.size()) == 0)
{
- if( files == NULL )
+ if( files == nullptr )
{
files = new vector<FileEntry *>();
}
@@ -627,12 +627,12 @@ vector<FileEntry *> *FileHeader::getDatFilesWithPrimaryUser()
{
vector<FileEntry *>* datFiles = getValidPlayerDatFiles();
- if(datFiles == NULL)
- return NULL;
+ if(datFiles == nullptr)
+ return nullptr;
// we're just looking for filenames starting with "P_" in these types of filenames -
// P_5e7ff8372ea9_00000004_Mark_4J
- vector<FileEntry *> *files = NULL;
+ vector<FileEntry *> *files = nullptr;
char tempStr[128];
for( unsigned int i = 0; i < datFiles->size(); ++i )
@@ -644,7 +644,7 @@ vector<FileEntry *> *FileHeader::getDatFilesWithPrimaryUser()
// check for "P_" prefix
if(wcsncmp(&filenameOnly[0], L"P_", 2) == 0)
{
- if( files == NULL )
+ if( files == nullptr )
{
files = new vector<FileEntry *>();
}
diff --git a/Minecraft.World/FileInputStream.cpp b/Minecraft.World/FileInputStream.cpp
index 5e0f6ca5..7c34a22f 100644
--- a/Minecraft.World/FileInputStream.cpp
+++ b/Minecraft.World/FileInputStream.cpp
@@ -24,20 +24,20 @@ FileInputStream::FileInputStream(const File &file)
file.getPath().c_str(), // file name
GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
- NULL, // Unused
+ nullptr, // Unused
OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
- NULL // Unsupported
+ nullptr // Unsupported
);
#else
m_fileHandle = CreateFile(
pchFilename, // file name
GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
- NULL, // Unused
+ nullptr, // Unused
OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
- NULL // Unsupported
+ nullptr // Unsupported
);
#endif
@@ -68,7 +68,7 @@ int FileInputStream::read()
&byteRead, // data buffer
1, // number of bytes to read
&numberOfBytesRead, // number of bytes read
- NULL // overlapped buffer
+ nullptr // overlapped buffer
);
if( bSuccess==FALSE )
@@ -100,7 +100,7 @@ int FileInputStream::read(byteArray b)
b.data, // data buffer
b.length, // number of bytes to read
&numberOfBytesRead, // number of bytes read
- NULL // overlapped buffer
+ nullptr // overlapped buffer
);
if( bSuccess==FALSE )
@@ -138,7 +138,7 @@ int FileInputStream::read(byteArray b, unsigned int offset, unsigned int length)
&b[offset], // data buffer
length, // number of bytes to read
&numberOfBytesRead, // number of bytes read
- NULL // overlapped buffer
+ nullptr // overlapped buffer
);
if( bSuccess==FALSE )
diff --git a/Minecraft.World/FileOutputStream.cpp b/Minecraft.World/FileOutputStream.cpp
index 557ba812..58a0ecd9 100644
--- a/Minecraft.World/FileOutputStream.cpp
+++ b/Minecraft.World/FileOutputStream.cpp
@@ -24,20 +24,20 @@ FileOutputStream::FileOutputStream(const File &file) : m_fileHandle( INVALID_HAN
file.getPath().c_str() , // file name
GENERIC_WRITE, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
- NULL, // Unused
+ nullptr, // Unused
OPEN_ALWAYS , // how to create
FILE_ATTRIBUTE_NORMAL , // file attributes
- NULL // Unsupported
+ nullptr // Unsupported
);
#else
m_fileHandle = CreateFile(
wstringtofilename(file.getPath()) , // file name
GENERIC_WRITE, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
- NULL, // Unused
+ nullptr, // Unused
OPEN_ALWAYS , // how to create
FILE_ATTRIBUTE_NORMAL , // file attributes
- NULL // Unsupported
+ nullptr // Unsupported
);
#endif
@@ -61,14 +61,14 @@ void FileOutputStream::write(unsigned int b)
{
DWORD numberOfBytesWritten;
- byte value = (byte) b;
+ byte value = static_cast<byte>(b);
BOOL result = WriteFile(
m_fileHandle, // handle to file
&value, // data buffer
1, // number of bytes to write
&numberOfBytesWritten, // number of bytes written
- NULL // overlapped buffer
+ nullptr // overlapped buffer
);
if( result == 0 )
@@ -93,7 +93,7 @@ void FileOutputStream::write(byteArray b)
&b.data, // data buffer
b.length, // number of bytes to write
&numberOfBytesWritten, // number of bytes written
- NULL // overlapped buffer
+ nullptr // overlapped buffer
);
if( result == 0 )
@@ -123,7 +123,7 @@ void FileOutputStream::write(byteArray b, unsigned int offset, unsigned int leng
&b[offset], // data buffer
length, // number of bytes to write
&numberOfBytesWritten, // number of bytes written
- NULL // overlapped buffer
+ nullptr // overlapped buffer
);
if( result == 0 )
diff --git a/Minecraft.World/FireChargeItem.cpp b/Minecraft.World/FireChargeItem.cpp
index 7a865ff5..d3499cdc 100644
--- a/Minecraft.World/FireChargeItem.cpp
+++ b/Minecraft.World/FireChargeItem.cpp
@@ -10,7 +10,7 @@
FireChargeItem::FireChargeItem(int id) : Item(id)
{
- m_dragonFireballIcon = NULL;
+ m_dragonFireballIcon = nullptr;
}
bool FireChargeItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly)
diff --git a/Minecraft.World/FireTile.cpp b/Minecraft.World/FireTile.cpp
index dfb4b961..49f859b5 100644
--- a/Minecraft.World/FireTile.cpp
+++ b/Minecraft.World/FireTile.cpp
@@ -24,7 +24,7 @@ FireTile::FireTile(int id) : Tile(id, Material::fire,isSolidRender())
burnOdds = new int[256];
memset( burnOdds,0,sizeof(int)*256);
- icons = NULL;
+ icons = nullptr;
setTicking(true);
}
@@ -64,7 +64,7 @@ void FireTile::setFlammable(int id, int flame, int burn)
AABB *FireTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
bool FireTile::blocksLight()
diff --git a/Minecraft.World/Fireball.cpp b/Minecraft.World/Fireball.cpp
index 2a538b06..b520f436 100644
--- a/Minecraft.World/Fireball.cpp
+++ b/Minecraft.World/Fireball.cpp
@@ -127,10 +127,10 @@ Fireball::Fireball(Level *level, shared_ptr<LivingEntity> mob, double xa, double
void Fireball::tick()
{
// 4J-PB - Moved forward from 1.2.3
- //if (!level->isClientSide && (owner == NULL || owner->removed))
+ //if (!level->isClientSide && (owner == nullptr || owner->removed))
if (!level->isClientSide)
{
- if((owner != NULL && owner->removed) || !level->hasChunkAt((int) x, (int) y, (int) z))
+ if((owner != nullptr && owner->removed) || !level->hasChunkAt(static_cast<int>(x), static_cast<int>(y), static_cast<int>(z)))
{
app.DebugPrintf("Fireball removed - owner is null or removed is true for owner\n");
remove();
@@ -193,7 +193,7 @@ void Fireball::tick()
from = Vec3::newTemp(x, y, z);
to = Vec3::newTemp(x + xd, y + yd, z + zd);
- if (res != NULL)
+ if (res != nullptr)
{
to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z);
}
@@ -207,7 +207,7 @@ void Fireball::tick()
float rr = 0.3f;
AABB *bb = e->bb->grow(rr, rr, rr);
HitResult *p = bb->clip(from, to);
- if (p != NULL)
+ if (p != nullptr)
{
double dd = from->distanceTo(p->pos);
if (dd < nearest || nearest == 0)
@@ -220,14 +220,14 @@ void Fireball::tick()
}
- if (hitEntity != NULL)
+ if (hitEntity != nullptr)
{
delete res;
res = new HitResult(hitEntity);
}
MemSect(0);
- if (res != NULL)
+ if (res != nullptr)
{
onHit(res);
}
@@ -237,8 +237,8 @@ void Fireball::tick()
z += zd;
double sd = sqrt(xd * xd + zd * zd);
- yRot = (float) (atan2(zd, xd) * 180 / PI) + 90;
- xRot = (float) (atan2(sd, yd) * 180 / PI) - 90;
+ yRot = static_cast<float>(atan2(zd, xd) * 180 / PI) + 90;
+ xRot = static_cast<float>(atan2(sd, yd) * 180 / PI) - 90;
while (xRot - xRotO < -180)
xRotO -= 360;
@@ -297,11 +297,11 @@ float Fireball::getInertia()
void Fireball::addAdditonalSaveData(CompoundTag *tag)
{
- tag->putShort(L"xTile", (short) xTile);
- tag->putShort(L"yTile", (short) yTile);
- tag->putShort(L"zTile", (short) zTile);
- tag->putByte(L"inTile", (byte) lastTile);
- tag->putByte(L"inGround", (byte) (inGround ? 1 : 0));
+ tag->putShort(L"xTile", static_cast<short>(xTile));
+ tag->putShort(L"yTile", static_cast<short>(yTile));
+ tag->putShort(L"zTile", static_cast<short>(zTile));
+ tag->putByte(L"inTile", static_cast<byte>(lastTile));
+ tag->putByte(L"inGround", static_cast<byte>(inGround ? 1 : 0));
tag->put(L"direction", newDoubleList(3, xd, yd, zd));
}
@@ -343,10 +343,10 @@ bool Fireball::hurt(DamageSource *source, float damage)
if (isInvulnerable()) return false;
markHurt();
- if (source->getEntity() != NULL)
+ if (source->getEntity() != nullptr)
{
Vec3 *lookAngle = source->getEntity()->getLookAngle();
- if (lookAngle != NULL)
+ if (lookAngle != nullptr)
{
xd = lookAngle->x;
yd = lookAngle->y;
diff --git a/Minecraft.World/FireworksChargeItem.cpp b/Minecraft.World/FireworksChargeItem.cpp
index 2de2be04..8b12c98c 100644
--- a/Minecraft.World/FireworksChargeItem.cpp
+++ b/Minecraft.World/FireworksChargeItem.cpp
@@ -21,9 +21,9 @@ int FireworksChargeItem::getColor(shared_ptr<ItemInstance> item, int spriteLayer
if (spriteLayer == 1)
{
Tag *colorTag = getExplosionTagField(item, FireworksItem::TAG_E_COLORS);
- if (colorTag != NULL)
+ if (colorTag != nullptr)
{
- IntArrayTag *colors = (IntArrayTag *) colorTag;
+ IntArrayTag *colors = static_cast<IntArrayTag *>(colorTag);
if (colors->data.length == 1)
{
return colors->data[0];
@@ -58,12 +58,12 @@ Tag *FireworksChargeItem::getExplosionTagField(shared_ptr<ItemInstance> instance
if (instance->hasTag())
{
CompoundTag *explosion = instance->getTag()->getCompound(FireworksItem::TAG_EXPLOSION);
- if (explosion != NULL)
+ if (explosion != nullptr)
{
return explosion->get(field);
}
}
- return NULL;
+ return nullptr;
}
void FireworksChargeItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, vector<HtmlString> *lines, bool advanced)
@@ -71,7 +71,7 @@ void FireworksChargeItem::appendHoverText(shared_ptr<ItemInstance> itemInstance,
if (itemInstance->hasTag())
{
CompoundTag *explosion = itemInstance->getTag()->getCompound(FireworksItem::TAG_EXPLOSION);
- if (explosion != NULL)
+ if (explosion != nullptr)
{
appendHoverText(explosion, lines);
}
diff --git a/Minecraft.World/FireworksItem.cpp b/Minecraft.World/FireworksItem.cpp
index f81b4588..f1cdf309 100644
--- a/Minecraft.World/FireworksItem.cpp
+++ b/Minecraft.World/FireworksItem.cpp
@@ -26,7 +26,7 @@ bool FireworksItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player>
if (!level->isClientSide)
{
- shared_ptr<FireworksRocketEntity> f = shared_ptr<FireworksRocketEntity>( new FireworksRocketEntity(level, x + clickX, y + clickY, z + clickZ, instance) );
+ shared_ptr<FireworksRocketEntity> f(new FireworksRocketEntity(level, x + clickX, y + clickY, z + clickZ, instance));
level->addEntity(f);
if (!player->abilities.instabuild)
@@ -46,7 +46,7 @@ void FireworksItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, share
return;
}
CompoundTag *fireTag = itemInstance->getTag()->getCompound(TAG_FIREWORKS);
- if (fireTag == NULL)
+ if (fireTag == nullptr)
{
return;
}
@@ -56,7 +56,7 @@ void FireworksItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, share
}
ListTag<CompoundTag> *explosions = (ListTag<CompoundTag> *) fireTag->getList(TAG_EXPLOSIONS);
- if (explosions != NULL && explosions->size() > 0)
+ if (explosions != nullptr && explosions->size() > 0)
{
for (int i = 0; i < explosions->size(); i++)
@@ -69,7 +69,7 @@ void FireworksItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, share
if (eLines.size() > 0)
{
// Indent lines after first line
- for (int i = 1; i < eLines.size(); i++)
+ for (size_t i = 1; i < eLines.size(); i++)
{
eLines[i].indent = true;
}
diff --git a/Minecraft.World/FireworksMenu.cpp b/Minecraft.World/FireworksMenu.cpp
index 68c9e0f2..cd9196af 100644
--- a/Minecraft.World/FireworksMenu.cpp
+++ b/Minecraft.World/FireworksMenu.cpp
@@ -15,8 +15,8 @@ FireworksMenu::FireworksMenu(shared_ptr<Inventory> inventory, Level *level, int
m_canMakeCharge = false;
m_canMakeFade = false;
- craftSlots = shared_ptr<CraftingContainer>( new CraftingContainer(this, 3, 3) );
- resultSlots = shared_ptr<ResultContainer>( new ResultContainer() );
+ craftSlots = std::make_shared<CraftingContainer>(this, 3, 3);
+ resultSlots = std::make_shared<ResultContainer>();
this->level = level;
x = xt;
@@ -61,7 +61,7 @@ void FireworksMenu::removed(shared_ptr<Player> player)
for (int i = 0; i < 9; i++)
{
shared_ptr<ItemInstance> item = craftSlots->removeItemNoUpdate(i);
- if (item != NULL)
+ if (item != nullptr)
{
player->drop(item);
}
@@ -77,7 +77,7 @@ shared_ptr<ItemInstance> FireworksMenu::quickMoveStack(shared_ptr<Player> player
{
shared_ptr<ItemInstance> clicked = nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
@@ -145,6 +145,6 @@ bool FireworksMenu::canTakeItemForPickAll(shared_ptr<ItemInstance> carried, Slot
bool FireworksMenu::isValidIngredient(shared_ptr<ItemInstance> item, int slotId)
{
- if(item == NULL || slotId == RESULT_SLOT) return true;
+ if(item == nullptr || slotId == RESULT_SLOT) return true;
return FireworksRecipe::isValidIngredient(item, m_canMakeFireworks, m_canMakeCharge, m_canMakeFade);
} \ No newline at end of file
diff --git a/Minecraft.World/FireworksRecipe.cpp b/Minecraft.World/FireworksRecipe.cpp
index a357c9cb..feb1cf57 100644
--- a/Minecraft.World/FireworksRecipe.cpp
+++ b/Minecraft.World/FireworksRecipe.cpp
@@ -3,7 +3,7 @@
#include "FireworksRecipe.h"
DWORD FireworksRecipe::tlsIdx = 0;
-FireworksRecipe::ThreadStorage *FireworksRecipe::tlsDefault = NULL;
+FireworksRecipe::ThreadStorage *FireworksRecipe::tlsDefault = nullptr;
FireworksRecipe::ThreadStorage::ThreadStorage()
{
@@ -13,7 +13,7 @@ FireworksRecipe::ThreadStorage::ThreadStorage()
void FireworksRecipe::CreateNewThreadStorage()
{
ThreadStorage *tls = new ThreadStorage();
- if(tlsDefault == NULL )
+ if(tlsDefault == nullptr )
{
tlsIdx = TlsAlloc();
tlsDefault = tls;
@@ -28,7 +28,7 @@ void FireworksRecipe::UseDefaultThreadStorage()
void FireworksRecipe::ReleaseThreadStorage()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
if( tls == tlsDefault ) return;
delete tls;
@@ -36,7 +36,7 @@ void FireworksRecipe::ReleaseThreadStorage()
void FireworksRecipe::setResultItem(shared_ptr<ItemInstance> item)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
tls->resultItem = item;
}
@@ -59,7 +59,7 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
for (int slot = 0; slot < craftSlots->getContainerSize(); slot++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(slot);
- if (item == NULL) continue;
+ if (item == nullptr) continue;
if (item->id == Item::gunpowder_Id)
{
@@ -124,7 +124,7 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
// create fireworks
if (sulphurCount >= 1 && paperCount == 1 && chargeComponents == 0)
{
- resultItem = shared_ptr<ItemInstance>( new ItemInstance(Item::fireworks) );
+ resultItem = std::make_shared<ItemInstance>(Item::fireworks);
if (chargeCount > 0)
{
CompoundTag *itemTag = new CompoundTag();
@@ -134,16 +134,16 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
for (int slot = 0; slot < craftSlots->getContainerSize(); slot++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(slot);
- if (item == NULL || item->id != Item::fireworksCharge_Id) continue;
+ if (item == nullptr || item->id != Item::fireworksCharge_Id) continue;
if (item->hasTag() && item->getTag()->contains(FireworksItem::TAG_EXPLOSION))
{
- expTags->add((CompoundTag *)item->getTag()->getCompound(FireworksItem::TAG_EXPLOSION)->copy());
+ expTags->add(static_cast<CompoundTag *>(item->getTag()->getCompound(FireworksItem::TAG_EXPLOSION)->copy()));
}
}
fireTag->put(FireworksItem::TAG_EXPLOSIONS, expTags);
- fireTag->putByte(FireworksItem::TAG_FLIGHT, (byte) sulphurCount);
+ fireTag->putByte(FireworksItem::TAG_FLIGHT, static_cast<byte>(sulphurCount));
itemTag->put(FireworksItem::TAG_FIREWORKS, fireTag);
resultItem->setTag(itemTag);
@@ -155,7 +155,7 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
if (sulphurCount == 1 && paperCount == 0 && chargeCount == 0 && colorCount > 0 && typeComponents <= 1)
{
- resultItem = shared_ptr<ItemInstance>( new ItemInstance(Item::fireworksCharge) );
+ resultItem = std::make_shared<ItemInstance>(Item::fireworksCharge);
CompoundTag *itemTag = new CompoundTag();
CompoundTag *expTag = new CompoundTag(FireworksItem::TAG_EXPLOSION);
@@ -165,7 +165,7 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
for (int slot = 0; slot < craftSlots->getContainerSize(); slot++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(slot);
- if (item == NULL) continue;
+ if (item == nullptr) continue;
if (item->id == Item::dye_powder_Id)
{
@@ -195,10 +195,10 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
}
else if (item->id == Item::skull_Id)
{
- type = FireworksItem::TYPE_CREEPER;
+ type = FireworksItem::TYPE_CREEPER;
}
}
- intArray colorArray(colors.size());
+ intArray colorArray(static_cast<unsigned int>(colors.size()));
for (int i = 0; i < colorArray.length; i++)
{
colorArray[i] = colors.at(i);
@@ -221,7 +221,7 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
for (int slot = 0; slot < craftSlots->getContainerSize(); slot++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(slot);
- if (item == NULL) continue;
+ if (item == nullptr) continue;
if (item->id == Item::dye_powder_Id)
{
@@ -230,18 +230,18 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
else if (item->id == Item::fireworksCharge_Id)
{
resultItem = item->copy();
- resultItem->count = 1;
+ resultItem->count = 1;
}
}
- intArray colorArray(colors.size());
+ intArray colorArray(static_cast<unsigned int>(colors.size()));
for (int i = 0; i < colorArray.length; i++)
{
colorArray[i] = colors.at(i);
}
- if (resultItem != NULL && resultItem->hasTag())
+ if (resultItem != nullptr && resultItem->hasTag())
{
CompoundTag *compound = resultItem->getTag()->getCompound(FireworksItem::TAG_EXPLOSION);
- if (compound == NULL)
+ if (compound == nullptr)
{
delete colorArray.data;
@@ -268,7 +268,7 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
shared_ptr<ItemInstance> FireworksRecipe::assemble(shared_ptr<CraftingContainer> craftSlots)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
return tls->resultItem->copy();
//return resultItem->copy();
}
@@ -280,7 +280,7 @@ int FireworksRecipe::size()
const ItemInstance *FireworksRecipe::getResultItem()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
return tls->resultItem.get();
//return resultItem.get();
}
@@ -301,7 +301,7 @@ void FireworksRecipe::updatePossibleRecipes(shared_ptr<CraftingContainer> craftS
for (int slot = 0; slot < craftSlots->getContainerSize(); slot++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(slot);
- if (item == NULL) continue;
+ if (item == nullptr) continue;
if (item->id == Item::gunpowder_Id)
{
diff --git a/Minecraft.World/FireworksRocketEntity.cpp b/Minecraft.World/FireworksRocketEntity.cpp
index e84844f1..d3897e4f 100644
--- a/Minecraft.World/FireworksRocketEntity.cpp
+++ b/Minecraft.World/FireworksRocketEntity.cpp
@@ -15,7 +15,7 @@ FireworksRocketEntity::FireworksRocketEntity(Level *level) : Entity(level)
void FireworksRocketEntity::defineSynchedData()
{
- entityData->defineNULL(DATA_ID_FIREWORKS_ITEM, NULL);
+ entityData->defineNULL(DATA_ID_FIREWORKS_ITEM, nullptr);
}
bool FireworksRocketEntity::shouldRenderAtSqrDistance(double distance)
@@ -35,13 +35,13 @@ FireworksRocketEntity::FireworksRocketEntity(Level *level, double x, double y, d
heightOffset = 0;
int flightCount = 1;
- if (sourceItem != NULL && sourceItem->hasTag())
+ if (sourceItem != nullptr && sourceItem->hasTag())
{
entityData->set(DATA_ID_FIREWORKS_ITEM, sourceItem);
CompoundTag *tag = sourceItem->getTag();
CompoundTag *compound = tag->getCompound(FireworksItem::TAG_FIREWORKS);
- if (compound != NULL)
+ if (compound != nullptr)
{
flightCount += compound->getByte(FireworksItem::TAG_FLIGHT);
}
@@ -61,8 +61,8 @@ void FireworksRocketEntity::lerpMotion(double xd, double yd, double zd)
if (xRotO == 0 && yRotO == 0)
{
double sd = Mth::sqrt(xd * xd + zd * zd);
- yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRotO = xRot = (float) (atan2(yd, sd) * 180 / PI);
+ yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRotO = xRot = static_cast<float>(atan2(yd, sd) * 180 / PI);
}
}
@@ -79,8 +79,8 @@ void FireworksRocketEntity::tick()
move(xd, yd, zd);
double sd = Mth::sqrt(xd * xd + zd * zd);
- yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRot = (float) (atan2(yd, sd) * 180 / PI);
+ yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRot = static_cast<float>(atan2(yd, sd) * 180 / PI);
while (xRot - xRotO < -180)
xRotO -= 360;
@@ -120,8 +120,8 @@ void FireworksRocketEntity::handleEntityEvent(byte eventId)
if (eventId == EntityEvent::FIREWORKS_EXPLODE && level->isClientSide)
{
shared_ptr<ItemInstance> sourceItem = entityData->getItemInstance(DATA_ID_FIREWORKS_ITEM);
- CompoundTag *tag = NULL;
- if (sourceItem != NULL && sourceItem->hasTag())
+ CompoundTag *tag = nullptr;
+ if (sourceItem != nullptr && sourceItem->hasTag())
{
tag = sourceItem->getTag()->getCompound(FireworksItem::TAG_FIREWORKS);
}
@@ -135,7 +135,7 @@ void FireworksRocketEntity::addAdditonalSaveData(CompoundTag *tag)
tag->putInt(L"Life", life);
tag->putInt(L"LifeTime", lifetime);
shared_ptr<ItemInstance> itemInstance = entityData->getItemInstance(DATA_ID_FIREWORKS_ITEM);
- if (itemInstance != NULL)
+ if (itemInstance != nullptr)
{
CompoundTag *itemTag = new CompoundTag();
itemInstance->save(itemTag);
@@ -150,10 +150,10 @@ void FireworksRocketEntity::readAdditionalSaveData(CompoundTag *tag)
lifetime = tag->getInt(L"LifeTime");
CompoundTag *itemTag = tag->getCompound(L"FireworksItem");
- if (itemTag != NULL)
+ if (itemTag != nullptr)
{
shared_ptr<ItemInstance> fromTag = ItemInstance::fromTag(itemTag);
- if (fromTag != NULL)
+ if (fromTag != nullptr)
{
entityData->set(DATA_ID_FIREWORKS_ITEM, fromTag);
}
diff --git a/Minecraft.World/FishingHook.cpp b/Minecraft.World/FishingHook.cpp
index e38a64b6..ba0876d9 100644
--- a/Minecraft.World/FishingHook.cpp
+++ b/Minecraft.World/FishingHook.cpp
@@ -102,7 +102,7 @@ bool FishingHook::shouldRenderAtSqrDistance(double distance)
void FishingHook::shoot(double xd, double yd, double zd, float pow, float uncertainty)
{
- float dist = (float) sqrt(xd * xd + yd * yd + zd * zd);
+ float dist = static_cast<float>(sqrt(xd * xd + yd * yd + zd * zd));
xd /= dist;
yd /= dist;
@@ -122,8 +122,8 @@ void FishingHook::shoot(double xd, double yd, double zd, float pow, float uncert
double sd = sqrt(xd * xd + zd * zd);
- yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRotO = xRot = (float) (atan2(yd, sd) * 180 / PI);
+ yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRotO = xRot = static_cast<float>(atan2(yd, sd) * 180 / PI);
life = 0;
}
@@ -161,8 +161,8 @@ void FishingHook::tick()
double yrd = Mth::wrapDegrees(lyr - yRot);
- yRot += (float) ( (yrd) / lSteps );
- xRot += (float) ( (lxr - xRot) / lSteps );
+ yRot += static_cast<float>((yrd) / lSteps);
+ xRot += static_cast<float>((lxr - xRot) / lSteps);
lSteps--;
setPos(xt, yt, zt);
@@ -173,14 +173,14 @@ void FishingHook::tick()
if (!level->isClientSide)
{
shared_ptr<ItemInstance> selectedItem = owner->getSelectedItem();
- if (owner->removed || !owner->isAlive() || selectedItem == NULL || selectedItem->getItem() != Item::fishingRod || distanceToSqr(owner) > 32 * 32)
+ if (owner->removed || !owner->isAlive() || selectedItem == nullptr || selectedItem->getItem() != Item::fishingRod || distanceToSqr(owner) > 32 * 32)
{
remove();
owner->fishing = nullptr;
return;
}
- if (hookedIn != NULL)
+ if (hookedIn != nullptr)
{
if (hookedIn->removed) hookedIn = nullptr;
else
@@ -226,7 +226,7 @@ void FishingHook::tick()
from = Vec3::newTemp(x, y, z);
to = Vec3::newTemp(x + xd, y + yd, z + zd);
- if (res != NULL)
+ if (res != nullptr)
{
to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z);
}
@@ -241,7 +241,7 @@ void FishingHook::tick()
float rr = 0.3f;
AABB *bb = e->bb->grow(rr, rr, rr);
HitResult *p = bb->clip(from, to);
- if (p != NULL)
+ if (p != nullptr)
{
double dd = from->distanceTo(p->pos);
if (dd < nearest || nearest == 0)
@@ -253,15 +253,15 @@ void FishingHook::tick()
}
}
- if (hitEntity != NULL)
+ if (hitEntity != nullptr)
{
delete res;
res = new HitResult(hitEntity);
}
- if (res != NULL)
+ if (res != nullptr)
{
- if (res->entity != NULL)
+ if (res->entity != nullptr)
{
// 4J Stu Move fix for : fix for #48587 - CRASH: Code: Gameplay: Hitting another player with the fishing bobber crashes the game. [Fishing pole, line]
// Incorrect dynamic_pointer_cast used around the shared_from_this()
@@ -284,8 +284,8 @@ void FishingHook::tick()
move(xd, yd, zd);
double sd = sqrt(xd * xd + zd * zd);
- yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRot = (float) (atan2(yd, sd) * 180 / PI);
+ yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRot = static_cast<float>(atan2(yd, sd) * 180 / PI);
while (xRot - xRotO < -180)
xRotO -= 360;
@@ -337,7 +337,7 @@ void FishingHook::tick()
nibble = random->nextInt(30) + 10;
yd -= 0.2f;
playSound(eSoundType_RANDOM_SPLASH, 0.25f, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f);
- float yt = (float) Mth::floor(bb->y0);
+ float yt = static_cast<float>(Mth::floor(bb->y0));
for (int i = 0; i < 1 + bbWidth * 20; i++)
{
float xo = (random->nextFloat() * 2 - 1) * bbWidth;
@@ -377,12 +377,12 @@ void FishingHook::tick()
void FishingHook::addAdditonalSaveData(CompoundTag *tag)
{
- tag->putShort(L"xTile", (short) xTile);
- tag->putShort(L"yTile", (short) yTile);
- tag->putShort(L"zTile", (short) zTile);
- tag->putByte(L"inTile", (byte) lastTile);
- tag->putByte(L"shake", (byte) shakeTime);
- tag->putByte(L"inGround", (byte) (inGround ? 1 : 0));
+ tag->putShort(L"xTile", static_cast<short>(xTile));
+ tag->putShort(L"yTile", static_cast<short>(yTile));
+ tag->putShort(L"zTile", static_cast<short>(zTile));
+ tag->putByte(L"inTile", static_cast<byte>(lastTile));
+ tag->putByte(L"shake", static_cast<byte>(shakeTime));
+ tag->putByte(L"inGround", static_cast<byte>(inGround ? 1 : 0));
}
void FishingHook::readAdditionalSaveData(CompoundTag *tag)
@@ -405,7 +405,7 @@ int FishingHook::retrieve()
if (level->isClientSide) return 0;
int dmg = 0;
- if (hookedIn != NULL)
+ if (hookedIn != nullptr)
{
double xa = owner->x - x;
double ya = owner->y - y;
@@ -420,7 +420,7 @@ int FishingHook::retrieve()
}
else if (nibble > 0)
{
- shared_ptr<ItemEntity> ie = shared_ptr<ItemEntity>( new ItemEntity(this->Entity::level, x, y, z, shared_ptr<ItemInstance>( new ItemInstance(Item::fish_raw) ) ) );
+ shared_ptr<ItemEntity> ie = std::make_shared<ItemEntity>(this->Entity::level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Item::fish_raw)));
double xa = owner->x - x;
double ya = owner->y - y;
double za = owner->z - z;
@@ -431,7 +431,7 @@ int FishingHook::retrieve()
ie->Entity::yd = ya * speed + sqrt(dist) * 0.08;
ie->Entity::zd = za * speed;
level->addEntity(ie);
- owner->level->addEntity( shared_ptr<ExperienceOrb>( new ExperienceOrb(owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f, random->nextInt(6) + 1) ) ); // 4J Stu brought forward from 1.4
+ owner->level->addEntity(std::make_shared<ExperienceOrb>(owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f, random->nextInt(6) + 1)); // 4J Stu brought forward from 1.4
dmg = 1;
}
if (inGround) dmg = 2;
@@ -445,5 +445,5 @@ int FishingHook::retrieve()
void FishingHook::remove()
{
Entity::remove();
- if (owner != NULL) owner->fishing = nullptr;
+ if (owner != nullptr) owner->fishing = nullptr;
} \ No newline at end of file
diff --git a/Minecraft.World/FishingRodItem.cpp b/Minecraft.World/FishingRodItem.cpp
index 883eb2de..b9eafd18 100644
--- a/Minecraft.World/FishingRodItem.cpp
+++ b/Minecraft.World/FishingRodItem.cpp
@@ -17,7 +17,7 @@ FishingRodItem::FishingRodItem(int id) : Item(id)
{
setMaxDamage(64);
setMaxStackSize(1);
- emptyIcon = NULL;
+ emptyIcon = nullptr;
}
bool FishingRodItem::isHandEquipped()
@@ -32,7 +32,7 @@ bool FishingRodItem::isMirroredArt()
shared_ptr<ItemInstance> FishingRodItem::use(shared_ptr<ItemInstance> instance, Level *level, shared_ptr<Player> player)
{
- if (player->fishing != NULL)
+ if (player->fishing != nullptr)
{
int dmg = player->fishing->retrieve();
instance->hurtAndBreak(dmg, player);
@@ -44,7 +44,7 @@ shared_ptr<ItemInstance> FishingRodItem::use(shared_ptr<ItemInstance> instance,
if (!level->isClientSide)
{
// 4J Stu - Move the player->fishing out of the ctor as we cannot reference 'this'
- shared_ptr<FishingHook> hook = shared_ptr<FishingHook>( new FishingHook(level, player) );
+ shared_ptr<FishingHook> hook = std::make_shared<FishingHook>(level, player);
player->fishing = hook;
level->addEntity( shared_ptr<FishingHook>( hook ) );
}
diff --git a/Minecraft.World/FixedBiomeSource.cpp b/Minecraft.World/FixedBiomeSource.cpp
index 257ec3db..2657bdb4 100644
--- a/Minecraft.World/FixedBiomeSource.cpp
+++ b/Minecraft.World/FixedBiomeSource.cpp
@@ -26,9 +26,9 @@ float FixedBiomeSource::getTemperature(int x, int z)
void FixedBiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z, int w, int h) const
{
- if (temperatures.data == NULL || temperatures.length < w * h)
+ if (temperatures.data == nullptr || temperatures.length < w * h)
{
- if(temperatures.data != NULL) delete [] temperatures.data;
+ if(temperatures.data != nullptr) delete [] temperatures.data;
temperatures = floatArray(w * h);
}
@@ -52,9 +52,9 @@ void FixedBiomeSource::getTemperatureBlock(doubleArray& temperatures, int x, int
void FixedBiomeSource::getDownfallBlock(floatArray &downfalls, int x, int z, int w, int h) const
{
- if (downfalls.data == NULL || downfalls.length < w * h)
+ if (downfalls.data == nullptr || downfalls.length < w * h)
{
- if(downfalls.data != NULL) delete [] downfalls.data;
+ if(downfalls.data != nullptr) delete [] downfalls.data;
downfalls = floatArray(w * h);
}
Arrays::fill(downfalls, 0, w * h, downfall);
@@ -74,9 +74,9 @@ float FixedBiomeSource::getDownfall(int x, int z) const
void FixedBiomeSource::getDownfallBlock(doubleArray downfalls, int x, int z, int w, int h)
{
- if (downfalls.data == NULL || downfalls.length < w * h)
+ if (downfalls.data == nullptr || downfalls.length < w * h)
{
- if(downfalls.data != NULL) delete [] downfalls.data;
+ if(downfalls.data != nullptr) delete [] downfalls.data;
downfalls = doubleArray(w * h);
}
Arrays::fill(downfalls, 0, w * h, (double) downfall);
@@ -129,7 +129,7 @@ TilePos *FixedBiomeSource::findBiome(int x, int z, int r, Biome *toFind, Random
return new TilePos(x - r + random->nextInt(r * 2 + 1), 0, z - r + random->nextInt(r * 2 + 1));
}
- return NULL;
+ return nullptr;
}
TilePos *FixedBiomeSource::findBiome(int x, int z, int r, vector<Biome *> allowed, Random *random)
@@ -139,7 +139,7 @@ TilePos *FixedBiomeSource::findBiome(int x, int z, int r, vector<Biome *> allowe
return new TilePos(x - r + random->nextInt(r * 2 + 1), 0, z - r + random->nextInt(r * 2 + 1));
}
- return NULL;
+ return nullptr;
}
bool FixedBiomeSource::containsOnly(int x, int z, int r, Biome *allowed)
diff --git a/Minecraft.World/FlatGeneratorInfo.cpp b/Minecraft.World/FlatGeneratorInfo.cpp
index dfd4cb66..c983fd2c 100644
--- a/Minecraft.World/FlatGeneratorInfo.cpp
+++ b/Minecraft.World/FlatGeneratorInfo.cpp
@@ -66,7 +66,7 @@ wstring FlatGeneratorInfo::toString()
builder.append(SERIALIZATION_VERSION);
builder.append(";");
- for (int i = 0; i < layers.size(); i++)
+ for (size_t i = 0; i < layers.size(); i++)
{
if (i > 0) builder.append(",");
builder.append(layers.get(i).toString());
@@ -114,7 +114,7 @@ wstring FlatGeneratorInfo::toString()
FlatLayerInfo *FlatGeneratorInfo::getLayerFromString(const wstring &input, int yOffset)
{
- return NULL;
+ return nullptr;
#if 0
std::vector<std::wstring> parts = stringSplit(input, L'x');
@@ -135,7 +135,7 @@ FlatLayerInfo *FlatGeneratorInfo::getLayerFromString(const wstring &input, int y
id = _fromString<int>(parts[0]);
if (parts.size() > 1) data = _from_String<int>(parts[1]);
- if (Tile::tiles[id] == NULL)
+ if (Tile::tiles[id] == nullptr)
{
id = 0;
data = 0;
@@ -151,7 +151,7 @@ FlatLayerInfo *FlatGeneratorInfo::getLayerFromString(const wstring &input, int y
vector<FlatLayerInfo *> *FlatGeneratorInfo::getLayersFromString(const wstring &input)
{
- if (input.empty()) return NULL;
+ if (input.empty()) return nullptr;
vector<FlatLayerInfo *> *result = new vector<FlatLayerInfo *>();
std::vector<std::wstring> depths = stringSplit(input, L',');
@@ -161,7 +161,7 @@ vector<FlatLayerInfo *> *FlatGeneratorInfo::getLayersFromString(const wstring &i
for(auto& depth : depths)
{
FlatLayerInfo *layer = getLayerFromString(depth, yOffset);
- if (layer == NULL) return NULL;
+ if (layer == nullptr) return nullptr;
result->push_back(layer);
yOffset += layer->getHeight();
}
@@ -184,7 +184,7 @@ FlatGeneratorInfo *FlatGeneratorInfo::fromValue(const wstring &input)
int index = parts.size() == 1 ? 0 : 1;
vector<FlatLayerInfo *> *layers = getLayersFromString(parts[index++]);
- if (layers == NULL || layers->isEmpty())
+ if (layers == nullptr || layers->isEmpty())
{
delete layers;
return getDefault();
diff --git a/Minecraft.World/FlatLevelSource.cpp b/Minecraft.World/FlatLevelSource.cpp
index ec2c0f96..9ea1ed36 100644
--- a/Minecraft.World/FlatLevelSource.cpp
+++ b/Minecraft.World/FlatLevelSource.cpp
@@ -55,7 +55,7 @@ void FlatLevelSource::prepareHeights(byteArray blocks)
{
block = Tile::grass_Id;
}
- blocks[xc << 11 | zc << 7 | yc] = (byte) block;
+ blocks[xc << 11 | zc << 7 | yc] = static_cast<byte>(block);
}
}
}
@@ -70,7 +70,7 @@ LevelChunk *FlatLevelSource::getChunk(int xOffs, int zOffs)
{
// 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed
int chunksSize = Level::genDepth * 16 * 16;
- byte *tileData = (byte *)XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
+ byte *tileData = static_cast<byte *>(XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, PAGE_READWRITE));
XMemSet128(tileData,0,chunksSize);
byteArray blocks = byteArray(tileData,chunksSize);
// byteArray blocks = byteArray(16 * level->depth * 16);
@@ -141,15 +141,15 @@ vector<Biome::MobSpawnerData *> *FlatLevelSource::getMobsAt(MobCategory *mobCate
{
Biome *biome = level->getBiome(x, z);
if (biome == NULL)
- {
- return NULL;
+ {
+ return nullptr;
}
return biome->getMobs(mobCategory);
}
TilePos *FlatLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
void FlatLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ)
diff --git a/Minecraft.World/FleeSunGoal.cpp b/Minecraft.World/FleeSunGoal.cpp
index d58ad709..bf1c04ad 100644
--- a/Minecraft.World/FleeSunGoal.cpp
+++ b/Minecraft.World/FleeSunGoal.cpp
@@ -18,10 +18,10 @@ bool FleeSunGoal::canUse()
{
if (!level->isDay()) return false;
if (!mob->isOnFire()) return false;
- if (!level->canSeeSky(Mth::floor(mob->x), (int) mob->bb->y0, Mth::floor(mob->z))) return false;
+ if (!level->canSeeSky(Mth::floor(mob->x), static_cast<int>(mob->bb->y0), Mth::floor(mob->z))) return false;
Vec3 *pos = getHidePos();
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
wantedX = pos->x;
wantedY = pos->y;
wantedZ = pos->z;
@@ -48,5 +48,5 @@ Vec3 *FleeSunGoal::getHidePos()
int zt = Mth::floor(mob->z + random->nextInt(20) - 10);
if (!level->canSeeSky(xt, yt, zt) && mob->getWalkTargetValue(xt, yt, zt) < 0) return Vec3::newTemp(xt, yt, zt);
}
- return NULL;
+ return nullptr;
} \ No newline at end of file
diff --git a/Minecraft.World/FlippedIcon.cpp b/Minecraft.World/FlippedIcon.cpp
index 559423d7..37122bfc 100644
--- a/Minecraft.World/FlippedIcon.cpp
+++ b/Minecraft.World/FlippedIcon.cpp
@@ -41,7 +41,7 @@ float FlippedIcon::getU1(bool adjust/*=false*/) const
float FlippedIcon::getU(double offset, bool adjust/*=false*/) const
{
float diff = getU1(adjust) - getU0(adjust);
- return getU0(adjust) + (diff * ((float) offset / SharedConstants::WORLD_RESOLUTION));
+ return getU0(adjust) + (diff * (static_cast<float>(offset) / SharedConstants::WORLD_RESOLUTION));
}
float FlippedIcon::getV0(bool adjust/*=false*/) const
@@ -59,7 +59,7 @@ float FlippedIcon::getV1(bool adjust/*=false*/) const
float FlippedIcon::getV(double offset, bool adjust/*=false*/) const
{
float diff = getV1(adjust) - getV0(adjust);
- return getV0(adjust) + (diff * ((float) offset / SharedConstants::WORLD_RESOLUTION));
+ return getV0(adjust) + (diff * (static_cast<float>(offset) / SharedConstants::WORLD_RESOLUTION));
}
wstring FlippedIcon::getName() const
diff --git a/Minecraft.World/FloatTag.h b/Minecraft.World/FloatTag.h
index 80301649..cc687da8 100644
--- a/Minecraft.World/FloatTag.h
+++ b/Minecraft.World/FloatTag.h
@@ -29,7 +29,7 @@ public:
{
if (Tag::equals(obj))
{
- FloatTag *o = (FloatTag *) obj;
+ FloatTag *o = static_cast<FloatTag *>(obj);
return data == o->data;
}
return false;
diff --git a/Minecraft.World/FlowerFeature.cpp b/Minecraft.World/FlowerFeature.cpp
index f24d61bf..c5cd68c6 100644
--- a/Minecraft.World/FlowerFeature.cpp
+++ b/Minecraft.World/FlowerFeature.cpp
@@ -12,7 +12,7 @@ FlowerFeature::FlowerFeature(int tile)
bool FlowerFeature::place(Level *level, Random *random, int x, int y, int z)
{
// 4J Stu Added to stop tree features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
bool intersects = levelGenOptions->checkIntersects(x - 8, y - 4, z - 8, x + 8, y + 4, z + 8);
diff --git a/Minecraft.World/FlowerPotTile.cpp b/Minecraft.World/FlowerPotTile.cpp
index 4cdd529c..80fdf2e4 100644
--- a/Minecraft.World/FlowerPotTile.cpp
+++ b/Minecraft.World/FlowerPotTile.cpp
@@ -36,7 +36,7 @@ bool FlowerPotTile::isCubeShaped()
bool FlowerPotTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly)
{
shared_ptr<ItemInstance> item = player->inventory->getSelected();
- if (item == NULL) return false;
+ if (item == nullptr) return false;
if (level->getData(x, y, z) != 0) return false;
int type = getTypeFromItem(item);
@@ -62,7 +62,7 @@ int FlowerPotTile::cloneTileId(Level *level, int x, int y, int z)
{
shared_ptr<ItemInstance> item = getItemFromType(level->getData(x, y, z));
- if (item == NULL)
+ if (item == nullptr)
{
return Item::flowerPot_Id;
}
@@ -76,7 +76,7 @@ int FlowerPotTile::cloneTileData(Level *level, int x, int y, int z)
{
shared_ptr<ItemInstance> item = getItemFromType(level->getData(x, y, z));
- if (item == NULL)
+ if (item == nullptr)
{
return Item::flowerPot_Id;
}
@@ -113,7 +113,7 @@ void FlowerPotTile::spawnResources(Level *level, int x, int y, int z, int data,
if (data > 0)
{
shared_ptr<ItemInstance> item = getItemFromType(data);
- if (item != NULL) popResource(level, x, y, z, item);
+ if (item != nullptr) popResource(level, x, y, z, item);
}
}
@@ -127,27 +127,27 @@ shared_ptr<ItemInstance> FlowerPotTile::getItemFromType(int type)
switch (type)
{
case TYPE_FLOWER_RED:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::rose) );
+ return std::make_shared<ItemInstance>(Tile::rose);
case TYPE_FLOWER_YELLOW:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::flower) );
+ return std::make_shared<ItemInstance>(Tile::flower);
case TYPE_CACTUS:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::cactus) );
+ return std::make_shared<ItemInstance>(Tile::cactus);
case TYPE_MUSHROOM_BROWN:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::mushroom_brown) );
+ return std::make_shared<ItemInstance>(Tile::mushroom_brown);
case TYPE_MUSHROOM_RED:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::mushroom_red) );
+ return std::make_shared<ItemInstance>(Tile::mushroom_red);
case TYPE_DEAD_BUSH:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::deadBush) );
+ return std::make_shared<ItemInstance>(Tile::deadBush);
case TYPE_SAPLING_DEFAULT:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_DEFAULT) );
+ return std::make_shared<ItemInstance>(Tile::sapling, 1, Sapling::TYPE_DEFAULT);
case TYPE_SAPLING_BIRCH:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_BIRCH) );
+ return std::make_shared<ItemInstance>(Tile::sapling, 1, Sapling::TYPE_BIRCH);
case TYPE_SAPLING_EVERGREEN:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_EVERGREEN) );
+ return std::make_shared<ItemInstance>(Tile::sapling, 1, Sapling::TYPE_EVERGREEN);
case TYPE_SAPLING_JUNGLE:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_JUNGLE) );
+ return std::make_shared<ItemInstance>(Tile::sapling, 1, Sapling::TYPE_JUNGLE);
case TYPE_FERN:
- return shared_ptr<ItemInstance>( new ItemInstance(Tile::tallgrass, 1, TallGrass::FERN) );
+ return std::make_shared<ItemInstance>(Tile::tallgrass, 1, TallGrass::FERN);
}
return nullptr;
diff --git a/Minecraft.World/FlyingMob.cpp b/Minecraft.World/FlyingMob.cpp
index 1757ae58..28404108 100644
--- a/Minecraft.World/FlyingMob.cpp
+++ b/Minecraft.World/FlyingMob.cpp
@@ -75,7 +75,7 @@ void FlyingMob::travel(float xa, float ya)
walkAnimSpeedO = walkAnimSpeed;
double xxd = x - xo;
double zzd = z - zo;
- float wst = (float) sqrt(xxd * xxd + zzd * zzd) * 4;
+ float wst = static_cast<float>(sqrt(xxd * xxd + zzd * zzd)) * 4;
if (wst > 1) wst = 1;
walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f;
walkAnimPos += walkAnimSpeed;
diff --git a/Minecraft.World/FollowOwnerGoal.cpp b/Minecraft.World/FollowOwnerGoal.cpp
index 8565d782..89ec4643 100644
--- a/Minecraft.World/FollowOwnerGoal.cpp
+++ b/Minecraft.World/FollowOwnerGoal.cpp
@@ -25,7 +25,7 @@ FollowOwnerGoal::FollowOwnerGoal(TamableAnimal *tamable, double speedModifier, f
bool FollowOwnerGoal::canUse()
{
shared_ptr<LivingEntity> owner = dynamic_pointer_cast<LivingEntity>( tamable->getOwner() );
- if (owner == NULL) return false;
+ if (owner == nullptr) return false;
if (tamable->isSitting()) return false;
if (tamable->distanceToSqr(owner) < startDistance * startDistance) return false;
this->owner = weak_ptr<LivingEntity>(owner);
@@ -34,7 +34,7 @@ bool FollowOwnerGoal::canUse()
bool FollowOwnerGoal::canContinueToUse()
{
- return owner.lock() != NULL && !navigation->isDone() && tamable->distanceToSqr(owner.lock()) > stopDistance * stopDistance && !tamable->isSitting();
+ return owner.lock() != nullptr && !navigation->isDone() && tamable->distanceToSqr(owner.lock()) > stopDistance * stopDistance && !tamable->isSitting();
}
void FollowOwnerGoal::start()
diff --git a/Minecraft.World/FollowParentGoal.cpp b/Minecraft.World/FollowParentGoal.cpp
index 8983590a..d8f3bad9 100644
--- a/Minecraft.World/FollowParentGoal.cpp
+++ b/Minecraft.World/FollowParentGoal.cpp
@@ -33,7 +33,7 @@ bool FollowParentGoal::canUse()
}
delete parents;
- if (closest == NULL) return false;
+ if (closest == nullptr) return false;
if (closestDistSqr < 3 * 3) return false;
parent = weak_ptr<Animal>(closest);
return true;
@@ -41,7 +41,7 @@ bool FollowParentGoal::canUse()
bool FollowParentGoal::canContinueToUse()
{
- if (parent.lock() == NULL || !parent.lock()->isAlive()) return false;
+ if (parent.lock() == nullptr || !parent.lock()->isAlive()) return false;
double distSqr = animal->distanceToSqr(parent.lock());
if (distSqr < 3 * 3 || distSqr > 16 * 16) return false;
return true;
diff --git a/Minecraft.World/FoodConstants.cpp b/Minecraft.World/FoodConstants.cpp
index 6ced45d5..a8e024a2 100644
--- a/Minecraft.World/FoodConstants.cpp
+++ b/Minecraft.World/FoodConstants.cpp
@@ -3,8 +3,8 @@
#include "FoodConstants.h"
const int FoodConstants::MAX_FOOD = 20;
-const float FoodConstants::MAX_SATURATION = (float) FoodConstants::MAX_FOOD;
-const float FoodConstants::START_SATURATION = (float) FoodConstants::MAX_SATURATION / 4.0f;
+const float FoodConstants::MAX_SATURATION = static_cast<float>(FoodConstants::MAX_FOOD);
+const float FoodConstants::START_SATURATION = static_cast<float>(FoodConstants::MAX_SATURATION) / 4.0f;
const float FoodConstants::SATURATION_FLOOR = FoodConstants::MAX_SATURATION / 8.0f;
// this value modifies how quickly food is dropped
diff --git a/Minecraft.World/FoodItem.h b/Minecraft.World/FoodItem.h
index 16e6ce3f..3fa04ed4 100644
--- a/Minecraft.World/FoodItem.h
+++ b/Minecraft.World/FoodItem.h
@@ -8,7 +8,7 @@ class Level;
class FoodItem : public Item
{
public:
- static const int EAT_DURATION = (int) (20 * 1.6);
+ static const int EAT_DURATION = static_cast<int>(20 * 1.6);
private:
const int nutrition;
diff --git a/Minecraft.World/FurnaceMenu.cpp b/Minecraft.World/FurnaceMenu.cpp
index f67d6388..2bc2d2bd 100644
--- a/Minecraft.World/FurnaceMenu.cpp
+++ b/Minecraft.World/FurnaceMenu.cpp
@@ -86,7 +86,7 @@ shared_ptr<ItemInstance> FurnaceMenu::quickMoveStack(shared_ptr<Player> player,
bool charcoalUsed = furnace->wasCharcoalUsed();
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
@@ -112,7 +112,7 @@ shared_ptr<ItemInstance> FurnaceMenu::quickMoveStack(shared_ptr<Player> player,
return nullptr;
}
}
- else if (FurnaceRecipes::getInstance()->getResult(stack->getItem()->id) != NULL)
+ else if (FurnaceRecipes::getInstance()->getResult(stack->getItem()->id) != nullptr)
{
if (!moveItemStackTo(stack, INGREDIENT_SLOT, INGREDIENT_SLOT + 1, false))
{
diff --git a/Minecraft.World/FurnaceRecipes.cpp b/Minecraft.World/FurnaceRecipes.cpp
index bed4e1b6..f0a4c770 100644
--- a/Minecraft.World/FurnaceRecipes.cpp
+++ b/Minecraft.World/FurnaceRecipes.cpp
@@ -3,7 +3,7 @@
#include "Tile.h"
#include "FurnaceRecipes.h"
-FurnaceRecipes *FurnaceRecipes::instance = NULL;
+FurnaceRecipes *FurnaceRecipes::instance = nullptr;
void FurnaceRecipes::staticCtor()
{
@@ -63,7 +63,7 @@ ItemInstance *FurnaceRecipes::getResult(int itemId)
{
return it->second;
}
- return NULL;
+ return nullptr;
}
unordered_map<int, ItemInstance *> *FurnaceRecipes::getRecipies()
diff --git a/Minecraft.World/FurnaceResultSlot.cpp b/Minecraft.World/FurnaceResultSlot.cpp
index d845dada..48f2f8fb 100644
--- a/Minecraft.World/FurnaceResultSlot.cpp
+++ b/Minecraft.World/FurnaceResultSlot.cpp
@@ -61,8 +61,8 @@ void FurnaceResultSlot::checkTakeAchievements(shared_ptr<ItemInstance> carried)
}
else if (value < 1)
{
- int baseValue = floor((float) amount * value);
- if (baseValue < ceil((float) amount * value) && (float) Math::random() < (((float) amount * value) - baseValue))
+ int baseValue = floor(static_cast<float>(amount) * value);
+ if (baseValue < ceil(static_cast<float>(amount) * value) && static_cast<float>(Math::random()) < ((static_cast<float>(amount) * value) - baseValue))
{
baseValue++;
}
@@ -73,7 +73,7 @@ void FurnaceResultSlot::checkTakeAchievements(shared_ptr<ItemInstance> carried)
{
int newCount = ExperienceOrb::getExperienceValue(amount);
amount -= newCount;
- player->level->addEntity(shared_ptr<ExperienceOrb>( new ExperienceOrb(player->level, player->x, player->y + .5, player->z + .5, newCount) ));
+ player->level->addEntity(std::make_shared<ExperienceOrb>(player->level, player->x, player->y + .5, player->z + .5, newCount));
}
}
diff --git a/Minecraft.World/FurnaceTile.cpp b/Minecraft.World/FurnaceTile.cpp
index d22d6ca7..d8856f4e 100644
--- a/Minecraft.World/FurnaceTile.cpp
+++ b/Minecraft.World/FurnaceTile.cpp
@@ -17,8 +17,8 @@ FurnaceTile::FurnaceTile(int id, bool lit) : BaseEntityTile(id, Material::stone)
random = new Random();
this->lit = lit;
- iconTop = NULL;
- iconFront = NULL;
+ iconTop = nullptr;
+ iconFront = nullptr;
}
int FurnaceTile::getResource(int data, Random *random, int playerBonusLevel)
@@ -117,7 +117,7 @@ bool FurnaceTile::use(Level *level, int x, int y, int z, shared_ptr<Player> play
return true;
}
shared_ptr<FurnaceTileEntity> furnace = dynamic_pointer_cast<FurnaceTileEntity>( level->getTileEntity(x, y, z) );
- if (furnace != NULL ) player->openFurnace(furnace);
+ if (furnace != nullptr ) player->openFurnace(furnace);
return true;
}
@@ -132,7 +132,7 @@ void FurnaceTile::setLit(bool lit, Level *level, int x, int y, int z)
noDrop = false;
level->setData(x, y, z, data, Tile::UPDATE_CLIENTS);
- if( te != NULL )
+ if( te != nullptr )
{
te->clearRemoved();
level->setTileEntity(x, y, z, te);
@@ -141,7 +141,7 @@ void FurnaceTile::setLit(bool lit, Level *level, int x, int y, int z)
shared_ptr<TileEntity> FurnaceTile::newTileEntity(Level *level)
{
- return shared_ptr<FurnaceTileEntity>( new FurnaceTileEntity() );
+ return std::make_shared<FurnaceTileEntity>();
}
void FurnaceTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance)
@@ -164,12 +164,12 @@ void FurnaceTile::onRemove(Level *level, int x, int y, int z, int id, int data)
if (!noDrop)
{
shared_ptr<Container> container = dynamic_pointer_cast<FurnaceTileEntity>( level->getTileEntity(x, y, z) );
- if( container != NULL )
+ if( container != nullptr )
{
for (unsigned int i = 0; i < container->getContainerSize(); i++)
{
shared_ptr<ItemInstance> 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;
@@ -192,16 +192,16 @@ void FurnaceTile::onRemove(Level *level, int x, int y, int z, int id, int data)
}
#endif
- shared_ptr<ItemInstance> newItem = shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue()) );
+ shared_ptr<ItemInstance> newItem = std::make_shared<ItemInstance>(item->id, count, item->getAuxValue());
newItem->set4JData( item->get4JData() );
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, newItem) );
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, newItem);
float pow = 0.05f;
- itemEntity->xd = (float) random->nextGaussian() * pow;
- itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f;
- itemEntity->zd = (float) random->nextGaussian() * pow;
+ itemEntity->xd = static_cast<float>(random->nextGaussian()) * pow;
+ itemEntity->yd = static_cast<float>(random->nextGaussian()) * pow + 0.2f;
+ itemEntity->zd = static_cast<float>(random->nextGaussian()) * pow;
if (item->hasTag())
{
- itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy());
+ itemEntity->getItem()->setTag(static_cast<CompoundTag *>(item->getTag()->copy()));
}
level->addEntity(itemEntity);
}
diff --git a/Minecraft.World/FurnaceTileEntity.cpp b/Minecraft.World/FurnaceTileEntity.cpp
index 1aa2c300..901235c0 100644
--- a/Minecraft.World/FurnaceTileEntity.cpp
+++ b/Minecraft.World/FurnaceTileEntity.cpp
@@ -53,7 +53,7 @@ shared_ptr<ItemInstance> FurnaceTileEntity::removeItem(unsigned int slot, int co
{
m_charcoalUsed = false;
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
if (items[slot]->count <= count)
{
@@ -79,7 +79,7 @@ shared_ptr<ItemInstance> FurnaceTileEntity::removeItemNoUpdate(int slot)
{
m_charcoalUsed = false;
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
shared_ptr<ItemInstance> item = items[slot];
items[slot] = nullptr;
@@ -92,7 +92,7 @@ shared_ptr<ItemInstance> FurnaceTileEntity::removeItemNoUpdate(int slot)
void FurnaceTileEntity::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
items[slot] = item;
- if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize();
+ if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize();
}
@@ -140,16 +140,16 @@ void FurnaceTileEntity::load(CompoundTag *base)
void FurnaceTileEntity::save(CompoundTag *base)
{
TileEntity::save(base);
- base->putShort(L"BurnTime", (short) (litTime));
- base->putShort(L"CookTime", (short) (tickCount));
+ base->putShort(L"BurnTime", static_cast<short>(litTime));
+ base->putShort(L"CookTime", static_cast<short>(tickCount));
ListTag<CompoundTag> *listTag = new ListTag<CompoundTag>();
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", (byte) i);
+ tag->putByte(L"Slot", static_cast<byte>(i));
items[i]->save(tag);
listTag->add(tag);
}
@@ -194,7 +194,7 @@ void FurnaceTileEntity::tick()
litTime--;
}
- if ( level != NULL && !level->isClientSide)
+ if ( level != nullptr && !level->isClientSide)
{
if (litTime == 0 && canBurn())
{
@@ -202,7 +202,7 @@ void FurnaceTileEntity::tick()
if (litTime > 0)
{
changed = true;
- if (items[SLOT_FUEL] != NULL)
+ if (items[SLOT_FUEL] != nullptr)
{
// 4J Added: Keep track of whether charcoal was used in production of current stack.
if ( items[SLOT_FUEL]->getItem()->id == Item::coal_Id
@@ -215,7 +215,7 @@ void FurnaceTileEntity::tick()
if (items[SLOT_FUEL]->count == 0)
{
Item *remaining = items[SLOT_FUEL]->getItem()->getCraftingRemainingItem();
- items[SLOT_FUEL] = remaining != NULL ? shared_ptr<ItemInstance>(new ItemInstance(remaining)) : nullptr;
+ items[SLOT_FUEL] = remaining != nullptr ? std::make_shared<ItemInstance>(remaining) : nullptr;
}
}
}
@@ -249,10 +249,10 @@ void FurnaceTileEntity::tick()
bool FurnaceTileEntity::canBurn()
{
- if (items[SLOT_INPUT] == NULL) return false;
+ if (items[SLOT_INPUT] == nullptr) return false;
const ItemInstance *burnResult = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
- if (burnResult == NULL) return false;
- if (items[SLOT_RESULT] == NULL) return true;
+ if (burnResult == nullptr) return false;
+ if (items[SLOT_RESULT] == nullptr) return true;
if (!items[SLOT_RESULT]->sameItem_not_shared(burnResult)) return false;
if (items[SLOT_RESULT]->count < getMaxStackSize() && items[SLOT_RESULT]->count < items[SLOT_RESULT]->getMaxStackSize()) return true;
if (items[SLOT_RESULT]->count < burnResult->getMaxStackSize()) return true;
@@ -265,7 +265,7 @@ void FurnaceTileEntity::burn()
if (!canBurn()) return;
const ItemInstance *result = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
- if (items[SLOT_RESULT] == NULL) items[SLOT_RESULT] = result->copy();
+ if (items[SLOT_RESULT] == nullptr) items[SLOT_RESULT] = result->copy();
else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++;
items[SLOT_INPUT]->count--;
@@ -275,12 +275,12 @@ void FurnaceTileEntity::burn()
int FurnaceTileEntity::getBurnDuration(shared_ptr<ItemInstance> 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];
@@ -300,15 +300,15 @@ int FurnaceTileEntity::getBurnDuration(shared_ptr<ItemInstance> itemInstance)
}
}
- if (dynamic_cast<DiggerItem *>(item) && ((DiggerItem *) item)->getTier() == Item::Tier::WOOD)
+ if (dynamic_cast<DiggerItem *>(item) && static_cast<DiggerItem *>(item)->getTier() == Item::Tier::WOOD)
{
return BURN_INTERVAL;
}
- else if (dynamic_cast<WeaponItem *>(item) && ((WeaponItem *) item)->getTier() == Item::Tier::WOOD)
+ else if (dynamic_cast<WeaponItem *>(item) && static_cast<WeaponItem *>(item)->getTier() == Item::Tier::WOOD)
{
return BURN_INTERVAL;
}
- else if (dynamic_cast<HoeItem *>(item) && ((HoeItem *) item)->getTier() == Item::Tier::WOOD)
+ else if (dynamic_cast<HoeItem *>(item) && static_cast<HoeItem *>(item)->getTier() == Item::Tier::WOOD)
{
return BURN_INTERVAL;
}
@@ -396,7 +396,7 @@ bool FurnaceTileEntity::canTakeItemThroughFace(int slot, shared_ptr<ItemInstance
// 4J Added
shared_ptr<TileEntity> FurnaceTileEntity::clone()
{
- shared_ptr<FurnaceTileEntity> result = shared_ptr<FurnaceTileEntity>( new FurnaceTileEntity() );
+ shared_ptr<FurnaceTileEntity> result = std::make_shared<FurnaceTileEntity>();
TileEntity::clone(result);
result->litTime = litTime;
@@ -405,7 +405,7 @@ shared_ptr<TileEntity> FurnaceTileEntity::clone()
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL)
+ if (items[i] != nullptr)
{
result->items[i] = ItemInstance::clone(items[i]);
}
diff --git a/Minecraft.World/FuzzyZoomLayer.cpp b/Minecraft.World/FuzzyZoomLayer.cpp
index 54155ff5..c8cbf553 100644
--- a/Minecraft.World/FuzzyZoomLayer.cpp
+++ b/Minecraft.World/FuzzyZoomLayer.cpp
@@ -66,7 +66,7 @@ shared_ptr<Layer>FuzzyZoomLayer::zoom(int64_t seed, shared_ptr<Layer>sup, int co
shared_ptr<Layer> result = sup;
for (int i = 0; i < count; i++)
{
- result = shared_ptr<Layer>(new FuzzyZoomLayer(seed + i, result));
+ result = std::make_shared<FuzzyZoomLayer>(seed + i, result);
}
return result;
} \ No newline at end of file
diff --git a/Minecraft.World/GameCommandPacket.cpp b/Minecraft.World/GameCommandPacket.cpp
index 98cdd312..17c5316a 100644
--- a/Minecraft.World/GameCommandPacket.cpp
+++ b/Minecraft.World/GameCommandPacket.cpp
@@ -15,7 +15,7 @@ GameCommandPacket::GameCommandPacket(EGameCommand command, byteArray data)
this->data = data;
length = 0;
- if (data.data != NULL)
+ if (data.data != nullptr)
{
length = data.length;
@@ -37,12 +37,12 @@ GameCommandPacket::~GameCommandPacket()
void GameCommandPacket::read(DataInputStream *dis)
{
- command = (EGameCommand)dis->readInt();
+ command = static_cast<EGameCommand>(dis->readInt());
length = dis->readShort();
if (length > 0 && length < Short::MAX_VALUE)
{
- if(data.data != NULL)
+ if(data.data != nullptr)
{
delete [] data.data;
}
@@ -54,8 +54,8 @@ void GameCommandPacket::read(DataInputStream *dis)
void GameCommandPacket::write(DataOutputStream *dos)
{
dos->writeInt(command);
- dos->writeShort((short) length);
- if (data.data != NULL)
+ dos->writeShort(static_cast<short>(length));
+ if (data.data != nullptr)
{
dos->write(data);
}
diff --git a/Minecraft.World/GameCommandPacket.h b/Minecraft.World/GameCommandPacket.h
index 1f63e950..d4827974 100644
--- a/Minecraft.World/GameCommandPacket.h
+++ b/Minecraft.World/GameCommandPacket.h
@@ -21,6 +21,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new GameCommandPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<GameCommandPacket>(); }
virtual int getId() { return 167; }
}; \ No newline at end of file
diff --git a/Minecraft.World/GameEventPacket.h b/Minecraft.World/GameEventPacket.h
index 93ea911c..c1134e7f 100644
--- a/Minecraft.World/GameEventPacket.h
+++ b/Minecraft.World/GameEventPacket.h
@@ -40,6 +40,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new GameEventPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<GameEventPacket>(); }
virtual int getId() { return 70; }
}; \ No newline at end of file
diff --git a/Minecraft.World/GameModeCommand.cpp b/Minecraft.World/GameModeCommand.cpp
index f8c1ffb6..6e4cd858 100644
--- a/Minecraft.World/GameModeCommand.cpp
+++ b/Minecraft.World/GameModeCommand.cpp
@@ -37,7 +37,7 @@ void GameModeCommand::execute(shared_ptr<CommandSender> source, byteArray comman
GameType *GameModeCommand::getModeForString(shared_ptr<CommandSender> source, const wstring &name)
{
- return NULL;
+ return nullptr;
//if (name.equalsIgnoreCase(GameType.SURVIVAL.getName()) || name.equalsIgnoreCase("s")) {
// return GameType.SURVIVAL;
//} else if (name.equalsIgnoreCase(GameType.CREATIVE.getName()) || name.equalsIgnoreCase("c")) {
diff --git a/Minecraft.World/GenericStats.cpp b/Minecraft.World/GenericStats.cpp
index 1fa90151..d97c182a 100644
--- a/Minecraft.World/GenericStats.cpp
+++ b/Minecraft.World/GenericStats.cpp
@@ -4,161 +4,161 @@
#include "GenericStats.h"
-GenericStats *GenericStats::instance = NULL;
+GenericStats *GenericStats::instance = nullptr;
Stat* GenericStats::get_walkOneM()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_swimOneM()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_fallOneM()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_climbOneM()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_minecartOneM()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_boatOneM()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_pigOneM()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_portalsCreated()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_cowsMilked()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_netherLavaCollected()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killMob()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsZombie()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsSkeleton()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsCreeper()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsSpider()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsSpiderJockey()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsZombiePigman()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsSlime()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsGhast()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsNetherZombiePigman()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_breedEntity(eINSTANCEOF entityId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_tamedEntity(eINSTANCEOF entityId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_curedEntity(eINSTANCEOF entityId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_craftedEntity(eINSTANCEOF entityId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_shearedEntity(eINSTANCEOF entityId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_totalBlocksMined()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_timePlayed()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_blocksPlaced(int blockId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_blocksMined(int blockId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_itemsCollected(int itemId, int itemAux)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_itemsCrafted(int itemId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_itemsSmelted(int itemId)
@@ -168,37 +168,37 @@ Stat* GenericStats::get_itemsSmelted(int itemId)
Stat* GenericStats::get_itemsUsed(int itemId)
{
- return NULL;
+ return nullptr;
}
Stat *GenericStats::get_itemsBought(int itemId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_killsEnderdragon()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_completeTheEnd()
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_changedDimension(int from, int to)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_enteredBiome(int biomeId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::get_achievement(eAward achievementId)
{
- return NULL;
+ return nullptr;
}
Stat* GenericStats::openInventory()
@@ -286,7 +286,7 @@ Stat* GenericStats::snipeSkeleton()
#ifndef _XBOX
return instance->get_achievement( eAward_snipeSkeleton );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -295,7 +295,7 @@ Stat* GenericStats::diamonds()
#ifndef _XBOX
return instance->get_achievement( eAward_diamonds );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -304,7 +304,7 @@ Stat* GenericStats::ghast()
#ifndef _XBOX
return instance->get_achievement( eAward_ghast );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -313,7 +313,7 @@ Stat* GenericStats::blazeRod()
#ifndef _XBOX
return instance->get_achievement( eAward_blazeRod );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -322,7 +322,7 @@ Stat* GenericStats::potion()
#ifndef _XBOX
return instance->get_achievement( eAward_potion );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -331,7 +331,7 @@ Stat* GenericStats::theEnd()
#ifndef _XBOX
return instance->get_achievement( eAward_theEnd );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -340,7 +340,7 @@ Stat* GenericStats::winGame()
#ifndef _XBOX
return instance->get_achievement( eAward_winGame );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -349,7 +349,7 @@ Stat* GenericStats::enchantments()
#ifndef _XBOX
return instance->get_achievement( eAward_enchantments );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -358,7 +358,7 @@ Stat* GenericStats::overkill()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement( eAward_overkill );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -367,7 +367,7 @@ Stat* GenericStats::bookcase()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement( eAward_bookcase );
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -426,7 +426,7 @@ Stat* GenericStats::adventuringTime()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_adventuringTime);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -435,7 +435,7 @@ Stat* GenericStats::repopulation()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_repopulation);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -444,7 +444,7 @@ Stat* GenericStats::porkChop()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_eatPorkChop);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -453,7 +453,7 @@ Stat* GenericStats::diamondsToYou()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_diamondsToYou);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -462,7 +462,7 @@ Stat* GenericStats::passingTheTime()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_play100Days);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -471,7 +471,7 @@ Stat* GenericStats::archer()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_arrowKillCreeper);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -480,7 +480,7 @@ Stat* GenericStats::theHaggler()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_theHaggler);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -489,7 +489,7 @@ Stat* GenericStats::potPlanter()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_potPlanter);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -498,7 +498,7 @@ Stat* GenericStats::itsASign()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_itsASign);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -507,7 +507,7 @@ Stat* GenericStats::ironBelly()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_ironBelly);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -516,7 +516,7 @@ Stat* GenericStats::haveAShearfulDay()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_haveAShearfulDay);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -525,7 +525,7 @@ Stat* GenericStats::rainbowCollection()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_rainbowCollection);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -534,7 +534,7 @@ Stat* GenericStats::stayinFrosty()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_stayinFrosty);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -543,7 +543,7 @@ Stat* GenericStats::chestfulOfCobblestone()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_chestfulOfCobblestone);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -552,7 +552,7 @@ Stat* GenericStats::renewableEnergy()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_renewableEnergy);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -561,7 +561,7 @@ Stat* GenericStats::musicToMyEars()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_musicToMyEars);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -570,7 +570,7 @@ Stat* GenericStats::bodyGuard()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_bodyGuard);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -579,7 +579,7 @@ Stat* GenericStats::ironMan()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_ironMan);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -588,7 +588,7 @@ Stat* GenericStats::zombieDoctor()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_zombieDoctor);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -597,7 +597,7 @@ Stat* GenericStats::lionTamer()
#ifdef _EXTENDED_ACHIEVEMENTS
return instance->get_achievement(eAward_lionTamer);
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -835,7 +835,7 @@ byteArray GenericStats::param_itemsSmelted(int id, int aux, int count)
byteArray GenericStats::param_itemsUsed(shared_ptr<Player> plr, shared_ptr<ItemInstance> itm)
{
- if ( (plr != NULL) && (itm != NULL) ) return instance->getParam_itemsUsed(plr, itm);
+ if ( (plr != nullptr) && (itm != nullptr) ) return instance->getParam_itemsUsed(plr, itm);
else return instance->getParam_noArgs();
}
@@ -846,7 +846,7 @@ byteArray GenericStats::param_itemsBought(int id, int aux, int count)
byteArray GenericStats::param_mobKill(shared_ptr<Player> plr, shared_ptr<Mob> mob, DamageSource *dmgSrc)
{
- if ( (plr != NULL) && (mob != NULL) ) return instance->getParam_mobKill(plr, mob, dmgSrc);
+ if ( (plr != nullptr) && (mob != nullptr) ) return instance->getParam_mobKill(plr, mob, dmgSrc);
else return instance->getParam_noArgs();
}
diff --git a/Minecraft.World/GetInfoPacket.h b/Minecraft.World/GetInfoPacket.h
index 90688f3e..a7c758ba 100644
--- a/Minecraft.World/GetInfoPacket.h
+++ b/Minecraft.World/GetInfoPacket.h
@@ -11,6 +11,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new GetInfoPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<GetInfoPacket>(); }
virtual int getId() { return 254; }
}; \ No newline at end of file
diff --git a/Minecraft.World/Ghast.cpp b/Minecraft.World/Ghast.cpp
index f0817791..738a42da 100644
--- a/Minecraft.World/Ghast.cpp
+++ b/Minecraft.World/Ghast.cpp
@@ -56,7 +56,7 @@ bool Ghast::hurt(DamageSource *source, float dmg)
if (isInvulnerable()) return false;
if (source->getMsgId() == ChatPacket::e_ChatDeathFireball)
{
- if ( (source->getEntity() != NULL) && source->getEntity()->instanceof(eTYPE_PLAYER) )
+ if ( (source->getEntity() != nullptr) && source->getEntity()->instanceof(eTYPE_PLAYER) )
{
// reflected fireball, kill the ghast
FlyingMob::hurt(source, 1000);
@@ -72,7 +72,7 @@ void Ghast::defineSynchedData()
{
FlyingMob::defineSynchedData();
- entityData->define(DATA_IS_CHARGING, (byte) 0);
+ entityData->define(DATA_IS_CHARGING, static_cast<byte>(0));
}
void Ghast::registerAttributes()
@@ -121,37 +121,37 @@ void Ghast::serverAiStep()
}
}
- if (target != NULL && target->removed) target = nullptr;
- if (target == NULL || retargetTime-- <= 0)
+ if (target != nullptr && target->removed) target = nullptr;
+ if (target == nullptr || retargetTime-- <= 0)
{
target = level->getNearestAttackablePlayer(shared_from_this(), 100);
- if (target != NULL)
+ if (target != nullptr)
{
retargetTime = 20;
}
}
double maxDist = 64.0f;
- if (target != NULL && target->distanceToSqr(shared_from_this()) < maxDist * maxDist)
+ if (target != nullptr && target->distanceToSqr(shared_from_this()) < maxDist * maxDist)
{
double xdd = target->x - x;
double ydd = (target->bb->y0 + target->bbHeight / 2) - (y + bbHeight / 2);
double zdd = target->z - z;
- yBodyRot = yRot = -(float) atan2(xdd, zdd) * 180 / PI;
+ yBodyRot = yRot = -static_cast<float>(atan2(xdd, zdd)) * 180 / PI;
if (canSee(target))
{
if (charge == 10)
{
// 4J - change brought forward from 1.2.3
- level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_WARNING, (int) x, (int) y, (int) z, 0);
+ level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_WARNING, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
}
charge++;
if (charge == 20)
{
// 4J - change brought forward from 1.2.3
- level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, (int) x, (int) y, (int) z, 0);
- shared_ptr<LargeFireball> ie = shared_ptr<LargeFireball>( new LargeFireball(level, dynamic_pointer_cast<Mob>( shared_from_this() ), xdd, ydd, zdd) );
+ level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
+ shared_ptr<LargeFireball> ie = std::make_shared<LargeFireball>(level, dynamic_pointer_cast<Mob>(shared_from_this()), xdd, ydd, zdd);
ie->explosionPower = explosionPower;
double d = 4;
Vec3 *v = getViewVector(1);
@@ -169,14 +169,14 @@ void Ghast::serverAiStep()
}
else
{
- yBodyRot = yRot = -(float) atan2(this->xd, this->zd) * 180 / PI;
+ yBodyRot = yRot = -static_cast<float>(atan2(this->xd, this->zd)) * 180 / PI;
if (charge > 0) charge--;
}
if (!level->isClientSide)
{
byte old = entityData->getByte(DATA_IS_CHARGING);
- byte current = (byte) (charge > 10 ? 1 : 0);
+ byte current = static_cast<byte>(charge > 10 ? 1 : 0);
if (old != current)
{
entityData->set(DATA_IS_CHARGING, current);
diff --git a/Minecraft.World/GiveItemCommand.cpp b/Minecraft.World/GiveItemCommand.cpp
index b3cbff4f..fa06d80d 100644
--- a/Minecraft.World/GiveItemCommand.cpp
+++ b/Minecraft.World/GiveItemCommand.cpp
@@ -30,9 +30,9 @@ void GiveItemCommand::execute(shared_ptr<CommandSender> source, byteArray comman
bais.reset();
shared_ptr<ServerPlayer> player = getPlayer(uid);
- if(player != NULL && item > 0 && Item::items[item] != NULL)
+ if(player != nullptr && item > 0 && Item::items[item] != nullptr)
{
- shared_ptr<ItemInstance> itemInstance = shared_ptr<ItemInstance>(new ItemInstance(item, amount, aux));
+ shared_ptr<ItemInstance> itemInstance = std::make_shared<ItemInstance>(item, amount, aux);
shared_ptr<ItemEntity> drop = player->drop(itemInstance);
drop->throwTime = 0;
//logAdminAction(source, L"commands.give.success", ChatPacket::e_ChatCustom, Item::items[item]->getName(itemInstance), item, amount, player->getAName());
@@ -42,7 +42,7 @@ void GiveItemCommand::execute(shared_ptr<CommandSender> source, byteArray comman
shared_ptr<GameCommandPacket> GiveItemCommand::preparePacket(shared_ptr<Player> player, int item, int amount, int aux, const wstring &tag)
{
- if(player == NULL) return nullptr;
+ if(player == nullptr) return nullptr;
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
@@ -53,5 +53,5 @@ shared_ptr<GameCommandPacket> GiveItemCommand::preparePacket(shared_ptr<Player>
dos.writeInt(aux);
dos.writeUTF(tag);
- return shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Give, baos.toByteArray() ));
+ return std::make_shared<GameCommandPacket>(eGameCommand_Give, baos.toByteArray());
} \ No newline at end of file
diff --git a/Minecraft.World/GrassTile.cpp b/Minecraft.World/GrassTile.cpp
index 68e7c233..9be44d0e 100644
--- a/Minecraft.World/GrassTile.cpp
+++ b/Minecraft.World/GrassTile.cpp
@@ -12,9 +12,9 @@
GrassTile::GrassTile(int id) : Tile(id, Material::grass)
{
- iconTop = NULL;
- iconSnowSide = NULL;
- iconSideOverlay = NULL;
+ iconTop = nullptr;
+ iconSnowSide = nullptr;
+ iconSideOverlay = nullptr;
setTicking(true);
}
diff --git a/Minecraft.World/HangingEntity.cpp b/Minecraft.World/HangingEntity.cpp
index 26261710..67d53114 100644
--- a/Minecraft.World/HangingEntity.cpp
+++ b/Minecraft.World/HangingEntity.cpp
@@ -35,16 +35,16 @@ HangingEntity::HangingEntity(Level *level, int xTile, int yTile, int zTile, int
void HangingEntity::setDir(int dir)
{
this->dir = dir;
- yRotO = yRot = (float)(dir * 90);
+ yRotO = yRot = static_cast<float>(dir * 90);
- float w = (float)getWidth();
- float h = (float)getHeight();
- float d = (float)getWidth();
+ float w = static_cast<float>(getWidth());
+ float h = static_cast<float>(getHeight());
+ float d = static_cast<float>(getWidth());
if (dir == Direction::NORTH || dir == Direction::SOUTH)
{
d = 0.5f;
- yRot = yRotO = (float)(Direction::DIRECTION_OPPOSITE[dir] * 90);
+ yRot = yRotO = static_cast<float>(Direction::DIRECTION_OPPOSITE[dir] * 90);
}
else
{
@@ -150,7 +150,7 @@ bool HangingEntity::survives()
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), bb);
- if (entities != NULL && entities->size() > 0)
+ if (entities != nullptr && entities->size() > 0)
{
for (auto& e : *entities)
{
@@ -184,11 +184,11 @@ bool HangingEntity::hurt(DamageSource *source, float damage)
if (isInvulnerable()) return false;
if (!removed && !level->isClientSide)
{
- if (dynamic_cast<EntityDamageSource *>(source) != NULL)
+ if (dynamic_cast<EntityDamageSource *>(source) != nullptr)
{
shared_ptr<Entity> sourceEntity = source->getDirectEntity();
- if ( (sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(sourceEntity)->isAllowedToHurtEntity(shared_from_this()) )
+ if ( (sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(sourceEntity)->isAllowedToHurtEntity(shared_from_this()) )
{
return false;
}
@@ -199,12 +199,12 @@ bool HangingEntity::hurt(DamageSource *source, float damage)
shared_ptr<Player> player = nullptr;
shared_ptr<Entity> e = source->getEntity();
- if ( (e!=NULL) && e->instanceof(eTYPE_PLAYER) ) // check if it's serverplayer or player
+ if ( (e!=nullptr) && e->instanceof(eTYPE_PLAYER) ) // check if it's serverplayer or player
{
player = dynamic_pointer_cast<Player>( e );
}
- if (player != NULL && player->abilities.instabuild)
+ if (player != nullptr && player->abilities.instabuild)
{
return true;
}
@@ -235,7 +235,7 @@ void HangingEntity::push(double xa, double ya, double za)
void HangingEntity::addAdditonalSaveData(CompoundTag *tag)
{
- tag->putByte(L"Direction", (byte) dir);
+ tag->putByte(L"Direction", static_cast<byte>(dir));
tag->putInt(L"TileX", xTile);
tag->putInt(L"TileY", yTile);
tag->putInt(L"TileZ", zTile);
diff --git a/Minecraft.World/HangingEntityItem.cpp b/Minecraft.World/HangingEntityItem.cpp
index 9e4e9d5b..97ddb31d 100644
--- a/Minecraft.World/HangingEntityItem.cpp
+++ b/Minecraft.World/HangingEntityItem.cpp
@@ -35,7 +35,7 @@ bool HangingEntityItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Play
if (!player->mayUseItemAt(xt, yt, zt, face, instance)) return false;
- if (entity != NULL && entity->survives())
+ if (entity != nullptr && entity->survives())
{
if (!level->isClientSide)
{
@@ -66,7 +66,7 @@ shared_ptr<HangingEntity> HangingEntityItem::createEntity(Level *level, int x, i
{
if (eType == eTYPE_PAINTING)
{
- shared_ptr<Painting> painting = shared_ptr<Painting>(new Painting(level, x, y, z, dir));
+ shared_ptr<Painting> painting = std::make_shared<Painting>(level, x, y, z, dir);
#ifndef _CONTENT_PACKAGE
if (app.DebugArtToolsOn() && auxValue > 0)
@@ -83,7 +83,7 @@ shared_ptr<HangingEntity> HangingEntityItem::createEntity(Level *level, int x, i
}
else if (eType == eTYPE_ITEM_FRAME)
{
- shared_ptr<ItemFrame> itemFrame = shared_ptr<ItemFrame>(new ItemFrame(level, x, y, z, dir));
+ shared_ptr<ItemFrame> itemFrame = std::make_shared<ItemFrame>(level, x, y, z, dir);
return dynamic_pointer_cast<HangingEntity> (itemFrame);
}
diff --git a/Minecraft.World/HatchetItem.cpp b/Minecraft.World/HatchetItem.cpp
index 7fa204ca..dd74a2ed 100644
--- a/Minecraft.World/HatchetItem.cpp
+++ b/Minecraft.World/HatchetItem.cpp
@@ -2,7 +2,7 @@
#include "net.minecraft.world.level.tile.h"
#include "HatchetItem.h"
-TileArray *HatchetItem::diggables = NULL;
+TileArray *HatchetItem::diggables = nullptr;
void HatchetItem::staticCtor()
{
@@ -25,7 +25,7 @@ HatchetItem::HatchetItem(int id, const Tier *tier) : DiggerItem (id, 3, tier, di
// 4J - brought forward from 1.2.3
float HatchetItem::getDestroySpeed(shared_ptr<ItemInstance> itemInstance, Tile *tile)
{
- if (tile != NULL && (tile->material == Material::wood || tile->material == Material::plant || tile->material == Material::replaceable_plant))
+ if (tile != nullptr && (tile->material == Material::wood || tile->material == Material::plant || tile->material == Material::replaceable_plant))
{
return speed;
}
diff --git a/Minecraft.World/HeavyTile.cpp b/Minecraft.World/HeavyTile.cpp
index 6c2b96e6..d4e65796 100644
--- a/Minecraft.World/HeavyTile.cpp
+++ b/Minecraft.World/HeavyTile.cpp
@@ -60,7 +60,7 @@ void HeavyTile::checkSlide(Level *level, int x, int y, int z)
return;
}
- shared_ptr<FallingTile> e = shared_ptr<FallingTile>( new FallingTile(level, x + 0.5f, y + 0.5f, z + 0.5f, id, level->getData(x, y, z)) );
+ shared_ptr<FallingTile> e = std::make_shared<FallingTile>(level, x + 0.5f, y + 0.5f, z + 0.5f, id, level->getData(x, y, z));
falling(e);
level->addEntity(e);
}
diff --git a/Minecraft.World/HellDimension.cpp b/Minecraft.World/HellDimension.cpp
index 63cb0df7..a765fd6f 100644
--- a/Minecraft.World/HellDimension.cpp
+++ b/Minecraft.World/HellDimension.cpp
@@ -23,9 +23,9 @@ Vec3 *HellDimension::getFogColor(float td, float a) const
byte greenComponent = ((colour>>8)&0xFF);
byte blueComponent = ((colour)&0xFF);
- float rr = (float)redComponent/256;//0.2f;
- float gg = (float)greenComponent/256;//0.03f;
- float bb = (float)blueComponent/256;//0.03f;
+ float rr = static_cast<float>(redComponent)/256;//0.2f;
+ float gg = static_cast<float>(greenComponent)/256;//0.03f;
+ float bb = static_cast<float>(blueComponent)/256;//0.03f;
return Vec3::newTemp(rr, gg, bb);
}
@@ -34,7 +34,7 @@ void HellDimension::updateLightRamp()
float ambientLight = 0.10f;
for (int i = 0; i <= Level::MAX_BRIGHTNESS; i++)
{
- float v = (1 - i / (float) (Level::MAX_BRIGHTNESS));
+ float v = (1 - i / static_cast<float>(Level::MAX_BRIGHTNESS));
brightnessRamp[i] = ((1 - v) / (v * 3 + 1)) * (1 - ambientLight) + ambientLight;
}
}
@@ -85,5 +85,5 @@ bool HellDimension::isFoggyAt(int x, int z)
int HellDimension::getXZSize()
{
- return ceil((float)level->getLevelData()->getXZSize() / level->getLevelData()->getHellScale());
+ return ceil(static_cast<float>(level->getLevelData()->getXZSize()) / level->getLevelData()->getHellScale());
}
diff --git a/Minecraft.World/HellFlatLevelSource.cpp b/Minecraft.World/HellFlatLevelSource.cpp
index 95144627..c4ba062c 100644
--- a/Minecraft.World/HellFlatLevelSource.cpp
+++ b/Minecraft.World/HellFlatLevelSource.cpp
@@ -8,7 +8,7 @@ HellFlatLevelSource::HellFlatLevelSource(Level *level, int64_t seed)
{
int xzSize = level->getLevelData()->getXZSize();
int hellScale = level->getLevelData()->getHellScale();
- m_XZSize = ceil((float)xzSize / hellScale);
+ m_XZSize = ceil(static_cast<float>(xzSize) / hellScale);
this->level = level;
@@ -38,7 +38,7 @@ void HellFlatLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
block = Tile::netherRack_Id;
}
- blocks[xc << 11 | zc << 7 | yc] = (byte) block;
+ blocks[xc << 11 | zc << 7 | yc] = static_cast<byte>(block);
}
}
}
@@ -60,7 +60,7 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks)
{
if( z - random->nextInt( 4 ) <= 0 || xOffs < -(m_XZSize/2) )
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
blockSet = true;
}
}
@@ -68,7 +68,7 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks)
{
if( x - random->nextInt( 4 ) <= 0 || zOffs < -(m_XZSize/2))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
blockSet = true;
}
}
@@ -76,7 +76,7 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks)
{
if( z + random->nextInt(4) >= 15 || xOffs > (m_XZSize/2))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
blockSet = true;
}
}
@@ -84,7 +84,7 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks)
{
if( x + random->nextInt(4) >= 15 || zOffs > (m_XZSize/2) )
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
blockSet = true;
}
}
@@ -93,11 +93,11 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks)
if (y >= Level::genDepthMinusOne - random->nextInt(5))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
}
else if (y <= 0 + random->nextInt(5))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
}
}
}
@@ -115,7 +115,7 @@ LevelChunk *HellFlatLevelSource::getChunk(int xOffs, int zOffs)
// 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed
int chunksSize = Level::genDepth * 16 * 16;
- byte *tileData = (byte *)XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
+ byte *tileData = static_cast<byte *>(XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, PAGE_READWRITE));
XMemSet128(tileData,0,chunksSize);
byteArray blocks = byteArray(tileData,chunksSize);
// byteArray blocks = byteArray(16 * level->depth * 16);
@@ -211,16 +211,16 @@ wstring HellFlatLevelSource::gatherStats()
vector<Biome::MobSpawnerData *> *HellFlatLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
{
Biome *biome = level->getBiome(x, z);
- if (biome == NULL)
+ if (biome == nullptr)
{
- return NULL;
+ return nullptr;
}
return biome->getMobs(mobCategory);
}
TilePos *HellFlatLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
void HellFlatLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ)
diff --git a/Minecraft.World/HellRandomLevelSource.cpp b/Minecraft.World/HellRandomLevelSource.cpp
index 66444d13..26127dde 100644
--- a/Minecraft.World/HellRandomLevelSource.cpp
+++ b/Minecraft.World/HellRandomLevelSource.cpp
@@ -11,7 +11,7 @@ HellRandomLevelSource::HellRandomLevelSource(Level *level, int64_t seed)
{
int xzSize = level->getLevelData()->getXZSize();
int hellScale = level->getLevelData()->getHellScale();
- m_XZSize = ceil((float)xzSize / hellScale);
+ m_XZSize = ceil(static_cast<float>(xzSize) / hellScale);
netherBridgeFeature = new NetherBridgeFeature();
caveFeature = new LargeHellCaveFeature();
@@ -64,7 +64,7 @@ void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray block
{
for (int yc = 0; yc < Level::genDepth / CHUNK_HEIGHT; yc++)
{
- double yStep = 1 / (double) CHUNK_HEIGHT;
+ double yStep = 1 / static_cast<double>(CHUNK_HEIGHT);
double s0 = buffer[((xc + 0) * zSize + (zc + 0)) * ySize + (yc + 0)];
double s1 = buffer[((xc + 0) * zSize + (zc + 1)) * ySize + (yc + 0)];
double s2 = buffer[((xc + 1) * zSize + (zc + 0)) * ySize + (yc + 0)];
@@ -77,7 +77,7 @@ void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray block
for (int y = 0; y < CHUNK_HEIGHT; y++)
{
- double xStep = 1 / (double) CHUNK_WIDTH;
+ double xStep = 1 / static_cast<double>(CHUNK_WIDTH);
double _s0 = s0;
double _s1 = s1;
@@ -88,7 +88,7 @@ void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray block
{
int offs = (x + xc * CHUNK_WIDTH) << Level::genDepthBitsPlusFour | (0 + zc * CHUNK_WIDTH) << Level::genDepthBits | (yc * CHUNK_HEIGHT + y);
int step = 1 << Level::genDepthBits;
- double zStep = 1 / (double) CHUNK_WIDTH;
+ double zStep = 1 / static_cast<double>(CHUNK_WIDTH);
double val = _s0;
double vala = (_s1 - _s0) * zStep;
@@ -104,7 +104,7 @@ void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray block
tileId = Tile::netherRack_Id;
}
- blocks[offs] = (byte) tileId;
+ blocks[offs] = static_cast<byte>(tileId);
offs += step;
val += vala;
}
@@ -143,7 +143,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks
{
bool sand = (sandBuffer[x + z * 16] + random->nextDouble() * 0.2) > 0;
bool gravel = (gravelBuffer[x + z * 16] + random->nextDouble() * 0.2) > 0;
- int runDepth = (int) (depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25);
+ int runDepth = static_cast<int>(depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25);
int run = -1;
@@ -160,7 +160,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks
{
if( z - random->nextInt( 4 ) <= 0 || xOffs < -(m_XZSize/2) )
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
blockSet = true;
}
}
@@ -168,7 +168,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks
{
if( x - random->nextInt( 4 ) <= 0 || zOffs < -(m_XZSize/2))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
blockSet = true;
}
}
@@ -176,7 +176,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks
{
if( z + random->nextInt(4) >= 15 || xOffs > (m_XZSize/2))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
blockSet = true;
}
}
@@ -184,7 +184,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks
{
if( x + random->nextInt(4) >= 15 || zOffs > (m_XZSize/2) )
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
blockSet = true;
}
}
@@ -193,7 +193,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks
if (y >= Level::genDepthMinusOne - random->nextInt(5) || y <= 0 + random->nextInt(5))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
}
else
{
@@ -210,20 +210,20 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks
if (runDepth <= 0)
{
top = 0;
- material = (byte) Tile::netherRack_Id;
+ material = static_cast<byte>(Tile::netherRack_Id);
}
else if (y >= waterHeight - 4 && y <= waterHeight + 1)
{
- top = (byte) Tile::netherRack_Id;
- material = (byte) Tile::netherRack_Id;
- if (gravel) top = (byte) Tile::gravel_Id;
- if (gravel) material = (byte) Tile::netherRack_Id;
+ top = static_cast<byte>(Tile::netherRack_Id);
+ material = static_cast<byte>(Tile::netherRack_Id);
+ if (gravel) top = static_cast<byte>(Tile::gravel_Id);
+ if (gravel) material = static_cast<byte>(Tile::netherRack_Id);
if (sand)
{
// 4J Stu - Make some nether wart spawn outside of the nether fortresses
if(random->nextInt(16) == 0)
{
- top = (byte) Tile::netherStalk_Id;
+ top = static_cast<byte>(Tile::netherStalk_Id);
// Place the nether wart on top of the soul sand
y += 1;
@@ -234,13 +234,13 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks
}
else
{
- top = (byte) Tile::soulsand_Id;
+ top = static_cast<byte>(Tile::soulsand_Id);
}
}
- if (sand) material = (byte) Tile::soulsand_Id;
+ if (sand) material = static_cast<byte>(Tile::soulsand_Id);
}
- if (y < waterHeight && top == 0) top = (byte) Tile::calmLava_Id;
+ if (y < waterHeight && top == 0) top = static_cast<byte>(Tile::calmLava_Id);
run = runDepth;
// 4J Stu - If sand, then allow adding nether wart at heights below the water level
@@ -273,7 +273,7 @@ LevelChunk *HellRandomLevelSource::getChunk(int xOffs, int zOffs)
// 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed
int blocksSize = Level::genDepth * 16 * 16;
- byte *tileData = (byte *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
+ byte *tileData = static_cast<byte *>(XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE));
XMemSet128(tileData,0,blocksSize);
byteArray blocks = byteArray(tileData,blocksSize);
// byteArray blocks = byteArray(16 * level->depth * 16);
@@ -303,7 +303,7 @@ void HellRandomLevelSource::lightChunk(LevelChunk *lc)
doubleArray HellRandomLevelSource::getHeights(doubleArray buffer, int x, int y, int z, int xSize, int ySize, int zSize)
{
- if (buffer.data == NULL)
+ if (buffer.data == nullptr)
{
buffer = doubleArray(xSize * ySize * zSize);
}
@@ -325,7 +325,7 @@ doubleArray HellRandomLevelSource::getHeights(doubleArray buffer, int x, int y,
doubleArray yoffs = doubleArray(ySize);
for (int yy = 0; yy < ySize; yy++)
{
- yoffs[yy] = cos(yy * PI * 6 / (double) ySize) * 2;
+ yoffs[yy] = cos(yy * PI * 6 / static_cast<double>(ySize)) * 2;
double dd = yy;
if (yy > ySize / 2)
@@ -547,19 +547,19 @@ vector<Biome::MobSpawnerData *> *HellRandomLevelSource::getMobsAt(MobCategory *m
}
Biome *biome = level->getBiome(x, z);
- if (biome == NULL)
+ if (biome == nullptr)
{
- return NULL;
+ return nullptr;
}
return biome->getMobs(mobCategory);
}
TilePos *HellRandomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
void HellRandomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ)
{
- netherBridgeFeature->apply(this, level, chunkX, chunkZ, NULL);
+ netherBridgeFeature->apply(this, level, chunkX, chunkZ, byteArray());
} \ No newline at end of file
diff --git a/Minecraft.World/HopperMenu.cpp b/Minecraft.World/HopperMenu.cpp
index afc700c3..996651c6 100644
--- a/Minecraft.World/HopperMenu.cpp
+++ b/Minecraft.World/HopperMenu.cpp
@@ -35,7 +35,7 @@ shared_ptr<ItemInstance> HopperMenu::quickMoveStack(shared_ptr<Player> player, i
{
shared_ptr<ItemInstance> clicked = nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
diff --git a/Minecraft.World/HopperTile.cpp b/Minecraft.World/HopperTile.cpp
index c111105e..0371712a 100644
--- a/Minecraft.World/HopperTile.cpp
+++ b/Minecraft.World/HopperTile.cpp
@@ -47,7 +47,7 @@ int HopperTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int
shared_ptr<TileEntity> HopperTile::newTileEntity(Level *level)
{
- return shared_ptr<HopperTileEntity>( new HopperTileEntity() );
+ return std::make_shared<HopperTileEntity>();
}
void HopperTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance)
@@ -74,7 +74,7 @@ bool HopperTile::use(Level *level, int x, int y, int z, shared_ptr<Player> playe
return true;
}
shared_ptr<HopperTileEntity> hopper = getHopper(level, x, y, z);
- if (hopper != NULL) player->openHopper(hopper);
+ if (hopper != nullptr) player->openHopper(hopper);
return true;
}
@@ -99,12 +99,12 @@ void HopperTile::checkPoweredState(Level *level, int x, int y, int z)
void HopperTile::onRemove(Level *level, int x, int y, int z, int id, int data)
{
shared_ptr<Container> container = dynamic_pointer_cast<HopperTileEntity>( level->getTileEntity(x, y, z) );
- if (container != NULL)
+ if (container != nullptr)
{
for (int i = 0; i < container->getContainerSize(); i++)
{
shared_ptr<ItemInstance> 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;
@@ -116,17 +116,17 @@ void HopperTile::onRemove(Level *level, int x, int y, int z, int id, int data)
if (count > item->count) count = item->count;
item->count -= count;
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue()))));
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>(new ItemInstance(item->id, count, item->getAuxValue())));
if (item->hasTag())
{
- itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy());
+ itemEntity->getItem()->setTag(static_cast<CompoundTag *>(item->getTag()->copy()));
}
float pow = 0.05f;
- itemEntity->xd = (float) random.nextGaussian() * pow;
- itemEntity->yd = (float) random.nextGaussian() * pow + 0.2f;
- itemEntity->zd = (float) random.nextGaussian() * pow;
+ itemEntity->xd = static_cast<float>(random.nextGaussian()) * pow;
+ itemEntity->yd = static_cast<float>(random.nextGaussian()) * pow + 0.2f;
+ itemEntity->zd = static_cast<float>(random.nextGaussian()) * pow;
level->addEntity(itemEntity);
}
}
@@ -197,7 +197,7 @@ Icon *HopperTile::getTexture(const wstring &name)
{
if (name.compare(TEXTURE_OUTSIDE) == 0) return Tile::hopper->hopperIcon;
if (name.compare(TEXTURE_INSIDE) == 0) return Tile::hopper->hopperInnerIcon;
- return NULL;
+ return nullptr;
}
wstring HopperTile::getTileItemIconName()
diff --git a/Minecraft.World/HopperTileEntity.cpp b/Minecraft.World/HopperTileEntity.cpp
index 38a0e817..e44232dc 100644
--- a/Minecraft.World/HopperTileEntity.cpp
+++ b/Minecraft.World/HopperTileEntity.cpp
@@ -46,10 +46,10 @@ void HopperTileEntity::save(CompoundTag *base)
for (int i = 0; i < items.length; i++)
{
- if (items[i] != NULL)
+ if (items[i] != nullptr)
{
CompoundTag *tag = new CompoundTag();
- tag->putByte(L"Slot", (byte) i);
+ tag->putByte(L"Slot", static_cast<byte>(i));
items[i]->save(tag);
listTag->add(tag);
}
@@ -76,7 +76,7 @@ shared_ptr<ItemInstance> HopperTileEntity::getItem(unsigned int slot)
shared_ptr<ItemInstance> HopperTileEntity::removeItem(unsigned int slot, int count)
{
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
if (items[slot]->count <= count)
{
@@ -96,7 +96,7 @@ shared_ptr<ItemInstance> HopperTileEntity::removeItem(unsigned int slot, int cou
shared_ptr<ItemInstance> HopperTileEntity::removeItemNoUpdate(int slot)
{
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
shared_ptr<ItemInstance> item = items[slot];
items[slot] = nullptr;
@@ -108,7 +108,7 @@ shared_ptr<ItemInstance> HopperTileEntity::removeItemNoUpdate(int slot)
void HopperTileEntity::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
items[slot] = item;
- if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize();
+ if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize();
}
wstring HopperTileEntity::getName()
@@ -158,7 +158,7 @@ bool HopperTileEntity::canPlaceItem(int slot, shared_ptr<ItemInstance> item)
void HopperTileEntity::tick()
{
- if (level == NULL || level->isClientSide) return;
+ if (level == nullptr || level->isClientSide) return;
cooldownTime--;
@@ -171,7 +171,7 @@ void HopperTileEntity::tick()
bool HopperTileEntity::tryMoveItems()
{
- if (level == NULL || level->isClientSide) return false;
+ if (level == nullptr || level->isClientSide) return false;
if (!isOnCooldown() && HopperTile::isTurnedOn(getData()))
{
@@ -192,19 +192,19 @@ bool HopperTileEntity::tryMoveItems()
bool HopperTileEntity::ejectItems()
{
shared_ptr<Container> container = getAttachedContainer();
- if (container == NULL)
+ if (container == nullptr)
{
return false;
}
for (int slot = 0; slot < getContainerSize(); slot++)
{
- if (getItem(slot) == NULL) continue;
+ if (getItem(slot) == nullptr) continue;
shared_ptr<ItemInstance> original = getItem(slot)->copy();
shared_ptr<ItemInstance> result = addItem(container.get(), removeItem(slot, 1), Facing::OPPOSITE_FACING[HopperTile::getAttachedFace(getData())]);
- if (result == NULL || result->count == 0)
+ if (result == nullptr || result->count == 0)
{
container->setChanged();
return true;
@@ -222,12 +222,12 @@ bool HopperTileEntity::suckInItems(Hopper *hopper)
{
shared_ptr<Container> container = getSourceContainer(hopper);
- if (container != NULL)
+ if (container != nullptr)
{
int face = Facing::DOWN;
shared_ptr<WorldlyContainer> worldly = dynamic_pointer_cast<WorldlyContainer>(container);
- if ( (worldly != NULL) && (face > -1) )
+ if ( (worldly != nullptr) && (face > -1) )
{
intArray slots = worldly->getSlotsForFace(face);
@@ -249,7 +249,7 @@ bool HopperTileEntity::suckInItems(Hopper *hopper)
{
shared_ptr<ItemEntity> above = getItemAt(hopper->getLevel(), hopper->getLevelX(), hopper->getLevelY() + 1, hopper->getLevelZ());
- if (above != NULL)
+ if (above != nullptr)
{
return addItem(hopper, above);
}
@@ -262,12 +262,12 @@ bool HopperTileEntity::tryTakeInItemFromSlot(Hopper *hopper, Container *containe
{
shared_ptr<ItemInstance> item = container->getItem(slot);
- if (item != NULL && canTakeItemFromContainer(container, item, slot, face))
+ if (item != nullptr && canTakeItemFromContainer(container, item, slot, face))
{
shared_ptr<ItemInstance> original = item->copy();
shared_ptr<ItemInstance> result = addItem(hopper, container->removeItem(slot, 1), -1);
- if (result == NULL || result->count == 0)
+ if (result == nullptr || result->count == 0)
{
container->setChanged();
return true;
@@ -284,12 +284,12 @@ bool HopperTileEntity::tryTakeInItemFromSlot(Hopper *hopper, Container *containe
bool HopperTileEntity::addItem(Container *container, shared_ptr<ItemEntity> item)
{
bool changed = false;
- if (item == NULL) return false;
+ if (item == nullptr) return false;
shared_ptr<ItemInstance> copy = item->getItem()->copy();
shared_ptr<ItemInstance> result = addItem(container, copy, -1);
- if (result == NULL || result->count == 0)
+ if (result == nullptr || result->count == 0)
{
changed = true;
@@ -305,12 +305,12 @@ bool HopperTileEntity::addItem(Container *container, shared_ptr<ItemEntity> item
shared_ptr<ItemInstance> HopperTileEntity::addItem(Container *container, shared_ptr<ItemInstance> item, int face)
{
- if (dynamic_cast<WorldlyContainer *>( container ) != NULL && face > -1)
+ if (dynamic_cast<WorldlyContainer *>( container ) != nullptr && face > -1)
{
- WorldlyContainer *worldly = (WorldlyContainer *) container;
+ WorldlyContainer *worldly = static_cast<WorldlyContainer *>(container);
intArray slots = worldly->getSlotsForFace(face);
- for (int i = 0; i < slots.length && item != NULL && item->count > 0; i++)
+ for (int i = 0; i < slots.length && item != nullptr && item->count > 0; i++)
{
item = tryMoveInItem(container, item, slots[i], face);
}
@@ -318,13 +318,13 @@ shared_ptr<ItemInstance> HopperTileEntity::addItem(Container *container, shared_
else
{
int size = container->getContainerSize();
- for (int i = 0; i < size && item != NULL && item->count > 0; i++)
+ for (int i = 0; i < size && item != nullptr && item->count > 0; i++)
{
item = tryMoveInItem(container, item, i, face);
}
}
- if (item != NULL && item->count == 0)
+ if (item != nullptr && item->count == 0)
{
item = nullptr;
}
@@ -335,13 +335,13 @@ shared_ptr<ItemInstance> HopperTileEntity::addItem(Container *container, shared_
bool HopperTileEntity::canPlaceItemInContainer(Container *container, shared_ptr<ItemInstance> item, int slot, int face)
{
if (!container->canPlaceItem(slot, item)) return false;
- if ( dynamic_cast<WorldlyContainer *>( container ) != NULL && !dynamic_cast<WorldlyContainer *>( container )->canPlaceItemThroughFace(slot, item, face)) return false;
+ if ( dynamic_cast<WorldlyContainer *>( container ) != nullptr && !dynamic_cast<WorldlyContainer *>( container )->canPlaceItemThroughFace(slot, item, face)) return false;
return true;
}
bool HopperTileEntity::canTakeItemFromContainer(Container *container, shared_ptr<ItemInstance> item, int slot, int face)
{
- if (dynamic_cast<WorldlyContainer *>( container ) != NULL && !dynamic_cast<WorldlyContainer *>( container )->canTakeItemThroughFace(slot, item, face)) return false;
+ if (dynamic_cast<WorldlyContainer *>( container ) != nullptr && !dynamic_cast<WorldlyContainer *>( container )->canTakeItemThroughFace(slot, item, face)) return false;
return true;
}
@@ -352,7 +352,7 @@ shared_ptr<ItemInstance> HopperTileEntity::tryMoveInItem(Container *container, s
if (canPlaceItemInContainer(container, item, slot, face))
{
bool success = false;
- if (current == NULL)
+ if (current == nullptr)
{
container->setItem(slot, item);
item = nullptr;
@@ -370,7 +370,7 @@ shared_ptr<ItemInstance> HopperTileEntity::tryMoveInItem(Container *container, s
if (success)
{
HopperTileEntity *hopper = dynamic_cast<HopperTileEntity *>(container);
- if (hopper != NULL)
+ if (hopper != nullptr)
{
hopper->setCooldown(MOVE_ITEM_SPEED);
container->setChanged();
@@ -420,25 +420,25 @@ shared_ptr<Container> HopperTileEntity::getContainerAt(Level *level, double x, d
shared_ptr<TileEntity> entity = level->getTileEntity(xt, yt, zt);
result = dynamic_pointer_cast<Container>(entity);
- if (result != NULL)
+ if (result != nullptr)
{
- if ( dynamic_pointer_cast<ChestTileEntity>(result) != NULL )
+ if ( dynamic_pointer_cast<ChestTileEntity>(result) != nullptr )
{
int id = level->getTile(xt, yt, zt);
Tile *tile = Tile::tiles[id];
- if ( dynamic_cast<ChestTile *>( tile ) != NULL )
+ if ( dynamic_cast<ChestTile *>( tile ) != nullptr )
{
- result = ((ChestTile *) tile)->getContainer(level, xt, yt, zt);
+ result = static_cast<ChestTile *>(tile)->getContainer(level, xt, yt, zt);
}
}
}
- if (result == NULL)
+ if (result == nullptr)
{
vector<shared_ptr<Entity> > *entities = level->getEntities(nullptr, AABB::newTemp(x, y, z, x + 1, y + 1, z + 1), EntitySelector::CONTAINER_ENTITY_SELECTOR);
- if ( (entities != NULL) && (entities->size() > 0) )
+ if ( (entities != nullptr) && (entities->size() > 0) )
{
result = dynamic_pointer_cast<Container>( entities->at( level->random->nextInt(entities->size()) ) );
}
@@ -489,14 +489,14 @@ bool HopperTileEntity::isOnCooldown()
// 4J Added
shared_ptr<TileEntity> HopperTileEntity::clone()
{
- shared_ptr<HopperTileEntity> result = shared_ptr<HopperTileEntity>( new HopperTileEntity() );
+ shared_ptr<HopperTileEntity> result = std::make_shared<HopperTileEntity>();
TileEntity::clone(result);
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/HorseInventoryMenu.cpp b/Minecraft.World/HorseInventoryMenu.cpp
index 7dba791f..467b3545 100644
--- a/Minecraft.World/HorseInventoryMenu.cpp
+++ b/Minecraft.World/HorseInventoryMenu.cpp
@@ -75,7 +75,7 @@ shared_ptr<ItemInstance> HorseInventoryMenu::quickMoveStack(shared_ptr<Player> p
{
shared_ptr<ItemInstance> clicked = nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
diff --git a/Minecraft.World/HouseFeature.cpp b/Minecraft.World/HouseFeature.cpp
index 40b4e770..b6bba5a5 100644
--- a/Minecraft.World/HouseFeature.cpp
+++ b/Minecraft.World/HouseFeature.cpp
@@ -185,7 +185,7 @@ bool HouseFeature::place(Level *level, Random *random, int x, int y, int z)
}
}
- shared_ptr<PigZombie>(pz) = shared_ptr<PigZombie>(new PigZombie(level));
+ shared_ptr<PigZombie>(pz) = std::make_shared<PigZombie>(level);
pz->moveTo(x0 + w / 2.0 + 0.5, y0 + 0.5, z0 + d / 2.0 + 0.5, 0, 0);
level->addEntity(pz);
diff --git a/Minecraft.World/HtmlString.cpp b/Minecraft.World/HtmlString.cpp
index ce25740e..af643671 100644
--- a/Minecraft.World/HtmlString.cpp
+++ b/Minecraft.World/HtmlString.cpp
@@ -38,7 +38,7 @@ wstring HtmlString::ToString()
wstring HtmlString::Compose(vector<HtmlString> *strings)
{
- if (strings == NULL) return L"";
+ if (strings == nullptr) return L"";
std::wstringstream ss;
diff --git a/Minecraft.World/HugeMushroomTile.cpp b/Minecraft.World/HugeMushroomTile.cpp
index e96cfd1f..8d3ef144 100644
--- a/Minecraft.World/HugeMushroomTile.cpp
+++ b/Minecraft.World/HugeMushroomTile.cpp
@@ -9,9 +9,9 @@ const wstring HugeMushroomTile::TEXTURE_TYPE[] = {L"skin_brown", L"skin_red"};
HugeMushroomTile::HugeMushroomTile(int id, Material *material, int type) : Tile(id, material)
{
this->type = type;
- icons = NULL;
- iconStem = NULL;
- iconInside = NULL;
+ icons = nullptr;
+ iconStem = nullptr;
+ iconInside = nullptr;
}
Icon *HugeMushroomTile::getTexture(int face, int data)
diff --git a/Minecraft.World/HurtByTargetGoal.cpp b/Minecraft.World/HurtByTargetGoal.cpp
index 076e5b6a..e70f8628 100644
--- a/Minecraft.World/HurtByTargetGoal.cpp
+++ b/Minecraft.World/HurtByTargetGoal.cpp
@@ -30,7 +30,7 @@ void HurtByTargetGoal::start()
{
shared_ptr<PathfinderMob> other = dynamic_pointer_cast<PathfinderMob>(it);
if (this->mob->shared_from_this() == other) continue;
- if (other->getTarget() != NULL) continue;
+ if (other->getTarget() != nullptr) continue;
if (other->isAlliedTo(mob->getLastHurtByMob())) continue; // don't target allies
other->setTarget(mob->getLastHurtByMob());
}
diff --git a/Minecraft.World/IceTile.cpp b/Minecraft.World/IceTile.cpp
index 938c098f..60e16291 100644
--- a/Minecraft.World/IceTile.cpp
+++ b/Minecraft.World/IceTile.cpp
@@ -30,7 +30,7 @@ void IceTile::playerDestroy(Level *level, shared_ptr<Player> player, int x, int
if (isSilkTouchable() && EnchantmentHelper::hasSilkTouch(player))
{
shared_ptr<ItemInstance> item = getSilkTouchItemInstance(data);
- if (item != NULL)
+ if (item != nullptr)
{
popResource(level, x, y, z, item);
}
diff --git a/Minecraft.World/ImprovedNoise.cpp b/Minecraft.World/ImprovedNoise.cpp
index 8be9e385..47f39085 100644
--- a/Minecraft.World/ImprovedNoise.cpp
+++ b/Minecraft.World/ImprovedNoise.cpp
@@ -46,9 +46,9 @@ double ImprovedNoise::noise(double _x, double _y, double _z)
double y = _y + yo;
double z = _z + zo;
- int xf = (int) x;
- int yf = (int) y;
- int zf = (int) z;
+ int xf = static_cast<int>(x);
+ int yf = static_cast<int>(y);
+ int zf = static_cast<int>(z);
if (x < xf) xf--;
if (y < yf) yf--;
@@ -125,7 +125,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int
for (int xx = 0; xx < xSize; xx++)
{
double x = _x + (xx) * xs + xo;
- int xf = (int) x;
+ int xf = static_cast<int>(x);
if (x < xf) xf--;
int X = xf & 255;
x -= xf;
@@ -134,7 +134,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int
for (int zz = 0; zz < zSize; zz++)
{
double z = _z + (zz) * zs + zo;
- int zf = (int) z;
+ int zf = static_cast<int>(z);
if (z < zf) zf--;
int Z = zf & 255;
z -= zf;
@@ -163,7 +163,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int
for (int xx = 0; xx < xSize; xx++)
{
double x = _x + (xx) * xs + xo;
- int xf = (int) x;
+ int xf = static_cast<int>(x);
if (x < xf) xf--;
int X = xf & 255;
x -= xf;
@@ -173,7 +173,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int
for (int zz = 0; zz < zSize; zz++)
{
double z = _z + (zz) * zs + zo;
- int zf = (int) z;
+ int zf = static_cast<int>(z);
if (z < zf) zf--;
int Z = zf & 255;
z -= zf;
@@ -183,7 +183,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int
for (int yy = 0; yy < ySize; yy++)
{
double y = _y + (yy) * ys + yo;
- int yf = (int) y;
+ int yf = static_cast<int>(y);
if (y < yf) yf--;
int Y = yf & 255;
y -= yf;
diff --git a/Minecraft.World/IndirectEntityDamageSource.cpp b/Minecraft.World/IndirectEntityDamageSource.cpp
index c2a67af5..a24ad1a7 100644
--- a/Minecraft.World/IndirectEntityDamageSource.cpp
+++ b/Minecraft.World/IndirectEntityDamageSource.cpp
@@ -32,26 +32,26 @@ shared_ptr<ChatPacket> IndirectEntityDamageSource::getDeathMessagePacket(shared_
shared_ptr<ItemInstance> held = entity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast<LivingEntity>(entity)->getCarriedItem() : nullptr;
wstring additional = L"";
int type;
- if(owner != NULL)
+ if(owner != nullptr)
{
type = owner->GetType();
if(type == eTYPE_SERVERPLAYER)
{
shared_ptr<Player> sourcePlayer = dynamic_pointer_cast<Player>(owner);
- if(sourcePlayer != NULL) additional = sourcePlayer->name;
+ if(sourcePlayer != nullptr) additional = sourcePlayer->name;
}
}
else
{
type = entity->GetType();
}
- if(held != NULL && held->hasCustomHoverName() )
+ if(held != nullptr && held->hasCustomHoverName() )
{
- return shared_ptr<ChatPacket>( new ChatPacket(player->getNetworkName(), m_msgWithItemId, type, additional, held->getHoverName() ) );
+ return std::make_shared<ChatPacket>(player->getNetworkName(), m_msgWithItemId, type, additional, held->getHoverName());
}
else
{
- return shared_ptr<ChatPacket>( new ChatPacket(player->getNetworkName(), m_msgId, type, additional ) );
+ return std::make_shared<ChatPacket>(player->getNetworkName(), m_msgId, type, additional);
}
}
diff --git a/Minecraft.World/InputStream.cpp b/Minecraft.World/InputStream.cpp
index e325db8a..f31399cf 100644
--- a/Minecraft.World/InputStream.cpp
+++ b/Minecraft.World/InputStream.cpp
@@ -7,5 +7,5 @@ InputStream *InputStream::getResourceAsStream(const wstring &fileName)
{
File file( fileName );
- return file.exists() ? new FileInputStream( file ) : NULL;
+ return file.exists() ? new FileInputStream( file ) : nullptr;
} \ No newline at end of file
diff --git a/Minecraft.World/InputStreamReader.cpp b/Minecraft.World/InputStreamReader.cpp
index 4a565cf4..972c5316 100644
--- a/Minecraft.World/InputStreamReader.cpp
+++ b/Minecraft.World/InputStreamReader.cpp
@@ -39,7 +39,7 @@ int InputStreamReader::read(wchar_t cbuf[], unsigned int offset, unsigned int le
unsigned int charsRead = 0;
for( unsigned int i = offset; i < offset + length; i++ )
{
- wchar_t value = (wchar_t)stream->readUTFChar();
+ wchar_t value = static_cast<wchar_t>(stream->readUTFChar());
if( value != -1 )
{
cbuf[i] = value;
diff --git a/Minecraft.World/IntArrayTag.h b/Minecraft.World/IntArrayTag.h
index 48f4ce74..61ca59d0 100644
--- a/Minecraft.World/IntArrayTag.h
+++ b/Minecraft.World/IntArrayTag.h
@@ -57,8 +57,8 @@ public:
{
if (Tag::equals(obj))
{
- IntArrayTag *o = (IntArrayTag *) obj;
- return ((data.data == NULL && o->data.data == NULL) || (data.data != NULL && data.length == o->data.length && memcmp(data.data, o->data.data, data.length * sizeof(int)) == 0) );
+ IntArrayTag *o = static_cast<IntArrayTag *>(obj);
+ return ((data.data == nullptr && o->data.data == nullptr) || (data.data != nullptr && data.length == o->data.length && memcmp(data.data, o->data.data, data.length * sizeof(int)) == 0) );
}
return false;
}
diff --git a/Minecraft.World/IntCache.cpp b/Minecraft.World/IntCache.cpp
index 174d01d3..cd980d16 100644
--- a/Minecraft.World/IntCache.cpp
+++ b/Minecraft.World/IntCache.cpp
@@ -28,7 +28,7 @@ IntCache::ThreadStorage::~ThreadStorage()
{
delete [] allocated[i].data;
}
- for( int i = 0; i < toosmall.size(); i++ )
+ for( size_t i = 0; i < toosmall.size(); i++ )
{
delete [] toosmall[i].data;
}
@@ -36,7 +36,7 @@ IntCache::ThreadStorage::~ThreadStorage()
void IntCache::ReleaseThreadStorage()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
delete tls;
@@ -44,13 +44,13 @@ void IntCache::ReleaseThreadStorage()
intArray IntCache::allocate(int size)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
if (size <= TINY_CUTOFF)
{
if (tls->tcache.empty())
{
- intArray result = intArray(TINY_CUTOFF, true);
+ intArray result = intArray(static_cast<unsigned int>(TINY_CUTOFF), true);
tls->tallocated.push_back(result);
return result;
}
@@ -76,7 +76,7 @@ intArray IntCache::allocate(int size)
tls->cache.clear();
tls->allocated.clear();
- intArray result = intArray(tls->maxSize, true);
+ intArray result = intArray(static_cast<unsigned int>(tls->maxSize), true);
tls->allocated.push_back(result);
return result;
}
@@ -84,7 +84,7 @@ intArray IntCache::allocate(int size)
{
if (tls->cache.empty())
{
- intArray result = intArray(tls->maxSize, true);
+ intArray result = intArray(static_cast<unsigned int>(tls->maxSize), true);
tls->allocated.push_back(result);
return result;
}
@@ -100,10 +100,10 @@ intArray IntCache::allocate(int size)
void IntCache::releaseAll()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
// 4J - added - we can now remove the vectors that were deemed as too small (see comment in IntCache::allocate)
- for( int i = 0; i < tls->toosmall.size(); i++ )
+ for( size_t i = 0; i < tls->toosmall.size(); i++ )
{
delete [] tls->toosmall[i].data;
}
@@ -130,27 +130,27 @@ void IntCache::releaseAll()
// 4J added so that we can fully reset between levels
void IntCache::Reset()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
tls->maxSize = TINY_CUTOFF;
- for( int i = 0; i < tls->allocated.size(); i++ )
+ for( size_t i = 0; i < tls->allocated.size(); i++ )
{
delete [] tls->allocated[i].data;
}
tls->allocated.clear();
- for( int i = 0; i < tls->cache.size(); i++ )
+ for( size_t i = 0; i < tls->cache.size(); i++ )
{
delete [] tls->cache[i].data;
}
tls->cache.clear();
- for( int i = 0; i < tls->tallocated.size(); i++ )
+ for( size_t i = 0; i < tls->tallocated.size(); i++ )
{
delete [] tls->tallocated[i].data;
}
tls->tallocated.clear();
- for( int i = 0; i < tls->tcache.size(); i++ )
+ for( size_t i = 0; i < tls->tcache.size(); i++ )
{
delete [] tls->tcache[i].data;
}
diff --git a/Minecraft.World/IntTag.h b/Minecraft.World/IntTag.h
index cce87da3..1f55c5f2 100644
--- a/Minecraft.World/IntTag.h
+++ b/Minecraft.World/IntTag.h
@@ -28,7 +28,7 @@ public:
{
if (Tag::equals(obj))
{
- IntTag *o = (IntTag *) obj;
+ IntTag *o = static_cast<IntTag *>(obj);
return data == o->data;
}
return false;
diff --git a/Minecraft.World/InteractPacket.h b/Minecraft.World/InteractPacket.h
index 0141038d..aae16391 100644
--- a/Minecraft.World/InteractPacket.h
+++ b/Minecraft.World/InteractPacket.h
@@ -20,6 +20,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new InteractPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<InteractPacket>(); }
virtual int getId() { return 7; }
}; \ No newline at end of file
diff --git a/Minecraft.World/Inventory.cpp b/Minecraft.World/Inventory.cpp
index 4a524bab..ad0fc3ec 100644
--- a/Minecraft.World/Inventory.cpp
+++ b/Minecraft.World/Inventory.cpp
@@ -69,7 +69,7 @@ int Inventory::getSlot(int tileId)
{
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL && items[i]->id == tileId) return i;
+ if (items[i] != nullptr && items[i]->id == tileId) return i;
}
return -1;
}
@@ -78,7 +78,7 @@ int Inventory::getSlot(int tileId, int data)
{
for (int i = 0; i < items.length; i++)
{
- if (items[i] != NULL && items[i]->id == tileId && items[i]->getAuxValue() == data) return i;
+ if (items[i] != nullptr && items[i]->id == tileId && items[i]->getAuxValue() == data) return i;
}
return -1;
}
@@ -87,7 +87,7 @@ int Inventory::getSlotWithRemainingSpace(shared_ptr<ItemInstance> item)
{
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL && items[i]->id == item->id && items[i]->isStackable()
+ if (items[i] != nullptr && items[i]->id == item->id && items[i]->isStackable()
&& items[i]->count < items[i]->getMaxStackSize() && items[i]->count < getMaxStackSize()
&& (!items[i]->isStackedByData() || items[i]->getAuxValue() == item->getAuxValue())
&& ItemInstance::tagMatches(items[i], item))
@@ -102,7 +102,7 @@ int Inventory::getFreeSlot()
{
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] == NULL) return i;
+ if (items[i] == nullptr) return i;
}
return -1;
}
@@ -160,7 +160,7 @@ int Inventory::clearInventory(int id, int data)
for (int i = 0; i < items.length; i++)
{
shared_ptr<ItemInstance> item = items[i];
- if (item == NULL) continue;
+ if (item == nullptr) continue;
if (id > -1 && item->id != id) continue;
if (data > -1 && item->getAuxValue() != data) continue;
@@ -170,7 +170,7 @@ int Inventory::clearInventory(int id, int data)
for (int i = 0; i < armor.length; i++)
{
shared_ptr<ItemInstance> item = armor[i];
- if (item == NULL) continue;
+ if (item == nullptr) continue;
if (id > -1 && item->id != id) continue;
if (data > -1 && item->getAuxValue() != data) continue;
@@ -178,7 +178,7 @@ int Inventory::clearInventory(int id, int data)
armor[i] = nullptr;
}
- if (carried != NULL)
+ if (carried != nullptr)
{
if (id > -1 && carried->id != id) return count;
if (data > -1 && carried->getAuxValue() != data) return count;
@@ -192,10 +192,10 @@ int Inventory::clearInventory(int id, int data)
void Inventory::replaceSlot(Item *item, int data)
{
- if (item != NULL)
+ if (item != nullptr)
{
// It's too easy to accidentally pick block and lose enchanted items.
- if (heldItem != NULL && heldItem->isEnchantable() && getSlot(heldItem->id, heldItem->getDamageValue()) == selected)
+ if (heldItem != nullptr && heldItem->isEnchantable() && getSlot(heldItem->id, heldItem->getDamageValue()) == selected)
{
return;
}
@@ -205,11 +205,11 @@ void Inventory::replaceSlot(Item *item, int data)
{
int oldSlotCount = items[oldSlot]->count;
items[oldSlot] = items[selected];
- items[selected] = shared_ptr<ItemInstance>( new ItemInstance(Item::items[item->id], oldSlotCount, data) );
+ items[selected] = std::make_shared<ItemInstance>(Item::items[item->id], oldSlotCount, data);
}
else
{
- items[selected] = shared_ptr<ItemInstance>(new ItemInstance(Item::items[item->id], 1, data));
+ items[selected] = std::make_shared<ItemInstance>(Item::items[item->id], 1, data);
}
}
}
@@ -226,7 +226,7 @@ int Inventory::addResource(shared_ptr<ItemInstance> itemInstance)
{
int slot = getFreeSlot();
if (slot < 0) return count;
- if (items[slot] == NULL)
+ if (items[slot] == nullptr)
{
items[slot] = ItemInstance::clone(itemInstance);
player->handleCollectItem(itemInstance);
@@ -237,13 +237,13 @@ int Inventory::addResource(shared_ptr<ItemInstance> itemInstance)
int slot = getSlotWithRemainingSpace(itemInstance);
if (slot < 0) slot = getFreeSlot();
if (slot < 0) return count;
- if (items[slot] == NULL)
+ if (items[slot] == nullptr)
{
- items[slot] = shared_ptr<ItemInstance>( new ItemInstance(type, 0, itemInstance->getAuxValue()) );
+ items[slot] = std::make_shared<ItemInstance>(type, 0, itemInstance->getAuxValue());
// 4J Stu - Brought forward from 1.2
if (itemInstance->hasTag())
{
- items[slot]->setTag((CompoundTag *) itemInstance->getTag()->copy());
+ items[slot]->setTag(static_cast<CompoundTag *>(itemInstance->getTag()->copy()));
player->handleCollectItem(itemInstance);
}
}
@@ -272,7 +272,7 @@ void Inventory::tick()
{
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL)
+ if (items[i] != nullptr)
{
items[i]->inventoryTick(player->level, player->shared_from_this(), i, selected == i);
}
@@ -299,12 +299,12 @@ bool Inventory::removeResource(int type,int iAuxVal)
void Inventory::removeResources(shared_ptr<ItemInstance> item)
{
- if(item == NULL) return;
+ if(item == nullptr) return;
int countToRemove = item->count;
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL && items[i]->sameItemWithTags(item))
+ if (items[i] != nullptr && items[i]->sameItemWithTags(item))
{
int slotCount = items[i]->count;
items[i]->count -= countToRemove;
@@ -348,7 +348,7 @@ int Inventory::countResource(int type, int auxVal)
int count = 0;
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL && items[i]->id == type &&
+ if (items[i] != nullptr && items[i]->id == type &&
(auxVal == -1 || items[i]->getAuxValue() == auxVal))
count += items[i]->count;
}
@@ -364,7 +364,7 @@ void Inventory::swapSlots(int from, int to)
bool Inventory::add(shared_ptr<ItemInstance> item)
{
- if (item == NULL) return false;
+ if (item == nullptr) return false;
if (item->count == 0) return false;
if (!item->isDamaged())
@@ -427,7 +427,7 @@ shared_ptr<ItemInstance> Inventory::removeItem(unsigned int slot, int count)
slot -= items.length;
}
- if (pile[slot] != NULL)
+ if (pile[slot] != nullptr)
{
if (pile[slot]->count <= count)
{
@@ -454,7 +454,7 @@ shared_ptr<ItemInstance> Inventory::removeItemNoUpdate(int slot)
slot -= items.length;
}
- if (pile[slot] != NULL)
+ if (pile[slot] != nullptr)
{
shared_ptr<ItemInstance> item = pile[slot];
pile[slot] = nullptr;
@@ -466,7 +466,7 @@ shared_ptr<ItemInstance> Inventory::removeItemNoUpdate(int slot)
void Inventory::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
#ifdef _DEBUG
- if(item!=NULL)
+ if(item!=nullptr)
{
wstring itemstring=item->toString();
app.DebugPrintf("Inventory::setItem - slot = %d,\t item = %d ",slot,item->id);
@@ -474,7 +474,7 @@ void Inventory::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
app.DebugPrintf("\n");
}
#else
- if(item!=NULL)
+ if(item!=nullptr)
{
app.DebugPrintf("Inventory::setItem - slot = %d,\t item = %d, aux = %d\n",slot,item->id,item->getAuxValue());
}
@@ -504,7 +504,7 @@ void Inventory::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
float Inventory::getDestroySpeed(Tile *tile)
{
float speed = 1.0f;
- if (items[selected] != NULL) speed *= items[selected]->getDestroySpeed(tile);
+ if (items[selected] != nullptr) speed *= items[selected]->getDestroySpeed(tile);
return speed;
}
@@ -512,20 +512,20 @@ ListTag<CompoundTag> *Inventory::save(ListTag<CompoundTag> *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", (byte) i);
+ tag->putByte(L"Slot", static_cast<byte>(i));
items[i]->save(tag);
listTag->add(tag);
}
}
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", (byte) (i + 100));
+ tag->putByte(L"Slot", static_cast<byte>(i + 100));
armor[i]->save(tag);
listTag->add(tag);
}
@@ -535,15 +535,15 @@ ListTag<CompoundTag> *Inventory::save(ListTag<CompoundTag> *listTag)
void Inventory::load(ListTag<CompoundTag> *inventoryList)
{
- if( items.data != NULL)
+ if( items.data != nullptr)
{
delete[] items.data;
- items.data = NULL;
+ items.data = nullptr;
}
- if( armor.data != NULL)
+ if( armor.data != nullptr)
{
delete[] armor.data;
- armor.data = NULL;
+ armor.data = nullptr;
}
items = ItemInstanceArray( INVENTORY_SIZE );
@@ -553,7 +553,7 @@ void Inventory::load(ListTag<CompoundTag> *inventoryList)
CompoundTag *tag = inventoryList->get(i);
unsigned int slot = tag->getByte(L"Slot") & 0xff;
shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>( ItemInstance::fromTag(tag) );
- if (item != NULL)
+ if (item != nullptr)
{
if (slot >= 0 && slot < items.length) items[slot] = item;
if (slot >= 100 && slot < armor.length + 100) armor[slot - 100] = item;
@@ -614,7 +614,7 @@ bool Inventory::canDestroy(Tile *tile)
if (tile->material->isAlwaysDestroyable()) return true;
shared_ptr<ItemInstance> item = getItem(selected);
- if (item != NULL) return item->canDestroySpecial(tile);
+ if (item != nullptr) return item->canDestroySpecial(tile);
return false;
}
@@ -628,7 +628,7 @@ int Inventory::getArmorValue()
int val = 0;
for (unsigned int i = 0; i < armor.length; i++)
{
- if (armor[i] != NULL && dynamic_cast<ArmorItem *>( armor[i]->getItem() ) != NULL )
+ if (armor[i] != nullptr && dynamic_cast<ArmorItem *>( armor[i]->getItem() ) != nullptr )
{
int baseProtection = dynamic_cast<ArmorItem *>(armor[i]->getItem())->defense;
@@ -647,9 +647,9 @@ void Inventory::hurtArmor(float dmg)
}
for (unsigned int i = 0; i < armor.length; i++)
{
- if (armor[i] != NULL && dynamic_cast<ArmorItem *>( armor[i]->getItem() ) != NULL )
+ if (armor[i] != nullptr && dynamic_cast<ArmorItem *>( armor[i]->getItem() ) != nullptr )
{
- armor[i]->hurtAndBreak( (int) dmg, dynamic_pointer_cast<LivingEntity>( player->shared_from_this() ) );
+ armor[i]->hurtAndBreak( static_cast<int>(dmg), dynamic_pointer_cast<LivingEntity>( player->shared_from_this() ) );
if (armor[i]->count == 0)
{
armor[i] = nullptr;
@@ -662,7 +662,7 @@ void Inventory::dropAll()
{
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL)
+ if (items[i] != nullptr)
{
player->drop(items[i], true);
items[i] = nullptr;
@@ -670,7 +670,7 @@ void Inventory::dropAll()
}
for (unsigned int i = 0; i < armor.length; i++)
{
- if (armor[i] != NULL)
+ if (armor[i] != nullptr)
{
player->drop(armor[i], true);
armor[i] = nullptr;
@@ -699,8 +699,8 @@ bool Inventory::isSame(shared_ptr<Inventory> copy)
bool Inventory::isSame(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b)
{
- if (a == NULL && b == NULL) return true;
- if (a == NULL || b == NULL) return false;
+ if (a == nullptr && b == nullptr) return true;
+ if (a == nullptr || b == nullptr) return false;
return a->id == b->id && a->count == b->count && a->getAuxValue() == b->getAuxValue();
}
@@ -708,14 +708,14 @@ bool Inventory::isSame(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b)
shared_ptr<Inventory> Inventory::copy()
{
- shared_ptr<Inventory> copy = shared_ptr<Inventory>( new Inventory(NULL) );
+ shared_ptr<Inventory> copy = std::make_shared<Inventory>(nullptr);
for (unsigned int i = 0; i < items.length; i++)
{
- copy->items[i] = items[i] != NULL ? items[i]->copy() : nullptr;
+ copy->items[i] = items[i] != nullptr ? items[i]->copy() : nullptr;
}
for (unsigned int i = 0; i < armor.length; i++)
{
- copy->armor[i] = armor[i] != NULL ? armor[i]->copy() : nullptr;
+ copy->armor[i] = armor[i] != nullptr ? armor[i]->copy() : nullptr;
}
return copy;
}
@@ -742,11 +742,11 @@ bool Inventory::contains(shared_ptr<ItemInstance> itemInstance)
{
for (unsigned int i = 0; i < armor.length; i++)
{
- if (armor[i] != NULL && armor[i]->sameItem(itemInstance)) return true;
+ if (armor[i] != nullptr && armor[i]->sameItem(itemInstance)) return true;
}
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL && items[i]->sameItem(itemInstance)) return true;
+ if (items[i] != nullptr && items[i]->sameItem(itemInstance)) return true;
}
return false;
}
@@ -782,15 +782,15 @@ void Inventory::replaceWith(shared_ptr<Inventory> other)
int Inventory::countMatches(shared_ptr<ItemInstance> itemInstance)
{
- if(itemInstance == NULL) return 0;
+ if(itemInstance == nullptr) return 0;
int count = 0;
//for (unsigned int i = 0; i < armor.length; i++)
//{
- // if (armor[i] != NULL && armor[i]->sameItem(itemInstance)) count += items[i]->count;
+ // if (armor[i] != nullptr && armor[i]->sameItem(itemInstance)) count += items[i]->count;
//}
for (unsigned int i = 0; i < items.length; i++)
{
- if (items[i] != NULL && items[i]->sameItemWithTags(itemInstance)) count += items[i]->count;
+ if (items[i] != nullptr && items[i]->sameItemWithTags(itemInstance)) count += items[i]->count;
}
return count;
}
diff --git a/Minecraft.World/InventoryMenu.cpp b/Minecraft.World/InventoryMenu.cpp
index ae5d9269..9c6c661f 100644
--- a/Minecraft.World/InventoryMenu.cpp
+++ b/Minecraft.World/InventoryMenu.cpp
@@ -28,8 +28,8 @@ InventoryMenu::InventoryMenu(shared_ptr<Inventory> inventory, bool active, Playe
void InventoryMenu::_init(shared_ptr<Inventory> inventory, bool active)
{
- craftSlots = shared_ptr<CraftingContainer>( new CraftingContainer(this, 2, 2) );
- resultSlots = shared_ptr<ResultContainer>( new ResultContainer() );
+ craftSlots = std::make_shared<CraftingContainer>(this, 2, 2);
+ resultSlots = std::make_shared<ResultContainer>();
this->active = active;
addSlot(new ResultSlot( inventory->player, craftSlots, resultSlots, 0, 144, 36));
@@ -77,7 +77,7 @@ void InventoryMenu::removed(shared_ptr<Player> player)
for (int i = 0; i < 4; i++)
{
shared_ptr<ItemInstance> item = craftSlots->removeItemNoUpdate(i);
- if (item != NULL)
+ if (item != nullptr)
{
player->drop(item);
craftSlots->setItem(i, nullptr);
@@ -102,7 +102,7 @@ shared_ptr<ItemInstance> InventoryMenu::quickMoveStack(shared_ptr<Player> player
Slot *BootsSlot = slots.at(ARMOR_SLOT_START+3);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
@@ -240,7 +240,7 @@ shared_ptr<ItemInstance> InventoryMenu::clicked(int slotIndex, int buttonNum, in
for (int i = ARMOR_SLOT_START; i < ARMOR_SLOT_END; i++)
{
Slot *slot = slots.at(i);
- if ( (slot==NULL) || (!slot->hasItem()) || (slot->getItem()->getItem()->id != ironItems[i-ARMOR_SLOT_START]) )
+ if ( (slot==nullptr) || (!slot->hasItem()) || (slot->getItem()->getItem()->id != ironItems[i-ARMOR_SLOT_START]) )
{
return out;
}
diff --git a/Minecraft.World/Item.cpp b/Minecraft.World/Item.cpp
index 2f23ab8c..ffb31070 100644
--- a/Minecraft.World/Item.cpp
+++ b/Minecraft.World/Item.cpp
@@ -32,224 +32,224 @@ Random *Item::random = new Random();
ItemArray Item::items = ItemArray( ITEM_NUM_COUNT );
-Item *Item::shovel_iron = NULL;
-Item *Item::pickAxe_iron = NULL;
-Item *Item::hatchet_iron = NULL;
-Item *Item::flintAndSteel = NULL;
-Item *Item::apple = NULL;
-BowItem *Item::bow = NULL;
-Item *Item::arrow = NULL;
-Item *Item::coal = NULL;
-Item *Item::diamond = NULL;
-Item *Item::ironIngot = NULL;
-Item *Item::goldIngot = NULL;
-Item *Item::sword_iron = NULL;
-
-Item *Item::sword_wood = NULL;
-Item *Item::shovel_wood = NULL;
-Item *Item::pickAxe_wood = NULL;
-Item *Item::hatchet_wood = NULL;
-
-Item *Item::sword_stone = NULL;
-Item *Item::shovel_stone = NULL;
-Item *Item::pickAxe_stone = NULL;
-Item *Item::hatchet_stone = NULL;
-
-Item *Item::sword_diamond = NULL;
-Item *Item::shovel_diamond = NULL;
-Item *Item::pickAxe_diamond = NULL;
-Item *Item::hatchet_diamond = NULL;
-
-Item *Item::stick = NULL;
-Item *Item::bowl = NULL;
-Item *Item::mushroomStew = NULL;
-
-Item *Item::sword_gold = NULL;
-Item *Item::shovel_gold = NULL;
-Item *Item::pickAxe_gold = NULL;
-Item *Item::hatchet_gold = NULL;
-
-Item *Item::string = NULL;
-Item *Item::feather = NULL;
-Item *Item::gunpowder = NULL;
-
-Item *Item::hoe_wood = NULL;
-Item *Item::hoe_stone = NULL;
-Item *Item::hoe_iron = NULL;
-Item *Item::hoe_diamond = NULL;
-Item *Item::hoe_gold = NULL;
-
-Item *Item::seeds_wheat = NULL;
-Item *Item::wheat = NULL;
-Item *Item::bread = NULL;
-
-ArmorItem *Item::helmet_leather = NULL;
-ArmorItem *Item::chestplate_leather = NULL;
-ArmorItem *Item::leggings_leather = NULL;
-ArmorItem *Item::boots_leather = NULL;
-
-ArmorItem *Item::helmet_chain = NULL;
-ArmorItem *Item::chestplate_chain = NULL;
-ArmorItem *Item::leggings_chain = NULL;
-ArmorItem *Item::boots_chain = NULL;
-
-ArmorItem *Item::helmet_iron = NULL;
-ArmorItem *Item::chestplate_iron = NULL;
-ArmorItem *Item::leggings_iron = NULL;
-ArmorItem *Item::boots_iron = NULL;
-
-ArmorItem *Item::helmet_diamond = NULL;
-ArmorItem *Item::chestplate_diamond = NULL;
-ArmorItem *Item::leggings_diamond = NULL;
-ArmorItem *Item::boots_diamond = NULL;
-
-ArmorItem *Item::helmet_gold = NULL;
-ArmorItem *Item::chestplate_gold = NULL;
-ArmorItem *Item::leggings_gold = NULL;
-ArmorItem *Item::boots_gold = NULL;
-
-Item *Item::flint = NULL;
-Item *Item::porkChop_raw = NULL;
-Item *Item::porkChop_cooked = NULL;
-Item *Item::painting = NULL;
-
-Item *Item::apple_gold = NULL;
-
-Item *Item::sign = NULL;
-Item *Item::door_wood = NULL;
-
-Item *Item::bucket_empty = NULL;
-Item *Item::bucket_water = NULL;
-Item *Item::bucket_lava = NULL;
-
-Item *Item::minecart = NULL;
-Item *Item::saddle = NULL;
-Item *Item::door_iron = NULL;
-Item *Item::redStone = NULL;
-Item *Item::snowBall = NULL;
-
-Item *Item::boat = NULL;
-
-Item *Item::leather = NULL;
-Item *Item::bucket_milk = NULL;
-Item *Item::brick = NULL;
-Item *Item::clay = NULL;
-Item *Item::reeds = NULL;
-Item *Item::paper = NULL;
-Item *Item::book = NULL;
-Item *Item::slimeBall = NULL;
-Item *Item::minecart_chest = NULL;
-Item *Item::minecart_furnace = NULL;
-Item *Item::egg = NULL;
-Item *Item::compass = NULL;
-FishingRodItem *Item::fishingRod = NULL;
-Item *Item::clock = NULL;
-Item *Item::yellowDust = NULL;
-Item *Item::fish_raw = NULL;
-Item *Item::fish_cooked = NULL;
-
-Item *Item::dye_powder = NULL;
-Item *Item::bone = NULL;
-Item *Item::sugar = NULL;
-Item *Item::cake = NULL;
-
-Item *Item::bed = NULL;
-
-Item *Item::repeater = NULL;
-Item *Item::cookie = NULL;
-
-MapItem *Item::map = NULL;
-
-Item *Item::record_01 = NULL;
-Item *Item::record_02 = NULL;
-Item *Item::record_03 = NULL;
-Item *Item::record_04 = NULL;
-Item *Item::record_05 = NULL;
-Item *Item::record_06 = NULL;
-Item *Item::record_07 = NULL;
-Item *Item::record_08 = NULL;
-Item *Item::record_09 = NULL;
-Item *Item::record_10 = NULL;
-Item *Item::record_11 = NULL;
-Item *Item::record_12 = NULL;
-
-ShearsItem *Item::shears = NULL;
-
-Item *Item::melon = NULL;
-
-Item *Item::seeds_pumpkin = NULL;
-Item *Item::seeds_melon = NULL;
-
-Item *Item::beef_raw = NULL;
-Item *Item::beef_cooked = NULL;
-Item *Item::chicken_raw = NULL;
-Item *Item::chicken_cooked = NULL;
-Item *Item::rotten_flesh = NULL;
-
-Item *Item::enderPearl = NULL;
-
-Item *Item::blazeRod = NULL;
-Item *Item::ghastTear = NULL;
-Item *Item::goldNugget = NULL;
-Item *Item::netherwart_seeds = NULL;
-PotionItem *Item::potion = NULL;
-Item *Item::glassBottle = NULL;
-Item *Item::spiderEye = NULL;
-Item *Item::fermentedSpiderEye = NULL;
-Item *Item::blazePowder = NULL;
-Item *Item::magmaCream = NULL;
-Item *Item::brewingStand = NULL;
-Item *Item::cauldron = NULL;
-Item *Item::eyeOfEnder = NULL;
-Item *Item::speckledMelon = NULL;
-
-Item *Item::spawnEgg = NULL;
-
-Item *Item::expBottle = NULL;
+Item *Item::shovel_iron = nullptr;
+Item *Item::pickAxe_iron = nullptr;
+Item *Item::hatchet_iron = nullptr;
+Item *Item::flintAndSteel = nullptr;
+Item *Item::apple = nullptr;
+BowItem *Item::bow = nullptr;
+Item *Item::arrow = nullptr;
+Item *Item::coal = nullptr;
+Item *Item::diamond = nullptr;
+Item *Item::ironIngot = nullptr;
+Item *Item::goldIngot = nullptr;
+Item *Item::sword_iron = nullptr;
+
+Item *Item::sword_wood = nullptr;
+Item *Item::shovel_wood = nullptr;
+Item *Item::pickAxe_wood = nullptr;
+Item *Item::hatchet_wood = nullptr;
+
+Item *Item::sword_stone = nullptr;
+Item *Item::shovel_stone = nullptr;
+Item *Item::pickAxe_stone = nullptr;
+Item *Item::hatchet_stone = nullptr;
+
+Item *Item::sword_diamond = nullptr;
+Item *Item::shovel_diamond = nullptr;
+Item *Item::pickAxe_diamond = nullptr;
+Item *Item::hatchet_diamond = nullptr;
+
+Item *Item::stick = nullptr;
+Item *Item::bowl = nullptr;
+Item *Item::mushroomStew = nullptr;
+
+Item *Item::sword_gold = nullptr;
+Item *Item::shovel_gold = nullptr;
+Item *Item::pickAxe_gold = nullptr;
+Item *Item::hatchet_gold = nullptr;
+
+Item *Item::string = nullptr;
+Item *Item::feather = nullptr;
+Item *Item::gunpowder = nullptr;
+
+Item *Item::hoe_wood = nullptr;
+Item *Item::hoe_stone = nullptr;
+Item *Item::hoe_iron = nullptr;
+Item *Item::hoe_diamond = nullptr;
+Item *Item::hoe_gold = nullptr;
+
+Item *Item::seeds_wheat = nullptr;
+Item *Item::wheat = nullptr;
+Item *Item::bread = nullptr;
+
+ArmorItem *Item::helmet_leather = nullptr;
+ArmorItem *Item::chestplate_leather = nullptr;
+ArmorItem *Item::leggings_leather = nullptr;
+ArmorItem *Item::boots_leather = nullptr;
+
+ArmorItem *Item::helmet_chain = nullptr;
+ArmorItem *Item::chestplate_chain = nullptr;
+ArmorItem *Item::leggings_chain = nullptr;
+ArmorItem *Item::boots_chain = nullptr;
+
+ArmorItem *Item::helmet_iron = nullptr;
+ArmorItem *Item::chestplate_iron = nullptr;
+ArmorItem *Item::leggings_iron = nullptr;
+ArmorItem *Item::boots_iron = nullptr;
+
+ArmorItem *Item::helmet_diamond = nullptr;
+ArmorItem *Item::chestplate_diamond = nullptr;
+ArmorItem *Item::leggings_diamond = nullptr;
+ArmorItem *Item::boots_diamond = nullptr;
+
+ArmorItem *Item::helmet_gold = nullptr;
+ArmorItem *Item::chestplate_gold = nullptr;
+ArmorItem *Item::leggings_gold = nullptr;
+ArmorItem *Item::boots_gold = nullptr;
+
+Item *Item::flint = nullptr;
+Item *Item::porkChop_raw = nullptr;
+Item *Item::porkChop_cooked = nullptr;
+Item *Item::painting = nullptr;
+
+Item *Item::apple_gold = nullptr;
+
+Item *Item::sign = nullptr;
+Item *Item::door_wood = nullptr;
+
+Item *Item::bucket_empty = nullptr;
+Item *Item::bucket_water = nullptr;
+Item *Item::bucket_lava = nullptr;
+
+Item *Item::minecart = nullptr;
+Item *Item::saddle = nullptr;
+Item *Item::door_iron = nullptr;
+Item *Item::redStone = nullptr;
+Item *Item::snowBall = nullptr;
+
+Item *Item::boat = nullptr;
+
+Item *Item::leather = nullptr;
+Item *Item::bucket_milk = nullptr;
+Item *Item::brick = nullptr;
+Item *Item::clay = nullptr;
+Item *Item::reeds = nullptr;
+Item *Item::paper = nullptr;
+Item *Item::book = nullptr;
+Item *Item::slimeBall = nullptr;
+Item *Item::minecart_chest = nullptr;
+Item *Item::minecart_furnace = nullptr;
+Item *Item::egg = nullptr;
+Item *Item::compass = nullptr;
+FishingRodItem *Item::fishingRod = nullptr;
+Item *Item::clock = nullptr;
+Item *Item::yellowDust = nullptr;
+Item *Item::fish_raw = nullptr;
+Item *Item::fish_cooked = nullptr;
+
+Item *Item::dye_powder = nullptr;
+Item *Item::bone = nullptr;
+Item *Item::sugar = nullptr;
+Item *Item::cake = nullptr;
+
+Item *Item::bed = nullptr;
+
+Item *Item::repeater = nullptr;
+Item *Item::cookie = nullptr;
+
+MapItem *Item::map = nullptr;
+
+Item *Item::record_01 = nullptr;
+Item *Item::record_02 = nullptr;
+Item *Item::record_03 = nullptr;
+Item *Item::record_04 = nullptr;
+Item *Item::record_05 = nullptr;
+Item *Item::record_06 = nullptr;
+Item *Item::record_07 = nullptr;
+Item *Item::record_08 = nullptr;
+Item *Item::record_09 = nullptr;
+Item *Item::record_10 = nullptr;
+Item *Item::record_11 = nullptr;
+Item *Item::record_12 = nullptr;
+
+ShearsItem *Item::shears = nullptr;
+
+Item *Item::melon = nullptr;
+
+Item *Item::seeds_pumpkin = nullptr;
+Item *Item::seeds_melon = nullptr;
+
+Item *Item::beef_raw = nullptr;
+Item *Item::beef_cooked = nullptr;
+Item *Item::chicken_raw = nullptr;
+Item *Item::chicken_cooked = nullptr;
+Item *Item::rotten_flesh = nullptr;
+
+Item *Item::enderPearl = nullptr;
+
+Item *Item::blazeRod = nullptr;
+Item *Item::ghastTear = nullptr;
+Item *Item::goldNugget = nullptr;
+Item *Item::netherwart_seeds = nullptr;
+PotionItem *Item::potion = nullptr;
+Item *Item::glassBottle = nullptr;
+Item *Item::spiderEye = nullptr;
+Item *Item::fermentedSpiderEye = nullptr;
+Item *Item::blazePowder = nullptr;
+Item *Item::magmaCream = nullptr;
+Item *Item::brewingStand = nullptr;
+Item *Item::cauldron = nullptr;
+Item *Item::eyeOfEnder = nullptr;
+Item *Item::speckledMelon = nullptr;
+
+Item *Item::spawnEgg = nullptr;
+
+Item *Item::expBottle = nullptr;
// TU9
-Item *Item::fireball = NULL;
-Item *Item::frame = NULL;
+Item *Item::fireball = nullptr;
+Item *Item::frame = nullptr;
-Item *Item::skull = NULL;
+Item *Item::skull = nullptr;
// TU14
-//Item *Item::writingBook = NULL;
-//Item *Item::writtenBook = NULL;
+//Item *Item::writingBook = nullptr;
+//Item *Item::writtenBook = nullptr;
-Item *Item::emerald = NULL;
+Item *Item::emerald = nullptr;
-Item *Item::flowerPot = NULL;
+Item *Item::flowerPot = nullptr;
-Item *Item::carrots = NULL;
-Item *Item::potato = NULL;
-Item *Item::potatoBaked = NULL;
-Item *Item::potatoPoisonous = NULL;
+Item *Item::carrots = nullptr;
+Item *Item::potato = nullptr;
+Item *Item::potatoBaked = nullptr;
+Item *Item::potatoPoisonous = nullptr;
-EmptyMapItem *Item::emptyMap = NULL;
+EmptyMapItem *Item::emptyMap = nullptr;
-Item *Item::carrotGolden = NULL;
+Item *Item::carrotGolden = nullptr;
-Item *Item::carrotOnAStick = NULL;
-Item *Item::netherStar = NULL;
-Item *Item::pumpkinPie = NULL;
-Item *Item::fireworks = NULL;
-Item *Item::fireworksCharge = NULL;
+Item *Item::carrotOnAStick = nullptr;
+Item *Item::netherStar = nullptr;
+Item *Item::pumpkinPie = nullptr;
+Item *Item::fireworks = nullptr;
+Item *Item::fireworksCharge = nullptr;
-EnchantedBookItem *Item::enchantedBook = NULL;
+EnchantedBookItem *Item::enchantedBook = nullptr;
-Item *Item::comparator = NULL;
-Item *Item::netherbrick = NULL;
-Item *Item::netherQuartz = NULL;
-Item *Item::minecart_tnt = NULL;
-Item *Item::minecart_hopper = NULL;
+Item *Item::comparator = nullptr;
+Item *Item::netherbrick = nullptr;
+Item *Item::netherQuartz = nullptr;
+Item *Item::minecart_tnt = nullptr;
+Item *Item::minecart_hopper = nullptr;
-Item *Item::horseArmorMetal = NULL;
-Item *Item::horseArmorGold = NULL;
-Item *Item::horseArmorDiamond = NULL;
-Item *Item::lead = NULL;
-Item *Item::nameTag = NULL;
+Item *Item::horseArmorMetal = nullptr;
+Item *Item::horseArmorGold = nullptr;
+Item *Item::horseArmorDiamond = nullptr;
+Item *Item::lead = nullptr;
+Item *Item::nameTag = nullptr;
void Item::staticCtor()
@@ -287,30 +287,30 @@ void Item::staticCtor()
Item::door_wood = ( new DoorItem(68, Material::wood) ) ->setBaseItemTypeAndMaterial(eBaseItemType_door, eMaterial_wood)->setIconName(L"doorWood")->setDescriptionId(IDS_ITEM_DOOR_WOOD)->setUseDescriptionId(IDS_DESC_DOOR_WOOD);
Item::door_iron = ( new DoorItem(74, Material::metal) ) ->setBaseItemTypeAndMaterial(eBaseItemType_door, eMaterial_iron)->setIconName(L"doorIron")->setDescriptionId(IDS_ITEM_DOOR_IRON)->setUseDescriptionId(IDS_DESC_DOOR_IRON);
- Item::helmet_leather = (ArmorItem *) ( ( new ArmorItem(42, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_cloth) ->setIconName(L"helmetCloth")->setDescriptionId(IDS_ITEM_HELMET_CLOTH)->setUseDescriptionId(IDS_DESC_HELMET_LEATHER) );
- Item::helmet_iron = (ArmorItem *) ( ( new ArmorItem(50, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_iron) ->setIconName(L"helmetIron")->setDescriptionId(IDS_ITEM_HELMET_IRON)->setUseDescriptionId(IDS_DESC_HELMET_IRON) );
- Item::helmet_diamond = (ArmorItem *) ( ( new ArmorItem(54, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_diamond) ->setIconName(L"helmetDiamond")->setDescriptionId(IDS_ITEM_HELMET_DIAMOND)->setUseDescriptionId(IDS_DESC_HELMET_DIAMOND) );
- Item::helmet_gold = (ArmorItem *) ( ( new ArmorItem(58, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_gold) ->setIconName(L"helmetGold")->setDescriptionId(IDS_ITEM_HELMET_GOLD)->setUseDescriptionId(IDS_DESC_HELMET_GOLD) );
+ Item::helmet_leather = static_cast<ArmorItem *>((new ArmorItem(42, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_cloth)->setIconName(L"helmetCloth")->setDescriptionId(IDS_ITEM_HELMET_CLOTH)->setUseDescriptionId(IDS_DESC_HELMET_LEATHER));
+ Item::helmet_iron = static_cast<ArmorItem *>((new ArmorItem(50, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_iron)->setIconName(L"helmetIron")->setDescriptionId(IDS_ITEM_HELMET_IRON)->setUseDescriptionId(IDS_DESC_HELMET_IRON));
+ Item::helmet_diamond = static_cast<ArmorItem *>((new ArmorItem(54, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_diamond)->setIconName(L"helmetDiamond")->setDescriptionId(IDS_ITEM_HELMET_DIAMOND)->setUseDescriptionId(IDS_DESC_HELMET_DIAMOND));
+ Item::helmet_gold = static_cast<ArmorItem *>((new ArmorItem(58, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_gold)->setIconName(L"helmetGold")->setDescriptionId(IDS_ITEM_HELMET_GOLD)->setUseDescriptionId(IDS_DESC_HELMET_GOLD));
- Item::chestplate_leather = (ArmorItem *) ( ( new ArmorItem(43, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_cloth) ->setIconName(L"chestplateCloth")->setDescriptionId(IDS_ITEM_CHESTPLATE_CLOTH)->setUseDescriptionId(IDS_DESC_CHESTPLATE_LEATHER) );
- Item::chestplate_iron = (ArmorItem *) ( ( new ArmorItem(51, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_iron) ->setIconName(L"chestplateIron")->setDescriptionId(IDS_ITEM_CHESTPLATE_IRON)->setUseDescriptionId(IDS_DESC_CHESTPLATE_IRON) );
- Item::chestplate_diamond = (ArmorItem *) ( ( new ArmorItem(55, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_diamond) ->setIconName(L"chestplateDiamond")->setDescriptionId(IDS_ITEM_CHESTPLATE_DIAMOND)->setUseDescriptionId(IDS_DESC_CHESTPLATE_DIAMOND) );
- Item::chestplate_gold = (ArmorItem *) ( ( new ArmorItem(59, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_gold) ->setIconName(L"chestplateGold")->setDescriptionId(IDS_ITEM_CHESTPLATE_GOLD)->setUseDescriptionId(IDS_DESC_CHESTPLATE_GOLD) );
+ Item::chestplate_leather = static_cast<ArmorItem *>((new ArmorItem(43, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_cloth)->setIconName(L"chestplateCloth")->setDescriptionId(IDS_ITEM_CHESTPLATE_CLOTH)->setUseDescriptionId(IDS_DESC_CHESTPLATE_LEATHER));
+ Item::chestplate_iron = static_cast<ArmorItem *>((new ArmorItem(51, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_iron)->setIconName(L"chestplateIron")->setDescriptionId(IDS_ITEM_CHESTPLATE_IRON)->setUseDescriptionId(IDS_DESC_CHESTPLATE_IRON));
+ Item::chestplate_diamond = static_cast<ArmorItem *>((new ArmorItem(55, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_diamond)->setIconName(L"chestplateDiamond")->setDescriptionId(IDS_ITEM_CHESTPLATE_DIAMOND)->setUseDescriptionId(IDS_DESC_CHESTPLATE_DIAMOND));
+ Item::chestplate_gold = static_cast<ArmorItem *>((new ArmorItem(59, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_gold)->setIconName(L"chestplateGold")->setDescriptionId(IDS_ITEM_CHESTPLATE_GOLD)->setUseDescriptionId(IDS_DESC_CHESTPLATE_GOLD));
- Item::leggings_leather = (ArmorItem *) ( ( new ArmorItem(44, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_cloth) ->setIconName(L"leggingsCloth")->setDescriptionId(IDS_ITEM_LEGGINGS_CLOTH)->setUseDescriptionId(IDS_DESC_LEGGINGS_LEATHER) );
- Item::leggings_iron = (ArmorItem *) ( ( new ArmorItem(52, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_iron) ->setIconName(L"leggingsIron")->setDescriptionId(IDS_ITEM_LEGGINGS_IRON)->setUseDescriptionId(IDS_DESC_LEGGINGS_IRON) );
- Item::leggings_diamond = (ArmorItem *) ( ( new ArmorItem(56, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_diamond) ->setIconName(L"leggingsDiamond")->setDescriptionId(IDS_ITEM_LEGGINGS_DIAMOND)->setUseDescriptionId(IDS_DESC_LEGGINGS_DIAMOND) );
- Item::leggings_gold = (ArmorItem *) ( ( new ArmorItem(60, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_gold) ->setIconName(L"leggingsGold")->setDescriptionId(IDS_ITEM_LEGGINGS_GOLD)->setUseDescriptionId(IDS_DESC_LEGGINGS_GOLD) );
+ Item::leggings_leather = static_cast<ArmorItem *>((new ArmorItem(44, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_cloth)->setIconName(L"leggingsCloth")->setDescriptionId(IDS_ITEM_LEGGINGS_CLOTH)->setUseDescriptionId(IDS_DESC_LEGGINGS_LEATHER));
+ Item::leggings_iron = static_cast<ArmorItem *>((new ArmorItem(52, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_iron)->setIconName(L"leggingsIron")->setDescriptionId(IDS_ITEM_LEGGINGS_IRON)->setUseDescriptionId(IDS_DESC_LEGGINGS_IRON));
+ Item::leggings_diamond = static_cast<ArmorItem *>((new ArmorItem(56, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_diamond)->setIconName(L"leggingsDiamond")->setDescriptionId(IDS_ITEM_LEGGINGS_DIAMOND)->setUseDescriptionId(IDS_DESC_LEGGINGS_DIAMOND));
+ Item::leggings_gold = static_cast<ArmorItem *>((new ArmorItem(60, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_gold)->setIconName(L"leggingsGold")->setDescriptionId(IDS_ITEM_LEGGINGS_GOLD)->setUseDescriptionId(IDS_DESC_LEGGINGS_GOLD));
- Item::helmet_chain = (ArmorItem *) ( ( new ArmorItem(46, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_chain) ->setIconName(L"helmetChain")->setDescriptionId(IDS_ITEM_HELMET_CHAIN)->setUseDescriptionId(IDS_DESC_HELMET_CHAIN) );
- Item::chestplate_chain = (ArmorItem *) ( ( new ArmorItem(47, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_chain) ->setIconName(L"chestplateChain")->setDescriptionId(IDS_ITEM_CHESTPLATE_CHAIN)->setUseDescriptionId(IDS_DESC_CHESTPLATE_CHAIN) );
- Item::leggings_chain = (ArmorItem *) ( ( new ArmorItem(48, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_chain) ->setIconName(L"leggingsChain")->setDescriptionId(IDS_ITEM_LEGGINGS_CHAIN)->setUseDescriptionId(IDS_DESC_LEGGINGS_CHAIN) );
- Item::boots_chain = (ArmorItem *) ( ( new ArmorItem(49, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_chain) ->setIconName(L"bootsChain")->setDescriptionId(IDS_ITEM_BOOTS_CHAIN)->setUseDescriptionId(IDS_DESC_BOOTS_CHAIN) );
+ Item::helmet_chain = static_cast<ArmorItem *>((new ArmorItem(46, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_chain)->setIconName(L"helmetChain")->setDescriptionId(IDS_ITEM_HELMET_CHAIN)->setUseDescriptionId(IDS_DESC_HELMET_CHAIN));
+ Item::chestplate_chain = static_cast<ArmorItem *>((new ArmorItem(47, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_chain)->setIconName(L"chestplateChain")->setDescriptionId(IDS_ITEM_CHESTPLATE_CHAIN)->setUseDescriptionId(IDS_DESC_CHESTPLATE_CHAIN));
+ Item::leggings_chain = static_cast<ArmorItem *>((new ArmorItem(48, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_chain)->setIconName(L"leggingsChain")->setDescriptionId(IDS_ITEM_LEGGINGS_CHAIN)->setUseDescriptionId(IDS_DESC_LEGGINGS_CHAIN));
+ Item::boots_chain = static_cast<ArmorItem *>((new ArmorItem(49, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_chain)->setIconName(L"bootsChain")->setDescriptionId(IDS_ITEM_BOOTS_CHAIN)->setUseDescriptionId(IDS_DESC_BOOTS_CHAIN));
- Item::boots_leather = (ArmorItem *) ( ( new ArmorItem(45, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_cloth) ->setIconName(L"bootsCloth")->setDescriptionId(IDS_ITEM_BOOTS_CLOTH)->setUseDescriptionId(IDS_DESC_BOOTS_LEATHER) );
- Item::boots_iron = (ArmorItem *) ( ( new ArmorItem(53, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_iron) ->setIconName(L"bootsIron")->setDescriptionId(IDS_ITEM_BOOTS_IRON)->setUseDescriptionId(IDS_DESC_BOOTS_IRON) );
- Item::boots_diamond = (ArmorItem *) ( ( new ArmorItem(57, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_diamond) ->setIconName(L"bootsDiamond")->setDescriptionId(IDS_ITEM_BOOTS_DIAMOND)->setUseDescriptionId(IDS_DESC_BOOTS_DIAMOND) );
- Item::boots_gold = (ArmorItem *) ( ( new ArmorItem(61, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_gold) ->setIconName(L"bootsGold")->setDescriptionId(IDS_ITEM_BOOTS_GOLD)->setUseDescriptionId(IDS_DESC_BOOTS_GOLD) );
+ Item::boots_leather = static_cast<ArmorItem *>((new ArmorItem(45, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_cloth)->setIconName(L"bootsCloth")->setDescriptionId(IDS_ITEM_BOOTS_CLOTH)->setUseDescriptionId(IDS_DESC_BOOTS_LEATHER));
+ Item::boots_iron = static_cast<ArmorItem *>((new ArmorItem(53, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_iron)->setIconName(L"bootsIron")->setDescriptionId(IDS_ITEM_BOOTS_IRON)->setUseDescriptionId(IDS_DESC_BOOTS_IRON));
+ Item::boots_diamond = static_cast<ArmorItem *>((new ArmorItem(57, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_diamond)->setIconName(L"bootsDiamond")->setDescriptionId(IDS_ITEM_BOOTS_DIAMOND)->setUseDescriptionId(IDS_DESC_BOOTS_DIAMOND));
+ Item::boots_gold = static_cast<ArmorItem *>((new ArmorItem(61, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_gold)->setIconName(L"bootsGold")->setDescriptionId(IDS_ITEM_BOOTS_GOLD)->setUseDescriptionId(IDS_DESC_BOOTS_GOLD));
Item::ironIngot = ( new Item(9) )->setIconName(L"ingotIron") ->setBaseItemTypeAndMaterial(eBaseItemType_treasure, eMaterial_iron)->setDescriptionId(IDS_ITEM_INGOT_IRON)->setUseDescriptionId(IDS_DESC_INGOT);
Item::goldIngot = ( new Item(10) )->setIconName(L"ingotGold") ->setBaseItemTypeAndMaterial(eBaseItemType_treasure, eMaterial_gold)->setDescriptionId(IDS_ITEM_INGOT_GOLD)->setUseDescriptionId(IDS_DESC_INGOT);
@@ -324,12 +324,12 @@ void Item::staticCtor()
Item::bucket_lava = ( new BucketItem(71, Tile::lava_Id) ) ->setIconName(L"bucketLava")->setDescriptionId(IDS_ITEM_BUCKET_LAVA)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_LAVA);
Item::bucket_milk = ( new MilkBucketItem(79) )->setIconName(L"milk")->setDescriptionId(IDS_ITEM_BUCKET_MILK)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_MILK);
- Item::bow = (BowItem *)( new BowItem(5) ) ->setIconName(L"bow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_bow) ->setDescriptionId(IDS_ITEM_BOW)->setUseDescriptionId(IDS_DESC_BOW);
+ Item::bow = static_cast<BowItem *>((new BowItem(5))->setIconName(L"bow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_bow)->setDescriptionId(IDS_ITEM_BOW)->setUseDescriptionId(IDS_DESC_BOW));
Item::arrow = ( new Item(6) ) ->setIconName(L"arrow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_arrow) ->setDescriptionId(IDS_ITEM_ARROW)->setUseDescriptionId(IDS_DESC_ARROW);
Item::compass = ( new CompassItem(89) ) ->setIconName(L"compass")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_compass) ->setDescriptionId(IDS_ITEM_COMPASS)->setUseDescriptionId(IDS_DESC_COMPASS);
Item::clock = ( new ClockItem(91) ) ->setIconName(L"clock")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_clock) ->setDescriptionId(IDS_ITEM_CLOCK)->setUseDescriptionId(IDS_DESC_CLOCK);
- Item::map = (MapItem *) ( new MapItem(102) ) ->setIconName(L"map")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_map) ->setDescriptionId(IDS_ITEM_MAP)->setUseDescriptionId(IDS_DESC_MAP);
+ Item::map = static_cast<MapItem *>((new MapItem(102))->setIconName(L"map")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_map)->setDescriptionId(IDS_ITEM_MAP)->setUseDescriptionId(IDS_DESC_MAP));
Item::flintAndSteel = ( new FlintAndSteelItem(3) ) ->setIconName(L"flintAndSteel")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_flintandsteel)->setDescriptionId(IDS_ITEM_FLINT_AND_STEEL)->setUseDescriptionId(IDS_DESC_FLINTANDSTEEL);
Item::apple = ( new FoodItem(4, 4, FoodConstants::FOOD_SATURATION_LOW, false) ) ->setIconName(L"apple")->setDescriptionId(IDS_ITEM_APPLE)->setUseDescriptionId(IDS_DESC_APPLE);
@@ -377,7 +377,7 @@ void Item::staticCtor()
Item::minecart_chest = ( new MinecartItem(86, Minecart::TYPE_CHEST) ) ->setIconName(L"minecart_chest")->setDescriptionId(IDS_ITEM_MINECART_CHEST)->setUseDescriptionId(IDS_DESC_MINECARTWITHCHEST);
Item::minecart_furnace = ( new MinecartItem(87, Minecart::TYPE_FURNACE) )->setIconName(L"minecart_furnace")->setDescriptionId(IDS_ITEM_MINECART_FURNACE)->setUseDescriptionId(IDS_DESC_MINECARTWITHFURNACE);
Item::egg = ( new EggItem(88) ) ->setIconName(L"egg")->setDescriptionId(IDS_ITEM_EGG)->setUseDescriptionId(IDS_DESC_EGG);
- Item::fishingRod = (FishingRodItem *)( new FishingRodItem(90) ) ->setBaseItemTypeAndMaterial(eBaseItemType_rod, eMaterial_wood)->setIconName(L"fishingRod")->setDescriptionId(IDS_ITEM_FISHING_ROD)->setUseDescriptionId(IDS_DESC_FISHINGROD);
+ Item::fishingRod = static_cast<FishingRodItem *>((new FishingRodItem(90))->setBaseItemTypeAndMaterial(eBaseItemType_rod, eMaterial_wood)->setIconName(L"fishingRod")->setDescriptionId(IDS_ITEM_FISHING_ROD)->setUseDescriptionId(IDS_DESC_FISHINGROD));
Item::yellowDust = ( new Item(92) ) ->setIconName(L"yellowDust")->setDescriptionId(IDS_ITEM_YELLOW_DUST)->setUseDescriptionId(IDS_DESC_YELLOW_DUST)->setPotionBrewingFormula(PotionBrewing::MOD_GLOWSTONE);
Item::fish_raw = ( new FoodItem(93, 2, FoodConstants::FOOD_SATURATION_LOW, false) ) ->setIconName(L"fishRaw")->setDescriptionId(IDS_ITEM_FISH_RAW)->setUseDescriptionId(IDS_DESC_FISH_RAW);
Item::fish_cooked = ( new FoodItem(94, 5, FoodConstants::FOOD_SATURATION_NORMAL, false) ) ->setIconName(L"fishCooked")->setDescriptionId(IDS_ITEM_FISH_COOKED)->setUseDescriptionId(IDS_DESC_FISH_COOKED);
@@ -392,11 +392,11 @@ void Item::staticCtor()
Item::bed = ( new BedItem(99) ) ->setMaxStackSize(1)->setIconName(L"bed")->setDescriptionId(IDS_ITEM_BED)->setUseDescriptionId(IDS_DESC_BED);
- Item::repeater = ( new TilePlanterItem(100, (Tile *)Tile::diode_off) ) ->setIconName(L"diode")->setDescriptionId(IDS_ITEM_DIODE)->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER);
+ Item::repeater = ( new TilePlanterItem(100, static_cast<Tile *>(Tile::diode_off)) ) ->setIconName(L"diode")->setDescriptionId(IDS_ITEM_DIODE)->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER);
Item::cookie = ( new FoodItem(101, 2, FoodConstants::FOOD_SATURATION_POOR, false) ) ->setIconName(L"cookie")->setDescriptionId(IDS_ITEM_COOKIE)->setUseDescriptionId(IDS_DESC_COOKIE);
- Item::shears = (ShearsItem *)( new ShearsItem(103) ) ->setIconName(L"shears")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_shears)->setDescriptionId(IDS_ITEM_SHEARS)->setUseDescriptionId(IDS_DESC_SHEARS);
+ Item::shears = static_cast<ShearsItem *>((new ShearsItem(103))->setIconName(L"shears")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_shears)->setDescriptionId(IDS_ITEM_SHEARS)->setUseDescriptionId(IDS_DESC_SHEARS));
Item::melon = (new FoodItem(104, 2, FoodConstants::FOOD_SATURATION_LOW, false)) ->setIconName(L"melon")->setDescriptionId(IDS_ITEM_MELON_SLICE)->setUseDescriptionId(IDS_DESC_MELON_SLICE);
@@ -417,7 +417,7 @@ void Item::staticCtor()
Item::netherwart_seeds = (new SeedItem(116, Tile::netherStalk_Id, Tile::soulsand_Id) ) ->setIconName(L"netherStalkSeeds")->setDescriptionId(IDS_ITEM_NETHER_STALK_SEEDS)->setUseDescriptionId(IDS_DESC_NETHER_STALK_SEEDS)->setPotionBrewingFormula(PotionBrewing::MOD_NETHERWART);
- Item::potion = (PotionItem *) ( ( new PotionItem(117) ) ->setIconName(L"potion")->setDescriptionId(IDS_ITEM_POTION)->setUseDescriptionId(IDS_DESC_POTION) );
+ Item::potion = static_cast<PotionItem *>((new PotionItem(117))->setIconName(L"potion")->setDescriptionId(IDS_ITEM_POTION)->setUseDescriptionId(IDS_DESC_POTION));
Item::glassBottle = (new BottleItem(118) ) ->setBaseItemTypeAndMaterial(eBaseItemType_utensil, eMaterial_glass)->setIconName(L"glassBottle")->setDescriptionId(IDS_ITEM_GLASS_BOTTLE)->setUseDescriptionId(IDS_DESC_GLASS_BOTTLE);
Item::spiderEye = (new FoodItem(119, 2, FoodConstants::FOOD_SATURATION_GOOD, false) ) ->setEatEffect(MobEffect::poison->id, 5, 0, 1.0f)->setIconName(L"spiderEye")->setDescriptionId(IDS_ITEM_SPIDER_EYE)->setUseDescriptionId(IDS_DESC_SPIDER_EYE)->setPotionBrewingFormula(PotionBrewing::MOD_SPIDEREYE);
@@ -473,7 +473,7 @@ void Item::staticCtor()
Item::potatoBaked = (new FoodItem(137, 6, FoodConstants::FOOD_SATURATION_NORMAL, false)) ->setIconName(L"potatoBaked")->setDescriptionId(IDS_ITEM_POTATO_BAKED)->setUseDescriptionId(IDS_DESC_POTATO_BAKED);
Item::potatoPoisonous = (new FoodItem(138, 2, FoodConstants::FOOD_SATURATION_LOW, false)) ->setEatEffect(MobEffect::poison->id, 5, 0, .6f)->setIconName(L"potatoPoisonous")->setDescriptionId(IDS_ITEM_POTATO_POISONOUS)->setUseDescriptionId(IDS_DESC_POTATO_POISONOUS);
- Item::emptyMap = (EmptyMapItem *) (new EmptyMapItem(139))->setIconName(L"map_empty")->setDescriptionId(IDS_ITEM_MAP_EMPTY)->setUseDescriptionId(IDS_DESC_MAP_EMPTY);
+ Item::emptyMap = static_cast<EmptyMapItem *>((new EmptyMapItem(139))->setIconName(L"map_empty")->setDescriptionId(IDS_ITEM_MAP_EMPTY)->setUseDescriptionId(IDS_DESC_MAP_EMPTY));
Item::carrotGolden = (new FoodItem(140, 6, FoodConstants::FOOD_SATURATION_SUPERNATURAL, false)) ->setBaseItemTypeAndMaterial(eBaseItemType_giltFruit, eMaterial_carrot)->setIconName(L"carrotGolden")->setPotionBrewingFormula(PotionBrewing::MOD_GOLDENCARROT)->setDescriptionId(IDS_ITEM_CARROT_GOLDEN)->setUseDescriptionId(IDS_DESC_CARROT_GOLDEN);
@@ -482,7 +482,7 @@ void Item::staticCtor()
Item::pumpkinPie = (new FoodItem(144, 8, FoodConstants::FOOD_SATURATION_LOW, false)) ->setIconName(L"pumpkinPie")->setDescriptionId(IDS_ITEM_PUMPKIN_PIE)->setUseDescriptionId(IDS_DESC_PUMPKIN_PIE);
Item::fireworks = (new FireworksItem(145)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_fireworks, Item::eMaterial_undefined)->setIconName(L"fireworks")->setDescriptionId(IDS_FIREWORKS)->setUseDescriptionId(IDS_DESC_FIREWORKS);
Item::fireworksCharge = (new FireworksChargeItem(146)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_fireworks, Item::eMaterial_undefined)->setIconName(L"fireworks_charge")->setDescriptionId(IDS_FIREWORKS_CHARGE)->setUseDescriptionId(IDS_DESC_FIREWORKS_CHARGE);
- EnchantedBookItem::enchantedBook = (EnchantedBookItem *)(new EnchantedBookItem(147)) ->setMaxStackSize(1)->setIconName(L"enchantedBook")->setDescriptionId(IDS_ITEM_ENCHANTED_BOOK)->setUseDescriptionId(IDS_DESC_ENCHANTED_BOOK);
+ EnchantedBookItem::enchantedBook = static_cast<EnchantedBookItem *>((new EnchantedBookItem(147))->setMaxStackSize(1)->setIconName(L"enchantedBook")->setDescriptionId(IDS_ITEM_ENCHANTED_BOOK)->setUseDescriptionId(IDS_DESC_ENCHANTED_BOOK));
Item::comparator = (new TilePlanterItem(148, Tile::comparator_off)) ->setIconName(L"comparator")->setDescriptionId(IDS_ITEM_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR);
Item::netherbrick = (new Item(149)) ->setIconName(L"netherbrick")->setDescriptionId(IDS_ITEM_NETHERBRICK)->setUseDescriptionId(IDS_DESC_ITEM_NETHERBRICK);
Item::netherQuartz = (new Item(150)) ->setIconName(L"netherquartz")->setDescriptionId(IDS_ITEM_NETHER_QUARTZ)->setUseDescriptionId(IDS_DESC_NETHER_QUARTZ);
@@ -568,11 +568,11 @@ Item::Item(int id) : id( 256 + id )
{
maxStackSize = Item::MAX_STACK_SIZE;
maxDamage = 0;
- icon = NULL;
+ icon = nullptr;
m_handEquipped = false;
m_isStackedByData = false;
- craftingRemainingItem = NULL;
+ craftingRemainingItem = nullptr;
potionBrewingFormula = L"";
m_iMaterial=eMaterial_undefined;
@@ -583,7 +583,7 @@ Item::Item(int id) : id( 256 + id )
//string descriptionId;
//this->id = 256 + id;
- if (items[256 + id] != NULL)
+ if (items[256 + id] != nullptr)
{
app.DebugPrintf("CONFLICT @ %d" , id);
}
@@ -837,7 +837,7 @@ Item *Item::getCraftingRemainingItem()
bool Item::hasCraftingRemainingItem()
{
- return craftingRemainingItem != NULL;
+ return craftingRemainingItem != nullptr;
}
wstring Item::getName()
diff --git a/Minecraft.World/ItemDispenseBehaviors.cpp b/Minecraft.World/ItemDispenseBehaviors.cpp
index 08c73a0c..8758dcfb 100644
--- a/Minecraft.World/ItemDispenseBehaviors.cpp
+++ b/Minecraft.World/ItemDispenseBehaviors.cpp
@@ -11,7 +11,7 @@
shared_ptr<Projectile> ArrowDispenseBehavior::getProjectile(Level *world, Position *position)
{
- shared_ptr<Arrow> arrow = shared_ptr<Arrow>(new Arrow(world, position->getX(), position->getY(), position->getZ()));
+ shared_ptr<Arrow> arrow = std::make_shared<Arrow>(world, position->getX(), position->getY(), position->getZ());
arrow->pickup = Arrow::PICKUP_ALLOWED;
return arrow;
@@ -21,7 +21,7 @@ shared_ptr<Projectile> ArrowDispenseBehavior::getProjectile(Level *world, Positi
shared_ptr<Projectile> EggDispenseBehavior::getProjectile(Level *world, Position *position)
{
- return shared_ptr<Projectile>(new ThrownEgg(world, position->getX(), position->getY(), position->getZ()));
+ return std::make_shared<ThrownEgg>(world, position->getX(), position->getY(), position->getZ());
}
@@ -29,7 +29,7 @@ shared_ptr<Projectile> EggDispenseBehavior::getProjectile(Level *world, Position
shared_ptr<Projectile> SnowballDispenseBehavior::getProjectile(Level *world, Position *position)
{
- return shared_ptr<Projectile>(new Snowball(world, position->getX(), position->getY(), position->getZ()));
+ return std::make_shared<Snowball>(world, position->getX(), position->getY(), position->getZ());
}
@@ -37,7 +37,7 @@ shared_ptr<Projectile> SnowballDispenseBehavior::getProjectile(Level *world, Pos
shared_ptr<Projectile> ExpBottleDispenseBehavior::getProjectile(Level *world, Position *position)
{
- return shared_ptr<Projectile>(new ThrownExpBottle(world, position->getX(), position->getY(), position->getZ()));
+ return std::make_shared<ThrownExpBottle>(world, position->getX(), position->getY(), position->getZ());
}
float ExpBottleDispenseBehavior::getUncertainty()
@@ -60,7 +60,7 @@ ThrownPotionDispenseBehavior::ThrownPotionDispenseBehavior(int potionValue)
shared_ptr<Projectile> ThrownPotionDispenseBehavior::getProjectile(Level *world, Position *position)
{
- return shared_ptr<Projectile>(new ThrownPotion(world, position->getX(), position->getY(), position->getZ(), m_potionValue));
+ return std::make_shared<ThrownPotion>(world, position->getX(), position->getY(), position->getZ(), m_potionValue);
}
float ThrownPotionDispenseBehavior::getUncertainty()
@@ -104,7 +104,7 @@ shared_ptr<ItemInstance> SpawnEggDispenseBehavior::execute(BlockSource *source,
shared_ptr<Entity> entity = SpawnEggItem::spawnMobAt(source->getWorld(), dispensed->getAuxValue(), spawnX, spawnY, spawnZ, &iResult);
// 4J-JEV: Added in-case spawn limit is encountered.
- if (entity == NULL)
+ if (entity == nullptr)
{
outcome = LEFT_ITEM;
return dispensed;
@@ -139,7 +139,7 @@ shared_ptr<ItemInstance> FireworksDispenseBehavior::execute(BlockSource *source,
double spawnY = source->getBlockY() + .2f;
double spawnZ = source->getZ() + facing->getStepZ();
- shared_ptr<FireworksRocketEntity> firework = shared_ptr<FireworksRocketEntity>(new FireworksRocketEntity(world, spawnX, spawnY, spawnZ, dispensed));
+ shared_ptr<FireworksRocketEntity> firework = std::make_shared<FireworksRocketEntity>(world, spawnX, spawnY, spawnZ, dispensed);
source->getWorld()->addEntity(firework);
outcome = ACTIVATED_ITEM;
@@ -183,7 +183,7 @@ shared_ptr<ItemInstance> FireballDispenseBehavior::execute(BlockSource *source,
double dirY = random->nextGaussian() * .05 + facing->getStepY();
double dirZ = random->nextGaussian() * .05 + facing->getStepZ();
- world->addEntity(shared_ptr<SmallFireball>(new SmallFireball(world, spawnX, spawnY, spawnZ, dirX, dirY, dirZ)));
+ world->addEntity(std::make_shared<SmallFireball>(world, spawnX, spawnY, spawnZ, dirX, dirY, dirZ));
outcome = ACTIVATED_ITEM;
@@ -254,7 +254,7 @@ shared_ptr<ItemInstance> BoatDispenseBehavior::execute(BlockSource *source, shar
outcome = ACTIVATED_ITEM;
- shared_ptr<Boat> boat = shared_ptr<Boat>(new Boat(world, spawnX, spawnY + yOffset, spawnZ));
+ shared_ptr<Boat> boat = std::make_shared<Boat>(world, spawnX, spawnY + yOffset, spawnZ);
world->addEntity(boat);
dispensed->remove(1);
@@ -273,7 +273,7 @@ void BoatDispenseBehavior::playSound(BlockSource *source, eOUTCOME outcome)
shared_ptr<ItemInstance> FilledBucketDispenseBehavior::execute(BlockSource *source, shared_ptr<ItemInstance> dispensed, eOUTCOME &outcome)
{
- BucketItem *bucket = (BucketItem *)dispensed->getItem();
+ BucketItem *bucket = static_cast<BucketItem *>(dispensed->getItem());
int sourceX = source->getBlockX();
int sourceY = source->getBlockY();
int sourceZ = source->getBlockZ();
@@ -326,9 +326,9 @@ shared_ptr<ItemInstance> EmptyBucketDispenseBehavior::execute(BlockSource *sourc
dispensed->id = targetType->id;
dispensed->count = 1;
}
- else if (dynamic_pointer_cast<DispenserTileEntity>(source->getEntity())->addItem(shared_ptr<ItemInstance>(new ItemInstance(targetType))) < 0)
+ else if (dynamic_pointer_cast<DispenserTileEntity>(source->getEntity())->addItem(std::make_shared<ItemInstance>(targetType)) < 0)
{
- DefaultDispenseItemBehavior::dispense(source, shared_ptr<ItemInstance>(new ItemInstance(targetType)));
+ DefaultDispenseItemBehavior::dispense(source, std::make_shared<ItemInstance>(targetType));
}
outcome = ACTIVATED_ITEM;
@@ -442,7 +442,7 @@ shared_ptr<ItemInstance> TntDispenseBehavior::execute(BlockSource *source, share
int targetY = source->getBlockY() + facing->getStepY();
int targetZ = source->getBlockZ() + facing->getStepZ();
- shared_ptr<PrimedTnt> tnt = shared_ptr<PrimedTnt>(new PrimedTnt(world, targetX + 0.5f, targetY + 0.5f, targetZ + 0.5f, nullptr));
+ shared_ptr<PrimedTnt> tnt(new PrimedTnt(world, targetX + 0.5, targetY + 0.5, targetZ + 0.5, nullptr));
world->addEntity(tnt);
outcome = ACTIVATED_ITEM;
diff --git a/Minecraft.World/ItemEntity.cpp b/Minecraft.World/ItemEntity.cpp
index 66d271f7..5dc1db6e 100644
--- a/Minecraft.World/ItemEntity.cpp
+++ b/Minecraft.World/ItemEntity.cpp
@@ -20,7 +20,7 @@ void ItemEntity::_init()
age = 0;
throwTime = 0;
health = 5;
- bobOffs = (float) (Math::random() * PI * 2);
+ bobOffs = static_cast<float>(Math::random() * PI * 2);
// 4J Stu - This function call had to be moved here from the Entity ctor to ensure that
// the derived version of the function is called
@@ -36,11 +36,11 @@ void ItemEntity::_init(Level *level, double x, double y, double z)
setPos(x, y, z);
- yRot = (float) (Math::random() * 360);
+ yRot = static_cast<float>(Math::random() * 360);
- xd = (float) (Math::random() * 0.2f - 0.1f);
+ xd = static_cast<float>(Math::random() * 0.2f - 0.1f);
yd = +0.2f;
- zd = (float) (Math::random() * 0.2f - 0.1f);
+ zd = static_cast<float>(Math::random() * 0.2f - 0.1f);
}
ItemEntity::ItemEntity(Level *level, double x, double y, double z) : Entity(level)
@@ -66,7 +66,7 @@ ItemEntity::ItemEntity(Level *level) : Entity( level )
void ItemEntity::defineSynchedData()
{
- getEntityData()->defineNULL(DATA_ITEM, NULL);
+ getEntityData()->defineNULL(DATA_ITEM, nullptr);
}
void ItemEntity::tick()
@@ -84,7 +84,7 @@ void ItemEntity::tick()
// 4J - added parameter here so that these don't care about colliding with other entities
move(xd, yd, zd, true);
- bool moved = (int) xo != (int) x || (int) yo != (int) y || (int) zo != (int) z;
+ bool moved = static_cast<int>(xo) != static_cast<int>(x) || static_cast<int>(yo) != static_cast<int>(y) || static_cast<int>(zo) != static_cast<int>(z);
if (moved || tickCount % 25 == 0)
{
@@ -192,7 +192,7 @@ bool ItemEntity::hurt(DamageSource *source, float damage)
if (level->isClientSide ) return false;
if (isInvulnerable()) return false;
- if (getItem() != NULL && getItem()->id == Item::netherStar_Id && source->isExplosion()) return false;
+ if (getItem() != nullptr && getItem()->id == Item::netherStar_Id && source->isExplosion()) return false;
markHurt();
health -= damage;
if (health <= 0)
@@ -204,9 +204,9 @@ bool ItemEntity::hurt(DamageSource *source, float damage)
void ItemEntity::addAdditonalSaveData(CompoundTag *entityTag)
{
- entityTag->putShort(L"Health", (byte) health);
- entityTag->putShort(L"Age", (short) age);
- if (getItem() != NULL) entityTag->putCompound(L"Item", getItem()->save(new CompoundTag()));
+ entityTag->putShort(L"Health", static_cast<byte>(health));
+ entityTag->putShort(L"Age", static_cast<short>(age));
+ if (getItem() != nullptr) entityTag->putCompound(L"Item", getItem()->save(new CompoundTag()));
}
void ItemEntity::readAdditionalSaveData(CompoundTag *tag)
@@ -215,7 +215,7 @@ void ItemEntity::readAdditionalSaveData(CompoundTag *tag)
age = tag->getShort(L"Age");
CompoundTag *itemTag = tag->getCompound(L"Item");
setItem(ItemInstance::fromTag(itemTag));
- if (getItem() == NULL) remove();
+ if (getItem() == nullptr) remove();
}
void ItemEntity::playerTouch(shared_ptr<Player> player)
@@ -280,14 +280,14 @@ shared_ptr<ItemInstance> ItemEntity::getItem()
{
shared_ptr<ItemInstance> result = getEntityData()->getItemInstance(DATA_ITEM);
- if (result == NULL)
+ if (result == nullptr)
{
- if (level != NULL)
+ if (level != nullptr)
{
app.DebugPrintf("Item entity %d has no item?!\n", entityId);
//level.getLogger().severe("Item entity " + entityId + " has no item?!");
}
- return shared_ptr<ItemInstance>(new ItemInstance(Tile::stone));
+ return std::make_shared<ItemInstance>(Tile::stone);
}
return result;
diff --git a/Minecraft.World/ItemFrame.cpp b/Minecraft.World/ItemFrame.cpp
index 0d52b421..f5988b9f 100644
--- a/Minecraft.World/ItemFrame.cpp
+++ b/Minecraft.World/ItemFrame.cpp
@@ -37,8 +37,8 @@ ItemFrame::ItemFrame(Level *level, int xTile, int yTile, int zTile, int dir) : H
void ItemFrame::defineSynchedData()
{
- getEntityData()->defineNULL(DATA_ITEM, NULL);
- getEntityData()->define(DATA_ROTATION, (byte) 0);
+ getEntityData()->defineNULL(DATA_ITEM, nullptr);
+ getEntityData()->define(DATA_ROTATION, static_cast<byte>(0));
}
bool ItemFrame::shouldRenderAtSqrDistance(double distance)
@@ -52,7 +52,7 @@ void ItemFrame::dropItem(shared_ptr<Entity> causedBy)
{
shared_ptr<ItemInstance> item = getItem();
- if (causedBy != NULL && causedBy->instanceof(eTYPE_PLAYER))
+ if (causedBy != nullptr && causedBy->instanceof(eTYPE_PLAYER))
{
if (dynamic_pointer_cast<Player>(causedBy)->abilities.instabuild)
{
@@ -61,8 +61,8 @@ void ItemFrame::dropItem(shared_ptr<Entity> causedBy)
}
}
- spawnAtLocation( shared_ptr<ItemInstance>(new ItemInstance(Item::frame) ), 0);
- if ( (item != NULL) && (random->nextFloat() < dropChance) )
+ spawnAtLocation(std::make_shared<ItemInstance>(Item::frame), 0);
+ if ( (item != nullptr) && (random->nextFloat() < dropChance) )
{
item = item->copy();
removeFramedMap(item);
@@ -72,7 +72,7 @@ void ItemFrame::dropItem(shared_ptr<Entity> causedBy)
void ItemFrame::removeFramedMap(shared_ptr<ItemInstance> item)
{
- if (item == NULL) return;
+ if (item == nullptr) return;
if (item->id == Item::map_Id)
{
shared_ptr<MapItemSavedData> mapItemSavedData = Item::map->getSavedData(item, level);
@@ -89,7 +89,7 @@ shared_ptr<ItemInstance> ItemFrame::getItem()
void ItemFrame::setItem(shared_ptr<ItemInstance> item)
{
- if(item != NULL)
+ if(item != nullptr)
{
item = item->copy();
item->count = 1;
@@ -107,15 +107,15 @@ int ItemFrame::getRotation()
void ItemFrame::setRotation(int rotation)
{
- getEntityData()->set(DATA_ROTATION, (byte) (rotation % 4));
+ getEntityData()->set(DATA_ROTATION, static_cast<byte>(rotation % 4));
}
void ItemFrame::addAdditonalSaveData(CompoundTag *tag)
{
- if (getItem() != NULL)
+ if (getItem() != nullptr)
{
tag->putCompound(L"Item", getItem()->save(new CompoundTag()));
- tag->putByte(L"ItemRotation", (byte) getRotation());
+ tag->putByte(L"ItemRotation", static_cast<byte>(getRotation()));
tag->putFloat(L"ItemDropChance", dropChance);
}
HangingEntity::addAdditonalSaveData(tag);
@@ -124,7 +124,7 @@ void ItemFrame::addAdditonalSaveData(CompoundTag *tag)
void ItemFrame::readAdditionalSaveData(CompoundTag *tag)
{
CompoundTag *itemTag = tag->getCompound(L"Item");
- if (itemTag != NULL && !itemTag->isEmpty())
+ if (itemTag != nullptr && !itemTag->isEmpty())
{
setItem(ItemInstance::fromTag(itemTag));
setRotation(tag->getByte(L"ItemRotation"));
@@ -141,11 +141,11 @@ bool ItemFrame::interact(shared_ptr<Player> player)
return false;
}
- if (getItem() == NULL)
+ if (getItem() == nullptr)
{
shared_ptr<ItemInstance> item = player->getCarriedItem();
- if (item != NULL)
+ if (item != nullptr)
{
if (!level->isClientSide)//isClientSide)
{
diff --git a/Minecraft.World/ItemInstance.cpp b/Minecraft.World/ItemInstance.cpp
index 4dcde7aa..4906c22e 100644
--- a/Minecraft.World/ItemInstance.cpp
+++ b/Minecraft.World/ItemInstance.cpp
@@ -25,7 +25,7 @@ void ItemInstance::_init(int id, int count, int auxValue)
this->id = id;
this->count = count;
this->auxValue = auxValue;
- this->tag = NULL;
+ this->tag = nullptr;
this->frame = nullptr;
// 4J-PB - for trading menu
this->m_bForceNumberDisplay=false;
@@ -81,18 +81,18 @@ shared_ptr<ItemInstance> ItemInstance::fromTag(CompoundTag *itemTag)
{
shared_ptr<ItemInstance> itemInstance = shared_ptr<ItemInstance>(new ItemInstance());
itemInstance->load(itemTag);
- return itemInstance->getItem() != NULL ? itemInstance : nullptr;
+ return itemInstance->getItem() != nullptr ? itemInstance : nullptr;
}
ItemInstance::~ItemInstance()
{
- if(tag != NULL) delete tag;
+ if(tag != nullptr) delete tag;
}
shared_ptr<ItemInstance> ItemInstance::remove(int count)
{
- shared_ptr<ItemInstance> ii = shared_ptr<ItemInstance>( new ItemInstance(id, count, auxValue) );
- if (tag != NULL) ii->tag = (CompoundTag *) tag->copy();
+ shared_ptr<ItemInstance> ii = std::make_shared<ItemInstance>(id, count, auxValue);
+ if (tag != nullptr) ii->tag = static_cast<CompoundTag *>(tag->copy());
this->count -= count;
// 4J Stu Fix for duplication glitch, make sure that item count is in range
@@ -145,10 +145,10 @@ shared_ptr<ItemInstance> ItemInstance::useTimeDepleted(Level *level, shared_ptr<
CompoundTag *ItemInstance::save(CompoundTag *compoundTag)
{
- compoundTag->putShort(L"id", (short) id);
- compoundTag->putByte(L"Count", (byte) count);
- compoundTag->putShort(L"Damage", (short) auxValue);
- if (tag != NULL) compoundTag->put(L"tag", tag->copy());
+ compoundTag->putShort(L"id", static_cast<short>(id));
+ compoundTag->putByte(L"Count", static_cast<byte>(count));
+ compoundTag->putShort(L"Damage", static_cast<short>(auxValue));
+ if (tag != nullptr) compoundTag->put(L"tag", tag->copy());
return compoundTag;
}
@@ -165,7 +165,7 @@ void ItemInstance::load(CompoundTag *compoundTag)
if (compoundTag->contains(L"tag"))
{
delete tag;
- tag = (CompoundTag *)compoundTag->getCompound(L"tag")->copy();
+ tag = static_cast<CompoundTag *>(compoundTag->getCompound(L"tag")->copy());
}
}
@@ -257,7 +257,7 @@ bool ItemInstance::hurt(int dmg, Random *random)
void ItemInstance::hurtAndBreak(int dmg, shared_ptr<LivingEntity> owner)
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(owner);
- if (player != NULL && player->abilities.instabuild) return;
+ if (player != nullptr && player->abilities.instabuild) return;
if (!isDamageableItem()) return;
if (hurt(dmg, owner->getRandom()))
@@ -265,10 +265,10 @@ void ItemInstance::hurtAndBreak(int dmg, shared_ptr<LivingEntity> owner)
owner->breakItem(shared_from_this());
count--;
- if (player != NULL)
+ if (player != nullptr)
{
//player->awardStat(Stats::itemBroke[id], 1);
- if (count == 0 && dynamic_cast<BowItem *>( getItem() ) != NULL)
+ if (count == 0 && dynamic_cast<BowItem *>( getItem() ) != nullptr)
{
player->removeSelectedItem();
}
@@ -302,10 +302,10 @@ bool ItemInstance::interactEnemy(shared_ptr<Player> player, shared_ptr<LivingEnt
shared_ptr<ItemInstance> ItemInstance::copy() const
{
- shared_ptr<ItemInstance> copy = shared_ptr<ItemInstance>( new ItemInstance(id, count, auxValue) );
- if (tag != NULL)
+ shared_ptr<ItemInstance> copy = std::make_shared<ItemInstance>(id, count, auxValue);
+ if (tag != nullptr)
{
- copy->tag = (CompoundTag *) tag->copy();
+ copy->tag = static_cast<CompoundTag *>(tag->copy());
}
return copy;
}
@@ -314,9 +314,9 @@ shared_ptr<ItemInstance> ItemInstance::copy() const
ItemInstance *ItemInstance::copy_not_shared() const
{
ItemInstance *copy = new ItemInstance(id, count, auxValue);
- if (tag != NULL)
+ if (tag != nullptr)
{
- copy->tag = (CompoundTag *) tag->copy();
+ copy->tag = static_cast<CompoundTag *>(tag->copy());
if (!copy->tag->equals(tag))
{
return copy;
@@ -328,14 +328,14 @@ ItemInstance *ItemInstance::copy_not_shared() const
// 4J Brought forward from 1.2
bool ItemInstance::tagMatches(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b)
{
- if (a == NULL && b == NULL) return true;
- if (a == NULL || b == NULL) return false;
+ if (a == nullptr && b == nullptr) return true;
+ if (a == nullptr || b == nullptr) return false;
- if (a->tag == NULL && b->tag != NULL)
+ if (a->tag == nullptr && b->tag != nullptr)
{
return false;
}
- if (a->tag != NULL && !a->tag->equals(b->tag))
+ if (a->tag != nullptr && !a->tag->equals(b->tag))
{
return false;
}
@@ -344,8 +344,8 @@ bool ItemInstance::tagMatches(shared_ptr<ItemInstance> a, shared_ptr<ItemInstanc
bool ItemInstance::matches(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b)
{
- if (a == NULL && b == NULL) return true;
- if (a == NULL || b == NULL) return false;
+ if (a == nullptr && b == nullptr) return true;
+ if (a == nullptr || b == nullptr) return false;
return a->matches(b);
}
@@ -354,11 +354,11 @@ bool ItemInstance::matches(shared_ptr<ItemInstance> b)
if (count != b->count) return false;
if (id != b->id) return false;
if (auxValue != b->auxValue) return false;
- if (tag == NULL && b->tag != NULL)
+ if (tag == nullptr && b->tag != nullptr)
{
return false;
}
- if (tag != NULL && !tag->equals(b->tag))
+ if (tag != nullptr && !tag->equals(b->tag))
{
return false;
}
@@ -381,11 +381,11 @@ bool ItemInstance::sameItemWithTags(shared_ptr<ItemInstance> b)
{
if (id != b->id) return false;
if (auxValue != b->auxValue) return false;
- if (tag == NULL && b->tag != NULL)
+ if (tag == nullptr && b->tag != nullptr)
{
return false;
}
- if (tag != NULL && !tag->equals(b->tag))
+ if (tag != nullptr && !tag->equals(b->tag))
{
return false;
}
@@ -417,7 +417,7 @@ ItemInstance *ItemInstance::setDescriptionId(unsigned int id)
shared_ptr<ItemInstance> ItemInstance::clone(shared_ptr<ItemInstance> item)
{
- return item == NULL ? nullptr : item->copy();
+ return item == nullptr ? nullptr : item->copy();
}
wstring ItemInstance::toString()
@@ -426,9 +426,9 @@ wstring ItemInstance::toString()
std::wostringstream oss;
// 4J-PB - TODO - temp fix until ore recipe issue is fixed
- if(Item::items[id]==NULL)
+ if(Item::items[id]==nullptr)
{
- oss << std::dec << count << L"x" << L" Item::items[id] is NULL " << L"@" << auxValue;
+ oss << std::dec << count << L"x" << L" Item::items[id] is nullptr " << L"@" << auxValue;
}
else
{
@@ -479,7 +479,7 @@ void ItemInstance::releaseUsing(Level *level, shared_ptr<Player> player, int dur
// 4J Stu - Brought forward these functions for enchanting/game rules
bool ItemInstance::hasTag()
{
- return tag != NULL;
+ return tag != nullptr;
}
CompoundTag *ItemInstance::getTag()
@@ -489,11 +489,11 @@ CompoundTag *ItemInstance::getTag()
ListTag<CompoundTag> *ItemInstance::getEnchantmentTags()
{
- if (tag == NULL)
+ if (tag == nullptr)
{
- return NULL;
+ return nullptr;
}
- return (ListTag<CompoundTag> *) tag->get(L"ench");
+ return static_cast<ListTag<CompoundTag> *>(tag->get(L"ench"));
}
void ItemInstance::setTag(CompoundTag *tag)
@@ -506,7 +506,7 @@ wstring ItemInstance::getHoverName()
{
wstring title = getItem()->getHoverName(shared_from_this());
- if (tag != NULL && tag->contains(L"display"))
+ if (tag != nullptr && tag->contains(L"display"))
{
CompoundTag *display = tag->getCompound(L"display");
@@ -521,14 +521,14 @@ wstring ItemInstance::getHoverName()
void ItemInstance::setHoverName(const wstring &name)
{
- if (tag == NULL) tag = new CompoundTag();
+ if (tag == nullptr) tag = new CompoundTag();
if (!tag->contains(L"display")) tag->putCompound(L"display", new CompoundTag());
tag->getCompound(L"display")->putString(L"Name", name);
}
void ItemInstance::resetHoverName()
{
- if (tag == NULL) return;
+ if (tag == nullptr) return;
if (!tag->contains(L"display")) return;
CompoundTag *display = tag->getCompound(L"display");
display->remove(L"Name");
@@ -539,14 +539,14 @@ void ItemInstance::resetHoverName()
if (tag->isEmpty())
{
- setTag(NULL);
+ setTag(nullptr);
}
}
}
bool ItemInstance::hasCustomHoverName()
{
- if (tag == NULL) return false;
+ if (tag == nullptr) return false;
if (!tag->contains(L"display")) return false;
return tag->getCompound(L"display")->contains(L"Name");
}
@@ -598,14 +598,14 @@ vector<HtmlString> *ItemInstance::getHoverText(shared_ptr<Player> player, bool a
if (hasTag())
{
ListTag<CompoundTag> *list = getEnchantmentTags();
- if (list != NULL)
+ if (list != nullptr)
{
for (int i = 0; i < list->size(); i++)
{
int type = list->get(i)->getShort((wchar_t *)TAG_ENCH_ID);
int level = list->get(i)->getShort((wchar_t *)TAG_ENCH_LEVEL);
- if (Enchantment::enchantments[type] != NULL)
+ if (Enchantment::enchantments[type] != nullptr)
{
wstring unformatted = L"";
lines->push_back(Enchantment::enchantments[type]->getFullname(level));
@@ -693,14 +693,14 @@ vector<HtmlString> *ItemInstance::getHoverTextOnly(shared_ptr<Player> player, bo
if (hasTag())
{
ListTag<CompoundTag> *list = getEnchantmentTags();
- if (list != NULL)
+ if (list != nullptr)
{
for (int i = 0; i < list->size(); i++)
{
int type = list->get(i)->getShort((wchar_t *)TAG_ENCH_ID);
int level = list->get(i)->getShort((wchar_t *)TAG_ENCH_LEVEL);
- if (Enchantment::enchantments[type] != NULL)
+ if (Enchantment::enchantments[type] != nullptr)
{
wstring unformatted = L"";
lines->push_back(Enchantment::enchantments[type]->getFullname(level));
@@ -730,25 +730,25 @@ 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<CompoundTag>(L"ench"));
- ListTag<CompoundTag> *list = (ListTag<CompoundTag> *) tag->get(L"ench");
+ ListTag<CompoundTag> *list = static_cast<ListTag<CompoundTag> *>(tag->get(L"ench"));
CompoundTag *ench = new CompoundTag();
- ench->putShort((wchar_t *)TAG_ENCH_ID, (short) enchantment->id);
- ench->putShort((wchar_t *)TAG_ENCH_LEVEL, (byte) level);
+ ench->putShort((wchar_t *)TAG_ENCH_ID, static_cast<short>(enchantment->id));
+ ench->putShort((wchar_t *)TAG_ENCH_LEVEL, static_cast<byte>(level));
list->add(ench);
}
bool ItemInstance::isEnchanted()
{
- if (tag != NULL && tag->contains(L"ench")) return true;
+ if (tag != nullptr && tag->contains(L"ench")) return true;
return false;
}
void ItemInstance::addTagElement(wstring name, Tag *tag)
{
- if (this->tag == NULL)
+ if (this->tag == nullptr)
{
setTag(new CompoundTag());
}
@@ -762,7 +762,7 @@ bool ItemInstance::mayBePlacedInAdventureMode()
bool ItemInstance::isFramed()
{
- return frame != NULL;
+ return frame != nullptr;
}
void ItemInstance::setFramed(shared_ptr<ItemFrame> frame)
@@ -795,7 +795,7 @@ void ItemInstance::setRepairCost(int cost)
attrAttrModMap *ItemInstance::getAttributeModifiers()
{
- attrAttrModMap *result = NULL;
+ attrAttrModMap *result = nullptr;
if (hasTag() && tag->contains(L"AttributeModifiers"))
{
@@ -824,12 +824,12 @@ 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");
+ IntTag *dataTag = static_cast<IntTag *>(tag->get(L"4jdata"));
dataTag->data = data;
}
else if(data != 0)
@@ -840,10 +840,10 @@ void ItemInstance::set4JData(int data)
int ItemInstance::get4JData()
{
- if(tag == NULL || !tag->contains(L"4jdata")) return 0;
+ if(tag == nullptr || !tag->contains(L"4jdata")) return 0;
else
{
- IntTag *dataTag = (IntTag *)tag->get(L"4jdata");
+ IntTag *dataTag = static_cast<IntTag *>(tag->get(L"4jdata"));
return dataTag->data;
}
}
diff --git a/Minecraft.World/JavaIntHash.h b/Minecraft.World/JavaIntHash.h
index fe608469..8293cb46 100644
--- a/Minecraft.World/JavaIntHash.h
+++ b/Minecraft.World/JavaIntHash.h
@@ -13,9 +13,9 @@ struct IntKeyHash
{
int h = k;
h += ~(h << 9);
- h ^= (((unsigned int)h) >> 14);
+ h ^= (static_cast<unsigned int>(h) >> 14);
h += (h << 4);
- h ^= (((unsigned int)h) >> 10);
+ h ^= (static_cast<unsigned int>(h) >> 10);
return h;
}
};
diff --git a/Minecraft.World/JavaMath.cpp b/Minecraft.World/JavaMath.cpp
index 87778c56..cec2eb3a 100644
--- a/Minecraft.World/JavaMath.cpp
+++ b/Minecraft.World/JavaMath.cpp
@@ -36,7 +36,7 @@ double Math::random()
//the value of the argument rounded to the nearest long value.
int64_t Math::round( double d )
{
- return (int64_t)floor( d + 0.5 );
+ return static_cast<int64_t>(floor(d + 0.5));
}
int Math::_max(int a, int b)
diff --git a/Minecraft.World/JukeboxTile.cpp b/Minecraft.World/JukeboxTile.cpp
index cf53a751..74e79e9e 100644
--- a/Minecraft.World/JukeboxTile.cpp
+++ b/Minecraft.World/JukeboxTile.cpp
@@ -23,7 +23,7 @@ void JukeboxTile::Entity::load(CompoundTag *tag)
}
else if (tag->getInt(L"Record") > 0)
{
- setRecord(shared_ptr<ItemInstance>( new ItemInstance(tag->getInt(L"Record"), 1, 0)));
+ setRecord(std::make_shared<ItemInstance>(tag->getInt(L"Record"), 1, 0));
}
}
@@ -31,7 +31,7 @@ void JukeboxTile::Entity::save(CompoundTag *tag)
{
TileEntity::save(tag);
- if (getRecord() != NULL)
+ if (getRecord() != nullptr)
{
tag->putCompound(L"RecordItem", getRecord()->save(new CompoundTag()));
@@ -42,7 +42,7 @@ void JukeboxTile::Entity::save(CompoundTag *tag)
// 4J Added
shared_ptr<TileEntity> JukeboxTile::Entity::clone()
{
- shared_ptr<JukeboxTile::Entity> result = shared_ptr<JukeboxTile::Entity>( new JukeboxTile::Entity() );
+ shared_ptr<JukeboxTile::Entity> result = std::make_shared<JukeboxTile::Entity>();
TileEntity::clone(result);
result->record = record;
@@ -63,7 +63,7 @@ void JukeboxTile::Entity::setRecord(shared_ptr<ItemInstance> record)
JukeboxTile::JukeboxTile(int id) : BaseEntityTile(id, Material::wood)
{
- iconTop = NULL;
+ iconTop = nullptr;
}
Icon *JukeboxTile::getTexture(int face, int data)
@@ -107,10 +107,10 @@ void JukeboxTile::dropRecording(Level *level, int x, int y, int z)
if (level->isClientSide) return;
shared_ptr<JukeboxTile::Entity> rte = dynamic_pointer_cast<JukeboxTile::Entity>( level->getTileEntity(x, y, z) );
- if( rte == NULL ) return;
+ if( rte == nullptr ) return;
shared_ptr<ItemInstance> oldRecord = rte->getRecord();
- if (oldRecord == NULL) return;
+ if (oldRecord == nullptr) return;
level->levelEvent(LevelEvent::SOUND_PLAY_RECORDING, x, y, z, 0);
@@ -127,7 +127,7 @@ void JukeboxTile::dropRecording(Level *level, int x, int y, int z)
shared_ptr<ItemInstance> itemInstance = oldRecord->copy();
- shared_ptr<ItemEntity> item = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) );
+ shared_ptr<ItemEntity> item = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, itemInstance);
item->throwTime = 10;
level->addEntity(item);
}
@@ -146,7 +146,7 @@ void JukeboxTile::spawnResources(Level *level, int x, int y, int z, int data, fl
shared_ptr<TileEntity> JukeboxTile::newTileEntity(Level *level)
{
- return shared_ptr<JukeboxTile::Entity>( new JukeboxTile::Entity() );
+ return std::make_shared<JukeboxTile::Entity>();
}
void JukeboxTile::registerIcons(IconRegister *iconRegister)
@@ -163,5 +163,5 @@ bool JukeboxTile::hasAnalogOutputSignal()
int JukeboxTile::getAnalogOutputSignal(Level *level, int x, int y, int z, int dir)
{
shared_ptr<ItemInstance> record = dynamic_pointer_cast<JukeboxTile::Entity>( level->getTileEntity(x, y, z))->getRecord();
- return record == NULL ? Redstone::SIGNAL_NONE : record->id + 1 - Item::record_01_Id;
+ return record == nullptr ? Redstone::SIGNAL_NONE : record->id + 1 - Item::record_01_Id;
} \ No newline at end of file
diff --git a/Minecraft.World/KeepAlivePacket.h b/Minecraft.World/KeepAlivePacket.h
index a44d8745..bbf7b0ab 100644
--- a/Minecraft.World/KeepAlivePacket.h
+++ b/Minecraft.World/KeepAlivePacket.h
@@ -20,6 +20,6 @@ public:
virtual bool isAync();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new KeepAlivePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<KeepAlivePacket>(); }
virtual int getId() { return 0; }
}; \ No newline at end of file
diff --git a/Minecraft.World/KickPlayerPacket.h b/Minecraft.World/KickPlayerPacket.h
index b9a6ce3e..67fc66fd 100644
--- a/Minecraft.World/KickPlayerPacket.h
+++ b/Minecraft.World/KickPlayerPacket.h
@@ -17,6 +17,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new KickPlayerPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<KickPlayerPacket>(); }
virtual int getId() { return 159; }
}; \ No newline at end of file
diff --git a/Minecraft.World/LakeFeature.cpp b/Minecraft.World/LakeFeature.cpp
index ac240e61..a25a7ece 100644
--- a/Minecraft.World/LakeFeature.cpp
+++ b/Minecraft.World/LakeFeature.cpp
@@ -24,8 +24,8 @@ bool LakeFeature::place(Level *level, Random *random, int x, int y, int z)
bool grid[16*16*8] = {0};
- LevelGenerationOptions *levelGenOptions = NULL;
- if( app.getLevelGenerationOptions() != NULL )
+ LevelGenerationOptions *levelGenOptions = nullptr;
+ if( app.getLevelGenerationOptions() != nullptr )
{
levelGenOptions = app.getLevelGenerationOptions();
diff --git a/Minecraft.World/LargeCaveFeature.cpp b/Minecraft.World/LargeCaveFeature.cpp
index 5ca539d5..c70f1156 100644
--- a/Minecraft.World/LargeCaveFeature.cpp
+++ b/Minecraft.World/LargeCaveFeature.cpp
@@ -144,11 +144,11 @@ void LargeCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, byteArray b
{
if (yy < 10)
{
- blocks[p] = (byte) Tile::lava_Id;
+ blocks[p] = static_cast<byte>(Tile::lava_Id);
}
else
{
- blocks[p] = (byte) 0;
+ blocks[p] = static_cast<byte>(0);
if (hasGrass && blocks[p - 1] == Tile::dirt_Id) blocks[p - 1] = (byte) level->getBiome(xx + xOffs * 16, zz + zOffs * 16)->topMaterial;
}
}
diff --git a/Minecraft.World/LargeFireball.cpp b/Minecraft.World/LargeFireball.cpp
index 9f8da92c..48f199d9 100644
--- a/Minecraft.World/LargeFireball.cpp
+++ b/Minecraft.World/LargeFireball.cpp
@@ -23,7 +23,7 @@ void LargeFireball::onHit(HitResult *res)
{
if (!level->isClientSide)
{
- if (res->entity != NULL)
+ if (res->entity != nullptr)
{
DamageSource *damageSource = DamageSource::fireball(dynamic_pointer_cast<Fireball>( shared_from_this() ), owner);
res->entity->hurt(damageSource, 6);
diff --git a/Minecraft.World/LargeHellCaveFeature.cpp b/Minecraft.World/LargeHellCaveFeature.cpp
index 6aa1aec5..9472c855 100644
--- a/Minecraft.World/LargeHellCaveFeature.cpp
+++ b/Minecraft.World/LargeHellCaveFeature.cpp
@@ -138,7 +138,7 @@ void LargeHellCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, byteArr
int block = blocks[p];
if (block == Tile::netherRack_Id || block == Tile::dirt_Id || block == Tile::grass_Id)
{
- blocks[p] = (byte) 0;
+ blocks[p] = static_cast<byte>(0);
}
}
p--;
diff --git a/Minecraft.World/LavaSlime.cpp b/Minecraft.World/LavaSlime.cpp
index 21982995..f60baf09 100644
--- a/Minecraft.World/LavaSlime.cpp
+++ b/Minecraft.World/LavaSlime.cpp
@@ -55,7 +55,7 @@ ePARTICLE_TYPE LavaSlime::getParticleName()
shared_ptr<Slime> LavaSlime::createChild()
{
- return shared_ptr<LavaSlime>( new LavaSlime(level) );
+ return std::make_shared<LavaSlime>(level);
}
int LavaSlime::getDeathLoot()
diff --git a/Minecraft.World/Layer.cpp b/Minecraft.World/Layer.cpp
index f90f1fa8..a0eda52f 100644
--- a/Minecraft.World/Layer.cpp
+++ b/Minecraft.World/Layer.cpp
@@ -21,16 +21,16 @@ LayerArray Layer::getDefaultLayers(int64_t seed, LevelType *levelType)
// 4J - Some changes moved here from 1.2.3. Temperature & downfall layers are no longer created & returned, and a debug layer is isn't.
// For reference with regard to future merging, things NOT brought forward from the 1.2.3 version are new layer types that we
// don't have yet (shores, swamprivers, region hills etc.)
- shared_ptr<Layer>islandLayer = shared_ptr<Layer>(new IslandLayer(1));
- islandLayer = shared_ptr<Layer>(new FuzzyZoomLayer(2000, islandLayer));
- islandLayer = shared_ptr<Layer>(new AddIslandLayer(1, islandLayer));
- islandLayer = shared_ptr<Layer>(new ZoomLayer(2001, islandLayer));
- islandLayer = shared_ptr<Layer>(new AddIslandLayer(2, islandLayer));
- islandLayer = shared_ptr<Layer>(new AddSnowLayer(2, islandLayer));
- islandLayer = shared_ptr<Layer>(new ZoomLayer(2002, islandLayer));
- islandLayer = shared_ptr<Layer>(new AddIslandLayer(3, islandLayer));
- islandLayer = shared_ptr<Layer>(new ZoomLayer(2003, islandLayer));
- islandLayer = shared_ptr<Layer>(new AddIslandLayer(4, islandLayer));
+ shared_ptr<Layer>islandLayer = std::make_shared<IslandLayer>(1);
+ islandLayer = std::make_shared<FuzzyZoomLayer>(2000, islandLayer);
+ islandLayer = std::make_shared<AddIslandLayer>(1, islandLayer);
+ islandLayer = std::make_shared<ZoomLayer>(2001, islandLayer);
+ islandLayer = std::make_shared<AddIslandLayer>(2, islandLayer);
+ islandLayer = std::make_shared<AddSnowLayer>(2, islandLayer);
+ islandLayer = std::make_shared<ZoomLayer>(2002, islandLayer);
+ islandLayer = std::make_shared<AddIslandLayer>(3, islandLayer);
+ islandLayer = std::make_shared<ZoomLayer>(2003, islandLayer);
+ islandLayer = std::make_shared<AddIslandLayer>(4, islandLayer);
// islandLayer = shared_ptr<Layer>(new AddMushroomIslandLayer(5, islandLayer)); // 4J - old position of mushroom island layer
int zoomLevel = 4;
@@ -41,30 +41,30 @@ LayerArray Layer::getDefaultLayers(int64_t seed, LevelType *levelType)
shared_ptr<Layer> riverLayer = islandLayer;
riverLayer = ZoomLayer::zoom(1000, riverLayer, 0);
- riverLayer = shared_ptr<Layer>(new RiverInitLayer(100, riverLayer));
+ riverLayer = std::make_shared<RiverInitLayer>(100, riverLayer);
riverLayer = ZoomLayer::zoom(1000, riverLayer, zoomLevel + 2);
- riverLayer = shared_ptr<Layer>(new RiverLayer(1, riverLayer));
- riverLayer = shared_ptr<Layer>(new SmoothLayer(1000, riverLayer));
+ riverLayer = std::make_shared<RiverLayer>(1, riverLayer);
+ riverLayer = std::make_shared<SmoothLayer>(1000, riverLayer);
shared_ptr<Layer> biomeLayer = islandLayer;
biomeLayer = ZoomLayer::zoom(1000, biomeLayer, 0);
- biomeLayer = shared_ptr<Layer>(new BiomeInitLayer(200, biomeLayer, levelType));
+ biomeLayer = std::make_shared<BiomeInitLayer>(200, biomeLayer, levelType);
biomeLayer = ZoomLayer::zoom(1000, biomeLayer, 2);
- biomeLayer = shared_ptr<Layer>(new RegionHillsLayer(1000, biomeLayer));
+ biomeLayer = std::make_shared<RegionHillsLayer>(1000, biomeLayer);
for (int i = 0; i < zoomLevel; i++)
{
- biomeLayer = shared_ptr<Layer>(new ZoomLayer(1000 + i, biomeLayer));
+ biomeLayer = std::make_shared<ZoomLayer>(1000 + i, biomeLayer);
- if (i == 0) biomeLayer = shared_ptr<Layer>(new AddIslandLayer(3, biomeLayer));
+ if (i == 0) biomeLayer = std::make_shared<AddIslandLayer>(3, biomeLayer);
if (i == 0)
{
// 4J - moved mushroom islands to here. This skips 3 zooms that the old location of the add was, making them about 1/8 of the original size. Adding
// them at this scale actually lets us place them near enough other land, if we add them at the same scale as java then they have to be too far out to see for
// the scale of our maps
- biomeLayer = shared_ptr<Layer>(new AddMushroomIslandLayer(5, biomeLayer));
+ biomeLayer = std::make_shared<AddMushroomIslandLayer>(5, biomeLayer);
}
if (i == 1 )
@@ -72,30 +72,30 @@ LayerArray Layer::getDefaultLayers(int64_t seed, LevelType *levelType)
// 4J - now expand mushroom islands up again. This does a simple region grow to add a new mushroom island element when any of the neighbours are also mushroom islands.
// This helps make the islands into nice compact shapes of the type that are actually likely to be able to make an island out of the sea in a small space. Also
// helps the shore layer from doing too much damage in shrinking the islands we are making
- biomeLayer = shared_ptr<Layer>(new GrowMushroomIslandLayer(5, biomeLayer));
+ biomeLayer = std::make_shared<GrowMushroomIslandLayer>(5, biomeLayer);
// Note - this reduces the size of mushroom islands by turning their edges into shores. We are doing this at i == 1 rather than i == 0 as the original does
- biomeLayer = shared_ptr<Layer>(new ShoreLayer(1000, biomeLayer));
+ biomeLayer = std::make_shared<ShoreLayer>(1000, biomeLayer);
- biomeLayer = shared_ptr<Layer>(new SwampRiversLayer(1000, biomeLayer));
+ biomeLayer = std::make_shared<SwampRiversLayer>(1000, biomeLayer);
}
}
- biomeLayer = shared_ptr<Layer>(new SmoothLayer(1000, biomeLayer));
+ biomeLayer = std::make_shared<SmoothLayer>(1000, biomeLayer);
- biomeLayer = shared_ptr<Layer>(new RiverMixerLayer(100, biomeLayer, riverLayer));
+ biomeLayer = std::make_shared<RiverMixerLayer>(100, biomeLayer, riverLayer);
#ifndef _CONTENT_PACKAGE
#ifdef _BIOME_OVERRIDE
if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_EnableBiomeOverride))
{
- biomeLayer = shared_ptr<BiomeOverrideLayer>(new BiomeOverrideLayer(1));
+ biomeLayer = std::make_shared<BiomeOverrideLayer>(1);
}
#endif
#endif
shared_ptr<Layer> debugLayer = biomeLayer;
- shared_ptr<Layer>zoomedLayer = shared_ptr<Layer>(new VoronoiZoom(10, biomeLayer));
+ shared_ptr<Layer>zoomedLayer = std::make_shared<VoronoiZoom>(10, biomeLayer);
biomeLayer->init(seed);
zoomedLayer->init(seed);
@@ -123,7 +123,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);
this->seed *= this->seed * 6364136223846793005l + 1442695040888963407l;
this->seed += seedMixup;
this->seed *= this->seed * 6364136223846793005l + 1442695040888963407l;
@@ -189,7 +189,7 @@ int Layer::nextRandom(int max)
}
#else
- int result = (int) ((rval >> 24) % max);
+ int result = static_cast<int>((rval >> 24) % max);
#endif
if (result < 0) result += max;
diff --git a/Minecraft.World/LeafTile.cpp b/Minecraft.World/LeafTile.cpp
index 684618a7..f8f5deae 100644
--- a/Minecraft.World/LeafTile.cpp
+++ b/Minecraft.World/LeafTile.cpp
@@ -17,7 +17,7 @@ const wstring LeafTile::TEXTURES[2][4] = { {L"leaves", L"leaves_spruce", L"leave
LeafTile::LeafTile(int id) : TransparentTile(id, Material::leaves, false, isSolidRender())
{
- checkBuffer = NULL;
+ checkBuffer = nullptr;
fancyTextureSet = 0;
setTicking(true);
}
@@ -123,7 +123,7 @@ void LeafTile::tick(Level *level, int x, int y, int z, Random *random)
int W = 32;
int WW = W * W;
int WO = W / 2;
- if (checkBuffer == NULL)
+ if (checkBuffer == nullptr)
{
checkBuffer = new int[W * W * W];
}
@@ -249,7 +249,7 @@ void LeafTile::spawnResources(Level *level, int x, int y, int z, int data, float
if (level->random->nextInt(chance) == 0)
{
int type = getResource(data, level->random,playerBonusLevel);
- popResource(level, x, y, z, shared_ptr<ItemInstance>( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data))));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(type, 1, getSpawnResourcesAuxValue(data)));
}
chance = 200;
@@ -263,14 +263,14 @@ void LeafTile::spawnResources(Level *level, int x, int y, int z, int data, float
}
if ((data & LEAF_TYPE_MASK) == NORMAL_LEAF && level->random->nextInt(chance) == 0)
{
- popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Item::apple_Id, 1, 0)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(Item::apple_Id, 1, 0));
}
}
}
void LeafTile::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y, int z, int data)
{
- if (!level->isClientSide && player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears->id)
+ if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id)
{
player->awardStat(
GenericStats::blocksMined(id),
@@ -278,7 +278,7 @@ void LeafTile::playerDestroy(Level *level, shared_ptr<Player> player, int x, int
);
// drop leaf block instead of sapling
- popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Tile::leaves_Id, 1, data & LEAF_TYPE_MASK)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(Tile::leaves_Id, 1, data & LEAF_TYPE_MASK));
}
else
{
@@ -324,7 +324,7 @@ void LeafTile::setFancy(bool fancyGraphics)
shared_ptr<ItemInstance> LeafTile::getSilkTouchItemInstance(int data)
{
- return shared_ptr<ItemInstance>( new ItemInstance(id, 1, data & LEAF_TYPE_MASK) );
+ return std::make_shared<ItemInstance>(id, 1, data & LEAF_TYPE_MASK);
}
void LeafTile::stepOn(Level *level, int x, int y, int z, shared_ptr<Entity> entity)
diff --git a/Minecraft.World/LeapAtTargetGoal.cpp b/Minecraft.World/LeapAtTargetGoal.cpp
index 6aebc9a8..b559ef7d 100644
--- a/Minecraft.World/LeapAtTargetGoal.cpp
+++ b/Minecraft.World/LeapAtTargetGoal.cpp
@@ -15,7 +15,7 @@ LeapAtTargetGoal::LeapAtTargetGoal(Mob *mob, float yd)
bool LeapAtTargetGoal::canUse()
{
target = weak_ptr<LivingEntity>(mob->getTarget());
- if (target.lock() == NULL) return false;
+ if (target.lock() == nullptr) return false;
double d = mob->distanceToSqr(target.lock());
if (d < 2 * 2 || d > 4 * 4) return false;
if (!mob->onGround) return false;
@@ -25,7 +25,7 @@ bool LeapAtTargetGoal::canUse()
bool LeapAtTargetGoal::canContinueToUse()
{
- return target.lock() != NULL && !mob->onGround;
+ return target.lock() != nullptr && !mob->onGround;
}
void LeapAtTargetGoal::start()
diff --git a/Minecraft.World/LeashFenceKnotEntity.cpp b/Minecraft.World/LeashFenceKnotEntity.cpp
index 55947d04..f94bcba7 100644
--- a/Minecraft.World/LeashFenceKnotEntity.cpp
+++ b/Minecraft.World/LeashFenceKnotEntity.cpp
@@ -70,14 +70,14 @@ bool LeashFenceKnotEntity::interact(shared_ptr<Player> player)
shared_ptr<ItemInstance> item = player->getCarriedItem();
bool attachedMob = false;
- if (item != NULL && item->id == Item::lead_Id)
+ if (item != nullptr && item->id == Item::lead_Id)
{
if (!level->isClientSide)
{
// look for entities that can be attached to the fence
double range = 7;
vector<shared_ptr<Entity> > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range));
- if (mobs != NULL)
+ if (mobs != nullptr)
{
for(auto& it : *mobs)
{
@@ -101,7 +101,7 @@ bool LeashFenceKnotEntity::interact(shared_ptr<Player> player)
// if the player is in creative mode, attempt to remove all leashed mobs without dropping additional items
double range = 7;
vector<shared_ptr<Entity> > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range));
- if (mobs != NULL)
+ if (mobs != nullptr)
{
for(auto& it : *mobs)
{
@@ -122,7 +122,7 @@ bool LeashFenceKnotEntity::survives()
{
// knots are placed on top of fence tiles
int tile = level->getTile(xTile, yTile, zTile);
- if (Tile::tiles[tile] != NULL && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE)
+ if (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE)
{
return true;
}
@@ -131,7 +131,7 @@ bool LeashFenceKnotEntity::survives()
shared_ptr<LeashFenceKnotEntity> LeashFenceKnotEntity::createAndAddKnot(Level *level, int x, int y, int z)
{
- shared_ptr<LeashFenceKnotEntity> knot = shared_ptr<LeashFenceKnotEntity>( new LeashFenceKnotEntity(level, x, y, z) );
+ shared_ptr<LeashFenceKnotEntity> knot = std::make_shared<LeashFenceKnotEntity>(level, x, y, z);
knot->forcedLoading = true;
level->addEntity(knot);
return knot;
@@ -140,7 +140,7 @@ shared_ptr<LeashFenceKnotEntity> LeashFenceKnotEntity::createAndAddKnot(Level *l
shared_ptr<LeashFenceKnotEntity> LeashFenceKnotEntity::findKnotAt(Level *level, int x, int y, int z)
{
vector<shared_ptr<Entity> > *knots = level->getEntitiesOfClass(typeid(LeashFenceKnotEntity), AABB::newTemp(x - 1.0, y - 1.0, z - 1.0, x + 1.0, y + 1.0, z + 1.0));
- if (knots != NULL)
+ if (knots != nullptr)
{
for (auto& it : *knots )
{
diff --git a/Minecraft.World/LeashItem.cpp b/Minecraft.World/LeashItem.cpp
index ddb7878b..4de74a5c 100644
--- a/Minecraft.World/LeashItem.cpp
+++ b/Minecraft.World/LeashItem.cpp
@@ -12,7 +12,7 @@ LeashItem::LeashItem(int id) : Item(id)
bool LeashItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly)
{
int tile = level->getTile(x, y, z);
- if (Tile::tiles[tile] != NULL && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE)
+ if (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE)
{
if (bTestUseOnOnly) return bindPlayerMobsTest(player, level, x,y,z);
@@ -36,14 +36,14 @@ bool LeashItem::bindPlayerMobs(shared_ptr<Player> player, Level *level, int x, i
bool foundMobs = false;
double range = 7;
vector<shared_ptr<Entity> > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range));
- if (mobs != NULL)
+ if (mobs != nullptr)
{
for(auto& it : *mobs)
{
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(it);
if (mob->isLeashed() && mob->getLeashHolder() == player)
{
- if (activeKnot == NULL)
+ if (activeKnot == nullptr)
{
activeKnot = LeashFenceKnotEntity::createAndAddKnot(level, x, y, z);
}
@@ -62,7 +62,7 @@ bool LeashItem::bindPlayerMobsTest(shared_ptr<Player> player, Level *level, int
double range = 7;
vector<shared_ptr<Entity> > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range));
- if (mobs != NULL)
+ if (mobs != nullptr)
{
for(auto& it : *mobs)
{
diff --git a/Minecraft.World/Level.cpp b/Minecraft.World/Level.cpp
index 7e7ed685..161f4e56 100644
--- a/Minecraft.World/Level.cpp
+++ b/Minecraft.World/Level.cpp
@@ -91,13 +91,13 @@ DWORD Level::tlsIdxLightCache = TlsAlloc();
void Level::enableLightingCache()
{
// Allocate 16K (needs 32K for large worlds) for a 16x16x16x4 byte cache of results, plus 128K required for toCheck array. Rounding up to 256 to keep as multiple of alignement - aligning to 128K boundary for possible cache locking.
- void *cache = (unsigned char *)XPhysicalAlloc(256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES);
+ void *cache = static_cast<unsigned char *>(XPhysicalAlloc(256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES));
TlsSetValue(tlsIdxLightCache,cache);
}
void Level::destroyLightingCache()
{
- lightCache_t *cache = (lightCache_t *)TlsGetValue(tlsIdxLightCache);
+ lightCache_t *cache = static_cast<lightCache_t *>(TlsGetValue(tlsIdxLightCache));
XPhysicalFree(cache);
}
@@ -109,7 +109,7 @@ inline int GetIndex(int x, int y, int z)
void Level::initCachePartial(lightCache_t *cache, int xc, int yc, int zc)
{
cachewritten = false;
- if( cache == NULL ) return;
+ if( cache == nullptr ) return;
int idx;
if( !(yc & 0xffffff00) )
@@ -180,7 +180,7 @@ void Level::initCacheComplete(lightCache_t *cache, int xc, int yc, int zc)
// Set a brightness value, going through the cache if enabled for this thread
void inline Level::setBrightnessCached(lightCache_t *cache, uint64_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;
@@ -195,8 +195,8 @@ void inline Level::setBrightnessCached(lightCache_t *cache, uint64_t *cacheUse,
( ( z & 0x3f0 ) >> 4 );
#ifdef _LARGE_WORLDS
// Add in the higher bits for x and z
- posbits |= ( ( ((uint64_t)x) & 0x3FFFC00L) << 38) |
- ( ( ((uint64_t)z) & 0x3FFFC00L) << 22);
+ posbits |= ( ( static_cast<uint64_t>(x) & 0x3FFFC00L) << 38) |
+ ( ( static_cast<uint64_t>(z) & 0x3FFFC00L) << 22);
#endif
lightCache_t cacheValue = cache[idx];
@@ -243,7 +243,7 @@ void inline Level::setBrightnessCached(lightCache_t *cache, uint64_t *cacheUse,
// Get a brightness value, going through the cache if enabled for this thread
inline int Level::getBrightnessCached(lightCache_t *cache, LightLayer::variety layer, int x, int y, int z)
{
- if( cache == NULL ) return getBrightness(layer, x, y, z);
+ if( cache == nullptr ) return getBrightness(layer, x, y, z);
if( y & 0xffffff00 ) return getBrightness(layer, x, y, z); // Fall back on original method for out-of-bounds y
int idx = ( ( x & 15 ) << 8 ) |
@@ -253,9 +253,8 @@ inline int Level::getBrightnessCached(lightCache_t *cache, LightLayer::variety l
( ( y & 0x0f0 ) << 2 ) |
( ( z & 0x3f0 ) >> 4 );
#ifdef _LARGE_WORLDS
- // Add in the higher bits for x and z
- posbits |= ( ( ((uint64_t)x) & 0x3FFFC00L) << 38) |
- ( ( ((uint64_t)z) & 0x3FFFC00L) << 22);
+ posbits |= ( ( static_cast<uint64_t>(x) & 0x3FFFC00L) << 38) |
+ ( ( static_cast<uint64_t>(z) & 0x3FFFC00L) << 22);
#endif
lightCache_t cacheValue = cache[idx];
@@ -311,7 +310,7 @@ inline int Level::getBrightnessCached(lightCache_t *cache, LightLayer::variety l
// Get a block emission value, going through the cache if enabled for this thread
inline int Level::getEmissionCached(lightCache_t *cache, int ct, int x, int y, int z)
{
- if( cache == NULL ) return Tile::lightEmission[ct];
+ if( cache == nullptr ) return Tile::lightEmission[ct];
int idx = ( ( x & 15 ) << 8 ) |
( ( y & 15 ) << 4 ) |
@@ -321,8 +320,8 @@ inline int Level::getEmissionCached(lightCache_t *cache, int ct, int x, int y, i
( ( z & 0x3f0 ) >> 4 );
#ifdef _LARGE_WORLDS
// Add in the higher bits for x and z
- posbits |= ( ( ((uint64_t)x) & 0x3FFFC00) << 38) |
- ( ( ((uint64_t)z) & 0x3FFFC00) << 22);
+ posbits |= ( ( static_cast<uint64_t>(x) & 0x3FFFC00) << 38) |
+ ( ( static_cast<uint64_t>(z) & 0x3FFFC00) << 22);
#endif
lightCache_t cacheValue = cache[idx];
@@ -382,7 +381,7 @@ inline int Level::getEmissionCached(lightCache_t *cache, int ct, int x, int y, i
// Get a tile light blocking value, going through cache if enabled for this thread
inline int Level::getBlockingCached(lightCache_t *cache, LightLayer::variety layer, int *ct, int x, int y, int z)
{
- if( cache == NULL )
+ if( cache == nullptr )
{
int t = getTile(x,y,z);
if(ct) *ct = t;
@@ -397,8 +396,8 @@ inline int Level::getBlockingCached(lightCache_t *cache, LightLayer::variety lay
( ( z & 0x3f0 ) >> 4 );
#ifdef _LARGE_WORLDS
// Add in the higher bits for x and z
- posbits |= ( ( ((uint64_t)x) & 0x3FFFC00L) << 38) |
- ( ( ((uint64_t)z) & 0x3FFFC00L) << 22);
+ posbits |= ( ( static_cast<uint64_t>(x) & 0x3FFFC00L) << 38) |
+ ( ( static_cast<uint64_t>(z) & 0x3FFFC00L) << 22);
#endif
lightCache_t cacheValue = cache[idx];
@@ -561,17 +560,17 @@ void Level::_init()
random = new Random();
isNew = false;
- dimension = NULL;
+ dimension = nullptr;
- chunkSource = NULL;
+ chunkSource = nullptr;
levelStorage = nullptr;
- levelData = NULL;
+ levelData = nullptr;
isFindingSpawn = false;
- savedDataStorage = NULL;
+ savedDataStorage = nullptr;
spawnEnemies = true;
@@ -604,9 +603,9 @@ Biome *Level::getBiome(int x, int z)
if (hasChunkAt(x, 0, z))
{
LevelChunk *lc = getChunkAt(x, z);
- if (lc != NULL)
+ if (lc != nullptr)
{
- // Water chunks at the edge of the world return NULL for their biome as they can't store it, so should fall back on the normal method below
+ // Water chunks at the edge of the world return nullptr for their biome as they can't store it, so should fall back on the normal method below
Biome *biome = lc->getBiome(x & 0xf, z & 0xf, dimension->biomeSource);
if( biome ) return biome;
}
@@ -630,9 +629,9 @@ Level::Level(shared_ptr<LevelStorage> levelStorage, const wstring& name, Dimensi
savedDataStorage = new SavedDataStorage(levelStorage.get());
shared_ptr<Villages> savedVillages = dynamic_pointer_cast<Villages>(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID));
- if (savedVillages == NULL)
+ if (savedVillages == nullptr)
{
- villages = shared_ptr<Villages>(new Villages(this));
+ villages = std::make_shared<Villages>(this);
savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages);
}
else
@@ -642,7 +641,7 @@ Level::Level(shared_ptr<LevelStorage> levelStorage, const wstring& name, Dimensi
}
dimension->init(this);
- chunkSource = NULL; // 4J - added flag so chunk source can be called from derived class instead
+ chunkSource = nullptr; // 4J - added flag so chunk source can be called from derived class instead
updateSkyBrightness();
prepareWeather();
@@ -651,7 +650,7 @@ Level::Level(shared_ptr<LevelStorage> levelStorage, const wstring& name, Dimensi
Level::Level(shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings)
: seaLevel( constSeaLevel )
{
- _init(levelStorage, levelName, levelSettings, NULL, true);
+ _init(levelStorage, levelName, levelSettings, nullptr, true);
}
@@ -668,9 +667,9 @@ void Level::_init(shared_ptr<LevelStorage>levelStorage, const wstring& levelName
savedDataStorage = new SavedDataStorage(levelStorage.get());
shared_ptr<Villages> savedVillages = dynamic_pointer_cast<Villages>(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID));
- if (savedVillages == NULL)
+ if (savedVillages == nullptr)
{
- villages = shared_ptr<Villages>(new Villages(this));
+ villages = std::make_shared<Villages>(this);
savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages);
}
else
@@ -680,14 +679,14 @@ void Level::_init(shared_ptr<LevelStorage>levelStorage, const wstring& levelName
}
levelData = levelStorage->prepareLevel();
- isNew = levelData == NULL;
+ isNew = levelData == nullptr;
- if (fixedDimension != NULL)
+ if (fixedDimension != nullptr)
{
dimension = fixedDimension;
}
// 4J Remove TU9 as getDimensions was never accurate. This path was never used anyway as we always set fixedDimension
- //else if (levelData != NULL && levelData->getDimension() != 0)
+ //else if (levelData != nullptr && levelData->getDimension() != 0)
//{
// dimension = Dimension::getNew(levelData->getDimension());
//}
@@ -696,7 +695,7 @@ void Level::_init(shared_ptr<LevelStorage>levelStorage, const wstring& levelName
dimension = Dimension::getNew(0);
}
- if (levelData == NULL)
+ if (levelData == nullptr)
{
levelData = new LevelData(levelSettings, levelName);
}
@@ -708,7 +707,7 @@ void Level::_init(shared_ptr<LevelStorage>levelStorage, const wstring& levelName
((Dimension *) dimension)->init( this );
- chunkSource = doCreateChunkSource ? createChunkSource() : NULL; // 4J - added flag so chunk source can be called from derived class instead
+ chunkSource = doCreateChunkSource ? createChunkSource() : nullptr; // 4J - added flag so chunk source can be called from derived class instead
// 4J Stu- Moved to derived classes
//if (!levelData->isInitialized())
@@ -740,7 +739,7 @@ Level::~Level()
DeleteCriticalSection(&m_checkLightCS);
// 4J-PB - savedDataStorage is shared between overworld and nether levels in the server, so it will already have been deleted on the first level delete
- if(savedDataStorage!=NULL) delete savedDataStorage;
+ if(savedDataStorage!=nullptr) delete savedDataStorage;
DeleteCriticalSection(&m_entitiesCS);
DeleteCriticalSection(&m_tileEntityListCS);
@@ -807,7 +806,7 @@ bool Level::isEmptyTile(int x, int y, int z)
bool Level::isEntityTile(int x, int y, int z)
{
int t = getTile(x, y, z);
- if (Tile::tiles[t] != NULL && Tile::tiles[t]->isEntityTile())
+ if (Tile::tiles[t] != nullptr && Tile::tiles[t]->isEntityTile())
{
return true;
}
@@ -817,7 +816,7 @@ bool Level::isEntityTile(int x, int y, int z)
int Level::getTileRenderShape(int x, int y, int z)
{
int t = getTile(x, y, z);
- if (Tile::tiles[t] != NULL)
+ if (Tile::tiles[t] != nullptr)
{
return Tile::tiles[t]->getRenderShape();
}
@@ -827,7 +826,7 @@ int Level::getTileRenderShape(int x, int y, int z)
// 4J Added to slightly optimise and avoid getTile call if we already know the tile
int Level::getTileRenderShape(int t)
{
- if (Tile::tiles[t] != NULL)
+ if (Tile::tiles[t] != nullptr)
{
return Tile::tiles[t]->getRenderShape();
}
@@ -954,7 +953,7 @@ bool Level::setTileAndData(int x, int y, int z, int tile, int data, int updateFl
{
tileUpdated(x, y, z, oldTile);
Tile *tobj = Tile::tiles[tile];
- if (tobj != NULL && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile);
+ if (tobj != nullptr && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile);
}
}
return result;
@@ -1011,7 +1010,7 @@ bool Level::setData(int x, int y, int z, int data, int updateFlags, bool forceUp
{
tileUpdated(x, y, z, tile);
Tile *tobj = Tile::tiles[tile];
- if (tobj != NULL && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile);
+ if (tobj != nullptr && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile);
}
}
return result;
@@ -1145,7 +1144,7 @@ void Level::neighborChanged(int x, int y, int z, int type)
int id = getTile(x, y, z);
Tile *tile = Tile::tiles[id];
- if (tile != NULL)
+ if (tile != nullptr)
{
tile->neighborChanged(this, x, y, z, type);
}
@@ -1336,7 +1335,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;
@@ -1377,7 +1376,7 @@ void Level::getNeighbourBrightnesses(int *brightnesses, LightLayer::variety laye
{
for( int i = 0; i < 6; i++ )
{
- brightnesses[i] = (int)layer;
+ brightnesses[i] = static_cast<int>(layer);
}
return;
}
@@ -1388,11 +1387,11 @@ void Level::getNeighbourBrightnesses(int *brightnesses, LightLayer::variety laye
// 4J Stu - The java LightLayer was an enum class type with a member "surrounding" which is what we
// were returning here. Surrounding has the same value as the enum value in our C++ code, so just cast
// it to an int
- if( c == NULL )
+ if( c == nullptr )
{
for( int i = 0; i < 6; i++ )
{
- brightnesses[i] = (int)layer;
+ brightnesses[i] = static_cast<int>(layer);
}
return;
}
@@ -1497,8 +1496,8 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid)
HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly)
{
- if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z)) return NULL;
- if (Double::isNaN(b->x) || Double::isNaN(b->y) || Double::isNaN(b->z)) return NULL;
+ if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z)) return nullptr;
+ if (Double::isNaN(b->x) || Double::isNaN(b->y) || Double::isNaN(b->z)) return nullptr;
int xTile1 = Mth::floor(b->x);
int yTile1 = Mth::floor(b->y);
@@ -1512,7 +1511,7 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly)
int t = getTile(xTile0, yTile0, zTile0);
int data = getData(xTile0, yTile0, zTile0);
Tile *tile = Tile::tiles[t];
- if (solidOnly && tile != NULL && tile->getAABB(this, xTile0, yTile0, zTile0) == NULL)
+ if (solidOnly && tile != nullptr && tile->getAABB(this, xTile0, yTile0, zTile0) == nullptr)
{
// No collision
@@ -1520,15 +1519,15 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly)
else if (t > 0 && tile->mayPick(data, liquid))
{
HitResult *r = tile->clip(this, xTile0, yTile0, zTile0, a, b);
- if (r != NULL) return r;
+ if (r != nullptr) return r;
}
}
int maxIterations = 200;
while (maxIterations-- >= 0)
{
- if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z)) return NULL;
- if (xTile0 == xTile1 && yTile0 == yTile1 && zTile0 == zTile1) return NULL;
+ if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z)) return nullptr;
+ if (xTile0 == xTile1 && yTile0 == yTile1 && zTile0 == zTile1) return nullptr;
bool xClipped = true;
bool yClipped = true;
@@ -1592,19 +1591,19 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly)
}
Vec3 *tPos = Vec3::newTemp(a->x, a->y, a->z);
- xTile0 = (int) (tPos->x = floor(a->x));
+ xTile0 = static_cast<int>(tPos->x = floor(a->x));
if (face == 5)
{
xTile0--;
tPos->x++;
}
- yTile0 = (int) (tPos->y = floor(a->y));
+ yTile0 = static_cast<int>(tPos->y = floor(a->y));
if (face == 1)
{
yTile0--;
tPos->y++;
}
- zTile0 = (int) (tPos->z = floor(a->z));
+ zTile0 = static_cast<int>(tPos->z = floor(a->z));
if (face == 3)
{
zTile0--;
@@ -1614,7 +1613,7 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly)
int t = getTile(xTile0, yTile0, zTile0);
int data = getData(xTile0, yTile0, zTile0);
Tile *tile = Tile::tiles[t];
- if (solidOnly && tile != NULL && tile->getAABB(this, xTile0, yTile0, zTile0) == NULL)
+ if (solidOnly && tile != nullptr && tile->getAABB(this, xTile0, yTile0, zTile0) == nullptr)
{
// No collision
@@ -1622,16 +1621,16 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly)
else if (t > 0 && tile->mayPick(data, liquid))
{
HitResult *r = tile->clip(this, xTile0, yTile0, zTile0, a, b);
- if (r != NULL) return r;
+ if (r != nullptr) return r;
}
}
- return NULL;
+ return nullptr;
}
void Level::playEntitySound(shared_ptr<Entity> entity, int iSound, float volume, float pitch)
{
- if(entity == NULL) return;
+ if(entity == nullptr) return;
for (auto& listener : listeners)
{
// 4J-PB - if the entity is a local player, don't play the sound
@@ -1650,7 +1649,7 @@ void Level::playEntitySound(shared_ptr<Entity> entity, int iSound, float volume,
void Level::playPlayerSound(shared_ptr<Player> entity, int iSound, float volume, float pitch)
{
- if (entity == NULL) return;
+ if (entity == nullptr) return;
for (auto& listener : listeners)
{
listener->playSoundExceptPlayer(entity, iSound, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch);
@@ -1703,7 +1702,7 @@ bool Level::addEntity(shared_ptr<Entity> e)
int xc = Mth::floor(e->x / 16);
int zc = Mth::floor(e->z / 16);
- if(e == NULL)
+ if(e == nullptr)
{
return false;
}
@@ -1892,7 +1891,7 @@ AABBList *Level::getCubes(shared_ptr<Entity> source, AABB *box, bool noEntities/
for (int y = y0 - 1; y < y1; y++)
{
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile != NULL)
+ if (tile != nullptr)
{
tile->addAABBs(this, x, y, z, box, &boxes, source);
}
@@ -1938,13 +1937,13 @@ AABBList *Level::getCubes(shared_ptr<Entity> source, AABB *box, bool noEntities/
for (auto& it : *ee)
{
AABB *collideBox = it->getCollideBox();
- if (collideBox != NULL && collideBox->intersects(box))
+ if (collideBox != nullptr && collideBox->intersects(box))
{
boxes.push_back(collideBox);
}
collideBox = source->getCollideAgainstBox(it);
- if (collideBox != NULL && collideBox->intersects(box))
+ if (collideBox != nullptr && collideBox->intersects(box))
{
boxes.push_back(collideBox);
}
@@ -1975,7 +1974,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);
// }
@@ -2001,7 +2000,7 @@ int Level::getOldSkyDarken(float a)
br *= 1 - (getRainLevel(a) * 5 / 16.0f);
br *= 1 - (getThunderLevel(a) * 5 / 16.0f);
br = 1 - br;
- return ((int) (br * 11));
+ return static_cast<int>(br * 11);
}
//4J - change brought forward from 1.8.2
@@ -2087,7 +2086,7 @@ float Level::getTimeOfDay(float a)
* getTimeOfDay and changed it before releasing (without
* re-committing)... that should be the only difference // jeb
*/
- /* if (this != NULL) return 0.5f; */
+ /* if (this != nullptr) return 0.5f; */
// 4J Added if so we can override timeOfDay without changing the time that affects ticking of things
return dimension->getTimeOfDay(levelData->getDayTime(), a);;
@@ -2303,7 +2302,7 @@ void Level::tickEntities()
{
shared_ptr<Entity> e = entities.at(i);
- if (e->riding != NULL)
+ if (e->riding != nullptr)
{
if (e->riding->removed || e->riding->rider.lock() != e)
{
@@ -2381,7 +2380,7 @@ void Level::tickEntities()
if (hasChunk(te->x >> 4, te->z >> 4))
{
LevelChunk *lc = getChunk(te->x >> 4, te->z >> 4);
- if (lc != NULL) lc->removeTileEntity(te->x & 15, te->y, te->z & 15);
+ if (lc != nullptr) lc->removeTileEntity(te->x & 15, te->y, te->z & 15);
}
}
else
@@ -2437,7 +2436,7 @@ void Level::tickEntities()
if (hasChunk(e->x >> 4, e->z >> 4))
{
LevelChunk *lc = getChunk(e->x >> 4, e->z >> 4);
- if (lc != NULL) lc->setTileEntity(e->x & 15, e->y, e->z & 15, e);
+ if (lc != nullptr) lc->setTileEntity(e->x & 15, e->y, e->z & 15, e);
}
sendTileUpdated(e->x, e->y, e->z);
@@ -2503,7 +2502,7 @@ void Level::tick(shared_ptr<Entity> e, bool actual)
#endif
{
e->tickCount++;
- if (e->riding != NULL)
+ if (e->riding != nullptr)
{
e->rideTick();
}
@@ -2550,7 +2549,7 @@ void Level::tick(shared_ptr<Entity> e, bool actual)
if (actual && e->inChunk)
{
- if (e->rider.lock() != NULL)
+ if (e->rider.lock() != nullptr)
{
if (e->rider.lock()->removed || e->rider.lock()->riding != e)
{
@@ -2600,7 +2599,7 @@ bool Level::containsAnyBlocks(AABB *box)
for (int z = z0; z < z1; z++)
{
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile != NULL)
+ if (tile != nullptr)
{
return true;
}
@@ -2627,7 +2626,7 @@ bool Level::containsAnyLiquid(AABB *box)
for (int z = z0; z < z1; z++)
{
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile != NULL && tile->material->isLiquid())
+ if (tile != nullptr && tile->material->isLiquid())
{
return true;
}
@@ -2657,7 +2656,7 @@ bool Level::containsAnyLiquid_NoLoad(AABB *box)
{
if( !hasChunkAt(x,y,z) ) return true; // If we don't have it, it might be liquid...
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile != NULL && tile->material->isLiquid())
+ if (tile != nullptr && tile->material->isLiquid())
{
return true;
}
@@ -2715,7 +2714,7 @@ bool Level::checkAndHandleWater(AABB *box, Material *material, shared_ptr<Entity
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)
@@ -2755,7 +2754,7 @@ bool Level::containsMaterial(AABB *box, Material *material)
for (int z = z0; z < z1; z++)
{
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile != NULL && tile->material == material)
+ if (tile != nullptr && tile->material == material)
{
return true;
}
@@ -2782,7 +2781,7 @@ bool Level::containsLiquid(AABB *box, Material *material)
for (int z = z0; z < z1; z++)
{
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile != NULL && tile->material == material)
+ if (tile != nullptr && tile->material == material)
{
int data = getData(x, y, z);
double yh1 = y + 1;
@@ -2810,7 +2809,7 @@ shared_ptr<Explosion> Level::explode(shared_ptr<Entity> source, double x, double
shared_ptr<Explosion> Level::explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks)
{
- shared_ptr<Explosion> explosion = shared_ptr<Explosion>( new Explosion(this, source, x, y, z, r) );
+ shared_ptr<Explosion> explosion = std::make_shared<Explosion>(this, source, x, y, z, r);
explosion->fire = fire;
explosion->destroyBlocks = destroyBlocks;
explosion->explode();
@@ -2834,12 +2833,12 @@ float Level::getSeenPercent(Vec3 *center, AABB *bb)
double y = bb->y0 + (bb->y1 - bb->y0) * yy;
double z = bb->z0 + (bb->z1 - bb->z0) * zz;
HitResult *res = clip(Vec3::newTemp(x, y, z), center);
- if ( res == NULL) hits++;
+ if ( res == nullptr) hits++;
delete res;
count++;
}
- return hits / (float) count;
+ return hits / static_cast<float>(count);
}
@@ -2896,7 +2895,7 @@ shared_ptr<TileEntity> Level::getTileEntity(int x, int y, int z)
if (updatingTileEntities)
{
EnterCriticalSection(&m_tileEntityListCS);
- for (int i = 0; i < pendingTileEntities.size(); i++)
+ for (size_t i = 0; i < pendingTileEntities.size(); i++)
{
shared_ptr<TileEntity> e = pendingTileEntities.at(i);
if (!e->isRemoved() && e->x == x && e->y == y && e->z == z)
@@ -2908,16 +2907,16 @@ shared_ptr<TileEntity> Level::getTileEntity(int x, int y, int z)
LeaveCriticalSection(&m_tileEntityListCS);
}
- if (tileEntity == NULL)
+ if (tileEntity == nullptr)
{
LevelChunk *lc = getChunk(x >> 4, z >> 4);
- if (lc != NULL)
+ if (lc != nullptr)
{
tileEntity = lc->getTileEntity(x & 15, y, z & 15);
}
}
- if (tileEntity == NULL)
+ if (tileEntity == nullptr)
{
EnterCriticalSection(&m_tileEntityListCS);
for(auto& e : pendingTileEntities)
@@ -2936,7 +2935,7 @@ shared_ptr<TileEntity> Level::getTileEntity(int x, int y, int z)
void Level::setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity)
{
- if (tileEntity != NULL && !tileEntity->isRemoved())
+ if (tileEntity != nullptr && !tileEntity->isRemoved())
{
EnterCriticalSection(&m_tileEntityListCS);
if (updatingTileEntities)
@@ -2967,7 +2966,7 @@ void Level::setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity
tileEntityList.push_back(tileEntity);
LevelChunk *lc = getChunk(x >> 4, z >> 4);
- if (lc != NULL) lc->setTileEntity(x & 15, y, z & 15, tileEntity);
+ if (lc != nullptr) lc->setTileEntity(x & 15, y, z & 15, tileEntity);
}
LeaveCriticalSection(&m_tileEntityListCS);
}
@@ -2977,7 +2976,7 @@ void Level::removeTileEntity(int x, int y, int z)
{
EnterCriticalSection(&m_tileEntityListCS);
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
- if (te != NULL && updatingTileEntities)
+ if (te != nullptr && updatingTileEntities)
{
te->setRemoved();
auto it = find(pendingTileEntities.begin(), pendingTileEntities.end(), te);
@@ -2988,7 +2987,7 @@ void Level::removeTileEntity(int x, int y, int z)
}
else
{
- if (te != NULL)
+ if (te != nullptr)
{
auto it = find(pendingTileEntities.begin(), pendingTileEntities.end(), te);
if( it != pendingTileEntities.end() )
@@ -3002,7 +3001,7 @@ void Level::removeTileEntity(int x, int y, int z)
}
}
LevelChunk *lc = getChunk(x >> 4, z >> 4);
- if (lc != NULL) lc->removeTileEntity(x & 15, y, z & 15);
+ if (lc != nullptr) lc->removeTileEntity(x & 15, y, z & 15);
}
LeaveCriticalSection(&m_tileEntityListCS);
}
@@ -3015,7 +3014,7 @@ void Level::markForRemoval(shared_ptr<TileEntity> entity)
bool Level::isSolidRenderTile(int x, int y, int z)
{
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile == NULL) return false;
+ if (tile == nullptr) return false;
// 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so
// blocks of leaves will have all sides of each block completely visible. Changing to consider as solid if this block is surrounded by
@@ -3031,7 +3030,7 @@ bool Level::isSolidRenderTile(int x, int y, int z)
for( int i = 0; i < 6; i++ )
{
int t = getTile(x + axo[i], y + ayo[i] , z + azo[i]);
- if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == NULL ) || !Tile::tiles[t]->isSolidRender() ) )
+ if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == nullptr ) || !Tile::tiles[t]->isSolidRender() ) )
{
return false;
}
@@ -3061,25 +3060,25 @@ bool Level::isSolidBlockingTileInLoadedChunk(int x, int y, int z, bool valueIfNo
return valueIfNotLoaded;
}
LevelChunk *chunk = chunkSource->getChunk(x >> 4, z >> 4);
- if (chunk == NULL || chunk->isEmpty())
+ if (chunk == nullptr || chunk->isEmpty())
{
return valueIfNotLoaded;
}
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile == NULL) return false;
+ if (tile == nullptr) return false;
return tile->material->isSolidBlocking() && tile->isCubeShaped();
}
bool Level::isFullAABBTile(int x, int y, int z)
{
int tile = getTile(x, y, z);
- if (tile == 0 || Tile::tiles[tile] == NULL)
+ if (tile == 0 || Tile::tiles[tile] == nullptr)
{
return false;
}
AABB *aabb = Tile::tiles[tile]->getAABB(this, x, y, z);
- return aabb != NULL && aabb->getSize() >= 1;
+ return aabb != nullptr && aabb->getSize() >= 1;
}
bool Level::isTopSolidBlocking(int x, int y, int z)
@@ -3091,19 +3090,19 @@ bool Level::isTopSolidBlocking(int x, int y, int z)
bool Level::isTopSolidBlocking(Tile *tile, int data)
{
- if (tile == NULL) return false;
+ if (tile == nullptr) return false;
if (tile->material->isSolidBlocking() && tile->isCubeShaped()) return true;
- if (dynamic_cast<StairTile *>(tile) != NULL)
+ if (dynamic_cast<StairTile *>(tile) != nullptr)
{
return (data & StairTile::UPSIDEDOWN_BIT) == StairTile::UPSIDEDOWN_BIT;
}
- if (dynamic_cast<HalfSlabTile *>(tile) != NULL)
+ if (dynamic_cast<HalfSlabTile *>(tile) != nullptr)
{
return (data & HalfSlabTile::TOP_SLOT_BIT) == HalfSlabTile::TOP_SLOT_BIT;
}
- if (dynamic_cast<HopperTile *>(tile) != NULL) return true;
- if (dynamic_cast<TopSnowTile *>(tile) != NULL) return (data & TopSnowTile::HEIGHT_MASK) == TopSnowTile::MAX_HEIGHT + 1;
+ if (dynamic_cast<HopperTile *>(tile) != nullptr) return true;
+ if (dynamic_cast<TopSnowTile *>(tile) != nullptr) return (data & TopSnowTile::HEIGHT_MASK) == TopSnowTile::MAX_HEIGHT + 1;
return false;
}
@@ -3258,7 +3257,7 @@ void Level::buildAndPrepareChunksToPoll()
// 4J - rewritten to add chunks interleaved by player, and to add them from the centre outwards. We're going to be
// potentially adding less creatures than the original so that our count stays consistent with number of players added, so
// we want to make sure as best we can that the ones we do add are near the active players
- int playerCount = (int)players.size();
+ int playerCount = static_cast<int>(players.size());
int *xx = new int[playerCount];
int *zz = new int[playerCount];
for (size_t i = 0; i < playerCount; i++)
@@ -3320,7 +3319,7 @@ void Level::tickClientSideTiles(int xo, int zo, LevelChunk *lc)
if (id == 0 && this->getDaytimeRawBrightness(x, y, z) <= random->nextInt(8) && getBrightness(LightLayer::Sky, x, y, z) <= 0)
{
shared_ptr<Player> player = getNearestPlayer(x + 0.5, y + 0.5, z + 0.5, 8);
- if (player != NULL && player->distanceToSqr(x + 0.5, y + 0.5, z + 0.5) > 2 * 2)
+ if (player != nullptr && player->distanceToSqr(x + 0.5, y + 0.5, z + 0.5) > 2 * 2)
{
// 4J-PB - Fixed issue with cave audio event having 2 sounds at 192k
#ifdef _XBOX
@@ -3437,7 +3436,7 @@ int Level::getExpectedLight(lightCache_t *cache, int x, int y, int z, LightLayer
// 4J - Made changes here so that lighting goes through a cache, if enabled for this thread
void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool force, bool rootOnlyEmissive)
{
- lightCache_t *cache = (lightCache_t *)TlsGetValue(tlsIdxLightCache);
+ lightCache_t *cache = static_cast<lightCache_t *>(TlsGetValue(tlsIdxLightCache));
uint64_t cacheUse = 0;
if( force )
@@ -3471,13 +3470,13 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool f
// If we're in cached mode, then use memory allocated after the cached data itself for the toCheck array, in an attempt to make both that & the other cached data sit on the CPU L2 cache better.
int *toCheck;
- if( cache == NULL )
+ if( cache == nullptr )
{
toCheck = toCheckLevel;
}
else
{
- toCheck = (int *)(cache + (16*16*16));
+ toCheck = reinterpret_cast<int *>(cache + (16 * 16 * 16));
}
int checkedPosition = 0;
@@ -3551,7 +3550,7 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool f
if( ( yy < 0 ) || ( yy >= maxBuildHeight ) ) continue;
// 4J - some changes here brought forward from 1.2.3
- int block = max(1, getBlockingCached(cache, layer, NULL, xx, yy, zz) );
+ int block = max(1, getBlockingCached(cache, layer, nullptr, xx, yy, zz) );
current = getBrightnessCached(cache, layer, xx, yy, zz);
if ((current == expected - block) && (toCheckCount < (32 * 32 * 32))) // 4J - 32 * 32 * 32 was toCheck.length
{
@@ -3670,13 +3669,13 @@ bool Level::tickPendingTicks(bool force)
vector<TickNextTickData> *Level::fetchTicksInChunk(LevelChunk *chunk, bool remove)
{
- return NULL;
+ return nullptr;
}
vector<shared_ptr<Entity> > *Level::getEntities(shared_ptr<Entity> except, AABB *bb)
{
- return getEntities(except, bb, NULL);
+ return getEntities(except, bb, nullptr);
}
vector<shared_ptr<Entity> > *Level::getEntities(shared_ptr<Entity> except, AABB *bb, const EntitySelector *selector)
@@ -3720,7 +3719,7 @@ vector<shared_ptr<Entity> > *Level::getEntities(shared_ptr<Entity> except, AABB
vector<shared_ptr<Entity> > *Level::getEntitiesOfClass(const type_info& baseClass, AABB *bb)
{
- return getEntitiesOfClass(baseClass, bb, NULL);
+ return getEntitiesOfClass(baseClass, bb, nullptr);
}
vector<shared_ptr<Entity> > *Level::getEntitiesOfClass(const type_info& baseClass, AABB *bb, const EntitySelector *selector)
@@ -3814,7 +3813,7 @@ unsigned int Level::countInstanceOf(BaseObject::Class *clas)
// 4J - added - more limited (but faster) version of above, used to count water animals, animals, monsters for the mob spawner
// singleType flag should be true if we are just trying to match eINSTANCEOF exactly, and false if it is a eINSTANCEOF from a group (eTYPE_WATERANIMAL, eTYPE_ANIMAL, eTYPE_MONSTER)
-unsigned int Level::countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount/* = NULL*/, unsigned int *couldWanderCount/* = NULL*/)
+unsigned int Level::countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount/* = nullptr*/, unsigned int *couldWanderCount/* = nullptr*/)
{
unsigned int count = 0;
if( protectedCount ) *protectedCount = 0;
@@ -3932,16 +3931,16 @@ bool Level::mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int f
Tile *tile = Tile::tiles[tileId];
AABB *aabb = tile->getAABB(this, x, y, z);
- if (ignoreEntities) aabb = NULL;
- if (aabb != NULL && !isUnobstructed(aabb, ignoreEntity)) return false;
- if (targetTile != NULL &&
+ if (ignoreEntities) aabb = nullptr;
+ if (aabb != nullptr && !isUnobstructed(aabb, ignoreEntity)) return false;
+ if (targetTile != nullptr &&
(targetTile == Tile::water || targetTile == Tile::calmWater || targetTile == Tile::lava ||
targetTile == Tile::calmLava || targetTile == Tile::fire || targetTile->material->isReplaceable()))
{
- targetTile = NULL;
+ targetTile = nullptr;
}
- if (targetTile != NULL && targetTile->material == Material::decoration && tile == Tile::anvil) return true;
- if (tileId > 0 && targetTile == NULL)
+ if (targetTile != nullptr && targetTile->material == Material::decoration && tile == Tile::anvil) return true;
+ if (tileId > 0 && targetTile == nullptr)
{
if (tile->mayPlace(this, x, y, z, face, item))
{
@@ -3964,7 +3963,7 @@ Path *Level::findPath(shared_ptr<Entity> from, shared_ptr<Entity> to, float maxD
int y = Mth::floor(from->y + 1);
int z = Mth::floor(from->z);
- int r = (int) (maxDist + 16);
+ int r = static_cast<int>(maxDist + 16);
int x1 = x - r;
int y1 = y - r;
int z1 = z - r;
@@ -3983,7 +3982,7 @@ Path *Level::findPath(shared_ptr<Entity> from, int xBest, int yBest, int zBest,
int y = Mth::floor(from->y);
int z = Mth::floor(from->z);
- int r = (int) (maxDist + 8);
+ int r = static_cast<int>(maxDist + 8);
int x1 = x - r;
int y1 = y - r;
int z1 = z - r;
@@ -4523,7 +4522,7 @@ int Level::getHeight()
Tickable *Level::makeSoundUpdater(shared_ptr<Minecart> minecart)
{
- return NULL;
+ return nullptr;
}
Random *Level::getRandomFor(int x, int z, int blend)
diff --git a/Minecraft.World/Level.h b/Minecraft.World/Level.h
index 946b21e3..eb750aff 100644
--- a/Minecraft.World/Level.h
+++ b/Minecraft.World/Level.h
@@ -438,7 +438,7 @@ public:
vector<shared_ptr<Entity> > getAllEntities();
void tileEntityChanged(int x, int y, int z, shared_ptr<TileEntity> te);
// unsigned int countInstanceOf(BaseObject::Class *clas);
- unsigned int countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount = NULL, unsigned int *couldWanderCount = NULL); // 4J added
+ unsigned int countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount = nullptr, unsigned int *couldWanderCount = nullptr); // 4J added
unsigned int countInstanceOfInRange(eINSTANCEOF clas, bool singleType, int range, int x, int y, int z); // 4J Added
void addEntities(vector<shared_ptr<Entity> > *list);
virtual void removeEntities(vector<shared_ptr<Entity> > *list);
diff --git a/Minecraft.World/LevelChunk.cpp b/Minecraft.World/LevelChunk.cpp
index e4958ecf..118dbcdd 100644
--- a/Minecraft.World/LevelChunk.cpp
+++ b/Minecraft.World/LevelChunk.cpp
@@ -123,7 +123,7 @@ void LevelChunk::init(Level *level, int x, int z)
#ifdef _LARGE_WORLDS
m_bUnloaded = false; // 4J Added
- m_unloadedEntitiesTag = NULL;
+ m_unloadedEntitiesTag = nullptr;
#endif
}
@@ -132,10 +132,10 @@ LevelChunk::LevelChunk(Level *level, int x, int z)
{
init(level, x, z);
lowerBlocks = new CompressedTileStorage();
- lowerData = NULL;
- lowerSkyLight = NULL;
- lowerBlockLight = NULL;
- serverTerrainPopulated = NULL;
+ lowerData = nullptr;
+ lowerSkyLight = nullptr;
+ lowerBlockLight = nullptr;
+ serverTerrainPopulated = nullptr;
if(Level::maxBuildHeight > Level::COMPRESSED_CHUNK_SECTION_HEIGHT)
{
@@ -147,10 +147,10 @@ LevelChunk::LevelChunk(Level *level, int x, int z)
}
else
{
- upperBlocks = NULL;
- upperData = NULL;
- upperSkyLight = NULL;
- upperBlockLight = NULL;
+ upperBlocks = nullptr;
+ upperData = nullptr;
+ upperSkyLight = nullptr;
+ upperBlockLight = nullptr;
}
#ifdef SHARING_ENABLED
@@ -167,7 +167,7 @@ LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z)
// We'll be creating this as "empty" when this ctor is called on the client, as a result of a chunk becoming visible (but we don't have the data yet for it).
// In this case, we want to keep memory usage down and so create all data as empty/compressed as possible. On the client we get the full data for the chunk as a single
// update in a block region update packet, and so there is a single point where it is good to compress the data.
- bool createEmpty = ( blocks.data == NULL );
+ bool createEmpty = ( blocks.data == nullptr );
if( createEmpty )
{
@@ -199,13 +199,13 @@ LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z)
}
else
{
- upperBlocks = NULL;
- upperData = NULL;
- upperSkyLight = NULL;
- upperBlockLight = NULL;
+ upperBlocks = nullptr;
+ upperData = nullptr;
+ upperSkyLight = nullptr;
+ upperBlockLight = nullptr;
}
- serverTerrainPopulated = NULL;
+ serverTerrainPopulated = nullptr;
#ifdef SHARING_ENABLED
sharingTilesAndData = false;
#endif
@@ -237,7 +237,7 @@ LevelChunk::LevelChunk(Level *level, int x, int z, LevelChunk *lc)
this->data = new SparseDataStorage(lc->data);
this->skyLight = new SparseLightStorage(lc->skyLight);
this->blockLight = new SparseLightStorage(lc->blockLight);
- serverTerrainPopulated = NULL;
+ serverTerrainPopulated = nullptr;
#endif
}
@@ -296,8 +296,8 @@ void LevelChunk::stopSharingTilesAndData()
}
else
{
- upperBlocks = NULL;
- upperData = NULL;
+ upperBlocks = nullptr;
+ upperData = nullptr;
}
/*
@@ -531,7 +531,7 @@ void LevelChunk::recalcHeightmapOnly()
blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks;
}
#endif
- heightmap[z << 4 | x] = (byte) y;
+ heightmap[z << 4 | x] = static_cast<byte>(y);
if (y < min) min = y;
}
@@ -588,7 +588,7 @@ void LevelChunk::recalcHeightmap()
blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks;
}
#endif
- heightmap[z << 4 | x] = (byte) y;
+ heightmap[z << 4 | x] = static_cast<byte>(y);
if (y < min) min = y;
if (y < lowestHeightmap) lowestHeightmap = y;
@@ -811,7 +811,7 @@ void LevelChunk::recalcHeight(int x, int yStart, int z)
if (y == yOld) return;
// level->lightColumnChanged(x, z, y, yOld); // 4J - this call moved below & corrected - see comment further down
- heightmap[z << 4 | x] = (byte) y;
+ heightmap[z << 4 | x] = static_cast<byte>(y);
if (y < minHeight)
{
@@ -919,12 +919,12 @@ int LevelChunk::getTile(int x, int y, int z)
bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
{
- byte tile = (byte) _tile;
+ byte tile = static_cast<byte>(_tile);
// Optimisation brought forward from 1.8.2, change from int to unsigned char & this special value changed from -999 to 255
int slot = z << 4 | x;
- if (y >= ((int)rainHeights[slot]) - 1)
+ if (y >= static_cast<int>(rainHeights[slot]) - 1)
{
rainHeights[slot] = 255;
}
@@ -939,7 +939,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
{
// 4J Stu - Need to do this here otherwise double chests don't always work correctly
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
- if (te != NULL)
+ if (te != nullptr)
{
te->clearCache();
}
@@ -1032,17 +1032,17 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
}
}
// AP - changed the method of EntityTile detection cos it's well slow on Vita mate
- // if (_tile > 0 && dynamic_cast<EntityTile *>(Tile::tiles[_tile]) != NULL)
- if (_tile > 0 && Tile::tiles[_tile] != NULL && Tile::tiles[_tile]->isEntityTile())
+ // if (_tile > 0 && dynamic_cast<EntityTile *>(Tile::tiles[_tile]) != nullptr)
+ if (_tile > 0 && Tile::tiles[_tile] != nullptr && Tile::tiles[_tile]->isEntityTile())
{
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
- if (te == NULL)
+ if (te == nullptr)
{
te = dynamic_cast<EntityTile *>(Tile::tiles[_tile])->newTileEntity(level);
//app.DebugPrintf("%s: Setting tile id %d, created tileEntity type %d\n", level->isClientSide?"Client":"Server", _tile, te->GetType());
level->setTileEntity(xOffs, y, zOffs, te);
}
- if (te != NULL)
+ if (te != nullptr)
{
//app.DebugPrintf("%s: Setting tile id %d, found tileEntity type %d\n", level->isClientSide?"Client":"Server", _tile, te->GetType());
te->clearCache();
@@ -1050,11 +1050,11 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
}
}
// AP - changed the method of EntityTile detection cos it's well slow on Vita mate
- // else if (old > 0 && dynamic_cast<EntityTile *>(Tile::tiles[old]) != NULL)
- else if (old > 0 && Tile::tiles[_tile] != NULL && Tile::tiles[_tile]->isEntityTile())
+ // else if (old > 0 && dynamic_cast<EntityTile *>(Tile::tiles[old]) != nullptr)
+ else if (old > 0 && Tile::tiles[_tile] != nullptr && Tile::tiles[_tile]->isEntityTile())
{
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
- if (te != NULL)
+ if (te != nullptr)
{
te->clearCache();
}
@@ -1091,10 +1091,10 @@ bool LevelChunk::setData(int x, int y, int z, int val, int mask, bool *maskedBit
data->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, val);
int _tile = getTile(x, y, z);
- if (_tile > 0 && dynamic_cast<EntityTile *>( Tile::tiles[_tile] ) != NULL)
+ if (_tile > 0 && dynamic_cast<EntityTile *>( Tile::tiles[_tile] ) != nullptr)
{
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
- if (te != NULL)
+ if (te != nullptr)
{
te->clearCache();
te->data = val;
@@ -1310,7 +1310,7 @@ shared_ptr<TileEntity> 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<EntityTile *>(Tile::tiles[t])->newTileEntity(level);
level->setTileEntity(this->x * 16 + x, y, this->z * 16 + z, tileEntity);
@@ -1332,7 +1332,7 @@ shared_ptr<TileEntity> LevelChunk::getTileEntity(int x, int y, int z)
tileEntity = it->second;
LeaveCriticalSection(&m_csTileEntities);
}
- if (tileEntity != NULL && tileEntity->isRemoved())
+ if (tileEntity != nullptr && tileEntity->isRemoved())
{
EnterCriticalSection(&m_csTileEntities);
tileEntities.erase(pos);
@@ -1398,7 +1398,7 @@ void LevelChunk::removeTileEntity(int x, int y, int z)
{
shared_ptr<TileEntity> te = tileEntities[pos];
tileEntities.erase(pos);
- if( te != NULL )
+ if( te != nullptr )
{
if(level->isClientSide)
{
@@ -1421,13 +1421,13 @@ void LevelChunk::load()
if(m_bUnloaded && m_unloadedEntitiesTag)
{
ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) m_unloadedEntitiesTag->getList(L"Entities");
- if (entityTags != NULL)
+ if (entityTags != nullptr)
{
for (int i = 0; i < entityTags->size(); i++)
{
CompoundTag *teTag = entityTags->get(i);
shared_ptr<Entity> ent = EntityIO::loadStatic(teTag, level);
- if (ent != NULL)
+ if (ent != nullptr)
{
ent->onLoadedFromSave();
addEntity(ent);
@@ -1436,20 +1436,20 @@ void LevelChunk::load()
}
ListTag<CompoundTag> *tileEntityTags = (ListTag<CompoundTag> *) m_unloadedEntitiesTag->getList(L"TileEntities");
- if (tileEntityTags != NULL)
+ if (tileEntityTags != nullptr)
{
for (int i = 0; i < tileEntityTags->size(); i++)
{
CompoundTag *teTag = tileEntityTags->get(i);
shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
- if (te != NULL)
+ if (te != nullptr)
{
addTileEntity(te);
}
}
}
delete m_unloadedEntitiesTag;
- m_unloadedEntitiesTag = NULL;
+ m_unloadedEntitiesTag = nullptr;
m_bUnloaded = false;
}
#endif
@@ -1628,16 +1628,16 @@ void LevelChunk::getEntities(shared_ptr<Entity> except, AABB *bb, vector<shared_
for (auto& e : *entities)
{
- if ( e && e != except && e->bb->intersects(bb) && (selector == NULL || selector->matches(e)))
+ if ( e && e != except && e->bb->intersects(bb) && (selector == nullptr || selector->matches(e)))
{
es.push_back(e);
vector<shared_ptr<Entity> > *subs = e->getSubEntities();
- if (subs != NULL)
+ if (subs != nullptr)
{
for (const auto& sub : *subs)
{
e = sub;
- if ( e && e != except && e->bb->intersects(bb) && (selector == NULL || selector->matches(e)))
+ if ( e && e != except && e->bb->intersects(bb) && (selector == nullptr || selector->matches(e)))
{
es.push_back(e);
}
@@ -1693,10 +1693,10 @@ void LevelChunk::getEntitiesOfClass(const type_info& ec, AABB *bb, vector<shared
else if ( ec==typeid(Minecart) ) isAssignableFrom = e->instanceof(eTYPE_MINECART);
else if ( ec==typeid(Monster) ) isAssignableFrom = e->instanceof(eTYPE_MONSTER);
else if ( ec==typeid(Zombie) ) isAssignableFrom = e->instanceof(eTYPE_ZOMBIE);
- else if(e != NULL && ec == typeid(*(e.get())) ) isAssignableFrom = true;
+ else if(e != nullptr && ec == typeid(*(e.get())) ) isAssignableFrom = true;
if (isAssignableFrom && e->bb->intersects(bb))
{
- if (selector == NULL || selector->matches(e))
+ if (selector == nullptr || selector->matches(e))
{
es.push_back(e);
}
@@ -1719,7 +1719,7 @@ int LevelChunk::countEntities()
#endif
for (int yc = 0; yc < ENTITY_BLOCKS_LENGTH; yc++)
{
- entityCount += (int)entityBlocks[yc]->size();
+ entityCount += static_cast<int>(entityBlocks[yc]->size());
}
#ifdef _ENTITIES_RW_SECTION
LeaveCriticalRWSection(&m_csEntities, false);
@@ -1813,7 +1813,7 @@ bool LevelChunk::testSetBlocksAndData(byteArray data, int x0, int y0, int z0, in
void LevelChunk::tileUpdatedCallback(int x, int y, int z, void *param, int yparam)
{
- LevelChunk *lc = (LevelChunk *)param;
+ LevelChunk *lc = static_cast<LevelChunk *>(param);
int xx = lc->x * 16 + x;
int yy = y + yparam;
int zz = lc->z * 16 + z;
@@ -1849,8 +1849,8 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1,
int compressedHeight = Level::COMPRESSED_CHUNK_SECTION_HEIGHT;
// 4J - replaced block storage as now uses CompressedTileStorage
- if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 );
- if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
+ if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, 0 );
+ if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
/*
for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++)
@@ -1864,8 +1864,8 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1,
recalcHeightmapOnly();
// 4J - replaced data storage as now uses SparseDataStorage
- if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 );
- if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
+ if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, 0 );
+ if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
if( includeLighting )
{
@@ -2000,7 +2000,7 @@ void LevelChunk::checkChests(ChunkSource *source, int x, int z )
{
int xOffs = x * 16 + xx;
int zOffs = z * 16 + zz;
- ChestTile *tile = (ChestTile *)Tile::tiles[Tile::chest_Id];
+ ChestTile *tile = static_cast<ChestTile *>(Tile::tiles[Tile::chest_Id]);
tile->recalcLockDir( level, xOffs, yy, zOffs );
level->checkLight(xOffs, yy, zOffs, true);
}
@@ -2047,7 +2047,7 @@ void LevelChunk::reloadBiomes()
for(unsigned int z = 0; z < 16; ++z)
{
Biome *biome = biomeSource->getBiome((this->x << 4) + x, (this->z << 4) + z);
- biomes[(z << 4) | x] = (byte) ( (biome->id) & 0xff);
+ biomes[(z << 4) | x] = static_cast<byte>((biome->id) & 0xff);
}
}
}
@@ -2059,9 +2059,9 @@ Biome *LevelChunk::getBiome(int x, int z, BiomeSource *biomeSource)
{
Biome *biome = biomeSource->getBiome((this->x << 4) + x, (this->z << 4) + z);
value = biome->id;
- biomes[(z << 4) | x] = (byte) (value & 0xff);
+ biomes[(z << 4) | x] = static_cast<byte>(value & 0xff);
}
- if (Biome::biomes[value] == NULL)
+ if (Biome::biomes[value] == nullptr)
{
return Biome::plains;
}
@@ -2075,7 +2075,7 @@ byteArray LevelChunk::getBiomes()
void LevelChunk::setBiomes(byteArray biomes)
{
- if(this->biomes.data != NULL) delete[] this->biomes.data;
+ if(this->biomes.data != nullptr) delete[] this->biomes.data;
this->biomes = biomes;
}
@@ -2156,8 +2156,8 @@ void LevelChunk::getDataData(byteArray data)
// Set data to data passed in input byte array of length 16384. This data must be in original (java version) order if originalOrder set.
void LevelChunk::setDataData(byteArray data)
{
- if( lowerData == NULL ) lowerData = new SparseDataStorage();
- if( upperData == NULL ) upperData = new SparseDataStorage(true);
+ if( lowerData == nullptr ) lowerData = new SparseDataStorage();
+ if( upperData == nullptr ) upperData = new SparseDataStorage(true);
lowerData->setData(data,0);
if(data.length > Level::COMPRESSED_CHUNK_SECTION_TILES/2) upperData->setData(data,Level::COMPRESSED_CHUNK_SECTION_TILES/2);
}
@@ -2179,8 +2179,8 @@ void LevelChunk::getBlockLightData(byteArray data)
// Set sky light data to data passed in input byte array of length 16384. This data must be in original (java version) order if originalOrder set.
void LevelChunk::setSkyLightData(byteArray data)
{
- if( lowerSkyLight == NULL ) lowerSkyLight = new SparseLightStorage(true);
- if( upperSkyLight == NULL ) upperSkyLight = new SparseLightStorage(true,true);
+ if( lowerSkyLight == nullptr ) lowerSkyLight = new SparseLightStorage(true);
+ if( upperSkyLight == nullptr ) upperSkyLight = new SparseLightStorage(true,true);
lowerSkyLight->setData(data,0);
if(data.length > Level::COMPRESSED_CHUNK_SECTION_TILES/2) upperSkyLight->setData(data,Level::COMPRESSED_CHUNK_SECTION_TILES/2);
}
@@ -2188,8 +2188,8 @@ void LevelChunk::setSkyLightData(byteArray data)
// Set block light data to data passed in input byte array of length 16384. This data must be in original (java version) order if originalOrder set.
void LevelChunk::setBlockLightData(byteArray data)
{
- if( lowerBlockLight == NULL ) lowerBlockLight = new SparseLightStorage(false);
- if( upperBlockLight == NULL ) upperBlockLight = new SparseLightStorage(false, true);
+ if( lowerBlockLight == nullptr ) lowerBlockLight = new SparseLightStorage(false);
+ if( upperBlockLight == nullptr ) upperBlockLight = new SparseLightStorage(false, true);
lowerBlockLight->setData(data,0);
if(data.length > Level::COMPRESSED_CHUNK_SECTION_TILES/2) upperBlockLight->setData(data,Level::COMPRESSED_CHUNK_SECTION_TILES/2);
}
@@ -2215,8 +2215,8 @@ void LevelChunk::compressLighting()
void LevelChunk::compressBlocks()
{
#ifdef SHARING_ENABLED
- CompressedTileStorage *blocksToCompressLower = NULL;
- CompressedTileStorage *blocksToCompressUpper = NULL;
+ CompressedTileStorage *blocksToCompressLower = nullptr;
+ CompressedTileStorage *blocksToCompressUpper = nullptr;
// If we're the host machine, and this is the client level, then we only want to do this if we are sharing data. This means that we will be compressing the data that is shared from the server.
// No point trying to compress the local client copy of the data if the data is unshared, since we'll be throwing this data away again anyway once we share with the server again.
@@ -2293,24 +2293,24 @@ void LevelChunk::readCompressedBlockData(DataInputStream *dis)
void LevelChunk::readCompressedDataData(DataInputStream *dis)
{
- if( lowerData == NULL ) lowerData = new SparseDataStorage();
- if( upperData == NULL ) upperData = new SparseDataStorage(true);
+ if( lowerData == nullptr ) lowerData = new SparseDataStorage();
+ if( upperData == nullptr ) upperData = new SparseDataStorage(true);
lowerData->read(dis);
upperData->read(dis);
}
void LevelChunk::readCompressedSkyLightData(DataInputStream *dis)
{
- if( lowerSkyLight == NULL ) lowerSkyLight = new SparseLightStorage(true);
- if( upperSkyLight == NULL ) upperSkyLight = new SparseLightStorage(true,true);
+ if( lowerSkyLight == nullptr ) lowerSkyLight = new SparseLightStorage(true);
+ if( upperSkyLight == nullptr ) upperSkyLight = new SparseLightStorage(true,true);
lowerSkyLight->read(dis);
upperSkyLight->read(dis);
}
void LevelChunk::readCompressedBlockLightData(DataInputStream *dis)
{
- if( lowerBlockLight == NULL ) lowerBlockLight = new SparseLightStorage(false);
- if( upperBlockLight == NULL ) upperBlockLight = new SparseLightStorage(false, true);
+ if( lowerBlockLight == nullptr ) lowerBlockLight = new SparseLightStorage(false);
+ if( upperBlockLight == nullptr ) upperBlockLight = new SparseLightStorage(false, true);
lowerBlockLight->read(dis);
upperBlockLight->read(dis);
}
@@ -2319,8 +2319,8 @@ void LevelChunk::readCompressedBlockLightData(DataInputStream *dis)
void LevelChunk::compressData()
{
#ifdef SHARING_ENABLED
- SparseDataStorage *dataToCompressLower = NULL;
- SparseDataStorage *dataToCompressUpper = NULL;
+ SparseDataStorage *dataToCompressLower = nullptr;
+ SparseDataStorage *dataToCompressUpper = nullptr;
// If we're the host machine, and this is the client level, then we only want to do this if we are sharing data. This means that we will be compressing the data that is shared from the server.
// No point trying to compress the local client copy of the data if the data is unshared, since we'll be throwing this data away again anyway once we share with the server again.
diff --git a/Minecraft.World/LevelData.cpp b/Minecraft.World/LevelData.cpp
index 05bc2060..fbc10ddb 100644
--- a/Minecraft.World/LevelData.cpp
+++ b/Minecraft.World/LevelData.cpp
@@ -18,7 +18,7 @@ LevelData::LevelData(CompoundTag *tag)
{
wstring generatorName = tag->getString(L"generatorName");
m_pGenerator = LevelType::getLevelType(generatorName);
- if (m_pGenerator == NULL)
+ if (m_pGenerator == nullptr)
{
m_pGenerator = LevelType::lvl_normal;
}
@@ -188,8 +188,13 @@ LevelData::LevelData(CompoundTag *tag)
dimension = loadedPlayerTag->getInt(L"Dimension");
}
else
+<<<<<<< HEAD
+ {
+ this->loadedPlayerTag = nullptr;
+=======
{
this->loadedPlayerTag = NULL;
+>>>>>>> origin/main
}
*/
dimension = 0;
@@ -215,7 +220,7 @@ LevelData::LevelData(LevelSettings *levelSettings, const wstring& levelName)
gameTime = -1;
lastPlayed = 0;
sizeOnDisk = 0;
- // this->loadedPlayerTag = NULL; // 4J - we don't store this anymore
+ // this->loadedPlayerTag = nullptr; // 4J - we don't store this anymore
dimension = 0;
version = 0;
rainTime = 0;
@@ -432,7 +437,7 @@ int64_t LevelData::getSizeOnDisk()
CompoundTag *LevelData::getLoadedPlayerTag()
{
- return NULL; // 4J - we don't store this anymore
+ return nullptr; // 4J - we don't store this anymore
}
// 4J Removed TU9 as it's never accurate due to the dimension never being set
@@ -712,7 +717,7 @@ void LevelData::getMoatFlags(bool* bClassicEdgeMoat, bool* bSmallEdgeMoat, bool*
int LevelData::getXZHellSizeOld()
{
- int hellXZSizeOld = ceil((float)m_xzSizeOld / m_hellScaleOld);
+ int hellXZSizeOld = ceil(static_cast<float>(m_xzSizeOld) / m_hellScaleOld);
while(hellXZSizeOld > HELL_LEVEL_MAX_WIDTH && m_hellScaleOld < HELL_LEVEL_MAX_SCALE)
{
diff --git a/Minecraft.World/LevelEventPacket.h b/Minecraft.World/LevelEventPacket.h
index 1d8c36e2..234f127d 100644
--- a/Minecraft.World/LevelEventPacket.h
+++ b/Minecraft.World/LevelEventPacket.h
@@ -21,6 +21,6 @@ public:
bool isGlobalEvent();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new LevelEventPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<LevelEventPacket>(); }
virtual int getId() { return 61; }
}; \ No newline at end of file
diff --git a/Minecraft.World/LevelParticlesPacket.h b/Minecraft.World/LevelParticlesPacket.h
index 7676f771..c7870a8e 100644
--- a/Minecraft.World/LevelParticlesPacket.h
+++ b/Minecraft.World/LevelParticlesPacket.h
@@ -34,6 +34,6 @@ public:
int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new LevelParticlesPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<LevelParticlesPacket>(); }
virtual int getId() { return 63; }
}; \ No newline at end of file
diff --git a/Minecraft.World/LevelSettings.cpp b/Minecraft.World/LevelSettings.cpp
index a81a4032..4f0536df 100644
--- a/Minecraft.World/LevelSettings.cpp
+++ b/Minecraft.World/LevelSettings.cpp
@@ -3,10 +3,10 @@
#include "net.minecraft.world.level.storage.h"
#include "LevelType.h"
-GameType *GameType::NOT_SET = NULL;
-GameType *GameType::SURVIVAL= NULL;
-GameType *GameType::CREATIVE = NULL;
-GameType *GameType::ADVENTURE = NULL;
+GameType *GameType::NOT_SET = nullptr;
+GameType *GameType::SURVIVAL= nullptr;
+GameType *GameType::CREATIVE = nullptr;
+GameType *GameType::ADVENTURE = nullptr;
void GameType::staticCtor()
{
diff --git a/Minecraft.World/LevelSoundPacket.cpp b/Minecraft.World/LevelSoundPacket.cpp
index cbe31a2d..cc2e29c4 100644
--- a/Minecraft.World/LevelSoundPacket.cpp
+++ b/Minecraft.World/LevelSoundPacket.cpp
@@ -20,9 +20,9 @@ LevelSoundPacket::LevelSoundPacket()
LevelSoundPacket::LevelSoundPacket(int sound, double x, double y, double z, float volume, float pitch)
{
this->sound = sound;
- this->x = (int) (x * LOCATION_ACCURACY);
- this->y = (int) (y * LOCATION_ACCURACY);
- this->z = (int) (z * LOCATION_ACCURACY);
+ this->x = static_cast<int>(x * LOCATION_ACCURACY);
+ this->y = static_cast<int>(y * LOCATION_ACCURACY);
+ this->z = static_cast<int>(z * LOCATION_ACCURACY);
this->volume = volume;
// 4J-PB - Let's make the pitch a float so it doesn't get mangled and make the noteblock people unhappy
//this->pitch = (int) (pitch * PITCH_ACCURACY);
diff --git a/Minecraft.World/LevelSoundPacket.h b/Minecraft.World/LevelSoundPacket.h
index 403ac092..e9ce356d 100644
--- a/Minecraft.World/LevelSoundPacket.h
+++ b/Minecraft.World/LevelSoundPacket.h
@@ -33,6 +33,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new LevelSoundPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<LevelSoundPacket>(); }
virtual int getId() { return 62; }
};
diff --git a/Minecraft.World/LevelStorage.h b/Minecraft.World/LevelStorage.h
index 25d2aba2..f0d2ac78 100644
--- a/Minecraft.World/LevelStorage.h
+++ b/Minecraft.World/LevelStorage.h
@@ -29,7 +29,7 @@ public:
virtual wstring getLevelId() = 0;
public:
- virtual ConsoleSaveFile *getSaveFile() { return NULL; }
+ virtual ConsoleSaveFile *getSaveFile() { return nullptr; }
virtual void flushSaveFile(bool autosave) {}
// 4J Added
diff --git a/Minecraft.World/LevelType.cpp b/Minecraft.World/LevelType.cpp
index 30b08132..924c8ab4 100644
--- a/Minecraft.World/LevelType.cpp
+++ b/Minecraft.World/LevelType.cpp
@@ -14,14 +14,14 @@
// private boolean replacement;
LevelType *LevelType::levelTypes[16];// = new LevelType[16];
-LevelType *LevelType::lvl_normal=NULL;// = new LevelType(0, "default", 1).setHasReplacement();
-LevelType *LevelType::lvl_flat=NULL;// = new LevelType(1, "flat");
-LevelType *LevelType::lvl_largeBiomes = NULL;// = new LevelType(2, "largeBiomes");
-LevelType *LevelType::lvl_normal_1_1=NULL;// = new LevelType(8, "default_1_1", 0).setSelectableByUser(false);
+LevelType *LevelType::lvl_normal=nullptr;// = new LevelType(0, "default", 1).setHasReplacement();
+LevelType *LevelType::lvl_flat=nullptr;// = new LevelType(1, "flat");
+LevelType *LevelType::lvl_largeBiomes = nullptr;// = new LevelType(2, "largeBiomes");
+LevelType *LevelType::lvl_normal_1_1=nullptr;// = new LevelType(8, "default_1_1", 0).setSelectableByUser(false);
void LevelType::staticCtor()
{
- for(int i=0;i<16;i++) levelTypes[i]=NULL;
+ for(int i=0;i<16;i++) levelTypes[i]=nullptr;
lvl_normal = new LevelType(0, L"default", 1);
lvl_normal->setHasReplacement();
lvl_flat = new LevelType(1, L"flat");
@@ -107,13 +107,13 @@ LevelType *LevelType::getLevelType(wstring name)
{
wstring genname=levelTypes[i]->m_generatorName;
- if (levelTypes[i] != NULL && (genname.compare(name)==0))
+ if (levelTypes[i] != nullptr && (genname.compare(name)==0))
{
return levelTypes[i];
}
}
}
- return NULL;
+ return nullptr;
}
int LevelType::getId()
diff --git a/Minecraft.World/LeverTile.cpp b/Minecraft.World/LeverTile.cpp
index eea9e3d3..7a7cdfd5 100644
--- a/Minecraft.World/LeverTile.cpp
+++ b/Minecraft.World/LeverTile.cpp
@@ -10,7 +10,7 @@ LeverTile::LeverTile(int id) : Tile(id, Material::decoration,isSolidRender())
AABB *LeverTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
bool LeverTile::blocksLight()
diff --git a/Minecraft.World/LightningBolt.cpp b/Minecraft.World/LightningBolt.cpp
index a109d96b..68ac77ef 100644
--- a/Minecraft.World/LightningBolt.cpp
+++ b/Minecraft.World/LightningBolt.cpp
@@ -78,11 +78,11 @@ void LightningBolt::tick()
life = 1;
seed = random->nextLong();
- if (!level->isClientSide && level->getGameRules()->getBoolean(GameRules::RULE_DOFIRETICK) && level->hasChunksAt( (int) floor(x), (int) floor(y), (int) floor(z), 10))
+ if (!level->isClientSide && level->getGameRules()->getBoolean(GameRules::RULE_DOFIRETICK) && level->hasChunksAt( static_cast<int>(floor(x)), static_cast<int>(floor(y)), static_cast<int>(floor(z)), 10))
{
- int xt = (int) floor(x);
- int yt = (int) floor(y);
- int zt = (int) floor(z);
+ int xt = static_cast<int>(floor(x));
+ int yt = static_cast<int>(floor(y));
+ int zt = static_cast<int>(floor(z));
// 4J added - don't go setting tiles if we aren't tracking them for network synchronisation
if( MinecraftServer::getInstance()->getPlayers()->isTrackingTile(xt, yt, zt, level->dimension->id) )
diff --git a/Minecraft.World/LiquidTile.cpp b/Minecraft.World/LiquidTile.cpp
index c31b6466..be6c582d 100644
--- a/Minecraft.World/LiquidTile.cpp
+++ b/Minecraft.World/LiquidTile.cpp
@@ -131,7 +131,7 @@ bool LiquidTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int f
AABB *LiquidTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
int LiquidTile::getRenderShape()
@@ -317,7 +317,7 @@ void LiquidTile::animateTick(Level *level, int x, int y, int z, Random *random)
{
if (random->nextInt(100) == 0)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
double xx = x + random->nextFloat();
double yy = y + tls->yy1;
double zz = z + random->nextFloat();
@@ -349,7 +349,7 @@ void LiquidTile::animateTick(Level *level, int x, int y, int z, Random *random)
double LiquidTile::getSlopeAngle(LevelSource *level, int x, int y, int z, Material *m)
{
- Vec3 *flow = NULL;
+ Vec3 *flow = nullptr;
if (m == Material::water) flow = ((LiquidTile *) Tile::water)->getFlow(level, x, y, z);
if (m == Material::lava) flow = ((LiquidTile *) Tile::lava)->getFlow(level, x, y, z);
if (flow->x == 0 && flow->z == 0) return -1000;
@@ -425,5 +425,5 @@ Icon *LiquidTile::getTexture(const wstring &name)
if (name.compare(TEXTURE_WATER_FLOW)==0) return Tile::water->icons[1];
if (name.compare(TEXTURE_LAVA_STILL)==0) return Tile::lava->icons[0];
if (name.compare(TEXTURE_LAVA_FLOW)==0) return Tile::lava->icons[1];
- return NULL;
+ return nullptr;
}
diff --git a/Minecraft.World/ListTag.h b/Minecraft.World/ListTag.h
index 69e51aee..2a0fdebc 100644
--- a/Minecraft.World/ListTag.h
+++ b/Minecraft.World/ListTag.h
@@ -18,7 +18,7 @@ public:
else type = 1;
dos->writeByte(type);
- dos->writeInt((int)list.size());
+ dos->writeInt(static_cast<int>(list.size()));
for ( auto& it : list )
it->write(dos);
@@ -83,12 +83,12 @@ public:
T *get(int index)
{
- return (T *) list[index];
+ return static_cast<T *>(list[index]);
}
int size()
{
- return (int)list.size();
+ return static_cast<int>(list.size());
}
virtual ~ListTag()
@@ -105,7 +105,7 @@ public:
res->type = type;
for ( auto& it : list )
{
- T *copy = (T *) it->copy();
+ T *copy = static_cast<T *>(it->copy());
res->list.push_back(copy);
}
return res;
@@ -115,7 +115,7 @@ public:
{
if (Tag::equals(obj))
{
- ListTag *o = (ListTag *) obj;
+ ListTag *o = static_cast<ListTag *>(obj);
if (type == o->type)
{
bool equal = false;
diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp
index ce702676..3ace8806 100644
--- a/Minecraft.World/LivingEntity.cpp
+++ b/Minecraft.World/LivingEntity.cpp
@@ -39,7 +39,7 @@ AttributeModifier *LivingEntity::SPEED_MODIFIER_SPRINTING = (new AttributeModifi
void LivingEntity::_init()
{
- attributes = NULL;
+ attributes = nullptr;
combatTracker = new CombatTracker(this);
lastEquipment = ItemInstanceArray(5);
@@ -107,10 +107,10 @@ LivingEntity::LivingEntity( Level* level) : Entity(level)
blocksBuilding = true;
- rotA = (float) (Math::random() + 1) * 0.01f;
+ rotA = static_cast<float>(Math::random() + 1) * 0.01f;
setPos(x, y, z);
- timeOffs = (float) Math::random() * 12398;
- yRot = (float) (Math::random() * PI * 2);
+ timeOffs = static_cast<float>(Math::random()) * 12398;
+ yRot = static_cast<float>(Math::random() * PI * 2);
yHeadRot = yRot;
footSize = 0.5f;
@@ -126,14 +126,14 @@ LivingEntity::~LivingEntity()
delete attributes;
delete combatTracker;
- if(lastEquipment.data != NULL) delete [] lastEquipment.data;
+ if(lastEquipment.data != nullptr) delete [] lastEquipment.data;
}
void LivingEntity::defineSynchedData()
{
entityData->define(DATA_EFFECT_COLOR_ID, 0);
- entityData->define(DATA_EFFECT_AMBIENCE_ID, (byte) 0);
- entityData->define(DATA_ARROW_COUNT_ID, (byte) 0);
+ entityData->define(DATA_EFFECT_AMBIENCE_ID, static_cast<byte>(0));
+ entityData->define(DATA_ARROW_COUNT_ID, static_cast<byte>(0));
entityData->define(DATA_HEALTH_ID, 1.0f);
}
@@ -198,7 +198,7 @@ void LivingEntity::baseTick()
if (isFireImmune() || level->isClientSide) clearFire();
shared_ptr<Player> thisPlayer = dynamic_pointer_cast<Player>(shared_from_this());
- bool isInvulnerable = (thisPlayer != NULL && thisPlayer->abilities.invulnerable);
+ bool isInvulnerable = (thisPlayer != nullptr && thisPlayer->abilities.invulnerable);
if (isAlive() && isUnderLiquid(Material::water))
{
@@ -253,13 +253,13 @@ void LivingEntity::baseTick()
lastHurtByPlayer.reset();
}
}
- if (lastHurtMob != NULL && !lastHurtMob->isAlive())
+ if (lastHurtMob != nullptr && !lastHurtMob->isAlive())
{
lastHurtMob = nullptr;
}
// If lastHurtByMob is dead, remove it
- if (lastHurtByMob != NULL && !lastHurtByMob->isAlive())
+ if (lastHurtByMob != nullptr && !lastHurtByMob->isAlive())
{
setLastHurtByMob(nullptr);
}
@@ -295,7 +295,7 @@ void LivingEntity::tickDeath()
{
int newCount = ExperienceOrb::getExperienceValue(xpCount);
xpCount -= newCount;
- level->addEntity(shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x, y, z, newCount) ) );
+ level->addEntity(std::make_shared<ExperienceOrb>(level, x, y, z, newCount));
}
}
}
@@ -391,17 +391,17 @@ int LivingEntity::getNoActionTime()
void LivingEntity::addAdditonalSaveData(CompoundTag *entityTag)
{
entityTag->putFloat(L"HealF", getHealth());
- entityTag->putShort(L"Health", (short) ceil(getHealth()));
- entityTag->putShort(L"HurtTime", (short) hurtTime);
- entityTag->putShort(L"DeathTime", (short) deathTime);
- entityTag->putShort(L"AttackTime", (short) attackTime);
+ entityTag->putShort(L"Health", static_cast<short>(ceil(getHealth())));
+ entityTag->putShort(L"HurtTime", static_cast<short>(hurtTime));
+ entityTag->putShort(L"DeathTime", static_cast<short>(deathTime));
+ entityTag->putShort(L"AttackTime", static_cast<short>(attackTime));
entityTag->putFloat(L"AbsorptionAmount", getAbsorptionAmount());
ItemInstanceArray items = getEquipmentSlots();
for (unsigned int i = 0; i < items.length; ++i)
{
shared_ptr<ItemInstance> item = items[i];
- if (item != NULL)
+ if (item != nullptr)
{
attributes->removeItemModifiers(item);
}
@@ -412,7 +412,7 @@ void LivingEntity::addAdditonalSaveData(CompoundTag *entityTag)
for (unsigned int i = 0; i < items.length; ++i)
{
shared_ptr<ItemInstance> item = items[i];
- if (item != NULL)
+ if (item != nullptr)
{
attributes->addItemModifiers(item);
}
@@ -435,7 +435,7 @@ void LivingEntity::readAdditionalSaveData(CompoundTag *tag)
{
setAbsorptionAmount(tag->getFloat(L"AbsorptionAmount"));
- if (tag->contains(L"Attributes") && level != NULL && !level->isClientSide)
+ if (tag->contains(L"Attributes") && level != nullptr && !level->isClientSide)
{
SharedMonsterAttributes::loadAttributes(getAttributes(), (ListTag<CompoundTag> *) tag->getList(L"Attributes"));
}
@@ -458,18 +458,18 @@ void LivingEntity::readAdditionalSaveData(CompoundTag *tag)
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);
+ setHealth(static_cast<FloatTag *>(healthTag)->data);
}
else if (healthTag->getId() == Tag::TAG_Short)
{
// pre-1.6 health
- setHealth((float) ((ShortTag *) healthTag)->data);
+ setHealth((float) static_cast<ShortTag *>(healthTag)->data);
}
}
@@ -512,7 +512,7 @@ void LivingEntity::tickEffects()
{
if (activeEffects.empty())
{
- entityData->set(DATA_EFFECT_AMBIENCE_ID, (byte) 0);
+ entityData->set(DATA_EFFECT_AMBIENCE_ID, static_cast<byte>(0));
entityData->set(DATA_EFFECT_COLOR_ID, 0);
setInvisible(false);
setWeakened(false);
@@ -525,7 +525,7 @@ void LivingEntity::tickEffects()
values.push_back(it.second);
}
int colorValue = PotionBrewing::getColorValue(&values);
- entityData->set(DATA_EFFECT_AMBIENCE_ID, PotionBrewing::areAllEffectsAmbient(&values) ? (byte) 1 : (byte) 0);
+ entityData->set(DATA_EFFECT_AMBIENCE_ID, PotionBrewing::areAllEffectsAmbient(&values) ? static_cast<byte>(1) : static_cast<byte>(0));
values.clear();
entityData->set(DATA_EFFECT_COLOR_ID, colorValue);
setInvisible(hasEffect(MobEffect::invisibility->id));
@@ -558,9 +558,9 @@ void LivingEntity::tickEffects()
// int colorValue = entityData.getInteger(DATA_EFFECT_COLOR_ID);
if (colorValue > 0)
{
- double red = (double) ((colorValue >> 16) & 0xff) / 255.0;
- double green = (double) ((colorValue >> 8) & 0xff) / 255.0;
- double blue = (double) ((colorValue >> 0) & 0xff) / 255.0;
+ double red = static_cast<double>((colorValue >> 16) & 0xff) / 255.0;
+ double green = static_cast<double>((colorValue >> 8) & 0xff) / 255.0;
+ double blue = static_cast<double>((colorValue >> 0) & 0xff) / 255.0;
level->addParticle(ambient? eParticleType_mobSpellAmbient : eParticleType_mobSpell, x + (random->nextDouble() - 0.5) * bbWidth, y + random->nextDouble() * bbHeight - heightOffset, z + (random->nextDouble() - 0.5) * bbWidth, red, green, blue);
}
@@ -611,7 +611,7 @@ bool LivingEntity::hasEffect(MobEffect *effect)
MobEffectInstance *LivingEntity::getEffect(MobEffect *effect)
{
- MobEffectInstance *effectInst = NULL;
+ MobEffectInstance *effectInst = nullptr;
auto it = activeEffects.find(effect->id);
if(it != activeEffects.end() ) effectInst = it->second;
@@ -685,7 +685,7 @@ void LivingEntity::removeEffectNoUpdate(int effectId)
if (it != activeEffects.end())
{
MobEffectInstance *effect = it->second;
- if(effect != NULL)
+ if(effect != nullptr)
{
delete effect;
}
@@ -699,7 +699,7 @@ void LivingEntity::removeEffect(int effectId)
if (it != activeEffects.end())
{
MobEffectInstance *effect = it->second;
- if(effect != NULL)
+ if(effect != nullptr)
{
onEffectRemoved(effect);
delete effect;
@@ -757,8 +757,8 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
// Fix for #8823 - Gameplay: Confirmation that a monster or animal has taken damage from an attack is highly delayed
// 4J Stu - Change to the fix to only show damage when attacked, rather than collision damage
// Fix for #10299 - When in corners, passive mobs may show that they are taking damage.
- // 4J Stu - Change to the fix for TU6, as source is never NULL due to changes in 1.8.2 to what source actually is
- if (level->isClientSide && dynamic_cast<EntityDamageSource *>(source) == NULL) return false;
+ // 4J Stu - Change to the fix for TU6, as source is never nullptr due to changes in 1.8.2 to what source actually is
+ if (level->isClientSide && dynamic_cast<EntityDamageSource *>(source) == nullptr) return false;
noActionTime = 0;
if (getHealth() <= 0) return false;
@@ -773,9 +773,9 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
return false;
}
- if ((source == DamageSource::anvil || source == DamageSource::fallingBlock) && getCarried(SLOT_HELM) != NULL)
+ if ((source == DamageSource::anvil || source == DamageSource::fallingBlock) && getCarried(SLOT_HELM) != nullptr)
{
- getCarried(SLOT_HELM)->hurtAndBreak((int) (dmg * 4 + random->nextFloat() * dmg * 2.0f), dynamic_pointer_cast<LivingEntity>( shared_from_this() ));
+ getCarried(SLOT_HELM)->hurtAndBreak(static_cast<int>(dmg * 4 + random->nextFloat() * dmg * 2.0f), dynamic_pointer_cast<LivingEntity>( shared_from_this() ));
dmg *= 0.75f;
}
@@ -801,7 +801,7 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
hurtDir = 0;
shared_ptr<Entity> sourceEntity = source->getEntity();
- if (sourceEntity != NULL)
+ if (sourceEntity != nullptr)
{
if ( sourceEntity->instanceof(eTYPE_LIVINGENTITY) )
{
@@ -833,7 +833,7 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
{
level->broadcastEntityEvent(shared_from_this(), EntityEvent::HURT);
if (source != DamageSource::drown) markHurt();
- if (sourceEntity != NULL)
+ if (sourceEntity != nullptr)
{
double xd = sourceEntity->x - x;
double zd = sourceEntity->z - z;
@@ -842,12 +842,12 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
xd = (Math::random() - Math::random()) * 0.01;
zd = (Math::random() - Math::random()) * 0.01;
}
- hurtDir = (float) (atan2(zd, xd) * 180 / PI) - yRot;
+ hurtDir = static_cast<float>(atan2(zd, xd) * 180 / PI) - yRot;
knockback(sourceEntity, dmg, xd, zd);
}
else
{
- hurtDir = (float) (int) ((Math::random() * 2) * 180); // 4J This cast is the same as Java
+ hurtDir = static_cast<float>((int)((Math::random() * 2) * 180)); // 4J This cast is the same as Java
}
}
@@ -888,9 +888,9 @@ void LivingEntity::die(DamageSource *source)
{
shared_ptr<Entity> sourceEntity = source->getEntity();
shared_ptr<LivingEntity> killer = getKillCredit();
- if (deathScore >= 0 && killer != NULL) killer->awardKillScore(shared_from_this(), deathScore);
+ if (deathScore >= 0 && killer != nullptr) killer->awardKillScore(shared_from_this(), deathScore);
- if (sourceEntity != NULL) sourceEntity->killed( dynamic_pointer_cast<LivingEntity>( shared_from_this() ) );
+ if (sourceEntity != nullptr) sourceEntity->killed( dynamic_pointer_cast<LivingEntity>( shared_from_this() ) );
dead = true;
@@ -899,7 +899,7 @@ void LivingEntity::die(DamageSource *source)
int playerBonus = 0;
shared_ptr<Player> player = nullptr;
- if ( (sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_PLAYER) )
+ if ( (sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_PLAYER) )
{
player = dynamic_pointer_cast<Player>(sourceEntity);
playerBonus = EnchantmentHelper::getKillingLootBonus(dynamic_pointer_cast<LivingEntity>(player));
@@ -920,7 +920,7 @@ void LivingEntity::die(DamageSource *source)
}
// 4J-JEV, hook for Durango mobKill event.
- if (player != NULL)
+ if (player != nullptr)
{
player->awardStat(GenericStats::killMob(),GenericStats::param_mobKill(player, dynamic_pointer_cast<Mob>(shared_from_this()), source));
}
@@ -1005,9 +1005,9 @@ 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);
+ int dmg = static_cast<int>(ceil(distance - 3 - padding));
if (dmg > 0)
{
// 4J - new sounds here brought forward from 1.2.3
@@ -1050,9 +1050,9 @@ int LivingEntity::getArmorValue()
for (unsigned int i = 0; i < items.length; ++i)
{
shared_ptr<ItemInstance> item = items[i];
- if (item != NULL && dynamic_cast<ArmorItem *>(item->getItem()) != NULL)
+ if (item != nullptr && dynamic_cast<ArmorItem *>(item->getItem()) != nullptr)
{
- int baseProtection = ((ArmorItem *) item->getItem())->defense;
+ int baseProtection = static_cast<ArmorItem *>(item->getItem())->defense;
val += baseProtection;
}
}
@@ -1131,15 +1131,15 @@ CombatTracker *LivingEntity::getCombatTracker()
shared_ptr<LivingEntity> 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;
}
float LivingEntity::getMaxHealth()
{
- return (float) getAttribute(SharedMonsterAttributes::MAX_HEALTH)->getValue();
+ return static_cast<float>(getAttribute(SharedMonsterAttributes::MAX_HEALTH)->getValue());
}
int LivingEntity::getArrowCount()
@@ -1149,7 +1149,7 @@ int LivingEntity::getArrowCount()
void LivingEntity::setArrowCount(int count)
{
- entityData->set(DATA_ARROW_COUNT_ID, (byte) count);
+ entityData->set(DATA_ARROW_COUNT_ID, static_cast<byte>(count));
}
int LivingEntity::getCurrentSwingDuration()
@@ -1172,9 +1172,9 @@ void LivingEntity::swing()
swingTime = -1;
swinging = true;
- if (dynamic_cast<ServerLevel *>(level) != NULL)
+ if (dynamic_cast<ServerLevel *>(level) != nullptr)
{
- ((ServerLevel *) level)->getTracker()->broadcast(shared_from_this(), shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::SWING)));
+ static_cast<ServerLevel *>(level)->getTracker()->broadcast(shared_from_this(), std::make_shared<AnimatePacket>(shared_from_this(), AnimatePacket::SWING));
}
}
}
@@ -1240,7 +1240,7 @@ void LivingEntity::updateSwingTime()
swingTime = 0;
}
- attackAnim = swingTime / (float) currentSwingDuration;
+ attackAnim = swingTime / static_cast<float>(currentSwingDuration);
}
AttributeInstance *LivingEntity::getAttribute(Attribute *attribute)
@@ -1250,7 +1250,7 @@ AttributeInstance *LivingEntity::getAttribute(Attribute *attribute)
BaseAttributeMap *LivingEntity::getAttributes()
{
- if (attributes == NULL)
+ if (attributes == nullptr)
{
attributes = new ServersideAttributeMap();
}
@@ -1268,7 +1268,7 @@ void LivingEntity::setSprinting(bool value)
Entity::setSprinting(value);
AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED);
- if (speed->getModifier(eModifierId_MOB_SPRINTING) != NULL)
+ if (speed->getModifier(eModifierId_MOB_SPRINTING) != nullptr)
{
speed->removeModifier(eModifierId_MOB_SPRINTING);
}
@@ -1378,7 +1378,7 @@ void LivingEntity::travel(float xa, float ya)
{
#ifdef __PSVITA__
// AP - dynamic_pointer_cast is a non-trivial call
- Player *thisPlayer = NULL;
+ Player *thisPlayer = nullptr;
if( this->instanceof(eTYPE_PLAYER) )
{
thisPlayer = (Player*) this;
@@ -1474,7 +1474,7 @@ void LivingEntity::travel(float xa, float ya)
yd = 0.2;
}
- if (!level->isClientSide || (level->hasChunkAt((int) x, 0, (int) z) && level->getChunkAt((int) x, (int) z)->loaded))
+ if (!level->isClientSide || (level->hasChunkAt(static_cast<int>(x), 0, static_cast<int>(z)) && level->getChunkAt(static_cast<int>(x), static_cast<int>(z))->loaded))
{
yd -= 0.08;
}
@@ -1517,12 +1517,12 @@ int LivingEntity::getLightColor(float a)
for( int yt = ymin; yt <= ymax; yt++ )
for( int zt = zmin; zt <= zmax; zt++ )
{
- float tilexmin = (float)xt;
- float tilexmax = (float)(xt+1);
- float tileymin = (float)yt;
- float tileymax = (float)(yt+1);
- float tilezmin = (float)zt;
- float tilezmax = (float)(zt+1);
+ float tilexmin = static_cast<float>(xt);
+ float tilexmax = static_cast<float>(xt + 1);
+ float tileymin = static_cast<float>(yt);
+ float tileymax = static_cast<float>(yt + 1);
+ float tilezmin = static_cast<float>(zt);
+ float tilezmax = static_cast<float>(zt + 1);
if( tilexmin < bb->x0 ) tilexmin = bb->x0;
if( tilexmax > bb->x1 ) tilexmax = bb->x1;
if( tileymin < bb->y0 ) tileymin = bb->y0;
@@ -1532,14 +1532,14 @@ int LivingEntity::getLightColor(float a)
float tileVol = ( tilexmax - tilexmin ) * ( tileymax - tileymin ) * ( tilezmax - tilezmin );
float frac = tileVol / totVol;
int lc = level->getLightColor(xt, yt, zt, 0);
- accum[0] += frac * (float)( lc & 0xffff );
- accum[1] += frac * (float)( lc >> 16 );
+ accum[0] += frac * static_cast<float>(lc & 0xffff);
+ accum[1] += frac * static_cast<float>(lc >> 16);
}
if( accum[0] > 240.0f ) accum[0] = 240.0f;
if( accum[1] > 240.0f ) accum[1] = 240.0f;
- return ( ( (int)accum[1])<<16) | ((int)accum[0]);
+ return ( static_cast<int>(accum[1])<<16) | static_cast<int>(accum[0]);
}
bool LivingEntity::useNewAi()
@@ -1602,10 +1602,10 @@ void LivingEntity::tick()
if (!ItemInstance::matches(current, previous))
{
- ((ServerLevel *) level)->getTracker()->broadcast(shared_from_this(), shared_ptr<SetEquippedItemPacket>( new SetEquippedItemPacket(entityId, i, current)));
- if (previous != NULL) attributes->removeItemModifiers(previous);
- if (current != NULL) attributes->addItemModifiers(current);
- lastEquipment[i] = current == NULL ? nullptr : current->copy();
+ static_cast<ServerLevel *>(level)->getTracker()->broadcast(shared_from_this(), std::make_shared<SetEquippedItemPacket>(entityId, i, current));
+ if (previous != nullptr) attributes->removeItemModifiers(previous);
+ if (current != nullptr) attributes->addItemModifiers(current);
+ lastEquipment[i] = current == nullptr ? nullptr : current->copy();
}
}
}
@@ -1626,7 +1626,7 @@ void LivingEntity::tick()
{
tRun = 1;
walkSpeed = sqrt(sideDist) * 3;
- yBodyRotT = ((float) atan2(zd, xd) * 180 / (float) PI - 90);
+ yBodyRotT = (static_cast<float>(atan2(zd, xd)) * 180 / (float) PI - 90);
}
if (attackAnim > 0)
{
@@ -1698,8 +1698,8 @@ void LivingEntity::aiStep()
double yrd = Mth::wrapDegrees(lyr - yRot);
double xrd = Mth::wrapDegrees(lxr - xRot);
- yRot += (float) ( (yrd) / lSteps );
- xRot += (float) ( (xrd) / lSteps );
+ yRot += static_cast<float>((yrd) / lSteps);
+ xRot += static_cast<float>((xrd) / lSteps);
lSteps--;
setPos(xt, yt, zt);
@@ -1804,7 +1804,7 @@ void LivingEntity::pushEntities()
{
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), this->bb->grow(0.2f, 0, 0.2f));
- if (entities != NULL && !entities->empty())
+ if (entities != nullptr && !entities->empty())
{
for (auto& e : *entities)
{
@@ -1857,18 +1857,18 @@ void LivingEntity::take(shared_ptr<Entity> e, int orgCount)
{
if (!e->removed && !level->isClientSide)
{
- EntityTracker *entityTracker = ((ServerLevel *) level)->getTracker();
+ EntityTracker *entityTracker = static_cast<ServerLevel *>(level)->getTracker();
if ( e->instanceof(eTYPE_ITEMENTITY) )
{
- entityTracker->broadcast(e, shared_ptr<TakeItemEntityPacket>( new TakeItemEntityPacket(e->entityId, entityId)));
+ entityTracker->broadcast(e, std::make_shared<TakeItemEntityPacket>(e->entityId, entityId));
}
else if ( e->instanceof(eTYPE_ARROW) )
{
- entityTracker->broadcast(e, shared_ptr<TakeItemEntityPacket>( new TakeItemEntityPacket(e->entityId, entityId)));
+ entityTracker->broadcast(e, std::make_shared<TakeItemEntityPacket>(e->entityId, entityId));
}
else if ( e->instanceof(eTYPE_EXPERIENCEORB) )
{
- entityTracker->broadcast(e, shared_ptr<TakeItemEntityPacket>( new TakeItemEntityPacket(e->entityId, entityId)));
+ entityTracker->broadcast(e, std::make_shared<TakeItemEntityPacket>(e->entityId, entityId));
}
}
}
@@ -1876,7 +1876,7 @@ void LivingEntity::take(shared_ptr<Entity> e, int orgCount)
bool LivingEntity::canSee(shared_ptr<Entity> target)
{
HitResult *hres = level->clip(Vec3::newTemp(x, y + getHeadHeight(), z), Vec3::newTemp(target->x, target->y + target->getHeadHeight(), target->z));
- bool retVal = (hres == NULL);
+ bool retVal = (hres == nullptr);
delete hres;
return retVal;
}
@@ -1984,7 +1984,7 @@ void LivingEntity::setAbsorptionAmount(float absorptionAmount)
Team *LivingEntity::getTeam()
{
- return NULL;
+ return nullptr;
}
bool LivingEntity::isAlliedTo(shared_ptr<LivingEntity> other)
@@ -1994,7 +1994,7 @@ bool LivingEntity::isAlliedTo(shared_ptr<LivingEntity> other)
bool LivingEntity::isAlliedTo(Team *other)
{
- if (getTeam() != NULL)
+ if (getTeam() != nullptr)
{
return getTeam()->isAlliedTo(other);
}
diff --git a/Minecraft.World/LivingEntity.h b/Minecraft.World/LivingEntity.h
index 5869eeb2..ecc819df 100644
--- a/Minecraft.World/LivingEntity.h
+++ b/Minecraft.World/LivingEntity.h
@@ -26,7 +26,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/LoginPacket.cpp b/Minecraft.World/LoginPacket.cpp
index 44ed62b3..79cdfbae 100644
--- a/Minecraft.World/LoginPacket.cpp
+++ b/Minecraft.World/LoginPacket.cpp
@@ -30,7 +30,7 @@ LoginPacket::LoginPacket()
m_playerCapeId = 0;
m_isGuest = false;
m_newSeaLevel = false;
- m_pLevelType = NULL;
+ m_pLevelType = nullptr;
m_uiGamePrivileges = 0;
m_xzSize = LEVEL_MAX_WIDTH;
m_hellScale = HELL_LEVEL_MAX_SCALE;
@@ -59,7 +59,7 @@ LoginPacket::LoginPacket(const wstring& userName, int clientVersion, PlayerUID o
m_playerCapeId = capeId;
m_isGuest = isGuest;
m_newSeaLevel = false;
- m_pLevelType = NULL;
+ m_pLevelType = nullptr;
m_uiGamePrivileges = 0;
m_xzSize = LEVEL_MAX_WIDTH;
m_hellScale = HELL_LEVEL_MAX_SCALE;
@@ -100,7 +100,7 @@ void LoginPacket::read(DataInputStream *dis) //throws IOException
userName = readUtf(dis, Player::MAX_NAME_LENGTH);
wstring typeName = readUtf(dis, 16);
m_pLevelType = LevelType::getLevelType(typeName);
- if (m_pLevelType == NULL)
+ if (m_pLevelType == nullptr)
{
m_pLevelType = LevelType::lvl_normal;
}
@@ -135,7 +135,7 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(clientVersion);
writeUtf(userName, dos);
- if (m_pLevelType == NULL)
+ if (m_pLevelType == nullptr)
{
writeUtf(L"", dos);
}
@@ -174,10 +174,10 @@ 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();
+ length = static_cast<int>(m_pLevelType->getGeneratorName().length());
}
- return (int)(sizeof(int) + userName.length() + 4 + 6 + sizeof(int64_t) + sizeof(char) + sizeof(int) + (2*sizeof(PlayerUID)) +1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int));
+ return static_cast<int>(sizeof(int) + userName.length() + 4 + 6 + sizeof(int64_t) + sizeof(char) + sizeof(int) + (2 * sizeof(PlayerUID)) + 1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int));
}
diff --git a/Minecraft.World/LoginPacket.h b/Minecraft.World/LoginPacket.h
index bf7164fa..02a62b60 100644
--- a/Minecraft.World/LoginPacket.h
+++ b/Minecraft.World/LoginPacket.h
@@ -40,6 +40,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new LoginPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<LoginPacket>(); }
virtual int getId() { return 1; }
};
diff --git a/Minecraft.World/LongTag.h b/Minecraft.World/LongTag.h
index 6a016715..36ed4de9 100644
--- a/Minecraft.World/LongTag.h
+++ b/Minecraft.World/LongTag.h
@@ -28,7 +28,7 @@ public:
{
if (Tag::equals(obj))
{
- LongTag *o = (LongTag *) obj;
+ LongTag *o = static_cast<LongTag *>(obj);
return data == o->data;
}
return false;
diff --git a/Minecraft.World/LookAtPlayerGoal.cpp b/Minecraft.World/LookAtPlayerGoal.cpp
index dcf1ea4f..a2e4786a 100644
--- a/Minecraft.World/LookAtPlayerGoal.cpp
+++ b/Minecraft.World/LookAtPlayerGoal.cpp
@@ -29,7 +29,7 @@ bool LookAtPlayerGoal::canUse()
{
if (mob->getRandom()->nextFloat() >= probability) return false;
- if (mob->getTarget() != NULL)
+ if (mob->getTarget() != nullptr)
{
lookAt = mob->getTarget();
}
@@ -41,12 +41,12 @@ bool LookAtPlayerGoal::canUse()
{
lookAt = weak_ptr<Entity>(mob->level->getClosestEntityOfClass(lookAtType, mob->bb->grow(lookDistance, 3, lookDistance), mob->shared_from_this()));
}
- return lookAt.lock() != NULL;
+ return lookAt.lock() != nullptr;
}
bool LookAtPlayerGoal::canContinueToUse()
{
- if (lookAt.lock() == NULL || !lookAt.lock()->isAlive()) return false;
+ if (lookAt.lock() == nullptr || !lookAt.lock()->isAlive()) return false;
if (mob->distanceToSqr(lookAt.lock()) > lookDistance * lookDistance) return false;
return lookTime > 0;
}
diff --git a/Minecraft.World/LookAtTradingPlayerGoal.cpp b/Minecraft.World/LookAtTradingPlayerGoal.cpp
index db1e25a2..9b50f0e7 100644
--- a/Minecraft.World/LookAtTradingPlayerGoal.cpp
+++ b/Minecraft.World/LookAtTradingPlayerGoal.cpp
@@ -3,7 +3,7 @@
#include "net.minecraft.world.entity.npc.h"
#include "LookAtTradingPlayerGoal.h"
-LookAtTradingPlayerGoal::LookAtTradingPlayerGoal(Villager *villager) : LookAtPlayerGoal((Mob *)villager, typeid(Player), 8)
+LookAtTradingPlayerGoal::LookAtTradingPlayerGoal(Villager *villager) : LookAtPlayerGoal(static_cast<Mob *>(villager), typeid(Player), 8)
{
this->villager = villager;
}
diff --git a/Minecraft.World/LookControl.cpp b/Minecraft.World/LookControl.cpp
index 1e0d5258..8eff9bca 100644
--- a/Minecraft.World/LookControl.cpp
+++ b/Minecraft.World/LookControl.cpp
@@ -47,8 +47,8 @@ void LookControl::tick()
double zd = wantedZ - mob->z;
double sd = sqrt(xd * xd + zd * zd);
- float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90;
- float xRotD = (float) -(atan2(yd, sd) * 180 / PI);
+ float yRotD = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
+ float xRotD = static_cast<float>(-(atan2(yd, sd) * 180 / PI));
mob->xRot = rotlerp(mob->xRot, xRotD, xMax);
mob->yHeadRot = rotlerp(mob->yHeadRot, yRotD, yMax);
}
diff --git a/Minecraft.World/MakeLoveGoal.cpp b/Minecraft.World/MakeLoveGoal.cpp
index c399d632..c308e33c 100644
--- a/Minecraft.World/MakeLoveGoal.cpp
+++ b/Minecraft.World/MakeLoveGoal.cpp
@@ -26,11 +26,11 @@ bool MakeLoveGoal::canUse()
if (villager->getRandom()->nextInt(500) != 0) return false;
village = level->villages->getClosestVillage(Mth::floor(villager->x), Mth::floor(villager->y), Mth::floor(villager->z), 0);
- if (village.lock() == NULL) return false;
+ if (village.lock() == nullptr) return false;
if (!villageNeedsMoreVillagers()) return false;
shared_ptr<Entity> mate = level->getClosestEntityOfClass(typeid(Villager), villager->bb->grow(8, 3, 8), villager->shared_from_this());
- if (mate == NULL) return false;
+ if (mate == nullptr) return false;
partner = weak_ptr<Villager>(dynamic_pointer_cast<Villager>(mate));
if (partner.lock()->getAge() != 0) return false;
@@ -53,7 +53,7 @@ void MakeLoveGoal::stop()
bool MakeLoveGoal::canContinueToUse()
{
- return partner.lock() != NULL && loveMakingTime >= 0 && villageNeedsMoreVillagers() && villager->getAge() == 0;
+ return partner.lock() != nullptr && loveMakingTime >= 0 && villageNeedsMoreVillagers() && villager->getAge() == 0;
}
void MakeLoveGoal::tick()
@@ -76,14 +76,14 @@ void MakeLoveGoal::tick()
bool MakeLoveGoal::villageNeedsMoreVillagers()
{
shared_ptr<Village> _village = village.lock();
- if( _village == NULL ) return false;
+ if( _village == nullptr ) return false;
if (!_village->isBreedTimerOk())
{
return false;
}
- int idealSize = (int) ((float) _village->getDoorCount() * 0.35);
+ int idealSize = static_cast<int>((float)_village->getDoorCount() * 0.35);
// System.out.println("idealSize: " + idealSize + " pop: " +
// village.getPopulationSize());
return _village->getPopulationSize() < idealSize;
diff --git a/Minecraft.World/MapItem.cpp b/Minecraft.World/MapItem.cpp
index 03529c1a..61c203e3 100644
--- a/Minecraft.World/MapItem.cpp
+++ b/Minecraft.World/MapItem.cpp
@@ -24,7 +24,7 @@ shared_ptr<MapItemSavedData> MapItem::getSavedData(short idNum, Level *level)
std::wstring id = wstring( L"map_" ) + std::to_wstring(idNum);
shared_ptr<MapItemSavedData> mapItemSavedData = dynamic_pointer_cast<MapItemSavedData>(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
@@ -32,7 +32,7 @@ shared_ptr<MapItemSavedData> MapItem::getSavedData(short idNum, Level *level)
int aux = idNum;
id = wstring( L"map_" ) + std::to_wstring(aux);
- mapItemSavedData = shared_ptr<MapItemSavedData>( new MapItemSavedData(id) );
+ mapItemSavedData = std::make_shared<MapItemSavedData>(id);
level->setSavedData(id, (shared_ptr<SavedData> ) mapItemSavedData);
}
@@ -48,14 +48,14 @@ shared_ptr<MapItemSavedData> MapItem::getSavedData(shared_ptr<ItemInstance> item
shared_ptr<MapItemSavedData> mapItemSavedData = dynamic_pointer_cast<MapItemSavedData>( 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
//itemInstance->setAuxValue(level->getFreeAuxValueFor(L"map"));
id = wstring( L"map_" ) + std::to_wstring(itemInstance->getAuxValue() );
- mapItemSavedData = shared_ptr<MapItemSavedData>( new MapItemSavedData(id) );
+ mapItemSavedData = std::make_shared<MapItemSavedData>(id);
newData = true;
}
@@ -71,10 +71,10 @@ shared_ptr<MapItemSavedData> MapItem::getSavedData(shared_ptr<ItemInstance> item
{
#ifdef _LARGE_WORLDS
int scale = MapItemSavedData::MAP_SIZE * 2 * (1 << mapItemSavedData->scale);
- mapItemSavedData->x = Math::round((float) level->getLevelData()->getXSpawn() / scale) * scale;
+ mapItemSavedData->x = Math::round(static_cast<float>(level->getLevelData()->getXSpawn()) / scale) * scale;
mapItemSavedData->z = Math::round(level->getLevelData()->getZSpawn() / scale) * scale;
#endif
- mapItemSavedData->dimension = (byte) level->dimension->id;
+ mapItemSavedData->dimension = static_cast<byte>(level->dimension->id);
mapItemSavedData->setDirty();
@@ -190,7 +190,7 @@ void MapItem::update(Level *level, shared_ptr<Entity> player, shared_ptr<MapItem
} while (y > 0 && below != 0 && Tile::tiles[below]->material->isLiquid());
}
}
- hh += yy / (double) (scale * scale);
+ hh += yy / static_cast<double>(scale * scale);
count[t]++;
}
@@ -237,7 +237,7 @@ void MapItem::update(Level *level, shared_ptr<Entity> player, shared_ptr<MapItem
continue;
}
byte oldColor = data->colors[x + z * w];
- byte newColor = (byte) (col * 4 + br);
+ byte newColor = static_cast<byte>(col * 4 + br);
if (oldColor != newColor)
{
if (yd0 > z) yd0 = z;
@@ -295,9 +295,9 @@ shared_ptr<Packet> MapItem::getUpdatePacket(shared_ptr<ItemInstance> itemInstanc
{
charArray data = MapItem::getSavedData(itemInstance, level)->getUpdatePacket(itemInstance, level, player);
- if (data.data == NULL || data.length == 0) return nullptr;
+ if (data.data == nullptr || data.length == 0) return nullptr;
- shared_ptr<Packet> retval = shared_ptr<Packet>(new ComplexItemDataPacket((short) Item::map->id, (short) itemInstance->getAuxValue(), data));
+ shared_ptr<Packet> retval = std::make_shared<ComplexItemDataPacket>(static_cast<short>(Item::map->id), static_cast<short>(itemInstance->getAuxValue()), data);
delete data.data;
return retval;
}
@@ -309,8 +309,8 @@ void MapItem::onCraftedBy(shared_ptr<ItemInstance> itemInstance, Level *level, s
int mapScale = 3;
#ifdef _LARGE_WORLDS
int scale = MapItemSavedData::MAP_SIZE * 2 * (1 << mapScale);
- int centreXC = (int) (Math::round(player->x / scale) * scale);
- int centreZC = (int) (Math::round(player->z / scale) * scale);
+ int centreXC = static_cast<int>(Math::round(player->x / scale) * scale);
+ int centreZC = static_cast<int>(Math::round(player->z / scale) * scale);
#else
// 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map
int centreXC = 0;
@@ -325,9 +325,9 @@ void MapItem::onCraftedBy(shared_ptr<ItemInstance> itemInstance, Level *level, s
shared_ptr<MapItemSavedData> data = getSavedData(itemInstance->getAuxValue(), level);
// 4J Stu - We only have one map per player per dimension, so don't reset the one that they have
// when a new one is created
- if( data == NULL )
+ if( data == nullptr )
{
- data = shared_ptr<MapItemSavedData>( new MapItemSavedData(id) );
+ data = std::make_shared<MapItemSavedData>(id);
}
level->setSavedData(id, (shared_ptr<SavedData> ) data);
@@ -335,7 +335,7 @@ void MapItem::onCraftedBy(shared_ptr<ItemInstance> itemInstance, Level *level, s
// 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map
data->x = centreXC;
data->z = centreZC;
- data->dimension = (byte) level->dimension->id;
+ data->dimension = static_cast<byte>(level->dimension->id);
data->setDirty();
}
diff --git a/Minecraft.World/MapItemSavedData.cpp b/Minecraft.World/MapItemSavedData.cpp
index c06c3fac..0a5eb7c4 100644
--- a/Minecraft.World/MapItemSavedData.cpp
+++ b/Minecraft.World/MapItemSavedData.cpp
@@ -65,8 +65,8 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
{
sendPosTick = 4;
- unsigned int playerDecorationsSize = (int)parent->decorations.size();
- unsigned int nonPlayerDecorationsSize = (int)parent->nonPlayerDecorations.size();
+ unsigned int playerDecorationsSize = static_cast<int>(parent->decorations.size());
+ unsigned int nonPlayerDecorationsSize = static_cast<int>(parent->nonPlayerDecorations.size());
charArray data = charArray( (playerDecorationsSize + nonPlayerDecorationsSize ) * DEC_PACKET_BYTES + 1);
data[0] = 1;
for (unsigned int i = 0; i < parent->decorations.size(); i++)
@@ -74,7 +74,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
MapDecoration *md = parent->decorations.at(i);
#ifdef _LARGE_WORLDS
data[i * DEC_PACKET_BYTES + 1] = (char) (md->img);
- data[i * DEC_PACKET_BYTES + 8] = (char) (md->rot & 0xF);
+ data[i * DEC_PACKET_BYTES + 8] = static_cast<char>(md->rot & 0xF);
#else
data[i * DEC_PACKET_BYTES + 1] = (char) ((md->img << 4) | (md->rot & 0xF));
#endif
@@ -92,7 +92,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
MapDecoration *md = it.second;
#ifdef _LARGE_WORLDS
data[dataIndex * DEC_PACKET_BYTES + 1] = (char) (md->img);
- data[dataIndex * DEC_PACKET_BYTES + 8] = (char) (md->rot & 0xF);
+ data[dataIndex * DEC_PACKET_BYTES + 8] = static_cast<char>(md->rot & 0xF);
#else
data[dataIndex * DEC_PACKET_BYTES + 1] = (char) ((md->img << 4) | (md->rot & 0xF));
#endif
@@ -107,7 +107,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
++dataIndex;
}
bool thesame = !itemInstance->isFramed();
- if (lastSentDecorations.data == NULL || lastSentDecorations.length != data.length)
+ if (lastSentDecorations.data == nullptr || lastSentDecorations.length != data.length)
{
thesame = false;
}
@@ -125,7 +125,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
if (!thesame)
{
- if( lastSentDecorations.data != NULL )
+ if( lastSentDecorations.data != nullptr )
{
delete[] lastSentDecorations.data;
}
@@ -148,8 +148,8 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
charArray data = charArray(len + 3);
data[0] = HEADER_COLOURS;
- data[1] = (char) column;
- data[2] = (char) min;
+ data[1] = static_cast<char>(column);
+ data[2] = static_cast<char>(min);
for (unsigned int y = 0; y < data.length - 3; y++)
{
data[y + 3] = parent->colors[(y + min) * MapItem::IMAGE_WIDTH + column];
@@ -199,7 +199,7 @@ void MapItemSavedData::load(CompoundTag *tag)
{
byteArray newColors = tag->getByteArray(L"colors");
//4J
- if(colors.data != NULL)
+ if(colors.data != nullptr)
{
delete[] colors.data;
}
@@ -236,7 +236,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
{
if (carriedByPlayers.find(player) == carriedByPlayers.end())
{
- shared_ptr<HoldingPlayer> hp = shared_ptr<HoldingPlayer>( new HoldingPlayer(player, this ) );
+ shared_ptr<HoldingPlayer> hp = std::make_shared<HoldingPlayer>(player, this);
carriedByPlayers.insert( playerHoldingPlayerMapType::value_type(player, hp) );
carriedBy.push_back(hp);
}
@@ -303,17 +303,17 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
float xd = (float) ( origX - x ) / (1 << scale);
float yd = (float) ( origZ - z ) / (1 << scale);
- char x = (char) (xd * 2 + 0.5);
- char y = (char) (yd * 2 + 0.5);
+ char x = static_cast<char>(xd * 2 + 0.5);
+ char y = static_cast<char>(yd * 2 + 0.5);
int size = MAP_SIZE - 1;
#ifdef _LARGE_WORLDS
if (xd < -size || yd < -size || xd > size || yd > size)
{
- if (xd <= -size) x = (byte) (size * 2 + 2.5);
- if (yd <= -size) y = (byte) (size * 2 + 2.5);
- if (xd >= size) x = (byte) (size * 2 + 1);
- if (yd >= size) y = (byte) (size * 2 + 1);
+ if (xd <= -size) x = static_cast<byte>(size * 2 + 2.5);
+ if (yd <= -size) y = static_cast<byte>(size * 2 + 2.5);
+ if (xd >= size) x = static_cast<byte>(size * 2 + 1);
+ if (yd >= size) y = static_cast<byte>(size * 2 + 1);
}
#endif
//decorations.push_back(new MapDecoration(4, x, y, 0));
@@ -332,25 +332,25 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
if( nonPlayerDecorations.find( item->getFrame()->entityId ) == nonPlayerDecorations.end() )
{
- float xd = (float) ( item->getFrame()->xTile - x ) / (1 << scale);
- float yd = (float) ( item->getFrame()->zTile - z ) / (1 << scale);
- char x = (char) (xd * 2 + 0.5);
- char y = (char) (yd * 2 + 0.5);
+ float xd = static_cast<float>(item->getFrame()->xTile - x) / (1 << scale);
+ float yd = static_cast<float>(item->getFrame()->zTile - z) / (1 << scale);
+ char x = static_cast<char>(xd * 2 + 0.5);
+ char y = static_cast<char>(yd * 2 + 0.5);
int size = MAP_SIZE - 1;
- char rot = (char) ( (item->getFrame()->dir * 90) * 16 / 360);
+ char rot = static_cast<char>((item->getFrame()->dir * 90) * 16 / 360);
if (dimension < 0)
{
- int s = (int) (playerLevel->getLevelData()->getDayTime() / 10);
- rot = (char) ((s * s * 34187121 + s * 121) >> 15 & 15);
+ int s = static_cast<int>(playerLevel->getLevelData()->getDayTime() / 10);
+ rot = static_cast<char>((s * s * 34187121 + s * 121) >> 15 & 15);
}
#ifdef _LARGE_WORLDS
if (xd < -size || yd < -size || xd > size || yd > size)
{
- if (xd <= -size) x = (byte) (size * 2 + 2.5);
- if (yd <= -size) y = (byte) (size * 2 + 2.5);
- if (xd >= size) x = (byte) (size * 2 + 1);
- if (yd >= size) y = (byte) (size * 2 + 1);
+ if (xd <= -size) x = static_cast<byte>(size * 2 + 2.5);
+ if (yd <= -size) y = static_cast<byte>(size * 2 + 2.5);
+ if (xd >= size) x = static_cast<byte>(size * 2 + 1);
+ if (yd >= size) y = static_cast<byte>(size * 2 + 1);
}
#endif
//decorations.push_back(new MapDecoration(7, x, y, 0));
@@ -399,12 +399,12 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
for(auto& decorationPlayer : players->players)
{
- if(decorationPlayer!=NULL && decorationPlayer->dimension == this->dimension)
+ if(decorationPlayer!=nullptr && decorationPlayer->dimension == this->dimension)
{
- float xd = (float) (decorationPlayer->x - x) / (1 << scale);
- float yd = (float) (decorationPlayer->z - z) / (1 << scale);
- char x = (char) (xd * 2);
- char y = (char) (yd * 2);
+ float xd = static_cast<float>(decorationPlayer->x - x) / (1 << scale);
+ float yd = static_cast<float>(decorationPlayer->z - z) / (1 << scale);
+ char x = static_cast<char>(xd * 2);
+ char y = static_cast<char>(yd * 2);
int size = MAP_SIZE; // - 1;
char rot;
char imgIndex;
@@ -414,16 +414,16 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
#endif
{
- rot = (char) (decorationPlayer->yRot * 16 / 360 + 0.5);
+ rot = static_cast<char>(decorationPlayer->yRot * 16 / 360 + 0.5);
if (dimension < 0)
{
- int s = (int) (playerLevel->getLevelData()->getDayTime() / 10);
- rot = (char) ((s * s * 34187121 + s * 121) >> 15 & 15);
+ int s = static_cast<int>(playerLevel->getLevelData()->getDayTime() / 10);
+ rot = static_cast<char>((s * s * 34187121 + s * 121) >> 15 & 15);
}
// 4J Stu - As we have added new icons for players on a new row below
// other icons used in Java we need to move our index to the next row
- imgIndex = (int)decorationPlayer->getPlayerIndex();
+ imgIndex = static_cast<int>(decorationPlayer->getPlayerIndex());
if(imgIndex>3) imgIndex += 4;
}
#ifdef _LARGE_WORLDS
@@ -431,16 +431,16 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
{
// 4J Stu - As we have added new icons for players on a new row below
// other icons used in Java we need to move our index to the next row
- imgIndex = (int)decorationPlayer->getPlayerIndex();
+ imgIndex = static_cast<int>(decorationPlayer->getPlayerIndex());
if(imgIndex>3) imgIndex += 4;
imgIndex += 16; // Add 16 to indicate that it's on the next texture
rot = 0;
size--; // Added to match the old adjusted size
- if (xd <= -size) x = (byte) (size * 2 + 2.5);
- if (yd <= -size) y = (byte) (size * 2 + 2.5);
- if (xd >= size) x = (byte) (size * 2 + 1);
- if (yd >= size) y = (byte) (size * 2 + 1);
+ if (xd <= -size) x = static_cast<byte>(size * 2 + 2.5);
+ if (yd <= -size) y = static_cast<byte>(size * 2 + 2.5);
+ if (xd >= size) x = static_cast<byte>(size * 2 + 1);
+ if (yd >= size) y = static_cast<byte>(size * 2 + 1);
}
#endif
@@ -527,7 +527,7 @@ void MapItemSavedData::handleComplexItemData(charArray &data)
#endif
char x = data[i * DEC_PACKET_BYTES + 2];
char y = data[i * DEC_PACKET_BYTES + 3];
- int entityId = (((int)data[i * DEC_PACKET_BYTES + 4])&0xFF) | ( (((int)data[i * DEC_PACKET_BYTES + 5])&0xFF)<<8) | ((((int)data[i * DEC_PACKET_BYTES + 6])&0xFF)<<16) | ((((int)data[i * DEC_PACKET_BYTES + 7])&0x7F)<<24);
+ int entityId = (static_cast<int>(data[i * DEC_PACKET_BYTES + 4])&0xFF) | ( (static_cast<int>(data[i * DEC_PACKET_BYTES + 5])&0xFF)<<8) | ((static_cast<int>(data[i * DEC_PACKET_BYTES + 6])&0xFF)<<16) | ((static_cast<int>(data[i * DEC_PACKET_BYTES + 7])&0x7F)<<24);
bool visible = (data[i * DEC_PACKET_BYTES + 7] & 0x80) != 0;
decorations.push_back(new MapDecoration(img, x, y, rot, entityId, visible));
}
@@ -545,7 +545,7 @@ shared_ptr<MapItemSavedData::HoldingPlayer> MapItemSavedData::getHoldingPlayer(s
if (it == carriedByPlayers.end())
{
- hp = shared_ptr<HoldingPlayer>( new HoldingPlayer(player, this) );
+ hp = std::make_shared<HoldingPlayer>(player, this);
carriedByPlayers[player] = hp;
carriedBy.push_back(hp);
}
diff --git a/Minecraft.World/Material.cpp b/Minecraft.World/Material.cpp
index 9e201ad5..d17965df 100644
--- a/Minecraft.World/Material.cpp
+++ b/Minecraft.World/Material.cpp
@@ -6,39 +6,39 @@
#include "PortalMaterial.h"
#include "WebMaterial.h"// 4J added, Java version just does a local alteration when instantiating the Material for webs to get the same thing
-Material *Material::air = NULL;
-Material *Material::grass = NULL;
-Material *Material::dirt = NULL;
-Material *Material::wood = NULL;
-Material *Material::stone = NULL;
-Material *Material::metal = NULL;
-Material *Material::heavyMetal = NULL;
-Material *Material::water = NULL;
-Material *Material::lava = NULL;
-Material *Material::leaves = NULL;
-Material *Material::plant = NULL;
-Material *Material::replaceable_plant = NULL;
-Material *Material::sponge = NULL;
-Material *Material::cloth = NULL;
-Material *Material::fire = NULL;
-Material *Material::sand = NULL;
-Material *Material::decoration = NULL;
-Material *Material::clothDecoration = NULL;
-Material *Material::glass = NULL;
-Material *Material::buildable_glass = NULL;
-Material *Material::explosive = NULL;
-Material *Material::coral = NULL;
-Material *Material::ice = NULL;
-Material *Material::topSnow = NULL;
-Material *Material::snow = NULL;
-Material *Material::cactus = NULL;
-Material *Material::clay = NULL;
-Material *Material::vegetable = NULL;
-Material *Material::egg = NULL;
-Material *Material::portal = NULL;
-Material *Material::cake = NULL;
-Material *Material::piston = NULL;
-Material *Material::web = NULL;
+Material *Material::air = nullptr;
+Material *Material::grass = nullptr;
+Material *Material::dirt = nullptr;
+Material *Material::wood = nullptr;
+Material *Material::stone = nullptr;
+Material *Material::metal = nullptr;
+Material *Material::heavyMetal = nullptr;
+Material *Material::water = nullptr;
+Material *Material::lava = nullptr;
+Material *Material::leaves = nullptr;
+Material *Material::plant = nullptr;
+Material *Material::replaceable_plant = nullptr;
+Material *Material::sponge = nullptr;
+Material *Material::cloth = nullptr;
+Material *Material::fire = nullptr;
+Material *Material::sand = nullptr;
+Material *Material::decoration = nullptr;
+Material *Material::clothDecoration = nullptr;
+Material *Material::glass = nullptr;
+Material *Material::buildable_glass = nullptr;
+Material *Material::explosive = nullptr;
+Material *Material::coral = nullptr;
+Material *Material::ice = nullptr;
+Material *Material::topSnow = nullptr;
+Material *Material::snow = nullptr;
+Material *Material::cactus = nullptr;
+Material *Material::clay = nullptr;
+Material *Material::vegetable = nullptr;
+Material *Material::egg = nullptr;
+Material *Material::portal = nullptr;
+Material *Material::cake = nullptr;
+Material *Material::piston = nullptr;
+Material *Material::web = nullptr;
void Material::staticCtor()
{
diff --git a/Minecraft.World/MaterialColor.cpp b/Minecraft.World/MaterialColor.cpp
index d14748b2..5c4fa9d7 100644
--- a/Minecraft.World/MaterialColor.cpp
+++ b/Minecraft.World/MaterialColor.cpp
@@ -3,20 +3,20 @@
MaterialColor **MaterialColor::colors;
-MaterialColor *MaterialColor::none = NULL;
-MaterialColor *MaterialColor::grass = NULL;
-MaterialColor *MaterialColor::sand = NULL;
-MaterialColor *MaterialColor::cloth = NULL;
-MaterialColor *MaterialColor::fire = NULL;
-MaterialColor *MaterialColor::ice = NULL;
-MaterialColor *MaterialColor::metal = NULL;
-MaterialColor *MaterialColor::plant = NULL;
-MaterialColor *MaterialColor::snow = NULL;
-MaterialColor *MaterialColor::clay = NULL;
-MaterialColor *MaterialColor::dirt = NULL;
-MaterialColor *MaterialColor::stone = NULL;
-MaterialColor *MaterialColor::water = NULL;
-MaterialColor *MaterialColor::wood = NULL;
+MaterialColor *MaterialColor::none = nullptr;
+MaterialColor *MaterialColor::grass = nullptr;
+MaterialColor *MaterialColor::sand = nullptr;
+MaterialColor *MaterialColor::cloth = nullptr;
+MaterialColor *MaterialColor::fire = nullptr;
+MaterialColor *MaterialColor::ice = nullptr;
+MaterialColor *MaterialColor::metal = nullptr;
+MaterialColor *MaterialColor::plant = nullptr;
+MaterialColor *MaterialColor::snow = nullptr;
+MaterialColor *MaterialColor::clay = nullptr;
+MaterialColor *MaterialColor::dirt = nullptr;
+MaterialColor *MaterialColor::stone = nullptr;
+MaterialColor *MaterialColor::water = nullptr;
+MaterialColor *MaterialColor::wood = nullptr;
void MaterialColor::staticCtor()
{
diff --git a/Minecraft.World/McRegionChunkStorage.cpp b/Minecraft.World/McRegionChunkStorage.cpp
index 87dabf0b..ad07a66e 100644
--- a/Minecraft.World/McRegionChunkStorage.cpp
+++ b/Minecraft.World/McRegionChunkStorage.cpp
@@ -76,7 +76,7 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
#ifdef SPLIT_SAVES
// If we can't find the chunk in the save file, then we should remove any entities we might have for that chunk
- if(regionChunkInputStream == NULL)
+ if(regionChunkInputStream == nullptr)
{
int64_t index = ((int64_t)(x) << 32) | (((int64_t)(z))&0x00000000FFFFFFFF);
@@ -89,11 +89,11 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
}
#endif
- LevelChunk *levelChunk = NULL;
+ LevelChunk *levelChunk = nullptr;
if(m_saveFile->getOriginalSaveVersion() >= SAVE_FILE_VERSION_COMPRESSED_CHUNK_STORAGE)
{
- if (regionChunkInputStream != NULL)
+ if (regionChunkInputStream != nullptr)
{
MemSect(9);
levelChunk = OldChunkStorage::load(level, regionChunkInputStream);
@@ -106,14 +106,14 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
else
{
CompoundTag *chunkData;
- if (regionChunkInputStream != NULL)
+ if (regionChunkInputStream != nullptr)
{
MemSect(8);
chunkData = NbtIo::read((DataInput *)regionChunkInputStream);
MemSect(0);
} else
{
- return NULL;
+ return nullptr;
}
regionChunkInputStream->deleteChildStream();
@@ -125,7 +125,7 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
sprintf(buf,"Chunk file at %d, %d is missing level data, skipping\n",x, z);
app.DebugPrintf(buf);
delete chunkData;
- return NULL;
+ return nullptr;
}
if (!chunkData->getCompound(L"Level")->contains(L"Blocks"))
{
@@ -133,7 +133,7 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
sprintf(buf,"Chunk file at %d, %d is missing block data, skipping\n",x, z);
app.DebugPrintf(buf);
delete chunkData;
- return NULL;
+ return nullptr;
}
MemSect(9);
levelChunk = OldChunkStorage::load(level, chunkData->getCompound(L"Level"));
@@ -146,7 +146,7 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
app.DebugPrintf(buf);
delete levelChunk;
delete chunkData;
- return NULL;
+ return nullptr;
// 4J Stu - We delete the data within OldChunkStorage::load, so we can never reload from it
//chunkData->putInt(L"xPos", x);
@@ -330,8 +330,8 @@ void McRegionChunkStorage::staticCtor()
sprintf(threadName,"McRegion Save thread %d\n",i);
SetThreadName(0, threadName);
- //saveThreads[j] = CreateThread(NULL,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]);
- s_saveThreads[i] = new C4JThread(runSaveThreadProc,NULL,threadName);
+ //saveThreads[j] = CreateThread(nullptr,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]);
+ s_saveThreads[i] = new C4JThread(runSaveThreadProc,nullptr,threadName);
//app.DebugPrintf("Created new thread: %s\n",threadName);
@@ -359,7 +359,7 @@ int McRegionChunkStorage::runSaveThreadProc(LPVOID lpParam)
bool running = true;
size_t lastQueueSize = 0;
- DataOutputStream *dos = NULL;
+ DataOutputStream *dos = nullptr;
while(running)
{
if( TryEnterCriticalSection(&cs_memory) )
@@ -382,7 +382,7 @@ int McRegionChunkStorage::runSaveThreadProc(LPVOID lpParam)
PIXEndNamedEvent();
}
delete dos;
- dos = NULL;
+ dos = nullptr;
EnterCriticalSection(&cs_memory);
s_runningThreadCount--;
diff --git a/Minecraft.World/McRegionLevelStorage.cpp b/Minecraft.World/McRegionLevelStorage.cpp
index daf6a7ef..ec472fad 100644
--- a/Minecraft.World/McRegionLevelStorage.cpp
+++ b/Minecraft.World/McRegionLevelStorage.cpp
@@ -24,14 +24,14 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
{
//File folder = getFolder();
- if (dynamic_cast<HellDimension *>(dimension) != NULL)
+ if (dynamic_cast<HellDimension *>(dimension) != nullptr)
{
if(app.GetResetNether())
{
#ifdef SPLIT_SAVES
vector<FileEntry *> *netherFiles = m_saveFile->getRegionFilesByDimension(1);
- if(netherFiles!=NULL)
+ if(netherFiles!=nullptr)
{
DWORD bytesWritten = 0;
for(auto& netherFile : *netherFiles)
@@ -42,7 +42,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
}
#else
vector<FileEntry *> *netherFiles = m_saveFile->getFilesWithPrefix(LevelStorage::NETHER_FOLDER);
- if(netherFiles!=NULL)
+ if(netherFiles!=nullptr)
{
for(auto& netherFile : *netherFiles)
{
@@ -74,7 +74,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
vector<FileEntry *> *endFiles = m_saveFile->getFilesWithPrefix(LevelStorage::ENDER_FOLDER);
// 4J-PB - There will be no End in early saves
- if(endFiles!=NULL)
+ if(endFiles!=nullptr)
{
for(auto& endFile : *endFiles)
{
diff --git a/Minecraft.World/McRegionLevelStorageSource.cpp b/Minecraft.World/McRegionLevelStorageSource.cpp
index 60904fde..bf60ee0c 100644
--- a/Minecraft.World/McRegionLevelStorageSource.cpp
+++ b/Minecraft.World/McRegionLevelStorageSource.cpp
@@ -51,12 +51,12 @@ vector<LevelSummary *> *McRegionLevelStorageSource::getLevelList()
wstring levelId = file->getName();
LevelData *levelData = getDataTagFor(levelId);
- if (levelData != NULL)
+ if (levelData != nullptr)
{
bool requiresConversion = levelData->getVersion() != McRegionLevelStorage::MCREGION_VERSION_ID;
wstring levelName = levelData->getLevelName();
- if (levelName.empty()) // 4J Jev TODO: levelName can't be NULL? if (levelName == NULL || isEmpty(levelName))
+ if (levelName.empty()) // 4J Jev TODO: levelName can't be nullptr? if (levelName == nullptr || isEmpty(levelName))
{
levelName = levelId;
}
@@ -76,14 +76,14 @@ void McRegionLevelStorageSource::clearAll()
shared_ptr<LevelStorage> McRegionLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir)
{
// return new LevelStorageProfilerDecorator(new McRegionLevelStorage(baseDir, levelId, createPlayerDir));
- return shared_ptr<LevelStorage>(new McRegionLevelStorage(saveFile, baseDir, levelId, createPlayerDir));
+ return std::make_shared<McRegionLevelStorage>(saveFile, baseDir, levelId, createPlayerDir);
}
bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const 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;
@@ -96,7 +96,7 @@ bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const
bool McRegionLevelStorageSource::requiresConversion(ConsoleSaveFile *saveFile, const wstring& levelId)
{
LevelData *levelData = getDataTagFor(saveFile, levelId);
- if (levelData == NULL || levelData->getVersion() != 0)
+ if (levelData == nullptr || levelData->getVersion() != 0)
{
delete levelData;
return false;
@@ -275,7 +275,7 @@ void McRegionLevelStorageSource::eraseFolders(vector<File *> *folders, int curre
folder->_delete();
currentCount++;
- int percent = (int) Math::round(100.0 * (double) currentCount / (double) totalCount);
+ int percent = static_cast<int>(Math::round(100.0 * (double)currentCount / (double)totalCount));
progress->progressStagePercentage(percent);
}
}
diff --git a/Minecraft.World/MegaTreeFeature.cpp b/Minecraft.World/MegaTreeFeature.cpp
index 09195fb4..db4a336a 100644
--- a/Minecraft.World/MegaTreeFeature.cpp
+++ b/Minecraft.World/MegaTreeFeature.cpp
@@ -15,7 +15,7 @@ bool MegaTreeFeature::place(Level *level, Random *random, int x, int y, int z)
if (y < 1 || y + treeHeight + 1 > Level::maxBuildHeight) return false;
// 4J Stu Added to stop tree features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
PIXBeginNamedEvent(0, "MegaTreeFeature Checking intersects");
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
@@ -69,14 +69,14 @@ bool MegaTreeFeature::place(Level *level, Random *random, int x, int y, int z)
while (branchHeight > y + treeHeight / 2)
{
float angle = random->nextFloat() * PI * 2.0f;
- int bx = x + (int) (0.5f + Mth::cos(angle) * 4.0f);
- int bz = z + (int) (0.5f + Mth::sin(angle) * 4.0f);
+ int bx = x + static_cast<int>(0.5f + Mth::cos(angle) * 4.0f);
+ int bz = z + static_cast<int>(0.5f + Mth::sin(angle) * 4.0f);
placeLeaves(level, bx, bz, branchHeight, 0, random);
for (int b = 0; b < 5; b++)
{
- bx = x + (int) (1.5f + Mth::cos(angle) * b);
- bz = z + (int) (1.5f + Mth::sin(angle) * b);
+ bx = x + static_cast<int>(1.5f + Mth::cos(angle) * b);
+ bz = z + static_cast<int>(1.5f + Mth::sin(angle) * b);
placeBlock(level, bx, branchHeight - 3 + b / 2, bz, Tile::treeTrunk_Id, trunkType);
}
diff --git a/Minecraft.World/MeleeAttackGoal.cpp b/Minecraft.World/MeleeAttackGoal.cpp
index 7003609e..5b7b0179 100644
--- a/Minecraft.World/MeleeAttackGoal.cpp
+++ b/Minecraft.World/MeleeAttackGoal.cpp
@@ -19,7 +19,7 @@ void MeleeAttackGoal::_init(PathfinderMob *mob, double speedModifier, bool track
attackTime = 0;
- path = NULL;
+ path = nullptr;
timeToRecalcPath = 0;
}
@@ -36,24 +36,24 @@ MeleeAttackGoal::MeleeAttackGoal(PathfinderMob *mob, double speedModifier, bool
MeleeAttackGoal::~MeleeAttackGoal()
{
- if(path != NULL) delete path;
+ if(path != nullptr) delete path;
}
bool MeleeAttackGoal::canUse()
{
shared_ptr<LivingEntity> target = mob->getTarget();
- if (target == NULL) return false;
+ if (target == nullptr) return false;
if (!target->isAlive()) return false;
- if (attackType != NULL && !target->instanceof(attackType)) return false;
+ if (attackType != eTYPE_NOTSET && !target->instanceof(attackType)) return false;
delete path;
path = mob->getNavigation()->createPath(target);
- return path != NULL;
+ return path != nullptr;
}
bool MeleeAttackGoal::canContinueToUse()
{
shared_ptr<LivingEntity> target = mob->getTarget();
- if (target == NULL) return false;
+ if (target == nullptr) return false;
if (!target->isAlive()) return false;
if (!trackTarget) return !mob->getNavigation()->isDone();
if (!mob->isWithinRestriction(Mth::floor(target->x), Mth::floor(target->y), Mth::floor(target->z))) return false;
@@ -63,7 +63,7 @@ bool MeleeAttackGoal::canContinueToUse()
void MeleeAttackGoal::start()
{
mob->getNavigation()->moveTo(path, speedModifier);
- path = NULL;
+ path = nullptr;
timeToRecalcPath = 0;
}
@@ -91,6 +91,6 @@ void MeleeAttackGoal::tick()
if (mob->distanceToSqr(target->x, target->bb->y0, target->z) > meleeRadiusSqr) return;
if (attackTime > 0) return;
attackTime = 20;
- if (mob->getCarriedItem() != NULL) mob->swing();
+ if (mob->getCarriedItem() != nullptr) mob->swing();
mob->doHurtTarget(target);
}
diff --git a/Minecraft.World/MelonTile.cpp b/Minecraft.World/MelonTile.cpp
index 298ae61f..be7cd98b 100644
--- a/Minecraft.World/MelonTile.cpp
+++ b/Minecraft.World/MelonTile.cpp
@@ -6,7 +6,7 @@
MelonTile::MelonTile(int id) : Tile(id, Material::vegetable)
{
- iconTop = NULL;
+ iconTop = nullptr;
}
Icon *MelonTile::getTexture(int face, int data)
diff --git a/Minecraft.World/MemoryChunkStorage.cpp b/Minecraft.World/MemoryChunkStorage.cpp
index 249efdd9..9ce5305d 100644
--- a/Minecraft.World/MemoryChunkStorage.cpp
+++ b/Minecraft.World/MemoryChunkStorage.cpp
@@ -5,7 +5,7 @@
LevelChunk *MemoryChunkStorage::load(Level *level, int x, int z) //throws IOException
{
- return NULL;
+ return nullptr;
}
void MemoryChunkStorage::save(Level *level, LevelChunk *levelChunk) //throws IOException
diff --git a/Minecraft.World/MemoryLevelStorage.cpp b/Minecraft.World/MemoryLevelStorage.cpp
index 5a1d43bb..5c5fe53d 100644
--- a/Minecraft.World/MemoryLevelStorage.cpp
+++ b/Minecraft.World/MemoryLevelStorage.cpp
@@ -14,7 +14,7 @@ MemoryLevelStorage::MemoryLevelStorage()
LevelData *MemoryLevelStorage::prepareLevel()
{
- return NULL;
+ return nullptr;
}
void MemoryLevelStorage::checkSession()
@@ -54,7 +54,7 @@ bool MemoryLevelStorage::load(shared_ptr<Player> player)
CompoundTag *MemoryLevelStorage::loadPlayerDataTag(const wstring& playerName)
{
- return NULL;
+ return nullptr;
}
ConsoleSavePath MemoryLevelStorage::getDataFile(const wstring& id)
diff --git a/Minecraft.World/MemoryLevelStorageSource.cpp b/Minecraft.World/MemoryLevelStorageSource.cpp
index db0cfa58..3028b3b1 100644
--- a/Minecraft.World/MemoryLevelStorageSource.cpp
+++ b/Minecraft.World/MemoryLevelStorageSource.cpp
@@ -29,7 +29,7 @@ void MemoryLevelStorageSource::clearAll()
LevelData *MemoryLevelStorageSource::getDataTagFor(const wstring& levelId)
{
- return NULL;
+ return nullptr;
}
bool MemoryLevelStorageSource::isNewLevelIdAcceptable(const wstring& levelId)
diff --git a/Minecraft.World/MenuBackup.cpp b/Minecraft.World/MenuBackup.cpp
index b6d3ba09..c811e068 100644
--- a/Minecraft.World/MenuBackup.cpp
+++ b/Minecraft.World/MenuBackup.cpp
@@ -15,7 +15,7 @@ MenuBackup::MenuBackup(shared_ptr<Inventory> inventory, AbstractContainerMenu *m
void MenuBackup::save(short changeUid)
{
- ItemInstanceArray *backup = new ItemInstanceArray( (int)menu->slots.size() + 1 );
+ ItemInstanceArray *backup = new ItemInstanceArray( static_cast<int>(menu->slots.size()) + 1 );
(*backup)[0] = ItemInstance::clone(inventory->getCarried());
for (unsigned int i = 0; i < menu->slots.size(); i++)
{
diff --git a/Minecraft.World/MerchantContainer.cpp b/Minecraft.World/MerchantContainer.cpp
index 7ceb4745..b9c9bb52 100644
--- a/Minecraft.World/MerchantContainer.cpp
+++ b/Minecraft.World/MerchantContainer.cpp
@@ -11,7 +11,7 @@ MerchantContainer::MerchantContainer(shared_ptr<Player> player, shared_ptr<Merch
items[0] = nullptr;
items[1] = nullptr;
items[2] = nullptr;
- activeRecipe = NULL;
+ activeRecipe = nullptr;
selectionHint = 0;
}
@@ -32,7 +32,7 @@ shared_ptr<ItemInstance> MerchantContainer::getItem(unsigned int slot)
shared_ptr<ItemInstance> MerchantContainer::removeItem(unsigned int slot, int count)
{
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
if (slot == MerchantMenu::RESULT_SLOT)
{
@@ -71,7 +71,7 @@ bool MerchantContainer::isPaymentSlot(int slot)
shared_ptr<ItemInstance> MerchantContainer::removeItemNoUpdate(int slot)
{
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
shared_ptr<ItemInstance> item = items[slot];
items[slot] = nullptr;
@@ -83,7 +83,7 @@ shared_ptr<ItemInstance> MerchantContainer::removeItemNoUpdate(int slot)
void MerchantContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
items[slot] = item;
- if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize();
+ if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize();
if (isPaymentSlot(slot))
{
updateSellItem();
@@ -135,37 +135,37 @@ void MerchantContainer::setChanged()
void MerchantContainer::updateSellItem()
{
- activeRecipe = NULL;
+ activeRecipe = nullptr;
shared_ptr<ItemInstance> buyItem1 = items[MerchantMenu::PAYMENT1_SLOT];
shared_ptr<ItemInstance> buyItem2 = items[MerchantMenu::PAYMENT2_SLOT];
- if (buyItem1 == NULL)
+ if (buyItem1 == nullptr)
{
buyItem1 = buyItem2;
buyItem2 = nullptr;
}
- if (buyItem1 == NULL)
+ if (buyItem1 == nullptr)
{
setItem(MerchantMenu::RESULT_SLOT, nullptr);
}
else
{
MerchantRecipeList *offers = merchant->getOffers(player);
- if (offers != NULL)
+ if (offers != nullptr)
{
MerchantRecipe *recipeFor = offers->getRecipeFor(buyItem1, buyItem2, selectionHint);
- if (recipeFor != NULL && !recipeFor->isDeprecated())
+ if (recipeFor != nullptr && !recipeFor->isDeprecated())
{
activeRecipe = recipeFor;
setItem(MerchantMenu::RESULT_SLOT, recipeFor->getSellItem()->copy());
}
- else if (buyItem2 != NULL)
+ else if (buyItem2 != nullptr)
{
// try to switch
recipeFor = offers->getRecipeFor(buyItem2, buyItem1, selectionHint);
- if (recipeFor != NULL && !recipeFor->isDeprecated())
+ if (recipeFor != nullptr && !recipeFor->isDeprecated())
{
activeRecipe = recipeFor;
setItem(MerchantMenu::RESULT_SLOT, recipeFor->getSellItem()->copy());
diff --git a/Minecraft.World/MerchantMenu.cpp b/Minecraft.World/MerchantMenu.cpp
index 52ce34f9..f24d24c9 100644
--- a/Minecraft.World/MerchantMenu.cpp
+++ b/Minecraft.World/MerchantMenu.cpp
@@ -10,7 +10,7 @@ MerchantMenu::MerchantMenu(shared_ptr<Inventory> inventory, shared_ptr<Merchant>
trader = merchant;
this->level = level;
- tradeContainer = shared_ptr<MerchantContainer>( new MerchantContainer(dynamic_pointer_cast<Player>(inventory->player->shared_from_this()), merchant) );
+ tradeContainer = std::make_shared<MerchantContainer>(dynamic_pointer_cast<Player>(inventory->player->shared_from_this()), merchant);
addSlot(new Slot(tradeContainer, PAYMENT1_SLOT, SELLSLOT1_X, ROW2_Y));
addSlot(new Slot(tradeContainer, PAYMENT2_SLOT, SELLSLOT2_X, ROW2_Y));
addSlot(new MerchantResultSlot(inventory->player, merchant, tradeContainer, RESULT_SLOT, BUYSLOT_X, ROW2_Y));
@@ -67,10 +67,10 @@ bool MerchantMenu::stillValid(shared_ptr<Player> player)
shared_ptr<ItemInstance> MerchantMenu::quickMoveStack(shared_ptr<Player> player, int slotIndex)
{
shared_ptr<ItemInstance> clicked = nullptr;
- Slot *slot = NULL;
+ Slot *slot = nullptr;
if(slotIndex < slots.size()) slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
@@ -138,7 +138,7 @@ void MerchantMenu::removed(shared_ptr<Player> player)
player->drop(item);
}
item = tradeContainer->removeItemNoUpdate(PAYMENT2_SLOT);
- if (item != NULL)
+ if (item != nullptr)
{
player->drop(item);
}
diff --git a/Minecraft.World/MerchantRecipe.cpp b/Minecraft.World/MerchantRecipe.cpp
index b772b0c7..b4eb1b54 100644
--- a/Minecraft.World/MerchantRecipe.cpp
+++ b/Minecraft.World/MerchantRecipe.cpp
@@ -34,12 +34,12 @@ MerchantRecipe::MerchantRecipe(shared_ptr<ItemInstance> buy, shared_ptr<ItemInst
MerchantRecipe::MerchantRecipe(shared_ptr<ItemInstance> buy, Item *sell)
{
- _init(buy, nullptr, shared_ptr<ItemInstance>(new ItemInstance(sell)));
+ _init(buy, nullptr, std::make_shared<ItemInstance>(sell));
}
MerchantRecipe::MerchantRecipe(shared_ptr<ItemInstance> buy, Tile *sell)
{
- _init(buy, nullptr, shared_ptr<ItemInstance>(new ItemInstance(sell)));
+ _init(buy, nullptr, std::make_shared<ItemInstance>(sell));
}
shared_ptr<ItemInstance> MerchantRecipe::getBuyAItem()
@@ -54,7 +54,7 @@ shared_ptr<ItemInstance> MerchantRecipe::getBuyBItem()
bool MerchantRecipe::hasSecondaryBuyItem()
{
- return buyB != NULL;
+ return buyB != nullptr;
}
shared_ptr<ItemInstance> MerchantRecipe::getSellItem()
@@ -68,13 +68,13 @@ bool MerchantRecipe::isSame(MerchantRecipe *other)
{
return false;
}
- return (buyB == NULL && other->buyB == NULL) || (buyB != NULL && other->buyB != NULL && buyB->id == other->buyB->id);
+ return (buyB == nullptr && other->buyB == nullptr) || (buyB != nullptr && other->buyB != nullptr && buyB->id == other->buyB->id);
}
bool MerchantRecipe::isSameSameButBetter(MerchantRecipe *other)
{
// same deal, but cheaper
- return isSame(other) && (buyA->count < other->buyA->count || (buyB != NULL && buyB->count < other->buyB->count));
+ return isSame(other) && (buyA->count < other->buyA->count || (buyB != nullptr && buyB->count < other->buyB->count));
}
int MerchantRecipe::getUses()
@@ -136,7 +136,7 @@ CompoundTag *MerchantRecipe::createTag()
CompoundTag *tag = new CompoundTag();
tag->putCompound(L"buy", buyA->save(new CompoundTag(L"buy")));
tag->putCompound(L"sell", sell->save(new CompoundTag(L"sell")));
- if (buyB != NULL)
+ if (buyB != nullptr)
{
tag->putCompound(L"buyB", buyB->save(new CompoundTag(L"buyB")));
}
diff --git a/Minecraft.World/MerchantRecipeList.cpp b/Minecraft.World/MerchantRecipeList.cpp
index c994081f..b1498389 100644
--- a/Minecraft.World/MerchantRecipeList.cpp
+++ b/Minecraft.World/MerchantRecipeList.cpp
@@ -21,35 +21,40 @@ MerchantRecipeList::~MerchantRecipeList()
MerchantRecipe *MerchantRecipeList::getRecipeFor(shared_ptr<ItemInstance> buyA, shared_ptr<ItemInstance> buyB, int selectionHint)
{
- if (selectionHint > 0 && selectionHint < m_recipes.size())
+ if (buyA == nullptr)
+ {
+ return nullptr;
+ }
+
+ if (selectionHint > 0 && selectionHint < static_cast<int>(m_recipes.size()))
{
// attempt to match vs the hint
MerchantRecipe *r = m_recipes.at(selectionHint);
- if (buyA->id == r->getBuyAItem()->id && ((buyB == NULL && !r->hasSecondaryBuyItem()) || (r->hasSecondaryBuyItem() && buyB != NULL && r->getBuyBItem()->id == buyB->id)))
+ if (buyA->id == r->getBuyAItem()->id && ((buyB == nullptr && !r->hasSecondaryBuyItem()) || (r->hasSecondaryBuyItem() && buyB != nullptr && r->getBuyBItem()->id == buyB->id)))
{
if (buyA->count >= r->getBuyAItem()->count && (!r->hasSecondaryBuyItem() || buyB->count >= r->getBuyBItem()->count))
{
return r;
}
}
- return NULL;
+ return nullptr;
}
- for (int i = 0; i < m_recipes.size(); i++)
+ for (size_t i = 0; i < m_recipes.size(); i++)
{
MerchantRecipe *r = m_recipes.at(i);
if (buyA->id == r->getBuyAItem()->id && buyA->count >= r->getBuyAItem()->count
- && ((!r->hasSecondaryBuyItem() && buyB == NULL) || (r->hasSecondaryBuyItem() && buyB != NULL && r->getBuyBItem()->id == buyB->id && buyB->count >= r->getBuyBItem()->count)))
+ && ((!r->hasSecondaryBuyItem() && buyB == nullptr) || (r->hasSecondaryBuyItem() && buyB != nullptr && r->getBuyBItem()->id == buyB->id && buyB->count >= r->getBuyBItem()->count)))
{
return r;
}
}
- return NULL;
+ return nullptr;
}
bool MerchantRecipeList::addIfNewOrBetter(MerchantRecipe *recipe)
{
bool added = false;
- for (int i = 0; i < m_recipes.size(); i++)
+ for (size_t i = 0; i < m_recipes.size(); i++)
{
MerchantRecipe *r = m_recipes.at(i);
if (recipe->isSame(r))
@@ -69,32 +74,32 @@ bool MerchantRecipeList::addIfNewOrBetter(MerchantRecipe *recipe)
MerchantRecipe *MerchantRecipeList::getMatchingRecipeFor(shared_ptr<ItemInstance> buy, shared_ptr<ItemInstance> buyB, shared_ptr<ItemInstance> sell)
{
- for (int i = 0; i < m_recipes.size(); i++)
+ for (size_t i = 0; i < m_recipes.size(); i++)
{
MerchantRecipe *r = m_recipes.at(i);
if (buy->id == r->getBuyAItem()->id && buy->count >= r->getBuyAItem()->count && sell->id == r->getSellItem()->id)
{
- if (!r->hasSecondaryBuyItem() || (buyB != NULL && buyB->id == r->getBuyBItem()->id && buyB->count >= r->getBuyBItem()->count))
+ if (!r->hasSecondaryBuyItem() || (buyB != nullptr && buyB->id == r->getBuyBItem()->id && buyB->count >= r->getBuyBItem()->count))
{
return r;
}
}
}
- return NULL;
+ return nullptr;
}
void MerchantRecipeList::writeToStream(DataOutputStream *stream)
{
- stream->writeByte((byte) (m_recipes.size() & 0xff));
- for (int i = 0; i < m_recipes.size(); i++)
+ stream->writeByte(static_cast<byte>(m_recipes.size() & 0xff));
+ for (size_t i = 0; i < m_recipes.size(); i++)
{
MerchantRecipe *r = m_recipes.at(i);
Packet::writeItem(r->getBuyAItem(), stream);
Packet::writeItem(r->getSellItem(), stream);
shared_ptr<ItemInstance> buyBItem = r->getBuyBItem();
- stream->writeBoolean(buyBItem != NULL);
- if (buyBItem != NULL)
+ stream->writeBoolean(buyBItem != nullptr);
+ if (buyBItem != nullptr)
{
Packet::writeItem(buyBItem, stream);
}
@@ -149,7 +154,7 @@ CompoundTag *MerchantRecipeList::createTag()
CompoundTag *tag = new CompoundTag();
ListTag<CompoundTag> *list = new ListTag<CompoundTag>(L"Recipes");
- for (int i = 0; i < m_recipes.size(); i++)
+ for (size_t i = 0; i < m_recipes.size(); i++)
{
MerchantRecipe *merchantRecipe = m_recipes.at(i);
list->add(merchantRecipe->createTag());
@@ -166,6 +171,10 @@ void MerchantRecipeList::push_back(MerchantRecipe *recipe)
MerchantRecipe *MerchantRecipeList::at(size_t index)
{
+ if (index >= m_recipes.size())
+ {
+ return nullptr;
+ }
return m_recipes.at(index);
}
diff --git a/Minecraft.World/MerchantResultSlot.cpp b/Minecraft.World/MerchantResultSlot.cpp
index fedbcc4a..7a09d069 100644
--- a/Minecraft.World/MerchantResultSlot.cpp
+++ b/Minecraft.World/MerchantResultSlot.cpp
@@ -42,7 +42,7 @@ void MerchantResultSlot::onTake(shared_ptr<Player> player, shared_ptr<ItemInstan
checkTakeAchievements(carried);
MerchantRecipe *activeRecipe = slots->getActiveRecipe();
- if (activeRecipe != NULL)
+ if (activeRecipe != nullptr)
{
shared_ptr<ItemInstance> item1 = slots->getItem(MerchantMenu::PAYMENT1_SLOT);
shared_ptr<ItemInstance> item2 = slots->getItem(MerchantMenu::PAYMENT2_SLOT);
@@ -76,15 +76,15 @@ bool MerchantResultSlot::removePaymentItemsIfMatching(MerchantRecipe *activeReci
shared_ptr<ItemInstance> buyA = activeRecipe->getBuyAItem();
shared_ptr<ItemInstance> buyB = activeRecipe->getBuyBItem();
- if (a != NULL && a->id == buyA->id)
+ if (a != nullptr && a->id == buyA->id)
{
- if (buyB != NULL && b != NULL && buyB->id == b->id)
+ if (buyB != nullptr && b != nullptr && buyB->id == b->id)
{
a->count -= buyA->count;
b->count -= buyB->count;
return true;
}
- else if (buyB == NULL && b == NULL)
+ else if (buyB == nullptr && b == nullptr)
{
a->count -= buyA->count;
return true;
diff --git a/Minecraft.World/MilkBucketItem.cpp b/Minecraft.World/MilkBucketItem.cpp
index 4a371078..8c8ea674 100644
--- a/Minecraft.World/MilkBucketItem.cpp
+++ b/Minecraft.World/MilkBucketItem.cpp
@@ -19,7 +19,7 @@ shared_ptr<ItemInstance> MilkBucketItem::useTimeDepleted(shared_ptr<ItemInstance
if (instance->count <= 0)
{
- return shared_ptr<ItemInstance>( new ItemInstance(Item::bucket_empty) );
+ return std::make_shared<ItemInstance>(Item::bucket_empty);
}
return instance;
}
diff --git a/Minecraft.World/MilkBucketItem.h b/Minecraft.World/MilkBucketItem.h
index 672e3143..f2cff3ea 100644
--- a/Minecraft.World/MilkBucketItem.h
+++ b/Minecraft.World/MilkBucketItem.h
@@ -5,7 +5,7 @@
class MilkBucketItem : public Item
{
private:
- static const int DRINK_DURATION = (int) (20 * 1.6);
+ static const int DRINK_DURATION = static_cast<int>(20 * 1.6);
public:
MilkBucketItem(int id);
diff --git a/Minecraft.World/MineShaftFeature.cpp b/Minecraft.World/MineShaftFeature.cpp
index d32af346..ebf59025 100644
--- a/Minecraft.World/MineShaftFeature.cpp
+++ b/Minecraft.World/MineShaftFeature.cpp
@@ -32,7 +32,7 @@ bool MineShaftFeature::isFeatureChunk(int x, int z, bool bIsSuperflat)
{
bool forcePlacement = false;
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
- if( levelGenOptions != NULL )
+ if( levelGenOptions != nullptr )
{
forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Mineshaft);
}
diff --git a/Minecraft.World/MineShaftPieces.cpp b/Minecraft.World/MineShaftPieces.cpp
index 3fda1bfc..97caf366 100644
--- a/Minecraft.World/MineShaftPieces.cpp
+++ b/Minecraft.World/MineShaftPieces.cpp
@@ -44,7 +44,7 @@ StructurePiece *MineShaftPieces::createRandomShaftPiece(list<StructurePiece *> *
if (randomSelection >= 80)
{
BoundingBox *crossingBox = MineShaftCrossing::findCrossing(pieces, random, footX, footY, footZ, direction);
- if (crossingBox != NULL)
+ if (crossingBox != nullptr)
{
return new MineShaftCrossing(genDepth, random, crossingBox, direction);
}
@@ -52,7 +52,7 @@ StructurePiece *MineShaftPieces::createRandomShaftPiece(list<StructurePiece *> *
else if (randomSelection >= 70)
{
BoundingBox *stairsBox = MineShaftStairs::findStairs(pieces, random, footX, footY, footZ, direction);
- if (stairsBox != NULL)
+ if (stairsBox != nullptr)
{
return new MineShaftPieces::MineShaftStairs(genDepth, random, stairsBox, direction);
}
@@ -60,28 +60,28 @@ StructurePiece *MineShaftPieces::createRandomShaftPiece(list<StructurePiece *> *
else
{
BoundingBox *corridorBox = MineShaftCorridor::findCorridorSize(pieces, random, footX, footY, footZ, direction);
- if (corridorBox != NULL)
+ if (corridorBox != nullptr)
{
return new MineShaftCorridor(genDepth, random, corridorBox, direction);
}
}
- return NULL;
+ return nullptr;
}
StructurePiece *MineShaftPieces::generateAndAddPiece(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth)
{
if (depth > MAX_DEPTH)
{
- return NULL;
+ return nullptr;
}
if (abs(footX - startPiece->getBoundingBox()->x0) > 5 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 5 * 16)
{
- return NULL;
+ return nullptr;
}
StructurePiece *newPiece = createRandomShaftPiece(pieces, random, footX, footY, footZ, direction, depth + 1);
- if (newPiece != NULL)
+ if (newPiece != nullptr)
{
MemSect(50);
pieces->push_back(newPiece);
@@ -132,7 +132,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis
break;
}
StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + pos, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z0 - 1, Direction::NORTH, depth);
- if (child != NULL)
+ if (child != nullptr)
{
BoundingBox *childBox = child->getBoundingBox();
childEntranceBoxes.push_back(new BoundingBox(childBox->x0, childBox->y0, boundingBox->z0, childBox->x1, childBox->y1, boundingBox->z0 + 1));
@@ -149,7 +149,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis
break;
}
StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + pos, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z1 + 1, Direction::SOUTH, depth);
- if (child != NULL)
+ if (child != nullptr)
{
BoundingBox *childBox = child->getBoundingBox();
childEntranceBoxes.push_back(new BoundingBox(childBox->x0, childBox->y0, boundingBox->z1 - 1, childBox->x1, childBox->y1, boundingBox->z1));
@@ -166,7 +166,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis
break;
}
StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z0 + pos, Direction::WEST, depth);
- if (child != NULL)
+ if (child != nullptr)
{
BoundingBox *childBox = child->getBoundingBox();
childEntranceBoxes.push_back(new BoundingBox(boundingBox->x0, childBox->y0, childBox->z0, boundingBox->x0 + 1, childBox->y1, childBox->z1));
@@ -183,7 +183,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis
break;
}
StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z0 + pos, Direction::EAST, depth);
- if (child != NULL)
+ if (child != nullptr)
{
BoundingBox *childBox = child->getBoundingBox();
childEntranceBoxes.push_back(new BoundingBox(boundingBox->x1 - 1, childBox->y0, childBox->z0, boundingBox->x1, childBox->y1, childBox->z1));
@@ -304,7 +304,7 @@ BoundingBox *MineShaftPieces::MineShaftCorridor::findCorridorSize(list<Structure
break;
}
- if (StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
corridorLength--;
}
@@ -320,7 +320,7 @@ BoundingBox *MineShaftPieces::MineShaftCorridor::findCorridorSize(list<Structure
}
delete box;
// unable to place corridor here
- return NULL;
+ return nullptr;
}
void MineShaftPieces::MineShaftCorridor::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
@@ -434,7 +434,7 @@ bool MineShaftPieces::MineShaftCorridor::createChest(Level *level, BoundingBox *
if (level->getTile(worldX, worldY, worldZ) == 0)
{
level->setTileAndData(worldX, worldY, worldZ, Tile::rail_Id, getOrientationData(Tile::rail_Id, random->nextBoolean() ? RailTile::DIR_FLAT_X : RailTile::DIR_FLAT_Z), Tile::UPDATE_CLIENTS);
- shared_ptr<MinecartChest> chest = shared_ptr<MinecartChest>( new MinecartChest(level, worldX + 0.5f, worldY + 0.5f, worldZ + 0.5f) );
+ shared_ptr<MinecartChest> chest = std::make_shared<MinecartChest>(level, worldX + 0.5f, worldY + 0.5f, worldZ + 0.5f);
WeighedTreasure::addChestItems(random, treasure, chest, numRolls);
level->addEntity(chest);
return true;
@@ -515,7 +515,7 @@ bool MineShaftPieces::MineShaftCorridor::postProcess(Level *level, Random *rando
hasPlacedSpider = true;
level->setTileAndData(x, y, newZ, Tile::mobSpawner_Id, 0, Tile::UPDATE_CLIENTS);
shared_ptr<MobSpawnerTileEntity> entity = dynamic_pointer_cast<MobSpawnerTileEntity>( level->getTileEntity(x, y, newZ) );
- if (entity != NULL) entity->getSpawner()->setEntityId(L"CaveSpider");
+ if (entity != nullptr) entity->getSpawner()->setEntityId(L"CaveSpider");
}
}
}
@@ -605,10 +605,10 @@ BoundingBox *MineShaftPieces::MineShaftCrossing::findCrossing(list<StructurePiec
break;
}
- if (StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return box;
@@ -746,10 +746,10 @@ BoundingBox *MineShaftPieces::MineShaftStairs::findStairs(list<StructurePiece *>
break;
}
- if (StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return box;
diff --git a/Minecraft.World/Minecart.cpp b/Minecraft.World/Minecart.cpp
index 4e1419cc..f6c4bb76 100644
--- a/Minecraft.World/Minecart.cpp
+++ b/Minecraft.World/Minecart.cpp
@@ -44,7 +44,7 @@ void Minecart::_init()
blocksBuilding = true;
setSize(0.98f, 0.7f);
heightOffset = bbHeight / 2.0f;
- soundUpdater = NULL;
+ soundUpdater = nullptr;
name = L"";
//
@@ -56,7 +56,7 @@ Minecart::Minecart(Level *level) : Entity( level )
{
_init();
- //soundUpdater = level != NULL ? level->makeSoundUpdater(this) : NULL;
+ //soundUpdater = level != nullptr ? level->makeSoundUpdater(this) : nullptr;
}
Minecart::~Minecart()
@@ -69,17 +69,17 @@ shared_ptr<Minecart> Minecart::createMinecart(Level *level, double x, double y,
switch (type)
{
case TYPE_CHEST:
- return shared_ptr<MinecartChest>( new MinecartChest(level, x, y, z) );
+ return std::make_shared<MinecartChest>(level, x, y, z);
case TYPE_FURNACE:
- return shared_ptr<MinecartFurnace>( new MinecartFurnace(level, x, y, z) );
+ return std::make_shared<MinecartFurnace>(level, x, y, z);
case TYPE_TNT:
- return shared_ptr<MinecartTNT>( new MinecartTNT(level, x, y, z) );
+ return std::make_shared<MinecartTNT>(level, x, y, z);
case TYPE_SPAWNER:
- return shared_ptr<MinecartSpawner>( new MinecartSpawner(level, x, y, z) );
+ return std::make_shared<MinecartSpawner>(level, x, y, z);
case TYPE_HOPPER:
- return shared_ptr<MinecartHopper>( new MinecartHopper(level, x, y, z) );
+ return std::make_shared<MinecartHopper>(level, x, y, z);
default:
- return shared_ptr<MinecartRideable>( new MinecartRideable(level, x, y, z) );
+ return std::make_shared<MinecartRideable>(level, x, y, z);
}
}
@@ -95,7 +95,7 @@ void Minecart::defineSynchedData()
entityData->define(DATA_ID_DAMAGE, 0.0f);
entityData->define(DATA_ID_DISPLAY_TILE, 0);
entityData->define(DATA_ID_DISPLAY_OFFSET, 6);
- entityData->define(DATA_ID_CUSTOM_DISPLAY, (byte) 0);
+ entityData->define(DATA_ID_CUSTOM_DISPLAY, static_cast<byte>(0));
}
@@ -105,12 +105,12 @@ AABB *Minecart::getCollideAgainstBox(shared_ptr<Entity> entity)
{
return entity->bb;
}
- return NULL;
+ return nullptr;
}
AABB *Minecart::getCollideBox()
{
- return NULL;
+ return nullptr;
}
bool Minecart::isPushable()
@@ -145,7 +145,7 @@ bool Minecart::hurt(DamageSource *source, float hurtDamage)
// 4J-JEV: Fix for #88212,
// Untrusted players shouldn't be able to damage minecarts or boats.
- if (dynamic_cast<EntityDamageSource *>(source) != NULL)
+ if (dynamic_cast<EntityDamageSource *>(source) != nullptr)
{
shared_ptr<Entity> attacker = source->getDirectEntity();
@@ -163,14 +163,14 @@ bool Minecart::hurt(DamageSource *source, float hurtDamage)
// 4J Stu - If someone is riding in this, then it can tick multiple times which causes the damage to
// decrease too quickly. So just make the damage a bit higher to start with for similar behaviour
// to an unridden one. Only do this change if the riding player is attacking it.
- if( rider.lock() != NULL && rider.lock() == source->getEntity() ) hurtDamage += 1;
+ if( rider.lock() != nullptr && rider.lock() == source->getEntity() ) hurtDamage += 1;
- bool creativePlayer = source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER) && dynamic_pointer_cast<Player>(source->getEntity())->abilities.instabuild;
+ bool creativePlayer = source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) && dynamic_pointer_cast<Player>(source->getEntity())->abilities.instabuild;
if (creativePlayer || getDamage() > 20 * 2)
{
// 4J HEG - Fixed issue with player falling through the ground on destroying a minecart while riding (issue #160607)
- if (rider.lock() != NULL) rider.lock()->ride(nullptr);
+ if (rider.lock() != nullptr) rider.lock()->ride(nullptr);
if (!creativePlayer || hasCustomName())
{
@@ -187,7 +187,7 @@ bool Minecart::hurt(DamageSource *source, float hurtDamage)
void Minecart::destroy(DamageSource *source)
{
remove();
- shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>( new ItemInstance(Item::minecart, 1) );
+ shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(Item::minecart, 1);
if (!name.empty()) item->setHoverName(name);
spawnAtLocation(item, 0);
}
@@ -207,12 +207,12 @@ bool Minecart::isPickable()
void Minecart::remove()
{
Entity::remove();
- //if (soundUpdater != NULL) soundUpdater->tick();
+ //if (soundUpdater != nullptr) soundUpdater->tick();
}
void Minecart::tick()
{
- //if (soundUpdater != NULL) soundUpdater->tick();
+ //if (soundUpdater != nullptr) soundUpdater->tick();
// 4J - make minecarts (server-side) tick twice, to put things back to how they were when we were accidently ticking them twice
for( int i = 0; i < 2; i++ )
{
@@ -223,16 +223,16 @@ void Minecart::tick()
outOfWorld();
}
- if (!level->isClientSide && dynamic_cast<ServerLevel *>(level) != NULL)
+ if (!level->isClientSide && dynamic_cast<ServerLevel *>(level) != nullptr)
{
- MinecraftServer *server = ((ServerLevel *) level)->getServer();
+ MinecraftServer *server = static_cast<ServerLevel *>(level)->getServer();
int waitTime = getPortalWaitTime();
if (isInsidePortal)
{
if (server->isNetherEnabled())
{
- if (riding == NULL)
+ if (riding == nullptr)
{
if (portalTime++ >= waitTime)
{
@@ -275,8 +275,8 @@ void Minecart::tick()
double yrd = Mth::wrapDegrees(lyr - yRot);
- yRot += (float) ( (yrd) / lSteps );
- xRot += (float) ( (lxr - xRot) / lSteps );
+ yRot += static_cast<float>((yrd) / lSteps);
+ xRot += static_cast<float>((lxr - xRot) / lSteps);
lSteps--;
setPos(xt, yt, zt);
@@ -330,7 +330,7 @@ void Minecart::tick()
double zDiff = zo - z;
if (xDiff * xDiff + zDiff * zDiff > 0.001)
{
- yRot = (float) (atan2(zDiff, xDiff) * 180 / PI);
+ yRot = static_cast<float>(atan2(zDiff, xDiff) * 180 / PI);
if (flipped) yRot += 180;
}
@@ -344,7 +344,7 @@ void Minecart::tick()
setRot(yRot, xRot);
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), bb->grow(0.2f, 0, 0.2f));
- if (entities != NULL && !entities->empty())
+ if (entities != nullptr && !entities->empty())
{
for (auto& e : *entities)
{
@@ -361,7 +361,7 @@ void Minecart::tick()
}
}
- if (rider.lock() != NULL)
+ if (rider.lock() != nullptr)
{
if (rider.lock()->removed)
{
@@ -415,7 +415,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl
powerTrack = (data & BaseRailTile::RAIL_DATA_BIT) != 0;
haltTrack = !powerTrack;
}
- if (((BaseRailTile *) Tile::tiles[tile])->isUsesDataBit())
+ if (static_cast<BaseRailTile *>(Tile::tiles[tile])->isUsesDataBit())
{
data &= BaseRailTile::RAIL_DIRECTION_MASK;
}
@@ -454,7 +454,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl
zd = pow * zD / dd;
- if ( rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY) )
+ if ( rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_LIVINGENTITY) )
{
shared_ptr<LivingEntity> living = dynamic_pointer_cast<LivingEntity>(rider.lock());
@@ -530,7 +530,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl
double xdd = xd;
double zdd = zd;
- if (rider.lock() != NULL)
+ if (rider.lock() != nullptr)
{
xdd *= 0.75;
zdd *= 0.75;
@@ -554,7 +554,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl
applyNaturalSlowdown();
Vec3 *newPos = getPos(x, y, z);
- if (newPos != NULL && oldPos != NULL)
+ if (newPos != nullptr && oldPos != nullptr)
{
double speed = (oldPos->y - newPos->y) * 0.05;
@@ -619,7 +619,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl
void Minecart::applyNaturalSlowdown()
{
- if (rider.lock() != NULL)
+ if (rider.lock() != nullptr)
{
xd *= 0.997f;
yd *= 0;
@@ -648,7 +648,7 @@ Vec3 *Minecart::getPosOffs(double x, double y, double z, double offs)
{
int data = level->getData(xt, yt, zt);
- if (((BaseRailTile *) Tile::tiles[tile])->isUsesDataBit())
+ if (static_cast<BaseRailTile *>(Tile::tiles[tile])->isUsesDataBit())
{
data &= BaseRailTile::RAIL_DIRECTION_MASK;
}
@@ -684,7 +684,7 @@ Vec3 *Minecart::getPosOffs(double x, double y, double z, double offs)
return getPos(x, y, z);
}
- return NULL;
+ return nullptr;
}
Vec3 *Minecart::getPos(double x, double y, double z)
@@ -703,7 +703,7 @@ Vec3 *Minecart::getPos(double x, double y, double z)
int data = level->getData(xt, yt, zt);
y = yt;
- if (((BaseRailTile *) Tile::tiles[tile])->isUsesDataBit())
+ if (static_cast<BaseRailTile *>(Tile::tiles[tile])->isUsesDataBit())
{
data &= BaseRailTile::RAIL_DIRECTION_MASK;
}
@@ -756,7 +756,7 @@ Vec3 *Minecart::getPos(double x, double y, double z)
if (yD > 0) y += 0.5;
return Vec3::newTemp(x, y, z);
}
- return NULL;
+ return nullptr;
}
void Minecart::readAdditionalSaveData(CompoundTag *tag)
@@ -776,7 +776,7 @@ void Minecart::addAdditonalSaveData(CompoundTag *tag)
if (hasCustomDisplay())
{
tag->putBoolean(L"CustomDisplayTile", true);
- tag->putInt(L"DisplayTile", getDisplayTile() == NULL ? 0 : getDisplayTile()->id);
+ tag->putInt(L"DisplayTile", getDisplayTile() == nullptr ? 0 : getDisplayTile()->id);
tag->putInt(L"DisplayData", getDisplayData());
tag->putInt(L"DisplayOffset", getDisplayOffset());
}
@@ -796,7 +796,7 @@ void Minecart::push(shared_ptr<Entity> e)
if (e == rider.lock()) return;
if ( e->instanceof(eTYPE_LIVINGENTITY) && !e->instanceof(eTYPE_PLAYER) && !e->instanceof(eTYPE_VILLAGERGOLEM) && (getType() == TYPE_RIDEABLE) && (xd * xd + zd * zd > 0.01) )
{
- if ( (rider.lock() == NULL) && (e->riding == NULL) )
+ if ( (rider.lock() == nullptr) && (e->riding == nullptr) )
{
e->ride( shared_from_this() );
}
@@ -844,7 +844,7 @@ void Minecart::push(shared_ptr<Entity> e)
double zdd = (e->zd + zd);
shared_ptr<Minecart> cart = dynamic_pointer_cast<Minecart>(e);
- if (cart != NULL && cart->getType() == TYPE_FURNACE && getType() != TYPE_FURNACE)
+ if (cart != nullptr && cart->getType() == TYPE_FURNACE && getType() != TYPE_FURNACE)
{
xd *= 0.2f;
zd *= 0.2f;
@@ -853,7 +853,7 @@ void Minecart::push(shared_ptr<Entity> e)
e->zd *= 0.95f;
m_bHasPushedCartThisTick = true;
}
- else if (cart != NULL && cart->getType() != TYPE_FURNACE && getType() == TYPE_FURNACE)
+ else if (cart != nullptr && cart->getType() != TYPE_FURNACE && getType() == TYPE_FURNACE)
{
e->xd *= 0.2f;
e->zd *= 0.2f;
@@ -957,12 +957,12 @@ Tile *Minecart::getDisplayTile()
{
if (!hasCustomDisplay()) return getDefaultDisplayTile();
int id = getEntityData()->getInteger(DATA_ID_DISPLAY_TILE) & 0xFFFF;
- return id > 0 && id < Tile::TILE_NUM_COUNT ? Tile::tiles[id] : NULL;
+ return id > 0 && id < Tile::TILE_NUM_COUNT ? Tile::tiles[id] : nullptr;
}
Tile *Minecart::getDefaultDisplayTile()
{
- return NULL;
+ return nullptr;
}
int Minecart::getDisplayData()
@@ -996,7 +996,7 @@ void Minecart::setDisplayTile(int id)
void Minecart::setDisplayData(int data)
{
Tile *tile = getDisplayTile();
- int id = tile == NULL ? 0 : tile->id;
+ int id = tile == nullptr ? 0 : tile->id;
getEntityData()->set(DATA_ID_DISPLAY_TILE, (id & 0xFFFF) | (data << 16));
setCustomDisplay(true);
@@ -1015,7 +1015,7 @@ bool Minecart::hasCustomDisplay()
void Minecart::setCustomDisplay(bool value)
{
- getEntityData()->set(DATA_ID_CUSTOM_DISPLAY, (byte) (value ? 1 : 0));
+ getEntityData()->set(DATA_ID_CUSTOM_DISPLAY, static_cast<byte>(value ? 1 : 0));
}
void Minecart::setCustomName(const wstring &name)
diff --git a/Minecraft.World/MinecartContainer.cpp b/Minecraft.World/MinecartContainer.cpp
index 20bfc4ea..0e0fd3ac 100644
--- a/Minecraft.World/MinecartContainer.cpp
+++ b/Minecraft.World/MinecartContainer.cpp
@@ -33,7 +33,7 @@ void MinecartContainer::destroy(DamageSource *source)
for (int i = 0; i < getContainerSize(); i++)
{
shared_ptr<ItemInstance> 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;
@@ -45,11 +45,11 @@ void MinecartContainer::destroy(DamageSource *source)
if (count > item->count) count = item->count;
item->count -= count;
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue()))) );
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>(new ItemInstance(item->id, count, item->getAuxValue())));
float pow = 0.05f;
- itemEntity->xd = (float) random->nextGaussian() * pow;
- itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f;
- itemEntity->zd = (float) random->nextGaussian() * pow;
+ itemEntity->xd = static_cast<float>(random->nextGaussian()) * pow;
+ itemEntity->yd = static_cast<float>(random->nextGaussian()) * pow + 0.2f;
+ itemEntity->zd = static_cast<float>(random->nextGaussian()) * pow;
level->addEntity(itemEntity);
}
}
@@ -63,7 +63,7 @@ shared_ptr<ItemInstance> MinecartContainer::getItem(unsigned int slot)
shared_ptr<ItemInstance> MinecartContainer::removeItem(unsigned int slot, int count)
{
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
if (items[slot]->count <= count)
{
@@ -83,7 +83,7 @@ shared_ptr<ItemInstance> MinecartContainer::removeItem(unsigned int slot, int co
shared_ptr<ItemInstance> MinecartContainer::removeItemNoUpdate(int slot)
{
- if (items[slot] != NULL)
+ if (items[slot] != nullptr)
{
shared_ptr<ItemInstance> item = items[slot];
items[slot] = nullptr;
@@ -95,7 +95,7 @@ shared_ptr<ItemInstance> MinecartContainer::removeItemNoUpdate(int slot)
void MinecartContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
items[slot] = item;
- if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize();
+ if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize();
}
void MinecartContainer::setChanged()
@@ -145,7 +145,7 @@ void MinecartContainer::remove()
for (int i = 0; i < getContainerSize(); i++)
{
shared_ptr<ItemInstance> 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;
@@ -157,17 +157,17 @@ void MinecartContainer::remove()
if (count > item->count) count = item->count;
item->count -= count;
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue()))));
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>(new ItemInstance(item->id, count, item->getAuxValue())));
if (item->hasTag())
{
- itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy());
+ itemEntity->getItem()->setTag(static_cast<CompoundTag *>(item->getTag()->copy()));
}
float pow = 0.05f;
- itemEntity->xd = (float) random->nextGaussian() * pow;
- itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f;
- itemEntity->zd = (float) random->nextGaussian() * pow;
+ itemEntity->xd = static_cast<float>(random->nextGaussian()) * pow;
+ itemEntity->yd = static_cast<float>(random->nextGaussian()) * pow + 0.2f;
+ itemEntity->zd = static_cast<float>(random->nextGaussian()) * pow;
level->addEntity(itemEntity);
}
}
@@ -185,10 +185,10 @@ void MinecartContainer::addAdditonalSaveData(CompoundTag *base)
for (int i = 0; i < items.length; i++)
{
- if (items[i] != NULL)
+ if (items[i] != nullptr)
{
CompoundTag *tag = new CompoundTag();
- tag->putByte(L"Slot", (byte) i);
+ tag->putByte(L"Slot", static_cast<byte>(i));
items[i]->save(tag);
listTag->add(tag);
}
diff --git a/Minecraft.World/MinecartFurnace.cpp b/Minecraft.World/MinecartFurnace.cpp
index 24950d5c..fa005eca 100644
--- a/Minecraft.World/MinecartFurnace.cpp
+++ b/Minecraft.World/MinecartFurnace.cpp
@@ -37,7 +37,7 @@ int MinecartFurnace::getType()
void MinecartFurnace::defineSynchedData()
{
Minecart::defineSynchedData();
- entityData->define(DATA_ID_FUEL, (byte) 0);
+ entityData->define(DATA_ID_FUEL, static_cast<byte>(0));
}
void MinecartFurnace::tick()
@@ -66,7 +66,7 @@ void MinecartFurnace::destroy(DamageSource *source)
if (!source->isExplosion())
{
- spawnAtLocation(shared_ptr<ItemInstance>(new ItemInstance(Tile::furnace, 1)), 0);
+ spawnAtLocation(std::make_shared<ItemInstance>(Tile::furnace, 1), 0);
}
}
@@ -123,7 +123,7 @@ void MinecartFurnace::applyNaturalSlowdown()
bool MinecartFurnace::interact(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> 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;
@@ -140,7 +140,7 @@ void MinecartFurnace::addAdditonalSaveData(CompoundTag *base)
Minecart::addAdditonalSaveData(base);
base->putDouble(L"PushX", xPush);
base->putDouble(L"PushZ", zPush);
- base->putShort(L"Fuel", (short) fuel);
+ base->putShort(L"Fuel", static_cast<short>(fuel));
}
void MinecartFurnace::readAdditionalSaveData(CompoundTag *base)
@@ -160,11 +160,11 @@ void MinecartFurnace::setHasFuel(bool fuel)
{
if (fuel)
{
- entityData->set(DATA_ID_FUEL, (byte) (entityData->getByte(DATA_ID_FUEL) | 1));
+ entityData->set(DATA_ID_FUEL, static_cast<byte>(entityData->getByte(DATA_ID_FUEL) | 1));
}
else
{
- entityData->set(DATA_ID_FUEL, (byte) (entityData->getByte(DATA_ID_FUEL) & ~1));
+ entityData->set(DATA_ID_FUEL, static_cast<byte>(entityData->getByte(DATA_ID_FUEL) & ~1));
}
}
diff --git a/Minecraft.World/MinecartItem.cpp b/Minecraft.World/MinecartItem.cpp
index 6100be65..3ffe561a 100644
--- a/Minecraft.World/MinecartItem.cpp
+++ b/Minecraft.World/MinecartItem.cpp
@@ -47,7 +47,7 @@ shared_ptr<ItemInstance> MinecartItem::MinecartDispenseBehavior::execute(BlockSo
outcome = ACTIVATED_ITEM;
- shared_ptr<Minecart> minecart = Minecart::createMinecart(world, spawnX, spawnY + yOffset, spawnZ, ((MinecartItem *) dispensed->getItem())->type);
+ shared_ptr<Minecart> minecart = Minecart::createMinecart(world, spawnX, spawnY + yOffset, spawnZ, static_cast<MinecartItem *>(dispensed->getItem())->type);
if (dispensed->hasCustomHoverName())
{
minecart->setCustomName(dispensed->getHoverName());
diff --git a/Minecraft.World/MinecartRideable.cpp b/Minecraft.World/MinecartRideable.cpp
index a006a2bc..5578fe3f 100644
--- a/Minecraft.World/MinecartRideable.cpp
+++ b/Minecraft.World/MinecartRideable.cpp
@@ -23,8 +23,8 @@ MinecartRideable::MinecartRideable(Level *level, double x, double y, double z) :
bool MinecartRideable::interact(shared_ptr<Player> player)
{
- if (rider.lock() != NULL && rider.lock()->instanceof(eTYPE_PLAYER) && rider.lock() != player) return true;
- if (rider.lock() != NULL && rider.lock() != player) return false;
+ if (rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_PLAYER) && rider.lock() != player) return true;
+ if (rider.lock() != nullptr && rider.lock() != player) return false;
if (!level->isClientSide)
{
player->ride(shared_from_this());
diff --git a/Minecraft.World/MinecartSpawner.cpp b/Minecraft.World/MinecartSpawner.cpp
index 3fcd4ef0..8dd54d01 100644
--- a/Minecraft.World/MinecartSpawner.cpp
+++ b/Minecraft.World/MinecartSpawner.cpp
@@ -10,7 +10,7 @@ MinecartSpawner::MinecartMobSpawner::MinecartMobSpawner(MinecartSpawner *parent)
void MinecartSpawner::MinecartMobSpawner::broadcastEvent(int id)
{
- m_parent->level->broadcastEntityEvent(m_parent->shared_from_this(), (byte) id);
+ m_parent->level->broadcastEntityEvent(m_parent->shared_from_this(), static_cast<byte>(id));
}
Level *MinecartSpawner::MinecartMobSpawner::getLevel()
diff --git a/Minecraft.World/MinecartTNT.cpp b/Minecraft.World/MinecartTNT.cpp
index 62aa2a35..6e72d66b 100644
--- a/Minecraft.World/MinecartTNT.cpp
+++ b/Minecraft.World/MinecartTNT.cpp
@@ -66,7 +66,7 @@ void MinecartTNT::destroy(DamageSource *source)
if (!source->isExplosion())
{
- spawnAtLocation( shared_ptr<ItemInstance>( new ItemInstance(Tile::tnt, 1) ), 0);
+ spawnAtLocation(std::make_shared<ItemInstance>(Tile::tnt, 1), 0);
}
if (source->isFire() || source->isExplosion() || speedSqr >= 0.01f)
@@ -83,7 +83,7 @@ void MinecartTNT::explode(double speedSqr)
if (speed > 5.0) speed = 5.0;
if (app.GetGameHostOption(eGameHostOption_TNT))
{
- level->explode(shared_from_this(), x, y, z, (float) (4 + random->nextDouble() * 1.5f * speed), true);
+ level->explode(shared_from_this(), x, y, z, static_cast<float>(4 + random->nextDouble() * 1.5f * speed), true);
remove();
}
}
diff --git a/Minecraft.World/Mob.cpp b/Minecraft.World/Mob.cpp
index 342400b4..17671112 100644
--- a/Minecraft.World/Mob.cpp
+++ b/Minecraft.World/Mob.cpp
@@ -43,7 +43,7 @@ void Mob::_init()
lookingAt = nullptr;
lookTime = 0;
target = nullptr;
- sensing = NULL;
+ sensing = nullptr;
equipment = ItemInstanceArray(5);
dropChances = floatArray(5);
@@ -58,7 +58,7 @@ void Mob::_init()
_isLeashed = false;
leashHolder = nullptr;
- leashInfoTag = NULL;
+ leashInfoTag = nullptr;
}
Mob::Mob( Level* level) : LivingEntity(level)
@@ -87,16 +87,16 @@ Mob::Mob( Level* level) : LivingEntity(level)
Mob::~Mob()
{
- if(lookControl != NULL) delete lookControl;
- if(moveControl != NULL) delete moveControl;
- if(jumpControl != NULL) delete jumpControl;
- if(bodyControl != NULL) delete bodyControl;
- if(navigation != NULL) delete navigation;
- if(sensing != NULL) delete sensing;
+ if(lookControl != nullptr) delete lookControl;
+ if(moveControl != nullptr) delete moveControl;
+ if(jumpControl != nullptr) delete jumpControl;
+ if(bodyControl != nullptr) delete bodyControl;
+ if(navigation != nullptr) delete navigation;
+ if(sensing != nullptr) delete sensing;
- if(leashInfoTag != NULL) delete leashInfoTag;
+ if(leashInfoTag != nullptr) delete leashInfoTag;
- if(equipment.data != NULL) delete [] equipment.data;
+ if(equipment.data != nullptr) delete [] equipment.data;
delete [] dropChances.data;
}
@@ -155,7 +155,7 @@ void Mob::ate()
void Mob::defineSynchedData()
{
LivingEntity::defineSynchedData();
- entityData->define(DATA_CUSTOM_NAME_VISIBLE, (byte) 0);
+ entityData->define(DATA_CUSTOM_NAME_VISIBLE, static_cast<byte>(0));
entityData->define(DATA_CUSTOM_NAME, L"");
}
@@ -196,7 +196,7 @@ int Mob::getExperienceReward(shared_ptr<Player> killedBy)
ItemInstanceArray slots = getEquipmentSlots();
for (int i = 0; i < slots.length; i++)
{
- if (slots[i] != NULL && dropChances[i] <= 1)
+ if (slots[i] != nullptr && dropChances[i] <= 1)
{
result += 1 + random->nextInt(3);
}
@@ -280,7 +280,7 @@ void Mob::addAdditonalSaveData(CompoundTag *entityTag)
for (int i = 0; i < equipment.length; i++)
{
CompoundTag *tag = new CompoundTag();
- if (equipment[i] != NULL) equipment[i]->save(tag);
+ if (equipment[i] != nullptr) equipment[i]->save(tag);
gear->add(tag);
}
entityTag->put(L"Equipment", gear);
@@ -296,7 +296,7 @@ void Mob::addAdditonalSaveData(CompoundTag *entityTag)
// leash info
entityTag->putBoolean(L"Leashed", _isLeashed);
- if (leashHolder != NULL)
+ if (leashHolder != nullptr)
{
CompoundTag *leashTag = new CompoundTag(L"Leash");
if ( leashHolder->instanceof(eTYPE_LIVINGENTITY) )
@@ -347,7 +347,7 @@ void Mob::readAdditionalSaveData(CompoundTag *tag)
_isLeashed = tag->getBoolean(L"Leashed");
if (_isLeashed && tag->contains(L"Leash"))
{
- leashInfoTag = (CompoundTag *)tag->getCompound(L"Leash")->copy();
+ leashInfoTag = static_cast<CompoundTag *>(tag->getCompound(L"Leash")->copy());
}
}
@@ -372,7 +372,7 @@ void Mob::aiStep()
for (auto& it : *entities)
{
shared_ptr<ItemEntity> entity = dynamic_pointer_cast<ItemEntity>(it);
- if (entity->removed || entity->getItem() == NULL) continue;
+ if (entity->removed || entity->getItem() == nullptr) continue;
shared_ptr<ItemInstance> item = entity->getItem();
int slot = getEquipmentSlotForItem(item);
@@ -381,17 +381,17 @@ void Mob::aiStep()
bool replace = true;
shared_ptr<ItemInstance> current = getCarried(slot);
- if (current != NULL)
+ if (current != nullptr)
{
if (slot == SLOT_WEAPON)
{
WeaponItem *newWeapon = dynamic_cast<WeaponItem *>(item->getItem());
WeaponItem *oldWeapon = dynamic_cast<WeaponItem *>(current->getItem());
- if ( newWeapon != NULL && oldWeapon == NULL)
+ if ( newWeapon != nullptr && oldWeapon == nullptr)
{
replace = true;
}
- else if (newWeapon != NULL && oldWeapon != NULL)
+ else if (newWeapon != nullptr && oldWeapon != nullptr)
{
if (newWeapon->getTierDamage() == oldWeapon->getTierDamage())
{
@@ -411,11 +411,11 @@ void Mob::aiStep()
{
ArmorItem *newArmor = dynamic_cast<ArmorItem *>(item->getItem());
ArmorItem *oldArmor = dynamic_cast<ArmorItem *>(current->getItem());
- if (newArmor != NULL && oldArmor == NULL)
+ if (newArmor != nullptr && oldArmor == nullptr)
{
replace = true;
}
- else if (newArmor != NULL && oldArmor != NULL)
+ else if (newArmor != nullptr && oldArmor != nullptr)
{
if (newArmor->defense == oldArmor->defense)
{
@@ -435,7 +435,7 @@ void Mob::aiStep()
if (replace)
{
- if (current != NULL && random->nextFloat() - 0.1f < dropChances[slot])
+ if (current != nullptr && random->nextFloat() - 0.1f < dropChances[slot])
{
spawnAtLocation(current, 0);
}
@@ -470,7 +470,7 @@ void Mob::checkDespawn()
return;
}
shared_ptr<Entity> player = level->getNearestPlayer(shared_from_this(), -1);
- if (player != NULL)
+ if (player != nullptr)
{
double xd = player->x - x;
double yd = player->y - y;
@@ -547,7 +547,7 @@ void Mob::serverAiStep()
if (random->nextFloat() < 0.02f)
{
shared_ptr<Player> player = level->getNearestPlayer(shared_from_this(), lookDistance);
- if (player != NULL)
+ if (player != nullptr)
{
lookingAt = player;
lookTime = 10 + random->nextInt(20);
@@ -558,9 +558,9 @@ void Mob::serverAiStep()
}
}
- if (lookingAt != NULL)
+ if (lookingAt != nullptr)
{
- lookAt(lookingAt, 10.0f, (float) getMaxHeadXRot());
+ lookAt(lookingAt, 10.0f, static_cast<float>(getMaxHeadXRot()));
if (lookTime-- <= 0 || lookingAt->removed || lookingAt->distanceToSqr(shared_from_this()) > lookDistance * lookDistance)
{
lookingAt = nullptr;
@@ -605,15 +605,15 @@ void Mob::lookAt(shared_ptr<Entity> e, float yMax, float xMax)
double sd = Mth::sqrt(xd * xd + zd * zd);
- float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90;
- float xRotD = (float) -(atan2(yd, sd) * 180 / PI);
+ float yRotD = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
+ float xRotD = static_cast<float>(-(atan2(yd, sd) * 180 / PI));
xRot = rotlerp(xRot, xRotD, xMax);
yRot = rotlerp(yRot, yRotD, yMax);
}
bool Mob::isLookingAtAnEntity()
{
- return lookingAt != NULL;
+ return lookingAt != nullptr;
}
shared_ptr<Entity> Mob::getLookingAt()
@@ -658,8 +658,8 @@ int Mob::getMaxSpawnClusterSize()
int Mob::getMaxFallDistance()
{
- if (getTarget() == NULL) return 3;
- int sacrifice = (int) (getHealth() - (getMaxHealth() * 0.33f));
+ if (getTarget() == nullptr) return 3;
+ int sacrifice = static_cast<int>(getHealth() - (getMaxHealth() * 0.33f));
sacrifice -= (3 - level->difficulty) * 4;
if (sacrifice < 0) sacrifice = 0;
return sacrifice + 3;
@@ -697,7 +697,7 @@ void Mob::dropEquipment(bool byPlayer, int playerBonusLevel)
shared_ptr<ItemInstance> item = getCarried(slot);
bool preserve = dropChances[slot] > 1;
- if (item != NULL && (byPlayer || preserve) && random->nextFloat() - playerBonusLevel * 0.01f < dropChances[slot])
+ if (item != nullptr && (byPlayer || preserve) && random->nextFloat() - playerBonusLevel * 0.01f < dropChances[slot])
{
if (!preserve && item->isDamageableItem())
{
@@ -726,10 +726,10 @@ void Mob::populateDefaultEquipmentSlots()
{
shared_ptr<ItemInstance> item = getArmor(i);
if (i < 3 && random->nextFloat() < partialChance) break;
- if (item == NULL)
+ if (item == nullptr)
{
Item *equip = getEquipmentForSlot(i + 1, armorType);
- if (equip != NULL) setEquippedSlot(i + 1, shared_ptr<ItemInstance>(new ItemInstance(equip)));
+ if (equip != nullptr) setEquippedSlot(i + 1, std::make_shared<ItemInstance>(equip));
}
}
}
@@ -743,7 +743,7 @@ int Mob::getEquipmentSlotForItem(shared_ptr<ItemInstance> item)
}
ArmorItem *armorItem = dynamic_cast<ArmorItem *>(item->getItem());
- if (armorItem != NULL)
+ if (armorItem != nullptr)
{
switch (armorItem->slot)
{
@@ -791,23 +791,23 @@ Item *Mob::getEquipmentForSlot(int slot, int type)
if (type == 4) return Item::boots_diamond;
}
- return NULL;
+ return nullptr;
}
void Mob::populateDefaultEquipmentEnchantments()
{
float difficulty = level->getDifficulty(x, y, z);
- if (getCarriedItem() != NULL && random->nextFloat() < MAX_ENCHANTED_WEAPON_CHANCE * difficulty) {
- EnchantmentHelper::enchantItem(random, getCarriedItem(), (int) (5 + difficulty * random->nextInt(18)));
+ if (getCarriedItem() != nullptr && random->nextFloat() < MAX_ENCHANTED_WEAPON_CHANCE * difficulty) {
+ EnchantmentHelper::enchantItem(random, getCarriedItem(), static_cast<int>(5 + difficulty * random->nextInt(18)));
}
for (int i = 0; i < 4; i++)
{
shared_ptr<ItemInstance> item = getArmor(i);
- if (item != NULL && random->nextFloat() < MAX_ENCHANTED_ARMOR_CHANCE * difficulty)
+ if (item != nullptr && random->nextFloat() < MAX_ENCHANTED_ARMOR_CHANCE * difficulty)
{
- EnchantmentHelper::enchantItem(random, item, (int) (5 + difficulty * random->nextInt(18)));
+ EnchantmentHelper::enchantItem(random, item, static_cast<int>(5 + difficulty * random->nextInt(18)));
}
}
}
@@ -865,7 +865,7 @@ bool Mob::hasCustomName()
void Mob::setCustomNameVisible(bool visible)
{
- entityData->set(DATA_CUSTOM_NAME_VISIBLE, visible ? (byte) 1 : (byte) 0);
+ entityData->set(DATA_CUSTOM_NAME_VISIBLE, visible ? static_cast<byte>(1) : static_cast<byte>(0));
}
bool Mob::isCustomNameVisible()
@@ -908,7 +908,7 @@ bool Mob::interact(shared_ptr<Player> player)
}
shared_ptr<ItemInstance> itemstack = player->inventory->getSelected();
- if (itemstack != NULL)
+ if (itemstack != nullptr)
{
// it's inconvenient to have the leash code here, but it's because
// the mob.interact(player) method has priority over
@@ -953,7 +953,7 @@ bool Mob::mobInteract(shared_ptr<Player> player)
void Mob::tickLeash()
{
- if (leashInfoTag != NULL)
+ if (leashInfoTag != nullptr)
{
restoreLeashFromSave();
}
@@ -962,7 +962,7 @@ void Mob::tickLeash()
return;
}
- if (leashHolder == NULL || leashHolder->removed)
+ if (leashHolder == nullptr || leashHolder->removed)
{
dropLeash(true, true);
return;
@@ -981,9 +981,9 @@ void Mob::dropLeash(bool synch, bool createItemDrop)
}
ServerLevel *serverLevel = dynamic_cast<ServerLevel *>(level);
- if (!level->isClientSide && synch && serverLevel != NULL)
+ if (!level->isClientSide && synch && serverLevel != nullptr)
{
- serverLevel->getTracker()->broadcast(shared_from_this(), shared_ptr<SetEntityLinkPacket>(new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, shared_from_this(), nullptr)));
+ serverLevel->getTracker()->broadcast(shared_from_this(), std::make_shared<SetEntityLinkPacket>(SetEntityLinkPacket::LEASH, shared_from_this(), nullptr));
}
}
}
@@ -1011,14 +1011,14 @@ void Mob::setLeashedTo(shared_ptr<Entity> holder, bool synch)
ServerLevel *serverLevel = dynamic_cast<ServerLevel *>(level);
if (!level->isClientSide && synch && serverLevel)
{
- serverLevel->getTracker()->broadcast(shared_from_this(), shared_ptr<SetEntityLinkPacket>( new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, shared_from_this(), leashHolder)));
+ serverLevel->getTracker()->broadcast(shared_from_this(), std::make_shared<SetEntityLinkPacket>(SetEntityLinkPacket::LEASH, shared_from_this(), leashHolder));
}
}
void Mob::restoreLeashFromSave()
{
// after being added to the world, attempt to recreate leash bond
- if (_isLeashed && leashInfoTag != NULL)
+ if (_isLeashed && leashInfoTag != nullptr)
{
if (leashInfoTag->contains(L"UUID"))
{
@@ -1043,7 +1043,7 @@ void Mob::restoreLeashFromSave()
int z = leashInfoTag->getInt(L"Z");
shared_ptr<LeashFenceKnotEntity> activeKnot = LeashFenceKnotEntity::findKnotAt(level, x, y, z);
- if (activeKnot == NULL)
+ if (activeKnot == nullptr)
{
activeKnot = LeashFenceKnotEntity::createAndAddKnot(level, x, y, z);
}
@@ -1055,7 +1055,7 @@ void Mob::restoreLeashFromSave()
dropLeash(false, true);
}
}
- leashInfoTag = NULL;
+ leashInfoTag = nullptr;
}
// 4J added so we can not render mobs before their chunks are loaded - to resolve bug 10327 :Gameplay: NPCs can spawn over chunks that have not yet been streamed and display jitter.
diff --git a/Minecraft.World/Mob.h b/Minecraft.World/Mob.h
index 11310509..e070e369 100644
--- a/Minecraft.World/Mob.h
+++ b/Minecraft.World/Mob.h
@@ -27,7 +27,7 @@ class Mob : public LivingEntity
public:
// 4J-PB - added to replace (e instanceof Type), avoiding dynamic casts
eINSTANCEOF GetType() { return eTYPE_MOB;}
- static Entity *create(Level *level) { return NULL; }
+ static Entity *create(Level *level) { return nullptr; }
public:
static const float MAX_WEARING_ARMOR_CHANCE;
diff --git a/Minecraft.World/MobCategory.cpp b/Minecraft.World/MobCategory.cpp
index 507be6ed..8c6d3b44 100644
--- a/Minecraft.World/MobCategory.cpp
+++ b/Minecraft.World/MobCategory.cpp
@@ -5,14 +5,14 @@
#include "Material.h"
#include "MobCategory.h"
-MobCategory *MobCategory::monster = NULL;
-MobCategory *MobCategory::creature = NULL;
-MobCategory *MobCategory::ambient = NULL;
-MobCategory *MobCategory::waterCreature = NULL;
+MobCategory *MobCategory::monster = nullptr;
+MobCategory *MobCategory::creature = nullptr;
+MobCategory *MobCategory::ambient = nullptr;
+MobCategory *MobCategory::waterCreature = nullptr;
// 4J - added these extra categories
-MobCategory *MobCategory::creature_wolf = NULL;
-MobCategory *MobCategory::creature_chicken = NULL;
-MobCategory *MobCategory::creature_mushroomcow = NULL;
+MobCategory *MobCategory::creature_wolf = nullptr;
+MobCategory *MobCategory::creature_chicken = nullptr;
+MobCategory *MobCategory::creature_mushroomcow = nullptr;
MobCategoryArray MobCategory::values = MobCategoryArray(7);
diff --git a/Minecraft.World/MobEffect.cpp b/Minecraft.World/MobEffect.cpp
index 92f8c9d0..4ded9c41 100644
--- a/Minecraft.World/MobEffect.cpp
+++ b/Minecraft.World/MobEffect.cpp
@@ -46,7 +46,7 @@ MobEffect *MobEffect::reserved_31;
void MobEffect::staticCtor()
{
- voidEffect = NULL;
+ voidEffect = nullptr;
movementSpeed = (new MobEffect(1, false, eMinecraftColour_Effect_MovementSpeed)) ->setDescriptionId(IDS_POTION_MOVESPEED) ->setPostfixDescriptionId(IDS_POTION_MOVESPEED_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Speed)->addAttributeModifier(SharedMonsterAttributes::MOVEMENT_SPEED, eModifierId_POTION_MOVESPEED, 0.2f, AttributeModifier::OPERATION_MULTIPLY_TOTAL); //setIcon(0, 0);
movementSlowdown = (new MobEffect(2, true, eMinecraftColour_Effect_MovementSlowDown)) ->setDescriptionId(IDS_POTION_MOVESLOWDOWN) ->setPostfixDescriptionId(IDS_POTION_MOVESLOWDOWN_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Slowness)->addAttributeModifier(SharedMonsterAttributes::MOVEMENT_SPEED, eModifierId_POTION_MOVESLOWDOWN, -0.15f, AttributeModifier::OPERATION_MULTIPLY_TOTAL); //->setIcon(1, 0);
digSpeed = (new MobEffect(3, false, eMinecraftColour_Effect_DigSpeed)) ->setDescriptionId(IDS_POTION_DIGSPEED) ->setPostfixDescriptionId(IDS_POTION_DIGSPEED_POSTFIX)->setDurationModifier(1.5)->setIcon(MobEffect::e_MobEffectIcon_Haste); //->setIcon(2, 0);
@@ -70,14 +70,14 @@ void MobEffect::staticCtor()
healthBoost = (new HealthBoostMobEffect(21, false, eMinecraftColour_Effect_HealthBoost)) ->setDescriptionId(IDS_POTION_HEALTHBOOST) ->setPostfixDescriptionId(IDS_POTION_HEALTHBOOST_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_HealthBoost)->addAttributeModifier(SharedMonsterAttributes::MAX_HEALTH, eModifierId_POTION_HEALTHBOOST, 4, AttributeModifier::OPERATION_ADDITION);
absorption = (new AbsoptionMobEffect(22, false, eMinecraftColour_Effect_Absoprtion)) ->setDescriptionId(IDS_POTION_ABSORPTION) ->setPostfixDescriptionId(IDS_POTION_ABSORPTION_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Absorption);
saturation = (new InstantenousMobEffect(23, false, eMinecraftColour_Effect_Saturation)) ->setDescriptionId(IDS_POTION_SATURATION) ->setPostfixDescriptionId(IDS_POTION_SATURATION_POSTFIX);
- reserved_24 = NULL;
- reserved_25 = NULL;
- reserved_26 = NULL;
- reserved_27 = NULL;
- reserved_28 = NULL;
- reserved_29 = NULL;
- reserved_30 = NULL;
- reserved_31 = NULL;
+ reserved_24 = nullptr;
+ reserved_25 = nullptr;
+ reserved_26 = nullptr;
+ reserved_27 = nullptr;
+ reserved_28 = nullptr;
+ reserved_29 = nullptr;
+ reserved_30 = nullptr;
+ reserved_31 = nullptr;
}
MobEffect::MobEffect(int id, bool isHarmful, eMinecraftColour color) : id(id), _isHarmful(isHarmful), color(color)
@@ -173,13 +173,13 @@ void MobEffect::applyInstantenousEffect(shared_ptr<LivingEntity> source, shared_
{
if ((id == heal->id && !mob->isInvertedHealAndHarm()) || (id == harm->id && mob->isInvertedHealAndHarm()))
{
- int amount = (int) (scale * (double) (4 << amplification) + .5);
+ int amount = static_cast<int>(scale * (double)(4 << amplification) + .5);
mob->heal(amount);
}
else if ((id == harm->id && !mob->isInvertedHealAndHarm()) || (id == heal->id && mob->isInvertedHealAndHarm()))
{
- int amount = (int) (scale * (double) (6 << amplification) + .5);
- if (source == NULL)
+ int amount = static_cast<int>(scale * (double)(6 << amplification) + .5);
+ if (source == nullptr)
{
mob->hurt(DamageSource::magic, amount);
}
@@ -359,7 +359,7 @@ void MobEffect::removeAttributeModifiers(shared_ptr<LivingEntity> entity, BaseAt
{
AttributeInstance *attribute = attributes->getInstance(it.first);
- if (attribute != NULL)
+ if (attribute != nullptr)
{
attribute->removeModifier(it.second);
}
@@ -372,7 +372,7 @@ void MobEffect::addAttributeModifiers(shared_ptr<LivingEntity> entity, BaseAttri
{
AttributeInstance *attribute = attributes->getInstance(it.first);
- if (attribute != NULL)
+ if (attribute != nullptr)
{
AttributeModifier *original = it.second;
attribute->removeModifier(original);
diff --git a/Minecraft.World/MobEffectInstance.cpp b/Minecraft.World/MobEffectInstance.cpp
index 2ca696f6..117311c3 100644
--- a/Minecraft.World/MobEffectInstance.cpp
+++ b/Minecraft.World/MobEffectInstance.cpp
@@ -172,8 +172,8 @@ bool MobEffectInstance::equals(MobEffectInstance *instance)
CompoundTag *MobEffectInstance::save(CompoundTag *tag)
{
- tag->putByte(L"Id", (byte) getId());
- tag->putByte(L"Amplifier", (byte) getAmplifier());
+ tag->putByte(L"Id", static_cast<byte>(getId()));
+ tag->putByte(L"Amplifier", static_cast<byte>(getAmplifier()));
tag->putInt(L"Duration", getDuration());
tag->putBoolean(L"Ambient", isAmbient());
return tag;
diff --git a/Minecraft.World/MobSpawner.cpp b/Minecraft.World/MobSpawner.cpp
index e593a59f..35b24721 100644
--- a/Minecraft.World/MobSpawner.cpp
+++ b/Minecraft.World/MobSpawner.cpp
@@ -118,7 +118,7 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
// 4J - rewritten to add chunks interleaved by player, and to add them from the centre outwards. We're going to be
// potentially adding less creatures than the original so that our count stays consistent with number of players added, so
// we want to make sure as best we can that the ones we do add are near the active players
- int playerCount = (int)level->players.size();
+ int playerCount = static_cast<int>(level->players.size());
int *xx = new int[playerCount];
int *zz = new int[playerCount];
for (int i = 0; i < playerCount; i++)
@@ -251,8 +251,8 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
int z = zStart;
int ss = 6;
- Biome::MobSpawnerData *currentMobType = NULL;
- MobGroupData *groupData = NULL;
+ Biome::MobSpawnerData *currentMobType = nullptr;
+ MobGroupData *groupData = nullptr;
for (int ll = 0; ll < 4; ll++)
{
@@ -267,9 +267,9 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
if (isSpawnPositionOk(mobCategory, level, x, y, z))
{
float xx = x + 0.5f;
- float yy = (float) y;
+ float yy = static_cast<float>(y);
float zz = z + 0.5f;
- if (level->getNearestPlayer(xx, yy, zz, MIN_SPAWN_DISTANCE) != NULL)
+ if (level->getNearestPlayer(xx, yy, zz, MIN_SPAWN_DISTANCE) != nullptr)
{
continue;
}
@@ -285,10 +285,10 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
}
}
- if (currentMobType == NULL)
+ if (currentMobType == nullptr)
{
currentMobType = level->getRandomMobSpawnAt(mobCategory, x, y, z);
- if (currentMobType == NULL)
+ if (currentMobType == nullptr)
{
break;
}
@@ -440,7 +440,7 @@ void MobSpawner::postProcessSpawnMobs(Level *level, Biome *biome, int xo, int zo
while (random->nextFloat() < biome->getCreatureProbability())
{
Biome::MobSpawnerData *type = (Biome::MobSpawnerData *) WeighedRandom::getRandomItem(level->random, ((vector<WeighedRandomItem *> *)mobs));
- MobGroupData *groupData = NULL;
+ MobGroupData *groupData = nullptr;
int count = type->minCount + random->nextInt(1 + type->maxCount - type->minCount);
int x = xo + random->nextInt(cellWidth);
diff --git a/Minecraft.World/MobSpawnerTile.cpp b/Minecraft.World/MobSpawnerTile.cpp
index 4665015a..08c1f87d 100644
--- a/Minecraft.World/MobSpawnerTile.cpp
+++ b/Minecraft.World/MobSpawnerTile.cpp
@@ -9,7 +9,7 @@ MobSpawnerTile::MobSpawnerTile(int id) : BaseEntityTile(id, Material::stone, isS
shared_ptr<TileEntity> MobSpawnerTile::newTileEntity(Level *level)
{
- return shared_ptr<MobSpawnerTileEntity>( new MobSpawnerTileEntity() );
+ return std::make_shared<MobSpawnerTileEntity>();
}
int MobSpawnerTile::getResource(int data, Random *random, int playerBonusLevel)
diff --git a/Minecraft.World/MobSpawnerTileEntity.cpp b/Minecraft.World/MobSpawnerTileEntity.cpp
index 013503b6..e3ee57d6 100644
--- a/Minecraft.World/MobSpawnerTileEntity.cpp
+++ b/Minecraft.World/MobSpawnerTileEntity.cpp
@@ -37,7 +37,7 @@ int MobSpawnerTileEntity::TileEntityMobSpawner::getZ()
void MobSpawnerTileEntity::TileEntityMobSpawner::setNextSpawnData(BaseMobSpawner::SpawnData *nextSpawnData)
{
BaseMobSpawner::setNextSpawnData(nextSpawnData);
- if (getLevel() != NULL) getLevel()->sendTileUpdated(m_parent->x, m_parent->y, m_parent->z);
+ if (getLevel() != nullptr) getLevel()->sendTileUpdated(m_parent->x, m_parent->y, m_parent->z);
}
MobSpawnerTileEntity::MobSpawnerTileEntity()
@@ -73,7 +73,7 @@ shared_ptr<Packet> MobSpawnerTileEntity::getUpdatePacket()
CompoundTag *tag = new CompoundTag();
save(tag);
tag->remove(L"SpawnPotentials");
- return shared_ptr<TileEntityDataPacket>( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_MOB_SPAWNER, tag) );
+ return std::make_shared<TileEntityDataPacket>(x, y, z, TileEntityDataPacket::TYPE_MOB_SPAWNER, tag);
}
bool MobSpawnerTileEntity::triggerEvent(int b0, int b1)
@@ -90,7 +90,7 @@ BaseMobSpawner *MobSpawnerTileEntity::getSpawner()
// 4J Added
shared_ptr<TileEntity> MobSpawnerTileEntity::clone()
{
- shared_ptr<MobSpawnerTileEntity> result = shared_ptr<MobSpawnerTileEntity>( new MobSpawnerTileEntity() );
+ shared_ptr<MobSpawnerTileEntity> result = std::make_shared<MobSpawnerTileEntity>();
TileEntity::clone(result);
return result;
diff --git a/Minecraft.World/MockedLevelStorage.cpp b/Minecraft.World/MockedLevelStorage.cpp
index 9a7a63c0..56910e3e 100644
--- a/Minecraft.World/MockedLevelStorage.cpp
+++ b/Minecraft.World/MockedLevelStorage.cpp
@@ -9,7 +9,7 @@
LevelData *MockedLevelStorage::prepareLevel()
{
- return NULL;
+ return nullptr;
}
void MockedLevelStorage::checkSession()
@@ -18,7 +18,7 @@ void MockedLevelStorage::checkSession()
ChunkStorage *MockedLevelStorage::createChunkStorage(Dimension *dimension)
{
- return NULL;
+ return nullptr;
}
void MockedLevelStorage::saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players)
@@ -31,7 +31,7 @@ void MockedLevelStorage::saveLevelData(LevelData *levelData)
PlayerIO *MockedLevelStorage::getPlayerIO()
{
- return NULL;
+ return nullptr;
}
void MockedLevelStorage::closeAll()
diff --git a/Minecraft.World/MockedLevelStorage.h b/Minecraft.World/MockedLevelStorage.h
index 6a9eed70..faa50582 100644
--- a/Minecraft.World/MockedLevelStorage.h
+++ b/Minecraft.World/MockedLevelStorage.h
@@ -18,5 +18,5 @@ public:
virtual ConsoleSavePath getDataFile(const wstring& id);
virtual wstring getLevelId();
public:
- virtual ConsoleSaveFile *getSaveFile() { return NULL; }
+ virtual ConsoleSaveFile *getSaveFile() { return nullptr; }
}; \ No newline at end of file
diff --git a/Minecraft.World/ModifiableAttributeInstance.cpp b/Minecraft.World/ModifiableAttributeInstance.cpp
index 3108df4d..216e5719 100644
--- a/Minecraft.World/ModifiableAttributeInstance.cpp
+++ b/Minecraft.World/ModifiableAttributeInstance.cpp
@@ -62,7 +62,7 @@ void ModifiableAttributeInstance::getModifiers(unordered_set<AttributeModifier *
AttributeModifier *ModifiableAttributeInstance::getModifier(eMODIFIER_ID id)
{
- AttributeModifier *modifier = NULL;
+ AttributeModifier *modifier = nullptr;
auto it = modifierById.find(id);
if(it != modifierById.end())
@@ -85,7 +85,7 @@ void ModifiableAttributeInstance::addModifiers(unordered_set<AttributeModifier *
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)
+ if (modifier->getId() != eModifierId_ANONYMOUS && getModifier(modifier->getId()) != nullptr)
{
assert(0);
// throw new IllegalArgumentException("Modifier is already applied on this attribute!");
@@ -126,7 +126,7 @@ void ModifiableAttributeInstance::removeModifier(AttributeModifier *modifier)
void ModifiableAttributeInstance::removeModifier(eMODIFIER_ID id)
{
AttributeModifier *modifier = getModifier(id);
- if (modifier != NULL) removeModifier(modifier);
+ if (modifier != nullptr) removeModifier(modifier);
}
void ModifiableAttributeInstance::removeModifiers()
diff --git a/Minecraft.World/Monster.cpp b/Minecraft.World/Monster.cpp
index 174a706c..2de45315 100644
--- a/Minecraft.World/Monster.cpp
+++ b/Minecraft.World/Monster.cpp
@@ -46,7 +46,7 @@ shared_ptr<Entity> Monster::findAttackTarget()
#endif
shared_ptr<Player> player = level->getNearestAttackablePlayer(shared_from_this(), 16);
- if (player != NULL && canSee(player) ) return player;
+ if (player != nullptr && canSee(player) ) return player;
return shared_ptr<Player>();
}
@@ -75,7 +75,7 @@ bool Monster::hurt(DamageSource *source, float dmg)
*/
bool Monster::doHurtTarget(shared_ptr<Entity> target)
{
- float dmg = (float) getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->getValue();
+ float dmg = static_cast<float>(getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->getValue());
int knockback = 0;
diff --git a/Minecraft.World/Monster.h b/Minecraft.World/Monster.h
index 33f72b0e..2c21b1d2 100644
--- a/Minecraft.World/Monster.h
+++ b/Minecraft.World/Monster.h
@@ -12,7 +12,7 @@ class Monster : public PathfinderMob, public Enemy
{
public:
eINSTANCEOF GetType() { return eTYPE_MONSTER; }
- static Entity *create(Level *level) { return NULL; }
+ static Entity *create(Level *level) { return nullptr; }
public:
Monster(Level *level);
diff --git a/Minecraft.World/MonsterRoomFeature.cpp b/Minecraft.World/MonsterRoomFeature.cpp
index 17ac55ae..e11ebcb2 100644
--- a/Minecraft.World/MonsterRoomFeature.cpp
+++ b/Minecraft.World/MonsterRoomFeature.cpp
@@ -110,7 +110,7 @@ bool MonsterRoomFeature::place(Level *level, Random *random, int x, int y, int z
WeighedTreasureArray wrapperArray(monsterRoomTreasure, TREASURE_ITEMS_COUNT);
WeighedTreasureArray treasure = WeighedTreasure::addToTreasure(wrapperArray, Item::enchantedBook->createForRandomTreasure(random));
shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity >( level->getTileEntity(xc, yc, zc) );
- if (chest != NULL )
+ if (chest != nullptr )
{
WeighedTreasure::addChestItems(random, treasure, chest, 8);
}
@@ -122,7 +122,7 @@ bool MonsterRoomFeature::place(Level *level, Random *random, int x, int y, int z
level->setTileAndData(x, y, z, Tile::mobSpawner_Id, 0, Tile::UPDATE_CLIENTS);
shared_ptr<MobSpawnerTileEntity> entity = dynamic_pointer_cast<MobSpawnerTileEntity>( level->getTileEntity(x, y, z) );
- if( entity != NULL )
+ if( entity != nullptr )
{
entity->getSpawner()->setEntityId(randomEntityId(random));
}
diff --git a/Minecraft.World/MoveControl.cpp b/Minecraft.World/MoveControl.cpp
index 02b5a9e0..d2a529a1 100644
--- a/Minecraft.World/MoveControl.cpp
+++ b/Minecraft.World/MoveControl.cpp
@@ -54,10 +54,10 @@ void MoveControl::tick()
double dd = xd * xd + yd * yd + zd * zd;
if (dd < MIN_SPEED_SQR) return;
- float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90;
+ float yRotD = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
mob->yRot = rotlerp(mob->yRot, yRotD, MAX_TURN);
- mob->setSpeed((float) (speedModifier * mob->getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue()));
+ mob->setSpeed(static_cast<float>(speedModifier * mob->getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue()));
if (yd > 0 && xd * xd + zd * zd < 1) mob->getJumpControl()->jump();
}
diff --git a/Minecraft.World/MoveEntityPacket.cpp b/Minecraft.World/MoveEntityPacket.cpp
index b52482f5..cae28e91 100644
--- a/Minecraft.World/MoveEntityPacket.cpp
+++ b/Minecraft.World/MoveEntityPacket.cpp
@@ -40,7 +40,7 @@ void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
}
- dos->writeShort((short)id);
+ dos->writeShort(static_cast<short>(id));
}
void MoveEntityPacket::handle(PacketListener *listener)
@@ -61,7 +61,7 @@ bool MoveEntityPacket::canBeInvalidated()
bool MoveEntityPacket::isInvalidatedBy(shared_ptr<Packet> packet)
{
shared_ptr<MoveEntityPacket> target = dynamic_pointer_cast<MoveEntityPacket>(packet);
- return target != NULL && target->id == id;
+ return target != nullptr && target->id == id;
}
MoveEntityPacket::PosRot::PosRot()
diff --git a/Minecraft.World/MoveEntityPacket.h b/Minecraft.World/MoveEntityPacket.h
index ab16ac3a..dc0f44d5 100644
--- a/Minecraft.World/MoveEntityPacket.h
+++ b/Minecraft.World/MoveEntityPacket.h
@@ -27,7 +27,7 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MoveEntityPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MoveEntityPacket>(); }
virtual int getId() { return 30; }
};
@@ -42,7 +42,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MoveEntityPacket::PosRot()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MoveEntityPacket::PosRot>(); }
virtual int getId() { return 33; }
};
@@ -57,7 +57,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MoveEntityPacket::Pos()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MoveEntityPacket::Pos>(); }
virtual int getId() { return 31; }
};
@@ -72,7 +72,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MoveEntityPacket::Rot()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MoveEntityPacket::Rot>(); }
virtual int getId() { return 32; }
}; \ No newline at end of file
diff --git a/Minecraft.World/MoveEntityPacketSmall.cpp b/Minecraft.World/MoveEntityPacketSmall.cpp
index 8216478f..ec67f37f 100644
--- a/Minecraft.World/MoveEntityPacketSmall.cpp
+++ b/Minecraft.World/MoveEntityPacketSmall.cpp
@@ -47,7 +47,7 @@ void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
}
- dos->writeShort((short)id);
+ dos->writeShort(static_cast<short>(id));
}
void MoveEntityPacketSmall::handle(PacketListener *listener)
@@ -68,7 +68,7 @@ bool MoveEntityPacketSmall::canBeInvalidated()
bool MoveEntityPacketSmall::isInvalidatedBy(shared_ptr<Packet> packet)
{
shared_ptr<MoveEntityPacketSmall> target = dynamic_pointer_cast<MoveEntityPacketSmall>(packet);
- return target != NULL && target->id == id;
+ return target != nullptr && target->id == id;
}
MoveEntityPacketSmall::PosRot::PosRot()
@@ -131,7 +131,7 @@ void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException
int idAndY = dis->readShort();
this->id = idAndY & 0x07ff;
this->ya = idAndY >> 11;
- int XandZ = (int)((signed char)(dis->readByte()));
+ int XandZ = (int)static_cast<signed char>(dis->readByte());
xa = XandZ >> 4;
za = ( XandZ << 28 ) >> 28;
}
diff --git a/Minecraft.World/MoveEntityPacketSmall.h b/Minecraft.World/MoveEntityPacketSmall.h
index 4218f11b..c3f357dd 100644
--- a/Minecraft.World/MoveEntityPacketSmall.h
+++ b/Minecraft.World/MoveEntityPacketSmall.h
@@ -27,7 +27,7 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MoveEntityPacketSmall()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MoveEntityPacketSmall>(); }
virtual int getId() { return 162; }
};
@@ -42,7 +42,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MoveEntityPacketSmall::PosRot()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MoveEntityPacketSmall::PosRot>(); }
virtual int getId() { return 165; }
};
@@ -57,7 +57,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MoveEntityPacketSmall::Pos()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MoveEntityPacketSmall::Pos>(); }
virtual int getId() { return 163; }
};
@@ -73,7 +73,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MoveEntityPacketSmall::Rot()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MoveEntityPacketSmall::Rot>(); }
virtual int getId() { return 164; }
}; \ No newline at end of file
diff --git a/Minecraft.World/MoveIndoorsGoal.cpp b/Minecraft.World/MoveIndoorsGoal.cpp
index 395fe578..f329a6bb 100644
--- a/Minecraft.World/MoveIndoorsGoal.cpp
+++ b/Minecraft.World/MoveIndoorsGoal.cpp
@@ -22,10 +22,10 @@ bool MoveIndoorsGoal::canUse()
if (mob->getRandom()->nextInt(50) != 0) return false;
if (insideX != -1 && mob->distanceToSqr(insideX, mob->y, insideZ) < 2 * 2) return false;
shared_ptr<Village> village = mob->level->villages->getClosestVillage(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 14);
- if (village == NULL) return false;
+ if (village == nullptr) return false;
shared_ptr<DoorInfo> _doorInfo = village->getBestDoorInfo(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z));
doorInfo = _doorInfo;
- return _doorInfo != NULL;
+ return _doorInfo != nullptr;
}
bool MoveIndoorsGoal::canContinueToUse()
@@ -37,7 +37,7 @@ void MoveIndoorsGoal::start()
{
insideX = -1;
shared_ptr<DoorInfo> _doorInfo = doorInfo.lock();
- if( _doorInfo == NULL )
+ if( _doorInfo == nullptr )
{
doorInfo = weak_ptr<DoorInfo>();
return;
@@ -45,7 +45,7 @@ void MoveIndoorsGoal::start()
if (mob->distanceToSqr(_doorInfo->getIndoorX(), _doorInfo->y, _doorInfo->getIndoorZ()) > 16 * 16)
{
Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 14, 3, Vec3::newTemp(_doorInfo->getIndoorX() + 0.5, _doorInfo->getIndoorY(), _doorInfo->getIndoorZ() + 0.5));
- if (pos != NULL) mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, 1.0f);
+ if (pos != nullptr) mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, 1.0f);
}
else mob->getNavigation()->moveTo(_doorInfo->getIndoorX() + 0.5, _doorInfo->getIndoorY(), _doorInfo->getIndoorZ() + 0.5, 1.0f);
}
@@ -53,7 +53,7 @@ void MoveIndoorsGoal::start()
void MoveIndoorsGoal::stop()
{
shared_ptr<DoorInfo> _doorInfo = doorInfo.lock();
- if( _doorInfo == NULL )
+ if( _doorInfo == nullptr )
{
doorInfo = weak_ptr<DoorInfo>();
return;
diff --git a/Minecraft.World/MovePlayerPacket.h b/Minecraft.World/MovePlayerPacket.h
index 26ae8392..1850c9d3 100644
--- a/Minecraft.World/MovePlayerPacket.h
+++ b/Minecraft.World/MovePlayerPacket.h
@@ -27,7 +27,7 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MovePlayerPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MovePlayerPacket>(); }
virtual int getId() { return 10; }
};
@@ -42,7 +42,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MovePlayerPacket::PosRot()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MovePlayerPacket::PosRot>(); }
virtual int getId() { return 13; }
};
@@ -57,7 +57,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MovePlayerPacket::Pos()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MovePlayerPacket::Pos>(); }
virtual int getId() { return 11; }
};
@@ -72,7 +72,7 @@ public:
virtual void write(DataOutputStream *dos);
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new MovePlayerPacket::Rot()); }
+ static shared_ptr<Packet> create() { return std::make_shared<MovePlayerPacket::Rot>(); }
virtual int getId() { return 12; }
}; \ No newline at end of file
diff --git a/Minecraft.World/MoveThroughVillageGoal.cpp b/Minecraft.World/MoveThroughVillageGoal.cpp
index f112c109..81476aec 100644
--- a/Minecraft.World/MoveThroughVillageGoal.cpp
+++ b/Minecraft.World/MoveThroughVillageGoal.cpp
@@ -11,7 +11,7 @@
MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob *mob, double speedModifier, bool onlyAtNight)
{
- path = NULL;
+ path = nullptr;
doorInfo = weak_ptr<DoorInfo>();
this->mob = mob;
@@ -22,7 +22,7 @@ MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob *mob, double speedM
MoveThroughVillageGoal::~MoveThroughVillageGoal()
{
- if(path != NULL) delete path;
+ if(path != nullptr) delete path;
}
bool MoveThroughVillageGoal::canUse()
@@ -32,10 +32,10 @@ bool MoveThroughVillageGoal::canUse()
if (onlyAtNight && mob->level->isDay()) return false;
shared_ptr<Village> village = mob->level->villages->getClosestVillage(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 0);
- if (village == NULL) return false;
+ if (village == nullptr) return false;
shared_ptr<DoorInfo> _doorInfo = getNextDoorInfo(village);
- if (_doorInfo == NULL) return false;
+ if (_doorInfo == nullptr) return false;
doorInfo = _doorInfo;
bool oldCanOpenDoors = mob->getNavigation()->canOpenDoors();
@@ -44,15 +44,15 @@ bool MoveThroughVillageGoal::canUse()
path = mob->getNavigation()->createPath(_doorInfo->x, _doorInfo->y, _doorInfo->z);
mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors);
- if (path != NULL) return true;
+ if (path != nullptr) return true;
Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10, 7, Vec3::newTemp(_doorInfo->x, _doorInfo->y, _doorInfo->z));
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
mob->getNavigation()->setCanOpenDoors(false);
delete path;
path = mob->getNavigation()->createPath(pos->x, pos->y, pos->z);
mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors);
- return path != NULL;
+ return path != nullptr;
}
bool MoveThroughVillageGoal::canContinueToUse()
@@ -60,7 +60,7 @@ bool MoveThroughVillageGoal::canContinueToUse()
if (mob->getNavigation()->isDone()) return false;
float dist = mob->bbWidth + 4.f;
shared_ptr<DoorInfo> _doorInfo = doorInfo.lock();
- if( _doorInfo == NULL ) return false;
+ if( _doorInfo == nullptr ) return false;
return mob->distanceToSqr(_doorInfo->x, _doorInfo->y, _doorInfo->z) > dist * dist;
}
@@ -68,13 +68,13 @@ bool MoveThroughVillageGoal::canContinueToUse()
void MoveThroughVillageGoal::start()
{
mob->getNavigation()->moveTo(path, speedModifier);
- path = NULL;
+ path = nullptr;
}
void MoveThroughVillageGoal::stop()
{
shared_ptr<DoorInfo> _doorInfo = doorInfo.lock();
- if( _doorInfo == NULL ) return;
+ if( _doorInfo == nullptr ) return;
if (mob->getNavigation()->isDone() || mob->distanceToSqr(_doorInfo->x, _doorInfo->y, _doorInfo->z) < 4 * 4)
{
diff --git a/Minecraft.World/MoveTowardsRestrictionGoal.cpp b/Minecraft.World/MoveTowardsRestrictionGoal.cpp
index 2c3900b6..1d54f935 100644
--- a/Minecraft.World/MoveTowardsRestrictionGoal.cpp
+++ b/Minecraft.World/MoveTowardsRestrictionGoal.cpp
@@ -20,7 +20,7 @@ bool MoveTowardsRestrictionGoal::canUse()
if (mob->isWithinRestriction()) return false;
Pos *towards = mob->getRestrictCenter();
Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16, 7, Vec3::newTemp(towards->x, towards->y, towards->z));
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
wantedX = pos->x;
wantedY = pos->y;
wantedZ = pos->z;
diff --git a/Minecraft.World/MoveTowardsTargetGoal.cpp b/Minecraft.World/MoveTowardsTargetGoal.cpp
index c0537d1f..a0e18115 100644
--- a/Minecraft.World/MoveTowardsTargetGoal.cpp
+++ b/Minecraft.World/MoveTowardsTargetGoal.cpp
@@ -17,10 +17,10 @@ MoveTowardsTargetGoal::MoveTowardsTargetGoal(PathfinderMob *mob, double speedMod
bool MoveTowardsTargetGoal::canUse()
{
target = weak_ptr<LivingEntity>(mob->getTarget());
- if (target.lock() == NULL) return false;
+ if (target.lock() == nullptr) return false;
if (target.lock()->distanceToSqr(mob->shared_from_this()) > within * within) return false;
Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16, 7, Vec3::newTemp(target.lock()->x, target.lock()->y, target.lock()->z));
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
wantedX = pos->x;
wantedY = pos->y;
wantedZ = pos->z;
@@ -29,7 +29,7 @@ bool MoveTowardsTargetGoal::canUse()
bool MoveTowardsTargetGoal::canContinueToUse()
{
- return target.lock() != NULL && !mob->getNavigation()->isDone() && target.lock()->isAlive() && target.lock()->distanceToSqr(mob->shared_from_this()) < within * within;
+ return target.lock() != nullptr && !mob->getNavigation()->isDone() && target.lock()->isAlive() && target.lock()->distanceToSqr(mob->shared_from_this()) < within * within;
}
void MoveTowardsTargetGoal::stop()
diff --git a/Minecraft.World/Mth.cpp b/Minecraft.World/Mth.cpp
index 77987917..4ec4f78b 100644
--- a/Minecraft.World/Mth.cpp
+++ b/Minecraft.World/Mth.cpp
@@ -9,7 +9,7 @@ const float Mth::DEGRAD = PI / 180.0f;
const float Mth::RADDEG = 180.0f / PI;
const float Mth::RAD_TO_GRAD = PI / 180.0f;
-float *Mth::_sin = NULL;
+float *Mth::_sin = nullptr;
const float Mth::sinScale = 65536.0f / (float) (PI * 2);
@@ -25,14 +25,14 @@ void Mth::init()
float Mth::sin(float i)
{
- if(_sin == NULL) init(); // 4J - added
- return _sin[(int) (i * sinScale) & 65535];
+ if(_sin == nullptr) init(); // 4J - added
+ return _sin[static_cast<int>(i * sinScale) & 65535];
}
float Mth::cos(float i)
{
- if(_sin == NULL) init(); // 4J - added
- return _sin[(int) (i * sinScale + 65536 / 4) & 65535];
+ if(_sin == nullptr) init(); // 4J - added
+ return _sin[static_cast<int>(i * sinScale + 65536 / 4) & 65535];
}
float Mth::sqrt(float x)
@@ -42,35 +42,35 @@ float Mth::sqrt(float x)
float Mth::sqrt(double x)
{
- return (float) ::sqrt(x);
+ return static_cast<float>(::sqrt(x));
}
int Mth::floor(float v)
{
- int i = (int) v;
+ int i = static_cast<int>(v);
return v < i ? i - 1 : i;
}
int64_t Mth::lfloor(double v)
{
- int64_t i = (int64_t) v;
+ int64_t i = static_cast<int64_t>(v);
return v < i ? i - 1 : i;
}
int Mth::fastFloor(double x)
{
- return (int) (x + BIG_ENOUGH_FLOAT) - BIG_ENOUGH_INT;
+ return static_cast<int>(x + BIG_ENOUGH_FLOAT) - BIG_ENOUGH_INT;
}
int Mth::floor(double v)
{
- int i = (int) v;
+ int i = static_cast<int>(v);
return v < i ? i - 1 : i;
}
int Mth::absFloor(double v)
{
- return (int) (v >= 0 ? v : -v + 1);
+ return static_cast<int>(v >= 0 ? v : -v + 1);
}
float Mth::abs(float v)
@@ -85,7 +85,7 @@ int Mth::abs(int v)
int Mth::ceil(float v)
{
- int i = (int) v;
+ int i = static_cast<int>(v);
return v > i ? i + 1 : i;
}
diff --git a/Minecraft.World/Mushroom.cpp b/Minecraft.World/Mushroom.cpp
index 6b20e0d1..ca8a8554 100644
--- a/Minecraft.World/Mushroom.cpp
+++ b/Minecraft.World/Mushroom.cpp
@@ -77,7 +77,7 @@ bool Mushroom::growTree(Level *level, int x, int y, int z, Random *random)
int data = level->getData(x, y, z);
level->removeTile(x, y, z);
- Feature *f = NULL;
+ Feature *f = nullptr;
if (id == Tile::mushroom_brown_Id)
{
@@ -88,14 +88,14 @@ bool Mushroom::growTree(Level *level, int x, int y, int z, Random *random)
f = new HugeMushroomFeature(1);
}
- if (f == NULL || !f->place(level, random, x, y, z))
+ if (f == nullptr || !f->place(level, random, x, y, z))
{
level->setTileAndData(x, y, z, id, data, Tile::UPDATE_ALL);
- if( f != NULL )
+ if( f != nullptr )
delete f;
return false;
}
- if( f != NULL )
+ if( f != nullptr )
delete f;
return true;
} \ No newline at end of file
diff --git a/Minecraft.World/MushroomCow.cpp b/Minecraft.World/MushroomCow.cpp
index 0f88c843..2b274215 100644
--- a/Minecraft.World/MushroomCow.cpp
+++ b/Minecraft.World/MushroomCow.cpp
@@ -24,36 +24,36 @@ MushroomCow::MushroomCow(Level *level) : Cow(level)
bool MushroomCow::mobInteract(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> 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, shared_ptr<ItemInstance>( new ItemInstance(Item::mushroomStew) ) );
+ player->inventory->setItem(player->inventory->selected, std::make_shared<ItemInstance>(Item::mushroomStew));
return true;
}
- if (player->inventory->add(shared_ptr<ItemInstance>(new ItemInstance(Item::mushroomStew))) && !player->abilities.instabuild)
+ if (player->inventory->add(std::make_shared<ItemInstance>(Item::mushroomStew)) && !player->abilities.instabuild)
{
player->inventory->removeItem(player->inventory->selected, 1);
return true;
}
}
// 4J: Do not allow shearing if we can't create more cows
- if (item != NULL && item->id == Item::shears_Id && getAge() >= 0 && level->canCreateMore(eTYPE_COW, Level::eSpawnType_Breed))
+ if (item != nullptr && item->id == Item::shears_Id && getAge() >= 0 && level->canCreateMore(eTYPE_COW, Level::eSpawnType_Breed))
{
remove();
level->addParticle(eParticleType_largeexplode, x, y + bbHeight / 2, z, 0, 0, 0);
if(!level->isClientSide)
{
remove();
- shared_ptr<Cow> cow = shared_ptr<Cow>( new Cow(level) );
+ shared_ptr<Cow> cow = std::make_shared<Cow>(level);
cow->moveTo(x, y, z, yRot, xRot);
cow->setHealth(getHealth());
cow->yBodyRot = yBodyRot;
level->addEntity(cow);
for (int i = 0; i < 5; i++)
{
- level->addEntity( shared_ptr<ItemEntity>( new ItemEntity(level, x, y + bbHeight, z, shared_ptr<ItemInstance>( new ItemInstance(Tile::mushroom_red))) ));
+ level->addEntity(std::make_shared<ItemEntity>(level, x, y + bbHeight, z, shared_ptr<ItemInstance>(new ItemInstance(Tile::mushroom_red))));
}
return true;
}
@@ -76,7 +76,7 @@ shared_ptr<AgableMob> MushroomCow::getBreedOffspring(shared_ptr<AgableMob> targe
// 4J - added limit to number of animals that can be bred
if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) )
{
- return shared_ptr<MushroomCow>( new MushroomCow(level) );
+ return std::make_shared<MushroomCow>(level);
}
else
{
diff --git a/Minecraft.World/MushroomIslandBiome.cpp b/Minecraft.World/MushroomIslandBiome.cpp
index fa7eafdb..91bd8097 100644
--- a/Minecraft.World/MushroomIslandBiome.cpp
+++ b/Minecraft.World/MushroomIslandBiome.cpp
@@ -13,7 +13,7 @@ MushroomIslandBiome::MushroomIslandBiome(int id) : Biome(id)
decorator->mushroomCount = 1;
decorator->hugeMushrooms = 1;
- topMaterial = (byte) Tile::mycel_Id;
+ topMaterial = static_cast<byte>(Tile::mycel_Id);
enemies.clear();
friendlies.clear();
diff --git a/Minecraft.World/MusicTileEntity.cpp b/Minecraft.World/MusicTileEntity.cpp
index d947cc69..7f2f2888 100644
--- a/Minecraft.World/MusicTileEntity.cpp
+++ b/Minecraft.World/MusicTileEntity.cpp
@@ -33,7 +33,7 @@ void MusicTileEntity::load(CompoundTag *tag)
void MusicTileEntity::tune()
{
- note = (byte) ((note + 1) % 25);
+ note = static_cast<byte>((note + 1) % 25);
setChanged();
}
@@ -55,7 +55,7 @@ void MusicTileEntity::playNote(Level *level, int x, int y, int z)
// 4J Added
shared_ptr<TileEntity> MusicTileEntity::clone()
{
- shared_ptr<MusicTileEntity> result = shared_ptr<MusicTileEntity>( new MusicTileEntity() );
+ shared_ptr<MusicTileEntity> result = std::make_shared<MusicTileEntity>();
TileEntity::clone(result);
result->note = note;
diff --git a/Minecraft.World/MycelTile.cpp b/Minecraft.World/MycelTile.cpp
index 875a598d..76b742e3 100644
--- a/Minecraft.World/MycelTile.cpp
+++ b/Minecraft.World/MycelTile.cpp
@@ -6,8 +6,8 @@
MycelTile::MycelTile(int id) : Tile(id, Material::grass)
{
- iconTop = NULL;
- iconSnowSide = NULL;
+ iconTop = nullptr;
+ iconSnowSide = nullptr;
setTicking(true);
}
diff --git a/Minecraft.World/NameTagItem.cpp b/Minecraft.World/NameTagItem.cpp
index 9c11f2af..fc9b80b4 100644
--- a/Minecraft.World/NameTagItem.cpp
+++ b/Minecraft.World/NameTagItem.cpp
@@ -10,7 +10,7 @@ bool NameTagItem::interactEnemy(shared_ptr<ItemInstance> itemInstance, shared_pt
{
if (!itemInstance->hasCustomHoverName()) return false;
- if ( (target != NULL) && target->instanceof(eTYPE_MOB) )
+ if ( (target != nullptr) && target->instanceof(eTYPE_MOB) )
{
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(target);
mob->setCustomName(itemInstance->getHoverName());
diff --git a/Minecraft.World/NbtIo.cpp b/Minecraft.World/NbtIo.cpp
index b6c63277..7e566114 100644
--- a/Minecraft.World/NbtIo.cpp
+++ b/Minecraft.World/NbtIo.cpp
@@ -52,11 +52,11 @@ CompoundTag *NbtIo::read(DataInput *dis)
{
Tag *tag = Tag::readNamedTag(dis);
- if( tag->getId() == Tag::TAG_Compound ) return (CompoundTag *)tag;
+ if( tag->getId() == Tag::TAG_Compound ) return static_cast<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/NbtSlotFile.cpp b/Minecraft.World/NbtSlotFile.cpp
index bb820ce0..96a27993 100644
--- a/Minecraft.World/NbtSlotFile.cpp
+++ b/Minecraft.World/NbtSlotFile.cpp
@@ -14,12 +14,12 @@ NbtSlotFile::NbtSlotFile(File file)
if ( !file.exists() || file.length() )
{
- raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
writeHeader();
}
else
{
- raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
}
readHeader();
@@ -34,7 +34,7 @@ NbtSlotFile::NbtSlotFile(File file)
{
seekSlotHeader(fileSlot);
short slot;
- ReadFile(raf,&slot,2,&numberofBytesRead,NULL);
+ ReadFile(raf,&slot,2,&numberofBytesRead,nullptr);
if (slot == 0)
{
freeFileSlots.push_back(fileSlot);
@@ -52,12 +52,12 @@ void NbtSlotFile::readHeader()
DWORD numberOfBytesRead;
SetFilePointer(raf,0,0,FILE_BEGIN);
int magic;
- ReadFile(raf,&magic,4,&numberOfBytesRead,NULL);
+ ReadFile(raf,&magic,4,&numberOfBytesRead,nullptr);
// if (magic != MAGIC_NUMBER) throw new IOException("Bad magic number: " + magic); // 4J - TODO
short version;
- ReadFile(raf,&version,2,&numberOfBytesRead,NULL);
+ ReadFile(raf,&version,2,&numberOfBytesRead,nullptr);
// if (version != 0) throw new IOException("Bad version number: " + version); // 4J - TODO
- ReadFile(raf,&totalFileSlots,4,&numberOfBytesRead,NULL);
+ ReadFile(raf,&totalFileSlots,4,&numberOfBytesRead,nullptr);
}
void NbtSlotFile::writeHeader()
@@ -65,9 +65,9 @@ void NbtSlotFile::writeHeader()
DWORD numberOfBytesWritten;
short version = 0;
SetFilePointer(raf,0,0,FILE_BEGIN);
- WriteFile(raf,&MAGIC_NUMBER,4,&numberOfBytesWritten,NULL);
- WriteFile(raf,&version,2,&numberOfBytesWritten,NULL);
- WriteFile(raf,&totalFileSlots,4,&numberOfBytesWritten,NULL);
+ WriteFile(raf,&MAGIC_NUMBER,4,&numberOfBytesWritten,nullptr);
+ WriteFile(raf,&version,2,&numberOfBytesWritten,nullptr);
+ WriteFile(raf,&totalFileSlots,4,&numberOfBytesWritten,nullptr);
}
void NbtSlotFile::seekSlotHeader(int fileSlot)
@@ -98,12 +98,12 @@ vector<CompoundTag *> *NbtSlotFile::readAll(int slot)
{
seekSlotHeader(c);
short oldSlot;
- ReadFile(raf,&oldSlot,2,&numberOfBytesRead,NULL);
+ ReadFile(raf,&oldSlot,2,&numberOfBytesRead,nullptr);
short size;
- ReadFile(raf,&size,2,&numberOfBytesRead,NULL);
- ReadFile(raf,&continuesAt,4,&numberOfBytesRead,NULL);
+ ReadFile(raf,&size,2,&numberOfBytesRead,nullptr);
+ ReadFile(raf,&continuesAt,4,&numberOfBytesRead,nullptr);
int lastSlot;
- ReadFile(raf,&lastSlot,4,&numberOfBytesRead,NULL);
+ ReadFile(raf,&lastSlot,4,&numberOfBytesRead,nullptr);
seekSlot(c);
if (expectedSlot > 0 && oldSlot == -expectedSlot)
@@ -112,7 +112,7 @@ vector<CompoundTag *> *NbtSlotFile::readAll(int slot)
goto fileSlotLoop; // 4J - used to be continue fileSlotLoop, with for loop labelled as fileSlotLoop
}
- ReadFile(raf,READ_BUFFER.data + pos,size,&numberOfBytesRead,NULL);
+ ReadFile(raf,READ_BUFFER.data + pos,size,&numberOfBytesRead,nullptr);
if (continuesAt >= 0)
{
@@ -203,13 +203,13 @@ void NbtSlotFile::replaceSlot(int slot, vector<CompoundTag *> *tags)
}
seekSlotHeader(fileSlot);
- WriteFile(raf,&currentSlot,2,&numberOfBytesWritten,NULL);
- WriteFile(raf,&toWrite,2,&numberOfBytesWritten,NULL);
- WriteFile(raf,&nextFileSlot,4,&numberOfBytesWritten,NULL);
- WriteFile(raf,&lastFileSlot,4,&numberOfBytesWritten,NULL);
+ WriteFile(raf,&currentSlot,2,&numberOfBytesWritten,nullptr);
+ WriteFile(raf,&toWrite,2,&numberOfBytesWritten,nullptr);
+ WriteFile(raf,&nextFileSlot,4,&numberOfBytesWritten,nullptr);
+ WriteFile(raf,&lastFileSlot,4,&numberOfBytesWritten,nullptr);
seekSlot(fileSlot);
- WriteFile(raf,compressed.data+pos,toWrite,&numberOfBytesWritten,NULL);
+ WriteFile(raf,compressed.data+pos,toWrite,&numberOfBytesWritten,nullptr);
if (remaining > 0)
{
@@ -227,7 +227,7 @@ void NbtSlotFile::replaceSlot(int slot, vector<CompoundTag *> *tags)
seekSlotHeader(c);
short zero = 0;
- WriteFile(raf,&zero,2,&numberOfBytesWritten,NULL);
+ WriteFile(raf,&zero,2,&numberOfBytesWritten,nullptr);
}
toReplace->clear();
diff --git a/Minecraft.World/NearestAttackableTargetGoal.cpp b/Minecraft.World/NearestAttackableTargetGoal.cpp
index 7ddd8895..c6b75481 100644
--- a/Minecraft.World/NearestAttackableTargetGoal.cpp
+++ b/Minecraft.World/NearestAttackableTargetGoal.cpp
@@ -18,7 +18,7 @@ SubselectEntitySelector::~SubselectEntitySelector()
bool SubselectEntitySelector::matches(shared_ptr<Entity> entity) const
{
if (!entity->instanceof(eTYPE_LIVINGENTITY)) return false;
- if (m_subselector != NULL && !m_subselector->matches(entity)) return false;
+ if (m_subselector != nullptr && !m_subselector->matches(entity)) return false;
return m_parent->canAttack(dynamic_pointer_cast<LivingEntity>(entity), false);
}
@@ -37,7 +37,7 @@ bool NearestAttackableTargetGoal::DistComp::operator() (shared_ptr<Entity> e1, s
return false;
}
-NearestAttackableTargetGoal::NearestAttackableTargetGoal(PathfinderMob *mob, const type_info& targetType, int randomInterval, bool mustSee, bool mustReach /*= false*/, EntitySelector *entitySelector /* =NULL */)
+NearestAttackableTargetGoal::NearestAttackableTargetGoal(PathfinderMob *mob, const type_info& targetType, int randomInterval, bool mustSee, bool mustReach /*= false*/, EntitySelector *entitySelector /* =nullptr */)
: TargetGoal(mob, mustSee, mustReach), targetType(targetType)
{
this->randomInterval = randomInterval;
@@ -61,7 +61,7 @@ bool NearestAttackableTargetGoal::canUse()
vector<shared_ptr<Entity> > *entities = mob->level->getEntitiesOfClass(targetType, mob->bb->grow(within, 4, within), selector);
bool result = false;
- if(entities != NULL && !entities->empty() )
+ if(entities != nullptr && !entities->empty() )
{
std::sort(entities->begin(), entities->end(), *distComp);
target = weak_ptr<LivingEntity>(dynamic_pointer_cast<LivingEntity>(entities->at(0)));
diff --git a/Minecraft.World/NearestAttackableTargetGoal.h b/Minecraft.World/NearestAttackableTargetGoal.h
index 1ba6c519..2bdb81ec 100644
--- a/Minecraft.World/NearestAttackableTargetGoal.h
+++ b/Minecraft.World/NearestAttackableTargetGoal.h
@@ -41,7 +41,7 @@ private:
weak_ptr<LivingEntity> target;
public:
- NearestAttackableTargetGoal(PathfinderMob *mob, const type_info& targetType, int randomInterval, bool mustSee, bool mustReach = false, EntitySelector *entitySelector = NULL);
+ NearestAttackableTargetGoal(PathfinderMob *mob, const type_info& targetType, int randomInterval, bool mustSee, bool mustReach = false, EntitySelector *entitySelector = nullptr);
virtual ~NearestAttackableTargetGoal();
diff --git a/Minecraft.World/NetherBridgeFeature.cpp b/Minecraft.World/NetherBridgeFeature.cpp
index d661d3b7..e78002ec 100644
--- a/Minecraft.World/NetherBridgeFeature.cpp
+++ b/Minecraft.World/NetherBridgeFeature.cpp
@@ -15,13 +15,13 @@ NetherBridgeFeature::NetherBridgeFeature() : StructureFeature()
bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_SKELETON, 10, 4, 4));
bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_LAVASLIME, 3, 4, 4));
isSpotSelected=false;
- netherFortressPos = NULL;
+ netherFortressPos = nullptr;
}
NetherBridgeFeature::~NetherBridgeFeature()
{
- if( netherFortressPos != NULL ) delete netherFortressPos;
+ if( netherFortressPos != nullptr ) delete netherFortressPos;
}
wstring NetherBridgeFeature::getFeatureName()
@@ -57,7 +57,7 @@ bool NetherBridgeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat)
bool forcePlacement = false;
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
- if( levelGenOptions != NULL )
+ if( levelGenOptions != nullptr )
{
forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_NetherBridge);
}
@@ -118,7 +118,7 @@ NetherBridgeFeature::NetherBridgeStart::NetherBridgeStart(Level *level, Random *
vector<StructurePiece *> *pendingChildren = &start->pendingChildren;
while (!pendingChildren->empty())
{
- int pos = random->nextInt((int)pendingChildren->size());
+ int pos = random->nextInt(static_cast<int>(pendingChildren->size()));
auto it = pendingChildren->begin() + pos;
StructurePiece *structurePiece = *it;
pendingChildren->erase(it);
diff --git a/Minecraft.World/NetherBridgePieces.cpp b/Minecraft.World/NetherBridgePieces.cpp
index 35baa71a..d9fbbf35 100644
--- a/Minecraft.World/NetherBridgePieces.cpp
+++ b/Minecraft.World/NetherBridgePieces.cpp
@@ -79,7 +79,7 @@ NetherBridgePieces::PieceWeight *NetherBridgePieces::castlePieceWeights[NetherBr
NetherBridgePieces::NetherBridgePiece *NetherBridgePieces::findAndCreateBridgePieceFactory(NetherBridgePieces::PieceWeight *piece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth)
{
EPieceClass pieceClass = piece->pieceClass;
- NetherBridgePiece *structurePiece = NULL;
+ NetherBridgePiece *structurePiece = nullptr;
if (pieceClass == EPieceClass_BridgeStraight)
{
@@ -204,7 +204,7 @@ NetherBridgePieces::NetherBridgePiece *NetherBridgePieces::NetherBridgePiece::ge
}
NetherBridgePiece *structurePiece = findAndCreateBridgePieceFactory(piece, pieces, random, footX, footY, footZ, direction, depth);
- if (structurePiece != NULL)
+ if (structurePiece != nullptr)
{
piece->placeCount++;
startPiece->previousPiece = piece;
@@ -236,7 +236,7 @@ StructurePiece *NetherBridgePieces::NetherBridgePiece::generateAndAddPiece(Start
availablePieces = &startPiece->availableCastlePieces;
}
StructurePiece *newPiece = generatePiece(startPiece, availablePieces, pieces, random, footX, footY, footZ, direction, depth + 1);
- if (newPiece != NULL)
+ if (newPiece != nullptr)
{
pieces->push_back(newPiece);
startPiece->pendingChildren.push_back(newPiece);
@@ -257,7 +257,7 @@ StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildForward(Star
case Direction::EAST:
return generateAndAddPiece(startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0 + yOff, boundingBox->z0 + xOff, orientation, getGenDepth(), isCastle);
}
- return NULL;
+ return nullptr;
}
StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildLeft(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff, bool isCastle)
@@ -273,7 +273,7 @@ StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildLeft(StartPi
case Direction::EAST:
return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth(), isCastle);
}
- return NULL;
+ return nullptr;
}
StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildRight(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff, bool isCastle)
@@ -289,14 +289,14 @@ StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildRight(StartP
case Direction::EAST:
return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth(), isCastle);
}
- return NULL;
+ return nullptr;
}
bool NetherBridgePieces::NetherBridgePiece::isOkBox(BoundingBox *box, StartPiece *startPiece)
{
bool bIsOk = false;
- if(box != NULL)
+ if(box != nullptr)
{
if( box->y0 > LOWEST_Y_POSITION ) bIsOk = true;
int xzSize = (startPiece->m_level->getLevelData()->getXZSize() / startPiece->m_level->getLevelData()->getHellScale()); //HellRandomLevelSource::XZSIZE;
@@ -368,20 +368,20 @@ NetherBridgePieces::BridgeStraight::BridgeStraight(int genDepth, Random *random,
void NetherBridgePieces::BridgeStraight::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildForward((StartPiece *) startPiece, pieces, random, 1, 3, false);
+ generateChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 1, 3, false);
}
NetherBridgePieces::BridgeStraight *NetherBridgePieces::BridgeStraight::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new BridgeStraight(genDepth, random, box, direction);
@@ -441,13 +441,13 @@ NetherBridgePieces::BridgeEndFiller *NetherBridgePieces::BridgeEndFiller::create
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new BridgeEndFiller(genDepth, random, box, direction);
@@ -540,22 +540,22 @@ NetherBridgePieces::BridgeCrossing::BridgeCrossing(Random *random, int west, int
void NetherBridgePieces::BridgeCrossing::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildForward((StartPiece *) startPiece, pieces, random, 8, 3, false);
- generateChildLeft((StartPiece *) startPiece, pieces, random, 3, 8, false);
- generateChildRight((StartPiece *) startPiece, pieces, random, 3, 8, false);
+ generateChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 8, 3, false);
+ generateChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, 3, 8, false);
+ generateChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 3, 8, false);
}
NetherBridgePieces::BridgeCrossing *NetherBridgePieces::BridgeCrossing::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -8, -3, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new BridgeCrossing(genDepth, random, box, direction);
@@ -612,12 +612,12 @@ bool NetherBridgePieces::BridgeCrossing::postProcess(Level *level, Random *rando
NetherBridgePieces::StartPiece::StartPiece()
{
// for reflection
- previousPiece = NULL;
+ previousPiece = nullptr;
}
NetherBridgePieces::StartPiece::StartPiece(Random *random, int west, int north, Level *level) : BridgeCrossing(random, west, north)
{
- previousPiece = NULL;
+ previousPiece = nullptr;
m_level = level;
for( int i = 0; i < BRIDGE_PIECEWEIGHTS_COUNT; i++ )
@@ -659,22 +659,22 @@ NetherBridgePieces::RoomCrossing::RoomCrossing(int genDepth, Random *random, Bou
void NetherBridgePieces::RoomCrossing::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildForward((StartPiece *) startPiece, pieces, random, 2, 0, false);
- generateChildLeft((StartPiece *) startPiece, pieces, random, 0, 2, false);
- generateChildRight((StartPiece *) startPiece, pieces, random, 0, 2, false);
+ generateChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 2, 0, false);
+ generateChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, 0, 2, false);
+ generateChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 0, 2, false);
}
NetherBridgePieces::RoomCrossing *NetherBridgePieces::RoomCrossing::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new RoomCrossing(genDepth, random, box, direction);
@@ -731,20 +731,20 @@ NetherBridgePieces::StairsRoom::StairsRoom(int genDepth, Random *random, Boundin
void NetherBridgePieces::StairsRoom::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildRight((StartPiece *) startPiece, pieces, random, 6, 2, false);
+ generateChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 6, 2, false);
}
NetherBridgePieces::StairsRoom *NetherBridgePieces::StairsRoom::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new StairsRoom(genDepth, random, box, direction);
@@ -812,13 +812,13 @@ NetherBridgePieces::MonsterThrone *NetherBridgePieces::MonsterThrone::createPiec
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new MonsterThrone(genDepth, random, box, direction);
@@ -873,7 +873,7 @@ bool NetherBridgePieces::MonsterThrone::postProcess(Level *level, Random *random
hasPlacedMobSpawner = true;
level->setTileAndData(x, y, z, Tile::mobSpawner_Id, 0, Tile::UPDATE_CLIENTS);
shared_ptr<MobSpawnerTileEntity> entity = dynamic_pointer_cast<MobSpawnerTileEntity>( level->getTileEntity(x, y, z) );
- if (entity != NULL) entity->getSpawner()->setEntityId(L"Blaze");
+ if (entity != nullptr) entity->getSpawner()->setEntityId(L"Blaze");
}
}
@@ -901,20 +901,20 @@ NetherBridgePieces::CastleEntrance::CastleEntrance(int genDepth, Random *random,
void NetherBridgePieces::CastleEntrance::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildForward((StartPiece *) startPiece, pieces, random, 5, 3, true);
+ generateChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 5, 3, true);
}
NetherBridgePieces::CastleEntrance *NetherBridgePieces::CastleEntrance::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new CastleEntrance(genDepth, random, box, direction);
@@ -1030,21 +1030,21 @@ NetherBridgePieces::CastleStalkRoom::CastleStalkRoom(int genDepth, Random *rando
void NetherBridgePieces::CastleStalkRoom::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildForward((StartPiece *) startPiece, pieces, random, 5, 3, true);
- generateChildForward((StartPiece *) startPiece, pieces, random, 5, 11, true);
+ generateChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 5, 3, true);
+ generateChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 5, 11, true);
}
NetherBridgePieces::CastleStalkRoom *NetherBridgePieces::CastleStalkRoom::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new CastleStalkRoom(genDepth, random, box, direction);
@@ -1196,7 +1196,7 @@ NetherBridgePieces::CastleSmallCorridorPiece::CastleSmallCorridorPiece(int genDe
void NetherBridgePieces::CastleSmallCorridorPiece::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildForward((StartPiece *) startPiece, pieces, random, 1, 0, true);
+ generateChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 1, 0, true);
}
NetherBridgePieces::CastleSmallCorridorPiece *NetherBridgePieces::CastleSmallCorridorPiece::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
@@ -1204,13 +1204,13 @@ NetherBridgePieces::CastleSmallCorridorPiece *NetherBridgePieces::CastleSmallCor
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new CastleSmallCorridorPiece(genDepth, random, box, direction);
@@ -1259,22 +1259,22 @@ NetherBridgePieces::CastleSmallCorridorCrossingPiece::CastleSmallCorridorCrossin
void NetherBridgePieces::CastleSmallCorridorCrossingPiece::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildForward((StartPiece *) startPiece, pieces, random, 1, 0, true);
- generateChildLeft((StartPiece *) startPiece, pieces, random, 0, 1, true);
- generateChildRight((StartPiece *) startPiece, pieces, random, 0, 1, true);
+ generateChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 1, 0, true);
+ generateChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, 0, 1, true);
+ generateChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 0, 1, true);
}
NetherBridgePieces::CastleSmallCorridorCrossingPiece *NetherBridgePieces::CastleSmallCorridorCrossingPiece::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new CastleSmallCorridorCrossingPiece(genDepth, random, box, direction);
@@ -1337,20 +1337,20 @@ void NetherBridgePieces::CastleSmallCorridorRightTurnPiece::addAdditonalSaveData
void NetherBridgePieces::CastleSmallCorridorRightTurnPiece::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildRight((StartPiece *) startPiece, pieces, random, 0, 1, true);
+ generateChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 0, 1, true);
}
NetherBridgePieces::CastleSmallCorridorRightTurnPiece *NetherBridgePieces::CastleSmallCorridorRightTurnPiece::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new CastleSmallCorridorRightTurnPiece(genDepth, random, box, direction);
@@ -1429,20 +1429,20 @@ void NetherBridgePieces::CastleSmallCorridorLeftTurnPiece::addAdditonalSaveData(
void NetherBridgePieces::CastleSmallCorridorLeftTurnPiece::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildLeft((StartPiece *) startPiece, pieces, random, 0, 1, true);
+ generateChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, 0, 1, true);
}
NetherBridgePieces::CastleSmallCorridorLeftTurnPiece *NetherBridgePieces::CastleSmallCorridorLeftTurnPiece::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new CastleSmallCorridorLeftTurnPiece(genDepth, random, box, direction);
@@ -1505,20 +1505,20 @@ NetherBridgePieces::CastleCorridorStairsPiece::CastleCorridorStairsPiece(int gen
void NetherBridgePieces::CastleCorridorStairsPiece::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateChildForward((StartPiece *) startPiece, pieces, random, 1, 0, true);
+ generateChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 1, 0, true);
}
NetherBridgePieces::CastleCorridorStairsPiece *NetherBridgePieces::CastleCorridorStairsPiece::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -7, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new CastleCorridorStairsPiece(genDepth, random, box, direction);
@@ -1586,21 +1586,21 @@ void NetherBridgePieces::CastleCorridorTBalconyPiece::addChildren(StructurePiece
zOff = 5;
}
- generateChildLeft((StartPiece *) startPiece, pieces, random, 0, zOff, random->nextInt(8) > 0);
- generateChildRight((StartPiece *) startPiece, pieces, random, 0, zOff, random->nextInt(8) > 0);
+ generateChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, 0, zOff, random->nextInt(8) > 0);
+ generateChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 0, zOff, random->nextInt(8) > 0);
}
NetherBridgePieces::CastleCorridorTBalconyPiece *NetherBridgePieces::CastleCorridorTBalconyPiece::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -3, 0, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<NetherBridgePieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new CastleCorridorTBalconyPiece(genDepth, random, box, direction);
diff --git a/Minecraft.World/NetherWartTile.cpp b/Minecraft.World/NetherWartTile.cpp
index add3eccf..afe45aec 100644
--- a/Minecraft.World/NetherWartTile.cpp
+++ b/Minecraft.World/NetherWartTile.cpp
@@ -84,7 +84,7 @@ void NetherWartTile::spawnResources(Level *level, int x, int y, int z, int data,
}
for (int i = 0; i < count; i++)
{
- popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Item::netherwart_seeds)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(Item::netherwart_seeds));
}
}
diff --git a/Minecraft.World/Node.cpp b/Minecraft.World/Node.cpp
index 7059c045..408370a0 100644
--- a/Minecraft.World/Node.cpp
+++ b/Minecraft.World/Node.cpp
@@ -10,7 +10,7 @@ void Node::_init()
closed = false;
- cameFrom = NULL;
+ cameFrom = nullptr;
}
Node::Node(const int x, const int y, const int z) :
@@ -35,9 +35,9 @@ int Node::createHash(const int x, const int y, const int z)
float Node::distanceTo(Node *to)
{
- float xd = (float) ( to->x - x );
- float yd = (float) ( to->y - y );
- float zd = (float) ( to->z - z );
+ float xd = static_cast<float>(to->x - x);
+ float yd = static_cast<float>(to->y - y);
+ float zd = static_cast<float>(to->z - z);
return Mth::sqrt(xd * xd + yd * yd + zd * zd);
}
@@ -52,7 +52,7 @@ float Node::distanceToSqr(Node *to)
bool Node::equals(Node *o)
{
//4J Jev, never used anything other than a node.
- //if (dynamic_cast<Node *>((Node *) o) != NULL)
+ //if (dynamic_cast<Node *>((Node *) o) != nullptr)
//{
return hash == o->hash && x == o->x && y == o->y && z == o->z;
//}
diff --git a/Minecraft.World/NotGateTile.cpp b/Minecraft.World/NotGateTile.cpp
index 8d41c839..969778d8 100644
--- a/Minecraft.World/NotGateTile.cpp
+++ b/Minecraft.World/NotGateTile.cpp
@@ -233,7 +233,7 @@ void NotGateTile::levelTimeChanged(Level *level, int64_t delta, int64_t newTime)
{
deque<Toggle> *toggles = recentToggles[level];
- if (toggles != NULL)
+ if (toggles != nullptr)
{
for (auto& toggle : *toggles)
{
diff --git a/Minecraft.World/NoteBlockTile.cpp b/Minecraft.World/NoteBlockTile.cpp
index 25ea587a..cafa0c4d 100644
--- a/Minecraft.World/NoteBlockTile.cpp
+++ b/Minecraft.World/NoteBlockTile.cpp
@@ -14,7 +14,7 @@ void NoteBlockTile::neighborChanged(Level *level, int x, int y, int z, int type)
bool signal = level->hasNeighborSignal(x, y, z);
shared_ptr<MusicTileEntity> mte = dynamic_pointer_cast<MusicTileEntity>( level->getTileEntity(x, y, z) );
app.DebugPrintf("-------- Signal is %s, tile is currently %s\n",signal?"TRUE":"FALSE", mte->on?"ON":"OFF");
- if (mte != NULL && mte->on != signal)
+ if (mte != nullptr && mte->on != signal)
{
if (signal)
{
@@ -35,7 +35,7 @@ bool NoteBlockTile::use(Level *level, int x, int y, int z, shared_ptr<Player> pl
if (soundOnly) return false;
if (level->isClientSide) return true;
shared_ptr<MusicTileEntity> mte = dynamic_pointer_cast<MusicTileEntity>( level->getTileEntity(x, y, z) );
- if (mte != NULL )
+ if (mte != nullptr )
{
mte->tune();
mte->playNote(level, x, y, z);
@@ -47,17 +47,17 @@ void NoteBlockTile::attack(Level *level, int x, int y, int z, shared_ptr<Player>
{
if (level->isClientSide) return;
shared_ptr<MusicTileEntity> mte = dynamic_pointer_cast<MusicTileEntity>( level->getTileEntity(x, y, z) );
- if( mte != NULL ) mte->playNote(level, x, y, z);
+ if( mte != nullptr ) mte->playNote(level, x, y, z);
}
shared_ptr<TileEntity> NoteBlockTile::newTileEntity(Level *level)
{
- return shared_ptr<MusicTileEntity>( new MusicTileEntity() );
+ return std::make_shared<MusicTileEntity>();
}
bool NoteBlockTile::triggerEvent(Level *level, int x, int y, int z, int i, int note)
{
- float pitch = (float) pow(2, (note - 12) / 12.0);
+ float pitch = static_cast<float>(pow(2, (note - 12) / 12.0));
int iSound;
switch(i)
diff --git a/Minecraft.World/Ocelot.cpp b/Minecraft.World/Ocelot.cpp
index 50285682..75c6e0f0 100644
--- a/Minecraft.World/Ocelot.cpp
+++ b/Minecraft.World/Ocelot.cpp
@@ -57,7 +57,7 @@ void Ocelot::defineSynchedData()
{
TamableAnimal::defineSynchedData();
- entityData->define(DATA_TYPE_ID, (byte) 0);
+ entityData->define(DATA_TYPE_ID, static_cast<byte>(0));
}
void Ocelot::serverAiMobStep()
@@ -199,7 +199,7 @@ bool Ocelot::mobInteract(shared_ptr<Player> player)
}
else
{
- if (temptGoal->isRunning() && item != NULL && item->id == Item::fish_raw_Id && player->distanceToSqr(shared_from_this()) < 3 * 3)
+ if (temptGoal->isRunning() && item != nullptr && item->id == Item::fish_raw_Id && player->distanceToSqr(shared_from_this()) < 3 * 3)
{
// 4J-PB - don't lose the fish in creative mode
if (!player->abilities.instabuild) item->count--;
@@ -240,7 +240,7 @@ shared_ptr<AgableMob> Ocelot::getBreedOffspring(shared_ptr<AgableMob> target)
// 4J - added limit to number of animals that can be bred
if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) )
{
- shared_ptr<Ocelot> offspring = shared_ptr<Ocelot>( new Ocelot(level) );
+ shared_ptr<Ocelot> offspring = std::make_shared<Ocelot>(level);
if (isTame())
{
offspring->setOwnerUUID(getOwnerUUID());
@@ -257,7 +257,7 @@ shared_ptr<AgableMob> Ocelot::getBreedOffspring(shared_ptr<AgableMob> target)
bool Ocelot::isFood(shared_ptr<ItemInstance> itemInstance)
{
- return itemInstance != NULL && itemInstance->id == Item::fish_raw_Id;
+ return itemInstance != nullptr && itemInstance->id == Item::fish_raw_Id;
}
bool Ocelot::canMate(shared_ptr<Animal> animal)
@@ -266,7 +266,7 @@ bool Ocelot::canMate(shared_ptr<Animal> animal)
if (!isTame()) return false;
shared_ptr<Ocelot> partner = dynamic_pointer_cast<Ocelot>(animal);
- if (partner == NULL) return false;
+ if (partner == nullptr) return false;
if (!partner->isTame()) return false;
return isInLove() && partner->isInLove();
@@ -279,7 +279,7 @@ int Ocelot::getCatType()
void Ocelot::setCatType(int type)
{
- entityData->set(DATA_TYPE_ID, (byte) type);
+ entityData->set(DATA_TYPE_ID, static_cast<byte>(type));
}
bool Ocelot::canSpawn()
@@ -339,7 +339,7 @@ MobGroupData *Ocelot::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
{
for (int kitten = 0; kitten < 2; kitten++)
{
- shared_ptr<Ocelot> ocelot = shared_ptr<Ocelot>( new Ocelot(level) );
+ shared_ptr<Ocelot> ocelot = std::make_shared<Ocelot>(level);
ocelot->moveTo(x, y, z, yRot, 0);
ocelot->setAge(-20 * 60 * 20);
level->addEntity(ocelot);
@@ -351,7 +351,7 @@ MobGroupData *Ocelot::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
void Ocelot::setSittingOnTile(bool val)
{
byte current = entityData->getByte(DATA_FLAGS_ID);
- entityData->set(DATA_FLAGS_ID, val ? (byte) (current | 0x02) : (byte) (current & ~0x02) );
+ entityData->set(DATA_FLAGS_ID, val ? static_cast<byte>(current | 0x02) : static_cast<byte>(current & ~0x02) );
}
bool Ocelot::isSittingOnTile()
diff --git a/Minecraft.World/OcelotAttackGoal.cpp b/Minecraft.World/OcelotAttackGoal.cpp
index d9e0f29b..9871de2f 100644
--- a/Minecraft.World/OcelotAttackGoal.cpp
+++ b/Minecraft.World/OcelotAttackGoal.cpp
@@ -21,14 +21,14 @@ OcelotAttackGoal::OcelotAttackGoal(Mob *mob)
bool OcelotAttackGoal::canUse()
{
shared_ptr<LivingEntity> bestTarget = mob->getTarget();
- if (bestTarget == NULL) return false;
+ if (bestTarget == nullptr) return false;
target = weak_ptr<LivingEntity>(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/OcelotSitOnTileGoal.cpp b/Minecraft.World/OcelotSitOnTileGoal.cpp
index a35537fb..09b98650 100644
--- a/Minecraft.World/OcelotSitOnTileGoal.cpp
+++ b/Minecraft.World/OcelotSitOnTileGoal.cpp
@@ -41,7 +41,7 @@ bool OcelotSitOnTileGoal::canContinueToUse()
void OcelotSitOnTileGoal::start()
{
- ocelot->getNavigation()->moveTo((float) tileX + 0.5, tileY + 1, (float) tileZ + 0.5, speedModifier);
+ ocelot->getNavigation()->moveTo(static_cast<float>(tileX) + 0.5, tileY + 1, static_cast<float>(tileZ) + 0.5, speedModifier);
_tick = 0;
tryTicks = 0;
maxTicks = ocelot->getRandom()->nextInt(ocelot->getRandom()->nextInt(SIT_TICKS) + SIT_TICKS) + SIT_TICKS;
@@ -64,7 +64,7 @@ void OcelotSitOnTileGoal::tick()
if (ocelot->distanceToSqr(tileX, tileY + 1, tileZ) > 1)
{
ocelot->setSitting(false);
- ocelot->getNavigation()->moveTo((float) tileX + 0.5, tileY + 1, (float) tileZ + 0.5, speedModifier);
+ ocelot->getNavigation()->moveTo(static_cast<float>(tileX) + 0.5, tileY + 1, static_cast<float>(tileZ) + 0.5, speedModifier);
tryTicks++;
}
else if (!ocelot->isSitting())
@@ -79,12 +79,12 @@ void OcelotSitOnTileGoal::tick()
bool OcelotSitOnTileGoal::findNearestTile()
{
- int y = (int) ocelot->y;
+ int y = static_cast<int>(ocelot->y);
double distSqr = Integer::MAX_VALUE;
- for (int x = (int) ocelot->x - SEARCH_RANGE; x < ocelot->x + SEARCH_RANGE; x++)
+ for (int x = static_cast<int>(ocelot->x) - SEARCH_RANGE; x < ocelot->x + SEARCH_RANGE; x++)
{
- for (int z = (int) ocelot->z - SEARCH_RANGE; z < ocelot->z + SEARCH_RANGE; z++)
+ for (int z = static_cast<int>(ocelot->z) - SEARCH_RANGE; z < ocelot->z + SEARCH_RANGE; z++)
{
if (isValidTarget(ocelot->level, x, y, z) && ocelot->level->isEmptyTile(x, y + 1, z))
{
diff --git a/Minecraft.World/OfferFlowerGoal.cpp b/Minecraft.World/OfferFlowerGoal.cpp
index b604ea84..2951b5ff 100644
--- a/Minecraft.World/OfferFlowerGoal.cpp
+++ b/Minecraft.World/OfferFlowerGoal.cpp
@@ -17,12 +17,12 @@ bool OfferFlowerGoal::canUse()
if (!golem->level->isDay()) return false;
if (golem->getRandom()->nextInt(8000) != 0) return false;
villager = weak_ptr<Villager>(dynamic_pointer_cast<Villager>( golem->level->getClosestEntityOfClass(typeid(Villager), golem->bb->grow(6, 2, 6), golem->shared_from_this()) ));
- return villager.lock() != NULL;
+ return villager.lock() != nullptr;
}
bool OfferFlowerGoal::canContinueToUse()
{
- return _tick > 0 && villager.lock() != NULL;
+ return _tick > 0 && villager.lock() != nullptr;
}
void OfferFlowerGoal::start()
diff --git a/Minecraft.World/OldChunkStorage.cpp b/Minecraft.World/OldChunkStorage.cpp
index 983c517d..9a8822fa 100644
--- a/Minecraft.World/OldChunkStorage.cpp
+++ b/Minecraft.World/OldChunkStorage.cpp
@@ -9,7 +9,7 @@
#include "FileHeader.h"
#include "OldChunkStorage.h"
DWORD OldChunkStorage::tlsIdx = 0;
-OldChunkStorage::ThreadStorage *OldChunkStorage::tlsDefault = NULL;
+OldChunkStorage::ThreadStorage *OldChunkStorage::tlsDefault = nullptr;
OldChunkStorage::ThreadStorage::ThreadStorage()
{
@@ -30,7 +30,7 @@ OldChunkStorage::ThreadStorage::~ThreadStorage()
void OldChunkStorage::CreateNewThreadStorage()
{
ThreadStorage *tls = new ThreadStorage();
- if(tlsDefault == NULL )
+ if(tlsDefault == nullptr )
{
tlsIdx = TlsAlloc();
tlsDefault = tls;
@@ -45,7 +45,7 @@ void OldChunkStorage::UseDefaultThreadStorage()
void OldChunkStorage::ReleaseThreadStorage()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
if( tls == tlsDefault ) return;
delete tls;
@@ -126,14 +126,14 @@ LevelChunk *OldChunkStorage::load(Level *level, int x, int z)
char buf[256];
sprintf(buf,"Chunk file at %d, %d is missing level data, skipping\n",x,z);
app.DebugPrintf(buf);
- return NULL;
+ return nullptr;
}
if (!tag->getCompound(L"Level")->contains(L"Blocks"))
{
char buf[256];
sprintf(buf,"Chunk file at %d, %d is missing block data, skipping\n",x,z);
app.DebugPrintf(buf);
- return NULL;
+ return nullptr;
}
LevelChunk *levelChunk = OldChunkStorage::load(level, tag->getCompound(L"Level"));
if (!levelChunk->isAt(x, z))
@@ -152,7 +152,7 @@ LevelChunk *OldChunkStorage::load(Level *level, int x, int z)
// e.printStackTrace();
// }
}
- return NULL;
+ return nullptr;
}
void OldChunkStorage::save(Level *level, LevelChunk *levelChunk)
@@ -277,7 +277,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos)
PIXBeginNamedEvent(0,"Saving tile tick data");
vector<TickNextTickData > *ticksInChunk = level->fetchTicksInChunk(lc, false);
- if (ticksInChunk != NULL)
+ if (ticksInChunk != nullptr)
{
int64_t levelTime = level->getGameTime();
@@ -290,7 +290,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos)
teTag->putInt(L"x", td.x);
teTag->putInt(L"y", td.y);
teTag->putInt(L"z", td.z);
- teTag->putInt(L"t", (int) (td.m_delay - levelTime));
+ teTag->putInt(L"t", static_cast<int>(td.m_delay - levelTime));
tickTags->add(teTag);
}
@@ -318,7 +318,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag)
// Will be fine so long as we only actually create tags for once chunk at a time.
// 4J Stu - As we now save on multiple threads, the static data has been moved to TLS
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
PIXBeginNamedEvent(0,"Getting block data");
//static byteArray blockData = byteArray(32768);
@@ -365,7 +365,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag)
PIXBeginNamedEvent(0,"Saving tile tick data");
vector<TickNextTickData > *ticksInChunk = level->fetchTicksInChunk(lc, false);
- if (ticksInChunk != NULL)
+ if (ticksInChunk != nullptr)
{
int64_t levelTime = level->getGameTime();
@@ -378,7 +378,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag)
teTag->putInt(L"x", td.x);
teTag->putInt(L"y", td.y);
teTag->putInt(L"z", td.z);
- teTag->putInt(L"t", (int) (td.m_delay - levelTime));
+ teTag->putInt(L"t", static_cast<int>(td.m_delay - levelTime));
teTag->putInt(L"p", td.priorityTilt);
tickTags->add(teTag);
@@ -393,14 +393,14 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag)
void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *tag)
{
ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) tag->getList(L"Entities");
- if (entityTags != NULL)
+ if (entityTags != nullptr)
{
for (int i = 0; i < entityTags->size(); i++)
{
CompoundTag *teTag = entityTags->get(i);
shared_ptr<Entity> te = EntityIO::loadStatic(teTag, level);
lc->lastSaveHadEntities = true;
- if (te != NULL)
+ if (te != nullptr)
{
lc->addEntity(te);
}
@@ -408,13 +408,13 @@ void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *ta
}
ListTag<CompoundTag> *tileEntityTags = (ListTag<CompoundTag> *) tag->getList(L"TileEntities");
- if (tileEntityTags != NULL)
+ if (tileEntityTags != nullptr)
{
for (int i = 0; i < tileEntityTags->size(); i++)
{
CompoundTag *teTag = tileEntityTags->get(i);
shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
- if (te != NULL)
+ if (te != nullptr)
{
lc->addTileEntity(te);
}
@@ -476,7 +476,7 @@ LevelChunk *OldChunkStorage::load(Level *level, DataInputStream *dis)
PIXBeginNamedEvent(0,"Loading TileTicks");
ListTag<CompoundTag> *tileTicks = (ListTag<CompoundTag> *) tag->getList(L"TileTicks");
- if (tileTicks != NULL)
+ if (tileTicks != nullptr)
{
for (int i = 0; i < tileTicks->size(); i++)
{
@@ -556,7 +556,7 @@ LevelChunk *OldChunkStorage::load(Level *level, CompoundTag *tag)
// 4J removed - we shouldn't need this any more
#if 0
- if (levelChunk->heightmap.data == NULL || !levelChunk->skyLight->isValid())
+ if (levelChunk->heightmap.data == nullptr || !levelChunk->skyLight->isValid())
{
static int chunksUpdated = 0;
delete [] levelChunk->heightmap.data;
@@ -594,7 +594,7 @@ LevelChunk *OldChunkStorage::load(Level *level, CompoundTag *tag)
{
ListTag<CompoundTag> *tileTicks = (ListTag<CompoundTag> *) tag->getList(L"TileTicks");
- if (tileTicks != NULL)
+ if (tileTicks != nullptr)
{
for (int i = 0; i < tileTicks->size(); i++)
{
diff --git a/Minecraft.World/OreFeature.cpp b/Minecraft.World/OreFeature.cpp
index c057511b..cea881aa 100644
--- a/Minecraft.World/OreFeature.cpp
+++ b/Minecraft.World/OreFeature.cpp
@@ -35,8 +35,8 @@ bool OreFeature::place(Level *level, Random *random, int x, int y, int z)
bool collisionsExpected = false;
- LevelGenerationOptions *levelGenOptions = NULL;
- if( app.getLevelGenerationOptions() != NULL )
+ LevelGenerationOptions *levelGenOptions = nullptr;
+ if( app.getLevelGenerationOptions() != nullptr )
{
levelGenOptions = app.getLevelGenerationOptions();
@@ -83,7 +83,7 @@ bool OreFeature::place(Level *level, Random *random, int x, int y, int z)
int zt1 = Mth::floor(zz + halfR);
// 4J Stu Added to stop ore features generating areas previously place by game rule generation
- if(collisionsExpected && levelGenOptions != NULL)
+ if(collisionsExpected && levelGenOptions != nullptr)
{
bool intersects = levelGenOptions->checkIntersects(xt0, yt0, zt0, xt1, yt1, zt1);
if(intersects)
diff --git a/Minecraft.World/OwnerHurtByTargetGoal.cpp b/Minecraft.World/OwnerHurtByTargetGoal.cpp
index 8250dc18..787eb2ae 100644
--- a/Minecraft.World/OwnerHurtByTargetGoal.cpp
+++ b/Minecraft.World/OwnerHurtByTargetGoal.cpp
@@ -14,7 +14,7 @@ bool OwnerHurtByTargetGoal::canUse()
{
if (!tameAnimal->isTame()) return false;
shared_ptr<LivingEntity> owner = dynamic_pointer_cast<LivingEntity>( tameAnimal->getOwner() );
- if (owner == NULL) return false;
+ if (owner == nullptr) return false;
ownerLastHurtBy = weak_ptr<LivingEntity>(owner->getLastHurtByMob());
int ts = owner->getLastHurtByMobTimestamp();
@@ -27,7 +27,7 @@ void OwnerHurtByTargetGoal::start()
mob->setTarget(ownerLastHurtBy.lock());
shared_ptr<LivingEntity> owner = dynamic_pointer_cast<LivingEntity>( tameAnimal->getOwner() );
- if (owner != NULL)
+ if (owner != nullptr)
{
timestamp = owner->getLastHurtByMobTimestamp();
}
diff --git a/Minecraft.World/OwnerHurtTargetGoal.cpp b/Minecraft.World/OwnerHurtTargetGoal.cpp
index b7e74505..a63e1784 100644
--- a/Minecraft.World/OwnerHurtTargetGoal.cpp
+++ b/Minecraft.World/OwnerHurtTargetGoal.cpp
@@ -14,7 +14,7 @@ bool OwnerHurtTargetGoal::canUse()
{
if (!tameAnimal->isTame()) return false;
shared_ptr<LivingEntity> owner = dynamic_pointer_cast<LivingEntity>( tameAnimal->getOwner() );
- if (owner == NULL) return false;
+ if (owner == nullptr) return false;
ownerLastHurt = weak_ptr<LivingEntity>(owner->getLastHurtMob());
int ts = owner->getLastHurtMobTimestamp();
shared_ptr<LivingEntity> locked = ownerLastHurt.lock();
@@ -26,7 +26,7 @@ void OwnerHurtTargetGoal::start()
mob->setTarget(ownerLastHurt.lock());
shared_ptr<LivingEntity> owner = dynamic_pointer_cast<LivingEntity>( tameAnimal->getOwner() );
- if (owner != NULL)
+ if (owner != nullptr)
{
timestamp = owner->getLastHurtMobTimestamp();
diff --git a/Minecraft.World/Packet.cpp b/Minecraft.World/Packet.cpp
index bc2152b2..129024b7 100644
--- a/Minecraft.World/Packet.cpp
+++ b/Minecraft.World/Packet.cpp
@@ -357,7 +357,7 @@ shared_ptr<Packet> Packet::readPacket(DataInputStream *dis, bool isServer) // th
}
packet = getPacket(id);
- if (packet == NULL) assert(false);//throw new IOException(wstring(L"Bad packet id ") + std::to_wstring(id));
+ if (packet == nullptr) assert(false);//throw new IOException(wstring(L"Bad packet id ") + std::to_wstring(id));
s_lastIds[s_lastIdPos] = id;
s_lastIdPos = (s_lastIdPos + 1) % 8;
@@ -369,7 +369,7 @@ shared_ptr<Packet> Packet::readPacket(DataInputStream *dis, bool isServer) // th
// {
// // reached end of stream
// OutputDebugString("Reached end of stream");
- // return NULL;
+ // return nullptr;
// }
// 4J - Don't bother tracking stats in a content package
@@ -410,7 +410,7 @@ void Packet::writeUtf(const wstring& value, DataOutputStream *dos) // throws IOE
}
#endif
- dos->writeShort((short)value.length());
+ dos->writeShort(static_cast<short>(value.length()));
dos->writeChars(value);
}
@@ -467,7 +467,7 @@ double Packet::PacketStatistics::getAverageSize()
{
return 0;
}
- return (double) totalSize / count;
+ return static_cast<double>(totalSize) / count;
}
int Packet::PacketStatistics::getTotalSize()
@@ -536,7 +536,7 @@ shared_ptr<ItemInstance> Packet::readItem(DataInputStream *dis)
int count = dis->readByte();
int damage = dis->readShort();
- item = shared_ptr<ItemInstance>( new ItemInstance(id, count, damage) );
+ item = std::make_shared<ItemInstance>(id, count, damage);
// 4J Stu - Always read/write the tag
//if (Item.items[id].canBeDepleted() || Item.items[id].shouldOverrideMultiplayerNBT())
{
@@ -549,7 +549,7 @@ shared_ptr<ItemInstance> Packet::readItem(DataInputStream *dis)
void Packet::writeItem(shared_ptr<ItemInstance> item, DataOutputStream *dos)
{
- if (item == NULL)
+ if (item == nullptr)
{
dos->writeShort(-1);
}
@@ -569,7 +569,7 @@ void Packet::writeItem(shared_ptr<ItemInstance> item, DataOutputStream *dos)
CompoundTag *Packet::readNbt(DataInputStream *dis)
{
int size = dis->readShort();
- if (size < 0) return NULL;
+ if (size < 0) return nullptr;
byteArray buff(size);
dis->readFully(buff);
CompoundTag *result = (CompoundTag *) NbtIo::decompress(buff);
@@ -579,14 +579,14 @@ 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);
- dos->writeShort((short) buff.length);
+ dos->writeShort(static_cast<short>(buff.length));
dos->write(buff);
delete [] buff.data;
}
diff --git a/Minecraft.World/Painting.cpp b/Minecraft.World/Painting.cpp
index 208beb77..5e56b9ca 100644
--- a/Minecraft.World/Painting.cpp
+++ b/Minecraft.World/Painting.cpp
@@ -54,7 +54,7 @@ const int Painting::Motive::MAX_MOTIVE_NAME_LENGTH = 13; //JAVA: "SkullAndRoses
// 4J - added for common ctor code
void Painting::_init( Level *level )
{
- motive = NULL;
+ motive = nullptr;
};
Painting::Painting(Level *level) : HangingEntity( level )
@@ -98,7 +98,7 @@ void Painting::PaintingPostConstructor(int dir, int motive)
}
if (!survivableMotives->empty())
{
- this->motive = survivableMotives->at(random->nextInt((int)survivableMotives->size()));
+ this->motive = survivableMotives->at(random->nextInt(static_cast<int>(survivableMotives->size())));
}
setDir(dir);
}
@@ -138,7 +138,7 @@ void Painting::readAdditionalSaveData(CompoundTag *tag)
this->motive = (Motive *)Motive::values[i];
}
}
- if (this->motive == NULL) motive = (Motive *)Motive::values[ Kebab ];
+ if (this->motive == nullptr) motive = (Motive *)Motive::values[ Kebab ];
HangingEntity::readAdditionalSaveData(tag);
}
@@ -155,7 +155,7 @@ int Painting::getHeight()
void Painting::dropItem(shared_ptr<Entity> causedBy)
{
- if ( (causedBy != NULL) && causedBy->instanceof(eTYPE_PLAYER) )
+ if ( (causedBy != nullptr) && causedBy->instanceof(eTYPE_PLAYER) )
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(causedBy);
if (player->abilities.instabuild)
@@ -164,5 +164,5 @@ void Painting::dropItem(shared_ptr<Entity> causedBy)
}
}
- spawnAtLocation(shared_ptr<ItemInstance>(new ItemInstance(Item::painting)), 0.0f);
+ spawnAtLocation(std::make_shared<ItemInstance>(Item::painting), 0.0f);
} \ No newline at end of file
diff --git a/Minecraft.World/Path.cpp b/Minecraft.World/Path.cpp
index 538917f6..afea4a17 100644
--- a/Minecraft.World/Path.cpp
+++ b/Minecraft.World/Path.cpp
@@ -46,7 +46,7 @@ Node *Path::last()
{
return nodes[length - 1];
}
- return NULL;
+ return nullptr;
}
Node *Path::get(int i)
@@ -76,9 +76,9 @@ void Path::setIndex(int index)
Vec3 *Path::getPos(shared_ptr<Entity> e, int index)
{
- double x = nodes[index]->x + (int) (e->bbWidth + 1) * 0.5;
+ double x = nodes[index]->x + static_cast<int>(e->bbWidth + 1) * 0.5;
double y = nodes[index]->y;
- double z = nodes[index]->z + (int) (e->bbWidth + 1) * 0.5;
+ double z = nodes[index]->z + static_cast<int>(e->bbWidth + 1) * 0.5;
return Vec3::newTemp(x, y, z);
}
@@ -94,7 +94,7 @@ Vec3 *Path::currentPos()
bool Path::sameAs(Path *path)
{
- if (path == NULL) return false;
+ if (path == nullptr) return false;
if (path->nodes.length != nodes.length) return false;
for (int i = 0; i < nodes.length; ++i)
if (nodes[i]->x != path->nodes[i]->x || nodes[i]->y != path->nodes[i]->y || nodes[i]->z != path->nodes[i]->z) return false;
@@ -104,13 +104,13 @@ bool Path::sameAs(Path *path)
bool Path::endsIn(Vec3 *pos)
{
Node *lastNode = last();
- if (lastNode == NULL) return false;
- return lastNode->x == (int) pos->x && lastNode->y == (int) pos->y && lastNode->z == (int) pos->z;
+ if (lastNode == nullptr) return false;
+ return lastNode->x == static_cast<int>(pos->x) && lastNode->y == static_cast<int>(pos->y) && lastNode->z == static_cast<int>(pos->z);
}
bool Path::endsInXZ(Vec3 *pos)
{
Node *lastNode = last();
- if (lastNode == NULL) return false;
- return lastNode->x == (int) pos->x && lastNode->z == (int) pos->z;
+ if (lastNode == nullptr) return false;
+ return lastNode->x == static_cast<int>(pos->x) && lastNode->z == static_cast<int>(pos->z);
} \ No newline at end of file
diff --git a/Minecraft.World/PathFinder.cpp b/Minecraft.World/PathFinder.cpp
index 2e11648f..eb3bd45e 100644
--- a/Minecraft.World/PathFinder.cpp
+++ b/Minecraft.World/PathFinder.cpp
@@ -51,7 +51,7 @@ Path *PathFinder::findPath(Entity *e, double xt, double yt, double zt, float max
int startY = Mth::floor(e->bb->y0 + 0.5f);
if (canFloat && e->isInWater())
{
- startY = (int) (e->bb->y0);
+ startY = static_cast<int>(e->bb->y0);
int tileId = level->getTile((int) Mth::floor(e->x), startY, (int) Mth::floor(e->z));
while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id)
{
@@ -62,10 +62,10 @@ Path *PathFinder::findPath(Entity *e, double xt, double yt, double zt, float max
avoidWater = false;
} else startY = Mth::floor(e->bb->y0 + 0.5f);
- Node *from = getNode((int) floor(e->bb->x0), startY, (int) floor(e->bb->z0));
- Node *to = getNode((int) floor(xt - e->bbWidth / 2), (int) floor(yt), (int) floor(zt - e->bbWidth / 2));
+ Node *from = getNode(static_cast<int>(floor(e->bb->x0)), startY, static_cast<int>(floor(e->bb->z0)));
+ Node *to = getNode(static_cast<int>(floor(xt - e->bbWidth / 2)), static_cast<int>(floor(yt)), static_cast<int>(floor(zt - e->bbWidth / 2)));
- Node *size = new Node((int) floor(e->bbWidth + 1), (int) floor(e->bbHeight + 1), (int) floor(e->bbWidth + 1));
+ Node *size = new Node(static_cast<int>(floor(e->bbWidth + 1)), static_cast<int>(floor(e->bbHeight + 1)), static_cast<int>(floor(e->bbWidth + 1)));
Path *path = findPath(e, from, to, size, maxDist);
delete size;
@@ -124,7 +124,7 @@ Path *PathFinder::findPath(Entity *e, Node *from, Node *to, Node *size, float ma
}
}
- if (closest == from) return NULL;
+ if (closest == from) return nullptr;
return reconstruct_path(from, closest);
}
@@ -140,44 +140,44 @@ int PathFinder::getNeighbors(Entity *entity, Node *pos, Node *size, Node *target
Node *e = getNode(entity, pos->x + 1, pos->y, pos->z, size, jumpSize);
Node *s = getNode(entity, pos->x, pos->y, pos->z - 1, size, jumpSize);
- if (n != NULL && !n->closed && n->distanceTo(target) < maxDist) neighbors->data[p++] = n;
- if (w != NULL && !w->closed && w->distanceTo(target) < maxDist) neighbors->data[p++] = w;
- if (e != NULL && !e->closed && e->distanceTo(target) < maxDist) neighbors->data[p++] = e;
- if (s != NULL && !s->closed && s->distanceTo(target) < maxDist) neighbors->data[p++] = s;
+ if (n != nullptr && !n->closed && n->distanceTo(target) < maxDist) neighbors->data[p++] = n;
+ if (w != nullptr && !w->closed && w->distanceTo(target) < maxDist) neighbors->data[p++] = w;
+ if (e != nullptr && !e->closed && e->distanceTo(target) < maxDist) neighbors->data[p++] = e;
+ if (s != nullptr && !s->closed && s->distanceTo(target) < maxDist) neighbors->data[p++] = s;
return p;
}
Node *PathFinder::getNode(Entity *entity, int x, int y, int z, Node *size, int jumpSize)
{
- Node *best = NULL;
+ Node *best = nullptr;
int pathType = isFree(entity, x, y, z, size);
if (pathType == TYPE_WALKABLE) return getNode(x, y, z);
if (pathType == TYPE_OPEN) best = getNode(x, y, z);
- if (best == NULL && jumpSize > 0 && pathType != TYPE_FENCE && pathType != TYPE_TRAP && isFree(entity, x, y + jumpSize, z, size) == TYPE_OPEN)
+ if (best == nullptr && jumpSize > 0 && pathType != TYPE_FENCE && pathType != TYPE_TRAP && isFree(entity, x, y + jumpSize, z, size) == TYPE_OPEN)
{
best = getNode(x, y + jumpSize, z);
y += jumpSize;
}
- if (best != NULL)
+ if (best != nullptr)
{
int drop = 0;
int cost = 0;
while (y > 0)
{
cost = isFree(entity, x, y - 1, z, size);
- if (avoidWater && cost == TYPE_WATER) return NULL;
+ if (avoidWater && cost == TYPE_WATER) return nullptr;
if (cost != TYPE_OPEN) break;
// fell too far?
- if (++drop >= 4) return NULL; // 4J - rolling this back to pre-java 1.6.4 version as we're suspicious of the performance implications of this
-// if (drop++ >= entity->getMaxFallDistance()) return NULL;
+ if (++drop >= 4) return nullptr; // 4J - rolling this back to pre-java 1.6.4 version as we're suspicious of the performance implications of this
+// if (drop++ >= entity->getMaxFallDistance()) return nullptr;
y--;
if (y > 0) best = getNode(x, y, z);
}
// fell into lava?
- if (cost == TYPE_LAVA) return NULL;
+ if (cost == TYPE_LAVA) return nullptr;
}
return best;
@@ -269,7 +269,7 @@ Path *PathFinder::reconstruct_path(Node *from, Node *to)
{
int count = 1;
Node *n = to;
- while (n->cameFrom != NULL)
+ while (n->cameFrom != nullptr)
{
count++;
n = n->cameFrom;
@@ -278,7 +278,7 @@ Path *PathFinder::reconstruct_path(Node *from, Node *to)
NodeArray nodes = NodeArray(count);
n = to;
nodes.data[--count] = n;
- while (n->cameFrom != NULL)
+ while (n->cameFrom != nullptr)
{
n = n->cameFrom;
nodes.data[--count] = n;
diff --git a/Minecraft.World/PathNavigation.cpp b/Minecraft.World/PathNavigation.cpp
index 7cac052e..51d08d1e 100644
--- a/Minecraft.World/PathNavigation.cpp
+++ b/Minecraft.World/PathNavigation.cpp
@@ -16,7 +16,7 @@ PathNavigation::PathNavigation(Mob *mob, Level *level)
this->level = level;
dist = mob->getAttribute(SharedMonsterAttributes::FOLLOW_RANGE);
- path = NULL;
+ path = nullptr;
speedModifier = 0.0;
avoidSun = false;
_tick = 0;
@@ -30,7 +30,7 @@ PathNavigation::PathNavigation(Mob *mob, Level *level)
PathNavigation::~PathNavigation()
{
- if(path != NULL) delete path;
+ if(path != nullptr) delete path;
delete lastStuckCheckPos;
}
@@ -81,19 +81,19 @@ void PathNavigation::setCanFloat(bool canFloat)
float PathNavigation::getMaxDist()
{
- return (float) dist->getValue();
+ return static_cast<float>(dist->getValue());
}
Path *PathNavigation::createPath(double x, double y, double z)
{
- if (!canUpdatePath()) return NULL;
- return level->findPath(mob->shared_from_this(), Mth::floor(x), (int) y, Mth::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat);
+ if (!canUpdatePath()) return nullptr;
+ return level->findPath(mob->shared_from_this(), Mth::floor(x), static_cast<int>(y), Mth::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat);
}
bool PathNavigation::moveTo(double x, double y, double z, double speedModifier)
{
MemSect(52);
- Path *newPath = createPath(Mth::floor(x), (int) y, Mth::floor(z));
+ Path *newPath = createPath(Mth::floor(x), static_cast<int>(y), Mth::floor(z));
MemSect(0);
// No need to delete newPath here as this will be copied into the member variable path and the class can assume responsibility for it
return moveTo(newPath, speedModifier);
@@ -101,7 +101,7 @@ bool PathNavigation::moveTo(double x, double y, double z, double speedModifier)
Path *PathNavigation::createPath(shared_ptr<Entity> target)
{
- if (!canUpdatePath()) return NULL;
+ if (!canUpdatePath()) return nullptr;
return level->findPath(mob->shared_from_this(), target, getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat);
}
@@ -111,21 +111,21 @@ bool PathNavigation::moveTo(shared_ptr<Entity> target, double speedModifier)
Path *newPath = createPath(target);
MemSect(0);
// No need to delete newPath here as this will be copied into the member variable path and the class can assume responsibility for it
- if (newPath != NULL) return moveTo(newPath, speedModifier);
+ if (newPath != nullptr) return moveTo(newPath, speedModifier);
else return false;
}
bool PathNavigation::moveTo(Path *newPath, double speedModifier)
{
- if(newPath == NULL)
+ if(newPath == nullptr)
{
- if(path != NULL) delete path;
- path = NULL;
+ if(path != nullptr) delete path;
+ path = nullptr;
return false;
}
if(!newPath->sameAs(path))
{
- if(path != NULL) delete path;
+ if(path != nullptr) delete path;
path = newPath;
}
else
@@ -158,7 +158,7 @@ void PathNavigation::tick()
if (isDone()) return;
Vec3 *target = path->currentPos(mob->shared_from_this());
- if (target == NULL) return;
+ if (target == nullptr) return;
mob->getMoveControl()->setWantedPosition(target->x, target->y, target->z, speedModifier);
}
@@ -169,9 +169,9 @@ 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)
+ if (static_cast<int>(path->get(i)->y) != static_cast<int>(mobPos->y))
{
firstElevation = i;
break;
@@ -191,8 +191,8 @@ void PathNavigation::updatePath()
}
// smooth remaining on same elevation
- int sx = (int) ceil(mob->bbWidth);
- int sy = (int) mob->bbHeight + 1;
+ int sx = static_cast<int>(ceil(mob->bbWidth));
+ int sy = static_cast<int>(mob->bbHeight) + 1;
int sz = sx;
for (int i = firstElevation - 1; i >= path->getIndex(); --i)
{
@@ -216,13 +216,13 @@ void PathNavigation::updatePath()
bool PathNavigation::isDone()
{
- return path == NULL || path->isDone();
+ return path == nullptr || path->isDone();
}
void PathNavigation::stop()
{
- if(path != NULL) delete path;
- path = NULL;
+ if(path != nullptr) delete path;
+ path = nullptr;
}
Vec3 *PathNavigation::getTempMobPos()
@@ -232,16 +232,16 @@ Vec3 *PathNavigation::getTempMobPos()
int PathNavigation::getSurfaceY()
{
- if (!mob->isInWater() || !canFloat) return (int) (mob->bb->y0 + 0.5);
+ if (!mob->isInWater() || !canFloat) return static_cast<int>(mob->bb->y0 + 0.5);
- int surface = (int) (mob->bb->y0);
+ int surface = static_cast<int>(mob->bb->y0);
int tileId = level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z));
int steps = 0;
while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id)
{
++surface;
tileId = level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z));
- if (++steps > 16) return (int) (mob->bb->y0);
+ if (++steps > 16) return static_cast<int>(mob->bb->y0);
}
return surface;
}
@@ -258,7 +258,7 @@ bool PathNavigation::isInLiquid()
void PathNavigation::trimPathFromSun()
{
- if (level->canSeeSky(Mth::floor(mob->x), (int) (mob->bb->y0 + 0.5), Mth::floor(mob->z))) return;
+ if (level->canSeeSky(Mth::floor(mob->x), static_cast<int>(mob->bb->y0 + 0.5), Mth::floor(mob->z))) return;
for (int i = 0; i < path->getSize(); ++i)
{
@@ -288,7 +288,7 @@ bool PathNavigation::canMoveDirectly(Vec3 *startPos, Vec3 *stopPos, int sx, int
sx += 2;
sz += 2;
- if (!canWalkOn(gridPosX, (int) startPos->y, gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false;
+ if (!canWalkOn(gridPosX, static_cast<int>(startPos->y), gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false;
sx -= 2;
sz -= 2;
@@ -323,7 +323,7 @@ bool PathNavigation::canMoveDirectly(Vec3 *startPos, Vec3 *stopPos, int sx, int
currentDirZ = gridGoalZ - gridPosZ;
}
- if (!canWalkOn(gridPosX, (int) startPos->y, gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false;
+ if (!canWalkOn(gridPosX, static_cast<int>(startPos->y), gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false;
}
return true;
}
diff --git a/Minecraft.World/PathfinderMob.cpp b/Minecraft.World/PathfinderMob.cpp
index c01790e7..840a6020 100644
--- a/Minecraft.World/PathfinderMob.cpp
+++ b/Minecraft.World/PathfinderMob.cpp
@@ -15,7 +15,7 @@ AttributeModifier *PathfinderMob::SPEED_MODIFIER_FLEEING = (new AttributeModifie
PathfinderMob::PathfinderMob(Level *level) : Mob( level )
{
- path = NULL;
+ path = nullptr;
attackTarget = nullptr;
holdGround = false;
fleeTime = 0;
@@ -51,10 +51,10 @@ void PathfinderMob::serverAiStep()
holdGround = shouldHoldGround();
float maxDist = 16;
- if (attackTarget == NULL)
+ if (attackTarget == nullptr)
{
attackTarget = findAttackTarget();
- if (attackTarget != NULL)
+ if (attackTarget != nullptr)
{
setPath(level->findPath(shared_from_this(), attackTarget, maxDist, true, false, false, true)); // 4J - changed to setPath from path =
}
@@ -84,18 +84,18 @@ void PathfinderMob::serverAiStep()
// they aren't enclosed. We don't want the extra network overhead of just having Everything wandering round all the time, so have put a management system in place
// that selects a subset of entities which have had their flag set through the considerForExtraWandering method so that these can keep doing random strolling.
- if (!holdGround && (attackTarget != NULL && (path == NULL || random->nextInt(20) == 0)))
+ if (!holdGround && (attackTarget != nullptr && (path == nullptr || random->nextInt(20) == 0)))
{
setPath(level->findPath(shared_from_this(), attackTarget, maxDist, true, false, false, true));// 4J - changed to setPath from path =
}
- else if (!holdGround && ((path == NULL && (random->nextInt(180) == 0) || fleeTime > 0) || (random->nextInt(120) == 0 || fleeTime > 0)))
+ else if (!holdGround && ((path == nullptr && (random->nextInt(180) == 0) || fleeTime > 0) || (random->nextInt(120) == 0 || fleeTime > 0)))
{
if(noActionTime < SharedConstants::TICKS_PER_SECOND * 5)
{
findRandomStrollLocation();
}
}
- else if (!holdGround && (path == NULL ) )
+ else if (!holdGround && (path == nullptr ) )
{
if( ( noActionTime >= SharedConstants::TICKS_PER_SECOND * 5 ) && isExtraWanderingEnabled() )
{
@@ -115,35 +115,35 @@ void PathfinderMob::serverAiStep()
bool inWater = isInWater();
bool inLava = isInLava();
xRot = 0;
- if (path == NULL || random->nextInt(100) == 0)
+ if (path == nullptr || random->nextInt(100) == 0)
{
this->Mob::serverAiStep();
- setPath(NULL);// 4J - changed to setPath from path =
+ setPath(nullptr);// 4J - changed to setPath from path =
return;
}
Vec3 *target = path->currentPos(shared_from_this());
double r = bbWidth * 2;
- while (target != NULL && target->distanceToSqr(x, target->y, z) < r * r)
+ while (target != nullptr && target->distanceToSqr(x, target->y, z) < r * r)
{
path->next();
if (path->isDone())
{
- target = NULL;
- setPath(NULL); // 4J - changed to setPath from path =
+ target = nullptr;
+ setPath(nullptr); // 4J - changed to setPath from path =
}
else target = path->currentPos(shared_from_this());
}
jumping = false;
- if (target != NULL)
+ if (target != nullptr)
{
double xd = target->x - x;
double zd = target->z - z;
double yd = target->y - yFloor;
- float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90;
+ float yRotD = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
float rotDiff = Mth::wrapDegrees(yRotD - yRot);
- yya = (float) getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue();
+ yya = static_cast<float>(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue());
if (rotDiff > MAX_TURN)
{
rotDiff = MAX_TURN;
@@ -156,13 +156,13 @@ void PathfinderMob::serverAiStep()
if (holdGround)
{
- if (attackTarget != NULL)
+ if (attackTarget != nullptr)
{
double xd2 = attackTarget->x - x;
double zd2 = attackTarget->z - z;
float oldyRot = yRot;
- yRot = (float) (atan2(zd2, xd2) * 180 / PI) - 90;
+ yRot = static_cast<float>(atan2(zd2, xd2) * 180 / PI) - 90;
rotDiff = ((oldyRot - yRot) + 90) * PI / 180;
xxa = -Mth::sin(rotDiff) * yya * 1.0f;
@@ -175,7 +175,7 @@ void PathfinderMob::serverAiStep()
}
}
- if (attackTarget != NULL)
+ if (attackTarget != nullptr)
{
lookAt(attackTarget, 30, 30);
}
@@ -250,7 +250,7 @@ bool PathfinderMob::canSpawn()
bool PathfinderMob::isPathFinding()
{
- return path != NULL;
+ return path != nullptr;
}
void PathfinderMob::setPath(Path *path)
@@ -311,16 +311,16 @@ void PathfinderMob::tickLeash()
{
Mob::tickLeash();
- if (isLeashed() && getLeashHolder() != NULL && getLeashHolder()->level == this->level)
+ if (isLeashed() && getLeashHolder() != nullptr && getLeashHolder()->level == this->level)
{
// soft restriction
shared_ptr<Entity> leashHolder = getLeashHolder();
- restrictTo((int) leashHolder->x, (int) leashHolder->y, (int) leashHolder->z, 5);
+ restrictTo(static_cast<int>(leashHolder->x), static_cast<int>(leashHolder->y), static_cast<int>(leashHolder->z), 5);
float _distanceTo = distanceTo(leashHolder);
shared_ptr<TamableAnimal> tamabaleAnimal = shared_from_this()->instanceof(eTYPE_TAMABLE_ANIMAL) ? dynamic_pointer_cast<TamableAnimal>(shared_from_this()) : nullptr;
- if ( (tamabaleAnimal != NULL) && tamabaleAnimal->isSitting() )
+ if ( (tamabaleAnimal != nullptr) && tamabaleAnimal->isSitting() )
{
if (_distanceTo > 10)
{
diff --git a/Minecraft.World/PerformanceTimer.cpp b/Minecraft.World/PerformanceTimer.cpp
index 5ed7ee0c..1e01a404 100644
--- a/Minecraft.World/PerformanceTimer.cpp
+++ b/Minecraft.World/PerformanceTimer.cpp
@@ -7,7 +7,7 @@ PerformanceTimer::PerformanceTimer()
// Get the frequency of the timer
LARGE_INTEGER qwTicksPerSec;
QueryPerformanceFrequency( &qwTicksPerSec );
- m_fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart;
+ m_fSecsPerTick = 1.0f / static_cast<float>(qwTicksPerSec.QuadPart);
Reset();
#endif
@@ -28,7 +28,7 @@ void PerformanceTimer::PrintElapsedTime(const wstring &description)
QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - m_qwStartTime.QuadPart;
- float fElapsedTime = m_fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart));
+ float fElapsedTime = m_fSecsPerTick * static_cast<FLOAT>(qwDeltaTime.QuadPart);
app.DebugPrintf("TIMER: %ls: Elapsed time %f\n", description.c_str(), fElapsedTime);
#endif
diff --git a/Minecraft.World/PerlinNoise.cpp b/Minecraft.World/PerlinNoise.cpp
index b4c65e55..21f92a6b 100644
--- a/Minecraft.World/PerlinNoise.cpp
+++ b/Minecraft.World/PerlinNoise.cpp
@@ -64,7 +64,7 @@ double PerlinNoise::getValue(double x, double y, double z)
doubleArray PerlinNoise::getRegion(doubleArray buffer, int x, int y, int z, int xSize, int ySize, int zSize, double xScale, double yScale, double zScale)
{
- if (buffer.data == NULL) buffer = doubleArray(xSize * ySize * zSize);
+ if (buffer.data == nullptr) buffer = doubleArray(xSize * ySize * zSize);
else for (unsigned int i = 0; i < buffer.length; i++)
buffer[i] = 0;
diff --git a/Minecraft.World/PerlinSimplexNoise.cpp b/Minecraft.World/PerlinSimplexNoise.cpp
index dbc570a4..97d11448 100644
--- a/Minecraft.World/PerlinSimplexNoise.cpp
+++ b/Minecraft.World/PerlinSimplexNoise.cpp
@@ -72,7 +72,7 @@ doubleArray PerlinSimplexNoise::getRegion(doubleArray buffer, double x, double y
xScale/=1.5;
yScale/=1.5;
- if (buffer.data == NULL || (int) buffer.length < xSize * ySize)
+ if (buffer.data == nullptr || static_cast<int>(buffer.length) < xSize * ySize)
{
if( buffer.data ) delete [] buffer.data;
buffer = doubleArray(xSize * ySize);
@@ -98,7 +98,7 @@ doubleArray PerlinSimplexNoise::getRegion(doubleArray buffer, double x, double y
xScale/=1.5;
yScale/=1.5;
- if (buffer.data == NULL) buffer = doubleArray(xSize * ySize * zSize);
+ if (buffer.data == nullptr) buffer = doubleArray(xSize * ySize * zSize);
else for (unsigned int i = 0; i < buffer.length; i++)
buffer[i] = 0;
diff --git a/Minecraft.World/PickaxeItem.cpp b/Minecraft.World/PickaxeItem.cpp
index 05177e7b..1bcee6e0 100644
--- a/Minecraft.World/PickaxeItem.cpp
+++ b/Minecraft.World/PickaxeItem.cpp
@@ -54,7 +54,7 @@ bool PickaxeItem::canDestroySpecial(Tile *tile)
// 4J - brought forward from 1.2.3
float PickaxeItem::getDestroySpeed(shared_ptr<ItemInstance> itemInstance, Tile *tile)
{
- if (tile != NULL && (tile->material == Material::metal || tile->material == Material::heavyMetal || tile->material == Material::stone))
+ if (tile != nullptr && (tile->material == Material::metal || tile->material == Material::heavyMetal || tile->material == Material::stone))
{
return speed;
}
diff --git a/Minecraft.World/Pig.cpp b/Minecraft.World/Pig.cpp
index cc042f58..a99af826 100644
--- a/Minecraft.World/Pig.cpp
+++ b/Minecraft.World/Pig.cpp
@@ -64,13 +64,13 @@ bool Pig::canBeControlledByRider()
{
shared_ptr<ItemInstance> item = dynamic_pointer_cast<Player>(rider.lock())->getCarriedItem();
- return item != NULL && item->id == Item::carrotOnAStick_Id;
+ return item != nullptr && item->id == Item::carrotOnAStick_Id;
}
void Pig::defineSynchedData()
{
Animal::defineSynchedData();
- entityData->define(DATA_SADDLE_ID, (byte) 0);
+ entityData->define(DATA_SADDLE_ID, static_cast<byte>(0));
}
void Pig::addAdditonalSaveData(CompoundTag *tag)
@@ -109,7 +109,7 @@ bool Pig::mobInteract(shared_ptr<Player> player)
{
if(!Animal::mobInteract(player))
{
- if (hasSaddle() && !level->isClientSide && (rider.lock() == NULL || rider.lock() == player))
+ if (hasSaddle() && !level->isClientSide && (rider.lock() == nullptr || rider.lock() == player))
{
// 4J HEG - Fixed issue with player not being able to dismount pig (issue #4479)
player->ride( rider.lock() == player ? nullptr : shared_from_this() );
@@ -153,18 +153,18 @@ void Pig::setSaddle(bool value)
{
if (value)
{
- entityData->set(DATA_SADDLE_ID, (byte) 1);
+ entityData->set(DATA_SADDLE_ID, static_cast<byte>(1));
}
else
{
- entityData->set(DATA_SADDLE_ID, (byte) 0);
+ entityData->set(DATA_SADDLE_ID, static_cast<byte>(0));
}
}
void Pig::thunderHit(const LightningBolt *lightningBolt)
{
if (level->isClientSide) return;
- shared_ptr<PigZombie> pz = shared_ptr<PigZombie>( new PigZombie(level) );
+ shared_ptr<PigZombie> pz = std::make_shared<PigZombie>(level);
pz->moveTo(x, y, z, yRot, xRot);
level->addEntity(pz);
remove();
@@ -173,7 +173,7 @@ void Pig::thunderHit(const LightningBolt *lightningBolt)
void Pig::causeFallDamage(float distance)
{
Animal::causeFallDamage(distance);
- if ( (distance > 5) && rider.lock() != NULL && rider.lock()->instanceof(eTYPE_PLAYER) )
+ if ( (distance > 5) && rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_PLAYER) )
{
(dynamic_pointer_cast<Player>(rider.lock()))->awardStat(GenericStats::flyPig(),GenericStats::param_flyPig());
}
@@ -184,7 +184,7 @@ shared_ptr<AgableMob> Pig::getBreedOffspring(shared_ptr<AgableMob> target)
// 4J - added limit to number of animals that can be bred
if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) )
{
- return shared_ptr<Pig>( new Pig(level) );
+ return std::make_shared<Pig>(level);
}
else
{
@@ -194,7 +194,7 @@ shared_ptr<AgableMob> Pig::getBreedOffspring(shared_ptr<AgableMob> target)
bool Pig::isFood(shared_ptr<ItemInstance> itemInstance)
{
- return itemInstance != NULL && itemInstance->id == Item::carrots_Id;
+ return itemInstance != nullptr && itemInstance->id == Item::carrots_Id;
}
ControlledByPlayerGoal *Pig::getControlGoal()
diff --git a/Minecraft.World/PigZombie.cpp b/Minecraft.World/PigZombie.cpp
index c284c323..1be123d7 100644
--- a/Minecraft.World/PigZombie.cpp
+++ b/Minecraft.World/PigZombie.cpp
@@ -53,7 +53,7 @@ void PigZombie::tick()
AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED);
speed->removeModifier(SPEED_MODIFIER_ATTACKING);
- if (attackTarget != NULL)
+ if (attackTarget != nullptr)
{
speed->addModifier(new AttributeModifier(*SPEED_MODIFIER_ATTACKING));
}
@@ -78,7 +78,7 @@ bool PigZombie::canSpawn()
void PigZombie::addAdditonalSaveData(CompoundTag *tag)
{
Zombie::addAdditonalSaveData(tag);
- tag->putShort(L"Anger", (short) angerTime);
+ tag->putShort(L"Anger", static_cast<short>(angerTime));
}
void PigZombie::readAdditionalSaveData(CompoundTag *tag)
@@ -105,7 +105,7 @@ shared_ptr<Entity> PigZombie::findAttackTarget()
bool PigZombie::hurt(DamageSource *source, float dmg)
{
shared_ptr<Entity> sourceEntity = source->getEntity();
- if ( sourceEntity != NULL && sourceEntity->instanceof(eTYPE_PLAYER) )
+ if ( sourceEntity != nullptr && sourceEntity->instanceof(eTYPE_PLAYER) )
{
vector<shared_ptr<Entity> > *nearby = level->getEntities( shared_from_this(), bb->grow(32, 32, 32));
for (auto& e : *nearby)
@@ -174,7 +174,7 @@ int PigZombie::getDeathLoot()
void PigZombie::populateDefaultEquipmentSlots()
{
- setEquippedSlot(SLOT_WEAPON, shared_ptr<ItemInstance>( new ItemInstance(Item::sword_gold)) );
+ setEquippedSlot(SLOT_WEAPON, std::make_shared<ItemInstance>(Item::sword_gold));
}
MobGroupData *PigZombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /*= 0*/) // 4J Added extraData param
diff --git a/Minecraft.World/PineFeature.cpp b/Minecraft.World/PineFeature.cpp
index 685f1e48..bbe424aa 100644
--- a/Minecraft.World/PineFeature.cpp
+++ b/Minecraft.World/PineFeature.cpp
@@ -19,7 +19,7 @@ bool PineFeature::place(Level *level, Random *random, int x, int y, int z)
}
// 4J Stu Added to stop tree features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
bool intersects = levelGenOptions->checkIntersects(x - topRadius, y - 1, z - topRadius, x + topRadius, y + treeHeight, z + topRadius);
diff --git a/Minecraft.World/PistonBaseTile.cpp b/Minecraft.World/PistonBaseTile.cpp
index c71bbf95..e8e2a713 100644
--- a/Minecraft.World/PistonBaseTile.cpp
+++ b/Minecraft.World/PistonBaseTile.cpp
@@ -28,7 +28,7 @@ DWORD PistonBaseTile::tlsIdx = TlsAlloc();
// 4J - ignoreUpdate is a static in java, implementing as TLS here to make thread safe
bool PistonBaseTile::ignoreUpdate()
{
- return (TlsGetValue(tlsIdx) != NULL);
+ return (TlsGetValue(tlsIdx) != nullptr);
}
void PistonBaseTile::ignoreUpdate(bool set)
@@ -45,9 +45,9 @@ PistonBaseTile::PistonBaseTile(int id, bool isSticky) : Tile(id, Material::pisto
setSoundType(SOUND_STONE);
setDestroyTime(0.5f);
- iconInside = NULL;
- iconBack = NULL;
- iconPlatform = NULL;
+ iconInside = nullptr;
+ iconBack = nullptr;
+ iconPlatform = nullptr;
}
Icon *PistonBaseTile::getPlatformTexture()
@@ -75,7 +75,7 @@ Icon *PistonBaseTile::getTexture(int face, int data)
// when the piston is extended, either normally
// or because a piston arm animation, the top
// texture is the furnace bottom
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
if (isExtended(data) || tls->xx0 > 0 || tls->yy0 > 0 || tls->zz0 > 0 || tls->xx1 < 1 || tls->yy1 < 1 || tls->zz1 < 1)
{
return iconInside;
@@ -97,7 +97,7 @@ Icon *PistonBaseTile::getTexture(const wstring &name)
if (name.compare(PLATFORM_STICKY_TEX) == 0) return Tile::pistonStickyBase->iconPlatform;
if (name.compare(INSIDE_TEX) == 0) return Tile::pistonBase->iconInside;
- return NULL;
+ return nullptr;
}
//@Override
@@ -144,7 +144,7 @@ void PistonBaseTile::neighborChanged(Level *level, int x, int y, int z, int type
void PistonBaseTile::onPlace(Level *level, int x, int y, int z)
{
- if (!level->isClientSide && level->getTileEntity(x, y, z) == NULL && !ignoreUpdate())
+ if (!level->isClientSide && level->getTileEntity(x, y, z) == nullptr && !ignoreUpdate())
{
checkIfExtend(level, x, y, z);
}
@@ -255,7 +255,7 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
{
PIXBeginNamedEvent(0,"Contract phase A\n");
shared_ptr<TileEntity> prevTileEntity = level->getTileEntity(x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], z + Facing::STEP_Z[facing]);
- if (prevTileEntity != NULL && dynamic_pointer_cast<PistonPieceEntity>(prevTileEntity) != NULL)
+ if (prevTileEntity != nullptr && dynamic_pointer_cast<PistonPieceEntity>(prevTileEntity) != nullptr)
{
dynamic_pointer_cast<PistonPieceEntity>(prevTileEntity)->finalTick();
}
@@ -285,7 +285,7 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
// the block two steps away is a moving piston block piece, so replace it with the real data,
// since it's probably this piston which is changing too fast
shared_ptr<TileEntity> tileEntity = level->getTileEntity(twoX, twoY, twoZ);
- if (tileEntity != NULL && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != NULL )
+ if (tileEntity != nullptr && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != nullptr )
{
shared_ptr<PistonPieceEntity> ppe = dynamic_pointer_cast<PistonPieceEntity>(tileEntity);
@@ -412,7 +412,7 @@ bool PistonBaseTile::isExtended(int data)
int PistonBaseTile::getNewFacing(Level *level, int x, int y, int z, shared_ptr<LivingEntity> player)
{
- if (Mth::abs((float) player->x - x) < 2 && Mth::abs((float) player->z - z) < 2)
+ if (Mth::abs(static_cast<float>(player->x) - x) < 2 && Mth::abs(static_cast<float>(player->z) - z) < 2)
{
// If the player is above the block, the slot is on the top
double py = player->y + 1.82 - player->heightOffset;
diff --git a/Minecraft.World/PistonExtensionTile.cpp b/Minecraft.World/PistonExtensionTile.cpp
index 25c5adb9..bf5e6e60 100644
--- a/Minecraft.World/PistonExtensionTile.cpp
+++ b/Minecraft.World/PistonExtensionTile.cpp
@@ -7,7 +7,7 @@
PistonExtensionTile::PistonExtensionTile(int id) : Tile(id, Material::piston,isSolidRender() )
{
// 4J added initialiser
- overrideTopTexture = NULL;
+ overrideTopTexture = nullptr;
setSoundType(SOUND_STONE);
setDestroyTime(0.5f);
@@ -20,7 +20,7 @@ void PistonExtensionTile::setOverrideTopTexture(Icon *overrideTopTexture)
void PistonExtensionTile::clearOverrideTopTexture()
{
- this->overrideTopTexture = NULL;
+ this->overrideTopTexture = nullptr;
}
void PistonExtensionTile::playerWillDestroy(Level *level, int x, int y, int z, int data, shared_ptr<Player> player)
@@ -65,7 +65,7 @@ Icon *PistonExtensionTile::getTexture(int face, int data)
if (face == facing)
{
- if (overrideTopTexture != NULL)
+ if (overrideTopTexture != nullptr)
{
return overrideTopTexture;
}
diff --git a/Minecraft.World/PistonMovingPiece.cpp b/Minecraft.World/PistonMovingPiece.cpp
index 5fa9a475..5ae01007 100644
--- a/Minecraft.World/PistonMovingPiece.cpp
+++ b/Minecraft.World/PistonMovingPiece.cpp
@@ -23,7 +23,7 @@ void PistonMovingPiece::onPlace(Level *level, int x, int y, int z)
void PistonMovingPiece::onRemove(Level *level, int x, int y, int z, int id, int data)
{
shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
- if (tileEntity != NULL && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != NULL)
+ if (tileEntity != nullptr && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != nullptr)
{
dynamic_pointer_cast<PistonPieceEntity>(tileEntity)->finalTick();
}
@@ -62,7 +62,7 @@ bool PistonMovingPiece::use(Level *level, int x, int y, int z, shared_ptr<Player
{
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);
@@ -81,7 +81,7 @@ void PistonMovingPiece::spawnResources(Level *level, int x, int y, int z, int da
if (level->isClientSide) return;
shared_ptr<PistonPieceEntity> entity = getEntity(level, x, y, z);
- if (entity == NULL)
+ if (entity == nullptr)
{
return;
}
@@ -93,21 +93,21 @@ void PistonMovingPiece::neighborChanged(Level *level, int x, int y, int z, int t
{
if (!level->isClientSide)
{
- level->getTileEntity(x, y, z) == NULL;
+ level->getTileEntity(x, y, z) == nullptr;
}
}
shared_ptr<TileEntity> PistonMovingPiece::newMovingPieceEntity(int block, int data, int facing, bool extending, bool isSourcePiston)
{
- return shared_ptr<TileEntity>(new PistonPieceEntity(block, data, facing, extending, isSourcePiston));
+ return std::make_shared<PistonPieceEntity>(block, data, facing, extending, isSourcePiston);
}
AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z)
{
shared_ptr<PistonPieceEntity> entity = getEntity(level, x, y, z);
- if (entity == NULL)
+ if (entity == nullptr)
{
- return NULL;
+ return nullptr;
}
// move the aabb depending on the animation
@@ -122,11 +122,11 @@ AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z)
void PistonMovingPiece::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
{
shared_ptr<PistonPieceEntity> entity = dynamic_pointer_cast<PistonPieceEntity>(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;
}
@@ -138,7 +138,7 @@ void PistonMovingPiece::updateShape(LevelSource *level, int x, int y, int z, int
progress = 1.0f - progress;
}
int facing = entity->getFacing();
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
tls->xx0 = tile->getShapeX0() - Facing::STEP_X[facing] * progress;
tls->yy0 = tile->getShapeY0() - Facing::STEP_Y[facing] * progress;
tls->zz0 = tile->getShapeZ0() - Facing::STEP_Z[facing] * progress;
@@ -152,13 +152,13 @@ AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z, int tile, fl
{
if (tile == 0 || tile == id)
{
- return NULL;
+ return nullptr;
}
AABB *aabb = Tile::tiles[tile]->getAABB(level, x, y, z);
- if (aabb == NULL)
+ if (aabb == nullptr)
{
- return NULL;
+ return nullptr;
}
// move the aabb depending on the animation
@@ -192,7 +192,7 @@ AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z, int tile, fl
shared_ptr<PistonPieceEntity> PistonMovingPiece::getEntity(LevelSource *level, int x, int y, int z)
{
shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
- if (tileEntity != NULL && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != NULL)
+ if (tileEntity != nullptr && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != nullptr)
{
return dynamic_pointer_cast<PistonPieceEntity>(tileEntity);
}
diff --git a/Minecraft.World/PistonPieceEntity.cpp b/Minecraft.World/PistonPieceEntity.cpp
index a915c2ff..08e18cbb 100644
--- a/Minecraft.World/PistonPieceEntity.cpp
+++ b/Minecraft.World/PistonPieceEntity.cpp
@@ -117,7 +117,7 @@ void PistonPieceEntity::moveCollidedEntities(float progress, float amount)
}
AABB *aabb = Tile::pistonMovingPiece->getAABB(level, x, y, z, id, progress, facing);
- if (aabb != NULL)
+ if (aabb != nullptr)
{
vector<shared_ptr<Entity> > *entities = level->getEntities(nullptr, aabb);
if (!entities->empty())
@@ -140,7 +140,7 @@ void PistonPieceEntity::moveCollidedEntities(float progress, float amount)
void PistonPieceEntity::finalTick()
{
- if (progressO < 1 && level != NULL)
+ if (progressO < 1 && level != nullptr)
{
progressO = progress = 1;
level->removeTileEntity(x, y, z);
@@ -207,7 +207,7 @@ void PistonPieceEntity::save(CompoundTag *tag)
// 4J Added
shared_ptr<TileEntity> PistonPieceEntity::clone()
{
- shared_ptr<PistonPieceEntity> result = shared_ptr<PistonPieceEntity>( new PistonPieceEntity() );
+ shared_ptr<PistonPieceEntity> result = std::make_shared<PistonPieceEntity>();
TileEntity::clone(result);
result->id = id;
diff --git a/Minecraft.World/PlayGoal.cpp b/Minecraft.World/PlayGoal.cpp
index 72ee69d4..6ce3af23 100644
--- a/Minecraft.World/PlayGoal.cpp
+++ b/Minecraft.World/PlayGoal.cpp
@@ -40,22 +40,22 @@ bool PlayGoal::canUse()
}
delete children;
- if (followFriend.lock() == NULL)
+ if (followFriend.lock() == nullptr)
{
Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16, 3);
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
}
return true;
}
bool PlayGoal::canContinueToUse()
{
- return playTime > 0 && followFriend.lock() != NULL;
+ return playTime > 0 && followFriend.lock() != nullptr;
}
void PlayGoal::start()
{
- if (followFriend.lock() != NULL) mob->setChasing(true);
+ if (followFriend.lock() != nullptr) mob->setChasing(true);
playTime = 1000;
}
@@ -68,7 +68,7 @@ void PlayGoal::stop()
void PlayGoal::tick()
{
--playTime;
- if (followFriend.lock() != NULL)
+ if (followFriend.lock() != nullptr)
{
if (mob->distanceToSqr(followFriend.lock()) > 2 * 2) mob->getNavigation()->moveTo(followFriend.lock(), speedModifier);
}
@@ -77,7 +77,7 @@ void PlayGoal::tick()
if (mob->getNavigation()->isDone())
{
Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16, 3);
- if (pos == NULL) return;
+ if (pos == nullptr) return;
mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, speedModifier);
}
}
diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp
index bd6b68a8..00c7148e 100644
--- a/Minecraft.World/Player.cpp
+++ b/Minecraft.World/Player.cpp
@@ -50,7 +50,7 @@ void Player::_init()
registerAttributes();
setHealth(getMaxHealth());
- inventory = shared_ptr<Inventory>( new Inventory( this ) );
+ inventory = std::make_shared<Inventory>(this);
userType = 0;
oBob = bob = 0.0f;
@@ -64,17 +64,17 @@ void Player::_init()
customTextureUrl2 = L"";
m_uiPlayerCurrentSkin=0;
- bedPosition = NULL;
+ bedPosition = nullptr;
sleepCounter = 0;
deathFadeCounter=0;
bedOffsetX = bedOffsetY = bedOffsetZ = 0.0f;
- stats = NULL;
+ stats = nullptr;
- respawnPosition = NULL;
+ respawnPosition = nullptr;
respawnForced = false;
- minecartAchievementPos = NULL;
+ minecartAchievementPos = nullptr;
fishing = nullptr;
@@ -97,7 +97,7 @@ void Player::_init()
m_uiGamePrivileges = 0;
- m_ppAdditionalModelParts=NULL;
+ m_ppAdditionalModelParts=nullptr;
m_bCheckedForModelParts=false;
m_bCheckedDLCForModelParts=false;
@@ -105,7 +105,7 @@ void Player::_init()
m_ePlayerNameValidState=ePlayerNameValid_NotSet;
#endif
- enderChestInventory = shared_ptr<PlayerEnderChestContainer>(new PlayerEnderChestContainer());
+ enderChestInventory = std::make_shared<PlayerEnderChestContainer>();
m_bAwardedOnARail=false;
}
@@ -175,8 +175,8 @@ void Player::defineSynchedData()
{
LivingEntity::defineSynchedData();
- entityData->define(DATA_PLAYER_FLAGS_ID, (byte) 0);
- entityData->define(DATA_PLAYER_ABSORPTION_ID, (float) 0);
+ entityData->define(DATA_PLAYER_FLAGS_ID, static_cast<byte>(0));
+ entityData->define(DATA_PLAYER_ABSORPTION_ID, static_cast<float>(0));
entityData->define(DATA_SCORE_ID, (int) 0);
}
@@ -192,7 +192,7 @@ int Player::getUseItemDuration()
bool Player::isUsingItem()
{
- return useItem != NULL;
+ return useItem != nullptr;
}
int Player::getTicksUsingItem()
@@ -206,7 +206,7 @@ int Player::getTicksUsingItem()
void Player::releaseUsingItem()
{
- if (useItem != NULL)
+ if (useItem != nullptr)
{
useItem->releaseUsing(level, dynamic_pointer_cast<Player>( shared_from_this() ), useItemDuration);
@@ -237,13 +237,13 @@ bool Player::isBlocking()
// 4J Stu - Added for things that should only be ticked once per simulation frame
void Player::updateFrameTick()
{
- if (useItem != NULL)
+ if (useItem != nullptr)
{
shared_ptr<ItemInstance> item = inventory->getSelected();
// 4J Stu - Fix for #45508 - TU5: Gameplay: Eating one piece of food will result in a second piece being eaten as well
- // Original code was item != useItem. Changed this now to use the equals function, and add the NULL check as well for the other possible not equals (useItem is not NULL if we are here)
+ // Original code was item != useItem. Changed this now to use the equals function, and add the nullptr check as well for the other possible not equals (useItem is not nullptr if we are here)
// This is because the useItem and item could be different objects due to an inventory update from the server, but still be the same item (with the same id,count and auxvalue)
- if (item == NULL || !item->equals(useItem) )
+ if (item == nullptr || !item->equals(useItem) )
{
stopUsingItem();
}
@@ -316,7 +316,7 @@ void Player::tick()
if (!level->isClientSide)
{
- if (containerMenu != NULL && !containerMenu->stillValid( dynamic_pointer_cast<Player>( shared_from_this() ) ))
+ if (containerMenu != nullptr && !containerMenu->stillValid( dynamic_pointer_cast<Player>( shared_from_this() ) ))
{
closeContainer();
containerMenu = inventoryMenu;
@@ -348,12 +348,12 @@ void Player::tick()
zCloak += zca * 0.25;
yCloak += yca * 0.25;
- if (riding == NULL)
+ if (riding == nullptr)
{
- if( minecartAchievementPos != NULL )
+ if( minecartAchievementPos != nullptr )
{
delete minecartAchievementPos;
- minecartAchievementPos = NULL;
+ minecartAchievementPos = nullptr;
}
}
@@ -573,13 +573,13 @@ void Player::spawnEatParticles(shared_ptr<ItemInstance> useItem, int count)
void Player::completeUsingItem()
{
- if (useItem != NULL)
+ if (useItem != nullptr)
{
spawnEatParticles(useItem, 16);
int oldCount = useItem->count;
shared_ptr<ItemInstance> itemInstance = useItem->useTimeDepleted(level, dynamic_pointer_cast<Player>(shared_from_this()));
- if (itemInstance != useItem || (itemInstance != NULL && itemInstance->count != oldCount))
+ if (itemInstance != useItem || (itemInstance != nullptr && itemInstance->count != oldCount))
{
inventory->items[inventory->selected] = itemInstance;
if (itemInstance->count == 0)
@@ -615,11 +615,11 @@ void Player::closeContainer()
void Player::ride(shared_ptr<Entity> e)
{
- if (riding != NULL && e == NULL)
+ if (riding != nullptr && e == nullptr)
{
if (!level->isClientSide) findStandUpPosition(riding);
- if (riding != NULL)
+ if (riding != nullptr)
{
riding->rider = weak_ptr<Entity>();
}
@@ -657,13 +657,13 @@ void Player::setCustomSkin(DWORD skinId)
DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId);
if( ugcSkinIndex == 0 && defaultSkinIndex > 0 )
{
- playerSkin = (EDefaultSkins) defaultSkinIndex;
+ playerSkin = static_cast<EDefaultSkins>(defaultSkinIndex);
}
}
if( playerSkin == eDefaultSkins_ServerSelected)
{
- playerSkin = (EDefaultSkins)(m_playerIndex + 1);
+ playerSkin = static_cast<EDefaultSkins>(m_playerIndex + 1);
}
// We always set a default skin, since we may be waiting for the player's custom skin to be transmitted
@@ -675,7 +675,7 @@ void Player::setCustomSkin(DWORD skinId)
// set the new player additional boxes
/*vector<ModelPart *> *pvModelParts=app.GetAdditionalModelParts(m_dwSkinId);
- if(pvModelParts==NULL)
+ if(pvModelParts==nullptr)
{
// we don't have the data from the dlc skin yet
app.DebugPrintf("Couldn't get model parts for skin %X\n",m_dwSkinId);
@@ -683,7 +683,7 @@ void Player::setCustomSkin(DWORD skinId)
// do we have it from the DLC pack?
DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(this->customTextureUrl);
- if(pDLCSkinFile!=NULL)
+ if(pDLCSkinFile!=nullptr)
{
DWORD dwBoxC=pDLCSkinFile->getAdditionalBoxesCount();
if(dwBoxC!=0)
@@ -694,13 +694,13 @@ void Player::setCustomSkin(DWORD skinId)
}
else
{
- this->SetAdditionalModelParts(NULL);
+ this->SetAdditionalModelParts(nullptr);
}
app.SetAnimOverrideBitmask(pDLCSkinFile->getSkinID(),pDLCSkinFile->getAnimOverrideBitmask());
}
else
{
- this->SetAdditionalModelParts(NULL);
+ this->SetAdditionalModelParts(nullptr);
}
}
else
@@ -713,7 +713,7 @@ void Player::setCustomSkin(DWORD skinId)
// reset the check for model parts
m_bCheckedForModelParts=false;
m_bCheckedDLCForModelParts=false;
- this->SetAdditionalModelParts(NULL);
+ this->SetAdditionalModelParts(nullptr);
}
@@ -964,7 +964,7 @@ void Player::rideTick()
checkRidingStatistiscs(x - preX, y - preY, z - preZ);
// riding can be set to null inside 'Entity::rideTick()'.
- if ( riding != NULL && (riding->GetType() & eTYPE_PIG) == eTYPE_PIG )
+ if ( riding != nullptr && (riding->GetType() & eTYPE_PIG) == eTYPE_PIG )
{
// 4J Stu - I don't know why we would want to do this, but it means that the players head is locked in position and can't move around
//xRot = preXRot;
@@ -1018,9 +1018,9 @@ void Player::aiStep()
flyingSpeed += defaultFlySpeed * 0.3f;
}
- setSpeed((float) speed->getValue());
+ setSpeed(static_cast<float>(speed->getValue()));
- float tBob = (float) sqrt(xd * xd + zd * zd);
+ float tBob = static_cast<float>(sqrt(xd * xd + zd * zd));
// 4J added - we were getting a NaN with zero xd & zd
if(( xd * xd + zd * zd ) < 0.00001f )
@@ -1028,7 +1028,7 @@ void Player::aiStep()
tBob = 0.0f;
}
- float tTilt = (float) atan(-yd * 0.2f) * 15.0f;
+ float tTilt = static_cast<float>(atan(-yd * 0.2f)) * 15.0f;
if (tBob > 0.1f) tBob = 0.1f;
if (!onGround || getHealth() <= 0) tBob = 0;
if (onGround || getHealth() <= 0) tTilt = 0;
@@ -1039,8 +1039,8 @@ void Player::aiStep()
if (getHealth() > 0)
{
- AABB *pickupArea = NULL;
- if (riding != NULL && !riding->removed)
+ AABB *pickupArea = nullptr;
+ if (riding != nullptr && !riding->removed)
{
// if the player is riding, also touch entities under the
// pig/horse
@@ -1052,7 +1052,7 @@ void Player::aiStep()
}
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), pickupArea);
- if (entities != NULL)
+ if (entities != nullptr)
{
for (auto& e : *entities)
{
@@ -1097,14 +1097,14 @@ void Player::die(DamageSource *source)
// 4J - TODO need to use a xuid
if ( app.isXuidNotch( m_xuid ) )
{
- drop(shared_ptr<ItemInstance>( new ItemInstance(Item::apple, 1) ), true);
+ drop(std::make_shared<ItemInstance>(Item::apple, 1), true);
}
if (!level->getGameRules()->getBoolean(GameRules::RULE_KEEPINVENTORY))
{
inventory->dropAll();
}
- if (source != NULL)
+ if (source != nullptr)
{
xd = -Mth::cos((hurtDir + yRot) * PI / 180) * 0.1f;
zd = -Mth::sin((hurtDir + yRot) * PI / 180) * 0.1f;
@@ -1157,7 +1157,7 @@ bool Player::isCreativeModeAllowed()
shared_ptr<ItemEntity> Player::drop(bool all)
{
- return drop(inventory->removeItem(inventory->selected, all && inventory->getSelected() != NULL ? inventory->getSelected()->count : 1), false);
+ return drop(inventory->removeItem(inventory->selected, all && inventory->getSelected() != nullptr ? inventory->getSelected()->count : 1), false);
}
shared_ptr<ItemEntity> Player::drop(shared_ptr<ItemInstance> item)
@@ -1167,10 +1167,10 @@ shared_ptr<ItemEntity> Player::drop(shared_ptr<ItemInstance> item)
shared_ptr<ItemEntity> Player::drop(shared_ptr<ItemInstance> item, bool randomly)
{
- if (item == NULL) return nullptr;
+ if (item == nullptr) return nullptr;
if (item->count == 0) return nullptr;
- shared_ptr<ItemEntity> thrownItem = shared_ptr<ItemEntity>( new ItemEntity(level, x, y - 0.3f + getHeadHeight(), z, item) );
+ shared_ptr<ItemEntity> thrownItem = std::make_shared<ItemEntity>(level, x, y - 0.3f + getHeadHeight(), z, item);
thrownItem->throwTime = 20 * 2;
thrownItem->setThrower(getName());
@@ -1221,7 +1221,7 @@ float Player::getDestroySpeed(Tile *tile, bool hasProperTool)
int efficiency = EnchantmentHelper::getDiggingBonus(dynamic_pointer_cast<LivingEntity>(shared_from_this()));
shared_ptr<ItemInstance> item = inventory->getSelected();
- if (efficiency > 0 && item != NULL)
+ if (efficiency > 0 && item != nullptr)
{
float boost = efficiency * efficiency + 1;
@@ -1305,14 +1305,14 @@ void Player::addAdditonalSaveData(CompoundTag *entityTag)
entityTag->put(L"Inventory", inventory->save(new ListTag<CompoundTag>()));
entityTag->putInt(L"SelectedItemSlot", inventory->selected);
entityTag->putBoolean(L"Sleeping", m_isSleeping);
- entityTag->putShort(L"SleepTimer", (short) sleepCounter);
+ entityTag->putShort(L"SleepTimer", static_cast<short>(sleepCounter));
entityTag->putFloat(L"XpP", experienceProgress);
entityTag->putInt(L"XpLevel", experienceLevel);
entityTag->putInt(L"XpTotal", totalExperience);
entityTag->putInt(L"Score", getScore());
- if (respawnPosition != NULL)
+ if (respawnPosition != nullptr)
{
entityTag->putInt(L"SpawnX", respawnPosition->x);
entityTag->putInt(L"SpawnY", respawnPosition->y);
@@ -1407,10 +1407,10 @@ bool Player::hurt(DamageSource *source, float dmg)
if (dmg == 0) return false;
shared_ptr<Entity> attacker = source->getEntity();
- if ( attacker != NULL && attacker->instanceof(eTYPE_ARROW) )
+ if ( attacker != nullptr && attacker->instanceof(eTYPE_ARROW) )
{
shared_ptr<Arrow> arrow = dynamic_pointer_cast<Arrow>(attacker);
- if ( arrow->owner != NULL)
+ if ( arrow->owner != nullptr)
{
attacker = arrow->owner;
}
@@ -1424,7 +1424,7 @@ bool Player::canHarmPlayer(shared_ptr<Player> target)
Team *team = getTeam();
Team *otherTeam = target->getTeam();
- if (team == NULL)
+ if (team == nullptr)
{
return true;
}
@@ -1455,11 +1455,11 @@ 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++;
}
}
- return (float) count / (float) inventory->armor.length;
+ return static_cast<float>(count) / static_cast<float>(inventory->armor.length);
}
void Player::actuallyHurt(DamageSource *source, float dmg)
@@ -1526,13 +1526,13 @@ bool Player::interact(shared_ptr<Entity> entity)
shared_ptr<Player> thisPlayer = dynamic_pointer_cast<Player>(shared_from_this());
shared_ptr<ItemInstance> item = getSelectedItem();
- shared_ptr<ItemInstance> itemClone = (item != NULL) ? item->copy() : nullptr;
+ shared_ptr<ItemInstance> itemClone = (item != nullptr) ? item->copy() : nullptr;
if ( entity->interact(thisPlayer) )
{
// [EB]: Added rude check to see if we're still talking about the
// same item; this code caused bucket->milkbucket to be deleted because
// the milkbuckets' stack got decremented to 0.
- if (item != NULL && item == getSelectedItem())
+ if (item != nullptr && item == getSelectedItem())
{
if (item->count <= 0 && !abilities.instabuild)
{
@@ -1546,7 +1546,7 @@ bool Player::interact(shared_ptr<Entity> 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
@@ -1594,7 +1594,7 @@ void Player::attack(shared_ptr<Entity> entity)
return;
}
- float dmg = (float) getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->getValue();
+ float dmg = static_cast<float>(getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->getValue());
int knockback = 0;
float magicBoost = 0;
@@ -1613,7 +1613,7 @@ void Player::attack(shared_ptr<Entity> entity)
if (dmg > 0 || magicBoost > 0)
{
- bool bCrit = fallDistance > 0 && !onGround && !onLadder() && !isInWater() && !hasEffect(MobEffect::blindness) && (riding == NULL) && entity->instanceof(eTYPE_LIVINGENTITY);
+ bool bCrit = fallDistance > 0 && !onGround && !onLadder() && !isInWater() && !hasEffect(MobEffect::blindness) && (riding == nullptr) && entity->instanceof(eTYPE_LIVINGENTITY);
if (bCrit && dmg > 0)
{
dmg *= 1.5f;
@@ -1671,12 +1671,12 @@ void Player::attack(shared_ptr<Entity> entity)
if ( entity->instanceof(eTYPE_MULTIENTITY_MOB_PART) )
{
shared_ptr<Entity> multiMob = dynamic_pointer_cast<Entity>((dynamic_pointer_cast<MultiEntityMobPart>(entity))->parentMob.lock());
- if ( (multiMob != NULL) && multiMob->instanceof(eTYPE_LIVINGENTITY) )
+ if ( (multiMob != nullptr) && multiMob->instanceof(eTYPE_LIVINGENTITY) )
{
hurtTarget = dynamic_pointer_cast<LivingEntity>( multiMob );
}
}
- if ( (item != NULL) && hurtTarget->instanceof(eTYPE_LIVINGENTITY) )
+ if ( (item != nullptr) && hurtTarget->instanceof(eTYPE_LIVINGENTITY) )
{
item->hurtEnemy(dynamic_pointer_cast<LivingEntity>(hurtTarget), dynamic_pointer_cast<Player>( shared_from_this() ) );
if (item->count <= 0)
@@ -1737,14 +1737,14 @@ void Player::animateRespawn(shared_ptr<Player> player, Level *level)
Slot *Player::getInventorySlot(int slotId)
{
- return NULL;
+ return nullptr;
}
void Player::remove()
{
LivingEntity::remove();
inventoryMenu->removed( dynamic_pointer_cast<Player>( shared_from_this() ) );
- if (containerMenu != NULL)
+ if (containerMenu != nullptr)
{
containerMenu->removed( dynamic_pointer_cast<Player>( shared_from_this() ) );
}
@@ -1909,12 +1909,12 @@ void Player::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool save
Pos *pos = bedPosition;
Pos *standUp = bedPosition;
- if (pos != NULL && level->getTile(pos->x, pos->y, pos->z) == Tile::bed_Id)
+ if (pos != nullptr && level->getTile(pos->x, pos->y, pos->z) == Tile::bed_Id)
{
BedTile::setOccupied(level, pos->x, pos->y, pos->z, false);
standUp = BedTile::findStandUpPosition(level, pos->x, pos->y, pos->z, 0);
- if (standUp == NULL)
+ if (standUp == nullptr)
{
standUp = new Pos(pos->x, pos->y + 1, pos->z);
}
@@ -1968,7 +1968,7 @@ Pos *Player::checkBedValidRespawnPosition(Level *level, Pos *pos, bool forced)
{
return pos;
}
- return NULL;
+ return nullptr;
}
// make sure the bed still has a stand-up position
Pos *standUp = BedTile::findStandUpPosition(level, pos->x, pos->y, pos->z, 0);
@@ -1977,7 +1977,7 @@ Pos *Player::checkBedValidRespawnPosition(Level *level, Pos *pos, bool forced)
float Player::getSleepRotation()
{
- if (bedPosition != NULL)
+ if (bedPosition != nullptr)
{
int data = level->getData(bedPosition->x, bedPosition->y, bedPosition->z);
int direction = BedTile::getDirection(data);
@@ -2028,11 +2028,11 @@ void Player::setPlayerFlag(int flag, bool value)
byte currentValue = entityData->getByte(DATA_PLAYER_FLAGS_ID);
if (value)
{
- entityData->set(DATA_PLAYER_FLAGS_ID, (byte) (currentValue | (1 << flag)));
+ entityData->set(DATA_PLAYER_FLAGS_ID, static_cast<byte>(currentValue | (1 << flag)));
}
else
{
- entityData->set(DATA_PLAYER_FLAGS_ID, (byte) (currentValue & ~(1 << flag)));
+ entityData->set(DATA_PLAYER_FLAGS_ID, static_cast<byte>(currentValue & ~(1 << flag)));
}
}
@@ -2059,21 +2059,21 @@ bool Player::isRespawnForced()
void Player::setRespawnPosition(Pos *respawnPosition, bool forced)
{
- if (respawnPosition != NULL)
+ if (respawnPosition != nullptr)
{
this->respawnPosition = new Pos(*respawnPosition);
respawnForced = forced;
}
else
{
- this->respawnPosition = NULL;
+ this->respawnPosition = nullptr;
respawnForced = false;
}
}
void Player::awardStat(Stat *stat, byteArray paramBlob)
{
- if (paramBlob.data != NULL)
+ if (paramBlob.data != nullptr)
{
delete [] paramBlob.data;
}
@@ -2102,7 +2102,7 @@ void Player::travel(float xa, float ya)
{
double preX = x, preY = y, preZ = z;
- if (abilities.flying && riding == NULL)
+ if (abilities.flying && riding == nullptr)
{
double ydo = yd;
float ofs = flyingSpeed;
@@ -2121,19 +2121,19 @@ void Player::travel(float xa, float ya)
float Player::getSpeed()
{
- return (float) getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue();
+ return static_cast<float>(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue());
}
void Player::checkMovementStatistiscs(double dx, double dy, double dz)
{
- if (riding != NULL)
+ if (riding != nullptr)
{
return;
}
if (isUnderLiquid(Material::water))
{
- int distance = (int) Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f);
+ int distance = static_cast<int>(Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f));
if (distance > 0)
{
//awardStat(Stats::diveOneCm, distance);
@@ -2142,7 +2142,7 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz)
}
else if (isInWater())
{
- int horizontalDistance = (int) Math::round(sqrt(dx * dx + dz * dz) * 100.0f);
+ int horizontalDistance = static_cast<int>(Math::round(sqrt(dx * dx + dz * dz) * 100.0f));
if (horizontalDistance > 0)
{
distanceSwim += horizontalDistance;
@@ -2159,7 +2159,7 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz)
{
if (dy > 0)
{
- distanceClimb += (int) Math::round(dy * 100.0f);
+ distanceClimb += static_cast<int>(Math::round(dy * 100.0f));
if( distanceClimb >= 100 )
{
int newDistance = distanceClimb - (distanceClimb % 100);
@@ -2170,7 +2170,7 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz)
}
else if (onGround)
{
- int horizontalDistance = (int) Math::round(sqrt(dx * dx + dz * dz) * 100.0f);
+ int horizontalDistance = static_cast<int>(Math::round(sqrt(dx * dx + dz * dz) * 100.0f));
if (horizontalDistance > 0)
{
distanceWalk += horizontalDistance;
@@ -2195,9 +2195,9 @@ 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);
+ int distance = static_cast<int>(Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f));
if (distance > 0)
{
if ( riding->instanceof(eTYPE_MINECART) )
@@ -2211,7 +2211,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz)
}
int dist = 0;
- if (minecartAchievementPos == NULL)
+ if (minecartAchievementPos == nullptr)
{
minecartAchievementPos = new Pos(Mth::floor(x), Mth::floor(y), Mth::floor(z));
}
@@ -2278,7 +2278,7 @@ void Player::causeFallDamage(float distance)
if (distance >= 2)
{
- distanceFall += (int) Math::round(distance * 100.0);
+ distanceFall += static_cast<int>(Math::round(distance * 100.0));
if( distanceFall >= 100 )
{
int newDistance = distanceFall - (distanceFall % 100);
@@ -2309,7 +2309,7 @@ void Player::killed(shared_ptr<LivingEntity> mob)
awardStat(GenericStats::killsSkeleton(), GenericStats::param_noArgs());
break;
case eTYPE_SPIDER:
- if( mob->rider.lock() != NULL && mob->rider.lock()->GetType() == eTYPE_SKELETON )
+ if( mob->rider.lock() != nullptr && mob->rider.lock()->GetType() == eTYPE_SKELETON )
awardStat(GenericStats::killsSpiderJockey(), GenericStats::param_noArgs());
else
awardStat(GenericStats::killsSpider(), GenericStats::param_noArgs());
@@ -2348,7 +2348,7 @@ void Player::makeStuckInWeb()
Icon *Player::getItemInHandIcon(shared_ptr<ItemInstance> item, int layer)
{
Icon *icon = LivingEntity::getItemInHandIcon(item, layer);
- if (item->id == Item::fishingRod->id && fishing != NULL)
+ if (item->id == Item::fishingRod->id && fishing != nullptr)
{
icon = Item::fishingRod->getEmptyIcon();
}
@@ -2356,7 +2356,7 @@ Icon *Player::getItemInHandIcon(shared_ptr<ItemInstance> item, int layer)
{
return item->getItem()->getLayerIcon(item->getAuxValue(), layer);
}
- else if (useItem != NULL && item->id == Item::bow_Id)
+ else if (useItem != nullptr && item->id == Item::bow_Id)
{
int ticksHeld = (item->getUseDuration() - useItemDuration);
if (ticksHeld >= BowItem::MAX_DRAW_DURATION - 2)
@@ -2388,7 +2388,7 @@ void Player::increaseXp(int i)
{
i = max;
}
- experienceProgress += (float) i / getXpNeededForNextLevel();
+ experienceProgress += static_cast<float>(i) / getXpNeededForNextLevel();
totalExperience += i;
while (experienceProgress >= 1)
{
@@ -2502,7 +2502,7 @@ bool Player::mayDestroyBlockAt(int x, int y, int z)
{
return true;
}
- else if (getSelectedItem() != NULL)
+ else if (getSelectedItem() != nullptr)
{
shared_ptr<ItemInstance> carried = getSelectedItem();
@@ -2521,7 +2521,7 @@ bool Player::mayUseItemAt(int x, int y, int z, int face, shared_ptr<ItemInstance
{
return true;
}
- if (item != NULL)
+ if (item != nullptr)
{
return item->mayBePlacedInAdventureMode();
}
@@ -2714,7 +2714,7 @@ int Player::hash_fnct(const shared_ptr<Player> k)
#ifdef __PS3__
return (int)boost::hash_value( k->name ); // 4J Stu - Names are completely unique?
#else
- return (int)std::hash<wstring>{}(k->name); // 4J Stu - Names are completely unique?
+ return static_cast<int>(std::hash<wstring>{}(k->name)); // 4J Stu - Names are completely unique?
#endif //__PS3__
}
@@ -2806,7 +2806,7 @@ void Player::setPlayerGamePrivilege(unsigned int &uiGamePrivileges, EPlayerGameP
bool Player::isAllowedToUse(Tile *tile)
{
bool allowed = true;
- if(tile != NULL && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0)
+ if(tile != nullptr && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0)
{
allowed = false;
@@ -2877,7 +2877,7 @@ bool Player::isAllowedToUse(Tile *tile)
bool Player::isAllowedToUse(shared_ptr<ItemInstance> item)
{
bool allowed = true;
- if(item != NULL && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0)
+ if(item != nullptr && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0)
{
if(getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotBuild) != 0)
{
@@ -3085,7 +3085,7 @@ bool Player::canCreateParticles()
vector<ModelPart *> *Player::GetAdditionalModelParts()
{
- if(m_ppAdditionalModelParts==NULL && !m_bCheckedForModelParts)
+ if(m_ppAdditionalModelParts==nullptr && !m_bCheckedForModelParts)
{
bool hasCustomTexture = !customTextureUrl.empty();
bool customTextureIsDefaultSkin = customTextureUrl.substr(0,3).compare(L"def") == 0;
@@ -3094,11 +3094,11 @@ vector<ModelPart *> *Player::GetAdditionalModelParts()
m_ppAdditionalModelParts=app.GetAdditionalModelParts(m_dwSkinId);
// If it's a default texture (which has no parts), we have the parts, or we already have the texture (in which case we should have parts if there are any) then we are done
- if(!hasCustomTexture || customTextureIsDefaultSkin || m_ppAdditionalModelParts != NULL || app.IsFileInMemoryTextures(customTextureUrl))
+ if(!hasCustomTexture || customTextureIsDefaultSkin || m_ppAdditionalModelParts != nullptr || app.IsFileInMemoryTextures(customTextureUrl))
{
m_bCheckedForModelParts=true;
}
- if(m_ppAdditionalModelParts == NULL && !m_bCheckedDLCForModelParts)
+ if(m_ppAdditionalModelParts == nullptr && !m_bCheckedDLCForModelParts)
{
m_bCheckedDLCForModelParts = true;
@@ -3108,7 +3108,7 @@ vector<ModelPart *> *Player::GetAdditionalModelParts()
// do we have it from the DLC pack?
DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(this->customTextureUrl);
- if(pDLCSkinFile!=NULL)
+ if(pDLCSkinFile!=nullptr)
{
DWORD dwBoxC=pDLCSkinFile->getAdditionalBoxesCount();
if(dwBoxC!=0)
diff --git a/Minecraft.World/PlayerAbilitiesPacket.h b/Minecraft.World/PlayerAbilitiesPacket.h
index 8cd82bf5..3998c66b 100644
--- a/Minecraft.World/PlayerAbilitiesPacket.h
+++ b/Minecraft.World/PlayerAbilitiesPacket.h
@@ -44,6 +44,6 @@ public:
bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new PlayerAbilitiesPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<PlayerAbilitiesPacket>(); }
virtual int getId() { return 202; }
}; \ No newline at end of file
diff --git a/Minecraft.World/PlayerActionPacket.h b/Minecraft.World/PlayerActionPacket.h
index 45c077d2..647777cd 100644
--- a/Minecraft.World/PlayerActionPacket.h
+++ b/Minecraft.World/PlayerActionPacket.h
@@ -24,7 +24,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new PlayerActionPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<PlayerActionPacket>(); }
virtual int getId() { return 14; }
};
diff --git a/Minecraft.World/PlayerCommandPacket.h b/Minecraft.World/PlayerCommandPacket.h
index 92ee57eb..042b32ca 100644
--- a/Minecraft.World/PlayerCommandPacket.h
+++ b/Minecraft.World/PlayerCommandPacket.h
@@ -36,6 +36,6 @@ public:
virtual void handle(PacketListener *listener);
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new PlayerCommandPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<PlayerCommandPacket>(); }
virtual int getId() { return 19; }
}; \ No newline at end of file
diff --git a/Minecraft.World/PlayerEnderChestContainer.cpp b/Minecraft.World/PlayerEnderChestContainer.cpp
index f0a1aaa3..33ebcbd4 100644
--- a/Minecraft.World/PlayerEnderChestContainer.cpp
+++ b/Minecraft.World/PlayerEnderChestContainer.cpp
@@ -38,10 +38,10 @@ ListTag<CompoundTag> *PlayerEnderChestContainer::createTag()
for (int i = 0; i < getContainerSize(); i++)
{
shared_ptr<ItemInstance> item = getItem(i);
- if (item != NULL)
+ if (item != nullptr)
{
CompoundTag *tag = new CompoundTag();
- tag->putByte(L"Slot", (byte) i);
+ tag->putByte(L"Slot", static_cast<byte>(i));
item->save(tag);
items->add(tag);
}
@@ -51,7 +51,7 @@ ListTag<CompoundTag> *PlayerEnderChestContainer::createTag()
bool PlayerEnderChestContainer::stillValid(shared_ptr<Player> player)
{
- if (activeChest != NULL && !activeChest->stillValid(player))
+ if (activeChest != nullptr && !activeChest->stillValid(player))
{
return false;
}
@@ -60,7 +60,7 @@ bool PlayerEnderChestContainer::stillValid(shared_ptr<Player> player)
void PlayerEnderChestContainer::startOpen()
{
- if (activeChest != NULL)
+ if (activeChest != nullptr)
{
activeChest->startOpen();
}
diff --git a/Minecraft.World/PlayerInfoPacket.cpp b/Minecraft.World/PlayerInfoPacket.cpp
index 9cbe5f7c..d0ad8d2a 100644
--- a/Minecraft.World/PlayerInfoPacket.cpp
+++ b/Minecraft.World/PlayerInfoPacket.cpp
@@ -28,7 +28,7 @@ PlayerInfoPacket::PlayerInfoPacket(BYTE networkSmallId, short playerColourIndex,
PlayerInfoPacket::PlayerInfoPacket(shared_ptr<ServerPlayer> player)
{
m_networkSmallId = 0;
- if(player->connection != NULL && player->connection->getNetworkPlayer() != NULL) m_networkSmallId = player->connection->getNetworkPlayer()->GetSmallId();
+ if(player->connection != nullptr && player->connection->getNetworkPlayer() != nullptr) m_networkSmallId = player->connection->getNetworkPlayer()->GetSmallId();
m_playerColourIndex = player->getPlayerIndex();
m_playerPrivileges = player->getAllPlayerGamePrivileges();
m_entityId = player->entityId;
diff --git a/Minecraft.World/PlayerInfoPacket.h b/Minecraft.World/PlayerInfoPacket.h
index 85e2ed64..7044ffbd 100644
--- a/Minecraft.World/PlayerInfoPacket.h
+++ b/Minecraft.World/PlayerInfoPacket.h
@@ -27,6 +27,6 @@ class PlayerInfoPacket : public Packet, public enable_shared_from_this<PlayerInf
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new PlayerInfoPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<PlayerInfoPacket>(); }
virtual int getId() { return 201; }
}; \ No newline at end of file
diff --git a/Minecraft.World/PlayerInputPacket.h b/Minecraft.World/PlayerInputPacket.h
index bc2d3985..6f1dce47 100644
--- a/Minecraft.World/PlayerInputPacket.h
+++ b/Minecraft.World/PlayerInputPacket.h
@@ -27,6 +27,6 @@ public:
bool isSneaking();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new PlayerInputPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<PlayerInputPacket>(); }
virtual int getId() { return 27; }
}; \ No newline at end of file
diff --git a/Minecraft.World/PlayerTeam.cpp b/Minecraft.World/PlayerTeam.cpp
index 3e159af4..608cb36b 100644
--- a/Minecraft.World/PlayerTeam.cpp
+++ b/Minecraft.World/PlayerTeam.cpp
@@ -77,7 +77,7 @@ wstring PlayerTeam::formatNameForTeam(PlayerTeam *team)
wstring PlayerTeam::formatNameForTeam(Team *team, const wstring &name)
{
- if (team == NULL) return name;
+ if (team == nullptr) return name;
return team->getFormattedName(name);
}
diff --git a/Minecraft.World/PortalForcer.cpp b/Minecraft.World/PortalForcer.cpp
index d0a12988..9695afdf 100644
--- a/Minecraft.World/PortalForcer.cpp
+++ b/Minecraft.World/PortalForcer.cpp
@@ -513,7 +513,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);
diff --git a/Minecraft.World/PortalTile.cpp b/Minecraft.World/PortalTile.cpp
index 5e891e53..5e664e65 100644
--- a/Minecraft.World/PortalTile.cpp
+++ b/Minecraft.World/PortalTile.cpp
@@ -28,7 +28,7 @@ void PortalTile::tick(Level *level, int x, int y, int z, Random *random)
// spawn a pig man here
int iResult = 0;
shared_ptr<Entity> entity = SpawnEggItem::spawnMobAt(level, 57, x + .5, y0 + 1.1, z + .5, &iResult);
- if (entity != NULL)
+ if (entity != nullptr)
{
entity->changingDimensionDelay = entity->getDimensionChangingDelay();
}
@@ -38,7 +38,7 @@ void PortalTile::tick(Level *level, int x, int y, int z, Random *random)
AABB *PortalTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
void PortalTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
@@ -201,7 +201,7 @@ void PortalTile::entityInside(Level *level, int x, int y, int z, shared_ptr<Enti
{
if (entity->GetType() == eTYPE_EXPERIENCEORB ) return; // 4J added
- if (entity->riding == NULL && entity->rider.lock() == NULL) entity->handleInsidePortal();
+ if (entity->riding == nullptr && entity->rider.lock() == nullptr) entity->handleInsidePortal();
}
void PortalTile::animateTick(Level *level, int xt, int yt, int zt, Random *random)
diff --git a/Minecraft.World/Pos.cpp b/Minecraft.World/Pos.cpp
index e673ecc3..d2f25def 100644
--- a/Minecraft.World/Pos.cpp
+++ b/Minecraft.World/Pos.cpp
@@ -28,13 +28,13 @@ Pos::Pos(Pos *position)
bool Pos::equals(void *other)
{
// TODO 4J Stu I cannot do a dynamic_cast from a void pointer
- // If I cast it to a Pos then do a dynamic_cast will it still return NULL if it wasn't originally a Pos?
- if (!( dynamic_cast<Pos *>( (Pos *)other ) != NULL ))
+ // If I cast it to a Pos then do a dynamic_cast will it still return nullptr if it wasn't originally a Pos?
+ if (!( dynamic_cast<Pos *>( static_cast<Pos *>(other) ) != nullptr ))
{
return false;
}
- Pos *p = (Pos *) other;
+ Pos *p = static_cast<Pos *>(other);
return x == p->x && y == p->y && z == p->z;
}
diff --git a/Minecraft.World/PotatoTile.cpp b/Minecraft.World/PotatoTile.cpp
index 872622ba..351c8c98 100644
--- a/Minecraft.World/PotatoTile.cpp
+++ b/Minecraft.World/PotatoTile.cpp
@@ -46,7 +46,7 @@ void PotatoTile::spawnResources(Level *level, int x, int y, int z, int data, flo
{
if (level->random->nextInt(50) == 0)
{
- popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Item::potatoPoisonous)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(Item::potatoPoisonous));
}
}
}
diff --git a/Minecraft.World/PotionBrewing.cpp b/Minecraft.World/PotionBrewing.cpp
index 8e27a601..bc5fd8c7 100644
--- a/Minecraft.World/PotionBrewing.cpp
+++ b/Minecraft.World/PotionBrewing.cpp
@@ -186,7 +186,7 @@ int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
int baseColor = colourTable->getColor( eMinecraftColour_Potion_BaseColour );
- if (effects == NULL || effects->empty())
+ if (effects == nullptr || effects->empty())
{
return baseColor;
}
@@ -203,9 +203,9 @@ int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
for (int potency = 0; potency <= effect->getAmplifier(); potency++)
{
- red += (float) ((potionColor >> 16) & 0xff) / 255.0f;
- green += (float) ((potionColor >> 8) & 0xff) / 255.0f;
- blue += (float) ((potionColor >> 0) & 0xff) / 255.0f;
+ red += static_cast<float>((potionColor >> 16) & 0xff) / 255.0f;
+ green += static_cast<float>((potionColor >> 8) & 0xff) / 255.0f;
+ blue += static_cast<float>((potionColor >> 0) & 0xff) / 255.0f;
count++;
}
}
@@ -214,7 +214,7 @@ int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
green = (green / count) * 255.0f;
blue = (blue / count) * 255.0f;
- return ((int) red) << 16 | ((int) green) << 8 | ((int) blue);
+ return static_cast<int>(red) << 16 | static_cast<int>(green) << 8 | static_cast<int>(blue);
}
bool PotionBrewing::areAllEffectsAmbient(vector<MobEffectInstance *> *effects)
@@ -238,7 +238,7 @@ int PotionBrewing::getColorValue(int brew, bool includeDisabledEffects)
}
vector<MobEffectInstance *> *effects = getEffects(brew, false);
int color = getColorValue(effects);
- if(effects != NULL)
+ if(effects != nullptr)
{
for(auto& effect : *effects)
{
@@ -325,16 +325,16 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start,
}
// split by and
- int andIndex = (int)definition.find_first_of(L'&', start);
- if (andIndex >= 0 && andIndex < end)
+ size_t andIndex = definition.find_first_of(L'&', start);
+ if (andIndex != wstring::npos && andIndex < static_cast<size_t>(end))
{
- int leftSide = parseEffectFormulaValue(definition, start, andIndex - 1, brew);
+ int leftSide = parseEffectFormulaValue(definition, start, static_cast<int>(andIndex) - 1, brew);
if (leftSide <= 0)
{
return 0;
}
- int rightSide = parseEffectFormulaValue(definition, andIndex + 1, end, brew);
+ int rightSide = parseEffectFormulaValue(definition, static_cast<int>(andIndex) + 1, end, brew);
if (rightSide <= 0)
{
return 0;
@@ -413,16 +413,16 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start,
}
// split by or
- int orIndex = definition.find_first_of(L'|', start);
- if (orIndex >= 0 && orIndex < end)
+ size_t orIndex = definition.find_first_of(L'|', start);
+ if (orIndex != wstring::npos && orIndex < static_cast<size_t>(end))
{
- int leftSide = parseEffectFormulaValue(definition, start, orIndex - 1, brew);
+ int leftSide = parseEffectFormulaValue(definition, start, static_cast<int>(orIndex) - 1, brew);
if (leftSide > 0)
{
return leftSide;
}
- int rightSide = parseEffectFormulaValue(definition, orIndex + 1, end, brew);
+ int rightSide = parseEffectFormulaValue(definition, static_cast<int>(orIndex) + 1, end, brew);
if (rightSide > 0)
{
return rightSide;
@@ -430,10 +430,10 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start,
return 0;
}
// split by and
- int andIndex = definition.find_first_of(L'&', start);
- if (andIndex >= 0 && andIndex < end)
+ size_t andIndex = definition.find_first_of(L'&', start);
+ if (andIndex != wstring::npos && andIndex < static_cast<size_t>(end))
{
- int leftSide = parseEffectFormulaValue(definition, start, andIndex - 1, brew);
+ int leftSide = parseEffectFormulaValue(definition, start, static_cast<int>(andIndex) - 1, brew);
if (leftSide <= 0)
{
return 0;
@@ -552,13 +552,13 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start,
vector<MobEffectInstance *> *PotionBrewing::getEffects(int brew, bool includeDisabledEffects)
{
- vector<MobEffectInstance *> *list = NULL;
+ vector<MobEffectInstance *> *list = nullptr;
//for (MobEffect effect : MobEffect.effects)
for(unsigned int i = 0; i < MobEffect::NUM_EFFECTS; ++i)
{
MobEffect *effect = MobEffect::effects[i];
- if (effect == NULL || (effect->isDisabled() && !includeDisabledEffects))
+ if (effect == nullptr || (effect->isDisabled() && !includeDisabledEffects))
{
continue;
}
@@ -570,7 +570,7 @@ vector<MobEffectInstance *> *PotionBrewing::getEffects(int brew, bool includeDis
}
wstring durationString = effIt->second;
- int duration = parseEffectFormulaValue(durationString, 0, (int)durationString.length(), brew);
+ int duration = parseEffectFormulaValue(durationString, 0, static_cast<int>(durationString.length()), brew);
if (duration > 0)
{
int amplifier = 0;
@@ -578,7 +578,7 @@ vector<MobEffectInstance *> *PotionBrewing::getEffects(int brew, bool includeDis
if (ampIt != potionEffectAmplifier.end())
{
wstring amplifierString = ampIt->second;
- amplifier = parseEffectFormulaValue(amplifierString, 0, (int)amplifierString.length(), brew);
+ amplifier = parseEffectFormulaValue(amplifierString, 0, static_cast<int>(amplifierString.length()), brew);
if (amplifier < 0)
{
amplifier = 0;
@@ -594,15 +594,15 @@ vector<MobEffectInstance *> *PotionBrewing::getEffects(int brew, bool includeDis
// 3, 8, 13, 18.. minutes
duration = (SharedConstants::TICKS_PER_SECOND * 60) * (duration * 3 + (duration - 1) * 2);
duration >>= amplifier;
- duration = (int) Math::round((double) duration * effect->getDurationModifier());
+ duration = static_cast<int>(Math::round((double)duration * effect->getDurationModifier()));
if ((brew & THROWABLE_MASK) != 0)
{
- duration = (int) Math::round((double) duration * .75 + .5);
+ duration = static_cast<int>(Math::round((double)duration * .75 + .5));
}
}
- if (list == NULL)
+ if (list == nullptr)
{
list = new vector<MobEffectInstance *>();
}
@@ -756,7 +756,7 @@ int PotionBrewing::applyBrew(int currentBrew, const wstring &formula)
{
int start = 0;
- int end = (int)formula.length();
+ int end = static_cast<int>(formula.length());
bool hasValue = false;
bool isNot = false;
diff --git a/Minecraft.World/PotionItem.cpp b/Minecraft.World/PotionItem.cpp
index fd8937bf..fd156883 100644
--- a/Minecraft.World/PotionItem.cpp
+++ b/Minecraft.World/PotionItem.cpp
@@ -26,26 +26,26 @@ PotionItem::PotionItem(int id) : Item(id)
setStackedByData(true);
setMaxDamage(0);
- iconThrowable = NULL;
- iconDrinkable = NULL;
- iconOverlay = NULL;
+ iconThrowable = nullptr;
+ iconDrinkable = nullptr;
+ iconOverlay = nullptr;
}
vector<MobEffectInstance *> *PotionItem::getMobEffects(shared_ptr<ItemInstance> potion)
{
if (!potion->hasTag() || !potion->getTag()->contains(L"CustomPotionEffects"))
{
- vector<MobEffectInstance *> *effects = NULL;
+ vector<MobEffectInstance *> *effects = nullptr;
auto it = cachedMobEffects.find(potion->getAuxValue());
if(it != cachedMobEffects.end()) effects = it->second;
- if (effects == NULL)
+ if (effects == nullptr)
{
effects = PotionBrewing::getEffects(potion->getAuxValue(), false);
cachedMobEffects[potion->getAuxValue()] = effects;
}
// Result should be a new (unmanaged) vector, so create a new one
- return effects == NULL ? NULL : new vector<MobEffectInstance *>(*effects);
+ return effects == nullptr ? nullptr : new vector<MobEffectInstance *>(*effects);
}
else
{
@@ -64,13 +64,13 @@ vector<MobEffectInstance *> *PotionItem::getMobEffects(shared_ptr<ItemInstance>
vector<MobEffectInstance *> *PotionItem::getMobEffects(int auxValue)
{
- vector<MobEffectInstance *> *effects = NULL;
+ vector<MobEffectInstance *> *effects = nullptr;
auto it = cachedMobEffects.find(auxValue);
if(it != cachedMobEffects.end()) effects = it->second;
- if (effects == NULL)
+ if (effects == nullptr)
{
effects = PotionBrewing::getEffects(auxValue, false);
- if(effects != NULL) cachedMobEffects.insert( std::pair<int, vector<MobEffectInstance *> *>(auxValue, effects) );
+ if(effects != nullptr) cachedMobEffects.insert( std::pair<int, vector<MobEffectInstance *> *>(auxValue, effects) );
}
return effects;
}
@@ -82,7 +82,7 @@ shared_ptr<ItemInstance> PotionItem::useTimeDepleted(shared_ptr<ItemInstance> in
if (!level->isClientSide)
{
vector<MobEffectInstance *> *effects = getMobEffects(instance);
- if (effects != NULL)
+ if (effects != nullptr)
{
for(auto& effect : *effects)
{
@@ -94,11 +94,11 @@ shared_ptr<ItemInstance> PotionItem::useTimeDepleted(shared_ptr<ItemInstance> in
{
if (instance->count <= 0)
{
- return shared_ptr<ItemInstance>( new ItemInstance(Item::glassBottle) );
+ return std::make_shared<ItemInstance>(Item::glassBottle);
}
else
{
- player->inventory->add( shared_ptr<ItemInstance>( new ItemInstance(Item::glassBottle) ) );
+ player->inventory->add(std::make_shared<ItemInstance>(Item::glassBottle));
}
}
@@ -126,7 +126,7 @@ shared_ptr<ItemInstance> PotionItem::use(shared_ptr<ItemInstance> instance, Leve
{
if (!player->abilities.instabuild) instance->count--;
level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f));
- if (!level->isClientSide) level->addEntity(shared_ptr<ThrownPotion>( new ThrownPotion(level, player, instance->getAuxValue()) ));
+ if (!level->isClientSide) level->addEntity(std::make_shared<ThrownPotion>(level, player, instance->getAuxValue()));
return instance;
}
player->startUsingItem(instance, getUseDuration(instance));
@@ -183,7 +183,7 @@ bool PotionItem::hasMultipleSpriteLayers()
bool PotionItem::hasInstantenousEffects(int itemAuxValue)
{
vector<MobEffectInstance *> *mobEffects = getMobEffects(itemAuxValue);
- if (mobEffects == NULL || mobEffects->empty())
+ if (mobEffects == nullptr || mobEffects->empty())
{
return false;
}
@@ -216,7 +216,7 @@ wstring PotionItem::getHoverName(shared_ptr<ItemInstance> itemInstance)
}
vector<MobEffectInstance *> *effects = ((PotionItem *) Item::potion)->getMobEffects(itemInstance);
- if (effects != NULL && !effects->empty())
+ if (effects != nullptr && !effects->empty())
{
//String postfixString = effects.get(0).getDescriptionId();
//postfixString += ".postfix";
@@ -244,7 +244,7 @@ void PotionItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, shared_p
}
vector<MobEffectInstance *> *effects = ((PotionItem *) Item::potion)->getMobEffects(itemInstance);
attrAttrModMap modifiers;
- if (effects != NULL && !effects->empty())
+ if (effects != nullptr && !effects->empty())
{
//for (MobEffectInstance effect : effects)
for(auto& effect : *effects)
@@ -254,7 +254,7 @@ void PotionItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, shared_p
MobEffect *mobEffect = MobEffect::effects[effect->getId()];
unordered_map<Attribute*, AttributeModifier*> *effectModifiers = mobEffect->getAttributeModifiers();
- if (effectModifiers != NULL && effectModifiers->size() > 0)
+ if (effectModifiers != nullptr && effectModifiers->size() > 0)
{
for(auto& it : *effectModifiers)
{
@@ -335,7 +335,7 @@ void PotionItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, shared_p
bool PotionItem::isFoil(shared_ptr<ItemInstance> itemInstance)
{
vector<MobEffectInstance *> *mobEffects = getMobEffects(itemInstance);
- return mobEffects != NULL && !mobEffects->empty();
+ return mobEffects != nullptr && !mobEffects->empty();
}
unsigned int PotionItem::getUseDescriptionId(shared_ptr<ItemInstance> instance)
@@ -368,7 +368,7 @@ Icon *PotionItem::getTexture(const wstring &name)
if (name.compare(DEFAULT_ICON) == 0) return Item::potion->iconDrinkable;
if (name.compare(THROWABLE_ICON) == 0) return Item::potion->iconThrowable;
if (name.compare(CONTENTS_ICON) == 0) return Item::potion->iconOverlay;
- return NULL;
+ return nullptr;
}
@@ -381,7 +381,7 @@ vector<pair<int, int> > *PotionItem::getUniquePotionValues()
{
vector<MobEffectInstance *> *effects = PotionBrewing::getEffects(brew, false);
- if (effects != NULL)
+ if (effects != nullptr)
{
if(!effects->empty())
{
diff --git a/Minecraft.World/PotionItem.h b/Minecraft.World/PotionItem.h
index 9fa158c2..4a43505f 100644
--- a/Minecraft.World/PotionItem.h
+++ b/Minecraft.World/PotionItem.h
@@ -7,7 +7,7 @@ class MobEffectInstance;
class PotionItem : public Item
{
private:
- static const int DRINK_DURATION = (int) (20 * 1.6);
+ static const int DRINK_DURATION = static_cast<int>(20 * 1.6);
public:
static const wstring DEFAULT_ICON;
diff --git a/Minecraft.World/PreLoginPacket.cpp b/Minecraft.World/PreLoginPacket.cpp
index 4b474214..aa6832ca 100644
--- a/Minecraft.World/PreLoginPacket.cpp
+++ b/Minecraft.World/PreLoginPacket.cpp
@@ -9,7 +9,7 @@
PreLoginPacket::PreLoginPacket()
{
loginKey = L"";
- m_playerXuids = NULL;
+ m_playerXuids = nullptr;
m_dwPlayerCount = 0;
m_friendsOnlyBits = 0;
m_ugcPlayersVersion = 0;
@@ -23,7 +23,7 @@ PreLoginPacket::PreLoginPacket()
PreLoginPacket::PreLoginPacket(wstring userName)
{
this->loginKey = userName;
- m_playerXuids = NULL;
+ m_playerXuids = nullptr;
m_dwPlayerCount = 0;
m_friendsOnlyBits = 0;
m_ugcPlayersVersion = 0;
@@ -50,7 +50,7 @@ PreLoginPacket::PreLoginPacket(wstring userName, PlayerUID *playerXuids, DWORD p
PreLoginPacket::~PreLoginPacket()
{
- if( m_playerXuids != NULL ) delete [] m_playerXuids;
+ if( m_playerXuids != nullptr ) delete [] m_playerXuids;
}
void PreLoginPacket::read(DataInputStream *dis) //throws IOException
@@ -92,7 +92,7 @@ void PreLoginPacket::write(DataOutputStream *dos) //throws IOException
dos->writeByte(m_friendsOnlyBits);
dos->writeInt(m_ugcPlayersVersion);
- dos->writeByte((byte)m_dwPlayerCount);
+ dos->writeByte(static_cast<byte>(m_dwPlayerCount));
for(DWORD i = 0; i < m_dwPlayerCount; ++i)
{
dos->writePlayerUID( m_playerXuids[i] );
@@ -115,5 +115,5 @@ void PreLoginPacket::handle(PacketListener *listener)
int PreLoginPacket::getEstimatedSize()
{
- return 4 + 4 + (int)loginKey.length() + 4 +14 + 4 + 1 + 4;
+ return 4 + 4 + static_cast<int>(loginKey.length()) + 4 +14 + 4 + 1 + 4;
}
diff --git a/Minecraft.World/PreLoginPacket.h b/Minecraft.World/PreLoginPacket.h
index 243f2f36..b0935d0a 100644
--- a/Minecraft.World/PreLoginPacket.h
+++ b/Minecraft.World/PreLoginPacket.h
@@ -34,6 +34,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new PreLoginPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<PreLoginPacket>(); }
virtual int getId() { return 2; }
}; \ No newline at end of file
diff --git a/Minecraft.World/PressurePlateTile.cpp b/Minecraft.World/PressurePlateTile.cpp
index beed308a..650fbf9f 100644
--- a/Minecraft.World/PressurePlateTile.cpp
+++ b/Minecraft.World/PressurePlateTile.cpp
@@ -23,14 +23,14 @@ int PressurePlateTile::getSignalForData(int data)
int PressurePlateTile::getSignalStrength(Level *level, int x, int y, int z)
{
- vector< shared_ptr<Entity> > *entities = NULL;
+ vector< shared_ptr<Entity> > *entities = nullptr;
if (sensitivity == everything) entities = level->getEntities(nullptr, getSensitiveAABB(x, y, z));
else if (sensitivity == mobs) entities = level->getEntitiesOfClass(typeid(LivingEntity), getSensitiveAABB(x, y, z));
else if (sensitivity == players) entities = level->getEntitiesOfClass(typeid(Player), getSensitiveAABB(x, y, z));
else __debugbreak(); // 4J-JEV: We're going to delete something at a random location.
- if (entities != NULL && !entities->empty())
+ if (entities != nullptr && !entities->empty())
{
for (auto& e : *entities)
{
diff --git a/Minecraft.World/PrimedTnt.cpp b/Minecraft.World/PrimedTnt.cpp
index 79fd760f..39b3ea73 100644
--- a/Minecraft.World/PrimedTnt.cpp
+++ b/Minecraft.World/PrimedTnt.cpp
@@ -33,7 +33,7 @@ PrimedTnt::PrimedTnt(Level *level, double x, double y, double z, shared_ptr<Livi
setPos(x, y, z);
- float rot = (float) (Math::random() * PI * 2);
+ float rot = static_cast<float>(Math::random() * PI * 2);
xd = -sin(rot) * 0.02f;
yd = +0.2f;
zd = -cos(rot) * 0.02f;
@@ -105,7 +105,7 @@ void PrimedTnt::explode()
void PrimedTnt::addAdditonalSaveData(CompoundTag *entityTag)
{
- entityTag->putByte(L"Fuse", (byte) life);
+ entityTag->putByte(L"Fuse", static_cast<byte>(life));
}
void PrimedTnt::readAdditionalSaveData(CompoundTag *tag)
diff --git a/Minecraft.World/ProtectionEnchantment.cpp b/Minecraft.World/ProtectionEnchantment.cpp
index 8304529b..13a6836c 100644
--- a/Minecraft.World/ProtectionEnchantment.cpp
+++ b/Minecraft.World/ProtectionEnchantment.cpp
@@ -54,7 +54,7 @@ int ProtectionEnchantment::getDescriptionId()
bool ProtectionEnchantment::isCompatibleWith(Enchantment *other) const
{
ProtectionEnchantment *pe = dynamic_cast<ProtectionEnchantment *>( other );
- if (pe != NULL)
+ if (pe != nullptr)
{
if (pe->type == type)
{
diff --git a/Minecraft.World/PumpkinTile.cpp b/Minecraft.World/PumpkinTile.cpp
index 2bc36972..da11001d 100644
--- a/Minecraft.World/PumpkinTile.cpp
+++ b/Minecraft.World/PumpkinTile.cpp
@@ -13,8 +13,8 @@ const wstring PumpkinTile::TEXTURE_LANTERN = L"pumpkin_jack";
PumpkinTile::PumpkinTile(int id, bool lit) : DirectionalTile(id, Material::vegetable, isSolidRender() )
{
- iconTop = NULL;
- iconFace = NULL;
+ iconTop = nullptr;
+ iconFace = nullptr;
setTicking(true);
this->lit = lit;
}
@@ -45,7 +45,7 @@ void PumpkinTile::onPlace(Level *level, int x, int y, int z)
level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_CLIENTS);
level->setTileAndData(x, y - 1, z, 0, 0, Tile::UPDATE_CLIENTS);
level->setTileAndData(x, y - 2, z, 0, 0, Tile::UPDATE_CLIENTS);
- shared_ptr<SnowMan> snowMan = shared_ptr<SnowMan>(new SnowMan(level));
+ shared_ptr<SnowMan> snowMan = std::make_shared<SnowMan>(level);
snowMan->moveTo(x + 0.5, y - 1.95, z + 0.5, 0, 0);
level->addEntity(snowMan);
@@ -94,7 +94,7 @@ void PumpkinTile::onPlace(Level *level, int x, int y, int z)
level->setTileAndData(x, y - 1, z + 1, 0, 0, Tile::UPDATE_CLIENTS);
}
- shared_ptr<VillagerGolem> villagerGolem = shared_ptr<VillagerGolem>(new VillagerGolem(level));
+ shared_ptr<VillagerGolem> villagerGolem = std::make_shared<VillagerGolem>(level);
villagerGolem->setPlayerCreated(true);
villagerGolem->moveTo(x + 0.5, y - 1.95, z + 0.5, 0, 0);
level->addEntity(villagerGolem);
diff --git a/Minecraft.World/QuartzBlockTile.cpp b/Minecraft.World/QuartzBlockTile.cpp
index 709e0c1e..d0ab02d2 100644
--- a/Minecraft.World/QuartzBlockTile.cpp
+++ b/Minecraft.World/QuartzBlockTile.cpp
@@ -91,7 +91,7 @@ int QuartzBlockTile::getSpawnResourcesAuxValue(int data)
shared_ptr<ItemInstance> QuartzBlockTile::getSilkTouchItemInstance(int data)
{
- if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return shared_ptr<ItemInstance>(new ItemInstance(id, 1, TYPE_LINES_Y));
+ if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return std::make_shared<ItemInstance>(id, 1, TYPE_LINES_Y);
return Tile::getSilkTouchItemInstance(data);
}
diff --git a/Minecraft.World/Random.cpp b/Minecraft.World/Random.cpp
index d4e3a545..89903da8 100644
--- a/Minecraft.World/Random.cpp
+++ b/Minecraft.World/Random.cpp
@@ -27,22 +27,22 @@ void Random::setSeed(int64_t s)
int Random::next(int bits)
{
seed = (seed * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1);
- return (int)(seed >> (48 - bits));
+ return static_cast<int>(seed >> (48 - bits));
}
void Random::nextBytes(byte *bytes, unsigned int count)
{
for(unsigned int i = 0; i < count; i++ )
{
- bytes[i] = (byte)next(8);
+ bytes[i] = static_cast<byte>(next(8));
}
}
double Random::nextDouble()
{
- return (((int64_t)next(26) << 27) + next(27))
- / (double)(1LL << 53);
+ return ((static_cast<int64_t>(next(26)) << 27) + next(27))
+ / static_cast<double>(1LL << 53);
}
double Random::nextGaussian()
@@ -79,7 +79,7 @@ int Random::nextInt(int n)
if ((n & -n) == n) // i.e., n is a power of 2
- return (int)(((int64_t)next(31) * n) >> 31); // 4J Stu - Made int64_t instead of long
+ return static_cast<int>((static_cast<int64_t>(next(31)) * n) >> 31); // 4J Stu - Made int64_t instead of long
int bits, val;
do
@@ -92,12 +92,12 @@ int Random::nextInt(int n)
float Random::nextFloat()
{
- return next(24) / ((float)(1 << 24));
+ return next(24) / static_cast<float>(1 << 24);
}
int64_t Random::nextLong()
{
- return ((int64_t)next(32) << 32) + next(32);
+ return (static_cast<int64_t>(next(32)) << 32) + next(32);
}
bool Random::nextBoolean()
diff --git a/Minecraft.World/RandomLevelSource.cpp b/Minecraft.World/RandomLevelSource.cpp
index ae06c1f8..a0e7a94b 100644
--- a/Minecraft.World/RandomLevelSource.cpp
+++ b/Minecraft.World/RandomLevelSource.cpp
@@ -58,8 +58,8 @@ RandomLevelSource::RandomLevelSource(Level *level, int64_t seed, bool generateSt
}
else
{
- floatingIslandScale = NULL;
- floatingIslandNoise = NULL;
+ floatingIslandScale = nullptr;
+ floatingIslandNoise = nullptr;
}
forestNoise = new PerlinNoise(random, 8);
@@ -93,7 +93,7 @@ RandomLevelSource::~RandomLevelSource()
delete forestNoise;
- if( pows.data != NULL ) delete [] pows.data;
+ if( pows.data != nullptr ) delete [] pows.data;
}
@@ -187,7 +187,7 @@ float RandomLevelSource::getHeightFalloff(int xxx, int zzz, int* pEMin)
if( emin < falloffStart )
{
int falloff = falloffStart - emin;
- comp = ((float)falloff / (float)falloffStart ) * falloffMax;
+ comp = (static_cast<float>(falloff) / static_cast<float>(falloffStart) ) * falloffMax;
}
*pEMin = emin;
return comp;
@@ -267,7 +267,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
{
for (int yc = 0; yc < yChunks; yc++)
{
- double yStep = 1 / (double) CHUNK_HEIGHT;
+ double yStep = 1 / static_cast<double>(CHUNK_HEIGHT);
double s0 = buffer[((xc + 0) * zSize + (zc + 0)) * ySize + (yc + 0)];
double s1 = buffer[((xc + 0) * zSize + (zc + 1)) * ySize + (yc + 0)];
double s2 = buffer[((xc + 1) * zSize + (zc + 0)) * ySize + (yc + 0)];
@@ -280,7 +280,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
for (int y = 0; y < CHUNK_HEIGHT; y++)
{
- double xStep = 1 / (double) CHUNK_WIDTH;
+ double xStep = 1 / static_cast<double>(CHUNK_WIDTH);
double _s0 = s0;
double _s1 = s1;
@@ -292,7 +292,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
int offs = (x + xc * CHUNK_WIDTH) << Level::genDepthBitsPlusFour | (0 + zc * CHUNK_WIDTH) << Level::genDepthBits | (yc * CHUNK_HEIGHT + y);
int step = 1 << Level::genDepthBits;
offs -= step;
- double zStep = 1 / (double) CHUNK_WIDTH;
+ double zStep = 1 / static_cast<double>(CHUNK_WIDTH);
double val = _s0;
double vala = (_s1 - _s0) * zStep;
@@ -315,11 +315,11 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
// 4J - this comparison used to just be with 0.0f but is now varied by block above
if ((val += vala) > comp)
{
- tileId = (byte) Tile::stone_Id;
+ tileId = static_cast<byte>(Tile::stone_Id);
}
else if (yc * CHUNK_HEIGHT + y < waterHeight)
{
- tileId = (byte) Tile::calmWater_Id;
+ tileId = static_cast<byte>(Tile::calmWater_Id);
}
// 4J - more extra code to make sure that the column at the edge of the world is just water & rock, to match the infinite sea that
@@ -377,7 +377,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
{
Biome *b = biomes[z + x * 16];
float temp = b->getTemperature();
- int runDepth = (int) (depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25);
+ int runDepth = static_cast<int>(depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25);
int run = -1;
@@ -385,7 +385,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
byte material = b->material;
LevelGenerationOptions *lgo = app.getLevelGenerationOptions();
- if(lgo != NULL)
+ if(lgo != nullptr)
{
lgo->getBiomeOverride(b->id,material,top);
}
@@ -397,7 +397,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (y <= 1 + random->nextInt(2)) // 4J - changed to make the bedrock not have bits you can get stuck in
// if (y <= 0 + random->nextInt(5))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
+ blocks[offs] = static_cast<byte>(Tile::unbreakable_Id);
}
else
{
@@ -414,13 +414,13 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (runDepth <= 0)
{
top = 0;
- material = (byte) Tile::stone_Id;
+ material = static_cast<byte>(Tile::stone_Id);
}
else if (y >= waterHeight - 4 && y <= waterHeight + 1)
{
top = b->topMaterial;
material = b->material;
- if(lgo != NULL)
+ if(lgo != nullptr)
{
lgo->getBiomeOverride(b->id,material,top);
}
@@ -428,8 +428,8 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (y < waterHeight && top == 0)
{
- if (temp < 0.15f) top = (byte) Tile::ice_Id;
- else top = (byte) Tile::calmWater_Id;
+ if (temp < 0.15f) top = static_cast<byte>(Tile::ice_Id);
+ else top = static_cast<byte>(Tile::calmWater_Id);
}
run = runDepth;
@@ -445,7 +445,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (run == 0 && material == Tile::sand_Id)
{
run = random->nextInt(4);
- material = (byte) Tile::sandStone_Id;
+ material = static_cast<byte>(Tile::sandStone_Id);
}
}
}
@@ -469,7 +469,7 @@ LevelChunk *RandomLevelSource::getChunk(int xOffs, int zOffs)
// 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed
int blocksSize = Level::genDepth * 16 * 16;
- byte *tileData = (byte *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
+ byte *tileData = static_cast<byte *>(XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE));
XMemSet128(tileData,0,blocksSize);
byteArray blocks = byteArray(tileData,blocksSize);
// byteArray blocks = byteArray(16 * level->depth * 16);
@@ -525,11 +525,11 @@ void RandomLevelSource::lightChunk(LevelChunk *lc)
doubleArray RandomLevelSource::getHeights(doubleArray buffer, int x, int y, int z, int xSize, int ySize, int zSize, BiomeArray& biomes)
{
- if (buffer.data == NULL)
+ if (buffer.data == nullptr)
{
buffer = doubleArray(xSize * ySize * zSize);
}
- if (pows.data == NULL)
+ if (pows.data == nullptr)
{
pows = floatArray(5 * 5);
for (int xb = -2; xb <= 2; xb++)
@@ -882,9 +882,9 @@ wstring RandomLevelSource::gatherStats()
vector<Biome::MobSpawnerData *> *RandomLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
{
Biome *biome = level->getBiome(x, z);
- if (biome == NULL)
+ if (biome == nullptr)
{
- return NULL;
+ return nullptr;
}
if (mobCategory == MobCategory::monster && scatteredFeature->isSwamphut(x, y, z))
{
@@ -895,20 +895,20 @@ vector<Biome::MobSpawnerData *> *RandomLevelSource::getMobsAt(MobCategory *mobCa
TilePos *RandomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
{
- if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != NULL)
+ if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != nullptr)
{
return strongholdFeature->getNearestGeneratedFeature(level, x, y, z);
}
- return NULL;
+ return nullptr;
}
void RandomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ)
{
if (generateStructures)
{
- mineShaftFeature->apply(this, level, chunkX, chunkZ, NULL);
- villageFeature->apply(this, level, chunkX, chunkZ, NULL);
- strongholdFeature->apply(this, level, chunkX, chunkZ, NULL);
- scatteredFeature->apply(this, level, chunkX, chunkZ, NULL);
+ mineShaftFeature->apply(this, level, chunkX, chunkZ, byteArray());
+ villageFeature->apply(this, level, chunkX, chunkZ, byteArray());
+ strongholdFeature->apply(this, level, chunkX, chunkZ, byteArray());
+ scatteredFeature->apply(this, level, chunkX, chunkZ, byteArray());
}
} \ No newline at end of file
diff --git a/Minecraft.World/RandomPos.cpp b/Minecraft.World/RandomPos.cpp
index c2cfd908..1a86800e 100644
--- a/Minecraft.World/RandomPos.cpp
+++ b/Minecraft.World/RandomPos.cpp
@@ -7,7 +7,7 @@ Vec3 *RandomPos::tempDir = Vec3::newPermanent(0, 0, 0);
Vec3 *RandomPos::getPos(shared_ptr<PathfinderMob> mob, int xzDist, int yDist, int quadrant/*=-1*/) // 4J - added quadrant
{
- return generateRandomPos(mob, xzDist, yDist, NULL, quadrant);
+ return generateRandomPos(mob, xzDist, yDist, nullptr, quadrant);
}
Vec3 *RandomPos::getPosTowards(shared_ptr<PathfinderMob> mob, int xzDist, int yDist, Vec3 *towardsPos)
@@ -62,7 +62,7 @@ Vec3 *RandomPos::generateRandomPos(shared_ptr<PathfinderMob> mob, int xzDist, in
}
yt = random->nextInt(2 * yDist) - yDist;
- if (dir != NULL && xt * dir->x + zt * dir->z < 0) continue;
+ if (dir != nullptr && xt * dir->x + zt * dir->z < 0) continue;
xt += Mth::floor(mob->x);
yt += Mth::floor(mob->y);
@@ -84,5 +84,5 @@ Vec3 *RandomPos::generateRandomPos(shared_ptr<PathfinderMob> mob, int xzDist, in
return Vec3::newTemp(xBest, yBest, zBest);
}
- return NULL;
+ return nullptr;
} \ No newline at end of file
diff --git a/Minecraft.World/RandomScatteredLargeFeature.cpp b/Minecraft.World/RandomScatteredLargeFeature.cpp
index bd0b70bb..3b03dba6 100644
--- a/Minecraft.World/RandomScatteredLargeFeature.cpp
+++ b/Minecraft.World/RandomScatteredLargeFeature.cpp
@@ -67,7 +67,7 @@ bool RandomScatteredLargeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat
bool forcePlacement = false;
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
- if( levelGenOptions != NULL )
+ if( levelGenOptions != nullptr )
{
forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Temples);
}
@@ -123,14 +123,14 @@ RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart(Level
bool RandomScatteredLargeFeature::isSwamphut(int cellX, int cellY, int cellZ)
{
StructureStart *structureAt = getStructureAt(cellX, cellY, cellZ);
- if (structureAt == NULL || !( dynamic_cast<ScatteredFeatureStart *>( structureAt ) ) || structureAt->pieces.empty())
+ if (structureAt == nullptr || !( dynamic_cast<ScatteredFeatureStart *>( structureAt ) ) || structureAt->pieces.empty())
{
return false;
}
- StructurePiece *first = NULL;
+ StructurePiece *first = nullptr;
auto it = structureAt->pieces.begin();
if(it != structureAt->pieces.end() ) first = *it;
- return dynamic_cast<ScatteredFeaturePieces::SwamplandHut *>(first) != NULL;
+ return dynamic_cast<ScatteredFeaturePieces::SwamplandHut *>(first) != nullptr;
}
vector<Biome::MobSpawnerData *> *RandomScatteredLargeFeature::getSwamphutEnemies()
diff --git a/Minecraft.World/RandomStrollGoal.cpp b/Minecraft.World/RandomStrollGoal.cpp
index 15957ab3..4eb5815d 100644
--- a/Minecraft.World/RandomStrollGoal.cpp
+++ b/Minecraft.World/RandomStrollGoal.cpp
@@ -22,7 +22,7 @@ bool RandomStrollGoal::canUse()
if (mob->getRandom()->nextInt(120) == 0)
{
Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10, 7);
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
wantedX = pos->x;
wantedY = pos->y;
wantedZ = pos->z;
@@ -38,7 +38,7 @@ bool RandomStrollGoal::canUse()
if( mob->isExtraWanderingEnabled() )
{
Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10, 7,mob->getWanderingQuadrant());
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
wantedX = pos->x;
wantedY = pos->y;
wantedZ = pos->z;
diff --git a/Minecraft.World/RangedAttackGoal.cpp b/Minecraft.World/RangedAttackGoal.cpp
index 2923e011..72178d9d 100644
--- a/Minecraft.World/RangedAttackGoal.cpp
+++ b/Minecraft.World/RangedAttackGoal.cpp
@@ -40,7 +40,7 @@ RangedAttackGoal::RangedAttackGoal(RangedAttackMob *rangedMob, Mob *mob, double
bool RangedAttackGoal::canUse()
{
shared_ptr<LivingEntity> bestTarget = mob->getTarget();
- if (bestTarget == NULL) return false;
+ if (bestTarget == nullptr) return false;
target = weak_ptr<LivingEntity>(bestTarget);
return true;
}
@@ -60,7 +60,7 @@ void RangedAttackGoal::stop()
void RangedAttackGoal::tick()
{
// 4J: It's possible the target has gone since canUse selected it, don't do tick if target is null
- if (target.lock() == NULL) return;
+ if (target.lock() == nullptr) return;
double targetDistSqr = mob->distanceToSqr(target.lock()->x, target.lock()->bb->y0, target.lock()->z);
bool canSee = mob->getSensing()->canSee(target.lock());
diff --git a/Minecraft.World/ReadOnlyChunkCache.cpp b/Minecraft.World/ReadOnlyChunkCache.cpp
index fdab13dc..dfafdf2d 100644
--- a/Minecraft.World/ReadOnlyChunkCache.cpp
+++ b/Minecraft.World/ReadOnlyChunkCache.cpp
@@ -25,7 +25,7 @@ ReadOnlyChunkCache::~ReadOnlyChunkCache()
bool ReadOnlyChunkCache::hasChunk(int x, int z)
{
int slot = (x & LEN_MASK) | ((z & LEN_MASK) * LEN);
- return chunks[slot] != NULL && (chunks[slot]->isAt(x, z));
+ return chunks[slot] != nullptr && (chunks[slot]->isAt(x, z));
}
LevelChunk *ReadOnlyChunkCache::create(int x, int z)
@@ -41,7 +41,7 @@ LevelChunk *ReadOnlyChunkCache::getChunk(int x, int z)
if (!hasChunk(x, z))
{
LevelChunk *newChunk = load(x, z);
- if (newChunk == NULL)
+ if (newChunk == nullptr)
{
newChunk = new EmptyLevelChunk(level, emptyPixels, x, z);
}
@@ -91,10 +91,10 @@ wstring ReadOnlyChunkCache::gatherStats()
vector<Biome::MobSpawnerData *> *ReadOnlyChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
TilePos *ReadOnlyChunkCache::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
diff --git a/Minecraft.World/Recipes.cpp b/Minecraft.World/Recipes.cpp
index ce026359..24faaebe 100644
--- a/Minecraft.World/Recipes.cpp
+++ b/Minecraft.World/Recipes.cpp
@@ -8,15 +8,15 @@
#include "net.minecraft.world.level.tile.h"
#include "net.minecraft.world.item.crafting.h"
-Recipes *Recipes::instance = NULL;
-ArmorRecipes *Recipes::pArmorRecipes=NULL;
-ClothDyeRecipes *Recipes::pClothDyeRecipes=NULL;
-FoodRecipies *Recipes::pFoodRecipies=NULL;
-OreRecipies *Recipes::pOreRecipies=NULL;
-StructureRecipies *Recipes::pStructureRecipies=NULL;
-ToolRecipies *Recipes::pToolRecipies=NULL;
-WeaponRecipies *Recipes::pWeaponRecipies=NULL;
-FireworksRecipe *Recipes::pFireworksRecipes=NULL;
+Recipes *Recipes::instance = nullptr;
+ArmorRecipes *Recipes::pArmorRecipes=nullptr;
+ClothDyeRecipes *Recipes::pClothDyeRecipes=nullptr;
+FoodRecipies *Recipes::pFoodRecipies=nullptr;
+OreRecipies *Recipes::pOreRecipies=nullptr;
+StructureRecipies *Recipes::pStructureRecipies=nullptr;
+ToolRecipies *Recipes::pToolRecipies=nullptr;
+WeaponRecipies *Recipes::pWeaponRecipies=nullptr;
+FireworksRecipe *Recipes::pFireworksRecipes=nullptr;
void Recipes::staticCtor()
{
@@ -950,7 +950,7 @@ Recipes::Recipes()
L'D');
// 4J - TODO - put these new 1.7.3 items in required place within recipes
- addShapedRecipy(new ItemInstance((Tile *)Tile::pistonBase, 1), //
+ addShapedRecipy(new ItemInstance(static_cast<Tile *>(Tile::pistonBase), 1), //
L"sssctcicictg",
L"TTT", //
L"#X#", //
@@ -959,7 +959,7 @@ Recipes::Recipes()
L'#', Tile::cobblestone, L'X', Item::ironIngot, L'R', Item::redStone, L'T', Tile::wood,
L'M');
- addShapedRecipy(new ItemInstance((Tile *)Tile::pistonStickyBase, 1), //
+ addShapedRecipy(new ItemInstance(static_cast<Tile *>(Tile::pistonStickyBase), 1), //
L"sscictg",
L"S", //
L"P", //
@@ -1042,7 +1042,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
Item *pItem;
wchar_t wchFrom;
int iCount;
- ItemInstance **ids = NULL;
+ ItemInstance **ids = nullptr;
myMap *mappings = new unordered_map<wchar_t, ItemInstance *>();
@@ -1072,14 +1072,14 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
pwchString=va_arg(vl,wchar_t *);
wString=pwchString;
height++;
- width = (int)wString.length();
+ width = static_cast<int>(wString.length());
map += wString;
break;
case L's':
pwchString=va_arg(vl,wchar_t *);
wString=pwchString;
height++;
- width = (int)wString.length();
+ width = static_cast<int>(wString.length());
map += wString;
break;
case L'w':
@@ -1091,7 +1091,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
if(!wString.empty())
{
height++;
- width = (int)wString.length();
+ width = static_cast<int>(wString.length());
map += wString;
}
}
@@ -1163,7 +1163,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
}
else
{
- ids[j] = NULL;
+ ids[j] = nullptr;
}
}
}
@@ -1248,7 +1248,7 @@ void Recipes::addShapelessRecipy(ItemInstance *result,... )
recipies->push_back(new ShapelessRecipy(result, ingredients, group));
}
-shared_ptr<ItemInstance> Recipes::getItemFor(shared_ptr<CraftingContainer> craftSlots, Level *level, Recipy *recipesClass /*= NULL*/)
+shared_ptr<ItemInstance> Recipes::getItemFor(shared_ptr<CraftingContainer> craftSlots, Level *level, Recipy *recipesClass /*= nullptr*/)
{
int count = 0;
shared_ptr<ItemInstance> first = nullptr;
@@ -1256,7 +1256,7 @@ shared_ptr<ItemInstance> Recipes::getItemFor(shared_ptr<CraftingContainer> craft
for (int i = 0; i < craftSlots->getContainerSize(); i++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(i);
- if (item != NULL)
+ if (item != nullptr)
{
if (count == 0) first = item;
if (count == 1) second = item;
@@ -1272,10 +1272,10 @@ shared_ptr<ItemInstance> Recipes::getItemFor(shared_ptr<CraftingContainer> craft
int remaining = (remaining1 + remaining2) + item->getMaxDamage() * 5 / 100;
int resultDamage = item->getMaxDamage() - remaining;
if (resultDamage < 0) resultDamage = 0;
- return shared_ptr<ItemInstance>( new ItemInstance(first->id, 1, resultDamage) );
+ return std::make_shared<ItemInstance>(first->id, 1, resultDamage);
}
- if(recipesClass != NULL)
+ if(recipesClass != nullptr)
{
if (recipesClass->matches(craftSlots, level)) return recipesClass->assemble(craftSlots);
}
@@ -1305,7 +1305,7 @@ void Recipes::buildRecipeIngredientsArray(void)
{
//RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies();
- int iRecipeC=(int)recipies->size();
+ int iRecipeC=static_cast<int>(recipies->size());
m_pRecipeIngredientsRequired= new Recipy::INGREDIENTS_REQUIRED [iRecipeC];
diff --git a/Minecraft.World/Recipes.h b/Minecraft.World/Recipes.h
index aacdac30..d6e508a8 100644
--- a/Minecraft.World/Recipes.h
+++ b/Minecraft.World/Recipes.h
@@ -90,7 +90,7 @@ public:
ShapedRecipy *addShapedRecipy(ItemInstance *, ... );
void addShapelessRecipy(ItemInstance *result,... );
- shared_ptr<ItemInstance> getItemFor(shared_ptr<CraftingContainer> craftSlots, Level *level, Recipy *recipesClass = NULL); // 4J Added recipesClass param
+ shared_ptr<ItemInstance> getItemFor(shared_ptr<CraftingContainer> craftSlots, Level *level, Recipy *recipesClass = nullptr); // 4J Added recipesClass param
vector <Recipy *> *getRecipies();
// 4J-PB - Added all below for new Xbox 'crafting'
diff --git a/Minecraft.World/RecordingItem.cpp b/Minecraft.World/RecordingItem.cpp
index 455323c2..3475263f 100644
--- a/Minecraft.World/RecordingItem.cpp
+++ b/Minecraft.World/RecordingItem.cpp
@@ -30,7 +30,7 @@ bool RecordingItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<Play
{
if (level->isClientSide) return true;
- ((JukeboxTile *) Tile::jukebox)->setRecord(level, x, y, z, itemInstance);
+ static_cast<JukeboxTile *>(Tile::jukebox)->setRecord(level, x, y, z, itemInstance);
level->levelEvent(nullptr, LevelEvent::SOUND_PLAY_RECORDING, x, y, z, id);
itemInstance->count--;
@@ -73,6 +73,6 @@ RecordingItem *RecordingItem::getByName(const wstring &name)
}
else
{
- return NULL;
+ return nullptr;
}
} \ No newline at end of file
diff --git a/Minecraft.World/RedStoneDustTile.cpp b/Minecraft.World/RedStoneDustTile.cpp
index a4577bd3..e348406b 100644
--- a/Minecraft.World/RedStoneDustTile.cpp
+++ b/Minecraft.World/RedStoneDustTile.cpp
@@ -25,10 +25,10 @@ RedStoneDustTile::RedStoneDustTile(int id) : Tile(id, Material::decoration,isSol
updateDefaultShape();
- iconCross = NULL;
- iconLine = NULL;
- iconCrossOver = NULL;
- iconLineOver = NULL;
+ iconCross = nullptr;
+ iconLine = nullptr;
+ iconCrossOver = nullptr;
+ iconLineOver = nullptr;
}
// 4J Added override
@@ -39,7 +39,7 @@ void RedStoneDustTile::updateDefaultShape()
AABB *RedStoneDustTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
bool RedStoneDustTile::isSolidRender(bool isServerLevel)
@@ -409,5 +409,5 @@ Icon *RedStoneDustTile::getTexture(const wstring &name)
if (name.compare(TEXTURE_LINE) == 0) return Tile::redStoneDust->iconLine;
if (name.compare(TEXTURE_CROSS_OVERLAY) == 0) return Tile::redStoneDust->iconCrossOver;
if (name.compare(TEXTURE_LINE_OVERLAY) == 0) return Tile::redStoneDust->iconLineOver;
- return NULL;
+ return nullptr;
}
diff --git a/Minecraft.World/RedStoneOreTile.cpp b/Minecraft.World/RedStoneOreTile.cpp
index b7551932..407da2cc 100644
--- a/Minecraft.World/RedStoneOreTile.cpp
+++ b/Minecraft.World/RedStoneOreTile.cpp
@@ -124,5 +124,5 @@ bool RedStoneOreTile::shouldTileTick(Level *level, int x,int y,int z)
shared_ptr<ItemInstance> RedStoneOreTile::getSilkTouchItemInstance(int data)
{
- return shared_ptr<ItemInstance>(new ItemInstance(Tile::redStoneOre));
+ return std::make_shared<ItemInstance>(Tile::redStoneOre);
} \ No newline at end of file
diff --git a/Minecraft.World/ReedTile.cpp b/Minecraft.World/ReedTile.cpp
index c01eb764..dc60bfba 100644
--- a/Minecraft.World/ReedTile.cpp
+++ b/Minecraft.World/ReedTile.cpp
@@ -78,7 +78,7 @@ bool ReedTile::canSurvive(Level *level, int x, int y, int z)
AABB *ReedTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
int ReedTile::getResource(int data, Random *random, int playerBonusLevel)
diff --git a/Minecraft.World/ReedsFeature.cpp b/Minecraft.World/ReedsFeature.cpp
index 2792b21b..ec46f053 100644
--- a/Minecraft.World/ReedsFeature.cpp
+++ b/Minecraft.World/ReedsFeature.cpp
@@ -12,7 +12,7 @@ bool ReedsFeature::place(Level *level, Random *random, int x, int y, int z)
int z2 = z + random->nextInt(4) - random->nextInt(4);
// 4J Stu Added to stop reed features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
bool intersects = levelGenOptions->checkIntersects(x2, y2, z2, x2, y2, z2);
diff --git a/Minecraft.World/Region.cpp b/Minecraft.World/Region.cpp
index e3e91bf0..1e8acaf3 100644
--- a/Minecraft.World/Region.cpp
+++ b/Minecraft.World/Region.cpp
@@ -45,7 +45,7 @@ Region::Region(Level *level, int x1, int y1, int z1, int x2, int y2, int z2, int
for (int zc = zc1; zc <= zc2; zc++)
{
LevelChunk *chunk = level->getChunk(xc, zc);
- if(chunk != NULL)
+ if(chunk != nullptr)
{
LevelChunkArray *lca = (*chunks)[xc - xc1];
lca->data[zc - zc1] = chunk;
@@ -58,7 +58,7 @@ Region::Region(Level *level, int x1, int y1, int z1, int x2, int y2, int z2, int
{
LevelChunkArray *lca = (*chunks)[xc - xc1];
LevelChunk *chunk = lca->data[zc - zc1];
- if (chunk != NULL)
+ if (chunk != nullptr)
{
if (!chunk->isYSpaceEmpty(y1, y2))
{
@@ -71,7 +71,7 @@ Region::Region(Level *level, int x1, int y1, int z1, int x2, int y2, int z2, int
// AP - added a caching system for Chunk::rebuild to take advantage of
xcCached = -1;
zcCached = -1;
- CachedTiles = NULL;
+ CachedTiles = nullptr;
}
bool Region::isAllEmpty()
@@ -105,13 +105,13 @@ int Region::getTile(int x, int y, int z)
xc -= xc1;
zc -= zc1;
- if (xc < 0 || xc >= (int)chunks->length || zc < 0 || zc >= (int)(*chunks)[xc]->length)
+ if (xc < 0 || xc >= static_cast<int>(chunks->length) || zc < 0 || zc >= static_cast<int>((*chunks)[xc]->length))
{
return 0;
}
LevelChunk *lc = (*chunks)[xc]->data[zc];
- if (lc == NULL) return 0;
+ if (lc == nullptr) return 0;
return lc->getTile(x & 15, y, z & 15);
}
@@ -122,9 +122,9 @@ 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);
+ CachedTiles = static_cast<unsigned char *>(malloc(size));
}
memcpy(CachedTiles, tiles, size);
}
@@ -132,14 +132,14 @@ void Region::setCachedTiles(unsigned char *tiles, int xc, int zc)
LevelChunk* Region::getLevelChunk(int x, int y, int z)
{
if (y < 0) return 0;
- if (y >= Level::maxBuildHeight) return NULL;
+ if (y >= Level::maxBuildHeight) return nullptr;
int xc = (x >> 4) - xc1;
int zc = (z >> 4) - zc1;
- if (xc < 0 || xc >= (int)chunks->length || zc < 0 || zc >= (int)(*chunks)[xc]->length)
+ if (xc < 0 || xc >= static_cast<int>(chunks->length) || zc < 0 || zc >= static_cast<int>((*chunks)[xc]->length))
{
- return NULL;
+ return nullptr;
}
LevelChunk *lc = (*chunks)[xc]->data[zc];
@@ -263,7 +263,7 @@ Biome *Region::getBiome(int x, int z)
bool Region::isSolidRenderTile(int x, int y, int z)
{
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile == NULL) return false;
+ if (tile == nullptr) return false;
// 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so
// blocks of leaves will have all sides of each block completely visible. Changing to consider as solid if this block is surrounded by
@@ -278,7 +278,7 @@ bool Region::isSolidRenderTile(int x, int y, int z)
for( int i = 0; i < 6; i++ )
{
int t = getTile(x + axo[i], y + ayo[i] , z + azo[i]);
- if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == NULL ) || !Tile::tiles[t]->isSolidRender() ) )
+ if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == nullptr ) || !Tile::tiles[t]->isSolidRender() ) )
{
return false;
}
@@ -294,7 +294,7 @@ bool Region::isSolidRenderTile(int x, int y, int z)
bool Region::isSolidBlockingTile(int x, int y, int z)
{
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile == NULL) return false;
+ if (tile == nullptr) return false;
return tile->material->blocksMotion() && tile->isCubeShaped();
}
@@ -307,7 +307,7 @@ bool Region::isTopSolidBlocking(int x, int y, int z)
bool Region::isEmptyTile(int x, int y, int z)
{
Tile *tile = Tile::tiles[getTile(x, y, z)];
- return (tile == NULL);
+ return (tile == nullptr);
}
diff --git a/Minecraft.World/RegionFile.cpp b/Minecraft.World/RegionFile.cpp
index 5c29f94e..175ea6c1 100644
--- a/Minecraft.World/RegionFile.cpp
+++ b/Minecraft.World/RegionFile.cpp
@@ -39,7 +39,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
*/
fileEntry = m_saveFile->createFile( fileName->getName() );
- m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END );
+ m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_END );
if ( fileEntry->getFileSize() < SECTOR_BYTES)
{
@@ -54,7 +54,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
m_bIsEmpty = false;
}
- //if ((GetFileSize(file,NULL) & 0xfff) != 0)
+ //if ((GetFileSize(file,nullptr) & 0xfff) != 0)
if ((fileEntry->getFileSize() & 0xfff) != 0)
{
//byte zero = 0;
@@ -78,7 +78,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
}
else
{
- nSectors = (int) fileEntry->getFileSize() / SECTOR_BYTES;
+ nSectors = static_cast<int>(fileEntry->getFileSize()) / SECTOR_BYTES;
}
sectorFree = new vector<bool>;
sectorFree->reserve(nSectors);
@@ -91,7 +91,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
sectorFree->at(0) = false; // chunk offset table
sectorFree->at(1) = false; // for the last modified info
- m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_BEGIN );
for (int i = 0; i < SECTOR_INTS; ++i)
{
unsigned int offset = 0;
@@ -139,11 +139,11 @@ void RegionFile::writeAllOffsets() // used for the file ConsoleSaveFile conversi
m_saveFile->LockSaveAccess();
DWORD numberOfBytesWritten = 0;
- m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_BEGIN );
m_saveFile->writeFile(fileEntry,offsets, SECTOR_BYTES ,&numberOfBytesWritten);
numberOfBytesWritten = 0;
- m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES, nullptr, FILE_BEGIN );
m_saveFile->writeFile(fileEntry, chunkTimestamps, SECTOR_BYTES, &numberOfBytesWritten);
m_saveFile->ReleaseSaveAccess();
@@ -175,7 +175,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
if (outOfBounds(x, z))
{
// debugln("READ", x, z, "out of bounds");
- return NULL;
+ return nullptr;
}
// 4J - removed try/catch
@@ -184,7 +184,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
if (offset == 0)
{
// debugln("READ", x, z, "miss");
- return NULL;
+ return nullptr;
}
unsigned int sectorNumber = offset >> 8;
@@ -193,13 +193,13 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
if (sectorNumber + numSectors > sectorFree->size())
{
// debugln("READ", x, z, "invalid sector");
- return NULL;
+ return nullptr;
}
m_saveFile->LockSaveAccess();
//SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN);
- m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN);
+ m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN);
unsigned int length;
unsigned int decompLength;
@@ -229,7 +229,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
// debugln("READ", x, z, "invalid length: " + length + " > 4096 * " + numSectors);
m_saveFile->ReleaseSaveAccess();
- return NULL;
+ return nullptr;
}
MemSect(50);
@@ -326,7 +326,7 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync
PIXBeginNamedEvent(0,"Scanning for free space\n");
/* scan for a free space large enough to store this chunk */
- int runStart = (int)(find(sectorFree->begin(),sectorFree->end(),true) - sectorFree->begin()); // 4J - was sectorFree.indexOf(true)
+ int runStart = static_cast<int>(find(sectorFree->begin(), sectorFree->end(), true) - sectorFree->begin()); // 4J - was sectorFree.indexOf(true)
int runLength = 0;
if (runStart != -1)
{
@@ -373,16 +373,16 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync
*/
// debug("SAVE", x, z, length, "grow");
//SetFilePointer(file,0,0,FILE_END);
- m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END );
+ m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_END );
- sectorNumber = (int)sectorFree->size();
+ sectorNumber = static_cast<int>(sectorFree->size());
#ifndef _CONTENT_PACAKGE
//wprintf(L"Writing chunk (%d,%d) in %ls from new sector %d to %d\n", x,z, fileEntry->data.filename, sectorNumber, sectorNumber + sectorsNeeded - 1);
#endif
DWORD numberOfBytesWritten = 0;
for (int i = 0; i < sectorsNeeded; ++i)
{
- //WriteFile(file,emptySector.data,SECTOR_BYTES,&numberOfBytesWritten,NULL);
+ //WriteFile(file,emptySector.data,SECTOR_BYTES,&numberOfBytesWritten,nullptr);
m_saveFile->writeFile(fileEntry,emptySector.data,SECTOR_BYTES,&numberOfBytesWritten);
sectorFree->push_back(false);
}
@@ -393,7 +393,7 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync
PIXEndNamedEvent();
}
}
- setTimestamp(x, z, (int) (System::currentTimeMillis() / 1000L));
+ setTimestamp(x, z, static_cast<int>(System::currentTimeMillis() / 1000L));
}
m_saveFile->ReleaseSaveAccess();
@@ -407,7 +407,7 @@ void RegionFile::write(int sectorNumber, byte *data, int length, unsigned int co
{
DWORD numberOfBytesWritten = 0;
//SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN);
- m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN );
// 4J - this differs a bit from the java file format. Java has length stored as an int, then a type as a byte, then length-1 bytes of data
// We store length and decompression length as ints, then length bytes of xbox LZX compressed data
@@ -426,7 +426,7 @@ void RegionFile::zero(int sectorNumber, int length)
{
DWORD numberOfBytesWritten = 0;
//SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN);
- m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN );
m_saveFile->zeroFile( fileEntry, length, &numberOfBytesWritten );
}
@@ -449,7 +449,7 @@ bool RegionFile::hasChunk(int x, int z)
// 4J added - write the initial two sectors that used to be written in the ctor when the file was empty
void RegionFile::insertInitialSectors()
{
- m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_BEGIN );
DWORD numberOfBytesWritten = 0;
byte zeroBytes[ SECTOR_BYTES ];
ZeroMemory(zeroBytes, SECTOR_BYTES);
@@ -472,7 +472,8 @@ void RegionFile::setOffset(int x, int z, int offset)
DWORD numberOfBytesWritten = 0;
offsets[x + z * 32] = offset;
- m_saveFile->setFilePointer( fileEntry, (x + z * 32) * 4, NULL, FILE_BEGIN );
+
+ m_saveFile->setFilePointer( fileEntry, (x + z * 32) * 4, nullptr, FILE_BEGIN );
m_saveFile->writeFile(fileEntry,&offset,4,&numberOfBytesWritten);
}
@@ -486,7 +487,7 @@ void RegionFile::setTimestamp(int x, int z, int value)
DWORD numberOfBytesWritten = 0;
chunkTimestamps[x + z * 32] = value;
- m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES + (x + z * 32) * 4, NULL, FILE_BEGIN );
+ m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES + (x + z * 32) * 4, nullptr, FILE_BEGIN );
m_saveFile->writeFile(fileEntry,&value,4,&numberOfBytesWritten);
}
diff --git a/Minecraft.World/RegionFileCache.cpp b/Minecraft.World/RegionFileCache.cpp
index 2bb370a8..ab0492b4 100644
--- a/Minecraft.World/RegionFileCache.cpp
+++ b/Minecraft.World/RegionFileCache.cpp
@@ -38,13 +38,13 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
}
MemSect(0);
- RegionFile *ref = NULL;
+ RegionFile *ref = nullptr;
auto it = cache.find(file);
if( it != cache.end() )
ref = it->second;
// 4J Jev, put back in.
- if (ref != NULL)
+ if (ref != nullptr)
{
return ref;
}
@@ -72,7 +72,7 @@ void RegionFileCache::_clear() // 4J - TODO was synchronized
for(auto& it : cache)
{
RegionFile *regionFile = it.second;
- if (regionFile != NULL)
+ if (regionFile != nullptr)
{
regionFile->close();
}
diff --git a/Minecraft.World/RemoveEntitiesPacket.h b/Minecraft.World/RemoveEntitiesPacket.h
index 2e734e71..b400b861 100644
--- a/Minecraft.World/RemoveEntitiesPacket.h
+++ b/Minecraft.World/RemoveEntitiesPacket.h
@@ -21,7 +21,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new RemoveEntitiesPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<RemoveEntitiesPacket>(); }
virtual int getId() { return 29; }
};
diff --git a/Minecraft.World/RemoveMobEffectPacket.cpp b/Minecraft.World/RemoveMobEffectPacket.cpp
index fcda6911..7e2d7c84 100644
--- a/Minecraft.World/RemoveMobEffectPacket.cpp
+++ b/Minecraft.World/RemoveMobEffectPacket.cpp
@@ -13,7 +13,7 @@ RemoveMobEffectPacket::RemoveMobEffectPacket()
RemoveMobEffectPacket::RemoveMobEffectPacket(int entityId, MobEffectInstance *effect)
{
this->entityId = entityId;
- this->effectId = (byte) (effect->getId() & 0xff);
+ this->effectId = static_cast<byte>(effect->getId() & 0xff);
}
void RemoveMobEffectPacket::read(DataInputStream *dis)
diff --git a/Minecraft.World/RemoveMobEffectPacket.h b/Minecraft.World/RemoveMobEffectPacket.h
index d69a4ed4..140b0a7e 100644
--- a/Minecraft.World/RemoveMobEffectPacket.h
+++ b/Minecraft.World/RemoveMobEffectPacket.h
@@ -18,6 +18,6 @@ class RemoveMobEffectPacket : public Packet, public enable_shared_from_this<Remo
virtual void handle(PacketListener *listener);
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new RemoveMobEffectPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<RemoveMobEffectPacket>(); }
virtual int getId() { return 42; }
}; \ No newline at end of file
diff --git a/Minecraft.World/RepairResultSlot.cpp b/Minecraft.World/RepairResultSlot.cpp
index 51e95b42..87d2aab6 100644
--- a/Minecraft.World/RepairResultSlot.cpp
+++ b/Minecraft.World/RepairResultSlot.cpp
@@ -30,7 +30,7 @@ void RepairResultSlot::onTake(shared_ptr<Player> player, shared_ptr<ItemInstance
if (m_menu->repairItemCountCost > 0)
{
shared_ptr<ItemInstance> addition = m_menu->repairSlots->getItem(AnvilMenu::ADDITIONAL_SLOT);
- if (addition != NULL && addition->count > m_menu->repairItemCountCost)
+ if (addition != nullptr && addition->count > m_menu->repairItemCountCost)
{
addition->count -= m_menu->repairItemCountCost;
m_menu->repairSlots->setItem(AnvilMenu::ADDITIONAL_SLOT, addition);
diff --git a/Minecraft.World/RespawnPacket.cpp b/Minecraft.World/RespawnPacket.cpp
index ecc0b7f0..6dbebfac 100644
--- a/Minecraft.World/RespawnPacket.cpp
+++ b/Minecraft.World/RespawnPacket.cpp
@@ -11,9 +11,9 @@ RespawnPacket::RespawnPacket()
this->difficulty = 1;
this->mapSeed = 0;
this->mapHeight = 0;
- this->playerGameType = NULL;
+ this->playerGameType = nullptr;
this->m_newSeaLevel = false;
- m_pLevelType = NULL;
+ m_pLevelType = nullptr;
m_newEntityId = 0;
m_xzSize = LEVEL_MAX_WIDTH;
m_hellScale = HELL_LEVEL_MAX_SCALE;
@@ -47,7 +47,7 @@ void RespawnPacket::read(DataInputStream *dis) //throws IOException
mapHeight = dis->readShort();
wstring typeName = readUtf(dis, 16);
m_pLevelType = LevelType::getLevelType(typeName);
- if (m_pLevelType == NULL)
+ if (m_pLevelType == nullptr)
{
m_pLevelType = LevelType::lvl_normal;
}
@@ -68,7 +68,7 @@ void RespawnPacket::write(DataOutputStream *dos) //throws IOException
dos->writeByte(dimension);
dos->writeByte(playerGameType->getId());
dos->writeShort(mapHeight);
- if (m_pLevelType == NULL)
+ if (m_pLevelType == nullptr)
{
writeUtf(L"", dos);
}
@@ -89,9 +89,9 @@ 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();
+ length = static_cast<int>(m_pLevelType->getGeneratorName().length());
}
return 13+length;
}
diff --git a/Minecraft.World/RespawnPacket.h b/Minecraft.World/RespawnPacket.h
index 3caf1ee3..dc815994 100644
--- a/Minecraft.World/RespawnPacket.h
+++ b/Minecraft.World/RespawnPacket.h
@@ -29,6 +29,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new RespawnPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<RespawnPacket>(); }
virtual int getId() { return 9; }
};
diff --git a/Minecraft.World/RestrictOpenDoorGoal.cpp b/Minecraft.World/RestrictOpenDoorGoal.cpp
index e8620a71..3f7e2ed9 100644
--- a/Minecraft.World/RestrictOpenDoorGoal.cpp
+++ b/Minecraft.World/RestrictOpenDoorGoal.cpp
@@ -14,9 +14,9 @@ bool RestrictOpenDoorGoal::canUse()
{
if (mob->level->isDay()) return false;
shared_ptr<Village> village = mob->level->villages->getClosestVillage(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 16);
- if (village == NULL) return false;
+ if (village == nullptr) return false;
shared_ptr<DoorInfo> _doorInfo = village->getClosestDoorInfo(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z));
- if (_doorInfo == NULL) return false;
+ if (_doorInfo == nullptr) return false;
doorInfo = _doorInfo;
return _doorInfo->distanceToInsideSqr(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)) < 1.5 * 1.5;
}
@@ -25,7 +25,7 @@ bool RestrictOpenDoorGoal::canContinueToUse()
{
if (mob->level->isDay()) return false;
shared_ptr<DoorInfo> _doorInfo = doorInfo.lock();
- if ( _doorInfo == NULL ) return false;
+ if ( _doorInfo == nullptr ) return false;
return !_doorInfo->removed && _doorInfo->isInsideSide(Mth::floor(mob->x), Mth::floor(mob->z));
}
diff --git a/Minecraft.World/ResultContainer.cpp b/Minecraft.World/ResultContainer.cpp
index 8c85d0c3..7c8dd1c1 100644
--- a/Minecraft.World/ResultContainer.cpp
+++ b/Minecraft.World/ResultContainer.cpp
@@ -33,7 +33,7 @@ bool ResultContainer::hasCustomName()
shared_ptr<ItemInstance> ResultContainer::removeItem(unsigned int slot, int count)
{
- if (items[0] != NULL)
+ if (items[0] != nullptr)
{
shared_ptr<ItemInstance> item = items[0];
items[0] = nullptr;
@@ -44,7 +44,7 @@ shared_ptr<ItemInstance> ResultContainer::removeItem(unsigned int slot, int coun
shared_ptr<ItemInstance> ResultContainer::removeItemNoUpdate(int slot)
{
- if (items[0] != NULL)
+ if (items[0] != nullptr)
{
shared_ptr<ItemInstance> item = items[0];
items[0] = nullptr;
diff --git a/Minecraft.World/ResultSlot.cpp b/Minecraft.World/ResultSlot.cpp
index 08ffe714..89a07ed1 100644
--- a/Minecraft.World/ResultSlot.cpp
+++ b/Minecraft.World/ResultSlot.cpp
@@ -60,13 +60,13 @@ void ResultSlot::onTake(shared_ptr<Player> player, shared_ptr<ItemInstance> carr
for (unsigned int i = 0; i < craftSlots->getContainerSize(); i++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(i);
- if (item != NULL)
+ if (item != nullptr)
{
craftSlots->removeItem(i, 1);
if (item->getItem()->hasCraftingRemainingItem())
{
- shared_ptr<ItemInstance> craftResult = shared_ptr<ItemInstance>(new ItemInstance(item->getItem()->getCraftingRemainingItem()));
+ shared_ptr<ItemInstance> craftResult = std::make_shared<ItemInstance>(item->getItem()->getCraftingRemainingItem());
/*
* Try to place this in the player's inventory (See we.java for new method)
@@ -77,7 +77,7 @@ void ResultSlot::onTake(shared_ptr<Player> player, shared_ptr<ItemInstance> carr
}
// If this slot is now empty, place it there (current behavior)
- if (craftSlots->getItem(i) == NULL)
+ if (craftSlots->getItem(i) == nullptr)
{
craftSlots->setItem(i, craftResult);
}
diff --git a/Minecraft.World/RotateHeadPacket.h b/Minecraft.World/RotateHeadPacket.h
index 19ccf97f..884f4844 100644
--- a/Minecraft.World/RotateHeadPacket.h
+++ b/Minecraft.World/RotateHeadPacket.h
@@ -22,6 +22,6 @@ public:
virtual bool isAync();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new RotateHeadPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<RotateHeadPacket>(); }
virtual int getId() { return 35; }
}; \ No newline at end of file
diff --git a/Minecraft.World/RotatedPillarTile.cpp b/Minecraft.World/RotatedPillarTile.cpp
index a4b7d931..6475cd72 100644
--- a/Minecraft.World/RotatedPillarTile.cpp
+++ b/Minecraft.World/RotatedPillarTile.cpp
@@ -73,5 +73,5 @@ int RotatedPillarTile::getType(int data)
shared_ptr<ItemInstance> RotatedPillarTile::getSilkTouchItemInstance(int data)
{
- return shared_ptr<ItemInstance>( new ItemInstance(id, 1, getType(data)) );
+ return std::make_shared<ItemInstance>(id, 1, getType(data));
} \ No newline at end of file
diff --git a/Minecraft.World/RunAroundLikeCrazyGoal.cpp b/Minecraft.World/RunAroundLikeCrazyGoal.cpp
index 118b09f9..40138d73 100644
--- a/Minecraft.World/RunAroundLikeCrazyGoal.cpp
+++ b/Minecraft.World/RunAroundLikeCrazyGoal.cpp
@@ -17,9 +17,9 @@ RunAroundLikeCrazyGoal::RunAroundLikeCrazyGoal(EntityHorse *mob, double speedMod
bool RunAroundLikeCrazyGoal::canUse()
{
- if (horse->isTamed() || horse->rider.lock() == NULL) return false;
+ if (horse->isTamed() || horse->rider.lock() == nullptr) return false;
Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(horse->shared_from_this()), 5, 4);
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
posX = pos->x;
posY = pos->y;
posZ = pos->z;
@@ -33,7 +33,7 @@ void RunAroundLikeCrazyGoal::start()
bool RunAroundLikeCrazyGoal::canContinueToUse()
{
- return !horse->getNavigation()->isDone() && horse->rider.lock() != NULL;
+ return !horse->getNavigation()->isDone() && horse->rider.lock() != nullptr;
}
void RunAroundLikeCrazyGoal::tick()
diff --git a/Minecraft.World/SaddleItem.cpp b/Minecraft.World/SaddleItem.cpp
index f982b751..63873060 100644
--- a/Minecraft.World/SaddleItem.cpp
+++ b/Minecraft.World/SaddleItem.cpp
@@ -11,7 +11,7 @@ SaddleItem::SaddleItem(int id) : Item(id)
bool SaddleItem::interactEnemy(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, shared_ptr<LivingEntity> mob)
{
- if ( (mob != NULL) && mob->instanceof(eTYPE_PIG) )
+ if ( (mob != nullptr) && mob->instanceof(eTYPE_PIG) )
{
shared_ptr<Pig> pig = dynamic_pointer_cast<Pig>(mob);
if (!pig->hasSaddle() && !pig->isBaby())
diff --git a/Minecraft.World/SandFeature.cpp b/Minecraft.World/SandFeature.cpp
index 122264ff..9c0dc67c 100644
--- a/Minecraft.World/SandFeature.cpp
+++ b/Minecraft.World/SandFeature.cpp
@@ -22,7 +22,7 @@ bool SandFeature::place(Level *level, Random *random, int x, int y, int z)
int yr = 2;
// 4J Stu Added to stop tree features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
bool intersects = levelGenOptions->checkIntersects(x - r, y - yr, z - r, x + r, y + yr, z + r);
diff --git a/Minecraft.World/SandStoneTile.cpp b/Minecraft.World/SandStoneTile.cpp
index daf42db8..bd7309b9 100644
--- a/Minecraft.World/SandStoneTile.cpp
+++ b/Minecraft.World/SandStoneTile.cpp
@@ -14,9 +14,9 @@ int SandStoneTile::SANDSTONE_NAMES[SANDSTONE_BLOCK_NAMES] = {
SandStoneTile::SandStoneTile(int id) : Tile(id, Material::stone)
{
- icons = NULL;
- iconTop = NULL;
- iconBottom = NULL;
+ icons = nullptr;
+ iconTop = nullptr;
+ iconBottom = nullptr;
}
Icon *SandStoneTile::getTexture(int face, int data)
diff --git a/Minecraft.World/Sapling.cpp b/Minecraft.World/Sapling.cpp
index 85fcea98..c169a608 100644
--- a/Minecraft.World/Sapling.cpp
+++ b/Minecraft.World/Sapling.cpp
@@ -17,7 +17,7 @@ const wstring Sapling::TEXTURE_NAMES[] = {L"sapling", L"sapling_spruce", L"sapli
Sapling::Sapling(int id) : Bush( id )
{
this->updateDefaultShape();
- icons = NULL;
+ icons = nullptr;
}
// 4J Added override
@@ -65,7 +65,7 @@ void Sapling::growTree(Level *level, int x, int y, int z, Random *random)
{
int data = level->getData(x, y, z) & TYPE_MASK;
- Feature *f = NULL;
+ Feature *f = nullptr;
int ox = 0, oz = 0;
bool multiblock = false;
@@ -93,12 +93,12 @@ void Sapling::growTree(Level *level, int x, int y, int z, Random *random)
break;
}
}
- if (f != NULL)
+ if (f != nullptr)
{
break;
}
}
- if (f == NULL)
+ if (f == nullptr)
{
ox = oz = 0;
f = new TreeFeature(true, 4 + random->nextInt(7), TreeTile::JUNGLE_TRUNK, LeafTile::JUNGLE_LEAF, false);
@@ -138,7 +138,7 @@ void Sapling::growTree(Level *level, int x, int y, int z, Random *random)
level->setTileAndData(x, y, z, id, data, Tile::UPDATE_NONE);
}
}
- if( f != NULL )
+ if( f != nullptr )
delete f;
}
diff --git a/Minecraft.World/SavedDataStorage.cpp b/Minecraft.World/SavedDataStorage.cpp
index 422b66dc..049a19fc 100644
--- a/Minecraft.World/SavedDataStorage.cpp
+++ b/Minecraft.World/SavedDataStorage.cpp
@@ -26,7 +26,7 @@ shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const wstrin
if (it != cache.end()) return (*it).second;
shared_ptr<SavedData> data = nullptr;
- if (levelStorage != NULL)
+ if (levelStorage != nullptr)
{
//File file = levelStorage->getDataFile(id);
ConsoleSavePath file = levelStorage->getDataFile(id);
@@ -37,15 +37,15 @@ shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const wstrin
if( clazz == typeid(MapItemSavedData) )
{
- data = dynamic_pointer_cast<SavedData>( shared_ptr<MapItemSavedData>(new MapItemSavedData(id)) );
+ data = dynamic_pointer_cast<SavedData>(std::make_shared<MapItemSavedData>(id));
}
else if( clazz == typeid(Villages) )
{
- data = dynamic_pointer_cast<SavedData>( shared_ptr<Villages>(new Villages(id) ) );
+ data = dynamic_pointer_cast<SavedData>(std::make_shared<Villages>(id));
}
else if( clazz == typeid(StructureFeatureSavedData) )
{
- data = dynamic_pointer_cast<SavedData>( shared_ptr<StructureFeatureSavedData>( new StructureFeatureSavedData(id) ) );
+ data = dynamic_pointer_cast<SavedData>(std::make_shared<StructureFeatureSavedData>(id));
}
else
{
@@ -61,7 +61,7 @@ shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const wstrin
}
}
- if (data != NULL)
+ if (data != nullptr)
{
cache.insert( unordered_map<wstring, shared_ptr<SavedData> >::value_type( id , data ) );
savedDatas.push_back(data);
@@ -71,7 +71,7 @@ shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const wstrin
void SavedDataStorage::set(const wstring& id, shared_ptr<SavedData> data)
{
- if (data == NULL)
+ if (data == nullptr)
{
// TODO 4J Stu - throw new RuntimeException("Can't set null data");
assert( false );
@@ -104,7 +104,7 @@ void SavedDataStorage::save()
void SavedDataStorage::save(shared_ptr<SavedData> data)
{
- if (levelStorage == NULL) return;
+ if (levelStorage == nullptr) return;
//File file = levelStorage->getDataFile(data->id);
ConsoleSavePath file = levelStorage->getDataFile(data->id);
if (!file.getName().empty())
@@ -127,7 +127,7 @@ void SavedDataStorage::loadAuxValues()
{
usedAuxIds.clear();
- if (levelStorage == NULL) return;
+ if (levelStorage == nullptr) return;
//File file = levelStorage->getDataFile(L"idcounts");
ConsoleSavePath file = levelStorage->getDataFile(L"idcounts");
if (!file.getName().empty() && levelStorage->getSaveFile()->doesFileExist( file ) )
@@ -163,7 +163,7 @@ int SavedDataStorage::getFreeAuxValueFor(const wstring& id)
}
usedAuxIds[id] = val;
- if (levelStorage == NULL) return val;
+ if (levelStorage == nullptr) return val;
//File file = levelStorage->getDataFile(L"idcounts");
ConsoleSavePath file = levelStorage->getDataFile(L"idcounts");
if (!file.getName().empty())
@@ -188,7 +188,7 @@ int SavedDataStorage::getFreeAuxValueFor(const wstring& id)
// 4J Added
int SavedDataStorage::getAuxValueForMap(PlayerUID xuid, int dimension, int centreXC, int centreZC, int scale)
{
- if( levelStorage == NULL )
+ if( levelStorage == nullptr )
{
switch(dimension)
{
diff --git a/Minecraft.World/ScatteredFeaturePieces.cpp b/Minecraft.World/ScatteredFeaturePieces.cpp
index 317d6d9e..07630ef7 100644
--- a/Minecraft.World/ScatteredFeaturePieces.cpp
+++ b/Minecraft.World/ScatteredFeaturePieces.cpp
@@ -35,7 +35,7 @@ ScatteredFeaturePieces::ScatteredFeaturePiece::ScatteredFeaturePiece(Random *ran
orientation = random->nextInt(4);
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
- if( levelGenOptions != NULL )
+ if( levelGenOptions != nullptr )
{
int tempOrientation = 0;
if(levelGenOptions->isFeatureChunk(west>>4,north>>4,StructureFeature::eFeature_Temples, &tempOrientation) )
@@ -737,9 +737,9 @@ bool ScatteredFeaturePieces::SwamplandHut::postProcess(Level *level, Random *ran
{
spawnedWitch = true;
- shared_ptr<Witch> witch = shared_ptr<Witch>( new Witch(level) );
+ shared_ptr<Witch> witch = std::make_shared<Witch>(level);
witch->moveTo(wx + .5, wy, wz + .5, 0, 0);
- witch->finalizeMobSpawn(NULL);
+ witch->finalizeMobSpawn(nullptr);
level->addEntity(witch);
}
}
diff --git a/Minecraft.World/Scoreboard.cpp b/Minecraft.World/Scoreboard.cpp
index 5c6f2ebd..bab0b213 100644
--- a/Minecraft.World/Scoreboard.cpp
+++ b/Minecraft.World/Scoreboard.cpp
@@ -4,15 +4,15 @@
Objective *Scoreboard::getObjective(const wstring &name)
{
- return NULL;
+ return nullptr;
//return objectivesByName.find(name)->second;
}
Objective *Scoreboard::addObjective(const wstring &name, ObjectiveCriteria *criteria)
{
- return NULL;
+ return nullptr;
// Objective *objective = getObjective(name);
-// if (objective != NULL)
+// if (objective != nullptr)
// {
//#indef _CONTENT_PACKAGE
// __debugbreak();
@@ -24,7 +24,7 @@ Objective *Scoreboard::addObjective(const wstring &name, ObjectiveCriteria *crit
//
// vector<Objective *> *criteriaList = objectivesByCriteria.find(criteria)->second;
//
-// if (criteriaList == NULL)
+// if (criteriaList == nullptr)
// {
// criteriaList = new vector<Objective *>();
// objectivesByCriteria[criteria] = criteriaList;
@@ -39,18 +39,18 @@ Objective *Scoreboard::addObjective(const wstring &name, ObjectiveCriteria *crit
vector<Objective *> *Scoreboard::findObjectiveFor(ObjectiveCriteria *criteria)
{
- return NULL;
+ return nullptr;
//vector<Objective *> *objectives = objectivesByCriteria.find(criteria)->second;
- //return objectives == NULL ? new vector<Objective *>() : new vector<Objective *>(objectives);
+ //return objectives == nullptr ? new vector<Objective *>() : new vector<Objective *>(objectives);
}
Score *Scoreboard::getPlayerScore(const wstring &name, Objective *objective)
{
- return NULL;
+ return nullptr;
//unordered_map<Objective *, Score *> *scores = playerScores.find(name)->it;
- //if (scores == NULL)
+ //if (scores == nullptr)
//{
// scores = new unordered_map<Objective *, Score *>();
// playerScores.put(name, scores);
@@ -58,7 +58,7 @@ Score *Scoreboard::getPlayerScore(const wstring &name, Objective *objective)
//Score *score = scores->get(objective);
- //if (score == NULL)
+ //if (score == nullptr)
//{
// score = new Score(this, objective, name);
// scores->put(objective, score);
@@ -69,7 +69,7 @@ Score *Scoreboard::getPlayerScore(const wstring &name, Objective *objective)
vector<Score *> *Scoreboard::getPlayerScores(Objective *objective)
{
- return NULL;
+ return nullptr;
//vector<Score *> *result = new vector<Score *>();
//for (Map<Objective, Score> scores : playerScores.values())
@@ -85,13 +85,13 @@ vector<Score *> *Scoreboard::getPlayerScores(Objective *objective)
vector<Objective *> *Scoreboard::getObjectives()
{
- return NULL;
+ return nullptr;
//return objectivesByName.values();
}
vector<wstring> *Scoreboard::getTrackedPlayers()
{
- return NULL;
+ return nullptr;
//return playerScores.keySet();
}
@@ -99,7 +99,7 @@ void Scoreboard::resetPlayerScore(const wstring &player)
{
//unordered_map<Objective *, Score *> *removed = playerScores.remove(player);
- //if (removed != NULL)
+ //if (removed != nullptr)
//{
// onPlayerRemoved(player);
//}
@@ -107,7 +107,7 @@ void Scoreboard::resetPlayerScore(const wstring &player)
vector<Score *> *Scoreboard::getScores()
{
- return NULL;
+ return nullptr;
//Collection<Map<Objective, Score>> values = playerScores.values();
//List<Score> result = new ArrayList<Score>();
@@ -121,7 +121,7 @@ vector<Score *> *Scoreboard::getScores()
vector<Score *> *Scoreboard::getScores(Objective *objective)
{
- return NULL;
+ return nullptr;
//Collection<Map<Objective, Score>> values = playerScores.values();
//List<Score> result = new ArrayList<Score>();
@@ -135,7 +135,7 @@ vector<Score *> *Scoreboard::getScores(Objective *objective)
unordered_map<Objective *, Score *> *Scoreboard::getPlayerScores(const wstring &player)
{
- return NULL;
+ return nullptr;
//Map<Objective, Score> result = playerScores.get(player);
//if (result == null) result = new HashMap<Objective, Score>();
//return result;
@@ -166,19 +166,19 @@ void Scoreboard::setDisplayObjective(int slot, Objective *objective)
Objective *Scoreboard::getDisplayObjective(int slot)
{
- return NULL;
+ return nullptr;
//return displayObjectives[slot];
}
PlayerTeam *Scoreboard::getPlayerTeam(const wstring &name)
{
- return NULL;
+ return nullptr;
//return teamsByName.get(name);
}
PlayerTeam *Scoreboard::addPlayerTeam(const wstring &name)
{
- return NULL;
+ return nullptr;
//PlayerTeam team = getPlayerTeam(name);
//if (team != null) throw new IllegalArgumentException("An objective with the name '" + name + "' already exists!");
@@ -237,13 +237,13 @@ void Scoreboard::removePlayerFromTeam(const wstring &player, PlayerTeam *team)
vector<wstring> *Scoreboard::getTeamNames()
{
- return NULL;
+ return nullptr;
//return teamsByName.keySet();
}
vector<PlayerTeam *> *Scoreboard::getPlayerTeams()
{
- return NULL;
+ return nullptr;
//return teamsByName.values();
}
@@ -255,7 +255,7 @@ shared_ptr<Player> Scoreboard::getPlayer(const wstring &name)
PlayerTeam *Scoreboard::getPlayersTeam(const wstring &name)
{
- return NULL;
+ return nullptr;
//return teamsByPlayer.get(name);
}
diff --git a/Minecraft.World/ServerSettingsChangedPacket.h b/Minecraft.World/ServerSettingsChangedPacket.h
index e6ab7356..c537eca9 100644
--- a/Minecraft.World/ServerSettingsChangedPacket.h
+++ b/Minecraft.World/ServerSettingsChangedPacket.h
@@ -26,6 +26,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ServerSettingsChangedPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<ServerSettingsChangedPacket>(); }
virtual int getId() { return 153; }
}; \ No newline at end of file
diff --git a/Minecraft.World/ServersideAttributeMap.cpp b/Minecraft.World/ServersideAttributeMap.cpp
index 901854cc..c7308666 100644
--- a/Minecraft.World/ServersideAttributeMap.cpp
+++ b/Minecraft.World/ServersideAttributeMap.cpp
@@ -17,7 +17,7 @@ AttributeInstance *ServersideAttributeMap::getInstance(eATTRIBUTE_ID id)
// 4J: Removed legacy name
// If we didn't find it, search by legacy name
- /*if (result == NULL)
+ /*if (result == nullptr)
{
auto it = attributesByLegacy.find(name);
if(it != attributesByLegacy.end())
@@ -43,7 +43,7 @@ AttributeInstance *ServersideAttributeMap::registerAttribute(Attribute *attribut
// 4J: Removed legacy name
// If this is a ranged attribute also add to legacy name map
/*RangedAttribute *rangedAttribute = dynamic_cast<RangedAttribute*>(attribute);
- if (rangedAttribute != NULL && rangedAttribute->getImportLegacyName() != L"")
+ if (rangedAttribute != nullptr && rangedAttribute->getImportLegacyName() != L"")
{
attributesByLegacy.insert(std::pair<wstring, AttributeInstance*>(rangedAttribute->getImportLegacyName(), instance));
}*/
@@ -69,9 +69,13 @@ unordered_set<AttributeInstance *> *ServersideAttributeMap::getSyncableAttribute
unordered_set<AttributeInstance *> *result = new unordered_set<AttributeInstance *>();
vector<AttributeInstance *> atts;
getAttributes(atts);
- for (int i = 0; i < atts.size(); i++)
+ for (size_t i = 0; i < atts.size(); i++)
{
AttributeInstance *instance = atts.at(i);
+ if (instance == nullptr)
+ {
+ continue;
+ }
if (instance->getAttribute()->isClientSyncable())
{
diff --git a/Minecraft.World/SetCarriedItemPacket.h b/Minecraft.World/SetCarriedItemPacket.h
index 06fb3c30..017314dc 100644
--- a/Minecraft.World/SetCarriedItemPacket.h
+++ b/Minecraft.World/SetCarriedItemPacket.h
@@ -19,6 +19,6 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetCarriedItemPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetCarriedItemPacket>(); }
virtual int getId() { return 16; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetCreativeModeSlotPacket.h b/Minecraft.World/SetCreativeModeSlotPacket.h
index 94ae7807..3724714e 100644
--- a/Minecraft.World/SetCreativeModeSlotPacket.h
+++ b/Minecraft.World/SetCreativeModeSlotPacket.h
@@ -18,6 +18,6 @@ class SetCreativeModeSlotPacket : public Packet, public enable_shared_from_this<
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetCreativeModeSlotPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetCreativeModeSlotPacket>(); }
virtual int getId() { return 107; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetDisplayObjectivePacket.cpp b/Minecraft.World/SetDisplayObjectivePacket.cpp
index f1cffa4b..9908d15e 100644
--- a/Minecraft.World/SetDisplayObjectivePacket.cpp
+++ b/Minecraft.World/SetDisplayObjectivePacket.cpp
@@ -13,7 +13,7 @@ SetDisplayObjectivePacket::SetDisplayObjectivePacket(int slot, Objective *object
{
this->slot = slot;
- if (objective == NULL)
+ if (objective == nullptr)
{
objectiveName = L"";
}
diff --git a/Minecraft.World/SetDisplayObjectivePacket.h b/Minecraft.World/SetDisplayObjectivePacket.h
index f32f6386..5404eab7 100644
--- a/Minecraft.World/SetDisplayObjectivePacket.h
+++ b/Minecraft.World/SetDisplayObjectivePacket.h
@@ -19,6 +19,6 @@ public:
int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetDisplayObjectivePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetDisplayObjectivePacket>(); }
virtual int getId() { return 208; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetEntityDataPacket.cpp b/Minecraft.World/SetEntityDataPacket.cpp
index 9947c163..a49ba9d9 100644
--- a/Minecraft.World/SetEntityDataPacket.cpp
+++ b/Minecraft.World/SetEntityDataPacket.cpp
@@ -10,7 +10,7 @@
SetEntityDataPacket::SetEntityDataPacket()
{
id = -1;
- packedItems = NULL;
+ packedItems = nullptr;
}
SetEntityDataPacket::~SetEntityDataPacket()
diff --git a/Minecraft.World/SetEntityDataPacket.h b/Minecraft.World/SetEntityDataPacket.h
index a3bb0860..cd3371dd 100644
--- a/Minecraft.World/SetEntityDataPacket.h
+++ b/Minecraft.World/SetEntityDataPacket.h
@@ -25,6 +25,6 @@ public:
vector<shared_ptr<SynchedEntityData::DataItem> > *getUnpackedData();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetEntityDataPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetEntityDataPacket>(); }
virtual int getId() { return 40; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetEntityLinkPacket.cpp b/Minecraft.World/SetEntityLinkPacket.cpp
index cae35e48..3ad0f45b 100644
--- a/Minecraft.World/SetEntityLinkPacket.cpp
+++ b/Minecraft.World/SetEntityLinkPacket.cpp
@@ -18,7 +18,7 @@ SetEntityLinkPacket::SetEntityLinkPacket(int linkType, shared_ptr<Entity> source
{
type = linkType;
this->sourceId = sourceEntity->entityId;
- this->destId = destEntity != NULL ? destEntity->entityId : -1;
+ this->destId = destEntity != nullptr ? destEntity->entityId : -1;
}
int SetEntityLinkPacket::getEstimatedSize()
diff --git a/Minecraft.World/SetEntityLinkPacket.h b/Minecraft.World/SetEntityLinkPacket.h
index aa92206d..04ee0e97 100644
--- a/Minecraft.World/SetEntityLinkPacket.h
+++ b/Minecraft.World/SetEntityLinkPacket.h
@@ -23,7 +23,7 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetEntityLinkPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetEntityLinkPacket>(); }
virtual int getId() { return 39; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetEntityMotionPacket.cpp b/Minecraft.World/SetEntityMotionPacket.cpp
index a0749b74..20d841f1 100644
--- a/Minecraft.World/SetEntityMotionPacket.cpp
+++ b/Minecraft.World/SetEntityMotionPacket.cpp
@@ -17,9 +17,9 @@ void SetEntityMotionPacket::_init(int id, double xd, double yd, double zd)
if (xd > m) xd = m;
if (yd > m) yd = m;
if (zd > m) zd = m;
- xa = (int) (xd * 8000.0);
- ya = (int) (yd * 8000.0);
- za = (int) (zd * 8000.0);
+ xa = static_cast<int>(xd * 8000.0);
+ ya = static_cast<int>(yd * 8000.0);
+ za = static_cast<int>(zd * 8000.0);
// 4J - if we could transmit this as bytes (in 1/16 accuracy) then flag to do so
if( ( xa >= (-128 * 16 ) ) && ( ya >= (-128 * 16 ) ) && ( za >= (-128 * 16 ) ) &&
( xa < (128 * 16 ) ) && ( ya < (128 * 16 ) ) && ( za < (128 * 16 ) ) )
@@ -53,9 +53,9 @@ void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException
id = idAndFlag & 0x07ff;
if( idAndFlag & 0x0800 )
{
- xa = (int)dis->readByte();
- ya = (int)dis->readByte();
- za = (int)dis->readByte();
+ xa = static_cast<int>(dis->readByte());
+ ya = static_cast<int>(dis->readByte());
+ za = static_cast<int>(dis->readByte());
xa = ( xa << 24 ) >> 24;
ya = ( ya << 24 ) >> 24;
za = ( za << 24 ) >> 24;
diff --git a/Minecraft.World/SetEntityMotionPacket.h b/Minecraft.World/SetEntityMotionPacket.h
index 00c019da..e71240c5 100644
--- a/Minecraft.World/SetEntityMotionPacket.h
+++ b/Minecraft.World/SetEntityMotionPacket.h
@@ -26,6 +26,6 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetEntityMotionPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetEntityMotionPacket>(); }
virtual int getId() { return 28; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetEquippedItemPacket.cpp b/Minecraft.World/SetEquippedItemPacket.cpp
index 1da93b84..ac9d22b2 100644
--- a/Minecraft.World/SetEquippedItemPacket.cpp
+++ b/Minecraft.World/SetEquippedItemPacket.cpp
@@ -20,7 +20,7 @@ SetEquippedItemPacket::SetEquippedItemPacket(int entity, int slot, shared_ptr<It
this->slot = slot;
// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
- this->item = item == NULL ? nullptr : item->copy();
+ this->item = item == nullptr ? nullptr : item->copy();
}
void SetEquippedItemPacket::read(DataInputStream *dis) //throws IOException
diff --git a/Minecraft.World/SetEquippedItemPacket.h b/Minecraft.World/SetEquippedItemPacket.h
index def39120..29df2b02 100644
--- a/Minecraft.World/SetEquippedItemPacket.h
+++ b/Minecraft.World/SetEquippedItemPacket.h
@@ -28,6 +28,6 @@ public:
shared_ptr<ItemInstance> getItem();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetEquippedItemPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetEquippedItemPacket>(); }
virtual int getId() { return 5; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetExperiencePacket.h b/Minecraft.World/SetExperiencePacket.h
index 01c0ed46..668f4416 100644
--- a/Minecraft.World/SetExperiencePacket.h
+++ b/Minecraft.World/SetExperiencePacket.h
@@ -20,6 +20,6 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetExperiencePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetExperiencePacket>(); }
virtual int getId() { return 43; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetHealthPacket.cpp b/Minecraft.World/SetHealthPacket.cpp
index 639cacd8..4557f7bb 100644
--- a/Minecraft.World/SetHealthPacket.cpp
+++ b/Minecraft.World/SetHealthPacket.cpp
@@ -32,7 +32,7 @@ void SetHealthPacket::read(DataInputStream *dis) //throws IOException
saturation = dis->readFloat();
// exhaustion = dis.readFloat();
- damageSource = (ETelemetryChallenges)dis->readByte();
+ damageSource = static_cast<ETelemetryChallenges>(dis->readByte());
}
void SetHealthPacket::write(DataOutputStream *dos) //throws IOException
diff --git a/Minecraft.World/SetHealthPacket.h b/Minecraft.World/SetHealthPacket.h
index 4704f220..cc85c4c6 100644
--- a/Minecraft.World/SetHealthPacket.h
+++ b/Minecraft.World/SetHealthPacket.h
@@ -23,7 +23,7 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetHealthPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetHealthPacket>(); }
virtual int getId() { return 8; }
};
diff --git a/Minecraft.World/SetObjectivePacket.h b/Minecraft.World/SetObjectivePacket.h
index 5b5dfc6f..52b67ee0 100644
--- a/Minecraft.World/SetObjectivePacket.h
+++ b/Minecraft.World/SetObjectivePacket.h
@@ -23,6 +23,6 @@ public:
int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetObjectivePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetObjectivePacket>(); }
virtual int getId() { return 206; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetPlayerTeamPacket.cpp b/Minecraft.World/SetPlayerTeamPacket.cpp
index fe36bfff..a574067d 100644
--- a/Minecraft.World/SetPlayerTeamPacket.cpp
+++ b/Minecraft.World/SetPlayerTeamPacket.cpp
@@ -42,7 +42,7 @@ SetPlayerTeamPacket::SetPlayerTeamPacket(PlayerTeam *team, vector<wstring> *play
__debugbreak();
#endif
}
- if (playerNames == NULL || playerNames->empty())
+ if (playerNames == nullptr || playerNames->empty())
{
app.DebugPrintf("Players cannot be null/empty");
#ifndef _CONTENT_PACKAGE
diff --git a/Minecraft.World/SetPlayerTeamPacket.h b/Minecraft.World/SetPlayerTeamPacket.h
index f6df9da2..60364db5 100644
--- a/Minecraft.World/SetPlayerTeamPacket.h
+++ b/Minecraft.World/SetPlayerTeamPacket.h
@@ -30,6 +30,6 @@ public:
int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetPlayerTeamPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetPlayerTeamPacket>(); }
virtual int getId() { return 209; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetScorePacket.h b/Minecraft.World/SetScorePacket.h
index 5f800be6..24555973 100644
--- a/Minecraft.World/SetScorePacket.h
+++ b/Minecraft.World/SetScorePacket.h
@@ -25,6 +25,6 @@ public:
int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetScorePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetScorePacket>(); }
virtual int getId() { return 207; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetSpawnPositionPacket.h b/Minecraft.World/SetSpawnPositionPacket.h
index 3ba66af8..f90d3f5c 100644
--- a/Minecraft.World/SetSpawnPositionPacket.h
+++ b/Minecraft.World/SetSpawnPositionPacket.h
@@ -20,6 +20,6 @@ public:
virtual bool isAync();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetSpawnPositionPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetSpawnPositionPacket>(); }
virtual int getId() { return 6; }
}; \ No newline at end of file
diff --git a/Minecraft.World/SetTimePacket.h b/Minecraft.World/SetTimePacket.h
index a0fa2ad9..2e876388 100644
--- a/Minecraft.World/SetTimePacket.h
+++ b/Minecraft.World/SetTimePacket.h
@@ -21,6 +21,6 @@ public:
virtual bool isAync();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SetTimePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SetTimePacket>(); }
virtual int getId() { return 4; }
}; \ No newline at end of file
diff --git a/Minecraft.World/ShapedRecipy.cpp b/Minecraft.World/ShapedRecipy.cpp
index ee737321..7a0e85b0 100644
--- a/Minecraft.World/ShapedRecipy.cpp
+++ b/Minecraft.World/ShapedRecipy.cpp
@@ -52,18 +52,18 @@ bool ShapedRecipy::matches(shared_ptr<CraftingContainer> craftSlots, int xOffs,
for (int y = 0; y < 3; y++) {
int xs = x - xOffs;
int ys = y - yOffs;
- ItemInstance *expected = NULL;
+ ItemInstance *expected = nullptr;
if (xs >= 0 && ys >= 0 && xs < width && ys < height)
{
if (xFlip) expected = recipeItems[(width - xs - 1) + ys * width];
else expected = recipeItems[xs + ys * width];
}
shared_ptr<ItemInstance> item = craftSlots->getItem(x, y);
- if (item == NULL && expected == NULL)
+ if (item == nullptr && expected == nullptr)
{
continue;
}
- if ((item == NULL && expected != NULL) || (item != NULL && expected == NULL))
+ if ((item == nullptr && expected != nullptr) || (item != nullptr && expected == nullptr))
{
return false;
}
@@ -84,15 +84,15 @@ shared_ptr<ItemInstance> ShapedRecipy::assemble(shared_ptr<CraftingContainer> cr
{
shared_ptr<ItemInstance> result = getResultItem()->copy();
- if (_keepTag && craftSlots != NULL)
+ if (_keepTag && craftSlots != nullptr)
{
for (int i = 0; i < craftSlots->getContainerSize(); i++)
{
shared_ptr<ItemInstance> item = craftSlots->getItem(i);
- if (item != NULL && item->hasTag())
+ if (item != nullptr && item->hasTag())
{
- result->setTag((CompoundTag *) item->tag->copy());
+ result->setTag(static_cast<CompoundTag *>(item->tag->copy()));
}
}
}
@@ -117,7 +117,7 @@ bool ShapedRecipy::reqs(int iRecipe)
if (x < width && y < height)
{
ItemInstance *expected = recipeItems[x+y*width];
- if (expected!=NULL)
+ if (expected!=nullptr)
{
//printf("\tIngredient %d is %d\n",iCount++,expected->id);
}
@@ -159,7 +159,7 @@ void ShapedRecipy::reqs(INGREDIENTS_REQUIRED *pIngReq)
{
ItemInstance *expected = recipeItems[x+y*width];
- if (expected!=NULL)
+ if (expected!=nullptr)
{
int iAuxVal = expected->getAuxValue();
TempIngReq.uiGridA[x+y*3]=expected->id | iAuxVal<<24;
diff --git a/Minecraft.World/ShapelessRecipy.cpp b/Minecraft.World/ShapelessRecipy.cpp
index 0fee321c..8fab1b7e 100644
--- a/Minecraft.World/ShapelessRecipy.cpp
+++ b/Minecraft.World/ShapelessRecipy.cpp
@@ -73,7 +73,7 @@ shared_ptr<ItemInstance> ShapelessRecipy::assemble(shared_ptr<CraftingContainer>
int ShapelessRecipy::size()
{
- return (int)ingredients->size();
+ return static_cast<int>(ingredients->size());
}
// 4J-PB
diff --git a/Minecraft.World/SharedMonsterAttributes.cpp b/Minecraft.World/SharedMonsterAttributes.cpp
index 3ff84197..53c05008 100644
--- a/Minecraft.World/SharedMonsterAttributes.cpp
+++ b/Minecraft.World/SharedMonsterAttributes.cpp
@@ -70,7 +70,7 @@ void SharedMonsterAttributes::loadAttributes(BaseAttributeMap *attributes, ListT
CompoundTag *tag = list->get(i);
AttributeInstance *instance = attributes->getInstance(static_cast<eATTRIBUTE_ID>(tag->getInt(L"ID")));
- if (instance != NULL)
+ if (instance != nullptr)
{
loadAttribute(instance, tag);
}
@@ -93,7 +93,7 @@ void SharedMonsterAttributes::loadAttribute(AttributeInstance *instance, Compoun
{
AttributeModifier *modifier = loadAttributeModifier(list->get(i));
AttributeModifier *old = instance->getModifier(modifier->getId());
- if (old != NULL) instance->removeModifier(old);
+ if (old != nullptr) instance->removeModifier(old);
instance->addModifier(modifier);
}
}
@@ -101,6 +101,6 @@ void SharedMonsterAttributes::loadAttribute(AttributeInstance *instance, Compoun
AttributeModifier *SharedMonsterAttributes::loadAttributeModifier(CompoundTag *tag)
{
- eMODIFIER_ID id = (eMODIFIER_ID)tag->getInt(L"UUID");
+ eMODIFIER_ID id = static_cast<eMODIFIER_ID>(tag->getInt(L"UUID"));
return new AttributeModifier(id, tag->getDouble(L"Amount"), tag->getInt(L"Operation"));
} \ No newline at end of file
diff --git a/Minecraft.World/Sheep.cpp b/Minecraft.World/Sheep.cpp
index 32379c2a..f06308f4 100644
--- a/Minecraft.World/Sheep.cpp
+++ b/Minecraft.World/Sheep.cpp
@@ -65,9 +65,9 @@ Sheep::Sheep(Level *level) : Animal( level )
goalSelector.addGoal(7, new LookAtPlayerGoal(this, typeid(Player), 6));
goalSelector.addGoal(8, new RandomLookAroundGoal(this));
- container = shared_ptr<CraftingContainer>(new CraftingContainer(new SheepContainer(), 2, 1));
- container->setItem(0, shared_ptr<ItemInstance>( new ItemInstance(Item::dye_powder, 1, 0)));
- container->setItem(1, shared_ptr<ItemInstance>( new ItemInstance(Item::dye_powder, 1, 0)));
+ container = std::make_shared<CraftingContainer>(new SheepContainer(), 2, 1);
+ container->setItem(0, std::make_shared<ItemInstance>(Item::dye_powder, 1, 0));
+ container->setItem(1, std::make_shared<ItemInstance>(Item::dye_powder, 1, 0));
}
bool Sheep::useNewAi()
@@ -100,7 +100,7 @@ void Sheep::defineSynchedData()
Animal::defineSynchedData();
// sheared and color share a byte
- entityData->define(DATA_WOOL_ID, ((byte) 0)); //was new Byte((byte), 0)
+ entityData->define(DATA_WOOL_ID, static_cast<byte>(0)); //was new Byte((byte), 0)
}
void Sheep::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
@@ -108,7 +108,7 @@ void Sheep::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
if(!isSheared())
{
// killing a non-sheared sheep will drop a single block of cloth
- spawnAtLocation(shared_ptr<ItemInstance>( new ItemInstance(Tile::wool_Id, 1, getColor()) ), 0.0f);
+ spawnAtLocation(std::make_shared<ItemInstance>(Tile::wool_Id, 1, getColor()), 0.0f);
}
}
@@ -141,16 +141,16 @@ float Sheep::getHeadEatPositionScale(float a)
}
if (eatAnimationTick < 4)
{
- return ((float) eatAnimationTick - a) / 4.0f;
+ return (static_cast<float>(eatAnimationTick) - a) / 4.0f;
}
- return -((float) (eatAnimationTick - EAT_ANIMATION_TICKS) - a) / 4.0f;
+ return -(static_cast<float>(eatAnimationTick - EAT_ANIMATION_TICKS) - a) / 4.0f;
}
float Sheep::getHeadEatAngleScale(float a)
{
if (eatAnimationTick > 4 && eatAnimationTick <= (EAT_ANIMATION_TICKS - 4))
{
- float scale = ((float) (eatAnimationTick - 4) - a) / (float) (EAT_ANIMATION_TICKS - 8);
+ float scale = (static_cast<float>(eatAnimationTick - 4) - a) / static_cast<float>(EAT_ANIMATION_TICKS - 8);
return PI * .20f + PI * .07f * Mth::sin(scale * 28.7f);
}
if (eatAnimationTick > 0)
@@ -169,7 +169,7 @@ bool Sheep::mobInteract(shared_ptr<Player> player)
if (!player->isAllowedToInteract( shared_from_this() ))
return false; //Animal::interact(player);
- if (item != NULL && item->id == Item::shears->id && !isSheared() && !isBaby())
+ if (item != nullptr && item->id == Item::shears->id && !isSheared() && !isBaby())
{
if (!level->isClientSide)
{
@@ -177,7 +177,7 @@ bool Sheep::mobInteract(shared_ptr<Player> player)
int count = 1 + random->nextInt(3);
for (int i = 0; i < count; i++)
{
- shared_ptr<ItemEntity> ie = spawnAtLocation(shared_ptr<ItemInstance>( new ItemInstance(Tile::wool_Id, 1, getColor()) ), 1.0f);
+ shared_ptr<ItemEntity> ie = spawnAtLocation(std::make_shared<ItemInstance>(Tile::wool_Id, 1, getColor()), 1.0f);
ie->yd += random->nextFloat() * 0.05f;
ie->xd += (random->nextFloat() - random->nextFloat()) * 0.1f;
ie->zd += (random->nextFloat() - random->nextFloat()) * 0.1f;
@@ -196,7 +196,7 @@ void Sheep::addAdditonalSaveData(CompoundTag *tag)
{
Animal::addAdditonalSaveData(tag);
tag->putBoolean(L"Sheared", isSheared());
- tag->putByte(L"Color", (byte) getColor());
+ tag->putByte(L"Color", static_cast<byte>(getColor()));
}
void Sheep::readAdditionalSaveData(CompoundTag *tag)
@@ -234,7 +234,7 @@ int Sheep::getColor()
void Sheep::setColor(int color)
{
byte current = entityData->getByte(DATA_WOOL_ID);
- entityData->set(DATA_WOOL_ID, (byte) ((current & 0xf0) | (color & 0x0f)));
+ entityData->set(DATA_WOOL_ID, static_cast<byte>((current & 0xf0) | (color & 0x0f)));
}
bool Sheep::isSheared()
@@ -247,11 +247,11 @@ void Sheep::setSheared(bool value)
byte current = entityData->getByte(DATA_WOOL_ID);
if (value)
{
- entityData->set(DATA_WOOL_ID, (byte) (current | 0x10));
+ entityData->set(DATA_WOOL_ID, static_cast<byte>(current | 0x10));
}
else
{
- entityData->set(DATA_WOOL_ID, (byte) (current & ~0x10));
+ entityData->set(DATA_WOOL_ID, static_cast<byte>(current & ~0x10));
}
}
@@ -284,7 +284,7 @@ shared_ptr<AgableMob> Sheep::getBreedOffspring(shared_ptr<AgableMob> target)
if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) )
{
shared_ptr<Sheep> otherSheep = dynamic_pointer_cast<Sheep>( target );
- shared_ptr<Sheep> sheep = shared_ptr<Sheep>( new Sheep(level) );
+ shared_ptr<Sheep> sheep = std::make_shared<Sheep>(level);
int color = getOffspringColor(dynamic_pointer_cast<Animal>(shared_from_this()), otherSheep);
sheep->setColor(15 - color);
return sheep;
@@ -324,7 +324,7 @@ int Sheep::getOffspringColor(shared_ptr<Animal> animal, shared_ptr<Animal> partn
shared_ptr<ItemInstance> instance = Recipes::getInstance()->getItemFor(container, animal->level);
int color = 0;
- if (instance != NULL && instance->getItem()->id == Item::dye_powder_Id)
+ if (instance != nullptr && instance->getItem()->id == Item::dye_powder_Id)
{
color = instance->getAuxValue();
}
diff --git a/Minecraft.World/ShortTag.h b/Minecraft.World/ShortTag.h
index 989e1fb1..cbe0b55f 100644
--- a/Minecraft.World/ShortTag.h
+++ b/Minecraft.World/ShortTag.h
@@ -28,7 +28,7 @@ public:
{
if (Tag::equals(obj))
{
- ShortTag *o = (ShortTag *) obj;
+ ShortTag *o = static_cast<ShortTag *>(obj);
return data == o->data;
}
return false;
diff --git a/Minecraft.World/ShovelItem.cpp b/Minecraft.World/ShovelItem.cpp
index 8064cbe3..4b75cd85 100644
--- a/Minecraft.World/ShovelItem.cpp
+++ b/Minecraft.World/ShovelItem.cpp
@@ -3,7 +3,7 @@
#include "net.minecraft.world.level.tile.h"
#include "ShovelItem.h"
-TileArray *ShovelItem::diggables = NULL;
+TileArray *ShovelItem::diggables = nullptr;
void ShovelItem::staticCtor()
{
diff --git a/Minecraft.World/SignItem.cpp b/Minecraft.World/SignItem.cpp
index c9cb627e..a418fd34 100644
--- a/Minecraft.World/SignItem.cpp
+++ b/Minecraft.World/SignItem.cpp
@@ -49,7 +49,7 @@ bool SignItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> playe
instance->count--;
shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>( level->getTileEntity(x, y, z) );
- if (ste != NULL) player->openTextEdit(ste);
+ if (ste != nullptr) player->openTextEdit(ste);
// 4J-JEV: Hook for durango 'BlockPlaced' event.
player->awardStat(
diff --git a/Minecraft.World/SignTile.cpp b/Minecraft.World/SignTile.cpp
index 52d62a60..15be23db 100644
--- a/Minecraft.World/SignTile.cpp
+++ b/Minecraft.World/SignTile.cpp
@@ -26,7 +26,7 @@ void SignTile::updateDefaultShape()
AABB *SignTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
AABB *SignTile::getTileAABB(Level *level, int x, int y, int z)
@@ -79,7 +79,7 @@ shared_ptr<TileEntity> SignTile::newTileEntity(Level *level)
{
//try {
// 4J Stu - For some reason the newInstance wasn't working right, but doing it like the other TileEntities is fine
- return shared_ptr<TileEntity>( new SignTileEntity() );
+ return std::make_shared<SignTileEntity>();
//return dynamic_pointer_cast<TileEntity>( clas->newInstance() );
//} catch (Exception e) {
// TODO 4J Stu - Exception handling
diff --git a/Minecraft.World/SignTileEntity.cpp b/Minecraft.World/SignTileEntity.cpp
index dc189102..598621eb 100644
--- a/Minecraft.World/SignTileEntity.cpp
+++ b/Minecraft.World/SignTileEntity.cpp
@@ -93,7 +93,7 @@ shared_ptr<Packet> SignTileEntity::getUpdatePacket()
{
copy[i] = m_wsmessages[i];
}
- return shared_ptr<SignUpdatePacket>( new SignUpdatePacket(x, y, z, m_bVerified, m_bCensored, copy) );
+ return std::make_shared<SignUpdatePacket>(x, y, z, m_bVerified, m_bCensored, copy);
}
bool SignTileEntity::isEditable()
@@ -181,7 +181,7 @@ void SignTileEntity::SetMessage(int iIndex,wstring &wsText)
int SignTileEntity::StringVerifyCallback(LPVOID lpParam,STRING_VERIFY_RESPONSE *pResults)
{
// results will be in m_pStringVerifyResponse
- SignTileEntity *pClass=(SignTileEntity *)lpParam;
+ SignTileEntity *pClass=static_cast<SignTileEntity *>(lpParam);
pClass->m_bVerified=true;
pClass->m_bCensored=false;
@@ -195,7 +195,7 @@ int SignTileEntity::StringVerifyCallback(LPVOID lpParam,STRING_VERIFY_RESPONSE *
if(!pClass->level->isClientSide)
{
- ServerLevel *serverLevel = (ServerLevel *)pClass->level;
+ ServerLevel *serverLevel = static_cast<ServerLevel *>(pClass->level);
// 4J Stu - This callback gets called on the main thread, but tried to access things on the server thread. Change to go through the protected method.
//pClass->level->sendTileUpdated(pClass->x, pClass->y, pClass->z);
serverLevel->queueSendTileUpdate(pClass->x, pClass->y, pClass->z);
@@ -207,7 +207,7 @@ int SignTileEntity::StringVerifyCallback(LPVOID lpParam,STRING_VERIFY_RESPONSE *
// 4J Added
shared_ptr<TileEntity> SignTileEntity::clone()
{
- shared_ptr<SignTileEntity> result = shared_ptr<SignTileEntity>( new SignTileEntity() );
+ shared_ptr<SignTileEntity> result = std::make_shared<SignTileEntity>();
TileEntity::clone(result);
result->m_wsmessages[0] = m_wsmessages[0];
diff --git a/Minecraft.World/SignUpdatePacket.cpp b/Minecraft.World/SignUpdatePacket.cpp
index 7b3a3217..10cc223e 100644
--- a/Minecraft.World/SignUpdatePacket.cpp
+++ b/Minecraft.World/SignUpdatePacket.cpp
@@ -66,6 +66,6 @@ int SignUpdatePacket::getEstimatedSize()
l+=sizeof(byte);
for (int i = 0; i < MAX_SIGN_LINES; i++)
- l += (int)lines[i].length();
+ l += static_cast<int>(lines[i].length());
return l;
}
diff --git a/Minecraft.World/SignUpdatePacket.h b/Minecraft.World/SignUpdatePacket.h
index 80cc2968..f44f4dde 100644
--- a/Minecraft.World/SignUpdatePacket.h
+++ b/Minecraft.World/SignUpdatePacket.h
@@ -21,6 +21,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new SignUpdatePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<SignUpdatePacket>(); }
virtual int getId() { return 130; }
}; \ No newline at end of file
diff --git a/Minecraft.World/Silverfish.cpp b/Minecraft.World/Silverfish.cpp
index 5cd4c77e..98f559c9 100644
--- a/Minecraft.World/Silverfish.cpp
+++ b/Minecraft.World/Silverfish.cpp
@@ -72,7 +72,7 @@ int Silverfish::getDeathSound()
bool Silverfish::hurt(DamageSource *source, float dmg)
{
if (isInvulnerable()) return false;
- if (lookForFriends <= 0 && (dynamic_cast<EntityDamageSource *>(source) != NULL || source == DamageSource::magic))
+ if (lookForFriends <= 0 && (dynamic_cast<EntityDamageSource *>(source) != nullptr || source == DamageSource::magic))
{
// look for friends
lookForFriends = 20;
@@ -173,7 +173,7 @@ void Silverfish::serverAiStep()
}
}
- if (attackTarget == NULL && !isPathFinding())
+ if (attackTarget == nullptr && !isPathFinding())
{
// if the silverfish isn't doing anything special, it will merge
// with any rock tile it is nearby
@@ -193,7 +193,7 @@ void Silverfish::serverAiStep()
}
}
- else if (attackTarget != NULL && !isPathFinding())
+ else if (attackTarget != nullptr && !isPathFinding())
{
attackTarget = nullptr;
}
@@ -216,7 +216,7 @@ bool Silverfish::canSpawn()
if (Monster::canSpawn())
{
shared_ptr<Player> nearestPlayer = level->getNearestPlayer(shared_from_this(), 5.0);
- return nearestPlayer == NULL;
+ return nearestPlayer == nullptr;
}
return false;
}
diff --git a/Minecraft.World/SimpleContainer.cpp b/Minecraft.World/SimpleContainer.cpp
index a5f551e2..87d11a70 100644
--- a/Minecraft.World/SimpleContainer.cpp
+++ b/Minecraft.World/SimpleContainer.cpp
@@ -13,12 +13,12 @@ SimpleContainer::SimpleContainer(int name, wstring stringName, bool customName,
this->size = size;
items = new ItemInstanceArray( size );
- listeners = NULL;
+ listeners = nullptr;
}
void SimpleContainer::addListener(net_minecraft_world::ContainerListener *listener)
{
- if (listeners == NULL) listeners = new vector<net_minecraft_world::ContainerListener *>();
+ if (listeners == nullptr) listeners = new vector<net_minecraft_world::ContainerListener *>();
listeners->push_back(listener);
}
@@ -43,7 +43,7 @@ shared_ptr<ItemInstance> SimpleContainer::getItem(unsigned int slot)
shared_ptr<ItemInstance> SimpleContainer::removeItem(unsigned int slot, int count)
{
- if ((*items)[slot] != NULL) {
+ if ((*items)[slot] != nullptr) {
if ((*items)[slot]->count <= count)
{
shared_ptr<ItemInstance> item = (*items)[slot];
@@ -64,7 +64,7 @@ shared_ptr<ItemInstance> SimpleContainer::removeItem(unsigned int slot, int coun
shared_ptr<ItemInstance> SimpleContainer::removeItemNoUpdate(int slot)
{
- if ((*items)[slot] != NULL)
+ if ((*items)[slot] != nullptr)
{
shared_ptr<ItemInstance> item = (*items)[slot];
(*items)[slot] = nullptr;
@@ -76,7 +76,7 @@ shared_ptr<ItemInstance> SimpleContainer::removeItemNoUpdate(int slot)
void SimpleContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
(*items)[slot] = item;
- if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize();
+ if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize();
setChanged();
}
@@ -113,7 +113,7 @@ int SimpleContainer::getMaxStackSize() const
void SimpleContainer::setChanged()
{
- if (listeners != NULL) for (unsigned int i = 0; i < listeners->size(); i++)
+ if (listeners != nullptr) for (unsigned int i = 0; i < listeners->size(); i++)
{
listeners->at(i)->containerChanged();//shared_from_this());
}
diff --git a/Minecraft.World/SimplexNoise.cpp b/Minecraft.World/SimplexNoise.cpp
index 469e0b41..35b86add 100644
--- a/Minecraft.World/SimplexNoise.cpp
+++ b/Minecraft.World/SimplexNoise.cpp
@@ -49,7 +49,7 @@ SimplexNoise::~SimplexNoise()
int SimplexNoise::fastfloor(double x)
{
- return x > 0 ? (int) x : (int) x - 1;
+ return x > 0 ? static_cast<int>(x) : static_cast<int>(x) - 1;
}
double SimplexNoise::dot(int *g, double x, double y)
diff --git a/Minecraft.World/SitGoal.cpp b/Minecraft.World/SitGoal.cpp
index b79b2df7..7b04a5f6 100644
--- a/Minecraft.World/SitGoal.cpp
+++ b/Minecraft.World/SitGoal.cpp
@@ -21,9 +21,9 @@ bool SitGoal::canUse()
if (!mob->onGround) return false;
shared_ptr<LivingEntity> owner = dynamic_pointer_cast<LivingEntity>( mob->getOwner() );
- if (owner == NULL) return true; // owner not on level
+ if (owner == nullptr) return true; // owner not on level
- if (mob->distanceToSqr(owner) < FollowOwnerGoal::TeleportDistance * FollowOwnerGoal::TeleportDistance && owner->getLastHurtByMob() != NULL) return false;
+ if (mob->distanceToSqr(owner) < FollowOwnerGoal::TeleportDistance * FollowOwnerGoal::TeleportDistance && owner->getLastHurtByMob() != nullptr) return false;
return _wantToSit;
}
diff --git a/Minecraft.World/Skeleton.cpp b/Minecraft.World/Skeleton.cpp
index 9afb95c6..cc325b97 100644
--- a/Minecraft.World/Skeleton.cpp
+++ b/Minecraft.World/Skeleton.cpp
@@ -43,7 +43,7 @@ Skeleton::Skeleton(Level *level) : Monster( level )
targetSelector.addGoal(1, new HurtByTargetGoal(this, false));
targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, typeid(Player), 0, true));
- if (level != NULL && !level->isClientSide) reassessWeaponGoal();
+ if (level != nullptr && !level->isClientSide) reassessWeaponGoal();
}
Skeleton::~Skeleton()
@@ -63,7 +63,7 @@ void Skeleton::defineSynchedData()
{
Monster::defineSynchedData();
- entityData->define(DATA_TYPE_ID, (byte) TYPE_DEFAULT);
+ entityData->define(DATA_TYPE_ID, static_cast<byte>(TYPE_DEFAULT));
}
bool Skeleton::useNewAi()
@@ -114,12 +114,12 @@ void Skeleton::aiStep()
if (level->isDay() && !level->isClientSide)
{
float br = getBrightness(1);
- if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && level->canSeeSky(Mth::floor(x), (int)floor( y + 0.5 ), Mth::floor(z)))
+ if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && level->canSeeSky(Mth::floor(x), static_cast<int>(floor(y + 0.5)), Mth::floor(z)))
{
bool burn = true;
shared_ptr<ItemInstance> helmet = getCarried(SLOT_HELM);
- if (helmet != NULL)
+ if (helmet != nullptr)
{
if (helmet->isDamageableItem())
{
@@ -155,7 +155,7 @@ void Skeleton::rideTick()
{
Monster::rideTick();
- if ( riding != NULL && riding->instanceof(eTYPE_PATHFINDER_MOB) )
+ if ( riding != nullptr && riding->instanceof(eTYPE_PATHFINDER_MOB) )
{
yBodyRot = dynamic_pointer_cast<PathfinderMob>(riding)->yBodyRot;
}
@@ -166,7 +166,7 @@ void Skeleton::die(DamageSource *source)
{
Monster::die(source);
- if ( source->getDirectEntity() != NULL && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER) )
+ if ( source->getDirectEntity() != nullptr && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) )
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>( source->getEntity() );
@@ -217,7 +217,7 @@ void Skeleton::dropRareDeathLoot(int rareLootLevel)
{
if (getSkeletonType() == TYPE_WITHER)
{
- spawnAtLocation( shared_ptr<ItemInstance>( new ItemInstance(Item::skull_Id, 1, SkullTileEntity::TYPE_WITHER) ), 0);
+ spawnAtLocation(std::make_shared<ItemInstance>(Item::skull_Id, 1, SkullTileEntity::TYPE_WITHER), 0);
}
}
@@ -225,19 +225,19 @@ void Skeleton::populateDefaultEquipmentSlots()
{
Monster::populateDefaultEquipmentSlots();
- setEquippedSlot(SLOT_WEAPON, shared_ptr<ItemInstance>( new ItemInstance(Item::bow)));
+ setEquippedSlot(SLOT_WEAPON, std::make_shared<ItemInstance>(Item::bow));
}
MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData /*= 0*/) // 4J Added extraData param
{
groupData = Monster::finalizeMobSpawn(groupData);
- if ( dynamic_cast<HellDimension *>(level->dimension) != NULL && getRandom()->nextInt(5) > 0)
+ if ( dynamic_cast<HellDimension *>(level->dimension) != nullptr && getRandom()->nextInt(5) > 0)
{
goalSelector.addGoal(4, meleeGoal, false);
setSkeletonType(TYPE_WITHER);
- setEquippedSlot(SLOT_WEAPON, shared_ptr<ItemInstance>( new ItemInstance(Item::sword_stone)));
+ setEquippedSlot(SLOT_WEAPON, std::make_shared<ItemInstance>(Item::sword_stone));
getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->setBaseValue(4);
}
else
@@ -250,12 +250,12 @@ MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData
setCanPickUpLoot(random->nextFloat() < MAX_PICKUP_LOOT_CHANCE * level->getDifficulty(x, y, z));
- if (getCarried(SLOT_HELM) == NULL)
+ if (getCarried(SLOT_HELM) == nullptr)
{
if (Calendar::GetMonth() + 1 == 10 && Calendar::GetDayOfMonth() == 31 && random->nextFloat() < 0.25f)
{
// Halloween! OooOOo! 25% of all skeletons/zombies can wear pumpkins on their heads.
- setEquippedSlot(SLOT_HELM, shared_ptr<ItemInstance>( new ItemInstance(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin)));
+ setEquippedSlot(SLOT_HELM, std::make_shared<ItemInstance>(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin));
dropChances[SLOT_HELM] = 0;
}
}
@@ -269,7 +269,7 @@ void Skeleton::reassessWeaponGoal()
shared_ptr<ItemInstance> carried = getCarriedItem();
- if (carried != NULL && carried->id == Item::bow_Id)
+ if (carried != nullptr && carried->id == Item::bow_Id)
{
goalSelector.addGoal(4, bowGoal, false);
}
@@ -281,7 +281,7 @@ void Skeleton::reassessWeaponGoal()
void Skeleton::performRangedAttack(shared_ptr<LivingEntity> target, float power)
{
- shared_ptr<Arrow> arrow = shared_ptr<Arrow>( new Arrow(level, dynamic_pointer_cast<LivingEntity>(shared_from_this()), target, 1.60f, 14 - (level->difficulty * 4)) );
+ shared_ptr<Arrow> arrow = std::make_shared<Arrow>(level, dynamic_pointer_cast<LivingEntity>(shared_from_this()), target, 1.60f, 14 - (level->difficulty * 4));
int damageBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowBonus->id, getCarriedItem());
int knockbackBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowKnockback->id, getCarriedItem());
@@ -289,7 +289,7 @@ void Skeleton::performRangedAttack(shared_ptr<LivingEntity> target, float power)
if (damageBonus > 0)
{
- arrow->setBaseDamage(arrow->getBaseDamage() + (double) damageBonus * .5 + .5);
+ arrow->setBaseDamage(arrow->getBaseDamage() + static_cast<double>(damageBonus) * .5 + .5);
}
if (knockbackBonus > 0)
{
@@ -311,7 +311,7 @@ int Skeleton::getSkeletonType()
void Skeleton::setSkeletonType(int type)
{
- entityData->set(DATA_TYPE_ID, (byte) type);
+ entityData->set(DATA_TYPE_ID, static_cast<byte>(type));
fireImmune = type == TYPE_WITHER;
if (type == TYPE_WITHER)
@@ -340,7 +340,7 @@ void Skeleton::readAdditionalSaveData(CompoundTag *tag)
void Skeleton::addAdditonalSaveData(CompoundTag *entityTag)
{
Monster::addAdditonalSaveData(entityTag);
- entityTag->putByte(L"SkeletonType", (byte) getSkeletonType());
+ entityTag->putByte(L"SkeletonType", static_cast<byte>(getSkeletonType()));
}
void Skeleton::setEquippedSlot(int slot, shared_ptr<ItemInstance> item)
diff --git a/Minecraft.World/SkullItem.cpp b/Minecraft.World/SkullItem.cpp
index 8fabc3cd..383f226f 100644
--- a/Minecraft.World/SkullItem.cpp
+++ b/Minecraft.World/SkullItem.cpp
@@ -48,7 +48,7 @@ bool SkullItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> play
shared_ptr<TileEntity> skullTE = level->getTileEntity(x, y, z);
shared_ptr<SkullTileEntity> skull = dynamic_pointer_cast<SkullTileEntity>(skullTE);
- if (skull != NULL)
+ if (skull != nullptr)
{
wstring extra = L"";
if (instance->hasTag() && instance->getTag()->contains(L"SkullOwner"))
@@ -57,7 +57,7 @@ bool SkullItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> play
}
skull->setSkullType(instance->getAuxValue(), extra);
skull->setRotation(rot);
- ((SkullTile *) Tile::skull)->checkMobSpawn(level, x, y, z, skull);
+ static_cast<SkullTile *>(Tile::skull)->checkMobSpawn(level, x, y, z, skull);
}
instance->count--;
diff --git a/Minecraft.World/SkullTile.cpp b/Minecraft.World/SkullTile.cpp
index 92ce7807..b5eca373 100644
--- a/Minecraft.World/SkullTile.cpp
+++ b/Minecraft.World/SkullTile.cpp
@@ -67,7 +67,7 @@ void SkullTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<Living
shared_ptr<TileEntity> SkullTile::newTileEntity(Level *level)
{
- return shared_ptr<SkullTileEntity>(new SkullTileEntity());
+ return std::make_shared<SkullTileEntity>();
}
int SkullTile::cloneTileId(Level *level, int x, int y, int z)
@@ -79,7 +79,7 @@ int SkullTile::cloneTileData(Level *level, int x, int y, int z)
{
shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
shared_ptr<SkullTileEntity> skull = dynamic_pointer_cast<SkullTileEntity>(tileEntity);
- if (skull != NULL)
+ if (skull != nullptr)
{
return skull->getSkullType();
}
@@ -113,7 +113,7 @@ void SkullTile::onRemove(Level *level, int x, int y, int z, int id, int data)
if (level->isClientSide) return;
if ((data & NO_DROP_BIT) == 0)
{
- shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>(new ItemInstance(Item::skull_Id, 1, cloneTileData(level, x, y, z)));
+ shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(Item::skull_Id, 1, cloneTileData(level, x, y, z));
shared_ptr<SkullTileEntity> entity = dynamic_pointer_cast<SkullTileEntity>(level->getTileEntity(x, y, z));
if (entity->getSkullType() == SkullTileEntity::TYPE_CHAR && !entity->getExtraType().empty())
@@ -166,7 +166,7 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptr<Skul
if (level->canCreateMore(eTYPE_WITHERBOSS, Level::eSpawnType_Egg))
{
// 4J: Removed !isClientSide check because there's one earlier on
- shared_ptr<WitherBoss> witherBoss = shared_ptr<WitherBoss>( new WitherBoss(level) );
+ shared_ptr<WitherBoss> witherBoss = std::make_shared<WitherBoss>(level);
witherBoss->moveTo(x + 0.5, y - 1.45, z + zo + 1.5, 90, 0);
witherBoss->yBodyRot = 90;
witherBoss->makeInvulnerable();
@@ -180,8 +180,8 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptr<Skul
Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x, y - 2, z + zo + 1, 0, 0);
Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x, y - 1, z + zo + 2, 0, 0);
- shared_ptr<ItemInstance> itemInstance = shared_ptr<ItemInstance>(new ItemInstance(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER));
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>(new ItemEntity(level, x, y, z + zo + 1, itemInstance) );
+ shared_ptr<ItemInstance> itemInstance = std::make_shared<ItemInstance>(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER);
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x, y, z + zo + 1, itemInstance);
level->addEntity(itemEntity);
}
@@ -229,7 +229,7 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptr<Skul
if (level->canCreateMore(eTYPE_WITHERBOSS, Level::eSpawnType_Egg))
{
// 4J: Removed !isClientSide check because there's one earlier on
- shared_ptr<WitherBoss> witherBoss = shared_ptr<WitherBoss>( new WitherBoss(level) );
+ shared_ptr<WitherBoss> witherBoss = std::make_shared<WitherBoss>(level);
witherBoss->moveTo(x + xo + 1.5, y - 1.45, z + .5, 0, 0);
witherBoss->makeInvulnerable();
level->addEntity(witherBoss);
@@ -242,8 +242,8 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptr<Skul
Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x + xo + 1, y - 2, z, 0, 0);
Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x + xo + 2, y - 1, z, 0, 0);
- shared_ptr<ItemInstance> itemInstance = shared_ptr<ItemInstance>(new ItemInstance(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER));
- shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>(new ItemEntity(level, x + xo + 1, y, z, itemInstance) );
+ shared_ptr<ItemInstance> itemInstance = std::make_shared<ItemInstance>(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER);
+ shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo + 1, y, z, itemInstance);
level->addEntity(itemEntity);
}
@@ -274,7 +274,7 @@ bool SkullTile::isSkullAt(Level *level, int x, int y, int z, int skullType)
}
shared_ptr<TileEntity> te = level->getTileEntity(x, y, z);
shared_ptr<SkullTileEntity> skull = dynamic_pointer_cast<SkullTileEntity>(te);
- if (skull == NULL)
+ if (skull == nullptr)
{
return false;
}
diff --git a/Minecraft.World/SkullTileEntity.cpp b/Minecraft.World/SkullTileEntity.cpp
index ea19b446..3937bec4 100644
--- a/Minecraft.World/SkullTileEntity.cpp
+++ b/Minecraft.World/SkullTileEntity.cpp
@@ -13,8 +13,8 @@ SkullTileEntity::SkullTileEntity()
void SkullTileEntity::save(CompoundTag *tag)
{
TileEntity::save(tag);
- tag->putByte(L"SkullType", (BYTE) (skullType & 0xff));
- tag->putByte(L"Rot", (BYTE) (rotation & 0xff));
+ tag->putByte(L"SkullType", static_cast<BYTE>(skullType & 0xff));
+ tag->putByte(L"Rot", static_cast<BYTE>(rotation & 0xff));
tag->putString(L"ExtraType", extraType);
}
@@ -30,7 +30,7 @@ shared_ptr<Packet> SkullTileEntity::getUpdatePacket()
{
CompoundTag *tag = new CompoundTag();
save(tag);
- return shared_ptr<TileEntityDataPacket>(new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_SKULL, tag));
+ return std::make_shared<TileEntityDataPacket>(x, y, z, TileEntityDataPacket::TYPE_SKULL, tag);
}
void SkullTileEntity::setSkullType(int skullType, const wstring &extra)
@@ -62,7 +62,7 @@ wstring SkullTileEntity::getExtraType()
// 4J Added
shared_ptr<TileEntity> SkullTileEntity::clone()
{
- shared_ptr<SkullTileEntity> result = shared_ptr<SkullTileEntity>( new SkullTileEntity() );
+ shared_ptr<SkullTileEntity> result = std::make_shared<SkullTileEntity>();
TileEntity::clone(result);
result->skullType = skullType;
diff --git a/Minecraft.World/SkyIslandDimension.cpp b/Minecraft.World/SkyIslandDimension.cpp
index aa68bd5e..354630eb 100644
--- a/Minecraft.World/SkyIslandDimension.cpp
+++ b/Minecraft.World/SkyIslandDimension.cpp
@@ -23,7 +23,7 @@ float SkyIslandDimension::getTimeOfDay(int64_t time, float a) const
float *SkyIslandDimension::getSunriseColor(float td, float a)
{
- return NULL;
+ return nullptr;
}
Vec3 *SkyIslandDimension::getFogColor(float td, float a) const
diff --git a/Minecraft.World/Slime.cpp b/Minecraft.World/Slime.cpp
index eaeea25a..de76ef06 100644
--- a/Minecraft.World/Slime.cpp
+++ b/Minecraft.World/Slime.cpp
@@ -47,12 +47,12 @@ void Slime::defineSynchedData()
{
Mob::defineSynchedData();
- entityData->define(ID_SIZE, (byte) 1);
+ entityData->define(ID_SIZE, static_cast<byte>(1));
}
void Slime::setSize(int size)
{
- entityData->set(ID_SIZE, (byte) size);
+ entityData->set(ID_SIZE, static_cast<byte>(size));
setSize(0.6f * size, 0.6f * size);
setPos(x, y, z);
getAttribute(SharedMonsterAttributes::MAX_HEALTH)->setBaseValue(size * size);
@@ -135,14 +135,14 @@ void Slime::serverAiStep()
{
checkDespawn();
shared_ptr<Player> 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;
}
@@ -155,7 +155,7 @@ void Slime::serverAiStep()
// 4J Removed TU7 to bring forward change to fix lava slime render in MP
//targetSquish = 1;
xxa = 1 - random->nextFloat() * 2;
- yya = (float) 1 * getSize();
+ yya = static_cast<float>(1) * getSize();
}
else
{
@@ -179,7 +179,7 @@ int Slime::getJumpDelay()
shared_ptr<Slime> Slime::createChild()
{
- return shared_ptr<Slime>( new Slime(level) );
+ return std::make_shared<Slime>(level);
}
void Slime::remove()
diff --git a/Minecraft.World/Slot.cpp b/Minecraft.World/Slot.cpp
index a5a53a48..2f42a27d 100644
--- a/Minecraft.World/Slot.cpp
+++ b/Minecraft.World/Slot.cpp
@@ -15,7 +15,7 @@ Slot::Slot(shared_ptr<Container> container, int slot, int x, int y) : container(
void Slot::onQuickCraft(shared_ptr<ItemInstance> picked, shared_ptr<ItemInstance> original)
{
- if (picked == NULL || original == NULL)
+ if (picked == nullptr || original == nullptr)
{
return;
}
@@ -44,14 +44,14 @@ void Slot::swap(Slot *other)
shared_ptr<ItemInstance> item1 = container->getItem(slot);
shared_ptr<ItemInstance> item2 = other->container->getItem(other->slot);
- if (item1 != NULL && item1->count > other->getMaxStackSize())
+ if (item1 != nullptr && item1->count > other->getMaxStackSize())
{
- if (item2 != NULL) return;
+ if (item2 != nullptr) return;
item2 = item1->remove(item1->count - other->getMaxStackSize());
}
- if (item2 != NULL && item2->count > getMaxStackSize())
+ if (item2 != nullptr && item2->count > getMaxStackSize())
{
- if (item1 != NULL) return;
+ if (item1 != nullptr) return;
item1 = item2->remove(item2->count - getMaxStackSize());
}
other->container->setItem(other->slot, item1);
@@ -77,7 +77,7 @@ shared_ptr<ItemInstance> Slot::getItem()
bool Slot::hasItem()
{
- return getItem() != NULL;
+ return getItem() != nullptr;
}
void Slot::set(shared_ptr<ItemInstance> item)
@@ -98,7 +98,7 @@ int Slot::getMaxStackSize() const
Icon *Slot::getNoItemIcon()
{
- return NULL;
+ return nullptr;
}
shared_ptr<ItemInstance> Slot::remove(int c)
@@ -125,7 +125,7 @@ bool Slot::mayCombine(shared_ptr<ItemInstance> second)
{
shared_ptr<ItemInstance> first = getItem();
- if(first == NULL || second == NULL) return false;
+ if(first == nullptr || second == nullptr) return false;
ArmorItem *thisItem = dynamic_cast<ArmorItem *>(first->getItem());
if(thisItem)
@@ -135,7 +135,7 @@ bool Slot::mayCombine(shared_ptr<ItemInstance> second)
return thisIsDyableArmor && itemIsDye;
}
// 4J Stu - This condition taken from Recipes::getItemFor to repair items, but added the damaged check to skip when the result is pointless
- else if (first != NULL && second != NULL && first->id == second->id && first->count == 1 && second->count == 1 && Item::items[first->id]->canBeDepleted() && (first->isDamaged() || second->isDamaged()) )
+ else if (first != nullptr && second != nullptr && first->id == second->id && first->count == 1 && second->count == 1 && Item::items[first->id]->canBeDepleted() && (first->isDamaged() || second->isDamaged()) )
{
// 4J Stu - Don't allow combinining enchanted items, the enchantment will be lost. They can use the anvil for this
return !first->isEnchanted() && !second->isEnchanted();
@@ -148,7 +148,7 @@ shared_ptr<ItemInstance> Slot::combine(shared_ptr<ItemInstance> item)
shared_ptr<ItemInstance> result = nullptr;
shared_ptr<ItemInstance> first = getItem();
- shared_ptr<CraftingContainer> craftSlots = shared_ptr<CraftingContainer>( new CraftingContainer(NULL, 2, 2) );
+ shared_ptr<CraftingContainer> craftSlots = std::make_shared<CraftingContainer>(nullptr, 2, 2);
craftSlots->setItem(0, item);
craftSlots->setItem(1, first);
@@ -159,7 +159,7 @@ shared_ptr<ItemInstance> Slot::combine(shared_ptr<ItemInstance> item)
}
else
{
- result = Recipes::getInstance()->getItemFor(craftSlots, NULL);
+ result = Recipes::getInstance()->getItemFor(craftSlots, nullptr);
}
craftSlots->setItem(0, nullptr);
diff --git a/Minecraft.World/SmallFireball.cpp b/Minecraft.World/SmallFireball.cpp
index 30f7a0b2..2475f5dc 100644
--- a/Minecraft.World/SmallFireball.cpp
+++ b/Minecraft.World/SmallFireball.cpp
@@ -25,7 +25,7 @@ void SmallFireball::onHit(HitResult *res)
{
if (!level->isClientSide)
{
- if (res->entity != NULL)
+ if (res->entity != nullptr)
{
DamageSource *damageSource = DamageSource::fireball(dynamic_pointer_cast<Fireball>(shared_from_this()),owner);
if (!res->entity->isFireImmune() && res->entity->hurt(damageSource, 5))
diff --git a/Minecraft.World/SmoothStoneBrickTile.cpp b/Minecraft.World/SmoothStoneBrickTile.cpp
index 22fb6df5..a42af97b 100644
--- a/Minecraft.World/SmoothStoneBrickTile.cpp
+++ b/Minecraft.World/SmoothStoneBrickTile.cpp
@@ -12,7 +12,7 @@ const unsigned int SmoothStoneBrickTile::SMOOTH_STONE_BRICK_NAMES[SMOOTH_STONE_B
SmoothStoneBrickTile::SmoothStoneBrickTile(int id) : Tile(id, Material::stone)
{
- icons = NULL;
+ icons = nullptr;
}
Icon *SmoothStoneBrickTile::getTexture(int face, int data)
diff --git a/Minecraft.World/SmoothZoomLayer.cpp b/Minecraft.World/SmoothZoomLayer.cpp
index 2df34a3b..60fd2664 100644
--- a/Minecraft.World/SmoothZoomLayer.cpp
+++ b/Minecraft.World/SmoothZoomLayer.cpp
@@ -55,7 +55,7 @@ shared_ptr<Layer>SmoothZoomLayer::zoom(int64_t seed, shared_ptr<Layer>sup, int c
shared_ptr<Layer>result = sup;
for (int i = 0; i < count; i++)
{
- result = shared_ptr<Layer>(new SmoothZoomLayer(seed + i, result));
+ result = std::make_shared<SmoothZoomLayer>(seed + i, result);
}
return result;
} \ No newline at end of file
diff --git a/Minecraft.World/SnowMan.cpp b/Minecraft.World/SnowMan.cpp
index 6c78b56f..05ead6a6 100644
--- a/Minecraft.World/SnowMan.cpp
+++ b/Minecraft.World/SnowMan.cpp
@@ -100,7 +100,7 @@ void SnowMan::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
void SnowMan::performRangedAttack(shared_ptr<LivingEntity> target, float power)
{
- shared_ptr<Snowball> snowball = shared_ptr<Snowball>(new Snowball(level, dynamic_pointer_cast<LivingEntity>(shared_from_this())));
+ shared_ptr<Snowball> snowball = std::make_shared<Snowball>(level, dynamic_pointer_cast<LivingEntity>(shared_from_this()));
double xd = target->x - x;
double yd = (target->y + target->getHeadHeight() - 1.1f) - snowball->y;
double zd = target->z - z;
diff --git a/Minecraft.World/Snowball.cpp b/Minecraft.World/Snowball.cpp
index 6588ac96..bb873b20 100644
--- a/Minecraft.World/Snowball.cpp
+++ b/Minecraft.World/Snowball.cpp
@@ -31,7 +31,7 @@ Snowball::Snowball(Level *level, double x, double y, double z) : Throwable(level
void Snowball::onHit(HitResult *res)
{
- if (res->entity != NULL)
+ if (res->entity != nullptr)
{
int damage = 0;
if ( res->entity->instanceof(eTYPE_BLAZE) )
diff --git a/Minecraft.World/SnowballItem.cpp b/Minecraft.World/SnowballItem.cpp
index 0149e68d..afb190d8 100644
--- a/Minecraft.World/SnowballItem.cpp
+++ b/Minecraft.World/SnowballItem.cpp
@@ -18,6 +18,6 @@ shared_ptr<ItemInstance> SnowballItem::use(shared_ptr<ItemInstance> instance, Le
instance->count--;
}
level->playEntitySound((shared_ptr<Entity> ) player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f));
- if (!level->isClientSide) level->addEntity( shared_ptr<Snowball>( new Snowball(level, player) ) );
+ if (!level->isClientSide) level->addEntity(std::make_shared<Snowball>(level, player));
return instance;
} \ No newline at end of file
diff --git a/Minecraft.World/Socket.cpp b/Minecraft.World/Socket.cpp
index 107fd884..2d5b257d 100644
--- a/Minecraft.World/Socket.cpp
+++ b/Minecraft.World/Socket.cpp
@@ -14,7 +14,7 @@ CRITICAL_SECTION Socket::s_hostQueueLock[2];
std::queue<byte> Socket::s_hostQueue[2];
Socket::SocketOutputStreamLocal *Socket::s_hostOutStream[2];
Socket::SocketInputStreamLocal *Socket::s_hostInStream[2];
-ServerConnection *Socket::s_serverConnection = NULL;
+ServerConnection *Socket::s_serverConnection = nullptr;
void Socket::Initialise(ServerConnection *serverConnection)
{
@@ -67,7 +67,7 @@ Socket::Socket(bool response)
{
m_endClosed[i] = false;
}
- m_socketClosedEvent = NULL;
+ m_socketClosedEvent = nullptr;
createdOk = true;
networkPlayerSmallId = g_NetworkManager.GetHostPlayer()->GetSmallId();
}
@@ -80,8 +80,8 @@ Socket::Socket(INetworkPlayer *player, bool response /* = false*/, bool hostLoca
for( int i = 0; i < 2; i++ )
{
InitializeCriticalSection(&m_queueLockNetwork[i]);
- m_inputStream[i] = NULL;
- m_outputStream[i] = NULL;
+ m_inputStream[i] = nullptr;
+ m_outputStream[i] = nullptr;
m_endClosed[i] = false;
}
@@ -105,7 +105,7 @@ Socket::Socket(INetworkPlayer *player, bool response /* = false*/, bool hostLoca
SocketAddress *Socket::getRemoteSocketAddress()
{
- return NULL;
+ return nullptr;
}
INetworkPlayer *Socket::getPlayer()
@@ -115,7 +115,7 @@ INetworkPlayer *Socket::getPlayer()
void Socket::setPlayer(INetworkPlayer *player)
{
- if(player!=NULL)
+ if(player!=nullptr)
{
networkPlayerSmallId = player->GetSmallId();
}
@@ -150,7 +150,7 @@ void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHos
void Socket::addIncomingSocket(Socket *socket)
{
- if( s_serverConnection != NULL )
+ if( s_serverConnection != nullptr )
{
s_serverConnection->NewIncomingSocket(socket);
}
@@ -243,7 +243,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();
}
@@ -334,7 +334,7 @@ void Socket::SocketOutputStreamLocal::write(unsigned int b)
return;
}
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
- s_hostQueue[m_queueIdx].push((byte)b);
+ s_hostQueue[m_queueIdx].push(static_cast<byte>(b));
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
}
@@ -447,7 +447,7 @@ void Socket::SocketOutputStreamNetwork::write(unsigned int b)
if( m_streamOpen != true ) return;
byteArray barray;
byte bb;
- bb = (byte)b;
+ bb = static_cast<byte>(b);
barray.data = &bb;
barray.length = 1;
write(barray, 0, 1);
@@ -493,15 +493,15 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(byteArray b, unsigned int
buffer.dwDataSize = length;
INetworkPlayer *hostPlayer = g_NetworkManager.GetHostPlayer();
- if(hostPlayer == NULL)
+ if(hostPlayer == nullptr)
{
- app.DebugPrintf("Trying to write to network, but the hostPlayer is NULL\n");
+ app.DebugPrintf("Trying to write to network, but the hostPlayer is nullptr\n");
return;
}
INetworkPlayer *socketPlayer = m_socket->getPlayer();
- if(socketPlayer == NULL)
+ if(socketPlayer == nullptr)
{
- app.DebugPrintf("Trying to write to network, but the socketPlayer is NULL\n");
+ app.DebugPrintf("Trying to write to network, but the socketPlayer is nullptr\n");
return;
}
@@ -522,7 +522,7 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(byteArray b, unsigned int
hostPlayer->SendData(socketPlayer, buffer.pbyData, buffer.dwDataSize, lowPriority, requireAck);
- // DWORD queueSize = hostPlayer->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_BYTES );
+ // DWORD queueSize = hostPlayer->GetSendQueueSize( nullptr, QNET_GETSENDQUEUESIZE_BYTES );
// if( queueSize > 24000 )
// {
// //printf("Queue size is: %d, forcing doWork()\n",queueSize);
diff --git a/Minecraft.World/SparseDataStorage.cpp b/Minecraft.World/SparseDataStorage.cpp
index 780c9819..556000fd 100644
--- a/Minecraft.World/SparseDataStorage.cpp
+++ b/Minecraft.World/SparseDataStorage.cpp
@@ -28,7 +28,7 @@ SparseDataStorage::SparseDataStorage()
#ifdef _XBOX
unsigned char *planeIndices = (unsigned char *)XPhysicalAlloc(128 * 128, MAXULONG_PTR, 4096, PAGE_READWRITE);
#else
- unsigned char *planeIndices = (unsigned char *)malloc(128 * 128);
+ unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128 * 128));
#endif
unsigned char *data = planeIndices + 128;
planeIndices[0] = ALL_0_INDEX;
@@ -51,7 +51,7 @@ SparseDataStorage::SparseDataStorage(bool isUpper)
{
// Allocate using physical alloc. As this will (by default) return memory from the pool of 4KB pages, the address will in the range of MM_PHYSICAL_4KB_BASE upwards. We can use
// this fact to identify the allocation later, and so free it with the corresponding call to XPhysicalFree.
- unsigned char *planeIndices = (unsigned char *)malloc(128);
+ unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128));
for( int i = 0; i < 128; i++ )
{
planeIndices[i] = ALL_0_INDEX;
@@ -87,12 +87,12 @@ SparseDataStorage::~SparseDataStorage()
SparseDataStorage::SparseDataStorage(SparseDataStorage *copyFrom)
{
// Extra details of source storage
- int64_t sourceDataAndCount = copyFrom->dataAndCount;
- unsigned char *sourceIndicesAndData = (unsigned char *)(sourceDataAndCount & 0x0000ffffffffffff);
+ const int64_t sourceDataAndCount = copyFrom->dataAndCount;
+ const unsigned char *sourceIndicesAndData = (unsigned char *)(sourceDataAndCount & 0x0000ffffffffffff);
int sourceCount = (sourceDataAndCount >> 48 ) & 0xffff;
// Allocate & copy indices ( 128 bytes ) and any allocated planes (128 * count)
- unsigned char *destIndicesAndData = (unsigned char *)malloc( sourceCount * 128 + 128 );
+ unsigned char *destIndicesAndData = static_cast<unsigned char *>(malloc(sourceCount * 128 + 128));
// AP - I've moved this to be before the memcpy because of a very strange bug on vita. Sometimes dataAndCount wasn't valid in time when ::get was called.
// This should never happen and this isn't a proper solution but fixes it for now.
@@ -129,10 +129,10 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset)
for( int xz = 0; xz < 256; xz++ ) // 256 in loop as 16 x 16 separate bytes need checked
{
- int pos = ( xz << 7 ) | y;
- int slot = pos >> 1;
- int part = pos & 1;
- unsigned char value = ( dataIn[slot + inOffset] >> (part * 4) ) & 15;
+ const int pos = ( xz << 7 ) | y;
+ const int slot = pos >> 1;
+ const int part = pos & 1;
+ const unsigned char value = ( dataIn[slot + inOffset] >> (part * 4) ) & 15;
if( value != 0 ) all0 = false;
}
if( all0 )
@@ -146,7 +146,7 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset)
}
// Allocate required storage
- unsigned char *planeIndices = (unsigned char *)malloc(128 * allocatedPlaneCount + 128);
+ unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128 * allocatedPlaneCount + 128));
unsigned char *data = planeIndices + 128;
XMemCpy(planeIndices, _planeIndices, 128);
@@ -158,9 +158,9 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset)
// we know they were sequentially allocated above.
if( planeIndices[y] < 128 )
{
- int part = y & 1;
+ const int part = y & 1;
//int shift = 4 * part;
- unsigned char *pucIn = &dataIn[ (y >> 1) + inOffset];
+ const unsigned char *pucIn = &dataIn[ (y >> 1) + inOffset];
for( int xz = 0; xz < 128; xz++ ) // 128 ( 16 x 16 x 0.5 ) in loop as packing 2 values into each destination byte
{
@@ -176,9 +176,9 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset)
// Get new data and count packed info
#pragma warning ( disable : 4826 )
- int64_t newDataAndCount = ((int64_t) planeIndices) & 0x0000ffffffffffffL;
+ int64_t newDataAndCount = reinterpret_cast<int64_t>(planeIndices) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
- newDataAndCount |= ((int64_t)allocatedPlaneCount) << 48;
+ newDataAndCount |= static_cast<int64_t>(allocatedPlaneCount) << 48;
updateDataAndCount( newDataAndCount );
}
@@ -205,10 +205,10 @@ void SparseDataStorage::getData(byteArray retArray, unsigned int retOffset)
}
else
{
- int part = y & 1;
- int shift = 4 * part;
+ const int part = y & 1;
+ const int shift = 4 * part;
unsigned char *pucOut = &retArray.data[ (y >> 1) + + retOffset];
- unsigned char *pucIn = &data[ planeIndices[ y ] * 128 ];
+ const unsigned char *pucIn = &data[ planeIndices[ y ] * 128 ];
for( int xz = 0; xz < 128; xz++ ) // 128 in loop (16 x 16 x 0.5) as input data is being treated in pairs of nybbles that are packed in the same byte
{
unsigned char value = (*pucIn) & 15;
@@ -237,10 +237,10 @@ int SparseDataStorage::get(int x, int y, int z)
}
else
{
- int planeIndex = x * 16 + z; // Index within this xz plane
- int byteIndex = planeIndex / 2; // Byte index within the plane (2 tiles stored per byte)
- int shift = ( planeIndex & 1 ) * 4; // Bit shift within the byte
- int retval = ( data[ planeIndices[y] * 128 + byteIndex ] >> shift ) & 15;
+ const int planeIndex = x * 16 + z; // Index within this xz plane
+ const int byteIndex = planeIndex / 2; // Byte index within the plane (2 tiles stored per byte)
+ const int shift = ( planeIndex & 1 ) * 4; // Bit shift within the byte
+ const int retval = ( data[ planeIndices[y] * 128 + byteIndex ] >> shift ) & 15;
return retval;
}
@@ -270,12 +270,12 @@ void SparseDataStorage::set(int x, int y, int z, int val)
// Either data was already allocated, or we've just done that. Now store our value into the right place.
- int planeIndex = x * 16 + z; // Index within this xz plane
- int byteIndex = planeIndex / 2; // Byte index within the plane (2 tiles stored per byte)
- int shift = ( planeIndex & 1 ) * 4; // Bit shift within the byte
- int mask = 0xf0 >> shift;
+ const int planeIndex = x * 16 + z; // Index within this xz plane
+ const int byteIndex = planeIndex / 2; // Byte index within the plane (2 tiles stored per byte)
+ const int shift = ( planeIndex & 1 ) * 4; // Bit shift within the byte
+ const int mask = 0xf0 >> shift;
- int idx = planeIndices[y] * 128 + byteIndex;
+ const int idx = planeIndices[y] * 128 + byteIndex;
data[idx] = ( data[idx] & mask ) | ( val << shift );
}
@@ -288,7 +288,7 @@ void SparseDataStorage::set(int x, int y, int z, int val)
int SparseDataStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, int x1, int y1, int z1, int offset, tileUpdatedCallback callback, void *param, int yparam)
{
// Actual setting of data happens when calling set method so no need to lock here
- unsigned char *pucIn = &dataIn.data[offset];
+ const unsigned char *pucIn = &dataIn.data[offset];
if( callback )
{
for( int x = x0; x < x1; x++ )
@@ -296,11 +296,11 @@ int SparseDataStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, i
for( int z = z0; z < z1; z++ )
{
// Emulate how data was extracted from DataLayer... see comment above
- int yy0 = y0 & 0xfffffffe;
- int len = ( y1 - y0 ) / 2;
+ const int yy0 = y0 & 0xfffffffe;
+ const int len = ( y1 - y0 ) / 2;
for( int i = 0; i < len; i++ )
{
- int y = yy0 + ( i * 2 );
+ const int y = yy0 + ( i * 2 );
int toSet = (*pucIn) & 15;
if( get(x, y, z) != toSet )
@@ -326,11 +326,11 @@ int SparseDataStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, i
for( int z = z0; z < z1; z++ )
{
// Emulate how data was extracted from DataLayer... see comment above
- int yy0 = y0 & 0xfffffffe;
- int len = ( y1 - y0 ) / 2;
+ const int yy0 = y0 & 0xfffffffe;
+ const int len = ( y1 - y0 ) / 2;
for( int i = 0; i < len; i++ )
{
- int y = yy0 + ( i * 2 );
+ const int y = yy0 + ( i * 2 );
set(x, y, z, (*pucIn) & 15 );
set(x, y + 1, z, ((*pucIn) >> 4 ) & 15 );
@@ -339,9 +339,9 @@ int SparseDataStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, i
}
}
}
- ptrdiff_t count = pucIn - &dataIn.data[offset];
+ const ptrdiff_t count = pucIn - &dataIn.data[offset];
- return (int)count;
+ return static_cast<int>(count);
}
// Updates the data at offset position dataInOut with a region of data information - external ordering compatible with java DataLayer
@@ -357,11 +357,11 @@ int SparseDataStorage::getDataRegion(byteArray dataInOut, int x0, int y0, int z0
for( int z = z0; z < z1; z++ )
{
// Emulate how data was extracted from DataLayer... see comment above
- int yy0 = y0 & 0xfffffffe;
- int len = ( y1 - y0 ) / 2;
+ const int yy0 = y0 & 0xfffffffe;
+ const int len = ( y1 - y0 ) / 2;
for( int i = 0; i < len; i++ )
{
- int y = yy0 + ( i * 2 );
+ const int y = yy0 + ( i * 2 );
*pucOut = get( x, y, z);
*pucOut |= get( x, y + 1, z) << 4;
@@ -369,9 +369,9 @@ int SparseDataStorage::getDataRegion(byteArray dataInOut, int x0, int y0, int z0
}
}
}
- ptrdiff_t count = pucOut - &dataInOut.data[offset];
+ const ptrdiff_t count = pucOut - &dataInOut.data[offset];
- return (int)count;
+ return static_cast<int>(count);
}
void SparseDataStorage::addNewPlane(int y)
@@ -380,34 +380,34 @@ void SparseDataStorage::addNewPlane(int y)
do
{
// Get last packed data pointer & count
- int64_t lastDataAndCount = dataAndCount;
+ const int64_t lastDataAndCount = dataAndCount;
// Unpack count & data pointer
- int lastLinesUsed = (int)(( lastDataAndCount >> 48 ) & 0xffff);
+ const int lastLinesUsed = static_cast<int>((lastDataAndCount >> 48) & 0xffff);
unsigned char *lastDataPointer = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff);
// Find out what to prefill the newly allocated line with
- unsigned char planeIndex = lastDataPointer[y];
+ const unsigned char planeIndex = lastDataPointer[y];
if( planeIndex < ALL_0_INDEX ) return; // Something has already allocated this line - we're done
int linesUsed = lastLinesUsed + 1;
// Allocate new memory storage, copy over anything from old storage, and initialise remainder
- unsigned char *dataPointer = (unsigned char *)malloc(linesUsed * 128 + 128);
+ auto dataPointer = static_cast<unsigned char *>(malloc(linesUsed * 128 + 128));
XMemCpy( dataPointer, lastDataPointer, 128 * lastLinesUsed + 128);
XMemSet( dataPointer + ( 128 * lastLinesUsed ) + 128, 0, 128 );
dataPointer[y] = lastLinesUsed;
// Get new data and count packed info
#pragma warning ( disable : 4826 )
- int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL;
+ int64_t newDataAndCount = reinterpret_cast<int64_t>(dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
- newDataAndCount |= ((int64_t)linesUsed) << 48;
+ newDataAndCount |= static_cast<int64_t>(linesUsed) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
- int64_t lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
+ const int64_t lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@@ -430,7 +430,7 @@ void SparseDataStorage::addNewPlane(int y)
void SparseDataStorage::getPlaneIndicesAndData(unsigned char **planeIndices, unsigned char **data)
{
- unsigned char *indicesAndData = (unsigned char *)(dataAndCount & 0x0000ffffffffffff);
+ unsigned char *indicesAndData = reinterpret_cast<unsigned char *>(dataAndCount & 0x0000ffffffffffff);
*planeIndices = indicesAndData;
*data = indicesAndData + 128;
@@ -448,10 +448,10 @@ void SparseDataStorage::tick()
{
// We have 3 queues for deleting. Always delete from the next one after where we are writing to, so it should take 2 ticks
// before we ever delete something, from when the request to delete it came in
- int freeIndex = ( deleteQueueIndex + 1 ) % 3;
+ const int freeIndex = ( deleteQueueIndex + 1 ) % 3;
// printf("Free queue: %d, %d\n",deleteQueue[freeIndex].GetEntryCount(),deleteQueue[freeIndex].GetAllocated());
- unsigned char *toFree = NULL;
+ unsigned char *toFree = nullptr;
do
{
toFree = deleteQueue[freeIndex].Pop();
@@ -480,12 +480,12 @@ void SparseDataStorage::updateDataAndCount(int64_t newDataAndCount)
bool success = false;
do
{
- int64_t lastDataAndCount = dataAndCount;
- unsigned char *lastDataPointer = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff);
+ const int64_t lastDataAndCount = dataAndCount;
+ unsigned char *lastDataPointer = reinterpret_cast<unsigned char *>(lastDataAndCount & 0x0000ffffffffffff);
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
- int64_t lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
+ const int64_t lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@@ -508,7 +508,7 @@ int SparseDataStorage::compress()
unsigned char _planeIndices[128];
bool needsCompressed = false;
- int64_t lastDataAndCount = dataAndCount;
+ const int64_t lastDataAndCount = dataAndCount;
unsigned char *planeIndices = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff);
unsigned char *data = planeIndices + 128;
@@ -522,7 +522,7 @@ int SparseDataStorage::compress()
}
else
{
- unsigned char *pucData = &data[ 128 * planeIndices[i] ];
+ const unsigned char *pucData = &data[ 128 * planeIndices[i] ];
bool all0 = true;
for( int j = 0; j < 128; j++ ) // 16 x 16 x 4-bits
{
@@ -543,7 +543,7 @@ int SparseDataStorage::compress()
if( needsCompressed )
{
- unsigned char *newIndicesAndData = (unsigned char *)malloc( 128 + 128 * planesToAlloc );
+ unsigned char *newIndicesAndData = static_cast<unsigned char *>(malloc(128 + 128 * planesToAlloc));
unsigned char *pucData = newIndicesAndData + 128;
XMemCpy( newIndicesAndData, _planeIndices, 128 );
@@ -560,11 +560,11 @@ int SparseDataStorage::compress()
#pragma warning ( disable : 4826 )
int64_t newDataAndCount = ((int64_t) newIndicesAndData) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
- newDataAndCount |= ((int64_t)planesToAlloc) << 48;
+ newDataAndCount |= static_cast<int64_t>(planesToAlloc) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
- int64_t lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
+ const int64_t lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 != lastDataAndCount )
{
@@ -586,7 +586,7 @@ int SparseDataStorage::compress()
}
else
{
- return (int)((lastDataAndCount >> 48 ) & 0xffff);
+ return static_cast<int>((lastDataAndCount >> 48) & 0xffff);
}
}
@@ -594,7 +594,7 @@ int SparseDataStorage::compress()
bool SparseDataStorage::isCompressed()
{
- int count = ( dataAndCount >> 48 ) & 0xffff;
+ const int count = ( dataAndCount >> 48 ) & 0xffff;
return (count < 127);
@@ -602,24 +602,24 @@ bool SparseDataStorage::isCompressed()
void SparseDataStorage::write(DataOutputStream *dos)
{
- int count = ( dataAndCount >> 48 ) & 0xffff;
+ const int count = ( dataAndCount >> 48 ) & 0xffff;
dos->writeInt(count);
unsigned char *dataPointer = (unsigned char *)(dataAndCount & 0x0000ffffffffffff);
- byteArray wrapper(dataPointer, count * 128 + 128);
+ const byteArray wrapper(dataPointer, count * 128 + 128);
dos->write(wrapper);
}
void SparseDataStorage::read(DataInputStream *dis)
{
- int count = dis->readInt();
- unsigned char *dataPointer = (unsigned char *)malloc(count * 128 + 128);
- byteArray wrapper(dataPointer, count * 128 + 128);
+ const int count = dis->readInt();
+ unsigned char *dataPointer = static_cast<unsigned char *>(malloc(count * 128 + 128));
+ const byteArray wrapper(dataPointer, count * 128 + 128);
dis->readFully(wrapper);
#pragma warning ( disable : 4826 )
- int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL;
+ int64_t newDataAndCount = reinterpret_cast<int64_t>(dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
- newDataAndCount |= ((int64_t)count) << 48;
+ newDataAndCount |= static_cast<int64_t>(count) << 48;
updateDataAndCount(newDataAndCount);
}
diff --git a/Minecraft.World/SparseLightStorage.cpp b/Minecraft.World/SparseLightStorage.cpp
index a0ba41b1..a80f9c97 100644
--- a/Minecraft.World/SparseLightStorage.cpp
+++ b/Minecraft.World/SparseLightStorage.cpp
@@ -28,7 +28,7 @@ SparseLightStorage::SparseLightStorage(bool sky)
#ifdef _XBOX
unsigned char *planeIndices = (unsigned char *)XPhysicalAlloc(128 * 128, MAXULONG_PTR, 4096, PAGE_READWRITE);
#else
- unsigned char *planeIndices = (unsigned char *)malloc(128 * 128);
+ unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128 * 128));
#endif
unsigned char *data = planeIndices + 128;
planeIndices[127] = sky ? ALL_15_INDEX : ALL_0_INDEX;
@@ -51,7 +51,7 @@ SparseLightStorage::SparseLightStorage(bool sky, bool isUpper)
{
// Allocate using physical alloc. As this will (by default) return memory from the pool of 4KB pages, the address will in the range of MM_PHYSICAL_4KB_BASE upwards. We can use
// this fact to identify the allocation later, and so free it with the corresponding call to XPhysicalFree.
- unsigned char *planeIndices = (unsigned char *)malloc(128);
+ unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128));
for( int i = 0; i < 128; i++ )
{
planeIndices[i] = sky ? ALL_15_INDEX : ALL_0_INDEX;
@@ -92,7 +92,7 @@ SparseLightStorage::SparseLightStorage(SparseLightStorage *copyFrom)
int sourceCount = (sourceDataAndCount >> 48 ) & 0xffff;
// Allocate & copy indices ( 128 bytes ) and any allocated planes (128 * count)
- unsigned char *destIndicesAndData = (unsigned char *)malloc( sourceCount * 128 + 128 );
+ unsigned char *destIndicesAndData = static_cast<unsigned char *>(malloc(sourceCount * 128 + 128));
// AP - I've moved this to be before the memcpy because of a very strange bug on vita. Sometimes dataAndCount wasn't valid in time when ::get was called.
// This should never happen and this isn't a proper solution but fixes it for now.
@@ -150,7 +150,7 @@ void SparseLightStorage::setData(byteArray dataIn, unsigned int inOffset)
}
// Allocate required storage
- unsigned char *planeIndices = (unsigned char *)malloc(128 * allocatedPlaneCount + 128);
+ unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128 * allocatedPlaneCount + 128));
unsigned char *data = planeIndices + 128;
XMemCpy(planeIndices, _planeIndices, 128);
@@ -180,9 +180,9 @@ void SparseLightStorage::setData(byteArray dataIn, unsigned int inOffset)
// Get new data and count packed info
#pragma warning ( disable : 4826 )
- int64_t newDataAndCount = ((int64_t) planeIndices) & 0x0000ffffffffffffL;
+ int64_t newDataAndCount = reinterpret_cast<int64_t>(planeIndices) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
- newDataAndCount |= ((int64_t)allocatedPlaneCount) << 48;
+ newDataAndCount |= static_cast<int64_t>(allocatedPlaneCount) << 48;
updateDataAndCount( newDataAndCount );
}
@@ -305,7 +305,7 @@ void SparseLightStorage::set(int x, int y, int z, int val)
void SparseLightStorage::setAllBright()
{
- unsigned char *planeIndices = (unsigned char *)malloc(128);
+ unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128));
for( int i = 0; i < 128; i++ )
{
planeIndices[i] = ALL_15_INDEX;
@@ -346,7 +346,7 @@ int SparseLightStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0,
}
ptrdiff_t count = pucIn - &dataIn.data[offset];
- return (int)count;
+ return static_cast<int>(count);
}
// Updates the data at offset position dataInOut with a region of lighting information - external ordering compatible with java DataLayer
@@ -376,7 +376,7 @@ int SparseLightStorage::getDataRegion(byteArray dataInOut, int x0, int y0, int z
}
ptrdiff_t count = pucOut - &dataInOut.data[offset];
- return (int)count;
+ return static_cast<int>(count);
}
void SparseLightStorage::addNewPlane(int y)
@@ -388,7 +388,7 @@ void SparseLightStorage::addNewPlane(int y)
int64_t lastDataAndCount = dataAndCount;
// Unpack count & data pointer
- int lastLinesUsed = (int)(( lastDataAndCount >> 48 ) & 0xffff);
+ int lastLinesUsed = static_cast<int>((lastDataAndCount >> 48) & 0xffff);
unsigned char *lastDataPointer = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff);
// Find out what to prefill the newly allocated line with
@@ -400,7 +400,7 @@ void SparseLightStorage::addNewPlane(int y)
int linesUsed = lastLinesUsed + 1;
// Allocate new memory storage, copy over anything from old storage, and initialise remainder
- unsigned char *dataPointer = (unsigned char *)malloc(linesUsed * 128 + 128);
+ unsigned char *dataPointer = static_cast<unsigned char *>(malloc(linesUsed * 128 + 128));
XMemCpy( dataPointer, lastDataPointer, 128 * lastLinesUsed + 128);
XMemSet( dataPointer + ( 128 * lastLinesUsed ) + 128, prefill, 128 );
dataPointer[y] = lastLinesUsed;
@@ -409,7 +409,7 @@ void SparseLightStorage::addNewPlane(int y)
#pragma warning ( disable : 4826 )
int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
- newDataAndCount |= ((int64_t)linesUsed) << 48;
+ newDataAndCount |= static_cast<int64_t>(linesUsed) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
@@ -457,7 +457,7 @@ void SparseLightStorage::tick()
int freeIndex = ( deleteQueueIndex + 1 ) % 3;
// printf("Free queue: %d, %d\n",deleteQueue[freeIndex].GetEntryCount(),deleteQueue[freeIndex].GetAllocated());
- unsigned char *toFree = NULL;
+ unsigned char *toFree = nullptr;
do
{
toFree = deleteQueue[freeIndex].Pop();
@@ -560,7 +560,7 @@ int SparseLightStorage::compress()
if( needsCompressed )
{
- unsigned char *newIndicesAndData = (unsigned char *)malloc( 128 + 128 * planesToAlloc );
+ unsigned char *newIndicesAndData = static_cast<unsigned char *>(malloc(128 + 128 * planesToAlloc));
unsigned char *pucData = newIndicesAndData + 128;
XMemCpy( newIndicesAndData, _planeIndices, 128 );
@@ -577,7 +577,7 @@ int SparseLightStorage::compress()
#pragma warning ( disable : 4826 )
int64_t newDataAndCount = ((int64_t) newIndicesAndData) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
- newDataAndCount |= ((int64_t)planesToAlloc) << 48;
+ newDataAndCount |= static_cast<int64_t>(planesToAlloc) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
@@ -603,7 +603,7 @@ int SparseLightStorage::compress()
}
else
{
- return (int)((lastDataAndCount >> 48 ) & 0xffff);
+ return static_cast<int>((lastDataAndCount >> 48) & 0xffff);
}
}
@@ -629,14 +629,14 @@ void SparseLightStorage::write(DataOutputStream *dos)
void SparseLightStorage::read(DataInputStream *dis)
{
int count = dis->readInt();
- unsigned char *dataPointer = (unsigned char *)malloc(count * 128 + 128);
+ unsigned char *dataPointer = static_cast<unsigned char *>(malloc(count * 128 + 128));
byteArray wrapper(dataPointer, count * 128 + 128);
dis->readFully(wrapper);
#pragma warning ( disable : 4826 )
int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
- newDataAndCount |= ((int64_t)count) << 48;
+ newDataAndCount |= static_cast<int64_t>(count) << 48;
updateDataAndCount( newDataAndCount );
}
diff --git a/Minecraft.World/SpawnEggItem.cpp b/Minecraft.World/SpawnEggItem.cpp
index 9c059126..5124f668 100644
--- a/Minecraft.World/SpawnEggItem.cpp
+++ b/Minecraft.World/SpawnEggItem.cpp
@@ -16,7 +16,7 @@ SpawnEggItem::SpawnEggItem(int id) : Item(id)
{
setMaxStackSize(16); // 4J-PB brought forward. It is 64 on PC, but we'll never be able to place that many
setStackedByData(true);
- overlay = NULL;
+ overlay = nullptr;
}
wstring SpawnEggItem::getHoverName(shared_ptr<ItemInstance> itemInstance)
@@ -69,7 +69,7 @@ Icon *SpawnEggItem::getLayerIcon(int auxValue, int spriteLayer)
shared_ptr<Entity> SpawnEggItem::canSpawn(int iAuxVal, Level *level, int *piResult)
{
shared_ptr<Entity> newEntity = EntityIO::newById(iAuxVal, level);
- if (newEntity != NULL)
+ if (newEntity != nullptr)
{
bool canSpawn = false;
@@ -200,7 +200,7 @@ bool SpawnEggItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<Playe
level->removeTile(x,y,z);
level->setTileAndData(x,y,z,Tile::mobSpawner_Id, 0, Tile::UPDATE_ALL);
shared_ptr<MobSpawnerTileEntity> mste = dynamic_pointer_cast<MobSpawnerTileEntity>( level->getTileEntity(x,y,z) );
- if(mste != NULL)
+ if(mste != nullptr)
{
mste->setEntityId( EntityIO::getEncodeId(itemInstance->getAuxValue()) );
return true;
@@ -213,7 +213,7 @@ bool SpawnEggItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<Playe
z += Facing::STEP_Z[face];
double yOff = 0;
- if (face == Facing::UP && (Tile::tiles[tile] != NULL && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE))
+ if (face == Facing::UP && (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE))
{
// special case
yOff = .5;
@@ -224,10 +224,10 @@ bool SpawnEggItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<Playe
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) && itemInstance->hasCustomHoverName() )
@@ -252,7 +252,7 @@ shared_ptr<ItemInstance> SpawnEggItem::use(shared_ptr<ItemInstance> itemInstance
if (level->isClientSide) return itemInstance;
HitResult *hr = getPlayerPOVHitResult(level, player, true);
- if (hr == NULL)
+ if (hr == nullptr)
{
delete hr;
return itemInstance;
@@ -275,7 +275,7 @@ shared_ptr<ItemInstance> SpawnEggItem::use(shared_ptr<ItemInstance> itemInstance
{
int iResult=0;
shared_ptr<Entity> result = spawnMobAt(level, itemInstance->getAuxValue(), xt, yt, zt, &iResult);
- if (result != NULL)
+ if (result != nullptr)
{
// 4J-JEV: SetCustomName is a method for Mob not LivingEntity; so change instanceof to check for Mobs.
if ( result->instanceof(eTYPE_MOB) && itemInstance->hasCustomHoverName() )
@@ -317,7 +317,7 @@ shared_ptr<Entity> SpawnEggItem::spawnMobAt(Level *level, int auxVal, double x,
newEntity = canSpawn(mobId, level, piResult);
// 4J-JEV: DynCasting to Mob not LivingEntity; so change instanceof to check for Mobs.
- if ( newEntity != NULL && newEntity->instanceof(eTYPE_MOB) )
+ if ( newEntity != nullptr && newEntity->instanceof(eTYPE_MOB) )
{
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(newEntity);
newEntity->moveTo(x, y, z, Mth::wrapDegrees(level->random->nextFloat() * 360), 0);
@@ -325,7 +325,7 @@ shared_ptr<Entity> SpawnEggItem::spawnMobAt(Level *level, int auxVal, double x,
mob->yHeadRot = mob->yRot;
mob->yBodyRot = mob->yRot;
- mob->finalizeMobSpawn(NULL, extraData);
+ mob->finalizeMobSpawn(nullptr, extraData);
level->addEntity(newEntity);
mob->playAmbientSound();
}
diff --git a/Minecraft.World/Spider.cpp b/Minecraft.World/Spider.cpp
index 49997db3..5d7bdd2c 100644
--- a/Minecraft.World/Spider.cpp
+++ b/Minecraft.World/Spider.cpp
@@ -31,7 +31,7 @@ void Spider::defineSynchedData()
{
Monster::defineSynchedData();
- entityData->define(DATA_FLAGS_ID, (byte) 0);
+ entityData->define(DATA_FLAGS_ID, static_cast<byte>(0));
}
void Spider::tick()
@@ -109,7 +109,7 @@ void Spider::checkHurtTarget(shared_ptr<Entity> target, float d)
{
double xdd = target->x - x;
double zdd = target->z - z;
- float dd = (float) sqrt(xdd * xdd + zdd * zdd);
+ float dd = static_cast<float>(sqrt(xdd * xdd + zdd * zdd));
xd = (xdd / dd * 0.5f) * 0.8f + xd * 0.2f;
zd = (zdd / dd * 0.5f) * 0.8f + zd * 0.2f;
yd = 0.4f;
@@ -195,26 +195,26 @@ MobGroupData *Spider::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
if (level->random->nextInt(100) == 0)
#endif
{
- shared_ptr<Skeleton> skeleton = shared_ptr<Skeleton>( new Skeleton(level) );
+ shared_ptr<Skeleton> skeleton = std::make_shared<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 && level->random->nextFloat() < SPIDER_SPECIAL_EFFECT_CHANCE * level->getDifficulty(x, y, z))
{
- ((SpiderEffectsGroupData *) groupData)->setRandomEffect(level->random);
+ static_cast<SpiderEffectsGroupData *>(groupData)->setRandomEffect(level->random);
}
}
- if ( dynamic_cast<SpiderEffectsGroupData *>( groupData ) != NULL)
+ if ( dynamic_cast<SpiderEffectsGroupData *>( groupData ) != nullptr)
{
- int effect = ((SpiderEffectsGroupData *) groupData)->effectId;
- if (effect > 0 && MobEffect::effects[effect] != NULL)
+ int effect = static_cast<SpiderEffectsGroupData *>(groupData)->effectId;
+ if (effect > 0 && MobEffect::effects[effect] != nullptr)
{
addEffect(new MobEffectInstance(effect, Integer::MAX_VALUE));
}
diff --git a/Minecraft.World/SpikeFeature.cpp b/Minecraft.World/SpikeFeature.cpp
index 629b3c83..912e3aff 100644
--- a/Minecraft.World/SpikeFeature.cpp
+++ b/Minecraft.World/SpikeFeature.cpp
@@ -50,7 +50,7 @@ bool SpikeFeature::place(Level *level, Random *random, int x, int y, int z)
} else break;
}
- shared_ptr<EnderCrystal> enderCrystal = shared_ptr<EnderCrystal>(new EnderCrystal(level));
+ shared_ptr<EnderCrystal> enderCrystal = std::make_shared<EnderCrystal>(level);
enderCrystal->moveTo(x + 0.5f, y + hh, z + 0.5f, random->nextFloat() * 360, 0);
level->addEntity(enderCrystal);
level->setTileAndData(x, y + hh, z, Tile::unbreakable_Id, 0, Tile::UPDATE_CLIENTS);
@@ -168,7 +168,7 @@ bool SpikeFeature::placeWithIndex(Level *level, Random *random, int x, int y, in
}
}
- shared_ptr<EnderCrystal> enderCrystal = shared_ptr<EnderCrystal>(new EnderCrystal(level));
+ shared_ptr<EnderCrystal> enderCrystal = std::make_shared<EnderCrystal>(level);
enderCrystal->moveTo(x + 0.5f, y + hh, z + 0.5f, random->nextFloat() * 360, 0);
level->addEntity(enderCrystal);
placeBlock(level, x, y + hh, z, Tile::unbreakable_Id, 0);
diff --git a/Minecraft.World/SpringFeature.cpp b/Minecraft.World/SpringFeature.cpp
index c6fa5e9f..fdd1cbef 100644
--- a/Minecraft.World/SpringFeature.cpp
+++ b/Minecraft.World/SpringFeature.cpp
@@ -11,7 +11,7 @@ SpringFeature::SpringFeature(int tile)
bool SpringFeature::place(Level *level, Random *random, int x, int y, int z)
{
// 4J Stu Added to stop spring features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
bool intersects = levelGenOptions->checkIntersects(x, y, z, x, y, z);
diff --git a/Minecraft.World/SpruceFeature.cpp b/Minecraft.World/SpruceFeature.cpp
index 39d628cf..d42e46f3 100644
--- a/Minecraft.World/SpruceFeature.cpp
+++ b/Minecraft.World/SpruceFeature.cpp
@@ -23,7 +23,7 @@ bool SpruceFeature::place(Level *level, Random *random, int x, int y, int z)
}
// 4J Stu Added to stop tree features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
bool intersects = levelGenOptions->checkIntersects(x - leafRadius, y - 1, z - leafRadius, x + leafRadius, y + treeHeight, z + leafRadius);
diff --git a/Minecraft.World/Squid.cpp b/Minecraft.World/Squid.cpp
index 7aae3615..f1b660eb 100644
--- a/Minecraft.World/Squid.cpp
+++ b/Minecraft.World/Squid.cpp
@@ -81,7 +81,7 @@ void Squid::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
int count = random->nextInt(3 + playerBonusLevel) + 1;
for (int i = 0; i < count; i++)
{
- spawnAtLocation(shared_ptr<ItemInstance>( new ItemInstance(Item::dye_powder, 1, DyePowderItem::BLACK) ), 0.0f);
+ spawnAtLocation(std::make_shared<ItemInstance>(Item::dye_powder, 1, DyePowderItem::BLACK), 0.0f);
}
}
@@ -140,10 +140,10 @@ void Squid::aiStep()
double horizontalMovement = sqrt(xd * xd + zd * zd);
- yBodyRot += ((-(float) atan2(xd, zd) * 180 / PI) - yBodyRot) * 0.1f;
+ yBodyRot += ((-static_cast<float>(atan2(xd, zd)) * 180 / PI) - yBodyRot) * 0.1f;
yRot = yBodyRot;
zBodyRot = zBodyRot + (float) PI * rotateSpeed * 1.5f;
- xBodyRot += ((-(float) atan2(horizontalMovement, yd) * 180 / PI) - xBodyRot) * 0.1f;
+ xBodyRot += ((-static_cast<float>(atan2(horizontalMovement, yd)) * 180 / PI) - xBodyRot) * 0.1f;
}
else
{
diff --git a/Minecraft.World/StairTile.cpp b/Minecraft.World/StairTile.cpp
index de2cc865..094ebf6f 100644
--- a/Minecraft.World/StairTile.cpp
+++ b/Minecraft.World/StairTile.cpp
@@ -66,7 +66,7 @@ void StairTile::setBaseShape(LevelSource *level, int x, int y, int z)
bool StairTile::isStairs(int id)
{
StairTile *st = dynamic_cast<StairTile *>(Tile::tiles[id]);
- return id > 0 && st != NULL; //Tile::tiles[id] instanceof StairTile;
+ return id > 0 && st != nullptr; //Tile::tiles[id] instanceof StairTile;
}
bool StairTile::isLockAttached(LevelSource *level, int x, int y, int z, int data)
@@ -476,7 +476,7 @@ HitResult *StairTile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *
HitResult *results[8];
for(unsigned int i = 0; i < 8; ++i)
{
- results[i] = NULL;
+ results[i] = nullptr;
}
int data = level->getData(xt, yt, zt);
int dir = data & 0x3;
@@ -498,16 +498,16 @@ HitResult *StairTile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *
for(unsigned int j = 0; j < DEAD_SPACE_COLUMN_COUNT; ++j)
{
- results[deadSpaces[j]] = NULL;
+ results[deadSpaces[j]] = nullptr;
}
- HitResult *closest = NULL;
+ HitResult *closest = nullptr;
double closestDist = 0;
for (unsigned int i = 0; i < 8; ++i)
{
HitResult *result = results[i];
- if (result != NULL)
+ if (result != nullptr)
{
double dist = result->pos->distanceToSqr(b);
diff --git a/Minecraft.World/Stats.cpp b/Minecraft.World/Stats.cpp
index c8a615ff..43ff486c 100644
--- a/Minecraft.World/Stats.cpp
+++ b/Minecraft.World/Stats.cpp
@@ -27,30 +27,30 @@ vector<ItemStat *> *Stats::itemsCraftedStats = new vector<ItemStat *>;
vector<ItemStat *> *Stats::blocksPlacedStats = new vector<ItemStat *>;
#endif
-Stat *Stats::walkOneM = NULL;
-Stat *Stats::swimOneM = NULL;
-Stat *Stats::fallOneM = NULL;
-Stat *Stats::climbOneM = NULL;
-Stat *Stats::minecartOneM = NULL;
-Stat *Stats::boatOneM = NULL;
-Stat *Stats::pigOneM = NULL;
-Stat *Stats::portalsCreated = NULL;
-Stat *Stats::cowsMilked = NULL;
-Stat *Stats::netherLavaCollected = NULL;
-Stat *Stats::killsZombie = NULL;
-Stat *Stats::killsSkeleton = NULL;
-Stat *Stats::killsCreeper = NULL;
-Stat *Stats::killsSpider = NULL;
-Stat *Stats::killsSpiderJockey = NULL;
-Stat *Stats::killsZombiePigman = NULL;
-Stat *Stats::killsSlime = NULL;
-Stat *Stats::killsGhast = NULL;
-Stat *Stats::killsNetherZombiePigman = NULL;
+Stat *Stats::walkOneM = nullptr;
+Stat *Stats::swimOneM = nullptr;
+Stat *Stats::fallOneM = nullptr;
+Stat *Stats::climbOneM = nullptr;
+Stat *Stats::minecartOneM = nullptr;
+Stat *Stats::boatOneM = nullptr;
+Stat *Stats::pigOneM = nullptr;
+Stat *Stats::portalsCreated = nullptr;
+Stat *Stats::cowsMilked = nullptr;
+Stat *Stats::netherLavaCollected = nullptr;
+Stat *Stats::killsZombie = nullptr;
+Stat *Stats::killsSkeleton = nullptr;
+Stat *Stats::killsCreeper = nullptr;
+Stat *Stats::killsSpider = nullptr;
+Stat *Stats::killsSpiderJockey = nullptr;
+Stat *Stats::killsZombiePigman = nullptr;
+Stat *Stats::killsSlime = nullptr;
+Stat *Stats::killsGhast = nullptr;
+Stat *Stats::killsNetherZombiePigman = nullptr;
// 4J : WESTY : Added for new achievements.
-Stat *Stats::befriendsWolf = NULL;
-Stat *Stats::totalBlocksMined = NULL;
-Stat *Stats::timePlayed = NULL;
+Stat *Stats::befriendsWolf = nullptr;
+Stat *Stats::totalBlocksMined = nullptr;
+Stat *Stats::timePlayed = nullptr;
StatArray Stats::blocksMined;
StatArray Stats::itemsCollected;
@@ -62,18 +62,18 @@ StatArray Stats::rainbowCollection;
StatArray Stats::biomesVisisted;
#endif
-Stat *Stats::killsEnderdragon = NULL; // The number of times this player has dealt the killing blow to the Enderdragon
-Stat *Stats::completeTheEnd = NULL; // The number of times this player has been present when the Enderdragon has died
+Stat *Stats::killsEnderdragon = nullptr; // The number of times this player has dealt the killing blow to the Enderdragon
+Stat *Stats::completeTheEnd = nullptr; // The number of times this player has been present when the Enderdragon has died
void Stats::staticCtor()
{
- Stats::walkOneM = (new GeneralStat(2000, L"stat.walkOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct();
- Stats::swimOneM = (new GeneralStat(2001, L"stat.swimOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct();
- Stats::fallOneM = (new GeneralStat(2002, L"stat.fallOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct();
- Stats::climbOneM = (new GeneralStat(2003, L"stat.climbOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct();
- Stats::minecartOneM = (new GeneralStat(2004, L"stat.minecartOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct();
- Stats::boatOneM = (new GeneralStat(2005, L"stat.boatOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct();
- Stats::pigOneM = (new GeneralStat(2006, L"stat.pigOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct();
+ Stats::walkOneM = (new GeneralStat(2000, L"stat.walkOneM", static_cast<StatFormatter *>(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct();
+ Stats::swimOneM = (new GeneralStat(2001, L"stat.swimOneM", static_cast<StatFormatter *>(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct();
+ Stats::fallOneM = (new GeneralStat(2002, L"stat.fallOneM", static_cast<StatFormatter *>(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct();
+ Stats::climbOneM = (new GeneralStat(2003, L"stat.climbOneM", static_cast<StatFormatter *>(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct();
+ Stats::minecartOneM = (new GeneralStat(2004, L"stat.minecartOneM", static_cast<StatFormatter *>(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct();
+ Stats::boatOneM = (new GeneralStat(2005, L"stat.boatOneM", static_cast<StatFormatter *>(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct();
+ Stats::pigOneM = (new GeneralStat(2006, L"stat.pigOneM", static_cast<StatFormatter *>(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct();
Stats::portalsCreated = (new GeneralStat(2007, L"stat.portalsUsed"))->postConstruct();
Stats::cowsMilked = (new GeneralStat(2008, L"stat.cowsMilked"))->postConstruct();
Stats::netherLavaCollected = (new GeneralStat(2009, L"stat.netherLavaCollected"))->postConstruct();
@@ -517,7 +517,7 @@ void Stats::buildAdditionalStats()
blocksPlaced[itemStat->getItemId()] = itemStat;
itemStat->postConstruct();
- GeneralStat *generalStat = NULL;
+ GeneralStat *generalStat = nullptr;
rainbowCollection = StatArray(16);
for (unsigned int i = 0; i < 16; i++)
diff --git a/Minecraft.World/StemTile.cpp b/Minecraft.World/StemTile.cpp
index 62b0d57b..476b643c 100644
--- a/Minecraft.World/StemTile.cpp
+++ b/Minecraft.World/StemTile.cpp
@@ -17,7 +17,7 @@ StemTile::StemTile(int id, Tile *fruit) : Bush(id)
float ss = 0.125f;
this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, 0.25f, 0.5f + ss);
- iconAngled = NULL;
+ iconAngled = nullptr;
}
bool StemTile::mayPlaceOn(int tile)
@@ -34,7 +34,7 @@ void StemTile::tick(Level *level, int x, int y, int z, Random *random)
float growthSpeed = getGrowthSpeed(level, x, y, z);
// 4J Stu - Brought forward change from 1.2.3 to make fruit more likely to grow
- if (random->nextInt((int) (25 / growthSpeed) + 1) == 0)
+ if (random->nextInt(static_cast<int>(25 / growthSpeed) + 1) == 0)
{
int age = level->getData(x, y, z);
if (age < 7)
@@ -149,10 +149,10 @@ void StemTile::updateDefaultShape()
void StemTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
tls->yy1 = (level->getData(x, y, z) * 2 + 2) / 16.0f;
float ss = 0.125f;
- setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, (float) tls->yy1, 0.5f + ss);
+ setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, static_cast<float>(tls->yy1), 0.5f + ss);
}
int StemTile::getRenderShape()
@@ -184,12 +184,12 @@ void StemTile::spawnResources(Level *level, int x, int y, int z, int data, float
return;
}
- Item *seed = NULL;
+ Item *seed = nullptr;
if (fruit == Tile::pumpkin) seed = Item::seeds_pumpkin;
if (fruit == Tile::melon) seed = Item::seeds_melon;
- if (seed != NULL)
+ if (seed != nullptr)
{
- popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(seed)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(seed));
}
}
diff --git a/Minecraft.World/StoneMonsterTile.cpp b/Minecraft.World/StoneMonsterTile.cpp
index ec31992f..fd3f1b90 100644
--- a/Minecraft.World/StoneMonsterTile.cpp
+++ b/Minecraft.World/StoneMonsterTile.cpp
@@ -48,7 +48,7 @@ void StoneMonsterTile::destroy(Level *level, int x, int y, int z, int data)
// Also limit the amount of silverfish specifically
if(level->countInstanceOf( eTYPE_SILVERFISH, true) < 15 )
{
- shared_ptr<Silverfish> silverfish = shared_ptr<Silverfish>(new Silverfish(level));
+ shared_ptr<Silverfish> silverfish = std::make_shared<Silverfish>(level);
silverfish->moveTo(x + .5, y, z + .5, 0, 0);
level->addEntity(silverfish);
@@ -106,7 +106,7 @@ shared_ptr<ItemInstance> StoneMonsterTile::getSilkTouchItemInstance(int data)
{
tile = Tile::stoneBrick;
}
- return shared_ptr<ItemInstance>(new ItemInstance(tile));
+ return std::make_shared<ItemInstance>(tile);
}
int StoneMonsterTile::cloneTileData(Level *level, int x, int y, int z)
diff --git a/Minecraft.World/StoneSlabTile.cpp b/Minecraft.World/StoneSlabTile.cpp
index e4de58da..10f1ee71 100644
--- a/Minecraft.World/StoneSlabTile.cpp
+++ b/Minecraft.World/StoneSlabTile.cpp
@@ -80,5 +80,5 @@ int StoneSlabTile::getAuxName(int auxValue)
shared_ptr<ItemInstance> StoneSlabTile::getSilkTouchItemInstance(int data)
{
- return shared_ptr<ItemInstance>(new ItemInstance(Tile::stoneSlabHalf_Id, 2, data & TYPE_MASK));
+ return std::make_shared<ItemInstance>(Tile::stoneSlabHalf_Id, 2, data & TYPE_MASK);
}
diff --git a/Minecraft.World/StringHelpers.cpp b/Minecraft.World/StringHelpers.cpp
index 6985c88f..b56a85f1 100644
--- a/Minecraft.World/StringHelpers.cpp
+++ b/Minecraft.World/StringHelpers.cpp
@@ -10,10 +10,10 @@ wstring toLower(const wstring& a)
wstring trimString(const wstring& a)
{
wstring b;
- int start = (int)a.find_first_not_of(L" \t\n\r");
- int end = (int)a.find_last_not_of(L" \t\n\r");
+ size_t start = a.find_first_not_of(L" \t\n\r");
+ size_t end = a.find_last_not_of(L" \t\n\r");
if( start == wstring::npos ) start = 0;
- if( end == wstring::npos ) end = (int)a.size()-1;
+ if( end == wstring::npos ) end = a.size() - 1;
b = a.substr(start,(end-start)+1);
return b;
}
@@ -62,7 +62,7 @@ const char *wstringtofilename(const wstring& name)
if(c=='/') c='\\';
#endif
assert(c<128); // Will we have to do any conversion of non-ASCII characters in filenames?
- buf[i] = (char)c;
+ buf[i] = static_cast<char>(c);
}
buf[name.length()] = 0;
return buf;
@@ -76,7 +76,7 @@ const char *wstringtochararray(const wstring& name)
{
wchar_t c = name[i];
assert(c<128); // Will we have to do any conversion of non-ASCII characters in filenames?
- buf[i] = (char)c;
+ buf[i] = static_cast<char>(c);
}
buf[name.length()] = 0;
return buf;
diff --git a/Minecraft.World/StringTag.h b/Minecraft.World/StringTag.h
index 8eb0eb7f..36b60368 100644
--- a/Minecraft.World/StringTag.h
+++ b/Minecraft.World/StringTag.h
@@ -34,7 +34,7 @@ public:
{
if (Tag::equals(obj))
{
- StringTag *o = (StringTag *) obj;
+ StringTag *o = static_cast<StringTag *>(obj);
return ((data.empty() && o->data.empty()) || (!data.empty() && data.compare(o->data) == 0));
}
return false;
diff --git a/Minecraft.World/StrongholdFeature.cpp b/Minecraft.World/StrongholdFeature.cpp
index fa85dc42..83f05cf3 100644
--- a/Minecraft.World/StrongholdFeature.cpp
+++ b/Minecraft.World/StrongholdFeature.cpp
@@ -39,7 +39,7 @@ void StrongholdFeature::_init()
// 4J added initialisers
for (int i = 0; i < strongholdPos_length; i++)
{
- strongholdPos[i] = NULL;
+ strongholdPos[i] = nullptr;
}
isSpotSelected = false;
}
@@ -136,11 +136,11 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
}
#endif
- int selectedX = (int) (Math::round(cos(angle) * dist));
- int selectedZ = (int) (Math::round(sin(angle) * dist));
+ int selectedX = static_cast<int>(Math::round(cos(angle) * dist));
+ int selectedZ = static_cast<int>(Math::round(sin(angle) * dist));
TilePos *position = level->getBiomeSource()->findBiome((selectedX << 4) + 8, (selectedZ << 4) + 8, 7 << 4, allowedBiomes, &random);
- if (position != NULL)
+ if (position != nullptr)
{
selectedX = position->x >> 4;
selectedZ = position->z >> 4;
@@ -164,7 +164,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
delete strongholdPos[i];
strongholdPos[i] = new ChunkPos(selectedX, selectedZ);
- angle += PI * 2.0 / (double) strongholdPos_length;
+ angle += PI * 2.0 / static_cast<double>(strongholdPos_length);
}
// 4J Stu - We want to make sure that we have at least one stronghold in this world
@@ -172,7 +172,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
// 4J Stu - Randomise the angles for retries as well
#ifdef _LARGE_WORLDS
- angle = random.nextDouble() * PI * 2.0 * circle / (double) spread;
+ angle = random.nextDouble() * PI * 2.0 * circle / static_cast<double>(spread);
#endif
}
while(!hasFoundValidPos && findAttempts < MAX_STRONGHOLD_ATTEMPTS);
@@ -191,7 +191,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
{
bool forcePlacement = false;
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
- if( levelGenOptions != NULL )
+ if( levelGenOptions != nullptr )
{
forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Stronghold);
}
@@ -211,7 +211,7 @@ vector<TilePos> *StrongholdFeature::getGuesstimatedFeaturePositions()
for( int i = 0; i < strongholdPos_length; i++ )
{
ChunkPos *chunkPos = strongholdPos[i];
- if (chunkPos != NULL)
+ if (chunkPos != nullptr)
{
positions->push_back(chunkPos->getMiddleBlockPosition(64));
}
@@ -225,7 +225,7 @@ StructureStart *StrongholdFeature::createStructureStart(int x, int z)
StrongholdStart *start = new StrongholdStart(level, random, x, z);
// 4J - front() was get(0)
- while (start->getPieces()->empty() || ((StrongholdPieces::StartPiece *) start->getPieces()->front())->portalRoomPiece == NULL)
+ while (start->getPieces()->empty() || static_cast<StrongholdPieces::StartPiece *>(start->getPieces()->front())->portalRoomPiece == nullptr)
{
delete start;
// regenerate stronghold without changing seed
@@ -254,7 +254,7 @@ StrongholdFeature::StrongholdStart::StrongholdStart(Level *level, Random *random
vector<StructurePiece *> *pendingChildren = &startRoom->pendingChildren;
while (!pendingChildren->empty())
{
- int pos = random->nextInt((int)pendingChildren->size());
+ int pos = random->nextInt(static_cast<int>(pendingChildren->size()));
auto it = pendingChildren->begin() + pos;
StructurePiece *structurePiece = *it;
pendingChildren->erase(it);
diff --git a/Minecraft.World/StrongholdPieces.cpp b/Minecraft.World/StrongholdPieces.cpp
index 383be42c..d98d9488 100644
--- a/Minecraft.World/StrongholdPieces.cpp
+++ b/Minecraft.World/StrongholdPieces.cpp
@@ -90,7 +90,7 @@ bool StrongholdPieces::updatePieceWeight()
StrongholdPieces::StrongholdPiece *StrongholdPieces::findAndCreatePieceFactory(EPieceClass pieceClass, list<StructurePiece*> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth)
{
- StrongholdPiece *strongholdPiece = NULL;
+ StrongholdPiece *strongholdPiece = nullptr;
if (pieceClass == EPieceClass_Straight)
{
@@ -145,7 +145,7 @@ StrongholdPieces::StrongholdPiece *StrongholdPieces::generatePieceFromSmallDoor(
{
if (!updatePieceWeight())
{
- return NULL;
+ return nullptr;
}
if (imposedPiece != EPieceClass_NULL)
@@ -153,7 +153,7 @@ StrongholdPieces::StrongholdPiece *StrongholdPieces::generatePieceFromSmallDoor(
StrongholdPiece *strongholdPiece = findAndCreatePieceFactory(imposedPiece, pieces, random, footX, footY, footZ, direction, depth);
imposedPiece = EPieceClass_NULL;
- if (strongholdPiece != NULL)
+ if (strongholdPiece != nullptr)
{
return strongholdPiece;
}
@@ -176,7 +176,7 @@ StrongholdPieces::StrongholdPiece *StrongholdPieces::generatePieceFromSmallDoor(
}
StrongholdPiece *strongholdPiece = findAndCreatePieceFactory(piece->pieceClass, pieces, random, footX, footY, footZ, direction, depth);
- if (strongholdPiece != NULL)
+ if (strongholdPiece != nullptr)
{
piece->placeCount++;
startPiece->previousPiece = piece;
@@ -192,21 +192,21 @@ StrongholdPieces::StrongholdPiece *StrongholdPieces::generatePieceFromSmallDoor(
}
{
BoundingBox *box = FillerCorridor::findPieceBox(pieces, random, footX, footY, footZ, direction);
- if (box != NULL && box->y0 > 1)
+ if (box != nullptr && box->y0 > 1)
{
return new FillerCorridor(depth, random, box, direction);
}
- if(box != NULL) delete box;
+ if(box != nullptr) delete box;
}
- return NULL;
+ return nullptr;
}
StructurePiece *StrongholdPieces::generateAndAddPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth)
{
if (depth > MAX_DEPTH)
{
- return NULL;
+ return nullptr;
}
if (abs(footX - startPiece->getBoundingBox()->x0) > 3 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 3 * 16)
{
@@ -221,7 +221,7 @@ StructurePiece *StrongholdPieces::generateAndAddPiece(StartPiece *startPiece, li
printf("Portal room forcing attempt\n");
#endif
StrongholdPiece *strongholdPiece = PortalRoom::createPiece(pieces, random, footX, footY, footZ, direction, depth);
- if (strongholdPiece != NULL)
+ if (strongholdPiece != nullptr)
{
piece->placeCount++;
startPiece->previousPiece = piece;
@@ -237,11 +237,11 @@ StructurePiece *StrongholdPieces::generateAndAddPiece(StartPiece *startPiece, li
}
}
}
- return NULL;
+ return nullptr;
}
StructurePiece *newPiece = generatePieceFromSmallDoor(startPiece, pieces, random, footX, footY, footZ, direction, depth + 1);
- if (newPiece != NULL)
+ if (newPiece != nullptr)
{
pieces->push_back(newPiece);
startPiece->pendingChildren.push_back(newPiece);
@@ -268,7 +268,7 @@ void StrongholdPieces::StrongholdPiece::addAdditonalSaveData(CompoundTag *tag)
void StrongholdPieces::StrongholdPiece::readAdditonalSaveData(CompoundTag *tag)
{
- entryDoor = (SmallDoorType)_fromString<int>(tag->getString(L"EntryDoor"));
+ entryDoor = static_cast<SmallDoorType>(_fromString<int>(tag->getString(L"EntryDoor")));
}
void StrongholdPieces::StrongholdPiece::generateSmallDoor(Level *level, Random *random, BoundingBox *chunkBB, StrongholdPieces::StrongholdPiece::SmallDoorType doorType, int footX, int footY, int footZ)
@@ -349,7 +349,7 @@ StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildForward
case Direction::EAST:
return generateAndAddPiece(startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0 + yOff, boundingBox->z0 + xOff, orientation, getGenDepth());
}
- return NULL;
+ return nullptr;
}
StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildLeft(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff)
@@ -365,7 +365,7 @@ StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildLeft(St
case Direction::EAST:
return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth());
}
- return NULL;
+ return nullptr;
}
StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildRight(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff)
@@ -381,20 +381,20 @@ StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildRight(S
case Direction::EAST:
return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth());
}
- return NULL;
+ return nullptr;
}
bool StrongholdPieces::StrongholdPiece::isOkBox(BoundingBox *box, StartPiece *startRoom)
{
- //return box != NULL && box->y0 > LOWEST_Y_POSITION;
+ //return box != nullptr && box->y0 > LOWEST_Y_POSITION;
bool bIsOk = false;
- if(box != NULL)
+ if(box != nullptr)
{
if( box->y0 > LOWEST_Y_POSITION ) bIsOk = true;
- if( startRoom != NULL && startRoom->m_level->getOriginalSaveVersion() >= SAVE_FILE_VERSION_MOVED_STRONGHOLD )
+ if( startRoom != nullptr && startRoom->m_level->getOriginalSaveVersion() >= SAVE_FILE_VERSION_MOVED_STRONGHOLD )
{
int xzSize = startRoom->m_level->getLevelData()->getXZSize();
int blockMin = -( (xzSize << 4) / 2) + 1;
@@ -442,12 +442,12 @@ BoundingBox *StrongholdPieces::FillerCorridor::findPieceBox(list<StructurePiece
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)
@@ -468,7 +468,7 @@ BoundingBox *StrongholdPieces::FillerCorridor::findPieceBox(list<StructurePiece
}
}
- return NULL;
+ return nullptr;
}
bool StrongholdPieces::FillerCorridor::postProcess(Level *level, Random *random, BoundingBox *chunkBB)
@@ -554,20 +554,20 @@ void StrongholdPieces::StairsDown::addChildren(StructurePiece *startPiece, list<
{
imposedPiece = EPieceClass_FiveCrossing;
}
- generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1);
+ generateSmallDoorChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 1, 1);
}
StrongholdPieces::StairsDown *StrongholdPieces::StairsDown::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 4 - height, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new StairsDown(genDepth, random, box, direction);
@@ -618,15 +618,15 @@ StrongholdPieces::StartPiece::StartPiece(int genDepth, Random *random, int west,
{
// 4J added initialisers
isLibraryAdded = false;
- previousPiece = NULL;
- portalRoomPiece = NULL;
+ previousPiece = nullptr;
+ portalRoomPiece = nullptr;
m_level = level;
}
TilePos *StrongholdPieces::StartPiece::getLocatorPosition()
{
- if( portalRoomPiece != NULL )
+ if( portalRoomPiece != nullptr )
{
return portalRoomPiece->getLocatorPosition();
}
@@ -663,22 +663,22 @@ void StrongholdPieces::Straight::readAdditonalSaveData(CompoundTag *tag)
void StrongholdPieces::Straight::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1);
- if (leftChild) generateSmallDoorChildLeft((StartPiece *) startPiece, pieces, random, 1, 2);
- if (rightChild) generateSmallDoorChildRight((StartPiece *) startPiece, pieces, random, 1, 2);
+ generateSmallDoorChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 1, 1);
+ if (leftChild) generateSmallDoorChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, 1, 2);
+ if (rightChild) generateSmallDoorChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 1, 2);
}
StrongholdPieces::Straight *StrongholdPieces::Straight::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new Straight(genDepth, random, box, direction);
@@ -765,20 +765,20 @@ void StrongholdPieces::ChestCorridor::readAdditonalSaveData(CompoundTag *tag)
void StrongholdPieces::ChestCorridor::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1);
+ generateSmallDoorChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 1, 1);
}
StrongholdPieces::ChestCorridor *StrongholdPieces::ChestCorridor::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new ChestCorridor(genDepth, random, box, direction);
@@ -837,20 +837,20 @@ StrongholdPieces::StraightStairsDown::StraightStairsDown(int genDepth, Random *r
void StrongholdPieces::StraightStairsDown::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1);
+ generateSmallDoorChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 1, 1);
}
StrongholdPieces::StraightStairsDown *StrongholdPieces::StraightStairsDown::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 4 - height, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new StraightStairsDown(genDepth, random, box, direction);
@@ -904,11 +904,11 @@ void StrongholdPieces::LeftTurn::addChildren(StructurePiece *startPiece, list<St
{
if (orientation == Direction::NORTH || orientation == Direction::EAST)
{
- generateSmallDoorChildLeft((StartPiece *) startPiece, pieces, random, 1, 1);
+ generateSmallDoorChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, 1, 1);
}
else
{
- generateSmallDoorChildRight((StartPiece *) startPiece, pieces, random, 1, 1);
+ generateSmallDoorChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 1, 1);
}
}
@@ -916,13 +916,13 @@ StrongholdPieces::LeftTurn *StrongholdPieces::LeftTurn::createPiece(list<Structu
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new LeftTurn(genDepth, random, box, direction);
@@ -965,11 +965,11 @@ void StrongholdPieces::RightTurn::addChildren(StructurePiece *startPiece, list<S
{
if (orientation == Direction::NORTH || orientation == Direction::EAST)
{
- generateSmallDoorChildRight((StartPiece *) startPiece, pieces, random, 1, 1);
+ generateSmallDoorChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 1, 1);
}
else
{
- generateSmallDoorChildLeft((StartPiece *) startPiece, pieces, random, 1, 1);
+ generateSmallDoorChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, 1, 1);
}
}
@@ -1023,22 +1023,22 @@ void StrongholdPieces::RoomCrossing::readAdditonalSaveData(CompoundTag *tag)
void StrongholdPieces::RoomCrossing::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateSmallDoorChildForward((StartPiece*) startPiece, pieces, random, 4, 1);
- generateSmallDoorChildLeft((StartPiece*) startPiece, pieces, random, 1, 4);
- generateSmallDoorChildRight((StartPiece*) startPiece, pieces, random, 1, 4);
+ generateSmallDoorChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 4, 1);
+ generateSmallDoorChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, 1, 4);
+ generateSmallDoorChildRight(static_cast<StartPiece *>(startPiece), pieces, random, 1, 4);
}
StrongholdPieces::RoomCrossing *StrongholdPieces::RoomCrossing::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -4, -1, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new RoomCrossing(genDepth, random, box, direction);
@@ -1177,20 +1177,20 @@ StrongholdPieces::PrisonHall::PrisonHall(int genDepth, Random *random, BoundingB
void StrongholdPieces::PrisonHall::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1);
+ generateSmallDoorChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 1, 1);
}
StrongholdPieces::PrisonHall *StrongholdPieces::PrisonHall::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new PrisonHall(genDepth, random, box, direction);
@@ -1263,19 +1263,19 @@ StrongholdPieces::Library *StrongholdPieces::Library::createPiece(list<Structure
// attempt to make a tall library first
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -4, -1, 0, width, tallHeight, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
// make a short library
box = BoundingBox::orientBox(footX, footY, footZ, -4, -1, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
}
@@ -1465,24 +1465,24 @@ void StrongholdPieces::FiveCrossing::addChildren(StructurePiece *startPiece, lis
zOffB = depth - 3 - zOffB;
}
- generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 5, 1);
- if (leftLow) generateSmallDoorChildLeft((StartPiece *) startPiece, pieces, random, zOffA, 1);
- if (leftHigh) generateSmallDoorChildLeft((StartPiece *) startPiece, pieces, random, zOffB, 7);
- if (rightLow) generateSmallDoorChildRight((StartPiece *) startPiece, pieces, random, zOffA, 1);
- if (rightHigh) generateSmallDoorChildRight((StartPiece *) startPiece, pieces, random, zOffB, 7);
+ generateSmallDoorChildForward(static_cast<StartPiece *>(startPiece), pieces, random, 5, 1);
+ if (leftLow) generateSmallDoorChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, zOffA, 1);
+ if (leftHigh) generateSmallDoorChildLeft(static_cast<StartPiece *>(startPiece), pieces, random, zOffB, 7);
+ if (rightLow) generateSmallDoorChildRight(static_cast<StartPiece *>(startPiece), pieces, random, zOffA, 1);
+ if (rightHigh) generateSmallDoorChildRight(static_cast<StartPiece *>(startPiece), pieces, random, zOffB, 7);
}
StrongholdPieces::FiveCrossing *StrongholdPieces::FiveCrossing::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth)
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -4, -3, 0, width, height, depth, direction);
- StartPiece *startPiece = NULL;
- if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new FiveCrossing(genDepth, random, box, direction);
@@ -1561,9 +1561,9 @@ void StrongholdPieces::PortalRoom::readAdditonalSaveData(CompoundTag *tag)
void StrongholdPieces::PortalRoom::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- if (startPiece != NULL)
+ if (startPiece != nullptr)
{
- ((StartPiece *) startPiece)->portalRoomPiece = this;
+ static_cast<StartPiece *>(startPiece)->portalRoomPiece = this;
}
}
@@ -1572,13 +1572,13 @@ StrongholdPieces::PortalRoom *StrongholdPieces::PortalRoom::createPiece(list<Str
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -4, -1, 0, width, height, depth, direction);
// 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 = ((StrongholdPieces::StartPiece *) pieces->front());
+ StartPiece *startPiece = nullptr;
+ if(pieces != nullptr) startPiece = static_cast<StrongholdPieces::StartPiece *>(pieces->front());
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new PortalRoom(genDepth, random, box, direction);
@@ -1688,7 +1688,7 @@ bool StrongholdPieces::PortalRoom::postProcess(Level *level, Random *random, Bou
hasPlacedMobSpawner = true;
level->setTileAndData(x, y, z, Tile::mobSpawner_Id, 0, Tile::UPDATE_CLIENTS);
shared_ptr<MobSpawnerTileEntity> entity = dynamic_pointer_cast<MobSpawnerTileEntity>(level->getTileEntity(x, y, z));
- if (entity != NULL) entity->getSpawner()->setEntityId(L"Silverfish");
+ if (entity != nullptr) entity->getSpawner()->setEntityId(L"Silverfish");
}
}
diff --git a/Minecraft.World/StructureFeature.cpp b/Minecraft.World/StructureFeature.cpp
index bbce7e1a..8de619ca 100644
--- a/Minecraft.World/StructureFeature.cpp
+++ b/Minecraft.World/StructureFeature.cpp
@@ -109,7 +109,7 @@ bool StructureFeature::isIntersection(int cellX, int cellZ)
bool StructureFeature::isInsideFeature(int cellX, int cellY, int cellZ)
{
restoreSavedData(level);
- return getStructureAt(cellX, cellY, cellZ) != NULL;
+ return getStructureAt(cellX, cellY, cellZ) != nullptr;
}
StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ)
@@ -142,7 +142,7 @@ StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ
}
}
}
- return NULL;
+ return nullptr;
}
bool StructureFeature::isInsideBoundingFeature(int cellX, int cellY, int cellZ)
@@ -178,7 +178,7 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i
addFeature(level, cellX >> 4, cellZ >> 4, 0, 0, byteArray());
double minDistance = DBL_MAX;
- TilePos *selected = NULL;
+ TilePos *selected = nullptr;
for(auto& it : cachedStructures)
{
@@ -203,14 +203,14 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i
}
}
}
- if (selected != NULL)
+ if (selected != nullptr)
{
return selected;
}
else
{
vector<TilePos> *guesstimatedFeaturePositions = getGuesstimatedFeaturePositions();
- if (guesstimatedFeaturePositions != NULL)
+ if (guesstimatedFeaturePositions != nullptr)
{
TilePos *pSelectedPos = new TilePos(0,0,0);
@@ -233,22 +233,22 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i
return pSelectedPos;
}
}
- return NULL;
+ return nullptr;
}
vector<TilePos> *StructureFeature::getGuesstimatedFeaturePositions()
{
- return NULL;
+ return nullptr;
}
void StructureFeature::restoreSavedData(Level *level)
{
#ifdef ENABLE_STRUCTURE_SAVING
- if (savedData == NULL)
+ if (savedData == nullptr)
{
savedData = dynamic_pointer_cast<StructureFeatureSavedData>( level->getSavedData(typeid(StructureFeatureSavedData), getFeatureName()) );
- if (savedData == NULL)
+ if (savedData == nullptr)
{
savedData = shared_ptr<StructureFeatureSavedData>( new StructureFeatureSavedData(getFeatureName()) );
level->setSavedData(getFeatureName(), savedData);
diff --git a/Minecraft.World/StructureFeatureIO.cpp b/Minecraft.World/StructureFeatureIO.cpp
index 3e73b028..784d14c9 100644
--- a/Minecraft.World/StructureFeatureIO.cpp
+++ b/Minecraft.World/StructureFeatureIO.cpp
@@ -63,7 +63,7 @@ wstring StructureFeatureIO::getEncodeId(StructurePiece *piece)
StructureStart *StructureFeatureIO::loadStaticStart(CompoundTag *tag, Level *level)
{
- StructureStart *start = NULL;
+ StructureStart *start = nullptr;
auto it = startIdClassMap.find(tag->getString(L"id"));
if(it != startIdClassMap.end())
@@ -71,7 +71,7 @@ StructureStart *StructureFeatureIO::loadStaticStart(CompoundTag *tag, Level *lev
start = (it->second)();
}
- if (start != NULL)
+ if (start != nullptr)
{
start->load(level, tag);
}
@@ -84,7 +84,7 @@ StructureStart *StructureFeatureIO::loadStaticStart(CompoundTag *tag, Level *lev
StructurePiece *StructureFeatureIO::loadStaticPiece(CompoundTag *tag, Level *level)
{
- StructurePiece *piece = NULL;
+ StructurePiece *piece = nullptr;
auto it = pieceIdClassMap.find(tag->getString(L"id"));
if(it != pieceIdClassMap.end())
@@ -92,7 +92,7 @@ StructurePiece *StructureFeatureIO::loadStaticPiece(CompoundTag *tag, Level *lev
piece = (it->second)();
}
- if (piece != NULL)
+ if (piece != nullptr)
{
piece->load(level, tag);
}
diff --git a/Minecraft.World/StructurePiece.cpp b/Minecraft.World/StructurePiece.cpp
index 85a19ab4..bb3887c0 100644
--- a/Minecraft.World/StructurePiece.cpp
+++ b/Minecraft.World/StructurePiece.cpp
@@ -44,7 +44,7 @@
StructurePiece::StructurePiece()
{
- boundingBox = NULL;
+ boundingBox = nullptr;
orientation = 0;
genDepth = 0;
// for reflection
@@ -52,14 +52,14 @@ StructurePiece::StructurePiece()
StructurePiece::StructurePiece( int genDepth )
{
- boundingBox = NULL;
+ boundingBox = nullptr;
this->genDepth = genDepth;
orientation = Direction::UNDEFINED;
}
StructurePiece::~StructurePiece()
{
- if(boundingBox != NULL) delete boundingBox;
+ if(boundingBox != nullptr) delete boundingBox;
}
CompoundTag *StructurePiece::createTag()
@@ -120,7 +120,7 @@ StructurePiece* StructurePiece::findCollisionPiece( list< StructurePiece* > *pie
return piece;
}
}
- return NULL;
+ return nullptr;
}
// 4J-PB - Added from 1.2.3
@@ -437,7 +437,7 @@ int StructurePiece::getOrientationData( int tile, int data )
}
}
}
- else if (tile == Tile::tripWireSource_Id || (Tile::tiles[tile] != NULL && dynamic_cast<DirectionalTile *>(Tile::tiles[tile])))
+ else if (tile == Tile::tripWireSource_Id || (Tile::tiles[tile] != nullptr && dynamic_cast<DirectionalTile *>(Tile::tiles[tile])))
{
if (orientation == Direction::SOUTH)
{
@@ -730,15 +730,15 @@ void StructurePiece::maybeGenerateBlock( Level* level, BoundingBox* chunkBB, Ran
void StructurePiece::generateUpperHalfSphere( Level* level, BoundingBox* chunkBB, int x0, int y0, int z0, int x1,
int y1, int z1, int fillTile, bool skipAir )
{
- float diagX = (float)( x1 - x0 + 1 );
- float diagY = (float)( y1 - y0 + 1 );
- float diagZ = (float)( z1 - z0 + 1 );
+ float diagX = static_cast<float>(x1 - x0 + 1);
+ float diagY = static_cast<float>(y1 - y0 + 1);
+ float diagZ = static_cast<float>(z1 - z0 + 1);
float cx = x0 + diagX / 2;
float cz = z0 + diagZ / 2;
for ( int y = y0; y <= y1; y++ )
{
- float normalizedYDistance = ( float )( y - y0 ) / diagY;
+ float normalizedYDistance = static_cast<float>(y - y0) / diagY;
for ( int x = x0; x <= x1; x++ )
{
@@ -816,7 +816,7 @@ bool StructurePiece::createChest( Level* level, BoundingBox* chunkBB, Random* ra
{
level->setTileAndData( worldX, worldY, worldZ, Tile::chest->id, 0, Tile::UPDATE_CLIENTS );
shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(level->getTileEntity( worldX, worldY, worldZ ));
- if ( chest != NULL ) WeighedTreasure::addChestItems( random, treasure, chest, numRolls );
+ if ( chest != nullptr ) WeighedTreasure::addChestItems( random, treasure, chest, numRolls );
return true;
}
}
@@ -835,7 +835,7 @@ bool StructurePiece::createDispenser(Level *level, BoundingBox *chunkBB, Random
{
level->setTileAndData(worldX, worldY, worldZ, Tile::dispenser_Id, getOrientationData(Tile::dispenser_Id, facing), Tile::UPDATE_CLIENTS);
shared_ptr<DispenserTileEntity> dispenser = dynamic_pointer_cast<DispenserTileEntity>(level->getTileEntity(worldX, worldY, worldZ));
- if (dispenser != NULL) WeighedTreasure::addDispenserItems(random, items, dispenser, numRolls);
+ if (dispenser != nullptr) WeighedTreasure::addDispenserItems(random, items, dispenser, numRolls);
return true;
}
}
diff --git a/Minecraft.World/StructureRecipies.cpp b/Minecraft.World/StructureRecipies.cpp
index c3e62863..1706a7ce 100644
--- a/Minecraft.World/StructureRecipies.cpp
+++ b/Minecraft.World/StructureRecipies.cpp
@@ -66,7 +66,7 @@ void StructureRecipies::addRecipes(Recipes *r)
L'#', Tile::cobblestone,
L'S');
- r->addShapedRecipy(new ItemInstance((Tile*)Tile::chest), //
+ r->addShapedRecipy(new ItemInstance(static_cast<Tile *>(Tile::chest)), //
L"sssctg",
L"###", //
L"# #", //
diff --git a/Minecraft.World/StructureStart.cpp b/Minecraft.World/StructureStart.cpp
index 3f22b4a7..0065160e 100644
--- a/Minecraft.World/StructureStart.cpp
+++ b/Minecraft.World/StructureStart.cpp
@@ -9,14 +9,14 @@
StructureStart::StructureStart()
{
chunkX = chunkZ = 0;
- boundingBox = NULL; // 4J added initialiser
+ boundingBox = nullptr; // 4J added initialiser
}
StructureStart::StructureStart(int x, int z)
{
this->chunkX = x;
this->chunkZ = z;
- boundingBox = NULL;
+ boundingBox = nullptr;
}
StructureStart::~StructureStart()
diff --git a/Minecraft.World/SwampTreeFeature.cpp b/Minecraft.World/SwampTreeFeature.cpp
index 19d3f66a..5b94767a 100644
--- a/Minecraft.World/SwampTreeFeature.cpp
+++ b/Minecraft.World/SwampTreeFeature.cpp
@@ -14,7 +14,7 @@ bool SwampTreeFeature::place(Level *level, Random *random, int x, int y, int z)
if (y < 1 || y + treeHeight + 1 > Level::genDepth) return false;
// 4J Stu Added to stop tree features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
bool intersects = levelGenOptions->checkIntersects(x - 3, y - 1, z - 3, x + 3, y + treeHeight, z + 3);
diff --git a/Minecraft.World/SwellGoal.cpp b/Minecraft.World/SwellGoal.cpp
index 040d09c2..0fd3c34a 100644
--- a/Minecraft.World/SwellGoal.cpp
+++ b/Minecraft.World/SwellGoal.cpp
@@ -16,7 +16,7 @@ SwellGoal::SwellGoal(Creeper *creeper)
bool SwellGoal::canUse()
{
shared_ptr<LivingEntity> target = creeper->getTarget();
- return creeper->getSwellDir() > 0 || (target != NULL && (creeper->distanceToSqr(target) < 3 * 3));
+ return creeper->getSwellDir() > 0 || (target != nullptr && (creeper->distanceToSqr(target) < 3 * 3));
}
void SwellGoal::start()
@@ -32,7 +32,7 @@ void SwellGoal::stop()
void SwellGoal::tick()
{
- if (target.lock() == NULL)
+ if (target.lock() == nullptr)
{
creeper->setSwellDir(-1);
return;
diff --git a/Minecraft.World/SynchedEntityData.cpp b/Minecraft.World/SynchedEntityData.cpp
index 655fa0c3..69d419b0 100644
--- a/Minecraft.World/SynchedEntityData.cpp
+++ b/Minecraft.World/SynchedEntityData.cpp
@@ -19,7 +19,7 @@ void SynchedEntityData::define(int id, int value)
MemSect(17);
checkId(id);
int type = TYPE_INT;
- shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) );
+ shared_ptr<DataItem> dataItem = std::make_shared<DataItem>(type, id, value);
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
@@ -30,7 +30,7 @@ void SynchedEntityData::define(int id, byte value)
MemSect(17);
checkId(id);
int type = TYPE_BYTE;
- shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) );
+ shared_ptr<DataItem> dataItem = std::make_shared<DataItem>(type, id, value);
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
@@ -41,7 +41,7 @@ void SynchedEntityData::define(int id, short value)
MemSect(17);
checkId(id);
int type = TYPE_SHORT;
- shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) );
+ shared_ptr<DataItem> dataItem = std::make_shared<DataItem>(type, id, value);
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
@@ -52,7 +52,7 @@ void SynchedEntityData::define(int id, float value)
MemSect(17);
checkId(id);
int type = TYPE_FLOAT;
- shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) );
+ shared_ptr<DataItem> dataItem = std::make_shared<DataItem>(type, id, value);
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
@@ -63,7 +63,7 @@ void SynchedEntityData::define(int id, const wstring& value)
MemSect(17);
checkId(id);
int type = TYPE_STRING;
- shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) );
+ shared_ptr<DataItem> dataItem = std::make_shared<DataItem>(type, id, value);
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
@@ -74,7 +74,7 @@ void SynchedEntityData::defineNULL(int id, void *pVal)
MemSect(17);
checkId(id);
int type = TYPE_ITEMINSTANCE;
- shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, shared_ptr<ItemInstance>()) );
+ shared_ptr<DataItem> dataItem = std::make_shared<DataItem>(type, id, shared_ptr<ItemInstance>());
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
@@ -128,7 +128,7 @@ shared_ptr<ItemInstance> SynchedEntityData::getItemInstance(int id)
Pos *SynchedEntityData::getPos(int id)
{
assert(false); // 4J - not currently implemented
- return NULL;
+ return nullptr;
}
void SynchedEntityData::set(int id, int value)
@@ -238,18 +238,18 @@ void SynchedEntityData::pack(vector<shared_ptr<DataItem> > *items, DataOutputStr
vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::packDirty()
{
- vector<shared_ptr<DataItem> > *result = NULL;
+ vector<shared_ptr<DataItem> > *result = nullptr;
if (m_isDirty)
{
for( int i = 0; i <= MAX_ID_VALUE; i++ )
{
shared_ptr<DataItem> dataItem = itemsById[i];
- if ((dataItem != NULL) && dataItem->isDirty())
+ if ((dataItem != nullptr) && dataItem->isDirty())
{
dataItem->setDirty(false);
- if (result == NULL)
+ if (result == nullptr)
{
result = new vector<shared_ptr<DataItem> >();
}
@@ -267,7 +267,7 @@ void SynchedEntityData::packAll(DataOutputStream *output) // throws IOException
for( int i = 0; i <= MAX_ID_VALUE; i++ )
{
shared_ptr<DataItem> dataItem = itemsById[i];
- if(dataItem != NULL)
+ if(dataItem != nullptr)
{
writeDataItem(output, dataItem);
}
@@ -279,14 +279,14 @@ void SynchedEntityData::packAll(DataOutputStream *output) // throws IOException
vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::getAll()
{
- vector<shared_ptr<DataItem> > *result = NULL;
+ vector<shared_ptr<DataItem> > *result = nullptr;
for( int i = 0; i <= MAX_ID_VALUE; i++ )
{
shared_ptr<DataItem> dataItem = itemsById[i];
- if(dataItem != NULL)
+ if(dataItem != nullptr)
{
- if (result == NULL)
+ if (result == nullptr)
{
result = new vector<shared_ptr<DataItem> >();
}
@@ -338,14 +338,14 @@ void SynchedEntityData::writeDataItem(DataOutputStream *output, shared_ptr<DataI
vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(DataInputStream *input) //throws IOException
{
- vector<shared_ptr<DataItem> > *result = NULL;
+ vector<shared_ptr<DataItem> > *result = nullptr;
int currentHeader = input->readByte();
while (currentHeader != EOF_MARKER)
{
- if (result == NULL)
+ if (result == nullptr)
{
result = new vector<shared_ptr<DataItem> >();
}
@@ -360,40 +360,40 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
case TYPE_BYTE:
{
byte dataRead = input->readByte();
- item = shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) );
+ item = std::make_shared<DataItem>(itemType, itemId, dataRead);
}
break;
case TYPE_SHORT:
{
short dataRead = input->readShort();
- item = shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) );
+ item = std::make_shared<DataItem>(itemType, itemId, dataRead);
}
break;
case TYPE_INT:
{
int dataRead = input->readInt();
- item = shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) );
+ item = std::make_shared<DataItem>(itemType, itemId, dataRead);
}
break;
case TYPE_FLOAT:
{
float dataRead = input->readFloat();
- item = shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) );
+ item = std::make_shared<DataItem>(itemType, itemId, dataRead);
}
break;
case TYPE_STRING:
- item = shared_ptr<DataItem>( new DataItem(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)) );
+ item = std::make_shared<DataItem>(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH));
break;
case TYPE_ITEMINSTANCE:
{
- item = shared_ptr<DataItem>(new DataItem(itemType, itemId, Packet::readItem(input)));
+ item = std::make_shared<DataItem>(itemType, itemId, Packet::readItem(input));
}
break;
default:
app.DebugPrintf(" ------ garbage data, or early end of stream due to an incomplete packet\n");
delete result;
- return NULL;
+ return nullptr;
break;
}
result->push_back(item);
@@ -415,7 +415,7 @@ void SynchedEntityData::assignValues(vector<shared_ptr<DataItem> > *items)
for (auto& item : *items)
{
shared_ptr<DataItem> itemFromId = itemsById[item->getId()];
- if( itemFromId != NULL )
+ if( itemFromId != nullptr )
{
switch(item->getType())
{
@@ -465,7 +465,7 @@ int SynchedEntityData::getSizeInBytes()
for( int i = 0; i <= MAX_ID_VALUE; i++ )
{
shared_ptr<DataItem> dataItem = itemsById[i];
- if(dataItem != NULL)
+ if(dataItem != nullptr)
{
size += 1;
@@ -485,7 +485,7 @@ int SynchedEntityData::getSizeInBytes()
size += 4;
break;
case TYPE_STRING:
- size += (int)dataItem->getValue_wstring().length() + 2; // Estimate, assuming all ascii chars
+ size += static_cast<int>(dataItem->getValue_wstring().length()) + 2; // Estimate, assuming all ascii chars
break;
case TYPE_ITEMINSTANCE:
// short + byte + short
diff --git a/Minecraft.World/Tag.cpp b/Minecraft.World/Tag.cpp
index aa988e02..b594bb0e 100644
--- a/Minecraft.World/Tag.cpp
+++ b/Minecraft.World/Tag.cpp
@@ -27,7 +27,7 @@ Tag::Tag(const wstring &name)
// 4J - Was Object obj
bool Tag::equals(Tag *obj)
{
- if (obj == NULL )// || !(obj instanceof Tag))
+ if (obj == nullptr )// || !(obj instanceof Tag))
{
return false;
}
@@ -150,7 +150,7 @@ Tag *Tag::newTag(byte type, const wstring &name)
case TAG_Compound:
return new CompoundTag(name);
}
- return NULL;
+ return nullptr;
}
const wchar_t *Tag::getTagName(byte type)
diff --git a/Minecraft.World/TakeFlowerGoal.cpp b/Minecraft.World/TakeFlowerGoal.cpp
index 48db34d3..71e7c7c6 100644
--- a/Minecraft.World/TakeFlowerGoal.cpp
+++ b/Minecraft.World/TakeFlowerGoal.cpp
@@ -53,12 +53,12 @@ bool TakeFlowerGoal::canUse()
bool TakeFlowerGoal::canContinueToUse()
{
- return golem.lock() != NULL && golem.lock()->getOfferFlowerTick() > 0;
+ return golem.lock() != nullptr && golem.lock()->getOfferFlowerTick() > 0;
}
void TakeFlowerGoal::start()
{
- pickupTick = villager->getRandom()->nextInt((int) (OfferFlowerGoal::OFFER_TICKS * 0.8));
+ pickupTick = villager->getRandom()->nextInt(static_cast<int>(OfferFlowerGoal::OFFER_TICKS * 0.8));
takeFlower = false;
golem.lock()->getNavigation()->stop();
}
diff --git a/Minecraft.World/TakeItemEntityPacket.h b/Minecraft.World/TakeItemEntityPacket.h
index 7c4b45fe..7acbfdc4 100644
--- a/Minecraft.World/TakeItemEntityPacket.h
+++ b/Minecraft.World/TakeItemEntityPacket.h
@@ -17,6 +17,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TakeItemEntityPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TakeItemEntityPacket>(); }
virtual int getId() { return 22; }
}; \ No newline at end of file
diff --git a/Minecraft.World/TallGrass.cpp b/Minecraft.World/TallGrass.cpp
index 1a89d3ed..337e343d 100644
--- a/Minecraft.World/TallGrass.cpp
+++ b/Minecraft.World/TallGrass.cpp
@@ -81,7 +81,7 @@ int TallGrass::getResourceCountForLootBonus(int bonusLevel, Random *random)
void TallGrass::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y, int z, int data)
{
- if (!level->isClientSide && player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears->id)
+ if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id)
{
player->awardStat(
GenericStats::blocksMined(id),
@@ -89,7 +89,7 @@ void TallGrass::playerDestroy(Level *level, shared_ptr<Player> player, int x, in
);
// drop leaf block instead of sapling
- popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Tile::tallgrass, 1, data)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(Tile::tallgrass, 1, data));
}
else
{
diff --git a/Minecraft.World/TamableAnimal.cpp b/Minecraft.World/TamableAnimal.cpp
index 2a3ea037..1fb41df3 100644
--- a/Minecraft.World/TamableAnimal.cpp
+++ b/Minecraft.World/TamableAnimal.cpp
@@ -13,13 +13,13 @@ TamableAnimal::TamableAnimal(Level *level) : Animal(level)
TamableAnimal::~TamableAnimal()
{
- if(sitGoal != NULL) delete sitGoal;
+ if(sitGoal != nullptr) delete sitGoal;
}
void TamableAnimal::defineSynchedData()
{
Animal::defineSynchedData();
- entityData->define(DATA_FLAGS_ID, (byte) 0);
+ entityData->define(DATA_FLAGS_ID, static_cast<byte>(0));
entityData->define(DATA_OWNERUUID_ID, L"");
}
@@ -113,11 +113,11 @@ void TamableAnimal::setTame(bool value)
byte current = entityData->getByte(DATA_FLAGS_ID);
if (value)
{
- entityData->set(DATA_FLAGS_ID, (byte) (current | 0x04));
+ entityData->set(DATA_FLAGS_ID, static_cast<byte>(current | 0x04));
}
else
{
- entityData->set(DATA_FLAGS_ID, (byte) (current & ~0x04));
+ entityData->set(DATA_FLAGS_ID, static_cast<byte>(current & ~0x04));
}
}
@@ -131,11 +131,11 @@ void TamableAnimal::setSitting(bool value)
byte current = entityData->getByte(DATA_FLAGS_ID);
if (value)
{
- entityData->set(DATA_FLAGS_ID, (byte) (current | 0x01));
+ entityData->set(DATA_FLAGS_ID, static_cast<byte>(current | 0x01));
}
else
{
- entityData->set(DATA_FLAGS_ID, (byte) (current & ~0x01));
+ entityData->set(DATA_FLAGS_ID, static_cast<byte>(current & ~0x01));
}
}
@@ -169,7 +169,7 @@ Team *TamableAnimal::getTeam()
if (isTame())
{
shared_ptr<LivingEntity> owner = dynamic_pointer_cast<LivingEntity>(getOwner());
- if (owner != NULL)
+ if (owner != nullptr)
{
return owner->getTeam();
}
@@ -186,7 +186,7 @@ bool TamableAnimal::isAlliedTo(shared_ptr<LivingEntity> other)
{
return true;
}
- if (owner != NULL)
+ if (owner != nullptr)
{
return owner->isAlliedTo(other);
}
diff --git a/Minecraft.World/TargetGoal.cpp b/Minecraft.World/TargetGoal.cpp
index 982acb5e..0c2b9363 100644
--- a/Minecraft.World/TargetGoal.cpp
+++ b/Minecraft.World/TargetGoal.cpp
@@ -34,7 +34,7 @@ TargetGoal::TargetGoal(PathfinderMob *mob, bool mustSee, bool mustReach)
bool TargetGoal::canContinueToUse()
{
shared_ptr<LivingEntity> target = mob->getTarget();
- if (target == NULL) return false;
+ if (target == nullptr) return false;
if (!target->isAlive()) return false;
double within = getFollowDistance();
@@ -56,7 +56,7 @@ bool TargetGoal::canContinueToUse()
double TargetGoal::getFollowDistance()
{
AttributeInstance *followRange = mob->getAttribute(SharedMonsterAttributes::FOLLOW_RANGE);
- return followRange == NULL ? 16 : followRange->getValue();
+ return followRange == nullptr ? 16 : followRange->getValue();
}
void TargetGoal::start()
@@ -73,16 +73,16 @@ void TargetGoal::stop()
bool TargetGoal::canAttack(shared_ptr<LivingEntity> 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<OwnableEntity *>(mob);
- if (ownableMob != NULL && !ownableMob->getOwnerUUID().empty())
+ if (ownableMob != nullptr && !ownableMob->getOwnerUUID().empty())
{
shared_ptr<OwnableEntity> ownableTarget = dynamic_pointer_cast<OwnableEntity>(target);
- if (ownableTarget != NULL && ownableMob->getOwnerUUID().compare(ownableTarget->getOwnerUUID()) == 0)
+ if (ownableTarget != nullptr && ownableMob->getOwnerUUID().compare(ownableTarget->getOwnerUUID()) == 0)
{
// We're attacking something owned by the same person...
return false;
@@ -117,9 +117,9 @@ bool TargetGoal::canReach(shared_ptr<LivingEntity> target)
{
reachCacheTime = 10 + mob->getRandom()->nextInt(5);
Path *path = mob->getNavigation()->createPath(target);
- if (path == NULL) return false;
+ if (path == nullptr) return false;
Node *last = path->last();
- if (last == NULL)
+ if (last == nullptr)
{
delete path;
return false;
diff --git a/Minecraft.World/Team.cpp b/Minecraft.World/Team.cpp
index f3f6e04e..7c3bde0c 100644
--- a/Minecraft.World/Team.cpp
+++ b/Minecraft.World/Team.cpp
@@ -4,7 +4,7 @@
bool Team::isAlliedTo(Team *other)
{
- if (other == NULL)
+ if (other == nullptr)
{
return false;
}
diff --git a/Minecraft.World/TeleportEntityPacket.cpp b/Minecraft.World/TeleportEntityPacket.cpp
index d31f5bc2..ccac5e51 100644
--- a/Minecraft.World/TeleportEntityPacket.cpp
+++ b/Minecraft.World/TeleportEntityPacket.cpp
@@ -23,8 +23,8 @@ TeleportEntityPacket::TeleportEntityPacket(shared_ptr<Entity> e)
x = Mth::floor(e->x * 32);
y = Mth::floor(e->y * 32);
z = Mth::floor(e->z * 32);
- yRot = (byte) (e->yRot * 256 / 360);
- xRot = (byte) (e->xRot * 256 / 360);
+ yRot = static_cast<byte>(e->yRot * 256 / 360);
+ xRot = static_cast<byte>(e->xRot * 256 / 360);
}
TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, byte yRot, byte xRot)
diff --git a/Minecraft.World/TeleportEntityPacket.h b/Minecraft.World/TeleportEntityPacket.h
index 6fc28732..38e09286 100644
--- a/Minecraft.World/TeleportEntityPacket.h
+++ b/Minecraft.World/TeleportEntityPacket.h
@@ -22,6 +22,6 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TeleportEntityPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TeleportEntityPacket>(); }
virtual int getId() { return 34; }
}; \ No newline at end of file
diff --git a/Minecraft.World/TemptGoal.cpp b/Minecraft.World/TemptGoal.cpp
index aebab8fa..40b3201c 100644
--- a/Minecraft.World/TemptGoal.cpp
+++ b/Minecraft.World/TemptGoal.cpp
@@ -29,10 +29,10 @@ bool TemptGoal::canUse()
return false;
}
player = weak_ptr<Player>(mob->level->getNearestPlayer(mob->shared_from_this(), 10));
- if (player.lock() == NULL) return false;
+ if (player.lock() == nullptr) return false;
mob->setDespawnProtected(); // If we've got a nearby player, then consider this mob as something we'd miss if it despawned
shared_ptr<ItemInstance> item = player.lock()->getSelectedItem();
- if (item == NULL) return false;
+ if (item == nullptr) return false;
if (item->id != itemId) return false;
return true;
}
@@ -41,7 +41,7 @@ bool TemptGoal::canContinueToUse()
{
if (canScare)
{
- if(player.lock() == NULL) return false;
+ if(player.lock() == nullptr) return false;
if (mob->distanceToSqr(player.lock()) < 6 * 6)
{
if (player.lock()->distanceToSqr(px, py, pz) > 0.1 * 0.1) return false;
diff --git a/Minecraft.World/TextureAndGeometryChangePacket.cpp b/Minecraft.World/TextureAndGeometryChangePacket.cpp
index 04c88bed..ec84031f 100644
--- a/Minecraft.World/TextureAndGeometryChangePacket.cpp
+++ b/Minecraft.World/TextureAndGeometryChangePacket.cpp
@@ -49,5 +49,5 @@ void TextureAndGeometryChangePacket::handle(PacketListener *listener)
int TextureAndGeometryChangePacket::getEstimatedSize()
{
- return 8 + (int)path.size();
+ return 8 + static_cast<int>(path.size());
}
diff --git a/Minecraft.World/TextureAndGeometryChangePacket.h b/Minecraft.World/TextureAndGeometryChangePacket.h
index dabe78fa..812222fc 100644
--- a/Minecraft.World/TextureAndGeometryChangePacket.h
+++ b/Minecraft.World/TextureAndGeometryChangePacket.h
@@ -20,6 +20,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TextureAndGeometryChangePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TextureAndGeometryChangePacket>(); }
virtual int getId() { return 161; }
}; \ No newline at end of file
diff --git a/Minecraft.World/TextureAndGeometryPacket.cpp b/Minecraft.World/TextureAndGeometryPacket.cpp
index d28fc862..bf5eccdb 100644
--- a/Minecraft.World/TextureAndGeometryPacket.cpp
+++ b/Minecraft.World/TextureAndGeometryPacket.cpp
@@ -10,21 +10,21 @@ TextureAndGeometryPacket::TextureAndGeometryPacket()
{
this->textureName = L"";
this->dwTextureBytes = 0;
- this->pbData = NULL;
+ this->pbData = nullptr;
this->dwBoxC = 0;
- this->BoxDataA = NULL;
+ this->BoxDataA = nullptr;
uiAnimOverrideBitmask=0;
}
TextureAndGeometryPacket::~TextureAndGeometryPacket()
{
// can't free these - they're used elsewhere
-// if(this->BoxDataA!=NULL)
+// if(this->BoxDataA!=nullptr)
// {
// delete [] this->BoxDataA;
// }
//
-// if(this->pbData!=NULL)
+// if(this->pbData!=nullptr)
// {
// delete [] this->pbData;
// }
@@ -43,7 +43,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P
this->pbData = pbData;
this->dwTextureBytes = dwBytes;
this->dwBoxC = 0;
- this->BoxDataA=NULL;
+ this->BoxDataA=nullptr;
this->uiAnimOverrideBitmask=0;
}
@@ -75,7 +75,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P
}
else
{
- this->BoxDataA=NULL;
+ this->BoxDataA=nullptr;
}
}
@@ -93,14 +93,14 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P
this->pbData = pbData;
this->dwTextureBytes = dwBytes;
this->uiAnimOverrideBitmask = uiAnimOverrideBitmask;
- if(pvSkinBoxes==NULL)
+ if(pvSkinBoxes==nullptr)
{
this->dwBoxC=0;
- this->BoxDataA=NULL;
+ this->BoxDataA=nullptr;
}
else
{
- this->dwBoxC = (DWORD)pvSkinBoxes->size();
+ this->dwBoxC = static_cast<DWORD>(pvSkinBoxes->size());
this->BoxDataA= new SKIN_BOX [this->dwBoxC];
int iCount=0;
@@ -120,8 +120,8 @@ void TextureAndGeometryPacket::handle(PacketListener *listener)
void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
{
textureName = dis->readUTF();
- dwSkinID = (DWORD)dis->readInt();
- dwTextureBytes = (DWORD)dis->readShort();
+ dwSkinID = static_cast<DWORD>(dis->readInt());
+ dwTextureBytes = static_cast<DWORD>(dis->readShort());
if(dwTextureBytes>0)
{
@@ -134,7 +134,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
}
uiAnimOverrideBitmask = dis->readInt();
- dwBoxC = (DWORD)dis->readShort();
+ dwBoxC = static_cast<DWORD>(dis->readShort());
if(dwBoxC>0)
{
@@ -143,7 +143,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
for(DWORD i=0;i<dwBoxC;i++)
{
- this->BoxDataA[i].ePart = (eBodyPart) dis->readShort();
+ this->BoxDataA[i].ePart = static_cast<eBodyPart>(dis->readShort());
this->BoxDataA[i].fX = dis->readFloat();
this->BoxDataA[i].fY = dis->readFloat();
this->BoxDataA[i].fZ = dis->readFloat();
@@ -159,17 +159,17 @@ void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeUTF(textureName);
dos->writeInt(dwSkinID);
- dos->writeShort((short)dwTextureBytes);
+ dos->writeShort(static_cast<short>(dwTextureBytes));
for(DWORD i=0;i<dwTextureBytes;i++)
{
dos->writeByte(this->pbData[i]);
}
dos->writeInt(uiAnimOverrideBitmask);
- dos->writeShort((short)dwBoxC);
+ dos->writeShort(static_cast<short>(dwBoxC));
for(DWORD i=0;i<dwBoxC;i++)
{
- dos->writeShort((short)this->BoxDataA[i].ePart);
+ dos->writeShort(static_cast<short>(this->BoxDataA[i].ePart));
dos->writeFloat(this->BoxDataA[i].fX);
dos->writeFloat(this->BoxDataA[i].fY);
dos->writeFloat(this->BoxDataA[i].fZ);
diff --git a/Minecraft.World/TextureChangePacket.cpp b/Minecraft.World/TextureChangePacket.cpp
index 2368136c..cea04d25 100644
--- a/Minecraft.World/TextureChangePacket.cpp
+++ b/Minecraft.World/TextureChangePacket.cpp
@@ -24,7 +24,7 @@ TextureChangePacket::TextureChangePacket(shared_ptr<Entity> e, ETextureChangeTyp
void TextureChangePacket::read(DataInputStream *dis) //throws IOException
{
id = dis->readInt();
- action = (ETextureChangeType)dis->readByte();
+ action = static_cast<ETextureChangeType>(dis->readByte());
path = dis->readUTF();
}
@@ -42,5 +42,5 @@ void TextureChangePacket::handle(PacketListener *listener)
int TextureChangePacket::getEstimatedSize()
{
- return 5 + (int)path.size();
+ return 5 + static_cast<int>(path.size());
}
diff --git a/Minecraft.World/TextureChangePacket.h b/Minecraft.World/TextureChangePacket.h
index 959fc4fe..81f45f4c 100644
--- a/Minecraft.World/TextureChangePacket.h
+++ b/Minecraft.World/TextureChangePacket.h
@@ -25,6 +25,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TextureChangePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TextureChangePacket>(); }
virtual int getId() { return 157; }
}; \ No newline at end of file
diff --git a/Minecraft.World/TexturePacket.cpp b/Minecraft.World/TexturePacket.cpp
index 77dfdc38..eadcb3ed 100644
--- a/Minecraft.World/TexturePacket.cpp
+++ b/Minecraft.World/TexturePacket.cpp
@@ -10,13 +10,13 @@ TexturePacket::TexturePacket()
{
this->textureName = L"";
this->dwBytes = 0;
- this->pbData = NULL;
+ this->pbData = nullptr;
}
TexturePacket::~TexturePacket()
{
// can't free this - it's used elsewhere
-// if(this->pbData!=NULL)
+// if(this->pbData!=nullptr)
// {
// delete [] this->pbData;
// }
@@ -37,7 +37,7 @@ void TexturePacket::handle(PacketListener *listener)
void TexturePacket::read(DataInputStream *dis) //throws IOException
{
textureName = dis->readUTF();
- dwBytes = (DWORD)dis->readShort();
+ dwBytes = static_cast<DWORD>(dis->readShort());
if(dwBytes>0)
{
@@ -53,7 +53,7 @@ void TexturePacket::read(DataInputStream *dis) //throws IOException
void TexturePacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeUTF(textureName);
- dos->writeShort((short)dwBytes);
+ dos->writeShort(static_cast<short>(dwBytes));
for(DWORD i=0;i<dwBytes;i++)
{
dos->writeByte(this->pbData[i]);
diff --git a/Minecraft.World/TheEndBiome.cpp b/Minecraft.World/TheEndBiome.cpp
index 9e2359ed..d54efb36 100644
--- a/Minecraft.World/TheEndBiome.cpp
+++ b/Minecraft.World/TheEndBiome.cpp
@@ -14,8 +14,8 @@ TheEndBiome::TheEndBiome(int id) : Biome(id)
ambientFriendlies.clear();
enemies.push_back(new MobSpawnerData(eTYPE_ENDERMAN, 10, 4, 4));
- topMaterial = (byte) Tile::dirt_Id;
- material = (byte) Tile::dirt_Id;
+ topMaterial = static_cast<byte>(Tile::dirt_Id);
+ material = static_cast<byte>(Tile::dirt_Id);
decorator = new TheEndBiomeDecorator(this);
}
diff --git a/Minecraft.World/TheEndBiomeDecorator.cpp b/Minecraft.World/TheEndBiomeDecorator.cpp
index 0ab1f766..2b80bcfc 100644
--- a/Minecraft.World/TheEndBiomeDecorator.cpp
+++ b/Minecraft.World/TheEndBiomeDecorator.cpp
@@ -58,7 +58,7 @@ void TheEndBiomeDecorator::decorate()
}
if (xo == 0 && zo == 0)
{
- shared_ptr<EnderDragon> enderDragon = shared_ptr<EnderDragon>(new EnderDragon(level));
+ shared_ptr<EnderDragon> enderDragon = std::make_shared<EnderDragon>(level);
enderDragon->AddParts(); // 4J added
enderDragon->moveTo(0, 128, 0, random->nextFloat() * 360, 0);
level->addEntity(enderDragon);
diff --git a/Minecraft.World/TheEndDimension.cpp b/Minecraft.World/TheEndDimension.cpp
index 031d6de4..7f26d0e8 100644
--- a/Minecraft.World/TheEndDimension.cpp
+++ b/Minecraft.World/TheEndDimension.cpp
@@ -26,7 +26,7 @@ float TheEndDimension::getTimeOfDay(int64_t time, float a) const
float *TheEndDimension::getSunriseColor(float td, float a)
{
- return NULL;
+ return nullptr;
}
Vec3 *TheEndDimension::getFogColor(float td, float a) const
diff --git a/Minecraft.World/TheEndLevelRandomLevelSource.cpp b/Minecraft.World/TheEndLevelRandomLevelSource.cpp
index f9f38470..3b42f8ca 100644
--- a/Minecraft.World/TheEndLevelRandomLevelSource.cpp
+++ b/Minecraft.World/TheEndLevelRandomLevelSource.cpp
@@ -53,7 +53,7 @@ void TheEndLevelRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArra
{
for (int yc = 0; yc < Level::genDepth / CHUNK_HEIGHT; yc++)
{
- double yStep = 1 / (double) CHUNK_HEIGHT;
+ double yStep = 1 / static_cast<double>(CHUNK_HEIGHT);
double s0 = buffer[((xc + 0) * zSize + (zc + 0)) * ySize + (yc + 0)];
double s1 = buffer[((xc + 0) * zSize + (zc + 1)) * ySize + (yc + 0)];
double s2 = buffer[((xc + 1) * zSize + (zc + 0)) * ySize + (yc + 0)];
@@ -66,7 +66,7 @@ void TheEndLevelRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArra
for (int y = 0; y < CHUNK_HEIGHT; y++)
{
- double xStep = 1 / (double) CHUNK_WIDTH;
+ double xStep = 1 / static_cast<double>(CHUNK_WIDTH);
double _s0 = s0;
double _s1 = s1;
@@ -77,7 +77,7 @@ void TheEndLevelRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArra
{
int offs = (x + xc * CHUNK_WIDTH) << Level::genDepthBitsPlusFour | (0 + zc * CHUNK_WIDTH) << Level::genDepthBits | (yc * CHUNK_HEIGHT + y);
int step = 1 << Level::genDepthBits;
- double zStep = 1 / (double) CHUNK_WIDTH;
+ double zStep = 1 / static_cast<double>(CHUNK_WIDTH);
double val = _s0;
double vala = (_s1 - _s0) * zStep;
@@ -90,7 +90,7 @@ void TheEndLevelRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArra
} else {
}
- blocks[offs] = (byte) tileId;
+ blocks[offs] = static_cast<byte>(tileId);
offs += step;
val += vala;
}
@@ -139,7 +139,7 @@ void TheEndLevelRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray
if (runDepth <= 0)
{
top = 0;
- material = (byte) Tile::endStone_Id;
+ material = static_cast<byte>(Tile::endStone_Id);
}
run = runDepth;
@@ -169,7 +169,7 @@ LevelChunk *TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs)
BiomeArray biomes;
// 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed
unsigned int blocksSize = Level::genDepth * 16 * 16;
- byte *tileData = (byte *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
+ byte *tileData = static_cast<byte *>(XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE));
XMemSet128(tileData,0,blocksSize);
byteArray blocks = byteArray(tileData,blocksSize);
// byteArray blocks = byteArray(16 * level->depth * 16);
@@ -195,7 +195,7 @@ LevelChunk *TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs)
doubleArray TheEndLevelRandomLevelSource::getHeights(doubleArray buffer, int x, int y, int z, int xSize, int ySize, int zSize)
{
- if (buffer.data == NULL)
+ if (buffer.data == nullptr)
{
buffer = doubleArray(xSize * ySize * zSize);
}
@@ -407,16 +407,16 @@ wstring TheEndLevelRandomLevelSource::gatherStats()
vector<Biome::MobSpawnerData *> *TheEndLevelRandomLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
{
Biome *biome = level->getBiome(x, z);
- if (biome == NULL)
+ if (biome == nullptr)
{
- return NULL;
+ return nullptr;
}
return biome->getMobs(mobCategory);
}
TilePos *TheEndLevelRandomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
void TheEndLevelRandomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ)
diff --git a/Minecraft.World/TheEndPortal.cpp b/Minecraft.World/TheEndPortal.cpp
index f2cb5dad..c3e5cbf5 100644
--- a/Minecraft.World/TheEndPortal.cpp
+++ b/Minecraft.World/TheEndPortal.cpp
@@ -13,7 +13,7 @@ DWORD TheEndPortal::tlsIdx = TlsAlloc();
// 4J - allowAnywhere is a static in java, implementing as TLS here to make thread safe
bool TheEndPortal::allowAnywhere()
{
- return (TlsGetValue(tlsIdx) != NULL);
+ return (TlsGetValue(tlsIdx) != nullptr);
}
void TheEndPortal::allowAnywhere(bool set)
@@ -28,7 +28,7 @@ TheEndPortal::TheEndPortal(int id, Material *material) : BaseEntityTile(id, mate
shared_ptr<TileEntity> TheEndPortal::newTileEntity(Level *level)
{
- return shared_ptr<TileEntity>(new TheEndPortalTileEntity());
+ return std::make_shared<TheEndPortalTileEntity>();
}
void TheEndPortal::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
@@ -66,7 +66,7 @@ void TheEndPortal::entityInside(Level *level, int x, int y, int z, shared_ptr<En
{
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)
{
diff --git a/Minecraft.World/TheEndPortalFrameTile.cpp b/Minecraft.World/TheEndPortalFrameTile.cpp
index f7b10a05..80e78f49 100644
--- a/Minecraft.World/TheEndPortalFrameTile.cpp
+++ b/Minecraft.World/TheEndPortalFrameTile.cpp
@@ -9,8 +9,8 @@ const wstring TheEndPortalFrameTile::TEXTURE_EYE = L"endframe_eye";
TheEndPortalFrameTile::TheEndPortalFrameTile(int id) : Tile(id, Material::glass, isSolidRender() )
{
- iconTop = NULL;
- iconEye = NULL;
+ iconTop = nullptr;
+ iconEye = nullptr;
}
Icon *TheEndPortalFrameTile::getTexture(int face, int data)
diff --git a/Minecraft.World/TheEndPortalTileEntity.cpp b/Minecraft.World/TheEndPortalTileEntity.cpp
index fa9b3544..63c0af56 100644
--- a/Minecraft.World/TheEndPortalTileEntity.cpp
+++ b/Minecraft.World/TheEndPortalTileEntity.cpp
@@ -4,7 +4,7 @@
// 4J Added
shared_ptr<TileEntity> TheEndPortalTileEntity::clone()
{
- shared_ptr<TheEndPortalTileEntity> result = shared_ptr<TheEndPortalTileEntity>( new TheEndPortalTileEntity() );
+ shared_ptr<TheEndPortalTileEntity> result = std::make_shared<TheEndPortalTileEntity>();
TileEntity::clone(result);
return result;
} \ No newline at end of file
diff --git a/Minecraft.World/ThinFenceTile.cpp b/Minecraft.World/ThinFenceTile.cpp
index 3f471ce4..65638ef6 100644
--- a/Minecraft.World/ThinFenceTile.cpp
+++ b/Minecraft.World/ThinFenceTile.cpp
@@ -5,7 +5,7 @@
ThinFenceTile::ThinFenceTile(int id, const wstring &tex, const wstring &edgeTex, Material *material, bool dropsResources) : Tile(id, material,isSolidRender())
{
- iconSide = NULL;
+ iconSide = nullptr;
edgeTexture = edgeTex;
this->dropsResources = dropsResources;
this->texture = tex;
@@ -144,7 +144,7 @@ bool ThinFenceTile::isSilkTouchable()
shared_ptr<ItemInstance> ThinFenceTile::getSilkTouchItemInstance(int data)
{
- return shared_ptr<ItemInstance>(new ItemInstance(id, 1, data));
+ return std::make_shared<ItemInstance>(id, 1, data);
}
void ThinFenceTile::registerIcons(IconRegister *iconRegister)
diff --git a/Minecraft.World/ThornsEnchantment.cpp b/Minecraft.World/ThornsEnchantment.cpp
index 53668642..a301907e 100644
--- a/Minecraft.World/ThornsEnchantment.cpp
+++ b/Minecraft.World/ThornsEnchantment.cpp
@@ -62,14 +62,14 @@ void ThornsEnchantment::doThornsAfterAttack(shared_ptr<Entity> source, shared_pt
source->hurt(DamageSource::thorns(target), getDamage(level, random));
source->playSound(eSoundType_DAMAGE_THORNS, .5f, 1.0f);
- if (item != NULL)
+ if (item != nullptr)
{
item->hurtAndBreak(3, target);
}
}
else
{
- if (item != NULL)
+ if (item != nullptr)
{
item->hurtAndBreak(1, target);
}
diff --git a/Minecraft.World/Throwable.cpp b/Minecraft.World/Throwable.cpp
index 7d30b898..08e40aa6 100644
--- a/Minecraft.World/Throwable.cpp
+++ b/Minecraft.World/Throwable.cpp
@@ -106,10 +106,10 @@ void Throwable::shoot(double xd, double yd, double zd, float pow, float uncertai
this->yd = yd;
this->zd = zd;
- float sd = (float) sqrt(xd * xd + zd * zd);
+ float sd = static_cast<float>(sqrt(xd * xd + zd * zd));
- yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRotO = xRot = (float) (atan2(yd, (double)sd) * 180 / PI);
+ yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRotO = xRot = static_cast<float>(atan2(yd, (double)sd) * 180 / PI);
life = 0;
}
@@ -120,9 +120,9 @@ void Throwable::lerpMotion(double xd, double yd, double zd)
this->zd = zd;
if (xRotO == 0 && yRotO == 0)
{
- float sd = (float) sqrt(xd * xd + zd * zd);
- yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRotO = xRot = (float) (atan2(yd, (double)sd) * 180 / PI);
+ float sd = static_cast<float>(sqrt(xd * xd + zd * zd));
+ yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRotO = xRot = static_cast<float>(atan2(yd, (double)sd) * 180 / PI);
}
}
@@ -166,7 +166,7 @@ void Throwable::tick()
from = Vec3::newTemp(x, y, z);
to = Vec3::newTemp(x + xd, y + yd, z + zd);
- if (res != NULL)
+ if (res != nullptr)
{
to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z);
}
@@ -185,7 +185,7 @@ void Throwable::tick()
float rr = 0.3f;
AABB *bb = e->bb->grow(rr, rr, rr);
HitResult *p = bb->clip(from, to);
- if (p != NULL)
+ if (p != nullptr)
{
double dd = from->distanceTo(p->pos);
delete p;
@@ -197,14 +197,14 @@ void Throwable::tick()
}
}
- if (hitEntity != NULL)
+ if (hitEntity != nullptr)
{
- if(res != NULL) delete res;
+ if(res != nullptr) delete res;
res = new HitResult(hitEntity);
}
}
- if (res != NULL)
+ if (res != nullptr)
{
if ( (res->type == HitResult::TILE) && (level->getTile(res->x, res->y, res->z) == Tile::portalTile_Id) )
{
@@ -220,9 +220,9 @@ void Throwable::tick()
y += yd;
z += zd;
- float sd = (float) sqrt(xd * xd + zd * zd);
- yRot = (float) (atan2(xd, zd) * 180 / PI);
- xRot = (float) (atan2(yd, (double)sd) * 180 / PI);
+ float sd = static_cast<float>(sqrt(xd * xd + zd * zd));
+ yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
+ xRot = static_cast<float>(atan2(yd, (double)sd) * 180 / PI);
while (xRot - xRotO < -180)
xRotO -= 360;
@@ -267,14 +267,14 @@ float Throwable::getGravity()
void Throwable::addAdditonalSaveData(CompoundTag *tag)
{
- tag->putShort(L"xTile", (short) xTile);
- tag->putShort(L"yTile", (short) yTile);
- tag->putShort(L"zTile", (short) zTile);
- tag->putByte(L"inTile", (byte) lastTile);
- tag->putByte(L"shake", (byte) shakeTime);
- tag->putByte(L"inGround", (byte) (inGround ? 1 : 0));
-
- if (ownerName.empty() && (owner != NULL) && owner->instanceof(eTYPE_PLAYER) )
+ tag->putShort(L"xTile", static_cast<short>(xTile));
+ tag->putShort(L"yTile", static_cast<short>(yTile));
+ tag->putShort(L"zTile", static_cast<short>(zTile));
+ tag->putByte(L"inTile", static_cast<byte>(lastTile));
+ tag->putByte(L"shake", static_cast<byte>(shakeTime));
+ tag->putByte(L"inGround", static_cast<byte>(inGround ? 1 : 0));
+
+ if (ownerName.empty() && (owner != nullptr) && owner->instanceof(eTYPE_PLAYER) )
{
ownerName = owner->getAName();
}
@@ -301,7 +301,7 @@ float Throwable::getShadowHeightOffs()
shared_ptr<LivingEntity> Throwable::getOwner()
{
- if (owner == NULL && !ownerName.empty() )
+ if (owner == nullptr && !ownerName.empty() )
{
owner = level->getPlayerByName(ownerName);
}
diff --git a/Minecraft.World/ThrownEgg.cpp b/Minecraft.World/ThrownEgg.cpp
index 1378e094..9bdfae10 100644
--- a/Minecraft.World/ThrownEgg.cpp
+++ b/Minecraft.World/ThrownEgg.cpp
@@ -33,7 +33,7 @@ ThrownEgg::ThrownEgg(Level *level, double x, double y, double z) : Throwable(lev
void ThrownEgg::onHit(HitResult *res)
{
- if (res->entity != NULL)
+ if (res->entity != nullptr)
{
DamageSource *damageSource = DamageSource::thrown(shared_from_this(), owner);
res->entity->hurt(damageSource, 0);
@@ -47,7 +47,7 @@ void ThrownEgg::onHit(HitResult *res)
if (random->nextInt(32) == 0) count = 4;
for (int i = 0; i < count; i++)
{
- shared_ptr<Chicken> chicken = shared_ptr<Chicken>( new Chicken(level) );
+ shared_ptr<Chicken> chicken = std::make_shared<Chicken>(level);
chicken->setAge(-20 * 60 * 20);
chicken->moveTo(x, y, z, yRot, 0);
diff --git a/Minecraft.World/ThrownEnderpearl.cpp b/Minecraft.World/ThrownEnderpearl.cpp
index 1035bffd..c325f1c9 100644
--- a/Minecraft.World/ThrownEnderpearl.cpp
+++ b/Minecraft.World/ThrownEnderpearl.cpp
@@ -32,7 +32,7 @@ ThrownEnderpearl::ThrownEnderpearl(Level *level, double x, double y, double z) :
void ThrownEnderpearl::onHit(HitResult *res)
{
- if (res->entity != NULL)
+ if (res->entity != nullptr)
{
DamageSource *damageSource = DamageSource::thrown(shared_from_this(), getOwner() );
res->entity->hurt(damageSource, 0);
@@ -49,7 +49,7 @@ void ThrownEnderpearl::onHit(HitResult *res)
// If the owner has been removed, then ignore
// 4J-JEV: Cheap type check first.
- if ( (getOwner() != NULL) && getOwner()->instanceof(eTYPE_SERVERPLAYER) )
+ if ( (getOwner() != nullptr) && getOwner()->instanceof(eTYPE_SERVERPLAYER) )
{
shared_ptr<ServerPlayer> serverPlayer = dynamic_pointer_cast<ServerPlayer>(getOwner() );
if (!serverPlayer->removed)
diff --git a/Minecraft.World/ThrownExpBottle.cpp b/Minecraft.World/ThrownExpBottle.cpp
index b8dbef96..acab0d05 100644
--- a/Minecraft.World/ThrownExpBottle.cpp
+++ b/Minecraft.World/ThrownExpBottle.cpp
@@ -40,14 +40,14 @@ void ThrownExpBottle::onHit(HitResult *res)
if (!level->isClientSide)
{
- level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), 0);
+ level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, static_cast<int>(Math::round(x)), static_cast<int>(Math::round(y)), static_cast<int>(Math::round(z)), 0);
int xpCount = 3 + level->random->nextInt(5) + level->random->nextInt(5);
while (xpCount > 0)
{
int newCount = ExperienceOrb::getExperienceValue(xpCount);
xpCount -= newCount;
- level->addEntity(shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x, y, z, newCount) ) );
+ level->addEntity(std::make_shared<ExperienceOrb>(level, x, y, z, newCount));
}
remove();
diff --git a/Minecraft.World/ThrownPotion.cpp b/Minecraft.World/ThrownPotion.cpp
index 69c096a2..170f6474 100644
--- a/Minecraft.World/ThrownPotion.cpp
+++ b/Minecraft.World/ThrownPotion.cpp
@@ -31,7 +31,7 @@ ThrownPotion::ThrownPotion(Level *level, shared_ptr<LivingEntity> mob, int potio
{
_init();
- potionItem = shared_ptr<ItemInstance>( new ItemInstance(Item::potion, 1, potionValue));
+ potionItem = std::make_shared<ItemInstance>(Item::potion, 1, potionValue);
}
ThrownPotion::ThrownPotion(Level *level, shared_ptr<LivingEntity> mob, shared_ptr<ItemInstance> potion) : Throwable(level, mob)
@@ -45,7 +45,7 @@ ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, int potio
{
_init();
- potionItem = shared_ptr<ItemInstance>( new ItemInstance(Item::potion, 1, potionValue));
+ potionItem = std::make_shared<ItemInstance>(Item::potion, 1, potionValue);
}
ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, shared_ptr<ItemInstance> potion) : Throwable(level, x, y, z)
@@ -72,13 +72,13 @@ float ThrownPotion::getThrowUpAngleOffset()
void ThrownPotion::setPotionValue(int potionValue)
{
- if (potionItem == NULL) potionItem = shared_ptr<ItemInstance>( new ItemInstance(Item::potion, 1, 0) );
+ if (potionItem == nullptr) potionItem = std::make_shared<ItemInstance>(Item::potion, 1, 0);
potionItem->setAuxValue(potionValue);
}
int ThrownPotion::getPotionValue()
{
- if (potionItem == NULL) potionItem = shared_ptr<ItemInstance>( new ItemInstance(Item::potion, 1, 0) );
+ if (potionItem == nullptr) potionItem = std::make_shared<ItemInstance>(Item::potion, 1, 0);
return potionItem->getAuxValue();
}
@@ -88,12 +88,12 @@ void ThrownPotion::onHit(HitResult *res)
{
vector<MobEffectInstance *> *mobEffects = Item::potion->getMobEffects(potionItem);
- if (mobEffects != NULL && !mobEffects->empty())
+ if (mobEffects != nullptr && !mobEffects->empty())
{
AABB *aoe = bb->grow(SPLASH_RANGE, SPLASH_RANGE / 2, SPLASH_RANGE);
vector<shared_ptr<Entity> > *entitiesOfClass = level->getEntitiesOfClass(typeid(LivingEntity), aoe);
- if (entitiesOfClass != NULL && !entitiesOfClass->empty())
+ if (entitiesOfClass != nullptr && !entitiesOfClass->empty())
{
for(auto & it : *entitiesOfClass)
{
@@ -117,7 +117,7 @@ void ThrownPotion::onHit(HitResult *res)
}
else
{
- int duration = (int) (scale * (double) effect->getDuration() + .5);
+ int duration = static_cast<int>(scale * (double)effect->getDuration() + .5);
if (duration > SharedConstants::TICKS_PER_SECOND)
{
e->addEffect(new MobEffectInstance(id, duration, effect->getAmplifier()));
@@ -129,7 +129,7 @@ void ThrownPotion::onHit(HitResult *res)
}
delete entitiesOfClass;
}
- level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), getPotionValue() );
+ level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, static_cast<int>(Math::round(x)), static_cast<int>(Math::round(y)), static_cast<int>(Math::round(z)), getPotionValue() );
remove();
}
@@ -148,12 +148,12 @@ void ThrownPotion::readAdditionalSaveData(CompoundTag *tag)
setPotionValue(tag->getInt(L"potionValue"));
}
- if (potionItem == NULL) remove();
+ if (potionItem == nullptr) remove();
}
void ThrownPotion::addAdditonalSaveData(CompoundTag *tag)
{
Throwable::addAdditonalSaveData(tag);
- if (potionItem != NULL) tag->putCompound(L"Potion", potionItem->save(new CompoundTag()));
+ if (potionItem != nullptr) tag->putCompound(L"Potion", potionItem->save(new CompoundTag()));
} \ No newline at end of file
diff --git a/Minecraft.World/TickNextTickData.cpp b/Minecraft.World/TickNextTickData.cpp
index 277be1f8..95639b04 100644
--- a/Minecraft.World/TickNextTickData.cpp
+++ b/Minecraft.World/TickNextTickData.cpp
@@ -21,7 +21,7 @@ bool TickNextTickData::equals(const TickNextTickData *o) const
{
// TODO 4J Is this safe to cast it before we do a dynamic_cast? Will the dynamic_cast still fail?
// We cannot dynamic_cast a void*
- if ( o != NULL)
+ if ( o != nullptr)
{
TickNextTickData *t = (TickNextTickData *) o;
return x == t->x && y == t->y && z == t->z && Tile::isMatching(tileId, t->tileId);
diff --git a/Minecraft.World/Tile.cpp b/Minecraft.World/Tile.cpp
index 67148274..de113714 100644
--- a/Minecraft.World/Tile.cpp
+++ b/Minecraft.World/Tile.cpp
@@ -21,18 +21,18 @@ wstring Tile::TILE_DESCRIPTION_PREFIX = L"Tile.";
const float Tile::INDESTRUCTIBLE_DESTROY_TIME = -1.0f;
-Tile::SoundType *Tile::SOUND_NORMAL = NULL;
-Tile::SoundType *Tile::SOUND_WOOD = NULL;
-Tile::SoundType *Tile::SOUND_GRAVEL = NULL;
-Tile::SoundType *Tile::SOUND_GRASS = NULL;
-Tile::SoundType *Tile::SOUND_STONE = NULL;
-Tile::SoundType *Tile::SOUND_METAL = NULL;
-Tile::SoundType *Tile::SOUND_GLASS = NULL;
-Tile::SoundType *Tile::SOUND_CLOTH = NULL;
-Tile::SoundType *Tile::SOUND_SAND = NULL;
-Tile::SoundType *Tile::SOUND_SNOW = NULL;
-Tile::SoundType *Tile::SOUND_LADDER = NULL;
-Tile::SoundType *Tile::SOUND_ANVIL = NULL;
+Tile::SoundType *Tile::SOUND_NORMAL = nullptr;
+Tile::SoundType *Tile::SOUND_WOOD = nullptr;
+Tile::SoundType *Tile::SOUND_GRAVEL = nullptr;
+Tile::SoundType *Tile::SOUND_GRASS = nullptr;
+Tile::SoundType *Tile::SOUND_STONE = nullptr;
+Tile::SoundType *Tile::SOUND_METAL = nullptr;
+Tile::SoundType *Tile::SOUND_GLASS = nullptr;
+Tile::SoundType *Tile::SOUND_CLOTH = nullptr;
+Tile::SoundType *Tile::SOUND_SAND = nullptr;
+Tile::SoundType *Tile::SOUND_SNOW = nullptr;
+Tile::SoundType *Tile::SOUND_LADDER = nullptr;
+Tile::SoundType *Tile::SOUND_ANVIL = nullptr;
bool Tile::solid[TILE_NUM_COUNT];
int Tile::lightBlock[TILE_NUM_COUNT];
@@ -42,183 +42,183 @@ unsigned char Tile::_sendTileData[TILE_NUM_COUNT]; // 4J changed - was bool, no
bool Tile::mipmapEnable[TILE_NUM_COUNT];
bool Tile::propagate[TILE_NUM_COUNT];
-Tile **Tile::tiles = NULL;
-
-Tile *Tile::stone = NULL;
-GrassTile *Tile::grass = NULL;
-Tile *Tile::dirt = NULL;
-Tile *Tile::cobblestone = NULL;
-Tile *Tile::wood = NULL;
-Tile *Tile::sapling = NULL;
-Tile *Tile::unbreakable = NULL;
-LiquidTile *Tile::water = NULL;
-Tile *Tile::calmWater = NULL;
-LiquidTile *Tile::lava = NULL;
-Tile *Tile::calmLava = NULL;
-Tile *Tile::sand = NULL;
-Tile *Tile::gravel = NULL;
-Tile *Tile::goldOre = NULL;
-Tile *Tile::ironOre = NULL;
-Tile *Tile::coalOre = NULL;
-Tile *Tile::treeTrunk = NULL;
-LeafTile *Tile::leaves = NULL;
-Tile *Tile::sponge = NULL;
-Tile *Tile::glass = NULL;
-Tile *Tile::lapisOre = NULL;
-Tile *Tile::lapisBlock = NULL;
-Tile *Tile::dispenser = NULL;
-Tile *Tile::sandStone = NULL;
-Tile *Tile::noteblock = NULL;
-Tile *Tile::bed = NULL;
-Tile *Tile::goldenRail = NULL;
-Tile *Tile::detectorRail = NULL;
-PistonBaseTile *Tile::pistonStickyBase = NULL;
-Tile *Tile::web = NULL;
-TallGrass *Tile::tallgrass = NULL;
-DeadBushTile *Tile::deadBush = NULL;
-PistonBaseTile *Tile::pistonBase = NULL;
-PistonExtensionTile *Tile::pistonExtension = NULL;
-Tile *Tile::wool = NULL;
-PistonMovingPiece *Tile::pistonMovingPiece = NULL;
-Bush *Tile::flower = NULL;
-Bush *Tile::rose = NULL;
-Bush *Tile::mushroom_brown = NULL;
-Bush *Tile::mushroom_red = NULL;
-Tile *Tile::goldBlock = NULL;
-Tile *Tile::ironBlock = NULL;
-HalfSlabTile *Tile::stoneSlab = NULL;
-HalfSlabTile *Tile::stoneSlabHalf = NULL;
-Tile *Tile::redBrick = NULL;
-Tile *Tile::tnt = NULL;
-Tile *Tile::bookshelf = NULL;
-Tile *Tile::mossyCobblestone = NULL;
-Tile *Tile::obsidian = NULL;
-Tile *Tile::torch = NULL;
-FireTile *Tile::fire = NULL;
-Tile *Tile::mobSpawner = NULL;
-Tile *Tile::stairs_wood = NULL;
-ChestTile *Tile::chest = NULL;
-RedStoneDustTile *Tile::redStoneDust = NULL;
-Tile *Tile::diamondOre = NULL;
-Tile *Tile::diamondBlock = NULL;
-Tile *Tile::workBench = NULL;
-Tile *Tile::wheat = NULL;
-Tile *Tile::farmland = NULL;
-Tile *Tile::furnace = NULL;
-Tile *Tile::furnace_lit = NULL;
-Tile *Tile::sign = NULL;
-Tile *Tile::door_wood = NULL;
-Tile *Tile::ladder = NULL;
-Tile *Tile::rail = NULL;
-Tile *Tile::stairs_stone = NULL;
-Tile *Tile::wallSign = NULL;
-Tile *Tile::lever = NULL;
-Tile *Tile::pressurePlate_stone = NULL;
-Tile *Tile::door_iron = NULL;
-Tile *Tile::pressurePlate_wood = NULL;
-Tile *Tile::redStoneOre = NULL;
-Tile *Tile::redStoneOre_lit = NULL;
-Tile *Tile::redstoneTorch_off = NULL;
-Tile *Tile::redstoneTorch_on = NULL;
-Tile *Tile::button = NULL;
-Tile *Tile::topSnow = NULL;
-Tile *Tile::ice = NULL;
-Tile *Tile::snow = NULL;
-Tile *Tile::cactus = NULL;
-Tile *Tile::clay = NULL;
-Tile *Tile::reeds = NULL;
-Tile *Tile::jukebox = NULL;
-Tile *Tile::fence = NULL;
-Tile *Tile::pumpkin = NULL;
-Tile *Tile::netherRack = NULL;
-Tile *Tile::soulsand = NULL;
-Tile *Tile::glowstone = NULL;
-PortalTile *Tile::portalTile = NULL;
-Tile *Tile::litPumpkin = NULL;
-Tile *Tile::cake = NULL;
-RepeaterTile *Tile::diode_off = NULL;
-RepeaterTile *Tile::diode_on = NULL;
-Tile *Tile::stained_glass = NULL;
-Tile *Tile::trapdoor = NULL;
-
-Tile *Tile::monsterStoneEgg = NULL;
-Tile *Tile::stoneBrick = NULL;
-Tile *Tile::hugeMushroom_brown = NULL;
-Tile *Tile::hugeMushroom_red = NULL;
-Tile *Tile::ironFence = NULL;
-Tile *Tile::thinGlass = NULL;
-Tile *Tile::melon = NULL;
-Tile *Tile::pumpkinStem = NULL;
-Tile *Tile::melonStem = NULL;
-Tile *Tile::vine = NULL;
-Tile *Tile::fenceGate = NULL;
-Tile *Tile::stairs_bricks = NULL;
-Tile *Tile::stairs_stoneBrickSmooth = NULL;
-
-MycelTile *Tile::mycel = NULL;
-Tile *Tile::waterLily = NULL;
-Tile *Tile::netherBrick = NULL;
-Tile *Tile::netherFence = NULL;
-Tile *Tile::stairs_netherBricks = NULL;
-Tile *Tile::netherStalk = NULL;
-Tile *Tile::enchantTable = NULL;
-Tile *Tile::brewingStand = NULL;
-CauldronTile *Tile::cauldron = NULL;
-Tile *Tile::endPortalTile = NULL;
-Tile *Tile::endPortalFrameTile = NULL;
-Tile *Tile::endStone = NULL;
-Tile *Tile::dragonEgg = NULL;
-Tile *Tile::redstoneLight = NULL;
-Tile *Tile::redstoneLight_lit = NULL;
+Tile **Tile::tiles = nullptr;
+
+Tile *Tile::stone = nullptr;
+GrassTile *Tile::grass = nullptr;
+Tile *Tile::dirt = nullptr;
+Tile *Tile::cobblestone = nullptr;
+Tile *Tile::wood = nullptr;
+Tile *Tile::sapling = nullptr;
+Tile *Tile::unbreakable = nullptr;
+LiquidTile *Tile::water = nullptr;
+Tile *Tile::calmWater = nullptr;
+LiquidTile *Tile::lava = nullptr;
+Tile *Tile::calmLava = nullptr;
+Tile *Tile::sand = nullptr;
+Tile *Tile::gravel = nullptr;
+Tile *Tile::goldOre = nullptr;
+Tile *Tile::ironOre = nullptr;
+Tile *Tile::coalOre = nullptr;
+Tile *Tile::treeTrunk = nullptr;
+LeafTile *Tile::leaves = nullptr;
+Tile *Tile::sponge = nullptr;
+Tile *Tile::glass = nullptr;
+Tile *Tile::lapisOre = nullptr;
+Tile *Tile::lapisBlock = nullptr;
+Tile *Tile::dispenser = nullptr;
+Tile *Tile::sandStone = nullptr;
+Tile *Tile::noteblock = nullptr;
+Tile *Tile::bed = nullptr;
+Tile *Tile::goldenRail = nullptr;
+Tile *Tile::detectorRail = nullptr;
+PistonBaseTile *Tile::pistonStickyBase = nullptr;
+Tile *Tile::web = nullptr;
+TallGrass *Tile::tallgrass = nullptr;
+DeadBushTile *Tile::deadBush = nullptr;
+PistonBaseTile *Tile::pistonBase = nullptr;
+PistonExtensionTile *Tile::pistonExtension = nullptr;
+Tile *Tile::wool = nullptr;
+PistonMovingPiece *Tile::pistonMovingPiece = nullptr;
+Bush *Tile::flower = nullptr;
+Bush *Tile::rose = nullptr;
+Bush *Tile::mushroom_brown = nullptr;
+Bush *Tile::mushroom_red = nullptr;
+Tile *Tile::goldBlock = nullptr;
+Tile *Tile::ironBlock = nullptr;
+HalfSlabTile *Tile::stoneSlab = nullptr;
+HalfSlabTile *Tile::stoneSlabHalf = nullptr;
+Tile *Tile::redBrick = nullptr;
+Tile *Tile::tnt = nullptr;
+Tile *Tile::bookshelf = nullptr;
+Tile *Tile::mossyCobblestone = nullptr;
+Tile *Tile::obsidian = nullptr;
+Tile *Tile::torch = nullptr;
+FireTile *Tile::fire = nullptr;
+Tile *Tile::mobSpawner = nullptr;
+Tile *Tile::stairs_wood = nullptr;
+ChestTile *Tile::chest = nullptr;
+RedStoneDustTile *Tile::redStoneDust = nullptr;
+Tile *Tile::diamondOre = nullptr;
+Tile *Tile::diamondBlock = nullptr;
+Tile *Tile::workBench = nullptr;
+Tile *Tile::wheat = nullptr;
+Tile *Tile::farmland = nullptr;
+Tile *Tile::furnace = nullptr;
+Tile *Tile::furnace_lit = nullptr;
+Tile *Tile::sign = nullptr;
+Tile *Tile::door_wood = nullptr;
+Tile *Tile::ladder = nullptr;
+Tile *Tile::rail = nullptr;
+Tile *Tile::stairs_stone = nullptr;
+Tile *Tile::wallSign = nullptr;
+Tile *Tile::lever = nullptr;
+Tile *Tile::pressurePlate_stone = nullptr;
+Tile *Tile::door_iron = nullptr;
+Tile *Tile::pressurePlate_wood = nullptr;
+Tile *Tile::redStoneOre = nullptr;
+Tile *Tile::redStoneOre_lit = nullptr;
+Tile *Tile::redstoneTorch_off = nullptr;
+Tile *Tile::redstoneTorch_on = nullptr;
+Tile *Tile::button = nullptr;
+Tile *Tile::topSnow = nullptr;
+Tile *Tile::ice = nullptr;
+Tile *Tile::snow = nullptr;
+Tile *Tile::cactus = nullptr;
+Tile *Tile::clay = nullptr;
+Tile *Tile::reeds = nullptr;
+Tile *Tile::jukebox = nullptr;
+Tile *Tile::fence = nullptr;
+Tile *Tile::pumpkin = nullptr;
+Tile *Tile::netherRack = nullptr;
+Tile *Tile::soulsand = nullptr;
+Tile *Tile::glowstone = nullptr;
+PortalTile *Tile::portalTile = nullptr;
+Tile *Tile::litPumpkin = nullptr;
+Tile *Tile::cake = nullptr;
+RepeaterTile *Tile::diode_off = nullptr;
+RepeaterTile *Tile::diode_on = nullptr;
+Tile *Tile::stained_glass = nullptr;
+Tile *Tile::trapdoor = nullptr;
+
+Tile *Tile::monsterStoneEgg = nullptr;
+Tile *Tile::stoneBrick = nullptr;
+Tile *Tile::hugeMushroom_brown = nullptr;
+Tile *Tile::hugeMushroom_red = nullptr;
+Tile *Tile::ironFence = nullptr;
+Tile *Tile::thinGlass = nullptr;
+Tile *Tile::melon = nullptr;
+Tile *Tile::pumpkinStem = nullptr;
+Tile *Tile::melonStem = nullptr;
+Tile *Tile::vine = nullptr;
+Tile *Tile::fenceGate = nullptr;
+Tile *Tile::stairs_bricks = nullptr;
+Tile *Tile::stairs_stoneBrickSmooth = nullptr;
+
+MycelTile *Tile::mycel = nullptr;
+Tile *Tile::waterLily = nullptr;
+Tile *Tile::netherBrick = nullptr;
+Tile *Tile::netherFence = nullptr;
+Tile *Tile::stairs_netherBricks = nullptr;
+Tile *Tile::netherStalk = nullptr;
+Tile *Tile::enchantTable = nullptr;
+Tile *Tile::brewingStand = nullptr;
+CauldronTile *Tile::cauldron = nullptr;
+Tile *Tile::endPortalTile = nullptr;
+Tile *Tile::endPortalFrameTile = nullptr;
+Tile *Tile::endStone = nullptr;
+Tile *Tile::dragonEgg = nullptr;
+Tile *Tile::redstoneLight = nullptr;
+Tile *Tile::redstoneLight_lit = nullptr;
// TU9
-Tile *Tile::stairs_sandstone = NULL;
-Tile *Tile::woodStairsDark = NULL;
-Tile *Tile::woodStairsBirch = NULL;
-Tile *Tile::woodStairsJungle = NULL;
-Tile *Tile::commandBlock = NULL;
-BeaconTile *Tile::beacon = NULL;
-Tile *Tile::button_wood = NULL;
-HalfSlabTile *Tile::woodSlab = NULL;
-HalfSlabTile *Tile::woodSlabHalf = NULL;
-
-Tile *Tile::emeraldOre = NULL;
-Tile *Tile::enderChest = NULL;
-TripWireSourceTile *Tile::tripWireSource = NULL;
-Tile *Tile::tripWire = NULL;
-Tile *Tile::emeraldBlock = NULL;
-
-
-Tile *Tile::cocoa = NULL;
-Tile *Tile::skull = NULL;
-
-Tile *Tile::cobbleWall = NULL;
-Tile *Tile::flowerPot = NULL;
-Tile *Tile::carrots = NULL;
-Tile *Tile::potatoes = NULL;
-Tile *Tile::anvil = NULL;
-Tile *Tile::chest_trap = NULL;
-Tile *Tile::weightedPlate_light = NULL;
-Tile *Tile::weightedPlate_heavy = NULL;
-ComparatorTile *Tile::comparator_off = NULL;
-ComparatorTile *Tile::comparator_on = NULL;
-
-DaylightDetectorTile *Tile::daylightDetector = NULL;
-Tile *Tile::redstoneBlock = NULL;
-
-Tile *Tile::netherQuartz = NULL;
-HopperTile *Tile::hopper = NULL;
-Tile *Tile::quartzBlock = NULL;
-Tile *Tile::stairs_quartz = NULL;
-Tile *Tile::activatorRail = NULL;
-Tile *Tile::dropper = NULL;
-Tile *Tile::clayHardened_colored = NULL;
-Tile *Tile::stained_glass_pane = NULL;
-
-Tile *Tile::hayBlock = NULL;
-Tile *Tile::woolCarpet = NULL;
-Tile *Tile::clayHardened = NULL;
-Tile *Tile::coalBlock = NULL;
+Tile *Tile::stairs_sandstone = nullptr;
+Tile *Tile::woodStairsDark = nullptr;
+Tile *Tile::woodStairsBirch = nullptr;
+Tile *Tile::woodStairsJungle = nullptr;
+Tile *Tile::commandBlock = nullptr;
+BeaconTile *Tile::beacon = nullptr;
+Tile *Tile::button_wood = nullptr;
+HalfSlabTile *Tile::woodSlab = nullptr;
+HalfSlabTile *Tile::woodSlabHalf = nullptr;
+
+Tile *Tile::emeraldOre = nullptr;
+Tile *Tile::enderChest = nullptr;
+TripWireSourceTile *Tile::tripWireSource = nullptr;
+Tile *Tile::tripWire = nullptr;
+Tile *Tile::emeraldBlock = nullptr;
+
+
+Tile *Tile::cocoa = nullptr;
+Tile *Tile::skull = nullptr;
+
+Tile *Tile::cobbleWall = nullptr;
+Tile *Tile::flowerPot = nullptr;
+Tile *Tile::carrots = nullptr;
+Tile *Tile::potatoes = nullptr;
+Tile *Tile::anvil = nullptr;
+Tile *Tile::chest_trap = nullptr;
+Tile *Tile::weightedPlate_light = nullptr;
+Tile *Tile::weightedPlate_heavy = nullptr;
+ComparatorTile *Tile::comparator_off = nullptr;
+ComparatorTile *Tile::comparator_on = nullptr;
+
+DaylightDetectorTile *Tile::daylightDetector = nullptr;
+Tile *Tile::redstoneBlock = nullptr;
+
+Tile *Tile::netherQuartz = nullptr;
+HopperTile *Tile::hopper = nullptr;
+Tile *Tile::quartzBlock = nullptr;
+Tile *Tile::stairs_quartz = nullptr;
+Tile *Tile::activatorRail = nullptr;
+Tile *Tile::dropper = nullptr;
+Tile *Tile::clayHardened_colored = nullptr;
+Tile *Tile::stained_glass_pane = nullptr;
+
+Tile *Tile::hayBlock = nullptr;
+Tile *Tile::woolCarpet = nullptr;
+Tile *Tile::clayHardened = nullptr;
+Tile *Tile::coalBlock = nullptr;
DWORD Tile::tlsIdxShape = TlsAlloc();
@@ -236,7 +236,7 @@ void Tile::CreateNewThreadStorage()
void Tile::ReleaseThreadStorage()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
delete tls;
}
@@ -259,15 +259,15 @@ void Tile::staticCtor()
memset( tiles, 0, sizeof( Tile *)*TILE_NUM_COUNT );
Tile::stone = (new StoneTile(1)) ->setDestroyTime(1.5f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stone")->setDescriptionId(IDS_TILE_STONE)->setUseDescriptionId(IDS_DESC_STONE);
- Tile::grass = (GrassTile *) (new GrassTile(2)) ->setDestroyTime(0.6f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"grass")->setDescriptionId(IDS_TILE_GRASS)->setUseDescriptionId(IDS_DESC_GRASS);
+ Tile::grass = static_cast<GrassTile *>((new GrassTile(2))->setDestroyTime(0.6f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"grass")->setDescriptionId(IDS_TILE_GRASS)->setUseDescriptionId(IDS_DESC_GRASS));
Tile::dirt = (new DirtTile(3)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_GRAVEL)->setIconName(L"dirt")->setDescriptionId(IDS_TILE_DIRT)->setUseDescriptionId(IDS_DESC_DIRT);
Tile::cobblestone = (new Tile(4, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"cobblestone")->setDescriptionId(IDS_TILE_STONE_BRICK)->setUseDescriptionId(IDS_DESC_STONE_BRICK);
Tile::wood = (new WoodTile(5)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structwoodstuff, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"planks")->setDescriptionId(IDS_TILE_OAKWOOD_PLANKS)->sendTileData()->setUseDescriptionId(IDS_DESC_WOODENPLANKS);
Tile::sapling = (new Sapling(6)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"sapling")->setDescriptionId(IDS_TILE_SAPLING)->sendTileData()->setUseDescriptionId(IDS_DESC_SAPLING)->disableMipmap();
Tile::unbreakable = (new Tile(7, Material::stone)) ->setIndestructible()->setExplodeable(6000000)->setSoundType(Tile::SOUND_STONE)->setIconName(L"bedrock")->setDescriptionId(IDS_TILE_BEDROCK)->setNotCollectStatistics()->setUseDescriptionId(IDS_DESC_BEDROCK);
- Tile::water = (LiquidTile *)(new LiquidTileDynamic(8, Material::water)) ->setDestroyTime(100.0f)->setLightBlock(3)->setIconName(L"water_flow")->setDescriptionId(IDS_TILE_WATER)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_WATER);
+ Tile::water = static_cast<LiquidTile *>((new LiquidTileDynamic(8, Material::water))->setDestroyTime(100.0f)->setLightBlock(3)->setIconName(L"water_flow")->setDescriptionId(IDS_TILE_WATER)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_WATER));
Tile::calmWater = (new LiquidTileStatic(9, Material::water)) ->setDestroyTime(100.0f)->setLightBlock(3)->setIconName(L"water_still")->setDescriptionId(IDS_TILE_WATER)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_WATER);
- Tile::lava = (LiquidTile *)(new LiquidTileDynamic(10, Material::lava)) ->setDestroyTime(00.0f)->setLightEmission(1.0f)->setLightBlock(255)->setIconName(L"lava_flow")->setDescriptionId(IDS_TILE_LAVA)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_LAVA);
+ Tile::lava = static_cast<LiquidTile *>((new LiquidTileDynamic(10, Material::lava))->setDestroyTime(00.0f)->setLightEmission(1.0f)->setLightBlock(255)->setIconName(L"lava_flow")->setDescriptionId(IDS_TILE_LAVA)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_LAVA));
Tile::calmLava = (new LiquidTileStatic(11, Material::lava)) ->setDestroyTime(100.0f)->setLightEmission(1.0f)->setLightBlock(255)->setIconName(L"lava_still")->setDescriptionId(IDS_TILE_LAVA)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_LAVA);
Tile::sand = (new HeavyTile(12)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_SAND)->setIconName(L"sand")->setDescriptionId(IDS_TILE_SAND)->setUseDescriptionId(IDS_DESC_SAND);
@@ -277,7 +277,7 @@ void Tile::staticCtor()
Tile::coalOre = (new OreTile(16)) ->setDestroyTime(3.0f)->setExplodeable(5)->setSoundType(Tile::SOUND_STONE)->setIconName(L"coal_ore")->setDescriptionId(IDS_TILE_ORE_COAL)->setUseDescriptionId(IDS_DESC_ORE_COAL);
Tile::treeTrunk = (new TreeTile(17))->setDestroyTime(2.0f) ->setSoundType(Tile::SOUND_WOOD)->setIconName(L"log")->setDescriptionId(IDS_TILE_LOG)->sendTileData()->setUseDescriptionId(IDS_DESC_LOG);
// 4J - for leaves, have specified that only the data bits that encode the type of leaf are important to be sent
- Tile::leaves = (LeafTile *)(new LeafTile(18)) ->setDestroyTime(0.2f)->setLightBlock(1)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"leaves")->setDescriptionId(IDS_TILE_LEAVES)->sendTileData(LeafTile::LEAF_TYPE_MASK)->setUseDescriptionId(IDS_DESC_LEAVES);
+ Tile::leaves = static_cast<LeafTile *>((new LeafTile(18))->setDestroyTime(0.2f)->setLightBlock(1)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"leaves")->setDescriptionId(IDS_TILE_LEAVES)->sendTileData(LeafTile::LEAF_TYPE_MASK)->setUseDescriptionId(IDS_DESC_LEAVES));
Tile::sponge = (new Sponge(19)) ->setDestroyTime(0.6f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"sponge")->setDescriptionId(IDS_TILE_SPONGE)->setUseDescriptionId(IDS_DESC_SPONGE);
Tile::glass = (new GlassTile(20, Material::glass, false)) ->setDestroyTime(0.3f)->setSoundType(Tile::SOUND_GLASS)->setIconName(L"glass")->setDescriptionId(IDS_TILE_GLASS)->setUseDescriptionId(IDS_DESC_GLASS);
@@ -289,24 +289,24 @@ void Tile::staticCtor()
Tile::bed = (new BedTile(26)) ->setDestroyTime(0.2f)->setIconName(L"bed")->setDescriptionId(IDS_TILE_BED)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_BED);
Tile::goldenRail = (new PoweredRailTile(27)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_rail, Item::eMaterial_gold)->setDestroyTime(0.7f)->setSoundType(Tile::SOUND_METAL)->setIconName(L"rail_golden")->setDescriptionId(IDS_TILE_GOLDEN_RAIL)->sendTileData()->setUseDescriptionId(IDS_DESC_POWEREDRAIL)->disableMipmap();
Tile::detectorRail = (new DetectorRailTile(28)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_rail, Item::eMaterial_detector)->setDestroyTime(0.7f)->setSoundType(Tile::SOUND_METAL)->setIconName(L"rail_detector")->setDescriptionId(IDS_TILE_DETECTOR_RAIL)->sendTileData()->setUseDescriptionId(IDS_DESC_DETECTORRAIL)->disableMipmap();
- Tile::pistonStickyBase = (PistonBaseTile *)(new PistonBaseTile(29, true)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_piston, Item::eMaterial_stickypiston)->setIconName(L"pistonStickyBase")->setDescriptionId(IDS_TILE_PISTON_STICK_BASE)->setUseDescriptionId(IDS_DESC_STICKY_PISTON)->sendTileData();
+ Tile::pistonStickyBase = static_cast<PistonBaseTile *>((new PistonBaseTile(29, true))->setBaseItemTypeAndMaterial(Item::eBaseItemType_piston, Item::eMaterial_stickypiston)->setIconName(L"pistonStickyBase")->setDescriptionId(IDS_TILE_PISTON_STICK_BASE)->setUseDescriptionId(IDS_DESC_STICKY_PISTON)->sendTileData());
Tile::web = (new WebTile(30)) ->setLightBlock(1)->setDestroyTime(4.0f)->setIconName(L"web")->setDescriptionId(IDS_TILE_WEB)->setUseDescriptionId(IDS_DESC_WEB);
- Tile::tallgrass = (TallGrass *)(new TallGrass(31)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"tallgrass")->setDescriptionId(IDS_TILE_TALL_GRASS)->setUseDescriptionId(IDS_DESC_TALL_GRASS)->disableMipmap();
- Tile::deadBush = (DeadBushTile *)(new DeadBushTile(32)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"deadbush")->setDescriptionId(IDS_TILE_DEAD_BUSH)->setUseDescriptionId(IDS_DESC_DEAD_BUSH)->disableMipmap();
- Tile::pistonBase = (PistonBaseTile *)(new PistonBaseTile(33,false)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_piston, Item::eMaterial_piston)->setIconName(L"pistonBase")->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(IDS_DESC_PISTON)->sendTileData();
- Tile::pistonExtension = (PistonExtensionTile *)(new PistonExtensionTile(34))->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(-1)->sendTileData();
+ Tile::tallgrass = static_cast<TallGrass *>((new TallGrass(31))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"tallgrass")->setDescriptionId(IDS_TILE_TALL_GRASS)->setUseDescriptionId(IDS_DESC_TALL_GRASS)->disableMipmap());
+ Tile::deadBush = static_cast<DeadBushTile *>((new DeadBushTile(32))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"deadbush")->setDescriptionId(IDS_TILE_DEAD_BUSH)->setUseDescriptionId(IDS_DESC_DEAD_BUSH)->disableMipmap());
+ Tile::pistonBase = static_cast<PistonBaseTile *>((new PistonBaseTile(33, false))->setBaseItemTypeAndMaterial(Item::eBaseItemType_piston, Item::eMaterial_piston)->setIconName(L"pistonBase")->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(IDS_DESC_PISTON)->sendTileData());
+ Tile::pistonExtension = static_cast<PistonExtensionTile *>((new PistonExtensionTile(34))->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(-1)->sendTileData());
Tile::wool = (new ColoredTile(35, Material::cloth)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_cloth, Item::eMaterial_cloth)->setDestroyTime(0.8f)->setSoundType(Tile::SOUND_CLOTH)->setIconName(L"wool_colored")->setDescriptionId(IDS_TILE_CLOTH)->sendTileData()->setUseDescriptionId(IDS_DESC_WOOL);
- Tile::pistonMovingPiece = (PistonMovingPiece *)(new PistonMovingPiece(36)) ->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(-1);
- Tile::flower = (Bush *) (new Bush(37)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"flower_dandelion")->setDescriptionId(IDS_TILE_FLOWER)->setUseDescriptionId(IDS_DESC_FLOWER)->disableMipmap();
- Tile::rose = (Bush *) (new Bush(38)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"flower_rose")->setDescriptionId(IDS_TILE_ROSE)->setUseDescriptionId(IDS_DESC_FLOWER)->disableMipmap();
- Tile::mushroom_brown = (Bush *) (new Mushroom(39)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setLightEmission(2 / 16.0f)->setIconName(L"mushroom_brown")->setDescriptionId(IDS_TILE_MUSHROOM)->setUseDescriptionId(IDS_DESC_MUSHROOM)->disableMipmap();
- Tile::mushroom_red = (Bush *) (new Mushroom(40)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"mushroom_red")->setDescriptionId(IDS_TILE_MUSHROOM)->setUseDescriptionId(IDS_DESC_MUSHROOM)->disableMipmap();
+ Tile::pistonMovingPiece = static_cast<PistonMovingPiece *>((new PistonMovingPiece(36))->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(-1));
+ Tile::flower = static_cast<Bush *>((new Bush(37))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"flower_dandelion")->setDescriptionId(IDS_TILE_FLOWER)->setUseDescriptionId(IDS_DESC_FLOWER)->disableMipmap());
+ Tile::rose = static_cast<Bush *>((new Bush(38))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"flower_rose")->setDescriptionId(IDS_TILE_ROSE)->setUseDescriptionId(IDS_DESC_FLOWER)->disableMipmap());
+ Tile::mushroom_brown = static_cast<Bush *>((new Mushroom(39))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setLightEmission(2 / 16.0f)->setIconName(L"mushroom_brown")->setDescriptionId(IDS_TILE_MUSHROOM)->setUseDescriptionId(IDS_DESC_MUSHROOM)->disableMipmap());
+ Tile::mushroom_red = static_cast<Bush *>((new Mushroom(40))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"mushroom_red")->setDescriptionId(IDS_TILE_MUSHROOM)->setUseDescriptionId(IDS_DESC_MUSHROOM)->disableMipmap());
Tile::goldBlock = (new MetalTile(41)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_gold)->setDestroyTime(3.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_METAL)->setIconName(L"gold_block")->setDescriptionId(IDS_TILE_BLOCK_GOLD)->setUseDescriptionId(IDS_DESC_BLOCK_GOLD);
Tile::ironBlock = (new MetalTile(42)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_iron)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_METAL)->setIconName(L"iron_block")->setDescriptionId(IDS_TILE_BLOCK_IRON)->setUseDescriptionId(IDS_DESC_BLOCK_IRON);
- Tile::stoneSlab = (HalfSlabTile *) (new StoneSlabTile(Tile::stoneSlab_Id, true)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_SLAB);
- Tile::stoneSlabHalf = (HalfSlabTile *) (new StoneSlabTile(Tile::stoneSlabHalf_Id, false)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_HALFSLAB);
+ Tile::stoneSlab = static_cast<HalfSlabTile *>((new StoneSlabTile(Tile::stoneSlab_Id, true))->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_SLAB));
+ Tile::stoneSlabHalf = static_cast<HalfSlabTile *>((new StoneSlabTile(Tile::stoneSlabHalf_Id, false))->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_HALFSLAB));
Tile::redBrick = (new Tile(45, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_brick)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"brick")->setDescriptionId(IDS_TILE_BRICK)->setUseDescriptionId(IDS_DESC_BRICK);
Tile::tnt = (new TntTile(46)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"tnt")->setDescriptionId(IDS_TILE_TNT)->setUseDescriptionId(IDS_DESC_TNT);
Tile::bookshelf = (new BookshelfTile(47)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_paper, Item::eMaterial_bookshelf)->setDestroyTime(1.5f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"bookshelf")->setDescriptionId(IDS_TILE_BOOKSHELF)->setUseDescriptionId(IDS_DESC_BOOKSHELF);
@@ -314,11 +314,11 @@ void Tile::staticCtor()
Tile::obsidian = (new ObsidianTile(49)) ->setDestroyTime(50.0f)->setExplodeable(2000)->setSoundType(Tile::SOUND_STONE)->setIconName(L"obsidian")->setDescriptionId(IDS_TILE_OBSIDIAN)->setUseDescriptionId(IDS_DESC_OBSIDIAN);
Tile::torch = (new TorchTile(50)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_torch, Item::eMaterial_wood)->setDestroyTime(0.0f)->setLightEmission(15 / 16.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"torch_on")->setDescriptionId(IDS_TILE_TORCH)->setUseDescriptionId(IDS_DESC_TORCH)->disableMipmap();
- Tile::fire = (FireTile *) ((new FireTile(51)) ->setDestroyTime(0.0f)->setLightEmission(1.0f)->setSoundType(Tile::SOUND_WOOD))->setIconName(L"fire")->setDescriptionId(IDS_TILE_FIRE)->setNotCollectStatistics()->setUseDescriptionId(-1);
+ Tile::fire = static_cast<FireTile *>(((new FireTile(51))->setDestroyTime(0.0f)->setLightEmission(1.0f)->setSoundType(Tile::SOUND_WOOD))->setIconName(L"fire")->setDescriptionId(IDS_TILE_FIRE)->setNotCollectStatistics()->setUseDescriptionId(-1));
Tile::mobSpawner = (new MobSpawnerTile(52)) ->setDestroyTime(5.0f)->setSoundType(Tile::SOUND_METAL)->setIconName(L"mob_spawner")->setDescriptionId(IDS_TILE_MOB_SPAWNER)->setNotCollectStatistics()->setUseDescriptionId(IDS_DESC_MOB_SPAWNER);
Tile::stairs_wood = (new StairTile(53, Tile::wood,0)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_wood) ->setIconName(L"stairsWood")->setDescriptionId(IDS_TILE_STAIRS_WOOD) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS);
- Tile::chest = (ChestTile *)(new ChestTile(54, ChestTile::TYPE_BASIC)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_chest, Item::eMaterial_wood)->setDestroyTime(2.5f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"chest")->setDescriptionId(IDS_TILE_CHEST)->sendTileData()->setUseDescriptionId(IDS_DESC_CHEST);
- Tile::redStoneDust = (RedStoneDustTile *)(new RedStoneDustTile(55)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_NORMAL)->setIconName(L"redstone_dust")->setDescriptionId(IDS_TILE_REDSTONE_DUST)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONE_DUST);
+ Tile::chest = static_cast<ChestTile *>((new ChestTile(54, ChestTile::TYPE_BASIC))->setBaseItemTypeAndMaterial(Item::eBaseItemType_chest, Item::eMaterial_wood)->setDestroyTime(2.5f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"chest")->setDescriptionId(IDS_TILE_CHEST)->sendTileData()->setUseDescriptionId(IDS_DESC_CHEST));
+ Tile::redStoneDust = static_cast<RedStoneDustTile *>((new RedStoneDustTile(55))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_NORMAL)->setIconName(L"redstone_dust")->setDescriptionId(IDS_TILE_REDSTONE_DUST)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONE_DUST));
Tile::diamondOre = (new OreTile(56)) ->setDestroyTime(3.0f)->setExplodeable(5)->setSoundType(Tile::SOUND_STONE)->setIconName(L"diamond_ore")->setDescriptionId(IDS_TILE_ORE_DIAMOND)->setUseDescriptionId(IDS_DESC_ORE_DIAMOND);
Tile::diamondBlock = (new MetalTile(57)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_diamond)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_METAL)->setIconName(L"diamond_block")->setDescriptionId(IDS_TILE_BLOCK_DIAMOND)->setUseDescriptionId(IDS_DESC_BLOCK_DIAMOND);
Tile::workBench = (new WorkbenchTile(58)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_device, Item::eMaterial_wood)->setDestroyTime(2.5f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"crafting_table")->setDescriptionId(IDS_TILE_WORKBENCH)->setUseDescriptionId(IDS_DESC_CRAFTINGTABLE);
@@ -356,12 +356,12 @@ void Tile::staticCtor()
Tile::netherRack = (new NetherrackTile(87)) ->setDestroyTime(0.4f)->setSoundType(Tile::SOUND_STONE)->setIconName(L"netherrack")->setDescriptionId(IDS_TILE_HELL_ROCK)->setUseDescriptionId(IDS_DESC_HELL_ROCK);
Tile::soulsand = (new SoulSandTile(88)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_SAND)->setIconName(L"soul_sand")->setDescriptionId(IDS_TILE_HELL_SAND)->setUseDescriptionId(IDS_DESC_HELL_SAND);
Tile::glowstone = (new Glowstonetile(89, Material::glass)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_torch, Item::eMaterial_glowstone)->setDestroyTime(0.3f)->setSoundType(Tile::SOUND_GLASS)->setLightEmission(1.0f)->setIconName(L"glowstone")->setDescriptionId(IDS_TILE_LIGHT_GEM)->setUseDescriptionId(IDS_DESC_GLOWSTONE);
- Tile::portalTile = (PortalTile *) ((new PortalTile(90)) ->setDestroyTime(-1)->setSoundType(Tile::SOUND_GLASS)->setLightEmission(0.75f))->setIconName(L"portal")->setDescriptionId(IDS_TILE_PORTAL)->setUseDescriptionId(IDS_DESC_PORTAL);
+ Tile::portalTile = static_cast<PortalTile *>(((new PortalTile(90))->setDestroyTime(-1)->setSoundType(Tile::SOUND_GLASS)->setLightEmission(0.75f))->setIconName(L"portal")->setDescriptionId(IDS_TILE_PORTAL)->setUseDescriptionId(IDS_DESC_PORTAL));
Tile::litPumpkin = (new PumpkinTile(91, true)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_torch, Item::eMaterial_pumpkin)->setDestroyTime(1.0f)->setSoundType(Tile::SOUND_WOOD)->setLightEmission(1.0f)->setIconName(L"pumpkin")->setDescriptionId(IDS_TILE_LIT_PUMPKIN)->sendTileData()->setUseDescriptionId(IDS_DESC_JACKOLANTERN);
Tile::cake = (new CakeTile(92)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_CLOTH)->setIconName(L"cake")->setDescriptionId(IDS_TILE_CAKE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_CAKE);
- Tile::diode_off = (RepeaterTile *)(new RepeaterTile(93, false)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"repeater_off")->setDescriptionId(IDS_ITEM_DIODE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER)->disableMipmap();
- Tile::diode_on = (RepeaterTile *)(new RepeaterTile(94, true)) ->setDestroyTime(0.0f)->setLightEmission(10 / 16.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"repeater_on")->setDescriptionId(IDS_ITEM_DIODE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER)->disableMipmap();
+ Tile::diode_off = static_cast<RepeaterTile *>((new RepeaterTile(93, false))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"repeater_off")->setDescriptionId(IDS_ITEM_DIODE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER)->disableMipmap());
+ Tile::diode_on = static_cast<RepeaterTile *>((new RepeaterTile(94, true))->setDestroyTime(0.0f)->setLightEmission(10 / 16.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"repeater_on")->setDescriptionId(IDS_ITEM_DIODE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER)->disableMipmap());
Tile::stained_glass = (new StainedGlassBlock(95, Material::glass))->setBaseItemTypeAndMaterial(Item::eBaseItemType_glass, Item::eMaterial_glass)->setDestroyTime(0.3f)->setSoundType(SOUND_GLASS)->setIconName(L"glass")->setDescriptionId(IDS_TILE_STAINED_GLASS)->setUseDescriptionId(IDS_DESC_STAINED_GLASS);
Tile::trapdoor = (new TrapDoorTile(96, Material::wood)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_door, Item::eMaterial_trap)->setDestroyTime(3.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"trapdoor")->setDescriptionId(IDS_TILE_TRAPDOOR)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_TRAPDOOR);
Tile::monsterStoneEgg = (new StoneMonsterTile(97)) ->setDestroyTime(0.75f)->setIconName(L"monsterStoneEgg")->setDescriptionId(IDS_TILE_STONE_SILVERFISH)->setUseDescriptionId(IDS_DESC_STONE_SILVERFISH);
@@ -379,7 +379,7 @@ void Tile::staticCtor()
Tile::fenceGate = (new FenceGateTile(107)) ->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"fenceGate")->setDescriptionId(IDS_TILE_FENCE_GATE)->sendTileData()->setUseDescriptionId(IDS_DESC_FENCE_GATE);
Tile::stairs_bricks = (new StairTile(108, Tile::redBrick,0)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_brick) ->setIconName(L"stairsBrick")->setDescriptionId(IDS_TILE_STAIRS_BRICKS) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS);
Tile::stairs_stoneBrickSmooth = (new StairTile(109, Tile::stoneBrick,0)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_stoneSmooth)->setIconName(L"stairsStoneBrickSmooth")->setDescriptionId(IDS_TILE_STAIRS_STONE_BRICKS_SMOOTH) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS);
- Tile::mycel = (MycelTile *)(new MycelTile(110)) ->setDestroyTime(0.6f)->setSoundType(SOUND_GRASS)->setIconName(L"mycelium")->setDescriptionId(IDS_TILE_MYCEL)->setUseDescriptionId(IDS_DESC_MYCEL);
+ Tile::mycel = static_cast<MycelTile *>((new MycelTile(110))->setDestroyTime(0.6f)->setSoundType(SOUND_GRASS)->setIconName(L"mycelium")->setDescriptionId(IDS_TILE_MYCEL)->setUseDescriptionId(IDS_DESC_MYCEL));
Tile::waterLily = (new WaterlilyTile(111)) ->setDestroyTime(0.0f)->setSoundType(SOUND_GRASS)->setIconName(L"waterlily")->setDescriptionId(IDS_TILE_WATERLILY)->setUseDescriptionId(IDS_DESC_WATERLILY);
Tile::netherBrick = (new Tile(112, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_netherbrick)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(SOUND_STONE)->setIconName(L"nether_brick")->setDescriptionId(IDS_TILE_NETHERBRICK)->setUseDescriptionId(IDS_DESC_NETHERBRICK);
@@ -388,7 +388,7 @@ void Tile::staticCtor()
Tile::netherStalk = (new NetherWartTile(115)) ->setIconName(L"nether_wart")->setDescriptionId(IDS_TILE_NETHERSTALK)->sendTileData()->setUseDescriptionId(IDS_DESC_NETHERSTALK);
Tile::enchantTable = (new EnchantmentTableTile(116)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_device, Item::eMaterial_magic)->setDestroyTime(5.0f)->setExplodeable(2000)->setIconName(L"enchanting_table")->setDescriptionId(IDS_TILE_ENCHANTMENTTABLE)->setUseDescriptionId(IDS_DESC_ENCHANTMENTTABLE);
Tile::brewingStand = (new BrewingStandTile(117)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_device, Item::eMaterial_blaze)->setDestroyTime(0.5f)->setLightEmission(2 / 16.0f)->setIconName(L"brewing_stand")->setDescriptionId(IDS_TILE_BREWINGSTAND)->sendTileData()->setUseDescriptionId(IDS_DESC_BREWING_STAND);
- Tile::cauldron = (CauldronTile *)(new CauldronTile(118)) ->setDestroyTime(2.0f)->setIconName(L"cauldron")->setDescriptionId(IDS_TILE_CAULDRON)->sendTileData()->setUseDescriptionId(IDS_DESC_CAULDRON);
+ Tile::cauldron = static_cast<CauldronTile *>((new CauldronTile(118))->setDestroyTime(2.0f)->setIconName(L"cauldron")->setDescriptionId(IDS_TILE_CAULDRON)->sendTileData()->setUseDescriptionId(IDS_DESC_CAULDRON));
Tile::endPortalTile = (new TheEndPortal(119, Material::portal)) ->setDestroyTime(INDESTRUCTIBLE_DESTROY_TIME)->setExplodeable(6000000)->setDescriptionId(IDS_TILE_END_PORTAL)->setUseDescriptionId(IDS_DESC_END_PORTAL);
Tile::endPortalFrameTile = (new TheEndPortalFrameTile(120)) ->setSoundType(SOUND_GLASS)->setLightEmission(2 / 16.0f)->setDestroyTime(INDESTRUCTIBLE_DESTROY_TIME)->setIconName(L"endframe")->setDescriptionId(IDS_TILE_ENDPORTALFRAME)->sendTileData()->setExplodeable(6000000)->setUseDescriptionId(IDS_DESC_ENDPORTALFRAME);
@@ -396,22 +396,22 @@ void Tile::staticCtor()
Tile::dragonEgg = (new EggTile(122)) ->setDestroyTime(3.0f)->setExplodeable(15)->setSoundType(SOUND_STONE)->setLightEmission(2.0f / 16.0f)->setIconName(L"dragon_egg")->setDescriptionId(IDS_TILE_DRAGONEGG)->setUseDescriptionId(IDS_DESC_DRAGONEGG);
Tile::redstoneLight = (new RedlightTile(123, false)) ->setDestroyTime(0.3f)->setSoundType(SOUND_GLASS)->setIconName(L"redstone_lamp_off")->setDescriptionId(IDS_TILE_REDSTONE_LIGHT)->setUseDescriptionId(IDS_DESC_REDSTONE_LIGHT);
Tile::redstoneLight_lit = (new RedlightTile(124, true)) ->setDestroyTime(0.3f)->setSoundType(SOUND_GLASS)->setIconName(L"redstone_lamp_on")->setDescriptionId(IDS_TILE_REDSTONE_LIGHT)->setUseDescriptionId(IDS_DESC_REDSTONE_LIGHT);
- Tile::woodSlab = (HalfSlabTile *) (new WoodSlabTile(Tile::woodSlab_Id, true)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB);
- Tile::woodSlabHalf = (HalfSlabTile *) (new WoodSlabTile(Tile::woodSlabHalf_Id, false)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB);
+ Tile::woodSlab = static_cast<HalfSlabTile *>((new WoodSlabTile(Tile::woodSlab_Id, true))->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB));
+ Tile::woodSlabHalf = static_cast<HalfSlabTile *>((new WoodSlabTile(Tile::woodSlabHalf_Id, false))->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB));
Tile::cocoa = (new CocoaTile(127)) ->setDestroyTime(0.2f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"cocoa")->sendTileData()->setDescriptionId(IDS_TILE_COCOA)->setUseDescriptionId(IDS_DESC_COCOA);
Tile::stairs_sandstone = (new StairTile(128, Tile::sandStone,0)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_sand) ->setIconName(L"stairsSandstone")->setDescriptionId(IDS_TILE_STAIRS_SANDSTONE) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS);
Tile::emeraldOre = (new OreTile(129)) ->setDestroyTime(3.0f)->setExplodeable(5)->setSoundType(SOUND_STONE)->setIconName(L"emerald_ore")->setDescriptionId(IDS_TILE_EMERALDORE)->setUseDescriptionId(IDS_DESC_EMERALDORE);
Tile::enderChest = (new EnderChestTile(130)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_chest, Item::eMaterial_ender)->setDestroyTime(22.5f)->setExplodeable(1000)->setSoundType(SOUND_STONE)->setIconName(L"enderChest")->sendTileData()->setLightEmission(.5f)->setDescriptionId(IDS_TILE_ENDERCHEST)->setUseDescriptionId(IDS_DESC_ENDERCHEST);
- Tile::tripWireSource = (TripWireSourceTile *)( new TripWireSourceTile(131) ) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_lever, Item::eMaterial_undefined)->setIconName(L"trip_wire_source")->sendTileData()->setDescriptionId(IDS_TILE_TRIPWIRE_SOURCE)->setUseDescriptionId(IDS_DESC_TRIPWIRE_SOURCE);
+ Tile::tripWireSource = static_cast<TripWireSourceTile *>((new TripWireSourceTile(131))->setBaseItemTypeAndMaterial(Item::eBaseItemType_lever, Item::eMaterial_undefined)->setIconName(L"trip_wire_source")->sendTileData()->setDescriptionId(IDS_TILE_TRIPWIRE_SOURCE)->setUseDescriptionId(IDS_DESC_TRIPWIRE_SOURCE));
Tile::tripWire = (new TripWireTile(132)) ->setIconName(L"trip_wire")->sendTileData()->setDescriptionId(IDS_TILE_TRIPWIRE)->setUseDescriptionId(IDS_DESC_TRIPWIRE);
Tile::emeraldBlock = (new MetalTile(133)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_emerald)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(SOUND_METAL)->setIconName(L"emerald_block")->setDescriptionId(IDS_TILE_EMERALDBLOCK)->setUseDescriptionId(IDS_DESC_EMERALDBLOCK);
Tile::woodStairsDark = (new StairTile(134, Tile::wood, TreeTile::DARK_TRUNK)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_sprucewood)->setIconName(L"stairsWoodSpruce")->setDescriptionId(IDS_TILE_STAIRS_SPRUCEWOOD) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS);
Tile::woodStairsBirch = (new StairTile(135, Tile::wood, TreeTile::BIRCH_TRUNK)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_birchwood)->setIconName(L"stairsWoodBirch")->setDescriptionId(IDS_TILE_STAIRS_BIRCHWOOD) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS);
Tile::woodStairsJungle =(new StairTile(136, Tile::wood, TreeTile::JUNGLE_TRUNK))->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_junglewood)->setIconName(L"stairsWoodJungle")->setDescriptionId(IDS_TILE_STAIRS_JUNGLEWOOD) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS);
Tile::commandBlock = (new CommandBlock(137)) ->setIndestructible()->setExplodeable(6000000)->setIconName(L"command_block")->setDescriptionId(IDS_TILE_COMMAND_BLOCK)->setUseDescriptionId(IDS_DESC_COMMAND_BLOCK);
- Tile::beacon = (BeaconTile *) (new BeaconTile(138)) ->setLightEmission(1.0f)->setIconName(L"beacon")->setDescriptionId(IDS_TILE_BEACON)->setUseDescriptionId(IDS_DESC_BEACON);
+ Tile::beacon = static_cast<BeaconTile *>((new BeaconTile(138))->setLightEmission(1.0f)->setIconName(L"beacon")->setDescriptionId(IDS_TILE_BEACON)->setUseDescriptionId(IDS_DESC_BEACON));
Tile::cobbleWall = (new WallTile(139, Tile::stoneBrick)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_fence, Item::eMaterial_stone)->setIconName(L"cobbleWall")->setDescriptionId(IDS_TILE_COBBLESTONE_WALL)->setUseDescriptionId(IDS_DESC_COBBLESTONE_WALL);
Tile::flowerPot = (new FlowerPotTile(140)) ->setDestroyTime(0.0f)->setSoundType(SOUND_NORMAL)->setIconName(L"flower_pot")->setDescriptionId(IDS_TILE_FLOWERPOT)->setUseDescriptionId(IDS_DESC_FLOWERPOT);
@@ -423,13 +423,13 @@ void Tile::staticCtor()
Tile::chest_trap = (new ChestTile(146, ChestTile::TYPE_TRAP)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_chest, Item::eMaterial_trap)->setDestroyTime(2.5f)->setSoundType(SOUND_WOOD)->setDescriptionId(IDS_TILE_CHEST_TRAP)->setUseDescriptionId(IDS_DESC_CHEST_TRAP);
Tile::weightedPlate_light = (new WeightedPressurePlateTile(147, L"gold_block", Material::metal, Redstone::SIGNAL_MAX)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_pressureplate, Item::eMaterial_gold)->setDestroyTime(0.5f)->setSoundType(SOUND_WOOD)->setDescriptionId(IDS_TILE_WEIGHTED_PLATE_LIGHT)->setUseDescriptionId(IDS_DESC_WEIGHTED_PLATE_LIGHT);
Tile::weightedPlate_heavy = (new WeightedPressurePlateTile(148, L"iron_block", Material::metal, Redstone::SIGNAL_MAX * 10))->setBaseItemTypeAndMaterial(Item::eBaseItemType_pressureplate, Item::eMaterial_iron)->setDestroyTime(0.5f)->setSoundType(SOUND_WOOD)->setDescriptionId(IDS_TILE_WEIGHTED_PLATE_HEAVY)->setUseDescriptionId(IDS_DESC_WEIGHTED_PLATE_HEAVY);
- Tile::comparator_off = (ComparatorTile *) (new ComparatorTile(149, false)) ->setDestroyTime(0.0f)->setSoundType(SOUND_WOOD)->setIconName(L"comparator_off")->setDescriptionId(IDS_TILE_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR);
- Tile::comparator_on = (ComparatorTile *) (new ComparatorTile(150, true)) ->setDestroyTime(0.0f)->setLightEmission(10 / 16.0f)->setSoundType(SOUND_WOOD)->setIconName(L"comparator_on")->setDescriptionId(IDS_TILE_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR);
+ Tile::comparator_off = static_cast<ComparatorTile *>((new ComparatorTile(149, false))->setDestroyTime(0.0f)->setSoundType(SOUND_WOOD)->setIconName(L"comparator_off")->setDescriptionId(IDS_TILE_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR));
+ Tile::comparator_on = static_cast<ComparatorTile *>((new ComparatorTile(150, true))->setDestroyTime(0.0f)->setLightEmission(10 / 16.0f)->setSoundType(SOUND_WOOD)->setIconName(L"comparator_on")->setDescriptionId(IDS_TILE_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR));
- Tile::daylightDetector = (DaylightDetectorTile *) (new DaylightDetectorTile(151))->setDestroyTime(0.2f)->setSoundType(SOUND_WOOD)->setIconName(L"daylight_detector")->setDescriptionId(IDS_TILE_DAYLIGHT_DETECTOR)->setUseDescriptionId(IDS_DESC_DAYLIGHT_DETECTOR);
+ Tile::daylightDetector = static_cast<DaylightDetectorTile *>((new DaylightDetectorTile(151))->setDestroyTime(0.2f)->setSoundType(SOUND_WOOD)->setIconName(L"daylight_detector")->setDescriptionId(IDS_TILE_DAYLIGHT_DETECTOR)->setUseDescriptionId(IDS_DESC_DAYLIGHT_DETECTOR));
Tile::redstoneBlock = (new PoweredMetalTile(152)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_redstone)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(SOUND_METAL)->setIconName(L"redstone_block")->setDescriptionId(IDS_TILE_REDSTONE_BLOCK)->setUseDescriptionId(IDS_DESC_REDSTONE_BLOCK);
Tile::netherQuartz = (new OreTile(153)) ->setDestroyTime(3.0f)->setExplodeable(5)->setSoundType(SOUND_STONE)->setIconName(L"quartz_ore")->setDescriptionId(IDS_TILE_NETHER_QUARTZ)->setUseDescriptionId(IDS_DESC_NETHER_QUARTZ_ORE);
- Tile::hopper = (HopperTile *)(new HopperTile(154)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_redstoneContainer, Item::eMaterial_undefined)->setDestroyTime(3.0f)->setExplodeable(8)->setSoundType(SOUND_WOOD)->setIconName(L"hopper")->setDescriptionId(IDS_TILE_HOPPER)->setUseDescriptionId(IDS_DESC_HOPPER);
+ Tile::hopper = static_cast<HopperTile *>((new HopperTile(154))->setBaseItemTypeAndMaterial(Item::eBaseItemType_redstoneContainer, Item::eMaterial_undefined)->setDestroyTime(3.0f)->setExplodeable(8)->setSoundType(SOUND_WOOD)->setIconName(L"hopper")->setDescriptionId(IDS_TILE_HOPPER)->setUseDescriptionId(IDS_DESC_HOPPER));
Tile::quartzBlock = (new QuartzBlockTile(155)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_quartz)->setSoundType(SOUND_STONE)->setDestroyTime(0.8f)->setIconName(L"quartz_block")->setDescriptionId(IDS_TILE_QUARTZ_BLOCK)->setUseDescriptionId(IDS_DESC_QUARTZ_BLOCK);
Tile::stairs_quartz = (new StairTile(156, Tile::quartzBlock, QuartzBlockTile::TYPE_DEFAULT)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_quartz)->setIconName(L"stairsQuartz")->setDescriptionId(IDS_TILE_STAIRS_QUARTZ)->setUseDescriptionId(IDS_DESC_STAIRS);
Tile::activatorRail = (new PoweredRailTile(157)) ->setDestroyTime(0.7f)->setSoundType(SOUND_METAL)->setIconName(L"rail_activator")->setDescriptionId(IDS_TILE_ACTIVATOR_RAIL)->setUseDescriptionId(IDS_DESC_ACTIVATOR_RAIL);
@@ -464,7 +464,7 @@ void Tile::staticCtor()
Item::items[vine_Id] = ( new ColoredTileItem(Tile::vine_Id - 256, false))->setDescriptionId(IDS_TILE_VINE)->setUseDescriptionId(IDS_DESC_VINE);
int idsData[3] = {IDS_TILE_SHRUB, IDS_TILE_TALL_GRASS, IDS_TILE_FERN};
intArray ids = intArray(idsData, 3);
- Item::items[tallgrass_Id] = ( (ColoredTileItem *)(new ColoredTileItem(Tile::tallgrass_Id - 256, true))->setDescriptionId(IDS_TILE_TALL_GRASS))->setDescriptionPostfixes(ids);
+ Item::items[tallgrass_Id] = static_cast<ColoredTileItem *>((new ColoredTileItem(Tile::tallgrass_Id - 256, true))->setDescriptionId(IDS_TILE_TALL_GRASS))->setDescriptionPostfixes(ids);
Item::items[topSnow_Id] = ( new SnowItem(topSnow_Id - 256, topSnow) );
Item::items[waterLily_Id] = ( new WaterLilyTileItem(Tile::waterLily_Id - 256));
Item::items[pistonBase_Id] = ( new PistonTileItem(Tile::pistonBase_Id - 256) )->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(IDS_DESC_PISTON);
@@ -475,9 +475,9 @@ void Tile::staticCtor()
for (int i = 0; i < 256; i++)
{
- if ( Tile::tiles[i] != NULL )
+ if ( Tile::tiles[i] != nullptr )
{
- if( Item::items[i] == NULL)
+ if( Item::items[i] == nullptr)
{
Item::items[i] = new TileItem(i - 256);
Tile::tiles[i]->init();
@@ -485,7 +485,7 @@ void Tile::staticCtor()
bool propagate = false;
if (i > 0 && Tile::tiles[i]->getRenderShape() == Tile::SHAPE_STAIRS) propagate = true;
- if (i > 0 && dynamic_cast<HalfSlabTile *>(Tile::tiles[i]) != NULL)
+ if (i > 0 && dynamic_cast<HalfSlabTile *>(Tile::tiles[i]) != nullptr)
{
propagate = true;
}
@@ -549,7 +549,7 @@ Tile::Tile(int id, Material *material, bool isSolidRender)
_init(id,material, isSolidRender);
m_iMaterial=Item::eMaterial_undefined;
m_iBaseItemType=Item::eBaseItemType_undefined;
- icon = NULL;
+ icon = nullptr;
}
Tile *Tile::sendTileData(unsigned char importantMask/*=15*/)
@@ -597,7 +597,7 @@ Tile *Tile::setLightBlock(int i)
Tile *Tile::setLightEmission(float f)
{
- Tile::lightEmission[id] = (int) (Level::MAX_BRIGHTNESS * f);
+ Tile::lightEmission[id] = static_cast<int>(Level::MAX_BRIGHTNESS * f);
return this;
}
@@ -610,7 +610,7 @@ Tile *Tile::setExplodeable(float explosionResistance)
bool Tile::isSolidBlockingTile(int t)
{
Tile *tile = Tile::tiles[t];
- if (tile == NULL) return false;
+ if (tile == nullptr) return false;
return tile->material->isSolidBlocking() && tile->isCubeShaped() && !tile->isSignalSource();
}
@@ -671,7 +671,7 @@ Tile *Tile::disableMipmap()
void Tile::setShape(float x0, float y0, float z0, float x1, float y1, float z1)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
tls->xx0 = x0;
tls->yy0 = y0;
tls->zz0 = z0;
@@ -721,7 +721,7 @@ bool Tile::isFaceVisible(Level *level, int x, int y, int z, int f)
bool Tile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
if (face == 0 && tls->yy0 > 0) return true;
@@ -738,7 +738,7 @@ int Tile::getFaceFlags(LevelSource *level, int x, int y, int z)
{
int faceFlags = 0;
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
@@ -779,13 +779,13 @@ Icon *Tile::getTexture(LevelSource *level, int x, int y, int z, int face)
for( int i = 0; (i < 6) && opaque; i++ )
{
int t = level->getTile(x + axo[i], y + ayo[i] , z + azo[i]);
- if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == NULL ) || !Tile::tiles[t]->isSolidRender() ) )
+ if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == nullptr ) || !Tile::tiles[t]->isSolidRender() ) )
{
opaque = false;
}
}
- Icon *icon = NULL;
+ Icon *icon = nullptr;
if(opaque)
{
Tile::leaves->setFancy(false);
@@ -813,7 +813,7 @@ Icon *Tile::getTexture(int face)
AABB *Tile::getTileAABB(Level *level, int x, int y, int z)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1);
@@ -822,12 +822,12 @@ AABB *Tile::getTileAABB(Level *level, int x, int y, int z)
void Tile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source)
{
AABB *aabb = getAABB(level, x, y, z);
- if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb);
+ if (aabb != nullptr && box->intersects(aabb)) boxes->push_back(aabb);
}
AABB *Tile::getAABB(Level *level, int x, int y, int z)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1);
@@ -917,7 +917,7 @@ void Tile::spawnResources(Level *level, int x, int y, int z, int data, float odd
int type = getResource(data, level->random, playerBonusLevel);
if (type <= 0) continue;
- popResource(level, x, y, z, shared_ptr<ItemInstance>( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) );
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(type, 1, getSpawnResourcesAuxValue(data)));
}
}
@@ -929,7 +929,7 @@ void Tile::popResource(Level *level, int x, int y, int z, shared_ptr<ItemInstanc
double xo = level->random->nextFloat() * s + (1 - s) * 0.5;
double yo = level->random->nextFloat() * s + (1 - s) * 0.5;
double zo = level->random->nextFloat() * s + (1 - s) * 0.5;
- shared_ptr<ItemEntity> item = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) );
+ shared_ptr<ItemEntity> item = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, itemInstance);
item->throwTime = 10;
level->addEntity(item);
}
@@ -943,7 +943,7 @@ void Tile::popExperience(Level *level, int x, int y, int z, int amount)
{
int newCount = ExperienceOrb::getExperienceValue(amount);
amount -= newCount;
- level->addEntity(shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
+ level->addEntity(std::make_shared<ExperienceOrb>(level, x + .5, y + .5, z + .5, newCount));
}
}
}
@@ -965,7 +965,7 @@ HitResult *Tile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b)
a = a->add(-xt, -yt, -zt);
b = b->add(-xt, -yt, -zt);
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
Vec3 *xh0 = a->clipX(b, tls->xx0);
Vec3 *xh1 = a->clipX(b, tls->xx1);
@@ -975,16 +975,16 @@ HitResult *Tile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b)
Vec3 *zh0 = a->clipZ(b, tls->zz0);
Vec3 *zh1 = a->clipZ(b, tls->zz1);
- Vec3 *closest = NULL;
+ Vec3 *closest = nullptr;
- if (containsX(xh0) && (closest == NULL || a->distanceToSqr(xh0) < a->distanceToSqr(closest))) closest = xh0;
- if (containsX(xh1) && (closest == NULL || a->distanceToSqr(xh1) < a->distanceToSqr(closest))) closest = xh1;
- if (containsY(yh0) && (closest == NULL || a->distanceToSqr(yh0) < a->distanceToSqr(closest))) closest = yh0;
- if (containsY(yh1) && (closest == NULL || a->distanceToSqr(yh1) < a->distanceToSqr(closest))) closest = yh1;
- if (containsZ(zh0) && (closest == NULL || a->distanceToSqr(zh0) < a->distanceToSqr(closest))) closest = zh0;
- if (containsZ(zh1) && (closest == NULL || a->distanceToSqr(zh1) < a->distanceToSqr(closest))) closest = zh1;
+ if (containsX(xh0) && (closest == nullptr || a->distanceToSqr(xh0) < a->distanceToSqr(closest))) closest = xh0;
+ if (containsX(xh1) && (closest == nullptr || a->distanceToSqr(xh1) < a->distanceToSqr(closest))) closest = xh1;
+ if (containsY(yh0) && (closest == nullptr || a->distanceToSqr(yh0) < a->distanceToSqr(closest))) closest = yh0;
+ if (containsY(yh1) && (closest == nullptr || a->distanceToSqr(yh1) < a->distanceToSqr(closest))) closest = yh1;
+ if (containsZ(zh0) && (closest == nullptr || a->distanceToSqr(zh0) < a->distanceToSqr(closest))) closest = zh0;
+ if (containsZ(zh1) && (closest == nullptr || a->distanceToSqr(zh1) < a->distanceToSqr(closest))) closest = zh1;
- if (closest == NULL) return NULL;
+ if (closest == nullptr) return nullptr;
int face = -1;
@@ -1000,9 +1000,9 @@ HitResult *Tile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b)
bool Tile::containsX(Vec3 *v)
{
- if( v == NULL) return false;
+ if( v == nullptr) return false;
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return v->y >= tls->yy0 && v->y <= tls->yy1 && v->z >= tls->zz0 && v->z <= tls->zz1;
@@ -1010,9 +1010,9 @@ bool Tile::containsX(Vec3 *v)
bool Tile::containsY(Vec3 *v)
{
- if( v == NULL) return false;
+ if( v == nullptr) return false;
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return v->x >= tls->xx0 && v->x <= tls->xx1 && v->z >= tls->zz0 && v->z <= tls->zz1;
@@ -1020,9 +1020,9 @@ bool Tile::containsY(Vec3 *v)
bool Tile::containsZ(Vec3 *v)
{
- if( v == NULL) return false;
+ if( v == nullptr) return false;
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return v->x >= tls->xx0 && v->x <= tls->xx1 && v->y >= tls->yy0 && v->y <= tls->yy1;
@@ -1092,14 +1092,14 @@ void Tile::handleEntityInside(Level *level, int x, int y, int z, shared_ptr<Enti
void Tile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
}
double Tile::getShapeX0()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return tls->xx0;
@@ -1107,7 +1107,7 @@ double Tile::getShapeX0()
double Tile::getShapeX1()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return tls->xx1;
@@ -1115,7 +1115,7 @@ double Tile::getShapeX1()
double Tile::getShapeY0()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return tls->yy0;
@@ -1123,7 +1123,7 @@ double Tile::getShapeY0()
double Tile::getShapeY1()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return tls->yy1;
@@ -1131,7 +1131,7 @@ double Tile::getShapeY1()
double Tile::getShapeZ0()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return tls->zz0;
@@ -1139,7 +1139,7 @@ double Tile::getShapeZ0()
double Tile::getShapeZ1()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return tls->zz1;
@@ -1194,7 +1194,7 @@ void Tile::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y,
// 4J Stu - Special case - only record a crop destroy if is fully grown
if( id==Tile::wheat_Id )
{
- if( Tile::wheat->getResource(data, NULL, 0) > 0 )
+ if( Tile::wheat->getResource(data, nullptr, 0) > 0 )
player->awardStat(
GenericStats::blocksMined(id),
GenericStats::param_blocksMined(id,data,1)
@@ -1202,7 +1202,7 @@ void Tile::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y,
}
else if (id == Tile::potatoes_Id)
{
- if (Tile::potatoes->getResource(data, NULL, 0) > 0)
+ if (Tile::potatoes->getResource(data, nullptr, 0) > 0)
player->awardStat(
GenericStats::blocksMined(id),
GenericStats::param_blocksMined(id,data,1)
@@ -1210,7 +1210,7 @@ void Tile::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y,
}
else if (id == Tile::carrots_Id)
{
- if (Tile::potatoes->getResource(data, NULL, 0) > 0)
+ if (Tile::potatoes->getResource(data, nullptr, 0) > 0)
player->awardStat(
GenericStats::blocksMined(id),
GenericStats::param_blocksMined(id,data,1)
@@ -1233,7 +1233,7 @@ void Tile::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y,
if (isSilkTouchable() && EnchantmentHelper::hasSilkTouch(player))
{
shared_ptr<ItemInstance> item = getSilkTouchItemInstance(data);
- if (item != NULL)
+ if (item != nullptr)
{
popResource(level, x, y, z, item);
}
@@ -1257,7 +1257,7 @@ shared_ptr<ItemInstance> Tile::getSilkTouchItemInstance(int data)
{
popData = data;
}
- return shared_ptr<ItemInstance>(new ItemInstance(id, 1, popData));
+ return std::make_shared<ItemInstance>(id, 1, popData);
}
int Tile::getResourceCountForLootBonus(int bonusLevel, Random *random)
@@ -1388,7 +1388,7 @@ bool Tile::isMatching(int tileIdA, int tileIdB)
{
return true;
}
- if (tileIdA == 0 || tileIdB == 0 || tiles[tileIdA] == NULL || tiles[tileIdB] == NULL)
+ if (tileIdA == 0 || tileIdB == 0 || tiles[tileIdA] == nullptr || tiles[tileIdB] == nullptr)
{
return false;
}
diff --git a/Minecraft.World/TileDestructionPacket.h b/Minecraft.World/TileDestructionPacket.h
index 20cd7db9..76509349 100644
--- a/Minecraft.World/TileDestructionPacket.h
+++ b/Minecraft.World/TileDestructionPacket.h
@@ -30,6 +30,6 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TileDestructionPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TileDestructionPacket>(); }
virtual int getId() { return 55; }
}; \ No newline at end of file
diff --git a/Minecraft.World/TileEditorOpenPacket.h b/Minecraft.World/TileEditorOpenPacket.h
index 20a731bb..ee68a6cf 100644
--- a/Minecraft.World/TileEditorOpenPacket.h
+++ b/Minecraft.World/TileEditorOpenPacket.h
@@ -20,6 +20,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TileEditorOpenPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TileEditorOpenPacket>(); }
virtual int getId() { return 133; }
}; \ No newline at end of file
diff --git a/Minecraft.World/TileEntity.cpp b/Minecraft.World/TileEntity.cpp
index 1eb9cab2..1fff44bb 100644
--- a/Minecraft.World/TileEntity.cpp
+++ b/Minecraft.World/TileEntity.cpp
@@ -46,11 +46,11 @@ void TileEntity::setId(tileEntityCreateFn createFn, eINSTANCEOF clas, wstring id
TileEntity::TileEntity()
{
- level = NULL;
+ level = nullptr;
x = y = z = 0;
remove = false;
data = -1;
- tile = NULL;
+ tile = nullptr;
renderRemoveStage = e_RenderRemoveStageKeep;
}
@@ -66,7 +66,7 @@ void TileEntity::setLevel(Level *level)
bool TileEntity::hasLevel()
{
- return level != NULL;
+ return level != nullptr;
}
void TileEntity::load(CompoundTag *tag)
@@ -101,7 +101,7 @@ shared_ptr<TileEntity> TileEntity::loadStatic(CompoundTag *tag)
auto it = idCreateMap.find(tag->getString(L"id"));
if (it != idCreateMap.end())
entity = shared_ptr<TileEntity>(it->second());
- if (entity != NULL)
+ if (entity != nullptr)
{
entity->load(tag);
}
@@ -129,11 +129,11 @@ void TileEntity::setData(int data, int updateFlags)
void TileEntity::setChanged()
{
- if (level != NULL)
+ if (level != nullptr)
{
data = level->getData(x, y, z);
level->tileEntityChanged(x, y, z, shared_from_this());
- if (getTile() != NULL) level->updateNeighbourForOutputSignal(x, y, z, getTile()->id);
+ if (getTile() != nullptr) level->updateNeighbourForOutputSignal(x, y, z, getTile()->id);
}
}
@@ -152,7 +152,7 @@ double TileEntity::getViewDistance()
Tile *TileEntity::getTile()
{
- if( tile == NULL ) tile = Tile::tiles[level->getTile(x, y, z)];
+ if( tile == nullptr ) tile = Tile::tiles[level->getTile(x, y, z)];
return tile;
}
@@ -183,7 +183,7 @@ bool TileEntity::triggerEvent(int b0, int b1)
void TileEntity::clearCache()
{
- tile = NULL;
+ tile = nullptr;
data = -1;
}
diff --git a/Minecraft.World/TileEntityDataPacket.cpp b/Minecraft.World/TileEntityDataPacket.cpp
index 41be4526..a30f7873 100644
--- a/Minecraft.World/TileEntityDataPacket.cpp
+++ b/Minecraft.World/TileEntityDataPacket.cpp
@@ -10,7 +10,7 @@ void TileEntityDataPacket::_init()
{
x = y = z = 0;
type = TYPE_MOB_SPAWNER;
- tag = NULL;
+ tag = nullptr;
}
@@ -50,7 +50,7 @@ void TileEntityDataPacket::write(DataOutputStream *dos)
dos->writeInt(x);
dos->writeShort(y);
dos->writeInt(z);
- dos->writeByte((byte) type);
+ dos->writeByte(static_cast<byte>(type));
writeNbt(tag, dos);
}
diff --git a/Minecraft.World/TileEntityDataPacket.h b/Minecraft.World/TileEntityDataPacket.h
index 2ee998f3..6fe3bf89 100644
--- a/Minecraft.World/TileEntityDataPacket.h
+++ b/Minecraft.World/TileEntityDataPacket.h
@@ -31,6 +31,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TileEntityDataPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TileEntityDataPacket>(); }
virtual int getId() { return 132; }
}; \ No newline at end of file
diff --git a/Minecraft.World/TileEventPacket.h b/Minecraft.World/TileEventPacket.h
index ca2685fa..f587b1ff 100644
--- a/Minecraft.World/TileEventPacket.h
+++ b/Minecraft.World/TileEventPacket.h
@@ -17,6 +17,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TileEventPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TileEventPacket>(); }
virtual int getId() { return 54; }
}; \ No newline at end of file
diff --git a/Minecraft.World/TileItem.cpp b/Minecraft.World/TileItem.cpp
index ce313dd6..8d22594d 100644
--- a/Minecraft.World/TileItem.cpp
+++ b/Minecraft.World/TileItem.cpp
@@ -20,7 +20,7 @@ using namespace std;
TileItem::TileItem(int id) : Item(id)
{
this->tileId = id + 256;
- itemIcon = NULL;
+ itemIcon = nullptr;
}
int TileItem::getTileId()
@@ -39,7 +39,7 @@ int TileItem::getIconType()
Icon *TileItem::getIcon(int auxValue)
{
- if (itemIcon != NULL)
+ if (itemIcon != nullptr)
{
return itemIcon;
}
@@ -128,7 +128,7 @@ bool TileItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> playe
//
// if(iPlaceSound==-1)
// {
- // strcpy(szPlaceSoundName,"NULL");
+ // strcpy(szPlaceSoundName,"nullptr");
// }
// else
// {
@@ -136,7 +136,7 @@ bool TileItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> playe
// }
// if(iStepSound==-1)
// {
- // strcpy(szStepSoundName,"NULL");
+ // strcpy(szStepSoundName,"nullptr");
// }
// else
// {
diff --git a/Minecraft.World/TileUpdatePacket.cpp b/Minecraft.World/TileUpdatePacket.cpp
index a1423129..067d0615 100644
--- a/Minecraft.World/TileUpdatePacket.cpp
+++ b/Minecraft.World/TileUpdatePacket.cpp
@@ -31,7 +31,7 @@ void TileUpdatePacket::read(DataInputStream *dis) //throws IOException
y = dis->readUnsignedByte();
z = dis->readInt();
- block = (int)dis->readShort() & 0xffff;
+ block = static_cast<int>(dis->readShort()) & 0xffff;
BYTE dataLevel = dis->readByte();
data = dataLevel & 0xf;
diff --git a/Minecraft.World/TileUpdatePacket.h b/Minecraft.World/TileUpdatePacket.h
index fe69c763..c9bb93ce 100644
--- a/Minecraft.World/TileUpdatePacket.h
+++ b/Minecraft.World/TileUpdatePacket.h
@@ -18,6 +18,6 @@ public:
virtual void handle(PacketListener *listener);
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TileUpdatePacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TileUpdatePacket>(); }
virtual int getId() { return 53; }
}; \ No newline at end of file
diff --git a/Minecraft.World/TimeCommand.cpp b/Minecraft.World/TimeCommand.cpp
index 4ac23c94..05147983 100644
--- a/Minecraft.World/TimeCommand.cpp
+++ b/Minecraft.World/TimeCommand.cpp
@@ -81,5 +81,5 @@ shared_ptr<GameCommandPacket> TimeCommand::preparePacket(bool night)
dos.writeBoolean(night);
- return shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Time, baos.toByteArray() ));
+ return std::make_shared<GameCommandPacket>(eGameCommand_Time, baos.toByteArray());
} \ No newline at end of file
diff --git a/Minecraft.World/TntTile.cpp b/Minecraft.World/TntTile.cpp
index 430755fc..eff9efae 100644
--- a/Minecraft.World/TntTile.cpp
+++ b/Minecraft.World/TntTile.cpp
@@ -12,8 +12,8 @@
TntTile::TntTile(int id) : Tile(id, Material::explosive)
{
- iconTop = NULL;
- iconBottom = NULL;
+ iconTop = nullptr;
+ iconBottom = nullptr;
}
Icon *TntTile::getTexture(int face, int data)
@@ -57,7 +57,7 @@ void TntTile::wasExploded(Level *level, int x, int y, int z, Explosion *explosio
// 4J-JEV: Fix for #90934 - Customer Encountered: TU11: Content: Gameplay: TNT blocks are triggered by explosions even though "TNT explodes" option is unchecked.
if( level->newPrimedTntAllowed() && app.GetGameHostOption(eGameHostOption_TNT) )
{
- shared_ptr<PrimedTnt> primed = shared_ptr<PrimedTnt>( new PrimedTnt(level, x + 0.5f, y + 0.5f, z + 0.5f, explosion->getSourceMob()) );
+ shared_ptr<PrimedTnt> primed = std::make_shared<PrimedTnt>(level, x + 0.5f, y + 0.5f, z + 0.5f, explosion->getSourceMob());
primed->life = level->random->nextInt(primed->life / 4) + primed->life / 8;
level->addEntity(primed);
}
@@ -77,7 +77,7 @@ void TntTile::destroy(Level *level, int x, int y, int z, int data, shared_ptr<Li
// 4J - added condition to have finite limit of these
if( level->newPrimedTntAllowed() && app.GetGameHostOption(eGameHostOption_TNT) )
{
- shared_ptr<PrimedTnt> tnt = shared_ptr<PrimedTnt>( new PrimedTnt(level, x + 0.5f, y + 0.5f, z + 0.5f, source) );
+ shared_ptr<PrimedTnt> tnt = std::make_shared<PrimedTnt>(level, x + 0.5f, y + 0.5f, z + 0.5f, source);
level->addEntity(tnt);
level->playEntitySound(tnt, eSoundType_RANDOM_FUSE, 1, 1.0f);
}
@@ -87,7 +87,7 @@ void TntTile::destroy(Level *level, int x, int y, int z, int data, shared_ptr<Li
bool TntTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param
{
if (soundOnly) return false;
- if (player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::flintAndSteel_Id)
+ if (player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::flintAndSteel_Id)
{
destroy(level, x, y, z, EXPLODE_BIT, player);
level->removeTile(x, y, z);
diff --git a/Minecraft.World/ToggleDownfallCommand.cpp b/Minecraft.World/ToggleDownfallCommand.cpp
index 1d0a4d9e..526be353 100644
--- a/Minecraft.World/ToggleDownfallCommand.cpp
+++ b/Minecraft.World/ToggleDownfallCommand.cpp
@@ -31,5 +31,5 @@ void ToggleDownfallCommand::doToggleDownfall()
shared_ptr<GameCommandPacket> ToggleDownfallCommand::preparePacket()
{
- return shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_ToggleDownfall, byteArray() ));
+ return std::make_shared<GameCommandPacket>(eGameCommand_ToggleDownfall, byteArray());
} \ No newline at end of file
diff --git a/Minecraft.World/ToolRecipies.cpp b/Minecraft.World/ToolRecipies.cpp
index 8ee4bbab..82b02df1 100644
--- a/Minecraft.World/ToolRecipies.cpp
+++ b/Minecraft.World/ToolRecipies.cpp
@@ -103,7 +103,7 @@ void ToolRecipies::addRecipes(Recipes *r)
}
}
}
- r->addShapedRecipy(new ItemInstance((Item *)Item::shears),
+ r->addShapedRecipy(new ItemInstance(static_cast<Item *>(Item::shears)),
L"sscig",
L" #", //
L"# ", //
diff --git a/Minecraft.World/TopSnowTile.cpp b/Minecraft.World/TopSnowTile.cpp
index 033b4eb2..7719f838 100644
--- a/Minecraft.World/TopSnowTile.cpp
+++ b/Minecraft.World/TopSnowTile.cpp
@@ -27,7 +27,7 @@ AABB *TopSnowTile::getAABB(Level *level, int x, int y, int z)
{
int height = level->getData(x, y, z) & HEIGHT_MASK;
float offset = 2.0f / SharedConstants::WORLD_RESOLUTION;
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + (height * offset), z + tls->zz1);
}
@@ -100,7 +100,7 @@ void TopSnowTile::playerDestroy(Level *level, shared_ptr<Player> player, int x,
{
int type = Item::snowBall->id;
int height = data & HEIGHT_MASK;
- popResource(level, x, y, z, shared_ptr<ItemInstance>( new ItemInstance(type, height + 1, 0)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(type, height + 1, 0));
level->removeTile(x, y, z);
}
diff --git a/Minecraft.World/TorchTile.cpp b/Minecraft.World/TorchTile.cpp
index cc377574..129a3b13 100644
--- a/Minecraft.World/TorchTile.cpp
+++ b/Minecraft.World/TorchTile.cpp
@@ -11,7 +11,7 @@ TorchTile::TorchTile(int id) : Tile(id, Material::decoration,isSolidRender())
AABB *TorchTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
AABB *TorchTile::getTileAABB(Level *level, int x, int y, int z)
diff --git a/Minecraft.World/TradeItemPacket.h b/Minecraft.World/TradeItemPacket.h
index ecd0f707..6a23ce7a 100644
--- a/Minecraft.World/TradeItemPacket.h
+++ b/Minecraft.World/TradeItemPacket.h
@@ -25,7 +25,7 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new TradeItemPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<TradeItemPacket>(); }
virtual int getId() { return 151; }
};
diff --git a/Minecraft.World/TradeWithPlayerGoal.cpp b/Minecraft.World/TradeWithPlayerGoal.cpp
index e8b791d1..155525bc 100644
--- a/Minecraft.World/TradeWithPlayerGoal.cpp
+++ b/Minecraft.World/TradeWithPlayerGoal.cpp
@@ -19,7 +19,7 @@ bool TradeWithPlayerGoal::canUse()
if (mob->hurtMarked) return false;
shared_ptr<Player> trader = mob->getTradingPlayer();
- if (trader == NULL)
+ if (trader == nullptr)
{
// no interaction
return false;
diff --git a/Minecraft.World/TrapDoorTile.cpp b/Minecraft.World/TrapDoorTile.cpp
index 9b668e3f..6ea64172 100644
--- a/Minecraft.World/TrapDoorTile.cpp
+++ b/Minecraft.World/TrapDoorTile.cpp
@@ -212,5 +212,5 @@ bool TrapDoorTile::attachesTo(int id)
}
Tile *tile = Tile::tiles[id];
- return tile != NULL && (tile->material->isSolidBlocking() && tile->isCubeShaped()) || tile == Tile::glowstone || (dynamic_cast<HalfSlabTile *>(tile) != NULL) || (dynamic_cast<StairTile *>(tile) != NULL);
+ return tile != nullptr && (tile->material->isSolidBlocking() && tile->isCubeShaped()) || tile == Tile::glowstone || (dynamic_cast<HalfSlabTile *>(tile) != nullptr) || (dynamic_cast<StairTile *>(tile) != nullptr);
} \ No newline at end of file
diff --git a/Minecraft.World/TrapMenu.cpp b/Minecraft.World/TrapMenu.cpp
index 65757839..a89069c7 100644
--- a/Minecraft.World/TrapMenu.cpp
+++ b/Minecraft.World/TrapMenu.cpp
@@ -40,7 +40,7 @@ shared_ptr<ItemInstance> TrapMenu::quickMoveStack(shared_ptr<Player> player, int
{
shared_ptr<ItemInstance> clicked = nullptr;
Slot *slot = slots.at(slotIndex);
- if (slot != NULL && slot->hasItem())
+ if (slot != nullptr && slot->hasItem())
{
shared_ptr<ItemInstance> stack = slot->getItem();
clicked = stack->copy();
diff --git a/Minecraft.World/TreeFeature.cpp b/Minecraft.World/TreeFeature.cpp
index f27258af..2bfec147 100644
--- a/Minecraft.World/TreeFeature.cpp
+++ b/Minecraft.World/TreeFeature.cpp
@@ -19,7 +19,7 @@ bool TreeFeature::place(Level *level, Random *random, int x, int y, int z)
if (y < 1 || y + treeHeight + 1 > Level::maxBuildHeight) return false;
// 4J Stu Added to stop tree features generating areas previously place by game rule generation
- if(app.getLevelGenerationOptions() != NULL)
+ if(app.getLevelGenerationOptions() != nullptr)
{
PIXBeginNamedEvent(0,"TreeFeature checking intersects");
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
diff --git a/Minecraft.World/TreeTile.cpp b/Minecraft.World/TreeTile.cpp
index 642d8fbb..6a5860f3 100644
--- a/Minecraft.World/TreeTile.cpp
+++ b/Minecraft.World/TreeTile.cpp
@@ -81,7 +81,7 @@ int TreeTile::getWoodType(int data)
shared_ptr<ItemInstance> TreeTile::getSilkTouchItemInstance(int data)
{
// fix to avoid getting silktouched sideways logs
- return shared_ptr<ItemInstance>(new ItemInstance(id, 1, getWoodType(data)));
+ return std::make_shared<ItemInstance>(id, 1, getWoodType(data));
}
void TreeTile::registerIcons(IconRegister *iconRegister)
diff --git a/Minecraft.World/TripWireSourceTile.cpp b/Minecraft.World/TripWireSourceTile.cpp
index c9271334..fcd7564d 100644
--- a/Minecraft.World/TripWireSourceTile.cpp
+++ b/Minecraft.World/TripWireSourceTile.cpp
@@ -12,7 +12,7 @@ TripWireSourceTile::TripWireSourceTile(int id) : Tile(id, Material::decoration,
AABB *TripWireSourceTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
bool TripWireSourceTile::blocksLight()
diff --git a/Minecraft.World/TripWireTile.cpp b/Minecraft.World/TripWireTile.cpp
index b8ae9f33..ee302af2 100644
--- a/Minecraft.World/TripWireTile.cpp
+++ b/Minecraft.World/TripWireTile.cpp
@@ -20,7 +20,7 @@ int TripWireTile::getTickDelay(Level *level)
AABB *TripWireTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
bool TripWireTile::blocksLight()
@@ -106,7 +106,7 @@ void TripWireTile::playerWillDestroy(Level *level, int x, int y, int z, int data
{
if (level->isClientSide) return;
- if (player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears_Id)
+ if (player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears_Id)
{
level->setData(x, y, z, data | MASK_DISARMED, Tile::UPDATE_NONE);
}
@@ -165,7 +165,7 @@ void TripWireTile::checkPressed(Level *level, int x, int y, int z)
bool wasPressed = (data & MASK_POWERED) == MASK_POWERED;
bool shouldBePressed = false;
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
vector<shared_ptr<Entity> > *entities = level->getEntities(nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1));
if (!entities->empty())
{
diff --git a/Minecraft.World/UpdateAttributesPacket.h b/Minecraft.World/UpdateAttributesPacket.h
index 77ba08be..4f604e0d 100644
--- a/Minecraft.World/UpdateAttributesPacket.h
+++ b/Minecraft.World/UpdateAttributesPacket.h
@@ -41,6 +41,6 @@ public:
unordered_set<AttributeSnapshot *> getValues();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new UpdateAttributesPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<UpdateAttributesPacket>(); }
virtual int getId() { return 44; }
}; \ No newline at end of file
diff --git a/Minecraft.World/UpdateGameRuleProgressPacket.cpp b/Minecraft.World/UpdateGameRuleProgressPacket.cpp
index 9459ed2b..d8856011 100644
--- a/Minecraft.World/UpdateGameRuleProgressPacket.cpp
+++ b/Minecraft.World/UpdateGameRuleProgressPacket.cpp
@@ -5,13 +5,9 @@
-UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket()
+// UpdateGameRuleProgressPacket() default constructor
+UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket() : m_icon(0), m_auxValue(0), m_dataTag(0)
{
- m_messageId = L"";
- m_icon = -1;
- m_auxValue = 0;
- m_definitionType = ConsoleGameRules::eGameRuleType_LevelRules;
- m_dataTag = 0;
}
UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket(ConsoleGameRules::EGameRuleType definitionType, const wstring &messageId, int icon, int auxValue, int dataTag, void *data, int dataLength)
@@ -35,7 +31,7 @@ UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket(ConsoleGameRules::EGa
void UpdateGameRuleProgressPacket::read(DataInputStream *dis) //throws IOException
{
- m_definitionType = (ConsoleGameRules::EGameRuleType)dis->readInt();
+ m_definitionType = static_cast<ConsoleGameRules::EGameRuleType>(dis->readInt());
m_messageId = readUtf(dis,64);
m_icon = dis->readInt();
m_auxValue = dis->readByte();
@@ -71,5 +67,5 @@ void UpdateGameRuleProgressPacket::handle(PacketListener *listener)
int UpdateGameRuleProgressPacket::getEstimatedSize()
{
- return (int)m_messageId.length() + 4 + m_data.length;
+ return static_cast<int>(m_messageId.length()) + 4 + m_data.length;
} \ No newline at end of file
diff --git a/Minecraft.World/UpdateMobEffectPacket.cpp b/Minecraft.World/UpdateMobEffectPacket.cpp
index e2f6233e..e8879d76 100644
--- a/Minecraft.World/UpdateMobEffectPacket.cpp
+++ b/Minecraft.World/UpdateMobEffectPacket.cpp
@@ -19,8 +19,8 @@ UpdateMobEffectPacket::UpdateMobEffectPacket()
UpdateMobEffectPacket::UpdateMobEffectPacket(int entityId, MobEffectInstance *effect)
{
this->entityId = entityId;
- effectId = (BYTE) (effect->getId() & 0xff);
- effectAmplifier = (char) (effect->getAmplifier() & 0xff);
+ effectId = static_cast<BYTE>(effect->getId() & 0xff);
+ effectAmplifier = static_cast<char>(effect->getAmplifier() & 0xff);
if (effect->getDuration() > Short::MAX_VALUE)
{
@@ -28,7 +28,7 @@ UpdateMobEffectPacket::UpdateMobEffectPacket(int entityId, MobEffectInstance *ef
}
else
{
- effectDurationTicks = (short) effect->getDuration();
+ effectDurationTicks = static_cast<short>(effect->getDuration());
}
}
diff --git a/Minecraft.World/UpdateMobEffectPacket.h b/Minecraft.World/UpdateMobEffectPacket.h
index 39eb98e9..48462550 100644
--- a/Minecraft.World/UpdateMobEffectPacket.h
+++ b/Minecraft.World/UpdateMobEffectPacket.h
@@ -24,6 +24,6 @@ public:
virtual bool isInvalidatedBy(shared_ptr<Packet> packet);
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new UpdateMobEffectPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<UpdateMobEffectPacket>(); }
virtual int getId() { return 41; }
}; \ No newline at end of file
diff --git a/Minecraft.World/UpdateProgressPacket.h b/Minecraft.World/UpdateProgressPacket.h
index beca6509..1643fb63 100644
--- a/Minecraft.World/UpdateProgressPacket.h
+++ b/Minecraft.World/UpdateProgressPacket.h
@@ -20,6 +20,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new UpdateProgressPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<UpdateProgressPacket>(); }
virtual int getId() { return 156; }
}; \ No newline at end of file
diff --git a/Minecraft.World/UseItemPacket.cpp b/Minecraft.World/UseItemPacket.cpp
index 55e44342..f8a5dac8 100644
--- a/Minecraft.World/UseItemPacket.cpp
+++ b/Minecraft.World/UseItemPacket.cpp
@@ -56,9 +56,9 @@ void UseItemPacket::write(DataOutputStream *dos) //throws IOException
dos->write(face);
writeItem(item, dos);
- dos->write((int) (clickX * CLICK_ACCURACY));
- dos->write((int) (clickY * CLICK_ACCURACY));
- dos->write((int) (clickZ * CLICK_ACCURACY));
+ dos->write(static_cast<int>(clickX * CLICK_ACCURACY));
+ dos->write(static_cast<int>(clickY * CLICK_ACCURACY));
+ dos->write(static_cast<int>(clickZ * CLICK_ACCURACY));
}
void UseItemPacket::handle(PacketListener *listener)
diff --git a/Minecraft.World/UseItemPacket.h b/Minecraft.World/UseItemPacket.h
index 44e20457..ce4635ba 100644
--- a/Minecraft.World/UseItemPacket.h
+++ b/Minecraft.World/UseItemPacket.h
@@ -31,6 +31,6 @@ public:
float getClickZ();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new UseItemPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<UseItemPacket>(); }
virtual int getId() { return 15; }
};
diff --git a/Minecraft.World/Vec3.cpp b/Minecraft.World/Vec3.cpp
index 1fc26fd5..b513c149 100644
--- a/Minecraft.World/Vec3.cpp
+++ b/Minecraft.World/Vec3.cpp
@@ -3,7 +3,7 @@
#include "AABB.h"
DWORD Vec3::tlsIdx = 0;
-Vec3::ThreadStorage *Vec3::tlsDefault = NULL;
+Vec3::ThreadStorage *Vec3::tlsDefault = nullptr;
Vec3::ThreadStorage::ThreadStorage()
{
@@ -19,7 +19,7 @@ Vec3::ThreadStorage::~ThreadStorage()
void Vec3::CreateNewThreadStorage()
{
ThreadStorage *tls = new ThreadStorage();
- if(tlsDefault == NULL )
+ if(tlsDefault == nullptr )
{
tlsIdx = TlsAlloc();
tlsDefault = tls;
@@ -34,7 +34,7 @@ void Vec3::UseDefaultThreadStorage()
void Vec3::ReleaseThreadStorage()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
if( tls == tlsDefault ) return;
delete tls;
@@ -55,7 +55,7 @@ void Vec3::resetPool()
Vec3 *Vec3::newTemp(double x, double y, double z)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
Vec3 *thisVec = &tls->pool[tls->poolPointer];
thisVec->set(x, y, z);
tls->poolPointer = ( tls->poolPointer + 1 ) % ThreadStorage::POOL_SIZE;
@@ -157,10 +157,10 @@ Vec3 *Vec3::clipX(Vec3 *b, double xt)
double yd = b->y - y;
double zd = b->z - z;
- if (xd * xd < 0.0000001f) return NULL;
+ if (xd * xd < 0.0000001f) return nullptr;
double d = (xt - x) / xd;
- if (d < 0 || d > 1) return NULL;
+ if (d < 0 || d > 1) return nullptr;
return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d);
}
@@ -170,10 +170,10 @@ Vec3 *Vec3::clipY(Vec3 *b, double yt)
double yd = b->y - y;
double zd = b->z - z;
- if (yd * yd < 0.0000001f) return NULL;
+ if (yd * yd < 0.0000001f) return nullptr;
double d = (yt - y) / yd;
- if (d < 0 || d > 1) return NULL;
+ if (d < 0 || d > 1) return nullptr;
return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d);
}
@@ -183,10 +183,10 @@ Vec3 *Vec3::clipZ(Vec3 *b, double zt)
double yd = b->y - y;
double zd = b->z - z;
- if (zd * zd < 0.0000001f) return NULL;
+ if (zd * zd < 0.0000001f) return nullptr;
double d = (zt - z) / zd;
- if (d < 0 || d > 1) return NULL;
+ if (d < 0 || d > 1) return nullptr;
return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d);
}
diff --git a/Minecraft.World/Village.cpp b/Minecraft.World/Village.cpp
index a72319fe..b7c82fa4 100644
--- a/Minecraft.World/Village.cpp
+++ b/Minecraft.World/Village.cpp
@@ -25,7 +25,7 @@ Village::Village()
golemCount = 0;
noBreedTimer = 0;
- level = NULL;
+ level = nullptr;
}
Village::Village(Level *level)
@@ -69,9 +69,9 @@ void Village::tick(int tick)
if (golemCount < idealGolemCount && doorInfos.size() > 20 && level->random->nextInt(7000) == 0)
{
Vec3 *spawnPos = findRandomSpawnPos(center->x, center->y, center->z, 2, 4, 2);
- if (spawnPos != NULL)
+ if (spawnPos != nullptr)
{
- shared_ptr<VillagerGolem> vg = shared_ptr<VillagerGolem>( new VillagerGolem(level) );
+ shared_ptr<VillagerGolem> vg = std::make_shared<VillagerGolem>(level);
vg->setPos(spawnPos->x, spawnPos->y, spawnPos->z);
level->addEntity(vg);
++golemCount;
@@ -103,7 +103,7 @@ Vec3 *Village::findRandomSpawnPos(int x, int y, int z, int sx, int sy, int sz)
if (!isInside(xx, yy, zz)) continue;
if (canSpawnAt(xx, yy, zz, sx, sy, sz)) return Vec3::newTemp(xx, yy, zz);
}
- return NULL;
+ return nullptr;
}
bool Village::canSpawnAt(int x, int y, int z, int sx, int sy, int sz)
@@ -215,7 +215,7 @@ shared_ptr<DoorInfo>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;
}
shared_ptr<DoorInfo> Village::getDoorInfo(int x, int y, int z)
@@ -260,7 +260,7 @@ void Village::addAggressor(shared_ptr<LivingEntity> mob)
shared_ptr<LivingEntity> Village::getClosestAggressor(shared_ptr<LivingEntity> from)
{
double closestSqr = Double::MAX_VALUE;
- Aggressor *closest = NULL;
+ Aggressor *closest = nullptr;
for(auto& a : aggressors)
{
double distSqr = a->mob->distanceToSqr(from);
@@ -268,7 +268,7 @@ shared_ptr<LivingEntity> Village::getClosestAggressor(shared_ptr<LivingEntity> f
closest = a;
closestSqr = distSqr;
}
- return closest != NULL ? closest->mob : nullptr;
+ return closest != nullptr ? closest->mob : nullptr;
}
shared_ptr<Player> Village::getClosestBadStandingPlayer(shared_ptr<LivingEntity> from)
@@ -282,7 +282,7 @@ shared_ptr<Player> Village::getClosestBadStandingPlayer(shared_ptr<LivingEntity>
if (isVeryBadStanding(player))
{
shared_ptr<Player> mob = level->getPlayerByName(player);
- if (mob != NULL)
+ if (mob != nullptr)
{
double distSqr = mob->distanceToSqr(from);
if (distSqr > closestSqr) continue;
@@ -422,7 +422,7 @@ void Village::readAdditionalSaveData(CompoundTag *tag)
{
CompoundTag *dTag = doorTags->get(i);
- shared_ptr<DoorInfo> door = shared_ptr<DoorInfo>(new DoorInfo(dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"), dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS")));
+ shared_ptr<DoorInfo> door = std::make_shared<DoorInfo>(dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"), dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS"));
doorInfos.push_back(door);
}
diff --git a/Minecraft.World/VillageFeature.cpp b/Minecraft.World/VillageFeature.cpp
index 5249256c..bde8a66c 100644
--- a/Minecraft.World/VillageFeature.cpp
+++ b/Minecraft.World/VillageFeature.cpp
@@ -82,7 +82,7 @@ bool VillageFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
bool forcePlacement = false;
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
- if( levelGenOptions != NULL )
+ if( levelGenOptions != nullptr )
{
forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Village);
}
@@ -134,7 +134,7 @@ VillageFeature::VillageStart::VillageStart(Level *level, Random *random, int chu
// prioritize roads
if (pendingRoads->empty())
{
- int pos = random->nextInt((int)pendingHouses->size());
+ int pos = random->nextInt(static_cast<int>(pendingHouses->size()));
auto it = pendingHouses->begin() + pos;
StructurePiece *structurePiece = *it;
pendingHouses->erase(it);
@@ -142,7 +142,7 @@ VillageFeature::VillageStart::VillageStart(Level *level, Random *random, int chu
}
else
{
- int pos = random->nextInt((int)pendingRoads->size());
+ int pos = random->nextInt(static_cast<int>(pendingRoads->size()));
auto it = pendingRoads->begin() + pos;
StructurePiece *structurePiece = *it;
pendingRoads->erase(it);
diff --git a/Minecraft.World/VillagePieces.cpp b/Minecraft.World/VillagePieces.cpp
index 1737d6e0..dcd765e0 100644
--- a/Minecraft.World/VillagePieces.cpp
+++ b/Minecraft.World/VillagePieces.cpp
@@ -101,7 +101,7 @@ int VillagePieces::updatePieceWeight(list<PieceWeight *> *currentPieces)
VillagePieces::VillagePiece *VillagePieces::findAndCreatePieceFactory(StartPiece *startPiece, VillagePieces::PieceWeight *piece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth)
{
VillagePieces::EPieceClass pieceClass = piece->pieceClass;
- VillagePiece *villagePiece = NULL;
+ VillagePiece *villagePiece = nullptr;
if (pieceClass == VillagePieces::EPieceClass_SimpleHouse)
{
@@ -148,7 +148,7 @@ VillagePieces::VillagePiece *VillagePieces::generatePieceFromSmallDoor(StartPiec
int totalWeight = updatePieceWeight(startPiece->pieceSet);
if (totalWeight <= 0)
{
- return NULL;
+ return nullptr;
}
int numAttempts = 0;
@@ -168,7 +168,7 @@ VillagePieces::VillagePiece *VillagePieces::generatePieceFromSmallDoor(StartPiec
}
VillagePiece *villagePiece = findAndCreatePieceFactory(startPiece, piece, pieces, random, footX, footY, footZ, direction, depth);
- if (villagePiece != NULL)
+ if (villagePiece != nullptr)
{
piece->placeCount++;
startPiece->previousPiece = piece;
@@ -186,29 +186,29 @@ VillagePieces::VillagePiece *VillagePieces::generatePieceFromSmallDoor(StartPiec
// attempt to place a light post instead
{
BoundingBox *box = LightPost::findPieceBox(startPiece, pieces, random, footX, footY, footZ, direction);
- if (box != NULL)
+ if (box != nullptr)
{
return new LightPost(startPiece, depth, random, box, direction);
}
delete box;
}
- return NULL;
+ return nullptr;
}
StructurePiece *VillagePieces::generateAndAddPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth)
{
if (depth > MAX_DEPTH)
{
- return NULL;
+ return nullptr;
}
if (abs(footX - startPiece->getBoundingBox()->x0) > 7 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 7 * 16)
{
- return NULL;
+ return nullptr;
}
StructurePiece *newPiece = generatePieceFromSmallDoor(startPiece, pieces, random, footX, footY, footZ, direction, depth + 1);
- if (newPiece != NULL)
+ if (newPiece != nullptr)
{
int x = (newPiece->boundingBox->x0 + newPiece->boundingBox->x1) / 2;
int z = (newPiece->boundingBox->z0 + newPiece->boundingBox->z1) / 2;
@@ -223,22 +223,22 @@ StructurePiece *VillagePieces::generateAndAddPiece(StartPiece *startPiece, list<
}
delete newPiece;
}
- return NULL;
+ return nullptr;
}
StructurePiece *VillagePieces::generateAndAddRoadPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth)
{
if (depth > BASE_ROAD_DEPTH + startPiece->villageSize)
{
- return NULL;
+ return nullptr;
}
if (abs(footX - startPiece->getBoundingBox()->x0) > 7 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 7 * 16)
{
- return NULL;
+ return nullptr;
}
BoundingBox *box = StraightRoad::findPieceBox(startPiece, pieces, random, footX, footY, footZ, direction);
- if (box != NULL && box->y0 > LOWEST_Y_POSITION)
+ if (box != nullptr && box->y0 > LOWEST_Y_POSITION)
{
StructurePiece *newPiece = new StraightRoad(startPiece, depth, random, box, direction);
int x = (newPiece->boundingBox->x0 + newPiece->boundingBox->x1) / 2;
@@ -255,12 +255,12 @@ StructurePiece *VillagePieces::generateAndAddRoadPiece(StartPiece *startPiece, l
// 4J Stu - The dtor for newPiece will destroy box
delete newPiece;
}
- else if(box != NULL)
+ else if(box != nullptr)
{
delete box;
}
- return NULL;
+ return nullptr;
}
VillagePieces::VillagePiece::VillagePiece()
@@ -268,7 +268,7 @@ VillagePieces::VillagePiece::VillagePiece()
heightPosition = -1;
spawnedVillagerCount = 0;
isDesertVillage = false;
- startPiece = NULL;
+ startPiece = nullptr;
// for reflection
}
@@ -278,7 +278,7 @@ VillagePieces::VillagePiece::VillagePiece(StartPiece *startPiece, int genDepth)
isDesertVillage = false;
spawnedVillagerCount = 0;
this->startPiece = startPiece;
- if (startPiece != NULL)
+ if (startPiece != nullptr)
{
this->isDesertVillage = startPiece->isDesertVillage;
}
@@ -311,7 +311,7 @@ StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernLeft(StartPiec
case Direction::EAST:
return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth());
}
- return NULL;
+ return nullptr;
}
StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernRight(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff)
@@ -327,7 +327,7 @@ StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernRight(StartPie
case Direction::EAST:
return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth());
}
- return NULL;
+ return nullptr;
}
int VillagePieces::VillagePiece::getAverageGroundHeight(Level *level, BoundingBox *chunkBB)
@@ -357,7 +357,7 @@ bool VillagePieces::VillagePiece::isOkBox(BoundingBox *box, StartPiece *startRoo
{
bool bIsOk = false;
- if(box != NULL)
+ if(box != nullptr)
{
if( box->y0 > LOWEST_Y_POSITION ) bIsOk = true;
@@ -391,7 +391,7 @@ void VillagePieces::VillagePiece::spawnVillagers(Level *level, BoundingBox *chun
{
spawnedVillagerCount++;
- shared_ptr<Villager> villager = shared_ptr<Villager>(new Villager(level, getVillagerProfession(i)));
+ shared_ptr<Villager> villager = std::make_shared<Villager>(level, getVillagerProfession(i));
villager->moveTo(worldX + 0.5, worldY, worldZ + 0.5, 0, 0);
level->addEntity(villager);
}
@@ -512,10 +512,10 @@ VillagePieces::Well::Well(StartPiece *startPiece, int genDepth, Random *random,
void VillagePieces::Well::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random)
{
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::WEST, getGenDepth());
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::EAST, getGenDepth());
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z0 - 1, Direction::NORTH, getGenDepth());
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 - 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::WEST, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 + 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::EAST, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z0 - 1, Direction::NORTH, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth());
}
bool VillagePieces::Well::postProcess(Level *level, Random *random, BoundingBox *chunkBB)
@@ -569,10 +569,10 @@ VillagePieces::StartPiece::StartPiece()
// for reflection
}
-VillagePieces::StartPiece::StartPiece(BiomeSource *biomeSource, int genDepth, Random *random, int west, int north, list<PieceWeight *> *pieceSet, int villageSize, Level *level) : Well(NULL, 0, random, west, north)
+VillagePieces::StartPiece::StartPiece(BiomeSource *biomeSource, int genDepth, Random *random, int west, int north, list<PieceWeight *> *pieceSet, int villageSize, Level *level) : Well(nullptr, 0, random, west, north)
{
isLibraryAdded = false; // 4J - added initialiser
- previousPiece = NULL; // 4J - added initialiser
+ previousPiece = nullptr; // 4J - added initialiser
this->biomeSource = biomeSource;
this->pieceSet = pieceSet;
this->villageSize = villageSize;
@@ -628,8 +628,8 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list<S
int depth = random->nextInt(5);
while (depth < length - 8)
{
- StructurePiece *piece = generateHouseNorthernLeft((StartPiece *) startPiece, pieces, random, 0, depth);
- if (piece != NULL)
+ StructurePiece *piece = generateHouseNorthernLeft(static_cast<StartPiece *>(startPiece), pieces, random, 0, depth);
+ if (piece != nullptr)
{
depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan());
hasHouses = true;
@@ -641,8 +641,8 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list<S
depth = random->nextInt(5);
while (depth < length - 8)
{
- StructurePiece *piece = generateHouseNorthernRight((StartPiece *) startPiece, pieces, random, 0, depth);
- if (piece != NULL)
+ StructurePiece *piece = generateHouseNorthernRight(static_cast<StartPiece *>(startPiece), pieces, random, 0, depth);
+ if (piece != nullptr)
{
depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan());
hasHouses = true;
@@ -655,16 +655,16 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list<S
switch (orientation)
{
case Direction::NORTH:
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z0, Direction::WEST, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z0, Direction::WEST, getGenDepth());
break;
case Direction::SOUTH:
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z1 - 2, Direction::WEST, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z1 - 2, Direction::WEST, getGenDepth());
break;
case Direction::EAST:
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth());
break;
case Direction::WEST:
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth());
break;
}
}
@@ -673,16 +673,16 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list<S
switch (orientation)
{
case Direction::NORTH:
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z0, Direction::EAST, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z0, Direction::EAST, getGenDepth());
break;
case Direction::SOUTH:
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z1 - 2, Direction::EAST, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z1 - 2, Direction::EAST, getGenDepth());
break;
case Direction::EAST:
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth());
break;
case Direction::WEST:
- generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth());
+ generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth());
break;
}
}
@@ -696,7 +696,7 @@ BoundingBox *VillagePieces::StraightRoad::findPieceBox(StartPiece *startPiece, l
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, 3, length, direction);
- if (isOkBox(box, startPiece) && StructurePiece::findCollisionPiece(pieces, box) == NULL)
+ if (isOkBox(box, startPiece) && StructurePiece::findCollisionPiece(pieces, box) == nullptr)
{
return box;
}
@@ -704,7 +704,7 @@ BoundingBox *VillagePieces::StraightRoad::findPieceBox(StartPiece *startPiece, l
length -= 7;
}
- return NULL;
+ return nullptr;
}
bool VillagePieces::StraightRoad::postProcess(Level *level, Random *random, BoundingBox *chunkBB)
@@ -753,10 +753,10 @@ VillagePieces::SimpleHouse *VillagePieces::SimpleHouse::createPiece(StartPiece *
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new SimpleHouse(startPiece, genDepth, random, box, direction);
@@ -880,10 +880,10 @@ VillagePieces::SmallTemple *VillagePieces::SmallTemple::createPiece(StartPiece *
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new SmallTemple(startPiece, genDepth, random, box, direction);
@@ -1022,10 +1022,10 @@ VillagePieces::BookHouse *VillagePieces::BookHouse::createPiece(StartPiece *star
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new BookHouse(startPiece, genDepth, random, box, direction);
@@ -1178,10 +1178,10 @@ VillagePieces::SmallHut *VillagePieces::SmallHut::createPiece(StartPiece *startP
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new SmallHut(startPiece, genDepth, random, box, direction);
@@ -1284,10 +1284,10 @@ VillagePieces::PigHouse *VillagePieces::PigHouse::createPiece(StartPiece *startP
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new PigHouse(startPiece, genDepth, random, box, direction);
@@ -1429,10 +1429,10 @@ VillagePieces::TwoRoomHouse *VillagePieces::TwoRoomHouse::createPiece(StartPiece
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new TwoRoomHouse(startPiece, genDepth, random, box, direction);
@@ -1619,10 +1619,10 @@ VillagePieces::Smithy *VillagePieces::Smithy::createPiece(StartPiece *startPiece
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new Smithy(startPiece, genDepth, random, box, direction);
@@ -1790,10 +1790,10 @@ VillagePieces::Farmland *VillagePieces::Farmland::createPiece(StartPiece *startP
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new Farmland(startPiece, genDepth, random, box, direction);
@@ -1902,10 +1902,10 @@ VillagePieces::DoubleFarmland *VillagePieces::DoubleFarmland::createPiece(StartP
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return new DoubleFarmland(startPiece, genDepth, random, box, direction);
@@ -1983,10 +1983,10 @@ BoundingBox *VillagePieces::LightPost::findPieceBox(StartPiece *startPiece, list
{
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction);
- if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
+ if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr)
{
delete box;
- return NULL;
+ return nullptr;
}
return box;
diff --git a/Minecraft.World/VillageSiege.cpp b/Minecraft.World/VillageSiege.cpp
index e3d20ef3..5a39b6eb 100644
--- a/Minecraft.World/VillageSiege.cpp
+++ b/Minecraft.World/VillageSiege.cpp
@@ -80,10 +80,10 @@ bool VillageSiege::tryToSetupSiege()
vector<shared_ptr<Player> > *players = &level->players;
for(auto& player : *players)
{
- shared_ptr<Village> _village = level->villages->getClosestVillage((int) player->x, (int) player->y, (int) player->z, 1);
+ shared_ptr<Village> _village = level->villages->getClosestVillage(static_cast<int>(player->x), static_cast<int>(player->y), static_cast<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;
@@ -95,9 +95,9 @@ bool VillageSiege::tryToSetupSiege()
bool overlaps = false;
for (int i = 0; i < 10; ++i)
{
- spawnX = center->x + (int) (Mth::cos(level->random->nextFloat() * PI * 2.f) * radius * 0.9);
+ spawnX = center->x + static_cast<int>(Mth::cos(level->random->nextFloat() * PI * 2.f) * radius * 0.9);
spawnY = center->y;
- spawnZ = center->z + (int) (Mth::sin(level->random->nextFloat() * PI * 2.f) * radius * 0.9);
+ spawnZ = center->z + static_cast<int>(Mth::sin(level->random->nextFloat() * PI * 2.f) * radius * 0.9);
overlaps = false;
vector<shared_ptr<Village> > *villages = level->villages->getVillages();
//for (Village v : level.villages.getVillages())
@@ -115,7 +115,7 @@ bool VillageSiege::tryToSetupSiege()
if (overlaps) return false;
Vec3 *spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ);
- if (spawnPos == NULL) continue;
+ if (spawnPos == nullptr) continue;
nextSpawnTime = 0;
siegeCount = 20;
@@ -127,17 +127,17 @@ bool VillageSiege::tryToSetupSiege()
bool VillageSiege::trySpawn()
{
Vec3 *spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ);
- if (spawnPos == NULL) return false;
+ if (spawnPos == nullptr) return false;
shared_ptr<Zombie> mob;
{
- mob = shared_ptr<Zombie>( new Zombie(level) );
- mob->finalizeMobSpawn(NULL);
+ mob = std::make_shared<Zombie>(level);
+ mob->finalizeMobSpawn(nullptr);
mob->setVillager(false);
}
mob->moveTo(spawnPos->x, spawnPos->y, spawnPos->z, level->random->nextFloat() * 360, 0);
level->addEntity(mob);
shared_ptr<Village> _village = village.lock();
- if( _village == NULL ) return false;
+ if( _village == nullptr ) return false;
Pos *center = _village->getCenter();
mob->restrictTo(center->x, center->y, center->z, _village->getRadius());
@@ -147,7 +147,7 @@ bool VillageSiege::trySpawn()
Vec3 *VillageSiege::findRandomSpawnPos(int x, int y, int z)
{
shared_ptr<Village> _village = village.lock();
- if( _village == NULL ) return NULL;
+ if( _village == nullptr ) return nullptr;
for (int i = 0; i < 10; ++i)
{
@@ -157,5 +157,5 @@ Vec3 *VillageSiege::findRandomSpawnPos(int x, int y, int z)
if (!_village->isInside(xx, yy, zz)) continue;
if (MobSpawner::isSpawnPositionOk(MobCategory::monster, level, xx, yy, zz)) return Vec3::newTemp(xx, yy, zz);
}
- return NULL;
+ return nullptr;
} \ No newline at end of file
diff --git a/Minecraft.World/Villager.cpp b/Minecraft.World/Villager.cpp
index 19303b0d..4e57affe 100644
--- a/Minecraft.World/Villager.cpp
+++ b/Minecraft.World/Villager.cpp
@@ -38,7 +38,7 @@ void Villager::_init(int profession)
village = weak_ptr<Village>();
tradingPlayer = weak_ptr<Player>();
- offers = NULL;
+ offers = nullptr;
updateMerchantTimer = 0;
addRecipeOnUpdate = false;
riches = 0;
@@ -102,11 +102,11 @@ void Villager::serverAiMobStep()
shared_ptr<Village> _village = level->villages->getClosestVillage(Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist);
village = _village;
- if (_village == NULL) clearRestriction();
+ if (_village == nullptr) clearRestriction();
else
{
Pos *center = _village->getCenter();
- restrictTo(center->x, center->y, center->z, (int)((float)_village->getRadius() * 0.6f));
+ restrictTo(center->x, center->y, center->z, static_cast<int>((float)_village->getRadius() * 0.6f));
if (rewardPlayersOnFirstVillage)
{
rewardPlayersOnFirstVillage = false;
@@ -137,7 +137,7 @@ void Villager::serverAiMobStep()
addOffers(1);
addRecipeOnUpdate = false;
- if (village.lock() != NULL && !lastPlayerTradeName.empty())
+ if (village.lock() != nullptr && !lastPlayerTradeName.empty())
{
level->broadcastEntityEvent(shared_from_this(), EntityEvent::VILLAGER_HAPPY);
village.lock()->modifyStanding(lastPlayerTradeName, 1);
@@ -154,7 +154,7 @@ bool Villager::mobInteract(shared_ptr<Player> player)
{
// [EB]: Truly dislike this code but I don't see another easy way
shared_ptr<ItemInstance> item = player->inventory->getSelected();
- bool holdingSpawnEgg = item != NULL && item->id == Item::spawnEgg_Id;
+ bool holdingSpawnEgg = item != nullptr && item->id == Item::spawnEgg_Id;
if (!holdingSpawnEgg && isAlive() && !isTrading() && !isBaby())
{
@@ -182,7 +182,7 @@ void Villager::addAdditonalSaveData(CompoundTag *tag)
AgableMob::addAdditonalSaveData(tag);
tag->putInt(L"Profession", getProfession());
tag->putInt(L"Riches", riches);
- if (offers != NULL)
+ if (offers != nullptr)
{
tag->putCompound(L"Offers", offers->createTag());
}
@@ -259,7 +259,7 @@ void Villager::setLastHurtByMob(shared_ptr<LivingEntity> mob)
{
AgableMob::setLastHurtByMob(mob);
shared_ptr<Village> _village = village.lock();
- if (_village != NULL && mob != NULL)
+ if (_village != nullptr && mob != nullptr)
{
_village->addAggressor(mob);
@@ -282,10 +282,10 @@ void Villager::setLastHurtByMob(shared_ptr<LivingEntity> mob)
void Villager::die(DamageSource *source)
{
shared_ptr<Village> _village = village.lock();
- if (_village != NULL)
+ if (_village != nullptr)
{
shared_ptr<Entity> sourceEntity = source->getEntity();
- if (sourceEntity != NULL)
+ if (sourceEntity != nullptr)
{
if ( sourceEntity->instanceof(eTYPE_PLAYER) )
{
@@ -296,12 +296,12 @@ void Villager::die(DamageSource *source)
_village->resetNoBreedTimer();
}
}
- else if (sourceEntity == NULL)
+ else if (sourceEntity == nullptr)
{
// if the villager was killed by the world (such as lava or falling), blame
// the nearest player by not reproducing for a while
shared_ptr<Player> nearestPlayer = level->getNearestPlayer(shared_from_this(), 16.0f);
- if (nearestPlayer != NULL)
+ if (nearestPlayer != nullptr)
{
_village->resetNoBreedTimer();
}
@@ -335,7 +335,7 @@ shared_ptr<Player> Villager::getTradingPlayer()
bool Villager::isTrading()
{
- return tradingPlayer.lock() != NULL;
+ return tradingPlayer.lock() != nullptr;
}
void Villager::notifyTrade(MerchantRecipe *activeRecipe)
@@ -349,7 +349,7 @@ void Villager::notifyTrade(MerchantRecipe *activeRecipe)
{
updateMerchantTimer = SharedConstants::TICKS_PER_SECOND * 2;
addRecipeOnUpdate = true;
- if (tradingPlayer.lock() != NULL)
+ if (tradingPlayer.lock() != nullptr)
{
lastPlayerTradeName = tradingPlayer.lock()->getName();
}
@@ -370,7 +370,7 @@ void Villager::notifyTradeUpdated(shared_ptr<ItemInstance> item)
if (!level->isClientSide && (ambientSoundTime > (-getAmbientSoundInterval() + SharedConstants::TICKS_PER_SECOND)))
{
ambientSoundTime = -getAmbientSoundInterval();
- if (item != NULL)
+ if (item != nullptr)
{
playSound(eSoundType_MOB_VILLAGER_YES, getSoundVolume(), getVoicePitch());
}
@@ -383,7 +383,7 @@ void Villager::notifyTradeUpdated(shared_ptr<ItemInstance> item)
MerchantRecipeList *Villager::getOffers(shared_ptr<Player> forPlayer)
{
- if (offers == NULL)
+ if (offers == nullptr)
{
addOffers(1);
}
@@ -420,7 +420,7 @@ void Villager::addOffers(int addCount)
addItemForPurchase(newOffers, Item::arrow_Id, random, getRecipeChance(.5f));
if (random->nextFloat() < getRecipeChance(.5f))
{
- newOffers->push_back(new MerchantRecipe(shared_ptr<ItemInstance>( new ItemInstance(Tile::gravel, 10) ), shared_ptr<ItemInstance>( new ItemInstance(Item::emerald) ), shared_ptr<ItemInstance>( new ItemInstance(Item::flint_Id, 4 + random->nextInt(2), 0))));
+ newOffers->push_back(new MerchantRecipe(std::make_shared<ItemInstance>(Tile::gravel, 10), std::make_shared<ItemInstance>(Item::emerald), std::make_shared<ItemInstance>(Item::flint_Id, 4 + random->nextInt(2), 0)));
}
break;
case PROFESSION_BUTCHER:
@@ -480,7 +480,7 @@ void Villager::addOffers(int addCount)
shared_ptr<ItemInstance> book = Item::enchantedBook->createForEnchantment(new EnchantmentInstance(enchantment, level));
int cost = 2 + random->nextInt(5 + (level * 10)) + 3 * level;
- newOffers->push_back(new MerchantRecipe(shared_ptr<ItemInstance>(new ItemInstance(Item::book)), shared_ptr<ItemInstance>(new ItemInstance(Item::emerald, cost)), book));
+ newOffers->push_back(new MerchantRecipe(std::make_shared<ItemInstance>(Item::book), std::make_shared<ItemInstance>(Item::emerald, cost), book));
}
break;
case PROFESSION_PRIEST:
@@ -498,9 +498,9 @@ void Villager::addOffers(int addCount)
int id = enchantItems[i];
if (random->nextFloat() < getRecipeChance(.05f))
{
- newOffers->push_back(new MerchantRecipe(shared_ptr<ItemInstance>(new ItemInstance(id, 1, 0)),
- shared_ptr<ItemInstance>(new ItemInstance(Item::emerald, 2 + random->nextInt(3), 0)),
- EnchantmentHelper::enchantItem(random, shared_ptr<ItemInstance>(new ItemInstance(id, 1, 0)), 5 + random->nextInt(15))));
+ newOffers->push_back(new MerchantRecipe(std::make_shared<ItemInstance>(id, 1, 0),
+ std::make_shared<ItemInstance>(Item::emerald, 2 + random->nextInt(3), 0),
+ EnchantmentHelper::enchantItem(random, std::make_shared<ItemInstance>(id, 1, 0), 5 + random->nextInt(15))));
}
}
}
@@ -515,7 +515,7 @@ void Villager::addOffers(int addCount)
// shuffle the list to make it more interesting
std::shuffle(newOffers->begin(), newOffers->end(), std::mt19937{std::random_device{}()});
- if (offers == NULL)
+ if (offers == nullptr)
{
offers = new MerchantRecipeList();
}
@@ -622,7 +622,7 @@ void Villager::addItemForTradeIn(MerchantRecipeList *list, int itemId, Random *r
shared_ptr<ItemInstance> Villager::getItemTradeInValue(int itemId, Random *random)
{
- return shared_ptr<ItemInstance>(new ItemInstance(itemId, getTradeInValue(itemId, random), 0));
+ return std::make_shared<ItemInstance>(itemId, getTradeInValue(itemId, random), 0);
}
int Villager::getTradeInValue(int itemId, Random *random)
@@ -658,13 +658,13 @@ void Villager::addItemForPurchase(MerchantRecipeList *list, int itemId, Random *
shared_ptr<ItemInstance> resultItem;
if (purchaseCost < 0)
{
- rubyItem = shared_ptr<ItemInstance>( new ItemInstance(Item::emerald_Id, 1, 0) );
- resultItem = shared_ptr<ItemInstance>( new ItemInstance(itemId, -purchaseCost, 0) );
+ rubyItem = std::make_shared<ItemInstance>(Item::emerald_Id, 1, 0);
+ resultItem = std::make_shared<ItemInstance>(itemId, -purchaseCost, 0);
}
else
{
- rubyItem = shared_ptr<ItemInstance>( new ItemInstance(Item::emerald_Id, purchaseCost, 0) );
- resultItem = shared_ptr<ItemInstance>( new ItemInstance(itemId, 1, 0) );
+ rubyItem = std::make_shared<ItemInstance>(Item::emerald_Id, purchaseCost, 0);
+ resultItem = std::make_shared<ItemInstance>(itemId, 1, 0);
}
list->push_back(new MerchantRecipe(rubyItem, resultItem));
}
@@ -735,8 +735,8 @@ shared_ptr<AgableMob> Villager::getBreedOffspring(shared_ptr<AgableMob> target)
// 4J - added limit to villagers that can be bred
if(level->canCreateMore(GetType(), Level::eSpawnType_Breed) )
{
- shared_ptr<Villager> villager = shared_ptr<Villager>(new Villager(level));
- villager->finalizeMobSpawn(NULL);
+ shared_ptr<Villager> villager = std::make_shared<Villager>(level);
+ villager->finalizeMobSpawn(nullptr);
return villager;
}
else
diff --git a/Minecraft.World/VillagerGolem.cpp b/Minecraft.World/VillagerGolem.cpp
index dba80ffa..09508bfc 100644
--- a/Minecraft.World/VillagerGolem.cpp
+++ b/Minecraft.World/VillagerGolem.cpp
@@ -53,7 +53,7 @@ VillagerGolem::VillagerGolem(Level *level) : Golem(level)
void VillagerGolem::defineSynchedData()
{
Golem::defineSynchedData();
- entityData->define(DATA_FLAGS_ID, (byte) 0);
+ entityData->define(DATA_FLAGS_ID, static_cast<byte>(0));
}
bool VillagerGolem::useNewAi()
@@ -68,11 +68,11 @@ void VillagerGolem::serverAiMobStep()
villageUpdateInterval = 70 + random->nextInt(50);
shared_ptr<Village> _village = level->villages->getClosestVillage(Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist);
village = _village;
- if (_village == NULL) clearRestriction();
+ if (_village == nullptr) clearRestriction();
else
{
Pos *center = _village->getCenter();
- restrictTo(center->x, center->y, center->z, (int)((float)_village->getRadius()) * 0.6f);
+ restrictTo(center->x, center->y, center->z, static_cast<int>((float)_village->getRadius()) * 0.6f);
}
}
@@ -234,17 +234,17 @@ void VillagerGolem::setPlayerCreated(bool value)
byte current = entityData->getByte(DATA_FLAGS_ID);
if (value)
{
- entityData->set(DATA_FLAGS_ID, (byte) (current | 0x01));
+ entityData->set(DATA_FLAGS_ID, static_cast<byte>(current | 0x01));
}
else
{
- entityData->set(DATA_FLAGS_ID, (byte) (current & ~0x01));
+ entityData->set(DATA_FLAGS_ID, static_cast<byte>(current & ~0x01));
}
}
void VillagerGolem::die(DamageSource *source)
{
- if (!isPlayerCreated() && lastHurtByPlayer != NULL && village.lock() != NULL)
+ if (!isPlayerCreated() && lastHurtByPlayer != nullptr && village.lock() != nullptr)
{
village.lock()->modifyStanding(lastHurtByPlayer->getName(), -5);
}
@@ -257,7 +257,7 @@ bool VillagerGolem::hurt(DamageSource *source, float dmg)
if (isPlayerCreated())
{
shared_ptr<Entity> entity = source->getDirectEntity();
- if (entity != NULL && entity->instanceof(eTYPE_PLAYER))
+ if (entity != nullptr && entity->instanceof(eTYPE_PLAYER))
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(entity);
if (!player->isAllowedToAttackPlayers()) return false;
diff --git a/Minecraft.World/Villages.cpp b/Minecraft.World/Villages.cpp
index e636ed74..432a8b6b 100644
--- a/Minecraft.World/Villages.cpp
+++ b/Minecraft.World/Villages.cpp
@@ -11,7 +11,7 @@ const wstring Villages::VILLAGE_FILE_ID = L"villages";
Villages::Villages(const wstring &id) : SavedData(id)
{
_tick = 0;
- level = NULL;
+ level = nullptr;
}
Villages::Villages(Level *level) : SavedData(VILLAGE_FILE_ID)
@@ -117,7 +117,7 @@ void Villages::cluster()
bool found = false;
for(auto& village : villages)
{
- int dist = (int) village->getCenter()->distSqr(di->x, di->y, di->z);
+ int dist = static_cast<int>(village->getCenter()->distSqr(di->x, di->y, di->z));
int radius = MaxDoorDist + village->getRadius();
if (dist > radius * radius) continue;
village->addDoorInfo(di);
@@ -127,7 +127,7 @@ void Villages::cluster()
if (found) continue;
// create new Village
- shared_ptr<Village> village = shared_ptr<Village>(new Village(level));
+ shared_ptr<Village> village = std::make_shared<Village>(level);
village->addDoorInfo(di);
villages.push_back(village);
setDirty();
@@ -147,7 +147,7 @@ void Villages::addDoorInfos(Pos *pos)
if (isDoor(xx, yy, zz))
{
shared_ptr<DoorInfo> currentDoor = getDoorInfo(xx, yy, zz);
- if (currentDoor == NULL) createDoorInfo(xx, yy, zz);
+ if (currentDoor == nullptr) createDoorInfo(xx, yy, zz);
else currentDoor->timeStamp = _tick;
}
}
@@ -173,7 +173,7 @@ shared_ptr<DoorInfo> Villages::getDoorInfo(int x, int y, int z)
void Villages::createDoorInfo(int x, int y, int z)
{
- int dir = ((DoorTile *) Tile::door_wood)->getDir(level, x, y, z);
+ int dir = static_cast<DoorTile *>(Tile::door_wood)->getDir(level, x, y, z);
if (dir == 0 || dir == 2)
{
int canSeeX = 0;
@@ -181,7 +181,7 @@ void Villages::createDoorInfo(int x, int y, int z)
if (level->canSeeSky(x + i, y, z)) canSeeX--;
for (int i = 1; i <= 5; ++i)
if (level->canSeeSky(x + i, y, z)) canSeeX++;
- if (canSeeX != 0) unclustered.push_back(shared_ptr<DoorInfo>(new DoorInfo(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick)));
+ if (canSeeX != 0) unclustered.push_back(std::make_shared<DoorInfo>(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick));
}
else
{
@@ -190,7 +190,7 @@ void Villages::createDoorInfo(int x, int y, int z)
if (level->canSeeSky(x, y, z + i)) canSeeZ--;
for (int i = 1; i <= 5; ++i)
if (level->canSeeSky(x, y, z + i)) canSeeZ++;
- if (canSeeZ != 0) unclustered.push_back(shared_ptr<DoorInfo>(new DoorInfo(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick)));
+ if (canSeeZ != 0) unclustered.push_back(std::make_shared<DoorInfo>(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick));
}
}
@@ -218,7 +218,7 @@ void Villages::load(CompoundTag *tag)
for (int i = 0; i < villageTags->size(); i++)
{
CompoundTag *compoundTag = villageTags->get(i);
- shared_ptr<Village> village = shared_ptr<Village>(new Village());
+ shared_ptr<Village> village = std::make_shared<Village>();
village->readAdditionalSaveData(compoundTag);
villages.push_back(village);
}
diff --git a/Minecraft.World/VineTile.cpp b/Minecraft.World/VineTile.cpp
index 25600cbd..8f16a921 100644
--- a/Minecraft.World/VineTile.cpp
+++ b/Minecraft.World/VineTile.cpp
@@ -102,7 +102,7 @@ void VineTile::updateShape(LevelSource *level, int x, int y, int z, int forceDat
AABB *VineTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
bool VineTile::mayPlace(Level *level, int x, int y, int z, int face)
@@ -259,7 +259,7 @@ testLoop: if(noSideSpread) break;
int edgeTile = level->getTile(x + Direction::STEP_X[testDirection], y, z + Direction::STEP_Z[testDirection]);
- if (edgeTile == 0 || Tile::tiles[edgeTile] == NULL)
+ if (edgeTile == 0 || Tile::tiles[edgeTile] == nullptr)
{
// if the edge tile is air, we could possibly cling
// to something
@@ -371,7 +371,7 @@ int VineTile::getResourceCount(Random *random)
void VineTile::playerDestroy(Level *level, shared_ptr<Player>player, int x, int y, int z, int data)
{
- if (!level->isClientSide && player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears->id)
+ if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id)
{
player->awardStat(
GenericStats::blocksMined(id),
@@ -379,7 +379,7 @@ void VineTile::playerDestroy(Level *level, shared_ptr<Player>player, int x, int
);
// drop leaf block instead of sapling
- popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Tile::vine, 1, 0)));
+ popResource(level, x, y, z, std::make_shared<ItemInstance>(Tile::vine, 1, 0));
}
else
{
diff --git a/Minecraft.World/WallTile.cpp b/Minecraft.World/WallTile.cpp
index a95360ce..b7d3f038 100644
--- a/Minecraft.World/WallTile.cpp
+++ b/Minecraft.World/WallTile.cpp
@@ -159,7 +159,7 @@ bool WallTile::connectsTo(LevelSource *level, int x, int y, int z)
return true;
}
Tile *tileInstance = Tile::tiles[tile];
- if (tileInstance != NULL)
+ if (tileInstance != nullptr)
{
if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped())
{
diff --git a/Minecraft.World/WaterLevelChunk.cpp b/Minecraft.World/WaterLevelChunk.cpp
index 3f4bd704..5cce2f80 100644
--- a/Minecraft.World/WaterLevelChunk.cpp
+++ b/Minecraft.World/WaterLevelChunk.cpp
@@ -160,5 +160,5 @@ void WaterLevelChunk::setLevelChunkBrightness(LightLayer::variety layer, int x,
Biome *WaterLevelChunk::getBiome(int x, int z, BiomeSource *biomeSource)
{
- return NULL;
+ return nullptr;
}
diff --git a/Minecraft.World/WaterLilyTile.cpp b/Minecraft.World/WaterLilyTile.cpp
index 15e43b9d..71c37874 100644
--- a/Minecraft.World/WaterLilyTile.cpp
+++ b/Minecraft.World/WaterLilyTile.cpp
@@ -25,7 +25,7 @@ int WaterlilyTile::getRenderShape()
void WaterlilyTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source)
{
- if (source == NULL || !source->instanceof(eTYPE_BOAT))
+ if (source == nullptr || !source->instanceof(eTYPE_BOAT))
{
Bush::addAABBs(level, x, y, z, box, boxes, source);
}
@@ -33,7 +33,7 @@ void WaterlilyTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBL
AABB *WaterlilyTile::getAABB(Level *level, int x, int y, int z)
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1);
diff --git a/Minecraft.World/WaterLilyTileItem.cpp b/Minecraft.World/WaterLilyTileItem.cpp
index fe523c05..978a611f 100644
--- a/Minecraft.World/WaterLilyTileItem.cpp
+++ b/Minecraft.World/WaterLilyTileItem.cpp
@@ -13,7 +13,7 @@ WaterLilyTileItem::WaterLilyTileItem(int id) : ColoredTileItem(id, false)
bool WaterLilyTileItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
{
HitResult *hr = getPlayerPOVHitResult(level, player, true);
- if (hr == NULL) return false;
+ if (hr == nullptr) return false;
if (hr->type == HitResult::TILE)
{
@@ -47,7 +47,7 @@ bool WaterLilyTileItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *le
shared_ptr<ItemInstance> WaterLilyTileItem::use(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
{
HitResult *hr = getPlayerPOVHitResult(level, player, true);
- if (hr == NULL) return itemInstance;
+ if (hr == nullptr) return itemInstance;
if (hr->type == HitResult::TILE)
{
diff --git a/Minecraft.World/WebTile.cpp b/Minecraft.World/WebTile.cpp
index a724c36d..43609e56 100644
--- a/Minecraft.World/WebTile.cpp
+++ b/Minecraft.World/WebTile.cpp
@@ -22,7 +22,7 @@ bool WebTile::isSolidRender(bool isServerLevel)
AABB *WebTile::getAABB(Level *level, int x, int y, int z)
{
- return NULL;
+ return nullptr;
}
diff --git a/Minecraft.World/WeighedRandom.cpp b/Minecraft.World/WeighedRandom.cpp
index 0c27bf32..777ab92f 100644
--- a/Minecraft.World/WeighedRandom.cpp
+++ b/Minecraft.World/WeighedRandom.cpp
@@ -28,7 +28,7 @@ WeighedRandomItem *WeighedRandom::getRandomItem(Random *random, vector<WeighedRa
return item;
}
}
- return NULL;
+ return nullptr;
}
WeighedRandomItem *WeighedRandom::getRandomItem(Random *random, vector<WeighedRandomItem *> *items)
@@ -62,7 +62,7 @@ WeighedRandomItem *WeighedRandom::getRandomItem(Random *random, WeighedRandomIte
return items[i];
}
}
- return NULL;
+ return nullptr;
}
diff --git a/Minecraft.World/WeighedTreasure.cpp b/Minecraft.World/WeighedTreasure.cpp
index ec4280e4..3c20ae66 100644
--- a/Minecraft.World/WeighedTreasure.cpp
+++ b/Minecraft.World/WeighedTreasure.cpp
@@ -6,7 +6,7 @@
WeighedTreasure::WeighedTreasure(int itemId, int auxValue, int minCount, int maxCount, int weight) : WeighedRandomItem(weight)
{
- this->item = shared_ptr<ItemInstance>( new ItemInstance(itemId, 1, auxValue) );
+ this->item = std::make_shared<ItemInstance>(itemId, 1, auxValue);
this->minCount = minCount;
this->maxCount = maxCount;
}
@@ -22,7 +22,7 @@ void WeighedTreasure::addChestItems(Random *random, WeighedTreasureArray items,
{
for (int r = 0; r < numRolls; r++)
{
- WeighedTreasure *treasure = (WeighedTreasure *) WeighedRandom::getRandomItem(random, *((WeighedRandomItemArray *)&items));
+ WeighedTreasure *treasure = static_cast<WeighedTreasure *>(WeighedRandom::getRandomItem(random, *((WeighedRandomItemArray *)&items)));
int count = treasure->minCount + random->nextInt(treasure->maxCount - treasure->minCount + 1);
if (treasure->item->getMaxStackSize() >= count)
@@ -48,7 +48,7 @@ void WeighedTreasure::addDispenserItems(Random *random, WeighedTreasureArray ite
{
for (int r = 0; r < numRolls; r++)
{
- WeighedTreasure *treasure = (WeighedTreasure *) WeighedRandom::getRandomItem(random, *((WeighedRandomItemArray *)&items));
+ WeighedTreasure *treasure = static_cast<WeighedTreasure *>(WeighedRandom::getRandomItem(random, *((WeighedRandomItemArray *)&items)));
int count = treasure->minCount + random->nextInt(treasure->maxCount - treasure->minCount + 1);
if (treasure->item->getMaxStackSize() >= count)
diff --git a/Minecraft.World/WeightedPressurePlateTile.cpp b/Minecraft.World/WeightedPressurePlateTile.cpp
index 352747ce..c9b7d5c8 100644
--- a/Minecraft.World/WeightedPressurePlateTile.cpp
+++ b/Minecraft.World/WeightedPressurePlateTile.cpp
@@ -25,7 +25,7 @@ int WeightedPressurePlateTile::getSignalStrength(Level *level, int x, int y, int
}
else
{
- float pct = min(maxWeight, count) / (float) maxWeight;
+ float pct = min(maxWeight, count) / static_cast<float>(maxWeight);
return Mth::ceil(pct * Redstone::SIGNAL_MAX);
}
}
diff --git a/Minecraft.World/Witch.cpp b/Minecraft.World/Witch.cpp
index c697d467..375c8388 100644
--- a/Minecraft.World/Witch.cpp
+++ b/Minecraft.World/Witch.cpp
@@ -43,7 +43,7 @@ void Witch::defineSynchedData()
{
Monster::defineSynchedData();
- getEntityData()->define(DATA_USING_ITEM, (byte) 0);
+ getEntityData()->define(DATA_USING_ITEM, static_cast<byte>(0));
}
int Witch::getAmbientSound()
@@ -63,7 +63,7 @@ int Witch::getDeathSound()
void Witch::setUsingItem(bool isUsing)
{
- getEntityData()->set(DATA_USING_ITEM, isUsing ? (byte) 1 : (byte) 0);
+ getEntityData()->set(DATA_USING_ITEM, isUsing ? static_cast<byte>(1) : static_cast<byte>(0));
}
bool Witch::isUsingItem()
@@ -96,10 +96,10 @@ void Witch::aiStep()
shared_ptr<ItemInstance> item = getCarriedItem();
setEquippedSlot(SLOT_WEAPON, nullptr);
- if (item != NULL && item->id == Item::potion_Id)
+ if (item != nullptr && item->id == Item::potion_Id)
{
vector<MobEffectInstance *> *effects = Item::potion->getMobEffects(item);
- if (effects != NULL)
+ if (effects != nullptr)
{
for(auto& effect : *effects)
{
@@ -124,18 +124,18 @@ void Witch::aiStep()
{
potion = PotionBrewing::POTION_ID_HEAL;
}
- else if (random->nextFloat() < 0.25f && getTarget() != NULL && !hasEffect(MobEffect::movementSpeed) && getTarget()->distanceToSqr(shared_from_this()) > 11 * 11)
+ else if (random->nextFloat() < 0.25f && getTarget() != nullptr && !hasEffect(MobEffect::movementSpeed) && getTarget()->distanceToSqr(shared_from_this()) > 11 * 11)
{
potion = PotionBrewing::POTION_ID_SWIFTNESS;
}
- else if (random->nextFloat() < 0.25f && getTarget() != NULL && !hasEffect(MobEffect::movementSpeed) && getTarget()->distanceToSqr(shared_from_this()) > 11 * 11)
+ else if (random->nextFloat() < 0.25f && getTarget() != nullptr && !hasEffect(MobEffect::movementSpeed) && getTarget()->distanceToSqr(shared_from_this()) > 11 * 11)
{
potion = PotionBrewing::POTION_ID_SWIFTNESS;
}
if (potion > -1)
{
- setEquippedSlot(SLOT_WEAPON, shared_ptr<ItemInstance>( new ItemInstance(Item::potion, 1, potion)) );
+ setEquippedSlot(SLOT_WEAPON, std::make_shared<ItemInstance>(Item::potion, 1, potion));
usingTime = getCarriedItem()->getUseDuration();
setUsingItem(true);
AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED);
@@ -198,7 +198,7 @@ void Witch::performRangedAttack(shared_ptr<LivingEntity> target, float power)
{
if (isUsingItem()) return;
- shared_ptr<ThrownPotion> potion = shared_ptr<ThrownPotion>( new ThrownPotion(level, dynamic_pointer_cast<LivingEntity>(shared_from_this()), PotionBrewing::POTION_ID_SPLASH_DAMAGE) );
+ shared_ptr<ThrownPotion> potion = std::make_shared<ThrownPotion>(level, dynamic_pointer_cast<LivingEntity>(shared_from_this()), PotionBrewing::POTION_ID_SPLASH_DAMAGE);
potion->xRot -= -20;
double xd = (target->x + target->xd) - x;
double yd = (target->y + target->getHeadHeight() - 1.1f) - y;
diff --git a/Minecraft.World/WitherBoss.cpp b/Minecraft.World/WitherBoss.cpp
index 84cf1382..af406a93 100644
--- a/Minecraft.World/WitherBoss.cpp
+++ b/Minecraft.World/WitherBoss.cpp
@@ -124,7 +124,7 @@ void WitherBoss::aiStep()
if (!level->isClientSide && getAlternativeTarget(0) > 0)
{
shared_ptr<Entity> e = level->getEntity(getAlternativeTarget(0));
- if (e != NULL)
+ if (e != nullptr)
{
if ((y < e->y) || (!isPowered() && y < (e->y + 5)))
{
@@ -148,7 +148,7 @@ void WitherBoss::aiStep()
}
if ((xd * xd + zd * zd) > .05f)
{
- yRot = (float) atan2(zd, xd) * Mth::RADDEG - 90;
+ yRot = static_cast<float>(atan2(zd, xd)) * Mth::RADDEG - 90;
}
Monster::aiStep();
@@ -167,7 +167,7 @@ void WitherBoss::aiStep()
{
e = level->getEntity(entityId);
}
- if (e != NULL)
+ if (e != nullptr)
{
double hx = getHeadX(i + 1);
double hy = getHeadY(i + 1);
@@ -178,8 +178,8 @@ void WitherBoss::aiStep()
double zd = e->z - hz;
double sd = Mth::sqrt(xd * xd + zd * zd);
- float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90;
- float xRotD = (float) -(atan2(yd, sd) * 180 / PI);
+ float yRotD = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90;
+ float xRotD = static_cast<float>(-(atan2(yd, sd) * 180 / PI));
xRotHeads[i] = rotlerp(xRotHeads[i], xRotD, 40);
yRotHeads[i] = rotlerp(yRotHeads[i], yRotD, 10);
@@ -221,7 +221,7 @@ void WitherBoss::newServerAiStep()
if (newCount <= 0)
{
level->explode(shared_from_this(), x, y + getHeadHeight(), z, 7, false, level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING));
- level->globalLevelEvent(LevelEvent::SOUND_WITHER_BOSS_SPAWN, (int) x, (int) y, (int) z, 0);
+ level->globalLevelEvent(LevelEvent::SOUND_WITHER_BOSS_SPAWN, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
}
setInvulnerableTicks(newCount);
@@ -258,7 +258,7 @@ void WitherBoss::newServerAiStep()
shared_ptr<Entity> current = level->getEntity(headTarget);
// 4J: Added check for instance of living entity, had a problem with IDs being recycled to other entities
- if (current == NULL || !current->instanceof(eTYPE_LIVINGENTITY) || !current->isAlive() || distanceToSqr(current) > 30 * 30 || !canSee(current))
+ if (current == nullptr || !current->instanceof(eTYPE_LIVINGENTITY) || !current->isAlive() || distanceToSqr(current) > 30 * 30 || !canSee(current))
{
setAlternativeTarget(i, 0);
}
@@ -303,7 +303,7 @@ void WitherBoss::newServerAiStep()
}
}
}
- if (getTarget() != NULL)
+ if (getTarget() != nullptr)
{
assert(getTarget()->instanceof(eTYPE_LIVINGENTITY));
setAlternativeTarget(0, getTarget()->entityId);
@@ -346,7 +346,7 @@ void WitherBoss::newServerAiStep()
}
if (destroyed)
{
- level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_DOOR_CRASH, (int) x, (int) y, (int) z, 0);
+ level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_DOOR_CRASH, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
}
}
}
@@ -427,7 +427,7 @@ void WitherBoss::performRangedAttack(int head, shared_ptr<LivingEntity> target)
void WitherBoss::performRangedAttack(int head, double tx, double ty, double tz, bool dangerous)
{
- level->levelEvent(nullptr, LevelEvent::SOUND_WITHER_BOSS_SHOOT, (int) x, (int) y, (int) z, 0);
+ level->levelEvent(nullptr, LevelEvent::SOUND_WITHER_BOSS_SHOOT, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
double hx = getHeadX(head);
double hy = getHeadY(head);
@@ -437,7 +437,7 @@ void WitherBoss::performRangedAttack(int head, double tx, double ty, double tz,
double yd = ty - hy;
double zd = tz - hz;
- shared_ptr<WitherSkull> ie = shared_ptr<WitherSkull>( new WitherSkull(level, dynamic_pointer_cast<LivingEntity>(shared_from_this()), xd, yd, zd) );
+ shared_ptr<WitherSkull> ie = std::make_shared<WitherSkull>(level, dynamic_pointer_cast<LivingEntity>(shared_from_this()), xd, yd, zd);
if (dangerous) ie->setDangerous(true);
ie->y = hy;
ie->x = hx;
@@ -462,14 +462,14 @@ bool WitherBoss::hurt(DamageSource *source, float dmg)
if (isPowered())
{
shared_ptr<Entity> directEntity = source->getDirectEntity();
- if (directEntity != NULL && directEntity->GetType() == eTYPE_ARROW)
+ if (directEntity != nullptr && directEntity->GetType() == eTYPE_ARROW)
{
return false;
}
}
shared_ptr<Entity> sourceEntity = source->getEntity();
- if (sourceEntity != NULL)
+ if (sourceEntity != nullptr)
{
if ( sourceEntity->instanceof(eTYPE_PLAYER) )
{
diff --git a/Minecraft.World/WitherSkull.cpp b/Minecraft.World/WitherSkull.cpp
index d67660c4..ccde41d4 100644
--- a/Minecraft.World/WitherSkull.cpp
+++ b/Minecraft.World/WitherSkull.cpp
@@ -55,9 +55,9 @@ void WitherSkull::onHit(HitResult *res)
{
if (!level->isClientSide)
{
- if (res->entity != NULL)
+ if (res->entity != nullptr)
{
- if (owner != NULL)
+ if (owner != nullptr)
{
DamageSource *damageSource = DamageSource::mobAttack(owner);
if (res->entity->hurt(damageSource, 8))
@@ -111,7 +111,7 @@ bool WitherSkull::hurt(DamageSource *source, float damage)
void WitherSkull::defineSynchedData()
{
- entityData->define(DATA_DANGEROUS, (byte) 0);
+ entityData->define(DATA_DANGEROUS, static_cast<byte>(0));
}
bool WitherSkull::isDangerous()
@@ -121,7 +121,7 @@ bool WitherSkull::isDangerous()
void WitherSkull::setDangerous(bool value)
{
- entityData->set(DATA_DANGEROUS, value ? (byte) 1 : (byte) 0);
+ entityData->set(DATA_DANGEROUS, value ? static_cast<byte>(1) : static_cast<byte>(0));
}
bool WitherSkull::shouldBurn()
diff --git a/Minecraft.World/Wolf.cpp b/Minecraft.World/Wolf.cpp
index 1988382e..7588a67b 100644
--- a/Minecraft.World/Wolf.cpp
+++ b/Minecraft.World/Wolf.cpp
@@ -81,7 +81,7 @@ bool Wolf::useNewAi()
void Wolf::setTarget(shared_ptr<LivingEntity> target)
{
TamableAnimal::setTarget(target);
- if ( target == NULL )
+ if ( target == nullptr )
{
setAngry(false);
}
@@ -100,8 +100,8 @@ void Wolf::defineSynchedData()
{
TamableAnimal::defineSynchedData();
entityData->define(DATA_HEALTH_ID, getHealth());
- entityData->define(DATA_INTERESTED_ID, (byte)0);
- entityData->define(DATA_COLLAR_COLOR, (byte) ColoredTile::getTileDataForItemAuxValue(DyePowderItem::RED));
+ entityData->define(DATA_INTERESTED_ID, static_cast<byte>(0));
+ entityData->define(DATA_COLLAR_COLOR, static_cast<byte>(ColoredTile::getTileDataForItemAuxValue(DyePowderItem::RED)));
}
void Wolf::playStepSound(int xt, int yt, int zt, int t)
@@ -114,7 +114,7 @@ void Wolf::addAdditonalSaveData(CompoundTag *tag)
TamableAnimal::addAdditonalSaveData(tag);
tag->putBoolean(L"Angry", isAngry());
- tag->putByte(L"CollarColor", (byte) getCollarColor());
+ tag->putByte(L"CollarColor", static_cast<byte>(getCollarColor()));
}
void Wolf::readAdditionalSaveData(CompoundTag *tag)
@@ -224,8 +224,8 @@ void Wolf::tick()
if (shakeAnim > 0.4f)
{
- float yt = (float) bb->y0;
- int shakeCount = (int) (Mth::sin((shakeAnim - 0.4f) * PI) * 7.0f);
+ float yt = static_cast<float>(bb->y0);
+ int shakeCount = static_cast<int>(Mth::sin((shakeAnim - 0.4f) * PI) * 7.0f);
for (int i = 0; i < shakeCount; i++)
{
float xo = (random->nextFloat() * 2 - 1) * bbWidth * 0.5f;
@@ -286,7 +286,7 @@ bool Wolf::hurt(DamageSource *source, float dmg)
if (isTame())
{
shared_ptr<Entity> entity = source->getDirectEntity();
- if (entity != NULL && entity->instanceof(eTYPE_PLAYER))
+ if (entity != nullptr && entity->instanceof(eTYPE_PLAYER))
{
shared_ptr<Player> attacker = dynamic_pointer_cast<Player>(entity);
attacker->canHarmPlayer(getOwnerUUID());
@@ -296,7 +296,7 @@ bool Wolf::hurt(DamageSource *source, float dmg)
if (isInvulnerable()) return false;
shared_ptr<Entity> sourceEntity = source->getEntity();
sitGoal->wantToSit(false);
- if (sourceEntity != NULL && !(sourceEntity->instanceof(eTYPE_PLAYER) || sourceEntity->instanceof(eTYPE_ARROW)))
+ if (sourceEntity != nullptr && !(sourceEntity->instanceof(eTYPE_PLAYER) || sourceEntity->instanceof(eTYPE_ARROW)))
{
// Take half damage from non-players and arrows
dmg = (dmg + 1) / 2;
@@ -327,7 +327,7 @@ void Wolf::setTame(bool value)
void Wolf::tame(const wstring &wsOwnerUUID, bool bDisplayTamingParticles, bool bSetSitting)
{
setTame(true);
- setPath(NULL);
+ setPath(nullptr);
setTarget(nullptr);
sitGoal->wantToSit(bSetSitting);
setHealth(TAME_HEALTH);
@@ -344,9 +344,9 @@ bool Wolf::mobInteract(shared_ptr<Player> player)
if (isTame())
{
- if (item != NULL)
+ if (item != nullptr)
{
- if(dynamic_cast<FoodItem *>(Item::items[item->id]) != NULL)
+ if(dynamic_cast<FoodItem *>(Item::items[item->id]) != nullptr)
{
FoodItem *food = dynamic_cast<FoodItem *>( Item::items[item->id] );
@@ -387,7 +387,7 @@ bool Wolf::mobInteract(shared_ptr<Player> player)
{
sitGoal->wantToSit(!isSitting());
jumping = false;
- setPath(NULL);
+ setPath(nullptr);
setAttackTarget(nullptr);
setTarget(nullptr);
}
@@ -395,7 +395,7 @@ bool Wolf::mobInteract(shared_ptr<Player> player)
}
else
{
- if (item != NULL && item->id == Item::bone->id && !isAngry())
+ if (item != nullptr && item->id == Item::bone->id && !isAngry())
{
// 4J-PB - don't lose the bone in creative mode
if (player->abilities.instabuild==false)
@@ -430,7 +430,7 @@ bool Wolf::mobInteract(shared_ptr<Player> player)
}
// 4J-PB - stop wild wolves going in to Love Mode (even though they do on Java, but don't breed)
- if((item != NULL) && isFood(item))
+ if((item != nullptr) && isFood(item))
{
return false;
}
@@ -467,9 +467,9 @@ float Wolf::getTailAngle()
bool Wolf::isFood(shared_ptr<ItemInstance> item)
{
- if (item == NULL) return false;
- if (dynamic_cast<FoodItem *>(Item::items[item->id]) == NULL) return false;
- return ((FoodItem *) Item::items[item->id])->isMeat();
+ if (item == nullptr) return false;
+ if (dynamic_cast<FoodItem *>(Item::items[item->id]) == nullptr) return false;
+ return static_cast<FoodItem *>(Item::items[item->id])->isMeat();
}
int Wolf::getMaxSpawnClusterSize()
@@ -488,11 +488,11 @@ void Wolf::setAngry(bool value)
byte current = entityData->getByte(DATA_FLAGS_ID);
if (value)
{
- entityData->set(DATA_FLAGS_ID, (byte) (current | 0x02));
+ entityData->set(DATA_FLAGS_ID, static_cast<byte>(current | 0x02));
}
else
{
- entityData->set(DATA_FLAGS_ID, (byte) (current & ~0x02));
+ entityData->set(DATA_FLAGS_ID, static_cast<byte>(current & ~0x02));
}
}
@@ -503,7 +503,7 @@ int Wolf::getCollarColor()
void Wolf::setCollarColor(int color)
{
- entityData->set(DATA_COLLAR_COLOR, (byte) (color & 0xF));
+ entityData->set(DATA_COLLAR_COLOR, static_cast<byte>(color & 0xF));
}
// 4J-PB added for tooltips
@@ -517,7 +517,7 @@ shared_ptr<AgableMob> Wolf::getBreedOffspring(shared_ptr<AgableMob> target)
// 4J - added limit to wolves that can be bred
if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) )
{
- shared_ptr<Wolf> pBabyWolf = shared_ptr<Wolf>( new Wolf(level) );
+ shared_ptr<Wolf> pBabyWolf = std::make_shared<Wolf>(level);
if(!getOwnerUUID().empty())
{
@@ -536,11 +536,11 @@ void Wolf::setIsInterested(bool value)
{
if (value)
{
- entityData->set(DATA_INTERESTED_ID, (byte) 1);
+ entityData->set(DATA_INTERESTED_ID, static_cast<byte>(1));
}
else
{
- entityData->set(DATA_INTERESTED_ID, (byte) 0);
+ entityData->set(DATA_INTERESTED_ID, static_cast<byte>(0));
}
}
@@ -552,7 +552,7 @@ bool Wolf::canMate(shared_ptr<Animal> animal)
if (!animal->instanceof(eTYPE_WOLF)) return false;
shared_ptr<Wolf> partner = dynamic_pointer_cast<Wolf>(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/WoodSlabTile.cpp b/Minecraft.World/WoodSlabTile.cpp
index ba3a98e5..574dab93 100644
--- a/Minecraft.World/WoodSlabTile.cpp
+++ b/Minecraft.World/WoodSlabTile.cpp
@@ -33,7 +33,7 @@ int WoodSlabTile::getResource(int data, Random *random, int playerBonusLevel)
shared_ptr<ItemInstance> WoodSlabTile::getSilkTouchItemInstance(int data)
{
- return shared_ptr<ItemInstance>(new ItemInstance(Tile::woodSlabHalf, 2, data & TYPE_MASK));
+ return std::make_shared<ItemInstance>(Tile::woodSlabHalf, 2, data & TYPE_MASK);
}
int WoodSlabTile::getAuxName(int auxValue)
diff --git a/Minecraft.World/WoodTile.cpp b/Minecraft.World/WoodTile.cpp
index c735c581..239ef61c 100644
--- a/Minecraft.World/WoodTile.cpp
+++ b/Minecraft.World/WoodTile.cpp
@@ -21,7 +21,7 @@ const wstring WoodTile::TEXTURE_NAMES[] = {L"oak", L"spruce", L"birch", L"jungle
WoodTile::WoodTile(int id) : Tile(id, Material::wood)
{
- icons = NULL;
+ icons = nullptr;
}
unsigned int WoodTile::getDescriptionId(int iData)
diff --git a/Minecraft.World/WoolCarpetTile.cpp b/Minecraft.World/WoolCarpetTile.cpp
index b509a312..370b4010 100644
--- a/Minecraft.World/WoolCarpetTile.cpp
+++ b/Minecraft.World/WoolCarpetTile.cpp
@@ -20,7 +20,7 @@ AABB *WoolCarpetTile::getAABB(Level *level, int x, int y, int z)
{
int height = 0;
float offset = 1.0f / SharedConstants::WORLD_RESOLUTION;
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
// 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + (height * offset), z + tls->zz1);
diff --git a/Minecraft.World/WorkbenchTile.cpp b/Minecraft.World/WorkbenchTile.cpp
index 82193b69..cc505fc6 100644
--- a/Minecraft.World/WorkbenchTile.cpp
+++ b/Minecraft.World/WorkbenchTile.cpp
@@ -7,8 +7,8 @@
WorkbenchTile::WorkbenchTile(int id) : Tile(id, Material::wood)
{
- iconTop = NULL;
- iconFront = NULL;
+ iconTop = nullptr;
+ iconFront = nullptr;
}
Icon *WorkbenchTile::getTexture(int face, int data)
diff --git a/Minecraft.World/XZPacket.h b/Minecraft.World/XZPacket.h
index 0c4115e0..41b6c30d 100644
--- a/Minecraft.World/XZPacket.h
+++ b/Minecraft.World/XZPacket.h
@@ -25,6 +25,6 @@ public:
virtual int getEstimatedSize();
public:
- static shared_ptr<Packet> create() { return shared_ptr<Packet>(new XZPacket()); }
+ static shared_ptr<Packet> create() { return std::make_shared<XZPacket>(); }
virtual int getId() { return 166; }
}; \ No newline at end of file
diff --git a/Minecraft.World/Zombie.cpp b/Minecraft.World/Zombie.cpp
index e923822c..f982d847 100644
--- a/Minecraft.World/Zombie.cpp
+++ b/Minecraft.World/Zombie.cpp
@@ -68,9 +68,9 @@ void Zombie::defineSynchedData()
{
Monster::defineSynchedData();
- getEntityData()->define(DATA_BABY_ID, (byte) 0);
- getEntityData()->define(DATA_VILLAGER_ID, (byte) 0);
- getEntityData()->define(DATA_CONVERTING_ID, (byte) 0);
+ getEntityData()->define(DATA_BABY_ID, static_cast<byte>(0));
+ getEntityData()->define(DATA_VILLAGER_ID, static_cast<byte>(0));
+ getEntityData()->define(DATA_CONVERTING_ID, static_cast<byte>(0));
}
int Zombie::getArmorValue()
@@ -87,7 +87,7 @@ bool Zombie::useNewAi()
bool Zombie::isBaby()
{
- return getEntityData()->getByte(DATA_BABY_ID) == (byte) 1;
+ return getEntityData()->getByte(DATA_BABY_ID) == static_cast<byte>(1);
}
void Zombie::setBaby(bool baby)
@@ -95,7 +95,7 @@ void Zombie::setBaby(bool baby)
getEntityData()->set(DATA_BABY_ID, (byte) (baby ? 1 : 0));
updateSize(baby);
- if (level != NULL && !level->isClientSide)
+ if (level != nullptr && !level->isClientSide)
{
AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED);
speed->removeModifier(SPEED_MODIFIER_BABY);
@@ -108,12 +108,12 @@ void Zombie::setBaby(bool baby)
bool Zombie::isVillager()
{
- return getEntityData()->getByte(DATA_VILLAGER_ID) == (byte) 1;
+ return getEntityData()->getByte(DATA_VILLAGER_ID) == static_cast<byte>(1);
}
void Zombie::setVillager(bool villager)
{
- getEntityData()->set(DATA_VILLAGER_ID, (byte) (villager ? 1 : 0));
+ getEntityData()->set(DATA_VILLAGER_ID, static_cast<byte>(villager ? 1 : 0));
}
void Zombie::aiStep()
@@ -121,12 +121,12 @@ void Zombie::aiStep()
if (level->isDay() && !level->isClientSide && !isBaby())
{
float br = getBrightness(1);
- if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && level->canSeeSky(Mth::floor(x), (int)floor( y + 0.5 ), Mth::floor(z)))
+ if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && level->canSeeSky(Mth::floor(x), static_cast<int>(floor(y + 0.5)), Mth::floor(z)))
{
bool burn = true;
shared_ptr<ItemInstance> helmet = getCarried(SLOT_HELM);
- if (helmet != NULL)
+ if (helmet != nullptr)
{
if (helmet->isDamageableItem())
{
@@ -155,15 +155,15 @@ bool Zombie::hurt(DamageSource *source, float dmg)
if (Monster::hurt(source, dmg))
{
shared_ptr<LivingEntity> target = getTarget();
- if ( (target == NULL) && getAttackTarget() != NULL && getAttackTarget()->instanceof(eTYPE_LIVINGENTITY) ) target = dynamic_pointer_cast<LivingEntity>( getAttackTarget() );
- if ( (target == NULL) && source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_LIVINGENTITY) ) target = dynamic_pointer_cast<LivingEntity>( source->getEntity() );
+ if ( (target == nullptr) && getAttackTarget() != nullptr && getAttackTarget()->instanceof(eTYPE_LIVINGENTITY) ) target = dynamic_pointer_cast<LivingEntity>( getAttackTarget() );
+ if ( (target == nullptr) && source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_LIVINGENTITY) ) target = dynamic_pointer_cast<LivingEntity>( source->getEntity() );
- if ( (target != NULL) && level->difficulty >= Difficulty::HARD && random->nextFloat() < getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->getValue())
+ if ( (target != nullptr) && level->difficulty >= Difficulty::HARD && random->nextFloat() < getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->getValue())
{
int x = Mth::floor(this->x);
int y = Mth::floor(this->y);
int z = Mth::floor(this->z);
- shared_ptr<Zombie> reinforcement = shared_ptr<Zombie>( new Zombie(level) );
+ shared_ptr<Zombie> reinforcement = std::make_shared<Zombie>(level);
for (int i = 0; i < REINFORCEMENT_ATTEMPTS; i++)
{
@@ -179,7 +179,7 @@ bool Zombie::hurt(DamageSource *source, float dmg)
{
level->addEntity(reinforcement);
reinforcement->setTarget(target);
- reinforcement->finalizeMobSpawn(NULL);
+ reinforcement->finalizeMobSpawn(nullptr);
getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->addModifier(new AttributeModifier(-0.05f, AttributeModifier::OPERATION_ADDITION));
reinforcement->getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->addModifier(new AttributeModifier(-0.05f, AttributeModifier::OPERATION_ADDITION));
@@ -223,7 +223,7 @@ bool Zombie::doHurtTarget(shared_ptr<Entity> target)
if (result)
{
- if (getCarriedItem() == NULL && isOnFire() && random->nextFloat() < level->difficulty * 0.3f)
+ if (getCarriedItem() == nullptr && isOnFire() && random->nextFloat() < level->difficulty * 0.3f)
{
target->setOnFire(2 * level->difficulty);
}
@@ -293,11 +293,11 @@ void Zombie::populateDefaultEquipmentSlots()
int rand = random->nextInt(3);
if (rand == 0)
{
- setEquippedSlot(SLOT_WEAPON, shared_ptr<ItemInstance>( new ItemInstance(Item::sword_iron)) );
+ setEquippedSlot(SLOT_WEAPON, std::make_shared<ItemInstance>(Item::sword_iron));
}
else
{
- setEquippedSlot(SLOT_WEAPON, shared_ptr<ItemInstance>( new ItemInstance(Item::shovel_iron)) );
+ setEquippedSlot(SLOT_WEAPON, std::make_shared<ItemInstance>(Item::shovel_iron));
}
}
}
@@ -328,15 +328,15 @@ void Zombie::killed(shared_ptr<LivingEntity> mob)
{
if (level->difficulty == Difficulty::NORMAL && random->nextBoolean()) return;
- shared_ptr<Zombie> zombie = shared_ptr<Zombie>(new Zombie(level));
+ shared_ptr<Zombie> zombie = std::make_shared<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);
- level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_INFECTED, (int) x, (int) y, (int) z, 0);
+ level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_INFECTED, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
}
}
@@ -347,14 +347,14 @@ MobGroupData *Zombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
setCanPickUpLoot(random->nextFloat() < MAX_PICKUP_LOOT_CHANCE * difficulty);
- if (groupData == NULL)
+ if (groupData == nullptr)
{
groupData = new ZombieGroupData(level->random->nextFloat() < 0.05f, level->random->nextFloat() < 0.05f);
}
- if ( dynamic_cast<ZombieGroupData *>( groupData ) != NULL)
+ if ( dynamic_cast<ZombieGroupData *>( groupData ) != nullptr)
{
- ZombieGroupData *zombieData = (ZombieGroupData *) groupData;
+ ZombieGroupData *zombieData = static_cast<ZombieGroupData *>(groupData);
if (zombieData->isVillager)
{
@@ -370,7 +370,7 @@ MobGroupData *Zombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
populateDefaultEquipmentSlots();
populateDefaultEquipmentEnchantments();
- if (getCarried(SLOT_HELM) == NULL)
+ if (getCarried(SLOT_HELM) == nullptr)
{
// [EB]: We have this code in quite some places, shouldn't we set
// something like this globally?
@@ -378,7 +378,7 @@ MobGroupData *Zombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
{
// Halloween! OooOOo! 25% of all skeletons/zombies can wear
// pumpkins on their heads.
- setEquippedSlot(SLOT_HELM, shared_ptr<ItemInstance>( new ItemInstance(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin) ));
+ setEquippedSlot(SLOT_HELM, std::make_shared<ItemInstance>(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin));
dropChances[SLOT_HELM] = 0;
}
}
@@ -401,7 +401,7 @@ bool Zombie::mobInteract(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> item = player->getSelectedItem();
- if (item != NULL && item->getItem() == Item::apple_gold && item->getAuxValue() == 0 && isVillager() && hasEffect(MobEffect::weakness))
+ if (item != nullptr && item->getItem() == Item::apple_gold && item->getAuxValue() == 0 && isVillager() && hasEffect(MobEffect::weakness))
{
if (!player->abilities.instabuild) item->count--;
if (item->count <= 0)
@@ -426,7 +426,7 @@ bool Zombie::mobInteract(shared_ptr<Player> player)
void Zombie::startConverting(int time)
{
villagerConversionTime = time;
- getEntityData()->set(DATA_CONVERTING_ID, (byte) 1);
+ getEntityData()->set(DATA_CONVERTING_ID, static_cast<byte>(1));
removeEffect(MobEffect::weakness->id);
addEffect(new MobEffectInstance(MobEffect::damageBoost->id, time, min(level->difficulty - 1, 0)));
@@ -453,21 +453,21 @@ bool Zombie::removeWhenFarAway()
bool Zombie::isConverting()
{
- return getEntityData()->getByte(DATA_CONVERTING_ID) == (byte) 1;
+ return getEntityData()->getByte(DATA_CONVERTING_ID) == static_cast<byte>(1);
}
void Zombie::finishConversion()
{
- shared_ptr<Villager> villager = shared_ptr<Villager>(new Villager(level));
+ shared_ptr<Villager> villager = std::make_shared<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());
level->addEntity(villager);
villager->addEffect(new MobEffectInstance(MobEffect::confusion->id, SharedConstants::TICKS_PER_SECOND * 10, 0));
- level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_CONVERTED, (int) x, (int) y, (int) z, 0);
+ level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_CONVERTED, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0);
}
int Zombie::getConversionProgress()
@@ -478,11 +478,11 @@ int Zombie::getConversionProgress()
{
int specialBlocksCount = 0;
- for (int xx = (int) x - SPECIAL_BLOCK_RADIUS; xx < (int) x + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; xx++)
+ for (int xx = static_cast<int>(x) - SPECIAL_BLOCK_RADIUS; xx < static_cast<int>(x) + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; xx++)
{
- for (int yy = (int) y - SPECIAL_BLOCK_RADIUS; yy < (int) y + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; yy++)
+ for (int yy = static_cast<int>(y) - SPECIAL_BLOCK_RADIUS; yy < static_cast<int>(y) + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; yy++)
{
- for (int zz = (int) z - SPECIAL_BLOCK_RADIUS; zz < (int) z + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; zz++)
+ for (int zz = static_cast<int>(z) - SPECIAL_BLOCK_RADIUS; zz < static_cast<int>(z) + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; zz++)
{
int tile = level->getTile(xx, yy, zz);
diff --git a/Minecraft.World/ZoneFile.cpp b/Minecraft.World/ZoneFile.cpp
index 661cb7dd..582ce26d 100644
--- a/Minecraft.World/ZoneFile.cpp
+++ b/Minecraft.World/ZoneFile.cpp
@@ -23,7 +23,7 @@ ZoneFile::ZoneFile(int64_t key, File file, File entityFile) : slots(slotsLength)
// this.entityFile = new NbtSlotFile(entityFile);
// }
- channel = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ channel = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
// 4J - try/catch removed
// try {
readHeader();
diff --git a/Minecraft.World/ZoneIo.cpp b/Minecraft.World/ZoneIo.cpp
index 0bd2a637..f6adcf0e 100644
--- a/Minecraft.World/ZoneIo.cpp
+++ b/Minecraft.World/ZoneIo.cpp
@@ -22,8 +22,8 @@ void ZoneIo::write(byteArray bb, int size)
void ZoneIo::write(ByteBuffer *bb, int size)
{
DWORD numberOfBytesWritten;
- SetFilePointer(channel,(int)pos,NULL,NULL);
- WriteFile(channel,bb->getBuffer(), bb->getSize(),&numberOfBytesWritten,NULL);
+ SetFilePointer(channel,static_cast<int>(pos),nullptr,nullptr);
+ WriteFile(channel,bb->getBuffer(), bb->getSize(),&numberOfBytesWritten,nullptr);
pos += size;
}
@@ -31,13 +31,13 @@ ByteBuffer *ZoneIo::read(int size)
{
DWORD numberOfBytesRead;
byteArray bb = byteArray(size);
- SetFilePointer(channel,(int)pos,NULL,NULL);
+ SetFilePointer(channel,static_cast<int>(pos),nullptr,nullptr);
ByteBuffer *buff = ByteBuffer::wrap(bb);
// 4J - to investigate - why is this buffer flipped before anything goes in it?
buff->order(ZonedChunkStorage::BYTEORDER);
buff->position(size);
buff->flip();
- ReadFile(channel, buff->getBuffer(), buff->getSize(), &numberOfBytesRead, NULL);
+ ReadFile(channel, buff->getBuffer(), buff->getSize(), &numberOfBytesRead, nullptr);
pos += size;
return buff;
}
diff --git a/Minecraft.World/ZonedChunkStorage.cpp b/Minecraft.World/ZonedChunkStorage.cpp
index 596d7c48..19023242 100644
--- a/Minecraft.World/ZonedChunkStorage.cpp
+++ b/Minecraft.World/ZonedChunkStorage.cpp
@@ -62,8 +62,8 @@ ZoneFile *ZonedChunkStorage::getZoneFile(int x, int z, bool create)
if ( !file.exists() )
{
- if (!create) return NULL;
- HANDLE ch = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (!create) return nullptr;
+ HANDLE ch = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
CloseHandle(ch);
}
@@ -76,7 +76,7 @@ ZoneFile *ZonedChunkStorage::getZoneFile(int x, int z, bool create)
zoneFile->lastUse = tickCount;
if (!zoneFile->containsSlot(slot))
{
- if (!create) return NULL;
+ if (!create) return nullptr;
}
return zoneFile;
@@ -85,14 +85,14 @@ ZoneFile *ZonedChunkStorage::getZoneFile(int x, int z, bool create)
ZoneIo *ZonedChunkStorage::getBuffer(int x, int z, bool create)
{
ZoneFile *zoneFile = getZoneFile(x, z, create);
- if (zoneFile == NULL) return NULL;
+ if (zoneFile == nullptr) return nullptr;
return zoneFile->getZoneIo(getSlot(x, z));
}
LevelChunk *ZonedChunkStorage::load(Level *level, int x, int z)
{
ZoneIo *zoneIo = getBuffer(x, z, false);
- if (zoneIo == NULL) return NULL;
+ if (zoneIo == nullptr) return nullptr;
LevelChunk *lc = new LevelChunk(level, x, z);
lc->unsaved = false;
diff --git a/Minecraft.World/ZoomLayer.cpp b/Minecraft.World/ZoomLayer.cpp
index c2123785..fd452a08 100644
--- a/Minecraft.World/ZoomLayer.cpp
+++ b/Minecraft.World/ZoomLayer.cpp
@@ -86,7 +86,7 @@ shared_ptr<Layer>ZoomLayer::zoom(int64_t seed, shared_ptr<Layer> sup, int count)
shared_ptr<Layer>result = sup;
for (int i = 0; i < count; i++)
{
- result = shared_ptr<Layer>(new ZoomLayer(seed + i, result));
+ result = std::make_shared<ZoomLayer>(seed + i, result);
}
return result;
} \ No newline at end of file
diff --git a/Minecraft.World/compression.cpp b/Minecraft.World/compression.cpp
index b9845f01..8c2e51c0 100644
--- a/Minecraft.World/compression.cpp
+++ b/Minecraft.World/compression.cpp
@@ -12,7 +12,7 @@
DWORD Compression::tlsIdx = 0;
-Compression::ThreadStorage *Compression::tlsDefault = NULL;
+Compression::ThreadStorage *Compression::tlsDefault = nullptr;
Compression::ThreadStorage::ThreadStorage()
{
@@ -27,7 +27,7 @@ Compression::ThreadStorage::~ThreadStorage()
void Compression::CreateNewThreadStorage()
{
ThreadStorage *tls = new ThreadStorage();
- if(tlsDefault == NULL )
+ if(tlsDefault == nullptr )
{
tlsIdx = TlsAlloc();
tlsDefault = tls;
@@ -42,7 +42,7 @@ void Compression::UseDefaultThreadStorage()
void Compression::ReleaseThreadStorage()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ const ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
if( tls == tlsDefault ) return;
delete tls;
@@ -50,7 +50,7 @@ void Compression::ReleaseThreadStorage()
Compression *Compression::getCompression()
{
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
+ const ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
return tls->compression;
}
@@ -63,7 +63,7 @@ HRESULT Compression::CompressLZXRLE(void *pDestination, unsigned int *pDestSize,
// Use the static buffer when it fits, dynamically allocate otherwise.
static const unsigned int staticCompressSize = 1024*100;
unsigned int rleBufSize = SrcSize * 2;
- unsigned char *dynamicRleBuf = NULL;
+ unsigned char *dynamicRleBuf = nullptr;
unsigned char *rleBuf;
if(rleBufSize <= staticCompressSize)
@@ -77,8 +77,8 @@ HRESULT Compression::CompressLZXRLE(void *pDestination, unsigned int *pDestSize,
rleBuf = dynamicRleBuf;
}
- unsigned char *pucIn = (unsigned char *)pSource;
- unsigned char *pucEnd = pucIn + SrcSize;
+ const unsigned char *pucIn = static_cast<unsigned char*>(pSource);
+ const unsigned char *pucEnd = pucIn + SrcSize;
unsigned char *pucOut = rleBuf;
// Compress with RLE first:
@@ -88,7 +88,7 @@ HRESULT Compression::CompressLZXRLE(void *pDestination, unsigned int *pDestSize,
PIXBeginNamedEvent(0,"RLE compression");
do
{
- unsigned char thisOne = *pucIn++;
+ const unsigned char thisOne = *pucIn++;
unsigned int count = 1;
while( ( pucIn != pucEnd ) && ( *pucIn == thisOne ) && ( count < 256 ) )
@@ -119,14 +119,14 @@ HRESULT Compression::CompressLZXRLE(void *pDestination, unsigned int *pDestSize,
*pucOut++ = thisOne;
}
} while (pucIn != pucEnd);
- unsigned int rleSize = (unsigned int)(pucOut - rleBuf);
+ const unsigned int rleSize = static_cast<unsigned int>(pucOut - rleBuf);
PIXEndNamedEvent();
PIXBeginNamedEvent(0,"Secondary compression");
Compress(pDestination, pDestSize, rleBuf, rleSize);
PIXEndNamedEvent();
- if(dynamicRleBuf != NULL) delete [] dynamicRleBuf;
+ if(dynamicRleBuf != nullptr) delete [] dynamicRleBuf;
LeaveCriticalSection(&rleCompressLock);
// printf("Compressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize);
@@ -142,7 +142,7 @@ HRESULT Compression::CompressRLE(void *pDestination, unsigned int *pDestSize, vo
// RLE can expand data (each 0xFF byte becomes 2 bytes), so worst case is 2*SrcSize.
static const unsigned int staticCompressSize = 1024*100;
unsigned int rleBufSize = SrcSize * 2;
- unsigned char *dynamicRleBuf = NULL;
+ unsigned char *dynamicRleBuf = nullptr;
unsigned char *rleBuf;
if(rleBufSize <= staticCompressSize)
@@ -156,8 +156,8 @@ HRESULT Compression::CompressRLE(void *pDestination, unsigned int *pDestSize, vo
rleBuf = dynamicRleBuf;
}
- unsigned char *pucIn = (unsigned char *)pSource;
- unsigned char *pucEnd = pucIn + SrcSize;
+ const unsigned char *pucIn = static_cast<unsigned char*>(pSource);
+ const unsigned char *pucEnd = pucIn + SrcSize;
unsigned char *pucOut = rleBuf;
// Compress with RLE first:
@@ -167,7 +167,7 @@ HRESULT Compression::CompressRLE(void *pDestination, unsigned int *pDestSize, vo
PIXBeginNamedEvent(0,"RLE compression");
do
{
- unsigned char thisOne = *pucIn++;
+ const unsigned char thisOne = *pucIn++;
unsigned int count = 1;
while( ( pucIn != pucEnd ) && ( *pucIn == thisOne ) && ( count < 256 ) )
@@ -198,7 +198,7 @@ HRESULT Compression::CompressRLE(void *pDestination, unsigned int *pDestSize, vo
*pucOut++ = thisOne;
}
} while (pucIn != pucEnd);
- unsigned int rleSize = (unsigned int)(pucOut - rleBuf);
+ const unsigned int rleSize = static_cast<unsigned int>(pucOut - rleBuf);
PIXEndNamedEvent();
// Return
@@ -214,7 +214,7 @@ HRESULT Compression::CompressRLE(void *pDestination, unsigned int *pDestSize, vo
#endif
}
- if(dynamicRleBuf != NULL) delete [] dynamicRleBuf;
+ if(dynamicRleBuf != nullptr) delete [] dynamicRleBuf;
LeaveCriticalSection(&rleCompressLock);
return S_OK;
@@ -229,12 +229,12 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
// only use 5% of this buffer
// 4J Stu - Changed this again to dynamically allocate a buffer if it's going to be too big
- unsigned char *pucIn = NULL;
+ unsigned char *pucIn = nullptr;
//const unsigned int staticRleSize = 1024*200;
//static unsigned char rleBuf[staticRleSize];
unsigned int rleSize = staticRleSize;
- unsigned char *dynamicRleBuf = NULL;
+ unsigned char *dynamicRleBuf = nullptr;
HRESULT decompressResult;
if(*pDestSize > rleSize)
@@ -247,27 +247,27 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
else
{
decompressResult = Decompress(rleDecompressBuf, &rleSize, pSource, SrcSize);
- pucIn = (unsigned char *)rleDecompressBuf;
+ pucIn = static_cast<unsigned char*>(rleDecompressBuf);
}
if(decompressResult != S_OK)
{
app.DebugPrintf("*** DecompressLZXRLE: zlib Decompress FAILED hr=0x%08X srcSize=%u expectedDest=%u rleSize=%u\n",
decompressResult, SrcSize, *pDestSize, rleSize);
- if(dynamicRleBuf != NULL) delete [] dynamicRleBuf;
+ if(dynamicRleBuf != nullptr) delete [] dynamicRleBuf;
*pDestSize = 0;
LeaveCriticalSection(&rleDecompressLock);
return decompressResult;
}
//unsigned char *pucIn = (unsigned char *)rleDecompressBuf;
- unsigned char *pucEnd = pucIn + rleSize;
- unsigned char *pucOut = (unsigned char *)pDestination;
- unsigned char *pucOutEnd = pucOut + *pDestSize;
+ const unsigned char *pucEnd = pucIn + rleSize;
+ unsigned char *pucOut = static_cast<unsigned char*>(pDestination);
+ const unsigned char *pucOutEnd = pucOut + *pDestSize;
while( pucIn != pucEnd )
{
- unsigned char thisOne = *pucIn++;
+ const unsigned char thisOne = *pucIn++;
if( thisOne == 255 )
{
if( pucIn >= pucEnd ) break;
@@ -285,7 +285,7 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
{
count++;
if( pucIn >= pucEnd ) break;
- unsigned char data = *pucIn++;
+ const unsigned char data = *pucIn++;
if( pucOut + count > pucOutEnd ) break;
for( unsigned int i = 0; i < count; i++ )
{
@@ -299,11 +299,11 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
*pucOut++ = thisOne;
}
}
- *pDestSize = (unsigned int)(pucOut - (unsigned char *)pDestination);
+ *pDestSize = static_cast<unsigned int>(pucOut - static_cast<unsigned char*>(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;
@@ -314,14 +314,14 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
EnterCriticalSection(&rleDecompressLock);
//unsigned char *pucIn = (unsigned char *)rleDecompressBuf;
- unsigned char *pucIn = (unsigned char *)pSource;
- unsigned char *pucEnd = pucIn + SrcSize;
- unsigned char *pucOut = (unsigned char *)pDestination;
- unsigned char *pucOutEnd = pucOut + *pDestSize;
+ unsigned char *pucIn = static_cast<unsigned char *>(pSource);
+ const unsigned char *pucEnd = pucIn + SrcSize;
+ unsigned char *pucOut = static_cast<unsigned char*>(pDestination);
+ const unsigned char *pucOutEnd = pucOut + *pDestSize;
while( pucIn != pucEnd )
{
- unsigned char thisOne = *pucIn++;
+ const unsigned char thisOne = *pucIn++;
if( thisOne == 255 )
{
if( pucIn >= pucEnd ) break;
@@ -339,7 +339,7 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
{
count++;
if( pucIn >= pucEnd ) break;
- unsigned char data = *pucIn++;
+ const unsigned char data = *pucIn++;
if( pucOut + count > pucOutEnd ) break;
for( unsigned int i = 0; i < count; i++ )
{
@@ -353,7 +353,7 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
*pucOut++ = thisOne;
}
}
- *pDestSize = (unsigned int)(pucOut - (unsigned char *)pDestination);
+ *pDestSize = static_cast<unsigned int>(pucOut - static_cast<unsigned char*>(pDestination));
LeaveCriticalSection(&rleDecompressLock);
return S_OK;
@@ -365,8 +365,8 @@ HRESULT Compression::Compress(void *pDestination, unsigned int *pDestSize, void
// Using zlib for x64 compression - 360 is using native 360 compression and PS3 a stubbed non-compressing version of this
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__
SIZE_T destSize = (SIZE_T)(*pDestSize);
- int res = ::compress((Bytef *)pDestination, (uLongf *)&destSize, (Bytef *)pSource, SrcSize);
- *pDestSize = (unsigned int)destSize;
+ const int res = ::compress(static_cast<Bytef *>(pDestination), (uLongf *)&destSize, static_cast<Bytef *>(pSource), SrcSize);
+ *pDestSize = static_cast<unsigned int>(destSize);
return ( ( res == Z_OK ) ? S_OK : -1 );
#elif defined __PS3__
uint32_t destSize = (uint32_t)(*pDestSize);
@@ -393,8 +393,8 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi
// Using zlib for x64 compression - 360 is using native 360 compression and PS3 a stubbed non-compressing version of this
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__
SIZE_T destSize = (SIZE_T)(*pDestSize);
- int res = ::uncompress((Bytef *)pDestination, (uLongf *)&destSize, (Bytef *)pSource, SrcSize);
- *pDestSize = (unsigned int)destSize;
+ const int res = ::uncompress(static_cast<Bytef *>(pDestination), (uLongf *)&destSize, static_cast<Bytef *>(pSource), SrcSize);
+ *pDestSize = static_cast<unsigned int>(destSize);
return ( ( res == Z_OK ) ? S_OK : -1 );
#elif defined __PS3__
uint32_t destSize = (uint32_t)(*pDestSize);
@@ -413,11 +413,11 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi
#ifndef _XBOX
VOID Compression::VitaVirtualDecompress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize) // (LPVOID buf, SIZE_T dwSize, LPVOID dst)
{
- uint8_t *pSrc = (uint8_t *)pSource;
+ const uint8_t *pSrc = static_cast<uint8_t *>(pSource);
int Offset = 0;
int Page = 0;
int Index = 0;
- uint8_t* Data = (uint8_t*)pDestination;
+ uint8_t* Data = static_cast<uint8_t *>(pDestination);
while( Index != SrcSize )
{
// is this a normal value
@@ -431,7 +431,7 @@ VOID Compression::VitaVirtualDecompress(void *pDestination, unsigned int *pDestS
{
// how many zeros do we have
Index += 1;
- int Count = pSrc[Index];
+ const int Count = pSrc[Index];
// to do : this should really be a sequence of memsets
for( int i = 0;i < Count;i += 1 )
{
@@ -459,8 +459,8 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS
{
#if (defined _XBOX || defined _DURANGO || defined _WIN64)
SIZE_T destSize = (SIZE_T)(*pDestSize);
- HRESULT res = XMemDecompress(decompressionContext, pDestination, (SIZE_T *)&destSize, pSource, SrcSize);
- *pDestSize = (unsigned int)destSize;
+ const HRESULT res = XMemDecompress(decompressionContext, pDestination, (SIZE_T *)&destSize, pSource, SrcSize);
+ *pDestSize = static_cast<unsigned int>(destSize);
return res;
#else
assert(0);
@@ -469,9 +469,9 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS
break;
case eCompressionType_ZLIBRLE:
#if (defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64)
- if (pDestination != NULL)
- return ::uncompress((PBYTE)pDestination, (unsigned long *) pDestSize, (PBYTE) pSource, SrcSize); // Decompress
- else break; // Cannot decompress when destination is NULL
+ if (pDestination != nullptr)
+ return ::uncompress(static_cast<PBYTE>(pDestination), (unsigned long *) pDestSize, static_cast<PBYTE>(pSource), SrcSize); // Decompress
+ else break; // Cannot decompress when destination is nullptr
#else
assert(0);
break;
@@ -480,16 +480,16 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS
#if (defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WIN64)
// Note that we're missing the normal zlib header and footer so we'll use inflate to
// decompress the payload and skip all the CRC checking, etc
- if (pDestination != NULL)
+ if (pDestination != nullptr)
{
// Read big-endian srcize from array
- PBYTE pbDestSize = (PBYTE) pDestSize;
- PBYTE pbSource = (PBYTE) pSource;
+ const PBYTE pbDestSize = (PBYTE) pDestSize;
+ const PBYTE pbSource = static_cast<PBYTE>(pSource);
for (int i = 3; i >= 0; i--) {
pbDestSize[3-i] = pbSource[i];
}
- byteArray uncompr = byteArray(*pDestSize);
+ const byteArray uncompr = byteArray(*pDestSize);
// Build decompression stream
z_stream strm;
@@ -499,7 +499,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS
strm.next_out = uncompr.data;
strm.avail_out = uncompr.length;
// Skip those first 4 bytes
- strm.next_in = (PBYTE) pSource + 4;
+ strm.next_in = static_cast<PBYTE>(pSource) + 4;
strm.avail_in = SrcSize - 4;
int hr = inflateInit2(&strm, -15);
@@ -529,7 +529,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS
delete uncompr.data;
return S_OK;
}
- else break; // Cannot decompress when destination is NULL
+ else break; // Cannot decompress when destination is nullptr
#else
assert(0);
#endif
diff --git a/Minecraft.World/system.cpp b/Minecraft.World/system.cpp
index f9bd07a7..71d0a85e 100644
--- a/Minecraft.World/system.cpp
+++ b/Minecraft.World/system.cpp
@@ -64,7 +64,7 @@ int64_t System::nanoTime()
// Using double to avoid 64-bit overflow during multiplication for long uptime
// Precision is sufficient for ~100 days of uptime.
- return (int64_t)((double)counter.QuadPart * 1000000000.0 / (double)s_frequency.QuadPart);
+ return static_cast<int64_t>(static_cast<double>(counter.QuadPart) * 1000000000.0 / static_cast<double>(s_frequency.QuadPart));
#else
return GetTickCount() * 1000000LL;
#endif
diff --git a/Minecraft.World/x64headers/extraX64.h b/Minecraft.World/x64headers/extraX64.h
index 79882800..4af047b5 100644
--- a/Minecraft.World/x64headers/extraX64.h
+++ b/Minecraft.World/x64headers/extraX64.h
@@ -120,7 +120,7 @@ public:
else
{
LeaveCriticalSection(&m_cs);
- return NULL;
+ return nullptr;
}
}
private:
@@ -332,10 +332,10 @@ public:
#define PIXSetMarkerDeprecated(a, b, ...) PIXSetMarker(a, L ## b, __VA_ARGS__)
#define PIXAddNamedCounter(a, b) PIXReportCounter( L ## b, a)
#else
-void PIXAddNamedCounter(int a, const char *b, ...);
-void PIXBeginNamedEvent(int a, const char *b, ...);
-void PIXEndNamedEvent();
-void PIXSetMarkerDeprecated(int a, const char *b, ...);
+inline void PIXAddNamedCounter(int, const char*, ...) {}
+inline void PIXBeginNamedEvent(int, const char*, ...) {}
+inline void PIXEndNamedEvent() {}
+inline void PIXSetMarkerDeprecated(int, const char*, ...) {}
#endif
void XSetThreadProcessor(HANDLE a, int b);