summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-07-29 22:04:00 +0200
committerarchshift <admin@archshift.com>2014-07-29 22:04:00 +0200
commita9b597087b56b4526a3f6447789ba141568575a1 (patch)
treea08542d77b5668a25ca5e00492577ed6f4d61a9a /src
parentSpacing fixes and a few more BLOCK_META constants. (diff)
parentSlight cleanup after portals (diff)
downloadcuberite-a9b597087b56b4526a3f6447789ba141568575a1.tar
cuberite-a9b597087b56b4526a3f6447789ba141568575a1.tar.gz
cuberite-a9b597087b56b4526a3f6447789ba141568575a1.tar.bz2
cuberite-a9b597087b56b4526a3f6447789ba141568575a1.tar.lz
cuberite-a9b597087b56b4526a3f6447789ba141568575a1.tar.xz
cuberite-a9b597087b56b4526a3f6447789ba141568575a1.tar.zst
cuberite-a9b597087b56b4526a3f6447789ba141568575a1.zip
Diffstat (limited to '')
-rw-r--r--src/AllocationPool.h113
-rw-r--r--src/Bindings/.gitignore2
-rw-r--r--src/Bindings/AllToLua.pkg3
-rw-r--r--src/Bindings/AllToLua_lua.bat27
-rw-r--r--src/Bindings/CMakeLists.txt135
-rw-r--r--src/Bindings/DeprecatedBindings.cpp77
-rw-r--r--src/Bindings/DeprecatedBindings.h2
-rw-r--r--src/Bindings/LuaChunkStay.cpp4
-rw-r--r--src/Bindings/LuaFunctions.h4
-rw-r--r--src/Bindings/LuaState.cpp166
-rw-r--r--src/Bindings/LuaState.h680
-rw-r--r--src/Bindings/LuaWindow.cpp4
-rw-r--r--src/Bindings/ManualBindings.cpp223
-rw-r--r--src/Bindings/ManualBindings.h2
-rw-r--r--src/Bindings/Plugin.h23
-rw-r--r--src/Bindings/PluginLua.cpp81
-rw-r--r--src/Bindings/PluginLua.h12
-rw-r--r--src/Bindings/PluginManager.cpp595
-rw-r--r--src/Bindings/PluginManager.h64
-rw-r--r--src/Bindings/WebPlugin.cpp32
-rw-r--r--src/Bindings/WebPlugin.h8
-rw-r--r--src/Bindings/gen_LuaState_Call.lua196
-rw-r--r--src/Bindings/lua51.dllbin167424 -> 0 bytes
-rw-r--r--src/Bindings/tolua++.exebin200704 -> 0 bytes
-rw-r--r--src/Bindings/virtual_method_hooks.lua14
-rw-r--r--src/BiomeDef.cpp181
-rw-r--r--src/BiomeDef.h9
-rw-r--r--src/BlockArea.cpp578
-rw-r--r--src/BlockArea.h17
-rw-r--r--src/BlockEntities/BeaconEntity.cpp4
-rw-r--r--src/BlockEntities/BeaconEntity.h2
-rw-r--r--src/BlockEntities/BlockEntity.cpp10
-rw-r--r--src/BlockEntities/BlockEntity.h6
-rw-r--r--src/BlockEntities/BlockEntityWithItems.h2
-rw-r--r--src/BlockEntities/CMakeLists.txt42
-rw-r--r--src/BlockEntities/ChestEntity.cpp26
-rw-r--r--src/BlockEntities/ChestEntity.h21
-rw-r--r--src/BlockEntities/CommandBlockEntity.cpp2
-rw-r--r--src/BlockEntities/CommandBlockEntity.h6
-rw-r--r--src/BlockEntities/DispenserEntity.cpp90
-rw-r--r--src/BlockEntities/DispenserEntity.h26
-rw-r--r--src/BlockEntities/DropSpenserEntity.cpp10
-rw-r--r--src/BlockEntities/DropSpenserEntity.h3
-rw-r--r--src/BlockEntities/EnderChestEntity.cpp93
-rw-r--r--src/BlockEntities/EnderChestEntity.h40
-rw-r--r--src/BlockEntities/FlowerPotEntity.h8
-rw-r--r--src/BlockEntities/FurnaceEntity.cpp2
-rw-r--r--src/BlockEntities/HopperEntity.cpp116
-rw-r--r--src/BlockEntities/HopperEntity.h3
-rw-r--r--src/BlockEntities/JukeboxEntity.h4
-rw-r--r--src/BlockEntities/MobHeadEntity.cpp2
-rw-r--r--src/BlockEntities/MobHeadEntity.h6
-rw-r--r--src/BlockEntities/NoteEntity.cpp2
-rw-r--r--src/BlockEntities/NoteEntity.h4
-rw-r--r--src/BlockEntities/SignEntity.h6
-rw-r--r--src/BlockID.cpp41
-rw-r--r--src/BlockID.h23
-rw-r--r--src/BlockInfo.cpp856
-rw-r--r--src/BlockInfo.h29
-rw-r--r--src/BlockTracer.h16
-rw-r--r--src/Blocks/BlockAnvil.h9
-rw-r--r--src/Blocks/BlockBed.cpp22
-rw-r--r--src/Blocks/BlockBed.h9
-rw-r--r--src/Blocks/BlockBigFlower.h10
-rw-r--r--src/Blocks/BlockButton.h9
-rw-r--r--src/Blocks/BlockCarpet.h2
-rw-r--r--src/Blocks/BlockCauldron.h18
-rw-r--r--src/Blocks/BlockChest.h48
-rw-r--r--src/Blocks/BlockCloth.h7
-rw-r--r--src/Blocks/BlockComparator.h2
-rw-r--r--src/Blocks/BlockCrops.h2
-rw-r--r--src/Blocks/BlockDirt.h8
-rw-r--r--src/Blocks/BlockDoor.cpp13
-rw-r--r--src/Blocks/BlockDoor.h106
-rw-r--r--src/Blocks/BlockDropSpenser.h10
-rw-r--r--src/Blocks/BlockEnderchest.h2
-rw-r--r--src/Blocks/BlockFarmland.h15
-rw-r--r--src/Blocks/BlockFenceGate.h3
-rw-r--r--src/Blocks/BlockFire.h53
-rw-r--r--src/Blocks/BlockFluid.h8
-rw-r--r--src/Blocks/BlockFurnace.h8
-rw-r--r--src/Blocks/BlockHandler.cpp176
-rw-r--r--src/Blocks/BlockHandler.h43
-rw-r--r--src/Blocks/BlockHayBale.h28
-rw-r--r--src/Blocks/BlockHopper.h2
-rw-r--r--src/Blocks/BlockIce.h2
-rw-r--r--src/Blocks/BlockLadder.h34
-rw-r--r--src/Blocks/BlockLeaves.h46
-rw-r--r--src/Blocks/BlockLever.h20
-rw-r--r--src/Blocks/BlockLilypad.h14
-rw-r--r--src/Blocks/BlockMobHead.h136
-rw-r--r--src/Blocks/BlockPiston.cpp183
-rw-r--r--src/Blocks/BlockPiston.h123
-rw-r--r--src/Blocks/BlockPlanks.h2
-rw-r--r--src/Blocks/BlockPortal.h24
-rw-r--r--src/Blocks/BlockPressurePlate.h38
-rw-r--r--src/Blocks/BlockPumpkin.h13
-rw-r--r--src/Blocks/BlockQuartz.h12
-rw-r--r--src/Blocks/BlockRail.h24
-rw-r--r--src/Blocks/BlockRedstoneRepeater.h2
-rw-r--r--src/Blocks/BlockSapling.h4
-rw-r--r--src/Blocks/BlockSideways.h14
-rw-r--r--src/Blocks/BlockSignPost.h (renamed from src/Blocks/BlockSign.h)59
-rw-r--r--src/Blocks/BlockSlab.h24
-rw-r--r--src/Blocks/BlockSnow.h10
-rw-r--r--src/Blocks/BlockStairs.h9
-rw-r--r--src/Blocks/BlockStone.h2
-rw-r--r--src/Blocks/BlockTallGrass.h3
-rw-r--r--src/Blocks/BlockTorch.h21
-rw-r--r--src/Blocks/BlockTripwire.h32
-rw-r--r--src/Blocks/BlockTripwireHook.h82
-rw-r--r--src/Blocks/BlockVine.h11
-rw-r--r--src/Blocks/BlockWallSign.h89
-rw-r--r--src/Blocks/BroadcastInterface.h6
-rw-r--r--src/Blocks/CMakeLists.txt100
-rw-r--r--src/Blocks/ChunkInterface.h8
-rw-r--r--src/Blocks/ClearMetaOnDrop.h24
-rw-r--r--src/Blocks/MetaRotator.h8
-rw-r--r--src/Blocks/WorldInterface.h20
-rw-r--r--src/BoundingBox.cpp2
-rw-r--r--src/BoundingBox.h2
-rw-r--r--src/ByteBuffer.cpp39
-rw-r--r--src/ByteBuffer.h44
-rw-r--r--src/CMakeLists.txt356
-rw-r--r--src/ChatColor.cpp48
-rw-r--r--src/ChatColor.h58
-rw-r--r--src/CheckBasicStyle.lua212
-rw-r--r--src/Chunk.cpp613
-rw-r--r--src/Chunk.h127
-rw-r--r--src/ChunkData.cpp595
-rw-r--r--src/ChunkData.h133
-rw-r--r--src/ChunkDataCallback.h127
-rw-r--r--src/ChunkDef.h186
-rw-r--r--src/ChunkMap.cpp260
-rw-r--r--src/ChunkMap.h87
-rw-r--r--src/ChunkSender.cpp4
-rw-r--r--src/ChunkSender.h11
-rw-r--r--src/ClientHandle.cpp416
-rw-r--r--src/ClientHandle.h90
-rw-r--r--src/CommandOutput.cpp4
-rw-r--r--src/CommandOutput.h6
-rw-r--r--src/CompositeChat.cpp41
-rw-r--r--src/CompositeChat.h28
-rw-r--r--src/CraftingRecipes.cpp21
-rw-r--r--src/CraftingRecipes.h2
-rw-r--r--src/Crypto.cpp509
-rw-r--r--src/Crypto.h198
-rw-r--r--src/Cuboid.cpp13
-rw-r--r--src/Cuboid.h10
-rw-r--r--src/DeadlockDetect.cpp2
-rw-r--r--src/Defines.h70
-rw-r--r--src/Enchantments.cpp9
-rw-r--r--src/Enchantments.h5
-rw-r--r--src/Endianness.h11
-rw-r--r--src/Entities/ArrowEntity.cpp76
-rw-r--r--src/Entities/ArrowEntity.h10
-rw-r--r--src/Entities/Boat.cpp12
-rw-r--r--src/Entities/Boat.h4
-rw-r--r--src/Entities/CMakeLists.txt65
-rw-r--r--src/Entities/Effects.h30
-rw-r--r--src/Entities/EnderCrystal.cpp4
-rw-r--r--src/Entities/EnderCrystal.h4
-rw-r--r--src/Entities/Entity.cpp566
-rw-r--r--src/Entities/Entity.h176
-rw-r--r--src/Entities/EntityEffect.cpp411
-rw-r--r--src/Entities/EntityEffect.h494
-rw-r--r--src/Entities/ExpBottleEntity.h4
-rw-r--r--src/Entities/ExpOrb.cpp14
-rw-r--r--src/Entities/ExpOrb.h4
-rw-r--r--src/Entities/FallingBlock.cpp10
-rw-r--r--src/Entities/FallingBlock.h2
-rw-r--r--src/Entities/FireChargeEntity.h4
-rw-r--r--src/Entities/FireworkEntity.h4
-rw-r--r--src/Entities/Floater.cpp20
-rw-r--r--src/Entities/Floater.h6
-rw-r--r--src/Entities/GhastFireballEntity.h4
-rw-r--r--src/Entities/HangingEntity.cpp6
-rw-r--r--src/Entities/HangingEntity.h4
-rw-r--r--src/Entities/ItemFrame.cpp14
-rw-r--r--src/Entities/ItemFrame.h6
-rw-r--r--src/Entities/Minecart.cpp128
-rw-r--r--src/Entities/Minecart.h27
-rw-r--r--src/Entities/Painting.h10
-rw-r--r--src/Entities/Pawn.cpp100
-rw-r--r--src/Entities/Pawn.h30
-rw-r--r--src/Entities/Pickup.cpp61
-rw-r--r--src/Entities/Pickup.h8
-rw-r--r--src/Entities/Player.cpp971
-rw-r--r--src/Entities/Player.h163
-rw-r--r--src/Entities/ProjectileEntity.cpp100
-rw-r--r--src/Entities/ProjectileEntity.h42
-rw-r--r--src/Entities/SplashPotionEntity.cpp134
-rw-r--r--src/Entities/SplashPotionEntity.h79
-rw-r--r--src/Entities/TNTEntity.cpp4
-rw-r--r--src/Entities/TNTEntity.h4
-rw-r--r--src/Entities/ThrownEggEntity.cpp7
-rw-r--r--src/Entities/ThrownEggEntity.h25
-rw-r--r--src/Entities/ThrownEnderPearlEntity.cpp40
-rw-r--r--src/Entities/ThrownEnderPearlEntity.h29
-rw-r--r--src/Entities/ThrownSnowballEntity.cpp11
-rw-r--r--src/Entities/ThrownSnowballEntity.h25
-rw-r--r--src/Entities/WitherSkullEntity.cpp49
-rw-r--r--src/Entities/WitherSkullEntity.h35
-rw-r--r--src/FastRandom.cpp3
-rw-r--r--src/FastRandom.h3
-rw-r--r--src/FurnaceRecipe.cpp274
-rw-r--r--src/FurnaceRecipe.h30
-rw-r--r--src/Generating/BioGen.cpp45
-rw-r--r--src/Generating/BioGen.h7
-rw-r--r--src/Generating/CMakeLists.txt65
-rw-r--r--src/Generating/Caves.cpp277
-rw-r--r--src/Generating/Caves.h22
-rw-r--r--src/Generating/ChunkDesc.cpp27
-rw-r--r--src/Generating/ChunkDesc.h5
-rw-r--r--src/Generating/ChunkGenerator.cpp14
-rw-r--r--src/Generating/ChunkGenerator.h2
-rw-r--r--src/Generating/CompoGen.cpp49
-rw-r--r--src/Generating/ComposableGenerator.cpp142
-rw-r--r--src/Generating/DistortedHeightmap.cpp28
-rw-r--r--src/Generating/EndGen.cpp4
-rw-r--r--src/Generating/EndGen.h3
-rw-r--r--src/Generating/FinishGen.cpp224
-rw-r--r--src/Generating/FinishGen.h109
-rw-r--r--src/Generating/GridStructGen.cpp184
-rw-r--r--src/Generating/GridStructGen.h145
-rw-r--r--src/Generating/HeiGen.cpp86
-rw-r--r--src/Generating/HeiGen.h21
-rw-r--r--src/Generating/MineShafts.cpp186
-rw-r--r--src/Generating/MineShafts.h36
-rw-r--r--src/Generating/NetherFortGen.cpp234
-rw-r--r--src/Generating/NetherFortGen.h63
-rw-r--r--src/Generating/Noise3DGenerator.cpp4
-rw-r--r--src/Generating/POCPieceGenerator.cpp7
-rw-r--r--src/Generating/PieceGenerator.cpp86
-rw-r--r--src/Generating/PieceGenerator.h53
-rw-r--r--src/Generating/Prefab.cpp142
-rw-r--r--src/Generating/Prefab.h38
-rw-r--r--src/Generating/PrefabPiecePool.cpp158
-rw-r--r--src/Generating/PrefabPiecePool.h85
-rw-r--r--src/Generating/Prefabs/AlchemistVillagePrefabs.cpp3590
-rw-r--r--src/Generating/Prefabs/AlchemistVillagePrefabs.h15
-rw-r--r--src/Generating/Prefabs/CMakeLists.txt31
-rw-r--r--src/Generating/Prefabs/JapaneseVillagePrefabs.cpp3386
-rw-r--r--src/Generating/Prefabs/JapaneseVillagePrefabs.h15
-rw-r--r--src/Generating/Prefabs/NetherFortPrefabs.cpp1112
-rw-r--r--src/Generating/Prefabs/PlainsVillagePrefabs.cpp6118
-rw-r--r--src/Generating/Prefabs/PlainsVillagePrefabs.h15
-rw-r--r--src/Generating/Prefabs/RainbowRoadPrefabs.cpp1406
-rw-r--r--src/Generating/Prefabs/RainbowRoadPrefabs.h15
-rw-r--r--src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp1669
-rw-r--r--src/Generating/Prefabs/SandFlatRoofVillagePrefabs.h15
-rw-r--r--src/Generating/Prefabs/SandVillagePrefabs.cpp2307
-rw-r--r--src/Generating/Prefabs/SandVillagePrefabs.h15
-rw-r--r--src/Generating/Prefabs/TestRailsPrefabs.cpp484
-rw-r--r--src/Generating/Prefabs/TestRailsPrefabs.h15
-rw-r--r--src/Generating/Prefabs/UnderwaterBasePrefabs.cpp2274
-rw-r--r--src/Generating/Prefabs/UnderwaterBasePrefabs.h15
-rw-r--r--src/Generating/RainbowRoadsGen.cpp116
-rw-r--r--src/Generating/RainbowRoadsGen.h47
-rw-r--r--src/Generating/Ravines.cpp245
-rw-r--r--src/Generating/Ravines.h24
-rw-r--r--src/Generating/RoughRavines.cpp318
-rw-r--r--src/Generating/RoughRavines.h86
-rw-r--r--src/Generating/StructGen.cpp55
-rw-r--r--src/Generating/TestRailsGen.cpp116
-rw-r--r--src/Generating/TestRailsGen.h47
-rw-r--r--src/Generating/Trees.cpp266
-rw-r--r--src/Generating/Trees.h2
-rw-r--r--src/Generating/UnderwaterBaseGen.cpp143
-rw-r--r--src/Generating/UnderwaterBaseGen.h50
-rw-r--r--src/Generating/VillageGen.cpp444
-rw-r--r--src/Generating/VillageGen.h57
-rw-r--r--src/Globals.h148
-rw-r--r--src/Group.cpp10
-rw-r--r--src/Group.h26
-rw-r--r--src/GroupManager.cpp81
-rw-r--r--src/GroupManager.h4
-rw-r--r--src/HTTPServer/CMakeLists.txt27
-rw-r--r--src/HTTPServer/HTTPConnection.cpp18
-rw-r--r--src/HTTPServer/HTTPConnection.h12
-rw-r--r--src/HTTPServer/HTTPMessage.cpp10
-rw-r--r--src/HTTPServer/HTTPMessage.h2
-rw-r--r--src/HTTPServer/HTTPServer.cpp54
-rw-r--r--src/HTTPServer/HTTPServer.h10
-rw-r--r--src/HTTPServer/MultipartParser.cpp4
-rw-r--r--src/HTTPServer/NameValueParser.cpp4
-rw-r--r--src/HTTPServer/SslHTTPConnection.cpp107
-rw-r--r--src/HTTPServer/SslHTTPConnection.h45
-rw-r--r--src/Inventory.cpp77
-rw-r--r--src/Inventory.h49
-rw-r--r--src/Item.cpp74
-rw-r--r--src/Item.h40
-rw-r--r--src/ItemGrid.cpp40
-rw-r--r--src/ItemGrid.h4
-rw-r--r--src/Items/CMakeLists.txt54
-rw-r--r--src/Items/ItemArmor.h43
-rw-r--r--src/Items/ItemBed.h2
-rw-r--r--src/Items/ItemBoat.h2
-rw-r--r--src/Items/ItemBow.h19
-rw-r--r--src/Items/ItemBrewingStand.h2
-rw-r--r--src/Items/ItemBucket.h81
-rw-r--r--src/Items/ItemCake.h2
-rw-r--r--src/Items/ItemCauldron.h2
-rw-r--r--src/Items/ItemComparator.h2
-rw-r--r--src/Items/ItemDoor.h6
-rw-r--r--src/Items/ItemFishingRod.h39
-rw-r--r--src/Items/ItemFlowerPot.h2
-rw-r--r--src/Items/ItemFood.h2
-rw-r--r--src/Items/ItemHandler.cpp173
-rw-r--r--src/Items/ItemHandler.h39
-rw-r--r--src/Items/ItemHoe.h10
-rw-r--r--src/Items/ItemItemFrame.h7
-rw-r--r--src/Items/ItemLeaves.h4
-rw-r--r--src/Items/ItemLighter.h6
-rw-r--r--src/Items/ItemLilypad.h18
-rw-r--r--src/Items/ItemMilk.h28
-rw-r--r--src/Items/ItemMinecart.h4
-rw-r--r--src/Items/ItemMobHead.h2
-rw-r--r--src/Items/ItemNetherWart.h2
-rw-r--r--src/Items/ItemPainting.h10
-rw-r--r--src/Items/ItemPickaxe.h19
-rw-r--r--src/Items/ItemPotion.h79
-rw-r--r--src/Items/ItemRedstoneDust.h4
-rw-r--r--src/Items/ItemRedstoneRepeater.h2
-rw-r--r--src/Items/ItemSapling.h2
-rw-r--r--src/Items/ItemSeeds.h8
-rw-r--r--src/Items/ItemShears.h27
-rw-r--r--src/Items/ItemShovel.h23
-rw-r--r--src/Items/ItemSign.h9
-rw-r--r--src/Items/ItemSpawnEgg.h40
-rw-r--r--src/Items/ItemString.h39
-rw-r--r--src/Items/ItemSugarcane.h2
-rw-r--r--src/Items/ItemSword.h36
-rw-r--r--src/Items/ItemThrowable.h21
-rw-r--r--src/LightingThread.cpp111
-rw-r--r--src/LightingThread.h19
-rw-r--r--src/LineBlockTracer.cpp57
-rw-r--r--src/Log.cpp32
-rw-r--r--src/Log.h4
-rw-r--r--src/MCLogger.cpp11
-rw-r--r--src/MCLogger.h9
-rw-r--r--src/Map.cpp6
-rw-r--r--src/Map.h24
-rw-r--r--src/MapManager.cpp6
-rw-r--r--src/MapManager.h27
-rw-r--r--src/Matrix4.h4
-rw-r--r--src/MobCensus.cpp6
-rw-r--r--src/MobFamilyCollecter.cpp2
-rw-r--r--src/MobFamilyCollecter.h4
-rw-r--r--src/MobProximityCounter.cpp18
-rw-r--r--src/MobProximityCounter.h17
-rw-r--r--src/MobSpawner.cpp17
-rw-r--r--src/MobSpawner.h6
-rw-r--r--src/Mobs/AggressiveMonster.cpp17
-rw-r--r--src/Mobs/Bat.cpp3
-rw-r--r--src/Mobs/Bat.h2
-rw-r--r--src/Mobs/Blaze.cpp6
-rw-r--r--src/Mobs/Blaze.h2
-rw-r--r--src/Mobs/CMakeLists.txt76
-rw-r--r--src/Mobs/CaveSpider.cpp16
-rw-r--r--src/Mobs/CaveSpider.h3
-rw-r--r--src/Mobs/Chicken.h2
-rw-r--r--src/Mobs/Cow.h2
-rw-r--r--src/Mobs/Creeper.cpp46
-rw-r--r--src/Mobs/Creeper.h4
-rw-r--r--src/Mobs/EnderDragon.h2
-rw-r--r--src/Mobs/Enderman.h2
-rw-r--r--src/Mobs/Ghast.cpp3
-rw-r--r--src/Mobs/Ghast.h2
-rw-r--r--src/Mobs/Giant.h2
-rw-r--r--src/Mobs/Horse.cpp2
-rw-r--r--src/Mobs/Horse.h2
-rw-r--r--src/Mobs/IronGolem.h4
-rw-r--r--src/Mobs/MagmaCube.h2
-rw-r--r--src/Mobs/Monster.cpp129
-rw-r--r--src/Mobs/Monster.h41
-rw-r--r--src/Mobs/Mooshroom.h2
-rw-r--r--src/Mobs/Ocelot.h2
-rw-r--r--src/Mobs/PassiveAggressiveMonster.cpp8
-rw-r--r--src/Mobs/PassiveAggressiveMonster.h2
-rw-r--r--src/Mobs/PassiveMonster.cpp8
-rw-r--r--src/Mobs/PassiveMonster.h2
-rw-r--r--src/Mobs/Pig.cpp20
-rw-r--r--src/Mobs/Pig.h3
-rw-r--r--src/Mobs/Sheep.cpp59
-rw-r--r--src/Mobs/Sheep.h21
-rw-r--r--src/Mobs/Silverfish.h2
-rw-r--r--src/Mobs/Skeleton.cpp25
-rw-r--r--src/Mobs/Skeleton.h10
-rw-r--r--src/Mobs/Slime.cpp76
-rw-r--r--src/Mobs/Slime.h15
-rw-r--r--src/Mobs/SnowGolem.cpp2
-rw-r--r--src/Mobs/SnowGolem.h2
-rw-r--r--src/Mobs/Spider.h2
-rw-r--r--src/Mobs/Squid.h2
-rw-r--r--src/Mobs/Villager.cpp15
-rw-r--r--src/Mobs/Villager.h9
-rw-r--r--src/Mobs/Witch.h2
-rw-r--r--src/Mobs/Wither.cpp56
-rw-r--r--src/Mobs/Wither.h15
-rw-r--r--src/Mobs/Wolf.cpp17
-rw-r--r--src/Mobs/Wolf.h4
-rw-r--r--src/Mobs/Zombie.cpp7
-rw-r--r--src/Mobs/Zombie.h10
-rw-r--r--src/Mobs/ZombiePigman.cpp6
-rw-r--r--src/Mobs/ZombiePigman.h6
-rw-r--r--src/MonsterConfig.cpp3
-rw-r--r--src/Noise.cpp288
-rw-r--r--src/Noise.h84
-rw-r--r--src/OSSupport/BlockingTCPLink.cpp142
-rw-r--r--src/OSSupport/BlockingTCPLink.h28
-rw-r--r--src/OSSupport/CMakeLists.txt43
-rw-r--r--src/OSSupport/CriticalSection.cpp10
-rw-r--r--src/OSSupport/CriticalSection.h2
-rw-r--r--src/OSSupport/Errors.cpp12
-rw-r--r--src/OSSupport/Event.cpp11
-rw-r--r--src/OSSupport/File.cpp15
-rw-r--r--src/OSSupport/File.h4
-rw-r--r--src/OSSupport/IsThread.cpp23
-rw-r--r--src/OSSupport/IsThread.h4
-rw-r--r--src/OSSupport/ListenThread.cpp2
-rw-r--r--src/OSSupport/Queue.h8
-rw-r--r--src/OSSupport/Semaphore.cpp76
-rw-r--r--src/OSSupport/Semaphore.h4
-rw-r--r--src/OSSupport/Sleep.cpp6
-rw-r--r--src/OSSupport/Sleep.h2
-rw-r--r--src/OSSupport/Socket.cpp33
-rw-r--r--src/OSSupport/Socket.h5
-rw-r--r--src/OSSupport/SocketThreads.cpp5
-rw-r--r--src/OSSupport/SocketThreads.h6
-rw-r--r--src/OSSupport/Thread.cpp44
-rw-r--r--src/OSSupport/Thread.h8
-rw-r--r--src/Piston.cpp297
-rw-r--r--src/Piston.h110
-rw-r--r--src/PolarSSL++/AesCfb128Decryptor.cpp67
-rw-r--r--src/PolarSSL++/AesCfb128Decryptor.h51
-rw-r--r--src/PolarSSL++/AesCfb128Encryptor.cpp68
-rw-r--r--src/PolarSSL++/AesCfb128Encryptor.h50
-rw-r--r--src/PolarSSL++/BlockingSslClientSocket.cpp195
-rw-r--r--src/PolarSSL++/BlockingSslClientSocket.h80
-rw-r--r--src/PolarSSL++/BufferedSslContext.cpp93
-rw-r--r--src/PolarSSL++/BufferedSslContext.h52
-rw-r--r--src/PolarSSL++/CMakeLists.txt42
-rw-r--r--src/PolarSSL++/CallbackSslContext.cpp60
-rw-r--r--src/PolarSSL++/CallbackSslContext.h64
-rw-r--r--src/PolarSSL++/CryptoKey.cpp149
-rw-r--r--src/PolarSSL++/CryptoKey.h76
-rw-r--r--src/PolarSSL++/CtrDrbgContext.cpp49
-rw-r--r--src/PolarSSL++/CtrDrbgContext.h63
-rw-r--r--src/PolarSSL++/EntropyContext.cpp29
-rw-r--r--src/PolarSSL++/EntropyContext.h31
-rw-r--r--src/PolarSSL++/RsaPrivateKey.cpp176
-rw-r--r--src/PolarSSL++/RsaPrivateKey.h67
-rw-r--r--src/PolarSSL++/Sha1Checksum.cpp138
-rw-r--r--src/PolarSSL++/Sha1Checksum.h52
-rw-r--r--src/PolarSSL++/SslContext.cpp303
-rw-r--r--src/PolarSSL++/SslContext.h156
-rw-r--r--src/PolarSSL++/X509Cert.cpp38
-rw-r--r--src/PolarSSL++/X509Cert.h41
-rw-r--r--src/ProbabDistrib.cpp2
-rw-r--r--src/Protocol/Authenticator.cpp332
-rw-r--r--src/Protocol/Authenticator.h15
-rw-r--r--src/Protocol/CMakeLists.txt30
-rw-r--r--src/Protocol/Protocol.h16
-rw-r--r--src/Protocol/Protocol125.cpp149
-rw-r--r--src/Protocol/Protocol125.h26
-rw-r--r--src/Protocol/Protocol132.cpp49
-rw-r--r--src/Protocol/Protocol132.h11
-rw-r--r--src/Protocol/Protocol14x.cpp4
-rw-r--r--src/Protocol/Protocol15x.cpp2
-rw-r--r--src/Protocol/Protocol16x.cpp18
-rw-r--r--src/Protocol/Protocol16x.h2
-rw-r--r--src/Protocol/Protocol17x.cpp244
-rw-r--r--src/Protocol/Protocol17x.h22
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp43
-rw-r--r--src/Protocol/ProtocolRecognizer.h17
-rw-r--r--src/RCONServer.cpp21
-rw-r--r--src/RCONServer.h2
-rw-r--r--src/Root.cpp92
-rw-r--r--src/Root.h46
-rw-r--r--src/Scoreboard.cpp18
-rw-r--r--src/Scoreboard.h35
-rw-r--r--src/Server.cpp74
-rw-r--r--src/Server.h51
-rw-r--r--src/SetChunkData.cpp115
-rw-r--r--src/SetChunkData.h120
-rw-r--r--src/Simulator/CMakeLists.txt35
-rw-r--r--src/Simulator/DelayedFluidSimulator.cpp10
-rw-r--r--src/Simulator/DelayedFluidSimulator.h4
-rw-r--r--src/Simulator/FireSimulator.cpp18
-rw-r--r--src/Simulator/FloodyFluidSimulator.cpp66
-rw-r--r--src/Simulator/FloodyFluidSimulator.h13
-rw-r--r--src/Simulator/FluidSimulator.cpp24
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp1550
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.h130
-rw-r--r--src/Simulator/NoopFluidSimulator.h2
-rw-r--r--src/Simulator/NoopRedstoneSimulator.h6
-rw-r--r--src/Simulator/SandSimulator.cpp8
-rw-r--r--src/Simulator/SandSimulator.h2
-rw-r--r--src/Simulator/Simulator.h4
-rw-r--r--src/Simulator/SimulatorManager.cpp6
-rw-r--r--src/Simulator/VanillaFluidSimulator.cpp10
-rw-r--r--src/Simulator/VanillaFluidSimulator.h2
-rw-r--r--src/Simulator/VaporizeFluidSimulator.cpp4
-rw-r--r--src/Statistics.cpp132
-rw-r--r--src/Statistics.h49
-rw-r--r--src/StringCompression.cpp14
-rw-r--r--src/StringCompression.h4
-rw-r--r--src/StringUtils.cpp115
-rw-r--r--src/StringUtils.h13
-rw-r--r--src/Tracer.cpp150
-rw-r--r--src/Tracer.h8
-rw-r--r--src/UI/CMakeLists.txt16
-rw-r--r--src/UI/SlotArea.cpp876
-rw-r--r--src/UI/SlotArea.h71
-rw-r--r--src/UI/Window.cpp173
-rw-r--r--src/UI/Window.h46
-rw-r--r--src/UI/WindowOwner.h2
-rw-r--r--src/Vector3.h89
-rw-r--r--src/VoronoiMap.cpp53
-rw-r--r--src/VoronoiMap.h25
-rw-r--r--src/WebAdmin.cpp12
-rw-r--r--src/WebAdmin.h8
-rw-r--r--src/World.cpp598
-rw-r--r--src/World.h237
-rw-r--r--src/WorldStorage/CMakeLists.txt35
-rw-r--r--src/WorldStorage/FastNBT.cpp50
-rw-r--r--src/WorldStorage/FastNBT.h34
-rw-r--r--src/WorldStorage/FireworksSerializer.cpp16
-rw-r--r--src/WorldStorage/MapSerializer.cpp8
-rw-r--r--src/WorldStorage/MapSerializer.h7
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp169
-rw-r--r--src/WorldStorage/NBTChunkSerializer.h7
-rw-r--r--src/WorldStorage/SchematicFileSerializer.cpp12
-rw-r--r--src/WorldStorage/ScoreboardSerializer.cpp10
-rw-r--r--src/WorldStorage/StatSerializer.cpp146
-rw-r--r--src/WorldStorage/StatSerializer.h55
-rw-r--r--src/WorldStorage/WSSAnvil.cpp193
-rw-r--r--src/WorldStorage/WSSAnvil.h9
-rw-r--r--src/WorldStorage/WSSCompact.cpp168
-rw-r--r--src/WorldStorage/WSSCompact.h11
-rw-r--r--src/WorldStorage/WorldStorage.cpp50
-rw-r--r--src/WorldStorage/WorldStorage.h16
-rw-r--r--src/XMLParser.h38
-rw-r--r--src/main.cpp48
545 files changed, 45196 insertions, 10684 deletions
diff --git a/src/AllocationPool.h b/src/AllocationPool.h
new file mode 100644
index 000000000..3c9dbe8c9
--- /dev/null
+++ b/src/AllocationPool.h
@@ -0,0 +1,113 @@
+
+#pragma once
+
+#include <memory>
+
+template<class T>
+class cAllocationPool
+{
+public:
+ class cStarvationCallbacks
+ {
+ public:
+ virtual ~cStarvationCallbacks() {}
+
+ /** Is called when the reserve buffer starts to be used **/
+ virtual void OnStartUsingReserve() = 0;
+
+ /** Is called once the reserve buffer has returned to normal size **/
+ virtual void OnEndUsingReserve() = 0;
+
+ /** Is called when the allocation pool is unable to allocate memory. Will be repeatedly
+ called if it does not free sufficient memory **/
+ virtual void OnOutOfReserve() = 0;
+ };
+
+ virtual ~cAllocationPool() {}
+
+ /** Allocates a pointer to T **/
+ virtual T * Allocate() = 0;
+
+ /** Frees the pointer passed in a_ptr, invalidating it **/
+ virtual void Free(T * a_ptr) = 0;
+};
+
+/** Allocates memory storing unused elements in a linked list. Keeps at least NumElementsInReserve
+elements in the list unless malloc fails so that the program has a reserve to handle OOM.**/
+template<class T, size_t NumElementsInReserve>
+class cListAllocationPool : public cAllocationPool<T>
+{
+ public:
+
+ cListAllocationPool(std::auto_ptr<typename cAllocationPool<T>::cStarvationCallbacks> a_Callbacks) :
+ m_Callbacks(a_Callbacks)
+ {
+ for (size_t i = 0; i < NumElementsInReserve; i++)
+ {
+ void * space = malloc(sizeof(T));
+ if (space == NULL)
+ {
+ m_Callbacks->OnStartUsingReserve();
+ break;
+ }
+ m_FreeList.push_front(space);
+ }
+ }
+
+ virtual ~cListAllocationPool()
+ {
+ while (!m_FreeList.empty())
+ {
+ free (m_FreeList.front());
+ m_FreeList.pop_front();
+ }
+ }
+
+ virtual T * Allocate() override
+ {
+ if (m_FreeList.size() <= NumElementsInReserve)
+ {
+ void * space = malloc(sizeof(T));
+ if (space != NULL)
+ {
+ return new(space) T;
+ }
+ else if (m_FreeList.size() == NumElementsInReserve)
+ {
+ m_Callbacks->OnStartUsingReserve();
+ }
+ else if (m_FreeList.empty())
+ {
+ m_Callbacks->OnOutOfReserve();
+ // Try again until the memory is avalable
+ return Allocate();
+ }
+ }
+ // placement new, used to initalize the object
+ T * ret = new (m_FreeList.front()) T;
+ m_FreeList.pop_front();
+ return ret;
+ }
+ virtual void Free(T * a_ptr) override
+ {
+ if (a_ptr == NULL)
+ {
+ return;
+ }
+ // placement destruct.
+ a_ptr->~T();
+ m_FreeList.push_front(a_ptr);
+ if (m_FreeList.size() == NumElementsInReserve)
+ {
+ m_Callbacks->OnEndUsingReserve();
+ }
+ }
+
+ private:
+ std::list<void *> m_FreeList;
+ std::auto_ptr<typename cAllocationPool<T>::cStarvationCallbacks> m_Callbacks;
+};
+
+
+
+
diff --git a/src/Bindings/.gitignore b/src/Bindings/.gitignore
new file mode 100644
index 000000000..0d00dd578
--- /dev/null
+++ b/src/Bindings/.gitignore
@@ -0,0 +1,2 @@
+lua51.dll
+LuaState_Call.inc
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 1cd7c74f8..1e5dfd2fe 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -40,7 +40,7 @@ $cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h"
$cfile "../Entities/TNTEntity.h"
-$cfile "../Entities/Effects.h"
+$cfile "../Entities/EntityEffect.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"
@@ -76,6 +76,7 @@ $cfile "../CompositeChat.h"
$cfile "../Map.h"
$cfile "../MapManager.h"
$cfile "../Scoreboard.h"
+$cfile "../Statistics.h"
diff --git a/src/Bindings/AllToLua_lua.bat b/src/Bindings/AllToLua_lua.bat
new file mode 100644
index 000000000..81c738f32
--- /dev/null
+++ b/src/Bindings/AllToLua_lua.bat
@@ -0,0 +1,27 @@
+
+:: AllToLua_Lua.bat
+:: This scripts updates the automatically-generates Lua bindings in Bindings.cpp / Bindings.h
+:: When called without any parameters, it will pause for a keypress at the end
+:: Call with any parameter to disable the wait (for buildserver use)
+:: This script assumes "lua" executable to be in PATH, it uses a pure-lua implementation of the ToLua processor
+
+@echo off
+
+
+
+
+
+:: Regenerate the files:
+echo Regenerating LUA bindings . . .
+lua ..\..\lib\tolua++\src\bin\lua\_driver.lua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+
+
+
+
+: Wait for keypress, if no param given:
+echo.
+if %ALLTOLUA_WAIT%N == N pause
+
+
+
+
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
new file mode 100644
index 000000000..2ea2fa8c0
--- /dev/null
+++ b/src/Bindings/CMakeLists.txt
@@ -0,0 +1,135 @@
+cmake_minimum_required (VERSION 2.6)
+project (MCServer)
+
+include_directories ("${PROJECT_SOURCE_DIR}/../")
+include_directories (".")
+
+SET (SRCS
+ Bindings.cpp
+ DeprecatedBindings.cpp
+ LuaChunkStay.cpp
+ LuaState.cpp
+ LuaWindow.cpp
+ ManualBindings.cpp
+ Plugin.cpp
+ PluginLua.cpp
+ PluginManager.cpp
+ WebPlugin.cpp
+)
+
+SET (HDRS
+ Bindings.h
+ DeprecatedBindings.h
+ LuaChunkStay.h
+ LuaFunctions.h
+ LuaState.h
+ LuaWindow.h
+ ManualBindings.h
+ Plugin.h
+ PluginLua.h
+ PluginManager.h
+ WebPlugin.h
+ tolua++.h
+)
+
+# List all the files that are generated as part of the Bindings build process
+set (BINDING_OUTPUTS
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Call.inc
+)
+
+set(BINDING_DEPENDENCIES
+ tolua
+ ../Bindings/virtual_method_hooks.lua
+ ../Bindings/AllToLua.pkg
+ ../Bindings/gen_LuaState_Call.lua
+ ../Bindings/LuaFunctions.h
+ ../Bindings/LuaState_Call.inc
+ ../Bindings/LuaWindow.h
+ ../Bindings/Plugin.h
+ ../Bindings/PluginLua.h
+ ../Bindings/PluginManager.h
+ ../Bindings/WebPlugin.h
+ ../BiomeDef.h
+ ../BlockArea.h
+ ../BlockEntities/BlockEntity.h
+ ../BlockEntities/BlockEntityWithItems.h
+ ../BlockEntities/ChestEntity.h
+ ../BlockEntities/DispenserEntity.h
+ ../BlockEntities/DropSpenserEntity.h
+ ../BlockEntities/DropperEntity.h
+ ../BlockEntities/FurnaceEntity.h
+ ../BlockEntities/HopperEntity.h
+ ../BlockEntities/JukeboxEntity.h
+ ../BlockEntities/NoteEntity.h
+ ../BlockEntities/SignEntity.h
+ ../BlockEntities/MobHeadEntity.h
+ ../BlockEntities/FlowerPotEntity.h
+ ../BlockID.h
+ ../BoundingBox.h
+ ../ChatColor.h
+ ../ChunkDef.h
+ ../ClientHandle.h
+ ../CraftingRecipes.h
+ ../Cuboid.h
+ ../Defines.h
+ ../Enchantments.h
+ ../Entities/EntityEffect.h
+ ../Entities/Entity.h
+ ../Entities/Floater.h
+ ../Entities/Pawn.h
+ ../Entities/Painting.h
+ ../Entities/Pickup.h
+ ../Entities/Player.h
+ ../Entities/ProjectileEntity.h
+ ../Entities/ArrowEntity.h
+ ../Entities/ThrownEggEntity.h
+ ../Entities/ThrownEnderPearlEntity.h
+ ../Entities/ExpBottleEntity.h
+ ../Entities/ThrownSnowballEntity.h
+ ../Entities/FireChargeEntity.h
+ ../Entities/FireworkEntity.h
+ ../Entities/GhastFireballEntity.h
+ ../Entities/TNTEntity.h
+ ../Entities/ExpOrb.h
+ ../Entities/HangingEntity.h
+ ../Entities/ItemFrame.h
+ ../Generating/ChunkDesc.h
+ ../Group.h
+ ../Inventory.h
+ ../Item.h
+ ../ItemGrid.h
+ ../Mobs/Monster.h
+ ../OSSupport/File.h
+ ../Root.h
+ ../Server.h
+ ../StringUtils.h
+ ../Tracer.h
+ ../UI/Window.h
+ ../Vector3.h
+ ../WebAdmin.h
+ ../World.h
+)
+
+if (NOT MSVC)
+ ADD_CUSTOM_COMMAND(
+ # add any new generated bindings here
+ OUTPUT ${BINDING_OUTPUTS}
+
+ # Regenerate bindings:
+ COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+
+ # add any new generation dependencies here
+ DEPENDS ${BINDING_DEPENDENCIES}
+ )
+endif ()
+set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
+set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE)
+
+if(NOT MSVC)
+ add_library(Bindings ${SRCS} ${HDRS})
+
+ target_link_libraries(Bindings lua sqlite tolualib polarssl)
+endif()
diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp
index d51ba2da3..36243bc92 100644
--- a/src/Bindings/DeprecatedBindings.cpp
+++ b/src/Bindings/DeprecatedBindings.cpp
@@ -25,9 +25,9 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
{
- tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
}
#endif
@@ -36,10 +36,10 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
{
tolua_error(tolua_S, "array indexing out of range.", NULL);
}
- tolua_pushnumber(tolua_S,(lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
+ tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
return 1;
}
-#endif //#ifndef TOLUA_DISABLE
+#endif // #ifndef TOLUA_DISABLE
@@ -53,8 +53,8 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
+ tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@@ -65,7 +65,7 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType));
return 1;
}
-#endif //#ifndef TOLUA_DISABLE
+#endif // #ifndef TOLUA_DISABLE
@@ -79,8 +79,8 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
+ tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@@ -91,7 +91,7 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType));
return 1;
}
-#endif //#ifndef TOLUA_DISABLE
+#endif // #ifndef TOLUA_DISABLE
@@ -105,8 +105,8 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
+ tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@@ -117,7 +117,7 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType));
return 1;
}
-#endif //#ifndef TOLUA_DISABLE
+#endif // #ifndef TOLUA_DISABLE
@@ -131,8 +131,8 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
+ tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@@ -143,7 +143,7 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType));
return 1;
}
-#endif //#ifndef TOLUA_DISABLE
+#endif // #ifndef TOLUA_DISABLE
@@ -157,8 +157,8 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
+ tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@@ -169,33 +169,7 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType));
return 1;
}
-#endif //#ifndef TOLUA_DISABLE
-
-
-
-
-
-/* get function: g_BlockRequiresSpecialTool */
-#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockRequiresSpecialTool
-static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S)
-{
- int BlockType;
- #ifndef TOLUA_RELEASE
- {
- tolua_Error tolua_err;
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
- }
- #endif
- BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
- if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
- {
- tolua_error(tolua_S, "array indexing out of range.", NULL);
- }
- tolua_pushboolean(tolua_S, cBlockInfo::RequiresSpecialTool((BLOCKTYPE)BlockType));
- return 1;
-}
-#endif //#ifndef TOLUA_DISABLE
+#endif // #ifndef TOLUA_DISABLE
@@ -209,8 +183,8 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
+ tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@@ -221,7 +195,7 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType));
return 1;
}
-#endif //#ifndef TOLUA_DISABLE
+#endif // #ifndef TOLUA_DISABLE
@@ -235,8 +209,8 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
+ if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
+ tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@@ -247,7 +221,7 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType));
return 1;
}
-#endif //#ifndef TOLUA_DISABLE
+#endif // #ifndef TOLUA_DISABLE
@@ -263,7 +237,6 @@ void DeprecatedBindings::Bind(lua_State * tolua_S)
tolua_array(tolua_S, "g_BlockOneHitDig", tolua_get_AllToLua_g_BlockOneHitDig, NULL);
tolua_array(tolua_S, "g_BlockPistonBreakable", tolua_get_AllToLua_g_BlockPistonBreakable, NULL);
tolua_array(tolua_S, "g_BlockIsSnowable", tolua_get_AllToLua_g_BlockIsSnowable, NULL);
- tolua_array(tolua_S, "g_BlockRequiresSpecialTool", tolua_get_AllToLua_g_BlockRequiresSpecialTool, NULL);
tolua_array(tolua_S, "g_BlockIsSolid", tolua_get_AllToLua_g_BlockIsSolid, NULL);
tolua_array(tolua_S, "g_BlockFullyOccupiesVoxel", tolua_get_AllToLua_g_BlockFullyOccupiesVoxel, NULL);
diff --git a/src/Bindings/DeprecatedBindings.h b/src/Bindings/DeprecatedBindings.h
index 5fc3cfa80..037d50489 100644
--- a/src/Bindings/DeprecatedBindings.h
+++ b/src/Bindings/DeprecatedBindings.h
@@ -4,5 +4,5 @@ struct lua_State;
class DeprecatedBindings
{
public:
- static void Bind( lua_State* tolua_S );
+ static void Bind( lua_State* tolua_S);
};
diff --git a/src/Bindings/LuaChunkStay.cpp b/src/Bindings/LuaChunkStay.cpp
index db865cfa4..59b02d8f7 100644
--- a/src/Bindings/LuaChunkStay.cpp
+++ b/src/Bindings/LuaChunkStay.cpp
@@ -42,7 +42,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
// Add each set of coords:
int NumChunks = luaL_getn(L, a_ChunkCoordTableStackPos);
- m_Chunks.reserve(NumChunks);
+ m_Chunks.reserve((size_t)NumChunks);
for (int idx = 1; idx <= NumChunks; idx++)
{
// Push the idx-th element of the array onto stack top, check that it's a table:
@@ -76,7 +76,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
-void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
+void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
{
// Check that the element has 2 coords:
int NumCoords = luaL_getn(L, -1);
diff --git a/src/Bindings/LuaFunctions.h b/src/Bindings/LuaFunctions.h
index 4f9eab86d..2ea37d7a4 100644
--- a/src/Bindings/LuaFunctions.h
+++ b/src/Bindings/LuaFunctions.h
@@ -4,12 +4,12 @@
#include <time.h>
// tolua_begin
-unsigned int GetTime()
+inline unsigned int GetTime()
{
return (unsigned int)time(0);
}
-std::string GetChar( std::string & a_Str, unsigned int a_Idx )
+inline std::string GetChar( std::string & a_Str, unsigned int a_Idx)
{
return std::string(1, a_Str[ a_Idx ]);
}
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index a33459ad2..e123a87c9 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -40,7 +40,7 @@ const cLuaState::cRet cLuaState::Return = {};
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cLuaState:
cLuaState::cLuaState(const AString & a_SubsystemName) :
@@ -372,11 +372,11 @@ void cLuaState::Push(const AStringVector & a_Vector)
-void cLuaState::PushUserType(void * a_Object, const char * a_Type)
+void cLuaState::Push(const cCraftingGrid * a_Grid)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Object, a_Type);
+ tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid");
m_NumCurrentFunctionArgs += 1;
}
@@ -384,11 +384,11 @@ void cLuaState::PushUserType(void * a_Object, const char * a_Type)
-void cLuaState::Push(int a_Value)
+void cLuaState::Push(const cCraftingRecipe * a_Recipe)
{
ASSERT(IsValid());
- tolua_pushnumber(m_LuaState, a_Value);
+ tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe");
m_NumCurrentFunctionArgs += 1;
}
@@ -396,11 +396,11 @@ void cLuaState::Push(int a_Value)
-void cLuaState::Push(double a_Value)
+void cLuaState::Push(const char * a_Value)
{
ASSERT(IsValid());
- tolua_pushnumber(m_LuaState, a_Value);
+ tolua_pushstring(m_LuaState, a_Value);
m_NumCurrentFunctionArgs += 1;
}
@@ -408,11 +408,11 @@ void cLuaState::Push(double a_Value)
-void cLuaState::Push(const char * a_Value)
+void cLuaState::Push(const cItems & a_Items)
{
ASSERT(IsValid());
- tolua_pushstring(m_LuaState, a_Value);
+ tolua_pushusertype(m_LuaState, (void *)&a_Items, "cItems");
m_NumCurrentFunctionArgs += 1;
}
@@ -420,11 +420,11 @@ void cLuaState::Push(const char * a_Value)
-void cLuaState::Push(bool a_Value)
+void cLuaState::Push(const cPlayer * a_Player)
{
ASSERT(IsValid());
- tolua_pushboolean(m_LuaState, a_Value ? 1 : 0);
+ tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer");
m_NumCurrentFunctionArgs += 1;
}
@@ -432,11 +432,11 @@ void cLuaState::Push(bool a_Value)
-void cLuaState::Push(cWorld * a_World)
+void cLuaState::Push(const HTTPRequest * a_Request)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_World, "cWorld");
+ tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPRequest");
m_NumCurrentFunctionArgs += 1;
}
@@ -444,11 +444,11 @@ void cLuaState::Push(cWorld * a_World)
-void cLuaState::Push(cPlayer * a_Player)
+void cLuaState::Push(const HTTPTemplateRequest * a_Request)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Player, "cPlayer");
+ tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPTemplateRequest");
m_NumCurrentFunctionArgs += 1;
}
@@ -456,11 +456,11 @@ void cLuaState::Push(cPlayer * a_Player)
-void cLuaState::Push(const cPlayer * a_Player)
+void cLuaState::Push(const Vector3d & a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer");
+ tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3d");
m_NumCurrentFunctionArgs += 1;
}
@@ -468,11 +468,11 @@ void cLuaState::Push(const cPlayer * a_Player)
-void cLuaState::Push(cEntity * a_Entity)
+void cLuaState::Push(bool a_Value)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Entity, "cEntity");
+ tolua_pushboolean(m_LuaState, a_Value ? 1 : 0);
m_NumCurrentFunctionArgs += 1;
}
@@ -480,11 +480,11 @@ void cLuaState::Push(cEntity * a_Entity)
-void cLuaState::Push(cProjectileEntity * a_ProjectileEntity)
+void cLuaState::Push(cBlockEntity * a_BlockEntity)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_ProjectileEntity, "cProjectileEntity");
+ tolua_pushusertype(m_LuaState, a_BlockEntity, "cBlockEntity");
m_NumCurrentFunctionArgs += 1;
}
@@ -492,11 +492,47 @@ void cLuaState::Push(cProjectileEntity * a_ProjectileEntity)
-void cLuaState::Push(cMonster * a_Monster)
+void cLuaState::Push(cChunkDesc * a_ChunkDesc)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Monster, "cMonster");
+ tolua_pushusertype(m_LuaState, a_ChunkDesc, "cChunkDesc");
+ m_NumCurrentFunctionArgs += 1;
+}
+
+
+
+
+
+void cLuaState::Push(cClientHandle * a_Client)
+{
+ ASSERT(IsValid());
+
+ tolua_pushusertype(m_LuaState, a_Client, "cClientHandle");
+ m_NumCurrentFunctionArgs += 1;
+}
+
+
+
+
+
+void cLuaState::Push(cEntity * a_Entity)
+{
+ ASSERT(IsValid());
+
+ tolua_pushusertype(m_LuaState, a_Entity, "cEntity");
+ m_NumCurrentFunctionArgs += 1;
+}
+
+
+
+
+
+void cLuaState::Push(cHopperEntity * a_Hopper)
+{
+ ASSERT(IsValid());
+
+ tolua_pushusertype(m_LuaState, a_Hopper, "cHopperEntity");
m_NumCurrentFunctionArgs += 1;
}
@@ -528,11 +564,11 @@ void cLuaState::Push(cItems * a_Items)
-void cLuaState::Push(const cItems & a_Items)
+void cLuaState::Push(cMonster * a_Monster)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)&a_Items, "cItems");
+ tolua_pushusertype(m_LuaState, a_Monster, "cMonster");
m_NumCurrentFunctionArgs += 1;
}
@@ -540,11 +576,11 @@ void cLuaState::Push(const cItems & a_Items)
-void cLuaState::Push(cClientHandle * a_Client)
+void cLuaState::Push(cPickup * a_Pickup)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Client, "cClientHandle");
+ tolua_pushusertype(m_LuaState, a_Pickup, "cPickup");
m_NumCurrentFunctionArgs += 1;
}
@@ -552,11 +588,11 @@ void cLuaState::Push(cClientHandle * a_Client)
-void cLuaState::Push(cPickup * a_Pickup)
+void cLuaState::Push(cPlayer * a_Player)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Pickup, "cPickup");
+ tolua_pushusertype(m_LuaState, a_Player, "cPlayer");
m_NumCurrentFunctionArgs += 1;
}
@@ -564,11 +600,11 @@ void cLuaState::Push(cPickup * a_Pickup)
-void cLuaState::Push(cChunkDesc * a_ChunkDesc)
+void cLuaState::Push(cPluginLua * a_Plugin)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_ChunkDesc, "cChunkDesc");
+ tolua_pushusertype(m_LuaState, a_Plugin, "cPluginLua");
m_NumCurrentFunctionArgs += 1;
}
@@ -576,11 +612,11 @@ void cLuaState::Push(cChunkDesc * a_ChunkDesc)
-void cLuaState::Push(const cCraftingGrid * a_Grid)
+void cLuaState::Push(cProjectileEntity * a_ProjectileEntity)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid");
+ tolua_pushusertype(m_LuaState, a_ProjectileEntity, "cProjectileEntity");
m_NumCurrentFunctionArgs += 1;
}
@@ -588,11 +624,11 @@ void cLuaState::Push(const cCraftingGrid * a_Grid)
-void cLuaState::Push(const cCraftingRecipe * a_Recipe)
+void cLuaState::Push(cTNTEntity * a_TNTEntity)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe");
+ tolua_pushusertype(m_LuaState, a_TNTEntity, "cTNTEntity");
m_NumCurrentFunctionArgs += 1;
}
@@ -600,11 +636,11 @@ void cLuaState::Push(const cCraftingRecipe * a_Recipe)
-void cLuaState::Push(TakeDamageInfo * a_TDI)
+void cLuaState::Push(cWebAdmin * a_WebAdmin)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_TDI, "TakeDamageInfo");
+ tolua_pushusertype(m_LuaState, a_WebAdmin, "cWebAdmin");
m_NumCurrentFunctionArgs += 1;
}
@@ -624,11 +660,11 @@ void cLuaState::Push(cWindow * a_Window)
-void cLuaState::Push(cPluginLua * a_Plugin)
+void cLuaState::Push(cWorld * a_World)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Plugin, "cPluginLua");
+ tolua_pushusertype(m_LuaState, a_World, "cWorld");
m_NumCurrentFunctionArgs += 1;
}
@@ -636,11 +672,11 @@ void cLuaState::Push(cPluginLua * a_Plugin)
-void cLuaState::Push(const HTTPRequest * a_Request)
+void cLuaState::Push(double a_Value)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPRequest");
+ tolua_pushnumber(m_LuaState, a_Value);
m_NumCurrentFunctionArgs += 1;
}
@@ -648,11 +684,11 @@ void cLuaState::Push(const HTTPRequest * a_Request)
-void cLuaState::Push(cWebAdmin * a_WebAdmin)
+void cLuaState::Push(int a_Value)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_WebAdmin, "cWebAdmin");
+ tolua_pushnumber(m_LuaState, a_Value);
m_NumCurrentFunctionArgs += 1;
}
@@ -660,11 +696,11 @@ void cLuaState::Push(cWebAdmin * a_WebAdmin)
-void cLuaState::Push(const HTTPTemplateRequest * a_Request)
+void cLuaState::Push(TakeDamageInfo * a_TDI)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPTemplateRequest");
+ tolua_pushusertype(m_LuaState, a_TDI, "TakeDamageInfo");
m_NumCurrentFunctionArgs += 1;
}
@@ -672,11 +708,11 @@ void cLuaState::Push(const HTTPTemplateRequest * a_Request)
-void cLuaState::Push(cTNTEntity * a_TNTEntity)
+void cLuaState::Push(Vector3i * a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_TNTEntity, "cTNTEntity");
+ tolua_pushusertype(m_LuaState, a_Vector, "Vector3i");
m_NumCurrentFunctionArgs += 1;
}
@@ -684,11 +720,11 @@ void cLuaState::Push(cTNTEntity * a_TNTEntity)
-void cLuaState::Push(Vector3i * a_Vector)
+void cLuaState::Push(Vector3d * a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Vector, "Vector3i");
+ tolua_pushusertype(m_LuaState, a_Vector, "Vector3d");
m_NumCurrentFunctionArgs += 1;
}
@@ -715,23 +751,12 @@ void cLuaState::Push(void * a_Ptr)
-void cLuaState::Push(cHopperEntity * a_Hopper)
-{
- ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, a_Hopper, "cHopperEntity");
- m_NumCurrentFunctionArgs += 1;
-}
-
-
-
-
-void cLuaState::Push(cBlockEntity * a_BlockEntity)
+void cLuaState::PushUserType(void * a_Object, const char * a_Type)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_BlockEntity, "cBlockEntity");
+ tolua_pushusertype(m_LuaState, a_Object, a_Type);
m_NumCurrentFunctionArgs += 1;
}
@@ -786,6 +811,18 @@ void cLuaState::GetStackValue(int a_StackPos, double & a_ReturnedVal)
+void cLuaState::GetStackValue(int a_StackPos, eWeather & a_ReturnedVal)
+{
+ if (lua_isnumber(m_LuaState, a_StackPos))
+ {
+ a_ReturnedVal = (eWeather)Clamp((int)tolua_tonumber(m_LuaState, a_StackPos, a_ReturnedVal), (int)wSunny, (int)wThunderstorm);
+ }
+}
+
+
+
+
+
bool cLuaState::CallFunction(int a_NumResults)
{
ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
@@ -1299,9 +1336,8 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
{
UNUSED(a_Header); // The param seems unused when compiling for release, so the compiler warns
-
// Format string consisting only of %s is used to appease the compiler
- LOGD("%s",(a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
+ LOGD("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
for (int i = lua_gettop(a_LuaState); i > 0; i--)
{
AString Value;
@@ -1334,7 +1370,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cLuaState::cRef:
cLuaState::cRef::cRef(void) :
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index b9ca2f29b..afac77ce8 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -9,10 +9,11 @@ Owned lua_State is created by calling Create() and the cLuaState automatically c
Or, lua_State can be attached by calling Attach(), the cLuaState doesn't close such a state
Attaching a state will automatically close an owned state.
-Calling a Lua function is done by pushing the function, either by PushFunction() or PushFunctionFromRegistry(),
-then pushing the arguments (PushString(), PushNumber(), PushUserData() etc.) and finally
-executing CallFunction(). cLuaState automatically keeps track of the number of arguments and the name of the
-function (for logging purposes), which makes the call less error-prone.
+Calling a Lua function is done internally by pushing the function using PushFunction(), then pushing the
+arguments and finally executing CallFunction(). cLuaState automatically keeps track of the number of
+arguments and the name of the function (for logging purposes). After the call the return values are read from
+the stack using GetStackValue(). All of this is wrapped in a templated function overloads cLuaState::Call(),
+which is generated automatically by gen_LuaState_Call.lua script file into the LuaState_Call.inc file.
Reference management is provided by the cLuaState::cRef class. This is used when you need to hold a reference to
any Lua object across several function calls; usually this is used for callbacks. The class is RAII-like, with
@@ -30,6 +31,7 @@ extern "C"
}
#include "../Vector3.h"
+#include "../Defines.h"
@@ -126,7 +128,7 @@ public:
/** Creates a new instance. The LuaState is not initialized.
- a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins,
+ a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins,
or "LuaScript" for the cLuaScript template
*/
cLuaState(const AString & a_SubsystemName);
@@ -173,38 +175,42 @@ public:
/** Returns true if a_FunctionName is a valid Lua function that can be called */
bool HasFunction(const char * a_FunctionName);
- // Push a value onto the stack
+ // Push a const value onto the stack (keep alpha-sorted):
void Push(const AString & a_String);
void Push(const AStringVector & a_Vector);
- void Push(int a_Value);
- void Push(double a_Value);
+ void Push(const cCraftingGrid * a_Grid);
+ void Push(const cCraftingRecipe * a_Recipe);
void Push(const char * a_Value);
- void Push(bool a_Value);
- void Push(cWorld * a_World);
- void Push(cPlayer * a_Player);
+ void Push(const cItems & a_Items);
void Push(const cPlayer * a_Player);
+ void Push(const HTTPRequest * a_Request);
+ void Push(const HTTPTemplateRequest * a_Request);
+ void Push(const Vector3d & a_Vector);
+
+ // Push a value onto the stack (keep alpha-sorted):
+ void Push(bool a_Value);
+ void Push(cBlockEntity * a_BlockEntity);
+ void Push(cChunkDesc * a_ChunkDesc);
+ void Push(cClientHandle * a_ClientHandle);
void Push(cEntity * a_Entity);
- void Push(cProjectileEntity * a_ProjectileEntity);
- void Push(cMonster * a_Monster);
+ void Push(cHopperEntity * a_Hopper);
void Push(cItem * a_Item);
void Push(cItems * a_Items);
- void Push(const cItems & a_Items);
- void Push(cClientHandle * a_ClientHandle);
+ void Push(cMonster * a_Monster);
void Push(cPickup * a_Pickup);
- void Push(cChunkDesc * a_ChunkDesc);
- void Push(const cCraftingGrid * a_Grid);
- void Push(const cCraftingRecipe * a_Recipe);
- void Push(TakeDamageInfo * a_TDI);
- void Push(cWindow * a_Window);
+ void Push(cPlayer * a_Player);
void Push(cPluginLua * a_Plugin);
- void Push(const HTTPRequest * a_Request);
- void Push(cWebAdmin * a_WebAdmin);
- void Push(const HTTPTemplateRequest * a_Request);
+ void Push(cProjectileEntity * a_ProjectileEntity);
void Push(cTNTEntity * a_TNTEntity);
+ void Push(cWebAdmin * a_WebAdmin);
+ void Push(cWindow * a_Window);
+ void Push(cWorld * a_World);
+ void Push(double a_Value);
+ void Push(int a_Value);
+ void Push(TakeDamageInfo * a_TDI);
+ void Push(Vector3d * a_Vector);
void Push(Vector3i * a_Vector);
void Push(void * a_Ptr);
- void Push(cHopperEntity * a_Hopper);
- void Push(cBlockEntity * a_BlockEntity);
/** Retrieve value at a_StackPos, if it is a valid bool. If not, a_Value is unchanged */
void GetStackValue(int a_StackPos, bool & a_Value);
@@ -218,625 +224,13 @@ public:
/** Retrieve value at a_StackPos, if it is a valid number. If not, a_Value is unchanged */
void GetStackValue(int a_StackPos, double & a_Value);
+ /** Retrieve value at a_StackPos, if it is a valid number, converting and clamping it to eWeather.
+ If not, a_Value is unchanged. */
+ void GetStackValue(int a_StackPos, eWeather & a_Value);
+
- /** Call any 0-param 0-return Lua function in a single line: */
- template <typename FnT>
- bool Call(FnT a_FnName)
- {
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- return CallFunction(0);
- }
-
- /** Call any 1-param 0-return Lua function in a single line: */
- template<
- typename FnT,
- typename ArgT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1)
- {
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- return CallFunction(0);
- }
-
- /** Call any 2-param 0-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2)
- {
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- return CallFunction(0);
- }
-
- /** Call any 3-param 0-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3)
- {
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- return CallFunction(0);
- }
-
- /** Call any 0-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename RetT1
- >
- bool Call(FnT a_FnName, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 1-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- int InitialTop = lua_gettop(m_LuaState);
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- ASSERT(InitialTop == lua_gettop(m_LuaState));
- return true;
- }
-
- /** Call any 2-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 3-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 4-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 5-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 6-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 7-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename ArgT7, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 8-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename ArgT7, typename ArgT8, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 9-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename ArgT7, typename ArgT8, typename ArgT9, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- Push(a_Arg9);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 10-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename ArgT7, typename ArgT8, typename ArgT9, typename ArgT10, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, ArgT10 a_Arg10, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- Push(a_Arg9);
- Push(a_Arg10);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 1-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 2-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 3-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 4-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 5-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 6-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 7-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6, typename ArgT7,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 7-param 3-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6, typename ArgT7,
- typename RetT1, typename RetT2, typename RetT3
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- if (!CallFunction(3))
- {
- return false;
- }
- GetStackValue(-3, a_Ret1);
- GetStackValue(-2, a_Ret2);
- GetStackValue(-1, a_Ret3);
- lua_pop(m_LuaState, 3);
- return true;
- }
-
- /** Call any 8-param 3-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6, typename ArgT7, typename ArgT8,
- typename RetT1, typename RetT2, typename RetT3
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- if (!CallFunction(3))
- {
- return false;
- }
- GetStackValue(-3, a_Ret1);
- GetStackValue(-2, a_Ret2);
- GetStackValue(-1, a_Ret3);
- lua_pop(m_LuaState, 3);
- return true;
- }
-
- /** Call any 9-param 5-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9,
- typename RetT1, typename RetT2, typename RetT3, typename RetT4, typename RetT5
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3, RetT4 & a_Ret4, RetT5 & a_Ret5)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- Push(a_Arg9);
- if (!CallFunction(5))
- {
- return false;
- }
- GetStackValue(-5, a_Ret1);
- GetStackValue(-4, a_Ret2);
- GetStackValue(-3, a_Ret3);
- GetStackValue(-2, a_Ret4);
- GetStackValue(-1, a_Ret5);
- lua_pop(m_LuaState, 5);
- return true;
- }
+ // Include the cLuaState::Call() overload implementation that is generated by the gen_LuaState_Call.lua script:
+ #include "LuaState_Call.inc"
/** Returns true if the specified parameters on the stack are of the specified usertable type; also logs warning if not. Used for static functions */
diff --git a/src/Bindings/LuaWindow.cpp b/src/Bindings/LuaWindow.cpp
index 733304eb2..1a2582ab0 100644
--- a/src/Bindings/LuaWindow.cpp
+++ b/src/Bindings/LuaWindow.cpp
@@ -7,13 +7,13 @@
#include "../UI/SlotArea.h"
#include "PluginLua.h"
#include "../Entities/Player.h"
-#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL
+#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cLuaWindow:
cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) :
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index b3f75aff1..df9687fc0 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -4,7 +4,7 @@
#include "ManualBindings.h"
#undef TOLUA_TEMPLATE_BIND
#include "tolua++/include/tolua++.h"
-
+#include "polarssl/md5.h"
#include "Plugin.h"
#include "PluginLua.h"
#include "PluginManager.h"
@@ -25,7 +25,6 @@
#include "../BlockEntities/NoteEntity.h"
#include "../BlockEntities/MobHeadEntity.h"
#include "../BlockEntities/FlowerPotEntity.h"
-#include "md5/md5.h"
#include "../LineBlockTracer.h"
#include "../WorldStorage/SchematicFileSerializer.h"
#include "../CompositeChat.h"
@@ -34,10 +33,8 @@
-/****************************
- * Better error reporting for Lua
- **/
-int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaError)
+// Better error reporting for Lua
+static int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaError)
{
// Retrieve current function name
lua_Debug entry;
@@ -57,7 +54,7 @@ int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaErro
-int lua_do_error(lua_State* L, const char * a_pFormat, ...)
+static int lua_do_error(lua_State* L, const char * a_pFormat, ...)
{
// Retrieve current function name
lua_Debug entry;
@@ -82,10 +79,7 @@ int lua_do_error(lua_State* L, const char * a_pFormat, ...)
-/****************************
- * Lua bound functions with special return types
- **/
-
+// Lua bound functions with special return types
static int tolua_StringSplit(lua_State * tolua_S)
{
cLuaState LuaState(tolua_S);
@@ -235,7 +229,7 @@ static int tolua_Base64Decode(lua_State * tolua_S)
-cPluginLua * GetLuaPlugin(lua_State * L)
+static cPluginLua * GetLuaPlugin(lua_State * L)
{
// Get the plugin identification out of LuaState:
lua_getglobal(L, LUA_PLUGIN_INSTANCE_VAR_NAME);
@@ -325,9 +319,9 @@ static int tolua_DoWith(lua_State* tolua_S)
{
public:
cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef)
- : LuaState( a_LuaState )
- , FuncRef( a_FuncRef )
- , TableRef( a_TableRef )
+ : LuaState( a_LuaState)
+ , FuncRef( a_FuncRef)
+ , TableRef( a_TableRef)
{}
private:
@@ -364,7 +358,7 @@ static int tolua_DoWith(lua_State* tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
- tolua_pushboolean(tolua_S, bRetVal );
+ tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@@ -454,7 +448,7 @@ static int tolua_DoWithID(lua_State* tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
- tolua_pushboolean(tolua_S, bRetVal );
+ tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@@ -484,7 +478,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
int ItemX = ((int)tolua_tonumber(tolua_S, 2, 0));
int ItemY = ((int)tolua_tonumber(tolua_S, 3, 0));
int ItemZ = ((int)tolua_tonumber(tolua_S, 4, 0));
- LOG("x %i y %i z %i", ItemX, ItemY, ItemZ );
+ LOG("x %i y %i z %i", ItemX, ItemY, ItemZ);
if (!lua_isfunction( tolua_S, 5))
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a function for parameter #4");
@@ -512,9 +506,9 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
{
public:
cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef)
- : LuaState( a_LuaState )
- , FuncRef( a_FuncRef )
- , TableRef( a_TableRef )
+ : LuaState( a_LuaState)
+ , FuncRef( a_FuncRef)
+ , TableRef( a_TableRef)
{}
private:
@@ -550,7 +544,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
- tolua_pushboolean(tolua_S, bRetVal );
+ tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@@ -558,10 +552,12 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
-template< class Ty1,
- class Ty2,
- bool (Ty1::*Func1)(int, int, cItemCallback<Ty2> &) >
-static int tolua_ForEachInChunk(lua_State* tolua_S)
+template<
+ class Ty1,
+ class Ty2,
+ bool (Ty1::*Func1)(int, int, cItemCallback<Ty2> &)
+>
+static int tolua_ForEachInChunk(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
if ((NumArgs != 3) && (NumArgs != 4))
@@ -605,9 +601,9 @@ static int tolua_ForEachInChunk(lua_State* tolua_S)
{
public:
cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef)
- : LuaState( a_LuaState )
- , FuncRef( a_FuncRef )
- , TableRef( a_TableRef )
+ : LuaState( a_LuaState)
+ , FuncRef( a_FuncRef)
+ , TableRef( a_TableRef)
{}
private:
@@ -644,7 +640,7 @@ static int tolua_ForEachInChunk(lua_State* tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
- tolua_pushboolean(tolua_S, bRetVal );
+ tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@@ -652,18 +648,20 @@ static int tolua_ForEachInChunk(lua_State* tolua_S)
-template< class Ty1,
- class Ty2,
- bool (Ty1::*Func1)(cItemCallback<Ty2> &) >
+template<
+ class Ty1,
+ class Ty2,
+ bool (Ty1::*Func1)(cItemCallback<Ty2> &)
+>
static int tolua_ForEach(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
- if( NumArgs != 1 && NumArgs != 2)
+ if ((NumArgs != 1) && (NumArgs != 2))
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs);
}
- Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
+ Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
@@ -696,16 +694,16 @@ static int tolua_ForEach(lua_State * tolua_S)
{
public:
cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef)
- : LuaState( a_LuaState )
- , FuncRef( a_FuncRef )
- , TableRef( a_TableRef )
+ : LuaState( a_LuaState)
+ , FuncRef( a_FuncRef)
+ , TableRef( a_TableRef)
{}
private:
virtual bool Item(Ty2 * a_Item) override
{
lua_rawgeti( LuaState, LUA_REGISTRYINDEX, FuncRef); /* Push function reference */
- tolua_pushusertype( LuaState, a_Item, Ty2::GetClassStatic() );
+ tolua_pushusertype( LuaState, a_Item, Ty2::GetClassStatic());
if (TableRef != LUA_REFNIL)
{
lua_rawgeti( LuaState, LUA_REGISTRYINDEX, TableRef); /* Push table reference */
@@ -735,7 +733,7 @@ static int tolua_ForEach(lua_State * tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
- tolua_pushboolean(tolua_S, bRetVal );
+ tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@@ -960,7 +958,7 @@ tolua_lerror:
static int tolua_cWorld_TryGetHeight(lua_State * tolua_S)
{
// Exported manually, because tolua would require the out-only param a_Height to be used when calling
- // Takes (a_World,) a_BlockX, a_BlockZ
+ // Takes a_World, a_BlockX, a_BlockZ
// Returns Height, IsValid
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -1362,7 +1360,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
- if( NumArgs != 1)
+ if (NumArgs != 1)
{
LOGWARN("Error in function call 'ForEachCommand': Requires 1 argument, got %i", NumArgs);
return 0;
@@ -1392,8 +1390,8 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
{
public:
cLuaCallback(lua_State * a_LuaState, int a_FuncRef)
- : LuaState( a_LuaState )
- , FuncRef( a_FuncRef )
+ : LuaState( a_LuaState)
+ , FuncRef( a_FuncRef)
{}
private:
@@ -1439,7 +1437,7 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
- if( NumArgs != 1)
+ if (NumArgs != 1)
{
LOGWARN("Error in function call 'ForEachConsoleCommand': Requires 1 argument, got %i", NumArgs);
return 0;
@@ -1469,8 +1467,8 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
{
public:
cLuaCallback(lua_State * a_LuaState, int a_FuncRef)
- : LuaState( a_LuaState )
- , FuncRef( a_FuncRef )
+ : LuaState( a_LuaState)
+ , FuncRef( a_FuncRef)
{}
private:
@@ -1765,6 +1763,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
if (!ChunkStay->AddChunks(2))
{
delete ChunkStay;
+ ChunkStay = NULL;
return 0;
}
@@ -1776,20 +1775,20 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
-static int tolua_cPlayer_GetGroups(lua_State* tolua_S)
+static int tolua_cPlayer_GetGroups(lua_State * tolua_S)
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S, 1, NULL);
+ cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL);
const cPlayer::GroupList & AllGroups = self->GetGroups();
- lua_createtable(tolua_S, AllGroups.size(), 0);
+ lua_createtable(tolua_S, (int)AllGroups.size(), 0);
int newTable = lua_gettop(tolua_S);
int index = 1;
cPlayer::GroupList::const_iterator iter = AllGroups.begin();
- while(iter != AllGroups.end())
+ while (iter != AllGroups.end())
{
- const cGroup* Group = *iter;
- tolua_pushusertype( tolua_S, (void*)Group, "const cGroup" );
+ const cGroup * Group = *iter;
+ tolua_pushusertype(tolua_S, (void *)Group, "const cGroup");
lua_rawseti(tolua_S, newTable, index);
++iter;
++index;
@@ -1801,20 +1800,20 @@ static int tolua_cPlayer_GetGroups(lua_State* tolua_S)
-static int tolua_cPlayer_GetResolvedPermissions(lua_State* tolua_S)
+static int tolua_cPlayer_GetResolvedPermissions(lua_State * tolua_S)
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S, 1, NULL);
+ cPlayer * self = (cPlayer*) tolua_tousertype(tolua_S, 1, NULL);
cPlayer::StringList AllPermissions = self->GetResolvedPermissions();
- lua_createtable(tolua_S, AllPermissions.size(), 0);
+ lua_createtable(tolua_S, (int)AllPermissions.size(), 0);
int newTable = lua_gettop(tolua_S);
int index = 1;
cPlayer::StringList::iterator iter = AllPermissions.begin();
- while(iter != AllPermissions.end())
+ while (iter != AllPermissions.end())
{
- std::string& Permission = *iter;
- tolua_pushstring( tolua_S, Permission.c_str() );
+ std::string & Permission = *iter;
+ lua_pushlstring(tolua_S, Permission.c_str(), Permission.length());
lua_rawseti(tolua_S, newTable, index);
++iter;
++index;
@@ -1927,28 +1926,28 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
int Reference = LUA_REFNIL;
if (
- tolua_isstring(tolua_S, 2, 0, &tolua_err ) &&
- lua_isfunction(tolua_S, 3 )
+ tolua_isstring(tolua_S, 2, 0, &tolua_err) &&
+ lua_isfunction(tolua_S, 3)
)
{
Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX);
- Title = ((std::string) tolua_tocppstring(tolua_S,2,0));
+ Title = ((std::string)tolua_tocppstring(tolua_S, 2, 0));
}
else
{
return tolua_do_error(tolua_S, "#ferror calling function '#funcname#'", &tolua_err);
}
- if( Reference != LUA_REFNIL )
+ if (Reference != LUA_REFNIL)
{
- if( !self->AddWebTab( Title.c_str(), tolua_S, Reference ) )
+ if (!self->AddWebTab(Title.c_str(), tolua_S, Reference))
{
- luaL_unref( tolua_S, LUA_REGISTRYINDEX, Reference );
+ luaL_unref(tolua_S, LUA_REGISTRYINDEX, Reference);
}
}
else
{
- LOGERROR("ERROR: cPluginLua:AddWebTab invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str() );
+ LOGWARNING("cPluginLua:AddWebTab: invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str());
}
return 0;
@@ -1964,7 +1963,7 @@ static int tolua_cPluginLua_AddTab(lua_State* tolua_S)
LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead. (plugin \"%s\" in folder \"%s\")",
self->GetName().c_str(), self->GetDirectory().c_str()
);
- return tolua_cPluginLua_AddWebTab( tolua_S );
+ return tolua_cPluginLua_AddWebTab( tolua_S);
}
@@ -2000,9 +1999,11 @@ static int tolua_cPlugin_Call(lua_State * tolua_S)
static int tolua_md5(lua_State* tolua_S)
{
- std::string SourceString = tolua_tostring(tolua_S, 1, 0);
- std::string CryptedString = md5( SourceString );
- tolua_pushstring( tolua_S, CryptedString.c_str() );
+ unsigned char Output[16];
+ size_t len = 0;
+ const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len);
+ md5(SourceString, len, Output);
+ lua_pushlstring(tolua_S, (const char *)Output, ARRAYCOUNT(Output));
return 1;
}
@@ -2010,12 +2011,12 @@ static int tolua_md5(lua_State* tolua_S)
-static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap )
+static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap)
{
lua_newtable(tolua_S);
int top = lua_gettop(tolua_S);
- for( std::map< std::string, std::string >::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it )
+ for (std::map<std::string, std::string>::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it)
{
const char* key = it->first.c_str();
const char* value = it->second.c_str();
@@ -2059,11 +2060,11 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
lua_newtable(tolua_S);
int top = lua_gettop(tolua_S);
- for( std::map< std::string, HTTPFormData >::iterator it = FormData.begin(); it != FormData.end(); ++it )
+ for (std::map<std::string, HTTPFormData>::iterator it = FormData.begin(); it != FormData.end(); ++it)
{
- lua_pushstring(tolua_S, it->first.c_str() );
- tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" );
- //lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data
+ lua_pushstring(tolua_S, it->first.c_str());
+ tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData");
+ // lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size()); // Might contain binary data
lua_settable(tolua_S, top);
}
@@ -2076,18 +2077,18 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S)
{
- cWebAdmin* self = (cWebAdmin*) tolua_tousertype(tolua_S, 1, NULL);
+ cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, NULL);
const cWebAdmin::PluginList & AllPlugins = self->GetPlugins();
- lua_createtable(tolua_S, AllPlugins.size(), 0);
+ lua_createtable(tolua_S, (int)AllPlugins.size(), 0);
int newTable = lua_gettop(tolua_S);
int index = 1;
cWebAdmin::PluginList::const_iterator iter = AllPlugins.begin();
- while(iter != AllPlugins.end())
+ while (iter != AllPlugins.end())
{
- const cWebPlugin* Plugin = *iter;
- tolua_pushusertype( tolua_S, (void*)Plugin, "const cWebPlugin" );
+ const cWebPlugin * Plugin = *iter;
+ tolua_pushusertype(tolua_S, (void *)Plugin, "const cWebPlugin");
lua_rawseti(tolua_S, newTable, index);
++iter;
++index;
@@ -2108,12 +2109,12 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
lua_newtable(tolua_S);
int index = 1;
cWebPlugin::TabNameList::const_iterator iter = TabNames.begin();
- while(iter != TabNames.end())
+ while (iter != TabNames.end())
{
const AString & FancyName = iter->first;
const AString & WebName = iter->second;
- tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key
- tolua_pushstring( tolua_S, FancyName.c_str() );
+ tolua_pushstring( tolua_S, WebName.c_str()); // Because the WebName is supposed to be unique, use it as key
+ tolua_pushstring( tolua_S, FancyName.c_str());
//
lua_rawset(tolua_S, -3);
++iter;
@@ -2538,6 +2539,37 @@ static int tolua_cBlockArea_GetSize(lua_State * tolua_S)
+static int tolua_cBlockArea_GetCoordRange(lua_State * tolua_S)
+{
+ // function cBlockArea::GetCoordRange()
+ // Returns all three sizes of the area, miuns one, so that they represent the maximum coord value
+ // Exported manually because there's no direct C++ equivalent,
+ // plus tolua would generate extra input params for the outputs
+
+ cLuaState L(tolua_S);
+ if (!L.CheckParamUserType(1, "cBlockArea"))
+ {
+ return 0;
+ }
+
+ cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
+ if (self == NULL)
+ {
+ tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", NULL);
+ return 0;
+ }
+
+ // Push the three origin coords:
+ lua_pushnumber(tolua_S, self->GetSizeX() - 1);
+ lua_pushnumber(tolua_S, self->GetSizeY() - 1);
+ lua_pushnumber(tolua_S, self->GetSizeZ() - 1);
+ return 3;
+}
+
+
+
+
+
static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
{
// function cBlockArea::LoadFromSchematicFile
@@ -2559,7 +2591,7 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
}
AString Filename = tolua_tostring(tolua_S, 2, 0);
- bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self,Filename);
+ bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self, Filename);
tolua_pushboolean(tolua_S, res);
return 1;
}
@@ -2619,7 +2651,7 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
return 0;
}
AString Filename = tolua_tostring(tolua_S, 2, 0);
- bool res = cSchematicFileSerializer::SaveToSchematicFile(*self,Filename);
+ bool res = cSchematicFileSerializer::SaveToSchematicFile(*self, Filename);
tolua_pushboolean(tolua_S, res);
return 1;
}
@@ -2864,8 +2896,8 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
}
// Set the type:
- int MessageType;
- L.GetStackValue(1, MessageType);
+ int MessageType = mtCustom;
+ L.GetStackValue(2, MessageType);
self->SetMessageType((eMessageType)MessageType);
// Cut away everything from the stack except for the cCompositeChat instance; return that:
@@ -2926,6 +2958,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_beginmodule(tolua_S, "cBlockArea");
tolua_function(tolua_S, "GetBlockTypeMeta", tolua_cBlockArea_GetBlockTypeMeta);
+ tolua_function(tolua_S, "GetCoordRange", tolua_cBlockArea_GetCoordRange);
tolua_function(tolua_S, "GetOrigin", tolua_cBlockArea_GetOrigin);
tolua_function(tolua_S, "GetRelBlockTypeMeta", tolua_cBlockArea_GetRelBlockTypeMeta);
tolua_function(tolua_S, "GetSize", tolua_cBlockArea_GetSize);
@@ -3032,13 +3065,13 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab);
tolua_endmodule(tolua_S);
- tolua_cclass(tolua_S,"HTTPRequest","HTTPRequest","",NULL);
- tolua_beginmodule(tolua_S,"HTTPRequest");
- // tolua_variable(tolua_S,"Method",tolua_get_HTTPRequest_Method,tolua_set_HTTPRequest_Method);
- // tolua_variable(tolua_S,"Path",tolua_get_HTTPRequest_Path,tolua_set_HTTPRequest_Path);
- tolua_variable(tolua_S,"FormData",tolua_get_HTTPRequest_FormData,0);
- tolua_variable(tolua_S,"Params",tolua_get_HTTPRequest_Params,0);
- tolua_variable(tolua_S,"PostParams",tolua_get_HTTPRequest_PostParams,0);
+ tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", NULL);
+ tolua_beginmodule(tolua_S, "HTTPRequest");
+ // tolua_variable(tolua_S, "Method", tolua_get_HTTPRequest_Method, tolua_set_HTTPRequest_Method);
+ // tolua_variable(tolua_S, "Path", tolua_get_HTTPRequest_Path, tolua_set_HTTPRequest_Path);
+ tolua_variable(tolua_S, "FormData", tolua_get_HTTPRequest_FormData, 0);
+ tolua_variable(tolua_S, "Params", tolua_get_HTTPRequest_Params, 0);
+ tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, 0);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cWebAdmin");
diff --git a/src/Bindings/ManualBindings.h b/src/Bindings/ManualBindings.h
index f38e26267..36161c6a2 100644
--- a/src/Bindings/ManualBindings.h
+++ b/src/Bindings/ManualBindings.h
@@ -4,5 +4,5 @@ struct lua_State;
class ManualBindings
{
public:
- static void Bind( lua_State* tolua_S );
+ static void Bind( lua_State* tolua_S);
};
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index df0bd4dcc..39d53674b 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -33,7 +33,7 @@ class cPlugin
public:
// tolua_end
- cPlugin( const AString & a_PluginDirectory );
+ cPlugin( const AString & a_PluginDirectory);
virtual ~cPlugin();
virtual void OnDisable(void) {}
@@ -42,10 +42,7 @@ public:
// Called each tick
virtual void Tick(float a_Dt) = 0;
- /**
- * On all these functions, return true if you want to override default behavior and not call other plugins on that callback.
- * You can also return false, so default behavior is used.
- **/
+ /** Calls the specified hook with the params given. Returns the bool that the hook callback returns.*/
virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0;
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0;
virtual bool OnChat (cPlayer * a_Player, AString & a_Message) = 0;
@@ -56,14 +53,15 @@ public:
virtual bool OnChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0;
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0;
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
- virtual bool OnDisconnect (cPlayer * a_Player, const AString & a_Reason) = 0;
+ virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0;
+ virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) = 0;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) = 0;
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) = 0;
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0;
- virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) = 0;
+ virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) = 0;
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) = 0;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
@@ -72,6 +70,7 @@ public:
virtual bool OnPlayerEating (cPlayer & a_Player) = 0;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0;
+ virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) = 0;
virtual bool OnPlayerJoined (cPlayer & a_Player) = 0;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0;
virtual bool OnPlayerMoved (cPlayer & a_Player) = 0;
@@ -90,7 +89,7 @@ public:
virtual bool OnPluginsLoaded (void) = 0;
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
- virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile) = 0;
+ virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) = 0;
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0;
virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0;
virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0;
@@ -116,10 +115,10 @@ public:
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output) = 0;
/// All bound commands are to be removed, do any language-dependent cleanup here
- virtual void ClearCommands(void) {} ;
+ virtual void ClearCommands(void) {}
/// All bound console commands are to be removed, do any language-dependent cleanup here
- virtual void ClearConsoleCommands(void) {} ;
+ virtual void ClearConsoleCommands(void) {}
// tolua_begin
const AString & GetName(void) const { return m_Name; }
@@ -142,7 +141,7 @@ public:
E_SQUIRREL, // OBSOLETE, but kept in place to remind us of the horrors lurking in the history
};
PluginLanguage GetLanguage() { return m_Language; }
- void SetLanguage( PluginLanguage a_Language ) { m_Language = a_Language; }
+ void SetLanguage( PluginLanguage a_Language) { m_Language = a_Language; }
private:
PluginLanguage m_Language;
@@ -150,7 +149,7 @@ private:
int m_Version;
AString m_Directory;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index cb55715a6..0f3f25d75 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -25,7 +25,7 @@ extern "C"
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cPluginLua:
cPluginLua::cPluginLua(const AString & a_PluginDirectory) :
@@ -78,7 +78,7 @@ bool cPluginLua::Initialize(void)
{
cCSLock Lock(m_CriticalSection);
if (!m_LuaState.IsValid())
- {
+ {
m_LuaState.Create();
m_LuaState.RegisterAPILibs();
@@ -400,14 +400,34 @@ bool cPluginLua::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGri
-bool cPluginLua::OnDisconnect(cPlayer * a_Player, const AString & a_Reason)
+bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_DISCONNECT];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), a_Player, a_Reason, cLuaState::Return, res);
+ m_LuaState.Call((int)(**itr), &a_Client, a_Reason, cLuaState::Return, res);
+ if (res)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
+bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
+{
+ cCSLock Lock(m_CriticalSection);
+ bool res = false;
+ cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_ADD_EFFECT];
+ for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
+ {
+ m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier, cLuaState::Return, res);
if (res)
{
return true;
@@ -575,14 +595,14 @@ bool cPluginLua::OnHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper,
-bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer)
+bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, cLuaState::Return, res);
+ m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, &a_TDI, cLuaState::Return, res);
if (res)
{
return true;
@@ -715,6 +735,26 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player)
+bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
+{
+ cCSLock Lock(m_CriticalSection);
+ bool res = false;
+ cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE];
+ for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
+ {
+ m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res);
+ if (res)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward)
{
cCSLock Lock(m_CriticalSection);
@@ -975,7 +1015,7 @@ bool cPluginLua::OnPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_Block
-bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
@@ -1113,14 +1153,14 @@ bool cPluginLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a
-bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile)
+bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Projectile, cLuaState::Return, res);
+ m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos, cLuaState::Return, res);
if (res)
{
return true;
@@ -1254,8 +1294,8 @@ bool cPluginLua::OnTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI)
bool cPluginLua::OnUpdatedSign(
- cWorld * a_World,
- int a_BlockX, int a_BlockY, int a_BlockZ,
+ cWorld * a_World,
+ 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,
cPlayer * a_Player
)
@@ -1279,8 +1319,8 @@ bool cPluginLua::OnUpdatedSign(
bool cPluginLua::OnUpdatingSign(
- cWorld * a_World,
- int a_BlockX, int a_BlockY, int a_BlockZ,
+ cWorld * a_World,
+ int a_BlockX, int a_BlockY, int a_BlockZ,
AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4,
cPlayer * a_Player
)
@@ -1327,18 +1367,15 @@ bool cPluginLua::OnWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
- int NewWeather = a_NewWeather;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WEATHER_CHANGING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, NewWeather, cLuaState::Return, res, NewWeather);
+ m_LuaState.Call((int)(**itr), &a_World, a_NewWeather, cLuaState::Return, res, a_NewWeather);
if (res)
{
- a_NewWeather = (eWeather)NewWeather;
return true;
}
}
- a_NewWeather = (eWeather)NewWeather;
return false;
}
@@ -1480,7 +1517,7 @@ bool cPluginLua::CanAddOldStyleHook(int a_HookType)
return true;
}
- LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.",
+ LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.",
GetName().c_str(), a_HookType, FnName
);
m_LuaState.LogStackTrace();
@@ -1507,6 +1544,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
case cPluginManager::HOOK_CRAFTING_NO_RECIPE: return "OnCraftingNoRecipe";
case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect";
case cPluginManager::HOOK_PLAYER_ANIMATION: return "OnPlayerAnimation";
+ case cPluginManager::HOOK_ENTITY_ADD_EFFECT: return "OnEntityAddEffect";
case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand";
case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake";
case cPluginManager::HOOK_KILLING: return "OnKilling";
@@ -1571,6 +1609,7 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType);
m_LuaState.LogStackTrace();
delete Ref;
+ Ref = NULL;
return false;
}
@@ -1616,7 +1655,7 @@ int cPluginLua::CallFunctionFromForeignState(
-AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request )
+AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request)
{
cCSLock Lock(m_CriticalSection);
std::string RetVal = "";
@@ -1631,7 +1670,7 @@ AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request )
sWebPluginTab * Tab = 0;
for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr)
{
- if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr
+ if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr
{
Tab = *itr;
break;
@@ -1713,7 +1752,7 @@ bool cPluginLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer
ASSERT(a_FnRef != LUA_REFNIL);
cCSLock Lock(m_CriticalSection);
- bool res;
+ bool res = false;
m_LuaState.Call(a_FnRef, &a_Window, &a_Player, a_CanRefuse, cLuaState::Return, res);
return res;
}
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 59542d23a..2cea644c1 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -79,14 +79,15 @@ public:
virtual bool OnChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override;
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
- virtual bool OnDisconnect (cPlayer * a_Player, const AString & a_Reason) override;
+ virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
+ virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override;
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) override;
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override;
- virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) override;
+ virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override;
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
@@ -95,6 +96,7 @@ public:
virtual bool OnPlayerEating (cPlayer & a_Player) override;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override;
+ virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) override;
virtual bool OnPlayerJoined (cPlayer & a_Player) override;
virtual bool OnPlayerMoved (cPlayer & a_Player) override;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override;
@@ -113,7 +115,7 @@ public:
virtual bool OnPluginsLoaded (void) override;
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
- virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile) override;
+ virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) override;
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override;
virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override;
virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override;
@@ -142,8 +144,8 @@ public:
virtual const AString GetWebTitle(void) const {return GetName(); }
// cWebPlugin and WebAdmin stuff
- virtual AString HandleWebRequest(const HTTPRequest * a_Request ) override;
- bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS <<
+ virtual AString HandleWebRequest(const HTTPRequest * a_Request) override;
+ bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS <<
/** Binds the command to call the function specified by a Lua function reference. Simply adds to CommandMap. */
void BindCommand(const AString & a_Command, int a_FnRef);
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 6a5356c0b..3560b8660 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -14,6 +14,13 @@
#include "inifile/iniFile.h"
#include "../Entities/Player.h"
+#define FIND_HOOK(a_HookName) HookMap::iterator Plugins = m_Hooks.find(a_HookName);
+#define VERIFY_HOOK \
+ if (Plugins == m_Hooks.end()) \
+ { \
+ return false; \
+ }
+
@@ -65,7 +72,7 @@ void cPluginManager::FindPlugins(void)
{
PluginMap::iterator thiz = itr;
++thiz;
- m_Plugins.erase( itr );
+ m_Plugins.erase( itr);
itr = thiz;
continue;
}
@@ -143,13 +150,14 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
}
}
- if (GetNumPlugins() == 0)
+ size_t NumLoadedPlugins = GetNumPlugins();
+ if (NumLoadedPlugins == 0)
{
LOG("-- No Plugins Loaded --");
}
- else if (GetNumPlugins() > 1)
+ else if (NumLoadedPlugins > 1)
{
- LOG("-- Loaded %i Plugins --", GetNumPlugins());
+ LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
}
else
{
@@ -191,7 +199,7 @@ void cPluginManager::Tick(float a_Dt)
ReloadPluginsNow();
}
- HookMap::iterator Plugins = m_Hooks.find(HOOK_TICK);
+ FIND_HOOK(HOOK_TICK);
if (Plugins != m_Hooks.end())
{
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
@@ -207,11 +215,9 @@ void cPluginManager::Tick(float a_Dt)
bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_SPREAD);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_BLOCK_SPREAD);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnBlockSpread(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source))
@@ -232,11 +238,9 @@ bool cPluginManager::CallHookBlockToPickups(
cItems & a_Pickups
)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_TO_PICKUPS);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_BLOCK_TO_PICKUPS);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups))
@@ -253,18 +257,44 @@ bool cPluginManager::CallHookBlockToPickups(
bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
{
- bool WasCommandForbidden = false;
- if (HandleCommand(a_Player, a_Message, true, WasCommandForbidden)) // We use HandleCommand as opposed to ExecuteCommand to accomodate the need to the WasCommandForbidden bool
- {
- return true; // Chat message was handled as command
- }
- else if (WasCommandForbidden) // Couldn't be handled as command, was it because of insufficient permissions?
+ // Check if the message contains a command, execute it:
+ switch (HandleCommand(a_Player, a_Message, true))
{
- return true; // Yes - message was sent in HandleCommand, abort
+ case crExecuted:
+ {
+ // The command has executed successfully
+ return true;
+ }
+
+ case crBlocked:
+ {
+ // The command was blocked by a plugin using HOOK_EXECUTE_COMMAND
+ // The plugin has most likely sent a message to the player already
+ return true;
+ }
+
+ case crError:
+ {
+ // An error in the plugin has prevented the command from executing. Report the error to the player:
+ a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str()));
+ return true;
+ }
+
+ case crNoPermission:
+ {
+ // The player is not allowed to execute this command
+ a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str()));
+ return true;
+ }
+
+ case crUnknownCommand:
+ {
+ // This was not a known command, keep processing as a message
+ break;
+ }
}
- // Check if it was a standard command (starts with a slash)
- // If it was, we know that it was completely unrecognised (WasCommandForbidden == false)
+ // Check if the message is a command (starts with a slash). If it is, we know that it wasn't recognised:
if (!a_Message.empty() && (a_Message[0] == '/'))
{
AStringVector Split(StringSplit(a_Message, " "));
@@ -274,11 +304,8 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
return true; // Cancel sending
}
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHAT);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHAT);
+ VERIFY_HOOK;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
@@ -297,11 +324,9 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_AVAILABLE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_AVAILABLE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkAvailable(a_World, a_ChunkX, a_ChunkZ))
@@ -318,11 +343,9 @@ bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_GENERATED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc))
@@ -339,11 +362,9 @@ bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_GENERATING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkGenerating(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc))
@@ -360,11 +381,9 @@ bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_UNLOADED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_UNLOADED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkUnloaded(a_World, a_ChunkX, a_ChunkZ))
@@ -381,11 +400,9 @@ bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a
bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_UNLOADING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_UNLOADING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ))
@@ -402,11 +419,9 @@ bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pickup)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_COLLECTING_PICKUP);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_COLLECTING_PICKUP);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnCollectingPickup(a_Player, &a_Pickup))
@@ -423,11 +438,9 @@ bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pi
bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CRAFTING_NO_RECIPE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CRAFTING_NO_RECIPE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe))
@@ -442,16 +455,33 @@ bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cC
-bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Reason)
+bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString & a_Reason)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_DISCONNECT);
- if (Plugins == m_Hooks.end())
+ FIND_HOOK(HOOK_DISCONNECT);
+ VERIFY_HOOK;
+
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- return false;
+ if ((*itr)->OnDisconnect(a_Client, a_Reason))
+ {
+ return true;
+ }
}
+ return false;
+}
+
+
+
+
+
+bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
+{
+ FIND_HOOK(HOOK_ENTITY_ADD_EFFECT);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- if ((*itr)->OnDisconnect(a_Player, a_Reason))
+ if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier))
{
return true;
}
@@ -465,11 +495,9 @@ bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Re
bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_EXECUTE_COMMAND);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_EXECUTE_COMMAND);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnExecuteCommand(a_Player, a_Split))
@@ -486,11 +514,9 @@ bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVec
bool cPluginManager::CallHookExploded(cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_EXPLODED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_EXPLODED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnExploded(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData))
@@ -507,11 +533,9 @@ bool cPluginManager::CallHookExploded(cWorld & a_World, double a_ExplosionSize,
bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_EXPLODING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_EXPLODING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnExploding(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData))
@@ -528,11 +552,9 @@ bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSiz
bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const AString & a_Username)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_HANDSHAKE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_HANDSHAKE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnHandshake(a_ClientHandle, a_Username))
@@ -549,11 +571,9 @@ bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const ASt
bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_HOPPER_PULLING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_HOPPER_PULLING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnHopperPullingItem(a_World, a_Hopper, a_DstSlotNum, a_SrcEntity, a_SrcSlotNum))
@@ -570,11 +590,9 @@ bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity &
bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_HOPPER_PUSHING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_HOPPER_PUSHING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnHopperPushingItem(a_World, a_Hopper, a_SrcSlotNum, a_DstEntity, a_DstSlotNum))
@@ -589,16 +607,14 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity &
-bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer)
+bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_KILLING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_KILLING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- if ((*itr)->OnKilling(a_Victim, a_Killer))
+ if ((*itr)->OnKilling(a_Victim, a_Killer, a_TDI))
{
return true;
}
@@ -612,11 +628,9 @@ bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer)
bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_LOGIN);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_LOGIN);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnLogin(a_Client, a_ProtocolVersion, a_Username))
@@ -633,11 +647,9 @@ bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersi
bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_ANIMATION);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_ANIMATION);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerAnimation(a_Player, a_Animation))
@@ -654,11 +666,9 @@ bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation
bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_BREAKING_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_BREAKING_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerBreakingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta))
@@ -675,11 +685,9 @@ bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_Block
bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_BROKEN_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_BROKEN_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerBrokenBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta))
@@ -696,11 +704,9 @@ bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_DESTROYED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_DESTROYED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerDestroyed(a_Player))
@@ -717,11 +723,9 @@ bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_EATING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_EATING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerEating(a_Player))
@@ -736,13 +740,30 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
-bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward)
+bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHED);
- if (Plugins == m_Hooks.end())
+ FIND_HOOK(HOOK_PLAYER_FOOD_LEVEL_CHANGE);
+ VERIFY_HOOK;
+
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- return false;
+ if ((*itr)->OnPlayerFoodLevelChange(a_Player, a_NewFoodLevel))
+ {
+ return true;
+ }
}
+ return false;
+}
+
+
+
+
+
+bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward)
+{
+ FIND_HOOK(HOOK_PLAYER_FISHED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerFished(a_Player, a_Reward))
@@ -759,11 +780,9 @@ bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Rew
bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_FISHING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerFishing(a_Player, a_Reward))
@@ -780,11 +799,9 @@ bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward)
bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_JOINED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_JOINED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerJoined(a_Player))
@@ -801,11 +818,9 @@ bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_LEFT_CLICK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_LEFT_CLICK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status))
@@ -822,11 +837,9 @@ bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, i
bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_MOVING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_MOVING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerMoved(a_Player))
@@ -843,11 +856,9 @@ bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_PLACED_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_PLACED_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerPlacedBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -864,11 +875,9 @@ bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_PLACING_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_PLACING_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerPlacingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -885,11 +894,9 @@ bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, int a_BlockX
bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_RIGHT_CLICK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_RIGHT_CLICK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
@@ -906,11 +913,9 @@ bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_RIGHT_CLICKING_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_RIGHT_CLICKING_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerRightClickingEntity(a_Player, a_Entity))
@@ -927,11 +932,9 @@ bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEnti
bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_SHOOTING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_SHOOTING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerShooting(a_Player))
@@ -948,11 +951,9 @@ bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_SPAWNED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_SPAWNED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerSpawned(a_Player))
@@ -969,11 +970,9 @@ bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_TOSSING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_TOSSING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerTossingItem(a_Player))
@@ -990,11 +989,9 @@ bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USED_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USED_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsedBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -1011,11 +1008,9 @@ bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, i
bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USED_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USED_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsedItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
@@ -1032,11 +1027,9 @@ bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, in
bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USING_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USING_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -1053,11 +1046,9 @@ bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsingItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
@@ -1074,11 +1065,9 @@ bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, i
bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGIN_MESSAGE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLUGIN_MESSAGE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPluginMessage(a_Client, a_Channel, a_Message))
@@ -1095,11 +1084,9 @@ bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AStri
bool cPluginManager::CallHookPluginsLoaded(void)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGINS_LOADED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLUGINS_LOADED);
+ VERIFY_HOOK;
+
bool res = false;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
@@ -1114,11 +1101,9 @@ bool cPluginManager::CallHookPluginsLoaded(void)
bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_POST_CRAFTING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPostCrafting(a_Player, a_Grid, a_Recipe))
@@ -1135,11 +1120,9 @@ bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraft
bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PRE_CRAFTING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PRE_CRAFTING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPreCrafting(a_Player, a_Grid, a_Recipe))
@@ -1154,16 +1137,14 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti
-bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile)
+bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PROJECTILE_HIT_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- if ((*itr)->OnProjectileHitBlock(a_Projectile))
+ if ((*itr)->OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos))
{
return true;
}
@@ -1177,11 +1158,9 @@ bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile
bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PROJECTILE_HIT_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnProjectileHitEntity(a_Projectile, a_HitEntity))
@@ -1198,11 +1177,9 @@ bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectil
bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNED_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNED_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawnedEntity(a_World, a_Entity))
@@ -1218,11 +1195,9 @@ bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monster)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNED_MONSTER);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNED_MONSTER);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawnedMonster(a_World, a_Monster))
@@ -1238,11 +1213,9 @@ bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monst
bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNING_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNING_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawningEntity(a_World, a_Entity))
@@ -1259,11 +1232,9 @@ bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity
bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Monster)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNING_MONSTER);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNING_MONSTER);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawningMonster(a_World, a_Monster))
@@ -1280,11 +1251,9 @@ bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Mons
bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_TAKE_DAMAGE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_TAKE_DAMAGE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnTakeDamage(a_Receiver, a_TDI))
@@ -1301,11 +1270,9 @@ bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a
bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATING_SIGN);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_UPDATING_SIGN);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnUpdatingSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player))
@@ -1322,11 +1289,9 @@ bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_
bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, 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, cPlayer * a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATED_SIGN);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_UPDATED_SIGN);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnUpdatedSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player))
@@ -1343,11 +1308,9 @@ bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, int a_BlockX, int a_B
bool cPluginManager::CallHookWeatherChanged(cWorld & a_World)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WEATHER_CHANGED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WEATHER_CHANGED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWeatherChanged(a_World))
@@ -1364,11 +1327,9 @@ bool cPluginManager::CallHookWeatherChanged(cWorld & a_World)
bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WEATHER_CHANGING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WEATHER_CHANGING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWeatherChanging(a_World, a_NewWeather))
@@ -1385,11 +1346,9 @@ bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewW
bool cPluginManager::CallHookWorldStarted(cWorld & a_World)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WORLD_STARTED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WORLD_STARTED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWorldStarted(a_World))
@@ -1406,11 +1365,9 @@ bool cPluginManager::CallHookWorldStarted(cWorld & a_World)
bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastTickDurationMSec)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WORLD_TICK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WORLD_TICK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWorldTick(a_World, a_Dt, a_LastTickDurationMSec))
@@ -1425,28 +1382,28 @@ bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastT
-bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden)
+cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
{
ASSERT(a_Player != NULL);
AStringVector Split(StringSplit(a_Command, " "));
if (Split.empty())
{
- return false;
+ return crUnknownCommand;
}
CommandMap::iterator cmd = m_Commands.find(Split[0]);
if (cmd == m_Commands.end())
{
// Command not found
- return false;
+ return crUnknownCommand;
}
// Ask plugins first if a command is okay to execute the command:
if (CallHookExecuteCommand(a_Player, Split))
{
LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player->GetName().c_str(), Split[0].c_str());
- return false;
+ return crBlocked;
}
if (
@@ -1455,26 +1412,29 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command
!a_Player->HasPermission(cmd->second.m_Permission)
)
{
- a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", Split[0].c_str()));
LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player->GetName().c_str(), Split[0].c_str());
- a_WasCommandForbidden = true;
- return false;
+ return crNoPermission;
}
ASSERT(cmd->second.m_Plugin != NULL);
- return cmd->second.m_Plugin->HandleCommand(Split, a_Player);
+ if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player))
+ {
+ return crError;
+ }
+
+ return crExecuted;
}
-cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin ) const
+cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin) const
{
- for( PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr )
+ for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr)
{
- if (itr->second == NULL ) continue;
+ if (itr->second == NULL) continue;
if (itr->second->GetName().compare(a_Plugin) == 0)
{
return itr->second;
@@ -1524,7 +1484,7 @@ bool cPluginManager::DisablePlugin(const AString & a_PluginName)
if (itr->first.compare(a_PluginName) == 0) // _X 2013_02_01: wtf? Isn't this supposed to be what find() does?
{
m_DisablePluginList.push_back(itr->second);
- itr->second = NULL; // Get rid of this thing right away
+ itr->second = NULL; // Get rid of this thing right away
return true;
}
return false;
@@ -1574,6 +1534,7 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin)
a_Plugin->OnDisable();
}
delete a_Plugin;
+ a_Plugin = NULL;
}
@@ -1660,7 +1621,7 @@ AString cPluginManager::GetCommandPermission(const AString & a_Command)
-bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command)
+cPluginManager::CommandResult cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command)
{
return HandleCommand(a_Player, a_Command, true);
}
@@ -1669,7 +1630,7 @@ bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Comman
-bool cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command)
+cPluginManager::CommandResult cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command)
{
return HandleCommand(a_Player, a_Command, false);
}
@@ -1869,7 +1830,7 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook)
-unsigned int cPluginManager::GetNumPlugins() const
+size_t cPluginManager::GetNumPlugins() const
{
return m_Plugins.size();
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 512bc1351..44a94e316 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -51,14 +51,25 @@ class cBlockEntityWithItems;
-class cPluginManager // tolua_export
-{ // tolua_export
-public: // tolua_export
-
+// tolua_begin
+class cPluginManager
+{
+public:
+ // tolua_end
+
// Called each tick
virtual void Tick(float a_Dt);
-
+
// tolua_begin
+ enum CommandResult
+ {
+ crExecuted,
+ crUnknownCommand,
+ crError,
+ crBlocked,
+ crNoPermission,
+ } ;
+
enum PluginHook
{
HOOK_BLOCK_SPREAD,
@@ -73,6 +84,7 @@ public: // tolua_export
HOOK_CRAFTING_NO_RECIPE,
HOOK_DISCONNECT,
HOOK_PLAYER_ANIMATION,
+ HOOK_ENTITY_ADD_EFFECT,
HOOK_EXECUTE_COMMAND,
HOOK_EXPLODED,
HOOK_EXPLODING,
@@ -87,6 +99,7 @@ public: // tolua_export
HOOK_PLAYER_EATING,
HOOK_PLAYER_FISHED,
HOOK_PLAYER_FISHING,
+ HOOK_PLAYER_FOOD_LEVEL_CHANGE,
HOOK_PLAYER_JOINED,
HOOK_PLAYER_LEFT_CLICK,
HOOK_PLAYER_MOVING,
@@ -146,20 +159,22 @@ public: // tolua_export
/** Returns the instance of the Plugin Manager (there is only ever one) */
- static cPluginManager * Get(void); // tolua_export
+ static cPluginManager * Get(void); // tolua_export
typedef std::map< AString, cPlugin * > PluginMap;
typedef std::list< cPlugin * > PluginList;
- cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export
- const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS <<
+ cPlugin * GetPlugin( const AString & a_Plugin) const; // tolua_export
+ const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS <<
- void FindPlugins(); // tolua_export
- void ReloadPlugins(); // tolua_export
+ // tolua_begin
+ void FindPlugins();
+ void ReloadPlugins();
+ // tolua_end
/** Adds the plugin to the list of plugins called for the specified hook type. Handles multiple adds as a single add */
void AddHook(cPlugin * a_Plugin, int a_HookType);
- unsigned int GetNumPlugins() const; // tolua_export
+ size_t GetNumPlugins() const; // tolua_export
// Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort
bool CallHookBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source);
@@ -172,14 +187,15 @@ public: // tolua_export
bool CallHookChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup);
bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
- bool CallHookDisconnect (cPlayer * a_Player, const AString & a_Reason);
+ bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
+ bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier);
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd
bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username);
bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum);
bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum);
- bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer);
+ bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI);
bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username);
bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
@@ -188,6 +204,7 @@ public: // tolua_export
bool CallHookPlayerEating (cPlayer & a_Player);
bool CallHookPlayerFished (cPlayer & a_Player, const cItems a_Reward);
bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward);
+ bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel);
bool CallHookPlayerJoined (cPlayer & a_Player);
bool CallHookPlayerMoving (cPlayer & a_Player);
bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
@@ -206,7 +223,7 @@ public: // tolua_export
bool CallHookPluginsLoaded (void);
bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
- bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile);
+ bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos);
bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity);
bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity);
bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster);
@@ -244,11 +261,11 @@ public: // tolua_export
/** Returns the permission needed for the specified command; empty string if command not found */
AString GetCommandPermission(const AString & a_Command); // tolua_export
- /** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns true if executed. */
- bool ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
+ /** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns crExecuted if executed. */
+ CommandResult ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
- /** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns true if executed (false if not found) */
- bool ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
+ /** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns crExecuted if executed. */
+ CommandResult ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
/** Removes all console command bindings that the specified plugin has made */
void RemovePluginConsoleCommands(cPlugin * a_Plugin);
@@ -321,14 +338,9 @@ private:
/** Adds the plugin into the internal list of plugins and initializes it. If initialization fails, the plugin is removed again. */
bool AddPlugin(cPlugin * a_Plugin);
- /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is handled. */
- bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden);
- bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
- {
- bool DummyBoolean = false;
- return HandleCommand(a_Player, a_Command, a_ShouldCheckPermissions, DummyBoolean);
- }
-} ; // tolua_export
+ /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns crExecuted if the command is executed. */
+ cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
+} ; // tolua_export
diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp
index bf45405ba..1178c127a 100644
--- a/src/Bindings/WebPlugin.cpp
+++ b/src/Bindings/WebPlugin.cpp
@@ -45,12 +45,12 @@ cWebPlugin::~cWebPlugin()
std::list<std::pair<AString, AString> > cWebPlugin::GetTabNames(void)
{
std::list< std::pair< AString, AString > > NameList;
- for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
+ for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr)
{
std::pair< AString, AString > StringPair;
StringPair.first = (*itr)->Title;
StringPair.second = (*itr)->SafeTitle;
- NameList.push_back( StringPair );
+ NameList.push_back( StringPair);
}
return NameList;
}
@@ -64,27 +64,27 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
std::pair< AString, AString > Names;
AStringVector Split = StringSplit(a_Request->Path, "/");
- if( Split.size() > 1 )
+ if (Split.size() > 1)
{
- sWebPluginTab* Tab = 0;
- if( Split.size() > 2 ) // If we got the tab name, show that page
+ sWebPluginTab * Tab = NULL;
+ if (Split.size() > 2) // If we got the tab name, show that page
{
- for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
+ for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr)
{
- if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr
+ if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one!
{
Tab = *itr;
break;
}
}
}
- else // Otherwise show the first tab
+ else // Otherwise show the first tab
{
- if( GetTabs().size() > 0 )
+ if (GetTabs().size() > 0)
Tab = *GetTabs().begin();
}
- if( Tab )
+ if (Tab != NULL)
{
Names.first = Tab->Title;
Names.second = Tab->SafeTitle;
@@ -97,17 +97,21 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
-AString cWebPlugin::SafeString( const AString & a_String )
+AString cWebPlugin::SafeString(const AString & a_String)
{
AString RetVal;
- for( unsigned int i = 0; i < a_String.size(); ++i )
+ for (unsigned int i = 0; i < a_String.size(); ++i)
{
char c = a_String[i];
- if( c == ' ' )
+ if (c == ' ')
{
c = '_';
}
- RetVal.push_back( c );
+ RetVal.push_back( c);
}
return RetVal;
}
+
+
+
+
diff --git a/src/Bindings/WebPlugin.h b/src/Bindings/WebPlugin.h
index 22587b892..46bc0cd2d 100644
--- a/src/Bindings/WebPlugin.h
+++ b/src/Bindings/WebPlugin.h
@@ -19,9 +19,9 @@ public:
// tolua_begin
virtual const AString GetWebTitle(void) const = 0;
- virtual AString HandleWebRequest(const HTTPRequest * a_Request ) = 0;
+ virtual AString HandleWebRequest(const HTTPRequest * a_Request) = 0;
- static AString SafeString( const AString & a_String );
+ static AString SafeString( const AString & a_String);
// tolua_end
struct sWebPluginTab
@@ -36,8 +36,8 @@ public:
TabList & GetTabs() { return m_Tabs; }
typedef std::list< std::pair<AString, AString> > TabNameList;
- TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS <<
- std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request );
+ TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS <<
+ std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request);
private:
TabList m_Tabs;
diff --git a/src/Bindings/gen_LuaState_Call.lua b/src/Bindings/gen_LuaState_Call.lua
new file mode 100644
index 000000000..fb1797dc0
--- /dev/null
+++ b/src/Bindings/gen_LuaState_Call.lua
@@ -0,0 +1,196 @@
+
+-- gen_LuaState_Call.lua
+
+-- Generates the cLuaState::Call() function templates that are included from LuaState.h
+
+--[[
+The cLuaState::Call() family of functions provides a template-based system for calling any Lua function
+either by name or by reference with almost any number of parameters and return values. This is done by
+providing a number of overloads of the same name with variable number of template-type parameters. To
+separate the arguments from the return values, a special type of cLuaState::cRet is used.
+--]]
+
+
+
+
+print("Generating LuaState_Call.inc...")
+
+
+
+
+-- List of combinations (# params, # returns) to generate:
+local Combinations =
+{
+ -- no return values:
+ {0, 0},
+ {1, 0},
+ {2, 0},
+ {3, 0},
+ {4, 0},
+
+ -- 1 return value:
+ {0, 1},
+ {1, 1},
+ {2, 1},
+ {3, 1},
+ {4, 1},
+ {5, 1},
+ {6, 1},
+ {7, 1},
+ {8, 1},
+ {9, 1},
+ {10, 1},
+
+ -- 2 return values:
+ {0, 2},
+ {1, 2},
+ {2, 2},
+ {3, 2},
+ {4, 2},
+ {5, 2},
+ {6, 2},
+ {7, 2},
+ {8, 2},
+ {9, 2},
+
+ -- Special combinations:
+ {7, 3},
+ {8, 3},
+ {9, 5},
+}
+
+
+
+
+--- Writes a single overloaded function definition for the specified number of params and returns into f
+--[[
+The format for the generated function is this:
+/** Call the specified 3-param 2-return Lua function:
+Returns true if call succeeded, false if there was an error. */
+template <typename FnT, typename ParamT1, typename ParamT2, typename ParamT3, typename RetT1, typename RetT2>
+bool Call(FnT a_Function, ParamT1 a_Param1, ParamT2 a_Param2, ParamT3 a_Param3, const cLuaState::cRet & a_RetMark, RetT1 & a_Ret1, RetT2 & a_Ret2)
+{
+ UNUSED(a_RetMark);
+ if (!PushFunction(a_Function))
+ {
+ return false;
+ }
+ Push(a_Param1);
+ Push(a_Param2);
+ Push(a_Param3);
+ if (!CallFunction(2))
+ {
+ return false;
+ }
+ GetStackValue(-2, a_Ret1);
+ GetStackValue(-1, a_Ret2);
+ lua_pop(m_LuaState, 2);
+ return true;
+}
+Note especially the negative numbers in GetStackValue() calls.
+--]]
+local function WriteOverload(f, a_NumParams, a_NumReturns)
+ -- Write the function doxy-comments:
+ f:write("/** Call the specified ", a_NumParams, "-param ", a_NumReturns, "-return Lua function:\n")
+ f:write("Returns true if call succeeded, false if there was an error. */\n")
+
+ -- Write the template <...> line:
+ f:write("template <typename FnT")
+ for i = 1, a_NumParams do
+ f:write(", typename ParamT", i)
+ end
+ if (a_NumReturns > 0) then
+ for i = 1, a_NumReturns do
+ f:write(", typename RetT", i)
+ end
+ end
+ f:write(">\n")
+
+ -- Write the function signature:
+ f:write("bool Call(")
+ f:write("FnT a_Function")
+ for i = 1, a_NumParams do
+ f:write(", ParamT", i, " a_Param", i)
+ end
+ if (a_NumReturns > 0) then
+ f:write(", const cLuaState::cRet & a_RetMark")
+ for i = 1, a_NumReturns do
+ f:write(", RetT", i, " & a_Ret", i)
+ end
+ end
+ f:write(")\n")
+
+ -- Common code:
+ f:write("{\n")
+ if (a_NumReturns > 0) then
+ f:write("\tUNUSED(a_RetMark);\n")
+ end
+ f:write("\tif (!PushFunction(a_Function))\n")
+ f:write("\t{\n")
+ f:write("\t\treturn false;\n")
+ f:write("\t}\n")
+
+ -- Push the params:
+ for i = 1, a_NumParams do
+ f:write("\tPush(a_Param", i, ");\n")
+ end
+
+ -- Call the function:
+ f:write("\tif (!CallFunction(", a_NumReturns, "))\n")
+ f:write("\t{\n")
+ f:write("\t\treturn false;\n")
+ f:write("\t}\n")
+
+ -- Get the return values:
+ for i = 1, a_NumReturns do
+ f:write("\tGetStackValue(", -1 - a_NumReturns + i, ", a_Ret", i, ");\n")
+ end
+
+ -- Pop the returns off the stack, if needed:
+ if (a_NumReturns > 0) then
+ f:write("\tlua_pop(m_LuaState, ", a_NumReturns, ");\n")
+ end
+
+ -- Everything ok:
+ f:write("\treturn true;\n")
+ f:write("}\n")
+
+ -- Separate from the next function:
+ f:write("\n\n\n\n\n")
+end
+
+
+
+
+
+local f = assert(io.open("LuaState_Call.inc", "w"))
+
+-- Write file header:
+f:write([[
+// LuaState_Call.inc
+
+// This file is auto-generated by gen_LuaState_Call.lua
+// Make changes to the generator instead of to this file!
+
+// This file contains the various overloads for the cLuaState::Call() function
+// Each overload handles a different number of parameters / return values
+]])
+f:write("\n\n\n\n\n")
+
+-- Write out a template function for each overload:
+for _, combination in ipairs(Combinations) do
+ WriteOverload(f, combination[1], combination[2])
+end
+
+-- Close the generated file
+f:close()
+
+
+
+
+
+print("LuaState_Call.inc generated")
+
+
+
+
diff --git a/src/Bindings/lua51.dll b/src/Bindings/lua51.dll
deleted file mode 100644
index 515cf8b30..000000000
--- a/src/Bindings/lua51.dll
+++ /dev/null
Binary files differ
diff --git a/src/Bindings/tolua++.exe b/src/Bindings/tolua++.exe
deleted file mode 100644
index ba3a6b0c7..000000000
--- a/src/Bindings/tolua++.exe
+++ /dev/null
Binary files differ
diff --git a/src/Bindings/virtual_method_hooks.lua b/src/Bindings/virtual_method_hooks.lua
index c610d424f..8ad30bf78 100644
--- a/src/Bindings/virtual_method_hooks.lua
+++ b/src/Bindings/virtual_method_hooks.lua
@@ -3,6 +3,20 @@ local disable_virtual_hooks = true
local enable_pure_virtual = true
local default_private_access = false
+
+
+
+
+-- Code generators used by the build
+-- Note that these are not exactly needed for the bindings, but rather we
+-- misuse tolua's Lua engine to process files for us
+dofile("gen_LuaState_Call.lua")
+
+
+
+
+
+
local access = {public = 0, protected = 1, private = 2}
function preparse_hook(p)
diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp
index 3fba93e8a..02f8c2232 100644
--- a/src/BiomeDef.cpp
+++ b/src/BiomeDef.cpp
@@ -7,6 +7,89 @@
#include "BiomeDef.h"
+
+
+// The "map" used for biome <-> string conversions:
+static struct
+{
+ EMCSBiome m_Biome;
+ const char * m_String;
+} g_BiomeMap[] =
+{
+ {biOcean, "Ocean"},
+ {biPlains, "Plains"},
+ {biDesert, "Desert"},
+ {biExtremeHills, "ExtremeHills"},
+ {biForest, "Forest"},
+ {biTaiga, "Taiga"},
+ {biSwampland, "Swampland"},
+ {biRiver, "River"},
+ {biNether, "Hell"},
+ {biNether, "Nether"},
+ {biEnd, "Sky"},
+ {biEnd, "End"},
+ {biFrozenOcean, "FrozenOcean"},
+ {biFrozenRiver, "FrozenRiver"},
+ {biIcePlains, "IcePlains"},
+ {biIcePlains, "Tundra"},
+ {biIceMountains, "IceMountains"},
+ {biMushroomIsland, "MushroomIsland"},
+ {biMushroomShore, "MushroomShore"},
+ {biBeach, "Beach"},
+ {biDesertHills, "DesertHills"},
+ {biForestHills, "ForestHills"},
+ {biTaigaHills, "TaigaHills"},
+ {biExtremeHillsEdge, "ExtremeHillsEdge"},
+ {biJungle, "Jungle"},
+ {biJungleHills, "JungleHills"},
+
+ // Release 1.7 biomes:
+ {biJungleEdge, "JungleEdge"},
+ {biDeepOcean, "DeepOcean"},
+ {biStoneBeach, "StoneBeach"},
+ {biColdBeach, "ColdBeach"},
+ {biBirchForest, "BirchForest"},
+ {biBirchForestHills, "BirchForestHills"},
+ {biRoofedForest, "RoofedForest"},
+ {biColdTaiga, "ColdTaiga"},
+ {biColdTaigaHills, "ColdTaigaHills"},
+ {biMegaTaiga, "MegaTaiga"},
+ {biMegaTaigaHills, "MegaTaigaHills"},
+ {biExtremeHillsPlus, "ExtremeHillsPlus"},
+ {biSavanna, "Savanna"},
+ {biSavannaPlateau, "SavannaPlateau"},
+ {biMesa, "Mesa"},
+ {biMesaPlateauF, "MesaPlateauF"},
+ {biMesaPlateau, "MesaPlateau"},
+
+ // Release 1.7 variants:
+ {biSunflowerPlains, "SunflowerPlains"},
+ {biDesertM, "DesertM"},
+ {biExtremeHillsM, "ExtremeHillsM"},
+ {biFlowerForest, "FlowerForest"},
+ {biTaigaM, "TaigaM"},
+ {biSwamplandM, "SwamplandM"},
+ {biIcePlainsSpikes, "IcePlainsSpikes"},
+ {biJungleM, "JungleM"},
+ {biJungleEdgeM, "JungleEdgeM"},
+ {biBirchForestM, "BirchForestM"},
+ {biBirchForestHillsM, "BirchForestHillsM"},
+ {biRoofedForestM, "RoofedForestM"},
+ {biColdTaigaM, "ColdTaigaM"},
+ {biMegaSpruceTaiga, "MegaSpruceTaiga"},
+ {biMegaSpruceTaigaHills, "MegaSpruceTaigaHills"},
+ {biExtremeHillsPlusM, "ExtremeHillsPlusM"},
+ {biSavannaM, "SavannaM"},
+ {biSavannaPlateauM, "SavannaPlateauM"},
+ {biMesaBryce, "MesaBryce"},
+ {biMesaPlateauFM, "MesaPlateauFM"},
+ {biMesaPlateauM, "MesaPlateauM"},
+} ;
+
+
+
+
+
EMCSBiome StringToBiome(const AString & a_BiomeString)
{
// If it is a number, return it:
@@ -25,87 +108,11 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
return biInvalidBiome;
}
- // Convert using the built-in map:
- static struct {
- EMCSBiome m_Biome;
- const char * m_String;
- } BiomeMap[] =
- {
- {biOcean, "Ocean"} ,
- {biPlains, "Plains"},
- {biDesert, "Desert"},
- {biExtremeHills, "ExtremeHills"},
- {biForest, "Forest"},
- {biTaiga, "Taiga"},
- {biSwampland, "Swampland"},
- {biRiver, "River"},
- {biNether, "Hell"},
- {biNether, "Nether"},
- {biEnd, "Sky"},
- {biEnd, "End"},
- {biFrozenOcean, "FrozenOcean"},
- {biFrozenRiver, "FrozenRiver"},
- {biIcePlains, "IcePlains"},
- {biIcePlains, "Tundra"},
- {biIceMountains, "IceMountains"},
- {biMushroomIsland, "MushroomIsland"},
- {biMushroomShore, "MushroomShore"},
- {biBeach, "Beach"},
- {biDesertHills, "DesertHills"},
- {biForestHills, "ForestHills"},
- {biTaigaHills, "TaigaHills"},
- {biExtremeHillsEdge, "ExtremeHillsEdge"},
- {biJungle, "Jungle"},
- {biJungleHills, "JungleHills"},
-
- // Release 1.7 biomes:
- {biJungleEdge, "JungleEdge"},
- {biDeepOcean, "DeepOcean"},
- {biStoneBeach, "StoneBeach"},
- {biColdBeach, "ColdBeach"},
- {biBirchForest, "BirchForest"},
- {biBirchForestHills, "BirchForestHills"},
- {biRoofedForest, "RoofedForest"},
- {biColdTaiga, "ColdTaiga"},
- {biColdTaigaHills, "ColdTaigaHills"},
- {biMegaTaiga, "MegaTaiga"},
- {biMegaTaigaHills, "MegaTaigaHills"},
- {biExtremeHillsPlus, "ExtremeHillsPlus"},
- {biSavanna, "Savanna"},
- {biSavannaPlateau, "SavannaPlateau"},
- {biMesa, "Mesa"},
- {biMesaPlateauF, "MesaPlateauF"},
- {biMesaPlateau, "MesaPlateau"},
-
- // Release 1.7 variants:
- {biSunflowerPlains, "SunflowerPlains"},
- {biDesertM, "DesertM"},
- {biExtremeHillsM, "ExtremeHillsM"},
- {biFlowerForest, "FlowerForest"},
- {biTaigaM, "TaigaM"},
- {biSwamplandM, "SwamplandM"},
- {biIcePlainsSpikes, "IcePlainsSpikes"},
- {biJungleM, "JungleM"},
- {biJungleEdgeM, "JungleEdgeM"},
- {biBirchForestM, "BirchForestM"},
- {biBirchForestHillsM, "BirchForestHillsM"},
- {biRoofedForestM, "RoofedForestM"},
- {biColdTaigaM, "ColdTaigaM"},
- {biMegaSpruceTaiga, "MegaSpruceTaiga"},
- {biMegaSpruceTaigaHills, "MegaSpruceTaigaHills"},
- {biExtremeHillsPlusM, "ExtremeHillsPlusM"},
- {biSavannaM, "SavannaM"},
- {biSavannaPlateauM, "SavannaPlateauM"},
- {biMesaBryce, "MesaBryce"},
- {biMesaPlateauFM, "MesaPlateauFM"},
- {biMesaPlateauM, "MesaPlateauM"},
- } ;
-
- for (size_t i = 0; i < ARRAYCOUNT(BiomeMap); i++)
+ for (size_t i = 0; i < ARRAYCOUNT(g_BiomeMap); i++)
{
- if (NoCaseCompare(BiomeMap[i].m_String, a_BiomeString) == 0)
+ if (NoCaseCompare(g_BiomeMap[i].m_String, a_BiomeString) == 0)
{
- return BiomeMap[i].m_Biome;
+ return g_BiomeMap[i].m_Biome;
}
} // for i - BiomeMap[]
return biInvalidBiome;
@@ -115,6 +122,22 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
+AString BiomeToString(int a_Biome)
+{
+ for (size_t i = 0; i < ARRAYCOUNT(g_BiomeMap); i++)
+ {
+ if (g_BiomeMap[i].m_Biome == a_Biome)
+ {
+ return g_BiomeMap[i].m_String;
+ }
+ }
+ return AString();
+}
+
+
+
+
+
bool IsBiomeNoDownfall(EMCSBiome a_Biome)
{
switch (a_Biome)
diff --git a/src/BiomeDef.h b/src/BiomeDef.h
index 474d4df76..f929596e9 100644
--- a/src/BiomeDef.h
+++ b/src/BiomeDef.h
@@ -10,7 +10,7 @@
#pragma once
-
+#include "StringUtils.h"
// tolua_begin
@@ -104,10 +104,13 @@ enum EMCSBiome
biMaxVariantBiome = biNumVariantBiomes - 1, // The maximum biome value
} ;
-/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure.
+/** Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure. */
extern EMCSBiome StringToBiome(const AString & a_BiomeString);
-/// Returns true if the biome has no downfall - deserts and savannas
+/** Translates biome enum into biome string. Returns empty string on failure (unknown biome). */
+extern AString BiomeToString(int a_Biome);
+
+/** Returns true if the biome has no downfall - deserts and savannas */
extern bool IsBiomeNoDownfall(EMCSBiome a_Biome);
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 40cca8882..a0dcb5ec8 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -9,22 +9,34 @@
#include "OSSupport/GZipFile.h"
#include "Blocks/BlockHandler.h"
#include "Cuboid.h"
+#include "ChunkData.h"
+// Disable MSVC warnings: "conditional expression is constant"
+#ifdef _MSC_VER
+ #pragma warning(push)
+ #pragma warning(disable:4127)
+#endif
+
+
+
+
+
+typedef void (CombinatorFunc)(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta);
// This wild construct allows us to pass a function argument and still have it inlined by the compiler :)
/// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function
-template<typename Combinator> void InternalMergeBlocks(
+template<bool MetasValid, CombinatorFunc Combinator>
+void InternalMergeBlocks(
BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes,
- NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas,
+ NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas,
int a_SizeX, int a_SizeY, int a_SizeZ,
int a_SrcOffX, int a_SrcOffY, int a_SrcOffZ,
int a_DstOffX, int a_DstOffY, int a_DstOffZ,
int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ,
- int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ,
- Combinator a_Combinator
+ int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ
)
{
UNUSED(a_SrcSizeY);
@@ -41,7 +53,15 @@ template<typename Combinator> void InternalMergeBlocks(
int DstIdx = DstBaseZ + a_DstOffX;
for (int x = 0; x < a_SizeX; x++)
{
- a_Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], a_DstMetas[DstIdx], a_SrcMetas[SrcIdx]);
+ if (MetasValid)
+ {
+ Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], a_DstMetas[DstIdx], a_SrcMetas[SrcIdx]);
+ }
+ else
+ {
+ NIBBLETYPE FakeDestMeta = 0;
+ Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], FakeDestMeta, (NIBBLETYPE)0);
+ }
++DstIdx;
++SrcIdx;
} // for x
@@ -54,10 +74,14 @@ template<typename Combinator> void InternalMergeBlocks(
/// Combinator used for cBlockArea::msOverwrite merging
-static inline void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
+template<bool MetaValid>
+void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
a_DstType = a_SrcType;
- a_DstMeta = a_SrcMeta;
+ if (MetaValid)
+ {
+ a_DstMeta = a_SrcMeta;
+ }
}
@@ -65,12 +89,16 @@ static inline void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_S
/// Combinator used for cBlockArea::msFillAir merging
-static inline void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
+template<bool MetaValid>
+void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
if (a_DstType == E_BLOCK_AIR)
{
a_DstType = a_SrcType;
- a_DstMeta = a_SrcMeta;
+ if (MetaValid)
+ {
+ a_DstMeta = a_SrcMeta;
+ }
}
// "else" is the default, already in place
}
@@ -80,12 +108,16 @@ static inline void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_Src
/// Combinator used for cBlockArea::msImprint merging
-static inline void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
+template<bool MetaValid>
+void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
if (a_SrcType != E_BLOCK_AIR)
{
a_DstType = a_SrcType;
- a_DstMeta = a_SrcMeta;
+ if (MetaValid)
+ {
+ a_DstMeta = a_SrcMeta;
+ }
}
// "else" is the default, already in place
}
@@ -95,7 +127,8 @@ static inline void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_Src
/// Combinator used for cBlockArea::msLake merging
-static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
+template<bool MetaValid>
+void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
// Sponge is the NOP block
if (a_SrcType == E_BLOCK_SPONGE)
@@ -103,11 +136,14 @@ static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp
return;
}
- // Air is always hollowed out
+ // Air is always hollowed out
if (a_SrcType == E_BLOCK_AIR)
{
a_DstType = E_BLOCK_AIR;
- a_DstMeta = 0;
+ if (MetaValid)
+ {
+ a_DstMeta = 0;
+ }
return;
}
@@ -132,7 +168,10 @@ static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp
case E_BLOCK_STATIONARY_LAVA:
{
a_DstType = a_SrcType;
- a_DstMeta = a_SrcMeta;
+ if (MetaValid)
+ {
+ a_DstMeta = a_SrcMeta;
+ }
return;
}
}
@@ -146,7 +185,10 @@ static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp
case E_BLOCK_MYCELIUM:
{
a_DstType = E_BLOCK_STONE;
- a_DstMeta = 0;
+ if (MetaValid)
+ {
+ a_DstMeta = 0;
+ }
return;
}
}
@@ -159,13 +201,17 @@ static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcTyp
/** Combinator used for cBlockArea::msSpongePrint merging */
-static inline void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
+template<bool MetaValid>
+void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
// Sponge overwrites nothing, everything else overwrites anything
if (a_SrcType != E_BLOCK_SPONGE)
{
a_DstType = a_SrcType;
- a_DstMeta = a_SrcMeta;
+ if (MetaValid)
+ {
+ a_DstMeta = a_SrcMeta;
+ }
}
}
@@ -174,17 +220,24 @@ static inline void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a
/** Combinator used for cBlockArea::msDifference merging */
-static inline void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
+template<bool MetaValid>
+void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
- if ((a_DstType == a_SrcType) && (a_DstMeta == a_SrcMeta))
+ if ((a_DstType == a_SrcType) && (!MetaValid || (a_DstMeta == a_SrcMeta)))
{
a_DstType = E_BLOCK_AIR;
- a_DstMeta = 0;
+ if (MetaValid)
+ {
+ a_DstMeta = 0;
+ }
}
else
{
a_DstType = a_SrcType;
- a_DstMeta = a_SrcMeta;
+ if (MetaValid)
+ {
+ a_DstMeta = a_SrcMeta;
+ }
}
}
@@ -193,21 +246,30 @@ static inline void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_
/** Combinator used for cBlockArea::msMask merging */
-static inline void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
+template<bool MetaValid>
+void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
// If the blocks are the same, keep the dest; otherwise replace with air
- if ((a_SrcType != a_DstType) || (a_SrcMeta != a_DstMeta))
+ if ((a_SrcType != a_DstType) || !MetaValid || (a_SrcMeta != a_DstMeta))
{
a_DstType = E_BLOCK_AIR;
- a_DstMeta = 0;
+ if (MetaValid)
+ {
+ a_DstMeta = 0;
+ }
}
}
+// Re-enable previously disabled MSVC warnings
+#ifdef _MSC_VER
+ #pragma warning(pop)
+#endif
+
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBlockArea:
cBlockArea::cBlockArea(void) :
@@ -233,9 +295,9 @@ cBlockArea::~cBlockArea()
void cBlockArea::Clear(void)
{
- delete[] m_BlockTypes; m_BlockTypes = NULL;
- delete[] m_BlockMetas; m_BlockMetas = NULL;
- delete[] m_BlockLight; m_BlockLight = NULL;
+ delete[] m_BlockTypes; m_BlockTypes = NULL;
+ delete[] m_BlockMetas; m_BlockMetas = NULL;
+ delete[] m_BlockLight; m_BlockLight = NULL;
delete[] m_BlockSkyLight; m_BlockSkyLight = NULL;
m_Origin.Set(0, 0, 0);
m_Size.Set(0, 0, 0);
@@ -247,6 +309,14 @@ void cBlockArea::Clear(void)
void cBlockArea::Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
{
+ if ((a_SizeX < 0) || (a_SizeY < 0) || (a_SizeZ < 0))
+ {
+ LOGWARNING("Creating a cBlockArea with a negative size! Call to Create ignored. (%d, %d, %d)",
+ a_SizeX, a_SizeY, a_SizeZ
+ );
+ return;
+ }
+
Clear();
int BlockCount = a_SizeX * a_SizeY * a_SizeZ;
if ((a_DataTypes & baTypes) != 0)
@@ -484,7 +554,7 @@ void cBlockArea::CopyTo(cBlockArea & a_Into) const
a_Into.Clear();
a_Into.SetSize(m_Size.x, m_Size.y, m_Size.z, GetDataTypes());
a_Into.m_Origin = m_Origin;
- int BlockCount = GetBlockCount();
+ size_t BlockCount = GetBlockCount();
if (HasBlockTypes())
{
memcpy(a_Into.m_BlockTypes, m_BlockTypes, BlockCount * sizeof(BLOCKTYPE));
@@ -532,7 +602,7 @@ void cBlockArea::DumpToRawFile(const AString & a_FileName)
f.Write(&SizeZ, 4);
unsigned char DataTypes = (unsigned char)GetDataTypes();
f.Write(&DataTypes, 1);
- int NumBlocks = GetBlockCount();
+ size_t NumBlocks = GetBlockCount();
if (HasBlockTypes())
{
f.Write(m_BlockTypes, NumBlocks * sizeof(BLOCKTYPE));
@@ -637,155 +707,19 @@ void cBlockArea::Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMa
void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy)
{
- // Block types are compulsory, block metas are voluntary
- if (!HasBlockTypes() || !a_Src.HasBlockTypes())
- {
- LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__);
- return;
- }
-
- // Dst is *this, Src is a_Src
- int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading
- int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing
- int SizeX = std::min(a_Src.GetSizeX() - SrcOffX, GetSizeX() - DstOffX); // How many blocks to copy
-
- int SrcOffY = std::max(0, -a_RelY); // Offset in Src where to start reading
- int DstOffY = std::max(0, a_RelY); // Offset in Dst where to start writing
- int SizeY = std::min(a_Src.GetSizeY() - SrcOffY, GetSizeY() - DstOffY); // How many blocks to copy
-
- int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading
- int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing
- int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy
const NIBBLETYPE * SrcMetas = a_Src.GetBlockMetas();
NIBBLETYPE * DstMetas = m_BlockMetas;
+
bool IsDummyMetas = ((SrcMetas == NULL) || (DstMetas == NULL));
if (IsDummyMetas)
{
- SrcMetas = new NIBBLETYPE[a_Src.GetBlockCount()];
- DstMetas = new NIBBLETYPE[GetBlockCount()];
+ MergeByStrategy<false>(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas);
}
-
- switch (a_Strategy)
- {
- case msOverwrite:
- {
- InternalMergeBlocks(
- m_BlockTypes, a_Src.GetBlockTypes(),
- DstMetas, SrcMetas,
- SizeX, SizeY, SizeZ,
- SrcOffX, SrcOffY, SrcOffZ,
- DstOffX, DstOffY, DstOffZ,
- a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
- m_Size.x, m_Size.y, m_Size.z,
- MergeCombinatorOverwrite
- );
- break;
- } // case msOverwrite
-
- case msFillAir:
- {
- InternalMergeBlocks(
- m_BlockTypes, a_Src.GetBlockTypes(),
- DstMetas, SrcMetas,
- SizeX, SizeY, SizeZ,
- SrcOffX, SrcOffY, SrcOffZ,
- DstOffX, DstOffY, DstOffZ,
- a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
- m_Size.x, m_Size.y, m_Size.z,
- MergeCombinatorFillAir
- );
- break;
- } // case msFillAir
-
- case msImprint:
- {
- InternalMergeBlocks(
- m_BlockTypes, a_Src.GetBlockTypes(),
- DstMetas, SrcMetas,
- SizeX, SizeY, SizeZ,
- SrcOffX, SrcOffY, SrcOffZ,
- DstOffX, DstOffY, DstOffZ,
- a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
- m_Size.x, m_Size.y, m_Size.z,
- MergeCombinatorImprint
- );
- break;
- } // case msImprint
-
- case msLake:
- {
- InternalMergeBlocks(
- m_BlockTypes, a_Src.GetBlockTypes(),
- DstMetas, SrcMetas,
- SizeX, SizeY, SizeZ,
- SrcOffX, SrcOffY, SrcOffZ,
- DstOffX, DstOffY, DstOffZ,
- a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
- m_Size.x, m_Size.y, m_Size.z,
- MergeCombinatorLake
- );
- break;
- } // case msLake
-
- case msSpongePrint:
- {
- InternalMergeBlocks(
- m_BlockTypes, a_Src.GetBlockTypes(),
- DstMetas, SrcMetas,
- SizeX, SizeY, SizeZ,
- SrcOffX, SrcOffY, SrcOffZ,
- DstOffX, DstOffY, DstOffZ,
- a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
- m_Size.x, m_Size.y, m_Size.z,
- MergeCombinatorSpongePrint
- );
- break;
- } // case msSpongePrint
-
- case msDifference:
- {
- InternalMergeBlocks(
- m_BlockTypes, a_Src.GetBlockTypes(),
- DstMetas, SrcMetas,
- SizeX, SizeY, SizeZ,
- SrcOffX, SrcOffY, SrcOffZ,
- DstOffX, DstOffY, DstOffZ,
- a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
- m_Size.x, m_Size.y, m_Size.z,
- MergeCombinatorDifference
- );
- break;
- } // case msDifference
-
- case msMask:
- {
- InternalMergeBlocks(
- m_BlockTypes, a_Src.GetBlockTypes(),
- DstMetas, SrcMetas,
- SizeX, SizeY, SizeZ,
- SrcOffX, SrcOffY, SrcOffZ,
- DstOffX, DstOffY, DstOffZ,
- a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
- m_Size.x, m_Size.y, m_Size.z,
- MergeCombinatorMask
- );
- break;
- } // case msMask
-
- default:
- {
- LOGWARNING("Unknown block area merge strategy: %d", a_Strategy);
- ASSERT(!"Unknown block area merge strategy");
- break;
- }
- } // switch (a_Strategy)
-
- if (IsDummyMetas)
+ else
{
- delete[] SrcMetas;
- delete[] DstMetas;
+ MergeByStrategy<true>(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas);
}
}
@@ -812,31 +746,31 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block
a_DataTypes = a_DataTypes & GetDataTypes();
}
- int BlockCount = GetBlockCount();
+ size_t BlockCount = GetBlockCount();
if ((a_DataTypes & baTypes) != 0)
{
- for (int i = 0; i < BlockCount; i++)
+ for (size_t i = 0; i < BlockCount; i++)
{
m_BlockTypes[i] = a_BlockType;
}
}
if ((a_DataTypes & baMetas) != 0)
{
- for (int i = 0; i < BlockCount; i++)
+ for (size_t i = 0; i < BlockCount; i++)
{
m_BlockMetas[i] = a_BlockMeta;
}
}
if ((a_DataTypes & baLight) != 0)
{
- for (int i = 0; i < BlockCount; i++)
+ for (size_t i = 0; i < BlockCount; i++)
{
m_BlockLight[i] = a_BlockLight;
}
}
if ((a_DataTypes & baSkyLight) != 0)
{
- for (int i = 0; i < BlockCount; i++)
+ for (size_t i = 0; i < BlockCount; i++)
{
m_BlockSkyLight[i] = a_BlockSkyLight;
}
@@ -847,7 +781,7 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block
-void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
+void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
)
@@ -1079,8 +1013,8 @@ void cBlockArea::RotateCCW(void)
} // for x
std::swap(m_BlockTypes, NewTypes);
std::swap(m_BlockMetas, NewMetas);
- delete[] NewTypes;
- delete[] NewMetas;
+ delete[] NewTypes; NewTypes = NULL;
+ delete[] NewMetas; NewMetas = NULL;
std::swap(m_Size.x, m_Size.z);
}
@@ -1124,8 +1058,8 @@ void cBlockArea::RotateCW(void)
} // for x
std::swap(m_BlockTypes, NewTypes);
std::swap(m_BlockMetas, NewMetas);
- delete[] NewTypes;
- delete[] NewMetas;
+ delete[] NewTypes; NewTypes = NULL;
+ delete[] NewMetas; NewMetas = NULL;
std::swap(m_Size.x, m_Size.z);
}
@@ -1272,7 +1206,7 @@ void cBlockArea::RotateCCWNoMeta(void)
} // for z
} // for x
std::swap(m_BlockTypes, NewTypes);
- delete[] NewTypes;
+ delete[] NewTypes; NewTypes = NULL;
}
if (HasBlockMetas())
{
@@ -1290,7 +1224,7 @@ void cBlockArea::RotateCCWNoMeta(void)
} // for z
} // for x
std::swap(m_BlockMetas, NewMetas);
- delete[] NewMetas;
+ delete[] NewMetas; NewMetas = NULL;
}
std::swap(m_Size.x, m_Size.z);
}
@@ -1317,7 +1251,7 @@ void cBlockArea::RotateCWNoMeta(void)
} // for x
} // for z
std::swap(m_BlockTypes, NewTypes);
- delete[] NewTypes;
+ delete[] NewTypes; NewTypes = NULL;
}
if (HasBlockMetas())
{
@@ -1335,7 +1269,7 @@ void cBlockArea::RotateCWNoMeta(void)
} // for x
} // for z
std::swap(m_BlockMetas, NewMetas);
- delete[] NewMetas;
+ delete[] NewMetas; NewMetas = NULL;
}
std::swap(m_Size.x, m_Size.z);
}
@@ -1724,6 +1658,7 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
if (m_BlockMetas == NULL)
{
delete[] m_BlockTypes;
+ m_BlockTypes = NULL;
return false;
}
}
@@ -1733,7 +1668,9 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
if (m_BlockLight == NULL)
{
delete[] m_BlockMetas;
+ m_BlockMetas = NULL;
delete[] m_BlockTypes;
+ m_BlockTypes = NULL;
return false;
}
}
@@ -1743,8 +1680,11 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
if (m_BlockSkyLight == NULL)
{
delete[] m_BlockLight;
+ m_BlockLight = NULL;
delete[] m_BlockMetas;
+ m_BlockMetas = NULL;
delete[] m_BlockTypes;
+ m_BlockTypes = NULL;
return false;
}
}
@@ -1819,7 +1759,7 @@ NIBBLETYPE cBlockArea::GetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBL
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBlockArea::cChunkReader:
cBlockArea::cChunkReader::cChunkReader(cBlockArea & a_Area) :
@@ -1909,18 +1849,12 @@ bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ)
-void cBlockArea::cChunkReader::BlockTypes(const BLOCKTYPE * a_BlockTypes)
+void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
{
- if (m_Area.m_BlockTypes == NULL)
- {
- // Don't want BlockTypes
- return;
- }
-
int SizeY = m_Area.m_Size.y;
int MinY = m_Origin.y;
-
- // SizeX, SizeZ are the dmensions of the block data to copy from the current chunk (size of the geometric union)
+
+ // SizeX, SizeZ are the dimensions of the block data to copy from the current chunk (size of the geometric union)
// OffX, OffZ are the offsets of the current chunk data from the area origin
// BaseX, BaseZ are the offsets of the area data within the current chunk from the chunk borders
int SizeX = cChunkDef::Width;
@@ -1958,71 +1892,95 @@ void cBlockArea::cChunkReader::BlockTypes(const BLOCKTYPE * a_BlockTypes)
{
SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_Origin.z + m_Area.m_Size.z);
}
-
- for (int y = 0; y < SizeY; y++)
+
+ // Copy the blocktypes:
+ if (m_Area.m_BlockTypes != NULL)
{
- int ChunkY = MinY + y;
- int AreaY = y;
- for (int z = 0; z < SizeZ; z++)
+ for (int y = 0; y < SizeY; y++)
{
- int ChunkZ = BaseZ + z;
- int AreaZ = OffZ + z;
- for (int x = 0; x < SizeX; x++)
+ int InChunkY = MinY + y;
+ int AreaY = y;
+ for (int z = 0; z < SizeZ; z++)
{
- int ChunkX = BaseX + x;
- int AreaX = OffX + x;
- m_Area.m_BlockTypes[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = cChunkDef::GetBlock(a_BlockTypes, ChunkX, ChunkY, ChunkZ);
- } // for x
- } // for z
- } // for y
-}
-
-
-
-
+ int InChunkZ = BaseZ + z;
+ int AreaZ = OffZ + z;
+ for (int x = 0; x < SizeX; x++)
+ {
+ int InChunkX = BaseX + x;
+ int AreaX = OffX + x;
+ m_Area.m_BlockTypes[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetBlock(InChunkX, InChunkY, InChunkZ);
+ } // for x
+ } // for z
+ } // for y
+ }
-void cBlockArea::cChunkReader::BlockMeta(const NIBBLETYPE * a_BlockMetas)
-{
- if (m_Area.m_BlockMetas == NULL)
+ // Copy the block metas:
+ if (m_Area.m_BlockMetas != NULL)
{
- // Don't want metas
- return;
+ for (int y = 0; y < SizeY; y++)
+ {
+ int InChunkY = MinY + y;
+ int AreaY = y;
+ for (int z = 0; z < SizeZ; z++)
+ {
+ int InChunkZ = BaseZ + z;
+ int AreaZ = OffZ + z;
+ for (int x = 0; x < SizeX; x++)
+ {
+ int InChunkX = BaseX + x;
+ int AreaX = OffX + x;
+ m_Area.m_BlockMetas[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetMeta(InChunkX, InChunkY, InChunkZ);
+ } // for x
+ } // for z
+ } // for y
}
- CopyNibbles(m_Area.m_BlockMetas, a_BlockMetas);
-}
-
-
-
-
-void cBlockArea::cChunkReader::BlockLight(const NIBBLETYPE * a_BlockLight)
-{
- if (m_Area.m_BlockLight == NULL)
+ // Copy the blocklight:
+ if (m_Area.m_BlockLight != NULL)
{
- // Don't want light
- return;
+ for (int y = 0; y < SizeY; y++)
+ {
+ int InChunkY = MinY + y;
+ int AreaY = y;
+ for (int z = 0; z < SizeZ; z++)
+ {
+ int InChunkZ = BaseZ + z;
+ int AreaZ = OffZ + z;
+ for (int x = 0; x < SizeX; x++)
+ {
+ int InChunkX = BaseX + x;
+ int AreaX = OffX + x;
+ m_Area.m_BlockLight[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetBlockLight(InChunkX, InChunkY, InChunkZ);
+ } // for x
+ } // for z
+ } // for y
}
- CopyNibbles(m_Area.m_BlockLight, a_BlockLight);
-}
-
-
-
-
-void cBlockArea::cChunkReader::BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight)
-{
- if (m_Area.m_BlockSkyLight == NULL)
+ // Copy the skylight:
+ if (m_Area.m_BlockSkyLight != NULL)
{
- // Don't want skylight
- return;
+ for (int y = 0; y < SizeY; y++)
+ {
+ int InChunkY = MinY + y;
+ int AreaY = y;
+ for (int z = 0; z < SizeZ; z++)
+ {
+ int InChunkZ = BaseZ + z;
+ int AreaZ = OffZ + z;
+ for (int x = 0; x < SizeX; x++)
+ {
+ int InChunkX = BaseX + x;
+ int AreaX = OffX + x;
+ m_Area.m_BlockSkyLight[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = a_BlockBuffer.GetSkyLight(InChunkX, InChunkY, InChunkZ);
+ } // for x
+ } // for z
+ } // for y
}
- CopyNibbles(m_Area.m_BlockSkyLight, a_BlockSkyLight);
}
-
void cBlockArea::CropBlockTypes(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ)
{
int NewSizeX = GetSizeX() - a_AddMinX - a_SubMaxX;
@@ -2079,7 +2037,7 @@ void cBlockArea::ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, i
int NewSizeX = m_Size.x + a_SubMinX + a_AddMaxX;
int NewSizeY = m_Size.y + a_SubMinY + a_AddMaxY;
int NewSizeZ = m_Size.z + a_SubMinZ + a_AddMaxZ;
- int BlockCount = NewSizeX * NewSizeY * NewSizeZ;
+ size_t BlockCount = (size_t)(NewSizeX * NewSizeY * NewSizeZ);
BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[BlockCount];
memset(NewBlockTypes, 0, BlockCount * sizeof(BLOCKTYPE));
int OldIndex = 0;
@@ -2109,7 +2067,7 @@ void cBlockArea::ExpandNibbles(NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMa
int NewSizeX = m_Size.x + a_SubMinX + a_AddMaxX;
int NewSizeY = m_Size.y + a_SubMinY + a_AddMaxY;
int NewSizeZ = m_Size.z + a_SubMinZ + a_AddMaxZ;
- int BlockCount = NewSizeX * NewSizeY * NewSizeZ;
+ size_t BlockCount = (size_t)(NewSizeX * NewSizeY * NewSizeZ);
NIBBLETYPE * NewNibbles = new NIBBLETYPE[BlockCount];
memset(NewNibbles, 0, BlockCount * sizeof(NIBBLETYPE));
int OldIndex = 0;
@@ -2161,4 +2119,134 @@ void cBlockArea::RelSetData(
+template<bool MetasValid>
+void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas)
+{
+ // Block types are compulsory, block metas are voluntary
+ if (!HasBlockTypes() || !a_Src.HasBlockTypes())
+ {
+ LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__);
+ return;
+ }
+
+ // Dst is *this, Src is a_Src
+ int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading
+ int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing
+ int SizeX = std::min(a_Src.GetSizeX() - SrcOffX, GetSizeX() - DstOffX); // How many blocks to copy
+
+ int SrcOffY = std::max(0, -a_RelY); // Offset in Src where to start reading
+ int DstOffY = std::max(0, a_RelY); // Offset in Dst where to start writing
+ int SizeY = std::min(a_Src.GetSizeY() - SrcOffY, GetSizeY() - DstOffY); // How many blocks to copy
+
+ int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading
+ int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing
+ int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy
+
+ switch (a_Strategy)
+ {
+ case cBlockArea::msOverwrite:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorOverwrite<MetasValid> >(
+ m_BlockTypes, a_Src.GetBlockTypes(),
+ DstMetas, SrcMetas,
+ SizeX, SizeY, SizeZ,
+ SrcOffX, SrcOffY, SrcOffZ,
+ DstOffX, DstOffY, DstOffZ,
+ a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
+ m_Size.x, m_Size.y, m_Size.z
+ );
+ return;
+ } // case msOverwrite
+
+ case cBlockArea::msFillAir:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorFillAir<MetasValid> >(
+ m_BlockTypes, a_Src.GetBlockTypes(),
+ DstMetas, SrcMetas,
+ SizeX, SizeY, SizeZ,
+ SrcOffX, SrcOffY, SrcOffZ,
+ DstOffX, DstOffY, DstOffZ,
+ a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
+ m_Size.x, m_Size.y, m_Size.z
+ );
+ return;
+ } // case msFillAir
+
+ case cBlockArea::msImprint:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorImprint<MetasValid> >(
+ m_BlockTypes, a_Src.GetBlockTypes(),
+ DstMetas, SrcMetas,
+ SizeX, SizeY, SizeZ,
+ SrcOffX, SrcOffY, SrcOffZ,
+ DstOffX, DstOffY, DstOffZ,
+ a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
+ m_Size.x, m_Size.y, m_Size.z
+ );
+ return;
+ } // case msImprint
+
+ case cBlockArea::msLake:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorLake<MetasValid> >(
+ m_BlockTypes, a_Src.GetBlockTypes(),
+ DstMetas, SrcMetas,
+ SizeX, SizeY, SizeZ,
+ SrcOffX, SrcOffY, SrcOffZ,
+ DstOffX, DstOffY, DstOffZ,
+ a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
+ m_Size.x, m_Size.y, m_Size.z
+ );
+ return;
+ } // case msLake
+
+ case cBlockArea::msSpongePrint:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorSpongePrint<MetasValid> >(
+ m_BlockTypes, a_Src.GetBlockTypes(),
+ DstMetas, SrcMetas,
+ SizeX, SizeY, SizeZ,
+ SrcOffX, SrcOffY, SrcOffZ,
+ DstOffX, DstOffY, DstOffZ,
+ a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
+ m_Size.x, m_Size.y, m_Size.z
+ );
+ return;
+ } // case msSpongePrint
+
+ case cBlockArea::msDifference:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorDifference<MetasValid> >(
+ m_BlockTypes, a_Src.GetBlockTypes(),
+ DstMetas, SrcMetas,
+ SizeX, SizeY, SizeZ,
+ SrcOffX, SrcOffY, SrcOffZ,
+ DstOffX, DstOffY, DstOffZ,
+ a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
+ m_Size.x, m_Size.y, m_Size.z
+ );
+ return;
+ } // case msDifference
+
+ case cBlockArea::msMask:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorMask<MetasValid> >(
+ m_BlockTypes, a_Src.GetBlockTypes(),
+ DstMetas, SrcMetas,
+ SizeX, SizeY, SizeZ,
+ SrcOffX, SrcOffY, SrcOffZ,
+ DstOffX, DstOffY, DstOffZ,
+ a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
+ m_Size.x, m_Size.y, m_Size.z
+ );
+ return;
+ } // case msMask
+ } // switch (a_Strategy)
+
+ LOGWARNING("Unknown block area merge strategy: %d", a_Strategy);
+ ASSERT(!"Unknown block area merge strategy");
+ return;
+}
+
+
diff --git a/src/BlockArea.h b/src/BlockArea.h
index c48175b8c..a95ba7788 100644
--- a/src/BlockArea.h
+++ b/src/BlockArea.h
@@ -14,6 +14,7 @@
#include "ForEachChunkProvider.h"
#include "Vector3.h"
+#include "ChunkDataCallback.h"
@@ -174,7 +175,7 @@ public:
void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f);
/** Fills a cuboid inside the block area with the specified data */
- void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
+ void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
@@ -294,7 +295,7 @@ public:
NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block!
NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block!
NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight; } // NOTE: one byte per block!
- int GetBlockCount(void) const { return m_Size.x * m_Size.y * m_Size.z; }
+ size_t GetBlockCount(void) const { return (size_t)(m_Size.x * m_Size.y * m_Size.z); }
int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const;
protected:
@@ -316,11 +317,8 @@ protected:
void CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc);
// cChunkDataCallback overrides:
- virtual bool Coords (int a_ChunkX, int a_ChunkZ) override;
- virtual void BlockTypes (const BLOCKTYPE * a_BlockTypes) override;
- virtual void BlockMeta (const NIBBLETYPE * a_BlockMetas) override;
- virtual void BlockLight (const NIBBLETYPE * a_BlockLight) override;
- virtual void BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight) override;
+ virtual bool Coords(int a_ChunkX, int a_ChunkZ) override;
+ virtual void ChunkData(const cChunkData & a_BlockTypes) override;
} ;
typedef NIBBLETYPE * NIBBLEARRAY;
@@ -359,10 +357,13 @@ protected:
/** Sets the specified datatypes at the specified location. */
void RelSetData(
- int a_RelX, int a_RelY, int a_RelZ,
+ int a_RelX, int a_RelY, int a_RelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
);
+
+ template<bool MetasValid>
+ void MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas);
// tolua_begin
} ;
// tolua_end
diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp
index 0914353eb..4b9662797 100644
--- a/src/BlockEntities/BeaconEntity.cpp
+++ b/src/BlockEntities/BeaconEntity.cpp
@@ -32,7 +32,7 @@ int cBeaconEntity::GetPyramidLevel(void)
}
Area.Read(
- m_World,
+ m_World,
GetPosX() - 4, GetPosX() + 4,
MinY, MaxY,
GetPosZ() - 4, GetPosZ() + 4,
@@ -66,7 +66,7 @@ int cBeaconEntity::GetPyramidLevel(void)
bool cBeaconEntity::IsMineralBlock(BLOCKTYPE a_BlockType)
{
- switch(a_BlockType)
+ switch (a_BlockType)
{
case E_BLOCK_DIAMOND_BLOCK:
case E_BLOCK_GOLD_BLOCK:
diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h
index b1df68bc4..ee1eda391 100644
--- a/src/BlockEntities/BeaconEntity.h
+++ b/src/BlockEntities/BeaconEntity.h
@@ -33,7 +33,7 @@ public:
static bool IsMineralBlock(BLOCKTYPE a_BlockType);
// cBlockEntity overrides:
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ virtual void SaveToJson(Json::Value& a_Value) override;
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
virtual bool Tick(float a_Dt, cChunk & /* a_Chunk */) override;
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp
index 430f04551..05ad03a3d 100644
--- a/src/BlockEntities/BlockEntity.cpp
+++ b/src/BlockEntities/BlockEntity.cpp
@@ -28,24 +28,26 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
switch (a_BlockType)
{
case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_FLOWER_POT: return new cFlowerPotEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
+ case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
}
LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)",
__FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()
);
+ ASSERT(!"Requesting creation of an unknown block entity");
return NULL;
}
diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h
index 7c6688f8d..5710f8543 100644
--- a/src/BlockEntities/BlockEntity.h
+++ b/src/BlockEntities/BlockEntity.h
@@ -38,9 +38,9 @@ protected:
public:
// tolua_end
- virtual ~cBlockEntity() {}; // force a virtual destructor in all descendants
+ virtual ~cBlockEntity() {} // force a virtual destructor in all descendants
- virtual void Destroy(void) {};
+ virtual void Destroy(void) {}
void SetWorld(cWorld * a_World)
{
@@ -79,7 +79,7 @@ public:
virtual void SaveToJson (Json::Value & a_Value) = 0;
/// Called when a player uses this entity; should open the UI window
- virtual void UsedBy( cPlayer * a_Player ) = 0;
+ virtual void UsedBy( cPlayer * a_Player) = 0;
/** Sends the packet defining the block entity to the client specified.
To send to all eligible clients, use cWorld::BroadcastBlockEntity()
diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h
index 918781a00..5f1639d45 100644
--- a/src/BlockEntities/BlockEntityWithItems.h
+++ b/src/BlockEntities/BlockEntityWithItems.h
@@ -50,7 +50,7 @@ public:
cItems Pickups;
m_Contents.CopyToItems(Pickups);
m_Contents.Clear();
- m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block
+ m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block
}
// tolua_begin
diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt
index 3e3d17f86..d87594b0d 100644
--- a/src/BlockEntities/CMakeLists.txt
+++ b/src/BlockEntities/CMakeLists.txt
@@ -4,9 +4,41 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ BeaconEntity.cpp
+ BlockEntity.cpp
+ ChestEntity.cpp
+ CommandBlockEntity.cpp
+ DispenserEntity.cpp
+ DropSpenserEntity.cpp
+ DropperEntity.cpp
+ EnderChestEntity.cpp
+ FlowerPotEntity.cpp
+ FurnaceEntity.cpp
+ HopperEntity.cpp
+ JukeboxEntity.cpp
+ MobHeadEntity.cpp
+ NoteEntity.cpp
+ SignEntity.cpp)
-add_library(BlockEntities ${SOURCE})
+SET (HDRS
+ BeaconEntity.h
+ BlockEntity.h
+ BlockEntityWithItems.h
+ ChestEntity.h
+ CommandBlockEntity.h
+ DispenserEntity.h
+ DropSpenserEntity.h
+ DropperEntity.h
+ EnderChestEntity.h
+ FlowerPotEntity.h
+ FurnaceEntity.h
+ HopperEntity.h
+ JukeboxEntity.h
+ MobHeadEntity.h
+ NoteEntity.h
+ SignEntity.h)
+
+if(NOT MSVC)
+ add_library(BlockEntities ${SRCS} ${HDRS})
+endif()
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp
index dfbe6ae87..21e1f6ba2 100644
--- a/src/BlockEntities/ChestEntity.cpp
+++ b/src/BlockEntities/ChestEntity.cpp
@@ -11,8 +11,9 @@
-cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
- super(E_BLOCK_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World)
+cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type) :
+ super(a_Type, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
+ m_NumActivePlayers(0)
{
cBlockEntityWindowOwner::SetBlockEntity(this);
}
@@ -113,7 +114,7 @@ void cChestEntity::UsedBy(cPlayer * a_Player)
// The few false positives aren't much to worry about
int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(m_PosX, m_PosZ, ChunkX, ChunkZ);
- m_World->MarkChunkDirty(ChunkX, ChunkZ);
+ m_World->MarkChunkDirty(ChunkX, ChunkZ, true);
}
@@ -122,6 +123,13 @@ void cChestEntity::UsedBy(cPlayer * a_Player)
void cChestEntity::OpenNewWindow(void)
{
+ // TODO: cats are an obstruction
+ if ((GetPosY() + 1 < cChunkDef::Height) && cBlockInfo::IsSolid(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())))
+ {
+ // Obstruction, don't open
+ return;
+ }
+
// Callback for opening together with neighbor chest:
class cOpenDouble :
public cChestCallback
@@ -135,6 +143,12 @@ void cChestEntity::OpenNewWindow(void)
virtual bool Item(cChestEntity * a_Chest) override
{
+ if ((a_Chest->GetPosY() + 1 < cChunkDef::Height) && cBlockInfo::IsSolid(a_Chest->GetWorld()->GetBlock(a_Chest->GetPosX(), a_Chest->GetPosY() + 1, a_Chest->GetPosZ())))
+ {
+ // Obstruction, don't open
+ return false;
+ }
+
// The primary chest should eb the one with lesser X or Z coord:
cChestEntity * Primary = a_Chest;
cChestEntity * Secondary = m_ThisChest;
@@ -155,15 +169,15 @@ void cChestEntity::OpenNewWindow(void)
if (
m_World->DoWithChestAt(m_PosX - 1, m_PosY, m_PosZ, OpenDbl) ||
m_World->DoWithChestAt(m_PosX + 1, m_PosY, m_PosZ, OpenDbl) ||
- m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ - 1, OpenDbl) ||
- m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ + 1, OpenDbl)
+ m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ - 1, OpenDbl) ||
+ m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ + 1, OpenDbl)
)
{
// The double-chest window has been opened in the callback
return;
}
- // There is no chest neighbor, open a single-chest window:
+ // There is no chest neighbor, open a single-chest window:
OpenWindow(new cChestWindow(this));
}
diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h
index ce16f84d7..cd06b3e2c 100644
--- a/src/BlockEntities/ChestEntity.h
+++ b/src/BlockEntities/ChestEntity.h
@@ -27,15 +27,16 @@ class cChestEntity :
typedef cBlockEntityWithItems super;
public:
- enum {
+ enum
+ {
ContentsHeight = 3,
ContentsWidth = 9,
} ;
// tolua_end
- /// Constructor used for normal operation
- cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+ /** Constructor used for normal operation */
+ cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type);
virtual ~cChestEntity();
@@ -48,8 +49,20 @@ public:
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
- /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate.
+ /** Opens a new chest window for this chest.
+ Scans for neighbors to open a double chest window, if appropriate. */
void OpenNewWindow(void);
+
+ /** Gets the number of players who currently have this chest open */
+ int GetNumberOfPlayers(void) const { return m_NumActivePlayers; }
+
+ /** Sets the number of players who currently have this chest open */
+ void SetNumberOfPlayers(int a_NumActivePlayers) { m_NumActivePlayers = a_NumActivePlayers; }
+
+private:
+
+ /** Number of players who currently have this chest open */
+ int m_NumActivePlayers;
} ; // tolua_export
diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp
index 146ad915b..45f8a3e4d 100644
--- a/src/BlockEntities/CommandBlockEntity.cpp
+++ b/src/BlockEntities/CommandBlockEntity.cpp
@@ -11,7 +11,7 @@
#include "../CommandOutput.h"
#include "../Root.h"
-#include "../Server.h" // ExecuteConsoleCommand()
+#include "../Server.h" // ExecuteConsoleCommand()
#include "../Chunk.h"
diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h
index 12157670f..d02bf7d7b 100644
--- a/src/BlockEntities/CommandBlockEntity.h
+++ b/src/BlockEntities/CommandBlockEntity.h
@@ -26,7 +26,7 @@ namespace Json
// tolua_begin
-class cCommandBlockEntity :
+class cCommandBlockEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -38,8 +38,8 @@ public:
/// Creates a new empty command block entity
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ bool LoadFromJson( const Json::Value& a_Value);
+ virtual void SaveToJson(Json::Value& a_Value) override;
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void SendTo(cClientHandle & a_Client) override;
diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp
index 2a32f69d9..c02c68afa 100644
--- a/src/BlockEntities/DispenserEntity.cpp
+++ b/src/BlockEntities/DispenserEntity.cpp
@@ -6,6 +6,10 @@
#include "../Simulator/FluidSimulator.h"
#include "../Chunk.h"
+#include "../World.h"
+#include "../Entities/ArrowEntity.h"
+#include "../Entities/FireChargeEntity.h"
+#include "../Entities/ProjectileEntity.h"
@@ -33,7 +37,10 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
// Would dispense into / interact with a non-loaded chunk, ignore the tick
return;
}
+
BLOCKTYPE DispBlock = DispChunk->GetBlock(DispX, DispY, DispZ);
+ int BlockX = (DispX + DispChunk->GetPosX() * cChunkDef::Width);
+ int BlockZ = (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
// Dispense the item:
switch (m_Contents.GetSlot(a_SlotNum).m_ItemType)
@@ -69,7 +76,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
}
break;
} // E_ITEM_BUCKET
-
+
case E_ITEM_WATER_BUCKET:
{
LOGD("Dispensing water bucket in slot %d; DispBlock is \"%s\" (%d).", a_SlotNum, ItemTypeToString(DispBlock).c_str(), DispBlock);
@@ -83,7 +90,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
}
break;
}
-
+
case E_ITEM_LAVA_BUCKET:
{
LOGD("Dispensing lava bucket in slot %d; DispBlock is \"%s\" (%d).", a_SlotNum, ItemTypeToString(DispBlock).c_str(), DispBlock);
@@ -97,7 +104,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
}
break;
}
-
+
case E_ITEM_SPAWN_EGG:
{
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
@@ -108,7 +115,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
}
break;
}
-
+
case E_BLOCK_TNT:
{
// Spawn a primed TNT entity, if space allows:
@@ -128,7 +135,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
if (DispChunk->GetBlock(DispX, DispY, DispZ) == E_BLOCK_AIR)
{
DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_FIRE, 0);
-
+
bool ItemBroke = m_Contents.DamageItem(a_SlotNum, 1);
if (ItemBroke)
@@ -138,13 +145,41 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
}
break;
}
-
+
case E_ITEM_FIRE_CHARGE:
{
- // TODO: Spawn fireball entity
+ SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkFireCharge, GetShootVector(Meta) * 20);
+ m_Contents.ChangeSlotCount(a_SlotNum, -1);
+ break;
+ }
+
+ case E_ITEM_ARROW:
+ {
+ SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkArrow, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0));
+ m_Contents.ChangeSlotCount(a_SlotNum, -1);
+ break;
+ }
+
+ case E_ITEM_SNOWBALL:
+ {
+ SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkSnowball, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0));
+ m_Contents.ChangeSlotCount(a_SlotNum, -1);
+ break;
+ }
+
+ case E_ITEM_EGG:
+ {
+ SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkEgg, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0));
+ m_Contents.ChangeSlotCount(a_SlotNum, -1);
+ break;
+ }
+
+ case E_ITEM_FIREWORK_ROCKET:
+ {
+ // TODO: Add the fireworks entity
break;
}
-
+
default:
{
DropFromSlot(a_Chunk, a_SlotNum);
@@ -157,6 +192,34 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
+void cDispenserEntity::SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_ShootVector)
+{
+ m_World->CreateProjectile((double)a_BlockX + 0.5, (double)a_BlockY + 0.5, (double)a_BlockZ + 0.5, a_Kind, NULL, NULL, &a_ShootVector);
+}
+
+
+
+
+
+Vector3d cDispenserEntity::GetShootVector(NIBBLETYPE a_Meta)
+{
+ switch (a_Meta)
+ {
+ case E_META_DROPSPENSER_FACING_YP: return Vector3d( 0, 1, 0);
+ case E_META_DROPSPENSER_FACING_YM: return Vector3d( 0, -1, 0);
+ case E_META_DROPSPENSER_FACING_XM: return Vector3d(-1, 0, 0);
+ case E_META_DROPSPENSER_FACING_XP: return Vector3d( 1, 0, 0);
+ case E_META_DROPSPENSER_FACING_ZM: return Vector3d( 0, 0, -1);
+ case E_META_DROPSPENSER_FACING_ZP: return Vector3d( 0, 0, 1);
+ }
+ LOGWARNING("Unhandled dispenser meta: %d", a_Meta);
+ ASSERT(!"Unhandled dispenser facing");
+ return Vector3d(0, 1, 0);
+}
+
+
+
+
bool cDispenserEntity::ScoopUpLiquid(int a_SlotNum, short a_BucketItemType)
{
@@ -167,14 +230,14 @@ bool cDispenserEntity::ScoopUpLiquid(int a_SlotNum, short a_BucketItemType)
m_Contents.SetSlot(a_SlotNum, LiquidBucket);
return true;
}
-
+
// There are stacked buckets at the selected slot, see if a full bucket will fit somewhere else
if (m_Contents.HowManyCanFit(LiquidBucket) < 1)
{
// Cannot fit into m_Contents
return false;
}
-
+
m_Contents.ChangeSlotCount(a_SlotNum, -1);
m_Contents.AddItem(LiquidBucket);
return true;
@@ -195,7 +258,7 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum
// Not a suitable block in front
return false;
}
-
+
cItem EmptyBucket(E_ITEM_BUCKET, 1);
if (m_Contents.GetSlot(a_SlotNum).m_ItemCount == 1)
{
@@ -203,14 +266,14 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum
m_Contents.SetSlot(a_SlotNum, EmptyBucket);
return true;
}
-
+
// There are full buckets stacked at this slot, check if we can fit in the empty bucket
if (m_Contents.HowManyCanFit(EmptyBucket) < 1)
{
// The empty bucket wouldn't fit into m_Contents
return false;
}
-
+
// The empty bucket fits in, remove one full bucket and add the empty one
m_Contents.ChangeSlotCount(a_SlotNum, -1);
m_Contents.AddItem(EmptyBucket);
@@ -219,4 +282,3 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum
-
diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h
index fdfe4e5b4..b33d08342 100644
--- a/src/BlockEntities/DispenserEntity.h
+++ b/src/BlockEntities/DispenserEntity.h
@@ -12,27 +12,37 @@ class cDispenserEntity :
public cDropSpenserEntity
{
typedef cDropSpenserEntity super;
-
+
public:
// tolua_end
-
- /// Constructor used for normal operation
+
+ /** Constructor used for normal operation */
cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
static const char * GetClassStatic(void) { return "cDispenserEntity"; }
+ // tolua_begin
+
+ /** Spawns a projectile of the given kind in front of the dispenser with the specified speed. */
+ void SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_Speed);
+
+ /** Returns a unit vector in the cardinal direction of where the dispenser is facing. */
+ Vector3d GetShootVector(NIBBLETYPE a_Meta);
+
+ // tolua_end
+
private:
// cDropSpenser overrides:
virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override;
-
- /// If such a bucket can fit, adds it to m_Contents and returns true
+
+ /** If such a bucket can fit, adds it to m_Contents and returns true */
bool ScoopUpLiquid(int a_SlotNum, short a_BucketItemType);
-
- /// If the a_BlockInFront is liquidable and the empty bucket can fit, does the m_Contents processing and returns true
+
+ /** If the a_BlockInFront can be washed away by liquid and the empty bucket can fit,
+ does the m_Contents processing and returns true. Returns false otherwise. */
bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum);
} ; // tolua_export
-
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp
index 0012742fb..dc38e3e9b 100644
--- a/src/BlockEntities/DropSpenserEntity.cpp
+++ b/src/BlockEntities/DropSpenserEntity.cpp
@@ -42,7 +42,7 @@ cDropSpenserEntity::~cDropSpenserEntity()
void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction)
{
- switch (a_Direction)
+ switch (a_Direction & 0x07) // Vanilla uses the 8th bit to determine power state - we don't
{
case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return;
case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return;
@@ -90,7 +90,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
int SmokeDir = 0;
switch (Meta)
{
- case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block)
+ case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block)
case E_META_DROPSPENSER_FACING_YM: SmokeDir = 4; break;
case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break;
case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break;
@@ -99,7 +99,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
}
m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir);
m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
-}
+}
@@ -235,7 +235,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
cItems Pickups;
Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum));
- const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6
+ const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6
int PickupSpeedX = 0, PickupSpeedY = 0, PickupSpeedZ = 0;
switch (Meta)
{
@@ -249,7 +249,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
double MicroX, MicroY, MicroZ;
MicroX = DispX + 0.5;
- MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
+ MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
MicroZ = DispZ + 0.5;
diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h
index 47d3bd492..9f58d0b07 100644
--- a/src/BlockEntities/DropSpenserEntity.h
+++ b/src/BlockEntities/DropSpenserEntity.h
@@ -35,7 +35,8 @@ class cDropSpenserEntity :
typedef cBlockEntityWithItems super;
public:
- enum {
+ enum
+ {
ContentsHeight = 3,
ContentsWidth = 3,
} ;
diff --git a/src/BlockEntities/EnderChestEntity.cpp b/src/BlockEntities/EnderChestEntity.cpp
index e53930798..17816d63e 100644
--- a/src/BlockEntities/EnderChestEntity.cpp
+++ b/src/BlockEntities/EnderChestEntity.cpp
@@ -12,9 +12,8 @@
cEnderChestEntity::cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
- super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World)
+ super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, a_World)
{
- cBlockEntityWindowOwner::SetBlockEntity(this);
}
@@ -34,95 +33,63 @@ cEnderChestEntity::~cEnderChestEntity()
-bool cEnderChestEntity::LoadFromJson(const Json::Value & a_Value)
+void cEnderChestEntity::UsedBy(cPlayer * a_Player)
{
- m_PosX = a_Value.get("x", 0).asInt();
- m_PosY = a_Value.get("y", 0).asInt();
- m_PosZ = a_Value.get("z", 0).asInt();
-
- Json::Value AllSlots = a_Value.get("Slots", 0);
- int SlotIdx = 0;
- for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
+ // If the window is not created, open it anew:
+ cWindow * Window = GetWindow();
+ if (Window == NULL)
{
- cItem Item;
- Item.FromJson(*itr);
- SetSlot(SlotIdx, Item);
- SlotIdx++;
+ OpenNewWindow();
+ Window = GetWindow();
}
- return true;
-}
-
-
-
-
-
-void cEnderChestEntity::SaveToJson(Json::Value & a_Value)
-{
- a_Value["x"] = m_PosX;
- a_Value["y"] = m_PosY;
- a_Value["z"] = m_PosZ;
-
- Json::Value AllSlots;
- for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--)
+
+ // Open the window for the player:
+ if (Window != NULL)
{
- Json::Value Slot;
- m_Contents.GetSlot(i).GetJson(Slot);
- AllSlots.append(Slot);
+ if (a_Player->GetWindow() != Window)
+ {
+ a_Player->OpenWindow(Window);
+ }
}
- a_Value["Slots"] = AllSlots;
}
-void cEnderChestEntity::SendTo(cClientHandle & a_Client)
+void cEnderChestEntity::OpenNewWindow()
{
- // The chest entity doesn't need anything sent to the client when it's created / gets in the viewdistance
- // All the actual handling is in the cWindow UI code that gets called when the chest is rclked
-
- UNUSED(a_Client);
+ OpenWindow(new cEnderChestWindow(this));
}
-void cEnderChestEntity::UsedBy(cPlayer * a_Player)
+void cEnderChestEntity::LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid)
{
- // If the window is not created, open it anew:
- cWindow * Window = GetWindow();
- if (Window == NULL)
- {
- OpenNewWindow();
- Window = GetWindow();
- }
-
- // Open the window for the player:
- if (Window != NULL)
+ int SlotIdx = 0;
+ for (Json::Value::iterator itr = a_Value.begin(); itr != a_Value.end(); ++itr)
{
- if (a_Player->GetWindow() != Window)
- {
- a_Player->OpenWindow(Window);
- }
+ cItem Item;
+ Item.FromJson(*itr);
+ a_Grid.SetSlot(SlotIdx, Item);
+ SlotIdx++;
}
-
- // This is rather a hack
- // Instead of marking the chunk as dirty upon chest contents change, we mark it dirty now
- // We cannot properly detect contents change, but such a change doesn't happen without a player opening the chest first.
- // The few false positives aren't much to worry about
- int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(m_PosX, m_PosZ, ChunkX, ChunkZ);
- m_World->MarkChunkDirty(ChunkX, ChunkZ);
}
-void cEnderChestEntity::OpenNewWindow(void)
+void cEnderChestEntity::SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid)
{
- OpenWindow(new cEnderChestWindow(this));
+ for (int i = 0; i < a_Grid.GetNumSlots(); i++)
+ {
+ Json::Value Slot;
+ a_Grid.GetSlot(i).GetJson(Slot);
+ a_Value.append(Slot);
+ }
}
diff --git a/src/BlockEntities/EnderChestEntity.h b/src/BlockEntities/EnderChestEntity.h
index 45beee45f..ed178f6fc 100644
--- a/src/BlockEntities/EnderChestEntity.h
+++ b/src/BlockEntities/EnderChestEntity.h
@@ -1,20 +1,9 @@
#pragma once
-#include "BlockEntityWithItems.h"
-
-
-
-
-
-namespace Json
-{
- class Value;
-};
-
-class cClientHandle;
-class cServer;
-class cNBTData;
+#include "BlockEntity.h"
+#include "UI/WindowOwner.h"
+#include "json/json.h"
@@ -22,33 +11,28 @@ class cNBTData;
// tolua_begin
class cEnderChestEntity :
- public cBlockEntityWithItems
+ public cBlockEntity,
+ public cBlockEntityWindowOwner
{
- typedef cBlockEntityWithItems super;
+ typedef cBlockEntity super;
public:
- enum {
- ContentsHeight = 3,
- ContentsWidth = 9,
- } ;
-
// tolua_end
- /// Constructor used for normal operation
cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
-
virtual ~cEnderChestEntity();
static const char * GetClassStatic(void) { return "cEnderChestEntity"; }
-
- bool LoadFromJson(const Json::Value & a_Value);
// cBlockEntity overrides:
- virtual void SaveToJson(Json::Value & a_Value) override;
- virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
+ virtual void SaveToJson(Json::Value & a_Value) override { UNUSED(a_Value); }
+ virtual void SendTo(cClientHandle & a_Client) override { UNUSED(a_Client); }
+
+ static void LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid);
+ static void SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid);
- /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate.
+ /** Opens a new enderchest window for this enderchest */
void OpenNewWindow(void);
} ; // tolua_export
diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h
index da3fe9b7e..89901cf2d 100644
--- a/src/BlockEntities/FlowerPotEntity.h
+++ b/src/BlockEntities/FlowerPotEntity.h
@@ -27,7 +27,7 @@ namespace Json
// tolua_begin
-class cFlowerPotEntity :
+class cFlowerPotEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -39,8 +39,8 @@ public:
/** Creates a new flowerpot entity at the specified block coords. a_World may be NULL */
cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World);
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ bool LoadFromJson( const Json::Value& a_Value);
+ virtual void SaveToJson(Json::Value& a_Value) override;
virtual void Destroy(void) override;
@@ -53,7 +53,7 @@ public:
cItem GetItem(void) const { return m_Item; }
/** Set the item in the flower pot */
- void SetItem(const cItem a_Item) { m_Item = a_Item; }
+ void SetItem(const cItem & a_Item) { m_Item = a_Item; }
// tolua_end
diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp
index 1b1741713..72fd7f2b3 100644
--- a/src/BlockEntities/FurnaceEntity.cpp
+++ b/src/BlockEntities/FurnaceEntity.cpp
@@ -160,7 +160,7 @@ bool cFurnaceEntity::LoadFromJson(const Json::Value & a_Value)
-void cFurnaceEntity::SaveToJson( Json::Value& a_Value )
+void cFurnaceEntity::SaveToJson( Json::Value& a_Value)
{
a_Value["x"] = m_PosX;
a_Value["y"] = m_PosY;
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index 7f001c739..48d3b8dcc 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -157,6 +157,7 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
bool res = false;
switch (a_Chunk.GetBlock(m_RelX, m_PosY + 1, m_RelZ))
{
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
{
// Chests have special handling because of double-chests
@@ -218,7 +219,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
}
Vector3f EntityPos = a_Entity->GetPosition();
- Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
+ Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
double Distance = (EntityPos - BlockPos).Length();
if (Distance < 0.5)
@@ -242,7 +243,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
{
m_bFoundPickupsAbove = true;
m_Contents.SetSlot(i, Item);
- a_Pickup->Destroy(); // Kill pickup
+ a_Pickup->Destroy(); // Kill pickup
return true;
}
@@ -252,11 +253,11 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;
- Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
+ Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
if (Item.IsEmpty())
{
- a_Pickup->Destroy(); // Kill pickup if all items were added
+ a_Pickup->Destroy(); // Kill pickup if all items were added
}
return true;
}
@@ -294,23 +295,24 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
return false;
}
- int bx, by, bz;
+ // Get the coords of the block where to output items:
+ int OutX, OutY, OutZ;
NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
- if (!GetOutputBlockPos(Meta, bx, by, bz))
+ if (!GetOutputBlockPos(Meta, OutX, OutY, OutZ))
{
// Not attached to another container
return false;
}
- if (by < 0)
+ if (OutY < 0)
{
// Cannot output below the zero-th block level
return false;
}
// Convert coords to relative:
- int rx = bx - a_Chunk.GetPosX() * cChunkDef::Width;
- int rz = bz - a_Chunk.GetPosZ() * cChunkDef::Width;
- cChunk * DestChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(rx, rz);
+ int OutRelX = OutX - a_Chunk.GetPosX() * cChunkDef::Width;
+ int OutRelZ = OutZ - a_Chunk.GetPosZ() * cChunkDef::Width;
+ cChunk * DestChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(OutRelX, OutRelZ);
if (DestChunk == NULL)
{
// The destination chunk has been unloaded, don't tick
@@ -319,26 +321,33 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
// Call proper moving function, based on the blocktype present at the coords:
bool res = false;
- switch (DestChunk->GetBlock(rx, by, rz))
+ switch (DestChunk->GetBlock(OutRelX, OutY, OutRelZ))
{
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
{
// Chests have special handling because of double-chests
- res = MoveItemsToChest(*DestChunk, bx, by, bz);
+ res = MoveItemsToChest(*DestChunk, OutX, OutY, OutZ);
break;
}
case E_BLOCK_LIT_FURNACE:
case E_BLOCK_FURNACE:
{
// Furnaces have special handling because of the direction-to-slot relation
- res = MoveItemsToFurnace(*DestChunk, bx, by, bz, Meta);
+ res = MoveItemsToFurnace(*DestChunk, OutX, OutY, OutZ, Meta);
break;
}
case E_BLOCK_DISPENSER:
case E_BLOCK_DROPPER:
case E_BLOCK_HOPPER:
{
- res = MoveItemsToGrid(*(cBlockEntityWithItems *)DestChunk->GetBlockEntity(bx, by, bz));
+ cBlockEntityWithItems * BlockEntity = (cBlockEntityWithItems *)DestChunk->GetBlockEntity(OutX, OutY, OutZ);
+ if (BlockEntity == NULL)
+ {
+ LOGWARNING("%s: A block entity was not found where expected at {%d, %d, %d}", __FUNCTION__, OutX, OutY, OutZ);
+ return false;
+ }
+ res = MoveItemsToGrid(*BlockEntity);
break;
}
}
@@ -359,13 +368,19 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
/// Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
{
- if (MoveItemsFromGrid(*(cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ)))
+ cChestEntity * MainChest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
+ if (MainChest == NULL)
+ {
+ LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
+ return false;
+ }
+ if (MoveItemsFromGrid(*MainChest))
{
// Moved the item from the chest directly above the hopper
return true;
}
- // Check if the chest is a double-chest, if so, try to move from there:
+ // Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there:
static const struct
{
int x, z;
@@ -382,16 +397,29 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
int x = m_RelX + Coords[i].x;
int z = m_RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
- if (
- (Neighbor == NULL) ||
- (Neighbor->GetBlock(x, m_PosY + 1, z) != E_BLOCK_CHEST)
- )
+ if (Neighbor == NULL)
{
continue;
}
- if (MoveItemsFromGrid(*(cChestEntity *)Neighbor->GetBlockEntity(x, m_PosY, z)))
+
+ BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z);
+ if (Block != MainChest->GetBlockType())
{
- return true;
+ // Not the same kind of chest
+ continue;
+ }
+
+ cChestEntity * SideChest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
+ if (SideChest == NULL)
+ {
+ LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
+ }
+ else
+ {
+ if (MoveItemsFromGrid(*SideChest))
+ {
+ return true;
+ }
}
return false;
}
@@ -408,7 +436,11 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
{
cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
- ASSERT(Furnace != NULL);
+ if (Furnace == NULL)
+ {
+ LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
+ return false;
+ }
// Try move from the output slot:
if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsOutput, true))
@@ -517,12 +549,19 @@ bool cHopperEntity::MoveItemsFromSlot(cBlockEntityWithItems & a_Entity, int a_Sl
bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ)
{
// Try the chest directly connected to the hopper:
- if (MoveItemsToGrid(*(cChestEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ)))
+ cChestEntity * Chest = (cChestEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
+ if (Chest == NULL)
+ {
+ LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, a_BlockX, a_BlockY, a_BlockZ);
+ return false;
+ }
+ if (MoveItemsToGrid(*Chest))
{
+ // Chest block directly connected was not full
return true;
}
- // Check if the chest is a double-chest, if so, try to move into the other half:
+ // Check if the chest is a double-chest (chest block directly connected was full), if so, try to move into the other half:
static const struct
{
int x, z;
@@ -534,19 +573,32 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
{0, 1},
{0, -1},
} ;
+ int RelX = a_BlockX - a_Chunk.GetPosX() * cChunkDef::Width;
+ int RelZ = a_BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width;
for (size_t i = 0; i < ARRAYCOUNT(Coords); i++)
{
- int x = m_RelX + Coords[i].x;
- int z = m_RelZ + Coords[i].z;
+ int x = RelX + Coords[i].x;
+ int z = RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
- if (
- (Neighbor == NULL) ||
- (Neighbor->GetBlock(x, m_PosY + 1, z) != E_BLOCK_CHEST)
- )
+ if (Neighbor == NULL)
+ {
+ continue;
+ }
+
+ BLOCKTYPE Block = Neighbor->GetBlock(x, a_BlockY, z);
+ if (Block != Chest->GetBlockType())
+ {
+ // Not the same kind of chest
+ continue;
+ }
+
+ Chest = (cChestEntity *)Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z);
+ if (Chest == NULL)
{
+ LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d} (%d, %d)", __FUNCTION__, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z, x, z);
continue;
}
- if (MoveItemsToGrid(*(cChestEntity *)Neighbor->GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ)))
+ if (MoveItemsToGrid(*Chest))
{
return true;
}
diff --git a/src/BlockEntities/HopperEntity.h b/src/BlockEntities/HopperEntity.h
index 6ef98f43a..8e856fcda 100644
--- a/src/BlockEntities/HopperEntity.h
+++ b/src/BlockEntities/HopperEntity.h
@@ -22,7 +22,8 @@ class cHopperEntity :
typedef cBlockEntityWithItems super;
public:
- enum {
+ enum
+ {
ContentsHeight = 1,
ContentsWidth = 5,
TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper
diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h
index 3d1d604f7..d677d340f 100644
--- a/src/BlockEntities/JukeboxEntity.h
+++ b/src/BlockEntities/JukeboxEntity.h
@@ -19,7 +19,7 @@ namespace Json
// tolua_begin
-class cJukeboxEntity :
+class cJukeboxEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -58,7 +58,7 @@ public:
static const char * GetClassStatic(void) { return "cJukeboxEntity"; }
virtual void UsedBy(cPlayer * a_Player) override;
- virtual void SendTo(cClientHandle &) override { };
+ virtual void SendTo(cClientHandle &) override {}
private:
int m_Record;
diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp
index dc9c18d58..ce895eb6f 100644
--- a/src/BlockEntities/MobHeadEntity.cpp
+++ b/src/BlockEntities/MobHeadEntity.cpp
@@ -70,6 +70,8 @@ void cMobHeadEntity::SetOwner(const AString & a_Owner)
void cMobHeadEntity::SendTo(cClientHandle & a_Client)
{
+ cWorld * World = a_Client.GetPlayer()->GetWorld();
+ a_Client.SendBlockChange(m_PosX, m_PosY, m_PosZ, m_BlockType, World->GetBlockMeta(m_PosX, m_PosY, m_PosZ));
a_Client.SendUpdateBlockEntity(*this);
}
diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h
index 367eb15e7..f91a3cc9e 100644
--- a/src/BlockEntities/MobHeadEntity.h
+++ b/src/BlockEntities/MobHeadEntity.h
@@ -25,7 +25,7 @@ namespace Json
// tolua_begin
-class cMobHeadEntity :
+class cMobHeadEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -37,8 +37,8 @@ public:
/** Creates a new mob head entity at the specified block coords. a_World may be NULL */
cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ bool LoadFromJson( const Json::Value& a_Value);
+ virtual void SaveToJson(Json::Value& a_Value) override;
// tolua_begin
diff --git a/src/BlockEntities/NoteEntity.cpp b/src/BlockEntities/NoteEntity.cpp
index 58b05a324..95145c117 100644
--- a/src/BlockEntities/NoteEntity.cpp
+++ b/src/BlockEntities/NoteEntity.cpp
@@ -91,7 +91,7 @@ void cNoteEntity::MakeSound(void)
// TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all
float calcPitch = pow(2.0f, ((float)m_Pitch - 12.0f) / 12.0f);
- m_World->BroadcastSoundEffect(sampleName, m_PosX * 8, m_PosY * 8, m_PosZ * 8, 3.0f, calcPitch);
+ m_World->BroadcastSoundEffect(sampleName, (double)m_PosX, (double)m_PosY, (double)m_PosZ, 3.0f, calcPitch);
}
diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h
index b698899c0..e8497da3e 100644
--- a/src/BlockEntities/NoteEntity.h
+++ b/src/BlockEntities/NoteEntity.h
@@ -28,7 +28,7 @@ enum ENUM_NOTE_INSTRUMENTS
// tolua_begin
-class cNoteEntity :
+class cNoteEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -52,7 +52,7 @@ public:
// tolua_end
virtual void UsedBy(cPlayer * a_Player) override;
- virtual void SendTo(cClientHandle &) override { };
+ virtual void SendTo(cClientHandle &) override {}
static const char * GetClassStatic(void) { return "cNoteEntity"; }
diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h
index 80c7bbfdf..33af100a4 100644
--- a/src/BlockEntities/SignEntity.h
+++ b/src/BlockEntities/SignEntity.h
@@ -25,7 +25,7 @@ namespace Json
// tolua_begin
-class cSignEntity :
+class cSignEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -37,8 +37,8 @@ public:
/// Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be NULL
cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ bool LoadFromJson( const Json::Value& a_Value);
+ virtual void SaveToJson(Json::Value& a_Value) override;
// tolua_begin
diff --git a/src/BlockID.cpp b/src/BlockID.cpp
index bf95d0798..d145a2e5b 100644
--- a/src/BlockID.cpp
+++ b/src/BlockID.cpp
@@ -102,7 +102,7 @@ public:
return true;
}
- a_Item.m_ItemDamage = atoi(Split[1].c_str());
+ a_Item.m_ItemDamage = (short)atoi(Split[1].c_str());
if ((a_Item.m_ItemDamage == 0) && (Split[1] != "0"))
{
// Parsing the number failed
@@ -255,7 +255,8 @@ AString ItemToFullString(const cItem & a_Item)
int StringToMobType(const AString & a_MobString)
{
- static struct {
+ static struct
+ {
int m_MobType;
const char * m_String;
} MobMap [] =
@@ -286,7 +287,7 @@ int StringToMobType(const AString & a_MobString)
{cMonster::mtMooshroom, "Mooshroom"},
{cMonster::mtSnowGolem, "SnowGolem"},
{cMonster::mtOcelot, "Ocelot"},
- {cMonster::mtIronGolem, "IronGolem"},
+ {cMonster::mtIronGolem, "IronGolem"},
{cMonster::mtVillager, "Villager"},
};
for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++)
@@ -345,6 +346,37 @@ eDimension StringToDimension(const AString & a_DimensionString)
+AString DimensionToString(eDimension a_Dimension)
+{
+ // Decode using a built-in map:
+ static struct
+ {
+ eDimension m_Dimension;
+ const char * m_String;
+ } DimensionMap[] =
+ {
+ { dimOverworld, "Overworld" },
+ { dimNether, "Nether" },
+ { dimEnd, "End" },
+ };
+
+ for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++)
+ {
+ if (DimensionMap[i].m_Dimension == a_Dimension)
+ {
+ return DimensionMap[i].m_String;
+ }
+ } // for i - DimensionMap[]
+
+ // Not found
+ LOGWARNING("Unknown dimension: \"%i\". Setting to Overworld", (int)a_Dimension);
+ return "Overworld";
+}
+
+
+
+
+
/// Translates damage type constant to a string representation (built-in).
AString DamageTypeToString(eDamageType a_DamageType)
{
@@ -363,6 +395,7 @@ AString DamageTypeToString(eDamageType a_DamageType)
case dtLightning: return "dtLightning";
case dtOnFire: return "dtOnFire";
case dtPoisoning: return "dtPoisoning";
+ case dtWithering: return "dtWithering";
case dtPotionOfHarming: return "dtPotionOfHarming";
case dtRangedAttack: return "dtRangedAttack";
case dtStarving: return "dtStarving";
@@ -408,6 +441,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
{ dtCactusContact, "dtCactusContact"},
{ dtLavaContact, "dtLavaContact"},
{ dtPoisoning, "dtPoisoning"},
+ { dtWithering, "dtWithering"},
{ dtOnFire, "dtOnFire"},
{ dtFireContact, "dtFireContact"},
{ dtInVoid, "dtInVoid"},
@@ -433,6 +467,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
{ dtCactusContact, "dtCacti"},
{ dtLavaContact, "dtLava"},
{ dtPoisoning, "dtPoison"},
+ { dtWithering, "dtWither"},
{ dtOnFire, "dtBurning"},
{ dtFireContact, "dtInFire"},
{ dtAdmin, "dtPlugin"},
diff --git a/src/BlockID.h b/src/BlockID.h
index 655c8c712..9334b7310 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -171,12 +171,12 @@ enum ENUM_BLOCK_ID
E_BLOCK_DROPPER = 158,
E_BLOCK_STAINED_CLAY = 159,
E_BLOCK_STAINED_GLASS_PANE = 160,
- E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x
+ E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x
E_BLOCK_NEW_LOG = 162,
E_BLOCK_ACACIA_WOOD_STAIRS = 163,
E_BLOCK_DARK_OAK_WOOD_STAIRS = 164,
E_BLOCK_HAY_BALE = 170,
- E_BLOCK_CARPET = 171,
+ E_BLOCK_CARPET = 171,
E_BLOCK_HARDENED_CLAY = 172,
E_BLOCK_BLOCK_OF_COAL = 173,
E_BLOCK_PACKED_ICE = 174,
@@ -187,7 +187,7 @@ enum ENUM_BLOCK_ID
E_BLOCK_NUMBER_OF_TYPES, ///< Number of individual (different) blocktypes
E_BLOCK_MAX_TYPE_ID = E_BLOCK_NUMBER_OF_TYPES - 1, ///< Maximum BlockType number used
- // Synonym or ID compatibility
+ // Synonym or ID compatibility
E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION,
E_BLOCK_RED_ROSE = E_BLOCK_FLOWER,
E_BLOCK_LOCKED_CHEST = E_BLOCK_STAINED_GLASS,
@@ -319,7 +319,8 @@ enum ENUM_ITEM_ID
E_ITEM_GHAST_TEAR = 370,
E_ITEM_GOLD_NUGGET = 371,
E_ITEM_NETHER_WART = 372,
- E_ITEM_POTIONS = 373,
+ E_ITEM_POTION = 373,
+ E_ITEM_POTIONS = 373, // OBSOLETE, use E_ITEM_POTION instead
E_ITEM_GLASS_BOTTLE = 374,
E_ITEM_SPIDER_EYE = 375,
E_ITEM_FERMENTED_SPIDER_EYE = 376,
@@ -398,7 +399,7 @@ enum
// Please keep this list alpha-sorted by the blocktype / itemtype part
// then number-sorted for the same block / item
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// Block metas:
// E_BLOCK_ANVIL metas
@@ -784,7 +785,7 @@ enum
E_META_WOOL_RED = 14,
E_META_WOOL_BLACK = 15,
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// Item metas:
// E_ITEM_COAL metas:
@@ -897,6 +898,7 @@ enum eDimension
dimNether = -1,
dimOverworld = 0,
dimEnd = 1,
+ dimNotSet = 255, // For things that need an "indeterminate" state, such as cProtocol's LastSentDimension
} ;
@@ -917,6 +919,7 @@ enum eDamageType
dtCactusContact, // Contact with a cactus block
dtLavaContact, // Contact with a lava block
dtPoisoning, // Having the poison effect
+ dtWithering, // Having the wither effect
dtOnFire, // Being on fire
dtFireContact, // Standing inside a fire block
dtInVoid, // Falling into the Void (Y < 0)
@@ -943,6 +946,7 @@ enum eDamageType
dtCacti = dtCactusContact,
dtLava = dtLavaContact,
dtPoison = dtPoisoning,
+ dtWither = dtWithering,
dtBurning = dtOnFire,
dtInFire = dtFireContact,
dtPlugin = dtAdmin,
@@ -1023,9 +1027,14 @@ extern AString ItemToFullString(const cItem & a_Item);
/// Translates a mob string ("ocelot") to mobtype (E_ENTITY_TYPE_OCELOT)
extern int StringToMobType(const AString & a_MobString);
-/// Translates a dimension string to dimension enum. Takes either a number or a dimension alias (built-in). Returns -1000 on failure
+/// Translates a dimension string to dimension enum. Takes either a number or a dimension alias (built-in). Returns dimOverworld on failure
extern eDimension StringToDimension(const AString & a_DimensionString);
+/** Translates a dimension enum to dimension string.
+Takes an eDimension enum value and returns "Overworld" on failure
+*/
+extern AString DimensionToString(eDimension a_Dimension);
+
/// Translates damage type constant to a string representation (built-in).
extern AString DamageTypeToString(eDamageType a_DamageType);
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index 6fb5aa5b3..602deb26d 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -8,20 +8,13 @@
-cBlockInfo cBlockInfo::ms_Info[256];
-
-
-
-
-
cBlockInfo::cBlockInfo()
: m_LightValue(0x00)
, m_SpreadLightFalloff(0x0f)
, m_Transparent(false)
, m_OneHitDig(false)
, m_PistonBreakable(false)
- , m_IsSnowable(true)
- , m_RequiresSpecialTool(false)
+ , m_IsSnowable(false)
, m_IsSolid(true)
, m_FullyOccupiesVoxel(false)
, m_Handler(NULL)
@@ -34,14 +27,25 @@ cBlockInfo::cBlockInfo()
cBlockInfo::~cBlockInfo()
{
delete m_Handler;
+ m_Handler = NULL;
}
+/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
+It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
+It works only if it is called for the first time before the app spawns other threads. */
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
{
+ static cBlockInfo ms_Info[256];
+ static bool IsBlockInfoInitialized = false;
+ if (!IsBlockInfoInitialized)
+ {
+ cBlockInfo::Initialize(ms_Info);
+ IsBlockInfoInitialized = true;
+ }
return ms_Info[a_Type];
}
@@ -49,403 +53,503 @@ cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
-void cBlockInfo::Initialize(void)
+void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
{
for (unsigned int i = 0; i < 256; ++i)
{
- if (ms_Info[i].m_Handler == NULL)
+ if (a_Info[i].m_Handler == NULL)
{
- ms_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i);
+ a_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i);
}
}
// Emissive blocks
- ms_Info[E_BLOCK_FIRE ].m_LightValue = 15;
- ms_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15;
- ms_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15;
- ms_Info[E_BLOCK_LAVA ].m_LightValue = 15;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15;
- ms_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15;
- ms_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15;
- ms_Info[E_BLOCK_TORCH ].m_LightValue = 14;
- ms_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13;
- ms_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11;
- ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7;
- ms_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1;
- ms_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1;
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_LightValue = 9;
+ a_Info[E_BLOCK_BEACON ].m_LightValue = 15;
+ a_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1;
+ a_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13;
+ a_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1;
+ a_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15;
+ a_Info[E_BLOCK_END_PORTAL_FRAME ].m_LightValue = 1;
+ a_Info[E_BLOCK_ENDER_CHEST ].m_LightValue = 7;
+ a_Info[E_BLOCK_FIRE ].m_LightValue = 15;
+ a_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15;
+ a_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15;
+ a_Info[E_BLOCK_LAVA ].m_LightValue = 15;
+ a_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11;
+ a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15;
+ a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15;
+ a_Info[E_BLOCK_TORCH ].m_LightValue = 14;
// Spread blocks
- ms_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_GLOWSTONE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ANVIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BEACON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BED ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BREWING_STAND ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CACTUS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CARPET ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CARROTS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CAULDRON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_COBBLESTONE_WALL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_COCOA_POD ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DANDELION ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DAYLIGHT_SENSOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DEAD_BUSH ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DETECTOR_RAIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DRAGON_EGG ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ENDER_CHEST ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_END_PORTAL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_END_PORTAL_FRAME ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FARMLAND ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FLOWER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FLOWER_POT ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_HEAD ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_HOPPER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ICE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LADDER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LEVER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LILY_PAD ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_MELON_STEM ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_MOB_SPAWNER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_NETHER_PORTAL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_NETHER_WART ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_PISTON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_PISTON_EXTENSION ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_POTATOES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_POWERED_RAIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_PUMPKIN_STEM ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_RAIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_SAPLING ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_SNOW ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STAINED_GLASS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STICKY_PISTON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STONE_BUTTON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STONE_SLAB ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_SUGARCANE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TALL_GRASS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TRAPDOOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TRAPPED_CHEST ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TRIPWIRE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WOODEN_BUTTON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WOODEN_SLAB ].m_SpreadLightFalloff = 1;
// Light in water and lava dissapears faster:
- ms_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_SpreadLightFalloff = 3;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_SpreadLightFalloff = 3;
- ms_Info[E_BLOCK_WATER ].m_SpreadLightFalloff = 3;
+ a_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_SpreadLightFalloff = 3;
+ a_Info[E_BLOCK_STATIONARY_WATER ].m_SpreadLightFalloff = 3;
+ a_Info[E_BLOCK_WATER ].m_SpreadLightFalloff = 3;
// Transparent blocks
- ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true;
- ms_Info[E_BLOCK_AIR ].m_Transparent = true;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true;
- ms_Info[E_BLOCK_CARROTS ].m_Transparent = true;
- ms_Info[E_BLOCK_CHEST ].m_Transparent = true;
- ms_Info[E_BLOCK_COBWEB ].m_Transparent = true;
- ms_Info[E_BLOCK_CROPS ].m_Transparent = true;
- ms_Info[E_BLOCK_DANDELION ].m_Transparent = true;
- ms_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true;
- ms_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true;
- ms_Info[E_BLOCK_FENCE ].m_Transparent = true;
- ms_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true;
- ms_Info[E_BLOCK_FIRE ].m_Transparent = true;
- ms_Info[E_BLOCK_FLOWER ].m_Transparent = true;
- ms_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true;
- ms_Info[E_BLOCK_GLASS ].m_Transparent = true;
- ms_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true;
- ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
- ms_Info[E_BLOCK_ICE ].m_Transparent = true;
- ms_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true;
- ms_Info[E_BLOCK_LAVA ].m_Transparent = true;
- ms_Info[E_BLOCK_LEAVES ].m_Transparent = true;
- ms_Info[E_BLOCK_LEVER ].m_Transparent = true;
- ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
- ms_Info[E_BLOCK_MELON_STEM ].m_Transparent = true;
- ms_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true;
- ms_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
- ms_Info[E_BLOCK_POTATOES ].m_Transparent = true;
- ms_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true;
- ms_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true;
- ms_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true;
- ms_Info[E_BLOCK_RAIL ].m_Transparent = true;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true;
- ms_Info[E_BLOCK_SIGN_POST ].m_Transparent = true;
- ms_Info[E_BLOCK_SNOW ].m_Transparent = true;
- ms_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true;
- ms_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
- ms_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
- ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true;
- ms_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
- ms_Info[E_BLOCK_TORCH ].m_Transparent = true;
- ms_Info[E_BLOCK_VINES ].m_Transparent = true;
- ms_Info[E_BLOCK_WALLSIGN ].m_Transparent = true;
- ms_Info[E_BLOCK_WATER ].m_Transparent = true;
- ms_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true;
- ms_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true;
- ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true;
-
- // TODO: Any other transparent blocks?
+ a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_Transparent = true;
+ a_Info[E_BLOCK_AIR ].m_Transparent = true;
+ a_Info[E_BLOCK_ANVIL ].m_Transparent = true;
+ a_Info[E_BLOCK_BEACON ].m_Transparent = true;
+ a_Info[E_BLOCK_BED ].m_Transparent = true;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true;
+ a_Info[E_BLOCK_BREWING_STAND ].m_Transparent = true;
+ a_Info[E_BLOCK_CACTUS ].m_Transparent = true;
+ a_Info[E_BLOCK_CAKE ].m_Transparent = true;
+ a_Info[E_BLOCK_CARPET ].m_Transparent = true;
+ a_Info[E_BLOCK_CARROTS ].m_Transparent = true;
+ a_Info[E_BLOCK_CAULDRON ].m_Transparent = true;
+ a_Info[E_BLOCK_CHEST ].m_Transparent = true;
+ a_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true;
+ a_Info[E_BLOCK_COCOA_POD ].m_Transparent = true;
+ a_Info[E_BLOCK_COBWEB ].m_Transparent = true;
+ a_Info[E_BLOCK_CROPS ].m_Transparent = true;
+ a_Info[E_BLOCK_DANDELION ].m_Transparent = true;
+ a_Info[E_BLOCK_DAYLIGHT_SENSOR ].m_Transparent = true;
+ a_Info[E_BLOCK_DEAD_BUSH ].m_Transparent = true;
+ a_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_DRAGON_EGG ].m_Transparent = true;
+ a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_Transparent = true;
+ a_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true;
+ a_Info[E_BLOCK_END_PORTAL ].m_Transparent = true;
+ a_Info[E_BLOCK_END_PORTAL_FRAME ].m_Transparent = true;
+ a_Info[E_BLOCK_FARMLAND ].m_Transparent = true;
+ a_Info[E_BLOCK_FENCE ].m_Transparent = true;
+ a_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true;
+ a_Info[E_BLOCK_FIRE ].m_Transparent = true;
+ a_Info[E_BLOCK_FLOWER ].m_Transparent = true;
+ a_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true;
+ a_Info[E_BLOCK_GLASS ].m_Transparent = true;
+ a_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true;
+ a_Info[E_BLOCK_HEAD ].m_Transparent = true;
+ a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_HOPPER ].m_Transparent = true;
+ a_Info[E_BLOCK_ICE ].m_Transparent = true;
+ a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_Transparent = true;
+ a_Info[E_BLOCK_IRON_BARS ].m_Transparent = true;
+ a_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true;
+ a_Info[E_BLOCK_LADDER ].m_Transparent = true;
+ a_Info[E_BLOCK_LAVA ].m_Transparent = true;
+ a_Info[E_BLOCK_LEAVES ].m_Transparent = true;
+ a_Info[E_BLOCK_LEVER ].m_Transparent = true;
+ a_Info[E_BLOCK_LILY_PAD ].m_Transparent = true;
+ a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_MELON_STEM ].m_Transparent = true;
+ a_Info[E_BLOCK_MOB_SPAWNER ].m_Transparent = true;
+ a_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true;
+ a_Info[E_BLOCK_NETHER_PORTAL ].m_Transparent = true;
+ a_Info[E_BLOCK_NETHER_WART ].m_Transparent = true;
+ a_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
+ a_Info[E_BLOCK_PISTON ].m_Transparent = true;
+ a_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true;
+ a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_Transparent = true;
+ a_Info[E_BLOCK_POTATOES ].m_Transparent = true;
+ a_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true;
+ a_Info[E_BLOCK_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_Transparent = true;
+ a_Info[E_BLOCK_SAPLING ].m_Transparent = true;
+ a_Info[E_BLOCK_SIGN_POST ].m_Transparent = true;
+ a_Info[E_BLOCK_SNOW ].m_Transparent = true;
+ a_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true;
+ a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true;
+ a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
+ a_Info[E_BLOCK_STICKY_PISTON ].m_Transparent = true;
+ a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
+ a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_STONE_SLAB ].m_Transparent = true;
+ a_Info[E_BLOCK_SUGARCANE ].m_Transparent = true;
+ a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
+ a_Info[E_BLOCK_TORCH ].m_Transparent = true;
+ a_Info[E_BLOCK_TRAPDOOR ].m_Transparent = true;
+ a_Info[E_BLOCK_TRAPPED_CHEST ].m_Transparent = true;
+ a_Info[E_BLOCK_TRIPWIRE ].m_Transparent = true;
+ a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_Transparent = true;
+ a_Info[E_BLOCK_VINES ].m_Transparent = true;
+ a_Info[E_BLOCK_WALLSIGN ].m_Transparent = true;
+ a_Info[E_BLOCK_WATER ].m_Transparent = true;
+ a_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true;
+ a_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true;
+ a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_WOODEN_SLAB ].m_Transparent = true;
// One hit break blocks:
- ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_OneHitDig = true;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_OneHitDig = true;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_OneHitDig = true;
- ms_Info[E_BLOCK_CARROTS ].m_OneHitDig = true;
- ms_Info[E_BLOCK_CROPS ].m_OneHitDig = true;
- ms_Info[E_BLOCK_DANDELION ].m_OneHitDig = true;
- ms_Info[E_BLOCK_FIRE ].m_OneHitDig = true;
- ms_Info[E_BLOCK_FLOWER ].m_OneHitDig = true;
- ms_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true;
- ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true;
- ms_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true;
- ms_Info[E_BLOCK_POTATOES ].m_OneHitDig = true;
- ms_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_WIRE ].m_OneHitDig = true;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_OneHitDig = true;
- ms_Info[E_BLOCK_REEDS ].m_OneHitDig = true;
- ms_Info[E_BLOCK_SAPLING ].m_OneHitDig = true;
- ms_Info[E_BLOCK_TNT ].m_OneHitDig = true;
- ms_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true;
- ms_Info[E_BLOCK_TORCH ].m_OneHitDig = true;
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_OneHitDig = true;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_OneHitDig = true;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_OneHitDig = true;
+ a_Info[E_BLOCK_CARROTS ].m_OneHitDig = true;
+ a_Info[E_BLOCK_CROPS ].m_OneHitDig = true;
+ a_Info[E_BLOCK_DANDELION ].m_OneHitDig = true;
+ a_Info[E_BLOCK_DEAD_BUSH ].m_OneHitDig = true;
+ a_Info[E_BLOCK_FIRE ].m_OneHitDig = true;
+ a_Info[E_BLOCK_FLOWER ].m_OneHitDig = true;
+ a_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true;
+ a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true;
+ a_Info[E_BLOCK_LILY_PAD ].m_OneHitDig = true;
+ a_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true;
+ a_Info[E_BLOCK_POTATOES ].m_OneHitDig = true;
+ a_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_OneHitDig = true;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_OneHitDig = true;
+ a_Info[E_BLOCK_REEDS ].m_OneHitDig = true;
+ a_Info[E_BLOCK_SAPLING ].m_OneHitDig = true;
+ a_Info[E_BLOCK_TNT ].m_OneHitDig = true;
+ a_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true;
+ a_Info[E_BLOCK_TORCH ].m_OneHitDig = true;
+ a_Info[E_BLOCK_TRIPWIRE ].m_OneHitDig = true;
// Blocks that break when pushed by piston:
- ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_AIR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_BED ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_CROPS ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_FIRE ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
- ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
- ms_Info[E_BLOCK_LADDER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_LAVA ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_LEVER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_MELON ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REEDS ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_SNOW ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_STONE_BUTTON ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true;
- ms_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_TORCH ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_VINES ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_WATER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true;
-
-
- // Blocks that cannot be snowed over:
- ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_IsSnowable = false;
- ms_Info[E_BLOCK_AIR ].m_IsSnowable = false;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_IsSnowable = false;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSnowable = false;
- ms_Info[E_BLOCK_CACTUS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_CHEST ].m_IsSnowable = false;
- ms_Info[E_BLOCK_CROPS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_DANDELION ].m_IsSnowable = false;
- ms_Info[E_BLOCK_FIRE ].m_IsSnowable = false;
- ms_Info[E_BLOCK_FLOWER ].m_IsSnowable = false;
- ms_Info[E_BLOCK_GLASS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_ICE ].m_IsSnowable = false;
- ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_IsSnowable = false;
- ms_Info[E_BLOCK_LAVA ].m_IsSnowable = false;
- ms_Info[E_BLOCK_LILY_PAD ].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSnowable = false;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_IsSnowable = false;
- ms_Info[E_BLOCK_REEDS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_SAPLING ].m_IsSnowable = false;
- ms_Info[E_BLOCK_SIGN_POST ].m_IsSnowable = false;
- ms_Info[E_BLOCK_SNOW ].m_IsSnowable = false;
- ms_Info[E_BLOCK_STAINED_GLASS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_STAINED_GLASS_PANE ].m_IsSnowable = false;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSnowable = false;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_IsSnowable = false;
- ms_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_TNT ].m_IsSnowable = false;
- ms_Info[E_BLOCK_TORCH ].m_IsSnowable = false;
- ms_Info[E_BLOCK_VINES ].m_IsSnowable = false;
- ms_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false;
- ms_Info[E_BLOCK_WATER ].m_IsSnowable = false;
- ms_Info[E_BLOCK_RAIL ].m_IsSnowable = false;
- ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSnowable = false;
- ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false;
- ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false;
- ms_Info[E_BLOCK_COBWEB ].m_IsSnowable = false;
-
-
- // Blocks that don't drop without a special tool:
- ms_Info[E_BLOCK_BRICK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_DIAMOND_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_IRON_BLOCK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_NETHER_BRICK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_OBSIDIAN ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_REDSTONE_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_SANDSTONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_SANDSTONE_STAIRS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_SNOW ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE_BRICKS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true;
-
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_AIR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_BED ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_CACTUS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_CAKE ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_CARROTS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_COCOA_POD ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_CROPS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_DRAGON_EGG ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_FIRE ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_FLOWER_POT ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_HEAD ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
+ a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LILY_PAD ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LADDER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LAVA ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LEVER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_MELON ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_NETHER_WART ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_POTATOES ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REEDS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_SAPLING ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_SIGN_POST ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_SNOW ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_STONE_BUTTON ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TORCH ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TRAPDOOR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TRIPWIRE ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_VINES ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WALLSIGN ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WATER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true;
+
+
+ // Blocks that can be snowed over:
+ a_Info[E_BLOCK_BEDROCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_BLOCK_OF_COAL ].m_IsSnowable = true;
+ a_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_BOOKCASE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_BRICK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_CLAY ].m_IsSnowable = true;
+ a_Info[E_BLOCK_CRAFTING_TABLE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_COAL_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_COMMAND_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_COBBLESTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DIAMOND_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DIAMOND_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DIRT ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DISPENSER ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DROPPER ].m_IsSnowable = true;
+ a_Info[E_BLOCK_EMERALD_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_EMERALD_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_END_STONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_FURNACE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GLOWSTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GOLD_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GOLD_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GRASS ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GRAVEL ].m_IsSnowable = true;
+ a_Info[E_BLOCK_HARDENED_CLAY ].m_IsSnowable = true;
+ a_Info[E_BLOCK_HAY_BALE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_IsSnowable = true;
+ a_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_IsSnowable = true;
+ a_Info[E_BLOCK_IRON_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_IRON_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_JACK_O_LANTERN ].m_IsSnowable = true;
+ a_Info[E_BLOCK_JUKEBOX ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LAPIS_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LAPIS_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LEAVES ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LIT_FURNACE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LOG ].m_IsSnowable = true;
+ a_Info[E_BLOCK_MELON ].m_IsSnowable = true;
+ a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_MYCELIUM ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NETHER_BRICK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NETHERRACK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NEW_LEAVES ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NEW_LOG ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NOTE_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_OBSIDIAN ].m_IsSnowable = true;
+ a_Info[E_BLOCK_PLANKS ].m_IsSnowable = true;
+ a_Info[E_BLOCK_PUMPKIN ].m_IsSnowable = true;
+ a_Info[E_BLOCK_QUARTZ_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_IsSnowable = true;
+ a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_IsSnowable = true;
+ a_Info[E_BLOCK_REDSTONE_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_IsSnowable = true;
+ a_Info[E_BLOCK_SAND ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SANDSTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SILVERFISH_EGG ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SNOW_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SOULSAND ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SPONGE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_STAINED_CLAY ].m_IsSnowable = true;
+ a_Info[E_BLOCK_STONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_STONE_BRICKS ].m_IsSnowable = true;
+ a_Info[E_BLOCK_TNT ].m_IsSnowable = true;
+ a_Info[E_BLOCK_WOOL ].m_IsSnowable = true;
// Nonsolid blocks:
- ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
- ms_Info[E_BLOCK_AIR ].m_IsSolid = false;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false;
- ms_Info[E_BLOCK_CARROTS ].m_IsSolid = false;
- ms_Info[E_BLOCK_COBWEB ].m_IsSolid = false;
- ms_Info[E_BLOCK_CROPS ].m_IsSolid = false;
- ms_Info[E_BLOCK_DANDELION ].m_IsSolid = false;
- ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false;
- ms_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false;
- ms_Info[E_BLOCK_FIRE ].m_IsSolid = false;
- ms_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
- ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
- ms_Info[E_BLOCK_LAVA ].m_IsSolid = false;
- ms_Info[E_BLOCK_LEVER ].m_IsSolid = false;
- ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
- ms_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false;
- ms_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false;
- ms_Info[E_BLOCK_PISTON_EXTENSION ].m_IsSolid = false;
- ms_Info[E_BLOCK_POTATOES ].m_IsSolid = false;
- ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false;
- ms_Info[E_BLOCK_RAIL ].m_IsSolid = false;
- ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false;
- ms_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false;
- ms_Info[E_BLOCK_REEDS ].m_IsSolid = false;
- ms_Info[E_BLOCK_SAPLING ].m_IsSolid = false;
- ms_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false;
- ms_Info[E_BLOCK_SNOW ].m_IsSolid = false;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false;
- ms_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false;
- ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false;
- ms_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false;
- ms_Info[E_BLOCK_TORCH ].m_IsSolid = false;
- ms_Info[E_BLOCK_TRIPWIRE ].m_IsSolid = false;
- ms_Info[E_BLOCK_VINES ].m_IsSolid = false;
- ms_Info[E_BLOCK_WALLSIGN ].m_IsSolid = false;
- ms_Info[E_BLOCK_WATER ].m_IsSolid = false;
- ms_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false;
- ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false;
- ms_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false;
+ a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
+ a_Info[E_BLOCK_AIR ].m_IsSolid = false;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false;
+ a_Info[E_BLOCK_CAKE ].m_IsSolid = false;
+ a_Info[E_BLOCK_CARROTS ].m_IsSolid = false;
+ a_Info[E_BLOCK_COBWEB ].m_IsSolid = false;
+ a_Info[E_BLOCK_CROPS ].m_IsSolid = false;
+ a_Info[E_BLOCK_DANDELION ].m_IsSolid = false;
+ a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false;
+ a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false;
+ a_Info[E_BLOCK_FIRE ].m_IsSolid = false;
+ a_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
+ a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
+ a_Info[E_BLOCK_LAVA ].m_IsSolid = false;
+ a_Info[E_BLOCK_LEVER ].m_IsSolid = false;
+ a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
+ a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false;
+ a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false;
+ a_Info[E_BLOCK_POTATOES ].m_IsSolid = false;
+ a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false;
+ a_Info[E_BLOCK_RAIL ].m_IsSolid = false;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false;
+ a_Info[E_BLOCK_REEDS ].m_IsSolid = false;
+ a_Info[E_BLOCK_SAPLING ].m_IsSolid = false;
+ a_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false;
+ a_Info[E_BLOCK_SNOW ].m_IsSolid = false;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false;
+ a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false;
+ a_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false;
+ a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false;
+ a_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false;
+ a_Info[E_BLOCK_TORCH ].m_IsSolid = false;
+ a_Info[E_BLOCK_TRIPWIRE ].m_IsSolid = false;
+ a_Info[E_BLOCK_VINES ].m_IsSolid = false;
+ a_Info[E_BLOCK_WALLSIGN ].m_IsSolid = false;
+ a_Info[E_BLOCK_WATER ].m_IsSolid = false;
+ a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false;
+ a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false;
// Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things:
- ms_Info[E_BLOCK_NEW_LOG ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BEDROCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BLOCK_OF_COAL ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BOOKCASE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BRICK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_CLAY ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_COAL_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_COBBLESTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_COMMAND_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_CRAFTING_TABLE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DIAMOND_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DIAMOND_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DIRT ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DISPENSER ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DROPPER ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_EMERALD_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_EMERALD_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_END_STONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_FURNACE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GLOWSTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GOLD_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GOLD_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GRASS ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GRAVEL ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_HARDENED_CLAY ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_HAY_BALE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_ICE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_IRON_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_IRON_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_JACK_O_LANTERN ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_JUKEBOX ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_LAPIS_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_LAPIS_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_LOG ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_MELON ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_MYCELIUM ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_NETHERRACK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_NETHER_BRICK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_NOTE_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_OBSIDIAN ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_PACKED_ICE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_PLANKS ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_PUMPKIN ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_QUARTZ_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_REDSTONE_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_SANDSTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_SAND ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NEW_LOG ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BEDROCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BLOCK_OF_COAL ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BOOKCASE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BRICK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_CLAY ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_COAL_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_COBBLESTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_COMMAND_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_CRAFTING_TABLE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DIAMOND_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DIAMOND_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DIRT ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DISPENSER ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DROPPER ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_EMERALD_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_EMERALD_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_END_STONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_FURNACE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GLOWSTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GOLD_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GOLD_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GRASS ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GRAVEL ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_HARDENED_CLAY ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_HAY_BALE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_ICE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_IRON_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_IRON_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_JACK_O_LANTERN ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_JUKEBOX ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_LAPIS_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_LAPIS_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_LOG ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_MELON ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_MYCELIUM ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NETHERRACK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NETHER_BRICK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NOTE_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_OBSIDIAN ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_PACKED_ICE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_PLANKS ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_PUMPKIN ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_QUARTZ_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_REDSTONE_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_SANDSTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_SAND ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true;
}
-
-// This is actually just some code that needs to run at program startup, so it is wrapped into a global var's constructor:
-class cBlockInfoInitializer
-{
-public:
- cBlockInfoInitializer(void)
- {
- cBlockInfo::Initialize();
- }
-} BlockInfoInitializer;
-
-
-
-
-
diff --git a/src/BlockInfo.h b/src/BlockInfo.h
index 40c1db867..e6ce566c5 100644
--- a/src/BlockInfo.h
+++ b/src/BlockInfo.h
@@ -16,18 +16,8 @@ class cBlockHandler;
class cBlockInfo
{
public:
- // tolua_end
-
- cBlockInfo();
-
- ~cBlockInfo();
-
- /** (Re-)Initializes the internal BlockInfo structures. */
- static void Initialize(void);
- // tolua_begin
-
- /** Returns the associated BlockInfo structure. */
+ /** Returns the associated BlockInfo structure for the specified block type. */
static cBlockInfo & Get(BLOCKTYPE a_Type);
@@ -49,9 +39,6 @@ public:
/** Can this block hold snow atop? */
bool m_IsSnowable;
- /** Does this block require a tool to drop? */
- bool m_RequiresSpecialTool;
-
/** Is this block solid (player cannot walk through)? */
bool m_IsSolid;
@@ -71,7 +58,6 @@ public:
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 IsSnowable (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSnowable; }
- inline static bool RequiresSpecialTool (BLOCKTYPE a_Type) { return Get(a_Type).m_RequiresSpecialTool; }
inline static bool IsSolid (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSolid; }
inline static bool FullyOccupiesVoxel (BLOCKTYPE a_Type) { return Get(a_Type).m_FullyOccupiesVoxel; }
@@ -79,14 +65,19 @@ public:
inline static cBlockHandler * GetHandler (BLOCKTYPE a_Type) { return Get(a_Type).m_Handler; }
-
protected:
+ /** Storage for all the BlockInfo structures. */
+ typedef cBlockInfo cBlockInfoArray[256];
- // TODO xdot: Change to std::vector to support dynamic block IDs
- static cBlockInfo ms_Info[256];
+ /** Creates a default BlockInfo structure, initializes all values to their defaults */
+ cBlockInfo();
+ /** Cleans up the stored values */
+ ~cBlockInfo();
-}; // tolua_export
+ /** Initializes the specified BlockInfo structures with block-specific values. */
+ static void Initialize(cBlockInfoArray & a_BlockInfos);
+}; // tolua_export
diff --git a/src/BlockTracer.h b/src/BlockTracer.h
index a18c8df4d..c569b4ec6 100644
--- a/src/BlockTracer.h
+++ b/src/BlockTracer.h
@@ -39,13 +39,13 @@ public:
/** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded
When this callback returns true, the tracing is aborted.
*/
- virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace)
- {
+ virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace)
+ {
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
UNUSED(a_EntryFace);
- return false;
+ return false;
}
/** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height)
@@ -54,8 +54,8 @@ public:
Note that some paths can go out of the world and come back again (parabola),
in such a case this callback is followed by OnIntoWorld() and further OnNextBlock() calls
*/
- virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
- {
+ virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
+ {
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
@@ -68,12 +68,12 @@ public:
Note that some paths can go out of the world and come back again (parabola),
in such a case this callback is followed by further OnNextBlock() calls
*/
- virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
- {
+ virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
+ {
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
- return false;
+ return false;
}
/** Called when the path is sure not to hit any more blocks.
diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h
index 93a796ef7..5c4661c11 100644
--- a/src/Blocks/BlockAnvil.h
+++ b/src/Blocks/BlockAnvil.h
@@ -23,11 +23,18 @@ public:
{
a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2));
}
+
+
+ virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
+ {
+ cWindow * Window = new cAnvilWindow(a_BlockX, a_BlockY, a_BlockZ);
+ a_Player->OpenWindow(Window);
+ }
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp
index 6a3c6a55b..cd5783f58 100644
--- a/src/Blocks/BlockBed.cpp
+++ b/src/Blocks/BlockBed.cpp
@@ -15,7 +15,7 @@ void cBlockBedHandler::OnPlacedByPlayer(
if (a_BlockMeta < 8)
{
Vector3i Direction = MetaDataToDirection(a_BlockMeta);
- a_ChunkInterface.SetBlock(a_WorldInterface,a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8);
+ a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8);
}
}
@@ -27,8 +27,8 @@ void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInt
{
NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ );
- Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 );
+ Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ);
+ Vector3i Direction = MetaDataToDirection( OldMeta & 0x7);
if (OldMeta & 0x8)
{
// Was pillow
@@ -108,7 +108,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
if (Meta & 0x4)
{
- a_Player->SendMessageFailure("This bed is occupied.");
+ a_Player->SendMessageFailure("This bed is occupied");
}
else
{
@@ -116,23 +116,25 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
if (Meta & 0x8)
{
- // Is pillow
+ // Is pillow
a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ);
}
else
{
// Is foot end
- VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken
+ VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken
PillowDirection = MetaDataToDirection(Meta & 0x7);
- if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
+ if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
{
a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z);
}
}
- a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit
a_Player->SetIsInBed(true);
+ a_Player->SetBedPos(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
+ a_Player->SendMessageSuccess("Home position set successfully");
cTimeFastForwardTester Tester;
if (a_WorldInterface.ForEachPlayer(Tester))
@@ -140,9 +142,9 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
cPlayerBedStateUnsetter Unsetter(Vector3i(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z), a_WorldInterface);
a_WorldInterface.ForEachPlayer(Unsetter);
a_WorldInterface.SetTimeOfDay(0);
- a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset
}
- }
+ }
}
else
{
diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h
index 92804aaac..bf9d9c01d 100644
--- a/src/Blocks/BlockBed.h
+++ b/src/Blocks/BlockBed.h
@@ -16,7 +16,7 @@ class cBlockBedHandler :
{
public:
cBlockBedHandler(BLOCKTYPE a_BlockType)
- : cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01,true>(a_BlockType)
+ : cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType)
{
}
@@ -39,6 +39,13 @@ public:
}
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
+ {
+ return true;
+ }
+
+
+
// Bed specific helper functions
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h
index 39fd3cac8..0b6ac9d8a 100644
--- a/src/Blocks/BlockBigFlower.h
+++ b/src/Blocks/BlockBigFlower.h
@@ -19,16 +19,16 @@ public:
}
- virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
if (Meta & 0x8)
{
- super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ);
+ super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_CanDrop, a_DropVerbatim);
}
else
{
- super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ);
+ super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop, a_DropVerbatim);
}
}
@@ -86,8 +86,8 @@ public:
virtual void OnPlacedByPlayer(
- cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
) override
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index 4b2f6f618..3b45afff8 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -23,7 +23,8 @@ public:
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x08);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
- a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
+ a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
+ a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
// Queue a button reset (unpress)
a_ChunkInterface.QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07), m_BlockType == E_BLOCK_STONE_BUTTON ? 20 : 30, m_BlockType, a_WorldInterface);
@@ -45,7 +46,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -73,7 +74,7 @@ public:
default:
{
ASSERT(!"Unhandled block face!");
- return 0x0; // No idea, give a special meta (button in centre of block)
+ return 0x0; // No idea, give a special meta (button in centre of block)
}
}
}
@@ -102,7 +103,7 @@ public:
AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
- return (a_RelY > 0) && (cBlockInfo::IsSolid(BlockIsOn));
+ return (a_RelY > 0) && (cBlockInfo::FullyOccupiesVoxel(BlockIsOn));
}
} ;
diff --git a/src/Blocks/BlockCarpet.h b/src/Blocks/BlockCarpet.h
index 33dc1da6c..d1aa52687 100644
--- a/src/Blocks/BlockCarpet.h
+++ b/src/Blocks/BlockCarpet.h
@@ -32,7 +32,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h
index 41b79b6c3..e0f86f4cb 100644
--- a/src/Blocks/BlockCauldron.h
+++ b/src/Blocks/BlockCauldron.h
@@ -58,6 +58,24 @@ public:
{
return true;
}
+
+ virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
+ {
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ if (!a_WorldInterface.IsWeatherWetAt(BlockX, BlockZ) || (a_RelY != a_WorldInterface.GetHeight(BlockX, BlockZ)))
+ {
+ // It's not raining at our current location or we do not have a direct view of the sky
+ // We cannot eat the rain :(
+ return;
+ }
+
+ NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
+ if (Meta < 3)
+ {
+ a_Chunk.SetMeta(a_RelX, a_RelY, a_RelZ, Meta + 1);
+ }
+ }
} ;
diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h
index c9a769c75..28adbed4f 100644
--- a/src/Blocks/BlockChest.h
+++ b/src/Blocks/BlockChest.h
@@ -22,7 +22,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -44,16 +44,16 @@ public:
}
double yaw = a_Player->GetYaw();
if (
- (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(0, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(2, 0, 1) == m_BlockType)
)
{
a_BlockMeta = ((yaw >= -90) && (yaw < 90)) ? 2 : 3;
return true;
}
if (
- (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(0, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(2, 0, 1) == m_BlockType)
)
{
// FIXME: This is unreachable, as the condition is the same as the above one
@@ -68,7 +68,7 @@ public:
virtual void OnPlacedByPlayer(
- cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
+ cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
@@ -130,12 +130,12 @@ public:
}
int NumChestNeighbors = 0;
- if (Area.GetRelBlockType(1, 0, 2) == E_BLOCK_CHEST)
+ if (Area.GetRelBlockType(1, 0, 2) == m_BlockType)
{
if (
- (Area.GetRelBlockType(0, 0, 2) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(1, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(1, 0, 3) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(0, 0, 2) == m_BlockType) ||
+ (Area.GetRelBlockType(1, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(1, 0, 3) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@@ -143,12 +143,12 @@ public:
}
NumChestNeighbors += 1;
}
- if (Area.GetRelBlockType(3, 0, 2) == E_BLOCK_CHEST)
+ if (Area.GetRelBlockType(3, 0, 2) == m_BlockType)
{
if (
- (Area.GetRelBlockType(4, 0, 2) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(3, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(3, 0, 3) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(4, 0, 2) == m_BlockType) ||
+ (Area.GetRelBlockType(3, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(3, 0, 3) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@@ -156,12 +156,12 @@ public:
}
NumChestNeighbors += 1;
}
- if (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
+ if (Area.GetRelBlockType(2, 0, 1) == m_BlockType)
{
if (
- (Area.GetRelBlockType(2, 0, 0) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(1, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(3, 0, 1) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(2, 0, 0) == m_BlockType) ||
+ (Area.GetRelBlockType(1, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(3, 0, 1) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@@ -169,12 +169,12 @@ public:
}
NumChestNeighbors += 1;
}
- if (Area.GetRelBlockType(2, 0, 3) == E_BLOCK_CHEST)
+ if (Area.GetRelBlockType(2, 0, 3) == m_BlockType)
{
if (
- (Area.GetRelBlockType(2, 0, 4) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(1, 0, 3) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(3, 0, 3) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(2, 0, 4) == m_BlockType) ||
+ (Area.GetRelBlockType(1, 0, 3) == m_BlockType) ||
+ (Area.GetRelBlockType(3, 0, 3) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@@ -217,7 +217,7 @@ public:
/// If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true.
bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta)
{
- if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != E_BLOCK_CHEST)
+ if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != m_BlockType)
{
return false;
}
@@ -228,7 +228,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- a_Pickups.push_back(cItem(E_BLOCK_CHEST, 1, 0));
+ a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
} ;
diff --git a/src/Blocks/BlockCloth.h b/src/Blocks/BlockCloth.h
index a136d3b9d..3c1ae7c25 100644
--- a/src/Blocks/BlockCloth.h
+++ b/src/Blocks/BlockCloth.h
@@ -16,13 +16,6 @@ public:
{
}
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_BLOCK_WOOL, 1, a_BlockMeta));
- }
-
-
virtual const char * GetStepSound(void) override
{
return "step.cloth";
diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h
index 4dd05366d..6caaaab13 100644
--- a/src/Blocks/BlockComparator.h
+++ b/src/Blocks/BlockComparator.h
@@ -22,7 +22,7 @@ public:
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
+ Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
}
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h
index 8606cf3f3..ae6e490e1 100644
--- a/src/Blocks/BlockCrops.h
+++ b/src/Blocks/BlockCrops.h
@@ -71,7 +71,7 @@ public:
}
}
}
- }
+ }
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h
index aa24b8668..2d4fccbac 100644
--- a/src/Blocks/BlockDirt.h
+++ b/src/Blocks/BlockDirt.h
@@ -35,8 +35,10 @@ public:
// Grass becomes dirt if there is something on top of it:
if (a_RelY < cChunkDef::Height - 1)
{
- BLOCKTYPE Above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ);
- if ((!cBlockInfo::IsTransparent(Above) && !cBlockInfo::IsOneHitDig(Above)) || IsBlockWater(Above))
+ BLOCKTYPE Above;
+ NIBBLETYPE AboveMeta;
+ a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY + 1, a_RelZ, Above, AboveMeta);
+ if (!cBlockInfo::GetHandler(Above)->CanDirtGrowGrass(AboveMeta))
{
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL);
return;
@@ -77,7 +79,7 @@ public:
BLOCKTYPE AboveDest;
NIBBLETYPE AboveMeta;
Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta);
- if ((cBlockInfo::IsOneHitDig(AboveDest) || cBlockInfo::IsTransparent(AboveDest)) && !IsBlockWater(AboveDest))
+ if (cBlockInfo::GetHandler(AboveDest)->CanDirtGrowGrass(AboveMeta))
{
if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, BlockX * cChunkDef::Width, BlockY, BlockZ * cChunkDef::Width, ssGrassSpread))
{
diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp
index 479c68153..e80473cb5 100644
--- a/src/Blocks/BlockDoor.cpp
+++ b/src/Blocks/BlockDoor.cpp
@@ -45,9 +45,16 @@ void cBlockDoorHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldIn
void cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
+ UNUSED(a_WorldInterface);
+ UNUSED(a_BlockFace);
+ UNUSED(a_CursorX);
+ UNUSED(a_CursorY);
+ UNUSED(a_CursorZ);
+
if (a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_DOOR)
{
ChangeDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
+ a_Player->GetWorld()->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle());
}
}
@@ -62,7 +69,7 @@ void cBlockDoorHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, c
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if (Meta & 8)
+ if (Meta & 0x8)
{
// Current block is top of the door
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, a_Player);
@@ -145,7 +152,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
// Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored
- // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
+ // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
// so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself
// needs extra datamembers.
if (a_Meta & 0x08) return a_Meta;
@@ -172,7 +179,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta)
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
// Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored
- // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
+ // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
// so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself
// needs extra datamembers.
diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h
index 797fe484c..c86fe829b 100644
--- a/src/Blocks/BlockDoor.h
+++ b/src/Blocks/BlockDoor.h
@@ -20,15 +20,15 @@ public:
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override;
virtual const char * GetStepSound(void) override;
-
+
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override;
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override;
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override;
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override;
-
+
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -52,7 +52,7 @@ public:
return true;
}
-
+
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem((m_BlockType == E_BLOCK_WOODEN_DOOR) ? E_ITEM_WOODEN_DOOR : E_ITEM_IRON_DOOR, 1, 0));
@@ -77,8 +77,8 @@ public:
{
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
}
-
-
+
+
bool CanReplaceBlock(BLOCKTYPE a_BlockType)
{
switch (a_BlockType)
@@ -99,7 +99,7 @@ public:
}
- /// Converts the player's yaw to placed door's blockmeta
+ /** Converts the player's yaw to placed door's blockmeta */
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{
ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
@@ -111,67 +111,109 @@ public:
}
if ((a_Yaw >= 0) && (a_Yaw < 90))
{
- return 0x0;
+ return 0x00;
}
else if ((a_Yaw >= 180) && (a_Yaw < 270))
{
- return 0x2;
+ return 0x02;
}
else if ((a_Yaw >= 90) && (a_Yaw < 180))
{
- return 0x1;
+ return 0x01;
}
else
{
- return 0x3;
+ return 0x03;
}
}
- /// Returns true if the specified blocktype is any kind of door
+ /** Returns true if the specified blocktype is any kind of door */
inline static bool IsDoor(BLOCKTYPE a_Block)
{
return (a_Block == E_BLOCK_WOODEN_DOOR) || (a_Block == E_BLOCK_IRON_DOOR);
}
- /// Returns the metadata for the opposite door state (open vs closed)
- static NIBBLETYPE ChangeStateMetaData(NIBBLETYPE a_MetaData)
+ static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
- return a_MetaData ^ 4;
+ NIBBLETYPE Meta = GetCompleteDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
+ return ((Meta & 0x04) != 0);
}
- /// Changes the door at the specified coords from open to close or vice versa
- static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_X, int a_Y, int a_Z)
+ /** Returns the complete meta composed from the both parts of the door as (TopMeta << 4) | BottomMeta
+ The coords may point to either part of the door.
+ The returned value has bit 3 (0x08) set iff the coords point to the top part of the door.
+ Fails gracefully for (invalid) doors on the world's top and bottom. */
+ static NIBBLETYPE GetCompleteDoorMeta(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
- NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_X, a_Y, a_Z);
-
- a_ChunkInterface.SetBlockMeta(a_X, a_Y, a_Z, ChangeStateMetaData(OldMetaData));
+ NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if (OldMetaData & 8)
+ if ((Meta & 0x08) != 0)
{
- // Current block is top of the door
- BLOCKTYPE BottomBlock = a_ChunkInterface.GetBlock(a_X, a_Y - 1, a_Z);
- NIBBLETYPE BottomMeta = a_ChunkInterface.GetBlockMeta(a_X, a_Y - 1, a_Z);
-
- if (IsDoor(BottomBlock) && !(BottomMeta & 8))
+ // The coords are pointing at the top part of the door
+ if (a_BlockX > 0)
{
- a_ChunkInterface.SetBlockMeta(a_X, a_Y - 1, a_Z, ChangeStateMetaData(BottomMeta));
+ NIBBLETYPE DownMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ);
+ return (NIBBLETYPE) ((DownMeta & 0x07) | 0x08 | (Meta << 4));
}
+ // This is the top part of the door at the bottommost layer of the world, there's no bottom:
+ return (NIBBLETYPE) (0x08 | (Meta << 4));
}
else
{
- // Current block is bottom of the door
- BLOCKTYPE TopBlock = a_ChunkInterface.GetBlock(a_X, a_Y + 1, a_Z);
- NIBBLETYPE TopMeta = a_ChunkInterface.GetBlockMeta(a_X, a_Y + 1, a_Z);
+ // The coords are pointing at the bottom part of the door
+ if (a_BlockY < cChunkDef::Height - 1)
+ {
+ NIBBLETYPE UpMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ);
+ return (NIBBLETYPE) (Meta | (UpMeta << 4));
+ }
+ // This is the bottom part of the door at the topmost layer of the world, there's no top:
+ return Meta;
+ }
+ }
+
+
+ /** Sets the door to the specified state. If the door is already in that state, does nothing. */
+ static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open)
+ {
+ BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ if (!IsDoor(Block))
+ {
+ return;
+ }
- if (IsDoor(TopBlock) && (TopMeta & 8))
+ NIBBLETYPE Meta = GetCompleteDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
+ bool IsOpened = ((Meta & 0x04) != 0);
+ if (IsOpened == a_Open)
+ {
+ return;
+ }
+
+ // Change the door
+ NIBBLETYPE NewMeta = (Meta & 0x07) ^ 0x04; // Flip the "IsOpen" bit (0x04)
+ if ((Meta & 0x08) == 0)
+ {
+ // The block is the bottom part of the door
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, NewMeta);
+ }
+ else
+ {
+ // The block is the top part of the door, set the meta to the corresponding top part
+ if (a_BlockY > 0)
{
- a_ChunkInterface.SetBlockMeta(a_X, a_Y + 1, a_Z, ChangeStateMetaData(TopMeta));
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ, NewMeta);
}
}
}
+
+
+ /** Changes the door at the specified coords from open to close or vice versa */
+ static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ SetOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, !IsOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ));
+ }
} ;
diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h
index 88b61a418..ba96c716a 100644
--- a/src/Blocks/BlockDropSpenser.h
+++ b/src/Blocks/BlockDropSpenser.h
@@ -5,7 +5,7 @@
#pragma once
-#include "../Piston.h"
+#include "../Blocks/BlockPiston.h"
#include "MetaRotator.h"
@@ -24,7 +24,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -32,7 +32,7 @@ public:
a_BlockType = m_BlockType;
// FIXME: Do not use cPiston class for dispenser placement!
- a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch());
+ a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch());
return true;
}
@@ -43,8 +43,8 @@ public:
// Mirrors defined by by a table. (Source, mincraft.gamepedia.com) 0x07 == 0111
switch (a_Meta & 0x07)
{
- case 0x00: return 0x01 + OtherMeta; // Down -> Up
- case 0x01: return 0x00 + OtherMeta; // Up -> Down
+ case 0x00: return 0x01 + OtherMeta; // Down -> Up
+ case 0x01: return 0x00 + OtherMeta; // Up -> Down
}
// Not Facing Up or Down; No change.
return a_Meta;
diff --git a/src/Blocks/BlockEnderchest.h b/src/Blocks/BlockEnderchest.h
index 67955f8ce..4672f1459 100644
--- a/src/Blocks/BlockEnderchest.h
+++ b/src/Blocks/BlockEnderchest.h
@@ -18,7 +18,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- //todo: Drop Ender Chest if using silk touch pickaxe
+ // todo: Drop Ender Chest if using silk touch pickaxe
a_Pickups.push_back(cItem(E_BLOCK_OBSIDIAN, 8, 0));
}
diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h
index b720ccd14..ed0592acd 100644
--- a/src/Blocks/BlockFarmland.h
+++ b/src/Blocks/BlockFarmland.h
@@ -19,15 +19,13 @@
class cBlockFarmlandHandler :
public cBlockHandler
{
- typedef cBlockHandler super;
public:
- cBlockFarmlandHandler(void) :
- super(E_BLOCK_FARMLAND)
+ cBlockFarmlandHandler(BLOCKTYPE a_BlockType) :
+ cBlockHandler(a_BlockType)
{
}
-
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
bool Found = false;
@@ -52,9 +50,9 @@ public:
return;
}
- int NumBlocks = Area.GetBlockCount();
+ size_t NumBlocks = Area.GetBlockCount();
BLOCKTYPE * BlockTypes = Area.GetBlockTypes();
- for (int i = 0; i < NumBlocks; i++)
+ for (size_t i = 0; i < NumBlocks; i++)
{
if (
(BlockTypes[i] == E_BLOCK_WATER) ||
@@ -105,6 +103,11 @@ public:
}
}
}
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta
+ }
} ;
diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h
index e202c6610..433531275 100644
--- a/src/Blocks/BlockFenceGate.h
+++ b/src/Blocks/BlockFenceGate.h
@@ -19,7 +19,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -45,6 +45,7 @@ public:
// Standing aside - use last direction
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, OldMetaData);
}
+ a_Player->GetWorld()->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle());
}
diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h
index c8f158e7e..f52825362 100644
--- a/src/Blocks/BlockFire.h
+++ b/src/Blocks/BlockFire.h
@@ -36,8 +36,8 @@ public:
- Loop through boundary variables, and fill with portal blocks based on Dir with meta from Dir
*/
- a_BlockY--; // Because we want the block below the fire
- FindAndSetPortalFrame(a_BlockX, a_BlockY, a_BlockZ, a_ChunkInterface, a_WorldInterface);
+ // a_BlockY - 1: Because we want the block below the fire
+ FindAndSetPortalFrame(a_BlockX, a_BlockY - 1, a_BlockZ, a_ChunkInterface, a_WorldInterface);
}
virtual void OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
@@ -68,7 +68,6 @@ public:
{
return 0;
}
-
for (int newY = Y + 1; newY < cChunkDef::Height; newY++)
{
@@ -84,7 +83,7 @@ public:
// This is because the frame is a solid obsidian pillar
if ((MaxY != 0) && (newY == Y + 1))
{
- return EvaluatePortalBorder(X, newY, Z, MaxY, a_ChunkInterface);
+ return EvaluatePortalBorder(X, newY, Z, MaxY, a_ChunkInterface) ? -1 /* -1 = found a frame */ : 0;
}
else
{
@@ -99,27 +98,27 @@ public:
}
/// Evaluates if coords have a valid border on top, based on MaxY
- int EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
+ bool EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
{
- for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners
+ for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners
{
if (a_ChunkInterface.GetBlock(X, checkBorder, Z) != E_BLOCK_OBSIDIAN)
{
// Base obsidian, base + 1 obsidian, base + x NOT obsidian -> not complete portal
- return 0;
+ return false;
}
}
// Everything was obsidian, found a border!
- return -1; // Return -1 for a frame border
+ return true;
}
/// Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE)
void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface)
{
- int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks
- int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above
+ int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks
+ int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above
- if (MaxY == 0) // Oh noes! Not a portal coordinate :(
+ if (MaxY == 0) // Oh noes! Not a portal coordinate :(
{
return;
}
@@ -128,11 +127,11 @@ public:
{
if (!FindPortalSliceZ(X, Y, Z1, Z2, MaxY, a_ChunkInterface))
{
- return; // No eligible portal construct, abort abort abort!!
+ return; // No eligible portal construct, abort abort abort!!
}
}
- for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks
+ for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks
{
for (int Width = XZM; Width <= XZP; Width++)
{
@@ -154,23 +153,23 @@ public:
/// Takes coordinates of base block and Y coord of target obsidian ceiling
bool FindPortalSliceX(int X1, int X2, int Y, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
{
- Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction)
+ Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction)
bool FoundFrameXP = false, FoundFrameXM = false;
- for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners
+ for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners
{
int Value = FindObsidianCeiling(X1, Y, Z, a_ChunkInterface, MaxY);
- int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian
- if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find
+ int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian
+ if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find
{
- FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further)
+ FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further)
break;
}
- else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice'
+ else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice'
{
- return false; // Not valid slice, no portal can be formed
+ return false; // Not valid slice, no portal can be formed
}
- } XZP = X1 - 1; // Set boundary of frame interior, note that for some reason, the loop of X and the loop of Z go to different numbers, hence -1 here and -2 there
- for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM)
+ } XZP = X1 - 1; // Set boundary of frame interior
+ for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM)
{
int Value = FindObsidianCeiling(X2, Y, Z, a_ChunkInterface, MaxY);
int ValueTwo = FindObsidianCeiling(X2, Y + 1, Z, a_ChunkInterface, MaxY);
@@ -183,7 +182,7 @@ public:
{
return false;
}
- } XZM = X2 + 1; // Set boundary, see previous
+ } XZM = X2 + 1; // Set boundary, see previous
return (FoundFrameXP && FoundFrameXM);
}
@@ -199,13 +198,13 @@ public:
if ((Value == -1) || (ValueTwo == -1))
{
FoundFrameZP = true;
- continue;
+ break;
}
else if ((Value != MaxY) && (ValueTwo != MaxY))
{
return false;
}
- } XZP = Z1 - 2;
+ } XZP = Z1 - 1;
for (; ((a_ChunkInterface.GetBlock(X, Y, Z2) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X, Y + 1, Z2) == E_BLOCK_OBSIDIAN)); Z2--)
{
int Value = FindObsidianCeiling(X, Y, Z2, a_ChunkInterface, MaxY);
@@ -213,13 +212,13 @@ public:
if ((Value == -1) || (ValueTwo == -1))
{
FoundFrameZM = true;
- continue;
+ break;
}
else if ((Value != MaxY) && (ValueTwo != MaxY))
{
return false;
}
- } XZM = Z2 + 2;
+ } XZM = Z2 + 1;
return (FoundFrameZP && FoundFrameZM);
}
};
diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h
index d486d642d..8c0aae041 100644
--- a/src/Blocks/BlockFluid.h
+++ b/src/Blocks/BlockFluid.h
@@ -17,7 +17,7 @@ public:
: cBlockHandler(a_BlockType)
{
- }
+ }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
@@ -49,6 +49,12 @@ public:
}
super::Check(a_ChunkInterface, a_PluginInterface, a_RelX, a_RelY, a_RelZ, a_Chunk);
}
+
+
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
+ {
+ return false;
+ }
} ;
diff --git a/src/Blocks/BlockFurnace.h b/src/Blocks/BlockFurnace.h
index a7a807957..2c7310ac9 100644
--- a/src/Blocks/BlockFurnace.h
+++ b/src/Blocks/BlockFurnace.h
@@ -3,7 +3,7 @@
#include "BlockEntity.h"
#include "../World.h"
-#include "../Piston.h"
+#include "../Blocks/BlockPiston.h"
#include "MetaRotator.h"
@@ -13,7 +13,7 @@ class cBlockFurnaceHandler :
public cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
{
public:
- cBlockFurnaceHandler(BLOCKTYPE a_BlockType)
+ cBlockFurnaceHandler(BLOCKTYPE a_BlockType)
: cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{
}
@@ -27,7 +27,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -35,7 +35,7 @@ public:
a_BlockType = m_BlockType;
// FIXME: Do not use cPiston class for furnace placement!
- a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetYaw(), 0);
+ a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), 0);
return true;
}
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index a764c6f44..ddb0186c9 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -38,6 +38,7 @@
#include "BlockGlass.h"
#include "BlockGlowstone.h"
#include "BlockGravel.h"
+#include "BlockHayBale.h"
#include "BlockMobHead.h"
#include "BlockHopper.h"
#include "BlockIce.h"
@@ -56,6 +57,7 @@
#include "BlockPlanks.h"
#include "BlockPortal.h"
#include "BlockPumpkin.h"
+#include "BlockPressurePlate.h"
#include "BlockQuartz.h"
#include "BlockRail.h"
#include "BlockRedstone.h"
@@ -63,10 +65,12 @@
#include "BlockRedstoneRepeater.h"
#include "BlockRedstoneTorch.h"
#include "BlockTNT.h"
+#include "BlockTripwire.h"
+#include "BlockTripwireHook.h"
#include "BlockSand.h"
#include "BlockSapling.h"
#include "BlockSideways.h"
-#include "BlockSign.h"
+#include "BlockSignPost.h"
#include "BlockSlab.h"
#include "BlockSnow.h"
#include "BlockStairs.h"
@@ -77,15 +81,101 @@
#include "BlockTorch.h"
#include "BlockTrapdoor.h"
#include "BlockVine.h"
+#include "BlockWallSign.h"
#include "BlockWorkbench.h"
+/*
+// Tests the meta rotation and mirroring.
+// Note that the cMetaRotator needs to have its assert paths disabled for this test to work!
+static class cBlockHandlerRotationTester
+{
+public:
+ cBlockHandlerRotationTester(void)
+ {
+ printf("Performing block handlers test...\n");
+ for (BLOCKTYPE Type = 0; Type < E_BLOCK_MAX_TYPE_ID; Type++)
+ {
+ cBlockHandler * Handler = cBlockInfo::GetHandler(Type);
+ if (Handler == NULL)
+ {
+ printf("NULL handler for block type %d!\n", Type);
+ continue;
+ }
+ AString BlockName = ItemTypeToString(Type);
+ for (NIBBLETYPE Meta = 0; Meta < 16; Meta++)
+ {
+ // Test the CW / CCW rotations:
+ NIBBLETYPE TestMeta;
+ TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Meta))));
+ if (TestMeta != Meta)
+ {
+ // 4 CW rotations should produce no change in the meta
+ printf("Handler for blocktype %d (%s) fails CW 4-rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
+ }
+ TestMeta = Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Meta))));
+ if (TestMeta != Meta)
+ {
+ // 4 CCW rotations should produce no change in the meta
+ printf("Handler for blocktype %d (%s) fails CCW 4-rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
+ }
+ TestMeta = Handler->MetaRotateCCW(Handler->MetaRotateCW(Meta));
+ if (TestMeta != Meta)
+ {
+ // CCW rotation of a CW rotation should produce no change in the meta
+ printf("Handler for blocktype %d (%s) fails CCW(CW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
+ }
+ TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCCW(Meta));
+ if (TestMeta != Meta)
+ {
+ // CW rotation of a CCW rotation should produce no change in the meta
+ printf("Handler for blocktype %d (%s) fails CW(CCW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
+ }
+
+ // Test the mirroring:
+ TestMeta = Handler->MetaMirrorXY(Handler->MetaMirrorXY(Meta));
+ if (TestMeta != Meta)
+ {
+ // Double-mirroring should produce the same meta:
+ printf("Handler for blocktype %d (%s) fails XY mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
+ }
+ TestMeta = Handler->MetaMirrorXZ(Handler->MetaMirrorXZ(Meta));
+ if (TestMeta != Meta)
+ {
+ // Double-mirroring should produce the same meta:
+ printf("Handler for blocktype %d (%s) fails XZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
+ }
+ TestMeta = Handler->MetaMirrorYZ(Handler->MetaMirrorYZ(Meta));
+ if (TestMeta != Meta)
+ {
+ // Double-mirroring should produce the same meta:
+ printf("Handler for blocktype %d (%s) fails YZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
+ }
+
+ // Test mirror-rotating:
+ TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaMirrorXY(Handler->MetaMirrorYZ(Meta))));
+ if (TestMeta != Meta)
+ {
+ // 2 CW rotations should be the same as XY, YZ mirroring:
+ printf("Handler for blocktype %d (%s) fails rotation-mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
+ }
+ }
+ } // for Type
+ printf("Block handlers test complete.\n");
+ }
+} g_BlockHandlerRotationTester;
+//*/
+
+
+
+
+
cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
{
- switch(a_BlockType)
+ switch (a_BlockType)
{
// Block handlers, alphabetically sorted:
case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
@@ -122,7 +212,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_ENCHANTMENT_TABLE: return new cBlockEnchantmentTableHandler(a_BlockType);
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
- case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler ( );
+ case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler (a_BlockType);
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
@@ -130,10 +220,12 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType);
case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType);
+ case E_BLOCK_GLASS_PANE: return new cBlockGlassHandler (a_BlockType);
case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType);
case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType);
- case E_BLOCK_HAY_BALE: return new cBlockSidewaysHandler (a_BlockType);
+ case E_BLOCK_HAY_BALE: return new cBlockHayBaleHandler (a_BlockType);
case E_BLOCK_HEAD: return new cBlockMobHeadHandler (a_BlockType);
+ case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType);
case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType);
case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
case E_BLOCK_INACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType);
@@ -147,6 +239,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType);
case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType);
+ case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType);
case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType);
case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType);
@@ -161,7 +254,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
- case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ( );
+ case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler;
case E_BLOCK_PLANKS: return new cBlockPlanksHandler (a_BlockType);
case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType);
case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType);
@@ -170,7 +263,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_QUARTZ_BLOCK: return new cBlockQuartzHandler (a_BlockType);
case E_BLOCK_QUARTZ_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType);
- case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType); // We need this to change pickups to an off lamp; else 1.7+ clients crash
+ case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType);
case E_BLOCK_REDSTONE_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_REDSTONE_ORE_GLOWING: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_REDSTONE_REPEATER_OFF: return new cBlockRedstoneRepeaterHandler(a_BlockType);
@@ -183,26 +276,33 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_SAND: return new cBlockSandHandler (a_BlockType);
case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_SAPLING: return new cBlockSaplingHandler (a_BlockType);
- case E_BLOCK_SIGN_POST: return new cBlockSignHandler (a_BlockType);
+ case E_BLOCK_SIGN_POST: return new cBlockSignPostHandler (a_BlockType);
case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType);
case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
+ case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType);
+ case E_BLOCK_STAINED_GLASS_PANE: return new cBlockGlassHandler (a_BlockType);
case E_BLOCK_STATIONARY_LAVA: return new cBlockLavaHandler (a_BlockType);
case E_BLOCK_STATIONARY_WATER: return new cBlockFluidHandler (a_BlockType);
case E_BLOCK_STICKY_PISTON: return new cBlockPistonHandler (a_BlockType);
case E_BLOCK_STONE: return new cBlockStoneHandler (a_BlockType);
case E_BLOCK_STONE_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_STONE_BUTTON: return new cBlockButtonHandler (a_BlockType);
+ case E_BLOCK_STONE_PRESSURE_PLATE: return new cBlockPressurePlateHandler (a_BlockType);
case E_BLOCK_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
case E_BLOCK_SUGARCANE: return new cBlockSugarcaneHandler (a_BlockType);
case E_BLOCK_TALL_GRASS: return new cBlockTallGrassHandler (a_BlockType);
case E_BLOCK_TORCH: return new cBlockTorchHandler (a_BlockType);
case E_BLOCK_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType);
case E_BLOCK_TNT: return new cBlockTNTHandler (a_BlockType);
+ case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler (a_BlockType);
+ case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType);
+ case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType);
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
- case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType);
+ case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType);
case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType);
case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType);
+ case E_BLOCK_WOODEN_PRESSURE_PLATE: return new cBlockPressurePlateHandler (a_BlockType);
case E_BLOCK_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
case E_BLOCK_WOODEN_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_WOOL: return new cBlockClothHandler (a_BlockType);
@@ -228,7 +328,7 @@ cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
bool cBlockHandler::GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
)
@@ -308,39 +408,6 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, int a_Bl
-
-void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
-}
-
-
-
-
-
-void cBlockHandler::OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
-}
-
-
-
-
-
-void cBlockHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
-{
-}
-
-
-
-
-
-void cBlockHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
-{
-}
-
-
-
-
-
void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta)
{
// Setting the meta to a_BlockMeta keeps most textures. The few other blocks have to override this.
@@ -351,11 +418,23 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta)
-void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ)
+void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim)
{
cItems Pickups;
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- ConvertToPickups(Pickups, Meta);
+
+ if (a_CanDrop)
+ {
+ if (!a_DropVerbatim)
+ {
+ ConvertToPickups(Pickups, Meta);
+ }
+ else
+ {
+ // TODO: Add a proper overridable function for this
+ Pickups.Add(m_BlockType, 1, Meta);
+ }
+ }
// Allow plugins to modify the pickups:
a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
@@ -400,6 +479,15 @@ bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, in
+bool cBlockHandler::CanDirtGrowGrass(NIBBLETYPE a_Meta)
+{
+ return ((cBlockInfo::IsTransparent(m_BlockType)) || (cBlockInfo::IsOneHitDig(m_BlockType)));
+}
+
+
+
+
+
bool cBlockHandler::IsUseable()
{
return false;
diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h
index 3a3efb3cc..de90ce55b 100644
--- a/src/Blocks/BlockHandler.h
+++ b/src/Blocks/BlockHandler.h
@@ -30,14 +30,14 @@ public:
/// Note that the coords are chunk-relative!
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
- /** Called before a block is placed into a world.
+ /** Called before a block is placed into a world.
The handler should return true to allow placement, false to refuse.
Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block.
Called by cItemHandler::GetPlacementBlockTypeMeta() if the item is a block
*/
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
);
@@ -47,8 +47,8 @@ public:
/// Called by cClientHandle::HandlePlaceBlock() after the player has placed a new block. Called after OnPlaced().
virtual void OnPlacedByPlayer(
- cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
);
@@ -60,34 +60,41 @@ public:
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
/// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position)
- virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
+ virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {}
/// Notifies all neighbors of the given block about a change
static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
/// Called while the player diggs the block.
- virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
+ virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}
/// Called if the user right clicks the block and the block is useable
- virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
+ virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}
- /** Called when a Right Click to this Block is cancelled */
- virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace);
+ /** Called when a right click to this block is cancelled */
+ virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}
/// <summary>Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents</summary>
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta);
- /// Handles the dropping of a block based on what ConvertToDrops() returns. This will not destroy the block. a_Digger is the entity causing the drop; it may be NULL
- virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ);
+ /** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins
+ @param a_Digger The entity causing the drop; it may be NULL
+ @param a_CanDrop Informs the handler whether the block should be dropped at all. One example when this is false is when stone is destroyed by hand
+ @param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment)
+ */
+ virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop = true, bool a_DropVerbatim = false);
/// Returns step sound name of block
virtual const char * GetStepSound(void);
/// Checks if the block can stay at the specified relative coords in the chunk
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk);
+
+ /** Can the dirt under this block grow to grass? */
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta);
/** Checks if the block can be placed at this point.
- Default: CanBeAt(...)
+ Default: CanBeAt(...)
NOTE: This call doesn't actually place the block
*/
// virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir);
@@ -95,27 +102,27 @@ public:
/// Called to check whether this block supports a rclk action. If it returns true, OnUse() is called
virtual bool IsUseable(void);
- /** Indicates whether the client will click through this block.
+ /** Indicates whether the client will click through this block.
For example digging a fire will hit the block below the fire so fire is clicked through
*/
virtual bool IsClickedThrough(void);
- /** Checks if the player can build "inside" this block.
+ /** Checks if the player can build "inside" this block.
For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision
*/
virtual bool DoesIgnoreBuildCollision(void);
/// <summary>Similar to DoesIgnoreBuildCollision(void), but is used for cases where block meta/player item-in-hand is needed to determine collision (thin snow)</summary>
- virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta)
- {
+ virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta)
+ {
UNUSED(a_Meta);
- return DoesIgnoreBuildCollision();
+ return DoesIgnoreBuildCollision();
}
/// <summary>Returns if this block drops if it gets destroyed by an unsuitable situation. Default: true</summary>
virtual bool DoesDropOnUnsuitable(void);
- /** Called when one of the neighbors gets set; equivalent to MC block update.
+ /** Called when one of the neighbors gets set; equivalent to MC block update.
By default drops if position no more suitable (CanBeAt(), DoesDropOnUnsuitable(), Drop()),
and wakes up all simulators on the block.
*/
diff --git a/src/Blocks/BlockHayBale.h b/src/Blocks/BlockHayBale.h
new file mode 100644
index 000000000..3c6472adb
--- /dev/null
+++ b/src/Blocks/BlockHayBale.h
@@ -0,0 +1,28 @@
+
+#pragma once
+
+#include "BlockSideways.h"
+
+
+
+
+
+class cBlockHayBaleHandler :
+ public cBlockSidewaysHandler
+{
+public:
+ cBlockHayBaleHandler(BLOCKTYPE a_BlockType)
+ : cBlockSidewaysHandler(a_BlockType)
+ {
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.grass";
+ }
+} ;
+
+
+
+
diff --git a/src/Blocks/BlockHopper.h b/src/Blocks/BlockHopper.h
index a882bb077..4a5d32dd5 100644
--- a/src/Blocks/BlockHopper.h
+++ b/src/Blocks/BlockHopper.h
@@ -19,7 +19,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Blocks/BlockIce.h b/src/Blocks/BlockIce.h
index 8dfe7ddac..c50623594 100644
--- a/src/Blocks/BlockIce.h
+++ b/src/Blocks/BlockIce.h
@@ -29,7 +29,7 @@ public:
// TODO: Ice destroyed with air below it should turn into air instead of water
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, 0);
// This is called later than the real destroying of this ice block
- }
+ }
} ;
diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h
index a605edf3f..284d1d732 100644
--- a/src/Blocks/BlockLadder.h
+++ b/src/Blocks/BlockLadder.h
@@ -3,24 +3,26 @@
#include "BlockHandler.h"
#include "../World.h"
+#include "ClearMetaOnDrop.h"
class cBlockLadderHandler :
- public cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
+ public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> >
{
+ typedef cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> > super;
public:
cBlockLadderHandler(BLOCKTYPE a_BlockType)
- : cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
+ : super(a_BlockType)
{
- }
+ }
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -41,21 +43,27 @@ public:
}
- static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) // tolua_export
- { // tolua_export
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.Add(m_BlockType, 1, 0); // Reset meta
+ }
+
+
+ static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
+ {
switch (a_Direction)
{
case BLOCK_FACE_ZM: return 0x2;
case BLOCK_FACE_ZP: return 0x3;
case BLOCK_FACE_XM: return 0x4;
case BLOCK_FACE_XP: return 0x5;
- default: return 0x2;
+ default: return 0x2;
}
- } // tolua_export
+ }
- static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export
- { // tolua_export
+ static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData)
+ {
switch (a_MetaData)
{
case 0x2: return BLOCK_FACE_ZM;
@@ -64,10 +72,10 @@ public:
case 0x5: return BLOCK_FACE_XP;
default: return BLOCK_FACE_ZM;
}
- } // tolua_export
+ }
- /// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure
+ /** Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure */
static eBlockFace FindSuitableBlockFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
for (int FaceInt = BLOCK_FACE_ZM; FaceInt <= BLOCK_FACE_XP; FaceInt++)
@@ -95,7 +103,7 @@ public:
}
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface,int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
// TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
eBlockFace BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index d9d1bdb7e..972dd6232 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -11,7 +11,7 @@
// Leaves can be this many blocks that away (inclusive) from the log not to decay
#define LEAVES_CHECK_DISTANCE 6
-#define PROCESS_NEIGHBOR(x,y,z) \
+#define PROCESS_NEIGHBOR(x, y, z) \
switch (a_Area.GetBlockType(x, y, z)) \
{ \
case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \
@@ -40,14 +40,20 @@ public:
{
cFastRandom rand;
- // Only the first 2 bits contain the display information, the others are for growing
+ // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand
if (rand.NextInt(6) == 0)
{
- a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3));
+ a_Pickups.push_back(
+ cItem(
+ E_BLOCK_SAPLING,
+ 1,
+ (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01))
+ )
+ );
}
// 1 % chance of dropping an apple, if the leaves' type is Apple Leaves
- if ((a_BlockMeta & 3) == E_META_NEWLEAVES_APPLE)
+ if ((m_BlockType == E_BLOCK_LEAVES) && ((a_BlockMeta & 0x03) == E_META_LEAVES_APPLE))
{
if (rand.NextInt(101) == 0)
{
@@ -55,28 +61,12 @@ public:
}
}
}
-
-
- void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- cBlockHandler::OnDestroyed(a_ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ);
-
- // 0.5% chance of dropping an apple, if the leaves' type is Apple Leaves:
- NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- cFastRandom rand;
- if (((Meta & 3) == E_META_NEWLEAVES_APPLE) && (rand.NextInt(201) == 100))
- {
- cItems Drops;
- Drops.push_back(cItem(E_ITEM_RED_APPLE, 1, 0));
- a_WorldInterface.SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
- }
- }
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
}
@@ -100,10 +90,10 @@ public:
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
cBlockArea Area;
if (!Area.Read(
- a_Chunk.GetWorld(),
- BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE,
- a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE,
- BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE,
+ a_Chunk.GetWorld(),
+ BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE,
+ a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE,
+ BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE,
cBlockArea::baTypes)
)
{
@@ -138,14 +128,14 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ)
{
// Filter the blocks into a {leaves, log, other (air)} set:
BLOCKTYPE * Types = a_Area.GetBlockTypes();
- for (int i = a_Area.GetBlockCount() - 1; i > 0; i--)
+ for (size_t i = a_Area.GetBlockCount() - 1; i > 0; i--)
{
switch (Types[i])
{
- case E_BLOCK_NEW_LEAVES:
- case E_BLOCK_NEW_LOG:
case E_BLOCK_LEAVES:
case E_BLOCK_LOG:
+ case E_BLOCK_NEW_LEAVES:
+ case E_BLOCK_NEW_LOG:
{
break;
}
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index ad2ae29e5..4316fd06b 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -7,12 +7,13 @@
class cBlockLeverHandler :
- public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x02, 0x03, 0x01, false>
+ public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false>
{
- typedef cMetaRotator<cBlockHandler, 0x07, 0x04, 0x02, 0x03, 0x01, false> super;
+ typedef cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false> super;
+
public:
- cBlockLeverHandler(BLOCKTYPE a_BlockType)
- : cMetaRotator<cBlockHandler, 0x07, 0x04, 0x02, 0x03, 0x01, false>(a_BlockType)
+ cBlockLeverHandler(BLOCKTYPE a_BlockType) :
+ super(a_BlockType)
{
}
@@ -21,8 +22,9 @@ public:
// Flip the ON bit on/off using the XOR bitwise operation
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08);
- a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_LEVER, Meta); // SetMeta doesn't work for unpowering levers, so setblock
- a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
+ a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
+ a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
}
@@ -41,7 +43,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -103,7 +105,7 @@ public:
AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
- return (a_RelY > 0) && cBlockInfo::IsSolid(BlockIsOn);
+ return (a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn);
}
@@ -132,7 +134,7 @@ public:
case 0x05: return 0x06; // Ground rotation
case 0x06: return 0x05;
- default: return super::MetaRotateCCW(a_Meta); // Wall Rotation
+ default: return super::MetaRotateCW(a_Meta); // Wall Rotation
}
}
} ;
diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h
index 2dd4ec768..53277caa5 100644
--- a/src/Blocks/BlockLilypad.h
+++ b/src/Blocks/BlockLilypad.h
@@ -8,18 +8,14 @@
class cBlockLilypadHandler :
- public cBlockHandler
+ public cClearMetaOnDrop<cBlockHandler>
{
+ typedef cClearMetaOnDrop<cBlockHandler> super;
public:
- cBlockLilypadHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+
+ cBlockLilypadHandler(BLOCKTYPE a_BlockType) :
+ super(a_BlockType)
{
- // Reset meta to zero
- a_Pickups.push_back(cItem(E_BLOCK_LILY_PAD, 1, 0));
}
};
diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h
index acd1c88fb..ff1ef97bf 100644
--- a/src/Blocks/BlockMobHead.h
+++ b/src/Blocks/BlockMobHead.h
@@ -19,24 +19,69 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- a_Pickups.push_back(cItem(E_ITEM_HEAD, 1, 0));
+ // The drop spawn is in OnDestroyed method
}
+
+ virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ if (a_Player->IsGameModeCreative())
+ {
+ // No drops in creative mode
+ return;
+ }
+
+ class cCallback : public cBlockEntityCallback
+ {
+ virtual bool Item(cBlockEntity * a_BlockEntity)
+ {
+ if (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD)
+ {
+ return false;
+ }
+ cMobHeadEntity * MobHeadEntity = static_cast<cMobHeadEntity*>(a_BlockEntity);
+
+ cItems Pickups;
+ Pickups.Add(E_ITEM_HEAD, 1, (short) MobHeadEntity->GetType());
+ MTRand r1;
- bool TrySpawnWither(cChunkInterface & a_ChunkInterface, cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+ // Mid-block position first
+ double MicroX, MicroY, MicroZ;
+ MicroX = MobHeadEntity->GetPosX() + 0.5;
+ MicroY = MobHeadEntity->GetPosY() + 0.5;
+ MicroZ = MobHeadEntity->GetPosZ() + 0.5;
+
+ // Add random offset second
+ MicroX += r1.rand(1) - 0.5;
+ MicroZ += r1.rand(1) - 0.5;
+
+ MobHeadEntity->GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ);
+ return false;
+ }
+ } Callback;
+
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback);
+ }
+
+ bool TrySpawnWither(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
if (a_BlockY < 2)
{
return false;
}
- class cCallback : public cMobHeadCallback
+ class cCallback : public cBlockEntityCallback
{
bool m_IsWither;
- virtual bool Item (cMobHeadEntity * a_MobHeadEntity)
+ virtual bool Item(cBlockEntity * a_BlockEntity)
{
- m_IsWither = (a_MobHeadEntity->GetType() == SKULL_TYPE_WITHER);
+ if (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD)
+ {
+ return false;
+ }
+ cMobHeadEntity * MobHeadEntity = static_cast<cMobHeadEntity*>(a_BlockEntity);
+ m_IsWither = (MobHeadEntity->GetType() == SKULL_TYPE_WITHER);
return false;
}
@@ -46,9 +91,31 @@ public:
bool IsWither(void) const { return m_IsWither; }
void Reset(void) { m_IsWither = false; }
+
} CallbackA, CallbackB;
- a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, CallbackA);
+ class cPlayerCallback : public cPlayerListCallback
+ {
+ Vector3f m_Pos;
+
+ virtual bool Item(cPlayer * a_Player)
+ {
+ // TODO 2014-05-21 xdot: Vanilla minecraft uses an AABB check instead of a radius one
+ double Dist = (a_Player->GetPosition() - m_Pos).Length();
+ if (Dist < 50.0)
+ {
+ // If player is close, award achievement
+ a_Player->AwardAchievement(achSpawnWither);
+ }
+ return false;
+ }
+
+ public:
+ cPlayerCallback(const Vector3f & a_Pos) : m_Pos(a_Pos) {}
+
+ } PlayerCallback(Vector3f((float)a_BlockX, (float)a_BlockY, (float)a_BlockZ));
+
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, CallbackA);
if (!CallbackA.IsWither())
{
@@ -65,8 +132,8 @@ public:
return false;
}
- a_World->DoWithMobHeadAt(a_BlockX - 1, a_BlockY, a_BlockZ, CallbackA);
- a_World->DoWithMobHeadAt(a_BlockX + 1, a_BlockY, a_BlockZ, CallbackB);
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockX - 1, a_BlockY, a_BlockZ, CallbackA);
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockX + 1, a_BlockY, a_BlockZ, CallbackB);
BLOCKTYPE Block1 = a_ChunkInterface.GetBlock(a_BlockX - 1, a_BlockY - 1, a_BlockZ);
BLOCKTYPE Block2 = a_ChunkInterface.GetBlock(a_BlockX + 1, a_BlockY - 1, a_BlockZ);
@@ -79,12 +146,15 @@ public:
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
// Block entities
- a_World->SetBlock(a_BlockX + 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- a_World->SetBlock(a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX + 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
// Spawn the wither:
- a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
+ a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
+
+ // Award Achievement
+ a_WorldInterface.ForEachPlayer(PlayerCallback);
return true;
}
@@ -92,8 +162,8 @@ public:
CallbackA.Reset();
CallbackB.Reset();
- a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ - 1, CallbackA);
- a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ + 1, CallbackB);
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ - 1, CallbackA);
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ + 1, CallbackB);
Block1 = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ - 1);
Block2 = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ + 1);
@@ -106,12 +176,15 @@ public:
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
// Block entities
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ + 1, E_BLOCK_AIR, 0);
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0);
+ a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ + 1, E_BLOCK_AIR, 0);
+ a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0);
// Spawn the wither:
- a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
+ a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
+
+ // Award Achievement
+ a_WorldInterface.ForEachPlayer(PlayerCallback);
return true;
}
@@ -120,29 +193,35 @@ public:
}
virtual void OnPlacedByPlayer(
- cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
) override
{
- class cCallback : public cMobHeadCallback
+ class cCallback : public cBlockEntityCallback
{
cPlayer * m_Player;
NIBBLETYPE m_OldBlockMeta;
NIBBLETYPE m_NewBlockMeta;
- virtual bool Item (cMobHeadEntity * a_MobHeadEntity)
+ virtual bool Item(cBlockEntity * a_BlockEntity)
{
+ if (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD)
+ {
+ return false;
+ }
+ cMobHeadEntity * MobHeadEntity = static_cast<cMobHeadEntity*>(a_BlockEntity);
+
int Rotation = 0;
if (m_NewBlockMeta == 1)
{
Rotation = (int) floor(m_Player->GetYaw() * 16.0F / 360.0F + 0.5) & 0xF;
}
-
- a_MobHeadEntity->SetType(static_cast<eMobHeadType>(m_OldBlockMeta));
- a_MobHeadEntity->SetRotation(static_cast<eMobHeadRotation>(Rotation));
- a_MobHeadEntity->GetWorld()->BroadcastBlockEntity(a_MobHeadEntity->GetPosX(), a_MobHeadEntity->GetPosY(), a_MobHeadEntity->GetPosZ(), m_Player->GetClientHandle());
+
+ MobHeadEntity->SetType(static_cast<eMobHeadType>(m_OldBlockMeta));
+ MobHeadEntity->SetRotation(static_cast<eMobHeadRotation>(Rotation));
+ MobHeadEntity->GetWorld()->BroadcastBlockEntity(MobHeadEntity->GetPosX(), MobHeadEntity->GetPosY(), MobHeadEntity->GetPosZ());
return false;
}
@@ -156,8 +235,7 @@ public:
cCallback Callback(a_Player, a_BlockMeta, static_cast<NIBBLETYPE>(a_BlockFace));
a_BlockMeta = (NIBBLETYPE)a_BlockFace;
- cWorld * World = (cWorld *) &a_WorldInterface;
- World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback);
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta);
if (a_BlockMeta == SKULL_TYPE_WITHER)
@@ -172,7 +250,7 @@ public:
};
for (size_t i = 0; i < ARRAYCOUNT(Coords); ++i)
{
- if (TrySpawnWither(a_ChunkInterface, World, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z))
+ if (TrySpawnWither(a_ChunkInterface, a_WorldInterface, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z))
{
break;
}
diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp
index 542eb33b5..164967621 100644
--- a/src/Blocks/BlockPiston.cpp
+++ b/src/Blocks/BlockPiston.cpp
@@ -4,14 +4,14 @@
#include "../Item.h"
#include "../World.h"
#include "../Entities/Player.h"
-#include "../Piston.h"
+#include "BlockInServerPluginInterface.h"
#define AddPistonDir(x, y, z, dir, amount) \
- switch (dir) \
+ switch (dir & 0x07) \
{ \
case 0: (y) -= (amount); break; \
case 1: (y) += (amount); break; \
@@ -19,8 +19,16 @@
case 3: (z) += (amount); break; \
case 4: (x) -= (amount); break; \
case 5: (x) += (amount); break; \
+ default: \
+ { \
+ LOGWARNING("%s: invalid direction %d, ignoring", __FUNCTION__, dir & 0x07); \
+ break; \
+ } \
}
+#define PISTON_TICK_DELAY 1
+#define PISTON_MAX_PUSH_DISTANCE 12
+
@@ -40,7 +48,7 @@ void cBlockPistonHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorld
int newX = a_BlockX;
int newY = a_BlockY;
int newZ = a_BlockZ;
- AddPistonDir(newX, newY, newZ, OldMeta & ~(8), 1);
+ AddPistonDir(newX, newY, newZ, OldMeta, 1);
if (a_ChunkInterface.GetBlock(newX, newY, newZ) == E_BLOCK_PISTON_EXTENSION)
{
@@ -54,13 +62,13 @@ void cBlockPistonHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorld
bool cBlockPistonHandler::GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
)
{
a_BlockType = m_BlockType;
- a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch());
+ a_BlockMeta = RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch());
return true;
}
@@ -68,7 +76,166 @@ bool cBlockPistonHandler::GetPlacementBlockTypeMeta(
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+int cBlockPistonHandler::FirstPassthroughBlock(int a_PistonX, int a_PistonY, int a_PistonZ, NIBBLETYPE pistonmeta, cWorld * a_World)
+{
+ // Examine each of the 12 blocks ahead of the piston:
+ for (int ret = 0; ret < PISTON_MAX_PUSH_DISTANCE; ret++)
+ {
+ BLOCKTYPE currBlock;
+ NIBBLETYPE currMeta;
+ AddPistonDir(a_PistonX, a_PistonY, a_PistonZ, pistonmeta, 1);
+ a_World->GetBlockTypeMeta(a_PistonX, a_PistonY, a_PistonZ, currBlock, currMeta);
+ if (cBlockInfo::IsPistonBreakable(currBlock))
+ {
+ // This block breaks when pushed, extend up to here
+ return ret;
+ }
+ if (!CanPush(currBlock, currMeta))
+ {
+ // This block cannot be pushed at all, the piston can't extend
+ return -1;
+ }
+ }
+ // There is no space for the blocks to move, piston can't extend
+ return -1;
+}
+
+
+
+
+
+void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
+{
+ BLOCKTYPE pistonBlock;
+ NIBBLETYPE pistonMeta;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta);
+
+ if (IsExtended(pistonMeta))
+ {
+ // Already extended, bail out
+ return;
+ }
+
+ int dist = FirstPassthroughBlock(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, a_World);
+ if (dist < 0)
+ {
+ // FirstPassthroughBlock says piston can't push anything, bail out
+ return;
+ }
+
+ a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 0, pistonMeta, pistonBlock);
+ a_World->BroadcastSoundEffect("tile.piston.out", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);
+
+ // Drop the breakable block in the line, if appropriate:
+ AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, dist + 1); // "a_Block" now at the breakable / empty block
+ BLOCKTYPE currBlock;
+ NIBBLETYPE currMeta;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currMeta);
+ if (currBlock != E_BLOCK_AIR)
+ {
+ cBlockHandler * Handler = BlockHandler(currBlock);
+ if (Handler->DoesDropOnUnsuitable())
+ {
+ cChunkInterface ChunkInterface(a_World->GetChunkMap());
+ cBlockInServerPluginInterface PluginInterface(*a_World);
+ Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, NULL, a_BlockX, a_BlockY, a_BlockZ);
+ }
+ }
+
+ // Push blocks, from the furthest to the nearest:
+ int oldx = a_BlockX, oldy = a_BlockY, oldz = a_BlockZ;
+ NIBBLETYPE currBlockMeta;
+ std::vector<Vector3i> ScheduledBlocks;
+ ScheduledBlocks.reserve(PISTON_MAX_PUSH_DISTANCE);
+
+ for (int i = dist + 1; i > 1; i--)
+ {
+ AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currBlockMeta);
+ a_World->SetBlock(oldx, oldy, oldz, currBlock, currBlockMeta, false);
+ ScheduledBlocks.push_back(Vector3i(oldx, oldy, oldz));
+ oldx = a_BlockX;
+ oldy = a_BlockY;
+ oldz = a_BlockZ;
+ }
+
+ int extx = a_BlockX;
+ int exty = a_BlockY;
+ int extz = a_BlockZ;
+ ScheduledBlocks.push_back(Vector3i(extx, exty, extz));
+ AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
+ // "a_Block" now at piston body, "ext" at future extension
+
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta | 0x8);
+ a_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), false);
+ a_World->ScheduleTask(PISTON_TICK_DELAY, new cWorld::cTaskSendBlockToAllPlayers(ScheduledBlocks));
+}
+
+
+
+
+
+void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
+{
+ BLOCKTYPE pistonBlock;
+ NIBBLETYPE pistonMeta;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta);
+
+ if (!IsExtended(pistonMeta))
+ {
+ // Already retracted, bail out
+ return;
+ }
+
+ // Check the extension:
+ AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1);
+ if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_PISTON_EXTENSION)
+ {
+ LOGD("%s: Piston without an extension - still extending, or just in an invalid state?", __FUNCTION__);
+ return;
+ }
+
+ AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta & ~(8));
+ a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 1, pistonMeta & ~(8), pistonBlock);
+ a_World->BroadcastSoundEffect("tile.piston.in", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);
+ AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1);
+
+ // Retract the extension, pull block if appropriate
+ if (IsSticky(pistonBlock))
+ {
+ int tempx = a_BlockX, tempy = a_BlockY, tempz = a_BlockZ;
+ AddPistonDir(tempx, tempy, tempz, pistonMeta, 1);
+ BLOCKTYPE tempBlock;
+ NIBBLETYPE tempMeta;
+ a_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta);
+ if (CanPull(tempBlock, tempMeta))
+ {
+ // Pull the block
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, tempBlock, tempMeta, false);
+ a_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, false);
+
+ std::vector<Vector3i> ScheduledBlocks;
+ ScheduledBlocks.push_back(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
+ ScheduledBlocks.push_back(Vector3i(tempx, tempy, tempz));
+ a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(ScheduledBlocks));
+ return;
+ }
+ }
+
+ // Retract without pulling
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0, false);
+
+ std::vector<Vector3i> ScheduledBlocks;
+ ScheduledBlocks.push_back(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
+ a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(ScheduledBlocks));
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cBlockPistonHeadHandler:
cBlockPistonHeadHandler::cBlockPistonHeadHandler(void) :
@@ -87,7 +254,7 @@ void cBlockPistonHeadHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInter
int newX = a_BlockX;
int newY = a_BlockY;
int newZ = a_BlockZ;
- AddPistonDir(newX, newY, newZ, OldMeta & ~(8), -1);
+ AddPistonDir(newX, newY, newZ, OldMeta, -1);
BLOCKTYPE Block = a_ChunkInterface.GetBlock(newX, newY, newZ);
if ((Block == E_BLOCK_STICKY_PISTON) || (Block == E_BLOCK_PISTON))
@@ -95,7 +262,7 @@ void cBlockPistonHeadHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInter
a_ChunkInterface.DigBlock(a_WorldInterface, newX, newY, newZ);
if (a_Player->IsGameModeCreative())
{
- return; // No pickups if creative
+ return; // No pickups if creative
}
cItems Pickups;
diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h
index 7632b5e5a..bbb8af75b 100644
--- a/src/Blocks/BlockPiston.h
+++ b/src/Blocks/BlockPiston.h
@@ -17,10 +17,129 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override;
+
+ static NIBBLETYPE RotationPitchToMetaData(double a_Rotation, double a_Pitch)
+ {
+ if (a_Pitch >= 50)
+ {
+ return 0x1;
+ }
+ else if (a_Pitch <= -50)
+ {
+ return 0x0;
+ }
+ else
+ {
+ a_Rotation += 90 + 45; // So its not aligned with axis
+
+ if (a_Rotation > 360)
+ {
+ a_Rotation -= 360;
+ }
+ if ((a_Rotation >= 0) && (a_Rotation < 90))
+ {
+ return 0x4;
+ }
+ else if ((a_Rotation >= 180) && (a_Rotation < 270))
+ {
+ return 0x5;
+ }
+ else if ((a_Rotation >= 90) && (a_Rotation < 180))
+ {
+ return 0x2;
+ }
+ else
+ {
+ return 0x3;
+ }
+ }
+ }
+
+ static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData)
+ {
+ switch (a_MetaData)
+ {
+ case 0x0: return BLOCK_FACE_YM;
+ case 0x1: return BLOCK_FACE_YP;
+ case 0x2: return BLOCK_FACE_ZM;
+ case 0x3: return BLOCK_FACE_ZP;
+ case 0x4: return BLOCK_FACE_XM;
+ case 0x5: return BLOCK_FACE_XP;
+ default:
+ {
+ ASSERT(!"Invalid Metadata");
+ return BLOCK_FACE_NONE;
+ }
+ }
+ }
+
+ static void ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+ static void RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+
+private:
+
+ /// Returns true if the piston (specified by blocktype) is a sticky piston
+ static inline bool IsSticky(BLOCKTYPE a_BlockType) { return (a_BlockType == E_BLOCK_STICKY_PISTON); }
+
+ /// Returns true if the piston (with the specified meta) is extended
+ static inline bool IsExtended(NIBBLETYPE a_PistonMeta) { return ((a_PistonMeta & 0x8) != 0x0); }
+
+ /// Returns true if the specified block can be pushed by a piston (and left intact)
+ static inline bool CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+ {
+ switch (a_BlockType)
+ {
+ case E_BLOCK_ANVIL:
+ case E_BLOCK_BEDROCK:
+ case E_BLOCK_BREWING_STAND:
+ case E_BLOCK_CHEST:
+ case E_BLOCK_COMMAND_BLOCK:
+ case E_BLOCK_DISPENSER:
+ case E_BLOCK_DROPPER:
+ case E_BLOCK_ENCHANTMENT_TABLE:
+ case E_BLOCK_END_PORTAL:
+ case E_BLOCK_END_PORTAL_FRAME:
+ // Notice the lack of an E_BLOCK_ENDER_CHEST here; its because ender chests can totally be pushed/pulled in MCS :)
+ case E_BLOCK_FURNACE:
+ case E_BLOCK_LIT_FURNACE:
+ case E_BLOCK_HOPPER:
+ case E_BLOCK_JUKEBOX:
+ case E_BLOCK_MOB_SPAWNER:
+ case E_BLOCK_NETHER_PORTAL:
+ case E_BLOCK_NOTE_BLOCK:
+ case E_BLOCK_OBSIDIAN:
+ case E_BLOCK_PISTON_EXTENSION:
+ case E_BLOCK_TRAPPED_CHEST:
+ {
+ return false;
+ }
+ case E_BLOCK_STICKY_PISTON:
+ case E_BLOCK_PISTON:
+ {
+ // A piston can only be pushed if retracted:
+ return !IsExtended(a_BlockMeta);
+ }
+ }
+ return true;
+ }
+
+ /// Returns true if the specified block can be pulled by a sticky piston
+ static inline bool CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+ {
+ if (cBlockInfo::IsPistonBreakable(a_BlockType))
+ {
+ return false; // CanBreakPush returns true, but we need false to prevent pulling
+ }
+
+ return CanPush(a_BlockType, a_BlockMeta);
+ }
+
+ /// Returns how many blocks the piston has to push (where the first free space is); < 0 when unpushable
+ static int FirstPassthroughBlock(int a_PistonX, int a_PistonY, int a_PistonZ, NIBBLETYPE a_PistonMeta, cWorld * a_World);
} ;
@@ -40,7 +159,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// No pickups
- // Also with 1.7, the item forms of these tecnical blocks have been removed, so giving someone this will crash their client...
+ // Also with 1.7, the item forms of these technical blocks have been removed, so giving someone this will crash their client...
}
} ;
diff --git a/src/Blocks/BlockPlanks.h b/src/Blocks/BlockPlanks.h
index 2a99a455e..de84ed319 100644
--- a/src/Blocks/BlockPlanks.h
+++ b/src/Blocks/BlockPlanks.h
@@ -18,7 +18,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h
index 21bcbdeea..fc74e89d0 100644
--- a/src/Blocks/BlockPortal.h
+++ b/src/Blocks/BlockPortal.h
@@ -2,6 +2,7 @@
#pragma once
#include "BlockHandler.h"
+#include "../Mobs/Monster.h"
@@ -18,7 +19,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -35,15 +36,28 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- return; // No pickups
+ return; // No pickups
}
+ virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
+ {
+ cFastRandom Random;
+ if (Random.NextInt(2000) != 0)
+ {
+ return;
+ }
+
+ int PosX = a_Chunk.GetPosX() * 16 + a_RelX;
+ int PosZ = a_Chunk.GetPosZ() * 16 + a_RelZ;
+
+ a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, cMonster::mtZombiePigman);
+ }
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if ((a_RelY - 1 < 0) || (a_RelY + 1 > cChunkDef::Height))
{
- return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1
+ return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1
}
switch (a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ))
@@ -56,7 +70,7 @@ public:
} PortalCheck[] =
{
{ 0, 1, 0},
- { 0,-1, 0},
+ { 0, -1, 0},
{ 1, 0, 0},
{-1, 0, 0},
} ;
@@ -81,7 +95,7 @@ public:
} PortalCheck[] =
{
{ 0, 1, 0},
- { 0,-1, 0},
+ { 0, -1, 0},
{ 0, 0, -1},
{ 0, 0, 1},
} ;
diff --git a/src/Blocks/BlockPressurePlate.h b/src/Blocks/BlockPressurePlate.h
new file mode 100644
index 000000000..adec36eb6
--- /dev/null
+++ b/src/Blocks/BlockPressurePlate.h
@@ -0,0 +1,38 @@
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+class cBlockPressurePlateHandler :
+ public cBlockHandler
+{
+public:
+ cBlockPressurePlateHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(m_BlockType, 1, 0));
+ }
+
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+
+ BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
+ return ((BlockBelow == E_BLOCK_FENCE_GATE) || (BlockBelow == E_BLOCK_FENCE) || cBlockInfo::IsSolid(BlockBelow));
+ }
+} ;
+
+
+
+
diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h
index ac2b9817a..15ac80fd7 100644
--- a/src/Blocks/BlockPumpkin.h
+++ b/src/Blocks/BlockPumpkin.h
@@ -6,13 +6,16 @@
class cBlockPumpkinHandler :
- public cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false>
+ public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false> >
{
+ typedef cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false> > super;
public:
- cBlockPumpkinHandler(BLOCKTYPE a_BlockType)
- : cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false>(a_BlockType)
+
+ cBlockPumpkinHandler(BLOCKTYPE a_BlockType) :
+ super(a_BlockType)
{
}
+
virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
{
@@ -73,14 +76,14 @@ public:
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
// Spawn the golem:
- a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem);
+ a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem);
}
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h
index 9cc51490f..2ce7e71e4 100644
--- a/src/Blocks/BlockQuartz.h
+++ b/src/Blocks/BlockQuartz.h
@@ -18,14 +18,14 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
a_BlockType = m_BlockType;
NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage);
- if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block.
+ if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block.
{
a_BlockMeta = Meta;
return true;
@@ -42,25 +42,25 @@ public:
case BLOCK_FACE_YM:
case BLOCK_FACE_YP:
{
- return a_QuartzMeta; // Top or bottom, just return original
+ return a_QuartzMeta; // Top or bottom, just return original
}
case BLOCK_FACE_ZP:
case BLOCK_FACE_ZM:
{
- return 0x4; // North or south
+ return 0x4; // North or south
}
case BLOCK_FACE_XP:
case BLOCK_FACE_XM:
{
- return 0x3; // East or west
+ return 0x3; // East or west
}
default:
{
ASSERT(!"Unhandled block face!");
- return a_QuartzMeta; // No idea, give a special meta (all sides the same)
+ return a_QuartzMeta; // No idea, give a special meta (all sides the same)
}
}
}
diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h
index 358b5ca11..87ce069ab 100644
--- a/src/Blocks/BlockRail.h
+++ b/src/Blocks/BlockRail.h
@@ -31,7 +31,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -140,7 +140,7 @@ public:
{
NIBBLETYPE Meta = 0;
char RailsCnt = 0;
- bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP
+ bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP
memset(Neighbors, 0, sizeof(Neighbors));
Neighbors[0] = (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN));
Neighbors[1] = (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN));
@@ -223,7 +223,7 @@ public:
case E_META_RAIL_ZM_ZP:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_DOWN)
)
{
@@ -235,7 +235,7 @@ public:
case E_META_RAIL_XM_XP:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN)
)
{
@@ -247,7 +247,7 @@ public:
case E_META_RAIL_ASCEND_XP:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
)
{
@@ -259,7 +259,7 @@ public:
case E_META_RAIL_ASCEND_XM:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_WEST)
)
{
@@ -271,7 +271,7 @@ public:
case E_META_RAIL_ASCEND_ZM:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH)
)
{
@@ -283,7 +283,7 @@ public:
case E_META_RAIL_ASCEND_ZP:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH)
)
{
@@ -295,7 +295,7 @@ public:
case E_META_RAIL_CURVED_ZP_XP:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST)
)
{
@@ -307,7 +307,7 @@ public:
case E_META_RAIL_CURVED_ZP_XM:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
)
{
@@ -319,7 +319,7 @@ public:
case E_META_RAIL_CURVED_ZM_XM:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
)
{
@@ -331,7 +331,7 @@ public:
case E_META_RAIL_CURVED_ZM_XP:
{
if (
- IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
+ IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST)
)
{
diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h
index fe6cd21b9..4c8a6a087 100644
--- a/src/Blocks/BlockRedstoneRepeater.h
+++ b/src/Blocks/BlockRedstoneRepeater.h
@@ -71,7 +71,7 @@ public:
inline static NIBBLETYPE RepeaterRotationToMetaData(double a_Rotation)
{
- a_Rotation += 90 + 45; // So its not aligned with axis
+ a_Rotation += 90 + 45; // So its not aligned with axis
if (a_Rotation > 360)
{
a_Rotation -= 360;
diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h
index 3d925029a..de28273d5 100644
--- a/src/Blocks/BlockSapling.h
+++ b/src/Blocks/BlockSapling.h
@@ -20,8 +20,8 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- // Only the first 2 bits contain the display information, the others are for growing
- a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3));
+ // Only the first 2 bits contain the display information and the 4th bit is for the growth indicator, but, we use 0x07 for forward compatibility
+ a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07));
}
diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h
index d67c3aa24..f5f10899d 100644
--- a/src/Blocks/BlockSideways.h
+++ b/src/Blocks/BlockSideways.h
@@ -18,7 +18,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -32,36 +32,36 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3);
+ a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta
}
- inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_WoodMeta)
+ inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_Meta)
{
switch (a_BlockFace)
{
case BLOCK_FACE_YM:
case BLOCK_FACE_YP:
{
- return a_WoodMeta; // Top or bottom, just return original
+ return a_Meta; // Top or bottom, just return original
}
case BLOCK_FACE_ZP:
case BLOCK_FACE_ZM:
{
- return a_WoodMeta | 0x8; // North or south
+ return a_Meta | 0x8; // North or south
}
case BLOCK_FACE_XP:
case BLOCK_FACE_XM:
{
- return a_WoodMeta | 0x4; // East or west
+ return a_Meta | 0x4; // East or west
}
default:
{
ASSERT(!"Unhandled block face!");
- return a_WoodMeta | 0xC; // No idea, give a special meta (all sides bark)
+ return a_Meta | 0xC; // No idea, give a special meta
}
}
}
diff --git a/src/Blocks/BlockSign.h b/src/Blocks/BlockSignPost.h
index 9d6fede21..ee65d099a 100644
--- a/src/Blocks/BlockSign.h
+++ b/src/Blocks/BlockSignPost.h
@@ -9,21 +9,23 @@
-class cBlockSignHandler :
+class cBlockSignPostHandler :
public cBlockHandler
{
+ typedef cBlockHandler super;
+
public:
- cBlockSignHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ cBlockSignPostHandler(BLOCKTYPE a_BlockType) :
+ super(a_BlockType)
{
}
-
+
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
}
-
+
virtual const char * GetStepSound(void) override
{
@@ -31,6 +33,17 @@ public:
}
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+
+ return (cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
+ }
+
+
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
@@ -43,23 +56,6 @@ public:
return ((char)a_Rotation) % 16;
}
-
-
- static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
- {
- switch (a_Direction)
- {
- case 0x2: return 0x2;
- case 0x3: return 0x3;
- case 0x4: return 0x4;
- case 0x5: return 0x5;
- default:
- {
- break;
- }
- }
- return 0x2;
- }
virtual void OnPlacedByPlayer(
@@ -75,31 +71,32 @@ public:
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
- return (++a_Meta) & 0x0F;
+ return (a_Meta + 4) & 0x0f;
}
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
- return (--a_Meta) & 0x0F;
+ return (a_Meta + 12) & 0x0f;
}
+
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
- // Mirrors signs over the XY plane (North-South Mirroring)
+ // Mirrors signs over the XY plane (North-South Mirroring)
- // There are 16 meta values which correspond to different directions.
- // These values are equated to angles on a circle; 0x08 = 180 degrees.
- return (a_Meta < 0x08) ? 0x08 + a_Meta : 0x08 - a_Meta;
+ // There are 16 meta values which correspond to different directions.
+ // These values are equated to angles on a circle; 0x08 = 180 degrees.
+ return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta);
}
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
- // Mirrors signs over the YZ plane (East-West Mirroring)
+ // Mirrors signs over the YZ plane (East-West Mirroring)
- // There are 16 meta values which correspond to different directions.
- // These values are equated to angles on a circle; 0x10 = 360 degrees.
+ // There are 16 meta values which correspond to different directions.
+ // These values are equated to angles on a circle; 0x10 = 360 degrees.
return 0x10 - a_Meta;
}
} ;
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h
index 76f5ed0e7..214445eda 100644
--- a/src/Blocks/BlockSlab.h
+++ b/src/Blocks/BlockSlab.h
@@ -33,7 +33,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -80,6 +80,7 @@ public:
if (IsAnySlabType(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ)))
{
a_BlockType = GetDoubleSlabType(m_BlockType);
+ a_BlockMeta = a_BlockMeta & 0x7;
}
return true;
@@ -97,6 +98,12 @@ public:
return "";
}
+
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
+ {
+ return ((a_Meta & 0x8) != 0);
+ }
+
/// Returns true if the specified blocktype is one of the slabs handled by this handler
static bool IsAnySlabType(BLOCKTYPE a_BlockType)
@@ -117,6 +124,12 @@ public:
return E_BLOCK_AIR;
}
+
+ virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
+ {
+ // Toggle the 4th bit - up / down:
+ return (a_Meta ^ 0x08);
+ }
} ;
@@ -160,15 +173,6 @@ public:
ASSERT(!"Unhandled double slab type!");
return "";
}
-
-
- virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
- {
- NIBBLETYPE OtherMeta = a_Meta & 0x07; // Contains unrelated meta data.
-
- // 8th bit is up/down. 1 right-side-up, 0 is up-side-down.
- return (a_Meta & 0x08) ? 0x00 + OtherMeta : 0x01 + OtherMeta;
- }
} ;
diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h
index b21995d3c..977f19a16 100644
--- a/src/Blocks/BlockSnow.h
+++ b/src/Blocks/BlockSnow.h
@@ -19,7 +19,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -33,8 +33,8 @@ public:
if ((BlockBeforePlacement == E_BLOCK_SNOW) && (MetaBeforePlacement < 7))
{
// Only increment if:
- // A snow block was already there (not first time placement) AND
- // Height is smaller than 7, the maximum possible height
+ // - A snow block was already there (not first time placement) AND
+ // - Height is smaller than 7, the maximum possible height
MetaBeforePlacement++;
}
@@ -47,12 +47,12 @@ public:
{
if ((a_Player->GetEquippedItem().m_ItemType == E_BLOCK_SNOW) && (a_Meta < 7))
{
- return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored
+ return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored
}
if (a_Meta == 0)
{
- return true; // If at normal snowfall height (lowest), we ignore collision
+ return true; // If at normal snowfall height (lowest), we ignore collision
}
return false;
diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h
index 09ff254a6..a7ccf1714 100644
--- a/src/Blocks/BlockStairs.h
+++ b/src/Blocks/BlockStairs.h
@@ -20,7 +20,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -77,10 +77,15 @@ public:
// Reset meta to 0
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
+
+ virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
+ {
+ return true;
+ }
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
- a_Rotation += 90 + 45; // So its not aligned with axis
+ a_Rotation += 90 + 45; // So its not aligned with axis
if (a_Rotation > 360)
{
a_Rotation -= 360;
diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h
index af4c6509a..cd5230f49 100644
--- a/src/Blocks/BlockStone.h
+++ b/src/Blocks/BlockStone.h
@@ -2,8 +2,6 @@
#pragma once
#include "BlockHandler.h"
-#include "../MersenneTwister.h"
-#include "../World.h"
diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h
index ba1f2e0f6..9c008f793 100644
--- a/src/Blocks/BlockTallGrass.h
+++ b/src/Blocks/BlockTallGrass.h
@@ -43,8 +43,9 @@ public:
cItems Pickups;
Pickups.Add(E_BLOCK_TALL_GRASS, 1, Meta);
a_WorldInterface.SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
+
+ a_Player->UseEquippedItem();
}
- a_Player->UseEquippedItem();
}
diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h
index 8ddec8de1..c73118870 100644
--- a/src/Blocks/BlockTorch.h
+++ b/src/Blocks/BlockTorch.h
@@ -19,7 +19,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -28,7 +28,7 @@ public:
if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM))
{
- a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); // Top or bottom faces clicked, find a suitable face
+ a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); // Top or bottom faces clicked, find a suitable face
if (a_BlockFace == BLOCK_FACE_NONE)
{
// Client wouldn't have sent anything anyway, but whatever
@@ -38,10 +38,10 @@ public:
else
{
// Not top or bottom faces, try to preserve whatever face was clicked
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); // Set to clicked block
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); // Set to clicked block
if (!CanBePlacedOn(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ), a_BlockFace))
{
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false); // Reset to torch block
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false); // Reset to torch block
// Torch couldn't be placed on whatever face was clicked, last ditch resort - find another face
a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
if (a_BlockFace == BLOCK_FACE_NONE)
@@ -99,7 +99,7 @@ public:
static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace)
{
- if ( !cBlockInfo::FullyOccupiesVoxel(a_BlockType) )
+ if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType))
{
return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle
}
@@ -113,13 +113,14 @@ public:
/// Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure
static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
- for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions
+ for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions
{
eBlockFace Face = static_cast<eBlockFace>(i);
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true);
BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- if ( // If on a block that can only hold a torch if torch is standing on it, return that face
+ // If on a block that can only hold a torch if torch is standing on it, return that face
+ if (
((BlockInQuestion == E_BLOCK_GLASS) ||
(BlockInQuestion == E_BLOCK_FENCE) ||
(BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) ||
@@ -154,7 +155,11 @@ public:
if (
(BlockInQuestion == E_BLOCK_GLASS) ||
+ (BlockInQuestion == E_BLOCK_STAINED_GLASS) ||
(BlockInQuestion == E_BLOCK_FENCE) ||
+ (BlockInQuestion == E_BLOCK_SOULSAND) ||
+ (BlockInQuestion == E_BLOCK_MOB_SPAWNER) ||
+ (BlockInQuestion == E_BLOCK_END_PORTAL_FRAME) || // Actual vanilla behaviour
(BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) ||
(BlockInQuestion == E_BLOCK_COBBLESTONE_WALL)
)
@@ -163,7 +168,7 @@ public:
// No need to check for upright orientation, it was done when the torch was placed
return true;
}
- else if ( !cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) )
+ else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion))
{
return false;
}
diff --git a/src/Blocks/BlockTripwire.h b/src/Blocks/BlockTripwire.h
new file mode 100644
index 000000000..3ab17bf4a
--- /dev/null
+++ b/src/Blocks/BlockTripwire.h
@@ -0,0 +1,32 @@
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockTripwireHandler :
+ public cBlockHandler
+{
+public:
+ cBlockTripwireHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0));
+ }
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "";
+ }
+};
+
+
+
+
diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h
new file mode 100644
index 000000000..f849fb8ad
--- /dev/null
+++ b/src/Blocks/BlockTripwireHook.h
@@ -0,0 +1,82 @@
+#pragma once
+
+#include "BlockHandler.h"
+#include "MetaRotator.h"
+
+
+
+
+
+class cBlockTripwireHookHandler :
+ public cMetaRotator<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01>
+{
+public:
+ cBlockTripwireHookHandler(BLOCKTYPE a_BlockType)
+ : cMetaRotator<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01>(a_BlockType)
+ {
+ }
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = m_BlockType;
+
+ a_BlockMeta = DirectionToMetadata(a_BlockFace);
+
+ return true;
+ }
+
+ inline static NIBBLETYPE DirectionToMetadata(eBlockFace a_Direction)
+ {
+ switch (a_Direction)
+ {
+ case BLOCK_FACE_XM: return 0x1;
+ case BLOCK_FACE_XP: return 0x3;
+ case BLOCK_FACE_ZM: return 0x2;
+ case BLOCK_FACE_ZP: return 0x0;
+ default: ASSERT(!"Unhandled tripwire hook direction!"); return 0x0;
+ }
+ }
+
+ inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta)
+ {
+ switch (a_Meta & 0x03)
+ {
+ case 0x1: return BLOCK_FACE_XM;
+ case 0x3: return BLOCK_FACE_XP;
+ case 0x2: return BLOCK_FACE_ZM;
+ case 0x0: return BLOCK_FACE_ZP;
+ default: ASSERT(!"Unhandled tripwire hook metadata!"); return BLOCK_FACE_NONE;
+ }
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(E_BLOCK_TRIPWIRE_HOOK, 1, 0));
+ }
+
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ NIBBLETYPE Meta;
+ a_Chunk.UnboundedRelGetBlockMeta(a_RelX, a_RelY, a_RelZ, Meta);
+
+ AddFaceDirection(a_RelX, a_RelY, a_RelZ, MetadataToDirection(Meta), true);
+ BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
+
+ return (a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn);
+ }
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+};
+
+
+
+
diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h
index 7bb9dc484..1e1f6d8d2 100644
--- a/src/Blocks/BlockVine.h
+++ b/src/Blocks/BlockVine.h
@@ -18,7 +18,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -44,6 +44,13 @@ public:
}
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(E_BLOCK_VINES, 1, 0));
+ }
+
+
static NIBBLETYPE DirectionToMetaData(char a_BlockFace)
{
switch (a_BlockFace)
@@ -59,7 +66,7 @@ public:
static char MetaDataToDirection(NIBBLETYPE a_MetaData)
{
- switch(a_MetaData)
+ switch (a_MetaData)
{
case 0x1: return BLOCK_FACE_NORTH;
case 0x4: return BLOCK_FACE_SOUTH;
diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h
new file mode 100644
index 000000000..e837b315e
--- /dev/null
+++ b/src/Blocks/BlockWallSign.h
@@ -0,0 +1,89 @@
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../Entities/Player.h"
+#include "Chunk.h"
+
+
+
+
+
+class cBlockWallSignHandler :
+ public cBlockHandler
+{
+ typedef cBlockHandler super;
+
+public:
+ cBlockWallSignHandler(BLOCKTYPE a_BlockType) :
+ super(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+
+
+ virtual void OnPlacedByPlayer(
+ cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
+ ) override
+ {
+ a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
+ }
+
+
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX;
+ int BlockZ = (a_Chunk.GetPosZ() * cChunkDef::Width) + a_RelZ;
+ GetBlockCoordsBehindTheSign(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ), BlockX, BlockZ);
+
+ return (cBlockInfo::IsSolid(a_ChunkInterface.GetBlock(BlockX, a_RelY, BlockZ)));
+ }
+
+
+ static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ)
+ {
+ switch (a_BlockMeta)
+ {
+ case 2: a_BlockZ++; break;
+ case 3: a_BlockZ--; break;
+ case 4: a_BlockX++; break;
+ case 5: a_BlockX--; break;
+ default: break;
+ }
+ }
+
+
+ static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
+ {
+ switch (a_Direction)
+ {
+ case 0x2: return 0x2;
+ case 0x3: return 0x3;
+ case 0x4: return 0x4;
+ case 0x5: return 0x5;
+ default:
+ {
+ break;
+ }
+ }
+ return 0x2;
+ }
+} ;
+
+
+
+
diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h
index b1b450690..cf332b153 100644
--- a/src/Blocks/BroadcastInterface.h
+++ b/src/Blocks/BroadcastInterface.h
@@ -1,12 +1,12 @@
#pragma once
-class cBroadcastInterface
+class cBroadcastInterface
{
public:
virtual ~cBroadcastInterface() {}
- virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) = 0;
- virtual void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) = 0;
+ virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
+ virtual void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) = 0;
virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) = 0;
};
diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt
index 4b8c745ad..05b7bfab4 100644
--- a/src/Blocks/CMakeLists.txt
+++ b/src/Blocks/CMakeLists.txt
@@ -4,9 +4,99 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ BlockBed.cpp
+ BlockDoor.cpp
+ BlockHandler.cpp
+ BlockPiston.cpp
+ ChunkInterface.cpp)
-add_library(Blocks ${SOURCE})
+SET (HDRS
+ BlockAnvil.h
+ BlockBed.h
+ BlockBigFlower.h
+ BlockBrewingStand.h
+ BlockButton.h
+ BlockCactus.h
+ BlockCake.h
+ BlockCarpet.h
+ BlockCauldron.h
+ BlockChest.h
+ BlockCloth.h
+ BlockCobWeb.h
+ BlockCommandBlock.h
+ BlockComparator.h
+ BlockCrops.h
+ BlockDeadBush.h
+ BlockDirt.h
+ BlockDoor.h
+ BlockDropSpenser.h
+ BlockEnchantmentTable.h
+ BlockEnderchest.h
+ BlockEntity.h
+ BlockFarmland.h
+ BlockFenceGate.h
+ BlockFire.h
+ BlockFlower.h
+ BlockFlowerPot.h
+ BlockFluid.h
+ BlockFurnace.h
+ BlockGlass.h
+ BlockGlowstone.h
+ BlockGravel.h
+ BlockHandler.h
+ BlockHayBale.h
+ BlockHopper.h
+ BlockIce.h
+ BlockLadder.h
+ BlockLeaves.h
+ BlockLever.h
+ BlockLilypad.h
+ BlockMelon.h
+ BlockMobHead.h
+ BlockMushroom.h
+ BlockMycelium.h
+ BlockNetherWart.h
+ BlockNewLeaves.h
+ BlockNote.h
+ BlockOre.h
+ BlockPiston.h
+ BlockPlanks.h
+ BlockPluginInterface.h
+ BlockPortal.h
+ BlockPressurePlate.h
+ BlockPumpkin.h
+ BlockQuartz.h
+ BlockRail.h
+ BlockRedstone.h
+ BlockRedstoneLamp.h
+ BlockRedstoneRepeater.h
+ BlockRedstoneTorch.h
+ BlockSand.h
+ BlockSapling.h
+ BlockSideways.h
+ BlockSignPost.h
+ BlockSlab.h
+ BlockSnow.h
+ BlockStairs.h
+ BlockStems.h
+ BlockStone.h
+ BlockSugarcane.h
+ BlockTNT.h
+ BlockTallGrass.h
+ BlockTorch.h
+ BlockTrapdoor.h
+ BlockTripwire.h
+ BlockTripwireHook.h
+ BlockVine.h
+ BlockWallSign.h
+ BlockWorkbench.h
+ BroadcastInterface.h
+ ChunkInterface.h
+ ClearMetaOnDrop.h
+ MetaRotator.h
+ WorldInterface.h)
+
+if(NOT MSVC)
+ add_library(Blocks ${SRCS} ${HDRS})
+endif()
diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h
index be7c2e0e5..dea9d7c7e 100644
--- a/src/Blocks/ChunkInterface.h
+++ b/src/Blocks/ChunkInterface.h
@@ -18,10 +18,10 @@ public:
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
{
- return m_ChunkMap->GetBlock(a_BlockX,a_BlockY,a_BlockZ);
+ return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
}
BLOCKTYPE GetBlock(const Vector3i & a_Pos)
- {
+ {
return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z);
}
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
@@ -61,9 +61,9 @@ public:
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
- void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta )
+ void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta );
+ FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta);
}
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h
new file mode 100644
index 000000000..f2afbc6ea
--- /dev/null
+++ b/src/Blocks/ClearMetaOnDrop.h
@@ -0,0 +1,24 @@
+
+#pragma once
+
+// mixin for use to clear meta values when the block is converted to a pickup
+
+// Usage: inherit from this class, passing the parent class as the parameter Base
+// For example to use in class Foo which should inherit Bar use
+// class Foo : public cClearMetaOnDrop<Bar>;
+
+template<class Base>
+class cClearMetaOnDrop : public Base
+{
+public:
+
+ cClearMetaOnDrop(BLOCKTYPE a_BlockType) :
+ Base(a_BlockType)
+ {}
+
+ virtual ~cClearMetaOnDrop() {}
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(this->m_BlockType));
+ }
+};
diff --git a/src/Blocks/MetaRotator.h b/src/Blocks/MetaRotator.h
index 899c583e1..599aa7ef9 100644
--- a/src/Blocks/MetaRotator.h
+++ b/src/Blocks/MetaRotator.h
@@ -6,7 +6,7 @@
// MSVC generates warnings for the templated AssertIfNotMatched parameter conditions, so disable it:
#ifdef _MSC_VER
- #pragma warning(disable: 4127) // Conditional expression is constant
+ #pragma warning(disable: 4127) // Conditional expression is constant
#endif
@@ -47,8 +47,8 @@ NIBBLETYPE cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatc
NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask)
{
- case South: return West | OtherMeta;
- case West: return North | OtherMeta;
+ case South: return West | OtherMeta;
+ case West: return North | OtherMeta;
case North: return East | OtherMeta;
case East: return South | OtherMeta;
}
@@ -69,7 +69,7 @@ NIBBLETYPE cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatc
NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask)
{
- case South: return East | OtherMeta;
+ case South: return East | OtherMeta;
case East: return North | OtherMeta;
case North: return West | OtherMeta;
case West: return South | OtherMeta;
diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h
index bfbb053d9..d1c6f9bfc 100644
--- a/src/Blocks/WorldInterface.h
+++ b/src/Blocks/WorldInterface.h
@@ -6,6 +6,12 @@
class cItems;
+typedef cItemCallback<cBlockEntity> cBlockEntityCallback;
+
+
+
+
+
class cWorldInterface
{
public:
@@ -18,7 +24,7 @@ public:
virtual cBroadcastInterface & GetBroadcastManager() = 0;
- virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) = 0;
+ virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) = 0;
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) = 0;
@@ -29,6 +35,9 @@ public:
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) = 0;
+ /** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */
+ virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) = 0;
+
/** Sends the block on those coords to the player */
virtual void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, cPlayer * a_Player) = 0;
@@ -37,4 +46,13 @@ public:
virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0;
+ /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */
+ virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) = 0;
+
+ /** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */
+ virtual int GetHeight(int a_BlockX, int a_BlockZ) = 0;
+
+ /** Wakes up the simulators for the specified block */
+ virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
+
};
diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp
index ce831c200..6b163b01e 100644
--- a/src/BoundingBox.cpp
+++ b/src/BoundingBox.cpp
@@ -191,7 +191,7 @@ bool cBoundingBox::IsInside(const Vector3d & a_Point)
-bool cBoundingBox::IsInside(double a_X, double a_Y,double a_Z)
+bool cBoundingBox::IsInside(double a_X, double a_Y, double a_Z)
{
return IsInside(m_Min, m_Max, a_X, a_Y, a_Z);
}
diff --git a/src/BoundingBox.h b/src/BoundingBox.h
index a7c6c3eea..793466302 100644
--- a/src/BoundingBox.h
+++ b/src/BoundingBox.h
@@ -49,7 +49,7 @@ public:
bool IsInside(const Vector3d & a_Point);
/// Returns true if the point is inside the bounding box
- bool IsInside(double a_X, double a_Y,double a_Z);
+ bool IsInside(double a_X, double a_Y, double a_Z);
/// Returns true if a_Other is inside this bounding box
bool IsInside(cBoundingBox & a_Other);
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp
index 24f91b195..64b31c60b 100644
--- a/src/ByteBuffer.cpp
+++ b/src/ByteBuffer.cpp
@@ -140,7 +140,7 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cByteBuffer:
cByteBuffer::cByteBuffer(size_t a_BufferSize) :
@@ -165,13 +165,14 @@ cByteBuffer::~cByteBuffer()
{
CheckValid();
delete[] m_Buffer;
+ m_Buffer = NULL;
}
-bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count)
+bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count)
{
CHECK_THREAD;
CheckValid();
@@ -187,13 +188,14 @@ bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count)
}
ASSERT(m_BufferSize >= m_WritePos);
size_t TillEnd = m_BufferSize - m_WritePos;
+ const char * Bytes = (const char *)a_Bytes;
if (TillEnd <= a_Count)
{
// Need to wrap around the ringbuffer end
if (TillEnd > 0)
{
- memcpy(m_Buffer + m_WritePos, a_Bytes, TillEnd);
- a_Bytes += TillEnd;
+ memcpy(m_Buffer + m_WritePos, Bytes, TillEnd);
+ Bytes += TillEnd;
a_Count -= TillEnd;
WrittenBytes = TillEnd;
}
@@ -203,7 +205,7 @@ bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count)
// We're guaranteed that we'll fit in a single write op
if (a_Count > 0)
{
- memcpy(m_Buffer + m_WritePos, a_Bytes, a_Count);
+ memcpy(m_Buffer + m_WritePos, Bytes, a_Count);
m_WritePos += a_Count;
WrittenBytes += a_Count;
}
@@ -326,7 +328,7 @@ bool cByteBuffer::ReadBEShort(short & a_Value)
CheckValid();
NEEDBYTES(2);
ReadBuf(&a_Value, 2);
- a_Value = ntohs(a_Value);
+ a_Value = (short)ntohs((u_short)a_Value);
return true;
}
@@ -340,7 +342,7 @@ bool cByteBuffer::ReadBEInt(int & a_Value)
CheckValid();
NEEDBYTES(4);
ReadBuf(&a_Value, 4);
- a_Value = ntohl(a_Value);
+ a_Value = (int)ntohl((u_long)a_Value);
return true;
}
@@ -419,7 +421,7 @@ bool cByteBuffer::ReadBEUTF16String16(AString & a_Value)
ASSERT(!"Negative string length? Are you sure?");
return true;
}
- return ReadUTF16String(a_Value, Length);
+ return ReadUTF16String(a_Value, (size_t)Length);
}
@@ -437,7 +439,7 @@ bool cByteBuffer::ReadVarInt(UInt32 & a_Value)
{
NEEDBYTES(1);
ReadBuf(&b, 1);
- Value = Value | (((Int64)(b & 0x7f)) << Shift);
+ Value = Value | (((UInt32)(b & 0x7f)) << Shift);
Shift += 7;
} while ((b & 0x80) != 0);
a_Value = Value;
@@ -461,7 +463,7 @@ bool cByteBuffer::ReadVarUTF8String(AString & a_Value)
{
LOGWARNING("%s: String too large: %u (%u KiB)", __FUNCTION__, Size, Size / 1024);
}
- return ReadString(a_Value, (int)Size);
+ return ReadString(a_Value, (size_t)Size);
}
@@ -516,7 +518,7 @@ bool cByteBuffer::WriteBEShort(short a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(2);
- short Converted = htons(a_Value);
+ u_short Converted = htons((u_short)a_Value);
return WriteBuf(&Converted, 2);
}
@@ -529,7 +531,7 @@ bool cByteBuffer::WriteBEInt(int a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(4);
- int Converted = HostToNetwork4(&a_Value);
+ UInt32 Converted = HostToNetwork4(&a_Value);
return WriteBuf(&Converted, 4);
}
@@ -542,7 +544,7 @@ bool cByteBuffer::WriteBEInt64(Int64 a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(8);
- Int64 Converted = HostToNetwork8(&a_Value);
+ UInt64 Converted = HostToNetwork8(&a_Value);
return WriteBuf(&Converted, 8);
}
@@ -555,7 +557,7 @@ bool cByteBuffer::WriteBEFloat(float a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(4);
- int Converted = HostToNetwork4(&a_Value);
+ UInt32 Converted = HostToNetwork4(&a_Value);
return WriteBuf(&Converted, 4);
}
@@ -568,7 +570,7 @@ bool cByteBuffer::WriteBEDouble(double a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(8);
- Int64 Converted = HostToNetwork8(&a_Value);
+ UInt64 Converted = HostToNetwork8(&a_Value);
return WriteBuf(&Converted, 8);
}
@@ -612,7 +614,7 @@ bool cByteBuffer::WriteVarInt(UInt32 a_Value)
// A 32-bit integer can be encoded by at most 5 bytes:
unsigned char b[5];
- int idx = 0;
+ size_t idx = 0;
do
{
b[idx] = (a_Value & 0x7f) | ((a_Value > 0x7f) ? 0x80 : 0x00);
@@ -631,7 +633,7 @@ bool cByteBuffer::WriteVarUTF8String(const AString & a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(a_Value.size() + 1); // This is a lower-bound on the bytes that will be actually written. Fail early.
- bool res = WriteVarInt(a_Value.size());
+ bool res = WriteVarInt((UInt32)(a_Value.size()));
if (!res)
{
return false;
@@ -756,12 +758,11 @@ bool cByteBuffer::ReadString(AString & a_String, size_t a_Count)
-bool cByteBuffer::ReadUTF16String(AString & a_String, int a_NumChars)
+bool cByteBuffer::ReadUTF16String(AString & a_String, size_t a_NumChars)
{
// Reads 2 * a_NumChars bytes and interprets it as a UTF16 string, converting it into UTF8 string a_String
CHECK_THREAD;
CheckValid();
- ASSERT(a_NumChars >= 0);
AString RawData;
if (!ReadString(RawData, a_NumChars * 2))
{
diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h
index 44f43e17f..adaa00330 100644
--- a/src/ByteBuffer.h
+++ b/src/ByteBuffer.h
@@ -30,25 +30,25 @@ public:
cByteBuffer(size_t a_BufferSize);
~cByteBuffer();
- /// Writes the bytes specified to the ringbuffer. Returns true if successful, false if not
- bool Write(const char * a_Bytes, size_t a_Count);
+ /** Writes the bytes specified to the ringbuffer. Returns true if successful, false if not */
+ bool Write(const void * a_Bytes, size_t a_Count);
- /// Returns the number of bytes that can be successfully written to the ringbuffer
+ /** Returns the number of bytes that can be successfully written to the ringbuffer */
size_t GetFreeSpace(void) const;
- /// Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes()
+ /** Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes() */
size_t GetUsedSpace(void) const;
- /// Returns the number of bytes that are currently available for reading (may be less than UsedSpace due to some data having been read already)
+ /** Returns the number of bytes that are currently available for reading (may be less than UsedSpace due to some data having been read already) */
size_t GetReadableSpace(void) const;
- /// Returns the current data start index. For debugging purposes.
+ /** Returns the current data start index. For debugging purposes. */
size_t GetDataStart(void) const { return m_DataStart; }
- /// Returns true if the specified amount of bytes are available for reading
+ /** Returns true if the specified amount of bytes are available for reading */
bool CanReadBytes(size_t a_Count) const;
- /// Returns true if the specified amount of bytes are available for writing
+ /** Returns true if the specified amount of bytes are available for writing */
bool CanWriteBytes(size_t a_Count) const;
// Read the specified datatype and advance the read pointer; return true if successfully read:
@@ -65,7 +65,7 @@ public:
bool ReadVarUTF8String (AString & a_Value); // string length as VarInt, then string as UTF-8
bool ReadLEInt (int & a_Value);
- /// Reads VarInt, assigns it to anything that can be assigned from an UInt32 (unsigned short, char, Byte, double, ...)
+ /** Reads VarInt, assigns it to anything that can be assigned from an UInt32 (unsigned short, char, Byte, double, ...) */
template <typename T> bool ReadVarInt(T & a_Value)
{
UInt32 v;
@@ -91,37 +91,37 @@ public:
bool WriteVarUTF8String (const AString & a_Value); // string length as VarInt, then string as UTF-8
bool WriteLEInt (int a_Value);
- /// Reads a_Count bytes into a_Buffer; returns true if successful
+ /** Reads a_Count bytes into a_Buffer; returns true if successful */
bool ReadBuf(void * a_Buffer, size_t a_Count);
- /// Writes a_Count bytes into a_Buffer; returns true if successful
+ /** Writes a_Count bytes into a_Buffer; returns true if successful */
bool WriteBuf(const void * a_Buffer, size_t a_Count);
- /// Reads a_Count bytes into a_String; returns true if successful
+ /** Reads a_Count bytes into a_String; returns true if successful */
bool ReadString(AString & a_String, size_t a_Count);
- /// Reads 2 * a_NumChars bytes and interprets it as a UTF16-BE string, converting it into UTF8 string a_String
- bool ReadUTF16String(AString & a_String, int a_NumChars);
+ /** Reads 2 * a_NumChars bytes and interprets it as a UTF16-BE string, converting it into UTF8 string a_String */
+ bool ReadUTF16String(AString & a_String, size_t a_NumChars);
- /// Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer
+ /** Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer */
bool SkipRead(size_t a_Count);
- /// Reads all available data into a_Data
+ /** Reads all available data into a_Data */
void ReadAll(AString & a_Data);
- /// Reads the specified number of bytes and writes it into the destinatio bytebuffer. Returns true on success.
+ /** Reads the specified number of bytes and writes it into the destinatio bytebuffer. Returns true on success. */
bool ReadToByteBuffer(cByteBuffer & a_Dst, size_t a_NumBytes);
- /// Removes the bytes that have been read from the ringbuffer
+ /** Removes the bytes that have been read from the ringbuffer */
void CommitRead(void);
- /// Restarts next reading operation at the start of the ringbuffer
+ /** Restarts next reading operation at the start of the ringbuffer */
void ResetRead(void);
- /// Re-reads the data that has been read since the last commit to the current readpos. Used by ProtoProxy to duplicate communication
+ /** Re-reads the data that has been read since the last commit to the current readpos. Used by ProtoProxy to duplicate communication */
void ReadAgain(AString & a_Out);
- /// Checks if the internal state is valid (read and write positions in the correct bounds) using ASSERTs
+ /** Checks if the internal state is valid (read and write positions in the correct bounds) using ASSERTs */
void CheckValid(void) const;
protected:
@@ -136,7 +136,7 @@ protected:
size_t m_WritePos; // Where the data ends in the ringbuffer
size_t m_ReadPos; // Where the next read will start in the ringbuffer
- /// Advances the m_ReadPos by a_Count bytes
+ /** Advances the m_ReadPos by a_Count bytes */
void AdvanceReadPos(size_t a_Count);
} ;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9fbaed926..29337cb2e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,120 +1,154 @@
cmake_minimum_required (VERSION 2.8.2)
project (MCServer)
-include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/")
-include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/jsoncpp/include")
-include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/polarssl/include")
+include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/")
+include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include")
+include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
-set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating)
-set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs)
+set(FOLDERS
+ OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ Bindings
+ WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs
+)
+SET (SRCS
+ BiomeDef.cpp
+ BlockArea.cpp
+ BlockID.cpp
+ BlockInfo.cpp
+ BoundingBox.cpp
+ ByteBuffer.cpp
+ ChatColor.cpp
+ Chunk.cpp
+ ChunkData.cpp
+ ChunkMap.cpp
+ ChunkSender.cpp
+ ChunkStay.cpp
+ ClientHandle.cpp
+ CommandOutput.cpp
+ CompositeChat.cpp
+ CraftingRecipes.cpp
+ Cuboid.cpp
+ DeadlockDetect.cpp
+ Enchantments.cpp
+ FastRandom.cpp
+ FurnaceRecipe.cpp
+ Globals.cpp
+ Group.cpp
+ GroupManager.cpp
+ Inventory.cpp
+ Item.cpp
+ ItemGrid.cpp
+ LightingThread.cpp
+ LineBlockTracer.cpp
+ LinearInterpolation.cpp
+ Log.cpp
+ MCLogger.cpp
+ Map.cpp
+ MapManager.cpp
+ MobCensus.cpp
+ MobFamilyCollecter.cpp
+ MobProximityCounter.cpp
+ MobSpawner.cpp
+ MonsterConfig.cpp
+ Noise.cpp
+ ProbabDistrib.cpp
+ RCONServer.cpp
+ Root.cpp
+ Scoreboard.cpp
+ Server.cpp
+ SetChunkData.cpp
+ Statistics.cpp
+ StringCompression.cpp
+ StringUtils.cpp
+ Tracer.cpp
+ VoronoiMap.cpp
+ WebAdmin.cpp
+ World.cpp
+ main.cpp)
+
+SET (HDRS
+ AllocationPool.h
+ BiomeDef.h
+ BlockArea.h
+ BlockID.h
+ BlockInServerPluginInterface.h
+ BlockInfo.h
+ BlockTracer.h
+ BoundingBox.h
+ ByteBuffer.h
+ ChatColor.h
+ Chunk.h
+ ChunkData.h
+ ChunkDataCallback.h
+ ChunkDef.h
+ ChunkMap.h
+ ChunkSender.h
+ ChunkStay.h
+ ClientHandle.h
+ CommandOutput.h
+ CompositeChat.h
+ CraftingRecipes.h
+ Cuboid.h
+ DeadlockDetect.h
+ Defines.h
+ Enchantments.h
+ Endianness.h
+ FastRandom.h
+ ForEachChunkProvider.h
+ FurnaceRecipe.h
+ Globals.h
+ Group.h
+ GroupManager.h
+ Inventory.h
+ Item.h
+ ItemGrid.h
+ LeakFinder.h
+ LightingThread.h
+ LineBlockTracer.h
+ LinearInterpolation.h
+ LinearUpscale.h
+ Log.h
+ MCLogger.h
+ Map.h
+ MapManager.h
+ Matrix4.h
+ MemoryLeak.h
+ MersenneTwister.h
+ MobCensus.h
+ MobFamilyCollecter.h
+ MobProximityCounter.h
+ MobSpawner.h
+ MonsterConfig.h
+ Noise.h
+ ProbabDistrib.h
+ RCONServer.h
+ Root.h
+ Scoreboard.h
+ Server.h
+ SetChunkData.h
+ StackWalker.h
+ Statistics.h
+ StringCompression.h
+ StringUtils.h
+ Tracer.h
+ Vector3.h
+ VoronoiMap.h
+ WebAdmin.h
+ World.h
+ XMLParser.h)
+
+include_directories(".")
if (NOT MSVC)
-
# Bindings need to reference other folders, so they are done here instead
-
# lib dependencies are not included
-
- set(BINDING_DEPENDECIES
- tolua
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg
- Bindings/LuaFunctions.h
- Bindings/LuaWindow.h
- Bindings/Plugin.h
- Bindings/PluginLua.h
- Bindings/PluginManager.h
- Bindings/WebPlugin.h
- BiomeDef.h
- BlockArea.h
- BlockEntities/BlockEntity.h
- BlockEntities/BlockEntityWithItems.h
- BlockEntities/ChestEntity.h
- BlockEntities/DispenserEntity.h
- BlockEntities/DropSpenserEntity.h
- BlockEntities/DropperEntity.h
- BlockEntities/FurnaceEntity.h
- BlockEntities/HopperEntity.h
- BlockEntities/JukeboxEntity.h
- BlockEntities/NoteEntity.h
- BlockEntities/SignEntity.h
- BlockEntities/MobHeadEntity.h
- BlockEntities/FlowerPotEntity.h
- BlockID.h
- BoundingBox.h
- ChatColor.h
- ChunkDef.h
- ClientHandle.h
- CraftingRecipes.h
- Cuboid.h
- Defines.h
- Enchantments.h
- Entities/Effects.h
- Entities/Entity.h
- Entities/Floater.h
- Entities/Pawn.h
- Entities/Painting.h
- Entities/Pickup.h
- Entities/Player.h
- Entities/ProjectileEntity.h
- Entities/ArrowEntity.h
- Entities/ThrownEggEntity.h
- Entities/ThrownEnderPearlEntity.h
- Entities/ExpBottleEntity.h
- Entities/ThrownSnowballEntity.h
- Entities/FireChargeEntity.h
- Entities/FireworkEntity.h
- Entities/GhastFireballEntity.h
- Entities/TNTEntity.h
- Entities/ExpOrb.h
- Entities/HangingEntity.h
- Entities/ItemFrame.h
- Generating/ChunkDesc.h
- Group.h
- Inventory.h
- Item.h
- ItemGrid.h
- Mobs/Monster.h
- OSSupport/File.h
- Root.h
- Server.h
- StringUtils.h
- Tracer.h
- UI/Window.h
- Vector3.h
- WebAdmin.h
- World.h
- )
-
- include_directories(Bindings)
- include_directories(.)
-
- ADD_CUSTOM_COMMAND(
- # add any new generated bindings here
- OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
-
- # command execuded to regerate bindings
- COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
-
- # add any new generation dependencies here
- DEPENDS ${BINDING_DEPENDECIES}
- )
- #add cpp files here
- add_library(Bindings
- Bindings/Bindings
- Bindings/DeprecatedBindings
- Bindings/LuaChunkStay
- Bindings/LuaState
- Bindings/LuaWindow
- Bindings/ManualBindings
- Bindings/Plugin
- Bindings/PluginLua
- Bindings/PluginManager
- Bindings/WebPlugin
- )
+ include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
+
+ foreach(folder ${FOLDERS})
+ add_subdirectory(${folder})
+ endforeach(folder)
- target_link_libraries(Bindings lua sqlite tolualib)
+ get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
#clear file
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt)
@@ -125,50 +159,19 @@ if (NOT MSVC)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h")
- foreach(folder ${FOLDERS})
- add_subdirectory(${folder})
- endforeach(folder)
-
- file(GLOB SOURCE
- "*.cpp"
- "*.h"
- )
-
- list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/StackWalker.cpp" "${PROJECT_SOURCE_DIR}/LeakFinder.cpp")
+ list(APPEND SOURCE "${SRCS}")
+ list(APPEND SOURCE "${HDRS}")
# If building a windows version, but not using MSVC, add the resources directly to the makefile:
if (WIN32)
- FILE(GLOB ResourceFiles
- "Resources/*.rc"
- )
- list(APPEND SOURCE "${ResourceFiles}")
+ list(APPEND SOURCE "Resources/MCServer.rc")
endif()
-
-
else ()
# MSVC-specific handling: Put all files into one project, separate by the folders:
- # Generate the Bindings if they don't exist:
- if (NOT EXISTS "${PROJECT_SOURCE_DIR}/Bindings/Bindings.cpp")
- message("Bindings.cpp not found, generating now")
- set(tolua_executable ${PROJECT_SOURCE_DIR}/Bindings/tolua++.exe)
- execute_process(
- COMMAND ${tolua_executable} -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Bindings
- )
- endif()
-
- # Get all files in this folder:
- file(GLOB_RECURSE SOURCE
- "*.cpp"
- "*.h"
- "*.pkg"
- )
- source_group("" FILES ${SOURCE})
+ source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h")
# Add all subfolders as solution-folders:
- list(APPEND FOLDERS "Resources")
- list(APPEND FOLDERS "Bindings")
function(includefolder PATH)
FILE(GLOB FOLDER_FILES
"${PATH}/*.cpp"
@@ -181,9 +184,29 @@ else ()
endfunction(includefolder)
foreach(folder ${FOLDERS})
+ add_subdirectory(${folder})
includefolder(${folder})
+
+ # Get all source files in this folder:
+ get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS)
+ foreach (src ${FOLDER_SRCS})
+ list(APPEND SOURCE "${folder}/${src}")
+ endforeach(src)
+
+ # Get all headers in this folder:
+ get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS)
+ foreach (hdr ${FOLDER_HDRS})
+ list(APPEND SOURCE "${folder}/${hdr}")
+ endforeach(hdr)
endforeach(folder)
+ list(APPEND SOURCE "${SRCS}")
+ list(APPEND SOURCE "${HDRS}")
+ list(APPEND SOURCE "Bindings/AllToLua.pkg")
+
+ includefolder("Resources")
+ source_group("" FILES ${SOURCE})
+
include_directories("${PROJECT_SOURCE_DIR}")
# Precompiled headers (1st part)
@@ -207,8 +230,47 @@ else ()
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /DEBUG")
endif()
+
+# Generate a list of all source files:
+set(ALLFILES "")
+foreach(folder ${FOLDERS})
+ get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS)
+ foreach (src ${FOLDER_SRCS})
+ list(APPEND ALLFILES "${folder}/${src}")
+ endforeach(src)
+
+ get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS)
+ foreach (hdr ${FOLDER_HDRS})
+ list(APPEND ALLFILES "${folder}/${hdr}")
+ endforeach(hdr)
+endforeach(folder)
+foreach(arg ${ALLFILES})
+ set(ALLFILESLINES "${ALLFILESLINES}${arg}\n")
+endforeach()
+FILE(WRITE "AllFiles.lst" "${ALLFILESLINES}")
+
+
set(EXECUTABLE MCServer)
+if (MSVC)
+ get_directory_property(BINDING_OUTPUTS DIRECTORY "Bindings" DEFINITION BINDING_OUTPUTS)
+ get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
+
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${BINDING_OUTPUTS}
+
+ # Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/MCServer/lua51.dll ./lua51.dll
+
+ # Regenerate bindings:
+ COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
+
+ # add any new generation dependencies here
+ DEPENDS ${BINDING_DEPENDENCIES}
+ )
+endif()
+
add_executable(${EXECUTABLE} ${SOURCE})
@@ -240,11 +302,13 @@ endif ()
if (NOT MSVC)
- target_link_libraries(${EXECUTABLE} OSSupport HTTPServer Bindings Items Blocks)
- target_link_libraries(${EXECUTABLE} Protocol Generating Generating_Prefabs WorldStorage)
- target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities)
+ target_link_libraries(${EXECUTABLE}
+ OSSupport HTTPServer Bindings Items Blocks
+ Protocol Generating Generating_Prefabs WorldStorage
+ Mobs Entities Simulator UI BlockEntities PolarSSL++
+ )
endif ()
if (WIN32)
target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib)
endif()
-target_link_libraries(${EXECUTABLE} md5 luaexpat iniFile jsoncpp polarssl zlib lua sqlite)
+target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib sqlite lua)
diff --git a/src/ChatColor.cpp b/src/ChatColor.cpp
index 72a0a6928..e1317c287 100644
--- a/src/ChatColor.cpp
+++ b/src/ChatColor.cpp
@@ -2,31 +2,31 @@
#include "ChatColor.h"
-const std::string cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8
-const std::string cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8
-const std::string cChatColor::Black = cChatColor::Color + "0";
-const std::string cChatColor::Navy = cChatColor::Color + "1";
-const std::string cChatColor::Green = cChatColor::Color + "2";
-const std::string cChatColor::Blue = cChatColor::Color + "3";
-const std::string cChatColor::Red = cChatColor::Color + "4";
-const std::string cChatColor::Purple = cChatColor::Color + "5";
-const std::string cChatColor::Gold = cChatColor::Color + "6";
-const std::string cChatColor::LightGray = cChatColor::Color + "7";
-const std::string cChatColor::Gray = cChatColor::Color + "8";
-const std::string cChatColor::DarkPurple = cChatColor::Color + "9";
-const std::string cChatColor::LightGreen = cChatColor::Color + "a";
-const std::string cChatColor::LightBlue = cChatColor::Color + "b";
-const std::string cChatColor::Rose = cChatColor::Color + "c";
-const std::string cChatColor::LightPurple = cChatColor::Color + "d";
-const std::string cChatColor::Yellow = cChatColor::Color + "e";
-const std::string cChatColor::White = cChatColor::Color + "f";
+const char * cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8
+const char * cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8
+const char * cChatColor::Black = "\xc2\xa7""0";
+const char * cChatColor::Navy = "\xc2\xa7""1";
+const char * cChatColor::Green = "\xc2\xa7""2";
+const char * cChatColor::Blue = "\xc2\xa7""3";
+const char * cChatColor::Red = "\xc2\xa7""4";
+const char * cChatColor::Purple = "\xc2\xa7""5";
+const char * cChatColor::Gold = "\xc2\xa7""6";
+const char * cChatColor::LightGray = "\xc2\xa7""7";
+const char * cChatColor::Gray = "\xc2\xa7""8";
+const char * cChatColor::DarkPurple = "\xc2\xa7""9";
+const char * cChatColor::LightGreen = "\xc2\xa7""a";
+const char * cChatColor::LightBlue = "\xc2\xa7""b";
+const char * cChatColor::Rose = "\xc2\xa7""c";
+const char * cChatColor::LightPurple = "\xc2\xa7""d";
+const char * cChatColor::Yellow = "\xc2\xa7""e";
+const char * cChatColor::White = "\xc2\xa7""f";
-const std::string cChatColor::Random = cChatColor::Color + "k";
-const std::string cChatColor::Bold = cChatColor::Color + "l";
-const std::string cChatColor::Strikethrough = cChatColor::Color + "m";
-const std::string cChatColor::Underlined = cChatColor::Color + "n";
-const std::string cChatColor::Italic = cChatColor::Color + "o";
-const std::string cChatColor::Plain = cChatColor::Color + "r";
+const char * cChatColor::Random = "\xc2\xa7""k";
+const char * cChatColor::Bold = "\xc2\xa7""l";
+const char * cChatColor::Strikethrough = "\xc2\xa7""m";
+const char * cChatColor::Underlined = "\xc2\xa7""n";
+const char * cChatColor::Italic = "\xc2\xa7""o";
+const char * cChatColor::Plain = "\xc2\xa7""r";
diff --git a/src/ChatColor.h b/src/ChatColor.h
index 643c4d5d8..21377e27f 100644
--- a/src/ChatColor.h
+++ b/src/ChatColor.h
@@ -9,34 +9,36 @@
class cChatColor
{
public:
- static const std::string Color;
- static const std::string Delimiter;
-
- static const std::string Black;
- static const std::string Navy;
- static const std::string Green;
- static const std::string Blue;
- static const std::string Red;
- static const std::string Purple;
- static const std::string Gold;
- static const std::string LightGray;
- static const std::string Gray;
- static const std::string DarkPurple;
- static const std::string LightGreen;
- static const std::string LightBlue;
- static const std::string Rose;
- static const std::string LightPurple;
- static const std::string Yellow;
- static const std::string White;
-
- // Styles ( source: http://wiki.vg/Chat )
- static const std::string Random;
- static const std::string Bold;
- static const std::string Strikethrough;
- static const std::string Underlined;
- static const std::string Italic;
- static const std::string Plain;
-
+ static const char * Delimiter;
+
+ /** @deprecated use ChatColor::Delimiter instead */
+ static const char * Color;
+
+ static const char * Black;
+ static const char * Navy;
+ static const char * Green;
+ static const char * Blue;
+ static const char * Red;
+ static const char * Purple;
+ static const char * Gold;
+ static const char * LightGray;
+ static const char * Gray;
+ static const char * DarkPurple;
+ static const char * LightGreen;
+ static const char * LightBlue;
+ static const char * Rose;
+ static const char * LightPurple;
+ static const char * Yellow;
+ static const char * White;
+
+ // Styles
+ // source: http://wiki.vg/Chat
+ static const char * Random;
+ static const char * Bold;
+ static const char * Strikethrough;
+ static const char * Underlined;
+ static const char * Italic;
+ static const char * Plain;
};
// tolua_end
diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua
new file mode 100644
index 000000000..13a6d15d2
--- /dev/null
+++ b/src/CheckBasicStyle.lua
@@ -0,0 +1,212 @@
+#!/usr/bin/env lua
+
+-- CheckBasicStyle.lua
+
+--[[
+Checks that all source files (*.cpp, *.h) use the basic style requirements of the project:
+ - Tabs for indentation, spaces for alignment
+ - Trailing whitespace on non-empty lines
+ - Two spaces between code and line-end comment ("//")
+ - Spaces after comma, not before
+ - Opening braces not at the end of a code line
+ - Spaces after if, for, while
+ - (TODO) Spaces before *, /, &
+ - (TODO) Hex numbers with even digit length
+ - (TODO) Hex numbers in lowercase
+ - (TODO) Line dividers (////...) exactly 80 slashes
+ - (TODO) Not using "* "-style doxy comment continuation lines
+
+Violations that cannot be checked easily:
+ - Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables)
+
+Reports all violations on stdout in a form that is readable by Visual Studio's parser, so that dblclicking
+the line brings the editor directly to the violation.
+
+Returns 0 on success, 1 on internal failure, 2 if any violations found
+
+--]]
+
+
+
+
+
+-- The list of file extensions that are processed:
+local g_ShouldProcessExt =
+{
+ ["h"] = true,
+ ["cpp"] = true,
+}
+
+--- The list of files not to be processed:
+local g_IgnoredFiles =
+{
+ "Bindings/Bindings.cpp",
+ "LeakFinder.cpp",
+ "LeakFinder.h",
+ "MersenneTwister.h",
+ "StackWalker.cpp",
+ "StackWalker.h",
+}
+
+--- The list of files not to be processed, as a dictionary (filename => true), built from g_IgnoredFiles
+local g_ShouldIgnoreFile = {}
+
+-- Initialize the g_ShouldIgnoreFile map:
+for _, fnam in ipairs(g_IgnoredFiles) do
+ g_ShouldIgnoreFile[fnam] = true
+end
+
+--- Keeps track of the number of violations for this folder
+local g_NumViolations = 0
+
+
+
+
+
+--- Reports one violation
+-- Pretty-prints the message
+-- Also increments g_NumViolations
+local function ReportViolation(a_FileName, a_LineNumber, a_PatStart, a_PatEnd, a_Message)
+ print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_PatStart .. " .. " .. a_PatEnd .. ": " .. a_Message)
+ g_NumViolations = g_NumViolations + 1
+end
+
+
+
+
+
+--- Searches for the specified pattern, if found, reports it as a violation with the given message
+local function ReportViolationIfFound(a_Line, a_FileName, a_LineNum, a_Pattern, a_Message)
+ local patStart, patEnd = a_Line:find(a_Pattern)
+ if not(patStart) then
+ return
+ end
+ ReportViolation(a_FileName, a_LineNum, patStart, patEnd, a_Message)
+end
+
+
+
+
+
+local g_ViolationPatterns =
+{
+ -- Check against indenting using spaces:
+ {"^\t* +", "Indenting with a space"},
+
+ -- Check against alignment using tabs:
+ {"[^%s]\t+[^%s]", "Aligning with a tab"},
+
+ -- Check against trailing whitespace:
+ {"[^%s]%s+\n", "Trailing whitespace"},
+
+ -- Check that all "//"-style comments have at least two spaces in front (unless alone on line):
+ {"[^%s] //", "Needs at least two spaces in front of a \"//\"-style comment"},
+
+ -- Check that all "//"-style comments have at least one spaces after:
+ {"%s//[^%s/*<]", "Needs a space after a \"//\"-style comment"},
+
+ -- Check that all commas have spaces after them and not in front of them:
+ {" ,", "Extra space before a \",\""},
+ {",[^%s\"%%]", "Needs a space after a \",\""}, -- Report all except >> "," << needed for splitting and >>,%s<< needed for formatting
+
+ -- Check that opening braces are not at the end of a code line:
+ {"[^%s].-{\n?$", "Brace should be on a separate line"},
+
+ -- Space after keywords:
+ {"[^_]if%(", "Needs a space after \"if\""},
+ {"for%(", "Needs a space after \"for\""},
+ {"while%(", "Needs a space after \"while\""},
+ {"switch%(", "Needs a space after \"switch\""},
+ {"catch%(", "Needs a space after \"catch\""},
+
+ -- No space after keyword's parenthesis:
+ {"[^%a#]if %( ", "Remove the space after \"(\""},
+ {"for %( ", "Remove the space after \"(\""},
+ {"while %( ", "Remove the space after \"(\""},
+ {"catch %( ", "Remove the space after \"(\""},
+
+ -- No space before a closing parenthesis:
+ {" %)", "Remove the space before \")\""},
+}
+
+
+
+
+
+--- Processes one file
+local function ProcessFile(a_FileName)
+ assert(type(a_FileName) == "string")
+
+ -- Read the whole file:
+ local f, err = io.open(a_FileName, "r")
+ if (f == nil) then
+ print("Cannot open file \"" .. a_FileName .. "\": " .. err)
+ print("Aborting")
+ os.exit(1)
+ end
+ local all = f:read("*all")
+
+ -- Check that the last line is empty - otherwise processing won't work properly:
+ local lastChar = string.byte(all, string.len(all))
+ if ((lastChar ~= 13) and (lastChar ~= 10)) then
+ local numLines = 1
+ string.gsub(all, "\n", function() numLines = numLines + 1 end) -- Count the number of line-ends
+ ReportViolation(a_FileName, numLines, 1, 1, "Missing empty line at file end")
+ return
+ end
+
+ -- Process each line separately:
+ -- Ref.: http://stackoverflow.com/questions/10416869/iterate-over-possibly-empty-lines-in-a-way-that-matches-the-expectations-of-exis
+ local lineCounter = 1
+ all:gsub("\r\n", "\n") -- normalize CRLF into LF-only
+ string.gsub(all .. "\n", "[^\n]*\n", -- Iterate over each line, while preserving empty lines
+ function(a_Line)
+ -- Check against each violation pattern:
+ for _, pat in ipairs(g_ViolationPatterns) do
+ ReportViolationIfFound(a_Line, a_FileName, lineCounter, pat[1], pat[2])
+ end
+
+ lineCounter = lineCounter + 1
+ end
+ )
+end
+
+
+
+
+
+--- Processes one item - a file or a folder
+local function ProcessItem(a_ItemName)
+ assert(type(a_ItemName) == "string")
+
+ -- Skip files / folders that should be ignored
+ if (g_ShouldIgnoreFile[a_ItemName]) then
+ return
+ end
+
+ local ext = a_ItemName:match("%.([^/%.]-)$")
+ if (g_ShouldProcessExt[ext]) then
+ ProcessFile(a_ItemName)
+ end
+end
+
+
+
+
+
+-- Process all files in the AllFiles.lst file (generated by cmake):
+for fnam in io.lines("AllFiles.lst") do
+ ProcessItem(fnam)
+end
+
+-- Report final verdict:
+print("Number of violations found: " .. g_NumViolations)
+if (g_NumViolations > 0) then
+ os.exit(2)
+else
+ os.exit(0)
+end
+
+
+
+
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index cd3bceda2..b83036b6d 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -34,6 +34,7 @@
#include "MobCensus.h"
#include "MobSpawner.h"
#include "BlockInServerPluginInterface.h"
+#include "SetChunkData.h"
#include "json/json.h"
@@ -41,15 +42,15 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// sSetBlock:
-sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) // absolute block position
- : x( a_BlockX )
- , y( a_BlockY )
- , z( a_BlockZ )
- , BlockType( a_BlockType )
- , BlockMeta( a_BlockMeta )
+sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) // absolute block position
+ : x( a_BlockX)
+ , y( a_BlockY)
+ , z( a_BlockZ)
+ , BlockType( a_BlockType)
+ , BlockMeta( a_BlockMeta)
{
cChunkDef::AbsoluteToRelative(x, y, z, ChunkX, ChunkZ);
}
@@ -58,13 +59,14 @@ sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_Bloc
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cChunk:
cChunk::cChunk(
- int a_ChunkX, int a_ChunkY, int a_ChunkZ,
+ int a_ChunkX, int a_ChunkY, int a_ChunkZ,
cChunkMap * a_ChunkMap, cWorld * a_World,
- cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP
+ cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP,
+ cAllocationPool<cChunkData::sChunkSection> & a_Pool
) :
m_IsValid(false),
m_IsLightValid(false),
@@ -77,6 +79,7 @@ cChunk::cChunk(
m_PosZ(a_ChunkZ),
m_World(a_World),
m_ChunkMap(a_ChunkMap),
+ m_ChunkData(a_Pool),
m_BlockTickX(0),
m_BlockTickY(0),
m_BlockTickZ(0),
@@ -85,7 +88,8 @@ cChunk::cChunk(
m_NeighborZM(a_NeighborZM),
m_NeighborZP(a_NeighborZP),
m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()),
- m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData())
+ m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()),
+ m_AlwaysTicked(0)
{
if (a_NeighborXM != NULL)
{
@@ -113,7 +117,7 @@ cChunk::~cChunk()
{
cPluginManager::Get()->CallHookChunkUnloaded(m_World, m_PosX, m_PosZ);
- // LOGINFO("### delete cChunk() (%i, %i) from %p, thread 0x%x ###", m_PosX, m_PosZ, this, GetCurrentThreadId() );
+ // LOGINFO("### delete cChunk() (%i, %i) from %p, thread 0x%x ###", m_PosX, m_PosZ, this, GetCurrentThreadId());
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
{
@@ -150,7 +154,9 @@ cChunk::~cChunk()
m_NeighborZP->m_NeighborZM = NULL;
}
delete m_WaterSimulatorData;
+ m_WaterSimulatorData = NULL;
delete m_LavaSimulatorData;
+ m_LavaSimulatorData = NULL;
}
@@ -238,26 +244,12 @@ void cChunk::MarkLoadFailed(void)
void cChunk::GetAllData(cChunkDataCallback & a_Callback)
{
- a_Callback.HeightMap (&m_HeightMap);
- a_Callback.BiomeData (&m_BiomeMap);
+ a_Callback.HeightMap(&m_HeightMap);
+ a_Callback.BiomeData(&m_BiomeMap);
- COMPRESSED_BLOCKTYPE Blocks = m_BlockTypes;
- Blocks.resize(NumBlocks);
- a_Callback.BlockTypes (&Blocks[0]);
+ a_Callback.LightIsValid(m_IsLightValid);
- COMPRESSED_NIBBLETYPE Metas = m_BlockMeta;
- Metas.resize(NumBlocks / 2);
- a_Callback.BlockMeta (&Metas[0]);
-
- a_Callback.LightIsValid (m_IsLightValid);
-
- COMPRESSED_NIBBLETYPE BlockLights = m_BlockLight;
- BlockLights.resize(NumBlocks / 2);
- a_Callback.BlockLight (&BlockLights[0]);
-
- COMPRESSED_NIBBLETYPE BlockSkyLights = m_BlockSkyLight;
- BlockSkyLights.resize(NumBlocks / 2, 0xff);
- a_Callback.BlockSkyLight(&BlockSkyLights[0]);
+ a_Callback.ChunkData(m_ChunkData);
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
@@ -274,79 +266,34 @@ void cChunk::GetAllData(cChunkDataCallback & a_Callback)
-void cChunk::SetAllData(
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const HeightMap * a_HeightMap,
- const BiomeMap & a_BiomeMap,
- cBlockEntityList & a_BlockEntities
-)
+void cChunk::SetAllData(cSetChunkData & a_SetChunkData)
{
- memcpy(m_BiomeMap, a_BiomeMap, sizeof(m_BiomeMap));
-
- if (a_HeightMap != NULL)
- {
- memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap));
- }
-
- if (a_HeightMap == NULL)
- {
- CalculateHeightmap(a_BlockTypes);
- }
-
- int IdxWhereNonEmptyStarts = 0;
- { // Blocktype compression
- unsigned char Highest = 0;
- int X = 0, Z = 0;
- m_BlockTypes.clear();
-
- for (int x = 0; x < Width; x++)
- {
- for (int z = 0; z < Width; z++)
- {
- unsigned char Height = m_HeightMap[x + z * Width];
- if (Height > Highest)
- {
- Highest = Height;
- X = x; Z = z;
- }
- }
- }
-
- IdxWhereNonEmptyStarts = MakeIndexNoCheck(X, Highest + 1, Z);
-
- m_BlockTypes.insert(m_BlockTypes.end(), &a_BlockTypes[0], &a_BlockTypes[IdxWhereNonEmptyStarts]);
- }
-
- { // Blockmeta compression
- m_BlockMeta.clear();
- m_BlockMeta.insert(m_BlockMeta.end(), &a_BlockMeta[0], &a_BlockMeta[IdxWhereNonEmptyStarts / 2]);
- }
+ ASSERT(a_SetChunkData.IsHeightMapValid());
+ ASSERT(a_SetChunkData.AreBiomesValid());
- if (a_BlockLight != NULL)
+ memcpy(m_BiomeMap, a_SetChunkData.GetBiomes(), sizeof(m_BiomeMap));
+ memcpy(m_HeightMap, a_SetChunkData.GetHeightMap(), sizeof(m_HeightMap));
+
+ m_ChunkData.SetBlockTypes(a_SetChunkData.GetBlockTypes());
+ m_ChunkData.SetMetas(a_SetChunkData.GetBlockMetas());
+ if (a_SetChunkData.IsLightValid())
{
- // Compress blocklight
- m_BlockLight.clear();
- m_BlockLight.insert(m_BlockLight.end(), &a_BlockLight[0], &a_BlockLight[IdxWhereNonEmptyStarts / 2]);
+ m_ChunkData.SetBlockLight(a_SetChunkData.GetBlockLight());
+ m_ChunkData.SetSkyLight(a_SetChunkData.GetSkyLight());
+ m_IsLightValid = true;
}
-
- if (a_BlockSkyLight != NULL)
+ else
{
- // Compress skylight
- m_BlockSkyLight.clear();
- m_BlockSkyLight.insert(m_BlockSkyLight.end(), &a_BlockSkyLight[0], &a_BlockSkyLight[IdxWhereNonEmptyStarts / 2]);
+ m_IsLightValid = false;
}
-
- m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL);
// Clear the block entities present - either the loader / saver has better, or we'll create empty ones:
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
{
delete *itr;
}
- std::swap(a_BlockEntities, m_BlockEntities);
+ m_BlockEntities.clear();
+ std::swap(a_SetChunkData.GetBlockEntities(), m_BlockEntities);
// Set all block entities' World variable:
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
@@ -378,15 +325,9 @@ void cChunk::SetLight(
// TODO: We might get cases of wrong lighting when a chunk changes in the middle of a lighting calculation.
// Postponing until we see how bad it is :)
- { // Compress blocklight
- m_BlockLight.clear();
- m_BlockLight.insert(m_BlockLight.end(), &a_BlockLight[0], &a_BlockLight[m_BlockTypes.size()]);
- }
+ m_ChunkData.SetBlockLight(a_BlockLight);
- { // Compress skylight
- m_BlockSkyLight.clear();
- m_BlockSkyLight.insert(m_BlockSkyLight.end(), &a_SkyLight[0], &a_SkyLight[m_BlockTypes.size()]);
- }
+ m_ChunkData.SetSkyLight(a_SkyLight);
m_IsLightValid = true;
}
@@ -397,8 +338,7 @@ void cChunk::SetLight(
void cChunk::GetBlockTypes(BLOCKTYPE * a_BlockTypes)
{
- std::copy(m_BlockTypes.begin(), m_BlockTypes.end(), a_BlockTypes);
- std::fill_n(&a_BlockTypes[m_BlockTypes.size()], NumBlocks - m_BlockTypes.size(), E_BLOCK_AIR);
+ m_ChunkData.CopyBlockTypes(a_BlockTypes);
}
@@ -497,19 +437,19 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
{
currentPlayer = (*itr)->GetPlayer();
playerPositions.push_back(&(currentPlayer->GetPosition()));
- }
+ }
Vector3d currentPosition;
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
- //LOGD("Counting entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass());
+ // LOGD("Counting entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass());
if ((*itr)->IsMob())
{
cMonster& Monster = (cMonster&)(**itr);
currentPosition = Monster.GetPosition();
for (std::list<const Vector3d*>::const_iterator itr2 = playerPositions.begin(); itr2 != playerPositions.end(); ++itr2)
{
- toFill.CollectMob(Monster,*this,(currentPosition-**itr2).SqrLength());
+ toFill.CollectMob(Monster, *this, (currentPosition - **itr2).SqrLength());
}
}
} // for itr - m_Entitites[]
@@ -518,7 +458,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
-void cChunk::getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a_MaxY, int a_MaxZ)
+void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX, int a_MaxY, int a_MaxZ)
{
ASSERT(a_MaxX * a_MaxY * a_MaxZ * 8 < 0x00ffffff);
int Random = m_World->GetTickRandomNumber(0x00ffffff);
@@ -534,12 +474,12 @@ void cChunk::getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a
-void cChunk::getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z)
+void cChunk::GetRandomBlockCoords(int & a_X, int & a_Y, int & a_Z)
{
// MG TODO : check if this kind of optimization (only one random call) is still needed
// MG TODO : if so propagate it
- getThreeRandomNumber(a_X, a_Y, a_Z, Width, Height-2, Width);
+ GetThreeRandomNumbers(a_X, a_Y, a_Z, Width, Height - 2, Width);
a_Y++;
}
@@ -549,65 +489,68 @@ void cChunk::getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z)
void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner)
{
- int Center_X,Center_Y,Center_Z;
- getRandomBlockCoords(Center_X,Center_Y,Center_Z);
-
- BLOCKTYPE PackCenterBlock = GetBlock(Center_X, Center_Y, Center_Z);
- if (a_MobSpawner.CheckPackCenter(PackCenterBlock))
- {
- a_MobSpawner.NewPack();
- int NumberOfTries = 0;
- int NumberOfSuccess = 0;
- int MaxNbOfSuccess = 4; // this can be changed during the process for Wolves and Ghass
- while (NumberOfTries < 12 && NumberOfSuccess < MaxNbOfSuccess)
- {
- const int HorizontalRange = 20; // MG TODO : relocate
- const int VerticalRange = 0; // MG TODO : relocate
- int Try_X, Try_Y, Try_Z;
- getThreeRandomNumber(Try_X, Try_Y, Try_Z, 2*HorizontalRange+1 , 2*VerticalRange+1 , 2*HorizontalRange+1);
- Try_X -= HorizontalRange;
- Try_Y -= VerticalRange;
- Try_Z -= HorizontalRange;
- Try_X += Center_X;
- Try_Y += Center_Y;
- Try_Z += Center_Z;
-
- ASSERT(Try_Y > 0);
- ASSERT(Try_Y < cChunkDef::Height-1);
-
- EMCSBiome Biome = m_ChunkMap->GetBiomeAt (Try_X, Try_Z);
- // MG TODO :
- // Moon cycle (for slime)
- // check player and playerspawn presence < 24 blocks
- // check mobs presence on the block
-
- // MG TODO : check that "Level" really means Y
-
- /*
- NIBBLETYPE SkyLight = 0;
+ int CenterX, CenterY, CenterZ;
+ GetRandomBlockCoords(CenterX, CenterY, CenterZ);
- NIBBLETYPE BlockLight = 0;
- */
-
- if (IsLightValid())
- {
- cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, MaxNbOfSuccess);
- if (newMob)
- {
- int WorldX, WorldY, WorldZ;
- PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ);
- double ActualX = WorldX + 0.5;
- double ActualZ = WorldZ + 0.5;
- newMob->SetPosition(ActualX, WorldY, ActualZ);
- LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ);
- NumberOfSuccess++;
- }
- }
-
- NumberOfTries++;
- }
+ BLOCKTYPE PackCenterBlock = GetBlock(CenterX, CenterY, CenterZ);
+ if (!a_MobSpawner.CheckPackCenter(PackCenterBlock))
+ {
+ return;
}
+
+ a_MobSpawner.NewPack();
+ int NumberOfTries = 0;
+ int NumberOfSuccess = 0;
+ int MaxNbOfSuccess = 4; // This can be changed during the process for Wolves and Ghasts
+ while ((NumberOfTries < 12) && (NumberOfSuccess < MaxNbOfSuccess))
+ {
+ const int HorizontalRange = 20; // MG TODO : relocate
+ const int VerticalRange = 0; // MG TODO : relocate
+ int TryX, TryY, TryZ;
+ GetThreeRandomNumbers(TryX, TryY, TryZ, 2 * HorizontalRange + 1, 2 * VerticalRange + 1, 2 * HorizontalRange + 1);
+ TryX -= HorizontalRange;
+ TryY -= VerticalRange;
+ TryZ -= HorizontalRange;
+ TryX += CenterX;
+ TryY += CenterY;
+ TryZ += CenterZ;
+
+ ASSERT(TryY > 0);
+ ASSERT(TryY < cChunkDef::Height - 1);
+
+ EMCSBiome Biome = m_ChunkMap->GetBiomeAt(TryX, TryZ);
+ // MG TODO :
+ // Moon cycle (for slime)
+ // check player and playerspawn presence < 24 blocks
+ // check mobs presence on the block
+
+ // MG TODO : check that "Level" really means Y
+
+ /*
+ NIBBLETYPE SkyLight = 0;
+
+ NIBBLETYPE BlockLight = 0;
+ */
+ NumberOfTries++;
+ if (!IsLightValid())
+ {
+ continue;
+ }
+
+ cEntity * newMob = a_MobSpawner.TryToSpawnHere(this, TryX, TryY, TryZ, Biome, MaxNbOfSuccess);
+ if (newMob == NULL)
+ {
+ continue;
+ }
+ int WorldX, WorldY, WorldZ;
+ PositionToWorldPosition(TryX, TryY, TryZ, WorldX, WorldY, WorldZ);
+ double ActualX = WorldX + 0.5;
+ double ActualZ = WorldZ + 0.5;
+ newMob->SetPosition(ActualX, WorldY, ActualZ);
+ LOGD("Spawning %s #%i at {%d, %d, %d}", newMob->GetClass(), newMob->GetUniqueID(), WorldX, WorldY, WorldZ);
+ NumberOfSuccess++;
+ } // while (retry)
}
@@ -634,38 +577,34 @@ void cChunk::Tick(float a_Dt)
m_IsDirty = (*itr)->Tick(a_Dt, *this) | m_IsDirty;
}
- // Tick all entities in this chunk (except mobs):
- for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
- {
- // Mobs are tickes inside MobTick (as we don't have to tick them if they are far away from players)
- if (!((*itr)->IsMob()))
+ for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();)
+ {
+ if (!((*itr)->IsMob())) // Mobs are ticked inside cWorld::TickMobs() (as we don't have to tick them if they are far away from players)
{
+ // Tick all entities in this chunk (except mobs):
(*itr)->Tick(a_Dt, *this);
}
- } // for itr - m_Entitites[]
-
- // Remove all entities that were scheduled for removal:
- for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();)
- {
- if ((*itr)->IsDestroyed())
- {
- LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass());
- cEntity * ToDelete = *itr;
- itr = m_Entities.erase(itr);
- delete ToDelete;
- continue;
- }
- ++itr;
- } // for itr - m_Entitites[]
-
- // If any entity moved out of the chunk, move it to the neighbor:
- for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();)
- {
- if (
+
+ if ((*itr)->IsDestroyed()) // Remove all entities that were scheduled for removal:
+ {
+ LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass());
+ MarkDirty();
+ cEntity * ToDelete = *itr;
+ itr = m_Entities.erase(itr);
+ delete ToDelete;
+ }
+ else if ((*itr)->IsWorldTravellingFrom(m_World)) // Remove all entities that are travelling to another world:
+ {
+ MarkDirty();
+ (*itr)->SetWorldTravellingFrom(NULL);
+ itr = m_Entities.erase(itr);
+ }
+ else if ( // If any entity moved out of the chunk, move it to the neighbor:
((*itr)->GetChunkX() != m_PosX) ||
((*itr)->GetChunkZ() != m_PosZ)
)
{
+ MarkDirty();
MoveEntityToNewChunk(*itr);
itr = m_Entities.erase(itr);
}
@@ -673,7 +612,7 @@ void cChunk::Tick(float a_Dt)
{
++itr;
}
- }
+ } // for itr - m_Entitites[]
ApplyWeatherToTop();
}
@@ -684,12 +623,11 @@ void cChunk::Tick(float a_Dt)
void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ)
{
- unsigned Index = MakeIndex(a_RelX, a_RelY, a_RelZ);
- cBlockHandler * Handler = BlockHandler(GetBlock(Index));
+ cBlockHandler * Handler = BlockHandler(GetBlock(a_RelX, a_RelY, a_RelZ));
ASSERT(Handler != NULL); // Happenned on server restart, FS #243
cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap());
cBlockInServerPluginInterface PluginInterface(*this->GetWorld());
- Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface,*this, a_RelX, a_RelY, a_RelZ);
+ Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelX, a_RelY, a_RelZ);
}
@@ -749,13 +687,13 @@ void cChunk::ProcessQueuedSetBlocks(void)
{
if (itr->m_Tick <= CurrTick)
{
- if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to -1 if not specified
+ if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to 0 if not specified
{
if (GetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ) == itr->m_PreviousType)
{
// Current world age is bigger than/equal to target world age - delay time reached AND
// Previous block type was the same as current block type (to prevent duplication)
- SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); // SetMeta doesn't send to client
+ SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); // SetMeta doesn't send to client
itr = m_SetBlockQueue.erase(itr);
LOGD("Successfully set queued block - previous and current types matched");
}
@@ -810,19 +748,18 @@ void cChunk::CheckBlocks()
{
return;
}
- std::vector<unsigned int> ToTickBlocks;
+ std::vector<Vector3i> ToTickBlocks;
std::swap(m_ToTickBlocks, ToTickBlocks);
cChunkInterface ChunkInterface(m_World->GetChunkMap());
cBlockInServerPluginInterface PluginInterface(*m_World);
- for (std::vector<unsigned int>::const_iterator itr = ToTickBlocks.begin(), end = ToTickBlocks.end(); itr != end; ++itr)
+ for (std::vector<Vector3i>::const_iterator itr = ToTickBlocks.begin(), end = ToTickBlocks.end(); itr != end; ++itr)
{
- unsigned int index = (*itr);
- Vector3i BlockPos = IndexToCoordinate(index);
+ Vector3i Pos = (*itr);
- cBlockHandler * Handler = BlockHandler(GetBlock(index));
- Handler->Check(ChunkInterface, PluginInterface, BlockPos.x, BlockPos.y, BlockPos.z, *this);
+ cBlockHandler * Handler = BlockHandler(GetBlock(Pos));
+ Handler->Check(ChunkInterface, PluginInterface, Pos.x, Pos.y, Pos.z, *this);
} // for itr - ToTickBlocks[]
}
@@ -833,7 +770,7 @@ void cChunk::CheckBlocks()
void cChunk::TickBlocks(void)
{
// Tick dem blocks
- // _X: We must limit the random number or else we get a nasty int overflow bug ( http://forum.mc-server.org/showthread.php?tid=457 )
+ // _X: We must limit the random number or else we get a nasty int overflow bug - http://forum.mc-server.org/showthread.php?tid=457
int RandomX = m_World->GetTickRandomNumber(0x00ffffff);
int RandomY = m_World->GetTickRandomNumber(0x00ffffff);
int RandomZ = m_World->GetTickRandomNumber(0x00ffffff);
@@ -862,11 +799,10 @@ void cChunk::TickBlocks(void)
if (m_BlockTickY > cChunkDef::GetHeight(m_HeightMap, m_BlockTickX, m_BlockTickZ))
{
- continue; // It's all air up here
+ continue; // It's all air up here
}
- unsigned int Index = MakeIndexNoCheck(m_BlockTickX, m_BlockTickY, m_BlockTickZ);
- cBlockHandler * Handler = BlockHandler(GetBlock(Index));
+ cBlockHandler * Handler = BlockHandler(GetBlock(m_BlockTickX, m_BlockTickY, m_BlockTickZ));
ASSERT(Handler != NULL); // Happenned on server restart, FS #243
Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, m_BlockTickX, m_BlockTickY, m_BlockTickZ);
} // for i - tickblocks
@@ -948,7 +884,7 @@ void cChunk::ApplyWeatherToTop()
SetBlock(X, Height, Z, E_BLOCK_ICE, 0);
}
else if (
- (m_World->IsDeepSnowEnabled()) &&
+ (m_World->IsDeepSnowEnabled()) &&
(
(TopBlock == E_BLOCK_RED_ROSE) ||
(TopBlock == E_BLOCK_YELLOW_FLOWER) ||
@@ -961,7 +897,6 @@ void cChunk::ApplyWeatherToTop()
}
break;
} // case (snowy biomes)
- // TODO: Rainy biomes should check for farmland and cauldrons
default:
{
break;
@@ -997,10 +932,10 @@ void cChunk::GrowMelonPumpkin(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Bl
IsValid = IsValid && UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ + 1, BlockType[2], BlockMeta);
IsValid = IsValid && UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ - 1, BlockType[3], BlockMeta);
if (
- !IsValid ||
- (BlockType[0] == ProduceType) ||
- (BlockType[1] == ProduceType) ||
- (BlockType[2] == ProduceType) ||
+ !IsValid ||
+ (BlockType[0] == ProduceType) ||
+ (BlockType[1] == ProduceType) ||
+ (BlockType[2] == ProduceType) ||
(BlockType[3] == ProduceType)
)
{
@@ -1258,9 +1193,8 @@ bool cChunk::UnboundedRelGetBlockLights(int a_RelX, int a_RelY, int a_RelZ, NIBB
// The chunk is not available, bail out
return false;
}
- int idx = Chunk->MakeIndex(a_RelX, a_RelY, a_RelZ);
- a_BlockLight = Chunk->GetBlockLight(idx);
- a_SkyLight = Chunk->GetSkyLight(idx);
+ a_BlockLight = Chunk->GetBlockLight(a_RelX, a_RelY, a_RelZ);
+ a_SkyLight = Chunk->GetSkyLight(a_RelX, a_RelY, a_RelZ);
return true;
}
@@ -1283,7 +1217,7 @@ bool cChunk::UnboundedRelSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE
}
Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta);
return true;
-}
+}
@@ -1355,6 +1289,7 @@ void cChunk::CreateBlockEntities(void)
switch (BlockType)
{
case E_BLOCK_BEACON:
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
case E_BLOCK_COMMAND_BLOCK:
case E_BLOCK_DISPENSER:
@@ -1447,10 +1382,10 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes)
{
for (int y = Height - 1; y > -1; y--)
{
- int index = MakeIndex( x, y, z );
+ int index = MakeIndex( x, y, z);
if (a_BlockTypes[index] != E_BLOCK_AIR)
{
- m_HeightMap[x + z * Width] = (unsigned char)y;
+ m_HeightMap[x + z * Width] = (HEIGHTTYPE)y;
break;
}
} // for y
@@ -1462,14 +1397,12 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes)
-void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients)
{
- FastSetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta);
-
- const int index = MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
+ FastSetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta, a_SendToClients);
// Tick this block and its neighbors:
- m_ToTickBlocks.push_back(index);
+ m_ToTickBlocks.push_back(Vector3i(a_RelX, a_RelY, a_RelZ));
QueueTickBlockNeighbors(a_RelX, a_RelY, a_RelZ);
// If there was a block entity, remove it:
@@ -1480,12 +1413,14 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType,
BlockEntity->Destroy();
RemoveBlockEntity(BlockEntity);
delete BlockEntity;
+ BlockEntity = NULL;
}
// If the new block is a block entity, create the entity object:
switch (a_BlockType)
{
case E_BLOCK_BEACON:
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
case E_BLOCK_COMMAND_BLOCK:
case E_BLOCK_DISPENSER:
@@ -1533,7 +1468,7 @@ void cChunk::QueueTickBlock(int a_RelX, int a_RelY, int a_RelZ)
return;
}
- m_ToTickBlocks.push_back(MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ));
+ m_ToTickBlocks.push_back(Vector3i(a_RelX, a_RelY, a_RelZ));
}
@@ -1565,43 +1500,42 @@ void cChunk::QueueTickBlockNeighbors(int a_RelX, int a_RelY, int a_RelZ)
-void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
+void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients)
{
ASSERT(!((a_RelX < 0) || (a_RelX >= Width) || (a_RelY < 0) || (a_RelY >= Height) || (a_RelZ < 0) || (a_RelZ >= Width)));
ASSERT(IsValid());
- const int index = MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
- const BLOCKTYPE OldBlockType = GetBlock(index);
- const BLOCKTYPE OldBlockMeta = GetNibble(m_BlockMeta, index);
+ const BLOCKTYPE OldBlockType = GetBlock(a_RelX, a_RelY, a_RelZ);
+ const BLOCKTYPE OldBlockMeta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
if ((OldBlockType == a_BlockType) && (OldBlockMeta == a_BlockMeta))
{
return;
}
MarkDirty();
+ m_IsRedstoneDirty = true;
- if ((size_t)index >= m_BlockTypes.size())
- {
- m_BlockTypes.resize(index + 1);
- }
- m_BlockTypes[index] = a_BlockType;
+ m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType);
- // The client doesn't need to distinguish between stationary and nonstationary fluids:
+ // Queue block to be sent only if ...
if (
- (OldBlockMeta != a_BlockMeta) || // Different meta always gets sent to the client
- !(
- ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water
- ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water
- ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water
- ((OldBlockType == E_BLOCK_LAVA) && (a_BlockType == E_BLOCK_STATIONARY_LAVA)) // Replacing water with stationary water
+ a_SendToClients && // ... we are told to do so AND ...
+ (
+ (OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ...
+ !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them):
+ ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water
+ ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water
+ ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water
+ ((OldBlockType == E_BLOCK_LAVA) && (a_BlockType == E_BLOCK_STATIONARY_LAVA)) // Replacing water with stationary water
+ )
)
)
{
m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta));
}
- SetNibble(m_BlockMeta, index, a_BlockMeta);
+ m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_BlockMeta);
// ONLY recalculate lighting if it's necessary!
if (
@@ -1618,15 +1552,15 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
{
if (a_BlockType != E_BLOCK_AIR)
{
- m_HeightMap[a_RelX + a_RelZ * Width] = (unsigned char)a_RelY;
+ m_HeightMap[a_RelX + a_RelZ * Width] = (HEIGHTTYPE)a_RelY;
}
else
{
for (int y = a_RelY - 1; y > 0; --y)
{
- if (GetBlock(MakeIndexNoCheck(a_RelX, y, a_RelZ)) != E_BLOCK_AIR)
+ if (GetBlock(a_RelX, y, a_RelZ) != E_BLOCK_AIR)
{
- m_HeightMap[a_RelX + a_RelZ * Width] = (unsigned char)y;
+ m_HeightMap[a_RelX + a_RelZ * Width] = (HEIGHTTYPE)y;
break;
}
} // for y - column in m_BlockData
@@ -1640,19 +1574,16 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client)
{
- // The coords must be valid, because the upper level already does chunk lookup. No need to check them again.
- // There's an debug-time assert in MakeIndexNoCheck anyway
- unsigned int index = MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
if (a_Client == NULL)
{
// Queue the block for all clients in the chunk (will be sent in Tick())
- m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(index), GetMeta(index)));
+ m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ)));
return;
}
Vector3i wp = PositionToWorldPosition(a_RelX, a_RelY, a_RelZ);
- a_Client->SendBlockChange(wp.x, wp.y, wp.z, GetBlock(index), GetMeta(index));
+ a_Client->SendBlockChange(wp.x, wp.y, wp.z, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ));
// FS #268 - if a BlockEntity digging is cancelled by a plugin, the entire block entity must be re-sent to the client:
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), end = m_BlockEntities.end(); itr != end; ++itr)
@@ -1680,6 +1611,12 @@ void cChunk::AddBlockEntity(cBlockEntity * a_BlockEntity)
cBlockEntity * cChunk::GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ)
{
+ // Check that the query coords are within chunk bounds:
+ ASSERT(a_BlockX >= m_PosX * cChunkDef::Width);
+ ASSERT(a_BlockX < m_PosX * cChunkDef::Width + cChunkDef::Width);
+ ASSERT(a_BlockZ >= m_PosZ * cChunkDef::Width);
+ ASSERT(a_BlockZ < m_PosZ * cChunkDef::Width + cChunkDef::Width);
+
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
{
if (
@@ -1699,6 +1636,31 @@ cBlockEntity * cChunk::GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ)
+bool cChunk::ShouldBeTicked(void) const
+{
+ return (HasAnyClients() || (m_AlwaysTicked > 0));
+}
+
+
+
+
+
+void cChunk::SetAlwaysTicked(bool a_AlwaysTicked)
+{
+ if (a_AlwaysTicked)
+ {
+ m_AlwaysTicked += 1;
+ }
+ else
+ {
+ m_AlwaysTicked -= 1;
+ }
+}
+
+
+
+
+
void cChunk::UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z)
{
cBlockEntity * be = GetBlockEntity(a_X, a_Y, a_Z);
@@ -1754,11 +1716,11 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player)
{
if ((!(*itr)->IsPickup()) && (!(*itr)->IsProjectile()))
{
- continue; // Only pickups and projectiles
+ continue; // Only pickups and projectiles can be picked up
}
- float DiffX = (float)((*itr)->GetPosX() - PosX );
- float DiffY = (float)((*itr)->GetPosY() - PosY );
- float DiffZ = (float)((*itr)->GetPosZ() - PosZ );
+ float DiffX = (float)((*itr)->GetPosX() - PosX);
+ float DiffY = (float)((*itr)->GetPosY() - PosY);
+ float DiffZ = (float)((*itr)->GetPosZ() - PosZ);
float SqrDist = DiffX * DiffX + DiffY * DiffY + DiffZ * DiffZ;
if (SqrDist < 1.5f * 1.5f) // 1.5 block
{
@@ -1820,7 +1782,7 @@ bool cChunk::SetSignLines(int a_PosX, int a_PosY, int a_PosZ, const AString & a_
-void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity )
+void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity)
{
MarkDirty();
m_BlockEntities.remove(a_BlockEntity);
@@ -1830,7 +1792,7 @@ void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity )
-bool cChunk::AddClient(cClientHandle* a_Client)
+bool cChunk::AddClient(cClientHandle * a_Client)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
@@ -1840,9 +1802,9 @@ bool cChunk::AddClient(cClientHandle* a_Client)
return false;
}
}
- m_LoadedByClient.push_back( a_Client );
+ m_LoadedByClient.push_back( a_Client);
- for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr )
+ for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
/*
// DEBUG:
@@ -1861,7 +1823,7 @@ bool cChunk::AddClient(cClientHandle* a_Client)
-void cChunk::RemoveClient( cClientHandle* a_Client )
+void cChunk::RemoveClient(cClientHandle * a_Client)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
@@ -1869,12 +1831,12 @@ void cChunk::RemoveClient( cClientHandle* a_Client )
{
continue;
}
-
+
m_LoadedByClient.erase(itr);
if (!a_Client->IsDestroyed())
{
- for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr )
+ for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
/*
// DEBUG:
@@ -1894,7 +1856,7 @@ void cChunk::RemoveClient( cClientHandle* a_Client )
-bool cChunk::HasClient( cClientHandle* a_Client )
+bool cChunk::HasClient(cClientHandle * a_Client)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
@@ -1910,7 +1872,7 @@ bool cChunk::HasClient( cClientHandle* a_Client )
-bool cChunk::HasAnyClients(void)
+bool cChunk::HasAnyClients(void) const
{
return !m_LoadedByClient.empty();
}
@@ -1925,9 +1887,9 @@ void cChunk::AddEntity(cEntity * a_Entity)
{
MarkDirty();
}
-
+
ASSERT(std::find(m_Entities.begin(), m_Entities.end(), a_Entity) == m_Entities.end()); // Not there already
-
+
m_Entities.push_back(a_Entity);
}
@@ -1937,17 +1899,12 @@ void cChunk::AddEntity(cEntity * a_Entity)
void cChunk::RemoveEntity(cEntity * a_Entity)
{
- size_t SizeBefore = m_Entities.size();
m_Entities.remove(a_Entity);
- size_t SizeAfter = m_Entities.size();
-
- if (SizeBefore != SizeAfter)
+
+ // Mark as dirty if it was a server-generated entity:
+ if (!a_Entity->IsPlayer())
{
- // Mark as dirty if it was a server-generated entity:
- if (!a_Entity->IsPlayer())
- {
- MarkDirty();
- }
+ MarkDirty();
}
}
@@ -2179,7 +2136,7 @@ bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb
{
continue;
}
- if ((*itr)->GetBlockType() != E_BLOCK_CHEST)
+ if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) // Trapped chests use normal chests' handlers
{
// There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out
return false;
@@ -2321,7 +2278,7 @@ bool cChunk::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceC
}
} // switch (BlockType)
- // The correct block entity is here,
+ // The correct block entity is here,
if (a_Callback.Item((cFurnaceEntity *)*itr))
{
return false;
@@ -2353,7 +2310,7 @@ bool cChunk::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBl
return false;
}
- // The correct block entity is here,
+ // The correct block entity is here
if (a_Callback.Item((cNoteEntity *)*itr))
{
return false;
@@ -2385,7 +2342,7 @@ bool cChunk::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCom
return false;
}
- // The correct block entity is here,
+ // The correct block entity is here,
if (a_Callback.Item((cCommandBlockEntity *)*itr))
{
return false;
@@ -2417,7 +2374,7 @@ bool cChunk::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadC
return false;
}
- // The correct block entity is here,
+ // The correct block entity is here,
if (a_Callback.Item((cMobHeadEntity *)*itr))
{
return false;
@@ -2449,7 +2406,7 @@ bool cChunk::DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlower
return false;
}
- // The correct block entity is here,
+ // The correct block entity is here
if (a_Callback.Item((cFlowerPotEntity *)*itr))
{
return false;
@@ -2502,36 +2459,16 @@ bool cChunk::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_
BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
{
if (
- (a_RelX < 0) || (a_RelX >= Width) ||
+ (a_RelX < 0) || (a_RelX >= Width) ||
(a_RelY < 0) || (a_RelY >= Height) ||
(a_RelZ < 0) || (a_RelZ >= Width)
)
{
ASSERT(!"GetBlock(x, y, z) out of bounds!");
- return 0; // Clip
- }
-
- return GetBlock(MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ));
-}
-
-
-
-
-
-BLOCKTYPE cChunk::GetBlock(int a_BlockIdx) const
-{
- if ((a_BlockIdx < 0) || (a_BlockIdx >= NumBlocks))
- {
- ASSERT(!"GetBlock(idx) out of bounds!");
- return 0;
- }
-
- if ((size_t)a_BlockIdx >= m_BlockTypes.size())
- {
- return E_BLOCK_AIR;
+ return 0; // Clip
}
- return m_BlockTypes[a_BlockIdx];
+ return m_ChunkData.GetBlock(a_RelX, a_RelY, a_RelZ);
}
@@ -2540,9 +2477,8 @@ BLOCKTYPE cChunk::GetBlock(int a_BlockIdx) const
void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
- int Idx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
- a_BlockType = GetBlock(Idx);
- a_BlockMeta = cChunkDef::GetNibble(m_BlockMeta, Idx);
+ a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ);
+ a_BlockMeta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
}
@@ -2551,11 +2487,10 @@ void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_
void cChunk::GetBlockInfo(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight)
{
- int Idx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
- a_BlockType = GetBlock(Idx);
- a_Meta = cChunkDef::GetNibble(m_BlockMeta, Idx);
- a_SkyLight = cChunkDef::GetNibble(m_BlockSkyLight, Idx);
- a_BlockLight = cChunkDef::GetNibble(m_BlockLight, Idx);
+ a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ);
+ a_Meta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
+ a_SkyLight = m_ChunkData.GetSkyLight(a_RelX, a_RelY, a_RelZ);
+ a_BlockLight = m_ChunkData.GetBlockLight(a_RelX, a_RelY, a_RelZ);
}
@@ -2581,8 +2516,8 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
{
int BlockX = m_PosX * cChunkDef::Width + a_RelX;
int BlockZ = m_PosZ * cChunkDef::Width + a_RelZ;
- int BlockY, ChunkX, ChunkZ;
- AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
+ int ChunkX, ChunkZ;
+ BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
return m_ChunkMap->GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
}
@@ -2701,7 +2636,7 @@ cChunk * cChunk::GetRelNeighborChunkAdjustCoords(int & a_RelX, int & a_RelZ) con
void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
(*itr)->SendAttachEntity(a_Entity, a_Vehicle);
} // for itr - LoadedByClient[]
@@ -2713,7 +2648,7 @@ void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_V
void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2729,7 +2664,7 @@ void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char
void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2751,7 +2686,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons
{
return;
}
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2767,7 +2702,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons
void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2781,15 +2716,15 @@ void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClie
-void cChunk::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
+void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
continue;
}
- (*itr)->SendCollectPickup(a_Pickup, a_Player);
+ (*itr)->SendCollectEntity(a_Entity, a_Player);
} // for itr - LoadedByClient[]
}
@@ -2799,7 +2734,7 @@ void cChunk::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_
void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2815,7 +2750,7 @@ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl
void cChunk::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2831,7 +2766,7 @@ void cChunk::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int
void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2847,7 +2782,7 @@ void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum,
void cChunk::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2863,7 +2798,7 @@ void cChunk::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHand
void cChunk::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2879,7 +2814,7 @@ void cChunk::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle *
void cChunk::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2895,7 +2830,7 @@ void cChunk::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHand
void cChunk::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2911,7 +2846,7 @@ void cChunk::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char
void cChunk::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2927,7 +2862,7 @@ void cChunk::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, c
void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2943,7 +2878,7 @@ void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, cons
void cChunk::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2959,7 +2894,7 @@ void cChunk::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHand
void cChunk::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2975,7 +2910,7 @@ void cChunk::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation
void cChunk::BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -2991,7 +2926,7 @@ void cChunk::BroadcastParticleEffect(const AString & a_ParticleName, float a_Src
void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -3005,15 +2940,15 @@ void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectI
-void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
continue;
}
- (*itr)->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
+ (*itr)->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch);
} // for itr - LoadedByClient[]
}
@@ -3023,7 +2958,7 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a
void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -3039,7 +2974,7 @@ void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY
void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -3055,7 +2990,7 @@ void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Ex
void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@@ -3069,9 +3004,9 @@ void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, cons
-void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
+void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
{
- for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
(*itr)->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
} // for itr - LoadedByClient[]
diff --git a/src/Chunk.h b/src/Chunk.h
index a15d43e00..7eee3999c 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -3,6 +3,7 @@
#include "Entities/Entity.h"
#include "ChunkDef.h"
+#include "ChunkData.h"
#include "Simulator/FireSimulator.h"
#include "Simulator/SandSimulator.h"
@@ -64,8 +65,10 @@ public:
cChunk(
int a_ChunkX, int a_ChunkY, int a_ChunkZ, // Chunk coords
cChunkMap * a_ChunkMap, cWorld * a_World, // Parent objects
- cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP // Neighbor chunks
+ cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP, // Neighbor chunks
+ cAllocationPool<cChunkData::sChunkSection> & a_Pool
);
+ cChunk(cChunk & other);
~cChunk();
bool IsValid(void) const {return m_IsValid; } // Returns true if the chunk block data is valid (loaded / generated)
@@ -79,12 +82,12 @@ public:
/*
To save a chunk, the WSSchema must:
- 1. Mark the chunk as being saved (MarkSaving() )
+ 1. Mark the chunk as being saved (MarkSaving())
2. Get the chunk's data using GetAllData()
- 3. Mark the chunk as saved (MarkSaved() )
+ 3. Mark the chunk as saved (MarkSaved())
If anywhere inside this sequence another thread mmodifies the chunk, the chunk will not get marked as saved in MarkSaved()
*/
- void MarkSaving(void); // Marks the chunk as being saved.
+ void MarkSaving(void); // Marks the chunk as being saved.
void MarkSaved(void); // Marks the chunk as saved, if it didn't change from the last call to MarkSaving()
void MarkLoaded(void); // Marks the chunk as freshly loaded. Fails if the chunk is already valid
void MarkLoadFailed(void); // Marks the chunk as failed to load. Ignored is the chunk is already valid
@@ -92,16 +95,10 @@ public:
/** Gets all chunk data, calls the a_Callback's methods for each data type */
void GetAllData(cChunkDataCallback & a_Callback);
- /** Sets all chunk data */
- void SetAllData(
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap & a_BiomeMap,
- cBlockEntityList & a_BlockEntities
- );
+ /** Sets all chunk data as either loaded from the storage or generated.
+ BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
+ Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk. */
+ void SetAllData(cSetChunkData & a_SetChunkData);
void SetLight(
const cChunkDef::BlockNibbles & a_BlockLight,
@@ -139,9 +136,9 @@ public:
cWorld * GetWorld(void) const { return m_World; }
- void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta );
+ void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true);
// SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense
- void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta ); }
+ void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta); }
/** Queues a block change till the specified world tick */
void QueueSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR);
@@ -152,9 +149,9 @@ public:
/** Queues all 6 neighbors of the specified block for ticking (m_ToTickQueue). If any are outside the chunk, relays the checking to the proper neighboring chunk */
void QueueTickBlockNeighbors(int a_RelX, int a_RelY, int a_RelZ);
- void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta ); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc.
+ void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc.
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const;
- BLOCKTYPE GetBlock(int a_BlockIdx) const;
+ BLOCKTYPE GetBlock(Vector3i a_cords) const { return GetBlock(a_cords.x, a_cords.y, a_cords.z);}
void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
void GetBlockInfo (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);
@@ -192,16 +189,21 @@ public:
/** Sets the sign text. Returns true if successful. Also sends update packets to all clients in the chunk */
bool SetSignLines(int a_RelX, int a_RelY, int a_RelZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
- int GetHeight( int a_X, int a_Z );
+ int GetHeight( int a_X, int a_Z);
void SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client);
/** Adds a client to the chunk; returns true if added, false if already there */
- bool AddClient (cClientHandle* a_Client );
+ bool AddClient(cClientHandle * a_Client);
+
+ /** Removes the specified client from the chunk; ignored if client not in chunk. */
+ void RemoveClient(cClientHandle * a_Client);
+
+ /** Returns true if the specified client is present in this chunk. */
+ bool HasClient(cClientHandle * a_Client);
- void RemoveClient (cClientHandle* a_Client );
- bool HasClient (cClientHandle* a_Client );
- bool HasAnyClients(void); // Returns true if theres any client in the chunk; false otherwise
+ /** Returns true if theres any client in the chunk; false otherwise */
+ bool HasAnyClients(void) const;
void AddEntity(cEntity * a_Entity);
void RemoveEntity(cEntity * a_Entity);
@@ -266,7 +268,6 @@ public:
void UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z); // [x, y, z] in world block coords
- void CalculateLighting(); // Recalculate right now
void CalculateHeightmap(const BLOCKTYPE * a_BlockTypes);
// Broadcast various packets to all clients of this chunk:
@@ -276,7 +277,7 @@ public:
void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
- void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
+ void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
@@ -290,11 +291,11 @@ public:
void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL);
void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL);
- void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
+ void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
- void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
+ void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ);
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
@@ -304,7 +305,7 @@ public:
}
void PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ, int & a_BlockX, int & a_BlockY, int & a_BlockZ);
- Vector3i PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ );
+ Vector3i PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ);
inline void MarkDirty(void)
{
@@ -320,15 +321,24 @@ public:
m_BlockTickZ = a_RelZ;
}
- inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ); }
- inline NIBBLETYPE GetMeta(int a_BlockIdx) const {return cChunkDef::GetNibble(m_BlockMeta, a_BlockIdx); }
- inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) { cChunkDef::SetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ, a_Meta); }
- inline void SetMeta(int a_BlockIdx, NIBBLETYPE a_Meta) { cChunkDef::SetNibble(m_BlockMeta, a_BlockIdx, a_Meta); }
+ inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
+ {
+ return m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
+ }
+ inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
+ {
+ bool hasChanged = m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta);
+ if (hasChanged)
+ {
+ MarkDirty();
+ m_IsRedstoneDirty = true;
+
+ m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), a_Meta));
+ }
+ }
- inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockLight, a_RelX, a_RelY, a_RelZ); }
- inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return cChunkDef::GetNibble(m_BlockSkyLight, a_RelX, a_RelY, a_RelZ, true); }
- inline NIBBLETYPE GetBlockLight(int a_Idx) const {return cChunkDef::GetNibble(m_BlockLight, a_Idx); }
- inline NIBBLETYPE GetSkyLight (int a_Idx) const {return cChunkDef::GetNibble(m_BlockSkyLight, a_Idx, true); }
+ inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkData.GetBlockLight(a_RelX, a_RelY, a_RelZ); }
+ inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkData.GetSkyLight(a_RelX, a_RelY, a_RelZ); }
/** Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case); returns true on success */
bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
@@ -368,13 +378,27 @@ public:
cSandSimulatorChunkData & GetSandSimulatorData (void) { return m_SandSimulatorData; }
cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return &m_RedstoneSimulatorData; }
+ cRedstoneSimulatorChunkData * GetRedstoneSimulatorQueuedData(void) { return &m_RedstoneSimulatorQueuedData; }
cIncrementalRedstoneSimulator::PoweredBlocksList * GetRedstoneSimulatorPoweredBlocksList(void) { return &m_RedstoneSimulatorPoweredBlocksList; }
- cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; };
- cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; };
- cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; };
+ cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; }
+ cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; }
+ cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; }
+ bool IsRedstoneDirty(void) const { return m_IsRedstoneDirty; }
+ void SetIsRedstoneDirty(bool a_Flag) { m_IsRedstoneDirty = a_Flag; }
cBlockEntity * GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
cBlockEntity * GetBlockEntity(const Vector3i & a_BlockPos) { return GetBlockEntity(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); }
+
+ /** Returns true if the chunk should be ticked in the tick-thread.
+ Checks if there are any clients and if the always-tick flag is set */
+ bool ShouldBeTicked(void) const;
+
+ /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter.
+ If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of
+ whether it has any clients or not.
+ This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long
+ as at least one requests is active the chunk will be ticked). */
+ void SetAlwaysTicked(bool a_AlwaysTicked);
private:
@@ -403,8 +427,8 @@ private:
bool m_IsSaving; // True if the chunk is being saved
bool m_HasLoadFailed; // True if chunk failed to load and hasn't been generated yet since then
- std::vector<unsigned int> m_ToTickBlocks;
- sSetBlockVector m_PendingSendBlocks; ///< Blocks that have changed and need to be sent to all clients
+ std::vector<Vector3i> m_ToTickBlocks;
+ sSetBlockVector m_PendingSendBlocks; ///< Blocks that have changed and need to be sent to all clients
sSetBlockQueueVector m_SetBlockQueue; ///< Block changes that are queued to a specific tick
@@ -420,11 +444,7 @@ private:
cWorld * m_World;
cChunkMap * m_ChunkMap;
- // TODO: Make these pointers and don't allocate what isn't needed
- COMPRESSED_BLOCKTYPE m_BlockTypes;
- COMPRESSED_NIBBLETYPE m_BlockMeta;
- COMPRESSED_NIBBLETYPE m_BlockLight;
- COMPRESSED_NIBBLETYPE m_BlockSkyLight;
+ cChunkData m_ChunkData;
cChunkDef::HeightMap m_HeightMap;
cChunkDef::BiomeMap m_BiomeMap;
@@ -443,15 +463,24 @@ private:
cSandSimulatorChunkData m_SandSimulatorData;
cRedstoneSimulatorChunkData m_RedstoneSimulatorData;
+ cRedstoneSimulatorChunkData m_RedstoneSimulatorQueuedData;
cIncrementalRedstoneSimulator::PoweredBlocksList m_RedstoneSimulatorPoweredBlocksList;
cIncrementalRedstoneSimulator::LinkedBlocksList m_RedstoneSimulatorLinkedBlocksList;
cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList m_RedstoneSimulatorSimulatedPlayerToggleableList;
cIncrementalRedstoneSimulator::RepeatersDelayList m_RedstoneSimulatorRepeatersDelayList;
+ /** Indicates if simulate-once blocks should be updated by the redstone simulator */
+ bool m_IsRedstoneDirty;
+
+ /** If greater than zero, the chunk is ticked even if it has no clients.
+ Manipulated by the SetAlwaysTicked() function, allows for nested calls of the function.
+ This is the support for plugin-accessible chunk tick forcing. */
+ int m_AlwaysTicked;
+
- // pick up a random block of this chunk
- void getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z);
- void getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a_MaxY, int a_MaxZ);
+ // Pick up a random block of this chunk
+ void GetRandomBlockCoords(int & a_X, int & a_Y, int & a_Z);
+ void GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX, int a_MaxY, int a_MaxZ);
void RemoveBlockEntity(cBlockEntity * a_BlockEntity);
void AddBlockEntity (cBlockEntity * a_BlockEntity);
diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp
new file mode 100644
index 000000000..03b0224a6
--- /dev/null
+++ b/src/ChunkData.cpp
@@ -0,0 +1,595 @@
+
+// ChunkData.cpp
+
+// Implements the cChunkData class that represents the block's type, meta, blocklight and skylight storage for a chunk
+
+#include "Globals.h"
+#include "ChunkData.h"
+
+
+
+
+
+/** Returns true if all a_Array's elements between [0] and [a_NumElements - 1] are equal to a_Value. */
+template <typename T> inline bool IsAllValue(const T * a_Array, size_t a_NumElements, T a_Value)
+{
+ for (size_t i = 0; i < a_NumElements; i++)
+ {
+ if (a_Array[i] != a_Value)
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+
+
+
+cChunkData::cChunkData(cAllocationPool<cChunkData::sChunkSection> & a_Pool) :
+#if __cplusplus < 201103L
+ // auto_ptr style interface for memory management
+ m_IsOwner(true),
+#endif
+ m_Pool(a_Pool)
+{
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ m_Sections[i] = NULL;
+ }
+}
+
+
+
+
+
+cChunkData::~cChunkData()
+{
+ #if __cplusplus < 201103L
+ // auto_ptr style interface for memory management
+ if (!m_IsOwner)
+ {
+ return;
+ }
+ #endif
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ Free(m_Sections[i]);
+ m_Sections[i] = NULL;
+ }
+}
+
+
+
+
+
+#if __cplusplus < 201103L
+ // auto_ptr style interface for memory management
+ cChunkData::cChunkData(const cChunkData & a_Other) :
+ m_IsOwner(true),
+ m_Pool(a_Other.m_Pool)
+ {
+ // Move contents and ownership from a_Other to this, pointer-wise:
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ m_Sections[i] = a_Other.m_Sections[i];
+ }
+ a_Other.m_IsOwner = false;
+ }
+
+
+
+
+
+ cChunkData & cChunkData::operator =(const cChunkData & a_Other)
+ {
+ // If assigning to self, no-op
+ if (&a_Other == this)
+ {
+ return *this;
+ }
+
+ // Free any currently held contents:
+ if (m_IsOwner)
+ {
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ Free(m_Sections[i]);
+ m_Sections[i] = NULL;
+ }
+ }
+
+ // Move contents and ownership from a_Other to this, pointer-wise:
+ m_IsOwner = true;
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ m_Sections[i] = a_Other.m_Sections[i];
+ }
+ a_Other.m_IsOwner = false;
+ ASSERT(&m_Pool == &a_Other.m_Pool);
+ return *this;
+ }
+
+#else
+
+ // unique_ptr style interface for memory management
+ cChunkData::cChunkData(cChunkData && other) :
+ m_Pool(other.m_Pool)
+ {
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ m_Sections[i] = other.m_Sections[i];
+ other.m_Sections[i] = NULL;
+ }
+ }
+
+
+
+
+
+ cChunkData & cChunkData::operator =(cChunkData && other)
+ {
+ if (&other != this)
+ {
+ ASSERT(&m_Pool == &other.m_Pool);
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ Free(m_Sections[i]);
+ m_Sections[i] = other.m_Sections[i];
+ other.m_Sections[i] = NULL;
+ }
+ }
+ return *this;
+ }
+#endif
+
+
+
+
+
+BLOCKTYPE cChunkData::GetBlock(int a_X, int a_Y, int a_Z) const
+{
+ ASSERT((a_X >= 0) && (a_X < cChunkDef::Width));
+ ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height));
+ ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width));
+ int Section = a_Y / SectionHeight;
+ if (m_Sections[Section] != NULL)
+ {
+ int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * SectionHeight), a_Z);
+ return m_Sections[Section]->m_BlockTypes[Index];
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+
+
+
+
+void cChunkData::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block)
+{
+ if (
+ (a_RelX >= cChunkDef::Width) || (a_RelX < 0) ||
+ (a_RelY >= cChunkDef::Height) || (a_RelY < 0) ||
+ (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0)
+ )
+ {
+ ASSERT(!"cChunkData::SetMeta(): index out of range!");
+ return;
+ }
+
+ int Section = a_RelY / SectionHeight;
+ if (m_Sections[Section] == NULL)
+ {
+ if (a_Block == 0x00)
+ {
+ return;
+ }
+ m_Sections[Section] = Allocate();
+ if (m_Sections[Section] == NULL)
+ {
+ ASSERT(!"Failed to allocate a new section in Chunkbuffer");
+ return;
+ }
+ ZeroSection(m_Sections[Section]);
+ }
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ m_Sections[Section]->m_BlockTypes[Index] = a_Block;
+}
+
+
+
+
+
+NIBBLETYPE cChunkData::GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
+{
+ if (
+ (a_RelX < cChunkDef::Width) && (a_RelX > -1) &&
+ (a_RelY < cChunkDef::Height) && (a_RelY > -1) &&
+ (a_RelZ < cChunkDef::Width) && (a_RelZ > -1))
+ {
+ int Section = a_RelY / SectionHeight;
+ if (m_Sections[Section] != NULL)
+ {
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ return (m_Sections[Section]->m_BlockMetas[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!");
+ return 0;
+}
+
+
+
+
+
+bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble)
+{
+ if (
+ (a_RelX >= cChunkDef::Width) || (a_RelX < 0) ||
+ (a_RelY >= cChunkDef::Height) || (a_RelY < 0) ||
+ (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0)
+ )
+ {
+ ASSERT(!"cChunkData::SetMeta(): index out of range!");
+ return false;
+ }
+
+ int Section = a_RelY / SectionHeight;
+ if (m_Sections[Section] == NULL)
+ {
+ if ((a_Nibble & 0xf) == 0x00)
+ {
+ return false;
+ }
+ m_Sections[Section] = Allocate();
+ if (m_Sections[Section] == NULL)
+ {
+ ASSERT(!"Failed to allocate a new section in Chunkbuffer");
+ return false;
+ }
+ ZeroSection(m_Sections[Section]);
+ }
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ NIBBLETYPE oldval = m_Sections[Section]->m_BlockMetas[Index / 2] >> ((Index & 1) * 4) & 0xf;
+ m_Sections[Section]->m_BlockMetas[Index / 2] = static_cast<NIBBLETYPE>(
+ (m_Sections[Section]->m_BlockMetas[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble
+ ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set
+ );
+ return oldval != a_Nibble;
+}
+
+
+
+
+
+NIBBLETYPE cChunkData::GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const
+{
+ if (
+ (a_RelX < cChunkDef::Width) && (a_RelX > -1) &&
+ (a_RelY < cChunkDef::Height) && (a_RelY > -1) &&
+ (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)
+ )
+ {
+ int Section = a_RelY / SectionHeight;
+ if (m_Sections[Section] != NULL)
+ {
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!");
+ return 0;
+}
+
+
+
+
+
+NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const
+{
+ if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1))
+ {
+ int Section = a_RelY / SectionHeight;
+ if (m_Sections[Section] != NULL)
+ {
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ return (m_Sections[Section]->m_BlockSkyLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
+ }
+ else
+ {
+ return 0xF;
+ }
+ }
+ ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!");
+ return 0;
+}
+
+
+
+
+
+cChunkData cChunkData::Copy(void) const
+{
+ cChunkData copy(m_Pool);
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ if (m_Sections[i] != NULL)
+ {
+ copy.m_Sections[i] = copy.Allocate();
+ *copy.m_Sections[i] = *m_Sections[i];
+ }
+ }
+ return copy;
+}
+
+
+
+
+
+void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) const
+{
+ size_t ToSkip = a_Idx;
+
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ size_t StartPos = 0;
+ if (ToSkip > 0)
+ {
+ StartPos = std::min(ToSkip, +SectionBlockCount);
+ ToSkip -= StartPos;
+ }
+ if (StartPos < SectionBlockCount)
+ {
+ size_t ToCopy = std::min(+SectionBlockCount - StartPos, a_Length);
+ a_Length -= ToCopy;
+ if (m_Sections[i] != NULL)
+ {
+ BLOCKTYPE * blockbuffer = m_Sections[i]->m_BlockTypes;
+ memcpy(&a_Dest[(i * SectionBlockCount) + StartPos - a_Idx], blockbuffer + StartPos, sizeof(BLOCKTYPE) * ToCopy);
+ }
+ else
+ {
+ memset(&a_Dest[(i * SectionBlockCount) - a_Idx], 0, sizeof(BLOCKTYPE) * ToCopy);
+ }
+ }
+ }
+}
+
+
+
+
+
+void cChunkData::CopyMetas(NIBBLETYPE * a_Dest) const
+{
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ if (m_Sections[i] != NULL)
+ {
+ memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockMetas, sizeof(m_Sections[i]->m_BlockMetas));
+ }
+ else
+ {
+ memset(&a_Dest[i * SectionBlockCount / 2], 0, sizeof(m_Sections[i]->m_BlockMetas));
+ }
+ }
+}
+
+
+
+
+
+void cChunkData::CopyBlockLight(NIBBLETYPE * a_Dest) const
+{
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ if (m_Sections[i] != NULL)
+ {
+ memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockLight, sizeof(m_Sections[i]->m_BlockLight));
+ }
+ else
+ {
+ memset(&a_Dest[i * SectionBlockCount / 2], 0, sizeof(m_Sections[i]->m_BlockLight));
+ }
+ }
+}
+
+
+
+
+
+void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const
+{
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ if (m_Sections[i] != NULL)
+ {
+ memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockSkyLight, sizeof(m_Sections[i]->m_BlockSkyLight));
+ }
+ else
+ {
+ memset(&a_Dest[i * SectionBlockCount / 2], 0xff, sizeof(m_Sections[i]->m_BlockSkyLight));
+ }
+ }
+}
+
+
+
+
+
+void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src)
+{
+ ASSERT(a_Src != NULL);
+
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ // If the section is already allocated, copy the data into it:
+ if (m_Sections[i] != NULL)
+ {
+ memcpy(m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes));
+ continue;
+ }
+
+ // The section doesn't exist, find out if it is needed:
+ if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, (const BLOCKTYPE)0))
+ {
+ // No need for the section, the data is all-air
+ continue;
+ }
+
+ // Allocate the section and copy the data into it:
+ m_Sections[i] = Allocate();
+ memcpy(m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes));
+ memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas));
+ memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight));
+ memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight));
+ } // for i - m_Sections[]
+}
+
+
+
+
+void cChunkData::SetMetas(const NIBBLETYPE * a_Src)
+{
+ ASSERT(a_Src != NULL);
+
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ // If the section is already allocated, copy the data into it:
+ if (m_Sections[i] != NULL)
+ {
+ memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockMetas));
+ continue;
+ }
+
+ // The section doesn't exist, find out if it is needed:
+ if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, (NIBBLETYPE)0))
+ {
+ // No need for the section, the data is all zeroes
+ continue;
+ }
+
+ // Allocate the section and copy the data into it:
+ m_Sections[i] = Allocate();
+ memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockMetas));
+ memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes));
+ memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight));
+ memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight));
+ } // for i - m_Sections[]
+}
+
+
+
+
+
+void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src)
+{
+ if (a_Src == NULL)
+ {
+ return;
+ }
+
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ // If the section is already allocated, copy the data into it:
+ if (m_Sections[i] != NULL)
+ {
+ memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockLight));
+ continue;
+ }
+
+ // The section doesn't exist, find out if it is needed:
+ if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, (NIBBLETYPE)0))
+ {
+ // No need for the section, the data is all zeroes
+ continue;
+ }
+
+ // Allocate the section and copy the data into it:
+ m_Sections[i] = Allocate();
+ memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockLight));
+ memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes));
+ memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas));
+ memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight));
+ } // for i - m_Sections[]
+}
+
+
+
+
+void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src)
+{
+ if (a_Src == NULL)
+ {
+ return;
+ }
+
+ for (size_t i = 0; i < NumSections; i++)
+ {
+ // If the section is already allocated, copy the data into it:
+ if (m_Sections[i] != NULL)
+ {
+ memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockSkyLight));
+ continue;
+ }
+
+ // The section doesn't exist, find out if it is needed:
+ if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, (NIBBLETYPE)0xff))
+ {
+ // No need for the section, the data is all zeroes
+ continue;
+ }
+
+ // Allocate the section and copy the data into it:
+ m_Sections[i] = Allocate();
+ memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockSkyLight));
+ memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes));
+ memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas));
+ memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight));
+ } // for i - m_Sections[]
+}
+
+
+
+
+
+cChunkData::sChunkSection * cChunkData::Allocate(void)
+{
+ return m_Pool.Allocate();
+}
+
+
+
+
+
+void cChunkData::Free(cChunkData::sChunkSection * a_Section)
+{
+ m_Pool.Free(a_Section);
+}
+
+
+
+
+
+void cChunkData::ZeroSection(cChunkData::sChunkSection * a_Section) const
+{
+ memset(a_Section->m_BlockTypes, 0x00, sizeof(a_Section->m_BlockTypes));
+ memset(a_Section->m_BlockMetas, 0x00, sizeof(a_Section->m_BlockMetas));
+ memset(a_Section->m_BlockLight, 0x00, sizeof(a_Section->m_BlockLight));
+ memset(a_Section->m_BlockSkyLight, 0xff, sizeof(a_Section->m_BlockSkyLight));
+}
+
+
+
+
diff --git a/src/ChunkData.h b/src/ChunkData.h
new file mode 100644
index 000000000..fe8b068a2
--- /dev/null
+++ b/src/ChunkData.h
@@ -0,0 +1,133 @@
+
+// ChunkData.h
+
+// Declares the cChunkData class that represents the block's type, meta, blocklight and skylight storage for a chunk
+
+
+
+
+
+#pragma once
+
+
+#include <cstring>
+
+
+#include "ChunkDef.h"
+
+#include "AllocationPool.h"
+
+
+
+#if __cplusplus < 201103L
+// auto_ptr style interface for memory management
+#else
+// unique_ptr style interface for memory management
+#endif
+
+class cChunkData
+{
+private:
+
+ static const size_t SectionHeight = 16;
+ static const size_t NumSections = (cChunkDef::Height / SectionHeight);
+ static const size_t SectionBlockCount = SectionHeight * cChunkDef::Width * cChunkDef::Width;
+
+public:
+
+ struct sChunkSection;
+
+ cChunkData(cAllocationPool<cChunkData::sChunkSection> & a_Pool);
+ ~cChunkData();
+
+ #if __cplusplus < 201103L
+ // auto_ptr style interface for memory management
+ cChunkData(const cChunkData & a_Other);
+ cChunkData & operator =(const cChunkData & a_Other);
+ #else
+ // unique_ptr style interface for memory management
+ cChunkData(cChunkData && a_Other);
+ cChunkData & operator =(cChunkData && a_ther);
+ #endif
+
+ BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z) const;
+ void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block);
+
+ NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const;
+ bool SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble);
+
+ NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const;
+
+ NIBBLETYPE GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const;
+
+ /** Creates a (deep) copy of self. */
+ cChunkData Copy(void) const;
+
+ /** Copies the blocktype data into the specified flat array.
+ Optionally, only a part of the data is copied, as specified by the a_Idx and a_Length parameters. */
+ void CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx = 0, size_t a_Length = cChunkDef::NumBlocks) const;
+
+ /** Copies the metadata into the specified flat array. */
+ void CopyMetas(NIBBLETYPE * a_Dest) const;
+
+ /** Copies the block light data into the specified flat array. */
+ void CopyBlockLight(NIBBLETYPE * a_Dest) const;
+
+ /** Copies the skylight data into the specified flat array. */
+ void CopySkyLight (NIBBLETYPE * a_Dest) const;
+
+ /** Copies the blocktype data from the specified flat array into the internal representation.
+ Allocates sections that are needed for the operation.
+ Requires that a_Src is a valid pointer. */
+ void SetBlockTypes(const BLOCKTYPE * a_Src);
+
+ /** Copies the metadata from the specified flat array into the internal representation.
+ Allocates sectios that are needed for the operation.
+ Requires that a_Src is a valid pointer. */
+ void SetMetas(const NIBBLETYPE * a_Src);
+
+ /** Copies the blocklight data from the specified flat array into the internal representation.
+ Allocates sectios that are needed for the operation.
+ Allows a_Src to be NULL, in which case it doesn't do anything. */
+ void SetBlockLight(const NIBBLETYPE * a_Src);
+
+ /** Copies the skylight data from the specified flat array into the internal representation.
+ Allocates sectios that are needed for the operation.
+ Allows a_Src to be NULL, in which case it doesn't do anything. */
+ void SetSkyLight(const NIBBLETYPE * a_Src);
+
+ struct sChunkSection
+ {
+ BLOCKTYPE m_BlockTypes [SectionHeight * 16 * 16] ;
+ NIBBLETYPE m_BlockMetas [SectionHeight * 16 * 16 / 2];
+ NIBBLETYPE m_BlockLight [SectionHeight * 16 * 16 / 2];
+ NIBBLETYPE m_BlockSkyLight[SectionHeight * 16 * 16 / 2];
+ };
+
+private:
+ #if __cplusplus < 201103L
+ // auto_ptr style interface for memory management
+ mutable bool m_IsOwner;
+ #endif
+
+ sChunkSection * m_Sections[NumSections];
+
+ cAllocationPool<cChunkData::sChunkSection> & m_Pool;
+
+ /** Allocates a new section. Entry-point to custom allocators. */
+ sChunkSection * Allocate(void);
+
+ /** Frees the specified section, previously allocated using Allocate().
+ Note that a_Section may be NULL. */
+ void Free(sChunkSection * a_Section);
+
+ /** Sets the data in the specified section to their default values. */
+ void ZeroSection(sChunkSection * a_Section) const;
+
+};
+
+
+
+
+
+
diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h
new file mode 100644
index 000000000..804299816
--- /dev/null
+++ b/src/ChunkDataCallback.h
@@ -0,0 +1,127 @@
+
+// ChunkDataCallback.h
+
+// Declares the cChunkDataCallback interface and several trivial descendants, for reading chunk data
+
+
+
+
+
+#pragma once
+
+#include "ChunkData.h"
+
+
+
+
+
+/** Interface class used for getting data out of a chunk using the GetAllData() function.
+Implementation must use the pointers immediately and NOT store any of them for later use
+The virtual methods are called in the same order as they're declared here.
+*/
+class cChunkDataCallback abstract
+{
+public:
+
+ virtual ~cChunkDataCallback() {}
+
+ /** Called before any other callbacks to inform of the current coords
+ (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
+ If false is returned, the chunk is skipped.
+ */
+ virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }
+
+ /// Called once to provide heightmap data
+ virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) { UNUSED(a_HeightMap); }
+
+ /// Called once to provide biome data
+ virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) { UNUSED(a_BiomeMap); }
+
+ /// Called once to let know if the chunk lighting is valid. Return value is ignored
+ virtual void LightIsValid(bool a_IsLightValid) { UNUSED(a_IsLightValid); }
+
+ /// Called once to export block info
+ virtual void ChunkData(const cChunkData & a_Buffer) { UNUSED(a_Buffer); }
+
+ /// Called for each entity in the chunk
+ virtual void Entity(cEntity * a_Entity) { UNUSED(a_Entity); }
+
+ /// Called for each blockentity in the chunk
+ virtual void BlockEntity(cBlockEntity * a_Entity) { UNUSED(a_Entity); }
+} ;
+
+
+
+
+
+/** A simple implementation of the cChunkDataCallback interface that collects all block data into a buffer
+*/
+class cChunkDataCollector :
+ public cChunkDataCallback
+{
+public:
+
+ cChunkData m_BlockData;
+
+protected:
+
+ virtual void ChunkData(const cChunkData & a_BlockData) override
+ {
+ m_BlockData = a_BlockData.Copy();
+ }
+};
+
+
+
+
+
+/** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer
+*/
+class cChunkDataArrayCollector :
+ public cChunkDataCallback
+{
+public:
+
+ // Must be unsigned char instead of BLOCKTYPE or NIBBLETYPE, because it houses both.
+ unsigned char m_BlockData[cChunkDef::BlockDataSize];
+
+protected:
+
+ virtual void ChunkData(const cChunkData & a_ChunkBuffer) override
+ {
+ a_ChunkBuffer.CopyBlockTypes(m_BlockData);
+ a_ChunkBuffer.CopyMetas(m_BlockData + cChunkDef::NumBlocks);
+ a_ChunkBuffer.CopyBlockLight(m_BlockData + 3 * cChunkDef::NumBlocks / 2);
+ a_ChunkBuffer.CopySkyLight(m_BlockData + 2 * cChunkDef::NumBlocks);
+ }
+};
+
+
+
+
+
+/** A simple implementation of the cChunkDataCallback interface that collects all block data into separate buffers */
+class cChunkDataSeparateCollector :
+ public cChunkDataCallback
+{
+public:
+
+ cChunkDef::BlockTypes m_BlockTypes;
+ cChunkDef::BlockNibbles m_BlockMetas;
+ cChunkDef::BlockNibbles m_BlockLight;
+ cChunkDef::BlockNibbles m_BlockSkyLight;
+
+protected:
+
+ virtual void ChunkData(const cChunkData & a_ChunkBuffer) override
+ {
+ a_ChunkBuffer.CopyBlockTypes(m_BlockTypes);
+ a_ChunkBuffer.CopyMetas(m_BlockMetas);
+ a_ChunkBuffer.CopyBlockLight(m_BlockLight);
+ a_ChunkBuffer.CopySkyLight(m_BlockSkyLight);
+ }
+} ;
+
+
+
+
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index 054168bdd..dbb782d26 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -22,8 +22,8 @@ It will help us when the new chunk format comes out and we need to patch everyth
#define ZERO_CHUNK_Y 0
// Used to smoothly convert to new axis ordering. One will be removed when deemed stable.
-#define AXIS_ORDER_YZX 1 // Original (1.1-)
-#define AXIS_ORDER_XZY 2 // New (1.2+)
+#define AXIS_ORDER_YZX 1 // Original (1.1-)
+#define AXIS_ORDER_XZY 2 // New (1.2+)
#define AXIS_ORDER AXIS_ORDER_XZY
@@ -72,7 +72,7 @@ public:
/// The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column
typedef HEIGHTTYPE HeightMap[Width * Width];
- /** The type used for any biomemap operations and storage inside MCServer,
+ /** The type used for any biomemap operations and storage inside MCServer,
using MCServer biomes (need not correspond to client representation!)
idx = x + Width * z // Need to verify this with the protocol spec, currently unknown!
*/
@@ -92,7 +92,7 @@ public:
/// Converts absolute block coords into relative (chunk + block) coords:
- inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ )
+ inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ)
{
UNUSED(a_Y);
BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ);
@@ -118,7 +118,7 @@ public:
}
- inline static int MakeIndex(int x, int y, int z )
+ inline static int MakeIndex(int x, int y, int z)
{
if (
(x < Width) && (x > -1) &&
@@ -138,27 +138,27 @@ public:
{
#if AXIS_ORDER == AXIS_ORDER_XZY
// For some reason, NOT using the Horner schema is faster. Weird.
- return x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width); // 1.2 is XZY
+ return x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width); // 1.2 uses XZY
#elif AXIS_ORDER == AXIS_ORDER_YZX
- return y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width); // 1.1 is YZX
+ return y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width); // 1.1 uses YZX
#endif
}
- inline static Vector3i IndexToCoordinate( unsigned int index )
+ inline static Vector3i IndexToCoordinate( unsigned int index)
{
#if AXIS_ORDER == AXIS_ORDER_XZY
- return Vector3i( // 1.2
- index % cChunkDef::Width, // X
- index / (cChunkDef::Width * cChunkDef::Width), // Y
- (index / cChunkDef::Width) % cChunkDef::Width // Z
- );
+ return Vector3i( // 1.2
+ index % cChunkDef::Width, // X
+ index / (cChunkDef::Width * cChunkDef::Width), // Y
+ (index / cChunkDef::Width) % cChunkDef::Width // Z
+ );
#elif AXIS_ORDER == AXIS_ORDER_YZX
- return Vector3i( // 1.1
- index / (cChunkDef::Height * cChunkDef::Width), // X
- index % cChunkDef::Height, // Y
- (index / cChunkDef::Height) % cChunkDef::Width // Z
- );
+ return Vector3i( // 1.1
+ index / (cChunkDef::Height * cChunkDef::Width), // X
+ index % cChunkDef::Height, // Y
+ (index / cChunkDef::Height) % cChunkDef::Width // Z
+ );
#endif
}
@@ -246,8 +246,8 @@ public:
{
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{
- int Index = MakeIndexNoCheck(x, y, z);
- if ((size_t)(Index / 2) >= a_Buffer.size())
+ size_t Index = (size_t)MakeIndexNoCheck(x, y, z);
+ if ((Index / 2) >= a_Buffer.size())
{
return (a_IsSkyLightNibble ? 0xff : 0);
}
@@ -281,7 +281,7 @@ public:
{
a_Buffer.resize((size_t)((a_BlockIdx / 2) + 1));
}
- a_Buffer[(size_t)(a_BlockIdx / 2)] = PackNibble(a_Buffer, a_BlockIdx, a_Nibble);
+ a_Buffer[(size_t)(a_BlockIdx / 2)] = PackNibble(a_Buffer, (size_t)a_BlockIdx, a_Nibble);
}
@@ -297,19 +297,19 @@ public:
return;
}
- int Index = MakeIndexNoCheck(x, y, z);
- if ((size_t)(Index / 2) >= a_Buffer.size())
+ size_t Index = (size_t)MakeIndexNoCheck(x, y, z);
+ if ((Index / 2) >= a_Buffer.size())
{
- a_Buffer.resize((size_t)((Index / 2) + 1));
+ a_Buffer.resize(((Index / 2) + 1));
}
- a_Buffer[(size_t)(Index / 2)] = PackNibble(a_Buffer, Index, a_Nibble);
+ a_Buffer[(Index / 2)] = PackNibble(a_Buffer, Index, a_Nibble);
}
private:
- inline static NIBBLETYPE PackNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, int a_Index, NIBBLETYPE a_Nibble)
+ inline static NIBBLETYPE PackNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, size_t a_Index, NIBBLETYPE a_Nibble)
{
return static_cast<NIBBLETYPE>(
(a_Buffer[a_Index / 2] & (0xf0 >> ((a_Index & 1) * 4))) | // The untouched nibble
@@ -318,7 +318,7 @@ private:
}
- inline static NIBBLETYPE ExpandNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, int a_Index)
+ inline static NIBBLETYPE ExpandNibble(const COMPRESSED_NIBBLETYPE & a_Buffer, size_t a_Index)
{
return (a_Buffer[a_Index / 2] >> ((a_Index & 1) * 4)) & 0x0f;
}
@@ -330,136 +330,6 @@ private:
-/** Interface class used for getting data out of a chunk using the GetAllData() function.
-Implementation must use the pointers immediately and NOT store any of them for later use
-The virtual methods are called in the same order as they're declared here.
-*/
-class cChunkDataCallback abstract
-{
-public:
-
- virtual ~cChunkDataCallback() {}
-
- /** Called before any other callbacks to inform of the current coords
- (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
- If false is returned, the chunk is skipped.
- */
- virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; };
-
- /// Called once to provide heightmap data
- virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); };
-
- /// Called once to provide biome data
- virtual void BiomeData (const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); };
-
- /// Called once to export block types
- virtual void BlockTypes (const BLOCKTYPE * a_Type) {UNUSED(a_Type); };
-
- /// Called once to export block meta
- virtual void BlockMeta (const NIBBLETYPE * a_Meta) {UNUSED(a_Meta); };
-
- /// Called once to let know if the chunk lighting is valid. Return value is used to control if BlockLight() and BlockSkyLight() are called next (if true)
- virtual bool LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); return true; };
-
- /// Called once to export block light
- virtual void BlockLight (const NIBBLETYPE * a_BlockLight) {UNUSED(a_BlockLight); };
-
- /// Called once to export sky light
- virtual void BlockSkyLight(const NIBBLETYPE * a_SkyLight) {UNUSED(a_SkyLight); };
-
- /// Called for each entity in the chunk
- virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); };
-
- /// Called for each blockentity in the chunk
- virtual void BlockEntity(cBlockEntity * a_Entity) {UNUSED(a_Entity); };
-} ;
-
-
-
-
-
-/** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer
-*/
-class cChunkDataCollector :
- public cChunkDataCallback
-{
-public:
-
- // Must be unsigned char instead of BLOCKTYPE or NIBBLETYPE, because it houses both.
- unsigned char m_BlockData[cChunkDef::BlockDataSize];
-
-protected:
-
- virtual void BlockTypes(const BLOCKTYPE * a_BlockTypes) override
- {
- memcpy(m_BlockData, a_BlockTypes, sizeof(cChunkDef::BlockTypes));
- }
-
-
- virtual void BlockMeta(const NIBBLETYPE * a_BlockMeta) override
- {
- memcpy(m_BlockData + cChunkDef::NumBlocks, a_BlockMeta, cChunkDef::NumBlocks / 2);
- }
-
-
- virtual void BlockLight(const NIBBLETYPE * a_BlockLight) override
- {
- memcpy(m_BlockData + 3 * cChunkDef::NumBlocks / 2, a_BlockLight, cChunkDef::NumBlocks / 2);
- }
-
-
- virtual void BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight) override
- {
- memcpy(m_BlockData + 2 * cChunkDef::NumBlocks, a_BlockSkyLight, cChunkDef::NumBlocks / 2);
- }
-} ;
-
-
-
-
-
-/** A simple implementation of the cChunkDataCallback interface that collects all block data into a separate buffers
-*/
-class cChunkDataSeparateCollector :
- public cChunkDataCallback
-{
-public:
-
- cChunkDef::BlockTypes m_BlockTypes;
- cChunkDef::BlockNibbles m_BlockMetas;
- cChunkDef::BlockNibbles m_BlockLight;
- cChunkDef::BlockNibbles m_BlockSkyLight;
-
-protected:
-
- virtual void BlockTypes(const BLOCKTYPE * a_BlockTypes) override
- {
- memcpy(m_BlockTypes, a_BlockTypes, sizeof(m_BlockTypes));
- }
-
-
- virtual void BlockMeta(const NIBBLETYPE * a_BlockMeta) override
- {
- memcpy(m_BlockMetas, a_BlockMeta, sizeof(m_BlockMetas));
- }
-
-
- virtual void BlockLight(const NIBBLETYPE * a_BlockLight) override
- {
- memcpy(m_BlockLight, a_BlockLight, sizeof(m_BlockLight));
- }
-
-
- virtual void BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight) override
- {
- memcpy(m_BlockSkyLight, a_BlockSkyLight, sizeof(m_BlockSkyLight));
- }
-} ;
-
-
-
-
-
/** Interface class used for comparing clients of two chunks.
Used primarily for entity moving while both chunks are locked.
*/
@@ -487,7 +357,7 @@ struct sSetBlock
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
- sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); // absolute block position
+ sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // absolute block position
sSetBlock(int a_ChunkX, int a_ChunkZ, int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
x(a_X), y(a_Y), z(a_Z),
ChunkX(a_ChunkX), ChunkZ(a_ChunkZ),
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 537d491c9..05d219918 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -16,11 +16,12 @@
#include "MobCensus.h"
#include "MobSpawner.h"
#include "BoundingBox.h"
+#include "SetChunkData.h"
#include "Entities/Pickup.h"
#ifndef _WIN32
- #include <cstdlib> // abs
+ #include <cstdlib> // abs
#endif
#include "zlib/zlib.h"
@@ -33,9 +34,17 @@
////////////////////////////////////////////////////////////////////////////////
// cChunkMap:
-cChunkMap::cChunkMap(cWorld * a_World )
- : m_World( a_World )
+cChunkMap::cChunkMap(cWorld * a_World) :
+ m_World(a_World),
+ m_Pool(
+ new cListAllocationPool<cChunkData::sChunkSection, 1600>(
+ std::auto_ptr<cAllocationPool<cChunkData::sChunkSection>::cStarvationCallbacks>(
+ new cStarvationCallbacks()
+ )
+ )
+ )
{
+
}
@@ -56,7 +65,7 @@ cChunkMap::~cChunkMap()
-void cChunkMap::RemoveLayer( cChunkLayer* a_Layer )
+void cChunkMap::RemoveLayer( cChunkLayer* a_Layer)
{
cCSLock Lock(m_CSLayers);
m_Layers.remove(a_Layer);
@@ -78,7 +87,7 @@ cChunkMap::cChunkLayer * cChunkMap::GetLayer(int a_LayerX, int a_LayerZ)
}
// Not found, create new:
- cChunkLayer * Layer = new cChunkLayer(a_LayerX, a_LayerZ, this);
+ cChunkLayer * Layer = new cChunkLayer(a_LayerX, a_LayerZ, this, *m_Pool);
if (Layer == NULL)
{
LOGERROR("cChunkMap: Cannot create new layer, server out of memory?");
@@ -139,7 +148,7 @@ cChunkPtr cChunkMap::GetChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
// No need to lock m_CSLayers, since it's already locked by the operation that called us
ASSERT(m_CSLayers.IsLockedByCurrentThread());
- cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ );
+ cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ);
if (Layer == NULL)
{
// An error must have occurred, since layers are automatically created if they don't exist
@@ -162,10 +171,10 @@ cChunkPtr cChunkMap::GetChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
-cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
+cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
// No need to lock m_CSLayers, since it's already locked by the operation that called us
- cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ );
+ cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ);
if (Layer == NULL)
{
// An error must have occurred, since layers are automatically created if they don't exist
@@ -189,10 +198,10 @@ cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
-cChunkPtr cChunkMap::GetChunkNoLoad( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
+cChunkPtr cChunkMap::GetChunkNoLoad( int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
// No need to lock m_CSLayers, since it's already locked by the operation that called us
- cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ );
+ cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ);
if (Layer == NULL)
{
// An error must have occurred, since layers are automatically created if they don't exist
@@ -219,9 +228,8 @@ bool cChunkMap::LockedGetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTY
return false;
}
- int Index = cChunkDef::MakeIndexNoCheck(a_BlockX, a_BlockY, a_BlockZ);
- a_BlockType = Chunk->GetBlock(Index);
- a_BlockMeta = Chunk->GetMeta(Index);
+ a_BlockType = Chunk->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ a_BlockMeta = Chunk->GetMeta(a_BlockX, a_BlockY, a_BlockZ);
return true;
}
@@ -242,8 +250,7 @@ bool cChunkMap::LockedGetBlockType(int a_BlockX, int a_BlockY, int a_BlockZ, BLO
return false;
}
- int Index = cChunkDef::MakeIndexNoCheck(a_BlockX, a_BlockY, a_BlockZ);
- a_BlockType = Chunk->GetBlock(Index);
+ a_BlockType = Chunk->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
return true;
}
@@ -264,8 +271,7 @@ bool cChunkMap::LockedGetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIB
return false;
}
- int Index = cChunkDef::MakeIndexNoCheck(a_BlockX, a_BlockY, a_BlockZ);
- a_BlockMeta = Chunk->GetMeta(Index);
+ a_BlockMeta = Chunk->GetMeta(a_BlockX, a_BlockY, a_BlockZ);
return true;
}
@@ -415,16 +421,16 @@ void cChunkMap::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSeriali
-void cChunkMap::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_Pickup.GetChunkX(), ZERO_CHUNK_Y, a_Pickup.GetChunkZ());
+ cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude);
+ Chunk->BroadcastCollectEntity(a_Entity, a_Player, a_Exclude);
}
@@ -643,19 +649,19 @@ void cChunkMap::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_Effe
-void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(a_SrcX / 8, a_SrcZ / 8, ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk((int)std::floor(a_X), (int)std::floor(a_Z), ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
+ Chunk->BroadcastSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch, a_Exclude);
}
@@ -715,7 +721,7 @@ void cChunkMap::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, c
-void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
+void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
{
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
@@ -843,7 +849,22 @@ void cChunkMap::WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_M
-void cChunkMap::MarkChunkDirty (int a_ChunkX, int a_ChunkZ)
+void cChunkMap::MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ)
+{
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
+ if ((Chunk == NULL) || !Chunk->IsValid())
+ {
+ return;
+ }
+ Chunk->SetIsRedstoneDirty(true);
+}
+
+
+
+
+
+void cChunkMap::MarkChunkDirty(int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
@@ -852,6 +873,10 @@ void cChunkMap::MarkChunkDirty (int a_ChunkX, int a_ChunkZ)
return;
}
Chunk->MarkDirty();
+ if (a_MarkRedstoneDirty)
+ {
+ Chunk->SetIsRedstoneDirty(true);
+ }
}
@@ -888,28 +913,20 @@ void cChunkMap::MarkChunkSaved (int a_ChunkX, int a_ChunkZ)
-void cChunkMap::SetChunkData(
- int a_ChunkX, int a_ChunkZ,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap & a_BiomeMap,
- cBlockEntityList & a_BlockEntities,
- bool a_MarkDirty
-)
+void cChunkMap::SetChunkData(cSetChunkData & a_SetChunkData)
{
+ int ChunkX = a_SetChunkData.GetChunkX();
+ int ChunkZ = a_SetChunkData.GetChunkZ();
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
+ cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
if (Chunk == NULL)
{
return;
}
- Chunk->SetAllData(a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight, a_HeightMap, a_BiomeMap, a_BlockEntities);
+ Chunk->SetAllData(a_SetChunkData);
- if (a_MarkDirty)
+ if (a_SetChunkData.ShouldMarkDirty())
{
Chunk->MarkDirty();
}
@@ -918,7 +935,7 @@ void cChunkMap::SetChunkData(
cChunkStays ToBeDisabled;
for (cChunkStays::iterator itr = m_ChunkStays.begin(), end = m_ChunkStays.end(); itr != end; ++itr)
{
- if ((*itr)->ChunkAvailable(a_ChunkX, a_ChunkZ))
+ if ((*itr)->ChunkAvailable(ChunkX, ChunkZ))
{
// The chunkstay wants to be disabled, add it to a list of to-be-disabled chunkstays for later processing:
ToBeDisabled.push_back(*itr);
@@ -933,7 +950,7 @@ void cChunkMap::SetChunkData(
}
// Notify plugins of the chunk becoming available
- cPluginManager::Get()->CallHookChunkAvailable(m_World, a_ChunkX, a_ChunkZ);
+ cPluginManager::Get()->CallHookChunkAvailable(m_World, ChunkX, ChunkZ);
}
@@ -1130,9 +1147,9 @@ void cChunkMap::CollectPickupsByPlayer(cPlayer * a_Player)
GetChunkNoLoad(ChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer(a_Player);
// Check the neighboring chunks as well:
- GetChunkNoLoad(OtherChunkX, ChunkY, ChunkZ )->CollectPickupsByPlayer(a_Player);
+ GetChunkNoLoad(OtherChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer (a_Player);
GetChunkNoLoad(OtherChunkX, ChunkY, OtherChunkZ)->CollectPickupsByPlayer(a_Player);
- GetChunkNoLoad(ChunkX, ChunkY, ChunkZ )->CollectPickupsByPlayer(a_Player);
+ GetChunkNoLoad(ChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer (a_Player);
GetChunkNoLoad(ChunkX, ChunkY, OtherChunkZ)->CollectPickupsByPlayer(a_Player);
}
@@ -1157,7 +1174,7 @@ BLOCKTYPE cChunkMap::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
} // for itr - m_FastSetBlockQueue[]
}
int ChunkX, ChunkZ;
- cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ );
+ cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ);
@@ -1186,11 +1203,11 @@ NIBBLETYPE cChunkMap::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
} // for itr - m_FastSetBlockQueue[]
}
int ChunkX, ChunkZ;
- cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ );
+ cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
- if ((Chunk != NULL) && Chunk->IsValid() )
+ cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
+ if ((Chunk != NULL) && Chunk->IsValid())
{
return Chunk->GetMeta(a_BlockX, a_BlockY, a_BlockZ);
}
@@ -1204,11 +1221,11 @@ NIBBLETYPE cChunkMap::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
NIBBLETYPE cChunkMap::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ)
{
int ChunkX, ChunkZ;
- cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ );
+ cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
- if ((Chunk != NULL) && Chunk->IsValid() )
+ cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
+ if ((Chunk != NULL) && Chunk->IsValid())
{
return Chunk->GetSkyLight(a_BlockX, a_BlockY, a_BlockZ);
}
@@ -1222,11 +1239,11 @@ NIBBLETYPE cChunkMap::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ)
NIBBLETYPE cChunkMap::GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ)
{
int ChunkX, ChunkZ;
- cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ );
+ cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
- if ((Chunk != NULL) && Chunk->IsValid() )
+ cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
+ if ((Chunk != NULL) && Chunk->IsValid())
{
return Chunk->GetBlockLight(a_BlockX, a_BlockY, a_BlockZ);
}
@@ -1248,8 +1265,6 @@ void cChunkMap::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYP
if ((Chunk != NULL) && Chunk->IsValid())
{
Chunk->SetMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta);
- Chunk->MarkDirty();
- Chunk->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, NULL);
}
}
@@ -1257,7 +1272,7 @@ void cChunkMap::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYP
-void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
+void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients)
{
cChunkInterface ChunkInterface(this);
if (a_BlockType == E_BLOCK_AIR)
@@ -1266,13 +1281,13 @@ void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a
}
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
- cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ );
+ cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
+ cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk != NULL) && Chunk->IsValid())
{
- Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta );
+ Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta, a_SendToClients);
m_World->GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ, Chunk);
}
BlockHandler(a_BlockType)->OnPlaced(ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
@@ -1282,7 +1297,7 @@ void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a
-void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType)
+void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType)
{
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
cChunkDef::AbsoluteToRelative(X, Y, Z, ChunkX, ChunkZ);
@@ -1302,10 +1317,10 @@ void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYP
bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
- cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ );
+ cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
+ cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk != NULL) && Chunk->IsValid())
{
Chunk->GetBlockTypeMeta(X, Y, Z, a_BlockType, a_BlockMeta);
@@ -1321,10 +1336,10 @@ bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCK
bool cChunkMap::GetBlockInfo(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight)
{
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
- cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ );
+ cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
+ cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk != NULL) && Chunk->IsValid())
{
Chunk->GetBlockInfo(X, Y, Z, a_BlockType, a_Meta, a_SkyLight, a_BlockLight);
@@ -1342,7 +1357,7 @@ void cChunkMap::ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_Filt
cCSLock Lock(m_CSLayers);
for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr)
{
- cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ );
+ cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ);
if ((Chunk == NULL) || !Chunk->IsValid())
{
continue;
@@ -1363,7 +1378,7 @@ void cChunkMap::ReplaceTreeBlocks(const sSetBlockVector & a_Blocks)
cCSLock Lock(m_CSLayers);
for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr)
{
- cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ );
+ cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ);
if ((Chunk == NULL) || !Chunk->IsValid())
{
continue;
@@ -1476,7 +1491,7 @@ bool cChunkMap::GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure)
cCSLock Lock(m_CSLayers);
for (sSetBlockVector::iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr)
{
- cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ );
+ cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ);
if ((Chunk == NULL) || !Chunk->IsValid())
{
if (!a_ContinueOnFailure)
@@ -1486,9 +1501,8 @@ bool cChunkMap::GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure)
res = false;
continue;
}
- int idx = cChunkDef::MakeIndexNoCheck(itr->x, itr->y, itr->z);
- itr->BlockType = Chunk->GetBlock(idx);
- itr->BlockMeta = Chunk->GetMeta(idx);
+ itr->BlockType = Chunk->GetBlock(itr->x, itr->y, itr->z);
+ itr->BlockMeta = Chunk->GetMeta(itr->x, itr->y, itr->z);
}
return res;
}
@@ -1501,17 +1515,17 @@ bool cChunkMap::DigBlock(int a_X, int a_Y, int a_Z)
{
int PosX = a_X, PosY = a_Y, PosZ = a_Z, ChunkX, ChunkZ;
- cChunkDef::AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkZ );
+ cChunkDef::AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkZ);
{
cCSLock Lock(m_CSLayers);
- cChunkPtr DestChunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
+ cChunkPtr DestChunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((DestChunk == NULL) || !DestChunk->IsValid())
{
return false;
}
- DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0 );
+ DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0);
m_World->GetSimulatorManager()->WakeUp(a_X, a_Y, a_Z, DestChunk);
}
@@ -1529,7 +1543,7 @@ void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player)
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ);
- if (Chunk->IsValid())
+ if ((Chunk != NULL) && (Chunk->IsValid()))
{
Chunk->SendBlockTo(a_X, a_Y, a_Z, a_Player->GetClientHandle());
}
@@ -1671,6 +1685,30 @@ void cChunkMap::AddEntity(cEntity * a_Entity)
+void cChunkMap::AddEntityIfNotPresent(cEntity * a_Entity)
+{
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ());
+ if (
+ (Chunk == NULL) || // Chunk not present at all
+ (!Chunk->IsValid() && !a_Entity->IsPlayer()) // Chunk present, but no valid data; players need to spawn in such chunks (#953)
+ )
+ {
+ LOGWARNING("Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.",
+ a_Entity, a_Entity->GetClass(), a_Entity->GetUniqueID()
+ );
+ return;
+ }
+ if (!Chunk->HasEntity(a_Entity->GetUniqueID()))
+ {
+ Chunk->AddEntity(a_Entity);
+ }
+}
+
+
+
+
+
bool cChunkMap::HasEntity(int a_UniqueID)
{
cCSLock Lock(m_CSLayers);
@@ -1692,7 +1730,9 @@ void cChunkMap::RemoveEntity(cEntity * a_Entity)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ());
- if ((Chunk == NULL) || !Chunk->IsValid())
+
+ // Even if a chunk is not valid, it may still contain entities such as players; make sure to remove them (#1190)
+ if (Chunk == NULL)
{
return;
}
@@ -1793,7 +1833,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 = 10 + m_World->GetTickRandomNumber(20);
m_World->SpawnPrimedTNT(a_BlockX + x + 0.5, a_BlockY + y + 0.5, a_BlockZ + z + 0.5, FuseTime);
- area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_AIR);
+ area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_AIR, 0);
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
break;
}
@@ -1829,15 +1869,15 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
default:
{
- if (m_World->GetTickRandomNumber(100) <= 25) // 25% chance of pickups
+ if (m_World->GetTickRandomNumber(100) <= 25) // 25% chance of pickups
{
cItems Drops;
cBlockHandler * Handler = BlockHandler(Block);
- Handler->ConvertToPickups(Drops, area.GetBlockMeta(bx + x, by + y, bz + z)); // Stone becomes cobblestone, coal ore becomes coal, etc.
+ Handler->ConvertToPickups(Drops, area.GetBlockMeta(bx + x, by + y, bz + z)); // Stone becomes cobblestone, coal ore becomes coal, etc.
m_World->SpawnItemPickups(Drops, bx + x, by + y, bz + z);
}
- else if ((m_World->GetTNTShrapnelLevel() > slNone) && (m_World->GetTickRandomNumber(100) < 20)) // 20% chance of flinging stuff around
+ else if ((m_World->GetTNTShrapnelLevel() > slNone) && (m_World->GetTickRandomNumber(100) < 20)) // 20% chance of flinging stuff around
{
if (!cBlockInfo::FullyOccupiesVoxel(Block))
{
@@ -1850,7 +1890,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
m_World->SpawnFallingBlock(bx + x, by + y + 5, bz + z, Block, area.GetBlockMeta(bx + x, by + y, bz + z));
}
- area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_AIR);
+ area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_AIR, 0);
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
break;
@@ -1877,7 +1917,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
{
if (a_Entity->IsPickup())
{
- if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible (so we don't kill pickups that were just spawned)
+ if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible (so we don't kill pickups that were just spawned)
{
return false;
}
@@ -1886,7 +1926,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
Vector3d EntityPos = a_Entity->GetPosition();
cBoundingBox bbEntity(EntityPos, a_Entity->GetWidth() / 2, a_Entity->GetHeight());
- if (!m_bbTNT.IsInside(bbEntity)) // IsInside actually acts like DoesSurround
+ if (!m_bbTNT.IsInside(bbEntity)) // IsInside actually acts like DoesSurround
{
return false;
}
@@ -1904,12 +1944,9 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
double FinalDamage = (((1 / AbsoluteEntityPos.x) + (1 / AbsoluteEntityPos.y) + (1 / AbsoluteEntityPos.z)) * 2) * m_ExplosionSize;
// Clip damage values
- if (FinalDamage > a_Entity->GetMaxHealth())
- FinalDamage = a_Entity->GetMaxHealth();
- else if (FinalDamage < 0)
- FinalDamage = 0;
+ FinalDamage = Clamp(FinalDamage, 0.0, (double)a_Entity->GetMaxHealth());
- if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible
+ if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible
{
a_Entity->TakeDamage(dtExplosion, NULL, (int)FinalDamage, 0);
}
@@ -2649,14 +2686,33 @@ void cChunkMap::QueueTickBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cChunkMap::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked)
+{
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
+ if (Chunk != NULL)
+ {
+ Chunk->SetAlwaysTicked(a_AlwaysTicked);
+ }
+}
+
+
+
+
+
////////////////////////////////////////////////////////////////////////////////
// cChunkMap::cChunkLayer:
-cChunkMap::cChunkLayer::cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent)
- : m_LayerX( a_LayerX )
- , m_LayerZ( a_LayerZ )
- , m_Parent( a_Parent )
- , m_NumChunksLoaded( 0 )
+cChunkMap::cChunkLayer::cChunkLayer(
+ int a_LayerX, int a_LayerZ,
+ cChunkMap * a_Parent,
+ cAllocationPool<cChunkData::sChunkSection> & a_Pool
+)
+ : m_LayerX( a_LayerX)
+ , m_LayerZ( a_LayerZ)
+ , m_Parent( a_Parent)
+ , m_NumChunksLoaded( 0)
+ , m_Pool(a_Pool)
{
memset(m_Chunks, 0, sizeof(m_Chunks));
}
@@ -2670,7 +2726,7 @@ cChunkMap::cChunkLayer::~cChunkLayer()
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); ++i)
{
delete m_Chunks[i];
- m_Chunks[i] = NULL; // // Must zero out, because further chunk deletions query the chunkmap for entities and that would touch deleted data
+ m_Chunks[i] = NULL; // Must zero out, because further chunk deletions query the chunkmap for entities and that would touch deleted data
} // for i - m_Chunks[]
}
@@ -2678,7 +2734,7 @@ cChunkMap::cChunkLayer::~cChunkLayer()
-cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
+cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
// Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check
@@ -2696,9 +2752,9 @@ cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_Ch
{
cChunk * neixm = (LocalX > 0) ? m_Chunks[Index - 1] : m_Parent->FindChunk(a_ChunkX - 1, a_ChunkZ);
cChunk * neixp = (LocalX < LAYER_SIZE - 1) ? m_Chunks[Index + 1] : m_Parent->FindChunk(a_ChunkX + 1, a_ChunkZ);
- cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ - 1);
- cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ + 1);
- m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp);
+ cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ - 1);
+ cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ + 1);
+ m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp, m_Pool);
}
return m_Chunks[Index];
}
@@ -2758,12 +2814,14 @@ void cChunkMap::cChunkLayer::SpawnMobs(cMobSpawner& a_MobSpawner)
+
+
void cChunkMap::cChunkLayer::Tick(float a_Dt)
{
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++)
{
- // Only tick chunks that are valid and have clients:
- if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->HasAnyClients())
+ // Only tick chunks that are valid and should be ticked:
+ if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->ShouldBeTicked())
{
m_Chunks[i]->Tick(a_Dt);
}
@@ -2858,7 +2916,7 @@ int cChunkMap::cChunkLayer::GetNumChunksLoaded(void) const
NumChunks++;
}
} // for i - m_Chunks[]
- return NumChunks;
+ return NumChunks;
}
@@ -2929,7 +2987,7 @@ void cChunkMap::cChunkLayer::UnloadUnusedChunks(void)
void cChunkMap::FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
cCSLock Lock(m_CSFastSetBlock);
- m_FastSetBlockQueue.push_back(sSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta));
+ m_FastSetBlockQueue.push_back(sSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta));
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index 9d973f2a9..e33d9f894 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -5,7 +5,8 @@
#pragma once
-#include "ChunkDef.h"
+
+#include "ChunkDataCallback.h"
@@ -33,9 +34,10 @@ class cChunkDataSerializer;
class cBlockArea;
class cMobCensus;
class cMobSpawner;
+class cSetChunkData;
-typedef std::list<cClientHandle *> cClientHandleList;
-typedef cChunk * cChunkPtr;
+typedef std::list<cClientHandle *> cClientHandleList;
+typedef cChunk * cChunkPtr;
typedef cItemCallback<cEntity> cEntityCallback;
typedef cItemCallback<cBlockEntity> cBlockEntityCallback;
typedef cItemCallback<cChestEntity> cChestCallback;
@@ -59,7 +61,7 @@ public:
static const int LAYER_SIZE = 32;
- cChunkMap(cWorld* a_World );
+ cChunkMap(cWorld* a_World);
~cChunkMap();
// Broadcast respective packets to all clients of the chunk where the event is taking place
@@ -69,6 +71,7 @@ public:
void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL);
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
+ void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
@@ -83,11 +86,11 @@ public:
void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL);
void BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL);
- void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
+ void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
- void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
+ void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ);
/** Sends the block entity, if it is at the coords specified, to a_Client */
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
@@ -104,27 +107,17 @@ public:
/** Wakes up the simulators for the specified area of blocks */
void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ);
- void MarkChunkDirty (int a_ChunkX, int a_ChunkZ);
+ void MarkRedstoneDirty (int a_ChunkX, int a_ChunkZ);
+ void MarkChunkDirty (int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty = false);
void MarkChunkSaving (int a_ChunkX, int a_ChunkZ);
void MarkChunkSaved (int a_ChunkX, int a_ChunkZ);
/** Sets the chunk data as either loaded from the storage or generated.
- a_BlockLight and a_BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
- a_BiomeMap is optional, if not present, biomes will be calculated by the generator
- a_HeightMap is optional, if not present, will be calculated.
- If a_MarkDirty is set, the chunk is set as dirty (used after generating)
+ BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
+ If MarkDirty is set, the chunk is set as dirty (used after generating)
+ Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk.
*/
- void SetChunkData(
- int a_ChunkX, int a_ChunkZ,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap & a_BiomeMap,
- cBlockEntityList & a_BlockEntities,
- bool a_MarkDirty
- );
+ void SetChunkData(cSetChunkData & a_SetChunkData);
void ChunkLighted(
int a_ChunkX, int a_ChunkZ,
@@ -151,9 +144,9 @@ public:
NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ);
NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ);
NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ);
- void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockMeta);
- void SetBlock (cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta);
- void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR);
+ void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockMeta);
+ void SetBlock (cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true);
+ void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR);
bool GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
bool GetBlockInfo (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);
@@ -198,6 +191,10 @@ public:
/** Adds the entity to its appropriate chunk, takes ownership of the entity pointer */
void AddEntity(cEntity * a_Entity);
+ /** Adds the entity to its appropriate chunk, if the entity is not already added.
+ Takes ownership of the entity pointer */
+ void AddEntityIfNotPresent(cEntity * a_Entity);
+
/** Returns true if the entity with specified ID is present in the chunks */
bool HasEntity(int a_EntityID);
@@ -282,7 +279,7 @@ public:
/** Sets the sign text. Returns true if sign text changed. */
bool SetSignLines(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);
- /** Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::RegenerateChunk() ) */
+ /** Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::RegenerateChunk()) */
void MarkChunkRegenerating(int a_ChunkX, int a_ChunkZ);
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ);
@@ -333,6 +330,13 @@ public:
/** Returns the CS for locking the chunkmap; only cWorld::cLock may use this function! */
cCriticalSection & GetCS(void) { return m_CSLayers; }
+
+ /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk.
+ If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of
+ whether it has any clients or not.
+ This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long
+ as at least one requests is active the chunk will be ticked). */
+ void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked);
private:
@@ -346,11 +350,15 @@ private:
class cChunkLayer
{
public:
- cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent);
+ cChunkLayer(
+ int a_LayerX, int a_LayerZ,
+ cChunkMap * a_Parent,
+ cAllocationPool<cChunkData::sChunkSection> & a_Pool
+ );
~cChunkLayer();
/** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */
- cChunkPtr GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ );
+ cChunkPtr GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ);
/** Returns the specified chunk, or NULL if not created yet */
cChunk * FindChunk(int a_ChunkX, int a_ChunkZ);
@@ -366,7 +374,7 @@ private:
void UnloadUnusedChunks(void);
/** Collect a mob census, of all mobs, their megatype, their chunk and their distance o closest player */
- void CollectMobCensus(cMobCensus& a_ToFill);
+ void CollectMobCensus(cMobCensus& a_ToFill);
/** Try to Spawn Monsters inside all Chunks */
void SpawnMobs(cMobSpawner& a_MobSpawner);
@@ -390,6 +398,25 @@ private:
int m_LayerZ;
cChunkMap * m_Parent;
int m_NumChunksLoaded;
+
+ cAllocationPool<cChunkData::sChunkSection> & m_Pool;
+ };
+
+ class cStarvationCallbacks
+ : public cAllocationPool<cChunkData::sChunkSection>::cStarvationCallbacks
+ {
+ virtual void OnStartUsingReserve() override
+ {
+ LOG("Using backup memory buffer");
+ }
+ virtual void OnEndUsingReserve() override
+ {
+ LOG("Stoped using backup memory buffer");
+ }
+ virtual void OnOutOfReserve() override
+ {
+ LOG("Out of Memory");
+ }
};
typedef std::list<cChunkLayer *> cChunkLayerList;
@@ -422,6 +449,8 @@ private:
/** The cChunkStay descendants that are currently enabled in this chunkmap */
cChunkStays m_ChunkStays;
+ std::auto_ptr<cAllocationPool<cChunkData::sChunkSection> > m_Pool;
+
cChunkPtr GetChunk (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading / generating if not valid
cChunkPtr GetChunkNoGen (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading if not valid; doesn't generate
cChunkPtr GetChunkNoLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Doesn't load, doesn't generate
diff --git a/src/ChunkSender.cpp b/src/ChunkSender.cpp
index 2425adf18..ebcf0e272 100644
--- a/src/ChunkSender.cpp
+++ b/src/ChunkSender.cpp
@@ -17,7 +17,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cNotifyChunkSender:
void cNotifyChunkSender::Call(int a_ChunkX, int a_ChunkZ)
@@ -29,7 +29,7 @@ void cNotifyChunkSender::Call(int a_ChunkX, int a_ChunkZ)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cChunkSender:
cChunkSender::cChunkSender(void) :
diff --git a/src/ChunkSender.h b/src/ChunkSender.h
index a26f764a7..624a3a0bd 100644
--- a/src/ChunkSender.h
+++ b/src/ChunkSender.h
@@ -6,17 +6,17 @@
/*
The whole thing is a thread that runs in a loop, waiting for either:
"finished chunks" (ChunkReady()), or
- "chunks to send" (QueueSendChunkTo() )
-to come to a queue.
+ "chunks to send" (QueueSendChunkTo())
+to come to a queue.
And once they do, it requests the chunk data and sends it all away, either
broadcasting (ChunkReady), or
sends to a specific client (QueueSendChunkTo)
Chunk data is queried using the cChunkDataCallback interface.
It is cached inside the ChunkSender object during the query and then processed after the query ends.
-Note that the data needs to be compressed only *after* the query finishes,
+Note that the data needs to be compressed only *after* the query finishes,
because the query callbacks run with ChunkMap's CS locked.
-A client may remove itself from all direct requests(QueueSendChunkTo()) by calling RemoveClient();
+A client may remove itself from all direct requests(QueueSendChunkTo()) by calling RemoveClient();
this ensures that the client's Send() won't be called anymore by ChunkSender.
Note that it may be called by world's BroadcastToChunk() if the client is still in the chunk.
*/
@@ -27,6 +27,7 @@ Note that it may be called by world's BroadcastToChunk() if the client is still
#include "OSSupport/IsThread.h"
#include "ChunkDef.h"
+#include "ChunkDataCallback.h"
@@ -109,7 +110,7 @@ protected:
bool operator ==(const sSendChunk & a_Other)
{
return (
- (a_Other.m_ChunkX == m_ChunkX) &&
+ (a_Other.m_ChunkX == m_ChunkX) &&
(a_Other.m_ChunkY == m_ChunkY) &&
(a_Other.m_ChunkZ == m_ChunkZ) &&
(a_Other.m_Client == m_Client)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index fc3f98aaf..b390bf2d6 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -12,7 +12,6 @@
#include "BlockEntities/SignEntity.h"
#include "UI/Window.h"
#include "Item.h"
-#include "Piston.h"
#include "Mobs/Monster.h"
#include "ChatColor.h"
#include "OSSupport/Socket.h"
@@ -31,7 +30,7 @@
#include "CompositeChat.h"
#include "Items/ItemSword.h"
-#include "md5/md5.h"
+#include "polarssl/md5.h"
@@ -41,9 +40,6 @@
/** Maximum number of block change interactions a player can perform per tick - exceeding this causes a kick */
#define MAX_BLOCK_CHANGE_INTERACTIONS 20
-/** How many ticks before the socket is closed after the client is destroyed (#31) */
-static const int TICKS_BEFORE_CLOSE = 20;
-
@@ -64,7 +60,7 @@ int cClientHandle::s_ClientCount = 0;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cClientHandle:
cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
@@ -80,7 +76,6 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
m_PingID(1),
m_BlockDigAnimStage(-1),
m_HasStartedDigging(false),
- m_TicksSinceDestruction(0),
m_State(csConnected),
m_ShouldCheckDownloaded(false),
m_NumExplosionsThisTick(0),
@@ -90,7 +85,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
{
m_Protocol = new cProtocolRecognizer(this);
- s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread
+ s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread
m_UniqueID = s_ClientCount;
cTimer t1;
@@ -105,7 +100,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
cClientHandle::~cClientHandle()
{
- ASSERT(m_State >= csDestroyedWaiting); // Has Destroy() been called?
+ ASSERT(m_State == csDestroyed); // Has Destroy() been called?
LOGD("Deleting client \"%s\" at %p", GetUsername().c_str(), this);
@@ -125,7 +120,7 @@ cClientHandle::~cClientHandle()
}
if (World != NULL)
{
- World->RemovePlayer(m_Player);
+ World->RemovePlayer(m_Player, true); // Must be called before cPlayer::Destroy() as otherwise cChunk tries to delete the player, and then we do it again
m_Player->Destroy();
}
delete m_Player;
@@ -170,7 +165,7 @@ void cClientHandle::Destroy(void)
RemoveFromAllChunks();
m_Player->GetWorld()->RemoveClientFromChunkSender(this);
}
- m_State = csDestroyedWaiting;
+ m_State = csDestroyed;
}
@@ -202,7 +197,7 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
{
switch (a_ChatPrefix)
{
- case mtCustom: return AString();
+ case mtCustom: return "";
case mtFailure: return FormatChatPrefix(ShouldAppendChatPrefixes, "INFO", cChatColor::Rose, cChatColor::White);
case mtInformation: return FormatChatPrefix(ShouldAppendChatPrefixes, "INFO", cChatColor::Yellow, cChatColor::White);
case mtSuccess: return FormatChatPrefix(ShouldAppendChatPrefixes, "INFO", cChatColor::Green, cChatColor::White);
@@ -214,12 +209,17 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
case mtPrivateMessage:
{
if (ShouldAppendChatPrefixes)
- return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue.c_str(), a_AdditionalData.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str());
+ {
+ return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue, a_AdditionalData.c_str(), cChatColor::White, cChatColor::Italic);
+ }
else
- return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str());
+ {
+ return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue);
+ }
}
}
ASSERT(!"Unhandled chat prefix type!");
+ return "";
}
@@ -228,22 +228,49 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
AString cClientHandle::GenerateOfflineUUID(const AString & a_Username)
{
+ // Online UUIDs are always version 4 (random)
+ // We use Version 3 (MD5 hash) UUIDs for the offline UUIDs
+ // This guarantees that they will never collide with an online UUID and can be distinguished.
// Proper format for a version 3 UUID is:
// xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B
// Generate an md5 checksum, and use it as base for the ID:
- MD5 Checksum(a_Username);
- AString UUID = Checksum.hexdigest();
- UUID[12] = '3'; // Version 3 UUID
- UUID[16] = '8'; // Variant 1 UUID
-
- // Now the digest doesn't have the UUID slashes, but the client requires them, so add them into the appropriate positions:
- UUID.insert(8, "-");
- UUID.insert(13, "-");
- UUID.insert(18, "-");
- UUID.insert(23, "-");
-
- return UUID;
+ unsigned char MD5[16];
+ md5((const unsigned char *)a_Username.c_str(), a_Username.length(), MD5);
+ MD5[6] &= 0x0f; // Need to trim to 4 bits only...
+ MD5[8] &= 0x0f; // ... otherwise %01x overflows into two chars
+ return Printf("%02x%02x%02x%02x-%02x%02x-3%01x%02x-8%01x%02x-%02x%02x%02x%02x%02x%02x",
+ MD5[0], MD5[1], MD5[2], MD5[3],
+ MD5[4], MD5[5], MD5[6], MD5[7],
+ MD5[8], MD5[9], MD5[10], MD5[11],
+ MD5[12], MD5[13], MD5[14], MD5[15]
+ );
+}
+
+
+
+
+
+bool cClientHandle::IsUUIDOnline(const AString & a_UUID)
+{
+ // Online UUIDs are always version 4 (random)
+ // We use Version 3 (MD5 hash) UUIDs for the offline UUIDs
+ // This guarantees that they will never collide with an online UUID and can be distinguished.
+ // The version-specifying char is at pos #12 of raw UUID, pos #14 in dashed-UUID.
+ switch (a_UUID.size())
+ {
+ case 32:
+ {
+ // This is the UUID format without dashes, the version char is at pos #12:
+ return (a_UUID[12] == '4');
+ }
+ case 36:
+ {
+ // This is the UUID format with dashes, the version char is at pos #14:
+ return (a_UUID[14] == '4');
+ }
+ }
+ return false;
}
@@ -263,17 +290,18 @@ void cClientHandle::Kick(const AString & a_Reason)
-void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID)
+void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties)
{
if (m_State != csAuthenticating)
{
return;
}
- ASSERT( m_Player == NULL );
+ ASSERT(m_Player == NULL);
m_Username = a_Name;
m_UUID = a_UUID;
+ m_Properties = a_Properties;
// Send login success (if the protocol supports it):
m_Protocol->SendLoginSuccess();
@@ -297,7 +325,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID)
if (!cRoot::Get()->GetPluginManager()->CallHookPlayerJoined(*m_Player))
{
cRoot::Get()->BroadcastChatJoin(Printf("%s has joined the game", GetUsername().c_str()));
- LOGINFO("Player %s has joined the game.", m_Username.c_str());
+ LOGINFO("Player %s has joined the game", m_Username.c_str());
}
m_ConfirmPosition = m_Player->GetPosition();
@@ -323,7 +351,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID)
// Send experience
m_Player->SendExperience();
- m_Player->Initialize(World);
+ m_Player->Initialize(*World);
m_State = csAuthenticated;
// Query player team
@@ -332,6 +360,14 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID)
// Send scoreboard data
World->GetScoreBoard().SendTo(*this);
+ // Send statistics
+ SendStatistics(m_Player->GetStatManager());
+
+ // Delay the first ping until the client "settles down"
+ // This should fix #889, "BadCast exception, cannot convert bit to fm" error in client
+ cTimer t1;
+ m_LastPingTime = t1.GetNowTime() + 3000; // Send the first KeepAlive packet in 3 seconds
+
cRoot::Get()->GetPluginManager()->CallHookPlayerSpawned(*m_Player);
}
@@ -347,7 +383,7 @@ void cClientHandle::StreamChunks(void)
}
ASSERT(m_Player != NULL);
-
+
int ChunkPosX = FAST_FLOOR_DIV((int)m_Player->GetPosX(), cChunkDef::Width);
int ChunkPosZ = FAST_FLOOR_DIV((int)m_Player->GetPosZ(), cChunkDef::Width);
if ((ChunkPosX == m_LastStreamedChunkX) && (ChunkPosZ == m_LastStreamedChunkZ))
@@ -495,11 +531,11 @@ void cClientHandle::HandlePing(void)
AString Reply;
const cServer & Server = *cRoot::Get()->GetServer();
- Printf(Reply, "%s%s%i%s%i",
+ Printf(Reply, "%s%s%i%s%i",
Server.GetDescription().c_str(),
- cChatColor::Delimiter.c_str(),
+ cChatColor::Delimiter,
Server.GetNumPlayers(),
- cChatColor::Delimiter.c_str(),
+ cChatColor::Delimiter,
Server.GetMaxPlayers()
);
Kick(Reply);
@@ -553,7 +589,7 @@ void cClientHandle::HandleCreativeInventory(short a_SlotNum, const cItem & a_Hel
void cClientHandle::HandlePlayerAbilities(bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed)
{
- UNUSED(FlyingSpeed); // Ignore the client values for these
+ UNUSED(FlyingSpeed); // Ignore the client values for these
UNUSED(WalkingSpeed);
m_Player->SetCanFly(a_CanFly);
@@ -623,12 +659,16 @@ void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString
// Client <-> Server branding exchange
SendPluginMessage("MC|Brand", "MCServer");
}
+ else if (a_Channel == "MC|ItemName")
+ {
+ HandleAnvilItemName(a_Message.c_str(), a_Message.size());
+ }
else if (a_Channel == "REGISTER")
{
if (HasPluginChannel(a_Channel))
{
SendPluginMessage("UNREGISTER", a_Channel);
- return; // Can't register again if already taken - kinda defeats the point of plugin messaging!
+ return; // Can't register again if already taken - kinda defeats the point of plugin messaging!
}
RegisterPluginChannels(BreakApartPluginChannels(a_Message));
@@ -706,7 +746,7 @@ void cClientHandle::UnregisterPluginChannels(const AStringVector & a_ChannelList
-void cClientHandle::HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length)
+void cClientHandle::HandleCommandBlockMessage(const char * a_Data, size_t a_Length)
{
if (a_Length < 14)
{
@@ -764,6 +804,29 @@ void cClientHandle::HandleCommandBlockMessage(const char * a_Data, unsigned int
+void cClientHandle::HandleAnvilItemName(const char * a_Data, size_t a_Length)
+{
+ if (a_Length < 1)
+ {
+ return;
+ }
+
+ if ((m_Player->GetWindow() == NULL) || (m_Player->GetWindow()->GetWindowType() != cWindow::wtAnvil))
+ {
+ return;
+ }
+
+ AString Name(a_Data, a_Length);
+ if (Name.length() <= 30)
+ {
+ ((cAnvilWindow *)m_Player->GetWindow())->SetRepairedItemName(Name, m_Player);
+ }
+}
+
+
+
+
+
void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status)
{
LOGD("HandleLeftClick: {%i, %i, %i}; Face: %i; Stat: %i",
@@ -778,6 +841,17 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
return;
}
+ if (
+ ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored
+ ((Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) ||
+ (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) ||
+ (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6))
+ )
+ {
+ m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
+ return;
+ }
+
cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
if (PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status))
{
@@ -803,7 +877,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
case DIG_STATUS_SHOOT_EAT:
{
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
- if (ItemHandler->IsFood())
+ if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(m_Player->GetEquippedItem().m_ItemDamage))
{
m_Player->AbortEating();
return;
@@ -841,6 +915,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
case DIG_STATUS_CANCELLED:
{
// Block breaking cancelled by player
+ FinishDigAnimation();
return;
}
@@ -851,7 +926,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
// A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
return;
}
- m_Player->TossEquippedItem(64); // Toss entire slot - if there aren't enough items, the maximum will be ejected
+ m_Player->TossEquippedItem(64); // Toss entire slot - if there aren't enough items, the maximum will be ejected
return;
}
@@ -879,7 +954,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
// It is a duplicate packet, drop it right away
return;
}
-
+
if (
m_Player->IsGameModeCreative() &&
ItemCategory::IsSword(m_Player->GetInventory().GetEquippedItem().m_ItemType)
@@ -888,20 +963,43 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
// Players can't destroy blocks with a Sword in the hand.
return;
}
-
- if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta))
+
+ if (
+ (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) ||
+ (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) ||
+ (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6)
+ )
{
- // A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows:
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
return;
}
-
+
// Set the last digging coords to the block being dug, so that they can be checked in DIG_FINISHED to avoid dig/aim bug in the client:
m_HasStartedDigging = true;
m_LastDigBlockX = a_BlockX;
m_LastDigBlockY = a_BlockY;
m_LastDigBlockZ = a_BlockZ;
+ // Check for clickthrough-blocks:
+ /* When the user breaks a fire block, the client send the wrong block location.
+ We must find the right block with the face direction. */
+ if (a_BlockFace != BLOCK_FACE_NONE)
+ {
+ int pX = a_BlockX;
+ int pY = a_BlockY;
+ int pZ = a_BlockZ;
+
+ AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false)
+ cBlockHandler * Handler = cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(pX, pY, pZ));
+
+ if (Handler->IsClickedThrough())
+ {
+ cChunkInterface ChunkInterface(m_Player->GetWorld()->GetChunkMap());
+ Handler->OnDigging(ChunkInterface, *m_Player->GetWorld(), m_Player, pX, pY, pZ);
+ return;
+ }
+ }
+
if (
(m_Player->IsGameModeCreative()) || // In creative mode, digging is done immediately
cBlockInfo::IsOneHitDig(a_OldBlock) // One-hit blocks get destroyed immediately, too
@@ -928,22 +1026,6 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
ItemHandler->OnDiggingBlock(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
-
- // Check for clickthrough-blocks:
- if (a_BlockFace != BLOCK_FACE_NONE)
- {
- int pX = a_BlockX;
- int pY = a_BlockY;
- int pZ = a_BlockZ;
-
- AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false)
- Handler = cBlockInfo::GetHandler(World->GetBlock(pX, pY, pZ));
-
- if (Handler->IsClickedThrough())
- {
- Handler->OnDigging(ChunkInterface, *World, m_Player, pX, pY, pZ);
- }
- }
}
@@ -967,28 +1049,28 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
return;
}
- m_HasStartedDigging = false;
- if (m_BlockDigAnimStage != -1)
+ FinishDigAnimation();
+
+ cWorld * World = m_Player->GetWorld();
+ cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
+
+ if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta))
{
- // End dig animation
- m_BlockDigAnimStage = -1;
- // It seems that 10 ends block animation
- m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ, 10, this);
+ // A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows:
+ m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
+ return;
}
- cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
-
if (a_OldBlock == E_BLOCK_AIR)
{
LOGD("Dug air - what the function?");
return;
}
-
- cWorld * World = m_Player->GetWorld();
+
ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ);
// The ItemHandler is also responsible for spawning the pickups
cChunkInterface ChunkInterface(World->GetChunkMap());
- BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
+ BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this);
World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
@@ -999,6 +1081,31 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
+void cClientHandle::FinishDigAnimation()
+{
+ if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet
+ {
+ return;
+ }
+
+ m_HasStartedDigging = false;
+ if (m_BlockDigAnimStage != -1)
+ {
+ // End dig animation
+ m_BlockDigAnimStage = -1;
+ // It seems that 10 ends block animation
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ, 10, this);
+ }
+
+ m_BlockDigAnimX = -1;
+ m_BlockDigAnimY = -1;
+ m_BlockDigAnimZ = -1;
+}
+
+
+
+
+
void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem)
{
LOGD("HandleRightClick: {%d, %d, %d}, face %d, HeldItem: %s",
@@ -1006,7 +1113,30 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
);
cWorld * World = m_Player->GetWorld();
-
+
+ if (
+ (a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block
+ (
+ (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || // The block is too far away
+ (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) ||
+ (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6)
+ )
+ )
+ {
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
+ if (a_BlockY < cChunkDef::Height - 1)
+ {
+ World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things
+ }
+ if (a_BlockY > 0)
+ {
+ World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, m_Player); // 2 block high things
+ }
+ m_Player->GetInventory().SendEquippedSlot();
+ return;
+ }
+
cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
{
@@ -1020,7 +1150,8 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
- World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); //2 block high things
+ World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things
+ m_Player->GetInventory().SendEquippedSlot();
}
return;
}
@@ -1038,8 +1169,8 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1))
{
// Only compare ItemType, not meta (torches have different metas)
- // The -1 check is there because sometimes the client sends -1 instead of the held item
- // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 )
+ // The -1 check is there because sometimes the client sends -1 instead of the held item
+ // Ref.: http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502
LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)",
m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType
);
@@ -1071,17 +1202,19 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
return;
}
+ short EquippedDamage = Equipped.m_ItemDamage;
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType);
if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE))
{
HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
}
- else if (ItemHandler->IsFood() && !m_Player->IsGameModeCreative())
+ else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)))
{
- if (m_Player->IsSatiated())
+ if ((m_Player->IsSatiated() || m_Player->IsGameModeCreative()) &&
+ ItemHandler->IsFood())
{
- // The player is satiated, they cannot eat
+ // The player is satiated or in creative, and trying to eat
return;
}
m_Player->StartEating();
@@ -1089,9 +1222,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
// A plugin won't let us eat, abort (send the proper packets to the client, too):
m_Player->AbortEating();
- return;
}
- return;
}
else
{
@@ -1208,7 +1339,8 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e
if (!a_ItemHandler.GetPlacementBlockTypeMeta(World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta))
{
// Handler refused the placement, send that information back to the client:
- World->SendBlockTo(a_BlockX, a_BlockY, a_BlockY, m_Player);
+ World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
+ m_Player->GetInventory().SendEquippedSlot();
return;
}
@@ -1218,6 +1350,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
// A plugin doesn't agree with placing the block, revert the block on the client:
World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
+ m_Player->GetInventory().SendEquippedSlot();
return;
}
@@ -1228,10 +1361,10 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e
m_Player->GetInventory().RemoveOneEquippedItem();
}
cChunkInterface ChunkInterface(World->GetChunkMap());
- NewBlock->OnPlacedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
+ NewBlock->OnPlacedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
// Step sound with 0.8f pitch is used as block placement sound
- World->BroadcastSoundEffect(NewBlock->GetStepSound(), a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.8f);
+ World->BroadcastSoundEffect(NewBlock->GetStepSound(), (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.8f);
cRoot::Get()->GetPluginManager()->CallHookPlayerPlacedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
}
@@ -1258,7 +1391,7 @@ void cClientHandle::HandleChat(const AString & a_Message)
Color = AString("@") + Color[2];
}
else
- {
+ {
Color.clear();
}
Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color);
@@ -1290,28 +1423,8 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO
void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround)
{
- if ((m_Player == NULL) || (m_State != csPlaying))
- {
- // The client hasn't been spawned yet and sends nonsense, we know better
- return;
- }
-
- /*
- // TODO: Invalid stance check
- if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65))
- {
- LOGD("Invalid stance");
- SendPlayerMoveLook();
- return;
- }
- */
-
- m_Player->MoveTo(Vector3d(a_PosX, a_PosY, a_PosZ));
- m_Player->SetStance (a_Stance);
- m_Player->SetTouchGround(a_IsOnGround);
- m_Player->SetHeadYaw (a_Rotation);
- m_Player->SetYaw (a_Rotation);
- m_Player->SetPitch (a_Pitch);
+ HandlePlayerLook(a_Rotation, a_Pitch, a_IsOnGround);
+ HandlePlayerPos(a_PosX, a_PosY, a_PosZ, a_Stance, a_IsOnGround);
}
@@ -1329,23 +1442,25 @@ void cClientHandle::HandleAnimation(char a_Animation)
// Because the animation ID sent to servers by clients are different to those sent back, we need this
switch (a_Animation)
{
- case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1
+ case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1
case 1:
case 2:
case 3:
{
- a_Animation--; // Offset by -1
+ a_Animation--; // Offset by -1
break;
}
- case 5:
+ case 5:
case 6:
case 7:
{
- a_Animation -= 2; // Offset by -2
+ a_Animation -= 2; // Offset by -2
break;
}
- default: // Anything else is the same
+ default: // Anything else is the same
+ {
break;
+ }
}
m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, a_Animation, this);
@@ -1405,8 +1520,8 @@ void cClientHandle::HandleWindowClick(char a_WindowID, short a_SlotNum, eClickAc
void cClientHandle::HandleUpdateSign(
- int a_BlockX, int a_BlockY, int a_BlockZ,
- const AString & a_Line1, const AString & a_Line2,
+ 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
)
{
@@ -1500,7 +1615,7 @@ void cClientHandle::HandleDisconnect(const AString & a_Reason)
{
LOGD("Received d/c packet from %s with reason \"%s\"", m_Username.c_str(), a_Reason.c_str());
- cRoot::Get()->GetPluginManager()->CallHookDisconnect(m_Player, a_Reason);
+ cRoot::Get()->GetPluginManager()->CallHookDisconnect(*this, a_Reason);
m_HasSentDC = true;
Destroy();
@@ -1648,7 +1763,7 @@ void cClientHandle::SendData(const char * a_Data, size_t a_Size)
{
// There is a queued overflow. Append to it, then send as much from its front as possible
m_OutgoingDataOverflow.append(a_Data, a_Size);
- int CanFit = m_OutgoingData.GetFreeSpace();
+ size_t CanFit = m_OutgoingData.GetFreeSpace();
if (CanFit > 128)
{
// No point in moving the data over if it's not large enough - too much effort for too little an effect
@@ -1666,18 +1781,8 @@ void cClientHandle::SendData(const char * a_Data, size_t a_Size)
-void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket)
+void cClientHandle::RemoveFromWorld(void)
{
- UNUSED(a_World);
- ASSERT(m_Player != NULL);
-
- if (a_SendRespawnPacket)
- {
- SendRespawn();
- }
-
- cWorld * World = m_Player->GetWorld();
-
// Remove all associated chunks:
cChunkCoordsList Chunks;
{
@@ -1687,12 +1792,10 @@ void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket)
}
for (cChunkCoordsList::iterator itr = Chunks.begin(), end = Chunks.end(); itr != end; ++itr)
{
- World->RemoveChunkClient(itr->m_ChunkX, itr->m_ChunkZ, this);
m_Protocol->SendUnloadChunk(itr->m_ChunkX, itr->m_ChunkZ);
} // for itr - Chunks[]
- // StreamChunks() called in cPlayer::MoveToWorld() after new world has been set
- // Meanwhile here, we set last streamed values to bogus ones so everything is resent
+ // Here, we set last streamed values to bogus ones so everything is resent
m_LastStreamedChunkX = 0x7fffffff;
m_LastStreamedChunkZ = 0x7fffffff;
m_HasSentPlayerChunk = false;
@@ -1721,17 +1824,6 @@ bool cClientHandle::CheckBlockInteractionsRate(void)
void cClientHandle::Tick(float a_Dt)
{
- // Handle clients that are waiting for final close while destroyed:
- if (m_State == csDestroyedWaiting)
- {
- m_TicksSinceDestruction += 1; // This field is misused for the timeout counting
- if (m_TicksSinceDestruction > TICKS_BEFORE_CLOSE)
- {
- m_State = csDestroyed;
- }
- return;
- }
-
// Process received network data:
AString IncomingData;
{
@@ -1798,14 +1890,6 @@ void cClientHandle::Tick(float a_Dt)
void cClientHandle::ServerTick(float a_Dt)
{
- // Handle clients that are waiting for final close while destroyed:
- if (m_State == csDestroyedWaiting)
- {
- // Do not wait while the client is not in the world, simply cut them off.
- m_State = csDestroyed;
- return;
- }
-
// Process received network data:
AString IncomingData;
{
@@ -1968,9 +2052,9 @@ void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializ
-void cClientHandle::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cClientHandle::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
- m_Protocol->SendCollectPickup(a_Pickup, a_Player);
+ m_Protocol->SendCollectEntity(a_Entity, a_Player);
}
@@ -2263,7 +2347,7 @@ void cClientHandle::SendPlayerSpawn(const cPlayer & a_Player)
return;
}
- LOGD("Spawning player \"%s\" on client \"%s\" @ %s",
+ LOGD("Spawning player \"%s\" on client \"%s\" @ %s",
a_Player.GetName().c_str(), GetPlayer()->GetName().c_str(), GetIPString().c_str()
);
@@ -2292,9 +2376,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec
-void cClientHandle::SendRespawn(void)
+void cClientHandle::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks)
{
- m_Protocol->SendRespawn();
+ m_Protocol->SendRespawn(a_Dimension, a_ShouldIgnoreDimensionChecks);
}
@@ -2346,9 +2430,9 @@ void cClientHandle::SendDisplayObjective(const AString & a_Objective, cScoreboar
-void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+void cClientHandle::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
- m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
+ m_Protocol->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch);
}
@@ -2391,7 +2475,7 @@ void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
-void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts
+void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts
{
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleSubType);
}
@@ -2400,6 +2484,15 @@ void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTy
+void cClientHandle::SendStatistics(const cStatManager & a_Manager)
+{
+ m_Protocol->SendStatistics(a_Manager);
+}
+
+
+
+
+
void cClientHandle::SendTabCompletionResults(const AStringVector & a_Results)
{
m_Protocol->SendTabCompletionResults(a_Results);
@@ -2468,7 +2561,7 @@ void cClientHandle::SendUpdateSign(
-void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
+void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
{
m_Protocol->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
}
@@ -2530,7 +2623,7 @@ const AString & cClientHandle::GetUsername(void) const
-void cClientHandle::SetUsername( const AString & a_Username )
+void cClientHandle::SetUsername( const AString & a_Username)
{
m_Username = a_Username;
}
@@ -2639,12 +2732,13 @@ void cClientHandle::PacketError(unsigned char a_PacketType)
-void cClientHandle::DataReceived(const char * a_Data, size_t a_Size)
+bool cClientHandle::DataReceived(const char * a_Data, size_t a_Size)
{
// Data is received from the client, store it in the buffer to be processed by the Tick thread:
m_TimeSinceLastPacket = 0;
cCSLock Lock(m_CSIncomingData);
m_IncomingData.append(a_Data, a_Size);
+ return false;
}
@@ -2679,9 +2773,9 @@ void cClientHandle::SocketClosed(void)
LOGD("Player %s @ %s disconnected", m_Username.c_str(), m_IPString.c_str());
- if (m_Username != "") // Ignore client pings
+ if (!m_Username.empty()) // Ignore client pings
{
- cRoot::Get()->GetPluginManager()->CallHookDisconnect(m_Player, "Player disconnected");
+ cRoot::Get()->GetPluginManager()->CallHookDisconnect(*this, "Player disconnected");
}
Destroy();
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 9f8d44129..48eba4de1 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -20,6 +20,7 @@
#include "Map.h"
#include "Enchantments.h"
#include "UI/SlotArea.h"
+#include "json/json.h"
@@ -39,6 +40,7 @@ class cFallingBlock;
class cItemHandler;
class cWorld;
class cCompositeChat;
+class cStatManager;
@@ -46,7 +48,7 @@ class cCompositeChat;
class cClientHandle : // tolua_export
public cSocketThreads::cCallback
-{ // tolua_export
+{ // tolua_export
public:
#if defined(ANDROID_NDK)
@@ -54,18 +56,20 @@ public:
#else
static const int DEFAULT_VIEW_DISTANCE = 10;
#endif
- static const int MAX_VIEW_DISTANCE = 15;
- static const int MIN_VIEW_DISTANCE = 3;
+ static const int MAX_VIEW_DISTANCE = 32;
+ static const int MIN_VIEW_DISTANCE = 1;
cClientHandle(const cSocket * a_Socket, int a_ViewDistance);
virtual ~cClientHandle();
const AString & GetIPString(void) const { return m_IPString; }
- cPlayer* GetPlayer() { return m_Player; } // tolua_export
+ cPlayer * GetPlayer(void) { return m_Player; } // tolua_export
- const AString & GetUUID(void) const { return m_UUID; } // tolua_export
+ const AString & GetUUID(void) const { return m_UUID; } // tolua_export
void SetUUID(const AString & a_UUID) { m_UUID = a_UUID; }
+
+ const Json::Value & GetProperties(void) const { return m_Properties; }
/** Generates an UUID based on the username stored for this client, and stores it in the m_UUID member.
This is used for the offline (non-auth) mode, when there's no UUID source.
@@ -75,16 +79,25 @@ public:
/** Generates an UUID based on the player name provided.
This is used for the offline (non-auth) mode, when there's no UUID source.
- Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. */
+ Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same.
+ Returns a 36-char UUID (with dashes). */
static AString GenerateOfflineUUID(const AString & a_Username); // tolua_export
+ /** Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID.
+ We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart.
+ Accepts both 32-char and 36-char UUIDs (with and without dashes).
+ If the string given is not a valid UUID, returns false. */
+ static bool IsUUIDOnline(const AString & a_UUID); // tolua_export
+
/** Formats the type of message with the proper color and prefix for sending to the client. **/
- AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData);
+ static AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData);
- AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2);
+ static AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2);
+
+ void Kick(const AString & a_Reason); // tolua_export
- void Kick(const AString & a_Reason); // tolua_export
- void Authenticate(const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator when the user passes authentication
+ /** Authenticates the specified user, called by cAuthenticator */
+ void Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties);
void StreamChunks(void);
@@ -110,12 +123,12 @@ public:
void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType);
void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage);
- void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_export
+ void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_export
void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes);
void SendChat (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
void SendChat (const cCompositeChat & a_Message);
void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer);
- void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player);
+ void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player);
void SendDestroyEntity (const cEntity & a_Entity);
void SendDisconnect (const AString & a_Reason);
void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ);
@@ -138,7 +151,7 @@ public:
void SendMapInfo (int a_ID, unsigned int a_Scale);
void SendPaintingSpawn (const cPainting & a_Painting);
void SendPickupSpawn (const cPickup & a_Pickup);
- void SendEntityAnimation (const cEntity & a_Entity, char a_Animation);
+ void SendEntityAnimation (const cEntity & a_Entity, char a_Animation); // tolua_export
void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount);
void SendPlayerAbilities (void);
void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline);
@@ -148,18 +161,19 @@ public:
void SendPlayerSpawn (const cPlayer & a_Player);
void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp
void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID);
- void SendRespawn (void);
+ void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks = false);
void SendExperience (void);
void SendExperienceOrb (const cExpOrb & a_ExpOrb);
void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode);
void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode);
void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display);
- void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8
+ void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch); // tolua_export
void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data);
void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock);
void SendSpawnMob (const cMonster & a_Mob);
void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch);
void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType = 0);
+ void SendStatistics (const cStatManager & a_Manager);
void SendTabCompletionResults(const AStringVector & a_Results);
void SendTeleportEntity (const cEntity & a_Entity);
void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ);
@@ -167,7 +181,7 @@ public:
void SendUnloadChunk (int a_ChunkX, int a_ChunkZ);
void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity);
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);
- void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
+ void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ);
void SendWeather (eWeather a_Weather);
void SendWholeInventory (const cWindow & a_Window);
void SendWindowClose (const cWindow & a_Window);
@@ -176,7 +190,7 @@ public:
// tolua_begin
const AString & GetUsername(void) const;
- void SetUsername( const AString & a_Username );
+ void SetUsername( const AString & a_Username);
inline short GetPing(void) const { return m_Ping; }
@@ -232,8 +246,8 @@ public:
void HandleSteerVehicle (float Forward, float Sideways);
void HandleTabCompletion (const AString & a_Text);
void HandleUpdateSign (
- int a_BlockX, int a_BlockY, int a_BlockZ,
- const AString & a_Line1, const AString & a_Line2,
+ 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
);
void HandleUnmount (void);
@@ -248,28 +262,29 @@ public:
void SendData(const char * a_Data, size_t a_Size);
- /** Called when the player moves into a different world; queues sreaming the new chunks */
- void MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket);
+ /** Called when the player moves into a different world.
+ Sends an UnloadChunk packet for each loaded chunk and resets the streamed chunks. */
+ void RemoveFromWorld(void);
/** Called when the player will enchant a Item */
void HandleEnchantItem(Byte & WindowID, Byte & Enchantment);
private:
- /** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */
- void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
-
/** The type used for storing the names of registered plugin channels. */
typedef std::set<AString> cChannels;
- int m_ViewDistance; // Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 )
+ /** Number of chunks the player can see in each direction */
+ int m_ViewDistance;
- static const int GENERATEDISTANCE = 2; // Server generates this many chunks AHEAD of player sight. 2 is the minimum, since foliage is generated 1 step behind chunk terrain generation
+ /** Server generates this many chunks AHEAD of player sight. */
+ static const int GENERATEDISTANCE = 2;
AString m_IPString;
AString m_Username;
AString m_Password;
+ Json::Value m_Properties;
cCriticalSection m_CSChunkLists;
cChunkCoordsList m_LoadedChunks; // Chunks that the player belongs to
@@ -301,7 +316,7 @@ private:
int m_PingID;
long long m_PingStartTime;
long long m_LastPingTime;
- static const unsigned short PING_TIME_MS = 1000; //minecraft sends 1 per 20 ticks (1 second or every 1000 ms)
+ static const unsigned short PING_TIME_MS = 1000; // Vanilla sends 1 per 20 ticks (1 second or every 1000 ms)
// Values required for block dig animation
int m_BlockDigAnimStage; // Current stage of the animation; -1 if not digging
@@ -315,9 +330,6 @@ private:
int m_LastDigBlockX;
int m_LastDigBlockY;
int m_LastDigBlockZ;
-
- /** Used while csDestroyedWaiting for counting the ticks until the connection is closed */
- int m_TicksSinceDestruction;
enum eState
{
@@ -325,10 +337,9 @@ private:
csAuthenticating, ///< The client has logged in, waiting for external authentication
csAuthenticated, ///< The client has been authenticated, will start streaming chunks in the next tick
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
+ csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back
csPlaying, ///< Normal gameplay
csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks
- csDestroyedWaiting, ///< The client has been destroyed, but is still kept so that the Kick packet is delivered (#31)
csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread
// TODO: Add Kicking here as well
@@ -362,6 +373,9 @@ private:
cChannels m_PluginChannels;
+ /** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */
+ void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
+
/** Returns true if the rate block interactions is within a reasonable limit (bot protection) */
bool CheckBlockInteractionsRate(void);
@@ -374,6 +388,9 @@ private:
/** Handles the DIG_FINISHED dig packet: */
void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
+ /** The clients will receive a finished dig animation */
+ void FinishDigAnimation();
+
/** Converts the protocol-formatted channel list (NUL-separated) into a proper string vector. */
AStringVector BreakApartPluginChannels(const AString & a_PluginChannels);
@@ -384,13 +401,16 @@ private:
void UnregisterPluginChannels(const AStringVector & a_ChannelList);
/** Handles the "MC|AdvCdm" plugin message */
- void HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length);
+ void HandleCommandBlockMessage(const char * a_Data, size_t a_Length);
+
+ /** Handles the "MC|ItemName" plugin message */
+ void HandleAnvilItemName(const char * a_Data, size_t a_Length);
// cSocketThreads::cCallback overrides:
- virtual void DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client
+ virtual bool DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client
virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client
virtual void SocketClosed (void) override; // The socket has been closed for any reason
-}; // tolua_export
+}; // tolua_export
diff --git a/src/CommandOutput.cpp b/src/CommandOutput.cpp
index 2c116b3d6..510461d81 100644
--- a/src/CommandOutput.cpp
+++ b/src/CommandOutput.cpp
@@ -10,7 +10,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCommandOutputCallback:
void cCommandOutputCallback::Out(const char * a_Fmt, ...)
@@ -28,7 +28,7 @@ void cCommandOutputCallback::Out(const char * a_Fmt, ...)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cLogCommandOutputCallback:
void cLogCommandOutputCallback::Out(const AString & a_Text)
diff --git a/src/CommandOutput.h b/src/CommandOutput.h
index 5682b4fd8..daa9430c0 100644
--- a/src/CommandOutput.h
+++ b/src/CommandOutput.h
@@ -14,16 +14,16 @@ Descendants override that function to provide specific processing of the output.
class cCommandOutputCallback
{
public:
- virtual ~cCommandOutputCallback() {}; // Force a virtual destructor in subclasses
+ virtual ~cCommandOutputCallback() {} // Force a virtual destructor in subclasses
- /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a "\n"
+ /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a newline"
void Out(const char * a_Fmt, ...) FORMATSTRING(2, 3);
/// Called when the command wants to output anything; may be called multiple times
virtual void Out(const AString & a_Text) = 0;
/// Called when the command processing has been finished
- virtual void Finished(void) {};
+ virtual void Finished(void) {}
} ;
diff --git a/src/CompositeChat.cpp b/src/CompositeChat.cpp
index c70ef1070..f1a797897 100644
--- a/src/CompositeChat.cpp
+++ b/src/CompositeChat.cpp
@@ -100,7 +100,7 @@ public:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompositeChat:
cCompositeChat::cCompositeChat(void) :
@@ -189,6 +189,15 @@ void cCompositeChat::AddSuggestCommandPart(const AString & a_Text, const AString
+void cCompositeChat::AddShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style)
+{
+ m_Parts.push_back(new cShowAchievementPart(a_PlayerName, a_Achievement, a_Style));
+}
+
+
+
+
+
void cCompositeChat::ParseText(const AString & a_ParseText)
{
size_t len = a_ParseText.length();
@@ -290,9 +299,10 @@ void cCompositeChat::ParseText(const AString & a_ParseText)
-void cCompositeChat::SetMessageType(eMessageType a_MessageType)
+void cCompositeChat::SetMessageType(eMessageType a_MessageType, const AString & a_AdditionalMessageTypeData)
{
m_MessageType = a_MessageType;
+ m_AdditionalMessageTypeData = a_AdditionalMessageTypeData;
}
@@ -389,7 +399,7 @@ void cCompositeChat::AddStyle(AString & a_Style, const AString & a_AddStyle)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompositeChat::cBasePart:
cCompositeChat::cBasePart::cBasePart(cCompositeChat::ePartType a_PartType, const AString & a_Text, const AString & a_Style) :
@@ -403,7 +413,7 @@ cCompositeChat::cBasePart::cBasePart(cCompositeChat::ePartType a_PartType, const
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompositeChat::cTextPart:
cCompositeChat::cTextPart::cTextPart(const AString & a_Text, const AString &a_Style) :
@@ -415,7 +425,7 @@ cCompositeChat::cTextPart::cTextPart(const AString & a_Text, const AString &a_St
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompositeChat::cClientTranslatedPart:
cCompositeChat::cClientTranslatedPart::cClientTranslatedPart(const AString & a_TranslationID, const AStringVector & a_Parameters, const AString & a_Style) :
@@ -428,7 +438,7 @@ cCompositeChat::cClientTranslatedPart::cClientTranslatedPart(const AString & a_T
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompositeChat::cUrlPart:
cCompositeChat::cUrlPart::cUrlPart(const AString & a_Text, const AString & a_Url, const AString & a_Style) :
@@ -441,7 +451,7 @@ cCompositeChat::cUrlPart::cUrlPart(const AString & a_Text, const AString & a_Url
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompositeChat::cCommandPart:
cCompositeChat::cCommandPart::cCommandPart(ePartType a_PartType, const AString & a_Text, const AString & a_Command, const AString & a_Style) :
@@ -454,7 +464,7 @@ cCompositeChat::cCommandPart::cCommandPart(ePartType a_PartType, const AString &
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompositeChat::cRunCommandPart:
cCompositeChat::cRunCommandPart::cRunCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style) :
@@ -465,7 +475,7 @@ cCompositeChat::cRunCommandPart::cRunCommandPart(const AString & a_Text, const A
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompositeChat::cSuggestCommandPart:
cCompositeChat::cSuggestCommandPart::cSuggestCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style) :
@@ -476,3 +486,16 @@ cCompositeChat::cSuggestCommandPart::cSuggestCommandPart(const AString & a_Text,
+
+////////////////////////////////////////////////////////////////////////////////
+// cCompositeChat::cShowAchievementPart:
+
+cCompositeChat::cShowAchievementPart::cShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style) :
+ super(ptShowAchievement, a_Achievement, a_Style),
+ m_PlayerName(a_PlayerName)
+{
+}
+
+
+
+
diff --git a/src/CompositeChat.h b/src/CompositeChat.h
index 5b9c5f612..1ad196f1d 100644
--- a/src/CompositeChat.h
+++ b/src/CompositeChat.h
@@ -38,6 +38,7 @@ public:
ptUrl,
ptRunCommand,
ptSuggestCommand,
+ ptShowAchievement,
} ;
class cBasePart
@@ -46,6 +47,7 @@ public:
ePartType m_PartType;
AString m_Text;
AString m_Style;
+ AString m_AdditionalStyleData;
cBasePart(ePartType a_PartType, const AString & a_Text, const AString & a_Style = "");
@@ -106,6 +108,15 @@ public:
public:
cSuggestCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style = "");
} ;
+
+ class cShowAchievementPart :
+ public cBasePart
+ {
+ typedef cBasePart super;
+ public:
+ AString m_PlayerName;
+ cShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style = "");
+ } ;
typedef std::vector<cBasePart *> cParts;
@@ -148,13 +159,20 @@ public:
/** Adds a part that suggests a command (enters it into the chat message area, but doesn't send) when clicked.
The default style is underlined yellow text. */
void AddSuggestCommandPart(const AString & a_Text, const AString & a_SuggestedCommand, const AString & a_Style = "u@b");
+
+ /** Adds a part that fully formats a specified achievement using client translatable strings
+ Takes achievement name and player awarded to. Displays as {player} has earned the achievement {achievement_name}.
+ */
+ void AddShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style = "");
/** Parses text into various parts, adds those.
Recognizes "http:" and "https:" URLs and @color-codes. */
void ParseText(const AString & a_ParseText);
- /** Sets the message type, which is indicated by prefixes added to the message when serializing. */
- void SetMessageType(eMessageType a_MessageType);
+ /** Sets the message type, which is indicated by prefixes added to the message when serializing
+ Takes optional AdditionalMessageTypeData to set m_AdditionalMessageTypeData. See said variable for more documentation.
+ */
+ void SetMessageType(eMessageType a_MessageType, const AString & a_AdditionalMessageTypeData = "");
/** Adds the "underline" style to each part that is an URL. */
void UnderlineUrls(void);
@@ -163,6 +181,9 @@ public:
/** Returns the message type set previously by SetMessageType(). */
eMessageType GetMessageType(void) const { return m_MessageType; }
+
+ /** Returns additional data pertaining to message type, for example, the name of a mtPrivateMsg sender */
+ AString GetAdditionalMessageTypeData(void) const { return m_AdditionalMessageTypeData; }
/** Returns the text from the parts that comprises the human-readable data.
Used for older protocols that don't support composite chat
@@ -184,6 +205,9 @@ protected:
/** The message type, as indicated by prefixes. */
eMessageType m_MessageType;
+ /** Additional data pertaining to message type, for example, the name of a mtPrivateMsg sender */
+ AString m_AdditionalMessageTypeData;
+
/** Adds a_AddStyle to a_Style; overwrites the existing style if appropriate.
If the style already contains something that a_AddStyle overrides, it is erased first. */
diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp
index b0af8f271..1a31a6e90 100644
--- a/src/CraftingRecipes.cpp
+++ b/src/CraftingRecipes.cpp
@@ -12,7 +12,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCraftingGrid:
cCraftingGrid::cCraftingGrid(int a_Width, int a_Height) :
@@ -59,6 +59,7 @@ cCraftingGrid::cCraftingGrid(const cCraftingGrid & a_Original) :
cCraftingGrid::~cCraftingGrid()
{
delete[] m_Items;
+ m_Items = NULL;
}
@@ -134,7 +135,7 @@ void cCraftingGrid::ConsumeGrid(const cCraftingGrid & a_Grid)
{
if ((a_Grid.m_Width != m_Width) || (a_Grid.m_Height != m_Height))
{
- LOGWARNING("Consuming a grid of different dimensions: (%d, %d) vs (%d, %d)",
+ LOGWARNING("Consuming a grid of different dimensions: (%d, %d) vs (%d, %d)",
a_Grid.m_Width, a_Grid.m_Height, m_Width, m_Height
);
}
@@ -195,7 +196,7 @@ void cCraftingGrid::Dump(void)
#ifdef _DEBUG
int idx = x + m_Width * y;
#endif
- LOGD("Slot (%d, %d): Type %d, health %d, count %d",
+ LOGD("Slot (%d, %d): Type %d, health %d, count %d",
x, y, m_Items[idx].m_ItemType, m_Items[idx].m_ItemDamage, m_Items[idx].m_ItemCount
);
}
@@ -205,7 +206,7 @@ void cCraftingGrid::Dump(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCraftingRecipe:
cCraftingRecipe::cCraftingRecipe(const cCraftingGrid & a_CraftingGrid) :
@@ -249,7 +250,7 @@ void cCraftingRecipe::Dump(void)
{
LOGD("Recipe ingredients:");
m_Ingredients.Dump();
- LOGD("Result: Type %d, health %d, count %d",
+ LOGD("Result: Type %d, health %d, count %d",
m_Result.m_ItemType, m_Result.m_ItemDamage, m_Result.m_ItemCount
);
}
@@ -258,7 +259,7 @@ void cCraftingRecipe::Dump(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCraftingRecipes:
cCraftingRecipes::cCraftingRecipes(void)
@@ -581,7 +582,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipe(const cItem * a_Craftin
// Get the real bounds of the crafting grid:
int GridLeft = MAX_GRID_WIDTH, GridTop = MAX_GRID_HEIGHT;
int GridRight = 0, GridBottom = 0;
- for (int y = 0; y < a_GridHeight; y++ ) for(int x = 0; x < a_GridWidth; x++)
+ for (int y = 0; y < a_GridHeight; y++) for (int x = 0; x < a_GridWidth; x++)
{
if (!a_CraftingGrid[x + y * a_GridWidth].IsEmpty())
{
@@ -664,7 +665,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
const cItem & Item = itrS->m_Item;
if (
- (itrS->x >= a_GridWidth) ||
+ (itrS->x >= a_GridWidth) ||
(itrS->y >= a_GridHeight) ||
(Item.m_ItemType != a_CraftingGrid[GridID].m_ItemType) || // same item type?
(Item.m_ItemCount > a_CraftingGrid[GridID].m_ItemCount) || // not enough items
@@ -802,7 +803,7 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe
break;
}
case E_ITEM_PAPER: break;
- default: LOG("Unexpected item in firework rocket a_Recipe, was the crafting file fireworks section changed?"); break;
+ default: LOG("Unexpected item in firework rocket recipe, was the crafting file's fireworks section changed?"); break;
}
}
}
@@ -837,7 +838,7 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe
case E_ITEM_GOLD_NUGGET: a_Recipe->m_Result.m_FireworkItem.m_Type = 2; break;
case E_ITEM_FEATHER: a_Recipe->m_Result.m_FireworkItem.m_Type = 4; break;
case E_ITEM_HEAD: a_Recipe->m_Result.m_FireworkItem.m_Type = 3; break;
- default: LOG("Unexpected item in firework star a_Recipe, was the crafting file fireworks section changed?"); break; // ermahgerd BARD ardmins
+ default: LOG("Unexpected item in firework star recipe, was the crafting file's fireworks section changed?"); break; // ermahgerd BARD ardmins
}
}
diff --git a/src/CraftingRecipes.h b/src/CraftingRecipes.h
index 90e41eddc..0250d2f68 100644
--- a/src/CraftingRecipes.h
+++ b/src/CraftingRecipes.h
@@ -127,7 +127,7 @@ protected:
typedef std::vector<cRecipeSlot> cRecipeSlots;
/** A single recipe, stored. Each recipe is normalized right after parsing (NormalizeIngredients())
- A normalized recipe starts at (0,0)
+ A normalized recipe starts at (0, 0)
*/
struct cRecipe
{
diff --git a/src/Crypto.cpp b/src/Crypto.cpp
deleted file mode 100644
index 16be5ec35..000000000
--- a/src/Crypto.cpp
+++ /dev/null
@@ -1,509 +0,0 @@
-
-// Crypto.cpp
-
-// Implements classes that wrap the cryptographic code library
-
-#include "Globals.h"
-#include "Crypto.h"
-
-#include "polarssl/pk.h"
-
-
-
-
-
-/*
-// Self-test the hash formatting for known values:
-// sha1(Notch) : 4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48
-// sha1(jeb_) : -7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1
-// sha1(simon) : 88e16a1019277b15d58faf0541e11910eb756f6
-
-class Test
-{
-public:
- Test(void)
- {
- AString DigestNotch, DigestJeb, DigestSimon;
- Byte Digest[20];
- cSHA1Checksum Checksum;
- Checksum.Update((const Byte *)"Notch", 5);
- Checksum.Finalize(Digest);
- cSHA1Checksum::DigestToJava(Digest, DigestNotch);
- Checksum.Restart();
- Checksum.Update((const Byte *)"jeb_", 4);
- Checksum.Finalize(Digest);
- cSHA1Checksum::DigestToJava(Digest, DigestJeb);
- Checksum.Restart();
- Checksum.Update((const Byte *)"simon", 5);
- Checksum.Finalize(Digest);
- cSHA1Checksum::DigestToJava(Digest, DigestSimon);
- printf("Notch: \"%s\"\n", DigestNotch.c_str());
- printf("jeb_: \"%s\"\n", DigestJeb.c_str());
- printf("simon: \"%s\"\n", DigestSimon.c_str());
- assert(DigestNotch == "4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48");
- assert(DigestJeb == "-7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1");
- assert(DigestSimon == "88e16a1019277b15d58faf0541e11910eb756f6");
- }
-} test;
-*/
-
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cRSAPrivateKey:
-
-cRSAPrivateKey::cRSAPrivateKey(void)
-{
- rsa_init(&m_Rsa, RSA_PKCS_V15, 0);
- InitRnd();
-}
-
-
-
-
-
-cRSAPrivateKey::cRSAPrivateKey(const cRSAPrivateKey & a_Other)
-{
- rsa_init(&m_Rsa, RSA_PKCS_V15, 0);
- rsa_copy(&m_Rsa, &a_Other.m_Rsa);
- InitRnd();
-}
-
-
-
-
-
-cRSAPrivateKey::~cRSAPrivateKey()
-{
- entropy_free(&m_Entropy);
- rsa_free(&m_Rsa);
-}
-
-
-
-
-
-void cRSAPrivateKey::InitRnd(void)
-{
- entropy_init(&m_Entropy);
- const unsigned char pers[] = "rsa_genkey";
- ctr_drbg_init(&m_Ctr_drbg, entropy_func, &m_Entropy, pers, sizeof(pers) - 1);
-}
-
-
-
-
-
-bool cRSAPrivateKey::Generate(unsigned a_KeySizeBits)
-{
- if (rsa_gen_key(&m_Rsa, ctr_drbg_random, &m_Ctr_drbg, a_KeySizeBits, 65537) != 0)
- {
- // Key generation failed
- return false;
- }
-
- return true;
-}
-
-
-
-
-
-AString cRSAPrivateKey::GetPubKeyDER(void)
-{
- class cPubKey
- {
- public:
- cPubKey(rsa_context * a_Rsa) :
- m_IsValid(false)
- {
- pk_init(&m_Key);
- if (pk_init_ctx(&m_Key, pk_info_from_type(POLARSSL_PK_RSA)) != 0)
- {
- ASSERT(!"Cannot init PrivKey context");
- return;
- }
- if (rsa_copy(pk_rsa(m_Key), a_Rsa) != 0)
- {
- ASSERT(!"Cannot copy PrivKey to PK context");
- return;
- }
- m_IsValid = true;
- }
-
- ~cPubKey()
- {
- if (m_IsValid)
- {
- pk_free(&m_Key);
- }
- }
-
- operator pk_context * (void) { return &m_Key; }
-
- protected:
- bool m_IsValid;
- pk_context m_Key;
- } PkCtx(&m_Rsa);
-
- unsigned char buf[3000];
- int res = pk_write_pubkey_der(PkCtx, buf, sizeof(buf));
- if (res < 0)
- {
- return AString();
- }
- return AString((const char *)(buf + sizeof(buf) - res), (size_t)res);
-}
-
-
-
-
-
-int cRSAPrivateKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength)
-{
- if (a_EncryptedLength < m_Rsa.len)
- {
- LOGD("%s: Invalid a_EncryptedLength: got %u, exp at least %u",
- __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len)
- );
- ASSERT(!"Invalid a_DecryptedMaxLength!");
- return -1;
- }
- if (a_DecryptedMaxLength < m_Rsa.len)
- {
- LOGD("%s: Invalid a_DecryptedMaxLength: got %u, exp at least %u",
- __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len)
- );
- ASSERT(!"Invalid a_DecryptedMaxLength!");
- return -1;
- }
- size_t DecryptedLength;
- int res = rsa_pkcs1_decrypt(
- &m_Rsa, ctr_drbg_random, &m_Ctr_drbg, RSA_PRIVATE, &DecryptedLength,
- a_EncryptedData, a_DecryptedData, a_DecryptedMaxLength
- );
- if (res != 0)
- {
- return -1;
- }
- return (int)DecryptedLength;
-}
-
-
-
-
-
-int cRSAPrivateKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength)
-{
- if (a_EncryptedMaxLength < m_Rsa.len)
- {
- LOGD("%s: Invalid a_EncryptedMaxLength: got %u, exp at least %u",
- __FUNCTION__, (unsigned)a_EncryptedMaxLength, (unsigned)(m_Rsa.len)
- );
- ASSERT(!"Invalid a_DecryptedMaxLength!");
- return -1;
- }
- if (a_PlainLength < m_Rsa.len)
- {
- LOGD("%s: Invalid a_PlainLength: got %u, exp at least %u",
- __FUNCTION__, (unsigned)a_PlainLength, (unsigned)(m_Rsa.len)
- );
- ASSERT(!"Invalid a_PlainLength!");
- return -1;
- }
- int res = rsa_pkcs1_encrypt(
- &m_Rsa, ctr_drbg_random, &m_Ctr_drbg, RSA_PRIVATE,
- a_PlainLength, a_PlainData, a_EncryptedData
- );
- if (res != 0)
- {
- return -1;
- }
- return (int)m_Rsa.len;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cPublicKey:
-
-cPublicKey::cPublicKey(const AString & a_PublicKeyDER)
-{
- pk_init(&m_Pk);
- if (pk_parse_public_key(&m_Pk, (const Byte *)a_PublicKeyDER.data(), a_PublicKeyDER.size()) != 0)
- {
- ASSERT(!"Cannot parse PubKey");
- return;
- }
- InitRnd();
-}
-
-
-
-
-
-cPublicKey::~cPublicKey()
-{
- pk_free(&m_Pk);
-}
-
-
-
-
-
-int cPublicKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength)
-{
- size_t DecryptedLen = a_DecryptedMaxLength;
- int res = pk_decrypt(&m_Pk,
- a_EncryptedData, a_EncryptedLength,
- a_DecryptedData, &DecryptedLen, a_DecryptedMaxLength,
- ctr_drbg_random, &m_Ctr_drbg
- );
- if (res != 0)
- {
- return res;
- }
- return (int)DecryptedLen;
-}
-
-
-
-
-
-int cPublicKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength)
-{
- size_t EncryptedLength = a_EncryptedMaxLength;
- int res = pk_encrypt(&m_Pk,
- a_PlainData, a_PlainLength, a_EncryptedData, &EncryptedLength, a_EncryptedMaxLength,
- ctr_drbg_random, &m_Ctr_drbg
- );
- if (res != 0)
- {
- return res;
- }
- return (int)EncryptedLength;
-}
-
-
-
-
-
-void cPublicKey::InitRnd(void)
-{
- entropy_init(&m_Entropy);
- const unsigned char pers[] = "rsa_genkey";
- ctr_drbg_init(&m_Ctr_drbg, entropy_func, &m_Entropy, pers, sizeof(pers) - 1);
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cAESCFBDecryptor:
-
-cAESCFBDecryptor::cAESCFBDecryptor(void) :
- m_IVOffset(0),
- m_IsValid(false)
-{
-}
-
-
-
-
-
-cAESCFBDecryptor::~cAESCFBDecryptor()
-{
- // Clear the leftover in-memory data, so that they can't be accessed by a backdoor
- memset(&m_Aes, 0, sizeof(m_Aes));
-}
-
-
-
-
-
-void cAESCFBDecryptor::Init(const Byte a_Key[16], const Byte a_IV[16])
-{
- ASSERT(!IsValid()); // Cannot Init twice
-
- memcpy(m_IV, a_IV, 16);
- aes_setkey_enc(&m_Aes, a_Key, 128);
- m_IsValid = true;
-}
-
-
-
-
-
-void cAESCFBDecryptor::ProcessData(Byte * a_DecryptedOut, const Byte * a_EncryptedIn, size_t a_Length)
-{
- ASSERT(IsValid()); // Must Init() first
-
- // PolarSSL doesn't support AES-CFB8, need to implement it manually:
- for (size_t i = 0; i < a_Length; i++)
- {
- Byte Buffer[sizeof(m_IV)];
- aes_crypt_ecb(&m_Aes, AES_ENCRYPT, m_IV, Buffer);
- for (size_t idx = 0; idx < sizeof(m_IV) - 1; idx++)
- {
- m_IV[idx] = m_IV[idx + 1];
- }
- m_IV[sizeof(m_IV) - 1] = a_EncryptedIn[i];
- a_DecryptedOut[i] = a_EncryptedIn[i] ^ Buffer[0];
- }
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cAESCFBEncryptor:
-
-cAESCFBEncryptor::cAESCFBEncryptor(void) :
- m_IVOffset(0),
- m_IsValid(false)
-{
-}
-
-
-
-
-
-cAESCFBEncryptor::~cAESCFBEncryptor()
-{
- // Clear the leftover in-memory data, so that they can't be accessed by a backdoor
- memset(&m_Aes, 0, sizeof(m_Aes));
-}
-
-
-
-
-
-void cAESCFBEncryptor::Init(const Byte a_Key[16], const Byte a_IV[16])
-{
- ASSERT(!IsValid()); // Cannot Init twice
- ASSERT(m_IVOffset == 0);
-
- memcpy(m_IV, a_IV, 16);
- aes_setkey_enc(&m_Aes, a_Key, 128);
- m_IsValid = true;
-}
-
-
-
-
-
-void cAESCFBEncryptor::ProcessData(Byte * a_EncryptedOut, const Byte * a_PlainIn, size_t a_Length)
-{
- ASSERT(IsValid()); // Must Init() first
-
- // PolarSSL doesn't do AES-CFB8, so we need to implement it ourselves:
- for (size_t i = 0; i < a_Length; i++)
- {
- Byte Buffer[sizeof(m_IV)];
- aes_crypt_ecb(&m_Aes, AES_ENCRYPT, m_IV, Buffer);
- for (size_t idx = 0; idx < sizeof(m_IV) - 1; idx++)
- {
- m_IV[idx] = m_IV[idx + 1];
- }
- a_EncryptedOut[i] = a_PlainIn[i] ^ Buffer[0];
- m_IV[sizeof(m_IV) - 1] = a_EncryptedOut[i];
- }
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSHA1Checksum:
-
-cSHA1Checksum::cSHA1Checksum(void) :
- m_DoesAcceptInput(true)
-{
- sha1_starts(&m_Sha1);
-}
-
-
-
-
-
-void cSHA1Checksum::Update(const Byte * a_Data, size_t a_Length)
-{
- ASSERT(m_DoesAcceptInput); // Not Finalize()-d yet, or Restart()-ed
-
- sha1_update(&m_Sha1, a_Data, a_Length);
-}
-
-
-
-
-
-void cSHA1Checksum::Finalize(cSHA1Checksum::Checksum & a_Output)
-{
- ASSERT(m_DoesAcceptInput); // Not Finalize()-d yet, or Restart()-ed
-
- sha1_finish(&m_Sha1, a_Output);
- m_DoesAcceptInput = false;
-}
-
-
-
-
-
-void cSHA1Checksum::DigestToJava(const Checksum & a_Digest, AString & a_Out)
-{
- Checksum Digest;
- memcpy(Digest, a_Digest, sizeof(Digest));
-
- bool IsNegative = (Digest[0] >= 0x80);
- if (IsNegative)
- {
- // Two's complement:
- bool carry = true; // Add one to the whole number
- for (int i = 19; i >= 0; i--)
- {
- Digest[i] = ~Digest[i];
- if (carry)
- {
- carry = (Digest[i] == 0xff);
- Digest[i]++;
- }
- }
- }
- a_Out.clear();
- a_Out.reserve(40);
- for (int i = 0; i < 20; i++)
- {
- AppendPrintf(a_Out, "%02x", Digest[i]);
- }
- while ((a_Out.length() > 0) && (a_Out[0] == '0'))
- {
- a_Out.erase(0, 1);
- }
- if (IsNegative)
- {
- a_Out.insert(0, "-");
- }
-}
-
-
-
-
-
-
-void cSHA1Checksum::Restart(void)
-{
- sha1_starts(&m_Sha1);
- m_DoesAcceptInput = true;
-}
-
-
-
-
diff --git a/src/Crypto.h b/src/Crypto.h
deleted file mode 100644
index a9ec2c6d4..000000000
--- a/src/Crypto.h
+++ /dev/null
@@ -1,198 +0,0 @@
-
-// Crypto.h
-
-// Declares classes that wrap the cryptographic code library
-
-
-
-
-
-#pragma once
-
-#include "polarssl/rsa.h"
-#include "polarssl/aes.h"
-#include "polarssl/entropy.h"
-#include "polarssl/ctr_drbg.h"
-#include "polarssl/sha1.h"
-#include "polarssl/pk.h"
-
-
-
-
-
-/** Encapsulates an RSA private key used in PKI cryptography */
-class cRSAPrivateKey
-{
-public:
- /** Creates a new empty object, the key is not assigned */
- cRSAPrivateKey(void);
-
- /** Deep-copies the key from a_Other */
- cRSAPrivateKey(const cRSAPrivateKey & a_Other);
-
- ~cRSAPrivateKey();
-
- /** Generates a new key within this object, with the specified size in bits.
- Returns true on success, false on failure. */
- bool Generate(unsigned a_KeySizeBits = 1024);
-
- /** Returns the public key part encoded in ASN1 DER encoding */
- AString GetPubKeyDER(void);
-
- /** Decrypts the data using RSAES-PKCS#1 algorithm.
- Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large.
- Returns the number of bytes decrypted, or negative number for error. */
- int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength);
-
- /** Encrypts the data using RSAES-PKCS#1 algorithm.
- Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large.
- Returns the number of bytes decrypted, or negative number for error. */
- int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength);
-
-protected:
- rsa_context m_Rsa;
- entropy_context m_Entropy;
- ctr_drbg_context m_Ctr_drbg;
-
- /** Initializes the m_Entropy and m_Ctr_drbg contexts
- Common part of this object's construction, called from all constructors. */
- void InitRnd(void);
-} ;
-
-
-
-
-
-class cPublicKey
-{
-public:
- cPublicKey(const AString & a_PublicKeyDER);
- ~cPublicKey();
-
- /** Decrypts the data using the stored public key
- Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large.
- Returns the number of bytes decrypted, or negative number for error. */
- int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength);
-
- /** Encrypts the data using the stored public key
- Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large.
- Returns the number of bytes decrypted, or negative number for error. */
- int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength);
-
-protected:
- pk_context m_Pk;
- entropy_context m_Entropy;
- ctr_drbg_context m_Ctr_drbg;
-
- /** Initializes the m_Entropy and m_Ctr_drbg contexts
- Common part of this object's construction, called from all constructors. */
- void InitRnd(void);
-} ;
-
-
-
-
-
-/** Decrypts data using the AES / CFB (128) algorithm */
-class cAESCFBDecryptor
-{
-public:
- Byte test;
-
- cAESCFBDecryptor(void);
- ~cAESCFBDecryptor();
-
- /** Initializes the decryptor with the specified Key / IV */
- void Init(const Byte a_Key[16], const Byte a_IV[16]);
-
- /** Decrypts a_Length bytes of the encrypted data; produces a_Length output bytes */
- void ProcessData(Byte * a_DecryptedOut, const Byte * a_EncryptedIn, size_t a_Length);
-
- /** Returns true if the object has been initialized with the Key / IV */
- bool IsValid(void) const { return m_IsValid; }
-
-protected:
- aes_context m_Aes;
-
- /** The InitialVector, used by the CFB mode decryption */
- Byte m_IV[16];
-
- /** Current offset in the m_IV, used by the CFB mode decryption */
- size_t m_IVOffset;
-
- /** Indicates whether the object has been initialized with the Key / IV */
- bool m_IsValid;
-} ;
-
-
-
-
-
-/** Encrypts data using the AES / CFB (128) algorithm */
-class cAESCFBEncryptor
-{
-public:
- cAESCFBEncryptor(void);
- ~cAESCFBEncryptor();
-
- /** Initializes the decryptor with the specified Key / IV */
- void Init(const Byte a_Key[16], const Byte a_IV[16]);
-
- /** Encrypts a_Length bytes of the plain data; produces a_Length output bytes */
- void ProcessData(Byte * a_EncryptedOut, const Byte * a_PlainIn, size_t a_Length);
-
- /** Returns true if the object has been initialized with the Key / IV */
- bool IsValid(void) const { return m_IsValid; }
-
-protected:
- aes_context m_Aes;
-
- /** The InitialVector, used by the CFB mode encryption */
- Byte m_IV[16];
-
- /** Current offset in the m_IV, used by the CFB mode encryption */
- size_t m_IVOffset;
-
- /** Indicates whether the object has been initialized with the Key / IV */
- bool m_IsValid;
-} ;
-
-
-
-
-
-/** Calculates a SHA1 checksum for data stream */
-class cSHA1Checksum
-{
-public:
- typedef Byte Checksum[20]; // The type used for storing the checksum
-
- cSHA1Checksum(void);
-
- /** Adds the specified data to the checksum */
- void Update(const Byte * a_Data, size_t a_Length);
-
- /** Calculates and returns the final checksum */
- void Finalize(Checksum & a_Output);
-
- /** Returns true if the object is accepts more input data, false if Finalize()-d (need to Restart()) */
- bool DoesAcceptInput(void) const { return m_DoesAcceptInput; }
-
- /** Converts a raw 160-bit SHA1 digest into a Java Hex representation
- According to http://wiki.vg/wiki/index.php?title=Protocol_Encryption&oldid=2802
- */
- static void DigestToJava(const Checksum & a_Digest, AString & a_JavaOut);
-
- /** Clears the current context and start a new checksum calculation */
- void Restart(void);
-
-protected:
- /** True if the object is accepts more input data, false if Finalize()-d (need to Restart()) */
- bool m_DoesAcceptInput;
-
- sha1_context m_Sha1;
-} ;
-
-
-
-
diff --git a/src/Cuboid.cpp b/src/Cuboid.cpp
index 3e5240248..26e86c77b 100644
--- a/src/Cuboid.cpp
+++ b/src/Cuboid.cpp
@@ -21,9 +21,20 @@ static bool DoIntervalsIntersect(int a_Min1, int a_Max1, int a_Min2, int a_Max2)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCuboid:
+cCuboid & cCuboid::operator=(cCuboid a_Other)
+{
+ std::swap(p1, a_Other.p1);
+ std::swap(p2, a_Other.p2);
+ return *this;
+}
+
+
+
+
+
void cCuboid::Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2)
{
p1.x = a_X1;
diff --git a/src/Cuboid.h b/src/Cuboid.h
index 3239c54fc..d62cf8063 100644
--- a/src/Cuboid.h
+++ b/src/Cuboid.h
@@ -15,10 +15,12 @@ public:
Vector3i p1, p2;
cCuboid(void) {}
- cCuboid(const cCuboid & a_Cuboid ) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {}
+ cCuboid(const cCuboid & a_Cuboid) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {}
cCuboid(const Vector3i & a_p1, const Vector3i & a_p2) : p1(a_p1), p2(a_p2) {}
cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {}
cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {}
+
+ cCuboid & operator=(cCuboid a_Other);
void Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2);
void Assign(const cCuboid & a_SrcCuboid);
@@ -38,7 +40,7 @@ public:
Assumes both cuboids are sorted. */
bool DoesIntersect(const cCuboid & a_Other) const;
- bool IsInside(const Vector3i & v) const
+ bool IsInside(const Vector3i & v) const
{
return (
(v.x >= p1.x) && (v.x <= p2.x) &&
@@ -47,7 +49,7 @@ public:
);
}
- bool IsInside(int a_X, int a_Y, int a_Z) const
+ bool IsInside(int a_X, int a_Y, int a_Z) const
{
return (
(a_X >= p1.x) && (a_X <= p2.x) &&
@@ -56,7 +58,7 @@ public:
);
}
- bool IsInside( const Vector3d & v ) const
+ bool IsInside( const Vector3d & v) const
{
return (
(v.x >= p1.x) && (v.x <= p2.x) &&
diff --git a/src/DeadlockDetect.cpp b/src/DeadlockDetect.cpp
index 38a3c369e..f73a45555 100644
--- a/src/DeadlockDetect.cpp
+++ b/src/DeadlockDetect.cpp
@@ -109,7 +109,7 @@ void cDeadlockDetect::CheckWorldAge(const AString & a_WorldName, Int64 a_Age)
WorldAges::iterator itr = m_WorldAges.find(a_WorldName);
if (itr == m_WorldAges.end())
{
- ASSERT(!"Unknown world in cDeadlockDetect");
+ SetWorldAge(a_WorldName, a_Age);
return;
}
diff --git a/src/Defines.h b/src/Defines.h
index 9fa3b3a8e..0981077c4 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -1,8 +1,8 @@
#pragma once
-#include "ChatColor.h"
#include <limits>
+#include <cmath>
@@ -21,7 +21,7 @@ typedef std::vector<int> cSlotNums;
/// Experience Orb setup
enum
{
- //open to suggestion on naming convention here :)
+ // Open to suggestion on naming convention here :)
MAX_EXPERIENCE_ORB_SIZE = 2000
} ;
@@ -273,8 +273,19 @@ inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace)
}
}
-
-
+inline eBlockFace ReverseBlockFace(eBlockFace a_BlockFace)
+{
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_YP: return BLOCK_FACE_YM;
+ case BLOCK_FACE_XP: return BLOCK_FACE_XM;
+ case BLOCK_FACE_ZP: return BLOCK_FACE_ZM;
+ case BLOCK_FACE_YM: return BLOCK_FACE_YP;
+ case BLOCK_FACE_XM: return BLOCK_FACE_XP;
+ case BLOCK_FACE_ZM: return BLOCK_FACE_ZP;
+ default: return a_BlockFace;
+ }
+}
/** Returns the textual representation of the BlockFace constant. */
@@ -459,18 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
{
int Y = a_BlockY;
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
- if (Y < 0)
- {
- a_BlockY = 0;
- }
- else if (Y > 255)
- {
- a_BlockY = 255;
- }
- else
- {
- a_BlockY = (unsigned char)Y;
- }
+ a_BlockY = Clamp<unsigned char>((unsigned char)Y, 0, 255);
}
@@ -479,9 +479,9 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a_Y, double & a_Z)
{
- // a_X = sinf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI );
- // a_Y = -sinf ( a_Pitch / 180 * PI );
- // a_Z = -cosf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI );
+ // a_X = sinf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI);
+ // a_Y = -sinf ( a_Pitch / 180 * PI);
+ // a_Z = -cosf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI);
a_X = cos(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI);
a_Y = sin(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI);
a_Z = sin(a_Pitch / 180 * PI);
@@ -500,7 +500,7 @@ inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, do
}
else
{
- a_Pan = atan2(a_Z, a_X) * 180 / PI - 90;
+ a_Pan = atan2(a_Z, a_X) * 180 / PI - 90;
}
a_Pitch = atan2(a_Y, r) * 180 / PI;
@@ -519,7 +519,7 @@ inline float GetSignf(float a_Val)
-inline float GetSpecialSignf( float a_Val )
+inline float GetSpecialSignf( float a_Val)
{
return (a_Val <= 0.f) ? -1.f : 1.f;
}
@@ -528,6 +528,15 @@ inline float GetSpecialSignf( float a_Val )
+template<class T> inline T Diff(T a_Val1, T a_Val2)
+{
+ return std::abs(a_Val1 - a_Val2);
+}
+
+
+
+
+
// tolua_begin
enum eMessageType
@@ -631,11 +640,11 @@ namespace ItemCategory
inline bool IsTool(short a_ItemID)
{
- return IsPickaxe( a_ItemID )
- || IsAxe ( a_ItemID )
- || IsSword ( a_ItemID )
- || IsHoe ( a_ItemID )
- || IsShovel ( a_ItemID );
+ return IsPickaxe( a_ItemID)
+ || IsAxe ( a_ItemID)
+ || IsSword ( a_ItemID)
+ || IsHoe ( a_ItemID)
+ || IsShovel ( a_ItemID);
}
@@ -706,14 +715,5 @@ namespace ItemCategory
// tolua_end
-inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType)
-{
- if(!IsValidBlock(a_BlockType)) return false;
- return cBlockInfo::RequiresSpecialTool(a_BlockType);
-}
-
-
-
-
diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp
index 64f89815b..264878c22 100644
--- a/src/Enchantments.cpp
+++ b/src/Enchantments.cpp
@@ -83,6 +83,15 @@ void cEnchantments::AddFromString(const AString & a_StringSpec)
+size_t cEnchantments::Count(void)
+{
+ return m_Enchantments.size();
+}
+
+
+
+
+
AString cEnchantments::ToString(void) const
{
// Serialize all the enchantments into a string
diff --git a/src/Enchantments.h b/src/Enchantments.h
index ec42257c8..98d7c0d36 100644
--- a/src/Enchantments.h
+++ b/src/Enchantments.h
@@ -40,7 +40,7 @@ Serialization will never put zero-level enchantments into the stringspec and wil
class cEnchantments
{
public:
- /** Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs )
+ /** Individual enchantment IDs, corresponding to their NBT IDs: http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs
*/
enum
@@ -84,6 +84,9 @@ public:
/** Adds enchantments in the stringspec; if a specified enchantment already exists, overwrites it */
void AddFromString(const AString & a_StringSpec);
+ /** Get the count of enchantments */
+ size_t Count(void);
+
/** Serializes all the enchantments into a string */
AString ToString(void) const;
diff --git a/src/Endianness.h b/src/Endianness.h
index 78f9a5d99..9aeb44986 100644
--- a/src/Endianness.h
+++ b/src/Endianness.h
@@ -1,6 +1,7 @@
#pragma once
+#undef ntohll
#define ntohll(x) ((((UInt64)ntohl((u_long)x)) << 32) + ntohl(x >> 32))
@@ -11,8 +12,8 @@
inline UInt64 HostToNetwork8(const void * a_Value)
{
unsigned long long __HostToNetwork8;
- memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8 ) );
- __HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8) ) << 32) + htonl(__HostToNetwork8 >> 32));
+ memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8));
+ __HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8)) << 32) + htonl(__HostToNetwork8 >> 32));
return __HostToNetwork8;
}
@@ -20,11 +21,11 @@ inline UInt64 HostToNetwork8(const void * a_Value)
-inline UInt32 HostToNetwork4(const void* a_Value )
+inline UInt32 HostToNetwork4(const void* a_Value)
{
unsigned int __HostToNetwork4;
- memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4 ) );
- __HostToNetwork4 = ntohl( __HostToNetwork4 );
+ memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4));
+ __HostToNetwork4 = ntohl( __HostToNetwork4);
return __HostToNetwork4;
}
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 847b39bbc..913519c4c 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -3,6 +3,7 @@
#include "Player.h"
#include "ArrowEntity.h"
#include "../Chunk.h"
+#include "FastRandom.h"
@@ -15,6 +16,7 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
m_IsCritical(false),
m_Timer(0),
m_HitGroundTimer(0),
+ m_HasTeleported(false),
m_bIsCollected(false),
m_HitBlockPos(Vector3i(0, 0, 0))
{
@@ -23,9 +25,9 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
SetYawFromSpeed();
SetPitchFromSpeed();
LOGD("Created arrow %d with speed {%.02f, %.02f, %.02f} and rot {%.02f, %.02f}",
- m_UniqueID, GetSpeedX(), GetSpeedY(), GetSpeedZ(),
- GetYaw(), GetPitch()
- );
+ m_UniqueID, GetSpeedX(), GetSpeedY(), GetSpeedZ(),
+ GetYaw(), GetPitch()
+ );
}
@@ -43,6 +45,10 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
m_bIsCollected(false),
m_HitBlockPos(0, 0, 0)
{
+ if (a_Player.IsGameModeCreative())
+ {
+ m_PickupState = psInCreative;
+ }
}
@@ -67,25 +73,23 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
- if (a_HitFace == BLOCK_FACE_NONE) { return; }
-
- super::OnHitSolidBlock(a_HitPos, a_HitFace);
- int a_X = (int)a_HitPos.x, a_Y = (int)a_HitPos.y, a_Z = (int)a_HitPos.z;
-
- switch (a_HitFace)
+ if (GetSpeed().EqualsEps(Vector3d(0, 0, 0), 0.0000001))
{
- case BLOCK_FACE_XM: // Strangely, bounding boxes / block tracers return the actual block for these two directions, so AddFace not needed
- case BLOCK_FACE_YM:
- {
- break;
- }
- default: AddFaceDirection(a_X, a_Y, a_Z, a_HitFace, true);
+ SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later
}
-
- m_HitBlockPos = Vector3i(a_X, a_Y, a_Z);
+
+ Vector3d Hit = a_HitPos;
+ Vector3d SinkMovement = (GetSpeed() / 1000);
+ Hit += SinkMovement * (0.0005 / SinkMovement.Length()); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside)
+
+ super::OnHitSolidBlock(Hit, a_HitFace);
+ Vector3i BlockHit = Hit.Floor();
+
+ int X = BlockHit.x, Y = BlockHit.y, Z = BlockHit.z;
+ m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound
- m_World->BroadcastSoundEffect("random.bowhit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.bowhit", (double)X, (double)Y, (double)Z, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
}
@@ -94,12 +98,6 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
- if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer() && !a_EntityHit.IsBoat())
- {
- // Not an entity that interacts with an arrow
- return;
- }
-
int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
if (m_IsCritical)
{
@@ -108,7 +106,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
// Broadcast successful hit sound
- m_World->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ GetWorld()->BroadcastSoundEffect("random.successful_hit", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
Destroy();
}
@@ -119,16 +117,22 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
void cArrowEntity::CollectedBy(cPlayer * a_Dest)
{
- if ((m_IsInGround) && (!m_bIsCollected) && (CanPickup(*a_Dest)))
+ if (m_IsInGround && !m_bIsCollected && CanPickup(*a_Dest))
{
- int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW);
- if (NumAdded > 0) // Only play effects if there was space in inventory
+ // Do not add the arrow to the inventory when the player is in creative:
+ if (!a_Dest->IsGameModeCreative())
{
- m_World->BroadcastCollectPickup((const cPickup &)*this, *a_Dest);
- // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
- m_World->BroadcastSoundEffect("random.pop", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
- m_bIsCollected = true;
+ int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW);
+ if (NumAdded == 0)
+ {
+ // No space in the inventory
+ return;
+ }
}
+
+ GetWorld()->BroadcastCollectEntity(*this, *a_Dest);
+ GetWorld()->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_bIsCollected = true;
}
}
@@ -162,9 +166,9 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
// We can afford to do this because xoft's algorithm for trajectory is near perfect, so things are pretty close anyway without sync
// Besides, this seems to be what the vanilla server does, note how arrows teleport half a second after they hit to the server position
- if (!m_HasTeleported) // Sent a teleport already, don't do again
+ if (!m_HasTeleported) // Sent a teleport already, don't do again
{
- if (m_HitGroundTimer > 1000.f) // Send after a second, could be less, but just in case
+ if (m_HitGroundTimer > 500.f) // Send after half a second, could be less, but just in case
{
m_World->BroadcastTeleportEntity(*this);
m_HasTeleported = true;
@@ -185,9 +189,9 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
return;
}
- if (Chunk->GetBlock(RelPosX, m_HitBlockPos.y, RelPosZ) == E_BLOCK_AIR) // Block attached to was destroyed?
+ if (Chunk->GetBlock(RelPosX, m_HitBlockPos.y, RelPosZ) == E_BLOCK_AIR) // Block attached to was destroyed?
{
- m_IsInGround = false; // Yes, begin simulating physics again
+ m_IsInGround = false; // Yes, begin simulating physics again
}
}
}
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 1fe3032ee..4bfcb1f6d 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -28,7 +28,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cArrowEntity);
+ CLASS_PROTODEF(cArrowEntity)
/// Creates a new arrow with psNoPickup state and default damage modifier coeff
cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
@@ -58,8 +58,14 @@ public:
/// Sets the IsCritical flag
void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; }
+
+ /** Gets the block arrow is in */
+ Vector3i GetBlockHit(void) const { return m_HitBlockPos; }
// tolua_end
+
+ /** Sets the block arrow is in. To be used by the MCA loader only! */
+ void SetBlockHit(const Vector3i & a_BlockHit) { m_HitBlockPos = a_BlockHit; }
protected:
@@ -93,4 +99,4 @@ protected:
virtual void CollectedBy(cPlayer * a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index 921252253..8ff8866a1 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -33,9 +33,12 @@ void cBoat::SpawnOn(cClientHandle & a_ClientHandle)
-void cBoat::DoTakeDamage(TakeDamageInfo & TDI)
+bool cBoat::DoTakeDamage(TakeDamageInfo & TDI)
{
- super::DoTakeDamage(TDI);
+ if (!super::DoTakeDamage(TDI))
+ {
+ return false;
+ }
if (GetHealth() == 0)
{
@@ -50,6 +53,7 @@ void cBoat::DoTakeDamage(TakeDamageInfo & TDI)
}
Destroy(true);
}
+ return true;
}
@@ -90,7 +94,7 @@ void cBoat::Tick(float a_Dt, cChunk & a_Chunk)
super::Tick(a_Dt, a_Chunk);
BroadcastMovementUpdate();
- SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed
+ SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed
if ((POSY_TOINT < 0) || (POSY_TOINT > cChunkDef::Height))
{
@@ -100,7 +104,7 @@ void cBoat::Tick(float a_Dt, cChunk & a_Chunk)
if (IsBlockWater(m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT)))
{
if (GetSpeedY() < 2)
- {
+ {
AddSpeedY(0.2);
}
}
diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h
index c4c9afe7a..8de88d165 100644
--- a/src/Entities/Boat.h
+++ b/src/Entities/Boat.h
@@ -21,12 +21,12 @@ class cBoat :
typedef cEntity super;
public:
- CLASS_PROTODEF(cBoat);
+ CLASS_PROTODEF(cBoat)
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
- virtual void DoTakeDamage(TakeDamageInfo & TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override;
diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt
index c9ca44d38..5d10e1680 100644
--- a/src/Entities/CMakeLists.txt
+++ b/src/Entities/CMakeLists.txt
@@ -4,9 +4,64 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ ArrowEntity.cpp
+ Boat.cpp
+ EnderCrystal.cpp
+ Entity.cpp
+ EntityEffect.cpp
+ ExpBottleEntity.cpp
+ ExpOrb.cpp
+ FallingBlock.cpp
+ FireChargeEntity.cpp
+ FireworkEntity.cpp
+ Floater.cpp
+ GhastFireballEntity.cpp
+ HangingEntity.cpp
+ ItemFrame.cpp
+ Minecart.cpp
+ Painting.cpp
+ Pawn.cpp
+ Pickup.cpp
+ Player.cpp
+ ProjectileEntity.cpp
+ SplashPotionEntity.cpp
+ TNTEntity.cpp
+ ThrownEggEntity.cpp
+ ThrownEnderPearlEntity.cpp
+ ThrownSnowballEntity.cpp
+ WitherSkullEntity.cpp)
-add_library(Entities ${SOURCE})
+SET (HDRS
+ ArrowEntity.h
+ Boat.h
+ EnderCrystal.h
+ Entity.h
+ EntityEffect.h
+ ExpBottleEntity.h
+ ExpOrb.h
+ FallingBlock.h
+ FireChargeEntity.h
+ FireworkEntity.h
+ Floater.h
+ GhastFireballEntity.h
+ HangingEntity.h
+ ItemFrame.h
+ Minecart.h
+ Painting.h
+ Pawn.h
+ Pickup.h
+ Player.h
+ ProjectileEntity.h
+ SplashPotionEntity.h
+ TNTEntity.h
+ ThrownEggEntity.h
+ ThrownEnderPearlEntity.h
+ ThrownSnowballEntity.h
+ WitherSkullEntity.h)
+
+if(NOT MSVC)
+ add_library(Entities ${SRCS} ${HDRS})
+
+ target_link_libraries(Entities WorldStorage)
+endif()
diff --git a/src/Entities/Effects.h b/src/Entities/Effects.h
deleted file mode 100644
index baf3302fb..000000000
--- a/src/Entities/Effects.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-
-// tolua_begin
-enum ENUM_ENTITY_EFFECT
-{
- E_EFFECT_SPEED = 1,
- E_EFFECT_SLOWNESS = 2,
- E_EFFECT_HASTE = 3,
- E_EFFECT_MINING_FATIGUE = 4,
- E_EFFECT_STENGTH = 5,
- E_EFFECT_INSTANT_HEALTH = 6,
- E_EFFECT_INSTANT_DAMAGE = 7,
- E_EFFECT_JUMP_BOOST = 8,
- E_EFFECT_NAUSEA = 9,
- E_EFFECT_REGENERATION = 10,
- E_EFFECT_RESISTANCE = 11,
- E_EFFECT_FIRE_RESISTANCE = 12,
- E_EFFECT_WATER_BREATHING = 13,
- E_EFFECT_INVISIBILITY = 14,
- E_EFFECT_BLINDNESS = 15,
- E_EFFECT_NIGHT_VISION = 16,
- E_EFFECT_HUNGER = 17,
- E_EFFECT_WEAKNESS = 18,
- E_EFFECT_POISON = 19,
- E_EFFECT_WITHER = 20,
- E_EFFECT_HEALTH_BOOST = 21,
- E_EFFECT_ABSORPTION = 22,
- E_EFFECT_SATURATION = 23,
-} ;
-// tolua_end
diff --git a/src/Entities/EnderCrystal.cpp b/src/Entities/EnderCrystal.cpp
index a640b236c..bf86a6c42 100644
--- a/src/Entities/EnderCrystal.cpp
+++ b/src/Entities/EnderCrystal.cpp
@@ -42,9 +42,9 @@ void cEnderCrystal::Tick(float a_Dt, cChunk & a_Chunk)
-void cEnderCrystal::KilledBy(cEntity * a_Killer)
+void cEnderCrystal::KilledBy(TakeDamageInfo & a_TDI)
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
m_World->DoExplosionAt(6.0, GetPosX(), GetPosY(), GetPosZ(), true, esEnderCrystal, this);
diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h
index 5b86df987..c98c3b681 100644
--- a/src/Entities/EnderCrystal.h
+++ b/src/Entities/EnderCrystal.h
@@ -15,7 +15,7 @@ class cEnderCrystal :
typedef cEntity super;
public:
- CLASS_PROTODEF(cEnderCrystal);
+ CLASS_PROTODEF(cEnderCrystal)
cEnderCrystal(double a_X, double a_Y, double a_Z);
@@ -24,7 +24,7 @@ private:
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
}; // tolua_export
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 2d325805b..da578013d 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1,3 +1,4 @@
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Entity.h"
@@ -10,8 +11,8 @@
#include "../Simulator/FluidSimulator.h"
#include "../Bindings/PluginManager.h"
#include "../Tracer.h"
-#include "Minecart.h"
#include "Player.h"
+#include "Items/ItemHandler.h"
@@ -32,17 +33,12 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
, m_Attachee(NULL)
, m_bDirtyHead(true)
, m_bDirtyOrientation(true)
- , m_bDirtyPosition(true)
- , m_bDirtySpeed(true)
- , m_bOnGround( false )
- , m_Gravity( -9.81f )
- , m_LastPosX( 0.0 )
- , m_LastPosY( 0.0 )
- , m_LastPosZ( 0.0 )
- , m_TimeLastTeleportPacket(0)
- , m_TimeLastMoveReltPacket(0)
- , m_TimeLastSpeedPacket(0)
+ , m_bHasSentNoSpeed(true)
+ , m_bOnGround(false)
+ , m_Gravity(-9.81f)
+ , m_LastPos(a_X, a_Y, a_Z)
, m_IsInitialized(false)
+ , m_WorldTravellingFrom(NULL)
, m_EntityType(a_EntityType)
, m_World(NULL)
, m_IsFireproof(false)
@@ -55,13 +51,15 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
, m_IsSubmerged(false)
, m_AirLevel(0)
, m_AirTickTimer(0)
- , m_HeadYaw( 0.0 )
+ , m_TicksAlive(0)
+ , m_HeadYaw(0.0)
, m_Rot(0.0, 0.0, 0.0)
, m_Pos(a_X, a_Y, a_Z)
, m_WaterSpeed(0, 0, 0)
, m_Mass (0.001) // Default 1g
, m_Width(a_Width)
, m_Height(a_Height)
+ , m_InvulnerableTicks(0)
{
cCSLock Lock(m_CSCount);
m_EntityCount++;
@@ -79,7 +77,7 @@ cEntity::~cEntity()
/*
// DEBUG:
- LOGD("Deleting entity %d at pos {%.2f, %.2f, %.2f} ~ [%d, %d]; ptr %p",
+ LOGD("Deleting entity %d at pos {%.2f, %.2f, %.2f} ~ [%d, %d]; ptr %p",
m_UniqueID,
m_Pos.x, m_Pos.y, m_Pos.z,
(int)(m_Pos.x / cChunkDef::Width), (int)(m_Pos.z / cChunkDef::Width),
@@ -134,9 +132,9 @@ const char * cEntity::GetParentClass(void) const
-bool cEntity::Initialize(cWorld * a_World)
+bool cEntity::Initialize(cWorld & a_World)
{
- if (cPluginManager::Get()->CallHookSpawningEntity(*a_World, *this))
+ if (cPluginManager::Get()->CallHookSpawningEntity(a_World, *this))
{
return false;
}
@@ -149,13 +147,13 @@ bool cEntity::Initialize(cWorld * a_World)
*/
m_IsInitialized = true;
- m_World = a_World;
+ m_World = &a_World;
m_World->AddEntity(this);
- cPluginManager::Get()->CallHookSpawnedEntity(*a_World, *this);
+ cPluginManager::Get()->CallHookSpawnedEntity(a_World, *this);
// Spawn the entity on the clients:
- a_World->BroadcastSpawnEntity(*this);
+ a_World.BroadcastSpawnEntity(*this);
return true;
}
@@ -184,14 +182,9 @@ void cEntity::WrapRotation(void)
void cEntity::WrapSpeed(void)
{
- // There shoudn't be a need for flipping the flag on because this function is called
- // after any update, so the flag is already turned on
- if (m_Speed.x > 78.0f) m_Speed.x = 78.0f;
- else if (m_Speed.x < -78.0f) m_Speed.x = -78.0f;
- if (m_Speed.y > 78.0f) m_Speed.y = 78.0f;
- else if (m_Speed.y < -78.0f) m_Speed.y = -78.0f;
- if (m_Speed.z > 78.0f) m_Speed.z = 78.0f;
- else if (m_Speed.z < -78.0f) m_Speed.z = -78.0f;
+ m_Speed.x = Clamp(m_Speed.x, -78.0, 78.0);
+ m_Speed.y = Clamp(m_Speed.y, -78.0, 78.0);
+ m_Speed.z = Clamp(m_Speed.z, -78.0, 78.0);
}
@@ -282,7 +275,7 @@ void cEntity::SetYawFromSpeed(void)
void cEntity::SetPitchFromSpeed(void)
{
const double EPS = 0.0000001;
- double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component
+ double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component
if ((abs(xz) < EPS) && (abs(m_Speed.y) < EPS))
{
// atan2() may overflow or is undefined, pick any number
@@ -296,78 +289,84 @@ void cEntity::SetPitchFromSpeed(void)
-void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
+bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI))
+ if (m_Health <= 0)
{
- return;
+ // Can't take damage if already dead
+ return false;
}
- if (m_Health <= 0)
+ if (m_InvulnerableTicks > 0)
{
- // Can't take damage if already dead
- return;
+ // Entity is invulnerable
+ return false;
+ }
+
+ if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI))
+ {
+ return false;
}
if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
{
+ cPlayer * Player = (cPlayer *)a_TDI.Attacker;
+
+ Player->GetEquippedItem().GetHandler()->OnEntityAttack(Player, this);
+
// IsOnGround() only is false if the player is moving downwards
- if (!((cPlayer *)a_TDI.Attacker)->IsOnGround()) // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
+ // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
+ if (!Player->IsOnGround())
{
- a_TDI.FinalDamage += 2;
- m_World->BroadcastEntityAnimation(*this, 4); // Critical hit
+ if ((a_TDI.DamageType == dtAttack) || (a_TDI.DamageType == dtArrowAttack))
+ {
+ a_TDI.FinalDamage += 2;
+ m_World->BroadcastEntityAnimation(*this, 4); // Critical hit
+ }
}
+
+ Player->GetStatManager().AddValue(statDamageDealt, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5));
}
m_Health -= (short)a_TDI.FinalDamage;
// TODO: Apply damage to armor
- if (m_Health < 0)
- {
- m_Health = 0;
- }
+ m_Health = std::max(m_Health, 0);
- if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
+ if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
{
- int KnockbackLevel = 0;
- if (a_TDI.Attacker->GetEquippedWeapon().m_ItemType == E_ITEM_BOW)
+ int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment
+ if (KnockbackLevel < 1)
{
+ // We support punch on swords and vice versa! :)
KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch);
}
- else
- {
- KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback);
- }
- Vector3d additionalSpeed(0, 0, 0);
+ Vector3d AdditionalSpeed(0, 0, 0);
switch (KnockbackLevel)
{
- case 1:
- {
- additionalSpeed.Set(5, .3, 5);
- break;
- }
- case 2:
- {
- additionalSpeed.Set(8, .3, 8);
- break;
- }
- default:
- {
- additionalSpeed.Set(2, .3, 2);
- break;
- }
+ case 1: AdditionalSpeed.Set(5, 0.3, 5); break;
+ case 2: AdditionalSpeed.Set(8, 0.3, 8); break;
+ default: break;
}
- AddSpeed(a_TDI.Knockback * additionalSpeed);
+ AddSpeed(a_TDI.Knockback + AdditionalSpeed);
}
m_World->BroadcastEntityStatus(*this, esGenericHurt);
+ m_InvulnerableTicks = 10;
+
if (m_Health <= 0)
{
- KilledBy(a_TDI.Attacker);
+ KilledBy(a_TDI);
+
+ if (a_TDI.Attacker != NULL)
+ {
+ a_TDI.Attacker->Killed(this);
+ }
}
+ return true;
}
@@ -423,6 +422,7 @@ bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType)
case dtStarving:
case dtInVoid:
case dtPoisoning:
+ case dtWithering:
case dtPotionOfHarming:
case dtFalling:
case dtLightning:
@@ -516,11 +516,11 @@ double cEntity::GetKnockbackAmountAgainst(const cEntity & a_Receiver)
-void cEntity::KilledBy(cEntity * a_Killer)
+void cEntity::KilledBy(TakeDamageInfo & a_TDI)
{
m_Health = 0;
- cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_Killer);
+ cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_TDI.Attacker, a_TDI);
if (m_Health > 0)
{
@@ -530,7 +530,7 @@ void cEntity::KilledBy(cEntity * a_Killer)
// Drop loot:
cItems Drops;
- GetDrops(Drops, a_Killer);
+ GetDrops(Drops, a_TDI.Attacker);
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());
m_World->BroadcastEntityStatus(*this, esGenericDead);
@@ -564,11 +564,25 @@ void cEntity::SetHealth(int a_Health)
void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
+ m_TicksAlive++;
+
+ if (m_InvulnerableTicks > 0)
+ {
+ m_InvulnerableTicks--;
+ }
+
if (m_AttachedTo != NULL)
{
- if ((m_Pos - m_AttachedTo->GetPosition()).Length() > 0.5)
+ Vector3d DeltaPos = m_Pos - m_AttachedTo->GetPosition();
+ if (DeltaPos.Length() > 0.5)
{
SetPosition(m_AttachedTo->GetPosition());
+
+ if (IsPlayer())
+ {
+ cPlayer * Player = (cPlayer *)this;
+ Player->UpdateMovementStats(DeltaPos);
+ }
}
}
else
@@ -592,6 +606,10 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
m_TicksSinceLastVoidDamage = 0;
}
+ if (IsMob() || IsPlayer() || IsPickup() || IsExpOrb())
+ {
+ DetectCacti();
+ }
if (IsMob() || IsPlayer())
{
// Set swimming state
@@ -600,9 +618,12 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
// Handle drowning
HandleAir();
}
-
- // None of the above functions change position, we remain in the chunk of NextChunk
- HandlePhysics(a_Dt, *NextChunk);
+
+ if (!DetectPortal()) // Our chunk is invalid if we have moved to another world
+ {
+ // None of the above functions changed position, we remain in the chunk of NextChunk
+ HandlePhysics(a_Dt, *NextChunk);
+ }
}
}
@@ -626,7 +647,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((BlockY >= cChunkDef::Height) || (BlockY < 0))
{
- // Outside of the world
+ // Outside of the world
AddSpeedY(m_Gravity * a_Dt);
AddPosition(GetSpeed() * a_Dt);
return;
@@ -634,7 +655,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width);
int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width);
- BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ );
+ BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ);
BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;
if (!cBlockInfo::IsSolid(BlockIn)) // Making sure we are not inside a solid block
{
@@ -738,13 +759,13 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
NextSpeed.x *= 0.25;
NextSpeed.z *= 0.25;
}
-
- //Get water direction
+
+ // Get water direction
Direction WaterDir = m_World->GetWaterSimulator()->GetFlowingDirection(BlockX, BlockY, BlockZ);
- m_WaterSpeed *= 0.9f; //Reduce speed each tick
+ m_WaterSpeed *= 0.9f; // Reduce speed each tick
- switch(WaterDir)
+ switch (WaterDir)
{
case X_PLUS:
m_WaterSpeed.x = 0.2f;
@@ -779,30 +800,43 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
NextSpeed += m_WaterSpeed;
- if( NextSpeed.SqrLength() > 0.f )
+ if (NextSpeed.SqrLength() > 0.f)
{
- cTracer Tracer( GetWorld() );
- bool HasHit = Tracer.Trace( NextPos, NextSpeed, 2 );
- if (HasHit) // Oh noez! we hit something
+ cTracer Tracer(GetWorld());
+ // Distance traced is an integer, so we round up from the distance we should go (Speed * Delta), else we will encounter collision detection failurse
+ int DistanceToTrace = (int)(ceil((NextSpeed * a_Dt).SqrLength()) * 2);
+ bool HasHit = Tracer.Trace(NextPos, NextSpeed, DistanceToTrace);
+
+ if (HasHit)
{
- // Set to hit position
+ // Oh noez! We hit something: verify that the (hit position - current) was smaller or equal to the (position that we should travel without obstacles - current)
+ // This is because previously, we traced with a length that was rounded up (due to integer limitations), and in the case that something was hit, we don't want to overshoot our projected movement
if ((Tracer.RealHit - NextPos).SqrLength() <= (NextSpeed * a_Dt).SqrLength())
{
+ // Block hit was within our projected path
+ // Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1.
+ // For example: HitNormal.y = -1 : BLOCK_FACE_YM; HitNormal.y = 1 : BLOCK_FACE_YP
if (Tracer.HitNormal.x != 0.f) NextSpeed.x = 0.f;
if (Tracer.HitNormal.y != 0.f) NextSpeed.y = 0.f;
if (Tracer.HitNormal.z != 0.f) NextSpeed.z = 0.f;
- if (Tracer.HitNormal.y > 0) // means on ground
+ if (Tracer.HitNormal.y == 1) // Hit BLOCK_FACE_YP, we are on the ground
{
m_bOnGround = true;
}
- NextPos.Set(Tracer.RealHit.x,Tracer.RealHit.y,Tracer.RealHit.z);
- NextPos.x += Tracer.HitNormal.x * 0.3f;
- NextPos.y += Tracer.HitNormal.y * 0.05f; // Any larger produces entity vibration-upon-the-spot
- NextPos.z += Tracer.HitNormal.z * 0.3f;
+
+ // Now, set our position to the hit block (i.e. move part way along our intended trajectory)
+ NextPos.Set(Tracer.RealHit.x, Tracer.RealHit.y, Tracer.RealHit.z);
+ NextPos.x += Tracer.HitNormal.x * 0.1;
+ NextPos.y += Tracer.HitNormal.y * 0.05;
+ NextPos.z += Tracer.HitNormal.z * 0.1;
}
else
{
+ // We have hit a block but overshot our intended trajectory, move normally, safe in the warm cocoon of knowledge that we won't appear to teleport forwards on clients,
+ // and that this piece of software will come to be hailed as the epitome of performance and functionality in C++, never before seen, and of such a like that will never
+ // be henceforth seen again in the time of programmers and man alike
+ // </&sensationalist>
NextPos += (NextSpeed * a_Dt);
}
}
@@ -826,12 +860,12 @@ void cEntity::TickBurning(cChunk & a_Chunk)
// Remember the current burning state:
bool HasBeenBurning = (m_TicksLeftBurning > 0);
- if (m_World->IsWeatherWet())
+ if (GetWorld()->IsWeatherWetAt(POSX_TOINT, POSZ_TOINT))
{
if (POSY_TOINT > m_World->GetHeight(POSX_TOINT, POSZ_TOINT))
{
m_TicksLeftBurning = 0;
- }
+ }
}
// Do the burning damage:
@@ -976,6 +1010,205 @@ void cEntity::TickInVoid(cChunk & a_Chunk)
+void cEntity::DetectCacti(void)
+{
+ int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT;
+ double w = m_Width / 2;
+ if (
+ ((Y > 0) && (Y < cChunkDef::Height)) &&
+ ((((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) ||
+ ((GetPosX() - X < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) ||
+ (((Z + 1) - GetPosZ() < w) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) ||
+ ((GetPosZ() - Z < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) ||
+ (((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))))
+ )
+ {
+ TakeDamage(dtCactusContact, NULL, 1, 0);
+ }
+}
+
+
+
+
+
+bool cEntity::DetectPortal()
+{
+ if (GetWorld()->GetDimension() == dimOverworld)
+ {
+ if (GetWorld()->GetNetherWorldName().empty() && GetWorld()->GetEndWorldName().empty())
+ {
+ // Teleportation to either dimension not enabled, don't bother proceeding
+ return false;
+ }
+ }
+ else if (GetWorld()->GetLinkedOverworldName().empty())
+ {
+ // Overworld teleportation disabled, abort
+ return false;
+ }
+
+ int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT;
+ if ((Y > 0) && (Y < cChunkDef::Height))
+ {
+ switch (GetWorld()->GetBlock(X, Y, Z))
+ {
+ case E_BLOCK_NETHER_PORTAL:
+ {
+ if (m_PortalCooldownData.m_ShouldPreventTeleportation)
+ {
+ // Just exited a portal, don't teleport again
+ return false;
+ }
+
+ if (IsPlayer() && !((cPlayer *)this)->IsGameModeCreative() && m_PortalCooldownData.m_TicksDelayed != 80)
+ {
+ // Delay teleportation for four seconds if the entity is a non-creative player
+ m_PortalCooldownData.m_TicksDelayed++;
+ return false;
+ }
+ m_PortalCooldownData.m_TicksDelayed = 0;
+
+ switch (GetWorld()->GetDimension())
+ {
+ case dimNether:
+ {
+ if (GetWorld()->GetLinkedOverworldName().empty())
+ {
+ return false;
+ }
+
+ m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn
+
+ if (IsPlayer())
+ {
+ ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimOverworld); // Send a respawn packet before world is loaded/generated so the client isn't left in limbo
+ }
+
+ return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false);
+ }
+ case dimOverworld:
+ {
+ if (GetWorld()->GetNetherWorldName().empty())
+ {
+ return false;
+ }
+
+ m_PortalCooldownData.m_ShouldPreventTeleportation = true;
+
+ if (IsPlayer())
+ {
+ ((cPlayer *)this)->AwardAchievement(achEnterPortal);
+ ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimNether);
+ }
+
+ return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName(), dimNether, GetWorld()->GetName()), false);
+ }
+ default: return false;
+ }
+ }
+ case E_BLOCK_END_PORTAL:
+ {
+ if (m_PortalCooldownData.m_ShouldPreventTeleportation)
+ {
+ return false;
+ }
+
+ switch (GetWorld()->GetDimension())
+ {
+ case dimEnd:
+ {
+ if (GetWorld()->GetLinkedOverworldName().empty())
+ {
+ return false;
+ }
+
+ m_PortalCooldownData.m_ShouldPreventTeleportation = true;
+
+ if (IsPlayer())
+ {
+ cPlayer * Player = (cPlayer *)this;
+ Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z);
+ Player->GetClientHandle()->SendRespawn(dimOverworld);
+ }
+
+ return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false);
+ }
+ case dimOverworld:
+ {
+ if (GetWorld()->GetEndWorldName().empty())
+ {
+ return false;
+ }
+
+ m_PortalCooldownData.m_ShouldPreventTeleportation = true;
+
+ if (IsPlayer())
+ {
+ ((cPlayer *)this)->AwardAchievement(achEnterTheEnd);
+ ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimEnd);
+ }
+
+ return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName(), dimEnd, GetWorld()->GetName()), false);
+ }
+ default: return false;
+ }
+ }
+ default: break;
+ }
+ }
+
+ // Allow portals to work again
+ m_PortalCooldownData.m_ShouldPreventTeleportation = false;
+ m_PortalCooldownData.m_TicksDelayed = 0;
+ return false;
+}
+
+
+
+
+
+bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
+{
+ UNUSED(a_ShouldSendRespawn);
+ ASSERT(a_World != NULL);
+
+ if (GetWorld() == a_World)
+ {
+ // Don't move to same world
+ return false;
+ }
+
+ // Remove all links to the old world
+ SetWorldTravellingFrom(GetWorld()); // cChunk::Tick() handles entity removal
+ GetWorld()->BroadcastDestroyEntity(*this);
+
+ // Queue add to new world
+ a_World->AddEntity(this);
+ SetWorld(a_World);
+
+ return true;
+}
+
+
+
+
+
+bool cEntity::MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn)
+{
+ cWorld * World = cRoot::Get()->GetWorld(a_WorldName);
+ if (World == NULL)
+ {
+ LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str());
+ return false;
+ }
+
+ return DoMoveToWorld(World, a_ShouldSendRespawn);
+}
+
+
+
+
+
void cEntity::SetSwimState(cChunk & a_Chunk)
{
int RelY = (int)floor(GetPosY() + 0.1);
@@ -995,9 +1228,9 @@ void cEntity::SetSwimState(cChunk & a_Chunk)
{
// This sometimes happens on Linux machines
// Ref.: http://forum.mc-server.org/showthread.php?tid=1244
- LOGD("SetSwimState failure: RelX = %d, RelZ = %d, LastPos = {%.02f, %.02f}, Pos = %.02f, %.02f}",
- RelX, RelY, m_LastPosX, m_LastPosZ, GetPosX(), GetPosZ()
- );
+ LOGD("SetSwimState failure: RelX = %d, RelZ = %d, Pos = %.02f, %.02f}",
+ RelX, RelY, GetPosX(), GetPosZ()
+ );
m_IsSwimming = false;
m_IsSubmerged = false;
return;
@@ -1013,6 +1246,17 @@ void cEntity::SetSwimState(cChunk & a_Chunk)
+void cEntity::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
+{
+ m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ);
+
+ WrapSpeed();
+}
+
+
+
+
+
void cEntity::HandleAir(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Chunk_format
@@ -1021,14 +1265,17 @@ void cEntity::HandleAir(void)
if (IsSubmerged())
{
- SetSpeedY(1); // Float in the water
+ if (!IsPlayer()) // Players control themselves
+ {
+ SetSpeedY(1); // Float in the water
+ }
// Either reduce air level or damage player
if (m_AirLevel < 1)
{
if (m_AirTickTimer < 1)
{
- // Damage player
+ // Damage player
TakeDamage(dtDrowning, NULL, 1, 1, 0);
// Reset timer
m_AirTickTimer = DROWNING_TICKS;
@@ -1084,10 +1331,7 @@ void cEntity::SetMaxHealth(int a_MaxHealth)
m_MaxHealth = a_MaxHealth;
// Reset health, if too high:
- if (m_Health > a_MaxHealth)
- {
- m_Health = a_MaxHealth;
- }
+ m_Health = std::min(m_Health, a_MaxHealth);
}
@@ -1163,72 +1407,70 @@ void cEntity::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
{
- // Send velocity packet every two ticks if: speed is not negligible or speed was set (as indicated by the DirtySpeed flag)
- if (((m_Speed.SqrLength() > 0.0004f) || m_bDirtySpeed) && ((m_World->GetWorldAge() - m_TimeLastSpeedPacket) >= 2))
+ // Process packet sending every two ticks
+ if (GetWorld()->GetWorldAge() % 2 == 0)
{
- m_World->BroadcastEntityVelocity(*this,a_Exclude);
- m_bDirtySpeed = false;
- m_TimeLastSpeedPacket = m_World->GetWorldAge();
- }
-
- // Have to process position related packets this every two ticks
- if (m_World->GetWorldAge() % 2 == 0)
- {
- int DiffX = (int) (floor(GetPosX() * 32.0) - floor(m_LastPosX * 32.0));
- int DiffY = (int) (floor(GetPosY() * 32.0) - floor(m_LastPosY * 32.0));
- int DiffZ = (int) (floor(GetPosZ() * 32.0) - floor(m_LastPosZ * 32.0));
- Int64 DiffTeleportPacket = m_World->GetWorldAge() - m_TimeLastTeleportPacket;
- // 4 blocks is max Relative So if the Diff is greater than 127 or. Send an absolute position every 20 seconds
- if (DiffTeleportPacket >= 400 ||
- ((DiffX > 127) || (DiffX < -128) ||
- (DiffY > 127) || (DiffY < -128) ||
- (DiffZ > 127) || (DiffZ < -128)))
+ double SpeedSqr = GetSpeed().SqrLength();
+ if (SpeedSqr == 0.0)
{
- //
- m_World->BroadcastTeleportEntity(*this,a_Exclude);
- m_TimeLastTeleportPacket = m_World->GetWorldAge();
- m_TimeLastMoveReltPacket = m_TimeLastTeleportPacket; //Must synchronize.
- m_LastPosX = GetPosX();
- m_LastPosY = GetPosY();
- m_LastPosZ = GetPosZ();
- m_bDirtyPosition = false;
- m_bDirtyOrientation = false;
+ // Speed is zero, send this to clients once only as well as an absolute position
+ if (!m_bHasSentNoSpeed)
+ {
+ m_World->BroadcastEntityVelocity(*this, a_Exclude);
+ m_World->BroadcastTeleportEntity(*this, a_Exclude);
+ m_bHasSentNoSpeed = true;
+ }
}
else
{
- Int64 DiffMoveRelPacket = m_World->GetWorldAge() - m_TimeLastMoveReltPacket;
- //if the change is big enough.
- if ((abs(DiffX) >= 4 || abs(DiffY) >= 4 || abs(DiffZ) >= 4 || DiffMoveRelPacket >= 60) && m_bDirtyPosition)
+ // Movin'
+ m_World->BroadcastEntityVelocity(*this, a_Exclude);
+ m_bHasSentNoSpeed = false;
+ }
+
+ // TODO: Pickups move disgracefully if relative move packets are sent as opposed to just velocity. Have a system to send relmove only when SetPosXXX() is called with a large difference in position
+ int DiffX = (int)(floor(GetPosX() * 32.0) - floor(m_LastPos.x * 32.0));
+ int DiffY = (int)(floor(GetPosY() * 32.0) - floor(m_LastPos.y * 32.0));
+ int DiffZ = (int)(floor(GetPosZ() * 32.0) - floor(m_LastPos.z * 32.0));
+
+ if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved?
+ {
+ if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte
{
+ // Difference within Byte limitations, use a relative move packet
if (m_bDirtyOrientation)
{
- m_World->BroadcastEntityRelMoveLook(*this, (char)DiffX, (char)DiffY, (char)DiffZ,a_Exclude);
+ m_World->BroadcastEntityRelMoveLook(*this, (char)DiffX, (char)DiffY, (char)DiffZ, a_Exclude);
m_bDirtyOrientation = false;
}
else
{
- m_World->BroadcastEntityRelMove(*this, (char)DiffX, (char)DiffY, (char)DiffZ,a_Exclude);
+ m_World->BroadcastEntityRelMove(*this, (char)DiffX, (char)DiffY, (char)DiffZ, a_Exclude);
}
- m_LastPosX = GetPosX();
- m_LastPosY = GetPosY();
- m_LastPosZ = GetPosZ();
- m_bDirtyPosition = false;
- m_TimeLastMoveReltPacket = m_World->GetWorldAge();
+ // Clients seem to store two positions, one for the velocity packet and one for the teleport/relmove packet
+ // The latter is only changed with a relmove/teleport, and m_LastPos stores this position
+ m_LastPos = GetPosition();
}
else
{
- if (m_bDirtyOrientation)
- {
- m_World->BroadcastEntityLook(*this,a_Exclude);
- m_bDirtyOrientation = false;
- }
- }
+ // Too big a movement, do a teleport
+ m_World->BroadcastTeleportEntity(*this, a_Exclude);
+ m_LastPos = GetPosition(); // See above
+ m_bDirtyOrientation = false;
+ }
}
+
if (m_bDirtyHead)
{
- m_World->BroadcastEntityHeadLook(*this,a_Exclude);
+ m_World->BroadcastEntityHeadLook(*this, a_Exclude);
m_bDirtyHead = false;
}
+ if (m_bDirtyOrientation)
+ {
+ // Send individual update in case above (sending with rel-move packet) wasn't done
+ GetWorld()->BroadcastEntityLook(*this, a_Exclude);
+ m_bDirtyOrientation = false;
+ }
}
}
@@ -1322,8 +1564,8 @@ void cEntity::SetMass(double a_Mass)
}
else
{
- // Make sure that mass is not zero. 1g is the default because we
- // have to choose a number. It's perfectly legal to have a mass
+ // Make sure that mass is not zero. 1g is the default because we
+ // have to choose a number. It's perfectly legal to have a mass
// less than 1g as long as is NOT equal or less than zero.
m_Mass = 0.001;
}
@@ -1367,9 +1609,7 @@ void cEntity::SetRoll(double a_Roll)
void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
{
- m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ);
- m_bDirtySpeed = true;
- WrapSpeed();
+ DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ);
}
@@ -1377,9 +1617,7 @@ void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
void cEntity::SetSpeedX(double a_SpeedX)
{
- m_Speed.x = a_SpeedX;
- m_bDirtySpeed = true;
- WrapSpeed();
+ SetSpeed(a_SpeedX, m_Speed.y, m_Speed.z);
}
@@ -1387,9 +1625,7 @@ void cEntity::SetSpeedX(double a_SpeedX)
void cEntity::SetSpeedY(double a_SpeedY)
{
- m_Speed.y = a_SpeedY;
- m_bDirtySpeed = true;
- WrapSpeed();
+ SetSpeed(m_Speed.x, a_SpeedY, m_Speed.z);
}
@@ -1397,9 +1633,7 @@ void cEntity::SetSpeedY(double a_SpeedY)
void cEntity::SetSpeedZ(double a_SpeedZ)
{
- m_Speed.z = a_SpeedZ;
- m_bDirtySpeed = true;
- WrapSpeed();
+ SetSpeed(m_Speed.x, m_Speed.y, a_SpeedZ);
}
@@ -1418,7 +1652,6 @@ void cEntity::SetWidth(double a_Width)
void cEntity::AddPosX(double a_AddPosX)
{
m_Pos.x += a_AddPosX;
- m_bDirtyPosition = true;
}
@@ -1427,7 +1660,6 @@ void cEntity::AddPosX(double a_AddPosX)
void cEntity::AddPosY(double a_AddPosY)
{
m_Pos.y += a_AddPosY;
- m_bDirtyPosition = true;
}
@@ -1436,7 +1668,6 @@ void cEntity::AddPosY(double a_AddPosY)
void cEntity::AddPosZ(double a_AddPosZ)
{
m_Pos.z += a_AddPosZ;
- m_bDirtyPosition = true;
}
@@ -1447,7 +1678,6 @@ void cEntity::AddPosition(double a_AddPosX, double a_AddPosY, double a_AddPosZ)
m_Pos.x += a_AddPosX;
m_Pos.y += a_AddPosY;
m_Pos.z += a_AddPosZ;
- m_bDirtyPosition = true;
}
@@ -1458,7 +1688,6 @@ void cEntity::AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeed
m_Speed.x += a_AddSpeedX;
m_Speed.y += a_AddSpeedY;
m_Speed.z += a_AddSpeedZ;
- m_bDirtySpeed = true;
WrapSpeed();
}
@@ -1469,7 +1698,6 @@ void cEntity::AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeed
void cEntity::AddSpeedX(double a_AddSpeedX)
{
m_Speed.x += a_AddSpeedX;
- m_bDirtySpeed = true;
WrapSpeed();
}
@@ -1480,7 +1708,6 @@ void cEntity::AddSpeedX(double a_AddSpeedX)
void cEntity::AddSpeedY(double a_AddSpeedY)
{
m_Speed.y += a_AddSpeedY;
- m_bDirtySpeed = true;
WrapSpeed();
}
@@ -1491,7 +1718,6 @@ void cEntity::AddSpeedY(double a_AddSpeedY)
void cEntity::AddSpeedZ(double a_AddSpeedZ)
{
m_Speed.z += a_AddSpeedZ;
- m_bDirtySpeed = true;
WrapSpeed();
}
@@ -1528,7 +1754,7 @@ void cEntity::SteerVehicle(float a_Forward, float a_Sideways)
-//////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Get look vector (this is NOT a rotation!)
Vector3d cEntity::GetLookVector(void) const
{
@@ -1542,12 +1768,11 @@ Vector3d cEntity::GetLookVector(void) const
-//////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Set position
void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ)
{
m_Pos.Set(a_PosX, a_PosY, a_PosZ);
- m_bDirtyPosition = true;
}
@@ -1557,7 +1782,6 @@ void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ)
void cEntity::SetPosX(double a_PosX)
{
m_Pos.x = a_PosX;
- m_bDirtyPosition = true;
}
@@ -1567,7 +1791,6 @@ void cEntity::SetPosX(double a_PosX)
void cEntity::SetPosY(double a_PosY)
{
m_Pos.y = a_PosY;
- m_bDirtyPosition = true;
}
@@ -1577,7 +1800,6 @@ void cEntity::SetPosY(double a_PosY)
void cEntity::SetPosZ(double a_PosZ)
{
m_Pos.z = a_PosZ;
- m_bDirtyPosition = true;
}
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 9b8011b55..e66194ca2 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -146,8 +146,9 @@ public:
cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
virtual ~cEntity();
- /// Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed)
- virtual bool Initialize(cWorld * a_World);
+ /** Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed).
+ Adds the entity to the world. */
+ virtual bool Initialize(cWorld & a_World);
// tolua_begin
@@ -157,6 +158,7 @@ public:
bool IsPlayer (void) const { return (m_EntityType == etPlayer); }
bool IsPickup (void) const { return (m_EntityType == etPickup); }
bool IsMob (void) const { return (m_EntityType == etMonster); }
+ bool IsPawn (void) const { return (IsMob() || IsPlayer()); }
bool IsFallingBlock(void) const { return (m_EntityType == etFallingBlock); }
bool IsMinecart (void) const { return (m_EntityType == etMinecart); }
bool IsBoat (void) const { return (m_EntityType == etBoat); }
@@ -214,20 +216,31 @@ public:
void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180)
void SetPitch (double a_Pitch); // In degrees, normalizes to [-180, +180)
void SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180)
- void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ);
- void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
- void SetSpeedX (double a_SpeedX);
- void SetSpeedY (double a_SpeedY);
- void SetSpeedZ (double a_SpeedZ);
+
+ /** Sets the speed of the entity, measured in m / sec */
+ 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); }
+
+ /** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */
+ void SetSpeedX(double a_SpeedX);
+
+ /** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */
+ void SetSpeedY(double a_SpeedY);
+
+ /** 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);
void AddPosY (double a_AddPosY);
void AddPosZ (double a_AddPosZ);
void AddPosition(double a_AddPosX, double a_AddPosY, double a_AddPosZ);
- void AddPosition(const Vector3d & a_AddPos) { AddPosition(a_AddPos.x,a_AddPos.y,a_AddPos.z);}
+ void AddPosition(const Vector3d & a_AddPos) { AddPosition(a_AddPos.x, a_AddPos.y, a_AddPos.z); }
void AddSpeed (double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeedZ);
- void AddSpeed (const Vector3d & a_AddSpeed) { AddSpeed(a_AddSpeed.x,a_AddSpeed.y,a_AddSpeed.z);}
+ void AddSpeed (const Vector3d & a_AddSpeed) { AddSpeed(a_AddSpeed.x, a_AddSpeed.y, a_AddSpeed.z); }
void AddSpeedX (double a_AddSpeedX);
void AddSpeedY (double a_AddSpeedY);
void AddSpeedZ (double a_AddSpeedZ);
@@ -262,8 +275,10 @@ public:
// tolua_end
- /// Makes this entity take damage specified in the a_TDI. The TDI is sent through plugins first, then applied
- virtual void DoTakeDamage(TakeDamageInfo & a_TDI);
+ /** Makes this entity take damage specified in the a_TDI.
+ The TDI is sent through plugins first, then applied.
+ If it returns false, the entity hasn't receive any damage. */
+ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI);
// tolua_begin
@@ -295,10 +310,13 @@ public:
virtual cItem GetEquippedBoots(void) const { return cItem(); }
/// Called when the health drops below zero. a_Killer may be NULL (environmental damage)
- virtual void KilledBy(cEntity * a_Killer);
+ virtual void KilledBy(TakeDamageInfo & a_TDI);
+
+ /// Called when the entity kills another entity
+ virtual void Killed(cEntity * a_Victim) {}
/// Heals the specified amount of HPs
- void Heal(int a_HitPoints);
+ virtual void Heal(int a_HitPoints);
/// Returns the health of this entity
int GetHealth(void) const { return m_Health; }
@@ -315,6 +333,14 @@ public:
/// Updates the state related to this entity being on fire
virtual void TickBurning(cChunk & a_Chunk);
+
+ /** Detects the time for application of cacti damage */
+ virtual void DetectCacti(void);
+
+ /** Detects whether we are in a portal block and begins teleportation procedures if so
+ Returns true if MoveToWorld() was called, false if not
+ */
+ virtual bool DetectPortal(void);
/// Handles when the entity is in the void
virtual void TickInVoid(cChunk & a_Chunk);
@@ -357,8 +383,22 @@ public:
/// Teleports to the coordinates specified
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ);
+
+ /** Moves entity to specified world, taking a world pointer */
+ bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn = true) { return DoMoveToWorld(a_World, a_ShouldSendRespawn); }
+
+ /** Moves entity to specified world, taking a world name */
+ bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true);
// tolua_end
+
+ virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn);
+
+ /** Returns if the entity is travelling away from a specified world */
+ bool IsWorldTravellingFrom(cWorld * a_World) const { return (m_WorldTravellingFrom == a_World); }
+
+ /** Sets the world the entity will be leaving */
+ void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; }
/// Updates clients of changes in the entity.
virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL);
@@ -394,23 +434,38 @@ public:
virtual bool IsSubmerged(void) const{ return m_IsSubmerged; }
/** Gets remaining air of a monster */
int GetAirLevel(void) const { return m_AirLevel; }
+
+ /** Gets number of ticks this entity has existed for */
+ long int GetTicksAlive(void) const { return m_TicksAlive; }
+
+ /** Gets the invulnerable ticks from the entity */
+ int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; }
+
+ /** Set the invulnerable ticks from the entity */
+ void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; }
// tolua_end
/// Called when the specified player right-clicks this entity
- virtual void OnRightClicked(cPlayer &) {};
+ virtual void OnRightClicked(cPlayer &) {}
/// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy().
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL)
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL)
{
UNUSED(a_Drops);
UNUSED(a_Killer);
}
+ /** Sets the internal world pointer to a new cWorld, doesn't update anything else. */
+ void SetWorld(cWorld * a_World) { m_World = a_World; }
+
protected:
static cCriticalSection m_CSCount;
static int m_EntityCount;
+ /** Measured in meter/second (m/s) */
+ Vector3d m_Speed;
+
int m_UniqueID;
int m_Health;
@@ -422,22 +477,35 @@ protected:
/// The entity which is attached to this entity (rider), NULL if none
cEntity * m_Attachee;
- // Flags that signal that we haven't updated the clients with the latest.
- bool m_bDirtyHead;
- bool m_bDirtyOrientation;
- bool m_bDirtyPosition;
- bool m_bDirtySpeed;
+ /** Stores whether head yaw has been set manually */
+ bool m_bDirtyHead;
+
+ /** Stores whether our yaw/pitch/roll (body orientation) has been set manually */
+ bool m_bDirtyOrientation;
+
+ /** Stores whether we have sent a Velocity packet with a speed of zero (no speed) to the client
+ Ensures that said packet is sent only once */
+ bool m_bHasSentNoSpeed;
- bool m_bOnGround;
- float m_Gravity;
+ /** Stores if the entity is on the ground */
+ bool m_bOnGround;
- // Last Position.
- double m_LastPosX, m_LastPosY, m_LastPosZ;
+ /** Stores gravity that is applied to an entity every tick
+ For realistic effects, this should be negative. For spaaaaaaace, this can be zero or even positive */
+ float m_Gravity;
+
+ /** Last position sent to client via the Relative Move or Teleport packets (not Velocity)
+ Only updated if cEntity::BroadcastMovementUpdate() is called! */
+ Vector3d m_LastPos;
- // This variables keep track of the last time a packet was sent
- Int64 m_TimeLastTeleportPacket, m_TimeLastMoveReltPacket, m_TimeLastSpeedPacket; // In ticks
+ /** True when entity is initialised (Initialize()) and false when destroyed pending deletion (Destroy()) */
+ bool m_IsInitialized;
- bool m_IsInitialized; // Is set to true when it's initialized, until it's destroyed (Initialize() till Destroy() )
+ /** World entity is travelling from
+ Set to a valid world pointer by MoveToWorld; reset to NULL when the entity is removed from the old world
+ Can't be a simple boolean as context switches between worlds may leave the new chunk processing (and therefore immediately removing) the entity before the old chunk could remove it
+ */
+ cWorld * m_WorldTravellingFrom;
eEntityType m_EntityType;
@@ -445,7 +513,7 @@ protected:
/// Whether the entity is capable of taking fire or lava damage.
bool m_IsFireproof;
-
+
/// Time, in ticks, since the last damage dealt by being on fire. Valid only if on fire (IsOnFire())
int m_TicksSinceLastBurnDamage;
@@ -460,13 +528,16 @@ protected:
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
int m_TicksSinceLastVoidDamage;
-
- virtual void Destroyed(void) {} // Called after the entity has been destroyed
-
- void SetWorld(cWorld * a_World) { m_World = a_World; }
+
+ /** Does the actual speed-setting. The default implementation just sets the member variable value;
+ overrides can provide further processing, such as forcing players to move at the given speed. */
+ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
+
+ virtual void Destroyed(void) {} // Called after the entity has been destroyed
/** Called in each tick to handle air-related processing i.e. drowning */
- virtual void HandleAir();
+ virtual void HandleAir(void);
+
/** Called once per tick to set IsSwimming and IsSubmerged */
virtual void SetSwimState(cChunk & a_Chunk);
@@ -476,31 +547,50 @@ protected:
/** Air level of a mobile */
int m_AirLevel;
int m_AirTickTimer;
+
+ /** Structure storing the portal delay timer and cooldown boolean */
+ struct sPortalCooldownData
+ {
+ /** Ticks since entry of portal, used to delay teleportation */
+ unsigned short m_TicksDelayed;
+
+ /** Whether the entity has just exited the portal, and should therefore not be teleported again
+ This prevents teleportation loops, and is reset when the entity has moved out of the portal
+ */
+ bool m_ShouldPreventTeleportation;
+ };
+
+ /** Portal delay timer and cooldown boolean data */
+ sPortalCooldownData m_PortalCooldownData;
+
+ /** The number of ticks this entity has been alive for */
+ long int m_TicksAlive;
private:
- // Measured in degrees, [-180, +180)
+ /** Measured in degrees, [-180, +180) */
double m_HeadYaw;
- // Measured in meter/second (m/s)
- Vector3d m_Speed;
-
- // Measured in degrees, [-180, +180)
+ /** Measured in degrees, [-180, +180) */
Vector3d m_Rot;
- /// Position of the entity's XZ center and Y bottom
+ /** Position of the entity's XZ center and Y bottom */
Vector3d m_Pos;
- // Measured in meter / second
+ /** Measured in meter / second */
Vector3d m_WaterSpeed;
- // Measured in Kilograms (Kg)
+ /** Measured in Kilograms (Kg) */
double m_Mass;
- /// Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter.
+ /** Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. */
double m_Width;
- /// Height of the entity (Y axis)
+ /** Height of the entity (Y axis) */
double m_Height;
+
+ /** If a player hit a entity, the entity receive a invulnerable of 10 ticks.
+ While this ticks, a player can't hit this entity. */
+ int m_InvulnerableTicks;
} ; // tolua_export
typedef std::list<cEntity *> cEntityList;
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
new file mode 100644
index 000000000..fdcbe822e
--- /dev/null
+++ b/src/Entities/EntityEffect.cpp
@@ -0,0 +1,411 @@
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "EntityEffect.h"
+#include "../Mobs/Monster.h"
+#include "Player.h"
+
+
+
+
+
+int cEntityEffect::GetPotionColor(short a_ItemDamage)
+{
+ // Lowest six bits
+ return (a_ItemDamage & 0x3f);
+}
+
+
+
+
+
+cEntityEffect::eType cEntityEffect::GetPotionEffectType(short a_ItemDamage)
+{
+ // Lowest four bits
+ // Potion effect bits are different from entity effect values
+ // For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits
+ switch (a_ItemDamage & 0x0f)
+ {
+ case 0x01: return cEntityEffect::effRegeneration;
+ case 0x02: return cEntityEffect::effSpeed;
+ case 0x03: return cEntityEffect::effFireResistance;
+ case 0x04: return cEntityEffect::effPoison;
+ case 0x05: return cEntityEffect::effInstantHealth;
+ case 0x06: return cEntityEffect::effNightVision;
+ case 0x08: return cEntityEffect::effWeakness;
+ case 0x09: return cEntityEffect::effStrength;
+ case 0x0a: return cEntityEffect::effSlowness;
+ case 0x0c: return cEntityEffect::effInstantDamage;
+ case 0x0d: return cEntityEffect::effWaterBreathing;
+ case 0x0e: return cEntityEffect::effInvisibility;
+
+ // No effect potions
+ case 0x00:
+ case 0x07:
+ case 0x0b: // Will be potion of leaping in 1.8
+ case 0x0f:
+ {
+ break;
+ }
+ }
+ return cEntityEffect::effNoEffect;
+}
+
+
+
+
+
+short cEntityEffect::GetPotionEffectIntensity(short a_ItemDamage)
+{
+ // Level II potion if the fifth lowest bit is set
+ return ((a_ItemDamage & 0x20) != 0) ? 1 : 0;
+}
+
+
+
+
+
+int cEntityEffect::GetPotionEffectDuration(short a_ItemDamage)
+{
+ // Base duration in ticks
+ int base = 0;
+ double TierCoeff = 1, ExtCoeff = 1, SplashCoeff = 1;
+
+ switch (GetPotionEffectType(a_ItemDamage))
+ {
+ case cEntityEffect::effRegeneration:
+ case cEntityEffect::effPoison:
+ {
+ base = 900;
+ break;
+ }
+
+ case cEntityEffect::effSpeed:
+ case cEntityEffect::effFireResistance:
+ case cEntityEffect::effNightVision:
+ case cEntityEffect::effStrength:
+ case cEntityEffect::effWaterBreathing:
+ case cEntityEffect::effInvisibility:
+ {
+ base = 3600;
+ break;
+ }
+
+ case cEntityEffect::effWeakness:
+ case cEntityEffect::effSlowness:
+ {
+ base = 1800;
+ break;
+ }
+ }
+
+ // If potion is level II, half the duration. If not, stays the same
+ TierCoeff = (GetPotionEffectIntensity(a_ItemDamage) > 0) ? 0.5 : 1;
+
+ // If potion is extended, multiply duration by 8/3. If not, stays the same
+ // Extended potion if sixth lowest bit is set
+ ExtCoeff = (a_ItemDamage & 0x40) ? (8.0 / 3.0) : 1;
+
+ // If potion is splash potion, multiply duration by 3/4. If not, stays the same
+ SplashCoeff = IsPotionDrinkable(a_ItemDamage) ? 1 : 0.75;
+
+ // Ref.:
+ // http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit
+ // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit
+ // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit
+
+ return (int)(base * TierCoeff * ExtCoeff * SplashCoeff);
+}
+
+
+
+
+
+bool cEntityEffect::IsPotionDrinkable(short a_ItemDamage)
+{
+ // Drinkable potion if 13th lowest bit is set
+ // Ref.: http://minecraft.gamepedia.com/Potions#Data_value_table
+ return ((a_ItemDamage & 0x2000) != 0);
+}
+
+
+
+
+
+cEntityEffect::cEntityEffect():
+ m_Ticks(0),
+ m_Duration(0),
+ m_Intensity(0),
+ m_DistanceModifier(1)
+{
+
+}
+
+
+
+
+
+cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier):
+ m_Ticks(0),
+ m_Duration(a_Duration),
+ m_Intensity(a_Intensity),
+ m_DistanceModifier(a_DistanceModifier)
+{
+
+}
+
+
+
+
+
+cEntityEffect::cEntityEffect(const cEntityEffect & a_OtherEffect):
+ m_Ticks(a_OtherEffect.m_Ticks),
+ m_Duration(a_OtherEffect.m_Duration),
+ m_Intensity(a_OtherEffect.m_Intensity),
+ m_DistanceModifier(a_OtherEffect.m_DistanceModifier)
+{
+
+}
+
+
+
+
+
+cEntityEffect & cEntityEffect::operator=(cEntityEffect a_OtherEffect)
+{
+ std::swap(m_Ticks, a_OtherEffect.m_Ticks);
+ std::swap(m_Duration, a_OtherEffect.m_Duration);
+ std::swap(m_Intensity, a_OtherEffect.m_Intensity);
+ std::swap(m_DistanceModifier, a_OtherEffect.m_DistanceModifier);
+ return *this;
+}
+
+
+
+
+
+cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
+{
+ switch (a_EffectType)
+ {
+ case cEntityEffect::effNoEffect: return new cEntityEffect (a_Duration, a_Intensity, a_DistanceModifier);
+
+ case cEntityEffect::effAbsorption: return new cEntityEffectAbsorption (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effBlindness: return new cEntityEffectBlindness (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effFireResistance: return new cEntityEffectFireResistance(a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effHaste: return new cEntityEffectHaste (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effHealthBoost: return new cEntityEffectHealthBoost (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effHunger: return new cEntityEffectHunger (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effInstantDamage: return new cEntityEffectInstantDamage (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effInstantHealth: return new cEntityEffectInstantHealth (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effInvisibility: return new cEntityEffectInvisibility (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effJumpBoost: return new cEntityEffectJumpBoost (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effMiningFatigue: return new cEntityEffectMiningFatigue (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effNausea: return new cEntityEffectNausea (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effNightVision: return new cEntityEffectNightVision (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effPoison: return new cEntityEffectPoison (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effRegeneration: return new cEntityEffectRegeneration (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effResistance: return new cEntityEffectResistance (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effSaturation: return new cEntityEffectSaturation (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effSlowness: return new cEntityEffectSlowness (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effSpeed: return new cEntityEffectSpeed (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effStrength: return new cEntityEffectStrength (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effWaterBreathing: return new cEntityEffectWaterBreathing(a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effWeakness: return new cEntityEffectWeakness (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effWither: return new cEntityEffectWither (a_Duration, a_Intensity, a_DistanceModifier);
+ }
+
+ ASSERT(!"Unhandled entity effect type!");
+ return NULL;
+}
+
+
+
+
+
+void cEntityEffect::OnTick(cPawn & a_Target)
+{
+ // Reduce the effect's duration
+ ++m_Ticks;
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEntityEffectInstantHealth:
+
+void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
+{
+ // Base amount = 6, doubles for every increase in intensity
+ int amount = (int)(6 * (1 << m_Intensity) * m_DistanceModifier);
+
+ if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
+ {
+ a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
+ return;
+ }
+ a_Target.Heal(amount);
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEntityEffectInstantDamage:
+
+void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
+{
+ // Base amount = 6, doubles for every increase in intensity
+ int amount = (int)(6 * (1 << m_Intensity) * m_DistanceModifier);
+
+ if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
+ {
+ a_Target.Heal(amount);
+ return;
+ }
+ a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEntityEffectRegeneration:
+
+void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
+ {
+ return;
+ }
+
+ // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
+ int frequency = (int) std::floor(50.0 / (double)(m_Intensity + 1));
+
+ if ((m_Ticks % frequency) != 0)
+ {
+ return;
+ }
+
+ a_Target.Heal(1);
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEntityEffectHunger:
+
+void cEntityEffectHunger::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ if (a_Target.IsPlayer())
+ {
+ cPlayer & Target = (cPlayer &) a_Target;
+ Target.SetFoodExhaustionLevel(Target.GetFoodExhaustionLevel() + 0.025); // 0.5 per second = 0.025 per tick
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEntityEffectWeakness:
+
+void cEntityEffectWeakness::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ // Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage)
+ // double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1);
+
+ // TODO: Implement me!
+ // TODO: Weakened villager zombies can be turned back to villagers with the god apple
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEntityEffectPoison:
+
+void cEntityEffectPoison::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ if (a_Target.IsMob())
+ {
+ cMonster & Target = (cMonster &) a_Target;
+
+ // Doesn't effect undead mobs, spiders
+ if (
+ Target.IsUndead() ||
+ (Target.GetMobType() == cMonster::mtSpider) ||
+ (Target.GetMobType() == cMonster::mtCaveSpider)
+ )
+ {
+ return;
+ }
+ }
+
+ // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
+ int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1));
+
+ if ((m_Ticks % frequency) == 0)
+ {
+ // Cannot take poison damage when health is at 1
+ if (a_Target.GetHealth() > 1)
+ {
+ a_Target.TakeDamage(dtPoisoning, NULL, 1, 0);
+ }
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEntityEffectWither:
+
+void cEntityEffectWither::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ // Damage frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
+ int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1));
+
+ if ((m_Ticks % frequency) == 0)
+ {
+ a_Target.TakeDamage(dtWither, NULL, 1, 0);
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEntityEffectSaturation:
+
+void cEntityEffectSaturation::OnTick(cPawn & a_Target)
+{
+ if (a_Target.IsPlayer())
+ {
+ cPlayer & Target = (cPlayer &) a_Target;
+ Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level
+ }
+}
+
+
+
+
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
new file mode 100644
index 000000000..f9c1e4eb2
--- /dev/null
+++ b/src/Entities/EntityEffect.h
@@ -0,0 +1,494 @@
+#pragma once
+
+class cPawn;
+
+// tolua_begin
+class cEntityEffect
+{
+public:
+
+ /** All types of entity effects (numbers correspond to protocol / storage types) */
+ enum eType
+ {
+ effNoEffect = 0,
+ effSpeed = 1,
+ effSlowness = 2,
+ effHaste = 3,
+ effMiningFatigue = 4,
+ effStrength = 5,
+ effInstantHealth = 6,
+ effInstantDamage = 7,
+ effJumpBoost = 8,
+ effNausea = 9,
+ effRegeneration = 10,
+ effResistance = 11,
+ effFireResistance = 12,
+ effWaterBreathing = 13,
+ effInvisibility = 14,
+ effBlindness = 15,
+ effNightVision = 16,
+ effHunger = 17,
+ effWeakness = 18,
+ effPoison = 19,
+ effWither = 20,
+ effHealthBoost = 21,
+ effAbsorption = 22,
+ effSaturation = 23,
+ } ;
+
+ /** Returns the potion color (used by the client for visuals), based on the potion's damage value */
+ static int GetPotionColor(short a_ItemDamage);
+
+
+ /** Translates the potion's damage value into the entity effect that the potion gives */
+ static cEntityEffect::eType GetPotionEffectType(short a_ItemDamage);
+
+
+ /** Retrieves the intensity level from the potion's damage value. Returns 0 for level I potions, 1 for level II potions. */
+ static short GetPotionEffectIntensity(short a_ItemDamage);
+
+
+ /** Returns the effect duration, in ticks, based on the potion's damage value */
+ static int GetPotionEffectDuration(short a_ItemDamage);
+
+ /** Returns true if the potion with the given damage is drinkable */
+ static bool IsPotionDrinkable(short a_ItemDamage);
+
+ // tolua_end
+
+ /** Creates an empty entity effect */
+ cEntityEffect(void);
+
+ /** Creates an entity effect of the specified type
+ @param a_Duration How long this effect will last, in ticks
+ @param a_Intensity How strong the effect will be applied
+ @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
+ cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier = 1);
+
+ /** Creates an entity effect by copying another
+ @param a_OtherEffect The other effect to copy */
+ cEntityEffect(const cEntityEffect & a_OtherEffect);
+
+ /** Creates an entity effect by copying another
+ @param a_OtherEffect The other effect to copy */
+ cEntityEffect & operator=(cEntityEffect a_OtherEffect);
+
+ virtual ~cEntityEffect(void) {}
+
+ /** Creates a pointer to the proper entity effect from the effect type
+ @warning This function creates raw pointers that must be manually managed.
+ @param a_EffectType The effect type to create the effect from
+ @param a_Duration How long this effect will last, in ticks
+ @param a_Intensity How strong the effect will be applied
+ @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
+ static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier);
+
+ /** Returns how many ticks this effect has been active for */
+ int GetTicks(void) const { return m_Ticks; }
+
+ /** Returns the duration of the effect */
+ int GetDuration(void) const { return m_Duration; }
+
+ /** Returns how strong the effect will be applied */
+ short GetIntensity(void) const { return m_Intensity; }
+
+ /** Returns the distance modifier for affecting potency */
+ double GetDistanceModifier(void) const { return m_DistanceModifier; }
+
+ void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; }
+ void SetDuration(int a_Duration) { m_Duration = a_Duration; }
+ void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
+ void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
+
+ /** Called on each tick.
+ By default increases the m_Ticks, descendants may override to provide additional processing. */
+ virtual void OnTick(cPawn & a_Target);
+
+ /** Called when the effect is first added to an entity */
+ virtual void OnActivate(cPawn & a_Target) { }
+
+ /** Called when the effect is removed from an entity */
+ virtual void OnDeactivate(cPawn & a_Target) { }
+
+protected:
+ /** How many ticks this effect has been active for */
+ int m_Ticks;
+
+ /** How long this effect will last, in ticks */
+ int m_Duration;
+
+ /** How strong the effect will be applied */
+ short m_Intensity;
+
+ /** The distance modifier for affecting potency */
+ double m_DistanceModifier;
+}; // tolua_export
+
+
+
+
+
+class cEntityEffectSpeed:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectSpeed(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectSlowness:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectSlowness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectHaste:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectHaste(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectMiningFatigue:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectStrength:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectStrength(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectInstantHealth:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectInstantHealth(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnActivate(cPawn & a_Target) override;
+};
+
+
+
+
+
+class cEntityEffectInstantDamage:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectInstantDamage(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnActivate(cPawn & a_Target) override;
+};
+
+
+
+
+
+class cEntityEffectJumpBoost:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectJumpBoost(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectNausea:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectNausea(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectRegeneration:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectRegeneration(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+
+
+
+
+class cEntityEffectResistance:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectResistance(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectFireResistance:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectFireResistance(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectWaterBreathing:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectInvisibility:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectInvisibility(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectBlindness:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectBlindness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectNightVision:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectNightVision(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectHunger:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectHunger(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+
+ // cEntityEffect overrides:
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+
+
+
+
+class cEntityEffectWeakness:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectWeakness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+
+ // cEntityEffect overrides:
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+
+
+
+
+class cEntityEffectPoison:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectPoison(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+
+ // cEntityEffect overrides:
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+
+
+
+
+class cEntityEffectWither:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectWither(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+
+ // cEntityEffect overrides:
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+
+
+
+
+class cEntityEffectHealthBoost:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectHealthBoost(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectAbsorption:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectAbsorption(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+};
+
+
+
+
+
+class cEntityEffectSaturation:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectSaturation(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+
+
+
diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h
index b2043d8f1..d62a84469 100644
--- a/src/Entities/ExpBottleEntity.h
+++ b/src/Entities/ExpBottleEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cExpBottleEntity);
+ CLASS_PROTODEF(cExpBottleEntity)
cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
@@ -30,4 +30,4 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index 3623c869a..73d5cbfed 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -6,7 +6,7 @@
cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward)
- : cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98)
+ : cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98)
, m_Reward(a_Reward)
, m_Timer(0.f)
{
@@ -19,7 +19,7 @@ cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward)
cExpOrb::cExpOrb(const Vector3d & a_Pos, int a_Reward)
- : cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98)
+ : cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98)
, m_Reward(a_Reward)
, m_Timer(0.f)
{
@@ -34,8 +34,6 @@ cExpOrb::cExpOrb(const Vector3d & a_Pos, int a_Reward)
void cExpOrb::SpawnOn(cClientHandle & a_Client)
{
a_Client.SendExperienceOrb(*this);
- m_bDirtyPosition = false;
- m_bDirtySpeed = false;
m_bDirtyOrientation = false;
m_bDirtyHead = false;
}
@@ -58,15 +56,15 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
LOGD("Player %s picked up an ExpOrb. His reward is %i", a_ClosestPlayer->GetName().c_str(), m_Reward);
a_ClosestPlayer->DeltaExperience(m_Reward);
- m_World->BroadcastSoundEffect("random.orb", (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.orb", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
Destroy();
}
a_Distance.Normalize();
a_Distance *= ((float) (5.5 - Distance));
- SetSpeedX( a_Distance.x );
- SetSpeedY( a_Distance.y );
- SetSpeedZ( a_Distance.z );
+ SetSpeedX( a_Distance.x);
+ SetSpeedY( a_Distance.y);
+ SetSpeedZ( a_Distance.z);
BroadcastMovementUpdate();
}
HandlePhysics(a_Dt, a_Chunk);
diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h
index e76274ac9..bdb9a5b19 100644
--- a/src/Entities/ExpOrb.h
+++ b/src/Entities/ExpOrb.h
@@ -11,12 +11,12 @@
class cExpOrb :
public cEntity
{
- typedef cExpOrb super;
+ typedef cEntity super;
public:
// tolua_end
- CLASS_PROTODEF(cExpOrb);
+ CLASS_PROTODEF(cExpOrb)
cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward);
cExpOrb(const Vector3d & a_Pos, int a_Reward);
diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp
index bcdac0291..111c5fa84 100644
--- a/src/Entities/FallingBlock.cpp
+++ b/src/Entities/FallingBlock.cpp
@@ -55,9 +55,8 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
return;
}
- int idx = a_Chunk.MakeIndexNoCheck(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width);
- BLOCKTYPE BlockBelow = a_Chunk.GetBlock(idx);
- NIBBLETYPE BelowMeta = a_Chunk.GetMeta(idx);
+ BLOCKTYPE BlockBelow = a_Chunk.GetBlock(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width);
+ NIBBLETYPE BelowMeta = a_Chunk.GetMeta(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width);
if (cSandSimulator::DoesBreakFallingThrough(BlockBelow, BelowMeta))
{
// Fallen onto a block that breaks this into pickups (e. g. half-slab)
@@ -87,9 +86,8 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
AddSpeedY(MilliDt * -9.8f);
AddPosition(GetSpeed() * MilliDt);
- // If not static (One billionth precision) broadcast movement.
- static const float epsilon = 0.000000001;
- if ((fabs(GetSpeedX()) > epsilon) || (fabs(GetSpeedZ()) > epsilon))
+ // If not static (one billionth precision) broadcast movement
+ if ((fabs(GetSpeedX()) > std::numeric_limits<double>::epsilon()) || (fabs(GetSpeedZ()) > std::numeric_limits<double>::epsilon()))
{
BroadcastMovementUpdate();
}
diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h
index 5ba9909bb..c20fe8eb9 100644
--- a/src/Entities/FallingBlock.h
+++ b/src/Entities/FallingBlock.h
@@ -20,7 +20,7 @@ class cFallingBlock :
typedef cEntity super;
public:
- CLASS_PROTODEF(cFallingBlock);
+ CLASS_PROTODEF(cFallingBlock)
/// Creates a new falling block. a_BlockPosition is expected in world coords
cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h
index 3924c337c..5df55bec4 100644
--- a/src/Entities/FireChargeEntity.h
+++ b/src/Entities/FireChargeEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cFireChargeEntity);
+ CLASS_PROTODEF(cFireChargeEntity)
cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
@@ -33,4 +33,4 @@ protected:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h
index c62ca9402..20f18b6dc 100644
--- a/src/Entities/FireworkEntity.h
+++ b/src/Entities/FireworkEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cFireworkEntity);
+ CLASS_PROTODEF(cFireworkEntity)
cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item);
const cItem & GetItem(void) const { return m_FireworkItem; }
@@ -37,4 +37,4 @@ private:
int m_ExplodeTimer;
cItem m_FireworkItem;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp
index b910c3769..159429147 100644
--- a/src/Entities/Floater.cpp
+++ b/src/Entities/Floater.cpp
@@ -11,7 +11,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFloaterEntityCollisionCallback
class cFloaterEntityCollisionCallback :
public cEntityCallback
@@ -75,7 +75,7 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFloaterCheckEntityExist
class cFloaterCheckEntityExist :
public cEntityCallback
@@ -130,18 +130,18 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
HandlePhysics(a_Dt, a_Chunk);
if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0)
{
- if ((!m_CanPickupItem) && (m_AttachedMobID == -1)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob.
+ if ((!m_CanPickupItem) && (m_AttachedMobID == -1)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob.
{
if (m_CountDownTime <= 0)
{
- m_World->BroadcastSoundEffect("random.splash", (int) floor(GetPosX() * 8), (int) floor(GetPosY() * 8), (int) floor(GetPosZ() * 8), 1, 1);
+ m_World->BroadcastSoundEffect("random.splash", GetPosX(), GetPosY(), GetPosZ(), 1, 1);
SetPosY(GetPosY() - 1);
m_CanPickupItem = true;
m_PickupCountDown = 20;
m_CountDownTime = 100 + m_World->GetTickRandomNumber(800);
LOGD("Floater %i can be picked up", GetUniqueID());
}
- else if (m_CountDownTime == 20) // Calculate the position where the particles should spawn and start producing them.
+ else if (m_CountDownTime == 20) // Calculate the position where the particles should spawn and start producing them.
{
LOGD("Started producing particles for floater %i", GetUniqueID());
m_ParticlePos.Set(GetPosX() + (-4 + m_World->GetTickRandomNumber(8)), GetPosY(), GetPosZ() + (-4 + m_World->GetTickRandomNumber(8)));
@@ -156,12 +156,12 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
m_CountDownTime--;
if (m_World->GetHeight((int) GetPosX(), (int) GetPosZ()) == (int) GetPosY())
{
- if (m_World->IsWeatherWet() && m_World->GetTickRandomNumber(3) == 0) // 25% chance of an extra countdown when being rained on.
+ if (m_World->IsWeatherWet() && m_World->GetTickRandomNumber(3) == 0) // 25% chance of an extra countdown when being rained on.
{
m_CountDownTime--;
}
}
- else // if the floater is underground it has a 50% chance of not decreasing the countdown.
+ else // if the floater is underground it has a 50% chance of not decreasing the countdown.
{
if (m_World->GetTickRandomNumber(1) == 0)
{
@@ -190,21 +190,21 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
if (Callback.HasHit())
{
AttachTo(Callback.GetHitEntity());
- Callback.GetHitEntity()->TakeDamage(*this); // TODO: the player attacked the mob not the floater.
+ Callback.GetHitEntity()->TakeDamage(*this); // TODO: the player attacked the mob not the floater.
m_AttachedMobID = Callback.GetHitEntity()->GetUniqueID();
}
}
cFloaterCheckEntityExist EntityCallback;
m_World->DoWithEntityByID(m_PlayerID, EntityCallback);
- if (!EntityCallback.DoesExist()) // The owner doesn't exist anymore. Destroy the floater entity.
+ if (!EntityCallback.DoesExist()) // The owner doesn't exist anymore. Destroy the floater entity.
{
Destroy(true);
}
if (m_AttachedMobID != -1)
{
- m_World->DoWithEntityByID(m_AttachedMobID, EntityCallback); // The mob the floater was attached to doesn't exist anymore.
+ m_World->DoWithEntityByID(m_AttachedMobID, EntityCallback); // The mob the floater was attached to doesn't exist anymore.
if (!EntityCallback.DoesExist())
{
m_AttachedMobID = -1;
diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h
index 547d503f1..96d77ac82 100644
--- a/src/Entities/Floater.h
+++ b/src/Entities/Floater.h
@@ -14,9 +14,9 @@ class cFloater :
typedef cEntity super;
public:
- //tolua_end
+ // tolua_end
- CLASS_PROTODEF(cFloater);
+ CLASS_PROTODEF(cFloater)
cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);
@@ -43,4 +43,4 @@ protected:
// Entity IDs
int m_PlayerID;
int m_AttachedMobID;
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h
index 9e4572c78..3ed72d9ef 100644
--- a/src/Entities/GhastFireballEntity.h
+++ b/src/Entities/GhastFireballEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cGhastFireballEntity);
+ CLASS_PROTODEF(cGhastFireballEntity)
cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
@@ -35,4 +35,4 @@ protected:
// TODO: Deflecting the fireballs by arrow- or sword- hits
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp
index 41ac86268..32d2b226d 100644
--- a/src/Entities/HangingEntity.cpp
+++ b/src/Entities/HangingEntity.cpp
@@ -10,7 +10,7 @@
cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
- : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8)
+ : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8)
, m_BlockFace(a_BlockFace)
{
SetMaxHealth(1);
@@ -28,14 +28,14 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
switch (m_BlockFace)
{
- case BLOCK_FACE_ZP: break; // Initialised to zero
+ case BLOCK_FACE_ZP: break; // Initialised to zero
case BLOCK_FACE_ZM: Dir = 2; break;
case BLOCK_FACE_XM: Dir = 1; break;
case BLOCK_FACE_XP: Dir = 3; break;
default: ASSERT(!"Unhandled block face when trying to spawn item frame!"); return;
}
- if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180
+ if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180
{
SetYaw((Dir * 90) - 180);
}
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index 6498e4b5b..3593f9ede 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -16,7 +16,7 @@ class cHangingEntity :
public:
- CLASS_PROTODEF(cHangingEntity);
+ CLASS_PROTODEF(cHangingEntity)
cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
@@ -38,7 +38,7 @@ public:
private:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override {};
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}
eBlockFace m_BlockFace;
diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp
index 9dd909880..f0b0c8c65 100644
--- a/src/Entities/ItemFrame.cpp
+++ b/src/Entities/ItemFrame.cpp
@@ -10,7 +10,7 @@
cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
- : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z)
+ : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z)
, m_Item(E_BLOCK_AIR)
, m_Rotation(0)
{
@@ -43,7 +43,7 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player)
}
}
- GetWorld()->BroadcastEntityMetadata(*this); // Update clients
+ GetWorld()->BroadcastEntityMetadata(*this); // Update clients
}
@@ -51,16 +51,17 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player)
-void cItemFrame::KilledBy(cEntity * a_Killer)
+void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
{
if (m_Item.IsEmpty())
{
- super::KilledBy(a_Killer);
+ SetHealth(0);
+ super::KilledBy(a_TDI);
Destroy();
return;
}
- if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
+ if ((a_TDI.Attacker != NULL) && a_TDI.Attacker->IsPlayer() && !((cPlayer *)a_TDI.Attacker)->IsGameModeCreative())
{
cItems Item;
Item.push_back(m_Item);
@@ -69,8 +70,9 @@ void cItemFrame::KilledBy(cEntity * a_Killer)
}
SetHealth(GetMaxHealth());
- m_Item.Clear();
+ m_Item.Empty();
m_Rotation = 0;
+ SetInvulnerableTicks(0);
GetWorld()->BroadcastEntityMetadata(*this);
}
diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h
index 6577e7d94..a63b78b70 100644
--- a/src/Entities/ItemFrame.h
+++ b/src/Entities/ItemFrame.h
@@ -16,7 +16,7 @@ class cItemFrame :
public:
- CLASS_PROTODEF(cItemFrame);
+ CLASS_PROTODEF(cItemFrame)
cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
@@ -24,7 +24,7 @@ public:
const cItem & GetItem(void) { return m_Item; } // tolua_export
/** Set the item in the frame */
- void SetItem(cItem & a_Item) { m_Item = a_Item; }; // tolua_export
+ void SetItem(cItem & a_Item) { m_Item = a_Item; } // tolua_export
/** Returns the rotation from the item in the frame */
Byte GetRotation(void) const { return m_Rotation; } // tolua_export
@@ -35,7 +35,7 @@ public:
private:
virtual void OnRightClicked(cPlayer & a_Player) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
cItem m_Item;
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index db55eb058..d4eadc5d5 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -103,21 +103,7 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
{
- char SubType = 0;
- switch (m_Payload)
- {
- case mpNone: SubType = 0; break;
- case mpChest: SubType = 1; break;
- case mpFurnace: SubType = 2; break;
- case mpTNT: SubType = 3; break;
- case mpHopper: SubType = 5; break;
- default:
- {
- ASSERT(!"Unknown payload, cannot spawn on client");
- return;
- }
- }
- a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart
+ a_ClientHandle.SendSpawnVehicle(*this, 10, (char)m_Payload); // 10 = Minecarts
a_ClientHandle.SendEntityMetadata(*this);
}
@@ -127,7 +113,7 @@ void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
{
- if (IsDestroyed()) // Mainly to stop detector rails triggering again after minecart is dead
+ if (IsDestroyed()) // Mainly to stop detector rails triggering again after minecart is dead
{
return;
}
@@ -156,8 +142,8 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if (!IsBlockRail(InsideType))
{
- Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta); // When an descending minecart hits a flat rail, it goes through the ground; check for this
- if (IsBlockRail(InsideType)) AddPosY(1); // Push cart upwards
+ Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta); // When an descending minecart hits a flat rail, it goes through the ground; check for this
+ if (IsBlockRail(InsideType)) AddPosY(1); // Push cart upwards
}
bool WasDetectorRail = false;
@@ -186,12 +172,12 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
default: VERIFY(!"Unhandled rail type despite checking if block was rail!"); break;
}
- AddPosition(GetSpeed() * (a_Dt / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp
+ AddPosition(GetSpeed() * (a_Dt / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp
}
else
{
// Not on rail, default physics
- SetPosY(floor(GetPosY()) + 0.35); // HandlePhysics overrides this if minecart can fall, else, it is to stop ground clipping minecart bottom when off-rail
+ SetPosY(floor(GetPosY()) + 0.35); // HandlePhysics overrides this if minecart can fall, else, it is to stop ground clipping minecart bottom when off-rail
super::HandlePhysics(a_Dt, *Chunk);
}
@@ -223,18 +209,18 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
switch (a_RailMeta)
{
- case E_META_RAIL_ZM_ZP: // NORTHSOUTH
+ case E_META_RAIL_ZM_ZP: // NORTHSOUTH
{
SetYaw(270);
SetPosY(floor(GetPosY()) + 0.55);
- SetSpeedY(0); // Don't move vertically as on ground
- SetSpeedX(0); // Correct diagonal movement from curved rails
+ SetSpeedY(0); // Don't move vertically as on ground
+ SetSpeedX(0); // Correct diagonal movement from curved rails
// Execute both the entity and block collision checks
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
if (EntCol || BlckCol) return;
- if (GetSpeedZ() != 0) // Don't do anything if cart is stationary
+ if (GetSpeedZ() != 0) // Don't do anything if cart is stationary
{
if (GetSpeedZ() > 0)
{
@@ -249,7 +235,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
}
break;
}
- case E_META_RAIL_XM_XP: // EASTWEST
+ case E_META_RAIL_XM_XP: // EASTWEST
{
SetYaw(180);
SetPosY(floor(GetPosY()) + 0.55);
@@ -272,7 +258,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
}
break;
}
- case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH
+ case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH
{
SetYaw(270);
SetSpeedX(0);
@@ -280,21 +266,21 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
if (GetSpeedZ() >= 0)
{
// SpeedZ POSITIVE, going SOUTH
- if (GetSpeedZ() <= MAX_SPEED) // Speed limit
+ if (GetSpeedZ() <= MAX_SPEED) // Speed limit
{
- AddSpeedZ(0.5); // Speed up
- SetSpeedY(-GetSpeedZ()); // Downward movement is negative (0 minus positive numbers is negative)
+ AddSpeedZ(0.5); // Speed up
+ SetSpeedY(-GetSpeedZ()); // Downward movement is negative (0 minus positive numbers is negative)
}
}
else
{
// SpeedZ NEGATIVE, going NORTH
- AddSpeedZ(1); // Slow down
- SetSpeedY(-GetSpeedZ()); // Upward movement is positive (0 minus negative number is positive number)
+ AddSpeedZ(1); // Slow down
+ SetSpeedY(-GetSpeedZ()); // Upward movement is positive (0 minus negative number is positive number)
}
break;
}
- case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH
+ case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH
{
SetYaw(270);
SetSpeedX(0);
@@ -302,21 +288,21 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
if (GetSpeedZ() > 0)
{
// SpeedZ POSITIVE, going SOUTH
- AddSpeedZ(-1); // Slow down
- SetSpeedY(GetSpeedZ()); // Upward movement positive
+ AddSpeedZ(-1); // Slow down
+ SetSpeedY(GetSpeedZ()); // Upward movement positive
}
else
{
- if (GetSpeedZ() >= MAX_SPEED_NEGATIVE) // Speed limit
+ if (GetSpeedZ() >= MAX_SPEED_NEGATIVE) // Speed limit
{
// SpeedZ NEGATIVE, going NORTH
- AddSpeedZ(-0.5); // Speed up
- SetSpeedY(GetSpeedZ()); // Downward movement negative
+ AddSpeedZ(-0.5); // Speed up
+ SetSpeedY(GetSpeedZ()); // Downward movement negative
}
}
break;
}
- case E_META_RAIL_ASCEND_XM: // ASCEND EAST
+ case E_META_RAIL_ASCEND_XM: // ASCEND EAST
{
SetYaw(180);
SetSpeedZ(0);
@@ -336,7 +322,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
}
break;
}
- case E_META_RAIL_ASCEND_XP: // ASCEND WEST
+ case E_META_RAIL_ASCEND_XP: // ASCEND WEST
{
SetYaw(180);
SetSpeedZ(0);
@@ -356,10 +342,10 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
}
break;
}
- case E_META_RAIL_CURVED_ZM_XM: // Ends pointing NORTH and WEST
+ case E_META_RAIL_CURVED_ZM_XM: // Ends pointing NORTH and WEST
{
- SetYaw(315); // Set correct rotation server side
- SetPosY(floor(GetPosY()) + 0.55); // Levitate dat cart
+ SetYaw(315); // Set correct rotation server side
+ SetPosY(floor(GetPosY()) + 0.55); // Levitate dat cart
SetSpeedY(0);
TestBlockCollision(a_RailMeta);
@@ -369,7 +355,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
break;
}
- case E_META_RAIL_CURVED_ZM_XP: // Curved NORTH EAST
+ case E_META_RAIL_CURVED_ZM_XP: // Curved NORTH EAST
{
SetYaw(225);
SetPosY(floor(GetPosY()) + 0.55);
@@ -380,7 +366,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
break;
}
- case E_META_RAIL_CURVED_ZP_XM: // Curved SOUTH WEST
+ case E_META_RAIL_CURVED_ZP_XM: // Curved SOUTH WEST
{
SetYaw(135);
SetPosY(floor(GetPosY()) + 0.55);
@@ -391,7 +377,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
break;
}
- case E_META_RAIL_CURVED_ZP_XP: // Curved SOUTH EAST
+ case E_META_RAIL_CURVED_ZP_XP: // Curved SOUTH EAST
{
SetYaw(45);
SetPosY(floor(GetPosY()) + 0.55);
@@ -404,7 +390,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
}
default:
{
- ASSERT(!"Unhandled rail meta!"); // Dun dun DUN!
+ ASSERT(!"Unhandled rail meta!"); // Dun dun DUN!
break;
}
}
@@ -428,7 +414,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
switch (a_RailMeta & 0x07)
{
- case E_META_RAIL_ZM_ZP: // NORTHSOUTH
+ case E_META_RAIL_ZM_ZP: // NORTHSOUTH
{
SetYaw(270);
SetPosY(floor(GetPosY()) + 0.55);
@@ -451,7 +437,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
}
break;
}
- case E_META_RAIL_XM_XP: // EASTWEST
+ case E_META_RAIL_XM_XP: // EASTWEST
{
SetYaw(180);
SetPosY(floor(GetPosY()) + 0.55);
@@ -474,7 +460,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
}
break;
}
- case E_META_RAIL_ASCEND_XM: // ASCEND EAST
+ case E_META_RAIL_ASCEND_XM: // ASCEND EAST
{
SetYaw(180);
SetSpeedZ(0);
@@ -493,8 +479,8 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
SetSpeedY(-GetSpeedX());
}
break;
- }
- case E_META_RAIL_ASCEND_XP: // ASCEND WEST
+ }
+ case E_META_RAIL_ASCEND_XP: // ASCEND WEST
{
SetYaw(180);
SetSpeedZ(0);
@@ -513,8 +499,8 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
}
}
break;
- }
- case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH
+ }
+ case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH
{
SetYaw(270);
SetSpeedX(0);
@@ -534,7 +520,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
}
break;
}
- case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH
+ case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH
{
SetYaw(270);
SetSpeedX(0);
@@ -787,7 +773,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
}
}
break;
- }
+ }
case E_META_RAIL_CURVED_ZM_XM:
case E_META_RAIL_CURVED_ZM_XP:
case E_META_RAIL_CURVED_ZP_XM:
@@ -883,7 +869,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
}
}
return true;
- }
+ }
case E_META_RAIL_CURVED_ZM_XM:
case E_META_RAIL_CURVED_ZM_XP:
case E_META_RAIL_CURVED_ZP_XM:
@@ -902,18 +888,21 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
-void cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
+bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
{
if ((TDI.Attacker != NULL) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative())
{
Destroy();
- TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative
- super::DoTakeDamage(TDI);
- return; // No drops for creative
+ TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative
+ SetInvulnerableTicks(0);
+ return super::DoTakeDamage(TDI); // No drops for creative
}
m_LastDamage = TDI.FinalDamage;
- super::DoTakeDamage(TDI);
+ if (!super::DoTakeDamage(TDI))
+ {
+ return false;
+ }
m_World->BroadcastEntityMetadata(*this);
@@ -952,12 +941,13 @@ void cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
default:
{
ASSERT(!"Unhandled minecart type when spawning pickup!");
- return;
+ return true;
}
}
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());
}
+ return true;
}
@@ -976,7 +966,7 @@ void cMinecart::Destroyed()
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cRideableMinecart:
cRideableMinecart::cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height) :
@@ -1019,7 +1009,7 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMinecartWithChest:
cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
@@ -1052,7 +1042,7 @@ void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMinecartWithFurnace:
cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) :
@@ -1074,12 +1064,12 @@ void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player)
{
a_Player.GetInventory().RemoveOneEquippedItem();
}
- if (!m_IsFueled) // We don't want to change the direction by right clicking it.
+ if (!m_IsFueled) // We don't want to change the direction by right clicking it.
{
AddSpeed(a_Player.GetLookVector().x, 0, a_Player.GetLookVector().z);
}
m_IsFueled = true;
- m_FueledTimeLeft = m_FueledTimeLeft + 600; // The minecart will be active 600 more ticks.
+ m_FueledTimeLeft = m_FueledTimeLeft + 600; // The minecart will be active 600 more ticks.
m_World->BroadcastEntityMetadata(*this);
}
}
@@ -1114,7 +1104,7 @@ void cMinecartWithFurnace::Tick(float a_Dt, cChunk & a_Chunk)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMinecartWithTNT:
cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) :
@@ -1128,7 +1118,7 @@ cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) :
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMinecartWithHopper:
cMinecartWithHopper::cMinecartWithHopper(double a_X, double a_Y, double a_Z) :
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index ebdb576e0..410d3c77d 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -21,22 +21,23 @@ class cMinecart :
typedef cEntity super;
public:
- CLASS_PROTODEF(cMinecart);
+ CLASS_PROTODEF(cMinecart)
+ /** Minecart payload, values correspond to packet subtype */
enum ePayload
{
- mpNone, // Empty minecart, ridable by player or mobs
- mpChest, // Minecart-with-chest, can store a grid of 3*8 items
- mpFurnace, // Minecart-with-furnace, can be powered
- mpTNT, // Minecart-with-TNT, can be blown up with activator rail
- mpHopper, // Minecart-with-hopper, can be hopper
+ mpNone = 0, // Empty minecart, ridable by player or mobs
+ mpChest = 1, // Minecart-with-chest, can store a grid of 3*8 items
+ mpFurnace = 2, // Minecart-with-furnace, can be powered
+ mpTNT = 3, // Minecart-with-TNT, can be blown up with activator rail
+ mpHopper = 5, // Minecart-with-hopper, can be hopper
// TODO: Spawner minecarts, (and possibly any block in a minecart with NBT editing)
} ;
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
- virtual void DoTakeDamage(TakeDamageInfo & TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
virtual void Destroyed() override;
int LastDamage(void) const { return m_LastDamage; }
@@ -88,7 +89,7 @@ class cRideableMinecart :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cRideableMinecart);
+ CLASS_PROTODEF(cRideableMinecart)
cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height);
@@ -99,7 +100,7 @@ public:
protected:
cItem m_Content;
- int m_Height;
+ int m_Height;
} ;
@@ -112,7 +113,7 @@ class cMinecartWithChest :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithChest);
+ CLASS_PROTODEF(cMinecartWithChest)
/// Number of item slots in the chest
static const int NumSlots = 9 * 3;
@@ -143,7 +144,7 @@ class cMinecartWithFurnace :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithFurnace);
+ CLASS_PROTODEF(cMinecartWithFurnace)
cMinecartWithFurnace(double a_X, double a_Y, double a_Z);
@@ -175,7 +176,7 @@ class cMinecartWithTNT :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithTNT);
+ CLASS_PROTODEF(cMinecartWithTNT)
cMinecartWithTNT(double a_X, double a_Y, double a_Z);
} ;
@@ -190,7 +191,7 @@ class cMinecartWithHopper :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithHopper);
+ CLASS_PROTODEF(cMinecartWithHopper)
cMinecartWithHopper(double a_X, double a_Y, double a_Z);
} ;
diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h
index c1024bd1b..9877c95c5 100644
--- a/src/Entities/Painting.h
+++ b/src/Entities/Painting.h
@@ -15,20 +15,20 @@ class cPainting :
typedef cEntity super;
public:
- CLASS_PROTODEF(cPainting);
+ CLASS_PROTODEF(cPainting)
cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z);
- const AString & GetName(void) const { return m_Name; } // tolua_export
- int GetDirection(void) const { return m_Direction; } // tolua_export
+ const AString & GetName(void) const { return m_Name; } // tolua_export
+ int GetDirection(void) const { return m_Direction; } // tolua_export
private:
virtual void SpawnOn(cClientHandle & a_Client) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
- virtual void KilledBy(cEntity * a_Killer) override
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
Destroy();
}
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index fffefd538..fe6c24a7a 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -2,14 +2,16 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Pawn.h"
+#include "../World.h"
+#include "../Bindings/PluginManager.h"
-cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
- : cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height)
- , m_bBurnable(true)
+cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height):
+ super(a_EntityType, 0, 0, 0, a_Width, a_Height),
+ m_EntityEffects(tEffectMap())
{
}
@@ -17,3 +19,95 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
+void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ // Iterate through this entity's applied effects
+ for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
+ {
+ // Copies values to prevent pesky wrong accesses and erasures
+ cEntityEffect::eType EffectType = iter->first;
+ cEntityEffect * Effect = iter->second;
+
+ Effect->OnTick(*this);
+
+ // Iterates (must be called before any possible erasure)
+ ++iter;
+
+ // Remove effect if duration has elapsed
+ if (Effect->GetDuration() - Effect->GetTicks() <= 0)
+ {
+ RemoveEntityEffect(EffectType);
+ }
+
+ // TODO: Check for discrepancies between client and server effect values
+ }
+
+ super::Tick(a_Dt, a_Chunk);
+}
+
+
+
+
+
+void cPawn::KilledBy(TakeDamageInfo & a_TDI)
+{
+ ClearEntityEffects();
+ super::KilledBy(a_TDI);
+}
+
+
+
+
+
+void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
+{
+ // Check if the plugins allow the addition:
+ if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Duration, a_Intensity, a_DistanceModifier))
+ {
+ // A plugin disallows the addition, bail out.
+ return;
+ }
+
+ // No need to add empty effects:
+ if (a_EffectType == cEntityEffect::effNoEffect)
+ {
+ return;
+ }
+ a_Duration = (int)(a_Duration * a_DistanceModifier);
+
+ m_EntityEffects[a_EffectType] = cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_DistanceModifier);
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_Intensity, a_Duration);
+ m_EntityEffects[a_EffectType]->OnActivate(*this);
+}
+
+
+
+
+
+void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
+{
+ m_World->BroadcastRemoveEntityEffect(*this, a_EffectType);
+ m_EntityEffects[a_EffectType]->OnDeactivate(*this);
+ delete m_EntityEffects[a_EffectType];
+ m_EntityEffects.erase(a_EffectType);
+}
+
+
+
+
+
+void cPawn::ClearEntityEffects()
+{
+ // Iterate through this entity's applied effects
+ for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
+ {
+ // Copy values to prevent pesky wrong erasures
+ cEntityEffect::eType EffectType = iter->first;
+
+ // Iterates (must be called before any possible erasure)
+ ++iter;
+
+ // Remove effect
+ RemoveEntityEffect(EffectType);
+ }
+}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index e76337d86..d50bcd8af 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -2,6 +2,7 @@
#pragma once
#include "Entity.h"
+#include "EntityEffect.h"
@@ -15,12 +16,37 @@ class cPawn :
typedef cEntity super;
public:
- CLASS_PROTODEF(cPawn);
+ CLASS_PROTODEF(cPawn)
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
+
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+
+ // tolua_begin
+
+ /** Applies an entity effect
+ Checks with plugins if they allow the addition.
+ @param a_EffectType The entity effect to apply
+ @param a_EffectDurationTicks The duration of the effect
+ @param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc)
+ @param a_DistanceModifier The scalar multiplied to the potion duration, only applies to splash potions)
+ */
+ void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1);
+
+ /** Removes a currently applied entity effect
+ @param a_EffectType The entity effect to remove
+ */
+ void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
+
+ /** Removes all currently applied entity effects (used when drinking milk) */
+ void ClearEntityEffects(void);
+
+ // tolua_end
protected:
- bool m_bBurnable;
+ typedef std::map<cEntityEffect::eType, cEntityEffect *> tEffectMap;
+ tEffectMap m_EntityEffects;
} ; // tolua_export
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 497b41683..aab534f41 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -30,7 +30,7 @@ public:
virtual bool Item(cEntity * a_Entity) override
{
- if (!a_Entity->IsPickup() || (a_Entity->GetUniqueID() == m_Pickup->GetUniqueID()) || a_Entity->IsDestroyed())
+ if (!a_Entity->IsPickup() || (a_Entity->GetUniqueID() <= m_Pickup->GetUniqueID()) || a_Entity->IsDestroyed())
{
return false;
}
@@ -38,10 +38,31 @@ public:
Vector3d EntityPos = a_Entity->GetPosition();
double Distance = (EntityPos - m_Position).Length();
- if ((Distance < 1.2) && ((cPickup *)a_Entity)->GetItem().IsEqual(m_Pickup->GetItem()))
+ cItem & Item = ((cPickup *)a_Entity)->GetItem();
+ if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem()))
{
- m_Pickup->GetItem().AddCount(((cPickup *)a_Entity)->GetItem().m_ItemCount);
- a_Entity->Destroy();
+ short CombineCount = Item.m_ItemCount;
+ if ((CombineCount + m_Pickup->GetItem().m_ItemCount) > Item.GetMaxStackSize())
+ {
+ CombineCount = Item.GetMaxStackSize() - m_Pickup->GetItem().m_ItemCount;
+ }
+
+ if (CombineCount <= 0)
+ {
+ return false;
+ }
+
+ m_Pickup->GetItem().AddCount((char)CombineCount);
+ Item.m_ItemCount -= CombineCount;
+
+ if (Item.m_ItemCount <= 0)
+ {
+ a_Entity->Destroy();
+ }
+ else
+ {
+ a_Entity->GetWorld()->BroadcastEntityMetadata(*a_Entity);
+ }
m_FoundMatchingPickup = true;
}
return false;
@@ -64,7 +85,7 @@ protected:
cPickup::cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */)
- : cEntity(etPickup, a_PosX, a_PosY, a_PosZ, 0.2, 0.2)
+ : cEntity(etPickup, a_PosX, a_PosY, a_PosZ, 0.2, 0.2)
, m_Timer(0.f)
, m_Item(a_Item)
, m_bCollected(false)
@@ -92,7 +113,7 @@ void cPickup::SpawnOn(cClientHandle & a_Client)
void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- BroadcastMovementUpdate(); //Notify clients of position
+ BroadcastMovementUpdate(); // Notify clients of position
m_Timer += a_Dt;
@@ -122,17 +143,17 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
m_bCollected = true;
m_Timer = 0; // We have to reset the timer.
m_Timer += a_Dt; // In case we have to destroy the pickup in the same tick.
- if (m_Timer > 500.f)
+ if (m_Timer > 500.f)
{
Destroy(true);
return;
}
}
- if (!IsDestroyed()) // Don't try to combine if someone has tried to combine me
+ if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't combine into an already full pickup
{
cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this);
- m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries
+ m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries
if (PickupCombiningCallback.FoundMatchingPickup())
{
m_World->BroadcastEntityMetadata(*this);
@@ -155,7 +176,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
return;
}
- if (GetPosY() < VOID_BOUNDARY) // Out of this world and no more visible!
+ if (GetPosY() < VOID_BOUNDARY) // Out of this world and no more visible!
{
Destroy(true);
return;
@@ -173,14 +194,14 @@ bool cPickup::CollectedBy(cPlayer * a_Dest)
if (m_bCollected)
{
// LOG("Pickup %d cannot be collected by \"%s\", because it has already been collected.", m_UniqueID, a_Dest->GetName().c_str());
- return false; // It's already collected!
+ return false; // It's already collected!
}
// Two seconds if player created the pickup (vomiting), half a second if anything else
if (m_Timer < (m_bIsPlayerCreated ? 2000.f : 500.f))
{
// LOG("Pickup %d cannot be collected by \"%s\", because it is not old enough.", m_UniqueID, a_Dest->GetName().c_str());
- return false; // Not old enough
+ return false; // Not old enough
}
if (cRoot::Get()->GetPluginManager()->CallHookCollectingPickup(a_Dest, *this))
@@ -192,11 +213,21 @@ bool cPickup::CollectedBy(cPlayer * a_Dest)
int NumAdded = a_Dest->GetInventory().AddItem(m_Item);
if (NumAdded > 0)
{
+ // Check achievements
+ switch (m_Item.m_ItemType)
+ {
+ case E_BLOCK_LOG: a_Dest->AwardAchievement(achMineWood); break;
+ case E_ITEM_LEATHER: a_Dest->AwardAchievement(achKillCow); break;
+ case E_ITEM_DIAMOND: a_Dest->AwardAchievement(achDiamonds); break;
+ case E_ITEM_BLAZE_ROD: a_Dest->AwardAchievement(achBlazeRod); break;
+ default: break;
+ }
+
m_Item.m_ItemCount -= NumAdded;
- m_World->BroadcastCollectPickup(*this, *a_Dest);
+ m_World->BroadcastCollectEntity(*this, *a_Dest);
// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
- m_World->BroadcastSoundEffect("random.pop",(int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
- if (m_Item.m_ItemCount == 0)
+ m_World->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ if (m_Item.m_ItemCount <= 0)
{
// All of the pickup has been collected, schedule the pickup for destroying
m_bCollected = true;
diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h
index 2dcbecaaf..4d5250819 100644
--- a/src/Entities/Pickup.h
+++ b/src/Entities/Pickup.h
@@ -23,16 +23,16 @@ class cPickup :
public:
// tolua_end
- CLASS_PROTODEF(cPickup);
+ CLASS_PROTODEF(cPickup)
cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f);
- cItem & GetItem(void) {return m_Item; } // tolua_export
+ cItem & GetItem(void) {return m_Item; } // tolua_export
const cItem & GetItem(void) const {return m_Item; }
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- bool CollectedBy(cPlayer * a_Dest); // tolua_export
+ bool CollectedBy(cPlayer * a_Dest); // tolua_export
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
@@ -46,7 +46,7 @@ public:
bool IsCollected(void) const { return m_bCollected; } // tolua_export
/** Returns true if created by player (i.e. vomiting), used for determining picking-up delay time */
- bool IsPlayerCreated(void) const { return m_bIsPlayerCreated; } // tolua_export
+ bool IsPlayerCreated(void) const { return m_bIsPlayerCreated; } // tolua_export
private:
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index fedb62527..cf3322968 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1,13 +1,15 @@
-
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Player.h"
+#include "../ChatColor.h"
#include "../Server.h"
#include "../UI/Window.h"
#include "../UI/WindowOwner.h"
#include "../World.h"
#include "../Bindings/PluginManager.h"
#include "../BlockEntities/BlockEntity.h"
+#include "../BlockEntities/EnderChestEntity.h"
#include "../GroupManager.h"
#include "../Group.h"
#include "../Root.h"
@@ -16,57 +18,64 @@
#include "../Items/ItemHandler.h"
#include "../Vector3.h"
+#include "../WorldStorage/StatSerializer.h"
+#include "../CompositeChat.h"
+
#include "inifile/iniFile.h"
#include "json/json.h"
-
-
-
-
-
-cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
- : super(etPlayer, 0.6, 1.8)
- , m_bVisible(true)
- , m_FoodLevel(MAX_FOOD_LEVEL)
- , m_FoodSaturationLevel(5)
- , m_FoodTickTimer(0)
- , m_FoodExhaustionLevel(0)
- , m_FoodPoisonedTicksRemaining(0)
- , m_LastJumpHeight(0)
- , m_LastGroundHeight(0)
- , m_bTouchGround(false)
- , m_Stance(0.0)
- , m_Inventory(*this)
- , m_CurrentWindow(NULL)
- , m_InventoryWindow(NULL)
- , m_Color('-')
- , m_GameMode(eGameMode_NotSet)
- , m_IP("")
- , m_ClientHandle(a_Client)
- , m_NormalMaxSpeed(1.0)
- , m_SprintingMaxSpeed(1.3)
- , m_FlyingMaxSpeed(1.0)
- , m_IsCrouched(false)
- , m_IsSprinting(false)
- , m_IsFlying(false)
- , m_IsSwimming(false)
- , m_IsSubmerged(false)
- , m_IsFishing(false)
- , m_CanFly(false)
- , m_EatingFinishTick(-1)
- , m_LifetimeTotalXp(0)
- , m_CurrentXp(0)
- , m_bDirtyExperience(false)
- , m_IsChargingBow(false)
- , m_BowCharge(0)
- , m_FloaterID(-1)
- , m_Team(NULL)
-{
- LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
- a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
- this, GetUniqueID()
- );
-
+// 6000 ticks or 5 minutes
+#define PLAYER_INVENTORY_SAVE_INTERVAL 6000
+
+// 1000 = once per second
+#define PLAYER_LIST_TIME_MS 1000
+
+
+
+
+
+
+cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
+ super(etPlayer, 0.6, 1.8),
+ m_bVisible(true),
+ m_FoodLevel(MAX_FOOD_LEVEL),
+ m_FoodSaturationLevel(5.0),
+ m_FoodTickTimer(0),
+ m_FoodExhaustionLevel(0.0),
+ m_LastJumpHeight(0),
+ m_LastGroundHeight(0),
+ m_bTouchGround(false),
+ m_Stance(0.0),
+ m_Inventory(*this),
+ m_EnderChestContents(9, 3),
+ m_CurrentWindow(NULL),
+ m_InventoryWindow(NULL),
+ m_Color('-'),
+ m_GameMode(eGameMode_NotSet),
+ m_IP(""),
+ m_ClientHandle(a_Client),
+ m_NormalMaxSpeed(1.0),
+ m_SprintingMaxSpeed(1.3),
+ m_FlyingMaxSpeed(1.0),
+ m_IsCrouched(false),
+ m_IsSprinting(false),
+ m_IsFlying(false),
+ m_IsSwimming(false),
+ m_IsSubmerged(false),
+ m_IsFishing(false),
+ m_CanFly(false),
+ m_EatingFinishTick(-1),
+ m_LifetimeTotalXp(0),
+ m_CurrentXp(0),
+ m_bDirtyExperience(false),
+ m_IsChargingBow(false),
+ m_BowCharge(0),
+ m_FloaterID(-1),
+ m_Team(NULL),
+ m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL),
+ m_bIsTeleporting(false),
+ m_UUID((a_Client != NULL) ? a_Client->GetUUID() : "")
+{
m_InventoryWindow = new cInventoryWindow(*this);
m_CurrentWindow = m_InventoryWindow;
m_InventoryWindow->OpenedByPlayer(*this);
@@ -76,19 +85,17 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
cTimer t1;
m_LastPlayerListTime = t1.GetNowTime();
-
- m_TimeLastTeleportPacket = 0;
m_PlayerName = a_PlayerName;
- m_bDirtyPosition = true; // So chunks are streamed to player at spawn
- if (!LoadFromDisk())
+ cWorld * World = NULL;
+ if (!LoadFromDisk(World))
{
m_Inventory.Clear();
- cWorld * DefaultWorld = cRoot::Get()->GetDefaultWorld();
- SetPosX(DefaultWorld->GetSpawnX());
- SetPosY(DefaultWorld->GetSpawnY());
- SetPosZ(DefaultWorld->GetSpawnZ());
+ SetPosX(World->GetSpawnX());
+ SetPosY(World->GetSpawnY());
+ SetPosZ(World->GetSpawnZ());
+ SetBedPos(Vector3i((int)World->GetSpawnX(), (int)World->GetSpawnY(), (int)World->GetSpawnZ()));
LOGD("Player \"%s\" is connecting for the first time, spawning at default world spawn {%.2f, %.2f, %.2f}",
a_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ()
@@ -101,11 +108,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
if (m_GameMode == gmNotSet)
{
- cWorld * World = cRoot::Get()->GetWorld(GetLoadedWorldName());
- if (World == NULL)
- {
- World = cRoot::Get()->GetDefaultWorld();
- }
if (World->IsGameModeCreative())
{
m_CanFly = true;
@@ -124,7 +126,7 @@ cPlayer::~cPlayer(void)
if (!cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this))
{
cRoot::Get()->BroadcastChatLeave(Printf("%s has left the game", GetName().c_str()));
- LOGINFO("Player %s has left the game.", GetName().c_str());
+ LOGINFO("Player %s has left the game", GetName().c_str());
}
LOGD("Deleting cPlayer \"%s\" at %p, ID %d", GetName().c_str(), this, GetUniqueID());
@@ -134,11 +136,10 @@ cPlayer::~cPlayer(void)
SaveToDisk();
- m_World->RemovePlayer( this );
-
m_ClientHandle = NULL;
delete m_InventoryWindow;
+ m_InventoryWindow = NULL;
LOGD("Player %p deleted", this);
}
@@ -150,8 +151,6 @@ cPlayer::~cPlayer(void)
void cPlayer::Destroyed()
{
CloseWindow(false);
-
- m_ClientHandle = NULL;
}
@@ -166,11 +165,11 @@ void cPlayer::SpawnOn(cClientHandle & a_Client)
}
a_Client.SendPlayerSpawn(*this);
a_Client.SendEntityHeadLook(*this);
- a_Client.SendEntityEquipment(*this, 0, m_Inventory.GetEquippedItem() );
- a_Client.SendEntityEquipment(*this, 1, m_Inventory.GetEquippedBoots() );
- a_Client.SendEntityEquipment(*this, 2, m_Inventory.GetEquippedLeggings() );
- a_Client.SendEntityEquipment(*this, 3, m_Inventory.GetEquippedChestplate() );
- a_Client.SendEntityEquipment(*this, 4, m_Inventory.GetEquippedHelmet() );
+ a_Client.SendEntityEquipment(*this, 0, m_Inventory.GetEquippedItem());
+ a_Client.SendEntityEquipment(*this, 1, m_Inventory.GetEquippedBoots());
+ a_Client.SendEntityEquipment(*this, 2, m_Inventory.GetEquippedLeggings());
+ a_Client.SendEntityEquipment(*this, 3, m_Inventory.GetEquippedChestplate());
+ a_Client.SendEntityEquipment(*this, 4, m_Inventory.GetEquippedHelmet());
}
@@ -194,6 +193,8 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
return;
}
}
+
+ m_Stats.AddValue(statMinutesPlayed, 1);
if (!a_Chunk.IsValid())
{
@@ -209,25 +210,22 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
m_BowCharge += 1;
}
- //handle updating experience
+ // Handle updating experience
if (m_bDirtyExperience)
{
SendExperience();
}
- if (m_bDirtyPosition)
+ if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick?
{
// Apply food exhaustion from movement:
ApplyFoodExhaustionFromMovement();
cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this);
- BroadcastMovementUpdate(m_ClientHandle);
m_ClientHandle->StreamChunks();
}
- else
- {
- BroadcastMovementUpdate(m_ClientHandle);
- }
+
+ BroadcastMovementUpdate(m_ClientHandle);
if (m_Health > 0) // make sure player is alive
{
@@ -251,7 +249,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
// Send Player List (Once per m_LastPlayerListTime/1000 ms)
cTimer t1;
- if (m_LastPlayerListTime + cPlayer::PLAYER_LIST_TIME_MS <= t1.GetNowTime())
+ if (m_LastPlayerListTime + PLAYER_LIST_TIME_MS <= t1.GetNowTime())
{
m_World->SendPlayerList(this);
m_LastPlayerListTime = t1.GetNowTime();
@@ -261,6 +259,16 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
{
m_LastGroundHeight = (float)GetPosY();
}
+
+ if (m_TicksUntilNextSave == 0)
+ {
+ SaveToDisk();
+ m_TicksUntilNextSave = PLAYER_INVENTORY_SAVE_INTERVAL;
+ }
+ else
+ {
+ m_TicksUntilNextSave--;
+ }
}
@@ -269,20 +277,20 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
short cPlayer::CalcLevelFromXp(short a_XpTotal)
{
- //level 0 to 15
- if(a_XpTotal <= XP_TO_LEVEL15)
+ // level 0 to 15
+ if (a_XpTotal <= XP_TO_LEVEL15)
{
return a_XpTotal / XP_PER_LEVEL_TO15;
}
- //level 30+
- if(a_XpTotal > XP_TO_LEVEL30)
+ // level 30+
+ if (a_XpTotal > XP_TO_LEVEL30)
{
return (short) (151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7;
}
- //level 16 to 30
- return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal )))) / 3;
+ // level 16 to 30
+ return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal)))) / 3;
}
@@ -291,20 +299,20 @@ short cPlayer::CalcLevelFromXp(short a_XpTotal)
short cPlayer::XpForLevel(short a_Level)
{
- //level 0 to 15
- if(a_Level <= 15)
+ // level 0 to 15
+ if (a_Level <= 15)
{
return a_Level * XP_PER_LEVEL_TO15;
}
- //level 30+
- if(a_Level >= 31)
+ // level 30+
+ if (a_Level >= 31)
{
- return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 );
+ return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220);
}
- //level 16 to 30
- return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360 );
+ // level 16 to 30
+ return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360);
}
@@ -325,7 +333,7 @@ float cPlayer::GetXpPercentage()
short int currentLevel = CalcLevelFromXp(m_CurrentXp);
short int currentLevel_XpBase = XpForLevel(currentLevel);
- return (float)(m_CurrentXp - currentLevel_XpBase) /
+ return (float)(m_CurrentXp - currentLevel_XpBase) /
(float)(XpForLevel(1+currentLevel) - currentLevel_XpBase);
}
@@ -335,10 +343,10 @@ float cPlayer::GetXpPercentage()
bool cPlayer::SetCurrentExperience(short int a_CurrentXp)
{
- if(!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp)))
+ if (!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp)))
{
LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_CurrentXp);
- return false; //oops, they gave us a dodgey number
+ return false; // oops, they gave us a dodgey number
}
m_CurrentXp = a_CurrentXp;
@@ -360,16 +368,13 @@ short cPlayer::DeltaExperience(short a_Xp_delta)
// Value was bad, abort and report
LOGWARNING("Attempt was made to increment Xp by %d, which overflowed the short datatype. Ignoring.",
a_Xp_delta);
- return -1; // Should we instead just return the current Xp?
+ return -1; // Should we instead just return the current Xp?
}
m_CurrentXp += a_Xp_delta;
// Make sure they didn't subtract too much
- if (m_CurrentXp < 0)
- {
- m_CurrentXp = 0;
- }
+ m_CurrentXp = std::max<short int>(m_CurrentXp, 0);
// Update total for score calculation
if (a_Xp_delta > 0)
@@ -377,8 +382,8 @@ short cPlayer::DeltaExperience(short a_Xp_delta)
m_LifetimeTotalXp += a_Xp_delta;
}
- LOGD("Player \"%s\" gained/lost %d experience, total is now: %d",
- m_PlayerName.c_str(), a_Xp_delta, m_CurrentXp);
+ LOGD("Player \"%s\" gained/lost %d experience, total is now: %d",
+ GetName().c_str(), a_Xp_delta, m_CurrentXp);
// Set experience to be updated
m_bDirtyExperience = true;
@@ -392,9 +397,10 @@ short cPlayer::DeltaExperience(short a_Xp_delta)
void cPlayer::StartChargingBow(void)
{
- LOGD("Player \"%s\" started charging their bow", m_PlayerName.c_str());
+ LOGD("Player \"%s\" started charging their bow", GetName().c_str());
m_IsChargingBow = true;
m_BowCharge = 0;
+ m_World->BroadcastEntityMetadata(*this, m_ClientHandle);
}
@@ -403,10 +409,12 @@ void cPlayer::StartChargingBow(void)
int cPlayer::FinishChargingBow(void)
{
- LOGD("Player \"%s\" finished charging their bow at a charge of %d", m_PlayerName.c_str(), m_BowCharge);
+ LOGD("Player \"%s\" finished charging their bow at a charge of %d", GetName().c_str(), m_BowCharge);
int res = m_BowCharge;
m_IsChargingBow = false;
m_BowCharge = 0;
+ m_World->BroadcastEntityMetadata(*this, m_ClientHandle);
+
return res;
}
@@ -416,9 +424,10 @@ int cPlayer::FinishChargingBow(void)
void cPlayer::CancelChargingBow(void)
{
- LOGD("Player \"%s\" cancelled charging their bow at a charge of %d", m_PlayerName.c_str(), m_BowCharge);
+ LOGD("Player \"%s\" cancelled charging their bow at a charge of %d", GetName().c_str(), m_BowCharge);
m_IsChargingBow = false;
m_BowCharge = 0;
+ m_World->BroadcastEntityMetadata(*this, m_ClientHandle);
}
@@ -457,8 +466,18 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
else
{
float Dist = (float)(m_LastGroundHeight - floor(GetPosY()));
+
+ if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above
+ {
+ // Increment statistic
+ m_Stats.AddValue(statDistFallen, (StatValue)floor(Dist * 100 + 0.5));
+ }
+
int Damage = (int)(Dist - 3.f);
- if (m_LastJumpHeight > m_LastGroundHeight) Damage++;
+ if (m_LastJumpHeight > m_LastGroundHeight)
+ {
+ Damage++;
+ }
m_LastJumpHeight = (float)GetPosY();
if (Damage > 0)
@@ -468,7 +487,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
// Fall particles
GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, (int)GetPosY() - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */);
- }
+ }
m_LastGroundHeight = (float)GetPosY();
}
@@ -490,7 +509,15 @@ void cPlayer::Heal(int a_Health)
void cPlayer::SetFoodLevel(int a_FoodLevel)
{
- m_FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL));
+ int FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL));
+
+ if (cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*this, FoodLevel))
+ {
+ m_FoodSaturationLevel = 5.0;
+ return;
+ }
+
+ m_FoodLevel = FoodLevel;
SendHealth();
}
@@ -525,26 +552,15 @@ void cPlayer::SetFoodExhaustionLevel(double a_FoodExhaustionLevel)
-void cPlayer::SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining)
-{
- m_FoodPoisonedTicksRemaining = a_FoodPoisonedTicksRemaining;
-}
-
-
-
-
-
bool cPlayer::Feed(int a_Food, double a_Saturation)
{
- if (m_FoodLevel >= MAX_FOOD_LEVEL)
+ if (IsSatiated())
{
return false;
}
-
- m_FoodLevel = std::min(a_Food + m_FoodLevel, (int)MAX_FOOD_LEVEL);
- m_FoodSaturationLevel = std::min(m_FoodSaturationLevel + a_Saturation, (double)m_FoodLevel);
-
- SendHealth();
+
+ SetFoodSaturationLevel(m_FoodSaturationLevel + a_Saturation);
+ SetFoodLevel(m_FoodLevel + a_Food);
return true;
}
@@ -554,17 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation)
void cPlayer::FoodPoison(int a_NumTicks)
{
- bool HasBeenFoodPoisoned = (m_FoodPoisonedTicksRemaining > 0);
- m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
- if (!HasBeenFoodPoisoned)
- {
- m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER);
- SendHealth();
- }
- else
- {
- m_World->BroadcastEntityEffect(*this, E_EFFECT_HUNGER, 0, 400); // Give the player the "Hunger" effect for 20 seconds.
- }
+ AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0, 1);
}
@@ -607,8 +613,9 @@ void cPlayer::FinishEating(void)
GetInventory().RemoveOneEquippedItem();
- //if the food is mushroom soup, return a bowl to the inventory
- if( Item.m_ItemType == E_ITEM_MUSHROOM_SOUP ) {
+ // if the food is mushroom soup, return a bowl to the inventory
+ if (Item.m_ItemType == E_ITEM_MUSHROOM_SOUP)
+ {
cItem emptyBowl(E_ITEM_BOWL, 1, 0, "");
GetInventory().AddItem(emptyBowl, true, true);
}
@@ -808,53 +815,57 @@ void cPlayer::SetFlying(bool a_IsFlying)
-void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
+bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if ((a_TDI.DamageType != dtInVoid) && (a_TDI.DamageType != dtPlugin))
{
if (IsGameModeCreative())
{
// No damage / health in creative mode if not void or plugin damage
- return;
+ return false;
}
}
if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
{
- cPlayer* Attacker = (cPlayer*) a_TDI.Attacker;
+ cPlayer * Attacker = (cPlayer *)a_TDI.Attacker;
if ((m_Team != NULL) && (m_Team == Attacker->m_Team))
{
if (!m_Team->AllowsFriendlyFire())
{
// Friendly fire is disabled
- return;
+ return false;
}
}
}
- super::DoTakeDamage(a_TDI);
-
- // Any kind of damage adds food exhaustion
- AddFoodExhaustion(0.3f);
-
- SendHealth();
+ if (super::DoTakeDamage(a_TDI))
+ {
+ // Any kind of damage adds food exhaustion
+ AddFoodExhaustion(0.3f);
+ SendHealth();
+
+ m_Stats.AddValue(statDamageTaken, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5));
+ return true;
+ }
+ return false;
}
-void cPlayer::KilledBy(cEntity * a_Killer)
+void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
if (m_Health > 0)
{
- return; // not dead yet =]
+ return; // not dead yet =]
}
- m_bVisible = false; // So new clients don't see the player
+ m_bVisible = false; // So new clients don't see the player
// Puke out all the items
cItems Pickups;
@@ -866,27 +877,53 @@ void cPlayer::KilledBy(cEntity * a_Killer)
Pickups.Add(cItem(E_ITEM_RED_APPLE));
}
+ m_Stats.AddValue(statItemsDropped, Pickups.Size());
+
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
SaveToDisk(); // Save it, yeah the world is a tough place !
- if (a_Killer == NULL)
+ if (a_TDI.Attacker == NULL)
{
- GetWorld()->BroadcastChatDeath(Printf("%s was killed by environmental damage", GetName().c_str()));
+ AString DamageText;
+ switch (a_TDI.DamageType)
+ {
+ case dtRangedAttack: DamageText = "was shot"; break;
+ case dtLightning: DamageText = "was plasmified by lightining"; break;
+ case dtFalling: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "fell to death" : "hit the ground too hard"; break;
+ case dtDrowning: DamageText = "drowned"; break;
+ case dtSuffocating: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "git merge'd into a block" : "fused with a block"; break;
+ case dtStarving: DamageText = "forgot the importance of food"; break;
+ case dtCactusContact: DamageText = "was impaled on a cactus"; break;
+ case dtLavaContact: DamageText = "was melted by lava"; break;
+ case dtPoisoning: DamageText = "died from septicaemia"; break;
+ case dtWithering: DamageText = "is a husk of their former selves"; break;
+ case dtOnFire: DamageText = "forgot to stop, drop, and roll"; break;
+ case dtFireContact: DamageText = "burnt themselves to death"; break;
+ case dtInVoid: DamageText = "somehow fell out of the world"; break;
+ case dtPotionOfHarming: DamageText = "was magicked to death"; break;
+ case dtEnderPearl: DamageText = "misused an ender pearl"; break;
+ case dtAdmin: DamageText = "was administrator'd"; break;
+ case dtExplosion: DamageText = "blew up"; break;
+ default: DamageText = "died, somehow; we've no idea how though"; break;
+ }
+ GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str()));
}
- else if (a_Killer->IsPlayer())
+ else if (a_TDI.Attacker->IsPlayer())
{
- GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), ((cPlayer *)a_Killer)->GetName().c_str()));
+ cPlayer * Killer = (cPlayer *)a_TDI.Attacker;
- m_World->GetScoreBoard().AddPlayerScore(((cPlayer *)a_Killer)->GetName(), cObjective::otPlayerKillCount, 1);
+ GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str()));
}
else
{
- AString KillerClass = a_Killer->GetClass();
- KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch")
+ AString KillerClass = a_TDI.Attacker->GetClass();
+ KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch")
GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));
}
+ m_Stats.AddValue(statDeaths);
+
m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::otDeathCount, 1);
}
@@ -894,25 +931,56 @@ void cPlayer::KilledBy(cEntity * a_Killer)
+void cPlayer::Killed(cEntity * a_Victim)
+{
+ cScoreboard & ScoreBoard = m_World->GetScoreBoard();
+
+ if (a_Victim->IsPlayer())
+ {
+ m_Stats.AddValue(statPlayerKills);
+
+ ScoreBoard.AddPlayerScore(GetName(), cObjective::otPlayerKillCount, 1);
+ }
+ else if (a_Victim->IsMob())
+ {
+ if (((cMonster *)a_Victim)->GetMobFamily() == cMonster::mfHostile)
+ {
+ AwardAchievement(achKillMonster);
+ }
+
+ m_Stats.AddValue(statMobKills);
+ }
+
+ ScoreBoard.AddPlayerScore(GetName(), cObjective::otTotalKillCount, 1);
+}
+
+
+
+
+
void cPlayer::Respawn(void)
{
+ ASSERT(m_World != NULL);
+
m_Health = GetMaxHealth();
+ SetInvulnerableTicks(20);
// Reset food level:
m_FoodLevel = MAX_FOOD_LEVEL;
- m_FoodSaturationLevel = 5;
+ m_FoodSaturationLevel = 5.0;
+ m_FoodExhaustionLevel = 0.0;
// Reset Experience
m_CurrentXp = 0;
m_LifetimeTotalXp = 0;
// ToDo: send score to client? How?
- m_ClientHandle->SendRespawn();
+ m_ClientHandle->SendRespawn(GetWorld()->GetDimension(), true);
// Extinguish the fire:
StopBurning();
- TeleportToCoords(GetWorld()->GetSpawnX(), GetWorld()->GetSpawnY(), GetWorld()->GetSpawnZ());
+ TeleportToCoords(GetLastBedPos().x, GetLastBedPos().y, GetLastBedPos().z);
SetVisible(true);
}
@@ -931,7 +999,7 @@ double cPlayer::GetEyeHeight(void) const
Vector3d cPlayer::GetEyePosition(void) const
{
- return Vector3d( GetPosX(), m_Stance, GetPosZ() );
+ return Vector3d( GetPosX(), m_Stance, GetPosZ());
}
@@ -1093,7 +1161,7 @@ void cPlayer::SetGameMode(eGameMode a_GameMode)
-void cPlayer::LoginSetGameMode( eGameMode a_GameMode )
+void cPlayer::LoginSetGameMode( eGameMode a_GameMode)
{
m_GameMode = a_GameMode;
}
@@ -1111,11 +1179,53 @@ void cPlayer::SetIP(const AString & a_IP)
+unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach)
+{
+ eStatistic Prerequisite = cStatInfo::GetPrerequisite(a_Ach);
+
+ // Check if the prerequisites are met
+ if (Prerequisite != statInvalid)
+ {
+ if (m_Stats.GetValue(Prerequisite) == 0)
+ {
+ return 0;
+ }
+ }
+
+ StatValue Old = m_Stats.GetValue(a_Ach);
+
+ if (Old > 0)
+ {
+ return m_Stats.AddValue(a_Ach);
+ }
+ else
+ {
+ // First time, announce it
+ cCompositeChat Msg;
+ Msg.SetMessageType(mtSuccess);
+ Msg.AddShowAchievementPart(GetName(), cStatInfo::GetName(a_Ach));
+ m_World->BroadcastChat(Msg);
+
+ // Increment the statistic
+ StatValue New = m_Stats.AddValue(a_Ach);
+
+ // Achievement Get!
+ m_ClientHandle->SendStatistics(m_Stats);
+
+ return New;
+ }
+}
+
+
+
+
+
void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
{
SetPosition(a_PosX, a_PosY, a_PosZ);
m_LastGroundHeight = (float)a_PosY;
m_LastJumpHeight = (float)a_PosY;
+ m_bIsTeleporting = true;
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
m_ClientHandle->SendPlayerMoveLook();
@@ -1160,7 +1270,7 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const
// TODO: Add a slight random change (+-0.0075 in each direction)
return res * a_SpeedCoeff;
-}
+}
@@ -1169,6 +1279,17 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const
void cPlayer::ForceSetSpeed(const Vector3d & a_Speed)
{
SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cPlayer::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
+{
+ super::DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ);
+
+ // Send the speed to the client so he actualy moves
m_ClientHandle->SendEntityVelocity(*this);
}
@@ -1176,13 +1297,13 @@ void cPlayer::ForceSetSpeed(const Vector3d & a_Speed)
-void cPlayer::MoveTo( const Vector3d & a_NewPos )
+void cPlayer::MoveTo( const Vector3d & a_NewPos)
{
if ((a_NewPos.y < -990) && (GetPosY() > -100))
{
// When attached to an entity, the client sends position packets with weird coords:
// Y = -999 and X, Z = attempting to create speed, usually up to 0.03
- // We cannot test m_AttachedTo, because when deattaching, the server thinks the client is already deattached while
+ // We cannot test m_AttachedTo, because when deattaching, the server thinks the client is already deattached while
// the client may still send more of these nonsensical packets.
if (m_AttachedTo != NULL)
{
@@ -1195,8 +1316,11 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos )
// TODO: should do some checks to see if player is not moving through terrain
// TODO: Official server refuses position packets too far away from each other, kicking "hacked" clients; we should, too
+
+ Vector3d DeltaPos = a_NewPos - GetPosition();
+ UpdateMovementStats(DeltaPos);
- SetPosition( a_NewPos );
+ SetPosition( a_NewPos);
SetStance(a_NewPos.y + 1.62);
}
@@ -1206,7 +1330,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos )
void cPlayer::SetVisible(bool a_bVisible)
{
- if (a_bVisible && !m_bVisible) // Make visible
+ if (a_bVisible && !m_bVisible) // Make visible
{
m_bVisible = true;
m_World->BroadcastSpawnEntity(*this);
@@ -1214,7 +1338,7 @@ void cPlayer::SetVisible(bool a_bVisible)
if (!a_bVisible && m_bVisible)
{
m_bVisible = false;
- m_World->BroadcastDestroyEntity(*this, m_ClientHandle); // Destroy on all clients
+ m_World->BroadcastDestroyEntity(*this, m_ClientHandle); // Destroy on all clients
}
}
@@ -1222,11 +1346,11 @@ void cPlayer::SetVisible(bool a_bVisible)
-void cPlayer::AddToGroup( const AString & a_GroupName )
+void cPlayer::AddToGroup( const AString & a_GroupName)
{
- cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName );
- m_Groups.push_back( Group );
- LOGD("Added %s to group %s", m_PlayerName.c_str(), a_GroupName.c_str() );
+ cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName);
+ m_Groups.push_back( Group);
+ LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str());
ResolveGroups();
ResolvePermissions();
}
@@ -1235,28 +1359,28 @@ void cPlayer::AddToGroup( const AString & a_GroupName )
-void cPlayer::RemoveFromGroup( const AString & a_GroupName )
+void cPlayer::RemoveFromGroup( const AString & a_GroupName)
{
bool bRemoved = false;
- for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
+ for (GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr)
{
- if( (*itr)->GetName().compare(a_GroupName ) == 0 )
+ if ((*itr)->GetName().compare(a_GroupName) == 0)
{
- m_Groups.erase( itr );
+ m_Groups.erase( itr);
bRemoved = true;
break;
}
}
- if( bRemoved )
+ if (bRemoved)
{
- LOGD("Removed %s from group %s", m_PlayerName.c_str(), a_GroupName.c_str() );
+ LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str());
ResolveGroups();
ResolvePermissions();
}
else
{
- LOGWARN("Tried to remove %s from group %s but was not in that group", m_PlayerName.c_str(), a_GroupName.c_str() );
+ LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str());
}
}
@@ -1272,30 +1396,30 @@ bool cPlayer::HasPermission(const AString & a_Permission)
return true;
}
- AStringVector Split = StringSplit( a_Permission, "." );
+ AStringVector Split = StringSplit( a_Permission, ".");
PermissionMap Possibilities = m_ResolvedPermissions;
// Now search the namespaces
- while( Possibilities.begin() != Possibilities.end() )
+ while (Possibilities.begin() != Possibilities.end())
{
PermissionMap::iterator itr = Possibilities.begin();
- if( itr->second )
+ if (itr->second)
{
- AStringVector OtherSplit = StringSplit( itr->first, "." );
- if( OtherSplit.size() <= Split.size() )
+ AStringVector OtherSplit = StringSplit( itr->first, ".");
+ if (OtherSplit.size() <= Split.size())
{
unsigned int i;
- for( i = 0; i < OtherSplit.size(); ++i )
+ for (i = 0; i < OtherSplit.size(); ++i)
{
- if( OtherSplit[i].compare( Split[i] ) != 0 )
+ if (OtherSplit[i].compare( Split[i]) != 0)
{
- if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard!
+ if (OtherSplit[i].compare("*") == 0) return true; // WildCard man!! WildCard!
break;
}
}
- if( i == Split.size() ) return true;
+ if (i == Split.size()) return true;
}
}
- Possibilities.erase( itr );
+ Possibilities.erase( itr);
}
// Nothing that matched :(
@@ -1306,11 +1430,11 @@ bool cPlayer::HasPermission(const AString & a_Permission)
-bool cPlayer::IsInGroup( const AString & a_Group )
+bool cPlayer::IsInGroup( const AString & a_Group)
{
- for( GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr )
+ for (GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr)
{
- if( a_Group.compare( (*itr)->GetName().c_str() ) == 0 )
+ if (a_Group.compare( (*itr)->GetName().c_str()) == 0)
return true;
}
return false;
@@ -1322,18 +1446,18 @@ bool cPlayer::IsInGroup( const AString & a_Group )
void cPlayer::ResolvePermissions()
{
- m_ResolvedPermissions.clear(); // Start with an empty map yo~
+ m_ResolvedPermissions.clear(); // Start with an empty map
// Copy all player specific permissions into the resolved permissions map
- for( PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr )
+ for (PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr)
{
m_ResolvedPermissions[ itr->first ] = itr->second;
}
- for( GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr )
+ for (GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr)
{
const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions();
- for( cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr )
+ for (cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr)
{
m_ResolvedPermissions[ itr->first ] = itr->second;
}
@@ -1350,37 +1474,37 @@ void cPlayer::ResolveGroups()
m_ResolvedGroups.clear();
// Get a complete resolved list of all groups the player is in
- std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates
+ std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates
GroupList ToIterate;
- for( GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr )
+ for (GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr)
{
- ToIterate.push_back( *GroupItr );
+ ToIterate.push_back( *GroupItr);
}
- while( ToIterate.begin() != ToIterate.end() )
+ while (ToIterate.begin() != ToIterate.end())
{
cGroup* CurrentGroup = *ToIterate.begin();
- if( AllGroups.find( CurrentGroup ) != AllGroups.end() )
+ if (AllGroups.find( CurrentGroup) != AllGroups.end())
{
LOGWARNING("ERROR: Player \"%s\" is in the group multiple times (\"%s\"). Please fix your settings in users.ini!",
- m_PlayerName.c_str(), CurrentGroup->GetName().c_str()
+ GetName().c_str(), CurrentGroup->GetName().c_str()
);
}
else
{
AllGroups[ CurrentGroup ] = true;
- m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list
+ m_ResolvedGroups.push_back( CurrentGroup); // Add group to resolved list
const cGroup::GroupList & Inherits = CurrentGroup->GetInherits();
- for( cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr )
+ for (cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr)
{
- if( AllGroups.find( *itr ) != AllGroups.end() )
+ if (AllGroups.find( *itr) != AllGroups.end())
{
- LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", m_PlayerName.c_str(), (*itr)->GetName().c_str() );
+ LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str());
continue;
}
- ToIterate.push_back( *itr );
+ ToIterate.push_back( *itr);
}
}
- ToIterate.erase( ToIterate.begin() );
+ ToIterate.erase( ToIterate.begin());
}
}
@@ -1390,12 +1514,12 @@ void cPlayer::ResolveGroups()
AString cPlayer::GetColor(void) const
{
- if ( m_Color != '-' )
+ if (m_Color != '-')
{
- return cChatColor::Color + m_Color;
+ return cChatColor::Delimiter + m_Color;
}
- if ( m_Groups.size() < 1 )
+ if (m_Groups.size() < 1)
{
return cChatColor::White;
}
@@ -1416,7 +1540,7 @@ void cPlayer::TossEquippedItem(char a_Amount)
char NewAmount = a_Amount;
if (NewAmount > GetInventory().GetEquippedItem().m_ItemCount)
{
- NewAmount = GetInventory().GetEquippedItem().m_ItemCount; // Drop only what's there
+ NewAmount = GetInventory().GetEquippedItem().m_ItemCount; // Drop only what's there
}
GetInventory().GetHotbarGrid().ChangeSlotCount(GetInventory().GetEquippedSlotNum() /* Returns hotbar subslot, which HotbarGrid takes */, -a_Amount);
@@ -1425,10 +1549,7 @@ void cPlayer::TossEquippedItem(char a_Amount)
Drops.push_back(DroppedItem);
}
- double vX = 0, vY = 0, vZ = 0;
- EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY);
- vY = -vY * 2 + 1.f;
- m_World->SpawnItemPickups(Drops, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player
+ TossItems(Drops);
}
@@ -1444,6 +1565,7 @@ void cPlayer::TossHeldItem(char a_Amount)
char OriginalItemAmount = Item.m_ItemCount;
Item.m_ItemCount = std::min(OriginalItemAmount, a_Amount);
Drops.push_back(Item);
+
if (OriginalItemAmount > a_Amount)
{
Item.m_ItemCount = OriginalItemAmount - a_Amount;
@@ -1454,10 +1576,7 @@ void cPlayer::TossHeldItem(char a_Amount)
}
}
- double vX = 0, vY = 0, vZ = 0;
- EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY);
- vY = -vY * 2 + 1.f;
- m_World->SpawnItemPickups(Drops, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player
+ TossItems(Drops);
}
@@ -1469,41 +1588,50 @@ void cPlayer::TossPickup(const cItem & a_Item)
cItems Drops;
Drops.push_back(a_Item);
+ TossItems(Drops);
+}
+
+
+
+
+
+void cPlayer::TossItems(const cItems & a_Items)
+{
+ m_Stats.AddValue(statItemsDropped, a_Items.Size());
+
double vX = 0, vY = 0, vZ = 0;
EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY);
vY = -vY * 2 + 1.f;
- m_World->SpawnItemPickups(Drops, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player
+ m_World->SpawnItemPickups(a_Items, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player
}
-bool cPlayer::MoveToWorld(const char * a_WorldName)
+bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
{
- cWorld * World = cRoot::Get()->GetWorld(a_WorldName);
- if (World == NULL)
+ ASSERT(a_World != NULL);
+
+ if (GetWorld() == a_World)
{
- LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName);
+ // Don't move to same world
return false;
}
- eDimension OldDimension = m_World->GetDimension();
-
- // Remove all links to the old world
- m_World->RemovePlayer(this);
- m_ClientHandle->RemoveFromAllChunks();
- m_World->RemoveEntity(this);
+ // Send the respawn packet:
+ if (a_ShouldSendRespawn && (m_ClientHandle != NULL))
+ {
+ m_ClientHandle->SendRespawn(a_World->GetDimension());
+ }
- // If the dimension is different, we can send the respawn packet
- // http://wiki.vg/Protocol#0x09 says "don't send if dimension is the same" as of 2013_07_02
- m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension()));
+ // Remove player from the old world
+ SetWorldTravellingFrom(GetWorld()); // cChunk handles entity removal
+ GetWorld()->RemovePlayer(this, false);
- // Add player to all the necessary parts of the new world
- SetWorld(World);
- m_ClientHandle->StreamChunks();
- World->AddEntity(this);
- World->AddPlayer(this);
+ // Queue adding player to the new world, including all the necessary adjustments to the object
+ a_World->AddPlayer(this);
+ SetWorld(a_World); // Chunks may be streamed before cWorld::AddPlayer() sets the world to the new value
return true;
}
@@ -1520,19 +1648,19 @@ void cPlayer::LoadPermissionsFromDisk()
cIniFile IniFile;
if (IniFile.ReadFile("users.ini"))
{
- AString Groups = IniFile.GetValueSet(m_PlayerName, "Groups", "Default");
+ AString Groups = IniFile.GetValueSet(GetName(), "Groups", "Default");
AStringVector Split = StringSplitAndTrim(Groups, ",");
for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
{
if (!cRoot::Get()->GetGroupManager()->ExistsGroup(*itr))
{
- LOGWARNING("The group %s for player %s was not found!", itr->c_str(), m_PlayerName.c_str());
+ LOGWARNING("The group %s for player %s was not found!", itr->c_str(), GetName().c_str());
}
AddToGroup(*itr);
}
- AString Color = IniFile.GetValue(m_PlayerName, "Color", "-");
+ AString Color = IniFile.GetValue(GetName(), "Color", "-");
if (!Color.empty())
{
m_Color = Color[0];
@@ -1541,7 +1669,7 @@ void cPlayer::LoadPermissionsFromDisk()
else
{
cGroupManager::GenerateDefaultUsersIni(IniFile);
- IniFile.AddValue("Groups", m_PlayerName, "Default");
+ IniFile.AddValue("Groups", GetName(), "Default");
AddToGroup("Default");
}
IniFile.WriteFile("users.ini");
@@ -1551,63 +1679,102 @@ void cPlayer::LoadPermissionsFromDisk()
-bool cPlayer::LoadFromDisk()
+bool cPlayer::LoadFromDisk(cWorldPtr & a_World)
{
LoadPermissionsFromDisk();
- // Log player permissions, cause it's what the cool kids do
- LOGINFO("Player %s has permissions:", m_PlayerName.c_str() );
- for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr )
+ // Load from the UUID file:
+ if (LoadFromFile(GetUUIDFileName(m_UUID), a_World))
{
- if( itr->second ) LOG(" - %s", itr->first.c_str() );
+ return true;
+ }
+
+ // Load from the offline UUID file, if allowed:
+ AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName());
+ if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData())
+ {
+ if (LoadFromFile(GetUUIDFileName(OfflineUUID), a_World))
+ {
+ return true;
+ }
+ }
+
+ // Load from the old-style name-based file, if allowed:
+ if (cRoot::Get()->GetServer()->ShouldLoadNamedPlayerData())
+ {
+ AString OldStyleFileName = Printf("players/%s.json", GetName().c_str());
+ if (LoadFromFile(OldStyleFileName, a_World))
+ {
+ // Save in new format and remove the old file
+ if (SaveToDisk())
+ {
+ cFile::Delete(OldStyleFileName);
+ }
+ return true;
+ }
+ }
+
+ // None of the files loaded successfully
+ LOG("Player data file not found for %s (%s, offline %s), will be reset to defaults.",
+ GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str()
+ );
+
+ if (a_World == NULL)
+ {
+ a_World = cRoot::Get()->GetDefaultWorld();
}
+ return false;
+}
+
- AString SourceFile;
- Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() );
+
+
+bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
+{
+ // Load the data from the file:
cFile f;
- if (!f.Open(SourceFile, cFile::fmRead))
+ if (!f.Open(a_FileName, cFile::fmRead))
{
// This is a new player whom we haven't seen yet, bail out, let them have the defaults
return false;
}
-
AString buffer;
if (f.ReadRestOfFile(buffer) != f.GetSize())
{
- LOGWARNING("Cannot read player data from file \"%s\"", SourceFile.c_str());
+ LOGWARNING("Cannot read player data from file \"%s\"", a_FileName.c_str());
return false;
}
- f.Close(); //cool kids play nice
+ f.Close();
+ // Parse the JSON format:
Json::Value root;
Json::Reader reader;
if (!reader.parse(buffer, root, false))
{
- LOGWARNING("Cannot parse player data in file \"%s\", player will be reset", SourceFile.c_str());
+ LOGWARNING("Cannot parse player data in file \"%s\"", a_FileName.c_str());
+ return false;
}
+ // Load the player data:
Json::Value & JSON_PlayerPosition = root["position"];
if (JSON_PlayerPosition.size() == 3)
{
- SetPosX(JSON_PlayerPosition[(unsigned int)0].asDouble());
- SetPosY(JSON_PlayerPosition[(unsigned int)1].asDouble());
- SetPosZ(JSON_PlayerPosition[(unsigned int)2].asDouble());
- m_LastPosX = GetPosX();
- m_LastPosY = GetPosY();
- m_LastPosZ = GetPosZ();
- m_LastFoodPos = GetPosition();
+ SetPosX(JSON_PlayerPosition[(unsigned)0].asDouble());
+ SetPosY(JSON_PlayerPosition[(unsigned)1].asDouble());
+ SetPosZ(JSON_PlayerPosition[(unsigned)2].asDouble());
+ m_LastPos = GetPosition();
}
Json::Value & JSON_PlayerRotation = root["rotation"];
if (JSON_PlayerRotation.size() == 3)
{
- SetYaw ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());
- SetPitch ((float)JSON_PlayerRotation[(unsigned int)1].asDouble());
- SetRoll ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
+ SetYaw ((float)JSON_PlayerRotation[(unsigned)0].asDouble());
+ SetPitch ((float)JSON_PlayerRotation[(unsigned)1].asDouble());
+ SetRoll ((float)JSON_PlayerRotation[(unsigned)2].asDouble());
}
- m_Health = root.get("health", 0).asInt();
+ m_Health = root.get("health", 0).asInt();
m_AirLevel = root.get("air", MAX_AIR_LEVEL).asInt();
m_FoodLevel = root.get("food", MAX_FOOD_LEVEL).asInt();
m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
@@ -1625,11 +1792,22 @@ bool cPlayer::LoadFromDisk()
}
m_Inventory.LoadFromJson(root["inventory"]);
+ cEnderChestEntity::LoadFromJson(root["enderchestinventory"], m_EnderChestContents);
m_LoadedWorldName = root.get("world", "world").asString();
+ a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), true);
+
+ m_LastBedPos.x = root.get("SpawnX", a_World->GetSpawnX()).asInt();
+ m_LastBedPos.y = root.get("SpawnY", a_World->GetSpawnY()).asInt();
+ m_LastBedPos.z = root.get("SpawnZ", a_World->GetSpawnZ()).asInt();
+
+ // 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);
+ StatSerializer.Load();
- LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
- m_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str()
+ LOGD("Player %s was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
+ GetName().c_str(), a_FileName.c_str(), GetPosX(), GetPosY(), GetPosZ(), a_World->GetName().c_str()
);
return true;
@@ -1641,7 +1819,7 @@ bool cPlayer::LoadFromDisk()
bool cPlayer::SaveToDisk()
{
- cFile::CreateFolder(FILE_IO_PREFIX + AString("players"));
+ cFile::CreateFolder(FILE_IO_PREFIX + AString("players/") + m_UUID.substr(0, 2));
// create the JSON data
Json::Value JSON_PlayerPosition;
@@ -1657,47 +1835,77 @@ bool cPlayer::SaveToDisk()
Json::Value JSON_Inventory;
m_Inventory.SaveToJson(JSON_Inventory);
+ Json::Value JSON_EnderChestInventory;
+ cEnderChestEntity::SaveToJson(JSON_EnderChestInventory, m_EnderChestContents);
+
Json::Value root;
- root["position"] = JSON_PlayerPosition;
- root["rotation"] = JSON_PlayerRotation;
- root["inventory"] = JSON_Inventory;
- root["health"] = m_Health;
- root["xpTotal"] = m_LifetimeTotalXp;
- root["xpCurrent"] = m_CurrentXp;
- root["air"] = m_AirLevel;
- root["food"] = m_FoodLevel;
- root["foodSaturation"] = m_FoodSaturationLevel;
- root["foodTickTimer"] = m_FoodTickTimer;
- root["foodExhaustion"] = m_FoodExhaustionLevel;
- root["world"] = GetWorld()->GetName();
- root["isflying"] = IsFlying();
-
- if (m_GameMode == GetWorld()->GetGameMode())
- {
- root["gamemode"] = (int) eGameMode_NotSet;
+ root["position"] = JSON_PlayerPosition;
+ root["rotation"] = JSON_PlayerRotation;
+ root["inventory"] = JSON_Inventory;
+ root["enderchestinventory"] = JSON_EnderChestInventory;
+ root["health"] = m_Health;
+ root["xpTotal"] = m_LifetimeTotalXp;
+ root["xpCurrent"] = m_CurrentXp;
+ root["air"] = m_AirLevel;
+ root["food"] = m_FoodLevel;
+ root["foodSaturation"] = m_FoodSaturationLevel;
+ root["foodTickTimer"] = m_FoodTickTimer;
+ root["foodExhaustion"] = m_FoodExhaustionLevel;
+ root["isflying"] = IsFlying();
+ root["lastknownname"] = GetName();
+ root["SpawnX"] = GetLastBedPos().x;
+ root["SpawnY"] = GetLastBedPos().y;
+ root["SpawnZ"] = GetLastBedPos().z;
+
+ if (m_World != NULL)
+ {
+ root["world"] = m_World->GetName();
+ if (m_GameMode == m_World->GetGameMode())
+ {
+ root["gamemode"] = (int) eGameMode_NotSet;
+ }
+ else
+ {
+ root["gamemode"] = (int) m_GameMode;
+ }
}
else
{
- root["gamemode"] = (int) m_GameMode;
+ // This happens if the player is saved to new format after loading from the old format
+ root["world"] = m_LoadedWorldName;
+ root["gamemode"] = (int) eGameMode_NotSet;
}
Json::StyledWriter writer;
std::string JsonData = writer.write(root);
- AString SourceFile;
- Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() );
+ AString SourceFile = GetUUIDFileName(m_UUID);
cFile f;
if (!f.Open(SourceFile, cFile::fmWrite))
{
- LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", m_PlayerName.c_str(), SourceFile.c_str());
+ LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot open file. Player will lose their progress.",
+ GetName().c_str(), SourceFile.c_str()
+ );
return false;
}
if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size())
{
- LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str());
+ LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot save data. Player will lose their progress. ",
+ GetName().c_str(), SourceFile.c_str()
+ );
+ return false;
+ }
+
+ // 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);
+ if (!StatSerializer.Save())
+ {
+ LOGWARNING("Could not save stats for player %s", GetName().c_str());
return false;
}
+
return true;
}
@@ -1710,9 +1918,12 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
StringList Permissions;
const PermissionMap& ResolvedPermissions = m_ResolvedPermissions;
- for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr )
+ for (PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr)
{
- if( itr->second ) Permissions.push_back( itr->first );
+ if (itr->second)
+ {
+ Permissions.push_back( itr->first);
+ }
}
return Permissions;
@@ -1722,16 +1933,16 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
-void cPlayer::UseEquippedItem(void)
+void cPlayer::UseEquippedItem(int a_Amount)
{
- if (IsGameModeCreative()) // No damage in creative
+ if (IsGameModeCreative()) // No damage in creative
{
return;
}
- if (GetInventory().DamageEquippedItem())
+ if (GetInventory().DamageEquippedItem(a_Amount))
{
- m_World->BroadcastSoundEffect("random.break", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
}
}
@@ -1759,16 +1970,13 @@ void cPlayer::TickBurning(cChunk & a_Chunk)
void cPlayer::HandleFood(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Hunger
-
+
if (IsGameModeCreative())
{
// Hunger is disabled for Creative
return;
}
-
- // Remember the food level before processing, for later comparison
- int LastFoodLevel = m_FoodLevel;
-
+
// Heal or damage, based on the food level, using the m_FoodTickTimer:
if ((m_FoodLevel > 17) || (m_FoodLevel <= 0))
{
@@ -1777,11 +1985,11 @@ void cPlayer::HandleFood(void)
{
m_FoodTickTimer = 0;
- if (m_FoodLevel >= 17)
+ if ((m_FoodLevel > 17) && (GetHealth() < GetMaxHealth()))
{
// Regenerate health from food, incur 3 pts of food exhaustion:
Heal(1);
- m_FoodExhaustionLevel += 3;
+ m_FoodExhaustionLevel += 3.0;
}
else if ((m_FoodLevel <= 0) && (m_Health > 1))
{
@@ -1790,37 +1998,21 @@ void cPlayer::HandleFood(void)
}
}
}
-
- // Apply food poisoning food exhaustion:
- if (m_FoodPoisonedTicksRemaining > 0)
- {
- m_FoodPoisonedTicksRemaining--;
- m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
- }
- else
- {
- m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER); // Remove the "Hunger" effect.
- }
// Apply food exhaustion that has accumulated:
- if (m_FoodExhaustionLevel >= 4)
+ if (m_FoodExhaustionLevel >= 4.0)
{
- m_FoodExhaustionLevel -= 4;
+ m_FoodExhaustionLevel -= 4.0;
- if (m_FoodSaturationLevel >= 1)
+ if (m_FoodSaturationLevel >= 1.0)
{
- m_FoodSaturationLevel -= 1;
+ m_FoodSaturationLevel -= 1.0;
}
else
{
- m_FoodLevel = std::max(m_FoodLevel - 1, 0);
+ SetFoodLevel(m_FoodLevel - 1);
}
}
-
- if (m_FoodLevel != LastFoodLevel)
- {
- SendHealth();
- }
}
@@ -1851,24 +2043,123 @@ void cPlayer::HandleFloater()
+bool cPlayer::IsClimbing(void) const
+{
+ int PosX = POSX_TOINT;
+ int PosY = POSY_TOINT;
+ int PosZ = POSZ_TOINT;
+
+ if ((PosY < 0) || (PosY >= cChunkDef::Height))
+ {
+ return false;
+ }
+
+ BLOCKTYPE Block = m_World->GetBlock(PosX, PosY, PosZ);
+ switch (Block)
+ {
+ case E_BLOCK_LADDER:
+ case E_BLOCK_VINES:
+ {
+ return true;
+ }
+ default: return false;
+ }
+}
+
+
+
+
+
+void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
+{
+ StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5);
+
+ if (m_AttachedTo == NULL)
+ {
+ if (IsClimbing())
+ {
+ if (a_DeltaPos.y > 0.0) // Going up
+ {
+ m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5));
+ }
+ }
+ else if (IsSubmerged())
+ {
+ m_Stats.AddValue(statDistDove, Value);
+ }
+ else if (IsSwimming())
+ {
+ m_Stats.AddValue(statDistSwum, Value);
+ }
+ else if (IsOnGround())
+ {
+ m_Stats.AddValue(statDistWalked, Value);
+ }
+ else
+ {
+ if (Value >= 25) // Ignore small/slow movement
+ {
+ m_Stats.AddValue(statDistFlown, Value);
+ }
+ }
+ }
+ else
+ {
+ switch (m_AttachedTo->GetEntityType())
+ {
+ case cEntity::etMinecart: m_Stats.AddValue(statDistMinecart, Value); break;
+ case cEntity::etBoat: m_Stats.AddValue(statDistBoat, Value); break;
+ case cEntity::etMonster:
+ {
+ cMonster * Monster = (cMonster *)m_AttachedTo;
+ switch (Monster->GetMobType())
+ {
+ case cMonster::mtPig: m_Stats.AddValue(statDistPig, Value); break;
+ case cMonster::mtHorse: m_Stats.AddValue(statDistHorse, Value); break;
+ default: break;
+ }
+ break;
+ }
+ default: break;
+ }
+ }
+}
+
+
+
+
+
void cPlayer::ApplyFoodExhaustionFromMovement()
{
if (IsGameModeCreative())
{
return;
}
-
- // Calculate the distance travelled, update the last pos:
- Vector3d Movement(GetPosition() - m_LastFoodPos);
- Movement.y = 0; // Only take XZ movement into account
- m_LastFoodPos = GetPosition();
-
+
+ // If we have just teleported, apply no exhaustion
+ if (m_bIsTeleporting)
+ {
+ m_bIsTeleporting = false;
+ return;
+ }
+
// If riding anything, apply no food exhaustion
if (m_AttachedTo != NULL)
{
return;
}
+ // Process exhaustion every two ticks as that is how frequently m_LastPos is updated
+ // Otherwise, we apply exhaustion for a 'movement' every tick, one of which is an already processed value
+ if (GetWorld()->GetWorldAge() % 2 != 0)
+ {
+ return;
+ }
+
+ // Calculate the distance travelled, update the last pos:
+ Vector3d Movement(GetPosition() - m_LastPos);
+ Movement.y = 0; // Only take XZ movement into account
+
// Apply the exhaustion based on distance travelled:
double BaseExhaustion = Movement.Length();
if (IsSprinting())
@@ -1922,3 +2213,19 @@ void cPlayer::Detach()
+
+AString cPlayer::GetUUIDFileName(const AString & a_UUID)
+{
+ ASSERT(a_UUID.size() == 36);
+
+ AString res("players/");
+ res.append(a_UUID, 0, 2);
+ res.push_back('/');
+ res.append(a_UUID, 2, AString::npos);
+ res.append(".json");
+ return res;
+}
+
+
+
+
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 78d661015..65c1e33a8 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -7,6 +7,8 @@
#include "../World.h"
#include "../ClientHandle.h"
+#include "../Statistics.h"
+
@@ -39,13 +41,14 @@ public:
cPlayer(cClientHandle * a_Client, const AString & a_PlayerName);
+
virtual ~cPlayer();
virtual void SpawnOn(cClientHandle & a_Client) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); };
+ virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }
/** Returns the curently equipped weapon; empty item if none */
virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); }
@@ -114,17 +117,23 @@ public:
/** Returns true if the player is currently charging the bow */
bool IsChargingBow(void) const { return m_IsChargingBow; }
- void SetTouchGround( bool a_bTouchGround );
- inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; }
- double GetEyeHeight(void) const; // tolua_export
- Vector3d GetEyePosition(void) const; // tolua_export
+ void SetTouchGround( bool a_bTouchGround);
+ inline void SetStance( const double a_Stance) { m_Stance = a_Stance; }
+ double GetEyeHeight(void) const; // tolua_export
+ Vector3d GetEyePosition(void) const; // tolua_export
inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export
inline double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc.
- inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export
+ inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export
inline const cInventory & GetInventory(void) const { return m_Inventory; }
+
+ /** Gets the contents of the player's associated enderchest */
+ cItemGrid & GetEnderChestContents(void) { return m_EnderChestContents; }
inline const cItem & GetEquippedItem(void) const { return GetInventory().GetEquippedItem(); } // tolua_export
+ /** Returns whether the player is climbing (ladders, vines etc.) */
+ bool IsClimbing(void) const;
+
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override;
// tolua_begin
@@ -165,7 +174,7 @@ public:
AString GetIP(void) const { return m_IP; } // tolua_export
/** Returns the associated team, NULL if none */
- cTeam * GetTeam(void) { return m_Team; } // tolua_export
+ cTeam * GetTeam(void) { return m_Team; } // tolua_export
/** Sets the player team, NULL if none */
void SetTeam(cTeam * a_Team);
@@ -174,14 +183,24 @@ public:
cTeam * UpdateTeam(void);
// tolua_end
+
+ /** Return the associated statistic and achievement manager. */
+ cStatManager & GetStatManager() { return m_Stats; }
+
+ /** Awards the player an achievement.
+ If all prerequisites are met, this method will award the achievement and will broadcast a chat message.
+ If the achievement has been already awarded to the player, this method will just increment the stat counter.
+ Returns the _new_ stat value. (0 = Could not award achievement) */
+ unsigned int AwardAchievement(const eStatistic a_Ach);
void SetIP(const AString & a_IP);
// Sets the current gamemode, doesn't check validity, doesn't send update packets to client
void LoginSetGameMode(eGameMode a_GameMode);
- /** Forces the player to move in the given direction. */
- void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export
+ /** Forces the player to move in the given direction.
+ @deprecated Use SetSpeed instead. */
+ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export
/** Tries to move to a new position, with attachment-related checks (y == -999) */
void MoveTo(const Vector3d & a_NewPos); // tolua_export
@@ -220,15 +239,15 @@ public:
typedef std::list< std::string > StringList;
/** Adds a player to existing group or creates a new group when it doesn't exist */
- void AddToGroup( const AString & a_GroupName ); // tolua_export
+ void AddToGroup( const AString & a_GroupName); // tolua_export
/** Removes a player from the group, resolves permissions and group inheritance (case sensitive) */
- void RemoveFromGroup( const AString & a_GroupName ); // tolua_export
+ void RemoveFromGroup( const AString & a_GroupName); // tolua_export
- bool HasPermission( const AString & a_Permission ); // tolua_export
- const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS <<
- StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS <<
- bool IsInGroup( const AString & a_Group ); // tolua_export
+ bool HasPermission( const AString & a_Permission); // tolua_export
+ const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS <<
+ StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS <<
+ bool IsInGroup( const AString & a_Group); // tolua_export
// tolua_begin
@@ -246,13 +265,12 @@ public:
void TossPickup(const cItem & a_Item);
/** Heals the player by the specified amount of HPs (positive only); sends health update */
- void Heal(int a_Health);
+ virtual void Heal(int a_Health) override;
int GetFoodLevel (void) const { return m_FoodLevel; }
double GetFoodSaturationLevel (void) const { return m_FoodSaturationLevel; }
int GetFoodTickTimer (void) const { return m_FoodTickTimer; }
double GetFoodExhaustionLevel (void) const { return m_FoodExhaustionLevel; }
- int GetFoodPoisonedTicksRemaining(void) const { return m_FoodPoisonedTicksRemaining; }
/** Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore */
bool IsSatiated(void) const { return (m_FoodLevel >= MAX_FOOD_LEVEL); }
@@ -261,7 +279,6 @@ public:
void SetFoodSaturationLevel (double a_FoodSaturationLevel);
void SetFoodTickTimer (int a_FoodTickTimer);
void SetFoodExhaustionLevel (double a_FoodExhaustionLevel);
- void SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining);
/** Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full" */
bool Feed(int a_Food, double a_Saturation);
@@ -272,7 +289,7 @@ public:
m_FoodExhaustionLevel += a_Exhaustion;
}
- /** Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two */
+ /** Starts the food poisoning for the specified amount of ticks */
void FoodPoison(int a_NumTicks);
/** Returns true if the player is currently in the process of eating the currently equipped item */
@@ -305,29 +322,47 @@ public:
/** Aborts the current eating operation */
void AbortEating(void);
- virtual void KilledBy(cEntity * a_Killer) override;
-
- void Respawn(void); // tolua_export
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+
+ virtual void Killed(cEntity * a_Victim) override;
- void SetVisible( bool a_bVisible ); // tolua_export
- bool IsVisible(void) const { return m_bVisible; } // tolua_export
+ void Respawn(void); // tolua_export
- bool MoveToWorld(const char * a_WorldName); // tolua_export
+ void SetVisible( bool a_bVisible); // tolua_export
+ bool IsVisible(void) const { return m_bVisible; } // tolua_export
+ /** Moves the player to the specified world.
+ Returns true if successful, false on failure (world not found). */
+ virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) override;
+
+ /** Saves all player data, such as inventory, to JSON */
bool SaveToDisk(void);
- bool LoadFromDisk(void);
- void LoadPermissionsFromDisk(void); // tolua_export
+
+ typedef cWorld * cWorldPtr;
+
+ /** Loads the player data from the disk file
+ Sets a_World to the world where the player will spawn, based on the stored world name or the default world by calling LoadFromFile()
+ Returns true on success, false on failure
+ */
+ bool LoadFromDisk(cWorldPtr & a_World);
+
+ /** Loads the player data from the specified file
+ Sets a_World to the world where the player will spawn, based on the stored world name or the default world
+ Returns true on success, false on failure
+ */
+ bool LoadFromFile(const AString & a_FileName, cWorldPtr & a_World);
+
+ void LoadPermissionsFromDisk(void); // tolua_export
const AString & GetLoadedWorldName() { return m_LoadedWorldName; }
- void UseEquippedItem(void);
+ void UseEquippedItem(int a_Amount = 1);
void SendHealth(void);
void SendExperience(void);
- // In UI windows, the item that the player is dragging:
- bool IsDraggingItem(void) const { return !m_DraggingItem.IsEmpty(); }
+ /** In UI windows, get the item that the player is dragging */
cItem & GetDraggingItem(void) {return m_DraggingItem; }
// In UI windows, when inventory-painting:
@@ -375,14 +410,26 @@ public:
/** If true the player can fly even when he's not in creative. */
void SetCanFly(bool a_CanFly);
+ /** Gets the last position that the player slept in
+ This is initialised to the world spawn point if the player has not slept in a bed as of yet
+ */
+ Vector3i GetLastBedPos(void) const { return m_LastBedPos; }
+
+ /** Sets the player's bed (home) position */
+ void SetBedPos(const Vector3i & a_Pos) { m_LastBedPos = a_Pos; }
+
+ /** Update movement-related statistics. */
+ void UpdateMovementStats(const Vector3d & a_DeltaPos);
+
/** Returns wheter the player can fly or not. */
virtual bool CanFly(void) const { return m_CanFly; }
+
// tolua_end
// cEntity overrides:
virtual bool IsCrouched (void) const { return m_IsCrouched; }
virtual bool IsSprinting(void) const { return m_IsSprinting; }
- virtual bool IsRclking (void) const { return IsEating(); }
+ virtual bool IsRclking (void) const { return IsEating() || IsChargingBow(); }
virtual void Detach(void);
@@ -398,7 +445,7 @@ protected:
AString m_LoadedWorldName;
/** Xp Level stuff */
- enum
+ enum
{
XP_TO_LEVEL15 = 255,
XP_PER_LEVEL_TO15 = 17,
@@ -415,25 +462,28 @@ protected:
double m_FoodSaturationLevel;
/** Count-up to the healing or damaging action, based on m_FoodLevel */
- int m_FoodTickTimer;
+ int m_FoodTickTimer;
/** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */
double m_FoodExhaustionLevel;
- /** Number of ticks remaining for the foodpoisoning effect; zero if not foodpoisoned */
- int m_FoodPoisonedTicksRemaining;
-
- /** Last position that has been recorded for food-related processing: */
- Vector3d m_LastFoodPos;
-
float m_LastJumpHeight;
float m_LastGroundHeight;
bool m_bTouchGround;
double m_Stance;
+
+ /** Stores the player's inventory, consisting of crafting grid, hotbar, and main slots */
cInventory m_Inventory;
+
+ /** An item grid that stores the player specific enderchest contents */
+ cItemGrid m_EnderChestContents;
+
cWindow * m_CurrentWindow;
cWindow * m_InventoryWindow;
+ /** The player's last saved bed position */
+ Vector3i m_LastBedPos;
+
char m_Color;
eGameMode m_GameMode;
@@ -443,7 +493,6 @@ protected:
cItem m_DraggingItem;
long long m_LastPlayerListTime;
- static const unsigned short PLAYER_LIST_TIME_MS = 1000; // 1000 = once per second
cClientHandle * m_ClientHandle;
@@ -490,7 +539,27 @@ protected:
cTeam * m_Team;
+ cStatManager m_Stats;
+
+ /** Flag representing whether the player is currently in a bed
+ Set by a right click on unoccupied bed, unset by a time fast forward or teleport */
+ bool m_bIsInBed;
+
+ /** How long till the player's inventory will be saved
+ Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */
+ unsigned int m_TicksUntilNextSave;
+
+ /** Flag used by food handling system to determine whether a teleport has just happened
+ Will not apply food penalties if found to be true; will set to false after processing
+ */
+ bool m_bIsTeleporting;
+
+ /** The UUID of the player, as read from the ClientHandle.
+ If no ClientHandle is given, the UUID is initialized to empty. */
+ AString m_UUID;
+ /** Sets the speed and sends it to the client, so that they are forced to move so. */
+ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override;
void ResolvePermissions(void);
void ResolveGroups(void);
@@ -498,7 +567,7 @@ protected:
virtual void Destroyed(void);
/** Filters out damage for creative mode/friendly fire */
- virtual void DoTakeDamage(TakeDamageInfo & TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
/** Stops players from burning in creative mode */
virtual void TickBurning(cChunk & a_Chunk) override;
@@ -509,14 +578,16 @@ protected:
/** Called in each tick if the player is fishing to make sure the floater dissapears when the player doesn't have a fishing rod as equipped item. */
void HandleFloater(void);
+ /** Tosses a list of items. */
+ void TossItems(const cItems & a_Items);
+
/** Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block) */
void ApplyFoodExhaustionFromMovement();
- /** Flag representing whether the player is currently in a bed
- Set by a right click on unoccupied bed, unset by a time fast forward or teleport */
- bool m_bIsInBed;
-
-} ; // tolua_export
+ /** Returns the filename for the player data based on the UUID given.
+ This can be used both for online and offline UUIDs. */
+ AString GetUUIDFileName(const AString & a_UUID);
+} ; // tolua_export
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 3e48d310c..43023ec28 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -21,6 +21,9 @@
#include "FireChargeEntity.h"
#include "FireworkEntity.h"
#include "GhastFireballEntity.h"
+#include "WitherSkullEntity.h"
+#include "SplashPotionEntity.h"
+#include "Player.h"
@@ -33,7 +36,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProjectileTracerCallback:
class cProjectileTracerCallback :
@@ -67,21 +70,22 @@ protected:
if (cBlockInfo::IsSolid(a_BlockType))
{
- // The projectile hit a solid block
- // Calculate the exact hit coords:
- cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1);
- Vector3d Line1 = m_Projectile->GetPosition();
- Vector3d Line2 = Line1 + m_Projectile->GetSpeed();
- double LineCoeff = 0;
- eBlockFace Face;
- if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face))
+ // The projectile hit a solid block, calculate the exact hit coords:
+ cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1); // Bounding box of the block hit
+ const Vector3d LineStart = m_Projectile->GetPosition(); // Start point for the imaginary line that goes through the block hit
+ const Vector3d LineEnd = LineStart + m_Projectile->GetSpeed(); // End point for the imaginary line that goes through the block hit
+ double LineCoeff = 0; // Used to calculate where along the line an intersection with the bounding box occurs
+ eBlockFace Face; // Face hit
+
+ if (bb.CalcLineIntersection(LineStart, LineEnd, LineCoeff, Face))
{
- if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile))
+ Vector3d Intersection = LineStart + m_Projectile->GetSpeed() * LineCoeff; // Point where projectile goes into the hit block
+
+ if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, a_BlockX, a_BlockY, a_BlockZ, Face, &Intersection))
{
return false;
}
- Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff;
m_Projectile->OnHitSolidBlock(Intersection, Face);
return true;
}
@@ -119,7 +123,7 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProjectileEntityCollisionCallback:
class cProjectileEntityCollisionCallback :
@@ -140,12 +144,14 @@ public:
{
if (
(a_Entity == m_Projectile) || // Do not check collisions with self
- (a_Entity == m_Projectile->GetCreator()) // Do not check whoever shot the projectile
+ (a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile
)
{
- // TODO: Don't check creator only for the first 5 ticks
- // so that arrows stuck in ground and dug up can hurt the player
- return false;
+ // Don't check creator only for the first 5 ticks so that projectiles can collide with the creator
+ if (m_Projectile->GetTicksAlive() <= 5)
+ {
+ return false;
+ }
}
cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight());
@@ -161,7 +167,12 @@ public:
return false;
}
- // TODO: Some entities don't interact with the projectiles (pickups, falling blocks)
+ if (!a_Entity->IsMob() && !a_Entity->IsMinecart() && !a_Entity->IsPlayer() && !a_Entity->IsBoat())
+ {
+ // Not an entity that interacts with a projectile
+ return false;
+ }
+
if (cPluginManager::Get()->CallHookProjectileHitEntity(*m_Projectile, *a_Entity))
{
// A plugin disagreed.
@@ -203,13 +214,16 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProjectileEntity:
cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) :
super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height),
m_ProjectileKind(a_Kind),
- m_Creator(a_Creator),
+ m_CreatorData(
+ ((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1),
+ ((a_Creator != NULL) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : "")
+ ),
m_IsInGround(false)
{
}
@@ -221,7 +235,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a
cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height) :
super(etProjectile, a_Pos.x, a_Pos.y, a_Pos.z, a_Width, a_Height),
m_ProjectileKind(a_Kind),
- m_Creator(a_Creator),
+ m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : ""),
m_IsInGround(false)
{
SetSpeed(a_Speed);
@@ -233,7 +247,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Ve
-cProjectileEntity * 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)
+cProjectileEntity * 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)
{
Vector3d Speed;
if (a_Speed != NULL)
@@ -250,14 +264,17 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
case pkGhastFireball: return new cGhastFireballEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkFireCharge: return new cFireChargeEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkExpBottle: return new cExpBottleEntity (a_Creator, a_X, a_Y, a_Z, Speed);
+ case pkSplashPotion: return new cSplashPotionEntity (a_Creator, a_X, a_Y, a_Z, Speed, *a_Item);
+ case pkWitherSkull: return new cWitherSkullEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkFirework:
{
- if (a_Item.m_FireworkItem.m_Colours.empty())
+ ASSERT(a_Item != NULL);
+ if (a_Item->m_FireworkItem.m_Colours.empty())
{
return NULL;
}
- return new cFireworkEntity(a_Creator, a_X, a_Y, a_Z, a_Item);
+ return new cFireworkEntity(a_Creator, a_X, a_Y, a_Z, *a_Item);
}
}
@@ -298,9 +315,9 @@ AString cProjectileEntity::GetMCAClassName(void) const
case pkEgg: return "Egg";
case pkGhastFireball: return "Fireball";
case pkFireCharge: return "SmallFireball";
- case pkEnderPearl: return "ThrownEnderPearl";
+ case pkEnderPearl: return "ThrownEnderpearl";
case pkExpBottle: return "ThrownExpBottle";
- case pkSplashPotion: return "ThrownPotion";
+ case pkSplashPotion: return "SplashPotion";
case pkWitherSkull: return "WitherSkull";
case pkFirework: return "Firework";
case pkFishingFloat: return ""; // Unknown, perhaps MC doesn't save this?
@@ -316,8 +333,9 @@ AString cProjectileEntity::GetMCAClassName(void) const
void cProjectileEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
-
- if (GetProjectileKind() != pkArrow) // See cArrow::Tick
+
+ // TODO: see BroadcastMovementUpdate; RelativeMove packet jerkiness affects projectiles too (cause of sympton described in cArrowEntity::Tick())
+ if (GetProjectileKind() != pkArrow)
{
BroadcastMovementUpdate();
}
@@ -335,19 +353,10 @@ void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
return;
}
- Vector3d PerTickSpeed = GetSpeed() / 20;
- Vector3d Pos = GetPosition();
-
- // Trace the tick's worth of movement as a line:
- Vector3d NextPos = Pos + PerTickSpeed;
- cProjectileTracerCallback TracerCallback(this);
- if (!cLineBlockTracer::Trace(*m_World, TracerCallback, Pos, NextPos))
- {
- // Something has been hit, abort all other processing
- return;
- }
- // The tracer also checks the blocks for slowdown blocks - water and lava - and stores it for later in its SlowdownCoeff
-
+ const Vector3d PerTickSpeed = GetSpeed() / 20;
+ const Vector3d Pos = GetPosition();
+ const Vector3d NextPos = Pos + PerTickSpeed;
+
// Test for entity collisions:
cProjectileEntityCollisionCallback EntityCollisionCallback(this, Pos, NextPos);
a_Chunk.ForEachEntity(EntityCollisionCallback);
@@ -364,10 +373,19 @@ void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
HitPos.x, HitPos.y, HitPos.z,
EntityCollisionCallback.GetMinCoeff()
);
-
+
OnHitEntity(*(EntityCollisionCallback.GetHitEntity()), HitPos);
}
// TODO: Test the entities in the neighboring chunks, too
+
+ // Trace the tick's worth of movement as a line:
+ cProjectileTracerCallback TracerCallback(this);
+ if (!cLineBlockTracer::Trace(*m_World, TracerCallback, Pos, NextPos))
+ {
+ // Something has been hit, abort all other processing
+ return;
+ }
+ // The tracer also checks the blocks for slowdown blocks - water and lava - and stores it for later in its SlowdownCoeff
// Update the position:
SetPosition(NextPos);
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index ae06b072f..0ebc32f36 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -41,18 +41,18 @@ public:
// tolua_end
- CLASS_PROTODEF(cProjectileEntity);
+ CLASS_PROTODEF(cProjectileEntity)
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height);
- static 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 = NULL);
+ static 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 = NULL);
/// 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);
/// 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, const Vector3d & a_HitPos)
{
UNUSED(a_EntityHit);
UNUSED(a_HitPos);
@@ -66,8 +66,15 @@ public:
/// Returns the kind of the projectile (fast class identification)
eKind GetProjectileKind(void) const { return m_ProjectileKind; }
- /// Returns the entity who created this projectile; may be NULL
- cEntity * GetCreator(void) { return m_Creator; }
+ /** Returns the unique ID of the entity who created this projectile
+ May return an ID <0
+ */
+ int GetCreatorUniqueID(void) { return m_CreatorData.m_UniqueID; }
+
+ /** Returns the name of the player that created the projectile
+ Will be empty for non-player creators
+ */
+ AString GetCreatorName(void) const { return m_CreatorData.m_Name; }
/// Returns the string that is used as the entity type (class name) in MCA files
AString GetMCAClassName(void) const;
@@ -81,10 +88,29 @@ public:
void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; }
protected:
+
+ /** A structure that stores the Entity ID and Playername of the projectile's creator
+ Used to migitate invalid pointers caused by the creator being destroyed
+ */
+ struct CreatorData
+ {
+ CreatorData(int a_UniqueID, const AString & a_Name) :
+ m_UniqueID(a_UniqueID),
+ m_Name(a_Name)
+ {
+ }
+
+ const int m_UniqueID;
+ AString m_Name;
+ };
+
+ /** The type of projectile I am */
eKind m_ProjectileKind;
- /// The entity who has created this projectile; may be NULL (e. g. for dispensers)
- cEntity * m_Creator;
+ /** The structure for containing the entity ID and name who has created this projectile
+ The ID and/or name may be NULL (e.g. for dispensers/mobs)
+ */
+ CreatorData m_CreatorData;
/// True if the projectile has hit the ground and is stuck there
bool m_IsInGround;
@@ -94,4 +120,4 @@ protected:
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
virtual void SpawnOn(cClientHandle & a_Client) override;
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
new file mode 100644
index 000000000..fd1a0179b
--- /dev/null
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -0,0 +1,134 @@
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "SplashPotionEntity.h"
+#include "Pawn.h"
+#include "../ClientHandle.h"
+
+
+
+
+
+/// Converts an angle in radians into a byte representation used by the network protocol
+#define ANGLE_TO_PROTO(X) (Byte)(X * 255 / 360)
+
+////////////////////////////////////////////////////////////////////////////////
+// cSplashPotionEntityCallback:
+
+/** Used to distribute the splashed potion effect among nearby entities */
+class cSplashPotionCallback :
+ public cEntityCallback
+{
+public:
+ /** Creates the callback.
+ @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) :
+ m_HitPos(a_HitPos),
+ m_EntityEffectType(a_EntityEffectType),
+ m_EntityEffect(a_EntityEffect)
+ {
+ }
+
+ /** Called by cWorld::ForEachEntity(), adds the stored entity effect to the entity, if it is close enough. */
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ if (!a_Entity->IsPawn())
+ {
+ // Not an entity that can take effects
+ return false;
+ }
+
+ double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length();
+ if (SplashDistance >= 20)
+ {
+ // Too far away
+ return false;
+ }
+
+ // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
+ // TODO: better equation
+ double Reduction = -0.25 * SplashDistance + 1.0;
+ Reduction = std::max(Reduction, 0.0);
+
+ ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction);
+ return false;
+ }
+
+private:
+ const Vector3d & m_HitPos;
+ cEntityEffect::eType m_EntityEffectType;
+ const cEntityEffect & m_EntityEffect;
+};
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cSplashPotionEntity:
+
+cSplashPotionEntity::cSplashPotionEntity(
+ cEntity * a_Creator,
+ double a_X, double a_Y, double a_Z,
+ const Vector3d & a_Speed,
+ const cItem & a_Item
+) :
+ super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+ m_DestroyTimer(-1)
+{
+ SetSpeed(a_Speed);
+ m_EntityEffectType = cEntityEffect::GetPotionEffectType(a_Item.m_ItemDamage);
+ m_EntityEffect = cEntityEffect(
+ cEntityEffect::GetPotionEffectDuration(a_Item.m_ItemDamage),
+ cEntityEffect::GetPotionEffectIntensity(a_Item.m_ItemDamage)
+ );
+ m_PotionColor = cEntityEffect::GetPotionColor(a_Item.m_ItemDamage);
+}
+
+
+
+
+
+void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+{
+ Splash(a_HitPos);
+ m_DestroyTimer = 2;
+}
+
+
+
+
+
+void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+{
+ a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
+ Splash(a_HitPos);
+ m_DestroyTimer = 5;
+}
+
+
+
+
+
+void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
+{
+ cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
+ m_World->ForEachEntity(Callback);
+
+ m_World->BroadcastSoundParticleEffect(2002, (int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z), m_PotionColor);
+}
+
+
+
+
+
+void cSplashPotionEntity::SpawnOn(cClientHandle & a_Client)
+{
+ a_Client.SendSpawnObject(*this, 73, m_PotionColor, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch()));
+ a_Client.SendEntityMetadata(*this);
+}
+
+
+
+
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
new file mode 100644
index 000000000..4afc5f204
--- /dev/null
+++ b/src/Entities/SplashPotionEntity.h
@@ -0,0 +1,79 @@
+//
+// SplashPotionEntity.h
+//
+
+#pragma once
+
+#include "ProjectileEntity.h"
+#include "EntityEffect.h"
+#include "../World.h"
+#include "Entity.h"
+
+
+
+
+// tolua_begin
+
+class cSplashPotionEntity :
+ public cProjectileEntity
+{
+ typedef cProjectileEntity super;
+
+public:
+
+ // tolua_end
+
+ CLASS_PROTODEF(cSplashPotionEntity)
+
+ cSplashPotionEntity(
+ cEntity * a_Creator,
+ double a_X, double a_Y, double a_Z,
+ const Vector3d & a_Speed,
+ const cItem & a_Item
+ );
+
+ cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
+ cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
+ int GetPotionColor(void) const { return m_PotionColor; }
+
+ 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; }
+
+protected:
+
+ cEntityEffect::eType m_EntityEffectType;
+ cEntityEffect m_EntityEffect;
+ int m_PotionColor;
+
+
+ // 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 Tick (float a_Dt, cChunk & a_Chunk) override
+ {
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+ }
+
+ /** 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);
+
+ virtual void SpawnOn(cClientHandle & a_Client) override;
+
+private:
+ /** Time in ticks to wait for the hit animation to begin before destroying */
+ int m_DestroyTimer;
+} ; // tolua_export
diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp
index 02f31f5bb..53af446cc 100644
--- a/src/Entities/TNTEntity.cpp
+++ b/src/Entities/TNTEntity.cpp
@@ -30,8 +30,6 @@ cTNTEntity::cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks) :
void cTNTEntity::SpawnOn(cClientHandle & a_ClientHandle)
{
a_ClientHandle.SendSpawnObject(*this, 50, 1, 0, 0); // 50 means TNT
- m_bDirtyPosition = false;
- m_bDirtySpeed = false;
m_bDirtyOrientation = false;
m_bDirtyHead = false;
}
@@ -44,7 +42,7 @@ void cTNTEntity::Explode(void)
{
m_FuseTicks = 0;
Destroy(true);
- LOGD("BOOM at {%f,%f,%f}", GetPosX(), GetPosY(), GetPosZ());
+ LOGD("BOOM at {%f, %f, %f}", GetPosX(), GetPosY(), GetPosZ());
m_World->DoExplosionAt(4.0, GetPosX() + 0.49, GetPosY() + 0.49, GetPosZ() + 0.49, true, esPrimedTNT, this);
}
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index 116f5a8cb..48503cf76 100644
--- a/src/Entities/TNTEntity.h
+++ b/src/Entities/TNTEntity.h
@@ -14,7 +14,7 @@ class cTNTEntity :
public:
// tolua_end
- CLASS_PROTODEF(cTNTEntity);
+ 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);
@@ -38,7 +38,7 @@ public:
protected:
int m_FuseTicks; ///< How much ticks is left, while the tnt will explode
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp
index 224019091..456083108 100644
--- a/src/Entities/ThrownEggEntity.cpp
+++ b/src/Entities/ThrownEggEntity.cpp
@@ -8,7 +8,8 @@
cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+ super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+ m_DestroyTimer(-1)
{
SetSpeed(a_Speed);
}
@@ -21,7 +22,7 @@ void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H
{
TrySpawnChicken(a_HitPos);
- Destroy();
+ m_DestroyTimer = 2;
}
@@ -36,7 +37,7 @@ void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
TrySpawnChicken(a_HitPos);
a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
- Destroy(true);
+ m_DestroyTimer = 5;
}
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index 5ba8f051b..a0b7d5340 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cThrownEggEntity);
+ CLASS_PROTODEF(cThrownEggEntity)
cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
@@ -30,8 +30,29 @@ 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 Tick (float a_Dt, cChunk & a_Chunk) override
+ {
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+ }
// Randomly decides whether to spawn a chicken where the egg lands.
void TrySpawnChicken(const Vector3d & a_HitPos);
+
+private:
+
+ /** Time in ticks to wait for the hit animation to begin before destroying */
+ int m_DestroyTimer;
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index c37161145..c7407e6ae 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -1,13 +1,15 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "ThrownEnderPearlEntity.h"
+#include "Player.h"
cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+ super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+ m_DestroyTimer(-1)
{
SetSpeed(a_Speed);
}
@@ -21,7 +23,7 @@ void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockF
// TODO: Tweak a_HitPos based on block face.
TeleportCreator(a_HitPos);
- Destroy();
+ m_DestroyTimer = 2;
}
@@ -36,7 +38,7 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
TeleportCreator(a_HitPos);
a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
- Destroy(true);
+ m_DestroyTimer = 5;
}
@@ -45,10 +47,34 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
{
- // Teleport the creator here, make them take 5 damage:
- if (m_Creator != NULL)
+ if (m_CreatorData.m_Name.empty())
{
- m_Creator->TeleportToCoords(a_HitPos.x + 0.5, a_HitPos.y + 1.7, a_HitPos.z + 0.5);
- m_Creator->TakeDamage(dtEnderPearl, this, 5, 0);
+ return;
}
+
+ class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback
+ {
+ public:
+ cProjectileCreatorCallbackForPlayers(cEntity * a_Attacker, Vector3i a_HitPos) :
+ m_Attacker(a_Attacker),
+ m_HitPos(a_HitPos)
+ {
+ }
+
+ virtual bool Item(cPlayer * a_Entity) override
+ {
+ // Teleport the creator here, make them take 5 damage:
+ a_Entity->TeleportToCoords(m_HitPos.x, m_HitPos.y + 0.2, m_HitPos.z);
+ a_Entity->TakeDamage(dtEnderPearl, m_Attacker, 5, 0);
+ return true;
+ }
+
+ private:
+
+ cEntity * m_Attacker;
+ Vector3i m_HitPos;
+ };
+
+ cProjectileCreatorCallbackForPlayers PCCFP(this, a_HitPos);
+ GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP);
}
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index ddee5babe..436450013 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cThrownEnderPearlEntity);
+ CLASS_PROTODEF(cThrownEnderPearlEntity)
cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
@@ -30,8 +30,29 @@ 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;
-
- // Teleports the creator where the ender pearl lands.
+ virtual void Tick (float a_Dt, cChunk & a_Chunk) override
+ {
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+ }
+
+ /** Teleports the creator where the ender pearl lands */
void TeleportCreator(const Vector3d & a_HitPos);
+
+private:
+
+ /** Time in ticks to wait for the hit animation to begin before destroying */
+ int m_DestroyTimer;
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp
index 427f630f7..d94e75898 100644
--- a/src/Entities/ThrownSnowballEntity.cpp
+++ b/src/Entities/ThrownSnowballEntity.cpp
@@ -8,7 +8,8 @@
cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+ super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+ m_DestroyTimer(-1)
{
SetSpeed(a_Speed);
}
@@ -19,7 +20,7 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do
void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
- Destroy();
+ m_DestroyTimer = 2;
}
@@ -36,13 +37,9 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
{
TotalDamage = 3;
}
- else if (MobType == cMonster::mtEnderDragon)
- {
- TotalDamage = 1;
- }
}
// TODO: If entity is Ender Crystal, destroy it
a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
- Destroy(true);
+ m_DestroyTimer = 5;
}
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index a09512e37..8d195ced1 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cThrownSnowballEntity);
+ CLASS_PROTODEF(cThrownSnowballEntity)
cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
@@ -30,5 +30,26 @@ 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 Tick (float a_Dt, cChunk & a_Chunk) override
+ {
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+ }
+
+private:
+
+ /** Time in ticks to wait for the hit animation to begin before destroying */
+ int m_DestroyTimer;
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp
new file mode 100644
index 000000000..a7e774bba
--- /dev/null
+++ b/src/Entities/WitherSkullEntity.cpp
@@ -0,0 +1,49 @@
+
+// WitherSkullEntity.cpp
+
+// Implements the cWitherSkullEntity class representing the entity used by both blue and black wither skulls
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "WitherSkullEntity.h"
+#include "../World.h"
+
+
+
+
+
+cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
+ super(pkWitherSkull, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+{
+ SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cWitherSkullEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+{
+ // TODO: Explode
+ // TODO: Apply wither effect to entities nearby
+ Destroy();
+}
+
+
+
+
+
+void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+{
+ // TODO: If entity is Ender Crystal, destroy it
+ a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
+
+ // TODO: Explode
+ // TODO: Apply wither effect to entity and others nearby
+
+ Destroy(true);
+}
+
+
+
+
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
new file mode 100644
index 000000000..c59acd807
--- /dev/null
+++ b/src/Entities/WitherSkullEntity.h
@@ -0,0 +1,35 @@
+
+// WitherSkullEntity.h
+
+// Declares the cWitherSkullEntity class representing the entity used by both blue and black wither skulls
+
+#pragma once
+
+#include "ProjectileEntity.h"
+
+
+
+
+
+// tolua_begin
+
+class cWitherSkullEntity :
+public cProjectileEntity
+{
+ typedef cProjectileEntity super;
+
+public:
+
+ // tolua_end
+
+ CLASS_PROTODEF(cWitherSkullEntity)
+
+ cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const 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;
+
+} ; // tolua_export
diff --git a/src/FastRandom.cpp b/src/FastRandom.cpp
index c45261947..42bf5f3f9 100644
--- a/src/FastRandom.cpp
+++ b/src/FastRandom.cpp
@@ -91,7 +91,8 @@ int cFastRandom::m_SeedCounter = 0;
cFastRandom::cFastRandom(void) :
- m_Seed(m_SeedCounter++)
+ m_Seed(m_SeedCounter++),
+ m_Counter(0)
{
}
diff --git a/src/FastRandom.h b/src/FastRandom.h
index 567198a31..2061a3958 100644
--- a/src/FastRandom.h
+++ b/src/FastRandom.h
@@ -44,6 +44,9 @@ public:
/// Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M; a_Salt is additional source of randomness
float NextFloat(float a_Range, int a_Salt);
+ /** Returns a random float between 0 and 1. */
+ float NextFloat(void) { return NextFloat(1); };
+
/** Returns a random int in the range [a_Begin .. a_End] */
int GenerateRandomInteger(int a_Begin, int a_End);
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index bd7fd8079..ab772e97b 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -5,7 +5,8 @@
#include "Item.h"
#include <fstream>
-#include <sstream>
+
+#define FURNACE_RECIPE_FILE "furnace.txt"
@@ -29,7 +30,7 @@ struct cFurnaceRecipe::sFurnaceRecipeState
cFurnaceRecipe::cFurnaceRecipe()
- : m_pState( new sFurnaceRecipeState )
+ : m_pState( new sFurnaceRecipeState)
{
ReloadRecipes();
}
@@ -42,6 +43,7 @@ cFurnaceRecipe::~cFurnaceRecipe()
{
ClearRecipes();
delete m_pState;
+ m_pState = NULL;
}
@@ -53,128 +55,207 @@ void cFurnaceRecipe::ReloadRecipes(void)
ClearRecipes();
LOGD("Loading furnace recipes...");
- std::ifstream f;
- char a_File[] = "furnace.txt";
- f.open(a_File, std::ios::in);
-
+ std::ifstream f(FURNACE_RECIPE_FILE, std::ios::in);
if (!f.good())
{
- f.close();
- LOG("Could not open the furnace recipes file \"%s\"", a_File);
+ LOG("Could not open the furnace recipes file \"%s\". No furnace recipes are available.", FURNACE_RECIPE_FILE);
return;
}
+
+ unsigned int LineNum = 0;
+ AString ParsingLine;
- // TODO: Replace this messy parse with a high-level-structured one (ReadLine / ProcessLine)
- bool bSyntaxError = false;
- while (f.good())
+ while (std::getline(f, ParsingLine))
{
- char c;
+ LineNum++;
+ ParsingLine.erase(std::remove_if(ParsingLine.begin(), ParsingLine.end(), isspace), ParsingLine.end()); // Remove ALL whitespace from the line
+ if (ParsingLine.empty())
+ {
+ continue;
+ }
- //////////////////////////////////////////////////////////////////////////
- // comments
- f >> c;
- f.unget();
- if( c == '#' )
+ switch (ParsingLine[0])
{
- while( f.good() && c != '\n' )
+ case '#':
{
- f.get( c );
+ // Comment
+ break;
}
- continue;
- }
+
+ case '!':
+ {
+ AddFuelFromLine(ParsingLine, LineNum);
+ break;
+ }
+
+ default:
+ {
+ AddRecipeFromLine(ParsingLine, LineNum);
+ break;
+ }
+ } // switch (ParsingLine[0])
+ } // while (getline(ParsingLine))
+
+ LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
+}
+
+
+
+
+
+void cFurnaceRecipe::AddFuelFromLine(const AString & a_Line, int a_LineNum)
+{
+ // Fuel
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
+ AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang)
+
+ if (
+ !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "=", a_Line, a_LineNum, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "0123456789", a_Line, a_LineNum, IBurnTime, true) // Read item burn time - last value
+ )
+ {
+ return;
+ }
+
+ // Add to fuel list:
+ Fuel F;
+ F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
+ F.BurnTime = IBurnTime;
+ m_pState->Fuel.push_back(F);
+}
+
+
+
+
+
+void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, int a_LineNum)
+{
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
+ int OItemID = 0, OItemCount = 0, OItemHealth = 0;
+ AString::size_type BeginPos = 0; // Begin at start of line
+
+ if (
+ !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "@", a_Line, a_LineNum, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "=", a_Line, a_LineNum, IBurnTime) || // Read item burn time
+ !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, OItemID) || // Read result ID
+ !ReadOptionalNumbers(BeginPos, ":", "012456789", a_Line, a_LineNum, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value
+ )
+ {
+ return;
+ }
+
+ // Add to recipe list
+ Recipe R;
+ R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
+ R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth);
+ R.CookTime = IBurnTime;
+ m_pState->Recipes.push_back(R);
+}
+
+
+
- //////////////////////////////////////////////////////////////////////////
- // Line breaks
- f.get( c );
- while( f.good() && ( c == '\n' || c == '\r' ) ) { f.get( c ); }
- if (f.eof())
+void cFurnaceRecipe::PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing)
+{
+ LOGWARN("Error parsing furnace recipes at line %i pos " SIZE_T_FMT ": missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str());
+}
+
+
+
+
+
+bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, unsigned int a_Line, int & a_Value, bool a_IsLastValue)
+{
+ // TODO: replace atoi with std::stoi
+ AString::size_type End;
+ if (a_IsLastValue)
+ {
+ End = a_Text.find_first_not_of(a_Delimiter, a_Begin);
+ }
+ else
+ {
+ End = a_Text.find_first_of(a_Delimiter, a_Begin);
+ if (End == AString::npos)
{
- break;
+ PrintParseError(a_Line, a_Begin, a_Delimiter);
+ return false;
}
- f.unget();
+ }
+
+ // stoi won't throw an exception if the string is alphanumeric, we should check for this
+ if (!DoesStringContainOnlyNumbers(a_Text.substr(a_Begin, End - a_Begin)))
+ {
+ PrintParseError(a_Line, a_Begin, "number");
+ return false;
+ }
+ a_Value = atoi(a_Text.substr(a_Begin, End - a_Begin).c_str());
+
+ a_Begin = End + 1; // Jump over delimiter
+ return true;
+}
+
+
+
+
- //////////////////////////////////////////////////////////////////////////
- // Check for fuel
- f >> c;
- if( c == '!' ) // It's fuel :)
+bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue)
+{
+ // TODO: replace atoi with std::stoi
+ AString::size_type End, Begin = a_Begin;
+
+ End = a_Text.find_first_of(a_DelimiterOne, Begin);
+ if (End != AString::npos)
+ {
+ if (DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin)))
{
- // Read item
- int IItemID = 0, IItemCount = 0, IItemHealth = 0;
- f >> IItemID;
- f >> c; if( c != ':' ) { bSyntaxError = true; break; }
- f >> IItemCount;
-
- // Optional health
- f >> c;
- if( c != ':' )
- f.unget();
+ a_ValueOne = std::atoi(a_Text.substr(Begin, End - Begin).c_str());
+ Begin = End + 1;
+
+ if (a_IsLastValue)
+ {
+ End = a_Text.find_first_not_of(a_DelimiterTwo, Begin);
+ }
else
{
- f >> IItemHealth;
+ End = a_Text.find_first_of(a_DelimiterTwo, Begin);
+ if (End == AString::npos)
+ {
+ PrintParseError(a_Line, Begin, a_DelimiterTwo);
+ return false;
+ }
}
- // Burn time
- int BurnTime;
- f >> c; if( c != '=' ) { bSyntaxError = true; break; }
- f >> BurnTime;
+ // stoi won't throw an exception if the string is alphanumeric, we should check for this
+ if (!DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin)))
+ {
+ PrintParseError(a_Line, Begin, "number");
+ return false;
+ }
+ a_ValueTwo = atoi(a_Text.substr(Begin, End - Begin).c_str());
- // Add to fuel list
- Fuel F;
- F.In = new cItem( (ENUM_ITEM_ID) IItemID, (char)IItemCount, (short)IItemHealth );
- F.BurnTime = BurnTime;
- m_pState->Fuel.push_back( F );
- continue;
+ a_Begin = End + 1; // Jump over delimiter
+ return true;
}
- f.unget();
-
- //////////////////////////////////////////////////////////////////////////
- // Read items
- int IItemID = 0, IItemCount = 0, IItemHealth = 0;
- f >> IItemID;
- f >> c; if( c != ':' ) { bSyntaxError = true; break; }
- f >> IItemCount;
-
- // Optional health
- f >> c;
- if( c != ':' )
- f.unget();
else
{
- f >> IItemHealth;
+ return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_Line, a_ValueOne, a_IsLastValue);
}
+ }
+
+ return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_Line, a_ValueOne, a_IsLastValue);
+}
- int CookTime;
- f >> c; if( c != '@' ) { bSyntaxError = true; break; }
- f >> CookTime;
- int OItemID = 0, OItemCount = 0, OItemHealth = 0;
- f >> c; if( c != '=' ) { bSyntaxError = true; break; }
- f >> OItemID;
- f >> c; if( c != ':' ) { bSyntaxError = true; break; }
- f >> OItemCount;
- // Optional health
- f >> c;
- if( c != ':' )
- f.unget();
- else
- {
- f >> OItemHealth;
- }
- // Add to recipe list
- Recipe R;
- R.In = new cItem( (ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth );
- R.Out = new cItem( (ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth );
- R.CookTime = CookTime;
- m_pState->Recipes.push_back( R );
- }
- if (bSyntaxError)
- {
- LOGERROR("ERROR: FurnaceRecipe, syntax error" );
- }
- LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
+
+bool cFurnaceRecipe::DoesStringContainOnlyNumbers(const AString & a_String)
+{
+ // TODO: replace this with std::all_of(a_String.begin(), a_String.end(), isdigit)
+ return (a_String.find_first_not_of("0123456789") == AString::npos);
}
@@ -187,7 +268,9 @@ void cFurnaceRecipe::ClearRecipes(void)
{
Recipe R = *itr;
delete R.In;
+ R.In = NULL;
delete R.Out;
+ R.Out = NULL;
}
m_pState->Recipes.clear();
@@ -195,6 +278,7 @@ void cFurnaceRecipe::ClearRecipes(void)
{
Fuel F = *itr;
delete F.In;
+ F.In = NULL;
}
m_pState->Fuel.clear();
}
diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h
index 2f91e9bcb..77ed35a57 100644
--- a/src/FurnaceRecipe.h
+++ b/src/FurnaceRecipe.h
@@ -41,6 +41,36 @@ public:
private:
void ClearRecipes(void);
+ /** Parses the fuel contained in the line, adds it to m_pState's fuels.
+ Logs a warning to the console on input error. */
+ void AddFuelFromLine(const AString & a_Line, int a_LineNum);
+
+ /** Parses the recipe contained in the line, adds it to m_pState's recipes.
+ Logs a warning to the console on input error. */
+ void AddRecipeFromLine(const AString & a_Line, int a_LineNum);
+
+ /** Calls LOGWARN with the line, position, and error */
+ static void PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing);
+
+ /** Reads a number from a string given, starting at a given position and ending at a delimiter given
+ Updates beginning position to the delimiter found + 1, and updates the value to the one read
+ If it encounters a substring that is not fully numeric, it will call SetParseError() and return false; the caller should abort processing
+ Otherwise, the function will return true
+ */
+ static bool ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, unsigned int a_Line, int & a_Value, bool a_IsLastValue = false);
+
+ /** Reads two numbers from a string given, starting at a given position and ending at the first delimiter given, then again (with an updated position) until the second delimiter given
+ Updates beginning position to the second delimiter found + 1, and updates the values to the ones read
+ If it encounters a substring that is not fully numeric whilst reading the second value, it will call SetParseError() and return false; the caller should abort processing
+ If this happens whilst reading the first value, it will call ReadMandatoryNumber() with the appropriate position, as this may legitimately occur with the optional value and AString::find_first_of finding the incorrect delimiter. It will return the result of ReadMandatoryNumber()
+ True will be returned definitively for an optional value that is valid
+ */
+ static bool ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue = false);
+
+ /** Uses std::all_of to determine if a string contains only digits */
+ static bool DoesStringContainOnlyNumbers(const AString & a_String);
+
+
struct sFurnaceRecipeState;
sFurnaceRecipeState * m_pState;
};
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index 32a687201..8fad9f5c9 100644
--- a/src/Generating/BioGen.cpp
+++ b/src/Generating/BioGen.cpp
@@ -12,7 +12,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBiomeGen:
cBiomeGen * cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault)
@@ -78,7 +78,7 @@ cBiomeGen * cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBioGenConstant:
void cBioGenConstant::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
@@ -95,7 +95,7 @@ void cBioGenConstant::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap
void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile)
{
- AString Biome = a_IniFile.GetValueSet("Generator", "ConstantBiome", "Plains");
+ AString Biome = a_IniFile.GetValueSet("Generator", "ConstantBiome", "");
m_Biome = StringToBiome(Biome);
if (m_Biome == biInvalidBiome)
{
@@ -108,7 +108,7 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBioGenCache:
cBioGenCache::cBioGenCache(cBiomeGen * a_BioGenToCache, int a_CacheSize) :
@@ -135,7 +135,9 @@ cBioGenCache::cBioGenCache(cBiomeGen * a_BioGenToCache, int a_CacheSize) :
cBioGenCache::~cBioGenCache()
{
delete[] m_CacheData;
+ m_CacheData = NULL;
delete[] m_CacheOrder;
+ m_CacheOrder = NULL;
}
@@ -207,12 +209,12 @@ void cBioGenCache::InitializeBiomeGen(cIniFile & a_IniFile)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBiomeGenList:
void cBiomeGenList::InitializeBiomes(const AString & a_Biomes)
{
- AStringVector Split = StringSplit(a_Biomes, ",");
+ AStringVector Split = StringSplitAndTrim(a_Biomes, ",");
// Convert each string in the list into biome:
for (AStringVector::const_iterator itr = Split.begin(); itr != Split.end(); ++itr)
@@ -288,7 +290,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBioGenCheckerboard:
void cBioGenCheckerboard::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
@@ -322,7 +324,7 @@ void cBioGenCheckerboard::InitializeBiomeGen(cIniFile & a_IniFile)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBioGenVoronoi :
void cBioGenVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
@@ -355,7 +357,7 @@ void cBioGenVoronoi::InitializeBiomeGen(cIniFile & a_IniFile)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBioGenDistortedVoronoi:
void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
@@ -416,7 +418,7 @@ void cBioGenDistortedVoronoi::Distort(int a_BlockX, int a_BlockZ, int & a_Distor
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBioGenMultiStepMap :
cBioGenMultiStepMap::cBioGenMultiStepMap(int a_Seed) :
@@ -737,7 +739,7 @@ void cBioGenMultiStepMap::FreezeWaterBiomes(cChunkDef::BiomeMap & a_BiomeMap, co
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBioGenTwoLevel:
cBioGenTwoLevel::cBioGenTwoLevel(int a_Seed) :
@@ -745,7 +747,12 @@ cBioGenTwoLevel::cBioGenTwoLevel(int a_Seed) :
m_VoronoiSmall(a_Seed + 2000),
m_DistortX(a_Seed + 3000),
m_DistortZ(a_Seed + 4000),
- m_Noise(a_Seed + 5000)
+ m_Noise1(a_Seed + 5001),
+ m_Noise2(a_Seed + 5002),
+ m_Noise3(a_Seed + 5003),
+ m_Noise4(a_Seed + 5004),
+ m_Noise5(a_Seed + 5005),
+ m_Noise6(a_Seed + 5006)
{
}
@@ -767,12 +774,12 @@ void cBioGenTwoLevel::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap
int BlockZ = BaseZ + z * 4;
float BlockXF = (float)(16 * BlockX) / 128;
float BlockZF = (float)(16 * BlockZ) / 128;
- double NoiseX = m_Noise.CubicNoise3D(BlockXF / 16, BlockZF / 16, 1000);
- NoiseX += 0.5 * m_Noise.CubicNoise3D(BlockXF / 8, BlockZF / 8, 2000);
- NoiseX += 0.08 * m_Noise.CubicNoise3D(BlockXF, BlockZF, 3000);
- double NoiseZ = m_Noise.CubicNoise3D(BlockXF / 16, BlockZF / 16, 4000);
- NoiseZ += 0.5 * m_Noise.CubicNoise3D(BlockXF / 8, BlockZF / 8, 5000);
- NoiseZ += 0.08 * m_Noise.CubicNoise3D(BlockXF, BlockZF, 6000);
+ double NoiseX = m_Noise1.CubicNoise2D(BlockXF / 16, BlockZF / 16);
+ NoiseX += 0.5 * m_Noise2.CubicNoise2D(BlockXF / 8, BlockZF / 8);
+ NoiseX += 0.08 * m_Noise3.CubicNoise2D(BlockXF, BlockZF);
+ double NoiseZ = m_Noise4.CubicNoise2D(BlockXF / 16, BlockZF / 16);
+ NoiseZ += 0.5 * m_Noise5.CubicNoise2D(BlockXF / 8, BlockZF / 8);
+ NoiseZ += 0.08 * m_Noise6.CubicNoise2D(BlockXF, BlockZF);
DistortX[4 * x][4 * z] = BlockX + (int)(64 * NoiseX);
DistortZ[4 * x][4 * z] = BlockZ + (int)(64 * NoiseZ);
@@ -786,8 +793,8 @@ void cBioGenTwoLevel::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap
{
for (int x = 0; x < cChunkDef::Width; x++)
{
- int BiomeGroup = m_VoronoiLarge.GetValueAt(DistortX[x][z], DistortZ[x][z]) / 7;
int MinDist1, MinDist2;
+ int BiomeGroup = m_VoronoiLarge.GetValueAt(DistortX[x][z], DistortZ[x][z], MinDist1, MinDist2) / 7;
int BiomeIdx = m_VoronoiSmall.GetValueAt(DistortX[x][z], DistortZ[x][z], MinDist1, MinDist2) / 11;
cChunkDef::SetBiome(a_BiomeMap, x, z, SelectBiome(BiomeGroup, BiomeIdx, (MinDist1 < MinDist2 / 4) ? 0 : 1));
}
diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h
index 8bd460d8f..227ec97d7 100644
--- a/src/Generating/BioGen.h
+++ b/src/Generating/BioGen.h
@@ -261,7 +261,12 @@ protected:
/// The noise used to distort the inupt Z coord
cPerlinNoise m_DistortZ;
- cNoise m_Noise;
+ cNoise m_Noise1;
+ cNoise m_Noise2;
+ cNoise m_Noise3;
+ cNoise m_Noise4;
+ cNoise m_Noise5;
+ cNoise m_Noise6;
// cBiomeGen overrides:
diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt
index 3dacb5066..58df9d421 100644
--- a/src/Generating/CMakeLists.txt
+++ b/src/Generating/CMakeLists.txt
@@ -4,11 +4,64 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ BioGen.cpp
+ Caves.cpp
+ ChunkDesc.cpp
+ ChunkGenerator.cpp
+ CompoGen.cpp
+ ComposableGenerator.cpp
+ DistortedHeightmap.cpp
+ EndGen.cpp
+ FinishGen.cpp
+ GridStructGen.cpp
+ HeiGen.cpp
+ MineShafts.cpp
+ NetherFortGen.cpp
+ Noise3DGenerator.cpp
+ POCPieceGenerator.cpp
+ PieceGenerator.cpp
+ Prefab.cpp
+ PrefabPiecePool.cpp
+ RainbowRoadsGen.cpp
+ Ravines.cpp
+ RoughRavines.cpp
+ StructGen.cpp
+ TestRailsGen.cpp
+ Trees.cpp
+ UnderwaterBaseGen.cpp
+ VillageGen.cpp)
-add_library(Generating ${SOURCE})
+SET (HDRS
+ BioGen.h
+ Caves.h
+ ChunkDesc.h
+ ChunkGenerator.h
+ CompoGen.h
+ ComposableGenerator.h
+ DistortedHeightmap.h
+ EndGen.h
+ FinishGen.h
+ GridStructGen.h
+ HeiGen.h
+ MineShafts.h
+ NetherFortGen.h
+ Noise3DGenerator.h
+ POCPieceGenerator.h
+ PieceGenerator.h
+ Prefab.h
+ PrefabPiecePool.h
+ RainbowRoadsGen.h
+ Ravines.h
+ RoughRavines.h
+ StructGen.h
+ TestRailsGen.h
+ Trees.h
+ UnderwaterBaseGen.h
+ VillageGen.h)
-target_link_libraries(Generating OSSupport iniFile Blocks)
+if(NOT MSVC)
+ add_library(Generating ${SRCS} ${HDRS})
+
+ target_link_libraries(Generating OSSupport iniFile Blocks)
+endif()
diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp
index 5cad11d2a..3b71efb57 100644
--- a/src/Generating/Caves.cpp
+++ b/src/Generating/Caves.cpp
@@ -35,13 +35,6 @@ reduced in complexity in order for this generator to be useful, so the caves' sh
-/// How many nests in each direction are generated for a given chunk. Must be an even number
-#define NEIGHBORHOOD_SIZE 8
-
-
-
-
-
const int MIN_RADIUS = 3;
const int MAX_RADIUS = 8;
@@ -122,27 +115,19 @@ typedef std::vector<cCaveTunnel *> cCaveTunnels;
/// A collection of connected tunnels, possibly branching.
-class cStructGenWormNestCaves::cCaveSystem
+class cStructGenWormNestCaves::cCaveSystem :
+ public cGridStructGen::cStructure
{
+ typedef cGridStructGen::cStructure super;
+
public:
// The generating block position; is read directly in cStructGenWormNestCaves::GetCavesForChunk()
int m_BlockX;
int m_BlockZ;
- cCaveSystem(int a_BlockX, int a_BlockZ, int a_MaxOffset, int a_Size, cNoise & a_Noise);
+ cCaveSystem(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise);
~cCaveSystem();
- /// Carves the cave system into the chunk specified
- void ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
- cChunkDef::HeightMap & a_HeightMap
- );
-
- #ifdef _DEBUG
- AString ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const;
- #endif // _DEBUG
-
protected:
int m_Size;
cCaveTunnels m_Tunnels;
@@ -157,13 +142,16 @@ protected:
/// Returns a radius based on the location provided.
int GetRadius(cNoise & a_Noise, int a_OriginX, int a_OriginY, int a_OriginZ);
+
+ // cGridStructGen::cStructure overrides:
+ virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override;
} ;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCaveTunnel:
cCaveTunnel::cCaveTunnel(
@@ -239,9 +227,15 @@ void cCaveTunnel::Randomize(cNoise & a_Noise)
bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst)
{
+ if (a_Src.size() < 2)
+ {
+ // There are no midpoints, nothing to smooth
+ return true;
+ }
+
// Smoothing: for each line segment, add points on its 1/4 lengths
bool res = false;
- int Num = a_Src.size() - 2; // this many intermediary points
+ size_t Num = a_Src.size() - 2; // this many intermediary points
a_Dst.clear();
a_Dst.reserve(Num * 2 + 2);
cCaveDefPoints::const_iterator itr = a_Src.begin() + 1;
@@ -251,7 +245,7 @@ bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints &
int PrevY = Source.m_BlockY;
int PrevZ = Source.m_BlockZ;
int PrevR = Source.m_Radius;
- for (int i = 0; i <= Num; ++i, ++itr)
+ for (size_t i = 0; i <= Num; ++i, ++itr)
{
int dx = itr->m_BlockX - PrevX;
int dy = itr->m_BlockY - PrevY;
@@ -561,14 +555,14 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons
{
AString SVG;
SVG.reserve(m_Points.size() * 20 + 200);
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#%06x;stroke-width:1px;\"\nd=\"", a_Color);
- char Prefix = 'M'; // The first point needs "M" prefix, all the others need "L"
- for (cCaveDefPoints::const_iterator itr = m_Points.begin(); itr != m_Points.end(); ++itr)
- {
- AppendPrintf(SVG, "%c %d,%d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ);
+ AppendPrintf(SVG, "<path style=\"fill:none;stroke:#%06x;stroke-width:1px;\"\nd=\"", a_Color);
+ char Prefix = 'M'; // The first point needs "M" prefix, all the others need "L"
+ for (cCaveDefPoints::const_iterator itr = m_Points.begin(); itr != m_Points.end(); ++itr)
+ {
+ AppendPrintf(SVG, "%c %d, %d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ);
Prefix = 'L';
- }
- SVG.append("\"/>\n");
+ }
+ SVG.append("\"/>\n");
return SVG;
}
#endif // _DEBUG
@@ -577,20 +571,19 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenWormNestCaves::cCaveSystem:
-cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_BlockX, int a_BlockZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) :
- m_BlockX(a_BlockX),
- m_BlockZ(a_BlockZ),
+cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) :
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
m_Size(a_Size)
{
- int Num = 1 + a_Noise.IntNoise2DInt(a_BlockX, a_BlockZ) % 3;
+ int Num = 1 + a_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) % 3;
for (int i = 0; i < Num; i++)
{
- int OriginX = a_BlockX + (a_Noise.IntNoise3DInt(13 * a_BlockX, 17 * a_BlockZ, 11 * i) / 19) % a_MaxOffset;
- int OriginZ = a_BlockZ + (a_Noise.IntNoise3DInt(17 * a_BlockX, 13 * a_BlockZ, 11 * i) / 23) % a_MaxOffset;
- int OriginY = 20 + (a_Noise.IntNoise3DInt(19 * a_BlockX, 13 * a_BlockZ, 11 * i) / 17) % 20;
+ int OriginX = a_OriginX + (a_Noise.IntNoise3DInt(13 * a_OriginX, 17 * a_OriginZ, 11 * i) / 19) % a_MaxOffset;
+ int OriginZ = a_OriginZ + (a_Noise.IntNoise3DInt(17 * a_OriginX, 13 * a_OriginZ, 11 * i) / 23) % a_MaxOffset;
+ int OriginY = 20 + (a_Noise.IntNoise3DInt(19 * a_OriginX, 13 * a_OriginZ, 11 * i) / 17) % 20;
// Generate three branches from the origin point:
// The tunnels generated depend on X, Y, Z and Branches,
@@ -616,64 +609,17 @@ cStructGenWormNestCaves::cCaveSystem::~cCaveSystem()
-void cStructGenWormNestCaves::cCaveSystem::ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
- cChunkDef::HeightMap & a_HeightMap
-)
+void cStructGenWormNestCaves::cCaveSystem::DrawIntoChunk(cChunkDesc & a_ChunkDesc)
{
+ int ChunkX = a_ChunkDesc.GetChunkX();
+ int ChunkZ = a_ChunkDesc.GetChunkZ();
+ cChunkDef::BlockTypes & BlockTypes = a_ChunkDesc.GetBlockTypes();
+ cChunkDef::HeightMap & HeightMap = a_ChunkDesc.GetHeightMap();
for (cCaveTunnels::const_iterator itr = m_Tunnels.begin(), end = m_Tunnels.end(); itr != end; ++itr)
{
- (*itr)->ProcessChunk(a_ChunkX, a_ChunkZ, a_BlockTypes, a_HeightMap);
- } // for itr - m_Tunnels[]
-}
-
-
-
-
-
-#ifdef _DEBUG
-AString cStructGenWormNestCaves::cCaveSystem::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const
-{
- AString SVG;
- SVG.reserve(512 * 1024);
- for (cCaveTunnels::const_iterator itr = m_Tunnels.begin(), end = m_Tunnels.end(); itr != end; ++itr)
- {
- SVG.append((*itr)->ExportAsSVG(a_Color, a_OffsetX, a_OffsetZ));
+ (*itr)->ProcessChunk(ChunkX, ChunkZ, BlockTypes, HeightMap);
} // for itr - m_Tunnels[]
-
- // Base point highlight:
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#ff0000;stroke-width:1px;\"\nd=\"M %d,%d L %d,%d\"/>\n",
- a_OffsetX + m_BlockX - 5, a_OffsetZ + m_BlockZ, a_OffsetX + m_BlockX + 5, a_OffsetZ + m_BlockZ
- );
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#ff0000;stroke-width:1px;\"\nd=\"M %d,%d L %d,%d\"/>\n",
- a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ - 5, a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ + 5
- );
-
- // A gray line from the base point to the first point of the ravine, for identification:
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#cfcfcf;stroke-width:1px;\"\nd=\"M %d,%d L %d,%d\"/>\n",
- a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ,
- a_OffsetX + m_Tunnels.front()->m_Points.front().m_BlockX,
- a_OffsetZ + m_Tunnels.front()->m_Points.front().m_BlockZ
- );
-
- // Offset guides:
- if (a_OffsetX > 0)
- {
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#0000ff;stroke-width:1px;\"\nd=\"M %d,0 L %d,1024\"/>\n",
- a_OffsetX, a_OffsetX
- );
- }
- if (a_OffsetZ > 0)
- {
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#0000ff;stroke-width:1px;\"\nd=\"M 0,%d L 1024,%d\"/>\n",
- a_OffsetZ, a_OffsetZ
- );
- }
-
- return SVG;
}
-#endif // _DEBUG
@@ -741,145 +687,12 @@ int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_Orig
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenWormNestCaves:
-cStructGenWormNestCaves::~cStructGenWormNestCaves()
-{
- ClearCache();
-}
-
-
-
-
-
-void cStructGenWormNestCaves::ClearCache(void)
-{
- for (cCaveSystems::const_iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end; ++itr)
- {
- delete *itr;
- } // for itr - m_Cache[]
- m_Cache.clear();
-}
-
-
-
-
-
-void cStructGenWormNestCaves::GenFinish(cChunkDesc & a_ChunkDesc)
-{
- int ChunkX = a_ChunkDesc.GetChunkX();
- int ChunkZ = a_ChunkDesc.GetChunkZ();
- cCaveSystems Caves;
- GetCavesForChunk(ChunkX, ChunkZ, Caves);
- for (cCaveSystems::const_iterator itr = Caves.begin(); itr != Caves.end(); ++itr)
- {
- (*itr)->ProcessChunk(ChunkX, ChunkZ, a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap());
- } // for itr - Caves[]
-}
-
-
-
-
-
-void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStructGenWormNestCaves::cCaveSystems & a_Caves)
+cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
- int BaseX = a_ChunkX * cChunkDef::Width / m_Grid;
- int BaseZ = a_ChunkZ * cChunkDef::Width / m_Grid;
- if (BaseX < 0)
- {
- --BaseX;
- }
- if (BaseZ < 0)
- {
- --BaseZ;
- }
- BaseX -= NEIGHBORHOOD_SIZE / 2;
- BaseZ -= NEIGHBORHOOD_SIZE / 2;
-
- // Walk the cache, move each cave system that we want into a_Caves:
- int StartX = BaseX * m_Grid;
- int EndX = (BaseX + NEIGHBORHOOD_SIZE + 1) * m_Grid;
- int StartZ = BaseZ * m_Grid;
- int EndZ = (BaseZ + NEIGHBORHOOD_SIZE + 1) * m_Grid;
- for (cCaveSystems::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;)
- {
- if (
- ((*itr)->m_BlockX >= StartX) && ((*itr)->m_BlockX < EndX) &&
- ((*itr)->m_BlockZ >= StartZ) && ((*itr)->m_BlockZ < EndZ)
- )
- {
- // want
- a_Caves.push_back(*itr);
- itr = m_Cache.erase(itr);
- }
- else
- {
- // don't want
- ++itr;
- }
- } // for itr - m_Cache[]
-
- for (int x = 0; x < NEIGHBORHOOD_SIZE; x++)
- {
- int RealX = (BaseX + x) * m_Grid;
- for (int z = 0; z < NEIGHBORHOOD_SIZE; z++)
- {
- int RealZ = (BaseZ + z) * m_Grid;
- bool Found = false;
- for (cCaveSystems::const_iterator itr = a_Caves.begin(), end = a_Caves.end(); itr != end; ++itr)
- {
- if (((*itr)->m_BlockX == RealX) && ((*itr)->m_BlockZ == RealZ))
- {
- Found = true;
- break;
- }
- }
- if (!Found)
- {
- a_Caves.push_back(new cCaveSystem(RealX, RealZ, m_MaxOffset, m_Size, m_Noise));
- }
- }
- }
-
- // Copy a_Caves into m_Cache to the beginning:
- cCaveSystems CavesCopy(a_Caves);
- m_Cache.splice(m_Cache.begin(), CavesCopy, CavesCopy.begin(), CavesCopy.end());
-
- // Trim the cache if it's too long:
- if (m_Cache.size() > 100)
- {
- cCaveSystems::iterator itr = m_Cache.begin();
- std::advance(itr, 100);
- for (cCaveSystems::iterator end = m_Cache.end(); itr != end; ++itr)
- {
- delete *itr;
- }
- itr = m_Cache.begin();
- std::advance(itr, 100);
- m_Cache.erase(itr, m_Cache.end());
- }
-
- /*
- // Uncomment this block for debugging the caves' shapes in 2D using an SVG export
- #ifdef _DEBUG
- AString SVG;
- SVG.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1024\" height = \"1024\">\n");
- SVG.reserve(2 * 1024 * 1024);
- for (cCaveSystems::const_iterator itr = a_Caves.begin(), end = a_Caves.end(); itr != end; ++itr)
- {
- int Color = 0x10 * abs((*itr)->m_BlockX / m_Grid);
- Color |= 0x1000 * abs((*itr)->m_BlockZ / m_Grid);
- SVG.append((*itr)->ExportAsSVG(Color, 512, 512));
- }
- SVG.append("</svg>\n");
-
- AString fnam;
- Printf(fnam, "wnc\\%03d_%03d.svg", a_ChunkX, a_ChunkZ);
- cFile File(fnam, cFile::fmWrite);
- File.Write(SVG.c_str(), SVG.size());
- #endif // _DEBUG
- //*/
+ return cStructurePtr(new cCaveSystem(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxOffset, m_Size, m_Noise));
}
@@ -887,13 +700,13 @@ void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStru
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenMarbleCaves:
-static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise )
+static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise)
{
static const float PI_2 = 1.57079633f;
- float oct1 = (a_Noise.CubicNoise3D(x * 0.1f, y * 0.1f, z * 0.1f )) * 4;
+ float oct1 = (a_Noise.CubicNoise3D(x * 0.1f, y * 0.1f, z * 0.1f)) * 4;
oct1 = oct1 * oct1 * oct1;
if (oct1 < 0.f) oct1 = PI_2;
@@ -917,7 +730,7 @@ void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc)
const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x);
int Top = a_ChunkDesc.GetHeight(x, z);
- for (int y = 1; y < Top; ++y )
+ for (int y = 1; y < Top; ++y)
{
if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_STONE)
{
@@ -939,7 +752,7 @@ void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenDualRidgeCaves:
void cStructGenDualRidgeCaves::GenFinish(cChunkDesc & a_ChunkDesc)
diff --git a/src/Generating/Caves.h b/src/Generating/Caves.h
index 7c45c056b..0e17acf9e 100644
--- a/src/Generating/Caves.h
+++ b/src/Generating/Caves.h
@@ -12,7 +12,7 @@
#pragma once
-#include "ComposableGenerator.h"
+#include "GridStructGen.h"
#include "../Noise.h"
@@ -64,10 +64,12 @@ protected:
class cStructGenWormNestCaves :
- public cFinishGen
+ public cGridStructGen
{
+ typedef cGridStructGen super;
public:
cStructGenWormNestCaves(int a_Seed, int a_Size = 64, int a_Grid = 96, int a_MaxOffset = 128) :
+ super(a_Seed, a_Grid, a_Grid, a_MaxOffset, a_MaxOffset, a_Size, a_Size, 100),
m_Noise(a_Seed),
m_Size(a_Size),
m_MaxOffset(a_MaxOffset),
@@ -75,26 +77,16 @@ public:
{
}
- ~cStructGenWormNestCaves();
-
protected:
class cCaveSystem; // fwd: Caves.cpp
- typedef std::list<cCaveSystem *> cCaveSystems;
cNoise m_Noise;
int m_Size; // relative size of the cave systems' caves. Average number of blocks of each initial tunnel
int m_MaxOffset; // maximum offset of the cave nest origin from the grid cell the nest belongs to
int m_Grid; // average spacing of the nests
- cCaveSystems m_Cache;
-
- /// Clears everything from the cache
- void ClearCache(void);
-
- /// Returns all caves that *may* intersect the given chunk. All the caves are valid until the next call to this function.
- void GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cCaveSystems & a_Caves);
-
- // cStructGen override:
- virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
+
+ // cGridStructGen override:
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
} ;
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 7711723fc..c0b646fd0 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -20,7 +20,6 @@ cChunkDesc::cChunkDesc(int a_ChunkX, int a_ChunkZ) :
m_bUseDefaultBiomes(true),
m_bUseDefaultHeight(true),
m_bUseDefaultComposition(true),
- m_bUseDefaultStructures(true),
m_bUseDefaultFinish(true)
{
m_BlockArea.Create(cChunkDef::Width, cChunkDef::Height, cChunkDef::Width);
@@ -207,26 +206,6 @@ bool cChunkDesc::IsUsingDefaultComposition(void) const
-void cChunkDesc::SetUseDefaultStructures(bool a_bUseDefaultStructures)
-{
- LOGWARNING("%s: Structures are no longer accounted for, use Finishers instead", __FUNCTION__);
- m_bUseDefaultStructures = a_bUseDefaultStructures;
-}
-
-
-
-
-
-bool cChunkDesc::IsUsingDefaultStructures(void) const
-{
- LOGWARNING("%s: Structures are no longer accounted for, use Finishers instead", __FUNCTION__);
- return m_bUseDefaultStructures;
-}
-
-
-
-
-
void cChunkDesc::SetUseDefaultFinish(bool a_bUseDefaultFinish)
{
m_bUseDefaultFinish = a_bUseDefaultFinish;
@@ -290,7 +269,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
LOGWARNING("%s: MaxRelX less than zero, adjusting to zero", __FUNCTION__);
a_MaxRelX = 0;
}
- else if (a_MinRelX >= cChunkDef::Width)
+ else if (a_MaxRelX >= cChunkDef::Width)
{
LOGWARNING("%s: MaxRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
a_MaxRelX = cChunkDef::Width - 1;
@@ -311,7 +290,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
LOGWARNING("%s: MaxRelY less than zero, adjusting to zero", __FUNCTION__);
a_MaxRelY = 0;
}
- else if (a_MinRelY >= cChunkDef::Height)
+ else if (a_MaxRelY >= cChunkDef::Height)
{
LOGWARNING("%s: MaxRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
a_MaxRelY = cChunkDef::Height - 1;
@@ -332,7 +311,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
LOGWARNING("%s: MaxRelZ less than zero, adjusting to zero", __FUNCTION__);
a_MaxRelZ = 0;
}
- else if (a_MinRelZ >= cChunkDef::Width)
+ else if (a_MaxRelZ >= cChunkDef::Width)
{
LOGWARNING("%s: MaxRelZ more than chunk width, adjusting to chunk width", __FUNCTION__);
a_MaxRelZ = cChunkDef::Width - 1;
diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h
index 8edc2800b..eeea0c957 100644
--- a/src/Generating/ChunkDesc.h
+++ b/src/Generating/ChunkDesc.h
@@ -68,8 +68,6 @@ public:
bool IsUsingDefaultHeight(void) const;
void SetUseDefaultComposition(bool a_bUseDefaultComposition);
bool IsUsingDefaultComposition(void) const;
- void SetUseDefaultStructures(bool a_bUseDefaultStructures);
- bool IsUsingDefaultStructures(void) const;
void SetUseDefaultFinish(bool a_bUseDefaultFinish);
bool IsUsingDefaultFinish(void) const;
@@ -186,7 +184,7 @@ public:
// Accessors used by cChunkGenerator::Generator descendants:
inline cChunkDef::BiomeMap & GetBiomeMap (void) { return m_BiomeMap; }
inline cChunkDef::BlockTypes & GetBlockTypes (void) { return *((cChunkDef::BlockTypes *)m_BlockArea.GetBlockTypes()); }
- // CANNOT, different compression!
+ // CANNOT, different compression!
// inline cChunkDef::BlockNibbles & GetBlockMetas (void) { return *((cChunkDef::BlockNibbles *)m_BlockArea.GetBlockMetas()); }
inline BlockNibbleBytes & GetBlockMetasUncompressed(void) { return *((BlockNibbleBytes *)m_BlockArea.GetBlockMetas()); }
inline cChunkDef::HeightMap & GetHeightMap (void) { return m_HeightMap; }
@@ -214,7 +212,6 @@ private:
bool m_bUseDefaultBiomes;
bool m_bUseDefaultHeight;
bool m_bUseDefaultComposition;
- bool m_bUseDefaultStructures;
bool m_bUseDefaultFinish;
} ; // tolua_export
diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp
index 73f0223e8..3d5af152c 100644
--- a/src/Generating/ChunkGenerator.cpp
+++ b/src/Generating/ChunkGenerator.cpp
@@ -22,7 +22,7 @@ const unsigned int QUEUE_SKIP_LIMIT = 500;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cChunkGenerator:
cChunkGenerator::cChunkGenerator(void) :
@@ -52,7 +52,7 @@ bool cChunkGenerator::Start(cPluginInterface & a_PluginInterface, cChunkSink & a
m_ChunkSink = &a_ChunkSink;
MTRand rnd;
- m_Seed = a_IniFile.GetValueSetI("Seed", "Seed", rnd.randInt());
+ m_Seed = a_IniFile.GetValueSetI("Seed", "Seed", (int)rnd.randInt());
AString GeneratorName = a_IniFile.GetValueSet("Generator", "Generator", "Composable");
if (NoCaseCompare(GeneratorName, "Noise3D") == 0)
@@ -180,7 +180,7 @@ BLOCKTYPE cChunkGenerator::GetIniBlock(cIniFile & a_IniFile, const AString & a_S
BLOCKTYPE Block = BlockStringToType(BlockType);
if (Block < 0)
{
- LOGWARN("[%s].%s Could not parse block value \"%s\". Using default: \"%s\".", a_SectionName.c_str(), a_ValueName.c_str(), BlockType.c_str(),a_Default.c_str());
+ LOGWARN("[%s].%s Could not parse block value \"%s\". Using default: \"%s\".", a_SectionName.c_str(), a_ValueName.c_str(), BlockType.c_str(), a_Default.c_str());
return BlockStringToType(a_Default);
}
return Block;
@@ -228,10 +228,10 @@ void cChunkGenerator::Execute(void)
continue;
}
- cChunkCoords coords = m_Queue.front(); // Get next coord from queue
- m_Queue.erase( m_Queue.begin() ); // Remove coordinate from queue
+ cChunkCoords coords = m_Queue.front(); // Get next coord from queue
+ m_Queue.erase( m_Queue.begin()); // Remove coordinate from queue
bool SkipEnabled = (m_Queue.size() > QUEUE_SKIP_LIMIT);
- Lock.Unlock(); // Unlock ASAP
+ Lock.Unlock(); // Unlock ASAP
m_evtRemoved.Set();
// Display perf info once in a while:
@@ -290,7 +290,7 @@ void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cChunkGenerator::cGenerator:
cChunkGenerator::cGenerator::cGenerator(cChunkGenerator & a_ChunkGenerator) :
diff --git a/src/Generating/ChunkGenerator.h b/src/Generating/ChunkGenerator.h
index 9b2d9eb3c..88d71f3f9 100644
--- a/src/Generating/ChunkGenerator.h
+++ b/src/Generating/ChunkGenerator.h
@@ -44,7 +44,7 @@ public:
{
public:
cGenerator(cChunkGenerator & a_ChunkGenerator);
- virtual ~cGenerator() {} ; // Force a virtual destructor
+ virtual ~cGenerator() {} // Force a virtual destructor
/// Called to initialize the generator on server startup.
virtual void Initialize(cIniFile & a_IniFile);
diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp
index 578bb2481..178673e32 100644
--- a/src/Generating/CompoGen.cpp
+++ b/src/Generating/CompoGen.cpp
@@ -18,7 +18,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompoGenSameBlock:
void cCompoGenSameBlock::ComposeTerrain(cChunkDesc & a_ChunkDesc)
@@ -60,7 +60,7 @@ void cCompoGenSameBlock::InitializeCompoGen(cIniFile & a_IniFile)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompoGenDebugBiomes:
void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc)
@@ -68,7 +68,7 @@ void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc)
static BLOCKTYPE Blocks[] =
{
E_BLOCK_STONE,
- E_BLOCK_COBBLESTONE,
+ E_BLOCK_COBBLESTONE,
E_BLOCK_LOG,
E_BLOCK_PLANKS,
E_BLOCK_SANDSTONE,
@@ -111,7 +111,7 @@ void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompoGenClassic:
cCompoGenClassic::cCompoGenClassic(void) :
@@ -209,7 +209,7 @@ void cCompoGenClassic::InitializeCompoGen(cIniFile & a_IniFile)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompoGenBiomal:
void cCompoGenBiomal::ComposeTerrain(cChunkDesc & a_ChunkDesc)
@@ -526,7 +526,7 @@ void cCompoGenBiomal::FillColumnPattern(int a_RelX, int a_RelZ, int a_Height, cC
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompoGenNether:
cCompoGenNether::cCompoGenNether(int a_Seed) :
@@ -561,10 +561,16 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc)
// Interpolate the lowest floor:
for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++)
{
- FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] =
- m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) *
+ //*
+ FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] =
+ m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) *
m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) /
256;
+ //*/
+ /*
+ FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] =
+ m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / 256;
+ //*/
} // for x, z - FloorLo[]
LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorLo);
@@ -574,10 +580,16 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc)
// First update the high floor:
for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++)
{
+ //*
FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] =
m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) *
m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) /
256;
+ //*/
+ /*
+ FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] =
+ m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) / 256;
+ //*/
} // for x, z - FloorLo[]
LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorHi);
@@ -616,7 +628,22 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc)
for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++)
{
a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK);
- a_ChunkDesc.SetBlockType(x, a_ChunkDesc.GetHeight(x, z), z, E_BLOCK_BEDROCK);
+
+ int Height = a_ChunkDesc.GetHeight(x, z);
+ a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_BEDROCK);
+
+ NOISE_DATATYPE CeilingDisguise = (m_Noise1.CubicNoise2D((float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10, (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10));
+ if (CeilingDisguise < 0)
+ {
+ CeilingDisguise = -CeilingDisguise;
+ }
+
+ int CeilingDisguiseHeight = Height - 2 - (int)CeilingDisguise * 3;
+
+ for (int y = Height - 1; y > CeilingDisguiseHeight; y--)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_NETHERRACK);
+ }
}
}
@@ -633,7 +660,7 @@ void cCompoGenNether::InitializeCompoGen(cIniFile & a_IniFile)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCompoGenCache:
cCompoGenCache::cCompoGenCache(cTerrainCompositionGen & a_Underlying, int a_CacheSize) :
@@ -660,7 +687,9 @@ cCompoGenCache::cCompoGenCache(cTerrainCompositionGen & a_Underlying, int a_Cach
cCompoGenCache::~cCompoGenCache()
{
delete[] m_CacheData;
+ m_CacheData = NULL;
delete[] m_CacheOrder;
+ m_CacheOrder = NULL;
}
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index 2e886336f..a7659149a 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -24,14 +24,20 @@
#include "NetherFortGen.h"
#include "Noise3DGenerator.h"
#include "POCPieceGenerator.h"
+#include "RainbowRoadsGen.h"
#include "Ravines.h"
+#include "RoughRavines.h"
+#include "TestRailsGen.h"
+#include "UnderwaterBaseGen.h"
+#include "VillageGen.h"
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cTerrainCompositionGen:
+
cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen, int a_Seed)
{
AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", "");
@@ -39,7 +45,6 @@ cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile &
{
LOGWARN("[Generator] CompositionGen value not set in world.ini, using \"Biomal\".");
CompoGenName = "Biomal";
- a_IniFile.SetValue("Generator", "CompositionGen", CompoGenName);
}
cTerrainCompositionGen * res = NULL;
@@ -93,7 +98,6 @@ cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile &
else
{
LOGWARN("Unknown CompositionGen \"%s\", using \"Biomal\" instead.", CompoGenName.c_str());
- a_IniFile.DeleteValue("Generator", "CompositionGen");
a_IniFile.SetValue("Generator", "CompositionGen", "Biomal");
return CreateCompositionGen(a_IniFile, a_BiomeGen, a_HeightGen, a_Seed);
}
@@ -109,7 +113,7 @@ cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile &
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cComposableGenerator:
cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) :
@@ -229,7 +233,7 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile)
{
if (CacheSize < 4)
{
- LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
+ LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
CacheSize, 4
);
CacheSize = 4;
@@ -247,7 +251,7 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile)
void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
{
bool CacheOffByDefault = false;
- m_HeightGen = cTerrainHeightGen::CreateHeightGen(a_IniFile, *m_BiomeGen, m_ChunkGenerator.GetSeed(), CacheOffByDefault);
+ m_HeightGen = cTerrainHeightGen::CreateHeightGen(a_IniFile, *m_BiomeGen, m_ChunkGenerator.GetSeed(), CacheOffByDefault);
// Add a cache, if requested:
int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64);
@@ -255,7 +259,7 @@ void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
{
if (CacheSize < 4)
{
- LOGWARNING("Heightgen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
+ LOGWARNING("Heightgen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
CacheSize, 4
);
CacheSize = 4;
@@ -291,19 +295,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
int Seed = m_ChunkGenerator.GetSeed();
eDimension Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld"));
- // Older configuration used "Structures" in addition to "Finishers"; we don't distinguish between the two anymore (#398)
- // Therefore, we load Structures from the ini file for compatibility, but move its contents over to Finishers:
- AString Structures = a_IniFile.GetValue("Generator", "Structures", "");
- AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, LavaLakes, OreNests, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator");
- if (!Structures.empty())
- {
- LOGINFO("[Generator].Structures is deprecated, moving the contents to [Generator].Finishers.");
- // Structures used to generate before Finishers, so place them first:
- Structures.append(", ");
- Finishers = Structures + Finishers;
- a_IniFile.SetValue("Generator", "Finishers", Finishers);
- }
- a_IniFile.DeleteValue("Generator", "Structures");
+ AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", "");
// Create all requested finishers:
AStringVector Str = StringSplitAndTrim(Finishers, ",");
@@ -318,7 +310,25 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
}
else if (NoCaseCompare(*itr, "DeadBushes") == 0)
{
- m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, biDesert, 2, E_BLOCK_SAND, E_BLOCK_SAND));
+ // A list with all the allowed biomes.
+ cFinishGenSingleTopBlock::BiomeList AllowedBiomes;
+ AllowedBiomes.push_back(biDesert);
+ AllowedBiomes.push_back(biDesertHills);
+ AllowedBiomes.push_back(biDesertM);
+ AllowedBiomes.push_back(biMesa);
+ AllowedBiomes.push_back(biMesaBryce);
+ AllowedBiomes.push_back(biMesaPlateau);
+ AllowedBiomes.push_back(biMesaPlateauF);
+ AllowedBiomes.push_back(biMesaPlateauFM);
+ AllowedBiomes.push_back(biMesaPlateauM);
+
+ // A list with all the allowed blocks that can be below the dead bush.
+ cFinishGenSingleTopBlock::BlockList AllowedBlocks;
+ AllowedBlocks.push_back(E_BLOCK_SAND);
+ AllowedBlocks.push_back(E_BLOCK_HARDENED_CLAY);
+ AllowedBlocks.push_back(E_BLOCK_STAINED_CLAY);
+
+ m_FinishGens.push_back(new cFinishGenSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, AllowedBiomes, 2, AllowedBlocks));
}
else if (NoCaseCompare(*itr, "DirectOverhangs") == 0)
{
@@ -353,18 +363,29 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
else if (NoCaseCompare(*itr, "MineShafts") == 0)
{
int GridSize = a_IniFile.GetValueSetI("Generator", "MineShaftsGridSize", 512);
+ int MaxOffset = a_IniFile.GetValueSetI("Generator", "MineShaftsMaxOffset", 256);
int MaxSystemSize = a_IniFile.GetValueSetI("Generator", "MineShaftsMaxSystemSize", 160);
int ChanceCorridor = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCorridor", 600);
int ChanceCrossing = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCrossing", 200);
int ChanceStaircase = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceStaircase", 200);
m_FinishGens.push_back(new cStructGenMineShafts(
- Seed, GridSize, MaxSystemSize,
+ Seed, GridSize, MaxOffset, MaxSystemSize,
ChanceCorridor, ChanceCrossing, ChanceStaircase
));
}
else if (NoCaseCompare(*itr, "Lilypads") == 0)
{
- m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_LILY_PAD, biSwampland, 4, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER));
+ // A list with all the allowed biomes.
+ cFinishGenSingleTopBlock::BiomeList AllowedBiomes;
+ AllowedBiomes.push_back(biSwampland);
+ AllowedBiomes.push_back(biSwamplandM);
+
+ // A list with all the allowed blocks that can be below the lilypad.
+ cFinishGenSingleTopBlock::BlockList AllowedBlocks;
+ AllowedBlocks.push_back(E_BLOCK_WATER);
+ AllowedBlocks.push_back(E_BLOCK_STATIONARY_WATER);
+
+ m_FinishGens.push_back(new cFinishGenSingleTopBlock(Seed, E_BLOCK_LILY_PAD, AllowedBiomes, 4, AllowedBlocks));
}
else if (NoCaseCompare(*itr, "NetherClumpFoliage") == 0)
{
@@ -372,9 +393,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
}
else if (NoCaseCompare(*itr, "NetherForts") == 0)
{
- int GridSize = a_IniFile.GetValueSetI("Generator", "NetherFortsGridSize", 512);
- int MaxDepth = a_IniFile.GetValueSetI("Generator", "NetherFortsMaxDepth", 12);
- m_FinishGens.push_back(new cNetherFortGen(Seed, GridSize, MaxDepth));
+ int GridSize = a_IniFile.GetValueSetI("Generator", "NetherFortsGridSize", 512);
+ int MaxOffset = a_IniFile.GetValueSetI("Generator", "NetherFortMaxOffset", 128);
+ int MaxDepth = a_IniFile.GetValueSetI("Generator", "NetherFortsMaxDepth", 12);
+ m_FinishGens.push_back(new cNetherFortGen(Seed, GridSize, MaxOffset, MaxDepth));
}
else if (NoCaseCompare(*itr, "OreNests") == 0)
{
@@ -388,10 +410,47 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
m_FinishGens.push_back(new cFinishGenPreSimulator);
}
+ else if (NoCaseCompare(*itr, "RainbowRoads") == 0)
+ {
+ int GridSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsGridSize", 512);
+ int MaxOffset = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxOffset", 128);
+ int MaxDepth = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxDepth", 30);
+ int MaxSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxSize", 260);
+ m_FinishGens.push_back(new cRainbowRoadsGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize));
+ }
else if (NoCaseCompare(*itr, "Ravines") == 0)
{
m_FinishGens.push_back(new cStructGenRavines(Seed, 128));
}
+ else if (NoCaseCompare(*itr, "RoughRavines") == 0)
+ {
+ int GridSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesGridSize", 256);
+ int MaxOffset = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxOffset", 128);
+ int MaxSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxSize", 128);
+ int MinSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMinSize", 64);
+ double MaxCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCenterWidth", 8);
+ double MinCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCenterWidth", 2);
+ double MaxRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxRoughness", 0.2);
+ double MinRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinRoughness", 0.05);
+ double MaxFloorHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxFloorHeightEdge", 8);
+ double MinFloorHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinFloorHeightEdge", 30);
+ double MaxFloorHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxFloorHeightCenter", 20);
+ double MinFloorHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinFloorHeightCenter", 6);
+ double MaxCeilingHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCeilingHeightEdge", 56);
+ double MinCeilingHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCeilingHeightEdge", 38);
+ double MaxCeilingHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCeilingHeightCenter", 58);
+ double MinCeilingHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCeilingHeightCenter", 36);
+ m_FinishGens.push_back(new cRoughRavines(
+ Seed, MaxSize, MinSize,
+ (float)MaxCenterWidth, (float)MinCenterWidth,
+ (float)MaxRoughness, (float)MinRoughness,
+ (float)MaxFloorHeightEdge, (float)MinFloorHeightEdge,
+ (float)MaxFloorHeightCenter, (float)MinFloorHeightCenter,
+ (float)MaxCeilingHeightEdge, (float)MinCeilingHeightEdge,
+ (float)MaxCeilingHeightCenter, (float)MinCeilingHeightCenter,
+ GridSize, MaxOffset
+ ));
+ }
else if (NoCaseCompare(*itr, "Snow") == 0)
{
m_FinishGens.push_back(new cFinishGenSnow);
@@ -400,10 +459,36 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed));
}
+ else if (NoCaseCompare(*itr, "TallGrass") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenTallGrass(Seed));
+ }
+ else if (NoCaseCompare(*itr, "TestRails") == 0)
+ {
+ m_FinishGens.push_back(new cTestRailsGen(Seed, 100, 1, 7, 50));
+ }
else if (NoCaseCompare(*itr, "Trees") == 0)
{
m_FinishGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen));
}
+ else if (NoCaseCompare(*itr, "UnderwaterBases") == 0)
+ {
+ int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024);
+ int MaxOffset = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxOffset", 128);
+ int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7);
+ int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128);
+ m_FinishGens.push_back(new cUnderwaterBaseGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize, *m_BiomeGen));
+ }
+ else if (NoCaseCompare(*itr, "Villages") == 0)
+ {
+ int GridSize = a_IniFile.GetValueSetI("Generator", "VillageGridSize", 384);
+ int MaxOffset = a_IniFile.GetValueSetI("Generator", "VillageMaxOffset", 128);
+ int MaxDepth = a_IniFile.GetValueSetI("Generator", "VillageMaxDepth", 2);
+ int MaxSize = a_IniFile.GetValueSetI("Generator", "VillageMaxSize", 128);
+ int MinDensity = a_IniFile.GetValueSetI("Generator", "VillageMinDensity", 50);
+ int MaxDensity = a_IniFile.GetValueSetI("Generator", "VillageMaxDensity", 80);
+ m_FinishGens.push_back(new cVillageGen(Seed, GridSize, MaxOffset, MaxDepth, MaxSize, MinDensity, MaxDensity, *m_BiomeGen, *m_HeightGen));
+ }
else if (NoCaseCompare(*itr, "WaterLakes") == 0)
{
int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
@@ -415,7 +500,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
}
else if (NoCaseCompare(*itr, "WormNestCaves") == 0)
{
- m_FinishGens.push_back(new cStructGenWormNestCaves(Seed));
+ int Size = a_IniFile.GetValueSetI("Generator", "WormNestCavesSize", 64);
+ int Grid = a_IniFile.GetValueSetI("Generator", "WormNestCavesGrid", 96);
+ int MaxOffset = a_IniFile.GetValueSetI("Generator", "WormNestMaxOffset", 32);
+ m_FinishGens.push_back(new cStructGenWormNestCaves(Seed, Size, Grid, MaxOffset));
}
else
{
diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp
index eb9fe92ba..c18c402da 100644
--- a/src/Generating/DistortedHeightmap.cpp
+++ b/src/Generating/DistortedHeightmap.cpp
@@ -14,7 +14,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cPattern:
/// This class is used to store a column pattern initialized at runtime,
@@ -50,7 +50,7 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// The arrays to use for the top block pattern definitions:
static cDistortedHeightmap::sBlockInfo tbGrass[] =
@@ -119,7 +119,7 @@ static cDistortedHeightmap::sBlockInfo tbStone[] =
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Ocean floor pattern top-block definitions:
static cDistortedHeightmap::sBlockInfo tbOFSand[] =
@@ -151,7 +151,7 @@ static cDistortedHeightmap::sBlockInfo tbOFRedSand[] =
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Individual patterns to use:
static cPattern patGrass (tbGrass, ARRAYCOUNT(tbGrass));
@@ -171,7 +171,7 @@ static cPattern patOFRedSand(tbOFRedSand, ARRAYCOUNT(tbOFRedSand));
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cDistortedHeightmap:
/** This table assigns a relative maximum overhang size in each direction to biomes.
@@ -675,6 +675,8 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in
case biForestHills:
case biTaigaHills:
case biExtremeHillsEdge:
+ case biExtremeHillsPlus:
+ case biExtremeHills:
case biJungle:
case biJungleHills:
case biJungleEdge:
@@ -750,18 +752,6 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in
return;
}
- case biExtremeHillsPlus:
- case biExtremeHills:
- {
- // Select the pattern to use - stone or grass:
- NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + a_RelX)) / FrequencyX;
- NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + a_RelZ)) / FrequencyZ;
- NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY);
- const sBlockInfo * Pattern = (Val < -0.1) ? patStone.Get() : patGrass.Get();
- FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, Pattern);
- return;
- }
-
case biExtremeHillsPlusM:
case biExtremeHillsM:
{
@@ -769,7 +759,7 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in
NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + a_RelX)) / FrequencyX;
NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + a_RelZ)) / FrequencyZ;
NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY);
- const sBlockInfo * Pattern = (Val < -0.9) ? patStone.Get() : ((Val > 0) ? patGravel.Get() : patGrass.Get());
+ const sBlockInfo * Pattern = (Val < 0.0) ? patStone.Get() : patGrass.Get();
FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, Pattern);
return;
}
@@ -819,7 +809,7 @@ void cDistortedHeightmap::FillColumnPattern(cChunkDesc & a_ChunkDesc, int a_RelX
}
// Select the ocean-floor pattern to use:
- a_Pattern = ChooseOceanFloorPattern(a_RelX, a_RelZ);
+ a_Pattern = a_ChunkDesc.GetBiome(a_RelX, a_RelZ) == biDeepOcean ? patGravel.Get() : ChooseOceanFloorPattern(a_RelX, a_RelZ);
HasHadWater = true;
} // for y
a_ChunkDesc.SetBlockType(a_RelX, 0, a_RelZ, E_BLOCK_BEDROCK);
diff --git a/src/Generating/EndGen.cpp b/src/Generating/EndGen.cpp
index f466039b9..c94cd1eff 100644
--- a/src/Generating/EndGen.cpp
+++ b/src/Generating/EndGen.cpp
@@ -29,7 +29,7 @@ enum
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cEndGen:
cEndGen::cEndGen(int a_Seed) :
@@ -50,7 +50,7 @@ cEndGen::cEndGen(int a_Seed) :
-void cEndGen::Initialize(cIniFile & a_IniFile)
+void cEndGen::InitializeCompoGen(cIniFile & a_IniFile)
{
m_IslandSizeX = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeX", m_IslandSizeX);
m_IslandSizeY = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeY", m_IslandSizeY);
diff --git a/src/Generating/EndGen.h b/src/Generating/EndGen.h
index 4904a0e3d..322061810 100644
--- a/src/Generating/EndGen.h
+++ b/src/Generating/EndGen.h
@@ -23,8 +23,6 @@ class cEndGen :
public:
cEndGen(int a_Seed);
- void Initialize(cIniFile & a_IniFile);
-
protected:
/// Seed for the noise
@@ -66,4 +64,5 @@ protected:
// cTerrainCompositionGen overrides:
virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
+ virtual void InitializeCompoGen(cIniFile & a_IniFile) override;
} ;
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index f2d66af70..f53addb68 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -40,47 +40,19 @@ static inline bool IsWater(BLOCKTYPE a_BlockType)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFinishGenNetherClumpFoliage:
void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
{
- double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates.
- double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1;
-
- NOISE_DATATYPE Val1 = m_Noise.CubicNoise2D((float) (ChunkX * ChunkZ * 0.01f), (float) (ChunkZ / ChunkX * 0.01f));
- NOISE_DATATYPE Val2 = m_Noise.CubicNoise2D((float) (ChunkX / ChunkZ / 0.01f), (float) (ChunkZ * ChunkX / 0.01f));
+ int ChunkX = a_ChunkDesc.GetChunkX();
+ int ChunkZ = a_ChunkDesc.GetChunkZ();
- if (Val1 < 0)
- {
- Val1 = -Val1;
- }
-
- if (Val2 < 0)
- {
- Val2 = -Val2;
- }
+ int Val1 = m_Noise.IntNoise2DInt(ChunkX ^ ChunkZ, ChunkZ + ChunkX);
+ int Val2 = m_Noise.IntNoise2DInt(ChunkZ ^ ChunkX, ChunkZ - ChunkX);
- int PosX, PosZ;
- // Calculate PosX
- if (Val1 <= 1)
- {
- PosX = (int) floor(Val1 * 16);
- }
- else
- {
- PosX = (int) floor(16 / Val1);
- }
-
- // Calculate PosZ
- if (Val2 <= 1)
- {
- PosZ = (int) floor(Val2 * 16);
- }
- else
- {
- PosZ = (int) floor(16 / Val2);
- }
+ int PosX = Val1 % 16;
+ int PosZ = Val2 % 16;
for (int y = 1; y < cChunkDef::Height; y++)
{
@@ -88,12 +60,14 @@ void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
{
continue;
}
+
if (!cBlockInfo::IsSolid(a_ChunkDesc.GetBlockType(PosX, y - 1, PosZ))) // Only place on solid blocks
{
continue;
}
- NOISE_DATATYPE BlockType = m_Noise.CubicNoise1D((float) (ChunkX * ChunkZ) / (y * 0.1f));
+ // Choose what block to use.
+ NOISE_DATATYPE BlockType = m_Noise.IntNoise3D((int) ChunkX, y, (int) ChunkZ);
if (BlockType < -0.7)
{
TryPlaceClump(a_ChunkDesc, PosX, y, PosZ, E_BLOCK_BROWN_MUSHROOM);
@@ -117,26 +91,71 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a
{
bool IsFireBlock = a_Block == E_BLOCK_FIRE;
- for (int x = a_RelX - 4; x < a_RelX + 4; x++)
+ int MinX = a_RelX - 4;
+ if (MinX < 0) // Check if the coordinate is outside the chunk. If it it then adjust it.
{
- float xx = (float) a_ChunkDesc.GetChunkX() * cChunkDef::Width + x;
- for (int z = a_RelZ - 4; z < a_RelZ + 4; z++)
+ MinX = 0;
+ }
+
+ int MaxX = a_RelX + 4;
+ if (MaxX > cChunkDef::Width) // Check if the coordinate is outside the chunk. If it it then adjust it.
+ {
+ MaxX = cChunkDef::Width;
+ }
+
+ int MinZ = a_RelZ - 4;
+ if (MinZ < 0) // Check if the coordinate is outside the chunk. If it it then adjust it.
+ {
+ MinZ = 0;
+ }
+
+ int MaxZ = a_RelZ + 4;
+ if (MaxZ > cChunkDef::Width) // Check if the coordinate is outside the chunk. If it it then adjust it.
+ {
+ MaxZ = cChunkDef::Width;
+ }
+
+ int MinY = a_RelY - 2;
+ if (MinY < 0) // Check if the coordinate is outside the chunk. If it it then adjust it.
+ {
+ MinY = 0;
+ }
+
+ int MaxY = a_RelY + 2;
+ if (MaxY > cChunkDef::Height) // Check if the coordinate is outside the chunk. If it it then adjust it.
+ {
+ MaxY = cChunkDef::Height;
+ }
+
+ for (int x = MinX; x < MaxX; x++)
+ {
+ int xx = a_ChunkDesc.GetChunkX() * cChunkDef::Width + x;
+ for (int z = MinZ; z < MaxZ; z++)
{
- float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z;
- for (int y = a_RelY - 2; y < a_RelY + 2; y++)
+ int zz = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z;
+ for (int y = MinY; y < MaxY; y++)
{
- if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks.
+ if (
+ ((x < 0) || (x >= cChunkDef::Width)) ||
+ ((y < 0) || (y >= cChunkDef::Height)) ||
+ ((z < 0) || (z >= cChunkDef::Width))
+ )
+ {
+ continue;
+ }
+
+ if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks.
{
continue;
}
BLOCKTYPE BlockBelow = a_ChunkDesc.GetBlockType(x, y - 1, z);
- if (!cBlockInfo::IsSolid(BlockBelow)) // Only place on solid blocks
+ if (!cBlockInfo::FullyOccupiesVoxel(BlockBelow)) // Only place on solid blocks
{
continue;
}
- if (IsFireBlock) // don't place fire on non-forever burning blocks.
+ if (IsFireBlock) // don't place fire on non-forever burning blocks.
{
if (!cFireSimulator::DoesBurnForever(BlockBelow))
{
@@ -144,9 +163,8 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a
}
}
-
- NOISE_DATATYPE Val = m_Noise.CubicNoise2D(xx, zz);
- if (Val < -0.70)
+ NOISE_DATATYPE Val = m_Noise.IntNoise2D(xx, zz);
+ if (Val < -0.5)
{
a_ChunkDesc.SetBlockType(x, y, z, a_Block);
}
@@ -159,7 +177,66 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// cFinishGenTallGrass:
+
+void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
+{
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int xx = x + a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ int zz = z + a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ int BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z));
+
+ // Choose if we want to place long grass here. If not then bail out:
+ if ((m_Noise.IntNoise2DInt(xx + m_Noise.IntNoise1DInt(xx), zz + m_Noise.IntNoise1DInt(zz)) / 7 % 100) > BiomeDensity)
+ {
+ continue;
+ }
+
+ // Get the top block + 1. This is the place where the grass would finaly be placed:
+ int y = a_ChunkDesc.GetHeight(x, z) + 1;
+
+ // Check if long grass can be placed:
+ if (
+ (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) ||
+ ((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT))
+ )
+ {
+ continue;
+ }
+
+ // Choose what long grass meta we should use:
+ int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100;
+ if (GrassType < 60)
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1);
+ }
+ else if (GrassType < 90)
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2);
+ }
+ else
+ {
+ // If double long grass we have to choose what type we should use:
+ if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR)
+ {
+ NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3;
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta);
+ a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8);
+ }
+ }
+ }
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cFinishGenSprinkleFoliage:
bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ)
@@ -193,8 +270,8 @@ bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_
if (
!IsWater(a_ChunkDesc.GetBlockType(a_RelX - 1, a_RelY, a_RelZ)) &&
!IsWater(a_ChunkDesc.GetBlockType(a_RelX + 1, a_RelY, a_RelZ)) &&
- !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ - 1)) &&
- !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ + 1))
+ !IsWater(a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ - 1)) &&
+ !IsWater(a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ + 1))
)
{
return false;
@@ -214,7 +291,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
// Generate small foliage (1-block):
// TODO: Update heightmap with 1-block-tall foliage
- for (int z = 0; z < cChunkDef::Width; z++)
+ for (int z = 0; z < cChunkDef::Width; z++)
{
int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z;
const float zz = (float)BlockZ;
@@ -239,14 +316,14 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
}
const float xx = (float)BlockX;
- float val1 = m_Noise.CubicNoise2D(xx * 0.1f, zz * 0.1f );
- float val2 = m_Noise.CubicNoise2D(xx * 0.01f, zz * 0.01f );
+ float val1 = m_Noise.CubicNoise2D(xx * 0.1f, zz * 0.1f);
+ float val2 = m_Noise.CubicNoise2D(xx * 0.01f, zz * 0.01f);
switch (a_ChunkDesc.GetBlockType(x, Top, z))
{
case E_BLOCK_GRASS:
{
- float val3 = m_Noise.CubicNoise2D(xx * 0.01f + 10, zz * 0.01f + 10 );
- float val4 = m_Noise.CubicNoise2D(xx * 0.05f + 20, zz * 0.05f + 20 );
+ float val3 = m_Noise.CubicNoise2D(xx * 0.01f + 10, zz * 0.01f + 10);
+ float val4 = m_Noise.CubicNoise2D(xx * 0.05f + 20, zz * 0.05f + 20);
if (val1 + val2 > 0.2f)
{
a_ChunkDesc.SetBlockType(x, ++Top, z, E_BLOCK_YELLOW_FLOWER);
@@ -309,7 +386,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFinishGenSnow:
void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc)
@@ -345,7 +422,7 @@ void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFinishGenIce:
void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc)
@@ -385,15 +462,15 @@ void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cFinishGenLilypads:
+////////////////////////////////////////////////////////////////////////////////
+// cFinishGenSingleTopBlock:
-int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap)
+int cFinishGenSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap)
{
int res = 0;
for (size_t i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
{
- if (a_BiomeMap[i] == m_Biome)
+ if (IsAllowedBiome(a_BiomeMap[i]))
{
res++;
}
@@ -405,7 +482,7 @@ int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap &
-void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc)
+void cFinishGenSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc)
{
// Add Lilypads on top of water surface in Swampland
@@ -418,11 +495,13 @@ void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc)
int z = (m_Noise.IntNoise3DInt(ChunkX - ChunkZ, i, ChunkZ) / 11) % cChunkDef::Width;
// Place the block at {x, z} if possible:
- if (a_ChunkDesc.GetBiome(x, z) != m_Biome)
+ EMCSBiome Biome = a_ChunkDesc.GetBiome(x, z);
+ if (!IsAllowedBiome(Biome))
{
// Incorrect biome
continue;
}
+
int Height = a_ChunkDesc.GetHeight(x, z);
if (Height >= cChunkDef::Height)
{
@@ -434,20 +513,23 @@ void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc)
// Not an empty block
continue;
}
+
BLOCKTYPE BlockBelow = a_ChunkDesc.GetBlockType(x, Height, z);
- if ((BlockBelow == m_AllowedBelow1) || (BlockBelow == m_AllowedBelow2))
+ if (!IsAllowedBlockBelow(BlockBelow))
{
- a_ChunkDesc.SetBlockType(x, Height + 1, z, m_BlockType);
- a_ChunkDesc.SetHeight(x, z, Height + 1);
+ continue;
}
- } // for i
+
+ a_ChunkDesc.SetBlockType(x, Height + 1, z, m_BlockType);
+ a_ChunkDesc.SetHeight(x, z, Height + 1);
+ }
}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFinishGenBottomLava:
void cFinishGenBottomLava::GenFinish(cChunkDesc & a_ChunkDesc)
@@ -470,7 +552,7 @@ void cFinishGenBottomLava::GenFinish(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFinishGenPreSimulator:
cFinishGenPreSimulator::cFinishGenPreSimulator(void)
@@ -637,7 +719,7 @@ void cFinishGenPreSimulator::StationarizeFluid(
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFinishGenFluidSprings:
cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, eDimension a_Dimension) :
@@ -678,7 +760,7 @@ cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cI
AString HeightDistribution = a_IniFile.GetValueSet(SectionName, "HeightDistribution", DefaultHeightDistribution);
if (!m_HeightDistribution.SetDefString(HeightDistribution) || (m_HeightDistribution.GetSum() <= 0))
{
- LOGWARNING("[%sSprings]: HeightDistribution is invalid, using the default of \"%s\".",
+ LOGWARNING("[%sSprings]: HeightDistribution is invalid, using the default of \"%s\".",
(a_Fluid == E_BLOCK_WATER) ? "Water" : "Lava",
DefaultHeightDistribution.c_str()
);
diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h
index 2e5732929..ed32768b3 100644
--- a/src/Generating/FinishGen.h
+++ b/src/Generating/FinishGen.h
@@ -69,6 +69,54 @@ protected:
+class cFinishGenTallGrass :
+ public cFinishGen
+{
+public:
+ cFinishGenTallGrass(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {}
+
+protected:
+ cNoise m_Noise;
+ int m_Seed;
+
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
+
+ int GetBiomeDensity(EMCSBiome a_Biome)
+ {
+ switch (a_Biome)
+ {
+ case biSavanna:
+ case biSavannaM:
+ case biSavannaPlateau:
+ case biSavannaPlateauM:
+ case biPlains:
+ {
+ return 70;
+ }
+
+ case biExtremeHillsEdge:
+ case biExtremeHillsPlus:
+ case biExtremeHills:
+ case biExtremeHillsPlusM:
+ case biExtremeHillsM:
+ case biIceMountains:
+ {
+ return 3;
+ }
+
+ default:
+ {
+ return 20;
+ }
+ }
+ }
+};
+
+
+
+
+
class cFinishGenSprinkleFoliage :
public cFinishGen
{
@@ -95,32 +143,69 @@ Used for:
- Lilypads finisher
- DeadBushes finisher
*/
-class cFinishGenSingleBiomeSingleTopBlock :
+class cFinishGenSingleTopBlock :
public cFinishGen
{
public:
- cFinishGenSingleBiomeSingleTopBlock(
- int a_Seed, BLOCKTYPE a_BlockType, EMCSBiome a_Biome, int a_Amount,
- BLOCKTYPE a_AllowedBelow1, BLOCKTYPE a_AllowedBelow2
+ typedef std::vector<BLOCKTYPE> BlockList;
+ bool m_IsAllowedBelow[256];
+
+ typedef std::vector<EMCSBiome> BiomeList;
+ bool m_IsBiomeAllowed[256];
+
+
+ cFinishGenSingleTopBlock(
+ int a_Seed, BLOCKTYPE a_BlockType, BiomeList a_Biomes, int a_Amount,
+ BlockList a_AllowedBelow
) :
m_Noise(a_Seed),
m_BlockType(a_BlockType),
- m_Biome(a_Biome),
- m_Amount(a_Amount),
- m_AllowedBelow1(a_AllowedBelow1),
- m_AllowedBelow2(a_AllowedBelow2)
+ m_Amount(a_Amount)
{
+ // Initialize all the block types.
+ for (int idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx)
+ {
+ m_IsAllowedBelow[idx] = false;
+ }
+
+ // Load the allowed blocks into m_IsAllowedBelow
+ for (BlockList::iterator itr = a_AllowedBelow.begin(); itr != a_AllowedBelow.end(); ++itr)
+ {
+ m_IsAllowedBelow[*itr] = true;
+ }
+
+ // Initialize all the biome types.
+ for (int idx = 0; idx < ARRAYCOUNT(m_IsBiomeAllowed); ++idx)
+ {
+ m_IsBiomeAllowed[idx] = false;
+ }
+
+ // Load the allowed biomes into m_IsBiomeAllowed
+ for (BiomeList::iterator itr = a_Biomes.begin(); itr != a_Biomes.end(); ++itr)
+ {
+ m_IsBiomeAllowed[*itr] = true;
+ }
}
protected:
cNoise m_Noise;
BLOCKTYPE m_BlockType;
- EMCSBiome m_Biome;
int m_Amount; ///< Relative amount of blocks to try adding. 1 = one block per 256 biome columns.
- BLOCKTYPE m_AllowedBelow1; ///< First of the two blocktypes that are allowed below m_BlockType
- BLOCKTYPE m_AllowedBelow2; ///< Second of the two blocktypes that are allowed below m_BlockType
int GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap);
+
+ // Returns true if the given biome is a biome that is allowed.
+ inline bool IsAllowedBiome(EMCSBiome a_Biome)
+ {
+ return m_IsBiomeAllowed[a_Biome];
+ }
+
+ // Returns true if the given blocktype may be below m_BlockType
+ inline bool IsAllowedBlockBelow(BLOCKTYPE a_BlockBelow)
+ {
+ return m_IsAllowedBelow[a_BlockBelow];
+ }
+
// cFinishGen override:
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
@@ -199,7 +284,7 @@ protected:
// cFinishGen override:
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
- /// Tries to place a spring at the specified coords, checks neighbors. Returns true if successful
+ /// Tries to place a spring at the specified coords, checks neighbors. Returns true if successful
bool TryPlaceSpring(cChunkDesc & a_ChunkDesc, int x, int y, int z);
} ;
diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp
new file mode 100644
index 000000000..7090f14b1
--- /dev/null
+++ b/src/Generating/GridStructGen.cpp
@@ -0,0 +1,184 @@
+
+// GridStructGen.cpp
+
+// Implements the cGridStructGen class representing a common base class for structure generators that place structures in a semi-random grid
+
+#include "Globals.h"
+#include "GridStructGen.h"
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEmptyStructure:
+
+/** A cStructure descendant representing an empty structure.
+Used when the generator descended from cGridStructGen doesn't return any structure, to keep at least the
+Origin coords so that the structure isn't queried over and over again. */
+class cEmptyStructure :
+ public cGridStructGen::cStructure
+{
+ typedef cGridStructGen::cStructure super;
+
+public:
+ cEmptyStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) :
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ)
+ {
+ }
+
+protected:
+ virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override
+ {
+ // Do nothing
+ }
+} ;
+
+
+
+
+
+cGridStructGen::cGridStructGen(
+ int a_Seed,
+ int a_GridSizeX, int a_GridSizeZ,
+ int a_MaxOffsetX, int a_MaxOffsetZ,
+ int a_MaxStructureSizeX, int a_MaxStructureSizeZ,
+ size_t a_MaxCacheSize
+) :
+ m_Seed(a_Seed),
+ m_Noise(a_Seed),
+ m_GridSizeX(a_GridSizeX),
+ m_GridSizeZ(a_GridSizeZ),
+ m_MaxOffsetX(a_MaxOffsetX),
+ m_MaxOffsetZ(a_MaxOffsetZ),
+ m_MaxStructureSizeX(a_MaxStructureSizeX),
+ m_MaxStructureSizeZ(a_MaxStructureSizeZ),
+ m_MaxCacheSize(a_MaxCacheSize)
+{
+ if (m_GridSizeX == 0)
+ {
+ LOG("Grid Size cannot be zero, setting to 1");
+ m_GridSizeX = 1;
+ }
+ if (m_GridSizeZ == 0)
+ {
+ LOG("Grid Size cannot be zero, setting to 1");
+ m_GridSizeZ = 1;
+ }
+ size_t NumStructuresPerQuery = (size_t)(((m_MaxStructureSizeX + m_MaxOffsetX) / m_GridSizeX + 1) * ((m_MaxStructureSizeZ + m_MaxOffsetZ) / m_GridSizeZ + 1));
+ if (NumStructuresPerQuery > m_MaxCacheSize)
+ {
+ m_MaxCacheSize = NumStructuresPerQuery * 4;
+ LOGINFO(
+ "cGridStructGen: The cache size is too small (%u), increasing the cache size to %u to avoid inefficiency.",
+ (unsigned)a_MaxCacheSize, (unsigned)m_MaxCacheSize
+ );
+ }
+}
+
+
+
+
+
+void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructurePtrs & a_Structures)
+{
+ // Calculate the min and max grid coords of the structures to be returned:
+ int MinBlockX = a_ChunkX * cChunkDef::Width - m_MaxStructureSizeX - m_MaxOffsetX;
+ int MinBlockZ = a_ChunkZ * cChunkDef::Width - m_MaxStructureSizeZ - m_MaxOffsetZ;
+ int MaxBlockX = a_ChunkX * cChunkDef::Width + m_MaxStructureSizeX + m_MaxOffsetX + cChunkDef::Width - 1;
+ int MaxBlockZ = a_ChunkZ * cChunkDef::Width + m_MaxStructureSizeZ + m_MaxOffsetZ + cChunkDef::Width - 1;
+ int MinGridX = MinBlockX / m_GridSizeX;
+ int MinGridZ = MinBlockZ / m_GridSizeZ;
+ int MaxGridX = (MaxBlockX + m_GridSizeX - 1) / m_GridSizeX;
+ int MaxGridZ = (MaxBlockZ + m_GridSizeZ - 1) / m_GridSizeZ;
+ int MinX = MinGridX * m_GridSizeX;
+ int MaxX = MaxGridX * m_GridSizeX;
+ int MinZ = MinGridZ * m_GridSizeZ;
+ int MaxZ = MaxGridZ * m_GridSizeZ;
+
+ // Walk the cache, move each structure that we want into a_Structures:
+ for (cStructurePtrs::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;)
+ {
+ if (
+ ((*itr)->m_GridX >= MinX) && ((*itr)->m_GridX < MaxX) &&
+ ((*itr)->m_GridZ >= MinZ) && ((*itr)->m_GridZ < MaxZ)
+ )
+ {
+ // want
+ a_Structures.push_back(*itr);
+ itr = m_Cache.erase(itr);
+ }
+ else
+ {
+ // don't want
+ ++itr;
+ }
+ } // for itr - m_Cache[]
+
+ // Create those structures that haven't been in the cache:
+ for (int x = MinGridX; x < MaxGridX; x++)
+ {
+ int GridX = x * m_GridSizeX;
+ for (int z = MinGridZ; z < MaxGridZ; z++)
+ {
+ int GridZ = z * m_GridSizeZ;
+ bool Found = false;
+ for (cStructurePtrs::const_iterator itr = a_Structures.begin(), end = a_Structures.end(); itr != end; ++itr)
+ {
+ if (((*itr)->m_GridX == GridX) && ((*itr)->m_GridZ == GridZ))
+ {
+ Found = true;
+ break;
+ }
+ } // for itr - a_Structures[]
+ if (!Found)
+ {
+ int OriginX = GridX + ((m_Noise.IntNoise2DInt(GridX + 3, GridZ + 5) / 7) % (m_MaxOffsetX * 2)) - m_MaxOffsetX;
+ int OriginZ = GridZ + ((m_Noise.IntNoise2DInt(GridX + 5, GridZ + 3) / 7) % (m_MaxOffsetZ * 2)) - m_MaxOffsetZ;
+ cStructurePtr Structure = CreateStructure(GridX, GridZ, OriginX, OriginZ);
+ if (Structure.get() == NULL)
+ {
+ Structure.reset(new cEmptyStructure(GridX, GridZ, OriginX, OriginZ));
+ }
+ a_Structures.push_back(Structure);
+ }
+ } // for z
+ } // for x
+
+ // Copy a_Forts into m_Cache to the beginning:
+ cStructurePtrs StructuresCopy (a_Structures);
+ m_Cache.splice(m_Cache.begin(), StructuresCopy, StructuresCopy.begin(), StructuresCopy.end());
+
+ // Trim the cache if it's too long:
+ size_t CacheSize = 0;
+ for (cStructurePtrs::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end; ++itr)
+ {
+ CacheSize += (*itr)->GetCacheCost();
+ if (CacheSize > m_MaxCacheSize)
+ {
+ // Erase all items from this one till the cache end
+ m_Cache.erase(itr, m_Cache.end());
+ break;
+ }
+ }
+}
+
+
+
+
+
+void cGridStructGen::GenFinish(cChunkDesc & a_ChunkDesc)
+{
+ int ChunkX = a_ChunkDesc.GetChunkX();
+ int ChunkZ = a_ChunkDesc.GetChunkZ();
+ cStructurePtrs Structures;
+ GetStructuresForChunk(ChunkX, ChunkZ, Structures);
+ for (cStructurePtrs::const_iterator itr = Structures.begin(); itr != Structures.end(); ++itr)
+ {
+ (*itr)->DrawIntoChunk(a_ChunkDesc);
+ } // for itr - Structures[]
+}
+
+
+
+
+
diff --git a/src/Generating/GridStructGen.h b/src/Generating/GridStructGen.h
new file mode 100644
index 000000000..03131fce9
--- /dev/null
+++ b/src/Generating/GridStructGen.h
@@ -0,0 +1,145 @@
+
+// GridStructGen.h
+
+// Declares the cGridStructGen class representing a common base class for structure generators that place structures in a semi-random grid
+
+
+
+
+
+#pragma once
+
+#include "ComposableGenerator.h"
+#include "../Noise.h"
+
+
+
+
+
+/** Generates structures in a semi-random grid.
+Defines a grid in the XZ space with predefined cell size in each direction. Each cell then receives exactly
+one structure (provided by the descendant class). The structure is placed within the cell, but doesn't need
+to be bounded by the cell, it can be well outside the cell; the generator uses the MaxStructureSize parameter
+to determine how far away from the cell the structure can be at most. Each structure has an offset from the
+grid's center point, the offset is generated randomly from a range given to this class as a parameter.
+
+Each structure thus contains the coords of its grid center (m_GridX, m_GridZ) and the actual origin from
+which it's built (m_OriginX, m_OriginZ).
+
+This class provides a cache for the structures generated for successive chunks and manages that cache. It
+also provides the cFinishGen override that uses the cache to actually generate the structure into chunk data.
+
+After generating each chunk the cache is checked for size, each item in the cache has a cost associated with
+it and the cache is trimmed (from its least-recently-used end) so that the sum of the cost in the cache is
+less than m_MaxCacheSize
+
+To use this class, declare a descendant class that implements the overridable methods, then create an
+instance of that class. The descendant must provide the CreateStructure() function that is called to generate
+a structure at the specific grid cell.
+
+The descendant must use a specific cStructure descendant to provide the actual structure that gets generated.
+The structure must provide the DrawIntoChunk() function that generates the structure into the chunk data, and
+can override the GetCacheCost() function that returns the cost of that structure in the cache.
+*/
+class cGridStructGen :
+ public cFinishGen
+{
+public:
+ /** Represents a single structure that occupies the grid point. Knows how to draw itself into a chunk. */
+ class cStructure
+ {
+ public:
+ /** The grid point for which the structure is generated. */
+ int m_GridX, m_GridZ;
+
+ /** The origin (the coords for which the structure is generated) */
+ int m_OriginX, m_OriginZ;
+
+
+ /** Creates a structure that has its origin set at the specified coords. */
+ cStructure (int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) :
+ m_GridX(a_GridX),
+ m_GridZ(a_GridZ),
+ m_OriginX(a_OriginX),
+ m_OriginZ(a_OriginZ)
+ {
+ }
+
+ // Force a virtual destructor in descendants:
+ virtual ~cStructure() {}
+
+ /** Draws self into the specified chunk */
+ virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) = 0;
+
+ /** Returns the cost of keeping this structure in the cache */
+ virtual size_t GetCacheCost(void) const { return 1; }
+ } ;
+ typedef SharedPtr<cStructure> cStructurePtr;
+ typedef std::list<cStructurePtr> cStructurePtrs;
+
+
+ cGridStructGen(
+ int a_Seed,
+ int a_GridSizeX, int a_GridSizeZ,
+ int a_MaxOffsetX, int a_MaxOffsetZ,
+ int a_MaxStructureSizeX, int a_MaxStructureSizeZ,
+ size_t a_MaxCacheSize
+ );
+
+protected:
+ /** Seed for generating grid offsets and also available for descendants. */
+ int m_Seed;
+
+ /** The noise used for generating grid offsets. */
+ cNoise m_Noise;
+
+ /** The size of each grid's cell in the X axis */
+ int m_GridSizeX;
+
+ /** The size of each grid's cell in the Z axis */
+ int m_GridSizeZ;
+
+ /** The maximum offset of the structure's origin from the grid midpoint, in X coord. */
+ int m_MaxOffsetX;
+
+ /** The maximum offset of the structure's origin from the grid midpoint, in Z coord. */
+ int m_MaxOffsetZ;
+
+ /** Maximum theoretical size of the structure in the X axis.
+ This limits the structures considered for a single chunk, so the lesser the number, the better performance.
+ Structures large than this may get cropped. */
+ int m_MaxStructureSizeX;
+
+ /** Maximum theoretical size of the structure in the Z axis.
+ This limits the structures considered for a single chunk, so the lesser the number, the better performance.
+ Structures large than this may get cropped. */
+ int m_MaxStructureSizeZ;
+
+ /** Maximum allowed sum of costs for items in the cache. Items that are over this cost are removed from the
+ cache, oldest-first */
+ size_t m_MaxCacheSize;
+
+ /** Cache for the most recently generated structures, ordered by the recentness. */
+ cStructurePtrs m_Cache;
+
+
+ /** Clears everything from the cache */
+ void ClearCache(void);
+
+ /** Returns all structures that may intersect the given chunk.
+ The structures are considered as intersecting iff their bounding box (defined by m_MaxStructureSize)
+ around their gridpoint intersects the chunk. */
+ void GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructurePtrs & a_Structures);
+
+ // cFinishGen overrides:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
+
+ // Functions for the descendants to override:
+ /** Create a new structure at the specified gridpoint */
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) = 0;
+} ;
+
+
+
+
+
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index 3621421c2..870ceef7f 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -16,7 +16,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cTerrainHeightGen:
cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBiomeGen & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault)
@@ -47,6 +47,10 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio
{
res = new cEndGen(a_Seed);
}
+ else if (NoCaseCompare(HeightGenName, "Mountains") == 0)
+ {
+ res = new cHeiGenMountains(a_Seed);
+ }
else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
{
res = new cNoise3DComposable(a_Seed);
@@ -87,7 +91,7 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHeiGenFlat:
void cHeiGenFlat::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
@@ -111,7 +115,7 @@ void cHeiGenFlat::InitializeHeightGen(cIniFile & a_IniFile)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHeiGenCache:
cHeiGenCache::cHeiGenCache(cTerrainHeightGen & a_HeiGenToCache, int a_CacheSize) :
@@ -138,7 +142,9 @@ cHeiGenCache::cHeiGenCache(cTerrainHeightGen & a_HeiGenToCache, int a_CacheSize)
cHeiGenCache::~cHeiGenCache()
{
delete[] m_CacheData;
+ m_CacheData = NULL;
delete[] m_CacheOrder;
+ m_CacheOrder = NULL;
}
@@ -228,7 +234,7 @@ bool cHeiGenCache::GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_Rel
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHeiGenClassic:
cHeiGenClassic::cHeiGenClassic(int a_Seed) :
@@ -247,9 +253,9 @@ float cHeiGenClassic::GetNoise(float x, float y)
float oct2 = m_Noise.CubicNoise2D(x * m_HeightFreq2, y * m_HeightFreq2) * m_HeightAmp2;
float oct3 = m_Noise.CubicNoise2D(x * m_HeightFreq3, y * m_HeightFreq3) * m_HeightAmp3;
- float height = m_Noise.CubicNoise2D(x * 0.1f, y * 0.1f ) * 2;
+ float height = m_Noise.CubicNoise2D(x * 0.1f, y * 0.1f) * 2;
- float flatness = ((m_Noise.CubicNoise2D(x * 0.5f, y * 0.5f) + 1.f) * 0.5f) * 1.1f; // 0 ... 1.5
+ float flatness = ((m_Noise.CubicNoise2D(x * 0.5f, y * 0.5f) + 1.f) * 0.5f) * 1.1f; // 0 ... 1.5
flatness *= flatness * flatness;
return (oct1 + oct2 + oct3) * flatness + height;
@@ -261,7 +267,7 @@ float cHeiGenClassic::GetNoise(float x, float y)
void cHeiGenClassic::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
{
- for (int z = 0; z < cChunkDef::Width; z++)
+ for (int z = 0; z < cChunkDef::Width; z++)
{
const float zz = (float)(a_ChunkZ * cChunkDef::Width + z);
for (int x = 0; x < cChunkDef::Width; x++)
@@ -277,7 +283,7 @@ void cHeiGenClassic::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightM
{
hei = 250;
}
- cChunkDef::SetHeight(a_HeightMap, x , z, hei);
+ cChunkDef::SetHeight(a_HeightMap, x, z, hei);
} // for x
} // for z
}
@@ -300,7 +306,69 @@ void cHeiGenClassic::InitializeHeightGen(cIniFile & a_IniFile)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// cHeiGenMountains:
+
+cHeiGenMountains::cHeiGenMountains(int a_Seed) :
+ m_Seed(a_Seed),
+ m_Noise(a_Seed)
+{
+}
+
+
+
+
+
+void cHeiGenMountains::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
+{
+ NOISE_DATATYPE StartX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width);
+ NOISE_DATATYPE EndX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + cChunkDef::Width - 1);
+ NOISE_DATATYPE StartZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width);
+ NOISE_DATATYPE EndZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + cChunkDef::Width - 1);
+ NOISE_DATATYPE Workspace[16 * 16];
+ NOISE_DATATYPE Noise[16 * 16];
+ NOISE_DATATYPE PerlinNoise[16 * 16];
+ m_Noise.Generate2D(Noise, 16, 16, StartX, EndX, StartZ, EndZ, Workspace);
+ m_Perlin.Generate2D(PerlinNoise, 16, 16, StartX, EndX, StartZ, EndZ, Workspace);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ int IdxZ = z * cChunkDef::Width;
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int idx = IdxZ + x;
+ int hei = 100 - (int)((Noise[idx] + PerlinNoise[idx]) * 15);
+ if (hei < 10)
+ {
+ hei = 10;
+ }
+ if (hei > 250)
+ {
+ hei = 250;
+ }
+ cChunkDef::SetHeight(a_HeightMap, x, z, hei);
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cHeiGenMountains::InitializeHeightGen(cIniFile & a_IniFile)
+{
+ // TODO: Read the params from an INI file
+ m_Noise.AddOctave(0.1f, 0.1f);
+ m_Noise.AddOctave(0.05f, 0.5f);
+ m_Noise.AddOctave(0.02f, 1.5f);
+
+ m_Perlin.AddOctave(0.01f, 1.5f);
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cHeiGenBiomal:
const cHeiGenBiomal::sGenParam cHeiGenBiomal::m_GenParam[256] =
diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h
index 1376f2a25..5c106c7d9 100644
--- a/src/Generating/HeiGen.h
+++ b/src/Generating/HeiGen.h
@@ -106,6 +106,27 @@ protected:
+class cHeiGenMountains :
+ public cTerrainHeightGen
+{
+public:
+ cHeiGenMountains(int a_Seed);
+
+protected:
+
+ int m_Seed;
+ cRidgedMultiNoise m_Noise;
+ cPerlinNoise m_Perlin;
+
+ // cTerrainHeightGen overrides:
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
+ virtual void InitializeHeightGen(cIniFile & a_IniFile) override;
+} ;
+
+
+
+
+
class cHeiGenBiomal :
public cTerrainHeightGen
{
diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp
index 231295c3f..0532aff39 100644
--- a/src/Generating/MineShafts.cpp
+++ b/src/Generating/MineShafts.cpp
@@ -25,12 +25,6 @@ in a depth-first processing. Each of the descendants will branch randomly, if no
-static const int NEIGHBORHOOD_SIZE = 3;
-
-
-
-
-
class cMineShaft abstract
{
public:
@@ -234,10 +228,12 @@ protected:
-class cStructGenMineShafts::cMineShaftSystem
+class cStructGenMineShafts::cMineShaftSystem :
+ public cGridStructGen::cStructure
{
+ typedef cGridStructGen::cStructure super;
+
public:
- int m_BlockX, m_BlockZ; ///< The pivot point on which the system is generated
int m_GridSize; ///< Maximum offset of the dirtroom from grid center, * 2, in each direction
int m_MaxRecursion; ///< Maximum recursion level (initialized from cStructGenMineShafts::m_MaxRecursion)
int m_ProbLevelCorridor; ///< Probability level of a branch object being the corridor
@@ -249,17 +245,16 @@ public:
cMineShafts m_MineShafts; ///< List of cMineShaft descendants that comprise this system
cCuboid m_BoundingBox; ///< Bounding box into which all of the components need to fit
- /// Creates and generates the entire system
+
+ /** Creates and generates the entire system */
cMineShaftSystem(
- int a_BlockX, int a_BlockZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise,
+ int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ,
+ int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise,
int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase
);
~cMineShaftSystem();
- /// Carves the system into the chunk data
- void ProcessChunk(cChunkDesc & a_Chunk);
-
/** Creates new cMineShaft descendant connected at the specified point, heading the specified direction,
if it fits, appends it to the list and calls its AppendBranches()
*/
@@ -269,23 +264,26 @@ public:
int a_RecursionLevel
);
- /// Returns true if none of the objects in m_MineShafts intersect with the specified bounding box and the bounding box is valid
+ /** Returns true if none of the objects in m_MineShafts intersect with the specified bounding box and the bounding box is valid */
bool CanAppend(const cCuboid & a_BoundingBox);
+
+ // cGridStructGen::cStructure overrides:
+ virtual void DrawIntoChunk(cChunkDesc & a_Chunk);
} ;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenMineShafts::cMineShaftSystem:
cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem(
- int a_BlockX, int a_BlockZ, int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise,
+ int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ,
+ int a_GridSize, int a_MaxSystemSize, cNoise & a_Noise,
int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase
) :
- m_BlockX(a_BlockX),
- m_BlockZ(a_BlockZ),
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
m_GridSize(a_GridSize),
m_MaxRecursion(8), // TODO: settable
m_ProbLevelCorridor(a_ProbLevelCorridor),
@@ -330,7 +328,7 @@ cStructGenMineShafts::cMineShaftSystem::~cMineShaftSystem()
-void cStructGenMineShafts::cMineShaftSystem::ProcessChunk(cChunkDesc & a_Chunk)
+void cStructGenMineShafts::cMineShaftSystem::DrawIntoChunk(cChunkDesc & a_Chunk)
{
for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
{
@@ -402,22 +400,22 @@ bool cStructGenMineShafts::cMineShaftSystem::CanAppend(const cCuboid & a_Boundin
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMineShaftDirtRoom:
cMineShaftDirtRoom::cMineShaftDirtRoom(cStructGenMineShafts::cMineShaftSystem & a_Parent, cNoise & a_Noise) :
super(a_Parent, mskDirtRoom)
{
// Make the room of random size, min 10 x 4 x 10; max 18 x 12 x 18:
- int rnd = a_Noise.IntNoise3DInt(a_Parent.m_BlockX, 0, a_Parent.m_BlockZ) / 7;
+ int rnd = a_Noise.IntNoise3DInt(a_Parent.m_OriginX, 0, a_Parent.m_OriginZ) / 7;
int OfsX = (rnd % a_Parent.m_GridSize) - a_Parent.m_GridSize / 2;
rnd >>= 12;
int OfsZ = (rnd % a_Parent.m_GridSize) - a_Parent.m_GridSize / 2;
- rnd = a_Noise.IntNoise3DInt(a_Parent.m_BlockX, 1000, a_Parent.m_BlockZ) / 11;
- m_BoundingBox.p1.x = a_Parent.m_BlockX + OfsX;
+ rnd = a_Noise.IntNoise3DInt(a_Parent.m_OriginX, 1000, a_Parent.m_OriginZ) / 11;
+ m_BoundingBox.p1.x = a_Parent.m_OriginX + OfsX;
m_BoundingBox.p2.x = m_BoundingBox.p1.x + 10 + (rnd % 8);
rnd >>= 4;
- m_BoundingBox.p1.z = a_Parent.m_BlockZ + OfsZ;
+ m_BoundingBox.p1.z = a_Parent.m_OriginZ + OfsZ;
m_BoundingBox.p2.z = m_BoundingBox.p1.z + 10 + (rnd % 8);
rnd >>= 4;
m_BoundingBox.p1.y = 20;
@@ -494,7 +492,7 @@ void cMineShaftDirtRoom::ProcessChunk(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMineShaftCorridor:
cMineShaftCorridor::cMineShaftCorridor(
@@ -543,7 +541,7 @@ cMineShaft * cMineShaftCorridor::CreateAndFit(
{
cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ);
BoundingBox.p2.y += 3;
- int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
+ int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
int NumSegments = 2 + (rnd) % (MAX_SEGMENTS - 1); // 2 .. MAX_SEGMENTS
switch (a_Direction)
{
@@ -734,7 +732,7 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc)
PlaceChest(a_ChunkDesc);
PlaceTracks(a_ChunkDesc);
- PlaceSpawner(a_ChunkDesc); // (must be after Tracks!)
+ PlaceSpawner(a_ChunkDesc); // (must be after Tracks!)
PlaceTorches(a_ChunkDesc);
}
@@ -966,7 +964,7 @@ void cMineShaftCorridor::PlaceTorches(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMineShaftCrossing:
cMineShaftCrossing::cMineShaftCrossing(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox) :
@@ -985,7 +983,7 @@ cMineShaft * cMineShaftCrossing::CreateAndFit(
)
{
cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ);
- int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
+ int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
BoundingBox.p2.y += 3;
if ((rnd % 4) < 2)
{
@@ -999,7 +997,6 @@ cMineShaft * cMineShaftCrossing::CreateAndFit(
BoundingBox.p2.y -= 4;
}
}
- rnd >>= 2;
switch (a_Direction)
{
case dirXP: BoundingBox.p2.x += 4; BoundingBox.p1.z -= 2; BoundingBox.p2.z += 2; break;
@@ -1102,7 +1099,7 @@ void cMineShaftCrossing::ProcessChunk(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMineShaftStaircase:
cMineShaftStaircase::cMineShaftStaircase(
@@ -1127,7 +1124,7 @@ cMineShaft * cMineShaftStaircase::CreateAndFit(
cNoise & a_Noise
)
{
- int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
+ int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
cCuboid Box;
switch (a_Direction)
{
@@ -1280,13 +1277,14 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenMineShafts:
cStructGenMineShafts::cStructGenMineShafts(
- int a_Seed, int a_GridSize, int a_MaxSystemSize,
+ int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxSystemSize,
int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase
) :
+ super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSystemSize, a_MaxSystemSize, 100),
m_Noise(a_Seed),
m_GridSize(a_GridSize),
m_MaxSystemSize(a_MaxSystemSize),
@@ -1300,125 +1298,9 @@ cStructGenMineShafts::cStructGenMineShafts(
-cStructGenMineShafts::~cStructGenMineShafts()
-{
- ClearCache();
-}
-
-
-
-
-
-void cStructGenMineShafts::ClearCache(void)
-{
- for (cMineShaftSystems::const_iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end; ++itr)
- {
- delete *itr;
- } // for itr - m_Cache[]
- m_Cache.clear();
-}
-
-
-
-
-
-void cStructGenMineShafts::GetMineShaftSystemsForChunk(
- int a_ChunkX, int a_ChunkZ,
- cStructGenMineShafts::cMineShaftSystems & a_MineShafts
-)
-{
- int BaseX = a_ChunkX * cChunkDef::Width / m_GridSize;
- int BaseZ = a_ChunkZ * cChunkDef::Width / m_GridSize;
- if (BaseX < 0)
- {
- --BaseX;
- }
- if (BaseZ < 0)
- {
- --BaseZ;
- }
- BaseX -= NEIGHBORHOOD_SIZE / 2;
- BaseZ -= NEIGHBORHOOD_SIZE / 2;
-
- // Walk the cache, move each cave system that we want into a_Mineshafts:
- int StartX = BaseX * m_GridSize;
- int EndX = (BaseX + NEIGHBORHOOD_SIZE + 1) * m_GridSize;
- int StartZ = BaseZ * m_GridSize;
- int EndZ = (BaseZ + NEIGHBORHOOD_SIZE + 1) * m_GridSize;
- for (cMineShaftSystems::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;)
- {
- if (
- ((*itr)->m_BlockX >= StartX) && ((*itr)->m_BlockX < EndX) &&
- ((*itr)->m_BlockZ >= StartZ) && ((*itr)->m_BlockZ < EndZ)
- )
- {
- // want
- a_MineShafts.push_back(*itr);
- itr = m_Cache.erase(itr);
- }
- else
- {
- // don't want
- ++itr;
- }
- } // for itr - m_Cache[]
-
- for (int x = 0; x < NEIGHBORHOOD_SIZE; x++)
- {
- int RealX = (BaseX + x) * m_GridSize;
- for (int z = 0; z < NEIGHBORHOOD_SIZE; z++)
- {
- int RealZ = (BaseZ + z) * m_GridSize;
- bool Found = false;
- for (cMineShaftSystems::const_iterator itr = a_MineShafts.begin(), end = a_MineShafts.end(); itr != end; ++itr)
- {
- if (((*itr)->m_BlockX == RealX) && ((*itr)->m_BlockZ == RealZ))
- {
- Found = true;
- break;
- }
- } // for itr - a_Mineshafts
- if (!Found)
- {
- a_MineShafts.push_back(new cMineShaftSystem(RealX, RealZ, m_GridSize, m_MaxSystemSize, m_Noise, m_ProbLevelCorridor, m_ProbLevelCrossing, m_ProbLevelStaircase));
- }
- } // for z
- } // for x
-
- // Copy a_MineShafts into m_Cache to the beginning:
- cMineShaftSystems MineShaftsCopy(a_MineShafts);
- m_Cache.splice(m_Cache.begin(), MineShaftsCopy, MineShaftsCopy.begin(), MineShaftsCopy.end());
-
- // Trim the cache if it's too long:
- if (m_Cache.size() > 100)
- {
- cMineShaftSystems::iterator itr = m_Cache.begin();
- std::advance(itr, 100);
- for (cMineShaftSystems::iterator end = m_Cache.end(); itr != end; ++itr)
- {
- delete *itr;
- }
- itr = m_Cache.begin();
- std::advance(itr, 100);
- m_Cache.erase(itr, m_Cache.end());
- }
-}
-
-
-
-
-
-
-void cStructGenMineShafts::GenFinish(cChunkDesc & a_ChunkDesc)
+cGridStructGen::cStructurePtr cStructGenMineShafts::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
- int ChunkX = a_ChunkDesc.GetChunkX();
- int ChunkZ = a_ChunkDesc.GetChunkZ();
- cMineShaftSystems MineShafts;
- GetMineShaftSystemsForChunk(ChunkX, ChunkZ, MineShafts);
- for (cMineShaftSystems::const_iterator itr = MineShafts.begin(); itr != MineShafts.end(); ++itr)
- {
- (*itr)->ProcessChunk(a_ChunkDesc);
- } // for itr - MineShafts[]
+ return cStructurePtr(new cMineShaftSystem(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_GridSize, m_MaxSystemSize, m_Noise, m_ProbLevelCorridor, m_ProbLevelCrossing, m_ProbLevelStaircase));
}
diff --git a/src/Generating/MineShafts.h b/src/Generating/MineShafts.h
index ba32e75ad..2850db571 100644
--- a/src/Generating/MineShafts.h
+++ b/src/Generating/MineShafts.h
@@ -9,7 +9,7 @@
#pragma once
-#include "ComposableGenerator.h"
+#include "GridStructGen.h"
#include "../Noise.h"
@@ -17,16 +17,16 @@
class cStructGenMineShafts :
- public cFinishGen
+ public cGridStructGen
{
+ typedef cGridStructGen super;
+
public:
cStructGenMineShafts(
- int a_Seed, int a_GridSize, int a_MaxSystemSize,
+ int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxSystemSize,
int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase
);
- virtual ~cStructGenMineShafts();
-
protected:
friend class cMineShaft;
friend class cMineShaftDirtRoom;
@@ -34,26 +34,16 @@ protected:
friend class cMineShaftCrossing;
friend class cMineShaftStaircase;
class cMineShaftSystem; // fwd: MineShafts.cpp
- typedef std::list<cMineShaftSystem *> cMineShaftSystems;
- cNoise m_Noise;
- int m_GridSize; ///< Average spacing of the systems
- int m_MaxSystemSize; ///< Maximum blcok size of a mineshaft system
- int m_ProbLevelCorridor; ///< Probability level of a branch object being the corridor
- int m_ProbLevelCrossing; ///< Probability level of a branch object being the crossing, minus Corridor
- int m_ProbLevelStaircase; ///< Probability level of a branch object being the staircase, minus Crossing
- cMineShaftSystems m_Cache; ///< Cache of the most recently used systems. MoveToFront used.
+ cNoise m_Noise;
+ int m_GridSize; ///< Average spacing of the systems
+ int m_MaxSystemSize; ///< Maximum blcok size of a mineshaft system
+ int m_ProbLevelCorridor; ///< Probability level of a branch object being the corridor
+ int m_ProbLevelCrossing; ///< Probability level of a branch object being the crossing, minus Corridor
+ int m_ProbLevelStaircase; ///< Probability level of a branch object being the staircase, minus Crossing
- /// Clears everything from the cache
- void ClearCache(void);
-
- /** Returns all systems that *may* intersect the given chunk.
- All the systems are valid until the next call to this function (which may delete some of the pointers).
- */
- void GetMineShaftSystemsForChunk(int a_ChunkX, int a_ChunkZ, cMineShaftSystems & a_MineShaftSystems);
-
- // cFinishGen overrides:
- virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
+ // cGridStructGen overrides:
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
} ;
diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp
index d90fdeb0a..f35555efd 100644
--- a/src/Generating/NetherFortGen.cpp
+++ b/src/Generating/NetherFortGen.cpp
@@ -11,29 +11,24 @@
-static const int NEIGHBORHOOD_SIZE = 3;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cNetherFortGen::cNetherFort:
-class cNetherFortGen::cNetherFort
+class cNetherFortGen::cNetherFort :
+ public cGridStructGen::cStructure
{
+ typedef cGridStructGen::cStructure super;
+
public:
cNetherFortGen & m_ParentGen;
- int m_BlockX, m_BlockZ;
int m_GridSize;
int m_Seed;
cPlacedPieces m_Pieces;
- cNetherFort(cNetherFortGen & a_ParentGen, int a_BlockX, int a_BlockZ, int a_GridSize, int a_MaxDepth, int a_Seed) :
+ cNetherFort(cNetherFortGen & a_ParentGen, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_GridSize, int a_MaxDepth, int a_Seed) :
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
m_ParentGen(a_ParentGen),
- m_BlockX(a_BlockX),
- m_BlockZ(a_BlockZ),
m_GridSize(a_GridSize),
m_Seed(a_Seed)
{
@@ -43,8 +38,8 @@ public:
// Generate pieces:
for (int i = 0; m_Pieces.size() < (size_t)(a_MaxDepth * a_MaxDepth / 8 + a_MaxDepth); i++)
{
- cBFSPieceGenerator pg(m_ParentGen, a_Seed + i);
- pg.PlacePieces(a_BlockX, BlockY, a_BlockZ, a_MaxDepth, m_Pieces);
+ cBFSPieceGenerator pg(cNetherFortGen::m_PiecePool, a_Seed + i);
+ pg.PlacePieces(a_OriginX, BlockY, a_OriginZ, a_MaxDepth, m_Pieces);
}
}
@@ -56,7 +51,7 @@ public:
/** Carves the system into the chunk data */
- void ProcessChunk(cChunkDesc & a_Chunk)
+ virtual void DrawIntoChunk(cChunkDesc & a_Chunk)
{
for (cPlacedPieces::const_iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
{
@@ -70,7 +65,7 @@ public:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Performance test of the NetherFort generator:
/*
@@ -104,215 +99,34 @@ public:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cNetherFortGen:
-cNetherFortGen::cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth) :
- m_Seed(a_Seed),
- m_Noise(a_Seed),
- m_GridSize(a_GridSize),
- m_MaxDepth(a_MaxDepth)
-{
- // Initialize the prefabs:
- for (size_t i = 0; i < g_NetherFortPrefabsCount; i++)
- {
- cPrefab * Prefab = new cPrefab(g_NetherFortPrefabs[i]);
- m_AllPieces.push_back(Prefab);
- if (Prefab->HasConnectorType(0))
- {
- m_OuterPieces.push_back(Prefab);
- }
- if (Prefab->HasConnectorType(1))
- {
- m_InnerPieces.push_back(Prefab);
- }
- }
-
- // Initialize the starting piece prefabs:
- for (size_t i = 0; i < g_NetherFortStartingPrefabsCount; i++)
- {
- m_StartingPieces.push_back(new cPrefab(g_NetherFortStartingPrefabs[i]));
- }
-
- /*
- // DEBUG: Try one round of placement:
- cPlacedPieces Pieces;
- cBFSPieceGenerator pg(*this, a_Seed);
- pg.PlacePieces(0, 64, 0, a_MaxDepth, Pieces);
- */
-}
-
+cPrefabPiecePool cNetherFortGen::m_PiecePool(g_NetherFortPrefabs, g_NetherFortPrefabsCount, g_NetherFortStartingPrefabs, g_NetherFortStartingPrefabsCount);
-cNetherFortGen::~cNetherFortGen()
-{
- ClearCache();
- for (cPieces::iterator itr = m_AllPieces.begin(), end = m_AllPieces.end(); itr != end; ++itr)
- {
- delete *itr;
- } // for itr - m_AllPieces[]
- m_AllPieces.clear();
-}
-
-
-
-
-
-void cNetherFortGen::ClearCache(void)
-{
- // TODO
-}
-
-
-
-
-
-void cNetherFortGen::GetFortsForChunk(int a_ChunkX, int a_ChunkZ, cNetherForts & a_Forts)
-{
- int BaseX = a_ChunkX * cChunkDef::Width / m_GridSize;
- int BaseZ = a_ChunkZ * cChunkDef::Width / m_GridSize;
- if (BaseX < 0)
- {
- --BaseX;
- }
- if (BaseZ < 0)
- {
- --BaseZ;
- }
- BaseX -= NEIGHBORHOOD_SIZE / 2;
- BaseZ -= NEIGHBORHOOD_SIZE / 2;
-
- // Walk the cache, move each cave system that we want into a_Forts:
- int StartX = BaseX * m_GridSize;
- int EndX = (BaseX + NEIGHBORHOOD_SIZE + 1) * m_GridSize;
- int StartZ = BaseZ * m_GridSize;
- int EndZ = (BaseZ + NEIGHBORHOOD_SIZE + 1) * m_GridSize;
- for (cNetherForts::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;)
- {
- if (
- ((*itr)->m_BlockX >= StartX) && ((*itr)->m_BlockX < EndX) &&
- ((*itr)->m_BlockZ >= StartZ) && ((*itr)->m_BlockZ < EndZ)
- )
- {
- // want
- a_Forts.push_back(*itr);
- itr = m_Cache.erase(itr);
- }
- else
- {
- // don't want
- ++itr;
- }
- } // for itr - m_Cache[]
- // Create those forts that haven't been in the cache:
- for (int x = 0; x < NEIGHBORHOOD_SIZE; x++)
- {
- int RealX = (BaseX + x) * m_GridSize;
- for (int z = 0; z < NEIGHBORHOOD_SIZE; z++)
- {
- int RealZ = (BaseZ + z) * m_GridSize;
- bool Found = false;
- for (cNetherForts::const_iterator itr = a_Forts.begin(), end = a_Forts.end(); itr != end; ++itr)
- {
- if (((*itr)->m_BlockX == RealX) && ((*itr)->m_BlockZ == RealZ))
- {
- Found = true;
- break;
- }
- } // for itr - a_Mineshafts
- if (!Found)
- {
- a_Forts.push_back(new cNetherFort(*this, RealX, RealZ, m_GridSize, m_MaxDepth, m_Seed));
- }
- } // for z
- } // for x
-
- // Copy a_Forts into m_Cache to the beginning:
- cNetherForts FortsCopy (a_Forts);
- m_Cache.splice(m_Cache.begin(), FortsCopy, FortsCopy.begin(), FortsCopy.end());
-
- // Trim the cache if it's too long:
- if (m_Cache.size() > 100)
- {
- cNetherForts::iterator itr = m_Cache.begin();
- std::advance(itr, 100);
- for (cNetherForts::iterator end = m_Cache.end(); itr != end; ++itr)
- {
- delete *itr;
- }
- itr = m_Cache.begin();
- std::advance(itr, 100);
- m_Cache.erase(itr, m_Cache.end());
- }
-}
-
-
-
-
-
-void cNetherFortGen::GenFinish(cChunkDesc & a_ChunkDesc)
-{
- int ChunkX = a_ChunkDesc.GetChunkX();
- int ChunkZ = a_ChunkDesc.GetChunkZ();
- cNetherForts Forts;
- GetFortsForChunk(ChunkX, ChunkZ, Forts);
- for (cNetherForts::const_iterator itr = Forts.begin(); itr != Forts.end(); ++itr)
- {
- (*itr)->ProcessChunk(a_ChunkDesc);
- } // for itr - Forts[]
-}
-
-
-
-
-
-cPieces cNetherFortGen::GetPiecesWithConnector(int a_ConnectorType)
-{
- switch (a_ConnectorType)
- {
- case 0: return m_OuterPieces;
- case 1: return m_InnerPieces;
- default: return cPieces();
- }
-}
-
-
-
-
-
-cPieces cNetherFortGen::GetStartingPieces(void)
-{
- return m_StartingPieces;
-}
-
-
-
-
-
-int cNetherFortGen::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece)
-{
- return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector);
-}
-
-
-
-
-
-void cNetherFortGen::PiecePlaced(const cPiece & a_Piece)
+cNetherFortGen::cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth) :
+ super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxDepth * 10, a_MaxDepth * 10, 200),
+ m_MaxDepth(a_MaxDepth)
{
- UNUSED(a_Piece);
+ /*
+ // DEBUG: Try one round of placement:
+ cPlacedPieces Pieces;
+ cBFSPieceGenerator pg(m_PiecePool, a_Seed);
+ pg.PlacePieces(0, 64, 0, a_MaxDepth, Pieces);
+ //*/
}
-void cNetherFortGen::Reset(void)
+cGridStructGen::cStructurePtr cNetherFortGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
- // Nothing needed
+ return cStructurePtr(new cNetherFort(*this, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_GridSizeX, m_MaxDepth, m_Seed));
}
diff --git a/src/Generating/NetherFortGen.h b/src/Generating/NetherFortGen.h
index d51596b9e..9b31aa0e2 100644
--- a/src/Generating/NetherFortGen.h
+++ b/src/Generating/NetherFortGen.h
@@ -10,77 +10,34 @@
#pragma once
#include "ComposableGenerator.h"
-#include "PieceGenerator.h"
+#include "PrefabPiecePool.h"
+#include "GridStructGen.h"
class cNetherFortGen :
- public cFinishGen,
- public cPiecePool
+ public cGridStructGen
{
-public:
- cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxDepth);
+ typedef cGridStructGen super;
- virtual ~cNetherFortGen();
+public:
+ cNetherFortGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth);
protected:
friend class cNetherFortPerfTest; // fwd: NetherFortGen.cpp
class cNetherFort; // fwd: NetherFortGen.cpp
- typedef std::list<cNetherFort *> cNetherForts;
-
-
- /** The seed used for generating*/
- int m_Seed;
-
- /** The noise used for generating */
- cNoise m_Noise;
-
- /** Average spacing between the fortresses*/
- int m_GridSize;
/** Maximum depth of the piece-generator tree */
int m_MaxDepth;
-
- /** Cache of the most recently used systems. MoveToFront used. */
- cNetherForts m_Cache;
- /** All the pieces that are allowed for building.
- This is the list that's used for memory allocation and deallocation for the pieces. */
- cPieces m_AllPieces;
+ /** The pool of pieces to use for generating. Static, so that it's shared by multiple generators. */
+ static cPrefabPiecePool m_PiecePool;
- /** The pieces that are used as starting pieces.
- This list is not shared and the pieces need deallocation. */
- cPieces m_StartingPieces;
-
- /** The pieces that have an "outer" connector.
- The pieces are copies out of m_AllPieces and shouldn't be ever delete-d. */
- cPieces m_OuterPieces;
-
- /** The pieces that have an "inner" connector.
- The pieces are copies out of m_AllPieces and shouldn't be ever delete-d. */
- cPieces m_InnerPieces;
-
- /** Clears everything from the cache.
- Also invalidates the forst returned by GetFortsForChunk(). */
- void ClearCache(void);
-
- /** Returns all forts that *may* intersect the given chunk.
- The returned forts live within m_Cache.They are valid until the next call
- to this function (which may delete some of the pointers). */
- void GetFortsForChunk(int a_ChunkX, int a_ChunkZ, cNetherForts & a_Forts);
-
- // cFinishGen overrides:
- virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
-
- // cPiecePool overrides:
- virtual cPieces GetPiecesWithConnector(int a_ConnectorType) override;
- virtual cPieces GetStartingPieces(void) override;
- virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override;
- virtual void PiecePlaced(const cPiece & a_Piece) override;
- virtual void Reset(void) override;
+ // cGridStructGen overrides:
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
} ;
diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp
index 15a588d45..b879349ee 100644
--- a/src/Generating/Noise3DGenerator.cpp
+++ b/src/Generating/Noise3DGenerator.cpp
@@ -61,7 +61,7 @@ public:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cNoise3DGenerator:
cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) :
@@ -342,7 +342,7 @@ void cNoise3DGenerator::ComposeTerrain(cChunkDesc & a_ChunkDesc)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cNoise3DComposable:
cNoise3DComposable::cNoise3DComposable(int a_Seed) :
diff --git a/src/Generating/POCPieceGenerator.cpp b/src/Generating/POCPieceGenerator.cpp
index 9ed4b565e..6e7e74d7a 100644
--- a/src/Generating/POCPieceGenerator.cpp
+++ b/src/Generating/POCPieceGenerator.cpp
@@ -150,7 +150,7 @@ static void DebugPieces(const cPlacedPieces & a_Pieces)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cPOCPieceGenerator:
cPOCPieceGenerator::cPOCPieceGenerator(int a_Seed) :
@@ -186,6 +186,11 @@ cPOCPieceGenerator::cPOCPieceGenerator(int a_Seed) :
cPOCPieceGenerator::~cPOCPieceGenerator()
{
cPieceGenerator::FreePieces(m_Pieces);
+ for (cPieces::iterator itr = m_AvailPieces.begin(), end = m_AvailPieces.end(); itr != end; ++itr)
+ {
+ delete *itr;
+ }
+ m_AvailPieces.clear();
}
diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp
index 8e9a48be6..ae4b6e36c 100644
--- a/src/Generating/PieceGenerator.cpp
+++ b/src/Generating/PieceGenerator.cpp
@@ -1,7 +1,7 @@
// PieceGenerator.cpp
-// Implements the cBFSPieceGenerator class and cDFSPieceGenerator class
+// Implements the cBFSPieceGenerator class and cDFSPieceGenerator class
// representing base classes for generating structures composed of individual "pieces"
#include "Globals.h"
@@ -13,7 +13,7 @@
#ifdef SELF_TEST
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Self-test:
static class cPieceGeneratorSelfTest :
@@ -140,7 +140,7 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cPiece:
@@ -254,7 +254,7 @@ cCuboid cPiece::RotateMoveHitBox(int a_NumCCWRotations, int a_MoveX, int a_MoveY
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cPiece::cConnector:
cPiece::cConnector::cConnector(int a_X, int a_Y, int a_Z, int a_Type, eBlockFace a_Direction) :
@@ -279,14 +279,15 @@ cPiece::cConnector::cConnector(const Vector3i & a_Pos, int a_Type, eBlockFace a_
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cPlacedPiece:
cPlacedPiece::cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece, const Vector3i & a_Coords, int a_NumCCWRotations) :
m_Parent(a_Parent),
m_Piece(&a_Piece),
m_Coords(a_Coords),
- m_NumCCWRotations(a_NumCCWRotations)
+ m_NumCCWRotations(a_NumCCWRotations),
+ m_HasBeenMovedToGround(false)
{
m_Depth = (m_Parent == NULL) ? 0 : (m_Parent->GetDepth() + 1);
m_HitBox = a_Piece.RotateMoveHitBox(a_NumCCWRotations, a_Coords.x, a_Coords.y, a_Coords.z);
@@ -297,7 +298,37 @@ cPlacedPiece::cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+cPiece::cConnector cPlacedPiece::GetRotatedConnector(size_t a_Index) const
+{
+ cPiece::cConnectors Connectors = m_Piece->GetConnectors();
+ ASSERT(Connectors.size() >= a_Index);
+ return m_Piece->RotateMoveConnector(Connectors[a_Index], m_NumCCWRotations, m_Coords.x, m_Coords.y, m_Coords.z);
+}
+
+
+
+
+
+cPiece::cConnector cPlacedPiece::GetRotatedConnector(const cPiece::cConnector & a_Connector) const
+{
+ return m_Piece->RotateMoveConnector(a_Connector, m_NumCCWRotations, m_Coords.x, m_Coords.y, m_Coords.z);
+}
+
+
+
+
+
+void cPlacedPiece::MoveToGroundBy(int a_OffsetY)
+{
+ m_Coords.y += a_OffsetY;
+ m_HasBeenMovedToGround = true;
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cPieceGenerator:
cPieceGenerator::cPieceGenerator(cPiecePool & a_PiecePool, int a_Seed) :
@@ -331,7 +362,31 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i
// Choose a random one of the starting pieces:
cPieces StartingPieces = m_PiecePool.GetStartingPieces();
- cPiece * StartingPiece = StartingPieces[rnd % StartingPieces.size()];
+ int Total = 0;
+ for (cPieces::const_iterator itr = StartingPieces.begin(), end = StartingPieces.end(); itr != end; ++itr)
+ {
+ Total += m_PiecePool.GetStartingPieceWeight(**itr);
+ }
+ cPiece * StartingPiece;
+ if (Total > 0)
+ {
+ int Chosen = rnd % Total;
+ StartingPiece = StartingPieces.front();
+ for (cPieces::const_iterator itr = StartingPieces.begin(), end = StartingPieces.end(); itr != end; ++itr)
+ {
+ Chosen -= m_PiecePool.GetStartingPieceWeight(**itr);
+ if (Chosen <= 0)
+ {
+ StartingPiece = *itr;
+ break;
+ }
+ }
+ }
+ else
+ {
+ // All pieces returned zero weight, but we need one to start. Choose with equal chance:
+ StartingPiece = StartingPieces[rnd % StartingPieces.size()];
+ }
rnd = rnd >> 16;
// Choose a random supported rotation:
@@ -339,9 +394,9 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i
int NumRotations = 1;
for (size_t i = 1; i < ARRAYCOUNT(Rotations); i++)
{
- if (StartingPiece->CanRotateCCW(i))
+ if (StartingPiece->CanRotateCCW((int)i))
{
- Rotations[NumRotations] = i;
+ Rotations[NumRotations] = (int)i;
NumRotations += 1;
}
}
@@ -388,7 +443,8 @@ bool cPieceGenerator::TryPlacePieceAtConnector(
// Get a list of available connections:
const int * RotTable = DirectionRotationTable[a_Connector.m_Direction];
cConnections Connections;
- cPieces AvailablePieces = m_PiecePool.GetPiecesWithConnector(a_Connector.m_Type);
+ int WantedConnectorType = -a_Connector.m_Type;
+ cPieces AvailablePieces = m_PiecePool.GetPiecesWithConnector(WantedConnectorType);
Connections.reserve(AvailablePieces.size());
Vector3i ConnPos = a_Connector.m_Pos; // The position at which the new connector should be placed - 1 block away from the connector
AddFaceDirection(ConnPos.x, ConnPos.y, ConnPos.z, a_Connector.m_Direction);
@@ -406,7 +462,7 @@ bool cPieceGenerator::TryPlacePieceAtConnector(
cPiece::cConnectors Connectors = (*itrP)->GetConnectors();
for (cPiece::cConnectors::iterator itrC = Connectors.begin(), endC = Connectors.end(); itrC != endC; ++itrC)
{
- if (itrC->m_Type != a_Connector.m_Type)
+ if (itrC->m_Type != WantedConnectorType)
{
continue;
}
@@ -522,7 +578,7 @@ void cPieceGenerator::DebugConnectorPool(const cPieceGenerator::cFreeConnectors
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cPieceGenerator::cConnection:
cPieceGenerator::cConnection::cConnection(cPiece & a_Piece, cPiece::cConnector & a_Connector, int a_NumCCWRotations, int a_Weight) :
@@ -537,7 +593,7 @@ cPieceGenerator::cConnection::cConnection(cPiece & a_Piece, cPiece::cConnector &
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cPieceGenerator::cFreeConnector:
cPieceGenerator::cFreeConnector::cFreeConnector(cPlacedPiece * a_Piece, const cPiece::cConnector & a_Connector) :
@@ -550,7 +606,7 @@ cPieceGenerator::cFreeConnector::cFreeConnector(cPlacedPiece * a_Piece, const cP
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cBFSPieceGenerator:
cBFSPieceGenerator::cBFSPieceGenerator(cPiecePool & a_PiecePool, int a_Seed) :
diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h
index f4433b947..f06029280 100644
--- a/src/Generating/PieceGenerator.h
+++ b/src/Generating/PieceGenerator.h
@@ -1,7 +1,7 @@
// PieceGenerator.h
-// Declares the cBFSPieceGenerator class and cDFSPieceGenerator class
+// Declares the cBFSPieceGenerator class and cDFSPieceGenerator class
// representing base classes for generating structures composed of individual "pieces"
/*
@@ -38,7 +38,8 @@ public:
/** Position relative to the piece */
Vector3i m_Pos;
- /** Type of the connector. Any arbitrary number; the generator connects only connectors of the same type. */
+ /** Type of the connector. Any arbitrary number; the generator connects only connectors of opposite
+ (negative) types. */
int m_Type;
/** Direction in which the connector is facing.
@@ -109,6 +110,7 @@ public:
virtual cPieces GetStartingPieces(void) = 0;
/** Returns the relative weight with which the a_NewPiece is to be selected for placing under a_PlacedPiece through a_ExistingConnector.
+ a_ExistingConnector is the original connector, before any movement or rotation is applied to it.
This allows the pool to tweak the piece's chances, based on the previous pieces in the tree and the connector used.
The higher the number returned, the higher the chance the piece will be chosen. 0 means the piece will never be chosen.
*/
@@ -118,6 +120,15 @@ public:
const cPiece & a_NewPiece
) { return 1; }
+ /** Returns the relative weight with which the a_NewPiece is to be selected for placing as the first piece.
+ This allows the pool to tweak the piece's chances.
+ The higher the number returned, the higher the chance the piece will be chosen. 0 means the piece will not be chosen.
+ If all pieces return 0, a random piece is chosen, with all equal chances.
+ */
+ virtual int GetStartingPieceWeight(
+ const cPiece & a_NewPiece
+ ) { return 1; }
+
/** Called after a piece is placed, to notify the pool that it has been used.
The pool may adjust the pieces it will return the next time. */
virtual void PiecePlaced(const cPiece & a_Piece) = 0;
@@ -137,19 +148,41 @@ class cPlacedPiece
public:
cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece, const Vector3i & a_Coords, int a_NumCCWRotations);
- const cPiece & GetPiece (void) const { return *m_Piece; }
- const Vector3i & GetCoords (void) const { return m_Coords; }
- int GetNumCCWRotations(void) const { return m_NumCCWRotations; }
- const cCuboid & GetHitBox (void) const { return m_HitBox; }
- int GetDepth (void) const { return m_Depth; }
+ const cPlacedPiece * GetParent (void) const { return m_Parent; }
+ const cPiece & GetPiece (void) const { return *m_Piece; }
+ const Vector3i & GetCoords (void) const { return m_Coords; }
+ int GetNumCCWRotations (void) const { return m_NumCCWRotations; }
+ const cCuboid & GetHitBox (void) const { return m_HitBox; }
+ int GetDepth (void) const { return m_Depth; }
+ bool HasBeenMovedToGround(void) const { return m_HasBeenMovedToGround; }
+
+ /** Returns the coords as a modifiable object. */
+ Vector3i & GetCoords(void) { return m_Coords; }
+
+ /** Returns the connector at the specified index, rotated in the actual placement.
+ Undefined behavior if a_Index is out of range. */
+ cPiece::cConnector GetRotatedConnector(size_t a_Index) const;
+
+ /** Returns a copy of the specified connector, modified to account for the translation and rotation for
+ this placement. */
+ cPiece::cConnector GetRotatedConnector(const cPiece::cConnector & a_Connector) const;
+
+ /** Moves the placed piece Y-wise by the specified offset.
+ Sets m_HasBeenMovedToGround to true, too.
+ Used eg. by village houses. */
+ void MoveToGroundBy(int a_OffsetY);
protected:
const cPlacedPiece * m_Parent;
const cPiece * m_Piece;
Vector3i m_Coords;
int m_NumCCWRotations;
- cCuboid m_HitBox;
- int m_Depth;
+ cCuboid m_HitBox; // Hitbox of the placed piece, in world coords
+ int m_Depth; // Depth in the generated piece tree
+
+ /** Set to true once the piece has been moved Y-wise.
+ Used eg. by village houses. */
+ bool m_HasBeenMovedToGround;
};
typedef std::vector<cPlacedPiece *> cPlacedPieces;
@@ -218,7 +251,7 @@ protected:
const cPiece::cConnector & a_ExistingConnector, // The existing connector
const Vector3i & a_ToPos, // The position on which the new connector should be placed
const cPiece & a_Piece, // The new piece
- const cPiece::cConnector & a_NewConnector, // The connector of the new piece
+ const cPiece::cConnector & a_NewConnector, // The connector of the new piece
int a_NumCCWRotations, // Number of rotations for the new piece to align the connector
const cPlacedPieces & a_OutPieces // All the already-placed pieces to check
);
diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp
index c0c9e8a13..6da3c3d10 100644
--- a/src/Generating/Prefab.cpp
+++ b/src/Generating/Prefab.cpp
@@ -108,6 +108,9 @@ static const cPrefab::sDef g_TestPrefabDef =
// AddWeightIfSame:
1000,
+
+ // MoveToGround:
+ false,
};
static cPrefab g_TestPrefab(g_TestPrefabDef);
@@ -127,7 +130,8 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) :
m_MergeStrategy(a_Def.m_MergeStrategy),
m_ShouldExtendFloor(a_Def.m_ShouldExtendFloor),
m_DefaultWeight(a_Def.m_DefaultWeight),
- m_AddWeightIfSame(a_Def.m_AddWeightIfSame)
+ m_AddWeightIfSame(a_Def.m_AddWeightIfSame),
+ m_MoveToGround(a_Def.m_MoveToGround)
{
m_BlockArea[0].Create(m_Size);
CharMap cm;
@@ -136,6 +140,34 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) :
ParseConnectors(a_Def.m_Connectors);
ParseDepthWeight(a_Def.m_DepthWeight);
+ AddRotatedBlockAreas();
+}
+
+
+
+
+
+cPrefab::cPrefab(const cBlockArea & a_Image, int a_AllowedRotations) :
+ m_Size(a_Image.GetSize()),
+ m_AllowedRotations(a_AllowedRotations),
+ m_MergeStrategy(cBlockArea::msOverwrite),
+ m_ShouldExtendFloor(false),
+ m_DefaultWeight(1),
+ m_AddWeightIfSame(0),
+ m_MoveToGround(false)
+{
+ m_HitBox.p1.Set(0, 0, 0);
+ m_HitBox.p2.Set(m_Size.x - 1, m_Size.y - 1, m_Size.z - 1);
+ m_BlockArea[0].CopyFrom(a_Image);
+ AddRotatedBlockAreas();
+}
+
+
+
+
+
+void cPrefab::AddRotatedBlockAreas(void)
+{
// 1 CCW rotation:
if ((m_AllowedRotations & 0x01) != 0)
{
@@ -149,7 +181,7 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) :
m_BlockArea[2].CopyFrom(m_BlockArea[0]);
m_BlockArea[2].MirrorXY();
m_BlockArea[2].MirrorYZ();
- }
+ }
// 3 CCW rotations = 1 CW rotation:
if ((m_AllowedRotations & 0x04) != 0)
@@ -165,53 +197,75 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) :
void cPrefab::Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const
{
+ Draw(a_Dest, a_Placement->GetCoords(), a_Placement->GetNumCCWRotations());
+}
+
+
+
+
+void cPrefab::Draw(cChunkDesc & a_Dest, const Vector3i & a_Placement, int a_NumRotations) const
+{
// Draw the basic image:
- Vector3i Placement = a_Placement->GetCoords();
+ Vector3i Placement(a_Placement);
int ChunkStartX = a_Dest.GetChunkX() * cChunkDef::Width;
int ChunkStartZ = a_Dest.GetChunkZ() * cChunkDef::Width;
Placement.Move(-ChunkStartX, 0, -ChunkStartZ);
- const cBlockArea & Image = m_BlockArea[a_Placement->GetNumCCWRotations()];
+ const cBlockArea & Image = m_BlockArea[a_NumRotations];
+
+ // If the placement is outside this chunk, bail out:
+ if (
+ (Placement.x > cChunkDef::Width) || (Placement.x + Image.GetSizeX() < 0) ||
+ (Placement.z > cChunkDef::Width) || (Placement.z + Image.GetSizeZ() < 0)
+ )
+ {
+ return;
+ }
+
+ // Write the image:
a_Dest.WriteBlockArea(Image, Placement.x, Placement.y, Placement.z, m_MergeStrategy);
// If requested, draw the floor (from the bottom of the prefab down to the nearest non-air)
- int MaxX = Image.GetSizeX();
- int MaxZ = Image.GetSizeZ();
- for (int z = 0; z < MaxZ; z++)
+ if (m_ShouldExtendFloor)
{
- int RelZ = Placement.z + z;
- if ((RelZ < 0) || (RelZ >= cChunkDef::Width))
+ int MaxX = Image.GetSizeX();
+ int MaxZ = Image.GetSizeZ();
+ for (int z = 0; z < MaxZ; z++)
{
- // Z coord outside the chunk
- continue;
- }
- for (int x = 0; x < MaxX; x++)
- {
- int RelX = Placement.x + x;
- if ((RelX < 0) || (RelX >= cChunkDef::Width))
+ int RelZ = Placement.z + z;
+ if ((RelZ < 0) || (RelZ >= cChunkDef::Width))
{
- // X coord outside the chunk
+ // Z coord outside the chunk
continue;
}
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- Image.GetRelBlockTypeMeta(x, 0, z, BlockType, BlockMeta);
- if ((BlockType == E_BLOCK_AIR) || (BlockType == E_BLOCK_SPONGE))
+ for (int x = 0; x < MaxX; x++)
{
- // Do not expand air nor sponge blocks
- continue;
- }
- for (int y = Placement.y - 1; y >= 0; y--)
- {
- BLOCKTYPE ExistingBlock = a_Dest.GetBlockType(RelX, y, RelZ);
- if (ExistingBlock != E_BLOCK_AIR)
+ int RelX = Placement.x + x;
+ if ((RelX < 0) || (RelX >= cChunkDef::Width))
+ {
+ // X coord outside the chunk
+ continue;
+ }
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ Image.GetRelBlockTypeMeta(x, 0, z, BlockType, BlockMeta);
+ if ((BlockType == E_BLOCK_AIR) || (BlockType == E_BLOCK_SPONGE))
{
- // End the expansion for this column, reached the end
- break;
+ // Do not expand air nor sponge blocks
+ continue;
}
- a_Dest.SetBlockTypeMeta(RelX, y, RelZ, BlockType, BlockMeta);
- } // for y
- } // for x
- } // for z
+ for (int y = Placement.y - 1; y >= 0; y--)
+ {
+ BLOCKTYPE ExistingBlock = a_Dest.GetBlockType(RelX, y, RelZ);
+ if (ExistingBlock != E_BLOCK_AIR)
+ {
+ // End the expansion for this column, reached the end
+ break;
+ }
+ a_Dest.SetBlockTypeMeta(RelX, y, RelZ, BlockType, BlockMeta);
+ } // for y
+ } // for x
+ } // for z
+ }
}
@@ -254,6 +308,24 @@ int cPrefab::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cC
+void cPrefab::SetDefaultWeight(int a_DefaultWeight)
+{
+ m_DefaultWeight = a_DefaultWeight;
+}
+
+
+
+
+
+void cPrefab::AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type)
+{
+ m_Connectors.push_back(cConnector(a_RelX, a_RelY, a_RelZ, a_Type, a_Direction));
+}
+
+
+
+
+
void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef)
{
ASSERT(a_CharMapDef != NULL);
@@ -283,7 +355,7 @@ void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef)
if ((NumElements >= 3) && !CharDef[2].empty())
{
BlockMeta = (NIBBLETYPE)atoi(CharDef[2].c_str());
- ASSERT((BlockMeta >= 0) && (BlockMeta <= 15));
+ ASSERT((BlockMeta <= 15));
}
a_CharMapOut[Src].m_BlockMeta = BlockMeta;
} // for itr - Lines[]
diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h
index 37db2ff16..eb905e78e 100644
--- a/src/Generating/Prefab.h
+++ b/src/Generating/Prefab.h
@@ -82,19 +82,47 @@ public:
Can be positive or negative.
This is used e. g. to make nether bridges prefer spanning multiple segments or to penalize turrets next to each other. */
int m_AddWeightIfSame;
+
+ /** If true, the piece will be moved Y-wise so that its first connector is sitting on the terrain.
+ This is used e. g. for village houses. */
+ bool m_MoveToGround;
};
+
+ /** Creates a prefab from the provided definition. */
cPrefab(const sDef & a_Def);
+ /** Creates a prefab based on the given BlockArea and allowed rotations. */
+ cPrefab(const cBlockArea & a_Image, int a_AllowedRotations);
+
/** Draws the prefab into the specified chunk, according to the placement stored in the PlacedPiece. */
void Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const;
+ /** Draws the prefab into the specified chunks, according to the specified placement and rotations. */
+ void Draw(cChunkDesc & a_Dest, const Vector3i & a_Placement, int a_NumRotations) const;
+
/** Returns true if the prefab has any connector of the specified type. */
bool HasConnectorType(int a_ConnectorType) const;
/** Returns the weight (chance) of this prefab generating as the next piece after the specified placed piece.
PiecePool implementations can use this for their GetPieceWeight() implementations. */
int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector) const;
+
+ /** Sets the (unmodified) DefaultWeight property for this piece. */
+ void SetDefaultWeight(int a_DefaultWeight);
+
+ /** Returns the unmodified DefaultWeight property for the piece. */
+ int GetDefaultWeight(void) const { return m_DefaultWeight; }
+
+ /** Sets the AddWeightIfSame member, that is used to modify the weight when the previous piece is the same prefab */
+ void SetAddWeightIfSame(int a_AddWeightIfSame) { m_AddWeightIfSame = a_AddWeightIfSame; }
+
+ /** Adds the specified connector to the list of connectors this piece supports. */
+ void AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type);
+
+ /** Returns whether the prefab should be moved Y-wise to ground before drawing, rather than staying
+ at the coords governed by the connectors. */
+ bool ShouldMoveToGround(void) const { return m_MoveToGround; }
protected:
/** Packs complete definition of a single block, for per-letter assignment. */
@@ -149,14 +177,22 @@ protected:
Can be positive or negative.
This is used e. g. to make nether bridges prefer spanning multiple segments or to penalize turrets next to each other. */
int m_AddWeightIfSame;
+
+ /** If true, the piece will be moved Y-wise so that its first connector is sitting on the terrain.
+ This is used e. g. for village houses. */
+ bool m_MoveToGround;
- // cPiece overrides:
+ // cPiece overrides:
virtual cConnectors GetConnectors(void) const override;
virtual Vector3i GetSize(void) const override;
virtual cCuboid GetHitBox(void) const override;
virtual bool CanRotateCCW(int a_NumRotations) const override;
+ /** Based on the m_AllowedRotations, adds rotated cBlockAreas to the m_BlockArea array.
+ To be called only from this class's constructor! */
+ void AddRotatedBlockAreas(void);
+
/** Parses the CharMap in the definition into a CharMap binary data used for translating the definition into BlockArea. */
void ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef);
diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp
new file mode 100644
index 000000000..122b9d2af
--- /dev/null
+++ b/src/Generating/PrefabPiecePool.cpp
@@ -0,0 +1,158 @@
+
+// PrefabPiecePool.cpp
+
+// Implements the cPrefabPiecePool class that represents a cPiecePool descendant that uses cPrefab instances as the pieces
+
+#include "Globals.h"
+#include "PrefabPiecePool.h"
+
+
+
+
+
+cPrefabPiecePool::cPrefabPiecePool(
+ const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs,
+ const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs
+)
+{
+ AddPieceDefs(a_PieceDefs, a_NumPieceDefs);
+ if (a_StartingPieceDefs != NULL)
+ {
+ AddStartingPieceDefs(a_StartingPieceDefs, a_NumStartingPieceDefs);
+ }
+}
+
+
+
+
+
+cPrefabPiecePool::~cPrefabPiecePool()
+{
+ Clear();
+}
+
+
+
+
+
+void cPrefabPiecePool::Clear(void)
+{
+ m_PiecesByConnector.clear();
+ for (cPieces::iterator itr = m_AllPieces.begin(), end = m_AllPieces.end(); itr != end; ++itr)
+ {
+ delete *itr;
+ }
+ m_AllPieces.clear();
+ for (cPieces::iterator itr = m_StartingPieces.begin(), end = m_StartingPieces.end(); itr != end; ++itr)
+ {
+ delete *itr;
+ }
+ m_StartingPieces.clear();
+}
+
+
+
+
+
+void cPrefabPiecePool::AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs)
+{
+ ASSERT(a_PieceDefs != NULL);
+ for (size_t i = 0; i < a_NumPieceDefs; i++)
+ {
+ cPrefab * Prefab = new cPrefab(a_PieceDefs[i]);
+ m_AllPieces.push_back(Prefab);
+ AddToPerConnectorMap(Prefab);
+ }
+}
+
+
+
+
+
+void cPrefabPiecePool::AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs)
+{
+ ASSERT(a_StartingPieceDefs != NULL);
+ for (size_t i = 0; i < a_NumStartingPieceDefs; i++)
+ {
+ cPrefab * Prefab = new cPrefab(a_StartingPieceDefs[i]);
+ m_StartingPieces.push_back(Prefab);
+ }
+}
+
+
+
+
+
+void cPrefabPiecePool::AddToPerConnectorMap(cPrefab * a_Prefab)
+{
+ cPiece::cConnectors Connectors = ((const cPiece *)a_Prefab)->GetConnectors();
+ for (cPiece::cConnectors::const_iterator itr = Connectors.begin(), end = Connectors.end(); itr != end; ++itr)
+ {
+ m_PiecesByConnector[itr->m_Type].push_back(a_Prefab);
+ }
+}
+
+
+
+
+cPieces cPrefabPiecePool::GetPiecesWithConnector(int a_ConnectorType)
+{
+ return m_PiecesByConnector[a_ConnectorType];
+}
+
+
+
+
+
+cPieces cPrefabPiecePool::GetStartingPieces(void)
+{
+ if (m_StartingPieces.empty())
+ {
+ return m_AllPieces;
+ }
+ else
+ {
+ return m_StartingPieces;
+ }
+}
+
+
+
+
+
+int cPrefabPiecePool::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece)
+{
+ return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector);
+}
+
+
+
+
+
+int cPrefabPiecePool::GetStartingPieceWeight(const cPiece & a_NewPiece)
+{
+ return ((const cPrefab &)a_NewPiece).GetDefaultWeight();
+}
+
+
+
+
+
+void cPrefabPiecePool::PiecePlaced(const cPiece & a_Piece)
+{
+ // Do nothing
+ UNUSED(a_Piece);
+}
+
+
+
+
+
+void cPrefabPiecePool::Reset(void)
+{
+ // Do nothing
+}
+
+
+
+
diff --git a/src/Generating/PrefabPiecePool.h b/src/Generating/PrefabPiecePool.h
new file mode 100644
index 000000000..b9c1f0483
--- /dev/null
+++ b/src/Generating/PrefabPiecePool.h
@@ -0,0 +1,85 @@
+
+// PrefabPiecePool.h
+
+// Declares the cPrefabPiecePool class that represents a cPiecePool descendant that uses cPrefab instances as the pieces
+
+
+
+
+
+#pragma once
+
+#include "PieceGenerator.h"
+#include "Prefab.h"
+
+
+
+
+
+class cPrefabPiecePool :
+ public cPiecePool
+{
+public:
+ /** Creates an empty instance. Prefabs can be added by calling AddPieceDefs() and AddStartingPieceDefs(). */
+ cPrefabPiecePool(void);
+
+ /** Creates a piece pool with prefabs from the specified definitions.
+ If both a_PieceDefs and a_StartingPieceDefs are given, only the a_StartingPieceDefs are used as starting
+ pieces for the pool, and they do not participate in the generation any further.
+ If only a_PieceDefs is given, any such piece can be chosen as a starting piece, and all the pieces are used
+ for generating.
+ More pieces can be added to the instance afterwards by calling AddPieceDefs() and AddStartingPieceDefs(). */
+ cPrefabPiecePool(
+ const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs,
+ const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs
+ );
+
+ /** Destroys the pool, freeing all pieces. */
+ ~cPrefabPiecePool();
+
+ /** Removes and frees all pieces from this pool. */
+ void Clear(void);
+
+ /** Adds pieces from the specified definitions into m_AllPieces. Also adds the pieces into
+ the m_PiecesByConnector map.
+ May be called multiple times with different PieceDefs, will add all such pieces. */
+ void AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs);
+
+ /** Adds pieces from the specified definitions into m_StartingPieces. Doesn't add them to
+ the m_PiecesByConnector map.
+ May be called multiple times with different PieceDefs, will add all such pieces. */
+ void AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs);
+
+protected:
+
+ /** The type used to map a connector type to the list of pieces with that connector */
+ typedef std::map<int, cPieces> cPiecesMap;
+
+ /** All the pieces that are allowed for building.
+ This is the list that's used for memory allocation and deallocation for the pieces. */
+ cPieces m_AllPieces;
+
+ /** The pieces that are used as starting pieces.
+ This list is not shared and the pieces need deallocation. */
+ cPieces m_StartingPieces;
+
+ /** The map that has all pieces by their connector types
+ The pieces are copies out of m_AllPieces and shouldn't be ever delete-d. */
+ cPiecesMap m_PiecesByConnector;
+
+
+ /** Adds the prefab to the m_PiecesByConnector map for all its connectors. */
+ void AddToPerConnectorMap(cPrefab * a_Prefab);
+
+ // cPiecePool overrides:
+ virtual cPieces GetPiecesWithConnector(int a_ConnectorType) override;
+ virtual cPieces GetStartingPieces(void) override;
+ virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override;
+ virtual int GetStartingPieceWeight(const cPiece & a_NewPiece) override;
+ virtual void PiecePlaced(const cPiece & a_Piece) override;
+ virtual void Reset(void) override;
+} ;
+
+
+
+
diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp
new file mode 100644
index 000000000..c08e53ef6
--- /dev/null
+++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp
@@ -0,0 +1,3590 @@
+
+// AlchemistVillagePrefabs.cpp
+
+// Defines the prefabs in the group AlchemistVillage
+
+// NOTE: This file has been generated automatically by GalExport!
+// Any manual changes will be overwritten by the next automatic export!
+
+#include "Globals.h"
+#include "AlchemistVillagePrefabs.h"
+
+
+
+
+
+const cPrefab::sDef g_AlchemistVillagePrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // BarWithBasement:
+ // The data has been exported from the gallery Desert, area index 82, ID 598, created by STR_Warrior
+ {
+ // Size:
+ 11, 12, 10, // SizeX = 11, SizeY = 12, SizeZ = 10
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 11, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "A: 65: 3\n" /* ladder */
+ "B: 50: 3\n" /* torch */
+ "C:171: 8\n" /* carpet */
+ "D:101: 0\n" /* ironbars */
+ "E: 64: 8\n" /* wooddoorblock */
+ "F:128: 2\n" /* sandstonestairs */
+ "G: 24: 1\n" /* sandstone */
+ "H: 44: 9\n" /* step */
+ "I:126: 8\n" /* woodenslab */
+ "J:128: 7\n" /* sandstonestairs */
+ "K: 44: 1\n" /* step */
+ "L: 64: 3\n" /* wooddoorblock */
+ "M:128: 6\n" /* sandstonestairs */
+ "a: 24: 2\n" /* sandstone */
+ "b: 1: 0\n" /* stone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 12: 0\n" /* sand */
+ "e:134: 4\n" /* 134 */
+ "f: 5: 1\n" /* wood */
+ "g:134: 5\n" /* 134 */
+ "h: 65: 5\n" /* ladder */
+ "i: 17: 3\n" /* tree */
+ "j: 69:11\n" /* lever */
+ "k: 4: 0\n" /* cobblestone */
+ "l:134: 0\n" /* 134 */
+ "m: 19: 0\n" /* sponge */
+ "n:134: 1\n" /* 134 */
+ "o: 50: 4\n" /* torch */
+ "p: 13: 0\n" /* gravel */
+ "q: 5: 0\n" /* wood */
+ "r: 96: 8\n" /* trapdoor */
+ "s:128: 5\n" /* sandstonestairs */
+ "t:107: 2\n" /* fencegate */
+ "u:128: 4\n" /* sandstonestairs */
+ "v:134: 3\n" /* 134 */
+ "w: 85: 0\n" /* fence */
+ "x:134: 7\n" /* 134 */
+ "y:107: 5\n" /* fencegate */
+ "z: 64: 1\n" /* wooddoorblock */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmabbbammm"
+ /* 1 */ "mcccccccccm"
+ /* 2 */ "abcccccccba"
+ /* 3 */ "cbcccccccbc"
+ /* 4 */ "cbcccccccbc"
+ /* 5 */ "cbcccccccbc"
+ /* 6 */ "cbcccccccbc"
+ /* 7 */ "cbcccccccbc"
+ /* 8 */ "abbbbbbbbba"
+ /* 9 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmadddammm"
+ /* 1 */ "mcccccccccm"
+ /* 2 */ "acefg.efgca"
+ /* 3 */ "ccefg.efgcc"
+ /* 4 */ "ccefg.efgcc"
+ /* 5 */ "cc.......cc"
+ /* 6 */ "cc.......cc"
+ /* 7 */ "cch......cc"
+ /* 8 */ "accccccccca"
+ /* 9 */ "mmmmmmmmmmm"
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmadddammm"
+ /* 1 */ "mcccccccccm"
+ /* 2 */ "acfff.fffca"
+ /* 3 */ "ccfff.fffcc"
+ /* 4 */ "ccfif.fifcc"
+ /* 5 */ "cc.j...j.cc"
+ /* 6 */ "cc.......cc"
+ /* 7 */ "cch......cc"
+ /* 8 */ "accccccccca"
+ /* 9 */ "mmmmmmmmmmm"
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmakkkammm"
+ /* 1 */ "mcccccccccm"
+ /* 2 */ "aclfn.lfnca"
+ /* 3 */ "cclfn.lfncc"
+ /* 4 */ "cclfn.lfncc"
+ /* 5 */ "cc.......cc"
+ /* 6 */ "cc.......cc"
+ /* 7 */ "cch..o...cc"
+ /* 8 */ "accccccccca"
+ /* 9 */ "mmmmmmmmmmm"
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmapppammm"
+ /* 1 */ "mmmmpppmmmm"
+ /* 2 */ "acccqqqccca"
+ /* 3 */ "cqqqqqqqqqc"
+ /* 4 */ "cqqqqqqqqqc"
+ /* 5 */ "cqqqqqqqqqc"
+ /* 6 */ "cqqqqqqqqqc"
+ /* 7 */ "cqrqqqqqqqc"
+ /* 8 */ "aqcccccccca"
+ /* 9 */ "mmmmmmmmmmm"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmma...ammm"
+ /* 1 */ "mmm.....mmm"
+ /* 2 */ "acccstuccca"
+ /* 3 */ "cnv.....vvc"
+ /* 4 */ "cnw.....wlc"
+ /* 5 */ "c.........c"
+ /* 6 */ "cgxxe.....c"
+ /* 7 */ "c...y..nwlc"
+ /* 8 */ "azcccccccca"
+ /* 9 */ "mmAmmmmmmmm"
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmma...ammm"
+ /* 1 */ "mmm.....mmm"
+ /* 2 */ "accc...ccca"
+ /* 3 */ "c..B...B..c"
+ /* 4 */ "c.C.....C.c"
+ /* 5 */ "D.........D"
+ /* 6 */ "c.........c"
+ /* 7 */ "c.......C.c"
+ /* 8 */ "aEccDDDccca"
+ /* 9 */ "mmAmmmmmmmm"
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmF...Fmmm"
+ /* 1 */ "mmmG...cmmm"
+ /* 2 */ "acccsHuccca"
+ /* 3 */ "cIIIIIIIIIc"
+ /* 4 */ "cIIIIIIIIIc"
+ /* 5 */ "uIIIIIIIIIs"
+ /* 6 */ "cIIIIIIIIIc"
+ /* 7 */ "cIIIIIIIIIc"
+ /* 8 */ "acccJJJccca"
+ /* 9 */ "mmAmmmmmmmm"
+
+ // Level 8
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmm.....mmm"
+ /* 1 */ "mmm.....mmm"
+ /* 2 */ "cKKKKcKKKKc"
+ /* 3 */ "KacccccccaK"
+ /* 4 */ "Kc.......cK"
+ /* 5 */ "cc.......cc"
+ /* 6 */ "Kc.......cK"
+ /* 7 */ "KaLccccccaK"
+ /* 8 */ "cK.KKcKKKKc"
+ /* 9 */ "mmmmmmmmmmm"
+
+ // Level 9
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ ".accDDDcca."
+ /* 4 */ ".c.......c."
+ /* 5 */ ".D.......D."
+ /* 6 */ ".c.......c."
+ /* 7 */ ".aEcDDDcca."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+
+ // Level 10
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ ".accMMMcca."
+ /* 4 */ ".cIIIIIIIc."
+ /* 5 */ ".uIIIIIIIs."
+ /* 6 */ ".cIIIIIIIc."
+ /* 7 */ ".accJJJcca."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+
+ // Level 11
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ ".cKKKcKKKc."
+ /* 4 */ ".K.......K."
+ /* 5 */ ".c.......c."
+ /* 6 */ ".K.......K."
+ /* 7 */ ".cKKKcKKKc."
+ /* 8 */ "..........."
+ /* 9 */ "...........",
+
+ // Connectors:
+ "-1: 5, 5, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 70,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // BarWithBasement
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // BarWithoutBasement:
+ // The data has been exported from the gallery Desert, area index 81, ID 597, created by STR_Warrior
+ {
+ // Size:
+ 11, 9, 10, // SizeX = 11, SizeY = 9, SizeZ = 10
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 8, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "A:126: 8\n" /* woodenslab */
+ "B:128: 7\n" /* sandstonestairs */
+ "C: 44: 1\n" /* step */
+ "D: 64: 3\n" /* wooddoorblock */
+ "E:128: 6\n" /* sandstonestairs */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f:128: 5\n" /* sandstonestairs */
+ "g:107: 2\n" /* fencegate */
+ "h:128: 4\n" /* sandstonestairs */
+ "i:134: 1\n" /* 134 */
+ "j:134: 3\n" /* 134 */
+ "k: 85: 0\n" /* fence */
+ "l:134: 0\n" /* 134 */
+ "m: 19: 0\n" /* sponge */
+ "n:134: 5\n" /* 134 */
+ "o:134: 7\n" /* 134 */
+ "p:134: 4\n" /* 134 */
+ "q:107: 1\n" /* fencegate */
+ "r: 64: 1\n" /* wooddoorblock */
+ "s: 65: 3\n" /* ladder */
+ "t: 50: 3\n" /* torch */
+ "u:171: 8\n" /* carpet */
+ "v:101: 0\n" /* ironbars */
+ "w: 64: 8\n" /* wooddoorblock */
+ "x:128: 2\n" /* sandstonestairs */
+ "y: 24: 1\n" /* sandstone */
+ "z: 44: 9\n" /* step */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmabbbammm"
+ /* 1 */ "mmmmbbbmmmm"
+ /* 2 */ "accccccccca"
+ /* 3 */ "ccccccccccc"
+ /* 4 */ "ccccccccccc"
+ /* 5 */ "ccccccccccc"
+ /* 6 */ "ccccccccccc"
+ /* 7 */ "ccccccccccc"
+ /* 8 */ "accccccccca"
+ /* 9 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmadddammm"
+ /* 1 */ "mmmmdddmmmm"
+ /* 2 */ "accceeeccca"
+ /* 3 */ "ceeeeeeeeec"
+ /* 4 */ "ceeeeeeeeec"
+ /* 5 */ "ceeeeeeeeec"
+ /* 6 */ "ceeeeeeeeec"
+ /* 7 */ "ceeeeeeeeec"
+ /* 8 */ "aecccccccca"
+ /* 9 */ "mmmmmmmmmmm"
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmma...ammm"
+ /* 1 */ "mmm.....mmm"
+ /* 2 */ "acccfghccca"
+ /* 3 */ "cij.....jjc"
+ /* 4 */ "cik.....klc"
+ /* 5 */ "c.........c"
+ /* 6 */ "cnoop.....c"
+ /* 7 */ "c...q..iklc"
+ /* 8 */ "arcccccccca"
+ /* 9 */ "mmsmmmmmmmm"
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmma...ammm"
+ /* 1 */ "mmm.....mmm"
+ /* 2 */ "accc...ccca"
+ /* 3 */ "c..t...t..c"
+ /* 4 */ "c.u.....u.c"
+ /* 5 */ "v.........v"
+ /* 6 */ "c.........c"
+ /* 7 */ "c.......u.c"
+ /* 8 */ "awccvvvccca"
+ /* 9 */ "mmsmmmmmmmm"
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmx...xmmm"
+ /* 1 */ "mmmy...cmmm"
+ /* 2 */ "acccfzhccca"
+ /* 3 */ "cAAAAAAAAAc"
+ /* 4 */ "cAAAAAAAAAc"
+ /* 5 */ "hAAAAAAAAAf"
+ /* 6 */ "cAAAAAAAAAc"
+ /* 7 */ "cAAAAAAAAAc"
+ /* 8 */ "acccBBBccca"
+ /* 9 */ "mmsmmmmmmmm"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmm.....mmm"
+ /* 1 */ "mmm.....mmm"
+ /* 2 */ "cCCCCcCCCCc"
+ /* 3 */ "CacccccccaC"
+ /* 4 */ "Cc.......cC"
+ /* 5 */ "cc.......cc"
+ /* 6 */ "Cc.......cC"
+ /* 7 */ "CaDccccccaC"
+ /* 8 */ "cC.CCcCCCCc"
+ /* 9 */ "mmmmmmmmmmm"
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ ".accvvvcca."
+ /* 4 */ ".c.......c."
+ /* 5 */ ".v.......v."
+ /* 6 */ ".c.......c."
+ /* 7 */ ".awcvvvcca."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ ".accEEEcca."
+ /* 4 */ ".cAAAAAAAc."
+ /* 5 */ ".hAAAAAAAf."
+ /* 6 */ ".cAAAAAAAc."
+ /* 7 */ ".accBBBcca."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+
+ // Level 8
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ ".cCCCcCCCc."
+ /* 4 */ ".C.......C."
+ /* 5 */ ".c.......c."
+ /* 6 */ ".C.......C."
+ /* 7 */ ".cCCCcCCCc."
+ /* 8 */ "..........."
+ /* 9 */ "...........",
+
+ // Connectors:
+ "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 80,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // BarWithoutBasement
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // BlackSmith:
+ // The data has been exported from the gallery Desert, area index 97, ID 642, created by STR_Warrior
+ {
+ // Size:
+ 11, 6, 13, // SizeX = 11, SizeY = 6, SizeZ = 13
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 5, 13, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 12: 0\n" /* sand */
+ "g: 64: 3\n" /* wooddoorblock */
+ "h: 43: 0\n" /* doubleslab */
+ "i: 53: 5\n" /* woodstairs */
+ "j: 53: 4\n" /* woodstairs */
+ "k: 10: 0\n" /* lava */
+ "l: 54: 5\n" /* chest */
+ "m: 19: 0\n" /* sponge */
+ "n: 64: 8\n" /* wooddoorblock */
+ "o: 50: 3\n" /* torch */
+ "p:101: 0\n" /* ironbars */
+ "q: 50: 1\n" /* torch */
+ "r: 50: 2\n" /* torch */
+ "s:128: 2\n" /* sandstonestairs */
+ "t: 44: 9\n" /* step */
+ "u:126: 8\n" /* woodenslab */
+ "v:128: 4\n" /* sandstonestairs */
+ "w:128: 5\n" /* sandstonestairs */
+ "x:128: 7\n" /* sandstonestairs */
+ "y: 44: 1\n" /* step */
+ "z: 43: 1\n" /* doubleslab */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmabbba"
+ /* 1 */ "mmmmmmbbbbm"
+ /* 2 */ "mmmmmmaccca"
+ /* 3 */ "maccccccccc"
+ /* 4 */ "mcccccccccc"
+ /* 5 */ "mcccccccccc"
+ /* 6 */ "mcccccacccc"
+ /* 7 */ "mcccccacccc"
+ /* 8 */ "acccaaacccc"
+ /* 9 */ "ccccccccccc"
+ /* 10 */ "ccccccccccc"
+ /* 11 */ "ccccccccccc"
+ /* 12 */ "accccccccca"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmaddda"
+ /* 1 */ "mmmmmmddddm"
+ /* 2 */ "mmmmmmaceca"
+ /* 3 */ "mafcfcceeec"
+ /* 4 */ "mcfccfceeec"
+ /* 5 */ "mcccccceeec"
+ /* 6 */ "mcffaaaeeec"
+ /* 7 */ "mffcaaaeeec"
+ /* 8 */ "acccaaaeeec"
+ /* 9 */ "ceeeeeeeeec"
+ /* 10 */ "ceeeeeeeeec"
+ /* 11 */ "ceeeeeeeeec"
+ /* 12 */ "accccccccca"
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmma...a"
+ /* 1 */ "mmmmmm....."
+ /* 2 */ "mmmmmmacgca"
+ /* 3 */ "ma....c...c"
+ /* 4 */ "m.h...c...c"
+ /* 5 */ "m.....c...c"
+ /* 6 */ "m...aac...c"
+ /* 7 */ "mij.akc...c"
+ /* 8 */ "accccca...c"
+ /* 9 */ "cl........c"
+ /* 10 */ "c.........c"
+ /* 11 */ "c.........c"
+ /* 12 */ "accccccccca"
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmma...a"
+ /* 1 */ "mmmmmm....."
+ /* 2 */ "mmmmmmacnca"
+ /* 3 */ "ma....c..oc"
+ /* 4 */ "m.....p...c"
+ /* 5 */ "m.....c...c"
+ /* 6 */ "m...ppc...p"
+ /* 7 */ "m...p.c...p"
+ /* 8 */ "accccca...p"
+ /* 9 */ "cq........c"
+ /* 10 */ "p.........c"
+ /* 11 */ "c........rc"
+ /* 12 */ "acccpppccca"
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmms...s"
+ /* 1 */ "mmmmmmc...c"
+ /* 2 */ "mmmmmmaccca"
+ /* 3 */ "mattttcuuuc"
+ /* 4 */ "mtuuuuvuuuc"
+ /* 5 */ "mtuuuucuuuc"
+ /* 6 */ "mtuuaacuuuw"
+ /* 7 */ "mtuua.cuuuw"
+ /* 8 */ "acccccauuuw"
+ /* 9 */ "cuuuuuuuuuc"
+ /* 10 */ "vuuuuuuuuuc"
+ /* 11 */ "cuuuuuuuuuc"
+ /* 12 */ "acccxxxccca"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmm....."
+ /* 1 */ "mmmmmm....."
+ /* 2 */ "mmmmmmcyyyc"
+ /* 3 */ "my.y.yy...y"
+ /* 4 */ "m.....y...y"
+ /* 5 */ "my....y...y"
+ /* 6 */ "m...zyz...y"
+ /* 7 */ "my..y.y...c"
+ /* 8 */ "cyyyzyc...y"
+ /* 9 */ "y.........y"
+ /* 10 */ "y.........y"
+ /* 11 */ "y.........y"
+ /* 12 */ "cyyyycyyyyc",
+
+ // Connectors:
+ "-1: 8, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 50,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // BlackSmith
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LargeHouse1:
+ // The data has been exported from the gallery Desert, area index 77, ID 577, created by STR_Warrior
+ {
+ // Size:
+ 15, 14, 11, // SizeX = 15, SizeY = 14, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, 0, -1, // MinX, MinY, MinZ
+ 14, 13, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "A: 96:10\n" /* trapdoor */
+ "B:128: 4\n" /* sandstonestairs */
+ "C:128: 5\n" /* sandstonestairs */
+ "D:128: 7\n" /* sandstonestairs */
+ "E: 44: 1\n" /* step */
+ "F:128: 2\n" /* sandstonestairs */
+ "G:128: 0\n" /* sandstonestairs */
+ "H: 87: 0\n" /* netherstone */
+ "I:128: 3\n" /* sandstonestairs */
+ "J: 51: 0\n" /* fire */
+ "K: 44: 9\n" /* step */
+ "a: 24: 2\n" /* sandstone */
+ "b: 24: 0\n" /* sandstone */
+ "c: 12: 0\n" /* sand */
+ "d: 4: 0\n" /* cobblestone */
+ "e: 5: 0\n" /* wood */
+ "f: 13: 0\n" /* gravel */
+ "g: 85: 0\n" /* fence */
+ "h: 5: 1\n" /* wood */
+ "i: 64: 2\n" /* wooddoorblock */
+ "j: 64: 0\n" /* wooddoorblock */
+ "k: 61: 2\n" /* furnace */
+ "l:118: 0\n" /* cauldronblock */
+ "m: 19: 0\n" /* sponge */
+ "n:134: 4\n" /* 134 */
+ "o: 65: 2\n" /* ladder */
+ "p:101: 0\n" /* ironbars */
+ "q: 50: 1\n" /* torch */
+ "r:140: 0\n" /* flowerpotblock */
+ "s: 64: 8\n" /* wooddoorblock */
+ "t: 50: 3\n" /* torch */
+ "u: 69:12\n" /* lever */
+ "v: 50: 4\n" /* torch */
+ "w:128: 6\n" /* sandstonestairs */
+ "x: 44:10\n" /* step */
+ "y:128: 1\n" /* sandstonestairs */
+ "z: 47: 0\n" /* bookshelf */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmabbbbbbbamm"
+ /* 1 */ "ccccbbbbbbbbbma"
+ /* 2 */ "ccccbbbbbbbbbdd"
+ /* 3 */ "ccccbbbbbbbbbdd"
+ /* 4 */ "ccccbbbbbbbbbdd"
+ /* 5 */ "ccccbbbbbbbbbma"
+ /* 6 */ "ccccbbbbbbbbbmm"
+ /* 7 */ "mmmmbbbbbbbbbmm"
+ /* 8 */ "mmmmbbbbbbbbbmm"
+ /* 9 */ "mmmmbbbbbbbbbmm"
+ /* 10 */ "mmmmabbbbbbbamm"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmabbbbbbbamm"
+ /* 1 */ "ccccbeeeeeeebma"
+ /* 2 */ "cccceeeeeeeebff"
+ /* 3 */ "ccccbeeeeeeeeff"
+ /* 4 */ "ccccbeeeeeeebff"
+ /* 5 */ "ccccbeeeeeeebma"
+ /* 6 */ "ccccbeeeeeeebmm"
+ /* 7 */ "mmmmbeeeeeeebmm"
+ /* 8 */ "mmmmbeeeeeeebmm"
+ /* 9 */ "mmmmbeeeeeeebmm"
+ /* 10 */ "mmmmabbbbbbbamm"
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmabbbbbbbamm"
+ /* 1 */ "ggggb......hb.a"
+ /* 2 */ "g...i.......b.."
+ /* 3 */ "g...b.......j.."
+ /* 4 */ "g...bkln..o.b.."
+ /* 5 */ "g...bbbb.bbbb.a"
+ /* 6 */ "ggggb.......bmm"
+ /* 7 */ "mmmmb.......bmm"
+ /* 8 */ "mmmmb.......bmm"
+ /* 9 */ "mmmmb.......bmm"
+ /* 10 */ "mmmmabbbbbbbamm"
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmabbpppbbamm"
+ /* 1 */ "....bq.....rb.a"
+ /* 2 */ "....s.......b.t"
+ /* 3 */ "....b.......s.."
+ /* 4 */ "....b.u...o.b.v"
+ /* 5 */ "....bbbb.bbbb.a"
+ /* 6 */ "....p..t.t..pmm"
+ /* 7 */ "mmmmp.......pmm"
+ /* 8 */ "mmmmp.......pmm"
+ /* 9 */ "mmmmb.......bmm"
+ /* 10 */ "mmmmabbpppbbamm"
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmabbwwwbbamm"
+ /* 1 */ "....bxxxxxxxbby"
+ /* 2 */ "....bxxxxxxxb.."
+ /* 3 */ "....bxxxxxxxb.."
+ /* 4 */ "....bzzzxxAxb.."
+ /* 5 */ "....bbbbbbbbbby"
+ /* 6 */ "....BxxxxxxxCmm"
+ /* 7 */ "mmmmBxxxxxxxCmm"
+ /* 8 */ "mmmmBxxxxxxxCmm"
+ /* 9 */ "mmmmbxxxxxxxbmm"
+ /* 10 */ "mmmmabbDDDbbamm"
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmbEEEbEEEbmm"
+ /* 1 */ "....EabbbbbaE.."
+ /* 2 */ "....Eb.....bE.."
+ /* 3 */ "....Eb.....bE.."
+ /* 4 */ "....Eb.....bE.."
+ /* 5 */ "....babb.bbab.."
+ /* 6 */ "....E.......Emm"
+ /* 7 */ "mmmmE.......Emm"
+ /* 8 */ "mmmmE.......Emm"
+ /* 9 */ "mmmmE.......Emm"
+ /* 10 */ "mmmmbEEEbEEEbmm"
+
+ // Level 6
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".....abbpbba..."
+ /* 2 */ ".....p.....p..."
+ /* 3 */ ".....p.....p..."
+ /* 4 */ ".....p.....p..."
+ /* 5 */ ".....abb.bba..."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+ /* 9 */ "..............."
+ /* 10 */ "..............."
+
+ // Level 7
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".....abbwbba..."
+ /* 2 */ ".....BxxxxxC..."
+ /* 3 */ ".....BxxxxxC..."
+ /* 4 */ ".....BxxxxxC..."
+ /* 5 */ ".....abbbbba..."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+ /* 9 */ "..............."
+ /* 10 */ "..............."
+
+ // Level 8
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".....bEEbEEb..."
+ /* 2 */ ".....E.bbb.E..."
+ /* 3 */ ".....b.bbb.b..."
+ /* 4 */ ".....E.bbb.E..."
+ /* 5 */ ".....bEEbEEb..."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+ /* 9 */ "..............."
+ /* 10 */ "..............."
+
+ // Level 9
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ ".......aFa....."
+ /* 3 */ ".......GHy....."
+ /* 4 */ ".......aIa....."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+ /* 9 */ "..............."
+ /* 10 */ "..............."
+
+ // Level 10
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ ".......a.a....."
+ /* 3 */ "........J......"
+ /* 4 */ ".......a.a....."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+ /* 9 */ "..............."
+ /* 10 */ "..............."
+
+ // Level 11
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ ".......awa....."
+ /* 3 */ ".......B.C....."
+ /* 4 */ ".......aDa....."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+ /* 9 */ "..............."
+ /* 10 */ "..............."
+
+ // Level 12
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ ".......bbb....."
+ /* 3 */ ".......bKb....."
+ /* 4 */ ".......bbb....."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+ /* 9 */ "..............."
+ /* 10 */ "..............."
+
+ // Level 13
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ ".......E.E....."
+ /* 3 */ "..............."
+ /* 4 */ ".......E.E....."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+ /* 9 */ "..............."
+ /* 10 */ "...............",
+
+ // Connectors:
+ "-1: 14, 2, 3: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 60,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LargeHouse1
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LargeTower:
+ // The data has been exported from the gallery Desert, area index 80, ID 596, created by STR_Warrior
+ {
+ // Size:
+ 7, 12, 7, // SizeX = 7, SizeY = 12, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 7, 11, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 12: 0\n" /* sand */
+ "d: 5: 0\n" /* wood */
+ "e: 13: 0\n" /* gravel */
+ "f:128: 2\n" /* sandstonestairs */
+ "g:128: 0\n" /* sandstonestairs */
+ "h: 24: 2\n" /* sandstone */
+ "i: 71: 3\n" /* irondoorblock */
+ "j:128: 1\n" /* sandstonestairs */
+ "k:128: 3\n" /* sandstonestairs */
+ "l: 77: 4\n" /* stonebutton */
+ "m: 19: 0\n" /* sponge */
+ "n: 71: 8\n" /* irondoorblock */
+ "o: 77: 3\n" /* stonebutton */
+ "p:128: 6\n" /* sandstonestairs */
+ "q:128: 4\n" /* sandstonestairs */
+ "r:128: 5\n" /* sandstonestairs */
+ "s: 50: 4\n" /* torch */
+ "t:128: 7\n" /* sandstonestairs */
+ "u: 85: 0\n" /* fence */
+ "v: 24: 1\n" /* sandstone */
+ "w: 44: 1\n" /* step */
+ "x: 89: 0\n" /* lightstone */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mabbbam"
+ /* 1 */ "aacdcaa"
+ /* 2 */ "madddam"
+ /* 3 */ "madddam"
+ /* 4 */ "madddam"
+ /* 5 */ "aaaaaaa"
+ /* 6 */ "mammmam"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "maeeeam"
+ /* 1 */ "aacdcaa"
+ /* 2 */ "madddam"
+ /* 3 */ "madddam"
+ /* 4 */ "madddam"
+ /* 5 */ "aaaaaaa"
+ /* 6 */ "mammmam"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "mf...fm"
+ /* 1 */ "ghaiahj"
+ /* 2 */ "ma...am"
+ /* 3 */ "ma...am"
+ /* 4 */ "ma...am"
+ /* 5 */ "ghaaahj"
+ /* 6 */ "mkmmmkm"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "m.l...m"
+ /* 1 */ ".hanah."
+ /* 2 */ ".ao..a."
+ /* 3 */ ".a...a."
+ /* 4 */ ".a...a."
+ /* 5 */ ".haaah."
+ /* 6 */ "m.....m"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "..pap.."
+ /* 2 */ ".q...r."
+ /* 3 */ ".a...a."
+ /* 4 */ ".q.s.r."
+ /* 5 */ "..tat.."
+ /* 6 */ "......."
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "..aua.."
+ /* 2 */ ".a...a."
+ /* 3 */ ".u...u."
+ /* 4 */ ".a...a."
+ /* 5 */ "..aua.."
+ /* 6 */ "......."
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "..aua.."
+ /* 2 */ ".a...a."
+ /* 3 */ ".u...u."
+ /* 4 */ ".a...a."
+ /* 5 */ "..aua.."
+ /* 6 */ "......."
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "..aua.."
+ /* 2 */ ".a...a."
+ /* 3 */ ".u...u."
+ /* 4 */ ".a...a."
+ /* 5 */ "..aua.."
+ /* 6 */ "......."
+
+ // Level 8
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "..faf.."
+ /* 2 */ ".g...j."
+ /* 3 */ ".a...a."
+ /* 4 */ ".g...j."
+ /* 5 */ "..kak.."
+ /* 6 */ "......."
+
+ // Level 9
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".aavaa."
+ /* 2 */ ".a...a."
+ /* 3 */ ".v...v."
+ /* 4 */ ".a...a."
+ /* 5 */ ".aavaa."
+ /* 6 */ "......."
+
+ // Level 10
+ /* z\x* 0123456 */
+ /* 0 */ "...p..."
+ /* 1 */ ".haaah."
+ /* 2 */ ".awwwa."
+ /* 3 */ "qawawar"
+ /* 4 */ ".awwwa."
+ /* 5 */ ".haaah."
+ /* 6 */ "...t..."
+
+ // Level 11
+ /* z\x* 0123456 */
+ /* 0 */ "...w..."
+ /* 1 */ ".w...w."
+ /* 2 */ "......."
+ /* 3 */ "w..x..w"
+ /* 4 */ "......."
+ /* 5 */ ".w...w."
+ /* 6 */ "...w...",
+
+ // Connectors:
+ "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LargeTower
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LittleHouse:
+ // The data has been exported from the gallery Desert, area index 65, ID 551, created by STR_Warrior
+ {
+ // Size:
+ 5, 6, 7, // SizeX = 5, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 5, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 64: 3\n" /* wooddoorblock */
+ "g: 61: 2\n" /* furnace */
+ "h: 65: 2\n" /* ladder */
+ "i: 64: 8\n" /* wooddoorblock */
+ "j:101: 0\n" /* ironbars */
+ "k: 50: 4\n" /* torch */
+ "l:128: 2\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n:126: 8\n" /* woodenslab */
+ "o:128: 4\n" /* sandstonestairs */
+ "p:128: 5\n" /* sandstonestairs */
+ "q:128: 7\n" /* sandstonestairs */
+ "r: 44: 1\n" /* step */
+ "s: 96: 2\n" /* trapdoor */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 01234 */
+ /* 0 */ "abbba"
+ /* 1 */ "mbbbm"
+ /* 2 */ "accca"
+ /* 3 */ "ccccc"
+ /* 4 */ "ccccc"
+ /* 5 */ "ccccc"
+ /* 6 */ "accca"
+
+ // Level 1
+ /* z\x* 01234 */
+ /* 0 */ "addda"
+ /* 1 */ "mdddm"
+ /* 2 */ "aceca"
+ /* 3 */ "ceeec"
+ /* 4 */ "ceeec"
+ /* 5 */ "ceeec"
+ /* 6 */ "accca"
+
+ // Level 2
+ /* z\x* 01234 */
+ /* 0 */ "a...a"
+ /* 1 */ "....."
+ /* 2 */ "acfca"
+ /* 3 */ "c...c"
+ /* 4 */ "c...c"
+ /* 5 */ "cg.hc"
+ /* 6 */ "accca"
+
+ // Level 3
+ /* z\x* 01234 */
+ /* 0 */ "a...a"
+ /* 1 */ "....."
+ /* 2 */ "acica"
+ /* 3 */ "c...c"
+ /* 4 */ "j...j"
+ /* 5 */ "ck.hc"
+ /* 6 */ "acjca"
+
+ // Level 4
+ /* z\x* 01234 */
+ /* 0 */ "l...l"
+ /* 1 */ "c...c"
+ /* 2 */ "accca"
+ /* 3 */ "cnnnc"
+ /* 4 */ "onnnp"
+ /* 5 */ "cnnhc"
+ /* 6 */ "acqca"
+
+ // Level 5
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "crcrc"
+ /* 3 */ "r...r"
+ /* 4 */ "c...c"
+ /* 5 */ "r..sr"
+ /* 6 */ "crcrc",
+
+ // Connectors:
+ "-1: 2, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LittleHouse
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LittleHouse2:
+ // The data has been exported from the gallery Desert, area index 72, ID 562, created by STR_Warrior
+ {
+ // Size:
+ 7, 6, 11, // SizeX = 7, SizeY = 6, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 7, 5, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 12: 0\n" /* sand */
+ "e: 13: 0\n" /* gravel */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 3\n" /* wooddoorblock */
+ "h: 65: 5\n" /* ladder */
+ "i: 85: 0\n" /* fence */
+ "j:101: 0\n" /* ironbars */
+ "k: 64: 8\n" /* wooddoorblock */
+ "l: 50: 3\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 2\n" /* sandstonestairs */
+ "o:128: 6\n" /* sandstonestairs */
+ "p:126: 8\n" /* woodenslab */
+ "q:128: 4\n" /* sandstonestairs */
+ "r:128: 5\n" /* sandstonestairs */
+ "s:128: 7\n" /* sandstonestairs */
+ "t: 44: 1\n" /* step */
+ "u: 96: 0\n" /* trapdoor */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mabbbam"
+ /* 1 */ "mmbbbmm"
+ /* 2 */ "accccca"
+ /* 3 */ "ccccccc"
+ /* 4 */ "ccccccc"
+ /* 5 */ "ccccccc"
+ /* 6 */ "accccca"
+ /* 7 */ "ddddddd"
+ /* 8 */ "ddddddd"
+ /* 9 */ "ddddddd"
+ /* 10 */ "ddddddd"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "maeeeam"
+ /* 1 */ "mmeeemm"
+ /* 2 */ "acccfca"
+ /* 3 */ "cfffffc"
+ /* 4 */ "cfffffc"
+ /* 5 */ "cfffffc"
+ /* 6 */ "acfccca"
+ /* 7 */ "ddddddd"
+ /* 8 */ "ddddddd"
+ /* 9 */ "ddddddd"
+ /* 10 */ "ddddddd"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "ma...am"
+ /* 1 */ "m.....m"
+ /* 2 */ "acccgca"
+ /* 3 */ "c.....c"
+ /* 4 */ "c.....c"
+ /* 5 */ "ch....c"
+ /* 6 */ "ac.ccca"
+ /* 7 */ "i.....i"
+ /* 8 */ "i.....i"
+ /* 9 */ "i.....i"
+ /* 10 */ "iiiiiii"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "ma...am"
+ /* 1 */ "m.....m"
+ /* 2 */ "acjckca"
+ /* 3 */ "c..l..c"
+ /* 4 */ "j.....j"
+ /* 5 */ "ch....c"
+ /* 6 */ "ac.cjca"
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "mn...nm"
+ /* 1 */ "mc...cm"
+ /* 2 */ "acoccca"
+ /* 3 */ "cpppppc"
+ /* 4 */ "qpppppr"
+ /* 5 */ "chppppc"
+ /* 6 */ "acccsca"
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "m.....m"
+ /* 1 */ "m.....m"
+ /* 2 */ "cttcttc"
+ /* 3 */ "t.....t"
+ /* 4 */ "c.....c"
+ /* 5 */ "tu....t"
+ /* 6 */ "cttcttc"
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ ".......",
+
+ // Connectors:
+ "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LittleHouse2
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LittleHouse3:
+ // The data has been exported from the gallery Desert, area index 66, ID 553, created by STR_Warrior
+ {
+ // Size:
+ 9, 6, 7, // SizeX = 9, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 9, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 64: 3\n" /* wooddoorblock */
+ "g: 65: 2\n" /* ladder */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i:101: 0\n" /* ironbars */
+ "j: 50: 4\n" /* torch */
+ "k:128: 2\n" /* sandstonestairs */
+ "l:126: 8\n" /* woodenslab */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 4\n" /* sandstonestairs */
+ "o:128: 5\n" /* sandstonestairs */
+ "p:128: 7\n" /* sandstonestairs */
+ "q: 44: 1\n" /* step */
+ "r: 96: 2\n" /* trapdoor */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmabbbamm"
+ /* 1 */ "mmmbbbmmm"
+ /* 2 */ "accccccca"
+ /* 3 */ "ccccccccc"
+ /* 4 */ "ccccccccc"
+ /* 5 */ "ccccccccc"
+ /* 6 */ "accccccca"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "mmadddamm"
+ /* 1 */ "mmmdddmmm"
+ /* 2 */ "accceccca"
+ /* 3 */ "ceeeeeeec"
+ /* 4 */ "ceeeeeeec"
+ /* 5 */ "ceeeeeeec"
+ /* 6 */ "accccccca"
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "mma...amm"
+ /* 1 */ "mm.....mm"
+ /* 2 */ "acccfccca"
+ /* 3 */ "c.......c"
+ /* 4 */ "c.......c"
+ /* 5 */ "c......gc"
+ /* 6 */ "accccccca"
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "mma...amm"
+ /* 1 */ "mm.....mm"
+ /* 2 */ "accchccca"
+ /* 3 */ "c.......c"
+ /* 4 */ "i.......i"
+ /* 5 */ "c.j....gc"
+ /* 6 */ "acciiicca"
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "mmk...kmm"
+ /* 1 */ "mmc...cmm"
+ /* 2 */ "accccccca"
+ /* 3 */ "clllllllc"
+ /* 4 */ "nlllllllo"
+ /* 5 */ "cllllllgc"
+ /* 6 */ "accpppcca"
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "mm.....mm"
+ /* 1 */ "mm.....mm"
+ /* 2 */ "cqqqcqqqc"
+ /* 3 */ "q.......q"
+ /* 4 */ "c.......c"
+ /* 5 */ "q......rq"
+ /* 6 */ "cqqqcqqqc",
+
+ // Connectors:
+ "-1: 4, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LittleHouse3
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LittleHouse4:
+ // The data has been exported from the gallery Desert, area index 70, ID 560, created by STR_Warrior
+ {
+ // Size:
+ 5, 6, 11, // SizeX = 5, SizeY = 6, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 5, 5, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 64: 3\n" /* wooddoorblock */
+ "g: 65: 5\n" /* ladder */
+ "h:134: 3\n" /* 134 */
+ "i: 85: 0\n" /* fence */
+ "j:134: 2\n" /* 134 */
+ "k: 61: 2\n" /* furnace */
+ "l:134: 6\n" /* 134 */
+ "m: 19: 0\n" /* sponge */
+ "n:134: 4\n" /* 134 */
+ "o: 64: 8\n" /* wooddoorblock */
+ "p: 50: 2\n" /* torch */
+ "q:101: 0\n" /* ironbars */
+ "r:171: 8\n" /* carpet */
+ "s:128: 2\n" /* sandstonestairs */
+ "t:126: 8\n" /* woodenslab */
+ "u:128: 4\n" /* sandstonestairs */
+ "v:128: 5\n" /* sandstonestairs */
+ "w:128: 7\n" /* sandstonestairs */
+ "x: 44: 1\n" /* step */
+ "y: 96: 1\n" /* trapdoor */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 01234 */
+ /* 0 */ "abbba"
+ /* 1 */ "mbbbm"
+ /* 2 */ "accca"
+ /* 3 */ "ccccc"
+ /* 4 */ "ccccc"
+ /* 5 */ "ccccc"
+ /* 6 */ "ccccc"
+ /* 7 */ "ccccc"
+ /* 8 */ "ccccc"
+ /* 9 */ "ccccc"
+ /* 10 */ "accca"
+
+ // Level 1
+ /* z\x* 01234 */
+ /* 0 */ "addda"
+ /* 1 */ "mdddm"
+ /* 2 */ "aceca"
+ /* 3 */ "ceeec"
+ /* 4 */ "ceeec"
+ /* 5 */ "ceeec"
+ /* 6 */ "ceeec"
+ /* 7 */ "ceeec"
+ /* 8 */ "ceeec"
+ /* 9 */ "ceeec"
+ /* 10 */ "accca"
+
+ // Level 2
+ /* z\x* 01234 */
+ /* 0 */ "a...a"
+ /* 1 */ "....."
+ /* 2 */ "acfca"
+ /* 3 */ "cg..c"
+ /* 4 */ "c...c"
+ /* 5 */ "c..hc"
+ /* 6 */ "c..ic"
+ /* 7 */ "c..jc"
+ /* 8 */ "c...c"
+ /* 9 */ "cklnc"
+ /* 10 */ "accca"
+
+ // Level 3
+ /* z\x* 01234 */
+ /* 0 */ "a...a"
+ /* 1 */ "....."
+ /* 2 */ "acoca"
+ /* 3 */ "cg..c"
+ /* 4 */ "c..pc"
+ /* 5 */ "q...q"
+ /* 6 */ "q..rq"
+ /* 7 */ "q...q"
+ /* 8 */ "c...c"
+ /* 9 */ "c...c"
+ /* 10 */ "acqca"
+
+ // Level 4
+ /* z\x* 01234 */
+ /* 0 */ "s...s"
+ /* 1 */ "c...c"
+ /* 2 */ "accca"
+ /* 3 */ "cgttc"
+ /* 4 */ "ctttc"
+ /* 5 */ "utttv"
+ /* 6 */ "utttv"
+ /* 7 */ "utttv"
+ /* 8 */ "ctttc"
+ /* 9 */ "ctttc"
+ /* 10 */ "acwca"
+
+ // Level 5
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "cxcxc"
+ /* 3 */ "xy..x"
+ /* 4 */ "x...x"
+ /* 5 */ "x...x"
+ /* 6 */ "c...c"
+ /* 7 */ "x...x"
+ /* 8 */ "x...x"
+ /* 9 */ "x...x"
+ /* 10 */ "cxcxc",
+
+ // Connectors:
+ "-1: 2, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LittleHouse4
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LittleHouse5:
+ // The data has been exported from the gallery Desert, area index 68, ID 558, created by STR_Warrior
+ {
+ // Size:
+ 9, 6, 9, // SizeX = 9, SizeY = 6, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 9, 5, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 64: 3\n" /* wooddoorblock */
+ "g: 65: 2\n" /* ladder */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i:101: 0\n" /* ironbars */
+ "j: 50: 1\n" /* torch */
+ "k: 50: 4\n" /* torch */
+ "l:128: 2\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n:126: 8\n" /* woodenslab */
+ "o:128: 6\n" /* sandstonestairs */
+ "p:128: 5\n" /* sandstonestairs */
+ "q:128: 4\n" /* sandstonestairs */
+ "r:128: 7\n" /* sandstonestairs */
+ "s: 44: 1\n" /* step */
+ "t: 96: 2\n" /* trapdoor */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmabbba"
+ /* 1 */ "mmmmmbbbm"
+ /* 2 */ "mmmmaccca"
+ /* 3 */ "mmmmccccc"
+ /* 4 */ "acccacccc"
+ /* 5 */ "ccccccccc"
+ /* 6 */ "ccccccccc"
+ /* 7 */ "ccccccccc"
+ /* 8 */ "accccccca"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmaddda"
+ /* 1 */ "mmmmmdddm"
+ /* 2 */ "mmmmaceca"
+ /* 3 */ "mmmmceeec"
+ /* 4 */ "acccaeeec"
+ /* 5 */ "ceeeeeeec"
+ /* 6 */ "ceeeeeeec"
+ /* 7 */ "ceeeeeeec"
+ /* 8 */ "accccccca"
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "mmmma...a"
+ /* 1 */ "mmmm....."
+ /* 2 */ "mmmmacfca"
+ /* 3 */ "mmmmc...c"
+ /* 4 */ "accca...c"
+ /* 5 */ "c.......c"
+ /* 6 */ "c.......c"
+ /* 7 */ "c......gc"
+ /* 8 */ "accccccca"
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "mmmma...a"
+ /* 1 */ "mmmm....."
+ /* 2 */ "mmmmachca"
+ /* 3 */ "mmmmc...c"
+ /* 4 */ "acica...i"
+ /* 5 */ "c.......i"
+ /* 6 */ "i.......i"
+ /* 7 */ "cj....kgc"
+ /* 8 */ "acciiicca"
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "mmmml...l"
+ /* 1 */ "mmmmc...c"
+ /* 2 */ "mmmmaccca"
+ /* 3 */ "mmmmcnnnc"
+ /* 4 */ "acocannnp"
+ /* 5 */ "cnnnnnnnp"
+ /* 6 */ "qnnnnnnnp"
+ /* 7 */ "cnnnnnngc"
+ /* 8 */ "accrrrcca"
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "mmmm....."
+ /* 1 */ "mmmm....."
+ /* 2 */ "mmmmcscsc"
+ /* 3 */ "mmmms...s"
+ /* 4 */ "csssc...c"
+ /* 5 */ "s.......s"
+ /* 6 */ "s.......s"
+ /* 7 */ "s......ts"
+ /* 8 */ "cssscsssc",
+
+ // Connectors:
+ "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LittleHouse5
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LittleHouse6:
+ // The data has been exported from the gallery Desert, area index 69, ID 559, created by STR_Warrior
+ {
+ // Size:
+ 9, 6, 9, // SizeX = 9, SizeY = 6, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 9, 5, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "A: 96: 2\n" /* trapdoor */
+ "a: 12: 0\n" /* sand */
+ "b: 24: 2\n" /* sandstone */
+ "c: 4: 0\n" /* cobblestone */
+ "d: 3: 0\n" /* dirt */
+ "e: 24: 0\n" /* sandstone */
+ "f: 13: 0\n" /* gravel */
+ "g: 2: 0\n" /* grass */
+ "h: 5: 0\n" /* wood */
+ "i: 85: 0\n" /* fence */
+ "j: 64: 3\n" /* wooddoorblock */
+ "k: 38: 1\n" /* rose */
+ "l: 38: 2\n" /* rose */
+ "m: 19: 0\n" /* sponge */
+ "n: 38: 5\n" /* rose */
+ "o: 65: 2\n" /* ladder */
+ "p: 64: 8\n" /* wooddoorblock */
+ "q:101: 0\n" /* ironbars */
+ "r: 50: 1\n" /* torch */
+ "s: 50: 4\n" /* torch */
+ "t:128: 2\n" /* sandstonestairs */
+ "u:126: 8\n" /* woodenslab */
+ "v:128: 6\n" /* sandstonestairs */
+ "w:128: 5\n" /* sandstonestairs */
+ "x:128: 4\n" /* sandstonestairs */
+ "y:128: 7\n" /* sandstonestairs */
+ "z: 44: 1\n" /* step */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "aaaabcccb"
+ /* 1 */ "adddccccm"
+ /* 2 */ "adddbeeeb"
+ /* 3 */ "adddeeeee"
+ /* 4 */ "beeebeeee"
+ /* 5 */ "eeeeeeeee"
+ /* 6 */ "eeeeeeeee"
+ /* 7 */ "eeeeeeeee"
+ /* 8 */ "beeeeeeeb"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "aaaabfffb"
+ /* 1 */ "agggffffm"
+ /* 2 */ "agggbeheb"
+ /* 3 */ "agggehhhe"
+ /* 4 */ "beeebhhhe"
+ /* 5 */ "ehhhhhhhe"
+ /* 6 */ "ehhhhhhhe"
+ /* 7 */ "ehhhhhhhe"
+ /* 8 */ "beeeeeeeb"
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "iiiib...b"
+ /* 1 */ "i........"
+ /* 2 */ "i...bejeb"
+ /* 3 */ "iklne...e"
+ /* 4 */ "beeeb...e"
+ /* 5 */ "e.......e"
+ /* 6 */ "e.......e"
+ /* 7 */ "e......oe"
+ /* 8 */ "beeeeeeeb"
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "....b...b"
+ /* 1 */ "........."
+ /* 2 */ "....bepeb"
+ /* 3 */ "....e...e"
+ /* 4 */ "beqeb...q"
+ /* 5 */ "e.......q"
+ /* 6 */ "q.......q"
+ /* 7 */ "er....soe"
+ /* 8 */ "beeqqqeeb"
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "....t...t"
+ /* 1 */ "....e...e"
+ /* 2 */ "....beeeb"
+ /* 3 */ "....euuue"
+ /* 4 */ "bevebuuuw"
+ /* 5 */ "euuuuuuuw"
+ /* 6 */ "xuuuuuuuw"
+ /* 7 */ "euuuuuuoe"
+ /* 8 */ "beeyyyeeb"
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ "........."
+ /* 2 */ "....ezeze"
+ /* 3 */ "....z...z"
+ /* 4 */ "ezzze...e"
+ /* 5 */ "z.......z"
+ /* 6 */ "z.......z"
+ /* 7 */ "z......Az"
+ /* 8 */ "ezzzezzze",
+
+ // Connectors:
+ "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LittleHouse6
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LittleHouse7:
+ // The data has been exported from the gallery Desert, area index 73, ID 563, created by xoft
+ {
+ // Size:
+ 9, 6, 11, // SizeX = 9, SizeY = 6, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 9, 5, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 64: 3\n" /* wooddoorblock */
+ "g: 65: 2\n" /* ladder */
+ "h:101: 0\n" /* ironbars */
+ "i: 64: 8\n" /* wooddoorblock */
+ "j: 50: 1\n" /* torch */
+ "k: 50: 2\n" /* torch */
+ "l:128: 2\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 6\n" /* sandstonestairs */
+ "o:126: 8\n" /* woodenslab */
+ "p:128: 4\n" /* sandstonestairs */
+ "q:128: 5\n" /* sandstonestairs */
+ "r:128: 7\n" /* sandstonestairs */
+ "s: 44: 1\n" /* step */
+ "t: 96: 2\n" /* trapdoor */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmabbba"
+ /* 1 */ "mmmmmbbbm"
+ /* 2 */ "accccccca"
+ /* 3 */ "ccccccccc"
+ /* 4 */ "ccccccccc"
+ /* 5 */ "ccccccccc"
+ /* 6 */ "acccacccc"
+ /* 7 */ "mmmmccccc"
+ /* 8 */ "mmmmccccc"
+ /* 9 */ "mmmmccccc"
+ /* 10 */ "mmmmaccca"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmaddda"
+ /* 1 */ "mmmmmdddm"
+ /* 2 */ "accccceca"
+ /* 3 */ "ceeeeeeec"
+ /* 4 */ "ceeeeeeec"
+ /* 5 */ "ceeeeeeec"
+ /* 6 */ "acccaeeec"
+ /* 7 */ "mmmmceeec"
+ /* 8 */ "mmmmceeec"
+ /* 9 */ "mmmmceeec"
+ /* 10 */ "mmmmaccca"
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "mmmma...a"
+ /* 1 */ "mmmm....."
+ /* 2 */ "acccccfca"
+ /* 3 */ "c.......c"
+ /* 4 */ "c.......c"
+ /* 5 */ "c.......c"
+ /* 6 */ "accca...c"
+ /* 7 */ "mmmmc...c"
+ /* 8 */ "mmmmc...c"
+ /* 9 */ "mmmmc..gc"
+ /* 10 */ "mmmmaccca"
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "mmmma...a"
+ /* 1 */ "mmmm....."
+ /* 2 */ "achcccica"
+ /* 3 */ "c.......c"
+ /* 4 */ "h.......c"
+ /* 5 */ "cj......h"
+ /* 6 */ "achca...h"
+ /* 7 */ "mmmmc...h"
+ /* 8 */ "mmmmh..kc"
+ /* 9 */ "mmmmc..gc"
+ /* 10 */ "mmmmachca"
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "mmmml...l"
+ /* 1 */ "mmmmc...c"
+ /* 2 */ "acnccccca"
+ /* 3 */ "coooooooc"
+ /* 4 */ "poooooooc"
+ /* 5 */ "coooooooq"
+ /* 6 */ "acrcaoooq"
+ /* 7 */ "mmmmcoooq"
+ /* 8 */ "mmmmpoooc"
+ /* 9 */ "mmmmcoogc"
+ /* 10 */ "mmmmacrca"
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "mmmm....."
+ /* 1 */ "mmmm....."
+ /* 2 */ "cssscscsc"
+ /* 3 */ "s.......s"
+ /* 4 */ "s.......s"
+ /* 5 */ "s.......s"
+ /* 6 */ "csssc...c"
+ /* 7 */ "mmmms...s"
+ /* 8 */ "mmmms...s"
+ /* 9 */ "mmmms..ts"
+ /* 10 */ "mmmmcsssc",
+
+ // Connectors:
+ "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LittleHouse7
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LittleHouse8:
+ // The data has been exported from the gallery Desert, area index 99, ID 739, created by STR_Warrior
+ {
+ // Size:
+ 9, 6, 9, // SizeX = 9, SizeY = 6, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ 0, 0, -1, // MinX, MinY, MinZ
+ 9, 5, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 24: 0\n" /* sandstone */
+ "c: 4: 0\n" /* cobblestone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 64: 2\n" /* wooddoorblock */
+ "g: 65: 2\n" /* ladder */
+ "h:101: 0\n" /* ironbars */
+ "i: 64: 8\n" /* wooddoorblock */
+ "j: 50: 1\n" /* torch */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:126: 8\n" /* woodenslab */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 5\n" /* sandstonestairs */
+ "o:128: 4\n" /* sandstonestairs */
+ "p:128: 7\n" /* sandstonestairs */
+ "q: 44: 1\n" /* step */
+ "r: 96: 2\n" /* trapdoor */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmabbba"
+ /* 1 */ "ccccbbbbb"
+ /* 2 */ "ccccbbbbb"
+ /* 3 */ "ccccbbbbb"
+ /* 4 */ "abbbabbbb"
+ /* 5 */ "bbbbbbbbb"
+ /* 6 */ "bbbbbbbbb"
+ /* 7 */ "bbbbbbbbb"
+ /* 8 */ "abbbbbbba"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmabbba"
+ /* 1 */ "ddddbeeeb"
+ /* 2 */ "ddddeeeeb"
+ /* 3 */ "ddddbeeeb"
+ /* 4 */ "abbbaeeeb"
+ /* 5 */ "beeeeeeeb"
+ /* 6 */ "beeeeeeeb"
+ /* 7 */ "beeeeeeeb"
+ /* 8 */ "abbbbbbba"
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmabbba"
+ /* 1 */ "....b...b"
+ /* 2 */ "....f...b"
+ /* 3 */ "....b...b"
+ /* 4 */ "abbba...b"
+ /* 5 */ "b.......b"
+ /* 6 */ "b.......b"
+ /* 7 */ "b......gb"
+ /* 8 */ "abbbbbbba"
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmabhba"
+ /* 1 */ "....b...b"
+ /* 2 */ "....i...b"
+ /* 3 */ "....b...h"
+ /* 4 */ "abhbaj..h"
+ /* 5 */ "b.......h"
+ /* 6 */ "h.......b"
+ /* 7 */ "b......gb"
+ /* 8 */ "abbhhhbba"
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmabkba"
+ /* 1 */ "....blllb"
+ /* 2 */ "....blllb"
+ /* 3 */ "....bllln"
+ /* 4 */ "abkballln"
+ /* 5 */ "bllllllln"
+ /* 6 */ "olllllllb"
+ /* 7 */ "bllllllgb"
+ /* 8 */ "abbpppbba"
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmbqbqb"
+ /* 1 */ "....q...q"
+ /* 2 */ "....q...q"
+ /* 3 */ "....q...q"
+ /* 4 */ "bqqqb...b"
+ /* 5 */ "q.......q"
+ /* 6 */ "b.......q"
+ /* 7 */ "q......rq"
+ /* 8 */ "bqqqbqqqb",
+
+ // Connectors:
+ "-1: 0, 2, 2: 4\n" /* Type -1, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LittleHouse8
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LittleTower:
+ // The data has been exported from the gallery Desert, area index 79, ID 595, created by STR_Warrior
+ {
+ // Size:
+ 5, 9, 7, // SizeX = 5, SizeY = 9, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 5, 8, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 64: 3\n" /* wooddoorblock */
+ "g: 65: 5\n" /* ladder */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i:101: 0\n" /* ironbars */
+ "j: 50: 4\n" /* torch */
+ "k:128: 2\n" /* sandstonestairs */
+ "l:126: 8\n" /* woodenslab */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 4\n" /* sandstonestairs */
+ "o:128: 5\n" /* sandstonestairs */
+ "p:128: 7\n" /* sandstonestairs */
+ "q:128: 6\n" /* sandstonestairs */
+ "r: 44: 1\n" /* step */
+ "s: 96: 1\n" /* trapdoor */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 01234 */
+ /* 0 */ "abbba"
+ /* 1 */ "mbbbm"
+ /* 2 */ "accca"
+ /* 3 */ "ccccc"
+ /* 4 */ "ccccc"
+ /* 5 */ "ccccc"
+ /* 6 */ "accca"
+
+ // Level 1
+ /* z\x* 01234 */
+ /* 0 */ "addda"
+ /* 1 */ "mdddm"
+ /* 2 */ "aceca"
+ /* 3 */ "ceeec"
+ /* 4 */ "ceeec"
+ /* 5 */ "ceeec"
+ /* 6 */ "accca"
+
+ // Level 2
+ /* z\x* 01234 */
+ /* 0 */ "a...a"
+ /* 1 */ "....."
+ /* 2 */ "acfca"
+ /* 3 */ "cg..c"
+ /* 4 */ "c...c"
+ /* 5 */ "c...c"
+ /* 6 */ "accca"
+
+ // Level 3
+ /* z\x* 01234 */
+ /* 0 */ "a...a"
+ /* 1 */ "....."
+ /* 2 */ "achca"
+ /* 3 */ "cg..c"
+ /* 4 */ "i...i"
+ /* 5 */ "c..jc"
+ /* 6 */ "acica"
+
+ // Level 4
+ /* z\x* 01234 */
+ /* 0 */ "k...k"
+ /* 1 */ "c...c"
+ /* 2 */ "accca"
+ /* 3 */ "cgllc"
+ /* 4 */ "nlllo"
+ /* 5 */ "clllc"
+ /* 6 */ "acpca"
+
+ // Level 5
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "accca"
+ /* 3 */ "cg..c"
+ /* 4 */ "c...c"
+ /* 5 */ "c...c"
+ /* 6 */ "accca"
+
+ // Level 6
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "acica"
+ /* 3 */ "cg..c"
+ /* 4 */ "i...i"
+ /* 5 */ "c..jc"
+ /* 6 */ "acica"
+
+ // Level 7
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "acqca"
+ /* 3 */ "cgllc"
+ /* 4 */ "nlllo"
+ /* 5 */ "clllc"
+ /* 6 */ "acpca"
+
+ // Level 8
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "crcrc"
+ /* 3 */ "rs..r"
+ /* 4 */ "c...c"
+ /* 5 */ "r...r"
+ /* 6 */ "crcrc",
+
+ // Connectors:
+ "-1: 2, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LittleTower
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MediumHouse1:
+ // The data has been exported from the gallery Desert, area index 71, ID 561, created by STR_Warrior
+ {
+ // Size:
+ 15, 9, 9, // SizeX = 15, SizeY = 9, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 15, 8, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 12: 0\n" /* sand */
+ "g: 64: 3\n" /* wooddoorblock */
+ "h: 85: 0\n" /* fence */
+ "i: 64: 0\n" /* wooddoorblock */
+ "j: 65: 5\n" /* ladder */
+ "k: 64: 8\n" /* wooddoorblock */
+ "l:101: 0\n" /* ironbars */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 4\n" /* torch */
+ "o:128: 2\n" /* sandstonestairs */
+ "p:126: 8\n" /* woodenslab */
+ "q:128: 4\n" /* sandstonestairs */
+ "r:128: 7\n" /* sandstonestairs */
+ "s: 44: 1\n" /* step */
+ "t: 50: 3\n" /* torch */
+ "u:128: 6\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmabbbammmmmmm"
+ /* 1 */ "mmmmbbbmmmmmmmm"
+ /* 2 */ "acccccccccacccc"
+ /* 3 */ "ccccccccccccccc"
+ /* 4 */ "ccccccccccccccc"
+ /* 5 */ "ccccccccccccccc"
+ /* 6 */ "ccccccccccccccc"
+ /* 7 */ "ccccccccccccccc"
+ /* 8 */ "acccccccccacccc"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmadddammmmmmm"
+ /* 1 */ "mmmmdddmmmmmmmm"
+ /* 2 */ "acccceccccaffff"
+ /* 3 */ "ceeeeeeeeecffff"
+ /* 4 */ "ceeeeeeeeecffff"
+ /* 5 */ "ceeeeeeeeeeffff"
+ /* 6 */ "ceeeeeeeeecffff"
+ /* 7 */ "ceeeeeeeeecffff"
+ /* 8 */ "acccccccccaffff"
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmma...ammmmmmm"
+ /* 1 */ "mmm.....mmmmmmm"
+ /* 2 */ "accccgccccahhhh"
+ /* 3 */ "c.........c...h"
+ /* 4 */ "c.........c...h"
+ /* 5 */ "c.........i...h"
+ /* 6 */ "c.........c...h"
+ /* 7 */ "c.........cj..h"
+ /* 8 */ "acccccccccahhhh"
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmma...ammmmmmm"
+ /* 1 */ "mmm.....mmmmmmm"
+ /* 2 */ "acccckcccca...."
+ /* 3 */ "c.........c...."
+ /* 4 */ "l.........c...."
+ /* 5 */ "l.........k...."
+ /* 6 */ "l.........c...."
+ /* 7 */ "c..n...n..cj..."
+ /* 8 */ "accclllccca...."
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmo...ommmmmmm"
+ /* 1 */ "mmmc...cmmmmmmm"
+ /* 2 */ "accccccccca...."
+ /* 3 */ "cpppppppppc...."
+ /* 4 */ "qpppppppppc...."
+ /* 5 */ "qpppppppppc...."
+ /* 6 */ "qpppppppppc...."
+ /* 7 */ "cpppppppppcj..."
+ /* 8 */ "acccrrrccca...."
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmm.....mmmmmmm"
+ /* 1 */ "mmm.....mmmmmmm"
+ /* 2 */ "csssscssssc...."
+ /* 3 */ "s..accca..s...."
+ /* 4 */ "s..c...c..s...."
+ /* 5 */ "c.........c...."
+ /* 6 */ "s..c...c..s...."
+ /* 7 */ "s..accca..s...."
+ /* 8 */ "csssscssssc...."
+
+ // Level 6
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "...aclca......."
+ /* 4 */ "...ct..c......."
+ /* 5 */ "..............."
+ /* 6 */ "...c...c......."
+ /* 7 */ "...aclca......."
+ /* 8 */ "..............."
+
+ // Level 7
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "...acuca......."
+ /* 4 */ "...cpppc......."
+ /* 5 */ "...cpppc......."
+ /* 6 */ "...cpppc......."
+ /* 7 */ "...acrca......."
+ /* 8 */ "..............."
+
+ // Level 8
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "...cscsc......."
+ /* 4 */ "...s...s......."
+ /* 5 */ "...c...c......."
+ /* 6 */ "...s...s......."
+ /* 7 */ "...cscsc......."
+ /* 8 */ "...............",
+
+ // Connectors:
+ "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 80,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // MediumHouse1
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MediumHouse2:
+ // The data has been exported from the gallery Desert, area index 74, ID 573, created by STR_Warrior
+ {
+ // Size:
+ 11, 10, 9, // SizeX = 11, SizeY = 10, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 9, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "A:128: 7\n" /* sandstonestairs */
+ "B: 44: 1\n" /* step */
+ "C: 96: 3\n" /* trapdoor */
+ "D: 96: 2\n" /* trapdoor */
+ "E:128: 2\n" /* sandstonestairs */
+ "F:128: 0\n" /* sandstonestairs */
+ "G: 87: 0\n" /* netherstone */
+ "H:128: 1\n" /* sandstonestairs */
+ "I:128: 3\n" /* sandstonestairs */
+ "J: 51: 0\n" /* fire */
+ "K: 44: 9\n" /* step */
+ "a: 24: 2\n" /* sandstone */
+ "b: 24: 0\n" /* sandstone */
+ "c: 4: 0\n" /* cobblestone */
+ "d: 12: 0\n" /* sand */
+ "e: 13: 0\n" /* gravel */
+ "f: 5: 0\n" /* wood */
+ "g: 65: 3\n" /* ladder */
+ "h: 85: 0\n" /* fence */
+ "i: 64: 3\n" /* wooddoorblock */
+ "j:134: 1\n" /* 134 */
+ "k:134: 2\n" /* 134 */
+ "l: 61: 2\n" /* furnace */
+ "m: 19: 0\n" /* sponge */
+ "n:134: 6\n" /* 134 */
+ "o:134: 4\n" /* 134 */
+ "p: 65: 2\n" /* ladder */
+ "q:101: 0\n" /* ironbars */
+ "r: 50: 2\n" /* torch */
+ "s: 47: 0\n" /* bookshelf */
+ "t: 64: 8\n" /* wooddoorblock */
+ "u: 50: 3\n" /* torch */
+ "v:171: 8\n" /* carpet */
+ "w:128: 6\n" /* sandstonestairs */
+ "x:126: 8\n" /* woodenslab */
+ "y:128: 5\n" /* sandstonestairs */
+ "z:128: 4\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "abbbammmcmm"
+ /* 1 */ "bbbbbdddcdm"
+ /* 2 */ "bbbbbmmmcdm"
+ /* 3 */ "bbbbbmmmcdm"
+ /* 4 */ "bbbbabbbbba"
+ /* 5 */ "bbbbbbbbbbb"
+ /* 6 */ "bbbbbbbbbbb"
+ /* 7 */ "bbbbbbbbbbb"
+ /* 8 */ "abbbbbbbbba"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "abbbammmemm"
+ /* 1 */ "bfffbdddedm"
+ /* 2 */ "bfffbmmmedm"
+ /* 3 */ "bfffbmmmedm"
+ /* 4 */ "bfffabbbfba"
+ /* 5 */ "bfffffffffb"
+ /* 6 */ "bfffffffffb"
+ /* 7 */ "bfffffffffb"
+ /* 8 */ "abbbbbbbbba"
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "abbba......"
+ /* 1 */ "bg..bhhh.h."
+ /* 2 */ "b...b....h."
+ /* 3 */ "b...b....h."
+ /* 4 */ "b...abbbiba"
+ /* 5 */ "b.........b"
+ /* 6 */ "bjh.......b"
+ /* 7 */ "bjk.lno..pb"
+ /* 8 */ "abbbbbbbbba"
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "abqba......"
+ /* 1 */ "bg..q......"
+ /* 2 */ "b...q......"
+ /* 3 */ "q..rb......"
+ /* 4 */ "q...sbqbtba"
+ /* 5 */ "q......u..b"
+ /* 6 */ "b.v.......q"
+ /* 7 */ "b........pb"
+ /* 8 */ "abbbqqqbbba"
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "abwba......"
+ /* 1 */ "bgxxy......"
+ /* 2 */ "bxxxy......"
+ /* 3 */ "zxxxb......"
+ /* 4 */ "zxxxabwbbba"
+ /* 5 */ "zxxxxxxxxxb"
+ /* 6 */ "bxxxxxxxxxy"
+ /* 7 */ "bxxxsssxxpb"
+ /* 8 */ "abbbAAAbbba"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "bBBBb......"
+ /* 1 */ "BC..B......"
+ /* 2 */ "B...B......"
+ /* 3 */ "B...B......"
+ /* 4 */ "b...bBBBBBb"
+ /* 5 */ "Bbbb......B"
+ /* 6 */ "Bbbb......B"
+ /* 7 */ "Bbbb.....DB"
+ /* 8 */ "bBBBBbBBBBb"
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ ".aEa......."
+ /* 6 */ ".FGH......."
+ /* 7 */ ".aIa......."
+ /* 8 */ "..........."
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ ".a.a......."
+ /* 6 */ "..J........"
+ /* 7 */ ".a.a......."
+ /* 8 */ "..........."
+
+ // Level 8
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ ".bbb......."
+ /* 6 */ ".bKb......."
+ /* 7 */ ".bbb......."
+ /* 8 */ "..........."
+
+ // Level 9
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ ".B.B......."
+ /* 6 */ "..........."
+ /* 7 */ ".B.B......."
+ /* 8 */ "...........",
+
+ // Connectors:
+ "-1: 8, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 80,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // MediumHouse2
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MediumHouse3:
+ // The data has been exported from the gallery Desert, area index 76, ID 575, created by STR_Warrior
+ {
+ // Size:
+ 12, 10, 11, // SizeX = 12, SizeY = 10, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 12, 9, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 3: 0\n" /* dirt */
+ "d: 24: 0\n" /* sandstone */
+ "e: 13: 0\n" /* gravel */
+ "f: 2: 0\n" /* grass */
+ "g: 5: 0\n" /* wood */
+ "h: 85: 0\n" /* fence */
+ "i: 64: 3\n" /* wooddoorblock */
+ "j: 64: 2\n" /* wooddoorblock */
+ "k: 65: 4\n" /* ladder */
+ "l: 65: 2\n" /* ladder */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 1\n" /* torch */
+ "o: 50: 2\n" /* torch */
+ "p:101: 0\n" /* ironbars */
+ "q: 64: 8\n" /* wooddoorblock */
+ "r:128: 2\n" /* sandstonestairs */
+ "s:128: 6\n" /* sandstonestairs */
+ "t:126: 8\n" /* woodenslab */
+ "u:128: 5\n" /* sandstonestairs */
+ "v:128: 7\n" /* sandstonestairs */
+ "w: 44: 1\n" /* step */
+ "x: 96: 0\n" /* trapdoor */
+ "y:126: 0\n" /* woodenslab */
+ "z:128: 4\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmammbbba"
+ /* 1 */ "mmmmmmmmbbbm"
+ /* 2 */ "cccccaddddda"
+ /* 3 */ "cccccddddddd"
+ /* 4 */ "cccccddddddd"
+ /* 5 */ "cccccddddddd"
+ /* 6 */ "cccddddddddd"
+ /* 7 */ "mmmddddddddd"
+ /* 8 */ "mmmdddddddda"
+ /* 9 */ "mmmdddddmmmm"
+ /* 10 */ "mmmadddammmm"
+
+ // Level 1
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmammeeea"
+ /* 1 */ "mmmmmmmmeeem"
+ /* 2 */ "fffffadddgda"
+ /* 3 */ "fffffdgggggd"
+ /* 4 */ "fffffggggggd"
+ /* 5 */ "fffffdgggggd"
+ /* 6 */ "fffddggggggd"
+ /* 7 */ "mmmdgggggggd"
+ /* 8 */ "mmmdggggddda"
+ /* 9 */ "mmmdgggdmmmm"
+ /* 10 */ "mmmadddammmm"
+
+ // Level 2
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmma.....a"
+ /* 1 */ "mmmmm......."
+ /* 2 */ "hhhhhadddida"
+ /* 3 */ "h....d.....d"
+ /* 4 */ "h....j.....d"
+ /* 5 */ "h....d.....d"
+ /* 6 */ "hhhad......d"
+ /* 7 */ "mmmd......kd"
+ /* 8 */ "mmmd....ddda"
+ /* 9 */ "mmmd..ldmmmm"
+ /* 10 */ "mmmadddammmm"
+
+ // Level 3
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmman...oa"
+ /* 1 */ "mmmmm......."
+ /* 2 */ ".....appdqda"
+ /* 3 */ ".....d.....d"
+ /* 4 */ ".....q.....d"
+ /* 5 */ ".....d.....p"
+ /* 6 */ "...hd......d"
+ /* 7 */ "mmmd......kd"
+ /* 8 */ "mmmd....dppa"
+ /* 9 */ "mmmd..ldmmmm"
+ /* 10 */ "mmmhdddhmmmm"
+
+ // Level 4
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmr.....r"
+ /* 1 */ "mmmmmd.....d"
+ /* 2 */ ".....assddda"
+ /* 3 */ ".....dtttttd"
+ /* 4 */ ".....dtttttd"
+ /* 5 */ ".....dtttttu"
+ /* 6 */ "...hdatttttd"
+ /* 7 */ "mmmdttttttkd"
+ /* 8 */ "mmmdtttadvva"
+ /* 9 */ "mmmdttldmmmm"
+ /* 10 */ "mmmhdddhmmmm"
+
+ // Level 5
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ ".....dwwdwwd"
+ /* 3 */ ".....w.....w"
+ /* 4 */ ".....w.....w"
+ /* 5 */ ".....w.....d"
+ /* 6 */ "...hdadh...w"
+ /* 7 */ "mmmd...d..xw"
+ /* 8 */ "mmmd...awwwd"
+ /* 9 */ "mmmd..ldmmmm"
+ /* 10 */ "mmmhdddhmmmm"
+
+ // Level 6
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "............"
+ /* 3 */ "............"
+ /* 4 */ "............"
+ /* 5 */ "............"
+ /* 6 */ "...hd.dh...."
+ /* 7 */ "mmmd...d...."
+ /* 8 */ "mmmp........"
+ /* 9 */ "mmmd..ldmmmm"
+ /* 10 */ "mmmhdpdhmmmm"
+
+ // Level 7
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "............"
+ /* 3 */ "............"
+ /* 4 */ "............"
+ /* 5 */ "............"
+ /* 6 */ "...hd.dh...."
+ /* 7 */ "mmmd...d...."
+ /* 8 */ "mmmp........"
+ /* 9 */ "mmmdn.ldmmmm"
+ /* 10 */ "mmmhdpdhmmmm"
+
+ // Level 8
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "............"
+ /* 3 */ "............"
+ /* 4 */ "............"
+ /* 5 */ "............"
+ /* 6 */ "...adsda...."
+ /* 7 */ "mmmdyyyd...."
+ /* 8 */ "mmmzyyyu...."
+ /* 9 */ "mmmdyyldmmmm"
+ /* 10 */ "mmmadvdammmm"
+
+ // Level 9
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "............"
+ /* 3 */ "............"
+ /* 4 */ "............"
+ /* 5 */ "............"
+ /* 6 */ "...w.w.w...."
+ /* 7 */ "mmm........."
+ /* 8 */ "mmmw...w...."
+ /* 9 */ "mmm.....mmmm"
+ /* 10 */ "mmmw.w.wmmmm",
+
+ // Connectors:
+ "-1: 9, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 80,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // MediumHouse3
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SmallHouse9:
+ // The data has been exported from the gallery Desert, area index 67, ID 556, created by STR_Warrior
+ {
+ // Size:
+ 9, 6, 11, // SizeX = 9, SizeY = 6, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 9, 5, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 64: 3\n" /* wooddoorblock */
+ "g: 65: 2\n" /* ladder */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i:101: 0\n" /* ironbars */
+ "j: 50: 2\n" /* torch */
+ "k: 50: 1\n" /* torch */
+ "l:128: 2\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n:126: 8\n" /* woodenslab */
+ "o:128: 5\n" /* sandstonestairs */
+ "p:128: 6\n" /* sandstonestairs */
+ "q:128: 4\n" /* sandstonestairs */
+ "r:128: 7\n" /* sandstonestairs */
+ "s: 44: 1\n" /* step */
+ "t: 96: 2\n" /* trapdoor */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmabbba"
+ /* 1 */ "mmmmmbbbm"
+ /* 2 */ "mmmmaccca"
+ /* 3 */ "mmmmccccc"
+ /* 4 */ "mmmmccccc"
+ /* 5 */ "mmmmccccc"
+ /* 6 */ "acccacccc"
+ /* 7 */ "ccccccccc"
+ /* 8 */ "ccccccccc"
+ /* 9 */ "ccccccccc"
+ /* 10 */ "accccccca"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmaddda"
+ /* 1 */ "mmmmmdddm"
+ /* 2 */ "mmmmaceca"
+ /* 3 */ "mmmmceeec"
+ /* 4 */ "mmmmceeec"
+ /* 5 */ "mmmmceeec"
+ /* 6 */ "acccaeeec"
+ /* 7 */ "ceeeeeeec"
+ /* 8 */ "ceeeeeeec"
+ /* 9 */ "ceeeeeeec"
+ /* 10 */ "accccccca"
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "mmmma...a"
+ /* 1 */ "mmmm....."
+ /* 2 */ "mmmmacfca"
+ /* 3 */ "mmmmc...c"
+ /* 4 */ "mmmmc...c"
+ /* 5 */ "mmmmc...c"
+ /* 6 */ "accca...c"
+ /* 7 */ "c.......c"
+ /* 8 */ "c.......c"
+ /* 9 */ "c......gc"
+ /* 10 */ "accccccca"
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "mmmma...a"
+ /* 1 */ "mmmm....."
+ /* 2 */ "mmmmachca"
+ /* 3 */ "mmmmc...c"
+ /* 4 */ "mmmmc...c"
+ /* 5 */ "mmmmc...i"
+ /* 6 */ "acica...i"
+ /* 7 */ "c.......i"
+ /* 8 */ "i......jc"
+ /* 9 */ "ck.....gc"
+ /* 10 */ "acciiicca"
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "mmmml...l"
+ /* 1 */ "mmmmc...c"
+ /* 2 */ "mmmmaccca"
+ /* 3 */ "mmmmcnnnc"
+ /* 4 */ "mmmmcnnnc"
+ /* 5 */ "mmmmcnnno"
+ /* 6 */ "acpcannno"
+ /* 7 */ "cnnnnnnno"
+ /* 8 */ "qnnnnnnnc"
+ /* 9 */ "cnnnnnngc"
+ /* 10 */ "accrrrcca"
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "mmmm....."
+ /* 1 */ "mmmm....."
+ /* 2 */ "mmmmcscsc"
+ /* 3 */ "mmmms...s"
+ /* 4 */ "mmmms...s"
+ /* 5 */ "mmmms...s"
+ /* 6 */ "csssc...c"
+ /* 7 */ "s.......s"
+ /* 8 */ "s.......s"
+ /* 9 */ "s......ts"
+ /* 10 */ "cssscsssc",
+
+ // Connectors:
+ "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // SmallHouse9
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Temple:
+ // The data has been exported from the gallery Desert, area index 83, ID 599, created by STR_Warrior
+ {
+ // Size:
+ 13, 10, 9, // SizeX = 13, SizeY = 10, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 13, 9, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "A: 51: 0\n" /* fire */
+ "B: 44: 9\n" /* step */
+ "a: 24: 2\n" /* sandstone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 13: 0\n" /* gravel */
+ "e: 5: 0\n" /* wood */
+ "f: 64: 3\n" /* wooddoorblock */
+ "g: 17: 0\n" /* tree */
+ "h:128: 5\n" /* sandstonestairs */
+ "i:128: 4\n" /* sandstonestairs */
+ "j:128: 7\n" /* sandstonestairs */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:118: 3\n" /* cauldronblock */
+ "m: 19: 0\n" /* sponge */
+ "n:155: 1\n" /* quartzblock */
+ "o: 64: 8\n" /* wooddoorblock */
+ "p: 50: 3\n" /* torch */
+ "q:101: 0\n" /* ironbars */
+ "r:140: 0\n" /* flowerpotblock */
+ "s: 24: 1\n" /* sandstone */
+ "t:128: 2\n" /* sandstonestairs */
+ "u:126: 8\n" /* woodenslab */
+ "v: 44: 1\n" /* step */
+ "w:128: 0\n" /* sandstonestairs */
+ "x: 87: 0\n" /* netherstone */
+ "y:128: 1\n" /* sandstonestairs */
+ "z:128: 3\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "mmmmabbbammmm"
+ /* 1 */ "mmmmmbbbmmmmm"
+ /* 2 */ "accccccccccca"
+ /* 3 */ "ccccccccccccc"
+ /* 4 */ "ccccccccccccc"
+ /* 5 */ "ccccccccccccc"
+ /* 6 */ "ccccccccccccc"
+ /* 7 */ "ccccccccccccc"
+ /* 8 */ "accccccccccca"
+
+ // Level 1
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "mmmmadddammmm"
+ /* 1 */ "mmmmmdddmmmmm"
+ /* 2 */ "accccceccccca"
+ /* 3 */ "ceeeeeeeeeeec"
+ /* 4 */ "ceeeeeeeeeeec"
+ /* 5 */ "ceeeeeeeeeeec"
+ /* 6 */ "ceeeeeeeeeeec"
+ /* 7 */ "ceeeeeeeeeeec"
+ /* 8 */ "accccccccccca"
+
+ // Level 2
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "mmmma...ammmm"
+ /* 1 */ "mmmm.....mmmm"
+ /* 2 */ "acccccfccccca"
+ /* 3 */ "cgh.......igc"
+ /* 4 */ "cj.........jc"
+ /* 5 */ "c...........c"
+ /* 6 */ "ck.........kc"
+ /* 7 */ "cgh.linhl.igc"
+ /* 8 */ "accccccccccca"
+
+ // Level 3
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "mmmma...ammmm"
+ /* 1 */ "mmmm.....mmmm"
+ /* 2 */ "acccccoccccca"
+ /* 3 */ "cg...p.p...gc"
+ /* 4 */ "c...........c"
+ /* 5 */ "q...........q"
+ /* 6 */ "c...........c"
+ /* 7 */ "cg...rsr...gc"
+ /* 8 */ "acqqqcccqqqca"
+
+ // Level 4
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "mmmmt...tmmmm"
+ /* 1 */ "mmmms...cmmmm"
+ /* 2 */ "accccccccccca"
+ /* 3 */ "cguuuuuuuuugc"
+ /* 4 */ "cuuuuuuuuuuuc"
+ /* 5 */ "iuuuuuuuuuuuh"
+ /* 6 */ "cuuuuuuuuuuuc"
+ /* 7 */ "cguuuuuuuuugc"
+ /* 8 */ "acjjjcccjjjca"
+
+ // Level 5
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "mmmm.....mmmm"
+ /* 1 */ "mmmm.....mmmm"
+ /* 2 */ "cvvvvvcvvvvvc"
+ /* 3 */ "v...........v"
+ /* 4 */ "v.ccc...ccc.v"
+ /* 5 */ "c.ccc...ccc.c"
+ /* 6 */ "v.ccc...ccc.v"
+ /* 7 */ "v...........v"
+ /* 8 */ "cvvvvvcvvvvvc"
+
+ // Level 6
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "............."
+ /* 4 */ "..ata...ata.."
+ /* 5 */ "..wxy...wxy.."
+ /* 6 */ "..aza...aza.."
+ /* 7 */ "............."
+ /* 8 */ "............."
+
+ // Level 7
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "............."
+ /* 4 */ "..a.a...a.a.."
+ /* 5 */ "...A.....A..."
+ /* 6 */ "..a.a...a.a.."
+ /* 7 */ "............."
+ /* 8 */ "............."
+
+ // Level 8
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "............."
+ /* 4 */ "..ccc...ccc.."
+ /* 5 */ "..cBc...cBc.."
+ /* 6 */ "..ccc...ccc.."
+ /* 7 */ "............."
+ /* 8 */ "............."
+
+ // Level 9
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "............."
+ /* 4 */ "..v.v...v.v.."
+ /* 5 */ "............."
+ /* 6 */ "..v.v...v.v.."
+ /* 7 */ "............."
+ /* 8 */ ".............",
+
+ // Connectors:
+ "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 50,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Temple
+}; // g_AlchemistVillagePrefabs
+
+
+
+
+
+
+const cPrefab::sDef g_AlchemistVillageStartingPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // Well:
+ // The data has been exported from the gallery Desert, area index 90, ID 631, created by STR_Warrior
+ {
+ // Size:
+ 7, 21, 7, // SizeX = 7, SizeY = 21, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 20, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 24: 2\n" /* sandstone */
+ "c: 24: 0\n" /* sandstone */
+ "d: 8: 0\n" /* water */
+ "e: 4: 0\n" /* cobblestone */
+ "f: 13: 0\n" /* gravel */
+ "g:128: 1\n" /* sandstonestairs */
+ "h: 44: 1\n" /* step */
+ "i:128: 0\n" /* sandstonestairs */
+ "j:128: 3\n" /* sandstonestairs */
+ "k:128: 2\n" /* sandstonestairs */
+ "l: 44: 9\n" /* step */
+ "m: 19: 0\n" /* sponge */
+ "n:126: 0\n" /* woodenslab */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 8
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 9
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 10
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 11
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 12
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 13
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "mcdddcm"
+ /* 3 */ "mcdddcm"
+ /* 4 */ "mcdddcm"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 14
+ /* z\x* 0123456 */
+ /* 0 */ "mmeeemm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "ecdddce"
+ /* 3 */ "ecdddce"
+ /* 4 */ "ecdddce"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmeeemm"
+
+ // Level 15
+ /* z\x* 0123456 */
+ /* 0 */ "mmfffmm"
+ /* 1 */ "mbcccbm"
+ /* 2 */ "fcdddcf"
+ /* 3 */ "fcdddcf"
+ /* 4 */ "fcdddcf"
+ /* 5 */ "mbcccbm"
+ /* 6 */ "mmfffmm"
+
+ // Level 16
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mbghibm"
+ /* 2 */ ".j...j."
+ /* 3 */ ".h...h."
+ /* 4 */ ".k...k."
+ /* 5 */ "mbghibm"
+ /* 6 */ "mm...mm"
+
+ // Level 17
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mb...bm"
+ /* 2 */ "......."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ "mb...bm"
+ /* 6 */ "mm...mm"
+
+ // Level 18
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mblllbm"
+ /* 2 */ ".l...l."
+ /* 3 */ ".l...l."
+ /* 4 */ ".l...l."
+ /* 5 */ "mblllbm"
+ /* 6 */ "mm...mm"
+
+ // Level 19
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mcccccm"
+ /* 2 */ ".cnnnc."
+ /* 3 */ ".cnnnc."
+ /* 4 */ ".cnnnc."
+ /* 5 */ "mcccccm"
+ /* 6 */ "mm...mm"
+
+ // Level 20
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mh.h.hm"
+ /* 2 */ "......."
+ /* 3 */ ".h...h."
+ /* 4 */ "......."
+ /* 5 */ "mh.h.hm"
+ /* 6 */ "mm...mm",
+
+ // Connectors:
+ "2: 3, 16, 6: 3\n" /* Type 2, direction Z+ */
+ "2: 0, 16, 3: 4\n" /* Type 2, direction X- */
+ "2: 3, 16, 0: 2\n" /* Type 2, direction Z- */
+ "2: 6, 16, 3: 5\n" /* Type 2, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Well
+};
+
+
+
+
+
+// The prefab counts:
+
+const size_t g_AlchemistVillagePrefabsCount = ARRAYCOUNT(g_AlchemistVillagePrefabs);
+
+const size_t g_AlchemistVillageStartingPrefabsCount = ARRAYCOUNT(g_AlchemistVillageStartingPrefabs);
+
diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.h b/src/Generating/Prefabs/AlchemistVillagePrefabs.h
new file mode 100644
index 000000000..dddc5530a
--- /dev/null
+++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.h
@@ -0,0 +1,15 @@
+
+// AlchemistVillagePrefabs.h
+
+// Declares the prefabs in the group AlchemistVillage
+
+#include "../Prefab.h"
+
+
+
+
+
+extern const cPrefab::sDef g_AlchemistVillagePrefabs[];
+extern const cPrefab::sDef g_AlchemistVillageStartingPrefabs[];
+extern const size_t g_AlchemistVillagePrefabsCount;
+extern const size_t g_AlchemistVillageStartingPrefabsCount;
diff --git a/src/Generating/Prefabs/CMakeLists.txt b/src/Generating/Prefabs/CMakeLists.txt
index a1f09112d..2c62aa73d 100644
--- a/src/Generating/Prefabs/CMakeLists.txt
+++ b/src/Generating/Prefabs/CMakeLists.txt
@@ -4,11 +4,30 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ AlchemistVillagePrefabs.cpp
+ JapaneseVillagePrefabs.cpp
+ NetherFortPrefabs.cpp
+ PlainsVillagePrefabs.cpp
+ RainbowRoadPrefabs.cpp
+ SandFlatRoofVillagePrefabs.cpp
+ SandVillagePrefabs.cpp
+ TestRailsPrefabs.cpp
+ UnderwaterBasePrefabs.cpp)
-add_library(Generating_Prefabs ${SOURCE})
+SET (HDRS
+ AlchemistVillagePrefabs.h
+ JapaneseVillagePrefabs.h
+ NetherFortPrefabs.h
+ PlainsVillagePrefabs.h
+ RainbowRoadPrefabs.h
+ SandFlatRoofVillagePrefabs.h
+ SandVillagePrefabs.h
+ TestRailsPrefabs.h
+ UnderwaterBasePrefabs.h)
-target_link_libraries(Generating_Prefabs OSSupport iniFile Blocks)
+if(NOT MSVC)
+ add_library(Generating_Prefabs ${SRCS} ${HDRS})
+
+ target_link_libraries(Generating_Prefabs OSSupport iniFile Blocks)
+endif()
diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp
new file mode 100644
index 000000000..0362c9406
--- /dev/null
+++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp
@@ -0,0 +1,3386 @@
+
+// JapaneseVillagePrefabs.cpp
+
+// Defines the prefabs in the group JapaneseVillage
+
+// NOTE: This file has been generated automatically by GalExport!
+// Any manual changes will be overwritten by the next automatic export!
+
+#include "Globals.h"
+#include "JapaneseVillagePrefabs.h"
+
+
+
+
+
+const cPrefab::sDef g_JapaneseVillagePrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // Arch:
+ // The data has been exported from the gallery Plains, area index 144, ID 488, created by Aloe_vera
+ {
+ // Size:
+ 11, 7, 5, // SizeX = 11, SizeY = 7, SizeZ = 5
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 6, 4, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 2: 0\n" /* grass */
+ "b: 13: 0\n" /* gravel */
+ "c:113: 0\n" /* netherbrickfence */
+ "d: 50: 5\n" /* torch */
+ "e: 44: 8\n" /* step */
+ "f: 44: 0\n" /* step */
+ "g: 43: 0\n" /* doubleslab */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "aaaabbbaaaa"
+ /* 1 */ "aaaabbbaaaa"
+ /* 2 */ "aaaabbbaaaa"
+ /* 3 */ "aaaabbbaaaa"
+ /* 4 */ "aaaabbbaaaa"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..c.....c.."
+ /* 1 */ "..c.....c.."
+ /* 2 */ "..c.....c.."
+ /* 3 */ "..c.....c.."
+ /* 4 */ "..c.....c.."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..c.....c.."
+ /* 1 */ "..........."
+ /* 2 */ "..c.....c.."
+ /* 3 */ "..........."
+ /* 4 */ "..c.....c.."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..d.....d.."
+ /* 1 */ "..........."
+ /* 2 */ "..c.....c.."
+ /* 3 */ "..........."
+ /* 4 */ "..d.....d.."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "...eeeee..."
+ /* 1 */ "..........."
+ /* 2 */ "..c.....c.."
+ /* 3 */ "..........."
+ /* 4 */ "...eeeee..."
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..f.....f.."
+ /* 1 */ ".egfffffge."
+ /* 2 */ ".egeeeeege."
+ /* 3 */ ".egfffffge."
+ /* 4 */ "..f.....f.."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "gf.......fg"
+ /* 3 */ "..........."
+ /* 4 */ "...........",
+
+ // Connectors:
+ "2: 5, 1, 4: 3\n" /* Type 2, direction Z+ */
+ "2: 5, 1, 0: 2\n" /* Type 2, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Arch
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Farm:
+ // The data has been exported from the gallery Plains, area index 166, ID 554, created by Aloe_vera
+ {
+ // Size:
+ 11, 8, 13, // SizeX = 11, SizeY = 8, SizeZ = 13
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 10, 7, 12, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 60: 7\n" /* tilleddirt */
+ "c: 8: 0\n" /* water */
+ "d: 43: 0\n" /* doubleslab */
+ "e: 44: 0\n" /* step */
+ "f: 59: 7\n" /* crops */
+ "g: 83: 0\n" /* reedblock */
+ "h:113: 0\n" /* netherbrickfence */
+ "i: 50: 5\n" /* torch */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "maaaaaaaaam"
+ /* 7 */ "maaaaaaaaam"
+ /* 8 */ "maaaaaaaaam"
+ /* 9 */ "maaaaaaaaam"
+ /* 10 */ "maaaaaaaaam"
+ /* 11 */ "maaaaaaaaam"
+ /* 12 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "mabbbbbbbam"
+ /* 3 */ "mabbbbbbbam"
+ /* 4 */ "mabbbbbbbam"
+ /* 5 */ "mabbbbbbbam"
+ /* 6 */ "mabcccccaam"
+ /* 7 */ "mabbbbbbbam"
+ /* 8 */ "mabbbbbbbam"
+ /* 9 */ "mabbbbbbbam"
+ /* 10 */ "mabbbbbbbam"
+ /* 11 */ "maaaaaaaaam"
+ /* 12 */ "mmmmmmmmmmm"
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".deeeeeeed."
+ /* 2 */ ".efffffffe."
+ /* 3 */ ".efffffffe."
+ /* 4 */ ".efffffffe."
+ /* 5 */ ".efgggggfe."
+ /* 6 */ ".eg.....ge."
+ /* 7 */ ".efgggggfe."
+ /* 8 */ ".efffffffe."
+ /* 9 */ ".efffffffe."
+ /* 10 */ ".efffffffe."
+ /* 11 */ ".deeeeeeed."
+ /* 12 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".h.......h."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ "...ggggg..."
+ /* 6 */ "..g.....g.."
+ /* 7 */ "...ggggg..."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+ /* 11 */ ".h.......h."
+ /* 12 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".h.......h."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ "...ggggg..."
+ /* 6 */ "..g.....g.."
+ /* 7 */ "...ggggg..."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+ /* 11 */ ".h.......h."
+ /* 12 */ "..........."
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".h.......h."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ "..........."
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+ /* 11 */ ".h.......h."
+ /* 12 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ ".h.......h."
+ /* 1 */ "hhh.....hhh"
+ /* 2 */ ".h.......h."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ "..........."
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ ".h.......h."
+ /* 11 */ "hhh.....hhh"
+ /* 12 */ ".h.......h."
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ ".i.......i."
+ /* 1 */ "i.i.....i.i"
+ /* 2 */ ".i.......i."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ "..........."
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ ".i.......i."
+ /* 11 */ "i.i.....i.i"
+ /* 12 */ ".i.......i.",
+
+ // Connectors:
+ "-1: 10, 2, 6: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Farm
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Forge:
+ // The data has been exported from the gallery Plains, area index 79, ID 145, created by Aloe_vera
+ {
+ // Size:
+ 16, 11, 14, // SizeX = 16, SizeY = 11, SizeZ = 14
+
+ // Hitbox (relative to bounding box):
+ 0, 0, -1, // MinX, MinY, MinZ
+ 16, 10, 14, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 17: 1\n" /* tree */
+ "c: 67: 0\n" /* stairs */
+ "d: 5: 2\n" /* wood */
+ "e: 67: 2\n" /* stairs */
+ "f:113: 0\n" /* netherbrickfence */
+ "g:118: 2\n" /* cauldronblock */
+ "h: 67: 6\n" /* stairs */
+ "i: 67: 4\n" /* stairs */
+ "j: 87: 0\n" /* netherstone */
+ "k: 67: 7\n" /* stairs */
+ "l: 54: 5\n" /* chest */
+ "m: 19: 0\n" /* sponge */
+ "n: 61: 2\n" /* furnace */
+ "o:101: 0\n" /* ironbars */
+ "p: 51: 0\n" /* fire */
+ "q: 50: 4\n" /* torch */
+ "r: 50: 2\n" /* torch */
+ "s: 35: 0\n" /* wool */
+ "t: 67: 3\n" /* stairs */
+ "u: 50: 3\n" /* torch */
+ "v: 44: 8\n" /* step */
+ "w: 43: 0\n" /* doubleslab */
+ "x: 44: 0\n" /* step */
+ "y: 17: 5\n" /* tree */
+ "z: 17: 9\n" /* tree */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmaaaaaaaaaaaamm"
+ /* 3 */ "mmaaaaaaaaaaaamm"
+ /* 4 */ "mmaaaaaaaaaaaamm"
+ /* 5 */ "mmaaaaaaaaaaaamm"
+ /* 6 */ "mmaaaaaaaaaaaamm"
+ /* 7 */ "mmaaaaaaaaaaaamm"
+ /* 8 */ "mmaaaaaaaaaaaamm"
+ /* 9 */ "mmaaaaaaaaaaaamm"
+ /* 10 */ "mmaaaaaaaaaaaamm"
+ /* 11 */ "mmaaaaaaaaaaaamm"
+ /* 12 */ "mmmmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ ".....bbbbbbbbb.."
+ /* 3 */ ".....cdddddddb.."
+ /* 4 */ ".....cddaaaadb.."
+ /* 5 */ "..beeedaaaaadb.."
+ /* 6 */ "..bddddaaaaadb.."
+ /* 7 */ "..bddddaaaaadb.."
+ /* 8 */ "..bddddaaaaadb.."
+ /* 9 */ "..bddddaaaaadb.."
+ /* 10 */ "..bddddddddddb.."
+ /* 11 */ "..bbbbbbbbbbbb.."
+ /* 12 */ "................"
+ /* 13 */ "................"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ ".....bfffbfffb.."
+ /* 3 */ ".............a.."
+ /* 4 */ ".............a.."
+ /* 5 */ "..b.....ghh..a.."
+ /* 6 */ "..f.....haa..b.."
+ /* 7 */ "..f.....ija..b.."
+ /* 8 */ "..f.....kaa..a.."
+ /* 9 */ "..f..........a.."
+ /* 10 */ "..fl.........a.."
+ /* 11 */ "..bffffbbffffb.."
+ /* 12 */ "................"
+ /* 13 */ "................"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ ".....bfffbfffb.."
+ /* 3 */ ".............a.."
+ /* 4 */ ".............a.."
+ /* 5 */ "..b......nn..a.."
+ /* 6 */ "..f.....oaa..b.."
+ /* 7 */ "..f.....opa..b.."
+ /* 8 */ "..f.....oaa..a.."
+ /* 9 */ "..f..........a.."
+ /* 10 */ "..f..........a.."
+ /* 11 */ "..bffffbbffffb.."
+ /* 12 */ "................"
+ /* 13 */ "................"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ ".........q...q.."
+ /* 2 */ "....rbsssbsssb.."
+ /* 3 */ ".............a.."
+ /* 4 */ "..q..........a.."
+ /* 5 */ "..b......ce..a.."
+ /* 6 */ "..s......ea..b.."
+ /* 7 */ "..s......aa..b.."
+ /* 8 */ "..s......ta..a.."
+ /* 9 */ "..s..........a.."
+ /* 10 */ "..s..........a.."
+ /* 11 */ ".rbssssbbssssb.."
+ /* 12 */ "..u....uu....u.."
+ /* 13 */ "................"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ ".vwxxxxxxxxxxwv."
+ /* 1 */ "vvvvvvvvvvvvvvvv"
+ /* 2 */ "wvbyybyyybbyybvw"
+ /* 3 */ "xvz..........zvx"
+ /* 4 */ "xvz..........zvx"
+ /* 5 */ "xvb..........zvx"
+ /* 6 */ "xvz.......a..bvx"
+ /* 7 */ "xvz......ca..bvx"
+ /* 8 */ "xvz.......a..zvx"
+ /* 9 */ "xvz..........zvx"
+ /* 10 */ "xvz..........zvx"
+ /* 11 */ "wvbyyyyyyyyyybvw"
+ /* 12 */ "vvvvvvvvvvvvvvvv"
+ /* 13 */ ".vwxxxxxxxxxxwv."
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "wx............xw"
+ /* 1 */ "x..............x"
+ /* 2 */ "..xxxxxxxxxxxx.."
+ /* 3 */ "..xwwwwwwwwwwx.."
+ /* 4 */ "..xwvvvvvvvvvx.."
+ /* 5 */ "..xwv.......vx.."
+ /* 6 */ "..xwv.....a.vx.."
+ /* 7 */ "..xwv.....a.vx.."
+ /* 8 */ "..xwv.....a.vx.."
+ /* 9 */ "..xwvvvvvvvvvx.."
+ /* 10 */ "..xwwwwwwwwwwx.."
+ /* 11 */ "..xxxxxxxxxxxx.."
+ /* 12 */ "x..............x"
+ /* 13 */ "wx............xw"
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "................"
+ /* 4 */ "....xxxxxxxx...."
+ /* 5 */ "....xxxxxxxx...."
+ /* 6 */ "....xwwwwwax...."
+ /* 7 */ "....xwvvvvax...."
+ /* 8 */ "....xwwwwwax...."
+ /* 9 */ "....xxxxxxxx...."
+ /* 10 */ "................"
+ /* 11 */ "................"
+ /* 12 */ "................"
+ /* 13 */ "................"
+
+ // Level 8
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "................"
+ /* 4 */ "................"
+ /* 5 */ "................"
+ /* 6 */ "..........a....."
+ /* 7 */ ".......xx.a....."
+ /* 8 */ "..........a....."
+ /* 9 */ "................"
+ /* 10 */ "................"
+ /* 11 */ "................"
+ /* 12 */ "................"
+ /* 13 */ "................"
+
+ // Level 9
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "................"
+ /* 4 */ "................"
+ /* 5 */ "................"
+ /* 6 */ "..........a....."
+ /* 7 */ "..........a....."
+ /* 8 */ "..........a....."
+ /* 9 */ "................"
+ /* 10 */ "................"
+ /* 11 */ "................"
+ /* 12 */ "................"
+ /* 13 */ "................"
+
+ // Level 10
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "................"
+ /* 4 */ "................"
+ /* 5 */ "................"
+ /* 6 */ "..........a....."
+ /* 7 */ "..........a....."
+ /* 8 */ "..........a....."
+ /* 9 */ "................"
+ /* 10 */ "................"
+ /* 11 */ "................"
+ /* 12 */ "................"
+ /* 13 */ "................",
+
+ // Connectors:
+ "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Forge
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Garden2:
+ // The data has been exported from the gallery Plains, area index 147, ID 491, created by Aloe_vera
+ {
+ // Size:
+ 16, 5, 16, // SizeX = 16, SizeY = 5, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 4, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 8: 0\n" /* water */
+ "c: 2: 0\n" /* grass */
+ "d: 17: 1\n" /* tree */
+ "e: 13: 0\n" /* gravel */
+ "f: 31: 2\n" /* tallgrass */
+ "g: 18: 5\n" /* leaves */
+ "h: 38: 7\n" /* rose */
+ "i: 17: 9\n" /* tree */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aaaaaaaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaaaaaaaa"
+ /* 7 */ "aaaaaaaaaaaaaaaa"
+ /* 8 */ "aaaaaaaaaaaaaaaa"
+ /* 9 */ "aaaaaaaaaaaaaaaa"
+ /* 10 */ "aaaaaaaaaaaaaaaa"
+ /* 11 */ "aaaaaaaaaaaaaaaa"
+ /* 12 */ "aaaaaaaaaaaaaaaa"
+ /* 13 */ "aaaaaaaaaaaaaaaa"
+ /* 14 */ "aaaaaaaaaaaaaaaa"
+ /* 15 */ "aaaaaaaaaaaaaaaa"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aaaaaaaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaaaaaaa"
+ /* 6 */ "aaaabbaaaaaaaaaa"
+ /* 7 */ "aaabbbaaaaaaaaaa"
+ /* 8 */ "aaabbaaaaaaaaaaa"
+ /* 9 */ "aaaabaaaaaaaaaaa"
+ /* 10 */ "aaaaaaaaaaaaaaaa"
+ /* 11 */ "aaaaaaaaaaaaaaaa"
+ /* 12 */ "aaaaaaaaaaaaaaaa"
+ /* 13 */ "aaaaaaaaaaaaaaaa"
+ /* 14 */ "aaaaaaaaaaaaaaaa"
+ /* 15 */ "aaaaaaaaaaaaaaaa"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "cccccccccccccccc"
+ /* 1 */ "ccdccccccccdcccc"
+ /* 2 */ "cccccceecccccdcc"
+ /* 3 */ "ccccccceeccccccc"
+ /* 4 */ "cccccccceccccccc"
+ /* 5 */ "cccbbbbceccccccc"
+ /* 6 */ "cccbbbbceecccccc"
+ /* 7 */ "ccbbbbbcceeeeccc"
+ /* 8 */ "ccbbbbbccccceecc"
+ /* 9 */ "ccbbbbcccccccecc"
+ /* 10 */ "ccccbcccccccceec"
+ /* 11 */ "ccccccccccccccec"
+ /* 12 */ "ccccccccaaacccec"
+ /* 13 */ "cccccccccaccccec"
+ /* 14 */ "ccccccccccccceec"
+ /* 15 */ "cccccccccccceecc"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "......f...gg.g.."
+ /* 1 */ "..gg.....gggggg."
+ /* 2 */ "ffgg......ghgggg"
+ /* 3 */ ".............gg."
+ /* 4 */ "...........f...."
+ /* 5 */ "...........h.ff."
+ /* 6 */ ".............fh."
+ /* 7 */ "...............f"
+ /* 8 */ "................"
+ /* 9 */ ".......ff.f....."
+ /* 10 */ ".f.....ffggf...."
+ /* 11 */ ".......gggg.f..."
+ /* 12 */ ".f......iddg...."
+ /* 13 */ ".....f..gdgg...."
+ /* 14 */ "....ff...gg....."
+ /* 15 */ "................"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "...........g.g.."
+ /* 2 */ ".............gg."
+ /* 3 */ "................"
+ /* 4 */ "................"
+ /* 5 */ "................"
+ /* 6 */ "................"
+ /* 7 */ "................"
+ /* 8 */ "................"
+ /* 9 */ "................"
+ /* 10 */ ".........g......"
+ /* 11 */ "........ggg....."
+ /* 12 */ "........ggg....."
+ /* 13 */ ".........g......"
+ /* 14 */ "................"
+ /* 15 */ "................",
+
+ // Connectors:
+ "-1: 12, 3, 15: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Garden2
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseMid:
+ // The data has been exported from the gallery Plains, area index 62, ID 119, created by Aloe_vera
+ {
+ // Size:
+ 10, 9, 9, // SizeX = 10, SizeY = 9, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ 0, 0, -1, // MinX, MinY, MinZ
+ 10, 8, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 2\n" /* wood */
+ "b:135: 2\n" /* 135 */
+ "c:135: 0\n" /* 135 */
+ "d: 17: 9\n" /* tree */
+ "e:135: 3\n" /* 135 */
+ "f: 85: 0\n" /* fence */
+ "g: 17: 1\n" /* tree */
+ "h:171: 0\n" /* carpet */
+ "i: 50: 5\n" /* torch */
+ "j: 35: 0\n" /* wool */
+ "k: 17: 5\n" /* tree */
+ "l:124: 0\n" /* redstonelampon */
+ "m: 19: 0\n" /* sponge */
+ "n: 69: 9\n" /* lever */
+ "o: 44: 8\n" /* step */
+ "p: 43: 0\n" /* doubleslab */
+ "q: 44: 0\n" /* step */,
+
+ // Block data:
+ // Level 0
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "maaaaaaaaa"
+ /* 1 */ "maaaaaaaaa"
+ /* 2 */ "aaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaa"
+ /* 7 */ "maaaaaaaaa"
+ /* 8 */ "maaaaaaaaa"
+
+ // Level 1
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".aaaaaaaaa"
+ /* 1 */ ".aaaaaaaaa"
+ /* 2 */ "baaaaaaaaa"
+ /* 3 */ "caaaaaaaaa"
+ /* 4 */ "caadaaaaaa"
+ /* 5 */ "caaaaaaaaa"
+ /* 6 */ "eaaaaaaaaa"
+ /* 7 */ ".aaaaaaaaa"
+ /* 8 */ ".aaaaaaaaa"
+
+ // Level 2
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".fffffffff"
+ /* 1 */ ".f.......f"
+ /* 2 */ ".f.ggggg.f"
+ /* 3 */ "...ghhhg.f"
+ /* 4 */ "....hhhg.f"
+ /* 5 */ "...ghhhg.f"
+ /* 6 */ ".f.ggggg.f"
+ /* 7 */ ".f.......f"
+ /* 8 */ ".fffffffff"
+
+ // Level 3
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".....i...i"
+ /* 1 */ ".........."
+ /* 2 */ ".i.jjgjj.."
+ /* 3 */ "...g...j.."
+ /* 4 */ ".......g.i"
+ /* 5 */ "...g...j.."
+ /* 6 */ ".i.jjgjj.."
+ /* 7 */ ".........."
+ /* 8 */ ".....i...i"
+
+ // Level 4
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".........."
+ /* 2 */ "...jjgjj.."
+ /* 3 */ "...g...j.."
+ /* 4 */ "...j...g.."
+ /* 5 */ "...g...j.."
+ /* 6 */ "...jjgjj.."
+ /* 7 */ ".........."
+ /* 8 */ ".........."
+
+ // Level 5
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ "...f...f.."
+ /* 2 */ "..fgkgkgf."
+ /* 3 */ "..fd...d.."
+ /* 4 */ "...d.lng.."
+ /* 5 */ "..fd...d.."
+ /* 6 */ "..fgkgkgf."
+ /* 7 */ "...f...f.."
+ /* 8 */ ".........."
+
+ // Level 6
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "...ooooo.."
+ /* 1 */ "..opppppo."
+ /* 2 */ ".opgjjjgpo"
+ /* 3 */ ".opjgggjpo"
+ /* 4 */ ".opjgggjpo"
+ /* 5 */ ".opjgggjpo"
+ /* 6 */ ".opgjjjgpo"
+ /* 7 */ "..opppppo."
+ /* 8 */ "...ooooo.."
+
+ // Level 7
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".opq...qpo"
+ /* 1 */ ".pq.....qp"
+ /* 2 */ ".q.qqqqq.q"
+ /* 3 */ "...qpppq.."
+ /* 4 */ "...qpppq.."
+ /* 5 */ "...qpppq.."
+ /* 6 */ ".q.qqqqq.q"
+ /* 7 */ ".pq.....qp"
+ /* 8 */ ".opq...qpo"
+
+ // Level 8
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".q.......q"
+ /* 1 */ ".........."
+ /* 2 */ ".........."
+ /* 3 */ ".........."
+ /* 4 */ ".....q...."
+ /* 5 */ ".........."
+ /* 6 */ ".........."
+ /* 7 */ ".........."
+ /* 8 */ ".q.......q",
+
+ // Connectors:
+ "-1: 0, 1, 4: 4\n" /* Type -1, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseMid
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseSmall:
+ // The data has been exported from the gallery Plains, area index 68, ID 131, created by Aloe_vera
+ {
+ // Size:
+ 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 7, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 2\n" /* wood */
+ "b: 17: 1\n" /* tree */
+ "c: 35: 0\n" /* wool */
+ "d: 50: 4\n" /* torch */
+ "e: 85: 0\n" /* fence */
+ "f: 44: 8\n" /* step */
+ "g: 43: 0\n" /* doubleslab */
+ "h: 44: 0\n" /* step */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".bcc.b."
+ /* 2 */ ".c...c."
+ /* 3 */ ".c...c."
+ /* 4 */ ".c...c."
+ /* 5 */ ".bcccb."
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ ".....d."
+ /* 1 */ ".bee.b."
+ /* 2 */ ".c...c."
+ /* 3 */ ".e...e."
+ /* 4 */ ".c...c."
+ /* 5 */ ".beeeb."
+ /* 6 */ "......."
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ ".fffff."
+ /* 1 */ "fbcccbf"
+ /* 2 */ "fc...cf"
+ /* 3 */ "fc...cf"
+ /* 4 */ "fc...cf"
+ /* 5 */ "fbcccbf"
+ /* 6 */ ".fffff."
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "gh...hg"
+ /* 1 */ "hhhhhhh"
+ /* 2 */ ".hgggh."
+ /* 3 */ ".hgggh."
+ /* 4 */ ".hgggh."
+ /* 5 */ "hhhhhhh"
+ /* 6 */ "gh...hg"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "......."
+ /* 2 */ "......."
+ /* 3 */ "...h..."
+ /* 4 */ "......."
+ /* 5 */ "......."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseSmall
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseSmallDblWithDoor:
+ // The data has been exported from the gallery Plains, area index 113, ID 265, created by Aloe_vera
+ {
+ // Size:
+ 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 2\n" /* wood */
+ "b: 17: 9\n" /* tree */
+ "c: 17: 1\n" /* tree */
+ "d: 35: 0\n" /* wool */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:171:12\n" /* carpet */
+ "g:135: 1\n" /* 135 */
+ "h:126: 2\n" /* woodenslab */
+ "i:135: 2\n" /* 135 */
+ "j: 50: 4\n" /* torch */
+ "k: 64:12\n" /* wooddoorblock */
+ "l: 85: 0\n" /* fence */
+ "m: 19: 0\n" /* sponge */
+ "n: 44: 8\n" /* step */
+ "o: 43: 0\n" /* doubleslab */
+ "p: 44: 0\n" /* step */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaabaaaam"
+ /* 3 */ "maaaabaaaam"
+ /* 4 */ "maaaabaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".cdedcdddc."
+ /* 2 */ ".dfff.fffd."
+ /* 3 */ ".dgffdfhfd."
+ /* 4 */ ".diifdfffd."
+ /* 5 */ ".cdddcdddc."
+ /* 6 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ ".j...j...j."
+ /* 1 */ ".cdkdclllc."
+ /* 2 */ ".d.......l."
+ /* 3 */ ".l...l...l."
+ /* 4 */ ".d...l...l."
+ /* 5 */ ".clllclllc."
+ /* 6 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ ".nnnnnnnnn."
+ /* 1 */ "ncdddcdddcn"
+ /* 2 */ "nd...d...dn"
+ /* 3 */ "nd...d...dn"
+ /* 4 */ "nd...d...dn"
+ /* 5 */ "ncdddcdddcn"
+ /* 6 */ ".nnnnnnnnn."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "op.......po"
+ /* 1 */ "ppppppppppp"
+ /* 2 */ ".pooooooop."
+ /* 3 */ ".ponndnnop."
+ /* 4 */ ".pooooooop."
+ /* 5 */ "ppppppppppp"
+ /* 6 */ "op.......po"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "...ppppp..."
+ /* 4 */ "..........."
+ /* 5 */ "..........."
+ /* 6 */ "...........",
+
+ // Connectors:
+ "-1: 3, 1, -1: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseSmallDblWithDoor
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseSmallDouble:
+ // The data has been exported from the gallery Plains, area index 72, ID 135, created by Aloe_vera
+ {
+ // Size:
+ 11, 6, 7, // SizeX = 11, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 2\n" /* wood */
+ "b: 17: 1\n" /* tree */
+ "c: 35: 0\n" /* wool */
+ "d:171:12\n" /* carpet */
+ "e:135: 1\n" /* 135 */
+ "f:126: 2\n" /* woodenslab */
+ "g:135: 2\n" /* 135 */
+ "h: 50: 4\n" /* torch */
+ "i: 85: 0\n" /* fence */
+ "j: 44: 8\n" /* step */
+ "k: 43: 0\n" /* doubleslab */
+ "l: 44: 0\n" /* step */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".bcc.bcccb."
+ /* 2 */ ".cddd.dddc."
+ /* 3 */ ".ceddcdfdc."
+ /* 4 */ ".cggdcdddc."
+ /* 5 */ ".bcccbcccb."
+ /* 6 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ ".h...h...h."
+ /* 1 */ ".bii.biiib."
+ /* 2 */ ".c.......c."
+ /* 3 */ ".i...i...i."
+ /* 4 */ ".c...i...c."
+ /* 5 */ ".biiibiiib."
+ /* 6 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ ".jjjjjjjjj."
+ /* 1 */ "jbiiibiiibj"
+ /* 2 */ "jc.......cj"
+ /* 3 */ "jc...c...cj"
+ /* 4 */ "jc...c...cj"
+ /* 5 */ "jbcccbcccbj"
+ /* 6 */ ".jjjjjjjjj."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "kl...l...lk"
+ /* 1 */ "lllllllllll"
+ /* 2 */ ".lkkklkkkl."
+ /* 3 */ ".lkjklkkkl."
+ /* 4 */ ".lkkklkkkl."
+ /* 5 */ "lllllllllll"
+ /* 6 */ "kl...l...lk"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "...l...l..."
+ /* 4 */ "..........."
+ /* 5 */ "..........."
+ /* 6 */ "...........",
+
+ // Connectors:
+ "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseSmallDouble
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseSmallWithDoor:
+ // The data has been exported from the gallery Plains, area index 112, ID 264, created by Aloe_vera
+ {
+ // Size:
+ 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 7, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 2\n" /* wood */
+ "b: 17: 1\n" /* tree */
+ "c: 35: 0\n" /* wool */
+ "d: 64: 7\n" /* wooddoorblock */
+ "e: 50: 4\n" /* torch */
+ "f: 64:12\n" /* wooddoorblock */
+ "g: 85: 0\n" /* fence */
+ "h: 44: 8\n" /* step */
+ "i: 43: 0\n" /* doubleslab */
+ "j: 44: 0\n" /* step */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".bcdcb."
+ /* 2 */ ".c...c."
+ /* 3 */ ".c...c."
+ /* 4 */ ".c...c."
+ /* 5 */ ".bcccb."
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ ".....e."
+ /* 1 */ ".bcfcb."
+ /* 2 */ ".g...g."
+ /* 3 */ ".g...g."
+ /* 4 */ ".g...g."
+ /* 5 */ ".bgggb."
+ /* 6 */ "......."
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ ".hhhhh."
+ /* 1 */ "hbcccbh"
+ /* 2 */ "hc...ch"
+ /* 3 */ "hc...ch"
+ /* 4 */ "hc...ch"
+ /* 5 */ "hbcccbh"
+ /* 6 */ ".hhhhh."
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "ij...ji"
+ /* 1 */ "jjjjjjj"
+ /* 2 */ ".jiiij."
+ /* 3 */ ".jiiij."
+ /* 4 */ ".jiiij."
+ /* 5 */ "jjjjjjj"
+ /* 6 */ "ij...ji"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "......."
+ /* 2 */ "......."
+ /* 3 */ "...j..."
+ /* 4 */ "......."
+ /* 5 */ "......."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseSmallWithDoor
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseWide:
+ // The data has been exported from the gallery Plains, area index 64, ID 121, created by STR_Warrior
+ {
+ // Size:
+ 11, 6, 11, // SizeX = 11, SizeY = 6, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, 0, -1, // MinX, MinY, MinZ
+ 11, 5, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 2\n" /* wood */
+ "b: 17: 1\n" /* tree */
+ "c: 35: 0\n" /* wool */
+ "d:171: 0\n" /* carpet */
+ "e:126: 1\n" /* woodenslab */
+ "f: 64: 5\n" /* wooddoorblock */
+ "g: 85: 0\n" /* fence */
+ "h: 50: 1\n" /* torch */
+ "i: 50: 2\n" /* torch */
+ "j: 64:12\n" /* wooddoorblock */
+ "k:126:11\n" /* woodenslab */
+ "l: 17: 5\n" /* tree */
+ "m: 19: 0\n" /* sponge */
+ "n:126: 3\n" /* woodenslab */
+ "o:125: 3\n" /* woodendoubleslab */
+ "p: 5: 3\n" /* wood */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "mmaaaaaaamm"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "maaaaaaaaam"
+ /* 7 */ "maaaaaaaaam"
+ /* 8 */ "maaaaaaaaam"
+ /* 9 */ "mmaaaaaaamm"
+ /* 10 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..bcbcbcb.."
+ /* 2 */ ".b.d.....b."
+ /* 3 */ ".cded....c."
+ /* 4 */ ".bded....b."
+ /* 5 */ ".c.d.....c."
+ /* 6 */ ".b.......b."
+ /* 7 */ ".c.......c."
+ /* 8 */ ".b.......b."
+ /* 9 */ "..bcbfbcb.."
+ /* 10 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..bgbgbgb.."
+ /* 2 */ ".b.......b."
+ /* 3 */ ".g.......g."
+ /* 4 */ ".bh.....ib."
+ /* 5 */ ".g.......g."
+ /* 6 */ ".b.......b."
+ /* 7 */ ".g.......g."
+ /* 8 */ ".b.......b."
+ /* 9 */ "..bgbjbgb.."
+ /* 10 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "...kkkkk..."
+ /* 1 */ "..bcbcbcb.."
+ /* 2 */ ".b.......b."
+ /* 3 */ "kc.......ck"
+ /* 4 */ "kb.......bk"
+ /* 5 */ "kc.......ck"
+ /* 6 */ "kb.......bk"
+ /* 7 */ "kc.......ck"
+ /* 8 */ ".b.......b."
+ /* 9 */ "..bcblbcb.."
+ /* 10 */ "...kkkkk..."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ ".kn.....nk."
+ /* 1 */ "konnnnnnnok"
+ /* 2 */ "nnnnnnnnnnn"
+ /* 3 */ ".nnpppppnn."
+ /* 4 */ ".nnpkkkpnn."
+ /* 5 */ ".nnpkkkpnn."
+ /* 6 */ ".nnpkkkpnn."
+ /* 7 */ ".nnpppppnn."
+ /* 8 */ "nnnnnnnnnnn"
+ /* 9 */ "kknnnnnnnok"
+ /* 10 */ ".kn.....nk."
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "n.........n"
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "....nnn...."
+ /* 5 */ "....non...."
+ /* 6 */ "....nnn...."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "n.........n",
+
+ // Connectors:
+ "-1: 5, 1, 10: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseWide
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseWithGarden:
+ // The data has been exported from the gallery Plains, area index 67, ID 130, created by Aloe_vera
+ {
+ // Size:
+ 16, 9, 16, // SizeX = 16, SizeY = 9, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 16, 8, 16, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 5: 2\n" /* wood */
+ "c: 2: 0\n" /* grass */
+ "d:113: 0\n" /* netherbrickfence */
+ "e: 17: 1\n" /* tree */
+ "f: 35: 0\n" /* wool */
+ "g:126: 2\n" /* woodenslab */
+ "h: 31: 2\n" /* tallgrass */
+ "i:125: 2\n" /* woodendoubleslab */
+ "j: 38: 3\n" /* rose */
+ "k: 38: 2\n" /* rose */
+ "l: 38: 1\n" /* rose */
+ "m: 19: 0\n" /* sponge */
+ "n: 17: 2\n" /* tree */
+ "o: 50: 4\n" /* torch */
+ "p: 85: 0\n" /* fence */
+ "q:140: 0\n" /* flowerpotblock */
+ "r: 50: 3\n" /* torch */
+ "s: 44: 8\n" /* step */
+ "t: 50: 1\n" /* torch */
+ "u: 50: 2\n" /* torch */
+ "v: 43: 0\n" /* doubleslab */
+ "w: 44: 0\n" /* step */
+ "x: 18:10\n" /* leaves */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmaammmmm"
+ /* 1 */ "aabbbbbbbbbbaaam"
+ /* 2 */ "aabbbbbbbbbbaaam"
+ /* 3 */ "aabbbbbbbbbbaaam"
+ /* 4 */ "aabbbbbbbbbbaaam"
+ /* 5 */ "aabbbbbbbbbbaaam"
+ /* 6 */ "aabbbbbbbbbbaaam"
+ /* 7 */ "aabbbbbbbbbbaaam"
+ /* 8 */ "aabbbbbbbbbbaaam"
+ /* 9 */ "aabbbbbbbbbbaaam"
+ /* 10 */ "aaaaaaaaaaaaaaam"
+ /* 11 */ "aaaaaaaaaaaaaaam"
+ /* 12 */ "aaaaaaaaaaaaaaam"
+ /* 13 */ "aaaaaaaaaaaaaaam"
+ /* 14 */ "aaaaaaaaaaaaaaam"
+ /* 15 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmccmmmmm"
+ /* 1 */ "ccbbbbbbbbbbcccm"
+ /* 2 */ "ccbbbbbbbbbbcccm"
+ /* 3 */ "ccbbbbbbbbbbcccm"
+ /* 4 */ "ccbbbbbbbbbbcccm"
+ /* 5 */ "ccbbbbbbbbbbcccm"
+ /* 6 */ "ccbbbbbbbbbbcccm"
+ /* 7 */ "ccbbbbbbbbbbcccm"
+ /* 8 */ "ccbbbbbbbbbbcccm"
+ /* 9 */ "ccbbbbbbbbbbcccm"
+ /* 10 */ "cccccccccccccccm"
+ /* 11 */ "cccccccccccccccm"
+ /* 12 */ "cccccccccccccccm"
+ /* 13 */ "cccccccccccccacm"
+ /* 14 */ "cccccccccccccccm"
+ /* 15 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "ddeffeffe..eddd."
+ /* 2 */ "d.fbbgggg..f..d."
+ /* 3 */ "d.fbgggggggf.hd."
+ /* 4 */ "d.fbgggggggf..d."
+ /* 5 */ "d.eggggggggehhd."
+ /* 6 */ "d.fgiiggiigf.hd."
+ /* 7 */ "d.fgiiggiigf..d."
+ /* 8 */ "d.fggggggggf..d."
+ /* 9 */ "d.efffeefffe.hd."
+ /* 10 */ "d.............d."
+ /* 11 */ "djhhk.jhh..hh.d."
+ /* 12 */ "d.jlk.hj.h....d."
+ /* 13 */ "d..jh.hh..h..nd."
+ /* 14 */ "ddddddddddddddd."
+ /* 15 */ "................"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "........o..o...."
+ /* 1 */ "..eppeffe..e...."
+ /* 2 */ "..pqq......p...."
+ /* 3 */ "..pq.......p...."
+ /* 4 */ "..pq.......p...."
+ /* 5 */ "..e........e...."
+ /* 6 */ "..p........p...."
+ /* 7 */ "..p........p...."
+ /* 8 */ "..p........p...."
+ /* 9 */ "..epppeepppe...."
+ /* 10 */ "......rr........"
+ /* 11 */ "................"
+ /* 12 */ "................"
+ /* 13 */ ".............n.."
+ /* 14 */ "................"
+ /* 15 */ "................"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..ssssssssss...."
+ /* 1 */ ".seffeffeffes..."
+ /* 2 */ ".sf..r.....fs..."
+ /* 3 */ ".sf........fs..."
+ /* 4 */ ".sf........fs..."
+ /* 5 */ ".set......ues..."
+ /* 6 */ ".sf........fs..."
+ /* 7 */ ".sf........fs..."
+ /* 8 */ ".sf........fs..."
+ /* 9 */ ".sefffeefffes..."
+ /* 10 */ "..ssssssssss...."
+ /* 11 */ "................"
+ /* 12 */ "................"
+ /* 13 */ ".............n.."
+ /* 14 */ "................"
+ /* 15 */ "................"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ ".vw........wv..."
+ /* 1 */ ".wwwwwwwwwwww..."
+ /* 2 */ "..wvvvvvvvvw...."
+ /* 3 */ "..wvvvvvvvvw...."
+ /* 4 */ "..wvvvvvvvvw...."
+ /* 5 */ "..wvvvvvvvvw...."
+ /* 6 */ "..wvvvvvvvvw...."
+ /* 7 */ "..wvvvvvvvvw...."
+ /* 8 */ "..wvvvvvvvvw...."
+ /* 9 */ ".wwwwwwwwwwww..."
+ /* 10 */ ".vw........wv..."
+ /* 11 */ "............xxx."
+ /* 12 */ "...........xxxxx"
+ /* 13 */ "...........xxnxx"
+ /* 14 */ "...........xxxxx"
+ /* 15 */ "............xxx."
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "....wwwwww......"
+ /* 4 */ "....wvvvvw......"
+ /* 5 */ "....wvvvvw......"
+ /* 6 */ "....wvvvvw......"
+ /* 7 */ "....wwwwww......"
+ /* 8 */ "................"
+ /* 9 */ "................"
+ /* 10 */ "................"
+ /* 11 */ "............xxx."
+ /* 12 */ "...........xxxxx"
+ /* 13 */ "...........xxnxx"
+ /* 14 */ "...........xxxxx"
+ /* 15 */ "............xxx."
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "................"
+ /* 4 */ "................"
+ /* 5 */ "......ww........"
+ /* 6 */ "................"
+ /* 7 */ "................"
+ /* 8 */ "................"
+ /* 9 */ "................"
+ /* 10 */ "................"
+ /* 11 */ "................"
+ /* 12 */ "............xxx."
+ /* 13 */ "............xnx."
+ /* 14 */ "............xx.."
+ /* 15 */ "................"
+
+ // Level 8
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "................"
+ /* 4 */ "................"
+ /* 5 */ "................"
+ /* 6 */ "................"
+ /* 7 */ "................"
+ /* 8 */ "................"
+ /* 9 */ "................"
+ /* 10 */ "................"
+ /* 11 */ "................"
+ /* 12 */ ".............x.."
+ /* 13 */ "............xxx."
+ /* 14 */ ".............x.."
+ /* 15 */ "................",
+
+ // Connectors:
+ "-1: 9, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseWithGarden
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseWithSakura1:
+ // The data has been exported from the gallery Plains, area index 75, ID 141, created by Aloe_vera
+ {
+ // Size:
+ 13, 7, 15, // SizeX = 13, SizeY = 7, SizeZ = 15
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 13, 6, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 2: 0\n" /* grass */
+ "c: 17: 5\n" /* tree */
+ "d: 5: 2\n" /* wood */
+ "e: 17: 9\n" /* tree */
+ "f:113: 0\n" /* netherbrickfence */
+ "g: 17: 1\n" /* tree */
+ "h: 35: 0\n" /* wool */
+ "i: 31: 2\n" /* tallgrass */
+ "j: 54: 2\n" /* chest */
+ "k: 38: 6\n" /* rose */
+ "l: 38: 2\n" /* rose */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 4\n" /* torch */
+ "o: 85: 0\n" /* fence */
+ "p: 44: 8\n" /* step */
+ "q: 35: 6\n" /* wool */
+ "r: 43: 0\n" /* doubleslab */
+ "s: 44: 0\n" /* step */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "aaaaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaaaaa"
+ /* 7 */ "aaaaaaaaaaaaa"
+ /* 8 */ "aaaaaaaaaaaaa"
+ /* 9 */ "aaaaaaaaaaaaa"
+ /* 10 */ "aaaaaaaaaaaaa"
+ /* 11 */ "aaaaaaaaaaaaa"
+ /* 12 */ "aaaaaaaaaaaaa"
+ /* 13 */ "aaaaaaaaaaaaa"
+ /* 14 */ "aaaaaaaaaaaaa"
+
+ // Level 1
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "bbbbbbbbbbbbb"
+ /* 1 */ "bbbbbbbbbbbbb"
+ /* 2 */ "bbbaccdabbbbb"
+ /* 3 */ "bbbedddebbbbb"
+ /* 4 */ "bbbedddebbbbb"
+ /* 5 */ "bbbedddebbbbb"
+ /* 6 */ "bbbacccabbbbb"
+ /* 7 */ "bbbbbbbbbbbbb"
+ /* 8 */ "bbbbbbbbbbbbb"
+ /* 9 */ "bbbbbbbbbbbbb"
+ /* 10 */ "bbbbbbbbbbabb"
+ /* 11 */ "bbbbbbbbbbbbb"
+ /* 12 */ "bbbbbbbbbbbbb"
+ /* 13 */ "bbbbbbbbbbbbb"
+ /* 14 */ "bbbbbbbbbbbbb"
+
+ // Level 2
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "ffff...ffffff"
+ /* 1 */ "f...........f"
+ /* 2 */ "f..ghh.g..i.f"
+ /* 3 */ "f..h...h..i.f"
+ /* 4 */ "f..h...h....f"
+ /* 5 */ "fi.h..jh..i.f"
+ /* 6 */ "f..ghhhg....f"
+ /* 7 */ "f.........i.f"
+ /* 8 */ "fii.........f"
+ /* 9 */ "f.k..k.i....f"
+ /* 10 */ "fl.i..i...g.f"
+ /* 11 */ "f.i..i.k....f"
+ /* 12 */ "f.l.k.......f"
+ /* 13 */ "f.....l.....f"
+ /* 14 */ "fffffffffffff"
+
+ // Level 3
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ ".......n....."
+ /* 2 */ "...goo.g....."
+ /* 3 */ "...h...h....."
+ /* 4 */ "...o...o....."
+ /* 5 */ "...h...h....."
+ /* 6 */ "...gooog....."
+ /* 7 */ "............."
+ /* 8 */ "............."
+ /* 9 */ "............."
+ /* 10 */ "..........g.."
+ /* 11 */ "............."
+ /* 12 */ "............."
+ /* 13 */ "............."
+ /* 14 */ "............."
+
+ // Level 4
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "...ppppp....."
+ /* 2 */ "..pghhhgp...."
+ /* 3 */ "..ph...hp...."
+ /* 4 */ "..ph...hp...."
+ /* 5 */ "..ph...hp...."
+ /* 6 */ "..pghhhgp...."
+ /* 7 */ "...ppppp....."
+ /* 8 */ "............."
+ /* 9 */ "..........q.."
+ /* 10 */ ".........qgq."
+ /* 11 */ "..........q.."
+ /* 12 */ "............."
+ /* 13 */ "............."
+ /* 14 */ "............."
+
+ // Level 5
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "..rs...sr...."
+ /* 2 */ "..sssssss...."
+ /* 3 */ "...srrrs....."
+ /* 4 */ "...srrrs....."
+ /* 5 */ "...srrrs....."
+ /* 6 */ "..sssssss...."
+ /* 7 */ "..rs...sr...."
+ /* 8 */ "............."
+ /* 9 */ ".........qqq."
+ /* 10 */ ".........qqq."
+ /* 11 */ ".........qqq."
+ /* 12 */ "............."
+ /* 13 */ "............."
+ /* 14 */ "............."
+
+ // Level 6
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "............."
+ /* 4 */ ".....s......."
+ /* 5 */ "............."
+ /* 6 */ "............."
+ /* 7 */ "............."
+ /* 8 */ "............."
+ /* 9 */ "............."
+ /* 10 */ "..........q.."
+ /* 11 */ "............."
+ /* 12 */ "............."
+ /* 13 */ "............."
+ /* 14 */ ".............",
+
+ // Connectors:
+ "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseWithSakura1
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseWithSpa:
+ // The data has been exported from the gallery Plains, area index 73, ID 139, created by Aloe_vera
+ {
+ // Size:
+ 16, 8, 14, // SizeX = 16, SizeY = 8, SizeZ = 14
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 7, 13, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 2\n" /* wood */
+ "b: 3: 0\n" /* dirt */
+ "c: 2: 0\n" /* grass */
+ "d: 8: 0\n" /* water */
+ "e:135: 3\n" /* 135 */
+ "f:135: 1\n" /* 135 */
+ "g:113: 0\n" /* netherbrickfence */
+ "h: 17: 1\n" /* tree */
+ "i: 35: 0\n" /* wool */
+ "j:171:12\n" /* carpet */
+ "k: 64: 6\n" /* wooddoorblock */
+ "l:126: 2\n" /* woodenslab */
+ "m: 19: 0\n" /* sponge */
+ "n:135: 2\n" /* 135 */
+ "o: 64: 7\n" /* wooddoorblock */
+ "p: 50: 4\n" /* torch */
+ "q: 85: 0\n" /* fence */
+ "r: 64:12\n" /* wooddoorblock */
+ "s: 50: 3\n" /* torch */
+ "t: 44: 8\n" /* step */
+ "u: 43: 0\n" /* doubleslab */
+ "v: 44: 0\n" /* step */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ ".aaaaaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaaaaa."
+ /* 6 */ ".aaaaaaaaaaaaaa."
+ /* 7 */ ".aaaaaabbbbbbbbb"
+ /* 8 */ ".aaaaaabbbbbbbbb"
+ /* 9 */ ".aaaaaabbbbbbbbb"
+ /* 10 */ ".aaaaaabbbbbbbbb"
+ /* 11 */ ".aaaaaabbbbbbbbb"
+ /* 12 */ ".aaaaaabbbbbbbbb"
+ /* 13 */ ".......bbbbbbbbb"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "maaaaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaccccc"
+ /* 8 */ "maaaaaaacccccccc"
+ /* 9 */ "maaaaaaacccccccc"
+ /* 10 */ "maaaaaaacccccccc"
+ /* 11 */ "maaaaaaccccccccc"
+ /* 12 */ "maaaaaaccccccccc"
+ /* 13 */ "mmmmmmmccccccccc"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ ".aaaaaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaaaaa."
+ /* 6 */ ".aaddaaaaaaaaaa."
+ /* 7 */ ".aaddaaeeef....."
+ /* 8 */ ".aaddaaf........"
+ /* 9 */ ".aaddaaf........"
+ /* 10 */ ".aaddaae........"
+ /* 11 */ ".aaddaa........."
+ /* 12 */ ".aaaaaa........."
+ /* 13 */ "................"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ ".ggggghiiihiiih."
+ /* 2 */ ".geee.ijjjjjjji."
+ /* 3 */ ".gf...kjjjijlji."
+ /* 4 */ ".gf...innjijjji."
+ /* 5 */ ".g....hiiohiiih."
+ /* 6 */ ".g....g........."
+ /* 7 */ ".g.............."
+ /* 8 */ ".g.............."
+ /* 9 */ ".g.............."
+ /* 10 */ ".g....g........."
+ /* 11 */ ".g....g........."
+ /* 12 */ ".gggggg........."
+ /* 13 */ "................"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "......p...p...p."
+ /* 1 */ ".g....hqqqhqqqh."
+ /* 2 */ "......i.......i."
+ /* 3 */ "......r...q...q."
+ /* 4 */ "......i...q...i."
+ /* 5 */ "......hqqrhqqqh."
+ /* 6 */ "......g...s....."
+ /* 7 */ "................"
+ /* 8 */ "................"
+ /* 9 */ "................"
+ /* 10 */ "................"
+ /* 11 */ "................"
+ /* 12 */ ".g....g........."
+ /* 13 */ "................"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ ".tttttttttttttt."
+ /* 1 */ "tggggghqqqhqqqht"
+ /* 2 */ "tg....i.......it"
+ /* 3 */ "tg....i...i...it"
+ /* 4 */ "tg....i...i...it"
+ /* 5 */ "tg....hiiihiiiht"
+ /* 6 */ "tg....gtttttttt."
+ /* 7 */ "tg....gt........"
+ /* 8 */ "tg....gt........"
+ /* 9 */ "tg....gt........"
+ /* 10 */ "tg....gt........"
+ /* 11 */ "tg....gt........"
+ /* 12 */ "tggggggt........"
+ /* 13 */ ".tttttt........."
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "uv............vu"
+ /* 1 */ "vvvvvvvvvvvvvvvv"
+ /* 2 */ ".vuuuuuuuuuuuuv."
+ /* 3 */ ".vuuuuuutuuuuuv."
+ /* 4 */ ".vuuuuuuuuuuuuv."
+ /* 5 */ ".vuuuuvvvvvvvvvv"
+ /* 6 */ ".vuuuuv.......vu"
+ /* 7 */ ".vuuuuv........."
+ /* 8 */ ".vuuuuv........."
+ /* 9 */ ".vuuuuv........."
+ /* 10 */ ".vuuuuv........."
+ /* 11 */ ".vuuuuv........."
+ /* 12 */ "vvvvvvvv........"
+ /* 13 */ "uv....vu........"
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "...vvvvvvvvvv..."
+ /* 4 */ "...vv..........."
+ /* 5 */ "...vv..........."
+ /* 6 */ "...vv..........."
+ /* 7 */ "...vv..........."
+ /* 8 */ "...vv..........."
+ /* 9 */ "...vv..........."
+ /* 10 */ "...vv..........."
+ /* 11 */ "................"
+ /* 12 */ "................"
+ /* 13 */ "................",
+
+ // Connectors:
+ "",
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseWithSpa
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MediumSakuraTree:
+ // The data has been exported from the gallery Plains, area index 146, ID 490, created by STR_Warrior
+ {
+ // Size:
+ 7, 10, 7, // SizeX = 7, SizeY = 10, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 9, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 2: 0\n" /* grass */
+ "c: 31: 1\n" /* tallgrass */
+ "d: 38: 7\n" /* rose */
+ "e: 17: 1\n" /* tree */
+ "f: 38: 0\n" /* rose */
+ "g: 38: 8\n" /* rose */
+ "h: 38: 5\n" /* rose */
+ "i: 35: 6\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "aaaaaaa"
+ /* 2 */ "aaaaaaa"
+ /* 3 */ "aaaaaaa"
+ /* 4 */ "aaaaaaa"
+ /* 5 */ "aaaaaaa"
+ /* 6 */ "aaaaaaa"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "bbbbbbb"
+ /* 1 */ "bbbbbbb"
+ /* 2 */ "bbbbbbb"
+ /* 3 */ "bbbabbb"
+ /* 4 */ "bbbbbbb"
+ /* 5 */ "bbbbbbb"
+ /* 6 */ "bbbbbbb"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "m.c...m"
+ /* 2 */ ".dccdc."
+ /* 3 */ "..cefc."
+ /* 4 */ ".ccfgh."
+ /* 5 */ "m.ccc.m"
+ /* 6 */ "mm...mm"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "m.....m"
+ /* 1 */ "......."
+ /* 2 */ "......."
+ /* 3 */ "...e..."
+ /* 4 */ "......."
+ /* 5 */ "......."
+ /* 6 */ "m.....m"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "..i...."
+ /* 2 */ "......."
+ /* 3 */ "...e.i."
+ /* 4 */ ".i....."
+ /* 5 */ "......."
+ /* 6 */ "......."
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "..i...."
+ /* 2 */ "...i..."
+ /* 3 */ "..ieii."
+ /* 4 */ ".i.ii.."
+ /* 5 */ "...i..."
+ /* 6 */ "......."
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "..ii..."
+ /* 2 */ "..iii.."
+ /* 3 */ ".iieii."
+ /* 4 */ ".iiii.."
+ /* 5 */ "..iii.."
+ /* 6 */ "......."
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "..iii.."
+ /* 2 */ ".iiiii."
+ /* 3 */ ".iieii."
+ /* 4 */ ".iiiii."
+ /* 5 */ "..iii.."
+ /* 6 */ "......."
+
+ // Level 8
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "...i..."
+ /* 2 */ "..iiii."
+ /* 3 */ ".iiiii."
+ /* 4 */ "..iii.."
+ /* 5 */ "...i..."
+ /* 6 */ "......."
+
+ // Level 9
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "......."
+ /* 2 */ "...i..."
+ /* 3 */ "..iii.."
+ /* 4 */ "...i..."
+ /* 5 */ "......."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "-1: 3, 2, 0: 2\n" /* Type -1, direction Z- */
+ "3: 6, 2, 3: 5\n" /* Type 3, direction X+ */
+ "-3: 0, 2, 3: 4\n" /* Type -3, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // MediumSakuraTree
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Restaurant:
+ // The data has been exported from the gallery Plains, area index 61, ID 117, created by Aloe_vera
+ {
+ // Size:
+ 15, 10, 15, // SizeX = 15, SizeY = 10, SizeZ = 15
+
+ // Hitbox (relative to bounding box):
+ -1, 0, -1, // MinX, MinY, MinZ
+ 14, 9, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 2\n" /* wood */
+ "b:135: 0\n" /* 135 */
+ "c:135: 2\n" /* 135 */
+ "d:135: 1\n" /* 135 */
+ "e: 17: 9\n" /* tree */
+ "f:135: 3\n" /* 135 */
+ "g: 85: 0\n" /* fence */
+ "h: 17: 1\n" /* tree */
+ "i:171: 0\n" /* carpet */
+ "j:171:12\n" /* carpet */
+ "k:126: 1\n" /* woodenslab */
+ "l: 50: 5\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 35: 0\n" /* wool */
+ "o: 50: 3\n" /* torch */
+ "p: 50: 1\n" /* torch */
+ "q: 50: 4\n" /* torch */
+ "r: 35:14\n" /* wool */
+ "s: 44: 8\n" /* step */
+ "t: 43: 0\n" /* doubleslab */
+ "u: 44: 0\n" /* step */
+ "v: 17: 5\n" /* tree */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmaaaaaaammmm"
+ /* 1 */ "maaaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaaam"
+ /* 4 */ "aaaaaaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaaaaaaa"
+ /* 7 */ "aaaaaaaaaaaaaaa"
+ /* 8 */ "aaaaaaaaaaaaaaa"
+ /* 9 */ "aaaaaaaaaaaaaaa"
+ /* 10 */ "aaaaaaaaaaaaaaa"
+ /* 11 */ "maaaaaaaaaaaaam"
+ /* 12 */ "maaaaaaaaaaaaam"
+ /* 13 */ "maaaaaaaaaaaaam"
+ /* 14 */ "mmmmaaaaaaammmm"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "....bcccccd...."
+ /* 1 */ ".aaaaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaaaa."
+ /* 4 */ "caaaaaaaaaaaaac"
+ /* 5 */ "baaaaaaaaaaaaad"
+ /* 6 */ "baaaaaaaaaaaaad"
+ /* 7 */ "baaaaaaaaaaeaad"
+ /* 8 */ "baaaaaaaaaaaaad"
+ /* 9 */ "baaaaaaaaaaaaad"
+ /* 10 */ "faaaaaaaaaaaaaf"
+ /* 11 */ ".aaaaaaaaaaaaa."
+ /* 12 */ ".aaaaaaaaaaaaa."
+ /* 13 */ ".aaaaaaaaaaaaa."
+ /* 14 */ "....bfffffd...."
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".gggg.....gggg."
+ /* 2 */ ".g...........g."
+ /* 3 */ ".g.hhhhhhhhh.g."
+ /* 4 */ ".g.hiiijiiih.g."
+ /* 5 */ "...hikijikih..."
+ /* 6 */ "...hiiijiiihg.."
+ /* 7 */ "...hjjjjjjj...."
+ /* 8 */ "...hiiijiiihg.."
+ /* 9 */ "...hikijikih..."
+ /* 10 */ ".g.hiiijiiih.g."
+ /* 11 */ ".g.hhhhhhhhh.g."
+ /* 12 */ ".g...........g."
+ /* 13 */ ".gggg.....gggg."
+ /* 14 */ "..............."
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".l..g.....g..l."
+ /* 2 */ "..............."
+ /* 3 */ "...hnnnhnnnh..."
+ /* 4 */ ".g.n.......n.g."
+ /* 5 */ "...n.......n..."
+ /* 6 */ "...n.......hl.."
+ /* 7 */ "...h..........."
+ /* 8 */ "...n.......hl.."
+ /* 9 */ "...n.......n..."
+ /* 10 */ ".g.n.......n.g."
+ /* 11 */ "...hnnnhnnnh..."
+ /* 12 */ "..............."
+ /* 13 */ ".l..g.....g..l."
+ /* 14 */ "..............."
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "....g.....g...."
+ /* 2 */ "..............."
+ /* 3 */ "...hn.nhn.nh..."
+ /* 4 */ ".g.n...o...n.g."
+ /* 5 */ "...n.......n..."
+ /* 6 */ "...n.......h..."
+ /* 7 */ "...hp......e..."
+ /* 8 */ "...n.......h..."
+ /* 9 */ "...n.......n..."
+ /* 10 */ ".g.n...q...n.g."
+ /* 11 */ "...hn.nhn.nh..."
+ /* 12 */ "..............."
+ /* 13 */ "....g.....g...."
+ /* 14 */ "..............."
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "....g.....g...."
+ /* 2 */ "....ggggggg...."
+ /* 3 */ "...hnnnhnnnh..."
+ /* 4 */ ".ggn.......ngg."
+ /* 5 */ "..gn.......ng.."
+ /* 6 */ "..gn.......hg.."
+ /* 7 */ "..gh..r.r..ng.."
+ /* 8 */ "..gn.......hg.."
+ /* 9 */ "..gn.......ng.."
+ /* 10 */ ".ggn.......ngg."
+ /* 11 */ "...hnnnhnnnh..."
+ /* 12 */ "....ggggggg...."
+ /* 13 */ "....g.....g...."
+ /* 14 */ "..............."
+
+ // Level 6
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "...stuuuuuts..."
+ /* 2 */ "..sttttttttts.."
+ /* 3 */ ".sthvvvhvvvhts."
+ /* 4 */ ".tte.......ett."
+ /* 5 */ ".ute.......etu."
+ /* 6 */ ".ute.......htu."
+ /* 7 */ ".uth..g.g..etu."
+ /* 8 */ ".ute.......htu."
+ /* 9 */ ".ute.......etu."
+ /* 10 */ ".tte.......ett."
+ /* 11 */ ".sthvvvhvvvhts."
+ /* 12 */ "..sttttttttts.."
+ /* 13 */ "...stuuuuuts..."
+ /* 14 */ "..............."
+
+ // Level 7
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".stu.......uts."
+ /* 2 */ ".tu.........ut."
+ /* 3 */ ".u.uuuuuuuuu.u."
+ /* 4 */ "...utttttttu..."
+ /* 5 */ "...utttttttu..."
+ /* 6 */ "...utttttttu..."
+ /* 7 */ "...utttttttu..."
+ /* 8 */ "...utttttttu..."
+ /* 9 */ "...utttttttu..."
+ /* 10 */ "...utttttttu..."
+ /* 11 */ ".u.uuuuuuuuu.u."
+ /* 12 */ ".tu.........ut."
+ /* 13 */ ".stu.......uts."
+ /* 14 */ "..............."
+
+ // Level 8
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".u...........u."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "..............."
+ /* 5 */ ".....uuuuu....."
+ /* 6 */ ".....utttu....."
+ /* 7 */ ".....utttu....."
+ /* 8 */ ".....utttu....."
+ /* 9 */ ".....uuuuu....."
+ /* 10 */ "..............."
+ /* 11 */ "..............."
+ /* 12 */ "..............."
+ /* 13 */ ".u...........u."
+ /* 14 */ "..............."
+
+ // Level 9
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "..............."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ ".......u......."
+ /* 8 */ "..............."
+ /* 9 */ "..............."
+ /* 10 */ "..............."
+ /* 11 */ "..............."
+ /* 12 */ "..............."
+ /* 13 */ "..............."
+ /* 14 */ "...............",
+
+ // Connectors:
+ "-1: 14, 1, 7: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Restaurant
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SakuraDouble:
+ // The data has been exported from the gallery Plains, area index 76, ID 142, created by Aloe_vera
+ {
+ // Size:
+ 12, 8, 6, // SizeX = 12, SizeY = 8, SizeZ = 6
+
+ // Hitbox (relative to bounding box):
+ -1, 0, -1, // MinX, MinY, MinZ
+ 12, 7, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 2: 0\n" /* grass */
+ "c: 17: 1\n" /* tree */
+ "d: 35: 6\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "aaaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaaa"
+
+ // Level 1
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "bbbbbbbbbbbb"
+ /* 1 */ "bbbbbbbbbbbb"
+ /* 2 */ "bbabbbbbbbbb"
+ /* 3 */ "bbbbbbbbbabb"
+ /* 4 */ "bbbbbbbbbbbb"
+ /* 5 */ "bbbbbbbbbbbb"
+
+ // Level 2
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "..c........."
+ /* 3 */ ".........c.."
+ /* 4 */ "............"
+ /* 5 */ "............"
+
+ // Level 3
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "..c........."
+ /* 3 */ ".........c.."
+ /* 4 */ "............"
+ /* 5 */ "............"
+
+ // Level 4
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "..d........."
+ /* 1 */ "ddddd......."
+ /* 2 */ "ddcdd...ddd."
+ /* 3 */ "ddddd...dcd."
+ /* 4 */ "..d.....ddd."
+ /* 5 */ "............"
+
+ // Level 5
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ ".ddd........"
+ /* 1 */ ".ddd....ddd."
+ /* 2 */ "ddddd..ddddd"
+ /* 3 */ ".ddd...ddcdd"
+ /* 4 */ ".ddd...ddddd"
+ /* 5 */ "........ddd."
+
+ // Level 6
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "..d......d.."
+ /* 2 */ ".ddd....ddd."
+ /* 3 */ "..d....ddddd"
+ /* 4 */ "........ddd."
+ /* 5 */ ".........d.."
+
+ // Level 7
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "............"
+ /* 3 */ ".........d.."
+ /* 4 */ "............"
+ /* 5 */ "............",
+
+ // Connectors:
+ "-1: -1, 2, 2: 4\n" /* Type -1, direction X- */
+ "3: 5, 2, 6: 3\n" /* Type 3, direction Z+ */
+ "-3: 6, 2, -1: 2\n" /* Type -3, direction Z- */
+ "-3: 12, 2, 2: 5\n" /* Type -3, direction X+ */
+ "3: 12, 2, 2: 5\n" /* Type 3, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // SakuraDouble
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SakuraSmall:
+ // The data has been exported from the gallery Plains, area index 145, ID 489, created by Aloe_vera
+ {
+ // Size:
+ 5, 7, 5, // SizeX = 5, SizeY = 7, SizeZ = 5
+
+ // Hitbox (relative to bounding box):
+ -1, 0, -1, // MinX, MinY, MinZ
+ 5, 6, 5, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 2: 0\n" /* grass */
+ "c: 17: 1\n" /* tree */
+ "d: 35: 6\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 01234 */
+ /* 0 */ "aaaaa"
+ /* 1 */ "aaaaa"
+ /* 2 */ "aaaaa"
+ /* 3 */ "aaaaa"
+ /* 4 */ "aaaaa"
+
+ // Level 1
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bbbbb"
+ /* 2 */ "bbabb"
+ /* 3 */ "bbbbb"
+ /* 4 */ "bbbbb"
+
+ // Level 2
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "..c.."
+ /* 3 */ "....."
+ /* 4 */ "....."
+
+ // Level 3
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "..c.."
+ /* 3 */ "....."
+ /* 4 */ "....."
+
+ // Level 4
+ /* z\x* 01234 */
+ /* 0 */ "..d.."
+ /* 1 */ "ddddd"
+ /* 2 */ "ddcdd"
+ /* 3 */ "ddddd"
+ /* 4 */ "..d.."
+
+ // Level 5
+ /* z\x* 01234 */
+ /* 0 */ ".ddd."
+ /* 1 */ ".ddd."
+ /* 2 */ "ddddd"
+ /* 3 */ ".ddd."
+ /* 4 */ ".ddd."
+
+ // Level 6
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "..d.."
+ /* 2 */ ".ddd."
+ /* 3 */ "..d.."
+ /* 4 */ ".....",
+
+ // Connectors:
+ "-1: 2, 2, -1: 2\n" /* Type -1, direction Z- */
+ "3: 5, 2, 2: 5\n" /* Type 3, direction X+ */
+ "-3: -1, 2, 2: 4\n" /* Type -3, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // SakuraSmall
+}; // g_JapaneseVillagePrefabs
+
+
+
+
+
+
+const cPrefab::sDef g_JapaneseVillageStartingPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // HighTemple:
+ // The data has been exported from the gallery Plains, area index 70, ID 133, created by Aloe_vera
+ {
+ // Size:
+ 11, 19, 11, // SizeX = 11, SizeY = 19, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 10, 18, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 2\n" /* wood */
+ "b:135: 0\n" /* 135 */
+ "c:135: 2\n" /* 135 */
+ "d:135: 1\n" /* 135 */
+ "e: 17: 9\n" /* tree */
+ "f:135: 3\n" /* 135 */
+ "g: 85: 0\n" /* fence */
+ "h: 17: 1\n" /* tree */
+ "i:171: 0\n" /* carpet */
+ "j: 50: 5\n" /* torch */
+ "k: 35: 0\n" /* wool */
+ "l: 17: 5\n" /* tree */
+ "m: 19: 0\n" /* sponge */
+ "n:124: 0\n" /* redstonelampon */
+ "o: 69: 9\n" /* lever */
+ "p: 44: 8\n" /* step */
+ "q: 43: 0\n" /* doubleslab */
+ "r: 44: 0\n" /* step */
+ "s: 50: 4\n" /* torch */
+ "t: 50: 1\n" /* torch */
+ "u: 50: 3\n" /* torch */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmaaaaammm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "aaaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaaa"
+ /* 7 */ "aaaaaaaaaaa"
+ /* 8 */ "maaaaaaaaam"
+ /* 9 */ "maaaaaaaaam"
+ /* 10 */ "mmmaaaaammm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "...bcccd..."
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".aaaaaaaaa."
+ /* 3 */ "caaaaaaaaac"
+ /* 4 */ "baaaaaaaaad"
+ /* 5 */ "baaeaaaaaad"
+ /* 6 */ "baaaaaaaaad"
+ /* 7 */ "faaaaaaaaaf"
+ /* 8 */ ".aaaaaaaaa."
+ /* 9 */ ".aaaaaaaaa."
+ /* 10 */ "...bfffd..."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".ggg...ggg."
+ /* 2 */ ".g.......g."
+ /* 3 */ ".g.hhhhh.g."
+ /* 4 */ "...hiiih..."
+ /* 5 */ "....iiih..."
+ /* 6 */ "...hiiih..."
+ /* 7 */ ".g.hhhhh.g."
+ /* 8 */ ".g.......g."
+ /* 9 */ ".ggg...ggg."
+ /* 10 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".j.g...g.j."
+ /* 2 */ "..........."
+ /* 3 */ ".g.kkhkk.g."
+ /* 4 */ "...h...k..."
+ /* 5 */ ".......h..."
+ /* 6 */ "...h...k..."
+ /* 7 */ ".g.kkhkk.g."
+ /* 8 */ "..........."
+ /* 9 */ ".j.g...g.j."
+ /* 10 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "...g...g..."
+ /* 2 */ "..........."
+ /* 3 */ ".g.kkhkk.g."
+ /* 4 */ "...h...k..."
+ /* 5 */ "...k...h..."
+ /* 6 */ "...h...k..."
+ /* 7 */ ".g.kkhkk.g."
+ /* 8 */ "..........."
+ /* 9 */ "...g...g..."
+ /* 10 */ "..........."
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "...g...g..."
+ /* 2 */ "...ggggg..."
+ /* 3 */ ".gghlhlhgg."
+ /* 4 */ "..ge...eg.."
+ /* 5 */ "..ge.nohg.."
+ /* 6 */ "..ge...eg.."
+ /* 7 */ ".gghlhlhgg."
+ /* 8 */ "...ggggg..."
+ /* 9 */ "...g...g..."
+ /* 10 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..pqrrrqp.."
+ /* 2 */ ".pqqqqqqqp."
+ /* 3 */ ".qqhkkkhqq."
+ /* 4 */ ".rqkhhhkqr."
+ /* 5 */ ".rqkhhhkqr."
+ /* 6 */ ".rqkhhhkqr."
+ /* 7 */ ".qqhkkkhqq."
+ /* 8 */ ".pqqqqqqqp."
+ /* 9 */ "..pqrrrqp.."
+ /* 10 */ "..........."
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".qr.....rq."
+ /* 2 */ ".........r."
+ /* 3 */ "...hhhhh..."
+ /* 4 */ "...hiiih..."
+ /* 5 */ "....iiih..."
+ /* 6 */ "...hiiih..."
+ /* 7 */ "...hhhhh..."
+ /* 8 */ ".r.......r."
+ /* 9 */ ".qr.....rq."
+ /* 10 */ "..........."
+
+ // Level 8
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "...kkhkk..."
+ /* 4 */ "...h...k..."
+ /* 5 */ ".......h..."
+ /* 6 */ "...h...k..."
+ /* 7 */ "...kkhkk..."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 9
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ ".....s....."
+ /* 3 */ "...kkhkk..."
+ /* 4 */ "...h...k..."
+ /* 5 */ "...k...ht.."
+ /* 6 */ "...h...k..."
+ /* 7 */ "...kkhkk..."
+ /* 8 */ ".....u....."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 10
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "...ggggg..."
+ /* 3 */ "..ghlhlhg.."
+ /* 4 */ "..ge...eg.."
+ /* 5 */ "..ge.nohg.."
+ /* 6 */ "..ge...eg.."
+ /* 7 */ "..ghlhlhg.."
+ /* 8 */ "...ggggg..."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 11
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..prrrrrp.."
+ /* 2 */ ".pqqqqqqqp."
+ /* 3 */ ".qqhkkkhqq."
+ /* 4 */ ".rqkhhhkqr."
+ /* 5 */ ".rqkhhhkqr."
+ /* 6 */ ".rqkhhhkqr."
+ /* 7 */ ".qqhkkkhqr."
+ /* 8 */ ".pqqqqqqqp."
+ /* 9 */ "..pqrrrqp.."
+ /* 10 */ "..........."
+
+ // Level 12
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".qr.....rq."
+ /* 2 */ ".r.......r."
+ /* 3 */ "...hhhhh..."
+ /* 4 */ "...hiiih..."
+ /* 5 */ "....iiih..."
+ /* 6 */ "...hiiih..."
+ /* 7 */ "...hhhhh..."
+ /* 8 */ ".r.......r."
+ /* 9 */ ".qr.....rq."
+ /* 10 */ "..........."
+
+ // Level 13
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "...kkhkk..."
+ /* 4 */ "...h...k..."
+ /* 5 */ ".......h..."
+ /* 6 */ "...h...k..."
+ /* 7 */ "...kkhkk..."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 14
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ ".....s....."
+ /* 3 */ "...kkhkk..."
+ /* 4 */ "...h...k..."
+ /* 5 */ "...k...ht.."
+ /* 6 */ "...h...k..."
+ /* 7 */ "...kkhkk..."
+ /* 8 */ ".....u....."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 15
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "...ggggg..."
+ /* 3 */ "..ghlhlhg.."
+ /* 4 */ "..ge...eg.."
+ /* 5 */ "..ge.nohg.."
+ /* 6 */ "..ge...eg.."
+ /* 7 */ "..ghlhlhg.."
+ /* 8 */ "...ggggg..."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 16
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..pqrrrqp.."
+ /* 2 */ ".pqqqqqqqp."
+ /* 3 */ ".qqrrrrrqq."
+ /* 4 */ ".rqrrrrrqr."
+ /* 5 */ ".rqrrrrrqr."
+ /* 6 */ ".rqrrrrrqr."
+ /* 7 */ ".qqrrrrrqq."
+ /* 8 */ ".pqqqqqqqp."
+ /* 9 */ "..pqrrrqp.."
+ /* 10 */ "..........."
+
+ // Level 17
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".qr.....rq."
+ /* 2 */ ".rr.....rr."
+ /* 3 */ "...rrrrr..."
+ /* 4 */ "...rqqqr..."
+ /* 5 */ "...rqqqr..."
+ /* 6 */ "...rqqqr..."
+ /* 7 */ "...rrrrr..."
+ /* 8 */ ".rr.....rr."
+ /* 9 */ ".qr.....rq."
+ /* 10 */ "..........."
+
+ // Level 18
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ ".....r....."
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "...........",
+
+ // Connectors:
+ "2: 0, 1, 5: 4\n" /* Type 2, direction X- */
+ "2: 5, 1, 0: 2\n" /* Type 2, direction Z- */
+ "2: 10, 1, 5: 5\n" /* Type 2, direction X+ */
+ "2: 5, 1, 10: 3\n" /* Type 2, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HighTemple
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Well:
+ // The data has been exported from the gallery Plains, area index 143, ID 487, created by STR_Warrior
+ {
+ // Size:
+ 7, 14, 7, // SizeX = 7, SizeY = 14, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 13, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 8: 0\n" /* water */
+ "d: 13: 0\n" /* gravel */
+ "e: 67: 1\n" /* stairs */
+ "f: 67: 2\n" /* stairs */
+ "g: 67: 0\n" /* stairs */
+ "h: 67: 3\n" /* stairs */
+ "i: 85: 0\n" /* fence */
+ "j: 44: 8\n" /* step */
+ "k: 44: 0\n" /* step */
+ "l: 43: 0\n" /* doubleslab */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbbbbbm"
+ /* 2 */ "mbcc.bm"
+ /* 3 */ "mbcccbm"
+ /* 4 */ "mbcccbm"
+ /* 5 */ "mbbbbbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbbbbbm"
+ /* 2 */ "mbcccbm"
+ /* 3 */ "mbcccbm"
+ /* 4 */ "mbcccbm"
+ /* 5 */ "mbbbbbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbbbbbm"
+ /* 2 */ "mbcccbm"
+ /* 3 */ "mbcccbm"
+ /* 4 */ "mbcccbm"
+ /* 5 */ "mbbbbbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbbbbbm"
+ /* 2 */ "mbcccbm"
+ /* 3 */ "mbcccbm"
+ /* 4 */ "mbcccbm"
+ /* 5 */ "mbbbbbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbbbbbm"
+ /* 2 */ "mbcccbm"
+ /* 3 */ "mbcccbm"
+ /* 4 */ "mbcccbm"
+ /* 5 */ "mbbbbbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mbbbbbm"
+ /* 2 */ "mbcccbm"
+ /* 3 */ "mbcccbm"
+ /* 4 */ "mbcccbm"
+ /* 5 */ "mbbbbbm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "mmbbbmm"
+ /* 1 */ "mbbbbbm"
+ /* 2 */ "bbcccbb"
+ /* 3 */ "bbcccbb"
+ /* 4 */ "bbcccbb"
+ /* 5 */ "mbbbbbm"
+ /* 6 */ "mmbbbmm"
+
+ // Level 8
+ /* z\x* 0123456 */
+ /* 0 */ "mmdddmm"
+ /* 1 */ "mbbbbbm"
+ /* 2 */ "dbcccbd"
+ /* 3 */ "dbcccbd"
+ /* 4 */ "dbcccbd"
+ /* 5 */ "mbbbbbm"
+ /* 6 */ "mmdddmm"
+
+ // Level 9
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mbefgbm"
+ /* 2 */ ".h...h."
+ /* 3 */ ".g...e."
+ /* 4 */ ".f...f."
+ /* 5 */ "mbehgbm"
+ /* 6 */ "mm...mm"
+
+ // Level 10
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mi...im"
+ /* 2 */ "......."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ "mi...im"
+ /* 6 */ "mm...mm"
+
+ // Level 11
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mi...im"
+ /* 2 */ "......."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ "mi...im"
+ /* 6 */ "mm...mm"
+
+ // Level 12
+ /* z\x* 0123456 */
+ /* 0 */ "mjkkkjm"
+ /* 1 */ "jlllllj"
+ /* 2 */ "klllllk"
+ /* 3 */ "klllllk"
+ /* 4 */ "klllllk"
+ /* 5 */ "jlllllj"
+ /* 6 */ "mjkkkjm"
+
+ // Level 13
+ /* z\x* 0123456 */
+ /* 0 */ "k.....k"
+ /* 1 */ "......."
+ /* 2 */ "..kkk.."
+ /* 3 */ "..klk.."
+ /* 4 */ "..kkk.."
+ /* 5 */ "......."
+ /* 6 */ "k.....k",
+
+ // Connectors:
+ "2: 0, 9, 3: 4\n" /* Type 2, direction X- */
+ "2: 3, 9, 0: 2\n" /* Type 2, direction Z- */
+ "2: 6, 9, 3: 5\n" /* Type 2, direction X+ */
+ "2: 3, 9, 6: 3\n" /* Type 2, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Well
+};
+
+
+
+
+
+// The prefab counts:
+
+const size_t g_JapaneseVillagePrefabsCount = ARRAYCOUNT(g_JapaneseVillagePrefabs);
+
+const size_t g_JapaneseVillageStartingPrefabsCount = ARRAYCOUNT(g_JapaneseVillageStartingPrefabs);
+
diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.h b/src/Generating/Prefabs/JapaneseVillagePrefabs.h
new file mode 100644
index 000000000..501b6c1cd
--- /dev/null
+++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.h
@@ -0,0 +1,15 @@
+
+// JapaneseVillagePrefabs.h
+
+// Declares the prefabs in the group JapaneseVillage
+
+#include "../Prefab.h"
+
+
+
+
+
+extern const cPrefab::sDef g_JapaneseVillagePrefabs[];
+extern const cPrefab::sDef g_JapaneseVillageStartingPrefabs[];
+extern const size_t g_JapaneseVillagePrefabsCount;
+extern const size_t g_JapaneseVillageStartingPrefabsCount;
diff --git a/src/Generating/Prefabs/NetherFortPrefabs.cpp b/src/Generating/Prefabs/NetherFortPrefabs.cpp
index d2ef5663d..a3e3da158 100644
--- a/src/Generating/Prefabs/NetherFortPrefabs.cpp
+++ b/src/Generating/Prefabs/NetherFortPrefabs.cpp
@@ -15,7 +15,7 @@
const cPrefab::sDef g_NetherFortPrefabs[] =
{
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BalconyCorridor:
// The data has been exported from the gallery Nether, area index 37, ID 288, created by Aloe_vera
{
@@ -134,7 +134,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 12, 2, 2: 5\n" /* Type 1, direction X+ */
- "1: 0, 2, 2: 4\n" /* Type 1, direction X- */,
+ "1: 0, 2, 2: 4\n" /* Type 1, direction X- */
+ "-1: 12, 2, 2: 5\n" /* Type -1, direction X+ */
+ "-1: 0, 2, 2: 4\n" /* Type -1, direction X- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -143,7 +145,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
20,
@@ -153,11 +155,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BalconyCorridor
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BalconyTee2:
// The data has been exported from the gallery Nether, area index 38, ID 289, created by Aloe_vera
{
@@ -291,7 +296,10 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 12, 2, 4: 5\n" /* Type 1, direction X+ */
"1: 6, 2, 0: 2\n" /* Type 1, direction Z- */
- "1: 0, 2, 4: 4\n" /* Type 1, direction X- */,
+ "1: 0, 2, 4: 4\n" /* Type 1, direction X- */
+ "-1: 12, 2, 4: 5\n" /* Type -1, direction X+ */
+ "-1: 6, 2, 0: 2\n" /* Type -1, direction Z- */
+ "-1: 0, 2, 4: 4\n" /* Type -1, direction X- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -300,7 +308,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
20,
@@ -310,11 +318,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BalconyTee2
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BlazePlatform:
// The data has been exported from the gallery Nether, area index 26, ID 276, created by tonibm1999
{
@@ -420,7 +431,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -430,11 +441,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BlazePlatform
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BlazePlatformOverhang:
// The data has been exported from the gallery Nether, area index 20, ID 162, created by STR_Warrior
{
@@ -590,7 +604,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -600,11 +614,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BlazePlatformOverhang
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BridgeCircleCrossing:
// The data has been exported from the gallery Nether, area index 49, ID 308, created by Aloe_vera
{
@@ -790,7 +807,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
5,
@@ -800,11 +817,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
-1000,
+
+ // MoveToGround:
+ false,
}, // BridgeCircleCrossing
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BridgeCrossing:
// The data has been exported from the gallery Nether, area index 17, ID 159, created by Aloe_vera
{
@@ -991,7 +1011,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
10,
@@ -1001,11 +1021,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BridgeCrossing
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BridgeCrumble1:
// The data has been exported from the gallery Nether, area index 19, ID 161, created by Aloe_vera
{
@@ -1085,7 +1108,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -1095,11 +1118,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BridgeCrumble1
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BridgeCrumble2:
// The data has been exported from the gallery Nether, area index 18, ID 160, created by Aloe_vera
{
@@ -1185,7 +1211,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -1195,11 +1221,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BridgeCrumble2
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BridgeDoubleCrumble:
// The data has been exported from the gallery Nether, area index 46, ID 305, created by STR_Warrior
{
@@ -1208,7 +1237,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Hitbox (relative to bounding box):
0, 0, 0, // MinX, MinY, MinZ
- 4, 6, 15, // MaxX, MaxY, MaxZ
+ 4, 16, 15, // MaxX, MaxY, MaxZ
// Block definitions:
".: 0: 0\n" /* air */
@@ -1364,7 +1393,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
10,
@@ -1374,11 +1403,391 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
1000,
+
+ // MoveToGround:
+ false,
}, // BridgeDoubleCrumble
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
+ // BridgeDoubleStairs:
+ // The data has been exported from the gallery Nether, area index 115, ID 810, created by STR_Warrior
+ {
+ // Size:
+ 15, 16, 16, // SizeX = 15, SizeY = 16, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 14, 15, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a:112: 0\n" /* netherbrick */
+ "b:114: 7\n" /* netherbrickstairs */
+ "c:114: 6\n" /* netherbrickstairs */
+ "d:114: 4\n" /* netherbrickstairs */
+ "e:114: 5\n" /* netherbrickstairs */
+ "f:114: 2\n" /* netherbrickstairs */
+ "g:114: 3\n" /* netherbrickstairs */
+ "h:114: 1\n" /* netherbrickstairs */
+ "i: 44:14\n" /* step */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmmaaam"
+ /* 1 */ "aammmmmmmmmaaaa"
+ /* 2 */ "aammmmmmmmmmmma"
+ /* 3 */ "aammmmmmmmmmmma"
+ /* 4 */ "mmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmm"
+ /* 12 */ "aammmmmmmmmmmma"
+ /* 13 */ "aammmmmmmmmmmma"
+ /* 14 */ "aammmmmmmmmaaaa"
+ /* 15 */ "mmmmmmmmmmmaaam"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmmaaam"
+ /* 1 */ "aammmmmmmmmaaaa"
+ /* 2 */ "aammmmmmmmmmmma"
+ /* 3 */ "aammmmmmmmmmmma"
+ /* 4 */ "mmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmm"
+ /* 12 */ "aammmmmmmmmmmma"
+ /* 13 */ "aammmmmmmmmmmma"
+ /* 14 */ "aammmmmmmmmaaaa"
+ /* 15 */ "mmmmmmmmmmmaaam"
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmmaaam"
+ /* 1 */ "aammmmmmmmmaaaa"
+ /* 2 */ "aammmmmmmmmmmma"
+ /* 3 */ "aammmmmmmmmmmma"
+ /* 4 */ "mmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmm"
+ /* 12 */ "aammmmmmmmmmmma"
+ /* 13 */ "aammmmmmmmmmmma"
+ /* 14 */ "aammmmmmmmmaaaa"
+ /* 15 */ "mmmmmmmmmmmaaam"
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmmaaam"
+ /* 1 */ "aammmmmmmmmaaaa"
+ /* 2 */ "aammmmmmmmmbbba"
+ /* 3 */ "aammmmmmmmmmmma"
+ /* 4 */ "mmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmm"
+ /* 12 */ "aammmmmmmmmmmma"
+ /* 13 */ "aammmmmmmmmccca"
+ /* 14 */ "aammmmmmmmmaaaa"
+ /* 15 */ "mmmmmmmmmmmaaam"
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmmaaam"
+ /* 1 */ "aammmmmmmmmaaaa"
+ /* 2 */ "aammmmmmmmmaaaa"
+ /* 3 */ "aammmmmmmmmbbba"
+ /* 4 */ "mmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmm"
+ /* 12 */ "aammmmmmmmmccca"
+ /* 13 */ "aammmmmmmmmaaaa"
+ /* 14 */ "aammmmmmmmmaaaa"
+ /* 15 */ "mmmmmmmmmmmaaam"
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmdaaae"
+ /* 1 */ "aammmmmmmmdaaaa"
+ /* 2 */ "aammmmmmmmdaaaa"
+ /* 3 */ "aammmmmmmmdaaaa"
+ /* 4 */ "mmmmmmmmmmdaaae"
+ /* 5 */ "mmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmdaaae"
+ /* 12 */ "aammmmmmmmdaaaa"
+ /* 13 */ "aammmmmmmmdaaaa"
+ /* 14 */ "aammmmmmmmdaaaa"
+ /* 15 */ "mmmmmmmmmmdaaae"
+
+ // Level 6
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmaaaaa"
+ /* 1 */ "aammmmmmmmaaaaa"
+ /* 2 */ "aammmmmmmmaaaaa"
+ /* 3 */ "aammmmmmmmaaaaa"
+ /* 4 */ "mmmmmmmmmmaaaaa"
+ /* 5 */ "mmmmmmmmmmdaaae"
+ /* 6 */ "mmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmdaaae"
+ /* 11 */ "mmmmmmmmmmaaaaa"
+ /* 12 */ "aammmmmmmmaaaaa"
+ /* 13 */ "aammmmmmmmaaaaa"
+ /* 14 */ "aammmmmmmmaaaaa"
+ /* 15 */ "mmmmmmmmmmaaaaa"
+
+ // Level 7
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmma...a"
+ /* 1 */ "aammmmmmmma...a"
+ /* 2 */ "aammmmmmmma...a"
+ /* 3 */ "aammmmmmmma...a"
+ /* 4 */ "mmmmmmmmmmafffa"
+ /* 5 */ "mmmmmmmmmaaaaaa"
+ /* 6 */ "mmmmmmmmmaaaaae"
+ /* 7 */ "mmmmmmmmmaaaaae"
+ /* 8 */ "mmmmmmmmmaaaaae"
+ /* 9 */ "mmmmmmmmmaaaaae"
+ /* 10 */ "mmmmmmmmmaaaaaa"
+ /* 11 */ "mmmmmmmmmmaggga"
+ /* 12 */ "aammmmmmmma...a"
+ /* 13 */ "aammmmmmmma...a"
+ /* 14 */ "aammmmmmmma...a"
+ /* 15 */ "mmmmmmmmmma...a"
+
+ // Level 8
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmm...m"
+ /* 1 */ "aammmmmmmma...a"
+ /* 2 */ "aammmmmmmma...a"
+ /* 3 */ "aammmmmmmma...a"
+ /* 4 */ "mmmmmmmmmma...a"
+ /* 5 */ "mmmmmmmmmaafffa"
+ /* 6 */ "mmmmmmmmaaaaaaa"
+ /* 7 */ "mmmmmmmmaaaaaaa"
+ /* 8 */ "mmmmmmmmaaaaaaa"
+ /* 9 */ "mmmmmmmmaaaaaaa"
+ /* 10 */ "mmmmmmmmmaaggga"
+ /* 11 */ "mmmmmmmmmma...a"
+ /* 12 */ "aammmmmmmma...a"
+ /* 13 */ "aammmmmmmma...a"
+ /* 14 */ "aammmmmmmma...a"
+ /* 15 */ "mmmmmmmmmmm...m"
+
+ // Level 9
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmm...m"
+ /* 1 */ "aaemmmmmmma...a"
+ /* 2 */ "aaemmmmmmma...a"
+ /* 3 */ "aaemmmmmmma...a"
+ /* 4 */ "mmmmmmmmmma...a"
+ /* 5 */ "mmmmmmmmmaa...a"
+ /* 6 */ "mmmmaaaaah....a"
+ /* 7 */ "mmmmaaaaah....a"
+ /* 8 */ "mmmmaaaaah....a"
+ /* 9 */ "mmmmaaaaah....a"
+ /* 10 */ "mmmmmmmmmaa...a"
+ /* 11 */ "mmmmmmmmmma...a"
+ /* 12 */ "aaemmmmmmma...a"
+ /* 13 */ "aaemmmmmmma...a"
+ /* 14 */ "aaemmmmmmma...a"
+ /* 15 */ "mmmmmmmmmmm...m"
+
+ // Level 10
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmmmmmm"
+ /* 1 */ "aaaeimmmmmammma"
+ /* 2 */ "aaaeimmmmmammma"
+ /* 3 */ "aaaeimmmmma...a"
+ /* 4 */ "mmmmmmmmmmm...m"
+ /* 5 */ "mmmmaaaaaam...m"
+ /* 6 */ "mmmmaaaah.....m"
+ /* 7 */ "mmmmaaaah.....m"
+ /* 8 */ "mmmmaaaah.....m"
+ /* 9 */ "mmmmaaaah.....m"
+ /* 10 */ "mmmmaaaaaam...m"
+ /* 11 */ "mmmmmmmmmmm...m"
+ /* 12 */ "aaaeimmmmma...a"
+ /* 13 */ "aaaeimmmmmammma"
+ /* 14 */ "aaaeimmmmmammma"
+ /* 15 */ "mmmmmmmmmmmmmmm"
+
+ // Level 11
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "ccccccccccccccc"
+ /* 1 */ "aaaaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaaaa"
+ /* 4 */ "bbbbaaaaabbbbbb"
+ /* 5 */ "mmmmagggamm...m"
+ /* 6 */ "mmmma.........m"
+ /* 7 */ "mmmma.........m"
+ /* 8 */ "mmmma.........m"
+ /* 9 */ "mmmma.........m"
+ /* 10 */ "mmmmafffamm...m"
+ /* 11 */ "ccccaaaahcccccc"
+ /* 12 */ "aaaaaaaaaaaaaaa"
+ /* 13 */ "aaaaaaaaaaaaaaa"
+ /* 14 */ "aaaaaaaaaaaaaaa"
+ /* 15 */ "bbbbbbbbbbbbbbb"
+
+ // Level 12
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "aaaaaaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaaaa"
+ /* 4 */ "aaaaagggaaaaaaa"
+ /* 5 */ "mmmma...ammmmmm"
+ /* 6 */ "mmmma.........m"
+ /* 7 */ "mmmmm.........m"
+ /* 8 */ "mmmmm.........m"
+ /* 9 */ "mmmma.........m"
+ /* 10 */ "mmmma...ammmmmm"
+ /* 11 */ "aaaaafffaaaaaaa"
+ /* 12 */ "aaaaaaaaaaaaaaa"
+ /* 13 */ "aaaaaaaaaaaaaaa"
+ /* 14 */ "aaaaaaaaaaaaaaa"
+ /* 15 */ "aaaaaaaaaaaaaaa"
+
+ // Level 13
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "aaaaaaaaaaaaaaa"
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "aaaaa...aaaaaaa"
+ /* 5 */ "mmmma...ammmmmm"
+ /* 6 */ "mmmmm.....mmmmm"
+ /* 7 */ "mmmmm.....mmmmm"
+ /* 8 */ "mmmmm.....mmmmm"
+ /* 9 */ "mmmmm.....mmmmm"
+ /* 10 */ "mmmma...ammmmmm"
+ /* 11 */ "aaaaa...aaaaaaa"
+ /* 12 */ "..............."
+ /* 13 */ "..............."
+ /* 14 */ "..............."
+ /* 15 */ "aaaaaaaaaaaaaaa"
+
+ // Level 14
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmmmmmm"
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "mmmmm...mmmmmmm"
+ /* 5 */ "mmmmm...mmmmmmm"
+ /* 6 */ "mmmmm...mmmmmmm"
+ /* 7 */ "mmmmm...mmmmmmm"
+ /* 8 */ "mmmmm...mmmmmmm"
+ /* 9 */ "mmmmm...mmmmmmm"
+ /* 10 */ "mmmmm...mmmmmmm"
+ /* 11 */ "mmmmm...mmmmmmm"
+ /* 12 */ "..............."
+ /* 13 */ "..............."
+ /* 14 */ "..............."
+ /* 15 */ "mmmmmmmmmmmmmmm"
+
+ // Level 15
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmmmmmmmmmm"
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "mmmmm...mmmmmmm"
+ /* 5 */ "mmmmm...mmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmm...mmmmmmm"
+ /* 11 */ "mmmmm...mmmmmmm"
+ /* 12 */ "..............."
+ /* 13 */ "..............."
+ /* 14 */ "..............."
+ /* 15 */ "mmmmmmmmmmmmmmm",
+
+ // Connectors:
+ "0: 0, 13, 13: 4\n" /* Type 0, direction X- */
+ "0: 14, 13, 13: 5\n" /* Type 0, direction X+ */
+ "0: 0, 13, 2: 4\n" /* Type 0, direction X- */
+ "0: 14, 13, 2: 5\n" /* Type 0, direction X+ */
+ "0: 12, 7, 15: 3\n" /* Type 0, direction Z+ */
+ "0: 12, 7, 0: 2\n" /* Type 0, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 20,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // BridgeDoubleStairs
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
// BridgeFunnelDown:
// The data has been exported from the gallery Nether, area index 0, ID 2, created by Aloe_vera
{
@@ -1604,7 +2013,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
5,
@@ -1614,11 +2023,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BridgeFunnelDown
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BridgeLevelCrossing:
// The data has been exported from the gallery Nether, area index 61, ID 321, created by Aloe_vera
{
@@ -1933,7 +2345,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
20,
@@ -1943,11 +2355,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BridgeLevelCrossing
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BridgeSegment:
// The data has been exported from the gallery Nether, area index 16, ID 158, created by Aloe_vera
{
@@ -2052,7 +2467,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
500,
@@ -2062,11 +2477,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
1000,
+
+ // MoveToGround:
+ false,
}, // BridgeSegment
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// BridgeTee:
// The data has been exported from the gallery Nether, area index 39, ID 290, created by STR_Warrior
{
@@ -2212,7 +2630,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
10,
@@ -2222,11 +2640,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // BridgeTee
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// Corridor11:
// The data has been exported from the gallery Nether, area index 36, ID 287, created by Aloe_vera
{
@@ -2302,7 +2723,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 10, 1, 2: 5\n" /* Type 1, direction X+ */
- "1: 0, 1, 2: 4\n" /* Type 1, direction X- */,
+ "1: 0, 1, 2: 4\n" /* Type 1, direction X- */
+ "-1: 10, 1, 2: 5\n" /* Type -1, direction X+ */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -2311,7 +2734,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
300,
@@ -2321,11 +2744,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // Corridor11
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// Corridor13:
// The data has been exported from the gallery Nether, area index 35, ID 286, created by Aloe_vera
{
@@ -2401,7 +2827,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 12, 1, 2: 5\n" /* Type 1, direction X+ */
- "1: 0, 1, 2: 4\n" /* Type 1, direction X- */,
+ "1: 0, 1, 2: 4\n" /* Type 1, direction X- */
+ "-1: 12, 1, 2: 5\n" /* Type -1, direction X+ */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -2410,7 +2838,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
300,
@@ -2420,11 +2848,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // Corridor13
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// Corridor5:
// The data has been exported from the gallery Nether, area index 65, ID 330, created by xoft
{
@@ -2494,7 +2925,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 4, 1, 2: 5\n" /* Type 1, direction X+ */
- "1: 0, 1, 2: 4\n" /* Type 1, direction X- */,
+ "1: 0, 1, 2: 4\n" /* Type 1, direction X- */
+ "-1: 4, 1, 2: 5\n" /* Type -1, direction X+ */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -2503,7 +2936,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
500,
@@ -2513,11 +2946,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
500,
+
+ // MoveToGround:
+ false,
}, // Corridor5
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// CorridorCorner5:
// The data has been exported from the gallery Nether, area index 10, ID 40, created by xoft
{
@@ -2547,12 +2983,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
/* 2 */ "aaaaaaaaaaa"
/* 3 */ "aaaaaaaaaaa"
/* 4 */ "aaaaaaaaaaa"
- /* 5 */ "aaaaa......"
- /* 6 */ "aaaaa......"
- /* 7 */ "aaaaa......"
- /* 8 */ "aaaaa......"
- /* 9 */ "aaaaa......"
- /* 10 */ "aaaaa......"
+ /* 5 */ "aaaaammmmmm"
+ /* 6 */ "aaaaammmmmm"
+ /* 7 */ "aaaaammmmmm"
+ /* 8 */ "aaaaammmmmm"
+ /* 9 */ "aaaaammmmmm"
+ /* 10 */ "aaaaammmmmm"
// Level 1
/* z\x* 1 */
@@ -2562,12 +2998,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
/* 2 */ "a.........."
/* 3 */ "a.........."
/* 4 */ "a...aaaaaaa"
- /* 5 */ "a...a......"
- /* 6 */ "a...a......"
- /* 7 */ "a...a......"
- /* 8 */ "a...a......"
- /* 9 */ "a...a......"
- /* 10 */ "a...a......"
+ /* 5 */ "a...ammmmmm"
+ /* 6 */ "a...ammmmmm"
+ /* 7 */ "a...ammmmmm"
+ /* 8 */ "a...ammmmmm"
+ /* 9 */ "a...ammmmmm"
+ /* 10 */ "a...ammmmmm"
// Level 2
/* z\x* 1 */
@@ -2577,12 +3013,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
/* 2 */ "a.........."
/* 3 */ "b.........."
/* 4 */ "a...abababa"
- /* 5 */ "b...b......"
- /* 6 */ "a...a......"
- /* 7 */ "b...b......"
- /* 8 */ "a...a......"
- /* 9 */ "b...b......"
- /* 10 */ "a...a......"
+ /* 5 */ "b...bmmmmmm"
+ /* 6 */ "a...ammmmmm"
+ /* 7 */ "b...bmmmmmm"
+ /* 8 */ "a...ammmmmm"
+ /* 9 */ "b...bmmmmmm"
+ /* 10 */ "a...ammmmmm"
// Level 3
/* z\x* 1 */
@@ -2592,12 +3028,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
/* 2 */ "a.........."
/* 3 */ "b.........."
/* 4 */ "a...abababa"
- /* 5 */ "b...b......"
- /* 6 */ "a...a......"
- /* 7 */ "b...b......"
- /* 8 */ "a...a......"
- /* 9 */ "b...b......"
- /* 10 */ "a...a......"
+ /* 5 */ "b...bmmmmmm"
+ /* 6 */ "a...ammmmmm"
+ /* 7 */ "b...bmmmmmm"
+ /* 8 */ "a...ammmmmm"
+ /* 9 */ "b...bmmmmmm"
+ /* 10 */ "a...ammmmmm"
// Level 4
/* z\x* 1 */
@@ -2607,12 +3043,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
/* 2 */ "a.........."
/* 3 */ "b.........."
/* 4 */ "a...abababa"
- /* 5 */ "b...b......"
- /* 6 */ "a...a......"
- /* 7 */ "b...b......"
- /* 8 */ "a...a......"
- /* 9 */ "b...b......"
- /* 10 */ "a...a......"
+ /* 5 */ "b...bmmmmmm"
+ /* 6 */ "a...ammmmmm"
+ /* 7 */ "b...bmmmmmm"
+ /* 8 */ "a...ammmmmm"
+ /* 9 */ "b...bmmmmmm"
+ /* 10 */ "a...ammmmmm"
// Level 5
/* z\x* 1 */
@@ -2622,16 +3058,18 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
/* 2 */ "daaaaaaaaaa"
/* 3 */ "daaaaaaaaaa"
/* 4 */ "daaaeeeeeee"
- /* 5 */ "daaaf......"
- /* 6 */ "daaaf......"
- /* 7 */ "daaaf......"
- /* 8 */ "daaaf......"
- /* 9 */ "daaaf......"
- /* 10 */ "daaaf......",
+ /* 5 */ "daaafmmmmmm"
+ /* 6 */ "daaafmmmmmm"
+ /* 7 */ "daaafmmmmmm"
+ /* 8 */ "daaafmmmmmm"
+ /* 9 */ "daaafmmmmmm"
+ /* 10 */ "daaafmmmmmm",
// Connectors:
"1: 2, 1, 10: 3\n" /* Type 1, direction Z+ */
- "1: 10, 1, 2: 5\n" /* Type 1, direction X+ */,
+ "1: 10, 1, 2: 5\n" /* Type 1, direction X+ */
+ "-1: 2, 1, 10: 3\n" /* Type -1, direction Z+ */
+ "-1: 10, 1, 2: 5\n" /* Type -1, direction X+ */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -2640,7 +3078,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -2650,11 +3088,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // CorridorCorner5
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// CorridorCornerChest5:
// The data has been exported from the gallery Nether, area index 42, ID 293, created by STR_Warrior
{
@@ -2769,7 +3210,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 10, 1, 2: 5\n" /* Type 1, direction X+ */
- "1: 2, 1, 10: 3\n" /* Type 1, direction Z+ */,
+ "1: 2, 1, 10: 3\n" /* Type 1, direction Z+ */
+ "-1: 2, 1, 10: 3\n" /* Type -1, direction Z+ */
+ "-1: 10, 1, 2: 5\n" /* Type -1, direction X+ */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -2778,7 +3221,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -2788,11 +3231,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // CorridorCornerChest5
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// CorridorCrossing:
// The data has been exported from the gallery Nether, area index 63, ID 328, created by xoft
{
@@ -2890,7 +3336,11 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
"1: 8, 1, 4: 5\n" /* Type 1, direction X+ */
"1: 4, 1, 0: 2\n" /* Type 1, direction Z- */
"1: 4, 1, 8: 3\n" /* Type 1, direction Z+ */
- "1: 0, 1, 4: 4\n" /* Type 1, direction X- */,
+ "1: 0, 1, 4: 4\n" /* Type 1, direction X- */
+ "-1: 8, 1, 4: 5\n" /* Type -1, direction X+ */
+ "-1: 4, 1, 8: 3\n" /* Type -1, direction Z+ */
+ "-1: 0, 1, 4: 4\n" /* Type -1, direction X- */
+ "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -2899,7 +3349,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -2909,11 +3359,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
-50,
+
+ // MoveToGround:
+ false,
}, // CorridorCrossing
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// CorridorStairs:
// The data has been exported from the gallery Nether, area index 12, ID 42, created by xoft
{
@@ -3040,7 +3493,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 0, 1, 2: 4\n" /* Type 1, direction X- */
- "1: 8, 8, 2: 5\n" /* Type 1, direction X+ */,
+ "1: 8, 8, 2: 5\n" /* Type 1, direction X+ */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */
+ "-1: 8, 8, 2: 5\n" /* Type -1, direction X+ */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -3049,7 +3504,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
1000,
@@ -3059,11 +3514,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // CorridorStairs
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// DarkCorridor:
// The data has been exported from the gallery Nether, area index 3, ID 30, created by STR_Warrior
{
@@ -3139,7 +3597,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 0, 1, 2: 4\n" /* Type 1, direction X- */
- "1: 13, 1, 2: 5\n" /* Type 1, direction X+ */,
+ "1: 13, 1, 2: 5\n" /* Type 1, direction X+ */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */
+ "-1: 13, 1, 2: 5\n" /* Type -1, direction X+ */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -3148,7 +3608,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -3158,11 +3618,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // DarkCorridor
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// LavaStaircase:
// The data has been exported from the gallery Nether, area index 28, ID 278, created by Aloe_vera
{
@@ -3393,7 +3856,10 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 0, 6, 7: 4\n" /* Type 1, direction X- */
"1: 9, 1, 14: 3\n" /* Type 1, direction Z+ */
- "1: 9, 1, 0: 2\n" /* Type 1, direction Z- */,
+ "1: 9, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 0, 6, 7: 4\n" /* Type -1, direction X- */
+ "-1: 9, 1, 14: 3\n" /* Type -1, direction Z+ */
+ "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -3402,7 +3868,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
10,
@@ -3412,11 +3878,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // LavaStaircase
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// LavaStaircaseBig:
// The data has been exported from the gallery Nether, area index 31, ID 282, created by STR_Warrior
{
@@ -3722,7 +4191,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 11, 1, 7: 5\n" /* Type 1, direction X+ */
- "1: 0, 9, 7: 4\n" /* Type 1, direction X- */,
+ "1: 0, 9, 7: 4\n" /* Type 1, direction X- */
+ "-1: 11, 1, 7: 5\n" /* Type -1, direction X+ */
+ "-1: 0, 9, 7: 4\n" /* Type -1, direction X- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -3731,7 +4202,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
10,
@@ -3741,11 +4212,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
-1000,
+
+ // MoveToGround:
+ false,
}, // LavaStaircaseBig
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// LavaStairsBridge:
// The data has been exported from the gallery Nether, area index 30, ID 281, created by STR_Warrior
{
@@ -4000,7 +4474,12 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
/* 14 */ "abbaabbaabbaabba",
// Connectors:
- "",
+ "1: 0, 6, 7: 4\n" /* Type 1, direction X- */
+ "-1: 0, 6, 7: 4\n" /* Type -1, direction X- */
+ "1: 9, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */
+ "1: 9, 1, 14: 3\n" /* Type 1, direction Z+ */
+ "-1: 9, 1, 14: 3\n" /* Type -1, direction Z+ */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -4009,7 +4488,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
10,
@@ -4019,11 +4498,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // LavaStairsBridge
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// MidStaircase:
// The data has been exported from the gallery Nether, area index 23, ID 165, created by Aloe_vera
{
@@ -4186,7 +4668,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 12, 1, 6: 5\n" /* Type 1, direction X+ */
- "1: 0, 1, 6: 4\n" /* Type 1, direction X- */,
+ "1: 0, 1, 6: 4\n" /* Type 1, direction X- */
+ "-1: 12, 1, 6: 5\n" /* Type -1, direction X+ */
+ "-1: 0, 1, 6: 4\n" /* Type -1, direction X- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -4195,7 +4679,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -4205,11 +4689,347 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
-1000,
+
+ // MoveToGround:
+ false,
}, // MidStaircase
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
+ // SlabbedBridgeStairs:
+ // The data has been exported from the gallery Nether, area index 116, ID 811, created by Aloe_vera
+ {
+ // Size:
+ 16, 14, 16, // SizeX = 16, SizeY = 14, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 13, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a:112: 0\n" /* netherbrick */
+ "b:114: 5\n" /* netherbrickstairs */
+ "c:114: 4\n" /* netherbrickstairs */
+ "d: 44:14\n" /* step */
+ "e:114: 6\n" /* netherbrickstairs */
+ "f:114: 7\n" /* netherbrickstairs */
+ "g: 44: 6\n" /* step */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "aammmmmmmmmmmmaa"
+ /* 2 */ "aammmmmmmmmmmmaa"
+ /* 3 */ "aammmmmmmmmmmmaa"
+ /* 4 */ "mmmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmmm"
+ /* 12 */ "maaammmmmmmmmmmm"
+ /* 13 */ "maaammmmmmmmmmmm"
+ /* 14 */ "maaammmmmmmmaaam"
+ /* 15 */ "mmmmmmmmmmmmaaam"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "aabmmmmmmmmmmcaa"
+ /* 2 */ "aabmmmmmmmmmmcaa"
+ /* 3 */ "aabmmmmmmmmmmcaa"
+ /* 4 */ "mmmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmmm"
+ /* 12 */ "maaammmmmmmmmmmm"
+ /* 13 */ "maaammmmmmmmmmmm"
+ /* 14 */ "maaammmmmmmmaaam"
+ /* 15 */ "mmmmmmmmmmmmaaam"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "aaabdmmmmmmdcaaa"
+ /* 2 */ "aaabdmmmmmmdcaaa"
+ /* 3 */ "aaabdmmmmmmdcaaa"
+ /* 4 */ "mmmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmmm"
+ /* 12 */ "maaammmmmmmmmmmm"
+ /* 13 */ "maaammmmmmmmmmmm"
+ /* 14 */ "maaammmmmmmmaaam"
+ /* 15 */ "mmmmmmmmmmmmaaam"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "eeeeeeeeeeeeeeee"
+ /* 1 */ "aaaaaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaaaaa"
+ /* 4 */ "ffffffffffffffff"
+ /* 5 */ "mmmmmmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmmm"
+ /* 12 */ "maaammmmmmmmmmmm"
+ /* 13 */ "maaammmmmmmmmmmm"
+ /* 14 */ "maaammmmmmmmaaam"
+ /* 15 */ "mmmmmmmmmmmmaaam"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aaaaaaaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaaaaaaaa"
+ /* 5 */ "faaabmmmmmmmmmmm"
+ /* 6 */ "caaabmmmmmmmmmmm"
+ /* 7 */ "caaabmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmmm"
+ /* 12 */ "maaammmmmmmmmmmm"
+ /* 13 */ "maaammmmmmmmmmmm"
+ /* 14 */ "maaammmmmmmmaaam"
+ /* 15 */ "mmmmmmmmmmmmaaam"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aaaaaaaaaaaaaaaa"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "................"
+ /* 4 */ "a...aaaaaaaaaaaa"
+ /* 5 */ "agggammmmmmmmmmm"
+ /* 6 */ "aaaaammmmmmmmmmm"
+ /* 7 */ "aaaaammmmmmmmmmm"
+ /* 8 */ "caaabmmmmmmmmmmm"
+ /* 9 */ "caaabmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmmm"
+ /* 12 */ "maaammmmmmmmmmmm"
+ /* 13 */ "maaammmmmmmmmmmm"
+ /* 14 */ "maaammmmmmmmaaam"
+ /* 15 */ "mmmmmmmmmmmmaaam"
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmaaam"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "................"
+ /* 4 */ "m...mmmmmmmmaaam"
+ /* 5 */ "a...ammmmmmmmmmm"
+ /* 6 */ "a...ammmmmmmmmmm"
+ /* 7 */ "agggammmmmmmmmmm"
+ /* 8 */ "aaaaammmmmmmmmmm"
+ /* 9 */ "aaaaammmmmmmmmmm"
+ /* 10 */ "caaabmmmmmmmmmmm"
+ /* 11 */ "caaabmmmmmmmmmmm"
+ /* 12 */ "maaabmmmmmmmmmmm"
+ /* 13 */ "maaabmmmmmmmmmmm"
+ /* 14 */ "maaafmmmmmmmaaam"
+ /* 15 */ "mmmmmmmmmmmmaaam"
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmaaam"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "................"
+ /* 4 */ "m...mmmmmmmmaaam"
+ /* 5 */ "m...mmmmmmmmmmmm"
+ /* 6 */ "m...mmmmmmmmmmmm"
+ /* 7 */ "a...ammmmmmmmmmm"
+ /* 8 */ "a...ammmmmmmmmmm"
+ /* 9 */ "agggammmmmmmmmmm"
+ /* 10 */ "aaaaammmmmmmmmmm"
+ /* 11 */ "aaaaaeemmmmmmmmm"
+ /* 12 */ "caaaaaammmmmmmmm"
+ /* 13 */ "caaaaaammmmmmmmm"
+ /* 14 */ "caaaaaammmmmaaam"
+ /* 15 */ "fffffffmmmmmaaam"
+
+ // Level 8
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmaaam"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmmmm"
+ /* 4 */ "m...mmmmmmmmaaam"
+ /* 5 */ "m...mmmmmmmmmmmm"
+ /* 6 */ "m...mmmmmmmmmmmm"
+ /* 7 */ "m...mmmmmmmmmmmm"
+ /* 8 */ "m...mmmmmmmmmmmm"
+ /* 9 */ "a...ammmmmmmmmmm"
+ /* 10 */ "a...ammmmmmmmmmm"
+ /* 11 */ "a...aaaeemmmmmmm"
+ /* 12 */ "a....gaaammmmmmm"
+ /* 13 */ "a....gaaammmmmmm"
+ /* 14 */ "a....gaaammmaaam"
+ /* 15 */ "aaaaaaaffmmmaaam"
+
+ // Level 9
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmcaaab"
+ /* 1 */ "mmmmmmmmmmmcaaab"
+ /* 2 */ "mmmmmmmmmmmcaaab"
+ /* 3 */ "mmmmmmmmmmmcaaab"
+ /* 4 */ "mmmmmmmmmmmcaaab"
+ /* 5 */ "mmmmmmmmmmmcaaab"
+ /* 6 */ "m...mmmmmmmcaaab"
+ /* 7 */ "m...mmmmmmmcaaab"
+ /* 8 */ "m...mmmmmmmcaaab"
+ /* 9 */ "m...mmmmmmmcaaab"
+ /* 10 */ "m...mmmmmmmcaaab"
+ /* 11 */ "m...maaaaeecaaab"
+ /* 12 */ "m......gaaaaaaab"
+ /* 13 */ "m......gaaaaaaab"
+ /* 14 */ "m......gaaaaaaab"
+ /* 15 */ "mmmmmaaaafffaaab"
+
+ // Level 10
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmaaaaa"
+ /* 1 */ "mmmmmmmmmmmaaaaa"
+ /* 2 */ "mmmmmmmmmmmaaaaa"
+ /* 3 */ "mmmmmmmmmmmaaaaa"
+ /* 4 */ "mmmmmmmmmmmaaaaa"
+ /* 5 */ "mmmmmmmmmmmaaaaa"
+ /* 6 */ "mmmmmmmmmmmaaaaa"
+ /* 7 */ "mmmmmmmmmmmaaaaa"
+ /* 8 */ "m...mmmmmmmaaaaa"
+ /* 9 */ "m...mmmmmmmaaaaa"
+ /* 10 */ "m...mmmmmmmaaaaa"
+ /* 11 */ "m...mmmaaaaaaaaa"
+ /* 12 */ "m........gaaaaaa"
+ /* 13 */ "m........gaaaaaa"
+ /* 14 */ "m........gaaaaaa"
+ /* 15 */ "mmmmmmmaaaaaaaaa"
+
+ // Level 11
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmma...a"
+ /* 1 */ "mmmmmmmmmmma...a"
+ /* 2 */ "mmmmmmmmmmma...a"
+ /* 3 */ "mmmmmmmmmmma...a"
+ /* 4 */ "mmmmmmmmmmma...a"
+ /* 5 */ "mmmmmmmmmmma...a"
+ /* 6 */ "mmmmmmmmmmma...a"
+ /* 7 */ "mmmmmmmmmmma...a"
+ /* 8 */ "mmmmmmmmmmma...a"
+ /* 9 */ "mmmmmmmmmmma...a"
+ /* 10 */ "mmmmmmmmmmma...a"
+ /* 11 */ "mmmmmmmmmaaa...a"
+ /* 12 */ "mmmm...........a"
+ /* 13 */ "mmmm...........a"
+ /* 14 */ "mmmm...........a"
+ /* 15 */ "mmmmmmmmmaaa...a"
+
+ // Level 12
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmm...m"
+ /* 1 */ "mmmmmmmmmmmm...m"
+ /* 2 */ "mmmmmmmmmmmm...m"
+ /* 3 */ "mmmmmmmmmmmm...m"
+ /* 4 */ "mmmmmmmmmmmm...m"
+ /* 5 */ "mmmmmmmmmmmm...m"
+ /* 6 */ "mmmmmmmmmmmm...m"
+ /* 7 */ "mmmmmmmmmmmm...m"
+ /* 8 */ "mmmmmmmmmmmm...m"
+ /* 9 */ "mmmmmmmmmmmm...m"
+ /* 10 */ "mmmmmmmmmmmm...m"
+ /* 11 */ "mmmmmmmmmmmm...m"
+ /* 12 */ "mmmmmm.........m"
+ /* 13 */ "mmmmmm.........m"
+ /* 14 */ "mmmmmm.........m"
+ /* 15 */ "mmmmmmmmmmmm...m"
+
+ // Level 13
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmm...m"
+ /* 1 */ "mmmmmmmmmmmm...m"
+ /* 2 */ "mmmmmmmmmmmm...m"
+ /* 3 */ "mmmmmmmmmmmm...m"
+ /* 4 */ "mmmmmmmmmmmm...m"
+ /* 5 */ "mmmmmmmmmmmm...m"
+ /* 6 */ "mmmmmmmmmmmm...m"
+ /* 7 */ "mmmmmmmmmmmm...m"
+ /* 8 */ "mmmmmmmmmmmm...m"
+ /* 9 */ "mmmmmmmmmmmm...m"
+ /* 10 */ "mmmmmmmmmmmm...m"
+ /* 11 */ "mmmmmmmmmmmm...m"
+ /* 12 */ "mmmmmmmm.......m"
+ /* 13 */ "mmmmmmmm.......m"
+ /* 14 */ "mmmmmmmm.......m"
+ /* 15 */ "mmmmmmmmmmmm...m",
+
+ // Connectors:
+ "0: 13, 11, 0: 2\n" /* Type 0, direction Z- */
+ "0: 13, 11, 15: 3\n" /* Type 0, direction Z+ */
+ "0: 0, 5, 2: 4\n" /* Type 0, direction X- */
+ "0: 15, 5, 2: 5\n" /* Type 0, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 20,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // SlabbedBridgeStairs
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
// StairsToOpen1:
// The data has been exported from the gallery Nether, area index 27, ID 277, created by Aloe_vera
{
@@ -4338,7 +5158,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -4348,11 +5168,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // StairsToOpen1
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// StairsToOpen2:
// The data has been exported from the gallery Nether, area index 8, ID 35, created by xoft
{
@@ -4481,7 +5304,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -4491,11 +5314,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // StairsToOpen2
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// Tee2x4:
// The data has been exported from the gallery Nether, area index 40, ID 291, created by Aloe_vera
{
@@ -4586,7 +5412,10 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 0, 1, 4: 4\n" /* Type 1, direction X- */
"1: 6, 1, 0: 2\n" /* Type 1, direction Z- */
- "1: 12, 1, 4: 5\n" /* Type 1, direction X+ */,
+ "1: 12, 1, 4: 5\n" /* Type 1, direction X+ */
+ "-1: 0, 1, 4: 4\n" /* Type -1, direction X- */
+ "-1: 12, 1, 4: 5\n" /* Type -1, direction X+ */
+ "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -4595,7 +5424,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -4605,11 +5434,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // Tee2x4
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// Tee4x4:
// The data has been exported from the gallery Nether, area index 41, ID 292, created by Aloe_vera
{
@@ -4712,7 +5544,10 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 0, 1, 6: 4\n" /* Type 1, direction X- */
"1: 6, 1, 0: 2\n" /* Type 1, direction Z- */
- "1: 12, 1, 6: 5\n" /* Type 1, direction X+ */,
+ "1: 12, 1, 6: 5\n" /* Type 1, direction X+ */
+ "-1: 0, 1, 6: 4\n" /* Type -1, direction X- */
+ "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */
+ "-1: 12, 1, 6: 5\n" /* Type -1, direction X+ */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -4721,7 +5556,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -4731,11 +5566,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // Tee4x4
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// TinyCorridorCorner:
// The data has been exported from the gallery Nether, area index 66, ID 331, created by xoft
{
@@ -4806,7 +5644,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 2, 1, 4: 3\n" /* Type 1, direction Z+ */
- "1: 0, 1, 2: 4\n" /* Type 1, direction X- */,
+ "1: 0, 1, 2: 4\n" /* Type 1, direction X- */
+ "-1: 2, 1, 4: 3\n" /* Type -1, direction Z+ */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -4815,7 +5655,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -4825,11 +5665,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
-50,
+
+ // MoveToGround:
+ false,
}, // TinyCorridorCorner
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// TinyCorridorCornerChest:
// The data has been exported from the gallery Nether, area index 67, ID 332, created by Aloe_vera
{
@@ -4901,7 +5744,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// Connectors:
"1: 2, 1, 4: 3\n" /* Type 1, direction Z+ */
- "1: 0, 1, 2: 4\n" /* Type 1, direction X- */,
+ "1: 0, 1, 2: 4\n" /* Type 1, direction X- */
+ "-1: 2, 1, 4: 3\n" /* Type -1, direction Z+ */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -4910,7 +5755,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -4920,11 +5765,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // TinyCorridorCornerChest
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// TinyCorridorCrossing:
// The data has been exported from the gallery Nether, area index 64, ID 329, created by xoft
{
@@ -4996,7 +5844,11 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
"1: 4, 1, 2: 5\n" /* Type 1, direction X+ */
"1: 2, 1, 4: 3\n" /* Type 1, direction Z+ */
"1: 0, 1, 2: 4\n" /* Type 1, direction X- */
- "1: 2, 1, 0: 2\n" /* Type 1, direction Z- */,
+ "1: 2, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 4, 1, 2: 5\n" /* Type -1, direction X+ */
+ "-1: 2, 1, 4: 3\n" /* Type -1, direction Z+ */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */
+ "-1: 2, 1, 0: 2\n" /* Type -1, direction Z- */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -5005,7 +5857,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -5015,11 +5867,14 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
-50,
+
+ // MoveToGround:
+ false,
}, // TinyCorridorCrossing
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// Turret:
// The data has been exported from the gallery Nether, area index 7, ID 34, created by xoft
{
@@ -5120,7 +5975,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -5130,6 +5985,9 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
// AddWeightIfSame:
-99,
+
+ // MoveToGround:
+ false,
}, // Turret
}; // g_NetherFortPrefabs
@@ -5140,7 +5998,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] =
const cPrefab::sDef g_NetherFortStartingPrefabs[] =
{
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
// CentralRoom:
// The data has been exported from the gallery Nether, area index 22, ID 164, created by Aloe_vera
{
@@ -5314,7 +6172,8 @@ const cPrefab::sDef g_NetherFortStartingPrefabs[] =
// Connectors:
"0: 6, 1, 0: 2\n" /* Type 0, direction Z- */
- "1: 6, 1, 12: 3\n" /* Type 1, direction Z+ */,
+ "1: 6, 1, 12: 3\n" /* Type 1, direction Z+ */
+ "-1: 6, 1, 12: 3\n" /* Type -1, direction Z+ */,
// AllowedRotations:
7, /* 1, 2, 3 CCW rotation allowed */
@@ -5323,7 +6182,7 @@ const cPrefab::sDef g_NetherFortStartingPrefabs[] =
cBlockArea::msSpongePrint,
// ShouldExtendFloor:
- false,
+ true,
// DefaultWeight:
100,
@@ -5333,6 +6192,9 @@ const cPrefab::sDef g_NetherFortStartingPrefabs[] =
// AddWeightIfSame:
0,
+
+ // MoveToGround:
+ false,
}, // CentralRoom
};
diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp
new file mode 100644
index 000000000..4613f76e2
--- /dev/null
+++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp
@@ -0,0 +1,6118 @@
+
+// PlainsVillagePrefabs.cpp
+
+// Defines the prefabs in the group PlainsVillage
+
+// NOTE: This file has been generated automatically by GalExport!
+// Any manual changes will be overwritten by the next automatic export!
+
+#include "Globals.h"
+#include "PlainsVillagePrefabs.h"
+
+
+
+
+
+const cPrefab::sDef g_PlainsVillagePrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // BigPlantBed:
+ // The data has been exported from the gallery Plains, area index 26, ID 70, created by Taugrammaton
+ {
+ // Size:
+ 13, 8, 12, // SizeX = 13, SizeY = 8, SizeZ = 12
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 12, 7, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 5: 0\n" /* wood */
+ "c: 13: 0\n" /* gravel */
+ "d: 17: 0\n" /* tree */
+ "e: 60: 7\n" /* tilleddirt */
+ "f: 8: 0\n" /* water */
+ "g: 85: 0\n" /* fence */
+ "h: 59: 7\n" /* crops */
+ "i: 50: 5\n" /* torch */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "aaaaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaaaaa"
+ /* 7 */ "aaaaaaaaaaaaa"
+ /* 8 */ "aaaaaaaaaaaaa"
+ /* 9 */ "aaaaaaaaaaaaa"
+ /* 10 */ "aaaaaaaaaaaaa"
+ /* 11 */ "aaaaaaaaaaaaa"
+
+ // Level 1
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "bbbbbbbbbbbbb"
+ /* 1 */ "bcccccccccccb"
+ /* 2 */ "bcccccccccccb"
+ /* 3 */ "bcccccccccccb"
+ /* 4 */ "bcccccccccccb"
+ /* 5 */ "bcccccccccccb"
+ /* 6 */ "bcccccccccccb"
+ /* 7 */ "bcccccccccccb"
+ /* 8 */ "bcccccccccccb"
+ /* 9 */ "bcccccccccccb"
+ /* 10 */ "bcccccccccccb"
+ /* 11 */ "bbbbbbbbbbbbb"
+
+ // Level 2
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "ddddddddddddd"
+ /* 1 */ "deefeefeefeed"
+ /* 2 */ "deefeefeefeed"
+ /* 3 */ "deefeefeefeed"
+ /* 4 */ "deefeefeefeed"
+ /* 5 */ "deefeefeefeed"
+ /* 6 */ "deefeefeefeed"
+ /* 7 */ "deefeefeefeed"
+ /* 8 */ "deefeefeefeed"
+ /* 9 */ "deefeefeefeed"
+ /* 10 */ "deefeefeefeed"
+ /* 11 */ "ddddddddddddd"
+
+ // Level 3
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "g..g..g..g..g"
+ /* 1 */ "ghh.h..hh.hhg"
+ /* 2 */ "ghh..h.hh.hhg"
+ /* 3 */ "ghh.h..h..hhg"
+ /* 4 */ "ghh.hh.h..hhg"
+ /* 5 */ "ghh.h..hh.hhg"
+ /* 6 */ "ghh.hh.hh.hhg"
+ /* 7 */ "ghh....h..hhg"
+ /* 8 */ "ghh..h....hhg"
+ /* 9 */ "ghh.....h.hhg"
+ /* 10 */ "ghh.hh.h..hhg"
+ /* 11 */ "g..g..g..g..g"
+
+ // Level 4
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "i..i..i..i..i"
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "............."
+ /* 4 */ "............."
+ /* 5 */ "............."
+ /* 6 */ "............."
+ /* 7 */ "............."
+ /* 8 */ "............."
+ /* 9 */ "............."
+ /* 10 */ "............."
+ /* 11 */ "i..i..i..i..i"
+
+ // Level 5
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "............."
+ /* 4 */ "............."
+ /* 5 */ "............."
+ /* 6 */ "............."
+ /* 7 */ "............."
+ /* 8 */ "............."
+ /* 9 */ "............."
+ /* 10 */ "............."
+ /* 11 */ "............."
+
+ // Level 6
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "............."
+ /* 4 */ "............."
+ /* 5 */ "............."
+ /* 6 */ "............."
+ /* 7 */ "............."
+ /* 8 */ "............."
+ /* 9 */ "............."
+ /* 10 */ "............."
+ /* 11 */ "............."
+
+ // Level 7
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "............."
+ /* 4 */ "............."
+ /* 5 */ "............."
+ /* 6 */ "............."
+ /* 7 */ "............."
+ /* 8 */ "............."
+ /* 9 */ "............."
+ /* 10 */ "............."
+ /* 11 */ ".............",
+
+ // Connectors:
+ "-1: 7, 1, 11: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // BigPlantBed
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CobbleHouse10x5Library:
+ // The data has been exported from the gallery Plains, area index 23, ID 66, created by xoft
+ {
+ // Size:
+ 12, 7, 7, // SizeX = 12, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 12, 6, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f: 53: 3\n" /* woodstairs */
+ "g: 53: 1\n" /* woodstairs */
+ "h: 85: 0\n" /* fence */
+ "i: 53: 0\n" /* woodstairs */
+ "j: 53: 2\n" /* woodstairs */
+ "k:102: 0\n" /* glasspane */
+ "l: 64:12\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 3\n" /* torch */
+ "o: 72: 0\n" /* woodplate */
+ "p: 50: 4\n" /* torch */
+ "q: 53: 7\n" /* woodstairs */
+ "r: 47: 0\n" /* bookshelf */
+ "s: 50: 1\n" /* torch */
+ "t: 50: 2\n" /* torch */
+ "u: 53: 6\n" /* woodstairs */
+ "v: 5: 0\n" /* wood */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmmmaaamm"
+ /* 1 */ "maaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaam"
+ /* 6 */ "mmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ ".......bcd.."
+ /* 1 */ ".aaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaa."
+ /* 6 */ "............"
+
+ // Level 2
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ ".aaaaaaaeaa."
+ /* 2 */ ".af.ghi...a."
+ /* 3 */ ".ah.......a."
+ /* 4 */ ".aj.ghighia."
+ /* 5 */ ".aaaaaaaaaa."
+ /* 6 */ "............"
+
+ // Level 3
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ ".akkakkalaa."
+ /* 2 */ ".k..no.n.nk."
+ /* 3 */ ".ko.......k."
+ /* 4 */ ".k..po.po.k."
+ /* 5 */ ".akkakkakka."
+ /* 6 */ "............"
+
+ // Level 4
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "jjjjjjjjjjjj"
+ /* 1 */ "qaaaaaaaaaaq"
+ /* 2 */ ".arrrrrrrra."
+ /* 3 */ ".as......ta."
+ /* 4 */ ".arrrrrrrra."
+ /* 5 */ "uaaaaaaaaaau"
+ /* 6 */ "ffffffffffff"
+
+ // Level 5
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "jjjjjjjjjjjj"
+ /* 2 */ "qvvvvvvvvvvq"
+ /* 3 */ ".vvvvvvvvvv."
+ /* 4 */ "uvvvvvvvvvvu"
+ /* 5 */ "ffffffffffff"
+ /* 6 */ "............"
+
+ // Level 6
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "jjjjjjjjjjjj"
+ /* 3 */ "vvvvvvvvvvvv"
+ /* 4 */ "ffffffffffff"
+ /* 5 */ "............"
+ /* 6 */ "............",
+
+ // Connectors:
+ "-1: 8, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // CobbleHouse10x5Library
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // DoublePlantBed:
+ // The data has been exported from the gallery Plains, area index 5, ID 20, created by tonibm1999
+ {
+ // Size:
+ 15, 8, 9, // SizeX = 15, SizeY = 8, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 14, 7, 8, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 2: 0\n" /* grass */
+ "c: 17: 0\n" /* tree */
+ "d: 60: 7\n" /* tilleddirt */
+ "e: 8: 0\n" /* water */
+ "f: 50: 5\n" /* torch */
+ "g: 59: 7\n" /* crops */
+ "h: 59: 3\n" /* crops */
+ "i: 59: 5\n" /* crops */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "aaaaaaabaaaaaaa"
+ /* 1 */ "aaaaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaaaa"
+ /* 4 */ "aaaaaaabaaaaaaa"
+ /* 5 */ "aaaaaaabaaaaaaa"
+ /* 6 */ "aaaaaaabaaaaaaa"
+ /* 7 */ "aaaaaaabaaaaaaa"
+ /* 8 */ "aaaaaaabaaaaaaa"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "aaaaaaamaaaaaaa"
+ /* 1 */ "aaaaaaamaaaaaaa"
+ /* 2 */ "aaaaaaamaaaaaaa"
+ /* 3 */ "aaaaaaamaaaaaaa"
+ /* 4 */ "aaaaaaamaaaaaaa"
+ /* 5 */ "aaaaaaamaaaaaaa"
+ /* 6 */ "aaaaaaamaaaaaaa"
+ /* 7 */ "aaaaaaamaaaaaaa"
+ /* 8 */ "aaaaaaamaaaaaaa"
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "ccccccc.ccccccc"
+ /* 1 */ "cddeddc.cddeddc"
+ /* 2 */ "cddeddc.cddeddc"
+ /* 3 */ "cddeddc.cddeddc"
+ /* 4 */ "cddeddc.cddeddc"
+ /* 5 */ "cddeddc.cddeddc"
+ /* 6 */ "cddeddc.cddeddc"
+ /* 7 */ "cddeddc.cddeddc"
+ /* 8 */ "ccccccc.ccccccc"
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "f.....f.f.....f"
+ /* 1 */ ".gg.gg...gg.gg."
+ /* 2 */ ".gg.hg...gg.gg."
+ /* 3 */ ".gg.gi...gg.gg."
+ /* 4 */ ".gg.gg...gg.gg."
+ /* 5 */ ".gg.gg...gg.gg."
+ /* 6 */ ".gg.gg...gg.gg."
+ /* 7 */ ".gg.gg...gg.gg."
+ /* 8 */ "f.....f.f.....f"
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "..............."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "..............."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+
+ // Level 6
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "..............."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+
+ // Level 7
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "..............."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "...............",
+
+ // Connectors:
+ "-1: 7, 2, 8: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // DoublePlantBed
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Forge:
+ // The data has been exported from the gallery Plains, area index 51, ID 102, created by Aloe_vera
+ {
+ // Size:
+ 12, 9, 11, // SizeX = 12, SizeY = 9, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 12, 8, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 2\n" /* wooddoorblock */
+ "h: 10: 0\n" /* lava */
+ "i: 54: 2\n" /* chest */
+ "j: 61: 2\n" /* furnace */
+ "k:102: 0\n" /* glasspane */
+ "l: 64: 8\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */
+ "n:139: 0\n" /* cobblestonewall */
+ "o:101: 0\n" /* ironbars */
+ "p: 53: 2\n" /* woodstairs */
+ "q: 53: 7\n" /* woodstairs */
+ "r: 50: 2\n" /* torch */
+ "s: 50: 1\n" /* torch */
+ "t: 53: 6\n" /* woodstairs */
+ "u: 53: 3\n" /* woodstairs */
+ "v: 43: 0\n" /* doubleslab */
+ "w: 44: 0\n" /* step */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmaaaaamm"
+ /* 1 */ "maaaaaaaaamm"
+ /* 2 */ "maaaaaaaaamm"
+ /* 3 */ "maaaaaaaaaaa"
+ /* 4 */ "maaaaaaaaaaa"
+ /* 5 */ "maaaaaaaaaaa"
+ /* 6 */ "maaaaaaaaaaa"
+ /* 7 */ "maaaaaaaaaaa"
+ /* 8 */ "maaaaammmmmm"
+ /* 9 */ "maaaaammmmmm"
+ /* 10 */ "mmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ ".....bcccd.."
+ /* 1 */ ".aaaaaaaad.."
+ /* 2 */ ".aaaaaaaad.."
+ /* 3 */ ".aaaaaaaaaaa"
+ /* 4 */ ".aaaaaaaaaaa"
+ /* 5 */ ".aaaaaaaaaaa"
+ /* 6 */ ".aaaaaaaaaaa"
+ /* 7 */ ".aaaaaaaaaaa"
+ /* 8 */ ".aaaaa......"
+ /* 9 */ ".aaaaa......"
+ /* 10 */ "............"
+
+ // Level 2
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ ".efffe......"
+ /* 2 */ ".f...g......"
+ /* 3 */ ".f...ea..aaa"
+ /* 4 */ ".f...f...aha"
+ /* 5 */ ".f...f...aha"
+ /* 6 */ ".f...fijjaha"
+ /* 7 */ ".f...eaaaaaa"
+ /* 8 */ ".f...f......"
+ /* 9 */ ".efffe......"
+ /* 10 */ "............"
+
+ // Level 3
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ ".ekkke......"
+ /* 2 */ ".k...l......"
+ /* 3 */ ".k...en..n.a"
+ /* 4 */ ".k...k.....o"
+ /* 5 */ ".f...k.....o"
+ /* 6 */ ".k...k.....o"
+ /* 7 */ ".k...eaooooa"
+ /* 8 */ ".k...f......"
+ /* 9 */ ".ekkke......"
+ /* 10 */ "............"
+
+ // Level 4
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "ppppppp....."
+ /* 1 */ "qfffffq....."
+ /* 2 */ ".f...f......"
+ /* 3 */ ".f..rfa..aoa"
+ /* 4 */ ".f...f...o.a"
+ /* 5 */ ".f...f...o.a"
+ /* 6 */ ".fs..f...o.a"
+ /* 7 */ ".f...faaaaaa"
+ /* 8 */ ".f...f......"
+ /* 9 */ "tffffft....."
+ /* 10 */ "uuuuuuu....."
+
+ // Level 5
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "ppppppp....."
+ /* 2 */ "qfffffq....."
+ /* 3 */ ".f...fvvvvvv"
+ /* 4 */ ".f...fvwwwwv"
+ /* 5 */ ".f...fvwwwwv"
+ /* 6 */ ".f...fvwwwwv"
+ /* 7 */ ".f...fvvvvvv"
+ /* 8 */ "tffffft....."
+ /* 9 */ "uuuuuuu....."
+ /* 10 */ "............"
+
+ // Level 6
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "ppppppp....."
+ /* 3 */ "qfffffq....."
+ /* 4 */ ".f...f......"
+ /* 5 */ ".f...f......"
+ /* 6 */ ".f...f......"
+ /* 7 */ "tffffft....."
+ /* 8 */ "uuuuuuu....."
+ /* 9 */ "............"
+ /* 10 */ "............"
+
+ // Level 7
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "............"
+ /* 3 */ "ppppppp....."
+ /* 4 */ "qfffffq....."
+ /* 5 */ ".f...f......"
+ /* 6 */ "tffffft....."
+ /* 7 */ "uuuuuuu....."
+ /* 8 */ "............"
+ /* 9 */ "............"
+ /* 10 */ "............"
+
+ // Level 8
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "............"
+ /* 3 */ "............"
+ /* 4 */ "ppppppp....."
+ /* 5 */ "fffffff....."
+ /* 6 */ "uuuuuuu....."
+ /* 7 */ "............"
+ /* 8 */ "............"
+ /* 9 */ "............"
+ /* 10 */ "............",
+
+ // Connectors:
+ "-1: 7, 1, -1: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Forge
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // LampPost:
+ // The data has been exported from the gallery Plains, area index 28, ID 73, created by STR_Warrior
+ {
+ // Size:
+ 3, 7, 3, // SizeX = 3, SizeY = 7, SizeZ = 3
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 2, 6, 2, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 43: 0\n" /* doubleslab */
+ "c:139: 0\n" /* cobblestonewall */
+ "d: 50: 4\n" /* torch */
+ "e: 50: 2\n" /* torch */
+ "f: 50: 1\n" /* torch */
+ "g: 50: 3\n" /* torch */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012 */
+ /* 0 */ "mmm"
+ /* 1 */ "mam"
+ /* 2 */ "mmm"
+
+ // Level 1
+ /* z\x* 012 */
+ /* 0 */ "..."
+ /* 1 */ ".b."
+ /* 2 */ "..."
+
+ // Level 2
+ /* z\x* 012 */
+ /* 0 */ "..."
+ /* 1 */ ".c."
+ /* 2 */ "..."
+
+ // Level 3
+ /* z\x* 012 */
+ /* 0 */ "..."
+ /* 1 */ ".c."
+ /* 2 */ "..."
+
+ // Level 4
+ /* z\x* 012 */
+ /* 0 */ ".d."
+ /* 1 */ "ebf"
+ /* 2 */ ".g."
+
+ // Level 5
+ /* z\x* 012 */
+ /* 0 */ "..."
+ /* 1 */ "..."
+ /* 2 */ "..."
+
+ // Level 6
+ /* z\x* 012 */
+ /* 0 */ "..."
+ /* 1 */ "..."
+ /* 2 */ "...",
+
+ // Connectors:
+ "-1: 1, 1, 2: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // LampPost
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineshaftCorridor:
+ // The data has been exported from the gallery Plains, area index 139, ID 447, created by STR_Warrior
+ {
+ // Size:
+ 10, 4, 3, // SizeX = 10, SizeY = 4, SizeZ = 3
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 9, 3, 2, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 85: 0\n" /* fence */
+ "c: 66: 1\n" /* tracks */
+ "d: 50: 2\n" /* torch */
+ "e: 50: 1\n" /* torch */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "aaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaa"
+
+ // Level 1
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "..b....b.."
+ /* 1 */ "cccccccccc"
+ /* 2 */ "..b....b.."
+
+ // Level 2
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "..b....b.."
+ /* 1 */ ".........."
+ /* 2 */ "..b....b.."
+
+ // Level 3
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "..a....a.."
+ /* 1 */ ".dae..dae."
+ /* 2 */ "..a....a..",
+
+ // Connectors:
+ "-3: 0, 1, 1: 4\n" /* Type -3, direction X- */
+ "3: 9, 1, 1: 5\n" /* Type 3, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 200,
+
+ // MoveToGround:
+ false,
+ }, // MineshaftCorridor
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineshaftCrossing:
+ // The data has been exported from the gallery Plains, area index 171, ID 578, created by Aloe_vera
+ {
+ // Size:
+ 5, 4, 5, // SizeX = 5, SizeY = 4, SizeZ = 5
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 4, 3, 4, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 66: 0\n" /* tracks */
+ "c: 66: 1\n" /* tracks */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 01234 */
+ /* 0 */ "aaaaa"
+ /* 1 */ "aaaaa"
+ /* 2 */ "aaaaa"
+ /* 3 */ "aaaaa"
+ /* 4 */ "aaaaa"
+
+ // Level 1
+ /* z\x* 01234 */
+ /* 0 */ "m.b.m"
+ /* 1 */ ".aba."
+ /* 2 */ "ccccc"
+ /* 3 */ ".aba."
+ /* 4 */ "m.b.m"
+
+ // Level 2
+ /* z\x* 01234 */
+ /* 0 */ "m...m"
+ /* 1 */ ".a.a."
+ /* 2 */ "....."
+ /* 3 */ ".a.a."
+ /* 4 */ "m...m"
+
+ // Level 3
+ /* z\x* 01234 */
+ /* 0 */ "m...m"
+ /* 1 */ ".a.a."
+ /* 2 */ "....."
+ /* 3 */ ".a.a."
+ /* 4 */ "m...m",
+
+ // Connectors:
+ "3: 4, 1, 2: 5\n" /* Type 3, direction X+ */
+ "-3: 4, 1, 2: 5\n" /* Type -3, direction X+ */
+ "-3: 2, 1, 4: 3\n" /* Type -3, direction Z+ */
+ "3: 2, 1, 4: 3\n" /* Type 3, direction Z+ */
+ "3: 0, 1, 2: 4\n" /* Type 3, direction X- */
+ "-3: 0, 1, 2: 4\n" /* Type -3, direction X- */
+ "3: 2, 1, 0: 2\n" /* Type 3, direction Z- */
+ "-3: 2, 1, 0: 2\n" /* Type -3, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 1,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // MineshaftCrossing
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineshaftCrossing:
+ // The data has been exported from the gallery Plains, area index 193, ID 657, created by Aloe_vera
+ {
+ // Size:
+ 11, 4, 11, // SizeX = 11, SizeY = 4, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 10, 3, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 66: 0\n" /* tracks */
+ "c: 85: 0\n" /* fence */
+ "d: 66: 1\n" /* tracks */
+ "e: 50: 4\n" /* torch */
+ "f: 50: 3\n" /* torch */
+ "g: 50: 2\n" /* torch */
+ "h: 50: 1\n" /* torch */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "mmmmaaammmm"
+ /* 2 */ "mmmmaaammmm"
+ /* 3 */ "mmmmaaammmm"
+ /* 4 */ "aaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaaa"
+ /* 7 */ "mmmmaaammmm"
+ /* 8 */ "mmmmaaammmm"
+ /* 9 */ "mmmmaaammmm"
+ /* 10 */ "mmmmaaammmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmm.b.mmmm"
+ /* 1 */ "mmmm.b.mmmm"
+ /* 2 */ "mmmmcbcmmmm"
+ /* 3 */ "mmmm.b.mmmm"
+ /* 4 */ "..c..b..c.."
+ /* 5 */ "ddddddddddd"
+ /* 6 */ "..c..b..c.."
+ /* 7 */ "mmmm.b.mmmm"
+ /* 8 */ "mmmmcbcmmmm"
+ /* 9 */ "mmmm.b.mmmm"
+ /* 10 */ "mmmm.b.mmmm"
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmm...mmmm"
+ /* 1 */ "mmmm...mmmm"
+ /* 2 */ "mmmmc.cmmmm"
+ /* 3 */ "mmmm...mmmm"
+ /* 4 */ "..c.....c.."
+ /* 5 */ "..........."
+ /* 6 */ "..c.....c.."
+ /* 7 */ "mmmm...mmmm"
+ /* 8 */ "mmmmc.cmmmm"
+ /* 9 */ "mmmm...mmmm"
+ /* 10 */ "mmmm...mmmm"
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmm...mmmm"
+ /* 1 */ "mmmm.e.mmmm"
+ /* 2 */ "mmmmaaammmm"
+ /* 3 */ "mmmm.f.mmmm"
+ /* 4 */ "..a.....a.."
+ /* 5 */ ".gah...gah."
+ /* 6 */ "..a.....a.."
+ /* 7 */ "mmmm.e.mmmm"
+ /* 8 */ "mmmmaaammmm"
+ /* 9 */ "mmmm.f.mmmm"
+ /* 10 */ "mmmm...mmmm",
+
+ // Connectors:
+ "3: 5, 1, 0: 2\n" /* Type 3, direction Z- */
+ "-3: 5, 1, 0: 2\n" /* Type -3, direction Z- */
+ "3: 0, 1, 5: 4\n" /* Type 3, direction X- */
+ "-3: 0, 1, 5: 4\n" /* Type -3, direction X- */
+ "3: 5, 1, 10: 3\n" /* Type 3, direction Z+ */
+ "-3: 5, 1, 10: 3\n" /* Type -3, direction Z+ */
+ "3: 10, 1, 5: 5\n" /* Type 3, direction X+ */
+ "-3: 10, 1, 5: 5\n" /* Type -3, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 10,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // MineshaftCrossing
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineshaftDoubleCrossing:
+ // The data has been exported from the gallery Plains, area index 172, ID 579, created by Aloe_vera
+ {
+ // Size:
+ 5, 8, 5, // SizeX = 5, SizeY = 8, SizeZ = 5
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 4, 7, 4, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 66: 0\n" /* tracks */
+ "c: 66: 1\n" /* tracks */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 01234 */
+ /* 0 */ "aaaaa"
+ /* 1 */ "aaaaa"
+ /* 2 */ "aaaaa"
+ /* 3 */ "aaaaa"
+ /* 4 */ "aaaaa"
+
+ // Level 1
+ /* z\x* 01234 */
+ /* 0 */ "m.b.m"
+ /* 1 */ ".aba."
+ /* 2 */ "ccccc"
+ /* 3 */ ".aba."
+ /* 4 */ "m.b.m"
+
+ // Level 2
+ /* z\x* 01234 */
+ /* 0 */ "m...m"
+ /* 1 */ ".a.a."
+ /* 2 */ "....."
+ /* 3 */ ".a.a."
+ /* 4 */ "m...m"
+
+ // Level 3
+ /* z\x* 01234 */
+ /* 0 */ "m...m"
+ /* 1 */ ".a.a."
+ /* 2 */ "....."
+ /* 3 */ ".a.a."
+ /* 4 */ "m...m"
+
+ // Level 4
+ /* z\x* 01234 */
+ /* 0 */ "aaaaa"
+ /* 1 */ "aa.aa"
+ /* 2 */ "a...a"
+ /* 3 */ "aa.aa"
+ /* 4 */ "aaaaa"
+
+ // Level 5
+ /* z\x* 01234 */
+ /* 0 */ "m...m"
+ /* 1 */ ".a.a."
+ /* 2 */ "....."
+ /* 3 */ ".a.a."
+ /* 4 */ "m...m"
+
+ // Level 6
+ /* z\x* 01234 */
+ /* 0 */ "m...m"
+ /* 1 */ ".a.a."
+ /* 2 */ "....."
+ /* 3 */ ".a.a."
+ /* 4 */ "m...m"
+
+ // Level 7
+ /* z\x* 01234 */
+ /* 0 */ "m...m"
+ /* 1 */ ".a.a."
+ /* 2 */ "....."
+ /* 3 */ ".a.a."
+ /* 4 */ "m...m",
+
+ // Connectors:
+ "-3: 4, 5, 2: 5\n" /* Type -3, direction X+ */
+ "3: 4, 5, 2: 5\n" /* Type 3, direction X+ */
+ "-3: 2, 1, 4: 3\n" /* Type -3, direction Z+ */
+ "3: 2, 1, 4: 3\n" /* Type 3, direction Z+ */
+ "-3: 0, 1, 2: 4\n" /* Type -3, direction X- */
+ "3: 0, 1, 2: 4\n" /* Type 3, direction X- */
+ "-3: 2, 1, 0: 2\n" /* Type -3, direction Z- */
+ "3: 2, 1, 0: 2\n" /* Type 3, direction Z- */
+ "-3: 4, 1, 2: 5\n" /* Type -3, direction X+ */
+ "3: 4, 1, 2: 5\n" /* Type 3, direction X+ */
+ "-3: 2, 5, 4: 3\n" /* Type -3, direction Z+ */
+ "3: 2, 5, 4: 3\n" /* Type 3, direction Z+ */
+ "-3: 0, 5, 2: 4\n" /* Type -3, direction X- */
+ "3: 0, 5, 2: 4\n" /* Type 3, direction X- */
+ "-3: 2, 5, 0: 2\n" /* Type -3, direction Z- */
+ "3: 2, 5, 0: 2\n" /* Type 3, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 1,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // MineshaftDoubleCrossing
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineshaftSpiral:
+ // The data has been exported from the gallery Plains, area index 198, ID 662, created by Aloe_vera
+ {
+ // Size:
+ 7, 12, 7, // SizeX = 7, SizeY = 12, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 11, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 85: 0\n" /* fence */
+ "c: 66: 4\n" /* tracks */
+ "d: 66: 0\n" /* tracks */
+ "e: 66: 6\n" /* tracks */
+ "f: 66: 2\n" /* tracks */
+ "g: 50: 1\n" /* torch */
+ "h: 50: 3\n" /* torch */
+ "i: 66: 1\n" /* tracks */
+ "j: 66: 7\n" /* tracks */
+ "k: 66: 5\n" /* tracks */
+ "l: 50: 2\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 66: 3\n" /* tracks */
+ "o: 66: 8\n" /* tracks */
+ "p: 50: 4\n" /* torch */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmmmmm"
+ /* 2 */ "mmmmmmm"
+ /* 3 */ "aaabmmm"
+ /* 4 */ "aaammmm"
+ /* 5 */ "aaammmm"
+ /* 6 */ "aaammmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmmmmm"
+ /* 2 */ "aaammmm"
+ /* 3 */ "aaabmmm"
+ /* 4 */ ".c.mmmm"
+ /* 5 */ ".d.mmmm"
+ /* 6 */ ".d.mmmm"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "aaaammm"
+ /* 1 */ "aaaammm"
+ /* 2 */ "aaaammm"
+ /* 3 */ ".c.bmmm"
+ /* 4 */ "...mmmm"
+ /* 5 */ "...mmmm"
+ /* 6 */ "...mmmm"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "b..aamm"
+ /* 1 */ ".efaamm"
+ /* 2 */ ".d.aamm"
+ /* 3 */ "...bmmm"
+ /* 4 */ "...mmmm"
+ /* 5 */ "...mmmm"
+ /* 6 */ "...mmmm"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "b...aaa"
+ /* 1 */ "...faaa"
+ /* 2 */ "....aaa"
+ /* 3 */ "...baaa"
+ /* 4 */ "...mmmm"
+ /* 5 */ "mmmmmmm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "ag....b"
+ /* 1 */ "h...ij."
+ /* 2 */ ".....k."
+ /* 3 */ "...baaa"
+ /* 4 */ "mmmmaaa"
+ /* 5 */ "mmmmmmm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "mm....b"
+ /* 1 */ "mm....."
+ /* 2 */ "mm....."
+ /* 3 */ "mmmb.k."
+ /* 4 */ "mmmaaaa"
+ /* 5 */ "mmmaaaa"
+ /* 6 */ "mmmaaaa"
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "mmm..la"
+ /* 1 */ "mmm...h"
+ /* 2 */ "mmm...."
+ /* 3 */ "mmmb..."
+ /* 4 */ "mmaa.d."
+ /* 5 */ "mmaano."
+ /* 6 */ "mmaa..b"
+
+ // Level 8
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmmmmm"
+ /* 2 */ "mmmm..."
+ /* 3 */ "mmmb..."
+ /* 4 */ "aaa...."
+ /* 5 */ "aaan..."
+ /* 6 */ "aaa...b"
+
+ // Level 9
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmmmmm"
+ /* 2 */ "mmmmmmm"
+ /* 3 */ "mmmb..."
+ /* 4 */ "......."
+ /* 5 */ "iii...p"
+ /* 6 */ ".....la"
+
+ // Level 10
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmmmmm"
+ /* 2 */ "mmmmmmm"
+ /* 3 */ "mmmbmmm"
+ /* 4 */ ".....mm"
+ /* 5 */ ".....mm"
+ /* 6 */ ".....mm"
+
+ // Level 11
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmmmmm"
+ /* 2 */ "mmmmmmm"
+ /* 3 */ "mmmbmmm"
+ /* 4 */ "....mmm"
+ /* 5 */ "....mmm"
+ /* 6 */ "....mmm",
+
+ // Connectors:
+ "3: 1, 1, 6: 3\n" /* Type 3, direction Z+ */
+ "-3: 1, 1, 6: 3\n" /* Type -3, direction Z+ */
+ "3: 0, 9, 5: 4\n" /* Type 3, direction X- */
+ "-3: 0, 9, 5: 4\n" /* Type -3, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // MineshaftSpiral
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineshaftStairs:
+ // The data has been exported from the gallery Plains, area index 195, ID 659, created by Aloe_vera
+ {
+ // Size:
+ 7, 8, 3, // SizeX = 7, SizeY = 8, SizeZ = 3
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 7, 2, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 66: 1\n" /* tracks */
+ "c: 66: 2\n" /* tracks */
+ "d: 85: 0\n" /* fence */
+ "e: 50: 1\n" /* torch */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "aaammmm"
+ /* 1 */ "aaammmm"
+ /* 2 */ "aaammmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "..aammm"
+ /* 1 */ "bcaammm"
+ /* 2 */ "..aammm"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "...aamm"
+ /* 1 */ "..caamm"
+ /* 2 */ "...aamm"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "...daam"
+ /* 1 */ "...caam"
+ /* 2 */ "...daam"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "m..d.aa"
+ /* 1 */ "m...caa"
+ /* 2 */ "m..d.aa"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "mm.d..."
+ /* 1 */ "mm...bb"
+ /* 2 */ "mm.d..."
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "mmmd..."
+ /* 1 */ "mmm...."
+ /* 2 */ "mmmd..."
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "mmma..."
+ /* 1 */ "mmmae.."
+ /* 2 */ "mmma...",
+
+ // Connectors:
+ "3: 0, 1, 1: 4\n" /* Type 3, direction X- */
+ "-3: 0, 1, 1: 4\n" /* Type -3, direction X- */
+ "3: 6, 5, 1: 5\n" /* Type 3, direction X+ */
+ "-3: 6, 5, 1: 5\n" /* Type -3, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // MineshaftStairs
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineshaftStairsCrossing:
+ // The data has been exported from the gallery Plains, area index 199, ID 663, created by Aloe_vera
+ {
+ // Size:
+ 11, 12, 12, // SizeX = 11, SizeY = 12, SizeZ = 12
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 10, 11, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 66: 0\n" /* tracks */
+ "c: 66: 5\n" /* tracks */
+ "d: 85: 0\n" /* fence */
+ "e: 66: 1\n" /* tracks */
+ "f: 50: 3\n" /* torch */
+ "g: 50: 2\n" /* torch */
+ "h: 50: 1\n" /* torch */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "mmmmaaammmm"
+ /* 2 */ "mmmmaaammmm"
+ /* 3 */ "mmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmm.b.mmmm"
+ /* 1 */ "mmmm.c.mmmm"
+ /* 2 */ "mmmmaaammmm"
+ /* 3 */ "mmmmaaammmm"
+ /* 4 */ "mmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmm"
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmm...mmmm"
+ /* 1 */ "mmmm...mmmm"
+ /* 2 */ "mmmm.c.mmmm"
+ /* 3 */ "mmmmaaammmm"
+ /* 4 */ "mmmmaaammmm"
+ /* 5 */ "mmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmm"
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmm...mmmm"
+ /* 1 */ "mmmm...mmmm"
+ /* 2 */ "mmmm...mmmm"
+ /* 3 */ "mmmmdcdmmmm"
+ /* 4 */ "mmmmaaammmm"
+ /* 5 */ "mmmmaaammmm"
+ /* 6 */ "mmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmm"
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "mmmm...mmmm"
+ /* 2 */ "mmmm...mmmm"
+ /* 3 */ "mmmmd.dmmmm"
+ /* 4 */ "mmmm.c.mmmm"
+ /* 5 */ "aaaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaaa"
+ /* 7 */ "aaaaaaaaaaa"
+ /* 8 */ "mmmmaaammmm"
+ /* 9 */ "mmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmm"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmm"
+ /* 2 */ "mmmm...mmmm"
+ /* 3 */ "mmmmd.dmmmm"
+ /* 4 */ "mmmm...mmmm"
+ /* 5 */ "..d..b..d.."
+ /* 6 */ "eeeeeeeeeee"
+ /* 7 */ "..d..c..d.."
+ /* 8 */ "mmmmaaammmm"
+ /* 9 */ "mmmmaaammmm"
+ /* 10 */ "mmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmm"
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmm"
+ /* 3 */ "mmmmd.dmmmm"
+ /* 4 */ "mmmm...mmmm"
+ /* 5 */ "..d.....d.."
+ /* 6 */ "..........."
+ /* 7 */ "..d.....d.."
+ /* 8 */ "mmmm.c.mmmm"
+ /* 9 */ "mmmmaaammmm"
+ /* 10 */ "mmmmaaammmm"
+ /* 11 */ "mmmmmmmmmmm"
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmm"
+ /* 3 */ "mmmmaaammmm"
+ /* 4 */ "mmmm.f.mmmm"
+ /* 5 */ "..a.....a.."
+ /* 6 */ ".gah...gah."
+ /* 7 */ "..a.....a.."
+ /* 8 */ "mmmm...mmmm"
+ /* 9 */ "mmmmdcdmmmm"
+ /* 10 */ "mmmmaaammmm"
+ /* 11 */ "mmmmaaammmm"
+
+ // Level 8
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmm"
+ /* 7 */ "mmmm...mmmm"
+ /* 8 */ "mmmm...mmmm"
+ /* 9 */ "mmmmd.dmmmm"
+ /* 10 */ "mmmm.c.mmmm"
+ /* 11 */ "mmmmaaammmm"
+
+ // Level 9
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmm"
+ /* 8 */ "mmmm...mmmm"
+ /* 9 */ "mmmmd.dmmmm"
+ /* 10 */ "mmmm...mmmm"
+ /* 11 */ "mmmm.b.mmmm"
+
+ // Level 10
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmm"
+ /* 9 */ "mmmmd.dmmmm"
+ /* 10 */ "mmmm...mmmm"
+ /* 11 */ "mmmm...mmmm"
+
+ // Level 11
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmm"
+ /* 9 */ "mmmmaaammmm"
+ /* 10 */ "mmmm.f.mmmm"
+ /* 11 */ "mmmm...mmmm",
+
+ // Connectors:
+ "3: 0, 5, 6: 4\n" /* Type 3, direction X- */
+ "-3: 0, 5, 6: 4\n" /* Type -3, direction X- */
+ "3: 10, 5, 6: 5\n" /* Type 3, direction X+ */
+ "-3: 10, 5, 6: 5\n" /* Type -3, direction X+ */
+ "3: 5, 9, 11: 3\n" /* Type 3, direction Z+ */
+ "-3: 5, 9, 11: 3\n" /* Type -3, direction Z+ */
+ "3: 5, 1, 1: 2\n" /* Type 3, direction Z- */
+ "-3: 5, 1, 1: 2\n" /* Type -3, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 30,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // MineshaftStairsCrossing
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineshaftTee:
+ // The data has been exported from the gallery Plains, area index 194, ID 658, created by Aloe_vera
+ {
+ // Size:
+ 11, 4, 7, // SizeX = 11, SizeY = 4, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 10, 3, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 66: 0\n" /* tracks */
+ "c: 85: 0\n" /* fence */
+ "d: 66: 1\n" /* tracks */
+ "e: 50: 4\n" /* torch */
+ "f: 50: 3\n" /* torch */
+ "g: 50: 2\n" /* torch */
+ "h: 50: 1\n" /* torch */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "mmmmaaammmm"
+ /* 2 */ "mmmmaaammmm"
+ /* 3 */ "mmmmaaammmm"
+ /* 4 */ "aaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaaa"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmm.b.mmmm"
+ /* 1 */ "mmmm.b.mmmm"
+ /* 2 */ "mmmmcbcmmmm"
+ /* 3 */ "mmmm.b.mmmm"
+ /* 4 */ "..c..b..c.."
+ /* 5 */ "ddddddddddd"
+ /* 6 */ "..c.....c.."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmm...mmmm"
+ /* 1 */ "mmmm...mmmm"
+ /* 2 */ "mmmmc.cmmmm"
+ /* 3 */ "mmmm...mmmm"
+ /* 4 */ "..c.....c.."
+ /* 5 */ "..........."
+ /* 6 */ "..c.....c.."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmm...mmmm"
+ /* 1 */ "mmmm.e.mmmm"
+ /* 2 */ "mmmmaaammmm"
+ /* 3 */ "mmmm.f.mmmm"
+ /* 4 */ "..a.....a.."
+ /* 5 */ ".gah...gah."
+ /* 6 */ "..a.....a..",
+
+ // Connectors:
+ "3: 0, 1, 5: 4\n" /* Type 3, direction X- */
+ "-3: 0, 1, 5: 4\n" /* Type -3, direction X- */
+ "3: 5, 1, 0: 2\n" /* Type 3, direction Z- */
+ "-3: 5, 1, 0: 2\n" /* Type -3, direction Z- */
+ "3: 10, 1, 5: 5\n" /* Type 3, direction X+ */
+ "-3: 10, 1, 5: 5\n" /* Type -3, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 20,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // MineshaftTee
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineshaftsCorridor5:
+ // The data has been exported from the gallery Plains, area index 200, ID 664, created by Aloe_vera
+ {
+ // Size:
+ 11, 4, 3, // SizeX = 11, SizeY = 4, SizeZ = 3
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 10, 3, 2, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 85: 0\n" /* fence */
+ "c: 66: 1\n" /* tracks */
+ "d: 50: 2\n" /* torch */
+ "e: 50: 1\n" /* torch */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "aaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaa"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..b.....b.."
+ /* 1 */ "ccccccccccc"
+ /* 2 */ "..b.....b.."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..b.....b.."
+ /* 1 */ "..........."
+ /* 2 */ "..b.....b.."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..a.....a.."
+ /* 1 */ ".dae...dae."
+ /* 2 */ "..a.....a..",
+
+ // Connectors:
+ "3: 10, 1, 1: 5\n" /* Type 3, direction X+ */
+ "-3: 10, 1, 1: 5\n" /* Type -3, direction X+ */
+ "-3: 0, 1, 1: 4\n" /* Type -3, direction X- */
+ "3: 0, 1, 1: 4\n" /* Type 3, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // MineshaftsCorridor5
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Scarecrow:
+ // The data has been exported from the gallery Plains, area index 150, ID 494, created by STR_Warrior
+ {
+ // Size:
+ 1, 6, 3, // SizeX = 1, SizeY = 6, SizeZ = 3
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 0, 5, 2, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a:139: 0\n" /* cobblestonewall */
+ "b: 85: 0\n" /* fence */
+ "c:126: 4\n" /* woodenslab */
+ "d: 86: 1\n" /* pumpkin */
+ "e:139: 1\n" /* cobblestonewall */
+ "f:163: 4\n" /* acaciawoodenstairs */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0 */
+ /* 0 */ "."
+ /* 1 */ "a"
+ /* 2 */ "."
+
+ // Level 1
+ /* z\x* 0 */
+ /* 0 */ "."
+ /* 1 */ "b"
+ /* 2 */ "."
+
+ // Level 2
+ /* z\x* 0 */
+ /* 0 */ "c"
+ /* 1 */ "d"
+ /* 2 */ "c"
+
+ // Level 3
+ /* z\x* 0 */
+ /* 0 */ "."
+ /* 1 */ "e"
+ /* 2 */ "."
+
+ // Level 4
+ /* z\x* 0 */
+ /* 0 */ "f"
+ /* 1 */ "d"
+ /* 2 */ "f"
+
+ // Level 5
+ /* z\x* 0 */
+ /* 0 */ "."
+ /* 1 */ "f"
+ /* 2 */ ".",
+
+ // Connectors:
+ "-1: -1, 0, 1: 4\n" /* Type -1, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 10,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Scarecrow
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SinglePlantBed:
+ // The data has been exported from the gallery Plains, area index 17, ID 60, created by Aloe_vera
+ {
+ // Size:
+ 10, 7, 7, // SizeX = 10, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 9, 6, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 17: 0\n" /* tree */
+ "c: 60: 7\n" /* tilleddirt */
+ "d: 8: 0\n" /* water */
+ "e: 59: 7\n" /* crops */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "aaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaa"
+
+ // Level 1
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "bbbbbbbbbb"
+ /* 1 */ "bccccccccb"
+ /* 2 */ "bccccccccb"
+ /* 3 */ "bddddddddb"
+ /* 4 */ "bccccccccb"
+ /* 5 */ "bccccccccb"
+ /* 6 */ "bbbbbbbbbb"
+
+ // Level 2
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".eeeeeeee."
+ /* 2 */ ".eeeeeeee."
+ /* 3 */ ".........."
+ /* 4 */ ".eeeeeeee."
+ /* 5 */ ".eeeeeeee."
+ /* 6 */ ".........."
+
+ // Level 3
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".........."
+ /* 2 */ ".........."
+ /* 3 */ ".........."
+ /* 4 */ ".........."
+ /* 5 */ ".........."
+ /* 6 */ ".........."
+
+ // Level 4
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".........."
+ /* 2 */ ".........."
+ /* 3 */ ".........."
+ /* 4 */ ".........."
+ /* 5 */ ".........."
+ /* 6 */ ".........."
+
+ // Level 5
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".........."
+ /* 2 */ ".........."
+ /* 3 */ ".........."
+ /* 4 */ ".........."
+ /* 5 */ ".........."
+ /* 6 */ ".........."
+
+ // Level 6
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".........."
+ /* 2 */ ".........."
+ /* 3 */ ".........."
+ /* 4 */ ".........."
+ /* 5 */ ".........."
+ /* 6 */ "..........",
+
+ // Connectors:
+ "-1: 9, 1, 3: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // SinglePlantBed
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenChurchMid:
+ // The data has been exported from the gallery Plains, area index 58, ID 109, created by Aloe_vera
+ {
+ // Size:
+ 7, 15, 13, // SizeX = 7, SizeY = 15, SizeZ = 13
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 7, 14, 13, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "A: 85: 0\n" /* fence */
+ "B:126: 8\n" /* woodenslab */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 7\n" /* wooddoorblock */
+ "h: 65: 3\n" /* ladder */
+ "i: 53: 3\n" /* woodstairs */
+ "j: 53: 7\n" /* woodstairs */
+ "k: 64:12\n" /* wooddoorblock */
+ "l:102: 0\n" /* glasspane */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 1\n" /* torch */
+ "o: 50: 2\n" /* torch */
+ "p:171:14\n" /* carpet */
+ "q: 50: 3\n" /* torch */
+ "r: 53: 2\n" /* woodstairs */
+ "s: 53: 0\n" /* woodstairs */
+ "t: 53: 1\n" /* woodstairs */
+ "u: 53: 5\n" /* woodstairs */
+ "v: 53: 4\n" /* woodstairs */
+ "w: 17: 4\n" /* tree */
+ "x: 17: 8\n" /* tree */
+ "y: 54: 2\n" /* chest */
+ "z: 50: 4\n" /* torch */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmaaamm"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "maaaaam"
+ /* 7 */ "maaaaam"
+ /* 8 */ "maaaaam"
+ /* 9 */ "maaaaam"
+ /* 10 */ "maaaaam"
+ /* 11 */ "maaaaam"
+ /* 12 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "..bcd.."
+ /* 1 */ ".aaaaa."
+ /* 2 */ ".aaaaa."
+ /* 3 */ ".aaaaa."
+ /* 4 */ ".aaaaa."
+ /* 5 */ ".aaaaa."
+ /* 6 */ ".aaaaa."
+ /* 7 */ ".aaaaa."
+ /* 8 */ ".aaaaa."
+ /* 9 */ ".aaaaa."
+ /* 10 */ ".aaaaa."
+ /* 11 */ ".aaaaa."
+ /* 12 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".efgfe."
+ /* 2 */ ".f..hf."
+ /* 3 */ ".f...f."
+ /* 4 */ ".f...f."
+ /* 5 */ ".ei.ie."
+ /* 6 */ ".f...f."
+ /* 7 */ ".fi.if."
+ /* 8 */ ".f...f."
+ /* 9 */ ".f.j.f."
+ /* 10 */ ".f...f."
+ /* 11 */ ".efffe."
+ /* 12 */ "......."
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".efkfe."
+ /* 2 */ ".l..hl."
+ /* 3 */ ".l...l."
+ /* 4 */ ".l...l."
+ /* 5 */ ".e...e."
+ /* 6 */ ".l...l."
+ /* 7 */ ".l...l."
+ /* 8 */ ".fn.of."
+ /* 9 */ ".l.p.l."
+ /* 10 */ ".l...l."
+ /* 11 */ ".ellle."
+ /* 12 */ "......."
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".efffe."
+ /* 2 */ ".f.qhf."
+ /* 3 */ ".f...f."
+ /* 4 */ ".f...f."
+ /* 5 */ "re...er"
+ /* 6 */ "sf...ft"
+ /* 7 */ "sf...ft"
+ /* 8 */ "sf...ft"
+ /* 9 */ "sf...ft"
+ /* 10 */ "sf...ft"
+ /* 11 */ "sefffet"
+ /* 12 */ "su...vt"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".ewwwe."
+ /* 2 */ ".xffhx."
+ /* 3 */ ".xfffx."
+ /* 4 */ ".xfffx."
+ /* 5 */ ".ewwwe."
+ /* 6 */ ".sf.ft."
+ /* 7 */ ".sf.ft."
+ /* 8 */ ".sf.ft."
+ /* 9 */ ".sf.ft."
+ /* 10 */ ".sf.ft."
+ /* 11 */ ".sffft."
+ /* 12 */ ".su.vt."
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".eflfe."
+ /* 2 */ ".f..hf."
+ /* 3 */ ".f...f."
+ /* 4 */ ".f.y.f."
+ /* 5 */ ".efffe."
+ /* 6 */ "..sft.."
+ /* 7 */ "..sft.."
+ /* 8 */ "..sft.."
+ /* 9 */ "..sft.."
+ /* 10 */ "..sft.."
+ /* 11 */ "..sft.."
+ /* 12 */ "..sft.."
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".eflfe."
+ /* 2 */ ".f..hf."
+ /* 3 */ ".l...l."
+ /* 4 */ ".f...f."
+ /* 5 */ ".efffe."
+ /* 6 */ "......."
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+ /* 11 */ "......."
+ /* 12 */ "......."
+
+ // Level 8
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".eflfe."
+ /* 2 */ ".f..hf."
+ /* 3 */ ".f...f."
+ /* 4 */ ".f.z.f."
+ /* 5 */ ".efffe."
+ /* 6 */ "......."
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+ /* 11 */ "......."
+ /* 12 */ "......."
+
+ // Level 9
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".ewwwe."
+ /* 2 */ ".xffhx."
+ /* 3 */ ".xfffx."
+ /* 4 */ ".xfffx."
+ /* 5 */ ".ewwwe."
+ /* 6 */ "......."
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+ /* 11 */ "......."
+ /* 12 */ "......."
+
+ // Level 10
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".eAAAe."
+ /* 2 */ ".A...A."
+ /* 3 */ ".A...A."
+ /* 4 */ ".A...A."
+ /* 5 */ ".eAAAe."
+ /* 6 */ "......."
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+ /* 11 */ "......."
+ /* 12 */ "......."
+
+ // Level 11
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".e...e."
+ /* 2 */ "......."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ ".e...e."
+ /* 6 */ "......."
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+ /* 11 */ "......."
+ /* 12 */ "......."
+
+ // Level 12
+ /* z\x* 0123456 */
+ /* 0 */ "su...vt"
+ /* 1 */ "sefffet"
+ /* 2 */ "sfBBBft"
+ /* 3 */ "sfBBBft"
+ /* 4 */ "sfBBBft"
+ /* 5 */ "sefffet"
+ /* 6 */ "su...vt"
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+ /* 11 */ "......."
+ /* 12 */ "......."
+
+ // Level 13
+ /* z\x* 0123456 */
+ /* 0 */ ".su.vt."
+ /* 1 */ ".sffft."
+ /* 2 */ ".sffft."
+ /* 3 */ ".sffft."
+ /* 4 */ ".sffft."
+ /* 5 */ ".sffft."
+ /* 6 */ ".su.vt."
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+ /* 11 */ "......."
+ /* 12 */ "......."
+
+ // Level 14
+ /* z\x* 0123456 */
+ /* 0 */ "..sft.."
+ /* 1 */ "..sft.."
+ /* 2 */ "..sft.."
+ /* 3 */ "..sft.."
+ /* 4 */ "..sft.."
+ /* 5 */ "..sft.."
+ /* 6 */ "..sft.."
+ /* 7 */ "......."
+ /* 8 */ "......."
+ /* 9 */ "......."
+ /* 10 */ "......."
+ /* 11 */ "......."
+ /* 12 */ ".......",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 20,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenChurchMid
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenGranary:
+ // The data has been exported from the gallery Plains, area index 54, ID 105, created by Aloe_vera
+ {
+ // Size:
+ 7, 7, 9, // SizeX = 7, SizeY = 7, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 7, 6, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b:170: 0\n" /* haybale */
+ "c: 67: 0\n" /* stairs */
+ "d: 67: 2\n" /* stairs */
+ "e: 67: 1\n" /* stairs */
+ "f: 17: 0\n" /* tree */
+ "g: 5: 0\n" /* wood */
+ "h:170: 4\n" /* haybale */
+ "i:170: 8\n" /* haybale */
+ "j: 54: 2\n" /* chest */
+ "k: 50: 4\n" /* torch */
+ "l: 53: 0\n" /* woodstairs */
+ "m: 19: 0\n" /* sponge */
+ "n: 53: 5\n" /* woodstairs */
+ "o: 53: 4\n" /* woodstairs */
+ "p: 53: 1\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "maaaaam"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "maaaaam"
+ /* 7 */ "maaaaam"
+ /* 8 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "bcddde."
+ /* 1 */ ".aaaaa."
+ /* 2 */ ".aaaaa."
+ /* 3 */ ".aaaaa."
+ /* 4 */ ".aaaaa."
+ /* 5 */ ".aaaaa."
+ /* 6 */ ".aaaaa."
+ /* 7 */ ".aaaaa."
+ /* 8 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".f..bf."
+ /* 2 */ ".g...g."
+ /* 3 */ ".gb.hg."
+ /* 4 */ ".fihif."
+ /* 5 */ ".gbbbg."
+ /* 6 */ ".gijbg."
+ /* 7 */ ".fgfgf."
+ /* 8 */ "......."
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ ".k...k."
+ /* 1 */ ".f...f."
+ /* 2 */ ".g...g."
+ /* 3 */ ".g...g."
+ /* 4 */ ".fh..f."
+ /* 5 */ ".ghibg."
+ /* 6 */ ".ghiig."
+ /* 7 */ ".fgfgf."
+ /* 8 */ "......."
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "ln...op"
+ /* 1 */ "lgggggp"
+ /* 2 */ "lg...gp"
+ /* 3 */ "lg...gp"
+ /* 4 */ "lg...gp"
+ /* 5 */ "lgbb.gp"
+ /* 6 */ "lgibigp"
+ /* 7 */ "lgggggp"
+ /* 8 */ "ln...op"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ ".ln.op."
+ /* 1 */ ".lgggp."
+ /* 2 */ ".lg.gp."
+ /* 3 */ ".lg.gp."
+ /* 4 */ ".lg.gp."
+ /* 5 */ ".lg.gp."
+ /* 6 */ ".lg.gp."
+ /* 7 */ ".lgggp."
+ /* 8 */ ".ln.op."
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "..lgp.."
+ /* 1 */ "..lgp.."
+ /* 2 */ "..lgp.."
+ /* 3 */ "..lgp.."
+ /* 4 */ "..lgp.."
+ /* 5 */ "..lgp.."
+ /* 6 */ "..lgp.."
+ /* 7 */ "..lgp.."
+ /* 8 */ "..lgp..",
+
+ // Connectors:
+ "-1: 3, 1, -1: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 20,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenGranary
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouse10x7Library:
+ // The data has been exported from the gallery Plains, area index 47, ID 98, created by Aloe_vera
+ {
+ // Size:
+ 12, 8, 9, // SizeX = 12, SizeY = 8, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 12, 7, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 7\n" /* wooddoorblock */
+ "h: 64: 5\n" /* wooddoorblock */
+ "i: 53: 3\n" /* woodstairs */
+ "j: 85: 0\n" /* fence */
+ "k: 53: 2\n" /* woodstairs */
+ "l: 53: 1\n" /* woodstairs */
+ "m: 19: 0\n" /* sponge */
+ "n: 53: 0\n" /* woodstairs */
+ "o:102: 0\n" /* glasspane */
+ "p: 64:12\n" /* wooddoorblock */
+ "q: 50: 3\n" /* torch */
+ "r: 72: 0\n" /* woodplate */
+ "s: 53: 7\n" /* woodstairs */
+ "t: 47: 0\n" /* bookshelf */
+ "u: 50: 1\n" /* torch */
+ "v: 50: 2\n" /* torch */
+ "w: 53: 6\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmaaaammmm"
+ /* 1 */ "maaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaam"
+ /* 8 */ "mmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "....bccd...."
+ /* 1 */ ".aaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaa."
+ /* 6 */ ".aaaaaaaaaa."
+ /* 7 */ ".aaaaaaaaaa."
+ /* 8 */ "............"
+
+ // Level 2
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ ".efffghfffe."
+ /* 2 */ ".f........f."
+ /* 3 */ ".fi......if."
+ /* 4 */ ".fj......jf."
+ /* 5 */ ".fk......kf."
+ /* 6 */ ".f.ljnljn.f."
+ /* 7 */ ".effffffffe."
+ /* 8 */ "............"
+
+ // Level 3
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ ".eoofppfooe."
+ /* 2 */ ".o..q..q..o."
+ /* 3 */ ".o........o."
+ /* 4 */ ".fr......rf."
+ /* 5 */ ".o........o."
+ /* 6 */ ".o..r..r..o."
+ /* 7 */ ".eoofoofooe."
+ /* 8 */ "............"
+
+ // Level 4
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "kkkkkkkkkkkk"
+ /* 1 */ "sffffffffffs"
+ /* 2 */ ".fttttttttf."
+ /* 3 */ ".f........f."
+ /* 4 */ ".fu......vf."
+ /* 5 */ ".f........f."
+ /* 6 */ ".fttttttttf."
+ /* 7 */ "wffffffffffw"
+ /* 8 */ "iiiiiiiiiiii"
+
+ // Level 5
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "kkkkkkkkkkkk"
+ /* 2 */ "sffffffffffs"
+ /* 3 */ ".fttttttttf."
+ /* 4 */ ".f........f."
+ /* 5 */ ".fttttttttf."
+ /* 6 */ "wffffffffffw"
+ /* 7 */ "iiiiiiiiiiii"
+ /* 8 */ "............"
+
+ // Level 6
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "kkkkkkkkkkkk"
+ /* 3 */ "sffffffffffs"
+ /* 4 */ ".f........f."
+ /* 5 */ "wffffffffffw"
+ /* 6 */ "iiiiiiiiiiii"
+ /* 7 */ "............"
+ /* 8 */ "............"
+
+ // Level 7
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ "............"
+ /* 2 */ "............"
+ /* 3 */ "kkkkkkkkkkkk"
+ /* 4 */ "ffffffffffff"
+ /* 5 */ "iiiiiiiiiiii"
+ /* 6 */ "............"
+ /* 7 */ "............"
+ /* 8 */ "............",
+
+ // Connectors:
+ "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouse10x7Library
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouse5x5:
+ // The data has been exported from the gallery Plains, area index 49, ID 100, created by Aloe_vera
+ {
+ // Size:
+ 7, 7, 7, // SizeX = 7, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 7, 6, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 3\n" /* wooddoorblock */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i:102: 0\n" /* glasspane */
+ "j: 53: 2\n" /* woodstairs */
+ "k: 53: 7\n" /* woodstairs */
+ "l: 50: 3\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 53: 6\n" /* woodstairs */
+ "o: 53: 3\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmaaamm"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "..bcd.."
+ /* 1 */ ".aaaaa."
+ /* 2 */ ".aaaaa."
+ /* 3 */ ".aaaaa."
+ /* 4 */ ".aaaaa."
+ /* 5 */ ".aaaaa."
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".efgfe."
+ /* 2 */ ".f...f."
+ /* 3 */ ".f...f."
+ /* 4 */ ".f...f."
+ /* 5 */ ".efffe."
+ /* 6 */ "......."
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".efhfe."
+ /* 2 */ ".i...i."
+ /* 3 */ ".i...i."
+ /* 4 */ ".i...i."
+ /* 5 */ ".eiiie."
+ /* 6 */ "......."
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "jjjjjjj"
+ /* 1 */ "kfffffk"
+ /* 2 */ ".fl.lf."
+ /* 3 */ ".f...f."
+ /* 4 */ ".f...f."
+ /* 5 */ "nfffffn"
+ /* 6 */ "ooooooo"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "jjjjjjj"
+ /* 2 */ "kfffffk"
+ /* 3 */ ".f...f."
+ /* 4 */ "nfffffn"
+ /* 5 */ "ooooooo"
+ /* 6 */ "......."
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "......."
+ /* 2 */ "jjjjjjj"
+ /* 3 */ "fffffff"
+ /* 4 */ "ooooooo"
+ /* 5 */ "......."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouse5x5
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouse7x5:
+ // The data has been exported from the gallery Plains, area index 40, ID 91, created by xoft
+ {
+ // Size:
+ 9, 7, 7, // SizeX = 9, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 9, 6, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 7\n" /* wooddoorblock */
+ "h:102: 0\n" /* glasspane */
+ "i: 64:12\n" /* wooddoorblock */
+ "j: 53: 2\n" /* woodstairs */
+ "k: 53: 7\n" /* woodstairs */
+ "l: 50: 3\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 53: 6\n" /* woodstairs */
+ "o: 53: 3\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmmaaammm"
+ /* 1 */ "maaaaaaam"
+ /* 2 */ "maaaaaaam"
+ /* 3 */ "maaaaaaam"
+ /* 4 */ "maaaaaaam"
+ /* 5 */ "maaaaaaam"
+ /* 6 */ "mmmmmmmmm"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "...bcd..."
+ /* 1 */ ".aaaaaaa."
+ /* 2 */ ".aaaaaaa."
+ /* 3 */ ".aaaaaaa."
+ /* 4 */ ".aaaaaaa."
+ /* 5 */ ".aaaaaaa."
+ /* 6 */ "........."
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ ".effgffe."
+ /* 2 */ ".f.....f."
+ /* 3 */ ".f.....f."
+ /* 4 */ ".f.....f."
+ /* 5 */ ".efffffe."
+ /* 6 */ "........."
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ ".ehfifhe."
+ /* 2 */ ".h.....h."
+ /* 3 */ ".h.....h."
+ /* 4 */ ".h.....h."
+ /* 5 */ ".ehhfhhe."
+ /* 6 */ "........."
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "jjjjjjjjj"
+ /* 1 */ "kefffffek"
+ /* 2 */ ".f.l.l.f."
+ /* 3 */ ".f.....f."
+ /* 4 */ ".f.....f."
+ /* 5 */ "nefffffen"
+ /* 6 */ "ooooooooo"
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ "jjjjjjjjj"
+ /* 2 */ "kfffffffk"
+ /* 3 */ ".f.....f."
+ /* 4 */ "nfffffffn"
+ /* 5 */ "ooooooooo"
+ /* 6 */ "........."
+
+ // Level 6
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ "........."
+ /* 2 */ "jjjjjjjjj"
+ /* 3 */ "fffffffff"
+ /* 4 */ "ooooooooo"
+ /* 5 */ "........."
+ /* 6 */ ".........",
+
+ // Connectors:
+ "-1: 4, 1, -1: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouse7x5
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouse9x5:
+ // The data has been exported from the gallery Plains, area index 41, ID 92, created by xoft
+ {
+ // Size:
+ 11, 7, 7, // SizeX = 11, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 11, 6, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 3\n" /* wooddoorblock */
+ "h:102: 0\n" /* glasspane */
+ "i: 64: 8\n" /* wooddoorblock */
+ "j: 53: 2\n" /* woodstairs */
+ "k: 53: 7\n" /* woodstairs */
+ "l: 50: 3\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 53: 6\n" /* woodstairs */
+ "o: 53: 3\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "....bcd...."
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".aaaaaaaaa."
+ /* 3 */ ".aaaaaaaaa."
+ /* 4 */ ".aaaaaaaaa."
+ /* 5 */ ".aaaaaaaaa."
+ /* 6 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".efffgfffe."
+ /* 2 */ ".f.......f."
+ /* 3 */ ".f.......f."
+ /* 4 */ ".f.......f."
+ /* 5 */ ".efffffffe."
+ /* 6 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".ehhfifhhe."
+ /* 2 */ ".h.......h."
+ /* 3 */ ".h.......h."
+ /* 4 */ ".h.......h."
+ /* 5 */ ".ehhhfhhhe."
+ /* 6 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "jjjjjjjjjjj"
+ /* 1 */ "kfffffffffk"
+ /* 2 */ ".f..l.l.ff."
+ /* 3 */ ".f......ff."
+ /* 4 */ ".f......ff."
+ /* 5 */ "nfffffffffn"
+ /* 6 */ "ooooooooooo"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "jjjjjjjjjjj"
+ /* 2 */ "kfffffffffk"
+ /* 3 */ ".fffffffff."
+ /* 4 */ "nfffffffffn"
+ /* 5 */ "ooooooooooo"
+ /* 6 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "jjjjjjjjjjj"
+ /* 3 */ "fffffffffff"
+ /* 4 */ "ooooooooooo"
+ /* 5 */ "..........."
+ /* 6 */ "...........",
+
+ // Connectors:
+ "-1: 5, 1, -1: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouse9x5
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouse9x5Fence:
+ // The data has been exported from the gallery Plains, area index 9, ID 26, created by Aloe_vera
+ {
+ // Size:
+ 10, 7, 11, // SizeX = 10, SizeY = 7, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ 0, -1, -1, // MinX, MinY, MinZ
+ 10, 6, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 3: 0\n" /* dirt */
+ "c: 5: 0\n" /* wood */
+ "d: 2: 0\n" /* grass */
+ "e: 67: 2\n" /* stairs */
+ "f: 43: 0\n" /* doubleslab */
+ "g: 67: 0\n" /* stairs */
+ "h: 67: 3\n" /* stairs */
+ "i: 17: 0\n" /* tree */
+ "j: 53: 1\n" /* woodstairs */
+ "k: 85: 0\n" /* fence */
+ "l: 53: 0\n" /* woodstairs */
+ "m: 19: 0\n" /* sponge */
+ "n: 64: 2\n" /* wooddoorblock */
+ "o: 64: 4\n" /* wooddoorblock */
+ "p:102: 0\n" /* glasspane */
+ "q: 72: 0\n" /* woodplate */
+ "r: 64: 8\n" /* wooddoorblock */
+ "s: 64:12\n" /* wooddoorblock */
+ "t: 53: 5\n" /* woodstairs */
+ "u: 53: 4\n" /* woodstairs */
+ "v: 50: 1\n" /* torch */
+ "w: 50: 2\n" /* torch */,
+
+ // Block data:
+ // Level 0
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "mmmmmmmmmm"
+ /* 1 */ "maaaaammmm"
+ /* 2 */ "maaaaammmm"
+ /* 3 */ "maaaaabbbb"
+ /* 4 */ "aaaaaabbbb"
+ /* 5 */ "aaaaaabbbb"
+ /* 6 */ "aaaaaabbbb"
+ /* 7 */ "maaaaabbbb"
+ /* 8 */ "maaaaabbbb"
+ /* 9 */ "maaaaammmm"
+ /* 10 */ "mmmmmmmmmm"
+
+ // Level 1
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "......mmmm"
+ /* 1 */ ".aaaaammmm"
+ /* 2 */ ".acccammmm"
+ /* 3 */ ".acccadddd"
+ /* 4 */ "eafffadddd"
+ /* 5 */ "gaffffdddd"
+ /* 6 */ "hafffadddd"
+ /* 7 */ ".afffadddd"
+ /* 8 */ ".afffadddd"
+ /* 9 */ ".aaaaammmm"
+ /* 10 */ "......mmmm"
+
+ // Level 2
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "......mmmm"
+ /* 1 */ ".icccimmmm"
+ /* 2 */ ".cjklcmmmm"
+ /* 3 */ ".c...ckkkk"
+ /* 4 */ ".c...c...k"
+ /* 5 */ ".n...o...k"
+ /* 6 */ ".c...c...k"
+ /* 7 */ ".cff.c...k"
+ /* 8 */ ".c...ckkkk"
+ /* 9 */ ".icccimmmm"
+ /* 10 */ "......mmmm"
+
+ // Level 3
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "......mmmm"
+ /* 1 */ ".ipppimmmm"
+ /* 2 */ ".p.q.pmmmm"
+ /* 3 */ ".p...p...."
+ /* 4 */ ".c...c...."
+ /* 5 */ ".r...s...."
+ /* 6 */ ".c...c...."
+ /* 7 */ ".p...p...."
+ /* 8 */ ".p...p...."
+ /* 9 */ ".ipppimmmm"
+ /* 10 */ "......mmmm"
+
+ // Level 4
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "lt...ujmmm"
+ /* 1 */ "licccijmmm"
+ /* 2 */ "lc...cjmmm"
+ /* 3 */ "lc...cj..."
+ /* 4 */ "lcv.wcj..."
+ /* 5 */ "lc...cj..."
+ /* 6 */ "lcv.wcj..."
+ /* 7 */ "lc...cj..."
+ /* 8 */ "lc...cj..."
+ /* 9 */ "licccijmmm"
+ /* 10 */ "lt...ujmmm"
+
+ // Level 5
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".lt.uj.mmm"
+ /* 1 */ ".lcccj.mmm"
+ /* 2 */ ".lc.cj.mmm"
+ /* 3 */ ".lc.cj...."
+ /* 4 */ ".lc.cj...."
+ /* 5 */ ".lc.cj...."
+ /* 6 */ ".lc.cj...."
+ /* 7 */ ".lc.cj...."
+ /* 8 */ ".lc.cj...."
+ /* 9 */ ".lcccj.mmm"
+ /* 10 */ ".lt.uj.mmm"
+
+ // Level 6
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "..lcj..mmm"
+ /* 1 */ "..lcj..mmm"
+ /* 2 */ "..lcj..mmm"
+ /* 3 */ "..lcj....."
+ /* 4 */ "..lcj....."
+ /* 5 */ "..lcj....."
+ /* 6 */ "..lcj....."
+ /* 7 */ "..lcj....."
+ /* 8 */ "..lcj....."
+ /* 9 */ "..lcj..mmm"
+ /* 10 */ "..lcj..mmm",
+
+ // Connectors:
+ "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouse9x5Fence
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouse9x5Library:
+ // The data has been exported from the gallery Plains, area index 46, ID 97, created by Aloe_vera
+ {
+ // Size:
+ 11, 7, 7, // SizeX = 11, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 11, 6, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 7\n" /* wooddoorblock */
+ "h: 53: 3\n" /* woodstairs */
+ "i: 85: 0\n" /* fence */
+ "j: 53: 2\n" /* woodstairs */
+ "k: 53: 1\n" /* woodstairs */
+ "l: 53: 0\n" /* woodstairs */
+ "m: 19: 0\n" /* sponge */
+ "n:102: 0\n" /* glasspane */
+ "o: 64:12\n" /* wooddoorblock */
+ "p: 50: 3\n" /* torch */
+ "q: 72: 0\n" /* woodplate */
+ "r: 53: 7\n" /* woodstairs */
+ "s: 47: 0\n" /* bookshelf */
+ "t: 50: 1\n" /* torch */
+ "u: 50: 2\n" /* torch */
+ "v: 53: 6\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "....bcd...."
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".aaaaaaaaa."
+ /* 3 */ ".aaaaaaaaa."
+ /* 4 */ ".aaaaaaaaa."
+ /* 5 */ ".aaaaaaaaa."
+ /* 6 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".efffgfffe."
+ /* 2 */ ".fh.....hf."
+ /* 3 */ ".fi.....if."
+ /* 4 */ ".fj.kil.jf."
+ /* 5 */ ".efffffffe."
+ /* 6 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".ennfofnne."
+ /* 2 */ ".n..p.p..n."
+ /* 3 */ ".nq.....qn."
+ /* 4 */ ".n...q...n."
+ /* 5 */ ".ennnfnnne."
+ /* 6 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "jjjjjjjjjjj"
+ /* 1 */ "rfffffffffr"
+ /* 2 */ ".fsssssssf."
+ /* 3 */ ".ft.....uf."
+ /* 4 */ ".fsssssssf."
+ /* 5 */ "vfffffffffv"
+ /* 6 */ "hhhhhhhhhhh"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "jjjjjjjjjjj"
+ /* 2 */ "rfffffffffr"
+ /* 3 */ ".f.......f."
+ /* 4 */ "vfffffffffv"
+ /* 5 */ "hhhhhhhhhhh"
+ /* 6 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "jjjjjjjjjjj"
+ /* 3 */ "fffffffffff"
+ /* 4 */ "hhhhhhhhhhh"
+ /* 5 */ "..........."
+ /* 6 */ "...........",
+
+ // Connectors:
+ "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouse9x5Library
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouse9x7:
+ // The data has been exported from the gallery Plains, area index 52, ID 103, created by Aloe_vera
+ {
+ // Size:
+ 11, 8, 9, // SizeX = 11, SizeY = 8, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 11, 7, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 7\n" /* wooddoorblock */
+ "h:102: 0\n" /* glasspane */
+ "i: 64:12\n" /* wooddoorblock */
+ "j: 53: 2\n" /* woodstairs */
+ "k: 53: 7\n" /* woodstairs */
+ "l: 50: 3\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 4\n" /* torch */
+ "o: 53: 6\n" /* woodstairs */
+ "p: 53: 3\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "maaaaaaaaam"
+ /* 7 */ "maaaaaaaaam"
+ /* 8 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "....bcd...."
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".aaaaaaaaa."
+ /* 3 */ ".aaaaaaaaa."
+ /* 4 */ ".aaaaaaaaa."
+ /* 5 */ ".aaaaaaaaa."
+ /* 6 */ ".aaaaaaaaa."
+ /* 7 */ ".aaaaaaaaa."
+ /* 8 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".efffgfffe."
+ /* 2 */ ".f.......f."
+ /* 3 */ ".f.......f."
+ /* 4 */ ".f.......f."
+ /* 5 */ ".f.......f."
+ /* 6 */ ".f.......f."
+ /* 7 */ ".efffffffe."
+ /* 8 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".ehhfifhhe."
+ /* 2 */ ".h.......h."
+ /* 3 */ ".h.......h."
+ /* 4 */ ".f.......f."
+ /* 5 */ ".h.......h."
+ /* 6 */ ".h.......h."
+ /* 7 */ ".ehhhfhhhe."
+ /* 8 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "jjjjjjjjjjj"
+ /* 1 */ "kfffffffffk"
+ /* 2 */ ".f..l.l..f."
+ /* 3 */ ".f.......f."
+ /* 4 */ ".f.......f."
+ /* 5 */ ".f.......f."
+ /* 6 */ ".f...n...f."
+ /* 7 */ "offfffffffo"
+ /* 8 */ "ppppppppppp"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "jjjjjjjjjjj"
+ /* 2 */ "kfffffffffk"
+ /* 3 */ ".f.......f."
+ /* 4 */ ".f.......f."
+ /* 5 */ ".f.......f."
+ /* 6 */ "offfffffffo"
+ /* 7 */ "ppppppppppp"
+ /* 8 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "jjjjjjjjjjj"
+ /* 3 */ "kfffffffffk"
+ /* 4 */ ".f.......f."
+ /* 5 */ "offfffffffo"
+ /* 6 */ "ppppppppppp"
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "jjjjjjjjjjj"
+ /* 4 */ "fffffffffff"
+ /* 5 */ "ppppppppppp"
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "...........",
+
+ // Connectors:
+ "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouse9x7
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouse9x7Butcher:
+ // The data has been exported from the gallery Plains, area index 48, ID 99, created by Aloe_vera
+ {
+ // Size:
+ 11, 9, 13, // SizeX = 11, SizeY = 9, SizeZ = 13
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 8, 13, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 3: 0\n" /* dirt */
+ "b: 2: 0\n" /* grass */
+ "c: 4: 0\n" /* cobblestone */
+ "d: 67: 0\n" /* stairs */
+ "e: 67: 2\n" /* stairs */
+ "f: 67: 1\n" /* stairs */
+ "g: 43: 0\n" /* doubleslab */
+ "h: 17: 0\n" /* tree */
+ "i: 5: 0\n" /* wood */
+ "j: 64: 7\n" /* wooddoorblock */
+ "k: 53: 3\n" /* woodstairs */
+ "l: 85: 0\n" /* fence */
+ "m: 19: 0\n" /* sponge */
+ "n: 53: 2\n" /* woodstairs */
+ "o:102: 0\n" /* glasspane */
+ "p: 64:12\n" /* wooddoorblock */
+ "q: 72: 0\n" /* woodplate */
+ "r: 53: 7\n" /* woodstairs */
+ "s: 50: 1\n" /* torch */
+ "t: 50: 2\n" /* torch */
+ "u: 53: 6\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "aaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaab"
+ /* 5 */ "baaaaaaaaab"
+ /* 6 */ "aaaaaaaaaaa"
+ /* 7 */ "baaaaaaaaaa"
+ /* 8 */ "baaaaaaaaaa"
+ /* 9 */ "baaaaaaaaab"
+ /* 10 */ "aaaaaaaaaaa"
+ /* 11 */ "aaaaaaaaaba"
+ /* 12 */ "aaaaaaaaaba"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmcccmmmm"
+ /* 1 */ "mcccccccccm"
+ /* 2 */ "mcccccccccm"
+ /* 3 */ "mcccccccccm"
+ /* 4 */ "mcccccccccm"
+ /* 5 */ "mcccccccccm"
+ /* 6 */ "mcccccccccm"
+ /* 7 */ "mcccccccccm"
+ /* 8 */ "mmaaaaaaamm"
+ /* 9 */ "mmaaaaaaamm"
+ /* 10 */ "mmaaaaaaamm"
+ /* 11 */ "mmaaaaaaamm"
+ /* 12 */ "mmaaaaaaamm"
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "....def...."
+ /* 1 */ ".ccccccccc."
+ /* 2 */ ".cggggcccc."
+ /* 3 */ ".cggggcccc."
+ /* 4 */ ".cggggcccc."
+ /* 5 */ ".cggggcccc."
+ /* 6 */ ".cggggcccc."
+ /* 7 */ ".ccccccccc."
+ /* 8 */ "..bbbbbbb.."
+ /* 9 */ "mmbbbbbbbmm"
+ /* 10 */ "mmbbbbbbbmm"
+ /* 11 */ "mmbbbbbbbmm"
+ /* 12 */ "mmbbbbbbbmm"
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".hiiijiiih."
+ /* 2 */ ".i.g....ki."
+ /* 3 */ ".i.g....li."
+ /* 4 */ ".i.g....ni."
+ /* 5 */ ".i.......i."
+ /* 6 */ ".i.......i."
+ /* 7 */ ".hiiijiiih."
+ /* 8 */ "..l.....l.."
+ /* 9 */ "mml.....lmm"
+ /* 10 */ "mml.....lmm"
+ /* 11 */ "mml.....lmm"
+ /* 12 */ "mmlllllllmm"
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".hooipiooh."
+ /* 2 */ ".o.......o."
+ /* 3 */ ".o......qo."
+ /* 4 */ ".i.......i."
+ /* 5 */ ".o.......o."
+ /* 6 */ ".o.......o."
+ /* 7 */ ".hooipiooh."
+ /* 8 */ "..........."
+ /* 9 */ "mm.......mm"
+ /* 10 */ "mm.......mm"
+ /* 11 */ "mm.......mm"
+ /* 12 */ "mm.......mm"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "nnnnnnnnnnn"
+ /* 1 */ "riiiiiiiiir"
+ /* 2 */ ".i.......i."
+ /* 3 */ ".i.......i."
+ /* 4 */ ".is.....ti."
+ /* 5 */ ".i.......i."
+ /* 6 */ ".i.......i."
+ /* 7 */ "uiiiiiiiiiu"
+ /* 8 */ "kkkkkkkkkkk"
+ /* 9 */ "mm.......mm"
+ /* 10 */ "mm.......mm"
+ /* 11 */ "mm.......mm"
+ /* 12 */ "mm.......mm"
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "nnnnnnnnnnn"
+ /* 2 */ "riiiiiiiiir"
+ /* 3 */ ".i.......i."
+ /* 4 */ ".i.......i."
+ /* 5 */ ".i.......i."
+ /* 6 */ "uiiiiiiiiiu"
+ /* 7 */ "kkkkkkkkkkk"
+ /* 8 */ "..........."
+ /* 9 */ "mm.......mm"
+ /* 10 */ "mm.......mm"
+ /* 11 */ "mm.......mm"
+ /* 12 */ "mm.......mm"
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "nnnnnnnnnnn"
+ /* 3 */ "riiiiiiiiir"
+ /* 4 */ ".i.......i."
+ /* 5 */ "uiiiiiiiiiu"
+ /* 6 */ "kkkkkkkkkkk"
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "mm.......mm"
+ /* 10 */ "mm.......mm"
+ /* 11 */ "mm.......mm"
+ /* 12 */ "mm.......mm"
+
+ // Level 8
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "nnnnnnnnnnn"
+ /* 4 */ "iiiiiiiiiii"
+ /* 5 */ "kkkkkkkkkkk"
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "mm.......mm"
+ /* 10 */ "mm.......mm"
+ /* 11 */ "mm.......mm"
+ /* 12 */ "mm.......mm",
+
+ // Connectors:
+ "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouse9x7Butcher
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouse9x7DoubleDoor:
+ // The data has been exported from the gallery Plains, area index 38, ID 87, created by Aloe_vera
+ {
+ // Size:
+ 11, 8, 9, // SizeX = 11, SizeY = 8, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 11, 7, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 67: 3\n" /* stairs */
+ "f: 17: 0\n" /* tree */
+ "g: 5: 0\n" /* wood */
+ "h: 64: 7\n" /* wooddoorblock */
+ "i:102: 0\n" /* glasspane */
+ "j: 64:12\n" /* wooddoorblock */
+ "k: 53: 2\n" /* woodstairs */
+ "l: 53: 7\n" /* woodstairs */
+ "m: 19: 0\n" /* sponge */
+ "n: 17: 4\n" /* tree */
+ "o: 17: 8\n" /* tree */
+ "p: 50: 3\n" /* torch */
+ "q: 50: 4\n" /* torch */
+ "r: 53: 6\n" /* woodstairs */
+ "s: 53: 3\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "maaaaaaaaam"
+ /* 7 */ "maaaaaaaaam"
+ /* 8 */ "mmmmaaammmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "....bcd...."
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".aaaaaaaaa."
+ /* 3 */ ".aaaaaaaaa."
+ /* 4 */ ".aaaaaaaaa."
+ /* 5 */ ".aaaaaaaaa."
+ /* 6 */ ".aaaaaaaaa."
+ /* 7 */ ".aaaaaaaaa."
+ /* 8 */ "....bed...."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".fggfhfggf."
+ /* 2 */ ".g.......g."
+ /* 3 */ ".g.......g."
+ /* 4 */ ".f.......f."
+ /* 5 */ ".g.......g."
+ /* 6 */ ".g.......g."
+ /* 7 */ ".fggfhfggf."
+ /* 8 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".fiifjfiif."
+ /* 2 */ ".i.......i."
+ /* 3 */ ".i.......i."
+ /* 4 */ ".f.......f."
+ /* 5 */ ".i.......i."
+ /* 6 */ ".i.......i."
+ /* 7 */ ".fiifjfiif."
+ /* 8 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "kkkkkkkkkkk"
+ /* 1 */ "lfnnnnnnnfl"
+ /* 2 */ ".o..p.p..o."
+ /* 3 */ ".o.......o."
+ /* 4 */ ".o.......o."
+ /* 5 */ ".o.......o."
+ /* 6 */ ".o..q.q..o."
+ /* 7 */ "rfnnnnnnnfr"
+ /* 8 */ "sssssssssss"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "kkkkkkkkkkk"
+ /* 2 */ "lgggggggggl"
+ /* 3 */ ".g.......g."
+ /* 4 */ ".g.......g."
+ /* 5 */ ".g.......g."
+ /* 6 */ "rgggggggggr"
+ /* 7 */ "sssssssssss"
+ /* 8 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "kkkkkkkkkkk"
+ /* 3 */ "lgggggggggl"
+ /* 4 */ ".g.......g."
+ /* 5 */ "rgggggggggr"
+ /* 6 */ "sssssssssss"
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "kkkkkkkkkkk"
+ /* 4 */ "ggggggggggg"
+ /* 5 */ "sssssssssss"
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "...........",
+
+ // Connectors:
+ "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouse9x7DoubleDoor
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouseL13x14:
+ // The data has been exported from the gallery Plains, area index 39, ID 90, created by STR_Warrior
+ {
+ // Size:
+ 15, 9, 16, // SizeX = 15, SizeY = 9, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 15, 8, 16, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "A: 53: 7\n" /* woodstairs */
+ "B: 53: 4\n" /* woodstairs */
+ "C: 53: 5\n" /* woodstairs */
+ "D: 53: 6\n" /* woodstairs */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 43: 0\n" /* doubleslab */
+ "f: 17: 0\n" /* tree */
+ "g: 5: 0\n" /* wood */
+ "h: 64: 7\n" /* wooddoorblock */
+ "i: 96: 8\n" /* trapdoor */
+ "j: 61: 2\n" /* furnace */
+ "k: 53: 3\n" /* woodstairs */
+ "l: 85: 0\n" /* fence */
+ "m: 19: 0\n" /* sponge */
+ "n: 53: 2\n" /* woodstairs */
+ "o: 53: 1\n" /* woodstairs */
+ "p: 53: 0\n" /* woodstairs */
+ "q: 47: 0\n" /* bookshelf */
+ "r:102: 0\n" /* glasspane */
+ "s: 64:12\n" /* wooddoorblock */
+ "t: 72: 0\n" /* woodplate */
+ "u: 17: 4\n" /* tree */
+ "v: 17: 8\n" /* tree */
+ "w: 50: 3\n" /* torch */
+ "x: 50: 1\n" /* torch */
+ "y: 50: 4\n" /* torch */
+ "z: 50: 2\n" /* torch */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmaaammmmmm"
+ /* 1 */ "maaaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaaaam"
+ /* 8 */ "mmmmmmmmaaaaaam"
+ /* 9 */ "mmmmmmmmaaaaaam"
+ /* 10 */ "mmmmmmmmaaaaaam"
+ /* 11 */ "mmmmmmmmaaaaaam"
+ /* 12 */ "mmmmmmmmaaaaaam"
+ /* 13 */ "mmmmmmmmaaaaaam"
+ /* 14 */ "mmmmmmmmaaaaaam"
+ /* 15 */ "mmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "......bcd......"
+ /* 1 */ ".aaaaaaaaaaaaa."
+ /* 2 */ ".aeeeeaaaaaaaa."
+ /* 3 */ ".aeeeeaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaaaa."
+ /* 6 */ ".aaaaaaaaaaaaa."
+ /* 7 */ ".aaaaaaaaaaaaa."
+ /* 8 */ "........aaaaaa."
+ /* 9 */ "mmmmmmm.aaaaaa."
+ /* 10 */ "mmmmmmm.aaaaaa."
+ /* 11 */ "mmmmmmm.aaaaaa."
+ /* 12 */ "mmmmmmm.aaaaaa."
+ /* 13 */ "mmmmmmm.aaaaaa."
+ /* 14 */ "mmmmmmm.aaaaaa."
+ /* 15 */ "mmmmmmm........"
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".fggggfhfggggf."
+ /* 2 */ ".g...i.......g."
+ /* 3 */ ".gjeee......kg."
+ /* 4 */ ".f..........lg."
+ /* 5 */ ".g..........ng."
+ /* 6 */ ".g.olp..ol...g."
+ /* 7 */ ".fggggggfn...f."
+ /* 8 */ "........g....g."
+ /* 9 */ "mmmmmmm.gk...g."
+ /* 10 */ "mmmmmmm.gl..kg."
+ /* 11 */ "mmmmmmm.gn..lg."
+ /* 12 */ "mmmmmmm.g...ng."
+ /* 13 */ "mmmmmmm.gq..qg."
+ /* 14 */ "mmmmmmm.fggggf."
+ /* 15 */ "mmmmmmm........"
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".fgrrgfsfgrrgf."
+ /* 2 */ ".g...........g."
+ /* 3 */ ".g...........r."
+ /* 4 */ ".f..........tr."
+ /* 5 */ ".g...........r."
+ /* 6 */ ".g..t....t...g."
+ /* 7 */ ".fgrrrrgf....f."
+ /* 8 */ "........g....g."
+ /* 9 */ "mmmmmmm.r....r."
+ /* 10 */ "mmmmmmm.rt...r."
+ /* 11 */ "mmmmmmm.r...tr."
+ /* 12 */ "mmmmmmm.r....r."
+ /* 13 */ "mmmmmmm.gq..qg."
+ /* 14 */ "mmmmmmm.fgrrgf."
+ /* 15 */ "mmmmmmm........"
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".fuuuuuuuuuuuf."
+ /* 2 */ ".v....w.w....v."
+ /* 3 */ ".v...........v."
+ /* 4 */ ".vx..........v."
+ /* 5 */ ".v...........v."
+ /* 6 */ ".v......y....v."
+ /* 7 */ ".fuuuuuufx..zv."
+ /* 8 */ "........v....v."
+ /* 9 */ "mmmmmmm.v....v."
+ /* 10 */ "mmmmmmm.v....v."
+ /* 11 */ "mmmmmmm.v....v."
+ /* 12 */ "mmmmmmm.v....v."
+ /* 13 */ "mmmmmmm.v.yy.v."
+ /* 14 */ "mmmmmmm.fuuuuf."
+ /* 15 */ "mmmmmmm........"
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "nnnnnnnnnnnnnno"
+ /* 1 */ "pgggggggggggggo"
+ /* 2 */ "pgAAAAAAAAAABgo"
+ /* 3 */ "pgC.........Bgo"
+ /* 4 */ "pgC.........Bgo"
+ /* 5 */ "pgC.........Bgo"
+ /* 6 */ "pgCDDDDDDD..Bgo"
+ /* 7 */ "pggggggggC..Bgo"
+ /* 8 */ "pkkkkkkpgC..Bgo"
+ /* 9 */ "mmmmmmmpgC..Bgo"
+ /* 10 */ "mmmmmmmpgC..Bgo"
+ /* 11 */ "mmmmmmmpgC..Bgo"
+ /* 12 */ "mmmmmmmpgC..Bgo"
+ /* 13 */ "mmmmmmmpgCDDBgo"
+ /* 14 */ "mmmmmmmpggggggo"
+ /* 15 */ "mmmmmmmpkkkkkkk"
+
+ // Level 6
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".pnnnnnnnnnnno."
+ /* 2 */ ".pgggggggggggo."
+ /* 3 */ ".pgggggggggggo."
+ /* 4 */ ".pgggggggggggo."
+ /* 5 */ ".pgggggggggggo."
+ /* 6 */ ".pgggggggggggo."
+ /* 7 */ ".pkkkkkkkggggo."
+ /* 8 */ "........pggggo."
+ /* 9 */ "mmmmmmm.pggggo."
+ /* 10 */ "mmmmmmm.pggggo."
+ /* 11 */ "mmmmmmm.pggggo."
+ /* 12 */ "mmmmmmm.pggggo."
+ /* 13 */ "mmmmmmm.pggggo."
+ /* 14 */ "mmmmmmm.kkkkko."
+ /* 15 */ "mmmmmmm........"
+
+ // Level 7
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..nnnnnnnnnnn.."
+ /* 3 */ "..pgggggggggo.."
+ /* 4 */ "..pgggggggggo.."
+ /* 5 */ "..pgggggggggo.."
+ /* 6 */ "..kkkkkkkkggo.."
+ /* 7 */ ".........pggo.."
+ /* 8 */ ".........pggo.."
+ /* 9 */ "mmmmmmm..pggo.."
+ /* 10 */ "mmmmmmm..pggo.."
+ /* 11 */ "mmmmmmm..pggo.."
+ /* 12 */ "mmmmmmm..pggo.."
+ /* 13 */ "mmmmmmm..kkko.."
+ /* 14 */ "mmmmmmm........"
+ /* 15 */ "mmmmmmm........"
+
+ // Level 8
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "...pnnnnnnno..."
+ /* 4 */ "...pgggggggo..."
+ /* 5 */ "...pkkkkkkpo..."
+ /* 6 */ "..........po..."
+ /* 7 */ "..........po..."
+ /* 8 */ "..........po..."
+ /* 9 */ "mmmmmmm...po..."
+ /* 10 */ "mmmmmmm...po..."
+ /* 11 */ "mmmmmmm...po..."
+ /* 12 */ "mmmmmmm...pk..."
+ /* 13 */ "mmmmmmm........"
+ /* 14 */ "mmmmmmm........"
+ /* 15 */ "mmmmmmm........",
+
+ // Connectors:
+ "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouseL13x14
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouseL14x14:
+ // The data has been exported from the gallery Plains, area index 0, ID 4, created by Aloe_vera
+ {
+ // Size:
+ 16, 8, 16, // SizeX = 16, SizeY = 8, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ -1, 1, 0, // MinX, MinY, MinZ
+ 16, 7, 16, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 5: 0\n" /* wood */
+ "f: 67: 3\n" /* stairs */
+ "g: 17: 0\n" /* tree */
+ "h: 64: 7\n" /* wooddoorblock */
+ "i: 64: 5\n" /* wooddoorblock */
+ "j:102: 0\n" /* glasspane */
+ "k: 64:12\n" /* wooddoorblock */
+ "l: 53: 2\n" /* woodstairs */
+ "m: 19: 0\n" /* sponge */
+ "n: 53: 1\n" /* woodstairs */
+ "o: 53: 7\n" /* woodstairs */
+ "p: 53: 6\n" /* woodstairs */
+ "q: 53: 3\n" /* woodstairs */
+ "r: 53: 0\n" /* woodstairs */
+ "s: 53: 5\n" /* woodstairs */
+ "t: 53: 4\n" /* woodstairs */
+ "u: 50: 3\n" /* torch */
+ "v: 50: 2\n" /* torch */
+ "w: 50: 4\n" /* torch */
+ "x: 50: 1\n" /* torch */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmaaammmmm"
+ /* 1 */ "maaaaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaaaaam"
+ /* 8 */ "mmmmmaaaaaaaaaam"
+ /* 9 */ "mmmmmmmmaaaaaaam"
+ /* 10 */ "mmmmmmmmaaaaaaam"
+ /* 11 */ "mmmmmmmmaaaaaaam"
+ /* 12 */ "mmmmmmmmaaaaaaam"
+ /* 13 */ "mmmmmmmmaaaaaaam"
+ /* 14 */ "mmmmmmmmaaaaaaam"
+ /* 15 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "........bcd....."
+ /* 1 */ ".aaaaaaaaaaaaaa."
+ /* 2 */ ".aeeeeeeeeeeeea."
+ /* 3 */ ".aeeeeeeeeeeeea."
+ /* 4 */ ".aeeeeeeeeeeeea."
+ /* 5 */ ".aeeeeeeeeeeeea."
+ /* 6 */ ".aeeeeeeeeeeeea."
+ /* 7 */ ".aaaaaaaaeeeeea."
+ /* 8 */ ".....bfdaeeeeea."
+ /* 9 */ "mmmm....aeeeeea."
+ /* 10 */ "mmmmmmm.aeeeeea."
+ /* 11 */ "mmmmmmm.aeeeeea."
+ /* 12 */ "mmmmmmm.aeeeeea."
+ /* 13 */ "mmmmmmm.aeeeeea."
+ /* 14 */ "mmmmmmm.aaaaaaa."
+ /* 15 */ "mmmmmmm........."
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ ".geeeeeeghgeeeg."
+ /* 2 */ ".e............e."
+ /* 3 */ ".e............e."
+ /* 4 */ ".e............e."
+ /* 5 */ ".e............e."
+ /* 6 */ ".e............e."
+ /* 7 */ ".geeeeieg.....e."
+ /* 8 */ "........e.....e."
+ /* 9 */ "mmmm....e.....e."
+ /* 10 */ "mmmmmmm.e.....e."
+ /* 11 */ "mmmmmmm.e.....e."
+ /* 12 */ "mmmmmmm.e.....e."
+ /* 13 */ "mmmmmmm.e.....e."
+ /* 14 */ "mmmmmmm.geeeeeg."
+ /* 15 */ "mmmmmmm........."
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ ".gejjejjgkgjjeg."
+ /* 2 */ ".j............e."
+ /* 3 */ ".j............j."
+ /* 4 */ ".j............j."
+ /* 5 */ ".j............e."
+ /* 6 */ ".j............j."
+ /* 7 */ ".gejjekeg.....j."
+ /* 8 */ "........e.....e."
+ /* 9 */ "mmmm....j.....j."
+ /* 10 */ "mmmmmmm.j.....j."
+ /* 11 */ "mmmmmmm.e.....e."
+ /* 12 */ "mmmmmmm.j.....j."
+ /* 13 */ "mmmmmmm.j.....j."
+ /* 14 */ "mmmmmmm.gjjjjjg."
+ /* 15 */ "mmmmmmm........."
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "llllllllllllllln"
+ /* 1 */ "ogeeeeeegegeeegn"
+ /* 2 */ ".e............en"
+ /* 3 */ ".e............en"
+ /* 4 */ ".e............en"
+ /* 5 */ ".e............en"
+ /* 6 */ ".e............en"
+ /* 7 */ "pgeeeeeeg.....en"
+ /* 8 */ "qqqqqqqre.....en"
+ /* 9 */ "mmmm...re.....en"
+ /* 10 */ "mmmmmmmre.....en"
+ /* 11 */ "mmmmmmmre.....en"
+ /* 12 */ "mmmmmmmre.....en"
+ /* 13 */ "mmmmmmmre.....en"
+ /* 14 */ "mmmmmmmrgeeeeegn"
+ /* 15 */ "mmmmmmmrs.....tn"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "lllllllllllllll."
+ /* 2 */ "oeeeeeeeeeeeeen."
+ /* 3 */ ".e.........u.en."
+ /* 4 */ ".e..........ven."
+ /* 5 */ ".e......w....en."
+ /* 6 */ "peeeeeeeee...en."
+ /* 7 */ "qqqqqqqqrex..en."
+ /* 8 */ "........re...en."
+ /* 9 */ "mmmm....re...en."
+ /* 10 */ "mmmmmmm.re...en."
+ /* 11 */ "mmmmmmm.re...en."
+ /* 12 */ "mmmmmmm.re...en."
+ /* 13 */ "mmmmmmm.re...en."
+ /* 14 */ "mmmmmmm.reeeeen."
+ /* 15 */ "mmmmmmm.rs...tn."
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "llllllllllllln.."
+ /* 3 */ "oeeeeeeeeeeeen.."
+ /* 4 */ ".ex.........en.."
+ /* 5 */ "peeeeeeeeee.en.."
+ /* 6 */ "qqqqqqqqqre.en.."
+ /* 7 */ ".........re.en.."
+ /* 8 */ ".........re.en.."
+ /* 9 */ "mmmm.....re.en.."
+ /* 10 */ "mmmmmmm..re.en.."
+ /* 11 */ "mmmmmmm..re.en.."
+ /* 12 */ "mmmmmmm..re.en.."
+ /* 13 */ "mmmmmmm..rewen.."
+ /* 14 */ "mmmmmmm..reeen.."
+ /* 15 */ "mmmmmmm..rs.tn.."
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "lllllllllllll..."
+ /* 4 */ "eeeeeeeeeeeen..."
+ /* 5 */ "qqqqqqqqqqren..."
+ /* 6 */ "..........ren..."
+ /* 7 */ "..........ren..."
+ /* 8 */ "..........ren..."
+ /* 9 */ "mmmm......ren..."
+ /* 10 */ "mmmmmmm...ren..."
+ /* 11 */ "mmmmmmm...ren..."
+ /* 12 */ "mmmmmmm...ren..."
+ /* 13 */ "mmmmmmm...ren..."
+ /* 14 */ "mmmmmmm...ren..."
+ /* 15 */ "mmmmmmm...ren...",
+
+ // Connectors:
+ "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouseL14x14
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouseL9x9:
+ // The data has been exported from the gallery Plains, area index 42, ID 93, created by xoft
+ {
+ // Size:
+ 11, 7, 11, // SizeX = 11, SizeY = 7, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 11, 6, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 7\n" /* wooddoorblock */
+ "h:102: 0\n" /* glasspane */
+ "i: 64:12\n" /* wooddoorblock */
+ "j: 53: 2\n" /* woodstairs */
+ "k: 53: 7\n" /* woodstairs */
+ "l: 53: 1\n" /* woodstairs */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 3\n" /* torch */
+ "o: 50: 4\n" /* torch */
+ "p: 53: 6\n" /* woodstairs */
+ "q: 50: 1\n" /* torch */
+ "r: 50: 2\n" /* torch */
+ "s: 53: 3\n" /* woodstairs */
+ "t: 53: 0\n" /* woodstairs */
+ "u: 53: 5\n" /* woodstairs */
+ "v: 53: 4\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "mmmmmaaaaam"
+ /* 7 */ "mmmmmaaaaam"
+ /* 8 */ "mmmmmaaaaam"
+ /* 9 */ "mmmmmaaaaam"
+ /* 10 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "....bcd...."
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".aaaaaaaaa."
+ /* 3 */ ".aaaaaaaaa."
+ /* 4 */ ".aaaaaaaaa."
+ /* 5 */ ".aaaaaaaaa."
+ /* 6 */ ".....aaaaa."
+ /* 7 */ "mmmm.aaaaa."
+ /* 8 */ "mmmm.aaaaa."
+ /* 9 */ "mmmm.aaaaa."
+ /* 10 */ "mmmm......."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".efffgfffe."
+ /* 2 */ ".f.......f."
+ /* 3 */ ".f.......f."
+ /* 4 */ ".f.......f."
+ /* 5 */ ".efffe...f."
+ /* 6 */ ".....f...f."
+ /* 7 */ "mmmm.f...f."
+ /* 8 */ "mmmm.f...f."
+ /* 9 */ "mmmm.efffe."
+ /* 10 */ "mmmm......."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".ehhfifhhe."
+ /* 2 */ ".h.......h."
+ /* 3 */ ".h.......h."
+ /* 4 */ ".h.......h."
+ /* 5 */ ".ehhhe...f."
+ /* 6 */ ".....h...h."
+ /* 7 */ "mmmm.h...h."
+ /* 8 */ "mmmm.h...h."
+ /* 9 */ "mmmm.ehhhe."
+ /* 10 */ "mmmm......."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "jjjjjjjjjjj"
+ /* 1 */ "kfffffffffl"
+ /* 2 */ ".f..n.n..fl"
+ /* 3 */ ".f.......fl"
+ /* 4 */ ".f...o...fl"
+ /* 5 */ "pfffffq.rfl"
+ /* 6 */ "sssssf...fl"
+ /* 7 */ "mmmmtf...fl"
+ /* 8 */ "mmmmtf...fl"
+ /* 9 */ "mmmmtfffffl"
+ /* 10 */ "mmmmtu...vl"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "jjjjjjjjjl."
+ /* 2 */ "kffffffffl."
+ /* 3 */ ".f......fl."
+ /* 4 */ "pffffff.fl."
+ /* 5 */ "ssssssf.fl."
+ /* 6 */ ".....tf.fl."
+ /* 7 */ "mmmm.tf.fl."
+ /* 8 */ "mmmm.tf.fl."
+ /* 9 */ "mmmm.tfffl."
+ /* 10 */ "mmmm.tu.vl."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "jjjjjjjjj.."
+ /* 3 */ "ffffffffl.."
+ /* 4 */ "sssssstfl.."
+ /* 5 */ "......tfl.."
+ /* 6 */ "......tfl.."
+ /* 7 */ "mmmm..tfl.."
+ /* 8 */ "mmmm..tfl.."
+ /* 9 */ "mmmm..tfl.."
+ /* 10 */ "mmmm..tfl..",
+
+ // Connectors:
+ "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouseL9x9
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenHouseU13x9:
+ // The data has been exported from the gallery Plains, area index 43, ID 94, created by xoft
+ {
+ // Size:
+ 15, 7, 11, // SizeX = 15, SizeY = 7, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 15, 6, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 64: 7\n" /* wooddoorblock */
+ "h:102: 0\n" /* glasspane */
+ "i: 64:12\n" /* wooddoorblock */
+ "j: 53: 2\n" /* woodstairs */
+ "k: 53: 0\n" /* woodstairs */
+ "l: 53: 1\n" /* woodstairs */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 3\n" /* torch */
+ "o: 50: 4\n" /* torch */
+ "p: 50: 2\n" /* torch */
+ "q: 50: 1\n" /* torch */
+ "r: 53: 3\n" /* woodstairs */
+ "s: 53: 5\n" /* woodstairs */
+ "t: 53: 4\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmmaaammmmmm"
+ /* 1 */ "maaaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaaam"
+ /* 6 */ "maaaaammmaaaaam"
+ /* 7 */ "maaaaammmaaaaam"
+ /* 8 */ "maaaaammmaaaaam"
+ /* 9 */ "maaaaammmaaaaam"
+ /* 10 */ "mmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "......bcd......"
+ /* 1 */ ".aaaaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaaaa."
+ /* 6 */ ".aaaaa...aaaaa."
+ /* 7 */ ".aaaaa...aaaaa."
+ /* 8 */ ".aaaaa...aaaaa."
+ /* 9 */ ".aaaaa...aaaaa."
+ /* 10 */ "..............."
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".efffffgfffffe."
+ /* 2 */ ".f...........f."
+ /* 3 */ ".f...........f."
+ /* 4 */ ".f...........f."
+ /* 5 */ ".f...efffe...f."
+ /* 6 */ ".f...f...f...f."
+ /* 7 */ ".f...f...f...f."
+ /* 8 */ ".f...f...f...f."
+ /* 9 */ ".efffe...efffe."
+ /* 10 */ "..............."
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".ehhhhfifhhhhe."
+ /* 2 */ ".h...........h."
+ /* 3 */ ".h...........h."
+ /* 4 */ ".h...........h."
+ /* 5 */ ".f...ehhhe...f."
+ /* 6 */ ".h...h...h...h."
+ /* 7 */ ".h...h...h...h."
+ /* 8 */ ".h...h...h...h."
+ /* 9 */ ".ehhhe...ehhhe."
+ /* 10 */ "..............."
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "jjjjjjjjjjjjjjj"
+ /* 1 */ "kfffffffffffffl"
+ /* 2 */ "kf....n.n....fl"
+ /* 3 */ "kf...........fl"
+ /* 4 */ "kf...o...o...fl"
+ /* 5 */ "kf..pfffffq..fl"
+ /* 6 */ "kf...frrrf...fl"
+ /* 7 */ "kf...fl.kf...fl"
+ /* 8 */ "kf...fl.kf...fl"
+ /* 9 */ "kfffffl.kfffffl"
+ /* 10 */ "ks...tl.ks...tl"
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".jjjjjjjjjjjjl."
+ /* 2 */ ".kfffffffffffl."
+ /* 3 */ ".kfffffffffffl."
+ /* 4 */ ".kfffffffffffl."
+ /* 5 */ ".kffflrrrrfffl."
+ /* 6 */ ".kfffl...kfffl."
+ /* 7 */ ".kfffl...kfffl."
+ /* 8 */ ".kfffl...kfffl."
+ /* 9 */ ".kfffl...kfffl."
+ /* 10 */ ".ks.tl...ks.tl."
+
+ // Level 6
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..kjjjjjjjjjj.."
+ /* 3 */ "..kfffffffffl.."
+ /* 4 */ "..kflrrrrrkfl.."
+ /* 5 */ "..kfl.....kfl.."
+ /* 6 */ "..kfl.....kfl.."
+ /* 7 */ "..kfl.....kfl.."
+ /* 8 */ "..kfl.....kfl.."
+ /* 9 */ "..kfl.....kfl.."
+ /* 10 */ "..kfl.....kfl..",
+
+ // Connectors:
+ "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenHouseU13x9
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenMill5x5:
+ // The data has been exported from the gallery Plains, area index 60, ID 111, created by Aloe_vera
+ {
+ // Size:
+ 9, 17, 13, // SizeX = 9, SizeY = 17, SizeZ = 13
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 8, 16, 12, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 2\n" /* stairs */
+ "c: 67: 1\n" /* stairs */
+ "d: 67: 3\n" /* stairs */
+ "e: 17: 0\n" /* tree */
+ "f: 5: 0\n" /* wood */
+ "g: 54: 4\n" /* chest */
+ "h:154: 4\n" /* hopper */
+ "i: 64: 4\n" /* wooddoorblock */
+ "j:102: 0\n" /* glasspane */
+ "k: 85: 0\n" /* fence */
+ "l: 64:12\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 2\n" /* torch */
+ "o: 35: 0\n" /* wool */
+ "p: 17: 4\n" /* tree */
+ "q: 17: 8\n" /* tree */
+ "r: 53: 2\n" /* woodstairs */
+ "s: 53: 7\n" /* woodstairs */
+ "t: 53: 6\n" /* woodstairs */
+ "u: 53: 3\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmmmm"
+ /* 1 */ "mmmmmmmmm"
+ /* 2 */ "mmmmmmmmm"
+ /* 3 */ "mmmmmmmmm"
+ /* 4 */ "maaaaammm"
+ /* 5 */ "maaaaaamm"
+ /* 6 */ "maaaaaamm"
+ /* 7 */ "maaaaaamm"
+ /* 8 */ "maaaaammm"
+ /* 9 */ "mmmmmmmmm"
+ /* 10 */ "mmmmmmmmm"
+ /* 11 */ "mmmmmmmmm"
+ /* 12 */ "mmmmmmmmm"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ ".aaaaa..."
+ /* 5 */ ".aaaaab.."
+ /* 6 */ ".aaaaac.."
+ /* 7 */ ".aaaaad.."
+ /* 8 */ ".aaaaa..."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ ".efffe..."
+ /* 5 */ ".f...f..."
+ /* 6 */ ".fgh.i..."
+ /* 7 */ ".f...f..."
+ /* 8 */ ".efffe..."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ ".ejjje..."
+ /* 5 */ ".j...f..."
+ /* 6 */ ".j.k.l..."
+ /* 7 */ ".j...f..."
+ /* 8 */ ".ejjje..."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ ".efffe..."
+ /* 5 */ ".f..nf..."
+ /* 6 */ ".f.k.f..."
+ /* 7 */ ".f..nf..k"
+ /* 8 */ ".efffe..o"
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ ".epppe..."
+ /* 5 */ ".q...q..."
+ /* 6 */ ".q.k.q..."
+ /* 7 */ ".q...q..k"
+ /* 8 */ ".epppe..o"
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 6
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ ".efffe..."
+ /* 5 */ ".f...f..."
+ /* 6 */ ".f.k.f..k"
+ /* 7 */ ".f...f..o"
+ /* 8 */ ".efffe..o"
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 7
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ ".ejjje..."
+ /* 5 */ ".j...j..."
+ /* 6 */ ".j.k.j..k"
+ /* 7 */ ".j...j..o"
+ /* 8 */ ".ejjje..."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 8
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.o"
+ /* 1 */ "mmmmmmm.o"
+ /* 2 */ "mmmmmmm.o"
+ /* 3 */ "........."
+ /* 4 */ ".efffe..."
+ /* 5 */ ".f...f..k"
+ /* 6 */ ".f.k.f..o"
+ /* 7 */ ".f...f..o"
+ /* 8 */ ".efffe..."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 9
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.k"
+ /* 1 */ "mmmmmmm.k"
+ /* 2 */ "mmmmmmm.o"
+ /* 3 */ "........o"
+ /* 4 */ ".epppe..o"
+ /* 5 */ ".q...q..k"
+ /* 6 */ ".q.k.q..o"
+ /* 7 */ ".q...q..k"
+ /* 8 */ ".epppe..k"
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 10
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.k"
+ /* 3 */ "rrrrrrr.k"
+ /* 4 */ "sfffffs.o"
+ /* 5 */ ".f...f..o"
+ /* 6 */ ".f.kppppp"
+ /* 7 */ ".f...f..o"
+ /* 8 */ "tffffft.o"
+ /* 9 */ "uuuuuuu.k"
+ /* 10 */ "mmmmmmm.k"
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 11
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ "rrrrrrr.k"
+ /* 5 */ "sfffffs.k"
+ /* 6 */ ".f...f..o"
+ /* 7 */ "tffffft.k"
+ /* 8 */ "uuuuuuu.o"
+ /* 9 */ "........o"
+ /* 10 */ "mmmmmmm.o"
+ /* 11 */ "mmmmmmm.k"
+ /* 12 */ "mmmmmmm.k"
+
+ // Level 12
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ "........."
+ /* 5 */ "rrrrrrr.o"
+ /* 6 */ "fffffff.o"
+ /* 7 */ "uuuuuuu.k"
+ /* 8 */ "........."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.o"
+ /* 11 */ "mmmmmmm.o"
+ /* 12 */ "mmmmmmm.o"
+
+ // Level 13
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ "........."
+ /* 5 */ "........o"
+ /* 6 */ "........k"
+ /* 7 */ "........."
+ /* 8 */ "........."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 14
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ "........o"
+ /* 5 */ "........o"
+ /* 6 */ "........k"
+ /* 7 */ "........."
+ /* 8 */ "........."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 15
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ "........o"
+ /* 5 */ "........k"
+ /* 6 */ "........."
+ /* 7 */ "........."
+ /* 8 */ "........."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm.."
+
+ // Level 16
+ /* z\x* 012345678 */
+ /* 0 */ "mmmmmmm.."
+ /* 1 */ "mmmmmmm.."
+ /* 2 */ "mmmmmmm.."
+ /* 3 */ "........."
+ /* 4 */ "........o"
+ /* 5 */ "........k"
+ /* 6 */ "........."
+ /* 7 */ "........."
+ /* 8 */ "........."
+ /* 9 */ "........."
+ /* 10 */ "mmmmmmm.."
+ /* 11 */ "mmmmmmm.."
+ /* 12 */ "mmmmmmm..",
+
+ // Connectors:
+ "-1: 8, 1, 6: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenMill5x5
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WoodenStables:
+ // The data has been exported from the gallery Plains, area index 55, ID 106, created by Aloe_vera
+ {
+ // Size:
+ 15, 9, 9, // SizeX = 15, SizeY = 9, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, -1, 0, // MinX, MinY, MinZ
+ 15, 8, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 4: 0\n" /* cobblestone */
+ "b: 67: 0\n" /* stairs */
+ "c: 67: 2\n" /* stairs */
+ "d: 67: 1\n" /* stairs */
+ "e: 3: 0\n" /* dirt */
+ "f: 17: 0\n" /* tree */
+ "g:107: 0\n" /* fencegate */
+ "h:107: 4\n" /* fencegate */
+ "i: 5: 0\n" /* wood */
+ "j:107: 6\n" /* fencegate */
+ "k: 85: 0\n" /* fence */
+ "l:170: 0\n" /* haybale */
+ "m: 19: 0\n" /* sponge */
+ "n:170: 4\n" /* haybale */
+ "o:170: 8\n" /* haybale */
+ "p: 50: 1\n" /* torch */
+ "q: 50: 2\n" /* torch */
+ "r: 53: 2\n" /* woodstairs */
+ "s: 53: 7\n" /* woodstairs */
+ "t: 53: 6\n" /* woodstairs */
+ "u: 53: 3\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "maaaaaaaaaaaaam"
+ /* 1 */ "maaaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaaaam"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ ".bcccccccccccd."
+ /* 1 */ ".aaaaaaaaaaaaa."
+ /* 2 */ ".aeeeeeeeeeeea."
+ /* 3 */ ".aeeeeeeeeeeea."
+ /* 4 */ ".aeeeeeeeeeeea."
+ /* 5 */ ".aeeeeeeeeeeea."
+ /* 6 */ ".aeeeeeeeeeeea."
+ /* 7 */ ".aaaaaaaaaaaaa."
+ /* 8 */ "..............."
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".fghgighgigjgf."
+ /* 2 */ ".k...k...k...k."
+ /* 3 */ ".k...k...k...k."
+ /* 4 */ ".k...k...k...k."
+ /* 5 */ ".k...k...k...k."
+ /* 6 */ ".kl..k..nko..k."
+ /* 7 */ ".fkkkikkkikkkf."
+ /* 8 */ "..............."
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".f...i...i...f."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "..............."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ ".f...i...i...f."
+ /* 8 */ "..............."
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".fp.qip.qip.qf."
+ /* 2 */ "..............."
+ /* 3 */ "..............."
+ /* 4 */ "..............."
+ /* 5 */ "..............."
+ /* 6 */ "..............."
+ /* 7 */ ".f...i...i...f."
+ /* 8 */ "..............."
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "rrrrrrrrrrrrrrr"
+ /* 1 */ "siiiiiiiiiiiiis"
+ /* 2 */ ".i...........i."
+ /* 3 */ ".i...........i."
+ /* 4 */ ".i...........i."
+ /* 5 */ ".i...........i."
+ /* 6 */ ".i...........i."
+ /* 7 */ "tiiiiiiiiiiiiit"
+ /* 8 */ "uuuuuuuuuuuuuuu"
+
+ // Level 6
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "rrrrrrrrrrrrrrr"
+ /* 2 */ "siiiiiiiiiiiiis"
+ /* 3 */ ".i...........i."
+ /* 4 */ ".i...........i."
+ /* 5 */ ".i...........i."
+ /* 6 */ "tiiiiiiiiiiiiit"
+ /* 7 */ "uuuuuuuuuuuuuuu"
+ /* 8 */ "..............."
+
+ // Level 7
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "rrrrrrrrrrrrrrr"
+ /* 3 */ "siiiiiiiiiiiiis"
+ /* 4 */ ".i...........i."
+ /* 5 */ "tiiiiiiiiiiiiit"
+ /* 6 */ "uuuuuuuuuuuuuuu"
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+
+ // Level 8
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "rrrrrrrrrrrrrrr"
+ /* 4 */ "iiiiiiiiiiiiiii"
+ /* 5 */ "uuuuuuuuuuuuuuu"
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "...............",
+
+ // Connectors:
+ "-1: 7, 1, -1: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // WoodenStables
+}; // g_PlainsVillagePrefabs
+
+
+
+
+
+
+const cPrefab::sDef g_PlainsVillageStartingPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // CobbleWell4x4:
+ // The data has been exported from the gallery Plains, area index 1, ID 5, created by Aloe_vera
+ {
+ // Size:
+ 4, 13, 4, // SizeX = 4, SizeY = 13, SizeZ = 4
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 3, 12, 3, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 8: 0\n" /* water */
+ "d: 85: 0\n" /* fence */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123 */
+ /* 0 */ "aaaa"
+ /* 1 */ "aaaa"
+ /* 2 */ "aaaa"
+ /* 3 */ "aaaa"
+
+ // Level 1
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 2
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 3
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 4
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 5
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 6
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 7
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 8
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 9
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "b..b"
+ /* 2 */ "b..b"
+ /* 3 */ "bbbb"
+
+ // Level 10
+ /* z\x* 0123 */
+ /* 0 */ "d..d"
+ /* 1 */ "...."
+ /* 2 */ "...."
+ /* 3 */ "d..d"
+
+ // Level 11
+ /* z\x* 0123 */
+ /* 0 */ "d..d"
+ /* 1 */ "...."
+ /* 2 */ "...."
+ /* 3 */ "d..d"
+
+ // Level 12
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bbbb"
+ /* 2 */ "bbbb"
+ /* 3 */ "bbbb",
+
+ // Connectors:
+ "2: 1, 9, 3: 3\n" /* Type 2, direction Z+ */
+ "2: 2, 9, 0: 2\n" /* Type 2, direction Z- */
+ "2: 0, 9, 1: 4\n" /* Type 2, direction X- */
+ "2: 3, 9, 2: 5\n" /* Type 2, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // CobbleWell4x4
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MineEntrance:
+ // The data has been exported from the gallery Plains, area index 138, ID 446, created by STR_Warrior
+ {
+ // Size:
+ 7, 38, 7, // SizeX = 7, SizeY = 38, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 37, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 77: 2\n" /* stonebutton */
+ "c: 66: 6\n" /* tracks */
+ "d: 27: 1\n" /* poweredrail */
+ "e: 66: 5\n" /* tracks */
+ "f: 66: 9\n" /* tracks */
+ "g: 66: 2\n" /* tracks */
+ "h: 50: 4\n" /* torch */
+ "i: 66: 4\n" /* tracks */
+ "j: 66: 8\n" /* tracks */
+ "k: 66: 3\n" /* tracks */
+ "l: 66: 7\n" /* tracks */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 2\n" /* torch */
+ "o: 4: 0\n" /* cobblestone */
+ "p: 2: 0\n" /* grass */
+ "q: 13: 0\n" /* gravel */
+ "r: 53: 2\n" /* woodstairs */
+ "s: 77: 1\n" /* stonebutton */
+ "t: 27: 0\n" /* poweredrail */
+ "u: 53: 7\n" /* woodstairs */
+ "v: 53: 6\n" /* woodstairs */
+ "w: 53: 3\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "maaaaam"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mm.abam"
+ /* 2 */ "mmcddam"
+ /* 3 */ "mae..am"
+ /* 4 */ "mmaa.mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "mm...mm"
+ /* 1 */ "mm.a.mm"
+ /* 2 */ "mm...mm"
+ /* 3 */ "ma..aam"
+ /* 4 */ "mmfgamm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "mm.h.mm"
+ /* 1 */ "mm.a.mm"
+ /* 2 */ "mm.aamm"
+ /* 3 */ "ma..iam"
+ /* 4 */ "mm..jmm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmaklmm"
+ /* 3 */ "maa..am"
+ /* 4 */ "mm...mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmc..mm"
+ /* 3 */ "mae.nam"
+ /* 4 */ "mmaa.mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm...mm"
+ /* 3 */ "ma..aam"
+ /* 4 */ "mmfgamm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm.aamm"
+ /* 3 */ "ma..iam"
+ /* 4 */ "mm..jmm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 8
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmaklmm"
+ /* 3 */ "maa..am"
+ /* 4 */ "mm...mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 9
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmc..mm"
+ /* 3 */ "mae.nam"
+ /* 4 */ "mmaa.mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 10
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm...mm"
+ /* 3 */ "ma..aam"
+ /* 4 */ "mmfgamm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 11
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm.aamm"
+ /* 3 */ "ma..iam"
+ /* 4 */ "mm..jmm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 12
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmaklmm"
+ /* 3 */ "maa..am"
+ /* 4 */ "mm...mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 13
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmc..mm"
+ /* 3 */ "mae.nam"
+ /* 4 */ "mmaa.mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 14
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm...mm"
+ /* 3 */ "ma..aam"
+ /* 4 */ "mmfgamm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 15
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm.aamm"
+ /* 3 */ "ma..iam"
+ /* 4 */ "mm..jmm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 16
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmaklmm"
+ /* 3 */ "maa..am"
+ /* 4 */ "mm...mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 17
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmc..mm"
+ /* 3 */ "mae.nam"
+ /* 4 */ "mmaa.mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 18
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm...mm"
+ /* 3 */ "ma..aam"
+ /* 4 */ "mmfgamm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 19
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm.aamm"
+ /* 3 */ "ma..iam"
+ /* 4 */ "mm..jmm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 20
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmaklmm"
+ /* 3 */ "maa..am"
+ /* 4 */ "mm...mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 21
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmc..mm"
+ /* 3 */ "mae.nam"
+ /* 4 */ "mmaa.mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 22
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm...mm"
+ /* 3 */ "ma..aam"
+ /* 4 */ "mmfgamm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 23
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm.aamm"
+ /* 3 */ "ma..iam"
+ /* 4 */ "mm..jmm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 24
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmaklmm"
+ /* 3 */ "maa..am"
+ /* 4 */ "mm...mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 25
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmc..mm"
+ /* 3 */ "mae.nam"
+ /* 4 */ "mmaa.mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 26
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm...mm"
+ /* 3 */ "ma..aam"
+ /* 4 */ "mmfgamm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 27
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mm.aamm"
+ /* 3 */ "ma..iam"
+ /* 4 */ "mm..jmm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 28
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmaklmm"
+ /* 3 */ "maa..am"
+ /* 4 */ "mm...mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 29
+ /* z\x* 0123456 */
+ /* 0 */ "mmmmmmm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "mmc..mm"
+ /* 3 */ "mae.nam"
+ /* 4 */ "mmaa.mm"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmmmmmm"
+
+ // Level 30
+ /* z\x* 0123456 */
+ /* 0 */ "mmooomm"
+ /* 1 */ "mmmammm"
+ /* 2 */ "om...mo"
+ /* 3 */ "oa..aao"
+ /* 4 */ "omfgamo"
+ /* 5 */ "mmmammm"
+ /* 6 */ "mmooomm"
+
+ // Level 31
+ /* z\x* 0123456 */
+ /* 0 */ "ppqqqpp"
+ /* 1 */ "paaaaap"
+ /* 2 */ "qa.aaaq"
+ /* 3 */ "qa..iaq"
+ /* 4 */ "qa..jaq"
+ /* 5 */ "paaaaap"
+ /* 6 */ "ppqqqpp"
+
+ // Level 32
+ /* z\x* 0123456 */
+ /* 0 */ "...r..."
+ /* 1 */ ".astba."
+ /* 2 */ "...fl.."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ ".a...a."
+ /* 6 */ "......."
+
+ // Level 33
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".a...a."
+ /* 2 */ "......."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ ".a...a."
+ /* 6 */ "......."
+
+ // Level 34
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".a...a."
+ /* 2 */ "......."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ ".a...a."
+ /* 6 */ "......."
+
+ // Level 35
+ /* z\x* 0123456 */
+ /* 0 */ "rrrrrrr"
+ /* 1 */ "uaaaaau"
+ /* 2 */ ".a...a."
+ /* 3 */ ".a...a."
+ /* 4 */ ".a...a."
+ /* 5 */ "vaaaaav"
+ /* 6 */ "wwwwwww"
+
+ // Level 36
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "rrrrrrr"
+ /* 2 */ "uaaaaau"
+ /* 3 */ ".aaaaa."
+ /* 4 */ "vaaaaav"
+ /* 5 */ "wwwwwww"
+ /* 6 */ "......."
+
+ // Level 37
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "......."
+ /* 2 */ "rrrrrrr"
+ /* 3 */ "aaaaaaa"
+ /* 4 */ "wwwwwww"
+ /* 5 */ "......."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "2: 6, 32, 3: 5\n" /* Type 2, direction X+ */
+ "2: 3, 32, 6: 3\n" /* Type 2, direction Z+ */
+ "2: 0, 32, 3: 4\n" /* Type 2, direction X- */
+ "2: 3, 32, 0: 2\n" /* Type 2, direction Z- */
+ "3: 3, 1, 0: 2\n" /* Type 3, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // MineEntrance
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // RoofedWell:
+ // The data has been exported from the gallery Plains, area index 119, ID 271, created by STR_Warrior
+ {
+ // Size:
+ 7, 15, 7, // SizeX = 7, SizeY = 15, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 14, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 4: 0\n" /* cobblestone */
+ "c: 8: 0\n" /* water */
+ "d: 3: 0\n" /* dirt */
+ "e: 2: 0\n" /* grass */
+ "f: 13: 0\n" /* gravel */
+ "g:118: 3\n" /* cauldronblock */
+ "h: 85: 0\n" /* fence */
+ "i: 53: 2\n" /* woodstairs */
+ "j: 53: 7\n" /* woodstairs */
+ "k: 5: 0\n" /* wood */
+ "l: 53: 4\n" /* woodstairs */
+ "m: 19: 0\n" /* sponge */
+ "n: 53: 5\n" /* woodstairs */
+ "o: 53: 6\n" /* woodstairs */
+ "p: 53: 3\n" /* woodstairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "aaaaaaa"
+ /* 2 */ "aaaaaaa"
+ /* 3 */ "aaaaaaa"
+ /* 4 */ "aaaaaaa"
+ /* 5 */ "aaaaaaa"
+ /* 6 */ "aaaaaaa"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "abbbbba"
+ /* 2 */ "abcccba"
+ /* 3 */ "abcccba"
+ /* 4 */ "abcccba"
+ /* 5 */ "abbbbba"
+ /* 6 */ "aaaaaaa"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "abbbbba"
+ /* 2 */ "abcccba"
+ /* 3 */ "abcccba"
+ /* 4 */ "abcccba"
+ /* 5 */ "abbbbba"
+ /* 6 */ "aaaaaaa"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "abbbbba"
+ /* 2 */ "abcccba"
+ /* 3 */ "abcccba"
+ /* 4 */ "abcccba"
+ /* 5 */ "abbbbba"
+ /* 6 */ "aaaaaaa"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "abbbbba"
+ /* 2 */ "abcccba"
+ /* 3 */ "abcccba"
+ /* 4 */ "abcccba"
+ /* 5 */ "abbbbba"
+ /* 6 */ "aaaaaaa"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "ddddddd"
+ /* 1 */ "dbbbbbd"
+ /* 2 */ "dbcccbd"
+ /* 3 */ "dbcccbd"
+ /* 4 */ "dbcccbd"
+ /* 5 */ "dbbbbbd"
+ /* 6 */ "ddddddd"
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "ddddddd"
+ /* 1 */ "dbbbbbd"
+ /* 2 */ "dbcccbd"
+ /* 3 */ "dbcccbd"
+ /* 4 */ "dbcccbd"
+ /* 5 */ "dbbbbbd"
+ /* 6 */ "ddddddd"
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "ddddddd"
+ /* 1 */ "dbbbbbd"
+ /* 2 */ "dbcccbd"
+ /* 3 */ "dbcccbd"
+ /* 4 */ "dbcccbd"
+ /* 5 */ "dbbbbbd"
+ /* 6 */ "ddddddd"
+
+ // Level 8
+ /* z\x* 0123456 */
+ /* 0 */ "eefffee"
+ /* 1 */ "ebbbbbe"
+ /* 2 */ "fbcccbf"
+ /* 3 */ "fbcccbf"
+ /* 4 */ "fbcccbf"
+ /* 5 */ "ebbbbbe"
+ /* 6 */ "eefffee"
+
+ // Level 9
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".bbbbb."
+ /* 2 */ ".b...b."
+ /* 3 */ ".b.g.b."
+ /* 4 */ ".b...b."
+ /* 5 */ ".bbbbb."
+ /* 6 */ "......."
+
+ // Level 10
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".h...h."
+ /* 2 */ "......."
+ /* 3 */ "...h..."
+ /* 4 */ "......."
+ /* 5 */ ".h...h."
+ /* 6 */ "......."
+
+ // Level 11
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".h...h."
+ /* 2 */ "......."
+ /* 3 */ "...h..."
+ /* 4 */ "......."
+ /* 5 */ ".h...h."
+ /* 6 */ "......."
+
+ // Level 12
+ /* z\x* 0123456 */
+ /* 0 */ "iiiiiii"
+ /* 1 */ "jkjjjkj"
+ /* 2 */ ".l...n."
+ /* 3 */ ".l.h.n."
+ /* 4 */ ".l...n."
+ /* 5 */ "okoooko"
+ /* 6 */ "ppppppp"
+
+ // Level 13
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "iiiiiii"
+ /* 2 */ "jkjjjkj"
+ /* 3 */ ".k.h.k."
+ /* 4 */ "okoooko"
+ /* 5 */ "ppppppp"
+ /* 6 */ "......."
+
+ // Level 14
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "......."
+ /* 2 */ "iiiiiii"
+ /* 3 */ "kkkkkkk"
+ /* 4 */ "ppppppp"
+ /* 5 */ "......."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "2: 0, 9, 3: 4\n" /* Type 2, direction X- */
+ "2: 3, 9, 6: 3\n" /* Type 2, direction Z+ */
+ "2: 6, 9, 3: 5\n" /* Type 2, direction X+ */
+ "2: 3, 9, 0: 2\n" /* Type 2, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // RoofedWell
+};
+
+
+
+
+
+// The prefab counts:
+
+const size_t g_PlainsVillagePrefabsCount = ARRAYCOUNT(g_PlainsVillagePrefabs);
+
+const size_t g_PlainsVillageStartingPrefabsCount = ARRAYCOUNT(g_PlainsVillageStartingPrefabs);
+
diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.h b/src/Generating/Prefabs/PlainsVillagePrefabs.h
new file mode 100644
index 000000000..087783b1e
--- /dev/null
+++ b/src/Generating/Prefabs/PlainsVillagePrefabs.h
@@ -0,0 +1,15 @@
+
+// PlainsVillagePrefabs.h
+
+// Declares the prefabs in the group PlainsVillage
+
+#include "../Prefab.h"
+
+
+
+
+
+extern const cPrefab::sDef g_PlainsVillagePrefabs[];
+extern const cPrefab::sDef g_PlainsVillageStartingPrefabs[];
+extern const size_t g_PlainsVillagePrefabsCount;
+extern const size_t g_PlainsVillageStartingPrefabsCount;
diff --git a/src/Generating/Prefabs/RainbowRoadPrefabs.cpp b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp
new file mode 100644
index 000000000..bf7b1b096
--- /dev/null
+++ b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp
@@ -0,0 +1,1406 @@
+
+// RainbowRoadPrefabs.cpp
+
+// Defines the prefabs in the group RainbowRoad
+
+// NOTE: This file has been generated automatically by GalExport!
+// Any manual changes will be overwritten by the next automatic export!
+
+#include "Globals.h"
+#include "RainbowRoadPrefabs.h"
+
+
+
+
+
+const cPrefab::sDef g_RainbowRoadPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // CurveDouble:
+ // The data has been exported from the gallery Cube, area index 89, ID 467, created by Aloe_vera
+ {
+ // Size:
+ 14, 1, 14, // SizeX = 14, SizeY = 1, SizeZ = 14
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 13, 2, 13, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:11\n" /* wool */
+ "b: 35: 3\n" /* wool */
+ "c: 35: 5\n" /* wool */
+ "d: 35: 4\n" /* wool */
+ "e: 35: 1\n" /* wool */
+ "f: 35:14\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "aaaaaa........"
+ /* 1 */ "bbbbbba......."
+ /* 2 */ "cccccbbaaa...."
+ /* 3 */ "dddddccbbaa..."
+ /* 4 */ "eeeeeddccbaa.."
+ /* 5 */ "fffffeddccba.."
+ /* 6 */ "ffffffeedcbaa."
+ /* 7 */ "eeeefffeddcba."
+ /* 8 */ "dddeefffedcbba"
+ /* 9 */ "cccddefffedcba"
+ /* 10 */ "bbccdeeffedcba"
+ /* 11 */ "abbccdeffedcba"
+ /* 12 */ ".abbcdeffedcba"
+ /* 13 */ "..abcdeffedcba",
+
+ // Connectors:
+ "2: 2, 1, 13: 3\n" /* Type 2, direction Z+ */
+ "2: 0, 1, 0: 4\n" /* Type 2, direction X- */
+ "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */
+ "-2: 13, 1, 13: 3\n" /* Type -2, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CurveDouble
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CurveDownFromTopSingle:
+ // The data has been exported from the gallery Cube, area index 100, ID 478, created by Aloe_vera
+ {
+ // Size:
+ 11, 8, 11, // SizeX = 11, SizeY = 8, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 10, 9, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:14\n" /* wool */
+ "b: 35: 5\n" /* wool */
+ "c: 35: 4\n" /* wool */
+ "d: 35: 1\n" /* wool */
+ "e: 35:11\n" /* wool */
+ "f: 35: 3\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ "..........."
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "..........a"
+ /* 9 */ ".......bcda"
+ /* 10 */ ".....efbcda"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ "..........."
+ /* 6 */ "........cda"
+ /* 7 */ ".......bcda"
+ /* 8 */ ".......bcd."
+ /* 9 */ ".....ef...."
+ /* 10 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ ".........a."
+ /* 5 */ ".......cdda"
+ /* 6 */ "......bc..."
+ /* 7 */ "......b...."
+ /* 8 */ ".....ff...."
+ /* 9 */ "....ee....."
+ /* 10 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "........aa."
+ /* 4 */ "......ccd.."
+ /* 5 */ ".....bb...."
+ /* 6 */ ".....f....."
+ /* 7 */ "....ef....."
+ /* 8 */ "....e......"
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "......daa.."
+ /* 3 */ ".....ccd..."
+ /* 4 */ "....bb....."
+ /* 5 */ "....f......"
+ /* 6 */ "...ef......"
+ /* 7 */ "...ee......"
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".....daa..."
+ /* 2 */ "...ccd....."
+ /* 3 */ "...bc......"
+ /* 4 */ "...b......."
+ /* 5 */ "..ff......."
+ /* 6 */ "..ee......."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "...aaa....."
+ /* 1 */ "..ddd......"
+ /* 2 */ ".cc........"
+ /* 3 */ ".bb........"
+ /* 4 */ ".ff........"
+ /* 5 */ ".e........."
+ /* 6 */ ".ee........"
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "aaa........"
+ /* 1 */ "dd........."
+ /* 2 */ "cc........."
+ /* 3 */ "bb........."
+ /* 4 */ "ff........."
+ /* 5 */ "e.........."
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "...........",
+
+ // Connectors:
+ "-1: 0, 8, 5: 4\n" /* Type -1, direction X- */
+ "1: 5, 1, 10: 3\n" /* Type 1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CurveDownFromTopSingle
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CurveSingle:
+ // The data has been exported from the gallery Cube, area index 84, ID 462, created by Aloe_vera
+ {
+ // Size:
+ 11, 1, 11, // SizeX = 11, SizeY = 1, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 10, 2, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:14\n" /* wool */
+ "b: 35: 1\n" /* wool */
+ "c: 35: 4\n" /* wool */
+ "d: 35: 5\n" /* wool */
+ "e: 35: 3\n" /* wool */
+ "f: 35:11\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "aaaaaa....."
+ /* 1 */ "bbbbbbaa..."
+ /* 2 */ "cccccbbaa.."
+ /* 3 */ "ddddcccbaa."
+ /* 4 */ "eeedddccba."
+ /* 5 */ "ffeeeddcbba"
+ /* 6 */ ".fffeedccba"
+ /* 7 */ "...ffeddcba"
+ /* 8 */ "....feedcba"
+ /* 9 */ "....ffedcba"
+ /* 10 */ ".....fedcba",
+
+ // Connectors:
+ "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */
+ "1: 5, 1, 10: 3\n" /* Type 1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CurveSingle
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CurveSingleLeft:
+ // The data has been exported from the gallery Cube, area index 97, ID 475, created by Aloe_vera
+ {
+ // Size:
+ 11, 1, 11, // SizeX = 11, SizeY = 1, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 10, 2, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:14\n" /* wool */
+ "b: 35: 1\n" /* wool */
+ "c: 35: 4\n" /* wool */
+ "d: 35: 5\n" /* wool */
+ "e: 35: 3\n" /* wool */
+ "f: 35:11\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ ".....abcdef"
+ /* 1 */ "....aabcdef"
+ /* 2 */ "....abbcdef"
+ /* 3 */ "...aabccdef"
+ /* 4 */ ".aaabbcddef"
+ /* 5 */ "aabbbccdeef"
+ /* 6 */ "bbbcccddef."
+ /* 7 */ "ccccdddeff."
+ /* 8 */ "dddddeeff.."
+ /* 9 */ "eeeeeeff..."
+ /* 10 */ "ffffff.....",
+
+ // Connectors:
+ "-1: 0, 1, 10: 4\n" /* Type -1, direction X- */
+ "1: 10, 1, 0: 2\n" /* Type 1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CurveSingleLeft
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CurveUpDouble:
+ // The data has been exported from the gallery Cube, area index 92, ID 470, created by Aloe_vera
+ {
+ // Size:
+ 14, 8, 14, // SizeX = 14, SizeY = 8, SizeZ = 14
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 13, 9, 13, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:11\n" /* wool */
+ "b: 35: 3\n" /* wool */
+ "c: 35: 5\n" /* wool */
+ "d: 35: 4\n" /* wool */
+ "e: 35: 1\n" /* wool */
+ "f: 35:14\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "a............."
+ /* 1 */ "b............."
+ /* 2 */ "c............."
+ /* 3 */ "d............."
+ /* 4 */ "e............."
+ /* 5 */ "f............."
+ /* 6 */ "f............."
+ /* 7 */ "e............."
+ /* 8 */ "d............."
+ /* 9 */ "c............."
+ /* 10 */ "b............."
+ /* 11 */ "a............."
+ /* 12 */ ".............."
+ /* 13 */ ".............."
+
+ // Level 1
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".aa..........."
+ /* 1 */ ".bb..........."
+ /* 2 */ ".cc..........."
+ /* 3 */ ".dd..........."
+ /* 4 */ ".ee..........."
+ /* 5 */ ".f............"
+ /* 6 */ ".f............"
+ /* 7 */ ".e............"
+ /* 8 */ ".d............"
+ /* 9 */ ".c............"
+ /* 10 */ ".b............"
+ /* 11 */ ".b............"
+ /* 12 */ ".............."
+ /* 13 */ ".............."
+
+ // Level 2
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "...aaa........"
+ /* 1 */ "...bb........."
+ /* 2 */ "...cc........."
+ /* 3 */ "...dd........."
+ /* 4 */ "...ee........."
+ /* 5 */ "..ff.........."
+ /* 6 */ "..ff.........."
+ /* 7 */ "..ee.........."
+ /* 8 */ "..de.........."
+ /* 9 */ "..c..........."
+ /* 10 */ ".b............"
+ /* 11 */ ".b............"
+ /* 12 */ ".............."
+ /* 13 */ ".............."
+
+ // Level 3
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".....baa......"
+ /* 2 */ ".....bbaaa...."
+ /* 3 */ "....dccbba...."
+ /* 4 */ "....eddcc....."
+ /* 5 */ "....fedd......"
+ /* 6 */ "....ffee......"
+ /* 7 */ "....ff........"
+ /* 8 */ "....e........."
+ /* 9 */ "...dd........."
+ /* 10 */ "..cc.........."
+ /* 11 */ "..b..........."
+ /* 12 */ ".a............"
+ /* 13 */ ".............."
+
+ // Level 4
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".............."
+ /* 2 */ ".............."
+ /* 3 */ "..........a..."
+ /* 4 */ ".........ba..."
+ /* 5 */ "........cc...."
+ /* 6 */ ".......edc...."
+ /* 7 */ "......fedd...."
+ /* 8 */ ".....ff......."
+ /* 9 */ "....de........"
+ /* 10 */ "...cde........"
+ /* 11 */ "..b..........."
+ /* 12 */ ".a............"
+ /* 13 */ ".............."
+
+ // Level 5
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".............."
+ /* 2 */ ".............."
+ /* 3 */ ".............."
+ /* 4 */ "...........a.."
+ /* 5 */ "..........ba.."
+ /* 6 */ "..........baa."
+ /* 7 */ "..........cba."
+ /* 8 */ ".......fedcb.."
+ /* 9 */ "......fffed..."
+ /* 10 */ ".....eef......"
+ /* 11 */ "...ccd........"
+ /* 12 */ "..b..........."
+ /* 13 */ ".............."
+
+ // Level 6
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".............."
+ /* 2 */ ".............."
+ /* 3 */ ".............."
+ /* 4 */ ".............."
+ /* 5 */ ".............."
+ /* 6 */ ".............."
+ /* 7 */ ".............."
+ /* 8 */ "............ba"
+ /* 9 */ "...........cba"
+ /* 10 */ "........fedcba"
+ /* 11 */ "......effedc.."
+ /* 12 */ "..bbcdef......"
+ /* 13 */ "..a..........."
+
+ // Level 7
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".............."
+ /* 2 */ ".............."
+ /* 3 */ ".............."
+ /* 4 */ ".............."
+ /* 5 */ ".............."
+ /* 6 */ ".............."
+ /* 7 */ ".............."
+ /* 8 */ ".............."
+ /* 9 */ ".............."
+ /* 10 */ ".............."
+ /* 11 */ "............ba"
+ /* 12 */ "........fedcba"
+ /* 13 */ "..abcdeffedcba",
+
+ // Connectors:
+ "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */
+ "2: 0, 1, 0: 4\n" /* Type 2, direction X- */
+ "2: 2, 8, 13: 3\n" /* Type 2, direction Z+ */
+ "-2: 13, 8, 13: 3\n" /* Type -2, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CurveUpDouble
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CurveUpSingle:
+ // The data has been exported from the gallery Cube, area index 87, ID 465, created by Aloe_vera
+ {
+ // Size:
+ 11, 8, 11, // SizeX = 11, SizeY = 8, SizeZ = 11
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 10, 9, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:14\n" /* wool */
+ "b: 35: 1\n" /* wool */
+ "c: 35: 4\n" /* wool */
+ "d: 35: 5\n" /* wool */
+ "e: 35: 3\n" /* wool */
+ "f: 35:11\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "aaa........"
+ /* 1 */ "bb........."
+ /* 2 */ "cc........."
+ /* 3 */ "dd........."
+ /* 4 */ "ee........."
+ /* 5 */ "f.........."
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "...aaa....."
+ /* 1 */ "..bbb......"
+ /* 2 */ ".cc........"
+ /* 3 */ ".dd........"
+ /* 4 */ ".ee........"
+ /* 5 */ ".f........."
+ /* 6 */ ".ff........"
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".....baa..."
+ /* 2 */ "...ccb....."
+ /* 3 */ "...dc......"
+ /* 4 */ "...d......."
+ /* 5 */ "..ee......."
+ /* 6 */ "..ff......."
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "......baa.."
+ /* 3 */ ".....ccb..."
+ /* 4 */ "....dd....."
+ /* 5 */ "....e......"
+ /* 6 */ "...fe......"
+ /* 7 */ "...ff......"
+ /* 8 */ "..........."
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "........aa."
+ /* 4 */ "......ccb.."
+ /* 5 */ ".....dd...."
+ /* 6 */ ".....e....."
+ /* 7 */ "....fe....."
+ /* 8 */ "....f......"
+ /* 9 */ "..........."
+ /* 10 */ "..........."
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ ".........a."
+ /* 5 */ ".......cbba"
+ /* 6 */ "......dc..."
+ /* 7 */ "......d...."
+ /* 8 */ ".....ee...."
+ /* 9 */ "....ff....."
+ /* 10 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ "..........."
+ /* 6 */ "........cba"
+ /* 7 */ ".......dcba"
+ /* 8 */ ".......dcb."
+ /* 9 */ ".....fe...."
+ /* 10 */ ".....f....."
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "..........."
+ /* 4 */ "..........."
+ /* 5 */ "..........."
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "..........a"
+ /* 9 */ ".......dcba"
+ /* 10 */ ".....fedcba",
+
+ // Connectors:
+ "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */
+ "1: 5, 8, 10: 3\n" /* Type 1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CurveUpSingle
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SlopeDownFromTopSingle:
+ // The data has been exported from the gallery Cube, area index 98, ID 476, created by Aloe_vera
+ {
+ // Size:
+ 16, 8, 6, // SizeX = 16, SizeY = 8, SizeZ = 6
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 15, 9, 5, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:14\n" /* wool */
+ "b: 35: 1\n" /* wool */
+ "c: 35: 4\n" /* wool */
+ "d: 35: 5\n" /* wool */
+ "e: 35: 3\n" /* wool */
+ "f: 35:11\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..............aa"
+ /* 1 */ "..............bb"
+ /* 2 */ "..............cc"
+ /* 3 */ "..............dd"
+ /* 4 */ "..............ee"
+ /* 5 */ "..............ff"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "............aa.."
+ /* 1 */ "............bb.."
+ /* 2 */ "............cc.."
+ /* 3 */ "............dd.."
+ /* 4 */ "............ee.."
+ /* 5 */ "............ff.."
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..........aa...."
+ /* 1 */ "..........bb...."
+ /* 2 */ "..........cc...."
+ /* 3 */ "..........dd...."
+ /* 4 */ "..........ee...."
+ /* 5 */ "..........ff...."
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "........aa......"
+ /* 1 */ "........bb......"
+ /* 2 */ "........cc......"
+ /* 3 */ "........dd......"
+ /* 4 */ "........ee......"
+ /* 5 */ "........ff......"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "......aa........"
+ /* 1 */ "......bb........"
+ /* 2 */ "......cc........"
+ /* 3 */ "......dd........"
+ /* 4 */ "......ee........"
+ /* 5 */ "......ff........"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "....aa.........."
+ /* 1 */ "....bb.........."
+ /* 2 */ "....cc.........."
+ /* 3 */ "....dd.........."
+ /* 4 */ "....ee.........."
+ /* 5 */ "....ff.........."
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..aa............"
+ /* 1 */ "..bb............"
+ /* 2 */ "..cc............"
+ /* 3 */ "..dd............"
+ /* 4 */ "..ee............"
+ /* 5 */ "..ff............"
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aa.............."
+ /* 1 */ "bb.............."
+ /* 2 */ "cc.............."
+ /* 3 */ "dd.............."
+ /* 4 */ "ee.............."
+ /* 5 */ "ff..............",
+
+ // Connectors:
+ "-1: 0, 8, 5: 4\n" /* Type -1, direction X- */
+ "1: 15, 1, 5: 5\n" /* Type 1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // SlopeDownFromTopSingle
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SlopeUpDouble:
+ // The data has been exported from the gallery Cube, area index 90, ID 468, created by Aloe_vera
+ {
+ // Size:
+ 16, 8, 12, // SizeX = 16, SizeY = 8, SizeZ = 12
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 15, 9, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:11\n" /* wool */
+ "b: 35: 3\n" /* wool */
+ "c: 35: 5\n" /* wool */
+ "d: 35: 4\n" /* wool */
+ "e: 35: 1\n" /* wool */
+ "f: 35:14\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aa.............."
+ /* 1 */ "bb.............."
+ /* 2 */ "cc.............."
+ /* 3 */ "dd.............."
+ /* 4 */ "ee.............."
+ /* 5 */ "ff.............."
+ /* 6 */ "ff.............."
+ /* 7 */ "ee.............."
+ /* 8 */ "dd.............."
+ /* 9 */ "cc.............."
+ /* 10 */ "bb.............."
+ /* 11 */ "aa.............."
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..aa............"
+ /* 1 */ "..bb............"
+ /* 2 */ "..cc............"
+ /* 3 */ "..dd............"
+ /* 4 */ "..ee............"
+ /* 5 */ "..ff............"
+ /* 6 */ "..ff............"
+ /* 7 */ "..ee............"
+ /* 8 */ "..dd............"
+ /* 9 */ "..cc............"
+ /* 10 */ "..bb............"
+ /* 11 */ "..aa............"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "....aa.........."
+ /* 1 */ "....bb.........."
+ /* 2 */ "....cc.........."
+ /* 3 */ "....dd.........."
+ /* 4 */ "....ee.........."
+ /* 5 */ "....ff.........."
+ /* 6 */ "....ff.........."
+ /* 7 */ "....ee.........."
+ /* 8 */ "....dd.........."
+ /* 9 */ "....cc.........."
+ /* 10 */ "....bb.........."
+ /* 11 */ "....aa.........."
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "......aa........"
+ /* 1 */ "......bb........"
+ /* 2 */ "......cc........"
+ /* 3 */ "......dd........"
+ /* 4 */ "......ee........"
+ /* 5 */ "......ff........"
+ /* 6 */ "......ff........"
+ /* 7 */ "......ee........"
+ /* 8 */ "......dd........"
+ /* 9 */ "......cc........"
+ /* 10 */ "......bb........"
+ /* 11 */ "......aa........"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "........aa......"
+ /* 1 */ "........bb......"
+ /* 2 */ "........cc......"
+ /* 3 */ "........dd......"
+ /* 4 */ "........ee......"
+ /* 5 */ "........ff......"
+ /* 6 */ "........ff......"
+ /* 7 */ "........ee......"
+ /* 8 */ "........dd......"
+ /* 9 */ "........cc......"
+ /* 10 */ "........bb......"
+ /* 11 */ "........aa......"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..........aa...."
+ /* 1 */ "..........bb...."
+ /* 2 */ "..........cc...."
+ /* 3 */ "..........dd...."
+ /* 4 */ "..........ee...."
+ /* 5 */ "..........ff...."
+ /* 6 */ "..........ff...."
+ /* 7 */ "..........ee...."
+ /* 8 */ "..........dd...."
+ /* 9 */ "..........cc...."
+ /* 10 */ "..........bb...."
+ /* 11 */ "..........aa...."
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "............aa.."
+ /* 1 */ "............bb.."
+ /* 2 */ "............cc.."
+ /* 3 */ "............dd.."
+ /* 4 */ "............ee.."
+ /* 5 */ "............ff.."
+ /* 6 */ "............ff.."
+ /* 7 */ "............ee.."
+ /* 8 */ "............dd.."
+ /* 9 */ "............cc.."
+ /* 10 */ "............bb.."
+ /* 11 */ "............aa.."
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..............aa"
+ /* 1 */ "..............bb"
+ /* 2 */ "..............cc"
+ /* 3 */ "..............dd"
+ /* 4 */ "..............ee"
+ /* 5 */ "..............ff"
+ /* 6 */ "..............ff"
+ /* 7 */ "..............ee"
+ /* 8 */ "..............dd"
+ /* 9 */ "..............cc"
+ /* 10 */ "..............bb"
+ /* 11 */ "..............aa",
+
+ // Connectors:
+ "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */
+ "2: 0, 1, 0: 4\n" /* Type 2, direction X- */
+ "-2: 15, 8, 0: 5\n" /* Type -2, direction X+ */
+ "2: 15, 8, 11: 5\n" /* Type 2, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // SlopeUpDouble
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SlopeUpSingle:
+ // The data has been exported from the gallery Cube, area index 85, ID 463, created by Aloe_vera
+ {
+ // Size:
+ 16, 8, 6, // SizeX = 16, SizeY = 8, SizeZ = 6
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 15, 9, 5, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:14\n" /* wool */
+ "b: 35: 1\n" /* wool */
+ "c: 35: 4\n" /* wool */
+ "d: 35: 5\n" /* wool */
+ "e: 35: 3\n" /* wool */
+ "f: 35:11\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aa.............."
+ /* 1 */ "bb.............."
+ /* 2 */ "cc.............."
+ /* 3 */ "dd.............."
+ /* 4 */ "ee.............."
+ /* 5 */ "ff.............."
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..aa............"
+ /* 1 */ "..bb............"
+ /* 2 */ "..cc............"
+ /* 3 */ "..dd............"
+ /* 4 */ "..ee............"
+ /* 5 */ "..ff............"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "....aa.........."
+ /* 1 */ "....bb.........."
+ /* 2 */ "....cc.........."
+ /* 3 */ "....dd.........."
+ /* 4 */ "....ee.........."
+ /* 5 */ "....ff.........."
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "......aa........"
+ /* 1 */ "......bb........"
+ /* 2 */ "......cc........"
+ /* 3 */ "......dd........"
+ /* 4 */ "......ee........"
+ /* 5 */ "......ff........"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "........aa......"
+ /* 1 */ "........bb......"
+ /* 2 */ "........cc......"
+ /* 3 */ "........dd......"
+ /* 4 */ "........ee......"
+ /* 5 */ "........ff......"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..........aa...."
+ /* 1 */ "..........bb...."
+ /* 2 */ "..........cc...."
+ /* 3 */ "..........dd...."
+ /* 4 */ "..........ee...."
+ /* 5 */ "..........ff...."
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "............aa.."
+ /* 1 */ "............bb.."
+ /* 2 */ "............cc.."
+ /* 3 */ "............dd.."
+ /* 4 */ "............ee.."
+ /* 5 */ "............ff.."
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "..............aa"
+ /* 1 */ "..............bb"
+ /* 2 */ "..............cc"
+ /* 3 */ "..............dd"
+ /* 4 */ "..............ee"
+ /* 5 */ "..............ff",
+
+ // Connectors:
+ "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */
+ "1: 15, 8, 5: 5\n" /* Type 1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ -1000,
+
+ // MoveToGround:
+ false,
+ }, // SlopeUpSingle
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SplitTee:
+ // The data has been exported from the gallery Cube, area index 93, ID 471, created by Aloe_vera
+ {
+ // Size:
+ 16, 1, 14, // SizeX = 16, SizeY = 1, SizeZ = 14
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 15, 2, 13, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:11\n" /* wool */
+ "b: 35: 3\n" /* wool */
+ "c: 35: 5\n" /* wool */
+ "d: 35: 4\n" /* wool */
+ "e: 35: 1\n" /* wool */
+ "f: 35:14\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aaaaaa.........."
+ /* 1 */ "bbbbbbaaa......."
+ /* 2 */ "ccccccbbbaaa...."
+ /* 3 */ "ddddddcccbbbaaaa"
+ /* 4 */ "eeeeeedddcccbbbb"
+ /* 5 */ "ffffffeeedddcccc"
+ /* 6 */ "fffffffffeeedddd"
+ /* 7 */ "eeeeff...fffeeee"
+ /* 8 */ "dddeeff.....ffff"
+ /* 9 */ "cccddeff........"
+ /* 10 */ "bbbccdeef......."
+ /* 11 */ "aaabbcddef......"
+ /* 12 */ "...aabcddef....."
+ /* 13 */ ".....abcdef.....",
+
+ // Connectors:
+ "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */
+ "2: 0, 1, 0: 4\n" /* Type 2, direction X- */
+ "-1: 15, 1, 3: 5\n" /* Type -1, direction X+ */
+ "1: 5, 1, 13: 3\n" /* Type 1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // SplitTee
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // StraightDouble:
+ // The data has been exported from the gallery Cube, area index 88, ID 466, created by Aloe_vera
+ {
+ // Size:
+ 16, 1, 12, // SizeX = 16, SizeY = 1, SizeZ = 12
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 15, 2, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:11\n" /* wool */
+ "b: 35: 3\n" /* wool */
+ "c: 35: 5\n" /* wool */
+ "d: 35: 4\n" /* wool */
+ "e: 35: 1\n" /* wool */
+ "f: 35:14\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aaaaaaaaaaaaaaaa"
+ /* 1 */ "bbbbbbbbbbbbbbbb"
+ /* 2 */ "cccccccccccccccc"
+ /* 3 */ "dddddddddddddddd"
+ /* 4 */ "eeeeeeeeeeeeeeee"
+ /* 5 */ "ffffffffffffffff"
+ /* 6 */ "ffffffffffffffff"
+ /* 7 */ "eeeeeeeeeeeeeeee"
+ /* 8 */ "dddddddddddddddd"
+ /* 9 */ "cccccccccccccccc"
+ /* 10 */ "bbbbbbbbbbbbbbbb"
+ /* 11 */ "aaaaaaaaaaaaaaaa",
+
+ // Connectors:
+ "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */
+ "2: 0, 1, 0: 4\n" /* Type 2, direction X- */
+ "-2: 15, 1, 0: 5\n" /* Type -2, direction X+ */
+ "2: 15, 1, 11: 5\n" /* Type 2, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // StraightDouble
+}; // g_RainbowRoadPrefabs
+
+
+
+
+
+
+const cPrefab::sDef g_RainbowRoadStartingPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // StraightSingle:
+ // The data has been exported from the gallery Cube, area index 83, ID 461, created by Aloe_vera
+ {
+ // Size:
+ 16, 1, 6, // SizeX = 16, SizeY = 1, SizeZ = 6
+
+ // Hitbox (relative to bounding box):
+ 0, -2, 0, // MinX, MinY, MinZ
+ 15, 2, 5, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 35:14\n" /* wool */
+ "b: 35: 1\n" /* wool */
+ "c: 35: 4\n" /* wool */
+ "d: 35: 5\n" /* wool */
+ "e: 35: 3\n" /* wool */
+ "f: 35:11\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "aaaaaaaaaaaaaaaa"
+ /* 1 */ "bbbbbbbbbbbbbbbb"
+ /* 2 */ "cccccccccccccccc"
+ /* 3 */ "dddddddddddddddd"
+ /* 4 */ "eeeeeeeeeeeeeeee"
+ /* 5 */ "ffffffffffffffff",
+
+ // Connectors:
+ "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */
+ "1: 15, 1, 5: 5\n" /* Type 1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 500,
+
+ // MoveToGround:
+ false,
+ }, // StraightSingle
+};
+
+
+
+
+
+// The prefab counts:
+
+const size_t g_RainbowRoadPrefabsCount = ARRAYCOUNT(g_RainbowRoadPrefabs);
+
+const size_t g_RainbowRoadStartingPrefabsCount = ARRAYCOUNT(g_RainbowRoadStartingPrefabs);
+
diff --git a/src/Generating/Prefabs/RainbowRoadPrefabs.h b/src/Generating/Prefabs/RainbowRoadPrefabs.h
new file mode 100644
index 000000000..ab0a0fbb2
--- /dev/null
+++ b/src/Generating/Prefabs/RainbowRoadPrefabs.h
@@ -0,0 +1,15 @@
+
+// RainbowRoadPrefabs.h
+
+// Declares the prefabs in the group RainbowRoad
+
+#include "../Prefab.h"
+
+
+
+
+
+extern const cPrefab::sDef g_RainbowRoadPrefabs[];
+extern const cPrefab::sDef g_RainbowRoadStartingPrefabs[];
+extern const size_t g_RainbowRoadPrefabsCount;
+extern const size_t g_RainbowRoadStartingPrefabsCount;
diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp
new file mode 100644
index 000000000..3328ee210
--- /dev/null
+++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp
@@ -0,0 +1,1669 @@
+
+// SandFlatRoofVillagePrefabs.cpp
+
+// Defines the prefabs in the group SandFlatRoofVillage
+
+// NOTE: This file has been generated automatically by GalExport!
+// Any manual changes will be overwritten by the next automatic export!
+
+#include "Globals.h"
+#include "SandFlatRoofVillagePrefabs.h"
+
+
+
+
+
+const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // Forge:
+ // The data has been exported from the gallery Desert, area index 32, ID 173, created by Aloe_vera
+ {
+ // Size:
+ 12, 6, 10, // SizeX = 12, SizeY = 6, SizeZ = 10
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 12, 5, 10, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e:128: 3\n" /* sandstonestairs */
+ "f:171:15\n" /* carpet */
+ "g: 64: 6\n" /* wooddoorblock */
+ "h:171: 0\n" /* carpet */
+ "i:171:14\n" /* carpet */
+ "j: 61: 2\n" /* furnace */
+ "k: 10: 0\n" /* lava */
+ "l: 54: 2\n" /* chest */
+ "m: 19: 0\n" /* sponge */
+ "n: 24: 2\n" /* sandstone */
+ "o: 64:12\n" /* wooddoorblock */
+ "p: 50: 1\n" /* torch */
+ "q:101: 0\n" /* ironbars */
+ "r:128: 4\n" /* sandstonestairs */
+ "s:128: 6\n" /* sandstonestairs */
+ "t:128: 5\n" /* sandstonestairs */
+ "u:128: 7\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "aaaaaaammmmm"
+ /* 1 */ "aaaaaaaaaaam"
+ /* 2 */ "aaaaaaaaaaam"
+ /* 3 */ "aaaaaaaaaaam"
+ /* 4 */ "aaaaaaaaaaam"
+ /* 5 */ "aaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaam"
+ /* 8 */ "maaaaaaaaaam"
+ /* 9 */ "mmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "bcccccd....."
+ /* 1 */ "baaaaaaaaaa."
+ /* 2 */ "baaaaaaaaaa."
+ /* 3 */ "baaaaaaaaaa."
+ /* 4 */ "baaaaaaaaaa."
+ /* 5 */ "eaaaaaaaaaa."
+ /* 6 */ ".aaaaaaaaaa."
+ /* 7 */ ".aaaaaaaaaa."
+ /* 8 */ ".aaaaaaaaaa."
+ /* 9 */ "............"
+
+ // Level 2
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ ".a....aaaaa."
+ /* 2 */ "......afffa."
+ /* 3 */ "......ghfha."
+ /* 4 */ "......aiiia."
+ /* 5 */ ".a....ahfha."
+ /* 6 */ ".ajaajafffa."
+ /* 7 */ ".aakkaal..a."
+ /* 8 */ ".aaaaaaaaaa."
+ /* 9 */ "............"
+
+ // Level 3
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ ".n....nn.nn."
+ /* 2 */ "......n...n."
+ /* 3 */ "......o...n."
+ /* 4 */ "......n....."
+ /* 5 */ ".n....n...n."
+ /* 6 */ ".n....n...n."
+ /* 7 */ ".n....n...n."
+ /* 8 */ ".nnn.nnn.nn."
+ /* 9 */ "............"
+
+ // Level 4
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "............"
+ /* 1 */ ".a....aaaaa."
+ /* 2 */ "......a...a."
+ /* 3 */ "......a...a."
+ /* 4 */ "......ap..a."
+ /* 5 */ ".a....a...a."
+ /* 6 */ ".aqqqqa...a."
+ /* 7 */ ".a....a...a."
+ /* 8 */ ".aaaaaaaaaa."
+ /* 9 */ "............"
+
+ // Level 5
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "rsssssssssss"
+ /* 1 */ "raaaaaaaaaat"
+ /* 2 */ "raaaaaaaaaat"
+ /* 3 */ "raaaaaaaaaat"
+ /* 4 */ "raaaaaaaaaat"
+ /* 5 */ "raaaaaaaaaat"
+ /* 6 */ "raaaaaaaaaat"
+ /* 7 */ "raaaaaaaaaat"
+ /* 8 */ "raaaaaaaaaat"
+ /* 9 */ "uuuuuuuuuuut",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Forge
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House11x7:
+ // The data has been exported from the gallery Desert, area index 31, ID 172, created by Aloe_vera
+ {
+ // Size:
+ 13, 6, 9, // SizeX = 13, SizeY = 6, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 13, 5, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:171: 0\n" /* carpet */
+ "g:171:15\n" /* carpet */
+ "h:171:14\n" /* carpet */
+ "i: 24: 2\n" /* sandstone */
+ "j: 64:12\n" /* wooddoorblock */
+ "k: 50: 3\n" /* torch */
+ "l: 50: 1\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 2\n" /* torch */
+ "o: 50: 4\n" /* torch */
+ "p:128: 4\n" /* sandstonestairs */
+ "q:128: 6\n" /* sandstonestairs */
+ "r:128: 5\n" /* sandstonestairs */
+ "s:128: 7\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "mmaaammmmmmmm"
+ /* 1 */ "maaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaam"
+ /* 8 */ "mmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "..bcd........"
+ /* 1 */ ".aaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaa."
+ /* 6 */ ".aaaaaaaaaaa."
+ /* 7 */ ".aaaaaaaaaaa."
+ /* 8 */ "............."
+
+ // Level 2
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ ".aaeaaaaaaaa."
+ /* 2 */ ".affgggggffa."
+ /* 3 */ ".afghhhhhgfa."
+ /* 4 */ ".afghfffhgfa."
+ /* 5 */ ".afghhhhhgfa."
+ /* 6 */ ".affgggggffa."
+ /* 7 */ ".aaaaaaaaaaa."
+ /* 8 */ "............."
+
+ // Level 3
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ ".iiji.iii.ii."
+ /* 2 */ ".i.........i."
+ /* 3 */ ".i.........i."
+ /* 4 */ "............."
+ /* 5 */ ".i.........i."
+ /* 6 */ ".i.........i."
+ /* 7 */ ".ii.ii.ii.ii."
+ /* 8 */ "............."
+
+ // Level 4
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ ".aaaaaaaaaaa."
+ /* 2 */ ".a..k..k...a."
+ /* 3 */ ".a.........a."
+ /* 4 */ ".al.......na."
+ /* 5 */ ".a.........a."
+ /* 6 */ ".a....o....a."
+ /* 7 */ ".aaaaaaaaaaa."
+ /* 8 */ "............."
+
+ // Level 5
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "pqqqqqqqqqqqq"
+ /* 1 */ "paaaaaaaaaaar"
+ /* 2 */ "paaaaaaaaaaar"
+ /* 3 */ "paaaaaaaaaaar"
+ /* 4 */ "paaaaaaaaaaar"
+ /* 5 */ "paaaaaaaaaaar"
+ /* 6 */ "paaaaaaaaaaar"
+ /* 7 */ "paaaaaaaaaaar"
+ /* 8 */ "ssssssssssssr",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House11x7
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House5x4:
+ // The data has been exported from the gallery Desert, area index 25, ID 166, created by Aloe_vera
+ {
+ // Size:
+ 7, 6, 6, // SizeX = 7, SizeY = 6, SizeZ = 6
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 7, 5, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:171: 0\n" /* carpet */
+ "g:171:14\n" /* carpet */
+ "h: 24: 2\n" /* sandstone */
+ "i: 64:12\n" /* wooddoorblock */
+ "j: 50: 3\n" /* torch */
+ "k:128: 4\n" /* sandstonestairs */
+ "l:128: 6\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 5\n" /* sandstonestairs */
+ "o:128: 7\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmaaamm"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "..bcd.."
+ /* 1 */ ".aaaaa."
+ /* 2 */ ".aaaaa."
+ /* 3 */ ".aaaaa."
+ /* 4 */ ".aaaaa."
+ /* 5 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".aaeaa."
+ /* 2 */ ".afgfa."
+ /* 3 */ ".afgfa."
+ /* 4 */ ".aaaaa."
+ /* 5 */ "......."
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".hhihh."
+ /* 2 */ ".h...h."
+ /* 3 */ ".h...h."
+ /* 4 */ ".hh.hh."
+ /* 5 */ "......."
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".aaaaa."
+ /* 2 */ ".aj.ja."
+ /* 3 */ ".a...a."
+ /* 4 */ ".aaaaa."
+ /* 5 */ "......."
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "kllllln"
+ /* 1 */ "kaaaaan"
+ /* 2 */ "kaaaaan"
+ /* 3 */ "kaaaaan"
+ /* 4 */ "kaaaaan"
+ /* 5 */ "oooooon",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House5x4
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House5x5:
+ // The data has been exported from the gallery Desert, area index 26, ID 167, created by Aloe_vera
+ {
+ // Size:
+ 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 7, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:171: 0\n" /* carpet */
+ "g:171:15\n" /* carpet */
+ "h:171:14\n" /* carpet */
+ "i: 24: 2\n" /* sandstone */
+ "j: 64:12\n" /* wooddoorblock */
+ "k: 50: 3\n" /* torch */
+ "l:128: 4\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 6\n" /* sandstonestairs */
+ "o:128: 5\n" /* sandstonestairs */
+ "p:128: 7\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmaaamm"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "..bcd.."
+ /* 1 */ ".aaaaa."
+ /* 2 */ ".aaaaa."
+ /* 3 */ ".aaaaa."
+ /* 4 */ ".aaaaa."
+ /* 5 */ ".aaaaa."
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".aaeaa."
+ /* 2 */ ".afffa."
+ /* 3 */ ".aghga."
+ /* 4 */ ".afffa."
+ /* 5 */ ".aaaaa."
+ /* 6 */ "......."
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".iijii."
+ /* 2 */ ".i...i."
+ /* 3 */ "......."
+ /* 4 */ ".i...i."
+ /* 5 */ ".ii.ii."
+ /* 6 */ "......."
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".aaaaa."
+ /* 2 */ ".ak.ka."
+ /* 3 */ ".a...a."
+ /* 4 */ ".a...a."
+ /* 5 */ ".aaaaa."
+ /* 6 */ "......."
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "lnnnnno"
+ /* 1 */ "laaaaao"
+ /* 2 */ "laaaaao"
+ /* 3 */ "laaaaao"
+ /* 4 */ "laaaaao"
+ /* 5 */ "laaaaao"
+ /* 6 */ "ppppppo",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House5x5
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House7x5:
+ // The data has been exported from the gallery Desert, area index 27, ID 168, created by Aloe_vera
+ {
+ // Size:
+ 9, 6, 7, // SizeX = 9, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 9, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:171:14\n" /* carpet */
+ "g:171: 0\n" /* carpet */
+ "h:171:15\n" /* carpet */
+ "i: 24: 2\n" /* sandstone */
+ "j: 64:12\n" /* wooddoorblock */
+ "k: 50: 3\n" /* torch */
+ "l:128: 4\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 6\n" /* sandstonestairs */
+ "o:128: 5\n" /* sandstonestairs */
+ "p:128: 7\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmaaammmm"
+ /* 1 */ "maaaaaaam"
+ /* 2 */ "maaaaaaam"
+ /* 3 */ "maaaaaaam"
+ /* 4 */ "maaaaaaam"
+ /* 5 */ "maaaaaaam"
+ /* 6 */ "mmmmmmmmm"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "..bcd...."
+ /* 1 */ ".aaaaaaa."
+ /* 2 */ ".aaaaaaa."
+ /* 3 */ ".aaaaaaa."
+ /* 4 */ ".aaaaaaa."
+ /* 5 */ ".aaaaaaa."
+ /* 6 */ "........."
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ ".aaeaaaa."
+ /* 2 */ ".afffffa."
+ /* 3 */ ".aghhhga."
+ /* 4 */ ".afffffa."
+ /* 5 */ ".aaaaaaa."
+ /* 6 */ "........."
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ ".iiji.ii."
+ /* 2 */ ".i.....i."
+ /* 3 */ "........."
+ /* 4 */ ".i.....i."
+ /* 5 */ ".iii.iii."
+ /* 6 */ "........."
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ ".aaaaaaa."
+ /* 2 */ ".ak.k..a."
+ /* 3 */ ".a.....a."
+ /* 4 */ ".a.....a."
+ /* 5 */ ".aaaaaaa."
+ /* 6 */ "........."
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "lnnnnnnnn"
+ /* 1 */ "laaaaaaao"
+ /* 2 */ "laaaaaaao"
+ /* 3 */ "laaaaaaao"
+ /* 4 */ "laaaaaaao"
+ /* 5 */ "laaaaaaao"
+ /* 6 */ "ppppppppo",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House7x5
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House8x5:
+ // The data has been exported from the gallery Desert, area index 28, ID 169, created by Aloe_vera
+ {
+ // Size:
+ 10, 6, 7, // SizeX = 10, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 10, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:171: 0\n" /* carpet */
+ "g:171:14\n" /* carpet */
+ "h:171:15\n" /* carpet */
+ "i: 24: 2\n" /* sandstone */
+ "j: 64:12\n" /* wooddoorblock */
+ "k: 50: 3\n" /* torch */
+ "l:128: 4\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 6\n" /* sandstonestairs */
+ "o:128: 5\n" /* sandstonestairs */
+ "p:128: 7\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "mmaaammmmm"
+ /* 1 */ "maaaaaaaam"
+ /* 2 */ "maaaaaaaam"
+ /* 3 */ "maaaaaaaam"
+ /* 4 */ "maaaaaaaam"
+ /* 5 */ "maaaaaaaam"
+ /* 6 */ "mmmmmmmmmm"
+
+ // Level 1
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "..bcd....."
+ /* 1 */ ".aaaaaaaa."
+ /* 2 */ ".aaaaaaaa."
+ /* 3 */ ".aaaaaaaa."
+ /* 4 */ ".aaaaaaaa."
+ /* 5 */ ".aaaaaaaa."
+ /* 6 */ ".........."
+
+ // Level 2
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".aaeaaaaa."
+ /* 2 */ ".afghhgfa."
+ /* 3 */ ".afhffhfa."
+ /* 4 */ ".afghhgfa."
+ /* 5 */ ".aaaaaaaa."
+ /* 6 */ ".........."
+
+ // Level 3
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".iijii.ii."
+ /* 2 */ ".i......i."
+ /* 3 */ ".........."
+ /* 4 */ ".i......i."
+ /* 5 */ ".ii.ii.ii."
+ /* 6 */ ".........."
+
+ // Level 4
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".aaaaaaaa."
+ /* 2 */ ".ak.k...a."
+ /* 3 */ ".a......a."
+ /* 4 */ ".a......a."
+ /* 5 */ ".aaaaaaaa."
+ /* 6 */ ".........."
+
+ // Level 5
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "lnnnnnnnnn"
+ /* 1 */ "laaaaaaaao"
+ /* 2 */ "laaaaaaaao"
+ /* 3 */ "laaaaaaaao"
+ /* 4 */ "laaaaaaaao"
+ /* 5 */ "laaaaaaaao"
+ /* 6 */ "pppppppppo",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House8x5
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House8x7:
+ // The data has been exported from the gallery Desert, area index 29, ID 170, created by Aloe_vera
+ {
+ // Size:
+ 10, 6, 9, // SizeX = 10, SizeY = 6, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 10, 5, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:171: 0\n" /* carpet */
+ "g:171:14\n" /* carpet */
+ "h:171:15\n" /* carpet */
+ "i: 24: 2\n" /* sandstone */
+ "j: 64:12\n" /* wooddoorblock */
+ "k: 50: 3\n" /* torch */
+ "l: 50: 1\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 2\n" /* torch */
+ "o:128: 4\n" /* sandstonestairs */
+ "p:128: 6\n" /* sandstonestairs */
+ "q:128: 5\n" /* sandstonestairs */
+ "r:128: 7\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "mmaaammmmm"
+ /* 1 */ "maaaaaaaam"
+ /* 2 */ "maaaaaaaam"
+ /* 3 */ "maaaaaaaam"
+ /* 4 */ "maaaaaaaam"
+ /* 5 */ "maaaaaaaam"
+ /* 6 */ "maaaaaaaam"
+ /* 7 */ "maaaaaaaam"
+ /* 8 */ "mmmmmmmmmm"
+
+ // Level 1
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "..bcd....."
+ /* 1 */ ".aaaaaaaa."
+ /* 2 */ ".aaaaaaaa."
+ /* 3 */ ".aaaaaaaa."
+ /* 4 */ ".aaaaaaaa."
+ /* 5 */ ".aaaaaaaa."
+ /* 6 */ ".aaaaaaaa."
+ /* 7 */ ".aaaaaaaa."
+ /* 8 */ ".........."
+
+ // Level 2
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".aaeaaaaa."
+ /* 2 */ ".afghhgfa."
+ /* 3 */ ".afhffhfa."
+ /* 4 */ ".afhgghfa."
+ /* 5 */ ".afhffhfa."
+ /* 6 */ ".afghhgfa."
+ /* 7 */ ".aaaaaaaa."
+ /* 8 */ ".........."
+
+ // Level 3
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".iijii.ii."
+ /* 2 */ ".i......i."
+ /* 3 */ ".i......i."
+ /* 4 */ ".........."
+ /* 5 */ ".i......i."
+ /* 6 */ ".i......i."
+ /* 7 */ ".ii.ii.ii."
+ /* 8 */ ".........."
+
+ // Level 4
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ ".........."
+ /* 1 */ ".aaaaaaaa."
+ /* 2 */ ".a..k...a."
+ /* 3 */ ".a......a."
+ /* 4 */ ".al....na."
+ /* 5 */ ".a......a."
+ /* 6 */ ".a......a."
+ /* 7 */ ".aaaaaaaa."
+ /* 8 */ ".........."
+
+ // Level 5
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "oppppppppp"
+ /* 1 */ "oaaaaaaaaq"
+ /* 2 */ "oaaaaaaaaq"
+ /* 3 */ "oaaaaaaaaq"
+ /* 4 */ "oaaaaaaaaq"
+ /* 5 */ "oaaaaaaaaq"
+ /* 6 */ "oaaaaaaaaq"
+ /* 7 */ "oaaaaaaaaq"
+ /* 8 */ "rrrrrrrrrq",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House8x7
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House9x7:
+ // The data has been exported from the gallery Desert, area index 30, ID 171, created by Aloe_vera
+ {
+ // Size:
+ 11, 6, 9, // SizeX = 11, SizeY = 6, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 5, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:171: 0\n" /* carpet */
+ "g:171:15\n" /* carpet */
+ "h:171:14\n" /* carpet */
+ "i: 24: 2\n" /* sandstone */
+ "j: 64:12\n" /* wooddoorblock */
+ "k: 50: 3\n" /* torch */
+ "l: 50: 1\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 2\n" /* torch */
+ "o: 50: 4\n" /* torch */
+ "p:128: 4\n" /* sandstonestairs */
+ "q:128: 6\n" /* sandstonestairs */
+ "r:128: 5\n" /* sandstonestairs */
+ "s:128: 7\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmaaammmmmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "maaaaaaaaam"
+ /* 7 */ "maaaaaaaaam"
+ /* 8 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..bcd......"
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".aaaaaaaaa."
+ /* 3 */ ".aaaaaaaaa."
+ /* 4 */ ".aaaaaaaaa."
+ /* 5 */ ".aaaaaaaaa."
+ /* 6 */ ".aaaaaaaaa."
+ /* 7 */ ".aaaaaaaaa."
+ /* 8 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".aaeaaaaaa."
+ /* 2 */ ".affgggffa."
+ /* 3 */ ".afghhhgfa."
+ /* 4 */ ".afghfhgfa."
+ /* 5 */ ".afghhhgfa."
+ /* 6 */ ".affgggffa."
+ /* 7 */ ".aaaaaaaaa."
+ /* 8 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".iijii.iii."
+ /* 2 */ ".i.......i."
+ /* 3 */ ".i.......i."
+ /* 4 */ "..........."
+ /* 5 */ ".i.......i."
+ /* 6 */ ".i.......i."
+ /* 7 */ ".ii.iii.ii."
+ /* 8 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".a..k....a."
+ /* 3 */ ".a.......a."
+ /* 4 */ ".al.....na."
+ /* 5 */ ".a.......a."
+ /* 6 */ ".a...o...a."
+ /* 7 */ ".aaaaaaaaa."
+ /* 8 */ "..........."
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "pqqqqqqqqqq"
+ /* 1 */ "paaaaaaaaar"
+ /* 2 */ "paaaaaaaaar"
+ /* 3 */ "paaaaaaaaar"
+ /* 4 */ "paaaaaaaaar"
+ /* 5 */ "paaaaaaaaar"
+ /* 6 */ "paaaaaaaaar"
+ /* 7 */ "paaaaaaaaar"
+ /* 8 */ "ssssssssssr",
+
+ // Connectors:
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House9x7
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseL13x12:
+ // The data has been exported from the gallery Desert, area index 53, ID 345, created by jakibaki
+ {
+ // Size:
+ 15, 6, 14, // SizeX = 15, SizeY = 6, SizeZ = 14
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 15, 5, 14, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 43: 1\n" /* doubleslab */
+ "f: 64: 7\n" /* wooddoorblock */
+ "g:171: 0\n" /* carpet */
+ "h:171:15\n" /* carpet */
+ "i:171:14\n" /* carpet */
+ "j: 58: 0\n" /* workbench */
+ "k: 24: 2\n" /* sandstone */
+ "l: 64:12\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 3\n" /* torch */
+ "o: 50: 1\n" /* torch */
+ "p: 50: 2\n" /* torch */
+ "q: 50: 4\n" /* torch */
+ "r:128: 6\n" /* sandstonestairs */
+ "s:128: 5\n" /* sandstonestairs */
+ "t:128: 4\n" /* sandstonestairs */
+ "u:128: 7\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmaaammmmmmmmm"
+ /* 1 */ "maaaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaaaam"
+ /* 8 */ "mmmmmmmaaaaaaam"
+ /* 9 */ "mmmmmmmaaaaaaam"
+ /* 10 */ "mmmmmmmaaaaaaam"
+ /* 11 */ "mmmmmmmaaaaaaam"
+ /* 12 */ "mmmmmmmaaaaaaam"
+ /* 13 */ "mmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "...bcd........."
+ /* 1 */ ".aaaaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaaea."
+ /* 6 */ ".aaaaaaaaaaaaa."
+ /* 7 */ ".aaaaaaaaaaaaa."
+ /* 8 */ ".......aeaaaaa."
+ /* 9 */ "mmmmmm.aaaaaaa."
+ /* 10 */ "mmmmmm.aaaaaaa."
+ /* 11 */ "mmmmmm.aaaaaaa."
+ /* 12 */ "mmmmmm.aaaaaaa."
+ /* 13 */ "..............."
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".aaafaaaaaaaaa."
+ /* 2 */ ".agghhhhhhhhga."
+ /* 3 */ ".aghiiiiiiiiha."
+ /* 4 */ ".aghiggggggiha."
+ /* 5 */ ".aghiiiiiigiha."
+ /* 6 */ ".agghhhhhigiha."
+ /* 7 */ ".aaaaaaahigiha."
+ /* 8 */ ".......ahigiha."
+ /* 9 */ "mmmmmm.ahiiiha."
+ /* 10 */ "mmmmmm.aghhhga."
+ /* 11 */ "mmmmmm.aggggja."
+ /* 12 */ "mmmmmm.aaaaaaa."
+ /* 13 */ "..............."
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".kkklkkkk.kkkk."
+ /* 2 */ ".k...........k."
+ /* 3 */ ".k...........k."
+ /* 4 */ "..............."
+ /* 5 */ ".k...........k."
+ /* 6 */ ".k...........k."
+ /* 7 */ ".kkk.kkk.....k."
+ /* 8 */ ".......k.....k."
+ /* 9 */ "mmmmmm.k......."
+ /* 10 */ "mmmmmm.......k."
+ /* 11 */ "mmmmmm.k.....k."
+ /* 12 */ "mmmmmm.kkk.kkk."
+ /* 13 */ "..............."
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".aaaaaaaaaaaaa."
+ /* 2 */ ".a......n....a."
+ /* 3 */ ".a...........a."
+ /* 4 */ ".ao..........a."
+ /* 5 */ ".a...........a."
+ /* 6 */ ".a..........pa."
+ /* 7 */ ".aaaaaaa.....a."
+ /* 8 */ ".......a.....a."
+ /* 9 */ "mmmmmm.a.....a."
+ /* 10 */ "mmmmmm.a.....a."
+ /* 11 */ "mmmmmm.a..q..a."
+ /* 12 */ "mmmmmm.aaaaaaa."
+ /* 13 */ "..............."
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "rrrrrrrrrrrrrrs"
+ /* 1 */ "taaaaaaaaaaaaas"
+ /* 2 */ "taaaaaaaaaaaaas"
+ /* 3 */ "taaaaaaaaaaaaas"
+ /* 4 */ "taaaaaaaaaaaaas"
+ /* 5 */ "taaaaaaaaaaaaas"
+ /* 6 */ "taaaaaaaaaaaaas"
+ /* 7 */ "taaaaaaaaaaaaas"
+ /* 8 */ "tuuuuutaaaaaaas"
+ /* 9 */ "mmmmmmtaaaaaaas"
+ /* 10 */ "mmmmmmtaaaaaaas"
+ /* 11 */ "mmmmmmtaaaaaaas"
+ /* 12 */ "mmmmmmtaaaaaaas"
+ /* 13 */ "......tuuuuuuuu",
+
+ // Connectors:
+ "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseL13x12
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // MarketStall:
+ // The data has been exported from the gallery Desert, area index 34, ID 175, created by Aloe_vera
+ {
+ // Size:
+ 7, 6, 7, // SizeX = 7, SizeY = 6, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 7, 5, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 12: 0\n" /* sand */
+ "b: 85: 0\n" /* fence */
+ "c:171:14\n" /* carpet */
+ "d:171:15\n" /* carpet */
+ "e:171: 0\n" /* carpet */
+ "f: 35:14\n" /* wool */
+ "g: 35: 0\n" /* wool */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "aaaaaaa"
+ /* 2 */ "aaaaaaa"
+ /* 3 */ "aaaaaaa"
+ /* 4 */ "aaaaaaa"
+ /* 5 */ "aaaaaaa"
+ /* 6 */ "aaaaaaa"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "b.....b"
+ /* 1 */ "cddeddc"
+ /* 2 */ "cdeeedc"
+ /* 3 */ "cdeeedc"
+ /* 4 */ "cddeddc"
+ /* 5 */ "b.....b"
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "b.....b"
+ /* 1 */ "......."
+ /* 2 */ "......."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ "b.....b"
+ /* 6 */ "......."
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "b.....b"
+ /* 1 */ "......."
+ /* 2 */ "......."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ "b.....b"
+ /* 6 */ "fgfgfgf"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "fgfgfgf"
+ /* 1 */ "......."
+ /* 2 */ "......."
+ /* 3 */ "......."
+ /* 4 */ "......."
+ /* 5 */ "fgfgfgf"
+ /* 6 */ "......."
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "fgfgfgf"
+ /* 2 */ "fgfgfgf"
+ /* 3 */ "fgfgfgf"
+ /* 4 */ "fgfgfgf"
+ /* 5 */ "......."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "-1: 2, 0, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 5,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // MarketStall
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Marketplace:
+ // The data has been exported from the gallery Desert, area index 38, ID 261, created by Aloe_vera
+ {
+ // Size:
+ 14, 4, 16, // SizeX = 14, SizeY = 4, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 14, 3, 16, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b: 12: 0\n" /* sand */
+ "c: 24: 2\n" /* sandstone */
+ "d: 12: 2\n" /* sand */
+ "e: 85: 0\n" /* fence */
+ "f: 5: 0\n" /* wood */
+ "g:128: 2\n" /* sandstonestairs */
+ "h:128: 0\n" /* sandstonestairs */
+ "i: 8: 0\n" /* water */
+ "j:128: 1\n" /* sandstonestairs */
+ "k:128: 3\n" /* sandstonestairs */
+ "l: 35: 0\n" /* wool */
+ "m: 19: 0\n" /* sponge */
+ "n: 35:14\n" /* wool */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "aaaabbbaaabbbb"
+ /* 1 */ "aaaabbaabbabbb"
+ /* 2 */ "aababbabcabbbb"
+ /* 3 */ "aaaaabaaaaabbb"
+ /* 4 */ "bbbbbbbbbbbbbb"
+ /* 5 */ "bbbbbbbbbbaabb"
+ /* 6 */ "bbbbccccbbabab"
+ /* 7 */ "ccbbccccbbaaab"
+ /* 8 */ "ccbbccccbbabbb"
+ /* 9 */ "dcbbccccbbabaa"
+ /* 10 */ "ccbbbbbbbbaaba"
+ /* 11 */ "ccbbbbbbbbabaa"
+ /* 12 */ "bbbbbbbbbbabaa"
+ /* 13 */ "bbbaababbbaaba"
+ /* 14 */ "bbbcaaaabbabbb"
+ /* 15 */ "bbbcccabbbabbb"
+
+ // Level 1
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "e...e.e...e..."
+ /* 1 */ ".............."
+ /* 2 */ ".............."
+ /* 3 */ "fffff.fffff..."
+ /* 4 */ ".............."
+ /* 5 */ "..........f..e"
+ /* 6 */ "....gggg..f..."
+ /* 7 */ ".f..hiij..f..."
+ /* 8 */ ".f..hiij..f..."
+ /* 9 */ ".f..kkkk..f..e"
+ /* 10 */ ".f............"
+ /* 11 */ ".f........f..e"
+ /* 12 */ "...fffff..f..."
+ /* 13 */ "..........f..."
+ /* 14 */ "..........f..."
+ /* 15 */ "...e...e..f..e"
+
+ // Level 2
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "lnlnl.lnlnl..."
+ /* 1 */ ".............."
+ /* 2 */ ".............."
+ /* 3 */ "e...e.e...e..."
+ /* 4 */ ".............."
+ /* 5 */ "..........e..l"
+ /* 6 */ ".............n"
+ /* 7 */ ".e...........l"
+ /* 8 */ ".............n"
+ /* 9 */ "..........e..l"
+ /* 10 */ ".............."
+ /* 11 */ ".e........e..l"
+ /* 12 */ "...e...e.....n"
+ /* 13 */ ".............l"
+ /* 14 */ ".............n"
+ /* 15 */ "...lnlnl..e..l"
+
+ // Level 3
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ "lnlnl.lnlnl..."
+ /* 2 */ "lnlnl.lnlnl..."
+ /* 3 */ "lnlnl.lnlnl..."
+ /* 4 */ ".............."
+ /* 5 */ "..........lll."
+ /* 6 */ "..........nnn."
+ /* 7 */ "ll........lll."
+ /* 8 */ "nn........nnn."
+ /* 9 */ "ll........lll."
+ /* 10 */ "nn............"
+ /* 11 */ "ll........lll."
+ /* 12 */ "...lnlnl..nnn."
+ /* 13 */ "...lnlnl..lll."
+ /* 14 */ "...lnlnl..nnn."
+ /* 15 */ "..........lll.",
+
+ // Connectors:
+ "-1: 5, 0, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 20,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Marketplace
+}; // g_SandFlatRoofVillagePrefabs
+
+
+
+
+
+
+const cPrefab::sDef g_SandFlatRoofVillageStartingPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // Well:
+ // The data has been exported from the gallery Desert, area index 44, ID 275, created by Aloe_vera
+ {
+ // Size:
+ 5, 16, 5, // SizeX = 5, SizeY = 16, SizeZ = 5
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 4, 15, 4, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 24: 0\n" /* sandstone */
+ "c: 8: 0\n" /* water */
+ "d:128: 2\n" /* sandstonestairs */
+ "e:128: 0\n" /* sandstonestairs */
+ "f:128: 1\n" /* sandstonestairs */
+ "g:128: 3\n" /* sandstonestairs */
+ "h:128: 6\n" /* sandstonestairs */
+ "i:128: 4\n" /* sandstonestairs */
+ "j:128: 5\n" /* sandstonestairs */
+ "k:128: 7\n" /* sandstonestairs */
+ "l: 44: 1\n" /* step */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 01234 */
+ /* 0 */ "aaaaa"
+ /* 1 */ "abbba"
+ /* 2 */ "abbba"
+ /* 3 */ "abbba"
+ /* 4 */ "aaaaa"
+
+ // Level 1
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcccb"
+ /* 2 */ "bcccb"
+ /* 3 */ "bcccb"
+ /* 4 */ "bbbbb"
+
+ // Level 2
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcccb"
+ /* 2 */ "bcccb"
+ /* 3 */ "bcccb"
+ /* 4 */ "bbbbb"
+
+ // Level 3
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcccb"
+ /* 2 */ "bcccb"
+ /* 3 */ "bcccb"
+ /* 4 */ "bbbbb"
+
+ // Level 4
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcccb"
+ /* 2 */ "bcccb"
+ /* 3 */ "bcccb"
+ /* 4 */ "bbbbb"
+
+ // Level 5
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcccb"
+ /* 2 */ "bcccb"
+ /* 3 */ "bcccb"
+ /* 4 */ "bbbbb"
+
+ // Level 6
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcccb"
+ /* 2 */ "bcccb"
+ /* 3 */ "bcccb"
+ /* 4 */ "bbbbb"
+
+ // Level 7
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcccb"
+ /* 2 */ "bcccb"
+ /* 3 */ "bcccb"
+ /* 4 */ "bbbbb"
+
+ // Level 8
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcbcb"
+ /* 2 */ "bbcbb"
+ /* 3 */ "bcbcb"
+ /* 4 */ "bbbbb"
+
+ // Level 9
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcbcb"
+ /* 2 */ "bbbbb"
+ /* 3 */ "bcbcb"
+ /* 4 */ "bbbbb"
+
+ // Level 10
+ /* z\x* 01234 */
+ /* 0 */ "bbbbb"
+ /* 1 */ "bcbcb"
+ /* 2 */ "bbbbb"
+ /* 3 */ "bcbcb"
+ /* 4 */ "bbbbb"
+
+ // Level 11
+ /* z\x* 01234 */
+ /* 0 */ "ddddd"
+ /* 1 */ "ecccf"
+ /* 2 */ "ecbcf"
+ /* 3 */ "ecccf"
+ /* 4 */ "ggggf"
+
+ // Level 12
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "..b.."
+ /* 3 */ "....."
+ /* 4 */ "....."
+
+ // Level 13
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ "....."
+ /* 2 */ "..b.."
+ /* 3 */ "....."
+ /* 4 */ "....."
+
+ // Level 14
+ /* z\x* 01234 */
+ /* 0 */ "....."
+ /* 1 */ ".hhh."
+ /* 2 */ ".ibj."
+ /* 3 */ ".kkj."
+ /* 4 */ "....."
+
+ // Level 15
+ /* z\x* 01234 */
+ /* 0 */ "lllll"
+ /* 1 */ "lllll"
+ /* 2 */ "lllll"
+ /* 3 */ "lllll"
+ /* 4 */ "lllll",
+
+ // Connectors:
+ "2: 4, 11, 2: 5\n" /* Type 2, direction X+ */
+ "2: 2, 11, 4: 3\n" /* Type 2, direction Z+ */
+ "2: 0, 11, 2: 4\n" /* Type 2, direction X- */
+ "2: 2, 11, 0: 2\n" /* Type 2, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Well
+};
+
+
+
+
+
+// The prefab counts:
+
+const size_t g_SandFlatRoofVillagePrefabsCount = ARRAYCOUNT(g_SandFlatRoofVillagePrefabs);
+
+const size_t g_SandFlatRoofVillageStartingPrefabsCount = ARRAYCOUNT(g_SandFlatRoofVillageStartingPrefabs);
+
diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.h b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.h
new file mode 100644
index 000000000..ea06de5b5
--- /dev/null
+++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.h
@@ -0,0 +1,15 @@
+
+// SandFlatRoofVillagePrefabs.h
+
+// Declares the prefabs in the group SandFlatRoofVillage
+
+#include "../Prefab.h"
+
+
+
+
+
+extern const cPrefab::sDef g_SandFlatRoofVillagePrefabs[];
+extern const cPrefab::sDef g_SandFlatRoofVillageStartingPrefabs[];
+extern const size_t g_SandFlatRoofVillagePrefabsCount;
+extern const size_t g_SandFlatRoofVillageStartingPrefabsCount;
diff --git a/src/Generating/Prefabs/SandVillagePrefabs.cpp b/src/Generating/Prefabs/SandVillagePrefabs.cpp
new file mode 100644
index 000000000..c63f8161b
--- /dev/null
+++ b/src/Generating/Prefabs/SandVillagePrefabs.cpp
@@ -0,0 +1,2307 @@
+
+// SandVillagePrefabs.cpp
+
+// Defines the prefabs in the group SandVillage
+
+// NOTE: This file has been generated automatically by GalExport!
+// Any manual changes will be overwritten by the next automatic export!
+
+#include "Globals.h"
+#include "SandVillagePrefabs.h"
+
+
+
+
+
+const cPrefab::sDef g_SandVillagePrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // DoubleField:
+ // The data has been exported from the gallery Desert, area index 5, ID 75, created by tonibm1999
+ {
+ // Size:
+ 13, 3, 9, // SizeX = 13, SizeY = 3, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, -1, // MinX, MinY, MinZ
+ 13, 2, 8, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b: 60: 7\n" /* tilleddirt */
+ "c: 8: 0\n" /* water */
+ "d: 50: 5\n" /* torch */
+ "e: 59: 7\n" /* crops */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "aaaaaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaaaaa"
+ /* 7 */ "aaaaaaaaaaaaa"
+ /* 8 */ "aaaaaaaaaaaaa"
+
+ // Level 1
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "aaaaaaaaaaaaa"
+ /* 1 */ "abbcbbabbcbba"
+ /* 2 */ "abbcbbabbcbba"
+ /* 3 */ "abbcbbabbcbba"
+ /* 4 */ "abbcbbabbcbba"
+ /* 5 */ "abbcbbabbcbba"
+ /* 6 */ "abbcbbabbcbba"
+ /* 7 */ "abbcbbabbcbba"
+ /* 8 */ "aaaaaaaaaaaaa"
+
+ // Level 2
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "d.....d.....d"
+ /* 1 */ ".ee.ee.ee.ee."
+ /* 2 */ ".ee.ee.ee.ee."
+ /* 3 */ ".ee.ee.ee.ee."
+ /* 4 */ ".ee.ee.ee.ee."
+ /* 5 */ ".ee.ee.ee.ee."
+ /* 6 */ ".ee.ee.ee.ee."
+ /* 7 */ ".ee.ee.ee.ee."
+ /* 8 */ "d.....d.....d",
+
+ // Connectors:
+ "-1: 6, 1, 8: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // DoubleField
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House11x7:
+ // The data has been exported from the gallery Desert, area index 6, ID 81, created by Aloe_vera
+ {
+ // Size:
+ 11, 7, 7, // SizeX = 11, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 6, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:102: 0\n" /* glasspane */
+ "g: 64:12\n" /* wooddoorblock */
+ "h:128: 7\n" /* sandstonestairs */
+ "i: 50: 3\n" /* torch */
+ "j: 50: 4\n" /* torch */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:128: 3\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 1\n" /* torch */
+ "o: 50: 2\n" /* torch */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "....bcd...."
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".aaaaaaaaa."
+ /* 3 */ ".aaaaaaaaa."
+ /* 4 */ ".aaaaaaaaa."
+ /* 5 */ ".aaaaaaaaa."
+ /* 6 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".aaaaeaaaa."
+ /* 2 */ ".a.......a."
+ /* 3 */ ".a.......a."
+ /* 4 */ ".a.......a."
+ /* 5 */ ".aaaaaaaaa."
+ /* 6 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".affagaffa."
+ /* 2 */ ".f.......f."
+ /* 3 */ ".f.......f."
+ /* 4 */ ".f.......f."
+ /* 5 */ ".affafaffa."
+ /* 6 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "ccccccccccc"
+ /* 1 */ "haaaaaaaaah"
+ /* 2 */ ".a..i.i..a."
+ /* 3 */ ".a.......a."
+ /* 4 */ ".a..j.j..a."
+ /* 5 */ "kaaaaaaaaak"
+ /* 6 */ "lllllllllll"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "ccccccccccc"
+ /* 2 */ "haaaaaaaaah"
+ /* 3 */ ".an.....oa."
+ /* 4 */ "kaaaaaaaaak"
+ /* 5 */ "lllllllllll"
+ /* 6 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "ccccccccccc"
+ /* 3 */ "aaaaaaaaaaa"
+ /* 4 */ "lllllllllll"
+ /* 5 */ "..........."
+ /* 6 */ "...........",
+
+ // Connectors:
+ "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House11x7
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House11x9:
+ // The data has been exported from the gallery Desert, area index 11, ID 115, created by xoft
+ {
+ // Size:
+ 11, 8, 9, // SizeX = 11, SizeY = 8, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 11, 7, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:102: 0\n" /* glasspane */
+ "g: 64:12\n" /* wooddoorblock */
+ "h:128: 7\n" /* sandstonestairs */
+ "i: 50: 3\n" /* torch */
+ "j: 50: 4\n" /* torch */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:128: 3\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "mmmmaaammmm"
+ /* 1 */ "maaaaaaaaam"
+ /* 2 */ "maaaaaaaaam"
+ /* 3 */ "maaaaaaaaam"
+ /* 4 */ "maaaaaaaaam"
+ /* 5 */ "maaaaaaaaam"
+ /* 6 */ "maaaaaaaaam"
+ /* 7 */ "maaaaaaaaam"
+ /* 8 */ "mmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "....bcd...."
+ /* 1 */ ".aaaaaaaaa."
+ /* 2 */ ".aaaaaaaaa."
+ /* 3 */ ".aaaaaaaaa."
+ /* 4 */ ".aaaaaaaaa."
+ /* 5 */ ".aaaaaaaaa."
+ /* 6 */ ".aaaaaaaaa."
+ /* 7 */ ".aaaaaaaaa."
+ /* 8 */ "..........."
+
+ // Level 2
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".aaaaeaaaa."
+ /* 2 */ ".a.......a."
+ /* 3 */ ".a.......a."
+ /* 4 */ ".a.......a."
+ /* 5 */ ".a.......a."
+ /* 6 */ ".a.......a."
+ /* 7 */ ".aaaaaaaaa."
+ /* 8 */ "..........."
+
+ // Level 3
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ ".affagaffa."
+ /* 2 */ ".f.......f."
+ /* 3 */ ".f.......f."
+ /* 4 */ ".a.......a."
+ /* 5 */ ".f.......f."
+ /* 6 */ ".f.......f."
+ /* 7 */ ".afffafffa."
+ /* 8 */ "..........."
+
+ // Level 4
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "ccccccccccc"
+ /* 1 */ "haaaaaaaaah"
+ /* 2 */ ".a..i.i..a."
+ /* 3 */ ".a.......a."
+ /* 4 */ ".a.......a."
+ /* 5 */ ".a.......a."
+ /* 6 */ ".a...j...a."
+ /* 7 */ "kaaaaaaaaak"
+ /* 8 */ "lllllllllll"
+
+ // Level 5
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "ccccccccccc"
+ /* 2 */ "haaaaaaaaah"
+ /* 3 */ ".a.......a."
+ /* 4 */ ".a.......a."
+ /* 5 */ ".a.......a."
+ /* 6 */ "kaaaaaaaaak"
+ /* 7 */ "lllllllllll"
+ /* 8 */ "..........."
+
+ // Level 6
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "ccccccccccc"
+ /* 3 */ "haaaaaaaaah"
+ /* 4 */ ".a.......a."
+ /* 5 */ "kaaaaaaaaak"
+ /* 6 */ "lllllllllll"
+ /* 7 */ "..........."
+ /* 8 */ "..........."
+
+ // Level 7
+ /* z\x* 1 */
+ /* * 01234567890 */
+ /* 0 */ "..........."
+ /* 1 */ "..........."
+ /* 2 */ "..........."
+ /* 3 */ "ccccccccccc"
+ /* 4 */ "aaaaaaaaaaa"
+ /* 5 */ "lllllllllll"
+ /* 6 */ "..........."
+ /* 7 */ "..........."
+ /* 8 */ "...........",
+
+ // Connectors:
+ "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House11x9
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House13x7:
+ // The data has been exported from the gallery Desert, area index 15, ID 125, created by Aloe_vera
+ {
+ // Size:
+ 13, 7, 7, // SizeX = 13, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 13, 6, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:102: 0\n" /* glasspane */
+ "g: 64:12\n" /* wooddoorblock */
+ "h:128: 7\n" /* sandstonestairs */
+ "i: 50: 3\n" /* torch */
+ "j: 50: 4\n" /* torch */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:128: 3\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "mmmmmaaammmmm"
+ /* 1 */ "maaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaam"
+ /* 6 */ "mmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ ".....bcd....."
+ /* 1 */ ".aaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaa."
+ /* 6 */ "............."
+
+ // Level 2
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ ".aaaaaeaaaaa."
+ /* 2 */ ".a.........a."
+ /* 3 */ ".a.........a."
+ /* 4 */ ".a.........a."
+ /* 5 */ ".aaaaaaaaaaa."
+ /* 6 */ "............."
+
+ // Level 3
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ ".afffagafffa."
+ /* 2 */ ".f.........f."
+ /* 3 */ ".f.........f."
+ /* 4 */ ".f.........f."
+ /* 5 */ ".affafffaffa."
+ /* 6 */ "............."
+
+ // Level 4
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "ccccccccccccc"
+ /* 1 */ "haaaaaaaaaaah"
+ /* 2 */ ".a...i.i...a."
+ /* 3 */ ".a.........a."
+ /* 4 */ ".a..j...j..a."
+ /* 5 */ "kaaaaaaaaaaak"
+ /* 6 */ "lllllllllllll"
+
+ // Level 5
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "ccccccccccccc"
+ /* 2 */ "haaaaaaaaaaah"
+ /* 3 */ ".a.........a."
+ /* 4 */ "kaaaaaaaaaaak"
+ /* 5 */ "lllllllllllll"
+ /* 6 */ "............."
+
+ // Level 6
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "ccccccccccccc"
+ /* 3 */ "aaaaaaaaaaaaa"
+ /* 4 */ "lllllllllllll"
+ /* 5 */ "............."
+ /* 6 */ ".............",
+
+ // Connectors:
+ "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House13x7
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House13x9:
+ // The data has been exported from the gallery Desert, area index 12, ID 116, created by xoft
+ {
+ // Size:
+ 13, 8, 9, // SizeX = 13, SizeY = 8, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 13, 7, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:102: 0\n" /* glasspane */
+ "g: 64:12\n" /* wooddoorblock */
+ "h:128: 7\n" /* sandstonestairs */
+ "i: 50: 3\n" /* torch */
+ "j: 50: 4\n" /* torch */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:128: 3\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "mmmmmaaammmmm"
+ /* 1 */ "maaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaam"
+ /* 8 */ "mmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ ".....bcd....."
+ /* 1 */ ".aaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaa."
+ /* 6 */ ".aaaaaaaaaaa."
+ /* 7 */ ".aaaaaaaaaaa."
+ /* 8 */ "............."
+
+ // Level 2
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ ".aaaaaeaaaaa."
+ /* 2 */ ".a.........a."
+ /* 3 */ ".a.........a."
+ /* 4 */ ".a.........a."
+ /* 5 */ ".a.........a."
+ /* 6 */ ".a.........a."
+ /* 7 */ ".aaaaaaaaaaa."
+ /* 8 */ "............."
+
+ // Level 3
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ ".afffagafffa."
+ /* 2 */ ".f.........f."
+ /* 3 */ ".f.........f."
+ /* 4 */ ".a.........a."
+ /* 5 */ ".f.........f."
+ /* 6 */ ".f.........f."
+ /* 7 */ ".affaffafffa."
+ /* 8 */ "............."
+
+ // Level 4
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "ccccccccccccc"
+ /* 1 */ "haaaaaaaaaaah"
+ /* 2 */ ".a...i.i...a."
+ /* 3 */ ".a.........a."
+ /* 4 */ ".a.........a."
+ /* 5 */ ".a.........a."
+ /* 6 */ ".a..j..j...a."
+ /* 7 */ "kaaaaaaaaaaak"
+ /* 8 */ "lllllllllllll"
+
+ // Level 5
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "ccccccccccccc"
+ /* 2 */ "haaaaaaaaaaah"
+ /* 3 */ ".a.........a."
+ /* 4 */ ".a.........a."
+ /* 5 */ ".a.........a."
+ /* 6 */ "kaaaaaaaaaaak"
+ /* 7 */ "lllllllllllll"
+ /* 8 */ "............."
+
+ // Level 6
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "ccccccccccccc"
+ /* 3 */ "haaaaaaaaaaah"
+ /* 4 */ ".a.........a."
+ /* 5 */ "kaaaaaaaaaaak"
+ /* 6 */ "lllllllllllll"
+ /* 7 */ "............."
+ /* 8 */ "............."
+
+ // Level 7
+ /* z\x* 111 */
+ /* * 0123456789012 */
+ /* 0 */ "............."
+ /* 1 */ "............."
+ /* 2 */ "............."
+ /* 3 */ "ccccccccccccc"
+ /* 4 */ "aaaaaaaaaaaaa"
+ /* 5 */ "lllllllllllll"
+ /* 6 */ "............."
+ /* 7 */ "............."
+ /* 8 */ ".............",
+
+ // Connectors:
+ "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House13x9
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House15x9:
+ // The data has been exported from the gallery Desert, area index 13, ID 118, created by xoft
+ {
+ // Size:
+ 15, 8, 9, // SizeX = 15, SizeY = 8, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 15, 7, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:102: 0\n" /* glasspane */
+ "g: 64:12\n" /* wooddoorblock */
+ "h:128: 7\n" /* sandstonestairs */
+ "i: 50: 3\n" /* torch */
+ "j: 50: 4\n" /* torch */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:128: 3\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "mmmmmaaammmmmmm"
+ /* 1 */ "maaaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaaaam"
+ /* 8 */ "mmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ ".....bcd......."
+ /* 1 */ ".aaaaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaaaa."
+ /* 6 */ ".aaaaaaaaaaaaa."
+ /* 7 */ ".aaaaaaaaaaaaa."
+ /* 8 */ "..............."
+
+ // Level 2
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".aaaaaeaaaaaaa."
+ /* 2 */ ".a...........a."
+ /* 3 */ ".a...........a."
+ /* 4 */ ".a...........a."
+ /* 5 */ ".a...........a."
+ /* 6 */ ".a...........a."
+ /* 7 */ ".aaaaaaaaaaaaa."
+ /* 8 */ "..............."
+
+ // Level 3
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ ".afffagaffaffa."
+ /* 2 */ ".f...........f."
+ /* 3 */ ".f...........f."
+ /* 4 */ ".a...........a."
+ /* 5 */ ".f...........f."
+ /* 6 */ ".f...........f."
+ /* 7 */ ".affaffaffaffa."
+ /* 8 */ "..............."
+
+ // Level 4
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "ccccccccccccccc"
+ /* 1 */ "haaaaaaaaaaaaah"
+ /* 2 */ ".a...i.i..i..a."
+ /* 3 */ ".a...........a."
+ /* 4 */ ".a...........a."
+ /* 5 */ ".a...........a."
+ /* 6 */ ".a..j..j..j..a."
+ /* 7 */ "kaaaaaaaaaaaaak"
+ /* 8 */ "lllllllllllllll"
+
+ // Level 5
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "ccccccccccccccc"
+ /* 2 */ "haaaaaaaaaaaaah"
+ /* 3 */ ".a...........a."
+ /* 4 */ ".a...........a."
+ /* 5 */ ".a...........a."
+ /* 6 */ "kaaaaaaaaaaaaak"
+ /* 7 */ "lllllllllllllll"
+ /* 8 */ "..............."
+
+ // Level 6
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "ccccccccccccccc"
+ /* 3 */ "haaaaaaaaaaaaah"
+ /* 4 */ ".a...........a."
+ /* 5 */ "kaaaaaaaaaaaaak"
+ /* 6 */ "lllllllllllllll"
+ /* 7 */ "..............."
+ /* 8 */ "..............."
+
+ // Level 7
+ /* z\x* 11111 */
+ /* * 012345678901234 */
+ /* 0 */ "..............."
+ /* 1 */ "..............."
+ /* 2 */ "..............."
+ /* 3 */ "ccccccccccccccc"
+ /* 4 */ "aaaaaaaaaaaaaaa"
+ /* 5 */ "lllllllllllllll"
+ /* 6 */ "..............."
+ /* 7 */ "..............."
+ /* 8 */ "...............",
+
+ // Connectors:
+ "-1: 6, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House15x9
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House16x9:
+ // The data has been exported from the gallery Desert, area index 16, ID 126, created by Aloe_vera
+ {
+ // Size:
+ 16, 8, 9, // SizeX = 16, SizeY = 8, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 16, 7, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:102: 0\n" /* glasspane */
+ "g: 64:12\n" /* wooddoorblock */
+ "h:128: 7\n" /* sandstonestairs */
+ "i: 50: 3\n" /* torch */
+ "j: 50: 4\n" /* torch */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:128: 3\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmaaammmmm"
+ /* 1 */ "maaaaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaaaaam"
+ /* 8 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "........bcd....."
+ /* 1 */ ".aaaaaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaaaaa."
+ /* 6 */ ".aaaaaaaaaaaaaa."
+ /* 7 */ ".aaaaaaaaaaaaaa."
+ /* 8 */ "................"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ ".aaaaaaaaeaaaaa."
+ /* 2 */ ".a............a."
+ /* 3 */ ".a............a."
+ /* 4 */ ".a............a."
+ /* 5 */ ".a............a."
+ /* 6 */ ".a............a."
+ /* 7 */ ".aaaaaaaaaaaaaa."
+ /* 8 */ "................"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ ".affafffagafffa."
+ /* 2 */ ".f............f."
+ /* 3 */ ".f............f."
+ /* 4 */ ".a............a."
+ /* 5 */ ".f............f."
+ /* 6 */ ".f............f."
+ /* 7 */ ".affaffafffaffa."
+ /* 8 */ "................"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "cccccccccccccccc"
+ /* 1 */ "haaaaaaaaaaaaaah"
+ /* 2 */ ".a..i...i.i...a."
+ /* 3 */ ".a............a."
+ /* 4 */ ".a............a."
+ /* 5 */ ".a............a."
+ /* 6 */ ".a..j..j...j..a."
+ /* 7 */ "kaaaaaaaaaaaaaak"
+ /* 8 */ "llllllllllllllll"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "cccccccccccccccc"
+ /* 2 */ "haaaaaaaaaaaaaah"
+ /* 3 */ ".a............a."
+ /* 4 */ ".a............a."
+ /* 5 */ ".a............a."
+ /* 6 */ "kaaaaaaaaaaaaaak"
+ /* 7 */ "llllllllllllllll"
+ /* 8 */ "................"
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "cccccccccccccccc"
+ /* 3 */ "haaaaaaaaaaaaaah"
+ /* 4 */ ".a............a."
+ /* 5 */ "kaaaaaaaaaaaaaak"
+ /* 6 */ "llllllllllllllll"
+ /* 7 */ "................"
+ /* 8 */ "................"
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "................"
+ /* 1 */ "................"
+ /* 2 */ "................"
+ /* 3 */ "cccccccccccccccc"
+ /* 4 */ "aaaaaaaaaaaaaaaa"
+ /* 5 */ "llllllllllllllll"
+ /* 6 */ "................"
+ /* 7 */ "................"
+ /* 8 */ "................",
+
+ // Connectors:
+ "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House16x9
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House7x7:
+ // The data has been exported from the gallery Desert, area index 8, ID 112, created by Aloe_vera
+ {
+ // Size:
+ 7, 7, 7, // SizeX = 7, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 7, 6, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:102: 0\n" /* glasspane */
+ "g: 64:12\n" /* wooddoorblock */
+ "h:128: 7\n" /* sandstonestairs */
+ "i: 50: 3\n" /* torch */
+ "j:128: 6\n" /* sandstonestairs */
+ "k:128: 3\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "mmmaaam"
+ /* 1 */ "maaaaam"
+ /* 2 */ "maaaaam"
+ /* 3 */ "maaaaam"
+ /* 4 */ "maaaaam"
+ /* 5 */ "maaaaam"
+ /* 6 */ "mmmmmmm"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "...bcd."
+ /* 1 */ ".aaaaa."
+ /* 2 */ ".aaaaa."
+ /* 3 */ ".aaaaa."
+ /* 4 */ ".aaaaa."
+ /* 5 */ ".aaaaa."
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".aaaea."
+ /* 2 */ ".a...a."
+ /* 3 */ ".a...a."
+ /* 4 */ ".a...a."
+ /* 5 */ ".aaaaa."
+ /* 6 */ "......."
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".afaga."
+ /* 2 */ ".f...f."
+ /* 3 */ ".f...f."
+ /* 4 */ ".f...f."
+ /* 5 */ ".afffa."
+ /* 6 */ "......."
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "ccccccc"
+ /* 1 */ "haaaaah"
+ /* 2 */ ".a.i.a."
+ /* 3 */ ".a...a."
+ /* 4 */ ".a...a."
+ /* 5 */ "jaaaaaj"
+ /* 6 */ "kkkkkkk"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "ccccccc"
+ /* 2 */ "haaaaah"
+ /* 3 */ ".a...a."
+ /* 4 */ "jaaaaaj"
+ /* 5 */ "kkkkkkk"
+ /* 6 */ "......."
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "......."
+ /* 2 */ "ccccccc"
+ /* 3 */ "aaaaaaa"
+ /* 4 */ "kkkkkkk"
+ /* 5 */ "......."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House7x7
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House9x7:
+ // The data has been exported from the gallery Desert, area index 9, ID 113, created by xoft
+ {
+ // Size:
+ 9, 7, 7, // SizeX = 9, SizeY = 7, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 9, 6, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:102: 0\n" /* glasspane */
+ "g: 64:12\n" /* wooddoorblock */
+ "h:128: 7\n" /* sandstonestairs */
+ "i: 50: 3\n" /* torch */
+ "j: 50: 4\n" /* torch */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:128: 3\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmmaaammm"
+ /* 1 */ "maaaaaaam"
+ /* 2 */ "maaaaaaam"
+ /* 3 */ "maaaaaaam"
+ /* 4 */ "maaaaaaam"
+ /* 5 */ "maaaaaaam"
+ /* 6 */ "mmmmmmmmm"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "...bcd..."
+ /* 1 */ ".aaaaaaa."
+ /* 2 */ ".aaaaaaa."
+ /* 3 */ ".aaaaaaa."
+ /* 4 */ ".aaaaaaa."
+ /* 5 */ ".aaaaaaa."
+ /* 6 */ "........."
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ ".aaaeaaa."
+ /* 2 */ ".a.....a."
+ /* 3 */ ".a.....a."
+ /* 4 */ ".a.....a."
+ /* 5 */ ".aaaaaaa."
+ /* 6 */ "........."
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ ".afagafa."
+ /* 2 */ ".f.....f."
+ /* 3 */ ".f.....f."
+ /* 4 */ ".f.....f."
+ /* 5 */ ".affaffa."
+ /* 6 */ "........."
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "ccccccccc"
+ /* 1 */ "haaaaaaah"
+ /* 2 */ ".a.i.i.a."
+ /* 3 */ ".a.....a."
+ /* 4 */ ".a..j..a."
+ /* 5 */ "kaaaaaaak"
+ /* 6 */ "lllllllll"
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ "ccccccccc"
+ /* 2 */ "haaaaaaah"
+ /* 3 */ ".a.....a."
+ /* 4 */ "kaaaaaaak"
+ /* 5 */ "lllllllll"
+ /* 6 */ "........."
+
+ // Level 6
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ "........."
+ /* 2 */ "ccccccccc"
+ /* 3 */ "aaaaaaaaa"
+ /* 4 */ "lllllllll"
+ /* 5 */ "........."
+ /* 6 */ ".........",
+
+ // Connectors:
+ "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House9x7
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // House9x9:
+ // The data has been exported from the gallery Desert, area index 10, ID 114, created by xoft
+ {
+ // Size:
+ 9, 8, 9, // SizeX = 9, SizeY = 8, SizeZ = 9
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 9, 7, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e: 64: 7\n" /* wooddoorblock */
+ "f:102: 0\n" /* glasspane */
+ "g: 64:12\n" /* wooddoorblock */
+ "h:128: 7\n" /* sandstonestairs */
+ "i: 50: 3\n" /* torch */
+ "j: 50: 4\n" /* torch */
+ "k:128: 6\n" /* sandstonestairs */
+ "l:128: 3\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345678 */
+ /* 0 */ "mmmaaammm"
+ /* 1 */ "maaaaaaam"
+ /* 2 */ "maaaaaaam"
+ /* 3 */ "maaaaaaam"
+ /* 4 */ "maaaaaaam"
+ /* 5 */ "maaaaaaam"
+ /* 6 */ "maaaaaaam"
+ /* 7 */ "maaaaaaam"
+ /* 8 */ "mmmmmmmmm"
+
+ // Level 1
+ /* z\x* 012345678 */
+ /* 0 */ "...bcd..."
+ /* 1 */ ".aaaaaaa."
+ /* 2 */ ".aaaaaaa."
+ /* 3 */ ".aaaaaaa."
+ /* 4 */ ".aaaaaaa."
+ /* 5 */ ".aaaaaaa."
+ /* 6 */ ".aaaaaaa."
+ /* 7 */ ".aaaaaaa."
+ /* 8 */ "........."
+
+ // Level 2
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ ".aaaeaaa."
+ /* 2 */ ".a.....a."
+ /* 3 */ ".a.....a."
+ /* 4 */ ".a.....a."
+ /* 5 */ ".a.....a."
+ /* 6 */ ".a.....a."
+ /* 7 */ ".aaaaaaa."
+ /* 8 */ "........."
+
+ // Level 3
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ ".afagafa."
+ /* 2 */ ".f.....f."
+ /* 3 */ ".f.....f."
+ /* 4 */ ".a.....a."
+ /* 5 */ ".f.....f."
+ /* 6 */ ".f.....f."
+ /* 7 */ ".affaffa."
+ /* 8 */ "........."
+
+ // Level 4
+ /* z\x* 012345678 */
+ /* 0 */ "ccccccccc"
+ /* 1 */ "haaaaaaah"
+ /* 2 */ ".a.i.i.a."
+ /* 3 */ ".a.....a."
+ /* 4 */ ".a.....a."
+ /* 5 */ ".a.....a."
+ /* 6 */ ".a..j..a."
+ /* 7 */ "kaaaaaaak"
+ /* 8 */ "lllllllll"
+
+ // Level 5
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ "ccccccccc"
+ /* 2 */ "haaaaaaah"
+ /* 3 */ ".a.....a."
+ /* 4 */ ".a.....a."
+ /* 5 */ ".a.....a."
+ /* 6 */ "kaaaaaaak"
+ /* 7 */ "lllllllll"
+ /* 8 */ "........."
+
+ // Level 6
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ "........."
+ /* 2 */ "ccccccccc"
+ /* 3 */ "haaaaaaah"
+ /* 4 */ ".a.....a."
+ /* 5 */ "kaaaaaaak"
+ /* 6 */ "lllllllll"
+ /* 7 */ "........."
+ /* 8 */ "........."
+
+ // Level 7
+ /* z\x* 012345678 */
+ /* 0 */ "........."
+ /* 1 */ "........."
+ /* 2 */ "........."
+ /* 3 */ "ccccccccc"
+ /* 4 */ "aaaaaaaaa"
+ /* 5 */ "lllllllll"
+ /* 6 */ "........."
+ /* 7 */ "........."
+ /* 8 */ ".........",
+
+ // Connectors:
+ "-1: 4, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // House9x9
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseL14x12:
+ // The data has been exported from the gallery Desert, area index 14, ID 124, created by Aloe_vera
+ {
+ // Size:
+ 14, 8, 12, // SizeX = 14, SizeY = 8, SizeZ = 12
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 14, 7, 12, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e:128: 3\n" /* sandstonestairs */
+ "f: 64: 3\n" /* wooddoorblock */
+ "g: 64: 1\n" /* wooddoorblock */
+ "h:102: 0\n" /* glasspane */
+ "i: 64: 8\n" /* wooddoorblock */
+ "j:128: 7\n" /* sandstonestairs */
+ "k: 50: 3\n" /* torch */
+ "l: 50: 2\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n: 50: 4\n" /* torch */
+ "o:128: 6\n" /* sandstonestairs */
+ "p: 50: 1\n" /* torch */
+ "q:128: 5\n" /* sandstonestairs */
+ "r:128: 4\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmaaammmmmmm"
+ /* 1 */ "maaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaam"
+ /* 6 */ "maaaaaaaaaaaam"
+ /* 7 */ "maaaaaaaaaaaam"
+ /* 8 */ "mmmmaaaaaaaaam"
+ /* 9 */ "mmmmmmaaaaaaam"
+ /* 10 */ "mmmmmmaaaaaaam"
+ /* 11 */ "mmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "....bcd......."
+ /* 1 */ ".aaaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaaa."
+ /* 6 */ ".aaaaaaaaaaaa."
+ /* 7 */ ".aaaaaaaaaaaa."
+ /* 8 */ "....beaaaaaaa."
+ /* 9 */ "mmmmm.aaaaaaa."
+ /* 10 */ "mmmmm.aaaaaaa."
+ /* 11 */ "mmmmm........."
+
+ // Level 2
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".aaaafaaaaaaa."
+ /* 2 */ ".a..........a."
+ /* 3 */ ".a..........a."
+ /* 4 */ ".a..........a."
+ /* 5 */ ".a..........a."
+ /* 6 */ ".a..........a."
+ /* 7 */ ".aaaaga.....a."
+ /* 8 */ "......a.....a."
+ /* 9 */ "mmmmm.a.....a."
+ /* 10 */ "mmmmm.aaaaaaa."
+ /* 11 */ "mmmmm........."
+
+ // Level 3
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".ahhaiahhahha."
+ /* 2 */ ".h..........h."
+ /* 3 */ ".h..........h."
+ /* 4 */ ".a..........a."
+ /* 5 */ ".h..........h."
+ /* 6 */ ".h..........h."
+ /* 7 */ ".ahhaia.....a."
+ /* 8 */ "......h.....h."
+ /* 9 */ "mmmmm.h.....h."
+ /* 10 */ "mmmmm.ahhahha."
+ /* 11 */ "mmmmm........."
+
+ // Level 4
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "cccccccccccccc"
+ /* 1 */ "jaaaaaaaaaaaad"
+ /* 2 */ ".a..k.k.....ad"
+ /* 3 */ ".a..........ad"
+ /* 4 */ ".a.........lad"
+ /* 5 */ ".a..........ad"
+ /* 6 */ ".a..n.n.....ad"
+ /* 7 */ "oaaaaaap...lad"
+ /* 8 */ "eeeeeba.....ad"
+ /* 9 */ "mmmmmba.....ad"
+ /* 10 */ "mmmmmbaaaaaaad"
+ /* 11 */ "mmmmmbq.....rd"
+
+ // Level 5
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ "ccccccccccccd."
+ /* 2 */ "jaaaaaaaaaaad."
+ /* 3 */ ".a.........ad."
+ /* 4 */ ".a.........ad."
+ /* 5 */ ".a.........ad."
+ /* 6 */ "oaaaaaaa...ad."
+ /* 7 */ "eeeeeeba...ad."
+ /* 8 */ "......ba...ad."
+ /* 9 */ "mmmmm.ba...ad."
+ /* 10 */ "mmmmm.baaaaad."
+ /* 11 */ "mmmmm.bq...rd."
+
+ // Level 6
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".............."
+ /* 2 */ "cccccccccccc.."
+ /* 3 */ "jaaaaaaaaaad.."
+ /* 4 */ ".a........ad.."
+ /* 5 */ "oaaaaaaaa.ad.."
+ /* 6 */ "eeeeeeeea.ad.."
+ /* 7 */ ".......ba.ad.."
+ /* 8 */ ".......ba.ad.."
+ /* 9 */ "mmmmm..ba.ad.."
+ /* 10 */ "mmmmm..baaad.."
+ /* 11 */ "mmmmm..bq.rd.."
+
+ // Level 7
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".............."
+ /* 2 */ ".............."
+ /* 3 */ "ccccccccccc..."
+ /* 4 */ "aaaaaaaaaad..."
+ /* 5 */ "eeeeeeeebad..."
+ /* 6 */ "........bad..."
+ /* 7 */ "........bad..."
+ /* 8 */ "........bad..."
+ /* 9 */ "mmmmm...bad..."
+ /* 10 */ "mmmmm...bad..."
+ /* 11 */ "mmmmm...bad...",
+
+ // Connectors:
+ "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseL14x12
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // HouseL14x12:
+ // The data has been exported from the gallery Desert, area index 7, ID 82, created by Aloe_vera
+ {
+ // Size:
+ 14, 7, 12, // SizeX = 14, SizeY = 7, SizeZ = 12
+
+ // Hitbox (relative to bounding box):
+ -1, 0, 0, // MinX, MinY, MinZ
+ 14, 6, 12, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 0\n" /* sandstonestairs */
+ "c:128: 2\n" /* sandstonestairs */
+ "d:128: 1\n" /* sandstonestairs */
+ "e:128: 3\n" /* sandstonestairs */
+ "f: 64: 7\n" /* wooddoorblock */
+ "g: 64: 5\n" /* wooddoorblock */
+ "h:102: 0\n" /* glasspane */
+ "i: 64:12\n" /* wooddoorblock */
+ "j:128: 7\n" /* sandstonestairs */
+ "k: 50: 3\n" /* torch */
+ "l: 50: 4\n" /* torch */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 6\n" /* sandstonestairs */
+ "o:128: 5\n" /* sandstonestairs */
+ "p:128: 4\n" /* sandstonestairs */
+ "q: 50: 1\n" /* torch */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmaaammmm"
+ /* 1 */ "maaaaaaaaaaaam"
+ /* 2 */ "maaaaaaaaaaaam"
+ /* 3 */ "maaaaaaaaaaaam"
+ /* 4 */ "maaaaaaaaaaaam"
+ /* 5 */ "maaaaaaaaaaaam"
+ /* 6 */ "mmmmaaamaaaaam"
+ /* 7 */ "mmmmmmmmaaaaam"
+ /* 8 */ "mmmmmmmmaaaaam"
+ /* 9 */ "mmmmmmmmaaaaam"
+ /* 10 */ "mmmmmmmmaaaaam"
+ /* 11 */ "mmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".......bcd...."
+ /* 1 */ ".aaaaaaaaaaaa."
+ /* 2 */ ".aaaaaaaaaaaa."
+ /* 3 */ ".aaaaaaaaaaaa."
+ /* 4 */ ".aaaaaaaaaaaa."
+ /* 5 */ ".aaaaaaaaaaaa."
+ /* 6 */ "....bed.aaaaa."
+ /* 7 */ "........aaaaa."
+ /* 8 */ "........aaaaa."
+ /* 9 */ "........aaaaa."
+ /* 10 */ "........aaaaa."
+ /* 11 */ ".............."
+
+ // Level 2
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".aaaaaaafaaaa."
+ /* 2 */ ".a..........a."
+ /* 3 */ ".a..........a."
+ /* 4 */ ".a..........a."
+ /* 5 */ ".aaaagaaa...a."
+ /* 6 */ "........a...a."
+ /* 7 */ "........a...a."
+ /* 8 */ "........a...a."
+ /* 9 */ "........a...a."
+ /* 10 */ "........aaaaa."
+ /* 11 */ ".............."
+
+ // Level 3
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".ahhahhaiahha."
+ /* 2 */ ".h..........h."
+ /* 3 */ ".h..........h."
+ /* 4 */ ".h..........a."
+ /* 5 */ ".ahhaiahh...h."
+ /* 6 */ "........h...h."
+ /* 7 */ "........a...a."
+ /* 8 */ "........h...h."
+ /* 9 */ "........h...h."
+ /* 10 */ "........ahhha."
+ /* 11 */ ".............."
+
+ // Level 4
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "cccccccccccccc"
+ /* 1 */ "jaaaaaaaaaaaad"
+ /* 2 */ ".a.....k.k..ad"
+ /* 3 */ ".a..........ad"
+ /* 4 */ ".a..l.l.....ad"
+ /* 5 */ "naaaaaaaa...ad"
+ /* 6 */ "eeeeeeeba...ad"
+ /* 7 */ ".......ba...ad"
+ /* 8 */ ".......ba...ad"
+ /* 9 */ ".......ba...ad"
+ /* 10 */ ".......baaaaad"
+ /* 11 */ ".......bo...pd"
+
+ // Level 5
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ "ccccccccccccc."
+ /* 2 */ "jaaaaaaaaaaad."
+ /* 3 */ ".aq........ad."
+ /* 4 */ "naaaaaaaaa.ad."
+ /* 5 */ "eeeeeeeeba.ad."
+ /* 6 */ "........ba.ad."
+ /* 7 */ "........ba.ad."
+ /* 8 */ "........ba.ad."
+ /* 9 */ "........balad."
+ /* 10 */ "........baaad."
+ /* 11 */ "........bo.pd."
+
+ // Level 6
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ ".............."
+ /* 1 */ ".............."
+ /* 2 */ "cccccccccccc.."
+ /* 3 */ "aaaaaaaaaaad.."
+ /* 4 */ "eeeeeeeeebad.."
+ /* 5 */ ".........bad.."
+ /* 6 */ ".........bad.."
+ /* 7 */ ".........bad.."
+ /* 8 */ ".........bad.."
+ /* 9 */ ".........bad.."
+ /* 10 */ ".........bad.."
+ /* 11 */ ".........bad..",
+
+ // Connectors:
+ "-1: 8, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // HouseL14x12
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SingleField:
+ // The data has been exported from the gallery Desert, area index 17, ID 127, created by Aloe_vera
+ {
+ // Size:
+ 10, 3, 7, // SizeX = 10, SizeY = 3, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, -1, // MinX, MinY, MinZ
+ 10, 2, 7, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b: 60: 7\n" /* tilleddirt */
+ "c: 8: 0\n" /* water */
+ "d: 50: 5\n" /* torch */
+ "e: 59: 7\n" /* crops */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "aaaaaaaaaa"
+ /* 1 */ "aaaaaaaaaa"
+ /* 2 */ "aaaaaaaaaa"
+ /* 3 */ "aaaaaaaaaa"
+ /* 4 */ "aaaaaaaaaa"
+ /* 5 */ "aaaaaaaaaa"
+ /* 6 */ "aaaaaaaaaa"
+
+ // Level 1
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "aaaaaaaaaa"
+ /* 1 */ "abbbbbbbba"
+ /* 2 */ "abbbbbbbba"
+ /* 3 */ "acccccccca"
+ /* 4 */ "abbbbbbbba"
+ /* 5 */ "abbbbbbbba"
+ /* 6 */ "aaaaaaaaaa"
+
+ // Level 2
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "d........d"
+ /* 1 */ ".eeeeeeee."
+ /* 2 */ ".eeeeeeee."
+ /* 3 */ ".........."
+ /* 4 */ ".eeeeeeee."
+ /* 5 */ ".eeeeeeee."
+ /* 6 */ "d........d",
+
+ // Connectors:
+ "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // SingleField
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // SmallHut:
+ // The data has been exported from the gallery Desert, area index 4, ID 68, created by tonibm1999
+ {
+ // Size:
+ 5, 6, 6, // SizeX = 5, SizeY = 6, SizeZ = 6
+
+ // Hitbox (relative to bounding box):
+ -1, 0, -1, // MinX, MinY, MinZ
+ 5, 5, 5, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 24: 0\n" /* sandstone */
+ "b:128: 3\n" /* sandstonestairs */
+ "c: 24: 2\n" /* sandstone */
+ "d: 50: 5\n" /* torch */
+ "e: 26:10\n" /* bedblock */
+ "f: 26: 2\n" /* bedblock */
+ "g: 64: 5\n" /* wooddoorblock */
+ "h: 64:12\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 01234 */
+ /* 0 */ "aaaaa"
+ /* 1 */ "aaaaa"
+ /* 2 */ "aaaaa"
+ /* 3 */ "aaaaa"
+ /* 4 */ "aaaaa"
+ /* 5 */ "mmamm"
+
+ // Level 1
+ /* z\x* 01234 */
+ /* 0 */ "aaaaa"
+ /* 1 */ "aaaaa"
+ /* 2 */ "aaaaa"
+ /* 3 */ "aaaaa"
+ /* 4 */ "aaaaa"
+ /* 5 */ "..b.."
+
+ // Level 2
+ /* z\x* 01234 */
+ /* 0 */ "accca"
+ /* 1 */ "cdedc"
+ /* 2 */ "c.f.c"
+ /* 3 */ "c...c"
+ /* 4 */ "acgca"
+ /* 5 */ "....."
+
+ // Level 3
+ /* z\x* 01234 */
+ /* 0 */ "ac.ca"
+ /* 1 */ "c...c"
+ /* 2 */ "....."
+ /* 3 */ "c...c"
+ /* 4 */ "achca"
+ /* 5 */ "....."
+
+ // Level 4
+ /* z\x* 01234 */
+ /* 0 */ "accca"
+ /* 1 */ "c...c"
+ /* 2 */ "c...c"
+ /* 3 */ "c...c"
+ /* 4 */ "accca"
+ /* 5 */ "....."
+
+ // Level 5
+ /* z\x* 01234 */
+ /* 0 */ ".aaa."
+ /* 1 */ "aaaaa"
+ /* 2 */ "aaaaa"
+ /* 3 */ "aaaaa"
+ /* 4 */ ".aaa."
+ /* 5 */ ".....",
+
+ // Connectors:
+ "-1: 2, 1, 5: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // SmallHut
+}; // g_SandVillagePrefabs
+
+
+
+
+
+
+const cPrefab::sDef g_SandVillageStartingPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // RoofedWell:
+ // The data has been exported from the gallery Desert, area index 43, ID 274, created by Aloe_vera
+ {
+ // Size:
+ 7, 14, 7, // SizeX = 7, SizeY = 14, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 13, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 24: 0\n" /* sandstone */
+ "c: 8: 0\n" /* water */
+ "d: 12: 0\n" /* sand */
+ "e: 4: 0\n" /* cobblestone */
+ "f: 13: 0\n" /* gravel */
+ "g:118: 3\n" /* cauldronblock */
+ "h: 85: 0\n" /* fence */
+ "i:128: 2\n" /* sandstonestairs */
+ "j:128: 7\n" /* sandstonestairs */
+ "k:128: 4\n" /* sandstonestairs */
+ "l:128: 5\n" /* sandstonestairs */
+ "m: 19: 0\n" /* sponge */
+ "n:128: 6\n" /* sandstonestairs */
+ "o:128: 3\n" /* sandstonestairs */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "aaaaaaa"
+ /* 2 */ "aaaaaaa"
+ /* 3 */ "aaaaaaa"
+ /* 4 */ "aaaaaaa"
+ /* 5 */ "aaaaaaa"
+ /* 6 */ "aaaaaaa"
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "abbbbba"
+ /* 2 */ "abcccba"
+ /* 3 */ "abcccba"
+ /* 4 */ "abcccba"
+ /* 5 */ "abbbbba"
+ /* 6 */ "aaaaaaa"
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "abbbbba"
+ /* 2 */ "abcccba"
+ /* 3 */ "abcccba"
+ /* 4 */ "abcccba"
+ /* 5 */ "abbbbba"
+ /* 6 */ "aaaaaaa"
+
+ // Level 3
+ /* z\x* 0123456 */
+ /* 0 */ "aaaaaaa"
+ /* 1 */ "abbbbba"
+ /* 2 */ "abcccba"
+ /* 3 */ "abcccba"
+ /* 4 */ "abcccba"
+ /* 5 */ "abbbbba"
+ /* 6 */ "aaaaaaa"
+
+ // Level 4
+ /* z\x* 0123456 */
+ /* 0 */ "ddddddd"
+ /* 1 */ "dbbbbbd"
+ /* 2 */ "dbcccbd"
+ /* 3 */ "dbcccbd"
+ /* 4 */ "dbcccbd"
+ /* 5 */ "dbbbbbd"
+ /* 6 */ "ddddddd"
+
+ // Level 5
+ /* z\x* 0123456 */
+ /* 0 */ "ddddddd"
+ /* 1 */ "dbbbbbd"
+ /* 2 */ "dbcccbd"
+ /* 3 */ "dbcccbd"
+ /* 4 */ "dbcccbd"
+ /* 5 */ "dbbbbbd"
+ /* 6 */ "ddddddd"
+
+ // Level 6
+ /* z\x* 0123456 */
+ /* 0 */ "ddeeedd"
+ /* 1 */ "dbbbbbd"
+ /* 2 */ "ebcccbe"
+ /* 3 */ "ebcccbe"
+ /* 4 */ "ebcccbe"
+ /* 5 */ "dbbbbbd"
+ /* 6 */ "ddeeedd"
+
+ // Level 7
+ /* z\x* 0123456 */
+ /* 0 */ "ddfffdd"
+ /* 1 */ "dbbbbbd"
+ /* 2 */ "fbcccbf"
+ /* 3 */ "fbcccbf"
+ /* 4 */ "fbcccbf"
+ /* 5 */ "dbbbbbd"
+ /* 6 */ "ddfffdd"
+
+ // Level 8
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".bbbbb."
+ /* 2 */ ".b...b."
+ /* 3 */ ".b.g.b."
+ /* 4 */ ".b...b."
+ /* 5 */ ".bbbbb."
+ /* 6 */ "......."
+
+ // Level 9
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".h...h."
+ /* 2 */ "......."
+ /* 3 */ "...h..."
+ /* 4 */ "......."
+ /* 5 */ ".h...h."
+ /* 6 */ "......."
+
+ // Level 10
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".h...h."
+ /* 2 */ "......."
+ /* 3 */ "...h..."
+ /* 4 */ "......."
+ /* 5 */ ".h...h."
+ /* 6 */ "......."
+
+ // Level 11
+ /* z\x* 0123456 */
+ /* 0 */ "iiiiiii"
+ /* 1 */ "jbjjjbj"
+ /* 2 */ ".k...l."
+ /* 3 */ ".k.h.l."
+ /* 4 */ ".k...l."
+ /* 5 */ "nbnnnbn"
+ /* 6 */ "ooooooo"
+
+ // Level 12
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "iiiiiii"
+ /* 2 */ "jb...bj"
+ /* 3 */ ".b.h.b."
+ /* 4 */ "nb...bn"
+ /* 5 */ "ooooooo"
+ /* 6 */ "......."
+
+ // Level 13
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "......."
+ /* 2 */ "iiiiiii"
+ /* 3 */ "bbbbbbb"
+ /* 4 */ "ooooooo"
+ /* 5 */ "......."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "2: 6, 8, 3: 5\n" /* Type 2, direction X+ */
+ "2: 3, 8, 6: 3\n" /* Type 2, direction Z+ */
+ "2: 0, 8, 3: 4\n" /* Type 2, direction X- */
+ "2: 3, 8, 0: 2\n" /* Type 2, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // RoofedWell
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Well:
+ // The data has been exported from the gallery Desert, area index 0, ID 1, created by Aloe_vera
+ {
+ // Size:
+ 4, 13, 4, // SizeX = 4, SizeY = 13, SizeZ = 4
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 3, 12, 3, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 24: 0\n" /* sandstone */
+ "c: 8: 0\n" /* water */
+ "d: 85: 0\n" /* fence */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123 */
+ /* 0 */ "aaaa"
+ /* 1 */ "aaaa"
+ /* 2 */ "aaaa"
+ /* 3 */ "aaaa"
+
+ // Level 1
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 2
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 3
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 4
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 5
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 6
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 7
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bccb"
+ /* 2 */ "bccb"
+ /* 3 */ "bbbb"
+
+ // Level 8
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "b..b"
+ /* 2 */ "b..b"
+ /* 3 */ "bbbb"
+
+ // Level 9
+ /* z\x* 0123 */
+ /* 0 */ "d..d"
+ /* 1 */ "...."
+ /* 2 */ "...."
+ /* 3 */ "d..d"
+
+ // Level 10
+ /* z\x* 0123 */
+ /* 0 */ "d..d"
+ /* 1 */ "...."
+ /* 2 */ "...."
+ /* 3 */ "d..d"
+
+ // Level 11
+ /* z\x* 0123 */
+ /* 0 */ "d..d"
+ /* 1 */ "...."
+ /* 2 */ "...."
+ /* 3 */ "d..d"
+
+ // Level 12
+ /* z\x* 0123 */
+ /* 0 */ "bbbb"
+ /* 1 */ "bbbb"
+ /* 2 */ "bbbb"
+ /* 3 */ "bbbb",
+
+ // Connectors:
+ "2: 2, 8, 0: 2\n" /* Type 2, direction Z- */
+ "2: 0, 8, 1: 4\n" /* Type 2, direction X- */
+ "2: 1, 8, 3: 3\n" /* Type 2, direction Z+ */
+ "2: 3, 8, 2: 5\n" /* Type 2, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ true,
+ }, // Well
+};
+
+
+
+
+
+// The prefab counts:
+
+const size_t g_SandVillagePrefabsCount = ARRAYCOUNT(g_SandVillagePrefabs);
+
+const size_t g_SandVillageStartingPrefabsCount = ARRAYCOUNT(g_SandVillageStartingPrefabs);
+
diff --git a/src/Generating/Prefabs/SandVillagePrefabs.h b/src/Generating/Prefabs/SandVillagePrefabs.h
new file mode 100644
index 000000000..7b00db56f
--- /dev/null
+++ b/src/Generating/Prefabs/SandVillagePrefabs.h
@@ -0,0 +1,15 @@
+
+// SandVillagePrefabs.h
+
+// Declares the prefabs in the group SandVillage
+
+#include "../Prefab.h"
+
+
+
+
+
+extern const cPrefab::sDef g_SandVillagePrefabs[];
+extern const cPrefab::sDef g_SandVillageStartingPrefabs[];
+extern const size_t g_SandVillagePrefabsCount;
+extern const size_t g_SandVillageStartingPrefabsCount;
diff --git a/src/Generating/Prefabs/TestRailsPrefabs.cpp b/src/Generating/Prefabs/TestRailsPrefabs.cpp
new file mode 100644
index 000000000..f58b95225
--- /dev/null
+++ b/src/Generating/Prefabs/TestRailsPrefabs.cpp
@@ -0,0 +1,484 @@
+
+// TestRailsPrefabs.cpp
+
+// Defines the prefabs in the group TestRails
+
+// NOTE: This file has been generated automatically by GalExport!
+// Any manual changes will be overwritten by the next automatic export!
+
+#include "Globals.h"
+#include "TestRailsPrefabs.h"
+
+
+
+
+
+const cPrefab::sDef g_TestRailsPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // ActivatorRail:
+ // The data has been exported from the gallery Plains, area index 251, ID 746, created by Aloe_vera
+ {
+ // Size:
+ 7, 3, 7, // SizeX = 7, SizeY = 3, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 2, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 5: 0\n" /* wood */
+ "c:157: 0\n" /* activatorrail */
+ "d:157: 2\n" /* activatorrail */
+ "e:157: 3\n" /* activatorrail */
+ "f:157: 5\n" /* activatorrail */
+ "g: 50: 5\n" /* torch */
+ "h:157: 4\n" /* activatorrail */
+ "i:157: 1\n" /* activatorrail */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "aaab..."
+ /* 1 */ "abbbbb."
+ /* 2 */ "abbb.b."
+ /* 3 */ "bbbb.bb"
+ /* 4 */ ".b...b."
+ /* 5 */ ".bbbbb."
+ /* 6 */ "...b..."
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".cdbec."
+ /* 2 */ ".fg..f."
+ /* 3 */ ".b.g.b."
+ /* 4 */ ".h...h."
+ /* 5 */ ".cdbec."
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "...i..."
+ /* 2 */ "......."
+ /* 3 */ ".c...c."
+ /* 4 */ "......."
+ /* 5 */ "...i..."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */
+ "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */
+ "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */
+ "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */
+ "1: 0, 1, 3: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */
+ "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // ActivatorRail
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // DetectorRail:
+ // The data has been exported from the gallery Plains, area index 250, ID 745, created by Aloe_vera
+ {
+ // Size:
+ 7, 3, 7, // SizeX = 7, SizeY = 3, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 2, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 5: 0\n" /* wood */
+ "c: 28: 0\n" /* detectorrail */
+ "d: 28: 2\n" /* detectorrail */
+ "e: 28: 3\n" /* detectorrail */
+ "f: 28: 5\n" /* detectorrail */
+ "g: 50: 5\n" /* torch */
+ "h: 28: 4\n" /* detectorrail */
+ "i: 28: 1\n" /* detectorrail */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "aaab..."
+ /* 1 */ "abbbbb."
+ /* 2 */ "abbb.b."
+ /* 3 */ "bbbb.bb"
+ /* 4 */ ".b...b."
+ /* 5 */ ".bbbbb."
+ /* 6 */ "...b..."
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".cdbec."
+ /* 2 */ ".fg..f."
+ /* 3 */ ".b.g.b."
+ /* 4 */ ".h...h."
+ /* 5 */ ".cdbec."
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "...i..."
+ /* 2 */ "......."
+ /* 3 */ ".c...c."
+ /* 4 */ "......."
+ /* 5 */ "...i..."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */
+ "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */
+ "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */
+ "1: 0, 1, 3: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */
+ "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */
+ "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // DetectorRail
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // PowerRail:
+ // The data has been exported from the gallery Plains, area index 248, ID 743, created by Aloe_vera
+ {
+ // Size:
+ 7, 3, 7, // SizeX = 7, SizeY = 3, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 2, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 5: 0\n" /* wood */
+ "c: 27: 0\n" /* poweredrail */
+ "d: 27: 2\n" /* poweredrail */
+ "e: 27: 3\n" /* poweredrail */
+ "f: 27: 5\n" /* poweredrail */
+ "g: 50: 5\n" /* torch */
+ "h: 27: 4\n" /* poweredrail */
+ "i: 27: 1\n" /* poweredrail */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "aaab..."
+ /* 1 */ "abbbbb."
+ /* 2 */ "abbb.b."
+ /* 3 */ "bbbb.bb"
+ /* 4 */ ".b...b."
+ /* 5 */ ".bbbbb."
+ /* 6 */ "...b..."
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".cdbec."
+ /* 2 */ ".fg..f."
+ /* 3 */ ".b.g.b."
+ /* 4 */ ".h...h."
+ /* 5 */ ".cdbec."
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "...i..."
+ /* 2 */ "......."
+ /* 3 */ ".c...c."
+ /* 4 */ "......."
+ /* 5 */ "...i..."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */
+ "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */
+ "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */
+ "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */
+ "1: 0, 1, 3: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */
+ "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */
+ "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */
+ "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // PowerRail
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // RegularRail:
+ // The data has been exported from the gallery Plains, area index 247, ID 742, created by Aloe_vera
+ {
+ // Size:
+ 7, 3, 7, // SizeX = 7, SizeY = 3, SizeZ = 7
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 6, 2, 6, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 5: 0\n" /* wood */
+ "c: 66: 6\n" /* tracks */
+ "d: 66: 2\n" /* tracks */
+ "e: 66: 3\n" /* tracks */
+ "f: 66: 7\n" /* tracks */
+ "g: 66: 5\n" /* tracks */
+ "h: 50: 5\n" /* torch */
+ "i: 66: 4\n" /* tracks */
+ "j: 66: 9\n" /* tracks */
+ "k: 66: 8\n" /* tracks */
+ "l: 66: 1\n" /* tracks */
+ "m: 19: 0\n" /* sponge */
+ "n: 66: 0\n" /* tracks */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 0123456 */
+ /* 0 */ "aaab..."
+ /* 1 */ "abbbbb."
+ /* 2 */ "abbb.b."
+ /* 3 */ "bbbb.bb"
+ /* 4 */ ".b...b."
+ /* 5 */ ".bbbbb."
+ /* 6 */ "...b..."
+
+ // Level 1
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ ".cdbef."
+ /* 2 */ ".gh..g."
+ /* 3 */ ".b.h.b."
+ /* 4 */ ".i...i."
+ /* 5 */ ".jdbek."
+ /* 6 */ "......."
+
+ // Level 2
+ /* z\x* 0123456 */
+ /* 0 */ "......."
+ /* 1 */ "...l..."
+ /* 2 */ "......."
+ /* 3 */ ".n...n."
+ /* 4 */ "......."
+ /* 5 */ "...l..."
+ /* 6 */ ".......",
+
+ // Connectors:
+ "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */
+ "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */
+ "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */
+ "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */
+ "1: 0, 1, 3: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */
+ "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ false,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // RegularRail
+}; // g_TestRailsPrefabs
+
+
+
+
+
+
+const cPrefab::sDef g_TestRailsStartingPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // CentralPiece:
+ // The data has been exported from the gallery Plains, area index 249, ID 744, created by Aloe_vera
+ {
+ // Size:
+ 6, 3, 6, // SizeX = 6, SizeY = 3, SizeZ = 6
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 5, 2, 5, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 1: 0\n" /* stone */
+ "b: 5: 0\n" /* wood */
+ "c: 66: 6\n" /* tracks */
+ "d: 66: 2\n" /* tracks */
+ "e: 66: 3\n" /* tracks */
+ "f: 66: 7\n" /* tracks */
+ "g: 66: 5\n" /* tracks */
+ "h: 50: 5\n" /* torch */
+ "i: 66: 4\n" /* tracks */
+ "j: 66: 9\n" /* tracks */
+ "k: 66: 8\n" /* tracks */
+ "l: 66: 1\n" /* tracks */
+ "m: 19: 0\n" /* sponge */
+ "n: 66: 0\n" /* tracks */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 012345 */
+ /* 0 */ "aaab.."
+ /* 1 */ "abbbbb"
+ /* 2 */ "abbb.b"
+ /* 3 */ "bbbb.b"
+ /* 4 */ ".b...b"
+ /* 5 */ ".bbbbb"
+
+ // Level 1
+ /* z\x* 012345 */
+ /* 0 */ "......"
+ /* 1 */ ".cdbef"
+ /* 2 */ ".gh..g"
+ /* 3 */ ".b.h.b"
+ /* 4 */ ".i...i"
+ /* 5 */ ".jdbek"
+
+ // Level 2
+ /* z\x* 012345 */
+ /* 0 */ "......"
+ /* 1 */ "...l.."
+ /* 2 */ "......"
+ /* 3 */ ".n...n"
+ /* 4 */ "......"
+ /* 5 */ "...l..",
+
+ // Connectors:
+ "1: 3, 1, 6: 3\n" /* Type 1, direction Z+ */
+ "1: 0, 1, 3: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */
+ "-1: 3, 1, 6: 3\n" /* Type -1, direction Z+ */
+ "1: 6, 1, 3: 5\n" /* Type 1, direction X+ */
+ "-1: 6, 1, 3: 5\n" /* Type -1, direction X+ */
+ "1: 3, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 3, 1, 0: 2\n" /* Type -1, direction Z- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CentralPiece
+};
+
+
+
+
+
+// The prefab counts:
+
+const size_t g_TestRailsPrefabsCount = ARRAYCOUNT(g_TestRailsPrefabs);
+
+const size_t g_TestRailsStartingPrefabsCount = ARRAYCOUNT(g_TestRailsStartingPrefabs);
+
diff --git a/src/Generating/Prefabs/TestRailsPrefabs.h b/src/Generating/Prefabs/TestRailsPrefabs.h
new file mode 100644
index 000000000..24b84de74
--- /dev/null
+++ b/src/Generating/Prefabs/TestRailsPrefabs.h
@@ -0,0 +1,15 @@
+
+// TestRailsPrefabs.h
+
+// Declares the prefabs in the group TestRails
+
+#include "../Prefab.h"
+
+
+
+
+
+extern const cPrefab::sDef g_TestRailsPrefabs[];
+extern const cPrefab::sDef g_TestRailsStartingPrefabs[];
+extern const size_t g_TestRailsPrefabsCount;
+extern const size_t g_TestRailsStartingPrefabsCount;
diff --git a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp
new file mode 100644
index 000000000..1655f50b9
--- /dev/null
+++ b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp
@@ -0,0 +1,2274 @@
+
+// UnderwaterBasePrefabs.cpp
+
+// Defines the prefabs in the group UnderwaterBase
+
+// NOTE: This file has been generated automatically by GalExport!
+// Any manual changes will be overwritten by the next automatic export!
+
+#include "Globals.h"
+#include "UnderwaterBasePrefabs.h"
+
+
+
+
+
+const cPrefab::sDef g_UnderwaterBasePrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // BrokenRoom:
+ // The data has been exported from the gallery Water, area index 49, ID 680, created by STR_Warrior
+ {
+ // Size:
+ 14, 7, 12, // SizeX = 14, SizeY = 7, SizeZ = 12
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 13, 6, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 20: 0\n" /* glass */
+ "c: 5: 5\n" /* wood */
+ "d: 8: 0\n" /* water */
+ "e: 64: 4\n" /* wooddoorblock */
+ "f: 64:12\n" /* wooddoorblock */
+ "g: 64:13\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmaaaammmmmm"
+ /* 2 */ "mmmaabbaammmmm"
+ /* 3 */ "mmaabbbbaammmm"
+ /* 4 */ "maabbbbbbaammm"
+ /* 5 */ "mabbbbbbbbaaac"
+ /* 6 */ "mabbbbbbbbaaac"
+ /* 7 */ "maabbbbbbaammm"
+ /* 8 */ "mmaabbbbaammmm"
+ /* 9 */ "mmmaabbaammmmm"
+ /* 10 */ "mmmmaaaammmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmaammmmmmm"
+ /* 1 */ "mmmaaddaammmmm"
+ /* 2 */ "mmaaddddaammmm"
+ /* 3 */ "maaddddddaammm"
+ /* 4 */ "maddddddddaaac"
+ /* 5 */ "adddddddddddde"
+ /* 6 */ "adddddddddddde"
+ /* 7 */ "maddddddddaaac"
+ /* 8 */ "maaddddddaammm"
+ /* 9 */ "mmaaddddaammmm"
+ /* 10 */ "mmmaaddaammmmm"
+ /* 11 */ "mmmmmaammmmmmm"
+
+ // Level 2
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmbbmmmmmmm"
+ /* 1 */ "mmmbb..bbmmmmm"
+ /* 2 */ "mmbb....bbmmmm"
+ /* 3 */ "mbb......bbmmm"
+ /* 4 */ "mb........bbac"
+ /* 5 */ "b............f"
+ /* 6 */ "b............g"
+ /* 7 */ "mb........bbac"
+ /* 8 */ "mbb......bbmmm"
+ /* 9 */ "mmbb....bbmmmm"
+ /* 10 */ "mmmbb..bbmmmmm"
+ /* 11 */ "mmmmmbbmmmmmmm"
+
+ // Level 3
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmbbmmmmmmm"
+ /* 1 */ "mmmbb..bbmmmmm"
+ /* 2 */ "mmbb....bbmmmm"
+ /* 3 */ "mbb......bbmmm"
+ /* 4 */ "mb........bbac"
+ /* 5 */ "b..........bac"
+ /* 6 */ "b..........bac"
+ /* 7 */ "mb........bbac"
+ /* 8 */ "mbb......bbmmm"
+ /* 9 */ "mmbb....bbmmmm"
+ /* 10 */ "mmmbb..bbmmmmm"
+ /* 11 */ "mmmmmbbmmmmmmm"
+
+ // Level 4
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmm.bmmmmmmm"
+ /* 2 */ "mmmmb..bmmmmmm"
+ /* 3 */ "mmmb....bmmmmm"
+ /* 4 */ "mmb......bmmmm"
+ /* 5 */ "m.........bmmm"
+ /* 6 */ "mb........bmmm"
+ /* 7 */ "mmb......bmmmm"
+ /* 8 */ "mmm.....bmmmmm"
+ /* 9 */ "mmmmb..bmmmmmm"
+ /* 10 */ "mmmmmbbmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+
+ // Level 5
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmbbmmmmmmm"
+ /* 3 */ "mmmm....mmmmmm"
+ /* 4 */ "mmmb....bmmmmm"
+ /* 5 */ "mmb......bmmmm"
+ /* 6 */ "mmb......bmmmm"
+ /* 7 */ "mmmb.....mmmmm"
+ /* 8 */ "mmmmb..bmmmmmm"
+ /* 9 */ "mmmmmbbmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+
+ // Level 6
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmbbmmmmmmm"
+ /* 4 */ "mmmmbbbbmmmmmm"
+ /* 5 */ "mmmbbbbbbmmmmm"
+ /* 6 */ "mmmbb.bbbmmmmm"
+ /* 7 */ "mmmmbbbbmmmmmm"
+ /* 8 */ "mmmmmbbmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm",
+
+ // Connectors:
+ "1: 13, 1, 6: 5\n" /* Type 1, direction X+ */
+ "-1: 13, 1, 5: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // BrokenRoom
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Corridor16:
+ // The data has been exported from the gallery Water, area index 25, ID 566, created by xoft
+ {
+ // Size:
+ 16, 4, 4, // SizeX = 16, SizeY = 4, SizeZ = 4
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 3, 3, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 64: 2\n" /* wooddoorblock */
+ "d: 64: 0\n" /* wooddoorblock */
+ "e: 20: 0\n" /* glass */
+ "f: 64: 9\n" /* wooddoorblock */
+ "g: 76: 3\n" /* redstonetorchon */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i: 76: 4\n" /* redstonetorchon */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "abbbbbbbbbbbbbba"
+ /* 2 */ "abbbbbbbbbbbbbba"
+ /* 3 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "abbbbbbbbbbbbbba"
+ /* 1 */ "c..............d"
+ /* 2 */ "c..............d"
+ /* 3 */ "abbbbbbbbbbbbbba"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "abeebbbeebbbeeba"
+ /* 1 */ "f...g......g...h"
+ /* 2 */ "h...i......i...f"
+ /* 3 */ "abeebbbeebbbeeba"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "abbbbbbbbbbbbbba"
+ /* 1 */ "abbbbbbbbbbbbbba"
+ /* 2 */ "abbbbbbbbbbbbbba"
+ /* 3 */ "abbbbbbbbbbbbbba",
+
+ // Connectors:
+ "1: 0, 1, 1: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */
+ "1: 15, 1, 2: 5\n" /* Type 1, direction X+ */
+ "-1: 15, 1, 1: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 500,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // Corridor16
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CorridorCorner:
+ // The data has been exported from the gallery Water, area index 26, ID 569, created by xoft
+ {
+ // Size:
+ 10, 4, 10, // SizeX = 10, SizeY = 4, SizeZ = 10
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 9, 3, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 64: 5\n" /* wooddoorblock */
+ "d: 64: 2\n" /* wooddoorblock */
+ "e: 64: 4\n" /* wooddoorblock */
+ "f: 64: 1\n" /* wooddoorblock */
+ "g: 20: 0\n" /* glass */
+ "h: 64:12\n" /* wooddoorblock */
+ "i: 76: 3\n" /* redstonetorchon */
+ "j: 64: 8\n" /* wooddoorblock */
+ "k: 76: 4\n" /* redstonetorchon */
+ "l: 76: 2\n" /* redstonetorchon */
+ "m: 19: 0\n" /* sponge */
+ "n: 76: 1\n" /* redstonetorchon */,
+
+ // Block data:
+ // Level 0
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "mmmmmmmmmm"
+ /* 1 */ "abbbbbmmmm"
+ /* 2 */ "abbbbbbbmm"
+ /* 3 */ "mmmbbbbbmm"
+ /* 4 */ "mmmmmbbbbm"
+ /* 5 */ "mmmmmmbbbm"
+ /* 6 */ "mmmmmmbbbm"
+ /* 7 */ "mmmmmmmbbm"
+ /* 8 */ "mmmmmmmbbm"
+ /* 9 */ "mmmmmmmaam"
+
+ // Level 1
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "abbbbbmmmm"
+ /* 1 */ "c.....bbmm"
+ /* 2 */ "d.......bm"
+ /* 3 */ "abb.....bm"
+ /* 4 */ "mmmbb....b"
+ /* 5 */ "mmmmmb...b"
+ /* 6 */ "mmmmmb...b"
+ /* 7 */ "mmmmmmb..b"
+ /* 8 */ "mmmmmmb..b"
+ /* 9 */ "mmmmmmaefa"
+
+ // Level 2
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "abggbbmmmm"
+ /* 1 */ "h...i.bbmm"
+ /* 2 */ "j.......bm"
+ /* 3 */ "abbk....bm"
+ /* 4 */ "mmmbb....b"
+ /* 5 */ "mmmmmb..lb"
+ /* 6 */ "mmmmmbn..g"
+ /* 7 */ "mmmmmmb..g"
+ /* 8 */ "mmmmmmb..b"
+ /* 9 */ "mmmmmmahja"
+
+ // Level 3
+ /* z\x* */
+ /* * 0123456789 */
+ /* 0 */ "abbbbbmmmm"
+ /* 1 */ "abbbbbbbmm"
+ /* 2 */ "abbbbbbbbm"
+ /* 3 */ "abbbbbbbbm"
+ /* 4 */ "mmmbbbbbbb"
+ /* 5 */ "mmmmmbbbbb"
+ /* 6 */ "mmmmmbbbbb"
+ /* 7 */ "mmmmmmbbbb"
+ /* 8 */ "mmmmmmbbbb"
+ /* 9 */ "mmmmmmaaaa",
+
+ // Connectors:
+ "1: 7, 1, 9: 3\n" /* Type 1, direction Z+ */
+ "-1: 8, 1, 9: 3\n" /* Type -1, direction Z+ */
+ "1: 0, 1, 1: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 200,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CorridorCorner
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CorridorCrossing:
+ // The data has been exported from the gallery Water, area index 31, ID 581, created by LO1ZB
+ {
+ // Size:
+ 16, 4, 16, // SizeX = 16, SizeY = 4, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 3, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 64: 3\n" /* wooddoorblock */
+ "d: 64: 6\n" /* wooddoorblock */
+ "e: 64: 5\n" /* wooddoorblock */
+ "f: 64: 0\n" /* wooddoorblock */
+ "g: 64: 2\n" /* wooddoorblock */
+ "h: 64: 1\n" /* wooddoorblock */
+ "i: 64: 8\n" /* wooddoorblock */
+ "j: 64:12\n" /* wooddoorblock */
+ "k: 20: 0\n" /* glass */
+ "l: 76: 1\n" /* redstonetorchon */
+ "m: 19: 0\n" /* sponge */
+ "n: 76: 2\n" /* redstonetorchon */
+ "o: 76: 3\n" /* redstonetorchon */
+ "p: 76: 4\n" /* redstonetorchon */
+ "q: 64: 9\n" /* wooddoorblock */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmaammmmmmm"
+ /* 1 */ "mmmmmmmbbmmmmmmm"
+ /* 2 */ "mmmmmmmbbmmmmmmm"
+ /* 3 */ "mmmmmmmbbmmmmmmm"
+ /* 4 */ "mmmmmmmbbmmmmmmm"
+ /* 5 */ "mmmmmmmbbmmmmmmm"
+ /* 6 */ "mmmmmmmbbmmmmmmm"
+ /* 7 */ "abbbbbbbbbbbbbba"
+ /* 8 */ "abbbbbbbbbbbbbba"
+ /* 9 */ "mmmmmmmbbmmmmmmm"
+ /* 10 */ "mmmmmmmbbmmmmmmm"
+ /* 11 */ "mmmmmmmbbmmmmmmm"
+ /* 12 */ "mmmmmmmbbmmmmmmm"
+ /* 13 */ "mmmmmmmbbmmmmmmm"
+ /* 14 */ "mmmmmmmbbmmmmmmm"
+ /* 15 */ "mmmmmmmaammmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmacdammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmb..bmmmmmm"
+ /* 3 */ "mmmmmmb..bmmmmmm"
+ /* 4 */ "mmmmmmb..bmmmmmm"
+ /* 5 */ "mmmmmmb..bmmmmmm"
+ /* 6 */ "abbbbbb..bbbbbba"
+ /* 7 */ "e..............f"
+ /* 8 */ "g..............f"
+ /* 9 */ "abbbbbb..bbbbbba"
+ /* 10 */ "mmmmmmb..bmmmmmm"
+ /* 11 */ "mmmmmmb..bmmmmmm"
+ /* 12 */ "mmmmmmb..bmmmmmm"
+ /* 13 */ "mmmmmmb..bmmmmmm"
+ /* 14 */ "mmmmmmb..bmmmmmm"
+ /* 15 */ "mmmmmmahhammmmmm"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmaijammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmk..kmmmmmm"
+ /* 3 */ "mmmmmmk..kmmmmmm"
+ /* 4 */ "mmmmmmblnbmmmmmm"
+ /* 5 */ "mmmmmmb..bmmmmmm"
+ /* 6 */ "abkkbbb..bbbkkba"
+ /* 7 */ "j...o......o...i"
+ /* 8 */ "i...p......p...q"
+ /* 9 */ "abkkbbb..bbbkkba"
+ /* 10 */ "mmmmmmb..bmmmmmm"
+ /* 11 */ "mmmmmmblnbmmmmmm"
+ /* 12 */ "mmmmmmk..kmmmmmm"
+ /* 13 */ "mmmmmmk..kmmmmmm"
+ /* 14 */ "mmmmmmb..bmmmmmm"
+ /* 15 */ "mmmmmmaqiammmmmm"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmaaaammmmmm"
+ /* 1 */ "mmmmmmbbbbmmmmmm"
+ /* 2 */ "mmmmmmbbbbmmmmmm"
+ /* 3 */ "mmmmmmbbbbmmmmmm"
+ /* 4 */ "mmmmmmbbbbmmmmmm"
+ /* 5 */ "mmmmmmbbbbmmmmmm"
+ /* 6 */ "abbbbbbbbbbbbbba"
+ /* 7 */ "abbbbbbbbbbbbbba"
+ /* 8 */ "abbbbbbbbbbbbbba"
+ /* 9 */ "abbbbbbbbbbbbbba"
+ /* 10 */ "mmmmmmbbbbmmmmmm"
+ /* 11 */ "mmmmmmbbbbmmmmmm"
+ /* 12 */ "mmmmmmbbbbmmmmmm"
+ /* 13 */ "mmmmmmbbbbmmmmmm"
+ /* 14 */ "mmmmmmbbbbmmmmmm"
+ /* 15 */ "mmmmmmaaaammmmmm",
+
+ // Connectors:
+ "1: 0, 1, 7: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */
+ "1: 7, 1, 15: 3\n" /* Type 1, direction Z+ */
+ "-1: 8, 1, 15: 3\n" /* Type -1, direction Z+ */
+ "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */
+ "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */
+ "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CorridorCrossing
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CorridorStairs:
+ // The data has been exported from the gallery Water, area index 32, ID 582, created by LO1ZB
+ {
+ // Size:
+ 16, 9, 4, // SizeX = 16, SizeY = 9, SizeZ = 4
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 8, 3, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 64: 2\n" /* wooddoorblock */
+ "d: 53: 0\n" /* woodstairs */
+ "e: 20: 0\n" /* glass */
+ "f: 64: 9\n" /* wooddoorblock */
+ "g: 76: 3\n" /* redstonetorchon */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i: 76: 4\n" /* redstonetorchon */
+ "j: 64: 0\n" /* wooddoorblock */
+ "k: 64: 7\n" /* wooddoorblock */
+ "l: 64:12\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "abbbbbbbmmmmmmmm"
+ /* 2 */ "abbbbbbbmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "abbbbbbbmmmmmmmm"
+ /* 1 */ "c.....dbbmmmmmmm"
+ /* 2 */ "c.....dbbmmmmmmm"
+ /* 3 */ "abbbbbbbmmmmmmmm"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "abeebbbbbmmmmmmm"
+ /* 1 */ "f...g..dbbmmmmmm"
+ /* 2 */ "h...i..dbbmmmmmm"
+ /* 3 */ "abeebbbbbmmmmmmm"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "abbbbbbbbbmmmmmm"
+ /* 1 */ "abbbb...dbbmmmmm"
+ /* 2 */ "abbbb...dbbmmmmm"
+ /* 3 */ "abbbbbbbbbmmmmmm"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmbbbbbmmmmmm"
+ /* 1 */ "mmmmmb...dbbmmmm"
+ /* 2 */ "mmmmmb...dbbmmmm"
+ /* 3 */ "mmmmmbbbbbmmmmmm"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmbbbbbmmmmm"
+ /* 1 */ "mmmmmmb...dbbbba"
+ /* 2 */ "mmmmmmb...dbbbba"
+ /* 3 */ "mmmmmmbbbbbmmmmm"
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmbbbbbbbba"
+ /* 1 */ "mmmmmmmb.......j"
+ /* 2 */ "mmmmmmmb.......k"
+ /* 3 */ "mmmmmmmbbbbbbbba"
+
+ // Level 7
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmbbbeebba"
+ /* 1 */ "mmmmmmmmb.g....h"
+ /* 2 */ "mmmmmmmmb.i....l"
+ /* 3 */ "mmmmmmmmbbbeebba"
+
+ // Level 8
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmbbbbbba"
+ /* 1 */ "mmmmmmmmmbbbbbba"
+ /* 2 */ "mmmmmmmmmbbbbbba"
+ /* 3 */ "mmmmmmmmmbbbbbba",
+
+ // Connectors:
+ "1: 0, 1, 1: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 2: 4\n" /* Type -1, direction X- */
+ "1: 15, 6, 2: 5\n" /* Type 1, direction X+ */
+ "-1: 15, 6, 1: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CorridorStairs
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // CorridorTee:
+ // The data has been exported from the gallery Water, area index 29, ID 576, created by LO1ZB
+ {
+ // Size:
+ 16, 4, 10, // SizeX = 16, SizeY = 4, SizeZ = 10
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 3, 9, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 64: 3\n" /* wooddoorblock */
+ "d: 64: 6\n" /* wooddoorblock */
+ "e: 64: 5\n" /* wooddoorblock */
+ "f: 64: 0\n" /* wooddoorblock */
+ "g: 64: 2\n" /* wooddoorblock */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i: 64:12\n" /* wooddoorblock */
+ "j: 20: 0\n" /* glass */
+ "k: 76: 1\n" /* redstonetorchon */
+ "l: 76: 2\n" /* redstonetorchon */
+ "m: 19: 0\n" /* sponge */
+ "n: 76: 3\n" /* redstonetorchon */
+ "o: 76: 4\n" /* redstonetorchon */
+ "p: 64: 9\n" /* wooddoorblock */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmaammmmmmm"
+ /* 1 */ "mmmmmmmbbmmmmmmm"
+ /* 2 */ "mmmmmmmbbmmmmmmm"
+ /* 3 */ "mmmmmmmbbmmmmmmm"
+ /* 4 */ "mmmmmmmbbmmmmmmm"
+ /* 5 */ "mmmmmmmbbmmmmmmm"
+ /* 6 */ "mmmmmmmbbmmmmmmm"
+ /* 7 */ "abbbbbbbbbbbbbba"
+ /* 8 */ "abbbbbbbbbbbbbba"
+ /* 9 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmacdammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmb..bmmmmmm"
+ /* 3 */ "mmmmmmb..bmmmmmm"
+ /* 4 */ "mmmmmmb..bmmmmmm"
+ /* 5 */ "mmmmmmb..bmmmmmm"
+ /* 6 */ "abbbbbb..bbbbbba"
+ /* 7 */ "e..............f"
+ /* 8 */ "g..............f"
+ /* 9 */ "abbbbbbbbbbbbbba"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmahiammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmj..jmmmmmm"
+ /* 3 */ "mmmmmmj..jmmmmmm"
+ /* 4 */ "mmmmmmbklbmmmmmm"
+ /* 5 */ "mmmmmmb..bmmmmmm"
+ /* 6 */ "abjjbbb..bbbjjba"
+ /* 7 */ "i...n......n...h"
+ /* 8 */ "h...o......o...p"
+ /* 9 */ "abjjbbbjjbbbjjba"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmaaaammmmmm"
+ /* 1 */ "mmmmmmbbbbmmmmmm"
+ /* 2 */ "mmmmmmbbbbmmmmmm"
+ /* 3 */ "mmmmmmbbbbmmmmmm"
+ /* 4 */ "mmmmmmbbbbmmmmmm"
+ /* 5 */ "mmmmmmbbbbmmmmmm"
+ /* 6 */ "abbbbbbbbbbbbbba"
+ /* 7 */ "abbbbbbbbbbbbbba"
+ /* 8 */ "abbbbbbbbbbbbbba"
+ /* 9 */ "abbbbbbbbbbbbbba",
+
+ // Connectors:
+ "1: 0, 1, 7: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */
+ "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */
+ "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */
+ "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CorridorTee
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // ViewingCorner:
+ // The data has been exported from the gallery Water, area index 40, ID 613, created by LO1ZB
+ {
+ // Size:
+ 14, 7, 14, // SizeX = 14, SizeY = 7, SizeZ = 14
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 13, 6, 13, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 20: 0\n" /* glass */
+ "c: 5: 5\n" /* wood */
+ "d: 76: 3\n" /* redstonetorchon */
+ "e: 76: 1\n" /* redstonetorchon */
+ "f: 64: 0\n" /* wooddoorblock */
+ "g: 76: 4\n" /* redstonetorchon */
+ "h: 76: 2\n" /* redstonetorchon */
+ "i: 64: 1\n" /* wooddoorblock */
+ "j: 64: 8\n" /* wooddoorblock */
+ "k: 64: 9\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmaaaammmmmm"
+ /* 2 */ "mmmaabbaammmmm"
+ /* 3 */ "mmaabbbbaammmm"
+ /* 4 */ "maabbbbbbaammm"
+ /* 5 */ "mabbbbbbbbaaac"
+ /* 6 */ "mabbbbbbbbaaac"
+ /* 7 */ "maabbbbbbaammm"
+ /* 8 */ "mmaabbbbaammmm"
+ /* 9 */ "mmmaabbaammmmm"
+ /* 10 */ "mmmmaaaammmmmm"
+ /* 11 */ "mmmmmaammmmmmm"
+ /* 12 */ "mmmmmaammmmmmm"
+ /* 13 */ "mmmmmccmmmmmmm"
+
+ // Level 1
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmaammmmmmm"
+ /* 1 */ "mmmaaddaammmmm"
+ /* 2 */ "mmaa....aammmm"
+ /* 3 */ "maa......aammm"
+ /* 4 */ "ma........aaac"
+ /* 5 */ "ae........d..f"
+ /* 6 */ "ae........g..f"
+ /* 7 */ "ma........aaac"
+ /* 8 */ "maa......aammm"
+ /* 9 */ "mmaa....aammmm"
+ /* 10 */ "mmmaaehaammmmm"
+ /* 11 */ "mmmma..ammmmmm"
+ /* 12 */ "mmmma..ammmmmm"
+ /* 13 */ "mmmmciicmmmmmm"
+
+ // Level 2
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmbbmmmmmmm"
+ /* 1 */ "mmmbb..bbmmmmm"
+ /* 2 */ "mmbb....bbmmmm"
+ /* 3 */ "mbb......bbmmm"
+ /* 4 */ "mb........bbac"
+ /* 5 */ "b............j"
+ /* 6 */ "b............k"
+ /* 7 */ "mb........bbac"
+ /* 8 */ "mbb......bbmmm"
+ /* 9 */ "mmbb....bbmmmm"
+ /* 10 */ "mmmbb..bbmmmmm"
+ /* 11 */ "mmmmb..bmmmmmm"
+ /* 12 */ "mmmma..ammmmmm"
+ /* 13 */ "mmmmckjcmmmmmm"
+
+ // Level 3
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmbbmmmmmmm"
+ /* 1 */ "mmmbb..bbmmmmm"
+ /* 2 */ "mmbb....bbmmmm"
+ /* 3 */ "mbb......bbmmm"
+ /* 4 */ "mb........bbac"
+ /* 5 */ "b..........bac"
+ /* 6 */ "b..........bac"
+ /* 7 */ "mb........bbac"
+ /* 8 */ "mbb......bbmmm"
+ /* 9 */ "mmbb....bbmmmm"
+ /* 10 */ "mmmbb..bbmmmmm"
+ /* 11 */ "mmmmbbbbmmmmmm"
+ /* 12 */ "mmmmaaaammmmmm"
+ /* 13 */ "mmmmccccmmmmmm"
+
+ // Level 4
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmbbmmmmmmm"
+ /* 2 */ "mmmmb..bmmmmmm"
+ /* 3 */ "mmmb....bmmmmm"
+ /* 4 */ "mmb......bmmmm"
+ /* 5 */ "mb........bmmm"
+ /* 6 */ "mb........bmmm"
+ /* 7 */ "mmb......bmmmm"
+ /* 8 */ "mmmb....bmmmmm"
+ /* 9 */ "mmmmb..bmmmmmm"
+ /* 10 */ "mmmmmbbmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmm"
+
+ // Level 5
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmbbmmmmmmm"
+ /* 3 */ "mmmmb..bmmmmmm"
+ /* 4 */ "mmmb....bmmmmm"
+ /* 5 */ "mmb......bmmmm"
+ /* 6 */ "mmb......bmmmm"
+ /* 7 */ "mmmb....bmmmmm"
+ /* 8 */ "mmmmb..bmmmmmm"
+ /* 9 */ "mmmmmbbmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmm"
+
+ // Level 6
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmbbmmmmmmm"
+ /* 4 */ "mmmmbbbbmmmmmm"
+ /* 5 */ "mmmbbbbbbmmmmm"
+ /* 6 */ "mmmbbbbbbmmmmm"
+ /* 7 */ "mmmmbbbbmmmmmm"
+ /* 8 */ "mmmmmbbmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmm",
+
+ // Connectors:
+ "1: 13, 1, 6: 5\n" /* Type 1, direction X+ */
+ "-1: 13, 1, 5: 5\n" /* Type -1, direction X+ */
+ "1: 5, 1, 13: 3\n" /* Type 1, direction Z+ */
+ "-1: 6, 1, 13: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // ViewingCorner
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // ViewingCorridor:
+ // The data has been exported from the gallery Water, area index 27, ID 571, created by LO1ZB
+ {
+ // Size:
+ 16, 5, 6, // SizeX = 16, SizeY = 5, SizeZ = 6
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 4, 5, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 5: 5\n" /* wood */
+ "c: 20: 0\n" /* glass */
+ "d: 64: 5\n" /* wooddoorblock */
+ "e: 64: 0\n" /* wooddoorblock */
+ "f: 64: 2\n" /* wooddoorblock */
+ "g: 76: 3\n" /* redstonetorchon */
+ "h: 64:12\n" /* wooddoorblock */
+ "i: 64: 8\n" /* wooddoorblock */
+ "j: 64: 9\n" /* wooddoorblock */
+ "k: 76: 4\n" /* redstonetorchon */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmaaaaaaaaaaaamm"
+ /* 1 */ "mmaaaaaaaaaaaamm"
+ /* 2 */ "baaccccccccccaab"
+ /* 3 */ "baaccccccccccaab"
+ /* 4 */ "mmaaaaaaaaaaaamm"
+ /* 5 */ "mmmaaaaaaaaaammm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmaccccccccccamm"
+ /* 1 */ "ba............ab"
+ /* 2 */ "d..............e"
+ /* 3 */ "f..............e"
+ /* 4 */ "ba............ab"
+ /* 5 */ "mmaccccccccccamm"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmaccccccccccamm"
+ /* 1 */ "bag..........gab"
+ /* 2 */ "h..............i"
+ /* 3 */ "i..............j"
+ /* 4 */ "bak..........kab"
+ /* 5 */ "mmaccccccccccamm"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmaccccccccccamm"
+ /* 1 */ "ba............ab"
+ /* 2 */ "ba............ab"
+ /* 3 */ "ba............ab"
+ /* 4 */ "ba............ab"
+ /* 5 */ "mmaccccccccccamm"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmaaaaaaaaaammm"
+ /* 1 */ "mmaaaaaaaaaaaamm"
+ /* 2 */ "mmaccccccccccamm"
+ /* 3 */ "mmaccccccccccamm"
+ /* 4 */ "mmaaaaaaaaaaaamm"
+ /* 5 */ "mmmaaaaaaaaaammm",
+
+ // Connectors:
+ "1: 0, 1, 2: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 3: 4\n" /* Type -1, direction X- */
+ "1: 15, 1, 3: 5\n" /* Type 1, direction X+ */
+ "-1: 15, 1, 2: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // ViewingCorridor
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // ViewingCorridorBulge:
+ // The data has been exported from the gallery Water, area index 42, ID 615, created by LO1ZB
+ {
+ // Size:
+ 12, 8, 16, // SizeX = 12, SizeY = 8, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 11, 7, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 20: 0\n" /* glass */
+ "d: 64: 3\n" /* wooddoorblock */
+ "e: 76: 1\n" /* redstonetorchon */
+ "f: 76: 2\n" /* redstonetorchon */
+ "g: 64: 1\n" /* wooddoorblock */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i: 64: 9\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmaammmmm"
+ /* 1 */ "mmmmmbbmmmmm"
+ /* 2 */ "mmmmmbbmmmmm"
+ /* 3 */ "mmmmbbbbmmmm"
+ /* 4 */ "mmmbbccbbmmm"
+ /* 5 */ "mmbbccccbbmm"
+ /* 6 */ "mbbccccccbbm"
+ /* 7 */ "mbccccccccbm"
+ /* 8 */ "mbccccccccbm"
+ /* 9 */ "mbbccccccbbm"
+ /* 10 */ "mmbbccccbbmm"
+ /* 11 */ "mmmbbccbbmmm"
+ /* 12 */ "mmmmbbbbmmmm"
+ /* 13 */ "mmmmmbbmmmmm"
+ /* 14 */ "mmmmmbbmmmmm"
+ /* 15 */ "mmmmmaammmmm"
+
+ // Level 1
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmaddammmm"
+ /* 1 */ "mmmmb..bmmmm"
+ /* 2 */ "mmmmb..bmmmm"
+ /* 3 */ "mmmbbefbbmmm"
+ /* 4 */ "mmbb....bbmm"
+ /* 5 */ "mbb......bbm"
+ /* 6 */ "mb........bm"
+ /* 7 */ "be........fb"
+ /* 8 */ "be........fb"
+ /* 9 */ "mb........bm"
+ /* 10 */ "mbb......bbm"
+ /* 11 */ "mmbb....bbmm"
+ /* 12 */ "mmmbbefbbmmm"
+ /* 13 */ "mmmmb..bmmmm"
+ /* 14 */ "mmmmb..bmmmm"
+ /* 15 */ "mmmmaggammmm"
+
+ // Level 2
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmahiammmm"
+ /* 1 */ "mmmmb..bmmmm"
+ /* 2 */ "mmmmc..cmmmm"
+ /* 3 */ "mmmcc..ccmmm"
+ /* 4 */ "mmcc....ccmm"
+ /* 5 */ "mcc......ccm"
+ /* 6 */ "mc........cm"
+ /* 7 */ "c..........c"
+ /* 8 */ "c..........c"
+ /* 9 */ "mc........cm"
+ /* 10 */ "mcc......ccm"
+ /* 11 */ "mmcc....ccmm"
+ /* 12 */ "mmmcc..ccmmm"
+ /* 13 */ "mmmmc..cmmmm"
+ /* 14 */ "mmmmb..bmmmm"
+ /* 15 */ "mmmmaihammmm"
+
+ // Level 3
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmaaaammmm"
+ /* 1 */ "mmmmbbbbmmmm"
+ /* 2 */ "mmmmccccmmmm"
+ /* 3 */ "mmmcc..ccmmm"
+ /* 4 */ "mmcc....ccmm"
+ /* 5 */ "mcc......ccm"
+ /* 6 */ "mc........cm"
+ /* 7 */ "c..........c"
+ /* 8 */ "c..........c"
+ /* 9 */ "mc........cm"
+ /* 10 */ "mcc......ccm"
+ /* 11 */ "mmcc....ccmm"
+ /* 12 */ "mmmcc..ccmmm"
+ /* 13 */ "mmmmccccmmmm"
+ /* 14 */ "mmmmbbbbmmmm"
+ /* 15 */ "mmmmaaaammmm"
+
+ // Level 4
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmm"
+ /* 3 */ "mmmmmccmmmmm"
+ /* 4 */ "mmmmc..cmmmm"
+ /* 5 */ "mmmc....cmmm"
+ /* 6 */ "mmc......cmm"
+ /* 7 */ "mc........cm"
+ /* 8 */ "mc........cm"
+ /* 9 */ "mmc......cmm"
+ /* 10 */ "mmmc....cmmm"
+ /* 11 */ "mmmmc..cmmmm"
+ /* 12 */ "mmmmmccmmmmm"
+ /* 13 */ "mmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmm"
+
+ // Level 5
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmm"
+ /* 4 */ "mmmmmccmmmmm"
+ /* 5 */ "mmmmc..cmmmm"
+ /* 6 */ "mmmc....cmmm"
+ /* 7 */ "mmc......cmm"
+ /* 8 */ "mmc......cmm"
+ /* 9 */ "mmmc....cmmm"
+ /* 10 */ "mmmmc..cmmmm"
+ /* 11 */ "mmmmmccmmmmm"
+ /* 12 */ "mmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmm"
+
+ // Level 6
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmmm"
+ /* 5 */ "mmmmmccmmmmm"
+ /* 6 */ "mmmmccccmmmm"
+ /* 7 */ "mmmccccccmmm"
+ /* 8 */ "mmmccccccmmm"
+ /* 9 */ "mmmmccccmmmm"
+ /* 10 */ "mmmmmccmmmmm"
+ /* 11 */ "mmmmmmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmm"
+
+ // Level 7
+ /* z\x* 11 */
+ /* * 012345678901 */
+ /* 0 */ "mmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmmmmmm"
+ /* 6 */ "mmmmmmmmmmmm"
+ /* 7 */ "mmmmmmmmmmmm"
+ /* 8 */ "mmmmmmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmm",
+
+ // Connectors:
+ "1: 6, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 5, 1, 0: 2\n" /* Type -1, direction Z- */
+ "1: 5, 1, 15: 3\n" /* Type 1, direction Z+ */
+ "-1: 6, 1, 15: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // ViewingCorridorBulge
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // ViewingCrossing:
+ // The data has been exported from the gallery Water, area index 38, ID 611, created by LO1ZB
+ {
+ // Size:
+ 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 6, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 20: 0\n" /* glass */
+ "d: 64: 3\n" /* wooddoorblock */
+ "e: 76: 1\n" /* redstonetorchon */
+ "f: 76: 2\n" /* redstonetorchon */
+ "g: 64: 2\n" /* wooddoorblock */
+ "h: 76: 3\n" /* redstonetorchon */
+ "i: 64: 0\n" /* wooddoorblock */
+ "j: 76: 4\n" /* redstonetorchon */
+ "k: 64: 1\n" /* wooddoorblock */
+ "l: 64: 8\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */
+ "n: 64: 9\n" /* wooddoorblock */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmaammmmmmm"
+ /* 1 */ "mmmmmmmbbmmmmmmm"
+ /* 2 */ "mmmmmmmbbmmmmmmm"
+ /* 3 */ "mmmmmmbbbbmmmmmm"
+ /* 4 */ "mmmmmbbccbbmmmmm"
+ /* 5 */ "mmmmbbccccbbmmmm"
+ /* 6 */ "mmmbbccccccbbmmm"
+ /* 7 */ "abbbccccccccbbba"
+ /* 8 */ "abbbccccccccbbba"
+ /* 9 */ "mmmbbccccccbbmmm"
+ /* 10 */ "mmmmbbccccbbmmmm"
+ /* 11 */ "mmmmmbbccbbmmmmm"
+ /* 12 */ "mmmmmmbbbbmmmmmm"
+ /* 13 */ "mmmmmmmbbmmmmmmm"
+ /* 14 */ "mmmmmmmbbmmmmmmm"
+ /* 15 */ "mmmmmmmaammmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmaddammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmb..bmmmmmm"
+ /* 3 */ "mmmmmbbefbbmmmmm"
+ /* 4 */ "mmmmbb....bbmmmm"
+ /* 5 */ "mmmbb......bbmmm"
+ /* 6 */ "abbb........bbba"
+ /* 7 */ "g..h........h..i"
+ /* 8 */ "g..j........j..i"
+ /* 9 */ "abbb........bbba"
+ /* 10 */ "mmmbb......bbmmm"
+ /* 11 */ "mmmmbb....bbmmmm"
+ /* 12 */ "mmmmmbbefbbmmmmm"
+ /* 13 */ "mmmmmmb..bmmmmmm"
+ /* 14 */ "mmmmmmb..bmmmmmm"
+ /* 15 */ "mmmmmmakkammmmmm"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmalnammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmc..cmmmmmm"
+ /* 3 */ "mmmmmcc..ccmmmmm"
+ /* 4 */ "mmmmcc....ccmmmm"
+ /* 5 */ "mmmcc......ccmmm"
+ /* 6 */ "abcc........ccba"
+ /* 7 */ "n..............l"
+ /* 8 */ "l..............n"
+ /* 9 */ "abcc........ccba"
+ /* 10 */ "mmmcc......ccmmm"
+ /* 11 */ "mmmmcc....ccmmmm"
+ /* 12 */ "mmmmmcc..ccmmmmm"
+ /* 13 */ "mmmmmmc..cmmmmmm"
+ /* 14 */ "mmmmmmb..bmmmmmm"
+ /* 15 */ "mmmmmmanlammmmmm"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmaaaammmmmm"
+ /* 1 */ "mmmmmmbbbbmmmmmm"
+ /* 2 */ "mmmmmmccccmmmmmm"
+ /* 3 */ "mmmmmcc..ccmmmmm"
+ /* 4 */ "mmmmcc....ccmmmm"
+ /* 5 */ "mmmcc......ccmmm"
+ /* 6 */ "abcc........ccba"
+ /* 7 */ "abc..........cba"
+ /* 8 */ "abc..........cba"
+ /* 9 */ "abcc........ccba"
+ /* 10 */ "mmmcc......ccmmm"
+ /* 11 */ "mmmmcc....ccmmmm"
+ /* 12 */ "mmmmmcc..ccmmmmm"
+ /* 13 */ "mmmmmmccccmmmmmm"
+ /* 14 */ "mmmmmmbbbbmmmmmm"
+ /* 15 */ "mmmmmmaaaammmmmm"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmccmmmmmmm"
+ /* 4 */ "mmmmmmc..cmmmmmm"
+ /* 5 */ "mmmmmc....cmmmmm"
+ /* 6 */ "mmmmc......cmmmm"
+ /* 7 */ "mmmc........cmmm"
+ /* 8 */ "mmmc........cmmm"
+ /* 9 */ "mmmmc......cmmmm"
+ /* 10 */ "mmmmmc....cmmmmm"
+ /* 11 */ "mmmmmmc..cmmmmmm"
+ /* 12 */ "mmmmmmmccmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmmmm"
+ /* 4 */ "mmmmmmmccmmmmmmm"
+ /* 5 */ "mmmmmmc..cmmmmmm"
+ /* 6 */ "mmmmmc....cmmmmm"
+ /* 7 */ "mmmmc......cmmmm"
+ /* 8 */ "mmmmc......cmmmm"
+ /* 9 */ "mmmmmc....cmmmmm"
+ /* 10 */ "mmmmmmc..cmmmmmm"
+ /* 11 */ "mmmmmmmccmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmccmmmmmmm"
+ /* 6 */ "mmmmmmccccmmmmmm"
+ /* 7 */ "mmmmmccccccmmmmm"
+ /* 8 */ "mmmmmccccccmmmmm"
+ /* 9 */ "mmmmmmccccmmmmmm"
+ /* 10 */ "mmmmmmmccmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmmmm",
+
+ // Connectors:
+ "1: 0, 1, 7: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */
+ "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */
+ "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */
+ "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */
+ "1: 7, 1, 15: 3\n" /* Type 1, direction Z+ */
+ "-1: 8, 1, 15: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 50,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // ViewingCrossing
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // ViewingEnd:
+ // The data has been exported from the gallery Water, area index 41, ID 614, created by LO1ZB
+ {
+ // Size:
+ 14, 7, 12, // SizeX = 14, SizeY = 7, SizeZ = 12
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 13, 6, 11, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 0\n" /* wood */
+ "b: 20: 0\n" /* glass */
+ "c: 5: 5\n" /* wood */
+ "d: 76: 3\n" /* redstonetorchon */
+ "e: 76: 1\n" /* redstonetorchon */
+ "f: 64: 0\n" /* wooddoorblock */
+ "g: 76: 4\n" /* redstonetorchon */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i: 64: 9\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmaaaammmmmm"
+ /* 2 */ "mmmaabbaammmmm"
+ /* 3 */ "mmaabbbbaammmm"
+ /* 4 */ "maabbbbbbaammm"
+ /* 5 */ "mabbbbbbbbaaac"
+ /* 6 */ "mabbbbbbbbaaac"
+ /* 7 */ "maabbbbbbaammm"
+ /* 8 */ "mmaabbbbaammmm"
+ /* 9 */ "mmmaabbaammmmm"
+ /* 10 */ "mmmmaaaammmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+
+ // Level 1
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmaammmmmmm"
+ /* 1 */ "mmmaaddaammmmm"
+ /* 2 */ "mmaa....aammmm"
+ /* 3 */ "maa......aammm"
+ /* 4 */ "ma........aaac"
+ /* 5 */ "ae........d..f"
+ /* 6 */ "ae........g..f"
+ /* 7 */ "ma........aaac"
+ /* 8 */ "maa......aammm"
+ /* 9 */ "mmaa....aammmm"
+ /* 10 */ "mmmaaggaammmmm"
+ /* 11 */ "mmmmmaammmmmmm"
+
+ // Level 2
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmbbmmmmmmm"
+ /* 1 */ "mmmbb..bbmmmmm"
+ /* 2 */ "mmbb....bbmmmm"
+ /* 3 */ "mbb......bbmmm"
+ /* 4 */ "mb........bbac"
+ /* 5 */ "b............h"
+ /* 6 */ "b............i"
+ /* 7 */ "mb........bbac"
+ /* 8 */ "mbb......bbmmm"
+ /* 9 */ "mmbb....bbmmmm"
+ /* 10 */ "mmmbb..bbmmmmm"
+ /* 11 */ "mmmmmbbmmmmmmm"
+
+ // Level 3
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmbbmmmmmmm"
+ /* 1 */ "mmmbb..bbmmmmm"
+ /* 2 */ "mmbb....bbmmmm"
+ /* 3 */ "mbb......bbmmm"
+ /* 4 */ "mb........bbac"
+ /* 5 */ "b..........bac"
+ /* 6 */ "b..........bac"
+ /* 7 */ "mb........bbac"
+ /* 8 */ "mbb......bbmmm"
+ /* 9 */ "mmbb....bbmmmm"
+ /* 10 */ "mmmbb..bbmmmmm"
+ /* 11 */ "mmmmmbbmmmmmmm"
+
+ // Level 4
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmbbmmmmmmm"
+ /* 2 */ "mmmmb..bmmmmmm"
+ /* 3 */ "mmmb....bmmmmm"
+ /* 4 */ "mmb......bmmmm"
+ /* 5 */ "mb........bmmm"
+ /* 6 */ "mb........bmmm"
+ /* 7 */ "mmb......bmmmm"
+ /* 8 */ "mmmb....bmmmmm"
+ /* 9 */ "mmmmb..bmmmmmm"
+ /* 10 */ "mmmmmbbmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+
+ // Level 5
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmbbmmmmmmm"
+ /* 3 */ "mmmmb..bmmmmmm"
+ /* 4 */ "mmmb....bmmmmm"
+ /* 5 */ "mmb......bmmmm"
+ /* 6 */ "mmb......bmmmm"
+ /* 7 */ "mmmb....bmmmmm"
+ /* 8 */ "mmmmb..bmmmmmm"
+ /* 9 */ "mmmmmbbmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+
+ // Level 6
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmbbmmmmmmm"
+ /* 4 */ "mmmmbbbbmmmmmm"
+ /* 5 */ "mmmbbbbbbmmmmm"
+ /* 6 */ "mmmbbbbbbmmmmm"
+ /* 7 */ "mmmmbbbbmmmmmm"
+ /* 8 */ "mmmmmbbmmmmmmm"
+ /* 9 */ "mmmmmmmmmmmmmm"
+ /* 10 */ "mmmmmmmmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm",
+
+ // Connectors:
+ "1: 13, 1, 6: 5\n" /* Type 1, direction X+ */
+ "-1: 13, 1, 5: 5\n" /* Type -1, direction X+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 200,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // ViewingEnd
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // ViewingTee:
+ // The data has been exported from the gallery Water, area index 39, ID 612, created by LO1ZB
+ {
+ // Size:
+ 14, 7, 17, // SizeX = 14, SizeY = 7, SizeZ = 17
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 13, 6, 16, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 20: 0\n" /* glass */
+ "d: 1: 0\n" /* stone */
+ "e: 64: 3\n" /* wooddoorblock */
+ "f: 76: 1\n" /* redstonetorchon */
+ "g: 76: 2\n" /* redstonetorchon */
+ "h: 76: 3\n" /* redstonetorchon */
+ "i: 64: 0\n" /* wooddoorblock */
+ "j: 76: 4\n" /* redstonetorchon */
+ "k: 64: 1\n" /* wooddoorblock */
+ "l: 64: 8\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmaammmmmmm"
+ /* 1 */ "mmmmmbbmmmmmmm"
+ /* 2 */ "mmmmmbbmmmmmmm"
+ /* 3 */ "mmmmbbbbmmmmmm"
+ /* 4 */ "mmmbbccbbmmmmm"
+ /* 5 */ "mmbbccccbbmmmm"
+ /* 6 */ "mbbccccccbbmmm"
+ /* 7 */ "mbccccccccbbba"
+ /* 8 */ "mbccccccccbbba"
+ /* 9 */ "mbbccccccbbmmm"
+ /* 10 */ "mmbbccccbbmmmm"
+ /* 11 */ "mmmbbccbbmmmmm"
+ /* 12 */ "mmmmbbbbmmmmmm"
+ /* 13 */ "mmmmmbbmmmmmmm"
+ /* 14 */ "mmmmmbbmmmmmmm"
+ /* 15 */ "mmmmmaammmmmmm"
+ /* 16 */ "dddddddddddddd"
+
+ // Level 1
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmaeeammmmmm"
+ /* 1 */ "mmmmb..bmmmmmm"
+ /* 2 */ "mmmmb..bmmmmmm"
+ /* 3 */ "mmmbbfgbbmmmmm"
+ /* 4 */ "mmbb....bbmmmm"
+ /* 5 */ "mbb......bbmmm"
+ /* 6 */ "mb........bbba"
+ /* 7 */ "bf........h..i"
+ /* 8 */ "bf........j..i"
+ /* 9 */ "mb........bbba"
+ /* 10 */ "mbb......bbmmm"
+ /* 11 */ "mmbb....bbmmmm"
+ /* 12 */ "mmmbbfgbbmmmmm"
+ /* 13 */ "mmmmb..bmmmmmm"
+ /* 14 */ "mmmmb..bmmmmmm"
+ /* 15 */ "mmmmakkammmmmm"
+ /* 16 */ "dddddddddddddd"
+
+ // Level 2
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmallammmmmm"
+ /* 1 */ "mmmmb..bmmmmmm"
+ /* 2 */ "mmmmc..cmmmmmm"
+ /* 3 */ "mmmcc..ccmmmmm"
+ /* 4 */ "mmcc....ccmmmm"
+ /* 5 */ "mcc......ccmmm"
+ /* 6 */ "mc........ccba"
+ /* 7 */ "c............l"
+ /* 8 */ "c............l"
+ /* 9 */ "mc........ccba"
+ /* 10 */ "mcc......ccmmm"
+ /* 11 */ "mmcc....ccmmmm"
+ /* 12 */ "mmmcc..ccmmmmm"
+ /* 13 */ "mmmmc..cmmmmmm"
+ /* 14 */ "mmmmb..bmmmmmm"
+ /* 15 */ "mmmmallammmmmm"
+ /* 16 */ "dddddddddddddd"
+
+ // Level 3
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmaaaammmmmm"
+ /* 1 */ "mmmmbbbbmmmmmm"
+ /* 2 */ "mmmmccccmmmmmm"
+ /* 3 */ "mmmcc..ccmmmmm"
+ /* 4 */ "mmcc....ccmmmm"
+ /* 5 */ "mcc......ccmmm"
+ /* 6 */ "mc........ccba"
+ /* 7 */ "c..........cba"
+ /* 8 */ "c..........cba"
+ /* 9 */ "mc........ccba"
+ /* 10 */ "mcc......ccmmm"
+ /* 11 */ "mmcc....ccmmmm"
+ /* 12 */ "mmmcc..ccmmmmm"
+ /* 13 */ "mmmmccccmmmmmm"
+ /* 14 */ "mmmmbbbbmmmmmm"
+ /* 15 */ "mmmmaaaammmmmm"
+ /* 16 */ "dddddddddddddd"
+
+ // Level 4
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmccmmmmmmm"
+ /* 4 */ "mmmmc..cmmmmmm"
+ /* 5 */ "mmmc....cmmmmm"
+ /* 6 */ "mmc......cmmmm"
+ /* 7 */ "mc........cmmm"
+ /* 8 */ "mc........cmmm"
+ /* 9 */ "mmc......cmmmm"
+ /* 10 */ "mmmc....cmmmmm"
+ /* 11 */ "mmmmc..cmmmmmm"
+ /* 12 */ "mmmmmccmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmm"
+ /* 16 */ "dddddddddddddd"
+
+ // Level 5
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmm"
+ /* 4 */ "mmmmmccmmmmmmm"
+ /* 5 */ "mmmmc..cmmmmmm"
+ /* 6 */ "mmmc....cmmmmm"
+ /* 7 */ "mmc......cmmmm"
+ /* 8 */ "mmc......cmmmm"
+ /* 9 */ "mmmc....cmmmmm"
+ /* 10 */ "mmmmc..cmmmmmm"
+ /* 11 */ "mmmmmccmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmm"
+ /* 16 */ "dddddddddddddd"
+
+ // Level 6
+ /* z\x* 1111 */
+ /* * 01234567890123 */
+ /* 0 */ "mmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmccmmmmmmm"
+ /* 6 */ "mmmmccccmmmmmm"
+ /* 7 */ "mmmccccccmmmmm"
+ /* 8 */ "mmmccccccmmmmm"
+ /* 9 */ "mmmmccccmmmmmm"
+ /* 10 */ "mmmmmccmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmm"
+ /* 16 */ "dddddddddddddd",
+
+ // Connectors:
+ "",
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 75,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // ViewingTee
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // WaterfallRoom:
+ // The data has been exported from the gallery Water, area index 50, ID 681, created by Aloe_vera
+ {
+ // Size:
+ 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 6, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 20: 0\n" /* glass */
+ "d: 64: 3\n" /* wooddoorblock */
+ "e: 76: 1\n" /* redstonetorchon */
+ "f: 76: 2\n" /* redstonetorchon */
+ "g: 64: 2\n" /* wooddoorblock */
+ "h: 76: 3\n" /* redstonetorchon */
+ "i: 64: 0\n" /* wooddoorblock */
+ "j: 76: 4\n" /* redstonetorchon */
+ "k: 64: 1\n" /* wooddoorblock */
+ "l: 64: 8\n" /* wooddoorblock */
+ "m: 19: 0\n" /* sponge */
+ "n: 64: 9\n" /* wooddoorblock */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmaammmmmmm"
+ /* 1 */ "mmmmmmmbbmmmmmmm"
+ /* 2 */ "mmmmmmmbbmmmmmmm"
+ /* 3 */ "mmmmmmbbbbmmmmmm"
+ /* 4 */ "mmmmmbbccbbmmmmm"
+ /* 5 */ "mmmmbbccccbbmmmm"
+ /* 6 */ "mmmbbccccccbbmmm"
+ /* 7 */ "abbbcccmmcccbbba"
+ /* 8 */ "abbbcccmmcccbbba"
+ /* 9 */ "mmmbbccccccbbmmm"
+ /* 10 */ "mmmmbbccccbbmmmm"
+ /* 11 */ "mmmmmbbccbbmmmmm"
+ /* 12 */ "mmmmmmbbbbmmmmmm"
+ /* 13 */ "mmmmmmmbbmmmmmmm"
+ /* 14 */ "mmmmmmmbbmmmmmmm"
+ /* 15 */ "mmmmmmmaammmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmaddammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmb..bmmmmmm"
+ /* 3 */ "mmmmmbbefbbmmmmm"
+ /* 4 */ "mmmmbb....bbmmmm"
+ /* 5 */ "mmmbb......bbmmm"
+ /* 6 */ "abbb...cc...bbba"
+ /* 7 */ "g..h..c..c..h..i"
+ /* 8 */ "g..j..c..c..j..i"
+ /* 9 */ "abbb...cc...bbba"
+ /* 10 */ "mmmbb......bbmmm"
+ /* 11 */ "mmmmbb....bbmmmm"
+ /* 12 */ "mmmmmbbefbbmmmmm"
+ /* 13 */ "mmmmmmb..bmmmmmm"
+ /* 14 */ "mmmmmmb..bmmmmmm"
+ /* 15 */ "mmmmmmakkammmmmm"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmalnammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmc..cmmmmmm"
+ /* 3 */ "mmmmmcc..ccmmmmm"
+ /* 4 */ "mmmmcc....ccmmmm"
+ /* 5 */ "mmmcc......ccmmm"
+ /* 6 */ "abcc........ccba"
+ /* 7 */ "n..............l"
+ /* 8 */ "l..............n"
+ /* 9 */ "abcc........ccba"
+ /* 10 */ "mmmcc......ccmmm"
+ /* 11 */ "mmmmcc....ccmmmm"
+ /* 12 */ "mmmmmcc..ccmmmmm"
+ /* 13 */ "mmmmmmc..cmmmmmm"
+ /* 14 */ "mmmmmmb..bmmmmmm"
+ /* 15 */ "mmmmmmanlammmmmm"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmaaaammmmmm"
+ /* 1 */ "mmmmmmbbbbmmmmmm"
+ /* 2 */ "mmmmmmccccmmmmmm"
+ /* 3 */ "mmmmmcc..ccmmmmm"
+ /* 4 */ "mmmmcc....ccmmmm"
+ /* 5 */ "mmmcc......ccmmm"
+ /* 6 */ "abcc........ccba"
+ /* 7 */ "abc..........cba"
+ /* 8 */ "abc..........cba"
+ /* 9 */ "abcc........ccba"
+ /* 10 */ "mmmcc......ccmmm"
+ /* 11 */ "mmmmcc....ccmmmm"
+ /* 12 */ "mmmmmcc..ccmmmmm"
+ /* 13 */ "mmmmmmccccmmmmmm"
+ /* 14 */ "mmmmmmbbbbmmmmmm"
+ /* 15 */ "mmmmmmaaaammmmmm"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmccmmmmmmm"
+ /* 4 */ "mmmmm.c..cmmmmmm"
+ /* 5 */ "mmmmmc....cmmmmm"
+ /* 6 */ "mmmmc......cmmmm"
+ /* 7 */ "mmmc........cmmm"
+ /* 8 */ "mmmc........cmmm"
+ /* 9 */ "mmmmc......cmmmm"
+ /* 10 */ "mmmmmc....cmmmmm"
+ /* 11 */ "mmmmmmc..cmmmmmm"
+ /* 12 */ "mmmmmmmccmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmmmm"
+ /* 4 */ "mmmmmm.ccmmmmmmm"
+ /* 5 */ "mmmmmmc..cmmmmmm"
+ /* 6 */ "mmmmmc....cmmmmm"
+ /* 7 */ "mmmmc......cmmmm"
+ /* 8 */ "mmmmc......cmmmm"
+ /* 9 */ "mmmmmc....cmmmmm"
+ /* 10 */ "mmmmmmc..cmmmmmm"
+ /* 11 */ "mmmmmmmccmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmccmmmmmmm"
+ /* 6 */ "mmmmmmccccmmmmmm"
+ /* 7 */ "mmmmmcc..ccmmmmm"
+ /* 8 */ "mmmmmcc..ccmmmmm"
+ /* 9 */ "mmmmmmccccmmmmmm"
+ /* 10 */ "mmmmmmmccmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmmmm",
+
+ // Connectors:
+ "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */
+ "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */
+ "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */
+ "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */
+ "1: 0, 1, 7: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */
+ "1: 7, 1, 15: 3\n" /* Type 1, direction Z+ */
+ "-1: 8, 1, 15: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 5,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // WaterfallRoom
+}; // g_UnderwaterBasePrefabs
+
+
+
+
+
+
+const cPrefab::sDef g_UnderwaterBaseStartingPrefabs[] =
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // CentralRoom:
+ // The data has been exported from the gallery Water, area index 24, ID 564, created by xoft
+ {
+ // Size:
+ 16, 7, 16, // SizeX = 16, SizeY = 7, SizeZ = 16
+
+ // Hitbox (relative to bounding box):
+ 0, 0, 0, // MinX, MinY, MinZ
+ 15, 6, 15, // MaxX, MaxY, MaxZ
+
+ // Block definitions:
+ ".: 0: 0\n" /* air */
+ "a: 5: 5\n" /* wood */
+ "b: 5: 0\n" /* wood */
+ "c: 20: 0\n" /* glass */
+ "d: 64: 3\n" /* wooddoorblock */
+ "e: 64: 2\n" /* wooddoorblock */
+ "f: 64: 0\n" /* wooddoorblock */
+ "g: 64: 1\n" /* wooddoorblock */
+ "h: 64: 8\n" /* wooddoorblock */
+ "i: 64: 9\n" /* wooddoorblock */
+ "j: 76: 3\n" /* redstonetorchon */
+ "k: 76: 1\n" /* redstonetorchon */
+ "l: 76: 2\n" /* redstonetorchon */
+ "m: 19: 0\n" /* sponge */
+ "n: 76: 4\n" /* redstonetorchon */
+ "o:125: 8\n" /* woodendoubleslab */,
+
+ // Block data:
+ // Level 0
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmaammmmmmm"
+ /* 1 */ "mmmmmmmbbmmmmmmm"
+ /* 2 */ "mmmmmmmbbmmmmmmm"
+ /* 3 */ "mmmmmmbbbbmmmmmm"
+ /* 4 */ "mmmmmbbbbbbmmmmm"
+ /* 5 */ "mmmmbbbccbbbmmmm"
+ /* 6 */ "mmmbbbccccbbbmmm"
+ /* 7 */ "abbbbccccccbbbba"
+ /* 8 */ "abbbbccccccbbbba"
+ /* 9 */ "mmmbbbccccbbbmmm"
+ /* 10 */ "mmmmbbbccbbbmmmm"
+ /* 11 */ "mmmmmbbbbbbmmmmm"
+ /* 12 */ "mmmmmmbbbbmmmmmm"
+ /* 13 */ "mmmmmmmbbmmmmmmm"
+ /* 14 */ "mmmmmmmbbmmmmmmm"
+ /* 15 */ "mmmmmmmaammmmmmm"
+
+ // Level 1
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmaddammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmb..bmmmmmm"
+ /* 3 */ "mmmmmbb..bbmmmmm"
+ /* 4 */ "mmmmbb....bbmmmm"
+ /* 5 */ "mmmbb......bbmmm"
+ /* 6 */ "abbb........bbba"
+ /* 7 */ "e..............f"
+ /* 8 */ "e..............f"
+ /* 9 */ "abbb........bbba"
+ /* 10 */ "mmmbb......bbmmm"
+ /* 11 */ "mmmmbb....bbmmmm"
+ /* 12 */ "mmmmmbb..bbmmmmm"
+ /* 13 */ "mmmmmmb..bmmmmmm"
+ /* 14 */ "mmmmmmb..bmmmmmm"
+ /* 15 */ "mmmmmmaggammmmmm"
+
+ // Level 2
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmahiammmmmm"
+ /* 1 */ "mmmmmmb..bmmmmmm"
+ /* 2 */ "mmmmmmb..bmmmmmm"
+ /* 3 */ "mmmmmcc..ccmmmmm"
+ /* 4 */ "mmmmcc....ccmmmm"
+ /* 5 */ "mmmcc......ccmmm"
+ /* 6 */ "abbc........cbba"
+ /* 7 */ "i..............h"
+ /* 8 */ "h..............i"
+ /* 9 */ "abbc........cbba"
+ /* 10 */ "mmmcc......ccmmm"
+ /* 11 */ "mmmmcc....ccmmmm"
+ /* 12 */ "mmmmmcc..ccmmmmm"
+ /* 13 */ "mmmmmmb..bmmmmmm"
+ /* 14 */ "mmmmmmb..bmmmmmm"
+ /* 15 */ "mmmmmmaihammmmmm"
+
+ // Level 3
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmaaaammmmmm"
+ /* 1 */ "mmmmmmbbbbmmmmmm"
+ /* 2 */ "mmmmmmbbbbmmmmmm"
+ /* 3 */ "mmmmmbb..bbmmmmm"
+ /* 4 */ "mmmmbb....bbmmmm"
+ /* 5 */ "mmmbb......bbmmm"
+ /* 6 */ "abbb........bbba"
+ /* 7 */ "abb..........bba"
+ /* 8 */ "abb..........bba"
+ /* 9 */ "abbb........bbba"
+ /* 10 */ "mmmbb......bbmmm"
+ /* 11 */ "mmmmbb....bbmmmm"
+ /* 12 */ "mmmmmbb..bbmmmmm"
+ /* 13 */ "mmmmmmbbbbmmmmmm"
+ /* 14 */ "mmmmmmbbbbmmmmmm"
+ /* 15 */ "mmmmmmaaaammmmmm"
+
+ // Level 4
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmbbmmmmmmm"
+ /* 4 */ "mmmmmmbjjbmmmmmm"
+ /* 5 */ "mmmmmb....bmmmmm"
+ /* 6 */ "mmmmb......bmmmm"
+ /* 7 */ "mmmbk......lbmmm"
+ /* 8 */ "mmmbk......lbmmm"
+ /* 9 */ "mmmmb......bmmmm"
+ /* 10 */ "mmmmmb....bmmmmm"
+ /* 11 */ "mmmmmmbnnbmmmmmm"
+ /* 12 */ "mmmmmmmbbmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 5
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmmmm"
+ /* 4 */ "mmmmmmmbbmmmmmmm"
+ /* 5 */ "mmmmmmb..bmmmmmm"
+ /* 6 */ "mmmmmb....bmmmmm"
+ /* 7 */ "mmmmb......bmmmm"
+ /* 8 */ "mmmmb......bmmmm"
+ /* 9 */ "mmmmmb....bmmmmm"
+ /* 10 */ "mmmmmmboobmmmmmm"
+ /* 11 */ "mmmmmmmbbmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmmmm"
+
+ // Level 6
+ /* z\x* 111111 */
+ /* * 0123456789012345 */
+ /* 0 */ "mmmmmmmmmmmmmmmm"
+ /* 1 */ "mmmmmmmmmmmmmmmm"
+ /* 2 */ "mmmmmmmmmmmmmmmm"
+ /* 3 */ "mmmmmmmmmmmmmmmm"
+ /* 4 */ "mmmmmmmmmmmmmmmm"
+ /* 5 */ "mmmmmmmbbmmmmmmm"
+ /* 6 */ "mmmmmmbbbbmmmmmm"
+ /* 7 */ "mmmmmbbccbbmmmmm"
+ /* 8 */ "mmmmmbbccbbmmmmm"
+ /* 9 */ "mmmmmmbbbbmmmmmm"
+ /* 10 */ "mmmmmmmbbmmmmmmm"
+ /* 11 */ "mmmmmmmmmmmmmmmm"
+ /* 12 */ "mmmmmmmmmmmmmmmm"
+ /* 13 */ "mmmmmmmmmmmmmmmm"
+ /* 14 */ "mmmmmmmmmmmmmmmm"
+ /* 15 */ "mmmmmmmmmmmmmmmm",
+
+ // Connectors:
+ "1: 0, 1, 7: 4\n" /* Type 1, direction X- */
+ "-1: 0, 1, 8: 4\n" /* Type -1, direction X- */
+ "-1: 7, 1, 0: 2\n" /* Type -1, direction Z- */
+ "1: 8, 1, 0: 2\n" /* Type 1, direction Z- */
+ "1: 15, 1, 8: 5\n" /* Type 1, direction X+ */
+ "-1: 15, 1, 7: 5\n" /* Type -1, direction X+ */
+ "1: 7, 1, 15: 3\n" /* Type 1, direction Z+ */
+ "-1: 8, 1, 15: 3\n" /* Type -1, direction Z+ */,
+
+ // AllowedRotations:
+ 7, /* 1, 2, 3 CCW rotation allowed */
+
+ // Merge strategy:
+ cBlockArea::msSpongePrint,
+
+ // ShouldExtendFloor:
+ true,
+
+ // DefaultWeight:
+ 100,
+
+ // DepthWeight:
+ "",
+
+ // AddWeightIfSame:
+ 0,
+
+ // MoveToGround:
+ false,
+ }, // CentralRoom
+};
+
+
+
+
+
+// The prefab counts:
+
+const size_t g_UnderwaterBasePrefabsCount = ARRAYCOUNT(g_UnderwaterBasePrefabs);
+
+const size_t g_UnderwaterBaseStartingPrefabsCount = ARRAYCOUNT(g_UnderwaterBaseStartingPrefabs);
+
diff --git a/src/Generating/Prefabs/UnderwaterBasePrefabs.h b/src/Generating/Prefabs/UnderwaterBasePrefabs.h
new file mode 100644
index 000000000..d7b248bb8
--- /dev/null
+++ b/src/Generating/Prefabs/UnderwaterBasePrefabs.h
@@ -0,0 +1,15 @@
+
+// UnderwaterBasePrefabs.h
+
+// Declares the prefabs in the group UnderwaterBase
+
+#include "../Prefab.h"
+
+
+
+
+
+extern const cPrefab::sDef g_UnderwaterBasePrefabs[];
+extern const cPrefab::sDef g_UnderwaterBaseStartingPrefabs[];
+extern const size_t g_UnderwaterBasePrefabsCount;
+extern const size_t g_UnderwaterBaseStartingPrefabsCount;
diff --git a/src/Generating/RainbowRoadsGen.cpp b/src/Generating/RainbowRoadsGen.cpp
new file mode 100644
index 000000000..c3c07cdec
--- /dev/null
+++ b/src/Generating/RainbowRoadsGen.cpp
@@ -0,0 +1,116 @@
+
+// RainbowRoadsGen.cpp
+
+// Implements the cRainbowRoadsGen class representing the rainbow road generator
+
+#include "Globals.h"
+#include "RainbowRoadsGen.h"
+#include "Prefabs/RainbowRoadPrefabs.h"
+#include "PieceGenerator.h"
+
+
+
+
+
+static cPrefabPiecePool g_RainbowRoads(g_RainbowRoadPrefabs, g_RainbowRoadPrefabsCount, g_RainbowRoadStartingPrefabs, g_RainbowRoadStartingPrefabsCount);
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cRainbowRoadsGen::cRainbowRoads:
+
+class cRainbowRoadsGen::cRainbowRoads :
+ public cGridStructGen::cStructure
+{
+ typedef cGridStructGen::cStructure super;
+
+public:
+ cRainbowRoads(
+ int a_Seed,
+ int a_GridX, int a_GridZ,
+ int a_OriginX, int a_OriginZ,
+ int a_MaxDepth,
+ int a_MaxSize
+ ) :
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
+ m_Seed(a_Seed),
+ m_Noise(a_Seed),
+ m_MaxSize(a_MaxSize),
+ m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize)
+ {
+ // Generate the pieces for this base:
+ cBFSPieceGenerator pg(g_RainbowRoads, a_Seed);
+ pg.PlacePieces(a_OriginX, 190, a_OriginZ, a_MaxDepth, m_Pieces);
+ if (m_Pieces.empty())
+ {
+ return;
+ }
+ }
+
+ ~cRainbowRoads()
+ {
+ cPieceGenerator::FreePieces(m_Pieces);
+ }
+
+protected:
+ /** Seed for the random functions */
+ int m_Seed;
+
+ /** The noise used as a pseudo-random generator */
+ cNoise m_Noise;
+
+ /** Maximum size, in X/Z blocks, of the village (radius from the origin) */
+ int m_MaxSize;
+
+ /** Borders of the vilalge - no item may reach out of this cuboid. */
+ cCuboid m_Borders;
+
+ /** The village pieces, placed by the generator. */
+ cPlacedPieces m_Pieces;
+
+
+ // cGridStructGen::cStructure overrides:
+ virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override
+ {
+ for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
+ {
+ cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece());
+ Prefab.Draw(a_Chunk, *itr);
+ } // for itr - m_PlacedPieces[]
+ }
+} ;
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cRainbowRoadsGen:
+
+
+
+
+
+cRainbowRoadsGen::cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize) :
+ super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100),
+ m_Noise(a_Seed + 9000),
+ m_MaxDepth(a_MaxDepth),
+ m_MaxSize(a_MaxSize)
+{
+}
+
+
+
+
+
+cGridStructGen::cStructurePtr cRainbowRoadsGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
+{
+ // Create a base based on the chosen prefabs:
+ return cStructurePtr(new cRainbowRoads(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize));
+}
+
+
+
+
diff --git a/src/Generating/RainbowRoadsGen.h b/src/Generating/RainbowRoadsGen.h
new file mode 100644
index 000000000..5813e1d14
--- /dev/null
+++ b/src/Generating/RainbowRoadsGen.h
@@ -0,0 +1,47 @@
+
+// RainbowRoadsGen.h
+
+// Declares the cRainbowRoadsGen class representing the underwater base generator
+
+
+
+
+
+#pragma once
+
+#include "GridStructGen.h"
+#include "PrefabPiecePool.h"
+
+
+
+
+
+class cRainbowRoadsGen :
+ public cGridStructGen
+{
+ typedef cGridStructGen super;
+
+public:
+ cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize);
+
+protected:
+ class cRainbowRoads; // fwd: RainbowRoadsGen.cpp
+
+
+ /** The noise used for generating random numbers */
+ cNoise m_Noise;
+
+ /** Maximum depth of the generator tree*/
+ int m_MaxDepth;
+
+ /** Maximum size, in X/Z blocks, of the base (radius from the origin) */
+ int m_MaxSize;
+
+
+ // cGridStructGen overrides:
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
+} ;
+
+
+
+
diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp
index 267dcbbf9..70b9d0b62 100644
--- a/src/Generating/Ravines.cpp
+++ b/src/Generating/Ravines.cpp
@@ -9,9 +9,6 @@
-/// How many ravines in each direction are generated for a given chunk. Must be an even number
-static const int NEIGHBORHOOD_SIZE = 8;
-
static const int NUM_RAVINE_POINTS = 4;
@@ -42,50 +39,49 @@ typedef std::vector<cRavDefPoint> cRavDefPoints;
-class cStructGenRavines::cRavine
+class cStructGenRavines::cRavine :
+ public cGridStructGen::cStructure
{
+ typedef cGridStructGen::cStructure super;
+
cRavDefPoints m_Points;
+
- /// Generates the shaping defpoints for the ravine, based on the ravine block coords and noise
+ /** Generates the shaping defpoints for the ravine, based on the ravine block coords and noise */
void GenerateBaseDefPoints(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise);
- /// Refines (adds and smooths) defpoints from a_Src into a_Dst
+ /** Refines (adds and smooths) defpoints from a_Src into a_Dst */
void RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst);
- /// Does one round of smoothing, two passes of RefineDefPoints()
+ /** Does one round of smoothing, two passes of RefineDefPoints() */
void Smooth(void);
- /// Linearly interpolates the points so that the maximum distance between two neighbors is max 1 block
+ /** Linearly interpolates the points so that the maximum distance between two neighbors is max 1 block */
void FinishLinear(void);
public:
- // Coords for which the ravine was generated (not necessarily the center)
- int m_BlockX;
- int m_BlockZ;
- cRavine(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise);
-
- /// Carves the ravine into the chunk specified
- void ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
- cChunkDef::HeightMap & a_HeightMap
- );
+ cRavine(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise);
#ifdef _DEBUG
/// Exports itself as a SVG line definition
AString ExportAsSVG(int a_Color, int a_OffsetX = 0, int a_OffsetZ = 0) const;
#endif // _DEBUG
+
+protected:
+ // cGridStructGen::cStructure overrides:
+ virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override;
} ;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenRavines:
cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) :
+ super(a_Seed, a_Size, a_Size, a_Size, a_Size, a_Size * 2, a_Size * 2, 100),
m_Noise(a_Seed),
m_Size(a_Size)
{
@@ -95,157 +91,26 @@ cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) :
-cStructGenRavines::~cStructGenRavines()
+cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
- ClearCache();
+ return cStructurePtr(new cRavine(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_Size, m_Noise));
}
-void cStructGenRavines::ClearCache(void)
-{
- for (cRavines::const_iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end; ++itr)
- {
- delete *itr;
- } // for itr - m_Cache[]
- m_Cache.clear();
-}
-
-
-
-
-
-void cStructGenRavines::GenFinish(cChunkDesc & a_ChunkDesc)
-{
- int ChunkX = a_ChunkDesc.GetChunkX();
- int ChunkZ = a_ChunkDesc.GetChunkZ();
- cRavines Ravines;
- GetRavinesForChunk(ChunkX, ChunkZ, Ravines);
- for (cRavines::const_iterator itr = Ravines.begin(), end = Ravines.end(); itr != end; ++itr)
- {
- (*itr)->ProcessChunk(ChunkX, ChunkZ, a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap());
- } // for itr - Ravines[]
-}
-
-
-
-
-void cStructGenRavines::GetRavinesForChunk(int a_ChunkX, int a_ChunkZ, cStructGenRavines::cRavines & a_Ravines)
-{
- int BaseX = a_ChunkX * cChunkDef::Width / m_Size;
- int BaseZ = a_ChunkZ * cChunkDef::Width / m_Size;
- if (BaseX < 0)
- {
- --BaseX;
- }
- if (BaseZ < 0)
- {
- --BaseZ;
- }
- BaseX -= 4;
- BaseZ -= 4;
-
- // Walk the cache, move each ravine that we want into a_Ravines:
- int StartX = BaseX * m_Size;
- int EndX = (BaseX + NEIGHBORHOOD_SIZE + 1) * m_Size;
- int StartZ = BaseZ * m_Size;
- int EndZ = (BaseZ + NEIGHBORHOOD_SIZE + 1) * m_Size;
- for (cRavines::iterator itr = m_Cache.begin(), end = m_Cache.end(); itr != end;)
- {
- if (
- ((*itr)->m_BlockX >= StartX) && ((*itr)->m_BlockX < EndX) &&
- ((*itr)->m_BlockZ >= StartZ) && ((*itr)->m_BlockZ < EndZ)
- )
- {
- // want
- a_Ravines.push_back(*itr);
- itr = m_Cache.erase(itr);
- }
- else
- {
- // don't want
- ++itr;
- }
- } // for itr - m_Cache[]
-
- for (int x = 0; x < NEIGHBORHOOD_SIZE; x++)
- {
- int RealX = (BaseX + x) * m_Size;
- for (int z = 0; z < NEIGHBORHOOD_SIZE; z++)
- {
- int RealZ = (BaseZ + z) * m_Size;
- bool Found = false;
- for (cRavines::const_iterator itr = a_Ravines.begin(), end = a_Ravines.end(); itr != end; ++itr)
- {
- if (((*itr)->m_BlockX == RealX) && ((*itr)->m_BlockZ == RealZ))
- {
- Found = true;
- break;
- }
- }
- if (!Found)
- {
- a_Ravines.push_back(new cRavine(RealX, RealZ, m_Size, m_Noise));
- }
- }
- }
-
- // Copy a_Ravines into m_Cache to the beginning:
- cRavines RavinesCopy(a_Ravines);
- m_Cache.splice(m_Cache.begin(), RavinesCopy, RavinesCopy.begin(), RavinesCopy.end());
-
- // Trim the cache if it's too long:
- if (m_Cache.size() > 100)
- {
- cRavines::iterator itr = m_Cache.begin();
- std::advance(itr, 100);
- for (cRavines::iterator end = m_Cache.end(); itr != end; ++itr)
- {
- delete *itr;
- }
- itr = m_Cache.begin();
- std::advance(itr, 100);
- m_Cache.erase(itr, m_Cache.end());
- }
-
- /*
- #ifdef _DEBUG
- // DEBUG: Export as SVG into a file specific for the chunk, for visual verification:
- AString SVG;
- SVG.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1024\" height = \"1024\">\n");
- for (cRavines::const_iterator itr = a_Ravines.begin(), end = a_Ravines.end(); itr != end; ++itr)
- {
- SVG.append((*itr)->ExportAsSVG(0, 512, 512));
- }
- SVG.append("</svg>\n");
-
- AString fnam;
- Printf(fnam, "ravines\\%03d_%03d.svg", a_ChunkX, a_ChunkZ);
- cFile File(fnam, cFile::fmWrite);
- File.Write(SVG.c_str(), SVG.size());
- #endif // _DEBUG
- //*/
-}
-
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenRavines::cRavine
-cStructGenRavines::cRavine::cRavine(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise) :
- m_BlockX(a_BlockX),
- m_BlockZ(a_BlockZ)
+cStructGenRavines::cRavine::cRavine(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise) :
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ)
{
// Calculate the ravine shape-defining points:
- GenerateBaseDefPoints(a_BlockX, a_BlockZ, a_Size, a_Noise);
+ GenerateBaseDefPoints(a_OriginX, a_OriginZ, a_Size, a_Noise);
- // Smooth the ravine. A two passes are needed:
+ // Smooth the ravine. Two passes are needed:
Smooth();
Smooth();
@@ -263,8 +128,8 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block
a_Size = (512 + ((a_Noise.IntNoise3DInt(19 * a_BlockX, 11 * a_BlockZ, a_BlockX + a_BlockZ) / 17) % 512)) * a_Size / 1024;
// The complete offset of the ravine from its cellpoint, up to 2 * a_Size in each direction
- int OffsetX = (((a_Noise.IntNoise3DInt(50 * a_BlockX, 30 * a_BlockZ, 0) / 9) % (2 * a_Size)) + ((a_Noise.IntNoise3DInt(30 * a_BlockX, 50 * m_BlockZ, 1000) / 7) % (2 * a_Size)) - 2 * a_Size) / 2;
- int OffsetZ = (((a_Noise.IntNoise3DInt(50 * a_BlockX, 30 * a_BlockZ, 2000) / 7) % (2 * a_Size)) + ((a_Noise.IntNoise3DInt(30 * a_BlockX, 50 * m_BlockZ, 3000) / 9) % (2 * a_Size)) - 2 * a_Size) / 2;
+ int OffsetX = (((a_Noise.IntNoise3DInt(50 * a_BlockX, 30 * a_BlockZ, 0) / 9) % (2 * a_Size)) + ((a_Noise.IntNoise3DInt(30 * a_BlockX, 50 * a_BlockZ, 1000) / 7) % (2 * a_Size)) - 2 * a_Size) / 2;
+ int OffsetZ = (((a_Noise.IntNoise3DInt(50 * a_BlockX, 30 * a_BlockZ, 2000) / 7) % (2 * a_Size)) + ((a_Noise.IntNoise3DInt(30 * a_BlockX, 50 * a_BlockZ, 3000) / 9) % (2 * a_Size)) - 2 * a_Size) / 2;
int CenterX = a_BlockX + OffsetX;
int CenterZ = a_BlockZ + OffsetZ;
@@ -306,8 +171,14 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block
void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst)
{
+ if (a_Src.size() < 2)
+ {
+ // No midpoints, nothing to refine
+ return;
+ }
+
// Smoothing: for each line segment, add points on its 1/4 lengths
- int Num = a_Src.size() - 2; // this many intermediary points
+ size_t Num = a_Src.size() - 2; // this many intermediary points
a_Dst.clear();
a_Dst.reserve(Num * 2 + 2);
cRavDefPoints::const_iterator itr = a_Src.begin() + 1;
@@ -318,7 +189,7 @@ void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cR
int PrevR = Source.m_Radius;
int PrevT = Source.m_Top;
int PrevB = Source.m_Bottom;
- for (int i = 0; i <= Num; ++i, ++itr)
+ for (size_t i = 0; i <= Num; ++i, ++itr)
{
int dx = itr->m_BlockX - PrevX;
int dz = itr->m_BlockZ - PrevZ;
@@ -412,38 +283,38 @@ void cStructGenRavines::cRavine::FinishLinear(void)
AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const
{
AString SVG;
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#%06x;stroke-width:1px;\"\nd=\"", a_Color);
- char Prefix = 'M'; // The first point needs "M" prefix, all the others need "L"
- for (cRavDefPoints::const_iterator itr = m_Points.begin(); itr != m_Points.end(); ++itr)
- {
- AppendPrintf(SVG, "%c %d,%d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ);
+ AppendPrintf(SVG, "<path style=\"fill:none;stroke:#%06x;stroke-width:1px;\"\nd=\"", a_Color);
+ char Prefix = 'M'; // The first point needs "M" prefix, all the others need "L"
+ for (cRavDefPoints::const_iterator itr = m_Points.begin(); itr != m_Points.end(); ++itr)
+ {
+ AppendPrintf(SVG, "%c %d, %d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ);
Prefix = 'L';
- }
- SVG.append("\"/>\n");
-
- // Base point highlight:
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#ff0000;stroke-width:1px;\"\nd=\"M %d,%d L %d,%d\"/>\n",
- a_OffsetX + m_BlockX - 5, a_OffsetZ + m_BlockZ, a_OffsetX + m_BlockX + 5, a_OffsetZ + m_BlockZ
+ }
+ SVG.append("\"/>\n");
+
+ // Base point highlight:
+ AppendPrintf(SVG, "<path style=\"fill:none;stroke:#ff0000;stroke-width:1px;\"\nd=\"M %d, %d L %d, %d\"/>\n",
+ a_OffsetX + m_OriginX - 5, a_OffsetZ + m_OriginZ, a_OffsetX + m_OriginX + 5, a_OffsetZ + m_OriginZ
);
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#ff0000;stroke-width:1px;\"\nd=\"M %d,%d L %d,%d\"/>\n",
- a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ - 5, a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ + 5
+ AppendPrintf(SVG, "<path style=\"fill:none;stroke:#ff0000;stroke-width:1px;\"\nd=\"M %d, %d L %d, %d\"/>\n",
+ a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ - 5, a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ + 5
);
// A gray line from the base point to the first point of the ravine, for identification:
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#cfcfcf;stroke-width:1px;\"\nd=\"M %d,%d L %d,%d\"/>\n",
- a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ, a_OffsetX + m_Points.front().m_BlockX, a_OffsetZ + m_Points.front().m_BlockZ
+ AppendPrintf(SVG, "<path style=\"fill:none;stroke:#cfcfcf;stroke-width:1px;\"\nd=\"M %d, %d L %d, %d\"/>\n",
+ a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ, a_OffsetX + m_Points.front().m_BlockX, a_OffsetZ + m_Points.front().m_BlockZ
);
// Offset guides:
if (a_OffsetX > 0)
{
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#0000ff;stroke-width:1px;\"\nd=\"M %d,0 L %d,1024\"/>\n",
+ AppendPrintf(SVG, "<path style=\"fill:none;stroke:#0000ff;stroke-width:1px;\"\nd=\"M %d, 0 L %d, 1024\"/>\n",
a_OffsetX, a_OffsetX
);
}
if (a_OffsetZ > 0)
{
- AppendPrintf(SVG, "<path style=\"fill:none;stroke:#0000ff;stroke-width:1px;\"\nd=\"M 0,%d L 1024,%d\"/>\n",
+ AppendPrintf(SVG, "<path style=\"fill:none;stroke:#0000ff;stroke-width:1px;\"\nd=\"M 0, %d L 1024, %d\"/>\n",
a_OffsetZ, a_OffsetZ
);
}
@@ -455,14 +326,10 @@ AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int
-void cStructGenRavines::cRavine::ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
- cChunkDef::HeightMap & a_HeightMap
-)
+void cStructGenRavines::cRavine::DrawIntoChunk(cChunkDesc & a_ChunkDesc)
{
- int BlockStartX = a_ChunkX * cChunkDef::Width;
- int BlockStartZ = a_ChunkZ * cChunkDef::Width;
+ int BlockStartX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ int BlockStartZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
int BlockEndX = BlockStartX + cChunkDef::Width;
int BlockEndZ = BlockStartZ + cChunkDef::Width;
for (cRavDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr)
@@ -488,7 +355,7 @@ void cStructGenRavines::cRavine::ProcessChunk(
// DEBUG: Make the ravine shapepoints visible on a single layer (so that we can see with Minutor what's going on)
if ((DifX + x == 0) && (DifZ + z == 0))
{
- cChunkDef::SetBlock(a_BlockTypes, x, 4, z, E_BLOCK_LAPIS_ORE);
+ a_ChunkDesc.SetBlockType(x, 4, z, E_BLOCK_LAPIS_ORE);
}
#endif // _DEBUG
@@ -498,7 +365,7 @@ void cStructGenRavines::cRavine::ProcessChunk(
int Top = std::min(itr->m_Top, (int)(cChunkDef::Height)); // Stupid gcc needs int cast
for (int y = std::max(itr->m_Bottom, 1); y <= Top; y++)
{
- switch (cChunkDef::GetBlock(a_BlockTypes, x, y, z))
+ switch (a_ChunkDesc.GetBlockType(x, y, z))
{
// Only carve out these specific block types
case E_BLOCK_DIRT:
@@ -516,7 +383,7 @@ void cStructGenRavines::cRavine::ProcessChunk(
case E_BLOCK_REDSTONE_ORE:
case E_BLOCK_REDSTONE_ORE_GLOWING:
{
- cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR);
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
break;
}
default: break;
diff --git a/src/Generating/Ravines.h b/src/Generating/Ravines.h
index c76b9f19f..3e41c5ce6 100644
--- a/src/Generating/Ravines.h
+++ b/src/Generating/Ravines.h
@@ -9,7 +9,7 @@
#pragma once
-#include "ComposableGenerator.h"
+#include "GridStructGen.h"
#include "../Noise.h"
@@ -17,28 +17,22 @@
class cStructGenRavines :
- public cFinishGen
+ public cGridStructGen
{
+ typedef cGridStructGen super;
+
public:
cStructGenRavines(int a_Seed, int a_Size);
- ~cStructGenRavines();
protected:
class cRavine; // fwd: Ravines.cpp
- typedef std::list<cRavine *> cRavines;
-
- cNoise m_Noise;
- int m_Size; // Max size, in blocks, of the ravines generated
- cRavines m_Cache;
- /// Clears everything from the cache
- void ClearCache(void);
+ cNoise m_Noise;
+ int m_Size; // Max size, in blocks, of the ravines generated
- /// Returns all ravines that *may* intersect the given chunk. All the ravines are valid until the next call to this function.
- void GetRavinesForChunk(int a_ChunkX, int a_ChunkZ, cRavines & a_Ravines);
-
- // cFinishGen override:
- virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
+
+ // cGridStructGen overrides:
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
} ;
diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp
new file mode 100644
index 000000000..badc7768e
--- /dev/null
+++ b/src/Generating/RoughRavines.cpp
@@ -0,0 +1,318 @@
+
+// RoughRavines.cpp
+
+// Implements the cRoughRavines class representing the rough ravine generator
+
+#include "Globals.h"
+
+#include "RoughRavines.h"
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cRoughRavine:
+
+class cRoughRavine :
+ public cGridStructGen::cStructure
+{
+ typedef cGridStructGen::cStructure super;
+
+public:
+ cRoughRavine(
+ int a_Seed, int a_Size,
+ float a_CenterWidth, float a_Roughness,
+ float a_FloorHeightEdge1, float a_FloorHeightEdge2, float a_FloorHeightCenter,
+ float a_CeilingHeightEdge1, float a_CeilingHeightEdge2, float a_CeilingHeightCenter,
+ int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ
+ ) :
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
+ m_Seed(a_Seed + 100),
+ m_Noise(a_Seed + 100),
+ m_Roughness(a_Roughness)
+ {
+ // Create the basic structure - 2 lines meeting at the centerpoint:
+ int Max = 2 * a_Size;
+ int Half = a_Size; // m_DefPoints[Half] will be the centerpoint
+ m_DefPoints.resize(Max + 1);
+ int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 7;
+ float Len = (float)a_Size;
+ float Angle = (float)rnd; // Angle is in radians, will be wrapped in the "sin" and "cos" operations
+ float OfsX = sin(Angle) * Len;
+ float OfsZ = cos(Angle) * Len;
+ m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, a_CeilingHeightEdge1, a_FloorHeightEdge1);
+ m_DefPoints[Half].Set((float)a_OriginX, (float)a_OriginZ, a_CenterWidth, a_CeilingHeightCenter, a_FloorHeightCenter);
+ m_DefPoints[Max].Set (a_OriginX + OfsX, a_OriginZ + OfsZ, 1, a_CeilingHeightEdge2, a_FloorHeightEdge2);
+
+ // Calculate the points in between, recursively:
+ SubdivideLine(0, Half);
+ SubdivideLine(Half, Max);
+
+ // Initialize the per-height radius modifiers:
+ InitPerHeightRadius(a_GridX, a_GridZ);
+ }
+
+protected:
+ struct sRavineDefPoint
+ {
+ float m_X;
+ float m_Z;
+ float m_Radius;
+ float m_Top;
+ float m_Bottom;
+
+ void Set(float a_X, float a_Z, float a_Radius, float a_Top, float a_Bottom)
+ {
+ m_X = a_X;
+ m_Z = a_Z;
+ m_Radius = a_Radius;
+ m_Top = a_Top;
+ m_Bottom = a_Bottom;
+ }
+ };
+ typedef std::vector<sRavineDefPoint> sRavineDefPoints;
+
+ int m_Seed;
+
+ cNoise m_Noise;
+
+ int m_MaxSize;
+
+ sRavineDefPoints m_DefPoints;
+
+ float m_Roughness;
+
+ /** Number to add to the radius based on the height. This creates the "ledges" in the ravine walls. */
+ float m_PerHeightRadius[cChunkDef::Height];
+
+
+ /** Recursively subdivides the line between the points of the specified index.
+ Sets the midpoint to the center of the line plus or minus a random offset, then calls itself for each half
+ of the new line. */
+ void SubdivideLine(int a_Idx1, int a_Idx2)
+ {
+ // Calculate the midpoint:
+ const sRavineDefPoint & p1 = m_DefPoints[a_Idx1];
+ const sRavineDefPoint & p2 = m_DefPoints[a_Idx2];
+ float MidX = (p1.m_X + p2.m_X) / 2;
+ float MidZ = (p1.m_Z + p2.m_Z) / 2;
+ float MidR = (p1.m_Radius + p2.m_Radius) / 2 + 0.1f;
+ float MidT = (p1.m_Top + p2.m_Top) / 2;
+ float MidB = (p1.m_Bottom + p2.m_Bottom) / 2;
+
+ // Adjust the midpoint by a small amount of perpendicular vector in a random one of its two directions:
+ float dx = p2.m_X - p1.m_X;
+ float dz = p2.m_Z - p1.m_Z;
+ if ((m_Noise.IntNoise2DInt((int)MidX, (int)MidZ) / 11) % 2 == 0)
+ {
+ MidX += dz * m_Roughness;
+ MidZ -= dx * m_Roughness;
+ }
+ else
+ {
+ MidX -= dz * m_Roughness;
+ MidZ += dx * m_Roughness;
+ }
+ int MidIdx = (a_Idx1 + a_Idx2) / 2;
+ m_DefPoints[MidIdx].Set(MidX, MidZ, MidR, MidT, MidB);
+
+ // Recurse the two halves, if they are worth recursing:
+ if (MidIdx - a_Idx1 > 1)
+ {
+ SubdivideLine(a_Idx1, MidIdx);
+ }
+ if (a_Idx2 - MidIdx > 1)
+ {
+ SubdivideLine(MidIdx, a_Idx2);
+ }
+ }
+
+
+ void InitPerHeightRadius(int a_GridX, int a_GridZ)
+ {
+ int h = 0;
+ while (h < cChunkDef::Height)
+ {
+ m_Noise.SetSeed(m_Seed + h);
+ int rnd = m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 13;
+ int NumBlocks = (rnd % 3) + 2;
+ rnd = rnd / 4;
+ float Val = (float)(rnd % 256) / 128 - 1; // Random float in range [-1, +1]
+ if (h + NumBlocks > cChunkDef::Height)
+ {
+ NumBlocks = cChunkDef::Height - h;
+ }
+ for (int i = 0; i < NumBlocks; i++)
+ {
+ m_PerHeightRadius[h + i] = Val;
+ }
+ h += NumBlocks;
+ }
+ }
+
+
+ virtual void DrawIntoChunk(cChunkDesc & a_ChunkDesc) override
+ {
+ int BlockStartX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ int BlockStartZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ int BlockEndX = BlockStartX + cChunkDef::Width;
+ int BlockEndZ = BlockStartZ + cChunkDef::Width;
+ for (sRavineDefPoints::const_iterator itr = m_DefPoints.begin(), end = m_DefPoints.end(); itr != end; ++itr)
+ {
+ if (
+ (ceilf (itr->m_X + itr->m_Radius + 2) < BlockStartX) ||
+ (floorf(itr->m_X - itr->m_Radius - 2) > BlockEndX) ||
+ (ceilf (itr->m_Z + itr->m_Radius + 2) < BlockStartZ) ||
+ (floorf(itr->m_Z - itr->m_Radius - 2) > BlockEndZ)
+ )
+ {
+ // Cannot intersect, bail out early
+ continue;
+ }
+
+ // Carve out a cylinder around the xz point, up to (m_Radius + 2) in diameter, from Bottom to Top:
+ // On each height level, use m_PerHeightRadius[] to modify the actual radius used
+ // EnlargedRadiusSq is the square of the radius enlarged by the maximum m_PerHeightRadius offset - anything outside it will never be touched.
+ float RadiusSq = (itr->m_Radius + 2) * (itr->m_Radius + 2);
+ float DifX = BlockStartX - itr->m_X; // substitution for faster calc
+ float DifZ = BlockStartZ - itr->m_Z; // substitution for faster calc
+ for (int x = 0; x < cChunkDef::Width; x++) for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ #ifdef _DEBUG
+ // DEBUG: Make the roughravine shapepoints visible on a single layer (so that we can see with Minutor what's going on)
+ if ((DifX + x == 0) && (DifZ + z == 0))
+ {
+ a_ChunkDesc.SetBlockType(x, 4, z, E_BLOCK_LAPIS_ORE);
+ }
+ #endif // _DEBUG
+
+ // If the column is outside the enlarged radius, bail out completely
+ float DistSq = (DifX + x) * (DifX + x) + (DifZ + z) * (DifZ + z);
+ if (DistSq > RadiusSq)
+ {
+ continue;
+ }
+
+ int Top = std::min((int)ceilf(itr->m_Top), +cChunkDef::Height);
+ for (int y = std::max((int)floorf(itr->m_Bottom), 1); y <= Top; y++)
+ {
+ if ((itr->m_Radius + m_PerHeightRadius[y]) * (itr->m_Radius + m_PerHeightRadius[y]) < DistSq)
+ {
+ continue;
+ }
+ switch (a_ChunkDesc.GetBlockType(x, y, z))
+ {
+ // Only carve out these specific block types
+ case E_BLOCK_DIRT:
+ case E_BLOCK_GRASS:
+ case E_BLOCK_STONE:
+ case E_BLOCK_COBBLESTONE:
+ case E_BLOCK_GRAVEL:
+ case E_BLOCK_SAND:
+ case E_BLOCK_SANDSTONE:
+ case E_BLOCK_NETHERRACK:
+ case E_BLOCK_COAL_ORE:
+ case E_BLOCK_IRON_ORE:
+ case E_BLOCK_GOLD_ORE:
+ case E_BLOCK_DIAMOND_ORE:
+ case E_BLOCK_REDSTONE_ORE:
+ case E_BLOCK_REDSTONE_ORE_GLOWING:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
+ break;
+ }
+ default: break;
+ } // switch (BlockType)
+ } // for y
+ } // for x, z - a_BlockTypes
+ } // for itr - m_Points[]
+ }
+};
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cRoughRavines:
+
+cRoughRavines::cRoughRavines(
+ int a_Seed,
+ int a_MaxSize, int a_MinSize,
+ float a_MaxCenterWidth, float a_MinCenterWidth,
+ float a_MaxRoughness, float a_MinRoughness,
+ float a_MaxFloorHeightEdge, float a_MinFloorHeightEdge,
+ float a_MaxFloorHeightCenter, float a_MinFloorHeightCenter,
+ float a_MaxCeilingHeightEdge, float a_MinCeilingHeightEdge,
+ float a_MaxCeilingHeightCenter, float a_MinCeilingHeightCenter,
+ int a_GridSize, int a_MaxOffset
+) :
+ super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 64),
+ m_Seed(a_Seed),
+ m_MaxSize(a_MaxSize),
+ m_MinSize(a_MinSize),
+ m_MaxCenterWidth(a_MaxCenterWidth),
+ m_MinCenterWidth(a_MinCenterWidth),
+ m_MaxRoughness(a_MaxRoughness),
+ m_MinRoughness(a_MinRoughness),
+ m_MaxFloorHeightEdge(a_MaxFloorHeightEdge),
+ m_MinFloorHeightEdge(a_MinFloorHeightEdge),
+ m_MaxFloorHeightCenter(a_MaxFloorHeightCenter),
+ m_MinFloorHeightCenter(a_MinFloorHeightCenter),
+ m_MaxCeilingHeightEdge(a_MaxCeilingHeightEdge),
+ m_MinCeilingHeightEdge(a_MinCeilingHeightEdge),
+ m_MaxCeilingHeightCenter(a_MaxCeilingHeightCenter),
+ m_MinCeilingHeightCenter(a_MinCeilingHeightCenter)
+{
+ if (m_MinSize > m_MaxSize)
+ {
+ std::swap(m_MinSize, m_MaxSize);
+ std::swap(a_MinSize, a_MaxSize);
+ }
+ if (m_MaxSize < 16)
+ {
+ m_MaxSize = 16;
+ LOGWARNING("RoughRavines: MaxSize too small, adjusting request from %d to %d", a_MaxSize, m_MaxSize);
+ }
+ if (m_MinSize < 16)
+ {
+ m_MinSize = 16;
+ LOGWARNING("RoughRavines: MinSize too small, adjusting request from %d to %d", a_MinSize, m_MinSize);
+ }
+ if (m_MinSize == m_MaxSize)
+ {
+ m_MaxSize = m_MinSize + 1;
+ }
+}
+
+
+
+
+
+cGridStructGen::cStructurePtr cRoughRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
+{
+ // Pick a random value for each of the ravine's parameters:
+ int Size = m_MinSize + (m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 7) % (m_MaxSize - m_MinSize); // Random int from m_MinSize to m_MaxSize
+ float CenterWidth = m_Noise.IntNoise2DInRange(a_GridX + 10, a_GridZ, m_MinCenterWidth, m_MaxCenterWidth);
+ float Roughness = m_Noise.IntNoise2DInRange(a_GridX + 20, a_GridZ, m_MinRoughness, m_MaxRoughness);
+ float FloorHeightEdge1 = m_Noise.IntNoise2DInRange(a_GridX + 30, a_GridZ, m_MinFloorHeightEdge, m_MaxFloorHeightEdge);
+ float FloorHeightEdge2 = m_Noise.IntNoise2DInRange(a_GridX + 40, a_GridZ, m_MinFloorHeightEdge, m_MaxFloorHeightEdge);
+ float FloorHeightCenter = m_Noise.IntNoise2DInRange(a_GridX + 50, a_GridZ, m_MinFloorHeightCenter, m_MaxFloorHeightCenter);
+ float CeilingHeightEdge1 = m_Noise.IntNoise2DInRange(a_GridX + 60, a_GridZ, m_MinCeilingHeightEdge, m_MaxCeilingHeightEdge);
+ float CeilingHeightEdge2 = m_Noise.IntNoise2DInRange(a_GridX + 70, a_GridZ, m_MinCeilingHeightEdge, m_MaxCeilingHeightEdge);
+ float CeilingHeightCenter = m_Noise.IntNoise2DInRange(a_GridX + 80, a_GridZ, m_MinCeilingHeightCenter, m_MaxCeilingHeightCenter);
+
+ // Create a ravine:
+ return cStructurePtr(new cRoughRavine(
+ m_Seed,
+ Size, CenterWidth, Roughness,
+ FloorHeightEdge1, FloorHeightEdge2, FloorHeightCenter,
+ CeilingHeightEdge1, CeilingHeightEdge2, CeilingHeightCenter,
+ a_GridX, a_GridZ, a_OriginX, a_OriginZ
+ ));
+}
+
+
+
+
diff --git a/src/Generating/RoughRavines.h b/src/Generating/RoughRavines.h
new file mode 100644
index 000000000..4c905b641
--- /dev/null
+++ b/src/Generating/RoughRavines.h
@@ -0,0 +1,86 @@
+
+// RoughRavines.h
+
+// Declares the cRoughRavines class representing the rough ravine generator
+
+
+
+
+#pragma once
+
+#include "GridStructGen.h"
+
+
+
+
+
+class cRoughRavines :
+ public cGridStructGen
+{
+ typedef cGridStructGen super;
+
+public:
+ cRoughRavines(
+ int a_Seed,
+ int a_MaxSize, int a_MinSize,
+ float a_MaxCenterWidth, float a_MinCenterWidth,
+ float a_MaxRoughness, float a_MinRoughness,
+ float a_MaxFloorHeightEdge, float a_MinFloorHeightEdge,
+ float a_MaxFloorHeightCenter, float a_MinFloorHeightCenter,
+ float a_MaxCeilingHeightEdge, float a_MinCeilingHeightEdge,
+ float a_MaxCeilingHeightCenter, float a_MinCeilingHeightCenter,
+ int a_GridSize, int a_MaxOffset
+ );
+
+protected:
+ int m_Seed;
+
+ /** Maximum size of the ravine, in each of the X / Z axis */
+ int m_MaxSize;
+
+ /** Minimum size of the ravine */
+ int m_MinSize;
+
+ /** Maximum width of the ravine's center, in blocks */
+ float m_MaxCenterWidth;
+
+ /** Minimum width of the ravine's center, in blocks */
+ float m_MinCenterWidth;
+
+ /** Maximum roughness of the ravine */
+ float m_MaxRoughness;
+
+ /** Minimum roughness of the ravine */
+ float m_MinRoughness;
+
+ /** Maximum floor height at the ravine's edge */
+ float m_MaxFloorHeightEdge;
+
+ /** Minimum floor height at the ravine's edge */
+ float m_MinFloorHeightEdge;
+
+ /** Maximum floor height at the ravine's center */
+ float m_MaxFloorHeightCenter;
+
+ /** Minimum floor height at the ravine's center */
+ float m_MinFloorHeightCenter;
+
+ /** Maximum ceiling height at the ravine's edge */
+ float m_MaxCeilingHeightEdge;
+
+ /** Minimum ceiling height at the ravine's edge */
+ float m_MinCeilingHeightEdge;
+
+ /** Maximum ceiling height at the ravine's center */
+ float m_MaxCeilingHeightCenter;
+
+ /** Minimum ceiling height at the ravine's center */
+ float m_MinCeilingHeightCenter;
+
+ // cGridStructGen overrides:
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
+};
+
+
+
+
diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp
index db9d5578c..054eec345 100644
--- a/src/Generating/StructGen.cpp
+++ b/src/Generating/StructGen.cpp
@@ -12,7 +12,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenOreNests configuration:
const int MAX_HEIGHT_COAL = 127;
@@ -51,7 +51,7 @@ const int NEST_SIZE_GRAVEL = 32;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenTrees:
void cStructGenTrees::GenFinish(cChunkDesc & a_ChunkDesc)
@@ -151,7 +151,7 @@ void cStructGenTrees::GenerateSingleTree(
sSetBlockVector TreeLogs, TreeOther;
GetTreeImageByBiome(
a_ChunkX * cChunkDef::Width + x, Height + 1, a_ChunkZ * cChunkDef::Width + z,
- m_Noise, a_Seq,
+ m_Noise, a_Seq,
a_ChunkDesc.GetBiome(x, z),
TreeLogs, TreeOther
);
@@ -181,7 +181,7 @@ void cStructGenTrees::GenerateSingleTree(
}
ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeOther, a_OutsideOther);
- ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeLogs, a_OutsideLogs);
+ ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeLogs, a_OutsideLogs);
}
@@ -303,7 +303,7 @@ int cStructGenTrees::GetNumTrees(
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenOreNests:
void cStructGenOreNests::GenFinish(cChunkDesc & a_ChunkDesc)
@@ -410,7 +410,7 @@ void cStructGenOreNests::GenerateOre(int a_ChunkX, int a_ChunkZ, BLOCKTYPE a_Ore
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenLakes:
void cStructGenLakes::GenFinish(cChunkDesc & a_ChunkDesc)
@@ -484,7 +484,6 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a
const int BubbleY = 4 + (Rnd & 0x01); // 4 .. 5
Rnd >>= 1;
const int BubbleZ = BubbleR + (Rnd % Range);
- Rnd >>= 4;
const int HalfR = BubbleR / 2; // 1 .. 2
const int RSquared = BubbleR * BubbleR;
for (int y = -HalfR; y <= HalfR; y++)
@@ -500,7 +499,7 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a
continue;
}
int IdxYZ = BubbleX + IdxY + (BubbleZ + z) * 16;
- for (int x = -BubbleR; x <= BubbleR; x++)
+ for (int x = -BubbleR; x <= BubbleR; x++)
{
if (x * x + DistYZ < RSquared)
{
@@ -511,10 +510,10 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a
} // for y
} // for i - bubbles
- // Turn air in the bottom half into liquid:
+ // Turn air in the bottom half into liquid:
for (int y = 0; y < 4; y++)
{
- for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++)
+ for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++)
{
if (BlockTypes[x + z * 16 + y * 16 * 16] == E_BLOCK_AIR)
{
@@ -532,7 +531,7 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenDirectOverhangs:
cStructGenDirectOverhangs::cStructGenDirectOverhangs(int a_Seed) :
@@ -573,8 +572,8 @@ void cStructGenDirectOverhangs::GenFinish(cChunkDesc & a_ChunkDesc)
// Interpolate the lowest floor:
for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++)
{
- FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] =
- m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) *
+ FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] =
+ m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) *
m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) /
256;
} // for x, z - FloorLo[]
@@ -596,24 +595,22 @@ void cStructGenDirectOverhangs::GenFinish(cChunkDesc & a_ChunkDesc)
// Interpolate between FloorLo and FloorHi:
for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++)
{
- switch (a_ChunkDesc.GetBiome(x, z))
+ EMCSBiome biome = a_ChunkDesc.GetBiome(x, z);
+
+ if ((biome == biExtremeHills) || (biome == biExtremeHillsEdge))
{
- case biExtremeHills:
- case biExtremeHillsEdge:
+ int Lo = FloorLo[x + 17 * z] / 256;
+ int Hi = FloorHi[x + 17 * z] / 256;
+ for (int y = 0; y < SEGMENT_HEIGHT; y++)
{
- int Lo = FloorLo[x + 17 * z] / 256;
- int Hi = FloorHi[x + 17 * z] / 256;
- for (int y = 0; y < SEGMENT_HEIGHT; y++)
+ int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT;
+ if (Val < 0)
{
- int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT;
- if (Val < 0)
- {
- a_ChunkDesc.SetBlockType(x, y + Segment, z, E_BLOCK_AIR);
- }
- } // for y
- break;
- }
- } // switch (biome)
+ a_ChunkDesc.SetBlockType(x, y + Segment, z, E_BLOCK_AIR);
+ }
+ } // for y
+ break;
+ } // if (biome)
} // for z, x
// Swap the floors:
@@ -650,7 +647,7 @@ bool cStructGenDirectOverhangs::HasWantedBiome(cChunkDesc & a_ChunkDesc) const
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cStructGenDistortedMembraneOverhangs:
cStructGenDistortedMembraneOverhangs::cStructGenDistortedMembraneOverhangs(int a_Seed) :
diff --git a/src/Generating/TestRailsGen.cpp b/src/Generating/TestRailsGen.cpp
new file mode 100644
index 000000000..66ab8b33f
--- /dev/null
+++ b/src/Generating/TestRailsGen.cpp
@@ -0,0 +1,116 @@
+
+// TestRailsGen.cpp
+
+// Implements the cTestRailsGen class representing the testing rails generator
+
+#include "Globals.h"
+#include "TestRailsGen.h"
+#include "Prefabs/TestRailsPrefabs.h"
+#include "PieceGenerator.h"
+
+
+
+
+
+static cPrefabPiecePool g_TestRails(g_TestRailsPrefabs, g_TestRailsPrefabsCount, g_TestRailsStartingPrefabs, g_TestRailsStartingPrefabsCount);
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cTestRailsGen::cTestRails:
+
+class cTestRailsGen::cTestRails :
+ public cGridStructGen::cStructure
+{
+ typedef cGridStructGen::cStructure super;
+
+public:
+ cTestRails(
+ int a_Seed,
+ int a_GridX, int a_GridZ,
+ int a_OriginX, int a_OriginZ,
+ int a_MaxDepth,
+ int a_MaxSize
+ ) :
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
+ m_Seed(a_Seed),
+ m_Noise(a_Seed),
+ m_MaxSize(a_MaxSize),
+ m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize)
+ {
+ // Generate the pieces for this test:
+ cBFSPieceGenerator pg(g_TestRails, a_Seed);
+ pg.PlacePieces(a_OriginX, 150, a_OriginZ, a_MaxDepth, m_Pieces);
+ if (m_Pieces.empty())
+ {
+ return;
+ }
+ }
+
+ ~cTestRails()
+ {
+ cPieceGenerator::FreePieces(m_Pieces);
+ }
+
+protected:
+ /** Seed for the random functions */
+ int m_Seed;
+
+ /** The noise used as a pseudo-random generator */
+ cNoise m_Noise;
+
+ /** Maximum size, in X/Z blocks, of the structure (radius from the origin) */
+ int m_MaxSize;
+
+ /** Borders of the structure - no item may reach out of this cuboid. */
+ cCuboid m_Borders;
+
+ /** The rails pieces, placed by the generator. */
+ cPlacedPieces m_Pieces;
+
+
+ // cGridStructGen::cStructure overrides:
+ virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override
+ {
+ for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
+ {
+ cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece());
+ Prefab.Draw(a_Chunk, *itr);
+ } // for itr - m_PlacedPieces[]
+ }
+} ;
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cTestRailsGen:
+
+
+
+
+
+cTestRailsGen::cTestRailsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize) :
+ super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100),
+ m_Noise(a_Seed + 1000),
+ m_MaxDepth(a_MaxDepth),
+ m_MaxSize(a_MaxSize)
+{
+}
+
+
+
+
+
+cGridStructGen::cStructurePtr cTestRailsGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
+{
+ // Create a base based on the chosen prefabs:
+ return cStructurePtr(new cTestRails(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize));
+}
+
+
+
+
diff --git a/src/Generating/TestRailsGen.h b/src/Generating/TestRailsGen.h
new file mode 100644
index 000000000..5b0ce95f4
--- /dev/null
+++ b/src/Generating/TestRailsGen.h
@@ -0,0 +1,47 @@
+
+// TestRailsGen.h
+
+// Declares the cTestRailsGen class representing the testing rails generator
+
+
+
+
+
+#pragma once
+
+#include "GridStructGen.h"
+#include "PrefabPiecePool.h"
+
+
+
+
+
+class cTestRailsGen :
+ public cGridStructGen
+{
+ typedef cGridStructGen super;
+
+public:
+ cTestRailsGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize);
+
+protected:
+ class cTestRails; // fwd: TestRailsGen.cpp
+
+
+ /** The noise used for generating random numbers */
+ cNoise m_Noise;
+
+ /** Maximum depth of the generator tree*/
+ int m_MaxDepth;
+
+ /** Maximum size, in X/Z blocks, of the base (radius from the origin) */
+ int m_MaxSize;
+
+
+ // cGridStructGen overrides:
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
+} ;
+
+
+
+
diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp
index 5a71cf13c..c40322630 100644
--- a/src/Generating/Trees.cpp
+++ b/src/Generating/Trees.cpp
@@ -10,13 +10,6 @@
-// DEBUG:
-int gTotalLargeJungleTrees = 0;
-int gOversizeLargeJungleTrees = 0;
-
-
-
-
typedef struct
{
@@ -41,49 +34,49 @@ static const sCoords Corners[] =
static const sCoords BigO1[] =
{
- {0, -1},
- {-1, 0}, {1, 0},
- {0, 1},
+ /* -1 */ {0, -1},
+ /* 0 */ {-1, 0}, {1, 0},
+ /* 1 */ {0, 1},
} ;
static const sCoords BigO2[] =
{
- {-1, -2}, {0, -2}, {1, -2},
- {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1},
- {-2, 0}, {-1, 0}, {1, 0}, {2, 0},
- {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1},
- {-1, 2}, {0, 2}, {1, 2},
+ /* -2 */ {-1, -2}, {0, -2}, {1, -2},
+ /* -1 */ {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1},
+ /* 0 */ {-2, 0}, {-1, 0}, {1, 0}, {2, 0},
+ /* 1 */ {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1},
+ /* 2 */ {-1, 2}, {0, 2}, {1, 2},
} ;
static const sCoords BigO3[] =
{
- {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3},
- {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2},
- {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1},
- {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0},
- {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1},
- {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2},
- {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3},
+ /* -3 */ {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3},
+ /* -2 */ {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2},
+ /* -1 */ {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1},
+ /* 0 */ {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0},
+ /* 1 */ {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1},
+ /* 2 */ {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2},
+ /* 3 */ {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3},
} ;
-static const sCoords BigO4[] = // Part of Big Jungle tree
+static const sCoords BigO4[] = // Part of Big Jungle tree
{
- {-2, -4}, {-1, -4}, {0, -4}, {1, -4}, {2, -4},
- {-3, -3}, {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, {3, -3},
- {-4, -2}, {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, {4, -2},
- {-4, -1}, {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, {4, -1},
- {-4, 0}, {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0},
- {-4, 1}, {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1},
- {-4, 2}, {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2},
- {-3, 3}, {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, {3, 3},
- {-2, 4}, {-1, 4}, {0, 4}, {1, 4}, {2, 4},
+ /* -4 */ {-2, -4}, {-1, -4}, {0, -4}, {1, -4}, {2, -4},
+ /* -3 */ {-3, -3}, {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, {3, -3},
+ /* -2 */ {-4, -2}, {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, {4, -2},
+ /* -1 */ {-4, -1}, {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, {4, -1},
+ /* 0 */ {-4, 0}, {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0},
+ /* 1 */ {-4, 1}, {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1},
+ /* 2 */ {-4, 2}, {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2},
+ /* 3 */ {-3, 3}, {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, {3, 3},
+ /* 4 */ {-2, 4}, {-1, 4}, {0, 4}, {1, 4}, {2, 4},
} ;
-typedef struct
+typedef struct
{
const sCoords * Coords;
size_t Count;
@@ -113,6 +106,7 @@ inline void PushCoordBlocks(int a_BlockX, int a_Height, int a_BlockZ, sSetBlockV
+
inline void PushCornerBlocks(int a_BlockX, int a_Height, int a_BlockZ, int a_Seq, cNoise & a_Noise, int a_Chance, sSetBlockVector & a_Blocks, int a_CornersDist, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta)
{
for (size_t i = 0; i < ARRAYCOUNT(Corners); i++)
@@ -136,7 +130,7 @@ inline void PushSomeColumns(int a_BlockX, int a_Height, int a_BlockZ, int a_Colu
{
int x = a_BlockX + a_Coords[i].x;
int z = a_BlockZ + a_Coords[i].z;
- if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + i, z + 64 * a_Seq) <= a_Chance)
+ if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + (int)i, z + 64 * a_Seq) <= a_Chance)
{
for (int j = 0; j < a_ColumnHeight; j++)
{
@@ -174,7 +168,7 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No
{
GetBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
}
- break;
+ return;
}
case biTaiga:
@@ -184,14 +178,14 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No
{
// Conifers
GetConiferTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
- break;
+ return;
}
case biSwampland:
{
// Swamp trees:
GetSwampTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
- break;
+ return;
}
case biJungle:
@@ -203,25 +197,25 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No
{
GetAppleBushImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
}
- else
+ else
{
GetJungleTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
}
- break;
+ return;
}
case biBirchForest:
case biBirchForestHills:
{
GetBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
- break;
+ return;
}
case biBirchForestM:
case biBirchForestHillsM:
{
GetTallBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
- break;
+ return;
}
case biRoofedForest:
@@ -257,9 +251,29 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No
{
// TODO: These need their special trees
GetBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
- break;
+ return;
+ }
+
+ case biDesert:
+ case biDesertHills:
+ case biRiver:
+ case biBeach:
+ case biHell:
+ case biSky:
+ case biOcean:
+ case biFrozenOcean:
+ case biFrozenRiver:
+ case biVariant:
+ case biNumBiomes:
+ case biNumVariantBiomes:
+ case biInvalidBiome:
+ {
+ // These biomes have no trees, or are non-biome members of the enum.
+ return;
}
}
+
+ ASSERT(!"Invalid biome type!");
}
@@ -304,31 +318,31 @@ void GetSmallAppleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a
// Trunk:
for (int i = 0; i < Height; i++)
{
- a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_APPLE));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_APPLE));
}
int Hei = a_BlockY + Height;
// 2 BigO2 + corners layers:
for (int i = 0; i < 2; i++)
{
- PushCoordBlocks (a_BlockX, Hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
- PushCornerBlocks(a_BlockX, Hei, a_BlockZ, a_Seq, a_Noise, 0x5000000 - i * 0x10000000, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
- a_LogBlocks.push_back(sSetBlock(a_BlockX, Hei, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_APPLE));
+ PushCoordBlocks (a_BlockX, Hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
+ PushCornerBlocks(a_BlockX, Hei, a_BlockZ, a_Seq, a_Noise, 0x5000000 - i * 0x10000000, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, Hei, a_BlockZ, E_BLOCK_LOG, E_META_LOG_APPLE));
Hei++;
} // for i - 2*
// Optional BigO1 + corners layer:
if ((Random & 1) == 0)
{
- PushCoordBlocks (a_BlockX, Hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
- PushCornerBlocks(a_BlockX, Hei, a_BlockZ, a_Seq, a_Noise, 0x6000000, a_OtherBlocks, 1, E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
- a_LogBlocks.push_back(sSetBlock(a_BlockX, Hei, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_APPLE));
+ PushCoordBlocks (a_BlockX, Hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
+ PushCornerBlocks(a_BlockX, Hei, a_BlockZ, a_Seq, a_Noise, 0x6000000, a_OtherBlocks, 1, E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, Hei, a_BlockZ, E_BLOCK_LOG, E_META_LOG_APPLE));
Hei++;
}
// Top plus:
- PushCoordBlocks(a_BlockX, Hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, Hei, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE));
+ PushCoordBlocks(a_BlockX, Hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, Hei, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_APPLE));
}
@@ -355,25 +369,25 @@ void GetBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Nois
// The entire trunk, out of logs:
for (int i = Height - 1; i >= 0; --i)
{
- a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_BIRCH));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_BIRCH));
}
int h = a_BlockY + Height;
// Top layer - just the Plus:
- PushCoordBlocks(a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH)); // There's no log at this layer
+ PushCoordBlocks(a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH)); // There's no log at this layer
h--;
// Second layer - log, Plus and maybe Corners:
- PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
- PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 1, E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
+ PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
+ PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 1, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
h--;
// Third and fourth layers - BigO2 and maybe 2*Corners:
for (int Row = 0; Row < 2; Row++)
{
- PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
- PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x3fffffff + Row * 0x10000000, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
+ PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
+ PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x3fffffff + Row * 0x10000000, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
h--;
} // for Row - 2*
}
@@ -411,25 +425,25 @@ void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_
// The entire trunk, out of logs:
for (int i = Height - 1; i >= 0; --i)
{
- a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_BIRCH));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_BIRCH));
}
int h = a_BlockY + Height;
// Top layer - just the Plus:
- PushCoordBlocks(a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH)); // There's no log at this layer
+ PushCoordBlocks(a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH)); // There's no log at this layer
h--;
// Second layer - log, Plus and maybe Corners:
- PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
- PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 1, E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
+ PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
+ PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 1, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
h--;
// Third and fourth layers - BigO2 and maybe 2*Corners:
for (int Row = 0; Row < 2; Row++)
{
- PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
- PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x3fffffff + Row * 0x10000000, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_NEWLEAVES_BIRCH);
+ PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
+ PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x3fffffff + Row * 0x10000000, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);
h--;
} // for Row - 2*
}
@@ -476,15 +490,15 @@ void GetSpruceTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noi
// Clear trunk blocks:
for (int i = 0; i < Height; i++)
{
- a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
}
Height += a_BlockY;
// Optional size-1 bottom leaves layer:
if ((MyRandom & 1) == 0)
{
- PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
+ PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
Height++;
}
MyRandom >>= 1;
@@ -500,30 +514,30 @@ void GetSpruceTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noi
case 0:
case 1:
{
- PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- PushCoordBlocks(a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- a_LogBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
- a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
+ PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ PushCoordBlocks(a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
Height += 2;
break;
}
case 2:
{
- PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- PushCoordBlocks(a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- a_LogBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
- a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
+ PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ PushCoordBlocks(a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
Height += 2;
break;
}
case 3:
{
- PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- PushCoordBlocks(a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- PushCoordBlocks(a_BlockX, Height + 2, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- a_LogBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
- a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
- a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 2, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
+ PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ PushCoordBlocks(a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ PushCoordBlocks(a_BlockX, Height + 2, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 2, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
Height += 3;
break;
}
@@ -534,17 +548,17 @@ void GetSpruceTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noi
if ((MyRandom & 1) == 0)
{
// (0, 1, 0) top:
- a_LogBlocks.push_back (sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
- PushCoordBlocks (a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER));
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height + 2, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER));
+ a_LogBlocks.push_back (sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
+ PushCoordBlocks (a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER));
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height + 2, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER));
}
else
{
// (1, 0) top:
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER));
- PushCoordBlocks (a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER));
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER));
+ PushCoordBlocks (a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER));
}
}
@@ -574,16 +588,16 @@ void GetPineTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise
// The entire trunk, out of logs:
for (int i = TrunkHeight; i >= 0; --i)
{
- a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_CONIFER));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER));
}
int h = a_BlockY + TrunkHeight + 2;
- // Top layer - just a single leaves block:
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER));
+ // Top layer - just a single leaves block:
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER));
h--;
- // One more layer is above the trunk, push the central leaves:
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER));
+ // One more layer is above the trunk, push the central leaves:
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER));
// Layers expanding in size, then collapsing again:
// LOGD("Generating %d layers of pine leaves, SameSizeMax = %d", NumLeavesLayers, SameSizeMax);
@@ -596,7 +610,7 @@ void GetPineTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise
break;
}
ASSERT((size_t)LayerSize < ARRAYCOUNT(BigOs));
- PushCoordBlocks(a_BlockX, h, a_BlockZ, a_OtherBlocks, BigOs[LayerSize].Coords, BigOs[LayerSize].Count, E_BLOCK_LEAVES, E_META_NEWLEAVES_CONIFER);
+ PushCoordBlocks(a_BlockX, h, a_BlockZ, a_OtherBlocks, BigOs[LayerSize].Coords, BigOs[LayerSize].Count, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
h--;
}
}
@@ -623,7 +637,7 @@ void GetSwampTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Nois
for (int i = 0; i < Height; i++)
{
- a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_APPLE));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_APPLE));
}
int hei = a_BlockY + Height - 2;
@@ -633,17 +647,17 @@ void GetSwampTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Nois
// The lower two leaves layers are BigO3 with log in the middle and possibly corners:
for (int i = 0; i < 2; i++)
{
- PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
- PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
+ PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
+ PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
hei++;
} // for i - 2*
// The upper two leaves layers are BigO2 with leaves in the middle and possibly corners:
for (int i = 0; i < 2; i++)
{
- PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
- PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE));
+ PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
+ PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_APPLE));
hei++;
} // for i - 2*
}
@@ -657,15 +671,15 @@ void GetAppleBushImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Nois
a_OtherBlocks.reserve(3 + ARRAYCOUNT(BigO2) + ARRAYCOUNT(BigO1));
int hei = a_BlockY;
- a_LogBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_JUNGLE));
- PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LOG, E_META_LOG_JUNGLE));
+ PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
hei++;
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE));
- PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_APPLE));
+ PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
hei++;
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_APPLE));
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_APPLE));
}
@@ -709,10 +723,10 @@ void GetLargeJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise &
for (int i = 0; i < Height; i++)
{
- a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_JUNGLE));
- a_LogBlocks.push_back(sSetBlock(a_BlockX + 1, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_JUNGLE));
- a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ + 1, E_BLOCK_LOG, E_META_NEWLOG_JUNGLE));
- a_LogBlocks.push_back(sSetBlock(a_BlockX + 1, a_BlockY + i, a_BlockZ + 1, E_BLOCK_LOG, E_META_NEWLOG_JUNGLE));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_JUNGLE));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX + 1, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_JUNGLE));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ + 1, E_BLOCK_LOG, E_META_LOG_JUNGLE));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX + 1, a_BlockY + i, a_BlockZ + 1, E_BLOCK_LOG, E_META_LOG_JUNGLE));
}
int hei = a_BlockY + Height - 2;
@@ -722,15 +736,15 @@ void GetLargeJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise &
// The lower two leaves layers are BigO4 with log in the middle and possibly corners:
for (int i = 0; i < 2; i++)
{
- PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO4, ARRAYCOUNT(BigO4), E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE);
- PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE);
+ PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO4, ARRAYCOUNT(BigO4), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE);
+ PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE);
hei++;
} // for i - 2*
// The top leaves layer is a BigO3 with leaves in the middle and possibly corners:
- PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE);
- PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE);
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE));
+ PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE);
+ PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE));
}
@@ -753,16 +767,16 @@ void GetSmallJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise &
a_LogBlocks.reserve(Height);
a_OtherBlocks.reserve(
- 2 * ARRAYCOUNT(BigO3) + // O3 layer, 2x
- 2 * ARRAYCOUNT(BigO2) + // O2 layer, 2x
- ARRAYCOUNT(BigO1) + 1 + // Plus on the top
- Height * ARRAYCOUNT(Vines) + // Vines
+ 2 * ARRAYCOUNT(BigO3) + // O3 layer, 2x
+ 2 * ARRAYCOUNT(BigO2) + // O2 layer, 2x
+ ARRAYCOUNT(BigO1) + 1 + // Plus on the top
+ Height * ARRAYCOUNT(Vines) + // Vines
50 // some safety
);
for (int i = 0; i < Height; i++)
{
- a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_NEWLOG_JUNGLE));
+ a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_JUNGLE));
}
int hei = a_BlockY + Height - 3;
@@ -772,22 +786,22 @@ void GetSmallJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise &
// The lower two leaves layers are BigO3 with log in the middle and possibly corners:
for (int i = 0; i < 2; i++)
{
- PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE);
- PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE);
+ PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE);
+ PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE);
hei++;
} // for i - 2*
// Two layers of BigO2 leaves, possibly with corners:
for (int i = 0; i < 1; i++)
{
- PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE);
- PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE);
+ PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE);
+ PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE);
hei++;
} // for i - 2*
// Top plus, all leaves:
- PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE);
- a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_NEWLEAVES_JUNGLE));
+ PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE);
+ a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_JUNGLE));
}
diff --git a/src/Generating/Trees.h b/src/Generating/Trees.h
index 00f343a3d..1f6ac4dff 100644
--- a/src/Generating/Trees.h
+++ b/src/Generating/Trees.h
@@ -70,7 +70,7 @@ void GetAcaciaTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noi
void GetDarkoakTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
/// Generates an image of a random large birch tree
-void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks,sSetBlockVector & a_OtherBlocks);
+void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
/// Generates an image of a random conifer tree
void GetConiferTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
diff --git a/src/Generating/UnderwaterBaseGen.cpp b/src/Generating/UnderwaterBaseGen.cpp
new file mode 100644
index 000000000..9278ea546
--- /dev/null
+++ b/src/Generating/UnderwaterBaseGen.cpp
@@ -0,0 +1,143 @@
+
+// UnderwaterBaseGen.cpp
+
+// Implements the cUnderwaterBaseGen class representing the underwater base generator
+
+#include "Globals.h"
+#include "UnderwaterBaseGen.h"
+#include "Prefabs/UnderwaterBasePrefabs.h"
+#include "PieceGenerator.h"
+
+
+
+
+
+static cPrefabPiecePool g_UnderwaterBase(g_UnderwaterBasePrefabs, g_UnderwaterBasePrefabsCount, g_UnderwaterBaseStartingPrefabs, g_UnderwaterBaseStartingPrefabsCount);
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cUnderwaterBaseGen::cUnderwaterBase:
+
+class cUnderwaterBaseGen::cUnderwaterBase :
+ public cGridStructGen::cStructure
+{
+ typedef cGridStructGen::cStructure super;
+
+public:
+ cUnderwaterBase(
+ int a_Seed,
+ int a_GridX, int a_GridZ,
+ int a_OriginX, int a_OriginZ,
+ int a_MaxDepth,
+ int a_MaxSize
+ ) :
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
+ m_Seed(a_Seed),
+ m_Noise(a_Seed),
+ m_MaxSize(a_MaxSize),
+ m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize)
+ {
+ // Generate the pieces for this base:
+ cBFSPieceGenerator pg(g_UnderwaterBase, a_Seed);
+ pg.PlacePieces(a_OriginX, 50, a_OriginZ, a_MaxDepth, m_Pieces);
+ if (m_Pieces.empty())
+ {
+ return;
+ }
+ }
+
+ ~cUnderwaterBase()
+ {
+ cPieceGenerator::FreePieces(m_Pieces);
+ }
+
+protected:
+ /** Seed for the random functions */
+ int m_Seed;
+
+ /** The noise used as a pseudo-random generator */
+ cNoise m_Noise;
+
+ /** Maximum size, in X/Z blocks, of the village (radius from the origin) */
+ int m_MaxSize;
+
+ /** Borders of the vilalge - no item may reach out of this cuboid. */
+ cCuboid m_Borders;
+
+ /** The village pieces, placed by the generator. */
+ cPlacedPieces m_Pieces;
+
+
+ // cGridStructGen::cStructure overrides:
+ virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override
+ {
+ for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
+ {
+ cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece());
+ Prefab.Draw(a_Chunk, *itr);
+ } // for itr - m_PlacedPieces[]
+ }
+} ;
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cUnderwaterBaseGen:
+
+
+
+
+
+cUnderwaterBaseGen::cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen) :
+ super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100),
+ m_Noise(a_Seed + 1000),
+ m_MaxDepth(a_MaxDepth),
+ m_MaxSize(a_MaxSize),
+ m_BiomeGen(a_BiomeGen)
+{
+}
+
+
+
+
+
+cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
+{
+ // Generate the biomes for the chunk surrounding the origin:
+ int ChunkX, ChunkZ;
+ cChunkDef::BlockToChunk(a_OriginX, a_OriginZ, ChunkX, ChunkZ);
+ cChunkDef::BiomeMap Biomes;
+ m_BiomeGen.GenBiomes(ChunkX, ChunkZ, Biomes);
+
+ // Check if all the biomes are ocean:
+ // If just one is not, no base is created, because it's likely that an unfriendly biome is too close
+ for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++)
+ {
+ switch (Biomes[i])
+ {
+ case biOcean:
+ case biDeepOcean:
+ {
+ // These biomes allow underwater bases
+ break;
+ }
+ default:
+ {
+ // base-unfriendly biome, bail out with zero structure:
+ return cStructurePtr();
+ }
+ } // switch (Biomes[i])
+ } // for i - Biomes[]
+
+ // Create a base based on the chosen prefabs:
+ return cStructurePtr(new cUnderwaterBase(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize));
+}
+
+
+
+
diff --git a/src/Generating/UnderwaterBaseGen.h b/src/Generating/UnderwaterBaseGen.h
new file mode 100644
index 000000000..d6267b602
--- /dev/null
+++ b/src/Generating/UnderwaterBaseGen.h
@@ -0,0 +1,50 @@
+
+// UnderwaterBaseGen.h
+
+// Declares the cUnderwaterBaseGen class representing the underwater base generator
+
+
+
+
+
+#pragma once
+
+#include "GridStructGen.h"
+#include "PrefabPiecePool.h"
+
+
+
+
+
+class cUnderwaterBaseGen :
+ public cGridStructGen
+{
+ typedef cGridStructGen super;
+
+public:
+ cUnderwaterBaseGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, cBiomeGen & a_BiomeGen);
+
+protected:
+ class cUnderwaterBase; // fwd: UnderwaterBaseGen.cpp
+
+
+ /** The noise used for generating random numbers */
+ cNoise m_Noise;
+
+ /** Maximum depth of the generator tree*/
+ int m_MaxDepth;
+
+ /** Maximum size, in X/Z blocks, of the base (radius from the origin) */
+ int m_MaxSize;
+
+ /** The underlying biome generator that defines whether the base is created or not */
+ cBiomeGen & m_BiomeGen;
+
+
+ // cGridStructGen overrides:
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
+} ;
+
+
+
+
diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp
new file mode 100644
index 000000000..cade923c9
--- /dev/null
+++ b/src/Generating/VillageGen.cpp
@@ -0,0 +1,444 @@
+
+// VillageGen.cpp
+
+// Implements the cVillageGen class representing the village generator
+
+#include "Globals.h"
+#include "VillageGen.h"
+#include "Prefabs/AlchemistVillagePrefabs.h"
+#include "Prefabs/JapaneseVillagePrefabs.h"
+#include "Prefabs/PlainsVillagePrefabs.h"
+#include "Prefabs/SandVillagePrefabs.h"
+#include "Prefabs/SandFlatRoofVillagePrefabs.h"
+#include "PieceGenerator.h"
+
+
+
+
+
+/*
+How village generating works:
+By descending from a cGridStructGen, a semi-random grid is generated. A village may be generated for each of
+the grid's cells. Each cell checks the biomes in an entire chunk around it, only generating a village if all
+biomes are village-friendly. If yes, the entire village structure is built for that cell. If not, the cell
+is left village-less.
+
+A village is generated using the regular BFS piece generator. The well piece is used as the starting piece,
+the roads and houses are then used as the following pieces. Only the houses are read from the prefabs,
+though, the roads are generated by code and their content is ignored. A special subclass of the cPiecePool
+class is used, so that the roads connect to each other and to the well only in predefined manners.
+
+The well has connectors of type "2". The houses have connectors of type "-1". The roads have connectors of
+both types' opposites, type "-2" at the far ends and type "1" on the long edges. Additionally, there are
+type "2" connectors along the long edges of the roads as well, so that the roads create T junctions.
+
+When the village is about to be drawn into a chunk, it queries the heights for each piece intersecting the
+chunk. The pieces are shifted so that their pivot points lie on the surface, and the roads are drawn
+directly by turning the surface blocks into gravel / sandstone.
+
+The village prefabs are stored in global piecepools (one pool per village type). In order to support
+per-village density setting, the cVillage class itself implements the cPiecePool interface, relaying the
+calls to the underlying cVillagePiecePool, after processing the density check.
+*/
+
+class cVillagePiecePool :
+ public cPrefabPiecePool
+{
+ typedef cPrefabPiecePool super;
+public:
+ cVillagePiecePool(
+ const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs,
+ const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs
+ ) :
+ super(a_PieceDefs, a_NumPieceDefs, a_StartingPieceDefs, a_NumStartingPieceDefs)
+ {
+ // Add the road pieces:
+ for (int len = 27; len < 60; len += 12)
+ {
+ cBlockArea BA;
+ BA.Create(len, 1, 3, cBlockArea::baTypes | cBlockArea::baMetas);
+ BA.Fill(cBlockArea::baTypes | cBlockArea::baMetas, E_BLOCK_GRAVEL, 0);
+ cPrefab * RoadPiece = new cPrefab(BA, 1);
+ RoadPiece->AddConnector(0, 0, 1, BLOCK_FACE_XM, -2);
+ RoadPiece->AddConnector(len - 1, 0, 1, BLOCK_FACE_XP, -2);
+ RoadPiece->SetDefaultWeight(100);
+
+ // Add the road connectors:
+ for (int x = 1; x < len; x += 12)
+ {
+ RoadPiece->AddConnector(x, 0, 0, BLOCK_FACE_ZM, 2);
+ RoadPiece->AddConnector(x, 0, 2, BLOCK_FACE_ZP, 2);
+ }
+
+ // Add the buildings connectors:
+ for (int x = 7; x < len; x += 12)
+ {
+ RoadPiece->AddConnector(x, 0, 0, BLOCK_FACE_ZM, 1);
+ RoadPiece->AddConnector(x, 0, 2, BLOCK_FACE_ZP, 1);
+ }
+ m_AllPieces.push_back(RoadPiece);
+ m_PiecesByConnector[-2].push_back(RoadPiece);
+ m_PiecesByConnector[1].push_back(RoadPiece);
+ m_PiecesByConnector[2].push_back(RoadPiece);
+ } // for len - roads of varying length
+ }
+
+
+ // cPrefabPiecePool overrides:
+ virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override
+ {
+ // Roads cannot branch T-wise (appending -2 connector to a +2 connector on a 1-high piece):
+ if ((a_ExistingConnector.m_Type == 2) && (a_PlacedPiece.GetDepth() > 0) && (a_PlacedPiece.GetPiece().GetSize().y == 1))
+ {
+ return 0;
+ }
+
+ return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector);
+ }
+};
+
+
+
+
+
+class cVillageGen::cVillage :
+ public cGridStructGen::cStructure,
+ protected cPiecePool
+{
+ typedef cGridStructGen::cStructure super;
+
+public:
+ cVillage(
+ int a_Seed,
+ int a_GridX, int a_GridZ,
+ int a_OriginX, int a_OriginZ,
+ int a_MaxRoadDepth,
+ int a_MaxSize,
+ int a_Density,
+ cPiecePool & a_Prefabs,
+ cTerrainHeightGen & a_HeightGen,
+ BLOCKTYPE a_RoadBlock,
+ BLOCKTYPE a_WaterRoadBlock
+ ) :
+ super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
+ m_Seed(a_Seed),
+ m_Noise(a_Seed),
+ m_MaxSize(a_MaxSize),
+ m_Density(a_Density),
+ m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize),
+ m_Prefabs(a_Prefabs),
+ m_HeightGen(a_HeightGen),
+ m_RoadBlock(a_RoadBlock),
+ m_WaterRoadBlock(a_WaterRoadBlock)
+ {
+ // Generate the pieces for this village; don't care about the Y coord:
+ cBFSPieceGenerator pg(*this, a_Seed);
+ pg.PlacePieces(a_OriginX, 0, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces);
+ if (m_Pieces.empty())
+ {
+ return;
+ }
+
+ // If the central piece should be moved to ground, move it, and
+ // check all of its dependents and move those that are strictly connector-driven based on its new Y coord:
+ if (((cPrefab &)m_Pieces[0]->GetPiece()).ShouldMoveToGround())
+ {
+ int OrigPosY = m_Pieces[0]->GetCoords().y;
+ PlacePieceOnGround(*m_Pieces[0]);
+ int NewPosY = m_Pieces[0]->GetCoords().y;
+ MoveAllDescendants(m_Pieces, 0, NewPosY - OrigPosY);
+ }
+ }
+
+ ~cVillage()
+ {
+ cPieceGenerator::FreePieces(m_Pieces);
+ }
+
+protected:
+ /** Seed for the random functions */
+ int m_Seed;
+
+ /** The noise used as a pseudo-random generator */
+ cNoise m_Noise;
+
+ /** Maximum size, in X/Z blocks, of the village (radius from the origin) */
+ int m_MaxSize;
+
+ /** The density for this village. Used to refrain from populating all house connectors. Range [0, 100] */
+ int m_Density;
+
+ /** Borders of the vilalge - no item may reach out of this cuboid. */
+ cCuboid m_Borders;
+
+ /** Prefabs to use for buildings */
+ cPiecePool & m_Prefabs;
+
+ /** The underlying height generator, used for placing the structures on top of the terrain. */
+ cTerrainHeightGen & m_HeightGen;
+
+ /** The village pieces, placed by the generator. */
+ cPlacedPieces m_Pieces;
+
+ /** The block to use for the roads. */
+ BLOCKTYPE m_RoadBlock;
+
+ /** The block used for the roads if the road is on water. */
+ BLOCKTYPE m_WaterRoadBlock;
+
+
+ // cGridStructGen::cStructure overrides:
+ virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override
+ {
+ // Iterate over all items
+ // Each intersecting prefab is placed on ground, then drawn
+ // Each intersecting road is drawn by replacing top soil blocks with gravel / sandstone blocks
+ cChunkDef::HeightMap HeightMap; // Heightmap for this chunk, used by roads
+ m_HeightGen.GenHeightMap(a_Chunk.GetChunkX(), a_Chunk.GetChunkZ(), HeightMap);
+ for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
+ {
+ cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece());
+ if ((*itr)->GetPiece().GetSize().y == 1)
+ {
+ // It's a road, special handling (change top terrain blocks to m_RoadBlock)
+ DrawRoad(a_Chunk, **itr, HeightMap);
+ continue;
+ }
+ if (Prefab.ShouldMoveToGround() && !(*itr)->HasBeenMovedToGround())
+ {
+ PlacePieceOnGround(**itr);
+ }
+ Prefab.Draw(a_Chunk, *itr);
+ } // for itr - m_PlacedPieces[]
+ }
+
+
+ /** Adjusts the Y coord of the given piece so that the piece is on the ground.
+ Ground level is assumed to be represented by the first connector in the piece. */
+ void PlacePieceOnGround(cPlacedPiece & a_Piece)
+ {
+ cPiece::cConnector FirstConnector = a_Piece.GetRotatedConnector(0);
+ int ChunkX, ChunkZ;
+ int BlockX = FirstConnector.m_Pos.x;
+ int BlockZ = FirstConnector.m_Pos.z;
+ int BlockY;
+ cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
+ cChunkDef::HeightMap HeightMap;
+ m_HeightGen.GenHeightMap(ChunkX, ChunkZ, HeightMap);
+ int TerrainHeight = cChunkDef::GetHeight(HeightMap, BlockX, BlockZ);
+ a_Piece.MoveToGroundBy(TerrainHeight - FirstConnector.m_Pos.y + 1);
+ }
+
+
+ /** Draws the road into the chunk.
+ The heightmap is not queried from the heightgen, but is given via parameter, so that it may be queried just
+ once for all roads in a chunk. */
+ void DrawRoad(cChunkDesc & a_Chunk, cPlacedPiece & a_Road, cChunkDef::HeightMap & a_HeightMap)
+ {
+ cCuboid RoadCoords = a_Road.GetHitBox();
+ RoadCoords.Sort();
+ int MinX = std::max(RoadCoords.p1.x - a_Chunk.GetChunkX() * cChunkDef::Width, 0);
+ int MaxX = std::min(RoadCoords.p2.x - a_Chunk.GetChunkX() * cChunkDef::Width, cChunkDef::Width - 1);
+ int MinZ = std::max(RoadCoords.p1.z - a_Chunk.GetChunkZ() * cChunkDef::Width, 0);
+ int MaxZ = std::min(RoadCoords.p2.z - a_Chunk.GetChunkZ() * cChunkDef::Width, cChunkDef::Width - 1);
+ for (int z = MinZ; z <= MaxZ; z++)
+ {
+ for (int x = MinX; x <= MaxX; x++)
+ {
+ if (IsBlockWater(a_Chunk.GetBlockType(x, cChunkDef::GetHeight(a_HeightMap, x, z), z)))
+ {
+ a_Chunk.SetBlockType(x, cChunkDef::GetHeight(a_HeightMap, x, z), z, m_WaterRoadBlock);
+ }
+ else
+ {
+ a_Chunk.SetBlockType(x, cChunkDef::GetHeight(a_HeightMap, x, z), z, m_RoadBlock);
+ }
+ }
+ }
+ }
+
+
+ // cPiecePool overrides:
+ virtual cPieces GetPiecesWithConnector(int a_ConnectorType)
+ {
+ return m_Prefabs.GetPiecesWithConnector(a_ConnectorType);
+ }
+
+
+ virtual cPieces GetStartingPieces(void)
+ {
+ return m_Prefabs.GetStartingPieces();
+ }
+
+
+ virtual int GetPieceWeight(
+ const cPlacedPiece & a_PlacedPiece,
+ const cPiece::cConnector & a_ExistingConnector,
+ const cPiece & a_NewPiece
+ ) override
+ {
+ // Check against the density:
+ if (a_ExistingConnector.m_Type == 1)
+ {
+ const Vector3i & Coords = a_PlacedPiece.GetRotatedConnector(a_ExistingConnector).m_Pos;
+ int rnd = (m_Noise.IntNoise3DInt(Coords.x, Coords.y, Coords.z) / 7) % 100;
+ if (rnd > m_Density)
+ {
+ return 0;
+ }
+ }
+
+ // Density check passed, relay to m_Prefabs:
+ return m_Prefabs.GetPieceWeight(a_PlacedPiece, a_ExistingConnector, a_NewPiece);
+ }
+
+
+ virtual int GetStartingPieceWeight(const cPiece & a_NewPiece) override
+ {
+ return m_Prefabs.GetStartingPieceWeight(a_NewPiece);
+ }
+
+
+ virtual void PiecePlaced(const cPiece & a_Piece) override
+ {
+ m_Prefabs.PiecePlaced(a_Piece);
+ }
+
+
+ virtual void Reset(void) override
+ {
+ m_Prefabs.Reset();
+ }
+
+
+ void MoveAllDescendants(cPlacedPieces & a_PlacedPieces, size_t a_Pivot, int a_HeightDifference)
+ {
+ size_t num = a_PlacedPieces.size();
+ cPlacedPiece * Pivot = a_PlacedPieces[a_Pivot];
+ for (size_t i = a_Pivot + 1; i < num; i++)
+ {
+ if (
+ (a_PlacedPieces[i]->GetParent() == Pivot) && // It is a direct dependant of the pivot
+ !((const cPrefab &)a_PlacedPieces[i]->GetPiece()).ShouldMoveToGround() // It attaches strictly by connectors
+ )
+ {
+ a_PlacedPieces[i]->MoveToGroundBy(a_HeightDifference);
+ MoveAllDescendants(a_PlacedPieces, i, a_HeightDifference);
+ }
+ } // for i - a_PlacedPieces[]
+ }
+} ;
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cVillageGen:
+
+static cVillagePiecePool g_SandVillage(g_SandVillagePrefabs, g_SandVillagePrefabsCount, g_SandVillageStartingPrefabs, g_SandVillageStartingPrefabsCount);
+static cVillagePiecePool g_SandFlatRoofVillage(g_SandFlatRoofVillagePrefabs, g_SandFlatRoofVillagePrefabsCount, g_SandFlatRoofVillageStartingPrefabs, g_SandFlatRoofVillageStartingPrefabsCount);
+static cVillagePiecePool g_AlchemistVillage(g_AlchemistVillagePrefabs, g_AlchemistVillagePrefabsCount, g_AlchemistVillageStartingPrefabs, g_AlchemistVillageStartingPrefabsCount);
+static cVillagePiecePool g_PlainsVillage(g_PlainsVillagePrefabs, g_PlainsVillagePrefabsCount, g_PlainsVillageStartingPrefabs, g_PlainsVillageStartingPrefabsCount);
+static cVillagePiecePool g_JapaneseVillage(g_JapaneseVillagePrefabs, g_JapaneseVillagePrefabsCount, g_JapaneseVillageStartingPrefabs, g_JapaneseVillageStartingPrefabsCount);
+
+static cVillagePiecePool * g_DesertVillagePools[] =
+{
+ &g_SandVillage,
+ &g_SandFlatRoofVillage,
+ &g_AlchemistVillage,
+} ;
+
+static cVillagePiecePool * g_PlainsVillagePools[] =
+{
+ &g_PlainsVillage,
+ &g_JapaneseVillage,
+} ;
+
+
+
+
+
+cVillageGen::cVillageGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen) :
+ super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 100),
+ m_Noise(a_Seed + 1000),
+ m_MaxDepth(a_MaxDepth),
+ m_MaxSize(a_MaxSize),
+ m_MinDensity(a_MinDensity),
+ m_MaxDensity(a_MaxDensity),
+ m_BiomeGen(a_BiomeGen),
+ m_HeightGen(a_HeightGen)
+{
+}
+
+
+
+
+
+cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
+{
+ // Generate the biomes for the chunk surrounding the origin:
+ int ChunkX, ChunkZ;
+ cChunkDef::BlockToChunk(a_OriginX, a_OriginZ, ChunkX, ChunkZ);
+ cChunkDef::BiomeMap Biomes;
+ m_BiomeGen.GenBiomes(ChunkX, ChunkZ, Biomes);
+
+ // Check if all the biomes are village-friendly:
+ // If just one is not, no village is created, because it's likely that an unfriendly biome is too close
+ cVillagePiecePool * VillagePrefabs = NULL;
+ BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL;
+ BLOCKTYPE WaterRoadBlock = E_BLOCK_PLANKS;
+ int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11;
+ cVillagePiecePool * PlainsVillage = g_PlainsVillagePools[rnd % ARRAYCOUNT(g_PlainsVillagePools)];
+ cVillagePiecePool * DesertVillage = g_DesertVillagePools[rnd % ARRAYCOUNT(g_DesertVillagePools)];
+ for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++)
+ {
+ switch (Biomes[i])
+ {
+ case biDesert:
+ case biDesertM:
+ {
+ // These biomes allow sand villages
+ VillagePrefabs = DesertVillage;
+ // RoadBlock = E_BLOCK_SANDSTONE;
+ break;
+ }
+ case biPlains:
+ case biSavanna:
+ case biSavannaM:
+ case biSunflowerPlains:
+ {
+ // These biomes allow plains-style villages
+ VillagePrefabs = PlainsVillage;
+ break;
+ }
+ default:
+ {
+ // Village-unfriendly biome, bail out with zero structure:
+ return cStructurePtr();
+ }
+ } // switch (Biomes[i])
+ } // for i - Biomes[]
+
+ // Choose density for the village, random between m_MinDensity and m_MaxDensity:
+ int Density;
+ if (m_MaxDensity > m_MinDensity)
+ {
+ Density = m_MinDensity + rnd % (m_MaxDensity - m_MinDensity);
+ }
+ else
+ {
+ Density = m_MinDensity;
+ }
+
+ // Create a village based on the chosen prefabs:
+ if (VillagePrefabs == NULL)
+ {
+ return cStructurePtr();
+ }
+ return cStructurePtr(new cVillage(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *VillagePrefabs, m_HeightGen, RoadBlock, WaterRoadBlock));
+}
+
+
+
+
diff --git a/src/Generating/VillageGen.h b/src/Generating/VillageGen.h
new file mode 100644
index 000000000..694ea2358
--- /dev/null
+++ b/src/Generating/VillageGen.h
@@ -0,0 +1,57 @@
+
+// VillageGen.h
+
+// Declares the cVillageGen class representing the village generator
+
+
+
+
+
+#pragma once
+
+#include "GridStructGen.h"
+#include "PrefabPiecePool.h"
+
+
+
+
+
+class cVillageGen :
+ public cGridStructGen
+{
+ typedef cGridStructGen super;
+public:
+ cVillageGen(int a_Seed, int a_GridSize, int a_MaxOffset, int a_MaxDepth, int a_MaxSize, int a_MinDensity, int a_MaxDensity, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen);
+
+protected:
+ class cVillage; // fwd: VillageGen.cpp
+
+ /** The noise used for generating random numbers */
+ cNoise m_Noise;
+
+ /** Maximum depth of the generator tree*/
+ int m_MaxDepth;
+
+ /** Maximum size, in X/Z blocks, of the village (radius from the origin) */
+ int m_MaxSize;
+
+ /** Minimum density - percentage of allowed house connections. Range [0, 100] */
+ int m_MinDensity;
+
+ /** Maximum density - percentage of allowed house connections. Range [0, 100] */
+ int m_MaxDensity;
+
+ /** The underlying biome generator that defines whether the village is created or not */
+ cBiomeGen & m_BiomeGen;
+
+ /** The underlying height generator, used to position the prefabs crossing chunk borders */
+ cTerrainHeightGen & m_HeightGen;
+
+
+ // cGridStructGen overrides:
+ virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
+} ;
+
+
+
+
diff --git a/src/Globals.h b/src/Globals.h
index 26a0d87a9..b35af9604 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -14,18 +14,18 @@
#pragma warning(disable:4481)
// Disable some warnings that we don't care about:
- #pragma warning(disable:4100) // Unreferenced formal parameter
-
- // Useful warnings from warning level 4:
- #pragma warning(3 : 4127) // Conditional expression is constant
- #pragma warning(3 : 4189) // Local variable is initialized but not referenced
- #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch
- #pragma warning(3 : 4310) // Cast truncates constant value
- #pragma warning(3 : 4389) // Signed/unsigned mismatch
- #pragma warning(3 : 4505) // Unreferenced local function has been removed
- #pragma warning(3 : 4701) // Potentially unitialized local variable used
- #pragma warning(3 : 4702) // Unreachable code
- #pragma warning(3 : 4706) // Assignment within conditional expression
+ #pragma warning(disable:4100) // Unreferenced formal parameter
+
+ // Useful warnings from warning level 4:
+ #pragma warning(3 : 4127) // Conditional expression is constant
+ #pragma warning(3 : 4189) // Local variable is initialized but not referenced
+ #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch
+ #pragma warning(3 : 4310) // Cast truncates constant value
+ #pragma warning(3 : 4389) // Signed/unsigned mismatch
+ #pragma warning(3 : 4505) // Unreferenced local function has been removed
+ #pragma warning(3 : 4701) // Potentially unitialized local variable used
+ #pragma warning(3 : 4702) // Unreachable code
+ #pragma warning(3 : 4706) // Assignment within conditional expression
// Disabling this warning, because we know what we're doing when we're doing this:
#pragma warning(disable: 4355) // 'this' used in initializer list
@@ -34,7 +34,7 @@
#pragma warning(disable: 4512) // 'class': assignment operator could not be generated - reported for each class that has a reference-type member
// 2014_01_06 xoft: Disabled this warning because MSVC is stupid and reports it in obviously wrong places
- // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data
+ // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data
#define OBSOLETE __declspec(deprecated)
@@ -58,8 +58,8 @@
// override is part of c++11
#if __cplusplus < 201103L
- #define override
- #endif
+ #define override
+ #endif
#define OBSOLETE __attribute__((deprecated))
@@ -71,9 +71,24 @@
#define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex)))
- #define SIZE_T_FMT "%zu"
- #define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
- #define SIZE_T_FMT_HEX "%zx"
+ #if defined(_WIN32)
+ // We're compiling on MinGW, which uses an old MSVCRT library that has no support for size_t printfing.
+ // We need direct size formats:
+ #if defined(_WIN64)
+ #define SIZE_T_FMT "%I64u"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "I64u"
+ #define SIZE_T_FMT_HEX "%I64x"
+ #else
+ #define SIZE_T_FMT "%u"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "u"
+ #define SIZE_T_FMT_HEX "%x"
+ #endif
+ #else
+ // We're compiling on Linux, so we can use libc's size_t printf format:
+ #define SIZE_T_FMT "%zu"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
+ #define SIZE_T_FMT_HEX "%zx"
+ #endif
#define NORETURN __attribute((__noreturn__))
@@ -130,7 +145,7 @@ class SizeChecker;
template <typename T, size_t Size>
class SizeChecker<T, Size, true>
{
- T v;
+ T v;
};
template class SizeChecker<Int64, 8>;
@@ -225,16 +240,28 @@ template class SizeChecker<UInt16, 2>;
+#ifndef TEST_GLOBALS
+ // Common headers (part 1, without macros):
+ #include "StringUtils.h"
+ #include "OSSupport/Sleep.h"
+ #include "OSSupport/CriticalSection.h"
+ #include "OSSupport/Semaphore.h"
+ #include "OSSupport/Event.h"
+ #include "OSSupport/Thread.h"
+ #include "OSSupport/File.h"
+ #include "MCLogger.h"
+#else
+ // Logging functions
+void inline LOGERROR(const char* a_Format, ...) FORMATSTRING(1, 2);
-// Common headers (part 1, without macros):
-#include "StringUtils.h"
-#include "OSSupport/Sleep.h"
-#include "OSSupport/CriticalSection.h"
-#include "OSSupport/Semaphore.h"
-#include "OSSupport/Event.h"
-#include "OSSupport/Thread.h"
-#include "OSSupport/File.h"
-#include "MCLogger.h"
+void inline LOGERROR(const char* a_Format, ...)
+{
+ va_list argList;
+ va_start(argList, a_Format);
+ vprintf(a_Format, argList);
+ va_end(argList);
+}
+#endif
@@ -245,26 +272,74 @@ template class SizeChecker<UInt16, 2>;
/// Evaluates to the number of elements in an array (compile-time!)
#define ARRAYCOUNT(X) (sizeof(X) / sizeof(*(X)))
-/// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)" )
+/// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)")
#define KiB * 1024
#define MiB * 1024 * 1024
/// Faster than (int)floorf((float)x / (float)div)
-#define FAST_FLOOR_DIV( x, div ) (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div))
+#define FAST_FLOOR_DIV( x, div) (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div))
// Own version of assert() that writes failed assertions to the log for review
-#ifdef _DEBUG
- #define ASSERT( x ) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), assert(0), 0 ) )
+#ifdef TEST_GLOBALS
+
+ class cAssertFailure
+ {
+ };
+
+ #ifdef _WIN32
+ #if (defined(_MSC_VER) && defined(_DEBUG))
+ #define DBG_BREAK _CrtDbgBreak()
+ #else
+ #define DBG_BREAK
+ #endif
+ #define REPORT_ERROR(FMT, ...) \
+ { \
+ AString msg = Printf(FMT, __VA_ARGS__); \
+ puts(msg.c_str()); \
+ fflush(stdout); \
+ OutputDebugStringA(msg.c_str()); \
+ DBG_BREAK; \
+ }
+ #else
+ #define REPORT_ERROR(FMT, ...) \
+ { \
+ AString msg = Printf(FMT, __VA_ARGS__); \
+ puts(msg.c_str()); \
+ fflush(stdout); \
+ }
+ #endif
+ #define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0)
+ #define testassert(x) do { if (!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0)
+ #define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } REPORT_ERROR("Test failure: assert didn't fire for %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } while (0)
+
#else
- #define ASSERT(x) ((void)(x))
+ #ifdef _DEBUG
+ #define ASSERT( x) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), assert(0), 0))
+ #else
+ #define ASSERT(x) ((void)(x))
+ #endif
#endif
// Pretty much the same as ASSERT() but stays in Release builds
-#define VERIFY( x ) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), exit(1), 0 ) )
+#define VERIFY( x) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__), exit(1), 0))
// Same as assert but in all Self test builds
#ifdef SELF_TEST
-#define assert_test(x) ( !!(x) || (assert(!#x), exit(1), 0))
+ #define assert_test(x) ( !!(x) || (assert(!#x), exit(1), 0))
+#endif
+
+// Allow both Older versions of MSVC and newer versions of everything use a shared_ptr:
+// Note that we cannot typedef, because C++ doesn't allow (partial) templates to be typedeffed.
+#if (defined(_MSC_VER) && (_MSC_VER < 1600))
+ // MSVC before 2010 doesn't have std::shared_ptr, but has std::tr1::shared_ptr, defined in <memory> included earlier
+ #define SharedPtr std::tr1::shared_ptr
+#elif (defined(_MSC_VER) || (__cplusplus >= 201103L))
+ // C++11 has std::shared_ptr in <memory>, included earlier
+ #define SharedPtr std::shared_ptr
+#else
+ // C++03 has std::tr1::shared_ptr in <tr1/memory>
+ #include <tr1/memory>
+ #define SharedPtr std::tr1::shared_ptr
#endif
@@ -296,7 +371,7 @@ T Clamp(T a_Value, T a_Min, T a_Max)
#ifndef TOLUA_TEMPLATE_BIND
-#define TOLUA_TEMPLATE_BIND(x)
+ #define TOLUA_TEMPLATE_BIND(x)
#endif
@@ -308,6 +383,5 @@ T Clamp(T a_Value, T a_Min, T a_Max)
#include "BiomeDef.h"
#include "BlockID.h"
#include "BlockInfo.h"
-#include "Entities/Effects.h"
diff --git a/src/Group.cpp b/src/Group.cpp
index 725740905..def585618 100644
--- a/src/Group.cpp
+++ b/src/Group.cpp
@@ -7,7 +7,7 @@
-void cGroup::AddCommand( const AString & a_Command )
+void cGroup::AddCommand( const AString & a_Command)
{
m_Commands[ a_Command ] = true;
}
@@ -16,7 +16,7 @@ void cGroup::AddCommand( const AString & a_Command )
-void cGroup::AddPermission( const AString & a_Permission )
+void cGroup::AddPermission( const AString & a_Permission)
{
m_Permissions[ a_Permission ] = true;
}
@@ -25,10 +25,10 @@ void cGroup::AddPermission( const AString & a_Permission )
-void cGroup::InheritFrom( cGroup* a_Group )
+void cGroup::InheritFrom( cGroup* a_Group)
{
- m_Inherits.remove( a_Group );
- m_Inherits.push_back( a_Group );
+ m_Inherits.remove( a_Group);
+ m_Inherits.push_back( a_Group);
}
diff --git a/src/Group.h b/src/Group.h
index 47088d50d..5816f8a06 100644
--- a/src/Group.h
+++ b/src/Group.h
@@ -5,18 +5,22 @@
-class cGroup // tolua_export
-{ // tolua_export
-public: // tolua_export
+// tolua_begin
+class cGroup
+{
+public:
+ // tolua_end
cGroup() {}
~cGroup() {}
- void SetName( const AString & a_Name ) { m_Name = a_Name; } // tolua_export
- const AString & GetName() const { return m_Name; } // tolua_export
- void SetColor( const AString & a_Color ) { m_Color = a_Color; } // tolua_export
- void AddCommand( const AString & a_Command ); // tolua_export
- void AddPermission( const AString & a_Permission ); // tolua_export
- void InheritFrom( cGroup* a_Group ); // tolua_export
+ // tolua_begin
+ void SetName( const AString & a_Name) { m_Name = a_Name; }
+ const AString & GetName() const { return m_Name; }
+ void SetColor( const AString & a_Color) { m_Color = a_Color; }
+ void AddCommand( const AString & a_Command);
+ void AddPermission( const AString & a_Permission);
+ void InheritFrom( cGroup* a_Group);
+ // tolua_end
typedef std::map< AString, bool > PermissionMap;
const PermissionMap & GetPermissions() const { return m_Permissions; }
@@ -26,7 +30,7 @@ public: // tolua_export
typedef std::map< AString, bool > CommandMap;
const CommandMap & GetCommands() const { return m_Commands; }
- const AString & GetColor() const { return m_Color; } // tolua_export
+ const AString & GetColor() const { return m_Color; } // tolua_export
typedef std::list< cGroup* > GroupList;
const GroupList & GetInherits() const { return m_Inherits; }
@@ -37,4 +41,4 @@ private:
PermissionMap m_Permissions;
CommandMap m_Commands;
GroupList m_Inherits;
-};// tolua_export
+}; // tolua_export
diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp
index 33b601e82..32c2f1c97 100644
--- a/src/GroupManager.cpp
+++ b/src/GroupManager.cpp
@@ -27,13 +27,15 @@ struct cGroupManager::sGroupManagerState
cGroupManager::~cGroupManager()
{
- for( GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr )
+ for (GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr)
{
delete itr->second;
+ itr->second = NULL;
}
m_pState->Groups.clear();
delete m_pState;
+ m_pState = NULL;
}
@@ -41,12 +43,18 @@ cGroupManager::~cGroupManager()
cGroupManager::cGroupManager()
- : m_pState( new sGroupManagerState )
+ : m_pState( new sGroupManagerState)
{
LOGD("-- Loading Groups --");
- LoadGroups();
- CheckUsers();
+ if (!LoadGroups())
+ {
+ LOGWARNING("ERROR: Groups could not load!");
+ }
+ if (!CheckUsers())
+ {
+ LOGWARNING("ERROR: User file could not be found!");
+ }
LOGD("-- Groups Successfully Loaded --");
}
@@ -70,39 +78,42 @@ void cGroupManager::GenerateDefaultUsersIni(cIniFile & a_IniFile)
-void cGroupManager::CheckUsers(void)
+bool cGroupManager::CheckUsers()
{
cIniFile IniFile;
if (!IniFile.ReadFile("users.ini"))
{
GenerateDefaultUsersIni(IniFile);
- return;
+ return true;
}
- unsigned int NumKeys = IniFile.GetNumKeys();
- for (size_t i = 0; i < NumKeys; i++)
+ int NumKeys = IniFile.GetNumKeys();
+ for (int i = 0; i < NumKeys; i++)
{
- AString Player = IniFile.GetKeyName( i );
+ AString Player = IniFile.GetKeyName(i);
AString Groups = IniFile.GetValue(Player, "Groups", "");
- if (!Groups.empty())
+ if (Groups.empty())
{
- AStringVector Split = StringSplit( Groups, "," );
- for( unsigned int i = 0; i < Split.size(); i++ )
+ continue;
+ }
+ AStringVector Split = StringSplitAndTrim(Groups, ",");
+ for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
+ {
+ if (!ExistsGroup(*itr))
{
- if (!ExistsGroup(Split[i]))
- {
- LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str());
- }
+ LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str());
}
- }
- }
+ } // for itr - Split[]
+ } // for i - ini file keys
+ // Always return true for now, just but we can handle writefile fails later.
+ return true;
}
-void cGroupManager::LoadGroups()
+bool cGroupManager::LoadGroups()
{
cIniFile IniFile;
if (!IniFile.ReadFile("groups.ini"))
@@ -114,7 +125,7 @@ void cGroupManager::LoadGroups()
IniFile.SetValue("Owner", "Permissions", "*", true);
IniFile.SetValue("Owner", "Color", "2", true);
- IniFile.SetValue("Moderator", "Permissions", "core.time,core.item,core.teleport,core.ban,core.unban,core.save-all,core.toggledownfall");
+ IniFile.SetValue("Moderator", "Permissions", "core.time, core.item, core.tpa, core.tpaccept, core.ban, core.unban, core.save-all, core.toggledownfall");
IniFile.SetValue("Moderator", "Color", "2", true);
IniFile.SetValue("Moderator", "Inherits", "Player", true);
@@ -122,27 +133,27 @@ void cGroupManager::LoadGroups()
IniFile.SetValue("Player", "Color", "f", true);
IniFile.SetValue("Player", "Inherits", "Default", true);
- IniFile.SetValue("Default", "Permissions", "core.help,core.plugins,core.spawn,core.worlds,core.back,core.motd,core.build,core.locate,core.viewdistance", true);
+ IniFile.SetValue("Default", "Permissions", "core.help, core.plugins, core.spawn, core.worlds, core.back, core.motd, core.build, core.locate, core.viewdistance", true);
IniFile.SetValue("Default", "Color", "f", true);
IniFile.WriteFile("groups.ini");
}
- unsigned int NumKeys = IniFile.GetNumKeys();
- for (size_t i = 0; i < NumKeys; i++)
+ int NumKeys = IniFile.GetNumKeys();
+ for (int i = 0; i < NumKeys; i++)
{
- AString KeyName = IniFile.GetKeyName( i );
- cGroup* Group = GetGroup( KeyName.c_str() );
+ AString KeyName = IniFile.GetKeyName(i);
+ cGroup * Group = GetGroup(KeyName.c_str());
- Group->ClearPermission(); // Needed in case the groups are reloaded.
+ Group->ClearPermission(); // Needed in case the groups are reloaded.
- LOGD("Loading group: %s", KeyName.c_str() );
+ LOGD("Loading group %s", KeyName.c_str());
Group->SetName(KeyName);
AString Color = IniFile.GetValue(KeyName, "Color", "-");
if ((Color != "-") && (Color.length() >= 1))
{
- Group->SetColor(cChatColor::Color + Color[0]);
+ Group->SetColor(cChatColor::Delimiter + Color[0]);
}
else
{
@@ -179,26 +190,28 @@ void cGroupManager::LoadGroups()
}
}
}
+ // Always return true, we can handle writefile fails later.
+ return true;
}
-bool cGroupManager::ExistsGroup( const AString & a_Name )
+bool cGroupManager::ExistsGroup( const AString & a_Name)
{
- GroupMap::iterator itr = m_pState->Groups.find( a_Name );
- return ( itr != m_pState->Groups.end() );
+ GroupMap::iterator itr = m_pState->Groups.find( a_Name);
+ return ( itr != m_pState->Groups.end());
}
-cGroup* cGroupManager::GetGroup( const AString & a_Name )
+cGroup* cGroupManager::GetGroup( const AString & a_Name)
{
- GroupMap::iterator itr = m_pState->Groups.find( a_Name );
- if( itr != m_pState->Groups.end() )
+ GroupMap::iterator itr = m_pState->Groups.find( a_Name);
+ if (itr != m_pState->Groups.end())
{
return itr->second;
}
diff --git a/src/GroupManager.h b/src/GroupManager.h
index 9e1689a76..d42b55c4a 100644
--- a/src/GroupManager.h
+++ b/src/GroupManager.h
@@ -16,8 +16,8 @@ class cGroupManager
public:
bool ExistsGroup(const AString & a_Name);
cGroup * GetGroup(const AString & a_Name);
- void LoadGroups(void);
- void CheckUsers(void);
+ bool LoadGroups();
+ bool CheckUsers();
/** Writes the default header to the specified ini file, and saves it as "users.ini". */
static void GenerateDefaultUsersIni(cIniFile & a_IniFile);
diff --git a/src/HTTPServer/CMakeLists.txt b/src/HTTPServer/CMakeLists.txt
index dc894368d..b0efc810d 100644
--- a/src/HTTPServer/CMakeLists.txt
+++ b/src/HTTPServer/CMakeLists.txt
@@ -4,9 +4,26 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ EnvelopeParser.cpp
+ HTTPConnection.cpp
+ HTTPFormParser.cpp
+ HTTPMessage.cpp
+ HTTPServer.cpp
+ MultipartParser.cpp
+ NameValueParser.cpp
+ SslHTTPConnection.cpp)
-add_library(HTTPServer ${SOURCE})
+SET (HDRS
+ EnvelopeParser.h
+ HTTPConnection.h
+ HTTPFormParser.h
+ HTTPMessage.h
+ HTTPServer.h
+ MultipartParser.h
+ NameValueParser.h
+ SslHTTPConnection.h)
+
+if(NOT MSVC)
+ add_library(HTTPServer ${SRCS} ${HDRS})
+endif()
diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp
index da4df0e34..b9c762e7c 100644
--- a/src/HTTPServer/HTTPConnection.cpp
+++ b/src/HTTPServer/HTTPConnection.cpp
@@ -26,7 +26,9 @@ cHTTPConnection::cHTTPConnection(cHTTPServer & a_HTTPServer) :
cHTTPConnection::~cHTTPConnection()
{
+ // LOGD("HTTP: Connection deleting: %p", this);
delete m_CurrentRequest;
+ m_CurrentRequest = NULL;
}
@@ -98,7 +100,7 @@ void cHTTPConnection::AwaitNextRequest(void)
{
case wcsRecvHeaders:
{
- // Nothing has been received yet, or a special response was given (SendStatusAndReason() or SendNeedAuth() )
+ // Nothing has been received yet, or a special response was given (SendStatusAndReason() or SendNeedAuth())
break;
}
@@ -144,7 +146,7 @@ void cHTTPConnection::Terminate(void)
-void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
+bool cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
{
switch (m_State)
{
@@ -162,12 +164,12 @@ void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
m_CurrentRequest = NULL;
m_State = wcsInvalid;
m_HTTPServer.CloseConnection(*this);
- return;
+ return true;
}
if (m_CurrentRequest->IsInHeaders())
{
// The request headers are not yet complete
- return;
+ return false;
}
// The request has finished parsing its headers successfully, notify of it:
@@ -183,13 +185,12 @@ void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
// Process the rest of the incoming data into the request body:
if (a_Size > BytesConsumed)
{
- DataReceived(a_Data + BytesConsumed, a_Size - BytesConsumed);
+ return cHTTPConnection::DataReceived(a_Data + BytesConsumed, a_Size - BytesConsumed);
}
else
{
- DataReceived("", 0); // If the request has zero body length, let it be processed right-away
+ return cHTTPConnection::DataReceived("", 0); // If the request has zero body length, let it be processed right-away
}
- break;
}
case wcsRecvBody:
@@ -209,7 +210,7 @@ void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
{
m_State = wcsInvalid;
m_HTTPServer.CloseConnection(*this);
- return;
+ return true;
}
delete m_CurrentRequest;
m_CurrentRequest = NULL;
@@ -223,6 +224,7 @@ void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
break;
}
}
+ return false;
}
diff --git a/src/HTTPServer/HTTPConnection.h b/src/HTTPServer/HTTPConnection.h
index fc11f1ba6..6ea8a1ae8 100644
--- a/src/HTTPServer/HTTPConnection.h
+++ b/src/HTTPServer/HTTPConnection.h
@@ -91,9 +91,15 @@ protected:
// cSocketThreads::cCallback overrides:
- virtual void DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client
- virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client
- virtual void SocketClosed (void) override; // The socket has been closed for any reason
+ /** Data is received from the client.
+ Returns true if the connection has been closed as the result of parsing the data. */
+ virtual bool DataReceived(const char * a_Data, size_t a_Size) override;
+
+ /** Data can be sent to client */
+ virtual void GetOutgoingData(AString & a_Data) override;
+
+ /** The socket has been closed for any reason */
+ virtual void SocketClosed(void) override;
} ;
typedef std::vector<cHTTPConnection *> cHTTPConnections;
diff --git a/src/HTTPServer/HTTPMessage.cpp b/src/HTTPServer/HTTPMessage.cpp
index 4a3611050..4226352e9 100644
--- a/src/HTTPServer/HTTPMessage.cpp
+++ b/src/HTTPServer/HTTPMessage.cpp
@@ -20,7 +20,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHTTPMessage:
cHTTPMessage::cHTTPMessage(eKind a_Kind) :
@@ -64,7 +64,7 @@ void cHTTPMessage::AddHeader(const AString & a_Key, const AString & a_Value)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHTTPRequest:
cHTTPRequest::cHTTPRequest(void) :
@@ -139,7 +139,7 @@ AString cHTTPRequest::GetBareURL(void) const
size_t cHTTPRequest::ParseRequestLine(const char * a_Data, size_t a_Size)
-{
+{
m_IncomingHeaderData.append(a_Data, a_Size);
size_t IdxEnd = m_IncomingHeaderData.size();
@@ -201,7 +201,7 @@ size_t cHTTPRequest::ParseRequestLine(const char * a_Data, size_t a_Size)
return AString::npos;
}
// Check that there's HTTP/version at the end
- if (strncmp(a_Data + URLEnd + 1, "HTTP/1.", 7) != 0)
+ if (strncmp(m_IncomingHeaderData.c_str() + URLEnd + 1, "HTTP/1.", 7) != 0)
{
m_IsValid = false;
return AString::npos;
@@ -248,7 +248,7 @@ void cHTTPRequest::OnHeaderLine(const AString & a_Key, const AString & a_Value)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHTTPResponse:
cHTTPResponse::cHTTPResponse(void) :
diff --git a/src/HTTPServer/HTTPMessage.h b/src/HTTPServer/HTTPMessage.h
index dab942136..e402c8ad6 100644
--- a/src/HTTPServer/HTTPMessage.h
+++ b/src/HTTPServer/HTTPMessage.h
@@ -33,7 +33,7 @@ public:
cHTTPMessage(eKind a_Kind);
// Force a virtual destructor in all descendants
- virtual ~cHTTPMessage() {};
+ virtual ~cHTTPMessage() {}
/** Adds a header into the internal map of headers. Recognizes special headers: Content-Type and Content-Length */
void AddHeader(const AString & a_Key, const AString & a_Value);
diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp
index eaf8405a3..8eabe5cb2 100644
--- a/src/HTTPServer/HTTPServer.cpp
+++ b/src/HTTPServer/HTTPServer.cpp
@@ -8,6 +8,7 @@
#include "HTTPMessage.h"
#include "HTTPConnection.h"
#include "HTTPFormParser.h"
+#include "SslHTTPConnection.h"
@@ -117,12 +118,12 @@ class cDebugCallbacks :
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHTTPServer:
cHTTPServer::cHTTPServer(void) :
- m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer IPv4"),
- m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer IPv6"),
+ m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer"),
+ m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer"),
m_Callbacks(NULL)
{
}
@@ -142,7 +143,44 @@ cHTTPServer::~cHTTPServer()
bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_PortsIPv6)
{
+ // Read the HTTPS cert + key:
+ AString CertFile = cFile::ReadWholeFile("webadmin/httpscert.crt");
+ AString KeyFile = cFile::ReadWholeFile("webadmin/httpskey.pem");
+ if (!CertFile.empty() && !KeyFile.empty())
+ {
+ m_Cert.reset(new cX509Cert);
+ int res = m_Cert->Parse(CertFile.data(), CertFile.size());
+ if (res == 0)
+ {
+ m_CertPrivKey.reset(new cCryptoKey);
+ int res2 = m_CertPrivKey->ParsePrivate(KeyFile.data(), KeyFile.size(), "");
+ if (res2 != 0)
+ {
+ // Reading the private key failed, reset the cert:
+ LOGWARNING("WebServer: Cannot read HTTPS certificate private key: -0x%x", -res2);
+ m_Cert.reset();
+ }
+ }
+ else
+ {
+ LOGWARNING("WebServer: Cannot read HTTPS certificate: -0x%x", -res);
+ }
+ }
+
+ // Notify the admin about the HTTPS / HTTP status
+ if (m_Cert.get() == NULL)
+ {
+ LOGWARNING("WebServer: The server is running in unsecure HTTP mode.");
+ }
+ else
+ {
+ LOGINFO("WebServer: The server is running in secure HTTPS mode.");
+ }
+
+ // Open up requested ports:
bool HasAnyPort;
+ m_ListenThreadIPv4.SetReuseAddr(true);
+ m_ListenThreadIPv6.SetReuseAddr(true);
HasAnyPort = m_ListenThreadIPv4.Initialize(a_PortsIPv4);
HasAnyPort = m_ListenThreadIPv6.Initialize(a_PortsIPv6) || HasAnyPort;
if (!HasAnyPort)
@@ -195,7 +233,15 @@ void cHTTPServer::Stop(void)
void cHTTPServer::OnConnectionAccepted(cSocket & a_Socket)
{
- cHTTPConnection * Connection = new cHTTPConnection(*this);
+ cHTTPConnection * Connection;
+ if (m_Cert.get() != NULL)
+ {
+ Connection = new cSslHTTPConnection(*this, m_Cert, m_CertPrivKey);
+ }
+ else
+ {
+ Connection = new cHTTPConnection(*this);
+ }
m_SocketThreads.AddClient(a_Socket, Connection);
cCSLock Lock(m_CSConnections);
m_Connections.push_back(Connection);
diff --git a/src/HTTPServer/HTTPServer.h b/src/HTTPServer/HTTPServer.h
index 8eff7d879..522b7da62 100644
--- a/src/HTTPServer/HTTPServer.h
+++ b/src/HTTPServer/HTTPServer.h
@@ -12,6 +12,9 @@
#include "../OSSupport/ListenThread.h"
#include "../OSSupport/SocketThreads.h"
#include "inifile/iniFile.h"
+#include "PolarSSL++/RsaPrivateKey.h"
+#include "PolarSSL++/CryptoKey.h"
+#include "PolarSSL++/X509Cert.h"
@@ -66,6 +69,7 @@ public:
protected:
friend class cHTTPConnection;
+ friend class cSslHTTPConnection;
cListenThread m_ListenThreadIPv4;
cListenThread m_ListenThreadIPv6;
@@ -78,6 +82,12 @@ protected:
/// The callbacks to call for various events
cCallbacks * m_Callbacks;
+ /** The server certificate to use for the SSL connections */
+ cX509CertPtr m_Cert;
+
+ /** The private key for m_Cert. */
+ cCryptoKeyPtr m_CertPrivKey;
+
// cListenThread::cCallback overrides:
virtual void OnConnectionAccepted(cSocket & a_Socket) override;
diff --git a/src/HTTPServer/MultipartParser.cpp b/src/HTTPServer/MultipartParser.cpp
index 309495dd7..09732c5f7 100644
--- a/src/HTTPServer/MultipartParser.cpp
+++ b/src/HTTPServer/MultipartParser.cpp
@@ -21,7 +21,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// self-test:
#if 0
@@ -87,7 +87,7 @@ ThisIsIgnoredEpilogue";
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMultipartParser:
diff --git a/src/HTTPServer/NameValueParser.cpp b/src/HTTPServer/NameValueParser.cpp
index 3f6c17dda..b345fef88 100644
--- a/src/HTTPServer/NameValueParser.cpp
+++ b/src/HTTPServer/NameValueParser.cpp
@@ -69,7 +69,7 @@ public:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cNameValueParser:
cNameValueParser::cNameValueParser(bool a_AllowsKeyOnly) :
@@ -97,7 +97,7 @@ void cNameValueParser::Parse(const char * a_Data, size_t a_Size)
{
ASSERT(m_State != psFinished); // Calling Parse() after Finish() is wrong!
- int Last = 0;
+ size_t Last = 0;
for (size_t i = 0; i < a_Size;)
{
switch (m_State)
diff --git a/src/HTTPServer/SslHTTPConnection.cpp b/src/HTTPServer/SslHTTPConnection.cpp
new file mode 100644
index 000000000..d237089d9
--- /dev/null
+++ b/src/HTTPServer/SslHTTPConnection.cpp
@@ -0,0 +1,107 @@
+
+// SslHTTPConnection.cpp
+
+// Implements the cSslHTTPConnection class representing a HTTP connection made over a SSL link
+
+#include "Globals.h"
+#include "SslHTTPConnection.h"
+#include "HTTPServer.h"
+
+
+
+
+
+cSslHTTPConnection::cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cCryptoKeyPtr & a_PrivateKey) :
+ super(a_HTTPServer),
+ m_Ssl(64000),
+ m_Cert(a_Cert),
+ m_PrivateKey(a_PrivateKey)
+{
+ m_Ssl.Initialize(false);
+ m_Ssl.SetOwnCert(a_Cert, a_PrivateKey);
+}
+
+
+
+
+
+bool cSslHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
+{
+ // If there is outgoing data in the queue, notify the server that it should write it out:
+ if (!m_OutgoingData.empty())
+ {
+ m_HTTPServer.NotifyConnectionWrite(*this);
+ }
+
+ // Process the received data:
+ const char * Data = a_Data;
+ size_t Size = a_Size;
+ for (;;)
+ {
+ // Try to write as many bytes into Ssl's "incoming" buffer as possible:
+ size_t BytesWritten = 0;
+ if (Size > 0)
+ {
+ BytesWritten = m_Ssl.WriteIncoming(Data, Size);
+ Data += BytesWritten;
+ Size -= BytesWritten;
+ }
+
+ // Try to read as many bytes from SSL's decryption as possible:
+ char Buffer[32000];
+ int NumRead = m_Ssl.ReadPlain(Buffer, sizeof(Buffer));
+ if (NumRead > 0)
+ {
+ if (super::DataReceived(Buffer, (size_t)NumRead))
+ {
+ // The socket has been closed, and the object is already deleted. Bail out.
+ return true;
+ }
+ }
+
+ // If both failed, bail out:
+ if ((BytesWritten == 0) && (NumRead <= 0))
+ {
+ return false;
+ }
+ }
+}
+
+
+
+
+
+void cSslHTTPConnection::GetOutgoingData(AString & a_Data)
+{
+ for (;;)
+ {
+ // Write as many bytes from our buffer to SSL's encryption as possible:
+ int NumWritten = 0;
+ if (!m_OutgoingData.empty())
+ {
+ NumWritten = m_Ssl.WritePlain(m_OutgoingData.data(), m_OutgoingData.size());
+ if (NumWritten > 0)
+ {
+ m_OutgoingData.erase(0, (size_t)NumWritten);
+ }
+ }
+
+ // Read as many bytes from SSL's "outgoing" buffer as possible:
+ char Buffer[32000];
+ size_t NumBytes = m_Ssl.ReadOutgoing(Buffer, sizeof(Buffer));
+ if (NumBytes > 0)
+ {
+ a_Data.append(Buffer, NumBytes);
+ }
+
+ // If both failed, bail out:
+ if ((NumWritten <= 0) && (NumBytes == 0))
+ {
+ return;
+ }
+ }
+}
+
+
+
+
diff --git a/src/HTTPServer/SslHTTPConnection.h b/src/HTTPServer/SslHTTPConnection.h
new file mode 100644
index 000000000..c2c1585cd
--- /dev/null
+++ b/src/HTTPServer/SslHTTPConnection.h
@@ -0,0 +1,45 @@
+
+// SslHTTPConnection.h
+
+// Declared the cSslHTTPConnection class representing a HTTP connection made over a SSL link
+
+
+
+
+
+#pragma once
+
+#include "HTTPConnection.h"
+#include "PolarSSL++/BufferedSslContext.h"
+
+
+
+
+
+class cSslHTTPConnection :
+ public cHTTPConnection
+{
+ typedef cHTTPConnection super;
+
+public:
+ /** Creates a new connection on the specified server.
+ Sends the specified cert as the server certificate, uses the private key for decryption. */
+ cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cCryptoKeyPtr & a_PrivateKey);
+
+protected:
+ cBufferedSslContext m_Ssl;
+
+ /** The certificate to send to the client */
+ cX509CertPtr m_Cert;
+
+ /** The private key used for the certificate */
+ cCryptoKeyPtr m_PrivateKey;
+
+ // cHTTPConnection overrides:
+ virtual bool DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client
+ virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client
+} ;
+
+
+
+
diff --git a/src/Inventory.cpp b/src/Inventory.cpp
index c7c089d5f..8da3dea5f 100644
--- a/src/Inventory.cpp
+++ b/src/Inventory.cpp
@@ -102,13 +102,17 @@ int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks, bool a_tryT
{
cItem ToAdd(a_Item);
int res = 0;
+
+ // When the item is a armor, try to set it directly to the armor slot.
if (ItemCategory::IsArmor(a_Item.m_ItemType))
{
- res = m_ArmorSlots.AddItem(ToAdd, a_AllowNewStacks);
- ToAdd.m_ItemCount -= res;
- if (ToAdd.m_ItemCount == 0)
+ for (size_t i = 0; i < (size_t)m_ArmorSlots.GetNumSlots(); i++)
{
- return res;
+ if (m_ArmorSlots.GetSlot(i).IsEmpty() && cSlotAreaArmor::CanPlaceArmorInSlot(i, a_Item))
+ {
+ m_ArmorSlots.SetSlot(i, a_Item);
+ return a_Item.m_ItemCount;
+ }
}
}
@@ -151,6 +155,24 @@ int cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a
+int cInventory::RemoveItem(const cItem & a_ItemStack)
+{
+ int RemovedItems = m_HotbarSlots.RemoveItem(a_ItemStack);
+
+ if (RemovedItems < a_ItemStack.m_ItemCount)
+ {
+ cItem Temp(a_ItemStack);
+ Temp.m_ItemCount -= RemovedItems;
+ RemovedItems += m_InventorySlots.RemoveItem(Temp);
+ }
+
+ return RemovedItems;
+}
+
+
+
+
+
bool cInventory::RemoveOneEquippedItem(void)
{
if (m_HotbarSlots.GetSlot(m_EquippedSlotNum).IsEmpty())
@@ -204,12 +226,6 @@ void cInventory::SetSlot(int a_SlotNum, const cItem & a_Item)
return;
}
Grid->SetSlot(GridSlotNum, a_Item);
-
- // Broadcast the Equipped Item, if the Slot is changed.
- if ((Grid == &m_HotbarSlots) && (m_EquippedSlotNum == (a_SlotNum - invHotbarOffset)))
- {
- m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, a_Item, m_Owner.GetClientHandle());
- }
}
@@ -243,6 +259,16 @@ void cInventory::SetHotbarSlot(int a_HotBarSlotNum, const cItem & a_Item)
+void cInventory::SendEquippedSlot()
+{
+ int EquippedSlotNum = cInventory::invArmorCount + cInventory::invInventoryCount + GetEquippedSlotNum();
+ SendSlot(EquippedSlotNum);
+}
+
+
+
+
+
const cItem & cInventory::GetSlot(int a_SlotNum) const
{
if ((a_SlotNum < 0) || (a_SlotNum >= invNumSlots))
@@ -365,6 +391,10 @@ bool cInventory::DamageItem(int a_SlotNum, short a_Amount)
LOGWARNING("%s: requesting an invalid slot index: %d out of %d", __FUNCTION__, a_SlotNum, invNumSlots - 1);
return false;
}
+ if (a_Amount <= 0)
+ {
+ return false;
+ }
int GridSlotNum = 0;
cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
@@ -376,6 +406,7 @@ bool cInventory::DamageItem(int a_SlotNum, short a_Amount)
if (!Grid->DamageItem(GridSlotNum, a_Amount))
{
// The item has been damaged, but did not break yet
+ SendSlot(a_SlotNum);
return false;
}
@@ -468,21 +499,21 @@ int cInventory::ArmorSlotNumToEntityEquipmentID(short a_ArmorSlotNum)
#if 0
-bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */ )
+bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */)
{
// Fill already present stacks
- if( a_Mode < 2 )
+ if (a_Mode < 2)
{
int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize();
- for(int i = 0; i < a_Size; i++)
+ for (int i = 0; i < a_Size; i++)
{
- if( m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage )
+ if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage)
{
int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount;
- if( NumFree >= a_Item.m_ItemCount )
+ if (NumFree >= a_Item.m_ItemCount)
{
- //printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree );
+ // printf("1. Adding %i items ( free: %i)\n", a_Item.m_ItemCount, NumFree);
m_Slots[i + a_Offset].m_ItemCount += a_Item.m_ItemCount;
a_Item.m_ItemCount = 0;
a_bChangedSlots[i + a_Offset] = true;
@@ -490,7 +521,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
}
else
{
- //printf("2. Adding %i items\n", NumFree );
+ // printf("2. Adding %i items\n", NumFree);
m_Slots[i + a_Offset].m_ItemCount += (char)NumFree;
a_Item.m_ItemCount -= (char)NumFree;
a_bChangedSlots[i + a_Offset] = true;
@@ -499,12 +530,12 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
}
}
- if( a_Mode > 0 )
+ if (a_Mode > 0)
{
// If we got more left, find first empty slot
- for(int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++)
+ for (int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++)
{
- if( m_Slots[i + a_Offset].m_ItemType == -1 )
+ if (m_Slots[i + a_Offset].m_ItemType == -1)
{
m_Slots[i + a_Offset] = a_Item;
a_Item.m_ItemCount = 0;
@@ -684,6 +715,12 @@ void cInventory::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
m_ArmorSlots.GetSlot(a_SlotNum), m_Owner.GetClientHandle()
);
}
+
+ // Broadcast the Equipped Item, if the Slot is changed.
+ if ((a_ItemGrid == &m_HotbarSlots) && (m_EquippedSlotNum == a_SlotNum))
+ {
+ m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, GetEquippedItem(), m_Owner.GetClientHandle());
+ }
// Convert the grid-local a_SlotNum to our global SlotNum:
int Base = 0;
diff --git a/src/Inventory.h b/src/Inventory.h
index 1ad7c4776..ed134aee4 100644
--- a/src/Inventory.h
+++ b/src/Inventory.h
@@ -56,13 +56,13 @@ public:
// tolua_begin
- /// Removes all items from the entire inventory
+ /** Removes all items from the entire inventory */
void Clear(void);
- /// Returns number of items out of a_ItemStack that can fit in the storage
+ /** Returns number of items out of a_ItemStack that can fit in the storage */
int HowManyCanFit(const cItem & a_ItemStack, bool a_ConsiderEmptySlots);
- /// Returns how many items of the specified type would fit into the slot range specified
+ /** Returns how many items of the specified type would fit into the slot range specified */
int HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int a_EndSlotNum, bool a_ConsiderEmptySlots);
/** Adds as many items out of a_ItemStack as can fit.
@@ -86,33 +86,40 @@ public:
*/
int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a_tryToFillEquippedFirst);
- /// Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed
+ /** Removes the specified item from the inventory, as many as possible, up to a_ItemStack.m_ItemCount.
+ Returns the number of items that were removed. */
+ int RemoveItem(const cItem & a_ItemStack);
+
+ /** Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed */
bool RemoveOneEquippedItem(void);
- /// Returns the number of items of type a_Item that are stored
+ /** Returns the number of items of type a_Item that are stored */
int HowManyItems(const cItem & a_Item);
- /// Returns true if there are at least as many items of type a_ItemStack as in a_ItemStack
+ /** Returns true if there are at least as many items of type a_ItemStack as in a_ItemStack */
bool HasItems(const cItem & a_ItemStack);
+
+ /** Sends the equipped item slot to the client */
+ void SendEquippedSlot();
- /// Returns the cItemGrid object representing the armor slots
+ /** Returns the cItemGrid object representing the armor slots */
cItemGrid & GetArmorGrid(void) { return m_ArmorSlots; }
- /// Returns the cItemGrid object representing the main inventory slots
+ /** Returns the cItemGrid object representing the main inventory slots */
cItemGrid & GetInventoryGrid(void) { return m_InventorySlots; }
- /// Returns the cItemGrid object representing the hotbar slots
+ /** Returns the cItemGrid object representing the hotbar slots */
cItemGrid & GetHotbarGrid(void) { return m_HotbarSlots; }
- /// Returns the player associated with this inventory
+ /** Returns the player associated with this inventory */
cPlayer & GetOwner(void) { return m_Owner; }
- /// Copies the non-empty slots into a_ItemStacks; preserves the original a_Items contents
+ /** Copies the non-empty slots into a_ItemStacks; preserves the original a_Items contents */
void CopyToItems(cItems & a_Items);
// tolua_end
- /// Returns the player associated with this inventory (const version)
+ /** Returns the player associated with this inventory (const version) */
const cPlayer & GetOwner(void) const { return m_Owner; }
// tolua_begin
@@ -136,10 +143,10 @@ public:
*/
int ChangeSlotCount(int a_SlotNum, int a_AddToCount);
- /// Adds the specified damage to the specified item; deletes the item and returns true if the item broke.
+ /** Adds the specified damage to the specified item; deletes the item and returns true if the item broke. */
bool DamageItem(int a_SlotNum, short a_Amount);
- /// Adds the specified damage to the currently held item; deletes the item and returns true if the item broke.
+ /** Adds the specified damage to the currently held item; deletes the item and returns true if the item broke. */
bool DamageEquippedItem(short a_Amount = 1);
const cItem & GetEquippedHelmet (void) const { return m_ArmorSlots.GetSlot(0); }
@@ -149,20 +156,20 @@ public:
// tolua_end
- /// Sends the slot contents to the owner
+ /** Sends the slot contents to the owner */
void SendSlot(int a_SlotNum);
- /// Update items (e.g. Maps)
+ /** Update items (e.g. Maps) */
void UpdateItems(void);
- /// Converts an armor slot number into the ID for the EntityEquipment packet
+ /** Converts an armor slot number into the ID for the EntityEquipment packet */
static int ArmorSlotNumToEntityEquipmentID(short a_ArmorSlotNum);
void SaveToJson(Json::Value & a_Value);
bool LoadFromJson(Json::Value & a_Value);
protected:
- bool AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode = 0 );
+ bool AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode = 0);
cItemGrid m_ArmorSlots;
cItemGrid m_InventorySlots;
@@ -172,15 +179,15 @@ protected:
cPlayer & m_Owner;
- /// Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum
+ /** Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum */
const cItemGrid * GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum) const;
- /// Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum
+ /** Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum */
cItemGrid * GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum);
// cItemGrid::cListener override:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Item.cpp b/src/Item.cpp
index 7e472f6d8..2c5deaddf 100644
--- a/src/Item.cpp
+++ b/src/Item.cpp
@@ -1,4 +1,4 @@
-
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Item.h"
@@ -41,33 +41,33 @@ short cItem::GetMaxDamage(void) const
switch (m_ItemType)
{
case E_ITEM_BOW: return 384;
- case E_ITEM_DIAMOND_AXE: return 1563;
- case E_ITEM_DIAMOND_HOE: return 1563;
- case E_ITEM_DIAMOND_PICKAXE: return 1563;
- case E_ITEM_DIAMOND_SHOVEL: return 1563;
- case E_ITEM_DIAMOND_SWORD: return 1563;
- case E_ITEM_FLINT_AND_STEEL: return 65;
+ case E_ITEM_DIAMOND_AXE: return 1561;
+ case E_ITEM_DIAMOND_HOE: return 1561;
+ case E_ITEM_DIAMOND_PICKAXE: return 1561;
+ case E_ITEM_DIAMOND_SHOVEL: return 1561;
+ case E_ITEM_DIAMOND_SWORD: return 1561;
+ case E_ITEM_FLINT_AND_STEEL: return 64;
case E_ITEM_GOLD_AXE: return 32;
case E_ITEM_GOLD_HOE: return 32;
case E_ITEM_GOLD_PICKAXE: return 32;
case E_ITEM_GOLD_SHOVEL: return 32;
case E_ITEM_GOLD_SWORD: return 32;
- case E_ITEM_IRON_AXE: return 251;
- case E_ITEM_IRON_HOE: return 251;
- case E_ITEM_IRON_PICKAXE: return 251;
- case E_ITEM_IRON_SHOVEL: return 251;
- case E_ITEM_IRON_SWORD: return 251;
- case E_ITEM_SHEARS: return 251;
- case E_ITEM_STONE_AXE: return 132;
- case E_ITEM_STONE_HOE: return 132;
- case E_ITEM_STONE_PICKAXE: return 132;
- case E_ITEM_STONE_SHOVEL: return 132;
- case E_ITEM_STONE_SWORD: return 132;
- case E_ITEM_WOODEN_AXE: return 60;
- case E_ITEM_WOODEN_HOE: return 60;
- case E_ITEM_WOODEN_PICKAXE: return 60;
- case E_ITEM_WOODEN_SHOVEL: return 60;
- case E_ITEM_WOODEN_SWORD: return 60;
+ case E_ITEM_IRON_AXE: return 250;
+ case E_ITEM_IRON_HOE: return 250;
+ case E_ITEM_IRON_PICKAXE: return 250;
+ case E_ITEM_IRON_SHOVEL: return 250;
+ case E_ITEM_IRON_SWORD: return 250;
+ case E_ITEM_SHEARS: return 250;
+ case E_ITEM_STONE_AXE: return 131;
+ case E_ITEM_STONE_HOE: return 131;
+ case E_ITEM_STONE_PICKAXE: return 131;
+ case E_ITEM_STONE_SHOVEL: return 131;
+ case E_ITEM_STONE_SWORD: return 131;
+ case E_ITEM_WOODEN_AXE: return 59;
+ case E_ITEM_WOODEN_HOE: return 59;
+ case E_ITEM_WOODEN_PICKAXE: return 59;
+ case E_ITEM_WOODEN_SHOVEL: return 59;
+ case E_ITEM_WOODEN_SWORD: return 59;
}
return 0;
}
@@ -86,7 +86,7 @@ bool cItem::DamageItem(short a_Amount)
}
m_ItemDamage += a_Amount;
- return (m_ItemDamage >= MaxDamage);
+ return (m_ItemDamage > MaxDamage);
}
@@ -151,6 +151,8 @@ void cItem::GetJson(Json::Value & a_OutValue) const
a_OutValue["Colours"] = m_FireworkItem.ColoursToString(m_FireworkItem);
a_OutValue["FadeColours"] = m_FireworkItem.FadeColoursToString(m_FireworkItem);
}
+
+ a_OutValue["RepairCost"] = m_RepairCost;
}
}
@@ -160,11 +162,11 @@ void cItem::GetJson(Json::Value & a_OutValue) const
void cItem::FromJson(const Json::Value & a_Value)
{
- m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1 ).asInt();
+ m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1).asInt();
if (m_ItemType > 0)
{
- m_ItemCount = (char)a_Value.get("Count", -1 ).asInt();
- m_ItemDamage = (short)a_Value.get("Health", -1 ).asInt();
+ m_ItemCount = (char)a_Value.get("Count", -1).asInt();
+ m_ItemDamage = (short)a_Value.get("Health", -1).asInt();
m_Enchantments.Clear();
m_Enchantments.AddFromString(a_Value.get("ench", "").asString());
m_CustomName = a_Value.get("Name", "").asString();
@@ -179,6 +181,8 @@ void cItem::FromJson(const Json::Value & a_Value)
m_FireworkItem.ColoursFromString(a_Value.get("Colours", "").asString(), m_FireworkItem);
m_FireworkItem.FadeColoursFromString(a_Value.get("FadeColours", "").asString(), m_FireworkItem);
}
+
+ m_RepairCost = a_Value.get("RepairCost", 0).asInt();
}
}
@@ -189,17 +193,29 @@ void cItem::FromJson(const Json::Value & a_Value)
bool cItem::IsEnchantable(short item)
{
if ((item >= 256) && (item <= 259))
+ {
return true;
+ }
if ((item >= 267) && (item <= 279))
+ {
return true;
- if ((item >= 283) && (item <= 286))
+ }
+ if ((item >= 283) && (item <= 286))
+ {
return true;
+ }
if ((item >= 290) && (item <= 294))
+ {
return true;
+ }
if ((item >= 298) && (item <= 317))
+ {
return true;
+ }
if ((item == 346) || (item == 359) || (item == 261))
+ {
return true;
+ }
return false;
}
@@ -359,7 +375,7 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cItems:
cItem * cItems::Get(int a_Idx)
diff --git a/src/Item.h b/src/Item.h
index 00316c188..d8b9e78a0 100644
--- a/src/Item.h
+++ b/src/Item.h
@@ -40,6 +40,7 @@ public:
m_ItemDamage(0),
m_CustomName(""),
m_Lore(""),
+ m_RepairCost(0),
m_FireworkItem()
{
}
@@ -60,11 +61,12 @@ public:
m_Enchantments(a_Enchantments),
m_CustomName (a_CustomName),
m_Lore (a_Lore),
+ m_RepairCost (0),
m_FireworkItem()
{
if (!IsValidItem(m_ItemType))
{
- if (m_ItemType != E_BLOCK_AIR)
+ if ((m_ItemType != E_BLOCK_AIR) && (m_ItemType != E_ITEM_EMPTY))
{
LOGWARNING("%s: creating an invalid item type (%d), resetting to empty.", __FUNCTION__, a_ItemType);
}
@@ -73,6 +75,10 @@ public:
}
+ // The constructor is disabled in code, because the compiler generates it anyway,
+ // but it needs to stay because ToLua needs to generate the binding for it
+ #if 0
+
/** Creates an exact copy of the item */
cItem(const cItem & a_CopyFrom) :
m_ItemType (a_CopyFrom.m_ItemType),
@@ -81,10 +87,13 @@ public:
m_Enchantments(a_CopyFrom.m_Enchantments),
m_CustomName (a_CopyFrom.m_CustomName),
m_Lore (a_CopyFrom.m_Lore),
+ m_RepairCost (a_CopyFrom.m_RepairCost),
m_FireworkItem(a_CopyFrom.m_FireworkItem)
{
}
+ #endif
+
void Empty(void)
{
@@ -94,6 +103,7 @@ public:
m_Enchantments.Clear();
m_CustomName = "";
m_Lore = "";
+ m_RepairCost = 0;
m_FireworkItem.EmptyData();
}
@@ -103,6 +113,7 @@ public:
m_ItemType = E_ITEM_EMPTY;
m_ItemCount = 0;
m_ItemDamage = 0;
+ m_RepairCost = 0;
}
@@ -139,7 +150,7 @@ public:
bool IsCustomNameEmpty(void) const { return (m_CustomName.empty()); }
- bool IsLoreEmpty(void) const { return (m_Lore.empty()); }
+ bool IsLoreEmpty(void) const { return (m_Lore.empty()); }
/** Returns a copy of this item with m_ItemCount set to 1. Useful to preserve enchantments etc. on stacked items */
cItem CopyOne(void) const;
@@ -173,25 +184,26 @@ public:
void FromJson(const Json::Value & a_Value);
/** Returns true if the specified item type is enchantable (as per 1.2.5 protocol requirements) */
- static bool IsEnchantable(short a_ItemType); // tolua_export
+ static bool IsEnchantable(short a_ItemType); // tolua_export
/** Returns the enchantability of the item. When the item hasn't a enchantability, it will returns 0 */
- int GetEnchantability(); // tolua_export
+ int GetEnchantability(); // tolua_export
/** Enchants the item using the specified number of XP levels.
Returns true if item enchanted, false if not. */
- bool EnchantByXPLevels(int a_NumXPLevels); // tolua_export
+ bool EnchantByXPLevels(int a_NumXPLevels); // tolua_export
// tolua_begin
- short m_ItemType;
- char m_ItemCount;
- short m_ItemDamage;
- cEnchantments m_Enchantments;
- AString m_CustomName;
- AString m_Lore;
-
- cFireworkItem m_FireworkItem;
+ short m_ItemType;
+ char m_ItemCount;
+ short m_ItemDamage;
+ cEnchantments m_Enchantments;
+ AString m_CustomName;
+ AString m_Lore;
+
+ int m_RepairCost;
+ cFireworkItem m_FireworkItem;
};
// tolua_end
@@ -216,7 +228,7 @@ public:
void Add (const cItem & a_Item) {push_back(a_Item); }
void Delete(int a_Idx);
void Clear (void) {clear(); }
- size_t Size (void) {return size(); }
+ size_t Size (void) const { return size(); }
void Set (int a_Idx, short a_ItemType, char a_ItemCount, short a_ItemDamage);
void Add (short a_ItemType, char a_ItemCount, short a_ItemDamage)
diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp
index 34a267bab..2344dc0a5 100644
--- a/src/ItemGrid.cpp
+++ b/src/ItemGrid.cpp
@@ -28,6 +28,7 @@ cItemGrid::cItemGrid(int a_Width, int a_Height) :
cItemGrid::~cItemGrid()
{
delete[] m_Slots;
+ m_Slots = NULL;
}
@@ -268,7 +269,7 @@ int cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, i
int cItemGrid::AddItem(cItem & a_ItemStack, bool a_AllowNewStacks, int a_PrioritarySlot)
{
int NumLeft = a_ItemStack.m_ItemCount;
- int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize();
+ int MaxStack = a_ItemStack.GetMaxStackSize();
// Try prioritarySlot first:
if (
@@ -283,7 +284,7 @@ int cItemGrid::AddItem(cItem & a_ItemStack, bool a_AllowNewStacks, int a_Priorit
}
// Scan existing stacks:
- for (int i = m_NumSlots - 1; i >= 0; i--)
+ for (int i = 0; i < m_NumSlots; i++)
{
if (m_Slots[i].IsEqual(a_ItemStack))
{
@@ -301,7 +302,7 @@ int cItemGrid::AddItem(cItem & a_ItemStack, bool a_AllowNewStacks, int a_Priorit
return (a_ItemStack.m_ItemCount - NumLeft);
}
- for (int i = m_NumSlots - 1; i >= 0; i--)
+ for (int i = 0; i < m_NumSlots; i++)
{
if (m_Slots[i].IsEmpty())
{
@@ -344,6 +345,39 @@ int cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_P
+int cItemGrid::RemoveItem(const cItem & a_ItemStack)
+{
+ int NumLeft = a_ItemStack.m_ItemCount;
+
+ for (int i = 0; i < m_NumSlots; i++)
+ {
+ if (NumLeft <= 0)
+ {
+ break;
+ }
+
+ if (m_Slots[i].IsEqual(a_ItemStack))
+ {
+ int NumToRemove = std::min(NumLeft, (int)m_Slots[i].m_ItemCount);
+ NumLeft -= NumToRemove;
+ m_Slots[i].m_ItemCount -= NumToRemove;
+
+ if (m_Slots[i].m_ItemCount <= 0)
+ {
+ m_Slots[i].Empty();
+ }
+
+ TriggerListeners(i);
+ }
+ }
+
+ return (a_ItemStack.m_ItemCount - NumLeft);
+}
+
+
+
+
+
int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount)
{
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
diff --git a/src/ItemGrid.h b/src/ItemGrid.h
index c34d5e9e2..8d6544792 100644
--- a/src/ItemGrid.h
+++ b/src/ItemGrid.h
@@ -96,6 +96,10 @@ public:
Returns the total number of items that fit.
*/
int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1);
+
+ /** Removes the specified item from the grid, as many as possible, up to a_ItemStack.m_ItemCount.
+ Returns the number of items that were removed. */
+ int RemoveItem(const cItem & a_ItemStack);
/** Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot.
If the slot is empty, ignores the call.
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt
index a6fe6ea70..12a467672 100644
--- a/src/Items/CMakeLists.txt
+++ b/src/Items/CMakeLists.txt
@@ -4,9 +4,53 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ ItemHandler.cpp)
-add_library(Items ${SOURCE})
+SET (HDRS
+ ItemArmor.h
+ ItemBed.h
+ ItemBoat.h
+ ItemBow.h
+ ItemBrewingStand.h
+ ItemBucket.h
+ ItemCake.h
+ ItemCauldron.h
+ ItemCloth.h
+ ItemComparator.h
+ ItemDoor.h
+ ItemDye.h
+ ItemEmptyMap.h
+ ItemFishingRod.h
+ ItemFlowerPot.h
+ ItemFood.h
+ ItemHandler.h
+ ItemHoe.h
+ ItemItemFrame.h
+ ItemLeaves.h
+ ItemLighter.h
+ ItemLilypad.h
+ ItemMap.h
+ ItemMilk.h
+ ItemMinecart.h
+ ItemMobHead.h
+ ItemNetherWart.h
+ ItemPainting.h
+ ItemPickaxe.h
+ ItemPotion.h
+ ItemRedstoneDust.h
+ ItemRedstoneRepeater.h
+ ItemSapling.h
+ ItemSeeds.h
+ ItemShears.h
+ ItemShovel.h
+ ItemSign.h
+ ItemSpawnEgg.h
+ ItemString.h
+ ItemSugarcane.h
+ ItemSword.h
+ ItemThrowable.h)
+
+if(NOT MSVC)
+ add_library(Items ${SRCS} ${HDRS})
+endif()
diff --git a/src/Items/ItemArmor.h b/src/Items/ItemArmor.h
index 08cddb1ad..2436df5bd 100644
--- a/src/Items/ItemArmor.h
+++ b/src/Items/ItemArmor.h
@@ -60,6 +60,49 @@ public:
return true;
}
+ virtual bool CanRepairWithRawMaterial(short a_ItemType) override
+ {
+ switch (m_ItemType)
+ {
+ case E_ITEM_CHAIN_BOOTS:
+ case E_ITEM_CHAIN_CHESTPLATE:
+ case E_ITEM_CHAIN_HELMET:
+ case E_ITEM_CHAIN_LEGGINGS:
+ {
+ return (a_ItemType == E_ITEM_IRON);
+ }
+ case E_ITEM_DIAMOND_BOOTS:
+ case E_ITEM_DIAMOND_CHESTPLATE:
+ case E_ITEM_DIAMOND_HELMET:
+ case E_ITEM_DIAMOND_LEGGINGS:
+ {
+ return (a_ItemType == E_ITEM_DIAMOND);
+ }
+ case E_ITEM_IRON_BOOTS:
+ case E_ITEM_IRON_CHESTPLATE:
+ case E_ITEM_IRON_HELMET:
+ case E_ITEM_IRON_LEGGINGS:
+ {
+ return (a_ItemType == E_ITEM_IRON);
+ }
+ case E_ITEM_GOLD_BOOTS:
+ case E_ITEM_GOLD_CHESTPLATE:
+ case E_ITEM_GOLD_HELMET:
+ case E_ITEM_GOLD_LEGGINGS:
+ {
+ return (a_ItemType == E_ITEM_GOLD);
+ }
+ case E_ITEM_LEATHER_BOOTS:
+ case E_ITEM_LEATHER_CAP:
+ case E_ITEM_LEATHER_PANTS:
+ case E_ITEM_LEATHER_TUNIC:
+ {
+ return (a_ItemType == E_ITEM_LEATHER);
+ }
+ }
+ return false;
+ }
+
} ;
diff --git a/src/Items/ItemBed.h b/src/Items/ItemBed.h
index f23d69731..94a14cf16 100644
--- a/src/Items/ItemBed.h
+++ b/src/Items/ItemBed.h
@@ -26,7 +26,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h
index 42f4ffc8f..7faac1e32 100644
--- a/src/Items/ItemBoat.h
+++ b/src/Items/ItemBoat.h
@@ -75,7 +75,7 @@ public:
double z = Callbacks.m_Pos.z;
cBoat * Boat = new cBoat(x + 0.5, y + 1, z + 0.5);
- Boat->Initialize(a_World);
+ Boat->Initialize(*a_World);
return true;
}
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h
index 8c0b3a0a3..e7a77dcbc 100644
--- a/src/Items/ItemBow.h
+++ b/src/Items/ItemBow.h
@@ -46,34 +46,31 @@ public:
{
// Actual shot - produce the arrow with speed based on the ticks that the bow was charged
ASSERT(a_Player != NULL);
-
+
int BowCharge = a_Player->FinishChargingBow();
- double Force = (double)BowCharge / 20;
- Force = (Force * Force + 2 * Force) / 3; // This formula is used by the 1.6.2 client
+ double Force = (double)BowCharge / 20.0;
+ Force = (Force * Force + 2.0 * Force) / 3.0; // This formula is used by the 1.6.2 client
if (Force < 0.1)
{
// Too little force, ignore the shot
return;
}
- if (Force > 1)
- {
- Force = 1;
- }
-
+ Force = std::min(Force, 1.0);
+
// Create the arrow entity:
cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2);
if (Arrow == NULL)
{
return;
}
- if (!Arrow->Initialize(a_Player->GetWorld()))
+ if (!Arrow->Initialize(*a_Player->GetWorld()))
{
delete Arrow;
+ Arrow = NULL;
return;
}
- a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow);
- a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force);
+ a_Player->GetWorld()->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY(), a_Player->GetPosZ(), 0.5, (float)Force);
if (!a_Player->IsGameModeCreative())
{
a_Player->UseEquippedItem();
diff --git a/src/Items/ItemBrewingStand.h b/src/Items/ItemBrewingStand.h
index d5eefb855..7be57763c 100644
--- a/src/Items/ItemBrewingStand.h
+++ b/src/Items/ItemBrewingStand.h
@@ -25,7 +25,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index 68c89dd85..a17c4838b 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -41,7 +41,7 @@ public:
bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
{
- if (a_BlockFace > 0)
+ if (a_BlockFace != BLOCK_FACE_NONE)
{
return false;
}
@@ -49,7 +49,7 @@ public:
Vector3i BlockPos;
if (!GetBlockFromTrace(a_World, a_Player, BlockPos))
{
- return false; // Nothing in range.
+ return false; // Nothing in range.
}
if (a_World->GetBlockMeta(BlockPos.x, BlockPos.y, BlockPos.z) != 0)
@@ -94,30 +94,16 @@ public:
bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock)
- {
- if (a_BlockFace < 0)
+ {
+ if (a_BlockFace != BLOCK_FACE_NONE)
{
return false;
}
- BLOCKTYPE CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
- if (!CanWashAway)
+ BLOCKTYPE CurrentBlock;
+ Vector3i BlockPos;
+ if (!GetPlacementCoordsFromTrace(a_World, a_Player, BlockPos, CurrentBlock))
{
- // The block pointed at cannot be washed away, so put fluid on top of it / on its sides
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- }
- if (
- !CanWashAway &&
- (CurrentBlock != E_BLOCK_AIR) &&
- (CurrentBlock != E_BLOCK_WATER) &&
- (CurrentBlock != E_BLOCK_STATIONARY_WATER) &&
- (CurrentBlock != E_BLOCK_LAVA) &&
- (CurrentBlock != E_BLOCK_STATIONARY_LAVA)
- )
- {
- // Cannot place water here
return false;
}
@@ -131,14 +117,14 @@ public:
return false;
}
cItem Item(E_ITEM_BUCKET, 1);
- if (!a_Player->GetInventory().AddItem(Item,true,true))
+ if (!a_Player->GetInventory().AddItem(Item, true, true))
{
return false;
}
}
// Wash away anything that was there prior to placing:
- if (CanWashAway)
+ if (cFluidSimulator::CanWashAway(CurrentBlock))
{
cBlockHandler * Handler = BlockHandler(CurrentBlock);
if (Handler->DoesDropOnUnsuitable())
@@ -149,13 +135,13 @@ public:
}
}
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FluidBlock, 0);
+ a_World->SetBlock(BlockPos.x, BlockPos.y, BlockPos.z, a_FluidBlock, 0);
return true;
}
- bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos)
+ bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos)
{
class cCallbacks :
public cBlockTracer::cCallbacks
@@ -174,7 +160,7 @@ public:
{
if (IsBlockWater(a_BlockType) || IsBlockLava(a_BlockType))
{
- if (a_BlockMeta != 0) // GetBlockFromTrace is called for scooping up fluids; the hit block should be a source
+ if (a_BlockMeta != 0) // GetBlockFromTrace is called for scooping up fluids; the hit block should be a source
{
return false;
}
@@ -198,8 +184,49 @@ public:
}
- BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z);
+ a_BlockPos = Callbacks.m_Pos;
return true;
}
+
+
+ bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType)
+ {
+ class cCallbacks :
+ public cBlockTracer::cCallbacks
+ {
+ public:
+ Vector3i m_Pos;
+ BLOCKTYPE m_ReplacedBlock;
+
+ virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override
+ {
+ if (a_BlockType != E_BLOCK_AIR)
+ {
+ m_ReplacedBlock = a_BlockType;
+ if (!cFluidSimulator::CanWashAway(a_BlockType) && !IsBlockLiquid(a_BlockType))
+ {
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was an unwashawayable block, can't overwrite it!
+ }
+ m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); // (Block could be washed away, replace it)
+ return true; // Abort tracing
+ }
+ return false;
+ }
+ } Callbacks;
+ cLineBlockTracer Tracer(*a_World, Callbacks);
+ Vector3d Start(a_Player->GetEyePosition());
+ Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5);
+
+ // cTracer::Trace returns true when whole line was traversed. By returning true when we hit something, we ensure that this never happens if liquid could be placed
+ // Use this to judge whether the position is valid
+ if (!Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z))
+ {
+ a_BlockPos = Callbacks.m_Pos;
+ a_BlockType = Callbacks.m_ReplacedBlock;
+ return true;
+ }
+
+ return false;
+ }
};
diff --git a/src/Items/ItemCake.h b/src/Items/ItemCake.h
index 48e23ed59..d1cb091b6 100644
--- a/src/Items/ItemCake.h
+++ b/src/Items/ItemCake.h
@@ -25,7 +25,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemCauldron.h b/src/Items/ItemCauldron.h
index 07ae12660..9617c30ef 100644
--- a/src/Items/ItemCauldron.h
+++ b/src/Items/ItemCauldron.h
@@ -25,7 +25,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemComparator.h b/src/Items/ItemComparator.h
index 60d9c3648..fc843c186 100644
--- a/src/Items/ItemComparator.h
+++ b/src/Items/ItemComparator.h
@@ -24,7 +24,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h
index f3677c28c..c1b439024 100644
--- a/src/Items/ItemDoor.h
+++ b/src/Items/ItemDoor.h
@@ -25,7 +25,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -33,8 +33,8 @@ public:
a_BlockType = (m_ItemType == E_ITEM_WOODEN_DOOR) ? E_BLOCK_WOODEN_DOOR : E_BLOCK_IRON_DOOR;
cChunkInterface ChunkInterface(a_World->GetChunkMap());
bool Meta = BlockHandler(a_BlockType)->GetPlacementBlockTypeMeta(
- ChunkInterface, a_Player,
- a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
+ ChunkInterface, a_Player,
+ a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
a_CursorX, a_CursorY, a_CursorZ,
a_BlockType, a_BlockMeta
);
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h
index 0431b88b7..6350a38ba 100644
--- a/src/Items/ItemFishingRod.h
+++ b/src/Items/ItemFishingRod.h
@@ -17,13 +17,15 @@
-/////////////////////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////////
// cFloaterCallback
class cFloaterCallback :
public cEntityCallback
{
public:
- cFloaterCallback(void) :
+ cFloaterCallback(void) :
m_CanPickup(false),
m_AttachedMobID(-1)
{
@@ -49,14 +51,19 @@ protected:
Vector3d m_Pos;
} ;
-////////////////////////////////////////////////////////////////////////////
-// cSweepEntityCallback
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cSweepEntityCallback:
+
class cSweepEntityCallback :
public cEntityCallback
{
public:
cSweepEntityCallback(Vector3d a_PlayerPos) :
- m_PlayerPos(a_PlayerPos)
+ m_PlayerPos(a_PlayerPos)
{
}
@@ -73,6 +80,8 @@ protected:
+
+
class cItemFishingRodHandler :
public cItemHandler
{
@@ -106,19 +115,19 @@ public:
{
cItems Drops;
int ItemCategory = a_World->GetTickRandomNumber(99);
- if (ItemCategory <= 4) // Treasures 5%
+ if (ItemCategory <= 4) // Treasures 5%
{
int Treasure = a_World->GetTickRandomNumber(5);
switch (Treasure)
{
case 0:
{
- Drops.Add(cItem(E_ITEM_BOW)); // TODO: Enchantments
+ Drops.Add(cItem(E_ITEM_BOW)); // TODO: Enchantments
break;
}
case 1:
{
- Drops.Add(cItem(E_ITEM_BOOK)); // TODO: Enchanted book
+ Drops.Add(cItem(E_ITEM_BOOK)); // TODO: Enchanted book
break;
}
case 2:
@@ -142,6 +151,8 @@ public:
break;
}
}
+
+ a_Player->GetStatManager().AddValue(statTreasureFished, 1);
}
else if (ItemCategory <= 14) // Junk 10%
{
@@ -190,6 +201,8 @@ public:
{
Drops.Add(cItem(E_BLOCK_TRIPWIRE_HOOK));
}
+
+ a_Player->GetStatManager().AddValue(statJunkFished, 1);
}
else // Fish
{
@@ -197,7 +210,7 @@ public:
if (FishType <= 1) // Clownfish has a 2% chance of spawning
{
Drops.Add(cItem(E_ITEM_RAW_FISH, 1, E_META_RAW_FISH_CLOWNFISH));
- }
+ }
else if (FishType <= 12) // Pufferfish has a 13% chance of spawning
{
Drops.Add(cItem(E_ITEM_RAW_FISH, 1, E_META_RAW_FISH_CLOWNFISH));
@@ -210,6 +223,8 @@ public:
{
Drops.Add(cItem(E_ITEM_RAW_FISH, 1, E_META_RAW_FISH_FISH));
}
+
+ a_Player->GetStatManager().AddValue(statFishCaught, 1);
}
if (cRoot::Get()->GetPluginManager()->CallHookPlayerFishing(*a_Player, Drops))
@@ -225,9 +240,13 @@ public:
else
{
cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), 100 + a_World->GetTickRandomNumber(800) - (a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100));
- Floater->Initialize(a_World);
+ Floater->Initialize(*a_World);
a_Player->SetIsFishing(true, Floater->GetUniqueID());
}
return true;
}
} ;
+
+
+
+
diff --git a/src/Items/ItemFlowerPot.h b/src/Items/ItemFlowerPot.h
index 60bf87985..320dce997 100644
--- a/src/Items/ItemFlowerPot.h
+++ b/src/Items/ItemFlowerPot.h
@@ -25,7 +25,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemFood.h b/src/Items/ItemFood.h
index 961cf482d..ff1d7991b 100644
--- a/src/Items/ItemFood.h
+++ b/src/Items/ItemFood.h
@@ -26,7 +26,7 @@ public:
virtual FoodInfo GetFoodInfo(void) override
{
- switch(m_ItemType)
+ switch (m_ItemType)
{
// Please keep alpha-sorted.
case E_ITEM_BAKED_POTATO: return FoodInfo(6, 7.2);
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index ce9593a70..d36b5d663 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -19,6 +19,7 @@
#include "ItemCloth.h"
#include "ItemComparator.h"
#include "ItemDoor.h"
+#include "ItemMilk.h"
#include "ItemDye.h"
#include "ItemEmptyMap.h"
#include "ItemFishingRod.h"
@@ -34,6 +35,7 @@
#include "ItemNetherWart.h"
#include "ItemPainting.h"
#include "ItemPickaxe.h"
+#include "ItemPotion.h"
#include "ItemThrowable.h"
#include "ItemRedstoneDust.h"
#include "ItemRedstoneRepeater.h"
@@ -44,6 +46,7 @@
#include "ItemSign.h"
#include "ItemMobHead.h"
#include "ItemSpawnEgg.h"
+#include "ItemString.h"
#include "ItemSugarcane.h"
#include "ItemSword.h"
@@ -62,7 +65,7 @@ cItemHandler * cItemHandler::m_ItemHandler[2268];
cItemHandler * cItemHandler::GetItemHandler(int a_ItemType)
{
- if (a_ItemType < 0)
+ if ((a_ItemType < 0) || ((unsigned long)a_ItemType >= ARRAYCOUNT(m_ItemHandler)))
{
// Either nothing (-1), or bad value, both cases should return the air handler
if (a_ItemType < -1)
@@ -91,7 +94,7 @@ cItemHandler * cItemHandler::GetItemHandler(int a_ItemType)
cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
{
- switch(a_ItemType)
+ switch (a_ItemType)
{
default: return new cItemHandler(a_ItemType);
@@ -119,9 +122,11 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType);
case E_BLOCK_LILY_PAD: return new cItemLilypadHandler(a_ItemType);
case E_ITEM_MAP: return new cItemMapHandler();
+ case E_ITEM_MILK: return new cItemMilkHandler();
case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType);
case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType);
case E_ITEM_PAINTING: return new cItemPaintingHandler(a_ItemType);
+ case E_ITEM_POTIONS: return new cItemPotionHandler();
case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType);
case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemType);
case E_ITEM_SHEARS: return new cItemShearsHandler(a_ItemType);
@@ -129,6 +134,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_HEAD: return new cItemMobHeadHandler(a_ItemType);
case E_ITEM_SNOWBALL: return new cItemSnowballHandler();
case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemType);
+ case E_ITEM_STRING: return new cItemStringHandler(a_ItemType);
case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemType);
case E_ITEM_WOODEN_HOE:
@@ -257,9 +263,10 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
void cItemHandler::Deinit()
{
- for(int i = 0; i < 2267; i++)
+ for (int i = 0; i < 2267; i++)
{
delete m_ItemHandler[i];
+ m_ItemHandler[i] = NULL;
}
memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); // Don't leave any dangling pointers around, just in case
m_HandlerInitialized = false;
@@ -321,15 +328,25 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const
if (a_Player->IsGameModeSurvival())
{
- if (!BlockRequiresSpecialTool(Block) || CanHarvestBlock(Block))
- {
- cChunkInterface ChunkInterface(a_World->GetChunkMap());
- cBlockInServerPluginInterface PluginInterface(*a_World);
- Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ);
- }
+ cChunkInterface ChunkInterface(a_World->GetChunkMap());
+ cBlockInServerPluginInterface PluginInterface(*a_World);
+ Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block), a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0);
}
-
- a_Player->UseEquippedItem();
+
+ if (!cBlockInfo::IsOneHitDig(Block))
+ {
+ a_Player->UseEquippedItem(GetDurabilityLossByAction(dlaBreakBlock));
+ }
+}
+
+
+
+
+
+void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity)
+{
+ UNUSED(a_AttackedEntity);
+ a_Attacker->UseEquippedItem(GetDurabilityLossByAction(dlaAttackEntity));
}
@@ -347,6 +364,20 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I
+short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action)
+{
+ switch ((int)a_Action)
+ {
+ case dlaAttackEntity: return 2;
+ case dlaBreakBlock: return 1;
+ }
+ return 0;
+}
+
+
+
+
+
char cItemHandler::GetMaxStackSize(void)
{
if (m_ItemType < 256)
@@ -355,7 +386,7 @@ char cItemHandler::GetMaxStackSize(void)
return 64;
}
- switch (m_ItemType) //sorted by id
+ switch (m_ItemType)
{
case E_ITEM_ARROW: return 64;
case E_ITEM_BAKED_POTATO: return 64;
@@ -451,14 +482,14 @@ char cItemHandler::GetMaxStackSize(void)
bool cItemHandler::IsTool()
{
// TODO: Rewrite this to list all tools specifically
- return
- (m_ItemType >= 256 && m_ItemType <= 259)
- || (m_ItemType == 261)
- || (m_ItemType >= 267 && m_ItemType <= 279)
- || (m_ItemType >= 283 && m_ItemType <= 286)
- || (m_ItemType >= 290 && m_ItemType <= 294)
- || (m_ItemType == 325)
- || (m_ItemType == 346);
+ return
+ ((m_ItemType >= 256) && (m_ItemType <= 259)) ||
+ (m_ItemType == 261) ||
+ ((m_ItemType >= 267) && (m_ItemType <= 279)) ||
+ ((m_ItemType >= 283) && (m_ItemType <= 286)) ||
+ ((m_ItemType >= 290) && (m_ItemType <= 294)) ||
+ (m_ItemType == 325) ||
+ (m_ItemType == 346);
}
@@ -467,33 +498,17 @@ bool cItemHandler::IsTool()
bool cItemHandler::IsFood(void)
{
- switch (m_ItemType)
- {
- case E_ITEM_RED_APPLE:
- case E_ITEM_GOLDEN_APPLE:
- case E_ITEM_MUSHROOM_SOUP:
- case E_ITEM_BREAD:
- case E_ITEM_RAW_PORKCHOP:
- case E_ITEM_COOKED_PORKCHOP:
- case E_ITEM_MILK:
- case E_ITEM_RAW_FISH:
- case E_ITEM_COOKED_FISH:
- case E_ITEM_COOKIE:
- case E_ITEM_MELON_SLICE:
- case E_ITEM_RAW_BEEF:
- case E_ITEM_STEAK:
- case E_ITEM_RAW_CHICKEN:
- case E_ITEM_COOKED_CHICKEN:
- case E_ITEM_ROTTEN_FLESH:
- case E_ITEM_SPIDER_EYE:
- case E_ITEM_CARROT:
- case E_ITEM_POTATO:
- case E_ITEM_BAKED_POTATO:
- case E_ITEM_POISONOUS_POTATO:
- {
- return true;
- }
- } // switch (m_ItemType)
+ return false;
+}
+
+
+
+
+
+bool cItemHandler::IsDrinkable(short a_ItemDamage)
+{
+ UNUSED(a_ItemDamage);
+
return false;
}
@@ -511,10 +526,10 @@ bool cItemHandler::IsPlaceable(void)
-bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
+
+bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType)
{
- UNUSED(a_BlockType);
-
+ UNUSED(a_ItemType);
return false;
}
@@ -522,9 +537,61 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
+bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
+{
+ switch (a_BlockType)
+ {
+ case E_BLOCK_ANVIL:
+ case E_BLOCK_ENCHANTMENT_TABLE:
+ case E_BLOCK_FURNACE:
+ case E_BLOCK_LIT_FURNACE:
+ case E_BLOCK_COAL_ORE:
+ case E_BLOCK_STONE:
+ case E_BLOCK_COBBLESTONE:
+ case E_BLOCK_END_STONE:
+ case E_BLOCK_MOSSY_COBBLESTONE:
+ case E_BLOCK_SANDSTONE_STAIRS:
+ case E_BLOCK_SANDSTONE:
+ case E_BLOCK_STONE_BRICKS:
+ case E_BLOCK_NETHER_BRICK:
+ case E_BLOCK_NETHERRACK:
+ case E_BLOCK_STONE_SLAB:
+ case E_BLOCK_DOUBLE_STONE_SLAB:
+ case E_BLOCK_STONE_PRESSURE_PLATE:
+ case E_BLOCK_BRICK:
+ case E_BLOCK_COBBLESTONE_STAIRS:
+ case E_BLOCK_COBBLESTONE_WALL:
+ case E_BLOCK_STONE_BRICK_STAIRS:
+ case E_BLOCK_NETHER_BRICK_STAIRS:
+ case E_BLOCK_CAULDRON:
+ case E_BLOCK_OBSIDIAN:
+ case E_BLOCK_DIAMOND_BLOCK:
+ case E_BLOCK_DIAMOND_ORE:
+ case E_BLOCK_GOLD_BLOCK:
+ case E_BLOCK_GOLD_ORE:
+ case E_BLOCK_REDSTONE_ORE:
+ case E_BLOCK_REDSTONE_ORE_GLOWING:
+ case E_BLOCK_EMERALD_ORE:
+ case E_BLOCK_IRON_BLOCK:
+ case E_BLOCK_IRON_ORE:
+ case E_BLOCK_LAPIS_ORE:
+ case E_BLOCK_LAPIS_BLOCK:
+ case E_BLOCK_SNOW:
+ case E_BLOCK_VINES:
+ {
+ return false;
+ }
+ default: return true;
+ }
+}
+
+
+
+
+
bool cItemHandler::GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
)
@@ -541,7 +608,7 @@ bool cItemHandler::GetPlacementBlockTypeMeta(
cChunkInterface ChunkInterface(a_World->GetChunkMap());
return BlockH->GetPlacementBlockTypeMeta(
ChunkInterface, a_Player,
- a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
+ a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
a_CursorX, a_CursorY, a_CursorZ,
a_BlockType, a_BlockMeta
);
@@ -567,7 +634,7 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
cFastRandom r1;
if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0)
{
- a_Player->FoodPoison(300);
+ a_Player->FoodPoison(600); // Give the player food poisoning for 30 seconds.
}
}
diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h
index 4993eac85..1d5f59f3e 100644
--- a/src/Items/ItemHandler.h
+++ b/src/Items/ItemHandler.h
@@ -19,6 +19,13 @@ class cPlayer;
class cItemHandler
{
public:
+
+ enum eDurabilityLostAction
+ {
+ dlaBreakBlock,
+ dlaAttackEntity,
+ };
+
cItemHandler(int a_ItemType);
/** Force virtual destructor */
@@ -28,7 +35,7 @@ public:
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir);
/** Called when the client sends the SHOOT status in the lclk packet */
- virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
+ virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
{
UNUSED(a_BlockX);
UNUSED(a_BlockY);
@@ -48,11 +55,17 @@ public:
virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace);
/** Called when the player destroys a block using this item. This also calls the drop function for the destroyed block */
- virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_X, int a_Y, int a_Z);
+ virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ /** Called when a player attacks a other entity. */
+ virtual void OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity);
/** Called after the player has eaten this item. */
virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item);
-
+
+ /** Get the durability lost which the item will get, when a specified action was performed. */
+ virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action);
+
/** Returns the maximum stack size for a given item */
virtual char GetMaxStackSize(void);
@@ -60,7 +73,7 @@ public:
{
double Saturation;
int FoodLevel;
- int PoisonChance; // 0 - 100, in percent. 0 = no chance of poisoning, 100 = sure poisoning
+ int PoisonChance; // 0 - 100, in percent. 0 = no chance of poisoning, 100 = sure poisoning
FoodInfo(int a_FoodLevel, double a_Saturation, int a_PoisonChance = 0) :
Saturation(a_Saturation),
@@ -82,21 +95,27 @@ public:
/** Indicates if this item is food */
virtual bool IsFood(void);
+ /** Indicates if this item is drinkable */
+ virtual bool IsDrinkable(short a_ItemDamage);
+
/** Blocks simply get placed */
virtual bool IsPlaceable(void);
- /** Called before a block is placed into a world.
+ /** Can the anvil repair this item, when a_Item is the second input? */
+ virtual bool CanRepairWithRawMaterial(short a_ItemType);
+
+ /** Called before a block is placed into a world.
The handler should return true to allow placement, false to refuse.
Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block.
*/
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
);
- /** Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can�t) DEFAULT: False */
+ /** Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can't) DEFAULT: False */
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType);
static cItemHandler * GetItemHandler(int a_ItemType);
@@ -106,11 +125,11 @@ public:
protected:
int m_ItemType;
- static cItemHandler *CreateItemHandler(int m_ItemType);
+ static cItemHandler * CreateItemHandler(int m_ItemType);
static cItemHandler * m_ItemHandler[E_ITEM_LAST + 1];
- static bool m_HandlerInitialized; //used to detect if the itemhandlers are initialized
+ static bool m_HandlerInitialized; // used to detect if the itemhandlers are initialized
};
-//Short function
+// Short function
inline cItemHandler *ItemHandler(int a_ItemType) { return cItemHandler::GetItemHandler(a_ItemType); }
diff --git a/src/Items/ItemHoe.h b/src/Items/ItemHoe.h
index 29f7c83d5..8d0b71478 100644
--- a/src/Items/ItemHoe.h
+++ b/src/Items/ItemHoe.h
@@ -16,7 +16,6 @@ public:
cItemHoeHandler(int a_ItemType)
: cItemHandler(a_ItemType)
{
-
}
virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
@@ -26,13 +25,18 @@ public:
if ((Block == E_BLOCK_DIRT) || (Block == E_BLOCK_GRASS))
{
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FARMLAND, 0);
-
a_Player->UseEquippedItem();
return true;
-
}
+
return false;
}
+
+
+ virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
+ {
+ return 0;
+ }
} ;
diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h
index 27e7dba35..87e20ecf0 100644
--- a/src/Items/ItemItemFrame.h
+++ b/src/Items/ItemItemFrame.h
@@ -27,16 +27,17 @@ public:
return false;
}
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again
if (Block == E_BLOCK_AIR)
{
cItemFrame * ItemFrame = new cItemFrame(a_Dir, a_BlockX, a_BlockY, a_BlockZ);
- if (!ItemFrame->Initialize(a_World))
+ if (!ItemFrame->Initialize(*a_World))
{
delete ItemFrame;
+ ItemFrame = NULL;
return false;
}
diff --git a/src/Items/ItemLeaves.h b/src/Items/ItemLeaves.h
index 12cb45d1c..f48126dc5 100644
--- a/src/Items/ItemLeaves.h
+++ b/src/Items/ItemLeaves.h
@@ -20,7 +20,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@@ -31,7 +31,7 @@ public:
a_CursorX, a_CursorY, a_CursorZ,
a_BlockType, a_BlockMeta
);
- a_BlockMeta = a_BlockMeta | 0x4; //0x4 bit set means this is a player-placed leaves block, not to be decayed
+ a_BlockMeta = a_BlockMeta | 0x4; // 0x4 bit set means this is a player-placed leaves block, not to be decayed
return res;
}
} ;
diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h
index 32f49cab6..9f98bf85f 100644
--- a/src/Items/ItemLighter.h
+++ b/src/Items/ItemLighter.h
@@ -52,8 +52,8 @@ public:
case E_BLOCK_TNT:
{
// Activate the TNT:
- a_World->BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 1.0f);
- a_World->SetBlock(a_BlockX,a_BlockY,a_BlockZ, E_BLOCK_AIR, 0);
+ a_World->BroadcastSoundEffect("game.tnt.primed", (double)a_BlockX, (double)a_BlockY, (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
break;
}
@@ -68,7 +68,7 @@ public:
if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR)
{
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
- a_World->BroadcastSoundEffect("fire.ignite", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0F, 1.04F);
+ a_World->BroadcastSoundEffect("fire.ignite", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0F, 1.04F);
break;
}
}
diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h
index 8fc1d8543..b9d837384 100644
--- a/src/Items/ItemLilypad.h
+++ b/src/Items/ItemLilypad.h
@@ -25,7 +25,7 @@ public:
virtual bool IsPlaceable(void) override
{
- return false; // Set as not placeable so OnItemUse is called
+ return false; // Set as not placeable so OnItemUse is called
}
@@ -47,9 +47,9 @@ public:
public cBlockTracer::cCallbacks
{
public:
- cCallbacks(cWorld * a_CBWorld) :
- m_HasHitFluid(false),
- m_World(a_CBWorld)
+
+ cCallbacks(void) :
+ m_HasHitFluid(false)
{
}
@@ -57,15 +57,14 @@ public:
{
if (IsBlockWater(a_CBBlockType))
{
- if ((a_CBBlockMeta != 0) || (a_CBEntryFace == BLOCK_FACE_NONE)) // The hit block should be a source. The FACE_NONE check is clicking whilst submerged
+ if ((a_CBBlockMeta != 0) || (a_CBEntryFace == BLOCK_FACE_NONE)) // The hit block should be a source. The FACE_NONE check is clicking whilst submerged
{
return false;
}
AddFaceDirection(a_CBBlockX, a_CBBlockY, a_CBBlockZ, BLOCK_FACE_YP); // Always place pad at top of water block
- BLOCKTYPE Block = m_World->GetBlock(a_CBBlockX, a_CBBlockY, a_CBBlockZ);
if (
- !IsBlockWater(Block) &&
- cBlockInfo::FullyOccupiesVoxel(Block)
+ !IsBlockWater(a_CBBlockType) &&
+ cBlockInfo::FullyOccupiesVoxel(a_CBBlockType)
)
{
// Can't place lilypad on air/in another block!
@@ -80,11 +79,10 @@ public:
Vector3i m_Pos;
bool m_HasHitFluid;
- cWorld * m_World;
};
- cCallbacks Callbacks(a_World);
+ cCallbacks Callbacks;
cLineBlockTracer Tracer(*a_Player->GetWorld(), Callbacks);
Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector());
Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5);
diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h
new file mode 100644
index 000000000..db7bc13be
--- /dev/null
+++ b/src/Items/ItemMilk.h
@@ -0,0 +1,28 @@
+
+#pragma once
+
+class cItemMilkHandler:
+ public cItemHandler
+{
+ typedef cItemHandler super;
+public:
+ cItemMilkHandler():
+ super(E_ITEM_MILK)
+ {
+ }
+
+ virtual bool IsDrinkable(short a_ItemDamage) override
+ {
+ UNUSED(a_ItemDamage);
+ return true;
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ UNUSED(a_Item);
+ a_Player->ClearEntityEffects();
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ a_Player->GetInventory().AddItem(E_ITEM_BUCKET);
+ return true;
+ }
+};
diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h
index 25500aeb9..63038de51 100644
--- a/src/Items/ItemMinecart.h
+++ b/src/Items/ItemMinecart.h
@@ -70,7 +70,7 @@ public:
return false;
}
} // switch (m_ItemType)
- Minecart->Initialize(a_World);
+ Minecart->Initialize(*a_World);
if (!a_Player->IsGameModeCreative())
{
@@ -78,7 +78,7 @@ public:
}
return true;
}
-
+
} ;
diff --git a/src/Items/ItemMobHead.h b/src/Items/ItemMobHead.h
index 5ae040282..4c36fe8d8 100644
--- a/src/Items/ItemMobHead.h
+++ b/src/Items/ItemMobHead.h
@@ -26,7 +26,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemNetherWart.h b/src/Items/ItemNetherWart.h
index a6a9a286a..10a0864b5 100644
--- a/src/Items/ItemNetherWart.h
+++ b/src/Items/ItemNetherWart.h
@@ -25,7 +25,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemPainting.h b/src/Items/ItemPainting.h
index b85098221..a2a77ce21 100644
--- a/src/Items/ItemPainting.h
+++ b/src/Items/ItemPainting.h
@@ -27,9 +27,9 @@ public:
return false;
}
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again
if (Block == E_BLOCK_AIR)
{
@@ -38,14 +38,14 @@ public:
// The client uses different values for painting directions and block faces. Our constants are for the block faces, so we convert them here to painting faces
switch (a_Dir)
{
- case BLOCK_FACE_ZP: break; // Initialised to zero
+ case BLOCK_FACE_ZP: break; // Initialised to zero
case BLOCK_FACE_ZM: Dir = 2; break;
case BLOCK_FACE_XM: Dir = 1; break;
case BLOCK_FACE_XP: Dir = 3; break;
default: ASSERT(!"Unhandled block face when trying spawn painting!"); return false;
}
- static const struct // Define all the possible painting titles
+ static const struct // Define all the possible painting titles
{
AString Title;
} gPaintingTitlesList[] =
@@ -79,7 +79,7 @@ public:
};
cPainting * Painting = new cPainting(gPaintingTitlesList[a_World->GetTickRandomNumber(ARRAYCOUNT(gPaintingTitlesList) - 1)].Title, Dir, a_BlockX, a_BlockY, a_BlockZ);
- Painting->Initialize(a_World);
+ Painting->Initialize(*a_World);
if (!a_Player->IsGameModeCreative())
{
diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h
index 2a8e40daa..17fd96822 100644
--- a/src/Items/ItemPickaxe.h
+++ b/src/Items/ItemPickaxe.h
@@ -8,6 +8,7 @@
class cItemPickaxeHandler :
public cItemHandler
{
+ typedef cItemHandler super;
public:
cItemPickaxeHandler(int a_ItemType)
: cItemHandler(a_ItemType)
@@ -17,7 +18,7 @@ public:
char PickaxeLevel()
{
- switch(m_ItemType)
+ switch (m_ItemType)
{
case E_ITEM_WOODEN_PICKAXE: return 1;
case E_ITEM_GOLD_PICKAXE: return 1;
@@ -31,7 +32,7 @@ public:
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
{
- switch(a_BlockType)
+ switch (a_BlockType)
{
case E_BLOCK_OBSIDIAN:
{
@@ -76,6 +77,7 @@ public:
case E_BLOCK_STONE_PRESSURE_PLATE:
case E_BLOCK_BRICK:
case E_BLOCK_COBBLESTONE_STAIRS:
+ case E_BLOCK_COBBLESTONE_WALL:
case E_BLOCK_STONE_BRICK_STAIRS:
case E_BLOCK_NETHER_BRICK_STAIRS:
case E_BLOCK_CAULDRON:
@@ -83,6 +85,19 @@ public:
return PickaxeLevel() >= 1;
}
}
+ return super::CanHarvestBlock(a_BlockType);
+ }
+
+ virtual bool CanRepairWithRawMaterial(short a_ItemType) override
+ {
+ switch (m_ItemType)
+ {
+ case E_ITEM_WOODEN_PICKAXE: return (a_ItemType == E_BLOCK_PLANKS);
+ case E_ITEM_STONE_PICKAXE: return (a_ItemType == E_BLOCK_COBBLESTONE);
+ case E_ITEM_IRON_PICKAXE: return (a_ItemType == E_ITEM_IRON);
+ case E_ITEM_GOLD_PICKAXE: return (a_ItemType == E_ITEM_GOLD);
+ case E_ITEM_DIAMOND_PICKAXE: return (a_ItemType == E_ITEM_DIAMOND);
+ }
return false;
}
} ;
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
new file mode 100644
index 000000000..24614cd8a
--- /dev/null
+++ b/src/Items/ItemPotion.h
@@ -0,0 +1,79 @@
+
+#pragma once
+
+#include "../Entities/EntityEffect.h"
+#include "../Entities/SplashPotionEntity.h"
+
+class cItemPotionHandler:
+ public cItemHandler
+{
+ typedef cItemHandler super;
+
+public:
+
+ cItemPotionHandler():
+ super(E_ITEM_POTION)
+ {
+ }
+
+
+ // cItemHandler overrides:
+ virtual bool IsDrinkable(short a_ItemDamage) override
+ {
+ // Drinkable potion if 13th lowest bit is set
+ // Ref.: http://minecraft.gamepedia.com/Potions#Data_value_table
+ return cEntityEffect::IsPotionDrinkable(a_ItemDamage);
+ }
+
+
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
+ {
+ short PotionDamage = a_Item.m_ItemDamage;
+
+ // Do not throw non-splash potions:
+ if (cEntityEffect::IsPotionDrinkable(PotionDamage))
+ {
+ return false;
+ }
+
+ Vector3d Pos = a_Player->GetThrowStartPos();
+ Vector3d Speed = a_Player->GetLookVector() * 7;
+
+ if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, cProjectileEntity::pkSplashPotion, a_Player, &a_Player->GetEquippedItem(), &Speed) < 0)
+ {
+ return false;
+ }
+
+ if (!a_Player->IsGameModeCreative())
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ }
+
+ return true;
+ }
+
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ short PotionDamage = a_Item->m_ItemDamage;
+
+ // Do not drink undrinkable potions:
+ if (!cEntityEffect::IsPotionDrinkable(a_Item->m_ItemDamage))
+ {
+ return false;
+ }
+
+ a_Player->AddEntityEffect(
+ cEntityEffect::GetPotionEffectType(PotionDamage),
+ cEntityEffect::GetPotionEffectDuration(PotionDamage),
+ cEntityEffect::GetPotionEffectIntensity(PotionDamage)
+ );
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE);
+ return true;
+ }
+};
+
+
+
+
diff --git a/src/Items/ItemRedstoneDust.h b/src/Items/ItemRedstoneDust.h
index 274d905a5..a2289239c 100644
--- a/src/Items/ItemRedstoneDust.h
+++ b/src/Items/ItemRedstoneDust.h
@@ -22,12 +22,12 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
- if (!cBlockInfo::FullyOccupiesVoxel(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) // Some solid blocks, such as cocoa beans, are not suitable for dust
+ if (!cBlockInfo::FullyOccupiesVoxel(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) // Some solid blocks, such as cocoa beans, are not suitable for dust
{
return false;
}
diff --git a/src/Items/ItemRedstoneRepeater.h b/src/Items/ItemRedstoneRepeater.h
index c5fb5d566..13a797d00 100644
--- a/src/Items/ItemRedstoneRepeater.h
+++ b/src/Items/ItemRedstoneRepeater.h
@@ -24,7 +24,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemSapling.h b/src/Items/ItemSapling.h
index 61b1a32be..dbcb12be5 100644
--- a/src/Items/ItemSapling.h
+++ b/src/Items/ItemSapling.h
@@ -20,7 +20,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h
index 7283edcee..54a1183d7 100644
--- a/src/Items/ItemSeeds.h
+++ b/src/Items/ItemSeeds.h
@@ -25,12 +25,12 @@ public:
virtual bool IsFood(void) override
{
- switch (m_ItemType) // Special cases, both a seed and food
+ switch (m_ItemType) // Special cases, both a seed and food
{
case E_ITEM_CARROT:
case E_ITEM_POTATO: return true;
default: return false;
- }
+ }
}
virtual FoodInfo GetFoodInfo(void) override
@@ -40,12 +40,12 @@ public:
case E_ITEM_CARROT: return FoodInfo(4, 4.8);
case E_ITEM_POTATO: return FoodInfo(1, 0.6);
default: return FoodInfo(0, 0);
- }
+ }
}
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h
index 39d2776fa..fa2794df2 100644
--- a/src/Items/ItemShears.h
+++ b/src/Items/ItemShears.h
@@ -12,6 +12,7 @@
class cItemShearsHandler :
public cItemHandler
{
+ typedef cItemHandler super;
public:
cItemShearsHandler(int a_ItemType) :
cItemHandler(a_ItemType)
@@ -30,8 +31,12 @@ public:
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
if ((Block == E_BLOCK_LEAVES) || (Block == E_BLOCK_NEW_LEAVES))
{
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ cBlockHandler * Handler = cBlockInfo::GetHandler(Block);
+
cItems Drops;
- Drops.push_back(cItem(Block, 1, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x03));
+ Handler->ConvertToPickups(Drops, Meta);
+ Drops.push_back(cItem(Block, 1, Meta & 3));
a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
@@ -54,7 +59,25 @@ public:
return true;
}
} // switch (a_BlockType)
- return false;
+ return super::CanHarvestBlock(a_BlockType);
+ }
+
+
+ virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
+ {
+ return 0;
+ }
+
+
+ virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ super::OnBlockDestroyed(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ);
+
+ BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ if ((Block == E_BLOCK_TRIPWIRE) || (Block == E_BLOCK_VINES))
+ {
+ a_Player->UseEquippedItem();
+ }
}
} ;
diff --git a/src/Items/ItemShovel.h b/src/Items/ItemShovel.h
index 873d5ae25..7d5760fa9 100644
--- a/src/Items/ItemShovel.h
+++ b/src/Items/ItemShovel.h
@@ -14,6 +14,7 @@
class cItemShovelHandler : public cItemHandler
{
+ typedef cItemHandler super;
public:
cItemShovelHandler(int a_ItemType)
: cItemHandler(a_ItemType)
@@ -28,7 +29,7 @@ public:
{
cChunkInterface ChunkInterface(a_World->GetChunkMap());
cBlockInServerPluginInterface PluginInterface(*a_World);
- BlockHandler(Block)->DropBlock(ChunkInterface,*a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ);
+ BlockHandler(Block)->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
a_Player->UseEquippedItem();
@@ -39,6 +40,24 @@ public:
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
{
- return (a_BlockType == E_BLOCK_SNOW);
+ if (a_BlockType == E_BLOCK_SNOW)
+ {
+ return true;
+ }
+ return super::CanHarvestBlock(a_BlockType);
+ }
+
+ virtual bool CanRepairWithRawMaterial(short a_ItemType) override
+ {
+ switch (m_ItemType)
+ {
+ case E_ITEM_WOODEN_SHOVEL: return (a_ItemType == E_BLOCK_PLANKS);
+ case E_ITEM_STONE_SHOVEL: return (a_ItemType == E_BLOCK_COBBLESTONE);
+ case E_ITEM_IRON_SHOVEL: return (a_ItemType == E_ITEM_IRON);
+ case E_ITEM_GOLD_SHOVEL: return (a_ItemType == E_ITEM_GOLD);
+ case E_ITEM_DIAMOND_SHOVEL: return (a_ItemType == E_ITEM_DIAMOND);
+ }
+ return false;
}
+
};
diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h
index 60cf0f5f8..0fa0fa0be 100644
--- a/src/Items/ItemSign.h
+++ b/src/Items/ItemSign.h
@@ -3,7 +3,8 @@
#include "ItemHandler.h"
#include "../World.h"
-#include "../Blocks/BlockSign.h"
+#include "../Blocks/BlockSignPost.h"
+#include "../Blocks/BlockWallSign.h"
@@ -27,19 +28,19 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
if (a_BlockFace == BLOCK_FACE_TOP)
{
- a_BlockMeta = cBlockSignHandler::RotationToMetaData(a_Player->GetYaw());
+ a_BlockMeta = cBlockSignPostHandler::RotationToMetaData(a_Player->GetYaw());
a_BlockType = E_BLOCK_SIGN_POST;
}
else
{
- a_BlockMeta = cBlockSignHandler::DirectionToMetaData(a_BlockFace);
+ a_BlockMeta = cBlockWallSignHandler::DirectionToMetaData(a_BlockFace);
a_BlockType = E_BLOCK_WALLSIGN;
}
return true;
diff --git a/src/Items/ItemSpawnEgg.h b/src/Items/ItemSpawnEgg.h
index 0d6019398..bba97afa1 100644
--- a/src/Items/ItemSpawnEgg.h
+++ b/src/Items/ItemSpawnEgg.h
@@ -33,7 +33,10 @@ public:
a_BlockY--;
}
- if (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, (cMonster::eType)(a_Item.m_ItemDamage)) >= 0)
+ cMonster::eType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage);
+ if (
+ (MonsterType != cMonster::mtInvalidType) && // Valid monster type
+ (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, MonsterType) >= 0)) // Spawning succeeded
{
if (!a_Player->IsGameModeCreative())
{
@@ -45,6 +48,41 @@ public:
return false;
}
+
+
+ /** Converts the Spawn egg item damage to the monster type to spawn.
+ Returns mtInvalidType for invalid damage values. */
+ static cMonster::eType ItemDamageToMonsterType(short a_ItemDamage)
+ {
+ switch (a_ItemDamage)
+ {
+ case E_META_SPAWN_EGG_BAT: return cMonster::mtBat;
+ case E_META_SPAWN_EGG_BLAZE: return cMonster::mtBlaze;
+ case E_META_SPAWN_EGG_CAVE_SPIDER: return cMonster::mtCaveSpider;
+ case E_META_SPAWN_EGG_CHICKEN: return cMonster::mtChicken;
+ case E_META_SPAWN_EGG_COW: return cMonster::mtCow;
+ case E_META_SPAWN_EGG_CREEPER: return cMonster::mtCreeper;
+ case E_META_SPAWN_EGG_ENDERMAN: return cMonster::mtEnderman;
+ case E_META_SPAWN_EGG_GHAST: return cMonster::mtGhast;
+ case E_META_SPAWN_EGG_HORSE: return cMonster::mtHorse;
+ case E_META_SPAWN_EGG_MAGMA_CUBE: return cMonster::mtMagmaCube;
+ case E_META_SPAWN_EGG_MOOSHROOM: return cMonster::mtMooshroom;
+ case E_META_SPAWN_EGG_OCELOT: return cMonster::mtOcelot;
+ case E_META_SPAWN_EGG_PIG: return cMonster::mtPig;
+ case E_META_SPAWN_EGG_SHEEP: return cMonster::mtSheep;
+ case E_META_SPAWN_EGG_SILVERFISH: return cMonster::mtSilverfish;
+ case E_META_SPAWN_EGG_SKELETON: return cMonster::mtSkeleton;
+ case E_META_SPAWN_EGG_SLIME: return cMonster::mtSlime;
+ case E_META_SPAWN_EGG_SPIDER: return cMonster::mtSpider;
+ case E_META_SPAWN_EGG_SQUID: return cMonster::mtSquid;
+ case E_META_SPAWN_EGG_VILLAGER: return cMonster::mtVillager;
+ case E_META_SPAWN_EGG_WITCH: return cMonster::mtWitch;
+ case E_META_SPAWN_EGG_WOLF: return cMonster::mtWolf;
+ case E_META_SPAWN_EGG_ZOMBIE: return cMonster::mtZombie;
+ case E_META_SPAWN_EGG_ZOMBIE_PIGMAN: return cMonster::mtZombiePigman;
+ }
+ return cMonster::mtInvalidType;
+ }
} ;
diff --git a/src/Items/ItemString.h b/src/Items/ItemString.h
new file mode 100644
index 000000000..a97fbe0ce
--- /dev/null
+++ b/src/Items/ItemString.h
@@ -0,0 +1,39 @@
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemStringHandler :
+ public cItemHandler
+{
+public:
+ cItemStringHandler(int a_ItemType) :
+ cItemHandler(a_ItemType)
+ {
+ }
+
+ virtual bool IsPlaceable(void) override
+ {
+ return true;
+ }
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = E_BLOCK_TRIPWIRE;
+ a_BlockMeta = 0;
+ return true;
+ }
+};
+
+
+
+
diff --git a/src/Items/ItemSugarcane.h b/src/Items/ItemSugarcane.h
index e891cc367..dd2e2ece3 100644
--- a/src/Items/ItemSugarcane.h
+++ b/src/Items/ItemSugarcane.h
@@ -23,7 +23,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h
index a7c1d2432..2b2dbfc0d 100644
--- a/src/Items/ItemSword.h
+++ b/src/Items/ItemSword.h
@@ -12,16 +12,46 @@
class cItemSwordHandler :
public cItemHandler
{
+ typedef cItemHandler super;
public:
cItemSwordHandler(int a_ItemType)
: cItemHandler(a_ItemType)
{
-
}
-
+
+
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
{
- return (a_BlockType == E_BLOCK_COBWEB);
+ if (a_BlockType == E_BLOCK_COBWEB)
+ {
+ return true;
+ }
+ return super::CanHarvestBlock(a_BlockType);
+ }
+
+
+ virtual bool CanRepairWithRawMaterial(short a_ItemType) override
+ {
+ switch (m_ItemType)
+ {
+ case E_ITEM_WOODEN_SWORD: return (a_ItemType == E_BLOCK_PLANKS);
+ case E_ITEM_STONE_SWORD: return (a_ItemType == E_BLOCK_COBBLESTONE);
+ case E_ITEM_IRON_SWORD: return (a_ItemType == E_ITEM_IRON);
+ case E_ITEM_GOLD_SWORD: return (a_ItemType == E_ITEM_GOLD);
+ case E_ITEM_DIAMOND_SWORD: return (a_ItemType == E_ITEM_DIAMOND);
+ }
+ return false;
+ }
+
+
+ virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
+ {
+ switch ((int)a_Action)
+ {
+ case dlaAttackEntity: return 1;
+ case dlaBreakBlock: return 2;
+ }
+ return 0;
}
} ;
diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h
index c6a4e714e..c151c5d3a 100644
--- a/src/Items/ItemThrowable.h
+++ b/src/Items/ItemThrowable.h
@@ -28,15 +28,23 @@ public:
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
{
+ Vector3d Pos = a_Player->GetThrowStartPos();
+ Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff;
+
+ // Play sound
+ cFastRandom Random;
+ a_World->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / (Random.NextFloat(1.0f) * 0.4f + 0.8f));
+
+ if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem(), &Speed) < 0)
+ {
+ return false;
+ }
+
if (!a_Player->IsGameModeCreative())
{
a_Player->GetInventory().RemoveOneEquippedItem();
}
- Vector3d Pos = a_Player->GetThrowStartPos();
- Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff;
- a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed);
-
return true;
}
@@ -127,7 +135,10 @@ public:
return false;
}
- a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem());
+ if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem()) < 0)
+ {
+ return false;
+ }
if (!a_Player->IsGameModeCreative())
{
diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp
index 5ba2940d2..3fbbee6b5 100644
--- a/src/LightingThread.cpp
+++ b/src/LightingThread.cpp
@@ -18,20 +18,18 @@
class cReader :
public cChunkDataCallback
{
- virtual void BlockTypes(const BLOCKTYPE * a_Type) override
+ virtual void ChunkData(const cChunkData & a_ChunkBuffer) override
{
- // ROW is a block of 16 Blocks, one whole row is copied at a time (hopefully the compiler will optimize that)
- // C++ doesn't permit copying arrays, but arrays as a part of a struct is ok :)
- typedef struct {BLOCKTYPE m_Row[16]; } ROW;
- ROW * InputRows = (ROW *)a_Type;
- ROW * OutputRows = (ROW *)m_BlockTypes;
+ BLOCKTYPE * OutputRows = m_BlockTypes;
int InputIdx = 0;
int OutputIdx = m_ReadingChunkX + m_ReadingChunkZ * cChunkDef::Width * 3;
- for (int y = 0; y < cChunkDef::Height; y++)
+ int MaxHeight = std::min(+cChunkDef::Height, m_MaxHeight + 16); // Need 16 blocks above the highest
+ for (int y = 0; y < MaxHeight; y++)
{
for (int z = 0; z < cChunkDef::Width; z++)
{
- OutputRows[OutputIdx] = InputRows[InputIdx++];
+ a_ChunkBuffer.CopyBlockTypes(OutputRows + OutputIdx * 16, InputIdx * 16, 16);
+ InputIdx++;
OutputIdx += 3;
} // for z
// Skip into the next y-level in the 3x3 chunk blob; each level has cChunkDef::Width * 9 rows
@@ -43,6 +41,7 @@ class cReader :
virtual void HeightMap(const cChunkDef::HeightMap * a_Heightmap) override
{
+ // Copy the entire heightmap, distribute it into the 3x3 chunk blob:
typedef struct {HEIGHTTYPE m_Row[16]; } ROW;
ROW * InputRows = (ROW *)a_Heightmap;
ROW * OutputRows = (ROW *)m_HeightMap;
@@ -53,20 +52,39 @@ class cReader :
OutputRows[OutputIdx] = InputRows[InputIdx++];
OutputIdx += 3;
} // for z
+
+ // Find the highest block in the entire chunk, use it as a base for m_MaxHeight:
+ HEIGHTTYPE MaxHeight = m_MaxHeight;
+ for (size_t i = 0; i < ARRAYCOUNT(*a_Heightmap); i++)
+ {
+ if ((*a_Heightmap)[i] > MaxHeight)
+ {
+ MaxHeight = (*a_Heightmap)[i];
+ }
+ }
+ m_MaxHeight = MaxHeight;
}
public:
int m_ReadingChunkX; // 0, 1 or 2; x-offset of the chunk we're reading from the BlockTypes start
int m_ReadingChunkZ; // 0, 1 or 2; z-offset of the chunk we're reading from the BlockTypes start
+ HEIGHTTYPE m_MaxHeight; // Maximum value in this chunk's heightmap
BLOCKTYPE * m_BlockTypes; // 3x3 chunks of block types, organized as a single XZY blob of data (instead of 3x3 XZY blobs)
HEIGHTTYPE * m_HeightMap; // 3x3 chunks of height map, organized as a single XZY blob of data (instead of 3x3 XZY blobs)
+
+ cReader(BLOCKTYPE * a_BlockTypes, HEIGHTTYPE * a_HeightMap) :
+ m_MaxHeight(0),
+ m_BlockTypes(a_BlockTypes),
+ m_HeightMap(a_HeightMap)
+ {
+ }
} ;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cLightingThread:
cLightingThread::cLightingThread(void) :
@@ -106,11 +124,13 @@ void cLightingThread::Stop(void)
cCSLock Lock(m_CS);
for (cChunkStays::iterator itr = m_PendingQueue.begin(), end = m_PendingQueue.end(); itr != end; ++itr)
{
+ (*itr)->Disable();
delete *itr;
}
m_PendingQueue.clear();
for (cChunkStays::iterator itr = m_Queue.begin(), end = m_Queue.end(); itr != end; ++itr)
{
+ (*itr)->Disable();
delete *itr;
}
m_Queue.clear();
@@ -225,7 +245,7 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item)
// DEBUG: Save chunk data with highlighted seeds for visual inspection:
cFile f4;
if (
- f4.Open(Printf("Chunk_%d_%d_seeds.grab", a_Item.x, a_Item.z), cFile::fmWrite)
+ f4.Open(Printf("Chunk_%d_%d_seeds.grab", a_Item.m_ChunkX, a_Item.m_ChunkZ), cFile::fmWrite)
)
{
for (int z = 0; z < cChunkDef::Width * 3; z++)
@@ -244,6 +264,7 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item)
f4.Write(Seeds, cChunkDef::Width * 3);
}
}
+ f4.Close();
}
//*/
@@ -253,9 +274,9 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item)
// DEBUG: Save XY slices of the chunk data and lighting for visual inspection:
cFile f1, f2, f3;
if (
- f1.Open(Printf("Chunk_%d_%d_data.grab", a_Item.x, a_Item.z), cFile::fmWrite) &&
- f2.Open(Printf("Chunk_%d_%d_sky.grab", a_Item.x, a_Item.z), cFile::fmWrite) &&
- f3.Open(Printf("Chunk_%d_%d_glow.grab", a_Item.x, a_Item.z), cFile::fmWrite)
+ f1.Open(Printf("Chunk_%d_%d_data.grab", a_Item.m_ChunkX, a_Item.m_ChunkZ), cFile::fmWrite) &&
+ f2.Open(Printf("Chunk_%d_%d_sky.grab", a_Item.m_ChunkX, a_Item.m_ChunkZ), cFile::fmWrite) &&
+ f3.Open(Printf("Chunk_%d_%d_glow.grab", a_Item.m_ChunkX, a_Item.m_ChunkZ), cFile::fmWrite)
)
{
for (int z = 0; z < cChunkDef::Width * 3; z++)
@@ -274,6 +295,9 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item)
f3.Write(BlockLight, cChunkDef::Width * 3);
}
}
+ f1.Close();
+ f2.Close();
+ f3.Close();
}
//*/
@@ -294,11 +318,9 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item)
-bool cLightingThread::ReadChunks(int a_ChunkX, int a_ChunkZ)
+void cLightingThread::ReadChunks(int a_ChunkX, int a_ChunkZ)
{
- cReader Reader;
- Reader.m_BlockTypes = m_BlockTypes;
- Reader.m_HeightMap = m_HeightMap;
+ cReader Reader(m_BlockTypes, m_HeightMap);
for (int z = 0; z < 3; z++)
{
@@ -306,16 +328,13 @@ bool cLightingThread::ReadChunks(int a_ChunkX, int a_ChunkZ)
for (int x = 0; x < 3; x++)
{
Reader.m_ReadingChunkX = x;
- if (!m_World->GetChunkData(a_ChunkX + x - 1, a_ChunkZ + z - 1, Reader))
- {
- return false;
- }
+ VERIFY(m_World->GetChunkData(a_ChunkX + x - 1, a_ChunkZ + z - 1, Reader));
} // for z
} // for x
memset(m_BlockLight, 0, sizeof(m_BlockLight));
memset(m_SkyLight, 0, sizeof(m_SkyLight));
- return true;
+ m_MaxHeight = Reader.m_MaxHeight;
}
@@ -406,6 +425,50 @@ void cLightingThread::PrepareBlockLight(void)
+void cLightingThread::PrepareBlockLight2(void)
+{
+ // Clear seeds:
+ memset(m_IsSeed1, 0, sizeof(m_IsSeed1));
+ memset(m_IsSeed2, 0, sizeof(m_IsSeed2));
+ m_NumSeeds = 0;
+
+ // Add each emissive block into the seeds:
+ for (int y = 0; y < m_MaxHeight; y++)
+ {
+ int BaseY = y * BlocksPerYLayer; // Partial offset into m_BlockTypes for the Y coord
+ for (int z = 1; z < cChunkDef::Width * 3 - 1; z++)
+ {
+ int HBaseZ = z * cChunkDef::Width * 3; // Partial offset into m_Heightmap for the Z coord
+ int BaseZ = BaseY + HBaseZ; // Partial offset into m_BlockTypes for the Y and Z coords
+ for (int x = 1; x < cChunkDef::Width * 3 - 1; x++)
+ {
+ int idx = BaseZ + x;
+ if (y > m_HeightMap[HBaseZ + x])
+ {
+ // We're above the heightmap, ignore the block
+ continue;
+ }
+ if (cBlockInfo::GetLightValue(m_BlockTypes[idx]) == 0)
+ {
+ // Not a light-emissive block
+ continue;
+ }
+
+ // Add current block as a seed:
+ m_IsSeed1[idx] = true;
+ m_SeedIdx1[m_NumSeeds++] = idx;
+
+ // Light it up:
+ m_BlockLight[idx] = cBlockInfo::GetLightValue(m_BlockTypes[idx]);
+ }
+ }
+ }
+}
+
+
+
+
+
void cLightingThread::CalcLight(NIBBLETYPE * a_Light)
{
int NumSeeds2 = 0;
@@ -432,7 +495,7 @@ void cLightingThread::CalcLight(NIBBLETYPE * a_Light)
void cLightingThread::CalcLightStep(
- NIBBLETYPE * a_Light,
+ NIBBLETYPE * a_Light,
int a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn,
int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
)
@@ -519,7 +582,7 @@ void cLightingThread::QueueChunkStay(cLightingChunkStay & a_ChunkStay)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cLightingThread::cLightingChunkStay:
cLightingThread::cLightingChunkStay::cLightingChunkStay(cLightingThread & a_LightingThread, int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_CallbackAfter) :
diff --git a/src/LightingThread.h b/src/LightingThread.h
index 770ae809f..f71d2cf1a 100644
--- a/src/LightingThread.h
+++ b/src/LightingThread.h
@@ -16,7 +16,7 @@ Lighting is calculated in a flood-fill fashion:
The seeds need two fast operations:
- Check if a block at [x, y, z] is already a seed
- Get the next seed in the row
-For that reason it is stored in two arrays, one stores a bool saying a seed is in that position,
+For that reason it is stored in two arrays, one stores a bool saying a seed is in that position,
the other is an array of seed coords, encoded as a single int.
Step 2 needs two separate storages for old seeds and new seeds, so there are two actual storages for that purpose,
their content is swapped after each full step-2-cycle.
@@ -82,7 +82,7 @@ protected:
cLightingChunkStay(cLightingThread & a_LightingThread, int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_CallbackAfter);
protected:
- virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override
+ virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override
{
UNUSED(a_ChunkX);
UNUSED(a_ChunkZ);
@@ -108,6 +108,9 @@ protected:
cEvent m_evtItemAdded; // Set when queue is appended, or to stop the thread
cEvent m_evtQueueEmpty; // Set when the queue gets empty
+ /** The highest block in the current 3x3 chunk data */
+ HEIGHTTYPE m_MaxHeight;
+
// Buffers for the 3x3 chunk data
// These buffers alone are 1.7 MiB in size, therefore they cannot be located on the stack safely - some architectures may have only 1 MiB for stack, or even less
@@ -136,8 +139,8 @@ protected:
/** Lights the entire chunk. If neighbor chunks don't exist, touches them and re-queues the chunk */
void LightChunk(cLightingChunkStay & a_Item);
- /** Prepares m_BlockTypes and m_HeightMap data; returns false if any of the chunks fail. Zeroes out the light arrays */
- bool ReadChunks(int a_ChunkX, int a_ChunkZ);
+ /** Prepares m_BlockTypes and m_HeightMap data; zeroes out the light arrays */
+ void ReadChunks(int a_ChunkX, int a_ChunkZ);
/** Uses m_HeightMap to initialize the m_SkyLight[] data; fills in seeds for the skylight */
void PrepareSkyLight(void);
@@ -145,12 +148,16 @@ protected:
/** Uses m_BlockTypes to initialize the m_BlockLight[] data; fills in seeds for the blocklight */
void PrepareBlockLight(void);
+ /** Same as PrepareBlockLight(), but uses a different traversal scheme; possibly better perf cache-wise.
+ To be compared in perf benchmarks. */
+ void PrepareBlockLight2(void);
+
/** Calculates light in the light array specified, using stored seeds */
void CalcLight(NIBBLETYPE * a_Light);
/** Does one step in the light calculation - one seed propagation and seed recalculation */
void CalcLightStep(
- NIBBLETYPE * a_Light,
+ NIBBLETYPE * a_Light,
int a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn,
int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
);
@@ -159,7 +166,7 @@ protected:
void CompressLight(NIBBLETYPE * a_LightArray, NIBBLETYPE * a_ChunkLight);
inline void PropagateLight(
- NIBBLETYPE * a_Light,
+ NIBBLETYPE * a_Light,
unsigned int a_SrcIdx, unsigned int a_DstIdx,
int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
)
diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp
index b03652bab..f03e796d1 100644
--- a/src/LineBlockTracer.cpp
+++ b/src/LineBlockTracer.cpp
@@ -203,54 +203,55 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk)
m_Callbacks->OnNoChunk();
return false;
}
- if (a_Chunk->IsValid())
+
+ // Move to next block
+ if (!MoveToNextBlock())
{
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- int RelX = m_CurrentX - a_Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = m_CurrentZ - a_Chunk->GetPosZ() * cChunkDef::Width;
- a_Chunk->GetBlockTypeMeta(RelX, m_CurrentY, RelZ, BlockType, BlockMeta);
- if (m_Callbacks->OnNextBlock(m_CurrentX, m_CurrentY, m_CurrentZ, BlockType, BlockMeta, m_CurrentFace))
- {
- // The callback terminated the trace
- return false;
- }
+ // We've reached the end
+ m_Callbacks->OnNoMoreHits();
+ return true;
}
- else
+
+ if ((m_CurrentY < 0) || (m_CurrentY >= cChunkDef::Height))
{
- if (m_Callbacks->OnNextBlockNoData(m_CurrentX, m_CurrentY, m_CurrentZ, m_CurrentFace))
+ // We've gone out of the world, that's the end of this trace
+ double IntersectX, IntersectZ;
+ CalcXZIntersection(m_CurrentY, IntersectX, IntersectZ);
+ if (m_Callbacks->OnOutOfWorld(IntersectX, m_CurrentY, IntersectZ))
{
// The callback terminated the trace
return false;
}
- }
-
- // Move to next block
- if (!MoveToNextBlock())
- {
- // We've reached the end
m_Callbacks->OnNoMoreHits();
return true;
}
-
+
// Update the current chunk
if (a_Chunk != NULL)
{
a_Chunk = a_Chunk->GetNeighborChunk(m_CurrentX, m_CurrentZ);
}
-
- if ((m_CurrentY < 0) || (m_CurrentY >= cChunkDef::Height))
+
+ if (a_Chunk->IsValid())
{
- // We've gone out of the world, that's the end of this trace
- double IntersectX, IntersectZ;
- CalcXZIntersection(m_CurrentY, IntersectX, IntersectZ);
- if (m_Callbacks->OnOutOfWorld(IntersectX, m_CurrentY, IntersectZ))
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ int RelX = m_CurrentX - a_Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = m_CurrentZ - a_Chunk->GetPosZ() * cChunkDef::Width;
+ a_Chunk->GetBlockTypeMeta(RelX, m_CurrentY, RelZ, BlockType, BlockMeta);
+ if (m_Callbacks->OnNextBlock(m_CurrentX, m_CurrentY, m_CurrentZ, BlockType, BlockMeta, m_CurrentFace))
+ {
+ // The callback terminated the trace
+ return false;
+ }
+ }
+ else
+ {
+ if (m_Callbacks->OnNextBlockNoData(m_CurrentX, m_CurrentY, m_CurrentZ, m_CurrentFace))
{
// The callback terminated the trace
return false;
}
- m_Callbacks->OnNoMoreHits();
- return true;
}
}
}
diff --git a/src/Log.cpp b/src/Log.cpp
index a7be04b1a..7686a0fb4 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -17,7 +17,7 @@
cLog* cLog::s_Log = NULL;
-cLog::cLog(const AString & a_FileName )
+cLog::cLog(const AString & a_FileName)
: m_File(NULL)
{
s_Log = this;
@@ -25,7 +25,7 @@ cLog::cLog(const AString & a_FileName )
// create logs directory
cFile::CreateFolder(FILE_IO_PREFIX + AString("logs"));
- OpenLog((FILE_IO_PREFIX + AString("logs/") + a_FileName).c_str() );
+ OpenLog((FILE_IO_PREFIX + AString("logs/") + a_FileName).c_str());
}
@@ -59,7 +59,7 @@ cLog * cLog::GetInstance()
void cLog::CloseLog()
{
- if( m_File )
+ if (m_File)
fclose (m_File);
m_File = 0;
}
@@ -68,13 +68,13 @@ void cLog::CloseLog()
-void cLog::OpenLog( const char* a_FileName )
+void cLog::OpenLog( const char* a_FileName)
{
- if(m_File) fclose (m_File);
+ if (m_File) fclose (m_File);
#ifdef _MSC_VER
- fopen_s( &m_File, a_FileName, "a+" );
+ fopen_s( &m_File, a_FileName, "a+");
#else
- m_File = fopen(a_FileName, "a+" );
+ m_File = fopen(a_FileName, "a+");
#endif
}
@@ -85,11 +85,11 @@ void cLog::OpenLog( const char* a_FileName )
void cLog::ClearLog()
{
#ifdef _MSC_VER
- if( fopen_s( &m_File, "log.txt", "w" ) == 0)
+ if (fopen_s( &m_File, "log.txt", "w") == 0)
fclose (m_File);
#else
- m_File = fopen("log.txt", "w" );
- if( m_File )
+ m_File = fopen("log.txt", "w");
+ if (m_File)
fclose (m_File);
#endif
m_File = NULL;
@@ -105,15 +105,15 @@ void cLog::Log(const char * a_Format, va_list argList)
AppendVPrintf(Message, a_Format, argList);
time_t rawtime;
- time ( &rawtime );
+ time ( &rawtime);
struct tm* timeinfo;
#ifdef _MSC_VER
struct tm timeinforeal;
timeinfo = &timeinforeal;
- localtime_s(timeinfo, &rawtime );
+ localtime_s(timeinfo, &rawtime);
#else
- timeinfo = localtime( &rawtime );
+ timeinfo = localtime( &rawtime);
#endif
AString Line;
@@ -130,9 +130,9 @@ void cLog::Log(const char * a_Format, va_list argList)
// Print to console:
#if defined(ANDROID_NDK)
- //__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
- __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() );
- //CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line );
+ // __android_log_vprint(ANDROID_LOG_ERROR, "MCServer", a_Format, argList);
+ __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str());
+ // CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line);
#else
printf("%s", Line.c_str());
#endif
diff --git a/src/Log.h b/src/Log.h
index d6a406154..dc88aa92f 100644
--- a/src/Log.h
+++ b/src/Log.h
@@ -6,7 +6,7 @@
class cLog
-{ // tolua_export
+{
private:
FILE * m_File;
static cLog * s_Log;
@@ -23,7 +23,7 @@ public:
void ClearLog();
static cLog* GetInstance();
};
-// tolua_end
+
diff --git a/src/MCLogger.cpp b/src/MCLogger.cpp
index 583438d65..044e83937 100644
--- a/src/MCLogger.cpp
+++ b/src/MCLogger.cpp
@@ -57,6 +57,7 @@ cMCLogger::~cMCLogger()
{
m_Log->Log("--- Stopped Log ---\n");
delete m_Log;
+ m_Log = NULL;
if (this == s_MCLogger)
{
s_MCLogger = NULL;
@@ -226,14 +227,14 @@ void cMCLogger::ResetColor(void)
-//////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Global functions
void LOG(const char* a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
- cMCLogger::GetInstance()->Log( a_Format, argList );
+ cMCLogger::GetInstance()->Log( a_Format, argList);
va_end(argList);
}
@@ -241,7 +242,7 @@ void LOGINFO(const char* a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
- cMCLogger::GetInstance()->Info( a_Format, argList );
+ cMCLogger::GetInstance()->Info( a_Format, argList);
va_end(argList);
}
@@ -249,7 +250,7 @@ void LOGWARN(const char* a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
- cMCLogger::GetInstance()->Warn( a_Format, argList );
+ cMCLogger::GetInstance()->Warn( a_Format, argList);
va_end(argList);
}
@@ -257,7 +258,7 @@ void LOGERROR(const char* a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
- cMCLogger::GetInstance()->Error( a_Format, argList );
+ cMCLogger::GetInstance()->Error( a_Format, argList);
va_end(argList);
}
diff --git a/src/MCLogger.h b/src/MCLogger.h
index 114210f63..aa3a52d02 100644
--- a/src/MCLogger.h
+++ b/src/MCLogger.h
@@ -10,7 +10,6 @@ class cLog;
-// tolua_begin
class cMCLogger
{
public:
@@ -27,9 +26,9 @@ public:
cMCLogger(void);
/** Creates a logger with the specified filename inside "logs" folder */
- cMCLogger(const AString & a_FileName); // tolua_export
+ cMCLogger(const AString & a_FileName);
- ~cMCLogger(); // tolua_export
+ ~cMCLogger();
void Log (const char * a_Format, va_list a_ArgList) FORMATSTRING(2, 0);
void Info (const char * a_Format, va_list a_ArgList) FORMATSTRING(2, 0);
@@ -37,7 +36,7 @@ public:
void Error(const char * a_Format, va_list a_ArgList) FORMATSTRING(2, 0);
/** Logs the simple text message at the specified log level. */
- void LogSimple(const char * a_Text, eLogLevel a_LogLevel = llRegular); // tolua_export
+ void LogSimple(const char * a_Text, eLogLevel a_LogLevel = llRegular);
static cMCLogger * GetInstance();
private:
@@ -63,7 +62,7 @@ private:
/// Common initialization for all constructors, creates a logfile with the specified name and assigns s_MCLogger to this
void InitLog(const AString & a_FileName);
-}; // tolua_export
+};
diff --git a/src/Map.cpp b/src/Map.cpp
index 79370b097..8f205a606 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -200,8 +200,8 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
int BlockX = m_CenterX + ((a_X - (m_Width / 2)) * PixelWidth);
int BlockZ = m_CenterZ + ((a_Z - (m_Height / 2)) * PixelWidth);
- int ChunkX, ChunkY, ChunkZ;
- m_World->BlockToChunk(BlockX, 0, BlockZ, ChunkX, ChunkY, ChunkZ);
+ int ChunkX, ChunkZ;
+ cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
int RelX = BlockX - (ChunkX * cChunkDef::Width);
int RelZ = BlockZ - (ChunkZ * cChunkDef::Width);
@@ -614,7 +614,7 @@ unsigned int cMap::GetNumPixels(void) const
-unsigned int cMap::GetNumDecorators(void) const
+size_t cMap::GetNumDecorators(void) const
{
return m_Decorators.size();
}
diff --git a/src/Map.h b/src/Map.h
index ee7c537b1..fe324a5e7 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -29,13 +29,12 @@ class cMap;
/** Encapsulates a map decorator.
- *
- * A map decorator represents an object drawn on the map that can move freely.
- * (e.g. player trackers and item frame pointers)
- *
- * Excluding manually placed decorators,
- * decorators are automatically managed (allocated and freed) by their parent cMap instance.
- */
+A map decorator represents an object drawn on the map that can move freely.
+(e.g. player trackers and item frame pointers)
+
+Excluding manually placed decorators,
+decorators are automatically managed (allocated and freed) by their parent cMap instance.
+*/
class cMapDecorator
{
public:
@@ -181,7 +180,7 @@ public:
// tolua_end
- unsigned int GetNumDecorators(void) const;
+ size_t GetNumDecorators(void) const;
const cColorList & GetData(void) const { return m_Data; }
@@ -194,10 +193,9 @@ public:
protected:
/** Encapsulates the state of a map client.
- *
- * In order to enhance performace, maps are streamed column-by-column to each client.
- * This structure stores the state of the stream.
- */
+ In order to enhance performace, maps are streamed column-by-column to each client.
+ This structure stores the state of the stream.
+ */
struct cMapClient
{
cClientHandle * m_Handle;
@@ -258,7 +256,7 @@ private:
friend class cMapSerializer;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/MapManager.cpp b/src/MapManager.cpp
index 9d02eafb4..e7df75118 100644
--- a/src/MapManager.cpp
+++ b/src/MapManager.cpp
@@ -86,7 +86,7 @@ cMap * cMapManager::CreateMap(int a_CenterX, int a_CenterY, int a_Scale)
return NULL;
}
- cMap Map(m_MapData.size(), a_CenterX, a_CenterY, m_World, a_Scale);
+ cMap Map((unsigned)m_MapData.size(), a_CenterX, a_CenterY, m_World, a_Scale);
m_MapData.push_back(Map);
@@ -97,7 +97,7 @@ cMap * cMapManager::CreateMap(int a_CenterX, int a_CenterY, int a_Scale)
-unsigned int cMapManager::GetNumMaps(void) const
+size_t cMapManager::GetNumMaps(void) const
{
return m_MapData.size();
}
@@ -151,7 +151,7 @@ void cMapManager::SaveMapData(void)
cIDCountSerializer IDSerializer(m_World->GetName());
- IDSerializer.SetMapCount(m_MapData.size());
+ IDSerializer.SetMapCount((unsigned)m_MapData.size());
if (!IDSerializer.Save())
{
diff --git a/src/MapManager.h b/src/MapManager.h
index 80e6d16d1..a40ec2630 100644
--- a/src/MapManager.h
+++ b/src/MapManager.h
@@ -32,28 +32,25 @@ public:
cMapManager(cWorld * a_World);
/** Returns the map with the specified ID, NULL if out of range.
- *
- * WARNING: The returned map object is not thread safe.
- */
+ WARNING: The returned map object is not thread safe.
+ */
cMap * GetMapData(unsigned int a_ID);
/** Creates a new map. Returns NULL on error */
cMap * CreateMap(int a_CenterX, int a_CenterY, int a_Scale = 3);
/** Calls the callback for the map with the specified ID.
- *
- * Returns true if the map was found and the callback called, false if map not found.
- * Callback return ignored.
- */
- bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp
-
- /** Calls the callback for each map.
- *
- * Returns true if all maps processed, false if the callback aborted by returning true.
- */
+ Returns true if the map was found and the callback called, false if map not found.
+ Callback return value is ignored.
+ */
+ bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp
+
+ /** Calls the callback for each map.
+ Returns true if all maps processed, false if the callback aborted by returning true.
+ */
bool ForEachMap(cMapCallback & a_Callback);
- unsigned int GetNumMaps(void) const; // tolua_export
+ size_t GetNumMaps(void) const; // tolua_export
/** Loads the map data from the disk */
void LoadMapData(void);
@@ -72,7 +69,7 @@ private:
cWorld * m_World;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Matrix4.h b/src/Matrix4.h
index 456677f0f..081847b9f 100644
--- a/src/Matrix4.h
+++ b/src/Matrix4.h
@@ -3,7 +3,7 @@
-#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC)
+#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC)
#include <math.h>
@@ -104,7 +104,7 @@ public:
}
inline void Translate(const Vector3<T> & a_Pos)
- {
+ {
cell[3] += a_Pos.x;
cell[7] += a_Pos.y;
cell[11] += a_Pos.z;
diff --git a/src/MobCensus.cpp b/src/MobCensus.cpp
index 9c32bf695..4109aff07 100644
--- a/src/MobCensus.cpp
+++ b/src/MobCensus.cpp
@@ -19,9 +19,9 @@ void cMobCensus::CollectMob(cMonster & a_Monster, cChunk & a_Chunk, double a_Dis
bool cMobCensus::IsCapped(cMonster::eFamily a_MobFamily)
{
- const int ratio = 319; // this should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player
+ const int ratio = 319; // This should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player
// but for now, we use all chunks loaded by players. that means 19 x 19 chunks. That's why we use 256 * (19*19) / (17*17) = 319
- // MG TODO : code the correct count
+ // MG TODO : code the correct count
if ((GetCapMultiplier(a_MobFamily) * GetNumChunks()) / ratio >= m_MobFamilyCollecter.GetNumberOfCollectedMobs(a_MobFamily))
{
return false;
@@ -64,7 +64,7 @@ void cMobCensus::CollectSpawnableChunk(cChunk & a_Chunk)
int cMobCensus::GetNumChunks(void)
{
- return m_EligibleForSpawnChunks.size();
+ return (int)m_EligibleForSpawnChunks.size();
}
diff --git a/src/MobFamilyCollecter.cpp b/src/MobFamilyCollecter.cpp
index e9c69e078..6da330c83 100644
--- a/src/MobFamilyCollecter.cpp
+++ b/src/MobFamilyCollecter.cpp
@@ -18,7 +18,7 @@ void cMobFamilyCollecter::CollectMob(cMonster & a_Monster)
int cMobFamilyCollecter::GetNumberOfCollectedMobs(cMonster::eFamily a_Family)
{
- return m_Mobs[a_Family].size();
+ return (int)m_Mobs[a_Family].size();
}
diff --git a/src/MobFamilyCollecter.h b/src/MobFamilyCollecter.h
index 6cef133b5..c4324bd68 100644
--- a/src/MobFamilyCollecter.h
+++ b/src/MobFamilyCollecter.h
@@ -4,7 +4,7 @@
#include <map>
#include <set>
#include "BlockID.h"
-#include "Mobs/Monster.h" //this is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it
+#include "Mobs/Monster.h" // This is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it
@@ -29,7 +29,7 @@ public :
// return the number of mobs for this family
int GetNumberOfCollectedMobs(cMonster::eFamily a_Family);
-protected :
+protected :
std::map<cMonster::eFamily, std::set<cMonster *> > m_Mobs;
} ;
diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp
index 519757c2c..82ba771ff 100644
--- a/src/MobProximityCounter.cpp
+++ b/src/MobProximityCounter.cpp
@@ -8,12 +8,12 @@
void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, double a_Distance)
{
-// LOGD("Collecting monster %s, with distance %f",a_Monster->GetClass(),a_Distance);
+ // LOGD("Collecting monster %s, with distance %f", a_Monster->GetClass(), a_Distance);
tMonsterToDistance::iterator it = m_MonsterToDistance.find(&a_Monster);
if (it == m_MonsterToDistance.end())
{
- sDistanceAndChunk newDistanceAndChunk(a_Distance,a_Chunk);
- std::pair<tMonsterToDistance::iterator,bool> result = m_MonsterToDistance.insert(tMonsterToDistance::value_type(&a_Monster,newDistanceAndChunk));
+ sDistanceAndChunk newDistanceAndChunk(a_Distance, a_Chunk);
+ std::pair<tMonsterToDistance::iterator, bool> result = m_MonsterToDistance.insert(tMonsterToDistance::value_type(&a_Monster, newDistanceAndChunk));
if (!result.second)
{
ASSERT(!"A collected Monster was not found inside distance map using find(), but insert() said there already is a key for it");
@@ -24,7 +24,7 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, doubl
if (a_Distance < it->second.m_Distance)
{
it->second.m_Distance = a_Distance;
- it->second.m_Chunk = a_Chunk;
+ it->second.m_Chunk = &a_Chunk;
}
}
@@ -34,9 +34,9 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, doubl
void cMobProximityCounter::convertMaps()
{
- for(tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr)
+ for (tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr)
{
- m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance,sMonsterAndChunk(*itr->first,itr->second.m_Chunk)));
+ m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance, sMonsterAndChunk(*itr->first, *itr->second.m_Chunk)));
}
}
@@ -55,13 +55,13 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist
convertMaps();
}
- for(tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); ++itr)
+ for (tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); ++itr)
{
if (toReturn.m_Begin == m_DistanceToMonster.end())
{
if ((a_DistanceMin == 1) || (itr->first > a_DistanceMin))
{
- toReturn.m_Begin = itr; // this is the first one with distance > a_DistanceMin;
+ toReturn.m_Begin = itr; // This is the first one with distance > a_DistanceMin;
}
}
@@ -69,7 +69,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist
{
if ((a_DistanceMax != 1) && (itr->first > a_DistanceMax))
{
- toReturn.m_End = itr; // this is just after the last one with distance < a_DistanceMax
+ toReturn.m_End = itr; // This is just after the last one with distance < a_DistanceMax
// Note : if we are not going through this, it's ok, toReturn.m_End will be end();
break;
}
diff --git a/src/MobProximityCounter.h b/src/MobProximityCounter.h
index 8a67139aa..2dabeaa21 100644
--- a/src/MobProximityCounter.h
+++ b/src/MobProximityCounter.h
@@ -16,9 +16,9 @@ protected :
// structs used for later maps (see m_MonsterToDistance and m_DistanceToMonster)
struct sDistanceAndChunk
{
- sDistanceAndChunk(double a_Distance, cChunk& a_Chunk) : m_Distance(a_Distance), m_Chunk(a_Chunk) {}
+ sDistanceAndChunk(double a_Distance, cChunk& a_Chunk) : m_Distance(a_Distance), m_Chunk(&a_Chunk) {}
double m_Distance;
- cChunk& m_Chunk;
+ cChunk* m_Chunk;
};
struct sMonsterAndChunk
{
@@ -27,11 +27,11 @@ protected :
cChunk& m_Chunk;
};
-public :
- typedef std::map<cEntity*,sDistanceAndChunk> tMonsterToDistance;
- typedef std::multimap<double,sMonsterAndChunk> tDistanceToMonster;
+public :
+ typedef std::map<cEntity*, sDistanceAndChunk> tMonsterToDistance;
+ typedef std::multimap<double, sMonsterAndChunk> tDistanceToMonster;
-protected :
+protected :
// this map is filled during collection phase, it will be later transformed into DistanceToMonster
tMonsterToDistance m_MonsterToDistance;
@@ -41,7 +41,7 @@ protected :
// this are the collected chunks. Used to determinate the number of elligible chunk for spawning.
std::set<cChunk*> m_EligibleForSpawnChunks;
-protected :
+protected :
// transform monsterToDistance map (that was usefull for collecting) into distanceToMonster
// that will be usefull for picking up.
void convertMaps();
@@ -55,7 +55,8 @@ public :
// return the mobs that are within the range of distance of the closest player they are
// that means that if a mob is 30 m from a player and 150 m from another one. It will be
// in the range [0..50] but not in [100..200]
- struct sIterablePair{
+ struct sIterablePair
+ {
tDistanceToMonster::const_iterator m_Begin;
tDistanceToMonster::const_iterator m_End;
int m_Count;
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index ce8e06777..db05b70af 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -8,7 +8,7 @@
-cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily,const std::set<cMonster::eType>& a_AllowedTypes) :
+cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily, const std::set<cMonster::eType>& a_AllowedTypes) :
m_MonsterFamily(a_MonsterFamily),
m_NewPack(true),
m_MobType(cMonster::mtInvalidType)
@@ -91,7 +91,7 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
addIfAllowed(cMonster::mtCow, allowedMobs);
addIfAllowed(cMonster::mtChicken, allowedMobs);
addIfAllowed(cMonster::mtEnderman, allowedMobs);
- addIfAllowed(cMonster::mtSlime, allowedMobs); // MG TODO : much more complicated rule
+ addIfAllowed(cMonster::mtSlime, allowedMobs); // MG TODO : much more complicated rule
if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills)
{
@@ -104,13 +104,13 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
}
}
- int allowedMobsSize = allowedMobs.size();
+ size_t allowedMobsSize = allowedMobs.size();
if (allowedMobsSize > 0)
{
std::set<cMonster::eType>::iterator itr = allowedMobs.begin();
- int iRandom = m_Random.NextInt(allowedMobsSize,a_Biome);
+ int iRandom = m_Random.NextInt((int)allowedMobsSize, a_Biome);
- for(int i = 0; i < iRandom; i++)
+ for (int i = 0; i < iRandom; i++)
{
++itr;
}
@@ -141,7 +141,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
SkyLight = a_Chunk->GetTimeAlteredLight(SkyLight);
- switch(a_MobType)
+ switch (a_MobType)
{
case cMonster::mtSquid:
{
@@ -208,7 +208,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
bool HasFloor = false;
for (int x = 0; x < 2; ++x)
{
- for(int z = 0; z < 2; ++z)
+ for (int z = 0; z < 2; ++z)
{
CanSpawn = a_Chunk->UnboundedRelGetBlockType(a_RelX + x, a_RelY, a_RelZ + z, TargetBlock);
CanSpawn = CanSpawn && (TargetBlock == E_BLOCK_AIR);
@@ -241,7 +241,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
(m_Random.NextInt(2, a_Biome) == 0)
);
}
-
+
+ case cMonster::mtMagmaCube:
case cMonster::mtSlime:
{
return (
diff --git a/src/MobSpawner.h b/src/MobSpawner.h
index ea6636310..f3c56fe2d 100644
--- a/src/MobSpawner.h
+++ b/src/MobSpawner.h
@@ -6,7 +6,7 @@
#include "ChunkDef.h"
#include "Chunk.h"
#include "FastRandom.h"
-#include "Mobs/Monster.h" //this is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it
+#include "Mobs/Monster.h" // This is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it
@@ -51,7 +51,7 @@ public :
typedef const std::set<cMonster *> tSpawnedContainer;
tSpawnedContainer & getSpawned(void);
-protected :
+protected :
// return true if specified type of mob can spawn on specified block
bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome);
@@ -62,7 +62,7 @@ protected :
// add toAdd inside toAddIn, if toAdd is in m_AllowedTypes
void addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType> & toAddIn);
-protected :
+protected :
cMonster::eFamily m_MonsterFamily;
std::set<cMonster::eType> m_AllowedTypes;
bool m_NewPack;
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 447bf3549..5f5b1853d 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -42,7 +42,7 @@ void cAggressiveMonster::InStateChasing(float a_Dt)
MoveToPosition(m_Target->GetPosition());
}
}
-}
+}
@@ -95,12 +95,14 @@ void cAggressiveMonster::Attack(float a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
- if ((m_Target != NULL) && (m_AttackInterval > 3.0))
+ if ((m_Target == NULL) || (m_AttackInterval < 3.0))
{
- // Setting this higher gives us more wiggle room for attackrate
- m_AttackInterval = 0.0;
- m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
+ return;
}
+
+ // Setting this higher gives us more wiggle room for attackrate
+ m_AttackInterval = 0.0;
+ m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
}
@@ -108,14 +110,13 @@ void cAggressiveMonster::Attack(float a_Dt)
bool cAggressiveMonster::IsMovingToTargetPosition()
{
- static const float epsilon = 0.000000000001f;
// Difference between destination x and target x is negligible (to 10^-12 precision)
- if (fabsf((float)m_FinalDestination.x - (float)m_Target->GetPosX()) < epsilon)
+ if (fabsf((float)m_FinalDestination.x - (float)m_Target->GetPosX()) < std::numeric_limits<float>::epsilon())
{
return false;
}
// Difference between destination z and target z is negligible (to 10^-12 precision)
- else if (fabsf((float)m_FinalDestination.z - (float)m_Target->GetPosZ()) > epsilon)
+ else if (fabsf((float)m_FinalDestination.z - (float)m_Target->GetPosZ()) > std::numeric_limits<float>::epsilon())
{
return false;
}
diff --git a/src/Mobs/Bat.cpp b/src/Mobs/Bat.cpp
index 1417ddd9e..c072d4f48 100644
--- a/src/Mobs/Bat.cpp
+++ b/src/Mobs/Bat.cpp
@@ -7,8 +7,7 @@
cBat::cBat(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7)
+ super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.5, 0.9)
{
}
diff --git a/src/Mobs/Bat.h b/src/Mobs/Bat.h
index e878d0ee8..6b06aeb4f 100644
--- a/src/Mobs/Bat.h
+++ b/src/Mobs/Bat.h
@@ -15,7 +15,7 @@ class cBat :
public:
cBat(void);
- CLASS_PROTODEF(cBat);
+ CLASS_PROTODEF(cBat)
bool IsHanging(void) const {return false; }
} ;
diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp
index 326b42f07..b4104d530 100644
--- a/src/Mobs/Blaze.cpp
+++ b/src/Mobs/Blaze.cpp
@@ -9,8 +9,7 @@
cBlaze::cBlaze(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8)
+ super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.6, 1.8)
{
}
@@ -45,9 +44,10 @@ void cBlaze::Attack(float a_Dt)
{
return;
}
- if (!FireCharge->Initialize(m_World))
+ if (!FireCharge->Initialize(*m_World))
{
delete FireCharge;
+ FireCharge = NULL;
return;
}
m_World->BroadcastSpawnEntity(*FireCharge);
diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h
index 5970451c7..f283b1070 100644
--- a/src/Mobs/Blaze.h
+++ b/src/Mobs/Blaze.h
@@ -15,7 +15,7 @@ class cBlaze :
public:
cBlaze(void);
- CLASS_PROTODEF(cBlaze);
+ CLASS_PROTODEF(cBlaze)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Attack(float a_Dt) override;
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index 53c265803..2c092c15f 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -4,9 +4,75 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ AggressiveMonster.cpp
+ Bat.cpp
+ Blaze.cpp
+ CaveSpider.cpp
+ Chicken.cpp
+ Cow.cpp
+ Creeper.cpp
+ EnderDragon.cpp
+ Enderman.cpp
+ Ghast.cpp
+ Giant.cpp
+ Horse.cpp
+ IronGolem.cpp
+ MagmaCube.cpp
+ Monster.cpp
+ Mooshroom.cpp
+ PassiveAggressiveMonster.cpp
+ PassiveMonster.cpp
+ Pig.cpp
+ Sheep.cpp
+ Skeleton.cpp
+ Slime.cpp
+ SnowGolem.cpp
+ Spider.cpp
+ Squid.cpp
+ Villager.cpp
+ Witch.cpp
+ Wither.cpp
+ Wolf.cpp
+ Zombie.cpp
+ ZombiePigman.cpp)
+
+SET (HDRS
+ AggressiveMonster.h
+ Bat.h
+ Blaze.h
+ CaveSpider.h
+ Chicken.h
+ Cow.h
+ Creeper.h
+ EnderDragon.h
+ Enderman.h
+ Ghast.h
+ Giant.h
+ Horse.h
+ IncludeAllMonsters.h
+ IronGolem.h
+ MagmaCube.h
+ Monster.h
+ Mooshroom.h
+ Ocelot.h
+ PassiveAggressiveMonster.h
+ PassiveMonster.h
+ Pig.h
+ Sheep.h
+ Silverfish.h
+ Skeleton.h
+ Slime.h
+ SnowGolem.h
+ Spider.h
+ Squid.h
+ Villager.h
+ Witch.h
+ Wither.h
+ Wolf.h
+ Zombie.h
+ ZombiePigman.h)
-add_library(Mobs ${SOURCE})
+if(NOT MSVC)
+ add_library(Mobs ${SRCS} ${HDRS})
+endif()
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index 56ecd2d28..118a6e93b 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -20,7 +20,6 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- // TODO: Check vanilla if cavespiders really get passive during the day / in daylight
m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE;
}
@@ -28,6 +27,21 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk)
+void cCaveSpider::Attack(float a_Dt)
+{
+ super::Attack(a_Dt);
+
+ if (m_Target->IsPawn())
+ {
+ // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds
+ ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0);
+ }
+}
+
+
+
+
+
void cCaveSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h
index be9f174f9..f9ed10e1b 100644
--- a/src/Mobs/CaveSpider.h
+++ b/src/Mobs/CaveSpider.h
@@ -14,9 +14,10 @@ class cCaveSpider :
public:
cCaveSpider(void);
- CLASS_PROTODEF(cCaveSpider);
+ CLASS_PROTODEF(cCaveSpider)
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Attack(float a_Dt) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;
diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h
index a4c1d6b9e..b1a50b61c 100644
--- a/src/Mobs/Chicken.h
+++ b/src/Mobs/Chicken.h
@@ -14,7 +14,7 @@ class cChicken :
public:
cChicken(void);
- CLASS_PROTODEF(cChicken);
+ CLASS_PROTODEF(cChicken)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h
index 973171ab5..8814b7e09 100644
--- a/src/Mobs/Cow.h
+++ b/src/Mobs/Cow.h
@@ -15,7 +15,7 @@ class cCow :
public:
cCow();
- CLASS_PROTODEF(cCow);
+ CLASS_PROTODEF(cCow)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index 3471b4cf1..02718edf8 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -37,13 +37,13 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_bIsBlowing)
{
- m_ExplodingTimer += 1;
+ m_ExplodingTimer += 1;
}
if (m_ExplodingTimer == 30)
{
m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this);
- Destroy();
+ Destroy(); // Just in case we aren't killed by the explosion
}
}
}
@@ -54,6 +54,12 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk)
void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
+ if (m_ExplodingTimer == 30)
+ {
+ // Exploded creepers drop naught but charred flesh, which Minecraft doesn't have
+ return;
+ }
+
int LootingLevel = 0;
if (a_Killer != NULL)
{
@@ -61,11 +67,29 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
- if ((a_Killer != NULL) && (a_Killer->IsProjectile()))
+ if ((a_Killer != NULL) && a_Killer->IsProjectile() && (((cProjectileEntity *)a_Killer)->GetCreatorUniqueID() >= 0))
{
- if (((cMonster *)((cProjectileEntity *)a_Killer)->GetCreator())->GetMobType() == mtSkeleton)
+ class cProjectileCreatorCallback : public cEntityCallback
{
- // 12 music discs. TickRand starts from 0, so range = 11. Disk IDs start at 2256, so add that. There.
+ public:
+ cProjectileCreatorCallback(void)
+ {
+ }
+
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ if (a_Entity->IsMob() && ((cMonster *)a_Entity)->GetMobType() == mtSkeleton)
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ cProjectileCreatorCallback PCC;
+ if (GetWorld()->DoWithEntityByID(((cProjectileEntity *)a_Killer)->GetCreatorUniqueID(), PCC))
+ {
+ // 12 music discs. TickRand starts from 0 to 11. Disk IDs start at 2256, so add that. There.
AddRandomDropItem(a_Drops, 1, 1, (short)m_World->GetTickRandomNumber(11) + 2256);
}
}
@@ -75,9 +99,12 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
+bool cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- super::DoTakeDamage(a_TDI);
+ if (!super::DoTakeDamage(a_TDI))
+ {
+ return false;
+ }
if (a_TDI.DamageType == dtLightning)
{
@@ -85,6 +112,7 @@ void cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
}
m_World->BroadcastEntityMetadata(*this);
+ return true;
}
@@ -97,7 +125,7 @@ void cCreeper::Attack(float a_Dt)
if (!m_bIsBlowing)
{
- m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
}
@@ -115,7 +143,7 @@ void cCreeper::OnRightClicked(cPlayer & a_Player)
{
a_Player.UseEquippedItem();
}
- m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
m_BurnedWithFlintAndSteel = true;
diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h
index 9abca369b..747daca09 100644
--- a/src/Mobs/Creeper.h
+++ b/src/Mobs/Creeper.h
@@ -15,10 +15,10 @@ class cCreeper :
public:
cCreeper(void);
- CLASS_PROTODEF(cCreeper);
+ CLASS_PROTODEF(cCreeper)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Attack(float a_Dt) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/EnderDragon.h b/src/Mobs/EnderDragon.h
index 77177edfe..1d4cd657c 100644
--- a/src/Mobs/EnderDragon.h
+++ b/src/Mobs/EnderDragon.h
@@ -15,7 +15,7 @@ class cEnderDragon :
public:
cEnderDragon(void);
- CLASS_PROTODEF(cEnderDragon);
+ CLASS_PROTODEF(cEnderDragon)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;
diff --git a/src/Mobs/Enderman.h b/src/Mobs/Enderman.h
index 32e40e70b..aa2eff682 100644
--- a/src/Mobs/Enderman.h
+++ b/src/Mobs/Enderman.h
@@ -15,7 +15,7 @@ class cEnderman :
public:
cEnderman(void);
- CLASS_PROTODEF(cEnderman);
+ CLASS_PROTODEF(cEnderman)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp
index d8a7663f8..6aac14779 100644
--- a/src/Mobs/Ghast.cpp
+++ b/src/Mobs/Ghast.cpp
@@ -46,9 +46,10 @@ void cGhast::Attack(float a_Dt)
{
return;
}
- if (!GhastBall->Initialize(m_World))
+ if (!GhastBall->Initialize(*m_World))
{
delete GhastBall;
+ GhastBall = NULL;
return;
}
m_World->BroadcastSpawnEntity(*GhastBall);
diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h
index 43e8bedb6..1d4e6b94a 100644
--- a/src/Mobs/Ghast.h
+++ b/src/Mobs/Ghast.h
@@ -15,7 +15,7 @@ class cGhast :
public:
cGhast(void);
- CLASS_PROTODEF(cGhast);
+ CLASS_PROTODEF(cGhast)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Attack(float a_Dt) override;
diff --git a/src/Mobs/Giant.h b/src/Mobs/Giant.h
index 356dd4352..7c04c9b4f 100644
--- a/src/Mobs/Giant.h
+++ b/src/Mobs/Giant.h
@@ -15,7 +15,7 @@ class cGiant :
public:
cGiant(void);
- CLASS_PROTODEF(cGiant);
+ CLASS_PROTODEF(cGiant)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;
diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp
index 9d130301f..67a09d4ab 100644
--- a/src/Mobs/Horse.cpp
+++ b/src/Mobs/Horse.cpp
@@ -63,7 +63,7 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
m_Attachee->Detach();
m_bIsRearing = true;
}
- }
+ }
else
{
m_bIsTame = true;
diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h
index be0c23f9b..47189b3b0 100644
--- a/src/Mobs/Horse.h
+++ b/src/Mobs/Horse.h
@@ -15,7 +15,7 @@ class cHorse :
public:
cHorse(int Type, int Color, int Style, int TameTimes);
- CLASS_PROTODEF(cHorse);
+ CLASS_PROTODEF(cHorse)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h
index 41c60438c..c5341ed76 100644
--- a/src/Mobs/IronGolem.h
+++ b/src/Mobs/IronGolem.h
@@ -15,11 +15,11 @@ class cIronGolem :
public:
cIronGolem(void);
- CLASS_PROTODEF(cIronGolem);
+ CLASS_PROTODEF(cIronGolem)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- // Iron golems do not drown
+ // Iron golems do not drown nor float
virtual void HandleAir(void) override {}
virtual void SetSwimState(cChunk & a_Chunk) override {}
} ;
diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h
index 43065cae5..bfe63fa2e 100644
--- a/src/Mobs/MagmaCube.h
+++ b/src/Mobs/MagmaCube.h
@@ -15,7 +15,7 @@ public:
/// Creates a MagmaCube of the specified size; size is 1 .. 3, with 1 being the smallest
cMagmaCube(int a_Size);
- CLASS_PROTODEF(cMagmaCube);
+ CLASS_PROTODEF(cMagmaCube)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
int GetSize(void) const { return m_Size; }
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 14d951393..622a67816 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -46,8 +46,8 @@ static const struct
{cMonster::mtSheep, "sheep"},
{cMonster::mtSilverfish, "silverfish"},
{cMonster::mtSkeleton, "skeleton"},
- {cMonster::mtSnowGolem, "snowgolem"},
{cMonster::mtSlime, "slime"},
+ {cMonster::mtSnowGolem, "snowgolem"},
{cMonster::mtSpider, "spider"},
{cMonster::mtSquid, "squid"},
{cMonster::mtVillager, "villager"},
@@ -62,7 +62,7 @@ static const struct
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMonster:
cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
@@ -115,12 +115,10 @@ void cMonster::TickPathFinding()
const int PosY = POSY_TOINT;
const int PosZ = POSZ_TOINT;
- m_FinalDestination.y = (double)FindFirstNonAirBlockPosition(m_FinalDestination.x, m_FinalDestination.z);
-
std::vector<Vector3d> m_PotentialCoordinates;
m_TraversedCoordinates.push_back(Vector3i(PosX, PosY, PosZ));
- static const struct // Define which directions to try to move to
+ static const struct // Define which directions to try to move to
{
int x, z;
} gCrossCoords[] =
@@ -128,7 +126,7 @@ void cMonster::TickPathFinding()
{ 1, 0},
{-1, 0},
{ 0, 1},
- { 0,-1},
+ { 0, -1},
} ;
if ((PosY - 1 < 0) || (PosY + 2 > cChunkDef::Height) /* PosY + 1 will never be true if PosY + 2 is not */)
@@ -201,19 +199,6 @@ void cMonster::TickPathFinding()
-void cMonster::MoveToPosition(const Vector3f & a_Position)
-{
- FinishPathFinding();
-
- m_FinalDestination = a_Position;
- m_bMovingToDestination = true;
- TickPathFinding();
-}
-
-
-
-
-
void cMonster::MoveToPosition(const Vector3d & a_Position)
{
FinishPathFinding();
@@ -227,15 +212,7 @@ void cMonster::MoveToPosition(const Vector3d & a_Position)
bool cMonster::IsCoordinateInTraversedList(Vector3i a_Coords)
{
- for (std::vector<Vector3i>::const_iterator itr = m_TraversedCoordinates.begin(); itr != m_TraversedCoordinates.end(); ++itr)
- {
- if (itr->Equals(a_Coords))
- {
- return true;
- }
- }
-
- return false;
+ return (std::find(m_TraversedCoordinates.begin(), m_TraversedCoordinates.end(), a_Coords) != m_TraversedCoordinates.end());
}
@@ -296,39 +273,47 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_bOnGround)
{
- m_Destination.y = FindFirstNonAirBlockPosition(m_Destination.x, m_Destination.z);
-
if (DoesPosYRequireJump((int)floor(m_Destination.y)))
{
m_bOnGround = false;
- AddPosY(1.5); // Jump!!
+ AddSpeedY(5.2); // Jump!!
}
}
Vector3f Distance = m_Destination - GetPosition();
- if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move
+ if (!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move
{
Distance.y = 0;
Distance.Normalize();
- Distance *= 5;
- SetSpeedX(Distance.x);
- SetSpeedZ(Distance.z);
+
+ if (m_bOnGround)
+ {
+ Distance *= 2.5;
+ }
+ else
+ {
+ // Don't let the mob move too much if he's falling.
+ Distance *= 0.25;
+ }
+
+ AddSpeedX(Distance.x);
+ AddSpeedZ(Distance.z);
if (m_EMState == ESCAPING)
- { //Runs Faster when escaping :D otherwise they just walk away
+ { // Runs Faster when escaping :D otherwise they just walk away
SetSpeedX (GetSpeedX() * 2.f);
SetSpeedZ (GetSpeedZ() * 2.f);
}
}
else
{
- if (ReachedFinalDestination()) // If we have reached the ultimate, final destination, stop pathfinding and attack if appropriate
+ if (ReachedFinalDestination()) // If we have reached the ultimate, final destination, stop pathfinding and attack if appropriate
{
FinishPathFinding();
}
else
{
- TickPathFinding(); // We have reached the next point in our path, calculate another point
+ TickPathFinding(); // We have reached the next point in our path, calculate another point
}
}
}
@@ -343,18 +328,20 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
// If enemy passive we ignore checks for player visibility
InStateIdle(a_Dt);
break;
- }
+ }
case CHASING:
{
// If we do not see a player anymore skip chasing action
InStateChasing(a_Dt);
break;
- }
+ }
case ESCAPING:
{
InStateEscaping(a_Dt);
break;
}
+
+ case ATTACKING: break;
} // switch (m_EMState)
BroadcastMovementUpdate();
@@ -423,14 +410,11 @@ void cMonster::HandleFalling()
+
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
{
int PosY = POSY_TOINT;
-
- if (PosY < 0)
- PosY = 0;
- else if (PosY > cChunkDef::Height)
- PosY = cChunkDef::Height;
+ PosY = Clamp(PosY, 0, cChunkDef::Height);
if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))))
{
@@ -457,29 +441,35 @@ int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
-void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
+bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- super::DoTakeDamage(a_TDI);
+ if (!super::DoTakeDamage(a_TDI))
+ {
+ return false;
+ }
- if((m_SoundHurt != "") && (m_Health > 0))
- m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f);
+ if (!m_SoundHurt.empty() && (m_Health > 0))
+ {
+ m_World->BroadcastSoundEffect(m_SoundHurt, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);
+ }
if (a_TDI.Attacker != NULL)
{
m_Target = a_TDI.Attacker;
}
+ return true;
}
-void cMonster::KilledBy(cEntity * a_Killer)
+void cMonster::KilledBy(TakeDamageInfo & a_TDI)
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
if (m_SoundHurt != "")
{
- m_World->BroadcastSoundEffect(m_SoundDeath, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f);
+ m_World->BroadcastSoundEffect(m_SoundDeath, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);
}
int Reward;
switch (m_MobType)
@@ -540,7 +530,7 @@ void cMonster::KilledBy(cEntity * a_Killer)
break;
}
}
- if ((a_Killer != NULL) && (!IsBaby()))
+ if ((a_TDI.Attacker != NULL) && (!IsBaby()))
{
m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward);
}
@@ -551,8 +541,8 @@ void cMonster::KilledBy(cEntity * a_Killer)
-//Checks to see if EventSeePlayer should be fired
-//monster sez: Do I see the player
+// Checks to see if EventSeePlayer should be fired
+// monster sez: Do I see the player
void cMonster::CheckEventSeePlayer(void)
{
// TODO: Rewrite this to use cWorld's DoWithPlayers()
@@ -569,7 +559,7 @@ void cMonster::CheckEventSeePlayer(void)
void cMonster::CheckEventLostPlayer(void)
-{
+{
if (m_Target != NULL)
{
if ((m_Target->GetPosition() - GetPosition()).Length() > m_SightDistance)
@@ -612,7 +602,7 @@ void cMonster::InStateIdle(float a_Dt)
{
if (m_bMovingToDestination)
{
- return; // Still getting there
+ return; // Still getting there
}
m_IdleInterval += a_Dt;
@@ -621,7 +611,7 @@ void cMonster::InStateIdle(float a_Dt)
{
// At this interval the results are predictable
int rem = m_World->GetTickRandomNumber(6) + 1;
- m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds
+ m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds
Vector3d Dist;
Dist.x = (double)m_World->GetTickRandomNumber(10) - 5;
@@ -688,6 +678,15 @@ void cMonster::GetMonsterConfig(const AString & a_Name)
+bool cMonster::IsUndead(void)
+{
+ return false;
+}
+
+
+
+
+
AString cMonster::MobTypeToString(cMonster::eType a_MobType)
{
// Mob types aren't sorted, so we need to search linearly:
@@ -823,15 +822,19 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
switch (a_MobType)
{
case mtMagmaCube:
+ {
+ toReturn = new cMagmaCube(Random.NextInt(2) + 1);
+ break;
+ }
case mtSlime:
{
- toReturn = new cSlime(Random.NextInt(2) + 1);
+ toReturn = new cSlime(1 << Random.NextInt(3)); // Size 1, 2 or 4
break;
}
case mtSkeleton:
{
// TODO: Actual detection of spawning in Nether
- toReturn = new cSkeleton(Random.NextInt(1) == 0 ? false : true);
+ toReturn = new cSkeleton((Random.NextInt(1) == 0) ? false : true);
break;
}
case mtVillager:
@@ -878,7 +881,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
case mtMooshroom: toReturn = new cMooshroom(); break;
case mtOcelot: toReturn = new cOcelot(); break;
case mtPig: toReturn = new cPig(); break;
- case mtSheep: toReturn = new cSheep (Random.NextInt(15)); break; // Colour parameter
+ case mtSheep: toReturn = new cSheep(); break;
case mtSilverfish: toReturn = new cSilverfish(); break;
case mtSnowGolem: toReturn = new cSnowGolem(); break;
case mtSpider: toReturn = new cSpider(); break;
@@ -886,7 +889,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
case mtWitch: toReturn = new cWitch(); break;
case mtWither: toReturn = new cWither(); break;
case mtWolf: toReturn = new cWolf(); break;
- case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter
+ case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter
case mtZombiePigman: toReturn = new cZombiePigman(); break;
default:
{
@@ -1012,7 +1015,7 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
(a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand
(GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime
!IsOnFire() && // Not already burning
- (GetWorld()->GetWeather() != eWeather_Rain) // Not raining
+ GetWorld()->IsWeatherWetAt(POSX_TOINT, POSZ_TOINT) // Not raining
)
{
// Burn for 100 ticks, then decide again
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 6b9c4fab8..cdbd26c09 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -61,39 +61,38 @@ public:
enum eFamily
{
- mfHostile = 0, // Spider, Zombies ...
- mfPassive = 1, // Cows, Pigs
- mfAmbient = 2, // Bats
- mfWater = 3, // Squid
+ mfHostile = 0, // Spider, Zombies ...
+ mfPassive = 1, // Cows, Pigs
+ mfAmbient = 2, // Bats
+ mfWater = 3, // Squid
mfNoSpawn,
- mfUnhandled, // Nothing. Be sure this is the last and the others are in order
+ mfUnhandled, // Nothing. Be sure this is the last and the others are in order
} ;
// tolua_end
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
- enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality;
+ enum MPersonality{PASSIVE, AGGRESSIVE, COWARDLY} m_EMPersonality;
/** Creates the mob object.
- * If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig()
- * a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs , 2012_12_22))
- * a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively
+ If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig()
+ a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22))
+ a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively
*/
cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
- CLASS_PROTODEF(cMonster);
+ CLASS_PROTODEF(cMonster)
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
- virtual void MoveToPosition(const Vector3f & a_Position);
- virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
+ virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
virtual bool ReachedDestination(void);
// tolua_begin
@@ -107,6 +106,9 @@ public:
/// Reads the monster configuration for the specified monster name and assigns it to this object.
void GetMonsterConfig(const AString & a_Name);
+ /** Returns whether this mob is undead (skeleton, zombie, etc.) */
+ virtual bool IsUndead(void);
+
virtual void EventLosePlayer(void);
virtual void CheckEventLostPlayer(void);
@@ -178,6 +180,7 @@ protected:
/** Stores if mobile is currently moving towards the ultimate, final destination */
bool m_bMovingToDestination;
+
/** Finds the first non-air block position (not the highest, as cWorld::GetHeight does)
If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1
If current Y is solid, goes up to find first nonsolid block, and returns that */
@@ -229,7 +232,7 @@ protected:
AString m_SoundHurt;
AString m_SoundDeath;
- float m_AttackRate;
+ float m_AttackRate;
int m_AttackDamage;
int m_AttackRange;
float m_AttackInterval;
@@ -246,13 +249,13 @@ protected:
bool m_BurnsInDaylight;
/** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/
- void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
+ void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
/** Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops*/
- void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0);
+ void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0);
/** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/
- void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel);
+ void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel);
/** Adds armor that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/
void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel);
@@ -261,7 +264,7 @@ protected:
void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel);
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h
index 16f6c8248..fb002c2bf 100644
--- a/src/Mobs/Mooshroom.h
+++ b/src/Mobs/Mooshroom.h
@@ -15,7 +15,7 @@ class cMooshroom :
public:
cMooshroom(void);
- CLASS_PROTODEF(cMooshroom);
+ CLASS_PROTODEF(cMooshroom)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/Ocelot.h b/src/Mobs/Ocelot.h
index adb7a1f75..f2727d354 100644
--- a/src/Mobs/Ocelot.h
+++ b/src/Mobs/Ocelot.h
@@ -18,7 +18,7 @@ public:
{
}
- CLASS_PROTODEF(cOcelot);
+ CLASS_PROTODEF(cOcelot)
} ;
diff --git a/src/Mobs/PassiveAggressiveMonster.cpp b/src/Mobs/PassiveAggressiveMonster.cpp
index 4b45f9a2a..24501b1ba 100644
--- a/src/Mobs/PassiveAggressiveMonster.cpp
+++ b/src/Mobs/PassiveAggressiveMonster.cpp
@@ -19,9 +19,12 @@ cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigNam
-void cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
+bool cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- super::DoTakeDamage(a_TDI);
+ if (!super::DoTakeDamage(a_TDI))
+ {
+ return false;
+ }
if ((m_Target != NULL) && (m_Target->IsPlayer()))
{
@@ -30,6 +33,7 @@ void cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
m_EMState = CHASING;
}
}
+ return true;
}
diff --git a/src/Mobs/PassiveAggressiveMonster.h b/src/Mobs/PassiveAggressiveMonster.h
index 2c5ef30b1..a0da50e8e 100644
--- a/src/Mobs/PassiveAggressiveMonster.h
+++ b/src/Mobs/PassiveAggressiveMonster.h
@@ -15,7 +15,7 @@ class cPassiveAggressiveMonster :
public:
cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
- virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
} ;
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index 904cd63cc..2861d7314 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -18,13 +18,17 @@ cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eType a_MobType,
-void cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
+bool cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- super::DoTakeDamage(a_TDI);
+ if (!super::DoTakeDamage(a_TDI))
+ {
+ return false;
+ }
if ((a_TDI.Attacker != this) && (a_TDI.Attacker != NULL))
{
m_EMState = ESCAPING;
}
+ return true;
}
diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h
index 0b3c155da..70574585a 100644
--- a/src/Mobs/PassiveMonster.h
+++ b/src/Mobs/PassiveMonster.h
@@ -18,7 +18,7 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
/// When hit by someone, run away
- virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
/** Returns the item that the animal of this class follows when a player holds it in hand
Return an empty item not to follow (default). */
virtual const cItem GetFollowedItem(void) const { return cItem(); }
diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp
index e862f5aaa..1f77cf613 100644
--- a/src/Mobs/Pig.cpp
+++ b/src/Mobs/Pig.cpp
@@ -78,3 +78,23 @@ void cPig::OnRightClicked(cPlayer & a_Player)
+
+
+void cPig::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ super::Tick(a_Dt, a_Chunk);
+
+ // If the attachee player is holding a carrot-on-stick, let them drive this pig:
+ if (m_bIsSaddled && (m_Attachee != NULL))
+ {
+ if (m_Attachee->IsPlayer() && (m_Attachee->GetEquippedWeapon().m_ItemType == E_ITEM_CARROT_ON_STICK))
+ {
+ MoveToPosition((m_Attachee->GetPosition()) + (m_Attachee->GetLookVector()*10));
+ m_bMovingToDestination = true;
+ }
+ }
+}
+
+
+
+
diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h
index d434324c1..534a0ca6f 100644
--- a/src/Mobs/Pig.h
+++ b/src/Mobs/Pig.h
@@ -15,10 +15,11 @@ class cPig :
public:
cPig(void);
- CLASS_PROTODEF(cPig);
+ CLASS_PROTODEF(cPig)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); }
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index 5a6b760af..9fb47201d 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -5,6 +5,7 @@
#include "../BlockID.h"
#include "../Entities/Player.h"
#include "../World.h"
+#include "FastRandom.h"
@@ -16,6 +17,16 @@ cSheep::cSheep(int a_Color) :
m_WoolColor(a_Color),
m_TimeToStopEating(-1)
{
+ // Generate random wool color.
+ if (m_WoolColor == -1)
+ {
+ m_WoolColor = GenerateNaturalRandomColor();
+ }
+
+ if ((m_WoolColor < 0) || (m_WoolColor > 15))
+ {
+ m_WoolColor = 0;
+ }
}
@@ -37,20 +48,17 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSheep::OnRightClicked(cPlayer & a_Player)
{
const cItem & EquippedItem = a_Player.GetEquippedItem();
- if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared))
+ if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && !IsSheared() && !IsBaby())
{
m_IsSheared = true;
m_World->BroadcastEntityMetadata(*this);
-
- if (!a_Player.IsGameModeCreative())
- {
- a_Player.UseEquippedItem();
- }
+ a_Player.UseEquippedItem();
cItems Drops;
int NumDrops = m_World->GetTickRandomNumber(2) + 1;
Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
+ m_World->BroadcastSoundEffect("mob.sheep.shear", GetPosX(), GetPosY(), GetPosZ(), 1.0f, 1.0f);
}
else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage))
{
@@ -81,12 +89,12 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk)
if (m_TimeToStopEating > 0)
{
- m_bMovingToDestination = false; // The sheep should not move when he's eating
+ m_bMovingToDestination = false; // The sheep should not move when he's eating
m_TimeToStopEating--;
if (m_TimeToStopEating == 0)
{
- if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime
+ if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime
{
// The sheep ate the grass so we change it to dirt
m_World->SetBlock(PosX, PosY, PosZ, E_BLOCK_DIRT, 0);
@@ -109,3 +117,38 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk)
}
}
+
+
+
+
+NIBBLETYPE cSheep::GenerateNaturalRandomColor(void)
+{
+ cFastRandom Random;
+ int Chance = Random.NextInt(101);
+
+ if (Chance <= 81)
+ {
+ return E_META_WOOL_WHITE;
+ }
+ else if (Chance <= 86)
+ {
+ return E_META_WOOL_BLACK;
+ }
+ else if (Chance <= 91)
+ {
+ return E_META_WOOL_GRAY;
+ }
+ else if (Chance <= 96)
+ {
+ return E_META_WOOL_LIGHTGRAY;
+ }
+ else if (Chance <= 99)
+ {
+ return E_META_WOOL_BROWN;
+ }
+ else
+ {
+ return E_META_WOOL_PINK;
+ }
+}
+
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 402e8e61c..28e1c7254 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -13,21 +13,32 @@ class cSheep :
typedef cPassiveMonster super;
public:
- cSheep(int a_Color);
-
- CLASS_PROTODEF(cSheep);
-
+
+ /** The number is the color of the sheep.
+ Use E_META_WOOL_* constants for the wool color.
+ If you type -1, the server will generate a random color
+ with the GenerateNaturalRandomColor() function. */
+ cSheep(int a_Color = -1);
+
+ CLASS_PROTODEF(cSheep)
+
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
+ /** Generates a random color for the sheep like the vanilla server.
+ The percent's where used are from the wiki: http://minecraft.gamepedia.com/Sheep#Breeding */
+ static NIBBLETYPE GenerateNaturalRandomColor(void);
+
bool IsSheared(void) const { return m_IsSheared; }
+ void SetSheared(bool a_IsSheared) { m_IsSheared = a_IsSheared; }
+
int GetFurColor(void) const { return m_WoolColor; }
+ void SetFurColor(int a_WoolColor) { m_WoolColor = a_WoolColor; }
private:
-
bool m_IsSheared;
int m_WoolColor;
int m_TimeToStopEating;
diff --git a/src/Mobs/Silverfish.h b/src/Mobs/Silverfish.h
index a6e11c49d..2df333dbc 100644
--- a/src/Mobs/Silverfish.h
+++ b/src/Mobs/Silverfish.h
@@ -18,7 +18,7 @@ public:
{
}
- CLASS_PROTODEF(cSilverfish);
+ CLASS_PROTODEF(cSilverfish)
} ;
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index 1e62d7987..cd707f4bb 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -4,6 +4,7 @@
#include "Skeleton.h"
#include "../World.h"
#include "../Entities/ArrowEntity.h"
+#include "ClientHandle.h"
@@ -47,13 +48,12 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cSkeleton::MoveToPosition(const Vector3f & a_Position)
+void cSkeleton::MoveToPosition(const Vector3d & a_Position)
{
- // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement.
+ // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement
if (
!IsOnFire() &&
- (m_World->GetTimeOfDay() < 13187) &&
- (m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15)
+ (m_World->GetBlockSkyLight((int)floor(a_Position.x), (int)floor(a_Position.y), (int)floor(a_Position.z)) - m_World->GetSkyDarkness() > 8)
)
{
m_bMovingToDestination = false;
@@ -81,12 +81,27 @@ void cSkeleton::Attack(float a_Dt)
{
return;
}
- if (!Arrow->Initialize(m_World))
+ if (!Arrow->Initialize(*m_World))
{
delete Arrow;
+ Arrow = NULL;
return;
}
m_World->BroadcastSpawnEntity(*Arrow);
m_AttackInterval = 0.0;
}
}
+
+
+
+
+
+void cSkeleton::SpawnOn(cClientHandle & a_ClientHandle)
+{
+ super::SpawnOn(a_ClientHandle);
+ a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW));
+}
+
+
+
+
diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h
index 8f31b42e1..577588b32 100644
--- a/src/Mobs/Skeleton.h
+++ b/src/Mobs/Skeleton.h
@@ -15,12 +15,16 @@ class cSkeleton :
public:
cSkeleton(bool IsWither);
- CLASS_PROTODEF(cSkeleton);
+ CLASS_PROTODEF(cSkeleton)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- virtual void MoveToPosition(const Vector3f & a_Position) override;
+ virtual void MoveToPosition(const Vector3d & a_Position) override;
virtual void Attack(float a_Dt) override;
- bool IsWither(void) const { return m_bIsWither; };
+ virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
+
+ virtual bool IsUndead(void) override { return true; }
+
+ bool IsWither(void) const { return m_bIsWither; }
private:
diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp
index 52a52bb39..b709ec664 100644
--- a/src/Mobs/Slime.cpp
+++ b/src/Mobs/Slime.cpp
@@ -2,16 +2,25 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Slime.h"
+#include "FastRandom.h"
+#include "World.h"
-/// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest
cSlime::cSlime(int a_Size) :
- super("Slime", mtSlime, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size),
+ super("Slime",
+ mtSlime,
+ Printf("mob.slime.%s", GetSizeName(a_Size).c_str()),
+ Printf("mob.slime.%s", GetSizeName(a_Size).c_str()),
+ 0.6 * a_Size,
+ 0.6 * a_Size
+ ),
m_Size(a_Size)
{
+ SetMaxHealth(a_Size * a_Size);
+ SetAttackDamage(a_Size);
}
@@ -25,7 +34,9 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
- if (GetSize() == 1)
+
+ // Only slimes with the size 1 can drop slimeballs.
+ if (m_Size == 1)
{
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SLIMEBALL);
}
@@ -34,3 +45,62 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+
+void cSlime::Attack(float a_Dt)
+{
+ if (m_Size > 1)
+ {
+ // Only slimes larger than size 1 attack a player.
+ super::Attack(a_Dt);
+ }
+}
+
+
+
+
+
+void cSlime::KilledBy(TakeDamageInfo & a_TDI)
+{
+ if (GetHealth() > 0)
+ {
+ return;
+ }
+
+ if (m_Size != 1)
+ {
+ cFastRandom Random;
+ int SpawnAmount = 2 + Random.NextInt(3);
+
+ for (int i = 0; i < SpawnAmount; ++i)
+ {
+ double AddX = (i % 2 - 0.5) * m_Size / 4.0;
+ double AddZ = (i / 2 - 0.5) * m_Size / 4.0;
+
+ cSlime * NewSlime = new cSlime(m_Size / 2);
+ NewSlime->SetPosition(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ);
+ NewSlime->SetYaw(Random.NextFloat(1.0f) * 360.0f);
+ m_World->SpawnMobFinalize(NewSlime);
+ }
+ }
+ super::KilledBy(a_TDI);
+}
+
+
+
+
+
+const AString cSlime::GetSizeName(int a_Size) const
+{
+ if (a_Size > 1)
+ {
+ return "big";
+ }
+ else
+ {
+ return "small";
+ }
+}
+
+
+
+
diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h
index 782c3113f..f0b800f94 100644
--- a/src/Mobs/Slime.h
+++ b/src/Mobs/Slime.h
@@ -13,17 +13,26 @@ class cSlime :
typedef cAggressiveMonster super;
public:
- /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest
+ /** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */
cSlime(int a_Size);
- CLASS_PROTODEF(cSlime);
+ CLASS_PROTODEF(cSlime)
+ // cAggressiveMonster overrides:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void Attack(float a_Dt) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+
int GetSize(void) const { return m_Size; }
+ /** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds.
+ Returns either "big" or "small". */
+ const AString GetSizeName(int a_Size) const;
+
protected:
- /// Size of the slime, 1 .. 3, with 1 being the smallest
+ /** Size of the slime, with 1 being the smallest.
+ Vanilla uses sizes 1, 2 and 4 only. */
int m_Size;
} ;
diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp
index c1979a495..76334d970 100644
--- a/src/Mobs/SnowGolem.cpp
+++ b/src/Mobs/SnowGolem.cpp
@@ -30,7 +30,7 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())) ))
+ if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ()))))
{
TakeDamage(*this);
}
diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h
index ff5e90da8..aba89e52d 100644
--- a/src/Mobs/SnowGolem.h
+++ b/src/Mobs/SnowGolem.h
@@ -15,7 +15,7 @@ class cSnowGolem :
public:
cSnowGolem(void);
- CLASS_PROTODEF(cSnowGolem);
+ CLASS_PROTODEF(cSnowGolem)
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/Spider.h b/src/Mobs/Spider.h
index 51e65d028..813d2e266 100644
--- a/src/Mobs/Spider.h
+++ b/src/Mobs/Spider.h
@@ -15,7 +15,7 @@ class cSpider :
public:
cSpider(void);
- CLASS_PROTODEF(cSpider);
+ CLASS_PROTODEF(cSpider)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;
diff --git a/src/Mobs/Squid.h b/src/Mobs/Squid.h
index a9dba8b70..b57340427 100644
--- a/src/Mobs/Squid.h
+++ b/src/Mobs/Squid.h
@@ -17,7 +17,7 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- CLASS_PROTODEF(cSquid);
+ CLASS_PROTODEF(cSquid)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index d049acc1e..1cdac7c74 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -23,9 +23,13 @@ cVillager::cVillager(eVillagerType VillagerType) :
-void cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
+bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- super::DoTakeDamage(a_TDI);
+ if (!super::DoTakeDamage(a_TDI))
+ {
+ return false;
+ }
+
if ((a_TDI.Attacker != NULL) && a_TDI.Attacker->IsPlayer())
{
if (m_World->GetTickRandomNumber(5) == 3)
@@ -33,6 +37,7 @@ void cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
m_World->BroadcastEntityStatus(*this, esVillagerAngry);
}
}
+ return true;
}
@@ -50,7 +55,7 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
{
switch (m_Type)
{
- case vtFarmer:
+ case vtFarmer:
{
HandleFarmerPlaceCrops();
}
@@ -133,8 +138,8 @@ void cVillager::HandleFarmerPrepareFarmCrops()
m_CropsPos = Vector3i((int) GetPosX() + X - 5, (int) GetPosY() + Y - 3, (int) GetPosZ() + Z - 5);
MoveToPosition(Vector3f((float) (m_CropsPos.x + 0.5), (float) m_CropsPos.y, (float) (m_CropsPos.z + 0.5)));
return;
- } // for Y loop.
- } // Repeat the procces 5 times.
+ } // for Y loop.
+ } // Repeat the procces 5 times.
}
diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h
index 5bba4d4ba..aa81f0790 100644
--- a/src/Mobs/Villager.h
+++ b/src/Mobs/Villager.h
@@ -27,19 +27,18 @@ public:
cVillager(eVillagerType VillagerType);
- CLASS_PROTODEF(cVillager);
+ CLASS_PROTODEF(cVillager)
// cEntity overrides
- virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
// cVillager functions
/** return true if the given blocktype are: crops, potatoes or carrots.*/
bool IsBlockFarmable(BLOCKTYPE a_BlockType);
- //////////////////////////////////////////////////////////////////
// Farmer functions
- /** It searches in a 11x7x11 area for crops. If it found some it will navigate to them.*/
+ /** Searches in a 11x7x11 area for crops. If it found some it will navigate to them.*/
void HandleFarmerPrepareFarmCrops();
/** Looks if the farmer has reached it's destination, and if it's still crops and the destination is closer then 2 blocks it will harvest them.*/
@@ -49,7 +48,7 @@ public:
void HandleFarmerPlaceCrops();
// Get and set functions.
- int GetVilType(void) const { return m_Type; }
+ int GetVilType(void) const { return m_Type; }
Vector3i GetCropsPos(void) const { return m_CropsPos; }
bool DoesHaveActionActivated(void) const { return m_VillagerAction; }
diff --git a/src/Mobs/Witch.h b/src/Mobs/Witch.h
index 51c63322a..bd059f61d 100644
--- a/src/Mobs/Witch.h
+++ b/src/Mobs/Witch.h
@@ -16,7 +16,7 @@ class cWitch :
public:
cWitch();
- CLASS_PROTODEF(cWitch);
+ CLASS_PROTODEF(cWitch)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index 8f5d28b68..578b47995 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -2,7 +2,9 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Wither.h"
+
#include "../World.h"
+#include "../Entities/Player.h"
@@ -10,7 +12,7 @@
cWither::cWither(void) :
super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0),
- m_InvulnerableTicks(220)
+ m_WitherInvulnerableTicks(220)
{
SetMaxHealth(300);
}
@@ -28,7 +30,7 @@ bool cWither::IsArmored(void) const
-bool cWither::Initialize(cWorld * a_World)
+bool cWither::Initialize(cWorld & a_World)
{
// Set health before BroadcastSpawnEntity()
SetHealth(GetMaxHealth() / 3);
@@ -40,24 +42,24 @@ bool cWither::Initialize(cWorld * a_World)
-void cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
+bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (a_TDI.DamageType == dtDrowning)
{
- return;
+ return false;
}
- if (m_InvulnerableTicks > 0)
+ if (m_WitherInvulnerableTicks > 0)
{
- return;
+ return false;
}
if (IsArmored() && (a_TDI.DamageType == dtRangedAttack))
{
- return;
+ return false;
}
- super::DoTakeDamage(a_TDI);
+ return super::DoTakeDamage(a_TDI);
}
@@ -68,16 +70,16 @@ void cWither::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (m_InvulnerableTicks > 0)
+ if (m_WitherInvulnerableTicks > 0)
{
- unsigned int NewTicks = m_InvulnerableTicks - 1;
+ unsigned int NewTicks = m_WitherInvulnerableTicks - 1;
if (NewTicks == 0)
{
m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this);
}
- m_InvulnerableTicks = NewTicks;
+ m_WitherInvulnerableTicks = NewTicks;
if ((NewTicks % 10) == 0)
{
@@ -100,3 +102,35 @@ void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+
+void cWither::KilledBy(TakeDamageInfo & a_TDI)
+{
+ super::KilledBy(a_TDI);
+
+ class cPlayerCallback : public cPlayerListCallback
+ {
+ Vector3f m_Pos;
+
+ virtual bool Item(cPlayer * a_Player)
+ {
+ // TODO 2014-05-21 xdot: Vanilla minecraft uses an AABB check instead of a radius one
+ double Dist = (a_Player->GetPosition() - m_Pos).Length();
+ if (Dist < 50.0)
+ {
+ // If player is close, award achievement
+ a_Player->AwardAchievement(achKillWither);
+ }
+ return false;
+ }
+
+ public:
+ cPlayerCallback(const Vector3f & a_Pos) : m_Pos(a_Pos) {}
+
+ } PlayerCallback(GetPosition());
+
+ m_World->ForEachPlayer(PlayerCallback);
+}
+
+
+
+
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index bc78bfaad..2403823ed 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -15,25 +15,28 @@ class cWither :
public:
cWither(void);
- CLASS_PROTODEF(cWither);
+ CLASS_PROTODEF(cWither)
- unsigned int GetNumInvulnerableTicks(void) const { return m_InvulnerableTicks; }
+ unsigned int GetWitherInvulnerableTicks(void) const { return m_WitherInvulnerableTicks; }
- void SetNumInvulnerableTicks(unsigned int a_Ticks) { m_InvulnerableTicks = a_Ticks; }
+ void SetWitherInvulnerableTicks(unsigned int a_Ticks) { m_WitherInvulnerableTicks = a_Ticks; }
/** Returns whether the wither is invulnerable to arrows. */
bool IsArmored(void) const;
// cEntity overrides
- virtual bool Initialize(cWorld * a_World) override;
+ virtual bool Initialize(cWorld & a_World) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+
+ virtual bool IsUndead(void) override { return true; }
private:
/** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */
- unsigned int m_InvulnerableTicks;
+ unsigned int m_WitherInvulnerableTicks;
} ;
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index f02b8a4fc..5bb97d30e 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -25,14 +25,19 @@ cWolf::cWolf(void) :
-void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
+bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- super::DoTakeDamage(a_TDI);
+ if (super::DoTakeDamage(a_TDI))
+ {
+ return false;
+ }
+
if (!m_IsTame)
{
m_IsAngry = true;
}
- m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face
+ m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face
+ return true;
}
@@ -109,7 +114,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
}
case E_ITEM_DYE:
{
- if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
+ if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
{
SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage);
if (!a_Player.IsGameModeCreative())
@@ -121,7 +126,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
}
default:
{
- if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
+ if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
{
SetIsSitting(!IsSitting());
}
@@ -167,7 +172,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
m_World->BroadcastEntityMetadata(*this);
}
- m_FinalDestination = a_Closest_Player->GetPosition(); // So that we will look at a player holding food
+ m_FinalDestination = a_Closest_Player->GetPosition(); // So that we will look at a player holding food
// Don't move to the player if the wolf is sitting.
if (!IsSitting())
diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h
index 5925373e1..2e83db701 100644
--- a/src/Mobs/Wolf.h
+++ b/src/Mobs/Wolf.h
@@ -16,9 +16,9 @@ class cWolf :
public:
cWolf(void);
- CLASS_PROTODEF(cWolf);
+ CLASS_PROTODEF(cWolf)
- virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void TickFollowPlayer();
diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp
index f19e096ee..30225c32d 100644
--- a/src/Mobs/Zombie.cpp
+++ b/src/Mobs/Zombie.cpp
@@ -42,13 +42,12 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cZombie::MoveToPosition(const Vector3f & a_Position)
+void cZombie::MoveToPosition(const Vector3d & a_Position)
{
- // If the destination is in the sun and if it is not night AND the zombie isn't on fire then block the movement.
+ // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement
if (
!IsOnFire() &&
- (m_World->GetTimeOfDay() < 13187) &&
- (m_World->GetBlockSkyLight((int)a_Position.x, (int)a_Position.y, (int)a_Position.z) == 15)
+ (m_World->GetBlockSkyLight((int)floor(a_Position.x), (int)floor(a_Position.y), (int)floor(a_Position.z)) - m_World->GetSkyDarkness() > 8)
)
{
m_bMovingToDestination = false;
diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h
index 1ba368f9c..118b6e6e7 100644
--- a/src/Mobs/Zombie.h
+++ b/src/Mobs/Zombie.h
@@ -14,13 +14,15 @@ class cZombie :
public:
cZombie(bool a_IsVillagerZombie);
- CLASS_PROTODEF(cZombie);
+ CLASS_PROTODEF(cZombie)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- virtual void MoveToPosition(const Vector3f & a_Position) override;
+ virtual void MoveToPosition(const Vector3d & a_Position) override;
- bool IsVillagerZombie(void) const {return m_IsVillagerZombie; }
- bool IsConverting (void) const {return m_IsConverting; }
+ virtual bool IsUndead(void) override { return true; }
+
+ bool IsVillagerZombie(void) const { return m_IsVillagerZombie; }
+ bool IsConverting (void) const { return m_IsConverting; }
private:
diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp
index c9d94face..05350f877 100644
--- a/src/Mobs/ZombiePigman.cpp
+++ b/src/Mobs/ZombiePigman.cpp
@@ -37,11 +37,11 @@ void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cZombiePigman::KilledBy(cEntity * a_Killer)
+void cZombiePigman::KilledBy(TakeDamageInfo & a_TDI)
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
- if ((a_Killer != NULL) && (a_Killer->IsPlayer()))
+ if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
{
// TODO: Anger all nearby zombie pigmen
// TODO: In vanilla, if one player angers ZPs, do they attack any nearby player, or only that one attacker?
diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h
index ab3cebf6d..bae0115eb 100644
--- a/src/Mobs/ZombiePigman.h
+++ b/src/Mobs/ZombiePigman.h
@@ -14,10 +14,12 @@ class cZombiePigman :
public:
cZombiePigman(void);
- CLASS_PROTODEF(cZombiePigman);
+ CLASS_PROTODEF(cZombiePigman)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+
+ virtual bool IsUndead(void) override { return true; }
} ;
diff --git a/src/MonsterConfig.cpp b/src/MonsterConfig.cpp
index 72a3a3245..f5e078213 100644
--- a/src/MonsterConfig.cpp
+++ b/src/MonsterConfig.cpp
@@ -35,7 +35,7 @@ struct cMonsterConfig::sMonsterConfigState
cMonsterConfig::cMonsterConfig(void)
- : m_pState( new sMonsterConfigState )
+ : m_pState( new sMonsterConfigState)
{
Initialize();
}
@@ -47,6 +47,7 @@ cMonsterConfig::cMonsterConfig(void)
cMonsterConfig::~cMonsterConfig()
{
delete m_pState;
+ m_pState = NULL;
}
diff --git a/src/Noise.cpp b/src/Noise.cpp
index 95a022ea3..507d05ea5 100644
--- a/src/Noise.cpp
+++ b/src/Noise.cpp
@@ -9,7 +9,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Globals:
void Debug3DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase)
@@ -90,7 +90,7 @@ void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, cons
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCubicCell2D:
class cCubicCell2D
@@ -239,7 +239,7 @@ void cCubicCell2D::Move(int a_NewFloorX, int a_NewFloorY)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCubicCell3D:
class cCubicCell3D
@@ -422,7 +422,7 @@ void cCubicCell3D::Move(int a_NewFloorX, int a_NewFloorY, int a_NewFloorZ)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cNoise:
cNoise::cNoise(int a_Seed) :
@@ -487,8 +487,8 @@ NOISE_DATATYPE cNoise::SmoothNoise1D(int a_X) const
NOISE_DATATYPE cNoise::CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) const
{
- const int BaseX = FAST_FLOOR(a_X);
- const int BaseY = FAST_FLOOR(a_Y);
+ const int BaseX = FAST_FLOOR(a_X);
+ const int BaseY = FAST_FLOOR(a_Y);
const NOISE_DATATYPE points[4][4] =
{
@@ -515,74 +515,78 @@ NOISE_DATATYPE cNoise::CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) cons
NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOISE_DATATYPE a_Z) const
{
- const int BaseX = FAST_FLOOR(a_X);
- const int BaseY = FAST_FLOOR(a_Y);
- const int BaseZ = FAST_FLOOR(a_Z);
+ const int BaseX = FAST_FLOOR(a_X);
+ const int BaseY = FAST_FLOOR(a_Y);
+ const int BaseZ = FAST_FLOOR(a_Z);
- const NOISE_DATATYPE points1[4][4] = {
+ const NOISE_DATATYPE points1[4][4] =
+ {
{ IntNoise3D(BaseX - 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ - 1), },
{ IntNoise3D(BaseX - 1, BaseY, BaseZ - 1), IntNoise3D(BaseX, BaseY, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY, BaseZ - 1), },
{ IntNoise3D(BaseX - 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ - 1), },
{ IntNoise3D(BaseX - 1, BaseY + 2, BaseZ - 1), IntNoise3D(BaseX, BaseY + 2, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY + 2, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY + 2, BaseZ - 1), },
};
- const NOISE_DATATYPE FracX = (a_X) - BaseX;
- const NOISE_DATATYPE x1interp1 = CubicInterpolate( points1[0][0], points1[0][1], points1[0][2], points1[0][3], FracX );
- const NOISE_DATATYPE x1interp2 = CubicInterpolate( points1[1][0], points1[1][1], points1[1][2], points1[1][3], FracX );
- const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX );
- const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX );
-
- const NOISE_DATATYPE points2[4][4] = {
- { IntNoise3D( BaseX-1, BaseY-1, BaseZ ), IntNoise3D( BaseX, BaseY-1, BaseZ ), IntNoise3D( BaseX+1, BaseY-1, BaseZ ), IntNoise3D( BaseX+2, BaseY-1, BaseZ ), },
- { IntNoise3D( BaseX-1, BaseY, BaseZ ), IntNoise3D( BaseX, BaseY, BaseZ ), IntNoise3D( BaseX+1, BaseY, BaseZ ), IntNoise3D( BaseX+2, BaseY, BaseZ ), },
- { IntNoise3D( BaseX-1, BaseY+1, BaseZ ), IntNoise3D( BaseX, BaseY+1, BaseZ ), IntNoise3D( BaseX+1, BaseY+1, BaseZ ), IntNoise3D( BaseX+2, BaseY+1, BaseZ ), },
- { IntNoise3D( BaseX-1, BaseY+2, BaseZ ), IntNoise3D( BaseX, BaseY+2, BaseZ ), IntNoise3D( BaseX+1, BaseY+2, BaseZ ), IntNoise3D( BaseX+2, BaseY+2, BaseZ ), },
+ const NOISE_DATATYPE FracX = (a_X) - BaseX;
+ const NOISE_DATATYPE x1interp1 = CubicInterpolate( points1[0][0], points1[0][1], points1[0][2], points1[0][3], FracX);
+ const NOISE_DATATYPE x1interp2 = CubicInterpolate( points1[1][0], points1[1][1], points1[1][2], points1[1][3], FracX);
+ const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX);
+ const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX);
+
+ const NOISE_DATATYPE points2[4][4] =
+ {
+ { IntNoise3D(BaseX - 1, BaseY - 1, BaseZ), IntNoise3D(BaseX, BaseY - 1, BaseZ), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ), },
+ { IntNoise3D(BaseX - 1, BaseY, BaseZ), IntNoise3D(BaseX, BaseY, BaseZ), IntNoise3D(BaseX + 1, BaseY, BaseZ), IntNoise3D(BaseX + 2, BaseY, BaseZ), },
+ { IntNoise3D(BaseX - 1, BaseY + 1, BaseZ), IntNoise3D(BaseX, BaseY + 1, BaseZ), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ), },
+ { IntNoise3D(BaseX - 1, BaseY + 2, BaseZ), IntNoise3D(BaseX, BaseY + 2, BaseZ), IntNoise3D(BaseX + 1, BaseY + 2, BaseZ), IntNoise3D(BaseX + 2, BaseY + 2, BaseZ), },
};
- const NOISE_DATATYPE x2interp1 = CubicInterpolate( points2[0][0], points2[0][1], points2[0][2], points2[0][3], FracX );
- const NOISE_DATATYPE x2interp2 = CubicInterpolate( points2[1][0], points2[1][1], points2[1][2], points2[1][3], FracX );
- const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX );
- const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX );
+ const NOISE_DATATYPE x2interp1 = CubicInterpolate( points2[0][0], points2[0][1], points2[0][2], points2[0][3], FracX);
+ const NOISE_DATATYPE x2interp2 = CubicInterpolate( points2[1][0], points2[1][1], points2[1][2], points2[1][3], FracX);
+ const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX);
+ const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX);
- const NOISE_DATATYPE points3[4][4] = {
- { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), },
- { IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), },
- { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), },
- { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), },
+ const NOISE_DATATYPE points3[4][4] =
+ {
+ { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1), IntNoise3D( BaseX, BaseY-1, BaseZ+1), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), },
+ { IntNoise3D( BaseX-1, BaseY, BaseZ+1), IntNoise3D( BaseX, BaseY, BaseZ+1), IntNoise3D( BaseX+1, BaseY, BaseZ+1), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), },
+ { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1), IntNoise3D( BaseX, BaseY+1, BaseZ+1), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), },
+ { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1), IntNoise3D( BaseX, BaseY+2, BaseZ+1), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), },
};
- const NOISE_DATATYPE x3interp1 = CubicInterpolate( points3[0][0], points3[0][1], points3[0][2], points3[0][3], FracX );
- const NOISE_DATATYPE x3interp2 = CubicInterpolate( points3[1][0], points3[1][1], points3[1][2], points3[1][3], FracX );
- const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX );
- const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX );
+ const NOISE_DATATYPE x3interp1 = CubicInterpolate( points3[0][0], points3[0][1], points3[0][2], points3[0][3], FracX);
+ const NOISE_DATATYPE x3interp2 = CubicInterpolate( points3[1][0], points3[1][1], points3[1][2], points3[1][3], FracX);
+ const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX);
+ const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX);
- const NOISE_DATATYPE points4[4][4] = {
- { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ), },
- { IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ), },
- { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ), },
- { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2 ), },
+ const NOISE_DATATYPE points4[4][4] =
+ {
+ { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2), IntNoise3D( BaseX, BaseY-1, BaseZ+2), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2), },
+ { IntNoise3D( BaseX-1, BaseY, BaseZ+2), IntNoise3D( BaseX, BaseY, BaseZ+2), IntNoise3D( BaseX+1, BaseY, BaseZ+2), IntNoise3D( BaseX+2, BaseY, BaseZ+2), },
+ { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2), IntNoise3D( BaseX, BaseY+1, BaseZ+2), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2), },
+ { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2), IntNoise3D( BaseX, BaseY+2, BaseZ+2), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2), },
};
- const NOISE_DATATYPE x4interp1 = CubicInterpolate( points4[0][0], points4[0][1], points4[0][2], points4[0][3], FracX );
- const NOISE_DATATYPE x4interp2 = CubicInterpolate( points4[1][0], points4[1][1], points4[1][2], points4[1][3], FracX );
- const NOISE_DATATYPE x4interp3 = CubicInterpolate( points4[2][0], points4[2][1], points4[2][2], points4[2][3], FracX );
- const NOISE_DATATYPE x4interp4 = CubicInterpolate( points4[3][0], points4[3][1], points4[3][2], points4[3][3], FracX );
+ const NOISE_DATATYPE x4interp1 = CubicInterpolate( points4[0][0], points4[0][1], points4[0][2], points4[0][3], FracX);
+ const NOISE_DATATYPE x4interp2 = CubicInterpolate( points4[1][0], points4[1][1], points4[1][2], points4[1][3], FracX);
+ const NOISE_DATATYPE x4interp3 = CubicInterpolate( points4[2][0], points4[2][1], points4[2][2], points4[2][3], FracX);
+ const NOISE_DATATYPE x4interp4 = CubicInterpolate( points4[3][0], points4[3][1], points4[3][2], points4[3][3], FracX);
- const NOISE_DATATYPE FracY = (a_Y) - BaseY;
- const NOISE_DATATYPE yinterp1 = CubicInterpolate( x1interp1, x1interp2, x1interp3, x1interp4, FracY );
- const NOISE_DATATYPE yinterp2 = CubicInterpolate( x2interp1, x2interp2, x2interp3, x2interp4, FracY );
- const NOISE_DATATYPE yinterp3 = CubicInterpolate( x3interp1, x3interp2, x3interp3, x3interp4, FracY );
- const NOISE_DATATYPE yinterp4 = CubicInterpolate( x4interp1, x4interp2, x4interp3, x4interp4, FracY );
+ const NOISE_DATATYPE FracY = (a_Y) - BaseY;
+ const NOISE_DATATYPE yinterp1 = CubicInterpolate( x1interp1, x1interp2, x1interp3, x1interp4, FracY);
+ const NOISE_DATATYPE yinterp2 = CubicInterpolate( x2interp1, x2interp2, x2interp3, x2interp4, FracY);
+ const NOISE_DATATYPE yinterp3 = CubicInterpolate( x3interp1, x3interp2, x3interp3, x3interp4, FracY);
+ const NOISE_DATATYPE yinterp4 = CubicInterpolate( x4interp1, x4interp2, x4interp3, x4interp4, FracY);
- const NOISE_DATATYPE FracZ = (a_Z) - BaseZ;
- return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ );
+ const NOISE_DATATYPE FracZ = (a_Z) - BaseZ;
+ return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ);
}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCubicNoise:
#ifdef _DEBUG
@@ -608,6 +612,8 @@ void cCubicNoise::Generate2D(
NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY ///< Noise-space coords of the array in the Y direction
) const
{
+ ASSERT(a_SizeX > 0);
+ ASSERT(a_SizeY > 0);
ASSERT(a_SizeX < MAX_SIZE);
ASSERT(a_SizeY < MAX_SIZE);
ASSERT(a_StartX < a_EndX);
@@ -629,7 +635,7 @@ void cCubicNoise::Generate2D(
Cell.InitWorkRnds(FloorX[0], FloorY[0]);
#ifdef _DEBUG
- // Statistics on the noise-space coords:
+ // Statistics on the noise-space coords:
if (NumSameX == 1)
{
m_NumSingleX++;
@@ -780,7 +786,7 @@ void cCubicNoise::CalcFloorFrac(
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cPerlinNoise:
cPerlinNoise::cPerlinNoise(void) :
@@ -812,7 +818,7 @@ void cPerlinNoise::SetSeed(int a_Seed)
void cPerlinNoise::AddOctave(float a_Frequency, float a_Amplitude)
{
- m_Octaves.push_back(cOctave(m_Seed * (m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude));
+ m_Octaves.push_back(cOctave(m_Seed * ((int)m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude));
}
@@ -852,7 +858,7 @@ void cPerlinNoise::Generate2D(
NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude;
for (int i = 0; i < ArrayCount; i++)
{
- a_Array[i] *= Amplitude;
+ a_Array[i] = a_Workspace[i] * Amplitude;
}
// Add each octave:
@@ -875,6 +881,7 @@ void cPerlinNoise::Generate2D(
if (ShouldFreeWorkspace)
{
delete[] a_Workspace;
+ a_Workspace = NULL;
}
}
@@ -941,6 +948,177 @@ void cPerlinNoise::Generate3D(
if (ShouldFreeWorkspace)
{
delete[] a_Workspace;
+ a_Workspace = NULL;
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cRidgedMultiNoise:
+
+cRidgedMultiNoise::cRidgedMultiNoise(void) :
+ m_Seed(0)
+{
+}
+
+
+
+
+
+cRidgedMultiNoise::cRidgedMultiNoise(int a_Seed) :
+ m_Seed(a_Seed)
+{
+}
+
+
+
+
+
+void cRidgedMultiNoise::SetSeed(int a_Seed)
+{
+ m_Seed = a_Seed;
+}
+
+
+
+
+
+void cRidgedMultiNoise::AddOctave(float a_Frequency, float a_Amplitude)
+{
+ m_Octaves.push_back(cOctave(m_Seed * ((int)m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude));
+}
+
+
+
+
+
+void cRidgedMultiNoise::Generate2D(
+ NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y]
+ int a_SizeX, int a_SizeY, ///< Count of the array, in each direction
+ NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction
+ NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction
+ NOISE_DATATYPE * a_Workspace ///< Workspace that this function can use and trash
+) const
+{
+ if (m_Octaves.empty())
+ {
+ // No work to be done
+ ASSERT(!"RidgedMulti: No octaves to generate!");
+ return;
+ }
+
+ bool ShouldFreeWorkspace = (a_Workspace == NULL);
+ int ArrayCount = a_SizeX * a_SizeY;
+ if (ShouldFreeWorkspace)
+ {
+ a_Workspace = new NOISE_DATATYPE[ArrayCount];
+ }
+
+ // Generate the first octave directly into array:
+ const cOctave & FirstOctave = m_Octaves.front();
+
+ FirstOctave.m_Noise.Generate2D(
+ a_Workspace, a_SizeX, a_SizeY,
+ a_StartX * FirstOctave.m_Frequency, a_EndX * FirstOctave.m_Frequency,
+ a_StartY * FirstOctave.m_Frequency, a_EndY * FirstOctave.m_Frequency
+ );
+ NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude;
+ for (int i = 0; i < ArrayCount; i++)
+ {
+ a_Array[i] = fabs(a_Workspace[i] * Amplitude);
+ }
+
+ // Add each octave:
+ for (cOctaves::const_iterator itr = m_Octaves.begin() + 1, end = m_Octaves.end(); itr != end; ++itr)
+ {
+ // Generate cubic noise for the octave:
+ itr->m_Noise.Generate2D(
+ a_Workspace, a_SizeX, a_SizeY,
+ a_StartX * itr->m_Frequency, a_EndX * itr->m_Frequency,
+ a_StartY * itr->m_Frequency, a_EndY * itr->m_Frequency
+ );
+ // Add the cubic noise into the output:
+ NOISE_DATATYPE Amplitude = itr->m_Amplitude;
+ for (int i = 0; i < ArrayCount; i++)
+ {
+ a_Array[i] += fabs(a_Workspace[i] * Amplitude);
+ }
+ }
+
+ if (ShouldFreeWorkspace)
+ {
+ delete[] a_Workspace;
+ a_Workspace = NULL;
+ }
+}
+
+
+
+
+
+void cRidgedMultiNoise::Generate3D(
+ NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z]
+ int a_SizeX, int a_SizeY, int a_SizeZ, ///< Count of the array, in each direction
+ NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction
+ NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction
+ NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ, ///< Noise-space coords of the array in the Z direction
+ NOISE_DATATYPE * a_Workspace ///< Workspace that this function can use and trash
+) const
+{
+ if (m_Octaves.empty())
+ {
+ // No work to be done
+ ASSERT(!"RidgedMulti: No octaves to generate!");
+ return;
+ }
+
+ bool ShouldFreeWorkspace = (a_Workspace == NULL);
+ int ArrayCount = a_SizeX * a_SizeY * a_SizeZ;
+ if (ShouldFreeWorkspace)
+ {
+ a_Workspace = new NOISE_DATATYPE[ArrayCount];
+ }
+
+ // Generate the first octave directly into array:
+ const cOctave & FirstOctave = m_Octaves.front();
+
+ FirstOctave.m_Noise.Generate3D(
+ a_Workspace, a_SizeX, a_SizeY, a_SizeZ,
+ a_StartX * FirstOctave.m_Frequency, a_EndX * FirstOctave.m_Frequency,
+ a_StartY * FirstOctave.m_Frequency, a_EndY * FirstOctave.m_Frequency,
+ a_StartZ * FirstOctave.m_Frequency, a_EndZ * FirstOctave.m_Frequency
+ );
+ NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude;
+ for (int i = 0; i < ArrayCount; i++)
+ {
+ a_Array[i] = a_Workspace[i] * Amplitude;
+ }
+
+ // Add each octave:
+ for (cOctaves::const_iterator itr = m_Octaves.begin() + 1, end = m_Octaves.end(); itr != end; ++itr)
+ {
+ // Generate cubic noise for the octave:
+ itr->m_Noise.Generate3D(
+ a_Workspace, a_SizeX, a_SizeY, a_SizeZ,
+ a_StartX * itr->m_Frequency, a_EndX * itr->m_Frequency,
+ a_StartY * itr->m_Frequency, a_EndY * itr->m_Frequency,
+ a_StartZ * itr->m_Frequency, a_EndZ * itr->m_Frequency
+ );
+ // Add the cubic noise into the output:
+ NOISE_DATATYPE Amplitude = itr->m_Amplitude;
+ for (int i = 0; i < ArrayCount; i++)
+ {
+ a_Array[i] += a_Workspace[i] * Amplitude;
+ }
+ }
+
+ if (ShouldFreeWorkspace)
+ {
+ delete[] a_Workspace;
+ a_Workspace = NULL;
}
}
diff --git a/src/Noise.h b/src/Noise.h
index 62004503f..4cf8d4ad8 100644
--- a/src/Noise.h
+++ b/src/Noise.h
@@ -5,6 +5,12 @@
#pragma once
+#include <cmath>
+
+
+
+
+
// Some settings
#define NOISE_DATATYPE float
@@ -33,6 +39,12 @@ public:
INLINE NOISE_DATATYPE IntNoise2D(int a_X, int a_Y) const;
INLINE NOISE_DATATYPE IntNoise3D(int a_X, int a_Y, int a_Z) const;
+ // Return a float number in the specified range:
+ INLINE NOISE_DATATYPE IntNoise2DInRange(int a_X, int a_Y, float a_Min, float a_Max) const
+ {
+ return a_Min + std::abs(IntNoise2D(a_X, a_Y)) * (a_Max - a_Min);
+ }
+
// Note: These functions have a mod8-irregular chance - each of the mod8 remainders has different chance of occurrence. Divide by 8 to rectify.
INLINE int IntNoise1DInt(int a_X) const;
INLINE int IntNoise2DInt(int a_X, int a_Y) const;
@@ -100,7 +112,7 @@ protected:
cNoise m_Noise; // Used for integral rnd values
#ifdef _DEBUG
- // Statistics on the noise-space coords:
+ // Statistics on the noise-space coords:
static int m_NumSingleX;
static int m_NumSingleXY;
static int m_NumSingleY;
@@ -192,7 +204,71 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+class cRidgedMultiNoise
+{
+public:
+ cRidgedMultiNoise(void);
+ cRidgedMultiNoise(int a_Seed);
+
+
+ void SetSeed(int a_Seed);
+
+ void AddOctave(NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude);
+
+ void Generate1D(
+ NOISE_DATATYPE * a_Array, ///< Array to generate into
+ int a_SizeX, ///< Count of the array
+ NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array
+ NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash
+ ) const;
+
+
+ void Generate2D(
+ NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y]
+ int a_SizeX, int a_SizeY, ///< Count of the array, in each direction
+ NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction
+ NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction
+ NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash
+ ) const;
+
+
+ void Generate3D(
+ NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z]
+ int a_SizeX, int a_SizeY, int a_SizeZ, ///< Count of the array, in each direction
+ NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction
+ NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction
+ NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ, ///< Noise-space coords of the array in the Z direction
+ NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash
+ ) const;
+
+protected:
+ class cOctave
+ {
+ public:
+ cCubicNoise m_Noise;
+
+ NOISE_DATATYPE m_Frequency; // Coord multiplier
+ NOISE_DATATYPE m_Amplitude; // Value multiplier
+
+ cOctave(int a_Seed, NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude) :
+ m_Noise(a_Seed),
+ m_Frequency(a_Frequency),
+ m_Amplitude(a_Amplitude)
+ {
+ }
+ } ;
+
+ typedef std::vector<cOctave> cOctaves;
+
+ int m_Seed;
+ cOctaves m_Octaves;
+} ;
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// Inline function definitions:
// These need to be in the header, otherwise linker error occur in MSVC
@@ -280,7 +356,7 @@ NOISE_DATATYPE cNoise::CubicInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B,
NOISE_DATATYPE cNoise::CosineInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, NOISE_DATATYPE a_Pct)
{
const NOISE_DATATYPE ft = a_Pct * (NOISE_DATATYPE)3.1415927;
- const NOISE_DATATYPE f = (1 - cos(ft)) * (NOISE_DATATYPE)0.5;
+ const NOISE_DATATYPE f = (NOISE_DATATYPE)((NOISE_DATATYPE)(1 - cos(ft)) * (NOISE_DATATYPE)0.5);
return a_A * (1 - f) + a_B * f;
}
@@ -297,7 +373,7 @@ NOISE_DATATYPE cNoise::LinearInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B,
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Global functions:
extern void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, const AString & a_FileNameBase);
diff --git a/src/OSSupport/BlockingTCPLink.cpp b/src/OSSupport/BlockingTCPLink.cpp
deleted file mode 100644
index 07f48b955..000000000
--- a/src/OSSupport/BlockingTCPLink.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "BlockingTCPLink.h"
-#include "Errors.h"
-
-
-
-
-cBlockingTCPLink::cBlockingTCPLink(void)
-{
-}
-
-
-
-
-
-cBlockingTCPLink::~cBlockingTCPLink()
-{
- CloseSocket();
-}
-
-
-
-
-
-void cBlockingTCPLink::CloseSocket()
-{
- if (!m_Socket.IsValid())
- {
- m_Socket.CloseSocket();
- }
-}
-
-
-
-
-
-bool cBlockingTCPLink::Connect(const char * iAddress, unsigned int iPort)
-{
- ASSERT(!m_Socket.IsValid());
- if (m_Socket.IsValid())
- {
- LOGWARN("WARNING: cTCPLink Connect() called while still connected.");
- m_Socket.CloseSocket();
- }
-
- struct hostent *hp;
- unsigned int addr;
- struct sockaddr_in server;
-
- m_Socket = socket(AF_INET, SOCK_STREAM, 0);
- if (!m_Socket.IsValid())
- {
- LOGERROR("cTCPLink: Cannot create a socket");
- return false;
- }
-
- addr = inet_addr(iAddress);
- hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
- if (hp == NULL)
- {
- //LOGWARN("cTCPLink: gethostbyaddr returned NULL");
- hp = gethostbyname(iAddress);
- if (hp == NULL)
- {
- LOGWARN("cTCPLink: Could not resolve %s", iAddress);
- CloseSocket();
- return false;
- }
- }
-
- memcpy(&server.sin_addr.s_addr,hp->h_addr, hp->h_length);
- server.sin_family = AF_INET;
- server.sin_port = htons( (unsigned short)iPort);
- if (connect(m_Socket, (struct sockaddr *)&server, sizeof(server)))
- {
- LOGWARN("cTCPLink: Connection to \"%s:%d\" failed (%s)", iAddress, iPort,GetOSErrorString( cSocket::GetLastError() ).c_str() );
- CloseSocket();
- return false;
- }
-
- return true;
-}
-
-
-
-
-
-int cBlockingTCPLink::Send(char * a_Data, unsigned int a_Size, int a_Flags /* = 0 */ )
-{
- UNUSED(a_Flags);
-
- ASSERT(m_Socket.IsValid());
- if (!m_Socket.IsValid())
- {
- LOGERROR("cBlockingTCPLink: Trying to send data without a valid connection!");
- return -1;
- }
- return m_Socket.Send(a_Data, a_Size);
-}
-
-
-
-
-
-int cBlockingTCPLink::SendMessage( const char* a_Message, int a_Flags /* = 0 */ )
-{
- UNUSED(a_Flags);
-
- ASSERT(m_Socket.IsValid());
- if (!m_Socket.IsValid())
- {
- LOGWARN("cBlockingTCPLink: Trying to send message without a valid connection!");
- return -1;
- }
- return m_Socket.Send(a_Message, strlen(a_Message));
-}
-
-
-
-
-
-void cBlockingTCPLink::ReceiveData(AString & oData)
-{
- ASSERT(m_Socket.IsValid());
- if (!m_Socket.IsValid())
- {
- return;
- }
-
- int Received = 0;
- char Buffer[256];
- while ((Received = recv(m_Socket, Buffer, sizeof(Buffer), 0)) > 0)
- {
- oData.append(Buffer, Received);
- }
-}
-
-
-
-
diff --git a/src/OSSupport/BlockingTCPLink.h b/src/OSSupport/BlockingTCPLink.h
deleted file mode 100644
index cb5f9e3f4..000000000
--- a/src/OSSupport/BlockingTCPLink.h
+++ /dev/null
@@ -1,28 +0,0 @@
-
-#pragma once
-
-#include "Socket.h"
-
-
-
-
-
-class cBlockingTCPLink // tolua_export
-{ // tolua_export
-public: // tolua_export
- cBlockingTCPLink(void); // tolua_export
- ~cBlockingTCPLink(); // tolua_export
-
- bool Connect( const char* a_Address, unsigned int a_Port ); // tolua_export
- int Send( char* a_Data, unsigned int a_Size, int a_Flags = 0 ); // tolua_export
- int SendMessage( const char* a_Message, int a_Flags = 0 ); // tolua_export
- void CloseSocket(); // tolua_export
- void ReceiveData(AString & oData); // tolua_export
-protected:
-
- cSocket m_Socket;
-}; // tolua_export
-
-
-
-
diff --git a/src/OSSupport/CMakeLists.txt b/src/OSSupport/CMakeLists.txt
index dee60b450..a42fcbed4 100644
--- a/src/OSSupport/CMakeLists.txt
+++ b/src/OSSupport/CMakeLists.txt
@@ -3,13 +3,42 @@ cmake_minimum_required (VERSION 2.6)
project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
-add_library(OSSupport ${SOURCE})
+SET (SRCS
+ CriticalSection.cpp
+ Errors.cpp
+ Event.cpp
+ File.cpp
+ GZipFile.cpp
+ IsThread.cpp
+ ListenThread.cpp
+ Semaphore.cpp
+ Sleep.cpp
+ Socket.cpp
+ SocketThreads.cpp
+ Thread.cpp
+ Timer.cpp)
-if(UNIX)
- target_link_libraries(OSSupport pthread)
+SET (HDRS
+ CriticalSection.h
+ Errors.h
+ Event.h
+ File.h
+ GZipFile.h
+ IsThread.h
+ ListenThread.h
+ Queue.h
+ Semaphore.h
+ Sleep.h
+ Socket.h
+ SocketThreads.h
+ Thread.h
+ Timer.h)
+
+if(NOT MSVC)
+ add_library(OSSupport ${SRCS} ${HDRS})
+
+ if(UNIX)
+ target_link_libraries(OSSupport pthread)
+ endif()
endif()
diff --git a/src/OSSupport/CriticalSection.cpp b/src/OSSupport/CriticalSection.cpp
index bda97e3a1..5dfc8b5f9 100644
--- a/src/OSSupport/CriticalSection.cpp
+++ b/src/OSSupport/CriticalSection.cpp
@@ -6,7 +6,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCriticalSection:
cCriticalSection::cCriticalSection()
@@ -105,10 +105,10 @@ bool cCriticalSection::IsLockedByCurrentThread(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCSLock
-cCSLock::cCSLock(cCriticalSection * a_CS)
+cCSLock::cCSLock(cCriticalSection * a_CS)
: m_CS(a_CS)
, m_IsLocked(false)
{
@@ -119,7 +119,7 @@ cCSLock::cCSLock(cCriticalSection * a_CS)
-cCSLock::cCSLock(cCriticalSection & a_CS)
+cCSLock::cCSLock(cCriticalSection & a_CS)
: m_CS(&a_CS)
, m_IsLocked(false)
{
@@ -165,7 +165,7 @@ void cCSLock::Unlock(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCSUnlock:
cCSUnlock::cCSUnlock(cCSLock & a_Lock) :
diff --git a/src/OSSupport/CriticalSection.h b/src/OSSupport/CriticalSection.h
index 73a71f5e1..c3c6e57f0 100644
--- a/src/OSSupport/CriticalSection.h
+++ b/src/OSSupport/CriticalSection.h
@@ -47,7 +47,7 @@ class cCSLock
cCriticalSection * m_CS;
// Unlike a cCriticalSection, this object should be used from a single thread, therefore access to m_IsLocked is not threadsafe
- // In Windows, it is an error to call cCriticalSection::Unlock() multiple times if the lock is not held,
+ // In Windows, it is an error to call cCriticalSection::Unlock() multiple times if the lock is not held,
// therefore we need to check this value whether we are locked or not.
bool m_IsLocked;
diff --git a/src/OSSupport/Errors.cpp b/src/OSSupport/Errors.cpp
index 6072b6ac6..9401ec257 100644
--- a/src/OSSupport/Errors.cpp
+++ b/src/OSSupport/Errors.cpp
@@ -3,7 +3,7 @@
#include "Errors.h"
-AString GetOSErrorString( int a_ErrNo )
+AString GetOSErrorString( int a_ErrNo)
{
char buffer[ 1024 ];
AString Out;
@@ -22,10 +22,10 @@ AString GetOSErrorString( int a_ErrNo )
// According to http://linux.die.net/man/3/strerror_r there are two versions of strerror_r():
- #if !defined(__APPLE__) && ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r()
+ #if !defined(__APPLE__) && ( _GNU_SOURCE) && !defined(ANDROID_NDK) // GNU version of strerror_r()
- char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) );
- if( res != NULL )
+ char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer));
+ if (res != NULL)
{
Printf(Out, "%d: %s", a_ErrNo, res);
return Out;
@@ -33,8 +33,8 @@ AString GetOSErrorString( int a_ErrNo )
#else // XSI version of strerror_r():
- int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) );
- if( res == 0 )
+ int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer));
+ if (res == 0)
{
Printf(Out, "%d: %s", a_ErrNo, buffer);
return Out;
diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp
index 649a0a3cf..74f823216 100644
--- a/src/OSSupport/Event.cpp
+++ b/src/OSSupport/Event.cpp
@@ -18,7 +18,7 @@ cEvent::cEvent(void)
m_Event = CreateEvent(NULL, FALSE, FALSE, NULL);
if (m_Event == NULL)
{
- LOGERROR("cEvent: cannot create event, GLE = %d. Aborting server.", GetLastError());
+ LOGERROR("cEvent: cannot create event, GLE = %u. Aborting server.", (unsigned)GetLastError());
abort();
}
#else // *nix
@@ -32,7 +32,7 @@ cEvent::cEvent(void)
AString EventName;
Printf(EventName, "cEvent%p", this);
- m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0 );
+ m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0);
if (m_Event == SEM_FAILED)
{
AString error = GetOSErrorString(errno);
@@ -71,6 +71,7 @@ cEvent::~cEvent()
{
sem_destroy(m_Event);
delete m_Event;
+ m_Event = NULL;
}
#endif
}
@@ -85,11 +86,11 @@ void cEvent::Wait(void)
DWORD res = WaitForSingleObject(m_Event, INFINITE);
if (res != WAIT_OBJECT_0)
{
- LOGWARN("cEvent: waiting for the event failed: %d, GLE = %d. Continuing, but server may be unstable.", res, GetLastError());
+ LOGWARN("cEvent: waiting for the event failed: %u, GLE = %u. Continuing, but server may be unstable.", (unsigned)res, (unsigned)GetLastError());
}
#else
int res = sem_wait(m_Event);
- if (res != 0 )
+ if (res != 0)
{
AString error = GetOSErrorString(errno);
LOGWARN("cEvent: waiting for the event failed: %i, err = %s. Continuing, but server may be unstable.", res, error.c_str());
@@ -106,7 +107,7 @@ void cEvent::Set(void)
#ifdef _WIN32
if (!SetEvent(m_Event))
{
- LOGWARN("cEvent: Could not set cEvent: GLE = %d", GetLastError());
+ LOGWARN("cEvent: Could not set cEvent: GLE = %u", (unsigned)GetLastError());
}
#else
int res = sem_post(m_Event);
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp
index f1b3bcf9e..ff6fb5898 100644
--- a/src/OSSupport/File.cpp
+++ b/src/OSSupport/File.cpp
@@ -7,6 +7,9 @@
#include "File.h"
#include <fstream>
+#ifdef _WIN32
+ #include <share.h> // for _SH_DENYWRITE
+#endif // _WIN32
@@ -75,10 +78,10 @@ bool cFile::Open(const AString & iFileName, eMode iMode)
}
#ifdef _WIN32
- fopen_s(&m_File, (FILE_IO_PREFIX + iFileName).c_str(), Mode);
+ m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), Mode, _SH_DENYWR);
#else
m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), Mode);
-#endif // _WIN32
+#endif // _WIN32
if ((m_File == NULL) && (iMode == fmReadWrite))
{
@@ -88,10 +91,10 @@ bool cFile::Open(const AString & iFileName, eMode iMode)
// Simply re-open for read-writing, erasing existing contents:
#ifdef _WIN32
- fopen_s(&m_File, (FILE_IO_PREFIX + iFileName).c_str(), "wb+");
+ m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+", _SH_DENYWR);
#else
m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+");
-#endif // _WIN32
+#endif // _WIN32
}
return (m_File != NULL);
@@ -143,7 +146,7 @@ bool cFile::IsEOF(void) const
-int cFile::Read (void * iBuffer, int iNumBytes)
+int cFile::Read (void * iBuffer, size_t iNumBytes)
{
ASSERT(IsOpen());
@@ -159,7 +162,7 @@ int cFile::Read (void * iBuffer, int iNumBytes)
-int cFile::Write(const void * iBuffer, int iNumBytes)
+int cFile::Write(const void * iBuffer, size_t iNumBytes)
{
ASSERT(IsOpen());
diff --git a/src/OSSupport/File.h b/src/OSSupport/File.h
index b394c5cb9..2a7ecf0ed 100644
--- a/src/OSSupport/File.h
+++ b/src/OSSupport/File.h
@@ -80,10 +80,10 @@ public:
bool IsEOF(void) const;
/** Reads up to iNumBytes bytes into iBuffer, returns the number of bytes actually read, or -1 on failure; asserts if not open */
- int Read (void * iBuffer, int iNumBytes);
+ int Read (void * iBuffer, size_t iNumBytes);
/** Writes up to iNumBytes bytes from iBuffer, returns the number of bytes actually written, or -1 on failure; asserts if not open */
- int Write(const void * iBuffer, int iNumBytes);
+ int Write(const void * iBuffer, size_t iNumBytes);
/** Seeks to iPosition bytes from file start, returns old position or -1 for failure; asserts if not open */
int Seek (int iPosition);
diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp
index 04fc818e4..1a436623a 100644
--- a/src/OSSupport/IsThread.cpp
+++ b/src/OSSupport/IsThread.cpp
@@ -60,6 +60,9 @@ static void SetThreadName(DWORD dwThreadID, const char * threadName)
cIsThread::cIsThread(const AString & iThreadName) :
m_ShouldTerminate(false),
m_ThreadName(iThreadName),
+ #ifdef _WIN32
+ m_ThreadID(0),
+ #endif
m_Handle(NULL_HANDLE)
{
}
@@ -83,11 +86,11 @@ bool cIsThread::Start(void)
ASSERT(m_Handle == NULL_HANDLE); // Has already started one thread?
#ifdef _WIN32
// Create the thread suspended, so that the mHandle variable is valid in the thread procedure
- DWORD ThreadID = 0;
- m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID);
+ m_ThreadID = 0;
+ m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &m_ThreadID);
if (m_Handle == NULL)
{
- LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", m_ThreadName.c_str(), GetLastError());
+ LOGERROR("ERROR: Could not create thread \"%s\", GLE = %u!", m_ThreadName.c_str(), (unsigned)GetLastError());
return false;
}
ResumeThread(m_Handle);
@@ -96,7 +99,7 @@ bool cIsThread::Start(void)
// Thread naming is available only in MSVC
if (!m_ThreadName.empty())
{
- SetThreadName(ThreadID, m_ThreadName.c_str());
+ SetThreadName(m_ThreadID, m_ThreadName.c_str());
}
#endif // _DEBUG and _MSC_VER
@@ -177,3 +180,15 @@ unsigned long cIsThread::GetCurrentID(void)
+bool cIsThread::IsCurrentThread(void) const
+{
+ #ifdef _WIN32
+ return (GetCurrentThreadId() == m_ThreadID);
+ #else
+ return (m_Handle == pthread_self());
+ #endif
+}
+
+
+
+
diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h
index 57651a490..c20fc3e7e 100644
--- a/src/OSSupport/IsThread.h
+++ b/src/OSSupport/IsThread.h
@@ -48,6 +48,9 @@ public:
/// Returns the OS-dependent thread ID for the caller's thread
static unsigned long GetCurrentID(void);
+ /** Returns true if the thread calling this function is the thread contained within this object. */
+ bool IsCurrentThread(void) const;
+
protected:
AString m_ThreadName;
@@ -60,6 +63,7 @@ protected:
#ifdef _WIN32
+ DWORD m_ThreadID;
HANDLE m_Handle;
static DWORD __stdcall thrExecute(LPVOID a_Param)
diff --git a/src/OSSupport/ListenThread.cpp b/src/OSSupport/ListenThread.cpp
index ba3198764..02e98acfc 100644
--- a/src/OSSupport/ListenThread.cpp
+++ b/src/OSSupport/ListenThread.cpp
@@ -214,7 +214,7 @@ void cListenThread::Execute(void)
timeval tv; // On Linux select() doesn't seem to wake up when socket is closed, so let's kinda busy-wait:
tv.tv_sec = 1;
tv.tv_usec = 0;
- if (select(Highest + 1, &fdRead, NULL, NULL, &tv) == -1)
+ if (select((int)Highest + 1, &fdRead, NULL, NULL, &tv) == -1)
{
LOG("select(R) call failed in cListenThread: \"%s\"", cSocket::GetLastErrorString().c_str());
continue;
diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h
index beb6a63f1..bf4d7f004 100644
--- a/src/OSSupport/Queue.h
+++ b/src/OSSupport/Queue.h
@@ -21,19 +21,19 @@ cQueueFuncs and is used as the default behavior.
/// This empty struct allows for the callback functions to be inlined
template<class T>
-struct cQueueFuncs
+struct cQueueFuncs
{
public:
/// Called when an Item is deleted from the queue without being returned
- static void Delete(T) {};
+ static void Delete(T) {}
/// Called when an Item is inserted with EnqueueItemIfNotPresent and there is another equal value already inserted
static void Combine(T & a_existing, const T & a_new)
{
UNUSED(a_existing);
UNUSED(a_new);
- };
+ }
};
@@ -88,7 +88,7 @@ public:
cCSLock Lock(m_CS);
if (m_Contents.size() == 0)
{
- return false;
+ return false;
}
item = m_Contents.front();
m_Contents.pop_front();
diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp
index 468de6858..c1fc7d9c7 100644
--- a/src/OSSupport/Semaphore.cpp
+++ b/src/OSSupport/Semaphore.cpp
@@ -5,9 +5,9 @@
-cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */ )
+cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */)
#ifndef _WIN32
- : m_bNamed( false )
+ : m_bNamed( false)
#endif
{
#ifndef _WIN32
@@ -20,15 +20,15 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /*
m_bNamed = true;
AString Name;
- Printf(Name, "cSemaphore%p", this );
+ Printf(Name, "cSemaphore%p", this);
m_Handle = sem_open(Name.c_str(), O_CREAT, 777, a_InitialCount);
- if( m_Handle == SEM_FAILED )
+ if (m_Handle == SEM_FAILED)
{
- LOG("ERROR: Could not create Semaphore. (%i)", errno );
+ LOG("ERROR: Could not create Semaphore. (%i)", errno);
}
else
{
- if( sem_unlink(Name.c_str()) != 0 )
+ if (sem_unlink(Name.c_str()) != 0)
{
LOG("ERROR: Could not unlink cSemaphore. (%i)", errno);
}
@@ -36,56 +36,72 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /*
}
#else
m_Handle = CreateSemaphore(
- NULL, // security attribute
- a_InitialCount, // initial count
- a_MaxCount, // maximum count
- 0 // name (optional)
+ NULL, // security attribute
+ a_InitialCount, // initial count
+ a_MaxCount, // maximum count
+ 0 // name (optional)
);
#endif
}
+
+
+
+
cSemaphore::~cSemaphore()
{
#ifdef _WIN32
- CloseHandle( m_Handle );
+ CloseHandle( m_Handle);
#else
- if( m_bNamed )
- {
- if( sem_close( (sem_t*)m_Handle ) != 0 )
- {
- LOG("ERROR: Could not close cSemaphore. (%i)", errno);
- }
- }
- else
- {
- sem_destroy( (sem_t*)m_Handle );
- delete (sem_t*)m_Handle;
- }
+ if (m_bNamed)
+ {
+ if (sem_close( (sem_t*)m_Handle) != 0)
+ {
+ LOG("ERROR: Could not close cSemaphore. (%i)", errno);
+ }
+ }
+ else
+ {
+ sem_destroy( (sem_t*)m_Handle);
+ delete (sem_t*)m_Handle;
+ }
m_Handle = 0;
#endif
}
+
+
+
+
void cSemaphore::Wait()
{
#ifndef _WIN32
- if( sem_wait( (sem_t*)m_Handle ) != 0)
- {
- LOG("ERROR: Could not wait for cSemaphore. (%i)", errno);
- }
+ if (sem_wait( (sem_t*)m_Handle) != 0)
+ {
+ LOG("ERROR: Could not wait for cSemaphore. (%i)", errno);
+ }
#else
WaitForSingleObject( m_Handle, INFINITE);
#endif
}
+
+
+
+
void cSemaphore::Signal()
{
#ifndef _WIN32
- if( sem_post( (sem_t*)m_Handle ) != 0 )
+ if (sem_post( (sem_t*)m_Handle) != 0)
{
- LOG("ERROR: Could not signal cSemaphore. (%i)", errno);
+ LOG("ERROR: Could not signal cSemaphore. (%i)", errno);
}
#else
- ReleaseSemaphore( m_Handle, 1, NULL );
+ ReleaseSemaphore( m_Handle, 1, NULL);
#endif
}
+
+
+
+
diff --git a/src/OSSupport/Semaphore.h b/src/OSSupport/Semaphore.h
index fbe8907f1..adc531ed8 100644
--- a/src/OSSupport/Semaphore.h
+++ b/src/OSSupport/Semaphore.h
@@ -3,13 +3,13 @@
class cSemaphore
{
public:
- cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount = 0 );
+ cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount = 0);
~cSemaphore();
void Wait();
void Signal();
private:
- void* m_Handle; // HANDLE pointer
+ void* m_Handle; // HANDLE pointer
#ifndef _WIN32
bool m_bNamed;
diff --git a/src/OSSupport/Sleep.cpp b/src/OSSupport/Sleep.cpp
index 70fb06b40..297d668d7 100644
--- a/src/OSSupport/Sleep.cpp
+++ b/src/OSSupport/Sleep.cpp
@@ -9,11 +9,11 @@
-void cSleep::MilliSleep( unsigned int a_MilliSeconds )
+void cSleep::MilliSleep( unsigned int a_MilliSeconds)
{
#ifdef _WIN32
- Sleep(a_MilliSeconds); // Don't tick too much
+ Sleep(a_MilliSeconds); // Don't tick too much
#else
- usleep(a_MilliSeconds*1000);
+ usleep(a_MilliSeconds*1000);
#endif
}
diff --git a/src/OSSupport/Sleep.h b/src/OSSupport/Sleep.h
index 0ec0adf9d..57d29682c 100644
--- a/src/OSSupport/Sleep.h
+++ b/src/OSSupport/Sleep.h
@@ -3,5 +3,5 @@
class cSleep
{
public:
- static void MilliSleep( unsigned int a_MilliSeconds );
+ static void MilliSleep( unsigned int a_MilliSeconds);
};
diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp
index c29e495c3..c07d31c8b 100644
--- a/src/OSSupport/Socket.cpp
+++ b/src/OSSupport/Socket.cpp
@@ -25,15 +25,6 @@ cSocket::cSocket(xSocket a_Socket)
-cSocket::~cSocket()
-{
- // Do NOT close the socket; this class is an API wrapper, not a RAII!
-}
-
-
-
-
-
cSocket::operator cSocket::xSocket() const
{
return m_Socket;
@@ -138,7 +129,7 @@ int cSocket::WSAStartup(void)
#ifdef _WIN32
WSADATA wsaData;
memset(&wsaData, 0, sizeof(wsaData));
- return ::WSAStartup(MAKEWORD(2, 2),&wsaData);
+ return ::WSAStartup(MAKEWORD(2, 2), &wsaData);
#else
return 0;
#endif
@@ -244,7 +235,7 @@ cSocket cSocket::AcceptIPv6(void)
// Windows XP doesn't have inet_ntop, so we need to improvise. And MSVC has different headers than GCC
#ifdef _MSC_VER
// MSVC version
- Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x",
+ Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x",
from.sin6_addr.u.Word[0],
from.sin6_addr.u.Word[1],
from.sin6_addr.u.Word[2],
@@ -256,7 +247,7 @@ cSocket cSocket::AcceptIPv6(void)
);
#else // _MSC_VER
// MinGW
- Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x",
+ Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x",
from.sin6_addr.s6_addr16[0],
from.sin6_addr.s6_addr16[1],
from.sin6_addr.s6_addr16[2],
@@ -295,7 +286,7 @@ bool cSocket::ConnectToLocalhostIPv4(unsigned short a_Port)
bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Port)
{
- // First try IP Address string to hostent conversion, because it's faster
+ // First try IP Address string to hostent conversion, because it's faster and local:
unsigned long addr = inet_addr(a_HostNameOrAddr.c_str());
if (addr == INADDR_NONE)
{
@@ -307,10 +298,16 @@ bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Por
CloseSocket();
return false;
}
- // Should be optimised to a single word copy
memcpy(&addr, hp->h_addr, hp->h_length);
}
+ // If the socket is not created yet, create one:
+ if (!IsValid())
+ {
+ m_Socket = socket((int)IPv4, SOCK_STREAM, 0);
+ }
+
+ // Connect the socket:
sockaddr_in server;
server.sin_addr.s_addr = addr;
server.sin_family = AF_INET;
@@ -322,18 +319,18 @@ bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Por
-int cSocket::Receive(char * a_Buffer, unsigned int a_Length, unsigned int a_Flags)
+int cSocket::Receive(char * a_Buffer, size_t a_Length, unsigned int a_Flags)
{
- return recv(m_Socket, a_Buffer, a_Length, a_Flags);
+ return recv(m_Socket, a_Buffer, (int)a_Length, a_Flags);
}
-int cSocket::Send(const char * a_Buffer, unsigned int a_Length)
+int cSocket::Send(const char * a_Buffer, size_t a_Length)
{
- return send(m_Socket, a_Buffer, a_Length, MSG_NOSIGNAL);
+ return send(m_Socket, a_Buffer, (int)a_Length, MSG_NOSIGNAL);
}
diff --git a/src/OSSupport/Socket.h b/src/OSSupport/Socket.h
index bdc2babf5..e4ec895cb 100644
--- a/src/OSSupport/Socket.h
+++ b/src/OSSupport/Socket.h
@@ -41,7 +41,6 @@ public:
cSocket(void) : m_Socket(INVALID_SOCKET) {}
cSocket(xSocket a_Socket);
- ~cSocket();
bool IsValid(void) const { return IsValidSocket(m_Socket); }
void CloseSocket(void);
@@ -110,8 +109,8 @@ public:
/// Connects to the specified host or string IP address and port, using IPv4. Returns true if successful.
bool ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Port);
- int Receive(char * a_Buffer, unsigned int a_Length, unsigned int a_Flags);
- int Send (const char * a_Buffer, unsigned int a_Length);
+ int Receive(char * a_Buffer, size_t a_Length, unsigned int a_Flags);
+ int Send (const char * a_Buffer, size_t a_Length);
unsigned short GetPort(void) const; // Returns 0 on failure
diff --git a/src/OSSupport/SocketThreads.cpp b/src/OSSupport/SocketThreads.cpp
index 0bc1d6b55..f436318a5 100644
--- a/src/OSSupport/SocketThreads.cpp
+++ b/src/OSSupport/SocketThreads.cpp
@@ -13,7 +13,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSocketThreads:
cSocketThreads::cSocketThreads(void)
@@ -61,6 +61,7 @@ bool cSocketThreads::AddClient(const cSocket & a_Socket, cCallback * a_Client)
// There was an error launching the thread (but it was already logged along with the reason)
LOGERROR("A new cSocketThread failed to start");
delete Thread;
+ Thread = NULL;
return false;
}
Thread->AddClient(a_Socket, a_Client);
@@ -406,7 +407,7 @@ void cSocketThreads::cSocketThread::Execute(void)
timeval Timeout;
Timeout.tv_sec = 5;
Timeout.tv_usec = 0;
- if (select(Highest + 1, &fdRead, &fdWrite, NULL, &Timeout) == -1)
+ if (select((int)Highest + 1, &fdRead, &fdWrite, NULL, &Timeout) == -1)
{
LOG("select() call failed in cSocketThread: \"%s\"", cSocket::GetLastErrorString().c_str());
continue;
diff --git a/src/OSSupport/SocketThreads.h b/src/OSSupport/SocketThreads.h
index 679e374e1..944f5f3bc 100644
--- a/src/OSSupport/SocketThreads.h
+++ b/src/OSSupport/SocketThreads.h
@@ -63,8 +63,10 @@ public:
// Force a virtual destructor in all subclasses:
virtual ~cCallback() {}
- /** Called when data is received from the remote party */
- virtual void DataReceived(const char * a_Data, size_t a_Size) = 0;
+ /** Called when data is received from the remote party.
+ SocketThreads does not care about the return value, others can use it for their specific purpose -
+ for example HTTPServer uses it to signal if the connection was terminated as a result of the data received. */
+ virtual bool DataReceived(const char * a_Data, size_t a_Size) = 0;
/** Called when data can be sent to remote party
The function is supposed to *set* outgoing data to a_Data (overwrite) */
diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp
index 7a10ef8d2..faaccce96 100644
--- a/src/OSSupport/Thread.cpp
+++ b/src/OSSupport/Thread.cpp
@@ -47,13 +47,13 @@ static void SetThreadName(DWORD dwThreadID, const char * threadName)
-cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName /* = 0 */ )
- : m_ThreadFunction( a_ThreadFunction )
- , m_Param( a_Param )
- , m_Event( new cEvent() )
- , m_StopEvent( 0 )
+cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName /* = 0 */)
+ : m_ThreadFunction( a_ThreadFunction)
+ , m_Param( a_Param)
+ , m_Event( new cEvent())
+ , m_StopEvent( 0)
{
- if( a_ThreadName )
+ if (a_ThreadName)
{
m_ThreadName.assign(a_ThreadName);
}
@@ -66,11 +66,13 @@ cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_Thre
cThread::~cThread()
{
delete m_Event;
+ m_Event = NULL;
- if( m_StopEvent )
+ if (m_StopEvent)
{
m_StopEvent->Wait();
delete m_StopEvent;
+ m_StopEvent = NULL;
}
}
@@ -78,24 +80,24 @@ cThread::~cThread()
-void cThread::Start( bool a_bWaitOnDelete /* = true */ )
+void cThread::Start( bool a_bWaitOnDelete /* = true */)
{
- if( a_bWaitOnDelete )
+ if (a_bWaitOnDelete)
m_StopEvent = new cEvent();
#ifndef _WIN32
pthread_t SndThread;
- if( pthread_create( &SndThread, NULL, MyThread, this) )
+ if (pthread_create( &SndThread, NULL, MyThread, this))
LOGERROR("ERROR: Could not create thread!");
#else
DWORD ThreadID = 0;
- HANDLE hThread = CreateThread( 0 // security
- ,0 // stack size
- , (LPTHREAD_START_ROUTINE) MyThread // function name
- ,this // parameters
- ,0 // flags
- ,&ThreadID ); // thread id
- CloseHandle( hThread );
+ HANDLE hThread = CreateThread(NULL // security
+ , 0 // stack size
+ , (LPTHREAD_START_ROUTINE) MyThread // function name
+ , this // parameters
+ , 0 // flags
+ , &ThreadID); // thread id
+ CloseHandle( hThread);
#ifdef _MSC_VER
if (!m_ThreadName.empty())
@@ -114,9 +116,9 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ )
#ifdef _WIN32
-unsigned long cThread::MyThread(void* a_Param )
+unsigned long cThread::MyThread(void* a_Param)
#else
-void *cThread::MyThread( void *a_Param )
+void *cThread::MyThread( void *a_Param)
#endif
{
cThread* self = (cThread*)a_Param;
@@ -128,8 +130,8 @@ void *cThread::MyThread( void *a_Param )
// Set event to let other thread know this thread has been created and it's safe to delete the cThread object
self->m_Event->Set();
- ThreadFunction( ThreadParam );
+ ThreadFunction( ThreadParam);
- if( StopEvent ) StopEvent->Set();
+ if (StopEvent) StopEvent->Set();
return 0;
}
diff --git a/src/OSSupport/Thread.h b/src/OSSupport/Thread.h
index 4153b2427..7ee352c82 100644
--- a/src/OSSupport/Thread.h
+++ b/src/OSSupport/Thread.h
@@ -4,18 +4,18 @@ class cThread
{
public:
typedef void (ThreadFunc)(void*);
- cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName = 0 );
+ cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName = 0);
~cThread();
- void Start( bool a_bWaitOnDelete = true );
+ void Start( bool a_bWaitOnDelete = true);
void WaitForThread();
private:
ThreadFunc* m_ThreadFunction;
#ifdef _WIN32
- static unsigned long MyThread(void* a_Param );
+ static unsigned long MyThread(void* a_Param);
#else
- static void *MyThread( void *lpParam );
+ static void *MyThread( void *lpParam);
#endif
void* m_Param;
diff --git a/src/Piston.cpp b/src/Piston.cpp
deleted file mode 100644
index b21d576f3..000000000
--- a/src/Piston.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Piston.h"
-#include "ChunkDef.h"
-#include "Entities/Pickup.h"
-#include "Item.h"
-#include "Root.h"
-#include "ClientHandle.h"
-#include "World.h"
-#include "Server.h"
-#include "Blocks/BlockHandler.h"
-#include "BlockInServerPluginInterface.h"
-
-
-
-
-
-/// Number of ticks that the piston extending / retracting waits before setting the block
-const int PISTON_TICK_DELAY = 1;
-
-
-
-
-
-cPiston::cPiston(cWorld * a_World)
- : m_World(a_World)
-{
-}
-
-
-
-
-
-int cPiston::FirstPassthroughBlock(int pistonX, int pistonY, int pistonZ, NIBBLETYPE pistonmeta)
-{
- // Examine each of the 12 blocks ahead of the piston:
- for (int ret = 0; ret < 12; ret++)
- {
- BLOCKTYPE currBlock;
- NIBBLETYPE currMeta;
- AddDir(pistonX, pistonY, pistonZ, pistonmeta, 1);
- m_World->GetBlockTypeMeta(pistonX, pistonY, pistonZ, currBlock, currMeta);
- if (CanBreakPush(currBlock, currMeta))
- {
- // This block breaks when pushed, extend up to here
- return ret;
- }
- if (!CanPush(currBlock, currMeta))
- {
- // This block cannot be pushed at all, the piston can't extend
- return -1;
- }
- }
- // There is no space for the blocks to move, piston can't extend
- return -1;
-}
-
-
-
-
-
-void cPiston::ExtendPiston(int pistx, int pisty, int pistz)
-{
- BLOCKTYPE pistonBlock;
- NIBBLETYPE pistonMeta;
- m_World->GetBlockTypeMeta(pistx, pisty, pistz, pistonBlock, pistonMeta);
-
- if (IsExtended(pistonMeta))
- {
- // Already extended, bail out
- return;
- }
-
- int dist = FirstPassthroughBlock(pistx, pisty, pistz, pistonMeta);
- if (dist < 0)
- {
- // FirstPassthroughBlock says piston can't push anything, bail out
- return;
- }
-
- m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, pistonBlock);
- m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);
-
- // Drop the breakable block in the line, if appropriate:
- AddDir(pistx, pisty, pistz, pistonMeta, dist + 1); // "pist" now at the breakable / empty block
- BLOCKTYPE currBlock;
- NIBBLETYPE currMeta;
- m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currMeta);
- if (currBlock != E_BLOCK_AIR)
- {
- cBlockHandler * Handler = BlockHandler(currBlock);
- if (Handler->DoesDropOnUnsuitable())
- {
- cChunkInterface ChunkInterface(m_World->GetChunkMap());
- cBlockInServerPluginInterface PluginInterface(*m_World);
- Handler->DropBlock(ChunkInterface, *m_World, PluginInterface, NULL, pistx, pisty, pistz);
- }
- }
-
- // Push blocks, from the furthest to the nearest:
- int oldx = pistx, oldy = pisty, oldz = pistz;
- NIBBLETYPE currBlockMeta;
- for (int i = dist + 1; i > 1; i--)
- {
- AddDir(pistx, pisty, pistz, pistonMeta, -1);
- m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta);
- m_World->QueueSetBlock( oldx, oldy, oldz, currBlock, currBlockMeta, PISTON_TICK_DELAY);
- oldx = pistx;
- oldy = pisty;
- oldz = pistz;
- }
-
- int extx = pistx;
- int exty = pisty;
- int extz = pistz;
- AddDir(pistx, pisty, pistz, pistonMeta, -1);
- // "pist" now at piston body, "ext" at future extension
-
- m_World->SetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8);
- m_World->QueueSetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), PISTON_TICK_DELAY);
-}
-
-
-
-
-
-void cPiston::RetractPiston(int pistx, int pisty, int pistz)
-{
- BLOCKTYPE pistonBlock;
- NIBBLETYPE pistonMeta;
- m_World->GetBlockTypeMeta(pistx, pisty, pistz, pistonBlock, pistonMeta);
-
- if (!IsExtended(pistonMeta))
- {
- // Already retracted, bail out
- return;
- }
-
- // Check the extension:
- AddDir(pistx, pisty, pistz, pistonMeta, 1);
- if (m_World->GetBlock(pistx, pisty, pistz) != E_BLOCK_PISTON_EXTENSION)
- {
- LOGD("%s: Piston without an extension - still extending, or just in an invalid state?", __FUNCTION__);
- return;
- }
-
- AddDir(pistx, pisty, pistz, pistonMeta, -1);
- m_World->SetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8));
- m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), pistonBlock);
- m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);
- AddDir(pistx, pisty, pistz, pistonMeta, 1);
-
- // Retract the extension, pull block if appropriate
- if (IsSticky(pistonBlock))
- {
- int tempx = pistx, tempy = pisty, tempz = pistz;
- AddDir(tempx, tempy, tempz, pistonMeta, 1);
- BLOCKTYPE tempBlock;
- NIBBLETYPE tempMeta;
- m_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta);
- if (CanPull(tempBlock, tempMeta))
- {
- // Pull the block
- m_World->QueueSetBlock(pistx, pisty, pistz, tempBlock, tempMeta, PISTON_TICK_DELAY);
- m_World->QueueSetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
- }
- else
- {
- // Retract without pulling
- m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
- }
- }
- else
- {
- m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
- }
-}
-
-
-
-
-
-bool cPiston::IsExtended(NIBBLETYPE a_PistonMeta)
-{
- return ((a_PistonMeta & 0x8) != 0x0);
-}
-
-
-
-
-
-bool cPiston::IsSticky(BLOCKTYPE a_BlockType)
-{
- return (a_BlockType == E_BLOCK_STICKY_PISTON);
-}
-
-
-
-
-
-bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- switch (a_BlockType)
- {
- case E_BLOCK_ANVIL:
- case E_BLOCK_BED:
- case E_BLOCK_BEDROCK:
- case E_BLOCK_BREWING_STAND:
- case E_BLOCK_CHEST:
- case E_BLOCK_COMMAND_BLOCK:
- case E_BLOCK_DISPENSER:
- case E_BLOCK_DROPPER:
- case E_BLOCK_ENCHANTMENT_TABLE:
- case E_BLOCK_END_PORTAL:
- case E_BLOCK_END_PORTAL_FRAME:
- case E_BLOCK_FURNACE:
- case E_BLOCK_LIT_FURNACE:
- case E_BLOCK_HOPPER:
- case E_BLOCK_JUKEBOX:
- case E_BLOCK_MOB_SPAWNER:
- case E_BLOCK_NETHER_PORTAL:
- case E_BLOCK_NOTE_BLOCK:
- case E_BLOCK_OBSIDIAN:
- case E_BLOCK_PISTON_EXTENSION:
- {
- return false;
- }
- case E_BLOCK_STICKY_PISTON:
- case E_BLOCK_PISTON:
- {
- // A piston can only be pushed if retracted:
- return !IsExtended(a_BlockMeta);
- }
- }
- return true;
-}
-
-
-
-
-
-bool cPiston::CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- UNUSED(a_BlockMeta);
- return cBlockInfo::IsPistonBreakable(a_BlockType);
-}
-
-
-
-
-
-bool cPiston::CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- switch (a_BlockType)
- {
- case E_BLOCK_LAVA:
- case E_BLOCK_STATIONARY_LAVA:
- case E_BLOCK_STATIONARY_WATER:
- case E_BLOCK_WATER:
- {
- return false;
- }
- }
-
- if (CanBreakPush(a_BlockType, a_BlockMeta))
- {
- return false; // CanBreakPush returns true, but we need false to prevent pulling
- }
-
- return CanPush(a_BlockType, a_BlockMeta);
-}
-
-
-
-
-
-void cPiston::AddDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_PistonMeta, int a_Amount)
-{
- switch (a_PistonMeta & 0x07)
- {
- case 0: a_BlockY -= a_Amount; break;
- case 1: a_BlockY += a_Amount; break;
- case 2: a_BlockZ -= a_Amount; break;
- case 3: a_BlockZ += a_Amount; break;
- case 4: a_BlockX -= a_Amount; break;
- case 5: a_BlockX += a_Amount; break;
- default:
- {
- LOGWARNING("%s: invalid direction %d, ignoring", __FUNCTION__, a_PistonMeta & 0x07);
- break;
- }
- }
-}
-
-
-
-
diff --git a/src/Piston.h b/src/Piston.h
deleted file mode 100644
index 9bbc8c6b9..000000000
--- a/src/Piston.h
+++ /dev/null
@@ -1,110 +0,0 @@
-
-#pragma once
-
-
-#include "Defines.h"
-
-
-// fwd: World.h
-class cWorld;
-
-
-
-
-
-class cPiston
-{
-public:
-
- cPiston(cWorld * a_World);
-
- static NIBBLETYPE RotationPitchToMetaData(double a_Rotation, double a_Pitch)
- {
- if (a_Pitch >= 50)
- {
- return 0x1;
- }
- else if (a_Pitch <= -50)
- {
- return 0x0;
- }
- else
- {
- a_Rotation += 90 + 45; // So its not aligned with axis
-
- if (a_Rotation > 360)
- {
- a_Rotation -= 360;
- }
- if ((a_Rotation >= 0) && (a_Rotation < 90))
- {
- return 0x4;
- }
- else if ((a_Rotation >= 180) && (a_Rotation < 270))
- {
- return 0x5;
- }
- else if ((a_Rotation >= 90) && (a_Rotation < 180))
- {
- return 0x2;
- }
- else
- {
- return 0x3;
- }
- }
- }
-
- static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData)
- {
- switch (a_MetaData)
- {
- //case -1: return BLOCK_FACE_NONE; //can never happen as metadata is unsigned
- case 0x0: return BLOCK_FACE_YM;
- case 0x1: return BLOCK_FACE_YP;
- case 0x2: return BLOCK_FACE_ZM;
- case 0x3: return BLOCK_FACE_ZP;
- case 0x4: return BLOCK_FACE_XM;
- case 0x5: return BLOCK_FACE_XP;
- default:
- {
- ASSERT(!"Invalid Metadata");
- return BLOCK_FACE_NONE;
- }
- }
- }
-
- void ExtendPiston( int, int, int );
- void RetractPiston( int, int, int );
-
- /// Returns true if the piston (specified by blocktype) is a sticky piston
- static bool IsSticky(BLOCKTYPE a_BlockType);
-
- /// Returns true if the piston (with the specified meta) is extended
- static bool IsExtended(NIBBLETYPE a_PistonMeta);
-
- /// Returns true if the specified block can be pushed by a piston (and left intact)
- static bool CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
-
- /// Returns true if the specified block can be pushed by a piston and broken / replaced
- static bool CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
-
- /// Returns true if the specified block can be pulled by a sticky piston
- static bool CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
-
- /// Updates the coords by the specified amount in the direction a piston of the specified meta is facing
- static void AddDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_PistonMeta, int a_Amount);
-
-
- cWorld * m_World;
-
-private:
- void ChainMove( int, int, int, char, unsigned short * );
-
- /// Returns how many blocks the piston has to push (where the first free space is); <0 when unpushable
- int FirstPassthroughBlock(int a_PistonX, int a_PistonY, int a_PistonZ, NIBBLETYPE a_PistonMeta);
-} ;
-
-
-
-
diff --git a/src/PolarSSL++/AesCfb128Decryptor.cpp b/src/PolarSSL++/AesCfb128Decryptor.cpp
new file mode 100644
index 000000000..af0d5106e
--- /dev/null
+++ b/src/PolarSSL++/AesCfb128Decryptor.cpp
@@ -0,0 +1,67 @@
+
+// AesCfb128Decryptor.cpp
+
+// Implements the cAesCfb128Decryptor class decrypting data using AES CFB-128
+
+#include "Globals.h"
+#include "AesCfb128Decryptor.h"
+
+
+
+
+
+cAesCfb128Decryptor::cAesCfb128Decryptor(void) :
+ m_IVOffset(0),
+ m_IsValid(false)
+{
+}
+
+
+
+
+
+cAesCfb128Decryptor::~cAesCfb128Decryptor()
+{
+ // Clear the leftover in-memory data, so that they can't be accessed by a backdoor
+ memset(&m_Aes, 0, sizeof(m_Aes));
+}
+
+
+
+
+
+void cAesCfb128Decryptor::Init(const Byte a_Key[16], const Byte a_IV[16])
+{
+ ASSERT(!IsValid()); // Cannot Init twice
+
+ memcpy(m_IV, a_IV, 16);
+ aes_setkey_enc(&m_Aes, a_Key, 128);
+ m_IsValid = true;
+}
+
+
+
+
+
+void cAesCfb128Decryptor::ProcessData(Byte * a_DecryptedOut, const Byte * a_EncryptedIn, size_t a_Length)
+{
+ ASSERT(IsValid()); // Must Init() first
+
+ // PolarSSL doesn't support AES-CFB8, need to implement it manually:
+ for (size_t i = 0; i < a_Length; i++)
+ {
+ Byte Buffer[sizeof(m_IV)];
+ aes_crypt_ecb(&m_Aes, AES_ENCRYPT, m_IV, Buffer);
+ for (size_t idx = 0; idx < sizeof(m_IV) - 1; idx++)
+ {
+ m_IV[idx] = m_IV[idx + 1];
+ }
+ m_IV[sizeof(m_IV) - 1] = a_EncryptedIn[i];
+ a_DecryptedOut[i] = a_EncryptedIn[i] ^ Buffer[0];
+ }
+}
+
+
+
+
+
diff --git a/src/PolarSSL++/AesCfb128Decryptor.h b/src/PolarSSL++/AesCfb128Decryptor.h
new file mode 100644
index 000000000..84c790b83
--- /dev/null
+++ b/src/PolarSSL++/AesCfb128Decryptor.h
@@ -0,0 +1,51 @@
+
+// AesCfb128Decryptor.h
+
+// Declares the cAesCfb128Decryptor class decrypting data using AES CFB-128
+
+
+
+
+
+#pragma once
+
+#include "polarssl/aes.h"
+
+
+
+
+
+/** Decrypts data using the AES / CFB 128 algorithm */
+class cAesCfb128Decryptor
+{
+public:
+
+ cAesCfb128Decryptor(void);
+ ~cAesCfb128Decryptor();
+
+ /** Initializes the decryptor with the specified Key / IV */
+ void Init(const Byte a_Key[16], const Byte a_IV[16]);
+
+ /** Decrypts a_Length bytes of the encrypted data; produces a_Length output bytes */
+ void ProcessData(Byte * a_DecryptedOut, const Byte * a_EncryptedIn, size_t a_Length);
+
+ /** Returns true if the object has been initialized with the Key / IV */
+ bool IsValid(void) const { return m_IsValid; }
+
+protected:
+ aes_context m_Aes;
+
+ /** The InitialVector, used by the CFB mode decryption */
+ Byte m_IV[16];
+
+ /** Current offset in the m_IV, used by the CFB mode decryption */
+ size_t m_IVOffset;
+
+ /** Indicates whether the object has been initialized with the Key / IV */
+ bool m_IsValid;
+} ;
+
+
+
+
+
diff --git a/src/PolarSSL++/AesCfb128Encryptor.cpp b/src/PolarSSL++/AesCfb128Encryptor.cpp
new file mode 100644
index 000000000..a641ad48e
--- /dev/null
+++ b/src/PolarSSL++/AesCfb128Encryptor.cpp
@@ -0,0 +1,68 @@
+
+// AesCfb128Encryptor.cpp
+
+// Implements the cAesCfb128Encryptor class encrypting data using AES CFB-128
+
+#include "Globals.h"
+#include "AesCfb128Encryptor.h"
+
+
+
+
+
+cAesCfb128Encryptor::cAesCfb128Encryptor(void) :
+ m_IVOffset(0),
+ m_IsValid(false)
+{
+}
+
+
+
+
+
+cAesCfb128Encryptor::~cAesCfb128Encryptor()
+{
+ // Clear the leftover in-memory data, so that they can't be accessed by a backdoor
+ memset(&m_Aes, 0, sizeof(m_Aes));
+}
+
+
+
+
+
+void cAesCfb128Encryptor::Init(const Byte a_Key[16], const Byte a_IV[16])
+{
+ ASSERT(!IsValid()); // Cannot Init twice
+ ASSERT(m_IVOffset == 0);
+
+ memcpy(m_IV, a_IV, 16);
+ aes_setkey_enc(&m_Aes, a_Key, 128);
+ m_IsValid = true;
+}
+
+
+
+
+
+void cAesCfb128Encryptor::ProcessData(Byte * a_EncryptedOut, const Byte * a_PlainIn, size_t a_Length)
+{
+ ASSERT(IsValid()); // Must Init() first
+
+ // PolarSSL doesn't do AES-CFB8, so we need to implement it ourselves:
+ for (size_t i = 0; i < a_Length; i++)
+ {
+ Byte Buffer[sizeof(m_IV)];
+ aes_crypt_ecb(&m_Aes, AES_ENCRYPT, m_IV, Buffer);
+ for (size_t idx = 0; idx < sizeof(m_IV) - 1; idx++)
+ {
+ m_IV[idx] = m_IV[idx + 1];
+ }
+ a_EncryptedOut[i] = a_PlainIn[i] ^ Buffer[0];
+ m_IV[sizeof(m_IV) - 1] = a_EncryptedOut[i];
+ }
+}
+
+
+
+
+
diff --git a/src/PolarSSL++/AesCfb128Encryptor.h b/src/PolarSSL++/AesCfb128Encryptor.h
new file mode 100644
index 000000000..9dbb5d2c3
--- /dev/null
+++ b/src/PolarSSL++/AesCfb128Encryptor.h
@@ -0,0 +1,50 @@
+
+// AesCfb128Encryptor.h
+
+// Declares the cAesCfb128Encryptor class encrypting data using AES CFB-128
+
+
+
+
+
+#pragma once
+
+#include "polarssl/aes.h"
+
+
+
+
+
+/** Encrypts data using the AES / CFB (128) algorithm */
+class cAesCfb128Encryptor
+{
+public:
+ cAesCfb128Encryptor(void);
+ ~cAesCfb128Encryptor();
+
+ /** Initializes the decryptor with the specified Key / IV */
+ void Init(const Byte a_Key[16], const Byte a_IV[16]);
+
+ /** Encrypts a_Length bytes of the plain data; produces a_Length output bytes */
+ void ProcessData(Byte * a_EncryptedOut, const Byte * a_PlainIn, size_t a_Length);
+
+ /** Returns true if the object has been initialized with the Key / IV */
+ bool IsValid(void) const { return m_IsValid; }
+
+protected:
+ aes_context m_Aes;
+
+ /** The InitialVector, used by the CFB mode encryption */
+ Byte m_IV[16];
+
+ /** Current offset in the m_IV, used by the CFB mode encryption */
+ size_t m_IVOffset;
+
+ /** Indicates whether the object has been initialized with the Key / IV */
+ bool m_IsValid;
+} ;
+
+
+
+
+
diff --git a/src/PolarSSL++/BlockingSslClientSocket.cpp b/src/PolarSSL++/BlockingSslClientSocket.cpp
new file mode 100644
index 000000000..699bc57ee
--- /dev/null
+++ b/src/PolarSSL++/BlockingSslClientSocket.cpp
@@ -0,0 +1,195 @@
+
+// BlockingSslClientSocket.cpp
+
+// Implements the cBlockingSslClientSocket class representing a blocking TCP socket with client SSL encryption over it
+
+#include "Globals.h"
+#include "BlockingSslClientSocket.h"
+
+
+
+
+
+cBlockingSslClientSocket::cBlockingSslClientSocket(void) :
+ m_Ssl(*this),
+ m_IsConnected(false)
+{
+ // Nothing needed yet
+}
+
+
+
+
+
+bool cBlockingSslClientSocket::Connect(const AString & a_ServerName, UInt16 a_Port)
+{
+ // If already connected, report an error:
+ if (m_IsConnected)
+ {
+ // TODO: Handle this better - if connected to the same server and port, and the socket is alive, return success
+ m_LastErrorText = "Already connected";
+ return false;
+ }
+
+ // Connect the underlying socket:
+ m_Socket.CreateSocket(cSocket::IPv4);
+ if (!m_Socket.ConnectIPv4(a_ServerName.c_str(), a_Port))
+ {
+ Printf(m_LastErrorText, "Socket connect failed: %s", m_Socket.GetLastErrorString().c_str());
+ return false;
+ }
+
+ // Initialize the SSL:
+ int ret = m_Ssl.Initialize(true);
+ if (ret != 0)
+ {
+ Printf(m_LastErrorText, "SSL initialization failed: -0x%x", -ret);
+ return false;
+ }
+
+ // If we have been assigned a trusted CA root cert store, push it into the SSL context:
+ if (m_CACerts.get() != NULL)
+ {
+ m_Ssl.SetCACerts(m_CACerts, m_ExpectedPeerName);
+ }
+
+ ret = m_Ssl.Handshake();
+ if (ret != 0)
+ {
+ Printf(m_LastErrorText, "SSL handshake failed: -0x%x", -ret);
+ return false;
+ }
+
+ m_IsConnected = true;
+ return true;
+}
+
+
+
+
+
+
+bool cBlockingSslClientSocket::SetTrustedRootCertsFromString(const AString & a_CACerts, const AString & a_ExpectedPeerName)
+{
+ // Warn if used multiple times, but don't signal an error:
+ if (m_CACerts.get() != NULL)
+ {
+ LOGWARNING(
+ "SSL: Trying to set multiple trusted CA root cert stores, only the last one will be used. Name: %s",
+ a_ExpectedPeerName.c_str()
+ );
+ }
+
+ // Parse the cert:
+ m_CACerts.reset(new cX509Cert);
+ int ret = m_CACerts->Parse(a_CACerts.data(), a_CACerts.size());
+ if (ret < 0)
+ {
+ Printf(m_LastErrorText, "CA cert parsing failed: -0x%x", -ret);
+ return false;
+ }
+ m_ExpectedPeerName = a_ExpectedPeerName;
+
+ return true;
+}
+
+
+
+
+
+bool cBlockingSslClientSocket::Send(const void * a_Data, size_t a_NumBytes)
+{
+ ASSERT(m_IsConnected);
+
+ // Keep sending the data until all of it is sent:
+ const char * Data = (const char *)a_Data;
+ size_t NumBytes = a_NumBytes;
+ for (;;)
+ {
+ int res = m_Ssl.WritePlain(a_Data, a_NumBytes);
+ if (res < 0)
+ {
+ ASSERT(res != POLARSSL_ERR_NET_WANT_READ); // This should never happen with callback-based SSL
+ ASSERT(res != POLARSSL_ERR_NET_WANT_WRITE); // This should never happen with callback-based SSL
+ Printf(m_LastErrorText, "Data cannot be written to SSL context: -0x%x", -res);
+ return false;
+ }
+ else
+ {
+ Data += res;
+ NumBytes -= res;
+ if (NumBytes == 0)
+ {
+ return true;
+ }
+ }
+ }
+}
+
+
+
+
+
+
+int cBlockingSslClientSocket::Receive(void * a_Data, size_t a_MaxBytes)
+{
+ ASSERT(m_IsConnected);
+
+ int res = m_Ssl.ReadPlain(a_Data, a_MaxBytes);
+ if (res < 0)
+ {
+ Printf(m_LastErrorText, "Data cannot be read form SSL context: -0x%x", -res);
+ }
+ return res;
+}
+
+
+
+
+
+void cBlockingSslClientSocket::Disconnect(void)
+{
+ // Ignore if not connected
+ if (!m_IsConnected)
+ {
+ return;
+ }
+
+ m_Ssl.NotifyClose();
+ m_Socket.CloseSocket();
+ m_IsConnected = false;
+}
+
+
+
+
+
+int cBlockingSslClientSocket::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes)
+{
+ int res = m_Socket.Receive((char *)a_Buffer, a_NumBytes, 0);
+ if (res < 0)
+ {
+ // PolarSSL's net routines distinguish between connection reset and general failure, we don't need to
+ return POLARSSL_ERR_NET_RECV_FAILED;
+ }
+ return res;
+}
+
+
+
+
+
+int cBlockingSslClientSocket::SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes)
+{
+ int res = m_Socket.Send((const char *)a_Buffer, a_NumBytes);
+ if (res < 0)
+ {
+ // PolarSSL's net routines distinguish between connection reset and general failure, we don't need to
+ return POLARSSL_ERR_NET_SEND_FAILED;
+ }
+ return res;
+}
+
+
+
+
diff --git a/src/PolarSSL++/BlockingSslClientSocket.h b/src/PolarSSL++/BlockingSslClientSocket.h
new file mode 100644
index 000000000..7af897582
--- /dev/null
+++ b/src/PolarSSL++/BlockingSslClientSocket.h
@@ -0,0 +1,80 @@
+
+// BlockingSslClientSocket.h
+
+// Declares the cBlockingSslClientSocket class representing a blocking TCP socket with client SSL encryption over it
+
+
+
+
+
+#pragma once
+
+#include "CallbackSslContext.h"
+#include "../OSSupport/Socket.h"
+
+
+
+
+
+class cBlockingSslClientSocket :
+ protected cCallbackSslContext::cDataCallbacks
+{
+public:
+ cBlockingSslClientSocket(void);
+
+ /** Connects to the specified server and performs SSL handshake.
+ Returns true if successful, false on failure. Sets internal error text on failure. */
+ bool Connect(const AString & a_ServerName, UInt16 a_Port);
+
+ /** Sends the specified data over the connection.
+ Returns true if successful, false on failure. Sets the internal error text on failure. */
+ bool Send(const void * a_Data, size_t a_NumBytes);
+
+ /** Receives data from the connection.
+ Blocks until there is any data available, then returns as much as possible.
+ Returns the number of bytes actually received, negative number on failure.
+ Sets the internal error text on failure. */
+ int Receive(void * a_Data, size_t a_MaxBytes);
+
+ /** Disconnects the connection gracefully, if possible.
+ Note that this also frees the internal SSL context, so all the certificates etc. are lost. */
+ void Disconnect(void);
+
+ /** Sets the root certificates that are to be trusted. Forces the connection to use strict cert
+ verification. Needs to be used before calling Connect().
+ a_ExpectedPeerName is the name that we expect to receive in the SSL peer's cert; verification will fail if
+ the presented name is different (possible MITM).
+ Returns true on success, false on failure. Sets internal error text on failure. */
+ bool SetTrustedRootCertsFromString(const AString & a_CACerts, const AString & a_ExpectedPeerName);
+
+ /** Returns the text of the last error that has occurred in this instance. */
+ const AString & GetLastErrorText(void) const { return m_LastErrorText; }
+
+protected:
+ /** The SSL context used for the socket */
+ cCallbackSslContext m_Ssl;
+
+ /** The underlying socket to the SSL server */
+ cSocket m_Socket;
+
+ /** The trusted CA root cert store, if we are to verify the cert strictly. Set by SetTrustedRootCertsFromString(). */
+ cX509CertPtr m_CACerts;
+
+ /** The expected SSL peer's name, if we are to verify the cert strictly. Set by SetTrustedRootCertsFromString(). */
+ AString m_ExpectedPeerName;
+
+ /** Text of the last error that has occurred. */
+ AString m_LastErrorText;
+
+ /** Set to true if the connection established successfully. */
+ bool m_IsConnected;
+
+
+ // cCallbackSslContext::cDataCallbacks overrides:
+ virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) override;
+ virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) override;
+} ;
+
+
+
+
diff --git a/src/PolarSSL++/BufferedSslContext.cpp b/src/PolarSSL++/BufferedSslContext.cpp
new file mode 100644
index 000000000..9f7caeb8a
--- /dev/null
+++ b/src/PolarSSL++/BufferedSslContext.cpp
@@ -0,0 +1,93 @@
+
+// BufferedSslContext.cpp
+
+// Implements the cBufferedSslContext class representing a SSL context with the SSL peer data backed by a cByteBuffer
+
+#include "Globals.h"
+#include "BufferedSslContext.h"
+
+
+
+
+
+cBufferedSslContext::cBufferedSslContext(size_t a_BufferSize):
+ m_OutgoingData(a_BufferSize),
+ m_IncomingData(a_BufferSize)
+{
+}
+
+
+
+
+
+size_t cBufferedSslContext::WriteIncoming(const void * a_Data, size_t a_NumBytes)
+{
+ size_t NumBytes = std::min(m_IncomingData.GetFreeSpace(), a_NumBytes);
+ if (NumBytes > 0)
+ {
+ m_IncomingData.Write(a_Data, NumBytes);
+ return NumBytes;
+ }
+ return 0;
+}
+
+
+
+
+
+size_t cBufferedSslContext::ReadOutgoing(void * a_Data, size_t a_DataMaxSize)
+{
+ size_t NumBytes = std::min(m_OutgoingData.GetReadableSpace(), a_DataMaxSize);
+ if (NumBytes > 0)
+ {
+ m_OutgoingData.ReadBuf(a_Data, NumBytes);
+ m_OutgoingData.CommitRead();
+ return NumBytes;
+ }
+ return 0;
+}
+
+
+
+
+
+int cBufferedSslContext::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes)
+{
+ // Called when PolarSSL wants to read encrypted data from the SSL peer
+ // Read the data from the buffer inside this object, where the owner has stored them using WriteIncoming():
+ size_t NumBytes = std::min(a_NumBytes, m_IncomingData.GetReadableSpace());
+ if (NumBytes == 0)
+ {
+ return POLARSSL_ERR_NET_WANT_READ;
+ }
+ if (!m_IncomingData.ReadBuf(a_Buffer, NumBytes))
+ {
+ m_IncomingData.ResetRead();
+ return POLARSSL_ERR_NET_RECV_FAILED;
+ }
+ m_IncomingData.CommitRead();
+ return (int)NumBytes;
+}
+
+
+
+
+
+int cBufferedSslContext::SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes)
+{
+ // Called when PolarSSL wants to write encrypted data to the SSL peer
+ // Write the data into the buffer inside this object, where the owner can later read them using ReadOutgoing():
+ if (!m_OutgoingData.CanWriteBytes(a_NumBytes))
+ {
+ return POLARSSL_ERR_NET_WANT_WRITE;
+ }
+ if (!m_OutgoingData.Write((const char *)a_Buffer, a_NumBytes))
+ {
+ return POLARSSL_ERR_NET_SEND_FAILED;
+ }
+ return (int)a_NumBytes;
+}
+
+
+
+
diff --git a/src/PolarSSL++/BufferedSslContext.h b/src/PolarSSL++/BufferedSslContext.h
new file mode 100644
index 000000000..1b7e1af46
--- /dev/null
+++ b/src/PolarSSL++/BufferedSslContext.h
@@ -0,0 +1,52 @@
+
+// BufferedSslContext.h
+
+// Declares the cBufferedSslContext class representing a SSL context with the SSL peer data backed by a cByteBuffer
+
+
+
+
+
+#pragma once
+
+#include "SslContext.h"
+
+
+
+
+
+class cBufferedSslContext :
+ public cSslContext
+{
+ typedef cSslContext super;
+
+public:
+ /** Creates a new context with the buffers of specified size for the encrypted / decrypted data. */
+ cBufferedSslContext(size_t a_BufferSize = 64000);
+
+ /** Stores the specified data in the "incoming" buffer, to be process by the SSL decryptor.
+ This is the data received from the SSL peer.
+ Returns the number of bytes actually stored. If 0 is returned, owner should check the error state. */
+ size_t WriteIncoming(const void * a_Data, size_t a_NumBytes);
+
+ /** Retrieves data from the "outgoing" buffer, after being processed by the SSL encryptor.
+ This is the data to be sent to the SSL peer.
+ Returns the number of bytes actually retrieved. */
+ size_t ReadOutgoing(void * a_Data, size_t a_DataMaxSize);
+
+protected:
+ /** Buffer for the data that has been encrypted into the SSL stream and should be sent out. */
+ cByteBuffer m_OutgoingData;
+
+ /** Buffer for the data that has come in and needs to be decrypted from the SSL stream. */
+ cByteBuffer m_IncomingData;
+
+
+ // cSslContext overrides:
+ virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) override;
+ virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) override;
+} ;
+
+
+
+
diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt
new file mode 100644
index 000000000..39d41292d
--- /dev/null
+++ b/src/PolarSSL++/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required (VERSION 2.6)
+project (MCServer)
+
+include_directories ("${PROJECT_SOURCE_DIR}/../")
+
+set(SRCS
+ AesCfb128Decryptor.cpp
+ AesCfb128Encryptor.cpp
+ BlockingSslClientSocket.cpp
+ BufferedSslContext.cpp
+ CallbackSslContext.cpp
+ CtrDrbgContext.cpp
+ CryptoKey.cpp
+ EntropyContext.cpp
+ RsaPrivateKey.cpp
+ Sha1Checksum.cpp
+ SslContext.cpp
+ X509Cert.cpp
+)
+
+set(HDRS
+ AesCfb128Decryptor.h
+ AesCfb128Encryptor.h
+ BlockingSslClientSocket.h
+ BufferedSslContext.h
+ CallbackSslContext.h
+ CtrDrbgContext.h
+ CryptoKey.h
+ EntropyContext.h
+ RsaPrivateKey.h
+ SslContext.h
+ Sha1Checksum.h
+ X509Cert.h
+)
+
+if(NOT MSVC)
+ add_library(PolarSSL++ ${SRCS} ${HDRS})
+
+ if (UNIX)
+ target_link_libraries(PolarSSL++ polarssl)
+ endif()
+endif()
diff --git a/src/PolarSSL++/CallbackSslContext.cpp b/src/PolarSSL++/CallbackSslContext.cpp
new file mode 100644
index 000000000..c4d19b2a0
--- /dev/null
+++ b/src/PolarSSL++/CallbackSslContext.cpp
@@ -0,0 +1,60 @@
+
+// CallbackSslContext.cpp
+
+// Declares the cCallbackSslContext class representing a SSL context wrapper that uses callbacks to read and write SSL peer data
+
+#include "Globals.h"
+#include "CallbackSslContext.h"
+
+
+
+
+
+
+cCallbackSslContext::cCallbackSslContext(void) :
+ m_Callbacks(NULL)
+{
+ // Nothing needed, but the constructor needs to exist so
+}
+
+
+
+
+
+cCallbackSslContext::cCallbackSslContext(cCallbackSslContext::cDataCallbacks & a_Callbacks) :
+ m_Callbacks(&a_Callbacks)
+{
+}
+
+
+
+
+
+int cCallbackSslContext::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes)
+{
+ if (m_Callbacks == NULL)
+ {
+ LOGWARNING("SSL: Trying to receive data with no callbacks, aborting.");
+ return POLARSSL_ERR_NET_RECV_FAILED;
+ }
+ return m_Callbacks->ReceiveEncrypted(a_Buffer, a_NumBytes);
+}
+
+
+
+
+
+int cCallbackSslContext::SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes)
+{
+ if (m_Callbacks == NULL)
+ {
+ LOGWARNING("SSL: Trying to send data with no callbacks, aborting.");
+ return POLARSSL_ERR_NET_SEND_FAILED;
+ }
+ return m_Callbacks->SendEncrypted(a_Buffer, a_NumBytes);
+}
+
+
+
+
+
diff --git a/src/PolarSSL++/CallbackSslContext.h b/src/PolarSSL++/CallbackSslContext.h
new file mode 100644
index 000000000..3e6edc5f4
--- /dev/null
+++ b/src/PolarSSL++/CallbackSslContext.h
@@ -0,0 +1,64 @@
+
+// CallbackSslContext.h
+
+// Declares the cCallbackSslContext class representing a SSL context wrapper that uses callbacks to read and write SSL peer data
+
+
+
+
+
+#pragma once
+
+#include "SslContext.h"
+
+
+
+
+
+class cCallbackSslContext :
+ public cSslContext
+{
+public:
+ /** Interface used as a data sink for the SSL peer data. */
+ class cDataCallbacks
+ {
+ public:
+ // Force a virtual destructor in descendants:
+ virtual ~cDataCallbacks() {}
+
+ /** Called when PolarSSL wants to read encrypted data from the SSL peer.
+ The returned value is the number of bytes received, or a PolarSSL error on failure.
+ The implementation can return POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE to indicate
+ that there's currently no more data and that there might be more data in the future. In such cases the
+ SSL operation that invoked this call will terminate with the same return value, so that the owner is
+ notified of this condition and can potentially restart the operation later on. */
+ virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) = 0;
+
+ /** Called when PolarSSL wants to write encrypted data to the SSL peer.
+ The returned value is the number of bytes sent, or a PolarSSL error on failure.
+ The implementation can return POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE to indicate
+ that there's currently no more data and that there might be more data in the future. In such cases the
+ SSL operation that invoked this call will terminate with the same return value, so that the owner is
+ notified of this condition and can potentially restart the operation later on. */
+ virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) = 0;
+ } ;
+
+
+ /** Creates a new SSL context with no callbacks assigned */
+ cCallbackSslContext(void);
+
+ /** Creates a new SSL context with the specified callbacks */
+ cCallbackSslContext(cDataCallbacks & a_Callbacks);
+
+protected:
+ /** The callbacks to use to send and receive SSL peer data */
+ cDataCallbacks * m_Callbacks;
+
+ // cSslContext overrides:
+ virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) override;
+ virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) override;
+};
+
+
+
+
diff --git a/src/PolarSSL++/CryptoKey.cpp b/src/PolarSSL++/CryptoKey.cpp
new file mode 100644
index 000000000..0763c387b
--- /dev/null
+++ b/src/PolarSSL++/CryptoKey.cpp
@@ -0,0 +1,149 @@
+
+// CryptoKey.cpp
+
+// Implements the cCryptoKey class representing a RSA public key in PolarSSL
+
+#include "Globals.h"
+#include "CryptoKey.h"
+
+
+
+
+
+cCryptoKey::cCryptoKey(void)
+{
+ pk_init(&m_Pk);
+ m_CtrDrbg.Initialize("rsa_pubkey", 10);
+}
+
+
+
+
+
+cCryptoKey::cCryptoKey(const AString & a_PublicKeyData)
+{
+ pk_init(&m_Pk);
+ m_CtrDrbg.Initialize("rsa_pubkey", 10);
+ int res = ParsePublic(a_PublicKeyData.data(), a_PublicKeyData.size());
+ if (res != 0)
+ {
+ LOGWARNING("Failed to parse public key: -0x%x", res);
+ ASSERT(!"Cannot parse PubKey");
+ return;
+ }
+}
+
+
+
+
+
+cCryptoKey::cCryptoKey(const AString & a_PrivateKeyData, const AString & a_Password)
+{
+ pk_init(&m_Pk);
+ m_CtrDrbg.Initialize("rsa_privkey", 11);
+ int res = ParsePrivate(a_PrivateKeyData.data(), a_PrivateKeyData.size(), a_Password);
+ if (res != 0)
+ {
+ LOGWARNING("Failed to parse private key: -0x%x", res);
+ ASSERT(!"Cannot parse PubKey");
+ return;
+ }
+}
+
+
+
+
+
+cCryptoKey::~cCryptoKey()
+{
+ pk_free(&m_Pk);
+}
+
+
+
+
+
+int cCryptoKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength)
+{
+ ASSERT(IsValid());
+
+ size_t DecryptedLen = a_DecryptedMaxLength;
+ int res = pk_decrypt(&m_Pk,
+ a_EncryptedData, a_EncryptedLength,
+ a_DecryptedData, &DecryptedLen, a_DecryptedMaxLength,
+ ctr_drbg_random, m_CtrDrbg.GetInternal()
+ );
+ if (res != 0)
+ {
+ return res;
+ }
+ return (int)DecryptedLen;
+}
+
+
+
+
+
+int cCryptoKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength)
+{
+ ASSERT(IsValid());
+
+ size_t EncryptedLength = a_EncryptedMaxLength;
+ int res = pk_encrypt(&m_Pk,
+ a_PlainData, a_PlainLength, a_EncryptedData, &EncryptedLength, a_EncryptedMaxLength,
+ ctr_drbg_random, m_CtrDrbg.GetInternal()
+ );
+ if (res != 0)
+ {
+ return res;
+ }
+ return (int)EncryptedLength;
+}
+
+
+
+
+
+
+int cCryptoKey::ParsePublic(const void * a_Data, size_t a_NumBytes)
+{
+ ASSERT(!IsValid()); // Cannot parse a second key
+
+ return pk_parse_public_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes);
+}
+
+
+
+
+
+
+int cCryptoKey::ParsePrivate(const void * a_Data, size_t a_NumBytes, const AString & a_Password)
+{
+ ASSERT(!IsValid()); // Cannot parse a second key
+
+ if (a_Password.empty())
+ {
+ return pk_parse_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes, NULL, 0);
+ }
+ else
+ {
+ return pk_parse_key(
+ &m_Pk,
+ (const unsigned char *)a_Data, a_NumBytes,
+ (const unsigned char *)a_Password.c_str(), a_Password.size()
+ );
+ }
+}
+
+
+
+
+
+bool cCryptoKey::IsValid(void) const
+{
+ return (pk_get_type(&m_Pk) != POLARSSL_PK_NONE);
+}
+
+
+
+
diff --git a/src/PolarSSL++/CryptoKey.h b/src/PolarSSL++/CryptoKey.h
new file mode 100644
index 000000000..9c298e501
--- /dev/null
+++ b/src/PolarSSL++/CryptoKey.h
@@ -0,0 +1,76 @@
+
+// CryptoKey.h
+
+// Declares the cCryptoKey class representing a RSA public key in PolarSSL
+
+
+
+
+
+#pragma once
+
+#include "CtrDrbgContext.h"
+#include "polarssl/pk.h"
+
+
+
+
+
+class cCryptoKey
+{
+ friend class cSslContext;
+
+public:
+ /** Constructs an empty key instance. Before use, it needs to be filled by ParsePublic() or ParsePrivate() */
+ cCryptoKey(void);
+
+ /** Constructs the public key out of the DER- or PEM-encoded pubkey data */
+ cCryptoKey(const AString & a_PublicKeyData);
+
+ /** Constructs the private key out of the DER- or PEM-encoded privkey data, with the specified password.
+ If a_Password is empty, no password is assumed. */
+ cCryptoKey(const AString & a_PrivateKeyData, const AString & a_Password);
+
+ ~cCryptoKey();
+
+ /** Decrypts the data using the stored public key
+ Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large.
+ Returns the number of bytes decrypted, or negative number for error. */
+ int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength);
+
+ /** Encrypts the data using the stored public key
+ Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large.
+ Returns the number of bytes decrypted, or negative number for error. */
+ int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength);
+
+ /** Parses the specified data into a public key representation.
+ The key can be DER- or PEM-encoded.
+ Returns 0 on success, PolarSSL error code on failure. */
+ int ParsePublic(const void * a_Data, size_t a_NumBytes);
+
+ /** Parses the specified data into a private key representation.
+ If a_Password is empty, no password is assumed.
+ The key can be DER- or PEM-encoded.
+ Returns 0 on success, PolarSSL error code on failure. */
+ int ParsePrivate(const void * a_Data, size_t a_NumBytes, const AString & a_Password);
+
+ /** Returns true if the contained key is valid. */
+ bool IsValid(void) const;
+
+protected:
+ /** The PolarSSL representation of the key data */
+ pk_context m_Pk;
+
+ /** The random generator used in encryption and decryption */
+ cCtrDrbgContext m_CtrDrbg;
+
+
+ /** Returns the internal context ptr. Only use in PolarSSL API calls. */
+ pk_context * GetInternal(void) { return &m_Pk; }
+} ;
+
+typedef SharedPtr<cCryptoKey> cCryptoKeyPtr;
+
+
+
+
diff --git a/src/PolarSSL++/CtrDrbgContext.cpp b/src/PolarSSL++/CtrDrbgContext.cpp
new file mode 100644
index 000000000..86e6d1ca5
--- /dev/null
+++ b/src/PolarSSL++/CtrDrbgContext.cpp
@@ -0,0 +1,49 @@
+
+// CtrDrbgContext.cpp
+
+// Implements the cCtrDrbgContext class representing a wrapper over CTR-DRBG implementation in PolarSSL
+
+#include "Globals.h"
+#include "CtrDrbgContext.h"
+#include "EntropyContext.h"
+
+
+
+
+
+cCtrDrbgContext::cCtrDrbgContext(void) :
+ m_EntropyContext(new cEntropyContext),
+ m_IsValid(false)
+{
+}
+
+
+
+
+
+cCtrDrbgContext::cCtrDrbgContext(const SharedPtr<cEntropyContext> & a_EntropyContext) :
+ m_EntropyContext(a_EntropyContext),
+ m_IsValid(false)
+{
+}
+
+
+
+
+
+int cCtrDrbgContext::Initialize(const void * a_Custom, size_t a_CustomSize)
+{
+ if (m_IsValid)
+ {
+ // Already initialized
+ return 0;
+ }
+
+ int res = ctr_drbg_init(&m_CtrDrbg, entropy_func, &(m_EntropyContext->m_Entropy), (const unsigned char *)a_Custom, a_CustomSize);
+ m_IsValid = (res == 0);
+ return res;
+}
+
+
+
+
diff --git a/src/PolarSSL++/CtrDrbgContext.h b/src/PolarSSL++/CtrDrbgContext.h
new file mode 100644
index 000000000..230db8753
--- /dev/null
+++ b/src/PolarSSL++/CtrDrbgContext.h
@@ -0,0 +1,63 @@
+
+// CtrDrbgContext.h
+
+// Declares the cCtrDrbgContext class representing a wrapper over CTR-DRBG implementation in PolarSSL
+
+
+
+
+
+#pragma once
+
+#include "polarssl/ctr_drbg.h"
+
+
+
+
+
+// fwd: EntropyContext.h
+class cEntropyContext;
+
+
+
+
+
+class cCtrDrbgContext
+{
+ friend class cSslContext;
+ friend class cRsaPrivateKey;
+ friend class cCryptoKey;
+
+public:
+ /** Constructs the context with a new entropy context. */
+ cCtrDrbgContext(void);
+
+ /** Constructs the context with the specified entropy context. */
+ cCtrDrbgContext(const SharedPtr<cEntropyContext> & a_EntropyContext);
+
+ /** Initializes the context.
+ a_Custom is optional additional data to use for entropy, nullptr is accepted.
+ Returns 0 if successful, PolarSSL error code on failure. */
+ int Initialize(const void * a_Custom, size_t a_CustomSize);
+
+ /** Returns true if the object is valid (has been initialized properly) */
+ bool IsValid(void) const { return m_IsValid; }
+
+protected:
+ /** The entropy source used for generating the random */
+ SharedPtr<cEntropyContext> m_EntropyContext;
+
+ /** The random generator context */
+ ctr_drbg_context m_CtrDrbg;
+
+ /** Set to true if the object is valid (has been initialized properly) */
+ bool m_IsValid;
+
+
+ /** Returns the internal context ptr. Only use in PolarSSL API calls. */
+ ctr_drbg_context * GetInternal(void) { return &m_CtrDrbg; }
+} ;
+
+
+
+
diff --git a/src/PolarSSL++/EntropyContext.cpp b/src/PolarSSL++/EntropyContext.cpp
new file mode 100644
index 000000000..9c59b3f11
--- /dev/null
+++ b/src/PolarSSL++/EntropyContext.cpp
@@ -0,0 +1,29 @@
+
+// EntropyContext.cpp
+
+// Implements the cEntropyContext class representing a wrapper over entropy contexts in PolarSSL
+
+#include "Globals.h"
+#include "EntropyContext.h"
+
+
+
+
+
+cEntropyContext::cEntropyContext(void)
+{
+ entropy_init(&m_Entropy);
+}
+
+
+
+
+
+cEntropyContext::~cEntropyContext()
+{
+ entropy_free(&m_Entropy);
+}
+
+
+
+
diff --git a/src/PolarSSL++/EntropyContext.h b/src/PolarSSL++/EntropyContext.h
new file mode 100644
index 000000000..bc7fff066
--- /dev/null
+++ b/src/PolarSSL++/EntropyContext.h
@@ -0,0 +1,31 @@
+
+// EntropyContext.h
+
+// Declares the cEntropyContext class representing a wrapper over entropy contexts in PolarSSL
+
+
+
+
+
+#pragma once
+
+#include "polarssl/entropy.h"
+
+
+
+
+
+class cEntropyContext
+{
+ friend class cCtrDrbgContext;
+public:
+ cEntropyContext(void);
+ ~cEntropyContext();
+
+protected:
+ entropy_context m_Entropy;
+} ;
+
+
+
+
diff --git a/src/PolarSSL++/RsaPrivateKey.cpp b/src/PolarSSL++/RsaPrivateKey.cpp
new file mode 100644
index 000000000..2d5a2a4b1
--- /dev/null
+++ b/src/PolarSSL++/RsaPrivateKey.cpp
@@ -0,0 +1,176 @@
+
+// RsaPrivateKey.cpp
+
+#include "Globals.h"
+#include "RsaPrivateKey.h"
+#include "CtrDrbgContext.h"
+#include "polarssl/pk.h"
+
+
+
+
+
+
+cRsaPrivateKey::cRsaPrivateKey(void)
+{
+ rsa_init(&m_Rsa, RSA_PKCS_V15, 0);
+ m_CtrDrbg.Initialize("RSA", 3);
+}
+
+
+
+
+
+cRsaPrivateKey::cRsaPrivateKey(const cRsaPrivateKey & a_Other)
+{
+ rsa_init(&m_Rsa, RSA_PKCS_V15, 0);
+ rsa_copy(&m_Rsa, &a_Other.m_Rsa);
+ m_CtrDrbg.Initialize("RSA", 3);
+}
+
+
+
+
+
+cRsaPrivateKey::~cRsaPrivateKey()
+{
+ rsa_free(&m_Rsa);
+}
+
+
+
+
+
+bool cRsaPrivateKey::Generate(unsigned a_KeySizeBits)
+{
+ int res = rsa_gen_key(&m_Rsa, ctr_drbg_random, m_CtrDrbg.GetInternal(), a_KeySizeBits, 65537);
+ if (res != 0)
+ {
+ LOG("RSA key generation failed: -0x%x", -res);
+ return false;
+ }
+
+ return true;
+}
+
+
+
+
+
+AString cRsaPrivateKey::GetPubKeyDER(void)
+{
+ class cPubKey
+ {
+ public:
+ cPubKey(rsa_context * a_Rsa) :
+ m_IsValid(false)
+ {
+ pk_init(&m_Key);
+ if (pk_init_ctx(&m_Key, pk_info_from_type(POLARSSL_PK_RSA)) != 0)
+ {
+ ASSERT(!"Cannot init PrivKey context");
+ return;
+ }
+ if (rsa_copy(pk_rsa(m_Key), a_Rsa) != 0)
+ {
+ ASSERT(!"Cannot copy PrivKey to PK context");
+ return;
+ }
+ m_IsValid = true;
+ }
+
+ ~cPubKey()
+ {
+ if (m_IsValid)
+ {
+ pk_free(&m_Key);
+ }
+ }
+
+ operator pk_context * (void) { return &m_Key; }
+
+ protected:
+ bool m_IsValid;
+ pk_context m_Key;
+ } PkCtx(&m_Rsa);
+
+ unsigned char buf[3000];
+ int res = pk_write_pubkey_der(PkCtx, buf, sizeof(buf));
+ if (res < 0)
+ {
+ return AString();
+ }
+ return AString((const char *)(buf + sizeof(buf) - res), (size_t)res);
+}
+
+
+
+
+
+int cRsaPrivateKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength)
+{
+ if (a_EncryptedLength < m_Rsa.len)
+ {
+ LOGD("%s: Invalid a_EncryptedLength: got %u, exp at least %u",
+ __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len)
+ );
+ ASSERT(!"Invalid a_DecryptedMaxLength!");
+ return -1;
+ }
+ if (a_DecryptedMaxLength < m_Rsa.len)
+ {
+ LOGD("%s: Invalid a_DecryptedMaxLength: got %u, exp at least %u",
+ __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len)
+ );
+ ASSERT(!"Invalid a_DecryptedMaxLength!");
+ return -1;
+ }
+ size_t DecryptedLength;
+ int res = rsa_pkcs1_decrypt(
+ &m_Rsa, ctr_drbg_random, m_CtrDrbg.GetInternal(), RSA_PRIVATE, &DecryptedLength,
+ a_EncryptedData, a_DecryptedData, a_DecryptedMaxLength
+ );
+ if (res != 0)
+ {
+ return -1;
+ }
+ return (int)DecryptedLength;
+}
+
+
+
+
+
+int cRsaPrivateKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength)
+{
+ if (a_EncryptedMaxLength < m_Rsa.len)
+ {
+ LOGD("%s: Invalid a_EncryptedMaxLength: got %u, exp at least %u",
+ __FUNCTION__, (unsigned)a_EncryptedMaxLength, (unsigned)(m_Rsa.len)
+ );
+ ASSERT(!"Invalid a_DecryptedMaxLength!");
+ return -1;
+ }
+ if (a_PlainLength < m_Rsa.len)
+ {
+ LOGD("%s: Invalid a_PlainLength: got %u, exp at least %u",
+ __FUNCTION__, (unsigned)a_PlainLength, (unsigned)(m_Rsa.len)
+ );
+ ASSERT(!"Invalid a_PlainLength!");
+ return -1;
+ }
+ int res = rsa_pkcs1_encrypt(
+ &m_Rsa, ctr_drbg_random, m_CtrDrbg.GetInternal(), RSA_PRIVATE,
+ a_PlainLength, a_PlainData, a_EncryptedData
+ );
+ if (res != 0)
+ {
+ return -1;
+ }
+ return (int)m_Rsa.len;
+}
+
+
+
+
+
diff --git a/src/PolarSSL++/RsaPrivateKey.h b/src/PolarSSL++/RsaPrivateKey.h
new file mode 100644
index 000000000..4d03f27df
--- /dev/null
+++ b/src/PolarSSL++/RsaPrivateKey.h
@@ -0,0 +1,67 @@
+
+// RsaPrivateKey.h
+
+// Declares the cRsaPrivateKey class representing a private key for RSA operations.
+
+
+
+
+
+#pragma once
+
+#include "CtrDrbgContext.h"
+#include "polarssl/rsa.h"
+
+
+
+
+
+/** Encapsulates an RSA private key used in PKI cryptography */
+class cRsaPrivateKey
+{
+ friend class cSslContext;
+
+public:
+ /** Creates a new empty object, the key is not assigned */
+ cRsaPrivateKey(void);
+
+ /** Deep-copies the key from a_Other */
+ cRsaPrivateKey(const cRsaPrivateKey & a_Other);
+
+ ~cRsaPrivateKey();
+
+ /** Generates a new key within this object, with the specified size in bits.
+ Returns true on success, false on failure. */
+ bool Generate(unsigned a_KeySizeBits = 1024);
+
+ /** Returns the public key part encoded in ASN1 DER encoding */
+ AString GetPubKeyDER(void);
+
+ /** Decrypts the data using RSAES-PKCS#1 algorithm.
+ Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large.
+ Returns the number of bytes decrypted, or negative number for error. */
+ int Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength, Byte * a_DecryptedData, size_t a_DecryptedMaxLength);
+
+ /** Encrypts the data using RSAES-PKCS#1 algorithm.
+ Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large.
+ Returns the number of bytes decrypted, or negative number for error. */
+ int Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a_EncryptedData, size_t a_EncryptedMaxLength);
+
+protected:
+ /** The PolarSSL key context */
+ rsa_context m_Rsa;
+
+ /** The random generator used for generating the key and encryption / decryption */
+ cCtrDrbgContext m_CtrDrbg;
+
+
+ /** Returns the internal context ptr. Only use in PolarSSL API calls. */
+ rsa_context * GetInternal(void) { return &m_Rsa; }
+} ;
+
+typedef SharedPtr<cRsaPrivateKey> cRsaPrivateKeyPtr;
+
+
+
+
+
diff --git a/src/PolarSSL++/Sha1Checksum.cpp b/src/PolarSSL++/Sha1Checksum.cpp
new file mode 100644
index 000000000..e69ef236f
--- /dev/null
+++ b/src/PolarSSL++/Sha1Checksum.cpp
@@ -0,0 +1,138 @@
+
+// Sha1Checksum.cpp
+
+// Declares the cSha1Checksum class representing the SHA-1 checksum calculator
+
+#include "Globals.h"
+#include "Sha1Checksum.h"
+
+
+
+
+
+/*
+// Self-test the hash formatting for known values:
+// sha1(Notch) : 4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48
+// sha1(jeb_) : -7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1
+// sha1(simon) : 88e16a1019277b15d58faf0541e11910eb756f6
+
+static class Test
+{
+public:
+ Test(void)
+ {
+ AString DigestNotch, DigestJeb, DigestSimon;
+ Byte Digest[20];
+ cSha1Checksum Checksum;
+ Checksum.Update((const Byte *)"Notch", 5);
+ Checksum.Finalize(Digest);
+ cSha1Checksum::DigestToJava(Digest, DigestNotch);
+ Checksum.Restart();
+ Checksum.Update((const Byte *)"jeb_", 4);
+ Checksum.Finalize(Digest);
+ cSha1Checksum::DigestToJava(Digest, DigestJeb);
+ Checksum.Restart();
+ Checksum.Update((const Byte *)"simon", 5);
+ Checksum.Finalize(Digest);
+ cSha1Checksum::DigestToJava(Digest, DigestSimon);
+ printf("Notch: \"%s\"\n", DigestNotch.c_str());
+ printf("jeb_: \"%s\"\n", DigestJeb.c_str());
+ printf("simon: \"%s\"\n", DigestSimon.c_str());
+ assert(DigestNotch == "4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48");
+ assert(DigestJeb == "-7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1");
+ assert(DigestSimon == "88e16a1019277b15d58faf0541e11910eb756f6");
+ }
+} test;
+*/
+
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cSha1Checksum:
+
+cSha1Checksum::cSha1Checksum(void) :
+ m_DoesAcceptInput(true)
+{
+ sha1_starts(&m_Sha1);
+}
+
+
+
+
+
+void cSha1Checksum::Update(const Byte * a_Data, size_t a_Length)
+{
+ ASSERT(m_DoesAcceptInput); // Not Finalize()-d yet, or Restart()-ed
+
+ sha1_update(&m_Sha1, a_Data, a_Length);
+}
+
+
+
+
+
+void cSha1Checksum::Finalize(cSha1Checksum::Checksum & a_Output)
+{
+ ASSERT(m_DoesAcceptInput); // Not Finalize()-d yet, or Restart()-ed
+
+ sha1_finish(&m_Sha1, a_Output);
+ m_DoesAcceptInput = false;
+}
+
+
+
+
+
+void cSha1Checksum::DigestToJava(const Checksum & a_Digest, AString & a_Out)
+{
+ Checksum Digest;
+ memcpy(Digest, a_Digest, sizeof(Digest));
+
+ bool IsNegative = (Digest[0] >= 0x80);
+ if (IsNegative)
+ {
+ // Two's complement:
+ bool carry = true; // Add one to the whole number
+ for (int i = 19; i >= 0; i--)
+ {
+ Digest[i] = ~Digest[i];
+ if (carry)
+ {
+ carry = (Digest[i] == 0xff);
+ Digest[i]++;
+ }
+ }
+ }
+ a_Out.clear();
+ a_Out.reserve(40);
+ for (int i = 0; i < 20; i++)
+ {
+ AppendPrintf(a_Out, "%02x", Digest[i]);
+ }
+ while ((a_Out.length() > 0) && (a_Out[0] == '0'))
+ {
+ a_Out.erase(0, 1);
+ }
+ if (IsNegative)
+ {
+ a_Out.insert(0, "-");
+ }
+}
+
+
+
+
+
+
+void cSha1Checksum::Restart(void)
+{
+ sha1_starts(&m_Sha1);
+ m_DoesAcceptInput = true;
+}
+
+
+
+
diff --git a/src/PolarSSL++/Sha1Checksum.h b/src/PolarSSL++/Sha1Checksum.h
new file mode 100644
index 000000000..68fdbcf1b
--- /dev/null
+++ b/src/PolarSSL++/Sha1Checksum.h
@@ -0,0 +1,52 @@
+
+// Sha1Checksum.h
+
+// Declares the cSha1Checksum class representing the SHA-1 checksum calculator
+
+
+
+
+
+#pragma once
+
+#include "polarssl/sha1.h"
+
+
+
+
+
+/** Calculates a SHA1 checksum for data stream */
+class cSha1Checksum
+{
+public:
+ typedef Byte Checksum[20]; // The type used for storing the checksum
+
+ cSha1Checksum(void);
+
+ /** Adds the specified data to the checksum */
+ void Update(const Byte * a_Data, size_t a_Length);
+
+ /** Calculates and returns the final checksum */
+ void Finalize(Checksum & a_Output);
+
+ /** Returns true if the object is accepts more input data, false if Finalize()-d (need to Restart()) */
+ bool DoesAcceptInput(void) const { return m_DoesAcceptInput; }
+
+ /** Converts a raw 160-bit SHA1 digest into a Java Hex representation
+ According to http://wiki.vg/wiki/index.php?title=Protocol_Encryption&oldid=2802
+ */
+ static void DigestToJava(const Checksum & a_Digest, AString & a_JavaOut);
+
+ /** Clears the current context and start a new checksum calculation */
+ void Restart(void);
+
+protected:
+ /** True if the object is accepts more input data, false if Finalize()-d (need to Restart()) */
+ bool m_DoesAcceptInput;
+
+ sha1_context m_Sha1;
+} ;
+
+
+
+
diff --git a/src/PolarSSL++/SslContext.cpp b/src/PolarSSL++/SslContext.cpp
new file mode 100644
index 000000000..c3074f197
--- /dev/null
+++ b/src/PolarSSL++/SslContext.cpp
@@ -0,0 +1,303 @@
+
+// SslContext.cpp
+
+// Implements the cSslContext class that holds everything a single SSL context needs to function
+
+#include "Globals.h"
+#include "SslContext.h"
+#include "EntropyContext.h"
+#include "CtrDrbgContext.h"
+
+
+
+
+
+cSslContext::cSslContext(void) :
+ m_IsValid(false),
+ m_HasHandshaken(false)
+{
+}
+
+
+
+
+
+cSslContext::~cSslContext()
+{
+ if (m_IsValid)
+ {
+ ssl_free(&m_Ssl);
+ }
+}
+
+
+
+
+
+int cSslContext::Initialize(bool a_IsClient, const SharedPtr<cCtrDrbgContext> & a_CtrDrbg)
+{
+ // Check double-initialization:
+ if (m_IsValid)
+ {
+ LOGWARNING("SSL: Double initialization is not supported.");
+ return POLARSSL_ERR_SSL_BAD_INPUT_DATA; // There is no return value well-suited for this, reuse this one.
+ }
+
+ // Set the CtrDrbg context, create a new one if needed:
+ m_CtrDrbg = a_CtrDrbg;
+ if (m_CtrDrbg.get() == NULL)
+ {
+ m_CtrDrbg.reset(new cCtrDrbgContext);
+ m_CtrDrbg->Initialize("MCServer", 8);
+ }
+
+ // Initialize PolarSSL's structures:
+ memset(&m_Ssl, 0, sizeof(m_Ssl));
+ int res = ssl_init(&m_Ssl);
+ if (res != 0)
+ {
+ return res;
+ }
+ ssl_set_endpoint(&m_Ssl, a_IsClient ? SSL_IS_CLIENT : SSL_IS_SERVER);
+ ssl_set_authmode(&m_Ssl, a_IsClient ? SSL_VERIFY_OPTIONAL : SSL_VERIFY_NONE); // Clients ask for server's cert but don't verify strictly; servers don't ask clients for certs by default
+ ssl_set_rng(&m_Ssl, ctr_drbg_random, &m_CtrDrbg->m_CtrDrbg);
+ ssl_set_bio(&m_Ssl, ReceiveEncrypted, this, SendEncrypted, this);
+
+ #ifdef _DEBUG
+ /*
+ // These functions allow us to debug SSL and certificate problems, but produce way too much output,
+ // so they're disabled until someone needs them
+ ssl_set_dbg(&m_Ssl, &SSLDebugMessage, this);
+ ssl_set_verify(&m_Ssl, &SSLVerifyCert, this);
+ */
+
+ /*
+ // Set ciphersuite to the easiest one to decode, so that the connection can be wireshark-decoded:
+ static const int CipherSuites[] =
+ {
+ TLS_RSA_WITH_RC4_128_MD5,
+ TLS_RSA_WITH_RC4_128_SHA,
+ TLS_RSA_WITH_AES_128_CBC_SHA,
+ 0, // Must be 0-terminated!
+ };
+ ssl_set_ciphersuites(&m_Ssl, CipherSuites);
+ */
+ #endif
+
+ m_IsValid = true;
+ return 0;
+}
+
+
+
+
+
+void cSslContext::SetOwnCert(const cX509CertPtr & a_OwnCert, const cRsaPrivateKeyPtr & a_OwnCertPrivKey)
+{
+ ASSERT(m_IsValid); // Call Initialize() first
+
+ // Check that both the cert and the key is valid:
+ if ((a_OwnCert.get() == NULL) || (a_OwnCertPrivKey.get() == NULL))
+ {
+ LOGWARNING("SSL: Own certificate is not valid, skipping the set.");
+ return;
+ }
+
+ // Make sure we have the cert stored for later, PolarSSL only uses the cert later on
+ m_OwnCert = a_OwnCert;
+ m_OwnCertPrivKey = a_OwnCertPrivKey;
+
+ // Set into the context:
+ ssl_set_own_cert_rsa(&m_Ssl, m_OwnCert->GetInternal(), m_OwnCertPrivKey->GetInternal());
+}
+
+
+
+
+
+void cSslContext::SetOwnCert(const cX509CertPtr & a_OwnCert, const cCryptoKeyPtr & a_OwnCertPrivKey)
+{
+ ASSERT(m_IsValid); // Call Initialize() first
+
+ // Check that both the cert and the key is valid:
+ if ((a_OwnCert.get() == NULL) || (a_OwnCertPrivKey.get() == NULL))
+ {
+ LOGWARNING("SSL: Own certificate is not valid, skipping the set.");
+ return;
+ }
+
+ // Make sure we have the cert stored for later, PolarSSL only uses the cert later on
+ m_OwnCert = a_OwnCert;
+ m_OwnCertPrivKey2 = a_OwnCertPrivKey;
+
+ // Set into the context:
+ ssl_set_own_cert(&m_Ssl, m_OwnCert->GetInternal(), m_OwnCertPrivKey2->GetInternal());
+}
+
+
+
+
+
+void cSslContext::SetCACerts(const cX509CertPtr & a_CACert, const AString & a_ExpectedPeerName)
+{
+ ASSERT(m_IsValid); // Call Initialize() first
+
+ // Store the data in our internal buffers, to avoid losing the pointers later on
+ // PolarSSL will need these after this call returns, and the caller may move / delete the data before that:
+ m_ExpectedPeerName = a_ExpectedPeerName;
+ m_CACerts = a_CACert;
+
+ // Set the trusted CA root cert store:
+ ssl_set_authmode(&m_Ssl, SSL_VERIFY_REQUIRED);
+ ssl_set_ca_chain(&m_Ssl, m_CACerts->GetInternal(), NULL, m_ExpectedPeerName.empty() ? NULL : m_ExpectedPeerName.c_str());
+}
+
+
+
+
+
+int cSslContext::WritePlain(const void * a_Data, size_t a_NumBytes)
+{
+ ASSERT(m_IsValid); // Need to call Initialize() first
+ if (!m_HasHandshaken)
+ {
+ int res = Handshake();
+ if (res != 0)
+ {
+ return res;
+ }
+ }
+
+ return ssl_write(&m_Ssl, (const unsigned char *)a_Data, a_NumBytes);
+}
+
+
+
+
+
+int cSslContext::ReadPlain(void * a_Data, size_t a_MaxBytes)
+{
+ ASSERT(m_IsValid); // Need to call Initialize() first
+ if (!m_HasHandshaken)
+ {
+ int res = Handshake();
+ if (res != 0)
+ {
+ return res;
+ }
+ }
+
+ return ssl_read(&m_Ssl, (unsigned char *)a_Data, a_MaxBytes);
+}
+
+
+
+
+
+int cSslContext::Handshake(void)
+{
+ ASSERT(m_IsValid); // Need to call Initialize() first
+ ASSERT(!m_HasHandshaken); // Must not call twice
+
+ int res = ssl_handshake(&m_Ssl);
+ if (res == 0)
+ {
+ m_HasHandshaken = true;
+ }
+ return res;
+}
+
+
+
+
+
+int cSslContext::NotifyClose(void)
+{
+ return ssl_close_notify(&m_Ssl);
+}
+
+
+
+
+
+#ifdef _DEBUG
+ void cSslContext::SSLDebugMessage(void * a_UserParam, int a_Level, const char * a_Text)
+ {
+ if (a_Level > 3)
+ {
+ // Don't want the trace messages
+ return;
+ }
+
+ // Remove the terminating LF:
+ size_t len = strlen(a_Text) - 1;
+ while ((len > 0) && (a_Text[len] <= 32))
+ {
+ len--;
+ }
+ AString Text(a_Text, len + 1);
+
+ LOGD("SSL (%d): %s", a_Level, Text.c_str());
+ }
+
+
+
+
+
+ int cSslContext::SSLVerifyCert(void * a_This, x509_crt * a_Crt, int a_Depth, int * a_Flags)
+ {
+ char buf[1024];
+ UNUSED(a_This);
+
+ LOG("Verify requested for (Depth %d):", a_Depth);
+ x509_crt_info(buf, sizeof(buf) - 1, "", a_Crt);
+ LOG("%s", buf);
+
+ int Flags = *a_Flags;
+ if ((Flags & BADCERT_EXPIRED) != 0)
+ {
+ LOG(" ! server certificate has expired");
+ }
+
+ if ((Flags & BADCERT_REVOKED) != 0)
+ {
+ LOG(" ! server certificate has been revoked");
+ }
+
+ if ((Flags & BADCERT_CN_MISMATCH) != 0)
+ {
+ LOG(" ! CN mismatch");
+ }
+
+ if ((Flags & BADCERT_NOT_TRUSTED) != 0)
+ {
+ LOG(" ! self-signed or not signed by a trusted CA");
+ }
+
+ if ((Flags & BADCRL_NOT_TRUSTED) != 0)
+ {
+ LOG(" ! CRL not trusted");
+ }
+
+ if ((Flags & BADCRL_EXPIRED) != 0)
+ {
+ LOG(" ! CRL expired");
+ }
+
+ if ((Flags & BADCERT_OTHER) != 0)
+ {
+ LOG(" ! other (unknown) flag");
+ }
+
+ if (Flags == 0)
+ {
+ LOG(" This certificate has no flags");
+ }
+
+ return 0;
+ }
+#endif // _DEBUG
+
+
+
+
diff --git a/src/PolarSSL++/SslContext.h b/src/PolarSSL++/SslContext.h
new file mode 100644
index 000000000..6b4f2c1e7
--- /dev/null
+++ b/src/PolarSSL++/SslContext.h
@@ -0,0 +1,156 @@
+
+// SslContext.h
+
+// Declares the cSslContext class that holds everything a single SSL context needs to function
+
+
+
+
+
+#pragma once
+
+#include "polarssl/ssl.h"
+#include "../ByteBuffer.h"
+#include "CryptoKey.h"
+#include "RsaPrivateKey.h"
+#include "X509Cert.h"
+
+
+
+
+
+// fwd:
+class cCtrDrbgContext;
+
+
+
+
+
+/**
+Acts as a generic SSL encryptor / decryptor between the two endpoints. The "owner" of this class is expected
+to create it, initialize it and then provide the means of reading and writing data through the SSL link.
+This is an abstract base class, there are descendants that handle the specific aspects of how the SSL peer
+data comes into the system:
+ - cBufferedSslContext uses a cByteBuffer to read and write the data
+ - cCallbackSslContext uses callbacks to provide the data
+*/
+class cSslContext abstract
+{
+public:
+ /** Creates a new uninitialized context */
+ cSslContext(void);
+
+ virtual ~cSslContext();
+
+ /** Initializes the context for use as a server or client.
+ Returns 0 on success, PolarSSL error on failure. */
+ int Initialize(bool a_IsClient, const SharedPtr<cCtrDrbgContext> & a_CtrDrbg = SharedPtr<cCtrDrbgContext>());
+
+ /** Returns true if the object has been initialized properly. */
+ bool IsValid(void) const { return m_IsValid; }
+
+ /** Sets the certificate to use as our own. Must be used when representing a server, optional when client.
+ Must be called after Initialize(). */
+ void SetOwnCert(const cX509CertPtr & a_OwnCert, const cRsaPrivateKeyPtr & a_OwnCertPrivKey);
+
+ /** Sets the certificate to use as our own. Must be used when representing a server, optional when client.
+ Must be called after Initialize(). */
+ void SetOwnCert(const cX509CertPtr & a_OwnCert, const cCryptoKeyPtr & a_OwnCertPrivKey);
+
+ /** Sets a cert chain as the trusted cert store for this context. Must be called after Initialize().
+ Calling this will switch the context into strict cert verification mode.
+ a_ExpectedPeerName is the CommonName that we expect the SSL peer to have in its cert,
+ if it is different, the verification will fail. An empty string will disable the CN check. */
+ void SetCACerts(const cX509CertPtr & a_CACert, const AString & a_ExpectedPeerName);
+
+ /** Writes data to be encrypted and sent to the SSL peer. Will perform SSL handshake, if needed.
+ Returns the number of bytes actually written, or PolarSSL error code.
+ If the return value is POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE, the owner should send any
+ cached outgoing data to the SSL peer and write any incoming data received from the SSL peer and then call
+ this function again with the same parameters. Note that this may repeat a few times before the data is
+ actually written, mainly due to initial handshake. */
+ int WritePlain(const void * a_Data, size_t a_NumBytes);
+
+ /** Reads data decrypted from the SSL stream. Will perform SSL handshake, if needed.
+ Returns the number of bytes actually read, or PolarSSL error code.
+ If the return value is POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE, the owner should send any
+ cached outgoing data to the SSL peer and write any incoming data received from the SSL peer and then call
+ this function again with the same parameters. Note that this may repeat a few times before the data is
+ actually read, mainly due to initial handshake. */
+ int ReadPlain(void * a_Data, size_t a_MaxBytes);
+
+ /** Performs the SSL handshake.
+ Returns zero on success, PoladSSL error code on failure.
+ If the return value is POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE, the owner should send any
+ cached outgoing data to the SSL peer and write any incoming data received from the SSL peer and then call
+ this function again. Note that this may repeat a few times before the handshake is completed. */
+ int Handshake(void);
+
+ /** Returns true if the SSL handshake has been completed. */
+ bool HasHandshaken(void) const { return m_HasHandshaken; }
+
+ /** Notifies the SSL peer that the connection is being closed.
+ Returns 0 on success, PolarSSL error code on failure. */
+ int NotifyClose(void);
+
+protected:
+ /** True if the object has been initialized properly. */
+ bool m_IsValid;
+
+ /** The random generator to use */
+ SharedPtr<cCtrDrbgContext> m_CtrDrbg;
+
+ /** The SSL context that PolarSSL uses. */
+ ssl_context m_Ssl;
+
+ /** The certificate that we present to the peer. */
+ cX509CertPtr m_OwnCert;
+
+ /** Private key for m_OwnCert, if initialized from a cRsaPrivateKey. */
+ cRsaPrivateKeyPtr m_OwnCertPrivKey;
+
+ /** Private key for m_OwnCert, if initialized from a cCryptoKey. */
+ cCryptoKeyPtr m_OwnCertPrivKey2;
+
+ /** True if the SSL handshake has been completed. */
+ bool m_HasHandshaken;
+
+ /** A copy of the trusted CA root cert store that is passed to us in SetCACerts(), so that the pointer
+ stays valid even after the call, when PolarSSL finally uses it. */
+ cX509CertPtr m_CACerts;
+
+ /** Buffer for the expected peer name. We need to buffer it because the caller may free the string they
+ give us before PolarSSL consumes the raw pointer it gets to the CN. */
+ AString m_ExpectedPeerName;
+
+
+ /** The callback used by PolarSSL when it wants to read encrypted data. */
+ static int ReceiveEncrypted(void * a_This, unsigned char * a_Buffer, size_t a_NumBytes)
+ {
+ return ((cSslContext *)a_This)->ReceiveEncrypted(a_Buffer, a_NumBytes);
+ }
+
+ /** The callback used by PolarSSL when it wants to write encrypted data. */
+ static int SendEncrypted(void * a_This, const unsigned char * a_Buffer, size_t a_NumBytes)
+ {
+ return ((cSslContext *)a_This)->SendEncrypted(a_Buffer, a_NumBytes);
+ }
+
+ #ifdef _DEBUG
+ /** The callback used by PolarSSL to output debug messages */
+ static void SSLDebugMessage(void * a_UserParam, int a_Level, const char * a_Text);
+
+ /** The callback used by PolarSSL to log information on the cert chain */
+ static int SSLVerifyCert(void * a_This, x509_crt * a_Crt, int a_Depth, int * a_Flags);
+ #endif // _DEBUG
+
+ /** Called when PolarSSL wants to read encrypted data. */
+ virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) = 0;
+
+ /** Called when PolarSSL wants to write encrypted data. */
+ virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) = 0;
+} ;
+
+
+
+
diff --git a/src/PolarSSL++/X509Cert.cpp b/src/PolarSSL++/X509Cert.cpp
new file mode 100644
index 000000000..ecf664855
--- /dev/null
+++ b/src/PolarSSL++/X509Cert.cpp
@@ -0,0 +1,38 @@
+
+// X509Cert.cpp
+
+// Implements the cX509Cert class representing a wrapper over X509 certs in PolarSSL
+
+#include "Globals.h"
+#include "X509Cert.h"
+
+
+
+
+
+cX509Cert::cX509Cert(void)
+{
+ x509_crt_init(&m_Cert);
+}
+
+
+
+
+
+cX509Cert::~cX509Cert()
+{
+ x509_crt_free(&m_Cert);
+}
+
+
+
+
+
+int cX509Cert::Parse(const void * a_CertContents, size_t a_Size)
+{
+ return x509_crt_parse(&m_Cert, (const unsigned char *)a_CertContents, a_Size);
+}
+
+
+
+
diff --git a/src/PolarSSL++/X509Cert.h b/src/PolarSSL++/X509Cert.h
new file mode 100644
index 000000000..991617d24
--- /dev/null
+++ b/src/PolarSSL++/X509Cert.h
@@ -0,0 +1,41 @@
+
+// X509Cert.h
+
+// Declares the cX509Cert class representing a wrapper over X509 certs in PolarSSL
+
+
+
+
+
+#pragma once
+
+#include "polarssl/x509_crt.h"
+
+
+
+
+
+class cX509Cert
+{
+ friend class cSslContext;
+
+public:
+ cX509Cert(void);
+ ~cX509Cert(void);
+
+ /** Parses the certificate chain data into the context.
+ Returns 0 on succes, or PolarSSL error code on failure. */
+ int Parse(const void * a_CertContents, size_t a_Size);
+
+protected:
+ x509_crt m_Cert;
+
+ /** Returns the internal cert ptr. Only use in PolarSSL API calls. */
+ x509_crt * GetInternal(void) { return &m_Cert; }
+} ;
+
+typedef SharedPtr<cX509Cert> cX509CertPtr;
+
+
+
+
diff --git a/src/ProbabDistrib.cpp b/src/ProbabDistrib.cpp
index 5fa17c276..7a5869dcc 100644
--- a/src/ProbabDistrib.cpp
+++ b/src/ProbabDistrib.cpp
@@ -118,7 +118,7 @@ int cProbabDistrib::MapValue(int a_OrigValue) const
size_t Hi = m_Cumulative.size() - 1;
while (Hi - Lo > 1)
{
- int Mid = (Lo + Hi) / 2;
+ size_t Mid = (Lo + Hi) / 2;
int MidProbab = m_Cumulative[Mid].m_Probability;
if (MidProbab < a_OrigValue)
{
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index bbc656eda..2a7cbc7bc 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -2,7 +2,6 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Authenticator.h"
-#include "../OSSupport/BlockingTCPLink.h"
#include "../Root.h"
#include "../Server.h"
#include "../ClientHandle.h"
@@ -10,16 +9,7 @@
#include "inifile/iniFile.h"
#include "json/json.h"
-#include "polarssl/config.h"
-#include "polarssl/net.h"
-#include "polarssl/ssl.h"
-#include "polarssl/entropy.h"
-#include "polarssl/ctr_drbg.h"
-#include "polarssl/error.h"
-#include "polarssl/certs.h"
-
-#include <sstream>
-#include <iomanip>
+#include "PolarSSL++/BlockingSslClientSocket.h"
@@ -28,6 +18,63 @@
#define DEFAULT_AUTH_SERVER "sessionserver.mojang.com"
#define DEFAULT_AUTH_ADDRESS "/session/minecraft/hasJoined?username=%USERNAME%&serverId=%SERVERID%"
+/** This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert:
+Downloaded from http://certs.starfieldtech.com/repository/ */
+static const AString StarfieldCACert()
+{
+ return AString(
+ // G2 cert
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n"
+ "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n"
+ "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n"
+ "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n"
+ "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n"
+ "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n"
+ "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n"
+ "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n"
+ "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n"
+ "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n"
+ "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n"
+ "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n"
+ "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n"
+ "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n"
+ "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n"
+ "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n"
+ "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n"
+ "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n"
+ "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n"
+ "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n"
+ "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n"
+ "-----END CERTIFICATE-----\n\n"
+ // Original (G1) cert:
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n"
+ "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n"
+ "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n"
+ "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n"
+ "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n"
+ "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n"
+ "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n"
+ "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n"
+ "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n"
+ "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n"
+ "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n"
+ "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n"
+ "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n"
+ "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n"
+ "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n"
+ "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n"
+ "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n"
+ "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n"
+ "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n"
+ "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n"
+ "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n"
+ "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n"
+ "-----END CERTIFICATE-----\n"
+ );
+}
+
@@ -68,7 +115,8 @@ void cAuthenticator::Authenticate(int a_ClientID, const AString & a_UserName, co
{
if (!m_ShouldAuthenticate)
{
- cRoot::Get()->AuthenticateUser(a_ClientID, a_UserName, cClientHandle::GenerateOfflineUUID(a_UserName));
+ Json::Value Value;
+ cRoot::Get()->AuthenticateUser(a_ClientID, a_UserName, cClientHandle::GenerateOfflineUUID(a_UserName), Value);
return;
}
@@ -128,10 +176,11 @@ void cAuthenticator::Execute(void)
AString NewUserName = UserName;
AString UUID;
- if (AuthWithYggdrasil(NewUserName, ServerID, UUID))
+ Json::Value Properties;
+ if (AuthWithYggdrasil(NewUserName, ServerID, UUID, Properties))
{
- LOGINFO("User %s authenticated with UUID '%s'", NewUserName.c_str(), UUID.c_str());
- cRoot::Get()->AuthenticateUser(ClientID, NewUserName, UUID);
+ LOGINFO("User %s authenticated with UUID %s", NewUserName.c_str(), UUID.c_str());
+ cRoot::Get()->AuthenticateUser(ClientID, NewUserName, UUID, Properties);
}
else
{
@@ -144,131 +193,36 @@ void cAuthenticator::Execute(void)
-bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID)
+bool cAuthenticator::SecureGetFromAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response)
{
- LOGD("Trying to auth user %s", a_UserName.c_str());
-
- int ret, server_fd = -1;
- unsigned char buf[1024];
- const char *pers = "cAuthenticator";
-
- entropy_context entropy;
- ctr_drbg_context ctr_drbg;
- ssl_context ssl;
- x509_crt cacert;
-
- /* Initialize the RNG and the session data */
- memset(&ssl, 0, sizeof(ssl_context));
- x509_crt_init(&cacert);
-
- entropy_init(&entropy);
- if ((ret = ctr_drbg_init(&ctr_drbg, entropy_func, &entropy, (const unsigned char *)pers, strlen(pers))) != 0)
- {
- LOGWARNING("cAuthenticator: ctr_drbg_init returned %d", ret);
-
- // Free all resources which have been initialized up to this line
- x509_crt_free(&cacert);
- entropy_free(&entropy);
- return false;
- }
-
- /* Initialize certificates */
- // TODO: Grab the sessionserver's root CA and any intermediates and hard-code them here, instead of test_ca_list
- ret = x509_crt_parse(&cacert, (const unsigned char *)test_ca_list, strlen(test_ca_list));
-
- if (ret < 0)
+ // Connect the socket:
+ cBlockingSslClientSocket Socket;
+ Socket.SetTrustedRootCertsFromString(a_CACerts, a_ExpectedPeerName);
+ if (!Socket.Connect(a_ExpectedPeerName, 443))
{
- LOGWARNING("cAuthenticator: x509_crt_parse returned -0x%x", -ret);
-
- // Free all resources which have been initialized up to this line
- x509_crt_free(&cacert);
- entropy_free(&entropy);
+ LOGWARNING("cAuthenticator: Can't connect to %s: %s", a_ExpectedPeerName.c_str(), Socket.GetLastErrorText().c_str());
return false;
}
- /* Connect */
- if ((ret = net_connect(&server_fd, m_Server.c_str(), 443)) != 0)
+ if (!Socket.Send(a_Data.c_str(), a_Data.size()))
{
- LOGWARNING("cAuthenticator: Can't connect to %s: %d", m_Server.c_str(), ret);
-
- // Free all resources which have been initialized up to this line
- x509_crt_free(&cacert);
- entropy_free(&entropy);
+ LOGWARNING("cAuthenticator: Writing SSL data failed: %s", Socket.GetLastErrorText().c_str());
return false;
}
- /* Setup */
- if ((ret = ssl_init(&ssl)) != 0)
- {
- LOGWARNING("cAuthenticator: ssl_init returned %d", ret);
-
- // Free all resources which have been initialized up to this line
- x509_crt_free(&cacert);
- net_close(server_fd);
- ssl_free(&ssl);
- entropy_free(&entropy);
- memset(&ssl, 0, sizeof(ssl));
- return false;
- }
- ssl_set_endpoint(&ssl, SSL_IS_CLIENT);
- ssl_set_authmode(&ssl, SSL_VERIFY_OPTIONAL);
- ssl_set_ca_chain(&ssl, &cacert, NULL, "PolarSSL Server 1");
- ssl_set_rng(&ssl, ctr_drbg_random, &ctr_drbg);
- ssl_set_bio(&ssl, net_recv, &server_fd, net_send, &server_fd);
-
- /* Handshake */
- while ((ret = ssl_handshake(&ssl)) != 0)
- {
- if ((ret != POLARSSL_ERR_NET_WANT_READ) && (ret != POLARSSL_ERR_NET_WANT_WRITE))
- {
- LOGWARNING("cAuthenticator: ssl_handshake returned -0x%x", -ret);
-
- // Free all resources which have been initialized up to this line
- x509_crt_free(&cacert);
- net_close(server_fd);
- ssl_free(&ssl);
- entropy_free(&entropy);
- memset(&ssl, 0, sizeof(ssl));
- return false;
- }
- }
-
- /* Write the GET request */
- AString ActualAddress = m_Address;
- ReplaceString(ActualAddress, "%USERNAME%", a_UserName);
- ReplaceString(ActualAddress, "%SERVERID%", a_ServerId);
-
- AString Request;
- Request += "GET " + ActualAddress + " HTTP/1.1\r\n";
- Request += "Host: " + m_Server + "\r\n";
- Request += "User-Agent: MCServer\r\n";
- Request += "Connection: close\r\n";
- Request += "\r\n";
-
- ret = ssl_write(&ssl, (const unsigned char *)Request.c_str(), Request.size());
- if (ret <= 0)
- {
- LOGWARNING("cAuthenticator: ssl_write returned %d", ret);
-
- // Free all resources which have been initialized up to this line
- x509_crt_free(&cacert);
- net_close(server_fd);
- ssl_free(&ssl);
- entropy_free(&entropy);
- memset(&ssl, 0, sizeof(ssl));
- return false;
- }
+ // Read the HTTP response:
+ int ret;
+ unsigned char buf[1024];
- /* Read the HTTP response */
- std::string Response;
for (;;)
{
- memset(buf, 0, sizeof(buf));
- ret = ssl_read(&ssl, buf, sizeof(buf));
+ ret = Socket.Receive(buf, sizeof(buf));
if ((ret == POLARSSL_ERR_NET_WANT_READ) || (ret == POLARSSL_ERR_NET_WANT_WRITE))
{
- continue;
+ // This value should never be returned, it is handled internally by cBlockingSslClientSocket
+ LOGWARNING("cAuthenticator: SSL reading failed internally");
+ return false;
}
if (ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY)
{
@@ -276,32 +230,54 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
}
if (ret < 0)
{
- LOGWARNING("cAuthenticator: ssl_read returned %d", ret);
- break;
+ LOGWARNING("cAuthenticator: SSL reading failed: -0x%x", -ret);
+ return false;
}
if (ret == 0)
{
- LOGWARNING("cAuthenticator: EOF");
break;
}
- Response.append((const char *)buf, ret);
- }
+ a_Response.append((const char *)buf, (size_t)ret);
+ }
+
+ Socket.Disconnect();
+ return true;
+}
+
+
+
+
+
+bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID, Json::Value & a_Properties)
+{
+ LOGD("Trying to authenticate user %s", a_UserName.c_str());
+
+ // Create the GET request:
+ AString ActualAddress = m_Address;
+ ReplaceString(ActualAddress, "%USERNAME%", a_UserName);
+ ReplaceString(ActualAddress, "%SERVERID%", a_ServerId);
+
+ AString Request;
+ Request += "GET " + ActualAddress + " HTTP/1.0\r\n";
+ Request += "Host: " + m_Server + "\r\n";
+ Request += "User-Agent: MCServer\r\n";
+ Request += "Connection: close\r\n";
+ Request += "\r\n";
- ssl_close_notify(&ssl);
- x509_crt_free(&cacert);
- net_close(server_fd);
- ssl_free(&ssl);
- entropy_free(&entropy);
- memset(&ssl, 0, sizeof(ssl));
+ AString Response;
+ if (!SecureGetFromAddress(StarfieldCACert(), m_Server, Request, Response))
+ {
+ return false;
+ }
// Check the HTTP status line:
- AString prefix("HTTP/1.1 200 OK");
+ const AString Prefix("HTTP/1.1 200 OK");
AString HexDump;
- if (Response.compare(0, prefix.size(), prefix))
+ if (Response.compare(0, Prefix.size(), Prefix))
{
- LOGINFO("User \"%s\" failed to auth, bad http status line received", a_UserName.c_str());
- LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
+ LOGINFO("User %s failed to auth, bad HTTP status line received", a_UserName.c_str());
+ LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
return false;
}
@@ -309,8 +285,8 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
size_t idxHeadersEnd = Response.find("\r\n\r\n");
if (idxHeadersEnd == AString::npos)
{
- LOGINFO("User \"%s\" failed to authenticate, bad http response header received", a_UserName.c_str());
- LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
+ LOGINFO("User %s failed to authenticate, bad HTTP response header received", a_UserName.c_str());
+ LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
return false;
}
Response.erase(0, idxHeadersEnd + 4);
@@ -324,12 +300,13 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
Json::Reader reader;
if (!reader.parse(Response, root, false))
{
- LOGWARNING("cAuthenticator: Cannot parse Received Data to json!");
+ LOGWARNING("cAuthenticator: Cannot parse received data (authentication) to JSON!");
return false;
}
a_UserName = root.get("name", "Unknown").asString();
a_UUID = root.get("id", "").asString();
-
+ a_Properties = root["properties"];
+
// If the UUID doesn't contain the hashes, insert them at the proper places:
if (a_UUID.size() == 32)
{
@@ -338,6 +315,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
a_UUID.insert(18, "-");
a_UUID.insert(23, "-");
}
+
return true;
}
@@ -345,3 +323,69 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
+/* In case we want to export this function to the plugin API later - don't forget to add the relevant INI configuration lines for DEFAULT_PROPERTIES_ADDRESS
+
+#define DEFAULT_PROPERTIES_ADDRESS "/session/minecraft/profile/%UUID%"
+
+// Gets the properties, such as skin, of a player based on their UUID via Mojang's API
+bool GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties);
+
+bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties)
+{
+ LOGD("Trying to get properties for user %s", a_UUID.c_str());
+
+ // Create the GET request:
+ AString ActualAddress = m_PropertiesAddress;
+ ReplaceString(ActualAddress, "%UUID%", a_UUID);
+
+ AString Request;
+ Request += "GET " + ActualAddress + " HTTP/1.0\r\n";
+ Request += "Host: " + m_Server + "\r\n";
+ Request += "User-Agent: MCServer\r\n";
+ Request += "Connection: close\r\n";
+ Request += "\r\n";
+
+ AString Response;
+ if (!ConnectSecurelyToAddress(StarfieldCACert(), m_Server, Request, Response))
+ {
+ return false;
+ }
+
+ // Check the HTTP status line:
+ const AString Prefix("HTTP/1.1 200 OK");
+ AString HexDump;
+ if (Response.compare(0, Prefix.size(), Prefix))
+ {
+ LOGINFO("Failed to get properties for user %s, bad HTTP status line received", a_UUID.c_str());
+ LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
+ return false;
+ }
+
+ // Erase the HTTP headers from the response:
+ size_t idxHeadersEnd = Response.find("\r\n\r\n");
+ if (idxHeadersEnd == AString::npos)
+ {
+ LOGINFO("Failed to get properties for user %s, bad HTTP response header received", a_UUID.c_str());
+ LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
+ return false;
+ }
+ Response.erase(0, idxHeadersEnd + 4);
+
+ // Parse the Json response:
+ if (Response.empty())
+ {
+ return false;
+ }
+
+ Json::Value root;
+ Json::Reader reader;
+ if (!reader.parse(Response, root, false))
+ {
+ LOGWARNING("cAuthenticator: Cannot parse received properties data to JSON!");
+ return false;
+ }
+
+ a_Properties = root["properties"];
+ return true;
+}
+*/
diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h
index 211f51394..244d94c0b 100644
--- a/src/Protocol/Authenticator.h
+++ b/src/Protocol/Authenticator.h
@@ -23,6 +23,11 @@
// fwd: "cRoot.h"
class cRoot;
+namespace Json
+{
+ class Value;
+}
+
@@ -73,13 +78,19 @@ private:
AString m_Server;
AString m_Address;
+ AString m_PropertiesAddress;
bool m_ShouldAuthenticate;
/** cIsThread override: */
virtual void Execute(void) override;
- /** Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep) */
- bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID);
+ /** Connects to a hostname using SSL, sends given data, and sets the response, returning whether all was successful or not */
+ bool SecureGetFromAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Request, AString & a_Response);
+
+ /** Returns true if the user authenticated okay, false on error
+ Sets the username, UUID, and properties (i.e. skin) fields
+ */
+ bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID, Json::Value & a_Properties);
};
diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt
index 849ec27ca..ae447ce54 100644
--- a/src/Protocol/CMakeLists.txt
+++ b/src/Protocol/CMakeLists.txt
@@ -4,9 +4,29 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ Authenticator.cpp
+ ChunkDataSerializer.cpp
+ Protocol125.cpp
+ Protocol132.cpp
+ Protocol14x.cpp
+ Protocol15x.cpp
+ Protocol16x.cpp
+ Protocol17x.cpp
+ ProtocolRecognizer.cpp)
-add_library(Protocol ${SOURCE})
+SET (HDRS
+ Authenticator.h
+ ChunkDataSerializer.h
+ Protocol.h
+ Protocol125.h
+ Protocol132.h
+ Protocol14x.h
+ Protocol15x.h
+ Protocol16x.h
+ Protocol17x.h
+ ProtocolRecognizer.h)
+
+if(NOT MSVC)
+ add_library(Protocol ${SRCS} ${HDRS})
+endif()
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 2fbeef0fa..d110f2af9 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -31,6 +31,7 @@ class cMonster;
class cChunkDataSerializer;
class cFallingBlock;
class cCompositeChat;
+class cStatManager;
@@ -63,7 +64,7 @@ public:
virtual void SendChat (const AString & a_Message) = 0;
virtual void SendChat (const cCompositeChat & a_Message) = 0;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) = 0;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) = 0;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) = 0;
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;
virtual void SendDisconnect (const AString & a_Reason) = 0;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; ///< Request the client to open up the sign editor for the sign (1.6+)
@@ -99,18 +100,19 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0;
- virtual void SendRespawn (void) = 0;
+ virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) = 0;
virtual void SendExperience (void) = 0;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0;
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0;
virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) = 0;
virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) = 0;
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) = 0;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0;
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) = 0;
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) = 0;
+ virtual void SendStatistics (const cStatManager & a_Manager) = 0;
virtual void SendTabCompletionResults(const AStringVector & a_Results) = 0;
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
@@ -118,25 +120,25 @@ public:
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) = 0;
virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) = 0;
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) = 0;
- virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) = 0;
+ virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
virtual void SendWeather (eWeather a_Weather) = 0;
virtual void SendWholeInventory (const cWindow & a_Window) = 0;
virtual void SendWindowClose (const cWindow & a_Window) = 0;
virtual void SendWindowOpen (const cWindow & a_Window) = 0;
- virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) = 0;
+ virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) = 0;
/// Returns the ServerID used for authentication through session.minecraft.net
virtual AString GetAuthServerID(void) = 0;
protected:
cClientHandle * m_Client;
- cCriticalSection m_CSPacket; //< Each SendXYZ() function must acquire this CS in order to send the whole packet at once
+ cCriticalSection m_CSPacket; // Each SendXYZ() function must acquire this CS in order to send the whole packet at once
/// 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;
/// Called after writing each packet, enables descendants to flush their buffers
- virtual void Flush(void) {};
+ virtual void Flush(void) {}
// Helpers for writing partial packet data, write using SendData()
void WriteByte(Byte a_Value)
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index 9502f9bec..538d31642 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -99,6 +99,7 @@ enum
PACKET_ENCHANT_ITEM = 0x6C,
PACKET_UPDATE_SIGN = 0x82,
PACKET_ITEM_DATA = 0x83,
+ PACKET_INCREMENT_STATISTIC = 0xC8,
PACKET_PLAYER_LIST_ITEM = 0xC9,
PACKET_PLAYER_ABILITIES = 0xca,
PACKET_PLUGIN_MESSAGE = 0xfa,
@@ -132,7 +133,8 @@ typedef unsigned char Byte;
cProtocol125::cProtocol125(cClientHandle * a_Client) :
super(a_Client),
- m_ReceivedData(32 KiB)
+ m_ReceivedData(32 KiB),
+ m_LastSentDimension(dimNotSet)
{
}
@@ -272,11 +274,11 @@ void cProtocol125::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize
-void cProtocol125::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cProtocol125::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
cCSLock Lock(m_CSPacket);
WriteByte(PACKET_COLLECT_PICKUP);
- WriteInt (a_Pickup.GetUniqueID());
+ WriteInt (a_Entity.GetUniqueID());
WriteInt (a_Player.GetUniqueID());
Flush();
}
@@ -396,7 +398,7 @@ void cProtocol125::SendEntityMetadata(const cEntity & a_Entity)
else
{
WriteEntityMetadata(a_Entity);
- }
+ }
WriteByte(0x7f);
Flush();
@@ -471,7 +473,7 @@ void cProtocol125::SendEntityVelocity(const cEntity & a_Entity)
cCSLock Lock(m_CSPacket);
WriteByte(PACKET_ENTITY_VELOCITY);
WriteInt (a_Entity.GetUniqueID());
- WriteShort((short) (a_Entity.GetSpeedX() * 400)); //400 = 8000 / 20
+ WriteShort((short) (a_Entity.GetSpeedX() * 400)); // 400 = 8000 / 20
WriteShort((short) (a_Entity.GetSpeedY() * 400));
WriteShort((short) (a_Entity.GetSpeedZ() * 400));
Flush();
@@ -590,6 +592,7 @@ void cProtocol125::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
WriteByte (0); // Unused
WriteByte (60); // Client list width or something
Flush();
+ m_LastSentDimension = a_World.GetDimension();
}
@@ -757,7 +760,7 @@ void cProtocol125::SendPlayerMoveLook(void)
);
*/
- WriteByte (PACKET_PLAYER_MOVE_LOOK);
+ WriteByte(PACKET_PLAYER_MOVE_LOOK);
cPlayer * Player = m_Client->GetPlayer();
WriteDouble(Player->GetPosX());
WriteDouble(Player->GetStance() + 0.03); // Add a small amount so that the player doesn't start inside a block
@@ -830,16 +833,23 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
-void cProtocol125::SendRespawn(void)
+void cProtocol125::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks)
{
cCSLock Lock(m_CSPacket);
+ if ((m_LastSentDimension == a_Dimension) && !a_ShouldIgnoreDimensionChecks)
+ {
+ // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do (unless we are respawning from death)
+ return;
+ }
cPlayer * Player = m_Client->GetPlayer();
WriteByte (PACKET_RESPAWN);
- WriteInt ((int)(Player->GetWorld()->GetDimension()));
+ WriteInt ((int)(a_Dimension));
WriteByte (2); // TODO: Difficulty; 2 = Normal
WriteChar ((char)Player->GetGameMode());
WriteShort (256); // Current world height
WriteString("default");
+ Flush();
+ m_LastSentDimension = a_Dimension;
}
@@ -889,7 +899,7 @@ void cProtocol125::SendScoreboardObjective(const AString & a_Name, const AString
-void cProtocol125::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+void cProtocol125::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
// Not needed in this protocol version
}
@@ -992,6 +1002,33 @@ void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
+void cProtocol125::SendStatistics(const cStatManager & a_Manager)
+{
+ /* NOTE:
+ Versions prior to minecraft 1.7 use an incremental statistic sync
+ method. The current setup does not allow us to implement that, because
+ of performance considerations.
+ */
+#if 0
+ for (unsigned int i = 0; i < (unsigned int)statCount; ++i)
+ {
+ StatValue Value = m_Manager->GetValue((eStatistic) i);
+
+ unsigned int StatID = cStatInfo::GetID((eStatistic) i);
+
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_INCREMENT_STATISTIC);
+ WriteInt(StatID);
+ WriteByte(Value); /* Can overflow! */
+ Flush();
+ }
+#endif
+}
+
+
+
+
+
void cProtocol125::SendTabCompletionResults(const AStringVector & a_Results)
{
// This protocol version doesn't support tab completion
@@ -1079,12 +1116,12 @@ void cProtocol125::SendUpdateSign(
-void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
+void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
{
cCSLock Lock(m_CSPacket);
WriteByte(PACKET_USE_BED);
WriteInt (a_Entity.GetUniqueID());
- WriteByte(0); // Unknown byte only 0 has been observed
+ WriteByte(0); // Unknown byte only 0 has been observed
WriteInt (a_BlockX);
WriteByte((Byte)a_BlockY);
WriteInt (a_BlockZ);
@@ -1098,7 +1135,7 @@ void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc
void cProtocol125::SendWeather(eWeather a_Weather)
{
cCSLock Lock(m_CSPacket);
- switch( a_Weather )
+ switch (a_Weather)
{
case eWeather_Sunny:
{
@@ -1175,7 +1212,7 @@ void cProtocol125::SendWindowOpen(const cWindow & a_Window)
-void cProtocol125::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
+void cProtocol125::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value)
{
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_WINDOW_PROPERTY);
@@ -1307,11 +1344,11 @@ int cProtocol125::ParseArmAnim(void)
int cProtocol125::ParseBlockDig(void)
{
- HANDLE_PACKET_READ(ReadChar, char, Status);
+ HANDLE_PACKET_READ(ReadChar, char, Status);
HANDLE_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_PACKET_READ(ReadByte, Byte, PosY);
+ HANDLE_PACKET_READ(ReadByte, Byte, PosY);
HANDLE_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_PACKET_READ(ReadChar, char, BlockFace);
+ HANDLE_PACKET_READ(ReadChar, char, BlockFace);
m_Client->HandleLeftClick(PosX, PosY, PosZ, static_cast<eBlockFace>(BlockFace), Status);
return PARSE_OK;
}
@@ -1389,11 +1426,11 @@ int cProtocol125::ParseEntityAction(void)
switch (ActionID)
{
- case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch
- case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch
- case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed
- case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting
- case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting
+ case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch
+ case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch
+ case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed
+ case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting
+ case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting
}
return PARSE_OK;
@@ -1407,7 +1444,7 @@ int cProtocol125::ParseHandshake(void)
{
HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
- AStringVector UserData = StringSplit(Username, ";"); // "FakeTruth;localhost:25565"
+ AStringVector UserData = StringSplit(Username, ";"); // "FakeTruth;localhost:25565"
if (UserData.empty())
{
m_Client->Kick("Did not receive username");
@@ -1417,9 +1454,9 @@ int cProtocol125::ParseHandshake(void)
LOGD("HANDSHAKE %s", Username.c_str());
- if (!m_Client->HandleHandshake( m_Username ))
+ if (!m_Client->HandleHandshake( m_Username))
{
- return PARSE_OK; // Player is not allowed into the server
+ return PARSE_OK; // Player is not allowed into the server
}
SendHandshake(cRoot::Get()->GetServer()->GetServerID());
@@ -1879,22 +1916,22 @@ void cProtocol125::WriteEntityMetadata(const cEntity & a_Entity)
{
WriteByte(0x51);
// No idea how Mojang makes their carts shakey shakey, so here is a complicated one-liner expression that does something similar
- WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4 );
+ WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4);
WriteByte(0x52);
- WriteInt(1); // Shaking direction, doesn't seem to affect anything
+ WriteInt(1); // Shaking direction, doesn't seem to affect anything
WriteByte(0x73);
- WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer
+ WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer
if (((cMinecart &)a_Entity).GetPayload() == cMinecart::mpFurnace)
{
WriteByte(0x10);
- WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled?
+ WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled?
}
}
else if ((a_Entity.IsProjectile() && ((cProjectileEntity &)a_Entity).GetProjectileKind() == cProjectileEntity::pkArrow))
{
WriteByte(0x10);
- WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); // Critical hitting arrow?
+ WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); // Critical hitting arrow?
}
}
@@ -1909,43 +1946,43 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
case cMonster::mtCreeper:
{
WriteByte(0x10);
- WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up?
+ WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up?
WriteByte(0x11);
- WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged?
+ WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged?
break;
}
case cMonster::mtBat:
{
WriteByte(0x10);
- WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down?
+ WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down?
break;
}
case cMonster::mtPig:
{
WriteByte(0x10);
- WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled?
+ WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled?
break;
}
case cMonster::mtVillager:
{
WriteByte(0x50);
- WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE?
+ WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE?
break;
}
case cMonster::mtZombie:
{
WriteByte(0xC);
- WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Babby zombie?
+ WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Baby zombie?
WriteByte(0xD);
- WriteByte(((const cZombie &)a_Mob).IsVillagerZombie() ? 1 : 0); // Converted zombie?
+ WriteByte(((const cZombie &)a_Mob).IsVillagerZombie() ? 1 : 0); // Converted zombie?
WriteByte(0xE);
- WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager?
+ WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager?
break;
}
case cMonster::mtGhast:
{
WriteByte(0x10);
- WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to eject un flamé-bol? :P
+ WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to spit a flameball?
break;
}
case cMonster::mtWolf:
@@ -1967,9 +2004,9 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
WriteByte(WolfStatus);
WriteByte(0x72);
- WriteFloat((float)(a_Mob.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way)
+ WriteFloat((float)(a_Mob.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way)
WriteByte(0x13);
- WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode?
+ WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode?
break;
}
case cMonster::mtSheep:
@@ -1991,30 +2028,30 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
case cMonster::mtEnderman:
{
WriteByte(0x10);
- WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house
+ WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house
WriteByte(0x11);
- WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedMeta())); // Meta of block that he stole from your house
+ WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedMeta())); // Meta of block that he stole from your house
WriteByte(0x12);
- WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face?
+ WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face?
break;
}
case cMonster::mtSkeleton:
{
WriteByte(0xD);
- WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not
+ WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not
break;
}
case cMonster::mtWitch:
{
WriteByte(0x15);
- WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything
+ WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything
break;
}
case cMonster::mtWither:
{
- WriteByte(0x54); // Int at index 20
- WriteInt((Int32)((const cWither &)a_Mob).GetNumInvulnerableTicks());
- WriteByte(0x66); // Float at index 6
+ WriteByte(0x54); // Int at index 20
+ WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks());
+ WriteByte(0x66); // Float at index 6
WriteFloat((float)(a_Mob.GetHealth()));
break;
}
@@ -2024,11 +2061,11 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
WriteByte(0x10);
if (a_Mob.GetMobType() == cMonster::mtSlime)
{
- WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
+ WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
}
else
{
- WriteByte((Byte)((const cMagmaCube &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
+ WriteByte((Byte)((const cMagmaCube &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
}
break;
}
@@ -2049,7 +2086,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
}
if (((const cHorse &)a_Mob).IsBaby())
{
- Flags |= 0x10; // IsBred flag, according to wiki.vg - don't think it does anything in multiplayer
+ Flags |= 0x10; // IsBred flag, according to wiki.vg - don't think it does anything in multiplayer
}
if (((const cHorse &)a_Mob).IsEating())
{
@@ -2067,16 +2104,16 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
WriteInt(Flags);
WriteByte(0x13);
- WriteByte((Byte)((const cHorse &)a_Mob).GetHorseType()); // Type of horse (donkey, chestnut, etc.)
+ WriteByte((Byte)((const cHorse &)a_Mob).GetHorseType()); // Type of horse (donkey, chestnut, etc.)
WriteByte(0x54);
int Appearance = 0;
- Appearance = ((const cHorse &)a_Mob).GetHorseColor(); // Mask FF
- Appearance |= ((const cHorse &)a_Mob).GetHorseStyle() * 256; // Mask FF00, so multiply by 256
- WriteInt(Appearance);
+ Appearance = ((const cHorse &)a_Mob).GetHorseColor(); // Mask FF
+ Appearance |= ((const cHorse &)a_Mob).GetHorseStyle() * 256; // Mask FF00, so multiply by 256
+ WriteInt(Appearance);
WriteByte(0x56);
- WriteInt(((const cHorse &)a_Mob).GetHorseArmour()); // Horshey armour
+ WriteInt(((const cHorse &)a_Mob).GetHorseArmour()); // Horshey armour
break;
}
default:
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index 89e64f386..18efeb079 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -36,7 +36,7 @@ public:
virtual void SendChat (const AString & a_Message) override;
virtual void SendChat (const cCompositeChat & a_Message) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDisconnect (const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
@@ -72,37 +72,39 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
- virtual void SendRespawn (void) override;
+ virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) override;
virtual void SendExperience (void) override;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
- virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override {} // This protocol doesn't support such message
- virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override {} // This protocol doesn't support such message
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
+ virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override {} // This protocol doesn't support such message
+ virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override {} // This protocol doesn't support such message
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override;
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override;
+ virtual void SendStatistics (const cStatManager & a_Manager) override;
virtual void SendTabCompletionResults(const AStringVector & a_Results) override;
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay) override;
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
- virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override {};
+ virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) 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 SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override;
+ virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void SendWeather (eWeather a_Weather) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
- virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
+ virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override;
virtual AString GetAuthServerID(void) override;
protected:
/// Results of packet-parsing:
- enum {
+ enum
+ {
PARSE_OK = 1,
PARSE_ERROR = -1,
PARSE_UNKNOWN = -2,
@@ -112,13 +114,17 @@ protected:
cByteBuffer m_ReceivedData; ///< Buffer for the received data
AString m_Username; ///< Stored in ParseHandshake(), compared to Login username
+
+ /** The dimension that was last sent to a player in a Respawn or Login packet.
+ Used to avoid Respawning into the same dimension, which confuses the client. */
+ eDimension m_LastSentDimension;
virtual void SendData(const char * a_Data, size_t a_Size) override;
/// Sends the Handshake packet
void SendHandshake(const AString & a_ConnectionHash);
- /// Parse the packet of the specified type from m_ReceivedData (switch into ParseXYZ() )
+ /// Parse the packet of the specified type from m_ReceivedData (switch into ParseXYZ())
virtual int ParsePacket(unsigned char a_PacketType);
// Specific packet parsers:
diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp
index 53d8c1561..5c58ab0ba 100644
--- a/src/Protocol/Protocol132.cpp
+++ b/src/Protocol/Protocol132.cpp
@@ -18,19 +18,7 @@
#include "../WorldStorage/FastNBT.h"
#include "../WorldStorage/EnchantmentSerializer.h"
#include "../StringCompression.h"
-
-#ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable:4127)
- #pragma warning(disable:4244)
- #pragma warning(disable:4231)
- #pragma warning(disable:4189)
- #pragma warning(disable:4702)
-#endif
-
-#ifdef _MSC_VER
- #pragma warning(pop)
-#endif
+#include "PolarSSL++/Sha1Checksum.h"
@@ -83,7 +71,7 @@ enum
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProtocol132:
cProtocol132::cProtocol132(cClientHandle * a_Client) :
@@ -200,20 +188,13 @@ void cProtocol132::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize
-void cProtocol132::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cProtocol132::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
cCSLock Lock(m_CSPacket);
WriteByte(PACKET_COLLECT_PICKUP);
- WriteInt (a_Pickup.GetUniqueID());
+ WriteInt (a_Entity.GetUniqueID());
WriteInt (a_Player.GetUniqueID());
Flush();
-
- // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
- SendSoundEffect(
- "random.pop",
- (int)(a_Pickup.GetPosX() * 8), (int)(a_Pickup.GetPosY() * 8), (int)(a_Pickup.GetPosZ() * 8),
- 0.5, (float)(0.75 + ((float)((a_Pickup.GetUniqueID() * 23) % 32)) / 64)
- );
}
@@ -265,7 +246,7 @@ void cProtocol132::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
WriteByte (0); // Unused, used to be world height
WriteByte (8); // Client list width or something
Flush();
-
+ m_LastSentDimension = a_World.GetDimension();
SendCompass(a_World);
}
@@ -297,14 +278,14 @@ void cProtocol132::SendPlayerSpawn(const cPlayer & a_Player)
-void cProtocol132::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+void cProtocol132::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_SOUND_EFFECT);
WriteString (a_SoundName);
- WriteInt (a_SrcX);
- WriteInt (a_SrcY);
- WriteInt (a_SrcZ);
+ WriteInt ((int)(a_X * 8.0));
+ WriteInt ((int)(a_Y * 8.0));
+ WriteInt ((int)(a_Z * 8.0));
WriteFloat (a_Volume);
WriteChar ((char)(a_Pitch * 63.0f));
Flush();
@@ -401,7 +382,7 @@ void cProtocol132::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
void cProtocol132::SendWholeInventory(const cWindow & a_Window)
{
- // 1.3.2 requires player inventory slots to be sent as SetSlot packets,
+ // 1.3.2 requires player inventory slots to be sent as SetSlot packets,
// otherwise it sometimes fails to update the window
// Send the entire window:
@@ -493,9 +474,9 @@ int cProtocol132::ParseHandshake(void)
HANDLE_PACKET_READ(ReadBEInt, int, ServerPort);
m_Username = Username;
- if (!m_Client->HandleHandshake( m_Username ))
+ if (!m_Client->HandleHandshake( m_Username))
{
- return PARSE_OK; // Player is not allowed into the server
+ return PARSE_OK; // Player is not allowed into the server
}
// Send a 0xfd Encryption Key Request http://wiki.vg/Protocol#0xFD
@@ -819,7 +800,7 @@ void cProtocol132::SendEncryptionKeyRequest(void)
void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const AString & a_EncNonce)
{
// Decrypt EncNonce using privkey
- cRSAPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey();
+ cRsaPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey();
Int32 DecryptedNonce[MAX_ENC_LEN / sizeof(Int32)];
int res = rsaDecryptor.Decrypt((const Byte *)a_EncNonce.data(), a_EncNonce.size(), (Byte *)DecryptedNonce, sizeof(DecryptedNonce));
@@ -876,7 +857,7 @@ void cProtocol132::StartEncryption(const Byte * a_Key)
m_IsEncrypted = true;
// Prepare the m_AuthServerID:
- cSHA1Checksum Checksum;
+ cSha1Checksum Checksum;
cServer * Server = cRoot::Get()->GetServer();
AString ServerID = Server->GetServerID();
Checksum.Update((const Byte *)ServerID.c_str(), ServerID.length());
@@ -884,7 +865,7 @@ void cProtocol132::StartEncryption(const Byte * a_Key)
Checksum.Update((const Byte *)Server->GetPublicKeyDER().data(), Server->GetPublicKeyDER().size());
Byte Digest[20];
Checksum.Finalize(Digest);
- cSHA1Checksum::DigestToJava(Digest, m_AuthServerID);
+ cSha1Checksum::DigestToJava(Digest, m_AuthServerID);
}
diff --git a/src/Protocol/Protocol132.h b/src/Protocol/Protocol132.h
index b280c8a41..1124a7253 100644
--- a/src/Protocol/Protocol132.h
+++ b/src/Protocol/Protocol132.h
@@ -24,7 +24,8 @@
#pragma warning(pop)
#endif
-#include "../Crypto.h"
+#include "PolarSSL++/AesCfb128Decryptor.h"
+#include "PolarSSL++/AesCfb128Encryptor.h"
@@ -47,12 +48,12 @@ public:
virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override;
virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendTabCompletionResults(const AStringVector & a_Results) override;
@@ -79,8 +80,8 @@ public:
protected:
bool m_IsEncrypted;
- cAESCFBDecryptor m_Decryptor;
- cAESCFBEncryptor m_Encryptor;
+ cAesCfb128Decryptor m_Decryptor;
+ cAesCfb128Encryptor m_Encryptor;
AString m_DataToSend;
diff --git a/src/Protocol/Protocol14x.cpp b/src/Protocol/Protocol14x.cpp
index f60e756fd..8b177ea48 100644
--- a/src/Protocol/Protocol14x.cpp
+++ b/src/Protocol/Protocol14x.cpp
@@ -66,7 +66,7 @@ enum
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProtocol142:
cProtocol142::cProtocol142(cClientHandle * a_Client) :
@@ -144,7 +144,7 @@ void cProtocol142::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProtocol146:
cProtocol146::cProtocol146(cClientHandle * a_Client) :
diff --git a/src/Protocol/Protocol15x.cpp b/src/Protocol/Protocol15x.cpp
index 264a596b9..2b1f01b08 100644
--- a/src/Protocol/Protocol15x.cpp
+++ b/src/Protocol/Protocol15x.cpp
@@ -47,7 +47,7 @@ enum
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProtocol150:
cProtocol150::cProtocol150(cClientHandle * a_Client) :
diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp
index 714bf5e46..0d354a030 100644
--- a/src/Protocol/Protocol16x.cpp
+++ b/src/Protocol/Protocol16x.cpp
@@ -55,7 +55,7 @@ enum
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProtocol161:
cProtocol161::cProtocol161(cClientHandle * a_Client) :
@@ -158,10 +158,10 @@ void cProtocol161::SendPlayerMaxSpeed(void)
-void cProtocol161::SendRespawn(void)
+void cProtocol161::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks)
{
// Besides sending the respawn, we need to also send the player max speed, otherwise the client reverts to super-fast
- super::SendRespawn();
+ super::SendRespawn(a_Dimension, a_ShouldIgnoreDimensionChecks);
SendPlayerMaxSpeed();
}
@@ -202,11 +202,11 @@ int cProtocol161::ParseEntityAction(void)
switch (ActionID)
{
- case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch
- case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch
- case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed
- case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting
- case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting
+ case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch
+ case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch
+ case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed
+ case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting
+ case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting
}
return PARSE_OK;
@@ -282,7 +282,7 @@ int cProtocol161::ParsePacket(unsigned char a_PacketType)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProtocol162:
cProtocol162::cProtocol162(cClientHandle * a_Client) :
diff --git a/src/Protocol/Protocol16x.h b/src/Protocol/Protocol16x.h
index 8eedce8d5..add761d1e 100644
--- a/src/Protocol/Protocol16x.h
+++ b/src/Protocol/Protocol16x.h
@@ -42,7 +42,7 @@ protected:
virtual void SendGameMode (eGameMode a_GameMode) override;
virtual void SendHealth (void) override;
virtual void SendPlayerMaxSpeed(void) override;
- virtual void SendRespawn (void) override;
+ virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual int ParseEntityAction (void) override;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 6fa928215..45d39e0e9 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -11,13 +11,19 @@ Implements the 1.7.x protocol classes:
#include "json/json.h"
#include "Protocol17x.h"
#include "ChunkDataSerializer.h"
+#include "PolarSSL++/Sha1Checksum.h"
+
#include "../ClientHandle.h"
#include "../Root.h"
#include "../Server.h"
#include "../World.h"
+#include "../StringCompression.h"
+#include "../CompositeChat.h"
+#include "../Statistics.h"
+
#include "../WorldStorage/FastNBT.h"
#include "../WorldStorage/EnchantmentSerializer.h"
-#include "../StringCompression.h"
+
#include "../Entities/ExpOrb.h"
#include "../Entities/Minecart.h"
#include "../Entities/FallingBlock.h"
@@ -25,14 +31,15 @@ Implements the 1.7.x protocol classes:
#include "../Entities/Pickup.h"
#include "../Entities/Player.h"
#include "../Entities/ItemFrame.h"
+#include "../Entities/ArrowEntity.h"
+#include "../Entities/FireworkEntity.h"
+
#include "../Mobs/IncludeAllMonsters.h"
#include "../UI/Window.h"
+
#include "../BlockEntities/CommandBlockEntity.h"
#include "../BlockEntities/MobHeadEntity.h"
#include "../BlockEntities/FlowerPotEntity.h"
-#include "../CompositeChat.h"
-#include "../Entities/ArrowEntity.h"
-#include "../Entities/FireworkEntity.h"
@@ -74,7 +81,7 @@ extern bool g_ShouldLogCommIn, g_ShouldLogCommOut;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProtocol172:
cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) :
@@ -85,7 +92,8 @@ cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAdd
m_ReceivedData(32 KiB),
m_OutPacketBuffer(64 KiB),
m_OutPacketLenBuffer(20), // 20 bytes is more than enough for one VarInt
- m_IsEncrypted(false)
+ m_IsEncrypted(false),
+ m_LastSentDimension(dimNotSet)
{
// Create the comm log file, if so requested:
if (g_ShouldLogCommIn || g_ShouldLogCommOut)
@@ -196,7 +204,7 @@ void cProtocol172::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV
Pkt.WriteInt(a_ChunkX);
Pkt.WriteInt(a_ChunkZ);
Pkt.WriteShort((short)a_Changes.size());
- Pkt.WriteInt(a_Changes.size() * 4);
+ Pkt.WriteInt((int)a_Changes.size() * 4);
for (sSetBlockVector::const_iterator itr = a_Changes.begin(), end = a_Changes.end(); itr != end; ++itr)
{
unsigned int Coords = itr->y | (itr->z << 8) | (itr->x << 12);
@@ -227,7 +235,8 @@ void cProtocol172::SendChat(const cCompositeChat & a_Message)
// Compose the complete Json string to send:
Json::Value msg;
- msg["text"] = ""; // The client crashes without this
+ cWorld * World = m_Client->GetPlayer()->GetWorld();
+ msg["text"] = cClientHandle::FormatMessageType((World == NULL) ? false : World->ShouldUseChatPrefixes(), a_Message.GetMessageType(), a_Message.GetAdditionalMessageTypeData()); // The client crashes without this field being present
const cCompositeChat::cParts & Parts = a_Message.GetParts();
for (cCompositeChat::cParts::const_iterator itr = Parts.begin(), end = Parts.end(); itr != end; ++itr)
{
@@ -282,6 +291,35 @@ void cProtocol172::SendChat(const cCompositeChat & a_Message)
AddChatPartStyle(Part, p.m_Style);
break;
}
+
+ case cCompositeChat::ptShowAchievement:
+ {
+ const cCompositeChat::cShowAchievementPart & p = (const cCompositeChat::cShowAchievementPart &)**itr;
+ Part["translate"] = "chat.type.achievement";
+
+ Json::Value Ach;
+ Ach["action"] = "show_achievement";
+ Ach["value"] = p.m_Text;
+
+ Json::Value AchColourAndName;
+ AchColourAndName["color"] = "green";
+ AchColourAndName["translate"] = p.m_Text;
+ AchColourAndName["hoverEvent"] = Ach;
+
+ Json::Value Extra;
+ Extra.append(AchColourAndName);
+
+ Json::Value Name;
+ Name["text"] = p.m_PlayerName;
+
+ Json::Value With;
+ With.append(Name);
+ With.append(Extra);
+
+ Part["with"] = With;
+ AddChatPartStyle(Part, p.m_Style);
+ break;
+ }
}
msg["extra"].append(Part);
} // for itr - Parts[]
@@ -313,12 +351,12 @@ void cProtocol172::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize
-void cProtocol172::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cProtocol172::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x0d); // Collect Item packet
- Pkt.WriteInt(a_Pickup.GetUniqueID());
+ Pkt.WriteInt(a_Entity.GetUniqueID());
Pkt.WriteInt(a_Player.GetUniqueID());
}
@@ -531,7 +569,7 @@ void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc
Pkt.WriteFloat((float)a_BlockY);
Pkt.WriteFloat((float)a_BlockZ);
Pkt.WriteFloat((float)a_Radius);
- Pkt.WriteInt(a_BlocksAffected.size());
+ Pkt.WriteInt((int)a_BlocksAffected.size());
for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(), end = a_BlocksAffected.end(); itr != end; ++itr)
{
Pkt.WriteChar((char)itr->x);
@@ -613,12 +651,13 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
cServer * Server = cRoot::Get()->GetServer();
cPacketizer Pkt(*this, 0x01); // Join Game packet
Pkt.WriteInt(a_Player.GetUniqueID());
- Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
+ Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
Pkt.WriteChar((char)a_World.GetDimension());
Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
Pkt.WriteByte(std::min(Server->GetMaxPlayers(), 60));
Pkt.WriteString("default"); // Level type - wtf?
}
+ m_LastSentDimension = a_World.GetDimension();
// Send the spawn position:
{
@@ -697,7 +736,7 @@ void cProtocol172::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decor
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt(a_ID);
- Pkt.WriteShort (1 + (3 * a_Decorators.size()));
+ Pkt.WriteShort ((short)(1 + (3 * a_Decorators.size())));
Pkt.WriteByte(1);
@@ -768,7 +807,7 @@ void cProtocol172::SendPlayerAbilities(void)
if (Player->IsGameModeCreative())
{
Flags |= 0x01;
- Flags |= 0x08; // Godmode, used for creative
+ Flags |= 0x08; // Godmode, used for creative
}
if (Player->IsFlying())
{
@@ -947,14 +986,21 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
-void cProtocol172::SendRespawn(void)
+void cProtocol172::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks)
{
+ if ((m_LastSentDimension == a_Dimension) && !a_ShouldIgnoreDimensionChecks)
+ {
+ // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do (unless we are respawning from death)
+ return;
+ }
+
cPacketizer Pkt(*this, 0x07); // Respawn packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteInt(Player->GetWorld()->GetDimension());
+ Pkt.WriteInt((int)a_Dimension);
Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
Pkt.WriteByte((Byte)Player->GetEffectiveGameMode());
Pkt.WriteString("default");
+ m_LastSentDimension = a_Dimension;
}
@@ -980,7 +1026,7 @@ void cProtocol172::SendExperienceOrb(const cExpOrb & a_ExpOrb)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, 0x11);
+ cPacketizer Pkt(*this, 0x11);
Pkt.WriteVarInt(a_ExpOrb.GetUniqueID());
Pkt.WriteInt((int) a_ExpOrb.GetPosX());
Pkt.WriteInt((int) a_ExpOrb.GetPosY());
@@ -1038,15 +1084,15 @@ void cProtocol172::SendDisplayObjective(const AString & a_Objective, cScoreboard
-void cProtocol172::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) // a_Src coords are Block * 8
+void cProtocol172::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x29); // Sound Effect packet
Pkt.WriteString(a_SoundName);
- Pkt.WriteInt(a_SrcX);
- Pkt.WriteInt(a_SrcY);
- Pkt.WriteInt(a_SrcZ);
+ Pkt.WriteInt((int)(a_X * 8.0));
+ Pkt.WriteInt((int)(a_Y * 8.0));
+ Pkt.WriteInt((int)(a_Z * 8.0));
Pkt.WriteFloat(a_Volume);
Pkt.WriteByte((Byte)(a_Pitch * 63));
}
@@ -1084,7 +1130,7 @@ void cProtocol172::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
Pkt.WriteFPInt(a_FallingBlock.GetPosZ());
Pkt.WriteByteAngle(a_FallingBlock.GetYaw());
Pkt.WriteByteAngle(a_FallingBlock.GetPitch());
- Pkt.WriteInt(((int)a_FallingBlock.GetBlockType()) | (((int)a_FallingBlock.GetBlockMeta()) << 16)); // Or 0x10
+ Pkt.WriteInt(((int)a_FallingBlock.GetBlockType()) | (((int)a_FallingBlock.GetBlockMeta()) << 16)); // Or 0x10
Pkt.WriteShort((short)(a_FallingBlock.GetSpeedX() * 400));
Pkt.WriteShort((short)(a_FallingBlock.GetSpeedY() * 400));
Pkt.WriteShort((short)(a_FallingBlock.GetSpeedZ() * 400));
@@ -1168,12 +1214,33 @@ void cProtocol172::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
+void cProtocol172::SendStatistics(const cStatManager & a_Manager)
+{
+ ASSERT(m_State == 3); // In game mode?
+
+ cPacketizer Pkt(*this, 0x37);
+ Pkt.WriteVarInt(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
+
+ for (size_t i = 0; i < (size_t)statCount; ++i)
+ {
+ StatValue Value = a_Manager.GetValue((eStatistic) i);
+ const AString & StatName = cStatInfo::GetName((eStatistic) i);
+
+ Pkt.WriteString(StatName);
+ Pkt.WriteVarInt(Value);
+ }
+}
+
+
+
+
+
void cProtocol172::SendTabCompletionResults(const AStringVector & a_Results)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet
- Pkt.WriteVarInt(a_Results.size());
+ Pkt.WriteVarInt((int)a_Results.size());
for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr)
{
@@ -1259,10 +1326,10 @@ void cProtocol172::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
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_HEAD: Action = 4; break; // Update Mobhead entity
- case E_BLOCK_FLOWER_POT: Action = 5; break; // Update flower pot
+ 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_HEAD: Action = 4; break; // Update Mobhead entity
+ case E_BLOCK_FLOWER_POT: Action = 5; break; // Update flower pot
default: ASSERT(!"Unhandled or unimplemented BlockEntity update request!"); break;
}
Pkt.WriteByte(Action);
@@ -1382,7 +1449,7 @@ void cProtocol172::SendWindowOpen(const cWindow & a_Window)
-void cProtocol172::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
+void cProtocol172::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value)
{
ASSERT(m_State == 3); // In game mode?
@@ -1520,7 +1587,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
ASSERT(!"Read wrong number of bytes!");
m_Client->PacketError(PacketType);
}
- } // for(ever)
+ } // for (ever)
// Log any leftover bytes into the logfile:
if (g_ShouldLogCommIn && (m_ReceivedData.GetReadableSpace() > 0))
@@ -1589,7 +1656,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
case 0x0c: HandlePacketSteerVehicle (a_ByteBuffer); return true;
case 0x0d: HandlePacketWindowClose (a_ByteBuffer); return true;
case 0x0e: HandlePacketWindowClick (a_ByteBuffer); return true;
- case 0x0f: // Confirm transaction - not used in MCS
+ case 0x0f: // Confirm transaction - not used in MCS
case 0x10: HandlePacketCreativeInventoryAction(a_ByteBuffer); return true;
case 0x11: HandlePacketEnchantItem (a_ByteBuffer); return true;
case 0x12: HandlePacketUpdateSign (a_ByteBuffer); return true;
@@ -1645,16 +1712,16 @@ void cProtocol172::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer)
void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
{
// Send the response:
- AString Response = "{\"version\":{\"name\":\"1.7.2\",\"protocol\":4},\"players\":{";
+ AString Response = "{\"version\":{\"name\":\"1.7.2\", \"protocol\":4}, \"players\":{";
cServer * Server = cRoot::Get()->GetServer();
- AppendPrintf(Response, "\"max\":%u,\"online\":%u,\"sample\":[]},",
+ AppendPrintf(Response, "\"max\":%u, \"online\":%u, \"sample\":[]},",
Server->GetMaxPlayers(),
Server->GetNumPlayers()
);
AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},",
Server->GetDescription().c_str()
);
- AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"",
+ AppendPrintf(Response, "\"favicon\": \"data:image/png;base64,%s\"",
Server->GetFaviconData().c_str()
);
Response.append("}");
@@ -1690,7 +1757,7 @@ void cProtocol172::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe
}
// Decrypt EncNonce using privkey
- cRSAPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey();
+ cRsaPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey();
Int32 DecryptedNonce[MAX_ENC_LEN / sizeof(Int32)];
int res = rsaDecryptor.Decrypt((const Byte *)EncNonce.data(), EncNonce.size(), (Byte *)DecryptedNonce, sizeof(DecryptedNonce));
if (res != 4)
@@ -1742,7 +1809,7 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
cPacketizer Pkt(*this, 0x01);
Pkt.WriteString(Server->GetServerID());
const AString & PubKeyDer = Server->GetPublicKeyDER();
- Pkt.WriteShort(PubKeyDer.size());
+ Pkt.WriteShort((short)PubKeyDer.size());
Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size());
Pkt.WriteShort(4);
Pkt.WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
@@ -1842,13 +1909,15 @@ void cProtocol172::HandlePacketClientStatus(cByteBuffer & a_ByteBuffer)
case 1:
{
// Request stats
- // TODO
+ const cStatManager & Manager = m_Client->GetPlayer()->GetStatManager();
+ SendStatistics(Manager);
+
break;
}
case 2:
{
// Open Inventory achievement
- // TODO
+ m_Client->GetPlayer()->AwardAchievement(achOpenInv);
break;
}
}
@@ -1881,11 +1950,11 @@ void cProtocol172::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer)
switch (Action)
{
- case 1: m_Client->HandleEntityCrouch(PlayerID, true); break; // Crouch
- case 2: m_Client->HandleEntityCrouch(PlayerID, false); break; // Uncrouch
- case 3: m_Client->HandleEntityLeaveBed(PlayerID); break; // Leave Bed
- case 4: m_Client->HandleEntitySprinting(PlayerID, true); break; // Start sprinting
- case 5: m_Client->HandleEntitySprinting(PlayerID, false); break; // Stop sprinting
+ case 1: m_Client->HandleEntityCrouch(PlayerID, true); break; // Crouch
+ case 2: m_Client->HandleEntityCrouch(PlayerID, false); break; // Uncrouch
+ case 3: m_Client->HandleEntityLeaveBed(PlayerID); break; // Leave Bed
+ case 4: m_Client->HandleEntitySprinting(PlayerID, true); break; // Start sprinting
+ case 5: m_Client->HandleEntitySprinting(PlayerID, false); break; // Stop sprinting
}
}
@@ -2137,7 +2206,7 @@ void cProtocol172::WritePacket(cByteBuffer & a_Packet)
cCSLock Lock(m_CSPacket);
AString Pkt;
a_Packet.ReadAll(Pkt);
- WriteVarInt(Pkt.size());
+ WriteVarInt((UInt32)Pkt.size());
SendData(Pkt.data(), Pkt.size());
Flush();
}
@@ -2242,7 +2311,7 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
{
case TAG_List:
{
- if ((TagName == "ench") || (TagName == "StoredEnchantments")) // Enchantments tags
+ if ((TagName == "ench") || (TagName == "StoredEnchantments")) // Enchantments tags
{
EnchantmentSerializer::ParseFromNBT(a_Item.m_Enchantments, NBT, tag);
}
@@ -2250,21 +2319,21 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
}
case TAG_Compound:
{
- if (TagName == "display") // Custom name and lore tag
+ if (TagName == "display") // Custom name and lore tag
{
for (int displaytag = NBT.GetFirstChild(tag); displaytag >= 0; displaytag = NBT.GetNextSibling(displaytag))
{
- if ((NBT.GetType(displaytag) == TAG_String) && (NBT.GetName(displaytag) == "Name")) // Custon name tag
+ if ((NBT.GetType(displaytag) == TAG_String) && (NBT.GetName(displaytag) == "Name")) // Custon name tag
{
a_Item.m_CustomName = NBT.GetString(displaytag);
}
- else if ((NBT.GetType(displaytag) == TAG_List) && (NBT.GetName(displaytag) == "Lore")) // Lore tag
+ else if ((NBT.GetType(displaytag) == TAG_List) && (NBT.GetName(displaytag) == "Lore")) // Lore tag
{
AString Lore;
- for (int loretag = NBT.GetFirstChild(displaytag); loretag >= 0; loretag = NBT.GetNextSibling(loretag)) // Loop through array of strings
+ for (int loretag = NBT.GetFirstChild(displaytag); loretag >= 0; loretag = NBT.GetNextSibling(loretag)) // Loop through array of strings
{
- AppendPrintf(Lore, "%s`", NBT.GetString(loretag).c_str()); // Append the lore with a newline, used internally by MCS to display a new line in the client; don't forget to c_str ;)
+ AppendPrintf(Lore, "%s`", NBT.GetString(loretag).c_str()); // Append the lore with a grave accent/backtick, used internally by MCS to display a new line in the client; don't forget to c_str ;)
}
a_Item.m_Lore = Lore;
@@ -2277,6 +2346,13 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
}
break;
}
+ case TAG_Int:
+ {
+ if (TagName == "RepairCost")
+ {
+ a_Item.m_RepairCost = NBT.GetInt(tag);
+ }
+ }
default: LOGD("Unimplemented NBT data when parsing!"); break;
}
}
@@ -2293,7 +2369,7 @@ void cProtocol172::StartEncryption(const Byte * a_Key)
m_IsEncrypted = true;
// Prepare the m_AuthServerID:
- cSHA1Checksum Checksum;
+ cSha1Checksum Checksum;
cServer * Server = cRoot::Get()->GetServer();
const AString & ServerID = Server->GetServerID();
Checksum.Update((const Byte *)ServerID.c_str(), ServerID.length());
@@ -2301,7 +2377,7 @@ void cProtocol172::StartEncryption(const Byte * a_Key)
Checksum.Update((const Byte *)Server->GetPublicKeyDER().data(), Server->GetPublicKeyDER().size());
Byte Digest[20];
Checksum.Finalize(Digest);
- cSHA1Checksum::DigestToJava(Digest, m_AuthServerID);
+ cSha1Checksum::DigestToJava(Digest, m_AuthServerID);
}
@@ -2387,7 +2463,7 @@ void cProtocol172::AddChatPartStyle(Json::Value & a_Value, const AString & a_Par
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProtocol172::cPacketizer:
cProtocol172::cPacketizer::~cPacketizer()
@@ -2395,7 +2471,7 @@ cProtocol172::cPacketizer::~cPacketizer()
AString DataToSend;
// Send the packet length
- UInt32 PacketLen = m_Out.GetUsedSpace();
+ UInt32 PacketLen = (UInt32)m_Out.GetUsedSpace();
m_Protocol.m_OutPacketLenBuffer.WriteVarInt(PacketLen);
m_Protocol.m_OutPacketLenBuffer.ReadAll(DataToSend);
m_Protocol.SendData(DataToSend.data(), DataToSend.size());
@@ -2450,10 +2526,14 @@ void cProtocol172::cPacketizer::WriteItem(const cItem & a_Item)
// Send the enchantments and custom names:
cFastNBTWriter Writer;
+ if (a_Item.m_RepairCost != 0)
+ {
+ Writer.AddInt("RepairCost", a_Item.m_RepairCost);
+ }
if (!a_Item.m_Enchantments.IsEmpty())
{
const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
- EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments,Writer, TagName);
+ EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName);
}
if (!a_Item.IsBothNameAndLoreEmpty())
{
@@ -2488,7 +2568,7 @@ void cProtocol172::cPacketizer::WriteItem(const cItem & a_Item)
Writer.Finish();
AString Compressed;
CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed);
- WriteShort(Compressed.size());
+ WriteShort((short)Compressed.size());
WriteBuf(Compressed.data(), Compressed.size());
}
@@ -2505,7 +2585,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt
{
cCommandBlockEntity & CommandBlockEntity = (cCommandBlockEntity &)a_BlockEntity;
- Writer.AddByte("TrackOutput", 1); // Neither I nor the MC wiki has any idea about this
+ Writer.AddByte("TrackOutput", 1); // Neither I nor the MC wiki has any idea about this
Writer.AddInt("SuccessCount", CommandBlockEntity.GetResult());
Writer.AddInt("x", CommandBlockEntity.GetPosX());
Writer.AddInt("y", CommandBlockEntity.GetPosY());
@@ -2515,7 +2595,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt
// For a command block, this would be the 'name' prepended to anything it outputs into global chat
// MCS doesn't have this, so just leave it @ '@'. (geddit?)
Writer.AddString("CustomName", "@");
- Writer.AddString("id", "Control"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
+ Writer.AddString("id", "Control"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
if (!CommandBlockEntity.GetLastOutput().empty())
{
@@ -2536,7 +2616,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt
Writer.AddByte("SkullType", MobHeadEntity.GetType() & 0xFF);
Writer.AddByte("Rot", MobHeadEntity.GetRotation() & 0xFF);
Writer.AddString("ExtraType", MobHeadEntity.GetOwner().c_str());
- Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
+ Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
break;
}
case E_BLOCK_FLOWER_POT:
@@ -2548,7 +2628,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt
Writer.AddInt("z", FlowerPotEntity.GetPosZ());
Writer.AddInt("Item", (Int32) FlowerPotEntity.GetItem().m_ItemType);
Writer.AddInt("Data", (Int32) FlowerPotEntity.GetItem().m_ItemDamage);
- Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
+ Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
break;
}
default: break;
@@ -2558,7 +2638,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt
AString Compressed;
CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed);
- WriteShort(Compressed.size());
+ WriteShort((short)Compressed.size());
WriteBuf(Compressed.data(), Compressed.size());
}
@@ -2627,15 +2707,16 @@ void cProtocol172::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity)
// The following expression makes Minecarts shake more with less health or higher damage taken
// It gets half the maximum health, and takes it away from the current health minus the half health:
- /* Health: 5 | 3 - (5 - 3) = 1 (shake power)
- Health: 3 | 3 - (3 - 3) = 3
- Health: 1 | 3 - (1 - 3) = 5
+ /*
+ Health: 5 | 3 - (5 - 3) = 1 (shake power)
+ Health: 3 | 3 - (3 - 3) = 3
+ Health: 1 | 3 - (1 - 3) = 5
*/
WriteInt((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4);
WriteByte(0x52);
- WriteInt(1); // Shaking direction, doesn't seem to affect anything
+ WriteInt(1); // Shaking direction, doesn't seem to affect anything
WriteByte(0x73);
- WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer
+ WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer
if (((cMinecart &)a_Entity).GetPayload() == cMinecart::mpNone)
{
@@ -2823,9 +2904,9 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
case cMonster::mtWither:
{
- WriteByte(0x54); // Int at index 20
- WriteInt(((const cWither &)a_Mob).GetNumInvulnerableTicks());
- WriteByte(0x66); // Float at index 6
+ WriteByte(0x54); // Int at index 20
+ WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks());
+ WriteByte(0x66); // Float at index 6
WriteFloat((float)(a_Mob.GetHealth()));
break;
}
@@ -2905,7 +2986,7 @@ void cProtocol172::cPacketizer::WriteEntityProperties(const cEntity & a_Entity)
return;
}
- //const cMonster & Mob = (const cMonster &)a_Entity;
+ // const cMonster & Mob = (const cMonster &)a_Entity;
// TODO: Send properties and modifiers based on the mob type
@@ -2916,7 +2997,7 @@ void cProtocol172::cPacketizer::WriteEntityProperties(const cEntity & a_Entity)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cProtocol176:
cProtocol176::cProtocol176(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) :
@@ -2935,7 +3016,18 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
Pkt.WriteVarInt(a_Player.GetUniqueID());
Pkt.WriteString(a_Player.GetClientHandle()->GetUUID());
Pkt.WriteString(a_Player.GetName());
- Pkt.WriteVarInt(0); // We have no data to send here
+
+ const Json::Value & Properties = m_Client->GetProperties();
+ const Json::Value::const_iterator End = Properties.end();
+ Pkt.WriteVarInt(Properties.size());
+
+ for (Json::Value::iterator itr = Properties.begin(); itr != End; ++itr)
+ {
+ Pkt.WriteString(((Json::Value)*itr).get("name", "").toStyledString());
+ Pkt.WriteString(((Json::Value)*itr).get("value", "").toStyledString());
+ Pkt.WriteString(((Json::Value)*itr).get("signature", "").toStyledString());
+ }
+
Pkt.WriteFPInt(a_Player.GetPosX());
Pkt.WriteFPInt(a_Player.GetPosY());
Pkt.WriteFPInt(a_Player.GetPosZ());
@@ -2955,15 +3047,15 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
void cProtocol176::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
{
// Send the response:
- AString Response = "{\"version\":{\"name\":\"1.7.6\",\"protocol\":5},\"players\":{";
- AppendPrintf(Response, "\"max\":%u,\"online\":%u,\"sample\":[]},",
+ AString Response = "{\"version\": {\"name\": \"1.7.6\", \"protocol\":5}, \"players\": {";
+ AppendPrintf(Response, "\"max\": %u, \"online\": %u, \"sample\": []},",
cRoot::Get()->GetServer()->GetMaxPlayers(),
cRoot::Get()->GetServer()->GetNumPlayers()
);
- AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},",
+ AppendPrintf(Response, "\"description\": {\"text\": \"%s\"},",
cRoot::Get()->GetServer()->GetDescription().c_str()
);
- AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"",
+ AppendPrintf(Response, "\"favicon\": \"data:image/png;base64,%s\"",
cRoot::Get()->GetServer()->GetFaviconData().c_str()
);
Response.append("}");
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 6a3e81eff..9c9f563e0 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -30,7 +30,8 @@ Declares the 1.7.x protocol classes:
#pragma warning(pop)
#endif
-#include "../Crypto.h"
+#include "PolarSSL++/AesCfb128Decryptor.h"
+#include "PolarSSL++/AesCfb128Encryptor.h"
@@ -67,7 +68,7 @@ public:
virtual void SendChat (const AString & a_Message) override;
virtual void SendChat (const cCompositeChat & a_Message) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDisconnect (const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
@@ -103,8 +104,8 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
- virtual void SendRespawn (void) override;
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
+ virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) override;
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
virtual void SendExperience (void) override;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
@@ -115,6 +116,7 @@ public:
virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override;
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override;
+ virtual void SendStatistics (const cStatManager & a_Manager) override;
virtual void SendTabCompletionResults(const AStringVector & a_Results) override;
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
@@ -122,12 +124,12 @@ public:
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) 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 SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override;
+ virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void SendWeather (eWeather a_Weather) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
- virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
+ virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override;
virtual AString GetAuthServerID(void) override { return m_AuthServerID; }
@@ -236,12 +238,16 @@ protected:
bool m_IsEncrypted;
- cAESCFBDecryptor m_Decryptor;
- cAESCFBEncryptor m_Encryptor;
+ cAesCfb128Decryptor m_Decryptor;
+ cAesCfb128Encryptor m_Encryptor;
/** The logfile where the comm is logged, when g_ShouldLogComm is true */
cFile m_CommLogFile;
+ /** The dimension that was last sent to a player in a Respawn or Login packet.
+ Used to avoid Respawning into the same dimension, which confuses the client. */
+ eDimension m_LastSentDimension;
+
/** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */
void AddReceivedData(const char * a_Data, size_t a_Size);
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index 2ccb9f197..a7fb7bcc2 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -1,7 +1,7 @@
// ProtocolRecognizer.cpp
-// Implements the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple
+// Implements the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple
// protocol versions and redirects everything to them
#include "Globals.h"
@@ -37,6 +37,7 @@ cProtocolRecognizer::cProtocolRecognizer(cClientHandle * a_Client) :
cProtocolRecognizer::~cProtocolRecognizer()
{
delete m_Protocol;
+ m_Protocol = NULL;
}
@@ -180,10 +181,10 @@ void cProtocolRecognizer::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSe
-void cProtocolRecognizer::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cProtocolRecognizer::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendCollectPickup(a_Pickup, a_Player);
+ m_Protocol->SendCollectEntity(a_Entity, a_Player);
}
@@ -330,7 +331,7 @@ void cProtocolRecognizer::SendEntityVelocity(const cEntity & a_Entity)
void cProtocolRecognizer::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendExplosion(a_BlockX,a_BlockY,a_BlockZ,a_Radius, a_BlocksAffected, a_PlayerMotion);
+ m_Protocol->SendExplosion(a_BlockX, a_BlockY, a_BlockZ, a_Radius, a_BlocksAffected, a_PlayerMotion);
}
@@ -357,7 +358,7 @@ void cProtocolRecognizer::SendHealth(void)
-void cProtocolRecognizer::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
+void cProtocolRecognizer::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value)
{
ASSERT(m_Protocol != NULL);
m_Protocol->SendWindowProperty(a_Window, a_Property, a_Value);
@@ -555,10 +556,10 @@ void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a
-void cProtocolRecognizer::SendRespawn(void)
+void cProtocolRecognizer::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendRespawn();
+ m_Protocol->SendRespawn(a_Dimension, a_ShouldIgnoreDimensionChecks);
}
@@ -615,10 +616,10 @@ void cProtocolRecognizer::SendDisplayObjective(const AString & a_Objective, cSco
-void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
+ m_Protocol->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch);
}
@@ -675,6 +676,16 @@ void cProtocolRecognizer::SendSpawnVehicle(const cEntity & a_Vehicle, char a_Veh
+void cProtocolRecognizer::SendStatistics(const cStatManager & a_Manager)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendStatistics(a_Manager);
+}
+
+
+
+
+
void cProtocolRecognizer::SendTabCompletionResults(const AStringVector & a_Results)
{
ASSERT(m_Protocol != NULL);
@@ -745,7 +756,7 @@ void cProtocolRecognizer::SendUpdateSign(int a_BlockX, int a_BlockY, int a_Block
-void cProtocolRecognizer::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
+void cProtocolRecognizer::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
{
ASSERT(m_Protocol != NULL);
m_Protocol->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
@@ -817,7 +828,7 @@ void cProtocolRecognizer::SendData(const char * a_Data, size_t a_Size)
bool cProtocolRecognizer::TryRecognizeProtocol(void)
{
- // NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and
+ // NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and
// MCS_PROTOCOL_VERSIONS macros in the header file, as well as PROTO_VERSION_LATEST macro
// The first packet should be a Handshake, 0x02:
@@ -871,7 +882,7 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void)
// Not enough bytes for the packet length, keep waiting
return false;
}
- ReadSoFar -= m_Buffer.GetReadableSpace();
+ ReadSoFar -= (UInt32)m_Buffer.GetReadableSpace();
if (!m_Buffer.CanReadBytes(PacketLen))
{
// Not enough bytes for the packet, keep waiting
@@ -942,7 +953,6 @@ bool cProtocolRecognizer::TryRecognizeLengthlessProtocol(void)
bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRemaining)
{
UInt32 PacketType;
- UInt32 NumBytesRead = (UInt32)m_Buffer.GetReadableSpace();
if (!m_Buffer.ReadVarInt(PacketType))
{
return false;
@@ -961,7 +971,6 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema
{
return false;
}
- NumBytesRead -= m_Buffer.GetReadableSpace();
switch (ProtocolVersion)
{
case PROTO_VERSION_1_7_2:
@@ -1010,11 +1019,11 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
case PROTO_VERSION_1_3_2:
{
// http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29
- Printf(Reply, "%s%s%i%s%i",
+ Printf(Reply, "%s%s%i%s%i",
Server->GetDescription().c_str(),
- cChatColor::Delimiter.c_str(),
+ cChatColor::Delimiter,
Server->GetNumPlayers(),
- cChatColor::Delimiter.c_str(),
+ cChatColor::Delimiter,
Server->GetMaxPlayers()
);
break;
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 408109ef4..65829ef73 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -1,7 +1,7 @@
// ProtocolRecognizer.h
-// Interfaces to the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple
+// Interfaces to the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple
// protocol versions and redirects everything to them
@@ -71,7 +71,7 @@ public:
virtual void SendChat (const AString & a_Message) override;
virtual void SendChat (const cCompositeChat & a_Message) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDisconnect (const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
@@ -107,18 +107,19 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
- virtual void SendRespawn (void) override;
+ virtual void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) override;
virtual void SendExperience (void) override;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override;
virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override;
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override;
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override;
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override;
+ virtual void SendStatistics (const cStatManager & a_Manager) override;
virtual void SendTabCompletionResults(const AStringVector & a_Results) override;
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
@@ -126,20 +127,20 @@ public:
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) 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 SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override;
+ virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void SendWeather (eWeather a_Weather) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
- virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
+ virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override;
virtual AString GetAuthServerID(void) override;
virtual void SendData(const char * a_Data, size_t a_Size) override;
protected:
- cProtocol * m_Protocol; //< The recognized protocol
- cByteBuffer m_Buffer; //< Buffer for the incoming data until we recognize the protocol
+ cProtocol * m_Protocol; ///< The recognized protocol
+ cByteBuffer m_Buffer; ///< Buffer for the incoming data until we recognize the protocol
/// Tries to recognize protocol based on m_Buffer contents; returns true if recognized
bool TryRecognizeProtocol(void);
diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp
index d7083ff2b..141c67d1b 100644
--- a/src/RCONServer.cpp
+++ b/src/RCONServer.cpp
@@ -38,7 +38,7 @@ enum
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cRCONCommandOutput:
class cRCONCommandOutput :
@@ -59,7 +59,7 @@ public:
virtual void Finished(void) override
{
- m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, m_Buffer.size(), m_Buffer.c_str());
+ m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, (int)m_Buffer.size(), m_Buffer.c_str());
delete this;
}
@@ -73,13 +73,13 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cRCONServer:
cRCONServer::cRCONServer(cServer & a_Server) :
m_Server(a_Server),
- m_ListenThread4(*this, cSocket::IPv4, "RCON IPv4"),
- m_ListenThread6(*this, cSocket::IPv6, "RCON IPv6")
+ m_ListenThread4(*this, cSocket::IPv4, "RCON"),
+ m_ListenThread6(*this, cSocket::IPv6, "RCON")
{
}
@@ -154,7 +154,7 @@ void cRCONServer::OnConnectionAccepted(cSocket & a_Socket)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cRCONServer::cConnection:
cRCONServer::cConnection::cConnection(cRCONServer & a_RCONServer, cSocket & a_Socket) :
@@ -169,7 +169,7 @@ cRCONServer::cConnection::cConnection(cRCONServer & a_RCONServer, cSocket & a_So
-void cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size)
+bool cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size)
{
// Append data to the buffer:
m_Buffer.append(a_Data, a_Size);
@@ -187,12 +187,12 @@ void cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size)
m_RCONServer.m_SocketThreads.RemoveClient(this);
m_Socket.CloseSocket();
delete this;
- return;
+ return false;
}
if (Length > (int)(m_Buffer.size() + 4))
{
// Incomplete packet yet, wait for more data to come
- return;
+ return false;
}
int RequestID = IntFromBuffer(m_Buffer.data() + 4);
@@ -202,10 +202,11 @@ void cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size)
m_RCONServer.m_SocketThreads.RemoveClient(this);
m_Socket.CloseSocket();
delete this;
- return;
+ return false;
}
m_Buffer.erase(0, Length + 4);
} // while (m_Buffer.size() >= 14)
+ return false;
}
diff --git a/src/RCONServer.h b/src/RCONServer.h
index b964852ab..47c746736 100644
--- a/src/RCONServer.h
+++ b/src/RCONServer.h
@@ -65,7 +65,7 @@ protected:
// cSocketThreads::cCallback overrides:
- virtual void DataReceived(const char * a_Data, size_t a_Size) override;
+ virtual bool DataReceived(const char * a_Data, size_t a_Size) override;
virtual void GetOutgoingData(AString & a_Data) override;
virtual void SocketClosed(void) override;
diff --git a/src/Root.cpp b/src/Root.cpp
index 5d32bdd87..b65e9b067 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -30,8 +30,6 @@
#include <mach/mach.h>
#endif
-extern bool g_TERMINATE_EVENT_RAISED;
-
@@ -79,17 +77,17 @@ void cRoot::InputThread(void * a_Params)
cLogCommandOutputCallback Output;
- while (!self.m_bStop && !self.m_bRestart && !g_TERMINATE_EVENT_RAISED && std::cin.good())
+ while (!self.m_bStop && !self.m_bRestart && !m_TerminateEventRaised && std::cin.good())
{
AString Command;
std::getline(std::cin, Command);
if (!Command.empty())
- {
+ {
self.ExecuteConsoleCommand(TrimString(Command), Output);
}
}
- if (g_TERMINATE_EVENT_RAISED || !std::cin.good())
+ if (m_TerminateEventRaised || !std::cin.good())
{
// We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running; stop the server:
self.m_bStop = true;
@@ -105,7 +103,7 @@ void cRoot::Start(void)
#ifdef _WIN32
HWND hwnd = GetConsoleWindow();
HMENU hmenu = GetSystemMenu(hwnd, FALSE);
- EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling
+ EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling
#endif
cDeadlockDetect dd;
@@ -193,8 +191,8 @@ void cRoot::Start(void)
#if !defined(ANDROID_NDK)
LOGD("Starting InputThread...");
- m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" );
- m_InputThread->Start( false ); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread
+ m_InputThread = new cThread( InputThread, this, "cRoot::InputThread");
+ m_InputThread->Start( false); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread
#endif
long long finishmseconds = Time.GetNowTime();
@@ -202,15 +200,15 @@ void cRoot::Start(void)
LOG("Startup complete, took %lld ms!", finishmseconds);
#ifdef _WIN32
- EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button
+ EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button
#endif
- while (!m_bStop && !m_bRestart && !g_TERMINATE_EVENT_RAISED) // These are modified by external threads
+ while (!m_bStop && !m_bRestart && !m_TerminateEventRaised) // These are modified by external threads
{
cSleep::MilliSleep(1000);
}
- if (g_TERMINATE_EVENT_RAISED)
+ if (m_TerminateEventRaised)
{
m_bStop = true;
}
@@ -271,12 +269,12 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
{
// First get the default world
AString DefaultWorldName = IniFile.GetValueSet("Worlds", "DefaultWorld", "world");
- m_pDefaultWorld = new cWorld( DefaultWorldName.c_str() );
+ m_pDefaultWorld = new cWorld( DefaultWorldName.c_str());
m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
// Then load the other worlds
unsigned int KeyNum = IniFile.FindKey("Worlds");
- unsigned int NumWorlds = IniFile.GetNumValues( KeyNum );
+ unsigned int NumWorlds = IniFile.GetNumValues( KeyNum);
if (NumWorlds <= 0)
{
return;
@@ -285,18 +283,18 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
bool FoundAdditionalWorlds = false;
for (unsigned int i = 0; i < NumWorlds; i++)
{
- AString ValueName = IniFile.GetValueName(KeyNum, i );
+ AString ValueName = IniFile.GetValueName(KeyNum, i);
if (ValueName.compare("World") != 0)
{
continue;
}
- AString WorldName = IniFile.GetValue(KeyNum, i );
+ AString WorldName = IniFile.GetValue(KeyNum, i);
if (WorldName.empty())
{
continue;
}
FoundAdditionalWorlds = true;
- cWorld* NewWorld = new cWorld( WorldName.c_str() );
+ cWorld* NewWorld = new cWorld( WorldName.c_str());
m_WorldsByName[ WorldName ] = NewWorld;
} // for i - Worlds
@@ -314,13 +312,15 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
-cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName)
+cWorld * cRoot::CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName)
{
- if (m_WorldsByName[a_WorldName] != NULL)
+ cWorld * World = m_WorldsByName[a_WorldName];
+ if (World != NULL)
{
- return NULL;
+ return World;
}
- cWorld* NewWorld = new cWorld(a_WorldName.c_str());
+
+ cWorld * NewWorld = new cWorld(a_WorldName.c_str(), a_Dimension, a_OverworldName);
m_WorldsByName[a_WorldName] = NewWorld;
NewWorld->Start();
NewWorld->InitializeSpawn();
@@ -361,7 +361,7 @@ void cRoot::StopWorlds(void)
void cRoot::UnloadWorlds(void)
{
m_pDefaultWorld = NULL;
- for( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr )
+ for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr)
{
delete itr->second;
}
@@ -372,7 +372,7 @@ void cRoot::UnloadWorlds(void)
-cWorld* cRoot::GetDefaultWorld()
+cWorld * cRoot::GetDefaultWorld()
{
return m_pDefaultWorld;
}
@@ -381,12 +381,19 @@ cWorld* cRoot::GetDefaultWorld()
-cWorld* cRoot::GetWorld( const AString & a_WorldName )
+cWorld * cRoot::GetWorld(const AString & a_WorldName, bool a_SearchForFolder)
{
- WorldMap::iterator itr = m_WorldsByName.find( a_WorldName );
- if( itr != m_WorldsByName.end() )
+ WorldMap::iterator itr = m_WorldsByName.find(a_WorldName);
+ if (itr != m_WorldsByName.end())
+ {
return itr->second;
- return 0;
+ }
+
+ if (a_SearchForFolder && cFile::IsFolder(FILE_IO_PREFIX + a_WorldName))
+ {
+ return CreateAndInitializeWorld(a_WorldName);
+ }
+ return NULL;
}
@@ -398,9 +405,12 @@ bool cRoot::ForEachWorld(cWorldListCallback & a_Callback)
for (WorldMap::iterator itr = m_WorldsByName.begin(), itr2 = itr; itr != m_WorldsByName.end(); itr = itr2)
{
++itr2;
- if (a_Callback.Item(itr->second))
+ if (itr->second != NULL)
{
- return false;
+ if (a_Callback.Item(itr->second))
+ {
+ return false;
+ }
}
}
return true;
@@ -499,9 +509,9 @@ void cRoot::KickUser(int a_ClientID, const AString & a_Reason)
-void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID)
+void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties)
{
- m_Server->AuthenticateUser(a_ClientID, a_Name, a_UUID);
+ m_Server->AuthenticateUser(a_ClientID, a_Name, a_UUID, a_Properties);
}
@@ -511,7 +521,7 @@ void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AStri
int cRoot::GetTotalChunkCount(void)
{
int res = 0;
- for ( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr )
+ for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr)
{
res += itr->second->GetNumChunks();
}
@@ -590,13 +600,13 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
{
class cCallback : public cPlayerListCallback
{
- unsigned m_BestRating;
- unsigned m_NameLength;
+ size_t m_BestRating;
+ size_t m_NameLength;
const AString m_PlayerName;
virtual bool Item (cPlayer * a_pPlayer)
{
- unsigned int Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName());
+ size_t Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName());
if ((Rating > 0) && (Rating >= m_BestRating))
{
m_BestMatch = a_pPlayer;
@@ -607,7 +617,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
m_BestRating = Rating;
++m_NumMatches;
}
- if (Rating == m_NameLength) // Perfect match
+ if (Rating == m_NameLength) // Perfect match
{
return true;
}
@@ -626,7 +636,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
cPlayer * m_BestMatch;
unsigned m_NumMatches;
} Callback (a_PlayerName);
- ForEachPlayer( Callback );
+ ForEachPlayer(Callback);
if (Callback.m_NumMatches == 1)
{
@@ -687,7 +697,7 @@ int cRoot::GetVirtualRAMUsage(void)
&t_info_count
))
{
- return (int)(t_info.virtual_size / 1024);
+ return (int)(t_info.virtual_size / 1024);
}
return -1;
#else
@@ -739,7 +749,7 @@ int cRoot::GetPhysicalRAMUsage(void)
&t_info_count
))
{
- return (int)(t_info.resident_size / 1024);
+ return (int)(t_info.resident_size / 1024);
}
return -1;
#else
@@ -763,8 +773,8 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output)
{
cWorld * World = itr->second;
int NumInGenerator = World->GetGeneratorQueueLength();
- int NumInSaveQueue = World->GetStorageSaveQueueLength();
- int NumInLoadQueue = World->GetStorageLoadQueueLength();
+ int NumInSaveQueue = (int)World->GetStorageSaveQueueLength();
+ int NumInLoadQueue = (int)World->GetStorageLoadQueueLength();
int NumValid = 0;
int NumDirty = 0;
int NumInLighting = 0;
@@ -784,8 +794,6 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output)
a_Output.Out(" block lighting: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", 2 * sizeof(cChunkDef::BlockNibbles), (2 * sizeof(cChunkDef::BlockNibbles) + 1023) / 1024);
a_Output.Out(" heightmap: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", sizeof(cChunkDef::HeightMap), (sizeof(cChunkDef::HeightMap) + 1023) / 1024);
a_Output.Out(" biomemap: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", sizeof(cChunkDef::BiomeMap), (sizeof(cChunkDef::BiomeMap) + 1023) / 1024);
- int Rest = sizeof(cChunk) - sizeof(cChunkDef::BlockTypes) - 3 * sizeof(cChunkDef::BlockNibbles) - sizeof(cChunkDef::HeightMap) - sizeof(cChunkDef::BiomeMap);
- a_Output.Out(" other: %6d bytes (%3d KiB)", Rest, (Rest + 1023) / 1024);
SumNumValid += NumValid;
SumNumDirty += NumDirty;
SumNumInLighting += NumInLighting;
diff --git a/src/Root.h b/src/Root.h
index d2a4d1eed..93117389e 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -26,25 +26,45 @@ class cCompositeChat;
typedef cItemCallback<cPlayer> cPlayerListCallback;
typedef cItemCallback<cWorld> cWorldListCallback;
+namespace Json
+{
+ class Value;
+}
+
/// The root of the object hierarchy
-class cRoot // tolua_export
-{ // tolua_export
+// tolua_begin
+class cRoot
+{
public:
- static cRoot * Get() { return s_Root; } // tolua_export
+ static bool m_TerminateEventRaised;
+
+ static cRoot * Get() { return s_Root; }
+ // tolua_end
cRoot(void);
~cRoot();
void Start(void);
- cServer * GetServer(void) { return m_Server; } // tolua_export
- cWorld * GetDefaultWorld(void); // tolua_export
- cWorld * GetWorld(const AString & a_WorldName); // tolua_export
- cWorld * CreateAndInitializeWorld(const AString & a_WorldName); // tolua_export
+ // tolua_begin
+ cServer * GetServer(void) { return m_Server; }
+ cWorld * GetDefaultWorld(void);
+
+ /** Returns a pointer to the world specified
+ If no world of that name was currently loaded and a_SearchForFolder was true, it will consult cFile::IsFolder() to see if a world folder of that name exists and if so, initialise a world based on that name
+ */
+ cWorld * GetWorld(const AString & a_WorldName, bool a_SearchForFolder = false);
+
+ /** Returns a pointer to a world of specified name - will search loaded worlds first, then create anew if not found
+ The dimension parameter is used to create a world with a specific dimension
+ a_OverworldName should be set for non-overworld dimensions if one wishes that world to link back to an overworld via portals
+ */
+ cWorld * CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = "");
+ // tolua_end
/// Calls the callback for each world; returns true if the callback didn't abort (return true)
bool ForEachWorld(cWorldListCallback & a_Callback); // >> Exported in ManualBindings <<
@@ -89,7 +109,7 @@ public:
void KickUser(int a_ClientID, const AString & a_Reason);
/// Called by cAuthenticator to auth the specified user
- void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID);
+ void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties);
/// Executes commands queued in the command queue
void TickCommands(void);
@@ -101,13 +121,13 @@ public:
void SaveAllChunks(void); // tolua_export
/// Reloads all the groups
- void ReloadGroups(void); // tolua_export
+ void ReloadGroups(void); // tolua_export
/// Calls the callback for each player in all worlds
- bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
+ bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
/// Finds a player from a partial or complete player name and calls the callback - case-insensitive
- bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
+ bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
// tolua_begin
@@ -197,8 +217,8 @@ private:
static void InputThread(void* a_Params);
- static cRoot* s_Root;
-}; // tolua_export
+ static cRoot* s_Root;
+}; // tolua_export
diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp
index 4c89ce265..def952029 100644
--- a/src/Scoreboard.cpp
+++ b/src/Scoreboard.cpp
@@ -45,7 +45,8 @@ AString cObjective::TypeToString(eType a_Type)
cObjective::eType cObjective::StringToType(const AString & a_Name)
{
- static struct {
+ static struct
+ {
eType m_Type;
const char * m_String;
} TypeMap [] =
@@ -197,15 +198,18 @@ void cObjective::SendTo(cClientHandle & a_Client)
-cTeam::cTeam(const AString & a_Name, const AString & a_DisplayName,
- const AString & a_Prefix, const AString & a_Suffix)
+cTeam::cTeam(
+ const AString & a_Name, const AString & a_DisplayName,
+ const AString & a_Prefix, const AString & a_Suffix
+)
: m_AllowsFriendlyFire(true)
, m_CanSeeFriendlyInvisible(false)
, m_DisplayName(a_DisplayName)
, m_Name(a_Name)
, m_Prefix(a_Prefix)
, m_Suffix(a_Suffix)
-{}
+{
+}
@@ -261,7 +265,7 @@ void cTeam::SetDisplayName(const AString & a_Name)
-unsigned int cTeam::GetNumPlayers(void) const
+size_t cTeam::GetNumPlayers(void) const
{
return m_Players.size();
}
@@ -569,7 +573,7 @@ void cScoreboard::SendTo(cClientHandle & a_Client)
-unsigned int cScoreboard::GetNumObjectives(void) const
+size_t cScoreboard::GetNumObjectives(void) const
{
return m_Objectives.size();
}
@@ -578,7 +582,7 @@ unsigned int cScoreboard::GetNumObjectives(void) const
-unsigned int cScoreboard::GetNumTeams(void) const
+size_t cScoreboard::GetNumTeams(void) const
{
return m_Teams.size();
}
diff --git a/src/Scoreboard.h b/src/Scoreboard.h
index 2fae5e499..f53b8c803 100644
--- a/src/Scoreboard.h
+++ b/src/Scoreboard.h
@@ -118,7 +118,7 @@ private:
friend class cScoreboardSerializer;
-}; // tolua_export
+}; // tolua_export
@@ -153,7 +153,7 @@ public:
// tolua_begin
/** Returns the number of registered players */
- unsigned int GetNumPlayers(void) const;
+ size_t GetNumPlayers(void) const;
bool AllowsFriendlyFire(void) const { return m_AllowsFriendlyFire; }
bool CanSeeFriendlyInvisible(void) const { return m_CanSeeFriendlyInvisible; }
@@ -197,7 +197,7 @@ private:
friend class cScoreboardSerializer;
-}; // tolua_export
+}; // tolua_export
@@ -248,9 +248,9 @@ public:
cObjective * GetObjectiveIn(eDisplaySlot a_Slot);
- unsigned int GetNumObjectives(void) const;
+ size_t GetNumObjectives(void) const;
- unsigned int GetNumTeams(void) const;
+ size_t GetNumTeams(void) const;
void AddPlayerScore(const AString & a_Name, cObjective::eType a_Type, cObjective::Score a_Value = 1);
@@ -259,25 +259,22 @@ public:
/** Send this scoreboard to the specified client */
void SendTo(cClientHandle & a_Client);
- cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn)
+ cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn)
- /** Execute callback for each objective with the specified type
- *
- * Returns true if all objectives processed, false if the callback aborted by returning true.
- */
+ /** Execute callback for each objective with the specified type
+ Returns true if all objectives processed, false if the callback aborted by returning true.
+ */
bool ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback& a_Callback);
/** Execute callback for each objective.
- *
- * Returns true if all objectives have been processed, false if the callback aborted by returning true.
- */
- bool ForEachObjective(cObjectiveCallback& a_Callback); // Exported in ManualBindings.cpp
+ Returns true if all objectives have been processed, false if the callback aborted by returning true.
+ */
+ bool ForEachObjective(cObjectiveCallback& a_Callback); // Exported in ManualBindings.cpp
/** Execute callback for each team.
- *
- * Returns true if all teams have been processed, false if the callback aborted by returning true.
- */
- bool ForEachTeam(cTeamCallback& a_Callback); // Exported in ManualBindings.cpp
+ Returns true if all teams have been processed, false if the callback aborted by returning true.
+ */
+ bool ForEachTeam(cTeamCallback& a_Callback); // Exported in ManualBindings.cpp
void SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot);
@@ -304,7 +301,7 @@ private:
friend class cScoreboardSerializer;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Server.cpp b/src/Server.cpp
index bfb1b1cbb..42ad133f1 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -30,7 +30,8 @@
#include <sstream>
#include <iostream>
-extern "C" {
+extern "C"
+{
#include "zlib/zlib.h"
}
@@ -60,7 +61,7 @@ typedef std::list< cClientHandle* > ClientList;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cServer::cTickThread:
cServer::cTickThread::cTickThread(cServer & a_Server) :
@@ -101,16 +102,22 @@ void cServer::cTickThread::Execute(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cServer:
cServer::cServer(void) :
- m_ListenThreadIPv4(*this, cSocket::IPv4, "Client IPv4"),
- m_ListenThreadIPv6(*this, cSocket::IPv6, "Client IPv6"),
+ m_ListenThreadIPv4(*this, cSocket::IPv4, "Client"),
+ m_ListenThreadIPv6(*this, cSocket::IPv6, "Client"),
+ m_PlayerCount(0),
+ m_PlayerCountDiff(0),
+ m_ClientViewDistance(0),
m_bIsConnected(false),
m_bRestarting(false),
m_RCONServer(*this),
- m_TickThread(*this)
+ m_MaxPlayers(0),
+ m_bIsHardcore(false),
+ m_TickThread(*this),
+ m_ShouldAuthenticate(false)
{
}
@@ -196,7 +203,7 @@ bool cServer::InitServer(cIniFile & a_SettingsIni)
m_PlayerCount = 0;
m_PlayerCountDiff = 0;
- m_FaviconData = Base64Encode(cFile::ReadWholeFile(FILE_IO_PREFIX + AString("favicon.png"))); // Will return empty string if file nonexistant; client doesn't mind
+ m_FaviconData = Base64Encode(cFile::ReadWholeFile(FILE_IO_PREFIX + AString("favicon.png"))); // Will return empty string if file nonexistant; client doesn't mind
if (m_bIsConnected)
{
@@ -207,7 +214,7 @@ bool cServer::InitServer(cIniFile & a_SettingsIni)
LOGINFO("Compatible clients: %s", MCS_CLIENT_VERSIONS);
LOGINFO("Compatible protocol versions %s", MCS_PROTOCOL_VERSIONS);
- if (cSocket::WSAStartup() != 0) // Only does anything on Windows, but whatever
+ if (cSocket::WSAStartup() != 0) // Only does anything on Windows, but whatever
{
LOGERROR("WSAStartup() != 0");
return false;
@@ -252,6 +259,9 @@ bool cServer::InitServer(cIniFile & a_SettingsIni)
m_ServerID.resize(16, '0');
}
+ m_ShouldLoadOfflinePlayerData = a_SettingsIni.GetValueSetB("PlayerData", "LoadOfflinePlayerData", false);
+ m_ShouldLoadNamedPlayerData = a_SettingsIni.GetValueSetB("PlayerData", "LoadNamedPlayerData", true);
+
m_ClientViewDistance = a_SettingsIni.GetValueSetI("Server", "DefaultViewDistance", cClientHandle::DEFAULT_VIEW_DISTANCE);
if (m_ClientViewDistance < cClientHandle::MIN_VIEW_DISTANCE)
{
@@ -320,6 +330,7 @@ void cServer::OnConnectionAccepted(cSocket & a_Socket)
LOGERROR("Client \"%s\" cannot be handled, server probably unstable", ClientIP.c_str());
a_Socket.CloseSocket();
delete NewHandle;
+ NewHandle = NULL;
return;
}
@@ -387,7 +398,7 @@ void cServer::TickClients(float a_Dt)
{
if ((*itr)->IsDestroyed())
{
- // Remove the client later, when CS is not held, to avoid deadlock ( http://forum.mc-server.org/showthread.php?tid=374 )
+ // Remove the client later, when CS is not held, to avoid deadlock: http://forum.mc-server.org/showthread.php?tid=374
RemoveClients.push_back(*itr);
itr = m_Clients.erase(itr);
continue;
@@ -401,7 +412,7 @@ void cServer::TickClients(float a_Dt)
for (cClientHandleList::iterator itr = RemoveClients.begin(); itr != RemoveClients.end(); ++itr)
{
delete *itr;
- } // for itr - RemoveClients[]
+ } // for itr - RemoveClients[]
}
@@ -476,7 +487,37 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
a_Output.Finished();
return;
}
-
+ if (split[0] == "load")
+ {
+ if (split.size() > 1)
+ {
+ cPluginManager::Get()->LoadPlugin(split[1]);
+
+ return;
+ }
+ else
+ {
+ a_Output.Out("No plugin given! Command: load <pluginname>");
+ a_Output.Finished();
+ return;
+ }
+ }
+
+ if (split[0] == "unload")
+ {
+ if (split.size() > 1)
+ {
+ cPluginManager::Get()->RemovePlugin(cPluginManager::Get()->GetPlugin(split[1]));
+ return;
+ }
+ else
+ {
+ a_Output.Out("No plugin given! Command: unload <pluginname>");
+ a_Output.Finished();
+ return;
+ }
+ }
+
// There is currently no way a plugin can do these (and probably won't ever be):
if (split[0].compare("chunkstats") == 0)
{
@@ -567,6 +608,9 @@ void cServer::BindBuiltInConsoleCommands(void)
PlgMgr->BindConsoleCommand("restart", NULL, " - Restarts the server cleanly");
PlgMgr->BindConsoleCommand("stop", NULL, " - Stops the server cleanly");
PlgMgr->BindConsoleCommand("chunkstats", NULL, " - Displays detailed chunk memory statistics");
+ PlgMgr->BindConsoleCommand("load <pluginname>", NULL, " - Adds and enables the specified plugin");
+ PlgMgr->BindConsoleCommand("unload <pluginname>", NULL, " - Disables the specified plugin");
+
#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
PlgMgr->BindConsoleCommand("dumpmem", NULL, " - Dumps all used memory blocks together with their callstacks into memdump.xml");
#endif
@@ -587,7 +631,7 @@ void cServer::Shutdown(void)
cRoot::Get()->SaveAllChunks();
cCSLock Lock(m_CSClients);
- for( ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr )
+ for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
{
(*itr)->Destroy();
delete *itr;
@@ -615,14 +659,14 @@ void cServer::KickUser(int a_ClientID, const AString & a_Reason)
-void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID)
+void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties)
{
cCSLock Lock(m_CSClients);
for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
{
if ((*itr)->GetUniqueID() == a_ClientID)
{
- (*itr)->Authenticate(a_Name, a_UUID);
+ (*itr)->Authenticate(a_Name, a_UUID, a_Properties);
return;
}
} // for itr - m_Clients[]
@@ -632,7 +676,7 @@ void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const ASt
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cServer::cNotifyWriteThread:
cServer::cNotifyWriteThread::cNotifyWriteThread(void) :
diff --git a/src/Server.h b/src/Server.h
index 51c450ebd..b03359f03 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -23,7 +23,7 @@
#pragma warning(disable:4702)
#endif
-#include "Crypto.h"
+#include "PolarSSL++/RsaPrivateKey.h"
#ifdef _MSC_VER
#pragma warning(pop)
@@ -37,18 +37,23 @@
class cPlayer;
class cClientHandle;
class cIniFile;
-class cCommandOutputCallback ;
+class cCommandOutputCallback;
typedef std::list<cClientHandle *> cClientHandleList;
+namespace Json
+{
+ class Value;
+}
-class cServer // tolua_export
+
+class cServer // tolua_export
: public cListenThread::cCallback
-{ // tolua_export
-public: // tolua_export
+{ // tolua_export
+public: // tolua_export
virtual ~cServer() {}
bool InitServer(cIniFile & a_SettingsIni);
@@ -83,7 +88,9 @@ public: // tolua_export
void Shutdown(void);
void KickUser(int a_ClientID, const AString & a_Reason);
- void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator to auth the specified user
+
+ /** Authenticates the specified user, called by cAuthenticator */
+ void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties);
const AString & GetServerID(void) const { return m_ServerID; } // tolua_export
@@ -109,14 +116,24 @@ public: // tolua_export
/** Returns base64 encoded favicon data (obtained from favicon.png) */
const AString & GetFaviconData(void) const { return m_FaviconData; }
- cRSAPrivateKey & GetPrivateKey(void) { return m_PrivateKey; }
+ cRsaPrivateKey & GetPrivateKey(void) { return m_PrivateKey; }
const AString & GetPublicKeyDER(void) const { return m_PublicKeyDER; }
+ /** Returns true if authentication has been turned on in server settings. */
bool ShouldAuthenticate(void) const { return m_ShouldAuthenticate; }
+ /** Returns true if offline UUIDs should be used to load data for players whose normal UUIDs cannot be found.
+ Loaded from the settings.ini [PlayerData].LoadOfflinePlayerData setting. */
+ bool ShouldLoadOfflinePlayerData(void) const { return m_ShouldLoadOfflinePlayerData; }
+
+ /** Returns true if old-style playernames should be used to load data for players whose regular datafiles cannot be found.
+ This allows a seamless transition from name-based to UUID-based player storage.
+ Loaded from the settings.ini [PlayerData].LoadNamedPlayerData setting. */
+ bool ShouldLoadNamedPlayerData(void) const { return m_ShouldLoadNamedPlayerData; }
+
private:
- friend class cRoot; // so cRoot can create and destroy cServer
+ friend class cRoot; // so cRoot can create and destroy cServer
/** When NotifyClientWrite() is called, it is queued for this thread to process (to avoid deadlocks between cSocketThreads, cClientHandle and cChunkMap) */
class cNotifyWriteThread :
@@ -132,7 +149,7 @@ private:
virtual void Execute(void);
- public:
+ public:
cNotifyWriteThread(void);
~cNotifyWriteThread();
@@ -177,12 +194,12 @@ private:
int m_ClientViewDistance; // The default view distance for clients; settable in Settings.ini
- bool m_bIsConnected; // true - connected false - not connected
+ bool m_bIsConnected; // true - connected false - not connected
bool m_bRestarting;
/** The private key used for the assymetric encryption start in the protocols */
- cRSAPrivateKey m_PrivateKey;
+ cRsaPrivateKey m_PrivateKey;
/** Public key for m_PrivateKey, ASN1-DER-encoded */
AString m_PublicKeyDER;
@@ -204,6 +221,16 @@ private:
This setting is the same as the "online-mode" setting in Vanilla. */
bool m_ShouldAuthenticate;
+ /** True if offline UUIDs should be used to load data for players whose normal UUIDs cannot be found.
+ This allows transitions from an offline (no-auth) server to an online one.
+ Loaded from the settings.ini [PlayerData].LoadOfflinePlayerData setting. */
+ bool m_ShouldLoadOfflinePlayerData;
+
+ /** True if old-style playernames should be used to load data for players whose regular datafiles cannot be found.
+ This allows a seamless transition from name-based to UUID-based player storage.
+ Loaded from the settings.ini [PlayerData].LoadNamedPlayerData setting. */
+ bool m_ShouldLoadNamedPlayerData;
+
cServer(void);
@@ -217,7 +244,7 @@ private:
// cListenThread::cCallback overrides:
virtual void OnConnectionAccepted(cSocket & a_Socket) override;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp
new file mode 100644
index 000000000..6e0c2733e
--- /dev/null
+++ b/src/SetChunkData.cpp
@@ -0,0 +1,115 @@
+
+// SetChunkData.cpp
+
+// Implements the cSetChunkData class used for sending loaded / generated chunk
+
+#include "Globals.h"
+#include "SetChunkData.h"
+
+
+
+
+
+cSetChunkData::cSetChunkData(int a_ChunkX, int a_ChunkZ, bool a_ShouldMarkDirty) :
+ m_ChunkX(a_ChunkX),
+ m_ChunkZ(a_ChunkZ),
+ m_ShouldMarkDirty(a_ShouldMarkDirty)
+{
+}
+
+
+
+
+
+cSetChunkData::cSetChunkData(
+ int a_ChunkX, int a_ChunkZ,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockMetas,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_SkyLight,
+ const cChunkDef::HeightMap * a_HeightMap,
+ const cChunkDef::BiomeMap * a_Biomes,
+ cEntityList & a_Entities,
+ cBlockEntityList & a_BlockEntities,
+ bool a_ShouldMarkDirty
+) :
+ m_ChunkX(a_ChunkX),
+ m_ChunkZ(a_ChunkZ),
+ m_ShouldMarkDirty(a_ShouldMarkDirty)
+{
+ // Check the params' validity:
+ ASSERT(a_BlockTypes != NULL);
+ ASSERT(a_BlockMetas != NULL);
+ ASSERT(a_Biomes != NULL);
+
+ // Copy block types and metas:
+ memcpy(m_BlockTypes, a_BlockTypes, sizeof(cChunkDef::BlockTypes));
+ memcpy(m_BlockMetas, a_BlockMetas, sizeof(cChunkDef::BlockNibbles));
+
+ // Copy lights, if both given:
+ if ((a_BlockLight != NULL) && (a_SkyLight != NULL))
+ {
+ memcpy(m_BlockLight, a_BlockLight, sizeof(m_BlockLight));
+ memcpy(m_SkyLight, a_SkyLight, sizeof(m_SkyLight));
+ m_IsLightValid = true;
+ }
+ else
+ {
+ m_IsLightValid = false;
+ }
+
+ // Copy the heightmap, if available:
+ if (a_HeightMap != NULL)
+ {
+ memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap));
+ m_IsHeightMapValid = true;
+ }
+ else
+ {
+ m_IsHeightMapValid = false;
+ }
+
+ // Copy biomes, if available:
+ if (a_Biomes != NULL)
+ {
+ memcpy(m_Biomes, a_Biomes, sizeof(m_Biomes));
+ m_AreBiomesValid = true;
+ }
+ else
+ {
+ m_AreBiomesValid = false;
+ }
+
+ // Move entities and blockentities:
+ std::swap(m_Entities, a_Entities);
+ std::swap(m_BlockEntities, a_BlockEntities);
+}
+
+
+
+
+
+void cSetChunkData::CalculateHeightMap(void)
+{
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int y = cChunkDef::Height - 1; y > -1; y--)
+ {
+ int index = cChunkDef::MakeIndexNoCheck(x, y, z);
+ if (m_BlockTypes[index] != E_BLOCK_AIR)
+ {
+ m_HeightMap[x + z * cChunkDef::Width] = (HEIGHTTYPE)y;
+ break;
+ }
+ } // for y
+ } // for z
+ } // for x
+ m_IsHeightMapValid = true;
+}
+
+
+
+
+
diff --git a/src/SetChunkData.h b/src/SetChunkData.h
new file mode 100644
index 000000000..a2f776f6b
--- /dev/null
+++ b/src/SetChunkData.h
@@ -0,0 +1,120 @@
+
+// SetChunkData.h
+
+// Declares the cSetChunkData class used for sending loaded / generated chunk data into cWorld
+
+
+
+
+
+#pragma once
+
+
+
+
+
+class cSetChunkData
+{
+public:
+ /** Constructs a new instance with empty data.
+ Allocates new buffers for the block data.
+ Prefer to use this constructor, then fill the object with data and then send it to cWorld, as this will
+ reduce the copying required to queue the set operation. */
+ cSetChunkData(int a_ChunkX, int a_ChunkZ, bool a_ShouldMarkDirty);
+
+ /** Constructs a new instance based on data existing elsewhere, will copy all the memory. Prefer to use the
+ other constructor as much as possible.
+ Will move the entity and blockentity lists into the internal storage, and empty the a_Entities and
+ a_BlockEntities lists.
+ a_BlockTypes and a_BlockMetas must always be valid.
+ If either of the light arrays are NULL, the chunk data will be marked as not having any light at all and
+ will be scheduled for re-lighting once it is set into the chunkmap.
+ If a_Biomes is not valid, the internal flag is set and the world will calculate the biomes using the chunk
+ generator when setting the chunk data.
+ If a_HeightMap is not assigned, the world will calculate the heightmap based on the blocktypes when setting
+ the chunk data. */
+ cSetChunkData(
+ int a_ChunkX, int a_ChunkZ,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockMetas,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_SkyLight,
+ const cChunkDef::HeightMap * a_HeightMap,
+ const cChunkDef::BiomeMap * a_Biomes,
+ cEntityList & a_Entities,
+ cBlockEntityList & a_BlockEntities,
+ bool a_ShouldMarkDirty
+ );
+
+ int GetChunkX(void) const { return m_ChunkX; }
+ int GetChunkZ(void) const { return m_ChunkZ; }
+
+ /** Returns the internal storage of the block types, read-only. */
+ const cChunkDef::BlockTypes & GetBlockTypes(void) const { return m_BlockTypes; }
+
+ /** Returns the internal storage of the block types, read-only. */
+ const cChunkDef::BlockNibbles & GetBlockMetas(void) const { return m_BlockMetas; }
+
+ /** Returns the internal storage of the block light, read-only. */
+ const cChunkDef::BlockNibbles & GetBlockLight(void) const { return m_BlockLight; }
+
+ /** Returns the internal storage of the block types, read-only. */
+ const cChunkDef::BlockNibbles & GetSkyLight(void) const { return m_SkyLight; }
+
+ /** Returns the internal storage for heightmap, read-only. */
+ const cChunkDef::HeightMap & GetHeightMap(void) const { return m_HeightMap; }
+
+ /** Returns the internal storage for biomes, read-write. */
+ cChunkDef::BiomeMap & GetBiomes(void) { return m_Biomes; }
+
+ /** Returns the internal storage for entities, read-write. */
+ cEntityList & GetEntities(void) { return m_Entities; }
+
+ /** Returns the internal storage for block entities, read-write. */
+ cBlockEntityList & GetBlockEntities(void) { return m_BlockEntities; }
+
+ /** Returns whether both light arrays stored in this object are valid. */
+ bool IsLightValid(void) const { return m_IsLightValid; }
+
+ /** Returns whether the heightmap stored in this object is valid. */
+ bool IsHeightMapValid(void) const { return m_IsHeightMapValid; }
+
+ /** Returns whether the biomes stored in this object are valid. */
+ bool AreBiomesValid(void) const { return m_AreBiomesValid; }
+
+ /** Returns whether the chunk should be marked as dirty after its data is set.
+ Used by the generator to save chunks after generating. */
+ bool ShouldMarkDirty(void) const { return m_ShouldMarkDirty; }
+
+ /** Marks the biomes stored in this object as valid. */
+ void MarkBiomesValid(void) { m_AreBiomesValid = true; }
+
+ /** Calculates the heightmap based on the contained blocktypes and marks it valid. */
+ void CalculateHeightMap(void);
+
+protected:
+ int m_ChunkX;
+ int m_ChunkZ;
+
+ cChunkDef::BlockTypes m_BlockTypes;
+ cChunkDef::BlockNibbles m_BlockMetas;
+ cChunkDef::BlockNibbles m_BlockLight;
+ cChunkDef::BlockNibbles m_SkyLight;
+ cChunkDef::HeightMap m_HeightMap;
+ cChunkDef::BiomeMap m_Biomes;
+ cEntityList m_Entities;
+ cBlockEntityList m_BlockEntities;
+
+ bool m_IsLightValid;
+ bool m_IsHeightMapValid;
+ bool m_AreBiomesValid;
+ bool m_ShouldMarkDirty;
+};
+
+typedef SharedPtr<cSetChunkData> cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11
+typedef std::vector<cSetChunkDataPtr> cSetChunkDataPtrs;
+
+
+
+
+
diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt
index b2a29d45c..521b145b6 100644
--- a/src/Simulator/CMakeLists.txt
+++ b/src/Simulator/CMakeLists.txt
@@ -4,9 +4,34 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ DelayedFluidSimulator.cpp
+ FireSimulator.cpp
+ FloodyFluidSimulator.cpp
+ FluidSimulator.cpp
+ IncrementalRedstoneSimulator.cpp
+ RedstoneSimulator.cpp
+ SandSimulator.cpp
+ Simulator.cpp
+ SimulatorManager.cpp
+ VanillaFluidSimulator.cpp
+ VaporizeFluidSimulator.cpp)
-add_library(Simulator ${SOURCE})
+SET (HDRS
+ DelayedFluidSimulator.h
+ FireSimulator.h
+ FloodyFluidSimulator.h
+ FluidSimulator.h
+ IncrementalRedstoneSimulator.h
+ NoopFluidSimulator.h
+ NoopRedstoneSimulator.h
+ RedstoneSimulator.h
+ SandSimulator.h
+ Simulator.h
+ SimulatorManager.h
+ VanillaFluidSimulator.h
+ VaporizeFluidSimulator.h)
+
+if(NOT MSVC)
+ add_library(Simulator ${SRCS} ${HDRS})
+endif()
diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp
index bc5158d95..59ea51aa0 100644
--- a/src/Simulator/DelayedFluidSimulator.cpp
+++ b/src/Simulator/DelayedFluidSimulator.cpp
@@ -14,7 +14,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cDelayedFluidSimulatorChunkData::cSlot
bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ)
@@ -40,7 +40,7 @@ bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_R
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cDelayedFluidSimulatorChunkData:
cDelayedFluidSimulatorChunkData::cDelayedFluidSimulatorChunkData(int a_TickDelay) :
@@ -62,7 +62,7 @@ cDelayedFluidSimulatorChunkData::~cDelayedFluidSimulatorChunkData()
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cDelayedFluidSimulator:
cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay) :
@@ -131,7 +131,7 @@ void cDelayedFluidSimulator::Simulate(float a_Dt)
void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
-{
+{
void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw;
cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_SimSlotNum];
@@ -148,7 +148,7 @@ void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_Chunk
{
SimulateBlock(a_Chunk, itr->x, itr->y, itr->z);
}
- m_TotalBlocks -= Blocks.size();
+ m_TotalBlocks -= (int)Blocks.size();
Blocks.clear();
}
}
diff --git a/src/Simulator/DelayedFluidSimulator.h b/src/Simulator/DelayedFluidSimulator.h
index c81500741..8a6c26c7a 100644
--- a/src/Simulator/DelayedFluidSimulator.h
+++ b/src/Simulator/DelayedFluidSimulator.h
@@ -50,7 +50,7 @@ class cDelayedFluidSimulator :
{
typedef cFluidSimulator super;
-public:
+public:
cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay);
// cSimulator overrides:
@@ -70,7 +70,7 @@ protected:
/*
Slots:
| 0 | 1 | ... | m_AddSlotNum | m_SimSlotNum | ... | m_TickDelay - 1 |
- adding blocks here ^ | ^ simulating here
+ | adding blocks here ^ | ^ simulating here
*/
/// Called from SimulateChunk() to simulate each block in one slot of blocks. Descendants override this method to provide custom simulation.
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 4fbfffd43..69dc7164e 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -63,7 +63,7 @@ static const struct
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFireSimulator:
cFireSimulator::cFireSimulator(cWorld & a_World, cIniFile & a_IniFile) :
@@ -95,8 +95,10 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
int NumMSecs = (int)a_Dt;
for (cCoordWithIntList::iterator itr = Data.begin(); itr != Data.end();)
{
- int idx = cChunkDef::MakeIndexNoCheck(itr->x, itr->y, itr->z);
- BLOCKTYPE BlockType = a_Chunk->GetBlock(idx);
+ int x = itr->x;
+ int y = itr->y;
+ int z = itr->z;
+ BLOCKTYPE BlockType = a_Chunk->GetBlock(x, y, z);
if (!IsAllowedBlock(BlockType))
{
@@ -125,7 +127,7 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
itr->x + a_ChunkX * cChunkDef::Width, itr->y, itr->z + a_ChunkZ * cChunkDef::Width
);
*/
- NIBBLETYPE BlockMeta = a_Chunk->GetMeta(idx);
+ NIBBLETYPE BlockMeta = a_Chunk->GetMeta(x, y, z);
if (BlockMeta == 0x0f)
{
// The fire burnt out completely
@@ -138,9 +140,9 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
continue;
}
- if((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z))))
+ if ((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z))))
{
- a_Chunk->SetMeta(idx, BlockMeta + 1);
+ a_Chunk->SetMeta(x, y, z, BlockMeta + 1);
}
itr->Data = GetBurnStepTime(a_Chunk, itr->x, itr->y, itr->z); // TODO: Add some randomness into this
} // for itr - Data[]
@@ -304,14 +306,14 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int
// No need to check the coords for equality with the parent block,
// it cannot catch fire anyway (because it's not an air block)
- if (m_World.GetTickRandomNumber(MAX_CHANCE_FLAMMABILITY) > m_Flammability)
+ if (m_World.GetTickRandomNumber(MAX_CHANCE_FLAMMABILITY) > m_Flammability)
{
continue;
}
// Start the fire in the neighbor {x, y, z}
/*
- FLOG("FS: Trying to start fire at {%d, %d, %d}.",
+ FLOG("FS: Trying to start fire at {%d, %d, %d}.",
x + a_Chunk->GetPosX() * cChunkDef::Width, y, z + a_Chunk->GetPosZ() * cChunkDef::Width
);
*/
diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp
index 03e94e791..2c5c4b658 100644
--- a/src/Simulator/FloodyFluidSimulator.cpp
+++ b/src/Simulator/FloodyFluidSimulator.cpp
@@ -48,7 +48,7 @@ cFloodyFluidSimulator::cFloodyFluidSimulator(
void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
{
- FLOG("Simulating block {%d, %d, %d}: block %d, meta %d",
+ FLOG("Simulating block {%d, %d, %d}: block %d, meta %d",
a_Chunk->GetPosX() * cChunkDef::Width + a_RelX, a_RelY, a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ,
a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ),
a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ)
@@ -119,7 +119,7 @@ void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_Re
if (SpreadFurther && (NewMeta < 8))
{
// Spread to the neighbors:
- Spread(a_Chunk, a_RelX, a_RelY, a_RelZ, NewMeta);
+ SpreadXZ(a_Chunk, a_RelX, a_RelY, a_RelZ, NewMeta);
}
// Mark as processed:
@@ -130,7 +130,7 @@ void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_Re
-void cFloodyFluidSimulator::Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta)
+void cFloodyFluidSimulator::SpreadXZ(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta)
{
SpreadToNeighbor(a_Chunk, a_RelX - 1, a_RelY, a_RelZ, a_NewMeta);
SpreadToNeighbor(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, a_NewMeta);
@@ -217,14 +217,20 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
{
ASSERT(a_NewMeta <= 8); // Invalid meta values
ASSERT(a_NewMeta > 0); // Source blocks aren't spread
-
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (!a_NearChunk->UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta))
+
+ a_NearChunk = a_NearChunk->GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
+ if ((a_NearChunk == NULL) || (!a_NearChunk->IsValid()))
{
// Chunk not available
return;
}
+
+ const int BlockX = a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX;
+ const int BlockZ = a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ;
+
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ a_NearChunk->GetBlockTypeMeta(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta);
if (IsAllowedBlock(BlockType))
{
@@ -242,19 +248,13 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
{
// Lava flowing into water, change to stone / cobblestone based on direction:
BLOCKTYPE NewBlock = (a_NewMeta == 8) ? E_BLOCK_STONE : E_BLOCK_COBBLESTONE;
- FLOG(" Lava flowing into water, turning water at rel {%d, %d, %d} into stone",
+ FLOG(" Lava flowing into water, turning water at rel {%d, %d, %d} into stone",
a_RelX, a_RelY, a_RelZ,
ItemTypeToString(NewBlock).c_str()
);
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
+ a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
- int BaseX = a_NearChunk->GetPosX() * cChunkDef::Width;
- int BaseZ = a_NearChunk->GetPosZ() * cChunkDef::Width;
-
- BaseX += a_RelX;
- BaseZ += a_RelZ;
-
- a_NearChunk->BroadcastSoundEffect("random.fizz", BaseX * 8, a_RelY * 8, BaseZ * 8, 0.5f, 1.5f);
+ a_NearChunk->BroadcastSoundEffect("random.fizz", (double)BlockX, (double)a_RelY, (double)BlockZ, 0.5f, 1.5f);
return;
}
}
@@ -264,18 +264,12 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
{
// Water flowing into lava, change to cobblestone / obsidian based on dest block:
BLOCKTYPE NewBlock = (BlockMeta == 0) ? E_BLOCK_OBSIDIAN : E_BLOCK_COBBLESTONE;
- FLOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s",
+ FLOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s",
a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str()
);
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
-
- int BaseX = a_NearChunk->GetPosX() * cChunkDef::Width;
- int BaseZ = a_NearChunk->GetPosZ() * cChunkDef::Width;
-
- BaseX += a_RelX;
- BaseZ += a_RelZ;
+ a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
- a_NearChunk->BroadcastSoundEffect("random.fizz", BaseX * 8, a_RelY * 8, BaseZ * 8, 0.5f, 1.5f);
+ a_NearChunk->BroadcastSoundEffect("random.fizz", (double)BlockX, (double)a_RelY, (double)BlockZ, 0.5f, 1.5f);
return;
}
}
@@ -302,22 +296,18 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
ChunkInterface,
m_World,
PluginInterface,
- NULL,
- a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
+ NULL,
+ BlockX,
a_RelY,
- a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ
+ BlockZ
);
}
} // if (CanWashAway)
-
+
// Spread:
- FLOG(" Spreading to {%d, %d, %d} with meta %d",
- a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
- a_RelY,
- a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ,
- a_NewMeta
- );
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
+ FLOG(" Spreading to {%d, %d, %d} with meta %d", BlockX, a_RelY, BlockZ, a_NewMeta);
+ a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
+ m_World.GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, a_NearChunk);
HardenBlock(a_NearChunk, a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
}
@@ -409,13 +399,13 @@ bool cFloodyFluidSimulator::HardenBlock(cChunk * a_Chunk, int a_RelX, int a_RelY
if (a_Meta == 0)
{
// Source lava block
- a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_OBSIDIAN, 0);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_OBSIDIAN, 0);
return true;
}
// Ignore last lava level
else if (a_Meta <= 4)
{
- a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_COBBLESTONE, 0);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_COBBLESTONE, 0);
return true;
}
}
diff --git a/src/Simulator/FloodyFluidSimulator.h b/src/Simulator/FloodyFluidSimulator.h
index 632de3bb2..8e1be5e6b 100644
--- a/src/Simulator/FloodyFluidSimulator.h
+++ b/src/Simulator/FloodyFluidSimulator.h
@@ -48,16 +48,13 @@ protected:
bool CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
/** Checks if the specified block should harden (Water/Lava interaction) and if so, converts it to a suitable block.
- *
- * Returns whether the block was changed or not.
- */
+ Returns whether the block was changed or not. */
bool HardenBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta);
- /** Spread water to neighbors.
- *
- * May be overridden to provide more sophisticated algorithms.
- */
- virtual void Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta);
+ /** Spread fluid to XZ neighbors.
+ The coords are of the block currently being processed; a_NewMeta is the new meta for the new fluid block.
+ Descendants may overridde to provide more sophisticated algorithms. */
+ virtual void SpreadXZ(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta);
} ;
diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp
index 4a84084d2..58501326f 100644
--- a/src/Simulator/FluidSimulator.cpp
+++ b/src/Simulator/FluidSimulator.cpp
@@ -125,31 +125,31 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
return NONE;
}
BLOCKTYPE BlockID = m_World.GetBlock(a_X, a_Y, a_Z);
- if (!IsAllowedBlock(BlockID)) // No Fluid -> No Flowing direction :D
+ if (!IsAllowedBlock(BlockID)) // No Fluid -> No Flowing direction :D
{
return NONE;
}
/*
Disabled because of causing problems and being useless atm
- char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); //If there is nothing or fluid below it -> dominating flow is down :D
+ char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); // If there is nothing or fluid below it -> dominating flow is down :D
if (BlockBelow == E_BLOCK_AIR || IsAllowedBlock(BlockBelow))
return Y_MINUS;
*/
- NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); //Current Block Meta so only lower points will be counted
- int X = 0, Z = 0; //Lowest Pos will be stored here
+ NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted
+ int X = 0, Z = 0; // Lowest Pos will be stored here
- if (IsAllowedBlock(m_World.GetBlock(a_X, a_Y + 1, a_Z)) && a_Over) //check for upper block to flow because this also affects the flowing direction
+ if (IsAllowedBlock(m_World.GetBlock(a_X, a_Y + 1, a_Z)) && a_Over) // check for upper block to flow because this also affects the flowing direction
{
return GetFlowingDirection(a_X, a_Y + 1, a_Z, false);
}
std::vector< Vector3i * > Points;
- Points.reserve(4); //Already allocate 4 places :D
+ Points.reserve(4); // Already allocate 4 places :D
- //add blocks around the checking pos
+ // add blocks around the checking pos
Points.push_back(new Vector3i(a_X - 1, a_Y, a_Z));
Points.push_back(new Vector3i(a_X + 1, a_Y, a_Z));
Points.push_back(new Vector3i(a_X, a_Y, a_Z + 1));
@@ -159,24 +159,26 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
{
Vector3i *Pos = (*it);
char BlockID = m_World.GetBlock(Pos->x, Pos->y, Pos->z);
- if(IsAllowedBlock(BlockID))
+ if (IsAllowedBlock(BlockID))
{
char Meta = m_World.GetBlockMeta(Pos->x, Pos->y, Pos->z);
- if(Meta > LowestPoint)
+ if (Meta > LowestPoint)
{
LowestPoint = Meta;
X = Pos->x;
Z = Pos->z;
}
- }else if(BlockID == E_BLOCK_AIR)
+ }
+ else if (BlockID == E_BLOCK_AIR)
{
- LowestPoint = 9; //This always dominates
+ LowestPoint = 9; // This always dominates
X = Pos->x;
Z = Pos->z;
}
delete Pos;
+ Pos = NULL;
}
if (LowestPoint == m_World.GetBlockMeta(a_X, a_Y, a_Z))
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index d37d2eecf..ada8de4b8 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -2,21 +2,32 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "IncrementalRedstoneSimulator.h"
+#include "BoundingBox.h"
#include "../BlockEntities/DropSpenserEntity.h"
#include "../BlockEntities/NoteEntity.h"
+#include "../BlockEntities/ChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../Entities/TNTEntity.h"
#include "../Entities/Pickup.h"
#include "../Blocks/BlockTorch.h"
#include "../Blocks/BlockDoor.h"
-#include "../Piston.h"
+#include "../Blocks/BlockButton.h"
+#include "../Blocks/BlockLever.h"
+#include "../Blocks/BlockPiston.h"
+#include "../Blocks/BlockTripwireHook.h"
+
-
-cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World)
- : super(a_World)
+cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World) :
+ super(a_World),
+ m_RedstoneSimulatorChunkData(),
+ m_PoweredBlocks(),
+ m_LinkedPoweredBlocks(),
+ m_SimulatedPlayerToggleableBlocks(),
+ m_RepeatersDelayList(),
+ m_Chunk()
{
}
@@ -48,7 +59,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
// Use that Chunk pointer to get a relative position
int RelX = 0;
- int RelZ = 0;
+ int RelZ = 0;
BLOCKTYPE Block;
NIBBLETYPE Meta;
@@ -57,6 +68,10 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width;
RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width;
a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta);
+
+ // If a_OtherChunk is passed (not NULL), it is the chunk that had a block change, and a_Chunk will be the neighbouring chunk of that block
+ // Because said neighbouring chunk does not know of this change but still needs to update its redstone, we set it to dirty
+ a_Chunk->SetIsRedstoneDirty(true);
}
else
{
@@ -87,10 +102,9 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
// Changeable sources
((Block == E_BLOCK_REDSTONE_WIRE) && (Meta == 0)) ||
((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) ||
- ((Block == E_BLOCK_DETECTOR_RAIL) && (Meta & 0x08) == 0) ||
+ ((Block == E_BLOCK_DETECTOR_RAIL) && ((Meta & 0x08) == 0)) ||
(((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) ||
- (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) ||
- (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0))
+ ((Block == E_BLOCK_TRIPWIRE_HOOK) && ((Meta & 0x08) == 0))
)
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
@@ -139,14 +153,14 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
SimulatedPlayerToggleableList * SimulatedPlayerToggleableBlocks = a_Chunk->GetRedstoneSimulatorSimulatedPlayerToggleableList();
for (SimulatedPlayerToggleableList::iterator itr = SimulatedPlayerToggleableBlocks->begin(); itr != SimulatedPlayerToggleableBlocks->end(); ++itr)
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (!itr->a_RelBlockPos.Equals(Vector3i(RelX, a_BlockY, RelZ)))
{
continue;
}
if (!IsAllowedBlock(Block))
{
- LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from toggleable simulated list as it is no longer redstone", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
+ LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from toggleable simulated list as it is no longer redstone", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z);
SimulatedPlayerToggleableBlocks->erase(itr);
break;
}
@@ -155,7 +169,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
RepeatersDelayList * RepeatersDelayList = a_Chunk->GetRedstoneSimulatorRepeatersDelayList();
for (RepeatersDelayList::iterator itr = RepeatersDelayList->begin(); itr != RepeatersDelayList->end(); ++itr)
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (!itr->a_RelBlockPos.Equals(Vector3i(RelX, a_BlockY, RelZ)))
{
continue;
}
@@ -176,15 +190,16 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
cRedstoneSimulatorChunkData * RedstoneSimulatorChunkData = a_Chunk->GetRedstoneSimulatorData();
for (cRedstoneSimulatorChunkData::iterator itr = RedstoneSimulatorChunkData->begin(); itr != RedstoneSimulatorChunkData->end(); ++itr)
{
- if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ)) // We are at an entry matching the current (changed) block
+ if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ)) // We are at an entry matching the current (changed) block
{
if (!IsAllowedBlock(Block))
{
- itr->DataTwo = true; // The new blocktype is not redstone; it must be queued to be removed from this list
+ itr->DataTwo = true; // The new blocktype is not redstone; it must be queued to be removed from this list
}
else
{
- itr->Data = Block; // Update block information
+ itr->DataTwo = false;
+ itr->Data = Block; // Update block information
}
return;
}
@@ -194,8 +209,16 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
return;
}
-
- RedstoneSimulatorChunkData->push_back(cCoordWithBlockAndBool(RelX, a_BlockY, RelZ, Block, false));
+
+ for (cRedstoneSimulatorChunkData::iterator itr = a_Chunk->GetRedstoneSimulatorQueuedData()->begin(); itr != a_Chunk->GetRedstoneSimulatorQueuedData()->end(); ++itr)
+ {
+ if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ))
+ {
+ // Can't have duplicates in here either, in case something adds the block again before the structure can written to the main chunk data
+ return;
+ }
+ }
+ a_Chunk->GetRedstoneSimulatorQueuedData()->push_back(cCoordWithBlockAndBool(RelX, a_BlockY, RelZ, Block, false));
}
@@ -204,25 +227,31 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{
- // We still attempt to simulate all blocks in the chunk every tick, because of outside influence that needs to be taken into account
- // For example, repeaters need to be ticked, pressure plates checked for entities, daylight sensor checked for light changes, etc.
- // The easiest way to make this more efficient is probably just to reduce code within the handlers that put too much strain on server, like getting or setting blocks
- // A marking dirty system might be a TODO for later on, perhaps
-
m_RedstoneSimulatorChunkData = a_Chunk->GetRedstoneSimulatorData();
- if (m_RedstoneSimulatorChunkData->empty())
+ if (m_RedstoneSimulatorChunkData->empty() && a_Chunk->GetRedstoneSimulatorQueuedData()->empty())
{
return;
}
+ m_RedstoneSimulatorChunkData->insert(m_RedstoneSimulatorChunkData->end(), a_Chunk->GetRedstoneSimulatorQueuedData()->begin(), a_Chunk->GetRedstoneSimulatorQueuedData()->end());
+ a_Chunk->GetRedstoneSimulatorQueuedData()->clear();
+
m_PoweredBlocks = a_Chunk->GetRedstoneSimulatorPoweredBlocksList();
m_RepeatersDelayList = a_Chunk->GetRedstoneSimulatorRepeatersDelayList();
m_SimulatedPlayerToggleableBlocks = a_Chunk->GetRedstoneSimulatorSimulatedPlayerToggleableList();
m_LinkedPoweredBlocks = a_Chunk->GetRedstoneSimulatorLinkedBlocksList();
m_Chunk = a_Chunk;
+ bool ShouldUpdateSimulateOnceBlocks = false;
- int BaseX = a_Chunk->GetPosX() * cChunkDef::Width;
- int BaseZ = a_Chunk->GetPosZ() * cChunkDef::Width;
+ if (a_Chunk->IsRedstoneDirty())
+ {
+ // Simulate the majority of devices only if something (blockwise or power-wise) has changed
+ // Make sure to allow the chunk to resimulate after the initial run if there was a power change (ShouldUpdateSimulateOnceBlocks helps to do this)
+ a_Chunk->SetIsRedstoneDirty(false);
+ ShouldUpdateSimulateOnceBlocks = true;
+ }
+
+ HandleRedstoneRepeaterDelays();
for (cRedstoneSimulatorChunkData::iterator dataitr = m_RedstoneSimulatorChunkData->begin(); dataitr != m_RedstoneSimulatorChunkData->end();)
{
@@ -232,78 +261,88 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int
continue;
}
- int a_X = BaseX + dataitr->x;
- int a_Z = BaseZ + dataitr->z;
switch (dataitr->Data)
{
- case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(a_X, dataitr->y, a_Z); break;
- case E_BLOCK_LEVER: HandleRedstoneLever(a_X, dataitr->y, a_Z); break;
- case E_BLOCK_FENCE_GATE: HandleFenceGate(a_X, dataitr->y, a_Z); break;
- case E_BLOCK_TNT: HandleTNT(a_X, dataitr->y, a_Z); break;
- case E_BLOCK_TRAPDOOR: HandleTrapdoor(a_X, dataitr->y, a_Z); break;
- case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(a_X, dataitr->y, a_Z); break;
- case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(a_X, dataitr->y, a_Z); break;
- case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(a_X, dataitr->y, a_Z); break;
- case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(a_X, dataitr->y, a_Z); break;
+ case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_TRIPWIRE: HandleTripwire(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_TRIPWIRE_HOOK: HandleTripwireHook(dataitr->x, dataitr->y, dataitr->z); break;
- case E_BLOCK_REDSTONE_TORCH_OFF:
- case E_BLOCK_REDSTONE_TORCH_ON:
- {
- HandleRedstoneTorch(a_X, dataitr->y, a_Z, dataitr->Data);
- break;
- }
- case E_BLOCK_STONE_BUTTON:
- case E_BLOCK_WOODEN_BUTTON:
- {
- HandleRedstoneButton(a_X, dataitr->y, a_Z, dataitr->Data);
- break;
- }
- case E_BLOCK_REDSTONE_REPEATER_OFF:
- case E_BLOCK_REDSTONE_REPEATER_ON:
- {
- HandleRedstoneRepeater(a_X, dataitr->y, a_Z, dataitr->Data);
- break;
- }
- case E_BLOCK_PISTON:
- case E_BLOCK_STICKY_PISTON:
- {
- HandlePiston(a_X, dataitr->y, a_Z);
- break;
- }
- case E_BLOCK_REDSTONE_LAMP_OFF:
- case E_BLOCK_REDSTONE_LAMP_ON:
- {
- HandleRedstoneLamp(a_X, dataitr->y, a_Z, dataitr->Data);
- break;
- }
- case E_BLOCK_DISPENSER:
- case E_BLOCK_DROPPER:
- {
- HandleDropSpenser(a_X, dataitr->y, a_Z);
- break;
- }
- case E_BLOCK_WOODEN_DOOR:
- case E_BLOCK_IRON_DOOR:
- {
- HandleDoor(a_X, dataitr->y, a_Z);
- break;
- }
- case E_BLOCK_ACTIVATOR_RAIL:
- case E_BLOCK_DETECTOR_RAIL:
- case E_BLOCK_POWERED_RAIL:
- {
- HandleRail(a_X, dataitr->y, a_Z, dataitr->Data);
- break;
- }
case E_BLOCK_WOODEN_PRESSURE_PLATE:
case E_BLOCK_STONE_PRESSURE_PLATE:
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
{
- HandlePressurePlate(a_X, dataitr->y, a_Z, dataitr->Data);
+ HandlePressurePlate(dataitr->x, dataitr->y, dataitr->z, dataitr->Data);
break;
}
- default: LOGD("Unhandled block (!) or unimplemented redstone block: %s", ItemToString(dataitr->Data).c_str()); break;
+ default: break;
+ }
+
+ if (ShouldUpdateSimulateOnceBlocks)
+ {
+ switch (dataitr->Data)
+ {
+ case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_TRAPPED_CHEST: HandleTrappedChest(dataitr->x, dataitr->y, dataitr->z); break;
+
+ case E_BLOCK_ACTIVATOR_RAIL:
+ case E_BLOCK_DETECTOR_RAIL:
+ case E_BLOCK_POWERED_RAIL:
+ {
+ HandleRail(dataitr->x, dataitr->y, dataitr->z, dataitr->Data);
+ break;
+ }
+ case E_BLOCK_WOODEN_DOOR:
+ case E_BLOCK_IRON_DOOR:
+ {
+ HandleDoor(dataitr->x, dataitr->y, dataitr->z);
+ break;
+ }
+ case E_BLOCK_REDSTONE_LAMP_OFF:
+ case E_BLOCK_REDSTONE_LAMP_ON:
+ {
+ HandleRedstoneLamp(dataitr->x, dataitr->y, dataitr->z, dataitr->Data);
+ break;
+ }
+ case E_BLOCK_DISPENSER:
+ case E_BLOCK_DROPPER:
+ {
+ HandleDropSpenser(dataitr->x, dataitr->y, dataitr->z);
+ break;
+ }
+ case E_BLOCK_PISTON:
+ case E_BLOCK_STICKY_PISTON:
+ {
+ HandlePiston(dataitr->x, dataitr->y, dataitr->z);
+ break;
+ }
+ case E_BLOCK_REDSTONE_REPEATER_OFF:
+ case E_BLOCK_REDSTONE_REPEATER_ON:
+ {
+ HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data);
+ break;
+ }
+ case E_BLOCK_REDSTONE_TORCH_OFF:
+ case E_BLOCK_REDSTONE_TORCH_ON:
+ {
+ HandleRedstoneTorch(dataitr->x, dataitr->y, dataitr->z, dataitr->Data);
+ break;
+ }
+ case E_BLOCK_STONE_BUTTON:
+ case E_BLOCK_WOODEN_BUTTON:
+ {
+ HandleRedstoneButton(dataitr->x, dataitr->y, dataitr->z);
+ break;
+ }
+ default: break;
+ }
}
++dataitr;
}
@@ -314,18 +353,13 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int
void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
{
- if (
- ((a_BlockX % cChunkDef::Width) <= 1) ||
- ((a_BlockX % cChunkDef::Width) >= 14) ||
- ((a_BlockZ % cChunkDef::Width) <= 1) ||
- ((a_BlockZ % cChunkDef::Width) >= 14)
- ) // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks
+ if (AreCoordsOnChunkBoundary(a_BlockX, a_BlockY, a_BlockZ))
{
// On a chunk boundary, alert all four sides (i.e. at least one neighbouring chunk)
AddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk);
// Pass the original coordinates, because when adding things to our simulator lists, we get the chunk that they are in, and therefore any updates need to preseve their position
- // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordiantes are in and +- 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries
+ // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordinates are in and +- 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries
RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX - 2, a_BlockZ), a_Chunk);
RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX + 2, a_BlockZ), a_Chunk);
RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ - 2), a_Chunk);
@@ -342,9 +376,9 @@ void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_Blo
-void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState)
+void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState)
{
- static const struct // Define which directions the torch can power
+ static const struct // Define which directions the torch can power
{
int x, y, z;
} gCrossCoords[] =
@@ -358,64 +392,80 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_Bloc
if (a_MyState == E_BLOCK_REDSTONE_TORCH_ON)
{
- // Check if the block the torch is on is powered
- int X = a_BlockX; int Y = a_BlockY; int Z = a_BlockZ;
- AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)), true); // Inverse true to get the block torch is on
+ // Check if the block the torch is on is powered
+ int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ;
+ AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on
- if (AreCoordsDirectlyPowered(X, Y, Z))
+ cChunk * Neighbour = m_Chunk->GetRelNeighborChunk(X, Z);
+ if ((Neighbour == NULL) || !Neighbour->IsValid())
+ {
+ return;
+ }
+
+ if (AreCoordsDirectlyPowered(X, Y, Z, Neighbour))
{
// There was a match, torch goes off
- m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_OFF, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ));
+ m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_TORCH_OFF, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ));
return;
}
// Torch still on, make all 4(X, Z) + 1(Y) sides powered
for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++)
{
- BLOCKTYPE Type = m_World.GetBlock(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z);
- if (i + 1 < ARRAYCOUNT(gCrossCoords)) // Sides of torch, not top (top is last)
+ BLOCKTYPE Type = 0;
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, Type))
+ {
+ continue;
+ }
+ if (i + 1 < ARRAYCOUNT(gCrossCoords)) // Sides of torch, not top (top is last)
{
if (
- ((IsMechanism(Type)) || (Type == E_BLOCK_REDSTONE_WIRE)) && // Is it a mechanism or wire? Not block/other torch etc.
- (!Vector3i(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z).Equals(Vector3i(X, Y, Z))) // CAN'T power block is that it is on
+ IsMechanism(Type) && // Is it a mechanism? Not block/other torch etc.
+ (!Vector3i(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z).Equals(Vector3i(X, Y, Z))) // CAN'T power block is that it is on
)
{
- SetBlockPowered(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON);
+ SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ);
}
}
else
{
// Top side, power whatever is there, including blocks
- SetBlockPowered(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON);
+ SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ);
// Power all blocks surrounding block above torch
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YP, E_BLOCK_REDSTONE_TORCH_ON);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YP);
}
}
- if (m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) != 0x5) // Is torch standing on ground? If NOT (i.e. on wall), power block beneath
+ if (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) != 0x5) // Is torch standing on ground? If NOT (i.e. on wall), power block beneath
{
- BLOCKTYPE Type = m_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ);
+ BLOCKTYPE Type = m_Chunk->GetBlock(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ);
- if ((IsMechanism(Type)) || (Type == E_BLOCK_REDSTONE_WIRE)) // Still can't make a normal block powered though!
+ if (IsMechanism(Type)) // Still can't make a normal block powered though!
{
- SetBlockPowered(a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON);
+ SetBlockPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ);
}
}
}
else
{
- // Check if the block the torch is on is powered
- int X = a_BlockX; int Y = a_BlockY; int Z = a_BlockZ;
- AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)), true); // Inverse true to get the block torch is on
-
+ // Check if the block the torch is on is powered
+ int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ;
+ AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on
+
+ cChunk * Neighbour = m_Chunk->GetRelNeighborChunk(X, Z);
+ if ((Neighbour == NULL) || !Neighbour->IsValid())
+ {
+ return;
+ }
+
// See if off state torch can be turned on again
- if (AreCoordsDirectlyPowered(X, Y, Z))
+ if (AreCoordsDirectlyPowered(X, Y, Z, Neighbour))
{
- return; // Something matches, torch still powered
+ return; // Something matches, torch still powered
}
// Block torch on not powered, can be turned on again!
- m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ));
+ m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_TORCH_ON, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ));
}
}
@@ -423,28 +473,28 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_Bloc
-void cIncrementalRedstoneSimulator::HandleRedstoneBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleRedstoneBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_BLOCK_OF_REDSTONE);
- SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_BLOCK_OF_REDSTONE); // Set self as powered
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+ SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Set self as powered
}
-void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- if (IsLeverOn(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)))
+ NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+ if (IsLeverOn(Meta))
{
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_LEVER);
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, E_BLOCK_LEVER);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, E_BLOCK_LEVER);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, E_BLOCK_LEVER);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YP, E_BLOCK_LEVER);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, E_BLOCK_LEVER);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, E_BLOCK_LEVER);
+ eBlockFace Dir = cBlockLeverHandler::BlockMetaDataToBlockFace(Meta);
+
+ Dir = ReverseBlockFace(Dir);
+
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Dir);
}
}
@@ -452,27 +502,34 @@ void cIncrementalRedstoneSimulator::HandleRedstoneLever(int a_BlockX, int a_Bloc
-void cIncrementalRedstoneSimulator::HandleFenceGate(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleFenceGate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- cChunkInterface ChunkInterface(m_World.GetChunkMap());
- NIBBLETYPE MetaData = ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ NIBBLETYPE MetaData = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
- if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
+ if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
- if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, true))
+ if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true))
{
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, MetaData | 0x4);
- m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0);
- SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, true);
+ if ((MetaData & 0x4) == 0)
+ {
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData | 0x4);
+ m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0);
+ }
+ SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true);
}
}
else
{
- if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, false))
+ if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false))
{
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, MetaData & 0xFFFFFFFB);
- m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0);
- SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, false);
+ if ((MetaData & 0x4) != 0)
+ {
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MetaData & ~0x04);
+ m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0);
+ }
+ SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false);
}
}
}
@@ -481,18 +538,16 @@ void cIncrementalRedstoneSimulator::HandleFenceGate(int a_BlockX, int a_BlockY,
-void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType)
+void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- if (IsButtonOn(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)))
+ NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+ if (IsButtonOn(Meta))
{
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_BlockType);
-
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, a_BlockType);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, a_BlockType);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, a_BlockType);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YP, a_BlockType);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, a_BlockType);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, a_BlockType);
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+
+ eBlockFace Dir = cBlockButtonHandler::BlockMetaDataToBlockFace(Meta);
+ Dir = ReverseBlockFace(Dir);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Dir);
}
}
@@ -500,9 +555,9 @@ void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_BlockX, int a_Blo
-void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- static const struct // Define which directions the wire can receive power from
+ static const struct // Define which directions the wire can receive power from
{
int x, y, z;
} gCrossCoords[] =
@@ -515,13 +570,13 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_Block
{-1, 1, 0},
{ 0, 1, 1},
{ 0, 1, -1}, /* Wires one higher, surrounding self stop */
- { 1,-1, 0}, /* Wires one lower, surrounding self start */
- {-1,-1, 0},
- { 0,-1, 1},
- { 0,-1, -1}, /* Wires one lower, surrounding self stop */
+ { 1, -1, 0}, /* Wires one lower, surrounding self start */
+ {-1, -1, 0},
+ { 0, -1, 1},
+ { 0, -1, -1}, /* Wires one lower, surrounding self stop */
} ;
- static const struct // Define which directions the wire will check for repeater prescence
+ static const struct // Define which directions the wire will check for repeater prescence
{
int x, y, z;
} gSideCoords[] =
@@ -529,20 +584,22 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_Block
{ 1, 0, 0 },
{-1, 0, 0 },
{ 0, 0, 1 },
- { 0, 0,-1 },
+ { 0, 0, -1 },
{ 0, 1, 0 },
};
// Check to see if directly beside a power source
unsigned char MyPower;
- if (!IsWirePowered(a_BlockX, a_BlockY, a_BlockZ, MyPower))
+ if (!IsWirePowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower))
{
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0);
- m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0);
+ m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ);
return;
}
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, MyPower);
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
if (MyPower < 1)
{
@@ -551,78 +608,102 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_Block
MyPower--;
- for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through all directions to transfer or receive power
+ for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through all directions to transfer or receive power
{
- if ((i >= 4) && (i <= 7)) // If we are currently checking for wire surrounding ourself one block above...
+ if ((i >= 4) && (i <= 7)) // If we are currently checking for wire surrounding ourself one block above...
{
- if (cBlockInfo::IsSolid(m_World.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))) // If there is something solid above us (wire cut off)...
+ BLOCKTYPE Type = 0;
+ if (a_RelBlockY + 1 >= cChunkDef::Height)
+ {
+ continue;
+ }
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, Type))
{
- continue; // We don't receive power from that wire
+ continue;
+ }
+ if (cBlockInfo::IsSolid(Type)) // If there is something solid above us (wire cut off)...
+ {
+ continue; // We don't receive power from that wire
}
}
- else if ((i >= 8) && (i <= 11)) // See above, but this is for wire below us
+ else if ((i >= 8) && (i <= 11)) // See above, but this is for wire below us
{
- if (cBlockInfo::IsSolid(m_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ)))
+ BLOCKTYPE Type = 0;
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY, a_RelBlockZ + gCrossCoords[i].z, Type))
+ {
+ continue;
+ }
+ if (cBlockInfo::IsSolid(Type))
{
continue;
}
}
- if (m_World.GetBlock(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z) == E_BLOCK_REDSTONE_WIRE)
+ BLOCKTYPE Type = 0;
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, Type))
{
- SetBlockPowered(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
+ continue;
+ }
+ if (Type == E_BLOCK_REDSTONE_WIRE)
+ {
+ SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
}
}
- for (size_t i = 0; i < ARRAYCOUNT(gSideCoords); i++) // Look for repeaters immediately surrounding self and try to power them
+ for (size_t i = 0; i < ARRAYCOUNT(gSideCoords); i++) // Look for repeaters immediately surrounding self and try to power them
{
- if (m_World.GetBlock(a_BlockX + gSideCoords[i].x, a_BlockY + gSideCoords[i].y, a_BlockZ + gSideCoords[i].z) == E_BLOCK_REDSTONE_REPEATER_OFF)
+ BLOCKTYPE Type = 0;
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gSideCoords[i].x, a_RelBlockY + gSideCoords[i].y, a_RelBlockZ + gSideCoords[i].z, Type))
+ {
+ continue;
+ }
+ if (Type == E_BLOCK_REDSTONE_REPEATER_OFF)
{
- SetBlockPowered(a_BlockX + gSideCoords[i].x, a_BlockY + gSideCoords[i].y, a_BlockZ + gSideCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
+ SetBlockPowered(a_RelBlockX + gSideCoords[i].x, a_RelBlockY + gSideCoords[i].y, a_RelBlockZ + gSideCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
}
}
// Wire still powered, power blocks beneath
- SetBlockPowered(a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, E_BLOCK_REDSTONE_WIRE, MyPower);
+ SetBlockPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM, MyPower);
- switch (GetWireDirection(a_BlockX, a_BlockY, a_BlockZ))
+ switch (GetWireDirection(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
case REDSTONE_NONE:
{
- SetBlockPowered(a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetBlockPowered(a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
+ SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
+ SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
+ SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
+ SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, E_BLOCK_REDSTONE_WIRE, MyPower);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM, MyPower);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP, MyPower);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM, MyPower);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP, MyPower);
break;
}
case REDSTONE_X_POS:
{
- SetBlockPowered(a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, E_BLOCK_REDSTONE_WIRE, MyPower);
+ SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP, MyPower);
break;
}
case REDSTONE_X_NEG:
{
- SetBlockPowered(a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, E_BLOCK_REDSTONE_WIRE, MyPower);
+ SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM, MyPower);
break;
}
case REDSTONE_Z_POS:
{
- SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, E_BLOCK_REDSTONE_WIRE, MyPower);
+ SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP, MyPower);
break;
}
case REDSTONE_Z_NEG:
{
- SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE, MyPower);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, E_BLOCK_REDSTONE_WIRE, MyPower);
+ SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MyPower);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM, MyPower);
break;
}
}
@@ -632,7 +713,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_Block
-void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState)
+void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState)
{
/* Repeater Orientation Mini Guide:
===================================
@@ -643,7 +724,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_B
X Axis ---->
- Repeater directions, values from a cWorld::GetBlockMeta(a_BlockX , a_BlockY, a_BlockZ) lookup:
+ Repeater directions, values from a cWorld::GetBlockMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) lookup:
East (Right) (X+): 0x1
West (Left) (X-): 0x3
@@ -656,87 +737,81 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_B
*/
// Create a variable holding my meta to avoid multiple lookups.
- NIBBLETYPE a_Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ NIBBLETYPE a_Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
bool IsOn = (a_MyState == E_BLOCK_REDSTONE_REPEATER_ON);
-
- if (!IsRepeaterLocked(a_BlockX, a_BlockY, a_BlockZ, a_Meta)) // If we're locked, change nothing. Otherwise:
+
+ if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise:
{
- bool IsSelfPowered = IsRepeaterPowered(a_BlockX, a_BlockY, a_BlockZ, a_Meta);
- if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked.
+ bool IsSelfPowered = IsRepeaterPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta);
+ if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked.
{
- QueueRepeaterPowerChange(a_BlockX, a_BlockY, a_BlockZ, a_Meta, true);
+ QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true);
}
- else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked.
+ else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked.
{
- QueueRepeaterPowerChange(a_BlockX, a_BlockY, a_BlockZ, a_Meta, false);
+ QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false);
}
}
+}
- for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); ++itr)
+void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays()
+{
+ for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end();)
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
- {
- continue;
- }
-
- if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks?
+ if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks?
{
+ int RelBlockX = itr->a_RelBlockPos.x;
+ int RelBlockY = itr->a_RelBlockPos.y;
+ int RelBlockZ = itr->a_RelBlockPos.z;
+ BLOCKTYPE Block;
+ NIBBLETYPE Meta;
+ m_Chunk->GetBlockTypeMeta(RelBlockX, RelBlockY, RelBlockZ, Block, Meta);
if (itr->ShouldPowerOn)
{
- if (!IsOn)
+ if (Block != E_BLOCK_REDSTONE_REPEATER_ON) // For performance
{
- m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // For performance
+ m_Chunk->SetBlock(itr->a_RelBlockPos, E_BLOCK_REDSTONE_REPEATER_ON, Meta);
}
- switch (a_Meta & 0x3) // We only want the direction (bottom) bits
+ switch (Meta & 0x3) // We only want the direction (bottom) bits
{
case 0x0:
{
- SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZM, E_BLOCK_REDSTONE_REPEATER_ON);
+ SetBlockPowered(RelBlockX, RelBlockY, RelBlockZ - 1, RelBlockX, RelBlockY, RelBlockZ);
+ SetDirectionLinkedPowered(RelBlockX, RelBlockY, RelBlockZ, BLOCK_FACE_ZM);
break;
}
case 0x1:
{
- SetBlockPowered(a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XP, E_BLOCK_REDSTONE_REPEATER_ON);
+ SetBlockPowered(RelBlockX + 1, RelBlockY, RelBlockZ, RelBlockX, RelBlockY, RelBlockZ);
+ SetDirectionLinkedPowered(RelBlockX, RelBlockY, RelBlockZ, BLOCK_FACE_XP);
break;
}
case 0x2:
{
- SetBlockPowered(a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_ZP, E_BLOCK_REDSTONE_REPEATER_ON);
+ SetBlockPowered(RelBlockX, RelBlockY, RelBlockZ + 1, RelBlockX, RelBlockY, RelBlockZ);
+ SetDirectionLinkedPowered(RelBlockX, RelBlockY, RelBlockZ, BLOCK_FACE_ZP);
break;
}
case 0x3:
{
- SetBlockPowered(a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON);
- SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_XM, E_BLOCK_REDSTONE_REPEATER_ON);
+ SetBlockPowered(RelBlockX - 1, RelBlockY, RelBlockZ, RelBlockX, RelBlockY, RelBlockZ);
+ SetDirectionLinkedPowered(RelBlockX, RelBlockY, RelBlockZ, BLOCK_FACE_XM);
break;
}
}
-
- // Removal of the data entry will be handled in SimChunk - we still want to continue trying to power blocks, even if our delay time has reached
- // Otherwise, the power state of blocks in front won't update after we have powered on
- return;
}
- else
+ else if (Block != E_BLOCK_REDSTONE_REPEATER_OFF)
{
- if (IsOn)
- {
- m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta);
- }
- m_RepeatersDelayList->erase(itr); // We can remove off repeaters which don't need further updating
- return;
+ m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta);
}
+ itr = m_RepeatersDelayList->erase(itr);
}
else
{
- // Apparently, incrementing ticks only works reliably here, and not in SimChunk;
- // With a world with lots of redstone, the repeaters simply do not delay
- // I am confounded to say why. Perhaps optimisation failure.
- LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks);
+ LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks);
itr->a_ElapsedTicks++;
+ itr++;
}
}
}
@@ -745,16 +820,18 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_B
-void cIncrementalRedstoneSimulator::HandlePiston(int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- cPiston Piston(&m_World);
- if (IsPistonPowered(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness)
+void cIncrementalRedstoneSimulator::HandlePiston(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
+{
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+
+ if (IsPistonPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness)
{
- Piston.ExtendPiston(a_BlockX, a_BlockY, a_BlockZ);
+ cBlockPistonHandler::ExtendPiston(BlockX, a_RelBlockY, BlockZ, &m_World);
}
else
{
- Piston.RetractPiston(a_BlockX, a_BlockY, a_BlockZ);
+ cBlockPistonHandler::RetractPiston(BlockX, a_RelBlockY, BlockZ, &m_World);
}
}
@@ -762,7 +839,7 @@ void cIncrementalRedstoneSimulator::HandlePiston(int a_BlockX, int a_BlockY, int
-void cIncrementalRedstoneSimulator::HandleDropSpenser(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleDropSpenser(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
class cSetPowerToDropSpenser :
public cDropSpenserCallback
@@ -776,29 +853,31 @@ void cIncrementalRedstoneSimulator::HandleDropSpenser(int a_BlockX, int a_BlockY
a_DropSpenser->SetRedstonePower(m_IsPowered);
return false;
}
- } DrSpSP (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ));
+ } DrSpSP (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ));
- m_World.DoWithDropSpenserAt(a_BlockX, a_BlockY, a_BlockZ, DrSpSP);
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ m_Chunk->DoWithDropSpenserAt(BlockX, a_RelBlockY, BlockZ, DrSpSP);
}
-void cIncrementalRedstoneSimulator::HandleRedstoneLamp(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState)
+void cIncrementalRedstoneSimulator::HandleRedstoneLamp(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState)
{
if (a_MyState == E_BLOCK_REDSTONE_LAMP_OFF)
{
- if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
+ if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
- m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_LAMP_ON, 0);
+ m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_LAMP_ON, 0);
}
}
else
{
- if (!AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
+ if (!AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
- m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_LAMP_OFF, 0);
+ m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_LAMP_OFF, 0);
}
}
}
@@ -807,13 +886,16 @@ void cIncrementalRedstoneSimulator::HandleRedstoneLamp(int a_BlockX, int a_Block
-void cIncrementalRedstoneSimulator::HandleTNT(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleTNT(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+
+ if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
- m_World.BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
- m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- m_World.SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom
+ m_Chunk->BroadcastSoundEffect("game.tnt.primed", (double)BlockX, (double)a_RelBlockY, (double)BlockZ, 0.5f, 0.6f);
+ m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_AIR, 0);
+ m_World.SpawnPrimedTNT(BlockX + 0.5, a_RelBlockY + 0.5, BlockZ + 0.5); // 80 ticks to boom
}
}
@@ -821,26 +903,35 @@ void cIncrementalRedstoneSimulator::HandleTNT(int a_BlockX, int a_BlockY, int a_
-void cIncrementalRedstoneSimulator::HandleDoor(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleDoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+
+ if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
- if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, true))
+ if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true))
{
cChunkInterface ChunkInterface(m_World.GetChunkMap());
- cBlockDoorHandler::ChangeDoor(ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
- m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0);
- SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, true);
+ if (!cBlockDoorHandler::IsOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ))
+ {
+ cBlockDoorHandler::SetOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ, true);
+ m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0);
+ }
+ SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true);
}
}
else
{
- if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, false))
+ if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false))
{
cChunkInterface ChunkInterface(m_World.GetChunkMap());
- cBlockDoorHandler::ChangeDoor(ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
- m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0);
- SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, false);
+ if (cBlockDoorHandler::IsOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ))
+ {
+ cBlockDoorHandler::SetOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ, false);
+ m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0);
+ }
+ SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false);
}
}
}
@@ -849,7 +940,7 @@ void cIncrementalRedstoneSimulator::HandleDoor(int a_BlockX, int a_BlockY, int a
-void cIncrementalRedstoneSimulator::HandleCommandBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleCommandBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
class cSetPowerToCommandBlock :
public cCommandBlockCallback
@@ -863,37 +954,39 @@ void cIncrementalRedstoneSimulator::HandleCommandBlock(int a_BlockX, int a_Block
a_CommandBlock->SetRedstonePower(m_IsPowered);
return false;
}
- } CmdBlockSP (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ));
+ } CmdBlockSP (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ));
- m_World.DoWithCommandBlockAt(a_BlockX, a_BlockY, a_BlockZ, CmdBlockSP);
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ m_Chunk->DoWithCommandBlockAt(BlockX, a_RelBlockY, BlockZ, CmdBlockSP);
}
-void cIncrementalRedstoneSimulator::HandleRail(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyType)
+void cIncrementalRedstoneSimulator::HandleRail(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType)
{
switch (a_MyType)
{
case E_BLOCK_DETECTOR_RAIL:
{
- if ((m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x08) == 0x08)
+ if ((m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x08) == 0x08)
{
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType);
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_MyType);
}
break;
}
case E_BLOCK_ACTIVATOR_RAIL:
case E_BLOCK_POWERED_RAIL:
{
- if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
+ if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x08);
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) | 0x08);
}
else
{
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07);
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x07);
}
break;
}
@@ -905,22 +998,25 @@ void cIncrementalRedstoneSimulator::HandleRail(int a_BlockX, int a_BlockY, int a
-void cIncrementalRedstoneSimulator::HandleTrapdoor(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleTrapdoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+
+ if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
- if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, true))
+ if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true))
{
- m_World.SetTrapdoorOpen(a_BlockX, a_BlockY, a_BlockZ, true);
- SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, true);
+ m_World.SetTrapdoorOpen(BlockX, a_RelBlockY, BlockZ, true);
+ SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true);
}
}
else
{
- if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, false))
+ if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false))
{
- m_World.SetTrapdoorOpen(a_BlockX, a_BlockY, a_BlockZ, false);
- SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, false);
+ m_World.SetTrapdoorOpen(BlockX, a_RelBlockY, BlockZ, false);
+ SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false);
}
}
}
@@ -929,13 +1025,13 @@ void cIncrementalRedstoneSimulator::HandleTrapdoor(int a_BlockX, int a_BlockY, i
-void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- bool m_bAreCoordsPowered = AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ);
+ bool m_bAreCoordsPowered = AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
if (m_bAreCoordsPowered)
{
- if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, true))
+ if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true))
{
class cSetPowerToNoteBlock :
public cNoteBlockCallback
@@ -954,15 +1050,17 @@ void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_BlockX, int a_BlockY,
}
} NoteBlockSP(m_bAreCoordsPowered);
- m_World.DoWithNoteBlockAt(a_BlockX, a_BlockY, a_BlockZ, NoteBlockSP);
- SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, true);
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ m_Chunk->DoWithNoteBlockAt(BlockX, a_RelBlockY, BlockZ, NoteBlockSP);
+ SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true);
}
}
else
{
- if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, false))
+ if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false))
{
- SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, false);
+ SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false);
}
}
}
@@ -971,21 +1069,25 @@ void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_BlockX, int a_BlockY,
-void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- int a_ChunkX, a_ChunkZ;
- cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, a_ChunkX, a_ChunkZ);
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX, BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ int ChunkX, ChunkZ;
+ cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
- if (!m_World.IsChunkLighted(a_ChunkX, a_ChunkZ))
+ if (!m_World.IsChunkLighted(ChunkX, ChunkZ))
{
- m_World.QueueLightChunk(a_ChunkX, a_ChunkZ);
+ m_World.QueueLightChunk(ChunkX, ChunkZ);
}
else
{
- NIBBLETYPE SkyLight = m_World.GetBlockSkyLight(a_BlockX, a_BlockY + 1, a_BlockZ) - m_World.GetSkyDarkness();
- if (SkyLight > 8)
+ if (m_Chunk->GetTimeAlteredLight(m_World.GetBlockSkyLight(BlockX, a_RelBlockY + 1, BlockZ)) > 8)
+ {
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+ }
+ else
{
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DAYLIGHT_SENSOR);
+ WakeUp(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
}
}
@@ -994,24 +1096,28 @@ void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_BlockX, int a_Blo
-void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyType)
+void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType)
{
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+
switch (a_MyType)
{
case E_BLOCK_STONE_PRESSURE_PLATE:
{
// MCS feature - stone pressure plates can only be triggered by players :D
- cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(a_BlockX + 0.5f, (float)a_BlockY, a_BlockZ + 0.5f), 0.5f, false);
+ cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, (float)a_RelBlockY, BlockZ + 0.5f), 0.5f, false);
if (a_Player != NULL)
{
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x1);
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_STONE_PRESSURE_PLATE);
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x1);
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM, a_MyType);
}
else
{
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x0);
- m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x0);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
break;
}
@@ -1035,7 +1141,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc
Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
double Distance = (EntityPos - BlockPos).Length();
- if (Distance <= 0.7)
+ if (Distance <= 0.5)
{
m_NumberOfEntities++;
}
@@ -1056,95 +1162,98 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc
int m_Z;
};
- cPressurePlateCallback PressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ);
- m_World.ForEachEntity(PressurePlateCallback);
+ cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ);
+ m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), PressurePlateCallback);
unsigned char Power;
- NIBBLETYPE Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
if (PressurePlateCallback.GetPowerLevel(Power))
{
if (Meta == E_META_PRESSURE_PLATE_RAISED)
{
- m_World.BroadcastSoundEffect("random.click", (int)((a_BlockX + 0.5) * 8.0), (int)((a_BlockY + 0.1) * 8.0), (int)((a_BlockZ + 0.5) * 8.0), 0.3F, 0.5F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F);
}
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType, Power);
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM, a_MyType);
}
else
{
if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
{
- m_World.BroadcastSoundEffect("random.click", (int)((a_BlockX + 0.5) * 8.0), (int)((a_BlockY + 0.1) * 8.0), (int)((a_BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F);
}
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_RAISED);
- m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
break;
}
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
- {class cPressurePlateCallback :
- public cEntityCallback
{
- public:
- cPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ) :
- m_NumberOfEntities(0),
- m_X(a_BlockX),
- m_Y(a_BlockY),
- m_Z(a_BlockZ)
- {
- }
-
- virtual bool Item(cEntity * a_Entity) override
+ class cPressurePlateCallback :
+ public cEntityCallback
{
- Vector3f EntityPos = a_Entity->GetPosition();
- Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
- double Distance = (EntityPos - BlockPos).Length();
+ public:
+ cPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ) :
+ m_NumberOfEntities(0),
+ m_X(a_BlockX),
+ m_Y(a_BlockY),
+ m_Z(a_BlockZ)
+ {
+ }
- if (Distance <= 0.7)
+ virtual bool Item(cEntity * a_Entity) override
{
- m_NumberOfEntities++;
+ Vector3f EntityPos = a_Entity->GetPosition();
+ Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
+ double Distance = (EntityPos - BlockPos).Length();
+
+ if (Distance <= 0.5)
+ {
+ m_NumberOfEntities++;
+ }
+ return false;
}
- return false;
- }
- bool GetPowerLevel(unsigned char & a_PowerLevel) const
- {
- a_PowerLevel = std::min((int)ceil(m_NumberOfEntities / (float)10), MAX_POWER_LEVEL);
- return (a_PowerLevel > 0);
- }
+ bool GetPowerLevel(unsigned char & a_PowerLevel) const
+ {
+ a_PowerLevel = std::min((int)ceil(m_NumberOfEntities / 10.f), MAX_POWER_LEVEL);
+ return (a_PowerLevel > 0);
+ }
- protected:
- int m_NumberOfEntities;
+ protected:
+ int m_NumberOfEntities;
- int m_X;
- int m_Y;
- int m_Z;
- };
+ int m_X;
+ int m_Y;
+ int m_Z;
+ };
- cPressurePlateCallback PressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ);
- m_World.ForEachEntity(PressurePlateCallback);
+ cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ);
+ m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), PressurePlateCallback);
- unsigned char Power;
- NIBBLETYPE Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if (PressurePlateCallback.GetPowerLevel(Power))
- {
- if (Meta == E_META_PRESSURE_PLATE_RAISED)
+ unsigned char Power;
+ NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+ if (PressurePlateCallback.GetPowerLevel(Power))
{
- m_World.BroadcastSoundEffect("random.click", (int)((a_BlockX + 0.5) * 8.0), (int)((a_BlockY + 0.1) * 8.0), (int)((a_BlockZ + 0.5) * 8.0), 0.3F, 0.5F);
+ if (Meta == E_META_PRESSURE_PLATE_RAISED)
+ {
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F);
+ }
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM, a_MyType);
}
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType, Power);
- }
- else
- {
- if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
+ else
{
- m_World.BroadcastSoundEffect("random.click", (int)((a_BlockX + 0.5) * 8.0), (int)((a_BlockY + 0.1) * 8.0), (int)((a_BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
+ if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
+ {
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F);
+ }
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_RAISED);
- m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
- }
break;
}
@@ -1168,10 +1277,10 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc
Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
double Distance = (EntityPos - BlockPos).Length();
- if (Distance <= 0.7)
+ if (Distance <= 0.5)
{
m_FoundEntity = true;
- return true; // Break out, we only need to know for plates that at least one entity is on top
+ return true; // Break out, we only need to know for plates that at least one entity is on top
}
return false;
}
@@ -1189,27 +1298,28 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc
int m_Z;
} ;
- cPressurePlateCallback PressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ);
- m_World.ForEachEntity(PressurePlateCallback);
+ cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ);
+ m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), PressurePlateCallback);
- NIBBLETYPE Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
if (PressurePlateCallback.FoundEntity())
{
if (Meta == E_META_PRESSURE_PLATE_RAISED)
{
- m_World.BroadcastSoundEffect("random.click", (int) ((a_BlockX + 0.5) * 8.0), (int) ((a_BlockY + 0.1) * 8.0), (int) ((a_BlockZ + 0.5) * 8.0), 0.3F, 0.5F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F);
}
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType);
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+ SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_YM, a_MyType);
}
else
{
if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
{
- m_World.BroadcastSoundEffect("random.click", (int) ((a_BlockX + 0.5) * 8.0), (int) ((a_BlockY + 0.1) * 8.0), (int) ((a_BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F);
}
- m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, E_META_PRESSURE_PLATE_RAISED);
- m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
break;
}
@@ -1225,27 +1335,204 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc
-bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
+ int RelX = a_RelBlockX, RelZ = a_RelBlockZ;
+ bool FoundActivated = false;
+ eBlockFace FaceToGoTowards = cBlockTripwireHookHandler::MetadataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ));
+
+ for (int i = 0; i < 40; ++i) // Tripwires can be connected up to 40 blocks
{
- if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ BLOCKTYPE Type;
+ NIBBLETYPE Meta;
+
+ AddFaceDirection(RelX, a_RelBlockY, RelZ, FaceToGoTowards);
+ m_Chunk->UnboundedRelGetBlock(RelX, a_RelBlockY, RelZ, Type, Meta);
+
+ if (Type == E_BLOCK_TRIPWIRE)
+ {
+ if (Meta == 0x1)
+ {
+ FoundActivated = true;
+ }
+ }
+ else if (Type == E_BLOCK_TRIPWIRE_HOOK)
+ {
+ if (ReverseBlockFace(cBlockTripwireHookHandler::MetadataToDirection(Meta)) == FaceToGoTowards)
+ {
+ // Other hook facing in opposite direction - circuit completed!
+ break;
+ }
+ else
+ {
+ // Tripwire hook not connected at all, AND away all the power state bits
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
+ return;
+ }
+ }
+ else
+ {
+ // Tripwire hook not connected at all, AND away all the power state bits
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
+ return;
+ }
+ }
+
+ if (FoundActivated)
+ {
+ // Connected and activated, set the 3rd and 4th highest bits
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) | 0xC);
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+ }
+ else
+ {
+ // Connected but not activated, AND away the highest bit
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7) | 0x4);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
+ }
+}
+
+
+
+
+
+void cIncrementalRedstoneSimulator::HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
+{
+ class cGetTrappedChestPlayers :
+ public cChestCallback
+ {
+ public:
+ cGetTrappedChestPlayers(void) :
+ m_NumberOfPlayers(0)
+ {
+ }
+
+ virtual bool Item(cChestEntity * a_Chest) override
+ {
+ ASSERT(a_Chest->GetBlockType() == E_BLOCK_TRAPPED_CHEST);
+ m_NumberOfPlayers = a_Chest->GetNumberOfPlayers();
+ return (m_NumberOfPlayers <= 0);
+ }
+
+ unsigned char GetPowerLevel(void) const
+ {
+ return std::min(m_NumberOfPlayers, MAX_POWER_LEVEL);
+ }
+
+ private:
+ int m_NumberOfPlayers;
+
+ } GTCP;
+
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
+ if (m_Chunk->DoWithChestAt(BlockX, a_RelBlockY, BlockZ, GTCP))
+ {
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, GTCP.GetPowerLevel());
+ }
+ else
+ {
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
+ }
+}
+
+
+
+
+
+void cIncrementalRedstoneSimulator::HandleTripwire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
+{
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
+
+ class cTripwireCallback :
+ public cEntityCallback
+ {
+ public:
+ cTripwireCallback(int a_BlockX, int a_BlockY, int a_BlockZ) :
+ m_FoundEntity(false),
+ m_X(a_BlockX),
+ m_Y(a_BlockY),
+ m_Z(a_BlockZ)
+ {
+ }
+
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ cBoundingBox bbWire(m_X, m_X + 1, m_Y, m_Y + 0.1, m_Z, m_Z + 1);
+ cBoundingBox bbEntity(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight());
+
+ if (bbEntity.DoesIntersect(bbWire))
+ {
+ m_FoundEntity = true;
+ return true; // One entity is sufficient to trigger the wire
+ }
+ return false;
+ }
+
+ bool FoundEntity(void) const
+ {
+ return m_FoundEntity;
+ }
+
+ protected:
+ bool m_FoundEntity;
+
+ int m_X;
+ int m_Y;
+ int m_Z;
+ };
+
+ cTripwireCallback TripwireCallback(BlockX, a_RelBlockY, BlockZ);
+ m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), TripwireCallback);
+
+ if (TripwireCallback.FoundEntity())
+ {
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x1);
+ }
+ else
+ {
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x0);
+ }
+}
+
+
+
+
+
+bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, cChunk * a_Chunk)
+{
+ // Torches want to access neighbour's data when on a wall, hence the extra chunk parameter
+
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+
+ for (PoweredBlocksList::const_iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end(); ++itr) // Check powered list
+ {
+ if (itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)))
{
return true;
}
}
- return false;
+ return false;
}
-bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ)
+bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+
+ for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list
{
- if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)))
{
return true;
}
@@ -1256,37 +1543,38 @@ bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_BlockX, int a_B
-// IsRepeaterPowered tests if a repeater should be powered by testing for power sources behind the repeater.
-// It takes the coordinates of the repeater the the meta value.
-bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta)
+
+bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta)
{
// Repeaters cannot be powered by any face except their back; verify that this is true for a source
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr)
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; }
+ if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; }
switch (a_Meta & 0x3)
{
case 0x0:
{
// Flip the coords to check the back of the repeater
- if (itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ + 1))) { return true; }
+ if (itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ + 1))) { return true; }
break;
}
case 0x1:
{
- if (itr->a_SourcePos.Equals(Vector3i(a_BlockX - 1, a_BlockY, a_BlockZ))) { return true; }
+ if (itr->a_SourcePos.Equals(Vector3i(BlockX - 1, a_RelBlockY, BlockZ))) { return true; }
break;
}
case 0x2:
{
- if (itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ - 1))) { return true; }
+ if (itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ - 1))) { return true; }
break;
}
case 0x3:
{
- if (itr->a_SourcePos.Equals(Vector3i(a_BlockX + 1, a_BlockY, a_BlockZ))) { return true; }
+ if (itr->a_SourcePos.Equals(Vector3i(BlockX + 1, a_RelBlockY, BlockZ))) { return true; }
break;
}
}
@@ -1294,59 +1582,60 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_BlockX, int a_BlockY
for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr)
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; }
+ if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; }
switch (a_Meta & 0x3)
{
case 0x0:
{
- if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ + 1))) { return true; }
+ if (itr->a_MiddlePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ + 1))) { return true; }
break;
}
case 0x1:
{
- if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX - 1, a_BlockY, a_BlockZ))) { return true; }
+ if (itr->a_MiddlePos.Equals(Vector3i(BlockX - 1, a_RelBlockY, BlockZ))) { return true; }
break;
}
case 0x2:
{
- if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ - 1))) { return true; }
+ if (itr->a_MiddlePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ - 1))) { return true; }
break;
}
case 0x3:
{
- if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX + 1, a_BlockY, a_BlockZ))) { return true; }
+ if (itr->a_MiddlePos.Equals(Vector3i(BlockX + 1, a_RelBlockY, BlockZ))) { return true; }
break;
}
}
}
- return false; // Couldn't find power source behind repeater
+ return false; // Couldn't find power source behind repeater
}
-bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta)
-{
- switch (a_Meta & 0x3) // We only want the 'direction' part of our metadata
+bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta)
+{
+ switch (a_Meta & 0x3) // We only want the 'direction' part of our metadata
{
// If the repeater is looking up or down (If parallel to the Z axis)
case 0x0:
case 0x2:
{
- // Check if eastern(right) neighbor is a powered on repeater who is facing us.
- if (m_World.GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) == E_BLOCK_REDSTONE_REPEATER_ON) // Is right neighbor a powered repeater?
+ // Check if eastern(right) neighbor is a powered on repeater who is facing us
+ BLOCKTYPE Block = 0;
+ if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater?
{
- NIBBLETYPE OtherRepeaterDir = m_World.GetBlockMeta(a_BlockX + 1, a_BlockY, a_BlockZ) & 0x3;
- if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked.
+ NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ) & 0x3;
+ if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked
}
- // Check if western(left) neighbor is a powered on repeater who is facing us.
- if (m_World.GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) == E_BLOCK_REDSTONE_REPEATER_ON)
+ // Check if western(left) neighbor is a powered on repeater who is facing us
+ if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
{
- NIBBLETYPE OtherRepeaterDir = m_World.GetBlockMeta(a_BlockX -1, a_BlockY, a_BlockZ) & 0x3;
- if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked.
+ NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX -1, a_RelBlockY, a_RelBlockZ) & 0x3;
+ if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked
}
break;
@@ -1356,205 +1645,232 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_BlockX, int a_BlockY,
case 0x1:
case 0x3:
{
- // Check if southern(down) neighbor is a powered on repeater who is facing us.
- if (m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) == E_BLOCK_REDSTONE_REPEATER_ON)
- {
- NIBBLETYPE OtherRepeaterDir = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ + 1) & 0x3;
- if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked.
+ // Check if southern(down) neighbor is a powered on repeater who is facing us
+ BLOCKTYPE Block = 0;
+ if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
+ {
+ NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1) & 0x3;
+ if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked
}
- // Check if northern(up) neighbor is a powered on repeater who is facing us.
- if (m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ -1) == E_BLOCK_REDSTONE_REPEATER_ON)
- {
- NIBBLETYPE OtherRepeaterDir = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ - 1) & 0x3;
- if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked.
+ // Check if northern(up) neighbor is a powered on repeater who is facing us
+ if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
+ {
+ NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1) & 0x3;
+ if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked
}
break;
}
}
- return false; // None of the checks succeeded, I am not a locked repeater.
+ return false; // None of the checks succeeded, I am not a locked repeater
}
-bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta)
+bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta)
{
// Pistons cannot be powered through their front face; this function verifies that a source meets this requirement
- int OldX = a_BlockX, OldY = a_BlockY, OldZ = a_BlockZ;
- eBlockFace Face = cPiston::MetaDataToDirection(a_Meta);
+ eBlockFace Face = cBlockPistonHandler::MetaDataToDirection(a_Meta);
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr)
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; }
+ if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; }
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face);
+ AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face);
- if (!itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (!itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)))
{
return true;
}
- a_BlockX = OldX;
- a_BlockY = OldY;
- a_BlockZ = OldZ;
+ AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face, true);
}
for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr)
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; }
+ if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; }
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face);
+ AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face);
- if (!itr->a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (!itr->a_MiddlePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)))
{
return true;
}
- a_BlockX = OldX;
- a_BlockY = OldY;
- a_BlockZ = OldZ;
+ AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face, true);
}
- return false; // Source was in front of the piston's front face
+ return false; // Source was in front of the piston's front face
}
-bool cIncrementalRedstoneSimulator::IsWirePowered(int a_BlockX, int a_BlockY, int a_BlockZ, unsigned char & a_PowerLevel)
+bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char & a_PowerLevel)
{
a_PowerLevel = 0;
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
- for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list
+ for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)))
{
continue;
}
- a_PowerLevel = std::max(a_PowerLevel, itr->a_PowerLevel);
+ a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel); // Get the highest power level (a_PowerLevel is initialised already and there CAN be multiple levels for one block)
}
- for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list
+ for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)))
{
continue;
}
- a_PowerLevel = std::max(a_PowerLevel, itr->a_PowerLevel);
+
+ BLOCKTYPE Type = E_BLOCK_AIR;
+ int RelSourceX = itr->a_SourcePos.x - m_Chunk->GetPosX() * cChunkDef::Width;
+ int RelSourceZ = itr->a_SourcePos.z - m_Chunk->GetPosZ() * cChunkDef::Width;
+ if (!m_Chunk->UnboundedRelGetBlockType(RelSourceX, itr->a_SourcePos.y, RelSourceZ, Type) || (Type == E_BLOCK_REDSTONE_WIRE))
+ {
+ continue;
+ }
+ a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel);
}
- return (a_PowerLevel != 0); // Source was in front of the piston's front face
+ return (a_PowerLevel != 0); // Answer the inital question: is the wire powered?
}
-bool cIncrementalRedstoneSimulator::AreCoordsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool IsCurrentStatePowered)
+bool cIncrementalRedstoneSimulator::AreCoordsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool IsCurrentStatePowered)
{
for (SimulatedPlayerToggleableList::const_iterator itr = m_SimulatedPlayerToggleableBlocks->begin(); itr != m_SimulatedPlayerToggleableBlocks->end(); ++itr)
{
- if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ)))
{
- if (itr->WasLastStatePowered != IsCurrentStatePowered) // Was the last power state different to the current?
+ if (itr->WasLastStatePowered != IsCurrentStatePowered) // Was the last power state different to the current?
{
- return false; // It was, coordinates are no longer simulated
+ return false; // It was, coordinates are no longer simulated
}
else
{
- return true; // It wasn't, don't resimulate block, and allow players to toggle
+ return true; // It wasn't, don't resimulate block, and allow players to toggle
}
}
}
- return false; // Block wasn't even in the list, not simulated
+ return false; // Block wasn't even in the list, not simulated
}
-void cIncrementalRedstoneSimulator::SetDirectionLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Direction, BLOCKTYPE a_SourceType, unsigned char a_PowerLevel)
+void cIncrementalRedstoneSimulator::SetDirectionLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, char a_Direction, unsigned char a_PowerLevel)
{
+ BLOCKTYPE MiddleBlock = 0;
switch (a_Direction)
{
case BLOCK_FACE_XM:
{
- BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ);
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, MiddleBlock))
+ {
+ return;
+ }
- SetBlockLinkedPowered(a_BlockX - 2, a_BlockY, a_BlockZ, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX - 1, a_BlockY + 1, a_BlockZ, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX - 1, a_BlockY - 1, a_BlockZ, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX - 1, a_BlockY, a_BlockZ + 1, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX - 1, a_BlockY, a_BlockZ - 1, a_BlockX - 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX - 2, a_RelBlockY, a_RelBlockZ, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
break;
}
case BLOCK_FACE_XP:
{
- BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ);
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, MiddleBlock))
+ {
+ return;
+ }
- SetBlockLinkedPowered(a_BlockX + 2, a_BlockY, a_BlockZ, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX + 1, a_BlockY + 1, a_BlockZ, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX + 1, a_BlockY - 1, a_BlockZ, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX + 1, a_BlockY, a_BlockZ + 1, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX + 1, a_BlockY, a_BlockZ - 1, a_BlockX + 1, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX + 2, a_RelBlockY, a_RelBlockZ, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
break;
}
case BLOCK_FACE_YM:
{
- BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ);
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, MiddleBlock))
+ {
+ return;
+ }
- SetBlockLinkedPowered(a_BlockX, a_BlockY - 2, a_BlockZ, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX + 1, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX - 1, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX, a_BlockY - 1, a_BlockZ + 1, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX, a_BlockY - 1, a_BlockZ - 1, a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 2, a_RelBlockZ, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
break;
}
case BLOCK_FACE_YP:
{
- BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ);
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, MiddleBlock))
+ {
+ return;
+ }
- SetBlockLinkedPowered(a_BlockX, a_BlockY + 2, a_BlockZ, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX + 1, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX - 1, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX, a_BlockY + 1, a_BlockZ + 1, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX, a_BlockY + 1, a_BlockZ - 1, a_BlockX, a_BlockY + 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 2, a_RelBlockZ, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
break;
}
case BLOCK_FACE_ZM:
{
- BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1);
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, MiddleBlock))
+ {
+ return;
+ }
- SetBlockLinkedPowered(a_BlockX, a_BlockY, a_BlockZ - 2, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX + 1, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX - 1, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX, a_BlockY + 1, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX, a_BlockY - 1, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ - 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 2, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
break;
}
case BLOCK_FACE_ZP:
{
- BLOCKTYPE MiddleBlock = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1);
+ if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, MiddleBlock))
+ {
+ return;
+ }
- SetBlockLinkedPowered(a_BlockX, a_BlockY, a_BlockZ + 2, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX + 1, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX - 1, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX, a_BlockY + 1, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
- SetBlockLinkedPowered(a_BlockX, a_BlockY - 1, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ + 1, a_BlockX, a_BlockY, a_BlockZ, a_SourceType, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 2, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY + 1, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
+ SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
break;
}
default:
{
- ASSERT(!"Unhandled face direction when attempting to set blocks as linked powered!"); // Zombies, that wasn't supposed to happen...
+ ASSERT(!"Unhandled face direction when attempting to set blocks as linked powered!"); // Zombies, that wasn't supposed to happen...
break;
}
}
@@ -1564,7 +1880,7 @@ void cIncrementalRedstoneSimulator::SetDirectionLinkedPowered(int a_BlockX, int
-void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel)
+void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char a_PowerLevel)
{
static const struct
{
@@ -1572,16 +1888,16 @@ void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_BlockX, int a_Bloc
} gCrossCoords[] =
{
{ 1, 0, 0 },
- {-1, 0, 0 },
+ { -1, 0, 0 },
{ 0, 0, 1 },
- { 0, 0,-1 },
+ { 0, 0, -1 },
{ 0, 1, 0 },
- { 0,-1, 0 }
+ { 0, -1, 0 }
};
- for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through struct to power all directions
+ for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through struct to power all directions
{
- SetBlockPowered(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y, a_BlockZ + gCrossCoords[i].z, a_BlockX, a_BlockY, a_BlockZ, a_SourceBlock, a_PowerLevel);
+ SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_PowerLevel);
}
}
@@ -1589,50 +1905,70 @@ void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_BlockX, int a_Bloc
-void cIncrementalRedstoneSimulator::SetBlockPowered(int a_BlockX, int a_BlockY, int a_BlockZ, int a_SourceX, int a_SourceY, int a_SourceZ, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel)
+void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, unsigned char a_PowerLevel)
{
- BLOCKTYPE Block = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- if (Block == E_BLOCK_AIR)
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX;
+ int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ;
+
+ cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values
+ if ((Neighbour == NULL) || !Neighbour->IsValid())
{
- // Don't set air, fixes some bugs (wires powering themselves)
return;
}
- PoweredBlocksList * Powered = m_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ)->GetRedstoneSimulatorPoweredBlocksList();
- for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list
+ PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); // We need to insert the value into the chunk who owns the block position
+ for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr)
{
if (
- itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)) &&
- itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ))
- )
+ itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) &&
+ itr->a_SourcePos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ))
+ )
{
- // Check for duplicates, update power level if everything else the same but either way, don't add a new listing
- if (itr->a_PowerLevel != a_PowerLevel)
- {
- itr->a_PowerLevel = a_PowerLevel;
- }
+ // Check for duplicates, update power level, don't add a new listing
+ itr->a_PowerLevel = a_PowerLevel;
return;
}
}
- PoweredBlocksList * OtherPowered = m_Chunk->GetNeighborChunk(a_SourceX, a_SourceZ)->GetRedstoneSimulatorPoweredBlocksList();
- for (PoweredBlocksList::const_iterator itr = OtherPowered->begin(); itr != OtherPowered->end(); ++itr) // Check powered list
+ // No need to get neighbouring chunk as we can guarantee that when something is powering us, the entry will be in our chunk
+ // TODO: on C++11 support, change this to a llama function pased to a std::remove_if
+ for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr)
{
if (
- itr->a_BlockPos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ)) &&
- itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))
- )
+ itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) &&
+ itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) &&
+ (m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE)
+ )
{
- // Powered wires try to power their source - don't let them!
- return;
+ BLOCKTYPE Block;
+ NIBBLETYPE Meta;
+ Neighbour->GetBlockTypeMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block, Meta);
+
+ if (Block == E_BLOCK_REDSTONE_WIRE)
+ {
+ if (Meta < a_PowerLevel)
+ {
+ m_PoweredBlocks->erase(itr); // Powering source with higher power level, allow it
+ break;
+ }
+ else
+ {
+ // Powered wires try to power their source - don't let them!
+ return;
+ }
+ }
}
}
sPoweredBlocks RC;
- RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ);
- RC.a_SourcePos = Vector3i(a_SourceX, a_SourceY, a_SourceZ);
+ RC.a_BlockPos = Vector3i(BlockX, a_RelBlockY, BlockZ);
+ RC.a_SourcePos = Vector3i(SourceX, a_RelSourceY, SourceZ);
RC.a_PowerLevel = a_PowerLevel;
Powered->push_back(RC);
+ Neighbour->SetIsRedstoneDirty(true);
+ m_Chunk->SetIsRedstoneDirty(true);
}
@@ -1640,58 +1976,64 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_BlockX, int a_BlockY,
void cIncrementalRedstoneSimulator::SetBlockLinkedPowered(
- int a_BlockX, int a_BlockY, int a_BlockZ,
- int a_MiddleX, int a_MiddleY, int a_MiddleZ,
- int a_SourceX, int a_SourceY, int a_SourceZ,
- BLOCKTYPE a_SourceBlock, BLOCKTYPE a_MiddleBlock, unsigned char a_PowerLevel
-)
+ int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ,
+ int a_RelMiddleX, int a_RelMiddleY, int a_RelMiddleZ,
+ int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ,
+ BLOCKTYPE a_MiddleBlock, unsigned char a_PowerLevel
+ )
{
- BLOCKTYPE DestBlock = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- if (DestBlock == E_BLOCK_AIR)
+ int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
+ int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ int MiddleX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelMiddleX;
+ int MiddleZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelMiddleZ;
+ int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX;
+ int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ;
+
+ if (!IsViableMiddleBlock(a_MiddleBlock))
{
- // Don't set air, fixes some bugs (wires powering themselves)
return;
}
- if (!IsViableMiddleBlock(a_MiddleBlock))
+
+ cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ);
+ if ((Neighbour == NULL) || !Neighbour->IsValid())
{
return;
}
- LinkedBlocksList * Linked = m_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ)->GetRedstoneSimulatorLinkedBlocksList();
+ LinkedBlocksList * Linked = Neighbour->GetRedstoneSimulatorLinkedBlocksList();
for (LinkedBlocksList::iterator itr = Linked->begin(); itr != Linked->end(); ++itr) // Check linked powered list
{
if (
- itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)) &&
- itr->a_MiddlePos.Equals(Vector3i(a_MiddleX, a_MiddleY, a_MiddleZ)) &&
- itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ))
+ itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) &&
+ itr->a_MiddlePos.Equals(Vector3i(MiddleX, a_RelMiddleY, MiddleZ)) &&
+ itr->a_SourcePos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ))
)
{
- // Check for duplicates, update power level if everything else the same but either way, don't add a new listing
- if (itr->a_PowerLevel != a_PowerLevel)
- {
- itr->a_PowerLevel = a_PowerLevel;
- }
+ // Check for duplicates, update power level, don't add a new listing
+ itr->a_PowerLevel = a_PowerLevel;
return;
}
}
sLinkedPoweredBlocks RC;
- RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ);
- RC.a_MiddlePos = Vector3i(a_MiddleX, a_MiddleY, a_MiddleZ);
- RC.a_SourcePos = Vector3i(a_SourceX, a_SourceY, a_SourceZ);
+ RC.a_BlockPos = Vector3i(BlockX, a_RelBlockY, BlockZ);
+ RC.a_MiddlePos = Vector3i(MiddleX, a_RelMiddleY, MiddleZ);
+ RC.a_SourcePos = Vector3i(SourceX, a_RelSourceY, SourceZ);
RC.a_PowerLevel = a_PowerLevel;
Linked->push_back(RC);
+ Neighbour->SetIsRedstoneDirty(true);
+ m_Chunk->SetIsRedstoneDirty(true);
}
-void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool WasLastStatePowered)
+void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool WasLastStatePowered)
{
for (SimulatedPlayerToggleableList::iterator itr = m_SimulatedPlayerToggleableBlocks->begin(); itr != m_SimulatedPlayerToggleableBlocks->end(); ++itr)
{
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (!itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ)))
{
continue;
}
@@ -1711,7 +2053,7 @@ void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_Bl
// We have arrive here; no block must be in list - add one
sSimulatedPlayerToggleableList RC;
- RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ);
+ RC.a_RelBlockPos = Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
RC.WasLastStatePowered = WasLastStatePowered;
m_SimulatedPlayerToggleableBlocks->push_back(RC);
}
@@ -1720,89 +2062,147 @@ void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_Bl
-void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn)
+bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn)
{
for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); ++itr)
{
- if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ)))
{
- if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry
+ if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry
{
- return;
+ return false;
}
// Already in here (normal to allow repeater to continue on powering and updating blocks in front) - just update info and quit
- itr->a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; // See below for description
+ itr->a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; // See below for description
itr->a_ElapsedTicks = 0;
itr->ShouldPowerOn = ShouldPowerOn;
- return;
+ return false;
}
}
// Self not in list, add self to list
- sRepeatersDelayList RC;
- RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ);
+ sRepeatersDelayList RC;
+ RC.a_RelBlockPos = Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
// Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.)
- // * 2 because in MCS, 1 redstone tick = 1 world tick, but in Vanilla, 1 redstone tick = 2 world ticks, and we need to maintain compatibility
+ // Multiply by 2 because in MCS, 1 redstone tick = 1 world tick, but in Vanilla, 1 redstone tick = 2 world ticks, and we need to maintain compatibility
RC.a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2;
RC.a_ElapsedTicks = 0;
RC.ShouldPowerOn = ShouldPowerOn;
m_RepeatersDelayList->push_back(RC);
- return;
+ return true;
}
-cIncrementalRedstoneSimulator::eRedstoneDirection cIncrementalRedstoneSimulator::GetWireDirection(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cIncrementalRedstoneSimulator::SetSourceUnpowered(int a_SourceX, int a_SourceY, int a_SourceZ, cChunk * a_Chunk, bool a_IsFirstCall)
{
- int Dir = REDSTONE_NONE;
+ if (!a_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid
+ {
+ if ((a_Chunk == NULL) || !a_Chunk->IsValid())
+ {
+ return;
+ }
+ }
+ // TODO: on C++11 support, change both of these to llama functions pased to a std::remove_if
- BLOCKTYPE NegX = m_World.GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ);
- if (IsPotentialSource(NegX))
+ for (PoweredBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end();)
+ {
+ if (itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ)))
+ {
+ itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->erase(itr);
+ a_Chunk->SetIsRedstoneDirty(true);
+ continue;
+ }
+ ++itr;
+ }
+ for (LinkedBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorLinkedBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorLinkedBlocksList()->end();)
{
- Dir |= (REDSTONE_X_POS);
+ if (itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ)))
+ {
+ itr = a_Chunk->GetRedstoneSimulatorLinkedBlocksList()->erase(itr);
+ a_Chunk->SetIsRedstoneDirty(true);
+ continue;
+ }
+ ++itr;
}
-
- BLOCKTYPE PosX = m_World.GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ);
- if (IsPotentialSource(PosX))
+
+ if (a_IsFirstCall && AreCoordsOnChunkBoundary(a_SourceX, a_SourceY, a_SourceZ))
{
- Dir |= (REDSTONE_X_NEG);
+ // +- 2 to accomodate linked powered blocks
+ SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX - 2, a_SourceZ), false);
+ SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX + 2, a_SourceZ), false);
+ SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX, a_SourceZ - 2), false);
+ SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX, a_SourceZ + 2), false);
}
-
- BLOCKTYPE NegZ = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1);
- if (IsPotentialSource(NegZ))
+}
+
+
+
+
+
+cIncrementalRedstoneSimulator::eRedstoneDirection cIncrementalRedstoneSimulator::GetWireDirection(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
+{
+ int Dir = REDSTONE_NONE;
+
+ BLOCKTYPE NegX = 0;
+ if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, NegX))
{
- if ((Dir & REDSTONE_X_POS) && !(Dir & REDSTONE_X_NEG)) // corner
+ if (IsPotentialSource(NegX))
{
- Dir ^= REDSTONE_X_POS;
- Dir |= REDSTONE_X_NEG;
+ Dir |= (REDSTONE_X_POS);
}
- if ((Dir & REDSTONE_X_NEG) && !(Dir & REDSTONE_X_POS)) // corner
+ }
+
+ BLOCKTYPE PosX = 0;
+ if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, PosX))
+ {
+ if (IsPotentialSource(PosX))
{
- Dir ^= REDSTONE_X_NEG;
- Dir |= REDSTONE_X_POS;
+ Dir |= (REDSTONE_X_NEG);
}
- Dir |= REDSTONE_Z_POS;
}
- BLOCKTYPE PosZ = m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1);
- if (IsPotentialSource(PosZ))
+ BLOCKTYPE NegZ = 0;
+ if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, NegZ))
{
- if ((Dir & REDSTONE_X_POS) && !(Dir & REDSTONE_X_NEG)) // corner
+ if (IsPotentialSource(NegZ))
{
- Dir ^= REDSTONE_X_POS;
- Dir |= REDSTONE_X_NEG;
+ if ((Dir & REDSTONE_X_POS) && !(Dir & REDSTONE_X_NEG)) // corner
+ {
+ Dir ^= REDSTONE_X_POS;
+ Dir |= REDSTONE_X_NEG;
+ }
+ if ((Dir & REDSTONE_X_NEG) && !(Dir & REDSTONE_X_POS)) // corner
+ {
+ Dir ^= REDSTONE_X_NEG;
+ Dir |= REDSTONE_X_POS;
+ }
+ Dir |= REDSTONE_Z_POS;
}
- if ((Dir & REDSTONE_X_NEG) && !(Dir & REDSTONE_X_POS)) // corner
+ }
+
+ BLOCKTYPE PosZ = 0;
+ if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, PosZ))
+ {
+ if (IsPotentialSource(PosZ))
{
- Dir ^= REDSTONE_X_NEG;
- Dir |= REDSTONE_X_POS;
+ if ((Dir & REDSTONE_X_POS) && !(Dir & REDSTONE_X_NEG)) // corner
+ {
+ Dir ^= REDSTONE_X_POS;
+ Dir |= REDSTONE_X_NEG;
+ }
+ if ((Dir & REDSTONE_X_NEG) && !(Dir & REDSTONE_X_POS)) // corner
+ {
+ Dir ^= REDSTONE_X_NEG;
+ Dir |= REDSTONE_X_POS;
+ }
+ Dir |= REDSTONE_Z_NEG;
}
- Dir |= REDSTONE_Z_NEG;
}
return (eRedstoneDirection)Dir;
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h
index a42cce79a..79740a8f6 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.h
+++ b/src/Simulator/IncrementalRedstoneSimulator.h
@@ -38,33 +38,33 @@ private:
#define MAX_POWER_LEVEL 15
- struct sPoweredBlocks // Define structure of the directly powered blocks list
+ struct sPoweredBlocks // Define structure of the directly powered blocks list
{
- Vector3i a_BlockPos; // Position of powered block
- Vector3i a_SourcePos; // Position of source powering the block at a_BlockPos
+ Vector3i a_BlockPos; // Position of powered block
+ Vector3i a_SourcePos; // Position of source powering the block at a_BlockPos
unsigned char a_PowerLevel;
};
- struct sLinkedPoweredBlocks // Define structure of the indirectly powered blocks list (i.e. repeaters powering through a block to the block at the other side)
+ struct sLinkedPoweredBlocks // Define structure of the indirectly powered blocks list (i.e. repeaters powering through a block to the block at the other side)
{
Vector3i a_BlockPos;
- Vector3i a_MiddlePos; // Position of block that is betwixt a source and the destination
+ Vector3i a_MiddlePos; // Position of block that is betwixt a source and the destination
Vector3i a_SourcePos;
unsigned char a_PowerLevel;
};
- struct sSimulatedPlayerToggleableList // Define structure of the list containing simulate-on-update blocks (such as trapdoors that respond once to a block update, and can be toggled by a player)
+ struct sSimulatedPlayerToggleableList // Define structure of the list containing simulate-on-update blocks (such as trapdoors that respond once to a block update, and can be toggled by a player)
{
- Vector3i a_BlockPos;
- bool WasLastStatePowered; // Was the last state powered or not? Determines whether a source update has happened and if I should resimulate
+ Vector3i a_RelBlockPos;
+ bool WasLastStatePowered; // Was the last state powered or not? Determines whether a source update has happened and if I should resimulate
};
- struct sRepeatersDelayList // Define structure of list containing repeaters' delay states
+ struct sRepeatersDelayList // Define structure of list containing repeaters' delay states
{
- Vector3i a_BlockPos;
- unsigned char a_DelayTicks; // For how many ticks should the repeater delay
- unsigned char a_ElapsedTicks; // How much of the previous has been elapsed?
- bool ShouldPowerOn; // What happens when the delay time is fulfilled?
+ Vector3i a_RelBlockPos;
+ unsigned char a_DelayTicks; // For how many ticks should the repeater delay
+ unsigned char a_ElapsedTicks; // How much of the previous has been elapsed?
+ bool ShouldPowerOn; // What happens when the delay time is fulfilled?
};
public:
@@ -91,81 +91,95 @@ private:
/* ====== SOURCES ====== */
/** Handles the redstone torch */
- void HandleRedstoneTorch(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState);
+ void HandleRedstoneTorch(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState);
/** Handles the redstone block */
- void HandleRedstoneBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleRedstoneBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles levers */
- void HandleRedstoneLever(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleRedstoneLever(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles buttons */
- void HandleRedstoneButton(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType);
+ void HandleRedstoneButton(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles daylight sensors */
- void HandleDaylightSensor(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleDaylightSensor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles pressure plates */
- void HandlePressurePlate(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyType);
+ void HandlePressurePlate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType);
+ /** Handles tripwire hooks
+ Performs correct meta and power setting for self by going in the direction it faces and looking for a continous line of tripwire bounded by another oppositely facing hook
+ If this line is complete, it verifies that at least on wire reports an entity is on top (via its meta), and performs its task
+ */
+ void HandleTripwireHook(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
+ /** Handles trapped chests */
+ void HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/* ==================== */
/* ====== CARRIERS ====== */
/** Handles redstone wire */
- void HandleRedstoneWire(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles repeaters */
- void HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState);
+ void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState);
/* ====================== */
/* ====== DEVICES ====== */
/** Handles pistons */
- void HandlePiston(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandlePiston(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles dispensers and droppers */
- void HandleDropSpenser(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleDropSpenser(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles TNT (exploding) */
- void HandleTNT(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleTNT(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles redstone lamps */
- void HandleRedstoneLamp(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyState);
+ void HandleRedstoneLamp(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState);
/** Handles doords */
- void HandleDoor(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleDoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles command blocks */
- void HandleCommandBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleCommandBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles activator, detector, and powered rails */
- void HandleRail(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyType);
+ void HandleRail(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType);
/** Handles trapdoors */
- void HandleTrapdoor(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleTrapdoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles fence gates */
- void HandleFenceGate(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleFenceGate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles noteblocks */
- void HandleNoteBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
+ void HandleNoteBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
+ /** Handles tripwires */
+ void HandleTripwire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/* ===================== */
/* ====== Helper functions ====== */
/** Marks a block as powered */
- void SetBlockPowered(int a_BlockX, int a_BlockY, int a_BlockZ, int a_SourceX, int a_SourceY, int a_SourceZ, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
+ void SetBlockPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
/** Marks a block as being powered through another block */
- void SetBlockLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ, int a_MiddleX, int a_MiddleY, int a_MiddleZ, int a_SourceX, int a_SourceY, int a_SourceZ, BLOCKTYPE a_SourceBlock, BLOCKTYPE a_MiddeBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
+ void SetBlockLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelMiddleX, int a_RelMiddleY, int a_RelMiddleZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, BLOCKTYPE a_MiddeBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
/** Marks a block as simulated, who should not be simulated further unless their power state changes, to accomodate a player manually toggling the block without triggering the simulator toggling it back */
- void SetPlayerToggleableBlockAsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool WasLastStatePowered);
+ void SetPlayerToggleableBlockAsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool WasLastStatePowered);
/** Marks the second block in a direction as linked powered */
- void SetDirectionLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Direction, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
+ void SetDirectionLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, char a_Direction, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
/** Marks all blocks immediately surrounding a coordinate as powered */
- void SetAllDirsAsPowered(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_SourceBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
- /** Queues a repeater to be powered or unpowered */
- void QueueRepeaterPowerChange(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn);
+ void SetAllDirsAsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
+ /** Queues a repeater to be powered or unpowered and returns if the m_RepeatersDelayList iterators were invalidated */
+ bool QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn);
+ /** Removes a block from the Powered and LinkedPowered lists
+ Used for variable sources such as tripwire hooks, daylight sensors, and trapped chests
+ */
+ void SetSourceUnpowered(int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, cChunk * a_Chunk, bool a_IsFirstCall = true);
/** Returns if a coordinate is powered or linked powered */
- bool AreCoordsPowered(int a_BlockX, int a_BlockY, int a_BlockZ) { return AreCoordsDirectlyPowered(a_BlockX, a_BlockY, a_BlockZ) || AreCoordsLinkedPowered(a_BlockX, a_BlockY, a_BlockZ); }
+ bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); }
/** Returns if a coordinate is in the directly powered blocks list */
- bool AreCoordsDirectlyPowered(int a_BlockX, int a_BlockY, int a_BlockZ);
+ bool AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, cChunk * a_Chunk);
/** Returns if a coordinate is in the indirectly powered blocks list */
- bool AreCoordsLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ);
+ bool AreCoordsLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Returns if a coordinate was marked as simulated (for blocks toggleable by players) */
- bool AreCoordsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool IsCurrentStatePowered);
- /** Returns if a repeater is powered */
- bool IsRepeaterPowered(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta);
+ bool AreCoordsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool IsCurrentStatePowered);
+ /** Returns if a repeater is powered by testing for power sources behind the repeater */
+ bool IsRepeaterPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta);
/** Returns if a repeater is locked */
- bool IsRepeaterLocked(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta);
+ bool IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta);
/** Returns if a piston is powered */
- bool IsPistonPowered(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta);
+ bool IsPistonPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta);
/** Returns if a wire is powered
The only diffence between this and a normal AreCoordsPowered is that this function checks for a wire powering another wire */
- bool IsWirePowered(int a_BlockX, int a_BlockY, int a_BlockZ, unsigned char & a_PowerLevel);
-
+ bool IsWirePowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char & a_PowerLevel);
+ /** Handles delayed updates to repeaters **/
+ void HandleRedstoneRepeaterDelays(void);
/** Returns if lever metadata marks it as emitting power */
bool IsLeverOn(NIBBLETYPE a_BlockMeta);
@@ -177,7 +191,9 @@ private:
/** Returns if a block is viable to be the MiddleBlock of a SetLinkedPowered operation */
inline static bool IsViableMiddleBlock(BLOCKTYPE Block) { return cBlockInfo::FullyOccupiesVoxel(Block); }
- /** Returns if a block is a mechanism (something that accepts power and does something) */
+ /** Returns if a block is a mechanism (something that accepts power and does something)
+ Used by torches to determine if they power a block whilst not standing on the ground
+ */
inline static bool IsMechanism(BLOCKTYPE Block)
{
switch (Block)
@@ -200,6 +216,7 @@ private:
case E_BLOCK_REDSTONE_REPEATER_OFF:
case E_BLOCK_REDSTONE_REPEATER_ON:
case E_BLOCK_POWERED_RAIL:
+ case E_BLOCK_REDSTONE_WIRE:
{
return true;
}
@@ -226,6 +243,7 @@ private:
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
case E_BLOCK_STONE_PRESSURE_PLATE:
case E_BLOCK_WOODEN_PRESSURE_PLATE:
+ case E_BLOCK_TRAPPED_CHEST:
{
return true;
}
@@ -268,17 +286,29 @@ private:
case E_BLOCK_STONE_PRESSURE_PLATE:
case E_BLOCK_TNT:
case E_BLOCK_TRAPDOOR:
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_TRIPWIRE_HOOK:
+ case E_BLOCK_TRIPWIRE:
case E_BLOCK_WOODEN_BUTTON:
case E_BLOCK_WOODEN_DOOR:
case E_BLOCK_WOODEN_PRESSURE_PLATE:
case E_BLOCK_PISTON:
{
- return true;
+ return true;
}
default: return false;
}
}
+
+ inline static bool AreCoordsOnChunkBoundary(int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ return ( // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks
+ ((a_BlockX % cChunkDef::Width) <= 1) ||
+ ((a_BlockX % cChunkDef::Width) >= 14) ||
+ ((a_BlockZ % cChunkDef::Width) <= 1) ||
+ ((a_BlockZ % cChunkDef::Width) >= 14)
+ );
+ }
};
diff --git a/src/Simulator/NoopFluidSimulator.h b/src/Simulator/NoopFluidSimulator.h
index 9113aec3c..9fe2f9040 100644
--- a/src/Simulator/NoopFluidSimulator.h
+++ b/src/Simulator/NoopFluidSimulator.h
@@ -27,7 +27,7 @@ public:
}
// cSimulator overrides:
- virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override
+ virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override
{
UNUSED(a_BlockX);
UNUSED(a_BlockY);
diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h
index fe3949198..f9ed47982 100644
--- a/src/Simulator/NoopRedstoneSimulator.h
+++ b/src/Simulator/NoopRedstoneSimulator.h
@@ -18,17 +18,17 @@ public:
{
}
- //~cRedstoneNoopSimulator();
+ // ~cRedstoneNoopSimulator();
virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used
- virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override
+ virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override
{
UNUSED(a_Dt);
UNUSED(a_ChunkX);
UNUSED(a_ChunkZ);
UNUSED(a_Chunk);
}
- virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override { return false; }
+ virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType) override { return false; }
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override
{
UNUSED(a_BlockX);
diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp
index f305ba61a..1380f8841 100644
--- a/src/Simulator/SandSimulator.cpp
+++ b/src/Simulator/SandSimulator.cpp
@@ -60,11 +60,11 @@ void cSandSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
);
*/
cFallingBlock * FallingBlock = new cFallingBlock(Pos, BlockType, a_Chunk->GetMeta(itr->x, itr->y, itr->z));
- FallingBlock->Initialize(&m_World);
+ FallingBlock->Initialize(m_World);
a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0);
}
}
- m_TotalBlocks -= ChunkData.size();
+ m_TotalBlocks -= (int)ChunkData.size();
ChunkData.clear();
}
@@ -254,6 +254,10 @@ void cSandSimulator::FinishFalling(
{
// Rematerialize the material here:
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FallingBlockType, a_FallingBlockMeta);
+ if (a_FallingBlockType == E_BLOCK_ANVIL)
+ {
+ a_World->BroadcastSoundParticleEffect(1022, a_BlockX, a_BlockY, a_BlockZ, 0);
+ }
return;
}
diff --git a/src/Simulator/SandSimulator.h b/src/Simulator/SandSimulator.h
index 6e64aa425..1262f2792 100644
--- a/src/Simulator/SandSimulator.h
+++ b/src/Simulator/SandSimulator.h
@@ -37,7 +37,7 @@ public:
based on the block currently present in the world at the dest specified coords
*/
static void FinishFalling(
- cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ,
+ cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ,
BLOCKTYPE a_FallingBlockType, NIBBLETYPE a_FallingBlockMeta
);
diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h
index a2e2a5742..4d9a18867 100644
--- a/src/Simulator/Simulator.h
+++ b/src/Simulator/Simulator.h
@@ -26,13 +26,13 @@ public:
/// Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct access to chunk data available
virtual void SimulateChunk(float a_Dt, int a_ChunkX,
- int a_ChunkZ, cChunk * a_Chunk)
+ int a_ChunkZ, cChunk * a_Chunk)
{
UNUSED(a_Dt);
UNUSED(a_ChunkX);
UNUSED(a_ChunkZ);
UNUSED(a_Chunk);
- };
+ }
/// Called when a block changes
virtual void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk);
diff --git a/src/Simulator/SimulatorManager.cpp b/src/Simulator/SimulatorManager.cpp
index 2bc483cbd..918bac7a1 100644
--- a/src/Simulator/SimulatorManager.cpp
+++ b/src/Simulator/SimulatorManager.cpp
@@ -29,7 +29,7 @@ cSimulatorManager::~cSimulatorManager()
void cSimulatorManager::Simulate(float a_Dt)
{
m_Ticks++;
- for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr )
+ for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr)
{
if ((m_Ticks % itr->second) == 0)
{
@@ -45,7 +45,7 @@ void cSimulatorManager::Simulate(float a_Dt)
void cSimulatorManager::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{
// m_Ticks has already been increased in Simulate()
- for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr )
+ for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr)
{
if ((m_Ticks % itr->second) == 0)
{
@@ -60,7 +60,7 @@ void cSimulatorManager::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cC
void cSimulatorManager::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
{
- for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr )
+ for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr)
{
itr->first->WakeUp(a_BlockX, a_BlockY, a_BlockZ, a_Chunk);
}
diff --git a/src/Simulator/VanillaFluidSimulator.cpp b/src/Simulator/VanillaFluidSimulator.cpp
index 78aff9d68..18d9b07e1 100644
--- a/src/Simulator/VanillaFluidSimulator.cpp
+++ b/src/Simulator/VanillaFluidSimulator.cpp
@@ -35,14 +35,16 @@ cVanillaFluidSimulator::cVanillaFluidSimulator(
-void cVanillaFluidSimulator::Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta)
+void cVanillaFluidSimulator::SpreadXZ(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta)
{
+ // Calculate the distance to the nearest "hole" in each direction:
int Cost[4];
Cost[0] = CalculateFlowCost(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, X_PLUS);
Cost[1] = CalculateFlowCost(a_Chunk, a_RelX - 1, a_RelY, a_RelZ, X_MINUS);
Cost[2] = CalculateFlowCost(a_Chunk, a_RelX, a_RelY, a_RelZ + 1, Z_PLUS);
Cost[3] = CalculateFlowCost(a_Chunk, a_RelX, a_RelY, a_RelZ - 1, Z_MINUS);
+ // Find the minimum distance:
int MinCost = InfiniteCost;
for (unsigned int i = 0; i < ARRAYCOUNT(Cost); ++i)
{
@@ -52,6 +54,7 @@ void cVanillaFluidSimulator::Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, in
}
}
+ // Spread in all directions where the distance matches the minimum:
if (Cost[0] == MinCost)
{
SpreadToNeighbor(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, a_NewMeta);
@@ -86,7 +89,10 @@ int cVanillaFluidSimulator::CalculateFlowCost(cChunk * a_Chunk, int a_RelX, int
{
return Cost;
}
- if (!IsPassableForFluid(BlockType) && !IsBlockLiquid(BlockType))
+ if (
+ !IsPassableForFluid(BlockType) || // The block cannot be passed by the liquid ...
+ (IsAllowedBlock(BlockType) && (BlockMeta == 0)) // ... or if it is liquid, it is a source block
+ )
{
return Cost;
}
diff --git a/src/Simulator/VanillaFluidSimulator.h b/src/Simulator/VanillaFluidSimulator.h
index a9ea98b5a..89a56ca14 100644
--- a/src/Simulator/VanillaFluidSimulator.h
+++ b/src/Simulator/VanillaFluidSimulator.h
@@ -30,7 +30,7 @@ public:
protected:
// cFloodyFluidSimulator overrides:
- virtual void Spread(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta) override;
+ virtual void SpreadXZ(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta) override;
/** Recursively calculates the minimum number of blocks needed to descend a level. */
int CalculateFlowCost(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, Direction a_Dir, unsigned a_Iteration = 0);
diff --git a/src/Simulator/VaporizeFluidSimulator.cpp b/src/Simulator/VaporizeFluidSimulator.cpp
index 4206c64d1..484cac334 100644
--- a/src/Simulator/VaporizeFluidSimulator.cpp
+++ b/src/Simulator/VaporizeFluidSimulator.cpp
@@ -27,7 +27,7 @@ void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ,
return;
}
int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
+ int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
if (
(BlockType == m_FluidBlock) ||
@@ -35,7 +35,7 @@ void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ,
)
{
a_Chunk->SetBlock(RelX, a_BlockY, RelZ, E_BLOCK_AIR, 0);
- a_Chunk->BroadcastSoundEffect("random.fizz", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.6f);
+ a_Chunk->BroadcastSoundEffect("random.fizz", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.6f);
}
}
diff --git a/src/Statistics.cpp b/src/Statistics.cpp
index 2c980d98e..e0c0dd925 100644
--- a/src/Statistics.cpp
+++ b/src/Statistics.cpp
@@ -7,63 +7,65 @@
-cStatInfo cStatInfo::ms_Info[statCount] = {
+cStatInfo cStatInfo::ms_Info[statCount] =
+{
// The order must match the order of enum eStatistic
// http://minecraft.gamepedia.com/Achievements
/* Type | Name | Prerequisite */
- cStatInfo(achOpenInv, "openInventory"),
- cStatInfo(achMineWood, "mineWood", achOpenInv),
- cStatInfo(achCraftWorkbench, "buildWorkBench", achMineWood),
- cStatInfo(achCraftPickaxe, "buildPickaxe", achCraftWorkbench),
- cStatInfo(achCraftFurnace, "buildFurnace", achCraftPickaxe),
- cStatInfo(achAcquireIron, "acquireIron", achCraftFurnace),
- cStatInfo(achCraftHoe, "buildHoe", achCraftWorkbench),
- cStatInfo(achMakeBread, "makeBread", achCraftHoe),
- cStatInfo(achBakeCake, "bakeCake", achCraftHoe),
- cStatInfo(achCraftBetterPick, "buildBetterPickaxe", achCraftPickaxe),
- cStatInfo(achCookFish, "cookFish", achAcquireIron),
- cStatInfo(achOnARail, "onARail", achAcquireIron),
- cStatInfo(achCraftSword, "buildSword", achCraftWorkbench),
- cStatInfo(achKillMonster, "killEnemy", achCraftSword),
- cStatInfo(achKillCow, "killCow", achCraftSword),
- cStatInfo(achFlyPig, "flyPig", achKillCow),
- cStatInfo(achSnipeSkeleton, "snipeSkeleton", achKillMonster),
- cStatInfo(achDiamonds, "diamonds", achAcquireIron),
- cStatInfo(achEnterPortal, "portal", achDiamonds),
- cStatInfo(achReturnToSender, "ghast", achEnterPortal),
- cStatInfo(achBlazeRod, "blazeRod", achEnterPortal),
- cStatInfo(achBrewPotion, "potion", achBlazeRod),
- cStatInfo(achEnterTheEnd, "theEnd", achBlazeRod),
- cStatInfo(achDefeatDragon, "theEnd2", achEnterTheEnd),
- cStatInfo(achCraftEnchantTable, "enchantments", achDiamonds),
- cStatInfo(achOverkill, "overkill", achCraftEnchantTable),
- cStatInfo(achBookshelf, "bookcase", achCraftEnchantTable),
- cStatInfo(achExploreAllBiomes, "exploreAllBiomes", achEnterTheEnd),
- cStatInfo(achSpawnWither, "spawnWither", achDefeatDragon),
- cStatInfo(achKillWither, "killWither", achSpawnWither),
- cStatInfo(achFullBeacon, "fullBeacon", achKillWither),
- cStatInfo(achBreedCow, "breedCow", achKillCow),
- cStatInfo(achThrowDiamonds, "diamondsToYou", achDiamonds),
+ cStatInfo(achOpenInv, "achievement.openInventory"),
+ cStatInfo(achMineWood, "achievement.mineWood", achOpenInv),
+ cStatInfo(achCraftWorkbench, "achievement.buildWorkBench", achMineWood),
+ cStatInfo(achCraftPickaxe, "achievement.buildPickaxe", achCraftWorkbench),
+ cStatInfo(achCraftFurnace, "achievement.buildFurnace", achCraftPickaxe),
+ cStatInfo(achAcquireIron, "achievement.acquireIron", achCraftFurnace),
+ cStatInfo(achCraftHoe, "achievement.buildHoe", achCraftWorkbench),
+ cStatInfo(achMakeBread, "achievement.makeBread", achCraftHoe),
+ cStatInfo(achBakeCake, "achievement.bakeCake", achCraftHoe),
+ cStatInfo(achCraftBetterPick, "achievement.buildBetterPickaxe", achCraftPickaxe),
+ cStatInfo(achCookFish, "achievement.cookFish", achAcquireIron),
+ cStatInfo(achOnARail, "achievement.onARail", achAcquireIron),
+ cStatInfo(achCraftSword, "achievement.buildSword", achCraftWorkbench),
+ cStatInfo(achKillMonster, "achievement.killEnemy", achCraftSword),
+ cStatInfo(achKillCow, "achievement.killCow", achCraftSword),
+ cStatInfo(achFlyPig, "achievement.flyPig", achKillCow),
+ cStatInfo(achSnipeSkeleton, "achievement.snipeSkeleton", achKillMonster),
+ cStatInfo(achDiamonds, "achievement.diamonds", achAcquireIron),
+ cStatInfo(achEnterPortal, "achievement.portal", achDiamonds),
+ cStatInfo(achReturnToSender, "achievement.ghast", achEnterPortal),
+ cStatInfo(achBlazeRod, "achievement.blazeRod", achEnterPortal),
+ cStatInfo(achBrewPotion, "achievement.potion", achBlazeRod),
+ cStatInfo(achEnterTheEnd, "achievement.theEnd", achBlazeRod),
+ cStatInfo(achDefeatDragon, "achievement.theEnd2", achEnterTheEnd),
+ cStatInfo(achCraftEnchantTable, "achievement.enchantments", achDiamonds),
+ cStatInfo(achOverkill, "achievement.overkill", achCraftEnchantTable),
+ cStatInfo(achBookshelf, "achievement.bookcase", achCraftEnchantTable),
+ cStatInfo(achExploreAllBiomes, "achievement.exploreAllBiomes", achEnterTheEnd),
+ cStatInfo(achSpawnWither, "achievement.spawnWither", achDefeatDragon),
+ cStatInfo(achKillWither, "achievement.killWither", achSpawnWither),
+ cStatInfo(achFullBeacon, "achievement.fullBeacon", achKillWither),
+ cStatInfo(achBreedCow, "achievement.breedCow", achKillCow),
+ cStatInfo(achThrowDiamonds, "achievement.diamondsToYou", achDiamonds),
// http://minecraft.gamepedia.com/Statistics
/* Type | Name */
cStatInfo(statGamesQuit, "stat.leaveGame"),
cStatInfo(statMinutesPlayed, "stat.playOneMinute"),
- cStatInfo(statDistWalked, "stat.walkOnCm"),
+ cStatInfo(statDistWalked, "stat.walkOneCm"),
cStatInfo(statDistSwum, "stat.swimOneCm"),
cStatInfo(statDistFallen, "stat.fallOneCm"),
cStatInfo(statDistClimbed, "stat.climbOneCm"),
cStatInfo(statDistFlown, "stat.flyOneCm"),
+ cStatInfo(statDistDove, "stat.diveOneCm"),
cStatInfo(statDistMinecart, "stat.minecartOneCm"),
cStatInfo(statDistBoat, "stat.boatOneCm"),
cStatInfo(statDistPig, "stat.pigOneCm"),
cStatInfo(statDistHorse, "stat.horseOneCm"),
cStatInfo(statJumps, "stat.jump"),
cStatInfo(statItemsDropped, "stat.drop"),
- cStatInfo(statDamageDealt, "stat.damageDealth"),
+ cStatInfo(statDamageDealt, "stat.damageDealt"),
cStatInfo(statDamageTaken, "stat.damageTaken"),
cStatInfo(statDeaths, "stat.deaths"),
cStatInfo(statMobKills, "stat.mobKills"),
@@ -113,7 +115,7 @@ eStatistic cStatInfo::GetType(const AString & a_Name)
{
for (unsigned int i = 0; i < ARRAYCOUNT(ms_Info); ++i)
{
- if (NoCaseCompare(ms_Info[i].m_Name, a_Name))
+ if (NoCaseCompare(ms_Info[i].m_Name, a_Name) == 0)
{
return ms_Info[i].m_Type;
}
@@ -137,3 +139,59 @@ eStatistic cStatInfo::GetPrerequisite(const eStatistic a_Type)
+cStatManager::cStatManager()
+{
+ Reset();
+}
+
+
+
+
+
+StatValue cStatManager::GetValue(const eStatistic a_Stat) const
+{
+ ASSERT((a_Stat > statInvalid) && (a_Stat < statCount));
+
+ return m_MainStats[a_Stat];
+}
+
+
+
+
+
+void cStatManager::SetValue(const eStatistic a_Stat, const StatValue a_Value)
+{
+ ASSERT((a_Stat > statInvalid) && (a_Stat < statCount));
+
+ m_MainStats[a_Stat] = a_Value;
+}
+
+
+
+
+
+StatValue cStatManager::AddValue(const eStatistic a_Stat, const StatValue a_Delta)
+{
+ ASSERT((a_Stat > statInvalid) && (a_Stat < statCount));
+
+ m_MainStats[a_Stat] += a_Delta;
+
+ return m_MainStats[a_Stat];
+}
+
+
+
+
+
+void cStatManager::Reset(void)
+{
+ for (unsigned int i = 0; i < (unsigned int)statCount; ++i)
+ {
+ m_MainStats[i] = 0;
+ }
+}
+
+
+
+
+
diff --git a/src/Statistics.h b/src/Statistics.h
index 540df38cc..d70a2aeab 100644
--- a/src/Statistics.h
+++ b/src/Statistics.h
@@ -9,6 +9,7 @@
+// tolua_begin
enum eStatistic
{
// The order must match the order of cStatInfo::ms_Info
@@ -61,7 +62,7 @@ enum eStatistic
statDistDove,
statDistMinecart,
statDistBoat,
- statDistPig,
+ statDistPig,
statDistHorse,
statJumps,
statItemsDropped,
@@ -77,6 +78,7 @@ enum eStatistic
statCount
};
+// tolua_end
@@ -114,3 +116,48 @@ private:
+
+/* Signed (?) integral value. */
+typedef int StatValue; // tolua_export
+
+
+
+
+/** Class that manages the statistics and achievements of a single player. */
+// tolua_begin
+class cStatManager
+{
+public:
+ // tolua_end
+
+ cStatManager();
+
+ // tolua_begin
+
+ /** Return the value of the specified stat. */
+ StatValue GetValue(const eStatistic a_Stat) const;
+
+ /** Set the value of the specified stat. */
+ void SetValue(const eStatistic a_Stat, const StatValue a_Value);
+
+ /** Reset everything. */
+ void Reset();
+
+ /** Increments the specified stat.
+ Returns the new value.
+ */
+ StatValue AddValue(const eStatistic a_Stat, const StatValue a_Delta = 1);
+
+ // tolua_end
+
+private:
+
+ StatValue m_MainStats[statCount];
+
+ // TODO 10-05-2014 xdot: Use, mine, craft statistics
+
+
+}; // tolua_export
+
+
+
diff --git a/src/StringCompression.cpp b/src/StringCompression.cpp
index 2a85649a1..71d64e71e 100644
--- a/src/StringCompression.cpp
+++ b/src/StringCompression.cpp
@@ -11,15 +11,15 @@
/// Compresses a_Data into a_Compressed; returns Z_XXX error constants same as zlib's compress2()
-int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, int a_Factor)
+int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor)
{
- uLongf CompressedSize = compressBound(a_Length);
+ uLongf CompressedSize = compressBound((uLong)a_Length);
// HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer!
// It saves us one allocation and one memcpy of the entire compressed data
// It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010)
a_Compressed.resize(CompressedSize);
- int errorcode = compress2( (Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef*)a_Data, a_Length, a_Factor);
+ int errorcode = compress2((Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef *)a_Data, (uLong)a_Length, a_Factor);
if (errorcode != Z_OK)
{
return errorcode;
@@ -33,14 +33,14 @@ int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, in
/// Uncompresses a_Data into a_Decompressed; returns Z_XXX error constants same as zlib's uncompress()
-int UncompressString(const char * a_Data, int a_Length, AString & a_Uncompressed, int a_UncompressedSize)
+int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompressed, size_t a_UncompressedSize)
{
// HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer!
// It saves us one allocation and one memcpy of the entire compressed data
// It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010)
a_Uncompressed.resize(a_UncompressedSize);
uLongf UncompressedSize = (uLongf)a_UncompressedSize; // On some architectures the uLongf is different in size to int, that may be the cause of the -5 error
- int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, a_Length);
+ int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, (uLong)a_Length);
if (errorcode != Z_OK)
{
return errorcode;
@@ -63,7 +63,7 @@ int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compres
z_stream strm;
memset(&strm, 0, sizeof(strm));
strm.next_in = (Bytef *)a_Data;
- strm.avail_in = a_Length;
+ strm.avail_in = (uInt)a_Length;
strm.next_out = (Bytef *)Buffer;
strm.avail_out = sizeof(Buffer);
@@ -127,7 +127,7 @@ extern int UncompressStringGZIP(const char * a_Data, size_t a_Length, AString &
z_stream strm;
memset(&strm, 0, sizeof(strm));
strm.next_in = (Bytef *)a_Data;
- strm.avail_in = a_Length;
+ strm.avail_in = (uInt)a_Length;
strm.next_out = (Bytef *)Buffer;
strm.avail_out = sizeof(Buffer);
diff --git a/src/StringCompression.h b/src/StringCompression.h
index c3a9eca91..038240797 100644
--- a/src/StringCompression.h
+++ b/src/StringCompression.h
@@ -10,10 +10,10 @@
/// Compresses a_Data into a_Compressed using ZLIB; returns Z_XXX error constants same as zlib's compress2()
-extern int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, int a_Factor);
+extern int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor);
/// Uncompresses a_Data into a_Uncompressed; returns Z_XXX error constants same as zlib's decompress()
-extern int UncompressString(const char * a_Data, int a_Length, AString & a_Uncompressed, int a_UncompressedSize);
+extern int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompressed, size_t a_UncompressedSize);
/// Compresses a_Data into a_Compressed using GZIP; returns Z_OK for success or Z_XXX error constants same as zlib
extern int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compressed);
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 33b04505f..b0e5a4ffe 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -233,13 +233,13 @@ AString & StrToLower(AString & s)
int NoCaseCompare(const AString & s1, const AString & s2)
{
#ifdef _MSC_VER
- // MSVC has stricmp that compares case-insensitive:
- return _stricmp(s1.c_str(), s2.c_str());
- #else
- // Do it the hard way:
- AString s1Copy(s1);
- AString s2Copy(s2);
- return StrToUpper(s1Copy).compare(StrToUpper(s2Copy));
+ // MSVC has stricmp that compares case-insensitive:
+ return _stricmp(s1.c_str(), s2.c_str());
+ #else
+ // Do it the hard way:
+ AString s1Copy(s1);
+ AString s2Copy(s2);
+ return StrToUpper(s1Copy).compare(StrToUpper(s2Copy));
#endif // else _MSC_VER
}
@@ -247,18 +247,22 @@ int NoCaseCompare(const AString & s1, const AString & s2)
-unsigned int RateCompareString(const AString & s1, const AString & s2 )
+size_t RateCompareString(const AString & s1, const AString & s2)
{
- unsigned int MatchedLetters = 0;
- unsigned int s1Length = s1.length();
+ size_t MatchedLetters = 0;
+ size_t s1Length = s1.length();
- if( s1Length > s2.length() ) return 0; // Definitely not a match
+ if (s1Length > s2.length())
+ {
+ // Definitely not a match
+ return 0;
+ }
- for (unsigned int i = 0; i < s1Length; i++)
+ for (size_t i = 0; i < s1Length; i++)
{
- char c1 = (char)toupper( s1[i] );
- char c2 = (char)toupper( s2[i] );
- if( c1 == c2 )
+ char c1 = (char)toupper(s1[i]);
+ char c2 = (char)toupper(s2[i]);
+ if (c1 == c2)
{
++MatchedLetters;
}
@@ -288,11 +292,11 @@ void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString &
// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8
-AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8)
+AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UTF8)
{
a_UTF8.clear();
a_UTF8.reserve(3 * a_NumShorts / 2); // a quick guess of the resulting size
- for (int i = 0; i < a_NumShorts; i++)
+ for (size_t i = 0; i < a_NumShorts; i++)
{
int c = GetBEShort(&a_RawData[i * 2]);
if (c < 0x80)
@@ -335,16 +339,16 @@ AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8)
// UTF-8 conversion code adapted from:
// http://stackoverflow.com/questions/2867123/convert-utf-16-to-utf-8-under-windows-and-linux-in-c
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Begin of Unicode, Inc.'s code / information
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
/*
Notice from the original file:
* Copyright 2001-2004 Unicode, Inc.
-*
+*
* Disclaimer
-*
+*
* This source code is provided as is by Unicode, Inc. No claims are
* made as to fitness for any particular purpose. No warranties of any
* kind are expressed or implied. The recipient agrees to determine
@@ -352,9 +356,9 @@ Notice from the original file:
* purchased on magnetic or optical media from Unicode, Inc., the
* sole remedy for any claim will be exchange of defective media
* within 90 days of receipt.
-*
+*
* Limitations on Rights to Redistribute This Code
-*
+*
* Unicode, Inc. hereby grants the right to freely use the information
* supplied in this file in the creation of products supporting the
* Unicode Standard, and to make copies of this file in any form
@@ -374,13 +378,13 @@ Notice from the original file:
static const char trailingBytesForUTF8[256] =
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5
};
@@ -390,7 +394,7 @@ static const char trailingBytesForUTF8[256] =
static const unsigned int offsetsFromUTF8[6] =
{
- 0x00000000UL, 0x00003080UL, 0x000E2080UL,
+ 0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL
};
@@ -498,27 +502,27 @@ AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a
return a_UTF16;
}
-/* ---------------------------------------------------------------------
-
- Note A.
- The fall-through switches in UTF-8 reading code save a
- temp variable, some decrements & conditionals. The switches
- are equivalent to the following loop:
- {
- int tmpBytesToRead = extraBytesToRead+1;
- do {
- ch += *source++;
- --tmpBytesToRead;
- if (tmpBytesToRead) ch <<= 6;
- } while (tmpBytesToRead > 0);
- }
-
- ---------------------------------------------------------------------
+/*
+---------------------------------------------------------------------
+Note A.
+The fall-through switches in UTF-8 reading code save a
+temp variable, some decrements & conditionals. The switches
+are equivalent to the following loop:
+{
+ int tmpBytesToRead = extraBytesToRead + 1;
+ do
+ {
+ ch += *source++;
+ --tmpBytesToRead;
+ if (tmpBytesToRead) ch <<= 6;
+ } while (tmpBytesToRead > 0);
+}
+---------------------------------------------------------------------
*/
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// End of Unicode, Inc.'s code / information
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
@@ -757,7 +761,7 @@ AString Base64Decode(const AString & a_Base64String)
{
switch (o & 7)
{
- case 0: res[o >> 3] |= (c << 2); break;
+ case 0: res[o >> 3] |= (c << 2); break;
case 6: res[o >> 3] |= (c >> 4); res[(o >> 3) + 1] |= (c << 4); break;
case 4: res[o >> 3] |= (c >> 2); res[(o >> 3) + 1] |= (c << 6); break;
case 2: res[o >> 3] |= c; break;
@@ -781,11 +785,12 @@ AString Base64Decode(const AString & a_Base64String)
AString Base64Encode(const AString & a_Input)
{
- static const char BASE64[64] = {
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
- 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
- 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
- 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
+ static const char BASE64[64] =
+ {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
};
AString output;
diff --git a/src/StringUtils.h b/src/StringUtils.h
index b69e47d3c..30b9904d1 100644
--- a/src/StringUtils.h
+++ b/src/StringUtils.h
@@ -6,9 +6,9 @@
-#ifndef STRINGUTILS_H_INCLUDED
-#define STRINGUTILS_H_INCLUDED
+#pragma once
+#include <string>
@@ -52,13 +52,13 @@ extern AString & StrToLower(AString & s);
extern int NoCaseCompare(const AString & s1, const AString & s2); // tolua_export
/// Case-insensitive string comparison that returns a rating of equal-ness between [0 - s1.length()]
-extern unsigned int RateCompareString(const AString & s1, const AString & s2 );
+extern size_t RateCompareString(const AString & s1, const AString & s2);
/// Replaces *each* occurence of iNeedle in iHayStack with iReplaceWith
extern void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith); // tolua_export
/// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8
-extern AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8);
+extern AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UTF8);
/// Converts a UTF-8 string into a UTF-16 BE string, packing that back into AString; return a ref to a_UTF16
extern AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a_UTF16);
@@ -98,8 +98,3 @@ extern void SetBEInt(char * a_Mem, Int32 a_Value);
-#endif // STRINGUTILS_H_INCLUDED
-
-
-
-
diff --git a/src/Tracer.cpp b/src/Tracer.cpp
index 6da6b2ad7..756147a7b 100644
--- a/src/Tracer.cpp
+++ b/src/Tracer.cpp
@@ -7,7 +7,7 @@
#include "Entities/Entity.h"
#ifndef _WIN32
- #include <stdlib.h> // abs()
+ #include <stdlib.h>
#endif
@@ -18,11 +18,11 @@ cTracer::cTracer(cWorld * a_World)
: m_World(a_World)
{
m_NormalTable[0].Set(-1, 0, 0);
- m_NormalTable[1].Set( 0, 0,-1);
+ m_NormalTable[1].Set( 0, 0, -1);
m_NormalTable[2].Set( 1, 0, 0);
m_NormalTable[3].Set( 0, 0, 1);
m_NormalTable[4].Set( 0, 1, 0);
- m_NormalTable[5].Set( 0,-1, 0);
+ m_NormalTable[5].Set( 0, -1, 0);
}
@@ -37,7 +37,7 @@ cTracer::~cTracer()
-float cTracer::SigNum( float a_Num )
+float cTracer::SigNum( float a_Num)
{
if (a_Num < 0.f) return -1.f;
if (a_Num > 0.f) return 1.f;
@@ -59,7 +59,7 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
step.z = (int) SigNum(dir.z);
// normalize the direction vector
- if( dir.SqrLength() > 0.f ) dir.Normalize();
+ if (dir.SqrLength() > 0.f) dir.Normalize();
// how far we must move in the ray direction before
// we encounter a new voxel in x-direction
@@ -192,7 +192,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
if (step.y > 0.0f)
{
- if(pos.y >= end1.y)
+ if (pos.y >= end1.y)
{
reachedY = true;
}
@@ -219,14 +219,18 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
return false;
}
+ if ((pos.y < 0) || (pos.y >= cChunkDef::Height))
+ {
+ return false;
+ }
BLOCKTYPE BlockID = m_World->GetBlock(pos.x, pos.y, pos.z);
// Block is counted as a collision if we are not doing a line of sight and it is solid,
// or if the block is not air and not water. That way mobs can still see underwater.
if ((!a_LineOfSight && cBlockInfo::IsSolid(BlockID)) || (a_LineOfSight && (BlockID != E_BLOCK_AIR) && !IsBlockWater(BlockID)))
{
BlockHitPosition = pos;
- int Normal = GetHitNormal(a_Start, End, pos );
- if(Normal > 0)
+ int Normal = GetHitNormal(a_Start, End, pos);
+ if (Normal > 0)
{
HitNormal = m_NormalTable[Normal-1];
}
@@ -241,9 +245,9 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
// return 1 = hit, other is not hit
-int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3)
+int LinesCross(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
{
- //float linx, liny;
+ // float linx, liny;
float d=(x1-x0)*(y3-y2)-(y1-y0)*(x3-x2);
if (abs(d)<0.001) {return 0;}
@@ -253,8 +257,8 @@ int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,fl
float CD=((y0-y2)*(x1-x0)-(x0-x2)*(y1-y0))/d;
if (CD>=0.0 && CD<=1.0)
{
- //linx=x0+AB*(x1-x0);
- //liny=y0+AB*(y1-y0);
+ // linx=x0+AB*(x1-x0);
+ // liny=y0+AB*(y1-y0);
return 1;
}
}
@@ -267,38 +271,52 @@ int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,fl
// Return: 0 = disjoint (no intersection)
// 1 = intersection in the unique point *I0
// 2 = the segment lies in the plane
-int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal )
+int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal)
{
- Vector3f u = a_End - a_Origin;//a_Ray.P1 - S.P0;
- Vector3f w = a_Origin - a_PlanePos;//S.P0 - Pn.V0;
+ Vector3f u = a_End - a_Origin; // a_Ray.P1 - S.P0;
+ Vector3f w = a_Origin - a_PlanePos; // S.P0 - Pn.V0;
- float D = a_PlaneNormal.Dot( u );//dot(Pn.n, u);
- float N = -(a_PlaneNormal.Dot( w ) );//-dot(a_Plane.n, w);
+ float D = a_PlaneNormal.Dot( u); // dot(Pn.n, u);
+ float N = -(a_PlaneNormal.Dot( w)); // -dot(a_Plane.n, w);
const float EPSILON = 0.0001f;
- if (fabs(D) < EPSILON) { // segment is parallel to plane
- if (N == 0) // segment lies in plane
+ if (fabs(D) < EPSILON)
+ {
+ // segment is parallel to plane
+ if (N == 0)
+ {
+ // segment lies in plane
return 2;
- return 0; // no intersection
+ }
+ return 0; // no intersection
}
+
// they are not parallel
// compute intersect param
float sI = N / D;
if (sI < 0 || sI > 1)
- return 0; // no intersection
+ {
+ return 0; // no intersection
+ }
- //Vector3f I ( a_Ray->GetOrigin() + sI * u );//S.P0 + sI * u; // compute segment intersect point
+ // Vector3f I ( a_Ray->GetOrigin() + sI * u);// S.P0 + sI * u; // compute segment intersect point
RealHit = a_Origin + u * sI;
return 1;
}
+
+
+
+
int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos)
{
Vector3i SmallBlockPos = a_BlockPos;
- char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z );
+ char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
- if( BlockID == E_BLOCK_AIR || IsBlockWater(BlockID))
+ if (BlockID == E_BLOCK_AIR || IsBlockWater(BlockID))
+ {
return 0;
+ }
Vector3f BlockPos;
BlockPos = Vector3f(SmallBlockPos);
@@ -306,86 +324,86 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
Vector3f Look = (end - start);
Look.Normalize();
- float dot = Look.Dot( Vector3f(-1, 0, 0) ); // first face normal is x -1
- if(dot < 0)
+ float dot = Look.Dot( Vector3f(-1, 0, 0)); // first face normal is x -1
+ if (dot < 0)
{
- int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1 );
- if(Lines == 1)
+ int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1);
+ if (Lines == 1)
{
- Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1 );
- if(Lines == 1)
+ Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1);
+ if (Lines == 1)
{
- intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0) );
+ intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0));
return 1;
}
}
}
- dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1
- if(dot < 0)
+ dot = Look.Dot( Vector3f(0, 0, -1)); // second face normal is z -1
+ if (dot < 0)
{
- int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1 );
- if(Lines == 1)
+ int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1);
+ if (Lines == 1)
{
- Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1 );
- if(Lines == 1)
+ Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1);
+ if (Lines == 1)
{
- intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1) );
+ intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1));
return 2;
}
}
}
- dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1
- if(dot < 0)
+ dot = Look.Dot( Vector3f(1, 0, 0)); // third face normal is x 1
+ if (dot < 0)
{
- int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1 );
- if(Lines == 1)
+ int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1);
+ if (Lines == 1)
{
- Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1 );
- if(Lines == 1)
+ Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1);
+ if (Lines == 1)
{
- intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0) );
+ intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0));
return 3;
}
}
}
- dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1
- if(dot < 0)
+ dot = Look.Dot( Vector3f(0, 0, 1)); // fourth face normal is z 1
+ if (dot < 0)
{
- int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1 );
- if(Lines == 1)
+ int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1);
+ if (Lines == 1)
{
- Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1 );
- if(Lines == 1)
+ Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1);
+ if (Lines == 1)
{
- intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1) );
+ intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1));
return 4;
}
}
}
- dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1
- if(dot < 0)
+ dot = Look.Dot( Vector3f(0, 1, 0)); // fifth face normal is y 1
+ if (dot < 0)
{
- int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1 );
- if(Lines == 1)
+ int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1);
+ if (Lines == 1)
{
- Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1 );
- if(Lines == 1)
+ Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1);
+ if (Lines == 1)
{
- intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0) );
+ intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0));
return 5;
}
}
}
- dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1
- if(dot < 0)
+ dot = Look.Dot( Vector3f(0, -1, 0)); // sixth face normal is y -1
+ if (dot < 0)
{
- int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1 );
- if(Lines == 1)
+ int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1);
+ if (Lines == 1)
{
- Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1 );
- if(Lines == 1)
+ Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1);
+ if (Lines == 1)
{
- intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0) );
+ intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0));
return 6;
}
}
diff --git a/src/Tracer.h b/src/Tracer.h
index bdb080f0d..ec87d449e 100644
--- a/src/Tracer.h
+++ b/src/Tracer.h
@@ -48,20 +48,20 @@ public:
private:
/// Preps Tracer object for call of Trace function. Only used internally.
- void SetValues( const Vector3f & a_Start, const Vector3f & a_Direction );
+ void SetValues( const Vector3f & a_Start, const Vector3f & a_Direction);
/// Calculates where on the block a collision occured, if it does occur
/// Returns 0 if no intersection occured
/// Returns 1 if an intersection occured at a single point
- /// Returns 2 if the line segment lies in the plane being checked
- int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal );
+ /// Returns 2 if the line segment lies in the plane being checked
+ int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal);
/// Determines which face on the block a collision occured, if it does occur
/// Returns 0 if the block is air, water or no collision occured
/// Return 1 through 6 for the following block faces, repectively: -x, -z, x, z, y, -y
int GetHitNormal( const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos);
- float SigNum( float a_Num );
+ float SigNum( float a_Num);
cWorld* m_World;
Vector3f m_NormalTable[6];
diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt
index 5b5b8cc18..2b094ef1d 100644
--- a/src/UI/CMakeLists.txt
+++ b/src/UI/CMakeLists.txt
@@ -4,9 +4,15 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ SlotArea.cpp
+ Window.cpp)
-add_library(UI ${SOURCE})
+SET (HDRS
+ SlotArea.h
+ Window.h
+ WindowOwner.h)
+
+if(NOT MSVC)
+ add_library(UI ${SRCS} ${HDRS})
+endif()
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 87b4032e0..b5f84c24c 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -20,7 +20,7 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSlotArea:
cSlotArea::cSlotArea(int a_NumSlots, cWindow & a_ParentWindow) :
@@ -36,8 +36,8 @@ cSlotArea::cSlotArea(int a_NumSlots, cWindow & a_ParentWindow) :
void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
/*
- LOGD("Slot area with %d slots clicked at slot number %d, clicked item %s, slot item %s",
- GetNumSlots(), a_SlotNum,
+ LOGD("Slot area with %d slots clicked at slot number %d, clicked item %s, slot item %s",
+ GetNumSlots(), a_SlotNum,
ItemToFullString(a_ClickedItem).c_str(),
ItemToFullString(*GetSlot(a_SlotNum, a_Player)).c_str()
);
@@ -60,12 +60,35 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
return;
}
-
case caDblClick:
{
DblClicked(a_Player, a_SlotNum);
return;
}
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+ case caDropKey:
+ case caCtrlDropKey:
+ {
+ DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey));
+ return;
+ }
+ case caNumber1:
+ case caNumber2:
+ case caNumber3:
+ case caNumber4:
+ case caNumber5:
+ case caNumber6:
+ case caNumber7:
+ case caNumber8:
+ case caNumber9:
+ {
+ NumberClicked(a_Player, a_SlotNum, a_ClickAction);
+ return;
+ }
default:
{
break;
@@ -85,9 +108,9 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
{
case caRightClick:
{
- if (DraggingItem.m_ItemType <= 0) // Empty-handed?
+ if (DraggingItem.m_ItemType <= 0) // Empty-handed?
{
- DraggingItem = Slot.CopyOne(); // Obtain copy of slot to preserve lore, enchantments, etc.
+ DraggingItem = Slot.CopyOne(); // Obtain copy of slot to preserve lore, enchantments, etc.
DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f);
Slot.m_ItemCount -= DraggingItem.m_ItemCount;
@@ -105,7 +128,7 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
{
char OldSlotCount = Slot.m_ItemCount;
- Slot = DraggingItem.CopyOne(); // See above
+ Slot = DraggingItem.CopyOne(); // See above
OldSlotCount++;
Slot.m_ItemCount = OldSlotCount;
@@ -226,6 +249,77 @@ void cSlotArea::DblClicked(cPlayer & a_Player, int a_SlotNum)
+void cSlotArea::MiddleClicked(cPlayer & a_Player, int a_SlotNum)
+{
+ cItem Slot(*GetSlot(a_SlotNum, a_Player));
+ cItem & DraggingItem = a_Player.GetDraggingItem();
+
+ if (!a_Player.IsGameModeCreative() || Slot.IsEmpty() || !DraggingItem.IsEmpty())
+ {
+ return;
+ }
+
+ DraggingItem = Slot;
+ DraggingItem.m_ItemCount = DraggingItem.GetMaxStackSize();
+}
+
+
+
+
+
+void cSlotArea::DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack)
+{
+ cItem Slot(*GetSlot(a_SlotNum, a_Player));
+ if (Slot.IsEmpty())
+ {
+ return;
+ }
+
+ cItem ItemToDrop = Slot.CopyOne();
+ if (a_DropStack)
+ {
+ ItemToDrop.m_ItemCount = Slot.m_ItemCount;
+ }
+
+ Slot.m_ItemCount -= ItemToDrop.m_ItemCount;
+ if (Slot.m_ItemCount <= 0)
+ {
+ Slot.Empty();
+ }
+ SetSlot(a_SlotNum, a_Player, Slot);
+
+ a_Player.TossPickup(ItemToDrop);
+}
+
+
+
+
+
+void cSlotArea::NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction)
+{
+ if ((a_ClickAction < caNumber1) || (a_ClickAction > caNumber9))
+ {
+ return;
+ }
+
+ int HotbarSlot = (int)a_ClickAction - (int)caNumber1;
+ cItem ItemInHotbar(a_Player.GetInventory().GetHotbarSlot(HotbarSlot));
+ cItem ItemInSlot(*GetSlot(a_SlotNum, a_Player));
+
+ // The items are equal. Do nothing.
+ if (ItemInHotbar.IsEqual(ItemInSlot))
+ {
+ return;
+ }
+
+ a_Player.GetInventory().SetHotbarSlot(HotbarSlot, ItemInSlot);
+ SetSlot(a_SlotNum, a_Player, ItemInHotbar);
+}
+
+
+
+
+
void cSlotArea::OnPlayerAdded(cPlayer & a_Player)
{
UNUSED(a_Player);
@@ -244,7 +338,7 @@ void cSlotArea::OnPlayerRemoved(cPlayer & a_Player)
-void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_Apply, bool a_KeepEmptySlots)
+void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
{
for (int i = 0; i < m_NumSlots; i++)
{
@@ -264,7 +358,7 @@ void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_
{
NumFit = a_ItemStack.m_ItemCount;
}
- if (a_Apply)
+ if (a_ShouldApply)
{
cItem NewSlot(a_ItemStack);
NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit;
@@ -315,7 +409,7 @@ bool cSlotArea::CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaChest:
cSlotAreaChest::cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow) :
@@ -347,7 +441,7 @@ void cSlotAreaChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaDoubleChest:
cSlotAreaDoubleChest::cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow) :
@@ -394,7 +488,7 @@ void cSlotAreaDoubleChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cIte
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaCrafting:
cSlotAreaCrafting::cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow) :
@@ -410,6 +504,12 @@ cSlotAreaCrafting::cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow) :
void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
+ if (a_ClickAction == caMiddleClick)
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+
// Override for craft result slot
if (a_SlotNum == 0)
{
@@ -417,12 +517,17 @@ void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction
{
ShiftClickedResult(a_Player);
}
+ else if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey))
+ {
+ DropClickedResult(a_Player);
+ }
else
{
ClickedResult(a_Player);
}
return;
}
+
super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
UpdateRecipe(a_Player);
}
@@ -468,6 +573,20 @@ void cSlotAreaCrafting::OnPlayerRemoved(cPlayer & a_Player)
+void cSlotAreaCrafting::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+{
+ // Update the recipe after setting the slot, if the slot is not the result slot:
+ super::SetSlot(a_SlotNum, a_Player, a_Item);
+ if (a_SlotNum != 0)
+ {
+ UpdateRecipe(a_Player);
+ }
+}
+
+
+
+
+
void cSlotAreaCrafting::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
{
UNUSED(a_ItemStack);
@@ -496,6 +615,8 @@ void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
DraggingItem = Result;
Recipe.ConsumeIngredients(Grid);
Grid.CopyToItems(PlayerSlots);
+
+ HandleCraftItem(Result, a_Player);
}
else if (DraggingItem.IsEqual(Result))
{
@@ -505,6 +626,8 @@ void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
DraggingItem.m_ItemCount += Result.m_ItemCount;
Recipe.ConsumeIngredients(Grid);
Grid.CopyToItems(PlayerSlots);
+
+ HandleCraftItem(Result, a_Player);
}
}
@@ -541,16 +664,20 @@ void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player)
// Distribute the result, this time for real:
ResultCopy = Result;
m_ParentWindow.DistributeStack(ResultCopy, a_Player, this, true);
-
+
// Remove the ingredients from the crafting grid and update the recipe:
cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize);
Recipe.ConsumeIngredients(Grid);
Grid.CopyToItems(PlayerSlots);
UpdateRecipe(a_Player);
+
+ // Broadcast the window, we sometimes move items to different locations than Vanilla, causing needless desyncs:
+ m_ParentWindow.BroadcastWholeWindow();
+
+ // If the recipe has changed, bail out:
if (!Recipe.GetResult().IsEqual(Result))
{
- // The recipe has changed, bail out
return;
}
}
@@ -560,6 +687,27 @@ void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player)
+void cSlotAreaCrafting::DropClickedResult(cPlayer & a_Player)
+{
+ // Get the current recipe:
+ cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
+ const cItem & Result = Recipe.GetResult();
+
+ cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1;
+ cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize);
+
+ a_Player.TossPickup(Result);
+ Recipe.ConsumeIngredients(Grid);
+ Grid.CopyToItems(PlayerSlots);
+
+ HandleCraftItem(Result, a_Player);
+ UpdateRecipe(a_Player);
+}
+
+
+
+
+
void cSlotAreaCrafting::UpdateRecipe(cPlayer & a_Player)
{
cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
@@ -594,8 +742,456 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player)
+void cSlotAreaCrafting::HandleCraftItem(const cItem & a_Result, cPlayer & a_Player)
+{
+ switch (a_Result.m_ItemType)
+ {
+ case E_BLOCK_WORKBENCH: a_Player.AwardAchievement(achCraftWorkbench); break;
+ case E_BLOCK_FURNACE: a_Player.AwardAchievement(achCraftFurnace); break;
+ case E_BLOCK_CAKE: a_Player.AwardAchievement(achBakeCake); break;
+ case E_BLOCK_ENCHANTMENT_TABLE: a_Player.AwardAchievement(achCraftEnchantTable); break;
+ case E_BLOCK_BOOKCASE: a_Player.AwardAchievement(achBookshelf); break;
+ case E_ITEM_WOODEN_PICKAXE: a_Player.AwardAchievement(achCraftPickaxe); break;
+ case E_ITEM_WOODEN_SWORD: a_Player.AwardAchievement(achCraftSword); break;
+ case E_ITEM_STONE_PICKAXE: a_Player.AwardAchievement(achCraftBetterPick); break;
+ case E_ITEM_WOODEN_HOE: a_Player.AwardAchievement(achCraftHoe); break;
+ case E_ITEM_BREAD: a_Player.AwardAchievement(achMakeBread); break;
+ default: break;
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaAnvil:
+
+cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) :
+ cSlotAreaTemporary(3, a_ParentWindow),
+ m_MaximumCost(0),
+ m_StackSizeToBeUsedInRepair(0)
+{
+}
+
+
+
+
+
+void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
+{
+ ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots()));
+ if (a_SlotNum != 2)
+ {
+ super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
+ UpdateResult(a_Player);
+ return;
+ }
+
+ bool bAsync = false;
+ if (GetSlot(a_SlotNum, a_Player) == NULL)
+ {
+ LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ return;
+ }
+
+ switch (a_ClickAction)
+ {
+ case caDblClick:
+ {
+ return;
+ }
+ case caShiftLeftClick:
+ case caShiftRightClick:
+ {
+ ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
+ return;
+ }
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+ case caDropKey:
+ case caCtrlDropKey:
+ {
+ if (CanTakeResultItem(a_Player))
+ {
+ DropClicked(a_Player, a_SlotNum, true);
+ OnTakeResult(a_Player);
+ }
+ return;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ cItem Slot(*GetSlot(a_SlotNum, a_Player));
+ if (!Slot.IsSameType(a_ClickedItem))
+ {
+ LOGWARNING("*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum, m_NumSlots);
+ LOGWARNING("My item: %s", ItemToFullString(Slot).c_str());
+ LOGWARNING("Their item: %s", ItemToFullString(a_ClickedItem).c_str());
+ bAsync = true;
+ }
+ cItem & DraggingItem = a_Player.GetDraggingItem();
+
+ if (Slot.IsEmpty())
+ {
+ return;
+ }
+ if (!DraggingItem.IsEmpty())
+ {
+ if (!(DraggingItem.IsEqual(Slot) && ((DraggingItem.m_ItemCount + Slot.m_ItemCount) <= cItemHandler::GetItemHandler(Slot)->GetMaxStackSize())))
+ {
+ return;
+ }
+ }
+
+ if (!CanTakeResultItem(a_Player))
+ {
+ return;
+ }
+
+ cItem NewItem = cItem(Slot);
+ NewItem.m_ItemCount += DraggingItem.m_ItemCount;
+
+ Slot.Empty();
+ DraggingItem.Empty();
+ SetSlot(a_SlotNum, a_Player, Slot);
+
+ DraggingItem = NewItem;
+ OnTakeResult(a_Player);
+
+ if (bAsync)
+ {
+ m_ParentWindow.BroadcastWholeWindow();
+ }
+}
+
+
+
+
+
+void cSlotAreaAnvil::ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem)
+{
+ if (a_SlotNum != 2)
+ {
+ super::ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
+ UpdateResult(a_Player);
+ return;
+ }
+
+ // Make a copy of the slot, distribute it among the other areas, then update the slot to contain the leftover:
+ cItem Slot(*GetSlot(a_SlotNum, a_Player));
+
+ if (Slot.IsEmpty() || !CanTakeResultItem(a_Player))
+ {
+ return;
+ }
+
+ m_ParentWindow.DistributeStack(Slot, a_Player, this, true);
+ if (Slot.IsEmpty())
+ {
+ Slot.Empty();
+ OnTakeResult(a_Player);
+ }
+ SetSlot(a_SlotNum, a_Player, Slot);
+
+ // Some clients try to guess our actions and not always right (armor slots in 1.2.5), so we fix them:
+ m_ParentWindow.BroadcastWholeWindow();
+}
+
+
+
+
+
+void cSlotAreaAnvil::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
+{
+ for (int i = 0; i < 2; i++)
+ {
+ const cItem * Slot = GetSlot(i, a_Player);
+ if (!Slot->IsEqual(a_ItemStack) && (!Slot->IsEmpty() || a_KeepEmptySlots))
+ {
+ // Different items
+ continue;
+ }
+ int NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
+ if (NumFit <= 0)
+ {
+ // Full stack already
+ continue;
+ }
+ if (NumFit > a_ItemStack.m_ItemCount)
+ {
+ NumFit = a_ItemStack.m_ItemCount;
+ }
+ if (a_ShouldApply)
+ {
+ cItem NewSlot(a_ItemStack);
+ NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit;
+ SetSlot(i, a_Player, NewSlot);
+ }
+ a_ItemStack.m_ItemCount -= NumFit;
+ if (a_ItemStack.IsEmpty())
+ {
+ UpdateResult(a_Player);
+ return;
+ }
+ } // for i - Slots
+ UpdateResult(a_Player);
+}
+
+
+
+
+
+void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
+{
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.DeltaExperience(-cPlayer::XpForLevel(m_MaximumCost));
+ }
+ SetSlot(0, a_Player, cItem());
+
+ if (m_StackSizeToBeUsedInRepair > 0)
+ {
+ const cItem * Item = GetSlot(1, a_Player);
+ if (!Item->IsEmpty() && (Item->m_ItemCount > m_StackSizeToBeUsedInRepair))
+ {
+ cItem NewSecondItem(*Item);
+ NewSecondItem.m_ItemCount -= m_StackSizeToBeUsedInRepair;
+ m_StackSizeToBeUsedInRepair = 0;
+ SetSlot(1, a_Player, NewSecondItem);
+ }
+ else
+ {
+ SetSlot(1, a_Player, cItem());
+ }
+ }
+ else
+ {
+ SetSlot(1, a_Player, cItem());
+ }
+ m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player);
+
+ m_MaximumCost = 0;
+ ((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", NULL);
+
+ int PosX, PosY, PosZ;
+ ((cAnvilWindow*)&m_ParentWindow)->GetBlockPos(PosX, PosY, PosZ);
+
+ BLOCKTYPE Block;
+ NIBBLETYPE BlockMeta;
+ a_Player.GetWorld()->GetBlockTypeMeta(PosX, PosY, PosZ, Block, BlockMeta);
+
+ cFastRandom Random;
+ if (!a_Player.IsGameModeCreative() && (Block == E_BLOCK_ANVIL) && (Random.NextFloat(1.0F) < 0.12F))
+ {
+ NIBBLETYPE Orientation = BlockMeta & 0x3;
+ NIBBLETYPE AnvilDamage = BlockMeta >> 2;
+ ++AnvilDamage;
+
+ if (AnvilDamage > 2)
+ {
+ // Anvil will break
+ a_Player.GetWorld()->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, (NIBBLETYPE)0);
+ a_Player.GetWorld()->BroadcastSoundParticleEffect(1020, PosX, PosY, PosZ, 0);
+ a_Player.CloseWindow(false);
+ }
+ else
+ {
+ a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, Orientation | (AnvilDamage << 2));
+ a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0);
+ }
+ }
+ else
+ {
+ a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0);
+ }
+}
+
+
+
+
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+bool cSlotAreaAnvil::CanTakeResultItem(cPlayer & a_Player)
+{
+ return (
+ (
+ a_Player.IsGameModeCreative() || // Is the player in gamemode?
+ (a_Player.GetXpLevel() >= m_MaximumCost) // or the player have enough exp?
+ ) &&
+ (!GetSlot(2, a_Player)->IsEmpty()) && // Is a item in the result slot?
+ (m_MaximumCost > 0) // When no maximum cost is set, the item isn't set from the UpdateResult() method and can't be a valid enchanting result.
+ );
+}
+
+
+
+
+
+void cSlotAreaAnvil::OnPlayerRemoved(cPlayer & a_Player)
+{
+ TossItems(a_Player, 0, 2);
+ super::OnPlayerRemoved(a_Player);
+}
+
+
+
+
+
+void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
+{
+ cItem Input(*GetSlot(0, a_Player));
+ cItem SecondInput(*GetSlot(1, a_Player));
+ cItem Output(*GetSlot(2, a_Player));
+
+ if (Input.IsEmpty() && !Output.IsEmpty())
+ {
+ Output.Empty();
+ SetSlot(2, a_Player, Output);
+ m_ParentWindow.SetProperty(0, 0, a_Player);
+ return;
+ }
+
+ m_MaximumCost = 0;
+ m_StackSizeToBeUsedInRepair = 0;
+ int RepairCost = Input.m_RepairCost;
+ int NeedExp = 0;
+ bool IsEnchantBook = false;
+ if (!SecondInput.IsEmpty())
+ {
+ IsEnchantBook = (SecondInput.m_ItemType == E_ITEM_ENCHANTED_BOOK);
+
+ RepairCost += SecondInput.m_RepairCost;
+ if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithRawMaterial(SecondInput.m_ItemType))
+ {
+ // Tool and armor repair with special item (iron / gold / diamond / ...)
+ int DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
+ if (DamageDiff <= 0)
+ {
+ // No enchantment
+ Output.Empty();
+ SetSlot(2, a_Player, Output);
+ m_ParentWindow.SetProperty(0, 0, a_Player);
+ return;
+ }
+
+ int x = 0;
+ while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount))
+ {
+ Input.m_ItemDamage -= DamageDiff;
+ NeedExp += std::max(1, DamageDiff / 100) + (int)Input.m_Enchantments.Count();
+ DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
+
+ ++x;
+ }
+ m_StackSizeToBeUsedInRepair = x;
+ }
+ else
+ {
+ // Tool and armor repair with two tools / armors
+ if (!IsEnchantBook && (!Input.IsSameType(SecondInput) || !Input.IsDamageable()))
+ {
+ // No enchantment
+ Output.Empty();
+ SetSlot(2, a_Player, Output);
+ m_ParentWindow.SetProperty(0, 0, a_Player);
+ return;
+ }
+
+ if ((Input.GetMaxDamage() > 0) && !IsEnchantBook)
+ {
+ int FirstDamageDiff = Input.GetMaxDamage() - Input.m_ItemDamage;
+ int SecondDamageDiff = SecondInput.GetMaxDamage() - SecondInput.m_ItemDamage;
+ int Damage = SecondDamageDiff + Input.GetMaxDamage() * 12 / 100;
+
+ int NewItemDamage = Input.GetMaxDamage() - (FirstDamageDiff + Damage);
+ if (NewItemDamage > 0)
+ {
+ NewItemDamage = 0;
+ }
+
+ if (NewItemDamage < Input.m_ItemDamage)
+ {
+ Input.m_ItemDamage = NewItemDamage;
+ NeedExp += std::max(1, Damage / 100);
+ }
+ }
+
+ // TODO: Add enchantments.
+ }
+ }
+
+ int NameChangeExp = 0;
+ const AString & RepairedItemName = ((cAnvilWindow*)&m_ParentWindow)->GetRepairedItemName();
+ if (RepairedItemName.empty())
+ {
+ // Remove custom name
+ if (!Input.m_CustomName.empty())
+ {
+ NameChangeExp = (Input.IsDamageable()) ? 7 : (Input.m_ItemCount * 5);
+ NeedExp += NameChangeExp;
+ Input.m_CustomName = "";
+ }
+ }
+ else if (RepairedItemName != Input.m_CustomName)
+ {
+ // Change custom name
+ NameChangeExp = (Input.IsDamageable()) ? 7 : (Input.m_ItemCount * 5);
+ NeedExp += NameChangeExp;
+
+ if (!Input.m_CustomName.empty())
+ {
+ RepairCost += NameChangeExp / 2;
+ }
+
+ Input.m_CustomName = RepairedItemName;
+ }
+
+ // TODO: Add enchantment exp cost.
+
+ m_MaximumCost = RepairCost + NeedExp;
+
+ if (NeedExp < 0)
+ {
+ Input.Empty();
+ }
+
+ if ((NameChangeExp == NeedExp) && (NameChangeExp > 0) && (m_MaximumCost >= 40))
+ {
+ m_MaximumCost = 39;
+ }
+ if (m_MaximumCost >= 40 && !a_Player.IsGameModeCreative())
+ {
+ Input.Empty();
+ }
+
+ if (!Input.IsEmpty())
+ {
+ RepairCost = std::max(Input.m_RepairCost, SecondInput.m_RepairCost);
+ if (!Input.m_CustomName.empty())
+ {
+ RepairCost -= 9;
+ }
+ RepairCost = std::max(RepairCost, 0);
+ RepairCost += 2;
+ Input.m_RepairCost = RepairCost;
+ }
+
+ SetSlot(2, a_Player, Input);
+ m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player);
+}
+
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaEnchanting:
cSlotAreaEnchanting::cSlotAreaEnchanting(cEnchantingWindow & a_ParentWindow) :
@@ -627,12 +1223,16 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio
ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
return;
}
-
case caDblClick:
{
DblClicked(a_Player, a_SlotNum);
return;
}
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
default:
{
break;
@@ -680,7 +1280,7 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio
}
case caLeftClick:
- {
+ {
// Left-clicked
if (DraggingItem.IsEmpty())
{
@@ -896,7 +1496,7 @@ int cSlotAreaEnchanting::GetBookshelvesCount(cWorld * a_World)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaEnderChest:
cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWindow & a_ParentWindow) :
@@ -911,8 +1511,7 @@ cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWind
const cItem * cSlotAreaEnderChest::GetSlot(int a_SlotNum, cPlayer & a_Player) const
{
- // a_SlotNum ranges from 0 to 26, use that to index the chest entity's inventory directly:
- return &(m_EnderChest->GetSlot(a_SlotNum));
+ return &(a_Player.GetEnderChestContents().GetSlot(a_SlotNum));
}
@@ -921,14 +1520,14 @@ const cItem * cSlotAreaEnderChest::GetSlot(int a_SlotNum, cPlayer & a_Player) co
void cSlotAreaEnderChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
{
- m_EnderChest->SetSlot(a_SlotNum, a_Item);
+ a_Player.GetEnderChestContents().SetSlot(a_SlotNum, a_Item);
}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaFurnace:
cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow) :
@@ -953,14 +1552,162 @@ cSlotAreaFurnace::~cSlotAreaFurnace()
void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
- super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
-
if (m_Furnace == NULL)
{
LOGERROR("cSlotAreaFurnace::Clicked(): m_Furnace == NULL");
ASSERT(!"cSlotAreaFurnace::Clicked(): m_Furnace == NULL");
return;
}
+
+ if (a_SlotNum == 2)
+ {
+ bool bAsync = false;
+ if (GetSlot(a_SlotNum, a_Player) == NULL)
+ {
+ LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ return;
+ }
+
+ cItem Slot(*GetSlot(a_SlotNum, a_Player));
+ if (!Slot.IsSameType(a_ClickedItem))
+ {
+ LOGWARNING("*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum, m_NumSlots);
+ LOGWARNING("My item: %s", ItemToFullString(Slot).c_str());
+ LOGWARNING("Their item: %s", ItemToFullString(a_ClickedItem).c_str());
+ bAsync = true;
+ }
+
+ switch (a_ClickAction)
+ {
+ case caShiftLeftClick:
+ case caShiftRightClick:
+ {
+ HandleSmeltItem(Slot, a_Player);
+ ShiftClicked(a_Player, a_SlotNum, Slot);
+ return;
+ }
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+ case caDropKey:
+ case caCtrlDropKey:
+ {
+ DropClicked(a_Player, a_SlotNum, (a_SlotNum == caCtrlDropKey));
+ Slot.m_ItemCount = Slot.m_ItemCount - GetSlot(a_SlotNum, a_Player)->m_ItemCount;
+ HandleSmeltItem(Slot, a_Player);
+ return;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ cItem & DraggingItem = a_Player.GetDraggingItem();
+ if (!DraggingItem.IsEmpty())
+ {
+ if (a_ClickAction == caDblClick)
+ {
+ return;
+ }
+ if (!DraggingItem.IsEqual(Slot))
+ {
+ return;
+ }
+ if ((DraggingItem.m_ItemCount + Slot.m_ItemCount) > Slot.GetMaxStackSize())
+ {
+ return;
+ }
+
+ DraggingItem.m_ItemCount += Slot.m_ItemCount;
+ HandleSmeltItem(Slot, a_Player);
+ Slot.Empty();
+ }
+ else
+ {
+ switch (a_ClickAction)
+ {
+ case caDblClick:
+ {
+ DblClicked(a_Player, a_SlotNum);
+ return;
+ }
+ case caLeftClick:
+ {
+ DraggingItem = Slot;
+ HandleSmeltItem(Slot, a_Player);
+ Slot.Empty();
+ break;
+ }
+ case caRightClick:
+ {
+ DraggingItem = Slot.CopyOne();
+ DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f);
+ Slot.m_ItemCount -= DraggingItem.m_ItemCount;
+
+ if (Slot.m_ItemCount <= 0)
+ {
+ Slot.Empty();
+ }
+ HandleSmeltItem(DraggingItem, a_Player);
+ break;
+ }
+ default:
+ {
+ ASSERT(!"Unhandled click type!");
+ }
+ }
+ }
+
+ SetSlot(a_SlotNum, a_Player, Slot);
+ if (bAsync)
+ {
+ m_ParentWindow.BroadcastWholeWindow();
+ }
+ return;
+ }
+
+ super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
+}
+
+
+
+
+
+void cSlotAreaFurnace::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
+{
+ for (int i = 0; i < 2; i++)
+ {
+ const cItem * Slot = GetSlot(i, a_Player);
+ if (!Slot->IsEqual(a_ItemStack) && (!Slot->IsEmpty() || a_KeepEmptySlots))
+ {
+ // Different items
+ continue;
+ }
+ int NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
+ if (NumFit <= 0)
+ {
+ // Full stack already
+ continue;
+ }
+ if (NumFit > a_ItemStack.m_ItemCount)
+ {
+ NumFit = a_ItemStack.m_ItemCount;
+ }
+ if (a_ShouldApply)
+ {
+ cItem NewSlot(a_ItemStack);
+ NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit;
+ SetSlot(i, a_Player, NewSlot);
+ }
+ a_ItemStack.m_ItemCount -= NumFit;
+ if (a_ItemStack.IsEmpty())
+ {
+ return;
+ }
+ } // for i - Slots
}
@@ -969,6 +1716,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const
{
+ UNUSED(a_Player);
// a_SlotNum ranges from 0 to 2, query the items from the underlying furnace:
return &(m_Furnace->GetSlot(a_SlotNum));
}
@@ -979,6 +1727,7 @@ const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const
void cSlotAreaFurnace::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
{
+ UNUSED(a_Player);
m_Furnace->SetSlot(a_SlotNum, a_Item);
}
@@ -988,9 +1737,10 @@ void cSlotAreaFurnace::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem &
void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
{
+ UNUSED(a_SlotNum);
// Something has changed in the window, broadcast the entire window to all clients
ASSERT(a_ItemGrid == &(m_Furnace->GetContents()));
-
+
m_ParentWindow.BroadcastWholeWindow();
}
@@ -998,7 +1748,22 @@ void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+void cSlotAreaFurnace::HandleSmeltItem(const cItem & a_Result, cPlayer & a_Player)
+{
+ /** TODO 2014-05-12 xdot: Figure out when to call this method. */
+ switch (a_Result.m_ItemType)
+ {
+ case E_ITEM_IRON: a_Player.AwardAchievement(achAcquireIron); break;
+ case E_ITEM_COOKED_FISH: a_Player.AwardAchievement(achCookFish); break;
+ default: break;
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaInventoryBase:
cSlotAreaInventoryBase::cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow) :
@@ -1015,6 +1780,12 @@ void cSlotAreaInventoryBase::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAc
{
if (a_Player.IsGameModeCreative() && (m_ParentWindow.GetWindowType() == cWindow::wtInventory))
{
+ if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey))
+ {
+ DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey));
+ return;
+ }
+
// Creative inventory must treat a_ClickedItem as a DraggedItem instead, replacing the inventory slot with it
SetSlot(a_SlotNum, a_Player, a_ClickedItem);
return;
@@ -1048,7 +1819,7 @@ void cSlotAreaInventoryBase::SetSlot(int a_SlotNum, cPlayer & a_Player, const cI
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaArmor:
void cSlotAreaArmor::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
@@ -1095,23 +1866,48 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C
{
ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots()));
- bool bAsync = false;
- if (GetSlot(a_SlotNum, a_Player) == NULL)
+ // When the player is in creative mode, the client sends the new item as a_ClickedItem, not the current item in the slot.
+ if (a_Player.IsGameModeCreative() && (m_ParentWindow.GetWindowType() == cWindow::wtInventory))
{
- LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey))
+ {
+ DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey));
+ return;
+ }
+
+ SetSlot(a_SlotNum, a_Player, a_ClickedItem);
return;
}
- if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick))
+ bool bAsync = false;
+ if (GetSlot(a_SlotNum, a_Player) == NULL)
{
- ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
+ LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
return;
}
- // Armors haven't a dbl click
- if (a_ClickAction == caDblClick)
+ switch (a_ClickAction)
{
- return;
+ case caDblClick:
+ {
+ // Armors haven't a dbl click
+ return;
+ }
+ case caShiftLeftClick:
+ case caShiftRightClick:
+ {
+ ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
+ return;
+ }
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+ default:
+ {
+ break;
+ }
}
cItem Slot(*GetSlot(a_SlotNum, a_Player));
@@ -1130,7 +1926,7 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C
return;
}
- if (DraggingItem.IsEmpty() || CanPlaceInSlot(a_SlotNum, DraggingItem))
+ if (DraggingItem.IsEmpty() || CanPlaceArmorInSlot(a_SlotNum, DraggingItem))
{
// Swap contents
cItem tmp(DraggingItem);
@@ -1149,7 +1945,7 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C
-bool cSlotAreaArmor::CanPlaceInSlot(int a_SlotNum, const cItem & a_Item)
+bool cSlotAreaArmor::CanPlaceArmorInSlot(int a_SlotNum, const cItem & a_Item)
{
switch (a_SlotNum)
{
@@ -1165,7 +1961,7 @@ bool cSlotAreaArmor::CanPlaceInSlot(int a_SlotNum, const cItem & a_Item)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaItemGrid:
cSlotAreaItemGrid::cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow) :
@@ -1216,7 +2012,7 @@ void cSlotAreaItemGrid::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaTemporary:
cSlotAreaTemporary::cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow) :
@@ -1321,7 +2117,7 @@ void cSlotAreaTemporary::TossItems(cPlayer & a_Player, int a_Begin, int a_End)
double vX = 0, vY = 0, vZ = 0;
EulerToVector(-a_Player.GetYaw(), a_Player.GetPitch(), vZ, vX, vY);
vY = -vY * 2 + 1.f;
- a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because player created
+ a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because player created
}
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index 254722822..fa842bb81 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -9,6 +9,7 @@
#pragma once
#include "../Inventory.h"
+#include "Window.h"
@@ -45,10 +46,19 @@ public:
/// Called from Clicked when the action is a shiftclick (left or right)
virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem);
-
+
/// Called from Clicked when the action is a caDblClick
virtual void DblClicked(cPlayer & a_Player, int a_SlotNum);
-
+
+ /** Called from Clicked when the action is a middleclick */
+ virtual void MiddleClicked(cPlayer & a_Player, int a_SlotNum);
+
+ /** Called from Clicked when the action is a drop click. */
+ virtual void DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack);
+
+ /** Called from Clicked when the action is a number click. */
+ virtual void NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction);
+
/// Called when a new player opens the same parent window. The window already tracks the player. CS-locked.
virtual void OnPlayerAdded(cPlayer & a_Player);
@@ -125,7 +135,7 @@ class cSlotAreaHotBar :
typedef cSlotAreaInventoryBase super;
public:
- cSlotAreaHotBar(cWindow & a_ParentWindow) :
+ cSlotAreaHotBar(cWindow & a_ParentWindow) :
cSlotAreaInventoryBase(cInventory::invHotbarCount, cInventory::invHotbarOffset, a_ParentWindow)
{
}
@@ -140,7 +150,7 @@ class cSlotAreaArmor :
public cSlotAreaInventoryBase
{
public:
- cSlotAreaArmor(cWindow & a_ParentWindow) :
+ cSlotAreaArmor(cWindow & a_ParentWindow) :
cSlotAreaInventoryBase(cInventory::invArmorCount, cInventory::invArmorOffset, a_ParentWindow)
{
}
@@ -151,7 +161,7 @@ public:
/** Called when a player clicks in the window. Parameters taken from the click packet. */
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
- bool CanPlaceInSlot(int a_SlotNum, const cItem & a_Item);
+ static bool CanPlaceArmorInSlot(int a_SlotNum, const cItem & a_Item);
} ;
@@ -231,10 +241,12 @@ public:
virtual void Clicked (cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
virtual void DblClicked (cPlayer & a_Player, int a_SlotNum);
virtual void OnPlayerRemoved(cPlayer & a_Player) override;
+ virtual void SetSlot (int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
// Distributing items into this area is completely disabled
virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
+
protected:
/// Maps player's EntityID -> current recipe; not a std::map because cCraftingGrid needs proper constructor params
typedef std::list<std::pair<int, cCraftingRecipe> > cRecipeMap;
@@ -247,12 +259,55 @@ protected:
/// Handles a shift-click in the result slot. Crafts using the current recipe until it changes or no more space for result.
void ShiftClickedResult(cPlayer & a_Player);
-
+
+ /** Handles a drop-click in the result slot. */
+ void DropClickedResult(cPlayer & a_Player);
+
/// Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player
void UpdateRecipe(cPlayer & a_Player);
/// Retrieves the recipe for the specified player from the map, or creates one if not found
cCraftingRecipe & GetRecipeForPlayer(cPlayer & a_Player);
+
+ /// Called after an item has been crafted to handle statistics e.t.c.
+ void HandleCraftItem(const cItem & a_Result, cPlayer & a_Player);
+} ;
+
+
+
+
+
+class cSlotAreaAnvil :
+ public cSlotAreaTemporary
+{
+ typedef cSlotAreaTemporary super;
+
+public:
+ cSlotAreaAnvil(cAnvilWindow & a_ParentWindow);
+
+ // cSlotArea overrides:
+ virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
+ virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem) override;
+ virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
+
+ // cSlotAreaTemporary overrides:
+ virtual void OnPlayerRemoved(cPlayer & a_Player) override;
+
+ /** Can the player take the item from the slot? */
+ bool CanTakeResultItem(cPlayer & a_Player);
+
+ /** This function will call, when the player take the item from the slot. */
+ void OnTakeResult(cPlayer & a_Player);
+
+ /** Handles a click in the item slot. */
+ void UpdateResult(cPlayer & a_Player);
+
+protected:
+ /** The maximum cost of repairing/renaming in the anvil. */
+ int m_MaximumCost;
+
+ /** The stack size of the second item where was used for repair */
+ char m_StackSizeToBeUsedInRepair;
} ;
@@ -351,6 +406,7 @@ public:
virtual ~cSlotAreaFurnace();
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
+ virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
@@ -359,6 +415,9 @@ protected:
// cItemGrid::cListener overrides:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
+
+ /// Called after an item has been smelted to handle statistics e.t.c.
+ void HandleSmeltItem(const cItem & a_Result, cPlayer & a_Player);
} ;
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 0a78578fc..4731f282b 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -146,7 +146,6 @@ void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const
int NumSlots = (*itr)->GetNumSlots();
for (int i = 0; i < NumSlots; i++)
{
-
const cItem * Item = (*itr)->GetSlot(i, a_Player);
if (Item == NULL)
{
@@ -165,12 +164,12 @@ void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const
void cWindow::Clicked(
- cPlayer & a_Player,
+ cPlayer & a_Player,
int a_WindowID, short a_SlotNum, eClickAction a_ClickAction,
const cItem & a_ClickedItem
)
{
- cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
+ cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
if (a_WindowID != m_WindowID)
{
LOGWARNING("%s: Wrong window ID (exp %d, got %d) received from \"%s\"; ignoring click.", __FUNCTION__, m_WindowID, a_WindowID, a_Player.GetName().c_str());
@@ -179,6 +178,7 @@ void cWindow::Clicked(
switch (a_ClickAction)
{
+ case caLeftClickOutside:
case caRightClickOutside:
{
if (PlgMgr->CallHookPlayerTossingItem(a_Player))
@@ -191,25 +191,16 @@ void cWindow::Clicked(
a_Player.TossPickup(a_ClickedItem);
}
- // Toss one of the dragged items:
- a_Player.TossHeldItem();
- return;
- }
- case caLeftClickOutside:
- {
- if (PlgMgr->CallHookPlayerTossingItem(a_Player))
+ if (a_ClickAction == caLeftClickOutside)
{
- // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
- return;
+ // Toss all dragged items:
+ a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount);
}
-
- if (a_Player.IsGameModeCreative())
+ else
{
- a_Player.TossPickup(a_ClickedItem);
+ // Toss one of the dragged items:
+ a_Player.TossHeldItem();
}
-
- // Toss all dragged items:
- a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount);
return;
}
case caLeftClickOutsideHoldNothing:
@@ -283,7 +274,7 @@ void cWindow::OpenedByPlayer(cPlayer & a_Player)
bool cWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
{
// Checks whether the player is still holding an item
- if (a_Player.IsDraggingItem())
+ if (!a_Player.GetDraggingItem().IsEmpty())
{
LOGD("Player holds item! Dropping it...");
a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount);
@@ -328,9 +319,9 @@ void cWindow::OwnerDestroyed()
// Close window for each player. Note that the last one needs special handling
while (m_OpenedBy.size() > 1)
{
- (*m_OpenedBy.begin() )->CloseWindow();
+ (*m_OpenedBy.begin())->CloseWindow();
}
- (*m_OpenedBy.begin() )->CloseWindow();
+ (*m_OpenedBy.begin())->CloseWindow();
}
@@ -591,7 +582,7 @@ void cWindow::OnLeftPaintEnd(cPlayer & a_Player)
const cSlotNums & SlotNums = a_Player.GetInventoryPaintSlots();
cItem ToDistribute(a_Player.GetDraggingItem());
- int ToEachSlot = (int)ToDistribute.m_ItemCount / SlotNums.size();
+ int ToEachSlot = (int)ToDistribute.m_ItemCount / (int)SlotNums.size();
int NumDistributed = DistributeItemToSlots(a_Player, ToDistribute, ToEachSlot, SlotNums);
@@ -772,7 +763,7 @@ void cWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cInventoryWindow:
cInventoryWindow::cInventoryWindow(cPlayer & a_Player) :
@@ -789,7 +780,7 @@ cInventoryWindow::cInventoryWindow(cPlayer & a_Player) :
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cCraftingWindow:
cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
@@ -804,11 +795,57 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// cAnvilWindow:
+
+cAnvilWindow::cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
+ cWindow(wtAnvil, "Repair"),
+ m_RepairedItemName(""),
+ m_BlockX(a_BlockX),
+ m_BlockY(a_BlockY),
+ m_BlockZ(a_BlockZ)
+{
+ m_AnvilSlotArea = new cSlotAreaAnvil(*this);
+ m_SlotAreas.push_back(m_AnvilSlotArea);
+ m_SlotAreas.push_back(new cSlotAreaInventory(*this));
+ m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
+}
+
+
+
+
+
+void cAnvilWindow::SetRepairedItemName(const AString & a_Name, cPlayer * a_Player)
+{
+ m_RepairedItemName = a_Name;
+
+ if (a_Player != NULL)
+ {
+ m_AnvilSlotArea->UpdateResult(*a_Player);
+ }
+}
+
+
+
+
+
+void cAnvilWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ)
+{
+ a_PosX = m_BlockX;
+ a_PosY = m_BlockY;
+ a_PosZ = m_BlockZ;
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cEnchantingWindow:
cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
cWindow(wtEnchantment, "Enchant"),
+ m_SlotArea(),
m_BlockX(a_BlockX),
m_BlockY(a_BlockY),
m_BlockZ(a_BlockZ)
@@ -864,25 +901,27 @@ void cEnchantingWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cChestWindow:
cChestWindow::cChestWindow(cChestEntity * a_Chest) :
- cWindow(wtChest, "Chest"),
+ cWindow(wtChest, (a_Chest->GetBlockType() == E_BLOCK_CHEST) ? "Chest" : "Trapped Chest"),
m_World(a_Chest->GetWorld()),
m_BlockX(a_Chest->GetPosX()),
m_BlockY(a_Chest->GetPosY()),
- m_BlockZ(a_Chest->GetPosZ())
+ m_BlockZ(a_Chest->GetPosZ()),
+ m_PrimaryChest(a_Chest),
+ m_SecondaryChest(NULL)
{
m_SlotAreas.push_back(new cSlotAreaChest(a_Chest, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
// Play the opening sound:
- m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
// Send out the chest-open packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_CHEST);
+ m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType());
}
@@ -890,11 +929,13 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) :
cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest) :
- cWindow(wtChest, "Double Chest"),
+ cWindow(wtChest, (a_PrimaryChest->GetBlockType() == E_BLOCK_CHEST) ? "Double Chest" : "Double Trapped Chest"),
m_World(a_PrimaryChest->GetWorld()),
m_BlockX(a_PrimaryChest->GetPosX()),
m_BlockY(a_PrimaryChest->GetPosY()),
- m_BlockZ(a_PrimaryChest->GetPosZ())
+ m_BlockZ(a_PrimaryChest->GetPosZ()),
+ m_PrimaryChest(a_PrimaryChest),
+ m_SecondaryChest(a_SecondaryChest)
{
m_SlotAreas.push_back(new cSlotAreaDoubleChest(a_PrimaryChest, a_SecondaryChest, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
@@ -903,10 +944,55 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon
m_ShouldDistributeToHotbarFirst = false;
// Play the opening sound:
- m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
// Send out the chest-open packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_CHEST);
+ m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType());
+}
+
+
+
+
+
+void cChestWindow::OpenedByPlayer(cPlayer & a_Player)
+{
+ int ChunkX, ChunkZ;
+
+ m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() + 1);
+ cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
+ m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
+
+ if (m_SecondaryChest != NULL)
+ {
+ m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() + 1);
+ cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
+ m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
+ }
+
+ cWindow::OpenedByPlayer(a_Player);
+}
+
+
+
+
+
+bool cChestWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
+{
+ int ChunkX, ChunkZ;
+
+ m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() - 1);
+ cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
+ m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
+
+ if (m_SecondaryChest != NULL)
+ {
+ m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() - 1);
+ cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
+ m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
+ }
+
+ cWindow::ClosedByPlayer(a_Player, a_CanRefuse);
+ return true;
}
@@ -916,20 +1002,20 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon
cChestWindow::~cChestWindow()
{
// Send out the chest-close packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_CHEST);
+ m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType());
- m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cDropSpenserWindow:
cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_DropSpenser) :
- cWindow(wtDropSpenser, "Dropspenser")
+ cWindow(wtDropSpenser, (a_DropSpenser->GetBlockType() == E_BLOCK_DISPENSER) ? "Dispenser" : "Dropper")
{
m_ShouldDistributeToHotbarFirst = false;
m_SlotAreas.push_back(new cSlotAreaItemGrid(a_DropSpenser->GetContents(), *this));
@@ -941,7 +1027,7 @@ cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ,
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cEnderChestWindow:
cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
@@ -956,7 +1042,7 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
// Play the opening sound:
- m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
// Send out the chest-open packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST);
@@ -971,14 +1057,15 @@ cEnderChestWindow::~cEnderChestWindow()
// Send out the chest-close packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST);
- m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ // Play the closing sound
+ m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cHopperWindow:
cHopperWindow::cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEntity * a_Hopper) :
@@ -994,7 +1081,7 @@ cHopperWindow::cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEn
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFurnaceWindow:
cFurnaceWindow::cFurnaceWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceEntity * a_Furnace) :
diff --git a/src/UI/Window.h b/src/UI/Window.h
index 1ca67bfd8..97db0ca88 100644
--- a/src/UI/Window.h
+++ b/src/UI/Window.h
@@ -24,6 +24,7 @@ class cEnderChestEntity;
class cFurnaceEntity;
class cHopperEntity;
class cSlotArea;
+class cSlotAreaAnvil;
class cWorld;
typedef std::list<cPlayer *> cPlayerList;
@@ -35,12 +36,12 @@ typedef std::vector<cSlotArea *> cSlotAreas;
// tolua_begin
-/**
+/**
Represents a UI window.
Each window has a list of players that are currently using it
When there's no player using a window, it is destroyed.
-A window consists of several areas of slots with similar functionality - for example the crafting grid area, or
+A window consists of several areas of slots with similar functionality - for example the crafting grid area, or
the inventory area. Each area knows what its slots are (GetSlot() function) and can handle mouse clicks.
The window acts only as a top-level container for those areas, redirecting the click events to the correct areas.
Inventory painting, introduced in 1.5, is handled by the window, too
@@ -76,7 +77,7 @@ public:
int GetWindowType(void) const { return m_WindowType; } // tolua_export
cWindowOwner * GetOwner(void) { return m_Owner; }
- void SetOwner( cWindowOwner * a_Owner ) { m_Owner = a_Owner; }
+ void SetOwner( cWindowOwner * a_Owner) { m_Owner = a_Owner; }
/// Returns the total number of slots
int GetNumSlots(void) const;
@@ -108,12 +109,12 @@ public:
/// Handles a click event from a player
void Clicked(
- cPlayer & a_Player, int a_WindowID,
+ cPlayer & a_Player, int a_WindowID,
short a_SlotNum, eClickAction a_ClickAction,
const cItem & a_ClickedItem
);
- void OpenedByPlayer(cPlayer & a_Player);
+ virtual void OpenedByPlayer(cPlayer & a_Player);
/// Called when a player closes this window; notifies all slot areas. Returns true if close accepted
virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse);
@@ -133,7 +134,7 @@ public:
// tolua_begin
const AString & GetWindowTitle() const { return m_WindowTitle; }
- void SetWindowTitle(const AString & a_WindowTitle ) { m_WindowTitle = a_WindowTitle; }
+ void SetWindowTitle(const AString & a_WindowTitle) { m_WindowTitle = a_WindowTitle; }
/// Sends the UpdateWindowProperty (0x69) packet to all clients of the window
virtual void SetProperty(int a_Property, int a_Value);
@@ -231,6 +232,32 @@ public:
+class cAnvilWindow :
+ public cWindow
+{
+ typedef cWindow super;
+public:
+ cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ /** Gets the repaired item name. */
+ AString GetRepairedItemName(void) const { return m_RepairedItemName; }
+
+ /** Set the repaired item name. */
+ void SetRepairedItemName(const AString & a_Name, cPlayer * a_Player);
+
+ /** Gets the Position from the Anvil */
+ void GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ);
+
+protected:
+ cSlotAreaAnvil * m_AnvilSlotArea;
+ AString m_RepairedItemName;
+ int m_BlockX, m_BlockY, m_BlockZ;
+} ;
+
+
+
+
+
class cEnchantingWindow :
public cWindow
{
@@ -243,7 +270,7 @@ public:
/** Return the Value of a Property */
int GetPropertyValue(int a_Property);
- /** Set the Position Values to the Position of the Enchantment Table */
+ /** Get the Position from the Enchantment Table */
void GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ);
cSlotArea * m_SlotArea;
@@ -300,10 +327,15 @@ public:
cChestWindow(cChestEntity * a_Chest);
cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest);
~cChestWindow();
+
+ virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override;
+ virtual void OpenedByPlayer(cPlayer & a_Player) override;
protected:
cWorld * m_World;
int m_BlockX, m_BlockY, m_BlockZ; // Position of the chest, for the window-close packet
+ cChestEntity * m_PrimaryChest;
+ cChestEntity * m_SecondaryChest;
} ;
diff --git a/src/UI/WindowOwner.h b/src/UI/WindowOwner.h
index e3c73edc4..7a7941e37 100644
--- a/src/UI/WindowOwner.h
+++ b/src/UI/WindowOwner.h
@@ -6,7 +6,7 @@
#include "Window.h"
/*
-Being a descendant of cWindowOwner means that the class can own one window. That window can be
+Being a descendant of cWindowOwner means that the class can own one window. That window can be
queried, opened by other players, closed by players and finally destroyed.
Also, a cWindowOwner can be queried for the block coords where the window is displayed. That will be used
for entities / players in motion to close their windows when they get too far away from the window "source".
diff --git a/src/Vector3.h b/src/Vector3.h
index 2c79f9ff1..1dcb38f64 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -3,8 +3,10 @@
-#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC)
+#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC)
#include <math.h>
+#include <list>
+#include <vector>
@@ -40,7 +42,6 @@ public:
Vector3(const Vector3<_T> * a_Rhs) : x(a_Rhs->x), y(a_Rhs->y), z(a_Rhs->z) {}
// tolua_begin
-
inline void Set(T a_x, T a_y, T a_z)
{
x = a_x;
@@ -105,18 +106,18 @@ public:
inline bool Equals(const Vector3<T> & a_Rhs) const
{
- return x == a_Rhs.x && y == a_Rhs.y && z == a_Rhs.z;
- }
-
- inline bool operator == (const Vector3<T> & a_Rhs) const
- {
- return Equals(a_Rhs);
+ // Perform a bitwise comparison of the contents - we want to know whether this object is exactly equal
+ // To perform EPS-based comparison, use the EqualsEps() function
+ return (
+ (memcmp(&x, &a_Rhs.x, sizeof(x)) == 0) &&
+ (memcmp(&y, &a_Rhs.y, sizeof(y)) == 0) &&
+ (memcmp(&z, &a_Rhs.z, sizeof(z)) == 0)
+ );
}
-
- inline bool operator < (const Vector3<T> & a_Rhs)
+
+ inline bool EqualsEps(const Vector3<T> & a_Rhs, T a_Eps) const
{
- // return (x < a_Rhs.x) && (y < a_Rhs.y) && (z < a_Rhs.z); ?
- return (x < a_Rhs.x) || (x == a_Rhs.x && y < a_Rhs.y) || (x == a_Rhs.x && y == a_Rhs.y && z < a_Rhs.z);
+ return (Abs(x - a_Rhs.x) < a_Eps) && (Abs(y - a_Rhs.y) < a_Eps) && (Abs(z - a_Rhs.z) < a_Eps);
}
inline void Move(T a_X, T a_Y, T a_Z)
@@ -133,8 +134,38 @@ public:
z += a_Diff.z;
}
+ /** Runs each value of the vector through std::floor() */
+ inline Vector3<int> Floor(void) const
+ {
+ return Vector3<int>(
+ (int)floor(x),
+ (int)floor(y),
+ (int)floor(z)
+ );
+ }
+
// tolua_end
+ inline bool operator != (const Vector3<T> & a_Rhs) const
+ {
+ return !Equals(a_Rhs);
+ }
+
+ inline bool operator == (const Vector3<T> & a_Rhs) const
+ {
+ return Equals(a_Rhs);
+ }
+
+ inline bool operator > (const Vector3<T> & a_Rhs) const
+ {
+ return (SqrLength() > a_Rhs.SqrLength());
+ }
+
+ inline bool operator < (const Vector3<T> & a_Rhs) const
+ {
+ return (SqrLength() < a_Rhs.SqrLength());
+ }
+
inline void operator += (const Vector3<T> & a_Rhs)
{
x += a_Rhs.x;
@@ -163,8 +194,16 @@ public:
z *= a_v;
}
- // tolua_begin
+ inline Vector3<T> & operator = (const Vector3<T> & a_Rhs)
+ {
+ x = a_Rhs.x;
+ y = a_Rhs.y;
+ z = a_Rhs.z;
+ return *this;
+ }
+ // tolua_begin
+
inline Vector3<T> operator + (const Vector3<T>& a_Rhs) const
{
return Vector3<T>(
@@ -217,7 +256,7 @@ public:
*/
inline double LineCoeffToXYPlane(const Vector3<T> & a_OtherEnd, T a_Z) const
{
- if (abs(z - a_OtherEnd.z) < EPS)
+ if (Abs(z - a_OtherEnd.z) < EPS)
{
return NO_INTERSECTION;
}
@@ -232,7 +271,7 @@ public:
*/
inline double LineCoeffToXZPlane(const Vector3<T> & a_OtherEnd, T a_Y) const
{
- if (abs(y - a_OtherEnd.y) < EPS)
+ if (Abs(y - a_OtherEnd.y) < EPS)
{
return NO_INTERSECTION;
}
@@ -247,7 +286,7 @@ public:
*/
inline double LineCoeffToYZPlane(const Vector3<T> & a_OtherEnd, T a_X) const
{
- if (abs(x - a_OtherEnd.x) < EPS)
+ if (Abs(x - a_OtherEnd.x) < EPS)
{
return NO_INTERSECTION;
}
@@ -260,6 +299,15 @@ public:
/** Return value of LineCoeffToPlane() if the line is parallel to the plane. */
static const double NO_INTERSECTION;
+
+protected:
+
+ /** Returns the absolute value of the given argument.
+ Templatized because the standard library differentiates between abs() and fabs(). */
+ static T Abs(T a_Value)
+ {
+ return (a_Value < 0) ? -a_Value : a_Value;
+ }
};
// tolua_end
@@ -268,6 +316,15 @@ public:
+template <> inline Vector3<int> Vector3<int>::Floor(void) const
+{
+ return *this;
+}
+
+
+
+
+
template <typename T>
const double Vector3<T>::EPS = 0.000001;
diff --git a/src/VoronoiMap.cpp b/src/VoronoiMap.cpp
index 7a36edebc..5efd09c01 100644
--- a/src/VoronoiMap.cpp
+++ b/src/VoronoiMap.cpp
@@ -11,8 +11,12 @@
cVoronoiMap::cVoronoiMap(int a_Seed, int a_CellSize) :
- m_Noise(a_Seed),
- m_CellSize(a_CellSize)
+ m_Noise1(a_Seed + 1),
+ m_Noise2(a_Seed + 2),
+ m_Noise3(a_Seed + 3),
+ m_CellSize(a_CellSize),
+ m_CurrentCellX(9999999), // Cell coords that are definitely out of the range for normal generator, so that the first query will overwrite them
+ m_CurrentCellZ(9999999)
{
}
@@ -57,26 +61,25 @@ int cVoronoiMap::GetValueAt(int a_X, int a_Y, int & a_MinDist1, int & a_MinDist2
int CellX = a_X / m_CellSize;
int CellZ = a_Y / m_CellSize;
+ UpdateCell(CellX, CellZ);
+
// Get 5x5 neighboring cell seeds, compare distance to each. Return the value in the minumim-distance cell
int MinDist = m_CellSize * m_CellSize * 16; // There has to be a cell closer than this
int MinDist2 = MinDist;
int res = 0; // Will be overriden
- for (int x = CellX - 2; x <= CellX + 2; x++)
+ for (int x = 0; x < 5; x++)
{
- int BaseX = x * m_CellSize;
- for (int z = CellZ - 2; z < CellZ + 2; z++)
+ for (int z = 0; z < 5; z++)
{
- int OffsetX = (m_Noise.IntNoise3DInt(x, 16 * x + 32 * z, z) / 8) % m_CellSize;
- int OffsetZ = (m_Noise.IntNoise3DInt(x, 32 * x - 16 * z, z) / 8) % m_CellSize;
- int SeedX = BaseX + OffsetX;
- int SeedZ = z * m_CellSize + OffsetZ;
+ int SeedX = m_SeedX[x][z];
+ int SeedZ = m_SeedZ[x][z];
int Dist = (SeedX - a_X) * (SeedX - a_X) + (SeedZ - a_Y) * (SeedZ - a_Y);
if (Dist < MinDist)
{
MinDist2 = MinDist;
MinDist = Dist;
- res = m_Noise.IntNoise3DInt(x, x - z + 1000, z);
+ res = m_Noise3.IntNoise2DInt(x + CellX - 2, z + CellZ - 2);
}
else if (Dist < MinDist2)
{
@@ -93,3 +96,33 @@ int cVoronoiMap::GetValueAt(int a_X, int a_Y, int & a_MinDist1, int & a_MinDist2
+
+void cVoronoiMap::UpdateCell(int a_CellX, int a_CellZ)
+{
+ // If the specified cell is currently cached, bail out:
+ if ((a_CellX == m_CurrentCellX) && (a_CellZ == m_CurrentCellZ))
+ {
+ return;
+ }
+
+ // Update the cell cache for the new cell position:
+ int NoiseBaseX = a_CellX - 2;
+ int NoiseBaseZ = a_CellZ - 2;
+ for (int x = 0; x < 5; x++)
+ {
+ int BaseX = (NoiseBaseX + x) * m_CellSize;
+ for (int z = 0; z < 5; z++)
+ {
+ int OffsetX = (m_Noise1.IntNoise2DInt(NoiseBaseX + x, NoiseBaseZ + z) / 8) % m_CellSize;
+ int OffsetZ = (m_Noise2.IntNoise2DInt(NoiseBaseX + x, NoiseBaseZ + z) / 8) % m_CellSize;
+ m_SeedX[x][z] = BaseX + OffsetX;
+ m_SeedZ[x][z] = (NoiseBaseZ + z) * m_CellSize + OffsetZ;
+ } // for z
+ } // for x
+ m_CurrentCellX = a_CellX;
+ m_CurrentCellZ = a_CellZ;
+}
+
+
+
+
diff --git a/src/VoronoiMap.h b/src/VoronoiMap.h
index bcd37f9cf..84cf206e9 100644
--- a/src/VoronoiMap.h
+++ b/src/VoronoiMap.h
@@ -29,15 +29,34 @@ public:
/// Returns the value in the cell into which the specified point lies, and the distance to the nearest Voronoi seed
int GetValueAt(int a_X, int a_Y, int & a_MinDistance);
- /// Returns the value in the cell into which the specified point lies, and the distances to the 2 nearest Voronoi seeds
+ /// Returns the value in the cell into which the specified point lies, and the distances to the 2 nearest Voronoi seeds. Uses a cache
int GetValueAt(int a_X, int a_Y, int & a_MinDistance1, int & a_MinDistance2);
-
+
protected:
/// The noise used for generating Voronoi seeds
- cNoise m_Noise;
+ cNoise m_Noise1;
+ cNoise m_Noise2;
+ cNoise m_Noise3;
/// Size of the Voronoi cells (avg X/Y distance between the seeds)
int m_CellSize;
+
+ /** The X coordinate of the currently cached cell neighborhood */
+ int m_CurrentCellX;
+
+ /** The Z coordinate of the currently cached cell neighborhood */
+ int m_CurrentCellZ;
+
+ /** The seeds of cells around m_CurrentCellX, m_CurrentCellZ, X-coords */
+ int m_SeedX[5][5];
+
+ /** The seeds of cells around m_CurrentCellX, m_CurrentCellZ, X-coords */
+ int m_SeedZ[5][5];
+
+
+ /** Updates the cached cell seeds to match the specified cell. Noop if cell pos already matches.
+ Updates m_SeedX and m_SeedZ. */
+ void UpdateCell(int a_CellX, int a_CellZ);
} ;
diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp
index 737705d7c..f5dc6fde7 100644
--- a/src/WebAdmin.cpp
+++ b/src/WebAdmin.cpp
@@ -89,6 +89,7 @@ bool cWebAdmin::Init(void)
m_IniFile.AddHeaderComment(" Password format: Password=*password*; for example:");
m_IniFile.AddHeaderComment(" [User:admin]");
m_IniFile.AddHeaderComment(" Password=admin");
+ m_IniFile.WriteFile("webadmin.ini");
}
if (!m_IniFile.GetValueSetB("WebAdmin", "Enabled", true))
@@ -373,7 +374,7 @@ AString cWebAdmin::GetDefaultPage(void)
{
AString Content;
Content += "<h4>Server Name:</h4>";
- Content += "<p>" + AString( cRoot::Get()->GetServer()->GetServerID() ) + "</p>";
+ Content += "<p>" + AString( cRoot::Get()->GetServer()->GetServerID()) + "</p>";
Content += "<h4>Plugins:</h4><ul>";
cPluginManager * PM = cPluginManager::Get();
@@ -390,8 +391,8 @@ AString cWebAdmin::GetDefaultPage(void)
Content += "<h4>Players:</h4><ul>";
cPlayerAccum PlayerAccum;
- cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players
- if( World != NULL )
+ cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players
+ if (World != NULL)
{
World->ForEachPlayer(PlayerAccum);
Content.append(PlayerAccum.m_Contents);
@@ -403,7 +404,7 @@ AString cWebAdmin::GetDefaultPage(void)
-AString cWebAdmin::GetBaseURL( const AString& a_URL )
+AString cWebAdmin::GetBaseURL( const AString& a_URL)
{
return GetBaseURL(StringSplit(a_URL, "/"));
}
@@ -523,13 +524,14 @@ void cWebAdmin::OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest &
// Delete any request data assigned to the request:
cRequestData * Data = (cRequestData *)(a_Request.GetUserData());
delete Data;
+ Data = NULL;
}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWebAdmin::cWebadminRequestData
void cWebAdmin::cWebadminRequestData::OnBody(const char * a_Data, size_t a_Size)
diff --git a/src/WebAdmin.h b/src/WebAdmin.h
index d5e45828f..d679a097c 100644
--- a/src/WebAdmin.h
+++ b/src/WebAdmin.h
@@ -60,11 +60,11 @@ struct HTTPRequest
StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS <<
/** Parameters posted as a part of a form - either in the URL (GET method) or in the body (POST method) */
- StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS <<
+ StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS <<
/** Same as PostParams */
FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS <<
-} ; // tolua_export
+} ; // tolua_export
@@ -120,7 +120,7 @@ public:
void RemovePlugin(cWebPlugin * a_Plugin);
// TODO: Convert this to the auto-locking callback mechanism used for looping players in worlds and such
- PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS <<
+ PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS <<
// tolua_begin
@@ -218,7 +218,7 @@ protected:
virtual void OnRequestBegun (cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override;
virtual void OnRequestBody (cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size) override;
virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override;
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/World.cpp b/src/World.cpp
index 5ac8e0a6e..84c0f2b93 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -11,6 +11,7 @@
#include "ChunkMap.h"
#include "Generating/ChunkDesc.h"
#include "OSSupport/Timer.h"
+#include "SetChunkData.h"
// Serializers
#include "WorldStorage/ScoreboardSerializer.h"
@@ -70,7 +71,7 @@ const int TIME_SPAWN_DIVISOR = 148;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWorldLoadProgress:
/// A simple thread that displays the progress of world loading / saving in cWorld::InitializeSpawn()
@@ -99,7 +100,7 @@ protected:
{
for (;;)
{
- LOG("" SIZE_T_FMT " chunks to load, %d chunks to generate",
+ LOG("" SIZE_T_FMT " chunks to load, %d chunks to generate",
m_World->GetStorage().GetLoadQueueLength(),
m_World->GetGenerator().GetQueueLength()
);
@@ -122,7 +123,7 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWorldLightingProgress:
/// A simple thread that displays the progress of world lighting in cWorld::InitializeSpawn()
@@ -172,7 +173,7 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWorld::cLock:
cWorld::cLock::cLock(cWorld & a_World) :
@@ -184,7 +185,7 @@ cWorld::cLock::cLock(cWorld & a_World) :
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWorld::cTickThread:
cWorld::cTickThread::cTickThread(cWorld & a_World) :
@@ -226,11 +227,12 @@ void cWorld::cTickThread::Execute(void)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWorld:
-cWorld::cWorld(const AString & a_WorldName) :
+cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName) :
m_WorldName(a_WorldName),
+ m_OverworldName(a_OverworldName),
m_IniFileName(m_WorldName + "/world.ini"),
m_StorageSchema("Default"),
#ifdef __arm__
@@ -238,6 +240,7 @@ cWorld::cWorld(const AString & a_WorldName) :
#else
m_StorageCompressionFactor(6),
#endif
+ m_Dimension(a_Dimension),
m_IsSpawnExplicitlySet(false),
m_WorldAgeSecs(0),
m_TimeOfDaySecs(0),
@@ -267,12 +270,12 @@ cWorld::cWorld(const AString & a_WorldName) :
cWorld::~cWorld()
{
- delete m_SimulatorManager;
- delete m_SandSimulator;
- delete m_WaterSimulator;
- delete m_LavaSimulator;
- delete m_FireSimulator;
- delete m_RedstoneSimulator;
+ delete m_SimulatorManager; m_SimulatorManager = NULL;
+ delete m_SandSimulator; m_SandSimulator = NULL;
+ delete m_WaterSimulator; m_WaterSimulator = NULL;
+ delete m_LavaSimulator; m_LavaSimulator = NULL;
+ delete m_FireSimulator; m_FireSimulator = NULL;
+ delete m_RedstoneSimulator; m_RedstoneSimulator = NULL;
UnloadUnusedChunks();
@@ -375,29 +378,31 @@ void cWorld::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ)
void cWorld::InitializeSpawn(void)
{
- if (!m_IsSpawnExplicitlySet) // Check if spawn position was already explicitly set or not
+ if (!m_IsSpawnExplicitlySet)
{
- GenerateRandomSpawn(); // Generate random solid-land coordinate and then write it to the world configuration
-
+ // Spawn position wasn't already explicitly set, enerate random solid-land coordinate and then write it to the world configuration:
+ GenerateRandomSpawn();
cIniFile IniFile;
IniFile.ReadFile(m_IniFileName);
-
IniFile.SetValueF("SpawnPosition", "X", m_SpawnX);
IniFile.SetValueF("SpawnPosition", "Y", m_SpawnY);
IniFile.SetValueF("SpawnPosition", "Z", m_SpawnZ);
-
IniFile.WriteFile(m_IniFileName);
}
- int ChunkX = 0, ChunkY = 0, ChunkZ = 0;
- BlockToChunk((int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ, ChunkX, ChunkY, ChunkZ);
+ int ChunkX = 0, ChunkZ = 0;
+ cChunkDef::BlockToChunk((int)m_SpawnX, (int)m_SpawnZ, ChunkX, ChunkZ);
// For the debugging builds, don't make the server build too much world upon start:
#if defined(_DEBUG) || defined(ANDROID_NDK)
- int ViewDist = 9;
+ const int DefaultViewDist = 9;
#else
- int ViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is
+ const int DefaultViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is
#endif // _DEBUG
+ cIniFile IniFile;
+ IniFile.ReadFile(m_IniFileName);
+ int ViewDist = IniFile.GetValueSetI("SpawnPosition", "PregenerateDistance", DefaultViewDist);
+ IniFile.WriteFile(m_IniFileName);
LOG("Preparing spawn area in world \"%s\"...", m_WorldName.c_str());
for (int x = 0; x < ViewDist; x++)
@@ -515,9 +520,15 @@ void cWorld::Start(void)
if (!IniFile.ReadFile(m_IniFileName))
{
LOGWARNING("Cannot read world settings from \"%s\", defaults will be used.", m_IniFileName.c_str());
+
+ // TODO: More descriptions for each key
+ IniFile.AddHeaderComment(" This is the per-world configuration file, managing settings such as generators, simulators, and spawn points");
+ IniFile.AddKeyComment(" LinkedWorlds", "This section governs portal world linkage; leave a value blank to disabled that associated method of teleportation");
}
- AString Dimension = IniFile.GetValueSet("General", "Dimension", "Overworld");
- m_Dimension = StringToDimension(Dimension);
+
+ // The presence of a configuration value overrides everything
+ // If no configuration value is found, GetDimension() is written to file and the variable is written to again to ensure that cosmic rays haven't sneakily changed its value
+ m_Dimension = StringToDimension(IniFile.GetValueSet("General", "Dimension", DimensionToString(GetDimension())));
// Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found
int KeyNum = IniFile.FindKey("SpawnPosition");
@@ -525,8 +536,8 @@ void cWorld::Start(void)
(
(KeyNum >= 0) &&
(
- (IniFile.FindValue(KeyNum, "X") >= 0) ||
- (IniFile.FindValue(KeyNum, "Y") >= 0) ||
+ (IniFile.FindValue(KeyNum, "X") >= 0) &&
+ (IniFile.FindValue(KeyNum, "Y") >= 0) &&
(IniFile.FindValue(KeyNum, "Z") >= 0)
)
);
@@ -562,35 +573,26 @@ void cWorld::Start(void)
m_bUseChatPrefixes = IniFile.GetValueSetB("Mechanics", "UseChatPrefixes", true);
m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true);
int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode);
-
- // Adjust the enum-backed variables into their respective bounds:
- m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure);
- m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll);
+ int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather);
+ m_TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay);
- // Load allowed mobs:
- const char * DefaultMonsters = "";
- switch (m_Dimension)
+ if (GetDimension() == dimOverworld)
{
- case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break;
- case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break;
- case dimEnd: DefaultMonsters = "enderman"; break;
+ m_NetherWorldName = IniFile.GetValueSet("LinkedWorlds", "NetherWorldName", GetName() + "_nether");
+ m_EndWorldName = IniFile.GetValueSet("LinkedWorlds", "EndWorldName", GetName() + "_end");
}
- m_bAnimals = IniFile.GetValueSetB("Monsters", "AnimalsOn", true);
- AString AllMonsters = IniFile.GetValueSet("Monsters", "Types", DefaultMonsters);
- AStringVector SplitList = StringSplitAndTrim(AllMonsters, ",");
- for (AStringVector::const_iterator itr = SplitList.begin(), end = SplitList.end(); itr != end; ++itr)
+ else
{
- cMonster::eType ToAdd = cMonster::StringToMobType(*itr);
- if (ToAdd != cMonster::mtInvalidType)
- {
- m_AllowedMobs.insert(ToAdd);
- LOGD("Allowed mob: %s", itr->c_str());
- }
- else
- {
- LOG("World \"%s\": Unknown mob type: %s", m_WorldName.c_str(), itr->c_str());
- }
+ m_OverworldName = IniFile.GetValueSet("LinkedWorlds", "OverworldName", GetLinkedOverworldName());
}
+
+ // Adjust the enum-backed variables into their respective bounds:
+ m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure);
+ m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll);
+ m_Weather = (eWeather) Clamp(Weather, (int)wSunny, (int)wStorm);
+
+ InitialiseGeneratorDefaults(IniFile);
+ InitialiseAndLoadMobSpawningValues(IniFile);
m_ChunkMap = new cChunkMap(this);
@@ -614,7 +616,7 @@ void cWorld::Start(void)
m_SimulatorManager->RegisterSimulator(m_FireSimulator, 1);
m_Lighting.Start(this);
- m_Storage.Start(this, m_StorageSchema, m_StorageCompressionFactor );
+ m_Storage.Start(this, m_StorageSchema, m_StorageCompressionFactor);
m_Generator.Start(m_GeneratorCallbacks, m_GeneratorCallbacks, IniFile);
m_ChunkSender.Start(this);
m_TickThread.Start();
@@ -644,7 +646,7 @@ void cWorld::GenerateRandomSpawn(void)
while (IsBlockWaterOrIce(GetBlock((int)m_SpawnX, GetHeight((int)m_SpawnX, (int)m_SpawnZ), (int)m_SpawnZ)))
{
- if ((GetTickRandomNumber(4) % 2) == 0) // Randomise whether to increment X or Z coords
+ if ((GetTickRandomNumber(4) % 2) == 0) // Randomise whether to increment X or Z coords
{
m_SpawnX += cChunkDef::Width;
}
@@ -654,7 +656,7 @@ void cWorld::GenerateRandomSpawn(void)
}
}
- m_SpawnY = (double)GetHeight((int)m_SpawnX, (int)m_SpawnZ) + 1.6f; // 1.6f to accomodate player height
+ m_SpawnY = (double)GetHeight((int)m_SpawnX, (int)m_SpawnZ) + 1.6f; // 1.6f to accomodate player height
LOGD("Generated random spawnpoint %i %i %i", (int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ);
}
@@ -687,6 +689,82 @@ eWeather cWorld::ChooseNewWeather()
+void cWorld::InitialiseGeneratorDefaults(cIniFile & a_IniFile)
+{
+ switch (GetDimension())
+ {
+ case dimEnd:
+ {
+ a_IniFile.GetValueSet("Generator", "BiomeGen", "Constant");
+ a_IniFile.GetValueSet("Generator", "ConstantBiome", "End");
+ a_IniFile.GetValueSet("Generator", "HeightGen", "Biomal");
+ a_IniFile.GetValueSet("Generator", "CompositionGen", "End");
+ break;
+ }
+ case dimOverworld:
+ {
+ a_IniFile.GetValueSet("Generator", "BiomeGen", "MultiStepMap");
+ a_IniFile.GetValueSet("Generator", "HeightGen", "DistortedHeightmap");
+ a_IniFile.GetValueSet("Generator", "CompositionGen", "DistortedHeightmap");
+ a_IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, WaterSprings, LavaLakes, LavaSprings, OreNests, Mineshafts, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator");
+ break;
+ }
+ case dimNether:
+ {
+ a_IniFile.GetValueSet("Generator", "BiomeGen", "Constant");
+ a_IniFile.GetValueSet("Generator", "ConstantBiome", "Nether");
+ a_IniFile.GetValueSet("Generator", "HeightGen", "Flat");
+ a_IniFile.GetValueSet("Generator", "FlatHeight", "128");
+ a_IniFile.GetValueSet("Generator", "CompositionGen", "Nether");
+ a_IniFile.GetValueSet("Generator", "Finishers", "WormNestCaves, BottomLava, LavaSprings, NetherClumpFoliage, NetherForts, PreSimulator");
+ a_IniFile.GetValueSet("Generator", "BottomLavaHeight", "30");
+ break;
+ }
+ }
+}
+
+
+
+
+
+void cWorld::InitialiseAndLoadMobSpawningValues(cIniFile & a_IniFile)
+{
+ AString DefaultMonsters;
+ switch (m_Dimension)
+ {
+ case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break;
+ case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break;
+ case dimEnd: DefaultMonsters = "enderman"; break;
+ }
+
+ m_bAnimals = a_IniFile.GetValueSetB("Monsters", "AnimalsOn", true);
+ AString AllMonsters = a_IniFile.GetValueSet("Monsters", "Types", DefaultMonsters);
+
+ if (!m_bAnimals)
+ {
+ return;
+ }
+
+ AStringVector SplitList = StringSplitAndTrim(AllMonsters, ",");
+ for (AStringVector::const_iterator itr = SplitList.begin(), end = SplitList.end(); itr != end; ++itr)
+ {
+ cMonster::eType ToAdd = cMonster::StringToMobType(*itr);
+ if (ToAdd != cMonster::mtInvalidType)
+ {
+ m_AllowedMobs.insert(ToAdd);
+ LOGD("Allowed mob: %s", itr->c_str());
+ }
+ else
+ {
+ LOG("World \"%s\": Unknown mob type: %s", m_WorldName.c_str(), itr->c_str());
+ }
+ }
+}
+
+
+
+
+
void cWorld::Stop(void)
{
// Delete the clients that have been in this world:
@@ -699,6 +777,25 @@ void cWorld::Stop(void)
} // for itr - m_Clients[]
m_Clients.clear();
}
+
+ // Write settings to file; these are all plugin changeable values - keep updated!
+ cIniFile IniFile;
+ IniFile.ReadFile(m_IniFileName);
+ if (GetDimension() == dimOverworld)
+ {
+ IniFile.SetValue("LinkedWorlds", "NetherWorldName", m_NetherWorldName);
+ IniFile.SetValue("LinkedWorlds", "EndWorldName", m_EndWorldName);
+ }
+ else
+ {
+ IniFile.SetValue("LinkedWorlds", "OverworldName", m_OverworldName);
+ }
+ IniFile.SetValueI("Physics", "TNTShrapnelLevel", (int)m_TNTShrapnelLevel);
+ IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled);
+ IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes);
+ IniFile.SetValueI("General", "Weather", (int)m_Weather);
+ IniFile.SetValueI("General", "TimeInTicks", m_TimeOfDay);
+ IniFile.WriteFile(m_IniFileName);
m_TickThread.Stop();
m_Lighting.Stop();
@@ -716,6 +813,17 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec)
// Call the plugins
cPluginManager::Get()->CallHookWorldTick(*this, a_Dt, a_LastTickDurationMSec);
+ // Set any chunk data that has been queued for setting:
+ cSetChunkDataPtrs SetChunkDataQueue;
+ {
+ cCSLock Lock(m_CSSetChunkDataQueue);
+ std::swap(SetChunkDataQueue, m_SetChunkDataQueue);
+ }
+ for (cSetChunkDataPtrs::iterator itr = SetChunkDataQueue.begin(), end = SetChunkDataQueue.end(); itr != end; ++itr)
+ {
+ SetChunkData(**itr);
+ } // for itr - SetChunkDataQueue[]
+
// We need sub-tick precision here, that's why we store the time in seconds and calculate ticks off of it
m_WorldAgeSecs += (double)a_Dt / 1000.0;
m_TimeOfDaySecs += (double)a_Dt / 1000.0;
@@ -739,6 +847,20 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec)
m_LastTimeUpdate = m_WorldAge;
}
+ // Add entities waiting in the queue to be added:
+ {
+ cCSLock Lock(m_CSEntitiesToAdd);
+ for (cEntityList::iterator itr = m_EntitiesToAdd.begin(), end = m_EntitiesToAdd.end(); itr != end; ++itr)
+ {
+ (*itr)->SetWorld(this);
+ m_ChunkMap->AddEntity(*itr);
+ }
+ m_EntitiesToAdd.clear();
+ }
+
+ // Add players waiting in the queue to be added:
+ AddQueuedPlayers();
+
m_ChunkMap->Tick(a_Dt);
TickClients(a_Dt);
@@ -752,12 +874,12 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec)
m_ChunkMap->FastSetQueuedBlocks();
- if (m_WorldAge - m_LastSave > 60 * 5 * 20) // Save each 5 minutes
+ if (m_WorldAge - m_LastSave > 60 * 5 * 20) // Save each 5 minutes
{
SaveAllChunks();
}
- if (m_WorldAge - m_LastUnload > 10 * 20) // Unload every 10 seconds
+ if (m_WorldAge - m_LastUnload > 10 * 20) // Unload every 10 seconds
{
UnloadUnusedChunks();
}
@@ -843,19 +965,19 @@ void cWorld::TickMobs(float a_Dt)
SpawnMobFinalize(*itr2);
}
}
- } // for i - AllFamilies[]
- } // if (Spawning enabled)
+ } // for i - AllFamilies[]
+ } // if (Spawning enabled)
// move close mobs
cMobProximityCounter::sIterablePair allCloseEnoughToMoveMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(-1, 64 * 16);// MG TODO : deal with this magic number (the 16 is the size of a block)
- for(cMobProximityCounter::tDistanceToMonster::const_iterator itr = allCloseEnoughToMoveMobs.m_Begin; itr != allCloseEnoughToMoveMobs.m_End; ++itr)
+ for (cMobProximityCounter::tDistanceToMonster::const_iterator itr = allCloseEnoughToMoveMobs.m_Begin; itr != allCloseEnoughToMoveMobs.m_End; ++itr)
{
itr->second.m_Monster.Tick(a_Dt, itr->second.m_Chunk);
}
// remove too far mobs
cMobProximityCounter::sIterablePair allTooFarMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(128 * 16, -1);// MG TODO : deal with this magic number (the 16 is the size of a block)
- for(cMobProximityCounter::tDistanceToMonster::const_iterator itr = allTooFarMobs.m_Begin; itr != allTooFarMobs.m_End; ++itr)
+ for (cMobProximityCounter::tDistanceToMonster::const_iterator itr = allTooFarMobs.m_Begin; itr != allTooFarMobs.m_End; ++itr)
{
itr->second.m_Monster.Destroy(true);
}
@@ -926,11 +1048,7 @@ void cWorld::TickClients(float a_Dt)
// Add clients scheduled for adding:
for (cClientHandleList::iterator itr = m_ClientsToAdd.begin(), end = m_ClientsToAdd.end(); itr != end; ++itr)
{
- if (std::find(m_Clients.begin(), m_Clients.end(), *itr) != m_Clients.end())
- {
- ASSERT(!"Adding a client that is already in the clientlist");
- continue;
- }
+ ASSERT(std::find(m_Clients.begin(), m_Clients.end(), *itr) == m_Clients.end());
m_Clients.push_back(*itr);
} // for itr - m_ClientsToRemove[]
m_ClientsToAdd.clear();
@@ -954,7 +1072,7 @@ void cWorld::TickClients(float a_Dt)
for (cClientHandleList::iterator itr = RemoveClients.begin(); itr != RemoveClients.end(); ++itr)
{
delete *itr;
- } // for itr - RemoveClients[]
+ } // for itr - RemoveClients[]
}
@@ -1070,7 +1188,7 @@ void cWorld::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_Blo
Vector3d explosion_pos = Vector3d(a_BlockX, a_BlockY, a_BlockZ);
cVector3iArray BlocksAffected;
m_ChunkMap->DoExplosionAt(a_ExplosionSize, a_BlockX, a_BlockY, a_BlockZ, BlocksAffected);
- BroadcastSoundEffect("random.explode", (int)floor(a_BlockX * 8), (int)floor(a_BlockY * 8), (int)floor(a_BlockZ * 8), 1.0f, 0.6f);
+ BroadcastSoundEffect("random.explode", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.6f);
{
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -1547,9 +1665,9 @@ bool cWorld::SetAreaBiome(const cCuboid & a_Area, EMCSBiome a_Biome)
-void cWorld::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+void cWorld::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients)
{
- m_ChunkMap->SetBlock(*this, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
+ m_ChunkMap->SetBlock(*this, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_SendToClients);
}
@@ -1627,7 +1745,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
a_BlockX, a_BlockY, a_BlockZ,
*itr, IsPlayerCreated, SpeedX, SpeedY, SpeedZ
);
- Pickup->Initialize(this);
+ Pickup->Initialize(*this);
}
}
@@ -1648,7 +1766,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
a_BlockX, a_BlockY, a_BlockZ,
*itr, IsPlayerCreated, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ
);
- Pickup->Initialize(this);
+ Pickup->Initialize(*this);
}
}
@@ -1659,7 +1777,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
int cWorld::SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta)
{
cFallingBlock * FallingBlock = new cFallingBlock(Vector3i(a_X, a_Y, a_Z), BlockType, BlockMeta);
- FallingBlock->Initialize(this);
+ FallingBlock->Initialize(*this);
return FallingBlock->GetUniqueID();
}
@@ -1675,7 +1793,7 @@ int cWorld::SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward)
}
cExpOrb * ExpOrb = new cExpOrb(a_X, a_Y, a_Z, a_Reward);
- ExpOrb->Initialize(this);
+ ExpOrb->Initialize(*this);
return ExpOrb->GetUniqueID();
}
@@ -1698,7 +1816,7 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType
return -1;
}
} // switch (a_MinecartType)
- Minecart->Initialize(this);
+ Minecart->Initialize(*this);
return Minecart->GetUniqueID();
}
@@ -1709,7 +1827,7 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType
void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTicks, double a_InitialVelocityCoeff)
{
cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTicks);
- TNT->Initialize(this);
+ TNT->Initialize(*this);
TNT->SetSpeed(
a_InitialVelocityCoeff * (GetTickRandomNumber(2) - 1), /** -1, 0, 1 */
a_InitialVelocityCoeff * 2,
@@ -1859,9 +1977,9 @@ void cWorld::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer
-void cWorld::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
+void cWorld::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude);
+ m_ChunkMap->BroadcastCollectEntity(a_Entity, a_Player, a_Exclude);
}
@@ -2056,9 +2174,9 @@ void cWorld::BroadcastDisplayObjective(const AString & a_Objective, cScoreboard:
-void cWorld::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cWorld::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
+ m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch, a_Exclude);
}
@@ -2164,9 +2282,18 @@ void cWorld::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHa
-void cWorld::MarkChunkDirty (int a_ChunkX, int a_ChunkZ)
+void cWorld::MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ)
+{
+ m_ChunkMap->MarkRedstoneDirty(a_ChunkX, a_ChunkZ);
+}
+
+
+
+
+
+void cWorld::MarkChunkDirty(int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty)
{
- m_ChunkMap->MarkChunkDirty (a_ChunkX, a_ChunkZ);
+ m_ChunkMap->MarkChunkDirty(a_ChunkX, a_ChunkZ, a_MarkRedstoneDirty);
}
@@ -2191,47 +2318,59 @@ void cWorld::MarkChunkSaved (int a_ChunkX, int a_ChunkZ)
-void cWorld::SetChunkData(
- int a_ChunkX, int a_ChunkZ,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap * a_BiomeMap,
- cEntityList & a_Entities,
- cBlockEntityList & a_BlockEntities,
- bool a_MarkDirty
-)
+void cWorld::QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData)
{
// Validate biomes, if needed:
- cChunkDef::BiomeMap BiomeMap;
- const cChunkDef::BiomeMap * Biomes = a_BiomeMap;
- if (a_BiomeMap == NULL)
+ if (!a_SetChunkData->AreBiomesValid())
{
// The biomes are not assigned, get them from the generator:
- Biomes = &BiomeMap;
- m_Generator.GenerateBiomes(a_ChunkX, a_ChunkZ, BiomeMap);
+ m_Generator.GenerateBiomes(a_SetChunkData->GetChunkX(), a_SetChunkData->GetChunkZ(), a_SetChunkData->GetBiomes());
+ a_SetChunkData->MarkBiomesValid();
}
- m_ChunkMap->SetChunkData(
- a_ChunkX, a_ChunkZ,
- a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight,
- a_HeightMap, *Biomes,
- a_BlockEntities,
- a_MarkDirty
- );
+ // Validate heightmap, if needed:
+ if (!a_SetChunkData->IsHeightMapValid())
+ {
+ a_SetChunkData->CalculateHeightMap();
+ }
+
+ // Store a copy of the data in the queue:
+ // TODO: If the queue is too large, wait for it to get processed. Not likely, though.
+ cCSLock Lock(m_CSSetChunkDataQueue);
+ m_SetChunkDataQueue.push_back(a_SetChunkData);
+}
+
+
+
+
+
+void cWorld::SetChunkData(cSetChunkData & a_SetChunkData)
+{
+ ASSERT(a_SetChunkData.AreBiomesValid());
+ ASSERT(a_SetChunkData.IsHeightMapValid());
+
+ m_ChunkMap->SetChunkData(a_SetChunkData);
// Initialize the entities (outside the m_ChunkMap's CS, to fix FS #347):
- for (cEntityList::iterator itr = a_Entities.begin(), end = a_Entities.end(); itr != end; ++itr)
+ cEntityList Entities;
+ std::swap(a_SetChunkData.GetEntities(), Entities);
+ for (cEntityList::iterator itr = Entities.begin(), end = Entities.end(); itr != end; ++itr)
{
- (*itr)->Initialize(this);
+ (*itr)->Initialize(*this);
}
// If a client is requesting this chunk, send it to them:
- if (m_ChunkMap->HasChunkAnyClients(a_ChunkX, a_ChunkZ))
+ int ChunkX = a_SetChunkData.GetChunkX();
+ int ChunkZ = a_SetChunkData.GetChunkZ();
+ if (m_ChunkMap->HasChunkAnyClients(ChunkX, ChunkZ))
{
- m_ChunkSender.ChunkReady(a_ChunkX, a_ChunkZ);
+ m_ChunkSender.ChunkReady(ChunkX, ChunkZ);
+ }
+
+ // Save the chunk right after generating, so that we don't have to generate it again on next run
+ if (a_SetChunkData.ShouldMarkDirty())
+ {
+ m_Storage.QueueSaveChunk(ChunkX, 0, ChunkZ);
}
}
@@ -2318,42 +2457,40 @@ void cWorld::CollectPickupsByPlayer(cPlayer * a_Player)
void cWorld::AddPlayer(cPlayer * a_Player)
{
- {
- cCSLock Lock(m_CSPlayers);
-
- ASSERT(std::find(m_Players.begin(), m_Players.end(), a_Player) == m_Players.end()); // Is it already in the list? HOW?
-
- m_Players.remove(a_Player); // Make sure the player is registered only once
- m_Players.push_back(a_Player);
- }
-
- // Add the player's client to the list of clients to be ticked:
- if (a_Player->GetClientHandle() != NULL)
- {
- cCSLock Lock(m_CSClients);
- m_ClientsToAdd.push_back(a_Player->GetClientHandle());
- }
-
- // The player has already been added to the chunkmap as the entity, do NOT add again!
+ cCSLock Lock(m_CSPlayersToAdd);
+ m_PlayersToAdd.push_back(a_Player);
}
-void cWorld::RemovePlayer(cPlayer * a_Player)
+void cWorld::RemovePlayer(cPlayer * a_Player, bool a_RemoveFromChunk)
{
- m_ChunkMap->RemoveEntity(a_Player);
+ if (a_RemoveFromChunk)
+ {
+ // To prevent iterator invalidations when an entity goes through a portal and calls this function whilst being ticked by cChunk
+ // we should not change cChunk's entity list if asked not to
+ m_ChunkMap->RemoveEntity(a_Player);
+ }
+ {
+ cCSLock Lock(m_CSPlayersToAdd);
+ m_PlayersToAdd.remove(a_Player);
+ }
{
cCSLock Lock(m_CSPlayers);
+ LOGD("Removing player %s from world \"%s\"", a_Player->GetName().c_str(), m_WorldName.c_str());
m_Players.remove(a_Player);
}
// Remove the player's client from the list of clients to be ticked:
- if (a_Player->GetClientHandle() != NULL)
+ cClientHandle * Client = a_Player->GetClientHandle();
+ if (Client != NULL)
{
+ Client->RemoveFromWorld();
+ m_ChunkMap->RemoveClientFromChunks(Client);
cCSLock Lock(m_CSClients);
- m_ClientsToRemove.push_back(a_Player->GetClientHandle());
+ m_ClientsToRemove.push_back(Client);
}
}
@@ -2402,13 +2539,13 @@ bool cWorld::DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_
bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback)
{
cPlayer * BestMatch = NULL;
- unsigned int BestRating = 0;
- unsigned int NameLength = a_PlayerNameHint.length();
+ size_t BestRating = 0;
+ size_t NameLength = a_PlayerNameHint.length();
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
- unsigned int Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName());
+ size_t Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName());
if (Rating >= BestRating)
{
BestMatch = *itr;
@@ -2422,7 +2559,6 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa
if (BestMatch != NULL)
{
- LOG("Compared %s and %s with rating %i", a_PlayerNameHint.c_str(), BestMatch->GetName().c_str(), BestRating);
return a_Callback.Item (BestMatch);
}
return false;
@@ -2448,10 +2584,13 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit,
if (Distance < ClosestDistance)
{
- if (a_CheckLineOfSight && !LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length()))
+ if (a_CheckLineOfSight)
{
- ClosestDistance = Distance;
- ClosestPlayer = *itr;
+ if (!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length()))
+ {
+ ClosestDistance = Distance;
+ ClosestPlayer = *itr;
+ }
}
else
{
@@ -2756,10 +2895,8 @@ bool cWorld::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunk
void cWorld::SaveAllChunks(void)
{
- LOGINFO("Saving all chunks...");
m_LastSave = m_WorldAge;
m_ChunkMap->SaveAllChunks();
- m_Storage.QueueSavedMessage();
}
@@ -2805,9 +2942,11 @@ void cWorld::ScheduleTask(int a_DelayTicks, cTask * a_Task)
+
void cWorld::AddEntity(cEntity * a_Entity)
{
- m_ChunkMap->AddEntity(a_Entity);
+ cCSLock Lock(m_CSEntitiesToAdd);
+ m_EntitiesToAdd.push_back(a_Entity);
}
@@ -2816,16 +2955,20 @@ void cWorld::AddEntity(cEntity * a_Entity)
bool cWorld::HasEntity(int a_UniqueID)
{
- return m_ChunkMap->HasEntity(a_UniqueID);
-}
-
-
-
-
+ // Check if the entity is in the queue to be added to the world:
+ {
+ cCSLock Lock(m_CSEntitiesToAdd);
+ for (cEntityList::const_iterator itr = m_EntitiesToAdd.begin(), end = m_EntitiesToAdd.end(); itr != end; ++itr)
+ {
+ if ((*itr)->GetUniqueID() == a_UniqueID)
+ {
+ return true;
+ }
+ } // for itr - m_EntitiesToAdd[]
+ }
-void cWorld::RemoveEntity(cEntity * a_Entity)
-{
- m_ChunkMap->RemoveEntity(a_Entity);
+ // Check if the entity is in the chunkmap:
+ return m_ChunkMap->HasEntity(a_UniqueID);
}
@@ -2836,7 +2979,7 @@ void cWorld::RemoveEntity(cEntity * a_Entity)
unsigned int cWorld::GetNumPlayers(void)
{
cCSLock Lock(m_CSPlayers);
- return m_Players.size();
+ return m_Players.size();
}
*/
@@ -2880,11 +3023,11 @@ void cWorld::TickQueuedBlocks(void)
{
// TODO: Handle the case when the chunk is already unloaded
m_ChunkMap->TickBlock(Block->X, Block->Y, Block->Z);
- delete Block; // We don't have to remove it from the vector, this will happen automatically on the next tick
+ delete Block; // We don't have to remove it from the vector, this will happen automatically on the next tick
}
else
{
- m_BlockTickQueue.push_back(Block); // Keep the block in the queue
+ m_BlockTickQueue.push_back(Block); // Keep the block in the queue
}
} // for itr - m_BlockTickQueueCopy[]
}
@@ -2940,19 +3083,31 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp
int cWorld::SpawnMobFinalize(cMonster * a_Monster)
{
+ // Invalid cMonster object. Bail out.
if (!a_Monster)
+ {
return -1;
+ }
+
+ // Give the mob full health.
a_Monster->SetHealth(a_Monster->GetMaxHealth());
+
+ // A plugin doesn't agree with the spawn. bail out.
if (cPluginManager::Get()->CallHookSpawningMonster(*this, *a_Monster))
{
delete a_Monster;
+ a_Monster = NULL;
return -1;
}
- if (!a_Monster->Initialize(this))
+
+ // Initialize the monster into the current world.
+ if (!a_Monster->Initialize(*this))
{
delete a_Monster;
+ a_Monster = NULL;
return -1;
}
+
BroadcastSpawnEntity(*a_Monster);
cPluginManager::Get()->CallHookSpawnedMonster(*this, *a_Monster);
@@ -2963,16 +3118,17 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster)
-int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem & a_Item, const Vector3d * a_Speed)
+int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed)
{
cProjectileEntity * Projectile = cProjectileEntity::Create(a_Kind, a_Creator, a_PosX, a_PosY, a_PosZ, a_Item, a_Speed);
if (Projectile == NULL)
{
return -1;
}
- if (!Projectile->Initialize(this))
+ if (!Projectile->Initialize(*this))
{
delete Projectile;
+ Projectile = NULL;
return -1;
}
return Projectile->GetUniqueID();
@@ -2987,18 +3143,18 @@ void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Resul
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(), end = m_Players.end(); itr != end; ++itr)
{
- size_t LastSpace = a_Text.find_last_of(" "); // Find the position of the last space
+ size_t LastSpace = a_Text.find_last_of(" "); // Find the position of the last space
- AString LastWord = a_Text.substr(LastSpace + 1, a_Text.length()); // Find the last word
+ AString LastWord = a_Text.substr(LastSpace + 1, a_Text.length()); // Find the last word
AString PlayerName ((*itr)->GetName());
- size_t Found = PlayerName.find(LastWord); // Try to find last word in playername
+ size_t Found = PlayerName.find(LastWord); // Try to find last word in playername
if (Found == AString::npos)
{
- continue; // No match
+ continue; // No match
}
- a_Results.push_back(PlayerName); // Match!
+ a_Results.push_back(PlayerName); // Match!
}
}
@@ -3006,6 +3162,15 @@ void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Resul
+void cWorld::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked)
+{
+ m_ChunkMap->SetChunkAlwaysTicked(a_ChunkX, a_ChunkZ, a_AlwaysTicked);
+}
+
+
+
+
+
cRedstoneSimulator * cWorld::InitializeRedstoneSimulator(cIniFile & a_IniFile)
{
AString SimulatorName = a_IniFile.GetValueSet("Physics", "RedstoneSimulator", "");
@@ -3100,7 +3265,65 @@ cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const c
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+void cWorld::AddQueuedPlayers(void)
+{
+ ASSERT(m_TickThread.IsCurrentThread());
+
+ // Grab the list of players to add, it has to be locked to access it:
+ cPlayerList PlayersToAdd;
+ {
+ cCSLock Lock(m_CSPlayersToAdd);
+ std::swap(PlayersToAdd, m_PlayersToAdd);
+ }
+
+ // Add all the players in the grabbed list:
+ {
+ cCSLock Lock(m_CSPlayers);
+ for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr)
+ {
+ ASSERT(std::find(m_Players.begin(), m_Players.end(), *itr) == m_Players.end()); // Is it already in the list? HOW?
+ LOGD("Adding player %s to world \"%s\".", (*itr)->GetName().c_str(), m_WorldName.c_str());
+
+ m_Players.push_back(*itr);
+ (*itr)->SetWorld(this);
+
+ // Add to chunkmap, if not already there (Spawn vs MoveToWorld):
+ m_ChunkMap->AddEntityIfNotPresent(*itr);
+ } // for itr - PlayersToAdd[]
+ } // Lock(m_CSPlayers)
+
+ // Add all the players' clienthandles:
+ {
+ cCSLock Lock(m_CSClients);
+ for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr)
+ {
+ cClientHandle * Client = (*itr)->GetClientHandle();
+ if (Client != NULL)
+ {
+ m_Clients.push_back(Client);
+ }
+ } // for itr - PlayersToAdd[]
+ } // Lock(m_CSClients)
+
+ // Stream chunks to all eligible clients:
+ for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr)
+ {
+ cClientHandle * Client = (*itr)->GetClientHandle();
+ if (Client != NULL)
+ {
+ Client->StreamChunks();
+ Client->SendPlayerMoveLook();
+ Client->SendHealth();
+ Client->SendWholeInventory(*(*itr)->GetWindow());
+ }
+ } // for itr - PlayersToAdd[]
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cWorld::cTaskSaveAllChunks:
void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World)
@@ -3112,7 +3335,7 @@ void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWorld::cTaskUnloadUnusedChunks
void cWorld::cTaskUnloadUnusedChunks::Run(cWorld & a_World)
@@ -3124,7 +3347,50 @@ void cWorld::cTaskUnloadUnusedChunks::Run(cWorld & a_World)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// cWorld::cTaskSendBlockTo
+
+cWorld::cTaskSendBlockToAllPlayers::cTaskSendBlockToAllPlayers(std::vector<Vector3i> & a_SendQueue) :
+ m_SendQueue(a_SendQueue)
+{
+}
+
+void cWorld::cTaskSendBlockToAllPlayers::Run(cWorld & a_World)
+{
+ class cPlayerCallback :
+ public cPlayerListCallback
+ {
+ public:
+ cPlayerCallback(std::vector<Vector3i> & a_SendQueue, cWorld & a_World) :
+ m_SendQueue(a_SendQueue),
+ m_World(a_World)
+ {
+ }
+
+ virtual bool Item(cPlayer * a_Player)
+ {
+ for (std::vector<Vector3i>::const_iterator itr = m_SendQueue.begin(); itr != m_SendQueue.end(); ++itr)
+ {
+ m_World.SendBlockTo(itr->x, itr->y, itr->z, a_Player);
+ }
+ return false;
+ }
+
+ private:
+
+ std::vector<Vector3i> m_SendQueue;
+ cWorld & m_World;
+
+ } PlayerCallback(m_SendQueue, a_World);
+
+ a_World.ForEachPlayer(PlayerCallback);
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cWorld::cChunkGeneratorCallbacks:
cWorld::cChunkGeneratorCallbacks::cChunkGeneratorCallbacks(cWorld & a_World) :
@@ -3141,17 +3407,14 @@ void cWorld::cChunkGeneratorCallbacks::OnChunkGenerated(cChunkDesc & a_ChunkDesc
cChunkDef::BlockNibbles BlockMetas;
a_ChunkDesc.CompressBlockMetas(BlockMetas);
- m_World->SetChunkData(
+ m_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData(
a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(),
a_ChunkDesc.GetBlockTypes(), BlockMetas,
NULL, NULL, // We don't have lighting, chunk will be lighted when needed
&a_ChunkDesc.GetHeightMap(), &a_ChunkDesc.GetBiomeMap(),
a_ChunkDesc.GetEntities(), a_ChunkDesc.GetBlockEntities(),
true
- );
-
- // Save the chunk right after generating, so that we don't have to generate it again on next run
- m_World->GetStorage().QueueSaveChunk(a_ChunkDesc.GetChunkX(), 0, a_ChunkDesc.GetChunkZ());
+ )));
}
@@ -3197,4 +3460,3 @@ void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerated (cChunkDesc & a_Ch
-
diff --git a/src/World.h b/src/World.h
index f789916df..6649c4163 100644
--- a/src/World.h
+++ b/src/World.h
@@ -47,12 +47,16 @@ class cFlowerPotEntity;
class cFurnaceEntity;
class cNoteEntity;
class cMobHeadEntity;
-class cMobCensus;
class cCompositeChat;
class cCuboid;
+class cSetChunkData;
+
typedef std::list< cPlayer * > cPlayerList;
+typedef SharedPtr<cSetChunkData> cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11
+typedef std::vector<cSetChunkDataPtr> cSetChunkDataPtrs;
+
typedef cItemCallback<cPlayer> cPlayerListCallback;
typedef cItemCallback<cEntity> cEntityCallback;
typedef cItemCallback<cChestEntity> cChestCallback;
@@ -92,7 +96,7 @@ public:
class cTask
{
public:
- virtual ~cTask(){};
+ virtual ~cTask() {}
virtual void Run(cWorld & a_World) = 0;
} ;
@@ -117,6 +121,20 @@ public:
};
+ class cTaskSendBlockToAllPlayers :
+ public cTask
+ {
+ public:
+ cTaskSendBlockToAllPlayers(std::vector<Vector3i> & a_SendQueue);
+
+ protected:
+ // cTask overrides:
+ virtual void Run(cWorld & a_World) override;
+
+ std::vector<Vector3i> m_SendQueue;
+ };
+
+
static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
{
return "cWorld";
@@ -127,7 +145,7 @@ public:
int GetTicksUntilWeatherChange(void) const { return m_WeatherInterval; }
virtual Int64 GetWorldAge (void) const override { return m_WorldAge; }
- virtual Int64 GetTimeOfDay(void) const override { return m_TimeOfDay; }
+ virtual Int64 GetTimeOfDay(void) const override { return m_TimeOfDay; }
void SetTicksUntilWeatherChange(int a_WeatherInterval)
{
@@ -167,7 +185,7 @@ public:
virtual eDimension GetDimension(void) const { return m_Dimension; }
/** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */
- int GetHeight(int a_BlockX, int a_BlockZ);
+ virtual int GetHeight(int a_BlockX, int a_BlockZ);
// tolua_end
@@ -193,7 +211,7 @@ public:
// tolua_end
void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
- void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
+ void BroadcastCollectEntity (const cEntity & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
@@ -204,15 +222,15 @@ public:
void BroadcastEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
- virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) override;
- void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); // tolua_export
+ virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) override; // tolua_export
+ void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); // tolua_export
void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL);
void BroadcastScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode);
void BroadcastScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode);
void BroadcastDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display);
- void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // tolua_export a_Src coords are Block * 8
- void BroadcastSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); // tolua_export
+ void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // tolua_export
+ void BroadcastSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); // tolua_export
void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
@@ -228,28 +246,14 @@ public:
/** If there is a block entity at the specified coords, sends it to the client specified */
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
- void MarkChunkDirty (int a_ChunkX, int a_ChunkZ);
+ void MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ);
+ void MarkChunkDirty (int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty = false);
void MarkChunkSaving(int a_ChunkX, int a_ChunkZ);
void MarkChunkSaved (int a_ChunkX, int a_ChunkZ);
- /** Sets the chunk data as either loaded from the storage or generated.
- a_BlockLight and a_BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
- a_BiomeMap is optional, if not present, biomes will be calculated by the generator
- a_HeightMap is optional, if not present, will be calculated.
- If a_MarkDirty is set, the chunk is set as dirty (used after generating)
- */
- void SetChunkData(
- int a_ChunkX, int a_ChunkZ,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const cChunkDef::HeightMap * a_HeightMap,
- const cChunkDef::BiomeMap * a_BiomeMap,
- cEntityList & a_Entities,
- cBlockEntityList & a_BlockEntities,
- bool a_MarkDirty
- );
+ /** Puts the chunk data into a queue to be set into the chunkmap in the tick thread.
+ If the chunk data doesn't contain valid biomes, the biomes are calculated before adding the data into the queue. */
+ void QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData);
void ChunkLighted(
int a_ChunkX, int a_ChunkZ,
@@ -270,8 +274,16 @@ public:
void CollectPickupsByPlayer(cPlayer * a_Player);
- void AddPlayer( cPlayer* a_Player );
- void RemovePlayer( cPlayer* a_Player );
+ /** Adds the player to the world.
+ Uses a queue to store the player object until the Tick thread processes the addition event.
+ Also adds the player as an entity in the chunkmap, and the player's ClientHandle, if any, for ticking. */
+ void AddPlayer(cPlayer * a_Player);
+
+ /** Removes the player from the world.
+ Removes the player from the addition queue, too, if appropriate.
+ If the player has a ClientHandle, the ClientHandle is removed from all chunks in the world and will not be ticked by this world anymore.
+ @param a_RemoveFromChunk determines if the entity should be removed from its chunk as well. Should be false when ticking from cChunk. */
+ void RemovePlayer(cPlayer * a_Player, bool a_RemoveFromChunk);
/** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */
virtual bool ForEachPlayer(cPlayerListCallback & a_Callback) override; // >> EXPORTED IN MANUALBINDINGS <<
@@ -280,21 +292,19 @@ public:
bool DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
/** Finds a player from a partial or complete player name and calls the callback - case-insensitive */
- bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
+ bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
- cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
+ cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player
- /** Adds the entity into its appropriate chunk; takes ownership of the entity ptr */
+ /** Adds the entity into its appropriate chunk; takes ownership of the entity ptr.
+ The entity is added lazily - this function only puts it in a queue that is then processed by the Tick thread. */
void AddEntity(cEntity * a_Entity);
bool HasEntity(int a_UniqueID);
- /** Removes the entity, the entity ptr ownership is assumed taken by the caller */
- void 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
@@ -343,22 +353,22 @@ public:
bool SetSignLines(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, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
/** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as SetSignLines() */
- bool UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
+ bool UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
/** Sets the command block command. Returns true if command changed. */
- bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command); // tolua_export
+ bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command); // tolua_export
/** Is the trapdoor open? Returns false if there is no trapdoor at the specified coords. */
bool IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
- /** Set the state of a trapdoor. Returns true if the trapdoor was update, false if there was no trapdoor at those coords. */
+ /** Set the state of a trapdoor. Returns true if the trapdoor was updated, false if there was no trapdoor at those coords. */
bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open); // tolua_export
/** Regenerate the given chunk: */
- void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
+ void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
/** Generates the given chunk, if not already generated */
- void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
+ void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
/** Queues a chunk for lighting; a_Callback is called after the chunk is lighted */
void QueueLightChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = NULL);
@@ -373,7 +383,7 @@ public:
/** Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed.
*/
- void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true);
/** Sets the block at the specified coords to the specified value.
The replacement doesn't trigger block updates.
@@ -414,10 +424,10 @@ public:
// tolua_begin
// Vector3i variants:
- void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta ); }
- BLOCKTYPE GetBlock (const Vector3i & a_Pos ) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z ); }
- NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos ) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z ); }
- void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData ) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData ); }
+ void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); }
+ BLOCKTYPE GetBlock (const Vector3i & a_Pos) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z); }
+ NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z); }
+ void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData); }
// tolua_end
/** Writes the block area into the specified coords.
@@ -464,7 +474,7 @@ public:
double GetSpawnZ(void) const { return m_SpawnZ; }
/** Wakes up the simulators for the specified block */
- void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ);
+ virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) override;
/** Wakes up the simulators for the specified area of blocks */
void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ);
@@ -511,7 +521,7 @@ public:
virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) override; // tolua_export
/** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */
- bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback); // Exported in ManualBindings.cpp
+ virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) override; // Exported in ManualBindings.cpp
/** Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found */
bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback); // Exported in ManualBindings.cpp
@@ -610,21 +620,18 @@ public:
bool ShouldUseChatPrefixes(void) const { return m_bUseChatPrefixes; }
void SetShouldUseChatPrefixes(bool a_Flag) { m_bUseChatPrefixes = a_Flag; }
+
+ AString GetNetherWorldName(void) const { return m_NetherWorldName; }
+ void SetNetherWorldName(const AString & a_Name) { m_NetherWorldName = a_Name; }
+
+ AString GetEndWorldName(void) const { return m_EndWorldName; }
+ void SetEndWorldName(const AString & a_Name) { m_EndWorldName = a_Name; }
+
+ AString GetLinkedOverworldName(void) const { return m_OverworldName; }
+ void SetLinkedOverworldName(const AString & a_Name) { m_OverworldName = a_Name; }
// tolua_end
- inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
- {
- // TODO: Use floor() instead of weird if statements
- // Also fix Y
- (void)a_Y; // not unused anymore
- a_ChunkX = a_X/cChunkDef::Width;
- if(a_X < 0 && a_X % cChunkDef::Width != 0) a_ChunkX--;
- a_ChunkY = 0;
- a_ChunkZ = a_Z/cChunkDef::Width;
- if(a_Z < 0 && a_Z % cChunkDef::Width != 0) a_ChunkZ--;
- }
-
/** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */
void SaveAllChunks(void);
@@ -645,7 +652,7 @@ public:
void GetChunkStats(int & a_NumValid, int & a_NumDirty, int & a_NumInLightingQueue);
// Various queues length queries (cannot be const, they lock their CS):
- inline int GetGeneratorQueueLength (void) { return m_Generator.GetQueueLength(); } // tolua_export
+ inline int GetGeneratorQueueLength (void) { return m_Generator.GetQueueLength(); } // tolua_export
inline size_t GetLightingQueueLength (void) { return m_Lighting.GetQueueLength(); } // tolua_export
inline size_t GetStorageLoadQueueLength(void) { return m_Storage.GetLoadQueueLength(); } // tolua_export
inline size_t GetStorageSaveQueueLength(void) { return m_Storage.GetSaveQueueLength(); } // tolua_export
@@ -677,21 +684,50 @@ public:
void CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ);
/** Sets the specified weather; resets weather interval; asks and notifies plugins of the change */
- void SetWeather (eWeather a_NewWeather);
+ void SetWeather(eWeather a_NewWeather);
/** Forces a weather change in the next game tick */
- void ChangeWeather (void);
+ void ChangeWeather(void);
/** Returns the current weather. Instead of comparing values directly to the weather constants, use IsWeatherXXX() functions, if possible */
- eWeather GetWeather (void) const { return m_Weather; };
+ eWeather GetWeather(void) const { return m_Weather; }
+ /** Returns true if the current weather is sun */
bool IsWeatherSunny(void) const { return (m_Weather == wSunny); }
- bool IsWeatherRain (void) const { return (m_Weather == wRain); }
+
+ /** Returns true if it is sunny at the specified location. This takes into account biomes. */
+ bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ)
+ {
+ return (IsWeatherSunny() || IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
+ }
+
+ /** Returns true if the current weather is rain */
+ bool IsWeatherRain(void) const { return (m_Weather == wRain); }
+
+ /** Returns true if it is raining at the specified location. This takes into account biomes. */
+ bool IsWeatherRainAt(int a_BlockX, int a_BlockZ)
+ {
+ return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
+ }
+
+ /** Returns true if the current weather is stormy */
bool IsWeatherStorm(void) const { return (m_Weather == wStorm); }
+
+ /** Returns true if the weather is stormy at the specified location. This takes into account biomes. */
+ bool IsWeatherStormAt(int a_BlockX, int a_BlockZ)
+ {
+ return (IsWeatherStorm() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
+ }
- /** Returns true if the current weather has any precipitation - rain or storm */
- bool IsWeatherWet (void) const { return (m_Weather != wSunny); }
+ /** Returns true if the current weather has any precipitation - rain, storm or snow */
+ bool IsWeatherWet(void) const { return !IsWeatherSunny(); }
+ /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */
+ virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ)
+ {
+ return (IsWeatherWet() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
+ }
+
// tolua_end
cChunkGenerator & GetGenerator(void) { return m_Generator; }
@@ -710,8 +746,10 @@ public:
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) override; // tolua_export
int SpawnMobFinalize(cMonster* a_Monster);
- /** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise */
- int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem & a_Item, const Vector3d * a_Speed = NULL); // tolua_export
+ /** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise
+ Item parameter used currently for Fireworks to correctly set entity metadata based on item metadata
+ */
+ int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = NULL); // tolua_export
/** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */
int GetTickRandomNumber(unsigned a_Range) { return (int)(m_TickRand.randInt(a_Range)); }
@@ -721,6 +759,13 @@ public:
/** Get the current darkness level based on the time */
NIBBLETYPE GetSkyDarkness() { return m_SkyDarkness; }
+
+ /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk.
+ If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of
+ whether it has any clients or not.
+ This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long
+ as at least one requests is active the chunk will be ticked). */
+ void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export
private:
@@ -779,6 +824,7 @@ private:
virtual ~cScheduledTask()
{
delete m_Task;
+ m_Task = NULL;
}
};
@@ -786,6 +832,12 @@ private:
AString m_WorldName;
+
+ /** The name of the world that a portal in this world should link to
+ Only has effect if this world is a nether or end world, as it is used by entities to see which world to teleport to when in a portal
+ */
+ AString m_OverworldName;
+
AString m_IniFileName;
/** Name of the storage schema used to load and save chunks */
@@ -811,7 +863,7 @@ private:
Int64 m_LastTimeUpdate; // The tick in which the last time update has been sent.
Int64 m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred
Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred
- std::map<cMonster::eFamily,Int64> m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
+ std::map<cMonster::eFamily, Int64> m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
NIBBLETYPE m_SkyDarkness;
@@ -822,7 +874,7 @@ private:
bool m_VillagersShouldHarvestCrops;
std::vector<BlockTickQueueItem *> m_BlockTickQueue;
- std::vector<BlockTickQueueItem *> m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue
+ std::vector<BlockTickQueueItem *> m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue
cSimulatorManager * m_SimulatorManager;
cSandSimulator * m_SandSimulator;
@@ -870,6 +922,12 @@ private:
See the eShrapnelLevel enumeration for details
*/
eShrapnelLevel m_TNTShrapnelLevel;
+
+ /** Name of the nether world */
+ AString m_NetherWorldName;
+
+ /** Name of the end world */
+ AString m_EndWorldName;
cChunkGenerator m_Generator;
@@ -910,8 +968,26 @@ private:
/** Clients that are scheduled for adding, waiting for TickClients to add them */
cClientHandleList m_ClientsToAdd;
+ /** Guards m_EntitiesToAdd */
+ cCriticalSection m_CSEntitiesToAdd;
+
+ /** List of entities that are scheduled for adding, waiting for the Tick thread to add them. */
+ cEntityList m_EntitiesToAdd;
+
+ /** Guards m_PlayersToAdd */
+ cCriticalSection m_CSPlayersToAdd;
+
+ /** List of players that are scheduled for adding, waiting for the Tick thread to add them. */
+ cPlayerList m_PlayersToAdd;
+
+ /** CS protecting m_SetChunkDataQueue. */
+ cCriticalSection m_CSSetChunkDataQueue;
+
+ /** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */
+ cSetChunkDataPtrs m_SetChunkDataQueue;
+
- cWorld(const AString & a_WorldName);
+ cWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = "");
virtual ~cWorld();
void Tick(float a_Dt, int a_LastTickDurationMSec);
@@ -947,7 +1023,22 @@ private:
/** Creates a new redstone simulator.*/
cRedstoneSimulator * InitializeRedstoneSimulator(cIniFile & a_IniFile);
-}; // tolua_export
+
+ /** Adds the players queued in the m_PlayersToAdd queue into the m_Players list.
+ Assumes it is called from the Tick thread. */
+ void AddQueuedPlayers(void);
+
+ /** Sets generator values to dimension specific defaults, if those values do not exist */
+ void InitialiseGeneratorDefaults(cIniFile & a_IniFile);
+
+ /** Sets mob spawning values if nonexistant to their dimension specific defaults */
+ void InitialiseAndLoadMobSpawningValues(cIniFile & a_IniFile);
+
+ /** Sets the specified chunk data into the chunkmap. Called in the tick thread.
+ Modifies the a_SetChunkData - moves the entities contained in it into the chunk. */
+ void SetChunkData(cSetChunkData & a_SetChunkData);
+
+}; // tolua_export
diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt
index 2844f7fe5..a00ff3b2f 100644
--- a/src/WorldStorage/CMakeLists.txt
+++ b/src/WorldStorage/CMakeLists.txt
@@ -4,11 +4,34 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ EnchantmentSerializer.cpp
+ FastNBT.cpp
+ FireworksSerializer.cpp
+ MapSerializer.cpp
+ NBTChunkSerializer.cpp
+ SchematicFileSerializer.cpp
+ ScoreboardSerializer.cpp
+ StatSerializer.cpp
+ WSSAnvil.cpp
+ WSSCompact.cpp
+ WorldStorage.cpp)
-add_library(WorldStorage ${SOURCE})
+SET (HDRS
+ EnchantmentSerializer.h
+ FastNBT.h
+ FireworksSerializer.h
+ MapSerializer.h
+ NBTChunkSerializer.h
+ SchematicFileSerializer.h
+ ScoreboardSerializer.h
+ StatSerializer.h
+ WSSAnvil.h
+ WSSCompact.h
+ WorldStorage.h)
-target_link_libraries(WorldStorage OSSupport)
+if(NOT MSVC)
+ add_library(WorldStorage ${SRCS} ${HDRS})
+
+ target_link_libraries(WorldStorage OSSupport)
+endif()
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp
index ac9a21205..c6294b99c 100644
--- a/src/WorldStorage/FastNBT.cpp
+++ b/src/WorldStorage/FastNBT.cpp
@@ -10,7 +10,7 @@
-// The number of NBT tags that are reserved when an NBT parsing is started.
+// The number of NBT tags that are reserved when an NBT parsing is started.
// You can override this by using a cmdline define
#ifndef NBT_RESERVE_SIZE
#define NBT_RESERVE_SIZE 200
@@ -25,11 +25,11 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cParsedNBT:
#define NEEDBYTES(N) \
- if (m_Length - m_Pos < N) \
+ if (m_Length - m_Pos < (size_t)N) \
{ \
return false; \
}
@@ -38,7 +38,7 @@
-cParsedNBT::cParsedNBT(const char * a_Data, int a_Length) :
+cParsedNBT::cParsedNBT(const char * a_Data, size_t a_Length) :
m_Data(a_Data),
m_Length(a_Length),
m_Pos(0)
@@ -69,7 +69,7 @@ bool cParsedNBT::Parse(void)
m_Pos = 1;
- RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength));
+ RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength));
RETURN_FALSE_IF_FALSE(ReadCompound());
return true;
@@ -79,14 +79,14 @@ bool cParsedNBT::Parse(void)
-bool cParsedNBT::ReadString(int & a_StringStart, int & a_StringLen)
+bool cParsedNBT::ReadString(size_t & a_StringStart, size_t & a_StringLen)
{
NEEDBYTES(2);
a_StringStart = m_Pos + 2;
- a_StringLen = GetBEShort(m_Data + m_Pos);
- if (a_StringLen < 0)
+ a_StringLen = (size_t)GetBEShort(m_Data + m_Pos);
+ if (a_StringLen > 0xffff)
{
- // Invalid string length
+ // Suspicious string length
return false;
}
m_Pos += 2 + a_StringLen;
@@ -99,8 +99,10 @@ bool cParsedNBT::ReadString(int & a_StringStart, int & a_StringLen)
bool cParsedNBT::ReadCompound(void)
{
+ ASSERT(m_Tags.size() > 0);
+
// Reads the latest tag as a compound
- int ParentIdx = m_Tags.size() - 1;
+ int ParentIdx = (int)m_Tags.size() - 1;
int PrevSibling = -1;
for (;;)
{
@@ -114,13 +116,13 @@ bool cParsedNBT::ReadCompound(void)
m_Tags.push_back(cFastNBTTag(TagType, ParentIdx, PrevSibling));
if (PrevSibling >= 0)
{
- m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1;
+ m_Tags[PrevSibling].m_NextSibling = (int)m_Tags.size() - 1;
}
else
{
- m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1;
+ m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1;
}
- PrevSibling = m_Tags.size() - 1;
+ PrevSibling = (int)m_Tags.size() - 1;
RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength));
RETURN_FALSE_IF_FALSE(ReadTag());
} // while (true)
@@ -146,20 +148,20 @@ bool cParsedNBT::ReadList(eTagType a_ChildrenType)
}
// Read items:
- int ParentIdx = m_Tags.size() - 1;
+ int ParentIdx = (int)m_Tags.size() - 1;
int PrevSibling = -1;
for (int i = 0; i < Count; i++)
{
m_Tags.push_back(cFastNBTTag(a_ChildrenType, ParentIdx, PrevSibling));
if (PrevSibling >= 0)
{
- m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1;
+ m_Tags[PrevSibling].m_NextSibling = (int)m_Tags.size() - 1;
}
else
{
- m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1;
+ m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1;
}
- PrevSibling = m_Tags.size() - 1;
+ PrevSibling = (int)m_Tags.size() - 1;
RETURN_FALSE_IF_FALSE(ReadTag());
} // for (i)
m_Tags[ParentIdx].m_LastChild = PrevSibling;
@@ -279,7 +281,7 @@ int cParsedNBT::FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLen
for (int Child = m_Tags[a_Tag].m_FirstChild; Child != -1; Child = m_Tags[Child].m_NextSibling)
{
if (
- (m_Tags[Child].m_NameLength == (int)a_NameLength) &&
+ (m_Tags[Child].m_NameLength == a_NameLength) &&
(memcmp(m_Data + m_Tags[Child].m_NameStart, a_Name, a_NameLength) == 0)
)
{
@@ -327,7 +329,7 @@ int cParsedNBT::FindTagByPath(int a_Tag, const AString & a_Path) const
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cFastNBTWriter:
cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) :
@@ -336,7 +338,7 @@ cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) :
m_Stack[0].m_Type = TAG_Compound;
m_Result.reserve(100 * 1024);
m_Result.push_back(TAG_Compound);
- WriteString(a_RootTagName.data(), a_RootTagName.size());
+ WriteString(a_RootTagName.data(), (UInt16)a_RootTagName.size());
}
@@ -389,7 +391,7 @@ void cFastNBTWriter::BeginList(const AString & a_Name, eTagType a_ChildrenType)
++m_CurrentStack;
m_Stack[m_CurrentStack].m_Type = TAG_List;
- m_Stack[m_CurrentStack].m_Pos = m_Result.size() - 4;
+ m_Stack[m_CurrentStack].m_Pos = (int)m_Result.size() - 4;
m_Stack[m_CurrentStack].m_Count = 0;
m_Stack[m_CurrentStack].m_ItemType = a_ChildrenType;
}
@@ -493,7 +495,7 @@ void cFastNBTWriter::AddString(const AString & a_Name, const AString & a_Value)
void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value, size_t a_NumElements)
{
TagCommon(a_Name, TAG_ByteArray);
- Int32 len = htonl(a_NumElements);
+ u_long len = htonl((u_long)a_NumElements);
m_Result.append((const char *)&len, 4);
m_Result.append(a_Value, a_NumElements);
}
@@ -505,7 +507,7 @@ void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value,
void cFastNBTWriter::AddIntArray(const AString & a_Name, const int * a_Value, size_t a_NumElements)
{
TagCommon(a_Name, TAG_IntArray);
- Int32 len = htonl(a_NumElements);
+ u_long len = htonl((u_long)a_NumElements);
size_t cap = m_Result.capacity();
size_t size = m_Result.length();
if ((cap - size) < (4 + a_NumElements * 4))
@@ -534,7 +536,7 @@ void cFastNBTWriter::Finish(void)
-void cFastNBTWriter::WriteString(const char * a_Data, short a_Length)
+void cFastNBTWriter::WriteString(const char * a_Data, UInt16 a_Length)
{
Int16 Len = htons(a_Length);
m_Result.append((const char *)&Len, 2);
diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h
index 5e5af3ca3..4ef72e379 100644
--- a/src/WorldStorage/FastNBT.h
+++ b/src/WorldStorage/FastNBT.h
@@ -5,11 +5,11 @@
/*
The fast parser parses the data into a vector of cFastNBTTag structures. These structures describe the NBT tree,
-but themselves are allocated in a vector, thus minimizing reallocation.
+but themselves are allocated in a vector, thus minimizing reallocation.
The structures have a minimal constructor, setting all member "pointers" to "invalid".
The fast writer doesn't need a NBT tree structure built beforehand, it is commanded to open, append and close tags
-(just like XML); it keeps the internal tag stack and reports errors in usage.
+(just like XML); it keeps the internal tag stack and reports errors in usage.
It directly outputs a string containing the serialized NBT data.
*/
@@ -61,10 +61,10 @@ public:
// The following members are indices into the data stream. m_DataLength == 0 if no data available
// They must not be pointers, because the datastream may be copied into another AString object in the meantime.
- int m_NameStart;
- int m_NameLength;
- int m_DataStart;
- int m_DataLength;
+ size_t m_NameStart;
+ size_t m_NameLength;
+ size_t m_DataStart;
+ size_t m_DataLength;
// The following members are indices into the array returned; -1 if not valid
// They must not be pointers, because pointers would not survive std::vector reallocation
@@ -114,7 +114,7 @@ Each primitive tag also stores the length of the contained data, in bytes.
class cParsedNBT
{
public:
- cParsedNBT(const char * a_Data, int a_Length);
+ cParsedNBT(const char * a_Data, size_t a_Length);
bool IsValid(void) const {return m_IsValid; }
@@ -135,7 +135,7 @@ public:
/** Returns the length of the tag's data, in bytes.
Not valid for Compound or List tags! */
- int GetDataLength (int a_Tag) const
+ size_t GetDataLength (int a_Tag) const
{
ASSERT(m_Tags[(size_t)a_Tag].m_Type != TAG_List);
ASSERT(m_Tags[(size_t)a_Tag].m_Type != TAG_Compound);
@@ -160,7 +160,7 @@ public:
/** Returns the direct child tag of the specified name, or -1 if no such tag. */
int FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLength = 0) const;
- /** Returns the child tag of the specified path (Name1\Name2\Name3...), or -1 if no such tag. */
+ /** Returns the child tag of the specified path (Name1/Name2/Name3...), or -1 if no such tag. */
int FindTagByPath(int a_Tag, const AString & a_Path) const;
eTagType GetType(int a_Tag) const { return m_Tags[(size_t)a_Tag].m_Type; }
@@ -173,7 +173,7 @@ public:
}
/** Returns the value stored in a Byte tag. Not valid for any other tag type. */
- inline unsigned char GetByte(int a_Tag) const
+ inline unsigned char GetByte(int a_Tag) const
{
ASSERT(m_Tags[(size_t)a_Tag].m_Type == TAG_Byte);
return (unsigned char)(m_Data[(size_t)m_Tags[(size_t)a_Tag].m_DataStart]);
@@ -237,7 +237,7 @@ public:
{
ASSERT(m_Tags[(size_t)a_Tag].m_Type == TAG_String);
AString res;
- res.assign(m_Data + m_Tags[(size_t)a_Tag].m_DataStart, m_Tags[(size_t)a_Tag].m_DataLength);
+ res.assign(m_Data + m_Tags[(size_t)a_Tag].m_DataStart, (size_t)m_Tags[(size_t)a_Tag].m_DataLength);
return res;
}
@@ -245,21 +245,21 @@ public:
inline AString GetName(int a_Tag) const
{
AString res;
- res.assign(m_Data + m_Tags[(size_t)a_Tag].m_NameStart, m_Tags[(size_t)a_Tag].m_NameLength);
+ res.assign(m_Data + m_Tags[(size_t)a_Tag].m_NameStart, (size_t)m_Tags[(size_t)a_Tag].m_NameLength);
return res;
}
protected:
const char * m_Data;
- int m_Length;
+ size_t m_Length;
std::vector<cFastNBTTag> m_Tags;
bool m_IsValid; // True if parsing succeeded
// Used while parsing:
- int m_Pos;
+ size_t m_Pos;
bool Parse(void);
- bool ReadString(int & a_StringStart, int & a_StringLen); // Reads a simple string (2 bytes length + data), sets the string descriptors
+ bool ReadString(size_t & a_StringStart, size_t & a_StringLen); // Reads a simple string (2 bytes length + data), sets the string descriptors
bool ReadCompound(void); // Reads the latest tag as a compound
bool ReadList(eTagType a_ChildrenType); // Reads the latest tag as a list of items of type a_ChildrenType
bool ReadTag(void); // Reads the latest tag, depending on its m_Type setting
@@ -319,7 +319,7 @@ protected:
bool IsStackTopCompound(void) const { return (m_Stack[m_CurrentStack].m_Type == TAG_Compound); }
- void WriteString(const char * a_Data, short a_Length);
+ void WriteString(const char * a_Data, UInt16 a_Length);
inline void TagCommon(const AString & a_Name, eTagType a_Type)
{
@@ -330,7 +330,7 @@ protected:
{
// Compound: add the type and name:
m_Result.push_back((char)a_Type);
- WriteString(a_Name.c_str(), (short)a_Name.length());
+ WriteString(a_Name.c_str(), (UInt16)a_Name.length());
}
else
{
diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp
index e0cd69634..ecb600483 100644
--- a/src/WorldStorage/FireworksSerializer.cpp
+++ b/src/WorldStorage/FireworksSerializer.cpp
@@ -72,7 +72,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
for (int explosiontag = a_NBT.GetFirstChild(a_TagIdx); explosiontag >= 0; explosiontag = a_NBT.GetNextSibling(explosiontag))
{
eTagType TagType = a_NBT.GetType(explosiontag);
- if (TagType == TAG_Byte) // Custon name tag
+ if (TagType == TAG_Byte) // Custon name tag
{
AString ExplosionName = a_NBT.GetName(explosiontag);
@@ -96,32 +96,32 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
if (ExplosionName == "Colors")
{
// Divide by four as data length returned in bytes
- int DataLength = a_NBT.GetDataLength(explosiontag);
+ size_t DataLength = a_NBT.GetDataLength(explosiontag);
// round to the next highest multiple of four
- DataLength -= DataLength % 4;
+ DataLength -= DataLength % 4;
if (DataLength == 0)
{
continue;
}
const char * ColourData = (a_NBT.GetData(explosiontag));
- for (int i = 0; i < DataLength; i += 4 /* Size of network int*/)
+ for (size_t i = 0; i < DataLength; i += 4)
{
a_FireworkItem.m_Colours.push_back(GetBEInt(ColourData + i));
}
}
else if (ExplosionName == "FadeColors")
{
- int DataLength = a_NBT.GetDataLength(explosiontag) / 4;
+ size_t DataLength = a_NBT.GetDataLength(explosiontag) / 4;
// round to the next highest multiple of four
- DataLength -= DataLength % 4;
+ DataLength -= DataLength % 4;
if (DataLength == 0)
{
continue;
}
const char * FadeColourData = (a_NBT.GetData(explosiontag));
- for (int i = 0; i < DataLength; i += 4 /* Size of network int*/)
+ for (size_t i = 0; i < DataLength; i += 4)
{
a_FireworkItem.m_FadeColours.push_back(GetBEInt(FadeColourData + i));
}
@@ -135,7 +135,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
for (int fireworkstag = a_NBT.GetFirstChild(a_TagIdx); fireworkstag >= 0; fireworkstag = a_NBT.GetNextSibling(fireworkstag))
{
eTagType TagType = a_NBT.GetType(fireworkstag);
- if (TagType == TAG_Byte) // Custon name tag
+ if (TagType == TAG_Byte) // Custon name tag
{
if (a_NBT.GetName(fireworkstag) == "Flight")
{
diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp
index df72d1cc9..012fc52f3 100644
--- a/src/WorldStorage/MapSerializer.cpp
+++ b/src/WorldStorage/MapSerializer.cpp
@@ -152,6 +152,10 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
if (CurrLine >= 0)
{
unsigned int Width = a_NBT.GetShort(CurrLine);
+ if (Width != 128)
+ {
+ return false;
+ }
m_Map->m_Width = Width;
}
@@ -159,6 +163,10 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
if (CurrLine >= 0)
{
unsigned int Height = a_NBT.GetShort(CurrLine);
+ if (Height >= 256)
+ {
+ return false;
+ }
m_Map->m_Height = Height;
}
diff --git a/src/WorldStorage/MapSerializer.h b/src/WorldStorage/MapSerializer.h
index eb7678a08..4fa40f6f9 100644
--- a/src/WorldStorage/MapSerializer.h
+++ b/src/WorldStorage/MapSerializer.h
@@ -52,10 +52,9 @@ private:
/** Utility class used to serialize item ID counts.
- *
- * In order to perform bounds checking (while loading),
- * the last registered ID of each item is serialized to an NBT file.
- */
+In order to perform bounds checking (while loading),
+the last registered ID of each item is serialized to an NBT file.
+*/
class cIDCountSerializer
{
public:
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 41e0d89fd..4857da1b6 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -29,6 +29,7 @@
#include "../Entities/Minecart.h"
#include "../Entities/Pickup.h"
#include "../Entities/ArrowEntity.h"
+#include "../Entities/SplashPotionEntity.h"
#include "../Entities/TNTEntity.h"
#include "../Entities/ExpOrb.h"
#include "../Entities/HangingEntity.h"
@@ -88,23 +89,48 @@ void cNBTChunkSerializer::Finish(void)
void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AString & a_CompoundName)
{
m_Writer.BeginCompound(a_CompoundName);
- m_Writer.AddShort("id", (short)(a_Item.m_ItemType));
- m_Writer.AddShort("Damage", a_Item.m_ItemDamage);
- m_Writer.AddByte ("Count", a_Item.m_ItemCount);
+ m_Writer.AddShort("id", (short)(a_Item.m_ItemType));
+ m_Writer.AddShort("Damage", a_Item.m_ItemDamage);
+ m_Writer.AddByte ("Count", a_Item.m_ItemCount);
if (a_Slot >= 0)
{
m_Writer.AddByte ("Slot", (unsigned char)a_Slot);
}
- // Write the enchantments:
- if (!a_Item.m_Enchantments.IsEmpty() || ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR)))
+ // Write the tag compound (for enchantment, firework, custom name and repair cost):
+ if (
+ (!a_Item.m_Enchantments.IsEmpty()) ||
+ ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR)) ||
+ (a_Item.m_RepairCost > 0) ||
+ (a_Item.m_CustomName != "") ||
+ (a_Item.m_Lore != "")
+ )
{
m_Writer.BeginCompound("tag");
+ if (a_Item.m_RepairCost > 0)
+ {
+ m_Writer.AddInt("RepairCost", a_Item.m_RepairCost);
+ }
+
+ if ((a_Item.m_CustomName != "") || (a_Item.m_Lore != ""))
+ {
+ m_Writer.BeginCompound("display");
+ if (a_Item.m_CustomName != "")
+ {
+ m_Writer.AddString("Name", a_Item.m_CustomName);
+ }
+ if (a_Item.m_Lore != "")
+ {
+ m_Writer.AddString("Lore", a_Item.m_Lore);
+ }
+ m_Writer.EndCompound();
+ }
+
if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR))
{
cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, m_Writer, (ENUM_ITEM_ID)a_Item.m_ItemType);
}
-
+
if (!a_Item.m_Enchantments.IsEmpty())
{
const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
@@ -150,10 +176,10 @@ void cNBTChunkSerializer::AddBasicTileEntity(cBlockEntity * a_Entity, const char
-void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity)
+void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity, BLOCKTYPE a_ChestType)
{
m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Chest");
+ AddBasicTileEntity(a_Entity, (a_ChestType == E_BLOCK_CHEST) ? "Chest" : "TrappedChest");
m_Writer.BeginList("Items", TAG_Compound);
AddItemGrid(a_Entity->GetContents());
m_Writer.EndList();
@@ -253,7 +279,7 @@ void cNBTChunkSerializer::AddCommandBlockEntity(cCommandBlockEntity * a_CmdBlock
m_Writer.AddString("Command", a_CmdBlock->GetCommand());
m_Writer.AddInt ("SuccessCount", a_CmdBlock->GetResult());
m_Writer.AddString("LastOutput", a_CmdBlock->GetLastOutput());
- m_Writer.AddByte ("TrackOutput", 1); // TODO 2014-01-18 xdot: Figure out what TrackOutput is and save it.
+ m_Writer.AddByte ("TrackOutput", 1); // TODO 2014-01-18 xdot: Figure out what TrackOutput is and save it.
m_Writer.EndCompound();
}
@@ -320,6 +346,7 @@ void cNBTChunkSerializer::AddBasicEntity(cEntity * a_Entity, const AString & a_C
m_Writer.AddDouble("", a_Entity->GetYaw());
m_Writer.AddDouble("", a_Entity->GetPitch());
m_Writer.EndList();
+ m_Writer.AddShort("Health", a_Entity->GetHealth());
}
@@ -366,38 +393,41 @@ void cNBTChunkSerializer::AddFallingBlockEntity(cFallingBlock * a_FallingBlock)
void cNBTChunkSerializer::AddMinecartEntity(cMinecart * a_Minecart)
{
- const char * EntityClass = NULL;
- switch (a_Minecart->GetPayload())
- {
- case cMinecart::mpNone: EntityClass = "MinecartRideable"; break;
- case cMinecart::mpChest: EntityClass = "MinecartChest"; break;
- case cMinecart::mpFurnace: EntityClass = "MinecartFurnace"; break;
- case cMinecart::mpTNT: EntityClass = "MinecartTNT"; break;
- case cMinecart::mpHopper: EntityClass = "MinecartHopper"; break;
- default:
- {
- ASSERT(!"Unhandled minecart payload type");
- return;
- }
- } // switch (payload)
-
m_Writer.BeginCompound("");
- AddBasicEntity(a_Minecart, EntityClass);
+
switch (a_Minecart->GetPayload())
{
case cMinecart::mpChest:
{
+ AddBasicEntity(a_Minecart, "MinecartChest");
// Add chest contents into the Items tag:
AddMinecartChestContents((cMinecartWithChest *)a_Minecart);
break;
}
-
case cMinecart::mpFurnace:
{
+ AddBasicEntity(a_Minecart, "MinecartFurnace");
// TODO: Add "Push" and "Fuel" tags
break;
}
+ case cMinecart::mpHopper:
+ {
+ AddBasicEntity(a_Minecart, "MinecartHopper");
+ // TODO: Add hopper contents?
+ break;
+ }
+ case cMinecart::mpTNT:
+ {
+ AddBasicEntity(a_Minecart, "MinecartTNT");
+ break;
+ }
+ case cMinecart::mpNone:
+ {
+ AddBasicEntity(a_Minecart, "MinecartRideable");
+ break;
+ }
} // switch (Payload)
+
m_Writer.EndCompound();
}
@@ -490,7 +520,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
}
case cMonster::mtMagmaCube:
{
- m_Writer.AddByte("Size", ((const cMagmaCube *)a_Monster)->GetSize());
+ m_Writer.AddInt("Size", ((const cMagmaCube *)a_Monster)->GetSize());
break;
}
case cMonster::mtSheep:
@@ -516,7 +546,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
}
case cMonster::mtWither:
{
- m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetNumInvulnerableTicks());
+ m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetWitherInvulnerableTicks());
break;
}
case cMonster::mtWolf:
@@ -547,7 +577,6 @@ void cNBTChunkSerializer::AddPickupEntity(cPickup * a_Pickup)
m_Writer.BeginCompound("");
AddBasicEntity(a_Pickup, "Item");
AddItem(a_Pickup->GetItem(), -1, "Item");
- m_Writer.AddShort("Health", (Int16)(unsigned char)a_Pickup->GetHealth());
m_Writer.AddShort("Age", (Int16)a_Pickup->GetAge());
m_Writer.EndCompound();
}
@@ -561,36 +590,41 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
m_Writer.BeginCompound("");
AddBasicEntity(a_Projectile, a_Projectile->GetMCAClassName());
Vector3d Pos = a_Projectile->GetPosition();
- m_Writer.AddShort("xTile", (Int16)floor(Pos.x));
- m_Writer.AddShort("yTile", (Int16)floor(Pos.y));
- m_Writer.AddShort("zTile", (Int16)floor(Pos.z));
- m_Writer.AddShort("inTile", 0); // TODO: Query the block type
- m_Writer.AddShort("shake", 0); // TODO: Any shake?
- m_Writer.AddByte ("inGround", a_Projectile->IsInGround() ? 1 : 0);
+ m_Writer.AddByte("inGround", a_Projectile->IsInGround() ? 1 : 0);
switch (a_Projectile->GetProjectileKind())
{
case cProjectileEntity::pkArrow:
{
- m_Writer.AddByte("inData", 0); // TODO: Query the block meta (is it needed?)
- m_Writer.AddByte("pickup", ((cArrowEntity *)a_Projectile)->GetPickupState());
- m_Writer.AddDouble("damage", ((cArrowEntity *)a_Projectile)->GetDamageCoeff());
+ cArrowEntity * Arrow = (cArrowEntity *)a_Projectile;
+
+ m_Writer.AddInt("xTile", (Int16)Arrow->GetBlockHit().x);
+ m_Writer.AddInt("yTile", (Int16)Arrow->GetBlockHit().y);
+ m_Writer.AddInt("zTile", (Int16)Arrow->GetBlockHit().z);
+ m_Writer.AddByte("pickup", Arrow->GetPickupState());
+ m_Writer.AddDouble("damage", Arrow->GetDamageCoeff());
+ break;
+ }
+ case cProjectileEntity::pkSplashPotion:
+ {
+ cSplashPotionEntity * Potion = (cSplashPotionEntity *)a_Projectile;
+
+ m_Writer.AddInt("EffectType", (Int16)Potion->GetEntityEffectType());
+ m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration());
+ m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
+ m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
+ m_Writer.AddInt("PotionName", Potion->GetPotionColor());
break;
}
case cProjectileEntity::pkGhastFireball:
{
m_Writer.AddInt("ExplosionPower", 1);
- // fall-through:
+ break;
}
case cProjectileEntity::pkFireCharge:
case cProjectileEntity::pkWitherSkull:
case cProjectileEntity::pkEnderPearl:
{
- m_Writer.BeginList("Motion", TAG_Double);
- m_Writer.AddDouble("", a_Projectile->GetSpeedX());
- m_Writer.AddDouble("", a_Projectile->GetSpeedY());
- m_Writer.AddDouble("", a_Projectile->GetSpeedZ());
- m_Writer.EndList();
break;
}
default:
@@ -598,13 +632,10 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
ASSERT(!"Unsaved projectile entity!");
}
} // switch (ProjectileKind)
- cEntity * Creator = a_Projectile->GetCreator();
- if (Creator != NULL)
+
+ if (!a_Projectile->GetCreatorName().empty())
{
- if (Creator->GetEntityType() == cEntity::etPlayer)
- {
- m_Writer.AddString("ownerName", ((cPlayer *)Creator)->GetName());
- }
+ m_Writer.AddString("ownerName", a_Projectile->GetCreatorName());
}
m_Writer.EndCompound();
}
@@ -625,6 +656,13 @@ void cNBTChunkSerializer::AddHangingEntity(cHangingEntity * a_Hanging)
case BLOCK_FACE_YP: m_Writer.AddByte("Dir", (unsigned char)1); break;
case BLOCK_FACE_ZM: m_Writer.AddByte("Dir", (unsigned char)0); break;
case BLOCK_FACE_ZP: m_Writer.AddByte("Dir", (unsigned char)3); break;
+
+ case BLOCK_FACE_XM:
+ case BLOCK_FACE_XP:
+ case BLOCK_FACE_NONE:
+ {
+ break;
+ }
}
}
@@ -648,7 +686,6 @@ void cNBTChunkSerializer::AddExpOrbEntity(cExpOrb * a_ExpOrb)
{
m_Writer.BeginCompound("");
AddBasicEntity(a_ExpOrb, "XPOrb");
- m_Writer.AddShort("Health", (Int16)(unsigned char)a_ExpOrb->GetHealth());
m_Writer.AddShort("Age", (Int16)a_ExpOrb->GetAge());
m_Writer.AddShort("Value", (Int16)a_ExpOrb->GetReward());
m_Writer.EndCompound();
@@ -692,10 +729,9 @@ void cNBTChunkSerializer::AddMinecartChestContents(cMinecartWithChest * a_Mineca
-bool cNBTChunkSerializer::LightIsValid(bool a_IsLightValid)
+void cNBTChunkSerializer::LightIsValid(bool a_IsLightValid)
{
m_IsLightValid = a_IsLightValid;
- return a_IsLightValid; // We want lighting only if it's valid, otherwise don't bother
}
@@ -789,18 +825,21 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
// Add tile-entity into NBT:
switch (a_Entity->GetBlockType())
{
- case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity); break;
- case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
- case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
- case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
- case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
- case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
- case E_BLOCK_SIGN_POST:
- case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
- case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break;
- case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
- case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break;
- case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *) a_Entity); break;
+ case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
+ case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *)a_Entity); break;
+ case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
+ case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
+ case E_BLOCK_ENDER_CHEST: /* No data to be saved */ break;
+ case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
+ case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
+ case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break;
+ case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
+ case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break;
+ case E_BLOCK_LIT_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
+ case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
+ case E_BLOCK_SIGN_POST: AddSignEntity ((cSignEntity *) a_Entity); break;
+ case E_BLOCK_TRAPPED_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
+ case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
default:
{
diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h
index 51d104970..710a06a70 100644
--- a/src/WorldStorage/NBTChunkSerializer.h
+++ b/src/WorldStorage/NBTChunkSerializer.h
@@ -9,7 +9,7 @@
#pragma once
-#include "../ChunkDef.h"
+#include "ChunkDataCallback.h"
@@ -46,6 +46,7 @@ class cTNTEntity;
class cExpOrb;
class cHangingEntity;
class cItemFrame;
+class cEntityEffect;
@@ -92,7 +93,7 @@ protected:
// Block entities:
void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID);
- void AddChestEntity (cChestEntity * a_Entity);
+ void AddChestEntity (cChestEntity * a_Entity, BLOCKTYPE a_ChestType);
void AddDispenserEntity(cDispenserEntity * a_Entity);
void AddDropperEntity (cDropperEntity * a_Entity);
void AddFurnaceEntity (cFurnaceEntity * a_Furnace);
@@ -121,7 +122,7 @@ protected:
void AddMinecartChestContents(cMinecartWithChest * a_Minecart);
// cChunkDataSeparateCollector overrides:
- virtual bool LightIsValid(bool a_IsLightValid) override;
+ virtual void LightIsValid(bool a_IsLightValid) override;
virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) override;
virtual void Entity(cEntity * a_Entity) override;
virtual void BlockEntity(cBlockEntity * a_Entity) override;
diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp
index 9d594a084..64f4cb00d 100644
--- a/src/WorldStorage/SchematicFileSerializer.cpp
+++ b/src/WorldStorage/SchematicFileSerializer.cpp
@@ -44,7 +44,7 @@ public:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cSchematicFileSerializer:
bool cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName)
@@ -192,7 +192,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
int SizeX = a_NBT.GetShort(TSizeX);
int SizeY = a_NBT.GetShort(TSizeY);
int SizeZ = a_NBT.GetShort(TSizeZ);
- if ((SizeX < 1) || (SizeY < 1) || (SizeZ < 1))
+ if ((SizeX < 1) || (SizeX > 65535) || (SizeY < 1) || (SizeY > 256) || (SizeZ < 1) || (SizeZ > 65535))
{
LOG("Dimensions are invalid in the schematic file: %d, %d, %d", SizeX, SizeY, SizeZ);
return false;
@@ -230,11 +230,11 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
}
// Copy the block types and metas:
- int NumBytes = a_BlockArea.GetBlockCount();
+ size_t NumBytes = a_BlockArea.GetBlockCount();
if (a_NBT.GetDataLength(TBlockTypes) < NumBytes)
{
LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.",
- NumBytes, a_NBT.GetDataLength(TBlockTypes)
+ (int)NumBytes, (int)a_NBT.GetDataLength(TBlockTypes)
);
NumBytes = a_NBT.GetDataLength(TBlockTypes);
}
@@ -242,11 +242,11 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
if (AreMetasPresent)
{
- int NumBytes = a_BlockArea.GetBlockCount();
+ size_t NumBytes = a_BlockArea.GetBlockCount();
if (a_NBT.GetDataLength(TBlockMetas) < NumBytes)
{
LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.",
- NumBytes, a_NBT.GetDataLength(TBlockMetas)
+ (int)NumBytes, (int)a_NBT.GetDataLength(TBlockMetas)
);
NumBytes = a_NBT.GetDataLength(TBlockMetas);
}
diff --git a/src/WorldStorage/ScoreboardSerializer.cpp b/src/WorldStorage/ScoreboardSerializer.cpp
index 6c885bb45..da8236e0d 100644
--- a/src/WorldStorage/ScoreboardSerializer.cpp
+++ b/src/WorldStorage/ScoreboardSerializer.cpp
@@ -117,7 +117,7 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
a_Writer.EndCompound();
}
- a_Writer.EndList(); // Objectives
+ a_Writer.EndList(); // Objectives
a_Writer.BeginList("PlayerScores", TAG_Compound);
@@ -138,7 +138,7 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
}
}
- a_Writer.EndList(); // PlayerScores
+ a_Writer.EndList(); // PlayerScores
a_Writer.BeginList("Teams", TAG_Compound);
@@ -169,7 +169,7 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
a_Writer.EndCompound();
}
- a_Writer.EndList(); // Teams
+ a_Writer.EndList(); // Teams
a_Writer.BeginCompound("DisplaySlots");
@@ -182,9 +182,9 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsName);
a_Writer.AddString("slot_2", (Objective == NULL) ? "" : Objective->GetName());
- a_Writer.EndCompound(); // DisplaySlots
+ a_Writer.EndCompound(); // DisplaySlots
- a_Writer.EndCompound(); // Data
+ a_Writer.EndCompound(); // Data
}
diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp
new file mode 100644
index 000000000..74113941c
--- /dev/null
+++ b/src/WorldStorage/StatSerializer.cpp
@@ -0,0 +1,146 @@
+
+// StatSerializer.cpp
+
+
+#include "Globals.h"
+#include "StatSerializer.h"
+
+#include "../Statistics.h"
+
+
+
+
+
+cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager)
+ : m_Manager(a_Manager)
+{
+ // Even though stats are shared between worlds, they are (usually) saved
+ // inside the folder of the default world.
+
+ AString StatsPath;
+ Printf(StatsPath, "%s/stats", a_WorldName.c_str());
+
+ m_Path = StatsPath + "/" + a_PlayerName + ".json";
+
+ // Ensure that the directory exists.
+ cFile::CreateFolder(FILE_IO_PREFIX + StatsPath);
+}
+
+
+
+
+
+bool cStatSerializer::Load(void)
+{
+ AString Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_Path);
+ if (Data.empty())
+ {
+ return false;
+ }
+
+ Json::Value Root;
+ Json::Reader Reader;
+
+ if (Reader.parse(Data, Root, false))
+ {
+ return LoadStatFromJSON(Root);
+ }
+
+ return false;
+}
+
+
+
+
+
+bool cStatSerializer::Save(void)
+{
+ Json::Value Root;
+ SaveStatToJSON(Root);
+
+ cFile File;
+ if (!File.Open(FILE_IO_PREFIX + m_Path, cFile::fmWrite))
+ {
+ return false;
+ }
+
+ Json::StyledWriter Writer;
+ AString JsonData = Writer.write(Root);
+
+ File.Write(JsonData.data(), JsonData.size());
+ File.Close();
+
+ return true;
+}
+
+
+
+
+
+void cStatSerializer::SaveStatToJSON(Json::Value & a_Out)
+{
+ for (unsigned int i = 0; i < (unsigned int)statCount; ++i)
+ {
+ StatValue Value = m_Manager->GetValue((eStatistic) i);
+
+ if (Value != 0)
+ {
+ const AString & StatName = cStatInfo::GetName((eStatistic) i);
+
+ a_Out[StatName] = Value;
+ }
+
+ // TODO 2014-05-11 xdot: Save "progress"
+ }
+}
+
+
+
+
+
+bool cStatSerializer::LoadStatFromJSON(const Json::Value & a_In)
+{
+ m_Manager->Reset();
+
+ for (Json::ValueIterator it = a_In.begin() ; it != a_In.end() ; ++it)
+ {
+ AString StatName = it.key().asString();
+
+ eStatistic StatType = cStatInfo::GetType(StatName);
+
+ if (StatType == statInvalid)
+ {
+ LOGWARNING("Invalid statistic type \"%s\"", StatName.c_str());
+ continue;
+ }
+
+ Json::Value & Node = *it;
+
+ if (Node.isInt())
+ {
+ m_Manager->SetValue(StatType, Node.asInt());
+ }
+ else if (Node.isObject())
+ {
+ StatValue Value = Node.get("value", 0).asInt();
+
+ // TODO 2014-05-11 xdot: Load "progress"
+
+ m_Manager->SetValue(StatType, Value);
+ }
+ else
+ {
+ LOGWARNING("Invalid statistic value for type \"%s\"", StatName.c_str());
+ }
+ }
+
+ return true;
+}
+
+
+
+
+
+
+
+
diff --git a/src/WorldStorage/StatSerializer.h b/src/WorldStorage/StatSerializer.h
new file mode 100644
index 000000000..72f8d74f1
--- /dev/null
+++ b/src/WorldStorage/StatSerializer.h
@@ -0,0 +1,55 @@
+
+// StatSerializer.h
+
+// Declares the cStatSerializer class that is used for saving stats into JSON
+
+
+
+
+
+#pragma once
+
+#include "json/json.h"
+
+
+
+
+
+// fwd:
+class cStatManager;
+
+
+
+
+class cStatSerializer
+{
+public:
+
+ cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager);
+
+ /* Try to load the player statistics. Returns whether the operation was successful or not. */
+ bool Load(void);
+
+ /* Try to save the player statistics. Returns whether the operation was successful or not. */
+ bool Save(void);
+
+
+protected:
+
+ void SaveStatToJSON(Json::Value & a_Out);
+
+ bool LoadStatFromJSON(const Json::Value & a_In);
+
+
+private:
+
+ cStatManager* m_Manager;
+
+ AString m_Path;
+
+
+} ;
+
+
+
+
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 809cb9e42..71ff3ef99 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -14,6 +14,7 @@
#include "../Item.h"
#include "../ItemGrid.h"
#include "../StringCompression.h"
+#include "../SetChunkData.h"
#include "../BlockEntities/ChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
@@ -36,6 +37,7 @@
#include "../Entities/Minecart.h"
#include "../Entities/Pickup.h"
#include "../Entities/ArrowEntity.h"
+#include "../Entities/SplashPotionEntity.h"
#include "../Entities/ThrownEggEntity.h"
#include "../Entities/ThrownEnderPearlEntity.h"
#include "../Entities/ThrownSnowballEntity.h"
@@ -55,7 +57,7 @@ thus making skylight visible in Minutor's Lighting mode
*/
// #define DEBUG_SKYLIGHT
-/** Maximum number of MCA files that are cached in memory.
+/** Maximum number of MCA files that are cached in memory.
Since only the header is actually in the memory, this number can be high, but still, each file means an OS FS handle.
*/
#define MAX_MCA_FILES 32
@@ -68,7 +70,7 @@ Since only the header is actually in the memory, this number can be high, but st
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWSSAnvil:
cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
@@ -96,7 +98,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
gzFile gz = gzopen((FILE_IO_PREFIX + fnam).c_str(), "wb");
if (gz != NULL)
{
- gzwrite(gz, Writer.GetResult().data(), Writer.GetResult().size());
+ gzwrite(gz, Writer.GetResult().data(), (unsigned)Writer.GetResult().size());
}
gzclose(gz);
}
@@ -252,7 +254,7 @@ bool cWSSAnvil::LoadChunkFromData(const cChunkCoords & a_Chunk, const AString &
strm.next_out = (Bytef *)Uncompressed;
strm.avail_out = sizeof(Uncompressed);
strm.next_in = (Bytef *)a_Data.data();
- strm.avail_in = a_Data.size();
+ strm.avail_in = (uInt)a_Data.size();
int res = inflate(&strm, Z_FINISH);
inflateEnd(&strm);
if (res != Z_STREAM_END)
@@ -390,22 +392,22 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
} // for y
//*/
- m_World->SetChunkData(
+ m_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData(
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ,
- BlockTypes, MetaData,
+ BlockTypes, MetaData,
IsLightValid ? BlockLight : NULL,
IsLightValid ? SkyLight : NULL,
NULL, Biomes,
Entities, BlockEntities,
false
- );
+ )));
return true;
}
-void cWSSAnvil::CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, int a_Length)
+void cWSSAnvil::CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, size_t a_Length)
{
int Child = a_NBT.FindChildByName(a_Tag, a_ChildName);
if ((Child >= 0) && (a_NBT.GetType(Child) == TAG_ByteArray) && (a_NBT.GetDataLength(Child) == a_Length))
@@ -440,15 +442,15 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_
// Save blockdata:
a_Writer.BeginList("Sections", TAG_Compound);
- int SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16;
- int SliceSizeNibble = SliceSizeBlock / 2;
+ size_t SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16;
+ size_t SliceSizeNibble = SliceSizeBlock / 2;
const char * BlockTypes = (const char *)(Serializer.m_BlockTypes);
const char * BlockMetas = (const char *)(Serializer.m_BlockMetas);
#ifdef DEBUG_SKYLIGHT
const char * BlockLight = (const char *)(Serializer.m_BlockSkyLight);
#else
const char * BlockLight = (const char *)(Serializer.m_BlockLight);
- #endif
+ #endif
const char * BlockSkyLight = (const char *)(Serializer.m_BlockSkyLight);
for (int Y = 0; Y < 16; Y++)
{
@@ -462,13 +464,16 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_
}
a_Writer.EndList(); // "Sections"
- // Store the information that the lighting is valid.
+ // Store the information that the lighting is valid.
// For compatibility reason, the default is "invalid" (missing) - this means older data is re-lighted upon loading.
if (Serializer.IsLightValid())
{
a_Writer.AddByte("MCSIsLightValid", 1);
}
+ // Store the flag that the chunk has all the ores, trees, dungeons etc. MCS chunks are always complete.
+ a_Writer.AddByte("TerrainPopulated", 1);
+
a_Writer.EndCompound(); // "Level"
return true;
}
@@ -579,7 +584,7 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
}
if (strncmp(a_NBT.GetData(sID), "Chest", a_NBT.GetDataLength(sID)) == 0)
{
- LoadChestFromNBT(a_BlockEntities, a_NBT, Child);
+ LoadChestFromNBT(a_BlockEntities, a_NBT, Child, E_BLOCK_CHEST);
}
else if (strncmp(a_NBT.GetData(sID), "Control", a_NBT.GetDataLength(sID)) == 0)
{
@@ -621,6 +626,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
{
LoadDispenserFromNBT(a_BlockEntities, a_NBT, Child);
}
+ else if (strncmp(a_NBT.GetData(sID), "TrappedChest", a_NBT.GetDataLength(sID)) == 0)
+ {
+ LoadChestFromNBT(a_BlockEntities, a_NBT, Child, E_BLOCK_TRAPPED_CHEST);
+ }
// TODO: Other block entities
} // for Child - tag children
}
@@ -645,18 +654,16 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
}
int Damage = a_NBT.FindChildByName(a_TagIdx, "Damage");
- if ((Damage < 0) || (a_NBT.GetType(Damage) != TAG_Short))
+ if ((Damage > 0) && (a_NBT.GetType(Damage) == TAG_Short))
{
- return false;
+ a_Item.m_ItemDamage = a_NBT.GetShort(Damage);
}
- a_Item.m_ItemDamage = a_NBT.GetShort(Damage);
int Count = a_NBT.FindChildByName(a_TagIdx, "Count");
- if ((Count < 0) || (a_NBT.GetType(Count) != TAG_Byte))
+ if ((Count > 0) && (a_NBT.GetType(Count) == TAG_Byte))
{
- return false;
+ a_Item.m_ItemCount = a_NBT.GetByte(Count);
}
- a_Item.m_ItemCount = a_NBT.GetByte(Count);
// Find the "tag" tag, used for enchantments and other extra data
int TagTag = a_NBT.FindChildByName(a_TagIdx, "tag");
@@ -666,6 +673,29 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
return true;
}
+ // Load repair cost:
+ int RepairCost = a_NBT.FindChildByName(TagTag, "RepairCost");
+ if ((RepairCost > 0) && (a_NBT.GetType(RepairCost) == TAG_Int))
+ {
+ a_Item.m_RepairCost = a_NBT.GetInt(RepairCost);
+ }
+
+ // Load display name:
+ int DisplayTag = a_NBT.FindChildByName(TagTag, "display");
+ if (DisplayTag > 0)
+ {
+ int DisplayName = a_NBT.FindChildByName(DisplayTag, "Name");
+ if ((DisplayName > 0) && (a_NBT.GetType(DisplayName) == TAG_String))
+ {
+ a_Item.m_CustomName = a_NBT.GetString(DisplayName);
+ }
+ int Lore = a_NBT.FindChildByName(DisplayTag, "Lore");
+ if ((Lore > 0) && (a_NBT.GetType(Lore) == TAG_String))
+ {
+ a_Item.m_Lore = a_NBT.GetString(Lore);
+ }
+ }
+
// Load enchantments:
const char * EnchName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
int EnchTag = a_NBT.FindChildByName(TagTag, EnchName);
@@ -674,6 +704,7 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
EnchantmentSerializer::ParseFromNBT(a_Item.m_Enchantments, a_NBT, EnchTag);
}
+ // Load firework data:
int FireworksTag = a_NBT.FindChildByName(TagTag, ((a_Item.m_ItemType == E_ITEM_FIREWORK_STAR) ? "Fireworks" : "Explosion"));
if (EnchTag > 0)
{
@@ -715,7 +746,7 @@ void cWSSAnvil::LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a
-void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_ChestType)
{
ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
int x, y, z;
@@ -728,7 +759,7 @@ void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cPars
{
return; // Make it an empty chest - the chunk loader will provide an empty cChestEntity for this
}
- std::auto_ptr<cChestEntity> Chest(new cChestEntity(x, y, z, m_World));
+ std::auto_ptr<cChestEntity> Chest(new cChestEntity(x, y, z, m_World, a_ChestType));
LoadItemGridFromNBT(Chest->GetContents(), a_NBT, Items);
a_BlockEntities.push_back(Chest.release());
}
@@ -1056,7 +1087,7 @@ void cWSSAnvil::LoadCommandBlockFromNBT(cBlockEntityList & a_BlockEntities, cons
-void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength)
+void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, size_t a_IDTagLength)
{
if (strncmp(a_IDTag, "Boat", a_IDTagLength) == 0)
{
@@ -1127,6 +1158,10 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{
LoadArrowFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
}
+ else if (strncmp(a_IDTag, "SplashPotion", a_IDTagLength) == 0)
+ {
+ LoadSplashPotionFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
+ }
else if (strncmp(a_IDTag, "Snowball", a_IDTagLength) == 0)
{
LoadSnowballFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
@@ -1322,7 +1357,7 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
void cWSSAnvil::LoadMinecartRFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cRideableMinecart> Minecart(new cRideableMinecart(0, 0, 0, cItem(), 1)); // TODO: Load the block and the height
+ std::auto_ptr<cRideableMinecart> Minecart(new cRideableMinecart(0, 0, 0, cItem(), 1)); // TODO: Load the block and the height
if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
{
return;
@@ -1431,18 +1466,11 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a
return;
}
- std::auto_ptr<cPickup> Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false
+ std::auto_ptr<cPickup> Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false
if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx))
{
return;
}
-
- // Load health:
- int Health = a_NBT.FindChildByName(a_TagIdx, "Health");
- if (Health > 0)
- {
- Pickup->SetHealth((int) (a_NBT.GetShort(Health) & 0xFF));
- }
// Load age:
int Age = a_NBT.FindChildByName(a_TagIdx, "Age");
@@ -1488,13 +1516,6 @@ void cWSSAnvil::LoadExpOrbFromNBT(cEntityList & a_Entities, const cParsedNBT & a
return;
}
- // Load Health:
- int Health = a_NBT.FindChildByName(a_TagIdx, "Health");
- if (Health > 0)
- {
- ExpOrb->SetHealth((int) (a_NBT.GetShort(Health) & 0xFF));
- }
-
// Load Age:
int Age = a_NBT.FindChildByName(a_TagIdx, "Age");
if (Age > 0)
@@ -1631,6 +1652,15 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
Arrow->SetDamageCoeff(a_NBT.GetDouble(DamageIdx));
}
+ // Load block hit:
+ int InBlockXIdx = a_NBT.FindChildByName(a_TagIdx, "xTile");
+ int InBlockYIdx = a_NBT.FindChildByName(a_TagIdx, "yTile");
+ int InBlockZIdx = a_NBT.FindChildByName(a_TagIdx, "zTile");
+ if ((InBlockXIdx > 0) && (InBlockYIdx > 0) && (InBlockZIdx > 0))
+ {
+ Arrow->SetBlockHit(Vector3i(a_NBT.GetInt(InBlockXIdx), a_NBT.GetInt(InBlockYIdx), a_NBT.GetInt(InBlockZIdx)));
+ }
+
// Store the new arrow in the entities list:
a_Entities.push_back(Arrow.release());
}
@@ -1638,6 +1668,29 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
+void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
+{
+ std::auto_ptr<cSplashPotionEntity> SplashPotion(new cSplashPotionEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0), cItem()));
+ if (!LoadProjectileBaseFromNBT(*SplashPotion.get(), a_NBT, a_TagIdx))
+ {
+ return;
+ }
+
+ int EffectDuration = a_NBT.FindChildByName(a_TagIdx, "EffectDuration");
+ int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity");
+ int EffectDistanceModifier = a_NBT.FindChildByName(a_TagIdx, "EffectDistanceModifier");
+
+ SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType"));
+ SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier));
+ SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
+
+ // Store the new splash potion in the entities list:
+ a_Entities.push_back(SplashPotion.release());
+}
+
+
+
+
void cWSSAnvil::LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
@@ -1974,7 +2027,10 @@ void cWSSAnvil::LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT
{
int SizeIdx = a_NBT.FindChildByName(a_TagIdx, "Size");
- if (SizeIdx < 0) { return; }
+ if (SizeIdx < 0)
+ {
+ return;
+ }
int Size = a_NBT.GetInt(SizeIdx);
@@ -2059,10 +2115,11 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
int ColorIdx = a_NBT.FindChildByName(a_TagIdx, "Color");
-
- if (ColorIdx < 0) { return; }
-
- int Color = (int)a_NBT.GetByte(ColorIdx);
+ int Color = -1;
+ if (ColorIdx > 0)
+ {
+ Color = (int)a_NBT.GetByte(ColorIdx);
+ }
std::auto_ptr<cSheep> Monster(new cSheep(Color));
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
@@ -2075,6 +2132,12 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
return;
}
+ int ShearedIdx = a_NBT.FindChildByName(a_TagIdx, "Sheared");
+ if (ShearedIdx > 0)
+ {
+ Monster->SetSheared(a_NBT.GetByte(ShearedIdx) != 0);
+ }
+
a_Entities.push_back(Monster.release());
}
@@ -2132,7 +2195,10 @@ void cWSSAnvil::LoadSlimeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
{
int SizeIdx = a_NBT.FindChildByName(a_TagIdx, "Size");
- if (SizeIdx < 0) { return; }
+ if (SizeIdx < 0)
+ {
+ return;
+ }
int Size = a_NBT.GetInt(SizeIdx);
@@ -2276,7 +2342,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a
int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul");
if (CurrLine > 0)
{
- Monster->SetNumInvulnerableTicks(a_NBT.GetInt(CurrLine));
+ Monster->SetWitherInvulnerableTicks(a_NBT.GetInt(CurrLine));
}
a_Entities.push_back(Monster.release());
@@ -2298,8 +2364,8 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
return;
}
int OwnerIdx = a_NBT.FindChildByName(a_TagIdx, "Owner");
- if (OwnerIdx > 0)
- {
+ if (OwnerIdx > 0)
+ {
AString OwnerName = a_NBT.GetString(OwnerIdx);
if (OwnerName != "")
{
@@ -2406,6 +2472,10 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N
}
a_Entity.SetYaw(Rotation[0]);
a_Entity.SetRoll(Rotation[1]);
+
+ // Load health:
+ int Health = a_NBT.FindChildByName(a_TagIdx, "Health");
+ a_Entity.SetHealth(Health > 0 ? a_NBT.GetShort(Health) : a_Entity.GetMaxHealth());
return true;
}
@@ -2417,7 +2487,7 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N
bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_NBT, int a_TagIdx)
{
float DropChance[5];
- if (!LoadFloatsListFromNBT(DropChance, 5, a_NBT, a_NBT.FindChildByName(a_TagIdx, "DropChance")))
+ if (!LoadFloatsListFromNBT(DropChance, 5, a_NBT, a_NBT.FindChildByName(a_TagIdx, "DropChances")))
{
return false;
}
@@ -2426,8 +2496,14 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT &
a_Monster.SetDropChanceChestplate(DropChance[2]);
a_Monster.SetDropChanceLeggings(DropChance[3]);
a_Monster.SetDropChanceBoots(DropChance[4]);
- bool CanPickUpLoot = (a_NBT.GetByte(a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot")) == 1);
- a_Monster.SetCanPickUpLoot(CanPickUpLoot);
+
+ int LootTag = a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot");
+ if (LootTag > 0)
+ {
+ bool CanPickUpLoot = (a_NBT.GetByte(LootTag) == 1);
+ a_Monster.SetCanPickUpLoot(CanPickUpLoot);
+ }
+
return true;
}
@@ -2450,8 +2526,6 @@ bool cWSSAnvil::LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cP
}
a_Entity.SetIsInGround(IsInGround);
- // TODO: Load inTile, TileCoords
-
return true;
}
@@ -2522,7 +2596,7 @@ bool cWSSAnvil::GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWSSAnvil::cMCAFile:
cWSSAnvil::cMCAFile::cMCAFile(const AString & a_FileName, int a_RegionX, int a_RegionZ) :
@@ -2602,14 +2676,14 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a
unsigned ChunkLocation = ntohl(m_Header[LocalX + 32 * LocalZ]);
unsigned ChunkOffset = ChunkLocation >> 8;
- m_File.Seek(ChunkOffset * 4096);
+ m_File.Seek((int)ChunkOffset * 4096);
int ChunkSize = 0;
if (m_File.Read(&ChunkSize, 4) != 4)
{
return false;
}
- ChunkSize = ntohl(ChunkSize);
+ ChunkSize = ntohl((u_long)ChunkSize);
char CompressionType = 0;
if (m_File.Read(&CompressionType, 1) != 1)
{
@@ -2654,7 +2728,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
// Store the chunk data:
m_File.Seek(ChunkSector * 4096);
- unsigned ChunkSize = htonl(a_Data.size() + 1);
+ u_long ChunkSize = htonl((u_long)a_Data.size() + 1);
if (m_File.Write(&ChunkSize, 4) != 4)
{
LOGWARNING("Cannot save chunk [%d, %d], writing(1) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
@@ -2672,8 +2746,13 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
return false;
}
+ // Add padding to 4K boundary:
+ size_t BytesWritten = a_Data.size() + MCA_CHUNK_HEADER_LENGTH;
+ static const char Padding[4095] = {0};
+ m_File.Write(Padding, 4096 - (BytesWritten % 4096));
+
// Store the header:
- ChunkSize = (a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number
+ ChunkSize = ((u_long)a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number
ASSERT(ChunkSize < 256);
m_Header[LocalX + 32 * LocalZ] = htonl((ChunkSector << 8) | ChunkSize);
if (m_File.Seek(0) < 0)
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index 1773ee882..9f8714404 100644
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -133,7 +133,7 @@ protected:
*/
void LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a_NBT, int a_ItemsTagIdx, int s_SlotOffset = 0);
- void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_ChestType);
void LoadDispenserFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadDropperFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadFlowerPotFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
@@ -145,7 +145,7 @@ protected:
void LoadMobHeadFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadCommandBlockFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength);
+ void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, size_t a_IDTagLength);
void LoadBoatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadEnderCrystalFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
@@ -153,7 +153,7 @@ protected:
void LoadPickupFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadTNTFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadExpOrbFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadHangingFromNBT (cHangingEntity & a_Hanging,const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadHangingFromNBT (cHangingEntity & a_Hanging, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadItemFrameFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadMinecartRFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
@@ -163,6 +163,7 @@ protected:
void LoadMinecartHFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadArrowFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSplashPotionFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadSnowballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadEggFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadFireballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
@@ -221,7 +222,7 @@ protected:
cMCAFile * LoadMCAFile(const cChunkCoords & a_Chunk);
/// Copies a_Length bytes of data from the specified NBT Tag's Child into the a_Destination buffer
- void CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, int a_Length);
+ void CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, size_t a_Length);
// cWSSchema overrides:
virtual bool LoadChunk(const cChunkCoords & a_Chunk) override;
diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp
index 359bac4a8..ee47047a0 100644
--- a/src/WorldStorage/WSSCompact.cpp
+++ b/src/WorldStorage/WSSCompact.cpp
@@ -18,6 +18,7 @@
#include "../BlockEntities/MobHeadEntity.h"
#include "../BlockEntities/NoteEntity.h"
#include "../BlockEntities/SignEntity.h"
+#include "../SetChunkData.h"
@@ -48,7 +49,7 @@ const int MAX_DIRTY_CHUNKS = 16;
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cJsonChunkSerializer:
cJsonChunkSerializer::cJsonChunkSerializer(void) :
@@ -107,22 +108,20 @@ void cJsonChunkSerializer::BlockEntity(cBlockEntity * a_BlockEntity)
-bool cJsonChunkSerializer::LightIsValid(bool a_IsLightValid)
+void cJsonChunkSerializer::LightIsValid(bool a_IsLightValid)
{
- if (!a_IsLightValid)
+ if (a_IsLightValid)
{
- return false;
+ m_Root["IsLightValid"] = true;
+ m_HasJsonData = true;
}
- m_Root["IsLightValid"] = true;
- m_HasJsonData = true;
- return true;
}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWSSCompact:
cWSSCompact::~cWSSCompact()
@@ -198,7 +197,7 @@ cWSSCompact::cPAKFile * cWSSCompact::LoadPAKFile(const cChunkCoords & a_Chunk)
// Load it anew:
AString FileName;
- Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ );
+ Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ);
cPAKFile * f = new cPAKFile(FileName, LayerX, LayerZ, m_CompressionFactor);
if (f == NULL)
{
@@ -273,12 +272,12 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
Json::Value AllChests = a_Value.get("Chests", Json::nullValue);
if (!AllChests.empty())
{
- for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr )
+ for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr)
{
- std::auto_ptr<cChestEntity> ChestEntity(new cChestEntity(0, 0, 0, a_World));
+ std::auto_ptr<cChestEntity> ChestEntity(new cChestEntity(0, 0, 0, a_World, E_BLOCK_CHEST));
if (!ChestEntity->LoadFromJson(*itr))
{
- LOGWARNING("ERROR READING CHEST FROM JSON!" );
+ LOGWARNING("ERROR READING CHEST FROM JSON!");
}
else
{
@@ -294,7 +293,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
std::auto_ptr<cDispenserEntity> DispenserEntity(new cDispenserEntity(0, 0, 0, a_World));
if (!DispenserEntity->LoadFromJson(*itr))
{
- LOGWARNING("ERROR READING DISPENSER FROM JSON!" );
+ LOGWARNING("ERROR READING DISPENSER FROM JSON!");
}
else
{
@@ -309,7 +308,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
std::auto_ptr<cFlowerPotEntity> FlowerPotEntity(new cFlowerPotEntity(0, 0, 0, a_World));
if (!FlowerPotEntity->LoadFromJson(*itr))
{
- LOGWARNING("ERROR READING FLOWERPOT FROM JSON!" );
+ LOGWARNING("ERROR READING FLOWERPOT FROM JSON!");
}
else
{
@@ -325,7 +324,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
std::auto_ptr<cFurnaceEntity> FurnaceEntity(new cFurnaceEntity(0, 0, 0, E_BLOCK_FURNACE, 0, a_World));
if (!FurnaceEntity->LoadFromJson(*itr))
{
- LOGWARNING("ERROR READING FURNACE FROM JSON!" );
+ LOGWARNING("ERROR READING FURNACE FROM JSON!");
}
else
{
@@ -355,7 +354,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
std::auto_ptr<cNoteEntity> NoteEntity(new cNoteEntity(0, 0, 0, a_World));
if (!NoteEntity->LoadFromJson(*itr))
{
- LOGWARNING("ERROR READING NOTE BLOCK FROM JSON!" );
+ LOGWARNING("ERROR READING NOTE BLOCK FROM JSON!");
}
else
{
@@ -370,7 +369,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
std::auto_ptr<cJukeboxEntity> JukeboxEntity(new cJukeboxEntity(0, 0, 0, a_World));
if (!JukeboxEntity->LoadFromJson(*itr))
{
- LOGWARNING("ERROR READING JUKEBOX FROM JSON!" );
+ LOGWARNING("ERROR READING JUKEBOX FROM JSON!");
}
else
{
@@ -385,7 +384,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
std::auto_ptr<cCommandBlockEntity> CommandBlockEntity(new cCommandBlockEntity(0, 0, 0, a_World));
if (!CommandBlockEntity->LoadFromJson(*itr))
{
- LOGWARNING("ERROR READING COMMAND BLOCK FROM JSON!" );
+ LOGWARNING("ERROR READING COMMAND BLOCK FROM JSON!");
}
else
{
@@ -400,7 +399,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
std::auto_ptr<cMobHeadEntity> MobHeadEntity(new cMobHeadEntity(0, 0, 0, a_World));
if (!MobHeadEntity->LoadFromJson(*itr))
{
- LOGWARNING("ERROR READING MOB HEAD FROM JSON!" );
+ LOGWARNING("ERROR READING MOB HEAD FROM JSON!");
}
else
{
@@ -413,7 +412,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWSSCompact::cPAKFile
#define READ(Var) \
@@ -429,8 +428,8 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_
m_LayerX(a_LayerX),
m_LayerZ(a_LayerZ),
m_NumDirty(0),
- m_ChunkVersion( CHUNK_VERSION ), // Init with latest version
- m_PakVersion( PAK_VERSION )
+ m_ChunkVersion( CHUNK_VERSION), // Init with latest version
+ m_PakVersion( PAK_VERSION)
{
cFile f;
if (!f.Open(m_FileName, cFile::fmRead))
@@ -447,18 +446,24 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_
}
READ(m_ChunkVersion);
- switch( m_ChunkVersion )
+ switch (m_ChunkVersion)
{
- case 1:
- m_ChunkSize.Set(16, 128, 16);
- break;
- case 2:
- case 3:
- m_ChunkSize.Set(16, 256, 16);
- break;
- default:
- LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion);
- return;
+ case 1:
+ {
+ m_ChunkSize.Set(16, 128, 16);
+ break;
+ }
+ case 2:
+ case 3:
+ {
+ m_ChunkSize.Set(16, 256, 16);
+ break;
+ }
+ default:
+ {
+ LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion);
+ return;
+ }
};
short NumChunks = 0;
@@ -475,6 +480,7 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_
{
LOGERROR("ERROR READING %s FROM FILE %s (line %d); file offset %d", "Header", m_FileName.c_str(), __LINE__, f.Tell());
delete Header;
+ Header = NULL;
return;
}
m_ChunkHeaders.push_back(Header);
@@ -487,12 +493,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_
return;
}
- if( m_ChunkVersion == 1 ) // Convert chunks to version 2
+ if (m_ChunkVersion == 1) // Convert chunks to version 2
{
UpdateChunk1To2();
}
#if AXIS_ORDER == AXIS_ORDER_XZY
- if( m_ChunkVersion == 2 ) // Convert chunks to version 3
+ if (m_ChunkVersion == 2) // Convert chunks to version 3
{
UpdateChunk2To3();
}
@@ -575,9 +581,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
{
sChunkHeader * Header = *itr;
- if( ChunksConverted % 32 == 0 )
+ if (ChunksConverted % 32 == 0)
{
- LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() );
+ LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size());
}
ChunksConverted++;
@@ -587,7 +593,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
Offset += Header->m_CompressedSize;
// Crude data integrity check:
- int ExpectedSize = (16*128*16)*2 + (16*128*16)/2; // For version 1
+ int ExpectedSize = (16*128*16)*2 + (16*128*16)/2; // For version 1
if (UncompressedSize < ExpectedSize)
{
LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing",
@@ -601,10 +607,10 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
// Decompress the data:
AString UncompressedData;
{
- int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize);
+ int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize);
if (errorcode != Z_OK)
{
- LOGERROR("Error %d decompressing data for chunk [%d, %d]",
+ LOGERROR("Error %d decompressing data for chunk [%d, %d]",
errorcode,
Header->m_ChunkX, Header->m_ChunkZ
);
@@ -628,9 +634,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
char ConvertedData[cChunkDef::BlockDataSize];
int Index = 0;
unsigned int InChunkOffset = 0;
- for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z )
+ for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z)
{
- for( int y = 0; y < 128; ++y )
+ for (int y = 0; y < 128; ++y)
{
ConvertedData[Index++] = UncompressedData[y + z * 128 + x * 128 * 16 + InChunkOffset];
}
@@ -639,9 +645,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
Index += 128;
}
InChunkOffset += (16 * 128 * 16);
- for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata
+ for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Metadata
{
- for( int y = 0; y < 64; ++y )
+ for (int y = 0; y < 64; ++y)
{
ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset];
}
@@ -649,9 +655,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
Index += 64;
}
InChunkOffset += (16 * 128 * 16) / 2;
- for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light
+ for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Block light
{
- for( int y = 0; y < 64; ++y )
+ for (int y = 0; y < 64; ++y)
{
ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset];
}
@@ -659,9 +665,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
Index += 64;
}
InChunkOffset += (16*128*16)/2;
- for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light
+ for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Sky light
{
- for( int y = 0; y < 64; ++y )
+ for (int y = 0; y < 64; ++y)
{
ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset];
}
@@ -675,16 +681,16 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
// Add JSON data afterwards
if (UncompressedData.size() > InChunkOffset)
{
- Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() );
+ Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end());
}
// Re-compress data
AString CompressedData;
{
- int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData,m_CompressionFactor);
+ int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor);
if (errorcode != Z_OK)
{
- LOGERROR("Error %d compressing data for chunk [%d, %d]",
+ LOGERROR("Error %d compressing data for chunk [%d, %d]",
errorcode,
Header->m_ChunkX, Header->m_ChunkZ
);
@@ -693,9 +699,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
}
// Save into file's cache
- Header->m_UncompressedSize = Converted.size();
- Header->m_CompressedSize = CompressedData.size();
- NewDataContents.append( CompressedData );
+ Header->m_UncompressedSize = (int)Converted.size();
+ Header->m_CompressedSize = (int)CompressedData.size();
+ NewDataContents.append(CompressedData);
}
// Done converting
@@ -703,7 +709,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
m_ChunkVersion = 2;
SynchronizeFile();
- LOGINFO("Updated \"%s\" version 1 to version 2", m_FileName.c_str() );
+ LOGINFO("Updated \"%s\" version 1 to version 2", m_FileName.c_str());
}
@@ -719,9 +725,9 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
{
sChunkHeader * Header = *itr;
- if( ChunksConverted % 32 == 0 )
+ if (ChunksConverted % 32 == 0)
{
- LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() );
+ LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size());
}
ChunksConverted++;
@@ -731,7 +737,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
Offset += Header->m_CompressedSize;
// Crude data integrity check:
- const int ExpectedSize = (16*256*16)*2 + (16*256*16)/2; // For version 2
+ const int ExpectedSize = (16 * 256 * 16) * 2 + (16 * 256 * 16) / 2; // For version 2
if (UncompressedSize < ExpectedSize)
{
LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing",
@@ -745,10 +751,10 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
// Decompress the data:
AString UncompressedData;
{
- int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize);
+ int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize);
if (errorcode != Z_OK)
{
- LOGERROR("Error %d decompressing data for chunk [%d, %d]",
+ LOGERROR("Error %d decompressing data for chunk [%d, %d]",
errorcode,
Header->m_ChunkX, Header->m_ChunkZ
);
@@ -772,10 +778,10 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
// Cannot use cChunk::MakeIndex because it might change again?????????
// For compatibility, use what we know is current
- #define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) )
+ #define MAKE_3_INDEX( x, y, z) ( x + (z * 16) + (y * 16 * 16))
unsigned int InChunkOffset = 0;
- for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X
+ for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) // YZX Loop order is important, in 1.1 Y was first then Z then X
{
ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset];
++InChunkOffset;
@@ -783,25 +789,25 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
unsigned int index2 = 0;
- for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
+ for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y)
{
- ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
+ ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4);
++index2;
}
InChunkOffset += index2 / 2;
index2 = 0;
- for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
+ for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y)
{
- ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
+ ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4);
++index2;
}
InChunkOffset += index2 / 2;
index2 = 0;
- for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
+ for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y)
{
- ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
+ ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4);
++index2;
}
InChunkOffset += index2 / 2;
@@ -811,7 +817,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
// Add JSON data afterwards
if (UncompressedData.size() > InChunkOffset)
{
- Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() );
+ Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end());
}
// Re-compress data
@@ -820,7 +826,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor);
if (errorcode != Z_OK)
{
- LOGERROR("Error %d compressing data for chunk [%d, %d]",
+ LOGERROR("Error %d compressing data for chunk [%d, %d]",
errorcode,
Header->m_ChunkX, Header->m_ChunkZ
);
@@ -829,9 +835,9 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
}
// Save into file's cache
- Header->m_UncompressedSize = Converted.size();
- Header->m_CompressedSize = CompressedData.size();
- NewDataContents.append( CompressedData );
+ Header->m_UncompressedSize = (int)Converted.size();
+ Header->m_CompressedSize = (int)CompressedData.size();
+ NewDataContents.append(CompressedData);
}
// Done converting
@@ -839,7 +845,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
m_ChunkVersion = 3;
SynchronizeFile();
- LOGINFO("Updated \"%s\" version 2 to version 3", m_FileName.c_str() );
+ LOGINFO("Updated \"%s\" version 2 to version 3", m_FileName.c_str());
}
@@ -861,10 +867,10 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
// Decompress the data:
AString UncompressedData;
- int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, a_UncompressedSize);
+ int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, (size_t)a_UncompressedSize);
if (errorcode != Z_OK)
{
- LOGERROR("Error %d decompressing data for chunk [%d, %d]",
+ LOGERROR("Error %d decompressing data for chunk [%d, %d]",
errorcode,
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ
);
@@ -873,7 +879,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
if (a_UncompressedSize != (int)UncompressedData.size())
{
- LOGWARNING("Uncompressed data size differs (exp %d bytes, got " SIZE_T_FMT ") for chunk [%d, %d]",
+ LOGWARNING("Uncompressed data size differs (exp %d bytes, got " SIZE_T_FMT ") for chunk [%d, %d]",
a_UncompressedSize, UncompressedData.size(),
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ
);
@@ -888,7 +894,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
{
Json::Value root; // will contain the root value after parsing.
Json::Reader reader;
- if ( !reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) )
+ if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false))
{
LOGERROR("Failed to parse trailing JSON in chunk [%d, %d]!",
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ
@@ -906,7 +912,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
NIBBLETYPE * BlockLight = (NIBBLETYPE *)(BlockData + LightOffset);
NIBBLETYPE * SkyLight = (NIBBLETYPE *)(BlockData + SkyLightOffset);
- a_World->SetChunkData(
+ a_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData(
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ,
BlockData, MetaData,
IsLightValid ? BlockLight : NULL,
@@ -914,7 +920,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
NULL, NULL,
Entities, BlockEntities,
false
- );
+ )));
return true;
}
@@ -971,7 +977,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld
// Compress the data:
AString CompressedData;
int errorcode = CompressString(Data.data(), Data.size(), CompressedData, m_CompressionFactor);
- if ( errorcode != Z_OK )
+ if (errorcode != Z_OK)
{
LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ);
return false;
diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h
index 97e3b82f9..83e9cb49f 100644
--- a/src/WorldStorage/WSSCompact.h
+++ b/src/WorldStorage/WSSCompact.h
@@ -14,6 +14,7 @@
#include "WorldStorage.h"
#include "../Vector3.h"
#include "json/json.h"
+#include "ChunkDataCallback.h"
@@ -21,7 +22,7 @@
/// Helper class for serializing a chunk into Json
class cJsonChunkSerializer :
- public cChunkDataCollector
+ public cChunkDataArrayCollector
{
public:
@@ -42,7 +43,7 @@ protected:
// cChunkDataCollector overrides:
virtual void Entity (cEntity * a_Entity) override;
virtual void BlockEntity (cBlockEntity * a_Entity) override;
- virtual bool LightIsValid (bool a_IsLightValid) override;
+ virtual void LightIsValid (bool a_IsLightValid) override;
} ;
@@ -104,15 +105,15 @@ protected:
int m_NumDirty; // Number of chunks that were written into m_DataContents but not into the file
- Vector3i m_ChunkSize; // Is related to m_ChunkVersion
+ Vector3i m_ChunkSize; // Is related to m_ChunkVersion
char m_ChunkVersion;
char m_PakVersion;
bool SaveChunkToData(const cChunkCoords & a_Chunk, cWorld * a_World); // Saves the chunk to m_DataContents, updates headers and m_NumDirty
void SynchronizeFile(void); // Writes m_DataContents along with the headers to file, resets m_NumDirty
- void UpdateChunk1To2(void); // Height from 128 to 256
- void UpdateChunk2To3(void); // Axis order from YZX to XZY
+ void UpdateChunk1To2(void); // Height from 128 to 256
+ void UpdateChunk2To3(void); // Axis order from YZX to XZY
} ;
typedef std::list<cPAKFile *> cPAKFiles;
diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp
index 54eaaca5c..707e8f929 100644
--- a/src/WorldStorage/WorldStorage.cpp
+++ b/src/WorldStorage/WorldStorage.cpp
@@ -17,13 +17,6 @@
-/// If a chunk with this Y coord is de-queued, it is a signal to emit the saved-all message (cWorldStorage::QueueSavedMessage())
-#define CHUNK_Y_MESSAGE 2
-
-
-
-
-
/// Example storage schema - forgets all chunks ;)
class cWSSForgetful :
public cWSSchema
@@ -42,7 +35,7 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cWorldStorage:
cWorldStorage::cWorldStorage(void) :
@@ -68,7 +61,7 @@ cWorldStorage::~cWorldStorage()
-bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor )
+bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor)
{
m_World = a_World;
m_StorageSchemaName = a_StorageSchemaName;
@@ -103,7 +96,7 @@ void cWorldStorage::WaitForFinish(void)
// Wait for the thread to finish:
m_ShouldTerminate = true;
- m_Event.Set(); // Wake up the thread if waiting
+ m_Event.Set(); // Wake up the thread if waiting
super::Wait();
LOG("World storage thread finished");
}
@@ -168,20 +161,9 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
-void cWorldStorage::QueueSavedMessage(void)
-{
- // Pushes a special coord pair into the queue, signalizing a message instead
- m_SaveQueue.EnqueueItem(cChunkCoords(0, CHUNK_Y_MESSAGE, 0));
- m_Event.Set();
-}
-
-
-
-
-
void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
- m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ,true));
+ m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, true));
}
@@ -200,8 +182,8 @@ void cWorldStorage::UnqueueSave(const cChunkCoords & a_Chunk)
void cWorldStorage::InitSchemas(int a_StorageCompressionFactor)
{
// The first schema added is considered the default
- m_Schemas.push_back(new cWSSAnvil (m_World,a_StorageCompressionFactor));
- m_Schemas.push_back(new cWSSCompact (m_World,a_StorageCompressionFactor));
+ m_Schemas.push_back(new cWSSAnvil (m_World, a_StorageCompressionFactor));
+ m_Schemas.push_back(new cWSSCompact (m_World, a_StorageCompressionFactor));
m_Schemas.push_back(new cWSSForgetful(m_World));
// Add new schemas here
@@ -220,7 +202,7 @@ void cWorldStorage::InitSchemas(int a_StorageCompressionFactor)
} // for itr - m_Schemas[]
// Unknown schema selected, let the admin know:
- LOGWARNING("Unknown storage schema name \"%s\". Using default (\"%s\"). Available schemas:",
+ LOGWARNING("Unknown storage schema name \"%s\". Using default (\"%s\"). Available schemas:",
m_StorageSchemaName.c_str(), m_SaveSchema->GetName().c_str()
);
for (cWSSchemaList::iterator itr = m_Schemas.begin(); itr != m_Schemas.end(); ++itr)
@@ -243,7 +225,6 @@ void cWorldStorage::Execute(void)
bool Success;
do
{
- Success = false;
if (m_ShouldTerminate)
{
return;
@@ -287,19 +268,12 @@ bool cWorldStorage::SaveOneChunk(void)
{
cChunkCoords ToSave(0, 0, 0);
bool ShouldSave = m_SaveQueue.TryDequeueItem(ToSave);
- if(ShouldSave) {
- if (ToSave.m_ChunkY == CHUNK_Y_MESSAGE)
- {
- LOGINFO("Saved all chunks in world %s", m_World->GetName().c_str());
- return ShouldSave;
- }
- if (ShouldSave && m_World->IsChunkValid(ToSave.m_ChunkX, ToSave.m_ChunkZ))
+ if (ShouldSave && m_World->IsChunkValid(ToSave.m_ChunkX, ToSave.m_ChunkZ))
+ {
+ m_World->MarkChunkSaving(ToSave.m_ChunkX, ToSave.m_ChunkZ);
+ if (m_SaveSchema->SaveChunk(ToSave))
{
- m_World->MarkChunkSaving(ToSave.m_ChunkX, ToSave.m_ChunkZ);
- if (m_SaveSchema->SaveChunk(ToSave))
- {
- m_World->MarkChunkSaved(ToSave.m_ChunkX, ToSave.m_ChunkZ);
- }
+ m_World->MarkChunkSaved(ToSave.m_ChunkX, ToSave.m_ChunkZ);
}
}
return ShouldSave;
diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h
index bb189b6c9..978a5b5d1 100644
--- a/src/WorldStorage/WorldStorage.h
+++ b/src/WorldStorage/WorldStorage.h
@@ -67,9 +67,6 @@ public:
void QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate); // Queues the chunk for loading; if not loaded, the chunk will be generated if a_Generate is true
void QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
- /// Signals that a message should be output to the console when all the chunks have been saved
- void QueueSavedMessage(void);
-
/// Loads the chunk specified; returns true on success, false on failure
bool LoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
@@ -98,21 +95,22 @@ protected:
bool operator==(const sChunkLoad other) const
{
- return this->m_ChunkX == other.m_ChunkX &&
+ return this->m_ChunkX == other.m_ChunkX &&
this->m_ChunkY == other.m_ChunkY &&
this->m_ChunkZ == other.m_ChunkZ;
}
} ;
- struct FuncTable {
- static void Delete(sChunkLoad) {};
- static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new)
+ struct FuncTable
+ {
+ static void Delete(sChunkLoad) {}
+ static void Combine(sChunkLoad & a_orig, const sChunkLoad a_new)
{
a_orig.m_Generate |= a_new.m_Generate;
- };
+ }
};
- typedef cQueue<sChunkLoad,FuncTable> sChunkLoadQueue;
+ typedef cQueue<sChunkLoad, FuncTable> sChunkLoadQueue;
cWorld * m_World;
AString m_StorageSchemaName;
diff --git a/src/XMLParser.h b/src/XMLParser.h
index f492d1a5d..e39405529 100644
--- a/src/XMLParser.h
+++ b/src/XMLParser.h
@@ -55,13 +55,13 @@ protected:
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// The following template has been modified from code available at
// http://www.codeproject.com/Articles/1847/C-Wrappers-for-the-Expat-XML-Parser
// It uses templates to remove the virtual function call penalty (both size and speed) for each callback
/* Usage:
-1, Declare a subclass:
+1, Declare a subclass:
class CMyParser : public CExpatImpl<CMyParser>
2, Declare handlers that you want in that subclass:
void CMyParser::OnEndElement(const XML_Char * iTagName);
@@ -318,7 +318,7 @@ protected:
void EnableEndDoctypeDeclHandler (bool fEnable = true)
{
assert (m_p != NULL);
- XML_SetEndDoctypeDeclHandler (m_p,
+ XML_SetEndDoctypeDeclHandler (m_p,
fEnable ? EndDoctypeDeclHandler : NULL);
}
@@ -336,7 +336,7 @@ public:
// @cmember Get last error
- enum XML_Error GetErrorCode ()
+ enum XML_Error GetErrorCode ()
{
assert (m_p != NULL);
return XML_GetErrorCode (m_p);
@@ -344,7 +344,7 @@ public:
// @cmember Get the current byte index
- long GetCurrentByteIndex ()
+ long GetCurrentByteIndex ()
{
assert (m_p != NULL);
return XML_GetCurrentByteIndex (m_p);
@@ -352,7 +352,7 @@ public:
// @cmember Get the current line number
- int GetCurrentLineNumber ()
+ int GetCurrentLineNumber ()
{
assert (m_p != NULL);
return XML_GetCurrentLineNumber (m_p);
@@ -360,7 +360,7 @@ public:
// @cmember Get the current column number
- int GetCurrentColumnNumber ()
+ int GetCurrentColumnNumber ()
{
assert (m_p != NULL);
return XML_GetCurrentColumnNumber (m_p);
@@ -368,7 +368,7 @@ public:
// @cmember Get the current byte count
- int GetCurrentByteCount ()
+ int GetCurrentByteCount ()
{
assert (m_p != NULL);
return XML_GetCurrentByteCount (m_p);
@@ -384,7 +384,7 @@ public:
// @cmember Get last error string
- const XML_LChar *GetErrorString ()
+ const XML_LChar *GetErrorString ()
{
return XML_ErrorString (GetErrorCode ());
}
@@ -411,7 +411,7 @@ public:
// @cmember Get last error string
- static const XML_LChar *GetErrorString (enum XML_Error nError)
+ static const XML_LChar *GetErrorString (enum XML_Error nError)
{
return XML_ErrorString (nError);
}
@@ -443,7 +443,7 @@ public:
// @cmember Processing instruction handler
- void OnProcessingInstruction (const XML_Char *pszTarget,
+ void OnProcessingInstruction (const XML_Char *pszTarget,
const XML_Char *pszData)
{
return;
@@ -495,7 +495,7 @@ public:
// @cmember Start namespace declaration handler
- void OnStartNamespaceDecl (const XML_Char *pszPrefix,
+ void OnStartNamespaceDecl (const XML_Char *pszPrefix,
const XML_Char *pszURI)
{
return;
@@ -518,7 +518,7 @@ public:
// @cmember Start DOCTYPE declaration handler
- void OnStartDoctypeDecl (const XML_Char *pszDoctypeName,
+ void OnStartDoctypeDecl (const XML_Char *pszDoctypeName,
const XML_Char *pszSysID, const XML_Char *pszPubID,
bool fHasInternalSubset)
{
@@ -607,7 +607,7 @@ protected:
// @cmember Default wrapper
- static void __cdecl DefaultHandler (void *pUserData,
+ static void __cdecl DefaultHandler (void *pUserData,
const XML_Char *pszData, int nLength)
{
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
@@ -616,12 +616,12 @@ protected:
// @cmember External entity ref wrapper
- static int __cdecl ExternalEntityRefHandler (void *pUserData,
- const XML_Char *pszContext, const XML_Char *pszBase,
+ static int __cdecl ExternalEntityRefHandler (void *pUserData,
+ const XML_Char *pszContext, const XML_Char *pszBase,
const XML_Char *pszSystemID, const XML_Char *pszPublicID)
{
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- return pThis ->OnExternalEntityRef (pszContext,
+ return pThis ->OnExternalEntityRef (pszContext,
pszBase, pszSystemID, pszPublicID) ? 1 : 0;
}
@@ -660,12 +660,12 @@ protected:
// @cmember Start Doctype declaration wrapper
static void __cdecl StartDoctypeDeclHandler (
- void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID,
+ void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID,
const XML_Char *pszPubID, int nHasInternalSubset
)
{
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnStartDoctypeDecl (pszDoctypeName, pszSysID,
+ pThis ->OnStartDoctypeDecl (pszDoctypeName, pszSysID,
pszPubID, nHasInternalSubset != 0);
}
diff --git a/src/main.cpp b/src/main.cpp
index 68eea7f4d..106233342 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3,17 +3,17 @@
#include "Root.h"
-#include <exception> //std::exception
-#include <csignal> //std::signal
-#include <stdlib.h> //exit()
+#include <exception>
+#include <csignal>
+#include <stdlib.h>
#ifdef _MSC_VER
#include <dbghelp.h>
#endif // _MSC_VER
-// Here, we have some ALL CAPS variables, to give the impression that this is deeeep, gritty programming :P
-bool g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot
-bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell Windows to close the console
+
+bool cRoot::m_TerminateEventRaised = false; // If something has told the server to stop; checked periodically in cRoot
+static bool g_ServerTerminated = false; // Set to true when the server terminates, so our CTRL handler can then tell the OS to close the console
@@ -49,10 +49,10 @@ bool g_ShouldLogCommOut;
-void NonCtrlHandler(int a_Signal)
+void NonCtrlHandler(int a_Signal)
{
LOGD("Terminate event raised from std::signal");
- g_TERMINATE_EVENT_RAISED = true;
+ cRoot::m_TerminateEventRaised = true;
switch (a_Signal)
{
@@ -61,7 +61,7 @@ void NonCtrlHandler(int a_Signal)
std::signal(SIGSEGV, SIG_DFL);
LOGERROR(" D: | MCServer has encountered an error and needs to close");
LOGERROR("Details | SIGSEGV: Segmentation fault");
- exit(EXIT_FAILURE);
+ abort();
}
case SIGABRT:
#ifdef SIGABRT_COMPAT
@@ -71,12 +71,12 @@ void NonCtrlHandler(int a_Signal)
std::signal(a_Signal, SIG_DFL);
LOGERROR(" D: | MCServer has encountered an error and needs to close");
LOGERROR("Details | SIGABRT: Server self-terminated due to an internal fault");
- exit(EXIT_FAILURE);
+ abort();
}
case SIGINT:
case SIGTERM:
{
- std::signal(a_Signal, SIG_IGN); // Server is shutting down, wait for it...
+ std::signal(a_Signal, SIG_IGN); // Server is shutting down, wait for it...
break;
}
default: break;
@@ -88,7 +88,7 @@ void NonCtrlHandler(int a_Signal)
#if defined(_WIN32) && !defined(_WIN64) && defined(_MSC_VER)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Windows 32-bit stuff: when the server crashes, create a "dump file" containing the callstack of each thread and some variables; let the user send us that crash file for analysis
typedef BOOL (WINAPI *pMiniDumpWriteDump)(
@@ -155,12 +155,12 @@ LONG WINAPI LastChanceExceptionFilter(__in struct _EXCEPTION_POINTERS * a_Except
// Handle CTRL events in windows, including console window close
BOOL CtrlHandler(DWORD fdwCtrlType)
{
- g_TERMINATE_EVENT_RAISED = true;
+ cRoot::m_TerminateEventRaised = true;
LOGD("Terminate event raised from the Windows CtrlHandler");
- if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore...
+ if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore...
{
- while (!g_SERVER_TERMINATED) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly
+ while (!g_ServerTerminated) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly
}
return TRUE;
@@ -171,10 +171,10 @@ BOOL CtrlHandler(DWORD fdwCtrlType)
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// main:
-int main( int argc, char **argv )
+int main( int argc, char **argv)
{
UNUSED(argc);
UNUSED(argv);
@@ -218,7 +218,7 @@ int main( int argc, char **argv )
#endif
#if defined(_DEBUG) && defined(_MSC_VER)
- _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+ _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
// _X: The simple built-in CRT leak finder - simply break when allocating the Nth block ({N} is listed in the leak output)
// Only useful when the leak is in the same sequence all the time
@@ -233,7 +233,7 @@ int main( int argc, char **argv )
std::signal(SIGABRT, NonCtrlHandler);
#ifdef SIGABRT_COMPAT
std::signal(SIGABRT_COMPAT, NonCtrlHandler);
- #endif // SIGABRT_COMPAT
+ #endif // SIGABRT_COMPAT
#endif
// DEBUG: test the dumpfile creation:
@@ -277,15 +277,15 @@ int main( int argc, char **argv )
try
#endif
{
- cRoot Root;
+ cRoot Root;
Root.Start();
}
#if !defined(ANDROID_NDK)
- catch( std::exception& e )
+ catch (std::exception & e)
{
- LOGERROR("Standard exception: %s", e.what() );
+ LOGERROR("Standard exception: %s", e.what());
}
- catch( ... )
+ catch (...)
{
LOGERROR("Unknown exception!");
}
@@ -296,7 +296,7 @@ int main( int argc, char **argv )
DeinitLeakFinder();
#endif
- g_SERVER_TERMINATED = true;
+ g_ServerTerminated = true;
return EXIT_SUCCESS;
}