summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-09-08 15:39:40 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-09-08 15:39:40 +0200
commit9ab5627a393a0b178f13fbba2c39463cfe0675b8 (patch)
tree1f89501893f02a6e711e5a31868a8acdb4ca7de5 /src
parentd (diff)
parentShutdown connection when disconnect packet sent (#3999) (diff)
downloadcuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.gz
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.bz2
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.lz
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.xz
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.zst
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.zip
Diffstat (limited to '')
-rw-r--r--src/BlockEntities/DispenserEntity.cpp4
-rw-r--r--src/BlockInfo.cpp69
-rw-r--r--src/BlockInfo.h10
-rw-r--r--src/ChunkMap.cpp2
-rw-r--r--src/ClientHandle.cpp14
-rw-r--r--src/ClientHandle.h10
-rw-r--r--src/Entities/ArrowEntity.cpp6
-rw-r--r--src/Entities/ArrowEntity.h4
-rw-r--r--src/Entities/Boat.cpp4
-rw-r--r--src/Entities/Boat.h2
-rw-r--r--src/Entities/Entity.cpp31
-rw-r--r--src/Entities/Entity.h9
-rw-r--r--src/Entities/ExpBottleEntity.cpp18
-rw-r--r--src/Entities/ExpBottleEntity.h10
-rw-r--r--src/Entities/FireChargeEntity.cpp4
-rw-r--r--src/Entities/FireChargeEntity.h4
-rw-r--r--src/Entities/GhastFireballEntity.cpp4
-rw-r--r--src/Entities/GhastFireballEntity.h4
-rw-r--r--src/Entities/Player.cpp22
-rw-r--r--src/Entities/Player.h18
-rw-r--r--src/Entities/ProjectileEntity.cpp4
-rw-r--r--src/Entities/ProjectileEntity.h4
-rw-r--r--src/Entities/SplashPotionEntity.cpp10
-rw-r--r--src/Entities/SplashPotionEntity.h11
-rw-r--r--src/Entities/TNTEntity.cpp14
-rw-r--r--src/Entities/TNTEntity.h3
-rw-r--r--src/Entities/ThrownEggEntity.cpp6
-rw-r--r--src/Entities/ThrownEggEntity.h6
-rw-r--r--src/Entities/ThrownEnderPearlEntity.cpp6
-rw-r--r--src/Entities/ThrownEnderPearlEntity.h6
-rw-r--r--src/Entities/ThrownSnowballEntity.cpp4
-rw-r--r--src/Entities/ThrownSnowballEntity.h4
-rw-r--r--src/Entities/WitherSkullEntity.cpp4
-rw-r--r--src/Entities/WitherSkullEntity.h4
-rw-r--r--src/Items/ItemBoat.h2
-rw-r--r--src/Items/ItemLighter.h2
-rw-r--r--src/LightingThread.cpp3
-rw-r--r--src/MapManager.cpp8
-rw-r--r--src/Protocol/CMakeLists.txt1
-rw-r--r--src/Protocol/PacketID.cpp182
-rw-r--r--src/Protocol/Protocol.h75
-rw-r--r--src/Protocol/ProtocolRecognizer.h7
-rw-r--r--src/Protocol/Protocol_1_10.cpp2
-rw-r--r--src/Protocol/Protocol_1_11.cpp8
-rw-r--r--src/Protocol/Protocol_1_12.cpp1111
-rw-r--r--src/Protocol/Protocol_1_12.h73
-rw-r--r--src/Protocol/Protocol_1_8.h7
-rw-r--r--src/Protocol/Protocol_1_9.cpp261
-rw-r--r--src/Protocol/Protocol_1_9.h12
-rw-r--r--src/Root.cpp48
-rw-r--r--src/Root.h3
-rw-r--r--src/Simulator/FireSimulator.cpp12
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h10
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h10
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h10
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/PistonHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/PoweredRailHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneBlockHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h10
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneLampHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneRepeaterHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneTorchHandler.h10
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h10
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/SolidBlockHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h10
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h8
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/TripwireHookHandler.h8
-rw-r--r--src/World.cpp70
-rw-r--r--src/World.h40
-rw-r--r--src/WorldStorage/StatSerializer.cpp11
-rw-r--r--src/WorldStorage/StatSerializer.h3
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp10
77 files changed, 815 insertions, 1645 deletions
diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp
index 66311a518..cf2b2f71b 100644
--- a/src/BlockEntities/DispenserEntity.cpp
+++ b/src/BlockEntities/DispenserEntity.cpp
@@ -131,7 +131,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
{
double TNTX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
double TNTZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
- m_World->SpawnPrimedTNT(TNTX, DispY + 0.5, TNTZ, 80, 0); // 80 ticks fuse, no initial velocity
+ m_World->SpawnPrimedTNT({TNTX, DispY + 0.5, TNTZ}, 80, 0); // 80 ticks fuse, no initial velocity
m_Contents.ChangeSlotCount(a_SlotNum, -1);
}
break;
@@ -250,7 +250,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
SpawnPos += GetShootVector(Meta) * 0.8; // A boat is bigger than one block. Add the shoot vector to put it outside the dispenser.
SpawnPos += Vector3d(0.5, 0.5, 0.5);
- if (m_World->SpawnBoat(SpawnPos.x, SpawnPos.y, SpawnPos.z, cBoat::ItemToMaterial(SlotItem)))
+ if (m_World->SpawnBoat(SpawnPos, cBoat::ItemToMaterial(SlotItem)))
{
m_Contents.ChangeSlotCount(a_SlotNum, -1);
}
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index a6178ec55..3021c5efe 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -100,7 +100,6 @@ cBlockInfo::cBlockInfoArray::cBlockInfoArray()
Info[E_BLOCK_HEAD ].m_SpreadLightFalloff = 1;
Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
Info[E_BLOCK_HOPPER ].m_SpreadLightFalloff = 1;
- Info[E_BLOCK_ICE ].m_SpreadLightFalloff = 1;
Info[E_BLOCK_INACTIVE_COMPARATOR ].m_SpreadLightFalloff = 1;
Info[E_BLOCK_INVERTED_DAYLIGHT_SENSOR ].m_SpreadLightFalloff = 1;
Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1;
@@ -161,17 +160,42 @@ cBlockInfo::cBlockInfoArray::cBlockInfoArray()
Info[E_BLOCK_WOODEN_PRESSURE_PLATE ].m_SpreadLightFalloff = 1;
Info[E_BLOCK_WOODEN_SLAB ].m_SpreadLightFalloff = 1;
- // Light in water and lava dissapears faster:
- Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3;
- Info[E_BLOCK_STATIONARY_LAVA ].m_SpreadLightFalloff = 3;
+ // Light in ice and water dissapears faster:
+ Info[E_BLOCK_ICE ].m_SpreadLightFalloff = 3;
Info[E_BLOCK_STATIONARY_WATER ].m_SpreadLightFalloff = 3;
Info[E_BLOCK_WATER ].m_SpreadLightFalloff = 3;
+ // Light does not pass through these blocks at all:
+ Info[E_BLOCK_ACACIA_WOOD_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_BIRCH_WOOD_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_BRICK_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_COBBLESTONE_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_DARK_OAK_WOOD_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_FARMLAND ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_JUNGLE_WOOD_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_OAK_WOOD_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_PURPUR_DOUBLE_SLAB ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_PURPUR_SLAB ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_PURPUR_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_QUARTZ_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_RED_SANDSTONE_SLAB ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_RED_SANDSTONE_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_SANDSTONE_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_SPRUCE_WOOD_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_STONE_BRICK_STAIRS ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_STONE_SLAB ].m_SpreadLightFalloff = 15;
+ Info[E_BLOCK_WOODEN_SLAB ].m_SpreadLightFalloff = 15;
// Transparent blocks
+
Info[E_BLOCK_ACACIA_DOOR ].m_Transparent = true;
Info[E_BLOCK_ACACIA_FENCE ].m_Transparent = true;
Info[E_BLOCK_ACACIA_FENCE_GATE ].m_Transparent = true;
+ Info[E_BLOCK_ACACIA_WOOD_STAIRS ].m_Transparent = true;
Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true;
Info[E_BLOCK_ACTIVE_COMPARATOR ].m_Transparent = true;
Info[E_BLOCK_AIR ].m_Transparent = true;
@@ -183,38 +207,44 @@ cBlockInfo::cBlockInfoArray::cBlockInfoArray()
Info[E_BLOCK_BIRCH_DOOR ].m_Transparent = true;
Info[E_BLOCK_BIRCH_FENCE ].m_Transparent = true;
Info[E_BLOCK_BIRCH_FENCE_GATE ].m_Transparent = true;
+ Info[E_BLOCK_BIRCH_WOOD_STAIRS ].m_Transparent = true;
Info[E_BLOCK_BLACK_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_Transparent = true;
Info[E_BLOCK_BLUE_SHULKER_BOX ].m_Transparent = true;
+ Info[E_BLOCK_BREWING_STAND ].m_Transparent = true;
+ Info[E_BLOCK_BRICK_STAIRS ].m_Transparent = true;
Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true;
Info[E_BLOCK_BROWN_SHULKER_BOX ].m_Transparent = true;
- Info[E_BLOCK_BREWING_STAND ].m_Transparent = true;
Info[E_BLOCK_CACTUS ].m_Transparent = true;
Info[E_BLOCK_CAKE ].m_Transparent = true;
Info[E_BLOCK_CARPET ].m_Transparent = true;
Info[E_BLOCK_CARROTS ].m_Transparent = true;
Info[E_BLOCK_CAULDRON ].m_Transparent = true;
Info[E_BLOCK_CHEST ].m_Transparent = true;
+ Info[E_BLOCK_COBBLESTONE_STAIRS ].m_Transparent = true;
Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true;
- Info[E_BLOCK_COCOA_POD ].m_Transparent = true;
Info[E_BLOCK_COBWEB ].m_Transparent = true;
+ Info[E_BLOCK_COCOA_POD ].m_Transparent = true;
Info[E_BLOCK_CROPS ].m_Transparent = true;
Info[E_BLOCK_CYAN_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_DANDELION ].m_Transparent = true;
Info[E_BLOCK_DARK_OAK_DOOR ].m_Transparent = true;
Info[E_BLOCK_DARK_OAK_FENCE ].m_Transparent = true;
Info[E_BLOCK_DARK_OAK_FENCE_GATE ].m_Transparent = true;
+ Info[E_BLOCK_DARK_OAK_WOOD_STAIRS ].m_Transparent = true;
Info[E_BLOCK_DAYLIGHT_SENSOR ].m_Transparent = true;
Info[E_BLOCK_DEAD_BUSH ].m_Transparent = true;
Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true;
+ Info[E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB ].m_Transparent = true;
+ Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_Transparent = true;
+ Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_Transparent = true;
Info[E_BLOCK_DRAGON_EGG ].m_Transparent = true;
Info[E_BLOCK_ENCHANTMENT_TABLE ].m_Transparent = true;
- Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true;
Info[E_BLOCK_END_PORTAL ].m_Transparent = true;
Info[E_BLOCK_END_PORTAL_FRAME ].m_Transparent = true;
+ Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true;
Info[E_BLOCK_FARMLAND ].m_Transparent = true;
Info[E_BLOCK_FENCE ].m_Transparent = true;
- Info[E_BLOCK_OAK_FENCE_GATE ].m_Transparent = true;
Info[E_BLOCK_FIRE ].m_Transparent = true;
Info[E_BLOCK_FLOWER ].m_Transparent = true;
Info[E_BLOCK_FLOWER_POT ].m_Transparent = true;
@@ -234,23 +264,28 @@ cBlockInfo::cBlockInfoArray::cBlockInfoArray()
Info[E_BLOCK_JUNGLE_DOOR ].m_Transparent = true;
Info[E_BLOCK_JUNGLE_FENCE ].m_Transparent = true;
Info[E_BLOCK_JUNGLE_FENCE_GATE ].m_Transparent = true;
+ Info[E_BLOCK_JUNGLE_WOOD_STAIRS ].m_Transparent = true;
Info[E_BLOCK_LADDER ].m_Transparent = true;
Info[E_BLOCK_LAVA ].m_Transparent = true;
Info[E_BLOCK_LEAVES ].m_Transparent = true;
Info[E_BLOCK_LEVER ].m_Transparent = true;
- Info[E_BLOCK_LILY_PAD ].m_Transparent = true;
Info[E_BLOCK_LIGHT_BLUE_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_LIGHT_GRAY_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
+ Info[E_BLOCK_LILY_PAD ].m_Transparent = true;
Info[E_BLOCK_LIME_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_LIT_FURNACE ].m_Transparent = true;
Info[E_BLOCK_MAGENTA_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_MELON_STEM ].m_Transparent = true;
Info[E_BLOCK_MOB_SPAWNER ].m_Transparent = true;
Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true;
+ Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_Transparent = true;
Info[E_BLOCK_NETHER_PORTAL ].m_Transparent = true;
Info[E_BLOCK_NETHER_WART ].m_Transparent = true;
Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
+ Info[E_BLOCK_OAK_DOOR ].m_Transparent = true;
+ Info[E_BLOCK_OAK_FENCE_GATE ].m_Transparent = true;
+ Info[E_BLOCK_OAK_WOOD_STAIRS ].m_Transparent = true;
Info[E_BLOCK_ORANGE_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_PINK_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_PISTON ].m_Transparent = true;
@@ -260,10 +295,14 @@ cBlockInfo::cBlockInfoArray::cBlockInfoArray()
Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true;
Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true;
Info[E_BLOCK_PURPLE_SHULKER_BOX ].m_Transparent = true;
+ Info[E_BLOCK_PURPUR_DOUBLE_SLAB ].m_Transparent = true;
Info[E_BLOCK_PURPUR_SLAB ].m_Transparent = true;
+ Info[E_BLOCK_PURPUR_STAIRS ].m_Transparent = true;
+ Info[E_BLOCK_QUARTZ_STAIRS ].m_Transparent = true;
Info[E_BLOCK_RAIL ].m_Transparent = true;
Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true;
Info[E_BLOCK_RED_SANDSTONE_SLAB ].m_Transparent = true;
+ Info[E_BLOCK_RED_SANDSTONE_STAIRS ].m_Transparent = true;
Info[E_BLOCK_RED_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_REDSTONE_ORE_GLOWING ].m_Transparent = true;
Info[E_BLOCK_REDSTONE_REPEATER_OFF ].m_Transparent = true;
@@ -271,20 +310,22 @@ cBlockInfo::cBlockInfoArray::cBlockInfoArray()
Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_Transparent = true;
Info[E_BLOCK_REDSTONE_TORCH_ON ].m_Transparent = true;
Info[E_BLOCK_REDSTONE_WIRE ].m_Transparent = true;
+ Info[E_BLOCK_SANDSTONE_STAIRS ].m_Transparent = true;
Info[E_BLOCK_SAPLING ].m_Transparent = true;
Info[E_BLOCK_SIGN_POST ].m_Transparent = true;
Info[E_BLOCK_SPRUCE_DOOR ].m_Transparent = true;
Info[E_BLOCK_SPRUCE_FENCE ].m_Transparent = true;
Info[E_BLOCK_SPRUCE_FENCE_GATE ].m_Transparent = true;
+ Info[E_BLOCK_SPRUCE_WOOD_STAIRS ].m_Transparent = true;
Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true;
Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true;
+ Info[E_BLOCK_STANDING_BANNER ].m_Transparent = true;
Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true;
Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
- Info[E_BLOCK_STANDING_BANNER ].m_Transparent = true;
Info[E_BLOCK_STICKY_PISTON ].m_Transparent = true;
+ Info[E_BLOCK_STONE_BRICK_STAIRS ].m_Transparent = true;
Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
Info[E_BLOCK_STONE_PRESSURE_PLATE ].m_Transparent = true;
- Info[E_BLOCK_STONE_SLAB ].m_Transparent = true;
Info[E_BLOCK_SUGARCANE ].m_Transparent = true;
Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
Info[E_BLOCK_TORCH ].m_Transparent = true;
@@ -298,12 +339,16 @@ cBlockInfo::cBlockInfoArray::cBlockInfoArray()
Info[E_BLOCK_WATER ].m_Transparent = true;
Info[E_BLOCK_WHITE_SHULKER_BOX ].m_Transparent = true;
Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true;
- Info[E_BLOCK_OAK_DOOR ].m_Transparent = true;
Info[E_BLOCK_WOODEN_PRESSURE_PLATE ].m_Transparent = true;
Info[E_BLOCK_WOODEN_SLAB ].m_Transparent = true;
Info[E_BLOCK_YELLOW_SHULKER_BOX ].m_Transparent = true;
+ // Skylight dispersant blocks:
+ Info[E_BLOCK_COBWEB ].m_IsSkylightDispersant = true;
+ Info[E_BLOCK_LEAVES ].m_IsSkylightDispersant = true;
+
+
// One hit break blocks:
Info[E_BLOCK_ACTIVE_COMPARATOR ].m_OneHitDig = true;
Info[E_BLOCK_BEETROOTS ].m_OneHitDig = true;
diff --git a/src/BlockInfo.h b/src/BlockInfo.h
index 1ba818cb3..fd8408638 100644
--- a/src/BlockInfo.h
+++ b/src/BlockInfo.h
@@ -28,7 +28,7 @@ public:
/** How much light do the blocks consume? */
NIBBLETYPE m_SpreadLightFalloff;
- /** Is a block completely transparent? (light doesn't get decreased(?)) */
+ /** Is a block transparent? (https://minecraft.gamepedia.com/Opacity) */
bool m_Transparent;
/** Is a block destroyed after a single hit? */
@@ -37,6 +37,9 @@ public:
/** Can a piston break this block? */
bool m_PistonBreakable;
+ /** Does a block disperse sky light? (only relevant for transparent blocks) */
+ bool m_IsSkylightDispersant;
+
/** Can this block hold snow atop? */
bool m_IsSnowable;
@@ -76,6 +79,10 @@ public:
inline static bool IsTransparent (BLOCKTYPE a_Type) { return Get(a_Type).m_Transparent; }
inline static bool IsOneHitDig (BLOCKTYPE a_Type) { return Get(a_Type).m_OneHitDig; }
inline static bool IsPistonBreakable (BLOCKTYPE a_Type) { return Get(a_Type).m_PistonBreakable; }
+ inline static bool IsSkylightDispersant (BLOCKTYPE a_Type)
+ {
+ return ((Get(a_Type).m_IsSkylightDispersant) || (Get(a_Type).m_SpreadLightFalloff > 1));
+ }
inline static bool IsSnowable (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSnowable; }
inline static bool IsSolid (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSolid; }
inline static bool IsUseableBySpectator (BLOCKTYPE a_Type) { return Get(a_Type).m_UseableBySpectator; }
@@ -95,6 +102,7 @@ public:
, m_Transparent(false)
, m_OneHitDig(false)
, m_PistonBreakable(false)
+ , m_IsSkylightDispersant(false)
, m_IsSnowable(false)
, m_IsSolid(true)
, m_UseableBySpectator(false)
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 6afce338d..1bb4ff89c 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1721,7 +1721,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
{
// Activate the TNT, with a random fuse between 10 to 30 game ticks
int FuseTime = GetRandomProvider().RandInt(10, 30);
- m_World->SpawnPrimedTNT(a_BlockX + x + 0.5, a_BlockY + y + 0.5, a_BlockZ + z + 0.5, FuseTime);
+ m_World->SpawnPrimedTNT({a_BlockX + x + 0.5, a_BlockY + y + 0.5, a_BlockZ + z + 0.5}, FuseTime);
area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_AIR, 0);
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
break;
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index a06650d89..7aa613f4c 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2087,6 +2087,12 @@ void cClientHandle::Tick(float a_Dt)
return;
}
+ // If player has been kicked, terminate the connection:
+ if (m_State == csKicked)
+ {
+ m_Link->Shutdown();
+ }
+
// If destruction is queued, destroy now:
if (m_State == csQueuedForDestruction)
{
@@ -2515,6 +2521,10 @@ void cClientHandle::SendDisconnect(const AString & a_Reason)
LOGD("Sending a DC: \"%s\"", StripColorCodes(a_Reason).c_str());
m_Protocol->SendDisconnect(a_Reason);
m_HasSentDC = true;
+ // csKicked means m_Link will be shut down on the next tick. The
+ // disconnect packet data is sent in the tick thread so the connection
+ // is closed there after the data is sent.
+ m_State = csKicked;
}
}
@@ -3389,7 +3399,3 @@ void cClientHandle::OnError(int a_ErrorCode, const AString & a_ErrorMsg)
}
SocketClosed();
}
-
-
-
-
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 4a4898179..630994c2e 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -242,7 +242,7 @@ public: // tolua_export
/** Returns the view distance that the player request, not the used view distance. */
int GetRequestedViewDistance(void) const { return m_RequestedViewDistance; }
- void SetLocale(AString & a_Locale) { m_Locale = a_Locale; }
+ void SetLocale(const AString & a_Locale) { m_Locale = a_Locale; }
AString GetLocale(void) const { return m_Locale; }
int GetUniqueID(void) const { return m_UniqueID; }
@@ -491,11 +491,10 @@ private:
csDownloadingWorld, ///< The client is waiting for chunks, we're waiting for the loader to provide and send them
csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back
csPlaying, ///< Normal gameplay
+ csKicked, ///< Disconnect packet sent, awaiting connection closure
csQueuedForDestruction, ///< The client will be destroyed in the next tick (flag set when socket closed)
csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks
csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread
-
- // TODO: Add Kicking here as well
} ;
/* Mutex protecting m_State from concurrent writes. */
@@ -595,8 +594,3 @@ private:
virtual void OnRemoteClosed(void) override;
virtual void OnError(int a_ErrorCode, const AString & a_ErrorMsg) override;
}; // tolua_export
-
-
-
-
-
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 6259098d8..2c1a1f005 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -76,7 +76,7 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
-void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cArrowEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Vector3d Hit = a_HitPos;
Hit += GetSpeed().NormalizeCopy() / 100000; // Make arrow sink into block a bit so it lodges (TODO: investigate how to stop them going so far so that they become black clientside)
@@ -93,7 +93,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
if ((m_World->GetBlock(Hit) == E_BLOCK_TNT) && IsOnFire())
{
m_World->SetBlock(X, Y, Z, E_BLOCK_AIR, 0);
- m_World->SpawnPrimedTNT(X, Y, Z);
+ m_World->SpawnPrimedTNT(Vector3d(BlockHit));
}
}
@@ -102,7 +102,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
-void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
super::OnHitEntity(a_EntityHit, a_HitPos);
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 7ed99b79e..6e4644190 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -100,8 +100,8 @@ protected:
Vector3i m_HitBlockPos;
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
virtual void CollectedBy(cPlayer & a_Player) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index cdb12123c..4021f9ce8 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -13,8 +13,8 @@
-cBoat::cBoat(double a_X, double a_Y, double a_Z, eMaterial a_Material) :
- super(etBoat, a_X, a_Y, a_Z, 0.98, 0.7),
+cBoat::cBoat(Vector3d a_Pos, eMaterial a_Material) :
+ super(etBoat, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.7),
m_LastDamage(0), m_ForwardDirection(0),
m_DamageTaken(0.0f), m_Material(a_Material),
m_RightPaddleUsed(false), m_LeftPaddleUsed(false)
diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h
index a6a99d683..1a00d48c9 100644
--- a/src/Entities/Boat.h
+++ b/src/Entities/Boat.h
@@ -42,7 +42,7 @@ public:
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override;
- cBoat(double a_X, double a_Y, double a_Z, eMaterial a_Material);
+ cBoat(Vector3d a_Pos, eMaterial a_Material);
int GetLastDamage(void) const { return m_LastDamage; }
int GetForwardDirection(void) const { return m_ForwardDirection; }
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 9ac8d2e3c..71647200d 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -223,8 +223,6 @@ cChunk * cEntity::GetParentChunk()
void cEntity::Destroy(bool a_ShouldBroadcast)
{
- ASSERT(IsTicking());
- ASSERT(GetParentChunk() != nullptr);
SetIsTicking(false);
// Unleash leashed mobs
@@ -238,19 +236,18 @@ void cEntity::Destroy(bool a_ShouldBroadcast)
m_World->BroadcastDestroyEntity(*this);
}
- cChunk * ParentChunk = GetParentChunk();
- // Destroy the entity after two seconds, to give time for all raw pointers such as m_Target
- // to de-target this entity. This is a temporary solution.
- m_World->ScheduleTask(40, [this, ParentChunk](cWorld & a_World)
+ // Destroy the entity after two seconds, to give time for all cMobPointers to nullify.
+ auto ParentChunkCoords = cChunkDef::BlockToChunk(GetPosition());
+ m_World->ScheduleTask(40, [this, ParentChunkCoords](cWorld & a_World)
{
LOGD("Destroying entity #%i (%s) from chunk (%d, %d)",
this->GetUniqueID(), this->GetClass(),
- ParentChunk->GetPosX(), ParentChunk->GetPosZ()
+ ParentChunkCoords.m_ChunkX, ParentChunkCoords.m_ChunkZ
);
// Make sure that RemoveEntity returned a valid smart pointer
// Also, not storing the returned pointer means automatic destruction
- VERIFY(ParentChunk->RemoveEntity(*this));
+ VERIFY(a_World.RemoveEntity(*this));
});
Destroyed();
}
@@ -1194,6 +1191,13 @@ void cEntity::TickBurning(cChunk & a_Chunk)
// Remember the current burning state:
bool HasBeenBurning = (m_TicksLeftBurning > 0);
+ // Fireproof entities burn out on the next tick
+ if (IsFireproof())
+ {
+ m_TicksLeftBurning = 0;
+ }
+
+ // Fire is extinguished by rain
if (GetWorld()->IsWeatherWetAt(POSX_TOINT, POSZ_TOINT))
{
if (POSY_TOINT > m_World->GetHeight(POSX_TOINT, POSZ_TOINT))
@@ -1577,7 +1581,6 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
{
UNUSED(a_ShouldSendRespawn);
ASSERT(a_World != nullptr);
- ASSERT(IsTicking());
if (GetWorld() == a_World)
{
@@ -1598,6 +1601,9 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
// Tell others we are gone
GetWorld()->BroadcastDestroyEntity(*this);
+ // Take note of old chunk coords
+ auto OldChunkCoords = cChunkDef::BlockToChunk(GetPosition());
+
// Set position to the new position
SetPosition(a_NewPosition);
@@ -1612,16 +1618,15 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
// Queue add to new world and removal from the old one
cWorld * OldWorld = GetWorld();
- cChunk * ParentChunk = GetParentChunk();
SetWorld(a_World); // Chunks may be streamed before cWorld::AddPlayer() sets the world to the new value
- OldWorld->QueueTask([this, ParentChunk, a_World](cWorld & a_OldWorld)
+ OldWorld->QueueTask([this, OldChunkCoords, a_World](cWorld & a_OldWorld)
{
LOGD("Warping entity #%i (%s) from world \"%s\" to \"%s\". Source chunk: (%d, %d) ",
this->GetUniqueID(), this->GetClass(),
a_OldWorld.GetName().c_str(), a_World->GetName().c_str(),
- ParentChunk->GetPosX(), ParentChunk->GetPosZ()
+ OldChunkCoords.m_ChunkX, OldChunkCoords.m_ChunkZ
);
- a_World->AddEntity(ParentChunk->RemoveEntity(*this));
+ a_World->AddEntity(a_OldWorld.RemoveEntity(*this));
cRoot::Get()->GetPluginManager()->CallHookEntityChangedWorld(*this, a_OldWorld);
});
return true;
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 3a4898757..a6ca390fd 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -217,7 +217,6 @@ public:
int GetChunkZ(void) const { return FloorC(m_Position.z / cChunkDef::Width); }
void SetHeadYaw (double a_HeadYaw);
- void SetHeight (double a_Height);
void SetMass (double a_Mass);
void SetPosX (double a_PosX) { SetPosition({a_PosX, m_Position.y, m_Position.z}); }
void SetPosY (double a_PosY) { SetPosition({m_Position.x, a_PosY, m_Position.z}); }
@@ -232,7 +231,7 @@ public:
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
/** Sets the speed of the entity, measured in m / sec */
- void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
+ void SetSpeed(Vector3d a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
/** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedX(double a_SpeedX);
@@ -243,8 +242,6 @@ public:
/** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedZ(double a_SpeedZ);
- void SetWidth (double a_Width);
-
void AddPosX (double a_AddPosX) { AddPosition(a_AddPosX, 0, 0); }
void AddPosY (double a_AddPosY) { AddPosition(0, a_AddPosY, 0); }
void AddPosZ (double a_AddPosZ) { AddPosition(0, 0, a_AddPosZ); }
@@ -300,6 +297,10 @@ public:
// tolua_end
+ void SetHeight(double a_Height);
+
+ void SetWidth(double a_Width);
+
/** Exported in ManualBindings */
const Vector3d & GetPosition(void) const { return m_Position; }
diff --git a/src/Entities/ExpBottleEntity.cpp b/src/Entities/ExpBottleEntity.cpp
index 4072b939b..a9d250118 100644
--- a/src/Entities/ExpBottleEntity.cpp
+++ b/src/Entities/ExpBottleEntity.cpp
@@ -8,7 +8,7 @@
-cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
+cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, Vector3d a_Speed) :
super(pkExpBottle, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
{
SetSpeed(a_Speed);
@@ -18,7 +18,17 @@ cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y,
-void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, Vector3d a_Pos, Vector3d a_Speed) :
+ super(pkExpBottle, a_Creator, a_Pos.x, a_Pos.y, a_Pos.z, 0.25, 0.25)
+{
+ SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cExpBottleEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Break(a_HitPos);
}
@@ -27,7 +37,7 @@ void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H
-void cExpBottleEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cExpBottleEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
Break(a_HitPos);
}
@@ -36,7 +46,7 @@ void cExpBottleEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
-void cExpBottleEntity::Break(const Vector3d &a_HitPos)
+void cExpBottleEntity::Break(Vector3d a_HitPos)
{
// Spawn an experience orb with a reward between 3 and 11.
m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SPLASH_POTION, POSX_TOINT, POSY_TOINT, POSZ_TOINT, 0);
diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h
index ea0c2b5a9..1fcc9b138 100644
--- a/src/Entities/ExpBottleEntity.h
+++ b/src/Entities/ExpBottleEntity.h
@@ -28,17 +28,19 @@ public:
CLASS_PROTODEF(cExpBottleEntity)
- cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, Vector3d a_Speed);
+
+ cExpBottleEntity(cEntity * a_Creator, Vector3d a_Pos, Vector3d a_Speed);
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity (cEntity & a_EntityHit, Vector3d a_HitPos) override;
/** Breaks the bottle, fires its particle effects and sounds
@param a_HitPos The position where the bottle will break */
- void Break(const Vector3d & a_HitPos);
+ void Break(Vector3d a_HitPos);
}; // tolua_export
diff --git a/src/Entities/FireChargeEntity.cpp b/src/Entities/FireChargeEntity.cpp
index 83c1f3c76..5432f9206 100644
--- a/src/Entities/FireChargeEntity.cpp
+++ b/src/Entities/FireChargeEntity.cpp
@@ -31,7 +31,7 @@ void cFireChargeEntity::Explode(Vector3i a_Block)
-void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cFireChargeEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Destroy();
Explode(a_HitPos.Floor());
@@ -41,7 +41,7 @@ void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_
-void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
super::OnHitEntity(a_EntityHit, a_HitPos);
diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h
index e17b25903..2ea64d1e3 100644
--- a/src/Entities/FireChargeEntity.h
+++ b/src/Entities/FireChargeEntity.h
@@ -35,8 +35,8 @@ protected:
void Explode(Vector3i a_Block);
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
} ; // tolua_export
diff --git a/src/Entities/GhastFireballEntity.cpp b/src/Entities/GhastFireballEntity.cpp
index 1adfd1bc0..2dbfbf481 100644
--- a/src/Entities/GhastFireballEntity.cpp
+++ b/src/Entities/GhastFireballEntity.cpp
@@ -28,7 +28,7 @@ void cGhastFireballEntity::Explode(Vector3i a_Block)
-void cGhastFireballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cGhastFireballEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Destroy();
Explode(a_HitPos.Floor());
@@ -38,7 +38,7 @@ void cGhastFireballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace
-void cGhastFireballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cGhastFireballEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
Destroy();
Explode(a_HitPos.Floor());
diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h
index 620efd9e6..bf5b333e2 100644
--- a/src/Entities/GhastFireballEntity.h
+++ b/src/Entities/GhastFireballEntity.h
@@ -35,8 +35,8 @@ protected:
void Explode(Vector3i a_Block);
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
// TODO: Deflecting the fireballs by arrow- or sword- hits
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 4189841b8..7aef38b93 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2203,7 +2203,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
// Load the player stats.
// We use the default world name (like bukkit) because stats are shared between dimensions / worlds.
- cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
+ cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetDataPath(), GetName(), GetUUID().ToLongString(), &m_Stats);
StatSerializer.Load();
LOGD("Player %s was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
@@ -2301,7 +2301,7 @@ bool cPlayer::SaveToDisk()
// Save the player stats.
// We use the default world name (like bukkit) because stats are shared between dimensions / worlds.
- cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
+ cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetDataPath(), GetName(), GetUUID().ToLongString(), &m_Stats);
if (!StatSerializer.Save())
{
LOGWARNING("Could not save stats for player %s", GetName().c_str());
@@ -2352,23 +2352,6 @@ void cPlayer::UseEquippedItem(int a_Amount)
-void cPlayer::TickBurning(cChunk & a_Chunk)
-{
- // Don't burn in creative or spectator and stop burning in creative if necessary
- if (!IsGameModeCreative() && !IsGameModeSpectator())
- {
- super::TickBurning(a_Chunk);
- }
- else if (IsOnFire())
- {
- m_TicksLeftBurning = 0;
- OnFinishedBurning();
- }
-}
-
-
-
-
void cPlayer::HandleFood(void)
{
@@ -3018,4 +3001,3 @@ float cPlayer::GetPlayerRelativeBlockHardness(BLOCKTYPE a_Block)
// LOGD("blockHardness: %f, digSpeed: %f, canHarvestBlockDivisor: %f\n", blockHardness, digSpeed, canHarvestBlockDivisor);
return (blockHardness < 0) ? 0 : ((digSpeed / blockHardness) / canHarvestBlockDivisor);
}
-
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 5c08151c8..2685622ad 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -195,6 +195,15 @@ public:
/** Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current world */
bool IsGameModeSpectator(void) const;
+ /** Returns true if the player is fireproof
+ Stops players burning in creative or spectator modes.
+ */
+ virtual bool IsFireproof() const override
+ {
+ return (m_IsFireproof || IsGameModeCreative() || IsGameModeSpectator());
+
+ }
+
/** Returns true if the player can be targeted by Mobs */
bool CanMobsTarget(void) const;
@@ -331,13 +340,13 @@ public:
/** Returns true if the player is currently in the process of eating the currently equipped item */
bool IsEating(void) const { return (m_EatingFinishTick >= 0); }
- /** Returns true if the player is currently flying. */
+ /** Returns true if the player is currently flying */
bool IsFlying(void) const { return m_IsFlying; }
- /** Returns if a player is sleeping in a bed */
+ /** Returns true if a player is sleeping in a bed */
bool IsInBed(void) const { return m_bIsInBed; }
- /** returns true if the player has thrown out a floater. */
+ /** Returns true if the player has thrown out a floater */
bool IsFishing(void) const { return m_IsFishing; }
void SetIsFishing(bool a_IsFishing, UInt32 a_FloaterID = cEntity::INVALID_ID) { m_IsFishing = a_IsFishing; m_FloaterID = a_FloaterID; }
@@ -719,9 +728,6 @@ protected:
/** Filters out damage for creative mode / friendly fire */
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
- /** Stops players from burning in creative mode */
- virtual void TickBurning(cChunk & a_Chunk) override;
-
/** Called in each tick to handle food-related processing */
void HandleFood(void);
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index c2a1f782d..1017f954a 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -300,7 +300,7 @@ std::unique_ptr<cProjectileEntity> cProjectileEntity::Create(eKind a_Kind, cEnti
-void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cProjectileEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
// Set the position based on what face was hit:
SetPosition(a_HitPos);
@@ -320,7 +320,7 @@ void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_
-void cProjectileEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cProjectileEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
UNUSED(a_HitPos);
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index da8c650f5..36f53c841 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -49,10 +49,10 @@ public:
static std::unique_ptr<cProjectileEntity> Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = nullptr);
/** Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given */
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace);
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace);
/** Called by the physics blocktracer when the entity hits another entity */
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos);
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos);
/** Called by Chunk when the projectile is eligible for player collection */
virtual void CollectedBy(cPlayer & a_Dest);
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index af4008e83..8356806b3 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -28,7 +28,7 @@ public:
@param a_HitPos The position where the splash potion has splashed
@param a_EntityEffectType The effect type of the potion
@param a_EntityEffect The effect description */
- cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType a_EntityEffectType, const cEntityEffect & a_EntityEffect) :
+ cSplashPotionCallback(Vector3d a_HitPos, cEntityEffect::eType a_EntityEffectType, const cEntityEffect & a_EntityEffect) :
m_HitPos(a_HitPos),
m_EntityEffectType(a_EntityEffectType),
m_EntityEffect(a_EntityEffect)
@@ -61,7 +61,7 @@ public:
}
private:
- const Vector3d & m_HitPos;
+ Vector3d m_HitPos;
cEntityEffect::eType m_EntityEffectType;
const cEntityEffect & m_EntityEffect;
};
@@ -96,7 +96,7 @@ cSplashPotionEntity::cSplashPotionEntity(
-void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cSplashPotionEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Splash(a_HitPos);
m_DestroyTimer = 2;
@@ -106,7 +106,7 @@ void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace
-void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
Splash(a_HitPos);
@@ -117,7 +117,7 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_
-void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
+void cSplashPotionEntity::Splash(Vector3d a_HitPos)
{
cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
m_World->ForEachEntity(Callback);
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index baa5da725..bb78bfaeb 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -41,16 +41,17 @@ public:
// tolua_begin
cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
- cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
int GetPotionColor(void) const { return m_PotionColor; }
const cItem & GetItem(void) const { return m_Item; }
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
- void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
// tolua_end
+ cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
+ void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
+
protected:
cEntityEffect::eType m_EntityEffectType;
@@ -60,8 +61,8 @@ protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity (cEntity & a_EntityHit, Vector3d a_HitPos) override;
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override
{
if (m_DestroyTimer > 0)
@@ -81,7 +82,7 @@ protected:
/** Splashes the potion, fires its particle effects and sounds
@param a_HitPos The position where the potion will splash */
- void Splash(const Vector3d & a_HitPos);
+ void Splash(Vector3d a_HitPos);
virtual void SpawnOn(cClientHandle & a_Client) override;
diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp
index 6784f19f5..26217cfcd 100644
--- a/src/Entities/TNTEntity.cpp
+++ b/src/Entities/TNTEntity.cpp
@@ -8,19 +8,7 @@
-cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks) :
- super(etTNT, a_X, a_Y, a_Z, 0.98, 0.98),
- m_FuseTicks(a_FuseTicks)
-{
- SetGravity(-16.0f);
- SetAirDrag(0.02f);
-}
-
-
-
-
-
-cTNTEntity::cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks) :
+cTNTEntity::cTNTEntity(Vector3d a_Pos, int a_FuseTicks) :
super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
m_FuseTicks(a_FuseTicks)
{
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index 5f1faa6b4..25c74ded5 100644
--- a/src/Entities/TNTEntity.h
+++ b/src/Entities/TNTEntity.h
@@ -16,8 +16,7 @@ public:
// tolua_end
CLASS_PROTODEF(cTNTEntity)
- cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks = 80);
- cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks = 80);
+ cTNTEntity(Vector3d a_Pos, int a_FuseTicks = 80);
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp
index 3131f4841..226f37fb6 100644
--- a/src/Entities/ThrownEggEntity.cpp
+++ b/src/Entities/ThrownEggEntity.cpp
@@ -18,7 +18,7 @@ cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y,
-void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cThrownEggEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
TrySpawnChicken(a_HitPos);
@@ -29,7 +29,7 @@ void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H
-void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
int TotalDamage = 0;
// If entity is an Ender Dragon or Ender Crystal, it is damaged.
@@ -72,7 +72,7 @@ void cThrownEggEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
-void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
+void cThrownEggEntity::TrySpawnChicken(Vector3d a_HitPos)
{
auto & Random = GetRandomProvider();
if (Random.RandBool(0.125))
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index f20cd41a1..071b974cb 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -33,12 +33,12 @@ public:
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// Randomly decides whether to spawn a chicken where the egg lands.
- void TrySpawnChicken(const Vector3d & a_HitPos);
+ void TrySpawnChicken(Vector3d a_HitPos);
private:
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index 4b2e2f9ff..4dedffc5b 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -19,7 +19,7 @@ cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X
-void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cThrownEnderPearlEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
// TODO: Tweak a_HitPos based on block face.
TeleportCreator(a_HitPos);
@@ -31,7 +31,7 @@ void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockF
-void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
int TotalDamage = 0;
// TODO: If entity is Ender Crystal, destroy it
@@ -67,7 +67,7 @@ void cThrownEnderPearlEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Ch
-void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
+void cThrownEnderPearlEntity::TeleportCreator(Vector3d a_HitPos)
{
if (m_CreatorData.m_Name.empty())
{
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index 03d54e911..ee618f900 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -33,12 +33,12 @@ public:
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
/** Teleports the creator where the ender pearl lands */
- void TeleportCreator(const Vector3d & a_HitPos);
+ void TeleportCreator(Vector3d a_HitPos);
private:
diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp
index ef88bfd18..8a6426ca9 100644
--- a/src/Entities/ThrownSnowballEntity.cpp
+++ b/src/Entities/ThrownSnowballEntity.cpp
@@ -18,7 +18,7 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do
-void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cThrownSnowballEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
m_DestroyTimer = 2;
}
@@ -27,7 +27,7 @@ void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFac
-void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
super::OnHitEntity(a_EntityHit, a_HitPos);
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index d22930f8f..7bed78df3 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -33,8 +33,8 @@ public:
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
private:
diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp
index cbf3d7ae9..a82ea8e7a 100644
--- a/src/Entities/WitherSkullEntity.cpp
+++ b/src/Entities/WitherSkullEntity.cpp
@@ -25,7 +25,7 @@ cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a
-void cWitherSkullEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cWitherSkullEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
// TODO: Explode
// TODO: Apply wither effect to entities nearby
@@ -36,7 +36,7 @@ void cWitherSkullEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a
-void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
// TODO: If entity is Ender Crystal, destroy it
a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
index 11b6fe3aa..af9b31625 100644
--- a/src/Entities/WitherSkullEntity.h
+++ b/src/Entities/WitherSkullEntity.h
@@ -33,8 +33,8 @@ public:
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
} ; // tolua_export
diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h
index f39a35a88..09d8b1d2d 100644
--- a/src/Items/ItemBoat.h
+++ b/src/Items/ItemBoat.h
@@ -95,7 +95,7 @@ public:
}
// Spawn block at water level
- if (a_World->SpawnBoat(x + 0.5, y + 0.5, z + 0.5, cBoat::ItemToMaterial(a_Player->GetEquippedItem())) == cEntity::INVALID_ID)
+ if (a_World->SpawnBoat(Callbacks.m_Pos + Vector3d(0.5, 0.5, 0.5), cBoat::ItemToMaterial(a_Player->GetEquippedItem())) == cEntity::INVALID_ID)
{
return false;
}
diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h
index 1cf2ec939..8b46ba011 100644
--- a/src/Items/ItemLighter.h
+++ b/src/Items/ItemLighter.h
@@ -58,7 +58,7 @@ public:
// Activate the TNT:
a_World->BroadcastSoundEffect("entity.tnt.primed", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 1.0f, 1.0f);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom
+ a_World->SpawnPrimedTNT({a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5}); // 80 ticks to boom
break;
}
default:
diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp
index df1a802a5..302a7ba01 100644
--- a/src/LightingThread.cpp
+++ b/src/LightingThread.cpp
@@ -378,7 +378,8 @@ void cLightingThread::PrepareSkyLight(void)
ASSERT(Current < cChunkDef::Height);
while (
(Current >= 0) &&
- cBlockInfo::IsTransparent(m_BlockTypes[idx + Current * BlocksPerYLayer])
+ cBlockInfo::IsTransparent(m_BlockTypes[idx + Current * BlocksPerYLayer]) &&
+ !cBlockInfo::IsSkylightDispersant(m_BlockTypes[idx + Current * BlocksPerYLayer])
)
{
Current -= 1; // Sunlight goes down unchanged through this block
diff --git a/src/MapManager.cpp b/src/MapManager.cpp
index 2729e67dd..4408af76b 100644
--- a/src/MapManager.cpp
+++ b/src/MapManager.cpp
@@ -96,7 +96,7 @@ void cMapManager::LoadMapData(void)
{
cCSLock Lock(m_CS);
- cIDCountSerializer IDSerializer(m_World->GetName());
+ cIDCountSerializer IDSerializer(m_World->GetDataPath());
if (!IDSerializer.Load())
{
@@ -111,7 +111,7 @@ void cMapManager::LoadMapData(void)
{
cMap Map(i, m_World);
- cMapSerializer Serializer(m_World->GetName(), &Map);
+ cMapSerializer Serializer(m_World->GetDataPath(), &Map);
if (!Serializer.Load())
{
@@ -135,7 +135,7 @@ void cMapManager::SaveMapData(void)
return;
}
- cIDCountSerializer IDSerializer(m_World->GetName());
+ cIDCountSerializer IDSerializer(m_World->GetDataPath());
IDSerializer.SetMapCount(static_cast<unsigned>(m_MapData.size()));
@@ -149,7 +149,7 @@ void cMapManager::SaveMapData(void)
{
cMap & Map = *it;
- cMapSerializer Serializer(m_World->GetName(), &Map);
+ cMapSerializer Serializer(m_World->GetDataPath(), &Map);
if (!Serializer.Save())
{
diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt
index 00ffeb255..f4f266963 100644
--- a/src/Protocol/CMakeLists.txt
+++ b/src/Protocol/CMakeLists.txt
@@ -7,6 +7,7 @@ SET (SRCS
ChunkDataSerializer.cpp
ForgeHandshake.cpp
MojangAPI.cpp
+ PacketID.cpp
Packetizer.cpp
Protocol_1_8.cpp
Protocol_1_9.cpp
diff --git a/src/Protocol/PacketID.cpp b/src/Protocol/PacketID.cpp
new file mode 100644
index 000000000..6bb8379dd
--- /dev/null
+++ b/src/Protocol/PacketID.cpp
@@ -0,0 +1,182 @@
+#include "Globals.h"
+
+#include "Protocol_1_9.h"
+#include "Protocol_1_12.h"
+
+
+
+
+
+UInt32 cProtocol_1_9_0::GetPacketId(eOutgoingPackets a_Packet)
+{
+ switch (a_Packet)
+ {
+ case sendAttachEntity: return 0x40;
+ case sendBlockAction: return 0x0a;
+ case sendBlockBreakAnim: return 0x08;
+ case sendBlockChange: return 0x0b;
+ case sendBlockChanges: return 0x10;
+ case sendCameraSetTo: return 0x36;
+ case sendChatRaw: return 0x0f;
+ case sendCollectEntity: return 0x49;
+ case sendDestroyEntity: return 0x30;
+ case sendDifficulty: return 0x0d;
+ case sendDisconnectDuringGame: return 0x1a;
+ case sendDisconnectDuringLogin: return 0x0;
+ case sendDisplayObjective: return 0x38;
+ case sendEditSign: return 0x2a;
+ case sendEntityAnimation: return 0x06;
+ case sendEntityEffect: return 0x4c;
+ case sendEntityEquipment: return 0x3c;
+ case sendEntityHeadLook: return 0x34;
+ case sendEntityLook: return 0x27;
+ case sendEntityMeta: return 0x39;
+ case sendEntityProperties: return 0x4b;
+ case sendEntityRelMove: return 0x25;
+ case sendEntityRelMoveLook: return 0x26;
+ case sendEntityStatus: return 0x1b;
+ case sendEntityVelocity: return 0x3b;
+ case sendExperience: return 0x3d;
+ case sendExperienceOrb: return 0x01;
+ case sendExplosion: return 0x1c;
+ case sendGameMode: return 0x1e;
+ case sendHealth: return 0x3e;
+ case sendInventorySlot: return 0x16;
+ case sendJoinGame: return 0x23;
+ case sendKeepAlive: return 0x1f;
+ case sendLeashEntity: return 0x3a;
+ case sendMapData: return 0x24;
+ case sendPaintingSpawn: return 0x04;
+ case sendParticleEffect: return 0x22;
+ case sendPlayerAbilities: return 0x2b;
+ case sendPlayerList: return 0x2d;
+ case sendPlayerMaxSpeed: return 0x4b;
+ case sendPlayerMoveLook: return 0x2e;
+ case sendPlayerSpawn: return 0x05;
+ case sendPluginMessage: return 0x18;
+ case sendRemoveEntityEffect: return 0x31;
+ case sendRespawn: return 0x33;
+ case sendScoreboardObjective: return 0x3f;
+ case sendScoreUpdate: return 0x42;
+ case sendSpawnGlobalEntity: return 0x02;
+ case sendSpawnObject: return 0x00;
+ case sendSpawnPosition: return 0x43;
+ case sendSoundEffect: return 0x19;
+ case sendSoundParticleEffect: return 0x21;
+ case sendSpawnMob: return 0x03;
+ case sendStatistics: return 0x07;
+ case sendTabCompletion: return 0x0e;
+ case sendTeleportEntity: return 0x4a;
+ case sendTimeUpdate: return 0x44;
+ case sendTitle: return 0x45;
+ case sendUnloadChunk: return 0x1d;
+ case sendUpdateBlockEntity: return 0x09;
+ case sendUpdateSign: return 0x46;
+ case sendUseBed: return 0x2f;
+ case sendWeather: return 0x1e;
+ case sendWindowClose: return 0x12;
+ case sendWindowItems: return 0x14;
+ case sendWindowOpen: return 0x13;
+ case sendWindowProperty: return 0x15;
+ }
+ LOGWARNING("Retrieving packet ID for unknown packet type %d!", a_Packet);
+ return 0;
+}
+
+
+
+
+
+UInt32 cProtocol_1_9_4::GetPacketId(eOutgoingPackets a_Packet)
+{
+ switch (a_Packet)
+ {
+ case sendCollectEntity: return 0x48;
+ case sendEntityEffect: return 0x4b;
+ case sendEntityProperties: return 0x4a;
+ case sendPlayerMaxSpeed: return 0x4a;
+ case sendTeleportEntity: return 0x49;
+
+ default: return super::GetPacketId(a_Packet);
+ }
+}
+
+
+
+
+
+UInt32 cProtocol_1_12::GetPacketId(eOutgoingPackets a_Packet)
+{
+ switch (a_Packet)
+ {
+ case sendAttachEntity: return 0x42;
+ case sendCameraSetTo: return 0x38;
+ case sendCollectEntity: return 0x4a;
+ case sendDestroyEntity: return 0x31;
+ case sendDisplayObjective: return 0x3a;
+ case sendEntityEffect: return 0x4e;
+ case sendEntityEquipment: return 0x3e;
+ case sendEntityHeadLook: return 0x35;
+ case sendEntityLook: return 0x28;
+ case sendEntityMeta: return 0x3b;
+ case sendEntityProperties: return 0x4d;
+ case sendEntityRelMove: return 0x26;
+ case sendEntityRelMoveLook: return 0x27;
+ case sendEntityVelocity: return 0x3d;
+ case sendExperience: return 0x3f;
+ case sendHealth: return 0x40;
+ case sendLeashEntity: return 0x3c;
+ case sendPlayerMaxSpeed: return 0x4d;
+ case sendRemoveEntityEffect: return 0x32;
+ case sendRespawn: return 0x34;
+ case sendScoreboardObjective: return 0x41;
+ case sendScoreUpdate: return 0x44;
+ case sendSpawnPosition: return 0x45;
+ case sendTeleportEntity: return 0x4b;
+ case sendTimeUpdate: return 0x46;
+ case sendTitle: return 0x47;
+ case sendUpdateBlockEntity: return 0x09;
+
+ default: return super::GetPacketId(a_Packet);
+ }
+}
+
+
+
+
+
+UInt32 cProtocol_1_12_1::GetPacketId(eOutgoingPackets a_Packet)
+{
+ switch (a_Packet)
+ {
+ case sendAttachEntity: return 0x43;
+ case sendCameraSetTo: return 0x39;
+ case sendCollectEntity: return 0x4b;
+ case sendDestroyEntity: return 0x32;
+ case sendDisplayObjective: return 0x3b;
+ case sendEntityEffect: return 0x4f;
+ case sendEntityEquipment: return 0x3f;
+ case sendEntityHeadLook: return 0x36;
+ case sendEntityMeta: return 0x3c;
+ case sendEntityProperties: return 0x4e;
+ case sendEntityVelocity: return 0x3e;
+ case sendExperience: return 0x40;
+ case sendHealth: return 0x41;
+ case sendLeashEntity: return 0x3d;
+ case sendPlayerList: return 0x2e;
+ case sendPlayerAbilities: return 0x2c;
+ case sendPlayerMaxSpeed: return 0x4e;
+ case sendPlayerMoveLook: return 0x2f;
+ case sendRemoveEntityEffect: return 0x33;
+ case sendRespawn: return 0x35;
+ case sendScoreboardObjective: return 0x42;
+ case sendScoreUpdate: return 0x45;
+ case sendSpawnPosition: return 0x46;
+ case sendUseBed: return 0x30;
+ case sendTeleportEntity: return 0x4c;
+ case sendTimeUpdate: return 0x47;
+ case sendTitle: return 0x48;
+
+ default: return super::GetPacketId(a_Packet);
+ }
+}
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 54c5b7223..235b60020 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -56,6 +56,78 @@ public:
virtual ~cProtocol() {}
+ /** A list of all outgoing packets */
+ enum eOutgoingPackets
+ {
+ sendAttachEntity = 0,
+ sendBlockAction,
+ sendBlockBreakAnim,
+ sendBlockChange,
+ sendBlockChanges,
+ sendCameraSetTo,
+ sendChatRaw,
+ sendCollectEntity,
+ sendDestroyEntity,
+ sendDifficulty,
+ sendDisconnectDuringLogin,
+ sendDisconnectDuringGame,
+ sendDisplayObjective,
+ sendEditSign,
+ sendEntityAnimation,
+ sendEntityEffect,
+ sendEntityEquipment,
+ sendEntityHeadLook,
+ sendEntityLook,
+ sendEntityMeta,
+ sendEntityProperties,
+ sendEntityRelMove,
+ sendEntityRelMoveLook,
+ sendEntityStatus,
+ sendEntityVelocity,
+ sendExperience,
+ sendExperienceOrb,
+ sendExplosion,
+ sendGameMode,
+ sendHealth,
+ sendInventorySlot,
+ sendJoinGame,
+ sendKeepAlive,
+ sendLeashEntity,
+ sendMapData,
+ sendPaintingSpawn,
+ sendParticleEffect,
+ sendPlayerAbilities,
+ sendPlayerList,
+ sendPlayerMaxSpeed,
+ sendPlayerMoveLook,
+ sendPlayerSpawn,
+ sendPluginMessage,
+ sendRemoveEntityEffect,
+ sendRespawn,
+ sendScoreboardObjective,
+ sendScoreUpdate,
+ sendSpawnObject,
+ sendSoundEffect,
+ sendSoundParticleEffect,
+ sendSpawnGlobalEntity,
+ sendSpawnMob,
+ sendSpawnPosition,
+ sendStatistics,
+ sendTabCompletion,
+ sendTeleportEntity,
+ sendTimeUpdate,
+ sendTitle,
+ sendUnloadChunk,
+ sendUpdateBlockEntity,
+ sendUpdateSign,
+ sendUseBed,
+ sendWeather,
+ sendWindowItems,
+ sendWindowClose,
+ sendWindowOpen,
+ sendWindowProperty
+ };
+
/** Called when client sends some data */
virtual void DataReceived(const char * a_Data, size_t a_Size) = 0;
@@ -165,6 +237,9 @@ protected:
/** Buffer for composing packet length (so that each cPacketizer instance doesn't allocate a new cPacketBuffer) */
cByteBuffer m_OutPacketLenBuffer;
+ /** Returns the protocol-specific packet ID given the protocol-agnostic packet enum (see PacketID.cpp for implementations) */
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) = 0;
+
/** A generic data-sending routine, all outgoing packet data needs to be routed through this so that descendants may override it. */
virtual void SendData(const char * a_Data, size_t a_Size) = 0;
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 295c6db16..6d75b0f2e 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -156,6 +156,13 @@ protected:
/** Is a server list ping for an unrecognized version currently occuring? */
bool m_InPingForUnrecognizedVersion;
+ /** GetPacketId is implemented in each protocol version class */
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override
+ {
+ ASSERT(!"cProtocolRecognizer::GetPacketId should never be called! Something is horribly wrong! (this method being called implies that someone other than a Protocol-derived class is calling GetPacketId)");
+ return 0;
+ }
+
// Packet handlers while in status state (m_InPingForUnrecognizedVersion == true)
void HandlePacketStatusRequest();
void HandlePacketStatusPing();
diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp
index 63b80dace..706558810 100644
--- a/src/Protocol/Protocol_1_10.cpp
+++ b/src/Protocol/Protocol_1_10.cpp
@@ -304,7 +304,7 @@ void cProtocol_1_10_0::SendSoundEffect(const AString & a_SoundName, double a_X,
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x19); // Named sound effect packet
+ cPacketizer Pkt(*this, GetPacketId(sendSoundEffect)); // Named sound effect packet
Pkt.WriteString(a_SoundName);
Pkt.WriteVarInt32(0); // Master sound category (may want to be changed to a parameter later)
Pkt.WriteBEInt32(FloorC(a_X * 8.0));
diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp
index b9b6e9ac3..ba7742493 100644
--- a/src/Protocol/Protocol_1_11.cpp
+++ b/src/Protocol/Protocol_1_11.cpp
@@ -342,7 +342,7 @@ void cProtocol_1_11_0::SendCollectEntity(const cEntity & a_Entity, const cPlayer
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x48); // Collect Item packet
+ cPacketizer Pkt(*this, GetPacketId(sendCollectEntity)); // Collect Item packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteVarInt32(a_Player.GetUniqueID());
Pkt.WriteVarInt32(static_cast<UInt32>(a_Count));
@@ -356,7 +356,7 @@ void cProtocol_1_11_0::SendHideTitle(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x45); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(4); // Hide title
}
@@ -368,7 +368,7 @@ void cProtocol_1_11_0::SendResetTitle(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x45); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(5); // Reset title
}
@@ -380,7 +380,7 @@ void cProtocol_1_11_0::SendSpawnMob(const cMonster & a_Mob)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x03); // Spawn Mob packet
+ cPacketizer Pkt(*this, GetPacketId(sendSpawnMob)); // Spawn Mob packet
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
diff --git a/src/Protocol/Protocol_1_12.cpp b/src/Protocol/Protocol_1_12.cpp
index a8e38a4e0..166078aef 100644
--- a/src/Protocol/Protocol_1_12.cpp
+++ b/src/Protocol/Protocol_1_12.cpp
@@ -985,360 +985,6 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
-void cProtocol_1_12::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x26); // Entity Relative Move packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- // TODO: 1.9 changed these from chars to shorts, meaning that there can be more percision and data. Other code needs to be updated for that.
- Pkt.WriteBEInt16(a_RelX * 128);
- Pkt.WriteBEInt16(a_RelY * 128);
- Pkt.WriteBEInt16(a_RelZ * 128);
- Pkt.WriteBool(a_Entity.IsOnGround());
-}
-
-
-
-
-
-void cProtocol_1_12::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x27); // Entity Look And Relative Move packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- // TODO: 1.9 changed these from chars to shorts, meaning that there can be more percision and data. Other code needs to be updated for that.
- Pkt.WriteBEInt16(a_RelX * 128);
- Pkt.WriteBEInt16(a_RelY * 128);
- Pkt.WriteBEInt16(a_RelZ * 128);
- Pkt.WriteByteAngle(a_Entity.GetYaw());
- Pkt.WriteByteAngle(a_Entity.GetPitch());
- Pkt.WriteBool(a_Entity.IsOnGround());
-}
-
-
-
-
-
-void cProtocol_1_12::SendEntityLook(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x28); // Entity Look packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteByteAngle(a_Entity.GetYaw());
- Pkt.WriteByteAngle(a_Entity.GetPitch());
- Pkt.WriteBool(a_Entity.IsOnGround());
-}
-
-
-
-
-
-void cProtocol_1_12::SendDestroyEntity(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x31); // Destroy Entities packet
- Pkt.WriteVarInt32(1);
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
-}
-
-
-
-
-
-void cProtocol_1_12::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x32); // Remove entity effect packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
-}
-
-
-
-
-
-void cProtocol_1_12::SendRespawn(eDimension a_Dimension)
-{
- cPacketizer Pkt(*this, 0x34); // Respawn packet
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteBEInt32(static_cast<Int32>(a_Dimension));
- Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteBEUInt8(static_cast<Byte>(Player->GetEffectiveGameMode()));
- Pkt.WriteString("default");
-}
-
-
-
-
-
-void cProtocol_1_12::SendEntityHeadLook(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x35); // Entity Head Look packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteByteAngle(a_Entity.GetHeadYaw());
-}
-
-
-
-
-
-void cProtocol_1_12::SendCameraSetTo(const cEntity & a_Entity)
-{
- cPacketizer Pkt(*this, 0x38); // Camera Packet (Attach the camera of a player at another entity in spectator mode)
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
-}
-
-
-
-
-
-void cProtocol_1_12::SendDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x3a); // Display scoreboard packet
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_Display));
- Pkt.WriteString(a_Objective);
-}
-
-
-
-
-
-void cProtocol_1_12::SendEntityMetadata(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x3b); // Entity Metadata packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- WriteEntityMetadata(Pkt, a_Entity);
- Pkt.WriteBEUInt8(0xff); // The termination byte
-}
-
-
-
-
-
-void cProtocol_1_12::SendLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo)
-{
- ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3c); // Set Attach Entity packet
- Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEUInt32(a_EntityLeashedTo.GetUniqueID());
-}
-
-
-
-
-
-void cProtocol_1_12::SendUnleashEntity(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3c); // Set Attach Entity packet
- Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEInt32(-1); // Unleash a_Entity
-}
-
-
-
-
-
-void cProtocol_1_12::SendEntityVelocity(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x3d); // Entity Velocity packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- // 400 = 8000 / 20 ... Conversion from our speed in m / s to 8000 m / tick
- Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedX() * 400));
- Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedY() * 400));
- Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedZ() * 400));
-}
-
-
-
-
-
-void cProtocol_1_12::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x3e); // Entity Equipment packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- // Needs to be adjusted due to the insertion of offhand at slot 1
- if (a_SlotNum > 0)
- {
- a_SlotNum++;
- }
- Pkt.WriteVarInt32(static_cast<UInt32>(a_SlotNum));
- WriteItem(Pkt, a_Item);
-}
-
-
-
-
-
-void cProtocol_1_12::SendExperience(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x3f); // Set Experience Packet
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteBEFloat(Player->GetXpPercentage());
- Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetXpLevel()));
- Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetCurrentXp()));
-}
-
-
-
-
-
-void cProtocol_1_12::SendHealth(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x40); // Update Health packet
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteBEFloat(static_cast<float>(Player->GetHealth()));
- Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetFoodLevel()));
- Pkt.WriteBEFloat(static_cast<float>(Player->GetFoodSaturationLevel()));
-}
-
-
-
-
-
-void cProtocol_1_12::SendScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x41); // Scoreboard objective packet
- Pkt.WriteString(a_Name);
- Pkt.WriteBEUInt8(a_Mode);
- if ((a_Mode == 0) || (a_Mode == 2))
- {
- Pkt.WriteString(a_DisplayName);
- Pkt.WriteString("integer");
- }
-}
-
-
-
-
-
-void cProtocol_1_12::SendAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle)
-{
- ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x42); // Set Passengers packet
- Pkt.WriteVarInt32(a_Vehicle.GetUniqueID());
- Pkt.WriteVarInt32(1); // 1 passenger
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
-}
-
-
-
-
-
-void cProtocol_1_12::SendDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle)
-{
- ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x42); // Set Passengers packet
- Pkt.WriteVarInt32(a_PreviousVehicle.GetUniqueID());
- Pkt.WriteVarInt32(0); // No passangers
-}
-
-
-
-
-
-void cProtocol_1_12::SendScoreUpdate(const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x44); // Update score packet
- Pkt.WriteString(a_Player);
- Pkt.WriteBEUInt8(a_Mode);
- Pkt.WriteString(a_Objective);
-
- if (a_Mode != 1)
- {
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Score));
- }
-}
-
-
-
-
-
-void cProtocol_1_12::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
-{
- // Send the Join Game packet:
- {
- cServer * Server = cRoot::Get()->GetServer();
- cPacketizer Pkt(*this, 0x23); // Join Game packet
- Pkt.WriteBEUInt32(a_Player.GetUniqueID());
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
- Pkt.WriteBEInt32(static_cast<Int32>(a_World.GetDimension()));
- Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteBEUInt8(static_cast<UInt8>(Clamp<size_t>(Server->GetMaxPlayers(), 0, 255)));
- Pkt.WriteString("default"); // Level type - wtf?
- Pkt.WriteBool(false); // Reduced Debug Info - wtf?
- }
-
- // Send the spawn position:
- {
- cPacketizer Pkt(*this, 0x45); // Spawn Position packet
- Pkt.WritePosition64(FloorC(a_World.GetSpawnX()), FloorC(a_World.GetSpawnY()), FloorC(a_World.GetSpawnZ()));
- }
-
- // Send the server difficulty:
- {
- cPacketizer Pkt(*this, 0x0d); // Server difficulty packet
- Pkt.WriteBEInt8(1);
- }
-
- // Send player abilities:
- SendPlayerAbilities();
-}
-
-
-
-
-
-void cProtocol_1_12::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x09); // Update tile entity packet
- Pkt.WritePosition64(a_BlockEntity.GetPosX(), a_BlockEntity.GetPosY(), a_BlockEntity.GetPosZ());
-
- Byte Action = 0;
- switch (a_BlockEntity.GetBlockType())
- {
- case E_BLOCK_MOB_SPAWNER: Action = 1; break; // Update mob spawner spinny mob thing
- case E_BLOCK_COMMAND_BLOCK: Action = 2; break; // Update command block text
- case E_BLOCK_BEACON: Action = 3; break; // Update beacon entity
- case E_BLOCK_HEAD: Action = 4; break; // Update Mobhead entity
- case E_BLOCK_FLOWER_POT: Action = 5; break; // Update flower pot
- case E_BLOCK_BED: Action = 11; break; // Update bed color
- default: ASSERT(!"Unhandled or unimplemented BlockEntity update request!"); break;
- }
- Pkt.WriteBEUInt8(Action);
-
- WriteBlockEntity(Pkt, a_BlockEntity);
-}
-
-
-
-
-
void cProtocol_1_12::HandlePacketCraftingBookData(cByteBuffer & a_ByteBuffer)
{
a_ByteBuffer.SkipRead(a_ByteBuffer.GetReadableSpace() - 1);
@@ -1359,57 +1005,11 @@ void cProtocol_1_12::HandlePacketAdvancementTab(cByteBuffer & a_ByteBuffer)
-void cProtocol_1_12::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle)
-{
- ASSERT(m_State == 3); // In game mode?
- if (!a_DoDaylightCycle)
- {
- // When writing a "-" before the number the client ignores it but it will stop the client-side time expiration.
- a_TimeOfDay = std::min(-a_TimeOfDay, -1LL);
- }
-
- cPacketizer Pkt(*this, 0x46); // Time update packet
- Pkt.WriteBEInt64(a_WorldAge);
- Pkt.WriteBEInt64(a_TimeOfDay);
-}
-
-
-
-
-
-void cProtocol_1_12::SendSetRawTitle(const AString & a_Title)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x47); // Title packet
- Pkt.WriteVarInt32(0); // Set title
-
- Pkt.WriteString(a_Title);
-}
-
-
-
-
-
-void cProtocol_1_12::SendSetRawSubTitle(const AString & a_SubTitle)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x47); // Title packet
- Pkt.WriteVarInt32(1); // Set subtitle
-
- Pkt.WriteString(a_SubTitle);
-}
-
-
-
-
-
void cProtocol_1_12::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x47); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(3); // Set title display times
Pkt.WriteBEInt32(a_FadeInTicks);
Pkt.WriteBEInt32(a_DisplayTicks);
@@ -1424,7 +1024,7 @@ void cProtocol_1_12::SendHideTitle(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x47); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(4); // Hide title
}
@@ -1436,7 +1036,7 @@ void cProtocol_1_12::SendResetTitle(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x47); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(5); // Reset title
}
@@ -1448,7 +1048,7 @@ void cProtocol_1_12::SendCollectEntity(const cEntity & a_Entity, const cPlayer &
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x4a); // Collect Item packet
+ cPacketizer Pkt(*this, GetPacketId(sendCollectEntity)); // Collect Item packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteVarInt32(a_Player.GetUniqueID());
Pkt.WriteVarInt32(static_cast<UInt32>(a_Count));
@@ -1458,83 +1058,6 @@ void cProtocol_1_12::SendCollectEntity(const cEntity & a_Entity, const cPlayer &
-void cProtocol_1_12::SendTeleportEntity(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x4b); // Entity teleport packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEDouble(a_Entity.GetPosX());
- Pkt.WriteBEDouble(a_Entity.GetPosY());
- Pkt.WriteBEDouble(a_Entity.GetPosZ());
- Pkt.WriteByteAngle(a_Entity.GetYaw());
- Pkt.WriteByteAngle(a_Entity.GetPitch());
- Pkt.WriteBool(a_Entity.IsOnGround());
-}
-
-
-
-
-
-void cProtocol_1_12::SendEntityProperties(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
-
- cPacketizer Pkt(*this, 0x4d); // Entity Properties packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- WriteEntityProperties(Pkt, a_Entity);
-}
-
-
-
-
-
-void cProtocol_1_12::SendPlayerMaxSpeed(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x4d); // Entity Properties
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteVarInt32(Player->GetUniqueID());
- Pkt.WriteBEInt32(1); // Count
- Pkt.WriteString("generic.movementSpeed");
- // The default game speed is 0.1, multiply that value by the relative speed:
- Pkt.WriteBEDouble(0.1 * Player->GetNormalMaxSpeed());
- if (Player->IsSprinting())
- {
- Pkt.WriteVarInt32(1); // Modifier count
- Pkt.WriteBEUInt64(0x662a6b8dda3e4c1c);
- Pkt.WriteBEUInt64(0x881396ea6097278d); // UUID of the modifier
- Pkt.WriteBEDouble(Player->GetSprintingMaxSpeed() - Player->GetNormalMaxSpeed());
- Pkt.WriteBEUInt8(2);
- }
- else
- {
- Pkt.WriteVarInt32(0); // Modifier count
- }
-}
-
-
-
-
-
-void cProtocol_1_12::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x4e); // Entity Effect packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_Amplifier));
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Duration));
- Pkt.WriteBool(false); // Hide particles
-}
-
-
-
-
-
bool cProtocol_1_12::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
{
switch (m_State)
@@ -1668,7 +1191,6 @@ void cProtocol_1_12_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
ResponseValue["version"] = Version;
ResponseValue["players"] = Players;
ResponseValue["description"] = Description;
- m_Client->ForgeAugmentServerListPing(ResponseValue);
if (!Favicon.empty())
{
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
@@ -1684,631 +1206,6 @@ void cProtocol_1_12_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
-void cProtocol_1_12_1::SendRespawn(eDimension a_Dimension)
-{
- cPacketizer Pkt(*this, 0x35); // Respawn packet
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteBEInt32(static_cast<Int32>(a_Dimension));
- Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteBEUInt8(static_cast<Byte>(Player->GetEffectiveGameMode()));
- Pkt.WriteString("default");
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendPlayerListAddPlayer(const cPlayer & a_Player)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x2e); // Player List Item packet
- Pkt.WriteVarInt32(0);
- Pkt.WriteVarInt32(1);
- Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteString(a_Player.GetPlayerListName());
-
- const Json::Value & Properties = a_Player.GetClientHandle()->GetProperties();
- Pkt.WriteVarInt32(Properties.size());
- for (auto & Node : Properties)
- {
- Pkt.WriteString(Node.get("name", "").asString());
- Pkt.WriteString(Node.get("value", "").asString());
- AString Signature = Node.get("signature", "").asString();
- if (Signature.empty())
- {
- Pkt.WriteBool(false);
- }
- else
- {
- Pkt.WriteBool(true);
- Pkt.WriteString(Signature);
- }
- }
-
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetGameMode()));
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetClientHandle()->GetPing()));
- Pkt.WriteBool(false);
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendPlayerListRemovePlayer(const cPlayer & a_Player)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x2e); // Player List Item packet
- Pkt.WriteVarInt32(4);
- Pkt.WriteVarInt32(1);
- Pkt.WriteUUID(a_Player.GetUUID());
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendPlayerListUpdateGameMode(const cPlayer & a_Player)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x2e); // Player List Item packet
- Pkt.WriteVarInt32(1);
- Pkt.WriteVarInt32(1);
- Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetGameMode()));
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendPlayerListUpdatePing(const cPlayer & a_Player)
-{
- ASSERT(m_State == 3); // In game mode?
-
- auto ClientHandle = a_Player.GetClientHandlePtr();
- if (ClientHandle != nullptr)
- {
- cPacketizer Pkt(*this, 0x2e); // Player List Item packet
- Pkt.WriteVarInt32(2);
- Pkt.WriteVarInt32(1);
- Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteVarInt32(static_cast<UInt32>(ClientHandle->GetPing()));
- }
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x2e); // Player List Item packet
- Pkt.WriteVarInt32(3);
- Pkt.WriteVarInt32(1);
- Pkt.WriteUUID(a_Player.GetUUID());
-
- if (a_CustomName.empty())
- {
- Pkt.WriteBool(false);
- }
- else
- {
- Pkt.WriteBool(true);
- Pkt.WriteString(Printf("{\"text\":\"%s\"}", a_CustomName.c_str()));
- }
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendPlayerAbilities(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x2c); // Player Abilities packet
- Byte Flags = 0;
- cPlayer * Player = m_Client->GetPlayer();
- if (Player->IsGameModeCreative())
- {
- Flags |= 0x01;
- Flags |= 0x08; // Godmode, used for creative
- }
- if (Player->IsFlying())
- {
- Flags |= 0x02;
- }
- if (Player->CanFly())
- {
- Flags |= 0x04;
- }
- Pkt.WriteBEUInt8(Flags);
- Pkt.WriteBEFloat(static_cast<float>(0.05 * Player->GetFlyingMaxSpeed()));
- Pkt.WriteBEFloat(static_cast<float>(0.1 * Player->GetNormalMaxSpeed()));
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendPlayerMoveLook(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x2f); // Player Position And Look packet
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteBEDouble(Player->GetPosX());
- Pkt.WriteBEDouble(Player->GetPosY());
- Pkt.WriteBEDouble(Player->GetPosZ());
- Pkt.WriteBEFloat(static_cast<float>(Player->GetYaw()));
- Pkt.WriteBEFloat(static_cast<float>(Player->GetPitch()));
- Pkt.WriteBEUInt8(0);
- Pkt.WriteVarInt32(++m_OutstandingTeleportId);
-
- // This teleport ID hasn't been confirmed yet
- m_IsTeleportIdConfirmed = false;
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x30); // Use bed
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendDestroyEntity(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x32); // Destroy Entities packet
- Pkt.WriteVarInt32(1);
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x33); // Remove entity effect packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendEntityHeadLook(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x36); // Entity Head Look packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteByteAngle(a_Entity.GetHeadYaw());
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendCameraSetTo(const cEntity & a_Entity)
-{
- cPacketizer Pkt(*this, 0x39); // Camera packet (Attach the camera of a player at another entity in spectator mode)
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x3b); // Display Scoreboard packet
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_Display));
- Pkt.WriteString(a_Objective);
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendEntityMetadata(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x3c); // Entity Metadata packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- WriteEntityMetadata(Pkt, a_Entity);
- Pkt.WriteBEUInt8(0xff); // The termination byte
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo)
-{
- ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3d); // Set Attach Entity packet
- Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEUInt32(a_EntityLeashedTo.GetUniqueID());
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendUnleashEntity(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3d); // Set Attach Entity packet
- Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEInt32(-1); // Unleash a_Entity
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendEntityVelocity(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x3e); // Entity Velocity packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- // 400 = 8000 / 20 ... Conversion from our speed in m / s to 8000 m / tick
- Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedX() * 400));
- Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedY() * 400));
- Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedZ() * 400));
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x3f); // Entity Equipment packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- // Needs to be adjusted due to the insertion of offhand at slot 1
- if (a_SlotNum > 0)
- {
- a_SlotNum++;
- }
- Pkt.WriteVarInt32(static_cast<UInt32>(a_SlotNum));
- WriteItem(Pkt, a_Item);
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendExperience(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x40); // Set Experience packet
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteBEFloat(Player->GetXpPercentage());
- Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetXpLevel()));
- Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetCurrentXp()));
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendHealth(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x41); // Update Health packet
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteBEFloat(static_cast<float>(Player->GetHealth()));
- Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetFoodLevel()));
- Pkt.WriteBEFloat(static_cast<float>(Player->GetFoodSaturationLevel()));
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x42); // Scoreboard Objective packet
- Pkt.WriteString(a_Name);
- Pkt.WriteBEUInt8(a_Mode);
- if ((a_Mode == 0) || (a_Mode == 2))
- {
- Pkt.WriteString(a_DisplayName);
- Pkt.WriteString("integer");
- }
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle)
-{
- ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x43); // Set Passengers packet
- Pkt.WriteVarInt32(a_Vehicle.GetUniqueID());
- Pkt.WriteVarInt32(1); // 1 passenger
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle)
-{
- ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x43); // Set Passengers packet
- Pkt.WriteVarInt32(a_PreviousVehicle.GetUniqueID());
- Pkt.WriteVarInt32(0); // No passangers
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendScoreUpdate(const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x45); // Update Score packet
- Pkt.WriteString(a_Player);
- Pkt.WriteBEUInt8(a_Mode);
- Pkt.WriteString(a_Objective);
-
- if (a_Mode != 1)
- {
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Score));
- }
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
-{
- // Send the Join Game packet:
- {
- cServer * Server = cRoot::Get()->GetServer();
- cPacketizer Pkt(*this, 0x23); // Join Game packet
- Pkt.WriteBEUInt32(a_Player.GetUniqueID());
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
- Pkt.WriteBEInt32(static_cast<Int32>(a_World.GetDimension()));
- Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteBEUInt8(static_cast<UInt8>(Clamp<size_t>(Server->GetMaxPlayers(), 0, 255)));
- Pkt.WriteString("default"); // Level type - wtf?
- Pkt.WriteBool(false); // Reduced Debug Info - wtf?
- }
-
- // Send the spawn position:
- {
- cPacketizer Pkt(*this, 0x46); // Spawn Position packet
- Pkt.WritePosition64(FloorC(a_World.GetSpawnX()), FloorC(a_World.GetSpawnY()), FloorC(a_World.GetSpawnZ()));
- }
-
- // Send the server difficulty:
- {
- cPacketizer Pkt(*this, 0x0d); // Server difficulty packet
- Pkt.WriteBEInt8(1);
- }
-
- // Send player abilities:
- SendPlayerAbilities();
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle)
-{
- ASSERT(m_State == 3); // In game mode?
- if (!a_DoDaylightCycle)
- {
- // When writing a "-" before the number the client ignores it but it will stop the client-side time expiration.
- a_TimeOfDay = std::min(-a_TimeOfDay, -1LL);
- }
-
- cPacketizer Pkt(*this, 0x47); // Time update packet
- Pkt.WriteBEInt64(a_WorldAge);
- Pkt.WriteBEInt64(a_TimeOfDay);
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendSetRawTitle(const AString & a_Title)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x48); // Title packet
- Pkt.WriteVarInt32(0); // Set title
-
- Pkt.WriteString(a_Title);
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendSetRawSubTitle(const AString & a_SubTitle)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x48); // Title packet
- Pkt.WriteVarInt32(1); // Set subtitle
-
- Pkt.WriteString(a_SubTitle);
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x48); // Title packet
- Pkt.WriteVarInt32(3); // Set title display times
- Pkt.WriteBEInt32(a_FadeInTicks);
- Pkt.WriteBEInt32(a_DisplayTicks);
- Pkt.WriteBEInt32(a_FadeOutTicks);
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendHideTitle(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x48); // Title packet
- Pkt.WriteVarInt32(4); // Hide title
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendResetTitle(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x48); // Title packet
- Pkt.WriteVarInt32(5); // Reset title
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x4b); // Collect Item packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteVarInt32(a_Player.GetUniqueID());
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Count));
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendTeleportEntity(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x4c); // Entity teleport packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEDouble(a_Entity.GetPosX());
- Pkt.WriteBEDouble(a_Entity.GetPosY());
- Pkt.WriteBEDouble(a_Entity.GetPosZ());
- Pkt.WriteByteAngle(a_Entity.GetYaw());
- Pkt.WriteByteAngle(a_Entity.GetPitch());
- Pkt.WriteBool(a_Entity.IsOnGround());
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendEntityProperties(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
-
- cPacketizer Pkt(*this, 0x4e); // Entity Properties packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- WriteEntityProperties(Pkt, a_Entity);
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x4f); // Entity Effect packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_Amplifier));
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Duration));
- Pkt.WriteBool(false); // Hide particles
-}
-
-
-
-
-
-void cProtocol_1_12_1::SendPlayerMaxSpeed(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x4e); // Entity Properties
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteVarInt32(Player->GetUniqueID());
- Pkt.WriteBEInt32(1); // Count
- Pkt.WriteString("generic.movementSpeed");
- // The default game speed is 0.1, multiply that value by the relative speed:
- Pkt.WriteBEDouble(0.1 * Player->GetNormalMaxSpeed());
- if (Player->IsSprinting())
- {
- Pkt.WriteVarInt32(1); // Modifier count
- Pkt.WriteBEUInt64(0x662a6b8dda3e4c1c);
- Pkt.WriteBEUInt64(0x881396ea6097278d); // UUID of the modifier
- Pkt.WriteBEDouble(Player->GetSprintingMaxSpeed() - Player->GetNormalMaxSpeed());
- Pkt.WriteBEUInt8(2);
- }
- else
- {
- Pkt.WriteVarInt32(0); // Modifier count
- }
-}
-
-
-
-
-
bool cProtocol_1_12_1::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
{
switch (m_State)
diff --git a/src/Protocol/Protocol_1_12.h b/src/Protocol/Protocol_1_12.h
index 17d7d4e86..9b87494a6 100644
--- a/src/Protocol/Protocol_1_12.h
+++ b/src/Protocol/Protocol_1_12.h
@@ -30,40 +30,11 @@ class cProtocol_1_12 :
public:
cProtocol_1_12(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
- virtual void SendAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle) override;
- virtual void SendCameraSetTo(const cEntity & a_Entity) override;
virtual void SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) override;
- virtual void SendDestroyEntity(const cEntity & a_Entity) override;
- virtual void SendDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
- virtual void SendDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override;
- virtual void SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
- virtual void SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
- virtual void SendEntityHeadLook(const cEntity & a_Entity) override;
- virtual void SendEntityLook(const cEntity & a_Entity) override;
- virtual void SendEntityMetadata(const cEntity & a_Entity) override;
- virtual void SendEntityProperties(const cEntity & a_Entity) override;
- virtual void SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
- virtual void SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
- virtual void SendEntityVelocity(const cEntity & a_Entity) override;
- virtual void SendExperience(void) override;
- virtual void SendHealth(void) override;
virtual void SendHideTitle(void) override;
- virtual void SendLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo) override;
- virtual void SendLogin(const cPlayer & a_Player, const cWorld & a_World) override;
- virtual void SendPlayerMaxSpeed(void) override;
- virtual void SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) override;
virtual void SendResetTitle(void) override;
- virtual void SendRespawn(eDimension a_Dimension) override;
- virtual void SendScoreUpdate(const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override;
- virtual void SendScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
- virtual void SendSetRawSubTitle(const AString & a_SubTitle) override;
- virtual void SendSetRawTitle(const AString & a_Title) override;
virtual void SendSpawnMob(const cMonster & a_Mob) override;
- virtual void SendTeleportEntity(const cEntity & a_Entity) override;
- virtual void SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle) override;
virtual void SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) override;
- virtual void SendUpdateBlockEntity(cBlockEntity & a_BlockEntity) override;
- virtual void SendUnleashEntity(const cEntity & a_Entity) override;
protected:
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
virtual void HandlePacketAdvancementTab(cByteBuffer & a_ByteBuffer);
@@ -72,6 +43,10 @@ protected:
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) override;
virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) override;
+
+protected:
+
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
};
@@ -86,45 +61,9 @@ class cProtocol_1_12_1 :
public:
cProtocol_1_12_1(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
- virtual void SendRespawn(eDimension a_Dimension) override;
- virtual void SendPlayerListAddPlayer(const cPlayer & a_Player) override;
- virtual void SendPlayerListRemovePlayer(const cPlayer & a_Player) override;
- virtual void SendPlayerListUpdateGameMode(const cPlayer & a_Player) override;
- virtual void SendPlayerListUpdatePing(const cPlayer & a_Player) override;
- virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) override;
- virtual void SendPlayerAbilities(void) override;
- virtual void SendPlayerMoveLook(void) override;
- virtual void SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override;
- virtual void SendDestroyEntity(const cEntity & a_Entity) override;
- virtual void SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) override;
- virtual void SendEntityHeadLook(const cEntity & a_Entity) override;
- virtual void SendCameraSetTo(const cEntity & a_Entity) override;
- virtual void SendDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override;
- virtual void SendEntityMetadata(const cEntity & a_Entity) override;
- virtual void SendLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo) override;
- virtual void SendUnleashEntity(const cEntity & a_Entity) override;
- virtual void SendEntityVelocity(const cEntity & a_Entity) override;
- virtual void SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
- virtual void SendExperience(void) override;
- virtual void SendHealth(void) override;
- virtual void SendScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
- virtual void SendAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle) override;
- virtual void SendDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
- virtual void SendScoreUpdate(const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override;
- virtual void SendLogin(const cPlayer & a_Player, const cWorld & a_World) override;
- virtual void SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle) override;
- virtual void SendHideTitle(void) override;
- virtual void SendResetTitle(void) override;
- virtual void SendSetRawSubTitle(const AString & a_SubTitle) override;
- virtual void SendSetRawTitle(const AString & a_Title) override;
- virtual void SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) override;
- virtual void SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) override;
- virtual void SendTeleportEntity(const cEntity & a_Entity) override;
- virtual void SendEntityProperties(const cEntity & a_Entity) override;
- virtual void SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
- virtual void SendPlayerMaxSpeed(void) override;
-
protected:
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
+
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
};
diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h
index d3d0daf0a..108cc9798 100644
--- a/src/Protocol/Protocol_1_8.h
+++ b/src/Protocol/Protocol_1_8.h
@@ -173,6 +173,13 @@ protected:
/** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */
void AddReceivedData(const char * a_Data, size_t a_Size);
+ /** Nobody inherits 1.8, so it doesn't use this method */
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override
+ {
+ ASSERT(!"GetPacketId for cProtocol_1_8_0 is not implemented.");
+ return 0;
+ }
+
/** Reads and handles the packet. The packet length and type have already been read.
Returns true if the packet was understood, false if it was an unknown packet
*/
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index 5267c7a8a..9f30e559d 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -216,7 +216,7 @@ void cProtocol_1_9_0::DataReceived(const char * a_Data, size_t a_Size)
void cProtocol_1_9_0::SendAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x40); // Set passangers packet
+ cPacketizer Pkt(*this, GetPacketId(sendAttachEntity)); // Set passangers packet
Pkt.WriteVarInt32(a_Vehicle.GetUniqueID());
Pkt.WriteVarInt32(1); // 1 passenger
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
@@ -230,7 +230,7 @@ void cProtocol_1_9_0::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ,
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x0a); // Block Action packet
+ cPacketizer Pkt(*this, GetPacketId(sendBlockAction)); // Block Action packet
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
Pkt.WriteBEInt8(a_Byte1);
Pkt.WriteBEInt8(a_Byte2);
@@ -245,7 +245,7 @@ void cProtocol_1_9_0::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x08); // Block Break Animation packet
+ cPacketizer Pkt(*this, GetPacketId(sendBlockBreakAnim)); // Block Break Animation packet
Pkt.WriteVarInt32(a_EntityID);
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
Pkt.WriteBEInt8(a_Stage);
@@ -259,7 +259,7 @@ void cProtocol_1_9_0::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ,
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x0b); // Block Change packet
+ cPacketizer Pkt(*this, GetPacketId(sendBlockChange)); // Block Change packet
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
Pkt.WriteVarInt32((static_cast<UInt32>(a_BlockType) << 4) | (static_cast<UInt32>(a_BlockMeta) & 15));
}
@@ -272,7 +272,7 @@ void cProtocol_1_9_0::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlo
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x10); // Multi Block Change packet
+ cPacketizer Pkt(*this, GetPacketId(sendBlockChanges)); // Multi Block Change packet
Pkt.WriteBEInt32(a_ChunkX);
Pkt.WriteBEInt32(a_ChunkZ);
Pkt.WriteVarInt32(static_cast<UInt32>(a_Changes.size()));
@@ -290,7 +290,7 @@ void cProtocol_1_9_0::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlo
void cProtocol_1_9_0::SendCameraSetTo(const cEntity & a_Entity)
{
- cPacketizer Pkt(*this, 0x36); // Camera Packet (Attach the camera of a player at another entity in spectator mode)
+ cPacketizer Pkt(*this, GetPacketId(sendCameraSetTo)); // Camera Packet (Attach the camera of a player at another entity in spectator mode)
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
}
@@ -325,7 +325,7 @@ void cProtocol_1_9_0::SendChatRaw(const AString & a_MessageRaw, eChatType a_Type
ASSERT(m_State == 3); // In game mode?
// Send the json string to the client:
- cPacketizer Pkt(*this, 0x0f); // Chat Message packet
+ cPacketizer Pkt(*this, GetPacketId(sendChatRaw)); // Chat Message packet
Pkt.WriteString(a_MessageRaw);
Pkt.WriteBEInt8(a_Type);
}
@@ -355,7 +355,7 @@ void cProtocol_1_9_0::SendCollectEntity(const cEntity & a_Entity, const cPlayer
UNUSED(a_Count);
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x49); // Collect Item packet
+ cPacketizer Pkt(*this, GetPacketId(sendCollectEntity)); // Collect Item packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteVarInt32(a_Player.GetUniqueID());
}
@@ -368,7 +368,7 @@ void cProtocol_1_9_0::SendDestroyEntity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x30); // Destroy Entities packet
+ cPacketizer Pkt(*this, GetPacketId(sendDestroyEntity)); // Destroy Entities packet
Pkt.WriteVarInt32(1);
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
}
@@ -380,7 +380,7 @@ void cProtocol_1_9_0::SendDestroyEntity(const cEntity & a_Entity)
void cProtocol_1_9_0::SendDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x40); // Set passangers packet
+ cPacketizer Pkt(*this, GetPacketId(sendAttachEntity)); // Set passangers packet
Pkt.WriteVarInt32(a_PreviousVehicle.GetUniqueID());
Pkt.WriteVarInt32(0); // No passangers
}
@@ -396,14 +396,14 @@ void cProtocol_1_9_0::SendDisconnect(const AString & a_Reason)
case 2:
{
// During login:
- cPacketizer Pkt(*this, 0);
+ cPacketizer Pkt(*this, GetPacketId(sendDisconnectDuringLogin));
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str()));
break;
}
case 3:
{
// In-game:
- cPacketizer Pkt(*this, 0x1a);
+ cPacketizer Pkt(*this, GetPacketId(sendDisconnectDuringGame));
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str()));
break;
}
@@ -418,7 +418,7 @@ void cProtocol_1_9_0::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x2a); // Sign Editor Open packet
+ cPacketizer Pkt(*this, GetPacketId(sendEditSign)); // Sign Editor Open packet
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
}
@@ -430,7 +430,7 @@ void cProtocol_1_9_0::SendEntityEffect(const cEntity & a_Entity, int a_EffectID,
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x4c); // Entity Effect packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityEffect)); // Entity Effect packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Amplifier));
@@ -446,7 +446,7 @@ void cProtocol_1_9_0::SendEntityEquipment(const cEntity & a_Entity, short a_Slot
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3c); // Entity Equipment packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityEquipment)); // Entity Equipment packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
// Needs to be adjusted due to the insertion of offhand at slot 1
if (a_SlotNum > 0)
@@ -465,7 +465,7 @@ void cProtocol_1_9_0::SendEntityHeadLook(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x34); // Entity Head Look packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityHeadLook)); // Entity Head Look packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetHeadYaw());
}
@@ -478,7 +478,7 @@ void cProtocol_1_9_0::SendEntityLook(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x27); // Entity Look packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityLook)); // Entity Look packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetYaw());
Pkt.WriteByteAngle(a_Entity.GetPitch());
@@ -493,7 +493,7 @@ void cProtocol_1_9_0::SendEntityMetadata(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x39); // Entity Metadata packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityMeta)); // Entity Metadata packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
WriteEntityMetadata(Pkt, a_Entity);
Pkt.WriteBEUInt8(0xff); // The termination byte
@@ -507,7 +507,7 @@ void cProtocol_1_9_0::SendEntityProperties(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x4b); // Entity Properties packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityProperties)); // Entity Properties packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
WriteEntityProperties(Pkt, a_Entity);
}
@@ -520,7 +520,7 @@ void cProtocol_1_9_0::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, c
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x25); // Entity Relative Move packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityRelMove)); // Entity Relative Move packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
// TODO: 1.9 changed these from chars to shorts, meaning that there can be more percision and data. Other code needs to be updated for that.
Pkt.WriteBEInt16(a_RelX * 128);
@@ -537,7 +537,7 @@ void cProtocol_1_9_0::SendEntityRelMoveLook(const cEntity & a_Entity, char a_Rel
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x26); // Entity Look And Relative Move packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityRelMoveLook)); // Entity Look And Relative Move packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
// TODO: 1.9 changed these from chars to shorts, meaning that there can be more percision and data. Other code needs to be updated for that.
Pkt.WriteBEInt16(a_RelX * 128);
@@ -556,7 +556,7 @@ void cProtocol_1_9_0::SendEntityStatus(const cEntity & a_Entity, char a_Status)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x1b); // Entity Status packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityStatus)); // Entity Status packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_Status);
}
@@ -569,7 +569,7 @@ void cProtocol_1_9_0::SendEntityVelocity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3b); // Entity Velocity packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityVelocity)); // Entity Velocity packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
// 400 = 8000 / 20 ... Conversion from our speed in m / s to 8000 m / tick
Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedX() * 400));
@@ -585,7 +585,7 @@ void cProtocol_1_9_0::SendExplosion(double a_BlockX, double a_BlockY, double a_B
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x1c); // Explosion packet
+ cPacketizer Pkt(*this, GetPacketId(sendExplosion)); // Explosion packet
Pkt.WriteBEFloat(static_cast<float>(a_BlockX));
Pkt.WriteBEFloat(static_cast<float>(a_BlockY));
Pkt.WriteBEFloat(static_cast<float>(a_BlockZ));
@@ -610,7 +610,7 @@ void cProtocol_1_9_0::SendGameMode(eGameMode a_GameMode)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x1e); // Change Game State packet
+ cPacketizer Pkt(*this, GetPacketId(sendGameMode)); // Change Game State packet
Pkt.WriteBEUInt8(3); // Reason: Change game mode
Pkt.WriteBEFloat(static_cast<float>(a_GameMode)); // The protocol really represents the value with a float!
}
@@ -623,7 +623,7 @@ void cProtocol_1_9_0::SendHealth(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3e); // Update Health packet
+ cPacketizer Pkt(*this, GetPacketId(sendHealth)); // Update Health packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEFloat(static_cast<float>(Player->GetHealth()));
Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetFoodLevel()));
@@ -638,7 +638,7 @@ void cProtocol_1_9_0::SendHideTitle(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x45); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(3); // Hide title
}
@@ -650,7 +650,7 @@ void cProtocol_1_9_0::SendInventorySlot(char a_WindowID, short a_SlotNum, const
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x16); // Set Slot packet
+ cPacketizer Pkt(*this, GetPacketId(sendInventorySlot)); // Set Slot packet
Pkt.WriteBEInt8(a_WindowID);
Pkt.WriteBEInt16(a_SlotNum);
WriteItem(Pkt, a_Item);
@@ -669,7 +669,7 @@ void cProtocol_1_9_0::SendKeepAlive(UInt32 a_PingID)
return;
}
- cPacketizer Pkt(*this, 0x1f); // Keep Alive packet
+ cPacketizer Pkt(*this, GetPacketId(sendKeepAlive)); // Keep Alive packet
Pkt.WriteVarInt32(a_PingID);
}
@@ -680,7 +680,7 @@ void cProtocol_1_9_0::SendKeepAlive(UInt32 a_PingID)
void cProtocol_1_9_0::SendLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3a); // Set Attach Entity packet
+ cPacketizer Pkt(*this, GetPacketId(sendLeashEntity)); // Set Attach Entity packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt32(a_EntityLeashedTo.GetUniqueID());
}
@@ -692,7 +692,7 @@ void cProtocol_1_9_0::SendLeashEntity(const cEntity & a_Entity, const cEntity &
void cProtocol_1_9_0::SendUnleashEntity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3a); // Set Attach Entity packet
+ cPacketizer Pkt(*this, GetPacketId(sendLeashEntity)); // Set Attach Entity packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt32(-1); // Unleash a_Entity
}
@@ -706,7 +706,7 @@ void cProtocol_1_9_0::SendLogin(const cPlayer & a_Player, const cWorld & a_World
// Send the Join Game packet:
{
cServer * Server = cRoot::Get()->GetServer();
- cPacketizer Pkt(*this, 0x23); // Join Game packet
+ cPacketizer Pkt(*this, GetPacketId(sendJoinGame)); // Join Game packet
Pkt.WriteBEUInt32(a_Player.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
Pkt.WriteBEInt8(static_cast<Int8>(a_World.GetDimension()));
@@ -718,13 +718,13 @@ void cProtocol_1_9_0::SendLogin(const cPlayer & a_Player, const cWorld & a_World
// Send the spawn position:
{
- cPacketizer Pkt(*this, 0x43); // Spawn Position packet
+ cPacketizer Pkt(*this, GetPacketId(sendSpawnPosition)); // Spawn Position packet
Pkt.WritePosition64(FloorC(a_World.GetSpawnX()), FloorC(a_World.GetSpawnY()), FloorC(a_World.GetSpawnZ()));
}
// Send the server difficulty:
{
- cPacketizer Pkt(*this, 0x0d); // Server difficulty packet
+ cPacketizer Pkt(*this, GetPacketId(sendDifficulty)); // Server difficulty packet
Pkt.WriteBEInt8(1);
}
@@ -765,7 +765,7 @@ void cProtocol_1_9_0::SendPaintingSpawn(const cPainting & a_Painting)
double PosY = a_Painting.GetPosY();
double PosZ = a_Painting.GetPosZ();
- cPacketizer Pkt(*this, 0x04); // Spawn Painting packet
+ cPacketizer Pkt(*this, GetPacketId(sendPaintingSpawn)); // Spawn Painting packet
Pkt.WriteVarInt32(a_Painting.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
@@ -783,7 +783,7 @@ void cProtocol_1_9_0::SendMapData(const cMap & a_Map, int a_DataStartX, int a_Da
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x24); // Map packet
+ cPacketizer Pkt(*this, GetPacketId(sendMapData)); // Map packet
Pkt.WriteVarInt32(a_Map.GetID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Map.GetScale()));
@@ -816,7 +816,7 @@ void cProtocol_1_9_0::SendPickupSpawn(const cPickup & a_Pickup)
ASSERT(m_State == 3); // In game mode?
{ // TODO Use SendSpawnObject
- cPacketizer Pkt(*this, 0x00); // Spawn Object packet
+ cPacketizer Pkt(*this, GetPacketId(sendSpawnObject)); // Spawn Object packet
Pkt.WriteVarInt32(a_Pickup.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
@@ -844,7 +844,7 @@ void cProtocol_1_9_0::SendPlayerAbilities(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x2b); // Player Abilities packet
+ cPacketizer Pkt(*this, GetPacketId(sendPlayerAbilities)); // Player Abilities packet
Byte Flags = 0;
cPlayer * Player = m_Client->GetPlayer();
if (Player->IsGameModeCreative())
@@ -873,7 +873,7 @@ void cProtocol_1_9_0::SendEntityAnimation(const cEntity & a_Entity, char a_Anima
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x06); // Animation packet
+ cPacketizer Pkt(*this, GetPacketId(sendEntityAnimation)); // Animation packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_Animation);
}
@@ -887,7 +887,7 @@ void cProtocol_1_9_0::SendParticleEffect(const AString & a_ParticleName, float a
ASSERT(m_State == 3); // In game mode?
int ParticleID = GetParticleID(a_ParticleName);
- cPacketizer Pkt(*this, 0x22); // Particle effect packet
+ cPacketizer Pkt(*this, GetPacketId(sendParticleEffect)); // Particle effect packet
Pkt.WriteBEInt32(ParticleID);
Pkt.WriteBool(false);
Pkt.WriteBEFloat(a_SrcX);
@@ -909,7 +909,7 @@ void cProtocol_1_9_0::SendParticleEffect(const AString & a_ParticleName, Vector3
ASSERT(m_State == 3); // In game mode?
int ParticleID = GetParticleID(a_ParticleName);
- cPacketizer Pkt(*this, 0x22); // Particle effect packet
+ cPacketizer Pkt(*this, GetPacketId(sendParticleEffect)); // Particle effect packet
Pkt.WriteBEInt32(ParticleID);
Pkt.WriteBool(false);
Pkt.WriteBEFloat(a_Src.x);
@@ -952,7 +952,7 @@ void cProtocol_1_9_0::SendPlayerListAddPlayer(const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet
+ cPacketizer Pkt(*this, GetPacketId(sendPlayerList)); // Playerlist Item packet
Pkt.WriteVarInt32(0);
Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
@@ -989,7 +989,7 @@ void cProtocol_1_9_0::SendPlayerListRemovePlayer(const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet
+ cPacketizer Pkt(*this, GetPacketId(sendPlayerList)); // Playerlist Item packet
Pkt.WriteVarInt32(4);
Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
@@ -1003,7 +1003,7 @@ void cProtocol_1_9_0::SendPlayerListUpdateGameMode(const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet
+ cPacketizer Pkt(*this, GetPacketId(sendPlayerList)); // Playerlist Item packet
Pkt.WriteVarInt32(1);
Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
@@ -1021,7 +1021,7 @@ void cProtocol_1_9_0::SendPlayerListUpdatePing(const cPlayer & a_Player)
auto ClientHandle = a_Player.GetClientHandlePtr();
if (ClientHandle != nullptr)
{
- cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet
+ cPacketizer Pkt(*this, GetPacketId(sendPlayerList)); // Playerlist Item packet
Pkt.WriteVarInt32(2);
Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
@@ -1037,7 +1037,7 @@ void cProtocol_1_9_0::SendPlayerListUpdateDisplayName(const cPlayer & a_Player,
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet
+ cPacketizer Pkt(*this, GetPacketId(sendPlayerList)); // Playerlist Item packet
Pkt.WriteVarInt32(3);
Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
@@ -1061,7 +1061,7 @@ void cProtocol_1_9_0::SendPlayerMaxSpeed(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x4b); // Entity Properties
+ cPacketizer Pkt(*this, GetPacketId(sendPlayerMaxSpeed)); // Entity Properties
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteVarInt32(Player->GetUniqueID());
Pkt.WriteBEInt32(1); // Count
@@ -1090,7 +1090,7 @@ void cProtocol_1_9_0::SendPlayerMoveLook(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x2e); // Player Position And Look packet
+ cPacketizer Pkt(*this, GetPacketId(sendPlayerMoveLook)); // Player Position And Look packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEDouble(Player->GetPosX());
Pkt.WriteBEDouble(Player->GetPosY());
@@ -1121,7 +1121,7 @@ void cProtocol_1_9_0::SendPlayerPosition(void)
void cProtocol_1_9_0::SendPlayerSpawn(const cPlayer & a_Player)
{
// Called to spawn another player for the client
- cPacketizer Pkt(*this, 0x05); // Spawn Player packet
+ cPacketizer Pkt(*this, GetPacketId(sendPlayerSpawn)); // Spawn Player packet
Pkt.WriteVarInt32(a_Player.GetUniqueID());
Pkt.WriteUUID(a_Player.GetUUID());
Vector3d LastSentPos = a_Player.GetLastSentPos();
@@ -1142,7 +1142,7 @@ void cProtocol_1_9_0::SendPluginMessage(const AString & a_Channel, const AString
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x18); // Plugin message packet
+ cPacketizer Pkt(*this, GetPacketId(sendPluginMessage)); // Plugin message packet
Pkt.WriteString(a_Channel);
Pkt.WriteBuf(a_Message.data(), a_Message.size());
}
@@ -1155,7 +1155,7 @@ void cProtocol_1_9_0::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Eff
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x31); // Remove entity effect packet
+ cPacketizer Pkt(*this, GetPacketId(sendRemoveEntityEffect)); // Remove entity effect packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
}
@@ -1168,7 +1168,7 @@ void cProtocol_1_9_0::SendResetTitle(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x45); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(4); // Reset title
}
@@ -1178,7 +1178,7 @@ void cProtocol_1_9_0::SendResetTitle(void)
void cProtocol_1_9_0::SendRespawn(eDimension a_Dimension)
{
- cPacketizer Pkt(*this, 0x33); // Respawn packet
+ cPacketizer Pkt(*this, GetPacketId(sendRespawn)); // Respawn packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEInt32(static_cast<Int32>(a_Dimension));
Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
@@ -1194,7 +1194,7 @@ void cProtocol_1_9_0::SendExperience(void)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3d); // Experience Packet
+ cPacketizer Pkt(*this, GetPacketId(sendExperience)); // Experience Packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEFloat(Player->GetXpPercentage());
Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetXpLevel()));
@@ -1209,7 +1209,7 @@ void cProtocol_1_9_0::SendExperienceOrb(const cExpOrb & a_ExpOrb)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x01); // Spawn experience orb packet
+ cPacketizer Pkt(*this, GetPacketId(sendExperienceOrb)); // Spawn experience orb packet
Pkt.WriteVarInt32(a_ExpOrb.GetUniqueID());
Pkt.WriteBEDouble(a_ExpOrb.GetPosX());
Pkt.WriteBEDouble(a_ExpOrb.GetPosY());
@@ -1225,7 +1225,7 @@ void cProtocol_1_9_0::SendScoreboardObjective(const AString & a_Name, const AStr
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x3f); // Scoreboard objective packet
+ cPacketizer Pkt(*this, GetPacketId(sendScoreboardObjective)); // Scoreboard objective packet
Pkt.WriteString(a_Name);
Pkt.WriteBEUInt8(a_Mode);
if ((a_Mode == 0) || (a_Mode == 2))
@@ -1243,7 +1243,7 @@ void cProtocol_1_9_0::SendScoreUpdate(const AString & a_Objective, const AString
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x42); // Update score packet
+ cPacketizer Pkt(*this, GetPacketId(sendScoreUpdate)); // Update score packet
Pkt.WriteString(a_Player);
Pkt.WriteBEUInt8(a_Mode);
Pkt.WriteString(a_Objective);
@@ -1262,7 +1262,7 @@ void cProtocol_1_9_0::SendDisplayObjective(const AString & a_Objective, cScorebo
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x38); // Display scoreboard packet
+ cPacketizer Pkt(*this, GetPacketId(sendDisplayObjective)); // Display scoreboard packet
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Display));
Pkt.WriteString(a_Objective);
}
@@ -1284,7 +1284,7 @@ void cProtocol_1_9_0::SendSetRawSubTitle(const AString & a_SubTitle)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x45); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(1); // Set subtitle
Pkt.WriteString(a_SubTitle);
@@ -1307,7 +1307,7 @@ void cProtocol_1_9_0::SendSetRawTitle(const AString & a_Title)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x45); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(0); // Set title
Pkt.WriteString(a_Title);
@@ -1321,7 +1321,7 @@ void cProtocol_1_9_0::SendSoundEffect(const AString & a_SoundName, double a_X, d
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x19); // Named sound effect packet
+ cPacketizer Pkt(*this, GetPacketId(sendSoundEffect)); // Named sound effect packet
Pkt.WriteString(a_SoundName);
Pkt.WriteVarInt32(0); // Master sound category (may want to be changed to a parameter later)
Pkt.WriteBEInt32(static_cast<Int32>(a_X * 8.0));
@@ -1339,7 +1339,7 @@ void cProtocol_1_9_0::SendSoundParticleEffect(const EffectID a_EffectID, int a_S
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x21); // Effect packet
+ cPacketizer Pkt(*this, GetPacketId(sendSoundParticleEffect)); // Effect packet
Pkt.WriteBEInt32(static_cast<int>(a_EffectID));
Pkt.WritePosition64(a_SrcX, a_SrcY, a_SrcZ);
Pkt.WriteBEInt32(a_Data);
@@ -1354,7 +1354,7 @@ void cProtocol_1_9_0::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x00); // Spawn Object packet
+ cPacketizer Pkt(*this, GetPacketId(sendSpawnObject)); // Spawn Object packet
Pkt.WriteVarInt32(a_FallingBlock.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
@@ -1380,7 +1380,7 @@ void cProtocol_1_9_0::SendSpawnMob(const cMonster & a_Mob)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x03); // Spawn Mob packet
+ cPacketizer Pkt(*this, GetPacketId(sendSpawnMob)); // Spawn Mob packet
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
@@ -1415,7 +1415,7 @@ void cProtocol_1_9_0::SendSpawnObject(const cEntity & a_Entity, char a_ObjectTyp
FixItemFramePositions(a_ObjectData, PosX, PosZ, Yaw);
}
- cPacketizer Pkt(*this, 0x00); // Spawn Object packet
+ cPacketizer Pkt(*this, GetPacketId(sendSpawnObject)); // Spawn Object packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
@@ -1440,7 +1440,7 @@ void cProtocol_1_9_0::SendSpawnVehicle(const cEntity & a_Vehicle, char a_Vehicle
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x00); // Spawn Object packet
+ cPacketizer Pkt(*this, GetPacketId(sendSpawnObject)); // Spawn Object packet
Pkt.WriteVarInt32(a_Vehicle.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
@@ -1466,7 +1466,7 @@ void cProtocol_1_9_0::SendStatistics(const cStatManager & a_Manager)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x07); // Statistics packet
+ cPacketizer Pkt(*this, GetPacketId(sendStatistics)); // Statistics packet
Pkt.WriteVarInt32(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
size_t Count = static_cast<size_t>(statCount);
@@ -1488,7 +1488,7 @@ void cProtocol_1_9_0::SendTabCompletionResults(const AStringVector & a_Results)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x0e); // Tab-Complete packet
+ cPacketizer Pkt(*this, GetPacketId(sendTabCompletion)); // Tab-Complete packet
Pkt.WriteVarInt32(static_cast<UInt32>(a_Results.size()));
for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr)
@@ -1505,7 +1505,7 @@ void cProtocol_1_9_0::SendTeleportEntity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x4a); // Entity teleport packet
+ cPacketizer Pkt(*this, GetPacketId(sendTeleportEntity)); // Entity teleport packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEDouble(a_Entity.GetPosX());
Pkt.WriteBEDouble(a_Entity.GetPosY());
@@ -1523,7 +1523,7 @@ void cProtocol_1_9_0::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x02); // Spawn Global Entity packet
+ cPacketizer Pkt(*this, GetPacketId(sendSpawnGlobalEntity)); // Spawn Global Entity packet
Pkt.WriteVarInt32(0); // EntityID = 0, always
Pkt.WriteBEUInt8(1); // Type = Thunderbolt
Pkt.WriteBEDouble(a_BlockX);
@@ -1539,7 +1539,7 @@ void cProtocol_1_9_0::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x45); // Title packet
+ cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
Pkt.WriteVarInt32(2); // Set title display times
Pkt.WriteBEInt32(a_FadeInTicks);
@@ -1560,7 +1560,7 @@ void cProtocol_1_9_0::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a
a_TimeOfDay = std::min(-a_TimeOfDay, -1LL);
}
- cPacketizer Pkt(*this, 0x44); // Time update packet
+ cPacketizer Pkt(*this, GetPacketId(sendTimeUpdate)); // Time update packet
Pkt.WriteBEInt64(a_WorldAge);
Pkt.WriteBEInt64(a_TimeOfDay);
}
@@ -1573,7 +1573,7 @@ void cProtocol_1_9_0::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x1d); // Unload chunk packet
+ cPacketizer Pkt(*this, GetPacketId(sendUnloadChunk)); // Unload chunk packet
Pkt.WriteBEInt32(a_ChunkX);
Pkt.WriteBEInt32(a_ChunkZ);
}
@@ -1585,7 +1585,7 @@ void cProtocol_1_9_0::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x09); // Update tile entity packet
+ cPacketizer Pkt(*this, GetPacketId(sendUpdateBlockEntity)); // Update tile entity packet
Pkt.WritePosition64(a_BlockEntity.GetPosX(), a_BlockEntity.GetPosY(), a_BlockEntity.GetPosZ());
Byte Action = 0;
@@ -1612,7 +1612,7 @@ void cProtocol_1_9_0::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, c
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x46); // Update sign packet
+ cPacketizer Pkt(*this, GetPacketId(sendUpdateSign)); // Update sign packet
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
Json::StyledWriter JsonWriter;
@@ -1633,7 +1633,7 @@ void cProtocol_1_9_0::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_B
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x2f); // Use bed
+ cPacketizer Pkt(*this, GetPacketId(sendUseBed)); // Use bed
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
}
@@ -1647,7 +1647,7 @@ void cProtocol_1_9_0::SendWeather(eWeather a_Weather)
ASSERT(m_State == 3); // In game mode?
{
- cPacketizer Pkt(*this, 0x1e); // Change Game State packet
+ cPacketizer Pkt(*this, GetPacketId(sendWeather)); // Change Game State packet
Pkt.WriteBEUInt8((a_Weather == wSunny) ? 1 : 2); // End rain / begin rain
Pkt.WriteBEFloat(0); // Unused for weather
}
@@ -1663,7 +1663,7 @@ void cProtocol_1_9_0::SendWholeInventory(const cWindow & a_Window)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x14); // Window Items packet
+ cPacketizer Pkt(*this, GetPacketId(sendWindowItems)); // Window Items packet
Pkt.WriteBEInt8(a_Window.GetWindowID());
Pkt.WriteBEInt16(static_cast<Int16>(a_Window.GetNumSlots()));
cItems Slots;
@@ -1682,7 +1682,7 @@ void cProtocol_1_9_0::SendWindowClose(const cWindow & a_Window)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x12); // Close window packet
+ cPacketizer Pkt(*this, GetPacketId(sendWindowClose)); // Close window packet
Pkt.WriteBEInt8(a_Window.GetWindowID());
}
@@ -1700,7 +1700,7 @@ void cProtocol_1_9_0::SendWindowOpen(const cWindow & a_Window)
return;
}
- cPacketizer Pkt(*this, 0x13); // Open window packet
+ cPacketizer Pkt(*this, GetPacketId(sendWindowOpen)); // Open window packet
Pkt.WriteBEInt8(a_Window.GetWindowID());
Pkt.WriteString(a_Window.GetWindowTypeName());
Pkt.WriteString(Printf("{\"text\":\"%s\"}", a_Window.GetWindowTitle().c_str()));
@@ -1735,7 +1735,7 @@ void cProtocol_1_9_0::SendWindowProperty(const cWindow & a_Window, short a_Prope
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x15); // Window Property packet
+ cPacketizer Pkt(*this, GetPacketId(sendWindowProperty)); // Window Property packet
Pkt.WriteBEInt8(a_Window.GetWindowID());
Pkt.WriteBEInt16(a_Property);
Pkt.WriteBEInt16(a_Value);
@@ -4176,10 +4176,10 @@ void cProtocol_1_9_1::SendLogin(const cPlayer & a_Player, const cWorld & a_World
// Send the Join Game packet:
{
cServer * Server = cRoot::Get()->GetServer();
- cPacketizer Pkt(*this, 0x23); // Join Game packet
+ cPacketizer Pkt(*this, GetPacketId(sendJoinGame)); // Join Game packet
Pkt.WriteBEUInt32(a_Player.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
- Pkt.WriteBEInt32(static_cast<Int32>(a_World.GetDimension()));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_World.GetDimension())); // This is the change from 1.9.0 (Int8 to Int32)
Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
Pkt.WriteBEUInt8(static_cast<UInt8>(Clamp<size_t>(Server->GetMaxPlayers(), 0, 255)));
Pkt.WriteString("default"); // Level type - wtf?
@@ -4188,13 +4188,13 @@ void cProtocol_1_9_1::SendLogin(const cPlayer & a_Player, const cWorld & a_World
// Send the spawn position:
{
- cPacketizer Pkt(*this, 0x43); // Spawn Position packet
+ cPacketizer Pkt(*this, GetPacketId(sendSpawnPosition)); // Spawn Position packet
Pkt.WritePosition64(FloorC(a_World.GetSpawnX()), FloorC(a_World.GetSpawnY()), FloorC(a_World.GetSpawnZ()));
}
// Send the server difficulty:
{
- cPacketizer Pkt(*this, 0x0d); // Server difficulty packet
+ cPacketizer Pkt(*this, GetPacketId(sendDifficulty)); // Server difficulty packet
Pkt.WriteBEInt8(1);
}
@@ -4368,20 +4368,6 @@ void cProtocol_1_9_4::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
-void cProtocol_1_9_4::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count)
-{
- UNUSED(a_Count);
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x48); // Collect Item packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteVarInt32(a_Player.GetUniqueID());
-}
-
-
-
-
-
void cProtocol_1_9_4::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
ASSERT(m_State == 3); // In game mode?
@@ -4398,83 +4384,6 @@ void cProtocol_1_9_4::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerial
-void cProtocol_1_9_4::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x4b); // Entity Effect packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
- Pkt.WriteBEUInt8(static_cast<UInt8>(a_Amplifier));
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Duration));
- Pkt.WriteBool(false); // Hide particles
-}
-
-
-
-
-
-void cProtocol_1_9_4::SendEntityProperties(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
-
- cPacketizer Pkt(*this, 0x4a); // Entity Properties packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- WriteEntityProperties(Pkt, a_Entity);
-}
-
-
-
-
-
-void cProtocol_1_9_4::SendPlayerMaxSpeed(void)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x4a); // Entity Properties
- cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteVarInt32(Player->GetUniqueID());
- Pkt.WriteBEInt32(1); // Count
- Pkt.WriteString("generic.movementSpeed");
- // The default game speed is 0.1, multiply that value by the relative speed:
- Pkt.WriteBEDouble(0.1 * Player->GetNormalMaxSpeed());
- if (Player->IsSprinting())
- {
- Pkt.WriteVarInt32(1); // Modifier count
- Pkt.WriteBEUInt64(0x662a6b8dda3e4c1c);
- Pkt.WriteBEUInt64(0x881396ea6097278d); // UUID of the modifier
- Pkt.WriteBEDouble(Player->GetSprintingMaxSpeed() - Player->GetNormalMaxSpeed());
- Pkt.WriteBEUInt8(2);
- }
- else
- {
- Pkt.WriteVarInt32(0); // Modifier count
- }
-}
-
-
-
-
-
-void cProtocol_1_9_4::SendTeleportEntity(const cEntity & a_Entity)
-{
- ASSERT(m_State == 3); // In game mode?
-
- cPacketizer Pkt(*this, 0x49); // Entity teleport packet
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEDouble(a_Entity.GetPosX());
- Pkt.WriteBEDouble(a_Entity.GetPosY());
- Pkt.WriteBEDouble(a_Entity.GetPosZ());
- Pkt.WriteByteAngle(a_Entity.GetYaw());
- Pkt.WriteByteAngle(a_Entity.GetPitch());
- Pkt.WriteBool(a_Entity.IsOnGround());
-}
-
-
-
-
-
void cProtocol_1_9_4::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
ASSERT(m_State == 3); // In game mode?
diff --git a/src/Protocol/Protocol_1_9.h b/src/Protocol/Protocol_1_9.h
index 3fbbe86da..d08b76755 100644
--- a/src/Protocol/Protocol_1_9.h
+++ b/src/Protocol/Protocol_1_9.h
@@ -183,6 +183,9 @@ protected:
/** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */
void AddReceivedData(const char * a_Data, size_t a_Size);
+ /** Get the packet ID for a given packet */
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
+
/** Reads and handles the packet. The packet length and type have already been read.
Returns true if the packet was understood, false if it was an unknown packet. */
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType);
@@ -337,16 +340,15 @@ public:
cProtocol_1_9_4(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
// cProtocol_1_9_2 overrides:
- virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
- virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
- virtual void SendEntityProperties(const cEntity & a_Entity) override;
- virtual void SendPlayerMaxSpeed (void) override;
- virtual void SendTeleportEntity (const cEntity & a_Entity) override;
virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
+protected:
+
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
+
} ;
diff --git a/src/Root.cpp b/src/Root.cpp
index 3e30d8a07..38c95f822 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -396,16 +396,20 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
a_Settings.AddValue("Worlds", "DefaultWorld", "world");
a_Settings.AddValue("Worlds", "World", "world_nether");
a_Settings.AddValue("Worlds", "World", "world_the_end");
- m_pDefaultWorld = new cWorld("world");
+ a_Settings.AddValue("WorldPaths", "world", "world");
+ a_Settings.AddValue("WorldPaths", "world_nether", "world_nether");
+ a_Settings.AddValue("WorldPaths", "world_the_end", "world_the_end");
+ m_pDefaultWorld = new cWorld("world", "world");
m_WorldsByName["world"] = m_pDefaultWorld;
- m_WorldsByName["world_nether"] = new cWorld("world_nether", dimNether, "world");
- m_WorldsByName["world_the_end"] = new cWorld("world_the_end", dimEnd, "world");
+ m_WorldsByName["world_nether"] = new cWorld("world_nether", "world_nether", dimNether, "world");
+ m_WorldsByName["world_the_end"] = new cWorld("world_the_end", "world_the_end", dimEnd, "world");
return;
}
// First get the default world
AString DefaultWorldName = a_Settings.GetValueSet("Worlds", "DefaultWorld", "world");
- m_pDefaultWorld = new cWorld(DefaultWorldName.c_str());
+ AString DefaultWorldPath = a_Settings.GetValueSet("WorldPaths", DefaultWorldName, DefaultWorldName);
+ m_pDefaultWorld = new cWorld(DefaultWorldName.c_str(), DefaultWorldPath.c_str());
m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
auto Worlds = a_Settings.GetValues("Worlds");
@@ -453,10 +457,15 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
FoundAdditionalWorlds = true;
cWorld * NewWorld;
AString LowercaseName = StrToLower(WorldName);
+ AString WorldPath = a_Settings.GetValueSet("WorldPaths", WorldName, WorldName);
AString NetherAppend = "_nether";
AString EndAppend1 = "_the_end";
AString EndAppend2 = "_end";
+ // The default world is an overworld with no links
+ eDimension Dimension = dimOverworld;
+ AString LinkTo = "";
+
// if the world is called x_nether
if ((LowercaseName.size() > NetherAppend.size()) && (LowercaseName.substr(LowercaseName.size() - NetherAppend.size()) == NetherAppend))
{
@@ -464,12 +473,12 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
// otherwise, choose the default world as the linked world.
// As before, any ini settings will completely override this if an ini is already present.
- AString LinkTo = WorldName.substr(0, WorldName.size() - NetherAppend.size());
+ LinkTo = WorldName.substr(0, WorldName.size() - NetherAppend.size());
if (GetWorld(LinkTo) == nullptr)
{
LinkTo = DefaultWorldName;
}
- NewWorld = new cWorld(WorldName.c_str(), dimNether, LinkTo);
+ Dimension = dimNether;
}
// if the world is called x_the_end
else if ((LowercaseName.size() > EndAppend1.size()) && (LowercaseName.substr(LowercaseName.size() - EndAppend1.size()) == EndAppend1))
@@ -478,12 +487,12 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
// otherwise, choose the default world as the linked world.
// As before, any ini settings will completely override this if an ini is already present.
- AString LinkTo = WorldName.substr(0, WorldName.size() - EndAppend1.size());
+ LinkTo = WorldName.substr(0, WorldName.size() - EndAppend1.size());
if (GetWorld(LinkTo) == nullptr)
{
LinkTo = DefaultWorldName;
}
- NewWorld = new cWorld(WorldName.c_str(), dimEnd, LinkTo);
+ Dimension = dimEnd;
}
// if the world is called x_end
else if ((LowercaseName.size() > EndAppend2.size()) && (LowercaseName.substr(LowercaseName.size() - EndAppend2.size()) == EndAppend2))
@@ -492,17 +501,14 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
// otherwise, choose the default world as the linked world.
// As before, any ini settings will completely override this if an ini is already present.
- AString LinkTo = WorldName.substr(0, WorldName.size() - EndAppend2.size());
+ LinkTo = WorldName.substr(0, WorldName.size() - EndAppend2.size());
if (GetWorld(LinkTo) == nullptr)
{
LinkTo = DefaultWorldName;
}
- NewWorld = new cWorld(WorldName.c_str(), dimEnd, LinkTo);
- }
- else
- {
- NewWorld = new cWorld(WorldName.c_str());
+ Dimension = dimEnd;
}
+ NewWorld = new cWorld(WorldName.c_str(), WorldPath.c_str(), Dimension, LinkTo);
m_WorldsByName[WorldName] = NewWorld;
} // for i - Worlds
@@ -709,6 +715,20 @@ void cRoot::SaveAllChunks(void)
+
+
+void cRoot::SetSavingEnabled(bool a_SavingEnabled)
+{
+ for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr)
+ {
+ itr->second->SetSavingEnabled(a_SavingEnabled);
+ }
+}
+
+
+
+
+
void cRoot::SendPlayerLists(cPlayer * a_DestPlayer)
{
for (const auto & itr : m_WorldsByName)
diff --git a/src/Root.h b/src/Root.h
index 44567018d..46b202c88 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -135,6 +135,9 @@ public:
/** Saves all chunks in all worlds */
void SaveAllChunks(void); // tolua_export
+ /** Sets whether saving chunks is enabled in all worlds (overrides however the worlds were already set) */
+ void SetSavingEnabled(bool a_SavingEnabled); // tolua_export
+
/** Calls the callback for each player in all worlds */
bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 45969bd0a..d5671c5c2 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -352,18 +352,18 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int
void cFireSimulator::RemoveFuelNeighbors(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
{
- for (size_t i = 0; i < ARRAYCOUNT(gNeighborCoords); i++)
+ for (auto & Coord : gNeighborCoords)
{
BLOCKTYPE BlockType;
- int X = a_RelX + gNeighborCoords[i].x;
- int Z = a_RelZ + gNeighborCoords[i].z;
+ int X = a_RelX + Coord.x;
+ int Z = a_RelZ + Coord.z;
cChunkPtr Neighbour = a_Chunk->GetRelNeighborChunkAdjustCoords(X, Z);
if (Neighbour == nullptr)
{
continue;
}
- BlockType = Neighbour->GetBlock(X, a_RelY + gNeighborCoords[i].y, Z);
+ BlockType = Neighbour->GetBlock(X, a_RelY + Coord.y, Z);
if (!IsFuel(BlockType))
{
@@ -371,12 +371,12 @@ void cFireSimulator::RemoveFuelNeighbors(cChunk * a_Chunk, int a_RelX, int a_Rel
}
int AbsX = (Neighbour->GetPosX() * cChunkDef::Width) + X;
- int Y = a_RelY + gNeighborCoords[i].y;
+ int Y = a_RelY + Coord.y;
int AbsZ = (Neighbour->GetPosZ() * cChunkDef::Width) + Z;
if (BlockType == E_BLOCK_TNT)
{
- m_World.SpawnPrimedTNT(AbsX, Y, AbsZ, 0);
+ m_World.SpawnPrimedTNT({static_cast<double>(AbsX), static_cast<double>(Y), static_cast<double>(AbsZ)}, 0);
Neighbour->SetBlock(X, Y, Z, E_BLOCK_AIR, 0);
return;
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h b/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h
index 91fbe05ff..2e7150080 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h
@@ -13,7 +13,7 @@ class cCommandBlockHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -24,7 +24,7 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -33,7 +33,7 @@ public:
return 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating commander the cmdblck (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
@@ -58,11 +58,11 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
UNUSED(a_Meta);
- return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());;
+ return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
}
};
diff --git a/src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h b/src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h
index 999454b56..b41f61941 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h
@@ -13,7 +13,7 @@ class cDoorHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -24,7 +24,7 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -33,7 +33,7 @@ public:
return 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating dori the door (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
@@ -47,11 +47,11 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
UNUSED(a_Meta);
- return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());;
+ return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
}
};
diff --git a/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h b/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h
index 62b37eb1d..42598f519 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h
@@ -29,7 +29,7 @@ public:
}
}
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -40,7 +40,7 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -49,7 +49,7 @@ public:
return 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating spencer the dropspenser (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
bool IsPoweredNow = (a_PoweringData.PowerLevel > 0);
@@ -79,7 +79,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h b/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h
index add608654..7ecc64c72 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h
@@ -13,7 +13,7 @@ class cNoteBlockHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_World);
UNUSED(a_World);
@@ -25,7 +25,7 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -34,7 +34,7 @@ public:
return 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating sparky the magical note block (%d %d %d) %i", a_Position.x, a_Position.y, a_Position.z, a_PoweringData.PowerLevel);
@@ -60,11 +60,11 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
UNUSED(a_Meta);
- return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());;
+ return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
}
};
diff --git a/src/Simulator/IncrementalRedstoneSimulator/PistonHandler.h b/src/Simulator/IncrementalRedstoneSimulator/PistonHandler.h
index f41fad89d..01742b13c 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/PistonHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/PistonHandler.h
@@ -13,7 +13,7 @@ class cPistonHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -24,7 +24,7 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -33,7 +33,7 @@ public:
return 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating pisty the piston (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
auto Data = static_cast<cIncrementalRedstoneSimulator *>(a_World.GetRedstoneSimulator())->GetChunkData();
@@ -72,7 +72,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/PoweredRailHandler.h b/src/Simulator/IncrementalRedstoneSimulator/PoweredRailHandler.h
index 0b18ae511..3c02bf5ec 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/PoweredRailHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/PoweredRailHandler.h
@@ -30,7 +30,7 @@ public:
}
}
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_QueryBlockType);
@@ -43,14 +43,14 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_BlockType);
UNUSED(a_Meta);
return static_cast<cIncrementalRedstoneSimulator *>(a_World.GetRedstoneSimulator())->GetChunkData()->GetCachedPowerData(a_Position).PowerLevel;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating tracky the rail (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
@@ -86,7 +86,7 @@ public:
}
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h b/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h
index 14d7baf85..944543460 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h
@@ -13,7 +13,7 @@ class cPressurePlateHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_BlockType);
UNUSED(a_Meta);
@@ -23,7 +23,7 @@ public:
return static_cast<cIncrementalRedstoneSimulator *>(a_World.GetRedstoneSimulator())->GetChunkData()->GetCachedPowerData(a_Position).PowerLevel;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
@@ -79,7 +79,7 @@ public:
}
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
UNUSED(a_PoweringData.PowerLevel);
// LOGD("Evaluating clicky the pressure plate (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
@@ -96,7 +96,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneBlockHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneBlockHandler.h
index 4151fc9ad..441f802c3 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneBlockHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneBlockHandler.h
@@ -12,7 +12,7 @@ class cRedstoneBlockHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -22,7 +22,7 @@ public:
return cIncrementalRedstoneSimulator::IsMechanism(a_QueryBlockType) ? 15 : 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -31,13 +31,13 @@ public:
return 15;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating crimson the redstone block (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h
index 55efee6b5..cd43a4875 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h
@@ -13,7 +13,7 @@ class cRedstoneComparatorHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- unsigned char GetFrontPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, unsigned char a_HighestSidePowerLevel, unsigned char a_HighestRearPowerLevel) const
+ unsigned char GetFrontPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, unsigned char a_HighestSidePowerLevel, unsigned char a_HighestRearPowerLevel) const
{
if (cBlockComparatorHandler::IsInSubtractionMode(a_Meta))
{
@@ -27,7 +27,7 @@ public:
}
}
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_QueryPosition);
UNUSED(a_QueryBlockType);
@@ -39,7 +39,7 @@ public:
);
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_Position);
UNUSED(a_BlockType);
@@ -90,7 +90,7 @@ public:
return RearPower;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// Note that a_PoweringData here contains the maximum * side * power level, as specified by GetValidSourcePositions
// LOGD("Evaluating ALU the comparator (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
@@ -134,7 +134,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.h
index 384d872f4..788a3c337 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.h
@@ -54,10 +54,10 @@ public:
}
};
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const = 0;
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const = 0;
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const = 0;
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const = 0;
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const = 0;
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const = 0;
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const = 0;
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const = 0;
// Force a virtual destructor
virtual ~cRedstoneHandler() {}
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneLampHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneLampHandler.h
index f28f75f4b..6c6fa48d7 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneLampHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneLampHandler.h
@@ -15,17 +15,17 @@ public:
return (a_BlockType == E_BLOCK_REDSTONE_LAMP_ON);
}
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
return 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating lamp (%i %i %i)", a_Position.x, a_Position.y, a_Position.z);
@@ -47,7 +47,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Meta);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneRepeaterHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneRepeaterHandler.h
index 9d8dda1bb..5f4898804 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneRepeaterHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneRepeaterHandler.h
@@ -18,7 +18,7 @@ public:
return (a_Block == E_BLOCK_REDSTONE_REPEATER_ON);
}
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
return (
(a_QueryPosition == (a_Position + cBlockRedstoneRepeaterHandler::GetFrontCoordinateOffset(a_Meta))) ?
@@ -26,7 +26,7 @@ public:
);
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -34,7 +34,7 @@ public:
return IsOn(a_BlockType) ? 15 : 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating loopy the repeater (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
auto Data = static_cast<cIncrementalRedstoneSimulator *>(a_World.GetRedstoneSimulator())->GetChunkData();
@@ -65,7 +65,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
return { cBlockRedstoneRepeaterHandler::GetRearCoordinateOffset(a_Meta) + a_Position };
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h
index 9d950a8b9..d5bf78399 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneToggleHandler.h
@@ -63,7 +63,7 @@ public:
}
}
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_QueryBlockType);
if ((GetPositionAttachedTo(a_Position, a_BlockType, a_Meta) == a_QueryPosition) || cIncrementalRedstoneSimulator::IsMechanism(a_QueryBlockType))
@@ -73,7 +73,7 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -91,13 +91,13 @@ public:
}
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating templatio<> the lever/button (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneTorchHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneTorchHandler.h
index b892dedb5..16f060939 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneTorchHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneTorchHandler.h
@@ -16,7 +16,7 @@ public:
return (a_Block == E_BLOCK_REDSTONE_TORCH_ON);
}
- inline static Vector3i GetOffsetAttachedTo(const Vector3i & a_Position, NIBBLETYPE a_Meta)
+ inline static Vector3i GetOffsetAttachedTo(Vector3i a_Position, NIBBLETYPE a_Meta)
{
switch (a_Meta)
{
@@ -33,7 +33,7 @@ public:
}
}
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
if (
IsOn(a_BlockType) &&
@@ -46,12 +46,12 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
return IsOn(a_BlockType) ? 15 : 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating torchy the redstone torch (%i %i %i)", a_Position.x, a_Position.y, a_Position.z);
@@ -86,7 +86,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h
index 7b2a60323..09b16fb25 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h
@@ -27,7 +27,7 @@ public:
}
}
- cVector3iArray GetTerracingConnectionOffsets(cWorld & a_World, const Vector3i & a_Position) const
+ cVector3iArray GetTerracingConnectionOffsets(cWorld & a_World, Vector3i a_Position) const
{
cVector3iArray RelativePositions;
auto YPTerraceBlock = a_World.GetBlock(a_Position + OffsetYP());
@@ -56,7 +56,7 @@ public:
return RelativePositions;
}
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
if (a_QueryPosition == (a_Position + OffsetYP()))
{
@@ -100,7 +100,7 @@ public:
return (a_Meta != 0) ? --a_Meta : a_Meta;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -108,7 +108,7 @@ public:
return a_Meta;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
UNUSED(a_BlockType);
// LOGD("Evaluating dusty the wire (%d %d %d) %i", a_Position.x, a_Position.y, a_Position.z, a_PoweringData.PowerLevel);
@@ -122,7 +122,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h b/src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h
index 6c201f354..dd4188b56 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h
@@ -12,7 +12,7 @@ class cSmallGateHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -23,7 +23,7 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -32,7 +32,7 @@ public:
return 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating gateydory the fence gate/trapdoor (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
auto Data = static_cast<cIncrementalRedstoneSimulator *>(a_World.GetRedstoneSimulator())->GetChunkData();
@@ -44,7 +44,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/SolidBlockHandler.h b/src/Simulator/IncrementalRedstoneSimulator/SolidBlockHandler.h
index 215ccd990..b8b9b3bed 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/SolidBlockHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/SolidBlockHandler.h
@@ -12,7 +12,7 @@ class cSolidBlockHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
// TODO: wire isn't linked powered only if the source was a wire, not just because it is a wire
return (
@@ -24,12 +24,12 @@ public:
) ? 0 : GetPowerLevel(a_World, a_Position, a_BlockType, a_Meta);
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
return static_cast<cIncrementalRedstoneSimulator *>(a_World.GetRedstoneSimulator())->GetChunkData()->GetCachedPowerData(a_Position).PowerLevel;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
UNUSED(a_BlockType);
UNUSED(a_Meta);
@@ -44,7 +44,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
index 40e7da96a..6cea4501f 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
@@ -12,7 +12,7 @@ class cTNTHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -23,7 +23,7 @@ public:
return 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
@@ -32,19 +32,19 @@ public:
return 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating explodinator the trinitrotoluene (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
if (a_PoweringData.PowerLevel != 0)
{
a_World.BroadcastSoundEffect("entity.tnt.primed", static_cast<double>(a_Position.x), static_cast<double>(a_Position.y), static_cast<double>(a_Position.z), 0.5f, 0.6f);
a_World.SetBlock(a_Position.x, a_Position.y, a_Position.z, E_BLOCK_AIR, 0);
- a_World.SpawnPrimedTNT(a_Position.x + 0.5, a_Position.y + 0.5, a_Position.z + 0.5); // 80 ticks to boom
+ a_World.SpawnPrimedTNT(a_Position + Vector3d(0.5, 0.5, 0.5)); // 80 ticks to boom
}
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h
index 8b7b82d49..4ae4aff3d 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h
@@ -13,7 +13,7 @@ class cTrappedChestHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_BlockType);
UNUSED(a_Meta);
@@ -23,7 +23,7 @@ public:
return static_cast<cIncrementalRedstoneSimulator *>(a_World.GetRedstoneSimulator())->GetChunkData()->GetCachedPowerData(a_Position).PowerLevel;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_BlockType);
UNUSED(a_Meta);
@@ -62,7 +62,7 @@ public:
return GTCP.GetPowerLevel();
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating tricky the trapped chest (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
@@ -77,7 +77,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_Position);
diff --git a/src/Simulator/IncrementalRedstoneSimulator/TripwireHookHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TripwireHookHandler.h
index 85c05430c..609db932d 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/TripwireHookHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/TripwireHookHandler.h
@@ -13,7 +13,7 @@ class cTripwireHookHandler : public cRedstoneHandler
typedef cRedstoneHandler super;
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
UNUSED(a_QueryBlockType);
UNUSED(a_QueryPosition);
@@ -21,7 +21,7 @@ public:
return (GetPowerLevel(a_World, a_Position, a_BlockType, a_Meta) == 15) ? 15 : 0;
}
- virtual unsigned char GetPowerLevel(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_BlockType);
@@ -86,7 +86,7 @@ public:
return 0;
}
- virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating hooky the tripwire hook (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
@@ -121,7 +121,7 @@ public:
return {};
}
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
{
UNUSED(a_World);
UNUSED(a_BlockType);
diff --git a/src/World.cpp b/src/World.cpp
index acec3049e..e2ac24e71 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -120,16 +120,18 @@ void cWorld::cTickThread::Execute(void)
////////////////////////////////////////////////////////////////////////////////
// cWorld:
-cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_LinkedOverworldName) :
+cWorld::cWorld(const AString & a_WorldName, const AString & a_DataPath, eDimension a_Dimension, const AString & a_LinkedOverworldName) :
m_WorldName(a_WorldName),
+ m_DataPath(a_DataPath),
m_LinkedOverworldName(a_LinkedOverworldName),
- m_IniFileName(m_WorldName + "/world.ini"),
+ m_IniFileName(m_DataPath + "/world.ini"),
m_StorageSchema("Default"),
#ifdef __arm__
m_StorageCompressionFactor(0),
#else
m_StorageCompressionFactor(6),
#endif
+ m_IsSavingEnabled(true),
m_Dimension(a_Dimension),
m_IsSpawnExplicitlySet(false),
m_SpawnX(0),
@@ -194,10 +196,10 @@ cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AStrin
{
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
- cFile::CreateFolder(FILE_IO_PREFIX + m_WorldName);
+ cFile::CreateFolderRecursive(FILE_IO_PREFIX + m_DataPath);
// Load the scoreboard
- cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard);
+ cScoreboardSerializer Serializer(m_DataPath, &m_Scoreboard);
Serializer.Load();
}
@@ -213,11 +215,14 @@ cWorld::~cWorld()
m_Storage.WaitForFinish();
- // Unload the scoreboard
- cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard);
- Serializer.Save();
+ if (IsSavingEnabled())
+ {
+ // Unload the scoreboard
+ cScoreboardSerializer Serializer(m_DataPath, &m_Scoreboard);
+ Serializer.Save();
- m_MapManager.SaveMapData();
+ m_MapManager.SaveMapData();
+ }
// Explicitly destroy the chunkmap, so that it's guaranteed to be destroyed before the other internals
// This fixes crashes on stopping the server, because chunk destructor deletes entities and those access the world.
@@ -2306,9 +2311,9 @@ UInt32 cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartT
-UInt32 cWorld::SpawnBoat(double a_X, double a_Y, double a_Z, cBoat::eMaterial a_Material)
+UInt32 cWorld::SpawnBoat(Vector3d a_Pos, cBoat::eMaterial a_Material)
{
- auto Boat = cpp14::make_unique<cBoat>(a_X, a_Y, a_Z, a_Material);
+ auto Boat = cpp14::make_unique<cBoat>(a_Pos, a_Material);
auto BoatPtr = Boat.get();
if (!BoatPtr->Initialize(std::move(Boat), *this))
{
@@ -2320,9 +2325,9 @@ UInt32 cWorld::SpawnBoat(double a_X, double a_Y, double a_Z, cBoat::eMaterial a_
-UInt32 cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTicks, double a_InitialVelocityCoeff)
+UInt32 cWorld::SpawnPrimedTNT(Vector3d a_Pos, int a_FuseTicks, double a_InitialVelocityCoeff)
{
- auto TNT = cpp14::make_unique<cTNTEntity>(a_X, a_Y, a_Z, a_FuseTicks);
+ auto TNT = cpp14::make_unique<cTNTEntity>(a_Pos, a_FuseTicks);
auto TNTPtr = TNT.get();
if (!TNTPtr->Initialize(std::move(TNT), *this))
{
@@ -2965,7 +2970,9 @@ void cWorld::SetChunkData(cSetChunkData & a_SetChunkData)
);
// Save the chunk right after generating, so that we don't have to generate it again on next run
- if (a_SetChunkData.ShouldMarkDirty())
+ // If saving is disabled, then the chunk was marked dirty so it will get
+ // saved if saving is later enabled.
+ if (a_SetChunkData.ShouldMarkDirty() && IsSavingEnabled())
{
m_Storage.QueueSaveChunk(ChunkX, ChunkZ);
}
@@ -3629,8 +3636,11 @@ bool cWorld::ForEachLoadedChunk(std::function<bool(int, int)> a_Callback)
void cWorld::SaveAllChunks(void)
{
- m_LastSave = std::chrono::duration_cast<cTickTimeLong>(m_WorldAge);
- m_ChunkMap->SaveAllChunks();
+ if (IsSavingEnabled())
+ {
+ m_LastSave = std::chrono::duration_cast<cTickTimeLong>(m_WorldAge);
+ m_ChunkMap->SaveAllChunks();
+ }
}
@@ -3709,6 +3719,36 @@ bool cWorld::HasEntity(UInt32 a_UniqueID)
+OwnedEntity cWorld::RemoveEntity(cEntity & a_Entity)
+{
+ // Check if the entity is in the chunkmap:
+ auto Entity = m_ChunkMap->RemoveEntity(a_Entity);
+ if (Entity != nullptr)
+ {
+ return Entity;
+ }
+
+ // Check if the entity is in the queue to be added to the world:
+ cCSLock Lock(m_CSEntitiesToAdd);
+ auto itr = std::find_if(m_EntitiesToAdd.begin(), m_EntitiesToAdd.end(),
+ [&a_Entity](const OwnedEntity & a_OwnedEntity)
+ {
+ return (a_OwnedEntity.get() == &a_Entity);
+ }
+ );
+
+ if (itr != m_EntitiesToAdd.end())
+ {
+ Entity = std::move(*itr);
+ m_EntitiesToAdd.erase(itr);
+ }
+ return Entity;
+}
+
+
+
+
+
/*
unsigned int cWorld::GetNumPlayers(void)
{
diff --git a/src/World.h b/src/World.h
index cbaf9cb95..22847b975 100644
--- a/src/World.h
+++ b/src/World.h
@@ -12,6 +12,7 @@
#include "ChunkSender.h"
#include "Defines.h"
#include "LightingThread.h"
+#include "IniFile.h"
#include "Item.h"
#include "Mobs/Monster.h"
#include "Entities/ProjectileEntity.h"
@@ -103,6 +104,12 @@ public:
// tolua_begin
+ /** Get whether saving chunks is enabled */
+ bool IsSavingEnabled(void) const { return m_IsSavingEnabled; }
+
+ /** Set whether saving chunks is enabled */
+ void SetSavingEnabled(bool a_IsSavingEnabled) { m_IsSavingEnabled = a_IsSavingEnabled; }
+
int GetTicksUntilWeatherChange(void) const { return m_WeatherInterval; }
/** Is the daylight cycle enabled? */
@@ -301,6 +308,10 @@ public:
Note: Only loaded chunks are considered. */
bool HasEntity(UInt32 a_UniqueID);
+ /** Removes the entity from the world.
+ Returns an owning reference to the found entity. */
+ OwnedEntity RemoveEntity(cEntity & a_Entity);
+
/** Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true */
bool ForEachEntity(cEntityCallback & a_Callback); // Exported in ManualBindings.cpp
@@ -453,18 +464,32 @@ public:
Returns the UniqueID of the spawned minecart, or cEntity::INVALID_ID on failure. */
UInt32 SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType, const cItem & a_Content = cItem(), int a_BlockHeight = 1);
+ // DEPRECATED, use the vector-parametered version instead.
+ UInt32 SpawnBoat(double a_X, double a_Y, double a_Z, cBoat::eMaterial a_Material)
+ {
+ LOGWARNING("cWorld::SpawnBoat(double, double, double) is deprecated, use cWorld::SpawnBoat(Vector3d) instead.");
+ return SpawnBoat({a_X, a_Y, a_Z}, a_Material);
+ }
+
/** Spawns a boat at the given coordinates.
Returns the UniqueID of the spawned boat, or cEntity::INVALID_ID on failure. */
- UInt32 SpawnBoat(double a_X, double a_Y, double a_Z, cBoat::eMaterial a_Material);
+ UInt32 SpawnBoat(Vector3d a_Pos, cBoat::eMaterial a_Material);
/** Spawns an experience orb at the given location with the given reward.
Returns the UniqueID of the spawned experience orb, or cEntity::INVALID_ID on failure. */
virtual UInt32 SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) override;
+ // DEPRECATED, use the vector-parametered version instead.
+ UInt32 SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1)
+ {
+ LOGWARNING("cWorld::SpawnPrimedTNT(double, double, double) is deprecated, use cWorld::SpawnPrimedTNT(Vector3d) instead.");
+ return SpawnPrimedTNT({a_X, a_Y, a_Z}, a_FuseTimeInSec, a_InitialVelocityCoeff);
+ }
+
/** Spawns a new primed TNT entity at the specified block coords and specified fuse duration.
Initial velocity is given based on the relative coefficient provided.
Returns the UniqueID of the created entity, or cEntity::INVALID_ID on failure. */
- UInt32 SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1);
+ UInt32 SpawnPrimedTNT(Vector3d a_Pos, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1);
// tolua_end
@@ -639,6 +664,9 @@ public:
/** Returns the name of the world */
const AString & GetName(void) const { return m_WorldName; }
+ /** Returns the data path to the world data */
+ const AString & GetDataPath(void) const { return m_DataPath; }
+
/** Returns the name of the world.ini file used by this world */
const AString & GetIniFileName(void) const {return m_IniFileName; }
@@ -882,6 +910,9 @@ private:
AString m_WorldName;
+ /** The path to the root directory for the world files. Does not including trailing path specifier. */
+ AString m_DataPath;
+
/** The name of the overworld that portals in this world should link to.
Only has effect if this world is a Nether or End world. */
AString m_LinkedOverworldName;
@@ -893,6 +924,9 @@ private:
int m_StorageCompressionFactor;
+ /** Whether or not writing chunks to disk is currently enabled */
+ std::atomic<bool> m_IsSavingEnabled;
+
/** The dimension of the world, used by the client to provide correct lighting scheme */
eDimension m_Dimension;
@@ -1047,7 +1081,7 @@ private:
cSetChunkDataPtrs m_SetChunkDataQueue;
- cWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_LinkedOverworldName = "");
+ cWorld(const AString & a_WorldName, const AString & a_DataPath, eDimension a_Dimension = dimOverworld, const AString & a_LinkedOverworldName = "");
virtual ~cWorld() override;
void Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp
index 16128966b..c8a4c0951 100644
--- a/src/WorldStorage/StatSerializer.cpp
+++ b/src/WorldStorage/StatSerializer.cpp
@@ -11,7 +11,7 @@
-cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager)
+cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, const AString & a_FileName, cStatManager * a_Manager)
: m_Manager(a_Manager)
{
// Even though stats are shared between worlds, they are (usually) saved
@@ -20,7 +20,8 @@ cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_
AString StatsPath;
Printf(StatsPath, "%s%cstats", a_WorldName.c_str(), cFile::PathSeparator);
- m_Path = StatsPath + "/" + a_PlayerName + ".json";
+ m_LegacyPath = StatsPath + "/" + a_PlayerName + ".json";
+ m_Path = StatsPath + "/" + a_FileName + ".json";
// Ensure that the directory exists.
cFile::CreateFolder(FILE_IO_PREFIX + StatsPath);
@@ -35,7 +36,11 @@ bool cStatSerializer::Load(void)
AString Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_Path);
if (Data.empty())
{
- return false;
+ Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_LegacyPath);
+ if (Data.empty())
+ {
+ return false;
+ }
}
Json::Value Root;
diff --git a/src/WorldStorage/StatSerializer.h b/src/WorldStorage/StatSerializer.h
index 6b7efddbb..8e8e4ffdb 100644
--- a/src/WorldStorage/StatSerializer.h
+++ b/src/WorldStorage/StatSerializer.h
@@ -25,7 +25,7 @@ class cStatSerializer
{
public:
- cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager);
+ cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, const AString & a_FileName, cStatManager * a_Manager);
/* Try to load the player statistics. Returns whether the operation was successful or not. */
bool Load(void);
@@ -45,6 +45,7 @@ private:
cStatManager * m_Manager;
+ AString m_LegacyPath; // The old <username>.json path to try to read from if the uuid path doesn't exist on load
AString m_Path;
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index a3251481f..158f7a819 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -85,7 +85,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
{
// Create a level.dat file for mapping tools, if it doesn't already exist:
AString fnam;
- Printf(fnam, "%s%clevel.dat", a_World->GetName().c_str(), cFile::PathSeparator);
+ Printf(fnam, "%s%clevel.dat", a_World->GetDataPath().c_str(), cFile::PathSeparator);
if (!cFile::Exists(fnam))
{
cFastNBTWriter Writer;
@@ -180,7 +180,7 @@ void cWSSAnvil::ChunkLoadFailed(int a_ChunkX, int a_ChunkZ, const AString & a_Re
{
// Construct the filename for offloading:
AString OffloadFileName;
- Printf(OffloadFileName, "%s%cregion%cbadchunks", m_World->GetName().c_str(), cFile::PathSeparator, cFile::PathSeparator);
+ Printf(OffloadFileName, "%s%cregion%cbadchunks", m_World->GetDataPath().c_str(), cFile::PathSeparator, cFile::PathSeparator);
cFile::CreateFolder(FILE_IO_PREFIX + OffloadFileName);
auto t = time(nullptr);
struct tm stm;
@@ -286,7 +286,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk)
// Load it anew:
AString FileName;
- Printf(FileName, "%s%cregion", m_World->GetName().c_str(), cFile::PathSeparator);
+ Printf(FileName, "%s%cregion", m_World->GetDataPath().c_str(), cFile::PathSeparator);
cFile::CreateFolder(FILE_IO_PREFIX + FileName);
AppendPrintf(FileName, "/r.%d.%d.mca", RegionX, RegionZ);
cMCAFile * f = new cMCAFile(*this, FileName, RegionX, RegionZ);
@@ -1661,7 +1661,7 @@ void cWSSAnvil::LoadOldMinecartFromNBT(cEntityList & a_Entities, const cParsedNB
void cWSSAnvil::LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cBoat> Boat = cpp14::make_unique<cBoat>(0, 0, 0, cBoat::bmOak);
+ std::unique_ptr<cBoat> Boat = cpp14::make_unique<cBoat>(Vector3d(), cBoat::bmOak);
if (!LoadEntityBaseFromNBT(*Boat.get(), a_NBT, a_TagIdx))
{
return;
@@ -1851,7 +1851,7 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cTNTEntity> TNT = cpp14::make_unique<cTNTEntity>(0.0, 0.0, 0.0, 0);
+ std::unique_ptr<cTNTEntity> TNT = cpp14::make_unique<cTNTEntity>(Vector3d(), 0);
if (!LoadEntityBaseFromNBT(*TNT.get(), a_NBT, a_TagIdx))
{
return;