From 50a606f9cd9d67751ca4b610c03166fe21cecc4f Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Fri, 6 Mar 2026 17:33:22 -0500 Subject: [PATCH] Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. --- Minecraft.Client/AbstractTexturePack.cpp | 1 + Minecraft.Client/ClientConnection.cpp | 131 +++++++++-------- Minecraft.Client/Common/Audio/miniaudio.h | 5 - Minecraft.Client/Common/DLC/DLCManager.cpp | 1 + .../GameRules/AddItemRuleDefinition.cpp | 2 +- .../GameRules/CollectItemRuleDefinition.cpp | 20 ++- .../GameRules/CompleteAllRuleDefinition.cpp | 2 +- .../Common/Network/GameNetworkManager.cpp | 6 +- .../Common/Tutorial/ChangeStateConstraint.cpp | 6 +- .../Common/Tutorial/ChoiceTask.cpp | 5 +- Minecraft.Client/Common/Tutorial/InfoTask.cpp | 3 +- Minecraft.Client/Common/Tutorial/Tutorial.cpp | 1 + .../UI/IUIScene_AbstractContainerMenu.cpp | 1 + .../Common/UI/IUIScene_AnvilMenu.cpp | 2 +- .../Common/UI/IUIScene_BeaconMenu.cpp | 2 +- .../Common/UI/IUIScene_CommandBlockMenu.cpp | 2 +- .../Common/UI/IUIScene_CraftingMenu.cpp | 8 +- .../Common/UI/IUIScene_CreativeMenu.cpp | 6 +- Minecraft.Client/Common/UI/IUIScene_HUD.cpp | 2 + .../Common/UI/IUIScene_TradingMenu.cpp | 8 +- Minecraft.Client/Common/UI/UI.h | 4 +- .../Common/UI/UIComponent_TutorialPopup.cpp | 36 ++--- Minecraft.Client/Common/UI/UIGroup.cpp | 2 + Minecraft.Client/Common/UI/UIScene.cpp | 33 ++--- .../Common/UI/UIScene_BeaconMenu.cpp | 8 +- .../Common/UI/UIScene_CreativeMenu.cpp | 2 +- .../Common/UI/UIScene_DebugOverlay.cpp | 2 +- .../Common/UI/UIScene_FullscreenProgress.cpp | 1 - .../UI/UIScene_InGameHostOptionsMenu.cpp | 2 +- .../Common/UI/UIScene_InGameInfoMenu.cpp | 2 +- .../UI/UIScene_InGamePlayerOptionsMenu.cpp | 5 +- .../Common/UI/UIScene_LeaderboardsMenu.cpp | 12 +- .../Common/UI/UIScene_SignEntryMenu.cpp | 2 +- .../Common/XUI/XUI_Ctrl_MinecraftSlot.cpp | 2 +- .../Common/XUI/XUI_DebugItemEditor.cpp | 4 +- .../Common/XUI/XUI_InGameHostOptions.cpp | 2 +- .../Common/XUI/XUI_InGameInfo.cpp | 2 +- .../Common/XUI/XUI_InGamePlayerOptions.cpp | 4 +- .../XUI/XUI_Scene_Inventory_Creative.cpp | 2 +- Minecraft.Client/Common/XUI/XUI_SignEntry.cpp | 2 +- .../Common/XUI/XUI_TutorialPopup.cpp | 4 +- Minecraft.Client/ConnectScreen.cpp | 2 +- Minecraft.Client/DLCTexturePack.cpp | 1 + Minecraft.Client/EntityTileRenderer.cpp | 6 +- Minecraft.Client/EntityTracker.cpp | 2 +- Minecraft.Client/FireworksParticles.cpp | 6 +- Minecraft.Client/GameRenderer.cpp | 19 +-- Minecraft.Client/Gui.cpp | 1 + Minecraft.Client/ItemFrameRenderer.cpp | 2 +- Minecraft.Client/LevelRenderer.cpp | 74 +++++----- Minecraft.Client/LivingEntityRenderer.cpp | 2 +- Minecraft.Client/LocalPlayer.cpp | 8 +- Minecraft.Client/Minecraft.cpp | 6 +- Minecraft.Client/MinecraftServer.cpp | 24 ++-- Minecraft.Client/MultiPlayerGameMode.cpp | 38 ++--- Minecraft.Client/MultiPlayerLevel.cpp | 8 +- Minecraft.Client/MultiPlayerLocalPlayer.cpp | 48 +++---- Minecraft.Client/ParticleEngine.cpp | 4 +- Minecraft.Client/PendingConnection.cpp | 6 +- Minecraft.Client/PlayerChunkMap.cpp | 12 +- Minecraft.Client/PlayerConnection.cpp | 80 ++++++----- Minecraft.Client/PlayerList.cpp | 80 ++++++----- Minecraft.Client/PlayerRenderer.cpp | 2 +- Minecraft.Client/ReceivingLevelScreen.cpp | 2 +- Minecraft.Client/ServerLevel.cpp | 16 +-- Minecraft.Client/ServerPlayer.cpp | 134 +++++++++--------- Minecraft.Client/ServerPlayerGameMode.cpp | 2 +- Minecraft.Client/SnowManRenderer.cpp | 2 +- Minecraft.Client/TeleportCommand.cpp | 2 +- Minecraft.Client/TextEditScreen.cpp | 2 +- Minecraft.Client/TexturePackRepository.cpp | 1 + Minecraft.Client/TrackedEntity.cpp | 94 ++++++------ .../Windows64/Windows64_Minecraft.cpp | 2 +- .../Windows64/Windows64_UIController.h | 2 - Minecraft.World/AbstractContainerMenu.cpp | 8 +- Minecraft.World/AbstractContainerMenu.h | 2 +- Minecraft.World/AddEntityPacket.h | 2 +- Minecraft.World/AddExperienceOrbPacket.h | 2 +- Minecraft.World/AddGlobalEntityPacket.h | 2 +- Minecraft.World/AddMobPacket.h | 2 +- Minecraft.World/AddPaintingPacket.h | 2 +- Minecraft.World/AddPlayerPacket.h | 2 +- Minecraft.World/Animal.cpp | 2 +- Minecraft.World/AnimatePacket.h | 2 +- Minecraft.World/AnvilMenu.cpp | 4 +- Minecraft.World/Arrow.cpp | 4 +- Minecraft.World/AwardStatPacket.h | 2 +- Minecraft.World/BeaconTile.cpp | 2 +- Minecraft.World/BeaconTileEntity.cpp | 6 +- Minecraft.World/Blaze.cpp | 2 +- Minecraft.World/BlockRegionUpdatePacket.h | 2 +- Minecraft.World/BoatItem.cpp | 2 +- Minecraft.World/BottleItem.cpp | 6 +- Minecraft.World/BowItem.cpp | 2 +- Minecraft.World/BowlFoodItem.cpp | 2 +- Minecraft.World/BreedGoal.cpp | 2 +- Minecraft.World/BrewingStandTile.cpp | 4 +- Minecraft.World/BrewingStandTileEntity.cpp | 6 +- Minecraft.World/BucketItem.cpp | 18 +-- Minecraft.World/CarrotOnAStickItem.cpp | 2 +- Minecraft.World/CauldronTile.cpp | 6 +- Minecraft.World/ChatPacket.h | 2 +- Minecraft.World/ChestTile.cpp | 14 +- Minecraft.World/ChestTileEntity.cpp | 2 +- Minecraft.World/Chicken.cpp | 2 +- Minecraft.World/ChunkTilesUpdatePacket.h | 2 +- Minecraft.World/ChunkVisibilityAreaPacket.h | 2 +- Minecraft.World/ChunkVisibilityPacket.h | 2 +- Minecraft.World/ClientCommandPacket.h | 2 +- Minecraft.World/CocoaTile.cpp | 2 +- Minecraft.World/CombatTracker.cpp | 14 +- Minecraft.World/CommandBlock.cpp | 2 +- Minecraft.World/CommandBlockEntity.cpp | 4 +- Minecraft.World/ComparatorTile.cpp | 2 +- Minecraft.World/ComparatorTileEntity.cpp | 2 +- Minecraft.World/ComplexItemDataPacket.h | 2 +- Minecraft.World/Connection.cpp | 2 +- Minecraft.World/ContainerAckPacket.h | 2 +- Minecraft.World/ContainerButtonClickPacket.h | 2 +- Minecraft.World/ContainerClickPacket.h | 2 +- Minecraft.World/ContainerClosePacket.h | 2 +- Minecraft.World/ContainerOpenPacket.h | 2 +- Minecraft.World/ContainerSetContentPacket.h | 2 +- Minecraft.World/ContainerSetDataPacket.h | 2 +- Minecraft.World/ContainerSetSlotPacket.h | 2 +- Minecraft.World/ControlledByPlayerGoal.cpp | 2 +- Minecraft.World/Cow.cpp | 8 +- Minecraft.World/CraftItemPacket.h | 2 +- Minecraft.World/CraftingMenu.cpp | 4 +- Minecraft.World/CropTile.cpp | 2 +- Minecraft.World/CustomPayloadPacket.h | 2 +- Minecraft.World/DamageSource.cpp | 4 +- Minecraft.World/DaylightDetectorTile.cpp | 2 +- .../DaylightDetectorTileEntity.cpp | 2 +- Minecraft.World/DeadBushTile.cpp | 2 +- Minecraft.World/DebugOptionsPacket.h | 2 +- .../DefaultDispenseItemBehavior.cpp | 2 +- .../DirectoryLevelStorageSource.cpp | 2 +- Minecraft.World/DisconnectPacket.h | 2 +- Minecraft.World/DispenserTile.cpp | 6 +- Minecraft.World/DispenserTileEntity.cpp | 2 +- Minecraft.World/DropperTile.cpp | 2 +- Minecraft.World/DropperTileEntity.cpp | 2 +- Minecraft.World/EggItem.cpp | 2 +- Minecraft.World/EggTile.cpp | 2 +- Minecraft.World/EmptyMapItem.cpp | 2 +- Minecraft.World/EnchantItemCommand.cpp | 2 +- Minecraft.World/EnchantedBookItem.cpp | 6 +- Minecraft.World/EnchantmentMenu.cpp | 2 +- Minecraft.World/EnchantmentTableEntity.cpp | 2 +- Minecraft.World/EnchantmentTableTile.cpp | 2 +- Minecraft.World/EnderChestTile.cpp | 2 +- Minecraft.World/EnderChestTileEntity.cpp | 2 +- Minecraft.World/EnderDragon.cpp | 22 +-- Minecraft.World/EnderEyeItem.cpp | 2 +- Minecraft.World/EnderpearlItem.cpp | 2 +- Minecraft.World/Entity.cpp | 6 +- .../EntityActionAtPositionPacket.h | 2 +- Minecraft.World/EntityDamageSource.cpp | 4 +- Minecraft.World/EntityEventPacket.h | 2 +- Minecraft.World/EntityHorse.cpp | 6 +- Minecraft.World/ExperienceItem.cpp | 2 +- Minecraft.World/ExplodePacket.h | 2 +- Minecraft.World/EyeOfEnderSignal.cpp | 2 +- Minecraft.World/FallingTile.cpp | 4 +- Minecraft.World/FireworksItem.cpp | 2 +- Minecraft.World/FireworksMenu.cpp | 4 +- Minecraft.World/FireworksRecipe.cpp | 4 +- Minecraft.World/FishingHook.cpp | 4 +- Minecraft.World/FishingRodItem.cpp | 2 +- Minecraft.World/FlowerPotTile.cpp | 22 +-- Minecraft.World/FurnaceResultSlot.cpp | 2 +- Minecraft.World/FurnaceTile.cpp | 6 +- Minecraft.World/FurnaceTileEntity.cpp | 4 +- Minecraft.World/FuzzyZoomLayer.cpp | 2 +- Minecraft.World/GameCommandPacket.h | 2 +- Minecraft.World/GameEventPacket.h | 2 +- Minecraft.World/GetInfoPacket.h | 2 +- Minecraft.World/Ghast.cpp | 2 +- Minecraft.World/GiveItemCommand.cpp | 4 +- Minecraft.World/HangingEntityItem.cpp | 4 +- Minecraft.World/HeavyTile.cpp | 2 +- Minecraft.World/HopperTile.cpp | 4 +- Minecraft.World/HopperTileEntity.cpp | 2 +- Minecraft.World/HouseFeature.cpp | 2 +- .../IndirectEntityDamageSource.cpp | 4 +- Minecraft.World/InteractPacket.h | 2 +- Minecraft.World/Inventory.cpp | 8 +- Minecraft.World/InventoryMenu.cpp | 4 +- Minecraft.World/ItemDispenseBehaviors.cpp | 22 +-- Minecraft.World/ItemEntity.cpp | 2 +- Minecraft.World/ItemFrame.cpp | 2 +- Minecraft.World/ItemInstance.cpp | 4 +- Minecraft.World/JukeboxTile.cpp | 8 +- Minecraft.World/KeepAlivePacket.h | 2 +- Minecraft.World/KickPlayerPacket.h | 2 +- Minecraft.World/LavaSlime.cpp | 2 +- Minecraft.World/Layer.cpp | 50 +++---- Minecraft.World/LeafTile.cpp | 8 +- Minecraft.World/LeashFenceKnotEntity.cpp | 2 +- Minecraft.World/Level.cpp | 6 +- Minecraft.World/LevelEventPacket.h | 2 +- Minecraft.World/LevelParticlesPacket.h | 2 +- Minecraft.World/LevelSoundPacket.h | 2 +- Minecraft.World/LivingEntity.cpp | 12 +- Minecraft.World/LoginPacket.h | 2 +- Minecraft.World/MapItem.cpp | 8 +- Minecraft.World/MapItemSavedData.cpp | 4 +- .../McRegionLevelStorageSource.cpp | 2 +- Minecraft.World/MerchantMenu.cpp | 2 +- Minecraft.World/MerchantRecipe.cpp | 4 +- Minecraft.World/MilkBucketItem.cpp | 2 +- Minecraft.World/MineShaftPieces.cpp | 2 +- Minecraft.World/Minecart.cpp | 14 +- Minecraft.World/MinecartContainer.cpp | 4 +- Minecraft.World/MinecartFurnace.cpp | 2 +- Minecraft.World/MinecartTNT.cpp | 2 +- Minecraft.World/Mob.cpp | 6 +- Minecraft.World/MobSpawnerTile.cpp | 2 +- Minecraft.World/MobSpawnerTileEntity.cpp | 4 +- Minecraft.World/MoveEntityPacket.h | 8 +- Minecraft.World/MoveEntityPacketSmall.h | 8 +- Minecraft.World/MovePlayerPacket.h | 8 +- Minecraft.World/MushroomCow.cpp | 10 +- Minecraft.World/MusicTileEntity.cpp | 2 +- Minecraft.World/NetherWartTile.cpp | 2 +- Minecraft.World/NoteBlockTile.cpp | 2 +- Minecraft.World/Ocelot.cpp | 4 +- Minecraft.World/Packet.cpp | 2 +- Minecraft.World/Painting.cpp | 2 +- Minecraft.World/Pig.cpp | 4 +- Minecraft.World/PigZombie.cpp | 2 +- Minecraft.World/PistonMovingPiece.cpp | 2 +- Minecraft.World/PistonPieceEntity.cpp | 2 +- Minecraft.World/Player.cpp | 8 +- Minecraft.World/PlayerAbilitiesPacket.h | 2 +- Minecraft.World/PlayerActionPacket.h | 2 +- Minecraft.World/PlayerCommandPacket.h | 2 +- Minecraft.World/PlayerInfoPacket.h | 2 +- Minecraft.World/PlayerInputPacket.h | 2 +- Minecraft.World/PotatoTile.cpp | 2 +- Minecraft.World/PotionItem.cpp | 6 +- Minecraft.World/PreLoginPacket.h | 2 +- Minecraft.World/PumpkinTile.cpp | 4 +- Minecraft.World/QuartzBlockTile.cpp | 2 +- Minecraft.World/Recipes.cpp | 2 +- Minecraft.World/RedStoneOreTile.cpp | 2 +- Minecraft.World/RemoveEntitiesPacket.h | 2 +- Minecraft.World/RemoveMobEffectPacket.h | 2 +- Minecraft.World/RespawnPacket.h | 2 +- Minecraft.World/ResultSlot.cpp | 2 +- Minecraft.World/RotateHeadPacket.h | 2 +- Minecraft.World/RotatedPillarTile.cpp | 2 +- Minecraft.World/SavedDataStorage.cpp | 6 +- Minecraft.World/ScatteredFeaturePieces.cpp | 2 +- Minecraft.World/ServerSettingsChangedPacket.h | 2 +- Minecraft.World/SetCarriedItemPacket.h | 2 +- Minecraft.World/SetCreativeModeSlotPacket.h | 2 +- Minecraft.World/SetDisplayObjectivePacket.h | 2 +- Minecraft.World/SetEntityDataPacket.h | 2 +- Minecraft.World/SetEntityLinkPacket.h | 2 +- Minecraft.World/SetEntityMotionPacket.h | 2 +- Minecraft.World/SetEquippedItemPacket.h | 2 +- Minecraft.World/SetExperiencePacket.h | 2 +- Minecraft.World/SetHealthPacket.h | 2 +- Minecraft.World/SetObjectivePacket.h | 2 +- Minecraft.World/SetPlayerTeamPacket.h | 2 +- Minecraft.World/SetScorePacket.h | 2 +- Minecraft.World/SetSpawnPositionPacket.h | 2 +- Minecraft.World/SetTimePacket.h | 2 +- Minecraft.World/Sheep.cpp | 12 +- Minecraft.World/SignTile.cpp | 2 +- Minecraft.World/SignTileEntity.cpp | 4 +- Minecraft.World/SignUpdatePacket.h | 2 +- Minecraft.World/Skeleton.cpp | 10 +- Minecraft.World/SkullTile.cpp | 16 +-- Minecraft.World/SkullTileEntity.cpp | 4 +- Minecraft.World/Slime.cpp | 2 +- Minecraft.World/Slot.cpp | 2 +- Minecraft.World/SmoothZoomLayer.cpp | 2 +- Minecraft.World/SnowMan.cpp | 2 +- Minecraft.World/SnowballItem.cpp | 2 +- Minecraft.World/Spider.cpp | 2 +- Minecraft.World/SpikeFeature.cpp | 4 +- Minecraft.World/Squid.cpp | 2 +- Minecraft.World/StemTile.cpp | 2 +- Minecraft.World/StoneMonsterTile.cpp | 4 +- Minecraft.World/StoneSlabTile.cpp | 2 +- Minecraft.World/SynchedEntityData.cpp | 24 ++-- Minecraft.World/TakeItemEntityPacket.h | 2 +- Minecraft.World/TallGrass.cpp | 2 +- Minecraft.World/TeleportEntityPacket.h | 2 +- .../TextureAndGeometryChangePacket.h | 2 +- Minecraft.World/TextureChangePacket.h | 2 +- Minecraft.World/TheEndBiomeDecorator.cpp | 2 +- Minecraft.World/TheEndPortal.cpp | 2 +- Minecraft.World/TheEndPortalTileEntity.cpp | 2 +- Minecraft.World/ThinFenceTile.cpp | 2 +- Minecraft.World/ThrownEgg.cpp | 2 +- Minecraft.World/ThrownExpBottle.cpp | 2 +- Minecraft.World/ThrownPotion.cpp | 8 +- Minecraft.World/Tile.cpp | 8 +- Minecraft.World/TileDestructionPacket.h | 2 +- Minecraft.World/TileEditorOpenPacket.h | 2 +- Minecraft.World/TileEntityDataPacket.h | 2 +- Minecraft.World/TileEventPacket.h | 2 +- Minecraft.World/TileUpdatePacket.h | 2 +- Minecraft.World/TimeCommand.cpp | 2 +- Minecraft.World/TntTile.cpp | 4 +- Minecraft.World/ToggleDownfallCommand.cpp | 2 +- Minecraft.World/TopSnowTile.cpp | 2 +- Minecraft.World/TradeItemPacket.h | 2 +- Minecraft.World/TreeTile.cpp | 2 +- Minecraft.World/UpdateAttributesPacket.h | 2 +- .../UpdateGameRuleProgressPacket.cpp | 8 +- Minecraft.World/UpdateMobEffectPacket.h | 2 +- Minecraft.World/UpdateProgressPacket.h | 2 +- Minecraft.World/UseItemPacket.h | 2 +- Minecraft.World/Village.cpp | 4 +- Minecraft.World/VillagePieces.cpp | 2 +- Minecraft.World/VillageSiege.cpp | 2 +- Minecraft.World/Villager.cpp | 22 +-- Minecraft.World/Villages.cpp | 8 +- Minecraft.World/VineTile.cpp | 2 +- Minecraft.World/WeighedTreasure.cpp | 2 +- Minecraft.World/Witch.cpp | 4 +- Minecraft.World/WitherBoss.cpp | 2 +- Minecraft.World/Wolf.cpp | 2 +- Minecraft.World/WoodSlabTile.cpp | 2 +- Minecraft.World/XZPacket.h | 2 +- Minecraft.World/Zombie.cpp | 12 +- Minecraft.World/ZoomLayer.cpp | 2 +- 332 files changed, 1031 insertions(+), 984 deletions(-) diff --git a/Minecraft.Client/AbstractTexturePack.cpp b/Minecraft.Client/AbstractTexturePack.cpp index 16d1b14e6..a3c677272 100644 --- a/Minecraft.Client/AbstractTexturePack.cpp +++ b/Minecraft.Client/AbstractTexturePack.cpp @@ -3,6 +3,7 @@ #include "AbstractTexturePack.h" #include "..\Minecraft.World\InputOutputStream.h" #include "..\Minecraft.World\StringHelpers.h" +#include "Common/UI/UI.h" AbstractTexturePack::AbstractTexturePack(DWORD id, File *file, const wstring &name, TexturePack *fallback) : id(id), name(name) { diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index 09a57759e..05a7f8aa3 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -452,7 +452,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) if (owner != nullptr && owner->instanceof(eTYPE_PLAYER)) { shared_ptr player = dynamic_pointer_cast(owner); - shared_ptr hook = shared_ptr( new FishingHook(level, x, y, z, player) ); + shared_ptr hook = std::make_shared(level, x, y, z, player); e = hook; // 4J Stu - Move the player->fishing out of the ctor as we cannot reference 'this' player->fishing = hook; @@ -461,10 +461,10 @@ void ClientConnection::handleAddEntity(shared_ptr packet) } break; case AddEntityPacket::ARROW: - e = shared_ptr( new Arrow(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::SNOWBALL: - e = shared_ptr( new Snowball(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::ITEM_FRAME: { @@ -473,64 +473,64 @@ void ClientConnection::handleAddEntity(shared_ptr packet) int iz = (int) z; app.DebugPrintf("ClientConnection ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz); } - e = shared_ptr(new ItemFrame(level, (int) x, (int) y, (int) z, packet->data)); + e = std::make_shared(level, (int)x, (int)y, (int)z, packet->data); packet->data = 0; setRot = false; break; case AddEntityPacket::THROWN_ENDERPEARL: - e = shared_ptr( new ThrownEnderpearl(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::EYEOFENDERSIGNAL: - e = shared_ptr( new EyeOfEnderSignal(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::FIREBALL: - e = shared_ptr( new LargeFireball(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0) ); + e = std::make_shared(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); packet->data = 0; break; case AddEntityPacket::SMALL_FIREBALL: - e = shared_ptr( new SmallFireball(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0) ); + e = std::make_shared(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); packet->data = 0; break; case AddEntityPacket::DRAGON_FIRE_BALL: - e = shared_ptr( new DragonFireball(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0) ); + e = std::make_shared(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); packet->data = 0; break; case AddEntityPacket::EGG: - e = shared_ptr( new ThrownEgg(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::THROWN_POTION: - e = shared_ptr( new ThrownPotion(level, x, y, z, packet->data) ); + e = std::make_shared(level, x, y, z, packet->data); packet->data = 0; break; case AddEntityPacket::THROWN_EXPBOTTLE: - e = shared_ptr( new ThrownExpBottle(level, x, y, z) ); + e = std::make_shared(level, x, y, z); packet->data = 0; break; case AddEntityPacket::BOAT: - e = shared_ptr( new Boat(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::PRIMED_TNT: - e = shared_ptr( new PrimedTnt(level, x, y, z, nullptr) ); + e = std::make_shared(level, x, y, z, std::shared_ptr()); break; case AddEntityPacket::ENDER_CRYSTAL: - e = shared_ptr( new EnderCrystal(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::ITEM: - e = shared_ptr( new ItemEntity(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::FALLING: - e = shared_ptr( new FallingTile(level, x, y, z, packet->data & 0xFFFF, packet->data >> 16) ); + e = std::make_shared(level, x, y, z, packet->data & 0xFFFF, packet->data >> 16); packet->data = 0; break; case AddEntityPacket::WITHER_SKULL: - e = shared_ptr(new WitherSkull(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0)); + e = std::make_shared(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); packet->data = 0; break; case AddEntityPacket::FIREWORKS: - e = shared_ptr(new FireworksRocketEntity(level, x, y, z, nullptr)); + e = std::make_shared(level, x, y, z, std::shared_ptr()); break; case AddEntityPacket::LEASH_KNOT: - e = shared_ptr(new LeashFenceKnotEntity(level, (int) x, (int) y, (int) z)); + e = std::make_shared(level, (int)x, (int)y, (int)z); packet->data = 0; break; #ifndef _FINAL_BUILD @@ -692,7 +692,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) void ClientConnection::handleAddExperienceOrb(shared_ptr packet) { - shared_ptr e = shared_ptr( new ExperienceOrb(level, packet->x / 32.0, packet->y / 32.0, packet->z / 32.0, packet->value) ); + shared_ptr e = std::make_shared(level, packet->x / 32.0, packet->y / 32.0, packet->z / 32.0, packet->value); e->xp = packet->x; e->yp = packet->y; e->zp = packet->z; @@ -708,7 +708,7 @@ void ClientConnection::handleAddGlobalEntity(shared_ptr p double y = packet->y / 32.0; double z = packet->z / 32.0; shared_ptr e;// = nullptr; - if (packet->type == AddGlobalEntityPacket::LIGHTNING) e = shared_ptr( new LightningBolt(level, x, y, z) ); + if (packet->type == AddGlobalEntityPacket::LIGHTNING) e = std::make_shared(level, x, y, z); if (e != nullptr) { e->xp = packet->x; @@ -723,7 +723,7 @@ void ClientConnection::handleAddGlobalEntity(shared_ptr p void ClientConnection::handleAddPainting(shared_ptr packet) { - shared_ptr painting = shared_ptr( new Painting(level, packet->x, packet->y, packet->z, packet->dir, packet->motive) ); + shared_ptr painting = std::make_shared(level, packet->x, packet->y, packet->z, packet->dir, packet->motive); level->putEntity(packet->id, painting); } @@ -792,7 +792,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) double z = packet->z / 32.0; float yRot = packet->yRot * 360 / 256.0f; float xRot = packet->xRot * 360 / 256.0f; - shared_ptr player = shared_ptr( new RemotePlayer(minecraft->level, packet->name) ); + shared_ptr player = std::make_shared(minecraft->level, packet->name); player->xo = player->xOld = player->xp = packet->x; player->yo = player->yOld = player->yp = packet->y; player->zo = player->zOld = player->zp = packet->z; @@ -868,7 +868,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) } else { - player->inventory->items[player->inventory->selected] = shared_ptr( new ItemInstance(item, 1, 0) ); + player->inventory->items[player->inventory->selected] = std::make_shared(item, 1, 0); } player->absMoveTo(x, y, z, yRot, xRot); @@ -877,15 +877,18 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) player->setCustomCape( packet->m_capeId ); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All, packet->m_uiGamePrivileges); - if(!player->customTextureUrl.empty() && player->customTextureUrl.substr(0,3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(player->customTextureUrl)) - { - if( minecraft->addPendingClientTextureRequest(player->customTextureUrl) ) - { - app.DebugPrintf("Client sending TextureAndGeometryPacket to get custom skin %ls for player %ls\n",player->customTextureUrl.c_str(), player->name.c_str()); + if (!player->customTextureUrl.empty() && player->customTextureUrl.substr(0, 3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(player->customTextureUrl)) + { + if (minecraft->addPendingClientTextureRequest(player->customTextureUrl)) + { + app.DebugPrintf("Client sending TextureAndGeometryPacket to get custom skin %ls for player %ls\n", player->customTextureUrl.c_str(), player->name.c_str()); - send(shared_ptr( new TextureAndGeometryPacket(player->customTextureUrl,nullptr,0) ) ); - } - } + send(std::make_shared( + player->customTextureUrl, + nullptr, + static_cast(0))); + } + } else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl)) { // Update the ref count on the memory texture data @@ -899,7 +902,11 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) if( minecraft->addPendingClientTextureRequest(player->customTextureUrl2) ) { app.DebugPrintf("Client sending texture packet to get custom cape %ls for player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str()); - send(shared_ptr( new TexturePacket(player->customTextureUrl2,nullptr,0) ) ); + send(std::make_shared( + player->customTextureUrl2, + nullptr, + static_cast(0) + )); } } else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2)) @@ -1402,7 +1409,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr pac level->playSound(from, eSoundType_RANDOM_POP, 0.2f, ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f); } - minecraft->particleEngine->add( shared_ptr( new TakeAnimationParticle(minecraft->level, from, to, -0.5f) ) ); + minecraft->particleEngine->add(std::make_shared(minecraft->level, from, to, -0.5f)); level->removeEntity(packet->itemId); } else @@ -1415,7 +1422,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr pac else { level->playSound(from, eSoundType_RANDOM_POP, 0.2f, ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f); - minecraft->particleEngine->add( shared_ptr( new TakeAnimationParticle(minecraft->level, from, to, -0.5f) ) ); + minecraft->particleEngine->add(std::make_shared(minecraft->level, from, to, -0.5f)); level->removeEntity(packet->itemId); } } @@ -1848,13 +1855,13 @@ void ClientConnection::handleAnimate(shared_ptr packet) } else if (packet->action == AnimatePacket::CRITICAL_HIT) { - shared_ptr critParticle = shared_ptr( new CritParticle(minecraft->level, e) ); + shared_ptr critParticle = std::make_shared(minecraft->level, e); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add( critParticle ); } else if (packet->action == AnimatePacket::MAGIC_CRITICAL_HIT) { - shared_ptr critParticle = shared_ptr( new CritParticle(minecraft->level, e, eParticleType_magicCrit) ); + shared_ptr critParticle = std::make_shared(minecraft->level, e, eParticleType_magicCrit); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add(critParticle); } @@ -2326,8 +2333,8 @@ void ClientConnection::handlePreLogin(shared_ptr packet) } BOOL allAllowed, friendsAllowed; ProfileManager.AllowedPlayerCreatedContent(m_userIndex,true,&allAllowed,&friendsAllowed); - send( shared_ptr( new LoginPacket(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (allAllowed!=TRUE && friendsAllowed==TRUE), - packet->m_ugcPlayersVersion, app.GetPlayerSkinId(m_userIndex), app.GetPlayerCapeId(m_userIndex), ProfileManager.IsGuest( m_userIndex )))); + send(std::make_shared(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (allAllowed != TRUE && friendsAllowed == TRUE), + packet->m_ugcPlayersVersion, app.GetPlayerSkinId(m_userIndex), app.GetPlayerCapeId(m_userIndex), ProfileManager.IsGuest(m_userIndex))); if(!g_NetworkManager.IsHost() ) { @@ -2550,7 +2557,7 @@ void ClientConnection::handleTexture(shared_ptr packet) if(dwBytes!=0) { - send( shared_ptr( new TexturePacket(packet->textureName,pbData,dwBytes) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes)); } } else @@ -2587,18 +2594,18 @@ void ClientConnection::handleTextureAndGeometry(shared_ptrgetAdditionalBoxesCount()!=0) { - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwBytes,pDLCSkinFile) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes, pDLCSkinFile)); } else { - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwBytes) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes)); } } else { unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID); - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwBytes,app.GetAdditionalSkinBoxes(packet->dwSkinID),uiAnimOverrideBitmask) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes, app.GetAdditionalSkinBoxes(packet->dwSkinID), uiAnimOverrideBitmask)); } } } @@ -2667,7 +2674,10 @@ void ClientConnection::handleTextureChange(shared_ptr packe #ifndef _CONTENT_PACKAGE wprintf(L"handleTextureChange - Client sending texture packet to get custom skin %ls for player %ls\n",packet->path.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TexturePacket(packet->path,nullptr,0) ) ); + send(std::make_shared( + player->customTextureUrl, + nullptr, + static_cast(0))); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) @@ -2712,7 +2722,10 @@ void ClientConnection::handleTextureAndGeometryChange(shared_ptrpath.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TextureAndGeometryPacket(packet->path,nullptr,0) ) ); + send(std::make_shared( + packet->path, + nullptr, + static_cast(0))); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) @@ -2895,7 +2908,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe default: assert(false); chestString = -1; break; } - if( player->openContainer(shared_ptr( new SimpleContainer(chestString, packet->title, packet->customName, packet->size) ))) + if( player->openContainer(std::make_shared(chestString, packet->title, packet->customName, packet->size))) { player->containerMenu->containerId = packet->containerId; } @@ -2907,7 +2920,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::HOPPER: { - shared_ptr hopper = shared_ptr(new HopperTileEntity()); + shared_ptr hopper = std::make_shared(); if (packet->customName) hopper->setCustomName(packet->title); if(player->openHopper(hopper)) { @@ -2921,7 +2934,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::FURNACE: { - shared_ptr furnace = shared_ptr(new FurnaceTileEntity()); + shared_ptr furnace = std::make_shared(); if (packet->customName) furnace->setCustomName(packet->title); if(player->openFurnace(furnace)) { @@ -2935,7 +2948,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::BREWING_STAND: { - shared_ptr brewingStand = shared_ptr(new BrewingStandTileEntity()); + shared_ptr brewingStand = std::make_shared(); if (packet->customName) brewingStand->setCustomName(packet->title); if( player->openBrewingStand(brewingStand)) @@ -2950,7 +2963,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::DROPPER: { - shared_ptr dropper = shared_ptr(new DropperTileEntity()); + shared_ptr dropper = std::make_shared(); if (packet->customName) dropper->setCustomName(packet->title); if( player->openTrap(dropper)) @@ -2965,7 +2978,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::TRAP: { - shared_ptr dispenser = shared_ptr(new DispenserTileEntity()); + shared_ptr dispenser = std::make_shared(); if (packet->customName) dispenser->setCustomName(packet->title); if( player->openTrap(dispenser)) @@ -3004,7 +3017,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::TRADER_NPC: { - shared_ptr csm = shared_ptr(new ClientSideMerchant(player, packet->title)); + shared_ptr csm = std::make_shared(player, packet->title); csm->createContainer(); if(player->openTrading(csm, packet->customName ? packet->title : L"")) { @@ -3018,7 +3031,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::BEACON: { - shared_ptr beacon = shared_ptr(new BeaconTileEntity()); + shared_ptr beacon = std::make_shared(); if (packet->customName) beacon->setCustomName(packet->title); if(player->openBeacon(beacon)) @@ -3056,7 +3069,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe iTitle = IDS_MULE; break; }; - if(player->openHorseInventory(dynamic_pointer_cast(entity), shared_ptr(new AnimalChest(iTitle, packet->title, packet->customName, packet->size)))) + if(player->openHorseInventory(dynamic_pointer_cast(entity), std::make_shared(iTitle, packet->title, packet->customName, packet->size))) { player->containerMenu->containerId = packet->containerId; } @@ -3091,7 +3104,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe } else { - send(shared_ptr(new ContainerClosePacket(packet->containerId))); + send(std::make_shared(packet->containerId)); } } } @@ -3144,7 +3157,7 @@ void ClientConnection::handleContainerAck(shared_ptr packet) { if (!packet->accepted) { - send( shared_ptr( new ContainerAckPacket(packet->containerId, packet->uid, true) )); + send(std::make_shared(packet->containerId, packet->uid, true)); } } } @@ -3171,7 +3184,7 @@ void ClientConnection::handleTileEditorOpen(shared_ptr pac } else if (packet->editorType == TileEditorOpenPacket::SIGN) { - shared_ptr localSignDummy = shared_ptr(new SignTileEntity()); + shared_ptr localSignDummy = std::make_shared(); localSignDummy->setLevel(level); localSignDummy->x = packet->x; localSignDummy->y = packet->y; @@ -3576,7 +3589,7 @@ void ClientConnection::displayPrivilegeChanges(shared_ptr packet) { - send(shared_ptr(new KeepAlivePacket(packet->id))); + send(std::make_shared(packet->id)); } void ClientConnection::handlePlayerAbilities(shared_ptr playerAbilitiesPacket) diff --git a/Minecraft.Client/Common/Audio/miniaudio.h b/Minecraft.Client/Common/Audio/miniaudio.h index f5997a42b..87cb06bec 100644 --- a/Minecraft.Client/Common/Audio/miniaudio.h +++ b/Minecraft.Client/Common/Audio/miniaudio.h @@ -3843,11 +3843,6 @@ typedef void* ma_proc; typedef ma_uint16 wchar_t; #endif -/* Define nullptr for some compilers. */ -#ifndef nullptr -#define nullptr 0 -#endif - #if defined(SIZE_MAX) #define MA_SIZE_MAX SIZE_MAX #else diff --git a/Minecraft.Client/Common/DLC/DLCManager.cpp b/Minecraft.Client/Common/DLC/DLCManager.cpp index 5fc5f3704..4a2dc2c72 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Common/DLC/DLCManager.cpp @@ -6,6 +6,7 @@ #include "..\..\..\Minecraft.World\StringHelpers.h" #include "..\..\Minecraft.h" #include "..\..\TexturePackRepository.h" +#include "Common/UI/UI.h" WCHAR *DLCManager::wchTypeNamesA[]= { diff --git a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp index 270909ecd..49809d0c5 100644 --- a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp @@ -100,7 +100,7 @@ bool AddItemRuleDefinition::addItemToContainer(shared_ptr container, if(Item::items[m_itemId] != nullptr) { int quantity = std::min(m_quantity, Item::items[m_itemId]->getMaxStackSize()); - shared_ptr newItem = shared_ptr(new ItemInstance(m_itemId,quantity,m_auxValue) ); + shared_ptr newItem = std::make_shared(m_itemId, quantity, m_auxValue); newItem->set4JData(m_dataTag); for( auto& it : m_enchantments ) diff --git a/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp index 85d382192..7f03a0fef 100644 --- a/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp @@ -90,13 +90,21 @@ bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptr= m_quantity) { setComplete(rule, true); - app.DebugPrintf("Completed CollectItemRule with info - itemId:%d, auxValue:%d, quantity:%d, dataTag:%d\n", m_itemId,m_auxValue,m_quantity,m_4JDataValue); + app.DebugPrintf("Completed CollectItemRule with info - itemId:%d, auxValue:%d, quantity:%d, dataTag:%d\n", m_itemId, m_auxValue, m_quantity, m_4JDataValue); - if(rule->getConnection() != nullptr) - { - rule->getConnection()->send( shared_ptr( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId, m_itemId, m_auxValue, this->m_4JDataValue,nullptr,0))); - } - } + if (rule->getConnection() != nullptr) + { + rule->getConnection()->send(std::make_shared( + getActionType(), + this->m_descriptionId, + m_itemId, + m_auxValue, + this->m_4JDataValue, + nullptr, + static_cast(0) + )); + } + } } } return statusChanged; diff --git a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp index ef83b32c0..cd23cd504 100644 --- a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp @@ -51,7 +51,7 @@ void CompleteAllRuleDefinition::updateStatus(GameRule *rule) auxValue = m_lastRuleStatusChanged->getAuxValue(); m_lastRuleStatusChanged = nullptr; } - rule->getConnection()->send( shared_ptr( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId,icon, auxValue, 0,&data,sizeof(PacketData)))); + rule->getConnection()->send(std::make_shared(getActionType(), this->m_descriptionId, icon, auxValue, 0, &data, sizeof(PacketData))); } app.DebugPrintf("Updated CompleteAllRule - Completed %d of %d\n", progress, goal); } diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Common/Network/GameNetworkManager.cpp index 7d282db5d..133a2dfcf 100644 --- a/Minecraft.Client/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/GameNetworkManager.cpp @@ -394,7 +394,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame return false; } - connection->send( shared_ptr( new PreLoginPacket(minecraft->user->name) ) ); + connection->send(std::make_shared(minecraft->user->name)); // Tick connection until we're ready to go. The stages involved in this are: // (1) Creating the ClientConnection sends a prelogin packet to the server @@ -481,7 +481,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame // Open the socket on the server end to accept incoming data Socket::addIncomingSocket(socket); - connection->send( shared_ptr( new PreLoginPacket(convStringToWstring( ProfileManager.GetGamertag(idx) )) ) ); + connection->send(std::make_shared(convStringToWstring(ProfileManager.GetGamertag(idx)))); createdConnections.push_back( connection ); @@ -1523,7 +1523,7 @@ void CGameNetworkManager::CreateSocket( INetworkPlayer *pNetworkPlayer, bool loc if( connection->createdOk ) { - connection->send( shared_ptr( new PreLoginPacket( pNetworkPlayer->GetOnlineName() ) ) ); + connection->send(std::make_shared(pNetworkPlayer->GetOnlineName())); pMinecraft->addPendingLocalConnection(idx, connection); } else diff --git a/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp b/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp index df2f5b2b2..06e73d6f7 100644 --- a/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp +++ b/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp @@ -63,7 +63,7 @@ void ChangeStateConstraint::tick(int iPad) shared_ptr player = minecraft->localplayers[iPad]; if(player != nullptr && player->connection && player->connection->getNetworkPlayer() != nullptr) { - player->connection->send( shared_ptr( new PlayerInfoPacket( player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs) ) ); + player->connection->send(std::make_shared(player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs)); } } } @@ -104,7 +104,7 @@ void ChangeStateConstraint::tick(int iPad) shared_ptr player = minecraft->localplayers[iPad]; if(player != nullptr && player->connection && player->connection->getNetworkPlayer() != nullptr) { - player->connection->send( shared_ptr( new PlayerInfoPacket( player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs) ) ); + player->connection->send(std::make_shared(player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs)); } } } @@ -128,7 +128,7 @@ void ChangeStateConstraint::tick(int iPad) shared_ptr player = minecraft->localplayers[iPad]; if(player != nullptr && player->connection && player->connection->getNetworkPlayer() != nullptr) { - player->connection->send( shared_ptr( new PlayerInfoPacket( player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs) ) ); + player->connection->send(std::make_shared(player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs)); } } } diff --git a/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp b/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp index 987ad6eb1..023e4b22c 100644 --- a/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp +++ b/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp @@ -8,10 +8,11 @@ #include "ChoiceTask.h" #include "..\..\..\Minecraft.World\Material.h" #include "..\..\Windows64\KeyboardMouseInput.h" +#include "Common/UI/UI.h" ChoiceTask::ChoiceTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/, - int iConfirmMapping /*= 0*/, int iCancelMapping /*= 0*/, - eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) + int iConfirmMapping /*= 0*/, int iCancelMapping /*= 0*/, + eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) : TutorialTask( tutorial, descriptionId, false, nullptr, true, false, false ) { if(requiresUserInput == true) diff --git a/Minecraft.Client/Common/Tutorial/InfoTask.cpp b/Minecraft.Client/Common/Tutorial/InfoTask.cpp index 340ea5187..2e4818047 100644 --- a/Minecraft.Client/Common/Tutorial/InfoTask.cpp +++ b/Minecraft.Client/Common/Tutorial/InfoTask.cpp @@ -8,9 +8,10 @@ #include "InfoTask.h" #include "..\..\..\Minecraft.World\Material.h" #include "..\..\Windows64\KeyboardMouseInput.h" +#include "Common/UI/UI.h" InfoTask::InfoTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/, - int iMapping /*= 0*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) + int iMapping /*= 0*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) : TutorialTask( tutorial, descriptionId, false, nullptr, true, false, false ) { if(requiresUserInput == true) diff --git a/Minecraft.Client/Common/Tutorial/Tutorial.cpp b/Minecraft.Client/Common/Tutorial/Tutorial.cpp index 0e6bf3468..c985ef491 100644 --- a/Minecraft.Client/Common/Tutorial/Tutorial.cpp +++ b/Minecraft.Client/Common/Tutorial/Tutorial.cpp @@ -17,6 +17,7 @@ #include "TutorialTasks.h" #include "TutorialConstraints.h" #include "TutorialHints.h" +#include "Common/UI/UI.h" vector Tutorial::s_completableTasks; diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp index 6df5571a8..d607d8754 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -2,6 +2,7 @@ #include "IUIScene_AbstractContainerMenu.h" +#include "UI.h" #include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" #include "..\..\..\Minecraft.World\net.minecraft.world.item.h" #include "..\..\..\Minecraft.World\net.minecraft.world.item.crafting.h" diff --git a/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp index 2c1469bcd..1e6fa6fa0 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp @@ -245,7 +245,7 @@ void IUIScene_AnvilMenu::updateItemName() ByteArrayOutputStream baos; DataOutputStream dos(&baos); dos.writeUTF(m_itemName); - Minecraft::GetInstance()->localplayers[getPad()]->connection->send(shared_ptr(new CustomPayloadPacket(CustomPayloadPacket::SET_ITEM_NAME_PACKET, baos.toByteArray()))); + Minecraft::GetInstance()->localplayers[getPad()]->connection->send(std::make_shared(CustomPayloadPacket::SET_ITEM_NAME_PACKET, baos.toByteArray())); } void IUIScene_AnvilMenu::refreshContainer(AbstractContainerMenu *container, vector > *items) diff --git a/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp index efe4c2e11..3dede3d94 100644 --- a/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp @@ -222,7 +222,7 @@ void IUIScene_BeaconMenu::handleOtherClicked(int iPad, ESceneSection eSection, i dos.writeInt(m_beacon->getPrimaryPower()); dos.writeInt(m_beacon->getSecondaryPower()); - Minecraft::GetInstance()->localplayers[getPad()]->connection->send(shared_ptr(new CustomPayloadPacket(CustomPayloadPacket::SET_BEACON_PACKET, baos.toByteArray()))); + Minecraft::GetInstance()->localplayers[getPad()]->connection->send(std::make_shared(CustomPayloadPacket::SET_BEACON_PACKET, baos.toByteArray())); if (m_beacon->getPrimaryPower() > 0) { diff --git a/Minecraft.Client/Common/UI/IUIScene_CommandBlockMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CommandBlockMenu.cpp index 4371b4e58..3af01678e 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CommandBlockMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CommandBlockMenu.cpp @@ -20,6 +20,6 @@ void IUIScene_CommandBlockMenu::ConfirmButtonClicked() dos.writeInt(m_commandBlock->z); dos.writeUTF(GetCommand()); - Minecraft::GetInstance()->localplayers[GetPad()]->connection->send(shared_ptr(new CustomPayloadPacket(CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET, baos.toByteArray()))); + Minecraft::GetInstance()->localplayers[GetPad()]->connection->send(std::make_shared(CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET, baos.toByteArray())); } diff --git a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp index e056fd68b..6fddece9c 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp @@ -6,6 +6,8 @@ #include "..\..\LocalPlayer.h" #include "IUIScene_CraftingMenu.h" +#include "UI.h" + Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping4GridA[IUIScene_CraftingMenu::m_iMaxGroup2x2]= { Recipy::eGroupType_Structure, @@ -293,7 +295,7 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) if (ingItemInst->getItem()->hasCraftingRemainingItem()) { // replace item with remaining result - m_pPlayer->inventory->add( shared_ptr( new ItemInstance(ingItemInst->getItem()->getCraftingRemainingItem()) ) ); + m_pPlayer->inventory->add(std::make_shared(ingItemInst->getItem()->getCraftingRemainingItem())); } } @@ -1071,7 +1073,7 @@ void IUIScene_CraftingMenu::DisplayIngredients() int iAuxVal=pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]; Item *item = Item::items[id]; - shared_ptr itemInst= shared_ptr(new ItemInstance(item,pRecipeIngredientsRequired[iRecipe].iIngValA[i],iAuxVal)); + shared_ptr itemInst= std::make_shared(item, pRecipeIngredientsRequired[iRecipe].iIngValA[i], iAuxVal); // 4J-PB - a very special case - the bed can use any kind of wool, so we can't use the item description // and the same goes for the painting @@ -1156,7 +1158,7 @@ void IUIScene_CraftingMenu::DisplayIngredients() { iAuxVal = 1; } - shared_ptr itemInst= shared_ptr(new ItemInstance(id,1,iAuxVal)); + shared_ptr itemInst= std::make_shared(id, 1, iAuxVal); setIngredientSlotItem(getPad(),index,itemInst); // show the ingredients we don't have if we can't make the recipe if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L< > IUIScene_CreativeMenu::categoryGroups[eCreati #define ITEM_AUX(id, aux) list->push_back( shared_ptr(new ItemInstance(id, 1, aux)) ); #define DEF(index) list = &categoryGroups[index]; - void IUIScene_CreativeMenu::staticCtor() { vector< shared_ptr > *list; @@ -495,7 +495,7 @@ void IUIScene_CreativeMenu::staticCtor() #ifndef _CONTENT_PACKAGE if(app.DebugSettingsOn()) { - shared_ptr debugSword = shared_ptr(new ItemInstance(Item::sword_diamond_Id, 1, 0)); + shared_ptr debugSword = std::make_shared(Item::sword_diamond_Id, 1, 0); debugSword->enchant( Enchantment::damageBonus, 50 ); debugSword->setHoverName(L"Sword of Debug"); list->push_back(debugSword); @@ -1362,7 +1362,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector > *lis shared_ptr firework; { - firework = shared_ptr( new ItemInstance(Item::fireworks) ); + firework = std::make_shared(Item::fireworks); CompoundTag *itemTag = new CompoundTag(); CompoundTag *fireTag = new CompoundTag(FireworksItem::TAG_FIREWORKS); ListTag *expTags = new ListTag(FireworksItem::TAG_EXPLOSIONS); diff --git a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp index 27c62a13e..fd9779665 100644 --- a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp @@ -7,6 +7,8 @@ #include "..\..\..\Minecraft.World\net.minecraft.world.entity.monster.h" #include "IUIScene_HUD.h" +#include "UI.h" + IUIScene_HUD::IUIScene_HUD() { m_lastActiveSlot = -1; diff --git a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp index 1f9cf7bd9..f45a00430 100644 --- a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp @@ -8,6 +8,8 @@ #include "..\..\ClientConnection.h" #include "IUIScene_TradingMenu.h" +#include "UI.h" + IUIScene_TradingMenu::IUIScene_TradingMenu() { m_validOffersCount = 0; @@ -95,7 +97,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) } // Send a packet to the server - player->connection->send( shared_ptr( new TradeItemPacket(m_menu->containerId, actualShopItem) ) ); + player->connection->send(std::make_shared(m_menu->containerId, actualShopItem)); updateDisplay(); } @@ -152,7 +154,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) ByteArrayOutputStream rawOutput; DataOutputStream output(&rawOutput); output.writeInt(actualShopItem); - Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()))); + Minecraft::GetInstance()->getConnection(getPad())->send(std::make_shared(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())); } } return handled; @@ -205,7 +207,7 @@ void IUIScene_TradingMenu::updateDisplay() ByteArrayOutputStream rawOutput; DataOutputStream output(&rawOutput); output.writeInt(firstValidTrade); - Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()))); + Minecraft::GetInstance()->getConnection(getPad())->send(std::make_shared(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())); } } diff --git a/Minecraft.Client/Common/UI/UI.h b/Minecraft.Client/Common/UI/UI.h index 428b3b904..a7c416f8e 100644 --- a/Minecraft.Client/Common/UI/UI.h +++ b/Minecraft.Client/Common/UI/UI.h @@ -123,4 +123,6 @@ #include "UIScene_TeleportMenu.h" #include "UIScene_EndPoem.h" #include "UIScene_EULA.h" -#include "UIScene_NewUpdateMessage.h" \ No newline at end of file +#include "UIScene_NewUpdateMessage.h" + +extern ConsoleUIController ui; \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp index 06dcd64ca..c1381c44c 100644 --- a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp @@ -212,7 +212,7 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, if( icon != TUTORIAL_NO_ICON ) { m_iconIsFoil = false; - m_iconItem = shared_ptr(new ItemInstance(icon,1,iAuxVal)); + m_iconItem = std::make_shared(icon, 1, iAuxVal); } else { @@ -241,7 +241,7 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, { iAuxVal = 0; } - m_iconItem = shared_ptr(new ItemInstance(iconId,1,iAuxVal)); + m_iconItem = std::make_shared(iconId, 1, iAuxVal); temp.replace(iconTagStartPos, iconEndPos - iconTagStartPos + closeTag.length(), L""); } @@ -250,63 +250,63 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, // remove any icon text else if(temp.find(L"{*CraftingTableIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::workBench_Id,1,0)); + m_iconItem = std::make_shared(Tile::workBench_Id, 1, 0); } else if(temp.find(L"{*SticksIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::stick_Id,1,0)); + m_iconItem = std::make_shared(Item::stick_Id, 1, 0); } else if(temp.find(L"{*PlanksIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::wood_Id,1,0)); + m_iconItem = std::make_shared(Tile::wood_Id, 1, 0); } else if(temp.find(L"{*WoodenShovelIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::shovel_wood_Id,1,0)); + m_iconItem = std::make_shared(Item::shovel_wood_Id, 1, 0); } else if(temp.find(L"{*WoodenHatchetIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::hatchet_wood_Id,1,0)); + m_iconItem = std::make_shared(Item::hatchet_wood_Id, 1, 0); } else if(temp.find(L"{*WoodenPickaxeIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::pickAxe_wood_Id,1,0)); + m_iconItem = std::make_shared(Item::pickAxe_wood_Id, 1, 0); } else if(temp.find(L"{*FurnaceIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::furnace_Id,1,0)); + m_iconItem = std::make_shared(Tile::furnace_Id, 1, 0); } else if(temp.find(L"{*WoodenDoorIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::door_wood,1,0)); + m_iconItem = std::make_shared(Item::door_wood, 1, 0); } else if(temp.find(L"{*TorchIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::torch_Id,1,0)); + m_iconItem = std::make_shared(Tile::torch_Id, 1, 0); } else if(temp.find(L"{*BoatIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::boat_Id,1,0)); + m_iconItem = std::make_shared(Item::boat_Id, 1, 0); } else if(temp.find(L"{*FishingRodIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::fishingRod_Id,1,0)); + m_iconItem = std::make_shared(Item::fishingRod_Id, 1, 0); } else if(temp.find(L"{*FishIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::fish_raw_Id,1,0)); + m_iconItem = std::make_shared(Item::fish_raw_Id, 1, 0); } else if(temp.find(L"{*MinecartIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::minecart_Id,1,0)); + m_iconItem = std::make_shared(Item::minecart_Id, 1, 0); } else if(temp.find(L"{*RailIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::rail_Id,1,0)); + m_iconItem = std::make_shared(Tile::rail_Id, 1, 0); } else if(temp.find(L"{*PoweredRailIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::goldenRail_Id,1,0)); + m_iconItem = std::make_shared(Tile::goldenRail_Id, 1, 0); } else if(temp.find(L"{*StructuresIcon*}")!=wstring::npos) { @@ -320,7 +320,7 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, } else if(temp.find(L"{*StoneIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::stone_Id,1,0)); + m_iconItem = std::make_shared(Tile::stone_Id, 1, 0); } else { diff --git a/Minecraft.Client/Common/UI/UIGroup.cpp b/Minecraft.Client/Common/UI/UIGroup.cpp index be9054c99..ab62e4c46 100644 --- a/Minecraft.Client/Common/UI/UIGroup.cpp +++ b/Minecraft.Client/Common/UI/UIGroup.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "UIGroup.h" +#include "UI.h" + UIGroup::UIGroup(EUIGroup group, int iPad) { m_group = group; diff --git a/Minecraft.Client/Common/UI/UIScene.cpp b/Minecraft.Client/Common/UI/UIScene.cpp index 9029e9ffc..d3b79c3f2 100644 --- a/Minecraft.Client/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Common/UI/UIScene.cpp @@ -389,21 +389,22 @@ void UIScene::loadMovie() void UIScene::getDebugMemoryUseRecursive(const wstring &moviePath, IggyMemoryUseInfo &memoryInfo) { - rrbool res; - IggyMemoryUseInfo internalMemoryInfo; - int internalIteration = 0; - while(res = IggyDebugGetMemoryUseInfo ( swf , - nullptr , - memoryInfo.subcategory , - memoryInfo.subcategory_stringlen , - internalIteration , - &internalMemoryInfo )) - { - app.DebugPrintf(app.USER_SR, "%ls - %.*s static: %d ( %d ) dynamic: %d ( %d )\n", moviePath.c_str(), internalMemoryInfo.subcategory_stringlen, internalMemoryInfo.subcategory, - internalMemoryInfo.static_allocation_bytes, internalMemoryInfo.static_allocation_count, internalMemoryInfo.dynamic_allocation_bytes, internalMemoryInfo.dynamic_allocation_count); - ++internalIteration; - if(internalMemoryInfo.subcategory_stringlen > memoryInfo.subcategory_stringlen) getDebugMemoryUseRecursive(moviePath, internalMemoryInfo); - } + rrbool res; + IggyMemoryUseInfo internalMemoryInfo; + int internalIteration = 0; + while (res = IggyDebugGetMemoryUseInfo(swf, + 0, + memoryInfo.subcategory, + memoryInfo.subcategory_stringlen, + internalIteration, + &internalMemoryInfo)) + { + app.DebugPrintf(app.USER_SR, "%ls - %.*s static: %d ( %d ) dynamic: %d ( %d )\n", moviePath.c_str(), internalMemoryInfo.subcategory_stringlen, internalMemoryInfo.subcategory, + internalMemoryInfo.static_allocation_bytes, internalMemoryInfo.static_allocation_count, internalMemoryInfo.dynamic_allocation_bytes, internalMemoryInfo.dynamic_allocation_count); + ++internalIteration; + if (internalMemoryInfo.subcategory_stringlen > memoryInfo.subcategory_stringlen) + getDebugMemoryUseRecursive(moviePath, internalMemoryInfo); + } } void UIScene::PrintTotalMemoryUsage(__int64 &totalStatic, __int64 &totalDynamic) @@ -416,7 +417,7 @@ void UIScene::PrintTotalMemoryUsage(__int64 &totalStatic, __int64 &totalDynamic) __int64 sceneStatic = 0; __int64 sceneDynamic = 0; while(res = IggyDebugGetMemoryUseInfo ( swf , - nullptr , + 0 , "" , 0 , iteration , diff --git a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp index cf1ff7f33..64e123736 100644 --- a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp @@ -336,16 +336,16 @@ void UIScene_BeaconMenu::customDraw(IggyCustomDrawCallbackRegion *region) switch(icon) { case 0: - item = shared_ptr(new ItemInstance(Item::emerald) ); + item = std::make_shared(Item::emerald); break; case 1: - item = shared_ptr(new ItemInstance(Item::diamond) ); + item = std::make_shared(Item::diamond); break; case 2: - item = shared_ptr(new ItemInstance(Item::goldIngot) ); + item = std::make_shared(Item::goldIngot); break; case 3: - item = shared_ptr(new ItemInstance(Item::ironIngot) ); + item = std::make_shared(Item::ironIngot); break; default: assert(false); diff --git a/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp index 1ac0c91a0..ba2cd8452 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp @@ -21,7 +21,7 @@ UIScene_CreativeMenu::UIScene_CreativeMenu(int iPad, void *_initData, UILayer *p InventoryScreenInput *initData = static_cast(_initData); - shared_ptr creativeContainer = shared_ptr(new SimpleContainer( 0, L"", false, TabSpec::MAX_SIZE )); + shared_ptr creativeContainer = std::make_shared(0, L"", false, TabSpec::MAX_SIZE); itemPickerMenu = new ItemPickerMenu(creativeContainer, initData->player->inventory); Initialize( initData->iPad, itemPickerMenu, false, -1, eSectionInventoryCreativeUsing, eSectionInventoryCreativeMax, initData->bNavigateBack); diff --git a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp index eed4bbe1b..d6381dd0a 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp @@ -147,7 +147,7 @@ void UIScene_DebugOverlay::customDraw(IggyCustomDrawCallbackRegion *region) } else { - shared_ptr item = shared_ptr( new ItemInstance(itemId,1,0) ); + shared_ptr item = std::make_shared(itemId, 1, 0); if(item != nullptr) customDrawSlotControl(region,m_iPad,item,1.0f,false,false); } } diff --git a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp index 0dfde06d6..e89c06261 100644 --- a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp @@ -4,7 +4,6 @@ #include "..\..\Minecraft.h" #include "..\..\ProgressRenderer.h" - UIScene_FullscreenProgress::UIScene_FullscreenProgress(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { // Setup all the Iggy references we need for this scene diff --git a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp index 72f9e4fd2..51992e322 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp @@ -126,7 +126,7 @@ void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat, shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player->connection) { - player->connection->send( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions) ) ); + player->connection->send(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions)); } } diff --git a/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp index dc11b524d..7fc3d0357 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp @@ -448,7 +448,7 @@ int UIScene_InGameInfoMenu::KickPlayerReturned(void *pParam,int iPad,C4JStorage: shared_ptr localPlayer = pMinecraft->localplayers[iPad]; if(localPlayer->connection) { - localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); + localPlayer->connection->send(std::make_shared(smallId)); } } diff --git a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp index fb570fdc4..ca28cb7ef 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp @@ -6,7 +6,6 @@ #include "..\..\ClientConnection.h" #include "..\..\..\Minecraft.World\net.minecraft.network.packet.h" - #define CHECKBOXES_TIMER_ID 0 #define CHECKBOXES_TIMER_TIME 100 @@ -405,7 +404,7 @@ void UIScene_InGamePlayerOptionsMenu::handleInput(int iPad, int key, bool repeat shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player->connection) { - player->connection->send( shared_ptr( new PlayerInfoPacket( m_networkSmallId, -1, m_playerPrivileges) ) ); + player->connection->send(std::make_shared(m_networkSmallId, -1, m_playerPrivileges)); } } navigateBack(); @@ -455,7 +454,7 @@ int UIScene_InGamePlayerOptionsMenu::KickPlayerReturned(void *pParam,int iPad,C4 shared_ptr localPlayer = pMinecraft->localplayers[iPad]; if(localPlayer->connection) { - localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); + localPlayer->connection->send(std::make_shared(smallId)); } // Fix for #61494 - [CRASH]: TU7: Code: Multiplayer: Title may crash while kicking a player from an online game. diff --git a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp index a5b8947b3..ed0b3151f 100644 --- a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp @@ -9,12 +9,12 @@ #define PLAYER_ONLINE_TIMER_TIME 100 // if the value is greater than 32000, it's an xzp icon that needs displayed, rather than the game icon -const int UIScene_LeaderboardsMenu::TitleIcons[UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][7] = +const int UIScene_LeaderboardsMenu::TitleIcons[UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][7] = { - { UIControl_LeaderboardList::e_ICON_TYPE_WALKED, UIControl_LeaderboardList::e_ICON_TYPE_FALLEN, Item::minecart_Id, Item::boat_Id, nullptr }, - { Tile::dirt_Id, Tile::cobblestone_Id, Tile::sand_Id, Tile::stone_Id, Tile::gravel_Id, Tile::clay_Id, Tile::obsidian_Id }, - { Item::egg_Id, Item::wheat_Id, Tile::mushroom_brown_Id, Tile::reeds_Id, Item::bucket_milk_Id, Tile::pumpkin_Id, nullptr }, - { UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIE, UIControl_LeaderboardList::e_ICON_TYPE_SKELETON, UIControl_LeaderboardList::e_ICON_TYPE_CREEPER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDERJOKEY, UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIEPIGMAN, UIControl_LeaderboardList::e_ICON_TYPE_SLIME }, + {UIControl_LeaderboardList::e_ICON_TYPE_WALKED, UIControl_LeaderboardList::e_ICON_TYPE_FALLEN, Item::minecart_Id, Item::boat_Id, -1}, + {Tile::dirt_Id, Tile::cobblestone_Id, Tile::sand_Id, Tile::stone_Id, Tile::gravel_Id, Tile::clay_Id, Tile::obsidian_Id}, + {Item::egg_Id, Item::wheat_Id, Tile::mushroom_brown_Id, Tile::reeds_Id, Item::bucket_milk_Id, Tile::pumpkin_Id, -1}, + {UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIE, UIControl_LeaderboardList::e_ICON_TYPE_SKELETON, UIControl_LeaderboardList::e_ICON_TYPE_CREEPER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDERJOKEY, UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIEPIGMAN, UIControl_LeaderboardList::e_ICON_TYPE_SLIME}, }; const UIScene_LeaderboardsMenu::LeaderboardDescriptor UIScene_LeaderboardsMenu::LEADERBOARD_DESCRIPTORS[UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][4] = { { @@ -971,7 +971,7 @@ void UIScene_LeaderboardsMenu::customDraw(IggyCustomDrawCallbackRegion *region) } else { - shared_ptr item = shared_ptr( new ItemInstance(TitleIcons[m_currentLeaderboard][slotId], 1, 0) ); + shared_ptr item = std::make_shared(TitleIcons[m_currentLeaderboard][slotId], 1, 0); customDrawSlotControl(region,m_iPad,item,1.0f,false,false); } } diff --git a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp index 679daff1e..72e30a339 100644 --- a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp @@ -97,7 +97,7 @@ void UIScene_SignEntryMenu::tick() shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player != nullptr && player->connection && player->connection->isStarted()) { - player->connection->send( shared_ptr( new SignUpdatePacket(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages()) ) ); + player->connection->send(std::make_shared(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages())); } } ui.CloseUIScenes(m_iPad); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp index 49217c5cd..9b64dbcb5 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp @@ -188,7 +188,7 @@ HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender *pRenderData, BOOL &bHa { HXUIDC hDC = pRenderData->hDC; CXuiControl xuiControl(m_hObj); - if(m_item == nullptr) m_item = shared_ptr( new ItemInstance(m_iID, m_iCount, m_iAuxVal) ); + if(m_item == nullptr) m_item = std::make_shared(m_iID, m_iCount, m_iAuxVal); // build and render with the game call diff --git a/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp b/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp index 01a4b573b..d8c06ae14 100644 --- a/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp @@ -60,7 +60,7 @@ HRESULT CScene_DebugItemEditor::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfH Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player != nullptr && player->connection) player->connection->send( shared_ptr( new ContainerSetSlotPacket(m_menu->containerId, m_slot->index, m_item) ) ); + if(player != nullptr && player->connection) player->connection->send(std::make_shared(m_menu->containerId, m_slot->index, m_item)); } // kill the crafting xui app.NavigateBack(m_iPad); @@ -76,7 +76,7 @@ HRESULT CScene_DebugItemEditor::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfH HRESULT CScene_DebugItemEditor::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled) { - if(m_item == nullptr) m_item = shared_ptr( new ItemInstance(0,1,0) ); + if(m_item == nullptr) m_item = std::make_shared(0, 1, 0); if(hObjSource == m_itemId) { int id = 0; diff --git a/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp b/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp index 64f1f22c6..5030a7923 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp @@ -78,7 +78,7 @@ HRESULT CScene_InGameHostOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& r shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player != nullptr && player->connection) { - player->connection->send( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions) ) ); + player->connection->send(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions)); } } diff --git a/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp b/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp index d22230a91..35e083396 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp @@ -529,7 +529,7 @@ int CScene_InGameInfo::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMes shared_ptr localPlayer = pMinecraft->localplayers[iPad]; if(localPlayer != nullptr && localPlayer->connection) { - localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); + localPlayer->connection->send(std::make_shared(smallId)); } } diff --git a/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp b/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp index 7903ff8eb..4ab2a54a2 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp @@ -280,7 +280,7 @@ HRESULT CScene_InGamePlayerOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player != nullptr && player->connection) { - player->connection->send( shared_ptr( new PlayerInfoPacket( m_networkSmallId, -1, m_playerPrivileges) ) ); + player->connection->send(std::make_shared(m_networkSmallId, -1, m_playerPrivileges)); } } @@ -339,7 +339,7 @@ int CScene_InGamePlayerOptions::KickPlayerReturned(void *pParam,int iPad,C4JStor shared_ptr localPlayer = pMinecraft->localplayers[iPad]; if(localPlayer != nullptr && localPlayer->connection) { - localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); + localPlayer->connection->send(std::make_shared(smallId)); } // Fix for #61494 - [CRASH]: TU7: Code: Multiplayer: Title may crash while kicking a player from an online game. diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp index 345d426dd..0fa3e7803 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp @@ -60,7 +60,7 @@ HRESULT CXuiSceneInventoryCreative::OnInit( XUIMessageInit *pInitData, BOOL &bHa initData->player->awardStat(GenericStats::openInventory(), GenericStats::param_noArgs()); // 4J JEV - Item Picker Menu - shared_ptr creativeContainer = shared_ptr(new SimpleContainer( 0, TabSpec::MAX_SIZE + 9 )); + shared_ptr creativeContainer = std::make_shared(0, TabSpec::MAX_SIZE + 9); itemPickerMenu = new ItemPickerMenu(creativeContainer, initData->player->inventory); // 4J JEV - InitDataAssociations. diff --git a/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp b/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp index 6c54c3e31..963d8f103 100644 --- a/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp @@ -77,7 +77,7 @@ HRESULT CScene_SignEntry::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* p shared_ptr player = pMinecraft->localplayers[pNotifyPressData->UserIndex]; if(player != nullptr && player->connection && player->connection->isStarted()) { - player->connection->send( shared_ptr( new SignUpdatePacket(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages()) ) ); + player->connection->send(std::make_shared(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages())); } } app.CloseXuiScenes(pNotifyPressData->UserIndex); diff --git a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp index 02b7d9db2..3c9c936eb 100644 --- a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp +++ b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp @@ -289,7 +289,7 @@ wstring CScene_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, LPCWS if( icon != TUTORIAL_NO_ICON ) { bool itemIsFoil = false; - itemIsFoil = (shared_ptr(new ItemInstance(icon,1,iAuxVal)))->isFoil(); + itemIsFoil = (std::make_shared(icon, 1, iAuxVal))->isFoil(); if(!itemIsFoil) itemIsFoil = isFoil; m_pCraftingPic->SetIcon(m_iPad, icon,iAuxVal,1,10,31,false,itemIsFoil); @@ -322,7 +322,7 @@ wstring CScene_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, LPCWS } bool itemIsFoil = false; - itemIsFoil = (shared_ptr(new ItemInstance(iconId,1,iAuxVal)))->isFoil(); + itemIsFoil = (std::make_shared(iconId, 1, iAuxVal))->isFoil(); if(!itemIsFoil) itemIsFoil = isFoil; m_pCraftingPic->SetIcon(m_iPad, iconId,iAuxVal,1,10,31,false,itemIsFoil); diff --git a/Minecraft.Client/ConnectScreen.cpp b/Minecraft.Client/ConnectScreen.cpp index c34a219e0..18d50a527 100644 --- a/Minecraft.Client/ConnectScreen.cpp +++ b/Minecraft.Client/ConnectScreen.cpp @@ -17,7 +17,7 @@ ConnectScreen::ConnectScreen(Minecraft *minecraft, const wstring& ip, int port) // 4J - removed from separate thread, but need to investigate what we actually need here connection = new ClientConnection(minecraft, ip, port); if (aborted) return; - connection->send( shared_ptr( new PreLoginPacket(minecraft->user->name) ) ); + connection->send(std::make_shared(minecraft->user->name)); #else new Thread() { diff --git a/Minecraft.Client/DLCTexturePack.cpp b/Minecraft.Client/DLCTexturePack.cpp index 1e72bb260..f1304a9ef 100644 --- a/Minecraft.Client/DLCTexturePack.cpp +++ b/Minecraft.Client/DLCTexturePack.cpp @@ -9,6 +9,7 @@ #include "Common\DLC\DLCLocalisationFile.h" #include "..\Minecraft.World\StringHelpers.h" #include "StringTable.h" +#include "Common/UI/UI.h" #include "Common\DLC\DLCAudioFile.h" #if defined _XBOX || defined _WINDOWS64 diff --git a/Minecraft.Client/EntityTileRenderer.cpp b/Minecraft.Client/EntityTileRenderer.cpp index deed369e8..6a84e3a3a 100644 --- a/Minecraft.Client/EntityTileRenderer.cpp +++ b/Minecraft.Client/EntityTileRenderer.cpp @@ -8,9 +8,9 @@ EntityTileRenderer *EntityTileRenderer::instance = new EntityTileRenderer; EntityTileRenderer::EntityTileRenderer() { - chest = shared_ptr(new ChestTileEntity()); - trappedChest = shared_ptr(new ChestTileEntity(ChestTile::TYPE_TRAP)); - enderChest = shared_ptr(new EnderChestTileEntity()); + chest = std::make_shared(); + trappedChest = std::make_shared(ChestTile::TYPE_TRAP); + enderChest = std::make_shared(); } void EntityTileRenderer::render(Tile *tile, int data, float brightness, float alpha, bool setColor, bool useCompiled) diff --git a/Minecraft.Client/EntityTracker.cpp b/Minecraft.Client/EntityTracker.cpp index 8171e50d4..087227e77 100644 --- a/Minecraft.Client/EntityTracker.cpp +++ b/Minecraft.Client/EntityTracker.cpp @@ -85,7 +85,7 @@ void EntityTracker::addEntity(shared_ptr e, int range, int updateInterva { __debugbreak(); } - shared_ptr te = shared_ptr( new TrackedEntity(e, range, updateInterval, trackDeltas) ); + shared_ptr te = std::make_shared(e, range, updateInterval, trackDeltas); entities.insert(te); entityMap[e->entityId] = te; te->updatePlayers(this, &level->players); diff --git a/Minecraft.Client/FireworksParticles.cpp b/Minecraft.Client/FireworksParticles.cpp index c8a109c4b..c17283ac4 100644 --- a/Minecraft.Client/FireworksParticles.cpp +++ b/Minecraft.Client/FireworksParticles.cpp @@ -189,7 +189,7 @@ void FireworksParticles::FireworksStarter::tick() float r = static_cast((rgb & 0xff0000) >> 16) / 255.0f; float g = static_cast((rgb & 0x00ff00) >> 8) / 255.0f; float b = static_cast((rgb & 0x0000ff) >> 0) / 255.0f; - shared_ptr fireworksOverlayParticle = shared_ptr(new FireworksParticles::FireworksOverlayParticle(level, x, y, z)); + shared_ptr fireworksOverlayParticle = std::make_shared(level, x, y, z); fireworksOverlayParticle->setColor(r, g, b); fireworksOverlayParticle->setAlpha(0.99f); // 4J added engine->add(fireworksOverlayParticle); @@ -224,7 +224,7 @@ bool FireworksParticles::FireworksStarter::isFarAwayFromCamera() void FireworksParticles::FireworksStarter::createParticle(double x, double y, double z, double xa, double ya, double za, intArray rgbColors, intArray fadeColors, bool trail, bool flicker) { - shared_ptr fireworksSparkParticle = shared_ptr(new FireworksSparkParticle(level, x, y, z, xa, ya, za, engine)); + shared_ptr fireworksSparkParticle = std::make_shared(level, x, y, z, xa, ya, za, engine); fireworksSparkParticle->setAlpha(0.99f); fireworksSparkParticle->setTrail(trail); fireworksSparkParticle->setFlicker(flicker); @@ -433,7 +433,7 @@ void FireworksParticles::FireworksSparkParticle::tick() if (trail && (age < lifetime / 2) && ((age + lifetime) % 2) == 0) { - shared_ptr fireworksSparkParticle = shared_ptr(new FireworksParticles::FireworksSparkParticle(level, x, y, z, 0, 0, 0, engine)); + shared_ptr fireworksSparkParticle = std::make_shared(level, x, y, z, 0, 0, 0, engine); fireworksSparkParticle->setAlpha(0.99f); fireworksSparkParticle->setColor(rCol, gCol, bCol); fireworksSparkParticle->age = fireworksSparkParticle->lifetime / 2; diff --git a/Minecraft.Client/GameRenderer.cpp b/Minecraft.Client/GameRenderer.cpp index 3c11db1f6..9758fc166 100644 --- a/Minecraft.Client/GameRenderer.cpp +++ b/Minecraft.Client/GameRenderer.cpp @@ -327,13 +327,14 @@ void GameRenderer::pick(float a) else if (p != nullptr) { double dd = from->distanceTo(p->pos); - if (e == mc->cameraTargetPlayer->riding != nullptr) - { - if (nearest == 0) - { - hovered = e; - } - } + auto const riding = mc->cameraTargetPlayer->riding; + if (riding != nullptr && e == riding) + { + if (nearest == 0) + { + hovered = e; + } + } else { hovered = e; @@ -1672,7 +1673,7 @@ void GameRenderer::tickRain() { if (Tile::tiles[t]->material == Material::lava) { - mc->particleEngine->add( shared_ptr( new SmokeParticle(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za, 0, 0, 0) ) ); + mc->particleEngine->add(std::make_shared(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za, 0, 0, 0)); } else { @@ -1682,7 +1683,7 @@ void GameRenderer::tickRain() rainPosY = y + 0.1f - Tile::tiles[t]->getShapeY0(); rainPosZ = z + za; } - mc->particleEngine->add( shared_ptr( new WaterDropParticle(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za) ) ); + mc->particleEngine->add(std::make_shared(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za)); } } } diff --git a/Minecraft.Client/Gui.cpp b/Minecraft.Client/Gui.cpp index 921472f20..24c186e0f 100644 --- a/Minecraft.Client/Gui.cpp +++ b/Minecraft.Client/Gui.cpp @@ -28,6 +28,7 @@ #include "..\Minecraft.World\net.minecraft.world.h" #include "..\Minecraft.World\LevelChunk.h" #include "..\Minecraft.World\Biome.h" +#include "Common/UI/UI.h" ResourceLocation Gui::PUMPKIN_BLUR_LOCATION = ResourceLocation(TN__BLUR__MISC_PUMPKINBLUR); diff --git a/Minecraft.Client/ItemFrameRenderer.cpp b/Minecraft.Client/ItemFrameRenderer.cpp index 33c4cd8ac..55354aac8 100644 --- a/Minecraft.Client/ItemFrameRenderer.cpp +++ b/Minecraft.Client/ItemFrameRenderer.cpp @@ -112,7 +112,7 @@ void ItemFrameRenderer::drawItem(shared_ptr entity) shared_ptr instance = entity->getItem(); if (instance == nullptr) return; - shared_ptr itemEntity = shared_ptr(new ItemEntity(entity->level, 0, 0, 0, instance)); + shared_ptr itemEntity = std::make_shared(entity->level, 0, 0, 0, instance); itemEntity->getItem()->count = 1; itemEntity->bobOffs = 0; diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index dc7b8987d..eab39c4e9 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -2736,32 +2736,32 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle switch(eParticleType) { case eParticleType_hugeexplosion: - particle = shared_ptr(new HugeExplosionSeedParticle(lev, x, y, z, xa, ya, za)); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_largeexplode: - particle = shared_ptr(new HugeExplosionParticle(textures, lev, x, y, z, xa, ya, za)); + particle = std::make_shared(textures, lev, x, y, z, xa, ya, za); break; case eParticleType_fireworksspark: - particle = shared_ptr(new FireworksParticles::FireworksSparkParticle(lev, x, y, z, xa, ya, za, mc->particleEngine)); + particle = std::make_shared(lev, x, y, z, xa, ya, za, mc->particleEngine); particle->setAlpha(0.99f); break; case eParticleType_bubble: - particle = shared_ptr( new BubbleParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_suspended: - particle = shared_ptr( new SuspendedParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_depthsuspend: - particle = shared_ptr( new SuspendedTownParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_townaura: - particle = shared_ptr( new SuspendedTownParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_crit: { - shared_ptr critParticle2 = shared_ptr(new CritParticle2(lev, x, y, z, xa, ya, za)); + shared_ptr critParticle2 = std::make_shared(lev, x, y, z, xa, ya, za); critParticle2->CritParticle2PostConstructor(); particle = shared_ptr( critParticle2 ); // request from 343 to set pink for the needler in the Halo Texture Pack @@ -2787,7 +2787,7 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle break; case eParticleType_magicCrit: { - shared_ptr critParticle2 = shared_ptr(new CritParticle2(lev, x, y, z, xa, ya, za)); + shared_ptr critParticle2 = std::make_shared(lev, x, y, z, xa, ya, za); critParticle2->CritParticle2PostConstructor(); particle = shared_ptr(critParticle2); particle->setColor(particle->getRedCol() * 0.3f, particle->getGreenCol() * 0.8f, particle->getBlueCol()); @@ -2795,7 +2795,7 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle } break; case eParticleType_smoke: - particle = shared_ptr( new SmokeParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_endportal: // 4J - Added. { @@ -2809,103 +2809,103 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle } break; case eParticleType_mobSpell: - particle = shared_ptr(new SpellParticle(lev, x, y, z, 0, 0, 0)); + particle = std::make_shared(lev, x, y, z, 0, 0, 0); particle->setColor(static_cast(xa), static_cast(ya), static_cast(za)); break; case eParticleType_mobSpellAmbient: - particle = shared_ptr(new SpellParticle(lev, x, y, z, 0, 0, 0)); + particle = std::make_shared(lev, x, y, z, 0, 0, 0); particle->setAlpha(0.15f); particle->setColor(static_cast(xa), static_cast(ya), static_cast(za)); break; case eParticleType_spell: - particle = shared_ptr( new SpellParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_witchMagic: { - particle = shared_ptr(new SpellParticle(lev, x, y, z, xa, ya, za)); + particle = std::make_shared(lev, x, y, z, xa, ya, za); dynamic_pointer_cast(particle)->setBaseTex(9 * 16); float randBrightness = lev->random->nextFloat() * 0.5f + 0.35f; particle->setColor(1 * randBrightness, 0 * randBrightness, 1 * randBrightness); } break; case eParticleType_instantSpell: - particle = shared_ptr(new SpellParticle(lev, x, y, z, xa, ya, za)); + particle = std::make_shared(lev, x, y, z, xa, ya, za); dynamic_pointer_cast(particle)->setBaseTex(9 * 16); break; case eParticleType_note: - particle = shared_ptr( new NoteParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_netherportal: - particle = shared_ptr( new NetherPortalParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_ender: - particle = shared_ptr( new EnderParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_enchantmenttable: - particle = shared_ptr(new EchantmentTableParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_explode: - particle = shared_ptr( new ExplodeParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_flame: - particle = shared_ptr( new FlameParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_lava: - particle = shared_ptr( new LavaParticle(lev, x, y, z) ); + particle = std::make_shared(lev, x, y, z); break; case eParticleType_footstep: - particle = shared_ptr( new FootstepParticle(textures, lev, x, y, z) ); + particle = std::make_shared(textures, lev, x, y, z); break; case eParticleType_splash: - particle = shared_ptr( new SplashParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_largesmoke: - particle = shared_ptr( new SmokeParticle(lev, x, y, z, xa, ya, za, 2.5f) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za, 2.5f); break; case eParticleType_reddust: - particle = shared_ptr( new RedDustParticle(lev, x, y, z, static_cast(xa), static_cast(ya), static_cast(za)) ); + particle = std::make_shared(lev, x, y, z, static_cast(xa), static_cast(ya), static_cast(za)); break; case eParticleType_snowballpoof: - particle = shared_ptr( new BreakingItemParticle(lev, x, y, z, Item::snowBall, textures) ); + particle = std::make_shared(lev, x, y, z, Item::snowBall, textures); break; case eParticleType_dripWater: - particle = shared_ptr( new DripParticle(lev, x, y, z, Material::water) ); + particle = std::make_shared(lev, x, y, z, Material::water); break; case eParticleType_dripLava: - particle = shared_ptr( new DripParticle(lev, x, y, z, Material::lava) ); + particle = std::make_shared(lev, x, y, z, Material::lava); break; case eParticleType_snowshovel: - particle = shared_ptr( new SnowShovelParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_slime: - particle = shared_ptr( new BreakingItemParticle(lev, x, y, z, Item::slimeBall, textures)); + particle = std::make_shared(lev, x, y, z, Item::slimeBall, textures); break; case eParticleType_heart: - particle = shared_ptr( new HeartParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_angryVillager: - particle = shared_ptr( new HeartParticle(lev, x, y + 0.5f, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y + 0.5f, z, xa, ya, za); particle->setMiscTex(1 + 16 * 5); particle->setColor(1, 1, 1); break; case eParticleType_happyVillager: - particle = shared_ptr( new SuspendedTownParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); particle->setMiscTex(2 + 16 * 5); particle->setColor(1, 1, 1); break; case eParticleType_dragonbreath: - particle = shared_ptr( new DragonBreathParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; default: if( ( eParticleType >= eParticleType_iconcrack_base ) && ( eParticleType <= eParticleType_iconcrack_last ) ) { int id = PARTICLE_CRACK_ID(eParticleType), data = PARTICLE_CRACK_DATA(eParticleType); - particle = shared_ptr(new BreakingItemParticle(lev, x, y, z, xa, ya, za, Item::items[id], textures, data)); + particle = std::make_shared(lev, x, y, z, xa, ya, za, Item::items[id], textures, data); } else if( ( eParticleType >= eParticleType_tilecrack_base ) && ( eParticleType <= eParticleType_tilecrack_last ) ) { int id = PARTICLE_CRACK_ID(eParticleType), data = PARTICLE_CRACK_DATA(eParticleType); - particle = dynamic_pointer_cast( shared_ptr(new TerrainParticle(lev, x, y, z, xa, ya, za, Tile::tiles[id], 0, data, textures))->init(data) ); + particle = dynamic_pointer_cast(std::make_shared(lev, x, y, z, xa, ya, za, Tile::tiles[id], 0, data, textures)->init(data) ); } } diff --git a/Minecraft.Client/LivingEntityRenderer.cpp b/Minecraft.Client/LivingEntityRenderer.cpp index 7e99f0ba6..600a66554 100644 --- a/Minecraft.Client/LivingEntityRenderer.cpp +++ b/Minecraft.Client/LivingEntityRenderer.cpp @@ -306,7 +306,7 @@ void LivingEntityRenderer::renderArrows(shared_ptr mob, float a) int arrowCount = mob->getArrowCount(); if (arrowCount > 0) { - shared_ptr arrow = shared_ptr(new Arrow(mob->level, mob->x, mob->y, mob->z)); + shared_ptr arrow = std::make_shared(mob->level, mob->x, mob->y, mob->z); Random random = Random(mob->entityId); Lighting::turnOff(); for (int i = 0; i < arrowCount; i++) diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index 6e06f9ef6..f7b90f240 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -56,7 +56,7 @@ #ifndef _DURANGO #include "..\Minecraft.World\CommonStats.h" #endif - +extern ConsoleUIController ui; LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dimension) : Player(level, user->name) @@ -705,21 +705,21 @@ bool LocalPlayer::openTrading(shared_ptr traderTarget, const wstring & void LocalPlayer::crit(shared_ptr e) { - shared_ptr critParticle = shared_ptr( new CritParticle((Level *)minecraft->level, e) ); + shared_ptr critParticle = std::make_shared(reinterpret_cast(minecraft->level), e); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add(critParticle); } void LocalPlayer::magicCrit(shared_ptr e) { - shared_ptr critParticle = shared_ptr( new CritParticle((Level *)minecraft->level, e, eParticleType_magicCrit) ); + shared_ptr critParticle = std::make_shared(reinterpret_cast(minecraft->level), e, eParticleType_magicCrit); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add(critParticle); } void LocalPlayer::take(shared_ptr e, int orgCount) { - minecraft->particleEngine->add( shared_ptr( new TakeAnimationParticle((Level *)minecraft->level, e, shared_from_this(), -0.5f) ) ); + minecraft->particleEngine->add(std::make_shared(reinterpret_cast(minecraft->level), e, shared_from_this(), -0.5f)); } void LocalPlayer::chat(const wstring& message) diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 7048c8d01..3762034db 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -91,6 +91,8 @@ int Minecraft::frameTimePos = 0; __int64 Minecraft::warezTime = 0; File Minecraft::workDir = File(L""); +extern ConsoleUIController ui; + #ifdef __PSVITA__ TOUCHSCREENRECT QuickSelectRect[3]= @@ -932,7 +934,7 @@ bool Minecraft::addLocalPlayer(int idx) if(success) { app.DebugPrintf("Adding temp local player on pad %d\n", idx); - localplayers[idx] = shared_ptr( new MultiplayerLocalPlayer(this, level, user, nullptr ) ); + localplayers[idx] = shared_ptr(new MultiplayerLocalPlayer(this, level, user, nullptr)); localgameModes[idx] = nullptr; updatePlayerViewportAssignments(); @@ -1131,7 +1133,7 @@ void Minecraft::removeLocalPlayerIdx(int idx) } else if( m_pendingLocalConnections[idx] != nullptr ) { - m_pendingLocalConnections[idx]->sendAndDisconnect( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );; + m_pendingLocalConnections[idx]->sendAndDisconnect(std::make_shared(DisconnectPacket::eDisconnect_Quitting));; delete m_pendingLocalConnections[idx]; m_pendingLocalConnections[idx] = nullptr; g_NetworkManager.RemoveLocalPlayerByUserIndex(idx); diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp index ad68b47fd..6a38ded24 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -226,7 +226,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom wstring message = L"[Server] " + JoinConsoleCommandTokens(tokens, 1); if (playerList != nullptr) { - playerList->broadcastAll(shared_ptr(new ChatPacket(message))); + playerList->broadcastAll(std::make_shared(message)); } server->info(message); return true; @@ -904,7 +904,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring levelChunksNeedConverted = true; pSave->ConvertToLocalPlatform(); // check if we need to convert this file from PS3->PS4 - storage = shared_ptr(new McRegionLevelStorage(pSave, File(L"."), name, true)); + storage = std::make_shared(pSave, File(L"."), name, true); } else { @@ -931,7 +931,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring storage = shared_ptr(new McRegionLevelStorage(newFormatSave, File(L"."), name, true)); #else - storage = shared_ptr(new McRegionLevelStorage(new ConsoleSaveFileOriginal( L"" ), File(L"."), name, true)); + storage = std::make_shared(new ConsoleSaveFileOriginal(L""), File(L"."), name, true); #endif } @@ -1885,7 +1885,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) players->saveAll(Minecraft::GetInstance()->progressRenderer); } - players->broadcastAll( shared_ptr( new UpdateProgressPacket(20) ) ); + players->broadcastAll(std::make_shared(20)); for (unsigned int j = 0; j < levels.length; j++) { @@ -1896,7 +1896,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) ServerLevel *level = levels[levels.length - 1 - j]; level->save(true, Minecraft::GetInstance()->progressRenderer, (eAction==eXuiServerAction_AutoSaveGame)); - players->broadcastAll( shared_ptr( new UpdateProgressPacket(33 + (j*33) ) ) ); + players->broadcastAll(std::make_shared(33 + (j * 33))); } if( !s_bServerHalted ) { @@ -1911,7 +1911,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) { shared_ptr player = players->players.at(0); size_t id = (size_t) param; - player->drop( shared_ptr( new ItemInstance(id, 1, 0 ) ) ); + player->drop(std::make_shared(id, 1, 0)); } break; case eXuiServerAction_SpawnMob: @@ -1946,14 +1946,14 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) } break; case eXuiServerAction_ServerSettingChanged_Gamertags: - players->broadcastAll( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_OPTIONS, app.GetGameHostOption(eGameHostOption_Gamertags)) ) ); + players->broadcastAll(std::make_shared(ServerSettingsChangedPacket::HOST_OPTIONS, app.GetGameHostOption(eGameHostOption_Gamertags))); break; case eXuiServerAction_ServerSettingChanged_BedrockFog: - players->broadcastAll( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All)) ) ); + players->broadcastAll(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All))); break; case eXuiServerAction_ServerSettingChanged_Difficulty: - players->broadcastAll( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, Minecraft::GetInstance()->options->difficulty) ) ); + players->broadcastAll(std::make_shared(ServerSettingsChangedPacket::HOST_DIFFICULTY, Minecraft::GetInstance()->options->difficulty)); break; case eXuiServerAction_ExportSchematic: #ifndef _CONTENT_PACKAGE @@ -2054,14 +2054,14 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) void MinecraftServer::broadcastStartSavingPacket() { - players->broadcastAll( shared_ptr( new GameEventPacket(GameEventPacket::START_SAVING, 0) ) );; + players->broadcastAll(std::make_shared(GameEventPacket::START_SAVING, 0));; } void MinecraftServer::broadcastStopSavingPacket() { if( !s_bServerHalted ) { - players->broadcastAll( shared_ptr( new GameEventPacket(GameEventPacket::STOP_SAVING, 0) ) );; + players->broadcastAll(std::make_shared(GameEventPacket::STOP_SAVING, 0));; } } @@ -2116,7 +2116,7 @@ void MinecraftServer::tick() if (tickCount % 20 == 0) { - players->broadcastAll( shared_ptr( new SetTimePacket(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT) ) ), level->dimension->id); + players->broadcastAll(std::make_shared(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)), level->dimension->id); } // #ifndef __PS3__ static __int64 stc = 0; diff --git a/Minecraft.Client/MultiPlayerGameMode.cpp b/Minecraft.Client/MultiPlayerGameMode.cpp index 50e3080d7..66fc22a6b 100644 --- a/Minecraft.Client/MultiPlayerGameMode.cpp +++ b/Minecraft.Client/MultiPlayerGameMode.cpp @@ -129,7 +129,7 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) // Skip if we just broke a block — prevents double-break on single clicks if (destroyDelay > 0) return; - connection->send(shared_ptr( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) )); + connection->send(std::make_shared(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); creativeDestroyBlock(minecraft, this, x, y, z, face); destroyDelay = 5; } @@ -137,9 +137,9 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) { if (isDestroying) { - connection->send(shared_ptr(new PlayerActionPacket(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, face))); + connection->send(std::make_shared(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, face)); } - connection->send( shared_ptr( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) ); + connection->send(std::make_shared(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); int t = minecraft->level->getTile(x, y, z); if (t > 0 && destroyProgress == 0) Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player); if (t > 0 && @@ -169,7 +169,7 @@ void MultiPlayerGameMode::stopDestroyBlock() { if (isDestroying) { - connection->send(shared_ptr(new PlayerActionPacket(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1))); + connection->send(std::make_shared(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1)); } isDestroying = false; @@ -193,7 +193,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) if (localPlayerMode->isCreative()) { destroyDelay = 5; - connection->send(shared_ptr( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) ); + connection->send(std::make_shared(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); creativeDestroyBlock(minecraft, this, x, y, z, face); return; } @@ -225,7 +225,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) if (destroyProgress >= 1) { isDestroying = false; - connection->send( shared_ptr( new PlayerActionPacket(PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face) ) ); + connection->send(std::make_shared(PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face)); destroyBlock(x, y, z, face); destroyProgress = 0; destroyTicks = 0; @@ -276,7 +276,7 @@ void MultiPlayerGameMode::ensureHasSentCarriedItem() if (newItem != carriedItem) { carriedItem = newItem; - connection->send( shared_ptr( new SetCarriedItemPacket(carriedItem) ) ); + connection->send(std::make_shared(carriedItem)); } } @@ -379,7 +379,7 @@ bool MultiPlayerGameMode::useItemOn(shared_ptr player, Level *level, sha // Fix for #7904 - Gameplay: Players can dupe torches by throwing them repeatedly into water. if(!bTestUseOnly) { - connection->send( shared_ptr( new UseItemPacket(x, y, z, face, player->inventory->getSelected(), clickX, clickY, clickZ) ) ); + connection->send(std::make_shared(x, y, z, face, player->inventory->getSelected(), clickX, clickY, clickZ)); } return didSomething; } @@ -421,27 +421,27 @@ bool MultiPlayerGameMode::useItem(shared_ptr player, Level *level, share if(!bTestUseOnly) { - connection->send( shared_ptr( new UseItemPacket(-1, -1, -1, 255, player->inventory->getSelected(), 0, 0, 0) ) ); + connection->send(std::make_shared(-1, -1, -1, 255, player->inventory->getSelected(), 0, 0, 0)); } return result; } shared_ptr MultiPlayerGameMode::createPlayer(Level *level) { - return shared_ptr( new MultiplayerLocalPlayer(minecraft, level, minecraft->user, connection) ); + return std::make_shared(minecraft, level, minecraft->user, connection); } void MultiPlayerGameMode::attack(shared_ptr player, shared_ptr entity) { ensureHasSentCarriedItem(); - connection->send( shared_ptr( new InteractPacket(player->entityId, entity->entityId, InteractPacket::ATTACK) ) ); + connection->send(std::make_shared(player->entityId, entity->entityId, InteractPacket::ATTACK)); player->attack(entity); } bool MultiPlayerGameMode::interact(shared_ptr player, shared_ptr entity) { ensureHasSentCarriedItem(); - connection->send(shared_ptr( new InteractPacket(player->entityId, entity->entityId, InteractPacket::INTERACT) ) ); + connection->send(std::make_shared(player->entityId, entity->entityId, InteractPacket::INTERACT)); return player->interact(entity); } @@ -450,21 +450,21 @@ shared_ptr MultiPlayerGameMode::handleInventoryMouseClick(int cont short changeUid = player->containerMenu->backup(player->inventory); shared_ptr clicked = player->containerMenu->clicked(slotNum, buttonNum, quickKeyHeld?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, player); - connection->send( shared_ptr( new ContainerClickPacket(containerId, slotNum, buttonNum, quickKeyHeld, clicked, changeUid) ) ); + connection->send(std::make_shared(containerId, slotNum, buttonNum, quickKeyHeld, clicked, changeUid)); return clicked; } void MultiPlayerGameMode::handleInventoryButtonClick(int containerId, int buttonId) { - connection->send(shared_ptr( new ContainerButtonClickPacket(containerId, buttonId) )); + connection->send(std::make_shared(containerId, buttonId)); } void MultiPlayerGameMode::handleCreativeModeItemAdd(shared_ptr clicked, int slot) { if (localPlayerMode->isCreative()) { - connection->send(shared_ptr( new SetCreativeModeSlotPacket(slot, clicked) ) ); + connection->send(std::make_shared(slot, clicked)); } } @@ -472,14 +472,14 @@ void MultiPlayerGameMode::handleCreativeModeItemDrop(shared_ptr cl { if (localPlayerMode->isCreative() && clicked != nullptr) { - connection->send(shared_ptr( new SetCreativeModeSlotPacket(-1, clicked) ) ); + connection->send(std::make_shared(-1, clicked)); } } void MultiPlayerGameMode::releaseUsingItem(shared_ptr player) { ensureHasSentCarriedItem(); - connection->send(shared_ptr( new PlayerActionPacket(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 255) ) ); + connection->send(std::make_shared(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 255)); player->releaseUsingItem(); } @@ -514,7 +514,7 @@ bool MultiPlayerGameMode::handleCraftItem(int recipe, shared_ptr player) { short changeUid = player->containerMenu->backup(player->inventory); - connection->send( shared_ptr( new CraftItemPacket(recipe, changeUid) ) ); + connection->send(std::make_shared(recipe, changeUid)); return true; } @@ -522,5 +522,5 @@ bool MultiPlayerGameMode::handleCraftItem(int recipe, shared_ptr player) void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal, shared_ptr player) { player->SetDebugOptions(uiVal); - connection->send( shared_ptr( new DebugOptionsPacket(uiVal) ) ); + connection->send(std::make_shared(uiVal)); } diff --git a/Minecraft.Client/MultiPlayerLevel.cpp b/Minecraft.Client/MultiPlayerLevel.cpp index d91a1affc..188189be1 100644 --- a/Minecraft.Client/MultiPlayerLevel.cpp +++ b/Minecraft.Client/MultiPlayerLevel.cpp @@ -26,7 +26,7 @@ MultiPlayerLevel::ResetInfo::ResetInfo(int x, int y, int z, int tile, int data) } MultiPlayerLevel::MultiPlayerLevel(ClientConnection *connection, LevelSettings *levelSettings, int dimension, int difficulty) - : Level(shared_ptr(new MockedLevelStorage()), L"MpServer", Dimension::getNew(dimension), levelSettings, false) + : Level(std::make_shared(), L"MpServer", Dimension::getNew(dimension), levelSettings, false) { minecraft = Minecraft::GetInstance(); @@ -618,7 +618,7 @@ void MultiPlayerLevel::disconnect(bool sendDisconnect /*= true*/) for (auto& it : connections ) { if ( it ) - it->sendAndDisconnect( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) ); + it->sendAndDisconnect(std::make_shared(DisconnectPacket::eDisconnect_Quitting)); } } else @@ -781,7 +781,7 @@ void MultiPlayerLevel::playLocalSound(double x, double y, double z, int iSound, void MultiPlayerLevel::createFireworks(double x, double y, double z, double xd, double yd, double zd, CompoundTag *infoTag) { - minecraft->particleEngine->add(shared_ptr(new FireworksParticles::FireworksStarter(this, x, y, z, xd, yd, zd, minecraft->particleEngine, infoTag))); + minecraft->particleEngine->add(std::make_shared(this, x, y, z, xd, yd, zd, minecraft->particleEngine, infoTag)); } void MultiPlayerLevel::setScoreboard(Scoreboard *scoreboard) @@ -899,7 +899,7 @@ void MultiPlayerLevel::removeClientConnection(ClientConnection *c, bool sendDisc { if( sendDisconnect ) { - c->sendAndDisconnect( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) ); + c->sendAndDisconnect(std::make_shared(DisconnectPacket::eDisconnect_Quitting)); } auto it = find(connections.begin(), connections.end(), c); diff --git a/Minecraft.Client/MultiPlayerLocalPlayer.cpp b/Minecraft.Client/MultiPlayerLocalPlayer.cpp index 57ffb2906..aef7898f2 100644 --- a/Minecraft.Client/MultiPlayerLocalPlayer.cpp +++ b/Minecraft.Client/MultiPlayerLocalPlayer.cpp @@ -76,8 +76,8 @@ void MultiplayerLocalPlayer::tick() { if (isRiding()) { - connection->send(shared_ptr(new MovePlayerPacket::Rot(yRot, xRot, onGround, abilities.flying))); - connection->send(shared_ptr(new PlayerInputPacket(xxa, yya, input->jumping, input->sneaking))); + connection->send(std::make_shared(yRot, xRot, onGround, abilities.flying)); + connection->send(std::make_shared(xxa, yya, input->jumping, input->sneaking)); } else { @@ -96,8 +96,8 @@ void MultiplayerLocalPlayer::sendPosition() bool sprinting = isSprinting(); if (sprinting != lastSprinting) { - if (sprinting) connection->send(shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SPRINTING))); - else connection->send(shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SPRINTING))); + if (sprinting) connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::START_SPRINTING)); + else connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::STOP_SPRINTING)); lastSprinting = sprinting; } @@ -105,8 +105,8 @@ void MultiplayerLocalPlayer::sendPosition() bool sneaking = isSneaking(); if (sneaking != lastSneaked) { - if (sneaking) connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SNEAKING) ) ); - else connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SNEAKING) ) ); + if (sneaking) connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::START_SNEAKING)); + else connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::STOP_SNEAKING)); lastSneaked = sneaking; } @@ -114,8 +114,8 @@ void MultiplayerLocalPlayer::sendPosition() bool idle = isIdle(); if (idle != lastIdle) { - if (idle) connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_IDLEANIM) ) ); - else connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM) ) ); + if (idle) connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::START_IDLEANIM)); + else connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM)); lastIdle = idle; } @@ -131,26 +131,26 @@ void MultiplayerLocalPlayer::sendPosition() bool rot = rydd != 0 || rxdd != 0; if (riding != nullptr) { - connection->send( shared_ptr( new MovePlayerPacket::PosRot(xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying) ) ); + connection->send(std::make_shared(xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying)); move = false; } else { if (move && rot) { - connection->send( shared_ptr( new MovePlayerPacket::PosRot(x, bb->y0, y, z, yRot, xRot, onGround, abilities.flying) ) ); + connection->send(std::make_shared(x, bb->y0, y, z, yRot, xRot, onGround, abilities.flying)); } else if (move) { - connection->send( shared_ptr( new MovePlayerPacket::Pos(x, bb->y0, y, z, onGround, abilities.flying) ) ); + connection->send(std::make_shared(x, bb->y0, y, z, onGround, abilities.flying)); } else if (rot) { - connection->send( shared_ptr( new MovePlayerPacket::Rot(yRot, xRot, onGround, abilities.flying) ) ); + connection->send(std::make_shared(yRot, xRot, onGround, abilities.flying)); } else { - connection->send( shared_ptr( new MovePlayerPacket(onGround, abilities.flying) ) ); + connection->send(std::make_shared(onGround, abilities.flying)); } } @@ -175,7 +175,7 @@ void MultiplayerLocalPlayer::sendPosition() shared_ptr MultiplayerLocalPlayer::drop() { - connection->send( shared_ptr( new PlayerActionPacket(PlayerActionPacket::DROP_ITEM, 0, 0, 0, 0) ) ); + connection->send(std::make_shared(PlayerActionPacket::DROP_ITEM, 0, 0, 0, 0)); return nullptr; } @@ -185,19 +185,19 @@ void MultiplayerLocalPlayer::reallyDrop(shared_ptr itemEntity) void MultiplayerLocalPlayer::chat(const wstring& message) { - connection->send( shared_ptr( new ChatPacket(message) ) ); + connection->send(std::make_shared(message)); } void MultiplayerLocalPlayer::swing() { LocalPlayer::swing(); - connection->send( shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::SWING) ) ); + connection->send(std::make_shared(shared_from_this(), AnimatePacket::SWING)); } void MultiplayerLocalPlayer::respawn() { - connection->send( shared_ptr( new ClientCommandPacket(ClientCommandPacket::PERFORM_RESPAWN))); + connection->send(std::make_shared(ClientCommandPacket::PERFORM_RESPAWN)); } @@ -260,7 +260,7 @@ void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance *effect) void MultiplayerLocalPlayer::closeContainer() { - connection->send( shared_ptr( new ContainerClosePacket(containerMenu->containerId) ) ); + connection->send(std::make_shared(containerMenu->containerId)); clientSideCloseContainer(); } @@ -314,7 +314,7 @@ void MultiplayerLocalPlayer::awardStatFromServer(Stat *stat, byteArray param) void MultiplayerLocalPlayer::onUpdateAbilities() { - connection->send(shared_ptr(new PlayerAbilitiesPacket(&abilities))); + connection->send(std::make_shared(&abilities)); } bool MultiplayerLocalPlayer::isLocalPlayer() @@ -324,12 +324,12 @@ bool MultiplayerLocalPlayer::isLocalPlayer() void MultiplayerLocalPlayer::sendRidingJump() { - connection->send(shared_ptr(new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::RIDING_JUMP, static_cast(getJumpRidingScale() * 100.0f)))); + connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::RIDING_JUMP, static_cast(getJumpRidingScale() * 100.0f))); } void MultiplayerLocalPlayer::sendOpenInventory() { - connection->send(shared_ptr(new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY))); + connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY)); } void MultiplayerLocalPlayer::ride(shared_ptr e) @@ -386,7 +386,7 @@ void MultiplayerLocalPlayer::ride(shared_ptr e) void MultiplayerLocalPlayer::StopSleeping() { - connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SLEEPING) ) ); + connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::STOP_SLEEPING)); } // 4J Added @@ -397,7 +397,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(DWORD skinId) #ifndef _CONTENT_PACKAGE wprintf(L"Skin for local player %ls has changed to %ls (%d)\n", name.c_str(), customTextureUrl.c_str(), getPlayerDefaultSkin() ); #endif - if(getCustomSkin() != oldSkinIndex) connection->send( shared_ptr( new TextureAndGeometryChangePacket( shared_from_this(), app.GetPlayerSkinName(GetXboxPad()) ) ) ); + if(getCustomSkin() != oldSkinIndex) connection->send(std::make_shared(shared_from_this(), app.GetPlayerSkinName(GetXboxPad()))); } void MultiplayerLocalPlayer::setAndBroadcastCustomCape(DWORD capeId) @@ -407,7 +407,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomCape(DWORD capeId) #ifndef _CONTENT_PACKAGE wprintf(L"Cape for local player %ls has changed to %ls\n", name.c_str(), customTextureUrl2.c_str()); #endif - if(getCustomCape() != oldCapeIndex) connection->send( shared_ptr( new TextureChangePacket( shared_from_this(), TextureChangePacket::e_TextureChange_Cape, app.GetPlayerCapeName(GetXboxPad()) ) ) ); + if(getCustomCape() != oldCapeIndex) connection->send(std::make_shared(shared_from_this(), TextureChangePacket::e_TextureChange_Cape, app.GetPlayerCapeName(GetXboxPad()))); } // 4J added for testing. This moves the player in a repeated sequence of 2 modes: diff --git a/Minecraft.Client/ParticleEngine.cpp b/Minecraft.Client/ParticleEngine.cpp index 82dd4ce1c..efc09c9ad 100644 --- a/Minecraft.Client/ParticleEngine.cpp +++ b/Minecraft.Client/ParticleEngine.cpp @@ -218,7 +218,7 @@ void ParticleEngine::destroy(int x, int y, int z, int tid, int data) double yp = y + (yy + 0.5) / SD; double zp = z + (zz + 0.5) / SD; int face = random->nextInt(6); - add(( shared_ptr(new TerrainParticle(level, xp, yp, zp, xp - x - 0.5f, yp - y - 0.5f, zp - z - 0.5f, tile, face, data, textures) ) )->init(x, y, z, data)); + add((std::make_shared(level, xp, yp, zp, xp - x - 0.5f, yp - y - 0.5f, zp - z - 0.5f, tile, face, data, textures))->init(x, y, z, data)); } } @@ -237,7 +237,7 @@ void ParticleEngine::crack(int x, int y, int z, int face) if (face == 3) zp = z + tile->getShapeZ1() + r; if (face == 4) xp = x + tile->getShapeX0() - r; if (face == 5) xp = x + tile->getShapeX1() + r; - add(( shared_ptr(new TerrainParticle(level, xp, yp, zp, 0, 0, 0, tile, face, level->getData(x, y, z), textures) ) )->init(x, y, z, level->getData(x, y, z))->setPower(0.2f)->scale(0.6f)); + add((std::make_shared(level, xp, yp, zp, 0, 0, 0, tile, face, level->getData(x, y, z), textures))->init(x, y, z, level->getData(x, y, z))->setPower(0.2f)->scale(0.6f)); } diff --git a/Minecraft.Client/PendingConnection.cpp b/Minecraft.Client/PendingConnection.cpp index 2adc1bb1e..5c11d41df 100644 --- a/Minecraft.Client/PendingConnection.cpp +++ b/Minecraft.Client/PendingConnection.cpp @@ -65,7 +65,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) // try { // 4J - removed try/catch // logger.info("Disconnecting " + getName() + ": " + reason); app.DebugPrintf("Pending connection disconnect: %d\n", reason ); - connection->send( shared_ptr( new DisconnectPacket(reason) ) ); + connection->send(std::make_shared(reason)); connection->sendAndQuit(); done = true; // } catch (Exception e) { @@ -136,7 +136,7 @@ void PendingConnection::sendPreLoginResponse() else #endif { - connection->send( shared_ptr( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) ); + connection->send(std::make_shared(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName, app.GetGameHostOption(eGameHostOption_All), hostIndex, server->m_texturePackId)); } } @@ -282,7 +282,7 @@ void PendingConnection::handleGetInfo(shared_ptr packet) //try { //String message = server->motd + "�" + server->players->getPlayerCount() + "�" + server->players->getMaxPlayers(); //connection->send(new DisconnectPacket(message)); - connection->send(shared_ptr(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) ); + connection->send(std::make_shared(DisconnectPacket::eDisconnect_ServerFull)); connection->sendAndQuit(); server->connection->removeSpamProtection(connection->getSocket()); done = true; diff --git a/Minecraft.Client/PlayerChunkMap.cpp b/Minecraft.Client/PlayerChunkMap.cpp index 2078093ed..e407bad29 100644 --- a/Minecraft.Client/PlayerChunkMap.cpp +++ b/Minecraft.Client/PlayerChunkMap.cpp @@ -64,7 +64,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr player, bool send player->seenChunks.insert(pos); // 4J Added the sendPacket check. See PlayerChunkMap::add for the usage - if( sendPacket ) player->connection->send( shared_ptr( new ChunkVisibilityPacket(pos.x, pos.z, true) ) ); + if( sendPacket ) player->connection->send(std::make_shared(pos.x, pos.z, true)); if (players.empty()) { @@ -143,7 +143,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr player) if(noOtherPlayersFound) { //wprintf(L"Sending ChunkVisiblity packet false for chunk (%d,%d) to player %ls\n", x, z, player->name.c_str() ); - player->connection->send( shared_ptr( new ChunkVisibilityPacket(pos.x, pos.z, false) ) ); + player->connection->send(std::make_shared(pos.x, pos.z, false)); } } else @@ -322,7 +322,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) int x = pos.x * 16 + xChangeMin; int y = yChangeMin; int z = pos.z * 16 + zChangeMin; - broadcast( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + broadcast(std::make_shared(x, y, z, level)); if (level->isEntityTile(x, y, z)) { broadcast(level->getTileEntity(x, y, z)); @@ -352,7 +352,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) // Block region update packets can only encode ys in a range of 1 - 256 if( ys > 256 ) ys = 256; - broadcast( shared_ptr( new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level) ) ); + broadcast(std::make_shared(xp, yp, zp, xs, ys, zs, level)); vector > *tes = level->getTileEntitiesInRegion(xp, yp, zp, xp + xs, yp + ys, zp + zs); for (unsigned int i = 0; i < tes->size(); i++) { @@ -365,7 +365,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) else { // 4J As we only get here if changes is less than MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in the packet - broadcast( shared_ptr( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, static_cast(changes), level) ) ); + broadcast(std::make_shared(pos.x, pos.z, changedTiles, static_cast(changes), level)); for (int i = 0; i < changes; i++) { int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15); @@ -712,7 +712,7 @@ void PlayerChunkMap::add(shared_ptr player) } // CraftBukkit end - player->connection->send( shared_ptr( new ChunkVisibilityAreaPacket(minX, maxX, minZ, maxZ) ) ); + player->connection->send(std::make_shared(minX, maxX, minZ, maxZ)); #ifdef _LARGE_WORLDS getLevel()->cache->dontDrop(xc,zc); diff --git a/Minecraft.Client/PlayerConnection.cpp b/Minecraft.Client/PlayerConnection.cpp index 48fd4e08d..752ed4a26 100644 --- a/Minecraft.Client/PlayerConnection.cpp +++ b/Minecraft.Client/PlayerConnection.cpp @@ -94,7 +94,7 @@ void PlayerConnection::tick() lastKeepAliveTick = tickCount; lastKeepAliveTime = System::nanoTime() / 1000000; lastKeepAliveId = random.nextInt(); - send( shared_ptr( new KeepAlivePacket(lastKeepAliveId) ) ); + send(std::make_shared(lastKeepAliveId)); } if (chatSpamTickCount > 0) @@ -121,17 +121,17 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason) // 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system server->getPlayers()->removePlayerFromReceiving( player ); - send( shared_ptr( new DisconnectPacket(reason) )); + send(std::make_shared(reason)); connection->sendAndQuit(); // 4J-PB - removed, since it needs to be localised in the language the client is in //server->players->broadcastAll( shared_ptr( new ChatPacket(L"�e" + player->name + L" left the game.") ) ); if(getWasKicked()) { - server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) ); + server->getPlayers()->broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerKickedFromGame)); } else { - server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) ); + server->getPlayers()->broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerLeftGame)); } server->getPlayers()->remove(player); @@ -376,7 +376,7 @@ void PlayerConnection::teleport(double x, double y, double z, float yRot, float player->absMoveTo(x, y, z, yRot, xRot); // 4J - note that 1.62 is added to the height here as the client connection that receives this will presume it represents y + heightOffset at that end // This is different to the way that height is sent back to the server, where it represents the bottom of the player bounding volume - if(sendPacket) player->connection->send( shared_ptr( new MovePlayerPacket::PosRot(x, y + 1.62f, y, z, yRot, xRot, false, false) ) ); + if(sendPacket) player->connection->send(std::make_shared(x, y + 1.62f, y, z, yRot, xRot, false, false)); } void PlayerConnection::handlePlayerAction(shared_ptr packet) @@ -429,19 +429,19 @@ void PlayerConnection::handlePlayerAction(shared_ptr packet) if (packet->action == PlayerActionPacket::START_DESTROY_BLOCK) { if (true) player->gameMode->startDestroyBlock(x, y, z, packet->face); // 4J - condition was !server->isUnderSpawnProtection(level, x, y, z, player) (from Java 1.6.4) but putting back to old behaviour - else player->connection->send( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + else player->connection->send(std::make_shared(x, y, z, level)); } else if (packet->action == PlayerActionPacket::STOP_DESTROY_BLOCK) { player->gameMode->stopDestroyBlock(x, y, z); server->getPlayers()->prioritiseTileChanges(x, y, z, level->dimension->id); // 4J added - make sure that the update packets for this get prioritised over other general world updates - if (level->getTile(x, y, z) != 0) player->connection->send( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + if (level->getTile(x, y, z) != 0) player->connection->send(std::make_shared(x, y, z, level)); } else if (packet->action == PlayerActionPacket::ABORT_DESTROY_BLOCK) { player->gameMode->abortDestroyBlock(x, y, z); - if (level->getTile(x, y, z) != 0) player->connection->send(shared_ptr( new TileUpdatePacket(x, y, z, level))); + if (level->getTile(x, y, z) != 0) player->connection->send(std::make_shared(x, y, z, level)); } } @@ -484,7 +484,7 @@ void PlayerConnection::handleUseItem(shared_ptr packet) if (informClient) { - player->connection->send( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + player->connection->send(std::make_shared(x, y, z, level)); if (face == 0) y--; if (face == 1) y++; @@ -500,7 +500,7 @@ void PlayerConnection::handleUseItem(shared_ptr packet) // isn't what it is expecting. if( level->getTile(x,y,z) != Tile::pistonMovingPiece_Id ) { - player->connection->send( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + player->connection->send(std::make_shared(x, y, z, level)); } } @@ -528,7 +528,7 @@ void PlayerConnection::handleUseItem(shared_ptr packet) if (forceClientUpdate || !ItemInstance::matches(player->inventory->getSelected(), packet->getItem())) { - send( shared_ptr( new ContainerSetSlotPacket(player->containerMenu->containerId, s->index, player->inventory->getSelected()) ) ); + send(std::make_shared(player->containerMenu->containerId, s->index, player->inventory->getSelected())); } } } @@ -542,11 +542,11 @@ void PlayerConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, //server->players->broadcastAll( shared_ptr( new ChatPacket(L"�e" + player->name + L" left the game.") ) ); if(getWasKicked()) { - server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) ); + server->getPlayers()->broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerKickedFromGame)); } else { - server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) ); + server->getPlayers()->broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerLeftGame)); } server->getPlayers()->remove(player); done = true; @@ -803,7 +803,7 @@ void PlayerConnection::handleTexture(shared_ptr packet) if(dwBytes!=0) { - send( shared_ptr( new TexturePacket(packet->textureName,pbData,dwBytes) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes)); } else { @@ -843,11 +843,11 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptrgetAdditionalBoxesCount()!=0) { - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pDLCSkinFile) ) ); + send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pDLCSkinFile)); } else { - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes) ) ); + send(std::make_shared(packet->textureName, pbData, dwTextureBytes)); } } else @@ -856,7 +856,7 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptr *pvSkinBoxes = app.GetAdditionalSkinBoxes(packet->dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID); - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pvSkinBoxes,uiAnimOverrideBitmask) ) ); + send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask)); } } else @@ -901,7 +901,7 @@ void PlayerConnection::handleTextureReceived(const wstring &textureName) if(dwBytes!=0) { - send( shared_ptr( new TexturePacket(textureName,pbData,dwBytes) ) ); + send(std::make_shared(textureName, pbData, dwBytes)); m_texturesRequested.erase(it); } } @@ -922,7 +922,7 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa { if(pDLCSkinFile && (pDLCSkinFile->getAdditionalBoxesCount()!=0)) { - send( shared_ptr( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes,pDLCSkinFile) ) ); + send(std::make_shared(textureName, pbData, dwTextureBytes, pDLCSkinFile)); } else { @@ -931,7 +931,7 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa vector *pvSkinBoxes = app.GetAdditionalSkinBoxes(dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(dwSkinID); - send( shared_ptr( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask) ) ); + send(std::make_shared(textureName, pbData, dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask)); } m_texturesRequested.erase(it); } @@ -958,20 +958,25 @@ void PlayerConnection::handleTextureChange(shared_ptr packe } if(!packet->path.empty() && packet->path.substr(0,3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(packet->path)) { - if( server->connection->addPendingTextureRequest(packet->path)) - { + if (server->connection->addPendingTextureRequest(packet->path)) + { #ifndef _CONTENT_PACKAGE - wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str()); + wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n", packet->path.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TexturePacket(packet->path,nullptr,0) ) ); - } - } + send(std::make_shared( + packet->path, + nullptr, + static_cast(0) + )); + + } + } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data app.AddMemoryTextureFile(packet->path,nullptr,0); } - server->getPlayers()->broadcastAll( shared_ptr( new TextureChangePacket(player,packet->action,packet->path) ), player->dimension ); + server->getPlayers()->broadcastAll(std::make_shared(player, packet->action, packet->path), player->dimension ); } void PlayerConnection::handleTextureAndGeometryChange(shared_ptr packet) @@ -990,7 +995,10 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptrpath.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TextureAndGeometryPacket(packet->path,nullptr,0) ) ); + send(std::make_shared( + packet->path, + nullptr, + static_cast(0))); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) @@ -1004,7 +1012,7 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptrdwSkinID,) //DebugBreak(); } - server->getPlayers()->broadcastAll( shared_ptr( new TextureAndGeometryChangePacket(player,packet->path) ), player->dimension ); + server->getPlayers()->broadcastAll(std::make_shared(player, packet->path), player->dimension ); } void PlayerConnection::handleServerSettingsChanged(shared_ptr packet) @@ -1026,7 +1034,7 @@ void PlayerConnection::handleServerSettingsChanged(shared_ptrdata, eGameHostOption_DoDaylightCycle)); app.SetGameHostOption(eGameHostOption_NaturalRegeneration, app.GetGameHostOption(packet->data, eGameHostOption_NaturalRegeneration)); - server->getPlayers()->broadcastAll( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS,app.GetGameHostOption(eGameHostOption_All) ) ) ); + server->getPlayers()->broadcastAll(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All))); // Update the QoS data g_NetworkManager.UpdateAndSetGameSessionData(); @@ -1141,7 +1149,7 @@ void PlayerConnection::handleContainerClick(shared_ptr pac if (ItemInstance::matches(packet->item, clicked)) { // Yep, you sure did click what you claimed to click! - player->connection->send( shared_ptr( new ContainerAckPacket(packet->containerId, packet->uid, true) ) ); + player->connection->send(std::make_shared(packet->containerId, packet->uid, true)); player->ignoreSlotUpdateHack = true; player->containerMenu->broadcastChanges(); player->broadcastCarriedItem(); @@ -1151,7 +1159,7 @@ void PlayerConnection::handleContainerClick(shared_ptr pac { // No, you clicked the wrong thing! expectedAcks[player->containerMenu->containerId] = packet->uid; - player->connection->send( shared_ptr( new ContainerAckPacket(packet->containerId, packet->uid, false) ) ); + player->connection->send(std::make_shared(packet->containerId, packet->uid, false)); player->containerMenu->setSynched(player, false); vector > items; @@ -1206,7 +1214,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr( new MapItemSavedData(id) ); + data = std::make_shared(id); } player->level->setSavedData(id, (shared_ptr ) data); @@ -1357,7 +1365,7 @@ void PlayerConnection::handlePlayerInfo(shared_ptr packet) #endif serverPlayer->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,Player::getPlayerGamePrivilege(packet->m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) ); serverPlayer->gameMode->setGameModeForPlayer(gameType); - serverPlayer->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, gameType->getId()) )); + serverPlayer->connection->send(std::make_shared(GameEventPacket::CHANGE_GAME_MODE, gameType->getId())); } else { @@ -1409,7 +1417,7 @@ void PlayerConnection::handlePlayerInfo(shared_ptr packet) } } - server->getPlayers()->broadcastAll( shared_ptr( new PlayerInfoPacket( serverPlayer ) ) ); + server->getPlayers()->broadcastAll(std::make_shared(serverPlayer)); } } } @@ -1656,7 +1664,7 @@ void PlayerConnection::handleCraftItem(shared_ptr packet) if (ingItemInst->getItem()->hasCraftingRemainingItem()) { // replace item with remaining result - player->inventory->add( shared_ptr( new ItemInstance(ingItemInst->getItem()->getCraftingRemainingItem()) ) ); + player->inventory->add(std::make_shared(ingItemInst->getItem()->getCraftingRemainingItem())); } } diff --git a/Minecraft.Client/PlayerList.cpp b/Minecraft.Client/PlayerList.cpp index 24457bee8..bd3bf3ddc 100644 --- a/Minecraft.Client/PlayerList.cpp +++ b/Minecraft.Client/PlayerList.cpp @@ -151,7 +151,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr player->setCustomCape( packet->m_playerCapeId ); // 4J-JEV: Moved this here so we can send player-model texture and geometry data. - shared_ptr playerConnection = shared_ptr(new PlayerConnection(server, connection, player)); + shared_ptr playerConnection = std::make_shared(server, connection, player); //player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use shared_ptr if(newPlayer) @@ -167,7 +167,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr int centreZC = 0; #endif // 4J Added - Give every player a map the first time they join a server - player->inventory->setItem( 9, shared_ptr( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) ); + player->inventory->setItem( 9, std::make_shared(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(), 0, centreXC, centreZC, mapScale))); if(app.getGameRuleDefinitions() != nullptr) { app.getGameRuleDefinitions()->postProcessPlayer(player); @@ -175,13 +175,17 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr } if(!player->customTextureUrl.empty() && player->customTextureUrl.substr(0,3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(player->customTextureUrl)) - { - if( server->getConnection()->addPendingTextureRequest(player->customTextureUrl)) - { + { + if (server->getConnection()->addPendingTextureRequest(player->customTextureUrl)) + { #ifndef _CONTENT_PACKAGE - wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl.c_str(), player->name.c_str()); + wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n", player->customTextureUrl.c_str(), player->name.c_str()); #endif - playerConnection->send(shared_ptr( new TextureAndGeometryPacket(player->customTextureUrl,nullptr,0) ) ); + playerConnection->send(std::make_shared( + player->customTextureUrl, + nullptr, + static_cast(0))); + } } else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl)) @@ -197,7 +201,11 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr #ifndef _CONTENT_PACKAGE wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str()); #endif - playerConnection->send(shared_ptr( new TexturePacket(player->customTextureUrl2,nullptr,0) ) ); + playerConnection->send(std::make_shared( + player->customTextureUrl, + nullptr, + static_cast(0) + )); } } else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2)) @@ -233,13 +241,13 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr addPlayerToReceiving( player ); - playerConnection->send( shared_ptr( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(), - static_cast(level->dimension->id), static_cast(level->getMaxBuildHeight()), static_cast(getMaxPlayers()), - level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), static_cast(playerIndex), level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(), - level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) ); - playerConnection->send( shared_ptr( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) ); - playerConnection->send( shared_ptr( new PlayerAbilitiesPacket(&player->abilities)) ); - playerConnection->send( shared_ptr( new SetCarriedItemPacket(player->inventory->selected))); + playerConnection->send(std::make_shared(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(), + static_cast(level->dimension->id), static_cast(level->getMaxBuildHeight()), static_cast(getMaxPlayers()), + level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), static_cast(playerIndex), level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(), + level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale())); + playerConnection->send(std::make_shared(spawnPos->x, spawnPos->y, spawnPos->z)); + playerConnection->send(std::make_shared(&player->abilities)); + playerConnection->send(std::make_shared(player->inventory->selected)); delete spawnPos; updateEntireScoreboard((ServerScoreboard *) level->getScoreboard(), player); @@ -248,7 +256,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr // 4J-PB - removed, since it needs to be localised in the language the client is in //server->players->broadcastAll( shared_ptr( new ChatPacket(L"�e" + playerEntity->name + L" joined the game.") ) ); - broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) ); + broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerJoinedGame)); MemSect(14); add(player); @@ -258,12 +266,12 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr playerConnection->teleport(player->x, player->y, player->z, player->yRot, player->xRot); server->getConnection()->addPlayerConnection(playerConnection); - playerConnection->send( shared_ptr( new SetTimePacket(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) ) ); + playerConnection->send(std::make_shared(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT))); auto activeEffects = player->getActiveEffects(); for(MobEffectInstance *effect : *player->getActiveEffects()) { - playerConnection->send(shared_ptr( new UpdateMobEffectPacket(player->entityId, effect) ) ); + playerConnection->send(std::make_shared(player->entityId, effect)); } player->initMenu(); @@ -430,7 +438,7 @@ void PlayerList::add(shared_ptr player) //broadcastAll(shared_ptr( new PlayerInfoPacket(player->name, true, 1000) ) ); if( player->connection->getNetworkPlayer() ) { - broadcastAll(shared_ptr( new PlayerInfoPacket( player ) ) ); + broadcastAll(std::make_shared(player)); } players.push_back(player); @@ -456,7 +464,7 @@ void PlayerList::add(shared_ptr player) //player->connection->send(shared_ptr( new PlayerInfoPacket(op->name, true, op->latency) ) ); if( op->connection->getNetworkPlayer() ) { - player->connection->send(shared_ptr( new PlayerInfoPacket( op ) ) ); + player->connection->send(std::make_shared(op)); } } @@ -469,10 +477,10 @@ void PlayerList::add(shared_ptr player) if(thisPlayer->isSleeping()) { if(firstSleepingPlayer == nullptr) firstSleepingPlayer = thisPlayer; - thisPlayer->connection->send(shared_ptr( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep))); + thisPlayer->connection->send(std::make_shared(thisPlayer->name, ChatPacket::e_ChatBedMeSleep)); } } - player->connection->send(shared_ptr( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep))); + player->connection->send(std::make_shared(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep)); } } @@ -522,7 +530,7 @@ shared_ptr PlayerList::getPlayerForLogin(PendingConnection *pendin pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull); return shared_ptr(); } - shared_ptr player = shared_ptr(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) )); + shared_ptr player = std::make_shared(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0))); player->gameMode->player = player; // 4J added as had to remove this assignment from ServerPlayer ctor player->setXuid( xuid ); // 4J Added player->setOnlineXuid( onlineXuid ); // 4J Added @@ -634,7 +642,7 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay PlayerUID playerXuid = serverPlayer->getXuid(); PlayerUID playerOnlineXuid = serverPlayer->getOnlineXuid(); - shared_ptr player = shared_ptr(new ServerPlayer(server, server->getLevel(serverPlayer->dimension), serverPlayer->getName(), new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension)))); + shared_ptr player = std::make_shared(server, server->getLevel(serverPlayer->dimension), serverPlayer->getName(), new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension))); player->connection = serverPlayer->connection; player->restoreFrom(serverPlayer, keepAllPlayerData); if (keepAllPlayerData) @@ -692,7 +700,7 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay } else { - player->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) ); + player->connection->send(std::make_shared(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0)); } delete bedPosition; } @@ -822,9 +830,9 @@ void PlayerList::toggleDimension(shared_ptr player, int targetDime // 4J Stu Added so that we remove entities from the correct level, after the respawn packet we will be in the wrong level player->flushEntitiesToRemove(); - player->connection->send( shared_ptr( new RespawnPacket(static_cast(player->dimension), newLevel->getSeed(), newLevel->getMaxBuildHeight(), - player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(), - newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale()) ) ); + player->connection->send(std::make_shared(static_cast(player->dimension), newLevel->getSeed(), newLevel->getMaxBuildHeight(), + player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(), + newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale())); oldLevel->removeEntityImmediately(player); player->removed = false; @@ -951,7 +959,7 @@ void PlayerList::tick() //broadcastAll(shared_ptr( new PlayerInfoPacket(op->name, true, op->latency) ) ); if( op->connection->getNetworkPlayer() ) { - broadcastAll(shared_ptr( new PlayerInfoPacket( op ) ) ); + broadcastAll(std::make_shared(op)); } } @@ -1013,7 +1021,7 @@ void PlayerList::tick() // 4J Stu - If we have kicked a player, make sure that they have no privileges if they later try to join the world when trust players is off player->enableAllPlayerPrivileges( false ); player->connection->setWasKicked(); - player->connection->send( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) )); + player->connection->send(std::make_shared(DisconnectPacket::eDisconnect_Kicked)); } //#endif } @@ -1240,7 +1248,7 @@ void PlayerList::sendMessage(const wstring& name, const wstring& message) shared_ptr player = getPlayer(name); if (player != nullptr) { - player->connection->send( shared_ptr( new ChatPacket(message) ) ); + player->connection->send(std::make_shared(message)); } } @@ -1351,22 +1359,22 @@ void PlayerList::reloadWhitelist() void PlayerList::sendLevelInfo(shared_ptr player, ServerLevel *level) { - player->connection->send( shared_ptr( new SetTimePacket(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) ) ); + player->connection->send(std::make_shared(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT))); if (level->isRaining()) { - player->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) ); + player->connection->send(std::make_shared(GameEventPacket::START_RAINING, 0)); } else { // 4J Stu - Fix for #44836 - Customer Encountered: Out of Sync Weather [A-10] // If it was raining when the player left the level, and is now not raining we need to make sure that state is updated - player->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) ); + player->connection->send(std::make_shared(GameEventPacket::STOP_RAINING, 0)); } // send the stronghold position if there is one if((level->dimension->id==0) && level->getLevelData()->getHasStronghold()) { - player->connection->send( shared_ptr( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) ); + player->connection->send(std::make_shared(XZPacket::STRONGHOLD, level->getLevelData()->getXStronghold(), level->getLevelData()->getZStronghold())); } } @@ -1374,7 +1382,7 @@ void PlayerList::sendAllPlayerInfo(shared_ptr player) { player->refreshContainer(player->inventoryMenu); player->resetSentInfo(); - player->connection->send( shared_ptr( new SetCarriedItemPacket(player->inventory->selected)) ); + player->connection->send(std::make_shared(player->inventory->selected)); } int PlayerList::getPlayerCount() diff --git a/Minecraft.Client/PlayerRenderer.cpp b/Minecraft.Client/PlayerRenderer.cpp index f4803eaee..ccc532f3c 100644 --- a/Minecraft.Client/PlayerRenderer.cpp +++ b/Minecraft.Client/PlayerRenderer.cpp @@ -353,7 +353,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) if (mob->fishing != nullptr) { - item = shared_ptr( new ItemInstance(Item::stick) ); + item = std::make_shared(Item::stick); } UseAnim anim = UseAnim_none;//null; diff --git a/Minecraft.Client/ReceivingLevelScreen.cpp b/Minecraft.Client/ReceivingLevelScreen.cpp index fda24773e..2969b0539 100644 --- a/Minecraft.Client/ReceivingLevelScreen.cpp +++ b/Minecraft.Client/ReceivingLevelScreen.cpp @@ -23,7 +23,7 @@ void ReceivingLevelScreen::tick() tickCount++; if (tickCount % 20 == 0) { - connection->send( shared_ptr( new KeepAlivePacket() ) ); + connection->send(std::make_shared()); } if (connection != nullptr) { diff --git a/Minecraft.Client/ServerLevel.cpp b/Minecraft.Client/ServerLevel.cpp index 89fe12a4b..090ec3466 100644 --- a/Minecraft.Client/ServerLevel.cpp +++ b/Minecraft.Client/ServerLevel.cpp @@ -497,7 +497,7 @@ void ServerLevel::tickTiles() if (isRainingAt(x, y, z)) { - addGlobalEntity( shared_ptr( new LightningBolt(this, x, y, z) ) ); + addGlobalEntity(std::make_shared(this, x, y, z)); } } @@ -1085,7 +1085,7 @@ bool ServerLevel::addGlobalEntity(shared_ptr e) { if (Level::addGlobalEntity(e)) { - server->getPlayers()->broadcast(e->x, e->y, e->z, 512, dimension->id, shared_ptr( new AddGlobalEntityPacket(e) ) ); + server->getPlayers()->broadcast(e->x, e->y, e->z, 512, dimension->id, std::make_shared(e)); return true; } return false; @@ -1093,7 +1093,7 @@ bool ServerLevel::addGlobalEntity(shared_ptr e) void ServerLevel::broadcastEntityEvent(shared_ptr e, byte event) { - shared_ptr p = shared_ptr( new EntityEventPacket(e->entityId, event) ); + shared_ptr p = std::make_shared(e->entityId, event); server->getLevel(dimension->id)->getTracker()->broadcastAndSend(e, p); } @@ -1101,7 +1101,7 @@ shared_ptr ServerLevel::explode(shared_ptr source, double x, { // instead of calling super, we run the same explosion code here except // we don't generate any particles - shared_ptr explosion = shared_ptr( new Explosion(this, source, x, y, z, r) ); + shared_ptr explosion = std::make_shared(this, source, x, y, z, r); explosion->fire = fire; explosion->destroyBlocks = destroyBlocks; explosion->explode(); @@ -1144,7 +1144,7 @@ shared_ptr ServerLevel::explode(shared_ptr source, double x, Vec3 *knockbackVec = explosion->getHitPlayerKnockback(player); //app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n", knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z); // If the player is not the primary on the system, then we only want to send info for the knockback - player->connection->send( shared_ptr( new ExplodePacket(x, y, z, r, &explosion->toBlow, knockbackVec, knockbackOnly))); + player->connection->send(std::make_shared(x, y, z, r, &explosion->toBlow, knockbackVec, knockbackOnly)); sentTo.push_back( player ); } } @@ -1182,7 +1182,7 @@ void ServerLevel::runTileEvents() if (doTileEvent(&it)) { TileEventData te = it; - server->getPlayers()->broadcast(te.getX(), te.getY(), te.getZ(), 64, dimension->id, shared_ptr( new TileEventPacket(te.getX(), te.getY(), te.getZ(), te.getTile(), te.getParamA(), te.getParamB()))); + server->getPlayers()->broadcast(te.getX(), te.getY(), te.getZ(), 64, dimension->id, std::make_shared(te.getX(), te.getY(), te.getZ(), te.getTile(), te.getParamA(), te.getParamB())); } } tileEvents[runList].clear(); @@ -1212,11 +1212,11 @@ void ServerLevel::tickWeather() { if (wasRaining) { - server->getPlayers()->broadcastAll( shared_ptr( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) ); + server->getPlayers()->broadcastAll(std::make_shared(GameEventPacket::STOP_RAINING, 0)); } else { - server->getPlayers()->broadcastAll( shared_ptr( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) ); + server->getPlayers()->broadcastAll(std::make_shared(GameEventPacket::START_RAINING, 0)); } } diff --git a/Minecraft.Client/ServerPlayer.cpp b/Minecraft.Client/ServerPlayer.cpp index dc4628ab1..11035438b 100644 --- a/Minecraft.Client/ServerPlayer.cpp +++ b/Minecraft.Client/ServerPlayer.cpp @@ -280,7 +280,7 @@ void ServerPlayer::flushEntitiesToRemove() it = entitiesToRemove.erase(it); } - connection->send(shared_ptr(new RemoveEntitiesPacket(ids))); + connection->send(std::make_shared(ids)); } } @@ -429,7 +429,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) // app.DebugPrintf("Creating BRUP for %d %d\n",nearest.x, nearest.z); PIXBeginNamedEvent(0,"Creation BRUP for sending\n"); __int64 before = System::currentTimeMillis(); - shared_ptr packet = shared_ptr( new BlockRegionUpdatePacket(nearest.x * 16, 0, nearest.z * 16, 16, Level::maxBuildHeight, 16, level) ); + shared_ptr packet = std::make_shared(nearest.x * 16, 0, nearest.z * 16, 16, Level::maxBuildHeight, 16, level); __int64 after = System::currentTimeMillis(); // app.DebugPrintf(">>><<< %d ms\n",after-before); PIXEndNamedEvent(); @@ -523,7 +523,7 @@ void ServerPlayer::doTickB() if (getHealth() != lastSentHealth || lastSentFood != foodData.getFoodLevel() || ((foodData.getSaturationLevel() == 0) != lastFoodSaturationZero)) { // 4J Stu - Added m_lastDamageSource for telemetry - connection->send( shared_ptr( new SetHealthPacket(getHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel(), m_lastDamageSource) ) ); + connection->send(std::make_shared(getHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel(), m_lastDamageSource)); lastSentHealth = getHealth(); lastSentFood = foodData.getFoodLevel(); lastFoodSaturationZero = foodData.getSaturationLevel() == 0; @@ -550,7 +550,7 @@ void ServerPlayer::doTickB() if (totalExperience != lastSentExp) { lastSentExp = totalExperience; - connection->send( shared_ptr( new SetExperiencePacket(experienceProgress, totalExperience, experienceLevel) ) ); + connection->send(std::make_shared(experienceProgress, totalExperience, experienceLevel)); } } @@ -741,7 +741,7 @@ void ServerPlayer::changeDimension(int i) level->removeEntity(shared_from_this()); wonGame = true; m_enteredEndExitPortal = true; // We only flag this for the player in the portal - connection->send( shared_ptr( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex()) ) ); + connection->send(std::make_shared(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex())); app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex()); } if(thisPlayer) @@ -752,7 +752,7 @@ void ServerPlayer::changeDimension(int i) if(thisPlayer != checkPlayer && checkPlayer != nullptr && thisPlayer->IsSameSystem( checkPlayer ) && !servPlayer->wonGame ) { servPlayer->wonGame = true; - servPlayer->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex() ) ) ); + servPlayer->connection->send(std::make_shared(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex())); app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex()); } } @@ -812,7 +812,7 @@ Player::BedSleepingResult ServerPlayer::startSleepInBed(int x, int y, int z, boo BedSleepingResult result = Player::startSleepInBed(x, y, z, bTestUse); if (result == OK) { - shared_ptr p = shared_ptr( new EntityActionAtPositionPacket(shared_from_this(), EntityActionAtPositionPacket::START_SLEEP, x, y, z) ); + shared_ptr p = std::make_shared(shared_from_this(), EntityActionAtPositionPacket::START_SLEEP, x, y, z); getLevel()->getTracker()->broadcast(shared_from_this(), p); connection->teleport(this->x, this->y, this->z, yRot, xRot); connection->send(p); @@ -824,7 +824,7 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, boo { if (isSleeping()) { - getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::WAKE_UP) ) ); + getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared(shared_from_this(), AnimatePacket::WAKE_UP)); } Player::stopSleepInBed(forcefulWakeUp, updateLevelList, saveRespawnPoint); if (connection != nullptr) connection->teleport(x, y, z, yRot, xRot); @@ -833,7 +833,7 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, boo void ServerPlayer::ride(shared_ptr e) { Player::ride(e); - connection->send( shared_ptr( new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, shared_from_this(), riding) ) ); + connection->send(std::make_shared(SetEntityLinkPacket::RIDING, shared_from_this(), riding)); // 4J Removed this - The act of riding will be handled on the client and will change the position // of the player. If we also teleport it then we can end up with a repeating movements, e.g. bouncing @@ -856,7 +856,7 @@ void ServerPlayer::openTextEdit(shared_ptr sign) if (signTE != nullptr) { signTE->setAllowedPlayerEditor(dynamic_pointer_cast(shared_from_this())); - connection->send( shared_ptr( new TileEditorOpenPacket(TileEditorOpenPacket::SIGN, sign->x, sign->y, sign->z)) ); + connection->send(std::make_shared(TileEditorOpenPacket::SIGN, sign->x, sign->y, sign->z)); } } @@ -870,7 +870,7 @@ bool ServerPlayer::startCrafting(int x, int y, int z) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::WORKBENCH, L"", 9, false) ) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::WORKBENCH, L"", 9, false)); containerMenu = new CraftingMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -888,7 +888,7 @@ bool ServerPlayer::openFireworks(int x, int y, int z) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false) ) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false)); containerMenu = new FireworksMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -898,7 +898,7 @@ bool ServerPlayer::openFireworks(int x, int y, int z) closeContainer(); nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false) ) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false)); containerMenu = new FireworksMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -916,7 +916,7 @@ bool ServerPlayer::startEnchanting(int x, int y, int z, const wstring &name) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send(shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::ENCHANTMENT, name.empty()? L"" : name, 9, !name.empty() ) )); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::ENCHANTMENT, name.empty() ? L"" : name, 9, !name.empty())); containerMenu = new EnchantmentMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -934,7 +934,7 @@ bool ServerPlayer::startRepairing(int x, int y, int z) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send(shared_ptr ( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::REPAIR_TABLE, L"", 9, false)) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::REPAIR_TABLE, L"", 9, false)); containerMenu = new AnvilMenu(inventory, level, x, y, z, dynamic_pointer_cast(shared_from_this())); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -957,7 +957,7 @@ bool ServerPlayer::openContainer(shared_ptr container) int containerType = container->getContainerType(); assert(containerType >= 0); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, containerType, container->getCustomName(), container->getContainerSize(), container->hasCustomName()) ) ); + connection->send(std::make_shared(containerCounter, containerType, container->getCustomName(), container->getContainerSize(), container->hasCustomName())); containerMenu = new ContainerMenu(inventory, container); containerMenu->containerId = containerCounter; @@ -976,7 +976,7 @@ bool ServerPlayer::openHopper(shared_ptr container) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName())) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName())); containerMenu = new HopperMenu(inventory, container); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -994,7 +994,7 @@ bool ServerPlayer::openHopper(shared_ptr container) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName())) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName())); containerMenu = new HopperMenu(inventory, container); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1012,7 +1012,7 @@ bool ServerPlayer::openFurnace(shared_ptr furnace) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::FURNACE, furnace->getCustomName(), furnace->getContainerSize(), furnace->hasCustomName()) ) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::FURNACE, furnace->getCustomName(), furnace->getContainerSize(), furnace->hasCustomName())); containerMenu = new FurnaceMenu(inventory, furnace); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1030,7 +1030,7 @@ bool ServerPlayer::openTrap(shared_ptr trap) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, trap->GetType() == eTYPE_DROPPERTILEENTITY ? ContainerOpenPacket::DROPPER : ContainerOpenPacket::TRAP, trap->getCustomName(), trap->getContainerSize(), trap->hasCustomName() ) ) ); + connection->send(std::make_shared(containerCounter, trap->GetType() == eTYPE_DROPPERTILEENTITY ? ContainerOpenPacket::DROPPER : ContainerOpenPacket::TRAP, trap->getCustomName(), trap->getContainerSize(), trap->hasCustomName())); containerMenu = new TrapMenu(inventory, trap); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1048,7 +1048,7 @@ bool ServerPlayer::openBrewingStand(shared_ptr brewingSt if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send(shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::BREWING_STAND, brewingStand->getCustomName(), brewingStand->getContainerSize(), brewingStand->hasCustomName() ))); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::BREWING_STAND, brewingStand->getCustomName(), brewingStand->getContainerSize(), brewingStand->hasCustomName())); containerMenu = new BrewingStandMenu(inventory, brewingStand); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1066,7 +1066,7 @@ bool ServerPlayer::openBeacon(shared_ptr beacon) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send(shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::BEACON, beacon->getCustomName(), beacon->getContainerSize(), beacon->hasCustomName() ))); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::BEACON, beacon->getCustomName(), beacon->getContainerSize(), beacon->hasCustomName())); containerMenu = new BeaconMenu(inventory, beacon); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1089,7 +1089,7 @@ bool ServerPlayer::openTrading(shared_ptr traderTarget, const wstring containerMenu->addSlotListener(this); shared_ptr container = static_cast(containerMenu)->getTradeContainer(); - connection->send(shared_ptr(new ContainerOpenPacket(containerCounter, ContainerOpenPacket::TRADER_NPC, name.empty()?L"":name, container->getContainerSize(), !name.empty()))); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::TRADER_NPC, name.empty() ? L"" : name, container->getContainerSize(), !name.empty())); MerchantRecipeList *offers = traderTarget->getOffers(dynamic_pointer_cast(shared_from_this())); if (offers != nullptr) @@ -1101,7 +1101,7 @@ bool ServerPlayer::openTrading(shared_ptr traderTarget, const wstring output.writeInt(containerCounter); offers->writeToStream(&output); - connection->send(shared_ptr( new CustomPayloadPacket(CustomPayloadPacket::TRADER_LIST_PACKET, rawOutput.toByteArray()))); + connection->send(std::make_shared(CustomPayloadPacket::TRADER_LIST_PACKET, rawOutput.toByteArray())); } } else @@ -1119,7 +1119,7 @@ bool ServerPlayer::openHorseInventory(shared_ptr horse, shared_ptr< closeContainer(); } nextContainerCounter(); - connection->send(shared_ptr(new ContainerOpenPacket(containerCounter, ContainerOpenPacket::HORSE, horse->getCustomName(), container->getContainerSize(), container->hasCustomName(), horse->entityId ))); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::HORSE, horse->getCustomName(), container->getContainerSize(), container->hasCustomName(), horse->entityId)); containerMenu = new HorseInventoryMenu(inventory, container, horse); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1144,7 +1144,7 @@ void ServerPlayer::slotChanged(AbstractContainerMenu *container, int slotIndex, return; } - connection->send( shared_ptr( new ContainerSetSlotPacket(container->containerId, slotIndex, item) ) ); + connection->send(std::make_shared(container->containerId, slotIndex, item)); } @@ -1157,8 +1157,8 @@ void ServerPlayer::refreshContainer(AbstractContainerMenu *menu) void ServerPlayer::refreshContainer(AbstractContainerMenu *container, vector > *items) { - connection->send( shared_ptr( new ContainerSetContentPacket(container->containerId, items) ) ); - connection->send( shared_ptr( new ContainerSetSlotPacket(-1, -1, inventory->getCarried()) ) ); + connection->send(std::make_shared(container->containerId, items)); + connection->send(std::make_shared(-1, -1, inventory->getCarried())); } void ServerPlayer::setContainerData(AbstractContainerMenu *container, int id, int value) @@ -1173,12 +1173,12 @@ void ServerPlayer::setContainerData(AbstractContainerMenu *container, int id, in // client again. return; } - connection->send( shared_ptr( new ContainerSetDataPacket(container->containerId, id, value) ) ); + connection->send(std::make_shared(container->containerId, id, value)); } void ServerPlayer::closeContainer() { - connection->send( shared_ptr( new ContainerClosePacket(containerMenu->containerId) ) ); + connection->send(std::make_shared(containerMenu->containerId)); doCloseContainer(); } @@ -1192,7 +1192,7 @@ void ServerPlayer::broadcastCarriedItem() // client again. return; } - connection->send( shared_ptr( new ContainerSetSlotPacket(-1, -1, inventory->getCarried()) ) ); + connection->send(std::make_shared(-1, -1, inventory->getCarried())); } void ServerPlayer::doCloseContainer() @@ -1226,7 +1226,7 @@ void ServerPlayer::awardStat(Stat *stat, byteArray param) int count = *((int*)param.data); delete [] param.data; - connection->send( shared_ptr( new AwardStatPacket(stat->id, count) ) ); + connection->send(std::make_shared(stat->id, count)); #else connection->send( shared_ptr( new AwardStatPacket(stat->id, param) ) ); // byteArray deleted in AwardStatPacket destructor. @@ -1257,19 +1257,19 @@ void ServerPlayer::displayClientMessage(int messageId) { case IDS_TILE_BED_OCCUPIED: messageType = ChatPacket::e_ChatBedOccupied; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_NO_SLEEP: messageType = ChatPacket::e_ChatBedNoSleep; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_NOT_VALID: messageType = ChatPacket::e_ChatBedNotValid; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_NOTSAFE: messageType = ChatPacket::e_ChatBedNotSafe; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_PLAYERSLEEP: messageType = ChatPacket::e_ChatBedPlayerSleep; @@ -1279,11 +1279,11 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()!=player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatBedPlayerSleep))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatBedPlayerSleep)); } else { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatBedMeSleep))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatBedMeSleep)); } } return; @@ -1294,7 +1294,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()!=player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerEnteredEnd))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerEnteredEnd)); } } break; @@ -1304,13 +1304,13 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()!=player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerLeftEnd))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerLeftEnd)); } } break; case IDS_TILE_BED_MESLEEP: messageType = ChatPacket::e_ChatBedMeSleep; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_MAX_PIGS_SHEEP_COWS_CATS_SPAWNED: @@ -1319,7 +1319,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxPigsSheepCows))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxPigsSheepCows)); } } break; @@ -1329,7 +1329,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxChickens))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxChickens)); } } break; @@ -1339,7 +1339,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxSquid))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxSquid)); } } break; @@ -1349,7 +1349,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBats))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBats)); } } break; @@ -1359,7 +1359,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxWolves))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxWolves)); } } break; @@ -1369,7 +1369,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxMooshrooms))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxMooshrooms)); } } break; @@ -1379,7 +1379,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxEnemies))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxEnemies)); } } break; @@ -1390,7 +1390,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxVillagers))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxVillagers)); } } break; @@ -1400,7 +1400,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredPigsSheepCows))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBredPigsSheepCows)); } } break; @@ -1410,7 +1410,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredChickens))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBredChickens)); } } break; @@ -1420,7 +1420,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredMooshrooms))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBredMooshrooms)); } } break; @@ -1431,7 +1431,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredWolves))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBredWolves)); } } break; @@ -1442,7 +1442,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerCantShearMooshroom))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerCantShearMooshroom)); } } break; @@ -1454,7 +1454,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxHangingEntities))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxHangingEntities)); } } break; @@ -1464,7 +1464,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerCantSpawnInPeaceful))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerCantSpawnInPeaceful)); } } break; @@ -1475,7 +1475,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBoats))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBoats)); } } break; @@ -1493,7 +1493,7 @@ void ServerPlayer::displayClientMessage(int messageId) void ServerPlayer::completeUsingItem() { - connection->send(shared_ptr( new EntityEventPacket(entityId, EntityEvent::USE_ITEM_COMPLETE) ) ); + connection->send(std::make_shared(entityId, EntityEvent::USE_ITEM_COMPLETE)); Player::completeUsingItem(); } @@ -1503,7 +1503,7 @@ void ServerPlayer::startUsingItem(shared_ptr instance, int duratio if (instance != nullptr && instance->getItem() != nullptr && instance->getItem()->getUseAnimation(instance) == UseAnim_eat) { - getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::EAT) ) ); + getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared(shared_from_this(), AnimatePacket::EAT)); } } @@ -1519,21 +1519,21 @@ void ServerPlayer::restoreFrom(shared_ptr oldPlayer, bool restoreAll) void ServerPlayer::onEffectAdded(MobEffectInstance *effect) { Player::onEffectAdded(effect); - connection->send(shared_ptr( new UpdateMobEffectPacket(entityId, effect) ) ); + connection->send(std::make_shared(entityId, effect)); } void ServerPlayer::onEffectUpdated(MobEffectInstance *effect, bool doRefreshAttributes) { Player::onEffectUpdated(effect, doRefreshAttributes); - connection->send(shared_ptr( new UpdateMobEffectPacket(entityId, effect) ) ); + connection->send(std::make_shared(entityId, effect)); } void ServerPlayer::onEffectRemoved(MobEffectInstance *effect) { Player::onEffectRemoved(effect); - connection->send(shared_ptr( new RemoveMobEffectPacket(entityId, effect) ) ); + connection->send(std::make_shared(entityId, effect)); } void ServerPlayer::teleportTo(double x, double y, double z) @@ -1543,18 +1543,18 @@ void ServerPlayer::teleportTo(double x, double y, double z) void ServerPlayer::crit(shared_ptr entity) { - getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(entity, AnimatePacket::CRITICAL_HIT) )); + getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared(entity, AnimatePacket::CRITICAL_HIT)); } void ServerPlayer::magicCrit(shared_ptr entity) { - getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(entity, AnimatePacket::MAGIC_CRITICAL_HIT) )); + getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared(entity, AnimatePacket::MAGIC_CRITICAL_HIT)); } void ServerPlayer::onUpdateAbilities() { if (connection == nullptr) return; - connection->send(shared_ptr(new PlayerAbilitiesPacket(&abilities))); + connection->send(std::make_shared(&abilities)); } ServerLevel *ServerPlayer::getLevel() @@ -1565,12 +1565,12 @@ ServerLevel *ServerPlayer::getLevel() void ServerPlayer::setGameMode(GameType *mode) { gameMode->setGameModeForPlayer(mode); - connection->send(shared_ptr(new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, mode->getId()))); + connection->send(std::make_shared(GameEventPacket::CHANGE_GAME_MODE, mode->getId())); } void ServerPlayer::sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type /*= e_ChatCustom*/, int customData /*= -1*/, const wstring& additionalMessage /*= L""*/) { - connection->send(shared_ptr(new ChatPacket(message,type,customData,additionalMessage))); + connection->send(std::make_shared(message, type, customData, additionalMessage)); } bool ServerPlayer::hasPermission(EGameCommand command) diff --git a/Minecraft.Client/ServerPlayerGameMode.cpp b/Minecraft.Client/ServerPlayerGameMode.cpp index daafc2ca6..d2dcaaf68 100644 --- a/Minecraft.Client/ServerPlayerGameMode.cpp +++ b/Minecraft.Client/ServerPlayerGameMode.cpp @@ -286,7 +286,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z) if (isCreative()) { - shared_ptr tup = shared_ptr( new TileUpdatePacket(x, y, z, level) ); + shared_ptr tup = std::make_shared(x, y, z, level); // 4J - a bit of a hack here, but if we want to tell the client that it needs to inform the renderer of a block being destroyed, then send a block 255 instead of a 0. This is handled in ClientConnection::handleTileUpdate if( tup->block == 0 ) { diff --git a/Minecraft.Client/SnowManRenderer.cpp b/Minecraft.Client/SnowManRenderer.cpp index 853127bb7..1ab1d4023 100644 --- a/Minecraft.Client/SnowManRenderer.cpp +++ b/Minecraft.Client/SnowManRenderer.cpp @@ -22,7 +22,7 @@ void SnowManRenderer::additionalRendering(shared_ptr _mob, float a shared_ptr mob = dynamic_pointer_cast(_mob); MobRenderer::additionalRendering(mob, a); - shared_ptr headGear = shared_ptr( new ItemInstance(Tile::pumpkin, 1) ); + shared_ptr headGear = std::make_shared(Tile::pumpkin, 1); if (headGear != nullptr && headGear->getItem()->id < 256) { glPushMatrix(); diff --git a/Minecraft.Client/TeleportCommand.cpp b/Minecraft.Client/TeleportCommand.cpp index 0ee269cd6..9dd29ff08 100644 --- a/Minecraft.Client/TeleportCommand.cpp +++ b/Minecraft.Client/TeleportCommand.cpp @@ -86,5 +86,5 @@ shared_ptr TeleportCommand::preparePacket(PlayerUID subject, dos.writePlayerUID(subject); dos.writePlayerUID(destination); - return shared_ptr( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() )); + return std::make_shared(eGameCommand_Teleport, baos.toByteArray()); } \ No newline at end of file diff --git a/Minecraft.Client/TextEditScreen.cpp b/Minecraft.Client/TextEditScreen.cpp index d9804b92a..4b32d1392 100644 --- a/Minecraft.Client/TextEditScreen.cpp +++ b/Minecraft.Client/TextEditScreen.cpp @@ -35,7 +35,7 @@ void TextEditScreen::removed() Keyboard::enableRepeatEvents(false); if (minecraft->level->isClientSide) { - minecraft->getConnection(0)->send( shared_ptr( new SignUpdatePacket(sign->x, sign->y, sign->z, sign->IsVerified(), sign->IsCensored(), sign->GetMessages()) ) ); + minecraft->getConnection(0)->send(std::make_shared(sign->x, sign->y, sign->z, sign->IsVerified(), sign->IsCensored(), sign->GetMessages())); } } diff --git a/Minecraft.Client/TexturePackRepository.cpp b/Minecraft.Client/TexturePackRepository.cpp index 92032aae0..ef926d78b 100644 --- a/Minecraft.Client/TexturePackRepository.cpp +++ b/Minecraft.Client/TexturePackRepository.cpp @@ -8,6 +8,7 @@ #include "..\Minecraft.World\File.h" #include "..\Minecraft.World\StringHelpers.h" #include "Minimap.h" +#include "Common/UI/UI.h" TexturePack *TexturePackRepository::DEFAULT_TEXTURE_PACK = nullptr; diff --git a/Minecraft.Client/TrackedEntity.cpp b/Minecraft.Client/TrackedEntity.cpp index 386339543..3aa33248d 100644 --- a/Minecraft.Client/TrackedEntity.cpp +++ b/Minecraft.Client/TrackedEntity.cpp @@ -66,7 +66,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (lastRidingEntity != e->riding || (e->riding != nullptr && tickCount % (SharedConstants::TICKS_PER_SECOND * 3) == 0)) { lastRidingEntity = e->riding; - broadcast(shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, e, e->riding))); + broadcast(std::make_shared(SetEntityLinkPacket::RIDING, e, e->riding)); } // Moving forward special case for item frames @@ -94,7 +94,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl shared_ptr entityData = e->getEntityData(); if (entityData->isDirty()) { - broadcastAndSend( shared_ptr( new SetEntityDataPacket(e->entityId, entityData, false) ) ); + broadcastAndSend(std::make_shared(e->entityId, entityData, false)); } } else if (tickCount % updateInterval == 0 || e->hasImpulse || e->getEntityData()->isDirty()) @@ -152,7 +152,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ) { teleportDelay = 0; - packet = shared_ptr( new TeleportEntityPacket(e->entityId, xn, yn, zn, static_cast(yRotn), static_cast(xRotn)) ); + packet = std::make_shared(e->entityId, xn, yn, zn, static_cast(yRotn), static_cast(xRotn)); // printf("%d: New teleport rot %d\n",e->entityId,yRotn); yRotp = yRotn; xRotp = xRotn; @@ -179,12 +179,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl yRotn = yRotp + yRota; } // 5 bits each for x & z, and 6 for y - packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), 0 ) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), 0); c0a++; } else { - packet = shared_ptr( new MoveEntityPacket::PosRot(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), static_cast(xRota)) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), static_cast(xRota)); // printf("%d: New posrot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); c0b++; } @@ -197,7 +197,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ( ya >= -16 ) && ( ya <= 15 ) ) { // 4 bits each for x & z, and 5 for y - packet = shared_ptr( new MoveEntityPacketSmall::Pos(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)); c1a++; } @@ -206,12 +206,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ( ya >= -32 ) && ( ya <= 31 ) ) { // use the packet with small packet with rotation if we can - 5 bits each for x & z, and 6 for y - still a byte less than the alternative - packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), 0, 0 )); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), 0, 0); c1b++; } else { - packet = shared_ptr( new MoveEntityPacket::Pos(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)); c1c++; } } @@ -231,13 +231,13 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl yRota = 15; yRotn = yRotp + yRota; } - packet = shared_ptr( new MoveEntityPacketSmall::Rot(e->entityId, static_cast(yRota), 0) ); + packet = std::make_shared(e->entityId, static_cast(yRota), 0); c2a++; } else { // printf("%d: New rot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); - packet = shared_ptr( new MoveEntityPacket::Rot(e->entityId, static_cast(yRota), static_cast(xRota)) ); + packet = std::make_shared(e->entityId, static_cast(yRota), static_cast(xRota)); c2b++; } } @@ -259,7 +259,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl xap = e->xd; yap = e->yd; zap = e->zd; - broadcast( shared_ptr( new SetEntityMotionPacket(e->entityId, xap, yap, zap) ) ); + broadcast(std::make_shared(e->entityId, xap, yap, zap)); } } @@ -291,7 +291,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (rot) { // 4J: Changed this to use deltas - broadcast( shared_ptr( new MoveEntityPacket::Rot(e->entityId, static_cast(yRota), static_cast(xRota))) ); + broadcast(std::make_shared(e->entityId, static_cast(yRota), static_cast(xRota))); yRotp = yRotn; xRotp = xRotn; } @@ -308,7 +308,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl int yHeadRot = Mth::floor(e->getYHeadRot() * 256 / 360); if (abs(yHeadRot - yHeadRotp) >= TOLERANCE_LEVEL) { - broadcast(shared_ptr( new RotateHeadPacket(e->entityId, static_cast(yHeadRot)))); + broadcast(std::make_shared(e->entityId, static_cast(yHeadRot))); yHeadRotp = yHeadRot; } @@ -320,7 +320,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (e->hurtMarked) { // broadcast(new AnimatePacket(e, AnimatePacket.HURT)); - broadcastAndSend( shared_ptr( new SetEntityMotionPacket(e) ) ); + broadcastAndSend(std::make_shared(e)); e->hurtMarked = false; } @@ -331,7 +331,7 @@ void TrackedEntity::sendDirtyEntityData() shared_ptr entityData = e->getEntityData(); if (entityData->isDirty()) { - broadcastAndSend( shared_ptr( new SetEntityDataPacket(e->entityId, entityData, false)) ); + broadcastAndSend(std::make_shared(e->entityId, entityData, false)); } if ( e->instanceof(eTYPE_LIVINGENTITY) ) @@ -342,7 +342,7 @@ void TrackedEntity::sendDirtyEntityData() if (!attributes->empty()) { - broadcastAndSend(shared_ptr( new UpdateAttributesPacket(e->entityId, attributes)) ); + broadcastAndSend(std::make_shared(e->entityId, attributes)); } attributes->clear(); @@ -539,7 +539,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptrgetEntityData()->isEmpty() && !isAddMobPacket) { - sp->connection->send(shared_ptr( new SetEntityDataPacket(e->entityId, e->getEntityData(), true))); + sp->connection->send(std::make_shared(e->entityId, e->getEntityData(), true)); } if ( e->instanceof(eTYPE_LIVINGENTITY) ) @@ -550,23 +550,23 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptrempty()) { - sp->connection->send(shared_ptr( new UpdateAttributesPacket(e->entityId, attributes)) ); + sp->connection->send(std::make_shared(e->entityId, attributes)); } delete attributes; } if (trackDelta && !isAddMobPacket) { - sp->connection->send( shared_ptr( new SetEntityMotionPacket(e->entityId, e->xd, e->yd, e->zd) ) ); + sp->connection->send(std::make_shared(e->entityId, e->xd, e->yd, e->zd)); } if (e->riding != nullptr) { - sp->connection->send(shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, e, e->riding))); + sp->connection->send(std::make_shared(SetEntityLinkPacket::RIDING, e, e->riding)); } if ( e->instanceof(eTYPE_MOB) && dynamic_pointer_cast(e)->getLeashHolder() != nullptr) { - sp->connection->send( shared_ptr( new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, e, dynamic_pointer_cast(e)->getLeashHolder())) ); + sp->connection->send(std::make_shared(SetEntityLinkPacket::LEASH, e, dynamic_pointer_cast(e)->getLeashHolder())); } if ( e->instanceof(eTYPE_LIVINGENTITY) ) @@ -574,7 +574,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr item = dynamic_pointer_cast(e)->getCarried(i); - if(item != nullptr) sp->connection->send( shared_ptr( new SetEquippedItemPacket(e->entityId, i, item) ) ); + if(item != nullptr) sp->connection->send(std::make_shared(e->entityId, i, item)); } } @@ -583,7 +583,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr spe = dynamic_pointer_cast(e); if (spe->isSleeping()) { - sp->connection->send( shared_ptr( new EntityActionAtPositionPacket(e, EntityActionAtPositionPacket::START_SLEEP, Mth::floor(e->x), Mth::floor(e->y), Mth::floor(e->z)) ) ); + sp->connection->send(std::make_shared(e, EntityActionAtPositionPacket::START_SLEEP, Mth::floor(e->x), Mth::floor(e->y), Mth::floor(e->z))); } } @@ -639,12 +639,12 @@ shared_ptr TrackedEntity::getAddEntityPacket() if (dynamic_pointer_cast(e) != nullptr) { yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); - return shared_ptr( new AddMobPacket(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp) ); + return std::make_shared(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp); } if (e->instanceof(eTYPE_ITEMENTITY)) { - shared_ptr packet = shared_ptr( new AddEntityPacket(e, AddEntityPacket::ITEM, 1, yRotp, xRotp, xp, yp, zp) ); + shared_ptr packet = std::make_shared(e, AddEntityPacket::ITEM, 1, yRotp, xRotp, xp, yp, zp); return packet; } else if (e->instanceof(eTYPE_SERVERPLAYER)) @@ -659,55 +659,55 @@ shared_ptr TrackedEntity::getAddEntityPacket() OnlineXuid = player->getOnlineXuid(); } // 4J Added yHeadRotp param to fix #102563 - TU12: Content: Gameplay: When one of the Players is idle for a few minutes his head turns 180 degrees. - return shared_ptr( new AddPlayerPacket( player, xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp, yHeadRotp ) ); + return std::make_shared(player, xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp, yHeadRotp); } else if (e->instanceof(eTYPE_MINECART)) { shared_ptr minecart = dynamic_pointer_cast(e); - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::MINECART, minecart->getType(), yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::MINECART, minecart->getType(), yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_BOAT)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ENDERDRAGON)) { yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); - return shared_ptr( new AddMobPacket(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp ) ); + return std::make_shared(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp); } else if (e->instanceof(eTYPE_FISHINGHOOK)) { shared_ptr owner = dynamic_pointer_cast(e)->owner; - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::FISH_HOOK, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ARROW)) { shared_ptr owner = (dynamic_pointer_cast(e))->owner; - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::ARROW, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::ARROW, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_SNOWBALL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNPOTION)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp)); + return std::make_shared(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNEXPBOTTLE)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNENDERPEARL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_EYEOFENDERSIGNAL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FIREWORKS_ROCKET)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FIREWORKS, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::FIREWORKS, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FIREBALL)) { @@ -730,11 +730,11 @@ shared_ptr TrackedEntity::getAddEntityPacket() shared_ptr aep = nullptr; if (fb->owner != nullptr) { - aep = shared_ptr( new AddEntityPacket(e, type, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) ); + aep = std::make_shared(e, type, fb->owner->entityId, yRotp, xRotp, xp, yp, zp); } else { - aep = shared_ptr( new AddEntityPacket(e, type, 0, yRotp, xRotp, xp, yp, zp) ); + aep = std::make_shared(e, type, 0, yRotp, xRotp, xp, yp, zp); } aep->xa = static_cast(fb->xPower * 8000); aep->ya = static_cast(fb->yPower * 8000); @@ -743,24 +743,24 @@ shared_ptr TrackedEntity::getAddEntityPacket() } else if (e->instanceof(eTYPE_THROWNEGG)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_PRIMEDTNT)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ENDER_CRYSTAL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FALLINGTILE)) { shared_ptr ft = dynamic_pointer_cast(e); - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FALLING, ft->tile | (ft->data << 16), yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::FALLING, ft->tile | (ft->data << 16), yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_PAINTING)) { - return shared_ptr( new AddPaintingPacket(dynamic_pointer_cast(e)) ); + return std::make_shared(dynamic_pointer_cast(e)); } else if (e->instanceof(eTYPE_ITEM_FRAME)) { @@ -774,7 +774,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() app.DebugPrintf("eTYPE_ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz); } - shared_ptr packet = shared_ptr(new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp)); + shared_ptr packet = std::make_shared(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp); packet->x = Mth::floor(frame->xTile * 32.0f); packet->y = Mth::floor(frame->yTile * 32.0f); packet->z = Mth::floor(frame->zTile * 32.0f); @@ -783,7 +783,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() else if (e->instanceof(eTYPE_LEASHFENCEKNOT)) { shared_ptr knot = dynamic_pointer_cast(e); - shared_ptr packet = shared_ptr(new AddEntityPacket(e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp) ); + shared_ptr packet = std::make_shared(e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp); packet->x = Mth::floor(static_cast(knot->xTile) * 32); packet->y = Mth::floor(static_cast(knot->yTile) * 32); packet->z = Mth::floor(static_cast(knot->zTile) * 32); @@ -791,7 +791,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() } else if (e->instanceof(eTYPE_EXPERIENCEORB)) { - return shared_ptr( new AddExperienceOrbPacket(dynamic_pointer_cast(e)) ); + return std::make_shared(dynamic_pointer_cast(e)); } else { diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 343dbd129..b2e2d2a30 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -43,6 +43,7 @@ #include "Common/PostProcesser.h" #include "Network\WinsockNetLayer.h" #include "Windows64_Xuid.h" +#include "Common/UI/UI.h" #include "Xbox/resource.h" @@ -78,7 +79,6 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= 0,0,0,0,0 #endif }; - //------------------------------------------------------------------------------------- // Time Since fAppTime is a float, we need to keep the quadword app time // as a LARGE_INTEGER so that we don't lose precision after running diff --git a/Minecraft.Client/Windows64/Windows64_UIController.h b/Minecraft.Client/Windows64/Windows64_UIController.h index 2b2ccdbac..066d279fb 100644 --- a/Minecraft.Client/Windows64/Windows64_UIController.h +++ b/Minecraft.Client/Windows64/Windows64_UIController.h @@ -26,5 +26,3 @@ public: public: void shutdown(); }; - -extern ConsoleUIController ui; \ No newline at end of file diff --git a/Minecraft.World/AbstractContainerMenu.cpp b/Minecraft.World/AbstractContainerMenu.cpp index 637d05a68..52d491a6b 100644 --- a/Minecraft.World/AbstractContainerMenu.cpp +++ b/Minecraft.World/AbstractContainerMenu.cpp @@ -276,7 +276,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto if(looped) { // Return a non-null value to indicate that we want to loop more - clickedEntity = shared_ptr(new ItemInstance(0,1,0)); + clickedEntity = std::make_shared(0, 1, 0); } else { @@ -467,20 +467,20 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto player->drop(item); } } - else if (clickType == CLICK_PICKUP_ALL && slotIndex >= 0) + else if (clickType == CLICK_PICKUP_ALL && slotIndex >= 0) { Slot *slot = slots.at(slotIndex); shared_ptr carried = inventory->getCarried(); if (carried != nullptr && (slot == nullptr || !slot->hasItem() || !slot->mayPickup(player))) { - int start = buttonNum == 0 ? 0 : slots.size() - 1; + int start = buttonNum == 0 ? 0 : static_cast(slots.size()) - 1; int step = buttonNum == 0 ? 1 : -1; for (int pass = 0; pass < 2; pass++ ) { // In the first pass, we only get partial stacks. - for (int i = start; i >= 0 && i < slots.size() && carried->count < carried->getMaxStackSize(); i += step) + for (int i = start; i >= 0 && i < static_cast(slots.size()) && carried->count < carried->getMaxStackSize(); i += step) { Slot *target = slots.at(i); diff --git a/Minecraft.World/AbstractContainerMenu.h b/Minecraft.World/AbstractContainerMenu.h index 3365593cf..9c7600ce1 100644 --- a/Minecraft.World/AbstractContainerMenu.h +++ b/Minecraft.World/AbstractContainerMenu.h @@ -35,7 +35,7 @@ public: static const int CONTAINER_ID_INVENTORY = 0; static const int CONTAINER_ID_CREATIVE = -2; - vector > lastSlots; + vector> lastSlots; vector slots; int containerId; diff --git a/Minecraft.World/AddEntityPacket.h b/Minecraft.World/AddEntityPacket.h index 293964796..d40a84379 100644 --- a/Minecraft.World/AddEntityPacket.h +++ b/Minecraft.World/AddEntityPacket.h @@ -52,6 +52,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new AddEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 23; } }; \ No newline at end of file diff --git a/Minecraft.World/AddExperienceOrbPacket.h b/Minecraft.World/AddExperienceOrbPacket.h index 59accfb31..f955a8bdb 100644 --- a/Minecraft.World/AddExperienceOrbPacket.h +++ b/Minecraft.World/AddExperienceOrbPacket.h @@ -19,6 +19,6 @@ public: virtual void handle(PacketListener *listener); virtual int getEstimatedSize(); - static shared_ptr create() { return shared_ptr(new AddExperienceOrbPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 26; } }; \ No newline at end of file diff --git a/Minecraft.World/AddGlobalEntityPacket.h b/Minecraft.World/AddGlobalEntityPacket.h index 80c10db2f..9959dc774 100644 --- a/Minecraft.World/AddGlobalEntityPacket.h +++ b/Minecraft.World/AddGlobalEntityPacket.h @@ -20,6 +20,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new AddGlobalEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 71; } }; \ No newline at end of file diff --git a/Minecraft.World/AddMobPacket.h b/Minecraft.World/AddMobPacket.h index 6af72655e..9f7c1e1c5 100644 --- a/Minecraft.World/AddMobPacket.h +++ b/Minecraft.World/AddMobPacket.h @@ -32,6 +32,6 @@ public: vector > *getUnpackedData(); public: - static shared_ptr create() { return shared_ptr(new AddMobPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 24; } }; diff --git a/Minecraft.World/AddPaintingPacket.h b/Minecraft.World/AddPaintingPacket.h index a5694b749..a50c1b771 100644 --- a/Minecraft.World/AddPaintingPacket.h +++ b/Minecraft.World/AddPaintingPacket.h @@ -22,6 +22,6 @@ public: virtual void handle(PacketListener *listener); virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new AddPaintingPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 25; } }; diff --git a/Minecraft.World/AddPlayerPacket.h b/Minecraft.World/AddPlayerPacket.h index 30f6bcdda..af90c97df 100644 --- a/Minecraft.World/AddPlayerPacket.h +++ b/Minecraft.World/AddPlayerPacket.h @@ -38,6 +38,6 @@ public: vector > *getUnpackedData(); public: - static shared_ptr create() { return shared_ptr(new AddPlayerPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 20; } }; diff --git a/Minecraft.World/Animal.cpp b/Minecraft.World/Animal.cpp index bd9bc3fad..682781623 100644 --- a/Minecraft.World/Animal.cpp +++ b/Minecraft.World/Animal.cpp @@ -154,7 +154,7 @@ void Animal::breedWith(shared_ptr target) } level->addEntity(offspring); - level->addEntity( shared_ptr( new ExperienceOrb(level, x, y, z, random->nextInt(4) + 1) ) ); + level->addEntity(std::make_shared(level, x, y, z, random->nextInt(4) + 1)); } setDespawnProtected(); diff --git a/Minecraft.World/AnimatePacket.h b/Minecraft.World/AnimatePacket.h index 0287b9a6e..7075ffab6 100644 --- a/Minecraft.World/AnimatePacket.h +++ b/Minecraft.World/AnimatePacket.h @@ -26,6 +26,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new AnimatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 18; } }; \ No newline at end of file diff --git a/Minecraft.World/AnvilMenu.cpp b/Minecraft.World/AnvilMenu.cpp index de3315544..78d72daf7 100644 --- a/Minecraft.World/AnvilMenu.cpp +++ b/Minecraft.World/AnvilMenu.cpp @@ -8,8 +8,8 @@ AnvilMenu::AnvilMenu(shared_ptr inventory, Level *level, int xt, int yt, int zt, shared_ptr player) { - resultSlots = shared_ptr( new ResultContainer() ); - repairSlots = shared_ptr( new RepairContainer(this,IDS_REPAIR_AND_NAME, true, 2) ); + resultSlots = std::make_shared(); + repairSlots = std::make_shared(this,IDS_REPAIR_AND_NAME, true, 2); cost = 0; repairItemCountCost = 0; diff --git a/Minecraft.World/Arrow.cpp b/Minecraft.World/Arrow.cpp index 4c5d9ae3b..c433715a5 100644 --- a/Minecraft.World/Arrow.cpp +++ b/Minecraft.World/Arrow.cpp @@ -338,7 +338,7 @@ void Arrow::tick() if (owner != nullptr && res->entity != owner && owner->GetType() == eTYPE_SERVERPLAYER) { - dynamic_pointer_cast(owner)->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::SUCCESSFUL_BOW_HIT, 0)) ); + dynamic_pointer_cast(owner)->connection->send(std::make_shared(GameEventPacket::SUCCESSFUL_BOW_HIT, 0)); } } @@ -499,7 +499,7 @@ void Arrow::playerTouch(shared_ptr player) if (pickup == PICKUP_ALLOWED) { - if (!player->inventory->add( shared_ptr( new ItemInstance(Item::arrow, 1) ) )) + if (!player->inventory->add(std::make_shared(Item::arrow, 1))) { bRemove = false; } diff --git a/Minecraft.World/AwardStatPacket.h b/Minecraft.World/AwardStatPacket.h index 6b79c0234..01cad26d9 100644 --- a/Minecraft.World/AwardStatPacket.h +++ b/Minecraft.World/AwardStatPacket.h @@ -24,7 +24,7 @@ public: virtual int getEstimatedSize(); virtual bool isAync(); - static shared_ptr create() { return shared_ptr(new AwardStatPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 200; } public: diff --git a/Minecraft.World/BeaconTile.cpp b/Minecraft.World/BeaconTile.cpp index 998f15e85..04b17d112 100644 --- a/Minecraft.World/BeaconTile.cpp +++ b/Minecraft.World/BeaconTile.cpp @@ -11,7 +11,7 @@ BeaconTile::BeaconTile(int id) : BaseEntityTile(id, Material::glass, isSolidRend shared_ptr BeaconTile::newTileEntity(Level *level) { - return shared_ptr( new BeaconTileEntity() ); + return std::make_shared(); } bool BeaconTile::use(Level *level, int x, int y, int z, shared_ptr player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly) diff --git a/Minecraft.World/BeaconTileEntity.cpp b/Minecraft.World/BeaconTileEntity.cpp index 10e74eee1..633930f4f 100644 --- a/Minecraft.World/BeaconTileEntity.cpp +++ b/Minecraft.World/BeaconTileEntity.cpp @@ -10,7 +10,7 @@ shared_ptr BeaconTileEntity::clone() { - shared_ptr result = shared_ptr( new BeaconTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->primaryPower = primaryPower; @@ -252,7 +252,7 @@ shared_ptr BeaconTileEntity::getUpdatePacket() { CompoundTag *tag = new CompoundTag(); save(tag); - return shared_ptr( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_BEACON, tag) ); + return std::make_shared(x, y, z, TileEntityDataPacket::TYPE_BEACON, tag); } double BeaconTileEntity::getViewDistance() @@ -306,7 +306,7 @@ shared_ptr BeaconTileEntity::removeItem(unsigned int slot, int cou else { paymentItem->count -= count; - return shared_ptr( new ItemInstance(paymentItem->id, count, paymentItem->getAuxValue()) ); + return std::make_shared(paymentItem->id, count, paymentItem->getAuxValue()); } } return nullptr; diff --git a/Minecraft.World/Blaze.cpp b/Minecraft.World/Blaze.cpp index de74fc758..ec72dfcb7 100644 --- a/Minecraft.World/Blaze.cpp +++ b/Minecraft.World/Blaze.cpp @@ -152,7 +152,7 @@ void Blaze::checkHurtTarget(shared_ptr target, float d) level->levelEvent(nullptr, LevelEvent::SOUND_BLAZE_FIREBALL, static_cast(x), static_cast(y), static_cast(z), 0); // level.playSound(this, "mob.ghast.fireball", getSoundVolume(), (random.nextFloat() - random.nextFloat()) * 0.2f + 1.0f); for (int i = 0; i < 1; i++) { - shared_ptr ie = shared_ptr( new SmallFireball(level, dynamic_pointer_cast( shared_from_this() ), xd + random->nextGaussian() * sqd, yd, zd + random->nextGaussian() * sqd) ); + shared_ptr ie = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), xd + random->nextGaussian() * sqd, yd, zd + random->nextGaussian() * sqd); // Vec3 v = getViewVector(1); // ie.x = x + v.x * 1.5; ie->y = y + bbHeight / 2 + 0.5f; diff --git a/Minecraft.World/BlockRegionUpdatePacket.h b/Minecraft.World/BlockRegionUpdatePacket.h index 54dfea4eb..d823acafb 100644 --- a/Minecraft.World/BlockRegionUpdatePacket.h +++ b/Minecraft.World/BlockRegionUpdatePacket.h @@ -28,6 +28,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new BlockRegionUpdatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 51; } }; diff --git a/Minecraft.World/BoatItem.cpp b/Minecraft.World/BoatItem.cpp index 379e5e448..5cf2cd380 100644 --- a/Minecraft.World/BoatItem.cpp +++ b/Minecraft.World/BoatItem.cpp @@ -107,7 +107,7 @@ shared_ptr BoatItem::use(shared_ptr itemInstance, Le if (level->getTile(xt, yt, zt) == Tile::topSnow_Id) yt--; if( level->countInstanceOf(eTYPE_BOAT, true) < Level::MAX_XBOX_BOATS ) // 4J - added limit { - shared_ptr boat = shared_ptr( new Boat(level, xt + 0.5f, yt + 1.0f, zt + 0.5f) ); + shared_ptr boat = std::make_shared(level, xt + 0.5f, yt + 1.0f, zt + 0.5f); boat->yRot = ((Mth::floor(player->yRot * 4.0F / 360.0F + 0.5) & 0x3) - 1) * 90; if (!level->getCubes(boat, boat->bb->grow(-.1, -.1, -.1))->empty()) { diff --git a/Minecraft.World/BottleItem.cpp b/Minecraft.World/BottleItem.cpp index 57fb95cdf..3e526b2a8 100644 --- a/Minecraft.World/BottleItem.cpp +++ b/Minecraft.World/BottleItem.cpp @@ -40,13 +40,13 @@ shared_ptr BottleItem::use(shared_ptr itemInstance, itemInstance->count--; if (itemInstance->count <= 0) { - return shared_ptr( new ItemInstance( static_cast(Item::potion)) ); + return std::make_shared(static_cast(Item::potion)); } else { - if (!player->inventory->add(shared_ptr( new ItemInstance( static_cast(Item::potion)) ))) + if (!player->inventory->add(std::make_shared(static_cast(Item::potion)))) { - player->drop( shared_ptr( new ItemInstance(Item::potion_Id, 1, 0) )); + player->drop(std::make_shared(Item::potion_Id, 1, 0)); } } } diff --git a/Minecraft.World/BowItem.cpp b/Minecraft.World/BowItem.cpp index b2ef08c9e..a2d34b89f 100644 --- a/Minecraft.World/BowItem.cpp +++ b/Minecraft.World/BowItem.cpp @@ -30,7 +30,7 @@ void BowItem::releaseUsing(shared_ptr itemInstance, Level *level, if (pow < 0.1) return; if (pow > 1) pow = 1; - shared_ptr arrow = shared_ptr( new Arrow(level, player, pow * 2.0f) ); + shared_ptr arrow = std::make_shared(level, player, pow * 2.0f); if (pow == 1) arrow->setCritArrow(true); int damageBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowBonus->id, itemInstance); if (damageBonus > 0) diff --git a/Minecraft.World/BowlFoodItem.cpp b/Minecraft.World/BowlFoodItem.cpp index f8ab06054..66e1dbb14 100644 --- a/Minecraft.World/BowlFoodItem.cpp +++ b/Minecraft.World/BowlFoodItem.cpp @@ -12,5 +12,5 @@ shared_ptr BowlFoodItem::useTimeDepleted(shared_ptr { FoodItem::useTimeDepleted(instance, level, player); - return shared_ptr(new ItemInstance(Item::bowl)); + return std::make_shared(Item::bowl); } \ No newline at end of file diff --git a/Minecraft.World/BreedGoal.cpp b/Minecraft.World/BreedGoal.cpp index 11840388c..10aa6844b 100644 --- a/Minecraft.World/BreedGoal.cpp +++ b/Minecraft.World/BreedGoal.cpp @@ -118,5 +118,5 @@ void BreedGoal::breed() * animal->bbWidth * 2 - animal->bbWidth, xa, ya, za); } // 4J-PB - Fix for 106869- Customer Encountered: TU12: Content: Gameplay: Breeding animals does not give any Experience Orbs. - level->addEntity( shared_ptr( new ExperienceOrb(level, animal->x, animal->y, animal->z, random->nextInt(7) + 1) ) ); + level->addEntity(std::make_shared(level, animal->x, animal->y, animal->z, random->nextInt(7) + 1)); } diff --git a/Minecraft.World/BrewingStandTile.cpp b/Minecraft.World/BrewingStandTile.cpp index afdf839aa..ec7242c82 100644 --- a/Minecraft.World/BrewingStandTile.cpp +++ b/Minecraft.World/BrewingStandTile.cpp @@ -30,7 +30,7 @@ int BrewingStandTile::getRenderShape() shared_ptr BrewingStandTile::newTileEntity(Level *level) { - return shared_ptr(new BrewingStandTileEntity()); + return std::make_shared(); } bool BrewingStandTile::isCubeShaped() @@ -104,7 +104,7 @@ void BrewingStandTile::onRemove(Level *level, int x, int y, int z, int id, int d if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue())))); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; diff --git a/Minecraft.World/BrewingStandTileEntity.cpp b/Minecraft.World/BrewingStandTileEntity.cpp index 825149816..3d081baec 100644 --- a/Minecraft.World/BrewingStandTileEntity.cpp +++ b/Minecraft.World/BrewingStandTileEntity.cpp @@ -254,14 +254,14 @@ void BrewingStandTileEntity::doBrew() } else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id) { - items[dest] = shared_ptr(new ItemInstance(Item::potion)); + items[dest] = std::make_shared(Item::potion); } } } if (Item::items[ingredient->id]->hasCraftingRemainingItem()) { - items[INGREDIENT_SLOT] = shared_ptr(new ItemInstance(Item::items[ingredient->id]->getCraftingRemainingItem())); + items[INGREDIENT_SLOT] = std::make_shared(Item::items[ingredient->id]->getCraftingRemainingItem()); } else { @@ -476,7 +476,7 @@ bool BrewingStandTileEntity::canTakeItemThroughFace(int slot, shared_ptr BrewingStandTileEntity::clone() { - shared_ptr result = shared_ptr( new BrewingStandTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->brewTime = brewTime; diff --git a/Minecraft.World/BucketItem.cpp b/Minecraft.World/BucketItem.cpp index b7553c26b..cb9d54b66 100644 --- a/Minecraft.World/BucketItem.cpp +++ b/Minecraft.World/BucketItem.cpp @@ -120,7 +120,7 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, if( servPlayer != nullptr ) { app.DebugPrintf("Sending ChatPacket::e_ChatCannotPlaceLava to player\n"); - servPlayer->connection->send( shared_ptr( new ChatPacket(L"", ChatPacket::e_ChatCannotPlaceLava ) ) ); + servPlayer->connection->send(std::make_shared(L"", ChatPacket::e_ChatCannotPlaceLava)); } delete hr; @@ -141,13 +141,13 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, if (--itemInstance->count <= 0) { - return shared_ptr( new ItemInstance(Item::bucket_water) ); + return std::make_shared(Item::bucket_water); } else { - if (!player->inventory->add(shared_ptr( new ItemInstance(Item::bucket_water)))) + if (!player->inventory->add(std::make_shared(Item::bucket_water))) { - player->drop(shared_ptr(new ItemInstance(Item::bucket_water_Id, 1, 0))); + player->drop(std::make_shared(Item::bucket_water_Id, 1, 0)); } return itemInstance; } @@ -168,13 +168,13 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, } if (--itemInstance->count <= 0) { - return shared_ptr( new ItemInstance(Item::bucket_lava) ); + return std::make_shared(Item::bucket_lava); } else { - if (!player->inventory->add(shared_ptr( new ItemInstance(Item::bucket_lava)))) + if (!player->inventory->add(std::make_shared(Item::bucket_lava))) { - player->drop(shared_ptr(new ItemInstance(Item::bucket_lava_Id, 1, 0))); + player->drop(std::make_shared(Item::bucket_lava_Id, 1, 0)); } return itemInstance; } @@ -183,7 +183,7 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, else if (content < 0) { delete hr; - return shared_ptr( new ItemInstance(Item::bucket_empty) ); + return std::make_shared(Item::bucket_empty); } else { @@ -199,7 +199,7 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, if (emptyBucket(level, xt, yt, zt) && !player->abilities.instabuild) { - return shared_ptr( new ItemInstance(Item::bucket_empty) ); + return std::make_shared(Item::bucket_empty); } } diff --git a/Minecraft.World/CarrotOnAStickItem.cpp b/Minecraft.World/CarrotOnAStickItem.cpp index 3701fce10..cc39196cf 100644 --- a/Minecraft.World/CarrotOnAStickItem.cpp +++ b/Minecraft.World/CarrotOnAStickItem.cpp @@ -35,7 +35,7 @@ shared_ptr CarrotOnAStickItem::use(shared_ptr itemIn if (itemInstance->count == 0) { - shared_ptr replacement = shared_ptr(new ItemInstance(Item::fishingRod)); + shared_ptr replacement = std::make_shared(Item::fishingRod); replacement->setTag(itemInstance->tag); return replacement; } diff --git a/Minecraft.World/CauldronTile.cpp b/Minecraft.World/CauldronTile.cpp index 599a9353e..c77ebd281 100644 --- a/Minecraft.World/CauldronTile.cpp +++ b/Minecraft.World/CauldronTile.cpp @@ -107,7 +107,7 @@ bool CauldronTile::use(Level *level, int x, int y, int z, shared_ptr pla { if (!player->abilities.instabuild) { - player->inventory->setItem(player->inventory->selected, shared_ptr(new ItemInstance(Item::bucket_empty))); + player->inventory->setItem(player->inventory->selected, std::make_shared(Item::bucket_empty)); } level->setData(x, y, z, 3, Tile::UPDATE_CLIENTS); @@ -119,10 +119,10 @@ bool CauldronTile::use(Level *level, int x, int y, int z, shared_ptr pla { if (fillLevel > 0) { - shared_ptr potion = shared_ptr(new ItemInstance(Item::potion, 1, 0)); + shared_ptr potion = std::make_shared(Item::potion, 1, 0); if (!player->inventory->add(potion)) { - level->addEntity(shared_ptr(new ItemEntity(level, x + 0.5, y + 1.5, z + 0.5, potion))); + level->addEntity(std::make_shared(level, x + 0.5, y + 1.5, z + 0.5, potion)); } // 4J Stu - Brought forward change to update inventory when filling bottles with water else if (player->instanceof(eTYPE_SERVERPLAYER)) diff --git a/Minecraft.World/ChatPacket.h b/Minecraft.World/ChatPacket.h index ca9e49557..ea9b38061 100644 --- a/Minecraft.World/ChatPacket.h +++ b/Minecraft.World/ChatPacket.h @@ -119,7 +119,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ChatPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 3; } }; diff --git a/Minecraft.World/ChestTile.cpp b/Minecraft.World/ChestTile.cpp index a81497215..ff3c0b406 100644 --- a/Minecraft.World/ChestTile.cpp +++ b/Minecraft.World/ChestTile.cpp @@ -231,9 +231,9 @@ void ChestTile::onRemove(Level *level, int x, int y, int z, int id, int data) if (count > item->count) count = item->count; item->count -= count; - shared_ptr newItem = shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()) ); + shared_ptr newItem = std::make_shared(item->id, count, item->getAuxValue()); newItem->set4JData( item->get4JData() ); - shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x + xo, y + yo, z + zo, newItem ) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, newItem); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; @@ -293,10 +293,10 @@ shared_ptr ChestTile::getContainer(Level *level, int x, int y, int z) if (level->getTile(x, y, z - 1) == id && (level->isSolidBlockingTile(x, y + 1, z - 1) || isCatSittingOnChest(level, x, y, z - 1))) return nullptr; if (level->getTile(x, y, z + 1) == id && (level->isSolidBlockingTile(x, y + 1, z + 1) || isCatSittingOnChest(level, x, y, z + 1))) return nullptr; - if (level->getTile(x - 1, y, z) == id) container = shared_ptr( new CompoundContainer(IDS_CHEST_LARGE, dynamic_pointer_cast( level->getTileEntity(x - 1, y, z) ), container) ); - if (level->getTile(x + 1, y, z) == id) container = shared_ptr( new CompoundContainer(IDS_CHEST_LARGE, container, dynamic_pointer_cast( level->getTileEntity(x + 1, y, z) )) ); - if (level->getTile(x, y, z - 1) == id) container = shared_ptr( new CompoundContainer(IDS_CHEST_LARGE, dynamic_pointer_cast( level->getTileEntity(x, y, z - 1) ), container) ); - if (level->getTile(x, y, z + 1) == id) container = shared_ptr( new CompoundContainer(IDS_CHEST_LARGE, container, dynamic_pointer_cast( level->getTileEntity(x, y, z + 1) )) ); + if (level->getTile(x - 1, y, z) == id) container = std::make_shared(IDS_CHEST_LARGE, dynamic_pointer_cast(level->getTileEntity(x - 1, y, z)), container); + if (level->getTile(x + 1, y, z) == id) container = std::make_shared(IDS_CHEST_LARGE, container, dynamic_pointer_cast(level->getTileEntity(x + 1, y, z))); + if (level->getTile(x, y, z - 1) == id) container = std::make_shared(IDS_CHEST_LARGE, dynamic_pointer_cast(level->getTileEntity(x, y, z - 1)), container); + if (level->getTile(x, y, z + 1) == id) container = std::make_shared(IDS_CHEST_LARGE, container, dynamic_pointer_cast(level->getTileEntity(x, y, z + 1))); return container; } @@ -304,7 +304,7 @@ shared_ptr ChestTile::getContainer(Level *level, int x, int y, int z) shared_ptr ChestTile::newTileEntity(Level *level) { MemSect(50); - shared_ptr retval = shared_ptr( new ChestTileEntity() ); + shared_ptr retval = std::make_shared(); MemSect(0); return retval; } diff --git a/Minecraft.World/ChestTileEntity.cpp b/Minecraft.World/ChestTileEntity.cpp index 966eb5bb5..ba277e243 100644 --- a/Minecraft.World/ChestTileEntity.cpp +++ b/Minecraft.World/ChestTileEntity.cpp @@ -405,7 +405,7 @@ int ChestTileEntity::getType() // 4J Added shared_ptr ChestTileEntity::clone() { - shared_ptr result = shared_ptr( new ChestTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); for (unsigned int i = 0; i < items->length; i++) diff --git a/Minecraft.World/Chicken.cpp b/Minecraft.World/Chicken.cpp index 5f4cf2a73..355d8a256 100644 --- a/Minecraft.World/Chicken.cpp +++ b/Minecraft.World/Chicken.cpp @@ -143,7 +143,7 @@ shared_ptr Chicken::getBreedOffspring(shared_ptr target) // 4J - added limit to chickens that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - return shared_ptr(new Chicken(level)); + return std::make_shared(level); } else { diff --git a/Minecraft.World/ChunkTilesUpdatePacket.h b/Minecraft.World/ChunkTilesUpdatePacket.h index a97f49a39..7cbc3c651 100644 --- a/Minecraft.World/ChunkTilesUpdatePacket.h +++ b/Minecraft.World/ChunkTilesUpdatePacket.h @@ -25,7 +25,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ChunkTilesUpdatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 52; } }; diff --git a/Minecraft.World/ChunkVisibilityAreaPacket.h b/Minecraft.World/ChunkVisibilityAreaPacket.h index 330874970..9442b6f76 100644 --- a/Minecraft.World/ChunkVisibilityAreaPacket.h +++ b/Minecraft.World/ChunkVisibilityAreaPacket.h @@ -25,6 +25,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ChunkVisibilityAreaPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 155; } }; diff --git a/Minecraft.World/ChunkVisibilityPacket.h b/Minecraft.World/ChunkVisibilityPacket.h index 8c5856c74..74af7f4d2 100644 --- a/Minecraft.World/ChunkVisibilityPacket.h +++ b/Minecraft.World/ChunkVisibilityPacket.h @@ -22,7 +22,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ChunkVisibilityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 50; } }; diff --git a/Minecraft.World/ClientCommandPacket.h b/Minecraft.World/ClientCommandPacket.h index 2f614ddf1..b3578a105 100644 --- a/Minecraft.World/ClientCommandPacket.h +++ b/Minecraft.World/ClientCommandPacket.h @@ -19,6 +19,6 @@ public: int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ClientCommandPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 205; } }; \ No newline at end of file diff --git a/Minecraft.World/CocoaTile.cpp b/Minecraft.World/CocoaTile.cpp index 095f9b527..3df58eb84 100644 --- a/Minecraft.World/CocoaTile.cpp +++ b/Minecraft.World/CocoaTile.cpp @@ -151,7 +151,7 @@ void CocoaTile::spawnResources(Level *level, int x, int y, int z, int data, floa } for (int i = 0; i < count; i++) { - popResource(level, x, y, z, shared_ptr( new ItemInstance(Item::dye_powder, 1, DyePowderItem::BROWN) )); + popResource(level, x, y, z, std::make_shared(Item::dye_powder, 1, DyePowderItem::BROWN)); } } diff --git a/Minecraft.World/CombatTracker.cpp b/Minecraft.World/CombatTracker.cpp index 7fe8316fb..7e1aa80c4 100644 --- a/Minecraft.World/CombatTracker.cpp +++ b/Minecraft.World/CombatTracker.cpp @@ -58,7 +58,7 @@ void CombatTracker::recordDamage(DamageSource *source, float health, float damag shared_ptr CombatTracker::getDeathMessagePacket() { - if (entries.size() == 0) return shared_ptr(new ChatPacket(mob->getNetworkName())); + if (entries.size() == 0) return std::make_shared(mob->getNetworkName()); CombatEntry *knockOffEntry = getMostSignificantFall(); CombatEntry *killingBlow = entries[entries.size() - 1]; @@ -91,7 +91,7 @@ shared_ptr CombatTracker::getDeathMessagePacket() break; } - result = shared_ptr(new ChatPacket(mob->getNetworkName(), message)); + result = std::make_shared(mob->getNetworkName(), message); } else if (attackerEntity != nullptr && (killingEntity == nullptr || attackerEntity != killingEntity)) { @@ -99,11 +99,11 @@ shared_ptr CombatTracker::getDeathMessagePacket() if (attackerItem != nullptr && attackerItem->hasCustomHoverName()) { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssistItem, attackerEntity->GetType(), attackerEntity->getNetworkName(), attackerItem->getHoverName())); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssistItem, attackerEntity->GetType(), attackerEntity->getNetworkName(), attackerItem->getHoverName()); } else { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssist, attackerEntity->GetType(), attackerEntity->getNetworkName())); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssist, attackerEntity->GetType(), attackerEntity->getNetworkName()); } } else if (killingEntity != nullptr) @@ -111,16 +111,16 @@ shared_ptr CombatTracker::getDeathMessagePacket() shared_ptr killerItem = killingEntity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast(killingEntity)->getCarriedItem() : nullptr; if (killerItem != nullptr && killerItem->hasCustomHoverName()) { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinishItem, killingEntity->GetType(), killingEntity->getNetworkName(), killerItem->getHoverName())); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinishItem, killingEntity->GetType(), killingEntity->getNetworkName(), killerItem->getHoverName()); } else { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinish, killingEntity->GetType(), killingEntity->getNetworkName())); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinish, killingEntity->GetType(), killingEntity->getNetworkName()); } } else { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellKiller)); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellKiller); } } else diff --git a/Minecraft.World/CommandBlock.cpp b/Minecraft.World/CommandBlock.cpp index 1810ef132..c151172e0 100644 --- a/Minecraft.World/CommandBlock.cpp +++ b/Minecraft.World/CommandBlock.cpp @@ -10,7 +10,7 @@ CommandBlock::CommandBlock(int id) : BaseEntityTile(id, Material::metal, isSolid shared_ptr CommandBlock::newTileEntity(Level *level) { - return shared_ptr( new CommandBlockEntity() ); + return std::make_shared(); } void CommandBlock::neighborChanged(Level *level, int x, int y, int z, int type) diff --git a/Minecraft.World/CommandBlockEntity.cpp b/Minecraft.World/CommandBlockEntity.cpp index b81f8e46b..00870ee48 100644 --- a/Minecraft.World/CommandBlockEntity.cpp +++ b/Minecraft.World/CommandBlockEntity.cpp @@ -94,7 +94,7 @@ shared_ptr CommandBlockEntity::getUpdatePacket() { CompoundTag *tag = new CompoundTag(); save(tag); - return shared_ptr( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_ADV_COMMAND, tag) ); + return std::make_shared(x, y, z, TileEntityDataPacket::TYPE_ADV_COMMAND, tag); } int CommandBlockEntity::getSuccessCount() @@ -110,7 +110,7 @@ void CommandBlockEntity::setSuccessCount(int successCount) // 4J Added shared_ptr CommandBlockEntity::clone() { - shared_ptr result = shared_ptr( new CommandBlockEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->successCount = successCount; diff --git a/Minecraft.World/ComparatorTile.cpp b/Minecraft.World/ComparatorTile.cpp index 197a936cc..e7d8f1787 100644 --- a/Minecraft.World/ComparatorTile.cpp +++ b/Minecraft.World/ComparatorTile.cpp @@ -244,7 +244,7 @@ bool ComparatorTile::triggerEvent(Level *level, int x, int y, int z, int b0, int shared_ptr ComparatorTile::newTileEntity(Level *level) { - return shared_ptr( new ComparatorTileEntity() ); + return std::make_shared(); } bool ComparatorTile::TestUse() diff --git a/Minecraft.World/ComparatorTileEntity.cpp b/Minecraft.World/ComparatorTileEntity.cpp index 9a58d23c1..7cd1f064e 100644 --- a/Minecraft.World/ComparatorTileEntity.cpp +++ b/Minecraft.World/ComparatorTileEntity.cpp @@ -27,7 +27,7 @@ void ComparatorTileEntity::setOutputSignal(int value) // 4J Added shared_ptr ComparatorTileEntity::clone() { - shared_ptr result = shared_ptr( new ComparatorTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->output = output; diff --git a/Minecraft.World/ComplexItemDataPacket.h b/Minecraft.World/ComplexItemDataPacket.h index 52de8f49d..1e41c3e94 100644 --- a/Minecraft.World/ComplexItemDataPacket.h +++ b/Minecraft.World/ComplexItemDataPacket.h @@ -20,7 +20,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ComplexItemDataPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 131; } }; diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp index 962624b87..c1d3f9c5b 100644 --- a/Minecraft.World/Connection.cpp +++ b/Minecraft.World/Connection.cpp @@ -473,7 +473,7 @@ void Connection::tick() tickCount++; if (tickCount % 20 == 0) { - send( shared_ptr( new KeepAlivePacket() ) ); + send(std::make_shared()); } // 4J Stu - 1.8.2 changed from 100 to 1000 diff --git a/Minecraft.World/ContainerAckPacket.h b/Minecraft.World/ContainerAckPacket.h index 00f3592e6..be0287745 100644 --- a/Minecraft.World/ContainerAckPacket.h +++ b/Minecraft.World/ContainerAckPacket.h @@ -23,7 +23,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerAckPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 106; } }; diff --git a/Minecraft.World/ContainerButtonClickPacket.h b/Minecraft.World/ContainerButtonClickPacket.h index 522c5f868..01e8deb88 100644 --- a/Minecraft.World/ContainerButtonClickPacket.h +++ b/Minecraft.World/ContainerButtonClickPacket.h @@ -17,6 +17,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerButtonClickPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 108; } }; \ No newline at end of file diff --git a/Minecraft.World/ContainerClickPacket.h b/Minecraft.World/ContainerClickPacket.h index 516861661..dee255b44 100644 --- a/Minecraft.World/ContainerClickPacket.h +++ b/Minecraft.World/ContainerClickPacket.h @@ -23,7 +23,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerClickPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 102; } }; diff --git a/Minecraft.World/ContainerClosePacket.h b/Minecraft.World/ContainerClosePacket.h index bf032a972..c4b78570b 100644 --- a/Minecraft.World/ContainerClosePacket.h +++ b/Minecraft.World/ContainerClosePacket.h @@ -17,7 +17,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerClosePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 101; } }; diff --git a/Minecraft.World/ContainerOpenPacket.h b/Minecraft.World/ContainerOpenPacket.h index 896b7dd9a..fac0e981f 100644 --- a/Minecraft.World/ContainerOpenPacket.h +++ b/Minecraft.World/ContainerOpenPacket.h @@ -46,7 +46,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerOpenPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 100; } }; diff --git a/Minecraft.World/ContainerSetContentPacket.h b/Minecraft.World/ContainerSetContentPacket.h index 10315f58d..3159085b1 100644 --- a/Minecraft.World/ContainerSetContentPacket.h +++ b/Minecraft.World/ContainerSetContentPacket.h @@ -19,7 +19,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerSetContentPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 104; } }; diff --git a/Minecraft.World/ContainerSetDataPacket.h b/Minecraft.World/ContainerSetDataPacket.h index ce075e00e..c5d52a976 100644 --- a/Minecraft.World/ContainerSetDataPacket.h +++ b/Minecraft.World/ContainerSetDataPacket.h @@ -19,6 +19,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerSetDataPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 105; } }; \ No newline at end of file diff --git a/Minecraft.World/ContainerSetSlotPacket.h b/Minecraft.World/ContainerSetSlotPacket.h index 61269df02..86bca334b 100644 --- a/Minecraft.World/ContainerSetSlotPacket.h +++ b/Minecraft.World/ContainerSetSlotPacket.h @@ -23,7 +23,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerSetSlotPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 103; } }; diff --git a/Minecraft.World/ControlledByPlayerGoal.cpp b/Minecraft.World/ControlledByPlayerGoal.cpp index 3069293d6..c5203e6ea 100644 --- a/Minecraft.World/ControlledByPlayerGoal.cpp +++ b/Minecraft.World/ControlledByPlayerGoal.cpp @@ -123,7 +123,7 @@ void ControlledByPlayerGoal::tick() if (carriedItem->count == 0) { - shared_ptr replacement = shared_ptr(new ItemInstance(Item::fishingRod)); + shared_ptr replacement = std::make_shared(Item::fishingRod); replacement->setTag(carriedItem->tag); player->inventory->items[player->inventory->selected] = replacement; } diff --git a/Minecraft.World/Cow.cpp b/Minecraft.World/Cow.cpp index d80c16a2e..69628d64f 100644 --- a/Minecraft.World/Cow.cpp +++ b/Minecraft.World/Cow.cpp @@ -112,11 +112,11 @@ bool Cow::mobInteract(shared_ptr player) if (item->count-- == 0) { - player->inventory->setItem(player->inventory->selected, shared_ptr( new ItemInstance(Item::bucket_milk) ) ); + player->inventory->setItem(player->inventory->selected, std::make_shared(Item::bucket_milk)); } - else if (!player->inventory->add(shared_ptr( new ItemInstance(Item::bucket_milk) ))) + else if (!player->inventory->add(std::make_shared(Item::bucket_milk))) { - player->drop(shared_ptr( new ItemInstance(Item::bucket_milk) )); + player->drop(std::make_shared(Item::bucket_milk)); } return true; @@ -129,7 +129,7 @@ shared_ptr Cow::getBreedOffspring(shared_ptr target) // 4J - added limit to number of animals that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - return shared_ptr( new Cow(level) ); + return std::make_shared(level); } else { diff --git a/Minecraft.World/CraftItemPacket.h b/Minecraft.World/CraftItemPacket.h index 9793d593a..f6cbdd3d8 100644 --- a/Minecraft.World/CraftItemPacket.h +++ b/Minecraft.World/CraftItemPacket.h @@ -22,6 +22,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new CraftItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 150; } }; \ No newline at end of file diff --git a/Minecraft.World/CraftingMenu.cpp b/Minecraft.World/CraftingMenu.cpp index a510e8691..6f24d3108 100644 --- a/Minecraft.World/CraftingMenu.cpp +++ b/Minecraft.World/CraftingMenu.cpp @@ -19,8 +19,8 @@ const int CraftingMenu::USE_ROW_SLOT_END = CraftingMenu::USE_ROW_SLOT_START + 9; CraftingMenu::CraftingMenu(shared_ptr inventory, Level *level, int xt, int yt, int zt) : AbstractContainerMenu() { - craftSlots = shared_ptr( new CraftingContainer(this, 3, 3) ); - resultSlots = shared_ptr( new ResultContainer() ); + craftSlots = std::make_shared(this, 3, 3); + resultSlots = std::make_shared(); this->level = level; x = xt; diff --git a/Minecraft.World/CropTile.cpp b/Minecraft.World/CropTile.cpp index 39753caea..1a1611996 100644 --- a/Minecraft.World/CropTile.cpp +++ b/Minecraft.World/CropTile.cpp @@ -136,7 +136,7 @@ void CropTile::spawnResources(Level *level, int x, int y, int z, int data, float for (int i = 0; i < count; i++) { if (level->random->nextInt(5 * 3) > data) continue; - popResource(level, x, y, z, shared_ptr(new ItemInstance(getBaseSeedId(), 1, 0))); + popResource(level, x, y, z, std::make_shared(getBaseSeedId(), 1, 0)); } } } diff --git a/Minecraft.World/CustomPayloadPacket.h b/Minecraft.World/CustomPayloadPacket.h index 95c5e708d..82a3f6e26 100644 --- a/Minecraft.World/CustomPayloadPacket.h +++ b/Minecraft.World/CustomPayloadPacket.h @@ -30,6 +30,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new CustomPayloadPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 250; } }; \ No newline at end of file diff --git a/Minecraft.World/DamageSource.cpp b/Minecraft.World/DamageSource.cpp index 43e236bf4..bc3adc804 100644 --- a/Minecraft.World/DamageSource.cpp +++ b/Minecraft.World/DamageSource.cpp @@ -193,11 +193,11 @@ shared_ptr DamageSource::getDeathMessagePacket(shared_ptr source = player->getKillCredit(); if(source != nullptr) { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId != ChatPacket::e_ChatCustom ? m_msgWithItemId : m_msgId, source->GetType(), source->getNetworkName() ) ); + return std::make_shared(player->getNetworkName(), m_msgWithItemId != ChatPacket::e_ChatCustom ? m_msgWithItemId : m_msgId, source->GetType(), source->getNetworkName()); } else { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgId ) ); + return std::make_shared(player->getNetworkName(), m_msgId); } } diff --git a/Minecraft.World/DaylightDetectorTile.cpp b/Minecraft.World/DaylightDetectorTile.cpp index 396daec6d..0bfc949ba 100644 --- a/Minecraft.World/DaylightDetectorTile.cpp +++ b/Minecraft.World/DaylightDetectorTile.cpp @@ -95,7 +95,7 @@ bool DaylightDetectorTile::isSignalSource() shared_ptr DaylightDetectorTile::newTileEntity(Level *level) { - return shared_ptr( new DaylightDetectorTileEntity() ); + return std::make_shared(); } Icon *DaylightDetectorTile::getTexture(int face, int data) diff --git a/Minecraft.World/DaylightDetectorTileEntity.cpp b/Minecraft.World/DaylightDetectorTileEntity.cpp index 2b72f3c9e..0cf1cec34 100644 --- a/Minecraft.World/DaylightDetectorTileEntity.cpp +++ b/Minecraft.World/DaylightDetectorTileEntity.cpp @@ -22,7 +22,7 @@ void DaylightDetectorTileEntity::tick() // 4J Added shared_ptr DaylightDetectorTileEntity::clone() { - shared_ptr result = shared_ptr( new DaylightDetectorTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); return result; diff --git a/Minecraft.World/DeadBushTile.cpp b/Minecraft.World/DeadBushTile.cpp index 06bd41ee0..7f22f747f 100644 --- a/Minecraft.World/DeadBushTile.cpp +++ b/Minecraft.World/DeadBushTile.cpp @@ -37,7 +37,7 @@ void DeadBushTile::playerDestroy(Level *level, shared_ptr player, int x, ); // drop leaf block instead of sapling - popResource(level, x, y, z, shared_ptr(new ItemInstance(Tile::deadBush, 1, data))); + popResource(level, x, y, z, std::make_shared(Tile::deadBush, 1, data)); } else { diff --git a/Minecraft.World/DebugOptionsPacket.h b/Minecraft.World/DebugOptionsPacket.h index 9ac5ef2f8..09167f8c1 100644 --- a/Minecraft.World/DebugOptionsPacket.h +++ b/Minecraft.World/DebugOptionsPacket.h @@ -21,6 +21,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new DebugOptionsPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 152; } }; diff --git a/Minecraft.World/DefaultDispenseItemBehavior.cpp b/Minecraft.World/DefaultDispenseItemBehavior.cpp index 8fd13282d..8563ef56e 100644 --- a/Minecraft.World/DefaultDispenseItemBehavior.cpp +++ b/Minecraft.World/DefaultDispenseItemBehavior.cpp @@ -38,7 +38,7 @@ void DefaultDispenseItemBehavior::spawnItem(Level *world, shared_ptrgetY(); double spawnZ = position->getZ(); - shared_ptr itemEntity = shared_ptr(new ItemEntity(world, spawnX, spawnY - 0.3, spawnZ, item)); + shared_ptr itemEntity = std::make_shared(world, spawnX, spawnY - 0.3, spawnZ, item); double pow = world->random->nextDouble() * 0.1 + 0.2; itemEntity->xd = facing->getStepX() * pow; diff --git a/Minecraft.World/DirectoryLevelStorageSource.cpp b/Minecraft.World/DirectoryLevelStorageSource.cpp index 232d4d443..9176b0d59 100644 --- a/Minecraft.World/DirectoryLevelStorageSource.cpp +++ b/Minecraft.World/DirectoryLevelStorageSource.cpp @@ -121,7 +121,7 @@ void DirectoryLevelStorageSource::deleteRecursive(vector *files) shared_ptr DirectoryLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir) { - return shared_ptr (new DirectoryLevelStorage(saveFile, baseDir, levelId, createPlayerDir)); + return std::make_shared(saveFile, baseDir, levelId, createPlayerDir); } bool DirectoryLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId) diff --git a/Minecraft.World/DisconnectPacket.h b/Minecraft.World/DisconnectPacket.h index 349837549..3c96a429b 100644 --- a/Minecraft.World/DisconnectPacket.h +++ b/Minecraft.World/DisconnectPacket.h @@ -66,7 +66,7 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new DisconnectPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 255; } }; diff --git a/Minecraft.World/DispenserTile.cpp b/Minecraft.World/DispenserTile.cpp index abbb67d41..5098fe308 100644 --- a/Minecraft.World/DispenserTile.cpp +++ b/Minecraft.World/DispenserTile.cpp @@ -168,7 +168,7 @@ void DispenserTile::tick(Level *level, int x, int y, int z, Random *random) shared_ptr DispenserTile::newTileEntity(Level *level) { - return shared_ptr( new DispenserTileEntity() ); + return std::make_shared(); } void DispenserTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr by, shared_ptr itemInstance) @@ -203,9 +203,9 @@ void DispenserTile::onRemove(Level *level, int x, int y, int z, int id, int data if (count > item->count) count = item->count; item->count -= count; - shared_ptr newItem = shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()) ); + shared_ptr newItem = std::make_shared(item->id, count, item->getAuxValue()); newItem->set4JData( item->get4JData() ); - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, newItem ) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, newItem); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; diff --git a/Minecraft.World/DispenserTileEntity.cpp b/Minecraft.World/DispenserTileEntity.cpp index 9129ea5cd..b1d8ecdeb 100644 --- a/Minecraft.World/DispenserTileEntity.cpp +++ b/Minecraft.World/DispenserTileEntity.cpp @@ -231,7 +231,7 @@ bool DispenserTileEntity::canPlaceItem(int slot, shared_ptr item) // 4J Added shared_ptr DispenserTileEntity::clone() { - shared_ptr result = shared_ptr( new DispenserTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); for (unsigned int i = 0; i < items.length; i++) diff --git a/Minecraft.World/DropperTile.cpp b/Minecraft.World/DropperTile.cpp index 098b6338a..180aec2ac 100644 --- a/Minecraft.World/DropperTile.cpp +++ b/Minecraft.World/DropperTile.cpp @@ -27,7 +27,7 @@ DispenseItemBehavior *DropperTile::getDispenseMethod(shared_ptr it shared_ptr DropperTile::newTileEntity(Level *level) { - return shared_ptr( new DropperTileEntity() ); + return std::make_shared(); } void DropperTile::dispenseFrom(Level *level, int x, int y, int z) diff --git a/Minecraft.World/DropperTileEntity.cpp b/Minecraft.World/DropperTileEntity.cpp index 51bf6abf7..ad2a0e83f 100644 --- a/Minecraft.World/DropperTileEntity.cpp +++ b/Minecraft.World/DropperTileEntity.cpp @@ -10,7 +10,7 @@ wstring DropperTileEntity::getName() // 4J Added shared_ptr DropperTileEntity::clone() { - shared_ptr result = shared_ptr( new DropperTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->name = name; diff --git a/Minecraft.World/EggItem.cpp b/Minecraft.World/EggItem.cpp index 0655a2fa3..3f3d123ea 100644 --- a/Minecraft.World/EggItem.cpp +++ b/Minecraft.World/EggItem.cpp @@ -26,6 +26,6 @@ shared_ptr EggItem::use(shared_ptr instance, Level * instance->count--; } level->playEntitySound( player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); - if (!level->isClientSide) level->addEntity( shared_ptr(new ThrownEgg(level, player)) ); + if (!level->isClientSide) level->addEntity(std::make_shared(level, player)); return instance; } diff --git a/Minecraft.World/EggTile.cpp b/Minecraft.World/EggTile.cpp index 3a11c0d1e..7052fac9b 100644 --- a/Minecraft.World/EggTile.cpp +++ b/Minecraft.World/EggTile.cpp @@ -40,7 +40,7 @@ void EggTile::checkSlide(Level *level, int x, int y, int z) } else { - shared_ptr e = shared_ptr(new FallingTile(level, x + 0.5f, y + 0.5f, z + 0.5f, id)); + shared_ptr e = std::make_shared(level, x + 0.5f, y + 0.5f, z + 0.5f, id); level->addEntity(e); } } diff --git a/Minecraft.World/EmptyMapItem.cpp b/Minecraft.World/EmptyMapItem.cpp index 42adc3048..9c46938a3 100644 --- a/Minecraft.World/EmptyMapItem.cpp +++ b/Minecraft.World/EmptyMapItem.cpp @@ -23,7 +23,7 @@ shared_ptr EmptyMapItem::use(shared_ptr itemInstance //data.setDirty(); - shared_ptr map = shared_ptr( new ItemInstance(Item::map, 1, -1) ); + shared_ptr map = std::make_shared(Item::map, 1, -1); Item::map->onCraftedBy(map, level, player); itemInstance->count--; diff --git a/Minecraft.World/EnchantItemCommand.cpp b/Minecraft.World/EnchantItemCommand.cpp index dec0bf8e4..c84117094 100644 --- a/Minecraft.World/EnchantItemCommand.cpp +++ b/Minecraft.World/EnchantItemCommand.cpp @@ -81,5 +81,5 @@ shared_ptr EnchantItemCommand::preparePacket(shared_ptr( new GameCommandPacket(eGameCommand_EnchantItem, baos.toByteArray() )); + return std::make_shared(eGameCommand_EnchantItem, baos.toByteArray()); } \ No newline at end of file diff --git a/Minecraft.World/EnchantedBookItem.cpp b/Minecraft.World/EnchantedBookItem.cpp index 65153c00b..70b15be46 100644 --- a/Minecraft.World/EnchantedBookItem.cpp +++ b/Minecraft.World/EnchantedBookItem.cpp @@ -102,7 +102,7 @@ void EnchantedBookItem::addEnchantment(shared_ptr item, Enchantmen shared_ptr EnchantedBookItem::createForEnchantment(EnchantmentInstance *enchant) { - shared_ptr item = shared_ptr(new ItemInstance(this)); + shared_ptr item = std::make_shared(this); addEnchantment(item, enchant); return item; } @@ -118,7 +118,7 @@ void EnchantedBookItem::createForEnchantment(Enchantment *enchant, vector EnchantedBookItem::createForRandomLoot(Random *random) { Enchantment *enchantment = Enchantment::validEnchantments[random->nextInt(Enchantment::validEnchantments.size())]; - shared_ptr book = shared_ptr(new ItemInstance(id, 1, 0)); + shared_ptr book = std::make_shared(id, 1, 0); int level = Mth::nextInt(random, enchantment->getMinLevel(), enchantment->getMaxLevel()); addEnchantment(book, new EnchantmentInstance(enchantment, level)); @@ -134,7 +134,7 @@ WeighedTreasure *EnchantedBookItem::createForRandomTreasure(Random *random) WeighedTreasure *EnchantedBookItem::createForRandomTreasure(Random *random, int minCount, int maxCount, int weight) { Enchantment *enchantment = Enchantment::validEnchantments[random->nextInt(Enchantment::validEnchantments.size())]; - shared_ptr book = shared_ptr(new ItemInstance(id, 1, 0)); + shared_ptr book = std::make_shared(id, 1, 0); int level = Mth::nextInt(random, enchantment->getMinLevel(), enchantment->getMaxLevel()); addEnchantment(book, new EnchantmentInstance(enchantment, level)); diff --git a/Minecraft.World/EnchantmentMenu.cpp b/Minecraft.World/EnchantmentMenu.cpp index 08c51c3d0..86c88e88a 100644 --- a/Minecraft.World/EnchantmentMenu.cpp +++ b/Minecraft.World/EnchantmentMenu.cpp @@ -9,7 +9,7 @@ EnchantmentMenu::EnchantmentMenu(shared_ptr inventory, Level *level, int xt, int yt, int zt) { - enchantSlots = shared_ptr( new EnchantmentContainer(this) ); + enchantSlots = std::make_shared(this); for(int i = 0; i < 3; ++i) { diff --git a/Minecraft.World/EnchantmentTableEntity.cpp b/Minecraft.World/EnchantmentTableEntity.cpp index 3e5924d22..dd9b6ad2a 100644 --- a/Minecraft.World/EnchantmentTableEntity.cpp +++ b/Minecraft.World/EnchantmentTableEntity.cpp @@ -124,7 +124,7 @@ void EnchantmentTableEntity::setCustomName(const wstring &name) shared_ptr EnchantmentTableEntity::clone() { - shared_ptr result = shared_ptr( new EnchantmentTableEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->time = time; diff --git a/Minecraft.World/EnchantmentTableTile.cpp b/Minecraft.World/EnchantmentTableTile.cpp index 8e777ea11..a5c518496 100644 --- a/Minecraft.World/EnchantmentTableTile.cpp +++ b/Minecraft.World/EnchantmentTableTile.cpp @@ -69,7 +69,7 @@ Icon *EnchantmentTableTile::getTexture(int face, int data) shared_ptr EnchantmentTableTile::newTileEntity(Level *level) { - return shared_ptr(new EnchantmentTableEntity()); + return std::make_shared(); } bool EnchantmentTableTile::use(Level *level, int x, int y, int z, shared_ptr player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param diff --git a/Minecraft.World/EnderChestTile.cpp b/Minecraft.World/EnderChestTile.cpp index 464c04823..f1b4738fb 100644 --- a/Minecraft.World/EnderChestTile.cpp +++ b/Minecraft.World/EnderChestTile.cpp @@ -82,7 +82,7 @@ bool EnderChestTile::use(Level *level, int x, int y, int z, shared_ptr p shared_ptr EnderChestTile::newTileEntity(Level *level) { - return shared_ptr(new EnderChestTileEntity()); + return std::make_shared(); } void EnderChestTile::animateTick(Level *level, int xt, int yt, int zt, Random *random) diff --git a/Minecraft.World/EnderChestTileEntity.cpp b/Minecraft.World/EnderChestTileEntity.cpp index 8169c0292..1ad682ae9 100644 --- a/Minecraft.World/EnderChestTileEntity.cpp +++ b/Minecraft.World/EnderChestTileEntity.cpp @@ -94,7 +94,7 @@ bool EnderChestTileEntity::stillValid(shared_ptr player) // 4J Added shared_ptr EnderChestTileEntity::clone() { - shared_ptr result = shared_ptr( new EnderChestTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); return result; diff --git a/Minecraft.World/EnderDragon.cpp b/Minecraft.World/EnderDragon.cpp index 9a97b765a..f8e4871f5 100644 --- a/Minecraft.World/EnderDragon.cpp +++ b/Minecraft.World/EnderDragon.cpp @@ -100,14 +100,14 @@ EnderDragon::EnderDragon(Level *level) : Mob(level) // 4J - split off from ctor so we can use shared_from_this() void EnderDragon::AddParts() { - head = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"head", 6, 6) ); - neck = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"neck", 6, 6) ); // 4J Added - body = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"body", 8, 8) ); - tail1 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4) ); - tail2 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4) ); - tail3 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4) ); - wing1 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"wing", 4, 4) ); - wing2 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"wing", 4, 4) ); + head = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"head", 6, 6); + neck = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"neck", 6, 6); // 4J Added + body = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"body", 8, 8); + tail1 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4); + tail2 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4); + tail3 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4); + wing1 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"wing", 4, 4); + wing2 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"wing", 4, 4); subEntities.push_back(head); subEntities.push_back(neck); // 4J Added @@ -739,7 +739,7 @@ void EnderDragon::aiStep() double zdd = attackTarget->z - startingZ; level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, static_cast(x), static_cast(y), static_cast(z), 0); - shared_ptr ie = shared_ptr( new DragonFireball(level, dynamic_pointer_cast( shared_from_this() ), xdd, ydd, zdd) ); + shared_ptr ie = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), xdd, ydd, zdd); ie->x = startingX; ie->y = startingY; ie->z = startingZ; @@ -1214,7 +1214,7 @@ void EnderDragon::tickDeath() { int newCount = ExperienceOrb::getExperienceValue(xpCount); xpCount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x, y, z, newCount) )); + level->addEntity(std::make_shared(level, x, y, z, newCount)); } } if (dragonDeathTime == 1) @@ -1234,7 +1234,7 @@ void EnderDragon::tickDeath() { int newCount = ExperienceOrb::getExperienceValue(xpCount); xpCount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x, y, z, newCount))); + level->addEntity(std::make_shared(level, x, y, z, newCount)); } int xo = 5 + random->nextInt(2) * 2 - 1; int zo = 5 + random->nextInt(2) * 2 - 1; diff --git a/Minecraft.World/EnderEyeItem.cpp b/Minecraft.World/EnderEyeItem.cpp index 80e5fe984..25b16d05d 100644 --- a/Minecraft.World/EnderEyeItem.cpp +++ b/Minecraft.World/EnderEyeItem.cpp @@ -207,7 +207,7 @@ shared_ptr EnderEyeItem::use(shared_ptr instance, Le { if((level->dimension->id==LevelData::DIMENSION_OVERWORLD) && level->getLevelData()->getHasStronghold()) { - shared_ptr eyeOfEnderSignal = shared_ptr( new EyeOfEnderSignal(level, player->x, player->y + 1.62 - player->heightOffset, player->z) ); + shared_ptr eyeOfEnderSignal = std::make_shared(level, player->x, player->y + 1.62 - player->heightOffset, player->z); eyeOfEnderSignal->signalTo(level->getLevelData()->getXStronghold()<<4, player->y + 1.62 - player->heightOffset, level->getLevelData()->getZStronghold()<<4); level->addEntity(eyeOfEnderSignal); diff --git a/Minecraft.World/EnderpearlItem.cpp b/Minecraft.World/EnderpearlItem.cpp index 4bf641f71..c024190b2 100644 --- a/Minecraft.World/EnderpearlItem.cpp +++ b/Minecraft.World/EnderpearlItem.cpp @@ -28,7 +28,7 @@ shared_ptr EnderpearlItem::use(shared_ptr instance, level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); if (!level->isClientSide) { - level->addEntity( shared_ptr( new ThrownEnderpearl(level, player) ) ); + level->addEntity(std::make_shared(level, player)); } return instance; } \ No newline at end of file diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index acb439b20..d754330b5 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -312,7 +312,7 @@ void Entity::_init(bool useSmallId, Level *level) // values that need to be sent to clients in SMP if( useSmallId ) { - entityData = shared_ptr(new SynchedEntityData()); + entityData = std::make_shared(); } else { @@ -1511,7 +1511,7 @@ shared_ptr Entity::spawnAtLocation(int resource, int count) shared_ptr Entity::spawnAtLocation(int resource, int count, float yOffs) { - return spawnAtLocation(shared_ptr( new ItemInstance(resource, count, 0) ), yOffs); + return spawnAtLocation(std::make_shared(resource, count, 0), yOffs); } shared_ptr Entity::spawnAtLocation(shared_ptr itemInstance, float yOffs) @@ -1520,7 +1520,7 @@ shared_ptr Entity::spawnAtLocation(shared_ptr itemInst { return nullptr; } - shared_ptr ie = shared_ptr( new ItemEntity(level, x, y + yOffs, z, itemInstance) ); + shared_ptr ie = std::make_shared(level, x, y + yOffs, z, itemInstance); ie->throwTime = 10; level->addEntity(ie); return ie; diff --git a/Minecraft.World/EntityActionAtPositionPacket.h b/Minecraft.World/EntityActionAtPositionPacket.h index 352020178..788c764b1 100644 --- a/Minecraft.World/EntityActionAtPositionPacket.h +++ b/Minecraft.World/EntityActionAtPositionPacket.h @@ -18,6 +18,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new EntityActionAtPositionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 17; } }; \ No newline at end of file diff --git a/Minecraft.World/EntityDamageSource.cpp b/Minecraft.World/EntityDamageSource.cpp index 8ff9e328a..8639156d9 100644 --- a/Minecraft.World/EntityDamageSource.cpp +++ b/Minecraft.World/EntityDamageSource.cpp @@ -41,11 +41,11 @@ shared_ptr EntityDamageSource::getDeathMessagePacket(shared_ptrhasCustomHoverName()) { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId, entity->GetType(), additional, held->getHoverName() ) ); + return std::make_shared(player->getNetworkName(), m_msgWithItemId, entity->GetType(), additional, held->getHoverName()); } else { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgId, entity->GetType(), additional ) ); + return std::make_shared(player->getNetworkName(), m_msgId, entity->GetType(), additional); } } diff --git a/Minecraft.World/EntityEventPacket.h b/Minecraft.World/EntityEventPacket.h index a151dbdb4..2b32dc29a 100644 --- a/Minecraft.World/EntityEventPacket.h +++ b/Minecraft.World/EntityEventPacket.h @@ -18,7 +18,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new EntityEventPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 38; } }; diff --git a/Minecraft.World/EntityHorse.cpp b/Minecraft.World/EntityHorse.cpp index 03a70f92b..32c9eb2de 100644 --- a/Minecraft.World/EntityHorse.cpp +++ b/Minecraft.World/EntityHorse.cpp @@ -456,7 +456,7 @@ int EntityHorse::getInventorySize() void EntityHorse::createInventory() { shared_ptr old = inventory; - inventory = shared_ptr( new AnimalChest(L"HorseChest", getInventorySize()) ); + inventory = std::make_shared(L"HorseChest", getInventorySize()); inventory->setCustomName(getAName()); if (old != nullptr) { @@ -1539,7 +1539,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag *tag) } else if (tag->getBoolean(L"Saddle")) { - inventory->setItem(INV_SLOT_SADDLE, shared_ptr( new ItemInstance(Item::saddle))); + inventory->setItem(INV_SLOT_SADDLE, std::make_shared(Item::saddle)); } updateEquipment(); } @@ -1566,7 +1566,7 @@ bool EntityHorse::canMate(shared_ptr partner) shared_ptr EntityHorse::getBreedOffspring(shared_ptr partner) { shared_ptr horsePartner = dynamic_pointer_cast(partner); - shared_ptr baby = shared_ptr( new EntityHorse(level) ); + shared_ptr baby = std::make_shared(level); int type = getType(); int partnerType = horsePartner->getType(); diff --git a/Minecraft.World/ExperienceItem.cpp b/Minecraft.World/ExperienceItem.cpp index 433c12070..a28a5859e 100644 --- a/Minecraft.World/ExperienceItem.cpp +++ b/Minecraft.World/ExperienceItem.cpp @@ -27,6 +27,6 @@ shared_ptr ExperienceItem::use(shared_ptr itemInstan itemInstance->count--; } level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); - if (!level->isClientSide) level->addEntity( shared_ptr( new ThrownExpBottle(level, player) )); + if (!level->isClientSide) level->addEntity(std::make_shared(level, player)); return itemInstance; } \ No newline at end of file diff --git a/Minecraft.World/ExplodePacket.h b/Minecraft.World/ExplodePacket.h index d4d8b3f91..caf77c77a 100644 --- a/Minecraft.World/ExplodePacket.h +++ b/Minecraft.World/ExplodePacket.h @@ -32,6 +32,6 @@ public: float getKnockbackZ(); public: - static shared_ptr create() { return shared_ptr(new ExplodePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 60; } }; \ No newline at end of file diff --git a/Minecraft.World/EyeOfEnderSignal.cpp b/Minecraft.World/EyeOfEnderSignal.cpp index ad2d48fc8..ca76b272d 100644 --- a/Minecraft.World/EyeOfEnderSignal.cpp +++ b/Minecraft.World/EyeOfEnderSignal.cpp @@ -163,7 +163,7 @@ void EyeOfEnderSignal::tick() remove(); if (surviveAfterDeath) { - level->addEntity(shared_ptr( new ItemEntity(level, x, y, z, shared_ptr(new ItemInstance(Item::eyeOfEnder))))); + level->addEntity(std::make_shared(level, x, y, z, shared_ptr(new ItemInstance(Item::eyeOfEnder)))); } else { diff --git a/Minecraft.World/FallingTile.cpp b/Minecraft.World/FallingTile.cpp index cd951681d..0ff776fde 100644 --- a/Minecraft.World/FallingTile.cpp +++ b/Minecraft.World/FallingTile.cpp @@ -161,13 +161,13 @@ void FallingTile::tick() } else { - if(dropItem && !cancelDrop) spawnAtLocation( shared_ptr(new ItemInstance(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data))), 0); + if(dropItem && !cancelDrop) spawnAtLocation(std::make_shared(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data)), 0); } } } else if ( (time > 20 * 5 && !level->isClientSide && (yt < 1 || yt > Level::maxBuildHeight)) || (time > 20 * 30)) { - if(dropItem) spawnAtLocation( shared_ptr( new ItemInstance(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data) )), 0); + if(dropItem) spawnAtLocation(std::make_shared(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data)), 0); remove(); } } diff --git a/Minecraft.World/FireworksItem.cpp b/Minecraft.World/FireworksItem.cpp index c872bc407..155a49617 100644 --- a/Minecraft.World/FireworksItem.cpp +++ b/Minecraft.World/FireworksItem.cpp @@ -26,7 +26,7 @@ bool FireworksItem::useOn(shared_ptr instance, shared_ptr if (!level->isClientSide) { - shared_ptr f = shared_ptr( new FireworksRocketEntity(level, x + clickX, y + clickY, z + clickZ, instance) ); + shared_ptr f(new FireworksRocketEntity(level, x + clickX, y + clickY, z + clickZ, instance)); level->addEntity(f); if (!player->abilities.instabuild) diff --git a/Minecraft.World/FireworksMenu.cpp b/Minecraft.World/FireworksMenu.cpp index 92474e2de..cd9196aff 100644 --- a/Minecraft.World/FireworksMenu.cpp +++ b/Minecraft.World/FireworksMenu.cpp @@ -15,8 +15,8 @@ FireworksMenu::FireworksMenu(shared_ptr inventory, Level *level, int m_canMakeCharge = false; m_canMakeFade = false; - craftSlots = shared_ptr( new CraftingContainer(this, 3, 3) ); - resultSlots = shared_ptr( new ResultContainer() ); + craftSlots = std::make_shared(this, 3, 3); + resultSlots = std::make_shared(); this->level = level; x = xt; diff --git a/Minecraft.World/FireworksRecipe.cpp b/Minecraft.World/FireworksRecipe.cpp index 6c6d3d259..feb1cf573 100644 --- a/Minecraft.World/FireworksRecipe.cpp +++ b/Minecraft.World/FireworksRecipe.cpp @@ -124,7 +124,7 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l // create fireworks if (sulphurCount >= 1 && paperCount == 1 && chargeComponents == 0) { - resultItem = shared_ptr( new ItemInstance(Item::fireworks) ); + resultItem = std::make_shared(Item::fireworks); if (chargeCount > 0) { CompoundTag *itemTag = new CompoundTag(); @@ -155,7 +155,7 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l if (sulphurCount == 1 && paperCount == 0 && chargeCount == 0 && colorCount > 0 && typeComponents <= 1) { - resultItem = shared_ptr( new ItemInstance(Item::fireworksCharge) ); + resultItem = std::make_shared(Item::fireworksCharge); CompoundTag *itemTag = new CompoundTag(); CompoundTag *expTag = new CompoundTag(FireworksItem::TAG_EXPLOSION); diff --git a/Minecraft.World/FishingHook.cpp b/Minecraft.World/FishingHook.cpp index e567e87b9..ba0876d92 100644 --- a/Minecraft.World/FishingHook.cpp +++ b/Minecraft.World/FishingHook.cpp @@ -420,7 +420,7 @@ int FishingHook::retrieve() } else if (nibble > 0) { - shared_ptr ie = shared_ptr( new ItemEntity(this->Entity::level, x, y, z, shared_ptr( new ItemInstance(Item::fish_raw) ) ) ); + shared_ptr ie = std::make_shared(this->Entity::level, x, y, z, shared_ptr(new ItemInstance(Item::fish_raw))); double xa = owner->x - x; double ya = owner->y - y; double za = owner->z - z; @@ -431,7 +431,7 @@ int FishingHook::retrieve() ie->Entity::yd = ya * speed + sqrt(dist) * 0.08; ie->Entity::zd = za * speed; level->addEntity(ie); - owner->level->addEntity( shared_ptr( new ExperienceOrb(owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f, random->nextInt(6) + 1) ) ); // 4J Stu brought forward from 1.4 + owner->level->addEntity(std::make_shared(owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f, random->nextInt(6) + 1)); // 4J Stu brought forward from 1.4 dmg = 1; } if (inGround) dmg = 2; diff --git a/Minecraft.World/FishingRodItem.cpp b/Minecraft.World/FishingRodItem.cpp index 70becf39e..b9eafd184 100644 --- a/Minecraft.World/FishingRodItem.cpp +++ b/Minecraft.World/FishingRodItem.cpp @@ -44,7 +44,7 @@ shared_ptr FishingRodItem::use(shared_ptr instance, if (!level->isClientSide) { // 4J Stu - Move the player->fishing out of the ctor as we cannot reference 'this' - shared_ptr hook = shared_ptr( new FishingHook(level, player) ); + shared_ptr hook = std::make_shared(level, player); player->fishing = hook; level->addEntity( shared_ptr( hook ) ); } diff --git a/Minecraft.World/FlowerPotTile.cpp b/Minecraft.World/FlowerPotTile.cpp index 57aa8b6d3..80fdf2e45 100644 --- a/Minecraft.World/FlowerPotTile.cpp +++ b/Minecraft.World/FlowerPotTile.cpp @@ -127,27 +127,27 @@ shared_ptr FlowerPotTile::getItemFromType(int type) switch (type) { case TYPE_FLOWER_RED: - return shared_ptr( new ItemInstance(Tile::rose) ); + return std::make_shared(Tile::rose); case TYPE_FLOWER_YELLOW: - return shared_ptr( new ItemInstance(Tile::flower) ); + return std::make_shared(Tile::flower); case TYPE_CACTUS: - return shared_ptr( new ItemInstance(Tile::cactus) ); + return std::make_shared(Tile::cactus); case TYPE_MUSHROOM_BROWN: - return shared_ptr( new ItemInstance(Tile::mushroom_brown) ); + return std::make_shared(Tile::mushroom_brown); case TYPE_MUSHROOM_RED: - return shared_ptr( new ItemInstance(Tile::mushroom_red) ); + return std::make_shared(Tile::mushroom_red); case TYPE_DEAD_BUSH: - return shared_ptr( new ItemInstance(Tile::deadBush) ); + return std::make_shared(Tile::deadBush); case TYPE_SAPLING_DEFAULT: - return shared_ptr( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_DEFAULT) ); + return std::make_shared(Tile::sapling, 1, Sapling::TYPE_DEFAULT); case TYPE_SAPLING_BIRCH: - return shared_ptr( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_BIRCH) ); + return std::make_shared(Tile::sapling, 1, Sapling::TYPE_BIRCH); case TYPE_SAPLING_EVERGREEN: - return shared_ptr( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_EVERGREEN) ); + return std::make_shared(Tile::sapling, 1, Sapling::TYPE_EVERGREEN); case TYPE_SAPLING_JUNGLE: - return shared_ptr( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_JUNGLE) ); + return std::make_shared(Tile::sapling, 1, Sapling::TYPE_JUNGLE); case TYPE_FERN: - return shared_ptr( new ItemInstance(Tile::tallgrass, 1, TallGrass::FERN) ); + return std::make_shared(Tile::tallgrass, 1, TallGrass::FERN); } return nullptr; diff --git a/Minecraft.World/FurnaceResultSlot.cpp b/Minecraft.World/FurnaceResultSlot.cpp index 8ea4b19f7..48f2f8fbf 100644 --- a/Minecraft.World/FurnaceResultSlot.cpp +++ b/Minecraft.World/FurnaceResultSlot.cpp @@ -73,7 +73,7 @@ void FurnaceResultSlot::checkTakeAchievements(shared_ptr carried) { int newCount = ExperienceOrb::getExperienceValue(amount); amount -= newCount; - player->level->addEntity(shared_ptr( new ExperienceOrb(player->level, player->x, player->y + .5, player->z + .5, newCount) )); + player->level->addEntity(std::make_shared(player->level, player->x, player->y + .5, player->z + .5, newCount)); } } diff --git a/Minecraft.World/FurnaceTile.cpp b/Minecraft.World/FurnaceTile.cpp index 2d8fc9914..d8856f4e3 100644 --- a/Minecraft.World/FurnaceTile.cpp +++ b/Minecraft.World/FurnaceTile.cpp @@ -141,7 +141,7 @@ void FurnaceTile::setLit(bool lit, Level *level, int x, int y, int z) shared_ptr FurnaceTile::newTileEntity(Level *level) { - return shared_ptr( new FurnaceTileEntity() ); + return std::make_shared(); } void FurnaceTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr by, shared_ptr itemInstance) @@ -192,9 +192,9 @@ void FurnaceTile::onRemove(Level *level, int x, int y, int z, int id, int data) } #endif - shared_ptr newItem = shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()) ); + shared_ptr newItem = std::make_shared(item->id, count, item->getAuxValue()); newItem->set4JData( item->get4JData() ); - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, newItem) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, newItem); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; diff --git a/Minecraft.World/FurnaceTileEntity.cpp b/Minecraft.World/FurnaceTileEntity.cpp index 461670db2..901235c03 100644 --- a/Minecraft.World/FurnaceTileEntity.cpp +++ b/Minecraft.World/FurnaceTileEntity.cpp @@ -215,7 +215,7 @@ void FurnaceTileEntity::tick() if (items[SLOT_FUEL]->count == 0) { Item *remaining = items[SLOT_FUEL]->getItem()->getCraftingRemainingItem(); - items[SLOT_FUEL] = remaining != nullptr ? shared_ptr(new ItemInstance(remaining)) : nullptr; + items[SLOT_FUEL] = remaining != nullptr ? std::make_shared(remaining) : nullptr; } } } @@ -396,7 +396,7 @@ bool FurnaceTileEntity::canTakeItemThroughFace(int slot, shared_ptr FurnaceTileEntity::clone() { - shared_ptr result = shared_ptr( new FurnaceTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->litTime = litTime; diff --git a/Minecraft.World/FuzzyZoomLayer.cpp b/Minecraft.World/FuzzyZoomLayer.cpp index 65c6709e9..0da4a992f 100644 --- a/Minecraft.World/FuzzyZoomLayer.cpp +++ b/Minecraft.World/FuzzyZoomLayer.cpp @@ -66,7 +66,7 @@ shared_ptrFuzzyZoomLayer::zoom(__int64 seed, shared_ptrsup, int co shared_ptr result = sup; for (int i = 0; i < count; i++) { - result = shared_ptr(new FuzzyZoomLayer(seed + i, result)); + result = std::make_shared(seed + i, result); } return result; } \ No newline at end of file diff --git a/Minecraft.World/GameCommandPacket.h b/Minecraft.World/GameCommandPacket.h index 1f63e9503..d4827974c 100644 --- a/Minecraft.World/GameCommandPacket.h +++ b/Minecraft.World/GameCommandPacket.h @@ -21,6 +21,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new GameCommandPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 167; } }; \ No newline at end of file diff --git a/Minecraft.World/GameEventPacket.h b/Minecraft.World/GameEventPacket.h index 93ea911c0..c1134e7ff 100644 --- a/Minecraft.World/GameEventPacket.h +++ b/Minecraft.World/GameEventPacket.h @@ -40,6 +40,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new GameEventPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 70; } }; \ No newline at end of file diff --git a/Minecraft.World/GetInfoPacket.h b/Minecraft.World/GetInfoPacket.h index 90688f3e0..a7c758ba6 100644 --- a/Minecraft.World/GetInfoPacket.h +++ b/Minecraft.World/GetInfoPacket.h @@ -11,6 +11,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new GetInfoPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 254; } }; \ No newline at end of file diff --git a/Minecraft.World/Ghast.cpp b/Minecraft.World/Ghast.cpp index b016320f3..738a42da2 100644 --- a/Minecraft.World/Ghast.cpp +++ b/Minecraft.World/Ghast.cpp @@ -151,7 +151,7 @@ void Ghast::serverAiStep() { // 4J - change brought forward from 1.2.3 level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, static_cast(x), static_cast(y), static_cast(z), 0); - shared_ptr ie = shared_ptr( new LargeFireball(level, dynamic_pointer_cast( shared_from_this() ), xdd, ydd, zdd) ); + shared_ptr ie = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), xdd, ydd, zdd); ie->explosionPower = explosionPower; double d = 4; Vec3 *v = getViewVector(1); diff --git a/Minecraft.World/GiveItemCommand.cpp b/Minecraft.World/GiveItemCommand.cpp index e51332666..fa06d80d1 100644 --- a/Minecraft.World/GiveItemCommand.cpp +++ b/Minecraft.World/GiveItemCommand.cpp @@ -32,7 +32,7 @@ void GiveItemCommand::execute(shared_ptr source, byteArray comman shared_ptr player = getPlayer(uid); if(player != nullptr && item > 0 && Item::items[item] != nullptr) { - shared_ptr itemInstance = shared_ptr(new ItemInstance(item, amount, aux)); + shared_ptr itemInstance = std::make_shared(item, amount, aux); shared_ptr drop = player->drop(itemInstance); drop->throwTime = 0; //logAdminAction(source, L"commands.give.success", ChatPacket::e_ChatCustom, Item::items[item]->getName(itemInstance), item, amount, player->getAName()); @@ -53,5 +53,5 @@ shared_ptr GiveItemCommand::preparePacket(shared_ptr dos.writeInt(aux); dos.writeUTF(tag); - return shared_ptr( new GameCommandPacket(eGameCommand_Give, baos.toByteArray() )); + return std::make_shared(eGameCommand_Give, baos.toByteArray()); } \ No newline at end of file diff --git a/Minecraft.World/HangingEntityItem.cpp b/Minecraft.World/HangingEntityItem.cpp index 75e9dcff5..97ddb31d8 100644 --- a/Minecraft.World/HangingEntityItem.cpp +++ b/Minecraft.World/HangingEntityItem.cpp @@ -66,7 +66,7 @@ shared_ptr HangingEntityItem::createEntity(Level *level, int x, i { if (eType == eTYPE_PAINTING) { - shared_ptr painting = shared_ptr(new Painting(level, x, y, z, dir)); + shared_ptr painting = std::make_shared(level, x, y, z, dir); #ifndef _CONTENT_PACKAGE if (app.DebugArtToolsOn() && auxValue > 0) @@ -83,7 +83,7 @@ shared_ptr HangingEntityItem::createEntity(Level *level, int x, i } else if (eType == eTYPE_ITEM_FRAME) { - shared_ptr itemFrame = shared_ptr(new ItemFrame(level, x, y, z, dir)); + shared_ptr itemFrame = std::make_shared(level, x, y, z, dir); return dynamic_pointer_cast (itemFrame); } diff --git a/Minecraft.World/HeavyTile.cpp b/Minecraft.World/HeavyTile.cpp index 6c2b96e64..d4e657967 100644 --- a/Minecraft.World/HeavyTile.cpp +++ b/Minecraft.World/HeavyTile.cpp @@ -60,7 +60,7 @@ void HeavyTile::checkSlide(Level *level, int x, int y, int z) return; } - shared_ptr e = shared_ptr( new FallingTile(level, x + 0.5f, y + 0.5f, z + 0.5f, id, level->getData(x, y, z)) ); + shared_ptr e = std::make_shared(level, x + 0.5f, y + 0.5f, z + 0.5f, id, level->getData(x, y, z)); falling(e); level->addEntity(e); } diff --git a/Minecraft.World/HopperTile.cpp b/Minecraft.World/HopperTile.cpp index dadda9b0f..0371712a8 100644 --- a/Minecraft.World/HopperTile.cpp +++ b/Minecraft.World/HopperTile.cpp @@ -47,7 +47,7 @@ int HopperTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int shared_ptr HopperTile::newTileEntity(Level *level) { - return shared_ptr( new HopperTileEntity() ); + return std::make_shared(); } void HopperTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr by, shared_ptr itemInstance) @@ -116,7 +116,7 @@ void HopperTile::onRemove(Level *level, int x, int y, int z, int id, int data) if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue())))); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); if (item->hasTag()) { diff --git a/Minecraft.World/HopperTileEntity.cpp b/Minecraft.World/HopperTileEntity.cpp index 3e0cbe86d..e44232dcc 100644 --- a/Minecraft.World/HopperTileEntity.cpp +++ b/Minecraft.World/HopperTileEntity.cpp @@ -489,7 +489,7 @@ bool HopperTileEntity::isOnCooldown() // 4J Added shared_ptr HopperTileEntity::clone() { - shared_ptr result = shared_ptr( new HopperTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->name = name; diff --git a/Minecraft.World/HouseFeature.cpp b/Minecraft.World/HouseFeature.cpp index 40b4e770c..b6bba5a5e 100644 --- a/Minecraft.World/HouseFeature.cpp +++ b/Minecraft.World/HouseFeature.cpp @@ -185,7 +185,7 @@ bool HouseFeature::place(Level *level, Random *random, int x, int y, int z) } } - shared_ptr(pz) = shared_ptr(new PigZombie(level)); + shared_ptr(pz) = std::make_shared(level); pz->moveTo(x0 + w / 2.0 + 0.5, y0 + 0.5, z0 + d / 2.0 + 0.5, 0, 0); level->addEntity(pz); diff --git a/Minecraft.World/IndirectEntityDamageSource.cpp b/Minecraft.World/IndirectEntityDamageSource.cpp index 90c80f6bd..a24ad1a7f 100644 --- a/Minecraft.World/IndirectEntityDamageSource.cpp +++ b/Minecraft.World/IndirectEntityDamageSource.cpp @@ -47,11 +47,11 @@ shared_ptr IndirectEntityDamageSource::getDeathMessagePacket(shared_ } if(held != nullptr && held->hasCustomHoverName() ) { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId, type, additional, held->getHoverName() ) ); + return std::make_shared(player->getNetworkName(), m_msgWithItemId, type, additional, held->getHoverName()); } else { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgId, type, additional ) ); + return std::make_shared(player->getNetworkName(), m_msgId, type, additional); } } diff --git a/Minecraft.World/InteractPacket.h b/Minecraft.World/InteractPacket.h index 0141038d7..aae163916 100644 --- a/Minecraft.World/InteractPacket.h +++ b/Minecraft.World/InteractPacket.h @@ -20,6 +20,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new InteractPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 7; } }; \ No newline at end of file diff --git a/Minecraft.World/Inventory.cpp b/Minecraft.World/Inventory.cpp index d50ff614e..ad0fc3ec1 100644 --- a/Minecraft.World/Inventory.cpp +++ b/Minecraft.World/Inventory.cpp @@ -205,11 +205,11 @@ void Inventory::replaceSlot(Item *item, int data) { int oldSlotCount = items[oldSlot]->count; items[oldSlot] = items[selected]; - items[selected] = shared_ptr( new ItemInstance(Item::items[item->id], oldSlotCount, data) ); + items[selected] = std::make_shared(Item::items[item->id], oldSlotCount, data); } else { - items[selected] = shared_ptr(new ItemInstance(Item::items[item->id], 1, data)); + items[selected] = std::make_shared(Item::items[item->id], 1, data); } } } @@ -239,7 +239,7 @@ int Inventory::addResource(shared_ptr itemInstance) if (slot < 0) return count; if (items[slot] == nullptr) { - items[slot] = shared_ptr( new ItemInstance(type, 0, itemInstance->getAuxValue()) ); + items[slot] = std::make_shared(type, 0, itemInstance->getAuxValue()); // 4J Stu - Brought forward from 1.2 if (itemInstance->hasTag()) { @@ -708,7 +708,7 @@ bool Inventory::isSame(shared_ptr a, shared_ptr b) shared_ptr Inventory::copy() { - shared_ptr copy = shared_ptr( new Inventory(nullptr) ); + shared_ptr copy = std::make_shared(nullptr); for (unsigned int i = 0; i < items.length; i++) { copy->items[i] = items[i] != nullptr ? items[i]->copy() : nullptr; diff --git a/Minecraft.World/InventoryMenu.cpp b/Minecraft.World/InventoryMenu.cpp index 2b0e9e80f..9c6c661f0 100644 --- a/Minecraft.World/InventoryMenu.cpp +++ b/Minecraft.World/InventoryMenu.cpp @@ -28,8 +28,8 @@ InventoryMenu::InventoryMenu(shared_ptr inventory, bool active, Playe void InventoryMenu::_init(shared_ptr inventory, bool active) { - craftSlots = shared_ptr( new CraftingContainer(this, 2, 2) ); - resultSlots = shared_ptr( new ResultContainer() ); + craftSlots = std::make_shared(this, 2, 2); + resultSlots = std::make_shared(); this->active = active; addSlot(new ResultSlot( inventory->player, craftSlots, resultSlots, 0, 144, 36)); diff --git a/Minecraft.World/ItemDispenseBehaviors.cpp b/Minecraft.World/ItemDispenseBehaviors.cpp index 0c9563261..8758dcfbb 100644 --- a/Minecraft.World/ItemDispenseBehaviors.cpp +++ b/Minecraft.World/ItemDispenseBehaviors.cpp @@ -11,7 +11,7 @@ shared_ptr ArrowDispenseBehavior::getProjectile(Level *world, Position *position) { - shared_ptr arrow = shared_ptr(new Arrow(world, position->getX(), position->getY(), position->getZ())); + shared_ptr arrow = std::make_shared(world, position->getX(), position->getY(), position->getZ()); arrow->pickup = Arrow::PICKUP_ALLOWED; return arrow; @@ -21,7 +21,7 @@ shared_ptr ArrowDispenseBehavior::getProjectile(Level *world, Positi shared_ptr EggDispenseBehavior::getProjectile(Level *world, Position *position) { - return shared_ptr(new ThrownEgg(world, position->getX(), position->getY(), position->getZ())); + return std::make_shared(world, position->getX(), position->getY(), position->getZ()); } @@ -29,7 +29,7 @@ shared_ptr EggDispenseBehavior::getProjectile(Level *world, Position shared_ptr SnowballDispenseBehavior::getProjectile(Level *world, Position *position) { - return shared_ptr(new Snowball(world, position->getX(), position->getY(), position->getZ())); + return std::make_shared(world, position->getX(), position->getY(), position->getZ()); } @@ -37,7 +37,7 @@ shared_ptr SnowballDispenseBehavior::getProjectile(Level *world, Pos shared_ptr ExpBottleDispenseBehavior::getProjectile(Level *world, Position *position) { - return shared_ptr(new ThrownExpBottle(world, position->getX(), position->getY(), position->getZ())); + return std::make_shared(world, position->getX(), position->getY(), position->getZ()); } float ExpBottleDispenseBehavior::getUncertainty() @@ -60,7 +60,7 @@ ThrownPotionDispenseBehavior::ThrownPotionDispenseBehavior(int potionValue) shared_ptr ThrownPotionDispenseBehavior::getProjectile(Level *world, Position *position) { - return shared_ptr(new ThrownPotion(world, position->getX(), position->getY(), position->getZ(), m_potionValue)); + return std::make_shared(world, position->getX(), position->getY(), position->getZ(), m_potionValue); } float ThrownPotionDispenseBehavior::getUncertainty() @@ -139,7 +139,7 @@ shared_ptr FireworksDispenseBehavior::execute(BlockSource *source, double spawnY = source->getBlockY() + .2f; double spawnZ = source->getZ() + facing->getStepZ(); - shared_ptr firework = shared_ptr(new FireworksRocketEntity(world, spawnX, spawnY, spawnZ, dispensed)); + shared_ptr firework = std::make_shared(world, spawnX, spawnY, spawnZ, dispensed); source->getWorld()->addEntity(firework); outcome = ACTIVATED_ITEM; @@ -183,7 +183,7 @@ shared_ptr FireballDispenseBehavior::execute(BlockSource *source, double dirY = random->nextGaussian() * .05 + facing->getStepY(); double dirZ = random->nextGaussian() * .05 + facing->getStepZ(); - world->addEntity(shared_ptr(new SmallFireball(world, spawnX, spawnY, spawnZ, dirX, dirY, dirZ))); + world->addEntity(std::make_shared(world, spawnX, spawnY, spawnZ, dirX, dirY, dirZ)); outcome = ACTIVATED_ITEM; @@ -254,7 +254,7 @@ shared_ptr BoatDispenseBehavior::execute(BlockSource *source, shar outcome = ACTIVATED_ITEM; - shared_ptr boat = shared_ptr(new Boat(world, spawnX, spawnY + yOffset, spawnZ)); + shared_ptr boat = std::make_shared(world, spawnX, spawnY + yOffset, spawnZ); world->addEntity(boat); dispensed->remove(1); @@ -326,9 +326,9 @@ shared_ptr EmptyBucketDispenseBehavior::execute(BlockSource *sourc dispensed->id = targetType->id; dispensed->count = 1; } - else if (dynamic_pointer_cast(source->getEntity())->addItem(shared_ptr(new ItemInstance(targetType))) < 0) + else if (dynamic_pointer_cast(source->getEntity())->addItem(std::make_shared(targetType)) < 0) { - DefaultDispenseItemBehavior::dispense(source, shared_ptr(new ItemInstance(targetType))); + DefaultDispenseItemBehavior::dispense(source, std::make_shared(targetType)); } outcome = ACTIVATED_ITEM; @@ -442,7 +442,7 @@ shared_ptr TntDispenseBehavior::execute(BlockSource *source, share int targetY = source->getBlockY() + facing->getStepY(); int targetZ = source->getBlockZ() + facing->getStepZ(); - shared_ptr tnt = shared_ptr(new PrimedTnt(world, targetX + 0.5f, targetY + 0.5f, targetZ + 0.5f, nullptr)); + shared_ptr tnt(new PrimedTnt(world, targetX + 0.5, targetY + 0.5, targetZ + 0.5, nullptr)); world->addEntity(tnt); outcome = ACTIVATED_ITEM; diff --git a/Minecraft.World/ItemEntity.cpp b/Minecraft.World/ItemEntity.cpp index e1cc92755..5dc1db6ee 100644 --- a/Minecraft.World/ItemEntity.cpp +++ b/Minecraft.World/ItemEntity.cpp @@ -287,7 +287,7 @@ shared_ptr ItemEntity::getItem() app.DebugPrintf("Item entity %d has no item?!\n", entityId); //level.getLogger().severe("Item entity " + entityId + " has no item?!"); } - return shared_ptr(new ItemInstance(Tile::stone)); + return std::make_shared(Tile::stone); } return result; diff --git a/Minecraft.World/ItemFrame.cpp b/Minecraft.World/ItemFrame.cpp index 7f1e0dcbc..f5988b9fd 100644 --- a/Minecraft.World/ItemFrame.cpp +++ b/Minecraft.World/ItemFrame.cpp @@ -61,7 +61,7 @@ void ItemFrame::dropItem(shared_ptr causedBy) } } - spawnAtLocation( shared_ptr(new ItemInstance(Item::frame) ), 0); + spawnAtLocation(std::make_shared(Item::frame), 0); if ( (item != nullptr) && (random->nextFloat() < dropChance) ) { item = item->copy(); diff --git a/Minecraft.World/ItemInstance.cpp b/Minecraft.World/ItemInstance.cpp index 5452b72c5..4906c22e6 100644 --- a/Minecraft.World/ItemInstance.cpp +++ b/Minecraft.World/ItemInstance.cpp @@ -91,7 +91,7 @@ ItemInstance::~ItemInstance() shared_ptr ItemInstance::remove(int count) { - shared_ptr ii = shared_ptr( new ItemInstance(id, count, auxValue) ); + shared_ptr ii = std::make_shared(id, count, auxValue); if (tag != nullptr) ii->tag = static_cast(tag->copy()); this->count -= count; @@ -302,7 +302,7 @@ bool ItemInstance::interactEnemy(shared_ptr player, shared_ptr ItemInstance::copy() const { - shared_ptr copy = shared_ptr( new ItemInstance(id, count, auxValue) ); + shared_ptr copy = std::make_shared(id, count, auxValue); if (tag != nullptr) { copy->tag = static_cast(tag->copy()); diff --git a/Minecraft.World/JukeboxTile.cpp b/Minecraft.World/JukeboxTile.cpp index 387ad9f2e..74e79e9ed 100644 --- a/Minecraft.World/JukeboxTile.cpp +++ b/Minecraft.World/JukeboxTile.cpp @@ -23,7 +23,7 @@ void JukeboxTile::Entity::load(CompoundTag *tag) } else if (tag->getInt(L"Record") > 0) { - setRecord(shared_ptr( new ItemInstance(tag->getInt(L"Record"), 1, 0))); + setRecord(std::make_shared(tag->getInt(L"Record"), 1, 0)); } } @@ -42,7 +42,7 @@ void JukeboxTile::Entity::save(CompoundTag *tag) // 4J Added shared_ptr JukeboxTile::Entity::clone() { - shared_ptr result = shared_ptr( new JukeboxTile::Entity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->record = record; @@ -127,7 +127,7 @@ void JukeboxTile::dropRecording(Level *level, int x, int y, int z) shared_ptr itemInstance = oldRecord->copy(); - shared_ptr item = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) ); + shared_ptr item = std::make_shared(level, x + xo, y + yo, z + zo, itemInstance); item->throwTime = 10; level->addEntity(item); } @@ -146,7 +146,7 @@ void JukeboxTile::spawnResources(Level *level, int x, int y, int z, int data, fl shared_ptr JukeboxTile::newTileEntity(Level *level) { - return shared_ptr( new JukeboxTile::Entity() ); + return std::make_shared(); } void JukeboxTile::registerIcons(IconRegister *iconRegister) diff --git a/Minecraft.World/KeepAlivePacket.h b/Minecraft.World/KeepAlivePacket.h index a44d87456..bbf7b0ab3 100644 --- a/Minecraft.World/KeepAlivePacket.h +++ b/Minecraft.World/KeepAlivePacket.h @@ -20,6 +20,6 @@ public: virtual bool isAync(); public: - static shared_ptr create() { return shared_ptr(new KeepAlivePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 0; } }; \ No newline at end of file diff --git a/Minecraft.World/KickPlayerPacket.h b/Minecraft.World/KickPlayerPacket.h index b9a6ce3e0..67fc66fde 100644 --- a/Minecraft.World/KickPlayerPacket.h +++ b/Minecraft.World/KickPlayerPacket.h @@ -17,6 +17,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new KickPlayerPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 159; } }; \ No newline at end of file diff --git a/Minecraft.World/LavaSlime.cpp b/Minecraft.World/LavaSlime.cpp index 21982995d..f60baf097 100644 --- a/Minecraft.World/LavaSlime.cpp +++ b/Minecraft.World/LavaSlime.cpp @@ -55,7 +55,7 @@ ePARTICLE_TYPE LavaSlime::getParticleName() shared_ptr LavaSlime::createChild() { - return shared_ptr( new LavaSlime(level) ); + return std::make_shared(level); } int LavaSlime::getDeathLoot() diff --git a/Minecraft.World/Layer.cpp b/Minecraft.World/Layer.cpp index b604cabca..0f3b22f2a 100644 --- a/Minecraft.World/Layer.cpp +++ b/Minecraft.World/Layer.cpp @@ -21,16 +21,16 @@ LayerArray Layer::getDefaultLayers(__int64 seed, LevelType *levelType) // 4J - Some changes moved here from 1.2.3. Temperature & downfall layers are no longer created & returned, and a debug layer is isn't. // For reference with regard to future merging, things NOT brought forward from the 1.2.3 version are new layer types that we // don't have yet (shores, swamprivers, region hills etc.) - shared_ptrislandLayer = shared_ptr(new IslandLayer(1)); - islandLayer = shared_ptr(new FuzzyZoomLayer(2000, islandLayer)); - islandLayer = shared_ptr(new AddIslandLayer(1, islandLayer)); - islandLayer = shared_ptr(new ZoomLayer(2001, islandLayer)); - islandLayer = shared_ptr(new AddIslandLayer(2, islandLayer)); - islandLayer = shared_ptr(new AddSnowLayer(2, islandLayer)); - islandLayer = shared_ptr(new ZoomLayer(2002, islandLayer)); - islandLayer = shared_ptr(new AddIslandLayer(3, islandLayer)); - islandLayer = shared_ptr(new ZoomLayer(2003, islandLayer)); - islandLayer = shared_ptr(new AddIslandLayer(4, islandLayer)); + shared_ptrislandLayer = std::make_shared(1); + islandLayer = std::make_shared(2000, islandLayer); + islandLayer = std::make_shared(1, islandLayer); + islandLayer = std::make_shared(2001, islandLayer); + islandLayer = std::make_shared(2, islandLayer); + islandLayer = std::make_shared(2, islandLayer); + islandLayer = std::make_shared(2002, islandLayer); + islandLayer = std::make_shared(3, islandLayer); + islandLayer = std::make_shared(2003, islandLayer); + islandLayer = std::make_shared(4, islandLayer); // islandLayer = shared_ptr(new AddMushroomIslandLayer(5, islandLayer)); // 4J - old position of mushroom island layer int zoomLevel = 4; @@ -41,30 +41,30 @@ LayerArray Layer::getDefaultLayers(__int64 seed, LevelType *levelType) shared_ptr riverLayer = islandLayer; riverLayer = ZoomLayer::zoom(1000, riverLayer, 0); - riverLayer = shared_ptr(new RiverInitLayer(100, riverLayer)); + riverLayer = std::make_shared(100, riverLayer); riverLayer = ZoomLayer::zoom(1000, riverLayer, zoomLevel + 2); - riverLayer = shared_ptr(new RiverLayer(1, riverLayer)); - riverLayer = shared_ptr(new SmoothLayer(1000, riverLayer)); + riverLayer = std::make_shared(1, riverLayer); + riverLayer = std::make_shared(1000, riverLayer); shared_ptr biomeLayer = islandLayer; biomeLayer = ZoomLayer::zoom(1000, biomeLayer, 0); - biomeLayer = shared_ptr(new BiomeInitLayer(200, biomeLayer, levelType)); + biomeLayer = std::make_shared(200, biomeLayer, levelType); biomeLayer = ZoomLayer::zoom(1000, biomeLayer, 2); - biomeLayer = shared_ptr(new RegionHillsLayer(1000, biomeLayer)); + biomeLayer = std::make_shared(1000, biomeLayer); for (int i = 0; i < zoomLevel; i++) { - biomeLayer = shared_ptr(new ZoomLayer(1000 + i, biomeLayer)); + biomeLayer = std::make_shared(1000 + i, biomeLayer); - if (i == 0) biomeLayer = shared_ptr(new AddIslandLayer(3, biomeLayer)); + if (i == 0) biomeLayer = std::make_shared(3, biomeLayer); if (i == 0) { // 4J - moved mushroom islands to here. This skips 3 zooms that the old location of the add was, making them about 1/8 of the original size. Adding // them at this scale actually lets us place them near enough other land, if we add them at the same scale as java then they have to be too far out to see for // the scale of our maps - biomeLayer = shared_ptr(new AddMushroomIslandLayer(5, biomeLayer)); + biomeLayer = std::make_shared(5, biomeLayer); } if (i == 1 ) @@ -72,30 +72,30 @@ LayerArray Layer::getDefaultLayers(__int64 seed, LevelType *levelType) // 4J - now expand mushroom islands up again. This does a simple region grow to add a new mushroom island element when any of the neighbours are also mushroom islands. // This helps make the islands into nice compact shapes of the type that are actually likely to be able to make an island out of the sea in a small space. Also // helps the shore layer from doing too much damage in shrinking the islands we are making - biomeLayer = shared_ptr(new GrowMushroomIslandLayer(5, biomeLayer)); + biomeLayer = std::make_shared(5, biomeLayer); // Note - this reduces the size of mushroom islands by turning their edges into shores. We are doing this at i == 1 rather than i == 0 as the original does - biomeLayer = shared_ptr(new ShoreLayer(1000, biomeLayer)); + biomeLayer = std::make_shared(1000, biomeLayer); - biomeLayer = shared_ptr(new SwampRiversLayer(1000, biomeLayer)); + biomeLayer = std::make_shared(1000, biomeLayer); } } - biomeLayer = shared_ptr(new SmoothLayer(1000, biomeLayer)); + biomeLayer = std::make_shared(1000, biomeLayer); - biomeLayer = shared_ptr(new RiverMixerLayer(100, biomeLayer, riverLayer)); + biomeLayer = std::make_shared(100, biomeLayer, riverLayer); #ifndef _CONTENT_PACKAGE #ifdef _BIOME_OVERRIDE if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<(new BiomeOverrideLayer(1)); + biomeLayer = std::make_shared(1); } #endif #endif shared_ptr debugLayer = biomeLayer; - shared_ptrzoomedLayer = shared_ptr(new VoronoiZoom(10, biomeLayer)); + shared_ptrzoomedLayer = std::make_shared(10, biomeLayer); biomeLayer->init(seed); zoomedLayer->init(seed); diff --git a/Minecraft.World/LeafTile.cpp b/Minecraft.World/LeafTile.cpp index d66c9bda3..f8f5deae4 100644 --- a/Minecraft.World/LeafTile.cpp +++ b/Minecraft.World/LeafTile.cpp @@ -249,7 +249,7 @@ void LeafTile::spawnResources(Level *level, int x, int y, int z, int data, float if (level->random->nextInt(chance) == 0) { int type = getResource(data, level->random,playerBonusLevel); - popResource(level, x, y, z, shared_ptr( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data)))); + popResource(level, x, y, z, std::make_shared(type, 1, getSpawnResourcesAuxValue(data))); } chance = 200; @@ -263,7 +263,7 @@ void LeafTile::spawnResources(Level *level, int x, int y, int z, int data, float } if ((data & LEAF_TYPE_MASK) == NORMAL_LEAF && level->random->nextInt(chance) == 0) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(Item::apple_Id, 1, 0))); + popResource(level, x, y, z, std::make_shared(Item::apple_Id, 1, 0)); } } } @@ -278,7 +278,7 @@ void LeafTile::playerDestroy(Level *level, shared_ptr player, int x, int ); // drop leaf block instead of sapling - popResource(level, x, y, z, shared_ptr(new ItemInstance(Tile::leaves_Id, 1, data & LEAF_TYPE_MASK))); + popResource(level, x, y, z, std::make_shared(Tile::leaves_Id, 1, data & LEAF_TYPE_MASK)); } else { @@ -324,7 +324,7 @@ void LeafTile::setFancy(bool fancyGraphics) shared_ptr LeafTile::getSilkTouchItemInstance(int data) { - return shared_ptr( new ItemInstance(id, 1, data & LEAF_TYPE_MASK) ); + return std::make_shared(id, 1, data & LEAF_TYPE_MASK); } void LeafTile::stepOn(Level *level, int x, int y, int z, shared_ptr entity) diff --git a/Minecraft.World/LeashFenceKnotEntity.cpp b/Minecraft.World/LeashFenceKnotEntity.cpp index f952a5abb..f94bcba70 100644 --- a/Minecraft.World/LeashFenceKnotEntity.cpp +++ b/Minecraft.World/LeashFenceKnotEntity.cpp @@ -131,7 +131,7 @@ bool LeashFenceKnotEntity::survives() shared_ptr LeashFenceKnotEntity::createAndAddKnot(Level *level, int x, int y, int z) { - shared_ptr knot = shared_ptr( new LeashFenceKnotEntity(level, x, y, z) ); + shared_ptr knot = std::make_shared(level, x, y, z); knot->forcedLoading = true; level->addEntity(knot); return knot; diff --git a/Minecraft.World/Level.cpp b/Minecraft.World/Level.cpp index 54bc04353..3ad65d9eb 100644 --- a/Minecraft.World/Level.cpp +++ b/Minecraft.World/Level.cpp @@ -632,7 +632,7 @@ Level::Level(shared_ptr levelStorage, const wstring& name, Dimensi shared_ptr savedVillages = dynamic_pointer_cast(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID)); if (savedVillages == nullptr) { - villages = shared_ptr(new Villages(this)); + villages = std::make_shared(this); savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages); } else @@ -670,7 +670,7 @@ void Level::_init(shared_ptrlevelStorage, const wstring& levelName shared_ptr savedVillages = dynamic_pointer_cast(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID)); if (savedVillages == nullptr) { - villages = shared_ptr(new Villages(this)); + villages = std::make_shared(this); savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages); } else @@ -2810,7 +2810,7 @@ shared_ptr Level::explode(shared_ptr source, double x, double shared_ptr Level::explode(shared_ptr source, double x, double y, double z, float r, bool fire, bool destroyBlocks) { - shared_ptr explosion = shared_ptr( new Explosion(this, source, x, y, z, r) ); + shared_ptr explosion = std::make_shared(this, source, x, y, z, r); explosion->fire = fire; explosion->destroyBlocks = destroyBlocks; explosion->explode(); diff --git a/Minecraft.World/LevelEventPacket.h b/Minecraft.World/LevelEventPacket.h index 1d8c36e28..234f127dd 100644 --- a/Minecraft.World/LevelEventPacket.h +++ b/Minecraft.World/LevelEventPacket.h @@ -21,6 +21,6 @@ public: bool isGlobalEvent(); public: - static shared_ptr create() { return shared_ptr(new LevelEventPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 61; } }; \ No newline at end of file diff --git a/Minecraft.World/LevelParticlesPacket.h b/Minecraft.World/LevelParticlesPacket.h index 7676f771b..c7870a8e1 100644 --- a/Minecraft.World/LevelParticlesPacket.h +++ b/Minecraft.World/LevelParticlesPacket.h @@ -34,6 +34,6 @@ public: int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new LevelParticlesPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 63; } }; \ No newline at end of file diff --git a/Minecraft.World/LevelSoundPacket.h b/Minecraft.World/LevelSoundPacket.h index 403ac092b..e9ce356db 100644 --- a/Minecraft.World/LevelSoundPacket.h +++ b/Minecraft.World/LevelSoundPacket.h @@ -33,6 +33,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new LevelSoundPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 62; } }; diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp index 814a768c3..3ace88068 100644 --- a/Minecraft.World/LivingEntity.cpp +++ b/Minecraft.World/LivingEntity.cpp @@ -295,7 +295,7 @@ void LivingEntity::tickDeath() { int newCount = ExperienceOrb::getExperienceValue(xpCount); xpCount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x, y, z, newCount) ) ); + level->addEntity(std::make_shared(level, x, y, z, newCount)); } } } @@ -1174,7 +1174,7 @@ void LivingEntity::swing() if (dynamic_cast(level) != nullptr) { - static_cast(level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::SWING))); + static_cast(level)->getTracker()->broadcast(shared_from_this(), std::make_shared(shared_from_this(), AnimatePacket::SWING)); } } } @@ -1602,7 +1602,7 @@ void LivingEntity::tick() if (!ItemInstance::matches(current, previous)) { - static_cast(level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new SetEquippedItemPacket(entityId, i, current))); + static_cast(level)->getTracker()->broadcast(shared_from_this(), std::make_shared(entityId, i, current)); if (previous != nullptr) attributes->removeItemModifiers(previous); if (current != nullptr) attributes->addItemModifiers(current); lastEquipment[i] = current == nullptr ? nullptr : current->copy(); @@ -1860,15 +1860,15 @@ void LivingEntity::take(shared_ptr e, int orgCount) EntityTracker *entityTracker = static_cast(level)->getTracker(); if ( e->instanceof(eTYPE_ITEMENTITY) ) { - entityTracker->broadcast(e, shared_ptr( new TakeItemEntityPacket(e->entityId, entityId))); + entityTracker->broadcast(e, std::make_shared(e->entityId, entityId)); } else if ( e->instanceof(eTYPE_ARROW) ) { - entityTracker->broadcast(e, shared_ptr( new TakeItemEntityPacket(e->entityId, entityId))); + entityTracker->broadcast(e, std::make_shared(e->entityId, entityId)); } else if ( e->instanceof(eTYPE_EXPERIENCEORB) ) { - entityTracker->broadcast(e, shared_ptr( new TakeItemEntityPacket(e->entityId, entityId))); + entityTracker->broadcast(e, std::make_shared(e->entityId, entityId)); } } } diff --git a/Minecraft.World/LoginPacket.h b/Minecraft.World/LoginPacket.h index 090411358..906753e84 100644 --- a/Minecraft.World/LoginPacket.h +++ b/Minecraft.World/LoginPacket.h @@ -40,6 +40,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new LoginPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 1; } }; diff --git a/Minecraft.World/MapItem.cpp b/Minecraft.World/MapItem.cpp index af9792afb..61c203e3b 100644 --- a/Minecraft.World/MapItem.cpp +++ b/Minecraft.World/MapItem.cpp @@ -32,7 +32,7 @@ shared_ptr MapItem::getSavedData(short idNum, Level *level) int aux = idNum; id = wstring( L"map_" ) + std::to_wstring(aux); - mapItemSavedData = shared_ptr( new MapItemSavedData(id) ); + mapItemSavedData = std::make_shared(id); level->setSavedData(id, (shared_ptr ) mapItemSavedData); } @@ -55,7 +55,7 @@ shared_ptr MapItem::getSavedData(shared_ptr item //itemInstance->setAuxValue(level->getFreeAuxValueFor(L"map")); id = wstring( L"map_" ) + std::to_wstring(itemInstance->getAuxValue() ); - mapItemSavedData = shared_ptr( new MapItemSavedData(id) ); + mapItemSavedData = std::make_shared(id); newData = true; } @@ -297,7 +297,7 @@ shared_ptr MapItem::getUpdatePacket(shared_ptr itemInstanc if (data.data == nullptr || data.length == 0) return nullptr; - shared_ptr retval = shared_ptr(new ComplexItemDataPacket(static_cast(Item::map->id), static_cast(itemInstance->getAuxValue()), data)); + shared_ptr retval = std::make_shared(static_cast(Item::map->id), static_cast(itemInstance->getAuxValue()), data); delete data.data; return retval; } @@ -327,7 +327,7 @@ void MapItem::onCraftedBy(shared_ptr itemInstance, Level *level, s // when a new one is created if( data == nullptr ) { - data = shared_ptr( new MapItemSavedData(id) ); + data = std::make_shared(id); } level->setSavedData(id, (shared_ptr ) data); diff --git a/Minecraft.World/MapItemSavedData.cpp b/Minecraft.World/MapItemSavedData.cpp index 2495b4551..0a5eb7c40 100644 --- a/Minecraft.World/MapItemSavedData.cpp +++ b/Minecraft.World/MapItemSavedData.cpp @@ -236,7 +236,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr player, shared_ptr hp = shared_ptr( new HoldingPlayer(player, this ) ); + shared_ptr hp = std::make_shared(player, this); carriedByPlayers.insert( playerHoldingPlayerMapType::value_type(player, hp) ); carriedBy.push_back(hp); } @@ -545,7 +545,7 @@ shared_ptr MapItemSavedData::getHoldingPlayer(s if (it == carriedByPlayers.end()) { - hp = shared_ptr( new HoldingPlayer(player, this) ); + hp = std::make_shared(player, this); carriedByPlayers[player] = hp; carriedBy.push_back(hp); } diff --git a/Minecraft.World/McRegionLevelStorageSource.cpp b/Minecraft.World/McRegionLevelStorageSource.cpp index d36706ead..bf60ee0cf 100644 --- a/Minecraft.World/McRegionLevelStorageSource.cpp +++ b/Minecraft.World/McRegionLevelStorageSource.cpp @@ -76,7 +76,7 @@ void McRegionLevelStorageSource::clearAll() shared_ptr McRegionLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir) { // return new LevelStorageProfilerDecorator(new McRegionLevelStorage(baseDir, levelId, createPlayerDir)); - return shared_ptr(new McRegionLevelStorage(saveFile, baseDir, levelId, createPlayerDir)); + return std::make_shared(saveFile, baseDir, levelId, createPlayerDir); } bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId) diff --git a/Minecraft.World/MerchantMenu.cpp b/Minecraft.World/MerchantMenu.cpp index 2fe9cf6aa..f24d24c93 100644 --- a/Minecraft.World/MerchantMenu.cpp +++ b/Minecraft.World/MerchantMenu.cpp @@ -10,7 +10,7 @@ MerchantMenu::MerchantMenu(shared_ptr inventory, shared_ptr trader = merchant; this->level = level; - tradeContainer = shared_ptr( new MerchantContainer(dynamic_pointer_cast(inventory->player->shared_from_this()), merchant) ); + tradeContainer = std::make_shared(dynamic_pointer_cast(inventory->player->shared_from_this()), merchant); addSlot(new Slot(tradeContainer, PAYMENT1_SLOT, SELLSLOT1_X, ROW2_Y)); addSlot(new Slot(tradeContainer, PAYMENT2_SLOT, SELLSLOT2_X, ROW2_Y)); addSlot(new MerchantResultSlot(inventory->player, merchant, tradeContainer, RESULT_SLOT, BUYSLOT_X, ROW2_Y)); diff --git a/Minecraft.World/MerchantRecipe.cpp b/Minecraft.World/MerchantRecipe.cpp index 9c30c36bb..b4eb1b541 100644 --- a/Minecraft.World/MerchantRecipe.cpp +++ b/Minecraft.World/MerchantRecipe.cpp @@ -34,12 +34,12 @@ MerchantRecipe::MerchantRecipe(shared_ptr buy, shared_ptr buy, Item *sell) { - _init(buy, nullptr, shared_ptr(new ItemInstance(sell))); + _init(buy, nullptr, std::make_shared(sell)); } MerchantRecipe::MerchantRecipe(shared_ptr buy, Tile *sell) { - _init(buy, nullptr, shared_ptr(new ItemInstance(sell))); + _init(buy, nullptr, std::make_shared(sell)); } shared_ptr MerchantRecipe::getBuyAItem() diff --git a/Minecraft.World/MilkBucketItem.cpp b/Minecraft.World/MilkBucketItem.cpp index 4a3710788..8c8ea674c 100644 --- a/Minecraft.World/MilkBucketItem.cpp +++ b/Minecraft.World/MilkBucketItem.cpp @@ -19,7 +19,7 @@ shared_ptr MilkBucketItem::useTimeDepleted(shared_ptrcount <= 0) { - return shared_ptr( new ItemInstance(Item::bucket_empty) ); + return std::make_shared(Item::bucket_empty); } return instance; } diff --git a/Minecraft.World/MineShaftPieces.cpp b/Minecraft.World/MineShaftPieces.cpp index 6f1d9adbd..97caf3663 100644 --- a/Minecraft.World/MineShaftPieces.cpp +++ b/Minecraft.World/MineShaftPieces.cpp @@ -434,7 +434,7 @@ bool MineShaftPieces::MineShaftCorridor::createChest(Level *level, BoundingBox * if (level->getTile(worldX, worldY, worldZ) == 0) { level->setTileAndData(worldX, worldY, worldZ, Tile::rail_Id, getOrientationData(Tile::rail_Id, random->nextBoolean() ? RailTile::DIR_FLAT_X : RailTile::DIR_FLAT_Z), Tile::UPDATE_CLIENTS); - shared_ptr chest = shared_ptr( new MinecartChest(level, worldX + 0.5f, worldY + 0.5f, worldZ + 0.5f) ); + shared_ptr chest = std::make_shared(level, worldX + 0.5f, worldY + 0.5f, worldZ + 0.5f); WeighedTreasure::addChestItems(random, treasure, chest, numRolls); level->addEntity(chest); return true; diff --git a/Minecraft.World/Minecart.cpp b/Minecraft.World/Minecart.cpp index 34076b126..f6c4bb769 100644 --- a/Minecraft.World/Minecart.cpp +++ b/Minecraft.World/Minecart.cpp @@ -69,17 +69,17 @@ shared_ptr Minecart::createMinecart(Level *level, double x, double y, switch (type) { case TYPE_CHEST: - return shared_ptr( new MinecartChest(level, x, y, z) ); + return std::make_shared(level, x, y, z); case TYPE_FURNACE: - return shared_ptr( new MinecartFurnace(level, x, y, z) ); + return std::make_shared(level, x, y, z); case TYPE_TNT: - return shared_ptr( new MinecartTNT(level, x, y, z) ); + return std::make_shared(level, x, y, z); case TYPE_SPAWNER: - return shared_ptr( new MinecartSpawner(level, x, y, z) ); + return std::make_shared(level, x, y, z); case TYPE_HOPPER: - return shared_ptr( new MinecartHopper(level, x, y, z) ); + return std::make_shared(level, x, y, z); default: - return shared_ptr( new MinecartRideable(level, x, y, z) ); + return std::make_shared(level, x, y, z); } } @@ -187,7 +187,7 @@ bool Minecart::hurt(DamageSource *source, float hurtDamage) void Minecart::destroy(DamageSource *source) { remove(); - shared_ptr item = shared_ptr( new ItemInstance(Item::minecart, 1) ); + shared_ptr item = std::make_shared(Item::minecart, 1); if (!name.empty()) item->setHoverName(name); spawnAtLocation(item, 0); } diff --git a/Minecraft.World/MinecartContainer.cpp b/Minecraft.World/MinecartContainer.cpp index e1a7e002a..0e0fd3ac7 100644 --- a/Minecraft.World/MinecartContainer.cpp +++ b/Minecraft.World/MinecartContainer.cpp @@ -45,7 +45,7 @@ void MinecartContainer::destroy(DamageSource *source) if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()))) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; @@ -157,7 +157,7 @@ void MinecartContainer::remove() if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue())))); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); if (item->hasTag()) { diff --git a/Minecraft.World/MinecartFurnace.cpp b/Minecraft.World/MinecartFurnace.cpp index b2ced6ed3..fa005ecaf 100644 --- a/Minecraft.World/MinecartFurnace.cpp +++ b/Minecraft.World/MinecartFurnace.cpp @@ -66,7 +66,7 @@ void MinecartFurnace::destroy(DamageSource *source) if (!source->isExplosion()) { - spawnAtLocation(shared_ptr(new ItemInstance(Tile::furnace, 1)), 0); + spawnAtLocation(std::make_shared(Tile::furnace, 1), 0); } } diff --git a/Minecraft.World/MinecartTNT.cpp b/Minecraft.World/MinecartTNT.cpp index 11a664843..57462e03d 100644 --- a/Minecraft.World/MinecartTNT.cpp +++ b/Minecraft.World/MinecartTNT.cpp @@ -66,7 +66,7 @@ void MinecartTNT::destroy(DamageSource *source) if (!source->isExplosion()) { - spawnAtLocation( shared_ptr( new ItemInstance(Tile::tnt, 1) ), 0); + spawnAtLocation(std::make_shared(Tile::tnt, 1), 0); } if (source->isFire() || source->isExplosion() || speedSqr >= 0.01f) diff --git a/Minecraft.World/Mob.cpp b/Minecraft.World/Mob.cpp index af49499ae..17671112f 100644 --- a/Minecraft.World/Mob.cpp +++ b/Minecraft.World/Mob.cpp @@ -729,7 +729,7 @@ void Mob::populateDefaultEquipmentSlots() if (item == nullptr) { Item *equip = getEquipmentForSlot(i + 1, armorType); - if (equip != nullptr) setEquippedSlot(i + 1, shared_ptr(new ItemInstance(equip))); + if (equip != nullptr) setEquippedSlot(i + 1, std::make_shared(equip)); } } } @@ -983,7 +983,7 @@ void Mob::dropLeash(bool synch, bool createItemDrop) ServerLevel *serverLevel = dynamic_cast(level); if (!level->isClientSide && synch && serverLevel != nullptr) { - serverLevel->getTracker()->broadcast(shared_from_this(), shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, shared_from_this(), nullptr))); + serverLevel->getTracker()->broadcast(shared_from_this(), std::make_shared(SetEntityLinkPacket::LEASH, shared_from_this(), nullptr)); } } } @@ -1011,7 +1011,7 @@ void Mob::setLeashedTo(shared_ptr holder, bool synch) ServerLevel *serverLevel = dynamic_cast(level); if (!level->isClientSide && synch && serverLevel) { - serverLevel->getTracker()->broadcast(shared_from_this(), shared_ptr( new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, shared_from_this(), leashHolder))); + serverLevel->getTracker()->broadcast(shared_from_this(), std::make_shared(SetEntityLinkPacket::LEASH, shared_from_this(), leashHolder)); } } diff --git a/Minecraft.World/MobSpawnerTile.cpp b/Minecraft.World/MobSpawnerTile.cpp index 4665015a6..08c1f87dd 100644 --- a/Minecraft.World/MobSpawnerTile.cpp +++ b/Minecraft.World/MobSpawnerTile.cpp @@ -9,7 +9,7 @@ MobSpawnerTile::MobSpawnerTile(int id) : BaseEntityTile(id, Material::stone, isS shared_ptr MobSpawnerTile::newTileEntity(Level *level) { - return shared_ptr( new MobSpawnerTileEntity() ); + return std::make_shared(); } int MobSpawnerTile::getResource(int data, Random *random, int playerBonusLevel) diff --git a/Minecraft.World/MobSpawnerTileEntity.cpp b/Minecraft.World/MobSpawnerTileEntity.cpp index 028ad3e44..e3ee57d6b 100644 --- a/Minecraft.World/MobSpawnerTileEntity.cpp +++ b/Minecraft.World/MobSpawnerTileEntity.cpp @@ -73,7 +73,7 @@ shared_ptr MobSpawnerTileEntity::getUpdatePacket() CompoundTag *tag = new CompoundTag(); save(tag); tag->remove(L"SpawnPotentials"); - return shared_ptr( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_MOB_SPAWNER, tag) ); + return std::make_shared(x, y, z, TileEntityDataPacket::TYPE_MOB_SPAWNER, tag); } bool MobSpawnerTileEntity::triggerEvent(int b0, int b1) @@ -90,7 +90,7 @@ BaseMobSpawner *MobSpawnerTileEntity::getSpawner() // 4J Added shared_ptr MobSpawnerTileEntity::clone() { - shared_ptr result = shared_ptr( new MobSpawnerTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); return result; diff --git a/Minecraft.World/MoveEntityPacket.h b/Minecraft.World/MoveEntityPacket.h index ab16ac3a4..dc0f44d57 100644 --- a/Minecraft.World/MoveEntityPacket.h +++ b/Minecraft.World/MoveEntityPacket.h @@ -27,7 +27,7 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 30; } }; @@ -42,7 +42,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacket::PosRot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 33; } }; @@ -57,7 +57,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacket::Pos()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 31; } }; @@ -72,7 +72,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacket::Rot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 32; } }; \ No newline at end of file diff --git a/Minecraft.World/MoveEntityPacketSmall.h b/Minecraft.World/MoveEntityPacketSmall.h index 4218f11b9..c3f357dd7 100644 --- a/Minecraft.World/MoveEntityPacketSmall.h +++ b/Minecraft.World/MoveEntityPacketSmall.h @@ -27,7 +27,7 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacketSmall()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 162; } }; @@ -42,7 +42,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacketSmall::PosRot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 165; } }; @@ -57,7 +57,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacketSmall::Pos()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 163; } }; @@ -73,7 +73,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacketSmall::Rot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 164; } }; \ No newline at end of file diff --git a/Minecraft.World/MovePlayerPacket.h b/Minecraft.World/MovePlayerPacket.h index 26ae83927..1850c9d3c 100644 --- a/Minecraft.World/MovePlayerPacket.h +++ b/Minecraft.World/MovePlayerPacket.h @@ -27,7 +27,7 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new MovePlayerPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 10; } }; @@ -42,7 +42,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MovePlayerPacket::PosRot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 13; } }; @@ -57,7 +57,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MovePlayerPacket::Pos()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 11; } }; @@ -72,7 +72,7 @@ public: virtual void write(DataOutputStream *dos); virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MovePlayerPacket::Rot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 12; } }; \ No newline at end of file diff --git a/Minecraft.World/MushroomCow.cpp b/Minecraft.World/MushroomCow.cpp index 66969a00f..2b274215e 100644 --- a/Minecraft.World/MushroomCow.cpp +++ b/Minecraft.World/MushroomCow.cpp @@ -28,11 +28,11 @@ bool MushroomCow::mobInteract(shared_ptr player) { if (item->count == 1) { - player->inventory->setItem(player->inventory->selected, shared_ptr( new ItemInstance(Item::mushroomStew) ) ); + player->inventory->setItem(player->inventory->selected, std::make_shared(Item::mushroomStew)); return true; } - if (player->inventory->add(shared_ptr(new ItemInstance(Item::mushroomStew))) && !player->abilities.instabuild) + if (player->inventory->add(std::make_shared(Item::mushroomStew)) && !player->abilities.instabuild) { player->inventory->removeItem(player->inventory->selected, 1); return true; @@ -46,14 +46,14 @@ bool MushroomCow::mobInteract(shared_ptr player) if(!level->isClientSide) { remove(); - shared_ptr cow = shared_ptr( new Cow(level) ); + shared_ptr cow = std::make_shared(level); cow->moveTo(x, y, z, yRot, xRot); cow->setHealth(getHealth()); cow->yBodyRot = yBodyRot; level->addEntity(cow); for (int i = 0; i < 5; i++) { - level->addEntity( shared_ptr( new ItemEntity(level, x, y + bbHeight, z, shared_ptr( new ItemInstance(Tile::mushroom_red))) )); + level->addEntity(std::make_shared(level, x, y + bbHeight, z, shared_ptr(new ItemInstance(Tile::mushroom_red)))); } return true; } @@ -76,7 +76,7 @@ shared_ptr MushroomCow::getBreedOffspring(shared_ptr targe // 4J - added limit to number of animals that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - return shared_ptr( new MushroomCow(level) ); + return std::make_shared(level); } else { diff --git a/Minecraft.World/MusicTileEntity.cpp b/Minecraft.World/MusicTileEntity.cpp index ac39758ae..7f2f28889 100644 --- a/Minecraft.World/MusicTileEntity.cpp +++ b/Minecraft.World/MusicTileEntity.cpp @@ -55,7 +55,7 @@ void MusicTileEntity::playNote(Level *level, int x, int y, int z) // 4J Added shared_ptr MusicTileEntity::clone() { - shared_ptr result = shared_ptr( new MusicTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->note = note; diff --git a/Minecraft.World/NetherWartTile.cpp b/Minecraft.World/NetherWartTile.cpp index add3eccf7..afe45aec5 100644 --- a/Minecraft.World/NetherWartTile.cpp +++ b/Minecraft.World/NetherWartTile.cpp @@ -84,7 +84,7 @@ void NetherWartTile::spawnResources(Level *level, int x, int y, int z, int data, } for (int i = 0; i < count; i++) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(Item::netherwart_seeds))); + popResource(level, x, y, z, std::make_shared(Item::netherwart_seeds)); } } diff --git a/Minecraft.World/NoteBlockTile.cpp b/Minecraft.World/NoteBlockTile.cpp index 4c58ec8b1..cafa0c4da 100644 --- a/Minecraft.World/NoteBlockTile.cpp +++ b/Minecraft.World/NoteBlockTile.cpp @@ -52,7 +52,7 @@ void NoteBlockTile::attack(Level *level, int x, int y, int z, shared_ptr shared_ptr NoteBlockTile::newTileEntity(Level *level) { - return shared_ptr( new MusicTileEntity() ); + return std::make_shared(); } bool NoteBlockTile::triggerEvent(Level *level, int x, int y, int z, int i, int note) diff --git a/Minecraft.World/Ocelot.cpp b/Minecraft.World/Ocelot.cpp index 474fcd71e..75c6e0f07 100644 --- a/Minecraft.World/Ocelot.cpp +++ b/Minecraft.World/Ocelot.cpp @@ -240,7 +240,7 @@ shared_ptr Ocelot::getBreedOffspring(shared_ptr target) // 4J - added limit to number of animals that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - shared_ptr offspring = shared_ptr( new Ocelot(level) ); + shared_ptr offspring = std::make_shared(level); if (isTame()) { offspring->setOwnerUUID(getOwnerUUID()); @@ -339,7 +339,7 @@ MobGroupData *Ocelot::finalizeMobSpawn(MobGroupData *groupData, int extraData /* { for (int kitten = 0; kitten < 2; kitten++) { - shared_ptr ocelot = shared_ptr( new Ocelot(level) ); + shared_ptr ocelot = std::make_shared(level); ocelot->moveTo(x, y, z, yRot, 0); ocelot->setAge(-20 * 60 * 20); level->addEntity(ocelot); diff --git a/Minecraft.World/Packet.cpp b/Minecraft.World/Packet.cpp index 417df48f3..e0f7603f2 100644 --- a/Minecraft.World/Packet.cpp +++ b/Minecraft.World/Packet.cpp @@ -512,7 +512,7 @@ shared_ptr Packet::readItem(DataInputStream *dis) int count = dis->readByte(); int damage = dis->readShort(); - item = shared_ptr( new ItemInstance(id, count, damage) ); + item = std::make_shared(id, count, damage); // 4J Stu - Always read/write the tag //if (Item.items[id].canBeDepleted() || Item.items[id].shouldOverrideMultiplayerNBT()) { diff --git a/Minecraft.World/Painting.cpp b/Minecraft.World/Painting.cpp index e1232809b..5e56b9cac 100644 --- a/Minecraft.World/Painting.cpp +++ b/Minecraft.World/Painting.cpp @@ -164,5 +164,5 @@ void Painting::dropItem(shared_ptr causedBy) } } - spawnAtLocation(shared_ptr(new ItemInstance(Item::painting)), 0.0f); + spawnAtLocation(std::make_shared(Item::painting), 0.0f); } \ No newline at end of file diff --git a/Minecraft.World/Pig.cpp b/Minecraft.World/Pig.cpp index 6ac1243af..a99af826c 100644 --- a/Minecraft.World/Pig.cpp +++ b/Minecraft.World/Pig.cpp @@ -164,7 +164,7 @@ void Pig::setSaddle(bool value) void Pig::thunderHit(const LightningBolt *lightningBolt) { if (level->isClientSide) return; - shared_ptr pz = shared_ptr( new PigZombie(level) ); + shared_ptr pz = std::make_shared(level); pz->moveTo(x, y, z, yRot, xRot); level->addEntity(pz); remove(); @@ -184,7 +184,7 @@ shared_ptr Pig::getBreedOffspring(shared_ptr target) // 4J - added limit to number of animals that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - return shared_ptr( new Pig(level) ); + return std::make_shared(level); } else { diff --git a/Minecraft.World/PigZombie.cpp b/Minecraft.World/PigZombie.cpp index 16f00213c..1be123d7a 100644 --- a/Minecraft.World/PigZombie.cpp +++ b/Minecraft.World/PigZombie.cpp @@ -174,7 +174,7 @@ int PigZombie::getDeathLoot() void PigZombie::populateDefaultEquipmentSlots() { - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::sword_gold)) ); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::sword_gold)); } MobGroupData *PigZombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /*= 0*/) // 4J Added extraData param diff --git a/Minecraft.World/PistonMovingPiece.cpp b/Minecraft.World/PistonMovingPiece.cpp index a1fe1c957..5ae010070 100644 --- a/Minecraft.World/PistonMovingPiece.cpp +++ b/Minecraft.World/PistonMovingPiece.cpp @@ -99,7 +99,7 @@ void PistonMovingPiece::neighborChanged(Level *level, int x, int y, int z, int t shared_ptr PistonMovingPiece::newMovingPieceEntity(int block, int data, int facing, bool extending, bool isSourcePiston) { - return shared_ptr(new PistonPieceEntity(block, data, facing, extending, isSourcePiston)); + return std::make_shared(block, data, facing, extending, isSourcePiston); } AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z) diff --git a/Minecraft.World/PistonPieceEntity.cpp b/Minecraft.World/PistonPieceEntity.cpp index dc946a2bd..08e18cbbf 100644 --- a/Minecraft.World/PistonPieceEntity.cpp +++ b/Minecraft.World/PistonPieceEntity.cpp @@ -207,7 +207,7 @@ void PistonPieceEntity::save(CompoundTag *tag) // 4J Added shared_ptr PistonPieceEntity::clone() { - shared_ptr result = shared_ptr( new PistonPieceEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->id = id; diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp index 4d5d55fbc..00c7148e4 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -50,7 +50,7 @@ void Player::_init() registerAttributes(); setHealth(getMaxHealth()); - inventory = shared_ptr( new Inventory( this ) ); + inventory = std::make_shared(this); userType = 0; oBob = bob = 0.0f; @@ -105,7 +105,7 @@ void Player::_init() m_ePlayerNameValidState=ePlayerNameValid_NotSet; #endif - enderChestInventory = shared_ptr(new PlayerEnderChestContainer()); + enderChestInventory = std::make_shared(); m_bAwardedOnARail=false; } @@ -1097,7 +1097,7 @@ void Player::die(DamageSource *source) // 4J - TODO need to use a xuid if ( app.isXuidNotch( m_xuid ) ) { - drop(shared_ptr( new ItemInstance(Item::apple, 1) ), true); + drop(std::make_shared(Item::apple, 1), true); } if (!level->getGameRules()->getBoolean(GameRules::RULE_KEEPINVENTORY)) { @@ -1170,7 +1170,7 @@ shared_ptr Player::drop(shared_ptr item, bool randomly if (item == nullptr) return nullptr; if (item->count == 0) return nullptr; - shared_ptr thrownItem = shared_ptr( new ItemEntity(level, x, y - 0.3f + getHeadHeight(), z, item) ); + shared_ptr thrownItem = std::make_shared(level, x, y - 0.3f + getHeadHeight(), z, item); thrownItem->throwTime = 20 * 2; thrownItem->setThrower(getName()); diff --git a/Minecraft.World/PlayerAbilitiesPacket.h b/Minecraft.World/PlayerAbilitiesPacket.h index 8cd82bf5a..3998c66bc 100644 --- a/Minecraft.World/PlayerAbilitiesPacket.h +++ b/Minecraft.World/PlayerAbilitiesPacket.h @@ -44,6 +44,6 @@ public: bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new PlayerAbilitiesPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 202; } }; \ No newline at end of file diff --git a/Minecraft.World/PlayerActionPacket.h b/Minecraft.World/PlayerActionPacket.h index 45c077d2a..647777cd7 100644 --- a/Minecraft.World/PlayerActionPacket.h +++ b/Minecraft.World/PlayerActionPacket.h @@ -24,7 +24,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new PlayerActionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 14; } }; diff --git a/Minecraft.World/PlayerCommandPacket.h b/Minecraft.World/PlayerCommandPacket.h index 92ee57eb5..042b32cae 100644 --- a/Minecraft.World/PlayerCommandPacket.h +++ b/Minecraft.World/PlayerCommandPacket.h @@ -36,6 +36,6 @@ public: virtual void handle(PacketListener *listener); virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new PlayerCommandPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 19; } }; \ No newline at end of file diff --git a/Minecraft.World/PlayerInfoPacket.h b/Minecraft.World/PlayerInfoPacket.h index 85e2ed648..7044ffbda 100644 --- a/Minecraft.World/PlayerInfoPacket.h +++ b/Minecraft.World/PlayerInfoPacket.h @@ -27,6 +27,6 @@ class PlayerInfoPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new PlayerInfoPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 201; } }; \ No newline at end of file diff --git a/Minecraft.World/PlayerInputPacket.h b/Minecraft.World/PlayerInputPacket.h index bc2d39851..6f1dce47b 100644 --- a/Minecraft.World/PlayerInputPacket.h +++ b/Minecraft.World/PlayerInputPacket.h @@ -27,6 +27,6 @@ public: bool isSneaking(); public: - static shared_ptr create() { return shared_ptr(new PlayerInputPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 27; } }; \ No newline at end of file diff --git a/Minecraft.World/PotatoTile.cpp b/Minecraft.World/PotatoTile.cpp index 872622ba9..351c8c980 100644 --- a/Minecraft.World/PotatoTile.cpp +++ b/Minecraft.World/PotatoTile.cpp @@ -46,7 +46,7 @@ void PotatoTile::spawnResources(Level *level, int x, int y, int z, int data, flo { if (level->random->nextInt(50) == 0) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(Item::potatoPoisonous))); + popResource(level, x, y, z, std::make_shared(Item::potatoPoisonous)); } } } diff --git a/Minecraft.World/PotionItem.cpp b/Minecraft.World/PotionItem.cpp index 3438cb854..fd156883d 100644 --- a/Minecraft.World/PotionItem.cpp +++ b/Minecraft.World/PotionItem.cpp @@ -94,11 +94,11 @@ shared_ptr PotionItem::useTimeDepleted(shared_ptr in { if (instance->count <= 0) { - return shared_ptr( new ItemInstance(Item::glassBottle) ); + return std::make_shared(Item::glassBottle); } else { - player->inventory->add( shared_ptr( new ItemInstance(Item::glassBottle) ) ); + player->inventory->add(std::make_shared(Item::glassBottle)); } } @@ -126,7 +126,7 @@ shared_ptr PotionItem::use(shared_ptr instance, Leve { if (!player->abilities.instabuild) instance->count--; level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); - if (!level->isClientSide) level->addEntity(shared_ptr( new ThrownPotion(level, player, instance->getAuxValue()) )); + if (!level->isClientSide) level->addEntity(std::make_shared(level, player, instance->getAuxValue())); return instance; } player->startUsingItem(instance, getUseDuration(instance)); diff --git a/Minecraft.World/PreLoginPacket.h b/Minecraft.World/PreLoginPacket.h index 243f2f360..b0935d0a5 100644 --- a/Minecraft.World/PreLoginPacket.h +++ b/Minecraft.World/PreLoginPacket.h @@ -34,6 +34,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new PreLoginPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 2; } }; \ No newline at end of file diff --git a/Minecraft.World/PumpkinTile.cpp b/Minecraft.World/PumpkinTile.cpp index f7bfe218c..da11001d8 100644 --- a/Minecraft.World/PumpkinTile.cpp +++ b/Minecraft.World/PumpkinTile.cpp @@ -45,7 +45,7 @@ void PumpkinTile::onPlace(Level *level, int x, int y, int z) level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_CLIENTS); level->setTileAndData(x, y - 1, z, 0, 0, Tile::UPDATE_CLIENTS); level->setTileAndData(x, y - 2, z, 0, 0, Tile::UPDATE_CLIENTS); - shared_ptr snowMan = shared_ptr(new SnowMan(level)); + shared_ptr snowMan = std::make_shared(level); snowMan->moveTo(x + 0.5, y - 1.95, z + 0.5, 0, 0); level->addEntity(snowMan); @@ -94,7 +94,7 @@ void PumpkinTile::onPlace(Level *level, int x, int y, int z) level->setTileAndData(x, y - 1, z + 1, 0, 0, Tile::UPDATE_CLIENTS); } - shared_ptr villagerGolem = shared_ptr(new VillagerGolem(level)); + shared_ptr villagerGolem = std::make_shared(level); villagerGolem->setPlayerCreated(true); villagerGolem->moveTo(x + 0.5, y - 1.95, z + 0.5, 0, 0); level->addEntity(villagerGolem); diff --git a/Minecraft.World/QuartzBlockTile.cpp b/Minecraft.World/QuartzBlockTile.cpp index 709e0c1e9..d0ab02d2a 100644 --- a/Minecraft.World/QuartzBlockTile.cpp +++ b/Minecraft.World/QuartzBlockTile.cpp @@ -91,7 +91,7 @@ int QuartzBlockTile::getSpawnResourcesAuxValue(int data) shared_ptr QuartzBlockTile::getSilkTouchItemInstance(int data) { - if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return shared_ptr(new ItemInstance(id, 1, TYPE_LINES_Y)); + if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return std::make_shared(id, 1, TYPE_LINES_Y); return Tile::getSilkTouchItemInstance(data); } diff --git a/Minecraft.World/Recipes.cpp b/Minecraft.World/Recipes.cpp index 94ee30ac7..c200d1651 100644 --- a/Minecraft.World/Recipes.cpp +++ b/Minecraft.World/Recipes.cpp @@ -1272,7 +1272,7 @@ shared_ptr Recipes::getItemFor(shared_ptr craft int remaining = (remaining1 + remaining2) + item->getMaxDamage() * 5 / 100; int resultDamage = item->getMaxDamage() - remaining; if (resultDamage < 0) resultDamage = 0; - return shared_ptr( new ItemInstance(first->id, 1, resultDamage) ); + return std::make_shared(first->id, 1, resultDamage); } if(recipesClass != nullptr) diff --git a/Minecraft.World/RedStoneOreTile.cpp b/Minecraft.World/RedStoneOreTile.cpp index b7551932f..407da2cc3 100644 --- a/Minecraft.World/RedStoneOreTile.cpp +++ b/Minecraft.World/RedStoneOreTile.cpp @@ -124,5 +124,5 @@ bool RedStoneOreTile::shouldTileTick(Level *level, int x,int y,int z) shared_ptr RedStoneOreTile::getSilkTouchItemInstance(int data) { - return shared_ptr(new ItemInstance(Tile::redStoneOre)); + return std::make_shared(Tile::redStoneOre); } \ No newline at end of file diff --git a/Minecraft.World/RemoveEntitiesPacket.h b/Minecraft.World/RemoveEntitiesPacket.h index 2e734e711..b400b861a 100644 --- a/Minecraft.World/RemoveEntitiesPacket.h +++ b/Minecraft.World/RemoveEntitiesPacket.h @@ -21,7 +21,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new RemoveEntitiesPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 29; } }; diff --git a/Minecraft.World/RemoveMobEffectPacket.h b/Minecraft.World/RemoveMobEffectPacket.h index d69a4ed4a..140b0a7e0 100644 --- a/Minecraft.World/RemoveMobEffectPacket.h +++ b/Minecraft.World/RemoveMobEffectPacket.h @@ -18,6 +18,6 @@ class RemoveMobEffectPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new RemoveMobEffectPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 42; } }; \ No newline at end of file diff --git a/Minecraft.World/RespawnPacket.h b/Minecraft.World/RespawnPacket.h index dc341ea17..90a5ef0d9 100644 --- a/Minecraft.World/RespawnPacket.h +++ b/Minecraft.World/RespawnPacket.h @@ -29,6 +29,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new RespawnPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 9; } }; diff --git a/Minecraft.World/ResultSlot.cpp b/Minecraft.World/ResultSlot.cpp index 87318d66b..89a07ed10 100644 --- a/Minecraft.World/ResultSlot.cpp +++ b/Minecraft.World/ResultSlot.cpp @@ -66,7 +66,7 @@ void ResultSlot::onTake(shared_ptr player, shared_ptr carr if (item->getItem()->hasCraftingRemainingItem()) { - shared_ptr craftResult = shared_ptr(new ItemInstance(item->getItem()->getCraftingRemainingItem())); + shared_ptr craftResult = std::make_shared(item->getItem()->getCraftingRemainingItem()); /* * Try to place this in the player's inventory (See we.java for new method) diff --git a/Minecraft.World/RotateHeadPacket.h b/Minecraft.World/RotateHeadPacket.h index 19ccf97f4..884f48444 100644 --- a/Minecraft.World/RotateHeadPacket.h +++ b/Minecraft.World/RotateHeadPacket.h @@ -22,6 +22,6 @@ public: virtual bool isAync(); public: - static shared_ptr create() { return shared_ptr(new RotateHeadPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 35; } }; \ No newline at end of file diff --git a/Minecraft.World/RotatedPillarTile.cpp b/Minecraft.World/RotatedPillarTile.cpp index a4b7d931e..6475cd727 100644 --- a/Minecraft.World/RotatedPillarTile.cpp +++ b/Minecraft.World/RotatedPillarTile.cpp @@ -73,5 +73,5 @@ int RotatedPillarTile::getType(int data) shared_ptr RotatedPillarTile::getSilkTouchItemInstance(int data) { - return shared_ptr( new ItemInstance(id, 1, getType(data)) ); + return std::make_shared(id, 1, getType(data)); } \ No newline at end of file diff --git a/Minecraft.World/SavedDataStorage.cpp b/Minecraft.World/SavedDataStorage.cpp index d882b2053..049a19fc2 100644 --- a/Minecraft.World/SavedDataStorage.cpp +++ b/Minecraft.World/SavedDataStorage.cpp @@ -37,15 +37,15 @@ shared_ptr SavedDataStorage::get(const type_info& clazz, const wstrin if( clazz == typeid(MapItemSavedData) ) { - data = dynamic_pointer_cast( shared_ptr(new MapItemSavedData(id)) ); + data = dynamic_pointer_cast(std::make_shared(id)); } else if( clazz == typeid(Villages) ) { - data = dynamic_pointer_cast( shared_ptr(new Villages(id) ) ); + data = dynamic_pointer_cast(std::make_shared(id)); } else if( clazz == typeid(StructureFeatureSavedData) ) { - data = dynamic_pointer_cast( shared_ptr( new StructureFeatureSavedData(id) ) ); + data = dynamic_pointer_cast(std::make_shared(id)); } else { diff --git a/Minecraft.World/ScatteredFeaturePieces.cpp b/Minecraft.World/ScatteredFeaturePieces.cpp index a623f9727..07630ef7a 100644 --- a/Minecraft.World/ScatteredFeaturePieces.cpp +++ b/Minecraft.World/ScatteredFeaturePieces.cpp @@ -737,7 +737,7 @@ bool ScatteredFeaturePieces::SwamplandHut::postProcess(Level *level, Random *ran { spawnedWitch = true; - shared_ptr witch = shared_ptr( new Witch(level) ); + shared_ptr witch = std::make_shared(level); witch->moveTo(wx + .5, wy, wz + .5, 0, 0); witch->finalizeMobSpawn(nullptr); level->addEntity(witch); diff --git a/Minecraft.World/ServerSettingsChangedPacket.h b/Minecraft.World/ServerSettingsChangedPacket.h index e6ab73563..c537eca94 100644 --- a/Minecraft.World/ServerSettingsChangedPacket.h +++ b/Minecraft.World/ServerSettingsChangedPacket.h @@ -26,6 +26,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ServerSettingsChangedPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 153; } }; \ No newline at end of file diff --git a/Minecraft.World/SetCarriedItemPacket.h b/Minecraft.World/SetCarriedItemPacket.h index 06fb3c306..017314dce 100644 --- a/Minecraft.World/SetCarriedItemPacket.h +++ b/Minecraft.World/SetCarriedItemPacket.h @@ -19,6 +19,6 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new SetCarriedItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 16; } }; \ No newline at end of file diff --git a/Minecraft.World/SetCreativeModeSlotPacket.h b/Minecraft.World/SetCreativeModeSlotPacket.h index 94ae7807f..3724714e0 100644 --- a/Minecraft.World/SetCreativeModeSlotPacket.h +++ b/Minecraft.World/SetCreativeModeSlotPacket.h @@ -18,6 +18,6 @@ class SetCreativeModeSlotPacket : public Packet, public enable_shared_from_this< public: - static shared_ptr create() { return shared_ptr(new SetCreativeModeSlotPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 107; } }; \ No newline at end of file diff --git a/Minecraft.World/SetDisplayObjectivePacket.h b/Minecraft.World/SetDisplayObjectivePacket.h index f32f63866..5404eab75 100644 --- a/Minecraft.World/SetDisplayObjectivePacket.h +++ b/Minecraft.World/SetDisplayObjectivePacket.h @@ -19,6 +19,6 @@ public: int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new SetDisplayObjectivePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 208; } }; \ No newline at end of file diff --git a/Minecraft.World/SetEntityDataPacket.h b/Minecraft.World/SetEntityDataPacket.h index a3bb08609..cd3371dd7 100644 --- a/Minecraft.World/SetEntityDataPacket.h +++ b/Minecraft.World/SetEntityDataPacket.h @@ -25,6 +25,6 @@ public: vector > *getUnpackedData(); public: - static shared_ptr create() { return shared_ptr(new SetEntityDataPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 40; } }; \ No newline at end of file diff --git a/Minecraft.World/SetEntityLinkPacket.h b/Minecraft.World/SetEntityLinkPacket.h index aa92206df..04ee0e977 100644 --- a/Minecraft.World/SetEntityLinkPacket.h +++ b/Minecraft.World/SetEntityLinkPacket.h @@ -23,7 +23,7 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new SetEntityLinkPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 39; } }; \ No newline at end of file diff --git a/Minecraft.World/SetEntityMotionPacket.h b/Minecraft.World/SetEntityMotionPacket.h index 00c019da9..e71240c5c 100644 --- a/Minecraft.World/SetEntityMotionPacket.h +++ b/Minecraft.World/SetEntityMotionPacket.h @@ -26,6 +26,6 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new SetEntityMotionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 28; } }; \ No newline at end of file diff --git a/Minecraft.World/SetEquippedItemPacket.h b/Minecraft.World/SetEquippedItemPacket.h index def39120b..29df2b028 100644 --- a/Minecraft.World/SetEquippedItemPacket.h +++ b/Minecraft.World/SetEquippedItemPacket.h @@ -28,6 +28,6 @@ public: shared_ptr getItem(); public: - static shared_ptr create() { return shared_ptr(new SetEquippedItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 5; } }; \ No newline at end of file diff --git a/Minecraft.World/SetExperiencePacket.h b/Minecraft.World/SetExperiencePacket.h index 01c0ed468..668f44168 100644 --- a/Minecraft.World/SetExperiencePacket.h +++ b/Minecraft.World/SetExperiencePacket.h @@ -20,6 +20,6 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new SetExperiencePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 43; } }; \ No newline at end of file diff --git a/Minecraft.World/SetHealthPacket.h b/Minecraft.World/SetHealthPacket.h index 4704f220b..cc85c4c62 100644 --- a/Minecraft.World/SetHealthPacket.h +++ b/Minecraft.World/SetHealthPacket.h @@ -23,7 +23,7 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new SetHealthPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 8; } }; diff --git a/Minecraft.World/SetObjectivePacket.h b/Minecraft.World/SetObjectivePacket.h index 5b5dfc6fd..52b67ee02 100644 --- a/Minecraft.World/SetObjectivePacket.h +++ b/Minecraft.World/SetObjectivePacket.h @@ -23,6 +23,6 @@ public: int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new SetObjectivePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 206; } }; \ No newline at end of file diff --git a/Minecraft.World/SetPlayerTeamPacket.h b/Minecraft.World/SetPlayerTeamPacket.h index f6df9da2c..60364db55 100644 --- a/Minecraft.World/SetPlayerTeamPacket.h +++ b/Minecraft.World/SetPlayerTeamPacket.h @@ -30,6 +30,6 @@ public: int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new SetPlayerTeamPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 209; } }; \ No newline at end of file diff --git a/Minecraft.World/SetScorePacket.h b/Minecraft.World/SetScorePacket.h index 5f800be6a..245559731 100644 --- a/Minecraft.World/SetScorePacket.h +++ b/Minecraft.World/SetScorePacket.h @@ -25,6 +25,6 @@ public: int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new SetScorePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 207; } }; \ No newline at end of file diff --git a/Minecraft.World/SetSpawnPositionPacket.h b/Minecraft.World/SetSpawnPositionPacket.h index 3ba66af87..f90d3f5c6 100644 --- a/Minecraft.World/SetSpawnPositionPacket.h +++ b/Minecraft.World/SetSpawnPositionPacket.h @@ -20,6 +20,6 @@ public: virtual bool isAync(); public: - static shared_ptr create() { return shared_ptr(new SetSpawnPositionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 6; } }; \ No newline at end of file diff --git a/Minecraft.World/SetTimePacket.h b/Minecraft.World/SetTimePacket.h index 7ded9ce1f..56cf4922e 100644 --- a/Minecraft.World/SetTimePacket.h +++ b/Minecraft.World/SetTimePacket.h @@ -21,6 +21,6 @@ public: virtual bool isAync(); public: - static shared_ptr create() { return shared_ptr(new SetTimePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 4; } }; \ No newline at end of file diff --git a/Minecraft.World/Sheep.cpp b/Minecraft.World/Sheep.cpp index 7343e29c0..f06308f49 100644 --- a/Minecraft.World/Sheep.cpp +++ b/Minecraft.World/Sheep.cpp @@ -65,9 +65,9 @@ Sheep::Sheep(Level *level) : Animal( level ) goalSelector.addGoal(7, new LookAtPlayerGoal(this, typeid(Player), 6)); goalSelector.addGoal(8, new RandomLookAroundGoal(this)); - container = shared_ptr(new CraftingContainer(new SheepContainer(), 2, 1)); - container->setItem(0, shared_ptr( new ItemInstance(Item::dye_powder, 1, 0))); - container->setItem(1, shared_ptr( new ItemInstance(Item::dye_powder, 1, 0))); + container = std::make_shared(new SheepContainer(), 2, 1); + container->setItem(0, std::make_shared(Item::dye_powder, 1, 0)); + container->setItem(1, std::make_shared(Item::dye_powder, 1, 0)); } bool Sheep::useNewAi() @@ -108,7 +108,7 @@ void Sheep::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) if(!isSheared()) { // killing a non-sheared sheep will drop a single block of cloth - spawnAtLocation(shared_ptr( new ItemInstance(Tile::wool_Id, 1, getColor()) ), 0.0f); + spawnAtLocation(std::make_shared(Tile::wool_Id, 1, getColor()), 0.0f); } } @@ -177,7 +177,7 @@ bool Sheep::mobInteract(shared_ptr player) int count = 1 + random->nextInt(3); for (int i = 0; i < count; i++) { - shared_ptr ie = spawnAtLocation(shared_ptr( new ItemInstance(Tile::wool_Id, 1, getColor()) ), 1.0f); + shared_ptr ie = spawnAtLocation(std::make_shared(Tile::wool_Id, 1, getColor()), 1.0f); ie->yd += random->nextFloat() * 0.05f; ie->xd += (random->nextFloat() - random->nextFloat()) * 0.1f; ie->zd += (random->nextFloat() - random->nextFloat()) * 0.1f; @@ -284,7 +284,7 @@ shared_ptr Sheep::getBreedOffspring(shared_ptr target) if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { shared_ptr otherSheep = dynamic_pointer_cast( target ); - shared_ptr sheep = shared_ptr( new Sheep(level) ); + shared_ptr sheep = std::make_shared(level); int color = getOffspringColor(dynamic_pointer_cast(shared_from_this()), otherSheep); sheep->setColor(15 - color); return sheep; diff --git a/Minecraft.World/SignTile.cpp b/Minecraft.World/SignTile.cpp index 1f8c6e948..15be23db5 100644 --- a/Minecraft.World/SignTile.cpp +++ b/Minecraft.World/SignTile.cpp @@ -79,7 +79,7 @@ shared_ptr SignTile::newTileEntity(Level *level) { //try { // 4J Stu - For some reason the newInstance wasn't working right, but doing it like the other TileEntities is fine - return shared_ptr( new SignTileEntity() ); + return std::make_shared(); //return dynamic_pointer_cast( clas->newInstance() ); //} catch (Exception e) { // TODO 4J Stu - Exception handling diff --git a/Minecraft.World/SignTileEntity.cpp b/Minecraft.World/SignTileEntity.cpp index a90ca5017..598621eb5 100644 --- a/Minecraft.World/SignTileEntity.cpp +++ b/Minecraft.World/SignTileEntity.cpp @@ -93,7 +93,7 @@ shared_ptr SignTileEntity::getUpdatePacket() { copy[i] = m_wsmessages[i]; } - return shared_ptr( new SignUpdatePacket(x, y, z, m_bVerified, m_bCensored, copy) ); + return std::make_shared(x, y, z, m_bVerified, m_bCensored, copy); } bool SignTileEntity::isEditable() @@ -207,7 +207,7 @@ int SignTileEntity::StringVerifyCallback(LPVOID lpParam,STRING_VERIFY_RESPONSE * // 4J Added shared_ptr SignTileEntity::clone() { - shared_ptr result = shared_ptr( new SignTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->m_wsmessages[0] = m_wsmessages[0]; diff --git a/Minecraft.World/SignUpdatePacket.h b/Minecraft.World/SignUpdatePacket.h index 80cc29681..f44f4dded 100644 --- a/Minecraft.World/SignUpdatePacket.h +++ b/Minecraft.World/SignUpdatePacket.h @@ -21,6 +21,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new SignUpdatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 130; } }; \ No newline at end of file diff --git a/Minecraft.World/Skeleton.cpp b/Minecraft.World/Skeleton.cpp index d5f59dfe0..cc325b979 100644 --- a/Minecraft.World/Skeleton.cpp +++ b/Minecraft.World/Skeleton.cpp @@ -217,7 +217,7 @@ void Skeleton::dropRareDeathLoot(int rareLootLevel) { if (getSkeletonType() == TYPE_WITHER) { - spawnAtLocation( shared_ptr( new ItemInstance(Item::skull_Id, 1, SkullTileEntity::TYPE_WITHER) ), 0); + spawnAtLocation(std::make_shared(Item::skull_Id, 1, SkullTileEntity::TYPE_WITHER), 0); } } @@ -225,7 +225,7 @@ void Skeleton::populateDefaultEquipmentSlots() { Monster::populateDefaultEquipmentSlots(); - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::bow))); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::bow)); } MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData /*= 0*/) // 4J Added extraData param @@ -237,7 +237,7 @@ MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData goalSelector.addGoal(4, meleeGoal, false); setSkeletonType(TYPE_WITHER); - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::sword_stone))); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::sword_stone)); getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->setBaseValue(4); } else @@ -255,7 +255,7 @@ MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData if (Calendar::GetMonth() + 1 == 10 && Calendar::GetDayOfMonth() == 31 && random->nextFloat() < 0.25f) { // Halloween! OooOOo! 25% of all skeletons/zombies can wear pumpkins on their heads. - setEquippedSlot(SLOT_HELM, shared_ptr( new ItemInstance(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin))); + setEquippedSlot(SLOT_HELM, std::make_shared(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin)); dropChances[SLOT_HELM] = 0; } } @@ -281,7 +281,7 @@ void Skeleton::reassessWeaponGoal() void Skeleton::performRangedAttack(shared_ptr target, float power) { - shared_ptr arrow = shared_ptr( new Arrow(level, dynamic_pointer_cast(shared_from_this()), target, 1.60f, 14 - (level->difficulty * 4)) ); + shared_ptr arrow = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), target, 1.60f, 14 - (level->difficulty * 4)); int damageBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowBonus->id, getCarriedItem()); int knockbackBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowKnockback->id, getCarriedItem()); diff --git a/Minecraft.World/SkullTile.cpp b/Minecraft.World/SkullTile.cpp index 28699645d..b5eca3732 100644 --- a/Minecraft.World/SkullTile.cpp +++ b/Minecraft.World/SkullTile.cpp @@ -67,7 +67,7 @@ void SkullTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr SkullTile::newTileEntity(Level *level) { - return shared_ptr(new SkullTileEntity()); + return std::make_shared(); } int SkullTile::cloneTileId(Level *level, int x, int y, int z) @@ -113,7 +113,7 @@ void SkullTile::onRemove(Level *level, int x, int y, int z, int id, int data) if (level->isClientSide) return; if ((data & NO_DROP_BIT) == 0) { - shared_ptr item = shared_ptr(new ItemInstance(Item::skull_Id, 1, cloneTileData(level, x, y, z))); + shared_ptr item = std::make_shared(Item::skull_Id, 1, cloneTileData(level, x, y, z)); shared_ptr entity = dynamic_pointer_cast(level->getTileEntity(x, y, z)); if (entity->getSkullType() == SkullTileEntity::TYPE_CHAR && !entity->getExtraType().empty()) @@ -166,7 +166,7 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptrcanCreateMore(eTYPE_WITHERBOSS, Level::eSpawnType_Egg)) { // 4J: Removed !isClientSide check because there's one earlier on - shared_ptr witherBoss = shared_ptr( new WitherBoss(level) ); + shared_ptr witherBoss = std::make_shared(level); witherBoss->moveTo(x + 0.5, y - 1.45, z + zo + 1.5, 90, 0); witherBoss->yBodyRot = 90; witherBoss->makeInvulnerable(); @@ -180,8 +180,8 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptrspawnResources(level, x, y - 2, z + zo + 1, 0, 0); Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x, y - 1, z + zo + 2, 0, 0); - shared_ptr itemInstance = shared_ptr(new ItemInstance(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER)); - shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x, y, z + zo + 1, itemInstance) ); + shared_ptr itemInstance = std::make_shared(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER); + shared_ptr itemEntity = std::make_shared(level, x, y, z + zo + 1, itemInstance); level->addEntity(itemEntity); } @@ -229,7 +229,7 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptrcanCreateMore(eTYPE_WITHERBOSS, Level::eSpawnType_Egg)) { // 4J: Removed !isClientSide check because there's one earlier on - shared_ptr witherBoss = shared_ptr( new WitherBoss(level) ); + shared_ptr witherBoss = std::make_shared(level); witherBoss->moveTo(x + xo + 1.5, y - 1.45, z + .5, 0, 0); witherBoss->makeInvulnerable(); level->addEntity(witherBoss); @@ -242,8 +242,8 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptrspawnResources(level, x + xo + 1, y - 2, z, 0, 0); Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x + xo + 2, y - 1, z, 0, 0); - shared_ptr itemInstance = shared_ptr(new ItemInstance(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER)); - shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x + xo + 1, y, z, itemInstance) ); + shared_ptr itemInstance = std::make_shared(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER); + shared_ptr itemEntity = std::make_shared(level, x + xo + 1, y, z, itemInstance); level->addEntity(itemEntity); } diff --git a/Minecraft.World/SkullTileEntity.cpp b/Minecraft.World/SkullTileEntity.cpp index 404332d46..3937bec45 100644 --- a/Minecraft.World/SkullTileEntity.cpp +++ b/Minecraft.World/SkullTileEntity.cpp @@ -30,7 +30,7 @@ shared_ptr SkullTileEntity::getUpdatePacket() { CompoundTag *tag = new CompoundTag(); save(tag); - return shared_ptr(new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_SKULL, tag)); + return std::make_shared(x, y, z, TileEntityDataPacket::TYPE_SKULL, tag); } void SkullTileEntity::setSkullType(int skullType, const wstring &extra) @@ -62,7 +62,7 @@ wstring SkullTileEntity::getExtraType() // 4J Added shared_ptr SkullTileEntity::clone() { - shared_ptr result = shared_ptr( new SkullTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->skullType = skullType; diff --git a/Minecraft.World/Slime.cpp b/Minecraft.World/Slime.cpp index aefb8ae29..d91b0a136 100644 --- a/Minecraft.World/Slime.cpp +++ b/Minecraft.World/Slime.cpp @@ -179,7 +179,7 @@ int Slime::getJumpDelay() shared_ptr Slime::createChild() { - return shared_ptr( new Slime(level) ); + return std::make_shared(level); } void Slime::remove() diff --git a/Minecraft.World/Slot.cpp b/Minecraft.World/Slot.cpp index 91920b2de..2f42a27d1 100644 --- a/Minecraft.World/Slot.cpp +++ b/Minecraft.World/Slot.cpp @@ -148,7 +148,7 @@ shared_ptr Slot::combine(shared_ptr item) shared_ptr result = nullptr; shared_ptr first = getItem(); - shared_ptr craftSlots = shared_ptr( new CraftingContainer(nullptr, 2, 2) ); + shared_ptr craftSlots = std::make_shared(nullptr, 2, 2); craftSlots->setItem(0, item); craftSlots->setItem(1, first); diff --git a/Minecraft.World/SmoothZoomLayer.cpp b/Minecraft.World/SmoothZoomLayer.cpp index 3e1c55a18..c8cff40de 100644 --- a/Minecraft.World/SmoothZoomLayer.cpp +++ b/Minecraft.World/SmoothZoomLayer.cpp @@ -55,7 +55,7 @@ shared_ptrSmoothZoomLayer::zoom(__int64 seed, shared_ptrsup, int c shared_ptrresult = sup; for (int i = 0; i < count; i++) { - result = shared_ptr(new SmoothZoomLayer(seed + i, result)); + result = std::make_shared(seed + i, result); } return result; } \ No newline at end of file diff --git a/Minecraft.World/SnowMan.cpp b/Minecraft.World/SnowMan.cpp index 6c78b56f8..05ead6a69 100644 --- a/Minecraft.World/SnowMan.cpp +++ b/Minecraft.World/SnowMan.cpp @@ -100,7 +100,7 @@ void SnowMan::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) void SnowMan::performRangedAttack(shared_ptr target, float power) { - shared_ptr snowball = shared_ptr(new Snowball(level, dynamic_pointer_cast(shared_from_this()))); + shared_ptr snowball = std::make_shared(level, dynamic_pointer_cast(shared_from_this())); double xd = target->x - x; double yd = (target->y + target->getHeadHeight() - 1.1f) - snowball->y; double zd = target->z - z; diff --git a/Minecraft.World/SnowballItem.cpp b/Minecraft.World/SnowballItem.cpp index 0149e68dc..afb190d81 100644 --- a/Minecraft.World/SnowballItem.cpp +++ b/Minecraft.World/SnowballItem.cpp @@ -18,6 +18,6 @@ shared_ptr SnowballItem::use(shared_ptr instance, Le instance->count--; } level->playEntitySound((shared_ptr ) player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); - if (!level->isClientSide) level->addEntity( shared_ptr( new Snowball(level, player) ) ); + if (!level->isClientSide) level->addEntity(std::make_shared(level, player)); return instance; } \ No newline at end of file diff --git a/Minecraft.World/Spider.cpp b/Minecraft.World/Spider.cpp index 24d737699..5d7bdd2c8 100644 --- a/Minecraft.World/Spider.cpp +++ b/Minecraft.World/Spider.cpp @@ -195,7 +195,7 @@ MobGroupData *Spider::finalizeMobSpawn(MobGroupData *groupData, int extraData /* if (level->random->nextInt(100) == 0) #endif { - shared_ptr skeleton = shared_ptr( new Skeleton(level) ); + shared_ptr skeleton = std::make_shared(level); skeleton->moveTo(x, y, z, yRot, 0); skeleton->finalizeMobSpawn(nullptr); level->addEntity(skeleton); diff --git a/Minecraft.World/SpikeFeature.cpp b/Minecraft.World/SpikeFeature.cpp index 629b3c832..912e3aff4 100644 --- a/Minecraft.World/SpikeFeature.cpp +++ b/Minecraft.World/SpikeFeature.cpp @@ -50,7 +50,7 @@ bool SpikeFeature::place(Level *level, Random *random, int x, int y, int z) } else break; } - shared_ptr enderCrystal = shared_ptr(new EnderCrystal(level)); + shared_ptr enderCrystal = std::make_shared(level); enderCrystal->moveTo(x + 0.5f, y + hh, z + 0.5f, random->nextFloat() * 360, 0); level->addEntity(enderCrystal); level->setTileAndData(x, y + hh, z, Tile::unbreakable_Id, 0, Tile::UPDATE_CLIENTS); @@ -168,7 +168,7 @@ bool SpikeFeature::placeWithIndex(Level *level, Random *random, int x, int y, in } } - shared_ptr enderCrystal = shared_ptr(new EnderCrystal(level)); + shared_ptr enderCrystal = std::make_shared(level); enderCrystal->moveTo(x + 0.5f, y + hh, z + 0.5f, random->nextFloat() * 360, 0); level->addEntity(enderCrystal); placeBlock(level, x, y + hh, z, Tile::unbreakable_Id, 0); diff --git a/Minecraft.World/Squid.cpp b/Minecraft.World/Squid.cpp index 4539d5ee9..f1b660ebe 100644 --- a/Minecraft.World/Squid.cpp +++ b/Minecraft.World/Squid.cpp @@ -81,7 +81,7 @@ void Squid::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) int count = random->nextInt(3 + playerBonusLevel) + 1; for (int i = 0; i < count; i++) { - spawnAtLocation(shared_ptr( new ItemInstance(Item::dye_powder, 1, DyePowderItem::BLACK) ), 0.0f); + spawnAtLocation(std::make_shared(Item::dye_powder, 1, DyePowderItem::BLACK), 0.0f); } } diff --git a/Minecraft.World/StemTile.cpp b/Minecraft.World/StemTile.cpp index 445c88e4a..33bb7c795 100644 --- a/Minecraft.World/StemTile.cpp +++ b/Minecraft.World/StemTile.cpp @@ -189,7 +189,7 @@ void StemTile::spawnResources(Level *level, int x, int y, int z, int data, float if (fruit == Tile::melon) seed = Item::seeds_melon; for (int i = 0; i < 3; i++) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(seed))); + popResource(level, x, y, z, std::make_shared(seed)); } } diff --git a/Minecraft.World/StoneMonsterTile.cpp b/Minecraft.World/StoneMonsterTile.cpp index ec31992ff..fd3f1b90e 100644 --- a/Minecraft.World/StoneMonsterTile.cpp +++ b/Minecraft.World/StoneMonsterTile.cpp @@ -48,7 +48,7 @@ void StoneMonsterTile::destroy(Level *level, int x, int y, int z, int data) // Also limit the amount of silverfish specifically if(level->countInstanceOf( eTYPE_SILVERFISH, true) < 15 ) { - shared_ptr silverfish = shared_ptr(new Silverfish(level)); + shared_ptr silverfish = std::make_shared(level); silverfish->moveTo(x + .5, y, z + .5, 0, 0); level->addEntity(silverfish); @@ -106,7 +106,7 @@ shared_ptr StoneMonsterTile::getSilkTouchItemInstance(int data) { tile = Tile::stoneBrick; } - return shared_ptr(new ItemInstance(tile)); + return std::make_shared(tile); } int StoneMonsterTile::cloneTileData(Level *level, int x, int y, int z) diff --git a/Minecraft.World/StoneSlabTile.cpp b/Minecraft.World/StoneSlabTile.cpp index e4de58dab..10f1ee71c 100644 --- a/Minecraft.World/StoneSlabTile.cpp +++ b/Minecraft.World/StoneSlabTile.cpp @@ -80,5 +80,5 @@ int StoneSlabTile::getAuxName(int auxValue) shared_ptr StoneSlabTile::getSilkTouchItemInstance(int data) { - return shared_ptr(new ItemInstance(Tile::stoneSlabHalf_Id, 2, data & TYPE_MASK)); + return std::make_shared(Tile::stoneSlabHalf_Id, 2, data & TYPE_MASK); } diff --git a/Minecraft.World/SynchedEntityData.cpp b/Minecraft.World/SynchedEntityData.cpp index 2c126f562..69d419b0d 100644 --- a/Minecraft.World/SynchedEntityData.cpp +++ b/Minecraft.World/SynchedEntityData.cpp @@ -19,7 +19,7 @@ void SynchedEntityData::define(int id, int value) MemSect(17); checkId(id); int type = TYPE_INT; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -30,7 +30,7 @@ void SynchedEntityData::define(int id, byte value) MemSect(17); checkId(id); int type = TYPE_BYTE; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -41,7 +41,7 @@ void SynchedEntityData::define(int id, short value) MemSect(17); checkId(id); int type = TYPE_SHORT; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -52,7 +52,7 @@ void SynchedEntityData::define(int id, float value) MemSect(17); checkId(id); int type = TYPE_FLOAT; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -63,7 +63,7 @@ void SynchedEntityData::define(int id, const wstring& value) MemSect(17); checkId(id); int type = TYPE_STRING; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -74,7 +74,7 @@ void SynchedEntityData::defineNULL(int id, void *pVal) MemSect(17); checkId(id); int type = TYPE_ITEMINSTANCE; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, shared_ptr()) ); + shared_ptr dataItem = std::make_shared(type, id, shared_ptr()); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -360,34 +360,34 @@ vector > *SynchedEntityData::unpack(Data case TYPE_BYTE: { byte dataRead = input->readByte(); - item = shared_ptr( new DataItem(itemType, itemId, dataRead) ); + item = std::make_shared(itemType, itemId, dataRead); } break; case TYPE_SHORT: { short dataRead = input->readShort(); - item = shared_ptr( new DataItem(itemType, itemId, dataRead) ); + item = std::make_shared(itemType, itemId, dataRead); } break; case TYPE_INT: { int dataRead = input->readInt(); - item = shared_ptr( new DataItem(itemType, itemId, dataRead) ); + item = std::make_shared(itemType, itemId, dataRead); } break; case TYPE_FLOAT: { float dataRead = input->readFloat(); - item = shared_ptr( new DataItem(itemType, itemId, dataRead) ); + item = std::make_shared(itemType, itemId, dataRead); } break; case TYPE_STRING: - item = shared_ptr( new DataItem(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)) ); + item = std::make_shared(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)); break; case TYPE_ITEMINSTANCE: { - item = shared_ptr(new DataItem(itemType, itemId, Packet::readItem(input))); + item = std::make_shared(itemType, itemId, Packet::readItem(input)); } break; default: diff --git a/Minecraft.World/TakeItemEntityPacket.h b/Minecraft.World/TakeItemEntityPacket.h index 7c4b45fe9..7acbfdc46 100644 --- a/Minecraft.World/TakeItemEntityPacket.h +++ b/Minecraft.World/TakeItemEntityPacket.h @@ -17,6 +17,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new TakeItemEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 22; } }; \ No newline at end of file diff --git a/Minecraft.World/TallGrass.cpp b/Minecraft.World/TallGrass.cpp index bf8899103..337e343d2 100644 --- a/Minecraft.World/TallGrass.cpp +++ b/Minecraft.World/TallGrass.cpp @@ -89,7 +89,7 @@ void TallGrass::playerDestroy(Level *level, shared_ptr player, int x, in ); // drop leaf block instead of sapling - popResource(level, x, y, z, shared_ptr(new ItemInstance(Tile::tallgrass, 1, data))); + popResource(level, x, y, z, std::make_shared(Tile::tallgrass, 1, data)); } else { diff --git a/Minecraft.World/TeleportEntityPacket.h b/Minecraft.World/TeleportEntityPacket.h index 6fc28732b..38e09286b 100644 --- a/Minecraft.World/TeleportEntityPacket.h +++ b/Minecraft.World/TeleportEntityPacket.h @@ -22,6 +22,6 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new TeleportEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 34; } }; \ No newline at end of file diff --git a/Minecraft.World/TextureAndGeometryChangePacket.h b/Minecraft.World/TextureAndGeometryChangePacket.h index dabe78fae..812222fc1 100644 --- a/Minecraft.World/TextureAndGeometryChangePacket.h +++ b/Minecraft.World/TextureAndGeometryChangePacket.h @@ -20,6 +20,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new TextureAndGeometryChangePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 161; } }; \ No newline at end of file diff --git a/Minecraft.World/TextureChangePacket.h b/Minecraft.World/TextureChangePacket.h index 959fc4feb..81f45f4ce 100644 --- a/Minecraft.World/TextureChangePacket.h +++ b/Minecraft.World/TextureChangePacket.h @@ -25,6 +25,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new TextureChangePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 157; } }; \ No newline at end of file diff --git a/Minecraft.World/TheEndBiomeDecorator.cpp b/Minecraft.World/TheEndBiomeDecorator.cpp index 0ab1f7669..2b80bcfca 100644 --- a/Minecraft.World/TheEndBiomeDecorator.cpp +++ b/Minecraft.World/TheEndBiomeDecorator.cpp @@ -58,7 +58,7 @@ void TheEndBiomeDecorator::decorate() } if (xo == 0 && zo == 0) { - shared_ptr enderDragon = shared_ptr(new EnderDragon(level)); + shared_ptr enderDragon = std::make_shared(level); enderDragon->AddParts(); // 4J added enderDragon->moveTo(0, 128, 0, random->nextFloat() * 360, 0); level->addEntity(enderDragon); diff --git a/Minecraft.World/TheEndPortal.cpp b/Minecraft.World/TheEndPortal.cpp index 0298ca48b..c3e5cbf56 100644 --- a/Minecraft.World/TheEndPortal.cpp +++ b/Minecraft.World/TheEndPortal.cpp @@ -28,7 +28,7 @@ TheEndPortal::TheEndPortal(int id, Material *material) : BaseEntityTile(id, mate shared_ptr TheEndPortal::newTileEntity(Level *level) { - return shared_ptr(new TheEndPortalTileEntity()); + return std::make_shared(); } void TheEndPortal::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr forceEntity) // 4J added forceData, forceEntity param diff --git a/Minecraft.World/TheEndPortalTileEntity.cpp b/Minecraft.World/TheEndPortalTileEntity.cpp index fa9b35447..63c0af56a 100644 --- a/Minecraft.World/TheEndPortalTileEntity.cpp +++ b/Minecraft.World/TheEndPortalTileEntity.cpp @@ -4,7 +4,7 @@ // 4J Added shared_ptr TheEndPortalTileEntity::clone() { - shared_ptr result = shared_ptr( new TheEndPortalTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); return result; } \ No newline at end of file diff --git a/Minecraft.World/ThinFenceTile.cpp b/Minecraft.World/ThinFenceTile.cpp index cbfdd2fe0..65638ef6e 100644 --- a/Minecraft.World/ThinFenceTile.cpp +++ b/Minecraft.World/ThinFenceTile.cpp @@ -144,7 +144,7 @@ bool ThinFenceTile::isSilkTouchable() shared_ptr ThinFenceTile::getSilkTouchItemInstance(int data) { - return shared_ptr(new ItemInstance(id, 1, data)); + return std::make_shared(id, 1, data); } void ThinFenceTile::registerIcons(IconRegister *iconRegister) diff --git a/Minecraft.World/ThrownEgg.cpp b/Minecraft.World/ThrownEgg.cpp index 7bf85d71b..9bdfae106 100644 --- a/Minecraft.World/ThrownEgg.cpp +++ b/Minecraft.World/ThrownEgg.cpp @@ -47,7 +47,7 @@ void ThrownEgg::onHit(HitResult *res) if (random->nextInt(32) == 0) count = 4; for (int i = 0; i < count; i++) { - shared_ptr chicken = shared_ptr( new Chicken(level) ); + shared_ptr chicken = std::make_shared(level); chicken->setAge(-20 * 60 * 20); chicken->moveTo(x, y, z, yRot, 0); diff --git a/Minecraft.World/ThrownExpBottle.cpp b/Minecraft.World/ThrownExpBottle.cpp index c700bdc56..acab0d055 100644 --- a/Minecraft.World/ThrownExpBottle.cpp +++ b/Minecraft.World/ThrownExpBottle.cpp @@ -47,7 +47,7 @@ void ThrownExpBottle::onHit(HitResult *res) { int newCount = ExperienceOrb::getExperienceValue(xpCount); xpCount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x, y, z, newCount) ) ); + level->addEntity(std::make_shared(level, x, y, z, newCount)); } remove(); diff --git a/Minecraft.World/ThrownPotion.cpp b/Minecraft.World/ThrownPotion.cpp index 6e0618582..170f64745 100644 --- a/Minecraft.World/ThrownPotion.cpp +++ b/Minecraft.World/ThrownPotion.cpp @@ -31,7 +31,7 @@ ThrownPotion::ThrownPotion(Level *level, shared_ptr mob, int potio { _init(); - potionItem = shared_ptr( new ItemInstance(Item::potion, 1, potionValue)); + potionItem = std::make_shared(Item::potion, 1, potionValue); } ThrownPotion::ThrownPotion(Level *level, shared_ptr mob, shared_ptr potion) : Throwable(level, mob) @@ -45,7 +45,7 @@ ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, int potio { _init(); - potionItem = shared_ptr( new ItemInstance(Item::potion, 1, potionValue)); + potionItem = std::make_shared(Item::potion, 1, potionValue); } ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, shared_ptr potion) : Throwable(level, x, y, z) @@ -72,13 +72,13 @@ float ThrownPotion::getThrowUpAngleOffset() void ThrownPotion::setPotionValue(int potionValue) { - if (potionItem == nullptr) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); + if (potionItem == nullptr) potionItem = std::make_shared(Item::potion, 1, 0); potionItem->setAuxValue(potionValue); } int ThrownPotion::getPotionValue() { - if (potionItem == nullptr) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); + if (potionItem == nullptr) potionItem = std::make_shared(Item::potion, 1, 0); return potionItem->getAuxValue(); } diff --git a/Minecraft.World/Tile.cpp b/Minecraft.World/Tile.cpp index 7ab09928f..6abd69ce3 100644 --- a/Minecraft.World/Tile.cpp +++ b/Minecraft.World/Tile.cpp @@ -917,7 +917,7 @@ void Tile::spawnResources(Level *level, int x, int y, int z, int data, float odd int type = getResource(data, level->random, playerBonusLevel); if (type <= 0) continue; - popResource(level, x, y, z, shared_ptr( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) ); + popResource(level, x, y, z, std::make_shared(type, 1, getSpawnResourcesAuxValue(data))); } } @@ -929,7 +929,7 @@ void Tile::popResource(Level *level, int x, int y, int z, shared_ptrrandom->nextFloat() * s + (1 - s) * 0.5; double yo = level->random->nextFloat() * s + (1 - s) * 0.5; double zo = level->random->nextFloat() * s + (1 - s) * 0.5; - shared_ptr item = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) ); + shared_ptr item = std::make_shared(level, x + xo, y + yo, z + zo, itemInstance); item->throwTime = 10; level->addEntity(item); } @@ -943,7 +943,7 @@ void Tile::popExperience(Level *level, int x, int y, int z, int amount) { int newCount = ExperienceOrb::getExperienceValue(amount); amount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount))); + level->addEntity(std::make_shared(level, x + .5, y + .5, z + .5, newCount)); } } } @@ -1257,7 +1257,7 @@ shared_ptr Tile::getSilkTouchItemInstance(int data) { popData = data; } - return shared_ptr(new ItemInstance(id, 1, popData)); + return std::make_shared(id, 1, popData); } int Tile::getResourceCountForLootBonus(int bonusLevel, Random *random) diff --git a/Minecraft.World/TileDestructionPacket.h b/Minecraft.World/TileDestructionPacket.h index 20cd7db99..765093490 100644 --- a/Minecraft.World/TileDestructionPacket.h +++ b/Minecraft.World/TileDestructionPacket.h @@ -30,6 +30,6 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new TileDestructionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 55; } }; \ No newline at end of file diff --git a/Minecraft.World/TileEditorOpenPacket.h b/Minecraft.World/TileEditorOpenPacket.h index 20a731bb9..ee68a6cf0 100644 --- a/Minecraft.World/TileEditorOpenPacket.h +++ b/Minecraft.World/TileEditorOpenPacket.h @@ -20,6 +20,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new TileEditorOpenPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 133; } }; \ No newline at end of file diff --git a/Minecraft.World/TileEntityDataPacket.h b/Minecraft.World/TileEntityDataPacket.h index 2ee998f39..6fe3bf899 100644 --- a/Minecraft.World/TileEntityDataPacket.h +++ b/Minecraft.World/TileEntityDataPacket.h @@ -31,6 +31,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new TileEntityDataPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 132; } }; \ No newline at end of file diff --git a/Minecraft.World/TileEventPacket.h b/Minecraft.World/TileEventPacket.h index ca2685fae..f587b1fff 100644 --- a/Minecraft.World/TileEventPacket.h +++ b/Minecraft.World/TileEventPacket.h @@ -17,6 +17,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new TileEventPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 54; } }; \ No newline at end of file diff --git a/Minecraft.World/TileUpdatePacket.h b/Minecraft.World/TileUpdatePacket.h index fe69c7639..c9bb93ce2 100644 --- a/Minecraft.World/TileUpdatePacket.h +++ b/Minecraft.World/TileUpdatePacket.h @@ -18,6 +18,6 @@ public: virtual void handle(PacketListener *listener); virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new TileUpdatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 53; } }; \ No newline at end of file diff --git a/Minecraft.World/TimeCommand.cpp b/Minecraft.World/TimeCommand.cpp index 4ac23c947..05147983f 100644 --- a/Minecraft.World/TimeCommand.cpp +++ b/Minecraft.World/TimeCommand.cpp @@ -81,5 +81,5 @@ shared_ptr TimeCommand::preparePacket(bool night) dos.writeBoolean(night); - return shared_ptr( new GameCommandPacket(eGameCommand_Time, baos.toByteArray() )); + return std::make_shared(eGameCommand_Time, baos.toByteArray()); } \ No newline at end of file diff --git a/Minecraft.World/TntTile.cpp b/Minecraft.World/TntTile.cpp index 1b16a3752..eff9efae6 100644 --- a/Minecraft.World/TntTile.cpp +++ b/Minecraft.World/TntTile.cpp @@ -57,7 +57,7 @@ void TntTile::wasExploded(Level *level, int x, int y, int z, Explosion *explosio // 4J-JEV: Fix for #90934 - Customer Encountered: TU11: Content: Gameplay: TNT blocks are triggered by explosions even though "TNT explodes" option is unchecked. if( level->newPrimedTntAllowed() && app.GetGameHostOption(eGameHostOption_TNT) ) { - shared_ptr primed = shared_ptr( new PrimedTnt(level, x + 0.5f, y + 0.5f, z + 0.5f, explosion->getSourceMob()) ); + shared_ptr primed = std::make_shared(level, x + 0.5f, y + 0.5f, z + 0.5f, explosion->getSourceMob()); primed->life = level->random->nextInt(primed->life / 4) + primed->life / 8; level->addEntity(primed); } @@ -77,7 +77,7 @@ void TntTile::destroy(Level *level, int x, int y, int z, int data, shared_ptr
  • newPrimedTntAllowed() && app.GetGameHostOption(eGameHostOption_TNT) ) { - shared_ptr tnt = shared_ptr( new PrimedTnt(level, x + 0.5f, y + 0.5f, z + 0.5f, source) ); + shared_ptr tnt = std::make_shared(level, x + 0.5f, y + 0.5f, z + 0.5f, source); level->addEntity(tnt); level->playEntitySound(tnt, eSoundType_RANDOM_FUSE, 1, 1.0f); } diff --git a/Minecraft.World/ToggleDownfallCommand.cpp b/Minecraft.World/ToggleDownfallCommand.cpp index 1d0a4d9eb..526be3534 100644 --- a/Minecraft.World/ToggleDownfallCommand.cpp +++ b/Minecraft.World/ToggleDownfallCommand.cpp @@ -31,5 +31,5 @@ void ToggleDownfallCommand::doToggleDownfall() shared_ptr ToggleDownfallCommand::preparePacket() { - return shared_ptr( new GameCommandPacket(eGameCommand_ToggleDownfall, byteArray() )); + return std::make_shared(eGameCommand_ToggleDownfall, byteArray()); } \ No newline at end of file diff --git a/Minecraft.World/TopSnowTile.cpp b/Minecraft.World/TopSnowTile.cpp index d165500cf..7719f8388 100644 --- a/Minecraft.World/TopSnowTile.cpp +++ b/Minecraft.World/TopSnowTile.cpp @@ -100,7 +100,7 @@ void TopSnowTile::playerDestroy(Level *level, shared_ptr player, int x, { int type = Item::snowBall->id; int height = data & HEIGHT_MASK; - popResource(level, x, y, z, shared_ptr( new ItemInstance(type, height + 1, 0))); + popResource(level, x, y, z, std::make_shared(type, height + 1, 0)); level->removeTile(x, y, z); } diff --git a/Minecraft.World/TradeItemPacket.h b/Minecraft.World/TradeItemPacket.h index ecd0f7070..6a23ce7aa 100644 --- a/Minecraft.World/TradeItemPacket.h +++ b/Minecraft.World/TradeItemPacket.h @@ -25,7 +25,7 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new TradeItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 151; } }; diff --git a/Minecraft.World/TreeTile.cpp b/Minecraft.World/TreeTile.cpp index 642d8fbba..6a5860f3a 100644 --- a/Minecraft.World/TreeTile.cpp +++ b/Minecraft.World/TreeTile.cpp @@ -81,7 +81,7 @@ int TreeTile::getWoodType(int data) shared_ptr TreeTile::getSilkTouchItemInstance(int data) { // fix to avoid getting silktouched sideways logs - return shared_ptr(new ItemInstance(id, 1, getWoodType(data))); + return std::make_shared(id, 1, getWoodType(data)); } void TreeTile::registerIcons(IconRegister *iconRegister) diff --git a/Minecraft.World/UpdateAttributesPacket.h b/Minecraft.World/UpdateAttributesPacket.h index 77ba08be5..4f604e0db 100644 --- a/Minecraft.World/UpdateAttributesPacket.h +++ b/Minecraft.World/UpdateAttributesPacket.h @@ -41,6 +41,6 @@ public: unordered_set getValues(); public: - static shared_ptr create() { return shared_ptr(new UpdateAttributesPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 44; } }; \ No newline at end of file diff --git a/Minecraft.World/UpdateGameRuleProgressPacket.cpp b/Minecraft.World/UpdateGameRuleProgressPacket.cpp index 6f6530d4f..d88560114 100644 --- a/Minecraft.World/UpdateGameRuleProgressPacket.cpp +++ b/Minecraft.World/UpdateGameRuleProgressPacket.cpp @@ -5,13 +5,9 @@ -UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket() +// UpdateGameRuleProgressPacket() default constructor +UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket() : m_icon(0), m_auxValue(0), m_dataTag(0) { - m_messageId = L""; - m_icon = -1; - m_auxValue = 0; - m_definitionType = ConsoleGameRules::eGameRuleType_LevelRules; - m_dataTag = 0; } UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket(ConsoleGameRules::EGameRuleType definitionType, const wstring &messageId, int icon, int auxValue, int dataTag, void *data, int dataLength) diff --git a/Minecraft.World/UpdateMobEffectPacket.h b/Minecraft.World/UpdateMobEffectPacket.h index 39eb98e9b..48462550c 100644 --- a/Minecraft.World/UpdateMobEffectPacket.h +++ b/Minecraft.World/UpdateMobEffectPacket.h @@ -24,6 +24,6 @@ public: virtual bool isInvalidatedBy(shared_ptr packet); public: - static shared_ptr create() { return shared_ptr(new UpdateMobEffectPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 41; } }; \ No newline at end of file diff --git a/Minecraft.World/UpdateProgressPacket.h b/Minecraft.World/UpdateProgressPacket.h index beca65097..1643fb63c 100644 --- a/Minecraft.World/UpdateProgressPacket.h +++ b/Minecraft.World/UpdateProgressPacket.h @@ -20,6 +20,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new UpdateProgressPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 156; } }; \ No newline at end of file diff --git a/Minecraft.World/UseItemPacket.h b/Minecraft.World/UseItemPacket.h index 44e20457c..ce4635ba0 100644 --- a/Minecraft.World/UseItemPacket.h +++ b/Minecraft.World/UseItemPacket.h @@ -31,6 +31,6 @@ public: float getClickZ(); public: - static shared_ptr create() { return shared_ptr(new UseItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 15; } }; diff --git a/Minecraft.World/Village.cpp b/Minecraft.World/Village.cpp index 705815b95..b7c82fa4f 100644 --- a/Minecraft.World/Village.cpp +++ b/Minecraft.World/Village.cpp @@ -71,7 +71,7 @@ void Village::tick(int tick) Vec3 *spawnPos = findRandomSpawnPos(center->x, center->y, center->z, 2, 4, 2); if (spawnPos != nullptr) { - shared_ptr vg = shared_ptr( new VillagerGolem(level) ); + shared_ptr vg = std::make_shared(level); vg->setPos(spawnPos->x, spawnPos->y, spawnPos->z); level->addEntity(vg); ++golemCount; @@ -422,7 +422,7 @@ void Village::readAdditionalSaveData(CompoundTag *tag) { CompoundTag *dTag = doorTags->get(i); - shared_ptr door = shared_ptr(new DoorInfo(dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"), dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS"))); + shared_ptr door = std::make_shared(dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"), dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS")); doorInfos.push_back(door); } diff --git a/Minecraft.World/VillagePieces.cpp b/Minecraft.World/VillagePieces.cpp index fbdf05a7e..dcd765e01 100644 --- a/Minecraft.World/VillagePieces.cpp +++ b/Minecraft.World/VillagePieces.cpp @@ -391,7 +391,7 @@ void VillagePieces::VillagePiece::spawnVillagers(Level *level, BoundingBox *chun { spawnedVillagerCount++; - shared_ptr villager = shared_ptr(new Villager(level, getVillagerProfession(i))); + shared_ptr villager = std::make_shared(level, getVillagerProfession(i)); villager->moveTo(worldX + 0.5, worldY, worldZ + 0.5, 0, 0); level->addEntity(villager); } diff --git a/Minecraft.World/VillageSiege.cpp b/Minecraft.World/VillageSiege.cpp index 525b0b36d..5a39b6ebe 100644 --- a/Minecraft.World/VillageSiege.cpp +++ b/Minecraft.World/VillageSiege.cpp @@ -130,7 +130,7 @@ bool VillageSiege::trySpawn() if (spawnPos == nullptr) return false; shared_ptr mob; { - mob = shared_ptr( new Zombie(level) ); + mob = std::make_shared(level); mob->finalizeMobSpawn(nullptr); mob->setVillager(false); } diff --git a/Minecraft.World/Villager.cpp b/Minecraft.World/Villager.cpp index 26f5e5740..7179f57d7 100644 --- a/Minecraft.World/Villager.cpp +++ b/Minecraft.World/Villager.cpp @@ -420,7 +420,7 @@ void Villager::addOffers(int addCount) addItemForPurchase(newOffers, Item::arrow_Id, random, getRecipeChance(.5f)); if (random->nextFloat() < getRecipeChance(.5f)) { - newOffers->push_back(new MerchantRecipe(shared_ptr( new ItemInstance(Tile::gravel, 10) ), shared_ptr( new ItemInstance(Item::emerald) ), shared_ptr( new ItemInstance(Item::flint_Id, 4 + random->nextInt(2), 0)))); + newOffers->push_back(new MerchantRecipe(std::make_shared(Tile::gravel, 10), std::make_shared(Item::emerald), std::make_shared(Item::flint_Id, 4 + random->nextInt(2), 0))); } break; case PROFESSION_BUTCHER: @@ -480,7 +480,7 @@ void Villager::addOffers(int addCount) shared_ptr book = Item::enchantedBook->createForEnchantment(new EnchantmentInstance(enchantment, level)); int cost = 2 + random->nextInt(5 + (level * 10)) + 3 * level; - newOffers->push_back(new MerchantRecipe(shared_ptr(new ItemInstance(Item::book)), shared_ptr(new ItemInstance(Item::emerald, cost)), book)); + newOffers->push_back(new MerchantRecipe(std::make_shared(Item::book), std::make_shared(Item::emerald, cost), book)); } break; case PROFESSION_PRIEST: @@ -498,9 +498,9 @@ void Villager::addOffers(int addCount) int id = enchantItems[i]; if (random->nextFloat() < getRecipeChance(.05f)) { - newOffers->push_back(new MerchantRecipe(shared_ptr(new ItemInstance(id, 1, 0)), - shared_ptr(new ItemInstance(Item::emerald, 2 + random->nextInt(3), 0)), - EnchantmentHelper::enchantItem(random, shared_ptr(new ItemInstance(id, 1, 0)), 5 + random->nextInt(15)))); + newOffers->push_back(new MerchantRecipe(std::make_shared(id, 1, 0), + std::make_shared(Item::emerald, 2 + random->nextInt(3), 0), + EnchantmentHelper::enchantItem(random, std::make_shared(id, 1, 0), 5 + random->nextInt(15)))); } } } @@ -622,7 +622,7 @@ void Villager::addItemForTradeIn(MerchantRecipeList *list, int itemId, Random *r shared_ptr Villager::getItemTradeInValue(int itemId, Random *random) { - return shared_ptr(new ItemInstance(itemId, getTradeInValue(itemId, random), 0)); + return std::make_shared(itemId, getTradeInValue(itemId, random), 0); } int Villager::getTradeInValue(int itemId, Random *random) @@ -658,13 +658,13 @@ void Villager::addItemForPurchase(MerchantRecipeList *list, int itemId, Random * shared_ptr resultItem; if (purchaseCost < 0) { - rubyItem = shared_ptr( new ItemInstance(Item::emerald_Id, 1, 0) ); - resultItem = shared_ptr( new ItemInstance(itemId, -purchaseCost, 0) ); + rubyItem = std::make_shared(Item::emerald_Id, 1, 0); + resultItem = std::make_shared(itemId, -purchaseCost, 0); } else { - rubyItem = shared_ptr( new ItemInstance(Item::emerald_Id, purchaseCost, 0) ); - resultItem = shared_ptr( new ItemInstance(itemId, 1, 0) ); + rubyItem = std::make_shared(Item::emerald_Id, purchaseCost, 0); + resultItem = std::make_shared(itemId, 1, 0); } list->push_back(new MerchantRecipe(rubyItem, resultItem)); } @@ -735,7 +735,7 @@ shared_ptr Villager::getBreedOffspring(shared_ptr target) // 4J - added limit to villagers that can be bred if(level->canCreateMore(GetType(), Level::eSpawnType_Breed) ) { - shared_ptr villager = shared_ptr(new Villager(level)); + shared_ptr villager = std::make_shared(level); villager->finalizeMobSpawn(nullptr); return villager; } diff --git a/Minecraft.World/Villages.cpp b/Minecraft.World/Villages.cpp index d73d568d5..432a8b6b9 100644 --- a/Minecraft.World/Villages.cpp +++ b/Minecraft.World/Villages.cpp @@ -127,7 +127,7 @@ void Villages::cluster() if (found) continue; // create new Village - shared_ptr village = shared_ptr(new Village(level)); + shared_ptr village = std::make_shared(level); village->addDoorInfo(di); villages.push_back(village); setDirty(); @@ -181,7 +181,7 @@ void Villages::createDoorInfo(int x, int y, int z) if (level->canSeeSky(x + i, y, z)) canSeeX--; for (int i = 1; i <= 5; ++i) if (level->canSeeSky(x + i, y, z)) canSeeX++; - if (canSeeX != 0) unclustered.push_back(shared_ptr(new DoorInfo(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick))); + if (canSeeX != 0) unclustered.push_back(std::make_shared(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick)); } else { @@ -190,7 +190,7 @@ void Villages::createDoorInfo(int x, int y, int z) if (level->canSeeSky(x, y, z + i)) canSeeZ--; for (int i = 1; i <= 5; ++i) if (level->canSeeSky(x, y, z + i)) canSeeZ++; - if (canSeeZ != 0) unclustered.push_back(shared_ptr(new DoorInfo(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick))); + if (canSeeZ != 0) unclustered.push_back(std::make_shared(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick)); } } @@ -218,7 +218,7 @@ void Villages::load(CompoundTag *tag) for (int i = 0; i < villageTags->size(); i++) { CompoundTag *compoundTag = villageTags->get(i); - shared_ptr village = shared_ptr(new Village()); + shared_ptr village = std::make_shared(); village->readAdditionalSaveData(compoundTag); villages.push_back(village); } diff --git a/Minecraft.World/VineTile.cpp b/Minecraft.World/VineTile.cpp index 2403c69aa..8f16a9214 100644 --- a/Minecraft.World/VineTile.cpp +++ b/Minecraft.World/VineTile.cpp @@ -379,7 +379,7 @@ void VineTile::playerDestroy(Level *level, shared_ptrplayer, int x, int ); // drop leaf block instead of sapling - popResource(level, x, y, z, shared_ptr(new ItemInstance(Tile::vine, 1, 0))); + popResource(level, x, y, z, std::make_shared(Tile::vine, 1, 0)); } else { diff --git a/Minecraft.World/WeighedTreasure.cpp b/Minecraft.World/WeighedTreasure.cpp index 37b04fffc..3c20ae666 100644 --- a/Minecraft.World/WeighedTreasure.cpp +++ b/Minecraft.World/WeighedTreasure.cpp @@ -6,7 +6,7 @@ WeighedTreasure::WeighedTreasure(int itemId, int auxValue, int minCount, int maxCount, int weight) : WeighedRandomItem(weight) { - this->item = shared_ptr( new ItemInstance(itemId, 1, auxValue) ); + this->item = std::make_shared(itemId, 1, auxValue); this->minCount = minCount; this->maxCount = maxCount; } diff --git a/Minecraft.World/Witch.cpp b/Minecraft.World/Witch.cpp index 6f8f4941f..375c83886 100644 --- a/Minecraft.World/Witch.cpp +++ b/Minecraft.World/Witch.cpp @@ -135,7 +135,7 @@ void Witch::aiStep() if (potion > -1) { - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::potion, 1, potion)) ); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::potion, 1, potion)); usingTime = getCarriedItem()->getUseDuration(); setUsingItem(true); AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); @@ -198,7 +198,7 @@ void Witch::performRangedAttack(shared_ptr target, float power) { if (isUsingItem()) return; - shared_ptr potion = shared_ptr( new ThrownPotion(level, dynamic_pointer_cast(shared_from_this()), PotionBrewing::POTION_ID_SPLASH_DAMAGE) ); + shared_ptr potion = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), PotionBrewing::POTION_ID_SPLASH_DAMAGE); potion->xRot -= -20; double xd = (target->x + target->xd) - x; double yd = (target->y + target->getHeadHeight() - 1.1f) - y; diff --git a/Minecraft.World/WitherBoss.cpp b/Minecraft.World/WitherBoss.cpp index ceb64df2f..af406a93a 100644 --- a/Minecraft.World/WitherBoss.cpp +++ b/Minecraft.World/WitherBoss.cpp @@ -437,7 +437,7 @@ void WitherBoss::performRangedAttack(int head, double tx, double ty, double tz, double yd = ty - hy; double zd = tz - hz; - shared_ptr ie = shared_ptr( new WitherSkull(level, dynamic_pointer_cast(shared_from_this()), xd, yd, zd) ); + shared_ptr ie = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), xd, yd, zd); if (dangerous) ie->setDangerous(true); ie->y = hy; ie->x = hx; diff --git a/Minecraft.World/Wolf.cpp b/Minecraft.World/Wolf.cpp index 55088ffd0..7588a67b0 100644 --- a/Minecraft.World/Wolf.cpp +++ b/Minecraft.World/Wolf.cpp @@ -517,7 +517,7 @@ shared_ptr Wolf::getBreedOffspring(shared_ptr target) // 4J - added limit to wolves that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - shared_ptr pBabyWolf = shared_ptr( new Wolf(level) ); + shared_ptr pBabyWolf = std::make_shared(level); if(!getOwnerUUID().empty()) { diff --git a/Minecraft.World/WoodSlabTile.cpp b/Minecraft.World/WoodSlabTile.cpp index ba3a98e50..574dab932 100644 --- a/Minecraft.World/WoodSlabTile.cpp +++ b/Minecraft.World/WoodSlabTile.cpp @@ -33,7 +33,7 @@ int WoodSlabTile::getResource(int data, Random *random, int playerBonusLevel) shared_ptr WoodSlabTile::getSilkTouchItemInstance(int data) { - return shared_ptr(new ItemInstance(Tile::woodSlabHalf, 2, data & TYPE_MASK)); + return std::make_shared(Tile::woodSlabHalf, 2, data & TYPE_MASK); } int WoodSlabTile::getAuxName(int auxValue) diff --git a/Minecraft.World/XZPacket.h b/Minecraft.World/XZPacket.h index 0c4115e07..41b6c30d0 100644 --- a/Minecraft.World/XZPacket.h +++ b/Minecraft.World/XZPacket.h @@ -25,6 +25,6 @@ public: virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new XZPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 166; } }; \ No newline at end of file diff --git a/Minecraft.World/Zombie.cpp b/Minecraft.World/Zombie.cpp index aba3fb2ab..76e129639 100644 --- a/Minecraft.World/Zombie.cpp +++ b/Minecraft.World/Zombie.cpp @@ -162,7 +162,7 @@ bool Zombie::hurt(DamageSource *source, float dmg) int x = Mth::floor(this->x); int y = Mth::floor(this->y); int z = Mth::floor(this->z); - shared_ptr reinforcement = shared_ptr( new Zombie(level) ); + shared_ptr reinforcement = std::make_shared(level); for (int i = 0; i < REINFORCEMENT_ATTEMPTS; i++) { @@ -281,11 +281,11 @@ void Zombie::populateDefaultEquipmentSlots() int rand = random->nextInt(3); if (rand == 0) { - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::sword_iron)) ); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::sword_iron)); } else { - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::shovel_iron)) ); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::shovel_iron)); } } } @@ -316,7 +316,7 @@ void Zombie::killed(shared_ptr mob) { if (level->difficulty == Difficulty::NORMAL && random->nextBoolean()) return; - shared_ptr zombie = shared_ptr(new Zombie(level)); + shared_ptr zombie = std::make_shared(level); zombie->copyPosition(mob); level->removeEntity(mob); zombie->finalizeMobSpawn(nullptr); @@ -366,7 +366,7 @@ MobGroupData *Zombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /* { // Halloween! OooOOo! 25% of all skeletons/zombies can wear // pumpkins on their heads. - setEquippedSlot(SLOT_HELM, shared_ptr( new ItemInstance(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin) )); + setEquippedSlot(SLOT_HELM, std::make_shared(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin)); dropChances[SLOT_HELM] = 0; } } @@ -446,7 +446,7 @@ bool Zombie::isConverting() void Zombie::finishConversion() { - shared_ptr villager = shared_ptr(new Villager(level)); + shared_ptr villager = std::make_shared(level); villager->copyPosition(shared_from_this()); villager->finalizeMobSpawn(nullptr); villager->setRewardPlayersInVillage(); diff --git a/Minecraft.World/ZoomLayer.cpp b/Minecraft.World/ZoomLayer.cpp index bef24709c..f14837dce 100644 --- a/Minecraft.World/ZoomLayer.cpp +++ b/Minecraft.World/ZoomLayer.cpp @@ -86,7 +86,7 @@ shared_ptrZoomLayer::zoom(__int64 seed, shared_ptr sup, int count) shared_ptrresult = sup; for (int i = 0; i < count; i++) { - result = shared_ptr(new ZoomLayer(seed + i, result)); + result = std::make_shared(seed + i, result); } return result; } \ No newline at end of file