summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore12
-rw-r--r--Android/.classpath16
-rw-r--r--Android/.project66
-rw-r--r--Android/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--Android/AndroidManifest.xml52
-rw-r--r--Android/assets/basedir/Plugins/README.txt2
-rw-r--r--Android/assets/basedir/README.txt18
-rw-r--r--Android/gen/com/mcserver/R.java78
-rw-r--r--Android/jni/Android.mk92
-rw-r--r--Android/jni/ToJava.cpp4
-rw-r--r--Android/jni/ToJava.h116
-rw-r--r--Android/jni/app-android.cpp258
-rw-r--r--Android/res/layout/main.xml114
-rw-r--r--Android/res/values/strings.xml14
-rw-r--r--Android/src/com/mcserver/MCServerInstaller.java864
-rw-r--r--COMPILING13
-rw-r--r--CryptoPP/authenc.cpp360
-rw-r--r--CryptoPP/authenc.h98
-rw-r--r--CryptoPP/ccm.cpp280
-rw-r--r--CryptoPP/ccm.h202
-rw-r--r--CryptoPP/cmac.cpp244
-rw-r--r--CryptoPP/cmac.h104
-rw-r--r--CryptoPP/eax.cpp118
-rw-r--r--CryptoPP/gcm.cpp1656
-rw-r--r--CryptoPP/gcm.h212
-rw-r--r--CryptoPP/seed.cpp208
-rw-r--r--Install/.gitignore3
-rw-r--r--Install/Lua-LICENSE.txt42
-rw-r--r--Install/LuaSQLite3-LICENSE.txt54
-rw-r--r--Install/MersenneTwister-LICENSE.txt84
-rw-r--r--Install/Zip2008.list34
-rw-r--r--Install/Zip2008_PDBs.list14
-rw-r--r--Install/banned.example.ini6
-rw-r--r--Install/groups.example.ini32
-rw-r--r--Install/settings.example.ini62
-rw-r--r--Install/users.example.ini14
-rw-r--r--Install/webadmin.example.ini10
-rw-r--r--Install/whitelist.example.ini12
-rw-r--r--MCServer/.gitignore23
-rw-r--r--MCServer/Plugins/APIDump/main.lua61
-rw-r--r--MCServer/Plugins/ChatLog/plugin.lua62
-rw-r--r--MCServer/Plugins/ChunkWorx/chunkworx_web.lua512
-rw-r--r--MCServer/Plugins/Core/Core.deproj126
-rw-r--r--MCServer/Plugins/Core/README.md23
-rw-r--r--MCServer/Plugins/Core/back.lua16
-rw-r--r--MCServer/Plugins/Core/ban-unban.lua (renamed from MCServer/Plugins/Core/ban.lua)102
-rw-r--r--MCServer/Plugins/Core/console.lua631
-rw-r--r--MCServer/Plugins/Core/functions.lua4
-rw-r--r--MCServer/Plugins/Core/give.lua (renamed from MCServer/Plugins/Core/item.lua)76
-rw-r--r--MCServer/Plugins/Core/gm.lua (renamed from MCServer/Plugins/Core/gamemode.lua)16
-rw-r--r--MCServer/Plugins/Core/gotoworld.lua15
-rw-r--r--MCServer/Plugins/Core/help.lua79
-rw-r--r--MCServer/Plugins/Core/itemrepair.lua (renamed from MCServer/Plugins/Core/oncraftingnorecipe.lua)416
-rw-r--r--MCServer/Plugins/Core/kick.lua86
-rw-r--r--MCServer/Plugins/Core/listgroups.lua14
-rw-r--r--MCServer/Plugins/Core/listworlds.lua20
-rw-r--r--MCServer/Plugins/Core/locate.lua (renamed from MCServer/Plugins/Core/coords.lua)6
-rw-r--r--MCServer/Plugins/Core/main.lua317
-rw-r--r--MCServer/Plugins/Core/me.lua15
-rw-r--r--MCServer/Plugins/Core/motd.lua192
-rw-r--r--MCServer/Plugins/Core/onbreakplaceblock.lua119
-rw-r--r--MCServer/Plugins/Core/ondeath.lua65
-rw-r--r--MCServer/Plugins/Core/onkilling.lua65
-rw-r--r--MCServer/Plugins/Core/onlogin.lua37
-rw-r--r--MCServer/Plugins/Core/onplayerbreakingblock.lua10
-rw-r--r--MCServer/Plugins/Core/onplayerplacingblock.lua63
-rw-r--r--MCServer/Plugins/Core/playerjoin.lua (renamed from MCServer/Plugins/Core/onplayerjoined.lua)8
-rw-r--r--MCServer/Plugins/Core/playerlist.lua26
-rw-r--r--MCServer/Plugins/Core/plugins.lua (renamed from MCServer/Plugins/Core/pluginlist.lua)28
-rw-r--r--MCServer/Plugins/Core/portal-worlds.lua36
-rw-r--r--MCServer/Plugins/Core/rank-groups.lua (renamed from MCServer/Plugins/Core/rank.lua)79
-rw-r--r--MCServer/Plugins/Core/regen.lua (renamed from MCServer/Plugins/Core/regeneratechunk.lua)34
-rw-r--r--MCServer/Plugins/Core/reload.lua6
-rw-r--r--MCServer/Plugins/Core/save-reload-stop.lua19
-rw-r--r--MCServer/Plugins/Core/saveall.lua5
-rw-r--r--MCServer/Plugins/Core/spawn.lua12
-rw-r--r--MCServer/Plugins/Core/stop.lua6
-rw-r--r--MCServer/Plugins/Core/teleport.lua126
-rw-r--r--MCServer/Plugins/Core/time.lua44
-rw-r--r--MCServer/Plugins/Core/top.lua20
-rw-r--r--MCServer/Plugins/Core/unban.lua20
-rw-r--r--MCServer/Plugins/Core/viewdistance.lua18
-rw-r--r--MCServer/Plugins/Core/weather.lua18
-rw-r--r--MCServer/Plugins/Core/web_chat.lua312
-rw-r--r--MCServer/Plugins/Core/web_manageplugins.lua312
-rw-r--r--MCServer/Plugins/Core/web_permissions.lua266
-rw-r--r--MCServer/Plugins/Core/web_playerlist.lua74
-rw-r--r--MCServer/Plugins/Core/web_serversettings.lua1844
-rw-r--r--MCServer/Plugins/Core/web_whitelist.lua156
-rw-r--r--MCServer/Plugins/Core/worldlimiter.lua (renamed from MCServer/Plugins/Core/onplayermoving.lua)40
-rw-r--r--MCServer/Plugins/Debuggers/Debuggers.lua1416
-rw-r--r--MCServer/Plugins/DiamondMover/DiamondMover.lua164
-rw-r--r--MCServer/Plugins/Handy/handy.lua54
-rw-r--r--MCServer/Plugins/Handy/handy_functions.lua708
-rw-r--r--MCServer/Plugins/HookNotify/HookNotify.lua808
-rw-r--r--MCServer/Plugins/MagicCarpet/objects.lua192
-rw-r--r--MCServer/Plugins/ProtectionAreas/CommandHandlers.lua644
-rw-r--r--MCServer/Plugins/ProtectionAreas/CommandState.lua242
-rw-r--r--MCServer/Plugins/ProtectionAreas/Config.lua108
-rw-r--r--MCServer/Plugins/ProtectionAreas/CurrentLng.lua152
-rw-r--r--MCServer/Plugins/ProtectionAreas/HookHandlers.lua278
-rw-r--r--MCServer/Plugins/ProtectionAreas/LICENSE.txt14
-rw-r--r--MCServer/Plugins/ProtectionAreas/PlayerAreas.lua218
-rw-r--r--MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua142
-rw-r--r--MCServer/Plugins/ProtectionAreas/Storage.lua1036
-rw-r--r--MCServer/Plugins/SquirrelChatLog.nut26
-rw-r--r--MCServer/crafting.txt784
-rw-r--r--MCServer/furnace.txt150
-rw-r--r--MCServer/groups.ini32
-rw-r--r--MCServer/hg.supp44
-rw-r--r--MCServer/items.ini1086
-rw-r--r--MCServer/monsters.ini220
-rw-r--r--MCServer/settings.example.ini (renamed from MCServer/settings.ini)62
-rw-r--r--MCServer/terrain.ini8
-rw-r--r--MCServer/users.ini44
-rw-r--r--MCServer/webadmin.example.ini (renamed from MCServer/webadmin.ini)10
-rw-r--r--MCServer/webadmin/template.html258
-rw-r--r--MCServer/webadmin/template.lua453
-rw-r--r--Nightbuild2008.cmd315
-rw-r--r--Tests/NoiseTest/NoiseTest.cpp202
-rw-r--r--Tests/NoiseTest/NoiseTest.sln40
-rw-r--r--Tests/NoiseTest/NoiseTest.vcproj516
-rw-r--r--Tools/AnvilStats/.gitignore5
-rw-r--r--Tools/AnvilStats/AnvilStats.cpp138
-rw-r--r--Tools/AnvilStats/AnvilStats.sln68
-rw-r--r--Tools/AnvilStats/AnvilStats.txt54
-rw-r--r--Tools/AnvilStats/AnvilStats.vcproj904
-rw-r--r--Tools/AnvilStats/BiomeMap.cpp344
-rw-r--r--Tools/AnvilStats/BiomeMap.h138
-rw-r--r--Tools/AnvilStats/Callback.h330
-rw-r--r--Tools/AnvilStats/ChunkExtract.cpp206
-rw-r--r--Tools/AnvilStats/ChunkExtract.h132
-rw-r--r--Tools/AnvilStats/Globals.cpp20
-rw-r--r--Tools/AnvilStats/Globals.h456
-rw-r--r--Tools/AnvilStats/HeightMap.cpp530
-rw-r--r--Tools/AnvilStats/HeightMap.h162
-rw-r--r--Tools/AnvilStats/Processor.cpp1158
-rw-r--r--Tools/AnvilStats/Processor.h154
-rw-r--r--Tools/AnvilStats/SpringStats.cpp558
-rw-r--r--Tools/AnvilStats/SpringStats.h204
-rw-r--r--Tools/AnvilStats/Statistics.cpp1046
-rw-r--r--Tools/AnvilStats/Statistics.h276
-rw-r--r--Tools/AnvilStats/Utils.cpp582
-rw-r--r--Tools/AnvilStats/Utils.h122
-rw-r--r--Tools/AnvilStats/profile_run.cmd140
-rw-r--r--Tools/BiomeVisualiser/BiomeCache.cpp666
-rw-r--r--Tools/BiomeVisualiser/BiomeCache.h192
-rw-r--r--Tools/BiomeVisualiser/BiomeRenderer.cpp294
-rw-r--r--Tools/BiomeVisualiser/BiomeRenderer.h100
-rw-r--r--Tools/BiomeVisualiser/BiomeSource.h74
-rw-r--r--Tools/BiomeVisualiser/BiomeViewWnd.cpp380
-rw-r--r--Tools/BiomeVisualiser/BiomeViewWnd.h92
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.cpp104
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.h62
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.sln46
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.vcproj966
-rw-r--r--Tools/BiomeVisualiser/GeneratorBiomeSource.h84
-rw-r--r--Tools/BiomeVisualiser/Pixmap.cpp240
-rw-r--r--Tools/BiomeVisualiser/Pixmap.h78
-rw-r--r--Tools/BiomeVisualiser/Timer.h80
-rw-r--r--Tools/BiomeVisualiser/WndProcThunk.h286
-rw-r--r--Tools/BiomeVisualiser/profile_run.cmd140
-rw-r--r--Tools/BlockZapper/BlockZapper.cpp194
-rw-r--r--Tools/BlockZapper/BlockZapper.sln68
-rw-r--r--Tools/BlockZapper/BlockZapper.txt38
-rw-r--r--Tools/BlockZapper/BlockZapper.vcproj626
-rw-r--r--Tools/BlockZapper/Globals.cpp20
-rw-r--r--Tools/BlockZapper/Globals.h28
-rw-r--r--Tools/BlockZapper/Regions.cpp334
-rw-r--r--Tools/BlockZapper/Regions.h116
-rw-r--r--Tools/BlockZapper/Zapper.cpp880
-rw-r--r--Tools/BlockZapper/Zapper.h160
-rw-r--r--Tools/MemDumpAnalysis/Globals.cpp20
-rw-r--r--Tools/MemDumpAnalysis/Globals.h70
-rw-r--r--Tools/MemDumpAnalysis/MemDumpAnalysis.cpp642
-rw-r--r--Tools/MemDumpAnalysis/MemDumpAnalysis.sln40
-rw-r--r--Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj878
-rw-r--r--Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj.user62
-rw-r--r--Tools/MemDumpAnalysis/targetver.h50
-rw-r--r--Tools/ProtoProxy/.gitignore4
-rw-r--r--Tools/ProtoProxy/Connection.cpp5067
-rw-r--r--Tools/ProtoProxy/Connection.h408
-rw-r--r--Tools/ProtoProxy/Globals.cpp20
-rw-r--r--Tools/ProtoProxy/Globals.h440
-rw-r--r--Tools/ProtoProxy/ProtoProxy.cpp64
-rw-r--r--Tools/ProtoProxy/ProtoProxy.sln58
-rw-r--r--Tools/ProtoProxy/ProtoProxy.txt62
-rw-r--r--Tools/ProtoProxy/ProtoProxy.vcproj534
-rw-r--r--Tools/ProtoProxy/Server.cpp164
-rw-r--r--Tools/ProtoProxy/Server.h76
-rw-r--r--Tools/ToLuaDoxy/Globals.cpp20
-rw-r--r--Tools/ToLuaDoxy/Globals.h202
-rw-r--r--Tools/ToLuaDoxy/ToLuaDoxy.cpp444
-rw-r--r--Tools/ToLuaDoxy/ToLuaDoxy.sln40
-rw-r--r--Tools/ToLuaDoxy/ToLuaDoxy.vcproj442
-rw-r--r--UpdateVersions.cmd76
-rw-r--r--VC2008/.gitignore5
-rw-r--r--VC2008/CryptoPP.vcproj10202
-rw-r--r--VC2008/GenerateBindings.cmd4
-rw-r--r--VC2008/JsonCpp.vcproj496
-rw-r--r--VC2008/Lua.vcproj874
-rw-r--r--VC2008/MCServer.rc34
-rw-r--r--VC2008/MCServer.sln186
-rw-r--r--VC2008/MCServer.vcproj5264
-rw-r--r--VC2008/Squirrel3.vcproj768
-rw-r--r--VC2008/ToLua.vcproj496
-rw-r--r--VC2008/WebServer.vcproj608
-rw-r--r--VC2008/expat.vcproj454
-rw-r--r--VC2008/icon_128.pngbin0 -> 26758 bytes
-rw-r--r--VC2008/icon_256.pngbin0 -> 66137 bytes
-rw-r--r--VC2008/profile_run.cmd146
-rw-r--r--VC2008/resource_MCServer.h10
-rw-r--r--VC2008/zlib.vcproj648
-rw-r--r--WebServer/Events.h36
-rw-r--r--WebServer/Globals.h30
-rw-r--r--WebServer/Socket.h254
-rw-r--r--WebServer/StdHelpers.h128
-rw-r--r--WebServer/Tracer.h226
-rw-r--r--WebServer/UrlHelper.h84
-rw-r--r--WebServer/WebServer.h216
-rw-r--r--WebServer/base64.h8
-rw-r--r--clean.bat46
-rw-r--r--cloc-exclude.txt52
-rw-r--r--docs/API class inheritance - blockentities.gv28
-rw-r--r--docs/API class inheritance - entities.gv86
-rw-r--r--docs/Object ownership.gv56
-rw-r--r--docs/_files.txt14
-rw-r--r--nbt examples/single chunk NBT data.txt142
-rw-r--r--nbt examples/tile entities.txt216
-rw-r--r--source/AllToLua.bat6
-rw-r--r--source/Bindings.cpp730
-rw-r--r--source/Bindings.h2
-rw-r--r--source/BlockArea.cpp4248
-rw-r--r--source/BlockArea.h620
-rw-r--r--source/BlockEntities/BlockEntityWithItems.h172
-rw-r--r--source/BlockEntities/DispenserEntity.cpp450
-rw-r--r--source/BlockEntities/DispenserEntity.h82
-rw-r--r--source/BlockEntities/DropSpenserEntity.cpp490
-rw-r--r--source/BlockEntities/DropSpenserEntity.h178
-rw-r--r--source/BlockEntities/DropperEntity.cpp84
-rw-r--r--source/BlockEntities/DropperEntity.h98
-rw-r--r--source/BlockEntities/HopperEntity.cpp1046
-rw-r--r--source/BlockEntities/HopperEntity.h204
-rw-r--r--source/BlockEntities/JukeboxEntity.cpp246
-rw-r--r--source/BlockEntities/JukeboxEntity.h86
-rw-r--r--source/BlockEntities/NoteEntity.cpp318
-rw-r--r--source/BlockEntities/NoteEntity.h104
-rw-r--r--source/Blocks/BlockBed.cpp170
-rw-r--r--source/Blocks/BlockBed.h146
-rw-r--r--source/Blocks/BlockBrewingStand.h64
-rw-r--r--source/Blocks/BlockCactus.h176
-rw-r--r--source/Blocks/BlockCauldron.h118
-rw-r--r--source/Blocks/BlockChest.h444
-rw-r--r--source/Blocks/BlockCloth.h68
-rw-r--r--source/Blocks/BlockCobWeb.h60
-rw-r--r--source/Blocks/BlockCrops.h216
-rw-r--r--source/Blocks/BlockDeadBush.h94
-rw-r--r--source/Blocks/BlockDirt.h176
-rw-r--r--source/Blocks/BlockDoor.cpp176
-rw-r--r--source/Blocks/BlockDoor.h210
-rw-r--r--source/Blocks/BlockDropSpenser.h78
-rw-r--r--source/Blocks/BlockEnderchest.h56
-rw-r--r--source/Blocks/BlockEntity.h62
-rw-r--r--source/Blocks/BlockFarmland.h198
-rw-r--r--source/Blocks/BlockFenceGate.h120
-rw-r--r--source/Blocks/BlockFire.h84
-rw-r--r--source/Blocks/BlockFlower.h106
-rw-r--r--source/Blocks/BlockFlowerPot.h210
-rw-r--r--source/Blocks/BlockFluid.h100
-rw-r--r--source/Blocks/BlockFurnace.h94
-rw-r--r--source/Blocks/BlockGlass.h52
-rw-r--r--source/Blocks/BlockGlowstone.h60
-rw-r--r--source/Blocks/BlockGravel.h54
-rw-r--r--source/Blocks/BlockHandler.cpp906
-rw-r--r--source/Blocks/BlockHandler.h316
-rw-r--r--source/Blocks/BlockHopper.h92
-rw-r--r--source/Blocks/BlockIce.h74
-rw-r--r--source/Blocks/BlockLadder.h230
-rw-r--r--source/Blocks/BlockLeaves.h368
-rw-r--r--source/Blocks/BlockLever.cpp96
-rw-r--r--source/Blocks/BlockLever.h122
-rw-r--r--source/Blocks/BlockMelon.h70
-rw-r--r--source/Blocks/BlockMushroom.h142
-rw-r--r--source/Blocks/BlockMycelium.h54
-rw-r--r--source/Blocks/BlockNote.h26
-rw-r--r--source/Blocks/BlockOre.h160
-rw-r--r--source/Blocks/BlockPiston.cpp138
-rw-r--r--source/Blocks/BlockPiston.h56
-rw-r--r--source/Blocks/BlockRail.h842
-rw-r--r--source/Blocks/BlockRedstone.cpp54
-rw-r--r--source/Blocks/BlockRedstone.h92
-rw-r--r--source/Blocks/BlockRedstoneRepeater.cpp94
-rw-r--r--source/Blocks/BlockRedstoneRepeater.h120
-rw-r--r--source/Blocks/BlockRedstoneTorch.h72
-rw-r--r--source/Blocks/BlockSand.h56
-rw-r--r--source/Blocks/BlockSapling.h138
-rw-r--r--source/Blocks/BlockSign.h157
-rw-r--r--source/Blocks/BlockSlab.h140
-rw-r--r--source/Blocks/BlockSnow.h104
-rw-r--r--source/Blocks/BlockStairs.h306
-rw-r--r--source/Blocks/BlockStems.h116
-rw-r--r--source/Blocks/BlockStone.h58
-rw-r--r--source/Blocks/BlockSugarcane.h192
-rw-r--r--source/Blocks/BlockTallGrass.h102
-rw-r--r--source/Blocks/BlockTorch.h518
-rw-r--r--source/Blocks/BlockVine.h400
-rw-r--r--source/Blocks/BlockWood.h54
-rw-r--r--source/Blocks/BlockWorkbench.h86
-rw-r--r--source/ByteBuffer.cpp1322
-rw-r--r--source/ByteBuffer.h242
-rw-r--r--source/ClientHandle.cpp34
-rw-r--r--source/ClientHandle.h9
-rw-r--r--source/CommandOutput.cpp142
-rw-r--r--source/CommandOutput.h164
-rw-r--r--source/Defines.h4
-rw-r--r--source/Enchantments.cpp596
-rw-r--r--source/Enchantments.h228
-rw-r--r--source/FallingBlock.cpp206
-rw-r--r--source/FallingBlock.h90
-rw-r--r--source/FastRandom.cpp348
-rw-r--r--source/FastRandom.h114
-rw-r--r--source/Generating/Caves.cpp1940
-rw-r--r--source/Generating/Caves.h204
-rw-r--r--source/Generating/ChunkDesc.cpp1156
-rw-r--r--source/Generating/ComposableGenerator.cpp1048
-rw-r--r--source/Generating/ComposableGenerator.h350
-rw-r--r--source/Generating/DistortedHeightmap.cpp838
-rw-r--r--source/Generating/DistortedHeightmap.h204
-rw-r--r--source/Generating/EndGen.cpp434
-rw-r--r--source/Generating/EndGen.h138
-rw-r--r--source/Generating/MineShafts.cpp2846
-rw-r--r--source/Generating/MineShafts.h122
-rw-r--r--source/Generating/Noise3DGenerator.cpp1162
-rw-r--r--source/Generating/Noise3DGenerator.h212
-rw-r--r--source/Generating/Ravines.cpp1062
-rw-r--r--source/Generating/Ravines.h92
-rw-r--r--source/ItemGrid.cpp1324
-rw-r--r--source/ItemGrid.h382
-rw-r--r--source/Items/ItemBed.h112
-rw-r--r--source/Items/ItemBrewingStand.h82
-rw-r--r--source/Items/ItemBucket.h320
-rw-r--r--source/Items/ItemCauldron.h82
-rw-r--r--source/Items/ItemCloth.h46
-rw-r--r--source/Items/ItemDoor.h90
-rw-r--r--source/Items/ItemDye.h88
-rw-r--r--source/Items/ItemFlowerPot.h82
-rw-r--r--source/Items/ItemFood.h112
-rw-r--r--source/Items/ItemHandler.cpp997
-rw-r--r--source/Items/ItemHandler.h191
-rw-r--r--source/Items/ItemHoe.h60
-rw-r--r--source/Items/ItemLeaves.h82
-rw-r--r--source/Items/ItemLighter.h112
-rw-r--r--source/Items/ItemMinecart.h160
-rw-r--r--source/Items/ItemPickaxe.h150
-rw-r--r--source/Items/ItemRedstoneDust.h76
-rw-r--r--source/Items/ItemRedstoneRepeater.h80
-rw-r--r--source/Items/ItemSapling.h84
-rw-r--r--source/Items/ItemSeeds.h130
-rw-r--r--source/Items/ItemShears.h126
-rw-r--r--source/Items/ItemShovel.h80
-rw-r--r--source/Items/ItemSign.h102
-rw-r--r--source/Items/ItemSlab.h104
-rw-r--r--source/Items/ItemSpawnEgg.h104
-rw-r--r--source/Items/ItemSugarcane.h78
-rw-r--r--source/Items/ItemSword.h40
-rw-r--r--source/Items/ItemWood.h44
-rw-r--r--source/LinearInterpolation.cpp502
-rw-r--r--source/LinearInterpolation.h120
-rw-r--r--source/LinearUpscale.h488
-rw-r--r--source/LuaScript.cpp278
-rw-r--r--source/LuaScript.h63
-rw-r--r--source/LuaWindow.cpp350
-rw-r--r--source/LuaWindow.h192
-rw-r--r--source/ManualBindings.cpp61
-rw-r--r--source/Minecart.cpp320
-rw-r--r--source/Minecart.h234
-rw-r--r--source/Mobs/Bat.h54
-rw-r--r--source/Mobs/Blaze.cpp54
-rw-r--r--source/Mobs/Blaze.h50
-rw-r--r--source/Mobs/Magmacube.cpp54
-rw-r--r--source/Mobs/Magmacube.h62
-rw-r--r--source/Mobs/Mooshroom.cpp66
-rw-r--r--source/Mobs/Mooshroom.h50
-rw-r--r--source/Mobs/Ocelot.h54
-rw-r--r--source/Mobs/Villager.cpp34
-rw-r--r--source/Mobs/Villager.h46
-rw-r--r--source/Mobs/Witch.cpp64
-rw-r--r--source/Mobs/Witch.h50
-rw-r--r--source/OSSupport/GZipFile.cpp214
-rw-r--r--source/OSSupport/GZipFile.h104
-rw-r--r--source/OSSupport/ListenThread.cpp462
-rw-r--r--source/OSSupport/ListenThread.h166
-rw-r--r--source/Player.cpp2749
-rw-r--r--source/Player.h64
-rw-r--r--source/Plugin_NewLua.cpp4
-rw-r--r--source/Plugin_NewLua.h4
-rw-r--r--source/Plugin_Squirrel.cpp818
-rw-r--r--source/Plugin_Squirrel.h138
-rw-r--r--source/ProbabDistrib.cpp284
-rw-r--r--source/ProbabDistrib.h148
-rw-r--r--source/Protocol/ChunkDataSerializer.cpp352
-rw-r--r--source/Protocol/ChunkDataSerializer.h96
-rw-r--r--source/Protocol/Protocol.h385
-rw-r--r--source/Protocol/Protocol125.cpp3285
-rw-r--r--source/Protocol/Protocol125.h305
-rw-r--r--source/Protocol/Protocol132.cpp1804
-rw-r--r--source/Protocol/Protocol132.h200
-rw-r--r--source/Protocol/Protocol14x.cpp506
-rw-r--r--source/Protocol/Protocol14x.h126
-rw-r--r--source/Protocol/Protocol15x.cpp274
-rw-r--r--source/Protocol/Protocol15x.h76
-rw-r--r--source/Protocol/Protocol16x.cpp507
-rw-r--r--source/Protocol/Protocol16x.h147
-rw-r--r--source/Protocol/ProtocolRecognizer.cpp1552
-rw-r--r--source/Protocol/ProtocolRecognizer.h261
-rw-r--r--source/RCONServer.cpp664
-rw-r--r--source/RCONServer.h218
-rw-r--r--source/SQLite/urls.txt16
-rw-r--r--source/Server.h2
-rw-r--r--source/Simulator/DelayedFluidSimulator.cpp316
-rw-r--r--source/Simulator/DelayedFluidSimulator.h164
-rw-r--r--source/Simulator/FloodyFluidSimulator.cpp668
-rw-r--r--source/Simulator/FloodyFluidSimulator.h106
-rw-r--r--source/Simulator/NoopFluidSimulator.h72
-rw-r--r--source/Simulator/VaporizeFluidSimulator.cpp106
-rw-r--r--source/Simulator/VaporizeFluidSimulator.h68
-rw-r--r--source/SquirrelCommandBinder.cpp236
-rw-r--r--source/SquirrelCommandBinder.h102
-rw-r--r--source/TNTEntity.cpp144
-rw-r--r--source/TNTEntity.h68
-rw-r--r--source/UI/SlotArea.cpp1630
-rw-r--r--source/UI/SlotArea.h606
-rw-r--r--source/WebAdmin.cpp287
-rw-r--r--source/WebAdmin.h91
-rw-r--r--source/WebPlugin.cpp2
-rw-r--r--source/WebPlugin.h9
-rw-r--r--source/World.h11
-rw-r--r--source/WorldStorage/NBTChunkSerializer.cpp918
-rw-r--r--source/WorldStorage/NBTChunkSerializer.h220
-rw-r--r--source/XMLParser.h1402
-rw-r--r--source/squirrelbindings/SquirrelArray.h112
-rw-r--r--source/squirrelbindings/SquirrelBaseClass.h132
-rw-r--r--source/squirrelbindings/SquirrelBindings.cpp390
-rw-r--r--source/squirrelbindings/SquirrelBindings.h64
-rw-r--r--source/squirrelbindings/SquirrelFunctions.cpp188
-rw-r--r--source/squirrelbindings/SquirrelFunctions.h56
-rw-r--r--source/squirrelbindings/SquirrelObject.h110
-rw-r--r--source/virtual_method_hooks.lua1012
-rw-r--r--squirrel_3_0_1_stable/sqstdlib/sqstdlib.dsp262
-rw-r--r--squirrel_3_0_1_stable/squirrel.dsw154
-rw-r--r--squirrel_3_0_1_stable/squirrel/squirrel.dsp604
-rw-r--r--tolua++-1.0.93/src/bin/lua/compat-5.1.lua114
-rw-r--r--tolua++-1.0.93/src/bin/lua/custom.lua90
-rw-r--r--tolua++-1.0.93/win32/tolualib/tolualib.vcproj394
-rw-r--r--tolua++-1.0.93/win32/tolualib/tolualib.vcproj.LAPTOPF.Kevin.user130
-rw-r--r--tolua++-1.0.93/win32/tolualib/tolualib.vcxproj158
-rw-r--r--tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.filters76
-rw-r--r--tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.user4
-rw-r--r--tolua++-1.0.93/win32/vc7/clean.bat30
-rw-r--r--tolua++-1.0.93/win32/vc7/toluapp.sln96
-rw-r--r--tolua++-1.0.93/win32/vc7/toluapp.vcproj878
-rw-r--r--tolua++-1.0.93/win32/vc7/toluapp.vcproj.LAPTOPF.Kevin.user242
-rw-r--r--tolua++-1.0.93/win32/vc7/toluapp.vcxproj350
-rw-r--r--tolua++-1.0.93/win32/vc7/toluapp.vcxproj.filters88
-rw-r--r--tolua++-1.0.93/win32/vc7/toluapp.vcxproj.user4
465 files changed, 71176 insertions, 69356 deletions
diff --git a/.gitignore b/.gitignore
index 567609b12..b8a60a580 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,13 @@
build/
+MCServer/MCServer
+ChunkWorxSave.ini
+doxy/
+Profiling
+Symbols
+cloc-ignored.txt
+cloc.xml
+cloc.xsl
+*.ncb
+*.user
+*.suo
+/EveryNight.cmd
diff --git a/Android/.classpath b/Android/.classpath
index a4f1e4054..a4763d1ee 100644
--- a/Android/.classpath
+++ b/Android/.classpath
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
diff --git a/Android/.project b/Android/.project
index 34dd17184..ad960717b 100644
--- a/Android/.project
+++ b/Android/.project
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>MCServer</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>MCServer</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/Android/.settings/org.eclipse.jdt.core.prefs b/Android/.settings/org.eclipse.jdt.core.prefs
index da5d06089..f77b31c2d 100644
--- a/Android/.settings/org.eclipse.jdt.core.prefs
+++ b/Android/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.source=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/Android/AndroidManifest.xml b/Android/AndroidManifest.xml
index 1de7d179a..0a2cc8380 100644
--- a/Android/AndroidManifest.xml
+++ b/Android/AndroidManifest.xml
@@ -1,27 +1,27 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.mcserver"
- android:versionCode="3"
- android:versionName="r1375" >
-
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.READ_LOGS"/>
-
- <uses-sdk android:minSdkVersion="10" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".MCServerActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.mcserver"
+ android:versionCode="3"
+ android:versionName="r1375" >
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.READ_LOGS"/>
+
+ <uses-sdk android:minSdkVersion="10" />
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name" >
+ <activity
+ android:name=".MCServerActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
</manifest> \ No newline at end of file
diff --git a/Android/assets/basedir/Plugins/README.txt b/Android/assets/basedir/Plugins/README.txt
index 06f28d0b6..1c8259eda 100644
--- a/Android/assets/basedir/Plugins/README.txt
+++ b/Android/assets/basedir/Plugins/README.txt
@@ -1,2 +1,2 @@
-Put all pre-packaged plugins in here such as Core.
+Put all pre-packaged plugins in here such as Core.
The user will be able to install each plugin in here separately. \ No newline at end of file
diff --git a/Android/assets/basedir/README.txt b/Android/assets/basedir/README.txt
index 082196c29..784d10fc7 100644
--- a/Android/assets/basedir/README.txt
+++ b/Android/assets/basedir/README.txt
@@ -1,10 +1,10 @@
-Put all pre-packaged settings/preferences and license files in here.
-Such as:
-
-settings.example.ini
-groups.example.ini
-users.example.ini
-webadmin.example.ini
-Lua-LICENSE.txt
-MersenneTwister-LICENSE.txt
+Put all pre-packaged settings/preferences and license files in here.
+Such as:
+
+settings.example.ini
+groups.example.ini
+users.example.ini
+webadmin.example.ini
+Lua-LICENSE.txt
+MersenneTwister-LICENSE.txt
etc.etc \ No newline at end of file
diff --git a/Android/gen/com/mcserver/R.java b/Android/gen/com/mcserver/R.java
index dd996a43f..cbb9e653a 100644
--- a/Android/gen/com/mcserver/R.java
+++ b/Android/gen/com/mcserver/R.java
@@ -1,39 +1,39 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package com.mcserver;
-
-public final class R {
- public static final class attr {
- }
- public static final class drawable {
- public static final int ic_launcher=0x7f020000;
- }
- public static final class id {
- public static final int configure_server=0x7f050003;
- public static final int ip_address=0x7f050005;
- public static final int listView1=0x7f050006;
- public static final int server_status_text=0x7f050004;
- public static final int start_server=0x7f050002;
- public static final int stop_server=0x7f050001;
- public static final int textView2=0x7f050000;
- }
- public static final class layout {
- public static final int list_item=0x7f030000;
- public static final int main=0x7f030001;
- }
- public static final class string {
- public static final int app_name=0x7f040001;
- public static final int configure=0x7f040007;
- public static final int hello=0x7f040000;
- public static final int mcserver_is_not_running=0x7f040005;
- public static final int mcserver_is_running=0x7f040004;
- public static final int start=0x7f040002;
- public static final int stop=0x7f040003;
- public static final int your_ip=0x7f040006;
- }
-}
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.mcserver;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int ic_launcher=0x7f020000;
+ }
+ public static final class id {
+ public static final int configure_server=0x7f050003;
+ public static final int ip_address=0x7f050005;
+ public static final int listView1=0x7f050006;
+ public static final int server_status_text=0x7f050004;
+ public static final int start_server=0x7f050002;
+ public static final int stop_server=0x7f050001;
+ public static final int textView2=0x7f050000;
+ }
+ public static final class layout {
+ public static final int list_item=0x7f030000;
+ public static final int main=0x7f030001;
+ }
+ public static final class string {
+ public static final int app_name=0x7f040001;
+ public static final int configure=0x7f040007;
+ public static final int hello=0x7f040000;
+ public static final int mcserver_is_not_running=0x7f040005;
+ public static final int mcserver_is_running=0x7f040004;
+ public static final int start=0x7f040002;
+ public static final int stop=0x7f040003;
+ public static final int your_ip=0x7f040006;
+ }
+}
diff --git a/Android/jni/Android.mk b/Android/jni/Android.mk
index 764e57ee8..23488e359 100644
--- a/Android/jni/Android.mk
+++ b/Android/jni/Android.mk
@@ -1,46 +1,46 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := mcserver
-
-
-
-LOCAL_SRC_FILES := $(shell find ../CryptoPP ../lua-5.1.4 ../jsoncpp-src-0.5.0 ../zlib-1.2.7 ../source ../squirrel_3_0_1_stable ../tolua++-1.0.93 ../iniFile ../WebServer ../expat '(' -name '*.cpp' -o -name '*.c' ')')
-LOCAL_SRC_FILES := $(filter-out %SquirrelFunctions.cpp %SquirrelBindings.cpp %cPlugin_Squirrel.cpp %cSquirrelCommandBinder.cpp %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(LOCAL_SRC_FILES))
-LOCAL_SRC_FILES := $(patsubst %.cpp,../%.cpp,$(LOCAL_SRC_FILES))
-LOCAL_SRC_FILES := $(patsubst %.c,../%.c,$(LOCAL_SRC_FILES))
-LOCAL_SRC_FILES += app-android.cpp ToJava.cpp
-
-LOCAL_CFLAGS := -DANDROID_NDK \
- -O3 \
- -funroll-loops \
- -mfloat-abi=softfp -mfpu=neon \
- -fexceptions \
-
-
-LOCAL_STATIC_LIBRARIES := cpufeatures
-
-LOCAL_C_INCLUDES := ../source \
- ../source/md5 \
- ../WebServer \
- ../source/packets \
- ../source/items \
- ../source/blocks \
- ../tolua++-1.0.93/src/lib \
- ../lua-5.1.4/src \
- ../zlib-1.2.7 \
- ../iniFile \
- ../tolua++-1.0.93/include \
- ../jsoncpp-src-0.5.0/include \
- ../jsoncpp-src-0.5.0/src/lib_json \
- ../squirrel_3_0_1_stable/include \
- ../squirrel_3_0_1_stable \
- ../squirrel_3_0_1_stable/sqrat \
- ../expat/ \
- .. \
-
-
-LOCAL_LDLIBS := -ldl -llog
-
-include $(BUILD_SHARED_LIBRARY)
-$(call import-module,cpufeatures)
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := mcserver
+
+
+
+LOCAL_SRC_FILES := $(shell find ../CryptoPP ../lua-5.1.4 ../jsoncpp-src-0.5.0 ../zlib-1.2.7 ../source ../squirrel_3_0_1_stable ../tolua++-1.0.93 ../iniFile ../WebServer ../expat '(' -name '*.cpp' -o -name '*.c' ')')
+LOCAL_SRC_FILES := $(filter-out %SquirrelFunctions.cpp %SquirrelBindings.cpp %cPlugin_Squirrel.cpp %cSquirrelCommandBinder.cpp %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(LOCAL_SRC_FILES))
+LOCAL_SRC_FILES := $(patsubst %.cpp,../%.cpp,$(LOCAL_SRC_FILES))
+LOCAL_SRC_FILES := $(patsubst %.c,../%.c,$(LOCAL_SRC_FILES))
+LOCAL_SRC_FILES += app-android.cpp ToJava.cpp
+
+LOCAL_CFLAGS := -DANDROID_NDK \
+ -O3 \
+ -funroll-loops \
+ -mfloat-abi=softfp -mfpu=neon \
+ -fexceptions \
+
+
+LOCAL_STATIC_LIBRARIES := cpufeatures
+
+LOCAL_C_INCLUDES := ../source \
+ ../source/md5 \
+ ../WebServer \
+ ../source/packets \
+ ../source/items \
+ ../source/blocks \
+ ../tolua++-1.0.93/src/lib \
+ ../lua-5.1.4/src \
+ ../zlib-1.2.7 \
+ ../iniFile \
+ ../tolua++-1.0.93/include \
+ ../jsoncpp-src-0.5.0/include \
+ ../jsoncpp-src-0.5.0/src/lib_json \
+ ../squirrel_3_0_1_stable/include \
+ ../squirrel_3_0_1_stable \
+ ../squirrel_3_0_1_stable/sqrat \
+ ../expat/ \
+ .. \
+
+
+LOCAL_LDLIBS := -ldl -llog
+
+include $(BUILD_SHARED_LIBRARY)
+$(call import-module,cpufeatures)
diff --git a/Android/jni/ToJava.cpp b/Android/jni/ToJava.cpp
index 10d4e84a0..8db22dd1d 100644
--- a/Android/jni/ToJava.cpp
+++ b/Android/jni/ToJava.cpp
@@ -1,3 +1,3 @@
-#include "Globals.h"
-
+#include "Globals.h"
+
#include "ToJava.h" \ No newline at end of file
diff --git a/Android/jni/ToJava.h b/Android/jni/ToJava.h
index bc10f01e3..11979c847 100644
--- a/Android/jni/ToJava.h
+++ b/Android/jni/ToJava.h
@@ -1,59 +1,59 @@
-#pragma once
-
-#include <jni.h>
-#include <android/log.h>
-extern JNIEnv* g_CurrentJNIEnv;
-extern JavaVM* g_JavaVM;
-extern jobject g_JavaThread;
-//extern jobject g_JavaActivity;
-
-//__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
-
-static void CallJavaFunction_Void_String( jobject a_Object, const std::string & a_FunctionName, const std::string & a_StringParam )
-{
- JNIEnv * oldEnv = g_CurrentJNIEnv;
- int status = g_JavaVM->AttachCurrentThread(&g_CurrentJNIEnv, NULL);
- __android_log_print(ANDROID_LOG_ERROR,"MCServer", "STATUS: %i old: %p new: %p", status, oldEnv, g_CurrentJNIEnv );
- jstring str = g_CurrentJNIEnv->NewStringUTF( a_StringParam.c_str() );
-
-
- //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "JNIEnv: %i Object: %i", g_CurrentJNIEnv, a_Object );
- jclass cls = g_CurrentJNIEnv->GetObjectClass( a_Object );
- //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jclass: %i", cls );
- jmethodID mid = g_CurrentJNIEnv->GetMethodID( cls, a_FunctionName.c_str(), "(Ljava/lang/String;)V"); // void a_FunctionName( String )
- //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jmethodID: %i", mid );
- if (mid != 0)
- {
-
- __android_log_print(ANDROID_LOG_ERROR,"MCServer", "Going to call right NOW! %s", a_FunctionName.c_str() );
- g_CurrentJNIEnv->CallVoidMethod( a_Object, mid, str );
- }
- else
- {
- __android_log_print(ANDROID_LOG_ERROR,"MCServer", "It was 0, derp" );
- }
-
- if( oldEnv != g_CurrentJNIEnv )
- {
- g_JavaVM->DetachCurrentThread();
- }
-}
-
-
-static void CallJavaFunction_Void_Void( jobject a_Object, const std::string & a_FunctionName )
-{
- //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "JNIEnv: %i Object: %i", g_CurrentJNIEnv, a_Object );
- jclass cls = g_CurrentJNIEnv->GetObjectClass( a_Object );
- //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jclass: %i", cls );
- jmethodID mid = g_CurrentJNIEnv->GetMethodID( cls, a_FunctionName.c_str(), "()V"); // void a_FunctionName( String )
- //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jmethodID: %i", mid );
- if (mid != 0)
- {
- //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "Going to call right NOW! %s", a_FunctionName.c_str() );
- g_CurrentJNIEnv->CallVoidMethod( a_Object, mid );
- }
- else
- {
- __android_log_print(ANDROID_LOG_ERROR,"MCServer", "It was 0, derp" );
- }
+#pragma once
+
+#include <jni.h>
+#include <android/log.h>
+extern JNIEnv* g_CurrentJNIEnv;
+extern JavaVM* g_JavaVM;
+extern jobject g_JavaThread;
+//extern jobject g_JavaActivity;
+
+//__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
+
+static void CallJavaFunction_Void_String( jobject a_Object, const std::string & a_FunctionName, const std::string & a_StringParam )
+{
+ JNIEnv * oldEnv = g_CurrentJNIEnv;
+ int status = g_JavaVM->AttachCurrentThread(&g_CurrentJNIEnv, NULL);
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "STATUS: %i old: %p new: %p", status, oldEnv, g_CurrentJNIEnv );
+ jstring str = g_CurrentJNIEnv->NewStringUTF( a_StringParam.c_str() );
+
+
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "JNIEnv: %i Object: %i", g_CurrentJNIEnv, a_Object );
+ jclass cls = g_CurrentJNIEnv->GetObjectClass( a_Object );
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jclass: %i", cls );
+ jmethodID mid = g_CurrentJNIEnv->GetMethodID( cls, a_FunctionName.c_str(), "(Ljava/lang/String;)V"); // void a_FunctionName( String )
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jmethodID: %i", mid );
+ if (mid != 0)
+ {
+
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "Going to call right NOW! %s", a_FunctionName.c_str() );
+ g_CurrentJNIEnv->CallVoidMethod( a_Object, mid, str );
+ }
+ else
+ {
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "It was 0, derp" );
+ }
+
+ if( oldEnv != g_CurrentJNIEnv )
+ {
+ g_JavaVM->DetachCurrentThread();
+ }
+}
+
+
+static void CallJavaFunction_Void_Void( jobject a_Object, const std::string & a_FunctionName )
+{
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "JNIEnv: %i Object: %i", g_CurrentJNIEnv, a_Object );
+ jclass cls = g_CurrentJNIEnv->GetObjectClass( a_Object );
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jclass: %i", cls );
+ jmethodID mid = g_CurrentJNIEnv->GetMethodID( cls, a_FunctionName.c_str(), "()V"); // void a_FunctionName( String )
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jmethodID: %i", mid );
+ if (mid != 0)
+ {
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "Going to call right NOW! %s", a_FunctionName.c_str() );
+ g_CurrentJNIEnv->CallVoidMethod( a_Object, mid );
+ }
+ else
+ {
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "It was 0, derp" );
+ }
} \ No newline at end of file
diff --git a/Android/jni/app-android.cpp b/Android/jni/app-android.cpp
index b34207344..197df29c4 100644
--- a/Android/jni/app-android.cpp
+++ b/Android/jni/app-android.cpp
@@ -1,130 +1,130 @@
-#include "Globals.h"
-
-#include <jni.h>
-#include <sys/time.h>
-#include <time.h>
-#include <stdint.h>
-
-#include <stdlib.h>
-#include <math.h>
-#include <float.h>
-#include <assert.h>
-
-#include "OSSupport/CriticalSection.h"
-#include "OSSupport/MakeDir.h"
-#include "ToJava.h"
-
-#include "Root.h"
-#include "WebAdmin.h"
-
-#include <android/log.h>
-
-#ifdef _WIN32 // For IntelliSense parsing
-typedef void jobject;
-typedef int jint;
-typedef bool jboolean;
-typedef void JavaVM;
-typedef void JNIEnv;
-#endif
-
-cCriticalSection g_CriticalSection;
-
-JNIEnv* g_CurrentJNIEnv = 0;
-jobject g_JavaThread = 0;
-JavaVM* g_JavaVM = 0;
-//jobject g_JavaActivity = 0;
-
-cRoot * pRoot = NULL;
-
-
-class cMainThread :
- public cIsThread
-{
-public:
- cMainThread() :
- cIsThread("cMainThread")
- {
- //Start();
- __android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "cMainThread");
- }
-
- void Stop(void)
- {
- m_ShouldTerminate = true;
- Wait();
- }
-
-protected:
-
- virtual void Execute(void) override
- {
- __android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "Execute");
- pRoot = new cRoot();
- pRoot->Start();
- delete pRoot;
- }
-
-} ;
-
-cMainThread * pMainThread = NULL;
-
-jint JNI_OnLoad(JavaVM* vm, void* reserved)
-{
- //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "JNI_OnLoad JNI_OnLoad JNI_OnLoad JNI_OnLoad");
- g_JavaVM = vm;
- return JNI_VERSION_1_4;
-}
-
-/* Called when program/activity is created */
-extern "C" void Java_com_mcserver_MCServerActivity_NativeOnCreate( JNIEnv* env, jobject thiz )
-{
- g_CriticalSection.Lock();
- g_CurrentJNIEnv = env;
- g_JavaThread = thiz;
- //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "Logging from C++!");
- g_CriticalSection.Unlock();
-
- mkdir("/sdcard/mcserver", S_IRWXU | S_IRWXG | S_IRWXO);
-
- pRoot = new cRoot();
- pRoot->Start();
- delete pRoot; pRoot = NULL;
-}
-
-
-
-
-
-extern "C" void Java_com_mcserver_MCServerActivity_NativeCleanUp( JNIEnv* env, jobject thiz )
-{
- g_CriticalSection.Lock();
- g_CurrentJNIEnv = env;
- g_JavaThread = thiz;
- g_CriticalSection.Unlock();
-
- __android_log_print(ANDROID_LOG_ERROR,"MCServer", "pRoot: %p", pRoot);
- if( pRoot != NULL )
- {
- pRoot->ExecuteConsoleCommand("stop");
- }
-}
-
-
-
-
-extern "C" jboolean Java_com_mcserver_MCServerActivity_NativeIsServerRunning( JNIEnv* env, jobject thiz )
-{
- return pRoot != NULL;
-}
-
-
-
-
-extern "C" jint Java_com_mcserver_MCServerActivity_NativeGetWebAdminPort( JNIEnv* env, jobject thiz )
-{
- if( pRoot != NULL && pRoot->GetWebAdmin() != NULL )
- {
- return pRoot->GetWebAdmin()->GetPort();
- }
- return 0;
+#include "Globals.h"
+
+#include <jni.h>
+#include <sys/time.h>
+#include <time.h>
+#include <stdint.h>
+
+#include <stdlib.h>
+#include <math.h>
+#include <float.h>
+#include <assert.h>
+
+#include "OSSupport/CriticalSection.h"
+#include "OSSupport/MakeDir.h"
+#include "ToJava.h"
+
+#include "Root.h"
+#include "WebAdmin.h"
+
+#include <android/log.h>
+
+#ifdef _WIN32 // For IntelliSense parsing
+typedef void jobject;
+typedef int jint;
+typedef bool jboolean;
+typedef void JavaVM;
+typedef void JNIEnv;
+#endif
+
+cCriticalSection g_CriticalSection;
+
+JNIEnv* g_CurrentJNIEnv = 0;
+jobject g_JavaThread = 0;
+JavaVM* g_JavaVM = 0;
+//jobject g_JavaActivity = 0;
+
+cRoot * pRoot = NULL;
+
+
+class cMainThread :
+ public cIsThread
+{
+public:
+ cMainThread() :
+ cIsThread("cMainThread")
+ {
+ //Start();
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "cMainThread");
+ }
+
+ void Stop(void)
+ {
+ m_ShouldTerminate = true;
+ Wait();
+ }
+
+protected:
+
+ virtual void Execute(void) override
+ {
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "Execute");
+ pRoot = new cRoot();
+ pRoot->Start();
+ delete pRoot;
+ }
+
+} ;
+
+cMainThread * pMainThread = NULL;
+
+jint JNI_OnLoad(JavaVM* vm, void* reserved)
+{
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "JNI_OnLoad JNI_OnLoad JNI_OnLoad JNI_OnLoad");
+ g_JavaVM = vm;
+ return JNI_VERSION_1_4;
+}
+
+/* Called when program/activity is created */
+extern "C" void Java_com_mcserver_MCServerActivity_NativeOnCreate( JNIEnv* env, jobject thiz )
+{
+ g_CriticalSection.Lock();
+ g_CurrentJNIEnv = env;
+ g_JavaThread = thiz;
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "Logging from C++!");
+ g_CriticalSection.Unlock();
+
+ mkdir("/sdcard/mcserver", S_IRWXU | S_IRWXG | S_IRWXO);
+
+ pRoot = new cRoot();
+ pRoot->Start();
+ delete pRoot; pRoot = NULL;
+}
+
+
+
+
+
+extern "C" void Java_com_mcserver_MCServerActivity_NativeCleanUp( JNIEnv* env, jobject thiz )
+{
+ g_CriticalSection.Lock();
+ g_CurrentJNIEnv = env;
+ g_JavaThread = thiz;
+ g_CriticalSection.Unlock();
+
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "pRoot: %p", pRoot);
+ if( pRoot != NULL )
+ {
+ pRoot->ExecuteConsoleCommand("stop");
+ }
+}
+
+
+
+
+extern "C" jboolean Java_com_mcserver_MCServerActivity_NativeIsServerRunning( JNIEnv* env, jobject thiz )
+{
+ return pRoot != NULL;
+}
+
+
+
+
+extern "C" jint Java_com_mcserver_MCServerActivity_NativeGetWebAdminPort( JNIEnv* env, jobject thiz )
+{
+ if( pRoot != NULL && pRoot->GetWebAdmin() != NULL )
+ {
+ return pRoot->GetWebAdmin()->GetPort();
+ }
+ return 0;
} \ No newline at end of file
diff --git a/Android/res/layout/main.xml b/Android/res/layout/main.xml
index 1895e2752..4ff238d80 100644
--- a/Android/res/layout/main.xml
+++ b/Android/res/layout/main.xml
@@ -1,61 +1,61 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="center_horizontal"
- android:orientation="vertical" >
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:gravity="center_horizontal"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/textView2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/app_name"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
- <TextView
- android:id="@+id/textView2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/app_name"
- android:textAppearance="?android:attr/textAppearanceLarge" />
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/stop_server"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:enabled="true"
- android:text="@string/stop" />
+ <Button
+ android:id="@+id/stop_server"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:enabled="true"
+ android:text="@string/stop" />
+
+ <Button
+ android:id="@+id/start_server"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/start" />
- <Button
- android:id="@+id/start_server"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/start" />
-
- <Button
- android:id="@+id/configure_server"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/configure" />
-
- </LinearLayout>
-
- <TextView
- android:id="@+id/server_status_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/mcserver_is_not_running"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <TextView
- android:id="@+id/ip_address"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/your_ip" />
- <ListView
- android:id="@+id/listView1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
- </ListView>
-
+ <Button
+ android:id="@+id/configure_server"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/configure" />
+
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/server_status_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/mcserver_is_not_running"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/ip_address"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/your_ip" />
+ <ListView
+ android:id="@+id/listView1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+ </ListView>
+
</LinearLayout> \ No newline at end of file
diff --git a/Android/res/values/strings.xml b/Android/res/values/strings.xml
index aa5978dc0..9eb81d653 100644
--- a/Android/res/values/strings.xml
+++ b/Android/res/values/strings.xml
@@ -1,13 +1,13 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="hello">Hello World, MCServerActivity!</string>
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="hello">Hello World, MCServerActivity!</string>
<string name="app_name">MCServer</string>
<string name="start">Start</string>
<string name="stop">Stop</string>
<string name="mcserver_is_running">MCServer is running</string>
<string name="mcserver_is_not_running">MCServer is not running</string>
- <string name="your_ip">Your IP …</string>
- <string name="configure">Configure</string>
-
+ <string name="your_ip">Your IP …</string>
+ <string name="configure">Configure</string>
+
</resources> \ No newline at end of file
diff --git a/Android/src/com/mcserver/MCServerInstaller.java b/Android/src/com/mcserver/MCServerInstaller.java
index 82dc3bfba..5a865a602 100644
--- a/Android/src/com/mcserver/MCServerInstaller.java
+++ b/Android/src/com/mcserver/MCServerInstaller.java
@@ -1,432 +1,432 @@
-package com.mcserver;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.AssetManager;
-import android.os.AsyncTask;
-import android.os.Environment;
-import android.util.Log;
-
-public class MCServerInstaller {
- private MCServerActivity mContext;
- final private String BaseDirectory = "basedir";
- final private String PluginDirectory = "Plugins";
-
- final public String SHARED_PREFS_NAME = "MCSERVER_PREFS";
- final public String PREF_IS_INSTALLED = "IS_INSTALLED";
- final public String PREF_LAST_VERSION = "LAST_VERSION";
- private SharedPreferences mSettings = null;
-
- int thisVersion;
-
- MCServerInstaller( MCServerActivity activity )
- {
- mContext = activity;
-
- mSettings = mContext.getSharedPreferences( SHARED_PREFS_NAME, 0);
-
- try {
- this.thisVersion = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode;
- } catch (NameNotFoundException e) {
- Log.e("MCServer", "Could not read version code from manifest!");
- e.printStackTrace();
- this.thisVersion = -1;
- }
- }
-
-
- public boolean IsInstalled()
- {
- return mSettings.getBoolean(PREF_IS_INSTALLED, false);
- }
-
-
- public boolean NeedsUpdate()
- {
- Log.i("MCServer", "thisVersion: " + this.thisVersion + " pref: " + mSettings.getInt(PREF_LAST_VERSION, 0));
- return mSettings.getInt(PREF_LAST_VERSION, 0) != this.thisVersion;
- }
-
-
- public ArrayList<String> FindFoldersInPath(String path)
- {
- ArrayList<String> allFolders = new ArrayList<String>();
- AssetManager am = mContext.getAssets();
- try {
- String[] allPlugins = am.list(path);
- for(String pluginName : allPlugins)
- {
- InputStream istr = null;
- try
- {
- istr = am.open(path + "/" + pluginName);
- } catch( java.io.FileNotFoundException e ) {
- // It seems to be a folder :D
- allFolders.add(pluginName);
- continue;
- }
- istr.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return allFolders;
- }
-
-
-
-
- public void ExpandAssets( String path )
- {
- AssetManager am = mContext.getAssets();
- try {
- String[] getAssets = am.list(path);
- for(String assetName : getAssets)
- {
- //Log.e("MCServer", path + "/" + imgName);
-
- InputStream istr = null;
- try
- {
- istr = am.open(path + "/" + assetName);
- } catch( java.io.FileNotFoundException e ) {
- //Log.e("MCServer", "Could not open" + path + "/" + imgName );
- ExpandAssets(path + "/" + assetName);
- continue;
- }
-
- String outPath = Environment.getExternalStorageDirectory().getPath() + "/mcserver/" + path + "/" + assetName;
- //Log.e("MCServer", "outPath: " + outPath );
- File f = new File( outPath );
-
- f.getParentFile().mkdirs();
- f.createNewFile();
- OutputStream ostr = new FileOutputStream(f);
-
- byte[] buffer = new byte[1024];
- int length;
- while ((length = istr.read(buffer))>0)
- {
- ostr.write(buffer, 0, length);
- }
- ostr.flush();
- ostr.close();
- istr.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- void ShowFirstRunDialog()
- {
- AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
- //builder.setTitle("blaa");
- builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- });
- builder.setMessage("It seems this is the first time you are running MCServer on your Android device or it has been updated! This app comes with a couple of pre-packaged plugins, please take a moment to select the plugins you would like to install.");
- builder.setCancelable(false);
- AlertDialog dialog = builder.create();
- dialog.show();
-
- dialog.setOnDismissListener( new DialogInterface.OnDismissListener(){
- public void onDismiss(DialogInterface dialog) {
- ShowPluginInstallDialog(false);
- }
- });
- }
-
-
- public void ShowPluginInstallDialog(boolean bCancelable)
- {
- final ArrayList<String> allPlugins = FindFoldersInPath( BaseDirectory + "/" + PluginDirectory );
- final CharSequence[] items = allPlugins.toArray(new CharSequence[allPlugins.size()]);
- final boolean[] selected = new boolean[items.length];
- for( int i = 0; i < items.length; ++i )
- {
- if( items[i].toString().contains("Core") )
- { // Select the core plugin by default
- selected[i] = true;
- items[i] = items[i] + " (Recommended)";
- }
- }
-
- AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
- builder.setTitle("Plugins to install");
- builder.setCancelable(bCancelable);
- builder.setMultiChoiceItems(items, selected, new DialogInterface.OnMultiChoiceClickListener() {
- public void onClick(DialogInterface dialog, int which, boolean isChecked) {
- selected[which] = isChecked;
- }
- });
- builder.setPositiveButton("Install", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- ArrayList<String> toInstall = new ArrayList<String>();
- for( int i = 0; i < selected.length; ++i )
- {
- if( selected[i] )
- {
- toInstall.add(allPlugins.get(i));
- }
- }
- InstallPlugins(toInstall);
- }
- });
-
- AlertDialog dialog2 = builder.create();
- dialog2.show();
- }
-
-
- void InstallPlugins( final ArrayList<String> plugins )
- {
- new AsyncTask<Void, Integer, Boolean>()
- {
- ProgressDialog progressDialog;
-
- @Override
- protected void onPreExecute()
- {
- /*
- * This is executed on UI thread before doInBackground(). It is
- * the perfect place to show the progress dialog.
- */
- progressDialog = ProgressDialog.show(mContext, "", "Installing...");
-
- }
-
- @Override
- protected Boolean doInBackground(Void... params)
- {
- if (params == null)
- {
- return false;
- }
- try
- {
- /*
- * This is run on a background thread, so we can sleep here
- * or do whatever we want without blocking UI thread. A more
- * advanced use would download chunks of fixed size and call
- * publishProgress();
- */
- for( int i = 0; i < plugins.size(); ++i )
- {
- this.publishProgress((int)(i / (float)plugins.size() * 100), i);
- InstallSinglePlugin(PluginDirectory + "/" + plugins.get(i));
- }
-
- this.publishProgress( 100, -1 );
- InstallExampleSettings();
-
- this.publishProgress( 100, -2 );
- InstallWebAdmin();
-
- }
- catch (Exception e)
- {
- Log.e("tag", e.getMessage());
- /*
- * The task failed
- */
- return false;
- }
-
- /*
- * The task succeeded
- */
- return true;
- }
-
- protected void onProgressUpdate(Integer... progress)
- {
- progressDialog.setProgress(progress[0]);
- if( progress[1] > -1 )
- {
- progressDialog.setMessage("Installing " + plugins.get(progress[1]) + "..." );
- }
- else if( progress[1] == -1 )
- {
- progressDialog.setMessage("Installing default settings...");
- }
- else if( progress[1] == -2 )
- {
- progressDialog.setMessage("Installing WebAdmin...");
- }
- }
-
- @Override
- protected void onPostExecute(Boolean result)
- {
- progressDialog.dismiss();
- /*
- * Update here your view objects with content from download. It
- * is save to dismiss dialogs, update views, etc., since we are
- * working on UI thread.
- */
- AlertDialog.Builder b = new AlertDialog.Builder(mContext);
- b.setTitle(android.R.string.dialog_alert_title);
- if (result)
- {
- b.setMessage("Install succeeded");
-
- SharedPreferences.Editor editor = mSettings.edit();
- editor.putBoolean(PREF_IS_INSTALLED, true);
- editor.putInt(PREF_LAST_VERSION, thisVersion);
- editor.commit();
- }
- else
- {
- b.setMessage("Install failed");
- }
- b.setPositiveButton(android.R.string.ok,
- new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface dialog, int which)
- {
- dialog.dismiss();
- }
- });
- b.create().show();
- }
- }.execute();
- }
-
-
- void InstallExampleSettings()
- {
- AssetManager am = mContext.getAssets();
- try {
- String[] allFiles = am.list(BaseDirectory);
- for(String fileName : allFiles)
- {
- InputStream istr = null;
- try
- {
- istr = am.open(BaseDirectory + "/" + fileName);
- } catch( java.io.FileNotFoundException e ) {
- // Must be a folder :D
- continue;
- }
-
- String outPath = Environment.getExternalStorageDirectory().getPath() + "/mcserver/" + fileName;
- Log.i("MCServer", "outPath: " + outPath );
- File f = new File( outPath );
-
- f.getParentFile().mkdirs();
- f.createNewFile();
- OutputStream ostr = new FileOutputStream(f);
-
- byte[] buffer = new byte[1024];
- int length;
- while ((length = istr.read(buffer))>0)
- {
- ostr.write(buffer, 0, length);
- }
- ostr.flush();
- ostr.close();
- istr.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- void InstallWebAdmin()
- {
- AssetManager am = mContext.getAssets();
- try {
- String[] allFiles = am.list(BaseDirectory + "/webadmin");
- for(String fileName : allFiles)
- {
- InputStream istr = null;
- try
- {
- istr = am.open(BaseDirectory + "/webadmin/" + fileName);
- } catch( java.io.FileNotFoundException e ) {
- // Must be a folder :D
- continue;
- }
-
- String outPath = Environment.getExternalStorageDirectory().getPath() + "/mcserver/webadmin/" + fileName;
- Log.i("MCServer", "outPath: " + outPath );
- File f = new File( outPath );
-
- f.getParentFile().mkdirs();
- f.createNewFile();
- OutputStream ostr = new FileOutputStream(f);
-
- byte[] buffer = new byte[1024];
- int length;
- while ((length = istr.read(buffer))>0)
- {
- ostr.write(buffer, 0, length);
- }
- ostr.flush();
- ostr.close();
- istr.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- void InstallSinglePlugin( String path )
- {
- AssetManager am = mContext.getAssets();
- try {
- String[] getImages = am.list(BaseDirectory + "/" + path);
- for(String imgName : getImages)
- {
- Log.i("MCServer", path + "/" + imgName);
-
- InputStream istr = null;
- try
- {
- istr = am.open(BaseDirectory + "/" + path + "/" + imgName);
- } catch( java.io.FileNotFoundException e ) {
- Log.i("MCServer", "Could not open" + path + "/" + imgName );
- InstallSinglePlugin(path + "/" + imgName);
- continue;
- }
-
- String outPath = Environment.getExternalStorageDirectory().getPath() + "/mcserver/" + path + "/" + imgName;
- Log.i("MCServer", "outPath: " + outPath );
- File f = new File( outPath );
-
- f.getParentFile().mkdirs();
- f.createNewFile();
- OutputStream ostr = new FileOutputStream(f);
-
- byte[] buffer = new byte[1024];
- int length;
- while ((length = istr.read(buffer))>0)
- {
- ostr.write(buffer, 0, length);
- }
- ostr.flush();
- ostr.close();
- istr.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-}
+package com.mcserver;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.AssetManager;
+import android.os.AsyncTask;
+import android.os.Environment;
+import android.util.Log;
+
+public class MCServerInstaller {
+ private MCServerActivity mContext;
+ final private String BaseDirectory = "basedir";
+ final private String PluginDirectory = "Plugins";
+
+ final public String SHARED_PREFS_NAME = "MCSERVER_PREFS";
+ final public String PREF_IS_INSTALLED = "IS_INSTALLED";
+ final public String PREF_LAST_VERSION = "LAST_VERSION";
+ private SharedPreferences mSettings = null;
+
+ int thisVersion;
+
+ MCServerInstaller( MCServerActivity activity )
+ {
+ mContext = activity;
+
+ mSettings = mContext.getSharedPreferences( SHARED_PREFS_NAME, 0);
+
+ try {
+ this.thisVersion = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode;
+ } catch (NameNotFoundException e) {
+ Log.e("MCServer", "Could not read version code from manifest!");
+ e.printStackTrace();
+ this.thisVersion = -1;
+ }
+ }
+
+
+ public boolean IsInstalled()
+ {
+ return mSettings.getBoolean(PREF_IS_INSTALLED, false);
+ }
+
+
+ public boolean NeedsUpdate()
+ {
+ Log.i("MCServer", "thisVersion: " + this.thisVersion + " pref: " + mSettings.getInt(PREF_LAST_VERSION, 0));
+ return mSettings.getInt(PREF_LAST_VERSION, 0) != this.thisVersion;
+ }
+
+
+ public ArrayList<String> FindFoldersInPath(String path)
+ {
+ ArrayList<String> allFolders = new ArrayList<String>();
+ AssetManager am = mContext.getAssets();
+ try {
+ String[] allPlugins = am.list(path);
+ for(String pluginName : allPlugins)
+ {
+ InputStream istr = null;
+ try
+ {
+ istr = am.open(path + "/" + pluginName);
+ } catch( java.io.FileNotFoundException e ) {
+ // It seems to be a folder :D
+ allFolders.add(pluginName);
+ continue;
+ }
+ istr.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return allFolders;
+ }
+
+
+
+
+ public void ExpandAssets( String path )
+ {
+ AssetManager am = mContext.getAssets();
+ try {
+ String[] getAssets = am.list(path);
+ for(String assetName : getAssets)
+ {
+ //Log.e("MCServer", path + "/" + imgName);
+
+ InputStream istr = null;
+ try
+ {
+ istr = am.open(path + "/" + assetName);
+ } catch( java.io.FileNotFoundException e ) {
+ //Log.e("MCServer", "Could not open" + path + "/" + imgName );
+ ExpandAssets(path + "/" + assetName);
+ continue;
+ }
+
+ String outPath = Environment.getExternalStorageDirectory().getPath() + "/mcserver/" + path + "/" + assetName;
+ //Log.e("MCServer", "outPath: " + outPath );
+ File f = new File( outPath );
+
+ f.getParentFile().mkdirs();
+ f.createNewFile();
+ OutputStream ostr = new FileOutputStream(f);
+
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = istr.read(buffer))>0)
+ {
+ ostr.write(buffer, 0, length);
+ }
+ ostr.flush();
+ ostr.close();
+ istr.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ void ShowFirstRunDialog()
+ {
+ AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
+ //builder.setTitle("blaa");
+ builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ });
+ builder.setMessage("It seems this is the first time you are running MCServer on your Android device or it has been updated! This app comes with a couple of pre-packaged plugins, please take a moment to select the plugins you would like to install.");
+ builder.setCancelable(false);
+ AlertDialog dialog = builder.create();
+ dialog.show();
+
+ dialog.setOnDismissListener( new DialogInterface.OnDismissListener(){
+ public void onDismiss(DialogInterface dialog) {
+ ShowPluginInstallDialog(false);
+ }
+ });
+ }
+
+
+ public void ShowPluginInstallDialog(boolean bCancelable)
+ {
+ final ArrayList<String> allPlugins = FindFoldersInPath( BaseDirectory + "/" + PluginDirectory );
+ final CharSequence[] items = allPlugins.toArray(new CharSequence[allPlugins.size()]);
+ final boolean[] selected = new boolean[items.length];
+ for( int i = 0; i < items.length; ++i )
+ {
+ if( items[i].toString().contains("Core") )
+ { // Select the core plugin by default
+ selected[i] = true;
+ items[i] = items[i] + " (Recommended)";
+ }
+ }
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
+ builder.setTitle("Plugins to install");
+ builder.setCancelable(bCancelable);
+ builder.setMultiChoiceItems(items, selected, new DialogInterface.OnMultiChoiceClickListener() {
+ public void onClick(DialogInterface dialog, int which, boolean isChecked) {
+ selected[which] = isChecked;
+ }
+ });
+ builder.setPositiveButton("Install", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ ArrayList<String> toInstall = new ArrayList<String>();
+ for( int i = 0; i < selected.length; ++i )
+ {
+ if( selected[i] )
+ {
+ toInstall.add(allPlugins.get(i));
+ }
+ }
+ InstallPlugins(toInstall);
+ }
+ });
+
+ AlertDialog dialog2 = builder.create();
+ dialog2.show();
+ }
+
+
+ void InstallPlugins( final ArrayList<String> plugins )
+ {
+ new AsyncTask<Void, Integer, Boolean>()
+ {
+ ProgressDialog progressDialog;
+
+ @Override
+ protected void onPreExecute()
+ {
+ /*
+ * This is executed on UI thread before doInBackground(). It is
+ * the perfect place to show the progress dialog.
+ */
+ progressDialog = ProgressDialog.show(mContext, "", "Installing...");
+
+ }
+
+ @Override
+ protected Boolean doInBackground(Void... params)
+ {
+ if (params == null)
+ {
+ return false;
+ }
+ try
+ {
+ /*
+ * This is run on a background thread, so we can sleep here
+ * or do whatever we want without blocking UI thread. A more
+ * advanced use would download chunks of fixed size and call
+ * publishProgress();
+ */
+ for( int i = 0; i < plugins.size(); ++i )
+ {
+ this.publishProgress((int)(i / (float)plugins.size() * 100), i);
+ InstallSinglePlugin(PluginDirectory + "/" + plugins.get(i));
+ }
+
+ this.publishProgress( 100, -1 );
+ InstallExampleSettings();
+
+ this.publishProgress( 100, -2 );
+ InstallWebAdmin();
+
+ }
+ catch (Exception e)
+ {
+ Log.e("tag", e.getMessage());
+ /*
+ * The task failed
+ */
+ return false;
+ }
+
+ /*
+ * The task succeeded
+ */
+ return true;
+ }
+
+ protected void onProgressUpdate(Integer... progress)
+ {
+ progressDialog.setProgress(progress[0]);
+ if( progress[1] > -1 )
+ {
+ progressDialog.setMessage("Installing " + plugins.get(progress[1]) + "..." );
+ }
+ else if( progress[1] == -1 )
+ {
+ progressDialog.setMessage("Installing default settings...");
+ }
+ else if( progress[1] == -2 )
+ {
+ progressDialog.setMessage("Installing WebAdmin...");
+ }
+ }
+
+ @Override
+ protected void onPostExecute(Boolean result)
+ {
+ progressDialog.dismiss();
+ /*
+ * Update here your view objects with content from download. It
+ * is save to dismiss dialogs, update views, etc., since we are
+ * working on UI thread.
+ */
+ AlertDialog.Builder b = new AlertDialog.Builder(mContext);
+ b.setTitle(android.R.string.dialog_alert_title);
+ if (result)
+ {
+ b.setMessage("Install succeeded");
+
+ SharedPreferences.Editor editor = mSettings.edit();
+ editor.putBoolean(PREF_IS_INSTALLED, true);
+ editor.putInt(PREF_LAST_VERSION, thisVersion);
+ editor.commit();
+ }
+ else
+ {
+ b.setMessage("Install failed");
+ }
+ b.setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int which)
+ {
+ dialog.dismiss();
+ }
+ });
+ b.create().show();
+ }
+ }.execute();
+ }
+
+
+ void InstallExampleSettings()
+ {
+ AssetManager am = mContext.getAssets();
+ try {
+ String[] allFiles = am.list(BaseDirectory);
+ for(String fileName : allFiles)
+ {
+ InputStream istr = null;
+ try
+ {
+ istr = am.open(BaseDirectory + "/" + fileName);
+ } catch( java.io.FileNotFoundException e ) {
+ // Must be a folder :D
+ continue;
+ }
+
+ String outPath = Environment.getExternalStorageDirectory().getPath() + "/mcserver/" + fileName;
+ Log.i("MCServer", "outPath: " + outPath );
+ File f = new File( outPath );
+
+ f.getParentFile().mkdirs();
+ f.createNewFile();
+ OutputStream ostr = new FileOutputStream(f);
+
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = istr.read(buffer))>0)
+ {
+ ostr.write(buffer, 0, length);
+ }
+ ostr.flush();
+ ostr.close();
+ istr.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ void InstallWebAdmin()
+ {
+ AssetManager am = mContext.getAssets();
+ try {
+ String[] allFiles = am.list(BaseDirectory + "/webadmin");
+ for(String fileName : allFiles)
+ {
+ InputStream istr = null;
+ try
+ {
+ istr = am.open(BaseDirectory + "/webadmin/" + fileName);
+ } catch( java.io.FileNotFoundException e ) {
+ // Must be a folder :D
+ continue;
+ }
+
+ String outPath = Environment.getExternalStorageDirectory().getPath() + "/mcserver/webadmin/" + fileName;
+ Log.i("MCServer", "outPath: " + outPath );
+ File f = new File( outPath );
+
+ f.getParentFile().mkdirs();
+ f.createNewFile();
+ OutputStream ostr = new FileOutputStream(f);
+
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = istr.read(buffer))>0)
+ {
+ ostr.write(buffer, 0, length);
+ }
+ ostr.flush();
+ ostr.close();
+ istr.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ void InstallSinglePlugin( String path )
+ {
+ AssetManager am = mContext.getAssets();
+ try {
+ String[] getImages = am.list(BaseDirectory + "/" + path);
+ for(String imgName : getImages)
+ {
+ Log.i("MCServer", path + "/" + imgName);
+
+ InputStream istr = null;
+ try
+ {
+ istr = am.open(BaseDirectory + "/" + path + "/" + imgName);
+ } catch( java.io.FileNotFoundException e ) {
+ Log.i("MCServer", "Could not open" + path + "/" + imgName );
+ InstallSinglePlugin(path + "/" + imgName);
+ continue;
+ }
+
+ String outPath = Environment.getExternalStorageDirectory().getPath() + "/mcserver/" + path + "/" + imgName;
+ Log.i("MCServer", "outPath: " + outPath );
+ File f = new File( outPath );
+
+ f.getParentFile().mkdirs();
+ f.createNewFile();
+ OutputStream ostr = new FileOutputStream(f);
+
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = istr.read(buffer))>0)
+ {
+ ostr.write(buffer, 0, length);
+ }
+ ostr.flush();
+ ostr.close();
+ istr.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/COMPILING b/COMPILING
index 9e29cee31..f8bdb298e 100644
--- a/COMPILING
+++ b/COMPILING
@@ -1,6 +1,7 @@
-COMPILING
-=========
-
-To compile MCServer on *nix, you need a GNUmake-compatible make that reads GNUmakefile.
-Run "make" to build a debug version (slow, but gives more info on crash)
-Run "make release=1" to build a release version (fast, less info on crash) \ No newline at end of file
+COMPILING
+=========
+
+To compile MCServer on *nix, you need a GNUmake-compatible make that reads GNUmakefile.
+Run "make" to build a debug version (slow, but gives more info on crash)
+Run "make release=1" to build a release version (fast, less info on crash)
+Add addm32=1 to compile in 32-bit mode on 64-bit systems.
diff --git a/CryptoPP/authenc.cpp b/CryptoPP/authenc.cpp
index 0ca5da60d..f93662efb 100644
--- a/CryptoPP/authenc.cpp
+++ b/CryptoPP/authenc.cpp
@@ -1,180 +1,180 @@
-// authenc.cpp - written and placed in the public domain by Wei Dai
-
-#include "pch.h"
-
-#ifndef CRYPTOPP_IMPORTS
-
-#include "authenc.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-void AuthenticatedSymmetricCipherBase::AuthenticateData(const byte *input, size_t len)
-{
- unsigned int blockSize = AuthenticationBlockSize();
- unsigned int &num = m_bufferedDataLength;
- byte* data = m_buffer.begin();
-
- if (num != 0) // process left over data
- {
- if (num+len >= blockSize)
- {
- memcpy(data+num, input, blockSize-num);
- AuthenticateBlocks(data, blockSize);
- input += (blockSize-num);
- len -= (blockSize-num);
- num = 0;
- // drop through and do the rest
- }
- else
- {
- memcpy(data+num, input, len);
- num += (unsigned int)len;
- return;
- }
- }
-
- // now process the input data in blocks of blockSize bytes and save the leftovers to m_data
- if (len >= blockSize)
- {
- size_t leftOver = AuthenticateBlocks(input, len);
- input += (len - leftOver);
- len = leftOver;
- }
-
- memcpy(data, input, len);
- num = (unsigned int)len;
-}
-
-void AuthenticatedSymmetricCipherBase::SetKey(const byte *userKey, size_t keylength, const NameValuePairs &params)
-{
- m_bufferedDataLength = 0;
- m_state = State_Start;
-
- SetKeyWithoutResync(userKey, keylength, params);
- m_state = State_KeySet;
-
- size_t length;
- const byte *iv = GetIVAndThrowIfInvalid(params, length);
- if (iv)
- Resynchronize(iv, (int)length);
-}
-
-void AuthenticatedSymmetricCipherBase::Resynchronize(const byte *iv, int length)
-{
- if (m_state < State_KeySet)
- throw BadState(AlgorithmName(), "Resynchronize", "key is set");
-
- m_bufferedDataLength = 0;
- m_totalHeaderLength = m_totalMessageLength = m_totalFooterLength = 0;
- m_state = State_KeySet;
-
- Resync(iv, this->ThrowIfInvalidIVLength(length));
- m_state = State_IVSet;
-}
-
-void AuthenticatedSymmetricCipherBase::Update(const byte *input, size_t length)
-{
- if (length == 0)
- return;
-
- switch (m_state)
- {
- case State_Start:
- case State_KeySet:
- throw BadState(AlgorithmName(), "Update", "setting key and IV");
- case State_IVSet:
- AuthenticateData(input, length);
- m_totalHeaderLength += length;
- break;
- case State_AuthUntransformed:
- case State_AuthTransformed:
- AuthenticateLastConfidentialBlock();
- m_bufferedDataLength = 0;
- m_state = State_AuthFooter;
- // fall through
- case State_AuthFooter:
- AuthenticateData(input, length);
- m_totalFooterLength += length;
- break;
- default:
- assert(false);
- }
-}
-
-void AuthenticatedSymmetricCipherBase::ProcessData(byte *outString, const byte *inString, size_t length)
-{
- m_totalMessageLength += length;
- if (m_state >= State_IVSet && m_totalMessageLength > MaxMessageLength())
- throw InvalidArgument(AlgorithmName() + ": message length exceeds maximum");
-
-reswitch:
- switch (m_state)
- {
- case State_Start:
- case State_KeySet:
- throw BadState(AlgorithmName(), "ProcessData", "setting key and IV");
- case State_AuthFooter:
- throw BadState(AlgorithmName(), "ProcessData was called after footer input has started");
- case State_IVSet:
- AuthenticateLastHeaderBlock();
- m_bufferedDataLength = 0;
- m_state = AuthenticationIsOnPlaintext()==IsForwardTransformation() ? State_AuthUntransformed : State_AuthTransformed;
- goto reswitch;
- case State_AuthUntransformed:
- AuthenticateData(inString, length);
- AccessSymmetricCipher().ProcessData(outString, inString, length);
- break;
- case State_AuthTransformed:
- AccessSymmetricCipher().ProcessData(outString, inString, length);
- AuthenticateData(outString, length);
- break;
- default:
- assert(false);
- }
-}
-
-void AuthenticatedSymmetricCipherBase::TruncatedFinal(byte *mac, size_t macSize)
-{
- if (m_totalHeaderLength > MaxHeaderLength())
- throw InvalidArgument(AlgorithmName() + ": header length of " + IntToString(m_totalHeaderLength) + " exceeds the maximum of " + IntToString(MaxHeaderLength()));
-
- if (m_totalFooterLength > MaxFooterLength())
- {
- if (MaxFooterLength() == 0)
- throw InvalidArgument(AlgorithmName() + ": additional authenticated data (AAD) cannot be input after data to be encrypted or decrypted");
- else
- throw InvalidArgument(AlgorithmName() + ": footer length of " + IntToString(m_totalFooterLength) + " exceeds the maximum of " + IntToString(MaxFooterLength()));
- }
-
- switch (m_state)
- {
- case State_Start:
- case State_KeySet:
- throw BadState(AlgorithmName(), "TruncatedFinal", "setting key and IV");
-
- case State_IVSet:
- AuthenticateLastHeaderBlock();
- m_bufferedDataLength = 0;
- // fall through
-
- case State_AuthUntransformed:
- case State_AuthTransformed:
- AuthenticateLastConfidentialBlock();
- m_bufferedDataLength = 0;
- // fall through
-
- case State_AuthFooter:
- AuthenticateLastFooterBlock(mac, macSize);
- m_bufferedDataLength = 0;
- break;
-
- default:
- assert(false);
- }
-
- m_state = State_KeySet;
-}
-
-NAMESPACE_END
-
-#endif
+// authenc.cpp - written and placed in the public domain by Wei Dai
+
+#include "pch.h"
+
+#ifndef CRYPTOPP_IMPORTS
+
+#include "authenc.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+void AuthenticatedSymmetricCipherBase::AuthenticateData(const byte *input, size_t len)
+{
+ unsigned int blockSize = AuthenticationBlockSize();
+ unsigned int &num = m_bufferedDataLength;
+ byte* data = m_buffer.begin();
+
+ if (num != 0) // process left over data
+ {
+ if (num+len >= blockSize)
+ {
+ memcpy(data+num, input, blockSize-num);
+ AuthenticateBlocks(data, blockSize);
+ input += (blockSize-num);
+ len -= (blockSize-num);
+ num = 0;
+ // drop through and do the rest
+ }
+ else
+ {
+ memcpy(data+num, input, len);
+ num += (unsigned int)len;
+ return;
+ }
+ }
+
+ // now process the input data in blocks of blockSize bytes and save the leftovers to m_data
+ if (len >= blockSize)
+ {
+ size_t leftOver = AuthenticateBlocks(input, len);
+ input += (len - leftOver);
+ len = leftOver;
+ }
+
+ memcpy(data, input, len);
+ num = (unsigned int)len;
+}
+
+void AuthenticatedSymmetricCipherBase::SetKey(const byte *userKey, size_t keylength, const NameValuePairs &params)
+{
+ m_bufferedDataLength = 0;
+ m_state = State_Start;
+
+ SetKeyWithoutResync(userKey, keylength, params);
+ m_state = State_KeySet;
+
+ size_t length;
+ const byte *iv = GetIVAndThrowIfInvalid(params, length);
+ if (iv)
+ Resynchronize(iv, (int)length);
+}
+
+void AuthenticatedSymmetricCipherBase::Resynchronize(const byte *iv, int length)
+{
+ if (m_state < State_KeySet)
+ throw BadState(AlgorithmName(), "Resynchronize", "key is set");
+
+ m_bufferedDataLength = 0;
+ m_totalHeaderLength = m_totalMessageLength = m_totalFooterLength = 0;
+ m_state = State_KeySet;
+
+ Resync(iv, this->ThrowIfInvalidIVLength(length));
+ m_state = State_IVSet;
+}
+
+void AuthenticatedSymmetricCipherBase::Update(const byte *input, size_t length)
+{
+ if (length == 0)
+ return;
+
+ switch (m_state)
+ {
+ case State_Start:
+ case State_KeySet:
+ throw BadState(AlgorithmName(), "Update", "setting key and IV");
+ case State_IVSet:
+ AuthenticateData(input, length);
+ m_totalHeaderLength += length;
+ break;
+ case State_AuthUntransformed:
+ case State_AuthTransformed:
+ AuthenticateLastConfidentialBlock();
+ m_bufferedDataLength = 0;
+ m_state = State_AuthFooter;
+ // fall through
+ case State_AuthFooter:
+ AuthenticateData(input, length);
+ m_totalFooterLength += length;
+ break;
+ default:
+ assert(false);
+ }
+}
+
+void AuthenticatedSymmetricCipherBase::ProcessData(byte *outString, const byte *inString, size_t length)
+{
+ m_totalMessageLength += length;
+ if (m_state >= State_IVSet && m_totalMessageLength > MaxMessageLength())
+ throw InvalidArgument(AlgorithmName() + ": message length exceeds maximum");
+
+reswitch:
+ switch (m_state)
+ {
+ case State_Start:
+ case State_KeySet:
+ throw BadState(AlgorithmName(), "ProcessData", "setting key and IV");
+ case State_AuthFooter:
+ throw BadState(AlgorithmName(), "ProcessData was called after footer input has started");
+ case State_IVSet:
+ AuthenticateLastHeaderBlock();
+ m_bufferedDataLength = 0;
+ m_state = AuthenticationIsOnPlaintext()==IsForwardTransformation() ? State_AuthUntransformed : State_AuthTransformed;
+ goto reswitch;
+ case State_AuthUntransformed:
+ AuthenticateData(inString, length);
+ AccessSymmetricCipher().ProcessData(outString, inString, length);
+ break;
+ case State_AuthTransformed:
+ AccessSymmetricCipher().ProcessData(outString, inString, length);
+ AuthenticateData(outString, length);
+ break;
+ default:
+ assert(false);
+ }
+}
+
+void AuthenticatedSymmetricCipherBase::TruncatedFinal(byte *mac, size_t macSize)
+{
+ if (m_totalHeaderLength > MaxHeaderLength())
+ throw InvalidArgument(AlgorithmName() + ": header length of " + IntToString(m_totalHeaderLength) + " exceeds the maximum of " + IntToString(MaxHeaderLength()));
+
+ if (m_totalFooterLength > MaxFooterLength())
+ {
+ if (MaxFooterLength() == 0)
+ throw InvalidArgument(AlgorithmName() + ": additional authenticated data (AAD) cannot be input after data to be encrypted or decrypted");
+ else
+ throw InvalidArgument(AlgorithmName() + ": footer length of " + IntToString(m_totalFooterLength) + " exceeds the maximum of " + IntToString(MaxFooterLength()));
+ }
+
+ switch (m_state)
+ {
+ case State_Start:
+ case State_KeySet:
+ throw BadState(AlgorithmName(), "TruncatedFinal", "setting key and IV");
+
+ case State_IVSet:
+ AuthenticateLastHeaderBlock();
+ m_bufferedDataLength = 0;
+ // fall through
+
+ case State_AuthUntransformed:
+ case State_AuthTransformed:
+ AuthenticateLastConfidentialBlock();
+ m_bufferedDataLength = 0;
+ // fall through
+
+ case State_AuthFooter:
+ AuthenticateLastFooterBlock(mac, macSize);
+ m_bufferedDataLength = 0;
+ break;
+
+ default:
+ assert(false);
+ }
+
+ m_state = State_KeySet;
+}
+
+NAMESPACE_END
+
+#endif
diff --git a/CryptoPP/authenc.h b/CryptoPP/authenc.h
index f726716e7..5bb2a51c8 100644
--- a/CryptoPP/authenc.h
+++ b/CryptoPP/authenc.h
@@ -1,49 +1,49 @@
-#ifndef CRYPTOPP_AUTHENC_H
-#define CRYPTOPP_AUTHENC_H
-
-#include "cryptlib.h"
-#include "secblock.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-//! .
-class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AuthenticatedSymmetricCipherBase : public AuthenticatedSymmetricCipher
-{
-public:
- AuthenticatedSymmetricCipherBase() : m_state(State_Start) {}
-
- bool IsRandomAccess() const {return false;}
- bool IsSelfInverting() const {return true;}
- void UncheckedSetKey(const byte *,unsigned int,const CryptoPP::NameValuePairs &) {assert(false);}
-
- void SetKey(const byte *userKey, size_t keylength, const NameValuePairs &params);
- void Restart() {if (m_state > State_KeySet) m_state = State_KeySet;}
- void Resynchronize(const byte *iv, int length=-1);
- void Update(const byte *input, size_t length);
- void ProcessData(byte *outString, const byte *inString, size_t length);
- void TruncatedFinal(byte *mac, size_t macSize);
-
-protected:
- void AuthenticateData(const byte *data, size_t len);
- const SymmetricCipher & GetSymmetricCipher() const {return const_cast<AuthenticatedSymmetricCipherBase *>(this)->AccessSymmetricCipher();};
-
- virtual SymmetricCipher & AccessSymmetricCipher() =0;
- virtual bool AuthenticationIsOnPlaintext() const =0;
- virtual unsigned int AuthenticationBlockSize() const =0;
- virtual void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params) =0;
- virtual void Resync(const byte *iv, size_t len) =0;
- virtual size_t AuthenticateBlocks(const byte *data, size_t len) =0;
- virtual void AuthenticateLastHeaderBlock() =0;
- virtual void AuthenticateLastConfidentialBlock() {}
- virtual void AuthenticateLastFooterBlock(byte *mac, size_t macSize) =0;
-
- enum State {State_Start, State_KeySet, State_IVSet, State_AuthUntransformed, State_AuthTransformed, State_AuthFooter};
- State m_state;
- unsigned int m_bufferedDataLength;
- lword m_totalHeaderLength, m_totalMessageLength, m_totalFooterLength;
- AlignedSecByteBlock m_buffer;
-};
-
-NAMESPACE_END
-
-#endif
+#ifndef CRYPTOPP_AUTHENC_H
+#define CRYPTOPP_AUTHENC_H
+
+#include "cryptlib.h"
+#include "secblock.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! .
+class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AuthenticatedSymmetricCipherBase : public AuthenticatedSymmetricCipher
+{
+public:
+ AuthenticatedSymmetricCipherBase() : m_state(State_Start) {}
+
+ bool IsRandomAccess() const {return false;}
+ bool IsSelfInverting() const {return true;}
+ void UncheckedSetKey(const byte *,unsigned int,const CryptoPP::NameValuePairs &) {assert(false);}
+
+ void SetKey(const byte *userKey, size_t keylength, const NameValuePairs &params);
+ void Restart() {if (m_state > State_KeySet) m_state = State_KeySet;}
+ void Resynchronize(const byte *iv, int length=-1);
+ void Update(const byte *input, size_t length);
+ void ProcessData(byte *outString, const byte *inString, size_t length);
+ void TruncatedFinal(byte *mac, size_t macSize);
+
+protected:
+ void AuthenticateData(const byte *data, size_t len);
+ const SymmetricCipher & GetSymmetricCipher() const {return const_cast<AuthenticatedSymmetricCipherBase *>(this)->AccessSymmetricCipher();};
+
+ virtual SymmetricCipher & AccessSymmetricCipher() =0;
+ virtual bool AuthenticationIsOnPlaintext() const =0;
+ virtual unsigned int AuthenticationBlockSize() const =0;
+ virtual void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params) =0;
+ virtual void Resync(const byte *iv, size_t len) =0;
+ virtual size_t AuthenticateBlocks(const byte *data, size_t len) =0;
+ virtual void AuthenticateLastHeaderBlock() =0;
+ virtual void AuthenticateLastConfidentialBlock() {}
+ virtual void AuthenticateLastFooterBlock(byte *mac, size_t macSize) =0;
+
+ enum State {State_Start, State_KeySet, State_IVSet, State_AuthUntransformed, State_AuthTransformed, State_AuthFooter};
+ State m_state;
+ unsigned int m_bufferedDataLength;
+ lword m_totalHeaderLength, m_totalMessageLength, m_totalFooterLength;
+ AlignedSecByteBlock m_buffer;
+};
+
+NAMESPACE_END
+
+#endif
diff --git a/CryptoPP/ccm.cpp b/CryptoPP/ccm.cpp
index 036878719..030828ad8 100644
--- a/CryptoPP/ccm.cpp
+++ b/CryptoPP/ccm.cpp
@@ -1,140 +1,140 @@
-// ccm.cpp - written and placed in the public domain by Wei Dai
-
-#include "pch.h"
-
-#ifndef CRYPTOPP_IMPORTS
-
-#include "ccm.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-void CCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params)
-{
- BlockCipher &blockCipher = AccessBlockCipher();
-
- blockCipher.SetKey(userKey, keylength, params);
-
- if (blockCipher.BlockSize() != REQUIRED_BLOCKSIZE)
- throw InvalidArgument(AlgorithmName() + ": block size of underlying block cipher is not 16");
-
- m_digestSize = params.GetIntValueWithDefault(Name::DigestSize(), DefaultDigestSize());
- if (m_digestSize % 2 > 0 || m_digestSize < 4 || m_digestSize > 16)
- throw InvalidArgument(AlgorithmName() + ": DigestSize must be 4, 6, 8, 10, 12, 14, or 16");
-
- m_buffer.Grow(2*REQUIRED_BLOCKSIZE);
- m_L = 8;
-}
-
-void CCM_Base::Resync(const byte *iv, size_t len)
-{
- BlockCipher &cipher = AccessBlockCipher();
-
- m_L = REQUIRED_BLOCKSIZE-1-(int)len;
- assert(m_L >= 2);
- if (m_L > 8)
- m_L = 8;
-
- m_buffer[0] = byte(m_L-1); // flag
- memcpy(m_buffer+1, iv, len);
- memset(m_buffer+1+len, 0, REQUIRED_BLOCKSIZE-1-len);
-
- if (m_state >= State_IVSet)
- m_ctr.Resynchronize(m_buffer, REQUIRED_BLOCKSIZE);
- else
- m_ctr.SetCipherWithIV(cipher, m_buffer);
-
- m_ctr.Seek(REQUIRED_BLOCKSIZE);
- m_aadLength = 0;
- m_messageLength = 0;
-}
-
-void CCM_Base::UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength)
-{
- if (m_state != State_IVSet)
- throw BadState(AlgorithmName(), "SpecifyDataLengths", "or after State_IVSet");
-
- m_aadLength = headerLength;
- m_messageLength = messageLength;
-
- byte *cbcBuffer = CBC_Buffer();
- const BlockCipher &cipher = GetBlockCipher();
-
- cbcBuffer[0] = byte(64*(headerLength>0) + 8*((m_digestSize-2)/2) + (m_L-1)); // flag
- PutWord<word64>(true, BIG_ENDIAN_ORDER, cbcBuffer+REQUIRED_BLOCKSIZE-8, m_messageLength);
- memcpy(cbcBuffer+1, m_buffer+1, REQUIRED_BLOCKSIZE-1-m_L);
- cipher.ProcessBlock(cbcBuffer);
-
- if (headerLength>0)
- {
- assert(m_bufferedDataLength == 0);
-
- if (headerLength < ((1<<16) - (1<<8)))
- {
- PutWord<word16>(true, BIG_ENDIAN_ORDER, m_buffer, (word16)headerLength);
- m_bufferedDataLength = 2;
- }
- else if (headerLength < (W64LIT(1)<<32))
- {
- m_buffer[0] = 0xff;
- m_buffer[1] = 0xfe;
- PutWord<word32>(false, BIG_ENDIAN_ORDER, m_buffer+2, (word32)headerLength);
- m_bufferedDataLength = 6;
- }
- else
- {
- m_buffer[0] = 0xff;
- m_buffer[1] = 0xff;
- PutWord<word64>(false, BIG_ENDIAN_ORDER, m_buffer+2, headerLength);
- m_bufferedDataLength = 10;
- }
- }
-}
-
-size_t CCM_Base::AuthenticateBlocks(const byte *data, size_t len)
-{
- byte *cbcBuffer = CBC_Buffer();
- const BlockCipher &cipher = GetBlockCipher();
- return cipher.AdvancedProcessBlocks(cbcBuffer, data, cbcBuffer, len, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
-}
-
-void CCM_Base::AuthenticateLastHeaderBlock()
-{
- byte *cbcBuffer = CBC_Buffer();
- const BlockCipher &cipher = GetBlockCipher();
-
- if (m_aadLength != m_totalHeaderLength)
- throw InvalidArgument(AlgorithmName() + ": header length doesn't match that given in SpecifyDataLengths");
-
- if (m_bufferedDataLength > 0)
- {
- xorbuf(cbcBuffer, m_buffer, m_bufferedDataLength);
- cipher.ProcessBlock(cbcBuffer);
- m_bufferedDataLength = 0;
- }
-}
-
-void CCM_Base::AuthenticateLastConfidentialBlock()
-{
- byte *cbcBuffer = CBC_Buffer();
- const BlockCipher &cipher = GetBlockCipher();
-
- if (m_messageLength != m_totalMessageLength)
- throw InvalidArgument(AlgorithmName() + ": message length doesn't match that given in SpecifyDataLengths");
-
- if (m_bufferedDataLength > 0)
- {
- xorbuf(cbcBuffer, m_buffer, m_bufferedDataLength);
- cipher.ProcessBlock(cbcBuffer);
- m_bufferedDataLength = 0;
- }
-}
-
-void CCM_Base::AuthenticateLastFooterBlock(byte *mac, size_t macSize)
-{
- m_ctr.Seek(0);
- m_ctr.ProcessData(mac, CBC_Buffer(), macSize);
-}
-
-NAMESPACE_END
-
-#endif
+// ccm.cpp - written and placed in the public domain by Wei Dai
+
+#include "pch.h"
+
+#ifndef CRYPTOPP_IMPORTS
+
+#include "ccm.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+void CCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params)
+{
+ BlockCipher &blockCipher = AccessBlockCipher();
+
+ blockCipher.SetKey(userKey, keylength, params);
+
+ if (blockCipher.BlockSize() != REQUIRED_BLOCKSIZE)
+ throw InvalidArgument(AlgorithmName() + ": block size of underlying block cipher is not 16");
+
+ m_digestSize = params.GetIntValueWithDefault(Name::DigestSize(), DefaultDigestSize());
+ if (m_digestSize % 2 > 0 || m_digestSize < 4 || m_digestSize > 16)
+ throw InvalidArgument(AlgorithmName() + ": DigestSize must be 4, 6, 8, 10, 12, 14, or 16");
+
+ m_buffer.Grow(2*REQUIRED_BLOCKSIZE);
+ m_L = 8;
+}
+
+void CCM_Base::Resync(const byte *iv, size_t len)
+{
+ BlockCipher &cipher = AccessBlockCipher();
+
+ m_L = REQUIRED_BLOCKSIZE-1-(int)len;
+ assert(m_L >= 2);
+ if (m_L > 8)
+ m_L = 8;
+
+ m_buffer[0] = byte(m_L-1); // flag
+ memcpy(m_buffer+1, iv, len);
+ memset(m_buffer+1+len, 0, REQUIRED_BLOCKSIZE-1-len);
+
+ if (m_state >= State_IVSet)
+ m_ctr.Resynchronize(m_buffer, REQUIRED_BLOCKSIZE);
+ else
+ m_ctr.SetCipherWithIV(cipher, m_buffer);
+
+ m_ctr.Seek(REQUIRED_BLOCKSIZE);
+ m_aadLength = 0;
+ m_messageLength = 0;
+}
+
+void CCM_Base::UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength)
+{
+ if (m_state != State_IVSet)
+ throw BadState(AlgorithmName(), "SpecifyDataLengths", "or after State_IVSet");
+
+ m_aadLength = headerLength;
+ m_messageLength = messageLength;
+
+ byte *cbcBuffer = CBC_Buffer();
+ const BlockCipher &cipher = GetBlockCipher();
+
+ cbcBuffer[0] = byte(64*(headerLength>0) + 8*((m_digestSize-2)/2) + (m_L-1)); // flag
+ PutWord<word64>(true, BIG_ENDIAN_ORDER, cbcBuffer+REQUIRED_BLOCKSIZE-8, m_messageLength);
+ memcpy(cbcBuffer+1, m_buffer+1, REQUIRED_BLOCKSIZE-1-m_L);
+ cipher.ProcessBlock(cbcBuffer);
+
+ if (headerLength>0)
+ {
+ assert(m_bufferedDataLength == 0);
+
+ if (headerLength < ((1<<16) - (1<<8)))
+ {
+ PutWord<word16>(true, BIG_ENDIAN_ORDER, m_buffer, (word16)headerLength);
+ m_bufferedDataLength = 2;
+ }
+ else if (headerLength < (W64LIT(1)<<32))
+ {
+ m_buffer[0] = 0xff;
+ m_buffer[1] = 0xfe;
+ PutWord<word32>(false, BIG_ENDIAN_ORDER, m_buffer+2, (word32)headerLength);
+ m_bufferedDataLength = 6;
+ }
+ else
+ {
+ m_buffer[0] = 0xff;
+ m_buffer[1] = 0xff;
+ PutWord<word64>(false, BIG_ENDIAN_ORDER, m_buffer+2, headerLength);
+ m_bufferedDataLength = 10;
+ }
+ }
+}
+
+size_t CCM_Base::AuthenticateBlocks(const byte *data, size_t len)
+{
+ byte *cbcBuffer = CBC_Buffer();
+ const BlockCipher &cipher = GetBlockCipher();
+ return cipher.AdvancedProcessBlocks(cbcBuffer, data, cbcBuffer, len, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
+}
+
+void CCM_Base::AuthenticateLastHeaderBlock()
+{
+ byte *cbcBuffer = CBC_Buffer();
+ const BlockCipher &cipher = GetBlockCipher();
+
+ if (m_aadLength != m_totalHeaderLength)
+ throw InvalidArgument(AlgorithmName() + ": header length doesn't match that given in SpecifyDataLengths");
+
+ if (m_bufferedDataLength > 0)
+ {
+ xorbuf(cbcBuffer, m_buffer, m_bufferedDataLength);
+ cipher.ProcessBlock(cbcBuffer);
+ m_bufferedDataLength = 0;
+ }
+}
+
+void CCM_Base::AuthenticateLastConfidentialBlock()
+{
+ byte *cbcBuffer = CBC_Buffer();
+ const BlockCipher &cipher = GetBlockCipher();
+
+ if (m_messageLength != m_totalMessageLength)
+ throw InvalidArgument(AlgorithmName() + ": message length doesn't match that given in SpecifyDataLengths");
+
+ if (m_bufferedDataLength > 0)
+ {
+ xorbuf(cbcBuffer, m_buffer, m_bufferedDataLength);
+ cipher.ProcessBlock(cbcBuffer);
+ m_bufferedDataLength = 0;
+ }
+}
+
+void CCM_Base::AuthenticateLastFooterBlock(byte *mac, size_t macSize)
+{
+ m_ctr.Seek(0);
+ m_ctr.ProcessData(mac, CBC_Buffer(), macSize);
+}
+
+NAMESPACE_END
+
+#endif
diff --git a/CryptoPP/ccm.h b/CryptoPP/ccm.h
index 2f3c56b45..b1e5f00b9 100644
--- a/CryptoPP/ccm.h
+++ b/CryptoPP/ccm.h
@@ -1,101 +1,101 @@
-#ifndef CRYPTOPP_CCM_H
-#define CRYPTOPP_CCM_H
-
-#include "authenc.h"
-#include "modes.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-//! .
-class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CCM_Base : public AuthenticatedSymmetricCipherBase
-{
-public:
- CCM_Base()
- : m_digestSize(0), m_L(0) {}
-
- // AuthenticatedSymmetricCipher
- std::string AlgorithmName() const
- {return GetBlockCipher().AlgorithmName() + std::string("/CCM");}
- size_t MinKeyLength() const
- {return GetBlockCipher().MinKeyLength();}
- size_t MaxKeyLength() const
- {return GetBlockCipher().MaxKeyLength();}
- size_t DefaultKeyLength() const
- {return GetBlockCipher().DefaultKeyLength();}
- size_t GetValidKeyLength(size_t n) const
- {return GetBlockCipher().GetValidKeyLength(n);}
- bool IsValidKeyLength(size_t n) const
- {return GetBlockCipher().IsValidKeyLength(n);}
- unsigned int OptimalDataAlignment() const
- {return GetBlockCipher().OptimalDataAlignment();}
- IV_Requirement IVRequirement() const
- {return UNIQUE_IV;}
- unsigned int IVSize() const
- {return 8;}
- unsigned int MinIVLength() const
- {return 7;}
- unsigned int MaxIVLength() const
- {return 13;}
- unsigned int DigestSize() const
- {return m_digestSize;}
- lword MaxHeaderLength() const
- {return W64LIT(0)-1;}
- lword MaxMessageLength() const
- {return m_L<8 ? (W64LIT(1)<<(8*m_L))-1 : W64LIT(0)-1;}
- bool NeedsPrespecifiedDataLengths() const
- {return true;}
- void UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength);
-
-protected:
- // AuthenticatedSymmetricCipherBase
- bool AuthenticationIsOnPlaintext() const
- {return true;}
- unsigned int AuthenticationBlockSize() const
- {return GetBlockCipher().BlockSize();}
- void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params);
- void Resync(const byte *iv, size_t len);
- size_t AuthenticateBlocks(const byte *data, size_t len);
- void AuthenticateLastHeaderBlock();
- void AuthenticateLastConfidentialBlock();
- void AuthenticateLastFooterBlock(byte *mac, size_t macSize);
- SymmetricCipher & AccessSymmetricCipher() {return m_ctr;}
-
- virtual BlockCipher & AccessBlockCipher() =0;
- virtual int DefaultDigestSize() const =0;
-
- const BlockCipher & GetBlockCipher() const {return const_cast<CCM_Base *>(this)->AccessBlockCipher();};
- byte *CBC_Buffer() {return m_buffer+REQUIRED_BLOCKSIZE;}
-
- enum {REQUIRED_BLOCKSIZE = 16};
- int m_digestSize, m_L;
- word64 m_messageLength, m_aadLength;
- CTR_Mode_ExternalCipher::Encryption m_ctr;
-};
-
-//! .
-template <class T_BlockCipher, int T_DefaultDigestSize, bool T_IsEncryption>
-class CCM_Final : public CCM_Base
-{
-public:
- static std::string StaticAlgorithmName()
- {return T_BlockCipher::StaticAlgorithmName() + std::string("/CCM");}
- bool IsForwardTransformation() const
- {return T_IsEncryption;}
-
-private:
- BlockCipher & AccessBlockCipher() {return m_cipher;}
- int DefaultDigestSize() const {return T_DefaultDigestSize;}
- typename T_BlockCipher::Encryption m_cipher;
-};
-
-/// <a href="http://www.cryptolounge.org/wiki/CCM">CCM</a>
-template <class T_BlockCipher, int T_DefaultDigestSize = 16>
-struct CCM : public AuthenticatedSymmetricCipherDocumentation
-{
- typedef CCM_Final<T_BlockCipher, T_DefaultDigestSize, true> Encryption;
- typedef CCM_Final<T_BlockCipher, T_DefaultDigestSize, false> Decryption;
-};
-
-NAMESPACE_END
-
-#endif
+#ifndef CRYPTOPP_CCM_H
+#define CRYPTOPP_CCM_H
+
+#include "authenc.h"
+#include "modes.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! .
+class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CCM_Base : public AuthenticatedSymmetricCipherBase
+{
+public:
+ CCM_Base()
+ : m_digestSize(0), m_L(0) {}
+
+ // AuthenticatedSymmetricCipher
+ std::string AlgorithmName() const
+ {return GetBlockCipher().AlgorithmName() + std::string("/CCM");}
+ size_t MinKeyLength() const
+ {return GetBlockCipher().MinKeyLength();}
+ size_t MaxKeyLength() const
+ {return GetBlockCipher().MaxKeyLength();}
+ size_t DefaultKeyLength() const
+ {return GetBlockCipher().DefaultKeyLength();}
+ size_t GetValidKeyLength(size_t n) const
+ {return GetBlockCipher().GetValidKeyLength(n);}
+ bool IsValidKeyLength(size_t n) const
+ {return GetBlockCipher().IsValidKeyLength(n);}
+ unsigned int OptimalDataAlignment() const
+ {return GetBlockCipher().OptimalDataAlignment();}
+ IV_Requirement IVRequirement() const
+ {return UNIQUE_IV;}
+ unsigned int IVSize() const
+ {return 8;}
+ unsigned int MinIVLength() const
+ {return 7;}
+ unsigned int MaxIVLength() const
+ {return 13;}
+ unsigned int DigestSize() const
+ {return m_digestSize;}
+ lword MaxHeaderLength() const
+ {return W64LIT(0)-1;}
+ lword MaxMessageLength() const
+ {return m_L<8 ? (W64LIT(1)<<(8*m_L))-1 : W64LIT(0)-1;}
+ bool NeedsPrespecifiedDataLengths() const
+ {return true;}
+ void UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength);
+
+protected:
+ // AuthenticatedSymmetricCipherBase
+ bool AuthenticationIsOnPlaintext() const
+ {return true;}
+ unsigned int AuthenticationBlockSize() const
+ {return GetBlockCipher().BlockSize();}
+ void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params);
+ void Resync(const byte *iv, size_t len);
+ size_t AuthenticateBlocks(const byte *data, size_t len);
+ void AuthenticateLastHeaderBlock();
+ void AuthenticateLastConfidentialBlock();
+ void AuthenticateLastFooterBlock(byte *mac, size_t macSize);
+ SymmetricCipher & AccessSymmetricCipher() {return m_ctr;}
+
+ virtual BlockCipher & AccessBlockCipher() =0;
+ virtual int DefaultDigestSize() const =0;
+
+ const BlockCipher & GetBlockCipher() const {return const_cast<CCM_Base *>(this)->AccessBlockCipher();};
+ byte *CBC_Buffer() {return m_buffer+REQUIRED_BLOCKSIZE;}
+
+ enum {REQUIRED_BLOCKSIZE = 16};
+ int m_digestSize, m_L;
+ word64 m_messageLength, m_aadLength;
+ CTR_Mode_ExternalCipher::Encryption m_ctr;
+};
+
+//! .
+template <class T_BlockCipher, int T_DefaultDigestSize, bool T_IsEncryption>
+class CCM_Final : public CCM_Base
+{
+public:
+ static std::string StaticAlgorithmName()
+ {return T_BlockCipher::StaticAlgorithmName() + std::string("/CCM");}
+ bool IsForwardTransformation() const
+ {return T_IsEncryption;}
+
+private:
+ BlockCipher & AccessBlockCipher() {return m_cipher;}
+ int DefaultDigestSize() const {return T_DefaultDigestSize;}
+ typename T_BlockCipher::Encryption m_cipher;
+};
+
+/// <a href="http://www.cryptolounge.org/wiki/CCM">CCM</a>
+template <class T_BlockCipher, int T_DefaultDigestSize = 16>
+struct CCM : public AuthenticatedSymmetricCipherDocumentation
+{
+ typedef CCM_Final<T_BlockCipher, T_DefaultDigestSize, true> Encryption;
+ typedef CCM_Final<T_BlockCipher, T_DefaultDigestSize, false> Decryption;
+};
+
+NAMESPACE_END
+
+#endif
diff --git a/CryptoPP/cmac.cpp b/CryptoPP/cmac.cpp
index e8fa6fea6..a31d5f8b0 100644
--- a/CryptoPP/cmac.cpp
+++ b/CryptoPP/cmac.cpp
@@ -1,122 +1,122 @@
-// cmac.cpp - written and placed in the public domain by Wei Dai
-
-#include "pch.h"
-
-#ifndef CRYPTOPP_IMPORTS
-
-#include "cmac.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-static void MulU(byte *k, unsigned int length)
-{
- byte carry = 0;
-
- for (int i=length-1; i>=1; i-=2)
- {
- byte carry2 = k[i] >> 7;
- k[i] += k[i] + carry;
- carry = k[i-1] >> 7;
- k[i-1] += k[i-1] + carry2;
- }
-
- if (carry)
- {
- switch (length)
- {
- case 8:
- k[7] ^= 0x1b;
- break;
- case 16:
- k[15] ^= 0x87;
- break;
- case 32:
- k[30] ^= 4;
- k[31] ^= 0x23;
- break;
- default:
- throw InvalidArgument("CMAC: " + IntToString(length) + " is not a supported cipher block size");
- }
- }
-}
-
-void CMAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
-{
- BlockCipher &cipher = AccessCipher();
- unsigned int blockSize = cipher.BlockSize();
-
- cipher.SetKey(key, length, params);
- m_reg.CleanNew(3*blockSize);
- m_counter = 0;
-
- cipher.ProcessBlock(m_reg, m_reg+blockSize);
- MulU(m_reg+blockSize, blockSize);
- memcpy(m_reg+2*blockSize, m_reg+blockSize, blockSize);
- MulU(m_reg+2*blockSize, blockSize);
-}
-
-void CMAC_Base::Update(const byte *input, size_t length)
-{
- if (!length)
- return;
-
- BlockCipher &cipher = AccessCipher();
- unsigned int blockSize = cipher.BlockSize();
-
- if (m_counter > 0)
- {
- unsigned int len = UnsignedMin(blockSize - m_counter, length);
- xorbuf(m_reg+m_counter, input, len);
- length -= len;
- input += len;
- m_counter += len;
-
- if (m_counter == blockSize && length > 0)
- {
- cipher.ProcessBlock(m_reg);
- m_counter = 0;
- }
- }
-
- if (length > blockSize)
- {
- assert(m_counter == 0);
- size_t leftOver = 1 + cipher.AdvancedProcessBlocks(m_reg, input, m_reg, length-1, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
- input += (length - leftOver);
- length = leftOver;
- }
-
- if (length > 0)
- {
- assert(m_counter + length <= blockSize);
- xorbuf(m_reg+m_counter, input, length);
- m_counter += (unsigned int)length;
- }
-
- assert(m_counter > 0);
-}
-
-void CMAC_Base::TruncatedFinal(byte *mac, size_t size)
-{
- ThrowIfInvalidTruncatedSize(size);
-
- BlockCipher &cipher = AccessCipher();
- unsigned int blockSize = cipher.BlockSize();
-
- if (m_counter < blockSize)
- {
- m_reg[m_counter] ^= 0x80;
- cipher.AdvancedProcessBlocks(m_reg, m_reg+2*blockSize, m_reg, blockSize, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
- }
- else
- cipher.AdvancedProcessBlocks(m_reg, m_reg+blockSize, m_reg, blockSize, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
-
- memcpy(mac, m_reg, size);
-
- m_counter = 0;
- memset(m_reg, 0, blockSize);
-}
-
-NAMESPACE_END
-
-#endif
+// cmac.cpp - written and placed in the public domain by Wei Dai
+
+#include "pch.h"
+
+#ifndef CRYPTOPP_IMPORTS
+
+#include "cmac.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+static void MulU(byte *k, unsigned int length)
+{
+ byte carry = 0;
+
+ for (int i=length-1; i>=1; i-=2)
+ {
+ byte carry2 = k[i] >> 7;
+ k[i] += k[i] + carry;
+ carry = k[i-1] >> 7;
+ k[i-1] += k[i-1] + carry2;
+ }
+
+ if (carry)
+ {
+ switch (length)
+ {
+ case 8:
+ k[7] ^= 0x1b;
+ break;
+ case 16:
+ k[15] ^= 0x87;
+ break;
+ case 32:
+ k[30] ^= 4;
+ k[31] ^= 0x23;
+ break;
+ default:
+ throw InvalidArgument("CMAC: " + IntToString(length) + " is not a supported cipher block size");
+ }
+ }
+}
+
+void CMAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
+{
+ BlockCipher &cipher = AccessCipher();
+ unsigned int blockSize = cipher.BlockSize();
+
+ cipher.SetKey(key, length, params);
+ m_reg.CleanNew(3*blockSize);
+ m_counter = 0;
+
+ cipher.ProcessBlock(m_reg, m_reg+blockSize);
+ MulU(m_reg+blockSize, blockSize);
+ memcpy(m_reg+2*blockSize, m_reg+blockSize, blockSize);
+ MulU(m_reg+2*blockSize, blockSize);
+}
+
+void CMAC_Base::Update(const byte *input, size_t length)
+{
+ if (!length)
+ return;
+
+ BlockCipher &cipher = AccessCipher();
+ unsigned int blockSize = cipher.BlockSize();
+
+ if (m_counter > 0)
+ {
+ unsigned int len = UnsignedMin(blockSize - m_counter, length);
+ xorbuf(m_reg+m_counter, input, len);
+ length -= len;
+ input += len;
+ m_counter += len;
+
+ if (m_counter == blockSize && length > 0)
+ {
+ cipher.ProcessBlock(m_reg);
+ m_counter = 0;
+ }
+ }
+
+ if (length > blockSize)
+ {
+ assert(m_counter == 0);
+ size_t leftOver = 1 + cipher.AdvancedProcessBlocks(m_reg, input, m_reg, length-1, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
+ input += (length - leftOver);
+ length = leftOver;
+ }
+
+ if (length > 0)
+ {
+ assert(m_counter + length <= blockSize);
+ xorbuf(m_reg+m_counter, input, length);
+ m_counter += (unsigned int)length;
+ }
+
+ assert(m_counter > 0);
+}
+
+void CMAC_Base::TruncatedFinal(byte *mac, size_t size)
+{
+ ThrowIfInvalidTruncatedSize(size);
+
+ BlockCipher &cipher = AccessCipher();
+ unsigned int blockSize = cipher.BlockSize();
+
+ if (m_counter < blockSize)
+ {
+ m_reg[m_counter] ^= 0x80;
+ cipher.AdvancedProcessBlocks(m_reg, m_reg+2*blockSize, m_reg, blockSize, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
+ }
+ else
+ cipher.AdvancedProcessBlocks(m_reg, m_reg+blockSize, m_reg, blockSize, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
+
+ memcpy(mac, m_reg, size);
+
+ m_counter = 0;
+ memset(m_reg, 0, blockSize);
+}
+
+NAMESPACE_END
+
+#endif
diff --git a/CryptoPP/cmac.h b/CryptoPP/cmac.h
index ab3ecf8cc..d8a1b391d 100644
--- a/CryptoPP/cmac.h
+++ b/CryptoPP/cmac.h
@@ -1,52 +1,52 @@
-#ifndef CRYPTOPP_CMAC_H
-#define CRYPTOPP_CMAC_H
-
-#include "seckey.h"
-#include "secblock.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-//! _
-class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CMAC_Base : public MessageAuthenticationCode
-{
-public:
- CMAC_Base() {}
-
- void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
- void Update(const byte *input, size_t length);
- void TruncatedFinal(byte *mac, size_t size);
- unsigned int DigestSize() const {return GetCipher().BlockSize();}
- unsigned int OptimalBlockSize() const {return GetCipher().BlockSize();}
- unsigned int OptimalDataAlignment() const {return GetCipher().OptimalDataAlignment();}
-
-protected:
- friend class EAX_Base;
-
- const BlockCipher & GetCipher() const {return const_cast<CMAC_Base*>(this)->AccessCipher();}
- virtual BlockCipher & AccessCipher() =0;
-
- void ProcessBuf();
- SecByteBlock m_reg;
- unsigned int m_counter;
-};
-
-/// <a href="http://www.cryptolounge.org/wiki/CMAC">CMAC</a>
-/*! Template parameter T should be a class derived from BlockCipherDocumentation, for example AES, with a block size of 8, 16, or 32 */
-template <class T>
-class CMAC : public MessageAuthenticationCodeImpl<CMAC_Base, CMAC<T> >, public SameKeyLengthAs<T>
-{
-public:
- CMAC() {}
- CMAC(const byte *key, size_t length=SameKeyLengthAs<T>::DEFAULT_KEYLENGTH)
- {this->SetKey(key, length);}
-
- static std::string StaticAlgorithmName() {return std::string("CMAC(") + T::StaticAlgorithmName() + ")";}
-
-private:
- BlockCipher & AccessCipher() {return m_cipher;}
- typename T::Encryption m_cipher;
-};
-
-NAMESPACE_END
-
-#endif
+#ifndef CRYPTOPP_CMAC_H
+#define CRYPTOPP_CMAC_H
+
+#include "seckey.h"
+#include "secblock.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! _
+class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CMAC_Base : public MessageAuthenticationCode
+{
+public:
+ CMAC_Base() {}
+
+ void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
+ void Update(const byte *input, size_t length);
+ void TruncatedFinal(byte *mac, size_t size);
+ unsigned int DigestSize() const {return GetCipher().BlockSize();}
+ unsigned int OptimalBlockSize() const {return GetCipher().BlockSize();}
+ unsigned int OptimalDataAlignment() const {return GetCipher().OptimalDataAlignment();}
+
+protected:
+ friend class EAX_Base;
+
+ const BlockCipher & GetCipher() const {return const_cast<CMAC_Base*>(this)->AccessCipher();}
+ virtual BlockCipher & AccessCipher() =0;
+
+ void ProcessBuf();
+ SecByteBlock m_reg;
+ unsigned int m_counter;
+};
+
+/// <a href="http://www.cryptolounge.org/wiki/CMAC">CMAC</a>
+/*! Template parameter T should be a class derived from BlockCipherDocumentation, for example AES, with a block size of 8, 16, or 32 */
+template <class T>
+class CMAC : public MessageAuthenticationCodeImpl<CMAC_Base, CMAC<T> >, public SameKeyLengthAs<T>
+{
+public:
+ CMAC() {}
+ CMAC(const byte *key, size_t length=SameKeyLengthAs<T>::DEFAULT_KEYLENGTH)
+ {this->SetKey(key, length);}
+
+ static std::string StaticAlgorithmName() {return std::string("CMAC(") + T::StaticAlgorithmName() + ")";}
+
+private:
+ BlockCipher & AccessCipher() {return m_cipher;}
+ typename T::Encryption m_cipher;
+};
+
+NAMESPACE_END
+
+#endif
diff --git a/CryptoPP/eax.cpp b/CryptoPP/eax.cpp
index cf836632b..2728c9bcd 100644
--- a/CryptoPP/eax.cpp
+++ b/CryptoPP/eax.cpp
@@ -1,59 +1,59 @@
-// eax.cpp - written and placed in the public domain by Wei Dai
-
-#include "pch.h"
-#include "eax.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-void EAX_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params)
-{
- AccessMAC().SetKey(userKey, keylength, params);
- m_buffer.New(2*AccessMAC().TagSize());
-}
-
-void EAX_Base::Resync(const byte *iv, size_t len)
-{
- MessageAuthenticationCode &mac = AccessMAC();
- unsigned int blockSize = mac.TagSize();
-
- memset(m_buffer, 0, blockSize);
- mac.Update(m_buffer, blockSize);
- mac.CalculateDigest(m_buffer+blockSize, iv, len);
-
- m_buffer[blockSize-1] = 1;
- mac.Update(m_buffer, blockSize);
-
- m_ctr.SetCipherWithIV(AccessMAC().AccessCipher(), m_buffer+blockSize, blockSize);
-}
-
-size_t EAX_Base::AuthenticateBlocks(const byte *data, size_t len)
-{
- AccessMAC().Update(data, len);
- return 0;
-}
-
-void EAX_Base::AuthenticateLastHeaderBlock()
-{
- assert(m_bufferedDataLength == 0);
- MessageAuthenticationCode &mac = AccessMAC();
- unsigned int blockSize = mac.TagSize();
-
- mac.Final(m_buffer);
- xorbuf(m_buffer+blockSize, m_buffer, blockSize);
-
- memset(m_buffer, 0, blockSize);
- m_buffer[blockSize-1] = 2;
- mac.Update(m_buffer, blockSize);
-}
-
-void EAX_Base::AuthenticateLastFooterBlock(byte *tag, size_t macSize)
-{
- assert(m_bufferedDataLength == 0);
- MessageAuthenticationCode &mac = AccessMAC();
- unsigned int blockSize = mac.TagSize();
-
- mac.TruncatedFinal(m_buffer, macSize);
- xorbuf(tag, m_buffer, m_buffer+blockSize, macSize);
-}
-
-NAMESPACE_END
+// eax.cpp - written and placed in the public domain by Wei Dai
+
+#include "pch.h"
+#include "eax.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+void EAX_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params)
+{
+ AccessMAC().SetKey(userKey, keylength, params);
+ m_buffer.New(2*AccessMAC().TagSize());
+}
+
+void EAX_Base::Resync(const byte *iv, size_t len)
+{
+ MessageAuthenticationCode &mac = AccessMAC();
+ unsigned int blockSize = mac.TagSize();
+
+ memset(m_buffer, 0, blockSize);
+ mac.Update(m_buffer, blockSize);
+ mac.CalculateDigest(m_buffer+blockSize, iv, len);
+
+ m_buffer[blockSize-1] = 1;
+ mac.Update(m_buffer, blockSize);
+
+ m_ctr.SetCipherWithIV(AccessMAC().AccessCipher(), m_buffer+blockSize, blockSize);
+}
+
+size_t EAX_Base::AuthenticateBlocks(const byte *data, size_t len)
+{
+ AccessMAC().Update(data, len);
+ return 0;
+}
+
+void EAX_Base::AuthenticateLastHeaderBlock()
+{
+ assert(m_bufferedDataLength == 0);
+ MessageAuthenticationCode &mac = AccessMAC();
+ unsigned int blockSize = mac.TagSize();
+
+ mac.Final(m_buffer);
+ xorbuf(m_buffer+blockSize, m_buffer, blockSize);
+
+ memset(m_buffer, 0, blockSize);
+ m_buffer[blockSize-1] = 2;
+ mac.Update(m_buffer, blockSize);
+}
+
+void EAX_Base::AuthenticateLastFooterBlock(byte *tag, size_t macSize)
+{
+ assert(m_bufferedDataLength == 0);
+ MessageAuthenticationCode &mac = AccessMAC();
+ unsigned int blockSize = mac.TagSize();
+
+ mac.TruncatedFinal(m_buffer, macSize);
+ xorbuf(tag, m_buffer, m_buffer+blockSize, macSize);
+}
+
+NAMESPACE_END
diff --git a/CryptoPP/gcm.cpp b/CryptoPP/gcm.cpp
index 237325d9f..2304f96d8 100644
--- a/CryptoPP/gcm.cpp
+++ b/CryptoPP/gcm.cpp
@@ -1,828 +1,828 @@
-// gcm.cpp - written and placed in the public domain by Wei Dai
-
-// use "cl /EP /P /DCRYPTOPP_GENERATE_X64_MASM gcm.cpp" to generate MASM code
-
-#include "pch.h"
-
-#ifndef CRYPTOPP_IMPORTS
-#ifndef CRYPTOPP_GENERATE_X64_MASM
-
-#include "gcm.h"
-#include "cpu.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-word16 GCM_Base::s_reductionTable[256];
-volatile bool GCM_Base::s_reductionTableInitialized = false;
-
-void GCM_Base::GCTR::IncrementCounterBy256()
-{
- IncrementCounterByOne(m_counterArray+BlockSize()-4, 3);
-}
-
-#if 0
-// preserved for testing
-void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *c)
-{
- word64 Z0=0, Z1=0, V0, V1;
-
- typedef BlockGetAndPut<word64, BigEndian> Block;
- Block::Get(a)(V0)(V1);
-
- for (int i=0; i<16; i++)
- {
- for (int j=0x80; j!=0; j>>=1)
- {
- int x = b[i] & j;
- Z0 ^= x ? V0 : 0;
- Z1 ^= x ? V1 : 0;
- x = (int)V1 & 1;
- V1 = (V1>>1) | (V0<<63);
- V0 = (V0>>1) ^ (x ? W64LIT(0xe1) << 56 : 0);
- }
- }
- Block::Put(NULL, c)(Z0)(Z1);
-}
-
-__m128i _mm_clmulepi64_si128(const __m128i &a, const __m128i &b, int i)
-{
- word64 A[1] = {ByteReverse(((word64*)&a)[i&1])};
- word64 B[1] = {ByteReverse(((word64*)&b)[i>>4])};
-
- PolynomialMod2 pa((byte *)A, 8);
- PolynomialMod2 pb((byte *)B, 8);
- PolynomialMod2 c = pa*pb;
-
- __m128i output;
- for (int i=0; i<16; i++)
- ((byte *)&output)[i] = c.GetByte(i);
- return output;
-}
-#endif
-
-#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
-inline static void SSE2_Xor16(byte *a, const byte *b, const byte *c)
-{
-#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
- *(__m128i *)a = _mm_xor_si128(*(__m128i *)b, *(__m128i *)c);
-#else
- asm ("movdqa %1, %%xmm0; pxor %2, %%xmm0; movdqa %%xmm0, %0;" : "=m" (a[0]) : "m"(b[0]), "m"(c[0]));
-#endif
-}
-#endif
-
-inline static void Xor16(byte *a, const byte *b, const byte *c)
-{
- ((word64 *)a)[0] = ((word64 *)b)[0] ^ ((word64 *)c)[0];
- ((word64 *)a)[1] = ((word64 *)b)[1] ^ ((word64 *)c)[1];
-}
-
-#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
-static CRYPTOPP_ALIGN_DATA(16) const word64 s_clmulConstants64[] = {
- W64LIT(0xe100000000000000), W64LIT(0xc200000000000000),
- W64LIT(0x08090a0b0c0d0e0f), W64LIT(0x0001020304050607),
- W64LIT(0x0001020304050607), W64LIT(0x08090a0b0c0d0e0f)};
-static const __m128i *s_clmulConstants = (const __m128i *)s_clmulConstants64;
-static const unsigned int s_clmulTableSizeInBlocks = 8;
-
-inline __m128i CLMUL_Reduce(__m128i c0, __m128i c1, __m128i c2, const __m128i &r)
-{
- /*
- The polynomial to be reduced is c0 * x^128 + c1 * x^64 + c2. c0t below refers to the most
- significant half of c0 as a polynomial, which, due to GCM's bit reflection, are in the
- rightmost bit positions, and the lowest byte addresses.
-
- c1 ^= c0t * 0xc200000000000000
- c2t ^= c0t
- t = shift (c1t ^ c0b) left 1 bit
- c2 ^= t * 0xe100000000000000
- c2t ^= c1b
- shift c2 left 1 bit and xor in lowest bit of c1t
- */
-#if 0 // MSVC 2010 workaround: see http://connect.microsoft.com/VisualStudio/feedback/details/575301
- c2 = _mm_xor_si128(c2, _mm_move_epi64(c0));
-#else
- c1 = _mm_xor_si128(c1, _mm_slli_si128(c0, 8));
-#endif
- c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(c0, r, 0x10));
- c0 = _mm_srli_si128(c0, 8);
- c0 = _mm_xor_si128(c0, c1);
- c0 = _mm_slli_epi64(c0, 1);
- c0 = _mm_clmulepi64_si128(c0, r, 0);
- c2 = _mm_xor_si128(c2, c0);
- c2 = _mm_xor_si128(c2, _mm_srli_si128(c1, 8));
- c1 = _mm_unpacklo_epi64(c1, c2);
- c1 = _mm_srli_epi64(c1, 63);
- c2 = _mm_slli_epi64(c2, 1);
- return _mm_xor_si128(c2, c1);
-}
-
-inline __m128i CLMUL_GF_Mul(const __m128i &x, const __m128i &h, const __m128i &r)
-{
- __m128i c0 = _mm_clmulepi64_si128(x,h,0);
- __m128i c1 = _mm_xor_si128(_mm_clmulepi64_si128(x,h,1), _mm_clmulepi64_si128(x,h,0x10));
- __m128i c2 = _mm_clmulepi64_si128(x,h,0x11);
-
- return CLMUL_Reduce(c0, c1, c2, r);
-}
-#endif
-
-void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params)
-{
- BlockCipher &blockCipher = AccessBlockCipher();
- blockCipher.SetKey(userKey, keylength, params);
-
- if (blockCipher.BlockSize() != REQUIRED_BLOCKSIZE)
- throw InvalidArgument(AlgorithmName() + ": block size of underlying block cipher is not 16");
-
- int tableSize, i, j, k;
-
-#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
- if (HasCLMUL())
- {
- params.GetIntValue(Name::TableSize(), tableSize); // avoid "parameter not used" error
- tableSize = s_clmulTableSizeInBlocks * REQUIRED_BLOCKSIZE;
- }
- else
-#endif
- {
- if (params.GetIntValue(Name::TableSize(), tableSize))
- tableSize = (tableSize >= 64*1024) ? 64*1024 : 2*1024;
- else
- tableSize = (GetTablesOption() == GCM_64K_Tables) ? 64*1024 : 2*1024;
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1300 && _MSC_VER < 1400)
- // VC 2003 workaround: compiler generates bad code for 64K tables
- tableSize = 2*1024;
-#endif
- }
-
- m_buffer.resize(3*REQUIRED_BLOCKSIZE + tableSize);
- byte *table = MulTable();
- byte *hashKey = HashKey();
- memset(hashKey, 0, REQUIRED_BLOCKSIZE);
- blockCipher.ProcessBlock(hashKey);
-
-#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
- if (HasCLMUL())
- {
- const __m128i r = s_clmulConstants[0];
- __m128i h0 = _mm_shuffle_epi8(_mm_load_si128((__m128i *)hashKey), s_clmulConstants[1]);
- __m128i h = h0;
-
- for (i=0; i<tableSize; i+=32)
- {
- __m128i h1 = CLMUL_GF_Mul(h, h0, r);
- _mm_storel_epi64((__m128i *)(table+i), h);
- _mm_storeu_si128((__m128i *)(table+i+16), h1);
- _mm_storeu_si128((__m128i *)(table+i+8), h);
- _mm_storel_epi64((__m128i *)(table+i+8), h1);
- h = CLMUL_GF_Mul(h1, h0, r);
- }
-
- return;
- }
-#endif
-
- word64 V0, V1;
- typedef BlockGetAndPut<word64, BigEndian> Block;
- Block::Get(hashKey)(V0)(V1);
-
- if (tableSize == 64*1024)
- {
- for (i=0; i<128; i++)
- {
- k = i%8;
- Block::Put(NULL, table+(i/8)*256*16+(size_t(1)<<(11-k)))(V0)(V1);
-
- int x = (int)V1 & 1;
- V1 = (V1>>1) | (V0<<63);
- V0 = (V0>>1) ^ (x ? W64LIT(0xe1) << 56 : 0);
- }
-
- for (i=0; i<16; i++)
- {
- memset(table+i*256*16, 0, 16);
-#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
- if (HasSSE2())
- for (j=2; j<=0x80; j*=2)
- for (k=1; k<j; k++)
- SSE2_Xor16(table+i*256*16+(j+k)*16, table+i*256*16+j*16, table+i*256*16+k*16);
- else
-#endif
- for (j=2; j<=0x80; j*=2)
- for (k=1; k<j; k++)
- Xor16(table+i*256*16+(j+k)*16, table+i*256*16+j*16, table+i*256*16+k*16);
- }
- }
- else
- {
- if (!s_reductionTableInitialized)
- {
- s_reductionTable[0] = 0;
- word16 x = 0x01c2;
- s_reductionTable[1] = ByteReverse(x);
- for (int i=2; i<=0x80; i*=2)
- {
- x <<= 1;
- s_reductionTable[i] = ByteReverse(x);
- for (int j=1; j<i; j++)
- s_reductionTable[i+j] = s_reductionTable[i] ^ s_reductionTable[j];
- }
- s_reductionTableInitialized = true;
- }
-
- for (i=0; i<128-24; i++)
- {
- k = i%32;
- if (k < 4)
- Block::Put(NULL, table+1024+(i/32)*256+(size_t(1)<<(7-k)))(V0)(V1);
- else if (k < 8)
- Block::Put(NULL, table+(i/32)*256+(size_t(1)<<(11-k)))(V0)(V1);
-
- int x = (int)V1 & 1;
- V1 = (V1>>1) | (V0<<63);
- V0 = (V0>>1) ^ (x ? W64LIT(0xe1) << 56 : 0);
- }
-
- for (i=0; i<4; i++)
- {
- memset(table+i*256, 0, 16);
- memset(table+1024+i*256, 0, 16);
-#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
- if (HasSSE2())
- for (j=2; j<=8; j*=2)
- for (k=1; k<j; k++)
- {
- SSE2_Xor16(table+i*256+(j+k)*16, table+i*256+j*16, table+i*256+k*16);
- SSE2_Xor16(table+1024+i*256+(j+k)*16, table+1024+i*256+j*16, table+1024+i*256+k*16);
- }
- else
-#endif
- for (j=2; j<=8; j*=2)
- for (k=1; k<j; k++)
- {
- Xor16(table+i*256+(j+k)*16, table+i*256+j*16, table+i*256+k*16);
- Xor16(table+1024+i*256+(j+k)*16, table+1024+i*256+j*16, table+1024+i*256+k*16);
- }
- }
- }
-}
-
-inline void GCM_Base::ReverseHashBufferIfNeeded()
-{
-#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
- if (HasCLMUL())
- {
- __m128i &x = *(__m128i *)HashBuffer();
- x = _mm_shuffle_epi8(x, s_clmulConstants[1]);
- }
-#endif
-}
-
-void GCM_Base::Resync(const byte *iv, size_t len)
-{
- BlockCipher &cipher = AccessBlockCipher();
- byte *hashBuffer = HashBuffer();
-
- if (len == 12)
- {
- memcpy(hashBuffer, iv, len);
- memset(hashBuffer+len, 0, 3);
- hashBuffer[len+3] = 1;
- }
- else
- {
- size_t origLen = len;
- memset(hashBuffer, 0, HASH_BLOCKSIZE);
-
- if (len >= HASH_BLOCKSIZE)
- {
- len = GCM_Base::AuthenticateBlocks(iv, len);
- iv += (origLen - len);
- }
-
- if (len > 0)
- {
- memcpy(m_buffer, iv, len);
- memset(m_buffer+len, 0, HASH_BLOCKSIZE-len);
- GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
- }
-
- PutBlock<word64, BigEndian, true>(NULL, m_buffer)(0)(origLen*8);
- GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
-
- ReverseHashBufferIfNeeded();
- }
-
- if (m_state >= State_IVSet)
- m_ctr.Resynchronize(hashBuffer, REQUIRED_BLOCKSIZE);
- else
- m_ctr.SetCipherWithIV(cipher, hashBuffer);
-
- m_ctr.Seek(HASH_BLOCKSIZE);
-
- memset(hashBuffer, 0, HASH_BLOCKSIZE);
-}
-
-unsigned int GCM_Base::OptimalDataAlignment() const
-{
- return
-#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
- HasSSE2() ? 16 :
-#endif
- GetBlockCipher().OptimalDataAlignment();
-}
-
-#pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code
-
-#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
-
-#ifdef CRYPTOPP_X64_MASM_AVAILABLE
-extern "C" {
-void GCM_AuthenticateBlocks_2K(const byte *data, size_t blocks, word64 *hashBuffer, const word16 *reductionTable);
-void GCM_AuthenticateBlocks_64K(const byte *data, size_t blocks, word64 *hashBuffer);
-}
-#endif
-
-#ifndef CRYPTOPP_GENERATE_X64_MASM
-
-size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
-{
-#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
- if (HasCLMUL())
- {
- const __m128i *table = (const __m128i *)MulTable();
- __m128i x = _mm_load_si128((__m128i *)HashBuffer());
- const __m128i r = s_clmulConstants[0], bswapMask = s_clmulConstants[1], bswapMask2 = s_clmulConstants[2];
-
- while (len >= 16)
- {
- size_t s = UnsignedMin(len/16, s_clmulTableSizeInBlocks), i=0;
- __m128i d, d2 = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)(data+(s-1)*16)), bswapMask2);;
- __m128i c0 = _mm_setzero_si128();
- __m128i c1 = _mm_setzero_si128();
- __m128i c2 = _mm_setzero_si128();
-
- while (true)
- {
- __m128i h0 = _mm_load_si128(table+i);
- __m128i h1 = _mm_load_si128(table+i+1);
- __m128i h01 = _mm_xor_si128(h0, h1);
-
- if (++i == s)
- {
- d = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)data), bswapMask);
- d = _mm_xor_si128(d, x);
- c0 = _mm_xor_si128(c0, _mm_clmulepi64_si128(d, h0, 0));
- c2 = _mm_xor_si128(c2, _mm_clmulepi64_si128(d, h1, 1));
- d = _mm_xor_si128(d, _mm_shuffle_epi32(d, _MM_SHUFFLE(1, 0, 3, 2)));
- c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(d, h01, 0));
- break;
- }
-
- d = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)(data+(s-i)*16-8)), bswapMask2);
- c0 = _mm_xor_si128(c0, _mm_clmulepi64_si128(d2, h0, 1));
- c2 = _mm_xor_si128(c2, _mm_clmulepi64_si128(d, h1, 1));
- d2 = _mm_xor_si128(d2, d);
- c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(d2, h01, 1));
-
- if (++i == s)
- {
- d = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)data), bswapMask);
- d = _mm_xor_si128(d, x);
- c0 = _mm_xor_si128(c0, _mm_clmulepi64_si128(d, h0, 0x10));
- c2 = _mm_xor_si128(c2, _mm_clmulepi64_si128(d, h1, 0x11));
- d = _mm_xor_si128(d, _mm_shuffle_epi32(d, _MM_SHUFFLE(1, 0, 3, 2)));
- c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(d, h01, 0x10));
- break;
- }
-
- d2 = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)(data+(s-i)*16-8)), bswapMask);
- c0 = _mm_xor_si128(c0, _mm_clmulepi64_si128(d, h0, 0x10));
- c2 = _mm_xor_si128(c2, _mm_clmulepi64_si128(d2, h1, 0x10));
- d = _mm_xor_si128(d, d2);
- c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(d, h01, 0x10));
- }
- data += s*16;
- len -= s*16;
-
- c1 = _mm_xor_si128(_mm_xor_si128(c1, c0), c2);
- x = CLMUL_Reduce(c0, c1, c2, r);
- }
-
- _mm_store_si128((__m128i *)HashBuffer(), x);
- return len;
- }
-#endif
-
- typedef BlockGetAndPut<word64, NativeByteOrder> Block;
- word64 *hashBuffer = (word64 *)HashBuffer();
-
- switch (2*(m_buffer.size()>=64*1024)
-#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
- + HasSSE2()
-#endif
- )
- {
- case 0: // non-SSE2 and 2K tables
- {
- byte *table = MulTable();
- word64 x0 = hashBuffer[0], x1 = hashBuffer[1];
-
- do
- {
- word64 y0, y1, a0, a1, b0, b1, c0, c1, d0, d1;
- Block::Get(data)(y0)(y1);
- x0 ^= y0;
- x1 ^= y1;
-
- data += HASH_BLOCKSIZE;
- len -= HASH_BLOCKSIZE;
-
- #define READ_TABLE_WORD64_COMMON(a, b, c, d) *(word64 *)(table+(a*1024)+(b*256)+c+d*8)
-
- #ifdef IS_LITTLE_ENDIAN
- #if CRYPTOPP_BOOL_SLOW_WORD64
- word32 z0 = (word32)x0;
- word32 z1 = (word32)(x0>>32);
- word32 z2 = (word32)x1;
- word32 z3 = (word32)(x1>>32);
- #define READ_TABLE_WORD64(a, b, c, d, e) READ_TABLE_WORD64_COMMON((d%2), c, (d?(z##c>>((d?d-1:0)*4))&0xf0:(z##c&0xf)<<4), e)
- #else
- #define READ_TABLE_WORD64(a, b, c, d, e) READ_TABLE_WORD64_COMMON((d%2), c, ((d+8*b)?(x##a>>(((d+8*b)?(d+8*b)-1:1)*4))&0xf0:(x##a&0xf)<<4), e)
- #endif
- #define GF_MOST_SIG_8BITS(a) (a##1 >> 7*8)
- #define GF_SHIFT_8(a) a##1 = (a##1 << 8) ^ (a##0 >> 7*8); a##0 <<= 8;
- #else
- #define READ_TABLE_WORD64(a, b, c, d, e) READ_TABLE_WORD64_COMMON((1-d%2), c, ((15-d-8*b)?(x##a>>(((15-d-8*b)?(15-d-8*b)-1:0)*4))&0xf0:(x##a&0xf)<<4), e)
- #define GF_MOST_SIG_8BITS(a) (a##1 & 0xff)
- #define GF_SHIFT_8(a) a##1 = (a##1 >> 8) ^ (a##0 << 7*8); a##0 >>= 8;
- #endif
-
- #define GF_MUL_32BY128(op, a, b, c) \
- a0 op READ_TABLE_WORD64(a, b, c, 0, 0) ^ READ_TABLE_WORD64(a, b, c, 1, 0);\
- a1 op READ_TABLE_WORD64(a, b, c, 0, 1) ^ READ_TABLE_WORD64(a, b, c, 1, 1);\
- b0 op READ_TABLE_WORD64(a, b, c, 2, 0) ^ READ_TABLE_WORD64(a, b, c, 3, 0);\
- b1 op READ_TABLE_WORD64(a, b, c, 2, 1) ^ READ_TABLE_WORD64(a, b, c, 3, 1);\
- c0 op READ_TABLE_WORD64(a, b, c, 4, 0) ^ READ_TABLE_WORD64(a, b, c, 5, 0);\
- c1 op READ_TABLE_WORD64(a, b, c, 4, 1) ^ READ_TABLE_WORD64(a, b, c, 5, 1);\
- d0 op READ_TABLE_WORD64(a, b, c, 6, 0) ^ READ_TABLE_WORD64(a, b, c, 7, 0);\
- d1 op READ_TABLE_WORD64(a, b, c, 6, 1) ^ READ_TABLE_WORD64(a, b, c, 7, 1);\
-
- GF_MUL_32BY128(=, 0, 0, 0)
- GF_MUL_32BY128(^=, 0, 1, 1)
- GF_MUL_32BY128(^=, 1, 0, 2)
- GF_MUL_32BY128(^=, 1, 1, 3)
-
- word32 r = (word32)s_reductionTable[GF_MOST_SIG_8BITS(d)] << 16;
- GF_SHIFT_8(d)
- c0 ^= d0; c1 ^= d1;
- r ^= (word32)s_reductionTable[GF_MOST_SIG_8BITS(c)] << 8;
- GF_SHIFT_8(c)
- b0 ^= c0; b1 ^= c1;
- r ^= s_reductionTable[GF_MOST_SIG_8BITS(b)];
- GF_SHIFT_8(b)
- a0 ^= b0; a1 ^= b1;
- a0 ^= ConditionalByteReverse<word64>(LITTLE_ENDIAN_ORDER, r);
- x0 = a0; x1 = a1;
- }
- while (len >= HASH_BLOCKSIZE);
-
- hashBuffer[0] = x0; hashBuffer[1] = x1;
- return len;
- }
-
- case 2: // non-SSE2 and 64K tables
- {
- byte *table = MulTable();
- word64 x0 = hashBuffer[0], x1 = hashBuffer[1];
-
- do
- {
- word64 y0, y1, a0, a1;
- Block::Get(data)(y0)(y1);
- x0 ^= y0;
- x1 ^= y1;
-
- data += HASH_BLOCKSIZE;
- len -= HASH_BLOCKSIZE;
-
- #undef READ_TABLE_WORD64_COMMON
- #undef READ_TABLE_WORD64
-
- #define READ_TABLE_WORD64_COMMON(a, c, d) *(word64 *)(table+(a)*256*16+(c)+(d)*8)
-
- #ifdef IS_LITTLE_ENDIAN
- #if CRYPTOPP_BOOL_SLOW_WORD64
- word32 z0 = (word32)x0;
- word32 z1 = (word32)(x0>>32);
- word32 z2 = (word32)x1;
- word32 z3 = (word32)(x1>>32);
- #define READ_TABLE_WORD64(b, c, d, e) READ_TABLE_WORD64_COMMON(c*4+d, (d?(z##c>>((d?d:1)*8-4))&0xff0:(z##c&0xff)<<4), e)
- #else
- #define READ_TABLE_WORD64(b, c, d, e) READ_TABLE_WORD64_COMMON(c*4+d, ((d+4*(c%2))?(x##b>>(((d+4*(c%2))?(d+4*(c%2)):1)*8-4))&0xff0:(x##b&0xff)<<4), e)
- #endif
- #else
- #define READ_TABLE_WORD64(b, c, d, e) READ_TABLE_WORD64_COMMON(c*4+d, ((7-d-4*(c%2))?(x##b>>(((7-d-4*(c%2))?(7-d-4*(c%2)):1)*8-4))&0xff0:(x##b&0xff)<<4), e)
- #endif
-
- #define GF_MUL_8BY128(op, b, c, d) \
- a0 op READ_TABLE_WORD64(b, c, d, 0);\
- a1 op READ_TABLE_WORD64(b, c, d, 1);\
-
- GF_MUL_8BY128(=, 0, 0, 0)
- GF_MUL_8BY128(^=, 0, 0, 1)
- GF_MUL_8BY128(^=, 0, 0, 2)
- GF_MUL_8BY128(^=, 0, 0, 3)
- GF_MUL_8BY128(^=, 0, 1, 0)
- GF_MUL_8BY128(^=, 0, 1, 1)
- GF_MUL_8BY128(^=, 0, 1, 2)
- GF_MUL_8BY128(^=, 0, 1, 3)
- GF_MUL_8BY128(^=, 1, 2, 0)
- GF_MUL_8BY128(^=, 1, 2, 1)
- GF_MUL_8BY128(^=, 1, 2, 2)
- GF_MUL_8BY128(^=, 1, 2, 3)
- GF_MUL_8BY128(^=, 1, 3, 0)
- GF_MUL_8BY128(^=, 1, 3, 1)
- GF_MUL_8BY128(^=, 1, 3, 2)
- GF_MUL_8BY128(^=, 1, 3, 3)
-
- x0 = a0; x1 = a1;
- }
- while (len >= HASH_BLOCKSIZE);
-
- hashBuffer[0] = x0; hashBuffer[1] = x1;
- return len;
- }
-#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
-
-#ifdef CRYPTOPP_X64_MASM_AVAILABLE
- case 1: // SSE2 and 2K tables
- GCM_AuthenticateBlocks_2K(data, len/16, hashBuffer, s_reductionTable);
- return len % 16;
- case 3: // SSE2 and 64K tables
- GCM_AuthenticateBlocks_64K(data, len/16, hashBuffer);
- return len % 16;
-#endif
-
-#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
- case 1: // SSE2 and 2K tables
- {
- #ifdef __GNUC__
- __asm__ __volatile__
- (
- ".intel_syntax noprefix;"
- #elif defined(CRYPTOPP_GENERATE_X64_MASM)
- ALIGN 8
- GCM_AuthenticateBlocks_2K PROC FRAME
- rex_push_reg rsi
- push_reg rdi
- push_reg rbx
- .endprolog
- mov rsi, r8
- mov r11, r9
- #else
- AS2( mov WORD_REG(cx), data )
- AS2( mov WORD_REG(dx), len )
- AS2( mov WORD_REG(si), hashBuffer )
- AS2( shr WORD_REG(dx), 4 )
- #endif
-
- AS_PUSH_IF86( bx)
- AS_PUSH_IF86( bp)
-
- #ifdef __GNUC__
- AS2( mov AS_REG_7, WORD_REG(di))
- #elif CRYPTOPP_BOOL_X86
- AS2( lea AS_REG_7, s_reductionTable)
- #endif
-
- AS2( movdqa xmm0, [WORD_REG(si)] )
-
- #define MUL_TABLE_0 WORD_REG(si) + 32
- #define MUL_TABLE_1 WORD_REG(si) + 32 + 1024
- #define RED_TABLE AS_REG_7
-
- ASL(0)
- AS2( movdqu xmm4, [WORD_REG(cx)] )
- AS2( pxor xmm0, xmm4 )
-
- AS2( movd ebx, xmm0 )
- AS2( mov eax, AS_HEX(f0f0f0f0) )
- AS2( and eax, ebx )
- AS2( shl ebx, 4 )
- AS2( and ebx, AS_HEX(f0f0f0f0) )
- AS2( movzx edi, ah )
- AS2( movdqa xmm5, XMMWORD_PTR [MUL_TABLE_1 + WORD_REG(di)] )
- AS2( movzx edi, al )
- AS2( movdqa xmm4, XMMWORD_PTR [MUL_TABLE_1 + WORD_REG(di)] )
- AS2( shr eax, 16 )
- AS2( movzx edi, ah )
- AS2( movdqa xmm3, XMMWORD_PTR [MUL_TABLE_1 + WORD_REG(di)] )
- AS2( movzx edi, al )
- AS2( movdqa xmm2, XMMWORD_PTR [MUL_TABLE_1 + WORD_REG(di)] )
-
- #define SSE2_MUL_32BITS(i) \
- AS2( psrldq xmm0, 4 )\
- AS2( movd eax, xmm0 )\
- AS2( and eax, AS_HEX(f0f0f0f0) )\
- AS2( movzx edi, bh )\
- AS2( pxor xmm5, XMMWORD_PTR [MUL_TABLE_0 + (i-1)*256 + WORD_REG(di)] )\
- AS2( movzx edi, bl )\
- AS2( pxor xmm4, XMMWORD_PTR [MUL_TABLE_0 + (i-1)*256 + WORD_REG(di)] )\
- AS2( shr ebx, 16 )\
- AS2( movzx edi, bh )\
- AS2( pxor xmm3, XMMWORD_PTR [MUL_TABLE_0 + (i-1)*256 + WORD_REG(di)] )\
- AS2( movzx edi, bl )\
- AS2( pxor xmm2, XMMWORD_PTR [MUL_TABLE_0 + (i-1)*256 + WORD_REG(di)] )\
- AS2( movd ebx, xmm0 )\
- AS2( shl ebx, 4 )\
- AS2( and ebx, AS_HEX(f0f0f0f0) )\
- AS2( movzx edi, ah )\
- AS2( pxor xmm5, XMMWORD_PTR [MUL_TABLE_1 + i*256 + WORD_REG(di)] )\
- AS2( movzx edi, al )\
- AS2( pxor xmm4, XMMWORD_PTR [MUL_TABLE_1 + i*256 + WORD_REG(di)] )\
- AS2( shr eax, 16 )\
- AS2( movzx edi, ah )\
- AS2( pxor xmm3, XMMWORD_PTR [MUL_TABLE_1 + i*256 + WORD_REG(di)] )\
- AS2( movzx edi, al )\
- AS2( pxor xmm2, XMMWORD_PTR [MUL_TABLE_1 + i*256 + WORD_REG(di)] )\
-
- SSE2_MUL_32BITS(1)
- SSE2_MUL_32BITS(2)
- SSE2_MUL_32BITS(3)
-
- AS2( movzx edi, bh )
- AS2( pxor xmm5, XMMWORD_PTR [MUL_TABLE_0 + 3*256 + WORD_REG(di)] )
- AS2( movzx edi, bl )
- AS2( pxor xmm4, XMMWORD_PTR [MUL_TABLE_0 + 3*256 + WORD_REG(di)] )
- AS2( shr ebx, 16 )
- AS2( movzx edi, bh )
- AS2( pxor xmm3, XMMWORD_PTR [MUL_TABLE_0 + 3*256 + WORD_REG(di)] )
- AS2( movzx edi, bl )
- AS2( pxor xmm2, XMMWORD_PTR [MUL_TABLE_0 + 3*256 + WORD_REG(di)] )
-
- AS2( movdqa xmm0, xmm3 )
- AS2( pslldq xmm3, 1 )
- AS2( pxor xmm2, xmm3 )
- AS2( movdqa xmm1, xmm2 )
- AS2( pslldq xmm2, 1 )
- AS2( pxor xmm5, xmm2 )
-
- AS2( psrldq xmm0, 15 )
- AS2( movd WORD_REG(di), xmm0 )
- AS2( movzx eax, WORD PTR [RED_TABLE + WORD_REG(di)*2] )
- AS2( shl eax, 8 )
-
- AS2( movdqa xmm0, xmm5 )
- AS2( pslldq xmm5, 1 )
- AS2( pxor xmm4, xmm5 )
-
- AS2( psrldq xmm1, 15 )
- AS2( movd WORD_REG(di), xmm1 )
- AS2( xor ax, WORD PTR [RED_TABLE + WORD_REG(di)*2] )
- AS2( shl eax, 8 )
-
- AS2( psrldq xmm0, 15 )
- AS2( movd WORD_REG(di), xmm0 )
- AS2( xor ax, WORD PTR [RED_TABLE + WORD_REG(di)*2] )
-
- AS2( movd xmm0, eax )
- AS2( pxor xmm0, xmm4 )
-
- AS2( add WORD_REG(cx), 16 )
- AS2( sub WORD_REG(dx), 1 )
- ASJ( jnz, 0, b )
- AS2( movdqa [WORD_REG(si)], xmm0 )
-
- AS_POP_IF86( bp)
- AS_POP_IF86( bx)
-
- #ifdef __GNUC__
- ".att_syntax prefix;"
- :
- : "c" (data), "d" (len/16), "S" (hashBuffer), "D" (s_reductionTable)
- : "memory", "cc", "%eax"
- #if CRYPTOPP_BOOL_X64
- , "%ebx", "%r11"
- #endif
- );
- #elif defined(CRYPTOPP_GENERATE_X64_MASM)
- pop rbx
- pop rdi
- pop rsi
- ret
- GCM_AuthenticateBlocks_2K ENDP
- #endif
-
- return len%16;
- }
- case 3: // SSE2 and 64K tables
- {
- #ifdef __GNUC__
- __asm__ __volatile__
- (
- ".intel_syntax noprefix;"
- #elif defined(CRYPTOPP_GENERATE_X64_MASM)
- ALIGN 8
- GCM_AuthenticateBlocks_64K PROC FRAME
- rex_push_reg rsi
- push_reg rdi
- .endprolog
- mov rsi, r8
- #else
- AS2( mov WORD_REG(cx), data )
- AS2( mov WORD_REG(dx), len )
- AS2( mov WORD_REG(si), hashBuffer )
- AS2( shr WORD_REG(dx), 4 )
- #endif
-
- AS2( movdqa xmm0, [WORD_REG(si)] )
-
- #undef MUL_TABLE
- #define MUL_TABLE(i,j) WORD_REG(si) + 32 + (i*4+j)*256*16
-
- ASL(1)
- AS2( movdqu xmm1, [WORD_REG(cx)] )
- AS2( pxor xmm1, xmm0 )
- AS2( pxor xmm0, xmm0 )
-
- #undef SSE2_MUL_32BITS
- #define SSE2_MUL_32BITS(i) \
- AS2( movd eax, xmm1 )\
- AS2( psrldq xmm1, 4 )\
- AS2( movzx edi, al )\
- AS2( add WORD_REG(di), WORD_REG(di) )\
- AS2( pxor xmm0, [MUL_TABLE(i,0) + WORD_REG(di)*8] )\
- AS2( movzx edi, ah )\
- AS2( add WORD_REG(di), WORD_REG(di) )\
- AS2( pxor xmm0, [MUL_TABLE(i,1) + WORD_REG(di)*8] )\
- AS2( shr eax, 16 )\
- AS2( movzx edi, al )\
- AS2( add WORD_REG(di), WORD_REG(di) )\
- AS2( pxor xmm0, [MUL_TABLE(i,2) + WORD_REG(di)*8] )\
- AS2( movzx edi, ah )\
- AS2( add WORD_REG(di), WORD_REG(di) )\
- AS2( pxor xmm0, [MUL_TABLE(i,3) + WORD_REG(di)*8] )\
-
- SSE2_MUL_32BITS(0)
- SSE2_MUL_32BITS(1)
- SSE2_MUL_32BITS(2)
- SSE2_MUL_32BITS(3)
-
- AS2( add WORD_REG(cx), 16 )
- AS2( sub WORD_REG(dx), 1 )
- ASJ( jnz, 1, b )
- AS2( movdqa [WORD_REG(si)], xmm0 )
-
- #ifdef __GNUC__
- ".att_syntax prefix;"
- :
- : "c" (data), "d" (len/16), "S" (hashBuffer)
- : "memory", "cc", "%edi", "%eax"
- );
- #elif defined(CRYPTOPP_GENERATE_X64_MASM)
- pop rdi
- pop rsi
- ret
- GCM_AuthenticateBlocks_64K ENDP
- #endif
-
- return len%16;
- }
-#endif
-#ifndef CRYPTOPP_GENERATE_X64_MASM
- }
-
- return len%16;
-}
-
-void GCM_Base::AuthenticateLastHeaderBlock()
-{
- if (m_bufferedDataLength > 0)
- {
- memset(m_buffer+m_bufferedDataLength, 0, HASH_BLOCKSIZE-m_bufferedDataLength);
- m_bufferedDataLength = 0;
- GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
- }
-}
-
-void GCM_Base::AuthenticateLastConfidentialBlock()
-{
- GCM_Base::AuthenticateLastHeaderBlock();
- PutBlock<word64, BigEndian, true>(NULL, m_buffer)(m_totalHeaderLength*8)(m_totalMessageLength*8);
- GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
-}
-
-void GCM_Base::AuthenticateLastFooterBlock(byte *mac, size_t macSize)
-{
- m_ctr.Seek(0);
- ReverseHashBufferIfNeeded();
- m_ctr.ProcessData(mac, HashBuffer(), macSize);
-}
-
-NAMESPACE_END
-
-#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
-#endif
+// gcm.cpp - written and placed in the public domain by Wei Dai
+
+// use "cl /EP /P /DCRYPTOPP_GENERATE_X64_MASM gcm.cpp" to generate MASM code
+
+#include "pch.h"
+
+#ifndef CRYPTOPP_IMPORTS
+#ifndef CRYPTOPP_GENERATE_X64_MASM
+
+#include "gcm.h"
+#include "cpu.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+word16 GCM_Base::s_reductionTable[256];
+volatile bool GCM_Base::s_reductionTableInitialized = false;
+
+void GCM_Base::GCTR::IncrementCounterBy256()
+{
+ IncrementCounterByOne(m_counterArray+BlockSize()-4, 3);
+}
+
+#if 0
+// preserved for testing
+void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *c)
+{
+ word64 Z0=0, Z1=0, V0, V1;
+
+ typedef BlockGetAndPut<word64, BigEndian> Block;
+ Block::Get(a)(V0)(V1);
+
+ for (int i=0; i<16; i++)
+ {
+ for (int j=0x80; j!=0; j>>=1)
+ {
+ int x = b[i] & j;
+ Z0 ^= x ? V0 : 0;
+ Z1 ^= x ? V1 : 0;
+ x = (int)V1 & 1;
+ V1 = (V1>>1) | (V0<<63);
+ V0 = (V0>>1) ^ (x ? W64LIT(0xe1) << 56 : 0);
+ }
+ }
+ Block::Put(NULL, c)(Z0)(Z1);
+}
+
+__m128i _mm_clmulepi64_si128(const __m128i &a, const __m128i &b, int i)
+{
+ word64 A[1] = {ByteReverse(((word64*)&a)[i&1])};
+ word64 B[1] = {ByteReverse(((word64*)&b)[i>>4])};
+
+ PolynomialMod2 pa((byte *)A, 8);
+ PolynomialMod2 pb((byte *)B, 8);
+ PolynomialMod2 c = pa*pb;
+
+ __m128i output;
+ for (int i=0; i<16; i++)
+ ((byte *)&output)[i] = c.GetByte(i);
+ return output;
+}
+#endif
+
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
+inline static void SSE2_Xor16(byte *a, const byte *b, const byte *c)
+{
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
+ *(__m128i *)a = _mm_xor_si128(*(__m128i *)b, *(__m128i *)c);
+#else
+ asm ("movdqa %1, %%xmm0; pxor %2, %%xmm0; movdqa %%xmm0, %0;" : "=m" (a[0]) : "m"(b[0]), "m"(c[0]));
+#endif
+}
+#endif
+
+inline static void Xor16(byte *a, const byte *b, const byte *c)
+{
+ ((word64 *)a)[0] = ((word64 *)b)[0] ^ ((word64 *)c)[0];
+ ((word64 *)a)[1] = ((word64 *)b)[1] ^ ((word64 *)c)[1];
+}
+
+#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
+static CRYPTOPP_ALIGN_DATA(16) const word64 s_clmulConstants64[] = {
+ W64LIT(0xe100000000000000), W64LIT(0xc200000000000000),
+ W64LIT(0x08090a0b0c0d0e0f), W64LIT(0x0001020304050607),
+ W64LIT(0x0001020304050607), W64LIT(0x08090a0b0c0d0e0f)};
+static const __m128i *s_clmulConstants = (const __m128i *)s_clmulConstants64;
+static const unsigned int s_clmulTableSizeInBlocks = 8;
+
+inline __m128i CLMUL_Reduce(__m128i c0, __m128i c1, __m128i c2, const __m128i &r)
+{
+ /*
+ The polynomial to be reduced is c0 * x^128 + c1 * x^64 + c2. c0t below refers to the most
+ significant half of c0 as a polynomial, which, due to GCM's bit reflection, are in the
+ rightmost bit positions, and the lowest byte addresses.
+
+ c1 ^= c0t * 0xc200000000000000
+ c2t ^= c0t
+ t = shift (c1t ^ c0b) left 1 bit
+ c2 ^= t * 0xe100000000000000
+ c2t ^= c1b
+ shift c2 left 1 bit and xor in lowest bit of c1t
+ */
+#if 0 // MSVC 2010 workaround: see http://connect.microsoft.com/VisualStudio/feedback/details/575301
+ c2 = _mm_xor_si128(c2, _mm_move_epi64(c0));
+#else
+ c1 = _mm_xor_si128(c1, _mm_slli_si128(c0, 8));
+#endif
+ c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(c0, r, 0x10));
+ c0 = _mm_srli_si128(c0, 8);
+ c0 = _mm_xor_si128(c0, c1);
+ c0 = _mm_slli_epi64(c0, 1);
+ c0 = _mm_clmulepi64_si128(c0, r, 0);
+ c2 = _mm_xor_si128(c2, c0);
+ c2 = _mm_xor_si128(c2, _mm_srli_si128(c1, 8));
+ c1 = _mm_unpacklo_epi64(c1, c2);
+ c1 = _mm_srli_epi64(c1, 63);
+ c2 = _mm_slli_epi64(c2, 1);
+ return _mm_xor_si128(c2, c1);
+}
+
+inline __m128i CLMUL_GF_Mul(const __m128i &x, const __m128i &h, const __m128i &r)
+{
+ __m128i c0 = _mm_clmulepi64_si128(x,h,0);
+ __m128i c1 = _mm_xor_si128(_mm_clmulepi64_si128(x,h,1), _mm_clmulepi64_si128(x,h,0x10));
+ __m128i c2 = _mm_clmulepi64_si128(x,h,0x11);
+
+ return CLMUL_Reduce(c0, c1, c2, r);
+}
+#endif
+
+void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params)
+{
+ BlockCipher &blockCipher = AccessBlockCipher();
+ blockCipher.SetKey(userKey, keylength, params);
+
+ if (blockCipher.BlockSize() != REQUIRED_BLOCKSIZE)
+ throw InvalidArgument(AlgorithmName() + ": block size of underlying block cipher is not 16");
+
+ int tableSize, i, j, k;
+
+#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
+ if (HasCLMUL())
+ {
+ params.GetIntValue(Name::TableSize(), tableSize); // avoid "parameter not used" error
+ tableSize = s_clmulTableSizeInBlocks * REQUIRED_BLOCKSIZE;
+ }
+ else
+#endif
+ {
+ if (params.GetIntValue(Name::TableSize(), tableSize))
+ tableSize = (tableSize >= 64*1024) ? 64*1024 : 2*1024;
+ else
+ tableSize = (GetTablesOption() == GCM_64K_Tables) ? 64*1024 : 2*1024;
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300 && _MSC_VER < 1400)
+ // VC 2003 workaround: compiler generates bad code for 64K tables
+ tableSize = 2*1024;
+#endif
+ }
+
+ m_buffer.resize(3*REQUIRED_BLOCKSIZE + tableSize);
+ byte *table = MulTable();
+ byte *hashKey = HashKey();
+ memset(hashKey, 0, REQUIRED_BLOCKSIZE);
+ blockCipher.ProcessBlock(hashKey);
+
+#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
+ if (HasCLMUL())
+ {
+ const __m128i r = s_clmulConstants[0];
+ __m128i h0 = _mm_shuffle_epi8(_mm_load_si128((__m128i *)hashKey), s_clmulConstants[1]);
+ __m128i h = h0;
+
+ for (i=0; i<tableSize; i+=32)
+ {
+ __m128i h1 = CLMUL_GF_Mul(h, h0, r);
+ _mm_storel_epi64((__m128i *)(table+i), h);
+ _mm_storeu_si128((__m128i *)(table+i+16), h1);
+ _mm_storeu_si128((__m128i *)(table+i+8), h);
+ _mm_storel_epi64((__m128i *)(table+i+8), h1);
+ h = CLMUL_GF_Mul(h1, h0, r);
+ }
+
+ return;
+ }
+#endif
+
+ word64 V0, V1;
+ typedef BlockGetAndPut<word64, BigEndian> Block;
+ Block::Get(hashKey)(V0)(V1);
+
+ if (tableSize == 64*1024)
+ {
+ for (i=0; i<128; i++)
+ {
+ k = i%8;
+ Block::Put(NULL, table+(i/8)*256*16+(size_t(1)<<(11-k)))(V0)(V1);
+
+ int x = (int)V1 & 1;
+ V1 = (V1>>1) | (V0<<63);
+ V0 = (V0>>1) ^ (x ? W64LIT(0xe1) << 56 : 0);
+ }
+
+ for (i=0; i<16; i++)
+ {
+ memset(table+i*256*16, 0, 16);
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
+ if (HasSSE2())
+ for (j=2; j<=0x80; j*=2)
+ for (k=1; k<j; k++)
+ SSE2_Xor16(table+i*256*16+(j+k)*16, table+i*256*16+j*16, table+i*256*16+k*16);
+ else
+#endif
+ for (j=2; j<=0x80; j*=2)
+ for (k=1; k<j; k++)
+ Xor16(table+i*256*16+(j+k)*16, table+i*256*16+j*16, table+i*256*16+k*16);
+ }
+ }
+ else
+ {
+ if (!s_reductionTableInitialized)
+ {
+ s_reductionTable[0] = 0;
+ word16 x = 0x01c2;
+ s_reductionTable[1] = ByteReverse(x);
+ for (int i=2; i<=0x80; i*=2)
+ {
+ x <<= 1;
+ s_reductionTable[i] = ByteReverse(x);
+ for (int j=1; j<i; j++)
+ s_reductionTable[i+j] = s_reductionTable[i] ^ s_reductionTable[j];
+ }
+ s_reductionTableInitialized = true;
+ }
+
+ for (i=0; i<128-24; i++)
+ {
+ k = i%32;
+ if (k < 4)
+ Block::Put(NULL, table+1024+(i/32)*256+(size_t(1)<<(7-k)))(V0)(V1);
+ else if (k < 8)
+ Block::Put(NULL, table+(i/32)*256+(size_t(1)<<(11-k)))(V0)(V1);
+
+ int x = (int)V1 & 1;
+ V1 = (V1>>1) | (V0<<63);
+ V0 = (V0>>1) ^ (x ? W64LIT(0xe1) << 56 : 0);
+ }
+
+ for (i=0; i<4; i++)
+ {
+ memset(table+i*256, 0, 16);
+ memset(table+1024+i*256, 0, 16);
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
+ if (HasSSE2())
+ for (j=2; j<=8; j*=2)
+ for (k=1; k<j; k++)
+ {
+ SSE2_Xor16(table+i*256+(j+k)*16, table+i*256+j*16, table+i*256+k*16);
+ SSE2_Xor16(table+1024+i*256+(j+k)*16, table+1024+i*256+j*16, table+1024+i*256+k*16);
+ }
+ else
+#endif
+ for (j=2; j<=8; j*=2)
+ for (k=1; k<j; k++)
+ {
+ Xor16(table+i*256+(j+k)*16, table+i*256+j*16, table+i*256+k*16);
+ Xor16(table+1024+i*256+(j+k)*16, table+1024+i*256+j*16, table+1024+i*256+k*16);
+ }
+ }
+ }
+}
+
+inline void GCM_Base::ReverseHashBufferIfNeeded()
+{
+#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
+ if (HasCLMUL())
+ {
+ __m128i &x = *(__m128i *)HashBuffer();
+ x = _mm_shuffle_epi8(x, s_clmulConstants[1]);
+ }
+#endif
+}
+
+void GCM_Base::Resync(const byte *iv, size_t len)
+{
+ BlockCipher &cipher = AccessBlockCipher();
+ byte *hashBuffer = HashBuffer();
+
+ if (len == 12)
+ {
+ memcpy(hashBuffer, iv, len);
+ memset(hashBuffer+len, 0, 3);
+ hashBuffer[len+3] = 1;
+ }
+ else
+ {
+ size_t origLen = len;
+ memset(hashBuffer, 0, HASH_BLOCKSIZE);
+
+ if (len >= HASH_BLOCKSIZE)
+ {
+ len = GCM_Base::AuthenticateBlocks(iv, len);
+ iv += (origLen - len);
+ }
+
+ if (len > 0)
+ {
+ memcpy(m_buffer, iv, len);
+ memset(m_buffer+len, 0, HASH_BLOCKSIZE-len);
+ GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
+ }
+
+ PutBlock<word64, BigEndian, true>(NULL, m_buffer)(0)(origLen*8);
+ GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
+
+ ReverseHashBufferIfNeeded();
+ }
+
+ if (m_state >= State_IVSet)
+ m_ctr.Resynchronize(hashBuffer, REQUIRED_BLOCKSIZE);
+ else
+ m_ctr.SetCipherWithIV(cipher, hashBuffer);
+
+ m_ctr.Seek(HASH_BLOCKSIZE);
+
+ memset(hashBuffer, 0, HASH_BLOCKSIZE);
+}
+
+unsigned int GCM_Base::OptimalDataAlignment() const
+{
+ return
+#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
+ HasSSE2() ? 16 :
+#endif
+ GetBlockCipher().OptimalDataAlignment();
+}
+
+#pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code
+
+#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
+
+#ifdef CRYPTOPP_X64_MASM_AVAILABLE
+extern "C" {
+void GCM_AuthenticateBlocks_2K(const byte *data, size_t blocks, word64 *hashBuffer, const word16 *reductionTable);
+void GCM_AuthenticateBlocks_64K(const byte *data, size_t blocks, word64 *hashBuffer);
+}
+#endif
+
+#ifndef CRYPTOPP_GENERATE_X64_MASM
+
+size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
+{
+#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
+ if (HasCLMUL())
+ {
+ const __m128i *table = (const __m128i *)MulTable();
+ __m128i x = _mm_load_si128((__m128i *)HashBuffer());
+ const __m128i r = s_clmulConstants[0], bswapMask = s_clmulConstants[1], bswapMask2 = s_clmulConstants[2];
+
+ while (len >= 16)
+ {
+ size_t s = UnsignedMin(len/16, s_clmulTableSizeInBlocks), i=0;
+ __m128i d, d2 = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)(data+(s-1)*16)), bswapMask2);;
+ __m128i c0 = _mm_setzero_si128();
+ __m128i c1 = _mm_setzero_si128();
+ __m128i c2 = _mm_setzero_si128();
+
+ while (true)
+ {
+ __m128i h0 = _mm_load_si128(table+i);
+ __m128i h1 = _mm_load_si128(table+i+1);
+ __m128i h01 = _mm_xor_si128(h0, h1);
+
+ if (++i == s)
+ {
+ d = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)data), bswapMask);
+ d = _mm_xor_si128(d, x);
+ c0 = _mm_xor_si128(c0, _mm_clmulepi64_si128(d, h0, 0));
+ c2 = _mm_xor_si128(c2, _mm_clmulepi64_si128(d, h1, 1));
+ d = _mm_xor_si128(d, _mm_shuffle_epi32(d, _MM_SHUFFLE(1, 0, 3, 2)));
+ c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(d, h01, 0));
+ break;
+ }
+
+ d = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)(data+(s-i)*16-8)), bswapMask2);
+ c0 = _mm_xor_si128(c0, _mm_clmulepi64_si128(d2, h0, 1));
+ c2 = _mm_xor_si128(c2, _mm_clmulepi64_si128(d, h1, 1));
+ d2 = _mm_xor_si128(d2, d);
+ c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(d2, h01, 1));
+
+ if (++i == s)
+ {
+ d = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)data), bswapMask);
+ d = _mm_xor_si128(d, x);
+ c0 = _mm_xor_si128(c0, _mm_clmulepi64_si128(d, h0, 0x10));
+ c2 = _mm_xor_si128(c2, _mm_clmulepi64_si128(d, h1, 0x11));
+ d = _mm_xor_si128(d, _mm_shuffle_epi32(d, _MM_SHUFFLE(1, 0, 3, 2)));
+ c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(d, h01, 0x10));
+ break;
+ }
+
+ d2 = _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)(data+(s-i)*16-8)), bswapMask);
+ c0 = _mm_xor_si128(c0, _mm_clmulepi64_si128(d, h0, 0x10));
+ c2 = _mm_xor_si128(c2, _mm_clmulepi64_si128(d2, h1, 0x10));
+ d = _mm_xor_si128(d, d2);
+ c1 = _mm_xor_si128(c1, _mm_clmulepi64_si128(d, h01, 0x10));
+ }
+ data += s*16;
+ len -= s*16;
+
+ c1 = _mm_xor_si128(_mm_xor_si128(c1, c0), c2);
+ x = CLMUL_Reduce(c0, c1, c2, r);
+ }
+
+ _mm_store_si128((__m128i *)HashBuffer(), x);
+ return len;
+ }
+#endif
+
+ typedef BlockGetAndPut<word64, NativeByteOrder> Block;
+ word64 *hashBuffer = (word64 *)HashBuffer();
+
+ switch (2*(m_buffer.size()>=64*1024)
+#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
+ + HasSSE2()
+#endif
+ )
+ {
+ case 0: // non-SSE2 and 2K tables
+ {
+ byte *table = MulTable();
+ word64 x0 = hashBuffer[0], x1 = hashBuffer[1];
+
+ do
+ {
+ word64 y0, y1, a0, a1, b0, b1, c0, c1, d0, d1;
+ Block::Get(data)(y0)(y1);
+ x0 ^= y0;
+ x1 ^= y1;
+
+ data += HASH_BLOCKSIZE;
+ len -= HASH_BLOCKSIZE;
+
+ #define READ_TABLE_WORD64_COMMON(a, b, c, d) *(word64 *)(table+(a*1024)+(b*256)+c+d*8)
+
+ #ifdef IS_LITTLE_ENDIAN
+ #if CRYPTOPP_BOOL_SLOW_WORD64
+ word32 z0 = (word32)x0;
+ word32 z1 = (word32)(x0>>32);
+ word32 z2 = (word32)x1;
+ word32 z3 = (word32)(x1>>32);
+ #define READ_TABLE_WORD64(a, b, c, d, e) READ_TABLE_WORD64_COMMON((d%2), c, (d?(z##c>>((d?d-1:0)*4))&0xf0:(z##c&0xf)<<4), e)
+ #else
+ #define READ_TABLE_WORD64(a, b, c, d, e) READ_TABLE_WORD64_COMMON((d%2), c, ((d+8*b)?(x##a>>(((d+8*b)?(d+8*b)-1:1)*4))&0xf0:(x##a&0xf)<<4), e)
+ #endif
+ #define GF_MOST_SIG_8BITS(a) (a##1 >> 7*8)
+ #define GF_SHIFT_8(a) a##1 = (a##1 << 8) ^ (a##0 >> 7*8); a##0 <<= 8;
+ #else
+ #define READ_TABLE_WORD64(a, b, c, d, e) READ_TABLE_WORD64_COMMON((1-d%2), c, ((15-d-8*b)?(x##a>>(((15-d-8*b)?(15-d-8*b)-1:0)*4))&0xf0:(x##a&0xf)<<4), e)
+ #define GF_MOST_SIG_8BITS(a) (a##1 & 0xff)
+ #define GF_SHIFT_8(a) a##1 = (a##1 >> 8) ^ (a##0 << 7*8); a##0 >>= 8;
+ #endif
+
+ #define GF_MUL_32BY128(op, a, b, c) \
+ a0 op READ_TABLE_WORD64(a, b, c, 0, 0) ^ READ_TABLE_WORD64(a, b, c, 1, 0);\
+ a1 op READ_TABLE_WORD64(a, b, c, 0, 1) ^ READ_TABLE_WORD64(a, b, c, 1, 1);\
+ b0 op READ_TABLE_WORD64(a, b, c, 2, 0) ^ READ_TABLE_WORD64(a, b, c, 3, 0);\
+ b1 op READ_TABLE_WORD64(a, b, c, 2, 1) ^ READ_TABLE_WORD64(a, b, c, 3, 1);\
+ c0 op READ_TABLE_WORD64(a, b, c, 4, 0) ^ READ_TABLE_WORD64(a, b, c, 5, 0);\
+ c1 op READ_TABLE_WORD64(a, b, c, 4, 1) ^ READ_TABLE_WORD64(a, b, c, 5, 1);\
+ d0 op READ_TABLE_WORD64(a, b, c, 6, 0) ^ READ_TABLE_WORD64(a, b, c, 7, 0);\
+ d1 op READ_TABLE_WORD64(a, b, c, 6, 1) ^ READ_TABLE_WORD64(a, b, c, 7, 1);\
+
+ GF_MUL_32BY128(=, 0, 0, 0)
+ GF_MUL_32BY128(^=, 0, 1, 1)
+ GF_MUL_32BY128(^=, 1, 0, 2)
+ GF_MUL_32BY128(^=, 1, 1, 3)
+
+ word32 r = (word32)s_reductionTable[GF_MOST_SIG_8BITS(d)] << 16;
+ GF_SHIFT_8(d)
+ c0 ^= d0; c1 ^= d1;
+ r ^= (word32)s_reductionTable[GF_MOST_SIG_8BITS(c)] << 8;
+ GF_SHIFT_8(c)
+ b0 ^= c0; b1 ^= c1;
+ r ^= s_reductionTable[GF_MOST_SIG_8BITS(b)];
+ GF_SHIFT_8(b)
+ a0 ^= b0; a1 ^= b1;
+ a0 ^= ConditionalByteReverse<word64>(LITTLE_ENDIAN_ORDER, r);
+ x0 = a0; x1 = a1;
+ }
+ while (len >= HASH_BLOCKSIZE);
+
+ hashBuffer[0] = x0; hashBuffer[1] = x1;
+ return len;
+ }
+
+ case 2: // non-SSE2 and 64K tables
+ {
+ byte *table = MulTable();
+ word64 x0 = hashBuffer[0], x1 = hashBuffer[1];
+
+ do
+ {
+ word64 y0, y1, a0, a1;
+ Block::Get(data)(y0)(y1);
+ x0 ^= y0;
+ x1 ^= y1;
+
+ data += HASH_BLOCKSIZE;
+ len -= HASH_BLOCKSIZE;
+
+ #undef READ_TABLE_WORD64_COMMON
+ #undef READ_TABLE_WORD64
+
+ #define READ_TABLE_WORD64_COMMON(a, c, d) *(word64 *)(table+(a)*256*16+(c)+(d)*8)
+
+ #ifdef IS_LITTLE_ENDIAN
+ #if CRYPTOPP_BOOL_SLOW_WORD64
+ word32 z0 = (word32)x0;
+ word32 z1 = (word32)(x0>>32);
+ word32 z2 = (word32)x1;
+ word32 z3 = (word32)(x1>>32);
+ #define READ_TABLE_WORD64(b, c, d, e) READ_TABLE_WORD64_COMMON(c*4+d, (d?(z##c>>((d?d:1)*8-4))&0xff0:(z##c&0xff)<<4), e)
+ #else
+ #define READ_TABLE_WORD64(b, c, d, e) READ_TABLE_WORD64_COMMON(c*4+d, ((d+4*(c%2))?(x##b>>(((d+4*(c%2))?(d+4*(c%2)):1)*8-4))&0xff0:(x##b&0xff)<<4), e)
+ #endif
+ #else
+ #define READ_TABLE_WORD64(b, c, d, e) READ_TABLE_WORD64_COMMON(c*4+d, ((7-d-4*(c%2))?(x##b>>(((7-d-4*(c%2))?(7-d-4*(c%2)):1)*8-4))&0xff0:(x##b&0xff)<<4), e)
+ #endif
+
+ #define GF_MUL_8BY128(op, b, c, d) \
+ a0 op READ_TABLE_WORD64(b, c, d, 0);\
+ a1 op READ_TABLE_WORD64(b, c, d, 1);\
+
+ GF_MUL_8BY128(=, 0, 0, 0)
+ GF_MUL_8BY128(^=, 0, 0, 1)
+ GF_MUL_8BY128(^=, 0, 0, 2)
+ GF_MUL_8BY128(^=, 0, 0, 3)
+ GF_MUL_8BY128(^=, 0, 1, 0)
+ GF_MUL_8BY128(^=, 0, 1, 1)
+ GF_MUL_8BY128(^=, 0, 1, 2)
+ GF_MUL_8BY128(^=, 0, 1, 3)
+ GF_MUL_8BY128(^=, 1, 2, 0)
+ GF_MUL_8BY128(^=, 1, 2, 1)
+ GF_MUL_8BY128(^=, 1, 2, 2)
+ GF_MUL_8BY128(^=, 1, 2, 3)
+ GF_MUL_8BY128(^=, 1, 3, 0)
+ GF_MUL_8BY128(^=, 1, 3, 1)
+ GF_MUL_8BY128(^=, 1, 3, 2)
+ GF_MUL_8BY128(^=, 1, 3, 3)
+
+ x0 = a0; x1 = a1;
+ }
+ while (len >= HASH_BLOCKSIZE);
+
+ hashBuffer[0] = x0; hashBuffer[1] = x1;
+ return len;
+ }
+#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
+
+#ifdef CRYPTOPP_X64_MASM_AVAILABLE
+ case 1: // SSE2 and 2K tables
+ GCM_AuthenticateBlocks_2K(data, len/16, hashBuffer, s_reductionTable);
+ return len % 16;
+ case 3: // SSE2 and 64K tables
+ GCM_AuthenticateBlocks_64K(data, len/16, hashBuffer);
+ return len % 16;
+#endif
+
+#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
+ case 1: // SSE2 and 2K tables
+ {
+ #ifdef __GNUC__
+ __asm__ __volatile__
+ (
+ ".intel_syntax noprefix;"
+ #elif defined(CRYPTOPP_GENERATE_X64_MASM)
+ ALIGN 8
+ GCM_AuthenticateBlocks_2K PROC FRAME
+ rex_push_reg rsi
+ push_reg rdi
+ push_reg rbx
+ .endprolog
+ mov rsi, r8
+ mov r11, r9
+ #else
+ AS2( mov WORD_REG(cx), data )
+ AS2( mov WORD_REG(dx), len )
+ AS2( mov WORD_REG(si), hashBuffer )
+ AS2( shr WORD_REG(dx), 4 )
+ #endif
+
+ AS_PUSH_IF86( bx)
+ AS_PUSH_IF86( bp)
+
+ #ifdef __GNUC__
+ AS2( mov AS_REG_7, WORD_REG(di))
+ #elif CRYPTOPP_BOOL_X86
+ AS2( lea AS_REG_7, s_reductionTable)
+ #endif
+
+ AS2( movdqa xmm0, [WORD_REG(si)] )
+
+ #define MUL_TABLE_0 WORD_REG(si) + 32
+ #define MUL_TABLE_1 WORD_REG(si) + 32 + 1024
+ #define RED_TABLE AS_REG_7
+
+ ASL(0)
+ AS2( movdqu xmm4, [WORD_REG(cx)] )
+ AS2( pxor xmm0, xmm4 )
+
+ AS2( movd ebx, xmm0 )
+ AS2( mov eax, AS_HEX(f0f0f0f0) )
+ AS2( and eax, ebx )
+ AS2( shl ebx, 4 )
+ AS2( and ebx, AS_HEX(f0f0f0f0) )
+ AS2( movzx edi, ah )
+ AS2( movdqa xmm5, XMMWORD_PTR [MUL_TABLE_1 + WORD_REG(di)] )
+ AS2( movzx edi, al )
+ AS2( movdqa xmm4, XMMWORD_PTR [MUL_TABLE_1 + WORD_REG(di)] )
+ AS2( shr eax, 16 )
+ AS2( movzx edi, ah )
+ AS2( movdqa xmm3, XMMWORD_PTR [MUL_TABLE_1 + WORD_REG(di)] )
+ AS2( movzx edi, al )
+ AS2( movdqa xmm2, XMMWORD_PTR [MUL_TABLE_1 + WORD_REG(di)] )
+
+ #define SSE2_MUL_32BITS(i) \
+ AS2( psrldq xmm0, 4 )\
+ AS2( movd eax, xmm0 )\
+ AS2( and eax, AS_HEX(f0f0f0f0) )\
+ AS2( movzx edi, bh )\
+ AS2( pxor xmm5, XMMWORD_PTR [MUL_TABLE_0 + (i-1)*256 + WORD_REG(di)] )\
+ AS2( movzx edi, bl )\
+ AS2( pxor xmm4, XMMWORD_PTR [MUL_TABLE_0 + (i-1)*256 + WORD_REG(di)] )\
+ AS2( shr ebx, 16 )\
+ AS2( movzx edi, bh )\
+ AS2( pxor xmm3, XMMWORD_PTR [MUL_TABLE_0 + (i-1)*256 + WORD_REG(di)] )\
+ AS2( movzx edi, bl )\
+ AS2( pxor xmm2, XMMWORD_PTR [MUL_TABLE_0 + (i-1)*256 + WORD_REG(di)] )\
+ AS2( movd ebx, xmm0 )\
+ AS2( shl ebx, 4 )\
+ AS2( and ebx, AS_HEX(f0f0f0f0) )\
+ AS2( movzx edi, ah )\
+ AS2( pxor xmm5, XMMWORD_PTR [MUL_TABLE_1 + i*256 + WORD_REG(di)] )\
+ AS2( movzx edi, al )\
+ AS2( pxor xmm4, XMMWORD_PTR [MUL_TABLE_1 + i*256 + WORD_REG(di)] )\
+ AS2( shr eax, 16 )\
+ AS2( movzx edi, ah )\
+ AS2( pxor xmm3, XMMWORD_PTR [MUL_TABLE_1 + i*256 + WORD_REG(di)] )\
+ AS2( movzx edi, al )\
+ AS2( pxor xmm2, XMMWORD_PTR [MUL_TABLE_1 + i*256 + WORD_REG(di)] )\
+
+ SSE2_MUL_32BITS(1)
+ SSE2_MUL_32BITS(2)
+ SSE2_MUL_32BITS(3)
+
+ AS2( movzx edi, bh )
+ AS2( pxor xmm5, XMMWORD_PTR [MUL_TABLE_0 + 3*256 + WORD_REG(di)] )
+ AS2( movzx edi, bl )
+ AS2( pxor xmm4, XMMWORD_PTR [MUL_TABLE_0 + 3*256 + WORD_REG(di)] )
+ AS2( shr ebx, 16 )
+ AS2( movzx edi, bh )
+ AS2( pxor xmm3, XMMWORD_PTR [MUL_TABLE_0 + 3*256 + WORD_REG(di)] )
+ AS2( movzx edi, bl )
+ AS2( pxor xmm2, XMMWORD_PTR [MUL_TABLE_0 + 3*256 + WORD_REG(di)] )
+
+ AS2( movdqa xmm0, xmm3 )
+ AS2( pslldq xmm3, 1 )
+ AS2( pxor xmm2, xmm3 )
+ AS2( movdqa xmm1, xmm2 )
+ AS2( pslldq xmm2, 1 )
+ AS2( pxor xmm5, xmm2 )
+
+ AS2( psrldq xmm0, 15 )
+ AS2( movd WORD_REG(di), xmm0 )
+ AS2( movzx eax, WORD PTR [RED_TABLE + WORD_REG(di)*2] )
+ AS2( shl eax, 8 )
+
+ AS2( movdqa xmm0, xmm5 )
+ AS2( pslldq xmm5, 1 )
+ AS2( pxor xmm4, xmm5 )
+
+ AS2( psrldq xmm1, 15 )
+ AS2( movd WORD_REG(di), xmm1 )
+ AS2( xor ax, WORD PTR [RED_TABLE + WORD_REG(di)*2] )
+ AS2( shl eax, 8 )
+
+ AS2( psrldq xmm0, 15 )
+ AS2( movd WORD_REG(di), xmm0 )
+ AS2( xor ax, WORD PTR [RED_TABLE + WORD_REG(di)*2] )
+
+ AS2( movd xmm0, eax )
+ AS2( pxor xmm0, xmm4 )
+
+ AS2( add WORD_REG(cx), 16 )
+ AS2( sub WORD_REG(dx), 1 )
+ ASJ( jnz, 0, b )
+ AS2( movdqa [WORD_REG(si)], xmm0 )
+
+ AS_POP_IF86( bp)
+ AS_POP_IF86( bx)
+
+ #ifdef __GNUC__
+ ".att_syntax prefix;"
+ :
+ : "c" (data), "d" (len/16), "S" (hashBuffer), "D" (s_reductionTable)
+ : "memory", "cc", "%eax"
+ #if CRYPTOPP_BOOL_X64
+ , "%ebx", "%r11"
+ #endif
+ );
+ #elif defined(CRYPTOPP_GENERATE_X64_MASM)
+ pop rbx
+ pop rdi
+ pop rsi
+ ret
+ GCM_AuthenticateBlocks_2K ENDP
+ #endif
+
+ return len%16;
+ }
+ case 3: // SSE2 and 64K tables
+ {
+ #ifdef __GNUC__
+ __asm__ __volatile__
+ (
+ ".intel_syntax noprefix;"
+ #elif defined(CRYPTOPP_GENERATE_X64_MASM)
+ ALIGN 8
+ GCM_AuthenticateBlocks_64K PROC FRAME
+ rex_push_reg rsi
+ push_reg rdi
+ .endprolog
+ mov rsi, r8
+ #else
+ AS2( mov WORD_REG(cx), data )
+ AS2( mov WORD_REG(dx), len )
+ AS2( mov WORD_REG(si), hashBuffer )
+ AS2( shr WORD_REG(dx), 4 )
+ #endif
+
+ AS2( movdqa xmm0, [WORD_REG(si)] )
+
+ #undef MUL_TABLE
+ #define MUL_TABLE(i,j) WORD_REG(si) + 32 + (i*4+j)*256*16
+
+ ASL(1)
+ AS2( movdqu xmm1, [WORD_REG(cx)] )
+ AS2( pxor xmm1, xmm0 )
+ AS2( pxor xmm0, xmm0 )
+
+ #undef SSE2_MUL_32BITS
+ #define SSE2_MUL_32BITS(i) \
+ AS2( movd eax, xmm1 )\
+ AS2( psrldq xmm1, 4 )\
+ AS2( movzx edi, al )\
+ AS2( add WORD_REG(di), WORD_REG(di) )\
+ AS2( pxor xmm0, [MUL_TABLE(i,0) + WORD_REG(di)*8] )\
+ AS2( movzx edi, ah )\
+ AS2( add WORD_REG(di), WORD_REG(di) )\
+ AS2( pxor xmm0, [MUL_TABLE(i,1) + WORD_REG(di)*8] )\
+ AS2( shr eax, 16 )\
+ AS2( movzx edi, al )\
+ AS2( add WORD_REG(di), WORD_REG(di) )\
+ AS2( pxor xmm0, [MUL_TABLE(i,2) + WORD_REG(di)*8] )\
+ AS2( movzx edi, ah )\
+ AS2( add WORD_REG(di), WORD_REG(di) )\
+ AS2( pxor xmm0, [MUL_TABLE(i,3) + WORD_REG(di)*8] )\
+
+ SSE2_MUL_32BITS(0)
+ SSE2_MUL_32BITS(1)
+ SSE2_MUL_32BITS(2)
+ SSE2_MUL_32BITS(3)
+
+ AS2( add WORD_REG(cx), 16 )
+ AS2( sub WORD_REG(dx), 1 )
+ ASJ( jnz, 1, b )
+ AS2( movdqa [WORD_REG(si)], xmm0 )
+
+ #ifdef __GNUC__
+ ".att_syntax prefix;"
+ :
+ : "c" (data), "d" (len/16), "S" (hashBuffer)
+ : "memory", "cc", "%edi", "%eax"
+ );
+ #elif defined(CRYPTOPP_GENERATE_X64_MASM)
+ pop rdi
+ pop rsi
+ ret
+ GCM_AuthenticateBlocks_64K ENDP
+ #endif
+
+ return len%16;
+ }
+#endif
+#ifndef CRYPTOPP_GENERATE_X64_MASM
+ }
+
+ return len%16;
+}
+
+void GCM_Base::AuthenticateLastHeaderBlock()
+{
+ if (m_bufferedDataLength > 0)
+ {
+ memset(m_buffer+m_bufferedDataLength, 0, HASH_BLOCKSIZE-m_bufferedDataLength);
+ m_bufferedDataLength = 0;
+ GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
+ }
+}
+
+void GCM_Base::AuthenticateLastConfidentialBlock()
+{
+ GCM_Base::AuthenticateLastHeaderBlock();
+ PutBlock<word64, BigEndian, true>(NULL, m_buffer)(m_totalHeaderLength*8)(m_totalMessageLength*8);
+ GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
+}
+
+void GCM_Base::AuthenticateLastFooterBlock(byte *mac, size_t macSize)
+{
+ m_ctr.Seek(0);
+ ReverseHashBufferIfNeeded();
+ m_ctr.ProcessData(mac, HashBuffer(), macSize);
+}
+
+NAMESPACE_END
+
+#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
+#endif
diff --git a/CryptoPP/gcm.h b/CryptoPP/gcm.h
index 0b32524f9..272a51c9c 100644
--- a/CryptoPP/gcm.h
+++ b/CryptoPP/gcm.h
@@ -1,106 +1,106 @@
-#ifndef CRYPTOPP_GCM_H
-#define CRYPTOPP_GCM_H
-
-#include "authenc.h"
-#include "modes.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-//! .
-enum GCM_TablesOption {GCM_2K_Tables, GCM_64K_Tables};
-
-//! .
-class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE GCM_Base : public AuthenticatedSymmetricCipherBase
-{
-public:
- // AuthenticatedSymmetricCipher
- std::string AlgorithmName() const
- {return GetBlockCipher().AlgorithmName() + std::string("/GCM");}
- size_t MinKeyLength() const
- {return GetBlockCipher().MinKeyLength();}
- size_t MaxKeyLength() const
- {return GetBlockCipher().MaxKeyLength();}
- size_t DefaultKeyLength() const
- {return GetBlockCipher().DefaultKeyLength();}
- size_t GetValidKeyLength(size_t n) const
- {return GetBlockCipher().GetValidKeyLength(n);}
- bool IsValidKeyLength(size_t n) const
- {return GetBlockCipher().IsValidKeyLength(n);}
- unsigned int OptimalDataAlignment() const;
- IV_Requirement IVRequirement() const
- {return UNIQUE_IV;}
- unsigned int IVSize() const
- {return 12;}
- unsigned int MinIVLength() const
- {return 1;}
- unsigned int MaxIVLength() const
- {return UINT_MAX;} // (W64LIT(1)<<61)-1 in the standard
- unsigned int DigestSize() const
- {return 16;}
- lword MaxHeaderLength() const
- {return (W64LIT(1)<<61)-1;}
- lword MaxMessageLength() const
- {return ((W64LIT(1)<<39)-256)/8;}
-
-protected:
- // AuthenticatedSymmetricCipherBase
- bool AuthenticationIsOnPlaintext() const
- {return false;}
- unsigned int AuthenticationBlockSize() const
- {return HASH_BLOCKSIZE;}
- void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params);
- void Resync(const byte *iv, size_t len);
- size_t AuthenticateBlocks(const byte *data, size_t len);
- void AuthenticateLastHeaderBlock();
- void AuthenticateLastConfidentialBlock();
- void AuthenticateLastFooterBlock(byte *mac, size_t macSize);
- SymmetricCipher & AccessSymmetricCipher() {return m_ctr;}
-
- virtual BlockCipher & AccessBlockCipher() =0;
- virtual GCM_TablesOption GetTablesOption() const =0;
-
- const BlockCipher & GetBlockCipher() const {return const_cast<GCM_Base *>(this)->AccessBlockCipher();};
- byte *HashBuffer() {return m_buffer+REQUIRED_BLOCKSIZE;}
- byte *HashKey() {return m_buffer+2*REQUIRED_BLOCKSIZE;}
- byte *MulTable() {return m_buffer+3*REQUIRED_BLOCKSIZE;}
- inline void ReverseHashBufferIfNeeded();
-
- class CRYPTOPP_DLL GCTR : public CTR_Mode_ExternalCipher::Encryption
- {
- protected:
- void IncrementCounterBy256();
- };
-
- GCTR m_ctr;
- static word16 s_reductionTable[256];
- static volatile bool s_reductionTableInitialized;
- enum {REQUIRED_BLOCKSIZE = 16, HASH_BLOCKSIZE = 16};
-};
-
-//! .
-template <class T_BlockCipher, GCM_TablesOption T_TablesOption, bool T_IsEncryption>
-class GCM_Final : public GCM_Base
-{
-public:
- static std::string StaticAlgorithmName()
- {return T_BlockCipher::StaticAlgorithmName() + std::string("/GCM");}
- bool IsForwardTransformation() const
- {return T_IsEncryption;}
-
-private:
- GCM_TablesOption GetTablesOption() const {return T_TablesOption;}
- BlockCipher & AccessBlockCipher() {return m_cipher;}
- typename T_BlockCipher::Encryption m_cipher;
-};
-
-//! <a href="http://www.cryptolounge.org/wiki/GCM">GCM</a>
-template <class T_BlockCipher, GCM_TablesOption T_TablesOption=GCM_2K_Tables>
-struct GCM : public AuthenticatedSymmetricCipherDocumentation
-{
- typedef GCM_Final<T_BlockCipher, T_TablesOption, true> Encryption;
- typedef GCM_Final<T_BlockCipher, T_TablesOption, false> Decryption;
-};
-
-NAMESPACE_END
-
-#endif
+#ifndef CRYPTOPP_GCM_H
+#define CRYPTOPP_GCM_H
+
+#include "authenc.h"
+#include "modes.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! .
+enum GCM_TablesOption {GCM_2K_Tables, GCM_64K_Tables};
+
+//! .
+class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE GCM_Base : public AuthenticatedSymmetricCipherBase
+{
+public:
+ // AuthenticatedSymmetricCipher
+ std::string AlgorithmName() const
+ {return GetBlockCipher().AlgorithmName() + std::string("/GCM");}
+ size_t MinKeyLength() const
+ {return GetBlockCipher().MinKeyLength();}
+ size_t MaxKeyLength() const
+ {return GetBlockCipher().MaxKeyLength();}
+ size_t DefaultKeyLength() const
+ {return GetBlockCipher().DefaultKeyLength();}
+ size_t GetValidKeyLength(size_t n) const
+ {return GetBlockCipher().GetValidKeyLength(n);}
+ bool IsValidKeyLength(size_t n) const
+ {return GetBlockCipher().IsValidKeyLength(n);}
+ unsigned int OptimalDataAlignment() const;
+ IV_Requirement IVRequirement() const
+ {return UNIQUE_IV;}
+ unsigned int IVSize() const
+ {return 12;}
+ unsigned int MinIVLength() const
+ {return 1;}
+ unsigned int MaxIVLength() const
+ {return UINT_MAX;} // (W64LIT(1)<<61)-1 in the standard
+ unsigned int DigestSize() const
+ {return 16;}
+ lword MaxHeaderLength() const
+ {return (W64LIT(1)<<61)-1;}
+ lword MaxMessageLength() const
+ {return ((W64LIT(1)<<39)-256)/8;}
+
+protected:
+ // AuthenticatedSymmetricCipherBase
+ bool AuthenticationIsOnPlaintext() const
+ {return false;}
+ unsigned int AuthenticationBlockSize() const
+ {return HASH_BLOCKSIZE;}
+ void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params);
+ void Resync(const byte *iv, size_t len);
+ size_t AuthenticateBlocks(const byte *data, size_t len);
+ void AuthenticateLastHeaderBlock();
+ void AuthenticateLastConfidentialBlock();
+ void AuthenticateLastFooterBlock(byte *mac, size_t macSize);
+ SymmetricCipher & AccessSymmetricCipher() {return m_ctr;}
+
+ virtual BlockCipher & AccessBlockCipher() =0;
+ virtual GCM_TablesOption GetTablesOption() const =0;
+
+ const BlockCipher & GetBlockCipher() const {return const_cast<GCM_Base *>(this)->AccessBlockCipher();};
+ byte *HashBuffer() {return m_buffer+REQUIRED_BLOCKSIZE;}
+ byte *HashKey() {return m_buffer+2*REQUIRED_BLOCKSIZE;}
+ byte *MulTable() {return m_buffer+3*REQUIRED_BLOCKSIZE;}
+ inline void ReverseHashBufferIfNeeded();
+
+ class CRYPTOPP_DLL GCTR : public CTR_Mode_ExternalCipher::Encryption
+ {
+ protected:
+ void IncrementCounterBy256();
+ };
+
+ GCTR m_ctr;
+ static word16 s_reductionTable[256];
+ static volatile bool s_reductionTableInitialized;
+ enum {REQUIRED_BLOCKSIZE = 16, HASH_BLOCKSIZE = 16};
+};
+
+//! .
+template <class T_BlockCipher, GCM_TablesOption T_TablesOption, bool T_IsEncryption>
+class GCM_Final : public GCM_Base
+{
+public:
+ static std::string StaticAlgorithmName()
+ {return T_BlockCipher::StaticAlgorithmName() + std::string("/GCM");}
+ bool IsForwardTransformation() const
+ {return T_IsEncryption;}
+
+private:
+ GCM_TablesOption GetTablesOption() const {return T_TablesOption;}
+ BlockCipher & AccessBlockCipher() {return m_cipher;}
+ typename T_BlockCipher::Encryption m_cipher;
+};
+
+//! <a href="http://www.cryptolounge.org/wiki/GCM">GCM</a>
+template <class T_BlockCipher, GCM_TablesOption T_TablesOption=GCM_2K_Tables>
+struct GCM : public AuthenticatedSymmetricCipherDocumentation
+{
+ typedef GCM_Final<T_BlockCipher, T_TablesOption, true> Encryption;
+ typedef GCM_Final<T_BlockCipher, T_TablesOption, false> Decryption;
+};
+
+NAMESPACE_END
+
+#endif
diff --git a/CryptoPP/seed.cpp b/CryptoPP/seed.cpp
index 6c739b474..101902dce 100644
--- a/CryptoPP/seed.cpp
+++ b/CryptoPP/seed.cpp
@@ -1,104 +1,104 @@
-// seed.cpp - written and placed in the public domain by Wei Dai
-
-#include "pch.h"
-#include "seed.h"
-#include "misc.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-static const word32 s_kc[16] = {
- 0x9e3779b9, 0x3c6ef373, 0x78dde6e6, 0xf1bbcdcc, 0xe3779b99, 0xc6ef3733, 0x8dde6e67, 0x1bbcdccf,
- 0x3779b99e, 0x6ef3733c, 0xdde6e678, 0xbbcdccf1, 0x779b99e3, 0xef3733c6, 0xde6e678d, 0xbcdccf1b};
-
-static const byte s_s0[256] = {
- 0xA9, 0x85, 0xD6, 0xD3, 0x54, 0x1D, 0xAC, 0x25, 0x5D, 0x43, 0x18, 0x1E, 0x51, 0xFC, 0xCA, 0x63, 0x28,
- 0x44, 0x20, 0x9D, 0xE0, 0xE2, 0xC8, 0x17, 0xA5, 0x8F, 0x03, 0x7B, 0xBB, 0x13, 0xD2, 0xEE, 0x70, 0x8C,
- 0x3F, 0xA8, 0x32, 0xDD, 0xF6, 0x74, 0xEC, 0x95, 0x0B, 0x57, 0x5C, 0x5B, 0xBD, 0x01, 0x24, 0x1C, 0x73,
- 0x98, 0x10, 0xCC, 0xF2, 0xD9, 0x2C, 0xE7, 0x72, 0x83, 0x9B, 0xD1, 0x86, 0xC9, 0x60, 0x50, 0xA3, 0xEB,
- 0x0D, 0xB6, 0x9E, 0x4F, 0xB7, 0x5A, 0xC6, 0x78, 0xA6, 0x12, 0xAF, 0xD5, 0x61, 0xC3, 0xB4, 0x41, 0x52,
- 0x7D, 0x8D, 0x08, 0x1F, 0x99, 0x00, 0x19, 0x04, 0x53, 0xF7, 0xE1, 0xFD, 0x76, 0x2F, 0x27, 0xB0, 0x8B,
- 0x0E, 0xAB, 0xA2, 0x6E, 0x93, 0x4D, 0x69, 0x7C, 0x09, 0x0A, 0xBF, 0xEF, 0xF3, 0xC5, 0x87, 0x14, 0xFE,
- 0x64, 0xDE, 0x2E, 0x4B, 0x1A, 0x06, 0x21, 0x6B, 0x66, 0x02, 0xF5, 0x92, 0x8A, 0x0C, 0xB3, 0x7E, 0xD0,
- 0x7A, 0x47, 0x96, 0xE5, 0x26, 0x80, 0xAD, 0xDF, 0xA1, 0x30, 0x37, 0xAE, 0x36, 0x15, 0x22, 0x38, 0xF4,
- 0xA7, 0x45, 0x4C, 0x81, 0xE9, 0x84, 0x97, 0x35, 0xCB, 0xCE, 0x3C, 0x71, 0x11, 0xC7, 0x89, 0x75, 0xFB,
- 0xDA, 0xF8, 0x94, 0x59, 0x82, 0xC4, 0xFF, 0x49, 0x39, 0x67, 0xC0, 0xCF, 0xD7, 0xB8, 0x0F, 0x8E, 0x42,
- 0x23, 0x91, 0x6C, 0xDB, 0xA4, 0x34, 0xF1, 0x48, 0xC2, 0x6F, 0x3D, 0x2D, 0x40, 0xBE, 0x3E, 0xBC, 0xC1,
- 0xAA, 0xBA, 0x4E, 0x55, 0x3B, 0xDC, 0x68, 0x7F, 0x9C, 0xD8, 0x4A, 0x56, 0x77, 0xA0, 0xED, 0x46, 0xB5,
- 0x2B, 0x65, 0xFA, 0xE3, 0xB9, 0xB1, 0x9F, 0x5E, 0xF9, 0xE6, 0xB2, 0x31, 0xEA, 0x6D, 0x5F, 0xE4, 0xF0,
- 0xCD, 0x88, 0x16, 0x3A, 0x58, 0xD4, 0x62, 0x29, 0x07, 0x33, 0xE8, 0x1B, 0x05, 0x79, 0x90, 0x6A, 0x2A,
- 0x9A};
-
-static const byte s_s1[256] = {
- 0x38, 0xE8, 0x2D, 0xA6, 0xCF, 0xDE, 0xB3, 0xB8, 0xAF, 0x60, 0x55, 0xC7, 0x44, 0x6F, 0x6B, 0x5B, 0xC3,
- 0x62, 0x33, 0xB5, 0x29, 0xA0, 0xE2, 0xA7, 0xD3, 0x91, 0x11, 0x06, 0x1C, 0xBC, 0x36, 0x4B, 0xEF, 0x88,
- 0x6C, 0xA8, 0x17, 0xC4, 0x16, 0xF4, 0xC2, 0x45, 0xE1, 0xD6, 0x3F, 0x3D, 0x8E, 0x98, 0x28, 0x4E, 0xF6,
- 0x3E, 0xA5, 0xF9, 0x0D, 0xDF, 0xD8, 0x2B, 0x66, 0x7A, 0x27, 0x2F, 0xF1, 0x72, 0x42, 0xD4, 0x41, 0xC0,
- 0x73, 0x67, 0xAC, 0x8B, 0xF7, 0xAD, 0x80, 0x1F, 0xCA, 0x2C, 0xAA, 0x34, 0xD2, 0x0B, 0xEE, 0xE9, 0x5D,
- 0x94, 0x18, 0xF8, 0x57, 0xAE, 0x08, 0xC5, 0x13, 0xCD, 0x86, 0xB9, 0xFF, 0x7D, 0xC1, 0x31, 0xF5, 0x8A,
- 0x6A, 0xB1, 0xD1, 0x20, 0xD7, 0x02, 0x22, 0x04, 0x68, 0x71, 0x07, 0xDB, 0x9D, 0x99, 0x61, 0xBE, 0xE6,
- 0x59, 0xDD, 0x51, 0x90, 0xDC, 0x9A, 0xA3, 0xAB, 0xD0, 0x81, 0x0F, 0x47, 0x1A, 0xE3, 0xEC, 0x8D, 0xBF,
- 0x96, 0x7B, 0x5C, 0xA2, 0xA1, 0x63, 0x23, 0x4D, 0xC8, 0x9E, 0x9C, 0x3A, 0x0C, 0x2E, 0xBA, 0x6E, 0x9F,
- 0x5A, 0xF2, 0x92, 0xF3, 0x49, 0x78, 0xCC, 0x15, 0xFB, 0x70, 0x75, 0x7F, 0x35, 0x10, 0x03, 0x64, 0x6D,
- 0xC6, 0x74, 0xD5, 0xB4, 0xEA, 0x09, 0x76, 0x19, 0xFE, 0x40, 0x12, 0xE0, 0xBD, 0x05, 0xFA, 0x01, 0xF0,
- 0x2A, 0x5E, 0xA9, 0x56, 0x43, 0x85, 0x14, 0x89, 0x9B, 0xB0, 0xE5, 0x48, 0x79, 0x97, 0xFC, 0x1E, 0x82,
- 0x21, 0x8C, 0x1B, 0x5F, 0x77, 0x54, 0xB2, 0x1D, 0x25, 0x4F, 0x00, 0x46, 0xED, 0x58, 0x52, 0xEB, 0x7E,
- 0xDA, 0xC9, 0xFD, 0x30, 0x95, 0x65, 0x3C, 0xB6, 0xE4, 0xBB, 0x7C, 0x0E, 0x50, 0x39, 0x26, 0x32, 0x84,
- 0x69, 0x93, 0x37, 0xE7, 0x24, 0xA4, 0xCB, 0x53, 0x0A, 0x87, 0xD9, 0x4C, 0x83, 0x8F, 0xCE, 0x3B, 0x4A,
- 0xB7};
-
-#define SS0(x) ((s_s0[x]*0x01010101UL) & 0x3FCFF3FC)
-#define SS1(x) ((s_s1[x]*0x01010101UL) & 0xFC3FCFF3)
-#define SS2(x) ((s_s0[x]*0x01010101UL) & 0xF3FC3FCF)
-#define SS3(x) ((s_s1[x]*0x01010101UL) & 0xCFF3FC3F)
-#define G(x) (SS0(GETBYTE(x, 0)) ^ SS1(GETBYTE(x, 1)) ^ SS2(GETBYTE(x, 2)) ^ SS3(GETBYTE(x, 3)))
-
-void SEED::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params)
-{
- AssertValidKeyLength(length);
-
- word64 key01, key23;
- GetBlock<word64, BigEndian> get(userKey);
- get(key01)(key23);
- word32 *k = m_k;
- size_t kInc = 2;
- if (!IsForwardTransformation())
- {
- k = k+30;
- kInc = 0-kInc;
- }
-
- for (int i=0; i<ROUNDS; i++)
- {
- word32 t0 = word32(key01>>32) + word32(key23>>32) - s_kc[i];
- word32 t1 = word32(key01) - word32(key23) + s_kc[i];
- k[0] = G(t0);
- k[1] = G(t1);
- k+=kInc;
- if (i&1)
- key23 = rotlFixed<word64>(key23, 8);
- else
- key01 = rotrFixed<word64>(key01, 8);
- }
-}
-
-void SEED::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
-{
- typedef BlockGetAndPut<word32, BigEndian> Block;
- word32 a0, a1, b0, b1, t0, t1;
- Block::Get(inBlock)(a0)(a1)(b0)(b1);
-
- for (int i=0; i<ROUNDS; i+=2)
- {
- t0 = b0 ^ m_k[2*i+0]; t1 = b1 ^ m_k[2*i+1] ^ t0;
- t1 = G(t1); t0 += t1; t0 = G(t0); t1 += t0; t1 = G(t1);
- a0 ^= t0 + t1; a1 ^= t1;
-
- t0 = a0 ^ m_k[2*i+2]; t1 = a1 ^ m_k[2*i+3] ^ t0;
- t1 = G(t1); t0 += t1; t0 = G(t0); t1 += t0; t1 = G(t1);
- b0 ^= t0 + t1; b1 ^= t1;
- }
-
- Block::Put(xorBlock, outBlock)(b0)(b1)(a0)(a1);
-}
-
-NAMESPACE_END
+// seed.cpp - written and placed in the public domain by Wei Dai
+
+#include "pch.h"
+#include "seed.h"
+#include "misc.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+static const word32 s_kc[16] = {
+ 0x9e3779b9, 0x3c6ef373, 0x78dde6e6, 0xf1bbcdcc, 0xe3779b99, 0xc6ef3733, 0x8dde6e67, 0x1bbcdccf,
+ 0x3779b99e, 0x6ef3733c, 0xdde6e678, 0xbbcdccf1, 0x779b99e3, 0xef3733c6, 0xde6e678d, 0xbcdccf1b};
+
+static const byte s_s0[256] = {
+ 0xA9, 0x85, 0xD6, 0xD3, 0x54, 0x1D, 0xAC, 0x25, 0x5D, 0x43, 0x18, 0x1E, 0x51, 0xFC, 0xCA, 0x63, 0x28,
+ 0x44, 0x20, 0x9D, 0xE0, 0xE2, 0xC8, 0x17, 0xA5, 0x8F, 0x03, 0x7B, 0xBB, 0x13, 0xD2, 0xEE, 0x70, 0x8C,
+ 0x3F, 0xA8, 0x32, 0xDD, 0xF6, 0x74, 0xEC, 0x95, 0x0B, 0x57, 0x5C, 0x5B, 0xBD, 0x01, 0x24, 0x1C, 0x73,
+ 0x98, 0x10, 0xCC, 0xF2, 0xD9, 0x2C, 0xE7, 0x72, 0x83, 0x9B, 0xD1, 0x86, 0xC9, 0x60, 0x50, 0xA3, 0xEB,
+ 0x0D, 0xB6, 0x9E, 0x4F, 0xB7, 0x5A, 0xC6, 0x78, 0xA6, 0x12, 0xAF, 0xD5, 0x61, 0xC3, 0xB4, 0x41, 0x52,
+ 0x7D, 0x8D, 0x08, 0x1F, 0x99, 0x00, 0x19, 0x04, 0x53, 0xF7, 0xE1, 0xFD, 0x76, 0x2F, 0x27, 0xB0, 0x8B,
+ 0x0E, 0xAB, 0xA2, 0x6E, 0x93, 0x4D, 0x69, 0x7C, 0x09, 0x0A, 0xBF, 0xEF, 0xF3, 0xC5, 0x87, 0x14, 0xFE,
+ 0x64, 0xDE, 0x2E, 0x4B, 0x1A, 0x06, 0x21, 0x6B, 0x66, 0x02, 0xF5, 0x92, 0x8A, 0x0C, 0xB3, 0x7E, 0xD0,
+ 0x7A, 0x47, 0x96, 0xE5, 0x26, 0x80, 0xAD, 0xDF, 0xA1, 0x30, 0x37, 0xAE, 0x36, 0x15, 0x22, 0x38, 0xF4,
+ 0xA7, 0x45, 0x4C, 0x81, 0xE9, 0x84, 0x97, 0x35, 0xCB, 0xCE, 0x3C, 0x71, 0x11, 0xC7, 0x89, 0x75, 0xFB,
+ 0xDA, 0xF8, 0x94, 0x59, 0x82, 0xC4, 0xFF, 0x49, 0x39, 0x67, 0xC0, 0xCF, 0xD7, 0xB8, 0x0F, 0x8E, 0x42,
+ 0x23, 0x91, 0x6C, 0xDB, 0xA4, 0x34, 0xF1, 0x48, 0xC2, 0x6F, 0x3D, 0x2D, 0x40, 0xBE, 0x3E, 0xBC, 0xC1,
+ 0xAA, 0xBA, 0x4E, 0x55, 0x3B, 0xDC, 0x68, 0x7F, 0x9C, 0xD8, 0x4A, 0x56, 0x77, 0xA0, 0xED, 0x46, 0xB5,
+ 0x2B, 0x65, 0xFA, 0xE3, 0xB9, 0xB1, 0x9F, 0x5E, 0xF9, 0xE6, 0xB2, 0x31, 0xEA, 0x6D, 0x5F, 0xE4, 0xF0,
+ 0xCD, 0x88, 0x16, 0x3A, 0x58, 0xD4, 0x62, 0x29, 0x07, 0x33, 0xE8, 0x1B, 0x05, 0x79, 0x90, 0x6A, 0x2A,
+ 0x9A};
+
+static const byte s_s1[256] = {
+ 0x38, 0xE8, 0x2D, 0xA6, 0xCF, 0xDE, 0xB3, 0xB8, 0xAF, 0x60, 0x55, 0xC7, 0x44, 0x6F, 0x6B, 0x5B, 0xC3,
+ 0x62, 0x33, 0xB5, 0x29, 0xA0, 0xE2, 0xA7, 0xD3, 0x91, 0x11, 0x06, 0x1C, 0xBC, 0x36, 0x4B, 0xEF, 0x88,
+ 0x6C, 0xA8, 0x17, 0xC4, 0x16, 0xF4, 0xC2, 0x45, 0xE1, 0xD6, 0x3F, 0x3D, 0x8E, 0x98, 0x28, 0x4E, 0xF6,
+ 0x3E, 0xA5, 0xF9, 0x0D, 0xDF, 0xD8, 0x2B, 0x66, 0x7A, 0x27, 0x2F, 0xF1, 0x72, 0x42, 0xD4, 0x41, 0xC0,
+ 0x73, 0x67, 0xAC, 0x8B, 0xF7, 0xAD, 0x80, 0x1F, 0xCA, 0x2C, 0xAA, 0x34, 0xD2, 0x0B, 0xEE, 0xE9, 0x5D,
+ 0x94, 0x18, 0xF8, 0x57, 0xAE, 0x08, 0xC5, 0x13, 0xCD, 0x86, 0xB9, 0xFF, 0x7D, 0xC1, 0x31, 0xF5, 0x8A,
+ 0x6A, 0xB1, 0xD1, 0x20, 0xD7, 0x02, 0x22, 0x04, 0x68, 0x71, 0x07, 0xDB, 0x9D, 0x99, 0x61, 0xBE, 0xE6,
+ 0x59, 0xDD, 0x51, 0x90, 0xDC, 0x9A, 0xA3, 0xAB, 0xD0, 0x81, 0x0F, 0x47, 0x1A, 0xE3, 0xEC, 0x8D, 0xBF,
+ 0x96, 0x7B, 0x5C, 0xA2, 0xA1, 0x63, 0x23, 0x4D, 0xC8, 0x9E, 0x9C, 0x3A, 0x0C, 0x2E, 0xBA, 0x6E, 0x9F,
+ 0x5A, 0xF2, 0x92, 0xF3, 0x49, 0x78, 0xCC, 0x15, 0xFB, 0x70, 0x75, 0x7F, 0x35, 0x10, 0x03, 0x64, 0x6D,
+ 0xC6, 0x74, 0xD5, 0xB4, 0xEA, 0x09, 0x76, 0x19, 0xFE, 0x40, 0x12, 0xE0, 0xBD, 0x05, 0xFA, 0x01, 0xF0,
+ 0x2A, 0x5E, 0xA9, 0x56, 0x43, 0x85, 0x14, 0x89, 0x9B, 0xB0, 0xE5, 0x48, 0x79, 0x97, 0xFC, 0x1E, 0x82,
+ 0x21, 0x8C, 0x1B, 0x5F, 0x77, 0x54, 0xB2, 0x1D, 0x25, 0x4F, 0x00, 0x46, 0xED, 0x58, 0x52, 0xEB, 0x7E,
+ 0xDA, 0xC9, 0xFD, 0x30, 0x95, 0x65, 0x3C, 0xB6, 0xE4, 0xBB, 0x7C, 0x0E, 0x50, 0x39, 0x26, 0x32, 0x84,
+ 0x69, 0x93, 0x37, 0xE7, 0x24, 0xA4, 0xCB, 0x53, 0x0A, 0x87, 0xD9, 0x4C, 0x83, 0x8F, 0xCE, 0x3B, 0x4A,
+ 0xB7};
+
+#define SS0(x) ((s_s0[x]*0x01010101UL) & 0x3FCFF3FC)
+#define SS1(x) ((s_s1[x]*0x01010101UL) & 0xFC3FCFF3)
+#define SS2(x) ((s_s0[x]*0x01010101UL) & 0xF3FC3FCF)
+#define SS3(x) ((s_s1[x]*0x01010101UL) & 0xCFF3FC3F)
+#define G(x) (SS0(GETBYTE(x, 0)) ^ SS1(GETBYTE(x, 1)) ^ SS2(GETBYTE(x, 2)) ^ SS3(GETBYTE(x, 3)))
+
+void SEED::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params)
+{
+ AssertValidKeyLength(length);
+
+ word64 key01, key23;
+ GetBlock<word64, BigEndian> get(userKey);
+ get(key01)(key23);
+ word32 *k = m_k;
+ size_t kInc = 2;
+ if (!IsForwardTransformation())
+ {
+ k = k+30;
+ kInc = 0-kInc;
+ }
+
+ for (int i=0; i<ROUNDS; i++)
+ {
+ word32 t0 = word32(key01>>32) + word32(key23>>32) - s_kc[i];
+ word32 t1 = word32(key01) - word32(key23) + s_kc[i];
+ k[0] = G(t0);
+ k[1] = G(t1);
+ k+=kInc;
+ if (i&1)
+ key23 = rotlFixed<word64>(key23, 8);
+ else
+ key01 = rotrFixed<word64>(key01, 8);
+ }
+}
+
+void SEED::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
+{
+ typedef BlockGetAndPut<word32, BigEndian> Block;
+ word32 a0, a1, b0, b1, t0, t1;
+ Block::Get(inBlock)(a0)(a1)(b0)(b1);
+
+ for (int i=0; i<ROUNDS; i+=2)
+ {
+ t0 = b0 ^ m_k[2*i+0]; t1 = b1 ^ m_k[2*i+1] ^ t0;
+ t1 = G(t1); t0 += t1; t0 = G(t0); t1 += t0; t1 = G(t1);
+ a0 ^= t0 + t1; a1 ^= t1;
+
+ t0 = a0 ^ m_k[2*i+2]; t1 = a1 ^ m_k[2*i+3] ^ t0;
+ t1 = G(t1); t0 += t1; t0 = G(t0); t1 += t0; t1 = G(t1);
+ b0 ^= t0 + t1; b1 ^= t1;
+ }
+
+ Block::Put(xorBlock, outBlock)(b0)(b1)(a0)(a1);
+}
+
+NAMESPACE_END
diff --git a/Install/.gitignore b/Install/.gitignore
new file mode 100644
index 000000000..4f8f2e7cb
--- /dev/null
+++ b/Install/.gitignore
@@ -0,0 +1,3 @@
+MCServer.exe
+*.7z
+*.tag \ No newline at end of file
diff --git a/Install/Lua-LICENSE.txt b/Install/Lua-LICENSE.txt
index bc4f3973c..3c6d06fcf 100644
--- a/Install/Lua-LICENSE.txt
+++ b/Install/Lua-LICENSE.txt
@@ -1,21 +1,21 @@
-Copyright (C) 1994-2008 Lua.org, PUC-Rio.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
-OR OTHER DEALINGS IN THE SOFTWARE.
+Copyright (C) 1994-2008 Lua.org, PUC-Rio.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Install/LuaSQLite3-LICENSE.txt b/Install/LuaSQLite3-LICENSE.txt
index b7e80023a..cf1014378 100644
--- a/Install/LuaSQLite3-LICENSE.txt
+++ b/Install/LuaSQLite3-LICENSE.txt
@@ -1,27 +1,27 @@
-/************************************************************************
-* lsqlite3 *
-* Copyright (C) 2002-2013 Tiago Dionizio, Doug Currie *
-* All rights reserved. *
-* Author : Tiago Dionizio <tiago.dionizio@ist.utl.pt> *
-* Author : Doug Currie <doug.currie@alum.mit.edu> *
-* Library : lsqlite3 - a SQLite 3 database binding for Lua 5 *
-* *
-* Permission is hereby granted, free of charge, to any person obtaining *
-* a copy of this software and associated documentation files (the *
-* "Software"), to deal in the Software without restriction, including *
-* without limitation the rights to use, copy, modify, merge, publish, *
-* distribute, sublicense, and/or sell copies of the Software, and to *
-* permit persons to whom the Software is furnished to do so, subject to *
-* the following conditions: *
-* *
-* The above copyright notice and this permission notice shall be *
-* included in all copies or substantial portions of the Software. *
-* *
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
-* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
-* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY *
-* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, *
-* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE *
-* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
-************************************************************************/
+/************************************************************************
+* lsqlite3 *
+* Copyright (C) 2002-2013 Tiago Dionizio, Doug Currie *
+* All rights reserved. *
+* Author : Tiago Dionizio <tiago.dionizio@ist.utl.pt> *
+* Author : Doug Currie <doug.currie@alum.mit.edu> *
+* Library : lsqlite3 - a SQLite 3 database binding for Lua 5 *
+* *
+* Permission is hereby granted, free of charge, to any person obtaining *
+* a copy of this software and associated documentation files (the *
+* "Software"), to deal in the Software without restriction, including *
+* without limitation the rights to use, copy, modify, merge, publish, *
+* distribute, sublicense, and/or sell copies of the Software, and to *
+* permit persons to whom the Software is furnished to do so, subject to *
+* the following conditions: *
+* *
+* The above copyright notice and this permission notice shall be *
+* included in all copies or substantial portions of the Software. *
+* *
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY *
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, *
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE *
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+************************************************************************/
diff --git a/Install/MersenneTwister-LICENSE.txt b/Install/MersenneTwister-LICENSE.txt
index db62b36c6..5c7a6ef04 100644
--- a/Install/MersenneTwister-LICENSE.txt
+++ b/Install/MersenneTwister-LICENSE.txt
@@ -1,43 +1,43 @@
-// The Mersenne Twister is an algorithm for generating random numbers. It
-// was designed with consideration of the flaws in various other generators.
-// The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
-// are far greater. The generator is also fast; it avoids multiplication and
-// division, and it benefits from caches and pipelines. For more information
-// see the inventors' web page at
-// http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
-
-// Reference
-// M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
-// Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
-// Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
-
-// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
-// Copyright (C) 2000 - 2009, Richard J. Wagner
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// 1. Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// 3. The names of its contributors may not be used to endorse or promote
-// products derived from this software without specific prior written
-// permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// The Mersenne Twister is an algorithm for generating random numbers. It
+// was designed with consideration of the flaws in various other generators.
+// The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
+// are far greater. The generator is also fast; it avoids multiplication and
+// division, and it benefits from caches and pipelines. For more information
+// see the inventors' web page at
+// http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+
+// Reference
+// M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
+// Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
+// Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
+
+// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+// Copyright (C) 2000 - 2009, Richard J. Wagner
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The names of its contributors may not be used to endorse or promote
+// products derived from this software without specific prior written
+// permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
diff --git a/Install/Zip2008.list b/Install/Zip2008.list
index 96c85deff..b611bf832 100644
--- a/Install/Zip2008.list
+++ b/Install/Zip2008.list
@@ -1,18 +1,18 @@
-..\MCServer\MCServer.exe
-..\MCServer\Plugins
-..\MCServer\webadmin
-..\MCServer\crafting.txt
-..\MCServer\furnace.txt
-..\MCServer\items.ini
-..\MCServer\monsters.ini
-MCServer*debug.cmd
-banned.example.ini
-groups.example.ini
-Lua-LICENSE.txt
-LuaExpat-license.html
-LuaSQLite3-LICENSE.txt
-MersenneTwister-LICENSE.txt
-settings.example.ini
-users.example.ini
-webadmin.example.ini
+..\MCServer\MCServer.exe
+..\MCServer\Plugins
+..\MCServer\webadmin
+..\MCServer\crafting.txt
+..\MCServer\furnace.txt
+..\MCServer\items.ini
+..\MCServer\monsters.ini
+MCServer*debug.cmd
+banned.example.ini
+groups.example.ini
+Lua-LICENSE.txt
+LuaExpat-license.html
+LuaSQLite3-LICENSE.txt
+MersenneTwister-LICENSE.txt
+settings.example.ini
+users.example.ini
+webadmin.example.ini
whitelist.example.ini \ No newline at end of file
diff --git a/Install/Zip2008_PDBs.list b/Install/Zip2008_PDBs.list
index bb645b954..578bcd181 100644
--- a/Install/Zip2008_PDBs.list
+++ b/Install/Zip2008_PDBs.list
@@ -1,8 +1,8 @@
-MCServer\*.pdb
-VC2008\Release\*.pdb
-VC2008\Release\JsonCpp\*.pdb
-VC2008\Release\Lua\*.pdb
-VC2008\Release\ToLua\*.pdb
-VC2008\Release\webserver\*.pdb
-VC2008\Release\zlib\*.pdb
+MCServer\*.pdb
+VC2008\Release\*.pdb
+VC2008\Release\JsonCpp\*.pdb
+VC2008\Release\Lua\*.pdb
+VC2008\Release\ToLua\*.pdb
+VC2008\Release\webserver\*.pdb
+VC2008\Release\zlib\*.pdb
source\Bindings.* \ No newline at end of file
diff --git a/Install/banned.example.ini b/Install/banned.example.ini
index efe5f51b6..ba53ec59f 100644
--- a/Install/banned.example.ini
+++ b/Install/banned.example.ini
@@ -1,3 +1,3 @@
-[Banned]
-;PlayerName=1
-
+[Banned]
+;PlayerName=1
+
diff --git a/Install/groups.example.ini b/Install/groups.example.ini
index 7f061204b..87b28b70d 100644
--- a/Install/groups.example.ini
+++ b/Install/groups.example.ini
@@ -1,17 +1,17 @@
-[Admins]
-Permissions=*
-Color=c
-
-[Mods]
-Color=5
-Inherits=Vips
-Permissions=core.time,core.item
-
-[Vips]
-Permissions=core.teleport
-Color=2
-Inherits=Default
-
-[Default]
-Permissions=core.build,core.help,core.playerlist,core.pluginlist,core.spawn
+[Admins]
+Permissions=*
+Color=c
+
+[Mods]
+Color=5
+Inherits=Vips
+Permissions=core.time,core.item
+
+[Vips]
+Permissions=core.teleport
+Color=2
+Inherits=Default
+
+[Default]
+Permissions=core.build,core.help,core.playerlist,core.pluginlist,core.spawn
Color=7 \ No newline at end of file
diff --git a/Install/settings.example.ini b/Install/settings.example.ini
index bfb16c7e6..46f92ef74 100644
--- a/Install/settings.example.ini
+++ b/Install/settings.example.ini
@@ -1,31 +1,31 @@
-[Server]
-Port=25565
-MaxPlayers=42
-Description=MCServer - Slightly more custom!
-
-[Worlds]
-DefaultWorld=world
-;World=world_sexy
-
-[Plugins]
-NewPlugin=Core
-NewPlugin=ChatLog
-
-[HelpPlugin]
-ShowPluginNames=1
-
-[Physics]
-Water=0
-
-[Redstone]
-SimulateRedstone=0
-
-[Monsters]
-AnimalsOn=0
-AnimalSpawnInterval=10
-Types=Spider,Chicken,Cow,Pig,Sheep,Squid,Enderman,Zombiepigman,Cavespider,Creeper,Ghast,Silverfish,Skeleton,Slime,Spider,Zombie
-
-[Authentication]
-Server=session.minecraft.net
-Address=/game/checkserver.jsp?user=%USERNAME%&serverId=%SERVERID%
-Authenticate=0
+[Server]
+Port=25565
+MaxPlayers=42
+Description=MCServer - Slightly more custom!
+
+[Worlds]
+DefaultWorld=world
+;World=world_sexy
+
+[Plugins]
+NewPlugin=Core
+NewPlugin=ChatLog
+
+[HelpPlugin]
+ShowPluginNames=1
+
+[Physics]
+Water=0
+
+[Redstone]
+SimulateRedstone=0
+
+[Monsters]
+AnimalsOn=0
+AnimalSpawnInterval=10
+Types=Spider,Chicken,Cow,Pig,Sheep,Squid,Enderman,Zombiepigman,Cavespider,Creeper,Ghast,Silverfish,Skeleton,Slime,Spider,Zombie
+
+[Authentication]
+Server=session.minecraft.net
+Address=/game/checkserver.jsp?user=%USERNAME%&serverId=%SERVERID%
+Authenticate=0
diff --git a/Install/users.example.ini b/Install/users.example.ini
index fae7030f1..2065d3e37 100644
--- a/Install/users.example.ini
+++ b/Install/users.example.ini
@@ -1,8 +1,8 @@
-[SomeAdmin]
-Groups=Admins
-
-[FancyModerator]
-Groups=Moderators
-
-[ImportantPerson]
+[SomeAdmin]
+Groups=Admins
+
+[FancyModerator]
+Groups=Moderators
+
+[ImportantPerson]
Groups=Vips \ No newline at end of file
diff --git a/Install/webadmin.example.ini b/Install/webadmin.example.ini
index 6ecbf7513..5d6b24063 100644
--- a/Install/webadmin.example.ini
+++ b/Install/webadmin.example.ini
@@ -1,6 +1,6 @@
-[WebAdmin]
-Enabled=1
-Port=8080
-
-[User:admin]
+[WebAdmin]
+Enabled=1
+Port=8080
+
+[User:admin]
Password=admin \ No newline at end of file
diff --git a/Install/whitelist.example.ini b/Install/whitelist.example.ini
index eb884dcda..7e06ba8d4 100644
--- a/Install/whitelist.example.ini
+++ b/Install/whitelist.example.ini
@@ -1,6 +1,6 @@
-[WhiteListSettings]
-WhiteListOn=0
-
-[WhiteList]
-;PlayerName=1
-
+[WhiteListSettings]
+WhiteListOn=0
+
+[WhiteList]
+;PlayerName=1
+
diff --git a/MCServer/.gitignore b/MCServer/.gitignore
new file mode 100644
index 000000000..62225e137
--- /dev/null
+++ b/MCServer/.gitignore
@@ -0,0 +1,23 @@
+*.exe
+ChunkWorx.ini
+ChunkWorxSave.ini
+MCServer
+banned.ini
+logs
+players
+whitelist.ini
+world*
+API.txt
+*.dat
+schematics
+*.schematic
+*.ilk
+*.pdb
+memdump.xml
+*.grab
+ProtectionAreas.ini
+ProtectionAreas.sqlite
+helgrind.log
+settings.ini
+webadmin.ini
+motd.txt
diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua
new file mode 100644
index 000000000..853ff6301
--- /dev/null
+++ b/MCServer/Plugins/APIDump/main.lua
@@ -0,0 +1,61 @@
+-- Global variables
+PLUGIN = {}; -- Reference to own plugin object
+
+
+
+
+
+
+function Initialize(Plugin)
+ PLUGIN = Plugin
+
+ Plugin:SetName("APIDump")
+ Plugin:SetVersion(1)
+
+ PluginManager = cRoot:Get():GetPluginManager()
+ LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
+
+ -- dump all available API functions and objects:
+ DumpAPI();
+
+ return true
+end
+
+
+
+
+
+
+function DumpAPI()
+ LOG("Dumping all available functions to API.txt...");
+ function dump (prefix, a, Output)
+ for i, v in pairs (a) do
+ if (type(v) == "table") then
+ if (GetChar(i, 1) ~= ".") then
+ if (v == _G) then
+ LOG(prefix .. i .. " == _G, CYCLE, ignoring");
+ elseif (v == _G.package) then
+ LOG(prefix .. i .. " == _G.package, ignoring");
+ else
+ dump(prefix .. i .. ".", v, Output)
+ end
+ end
+ elseif (type(v) == "function") then
+ if (string.sub(i, 1, 2) ~= "__") then
+ table.insert(Output, prefix .. i .. "()");
+ end
+ end
+ end
+ end
+
+ local Output = {};
+ dump("", _G, Output);
+
+ table.sort(Output);
+ local f = io.open("API.txt", "w");
+ for i, n in ipairs(Output) do
+ f:write(n, "\n");
+ end
+ f:close();
+ LOG("API.txt written.");
+end
diff --git a/MCServer/Plugins/ChatLog/plugin.lua b/MCServer/Plugins/ChatLog/plugin.lua
index c8358a6d3..c2f6fb81a 100644
--- a/MCServer/Plugins/ChatLog/plugin.lua
+++ b/MCServer/Plugins/ChatLog/plugin.lua
@@ -1,32 +1,32 @@
-
--- plugin.lua
-
--- Implements the main entrypoint for the plugin, as well as all the handling needed
-
--- ChatLog plugin logs all chat messages into the server log
-
-
-
-
-
-function Initialize(Plugin)
- Plugin:SetName("ChatLog")
- Plugin:SetVersion(3)
-
- PluginManager = cRoot:Get():GetPluginManager()
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT)
-
- LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
- return true
-end
-
-
-
-
-
-function OnChat(Player, Message)
- -- Lets get loggin'
- LOGINFO("[" .. Player:GetName() .. "]: " .. StripColorCodes(Message));
-
- return false
+
+-- plugin.lua
+
+-- Implements the main entrypoint for the plugin, as well as all the handling needed
+
+-- ChatLog plugin logs all chat messages into the server log
+
+
+
+
+
+function Initialize(Plugin)
+ Plugin:SetName("ChatLog")
+ Plugin:SetVersion(3)
+
+ PluginManager = cRoot:Get():GetPluginManager()
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT)
+
+ LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
+ return true
+end
+
+
+
+
+
+function OnChat(Player, Message)
+ -- Lets get loggin'
+ LOGINFO("[" .. Player:GetName() .. "]: " .. StripColorCodes(Message));
+
+ return false
end \ No newline at end of file
diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
index aeccb9719..e9a930c92 100644
--- a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
+++ b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
@@ -1,257 +1,257 @@
-local function Buttons_Player( Name )
- return "<form method='POST'><input type='hidden' name='PlayerName' value='"..Name.."'><input type='submit' name='PlayerExact' value='Exact'><input type='submit' name='Player3x3' value='3x3'></form>"
-end
-
-local function Button_World( Name )
- return "<form method='POST'><input type='hidden' name='WorldName' value='"..Name.."'><input type='submit' name='SelectWorld' value='Select'></form>"
-end
-
-function HandleRequest_Generation( Request )
- local Content = ""
- if (Request.PostParams["AGHRRRR"] ~= nil) then
- GENERATION_STATE = 0
- WW_instance:SaveAllChunks()
- WW_instance:UnloadUnusedChunks()
- LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED by admin")
- end
- --Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
- -- PROCESSING
- --------------------------------------------------------------------------------------------------
- local function ProcessingContent()
- local _small_content = ""
- _small_content = _small_content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
- _small_content = _small_content .. "<h4>World for operations:</h4>"..WORK_WORLD
- if (OPERATION_CODE == 0) then
- _small_content = _small_content .. "<h4>Operation:</h4>Generation"
- elseif (OPERATION_CODE == 1) then
- _small_content = _small_content .. "<h4>Operation:</h4>Regeneration"
- end
- _small_content = _small_content .. "<h4>Area: </h4>["..AreaStartX..":"..AreaStartZ.."] ["..AreaEndX..":"..AreaEndZ.."]"
- _small_content = _small_content .. "<h4>Progress:</h4>"..CURRENT.."/"..TOTAL
- _small_content = _small_content .. "<br>"
- _small_content = _small_content .. "<form method='POST'>"
- _small_content = _small_content .. "<input type='submit' name='AGHRRRR' value='Stop'>"
- _small_content = _small_content .. "</form>"
- return _small_content
- end
- if (GENERATION_STATE == 2 or GENERATION_STATE == 4) then
- Content = ProcessingContent()
- return Content
- end
- -- SELECTING
- --------------------------------------------------------------------------------------------------
- if ( Request.PostParams["FormSetWorld"] ) then
- WORK_WORLD = Request.PostParams["FormWorldName"]
- WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
- end
-
- if( Request.PostParams["SelectWorld"] ~= nil
- and Request.PostParams["WorldName"] ~= nil ) then -- World is selected!
- WORK_WORLD = Request.PostParams["WorldName"]
- WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
- end
-
- if(Request.PostParams["OperationGenerate"] ~= nil) then
- OPERATION_CODE = 0
- end
- if(Request.PostParams["OperationReGenerate"] ~= nil) then
- OPERATION_CODE = 1
- end
-
- if (GENERATION_STATE == 0) then
- if( Request.PostParams["FormAreaStartX"] ~= nil
- and Request.PostParams["FormAreaStartZ"] ~= nil
- and Request.PostParams["FormAreaEndX"] ~= nil
- and Request.PostParams["FormAreaEndZ"] ~= nil ) then --(Re)Generation valid!
- -- COMMON (Re)gen
- if( Request.PostParams["StartArea"]) then
- AreaStartX = tonumber(Request.PostParams["FormAreaStartX"])
- AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"])
- AreaEndX = tonumber(Request.PostParams["FormAreaEndX"])
- AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"])
-
- PLUGIN.IniFile:DeleteValue("Area data", "StartX")
- PLUGIN.IniFile:DeleteValue("Area data", "StartZ")
- PLUGIN.IniFile:DeleteValue("Area data", "EndX")
- PLUGIN.IniFile:DeleteValue("Area data", "EndZ")
- PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX)
- PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ)
- PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX)
- PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ)
- if (OPERATION_CODE == 0) then
- GENERATION_STATE = 1
- elseif (OPERATION_CODE == 1) then
- GENERATION_STATE = 3
- end
- PLUGIN.IniFile:WriteFile()
- Content = ProcessingContent()
- return Content
- end
- end
- if( Request.PostParams["FormRadialX"] ~= nil
- and Request.PostParams["FormRadialZ"] ~= nil
- and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid!
- -- COMMON (Re)gen
- if( Request.PostParams["StartRadial"]) then
- RadialX = tonumber(Request.PostParams["FormRadialX"])
- RadialZ = tonumber(Request.PostParams["FormRadialZ"])
- Radius = tonumber(Request.PostParams["FormRadius"])
- AreaStartX = RadialX - Radius
- AreaStartZ = RadialZ - Radius
- AreaEndX = RadialX + Radius
- AreaEndZ = RadialZ + Radius
-
- PLUGIN.IniFile:DeleteValue("Radial data", "RadialX")
- PLUGIN.IniFile:DeleteValue("Radial data", "RadialZ")
- PLUGIN.IniFile:DeleteValue("Radial data", "Radius")
- PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX)
- PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ)
- PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius)
- if (OPERATION_CODE == 0) then
- GENERATION_STATE = 1
- elseif (OPERATION_CODE == 1) then
- GENERATION_STATE = 3
- end
- PLUGIN.IniFile:WriteFile()
- Content = ProcessingContent()
- return Content
- end
- end
- -- POINT REGEN!
- if( Request.PostParams["FormPointX"] ~= nil
- and Request.PostParams["FormPointZ"] ~= nil ) then --ReGeneration valid!
- -- EXACT
- if ( Request.PostParams["PointExact"] ~= nil) then
- AreaStartX = tonumber(Request.PostParams["FormPointX"])
- AreaStartZ = tonumber(Request.PostParams["FormPointZ"])
- AreaEndX = AreaStartX
- AreaEndZ = AreaStartZ
- GENERATION_STATE = 3
- Content = ProcessingContent()
- return Content
- end
- -- 3x3
- if ( Request.PostParams["Point3x3"] ~= nil) then
- AreaStartX = tonumber(Request.PostParams["FormPointX"]) - 1
- AreaStartZ = tonumber(Request.PostParams["FormPointZ"]) - 1
- AreaEndX = AreaStartX + 2
- AreaEndZ = AreaStartZ + 2
- GENERATION_STATE = 3
- Content = ProcessingContent()
- return Content
- end
- end
-
- local GetAreaByPlayer = function(Player)
- -- Player is valid only within this function, it cannot be stord and used later!
- AreaStartX = Player:GetChunkX()
- AreaStartZ = Player:GetChunkZ()
- end
- -- PLAYERS REGEN!
- if( Request.PostParams["PlayerExact"] ~= nil
- and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate...
- cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer)
- AreaEndX = AreaStartX
- AreaEndZ = AreaStartZ
- GENERATION_STATE = 3
- Content = ProcessingContent()
- return Content
- end
- if( Request.PostParams["Player3x3"] ~= nil
- and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate...
- cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer)
- AreaStartX = AreaStartX - 1
- AreaStartZ = AreaStartZ - 1
- AreaEndX = AreaStartX + 2
- AreaEndZ = AreaStartZ + 2
- GENERATION_STATE = 3
- Content = ProcessingContent()
- return Content
- end
- end
-
- --Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>"
- --Content = Content .. "<form method='POST'>"
- --Content = Content .. "<input type='text' name='FormWorldName' value='Input world name here'><input type='submit' name='FormSetWorld' value='Set world'>"
- --Content = Content .. "</form>"
-
- -- SELECTING WORK_WORLD
- Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>"
- Content = Content .. "<table>"
- local WorldNum = 0
- local AddWorldToTable = function(World)
- WorldNum = WorldNum + 1
- Content = Content .. "<tr>"
- Content = Content .. "<td style='width: 10px;'>" .. WorldNum .. ".</td>"
- Content = Content .. "<td>" .. World:GetName() .. "</td>"
- Content = Content .. "<td>" .. Button_World(World:GetName()) .. "</td>"
- Content = Content .. "</tr>"
- end
- cRoot:Get():ForEachWorld(AddWorldToTable)
- if( WorldNum == 0 ) then
- Content = Content .. "<tr><td>No worlds! O_O</td></tr>"
- end
- Content = Content .. "</table>"
- Content = Content .. "<br>"
-
- -- SELECTING OPERATION
- if (OPERATION_CODE == 0) then
- Content = Content .. "<h4>Operation: Generation</h4>"
- elseif (OPERATION_CODE == 1) then
- Content = Content .. "<h4>Operation: Regeneration</h4>"
- end
- Content = Content .. "<form method='POST'>"
- Content = Content .. "<input type='submit' name='OperationGenerate' value='Generation'>"
- Content = Content .. "<input type='submit' name='OperationReGenerate' value='Regeneration'>"
- Content = Content .. "</form>"
-
- -- SELECTING AREA
- Content = Content .. "<h4>Area: </h4>Start X, Start Z; End X, End Z"
- Content = Content .. "<form method='POST'>"
- Content = Content .. "<input type='text' name='FormAreaStartX' value='" .. AreaStartX .. "'><input type='text' name='FormAreaStartZ' value='" .. AreaStartZ .. "'>"
- Content = Content .. "<input type='text' name='FormAreaEndX' value='" .. AreaEndX .. "'><input type='text' name='FormAreaEndZ' value='" .. AreaEndZ .. "'>"
- Content = Content .. "<input type='submit' name='StartArea' value='Start'>"
- Content = Content .. "</form>"
-
- -- SELECTING RADIAL
- Content = Content .. "<h4>Radial: </h4>Center X, Center Z, Raduis (0 to any)"
- Content = Content .. "<form method='POST'>"
- Content = Content .. "<input type='text' name='FormRadialX' value='" .. RadialX .. "'><input type='text' name='FormRadialZ' value='" .. RadialZ .. "'><input type='text' name='FormRadius' value='" .. Radius .. "'>"
- Content = Content .. "<input type='submit' name='StartRadial' value='Start'>"
- Content = Content .. "</form>"
- Content = Content .. "<br>"
- Content = Content .. "<br>"
- Content = Content .. "<br>"
-
- -- SELECTING POINT
- Content = Content .. "<h4>Point regeneration:</h4> X, Z"
- Content = Content .. "<form method='POST'>"
- Content = Content .. "<input type='text' name='FormPointX' value='0'><input type='text' name='FormPointZ' value='0'>"
- Content = Content .. "<input type='submit' name='PointExact' value='Exact'>"
- Content = Content .. "<input type='submit' name='Point3x3' value='3x3'>"
- Content = Content .. "</form>"
-
- -- SELECTING PLAYERS
- Content = Content .. "<h4>Player-based regeneration:</h4>"
- Content = Content .. "<table>"
- local PlayerNum = 0
- local AddPlayerToTable = function( Player )
- PlayerNum = PlayerNum + 1
- Content = Content .. "<tr>"
- Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>"
- Content = Content .. "<td>" .. Player:GetName() .. "</td>"
- Content = Content .. "<td>" .. Buttons_Player(Player:GetName()) .. "</td>"
- Content = Content .. "</tr>"
- end
- if (cRoot:Get():GetWorld(WORK_WORLD) == nil) then
- Content = Content .. "<tr><td>Incorrect world selection</td></tr>"
- else
- cRoot:Get():GetWorld(WORK_WORLD):ForEachPlayer( AddPlayerToTable )
- if( PlayerNum == 0 ) then
- Content = Content .. "<tr><td>No connected players</td></tr>"
- end
- end
- Content = Content .. "</table>"
- Content = Content .. "<br>"
- return Content
+local function Buttons_Player( Name )
+ return "<form method='POST'><input type='hidden' name='PlayerName' value='"..Name.."'><input type='submit' name='PlayerExact' value='Exact'><input type='submit' name='Player3x3' value='3x3'></form>"
+end
+
+local function Button_World( Name )
+ return "<form method='POST'><input type='hidden' name='WorldName' value='"..Name.."'><input type='submit' name='SelectWorld' value='Select'></form>"
+end
+
+function HandleRequest_Generation( Request )
+ local Content = ""
+ if (Request.PostParams["AGHRRRR"] ~= nil) then
+ GENERATION_STATE = 0
+ WW_instance:SaveAllChunks()
+ WW_instance:UnloadUnusedChunks()
+ LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED by admin")
+ end
+ --Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
+ -- PROCESSING
+ --------------------------------------------------------------------------------------------------
+ local function ProcessingContent()
+ local _small_content = ""
+ _small_content = _small_content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
+ _small_content = _small_content .. "<h4>World for operations:</h4>"..WORK_WORLD
+ if (OPERATION_CODE == 0) then
+ _small_content = _small_content .. "<h4>Operation:</h4>Generation"
+ elseif (OPERATION_CODE == 1) then
+ _small_content = _small_content .. "<h4>Operation:</h4>Regeneration"
+ end
+ _small_content = _small_content .. "<h4>Area: </h4>["..AreaStartX..":"..AreaStartZ.."] ["..AreaEndX..":"..AreaEndZ.."]"
+ _small_content = _small_content .. "<h4>Progress:</h4>"..CURRENT.."/"..TOTAL
+ _small_content = _small_content .. "<br>"
+ _small_content = _small_content .. "<form method='POST'>"
+ _small_content = _small_content .. "<input type='submit' name='AGHRRRR' value='Stop'>"
+ _small_content = _small_content .. "</form>"
+ return _small_content
+ end
+ if (GENERATION_STATE == 2 or GENERATION_STATE == 4) then
+ Content = ProcessingContent()
+ return Content
+ end
+ -- SELECTING
+ --------------------------------------------------------------------------------------------------
+ if ( Request.PostParams["FormSetWorld"] ) then
+ WORK_WORLD = Request.PostParams["FormWorldName"]
+ WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
+ end
+
+ if( Request.PostParams["SelectWorld"] ~= nil
+ and Request.PostParams["WorldName"] ~= nil ) then -- World is selected!
+ WORK_WORLD = Request.PostParams["WorldName"]
+ WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
+ end
+
+ if(Request.PostParams["OperationGenerate"] ~= nil) then
+ OPERATION_CODE = 0
+ end
+ if(Request.PostParams["OperationReGenerate"] ~= nil) then
+ OPERATION_CODE = 1
+ end
+
+ if (GENERATION_STATE == 0) then
+ if( Request.PostParams["FormAreaStartX"] ~= nil
+ and Request.PostParams["FormAreaStartZ"] ~= nil
+ and Request.PostParams["FormAreaEndX"] ~= nil
+ and Request.PostParams["FormAreaEndZ"] ~= nil ) then --(Re)Generation valid!
+ -- COMMON (Re)gen
+ if( Request.PostParams["StartArea"]) then
+ AreaStartX = tonumber(Request.PostParams["FormAreaStartX"])
+ AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"])
+ AreaEndX = tonumber(Request.PostParams["FormAreaEndX"])
+ AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"])
+
+ PLUGIN.IniFile:DeleteValue("Area data", "StartX")
+ PLUGIN.IniFile:DeleteValue("Area data", "StartZ")
+ PLUGIN.IniFile:DeleteValue("Area data", "EndX")
+ PLUGIN.IniFile:DeleteValue("Area data", "EndZ")
+ PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX)
+ PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ)
+ PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX)
+ PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ)
+ if (OPERATION_CODE == 0) then
+ GENERATION_STATE = 1
+ elseif (OPERATION_CODE == 1) then
+ GENERATION_STATE = 3
+ end
+ PLUGIN.IniFile:WriteFile()
+ Content = ProcessingContent()
+ return Content
+ end
+ end
+ if( Request.PostParams["FormRadialX"] ~= nil
+ and Request.PostParams["FormRadialZ"] ~= nil
+ and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid!
+ -- COMMON (Re)gen
+ if( Request.PostParams["StartRadial"]) then
+ RadialX = tonumber(Request.PostParams["FormRadialX"])
+ RadialZ = tonumber(Request.PostParams["FormRadialZ"])
+ Radius = tonumber(Request.PostParams["FormRadius"])
+ AreaStartX = RadialX - Radius
+ AreaStartZ = RadialZ - Radius
+ AreaEndX = RadialX + Radius
+ AreaEndZ = RadialZ + Radius
+
+ PLUGIN.IniFile:DeleteValue("Radial data", "RadialX")
+ PLUGIN.IniFile:DeleteValue("Radial data", "RadialZ")
+ PLUGIN.IniFile:DeleteValue("Radial data", "Radius")
+ PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX)
+ PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ)
+ PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius)
+ if (OPERATION_CODE == 0) then
+ GENERATION_STATE = 1
+ elseif (OPERATION_CODE == 1) then
+ GENERATION_STATE = 3
+ end
+ PLUGIN.IniFile:WriteFile()
+ Content = ProcessingContent()
+ return Content
+ end
+ end
+ -- POINT REGEN!
+ if( Request.PostParams["FormPointX"] ~= nil
+ and Request.PostParams["FormPointZ"] ~= nil ) then --ReGeneration valid!
+ -- EXACT
+ if ( Request.PostParams["PointExact"] ~= nil) then
+ AreaStartX = tonumber(Request.PostParams["FormPointX"])
+ AreaStartZ = tonumber(Request.PostParams["FormPointZ"])
+ AreaEndX = AreaStartX
+ AreaEndZ = AreaStartZ
+ GENERATION_STATE = 3
+ Content = ProcessingContent()
+ return Content
+ end
+ -- 3x3
+ if ( Request.PostParams["Point3x3"] ~= nil) then
+ AreaStartX = tonumber(Request.PostParams["FormPointX"]) - 1
+ AreaStartZ = tonumber(Request.PostParams["FormPointZ"]) - 1
+ AreaEndX = AreaStartX + 2
+ AreaEndZ = AreaStartZ + 2
+ GENERATION_STATE = 3
+ Content = ProcessingContent()
+ return Content
+ end
+ end
+
+ local GetAreaByPlayer = function(Player)
+ -- Player is valid only within this function, it cannot be stord and used later!
+ AreaStartX = Player:GetChunkX()
+ AreaStartZ = Player:GetChunkZ()
+ end
+ -- PLAYERS REGEN!
+ if( Request.PostParams["PlayerExact"] ~= nil
+ and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate...
+ cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer)
+ AreaEndX = AreaStartX
+ AreaEndZ = AreaStartZ
+ GENERATION_STATE = 3
+ Content = ProcessingContent()
+ return Content
+ end
+ if( Request.PostParams["Player3x3"] ~= nil
+ and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate...
+ cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer)
+ AreaStartX = AreaStartX - 1
+ AreaStartZ = AreaStartZ - 1
+ AreaEndX = AreaStartX + 2
+ AreaEndZ = AreaStartZ + 2
+ GENERATION_STATE = 3
+ Content = ProcessingContent()
+ return Content
+ end
+ end
+
+ --Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>"
+ --Content = Content .. "<form method='POST'>"
+ --Content = Content .. "<input type='text' name='FormWorldName' value='Input world name here'><input type='submit' name='FormSetWorld' value='Set world'>"
+ --Content = Content .. "</form>"
+
+ -- SELECTING WORK_WORLD
+ Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>"
+ Content = Content .. "<table>"
+ local WorldNum = 0
+ local AddWorldToTable = function(World)
+ WorldNum = WorldNum + 1
+ Content = Content .. "<tr>"
+ Content = Content .. "<td style='width: 10px;'>" .. WorldNum .. ".</td>"
+ Content = Content .. "<td>" .. World:GetName() .. "</td>"
+ Content = Content .. "<td>" .. Button_World(World:GetName()) .. "</td>"
+ Content = Content .. "</tr>"
+ end
+ cRoot:Get():ForEachWorld(AddWorldToTable)
+ if( WorldNum == 0 ) then
+ Content = Content .. "<tr><td>No worlds! O_O</td></tr>"
+ end
+ Content = Content .. "</table>"
+ Content = Content .. "<br>"
+
+ -- SELECTING OPERATION
+ if (OPERATION_CODE == 0) then
+ Content = Content .. "<h4>Operation: Generation</h4>"
+ elseif (OPERATION_CODE == 1) then
+ Content = Content .. "<h4>Operation: Regeneration</h4>"
+ end
+ Content = Content .. "<form method='POST'>"
+ Content = Content .. "<input type='submit' name='OperationGenerate' value='Generation'>"
+ Content = Content .. "<input type='submit' name='OperationReGenerate' value='Regeneration'>"
+ Content = Content .. "</form>"
+
+ -- SELECTING AREA
+ Content = Content .. "<h4>Area: </h4>Start X, Start Z; End X, End Z"
+ Content = Content .. "<form method='POST'>"
+ Content = Content .. "<input type='text' name='FormAreaStartX' value='" .. AreaStartX .. "'><input type='text' name='FormAreaStartZ' value='" .. AreaStartZ .. "'>"
+ Content = Content .. "<input type='text' name='FormAreaEndX' value='" .. AreaEndX .. "'><input type='text' name='FormAreaEndZ' value='" .. AreaEndZ .. "'>"
+ Content = Content .. "<input type='submit' name='StartArea' value='Start'>"
+ Content = Content .. "</form>"
+
+ -- SELECTING RADIAL
+ Content = Content .. "<h4>Radial: </h4>Center X, Center Z, Raduis (0 to any)"
+ Content = Content .. "<form method='POST'>"
+ Content = Content .. "<input type='text' name='FormRadialX' value='" .. RadialX .. "'><input type='text' name='FormRadialZ' value='" .. RadialZ .. "'><input type='text' name='FormRadius' value='" .. Radius .. "'>"
+ Content = Content .. "<input type='submit' name='StartRadial' value='Start'>"
+ Content = Content .. "</form>"
+ Content = Content .. "<br>"
+ Content = Content .. "<br>"
+ Content = Content .. "<br>"
+
+ -- SELECTING POINT
+ Content = Content .. "<h4>Point regeneration:</h4> X, Z"
+ Content = Content .. "<form method='POST'>"
+ Content = Content .. "<input type='text' name='FormPointX' value='0'><input type='text' name='FormPointZ' value='0'>"
+ Content = Content .. "<input type='submit' name='PointExact' value='Exact'>"
+ Content = Content .. "<input type='submit' name='Point3x3' value='3x3'>"
+ Content = Content .. "</form>"
+
+ -- SELECTING PLAYERS
+ Content = Content .. "<h4>Player-based regeneration:</h4>"
+ Content = Content .. "<table>"
+ local PlayerNum = 0
+ local AddPlayerToTable = function( Player )
+ PlayerNum = PlayerNum + 1
+ Content = Content .. "<tr>"
+ Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>"
+ Content = Content .. "<td>" .. Player:GetName() .. "</td>"
+ Content = Content .. "<td>" .. Buttons_Player(Player:GetName()) .. "</td>"
+ Content = Content .. "</tr>"
+ end
+ if (cRoot:Get():GetWorld(WORK_WORLD) == nil) then
+ Content = Content .. "<tr><td>Incorrect world selection</td></tr>"
+ else
+ cRoot:Get():GetWorld(WORK_WORLD):ForEachPlayer( AddPlayerToTable )
+ if( PlayerNum == 0 ) then
+ Content = Content .. "<tr><td>No connected players</td></tr>"
+ end
+ end
+ Content = Content .. "</table>"
+ Content = Content .. "<br>"
+ return Content
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/Core.deproj b/MCServer/Plugins/Core/Core.deproj
deleted file mode 100644
index 36ba2d29a..000000000
--- a/MCServer/Plugins/Core/Core.deproj
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<project>
- <file>
- <filename>back.lua</filename>
- </file>
- <file>
- <filename>ban.lua</filename>
- </file>
- <file>
- <filename>console.lua</filename>
- </file>
- <file>
- <filename>coords.lua</filename>
- </file>
- <file>
- <filename>gamemode.lua</filename>
- </file>
- <file>
- <filename>gotoworld.lua</filename>
- </file>
- <file>
- <filename>help.lua</filename>
- </file>
- <file>
- <filename>item.lua</filename>
- </file>
- <file>
- <filename>kick.lua</filename>
- </file>
- <file>
- <filename>listgroups.lua</filename>
- </file>
- <file>
- <filename>main.lua</filename>
- </file>
- <file>
- <filename>motd.lua</filename>
- </file>
- <file>
- <filename>onchunkgenerating.lua</filename>
- </file>
- <file>
- <filename>oncraftingnorecipe.lua</filename>
- </file>
- <file>
- <filename>onkilling.lua</filename>
- </file>
- <file>
- <filename>onlogin.lua</filename>
- </file>
- <file>
- <filename>onplayerbreakingblock.lua</filename>
- </file>
- <file>
- <filename>onplayerjoined.lua</filename>
- </file>
- <file>
- <filename>onplayermoving.lua</filename>
- </file>
- <file>
- <filename>onplayerplacingblock.lua</filename>
- </file>
- <file>
- <filename>playerlist.lua</filename>
- </file>
- <file>
- <filename>pluginlist.lua</filename>
- </file>
- <file>
- <filename>rank.lua</filename>
- </file>
- <file>
- <filename>regeneratechunk.lua</filename>
- </file>
- <file>
- <filename>reload.lua</filename>
- </file>
- <file>
- <filename>saveall.lua</filename>
- </file>
- <file>
- <filename>spawn.lua</filename>
- </file>
- <file>
- <filename>stop.lua</filename>
- </file>
- <file>
- <filename>teleport.lua</filename>
- </file>
- <file>
- <filename>time.lua</filename>
- </file>
- <file>
- <filename>top.lua</filename>
- </file>
- <file>
- <filename>unban.lua</filename>
- </file>
- <file>
- <filename>viewdistance.lua</filename>
- </file>
- <file>
- <filename>weather.lua</filename>
- </file>
- <file>
- <filename>web_chat.lua</filename>
- </file>
- <file>
- <filename>web_manageplugins.lua</filename>
- </file>
- <file>
- <filename>web_manageserver.lua</filename>
- </file>
- <file>
- <filename>web_permissions.lua</filename>
- </file>
- <file>
- <filename>web_playerlist.lua</filename>
- </file>
- <file>
- <filename>web_serversettings.lua</filename>
- </file>
- <file>
- <filename>web_whitelist.lua</filename>
- </file>
-</project>
diff --git a/MCServer/Plugins/Core/README.md b/MCServer/Plugins/Core/README.md
new file mode 100644
index 000000000..d840459a0
--- /dev/null
+++ b/MCServer/Plugins/Core/README.md
@@ -0,0 +1,23 @@
+Core Plugin (Forked)
+===========
+
+A fork of MCServer's Core plugin.
+
+**New Features:**
+* Simplified commands, such as 'gotoworld' -> 'portal'
+* Simplified and combined LUA files, such as 'listworlds.lua & gotoworld.lua' -> 'worlds-portal.lua'
+* Fixed 'tp' command not working due to typography errors
+* Fixed 'arithmetic on nil value' on startup due to inactivation of world limiter
+* Massive overhaul / redesign of webadmin GUI interface.
+ * Added jQuery transition effect
+ * Completely redesigned CSS
+ * Added new logo
+ * Made HTML5 compliant
+* Beautified 'help' menu
+* Rewrite of death messages - fixed strange grammar and edited to more faithfully reflect Vanilla
+* Added 'unban' console command
+
+**How to Use**
+
+Simply copy all LUA files into Plugins/Core (delete existing files first, except banned.ini and whitelist.ini!)
+Then, copy webadmin to MCServer root directory (delete existing directory first!)
diff --git a/MCServer/Plugins/Core/back.lua b/MCServer/Plugins/Core/back.lua
index 63ec1d857..cc215ba11 100644
--- a/MCServer/Plugins/Core/back.lua
+++ b/MCServer/Plugins/Core/back.lua
@@ -1,9 +1,9 @@
-function HandleBackCommand( Split, Player )
- if BackCoords[Player:GetName()] == nil then
- Player:SendMessage(cChatColor.Green .. "There is no last position known")
- else
- Player:TeleportToCoords(BackCoords[Player:GetName()].x, BackCoords[Player:GetName()].y, BackCoords[Player:GetName()].z)
- Player:SendMessage(cChatColor.Green .. "You teleported back to your last known position")
- end
- return true
+function HandleBackCommand( Split, Player )
+ if BackCoords[Player:GetName()] == nil then
+ Player:SendMessage(cChatColor.Green .. "There is no last position known")
+ else
+ Player:TeleportToCoords(BackCoords[Player:GetName()].x, BackCoords[Player:GetName()].y, BackCoords[Player:GetName()].z)
+ Player:SendMessage(cChatColor.Green .. "You teleported back to your last known position")
+ end
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/ban.lua b/MCServer/Plugins/Core/ban-unban.lua
index 4e882b66f..cee511e37 100644
--- a/MCServer/Plugins/Core/ban.lua
+++ b/MCServer/Plugins/Core/ban-unban.lua
@@ -1,44 +1,60 @@
-function HandleBanCommand( Split, Player )
- if( #Split < 2 ) then
- Player:SendMessage( cChatColor.Green .. "Usage: /ban [Player] <Reason>" )
- return true
- end
-
- local Reason = "You have been banned"
- if( #Split > 2 ) then
- Reason = table.concat(Split, " ", 3)
- end
-
-
- if( BanPlayer(Split[2], Reason) == false ) then
- Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] )
- return true
- end
-
- return true
-end
-
-
-
-
-
-function BanPlayer(PlayerName, Reason)
- -- Ban the player in the banned.ini:
- BannedPlayersIni:SetValueB("Banned", PlayerName, true)
- BannedPlayersIni:WriteFile()
-
- -- Kick the player:
- if (Reason == nil) then
- Reason = "You have been banned"
- end
- local Success = KickPlayer(PlayerName, Reason)
- if (not(Success)) then
- return false;
- end
-
- LOGINFO("'" .. PlayerName .. "' has been banned (\"" .. Reason .. "\") ");
- local Server = cRoot:Get():GetServer();
- Server:SendMessage("Banned " .. PlayerName);
-
- return true
+function HandleBanCommand( Split, Player )
+ if( #Split < 2 ) then
+ Player:SendMessage( cChatColor.Green .. "Usage: /ban [Player] <Reason>" )
+ return true
+ end
+
+ local Reason = "You have been banned"
+ if( #Split > 2 ) then
+ Reason = table.concat(Split, " ", 3)
+ end
+
+ if( BanPlayer(Split[2], Reason) == false ) then
+ Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] )
+ return true
+ end
+
+ return true
+end
+
+function BanPlayer(PlayerName, Reason)
+ -- Ban the player in the banned.ini:
+ BannedPlayersIni:SetValueB("Banned", PlayerName, true)
+ BannedPlayersIni:WriteFile()
+
+ -- Kick the player:
+ if (Reason == nil) then
+ Reason = "You have been banned"
+ end
+ local Success = KickPlayer(PlayerName, Reason)
+ if (not(Success)) then
+ return false;
+ end
+
+ LOGINFO("'" .. PlayerName .. "' has been banned (\"" .. Reason .. "\") ");
+ local Server = cRoot:Get():GetServer();
+ Server:SendMessage("Banned " .. PlayerName);
+
+ return true
+end
+
+function HandleUnbanCommand( Split, Player )
+ if( #Split < 2 ) then
+ Player:SendMessage( cChatColor.Green .. "Usage: /unban [Player]" )
+ return true
+ end
+
+ if( BannedPlayersIni:GetValueB("Banned", Split[2], false) == false ) then
+ Player:SendMessage( cChatColor.Green .. Split[2] .. " is not banned!" )
+ return true
+ end
+
+ BannedPlayersIni:SetValueB("Banned", Split[2], false, false)
+ BannedPlayersIni:WriteFile()
+
+ local Server = cRoot:Get():GetServer()
+ LOGINFO( Player:GetName() .. " is unbanning " .. Split[2] )
+ Server:SendMessage( "Unbanning " .. Split[2] )
+
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/console.lua b/MCServer/Plugins/Core/console.lua
index df90a9b9a..b1c454d59 100644
--- a/MCServer/Plugins/Core/console.lua
+++ b/MCServer/Plugins/Core/console.lua
@@ -1,343 +1,288 @@
-
--- console.lua
-
--- Implements things related to console commands
-
-
-
-
-
-function InitConsoleCommands()
- local PluginMgr = cPluginManager:Get();
-
- -- Please keep the list alpha-sorted
- PluginMgr:BindConsoleCommand("ban", HandleConsoleBan, "Bans a player by name");
- PluginMgr:BindConsoleCommand("banlist", HandleConsoleBanList, "Lists all players banned by name");
- PluginMgr:BindConsoleCommand("banlist ips", HandleConsoleBanList, "Lists all players banned by IP");
- PluginMgr:BindConsoleCommand("help", HandleConsoleHelp, "Lists all commands");
- PluginMgr:BindConsoleCommand("list", HandleConsoleList, "Lists all players in a machine-readable format");
- PluginMgr:BindConsoleCommand("listgroups", HandleConsoleListGroups, "Shows a list of all the groups");
- PluginMgr:BindConsoleCommand("numchunks", HandleConsoleNumChunks, "Shows number of chunks currently loaded");
- PluginMgr:BindConsoleCommand("players", HandleConsolePlayers, "Lists all connected players");
- PluginMgr:BindConsoleCommand("primaryserverversion", HandleConsolePrimaryServerVersion, "Gets or sets server version reported to 1.4+ clients");
- PluginMgr:BindConsoleCommand("rank", HandleConsoleRank, " [Player] [Group] - add a player to a group");
- PluginMgr:BindConsoleCommand("reload", HandleConsoleReload, "Reloads all plugins");
- PluginMgr:BindConsoleCommand("save-all", HandleConsoleSaveAll, "Saves all chunks");
- PluginMgr:BindConsoleCommand("say", HandleConsoleSay, "Sends a chat message to all players");
- PluginMgr:BindConsoleCommand("unload", HandleConsoleUnload, "Unloads all unused chunks");
-end
-
-
-
-
-
-function HandleConsoleBan(Split)
- if (#Split < 2) then
- return true, cChatColor.Green .. "Usage: /ban [Player] <Reason>";
- end
-
- local Reason = "You have been banned"
- if (#Split > 2) then
- Reason = table.concat(Split, " ", 3);
- end
-
-
- if (not(BanPlayer(Split[2], Reason))) then
- return true, cChatColor.Green .. "Could not find player " .. Split[2];
- end
-
- return true, "Player " .. Split[2] .. " has been banned.";
-end
-
-
-
-
-
-function HandleConsoleBanList(Split)
- if (#Split == 1) then
- return true, BanListByName();
- end
-
- if (string.lower(Split[2]) == "ips") then
- return true, BanListByIPs();
- end
-
- return true, "Unknown banlist subcommand";
-end
-
-
-
-
-
-function HandleConsoleHelp(Split)
- local Commands = {}; -- {index => {"Command", "HelpString"} }
- local MaxLength = 0;
- local AddToTable = function(Command, HelpString)
- table.insert(Commands, { Command, HelpString });
- local CmdLen = Command:len();
- if (CmdLen > MaxLength) then
- MaxLength = CmdLen;
- end
- end
-
- cPluginManager:Get():ForEachConsoleCommand(AddToTable);
-
- -- Sort the table:
- local CompareCommands = function(a, b)
- return a[1] < b[1]; -- compare command strings
- end
- table.sort(Commands, CompareCommands);
-
- local Out = "";
- for i, Command in ipairs(Commands) do
- Out = Out .. Command[1] .. string.rep(" ", MaxLength - Command[1]:len()); -- Align to a table
- Out = Out .. " - " .. Command[2] .. "\n";
- end
- return true, Out;
-end
-
-
-
-
-
-function HandleConsoleList(Split)
- -- Get a list of all players, one playername per line
- local Out = "";
- cRoot:Get():ForEachWorld(
- function (a_World)
- a_World:ForEachPlayer(
- function (a_Player)
- Out = Out .. a_Player:GetName() .. "\n";
- end
- );
- end
- );
- return true, Out;
-end
-
-
-
-
-
-function HandleConsoleListGroups(Split)
- -- Read the groups.ini file:
- local GroupsIni = cIniFile("groups.ini");
- if (not(GroupsIni:ReadFile())) then
- return true, "No groups found";
- end
-
- -- Read the groups:
- Number = GroupsIni:NumKeys();
- Groups = {};
- for i = 0, Number do
- table.insert(Groups, GroupsIni:KeyName(i))
- end
-
- -- Output the groups, concatenated to a string:
- local Out = "Groups:\n"
- Out = Out .. table.concat(Groups, ", ");
- return true, Out;
-end
-
-
-
-
-
-function HandleConsoleNumChunks(Split)
- local Output = {};
- local AddNumChunks = function(World)
- Output[World:GetName()] = World:GetNumChunks();
- end;
-
- cRoot:Get():ForEachWorld(AddNumChunks);
-
- local Total = 0;
- local Out = "";
- for name, num in pairs(Output) do
- Out = Out .. " " .. name .. ": " .. num .. " chunks\n";
- Total = Total + num;
- end
- Out = Out .. "Total: " .. Total .. " chunks\n";
-
- return true, Out;
-end
-
-
-
-
-
-function HandleConsolePlayers(Split)
- local PlayersInWorlds = {}; -- "WorldName" => [players array]
- local AddToTable = function(Player)
- local WorldName = Player:GetWorld():GetName();
- if (PlayersInWorlds[WorldName] == nil) then
- PlayersInWorlds[WorldName] = {};
- end
- table.insert(PlayersInWorlds[WorldName], Player:GetName() .. " @ " .. Player:GetIP());
- end
-
- cRoot:Get():ForEachPlayer(AddToTable);
-
- local Out = "";
- for WorldName, Players in pairs(PlayersInWorlds) do
- Out = Out .. "World " .. WorldName .. ":\n";
- for i, PlayerName in ipairs(Players) do
- Out = Out .. " " .. PlayerName .. "\n";
- end
- end
-
- return true, Out;
-end
-
-
-
-
-
-function HandleConsolePrimaryServerVersion(Split)
- if (#Split == 1) then
- -- Display current version:
- local Version = cRoot:Get():GetPrimaryServerVersion();
- return true, "Primary server version: #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version);
- end
-
- -- Set new value as the version:
- cRoot:Get():SetPrimaryServerVersion(tonumber(Split[2]));
- local Version = cRoot:Get():GetPrimaryServerVersion();
- return true, "Primary server version is now #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version);
-end
-
-
-
-
-
-function HandleConsoleRank(Split)
- if (Split[2] == nil) or (Split[3] == nil) then
- return true, "Usage: /rank [Player] [Group]";
- end
- local Out = "";
-
- -- Read the groups.ini file:
- local GroupsIni = cIniFile("groups.ini")
- if (not(GroupsIni:ReadFile())) then
- Out = "Could not read groups.ini, creating anew!\n"
- end
-
- -- Find the group:
- if (GroupsIni:FindKey(Split[3]) == -1) then
- return true, Out .. "Group does not exist";
- end
-
- -- Read the users.ini file:
- local UsersIni = cIniFile("users.ini");
- if (not(UsersIni:ReadFile())) then
- Out = Out .. "Could not read users.ini, creating anew!\n";
- end
-
- -- Write the new group value to users.ini:
- UsersIni:DeleteKey(Split[2]);
- UsersIni:GetValueSet(Split[2], "Groups", Split[3]);
- UsersIni:WriteFile();
-
- -- Reload the player's permissions:
- cRoot:Get():ForEachWorld(
- function (World)
- World:ForEachPlayer(
- function (Player)
- if (Player:GetName() == Split[2]) then
- Player:SendMessage(cChatColor.Green .. "You were moved to group " .. Split[3]);
- Player:LoadPermissionsFromDisk();
- end
- end
- );
- end
- )
-
- return true, Out .. "Player " .. Split[2] .. " was moved to " .. Split[3];
-end
-
-
-
-
-
-function HandleConsoleReload(Split)
- Server = cRoot:Get():GetServer();
- Server:SendMessage(cChatColor.Green .. "Reloading all plugins.");
- cPluginManager:Get():ReloadPlugins();
- return true;
-end
-
-
-
-
-
-function HandleConsoleSaveAll(Split)
- cRoot:Get():SaveAllChunks();
- return true;
-end
-
-
-
-
-
-function HandleConsoleSay(Split)
- table.remove(Split, 1);
- local Message = "";
- for i, Text in ipairs(Split) do
- Message = Message .. " " .. Text;
- end
- Message = Message:sub(2); -- Cut off the first space
- cRoot:Get():GetServer():BroadcastChat(cChatColor.Purple .. "[SERVER] " .. Message);
- return true;
-end
-
-
-
-
-
-function HandleConsoleUnload(Split)
- local UnloadChunks = function(World)
- World:UnloadUnusedChunks();
- end
-
- local Out = "Num loaded chunks before: " .. cRoot:Get():GetTotalChunkCount() .. "\n";
- cRoot:Get():ForEachWorld(UnloadChunks);
- Out = Out .. "Num loaded chunks after: " .. cRoot:Get():GetTotalChunkCount();
- return true, Out;
-end
-
-
-
-
-
-
--------------------------------------------------------------------------------------------
--- Helper functions:
-
---- Returns the list of players banned by name, separated by ", "
-function BanListByName()
- local NumValues = BannedPlayersIni:NumValues("Banned");
- local Banned = {};
- local KeyID = BannedPlayersIni:FindKey("Banned");
- for i = 1, NumValues do
- local PlayerName = BannedPlayersIni:ValueName(KeyID, i - 1);
- if (BannedPlayersIni:GetValueB("Banned", PlayerName)) then
- -- Player listed AND banned
- table.insert(Banned, PlayerName);
- end
- end
- return table.concat(Banned, ", ");
-end
-
-
-
-
-
---- Returns the list of players banned by IP, separated by ", "
-function BanListByIPs()
- -- TODO: No IP ban implemented yet
- return "";
-end
-
-
-
-
+-- Implements things related to console commands
+
+function InitConsoleCommands()
+ local PluginMgr = cPluginManager:Get();
+
+ -- Please keep the list alpha-sorted
+ PluginMgr:BindConsoleCommand("ban", HandleConsoleBan, "Bans a player by name");
+ PluginMgr:BindConsoleCommand("unban", HandleConsoleUnban, "Unbans a player by name");
+ PluginMgr:BindConsoleCommand("banlist", HandleConsoleBanList, "Lists all players banned by name");
+ PluginMgr:BindConsoleCommand("banlist ips", HandleConsoleBanList, "Lists all players banned by IP");
+ PluginMgr:BindConsoleCommand("help", HandleConsoleHelp, "Lists all commands");
+ PluginMgr:BindConsoleCommand("list", HandleConsoleList, "Lists all players in a machine-readable format");
+ PluginMgr:BindConsoleCommand("listgroups", HandleConsoleListGroups, "Shows a list of all the groups");
+ PluginMgr:BindConsoleCommand("numchunks", HandleConsoleNumChunks, "Shows number of chunks currently loaded");
+ PluginMgr:BindConsoleCommand("players", HandleConsolePlayers, "Lists all connected players");
+ PluginMgr:BindConsoleCommand("primaryserverversion", HandleConsolePrimaryServerVersion, "Gets or sets server version reported to 1.4+ clients");
+ PluginMgr:BindConsoleCommand("rank", HandleConsoleRank, " [Player] [Group] - add a player to a group");
+ PluginMgr:BindConsoleCommand("reload", HandleConsoleReload, "Reloads all plugins");
+ PluginMgr:BindConsoleCommand("save-all", HandleConsoleSaveAll, "Saves all chunks");
+ PluginMgr:BindConsoleCommand("say", HandleConsoleSay, "Sends a chat message to all players");
+ PluginMgr:BindConsoleCommand("unload", HandleConsoleUnload, "Unloads all unused chunks");
+end
+
+function HandleConsoleBan(Split)
+ if (#Split < 2) then
+ return true, "Usage: ban [Player] <Reason>";
+ end
+
+ local Reason = "You have been banned"
+ if (#Split > 2) then
+ Reason = table.concat(Split, " ", 3);
+ end
+
+
+ if (not(BanPlayer(Split[2], Reason))) then
+ return true, "Could not find player " .. Split[2];
+ end
+
+ return true, "Player " .. Split[2] .. " has been banned.";
+end
+
+function HandleConsoleUnban(Split)
+ if( #Split < 2 ) then
+ return true, "Usage: /unban [Player]"
+ end
+
+ if( BannedPlayersIni:GetValueB("Banned", Split[2], false) == false ) then
+ return true, Split[2] .. " is not banned!"
+ end
+
+ BannedPlayersIni:SetValueB("Banned", Split[2], false, false)
+ BannedPlayersIni:WriteFile()
+
+ local Server = cRoot:Get():GetServer()
+ return true, "Unbanned " .. Split[2]
+end
+
+function HandleConsoleBanList(Split)
+ if (#Split == 1) then
+ return true, BanListByName();
+ end
+
+ if (string.lower(Split[2]) == "ips") then
+ return true, BanListByIPs();
+ end
+
+ return true, "Unknown banlist subcommand";
+end
+
+function HandleConsoleHelp(Split)
+ local Commands = {}; -- {index => {"Command", "HelpString"} }
+ local MaxLength = 0;
+ local AddToTable = function(Command, HelpString)
+ table.insert(Commands, { Command, HelpString });
+ local CmdLen = Command:len();
+ if (CmdLen > MaxLength) then
+ MaxLength = CmdLen;
+ end
+ end
+
+ cPluginManager:Get():ForEachConsoleCommand(AddToTable);
+
+ -- Sort the table:
+ local CompareCommands = function(a, b)
+ return a[1] < b[1]; -- compare command strings
+ end
+ table.sort(Commands, CompareCommands);
+
+ local Out = "";
+ for i, Command in ipairs(Commands) do
+ Out = Out .. Command[1] .. string.rep(" ", MaxLength - Command[1]:len()); -- Align to a table
+ Out = Out .. " - " .. Command[2] .. "\n";
+ end
+ return true, Out;
+end
+
+function HandleConsoleList(Split)
+ -- Get a list of all players, one playername per line
+ local Out = "";
+ cRoot:Get():ForEachWorld(
+ function (a_World)
+ a_World:ForEachPlayer(
+ function (a_Player)
+ Out = Out .. a_Player:GetName() .. "\n";
+ end
+ );
+ end
+ );
+ return true, Out;
+end
+
+function HandleConsoleListGroups(Split)
+ -- Read the groups.ini file:
+ local GroupsIni = cIniFile("groups.ini");
+ if (not(GroupsIni:ReadFile())) then
+ return true, "No groups found";
+ end
+
+ -- Read the groups:
+ Number = GroupsIni:NumKeys();
+ Groups = {};
+ for i = 0, Number do
+ table.insert(Groups, GroupsIni:KeyName(i))
+ end
+
+ -- Output the groups, concatenated to a string:
+ local Out = "Groups:\n"
+ Out = Out .. table.concat(Groups, ", ");
+ return true, Out;
+end
+
+function HandleConsoleNumChunks(Split)
+ local Output = {};
+ local AddNumChunks = function(World)
+ Output[World:GetName()] = World:GetNumChunks();
+ end;
+
+ cRoot:Get():ForEachWorld(AddNumChunks);
+
+ local Total = 0;
+ local Out = "";
+ for name, num in pairs(Output) do
+ Out = Out .. " " .. name .. ": " .. num .. " chunks\n";
+ Total = Total + num;
+ end
+ Out = Out .. "Total: " .. Total .. " chunks\n";
+
+ return true, Out;
+end
+
+function HandleConsolePlayers(Split)
+ local PlayersInWorlds = {}; -- "WorldName" => [players array]
+ local AddToTable = function(Player)
+ local WorldName = Player:GetWorld():GetName();
+ if (PlayersInWorlds[WorldName] == nil) then
+ PlayersInWorlds[WorldName] = {};
+ end
+ table.insert(PlayersInWorlds[WorldName], Player:GetName() .. " @ " .. Player:GetIP());
+ end
+
+ cRoot:Get():ForEachPlayer(AddToTable);
+
+ local Out = "";
+ for WorldName, Players in pairs(PlayersInWorlds) do
+ Out = Out .. "World " .. WorldName .. ":\n";
+ for i, PlayerName in ipairs(Players) do
+ Out = Out .. " " .. PlayerName .. "\n";
+ end
+ end
+
+ return true, Out;
+end
+
+function HandleConsolePrimaryServerVersion(Split)
+ if (#Split == 1) then
+ -- Display current version:
+ local Version = cRoot:Get():GetPrimaryServerVersion();
+ return true, "Primary server version: #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version);
+ end
+
+ -- Set new value as the version:
+ cRoot:Get():SetPrimaryServerVersion(tonumber(Split[2]));
+ local Version = cRoot:Get():GetPrimaryServerVersion();
+ return true, "Primary server version is now #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version);
+end
+
+function HandleConsoleRank(Split)
+ if (Split[2] == nil) or (Split[3] == nil) then
+ return true, "Usage: /rank [Player] [Group]";
+ end
+ local Out = "";
+
+ -- Read the groups.ini file:
+ local GroupsIni = cIniFile("groups.ini")
+ if (not(GroupsIni:ReadFile())) then
+ Out = "Could not read groups.ini, creating anew!\n"
+ end
+
+ -- Find the group:
+ if (GroupsIni:FindKey(Split[3]) == -1) then
+ return true, Out .. "Group does not exist";
+ end
+
+ -- Read the users.ini file:
+ local UsersIni = cIniFile("users.ini");
+ if (not(UsersIni:ReadFile())) then
+ Out = Out .. "Could not read users.ini, creating anew!\n";
+ end
+
+ -- Write the new group value to users.ini:
+ UsersIni:DeleteKey(Split[2]);
+ UsersIni:GetValueSet(Split[2], "Groups", Split[3]);
+ UsersIni:WriteFile();
+
+ -- Reload the player's permissions:
+ cRoot:Get():ForEachWorld(
+ function (World)
+ World:ForEachPlayer(
+ function (Player)
+ if (Player:GetName() == Split[2]) then
+ Player:SendMessage(cChatColor.Green .. "You were moved to group " .. Split[3]);
+ Player:LoadPermissionsFromDisk();
+ end
+ end
+ );
+ end
+ )
+
+ return true, Out .. "Player " .. Split[2] .. " was moved to " .. Split[3];
+end
+
+function HandleConsoleReload(Split)
+ Server = cRoot:Get():GetServer();
+ Server:SendMessage(cChatColor.Green .. "Reloading all plugins.");
+ cPluginManager:Get():ReloadPlugins();
+ return true;
+end
+
+function HandleConsoleSaveAll(Split)
+ cRoot:Get():SaveAllChunks();
+ return true;
+end
+
+function HandleConsoleSay(Split)
+ table.remove(Split, 1);
+ local Message = "";
+ for i, Text in ipairs(Split) do
+ Message = Message .. " " .. Text;
+ end
+ Message = Message:sub(2); -- Cut off the first space
+ cRoot:Get():GetServer():BroadcastChat(cChatColor.Purple .. "[SERVER] " .. Message);
+ return true;
+end
+
+function HandleConsoleUnload(Split)
+ local UnloadChunks = function(World)
+ World:UnloadUnusedChunks();
+ end
+
+ local Out = "Num loaded chunks before: " .. cRoot:Get():GetTotalChunkCount() .. "\n";
+ cRoot:Get():ForEachWorld(UnloadChunks);
+ Out = Out .. "Num loaded chunks after: " .. cRoot:Get():GetTotalChunkCount();
+ return true, Out;
+end
+
+
+-- Helper functions:
+
+--- Returns the list of players banned by name, separated by ", "
+function BanListByName()
+ local NumValues = BannedPlayersIni:NumValues("Banned");
+ local Banned = {};
+ local KeyID = BannedPlayersIni:FindKey("Banned");
+ for i = 1, NumValues do
+ local PlayerName = BannedPlayersIni:ValueName(KeyID, i - 1);
+ if (BannedPlayersIni:GetValueB("Banned", PlayerName)) then
+ -- Player listed AND banned
+ table.insert(Banned, PlayerName);
+ end
+ end
+ return table.concat(Banned, ", ");
+end
+
+--- Returns the list of players banned by IP, separated by ", "
+function BanListByIPs()
+ -- TODO: No IP ban implemented yet
+ return "";
+end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/functions.lua b/MCServer/Plugins/Core/functions.lua
index 36fb3786f..5fc0173b9 100644
--- a/MCServer/Plugins/Core/functions.lua
+++ b/MCServer/Plugins/Core/functions.lua
@@ -1,3 +1,3 @@
-function SetBackCoordinates( Player )
- BackCoords[Player:GetName()] = Vector3i( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() )
+function SetBackCoordinates( Player )
+ BackCoords[Player:GetName()] = Vector3i( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() )
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/item.lua b/MCServer/Plugins/Core/give.lua
index 86ff0576f..d0fc026a6 100644
--- a/MCServer/Plugins/Core/item.lua
+++ b/MCServer/Plugins/Core/give.lua
@@ -1,39 +1,39 @@
-function HandleItemCommand(Split, Player)
- if ((#Split ~= 2) and (#Split ~=3)) then
- Player:SendMessage(cChatColor.Green .. "Usage: /item [ItemType/Name:Dmg] <Amount>");
- return true;
- end
-
- local Item = cItem();
- local FoundItem = StringToItem(Split[2], Item);
-
- if not(IsValidItem(Item.m_ItemType)) then -- StringToItem does not check if item is valid
- FoundItem = false
- end
-
- if not(FoundItem) then
- Player:SendMessage( cChatColor.Green .. "Invalid Item type / name !" )
- return true
- end
-
- local ItemAmount = 1;
- if (#Split == 3) then
- ItemAmount = tonumber(Split[3]);
- if ((ItemAmount == nil) or (ItemAmount < 1) or (ItemAmount > 512)) then
- Player:SendMessage(cChatColor.Green .. "Invalid Amount!");
- return true;
- end
- end
-
- Item.m_ItemCount = ItemAmount;
-
- local ItemsGiven = Player:GetInventory():AddItem(Item);
- if (ItemsGiven == ItemAmount) then
- Player:SendMessage( cChatColor.Green .. "There you go !");
- LOG("Gave " .. Player:GetName() .. " " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage);
- else
- Player:SendMessage(cChatColor.Green .. "Not enough space in inventory, only gave " .. ItemsGiven);
- LOG("Player " .. Player:GetName() .. " asked for " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage ..", but only could fit " .. ItemsGiven);
- end
- return true;
+function HandleGiveCommand(Split, Player)
+ if ((#Split ~= 2) and (#Split ~=3)) then
+ Player:SendMessage(cChatColor.Green .. "Usage: /give [ItemType/Name:Dmg] <Amount>");
+ return true;
+ end
+
+ local Item = cItem();
+ local FoundItem = StringToItem(Split[2], Item);
+
+ if not(IsValidItem(Item.m_ItemType)) then -- StringToItem does not check if item is valid
+ FoundItem = false
+ end
+
+ if not(FoundItem) then
+ Player:SendMessage( cChatColor.Green .. "Invalid item id or name!" )
+ return true
+ end
+
+ local ItemAmount = 1;
+ if (#Split == 3) then
+ ItemAmount = tonumber(Split[3]);
+ if ((ItemAmount == nil) or (ItemAmount < 1) or (ItemAmount > 512)) then
+ Player:SendMessage(cChatColor.Green .. "Invalid amount!");
+ return true;
+ end
+ end
+
+ Item.m_ItemCount = ItemAmount;
+
+ local ItemsGiven = Player:GetInventory():AddItem(Item);
+ if (ItemsGiven == ItemAmount) then
+ Player:SendMessage( cChatColor.Green .. "There you go!");
+ LOG("Gave " .. Player:GetName() .. " " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage);
+ else
+ Player:SendMessage(cChatColor.Green .. "Not enough space in inventory, only gave " .. ItemsGiven);
+ LOG("Player " .. Player:GetName() .. " asked for " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage ..", but only could fit " .. ItemsGiven);
+ end
+ return true;
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/gamemode.lua b/MCServer/Plugins/Core/gm.lua
index 1e73b46fd..85bcf984b 100644
--- a/MCServer/Plugins/Core/gamemode.lua
+++ b/MCServer/Plugins/Core/gm.lua
@@ -1,10 +1,8 @@
-function HandleChangeGMCommand( Split, Player )
- if( #Split ~= 2 ) then
- Player:SendMessage( cChatColor.Green .. "Usage: /gm [GameMode (0|1)]" )
- return true
- end
-
- Player:SetGameMode(Split[2])
-
- return true
+function HandleChangeGMCommand( Split, Player )
+ if( #Split ~= 2 ) then
+ Player:SendMessage( cChatColor.Green .. "Usage: /gm [GameMode (0|1)]" )
+ return true
+ end
+ Player:SetGameMode(Split[2])
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/gotoworld.lua b/MCServer/Plugins/Core/gotoworld.lua
deleted file mode 100644
index d5113b667..000000000
--- a/MCServer/Plugins/Core/gotoworld.lua
+++ /dev/null
@@ -1,15 +0,0 @@
-function HandleGotoWorldCommand( Split, Player )
- if( #Split ~= 2 ) then
- Player:SendMessage( cChatColor.Green .. "Usage: /gotoworld [WorldName]" )
- return true
- end
-
- if( Player:MoveToWorld(Split[2]) == false ) then
- Player:SendMessage( cChatColor.Green .. "Could not move to world '" .. Split[2] .. "'!" )
- return true
- end
-
-
- Player:SendMessage( cChatColor.Green .. "Moved successfully to '" .. Split[2] .. "'! :D" )
- return true
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/help.lua b/MCServer/Plugins/Core/help.lua
index 68cdeca66..339fc054b 100644
--- a/MCServer/Plugins/Core/help.lua
+++ b/MCServer/Plugins/Core/help.lua
@@ -1,40 +1,41 @@
-function HandleHelpCommand(Split, Player)
- local PluginManager = cRoot:Get():GetPluginManager()
-
- local LinesPerPage = 9;
- local CurrentPage = 1;
- local CurrentLine = 0;
- local PageRequested = 1;
- local Output = {};
-
- if (#Split == 2) then
- PageRequested = tonumber(Split[2]);
- end
-
- local Process = function(Command, Permission, HelpString)
- if not(Player:HasPermission(Permission)) then
- return false;
- end;
- if (HelpString == "") then
- return false;
- end;
-
- CurrentLine = CurrentLine + 1;
- CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1;
- if (CurrentPage ~= PageRequested) then
- return false;
- end;
- table.insert(Output, cChatColor.Blue .. Command .. HelpString);
- end
-
- PluginManager:ForEachCommand(Process);
-
- -- CurrentPage now contains the total number of pages, and Output has the individual help lines to be sent
-
- Player:SendMessage(cChatColor.Purple .. "- All commands - " .. cChatColor.Gold .. "[Page " .. PageRequested .. " / " .. CurrentPage .. "]");
- for idx, msg in ipairs(Output) do
- Player:SendMessage(msg);
- end;
-
- return true
+function HandleHelpCommand(Split, Player)
+ local PluginManager = cRoot:Get():GetPluginManager()
+
+ local LinesPerPage = 8;
+ local CurrentPage = 1;
+ local CurrentLine = 0;
+ local PageRequested = 1;
+ local Output = {};
+
+ if (#Split == 2) then
+ PageRequested = tonumber(Split[2]);
+ end
+
+ local Process = function(Command, Permission, HelpString)
+ if not(Player:HasPermission(Permission)) then
+ return false;
+ end;
+ if (HelpString == "") then
+ return false;
+ end;
+
+ CurrentLine = CurrentLine + 1;
+ CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1;
+ if (CurrentPage ~= PageRequested) then
+ return false;
+ end;
+ table.insert(Output, cChatColor.Blue .. Command .. HelpString);
+ end
+
+ PluginManager:ForEachCommand(Process);
+
+ -- CurrentPage now contains the total number of pages, and Output has the individual help lines to be sent
+
+ Player:SendMessage(cChatColor.Purple .. "---------- [COMMANDS HELP " .. cChatColor.Gold .. "(Page " .. PageRequested .. " / " .. CurrentPage .. ")" .. cChatColor.Purple .. "] -----------");
+ Player:SendMessage(cChatColor.Purple .. "'-' means no prefix, '~' means a value is required.");
+ for idx, msg in ipairs(Output) do
+ Player:SendMessage(msg);
+ end;
+
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/oncraftingnorecipe.lua b/MCServer/Plugins/Core/itemrepair.lua
index b6909d672..ee411dcc2 100644
--- a/MCServer/Plugins/Core/oncraftingnorecipe.lua
+++ b/MCServer/Plugins/Core/itemrepair.lua
@@ -1,214 +1,202 @@
-
--- Implements item-repair using the HOOK_CRAFTING_NO_RECIPE hook
--- Based on Fixies plugin v2 by Taugeshtu
-
-
--- how much "extra" points are healed per a repair operation (fraction of full health)
-BONUS = 0.1
-
-
-
-
-
-function OnCraftingNoRecipe(Player, Grid, Recipe)
- local _do_fix = false
- local Items = {}
- for x = 0, Grid:GetWidth() - 1 do
- for y = 0, Grid:GetHeight() - 1 do
- local Item = Grid:GetItem(x, y)
- if (Item.m_ItemType ~= E_ITEM_EMPTY) then
- table.insert(Items, Item)
- end
- end
- end
-
- if (#Items ~= 2) then
- -- Only two items together can be fixed
- return false
- end
-
- if (Items[1].m_ItemType ~= Items[2].m_ItemType) then
- -- Only items of the same type may be fixed
- return false
- end
-
- if (
- (Items[1].m_ItemDamage == 0) or
- (Items[2].m_ItemDamage == 0)
- )
- then
- -- Only damaged items may be fixed
- return false
- end
-
- local _ID = Items[1].m_ItemType
- local _least_hp = math.max(Items[1].m_ItemDamage, Items[2].m_ItemDamage)
- local _most_hp = math.min(Items[1].m_ItemDamage, Items[2].m_ItemDamage)
- local _item_hp = 0
-
- -- TODO: This could be refactored into better code, using an _ID-indexed table for _item_hp
-
- if (
- (_ID == E_ITEM_WOODEN_SHOVEL) or
- (_ID == E_ITEM_WOODEN_AXE) or
- (_ID == E_ITEM_WOODEN_PICKAXE) or
- (_ID == E_ITEM_WOODEN_SWORD) or
- (_ID == E_ITEM_WOODEN_HOE)
- )
- then
- _item_hp = 60
- _do_fix = true
- end
-
- if (
- (_ID == E_ITEM_STONE_SHOVEL) or
- (_ID == E_ITEM_STONE_AXE) or
- (_ID == E_ITEM_STONE_PICKAXE) or
- (_ID == E_ITEM_STONE_SWORD) or
- (_ID == E_ITEM_STONE_HOE)
- )
- then
- _item_hp = 132
- _do_fix = true
- end
-
- if (
- (_ID == E_ITEM_IRON_SHOVEL) or
- (_ID == E_ITEM_IRON_AXE) or
- (_ID == E_ITEM_IRON_PICKAXE) or
- (_ID == E_ITEM_IRON_SWORD) or
- (_ID == E_ITEM_IRON_HOE)
- )
- then
- _item_hp = 251
- _do_fix = true
- end
-
- if (
- (_ID == E_ITEM_GOLD_SHOVEL) or
- (_ID == E_ITEM_GOLD_AXE) or
- (_ID == E_ITEM_GOLD_PICKAXE) or
- (_ID == E_ITEM_GOLD_SWORD) or
- (_ID == E_ITEM_GOLD_HOE)
- )
- then
- _item_hp = 33
- _do_fix = true
- end
-
- if (
- (_ID == E_ITEM_DIAMOND_SHOVEL) or
- (_ID == E_ITEM_DIAMOND_AXE) or
- (_ID == E_ITEM_DIAMOND_PICKAXE) or
- (_ID == E_ITEM_DIAMOND_SWORD) or
- (_ID == E_ITEM_DIAMOND_HOE)
- )
- then
- _item_hp = 1562
- _do_fix = true
- end
-
- if (_ID == E_ITEM_LEATHER_CAP) then
- _item_hp = 56
- _do_fix = true
- end
- if (_ID == E_ITEM_LEATHER_TUNIC) then
- _item_hp = 82
- _do_fix = true
- end
- if (_ID == E_ITEM_LEATHER_PANTS) then
- _item_hp = 76
- _do_fix = true
- end
- if (_ID == E_ITEM_LEATHER_BOOTS) then
- _item_hp = 66
- _do_fix = true
- end
-
-
- if (_ID == E_ITEM_CHAIN_HELMET) then
- _item_hp = 78
- _do_fix = true
- end
- if (_ID == E_ITEM_CHAIN_CHESTPLATE) then
- _item_hp = 114
- _do_fix = true
- end
- if (_ID == E_ITEM_CHAIN_LEGGINGS) then
- _item_hp = 106
- _do_fix = true
- end
- if (_ID == E_ITEM_CHAIN_BOOTS) then
- _item_hp = 92
- _do_fix = true
- end
-
-
- if (_ID == E_ITEM_IRON_HELMET) then
- _item_hp = 166
- _do_fix = true
- end
- if (_ID == E_ITEM_IRON_CHESTPLATE) then
- _item_hp = 242
- _do_fix = true
- end
- if (_ID == E_ITEM_IRON_LEGGINGS) then
- _item_hp = 226
- _do_fix = true
- end
- if (_ID == E_ITEM_IRON_BOOTS) then
- _item_hp = 196
- _do_fix = true
- end
-
-
- if (_ID == E_ITEM_GOLD_HELMET) then
- _item_hp = 78
- _do_fix = true
- end
- if (_ID == E_ITEM_GOLD_CHESTPLATE) then
- _item_hp = 114
- _do_fix = true
- end
- if (_ID == E_ITEM_GOLD_LEGGINGS) then
- _item_hp = 106
- _do_fix = true
- end
- if (_ID == E_ITEM_GOLD_BOOTS) then
- _item_hp = 92
- _do_fix = true
- end
-
-
- if (_ID == E_ITEM_DIAMOND_HELMET) then
- _item_hp = 364
- _do_fix = true
- end
- if (_ID == E_ITEM_DIAMOND_CHESTPLATE)then
- _item_hp = 529
- _do_fix = true
- end
- if (_ID == E_ITEM_DIAMOND_LEGGINGS) then
- _item_hp = 496
- _do_fix = true
- end
- if (_ID == E_ITEM_DIAMOND_BOOTS) then
- _item_hp = 430
- _do_fix = true
- end
- -- /////////////////////////////////////////////////////
-
- if (_do_fix == true) then
- local _hp = _most_hp - (_item_hp - _least_hp) - _item_hp * BONUS
- _hp = math.max(_hp, 0)
- Recipe:SetResult(_ID, 1, _hp)
- Recipe:SetIngredient(Items[1].x, Items[1].y, Items[1]);
- Recipe:SetIngredient(Items[2].x, Items[2].y, Items[2]);
- return true
- end
- return false
-end
-
-
-
-
+-- Based on Fixies plugin v2 by Taugeshtu
+-- how much "extra" points are healed per a repair operation (fraction of full health)
+BONUS = 0.1
+
+function OnCraftingNoRecipe(Player, Grid, Recipe)
+ local _do_fix = false
+ local Items = {}
+ for x = 0, Grid:GetWidth() - 1 do
+ for y = 0, Grid:GetHeight() - 1 do
+ local Item = Grid:GetItem(x, y)
+ if (Item.m_ItemType ~= E_ITEM_EMPTY) then
+ table.insert(Items, Item)
+ end
+ end
+ end
+
+ if (#Items ~= 2) then
+ -- Only two items together can be fixed
+ return false
+ end
+
+ if (Items[1].m_ItemType ~= Items[2].m_ItemType) then
+ -- Only items of the same type may be fixed
+ return false
+ end
+
+ if (
+ (Items[1].m_ItemDamage == 0) or
+ (Items[2].m_ItemDamage == 0)
+ )
+ then
+ -- Only damaged items may be fixed
+ return false
+ end
+
+ local _ID = Items[1].m_ItemType
+ local _least_hp = math.max(Items[1].m_ItemDamage, Items[2].m_ItemDamage)
+ local _most_hp = math.min(Items[1].m_ItemDamage, Items[2].m_ItemDamage)
+ local _item_hp = 0
+
+ -- TODO: This could be refactored into better code, using an _ID-indexed table for _item_hp
+
+ if (
+ (_ID == E_ITEM_WOODEN_SHOVEL) or
+ (_ID == E_ITEM_WOODEN_AXE) or
+ (_ID == E_ITEM_WOODEN_PICKAXE) or
+ (_ID == E_ITEM_WOODEN_SWORD) or
+ (_ID == E_ITEM_WOODEN_HOE)
+ )
+ then
+ _item_hp = 60
+ _do_fix = true
+ end
+
+ if (
+ (_ID == E_ITEM_STONE_SHOVEL) or
+ (_ID == E_ITEM_STONE_AXE) or
+ (_ID == E_ITEM_STONE_PICKAXE) or
+ (_ID == E_ITEM_STONE_SWORD) or
+ (_ID == E_ITEM_STONE_HOE)
+ )
+ then
+ _item_hp = 132
+ _do_fix = true
+ end
+
+ if (
+ (_ID == E_ITEM_IRON_SHOVEL) or
+ (_ID == E_ITEM_IRON_AXE) or
+ (_ID == E_ITEM_IRON_PICKAXE) or
+ (_ID == E_ITEM_IRON_SWORD) or
+ (_ID == E_ITEM_IRON_HOE)
+ )
+ then
+ _item_hp = 251
+ _do_fix = true
+ end
+
+ if (
+ (_ID == E_ITEM_GOLD_SHOVEL) or
+ (_ID == E_ITEM_GOLD_AXE) or
+ (_ID == E_ITEM_GOLD_PICKAXE) or
+ (_ID == E_ITEM_GOLD_SWORD) or
+ (_ID == E_ITEM_GOLD_HOE)
+ )
+ then
+ _item_hp = 33
+ _do_fix = true
+ end
+
+ if (
+ (_ID == E_ITEM_DIAMOND_SHOVEL) or
+ (_ID == E_ITEM_DIAMOND_AXE) or
+ (_ID == E_ITEM_DIAMOND_PICKAXE) or
+ (_ID == E_ITEM_DIAMOND_SWORD) or
+ (_ID == E_ITEM_DIAMOND_HOE)
+ )
+ then
+ _item_hp = 1562
+ _do_fix = true
+ end
+
+ if (_ID == E_ITEM_LEATHER_CAP) then
+ _item_hp = 56
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_LEATHER_TUNIC) then
+ _item_hp = 82
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_LEATHER_PANTS) then
+ _item_hp = 76
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_LEATHER_BOOTS) then
+ _item_hp = 66
+ _do_fix = true
+ end
+
+
+ if (_ID == E_ITEM_CHAIN_HELMET) then
+ _item_hp = 78
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_CHAIN_CHESTPLATE) then
+ _item_hp = 114
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_CHAIN_LEGGINGS) then
+ _item_hp = 106
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_CHAIN_BOOTS) then
+ _item_hp = 92
+ _do_fix = true
+ end
+
+
+ if (_ID == E_ITEM_IRON_HELMET) then
+ _item_hp = 166
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_IRON_CHESTPLATE) then
+ _item_hp = 242
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_IRON_LEGGINGS) then
+ _item_hp = 226
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_IRON_BOOTS) then
+ _item_hp = 196
+ _do_fix = true
+ end
+
+
+ if (_ID == E_ITEM_GOLD_HELMET) then
+ _item_hp = 78
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_GOLD_CHESTPLATE) then
+ _item_hp = 114
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_GOLD_LEGGINGS) then
+ _item_hp = 106
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_GOLD_BOOTS) then
+ _item_hp = 92
+ _do_fix = true
+ end
+
+
+ if (_ID == E_ITEM_DIAMOND_HELMET) then
+ _item_hp = 364
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_DIAMOND_CHESTPLATE)then
+ _item_hp = 529
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_DIAMOND_LEGGINGS) then
+ _item_hp = 496
+ _do_fix = true
+ end
+ if (_ID == E_ITEM_DIAMOND_BOOTS) then
+ _item_hp = 430
+ _do_fix = true
+ end
+ -- /////////////////////////////////////////////////////
+
+ if (_do_fix == true) then
+ local _hp = _most_hp - (_item_hp - _least_hp) - _item_hp * BONUS
+ _hp = math.max(_hp, 0)
+ Recipe:SetResult(_ID, 1, _hp)
+ Recipe:SetIngredient(Items[1].x, Items[1].y, Items[1]);
+ Recipe:SetIngredient(Items[2].x, Items[2].y, Items[2]);
+ return true
+ end
+ return false
+end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/kick.lua b/MCServer/Plugins/Core/kick.lua
index 4091fd701..be6215df4 100644
--- a/MCServer/Plugins/Core/kick.lua
+++ b/MCServer/Plugins/Core/kick.lua
@@ -1,46 +1,42 @@
-function HandleKickCommand( Split, Player )
- if( #Split < 2 ) then
- Player:SendMessage( cChatColor.Green .. "Usage: /kick [Player] <Reason>" )
- return true
- end
-
- local Reason = "You have been kicked"
- if( #Split > 2 ) then
- Reason = table.concat(Split, " ", 3)
- end
-
- if( KickPlayer( Split[2], Reason ) == false ) then
- Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] )
- end
-
- return true
-end
-
-
-
-
-
---- Kicks a player by name, with the specified reason; returns bool whether found and player's real name
-function KickPlayer(PlayerName, Reason)
- local RealName = "";
- if (Reason == nil) then
- Reason = "You have been kicked";
- end
-
- local FoundPlayerCallback = function(a_Player)
- RealName = a_Player:GetName()
-
- local Server = cRoot:Get():GetServer()
- LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " )
- Server:SendMessage("Kicking " .. RealName)
-
- a_Player:GetClientHandle():Kick(Reason);
- end
-
- if (not(cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback))) then
- -- Could not find player
- return false;
- end
-
- return true, RealName; -- Player has been kicked
+function HandleKickCommand( Split, Player )
+ if( #Split < 2 ) then
+ Player:SendMessage( cChatColor.Green .. "Usage: /kick [Player] <Reason>" )
+ return true
+ end
+
+ local Reason = "You have been kicked"
+ if( #Split > 2 ) then
+ Reason = table.concat(Split, " ", 3)
+ end
+
+ if( KickPlayer( Split[2], Reason ) == false ) then
+ Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] )
+ end
+
+ return true
+end
+
+--- Kicks a player by name, with the specified reason; returns bool whether found and player's real name
+function KickPlayer(PlayerName, Reason)
+ local RealName = "";
+ if (Reason == nil) then
+ Reason = "You have been kicked";
+ end
+
+ local FoundPlayerCallback = function(a_Player)
+ RealName = a_Player:GetName()
+
+ local Server = cRoot:Get():GetServer()
+ LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " )
+ Server:SendMessage("Kicking " .. RealName)
+
+ a_Player:GetClientHandle():Kick(Reason);
+ end
+
+ if (not(cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback))) then
+ -- Could not find player
+ return false;
+ end
+
+ return true, RealName; -- Player has been kicked
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/listgroups.lua b/MCServer/Plugins/Core/listgroups.lua
deleted file mode 100644
index 531b46463..000000000
--- a/MCServer/Plugins/Core/listgroups.lua
+++ /dev/null
@@ -1,14 +0,0 @@
-function HandleListGroupsCommand( Split, Player )
- local GroupsIni = cIniFile("groups.ini")
- if GroupsIni:ReadFile() == false then
- Player:SendMessage( cChatColor.Green .. "No groups found" )
- end
- Number = GroupsIni:NumKeys() - 1
- Groups = {}
- for i=0, Number do
- table.insert( Groups, GroupsIni:KeyName(i) )
- end
- Player:SendMessage( cChatColor.Green .. "Groups:" )
- Player:SendMessage( cChatColor.Green .. table.concat( Groups, ", " ) )
- return true
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/listworlds.lua b/MCServer/Plugins/Core/listworlds.lua
deleted file mode 100644
index 753345426..000000000
--- a/MCServer/Plugins/Core/listworlds.lua
+++ /dev/null
@@ -1,20 +0,0 @@
-function HandleListWorldsCommand( Split, Player )
- local SettingsIni = cIniFile("settings.ini")
- if SettingsIni:ReadFile() == false then
- Player:SendMessage( cChatColor.Green .. "No worlds found" )
- end
- Number = SettingsIni:NumValues("Worlds") - 1
- Worlds = {}
- for i=0, SettingsIni:GetNumKeys() - 1 do
- if SettingsIni:GetKeyName(i) == "Worlds" then
- Key = i
- break
- end
- end
- for i=0, Number do
- table.insert( Worlds, SettingsIni:GetValue( Key, i) )
- end
- Player:SendMessage( cChatColor.Green .. "Worlds:" )
- Player:SendMessage( cChatColor.Green .. table.concat( Worlds, ", " ) )
- return true
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/coords.lua b/MCServer/Plugins/Core/locate.lua
index 07cda1a92..27fcad229 100644
--- a/MCServer/Plugins/Core/coords.lua
+++ b/MCServer/Plugins/Core/locate.lua
@@ -1,4 +1,4 @@
-function HandleCoordsCommand( Split, Player )
- Player:SendMessage(cChatColor.Green .. string.format("[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
- return true
+function HandleLocateCommand( Split, Player )
+ Player:SendMessage(cChatColor.Green .. string.format("[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/main.lua b/MCServer/Plugins/Core/main.lua
index 7558a5e6f..75f8a028b 100644
--- a/MCServer/Plugins/Core/main.lua
+++ b/MCServer/Plugins/Core/main.lua
@@ -1,129 +1,188 @@
----- Some settings -----
-SHOW_PLUGIN_NAMES = true -- If true, plugin name will be shown before commands
- -- This is overwritten in the Initialize() function
-------------------------
-
--- Global variables
-PLUGIN = {} -- Reference to own plugin object
-BannedPlayersIni = {}
-WhiteListIni = {}
-BackCoords = {}
-Messages = {}
-LimitWorldsCuboid = {}
-
-
-
-
-function Initialize(Plugin)
- PLUGIN = Plugin
-
- Plugin:SetName("Core")
- Plugin:SetVersion(13)
-
- PluginManager = cRoot:Get():GetPluginManager()
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED)
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK)
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK)
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN)
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING)
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE)
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) -- used in web_chat.lua
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING)
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING)
-
- PluginManager:BindCommand("/listworlds", "core.listworlds", HandleListWorldsCommand, " - Shows a list of all the worlds");
- PluginManager:BindCommand("/listgroups", "core.listgroups", HandleListGroupsCommand, " - Shows a list of all the groups");
- PluginManager:BindCommand("/toggledownfall", "core.toggledownfall", HandleToggleDownfallCommand, " - Toggles the weather");
- PluginManager:BindCommand("/back", "core.back", HandleBackCommand, " - Return to your last position");
- PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds");
- PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " [Page] - Show available commands");
- PluginManager:BindCommand("/rank", "core.rank", HandleRankCommand, " [Player] [Rank] - to add someone to a group");
- PluginManager:BindCommand("/pluginlist", "core.pluginlist", HandlePluginListCommand, " - Show list of plugins");
- PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " [Player] - Teleport yourself to a player");
- PluginManager:BindCommand("/item", "core.item", HandleItemCommand, " [ItemType/Name] <Amount> - Give yourself an item");
- PluginManager:BindCommand("/i", "core.item", HandleItemCommand, "");
- PluginManager:BindCommand("/list", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
- PluginManager:BindCommand("/who", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
- PluginManager:BindCommand("/playerlist", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
- PluginManager:BindCommand("/motd", "core.motd", HandleMOTDCommand, " - Show message of the day");
- PluginManager:BindCommand("/reload", "core.reload", HandleReloadCommand, " - Reload all plugins");
- PluginManager:BindCommand("/stop", "core.stop", HandleStopCommand, " - Stops the server");
- PluginManager:BindCommand("/time", "core.time", HandleTimeCommand, " [Day/Night] - Sets the time of day");
- PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn");
- PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " [Player] - Kick a player");
- PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " [Player] - Ban a player");
- PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " [Player] - Unban a player");
- PluginManager:BindCommand("/top", "core.top", HandleTopCommand, " - Teleport yourself to the top most block");
- PluginManager:BindCommand("/gm", "core.changegm", HandleChangeGMCommand, " [0|1] - Change your gamemode");
- PluginManager:BindCommand("/gotoworld", "core.gotoworld", HandleGotoWorldCommand, " [WorldName] - Move to a different world!");
- PluginManager:BindCommand("/coords", "core.coords", HandleCoordsCommand, " - Show your current server coordinates");
- PluginManager:BindCommand("/regeneratechunk", "core.regeneratechunk", HandleRegenerateChunkCommand, " <[X] [Z]> - Regenerates a chunk, current or specified");
- PluginManager:BindCommand("/viewdistance", "core.viewdistance", HandleViewDistanceCommand, " [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance")
-
- InitConsoleCommands();
-
- -- Load the settings
- IniFile = cIniFile("Settings.ini")
- if ( IniFile:ReadFile() == true ) then
- HardCore = IniFile:GetValueSet("GameMode", "Hardcore", "false")
- LimitWorld = IniFile:GetValueSetB("Worlds", "LimitWorld", true)
- LimitWorldWidth = IniFile:GetValueSetI("Worlds", "LimitWorldWidth", 10)
- SHOW_PLUGIN_NAMES = IniFile:GetValueSetB("HelpPlugin", "ShowPluginNames", true )
- IniFile:WriteFile()
- end
-
- cRoot:Get():ForEachWorld(
- function( World )
- LimitWorldsCuboid[World:GetName()] = cCuboid()
- LimitWorldsCuboid[World:GetName()].p1 = Vector3i( math.floor(World:GetSpawnX() / 16) + LimitWorldWidth, 0, math.floor(World:GetSpawnZ() / 16) + LimitWorldWidth)
- LimitWorldsCuboid[World:GetName()].p2 = Vector3i( math.floor(World:GetSpawnX() / 16) - LimitWorldWidth, 256, math.floor(World:GetSpawnZ() / 16) - LimitWorldWidth)
- LimitWorldsCuboid[World:GetName()]:Sort()
- end
- )
- -- Load whitelist, and add default values and stuff
- WhiteListIni = cIniFile( Plugin:GetLocalDirectory() .. "/whitelist.ini" )
- if ( WhiteListIni:ReadFile() == true ) then
- if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) == true ) then
- if( WhiteListIni:GetNumValues("WhiteList") > 0 ) then
- LOGINFO("Core: loaded " .. WhiteListIni:GetNumValues('WhiteList') .. " whitelisted players.")
- else
- LOGWARN("WARNING: WhiteList is on, but there are no people in the whitelist!")
- end
- end
- else
- WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false )
- WhiteListIni:SetValue("WhiteList", "", "") -- So it adds an empty header
- WhiteListIni:DeleteValue("WhiteList", "") -- And remove the value
- WhiteListIni:KeyComment("WhiteList", "PlayerName=1")
- if( WhiteListIni:WriteFile() == false ) then
- LOGWARN("WARNING: Could not write to whitelist.ini")
- end
- end
-
- -- Load banned players, and add default values and stuff
- BannedPlayersIni = cIniFile( Plugin:GetLocalDirectory() .. "/banned.ini" )
- if ( BannedPlayersIni:ReadFile() == true ) then
- if( BannedPlayersIni:GetNumValues("Banned") > 0 ) then
- LOGINFO("Core: loaded " .. BannedPlayersIni:GetNumValues("Banned") .. " banned players.")
- end
- else
- BannedPlayersIni:SetValue("Banned", "", "") -- So it adds an empty header
- BannedPlayersIni:DeleteValue("Banned", "") -- And remove the value
- BannedPlayersIni:KeyComment("Banned", "PlayerName=1")
- if( BannedPlayersIni:WriteFile() == false ) then
- LOGWARN("WARNING: Could not write to banned.ini")
- end
- end
-
- Plugin:AddWebTab("Manage Server", HandleRequest_ManageServer);
- Plugin:AddWebTab("Server Settings", HandleRequest_ServerSettings);
- Plugin:AddWebTab("Chat", HandleRequest_Chat);
- Plugin:AddWebTab("Playerlist", HandleRequest_PlayerList);
- Plugin:AddWebTab("Whitelist", HandleRequest_WhiteList);
- Plugin:AddWebTab("Permissions", HandleRequest_Permissions);
- Plugin:AddWebTab("Manage Plugins", HandleRequest_ManagePlugins);
-
- LoadMotd()
- LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
- return true
-end \ No newline at end of file
+--COMMENCE VARIABLES
+PLUGIN = {}
+BannedPlayersIni = {}
+WhiteListIni = {}
+BackCoords = {}
+Messages = {}
+LimitWorldsCuboid = {}
+--END VARIABLES
+
+--COMMENCE AWESOMENESS!
+function Initialize(Plugin)
+ PLUGIN = Plugin
+
+ Plugin:SetName("Core")
+ Plugin:SetVersion(13)
+
+ --ADD HOOKS
+ PluginManager = cRoot:Get():GetPluginManager()
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED)
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK)
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK)
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN)
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING)
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE)
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) -- used in web_chat.lua
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING)
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING)
+
+ --PLEASE ALPHA SORT http://elmosaukko.com/sort-alphabetically/ THIS LIST
+ --BIND COMMANDS
+ PluginManager:BindCommand("/back", "core.back", HandleBackCommand, " - Return to your last position");
+ PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " ~ Ban a player");
+ PluginManager:BindCommand("/give", "core.give", HandleGiveCommand, " ~ Give yourself an item");
+ PluginManager:BindCommand("/gm", "core.changegm", HandleChangeGMCommand, " ~ Change your gamemode");
+ PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " ~ Show available commands");
+ PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " ~ Kick a player");
+ PluginManager:BindCommand("/list", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
+ PluginManager:BindCommand("/listgroups", "core.listgroups", HandleListGroupsCommand, " - Shows a list of all the groups");
+ PluginManager:BindCommand("/locate", "core.locate", HandleLocateCommand, " - Show your current server coordinates");
+ PluginManager:BindCommand("/motd", "core.motd", HandleMOTDCommand, " - Show message of the day");
+ PluginManager:BindCommand("/playerlist", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
+ PluginManager:BindCommand("/plugins", "core.plugins", HandlePluginsCommand, " - Show list of plugins");
+ PluginManager:BindCommand("/portal", "core.portal", HandlePortalCommand, " ~ Move to a different world");
+ PluginManager:BindCommand("/rank", "core.rank", HandleRankCommand, " ~ Add someone to a group");
+ PluginManager:BindCommand("/regen", "core.regen", HandleRegenCommand, " ~ Regenerates a chunk, current or specified");
+ PluginManager:BindCommand("/reload", "core.reload", HandleReloadCommand, " - Reload all plugins");
+ PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds");
+ PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn");
+ PluginManager:BindCommand("/stop", "core.stop", HandleStopCommand, " - Stops the server");
+ PluginManager:BindCommand("/time", "core.time", HandleTimeCommand, " ~ Sets the time of day");
+ PluginManager:BindCommand("/toggledownfall", "core.toggledownfall", HandleToggleDownfallCommand, " - Toggles the weather");
+ PluginManager:BindCommand("/me", "core.me", HandleMeCommand, " ~ Tell what you are doing");
+ PluginManager:BindCommand("/top", "core.top", HandleTopCommand, " - Teleport yourself to the top most block");
+ PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " ~ Teleport yourself to a player");
+ PluginManager:BindCommand("/tpa", "core.teleport", HandleTPACommand, " ~ Ask to teleport yourself to a player");
+ PluginManager:BindCommand("/tpaccept", "core.teleport", HandleTPAcceptCommand, " ~ Accept a teleportation request");
+ PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " ~ Unban a player");
+ PluginManager:BindCommand("/viewdistance", "core.viewdistance", HandleViewDistanceCommand, " [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance")
+ PluginManager:BindCommand("/who", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
+ PluginManager:BindCommand("/worlds", "core.worlds", HandleWorldsCommand, " - Shows a list of all the worlds");
+
+ InitConsoleCommands();
+
+ --LOAD SETTINGS
+ IniFile = cIniFile("settings.ini")
+ if ( IniFile:ReadFile() == true ) then
+ HardCore = IniFile:GetValueSet("GameMode", "Hardcore", "false")
+ LimitWorld = IniFile:GetValueSetB("Worlds", "LimitWorld", false)
+ LimitWorldWidth = IniFile:GetValueSetI("Worlds", "LimitWorldWidth", 10)
+ IniFile:WriteFile()
+ end
+
+ WorldsSpawnProtect = {}
+ local KeyIdx = IniFile:FindKey("Worlds") --(FIND WHERE 'WORLDS' KEY IS LOCATED)
+ local NumValues = (IniFile:GetNumValues( KeyIdx ) - 2) --(TAKE AWAY TWO OPTIONS FOR WORLD LIMITER)
+ for i = 0, NumValues - 1 do --(FOR EVERY WORLD KEY, TAKING ACCOUNT OF OFF BY ONE ERRORS)
+ WorldIni = cIniFile(IniFile:GetValue(KeyIdx, i) .. "/world.ini")
+ if WorldIni:ReadFile() == true then
+ WorldsSpawnProtect[IniFile:GetValue(KeyIdx, i)] = WorldIni:GetValueSetI("SpawnProtect", "ProtectRadius", 10)
+ WorldIni:WriteFile()
+ end
+ end
+
+ if LimitWorld == true then
+ cRoot:Get():ForEachWorld(
+ function( World )
+ LimitWorldsCuboid[World:GetName()] = cCuboid()
+ LimitWorldsCuboid[World:GetName()].p1 = Vector3i( math.floor(World:GetSpawnX() / 16) + LimitWorldWidth, 0, math.floor(World:GetSpawnZ() / 16) + LimitWorldWidth)
+ LimitWorldsCuboid[World:GetName()].p2 = Vector3i( math.floor(World:GetSpawnX() / 16) - LimitWorldWidth, 256, math.floor(World:GetSpawnZ() / 16) - LimitWorldWidth)
+ LimitWorldsCuboid[World:GetName()]:Sort()
+ end
+ )
+ end
+
+ --LOAD WHITELIST
+ WhiteListIni = cIniFile( Plugin:GetLocalDirectory() .. "/whitelist.ini" )
+ if ( WhiteListIni:ReadFile() == true ) then
+ if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) == true ) then
+ if( WhiteListIni:GetNumValues("WhiteList") > 0 ) then
+ LOGINFO("Core: loaded " .. WhiteListIni:GetNumValues('WhiteList') .. " whitelisted players.")
+ else
+ LOGWARN("WARNING: WhiteList is on, but there are no people in the whitelist!")
+ end
+ end
+ else
+ WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false )
+ WhiteListIni:SetValue("WhiteList", "", "") -- So it adds an empty header
+ WhiteListIni:DeleteValue("WhiteList", "") -- And remove the value
+ WhiteListIni:KeyComment("WhiteList", "PlayerName=1")
+ if( WhiteListIni:WriteFile() == false ) then
+ LOGWARN("WARNING: Could not write to whitelist.ini")
+ end
+ end
+
+ --LOAD BANNED (BAD LUCK, BRO)
+ BannedPlayersIni = cIniFile( Plugin:GetLocalDirectory() .. "/banned.ini" )
+ if ( BannedPlayersIni:ReadFile() == true ) then
+ if( BannedPlayersIni:GetNumValues("Banned") > 0 ) then
+ LOGINFO("Core: loaded " .. BannedPlayersIni:GetNumValues("Banned") .. " banned players.")
+ end
+ else
+ BannedPlayersIni:SetValue("Banned", "", "") -- So it adds an empty header
+ BannedPlayersIni:DeleteValue("Banned", "") -- And remove the value
+ BannedPlayersIni:KeyComment("Banned", "PlayerName=1")
+ if( BannedPlayersIni:WriteFile() == false ) then
+ LOGWARN("WARNING: Could not write to banned.ini")
+ end
+ end
+
+ --ADD WEB INTERFACE TABULATES
+ Plugin:AddWebTab("Manage Server", HandleRequest_ManageServer);
+ Plugin:AddWebTab("Server Settings", HandleRequest_ServerSettings);
+ Plugin:AddWebTab("Chat", HandleRequest_Chat);
+ Plugin:AddWebTab("Playerlist", HandleRequest_PlayerList);
+ Plugin:AddWebTab("Whitelist", HandleRequest_WhiteList);
+ Plugin:AddWebTab("Permissions", HandleRequest_Permissions);
+ Plugin:AddWebTab("Manage Plugins", HandleRequest_ManagePlugins);
+
+ LoadMotd()
+ LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
+
+ return true
+end
+--AWESOMENESS STILL GOING!
+
+--BEGIN SPAWNPROTECT LOGFILE CODE (COURTSEY OF BEARBIN)
+function WriteLog(breakPlace, X, Y, Z, player, id, meta)
+ local logText = {}
+
+ table.insert(logText, player)
+ table.insert(logText, " tried to ")
+
+ if breakPlace == 0 then
+ table.insert(logText, "break ")
+ else
+ table.insert(logText, "place ")
+ end
+
+
+ table.insert(logText, ItemToString(cItem(id, 1, meta)))
+ table.insert(logText, " at ")
+ table.insert(logText, tostring(X))
+ table.insert(logText, ", ")
+ table.insert(logText, tostring(Y))
+ table.insert(logText, ", ")
+ table.insert(logText, tostring(Z))
+ table.insert(logText, ".")
+
+ LOGINFO(table.concat(logText,''))
+
+ if LOGTOFILE then
+ local logFile = io.open( Plugin:GetLocalDirectory() .. '/blocks.log', 'a')
+ logFile:write(table.concat(logText,'').."\n")
+ logFile:close()
+ end
+
+ return
+end
+
+function WarnPlayer(Player)
+ Player:SendMessage("Go further from spawn to build")
+ return
+end
+
+function OnDisable()
+ LOG( "Disabled Core!")
+end
+--END AWESOMENESS :'(
diff --git a/MCServer/Plugins/Core/me.lua b/MCServer/Plugins/Core/me.lua
new file mode 100644
index 000000000..8717a097e
--- /dev/null
+++ b/MCServer/Plugins/Core/me.lua
@@ -0,0 +1,15 @@
+function HandleMeCommand( Split, Player )
+ table.remove(Split, 1);
+ local Message = "";
+ for i, Text in ipairs(Split) do
+ Message = Message .. " " .. Text;
+ end
+ if (Split[1] == nil) then
+ Player:SendMessage("Usage: /me <action>")
+ return true
+ end
+ if (Split[1] ~= nil) then
+ cRoot:Get():GetServer():BroadcastChat(Player:GetName().. ""..Message);
+ return true
+ end
+end
diff --git a/MCServer/Plugins/Core/motd.lua b/MCServer/Plugins/Core/motd.lua
index 928e7ebb3..2a42c80af 100644
--- a/MCServer/Plugins/Core/motd.lua
+++ b/MCServer/Plugins/Core/motd.lua
@@ -1,97 +1,97 @@
-function HandleMOTDCommand( Split, Player )
- ShowMOTDTo( Player )
- return true
-end
-
-
-
-
-function LoadMotd()
- local File = io.open("motd.txt", "r")
- -- Check if the file 'motd.txt' exists, else create it.
- if not File then
- CreateFile = io.open("motd.txt", "w")
- CreateFile:write("@6Welcome to the MCServer test server!\n@6http://www.mc-server.org/\n@6Type /help for all commands")
- CreateFile:close()
- else
- File:close()
- end
- for line in io.lines("motd.txt") do
- local TempMessage = line
- -- Do a for loop that goes to each char in the line.
- for I=1, string.len(TempMessage) do
- -- If the char is a '@' then check if the next char represents a color.
- if string.sub(TempMessage, I, I) == "@" then
- local Char = string.sub(TempMessage, I + 1, I + 1)
- local Color = ReturnColorFromChar(TempMessage, Char)
- -- If the next char represented a color then put the color in the string.
- if (Color ~= nil) then
- TempMessage = string.gsub(TempMessage, "@" .. Char, Color)
- end
- end
- end
- -- Add the message to the list of messages.
- Messages[#Messages + 1] = TempMessage
- end
-end
-
-
-
-
-function ShowMOTDTo( Player )
- for I=1, #Messages do
- Player:SendMessage(Messages[I])
- end
-end
-
-
-
-
-function ReturnColorFromChar( Split, char )
- -- Check if the char represents a color. Else return nil.
- if char == "0" then
- return cChatColor.Black
- elseif char == "1" then
- return cChatColor.Navy
- elseif char == "2" then
- return cChatColor.Green
- elseif char == "3" then
- return cChatColor.Blue
- elseif char == "4" then
- return cChatColor.Red
- elseif char == "5" then
- return cChatColor.Purple
- elseif char == "6" then
- return cChatColor.Gold
- elseif char == "7" then
- return cChatColor.LightGray
- elseif char == "8" then
- return cChatColor.Gray
- elseif char == "9" then
- return cChatColor.DarkPurple
- elseif char == "a" then
- return cChatColor.LightGreen
- elseif char == "b" then
- return cChatColor.LightBlue
- elseif char == "c" then
- return cChatColor.Rose
- elseif char == "d" then
- return cChatColor.LightPurple
- elseif char == "e" then
- return cChatColor.Yellow
- elseif char == "f" then
- return cChatColor.White
- elseif char == "k" then
- return cChatColor.Random
- elseif char == "l" then
- return cChatColor.Bold
- elseif char == "m" then
- return cChatColor.Strikethrough
- elseif char == "n" then
- return cChatColor.Underlined
- elseif char == "o" then
- return cChatColor.Italic
- elseif char == "r" then
- return cChatColor.Plain
- end
+function HandleMOTDCommand( Split, Player )
+ ShowMOTDTo( Player )
+ return true
+end
+
+
+
+
+function LoadMotd()
+ local File = io.open("motd.txt", "r")
+ -- Check if the file 'motd.txt' exists, else create it.
+ if not File then
+ CreateFile = io.open("motd.txt", "w")
+ CreateFile:write("@6Welcome to the MCServer test server!\n@6http://www.mc-server.org/\n@6Type /help for all commands")
+ CreateFile:close()
+ else
+ File:close()
+ end
+ for line in io.lines("motd.txt") do
+ local TempMessage = line
+ -- Do a for loop that goes to each char in the line.
+ for I=1, string.len(TempMessage) do
+ -- If the char is a '@' then check if the next char represents a color.
+ if string.sub(TempMessage, I, I) == "@" then
+ local Char = string.sub(TempMessage, I + 1, I + 1)
+ local Color = ReturnColorFromChar(TempMessage, Char)
+ -- If the next char represented a color then put the color in the string.
+ if (Color ~= nil) then
+ TempMessage = string.gsub(TempMessage, "@" .. Char, Color)
+ end
+ end
+ end
+ -- Add the message to the list of messages.
+ Messages[#Messages + 1] = TempMessage
+ end
+end
+
+
+
+
+function ShowMOTDTo( Player )
+ for I=1, #Messages do
+ Player:SendMessage(Messages[I])
+ end
+end
+
+
+
+
+function ReturnColorFromChar( Split, char )
+ -- Check if the char represents a color. Else return nil.
+ if char == "0" then
+ return cChatColor.Black
+ elseif char == "1" then
+ return cChatColor.Navy
+ elseif char == "2" then
+ return cChatColor.Green
+ elseif char == "3" then
+ return cChatColor.Blue
+ elseif char == "4" then
+ return cChatColor.Red
+ elseif char == "5" then
+ return cChatColor.Purple
+ elseif char == "6" then
+ return cChatColor.Gold
+ elseif char == "7" then
+ return cChatColor.LightGray
+ elseif char == "8" then
+ return cChatColor.Gray
+ elseif char == "9" then
+ return cChatColor.DarkPurple
+ elseif char == "a" then
+ return cChatColor.LightGreen
+ elseif char == "b" then
+ return cChatColor.LightBlue
+ elseif char == "c" then
+ return cChatColor.Rose
+ elseif char == "d" then
+ return cChatColor.LightPurple
+ elseif char == "e" then
+ return cChatColor.Yellow
+ elseif char == "f" then
+ return cChatColor.White
+ elseif char == "k" then
+ return cChatColor.Random
+ elseif char == "l" then
+ return cChatColor.Bold
+ elseif char == "m" then
+ return cChatColor.Strikethrough
+ elseif char == "n" then
+ return cChatColor.Underlined
+ elseif char == "o" then
+ return cChatColor.Italic
+ elseif char == "r" then
+ return cChatColor.Plain
+ end
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/onbreakplaceblock.lua b/MCServer/Plugins/Core/onbreakplaceblock.lua
new file mode 100644
index 000000000..49b3226c2
--- /dev/null
+++ b/MCServer/Plugins/Core/onbreakplaceblock.lua
@@ -0,0 +1,119 @@
+function OnPlayerPlacingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType)
+ -- Direction is air check
+ if (BlockFace == -1) then
+ return false
+ end
+
+ local PROTECTRADIUS = WorldsSpawnProtect[Player:GetWorld():GetName()];
+
+ if not (Player:HasPermission("core.build")) then
+ return true
+ else
+ if not (Player:HasPermission("core.spawnprotect.bypass")) and not (PROTECTRADIUS == 0) then
+ local World = Player:GetWorld()
+ local xcoord = World:GetSpawnX()
+ local ycoord = World:GetSpawnY()
+ local zcoord = World:GetSpawnZ()
+
+ if not ((BlockX <= (xcoord + PROTECTRADIUS)) and (BlockX >= (xcoord - PROTECTRADIUS))) then
+ return false -- Not in spawn area.
+ end
+ if not ((BlockY <= (ycoord + PROTECTRADIUS)) and (BlockY >= (ycoord - PROTECTRADIUS))) then
+ return false -- Not in spawn area.
+ end
+ if not ((BlockZ <= (zcoord + PROTECTRADIUS)) and (BlockZ >= (zcoord - PROTECTRADIUS))) then
+ return false -- Not in spawn area.
+ end
+
+ --WriteLog(1, BlockX, BlockY, BlockZ, Player:GetName(), id, meta)
+
+ WarnPlayer(Player)
+
+ return true
+ else
+ if BlockType == "50" or BlockType == "76" then
+ local X = BlockX
+ local Y = BlockY
+ local Z = BlockZ
+ X, Y, Z = AddFaceDirection(X, Y, Z, BlockFace)
+ if (Y >= 256 or Y < 0) then
+ return true
+ end
+
+ local CheckCollision = function(Player)
+ -- drop the decimals, we only care about the full block X,Y,Z
+ local PlayerX = math.floor(Player:GetPosX(), 0)
+ local PlayerY = math.floor(Player:GetPosY(), 0)
+ local PlayerZ = math.floor(Player:GetPosZ(), 0)
+
+ local collision = false
+ if ((BlockFace == BLOCK_FACE_TOP) and (PlayerY == BlockY - 2) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then
+ collision = true
+ end
+
+ if ((BlockFace == BLOCK_FACE_BOTTOM) and (PlayerY == BlockY + 1) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then
+ collision = true
+ end
+
+ if ((BlockFace == BLOCK_FACE_NORTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ - 1)) then
+ if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end
+ end
+
+ if ((BlockFace == BLOCK_FACE_SOUTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ + 1)) then
+ if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end
+ end
+
+ if ((BlockFace == BLOCK_FACE_WEST) and (PlayerX == BlockX - 1) and (PlayerZ == BlockZ)) then
+ if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end
+ end
+
+ if ((BlockFace == BLOCK_FACE_EAST) and (PlayerX == BlockX + 1) and (PlayerZ == BlockZ)) then
+ if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end
+ end
+ return collision
+ end
+ if (Player:GetWorld():ForEachPlayer(CheckCollision) == false) then
+ return true
+ end
+ end
+ end
+ end
+ return false
+end
+
+function OnPlayerBreakingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, Status, OldBlockType, OldBlockMeta)
+ -- dont check if the direction is in the air
+ if (BlockFace ~= -1) then
+
+ local PROTECTRADIUS = WorldsSpawnProtect[Player:GetWorld():GetName()];
+
+ if not (Player:HasPermission("core.build")) then
+ return true
+ else
+ if not (Player:HasPermission("core.spawnprotect.bypass")) and not (PROTECTRADIUS == 0) then
+ local World = Player:GetWorld()
+ local xcoord = World:GetSpawnX()
+ local ycoord = World:GetSpawnY()
+ local zcoord = World:GetSpawnZ()
+
+ if not ((BlockX <= (xcoord + PROTECTRADIUS)) and (BlockX >= (xcoord - PROTECTRADIUS))) then
+ return false -- Not in spawn area.
+ end
+ if not ((BlockY <= (ycoord + PROTECTRADIUS)) and (BlockY >= (ycoord - PROTECTRADIUS))) then
+ return false -- Not in spawn area.
+ end
+ if not ((BlockZ <= (zcoord + PROTECTRADIUS)) and (BlockZ >= (zcoord - PROTECTRADIUS))) then
+ return false -- Not in spawn area.
+ end
+
+ --WriteLog(0, BlockX, BlockY, BlockZ, Player:GetName(), id, meta)
+
+ WarnPlayer(Player)
+
+ return true
+ end
+ end
+ end
+
+ return false
+end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/ondeath.lua b/MCServer/Plugins/Core/ondeath.lua
new file mode 100644
index 000000000..47a7532a6
--- /dev/null
+++ b/MCServer/Plugins/Core/ondeath.lua
@@ -0,0 +1,65 @@
+function OnKilling(Victim, Killer)
+ if Victim:IsPlayer() then
+ SetBackCoordinates( Victim )
+ Server = cRoot:Get():GetServer()
+ if Killer == nil then
+ if Victim:IsOnFire() then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was burnt to a cinder" )
+ CheckHardcore(Victim)
+ return false
+ end
+ if Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 10 or Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 11 then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " tried to swim in lava (and failed)" )
+ CheckHardcore(Victim)
+ return false
+ end
+ else
+ if Killer:IsPlayer() then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was terminated by " .. Killer:GetName() )
+ CheckHardcore(Victim)
+ return false
+ elseif Killer:IsMob() then
+ if Killer:IsA("cZombie") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was eaten by a Zombie")
+ elseif Killer:IsA("cSkeleton") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was shot by a Skeleton" )
+ elseif Killer:IsA("cCreeper") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was blown up by a Creeper")
+ elseif Killer:IsA("cSpider") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was ripped apart by a giant Spider")
+ elseif Killer:IsA("cCaveSpider") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was poisoned by a giant Cave Spider")
+ elseif Killer:IsA("cBlaze") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was flamed by a Blaze")
+ elseif Killer:IsA("cEnderman") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was " .. cChatColor.Random .. " by an Enderman")
+ elseif Killer:IsA("cSilverfish") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was... DERPED by a Silverfish!")
+ elseif Killer:IsA("cSlime") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was stuck fast and killed by a Slime")
+ elseif Killer:IsA("cWitch") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was enchanted (to death) by a Witch")
+ elseif Killer:IsA("cZombiepigman") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was slain by a Zombie Pigman")
+ elseif Killer:IsA("cMagmacube") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was incinerated by a Magmacube")
+ elseif Killer:IsA("cWolf") then
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was savaged by a Wolf")
+ end
+ CheckHardcore(Victim)
+ return false
+ end
+ end
+ Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " died of mysterious circumstances")
+ CheckHardcore(Victim)
+ end
+end
+
+function CheckHardcore(Victim)
+ if HardCore == "true" then
+ if Victim:IsPlayer() == true then
+ local KilledPlayer = tolua.cast(Victim, "cPlayer")
+ BanPlayer(KilledPlayer:GetName(), "You died, haha. Good game, bro.")
+ end
+ end
+end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/onkilling.lua b/MCServer/Plugins/Core/onkilling.lua
deleted file mode 100644
index e74f36065..000000000
--- a/MCServer/Plugins/Core/onkilling.lua
+++ /dev/null
@@ -1,65 +0,0 @@
-function OnKilling(Victim, Killer)
- if Victim:IsPlayer() then
- SetBackCoordinates( Victim )
- Server = cRoot:Get():GetServer()
- if Killer == nil then
- if Victim:IsOnFire() then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " burned away." )
- CheckHardcore(Victim)
- return false
- end
- if Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 10 or Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 11 then
- Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " tried to swim in lava" )
- CheckHardcore(Victim)
- return false
- end
- else
- if Killer:IsPlayer() then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by " .. Killer:GetName() )
- CheckHardcore(Victim)
- return false
- elseif Killer:IsMob() then
- if Killer:IsA("cZombie") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is eaten by a zombie")
- elseif Killer:IsA("cSkeleton") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a skeleton" )
- elseif Killer:IsA("cCreeper") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is blown up by a creeper")
- elseif Killer:IsA("cSpider") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a spider")
- elseif Killer:IsA("cCaveSpider") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a cavespider")
- elseif Killer:IsA("cBlaze") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a blaze")
- elseif Killer:IsA("cEnderman") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is slain by a enderman")
- elseif Killer:IsA("cSilverfish") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a silverfish")
- elseif Killer:IsA("cSlime") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a slime")
- elseif Killer:IsA("cWitch") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a witch")
- elseif Killer:IsA("cZombiepigman") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is slain by a zombiepigman")
- elseif Killer:IsA("cMagmacube") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a magmacube")
- elseif Killer:IsA("cWolf") then
- Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a wolf")
- end
- CheckHardcore(Victim)
- return false
- end
- end
- Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " Died")
- CheckHardcore(Victim)
- end
-end
-
-function CheckHardcore(Victim)
- if HardCore == "true" then
- if Victim:IsPlayer() == true then
- local KilledPlayer = tolua.cast(Victim, "cPlayer")
- BanPlayer(KilledPlayer:GetName(), "You Died")
- end
- end
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/onlogin.lua b/MCServer/Plugins/Core/onlogin.lua
index 07b8460ee..4b2f24f17 100644
--- a/MCServer/Plugins/Core/onlogin.lua
+++ b/MCServer/Plugins/Core/onlogin.lua
@@ -1,20 +1,19 @@
-function OnLogin(Client, ProtocolVersion, Username)
- if( Username ~= "" ) then
- if( BannedPlayersIni:GetValueB("Banned", Username, false) == true ) then
- local Server = cRoot:Get():GetServer()
- Server:SendMessage( Username .. " tried to join, but is banned!" )
- LOGINFO( Username .. " tried to join, but is banned!")
- return true -- Player is banned, return true to deny access
- end
- if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false ) == true ) then
- if( WhiteListIni:GetValueB("WhiteList", Username, false ) == false ) then -- not on whitelist
- local Server = cRoot:Get():GetServer()
- Server:SendMessage( Username .. " tried to join, but is not on the whitelist." )
- LOGINFO( Username .. " tried to join, but is not on the whitelist." )
- return true -- Deny access to the server
- end
- end
- end
-
- return false
+function OnLogin(Client, ProtocolVersion, Username)
+ if( Username ~= "" ) then
+ if( BannedPlayersIni:GetValueB("Banned", Username, false) == true ) then
+ local Server = cRoot:Get():GetServer()
+ Server:SendMessage( Username .. " tried to join, but is banned!" )
+ LOGINFO( Username .. " tried to join, but is banned!")
+ return true -- Player is banned, return true to deny access
+ end
+ if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false ) == true ) then
+ if( WhiteListIni:GetValueB("WhiteList", Username, false ) == false ) then -- not on whitelist
+ local Server = cRoot:Get():GetServer()
+ Server:SendMessage( Username .. " tried to join, but is not on the whitelist." )
+ LOGINFO( Username .. " tried to join, but is not on the whitelist." )
+ return true -- Deny access to the server
+ end
+ end
+ end
+ return false
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/onplayerbreakingblock.lua b/MCServer/Plugins/Core/onplayerbreakingblock.lua
deleted file mode 100644
index fc7d5897d..000000000
--- a/MCServer/Plugins/Core/onplayerbreakingblock.lua
+++ /dev/null
@@ -1,10 +0,0 @@
-function OnPlayerBreakingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, Status, OldBlockType, OldBlockMeta)
- -- dont check if the direction is in the air
- if (BlockFace ~= -1) then
-
- if (Player:HasPermission("core.build") == false) then
- return true
- end
- end
- return false
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/onplayerplacingblock.lua b/MCServer/Plugins/Core/onplayerplacingblock.lua
deleted file mode 100644
index be2fd64d3..000000000
--- a/MCServer/Plugins/Core/onplayerplacingblock.lua
+++ /dev/null
@@ -1,63 +0,0 @@
-function OnPlayerPlacingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType)
-
- -- dont check if the direction is in the air
- if (BlockFace == -1) then
- return false
- end
-
- if( Player:HasPermission("core.build") == false ) then
- return true
- end
-
- -- TODO: If the placed block is not a block (torch etc.), allow it without checking for collisions
-
- local X = BlockX
- local Y = BlockY
- local Z = BlockZ
- X, Y, Z = AddFaceDirection(X, Y, Z, BlockFace)
- if (Y >= 256 or Y < 0) then
- return true
- end
-
- local CheckCollision = function(Player)
- -- drop the decimals, we only care about the full block X,Y,Z
- local PlayerX = math.floor(Player:GetPosX(), 0)
- local PlayerY = math.floor(Player:GetPosY(), 0)
- local PlayerZ = math.floor(Player:GetPosZ(), 0)
-
- -- player height is 2 blocks, so we check the position and then offset it up one
- -- so they can't place a block in anyone's face
-
- local collision = false
- if ((BlockFace == BLOCK_FACE_TOP) and (PlayerY == BlockY - 2) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then
- collision = true
- end
-
- if ((BlockFace == BLOCK_FACE_BOTTOM) and (PlayerY == BlockY + 1) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then
- collision = true
- end
-
- if ((BlockFace == BLOCK_FACE_NORTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ - 1)) then
- if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end
- end
-
- if ((BlockFace == BLOCK_FACE_SOUTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ + 1)) then
- if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end
- end
-
- if ((BlockFace == BLOCK_FACE_WEST) and (PlayerX == BlockX - 1) and (PlayerZ == BlockZ)) then
- if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end
- end
-
- if ((BlockFace == BLOCK_FACE_EAST) and (PlayerX == BlockX + 1) and (PlayerZ == BlockZ)) then
- if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end
- end
-
- return collision
- end
-
- if (Player:GetWorld():ForEachPlayer(CheckCollision) == false) then
- return true
- end
- return false
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/onplayerjoined.lua b/MCServer/Plugins/Core/playerjoin.lua
index 334307000..884acb66a 100644
--- a/MCServer/Plugins/Core/onplayerjoined.lua
+++ b/MCServer/Plugins/Core/playerjoin.lua
@@ -1,5 +1,5 @@
-function OnPlayerJoined(Player)
- ShowMOTDTo( Player )
- AddMessage( Player:GetName() .. " has joined the game", " " )
- return false
+function OnPlayerJoined(Player)
+ ShowMOTDTo( Player )
+ AddMessage( Player:GetName() .. " has joined the game", " " )
+ return false
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/playerlist.lua b/MCServer/Plugins/Core/playerlist.lua
index f06dfed85..73d9e5b24 100644
--- a/MCServer/Plugins/Core/playerlist.lua
+++ b/MCServer/Plugins/Core/playerlist.lua
@@ -1,14 +1,14 @@
-function HandlePlayerListCommand( Split, Player )
-
- local PlayerTable = {}
- local AppendToTable = function( Player )
- table.insert(PlayerTable, Player:GetName() )
- end
- Player:GetWorld():ForEachPlayer( AppendToTable )
-
- local Message = cChatColor.Green .. "Connected players: (".. cChatColor.White.. #PlayerTable .. cChatColor.Green .. ")"
- Player:SendMessage( Message )
-
- Player:SendMessage( table.concat(PlayerTable, " ") )
- return true
+function HandlePlayerListCommand( Split, Player )
+
+ local PlayerTable = {}
+ local AppendToTable = function( Player )
+ table.insert(PlayerTable, Player:GetName() )
+ end
+ Player:GetWorld():ForEachPlayer( AppendToTable )
+
+ local Message = cChatColor.Green .. "Connected players: (".. cChatColor.White.. #PlayerTable .. cChatColor.Green .. ")"
+ Player:SendMessage( Message )
+
+ Player:SendMessage( table.concat(PlayerTable, " ") )
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/pluginlist.lua b/MCServer/Plugins/Core/plugins.lua
index 5f01c0339..6d74cf29e 100644
--- a/MCServer/Plugins/Core/pluginlist.lua
+++ b/MCServer/Plugins/Core/plugins.lua
@@ -1,15 +1,15 @@
-function HandlePluginListCommand( Split, Player )
- local PluginManager = cRoot:Get():GetPluginManager()
- local PluginList = PluginManager:GetAllPlugins()
-
- local PluginTable = {}
- for k, Plugin in pairs( PluginList ) do
- if ( Plugin ) then
- table.insert(PluginTable, Plugin:GetName() )
- end
- end
-
- Player:SendMessage( cChatColor.Green .. "Loaded plugins: (" .. #PluginTable .. ")" )
- Player:SendMessage( cChatColor.Gold .. table.concat(PluginTable, cChatColor.Gold.." ") )
- return true
+function HandlePluginsCommand( Split, Player )
+ local PluginManager = cRoot:Get():GetPluginManager()
+ local PluginList = PluginManager:GetAllPlugins()
+
+ local PluginTable = {}
+ for k, Plugin in pairs( PluginList ) do
+ if ( Plugin ) then
+ table.insert(PluginTable, Plugin:GetName() )
+ end
+ end
+
+ Player:SendMessage( cChatColor.Green .. "Loaded plugins: (" .. #PluginTable .. ")" )
+ Player:SendMessage( cChatColor.Gold .. table.concat(PluginTable, cChatColor.Gold.." ") )
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/portal-worlds.lua b/MCServer/Plugins/Core/portal-worlds.lua
new file mode 100644
index 000000000..136edb82e
--- /dev/null
+++ b/MCServer/Plugins/Core/portal-worlds.lua
@@ -0,0 +1,36 @@
+function HandlePortalCommand( Split, Player )
+ if( #Split ~= 2 ) then
+ Player:SendMessage( cChatColor.Green .. "Usage: /gotoworld [WorldName]" )
+ return true
+ end
+
+ if( Player:MoveToWorld(Split[2]) == false ) then
+ Player:SendMessage( cChatColor.Green .. "Could not move to world '" .. Split[2] .. "'!" )
+ return true
+ end
+
+
+ Player:SendMessage( cChatColor.Green .. "Moved successfully to '" .. Split[2] .. "'! :D" )
+ return true
+end
+
+function HandleWorldsCommand( Split, Player )
+ local SettingsIni = cIniFile("settings.ini")
+ if SettingsIni:ReadFile() == false then
+ Player:SendMessage( cChatColor.Green .. "No worlds found" )
+ end
+ Number = SettingsIni:NumValues("Worlds") - 1
+ Worlds = {}
+ for i=0, SettingsIni:GetNumKeys() - 1 do
+ if SettingsIni:GetKeyName(i) == "Worlds" then
+ Key = i
+ break
+ end
+ end
+ for i=0, Number do
+ table.insert( Worlds, SettingsIni:GetValue( Key, i) )
+ end
+ Player:SendMessage( cChatColor.Green .. "Worlds:" )
+ Player:SendMessage( cChatColor.Green .. table.concat( Worlds, ", " ) )
+ return true
+end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/rank.lua b/MCServer/Plugins/Core/rank-groups.lua
index e178f0a2b..157d91744 100644
--- a/MCServer/Plugins/Core/rank.lua
+++ b/MCServer/Plugins/Core/rank-groups.lua
@@ -1,33 +1,48 @@
-function HandleRankCommand( Split, Player )
- if Split[2] == nil or Split[3] == nil then
- Player:SendMessage(cChatColor.Rose .. "Usage: /rank [Player] [Group]")
- return true
- end
- local GroupsIni = cIniFile("groups.ini")
- if( GroupsIni:ReadFile() == false ) then
- LOG("Could not read groups.ini!")
- end
- if GroupsIni:FindKey(Split[3]) == -1 then
- Player:SendMessage(cChatColor.Rose .. "Group does not exist")
- return true
- end
- local UsersIni = cIniFile("users.ini")
- if( UsersIni:ReadFile() == false ) then
- LOG("Could not read users.ini!")
- end
- UsersIni:DeleteKey(Split[2])
- UsersIni:GetValueSet(Split[2], "Groups", Split[3])
- UsersIni:WriteFile()
- local loopPlayers = function( Player )
- if Player:GetName() == Split[2] then
- Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Split[3] )
- Player:LoadPermissionsFromDisk()
- end
- end
- local loopWorlds = function ( World )
- World:ForEachPlayer( loopPlayers )
- end
- cRoot:Get():ForEachWorld( loopWorlds )
- Player:SendMessage(cChatColor.Green .. "Player " .. Split[2] .. " Was moved to " .. Split[3])
- return true
+function HandleRankCommand( Split, Player )
+ if Split[2] == nil or Split[3] == nil then
+ Player:SendMessage(cChatColor.Rose .. "Usage: /rank [Player] [Group]")
+ return true
+ end
+ local GroupsIni = cIniFile("groups.ini")
+ if( GroupsIni:ReadFile() == false ) then
+ LOG("Could not read groups.ini!")
+ end
+ if GroupsIni:FindKey(Split[3]) == -1 then
+ Player:SendMessage(cChatColor.Rose .. "Group does not exist")
+ return true
+ end
+ local UsersIni = cIniFile("users.ini")
+ if( UsersIni:ReadFile() == false ) then
+ LOG("Could not read users.ini!")
+ end
+ UsersIni:DeleteKey(Split[2])
+ UsersIni:GetValueSet(Split[2], "Groups", Split[3])
+ UsersIni:WriteFile()
+ local loopPlayers = function( Player )
+ if Player:GetName() == Split[2] then
+ Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Split[3] )
+ Player:LoadPermissionsFromDisk()
+ end
+ end
+ local loopWorlds = function ( World )
+ World:ForEachPlayer( loopPlayers )
+ end
+ cRoot:Get():ForEachWorld( loopWorlds )
+ Player:SendMessage(cChatColor.Green .. "Player " .. Split[2] .. " Was moved to " .. Split[3])
+ return true
+end
+
+function HandleListGroupsCommand( Split, Player )
+ local GroupsIni = cIniFile("groups.ini")
+ if GroupsIni:ReadFile() == false then
+ Player:SendMessage( cChatColor.Green .. "No groups found" )
+ end
+ Number = GroupsIni:NumKeys() - 1
+ Groups = {}
+ for i=0, Number do
+ table.insert( Groups, GroupsIni:KeyName(i) )
+ end
+ Player:SendMessage( cChatColor.Green .. "Groups:" )
+ Player:SendMessage( cChatColor.Green .. table.concat( Groups, ", " ) )
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/regeneratechunk.lua b/MCServer/Plugins/Core/regen.lua
index 7f91f48c1..f1dd4e118 100644
--- a/MCServer/Plugins/Core/regeneratechunk.lua
+++ b/MCServer/Plugins/Core/regen.lua
@@ -1,18 +1,18 @@
-function HandleRegenerateChunkCommand(Split, Player)
- if ((#Split == 2) or (#Split > 3)) then
- Player:SendMessage( cChatColor.Green .. "Usage: '/regeneratechunk' or '/regeneratechunk [X] [Z]'");
- return true;
- end
-
- local X = Player:GetChunkX();
- local Z = Player:GetChunkZ();
-
- if (#Split == 3) then
- X = Split[2];
- Z = Split[3];
- end
-
- Player:SendMessage(cChatColor.Green .. "Regenerating chunk ["..X..", "..Z.."]");
- Player:GetWorld():RegenerateChunk(X, Z);
- return true;
+function HandleRegenCommand(Split, Player)
+ if ((#Split == 2) or (#Split > 3)) then
+ Player:SendMessage( cChatColor.Green .. "Usage: '/regeneratechunk' or '/regeneratechunk [X] [Z]'");
+ return true;
+ end
+
+ local X = Player:GetChunkX();
+ local Z = Player:GetChunkZ();
+
+ if (#Split == 3) then
+ X = Split[2];
+ Z = Split[3];
+ end
+
+ Player:SendMessage(cChatColor.Green .. "Regenerating chunk ["..X..", "..Z.."]");
+ Player:GetWorld():RegenerateChunk(X, Z);
+ return true;
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/reload.lua b/MCServer/Plugins/Core/reload.lua
deleted file mode 100644
index e2b338ba1..000000000
--- a/MCServer/Plugins/Core/reload.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-function HandleReloadCommand( Split, Player )
- Server = cRoot:Get():GetServer()
- Server:SendMessage( cChatColor.Green .. "Reloading all plugins." )
- cRoot:Get():GetPluginManager():ReloadPlugins()
- return true
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/save-reload-stop.lua b/MCServer/Plugins/Core/save-reload-stop.lua
new file mode 100644
index 000000000..57744b088
--- /dev/null
+++ b/MCServer/Plugins/Core/save-reload-stop.lua
@@ -0,0 +1,19 @@
+function HandleSaveAllCommand( Split, Player )
+ cRoot:Get():SaveAllChunks();
+ Player:SendMessage(cChatColor.Green .. "All the worlds are saved")
+ return true;
+end
+
+function HandleStopCommand( Split, Player )
+ Server = cRoot:Get():GetServer()
+ Server:SendMessage( cChatColor.Green .. "Stopping the server..." )
+ cRoot:Get():QueueExecuteConsoleCommand("stop")
+ return true
+end
+
+function HandleReloadCommand( Split, Player )
+ Server = cRoot:Get():GetServer()
+ Server:SendMessage( cChatColor.Green .. "Reloading all plugins." )
+ cRoot:Get():GetPluginManager():ReloadPlugins()
+ return true
+end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/saveall.lua b/MCServer/Plugins/Core/saveall.lua
deleted file mode 100644
index 1dd12335b..000000000
--- a/MCServer/Plugins/Core/saveall.lua
+++ /dev/null
@@ -1,5 +0,0 @@
-function HandleSaveAllCommand( Split, Player )
- cRoot:Get():SaveAllChunks();
- Player:SendMessage(cChatColor.Green .. "All the worlds are saved")
- return true;
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/spawn.lua b/MCServer/Plugins/Core/spawn.lua
index d4e033c7e..2b07c5767 100644
--- a/MCServer/Plugins/Core/spawn.lua
+++ b/MCServer/Plugins/Core/spawn.lua
@@ -1,7 +1,7 @@
-function HandleSpawnCommand(Split, Player)
- World = Player:GetWorld()
- SetBackCoordinates(Player)
- Player:TeleportToCoords(World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ())
- LOGINFO(Player:GetName() .. " returned to spawn.")
- return true
+function HandleSpawnCommand(Split, Player)
+ World = Player:GetWorld()
+ SetBackCoordinates(Player)
+ Player:TeleportToCoords(World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ())
+ LOGINFO(Player:GetName() .. " returned to spawn.")
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/stop.lua b/MCServer/Plugins/Core/stop.lua
deleted file mode 100644
index 1240c49d8..000000000
--- a/MCServer/Plugins/Core/stop.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-function HandleStopCommand( Split, Player )
- Server = cRoot:Get():GetServer()
- Server:SendMessage( cChatColor.Green .. "Stopping the server..." )
- cRoot:Get():QueueExecuteConsoleCommand("stop")
- return true
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/teleport.lua b/MCServer/Plugins/Core/teleport.lua
index ad9e7be69..89352408a 100644
--- a/MCServer/Plugins/Core/teleport.lua
+++ b/MCServer/Plugins/Core/teleport.lua
@@ -1,46 +1,80 @@
-function HandleTPCommand(a_Split, a_Player)
- if ((#a_Split == 2) or (#a_Split == 3)) then
- -- Teleport to player specified in a_Split[2], tell them unless a_Split[3] equals "-h":
- TeleportToPlayer(a_Player, a_Split[2], (a_Split[3] ~= "-h"));
- return true;
- elseif (#a_Split == 4) then
- -- Teleport to XYZ coords specified in a_Split[2, 3, 4]:
- SetBackCoordinates(a_Player);
- a_Player:TeleportToCoords(a_Split[2], a_Split[3], a_Split[4]);
- a_Player:SendMessage(cChatColor.Green .. "You teleported to {" .. a_Split[2] .. ", " .. a_Split[3] .. ", " .. a_Split[4] .. "}");
- return true;
- else
- Player:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName] (-h)" )
- return true
- end
-end
-
-
-
-
-
--- Teleports a_SrcPlayer to a player named a_DstPlayerName; if a_TellDst is true, will send a notice to the destination player
-function TeleportToPlayer(a_SrcPlayer, a_DstPlayerName, a_TellDst)
- local teleport = function(OtherPlayer)
- if (OtherPlayer == a_SrcPlayer) then
- -- Asked to teleport to self?
- a_SrcPlayer:SendMessage(cChatColor.Green .. "Already there :)");
- else
- SetBackCoordinates(a_SrcPlayer);
- a_SrcPlayer:TeleportToEntity(OtherPlayer);
- a_SrcPlayer:SendMessage(cChatColor.Green .. "You teleported to " .. OtherPlayer:GetName() .. "!");
- if (a_TellDst) then
- OtherPlayer:SendMessage(cChatColor.Green .. Player:GetName().." teleported to you!");
- end
- end
- end
-
- local World = Player:GetWorld();
- if (not(World:DoWithPlayer(s_DstPlayerName, teleport))) then
- a_SrcPlayer:SendMessage(cChatColor.Green .. "Can't find player " .. a_DstPlayerName);
- end
-end
-
-
-
-
+function HandleTPCommand(a_Split, a_Player)
+ if ((#a_Split == 2) or (#a_Split == 3)) then
+ -- Teleport to player specified in a_Split[2], tell them unless a_Split[3] equals "-h":
+ TeleportToPlayer(a_Player, a_Split[2], (a_Split[3] ~= "-h"));
+ return true;
+ elseif (#a_Split == 4) then
+ -- Teleport to XYZ coords specified in a_Split[2, 3, 4]:
+ SetBackCoordinates(a_Player);
+ a_Player:TeleportToCoords(a_Split[2], a_Split[3], a_Split[4]);
+ a_Player:SendMessage(cChatColor.Green .. "You teleported to {" .. a_Split[2] .. ", " .. a_Split[3] .. ", " .. a_Split[4] .. "}");
+ return true;
+ else
+ a_Player:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName] (-h) or /tp [X Y Z]" )
+ return true
+ end
+end
+
+function HandleTPACommand( Split, Player )
+ if Split[2] == nil then
+ Player:SendMessage( cChatColor.Green .. "Usage: /tpa [Player]" )
+ return true
+ end
+ local loopPlayer = function( OtherPlayer )
+ if OtherPlayer:GetName() == Split[2] then
+ OtherPlayer:SendMessage( cChatColor.Green .. Player:GetName() .. " send a teleport request" )
+ Player:SendMessage( cChatColor.Green .. "You send a teleport request to " .. OtherPlayer:GetName() )
+ Destination[OtherPlayer:GetName()] = Player:GetName()
+ end
+ end
+ local loopWorlds = function( World )
+ World:ForEachPlayer( loopPlayer )
+ end
+ cRoot:Get():ForEachWorld( loopWorlds )
+ return true
+end
+
+function HandleTPAcceptCommand( Split, Player )
+ if Destination[Player:GetName()] == nil then
+ Player:SendMessage( cChatColor.Green .. "Nobody has send you a teleport request" )
+ return true
+ end
+ local loopPlayer = function( OtherPlayer )
+ if Destination[Player:GetName()] == OtherPlayer:GetName() then
+ if OtherPlayer:GetWorld():GetName() ~= Player:GetWorld():GetName() then
+ OtherPlayer:MoveToWorld( Player:GetWorld():GetName() )
+ end
+ OtherPlayer:TeleportToEntity( Player )
+ Player:SendMessage( cChatColor.Green .. OtherPlayer:GetName() .. " teleported to you" )
+ OtherPlayer:SendMessage( cChatColor.Green .. "You teleported to " .. Player:GetName() )
+ Destination[Player:GetName()] = nil
+ end
+ end
+ local loopWorlds = function( World )
+ World:ForEachPlayer( loopPlayer )
+ end
+ cRoot:Get():ForEachWorld( loopWorlds )
+ return true
+end
+
+-- Teleports a_SrcPlayer to a player named a_DstPlayerName; if a_TellDst is true, will send a notice to the destination player
+function TeleportToPlayer(a_SrcPlayer, a_DstPlayerName, a_TellDst)
+ local teleport = function(OtherPlayer)
+ if (OtherPlayer == a_SrcPlayer) then
+ -- Asked to teleport to self?
+ a_SrcPlayer:SendMessage(cChatColor.Green .. "Y' can't teleport to yerself!");
+ else
+ SetBackCoordinates(a_SrcPlayer);
+ a_SrcPlayer:TeleportToEntity(OtherPlayer);
+ a_SrcPlayer:SendMessage(cChatColor.Green .. "You teleported to " .. OtherPlayer:GetName() .. "!");
+ if (a_TellDst) then
+ OtherPlayer:SendMessage(cChatColor.Green .. Player:GetName().." teleported to you!");
+ end
+ end
+ end
+
+ local World = a_SrcPlayer:GetWorld();
+ if (not(World:DoWithPlayer(a_DstPlayerName, teleport))) then
+ a_SrcPlayer:SendMessage(cChatColor.Green .. "Can't find player " .. a_DstPlayerName);
+ end
+end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/time.lua b/MCServer/Plugins/Core/time.lua
index 637773b45..85593695a 100644
--- a/MCServer/Plugins/Core/time.lua
+++ b/MCServer/Plugins/Core/time.lua
@@ -1,23 +1,23 @@
-function HandleTimeCommand( Split, Player )
- if Split[2] == nil then
- Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" )
- return true
- end
- local Server = cRoot:Get():GetServer()
- if( string.upper( Split[2] ) == "DAY") then
- Player:GetWorld():SetTimeOfDay( 0 )
- Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Day.")
- elseif( string.upper( Split[2] ) == "NIGHT") then
- Player:GetWorld():SetTimeOfDay( 12000 + 1000 )
- Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Night.")
- elseif( string.upper(Split[2]) == "SET" ) and ( tonumber(Split[3]) ~= nil) then
- Player:GetWorld():SetTimeOfDay( tonumber(Split[3]) )
- Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to " .. Split[3] )
- elseif( string.upper(Split[2]) == "ADD" ) and ( tonumber(Split[3]) ~= nil) then
- Player:GetWorld():SetTimeOfDay( Player:GetWorld():GetTimeOfDay() + Split[3] )
- Server:SendMessage( cChatColor.Green .. Player:GetName() .. " Added " .. Split[3] .. " to the time" )
- else
- Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" )
- end
- return true
+function HandleTimeCommand( Split, Player )
+ if Split[2] == nil then
+ Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" )
+ return true
+ end
+ local Server = cRoot:Get():GetServer()
+ if( string.upper( Split[2] ) == "DAY") then
+ Player:GetWorld():SetTimeOfDay( 0 )
+ Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Day.")
+ elseif( string.upper( Split[2] ) == "NIGHT") then
+ Player:GetWorld():SetTimeOfDay( 12000 + 1000 )
+ Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Night.")
+ elseif( string.upper(Split[2]) == "SET" ) and ( tonumber(Split[3]) ~= nil) then
+ Player:GetWorld():SetTimeOfDay( tonumber(Split[3]) )
+ Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to " .. Split[3] )
+ elseif( string.upper(Split[2]) == "ADD" ) and ( tonumber(Split[3]) ~= nil) then
+ Player:GetWorld():SetTimeOfDay( Player:GetWorld():GetTimeOfDay() + Split[3] )
+ Server:SendMessage( cChatColor.Green .. Player:GetName() .. " Added " .. Split[3] .. " to the time" )
+ else
+ Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" )
+ end
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/top.lua b/MCServer/Plugins/Core/top.lua
index 99bea5f75..bc2343f7f 100644
--- a/MCServer/Plugins/Core/top.lua
+++ b/MCServer/Plugins/Core/top.lua
@@ -1,11 +1,11 @@
-function HandleTopCommand( Split, Player )
- local World = Player:GetWorld()
-
- local PlayerPos = Player:GetPosition()
- local Height = World:GetHeight( math.floor(PlayerPos.x), math.floor(PlayerPos.z) )
- SetBackCoordinates( Player )
- Player:TeleportToCoords( PlayerPos.x, Height+1, PlayerPos.z )
- Player:SendMessage("Teleported to the top block")
-
- return true
+function HandleTopCommand( Split, Player )
+ local World = Player:GetWorld()
+
+ local PlayerPos = Player:GetPosition()
+ local Height = World:GetHeight( math.floor(PlayerPos.x), math.floor(PlayerPos.z) )
+ SetBackCoordinates( Player )
+ Player:TeleportToCoords( PlayerPos.x, Height+1, PlayerPos.z )
+ Player:SendMessage("Teleported to the top block")
+
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/unban.lua b/MCServer/Plugins/Core/unban.lua
deleted file mode 100644
index 9defbe323..000000000
--- a/MCServer/Plugins/Core/unban.lua
+++ /dev/null
@@ -1,20 +0,0 @@
-function HandleUnbanCommand( Split, Player )
- if( #Split < 2 ) then
- Player:SendMessage( cChatColor.Green .. "Usage: /unban [Player]" )
- return true
- end
-
- if( BannedPlayersIni:GetValueB("Banned", Split[2], false) == false ) then
- Player:SendMessage( cChatColor.Green .. Split[2] .. " is not banned!" )
- return true
- end
-
- BannedPlayersIni:SetValueB("Banned", Split[2], false, false)
- BannedPlayersIni:WriteFile()
-
- local Server = cRoot:Get():GetServer()
- LOGINFO( Player:GetName() .. " is unbanning " .. Split[2] )
- Server:SendMessage( "Unbanning " .. Split[2] )
-
- return true
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/viewdistance.lua b/MCServer/Plugins/Core/viewdistance.lua
index 43d2a7de8..dfd310aa7 100644
--- a/MCServer/Plugins/Core/viewdistance.lua
+++ b/MCServer/Plugins/Core/viewdistance.lua
@@ -1,10 +1,10 @@
-function HandleViewDistanceCommand( Split, Player )
- if( #Split ~= 2 ) then
- Player:SendMessage( cChatColor.Green .. "Usage: /viewdistance [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."]" )
- return true
- end
-
- Player:GetClientHandle():SetViewDistance( Split[2] )
- Player:SendMessage(cChatColor.Green .. "Your viewdistance has been set to " .. Player:GetClientHandle():GetViewDistance() )
- return true
+function HandleViewDistanceCommand( Split, Player )
+ if( #Split ~= 2 ) then
+ Player:SendMessage( cChatColor.Green .. "Usage: /viewdistance [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."]" )
+ return true
+ end
+
+ Player:GetClientHandle():SetViewDistance( Split[2] )
+ Player:SendMessage(cChatColor.Green .. "Your viewdistance has been set to " .. Player:GetClientHandle():GetViewDistance() )
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/weather.lua b/MCServer/Plugins/Core/weather.lua
index 49cbaa079..7176e544e 100644
--- a/MCServer/Plugins/Core/weather.lua
+++ b/MCServer/Plugins/Core/weather.lua
@@ -1,10 +1,10 @@
-function HandleToggleDownfallCommand( Split, Player )
- World = Player:GetWorld()
- if World:GetWeather() == 0 then
- World:SetWeather(1)
- else
- World:SetWeather(0)
- end
- Player:SendMessage( cChatColor.Green .. "Weather toggled")
- return true
+function HandleToggleDownfallCommand( Split, Player )
+ World = Player:GetWorld()
+ if World:GetWeather() == 0 then
+ World:SetWeather(1)
+ else
+ World:SetWeather(0)
+ end
+ Player:SendMessage( cChatColor.Green .. "Weather toggled")
+ return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/web_chat.lua b/MCServer/Plugins/Core/web_chat.lua
index dd03203bd..dfb17091e 100644
--- a/MCServer/Plugins/Core/web_chat.lua
+++ b/MCServer/Plugins/Core/web_chat.lua
@@ -1,157 +1,157 @@
-local CHAT_HISTORY = 50
-local LastMessageID = 0
-
-local JavaScript = [[
- <script type="text/javascript">
- function createXHR()
- {
- var request = false;
- try {
- request = new ActiveXObject('Msxml2.XMLHTTP');
- }
- catch (err2) {
- try {
- request = new ActiveXObject('Microsoft.XMLHTTP');
- }
- catch (err3) {
- try {
- request = new XMLHttpRequest();
- }
- catch (err1) {
- request = false;
- }
- }
- }
- return request;
- }
-
- function OpenPage( url, postParams, callback )
- {
- var xhr = createXHR();
- xhr.onreadystatechange=function()
- {
- if (xhr.readyState == 4)
- {
- callback( xhr )
- }
- };
- xhr.open( (postParams!=null)?"POST":"GET", url , true);
- if( postParams != null )
- {
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- }
- xhr.send(postParams);
- }
-
- function LoadPageInto( url, postParams, storage )
- {
- OpenPage( url, postParams, function( xhr )
- {
- var ScrollBottom = storage.scrollTop + storage.offsetHeight;
- var bAutoScroll = (ScrollBottom >= storage.scrollHeight); // Detect whether we scrolled to the bottom of the div
-
- results = xhr.responseText.split("<<divider>>");
- if( results[2] != LastMessageID ) return; // Check if this message was meant for us
-
- LastMessageID = results[1];
- if( results[0] != "" )
- {
- storage.innerHTML += results[0];
-
- if( bAutoScroll == true )
- {
- storage.scrollTop = storage.scrollHeight;
- }
- }
- } );
-
-
- return false;
- }
-
- function SendChatMessage()
- {
- var MessageContainer = document.getElementById('ChatMessage');
- if( MessageContainer.value == "" ) return;
-
- var postParams = "ChatMessage=" + MessageContainer.value;
- OpenPage( "/~webadmin/Core/Chat/", postParams, function( xhr )
- {
- RefreshChat();
- } );
- MessageContainer.value = "";
- }
-
- function RefreshChat()
- {
- var postParams = "JustChat=true&LastMessageID=" + LastMessageID;
- LoadPageInto("/~webadmin/Core/Chat/", postParams, document.getElementById('ChatDiv'));
- }
-
- setInterval(RefreshChat, 1000);
- window.onload = RefreshChat;
-
- var LastMessageID = 0;
-
- </script>
-]]
-
-local ChatLogMessages = {}
-
-function AddMessage( PlayerName, Message )
- LastMessageID = LastMessageID + 1
- table.insert( ChatLogMessages, { name = PlayerName, message = Message, id = LastMessageID } )
- while( #ChatLogMessages > CHAT_HISTORY ) do
- table.remove( ChatLogMessages, 1 )
- end
-end
-
-function OnChat( Player, Message )
- AddMessage( Player:GetName(), Message )
-end
-
-function HandleRequest_Chat( Request )
- if( Request.PostParams["JustChat"] ~= nil ) then
- local LastIdx = 0
- if( Request.PostParams["LastMessageID"] ~= nil ) then LastIdx = tonumber( Request.PostParams["LastMessageID"] ) end
- local Content = ""
- for key, value in pairs(ChatLogMessages) do
- if( value.id > LastIdx ) then
- Content = Content .. "[" .. value.name .. "]: " .. value.message .. "<br>"
- end
- end
- Content = Content .. "<<divider>>" .. LastMessageID .. "<<divider>>" .. LastIdx
- return Content
- end
-
- if( Request.PostParams["ChatMessage"] ~= nil ) then
- if( Request.PostParams["ChatMessage"] == "/help" ) then
- Commands = "Available commands"
- AddMessage(Commands, "<br>" .. "/help, /reload" )
- return Commands
- elseif( Request.PostParams["ChatMessage"] == "/reload" ) then
- Server = cRoot:Get():GetServer()
- Server:SendMessage( cChatColor.Green .. "Reloading all plugins." )
- AddMessage("Reloading all plugins", "")
- cRoot:Get():GetPluginManager():ReloadPlugins()
- return ""
- else
- cmd = Request.PostParams["ChatMessage"]
- if string.sub(cmd,1,string.len("/")) == "/" then
- AddMessage('Unknown Command "' .. Request.PostParams["ChatMessage"] .. '"', "")
- return ""
- end
- end
- local Message = "[WebAdmin]: " .. Request.PostParams["ChatMessage"]
- cRoot:Get():GetServer():SendMessage( Message )
- AddMessage("WebAdmin", Request.PostParams["ChatMessage"] )
- return ""
- end
-
- local Content = JavaScript
- Content = Content .. [[
- <div style="font-family: Courier; border: 1px solid #DDD; padding: 10px; width: 97%; height: 200px; overflow: scroll;" id="ChatDiv"></div>
- <input type="text" id="ChatMessage" onKeyPress="if (event.keyCode == 13) { SendChatMessage(); }"><input type="submit" value="Submit" onClick="SendChatMessage();">
- ]]
- return Content
+local CHAT_HISTORY = 50
+local LastMessageID = 0
+
+local JavaScript = [[
+ <script type="text/javascript">
+ function createXHR()
+ {
+ var request = false;
+ try {
+ request = new ActiveXObject('Msxml2.XMLHTTP');
+ }
+ catch (err2) {
+ try {
+ request = new ActiveXObject('Microsoft.XMLHTTP');
+ }
+ catch (err3) {
+ try {
+ request = new XMLHttpRequest();
+ }
+ catch (err1) {
+ request = false;
+ }
+ }
+ }
+ return request;
+ }
+
+ function OpenPage( url, postParams, callback )
+ {
+ var xhr = createXHR();
+ xhr.onreadystatechange=function()
+ {
+ if (xhr.readyState == 4)
+ {
+ callback( xhr )
+ }
+ };
+ xhr.open( (postParams!=null)?"POST":"GET", url , true);
+ if( postParams != null )
+ {
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ }
+ xhr.send(postParams);
+ }
+
+ function LoadPageInto( url, postParams, storage )
+ {
+ OpenPage( url, postParams, function( xhr )
+ {
+ var ScrollBottom = storage.scrollTop + storage.offsetHeight;
+ var bAutoScroll = (ScrollBottom >= storage.scrollHeight); // Detect whether we scrolled to the bottom of the div
+
+ results = xhr.responseText.split("<<divider>>");
+ if( results[2] != LastMessageID ) return; // Check if this message was meant for us
+
+ LastMessageID = results[1];
+ if( results[0] != "" )
+ {
+ storage.innerHTML += results[0];
+
+ if( bAutoScroll == true )
+ {
+ storage.scrollTop = storage.scrollHeight;
+ }
+ }
+ } );
+
+
+ return false;
+ }
+
+ function SendChatMessage()
+ {
+ var MessageContainer = document.getElementById('ChatMessage');
+ if( MessageContainer.value == "" ) return;
+
+ var postParams = "ChatMessage=" + MessageContainer.value;
+ OpenPage( "/~webadmin/Core/Chat/", postParams, function( xhr )
+ {
+ RefreshChat();
+ } );
+ MessageContainer.value = "";
+ }
+
+ function RefreshChat()
+ {
+ var postParams = "JustChat=true&LastMessageID=" + LastMessageID;
+ LoadPageInto("/~webadmin/Core/Chat/", postParams, document.getElementById('ChatDiv'));
+ }
+
+ setInterval(RefreshChat, 1000);
+ window.onload = RefreshChat;
+
+ var LastMessageID = 0;
+
+ </script>
+]]
+
+local ChatLogMessages = {}
+
+function AddMessage( PlayerName, Message )
+ LastMessageID = LastMessageID + 1
+ table.insert( ChatLogMessages, { name = PlayerName, message = Message, id = LastMessageID } )
+ while( #ChatLogMessages > CHAT_HISTORY ) do
+ table.remove( ChatLogMessages, 1 )
+ end
+end
+
+function OnChat( Player, Message )
+ AddMessage( Player:GetName(), Message )
+end
+
+function HandleRequest_Chat( Request )
+ if( Request.PostParams["JustChat"] ~= nil ) then
+ local LastIdx = 0
+ if( Request.PostParams["LastMessageID"] ~= nil ) then LastIdx = tonumber( Request.PostParams["LastMessageID"] ) end
+ local Content = ""
+ for key, value in pairs(ChatLogMessages) do
+ if( value.id > LastIdx ) then
+ Content = Content .. "[" .. value.name .. "]: " .. value.message .. "<br>"
+ end
+ end
+ Content = Content .. "<<divider>>" .. LastMessageID .. "<<divider>>" .. LastIdx
+ return Content
+ end
+
+ if( Request.PostParams["ChatMessage"] ~= nil ) then
+ if( Request.PostParams["ChatMessage"] == "/help" ) then
+ Commands = "Available commands"
+ AddMessage(Commands, "<br>" .. "/help, /reload" )
+ return Commands
+ elseif( Request.PostParams["ChatMessage"] == "/reload" ) then
+ Server = cRoot:Get():GetServer()
+ Server:SendMessage( cChatColor.Green .. "Reloading all plugins." )
+ AddMessage("Reloading all plugins", "")
+ cRoot:Get():GetPluginManager():ReloadPlugins()
+ return ""
+ else
+ cmd = Request.PostParams["ChatMessage"]
+ if string.sub(cmd,1,string.len("/")) == "/" then
+ AddMessage('Unknown Command "' .. Request.PostParams["ChatMessage"] .. '"', "")
+ return ""
+ end
+ end
+ local Message = "[WebAdmin]: " .. Request.PostParams["ChatMessage"]
+ cRoot:Get():GetServer():SendMessage( Message )
+ AddMessage("WebAdmin", Request.PostParams["ChatMessage"] )
+ return ""
+ end
+
+ local Content = JavaScript
+ Content = Content .. [[
+ <div style="font-family: Courier; border: 1px solid #DDD; padding: 10px; width: 97%; height: 200px; overflow: scroll;" id="ChatDiv"></div>
+ <input type="text" id="ChatMessage" onKeyPress="if (event.keyCode == 13) { SendChatMessage(); }"><input type="submit" value="Submit" onClick="SendChatMessage();">
+ ]]
+ return Content
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/web_manageplugins.lua b/MCServer/Plugins/Core/web_manageplugins.lua
index bf1f04ff5..543638183 100644
--- a/MCServer/Plugins/Core/web_manageplugins.lua
+++ b/MCServer/Plugins/Core/web_manageplugins.lua
@@ -1,157 +1,157 @@
-local function Button_RemovePlugin( Name, Index )
- return "<form method='POST'><input type='hidden' name='PluginName' value='"..Name.."'><input type='hidden' name='PluginIndex' value='"..Index.."'><input type='submit' name='RemovePlugin' value='Remove'></form>"
-end
-
-local function Button_EnablePlugin( Name )
- return [[<form method="POST"><input type="hidden" name="PluginName", value="]].. Name ..[["><input type="submit" name="EnablePlugin" value="Enable"></form>]]
-end
-
-local function Button_DisablePlugin( Name )
- return [[<form method="POST"><input type="hidden" name="PluginName", value="]].. Name ..[["><input type="submit" name="DisablePlugin" value="Disable"></form>]]
-end
-
-local function FindPluginID( SettingsIni, PluginName )
- local KeyIdx = SettingsIni:FindKey("Plugins")
- local NumValues = SettingsIni:GetNumValues( KeyIdx )
-
- for i = 0, NumValues-1 do
- LOGINFO( SettingsIni:GetValue(KeyIdx, i) )
- if( SettingsIni:GetValue(KeyIdx, i) == PluginName ) then
- return i
- end
- end
-
- return nil
-end
-
-local function RemovePluginFromIni( SettingsIni, PluginName )
- local KeyIdx = SettingsIni:FindKey("Plugins")
- local PluginIdx = FindPluginID( SettingsIni, PluginName )
-
- if( PluginIdx == nil ) then
- LOGINFO("Got nil! NOOOO")
- return false
- end
-
- local Name = SettingsIni:GetValue( KeyIdx, PluginIdx )
- if( Name ~= PluginName ) then
- LOGINFO("not the same name T_T '" .. Name .. "' '" .. PluginName .. "'")
- end
- if( (Name == PluginName) and (SettingsIni:DeleteValueByID( KeyIdx, PluginIdx ) == true) ) then
- return SettingsIni:WriteFile()
- end
-
- return false
-end
-
-local function AddPluginToIni( SettingsIni, PluginName )
- RemovePluginFromIni( SettingsIni, PluginName ) -- Make sure there are no duplicates
-
- if( SettingsIni:SetValue("Plugins", "Plugin", PluginName, true ) == true ) then
- return SettingsIni:WriteFile()
- end
-
- return false
-end
-
-local function HandlePluginListChanges( Request, SettingsIni )
- local Content = ""
-
- if( Request.PostParams["EnablePlugin"] ~= nil
- and Request.PostParams["PluginName"] ~= nil ) then
-
- local PluginName = Request.PostParams["PluginName"]
-
- local PM = cRoot:Get():GetPluginManager()
- if( PM:LoadPlugin( PluginName ) == false ) then
- Content = "Could not enable '".. PluginName .."'!"
- end
-
- if( AddPluginToIni( SettingsIni, PluginName ) == true ) then
- Content = "Enabled plugin '".. PluginName .."'"
- else
- Content = "Enabled plugin '".. PluginName .."' but could not add it to settings.ini"
- end
-
-
- elseif( Request.PostParams["DisablePlugin"] ~= nil
- and Request.PostParams["PluginName"] ~= nil ) then
-
- local PluginName = Request.PostParams["PluginName"]
-
- local PM = cRoot:Get():GetPluginManager()
- PM:DisablePlugin( PluginName )
-
- if( RemovePluginFromIni( SettingsIni, PluginName ) == true ) then
- Content = "Disabled plugin '".. PluginName .."'"
- else
- Content = "Disabled plugin '".. PluginName .."' but could not remove it from settings.ini"
- end
-
-
-
- end
-
- if( #Content > 0 ) then
- return "<p><font color='red'><strong>INFO: " .. Content .. "</strong></font></p>"
- else
- return ""
- end
-end
-
-function HandleRequest_ManagePlugins( Request )
- local Content = ""
-
- if( Request.PostParams["reload"] ~= nil ) then
- Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
- Content = Content .. "<p>Reloading plugins... This can take a while depending on the plugins you're using.</p>"
- cRoot:Get():GetPluginManager():ReloadPlugins()
- return Content
- end
-
- local SettingsIni = cIniFile("settings.ini")
- if( SettingsIni:ReadFile() == true ) then
- Content = Content .. HandlePluginListChanges( Request, SettingsIni )
- else
- Content = Content .. "Cannot find/modify settings.ini"
- end
-
- local PluginManager = cRoot:Get():GetPluginManager()
- PluginManager:FindPlugins() -- Refreshes the plugin list
- local PluginList = PluginManager:GetAllPlugins()
-
- Content = Content .. "<h4>Currently installed plugins</h4>"
- Content = Content .. "<table>"
- ActivePluginsName = {}
- ActivePluginVersion = {}
- InactivePlugins = {}
- for k, Plugin in pairs(PluginList) do
- if( Plugin ) then
- table.insert( ActivePluginsName, k )
- table.insert( ActivePluginVersion, Plugin:GetVersion() )
- else
- table.insert( InactivePlugins, k )
- end
- end
- table.sort( ActivePluginsName )
- table.sort( InactivePlugins )
- for i = 1, #ActivePluginsName do
- Content = Content .. "<tr><td>".. ActivePluginsName[i] .."</td>"
- Content = Content .. "<td>" .. ActivePluginsName[i] .. " V. " .. ActivePluginVersion[i] .. "</td><td>" .. Button_DisablePlugin(ActivePluginsName[i]) .. "</td>"
- Content = Content .. "</tr>"
- end
- for i = 1, #InactivePlugins do
- Content = Content .. "<tr><td>".. InactivePlugins[i] .."</td>"
- Content = Content .. "<td></td><td>" .. Button_EnablePlugin(InactivePlugins[i]) .. "</td>"
- Content = Content .. "</tr>"
- end
- Content = Content .. "</table>"
-
- Content = Content .. "<h4>Reload</h4>"
- Content = Content .. "<form method='POST'>"
- Content = Content .. "<p>Click the reload button to reload all plugins according to <strong>settings.ini</strong>!"
- Content = Content .. "<input type='submit' name='reload' value='Reload!'></p>"
- Content = Content .. "</form>"
-
- return Content
+local function Button_RemovePlugin( Name, Index )
+ return "<form method='POST'><input type='hidden' name='PluginName' value='"..Name.."'><input type='hidden' name='PluginIndex' value='"..Index.."'><input type='submit' name='RemovePlugin' value='Remove'></form>"
+end
+
+local function Button_EnablePlugin( Name )
+ return [[<form method="POST"><input type="hidden" name="PluginName", value="]].. Name ..[["><input type="submit" name="EnablePlugin" value="Enable"></form>]]
+end
+
+local function Button_DisablePlugin( Name )
+ return [[<form method="POST"><input type="hidden" name="PluginName", value="]].. Name ..[["><input type="submit" name="DisablePlugin" value="Disable"></form>]]
+end
+
+local function FindPluginID( SettingsIni, PluginName )
+ local KeyIdx = SettingsIni:FindKey("Plugins")
+ local NumValues = SettingsIni:GetNumValues( KeyIdx )
+
+ for i = 0, NumValues-1 do
+ LOGINFO( SettingsIni:GetValue(KeyIdx, i) )
+ if( SettingsIni:GetValue(KeyIdx, i) == PluginName ) then
+ return i
+ end
+ end
+
+ return nil
+end
+
+local function RemovePluginFromIni( SettingsIni, PluginName )
+ local KeyIdx = SettingsIni:FindKey("Plugins")
+ local PluginIdx = FindPluginID( SettingsIni, PluginName )
+
+ if( PluginIdx == nil ) then
+ LOGINFO("Got nil! NOOOO")
+ return false
+ end
+
+ local Name = SettingsIni:GetValue( KeyIdx, PluginIdx )
+ if( Name ~= PluginName ) then
+ LOGINFO("not the same name T_T '" .. Name .. "' '" .. PluginName .. "'")
+ end
+ if( (Name == PluginName) and (SettingsIni:DeleteValueByID( KeyIdx, PluginIdx ) == true) ) then
+ return SettingsIni:WriteFile()
+ end
+
+ return false
+end
+
+local function AddPluginToIni( SettingsIni, PluginName )
+ RemovePluginFromIni( SettingsIni, PluginName ) -- Make sure there are no duplicates
+
+ if( SettingsIni:SetValue("Plugins", "Plugin", PluginName, true ) == true ) then
+ return SettingsIni:WriteFile()
+ end
+
+ return false
+end
+
+local function HandlePluginListChanges( Request, SettingsIni )
+ local Content = ""
+
+ if( Request.PostParams["EnablePlugin"] ~= nil
+ and Request.PostParams["PluginName"] ~= nil ) then
+
+ local PluginName = Request.PostParams["PluginName"]
+
+ local PM = cRoot:Get():GetPluginManager()
+ if( PM:LoadPlugin( PluginName ) == false ) then
+ Content = "Could not enable '".. PluginName .."'!"
+ end
+
+ if( AddPluginToIni( SettingsIni, PluginName ) == true ) then
+ Content = "Enabled plugin '".. PluginName .."'"
+ else
+ Content = "Enabled plugin '".. PluginName .."' but could not add it to settings.ini"
+ end
+
+
+ elseif( Request.PostParams["DisablePlugin"] ~= nil
+ and Request.PostParams["PluginName"] ~= nil ) then
+
+ local PluginName = Request.PostParams["PluginName"]
+
+ local PM = cRoot:Get():GetPluginManager()
+ PM:DisablePlugin( PluginName )
+
+ if( RemovePluginFromIni( SettingsIni, PluginName ) == true ) then
+ Content = "Disabled plugin '".. PluginName .."'"
+ else
+ Content = "Disabled plugin '".. PluginName .."' but could not remove it from settings.ini"
+ end
+
+
+
+ end
+
+ if( #Content > 0 ) then
+ return "<p><font color='red'><strong>INFO: " .. Content .. "</strong></font></p>"
+ else
+ return ""
+ end
+end
+
+function HandleRequest_ManagePlugins( Request )
+ local Content = ""
+
+ if( Request.PostParams["reload"] ~= nil ) then
+ Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
+ Content = Content .. "<p>Reloading plugins... This can take a while depending on the plugins you're using.</p>"
+ cRoot:Get():GetPluginManager():ReloadPlugins()
+ return Content
+ end
+
+ local SettingsIni = cIniFile("settings.ini")
+ if( SettingsIni:ReadFile() == true ) then
+ Content = Content .. HandlePluginListChanges( Request, SettingsIni )
+ else
+ Content = Content .. "Cannot find/modify settings.ini"
+ end
+
+ local PluginManager = cRoot:Get():GetPluginManager()
+ PluginManager:FindPlugins() -- Refreshes the plugin list
+ local PluginList = PluginManager:GetAllPlugins()
+
+ Content = Content .. "<h4>Currently installed plugins</h4>"
+ Content = Content .. "<table>"
+ ActivePluginsName = {}
+ ActivePluginVersion = {}
+ InactivePlugins = {}
+ for k, Plugin in pairs(PluginList) do
+ if( Plugin ) then
+ table.insert( ActivePluginsName, k )
+ table.insert( ActivePluginVersion, Plugin:GetVersion() )
+ else
+ table.insert( InactivePlugins, k )
+ end
+ end
+ table.sort( ActivePluginsName )
+ table.sort( InactivePlugins )
+ for i = 1, #ActivePluginsName do
+ Content = Content .. "<tr><td>".. ActivePluginsName[i] .."</td>"
+ Content = Content .. "<td>" .. ActivePluginsName[i] .. " V. " .. ActivePluginVersion[i] .. "</td><td>" .. Button_DisablePlugin(ActivePluginsName[i]) .. "</td>"
+ Content = Content .. "</tr>"
+ end
+ for i = 1, #InactivePlugins do
+ Content = Content .. "<tr><td>".. InactivePlugins[i] .."</td>"
+ Content = Content .. "<td></td><td>" .. Button_EnablePlugin(InactivePlugins[i]) .. "</td>"
+ Content = Content .. "</tr>"
+ end
+ Content = Content .. "</table>"
+
+ Content = Content .. "<h4>Reload</h4>"
+ Content = Content .. "<form method='POST'>"
+ Content = Content .. "<p>Click the reload button to reload all plugins according to <strong>settings.ini</strong>!"
+ Content = Content .. "<input type='submit' name='reload' value='Reload!'></p>"
+ Content = Content .. "</form>"
+
+ return Content
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/web_permissions.lua b/MCServer/Plugins/Core/web_permissions.lua
index 5278767e7..7a8af56e9 100644
--- a/MCServer/Plugins/Core/web_permissions.lua
+++ b/MCServer/Plugins/Core/web_permissions.lua
@@ -1,134 +1,134 @@
-local function HTML_Option( value, text, selected )
- if( selected == true ) then
- return [[<option value="]] .. value .. [[" selected>]] .. text .. [[</option>]]
- else
- return [[<option value="]] .. value .. [[">]] .. text .. [[</option>"]]
- end
-end
-
-local function ShowUsersTable()
- local Content = "<h4>Users</h4>"
-
- local NumUsers = UsersIni:GetNumKeys()
-
- Content = Content .. "<table>"
-
- if( NumUsers > 0 ) then
- Content = Content .. "<tr><th></th><th>User</th><th>Groups</th></tr>"
-
- for i=0, NumUsers-1 do
- local UserName = UsersIni:GetKeyName( i )
-
- Content = Content .. "<tr>"
- Content = Content .. "<td style='width: 10px;'>" .. i .. ".</td>"
- Content = Content .. "<td>" .. UserName .. "</td>"
- Content = Content .. "<td>"
- Content = Content .. UsersIni:GetValue( UserName, "Groups", "-" )
- Content = Content .. "</td>"
- Content = Content .. "</tr>"
- end
- else
- Content = Content .. "<tr><td>None</td></tr>"
- end
- Content = Content .. "</table>"
-
-
- return Content
-end
-
-local function ShowGroupsTable()
- local Content = "<h4>Groups</h4>"
-
- local NumGroups = GroupsIni:GetNumKeys()
-
- Content = Content .. "<table>"
- if( NumGroups > 0 ) then
- Content = Content .. "<tr><th></th><th>Name</th><th>Permissions</th><th>Color</th></tr>"
-
- for i=0, NumGroups-1 do
- local GroupName = GroupsIni:GetKeyName( i )
-
- Content = Content .. "<tr>"
- Content = Content .. "<td style='width: 10px;'>" .. i .. ".</td>"
- Content = Content .. "<td>" .. GroupName .. "</td>"
- Content = Content .. "<td>"
- Content = Content .. GroupsIni:GetValue( GroupName, "Permissions", "-" )
- Content = Content .. "</td>"
- Content = Content .. "<td>"
- Content = Content .. GroupsIni:GetValue( GroupName, "Color", "-" )
- Content = Content .. "</td>"
- Content = Content .. "</tr>"
- end
- else
- Content = Content .. "<tr><td>None</td></tr>"
- end
- Content = Content .. "</table>"
-
- return Content
-end
-
-local function HTML_Select_Group( name, defaultValue )
- Groups = ""
- for I=0, GroupsIni:GetNumKeys() - 1 do
- Groups = Groups ..
- HTML_Option(GroupsIni:KeyName(I), GroupsIni:KeyName(I), defaultValue == GroupsIni:KeyName(I) )
- end
- return [[<select name="]] .. name .. [[">]] .. Groups .. [[</select>]]
-end
-
-
-local function AddPlayers( Request )
- local Content = "<h4>Add or change Players</h4>"
- if( Request.PostParams["AddPlayerToGroup"] ~= nil ) then
- if Request.PostParams["AddPlayer"] ~= "" then
- if Request.PostParams["AddGroups"] ~= "" then
- if GroupsIni:FindKey(Request.PostParams["AddGroup"]) == -1 then
- return "Group does not exist"
- end
- UsersIni:DeleteKey(Request.PostParams["AddPlayer"])
- UsersIni:GetValueSet(Request.PostParams["AddPlayer"], "Groups", Request.PostParams["AddGroup"])
- UsersIni:WriteFile()
- local loopPlayers = function( Player )
- if Player:GetName() == Request.PostParams["AddPlayer"] then
- Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Request.PostParams["AddGroup"] )
- Player:LoadPermissionsFromDisk()
- end
- end
- local loopWorlds = function ( World )
- World:ForEachPlayer( loopPlayers )
- end
- cRoot:Get():ForEachWorld( loopWorlds )
- end
- end
- end
- Content = Content .. [[
- <form method="POST">
- <table>
- <tr><td style="width: 20%;">Player:</td>
- <td><input type="text" name="AddPlayer" value=""></td></tr><br>
- <tr><td style="width: 20%;">Group:</td>
- <td>]] .. HTML_Select_Group("AddGroup", GroupsIni:KeyName(0) ) .. [[</td></tr>
- </table>
- <input type="submit" value="Add Player" name="AddPlayerToGroup">]]
-
- return Content
-end
-
-function HandleRequest_Permissions( Request )
- GroupsIni = cIniFile("groups.ini")
- if( GroupsIni:ReadFile() == false ) then
- return "Could not read groups.ini!"
- end
- UsersIni = cIniFile("users.ini")
- if( UsersIni:ReadFile() == false ) then
- return "Could not read users.ini!"
- end
-
- local Content = ""
-
- Content = Content .. AddPlayers( Request )
- Content = Content .. ShowGroupsTable()
- Content = Content .. ShowUsersTable()
-
- return Content
+local function HTML_Option( value, text, selected )
+ if( selected == true ) then
+ return [[<option value="]] .. value .. [[" selected>]] .. text .. [[</option>]]
+ else
+ return [[<option value="]] .. value .. [[">]] .. text .. [[</option>"]]
+ end
+end
+
+local function ShowUsersTable()
+ local Content = "<h4>Users</h4>"
+
+ local NumUsers = UsersIni:GetNumKeys()
+
+ Content = Content .. "<table>"
+
+ if( NumUsers > 0 ) then
+ Content = Content .. "<tr><th></th><th>User</th><th>Groups</th></tr>"
+
+ for i=0, NumUsers-1 do
+ local UserName = UsersIni:GetKeyName( i )
+
+ Content = Content .. "<tr>"
+ Content = Content .. "<td style='width: 10px;'>" .. i .. ".</td>"
+ Content = Content .. "<td>" .. UserName .. "</td>"
+ Content = Content .. "<td>"
+ Content = Content .. UsersIni:GetValue( UserName, "Groups", "-" )
+ Content = Content .. "</td>"
+ Content = Content .. "</tr>"
+ end
+ else
+ Content = Content .. "<tr><td>None</td></tr>"
+ end
+ Content = Content .. "</table>"
+
+
+ return Content
+end
+
+local function ShowGroupsTable()
+ local Content = "<h4>Groups</h4>"
+
+ local NumGroups = GroupsIni:GetNumKeys()
+
+ Content = Content .. "<table>"
+ if( NumGroups > 0 ) then
+ Content = Content .. "<tr><th></th><th>Name</th><th>Permissions</th><th>Color</th></tr>"
+
+ for i=0, NumGroups-1 do
+ local GroupName = GroupsIni:GetKeyName( i )
+
+ Content = Content .. "<tr>"
+ Content = Content .. "<td style='width: 10px;'>" .. i .. ".</td>"
+ Content = Content .. "<td>" .. GroupName .. "</td>"
+ Content = Content .. "<td>"
+ Content = Content .. GroupsIni:GetValue( GroupName, "Permissions", "-" )
+ Content = Content .. "</td>"
+ Content = Content .. "<td>"
+ Content = Content .. GroupsIni:GetValue( GroupName, "Color", "-" )
+ Content = Content .. "</td>"
+ Content = Content .. "</tr>"
+ end
+ else
+ Content = Content .. "<tr><td>None</td></tr>"
+ end
+ Content = Content .. "</table>"
+
+ return Content
+end
+
+local function HTML_Select_Group( name, defaultValue )
+ Groups = ""
+ for I=0, GroupsIni:GetNumKeys() - 1 do
+ Groups = Groups ..
+ HTML_Option(GroupsIni:KeyName(I), GroupsIni:KeyName(I), defaultValue == GroupsIni:KeyName(I) )
+ end
+ return [[<select name="]] .. name .. [[">]] .. Groups .. [[</select>]]
+end
+
+
+local function AddPlayers( Request )
+ local Content = "<h4>Add or change Players</h4>"
+ if( Request.PostParams["AddPlayerToGroup"] ~= nil ) then
+ if Request.PostParams["AddPlayer"] ~= "" then
+ if Request.PostParams["AddGroups"] ~= "" then
+ if GroupsIni:FindKey(Request.PostParams["AddGroup"]) == -1 then
+ return "Group does not exist"
+ end
+ UsersIni:DeleteKey(Request.PostParams["AddPlayer"])
+ UsersIni:GetValueSet(Request.PostParams["AddPlayer"], "Groups", Request.PostParams["AddGroup"])
+ UsersIni:WriteFile()
+ local loopPlayers = function( Player )
+ if Player:GetName() == Request.PostParams["AddPlayer"] then
+ Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Request.PostParams["AddGroup"] )
+ Player:LoadPermissionsFromDisk()
+ end
+ end
+ local loopWorlds = function ( World )
+ World:ForEachPlayer( loopPlayers )
+ end
+ cRoot:Get():ForEachWorld( loopWorlds )
+ end
+ end
+ end
+ Content = Content .. [[
+ <form method="POST">
+ <table>
+ <tr><td style="width: 20%;">Player:</td>
+ <td><input type="text" name="AddPlayer" value=""></td></tr><br>
+ <tr><td style="width: 20%;">Group:</td>
+ <td>]] .. HTML_Select_Group("AddGroup", GroupsIni:KeyName(0) ) .. [[</td></tr>
+ </table>
+ <input type="submit" value="Add Player" name="AddPlayerToGroup">]]
+
+ return Content
+end
+
+function HandleRequest_Permissions( Request )
+ GroupsIni = cIniFile("groups.ini")
+ if( GroupsIni:ReadFile() == false ) then
+ return "Could not read groups.ini!"
+ end
+ UsersIni = cIniFile("users.ini")
+ if( UsersIni:ReadFile() == false ) then
+ return "Could not read users.ini!"
+ end
+
+ local Content = ""
+
+ Content = Content .. AddPlayers( Request )
+ Content = Content .. ShowGroupsTable()
+ Content = Content .. ShowUsersTable()
+
+ return Content
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/web_playerlist.lua b/MCServer/Plugins/Core/web_playerlist.lua
index c042c0072..6ac25db86 100644
--- a/MCServer/Plugins/Core/web_playerlist.lua
+++ b/MCServer/Plugins/Core/web_playerlist.lua
@@ -1,38 +1,38 @@
-function HandleRequest_PlayerList( Request )
- local World = cRoot:Get():GetDefaultWorld()
- local Content = ""
-
- if( Request.Params["playerlist-kick"] ~= nil ) then
- local KickPlayerName = Request.Params["playerlist-kick"]
- local FoundPlayerCallback = function( Player )
- if( Player:GetName() == KickPlayerName ) then
- Player:GetClientHandle():Kick("You were kicked from the game!")
- Content = Content .. "<p>" .. KickPlayerName .. " has been kicked from the game!</p>"
- end
- end
- if( World:DoWithPlayer( KickPlayerName, FoundPlayerCallback ) == false ) then
- Content = Content .. "<p>Could not find player " .. KickPlayerName .. " !</p>"
- end
- end
-
- Content = Content .. "<p>Connected Players: <b>" .. World:GetNumPlayers() .. "</b></p>"
- Content = Content .. "<table>"
-
- local PlayerNum = 0
- local AddPlayerToTable = function( Player )
- PlayerNum = PlayerNum + 1
- Content = Content .. "<tr>"
- Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>"
- Content = Content .. "<td>" .. Player:GetName() .. "</td>"
- Content = Content .. "<td><a href='?playerlist-kick=" .. Player:GetName() .. "'>Kick</a></td>"
- Content = Content .. "</tr>"
- end
- cRoot:Get():ForEachPlayer( AddPlayerToTable )
-
- if( PlayerNum == 0 ) then
- Content = Content .. "<tr><td>None</td></tr>"
- end
- Content = Content .. "</table>"
- Content = Content .. "<br>"
- return Content
+function HandleRequest_PlayerList( Request )
+ local World = cRoot:Get():GetDefaultWorld()
+ local Content = ""
+
+ if( Request.Params["playerlist-kick"] ~= nil ) then
+ local KickPlayerName = Request.Params["playerlist-kick"]
+ local FoundPlayerCallback = function( Player )
+ if( Player:GetName() == KickPlayerName ) then
+ Player:GetClientHandle():Kick("You were kicked from the game!")
+ Content = Content .. "<p>" .. KickPlayerName .. " has been kicked from the game!</p>"
+ end
+ end
+ if( World:DoWithPlayer( KickPlayerName, FoundPlayerCallback ) == false ) then
+ Content = Content .. "<p>Could not find player " .. KickPlayerName .. " !</p>"
+ end
+ end
+
+ Content = Content .. "<p>Connected Players: <b>" .. World:GetNumPlayers() .. "</b></p>"
+ Content = Content .. "<table>"
+
+ local PlayerNum = 0
+ local AddPlayerToTable = function( Player )
+ PlayerNum = PlayerNum + 1
+ Content = Content .. "<tr>"
+ Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>"
+ Content = Content .. "<td>" .. Player:GetName() .. "</td>"
+ Content = Content .. "<td><a href='?playerlist-kick=" .. Player:GetName() .. "'>Kick</a></td>"
+ Content = Content .. "</tr>"
+ end
+ cRoot:Get():ForEachPlayer( AddPlayerToTable )
+
+ if( PlayerNum == 0 ) then
+ Content = Content .. "<tr><td>None</td></tr>"
+ end
+ Content = Content .. "</table>"
+ Content = Content .. "<br>"
+ return Content
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/web_serversettings.lua b/MCServer/Plugins/Core/web_serversettings.lua
index d3a890b0c..700d84ae1 100644
--- a/MCServer/Plugins/Core/web_serversettings.lua
+++ b/MCServer/Plugins/Core/web_serversettings.lua
@@ -1,922 +1,924 @@
--- Some HTML helper functions
-local function HTML_Option( value, text, selected )
- if( selected == true ) then
- return [[<option value="]] .. value .. [[" selected>]] .. text .. [[</option>]]
- else
- return [[<option value="]] .. value .. [[">]] .. text .. [[</option>"]]
- end
-end
-
-local function HTML_Select_On_Off( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("1", "On", defaultValue == 1 )
- .. HTML_Option("0", "Off", defaultValue == 0 )
- .. [[</select>]]
-end
-
-local function HTML_Select_Version( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("0", "Latest Version", defaultValue == 0 )
- .. HTML_Option("61", "1.5.2", defaultValue == 1 )
- .. HTML_Option("60", "1.5.0", defaultValue == 2 )
- .. HTML_Option("49", "1.4.5", defaultValue == 3 )
- .. HTML_Option("47", "1.4.2", defaultValue == 4 )
- .. HTML_Option("39", "1.3.2", defaultValue == 5 )
- .. HTML_Option("29", "1.2.5", defaultValue == 6 )
- .. [[</select>]]
-end
-
-
-local function ShowGeneralSettings( Request )
- local Content = ""
- local InfoMsg = nil
-
- local SettingsIni = cIniFile("settings.ini")
- if( SettingsIni:ReadFile() == false ) then
- InfoMsg = "<b style=\"color: red;\">ERROR: Could not read settings.ini!</b>"
- end
-
- if( Request.PostParams["general_submit"] ~= nil ) then
-
- SettingsIni:SetValue("Server", "Description",Request.PostParams["Server_Description"],false )
- if( tonumber( Request.PostParams["Server_MaxPlayers"] ) ~= nil ) then
- SettingsIni:SetValue("Server", "MaxPlayers", Request.PostParams["Server_MaxPlayers"], false )
- end
- if( tonumber( Request.PostParams["Server_Port"] ) ~= nil ) then
- SettingsIni:SetValue("Server", "Port", Request.PostParams["Server_Port"], false )
- end
- if( tonumber( Request.PostParams["Server_PortsIPv6"] ) ~= nil ) then
- SettingsIni:SetValue("Server", "PortsIPv6", Request.PostParams["Server_PortsIPv6"], false )
- end
- if( tonumber( Request.PostParams["Server_Version"] ) ~= nil ) then
- SettingsIni:SetValue("Server", "PrimaryServerVersion", Request.PostParams["Server_Version"], false )
- end
- if( tonumber( Request.PostParams["Authentication_Authenticate"] ) ~= nil ) then
- SettingsIni:SetValue("Authentication", "Authenticate", Request.PostParams["Authentication_Authenticate"], false )
- end
- if( tonumber( Request.PostParams["Limit_World"] ) ~= nil ) then
- SettingsIni:SetValue("Worlds", "LimitWorld", Request.PostParams["Limit_World"], false )
- end
- if( tonumber( Request.PostParams["LimitWorldWidth"] ) ~= nil ) then
- SettingsIni:SetValue("Worlds", "LimitWorldWidth", Request.PostParams["LimitWorldWidth"], false )
- end
-
- if( SettingsIni:WriteFile() == false ) then
- InfoMsg = [[<b style="color: red;">ERROR: Could not write to settings.ini!</b>]]
- else
- InfoMsg = [[<b style="color: green;">INFO: Successfully saved changes to settings.ini</b>]]
- end
- end
-
-
- Content = Content .. [[
- <form method="POST">
- <h4>General Settings</h4>]]
-
- if( InfoMsg ~= nil ) then
- Content = Content .. "<p>" .. InfoMsg .. "</p>"
- end
- Content = Content .. [[
- <table>
- <th colspan="2">Server</th>
- <tr><td style="width: 50%;">Description:</td>
- <td><input type="text" name="Server_Description" value="]] .. SettingsIni:GetValue("Server", "Description") .. [["></td></tr>
- <tr><td>Max Players:</td>
- <td><input type="text" name="Server_MaxPlayers" value="]] .. SettingsIni:GetValue("Server", "MaxPlayers") .. [["></td></tr>
- <tr><td>Port:</td>
- <td><input type="text" name="Server_Port" value="]] .. SettingsIni:GetValue("Server", "Port") .. [["></td></tr>
- <tr><td>PortsIPv6:</td>
- <td><input type="text" name="Server_PortsIPv6" value="]] .. SettingsIni:GetValue("Server", "PortsIPv6") .. [["></td></tr>
- <tr><td>Shown Version:</td>
- <td>]] .. HTML_Select_Version("Server_Version", SettingsIni:GetValueI("Server", "PrimaryServerVersion") ) .. [[</td></tr>
- </table><br />
-
- <table>
- <th colspan="2">Authentication</th>
- <tr><td style="width: 50%;">Authenticate:</td>
- <td>]] .. HTML_Select_On_Off("Authentication_Authenticate", SettingsIni:GetValueI("Authentication", "Authenticate") ) .. [[</td></tr>
- </table><br />
-
- <table>
- <th colspan="2">LimitWorld</th>
- <tr><td style="width: 50%;">Limit World:</td>
- <td>]] .. HTML_Select_On_Off("Limit_World", SettingsIni:GetValueI("Worlds", "LimitWorld") ) .. [[</td></tr>
- <tr><td>Max Chunks from spawn:</td>
- <td><input type="text" name="LimitWorldWidth" value="]] .. SettingsIni:GetValue("Worlds", "LimitWorldWidth") .. [["></td></tr>
- </table><br />
- <input type="submit" value="Save Settings" name="general_submit"> WARNING: Any changes made here might require a server restart in order to be applied!
- </form>]]
-
- return Content
-end
-
-
-local function ShowMonstersSettings( Request )
- local Content = ""
- local InfoMsg = nil
-
- local SettingsIni = cIniFile("settings.ini")
- if( SettingsIni:ReadFile() == false ) then
- InfoMsg = "<b style=\"color: red;\">ERROR: Could not read settings.ini!</b>"
- end
-
- if( Request.PostParams["monsters_submit"] ~= nil ) then
-
- if( tonumber( Request.PostParams["Monsters_AnimalsOn"] ) ~= nil ) then
- SettingsIni:SetValue("Monsters", "AnimalsOn", Request.PostParams["Monsters_AnimalsOn"], false )
- end
- if( tonumber( Request.PostParams["Monsters_AnimalSpawnInterval"] ) ~= nil ) then
- SettingsIni:SetValue("Monsters", "AnimalSpawnInterval", Request.PostParams["Monsters_AnimalSpawnInterval"], false )
- end
- SettingsIni:SetValue("Monsters", "Types", Request.PostParams["Monsters_Types"], false )
- if( SettingsIni:WriteFile() == false ) then
- InfoMsg = "<b style=\"color: red;\">ERROR: Could not write to settings.ini!</b>"
- else
- InfoMsg = "<b style=\"color: green;\">INFO: Successfully saved changes to settings.ini</b>"
- end
- end
-
-
- Content = Content .. "<form method=\"POST\">"
-
- Content = Content .. "<h4>Monsters Settings</h4>"
- if( InfoMsg ~= nil ) then
- Content = Content .. "<p>" .. InfoMsg .. "</p>"
- end
-
- Content = Content .. [[
- <table>
- <th colspan="2">Monsters</th>
- <tr><td style="width: 50%;">Animals On:</td>
- <td>]] .. HTML_Select_On_Off("Monsters_AnimalsOn", SettingsIni:GetValueI("Monsters", "AnimalsOn") ) .. [[</td></tr>
- <tr><td>Animal Spawn Interval:</td>
- <td><input type="text" name="Monsters_AnimalSpawnInterval" value="]] .. SettingsIni:GetValue("Monsters", "AnimalSpawnInterval") .. [["></td></tr>
- <tr><td>Monster Types:</td>
- <td><input type="text" name="Monsters_Types" value="]] .. SettingsIni:GetValue("Monsters", "Types") .. [["></td></tr>
- </table><br />
- <input type="submit" value="Save Settings" name="monsters_submit"> WARNING: Any changes made here might require a server restart in order to be applied!
- </form>]]
-
- return Content
-end
-
-local function ShowWorldsSettings( Request )
- local Content = ""
- local InfoMsg = nil
- local bSaveIni = false
-
- local SettingsIni = cIniFile("settings.ini")
- if( SettingsIni:ReadFile() == false ) then
- InfoMsg = [[<b style="color: red;">ERROR: Could not read settings.ini!</b>]]
- end
-
- if( Request.PostParams["RemoveWorld"] ~= nil ) then
- Content = Content .. Request.PostParams["RemoveWorld"]
- local WorldIdx = string.sub( Request.PostParams["RemoveWorld"], string.len("Remove ") )
- local KeyIdx = SettingsIni:FindKey("Worlds")
- local WorldName = SettingsIni:GetValue( KeyIdx, WorldIdx )
- if( SettingsIni:DeleteValueByID( KeyIdx, WorldIdx ) == true ) then
- InfoMsg = "<b style=\"color: green;\">INFO: Successfully removed world " .. WorldName .. "!</b><br />"
- bSaveIni = true
- end
- end
-
- if( Request.PostParams["AddWorld"] ~= nil ) then
- if( Request.PostParams["WorldName"] ~= nil and Request.PostParams["WorldName"] ~= "" ) then
- SettingsIni:SetValue("Worlds", "World", Request.PostParams["WorldName"], true )
- InfoMsg = "<b style=\"color: green;\">INFO: Successfully added world " .. Request.PostParams["WorldName"] .. "!</b><br />"
- bSaveIni = true
- end
- end
-
- if( Request.PostParams["worlds_submit"] ~= nil ) then
- SettingsIni:SetValue("Worlds", "DefaultWorld", Request.PostParams["Worlds_DefaultWorld"], false )
- if( Request.PostParams["Worlds_World"] ~= nil ) then
- SettingsIni:SetValue("Worlds", "World", Request.PostParams["Worlds_World"], true )
- end
- bSaveIni = true
- end
-
- if( bSaveIni == true ) then
- if( InfoMsg == nil ) then InfoMsg = "" end
- if( SettingsIni:WriteFile() == false ) then
- InfoMsg = InfoMsg .. "<b style=\"color: red;\">ERROR: Could not write to settings.ini!</b>"
- else
- InfoMsg = InfoMsg .. "<b style=\"color: green;\">INFO: Successfully saved changes to settings.ini</b>"
- end
- end
-
- Content = Content .. "<h4>Worlds Settings</h4>"
- if( InfoMsg ~= nil ) then
- Content = Content .. "<p>" .. InfoMsg .. "</p>"
- end
-
- Content = Content .. [[
- <form method="POST">
- <table>
- <th colspan="2">Worlds</th>
- <tr><td style="width: 50%;">Default World:</td>
- <td><input type="Submit" name="Worlds_DefaultWorld" value="]] .. SettingsIni:GetValue("Worlds", "DefaultWorld") .. [["></td></tr>]]
-
- local KeyIdx = SettingsIni:FindKey("Worlds")
- local NumValues = SettingsIni:GetNumValues( KeyIdx )
- for i = 0, NumValues-1 do
- local ValueName = SettingsIni:GetValueName(KeyIdx, i )
- if( ValueName == "World" ) then
- local WorldName = SettingsIni:GetValue(KeyIdx, i)
- Content = Content .. [[
- <tr><td>]] .. ValueName .. [[:</td><td><div style="width: 100px; display: inline-block;">]] .. WorldName .. [[</div><input type="submit" value="Remove ]] .. i .. [[" name="RemoveWorld"></td></tr>]]
- end
- end
-
- Content = Content .. [[
- <tr><td>Add World:</td>
- <td><input type='text' name='WorldName'><input type='submit' name='AddWorld' value='Add World'></td></tr>
- </table><br />
-
- <input type="submit" value="Save Settings" name="worlds_submit"> WARNING: Any changes made here might require a server restart in order to be applied!
- </form>]]
- return Content
-end
-
-local function SelectWorldButton( WorldName )
- return "<form method='POST'><input type='hidden' name='WorldName' value='"..WorldName.."'><input type='submit' name='SelectWorld' value='Select'></form>"
-end
-
-local function HTML_Select_Dimension( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("0", "Overworld", defaultValue == 0 )
- .. HTML_Option("-1", "Nether", defaultValue == 1 )
- .. HTML_Option("1", "The End", defaultValue == 2 )
- .. [[</select>]]
-end
-
-local function HTML_Select_Scheme( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("Default", "Default", defaultValue == "Default" )
- .. HTML_Option("Forgetful", "Forgetful", defaultValue == "Forgetful" )
- .. HTML_Option("Compact", "Compact", defaultValue == "Compact" )
- .. [[</select>]]
-end
-
-local function HTML_Select_GameMode( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("0", "Survival", defaultValue == 0 )
- .. HTML_Option("1", "Creative", defaultValue == 1 )
- .. HTML_Option("2", "Adventure", defaultValue == 2 )
- .. [[</select>]]
-end
-
-local function HTML_Select_Simulator( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("Floody", "Floody", defaultValue == 0 )
- .. HTML_Option("Noop", "Noop", defaultValue == 1 )
- .. HTML_Option("Vaporize", "Vaporize", defaultValue == 2 )
- .. [[</select>]]
-end
-
-local function HTML_Select_BiomeGen( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("MultiStepMap", "MultiStepMap", defaultValue == "MultiStepMap" )
- .. HTML_Option("DistortedVoronoi", "DistortedVoronoi", defaultValue == "DistortedVoronoi" )
- .. HTML_Option("Voronoi", "Voronoi", defaultValue == "Voronoi" )
- .. HTML_Option("CheckerBoard", "CheckerBoard", defaultValue == "CheckerBoard" )
- .. HTML_Option("Constant", "Constant", defaultValue == "Constant" )
- .. [[</select>]]
-end
-
-local function HTML_Select_HeightGen( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("Noise3D", "Noise3D", defaultValue == "Noise3D" )
- .. HTML_Option("Biomal", "Biomal", defaultValue == "Biomal" )
- .. HTML_Option("Classic", "Classic", defaultValue == "Classic" )
- .. HTML_Option("Flat", "Flat", defaultValue == "Flat" )
- .. [[</select>]]
-end
-
-local function HTML_Select_CompositionGen( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("Noise3D", "Noise3D", defaultValue == "Noise3D" )
- .. HTML_Option("Biomal", "Biomal", defaultValue == "Biomal" )
- .. HTML_Option("Classic", "Classic", defaultValue == "Classic" )
- .. HTML_Option("SameBlock", "SameBlock", defaultValue == "SameBlock" )
- .. HTML_Option("DebugBiomes", "DebugBiomes", defaultValue == "DebugBiomes" )
- .. [[</select>]]
-end
-
-local function HTML_Select_Generator( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("Composable", "Composable", defaultValue == "Composable" )
- .. [[</select>]]
-end
-
-local function HTML_Select_Biome( name, defaultValue )
- return [[<select name="]] .. name .. [[">]]
- .. HTML_Option("Ocean", "Ocean", defaultValue == "Ocean" )
- .. HTML_Option("Plains", "Plains", defaultValue == "Plains" )
- .. HTML_Option("Extreme Hills", "Extreme Hills", defaultValue == "Extreme Hills" )
- .. HTML_Option("Forest", "Forest", defaultValue == "Forest" )
- .. HTML_Option("Taiga", "Taiga", defaultValue == "Taiga" )
- .. HTML_Option("Swampland", "Swampland", defaultValue == "Swampland" )
- .. HTML_Option("River", "River", defaultValue == "River" )
- .. HTML_Option("Hell", "Hell", defaultValue == "Hell" )
- .. HTML_Option("Sky", "Sky", defaultValue == "Sky" )
- .. HTML_Option("FrozenOcean", "FrozenOcean", defaultValue == "FrozenOcean" )
- .. HTML_Option("FrozenRiver", "FrozenRiver", defaultValue == "FrozenRiver" )
- .. HTML_Option("Ice Plains", "Ice Plains", defaultValue == "Ice Plains" )
- .. HTML_Option("Ice Mountains", "Ice Mountains", defaultValue == "Ice Mountains" )
- .. HTML_Option("MushroomIsland", "MushroomIsland", defaultValue == "MushroomIsland" )
- .. HTML_Option("MushroomIslandShore", "MushroomIslandShore", defaultValue == "MushroomIslandShore" )
- .. HTML_Option("Beach", "Beach", defaultValue == "Beach" )
- .. HTML_Option("DesertHills", "DesertHills", defaultValue == "DesertHills" )
- .. HTML_Option("ForestHills", "ForestHills", defaultValue == "ForestHills" )
- .. HTML_Option("TaigaHills", "TaigaHills", defaultValue == "TaigaHills" )
- .. HTML_Option("Extreme Hills Edge", "Extreme Hills Edge", defaultValue == "Extreme Hills Edge" )
- .. HTML_Option("Jungle", "Jungle", defaultValue == "Jungle" )
- .. HTML_Option("JungleHills", "JungleHills", defaultValue == "JungleHills" )
- .. [[</select>]]
-end
-
-function ShowWorldSettings( Request )
- local Content = ""
- local InfoMsg = nil
- local SettingsIni = cIniFile("settings.ini")
- if( SettingsIni:ReadFile() == false ) then
- InfoMsg = [[<b style="color: red;">ERROR: Could not read settings.ini!</b>]]
- end
- if (Request.PostParams["SelectWorld"] ~= nil and Request.PostParams["WorldName"] ~= nil) then -- World is selected!
- WORLD = Request.PostParams["WorldName"]
- SelectedWorld = cRoot:Get():GetWorld(WORLD)
- elseif SelectedWorld == nil then
- WORLD = SettingsIni:GetValue("Worlds", "DefaultWorld")
- SelectedWorld = cRoot:Get():GetWorld( WORLD )
- end
- local WorldIni = cIniFile(SelectedWorld:GetName() .. "/world.ini")
- WorldIni:ReadFile()
- if (Request.PostParams["world_submit"]) ~= nil then
- if( tonumber( Request.PostParams["World_Dimension"] ) ~= nil ) then
- WorldIni:DeleteValue( "General", "Dimension" )
- WorldIni:SetValue( "General", "Dimension", Request.PostParams["World_Dimension"] )
- end
- if( tonumber( Request.PostParams["World_Schema"] ) ~= nil ) then
- WorldIni:DeleteValue( "General", "Schema" )
- WorldIni:SetValue( "General", "Schema", Request.PostParams["World_Schema"] )
- end
- if( tonumber( Request.PostParams["World_SpawnX"] ) ~= nil ) then
- WorldIni:DeleteValue( "SpawnPosition", "X" )
- WorldIni:SetValue( "SpawnPosition", "X", Request.PostParams["World_SpawnX"] )
- end
- if( tonumber( Request.PostParams["World_SpawnY"] ) ~= nil ) then
- WorldIni:DeleteValue( "SpawnPosition", "Y" )
- WorldIni:SetValue( "SpawnPosition", "Y", Request.PostParams["World_SpawnY"] )
- end
- if( tonumber( Request.PostParams["World_SpawnZ"] ) ~= nil ) then
- WorldIni:DeleteValue( "SpawnPosition", "Z" )
- WorldIni:SetValue( "SpawnPosition", "Z", Request.PostParams["World_SpawnZ"] )
- end
- if( tonumber( Request.PostParams["World_Seed"] ) ~= nil ) then
- WorldIni:DeleteValue( "Seed", "Seed" )
- WorldIni:SetValue( "Seed", "Seed", Request.PostParams["World_Seed"] )
- end
- if( tonumber( Request.PostParams["World_PVP"] ) ~= nil ) then
- WorldIni:DeleteValue( "PVP", "Enabled" )
- WorldIni:SetValue( "PVP", "Enabled", Request.PostParams["World_PVP"] )
- end
- if( tonumber( Request.PostParams["World_GameMode"] ) ~= nil ) then
- WorldIni:DeleteValue( "GameMode", "GameMode" )
- WorldIni:SetValue( "GameMode", "GameMode", Request.PostParams["World_GameMode"] )
- end
- if( tonumber( Request.PostParams["World_DeepSnow"] ) ~= nil ) then
- WorldIni:DeleteValue( "Physics", "DeepSnow" )
- WorldIni:SetValue( "Physics", "DeepSnow", Request.PostParams["World_DeepSnow"] )
- end
- if( tonumber( Request.PostParams["World_SandInstantFall"] ) ~= nil ) then
- WorldIni:DeleteValue( "Physics", "SandInstantFall" )
- WorldIni:SetValue( "Physics", "SandInstantFall", Request.PostParams["World_SandInstantFall"] )
- end
- if( tonumber( Request.PostParams["World_WaterSimulator"] ) ~= nil ) then
- WorldIni:DeleteValue( "Physics", "WaterSimulator" )
- WorldIni:SetValue( "Physics", "WaterSimulator", Request.PostParams["World_WaterSimulator"] )
- end
- if( tonumber( Request.PostParams["World_LavaSimulator"] ) ~= nil ) then
- WorldIni:DeleteValue( "Physics", "LavaSimulator" )
- WorldIni:SetValue( "Physics", "LavaSimulator", Request.PostParams["World_LavaSimulator"] )
- end
- if( tonumber( Request.PostParams["World_MaxSugarcaneHeight"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "MaxSugarcaneHeight" )
- WorldIni:SetValue( "Plants", "MaxSugarcaneHeight", Request.PostParams["World_MaxSugarcaneHeight"] )
- end
- if( tonumber( Request.PostParams["World_MaxCactusHeight"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "MaxCactusHeight" )
- WorldIni:SetValue( "Plants", "MaxCactusHeight", Request.PostParams["World_MaxCactusHeight"] )
- end
- if( tonumber( Request.PostParams["World_CarrotsBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsCarrotsBonemealable" )
- WorldIni:SetValue( "Plants", "IsCarrotsBonemealable", Request.PostParams["World_CarrotsBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_CropsBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsCropsBonemealable" )
- WorldIni:SetValue( "Plants", "IsCropsBonemealable", Request.PostParams["World_CropsBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_GrassBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsGrassBonemealable" )
- WorldIni:SetValue( "Plants", "IsGrassBonemealable", Request.PostParams["World_GrassBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_SaplingBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsSaplingBonemealable" )
- WorldIni:SetValue( "Plants", "IsSaplingBonemealable", Request.PostParams["World_SaplingBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_MelonStemBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsMelonStemBonemealable" )
- WorldIni:SetValue( "Plants", "IsMelonStemBonemealable", Request.PostParams["World_MelonStemBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_MelonBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsMelonBonemealable" )
- WorldIni:SetValue( "Plants", "IsMelonBonemealable", Request.PostParams["World_MelonBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_PotatoesBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsPotatoesBonemealable" )
- WorldIni:SetValue( "Plants", "IsPotatoesBonemealable", Request.PostParams["World_PotatoesBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_PumpkinStemBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsPumpkinStemBonemealable" )
- WorldIni:SetValue( "Plants", "IsPumpkinStemBonemealable", Request.PostParams["World_PumpkinStemBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_PumpkinBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsPumpkinBonemealable" )
- WorldIni:SetValue( "Plants", "IsPumpkinBonemealable", Request.PostParams["World_PumpkinBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_SugarCaneBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsSugarCaneBonemealable" )
- WorldIni:SetValue( "Plants", "IsSugarCaneBonemealable", Request.PostParams["World_SugarCaneBonemealable"] )
- end
- if( tonumber( Request.PostParams["World_CactusBonemealable"] ) ~= nil ) then
- WorldIni:DeleteValue( "Plants", "IsCactusBonemealable" )
- WorldIni:SetValue( "Plants", "IsCactusBonemealable", Request.PostParams["World_CactusBonemealable"] )
- end
- if( ( Request.PostParams["World_BiomeGen"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "BiomeGen" )
- WorldIni:SetValue( "Generator", "BiomeGen", Request.PostParams["World_BiomeGen"] )
- end
- if( ( Request.PostParams["World_Biome"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ConstantBiome" )
- WorldIni:SetValue( "Generator", "ConstantBiome", Request.PostParams["World_Biome"] )
- end
- if( ( Request.PostParams["World_MultiStepMapOceanCellSize"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MultiStepMapOceanCellSize" )
- WorldIni:SetValue( "Generator", "MultiStepMapOceanCellSize", Request.PostParams["World_MultiStepMapOceanCellSize"] )
- end
- if( ( Request.PostParams["World_MultiStepMapMushroomIslandSize"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MultiStepMapMushroomIslandSize" )
- WorldIni:SetValue( "Generator", "MultiStepMapMushroomIslandSize", Request.PostParams["World_MultiStepMapMushroomIslandSize"] )
- end
- if( ( Request.PostParams["World_MultiStepMapRiverCellSize"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MultiStepMapRiverCellSize" )
- WorldIni:SetValue( "Generator", "MultiStepMapRiverCellSize", Request.PostParams["World_MultiStepMapRiverCellSize"] )
- end
- if( ( Request.PostParams["World_MultiStepMapRiverWidth"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MultiStepMapRiverWidth" )
- WorldIni:SetValue( "Generator", "MultiStepMapRiverWidth", Request.PostParams["World_MultiStepMapRiverWidth"] )
- end
- if( ( Request.PostParams["World_MultiStepMapLandBiomeSize"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MultiStepMapLandBiomeSize" )
- WorldIni:SetValue( "Generator", "MultiStepMapLandBiomeSize", Request.PostParams["World_MultiStepMapLandBiomeSize"] )
- end
- if( ( Request.PostParams["World_DistortedVoronoiCellSize"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "DistortedVoronoiCellSize" )
- WorldIni:SetValue( "Generator", "DistortedVoronoiCellSize", Request.PostParams["World_DistortedVoronoiCellSize"] )
- end
- if( ( Request.PostParams["World_DistortedVoronoiBiomes"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "DistortedVoronoiBiomes" )
- WorldIni:SetValue( "Generator", "DistortedVoronoiBiomes", Request.PostParams["World_DistortedVoronoiBiomes"] )
- end
- if( ( Request.PostParams["World_VoronoiCellSize"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "VoronoiCellSize" )
- WorldIni:SetValue( "Generator", "VoronoiCellSize", Request.PostParams["World_VoronoiCellSize"] )
- end
- if( ( Request.PostParams["World_VoronoiBiomesdVoronoiBiomes"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "VoronoiBiomes" )
- WorldIni:SetValue( "Generator", "VoronoiBiomes", Request.PostParams["World_VoronoiBiomes"] )
- end
- if( ( Request.PostParams["World_CheckerBoardBiomes"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "CheckerBoardBiomes" )
- WorldIni:SetValue( "Generator", "CheckerBoardBiomes", Request.PostParams["World_CheckerBoardBiomes"] )
- end
- if( ( Request.PostParams["World_CheckerBoardBiomeSize"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "CheckerBoardBiomeSize" )
- WorldIni:SetValue( "Generator", "CheckerBoardBiomeSize", Request.PostParams["World_CheckerBoardBiomeSize"] )
- end
- if( ( Request.PostParams["World_HeightGen"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "HeightGen" )
- WorldIni:SetValue( "Generator", "HeightGen", Request.PostParams["World_HeightGen"] )
- end
- if( ( Request.PostParams["World_FlatHeight"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "FlatHeight" )
- WorldIni:SetValue( "Generator", "FlatHeight", Request.PostParams["World_FlatHeight"] )
- end
- if( ( Request.PostParams["World_CompositionGen"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "CompositionGen" )
- WorldIni:SetValue( "Generator", "CompositionGen", Request.PostParams["World_CompositionGen"] )
- end
- if( ( Request.PostParams["World_Noise3DSeaLevel"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Noise3DSeaLevel" )
- WorldIni:SetValue( "Generator", "Noise3DSeaLevel", Request.PostParams["World_Noise3DSeaLevel"] )
- end
- if( ( Request.PostParams["World_Noise3DHeightAmplification"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Noise3DHeightAmplification" )
- WorldIni:SetValue( "Generator", "Noise3DHeightAmplification", Request.PostParams["World_Noise3DHeightAmplification"] )
- end
- if( ( Request.PostParams["World_Noise3DMidPoint"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Noise3DMidPoint" )
- WorldIni:SetValue( "Generator", "Noise3DMidPoint", Request.PostParams["World_Noise3DMidPoint"] )
- end
- if( ( Request.PostParams["World_Noise3DFrequencyX"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Noise3DFrequencyX" )
- WorldIni:SetValue( "Generator", "Noise3DFrequencyX", Request.PostParams["World_Noise3DFrequencyX"] )
- end
- if( ( Request.PostParams["World_Noise3DFrequencyY"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Noise3DFrequencyY" )
- WorldIni:SetValue( "Generator", "Noise3DFrequencyY", Request.PostParams["World_Noise3DFrequencyY"] )
- end
- if( ( Request.PostParams["World_Noise3DFrequencyZ"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Noise3DFrequencyZ" )
- WorldIni:SetValue( "Generator", "Noise3DFrequencyZ", Request.PostParams["World_Noise3DFrequencyZ"] )
- end
- if( ( Request.PostParams["World_Noise3DAirThreshold"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Noise3DAirThreshold" )
- WorldIni:SetValue( "Generator", "Noise3DAirThreshold", Request.PostParams["World_Noise3DAirThreshold"] )
- end
- if( ( Request.PostParams["World_ClassicSeaLevel"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ClassicSeaLevel" )
- WorldIni:SetValue( "Generator", "ClassicSeaLevel", Request.PostParams["World_ClassicSeaLevel"] )
- end
- if( ( Request.PostParams["World_ClassicBeachHeight"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ClassicBeachHeight" )
- WorldIni:SetValue( "Generator", "ClassicBeachHeight", Request.PostParams["World_ClassicBeachHeight"] )
- end
- if( ( Request.PostParams["World_ClassicBeachDepth"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ClassicBeachDepth" )
- WorldIni:SetValue( "Generator", "ClassicBeachDepth", Request.PostParams["World_ClassicBeachDepth"] )
- end
- if( ( Request.PostParams["World_ClassicBlockTop"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ClassicBlockTop" )
- WorldIni:SetValue( "Generator", "ClassicBlockTop", Request.PostParams["World_ClassicBlockTop"] )
- end
- if( ( Request.PostParams["World_ClassicBlockMiddle"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ClassicBlockMiddle" )
- WorldIni:SetValue( "Generator", "ClassicBlockMiddle", Request.PostParams["World_ClassicBlockMiddle"] )
- end
- if( ( Request.PostParams["World_ClassicBlockBottom"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ClassicBlockBottom" )
- WorldIni:SetValue( "Generator", "ClassicBlockBottom", Request.PostParams["World_ClassicBlockBottom"] )
- end
- if( ( Request.PostParams["World_ClassicBlockBeach"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ClassicBlockBeach" )
- WorldIni:SetValue( "Generator", "ClassicBlockBeach", Request.PostParams["World_ClassicBlockBeach"] )
- end
- if( ( Request.PostParams["World_ClassicBlockBeachBottom"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ClassicBlockBeachBottom" )
- WorldIni:SetValue( "Generator", "ClassicBlockBeachBottom", Request.PostParams["World_ClassicBlockBeachBottom"] )
- end
- if( ( Request.PostParams["World_ClassicBlockSea"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "ClassicBlockSea" )
- WorldIni:SetValue( "Generator", "ClassicBlockSea", Request.PostParams["World_ClassicBlockSea"] )
- end
- if( ( Request.PostParams["World_SameBlockType"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "SameBlockType" )
- WorldIni:SetValue( "Generator", "SameBlockType", Request.PostParams["World_SameBlockType"] )
- end
- if( ( Request.PostParams["World_SameBlockBedrocked"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "SameBlockBedrocked" )
- WorldIni:SetValue( "Generator", "SameBlockBedrocked", Request.PostParams["World_SameBlockBedrocked"] )
- end
- if( ( Request.PostParams["World_Structures"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Structures" )
- WorldIni:SetValue( "Generator", "Structures", Request.PostParams["World_Structures"] )
- end
- if( ( Request.PostParams["World_Finishers"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Finishers" )
- WorldIni:SetValue( "Generator", "Finishers", Request.PostParams["World_Finishers"] )
- end
- if( ( Request.PostParams["World_Generator"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "Generator" )
- WorldIni:SetValue( "Generator", "Generator", Request.PostParams["World_Generator"] )
- end
- if( ( Request.PostParams["World_MineShaftsGridSize"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MineShaftsGridSize" )
- WorldIni:SetValue( "Generator", "MineShaftsGridSize", Request.PostParams["World_MineShaftsGridSize"] )
- end
- if( ( Request.PostParams["World_MineShaftsMaxSystemSize"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MineShaftsMaxSystemSize" )
- WorldIni:SetValue( "Generator", "MineShaftsMaxSystemSize", Request.PostParams["World_MineShaftsMaxSystemSize"] )
- end
- if( ( Request.PostParams["World_MineShaftsChanceCorridor"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MineShaftsChanceCorridor" )
- WorldIni:SetValue( "Generator", "MineShaftsChanceCorridor", Request.PostParams["World_MineShaftsChanceCorridor"] )
- end
- if( ( Request.PostParams["World_MineShaftsChanceCrossing"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MineShaftsChanceCrossing" )
- WorldIni:SetValue( "Generator", "MineShaftsChanceCrossing", Request.PostParams["World_MineShaftsChanceCrossing"] )
- end
- if( ( Request.PostParams["World_MineShaftsChanceStaircase"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "MineShaftsChanceStaircase" )
- WorldIni:SetValue( "Generator", "MineShaftsChanceStaircase", Request.PostParams["World_MineShaftsChanceStaircase"] )
- end
- if( ( Request.PostParams["World_LavaLakesProbability"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "LavaLakesProbability" )
- WorldIni:SetValue( "Generator", "LavaLakesProbability", Request.PostParams["World_LavaLakesProbability"] )
- end
- if( ( Request.PostParams["World_WaterLakesProbability"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "WaterLakesProbability" )
- WorldIni:SetValue( "Generator", "WaterLakesProbability", Request.PostParams["World_WaterLakesProbability"] )
- end
- if( ( Request.PostParams["World_BottomLavaLevel"] ) ~= nil ) then
- WorldIni:DeleteValue( "Generator", "BottomLavaLevel" )
- WorldIni:SetValue( "Generator", "BottomLavaLevel", Request.PostParams["World_BottomLavaLevel"] )
- end
-
- WorldIni:WriteFile()
- end
- Content = Content .. "<h4>World for operations: " .. WORLD .. "</h4>"
- Content = Content .. "<table>"
- local WorldNum = 0
- local AddWorldToTable = function(World)
- WorldNum = WorldNum + 1
- Content = Content .. "<tr>"
- Content = Content .. "<td style='width: 10px;'>" .. WorldNum .. ".</td>"
- Content = Content .. "<td>" .. World:GetName() .. "</td>"
- Content = Content .. "<td>" .. SelectWorldButton(World:GetName()) .. "</td>"
- Content = Content .. "</tr>"
- end
- cRoot:Get():ForEachWorld(AddWorldToTable)
- Content = Content .. "</table>"
-
-
- Content = Content .. [[<table>
- <form method="POST">
- <br />
- <th colspan="2">General</th>
- <tr><td>Dimension:</td>
- <td>]] .. HTML_Select_Dimension("World_Dimension", WorldIni:GetValueI("General", "Dimension") ) .. [[</td></tr>
- </table>
- <br />
- <table>
- <th colspan="2">Storage</th>
- <tr><td>Schema:</td>
- <td>]] .. HTML_Select_Scheme("World_Schema", WorldIni:GetValueI("Storage", "Schema") ) .. [[</td></tr>
- </table>
- <br />
- <table>
- <th colspan="2">Spawn Position</th>
- <tr><td>X:</td>
- <td><input type="text" name="World_SpawnX" value="]] .. WorldIni:GetValue("SpawnPosition", "X") .. [["></td></tr>
- <tr><td>Y:</td>
- <td><input type="text" name="World_SpawnY" value="]] .. WorldIni:GetValue("SpawnPosition", "Y") .. [["></td></tr>
- <tr><td>Z:</td>
- <td><input type="text" name="World_SpawnZ" value="]] .. WorldIni:GetValue("SpawnPosition", "Z") .. [["></td></tr>
- </table>
- <br />
- <table>
- <th colspan="2">Seed</th>
- <tr><td>Seed:</td>
- <td><input type="text" name="World_Seed" value="]] .. WorldIni:GetValue("Seed", "Seed") .. [["></td></tr>
- </table>
- <br />
- <table>
- <th colspan="2">PVP</th>
- <tr><td style="width: 50%;">PVP:</td>
- <td>]] .. HTML_Select_On_Off("World_PVP", WorldIni:GetValueI("PVP", "Enabled") ) .. [[</td></tr>
- </table>
- <br />
- <table>
- <th colspan="2">GameMode</th>
- <tr><td style="width: 50%;">GameMode:</td>
- <td>]] .. HTML_Select_GameMode("World_GameMode", WorldIni:GetValueI("GameMode", "GameMode") ) .. [[</td></tr>
- </table>
- <br />
- <table>
- <th colspan="2">Physics</th>
- <tr><td style="width: 50%;">DeepSnow:</td>
- <td>]] .. HTML_Select_On_Off("World_DeepSnow", WorldIni:GetValueI("Physics", "DeepSnow") ) .. [[</td></tr>
- <tr><td style="width: 50%;">SandInstantFall:</td>
- <td>]] .. HTML_Select_On_Off("World_SandInstantFall", WorldIni:GetValueI("Physics", "SandInstantFall") ) .. [[</td></tr>
- <tr><td style="width: 50%;">WaterSimulator:</td>
- <td>]] .. HTML_Select_Simulator("World_WaterSimulator", WorldIni:GetValue("Physics", "WaterSimulator") ) .. [[</td></tr>
- <tr><td style="width: 50%;">LavaSimulator:</td>
- <td>]] .. HTML_Select_Simulator("World_LavaSimulator", WorldIni:GetValue("Physics", "LavaSimulator") ) .. [[</td></tr>
- </table>
- <br />
- <table>
- <th colspan="2">Plants</th>
- <tr><td>MaxCactusHeight:</td>
- <td><input type="text" name="World_MaxCactusHeight" value="]] .. WorldIni:GetValue("Plants", "MaxCactusHeight") .. [["></td></tr>
- <tr><td>MaxSugarcaneHeigh:</td>
- <td><input type="text" name="World_MaxSugarcaneHeight" value="]] .. WorldIni:GetValue("Plants", "MaxSugarcaneHeight") .. [["></td></tr>
- <tr><td style="width: 50%;">CarrotsBonemealable:</td>
- <td>]] .. HTML_Select_On_Off("World_CarrotsBonemealable", WorldIni:GetValueI("Plants", "IsCarrotsBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">CropsBonemealable:</td>
- <td>]] .. HTML_Select_On_Off("World_CropsBonemealable", WorldIni:GetValueI("Plants", "IsCropsBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">GrassBonemealabl:</td>
- <td>]] .. HTML_Select_On_Off("World_GrassBonemealable", WorldIni:GetValueI("Plants", "IsGrassBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">SaplingBonemealable:</td>
- <td>]] .. HTML_Select_On_Off("World_SaplingBonemealable", WorldIni:GetValueI("Plants", "IsSaplingBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">MelonStemBonemealable:</td>
- <td>]] .. HTML_Select_On_Off("World_MelonStemBonemealable", WorldIni:GetValueI("Plants", "IsMelonStemBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">MelonBonemealable:</td>
- <td>]] .. HTML_Select_On_Off("World_MelonBonemealable", WorldIni:GetValueI("Plants", "IsMelonBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">PotatoesBonemealable:</td>
- <td>]] .. HTML_Select_On_Off("World_PotatoesBonemealable", WorldIni:GetValueI("Plants", "IsPotatoesBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">PumpkinStemBonemealable:</td>
- <td>]] .. HTML_Select_On_Off("World_PumpkinStemBonemealable", WorldIni:GetValueI("Plants", "IsPumpkinStemBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">PumpkinBonemealable:</td>
- <td>]] .. HTML_Select_On_Off("World_PumpkinBonemealable", WorldIni:GetValueI("Plants", "IsPumpkinBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">SugarcaneBonemealabl:</td>
- <td>]] .. HTML_Select_On_Off("World_SugarcaneBonemealable", WorldIni:GetValueI("Plants", "IsSugarcaneBonemealable") ) .. [[</td></tr>
- <tr><td style="width: 50%;">CactusBonemealable:</td>
- <td>]] .. HTML_Select_On_Off("World_CactusBonemealable", WorldIni:GetValueI("Plants", "IsCactusBonemealable") ) .. [[</td></tr>
- </table>
- <br />
- <table>
- <th colspan="2">Generator</th>
- <tr><td style="width: 50%;">BiomeGen:</td>
- <td>]] .. HTML_Select_BiomeGen("World_BiomeGen", WorldIni:GetValue("Generator", "BiomeGen") ) .. [[</td></tr>
- <tr><td style="width: 50%;">HeightGen:</td>
- <td>]] .. HTML_Select_HeightGen("World_HeightGen", WorldIni:GetValue("Generator", "HeightGen") ) .. [[</td></tr>
- <tr><td style="width: 50%;">CompositionGen:</td>
- <td>]] .. HTML_Select_CompositionGen("World_CompositionGen", WorldIni:GetValue("Generator", "CompositionGen") ) .. [[</td></tr>
- <tr><td>Structures:</td>
- <td><input type="text" size="50" name="World_Structures" value="]] .. WorldIni:GetValue("Generator", "Structures") .. [["></td></tr>
- <tr><td>Finishers:</td>
- <td><input type="text" size="50" name="World_Finishers" value="]] .. WorldIni:GetValue("Generator", "Finishers") .. [["></td></tr>
- <tr><td style="width: 50%;">Generator:</td>
- <td>]] .. HTML_Select_Generator("World_Generator", WorldIni:GetValue("Generator", "Generator") ) .. [[</td></tr>
-
- </table>
- <br />
- <table>
- <th colspan="1">Finetuning</th><br />
- </table>
- <table>
- ]]
- if WorldIni:GetValue( "Generator", "BiomeGen" ) == "Constant" then
- Content = Content .. [[
- <th colspan="2">Biome Generator</th>
- <tr><td style="width: 50%;">ConstantBiome:</td>
- <td>]] .. HTML_Select_Biome( "World_Biome", WorldIni:GetValue("Generator", "ConstantBiome" ) ) .. [[</td></tr>]]
- elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "MultiStepMap" then
- Content = Content .. [[
- <th colspan="2">Biome Generator</th>
- <tr><td>MultiStepMapOceanCellSize:</td>
- <td><input type="text" name="World_MultiStepMapOceanCellSize" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapOceanCellSize") .. [["></td></tr>
- <tr><td>MultiStepMapOceanCellSize:</td>
- <td><input type="text" name="World_MultiStepMapMushroomIslandSize" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapMushroomIslandSize") .. [["></td></tr>
- <tr><td>MultiStepMapOceanCellSize:</td>
- <td><input type="text" name="World_MultiStepMapRiverCellSize" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapRiverCellSize") .. [["></td></tr>
- <tr><td>MultiStepMapOceanCellSize:</td>
- <td><input type="text" name="World_MultiStepMapRiverWidth" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapRiverWidth") .. [["></td></tr>
- <tr><td>MultiStepMapOceanCellSize:</td>
- <td><input type="text" name="World_MultiStepMapLandBiomeSize" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapLandBiomeSize") .. [["></td></tr>]]
- elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "DistortedVoronoi" then
- Content = Content .. [[
- <th colspan="2">Biome Generator</th>
- <tr><td>DistortedVoronoiCellSize:</td>
- <td><input type="text" name="World_DistortedVoronoiCellSize" value="]] .. WorldIni:GetValue("Generator", "DistortedVoronoiCellSize") .. [["></td></tr>
- <tr><td>DistortedVoronoiBiomes:</td>
- <td><input type="text" name="World_DistortedVoronoiBiomes" value="]] .. WorldIni:GetValue("Generator", "DistortedVoronoiBiomes") .. [["></td></tr>]]
- elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "Voronoi" then
- Content = Content .. [[
- <th colspan="2">Biome Generator</th>
- <tr><td>VoronoiCellSize:</td>
- <td><input type="text" name="World_VoronoiCellSize" value="]] .. WorldIni:GetValue("Generator", "VoronoiCellSize") .. [["></td></tr>
- <tr><td>VoronoiBiomes:</td>
- <td><input type="text" name="World_VoronoiBiomes" value="]] .. WorldIni:GetValue("Generator", "VoronoiBiomes") .. [["></td></tr>]]
- elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "CheckerBoard" then
- Content = Content .. [[
- <th colspan="2">Biome Generator</th>
- <tr><td>CheckerBoardBiomes:</td>
- <td><input type="text" name="World_CheckerBoardBiomes" value="]] .. WorldIni:GetValue("Generator", "CheckerBoardBiomes") .. [["></td></tr>
- <tr><td>CheckerBoardBiomeSize:</td>
- <td><input type="text" name="World_CheckerBoardBiomeSize" value="]] .. WorldIni:GetValue("Generator", "CheckerBoardBiomeSize") .. [["></td></tr>]]
- end
-
- if WorldIni:GetValue( "Generator", "CompositionGen" ) == "Noise3D" then
- Content = Content .. [[
- <th colspan="2">Composition Generator</th>
- <tr><td>Noise3DSeaLevel:</td>
- <td><input type="text" name="World_Noise3DSeaLevel" value="]] .. WorldIni:GetValue("Generator", "Noise3DSeaLevel") .. [["></td></tr>
- <tr><td>Noise3DHeightAmplification:</td>
- <td><input type="text" name="World_Noise3DHeightAmplification" value="]] .. WorldIni:GetValue("Generator", "Noise3DHeightAmplification") .. [["></td></tr>
- <tr><td>Noise3DMidPoint:</td>
- <td><input type="text" name="World_Noise3DMidPoint" value="]] .. WorldIni:GetValue("Generator", "Noise3DMidPoint") .. [["></td></tr>
- <tr><td>Noise3DFrequencyX:</td>
- <td><input type="text" name="World_Noise3DFrequencyX" value="]] .. WorldIni:GetValue("Generator", "Noise3DFrequencyX") .. [["></td></tr>
- <tr><td>Noise3DFrequencyY:</td>
- <td><input type="text" name="World_Noise3DFrequencyY" value="]] .. WorldIni:GetValue("Generator", "Noise3DFrequencyY") .. [["></td></tr>
- <tr><td>Noise3DFrequencyZ:</td>
- <td><input type="text" name="World_Noise3DFrequencyZ" value="]] .. WorldIni:GetValue("Generator", "Noise3DFrequencyZ") .. [["></td></tr>
- <tr><td>Noise3DAirThreshold:</td>
- <td><input type="text" name="World_Noise3DAirThreshold" value="]] .. WorldIni:GetValue("Generator", "Noise3DAirThreshold") .. [["></td></tr>]]
- elseif WorldIni:GetValue( "Generator", "CompositionGen" ) == "Classic" then
- Content = Content .. [[
- <th colspan="2">Composition Generator</th>
- <tr><td>ClassicSeaLevel:</td>
- <td><input type="text" name="World_ClassicSeaLevel" value="]] .. WorldIni:GetValue("Generator", "ClassicSeaLevel") .. [["></td></tr>
- <tr><td>ClassicBeachHeight:</td>
- <td><input type="text" name="World_ClassicBeachHeight" value="]] .. WorldIni:GetValue("Generator", "ClassicBeachHeight") .. [["></td></tr>
- <tr><td>ClassicBeachDepth:</td>
- <td><input type="text" name="World_ClassicBeachDepth" value="]] .. WorldIni:GetValue("Generator", "ClassicBeachDepth") .. [["></td></tr>
- <tr><td>ClassicBlockTop:</td>
- <td><input type="text" name="World_ClassicBlockTop" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockTop") .. [["></td></tr>
- <tr><td>ClassicBlockMiddle:</td>
- <td><input type="text" name="World_ClassicBlockMiddle" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockMiddle") .. [["></td></tr>
- <tr><td>ClassicBlockBottom:</td>
- <td><input type="text" name="World_ClassicBlockBottom" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockBottom") .. [["></td></tr>
- <tr><td>ClassicBlockBeach:</td>
- <td><input type="text" name="World_ClassicBlockBeach" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockBeach") .. [["></td></tr>
- <tr><td>ClassicBlockBeachBottom:</td>
- <td><input type="text" name="World_ClassicBlockBeachBottom" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockBeachBottom") .. [["></td></tr>
- <tr><td>ClassicBlockSea:</td>
- <td><input type="text" name="World_ClassicBlockSea" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockSea") .. [["></td></tr>]]
- elseif WorldIni:GetValue( "Generator", "CompositionGen" ) == "SameBlock" then
- Content = Content .. [[
- <th colspan="2">Composition Generator</th>
- <tr><td>SameBlockType:</td>
- <td><input type="text" name="World_SameBlockType" value="]] .. WorldIni:GetValue("Generator", "SameBlockType") .. [["></td></tr>
- <tr><td>SameBlockBedrocked:</td>
- <td><input type="text" name="World_SameBlockBedrocked" value="]] .. WorldIni:GetValue("Generator", "SameBlockBedrocked") .. [["></td></tr>]]
- end
- if WorldIni:GetValue( "Generator", "HeightGen" ) == "Flat" then
- Content = Content .. [[
- <th colspan="2">Height Generator</th>
- <tr><td>FlatHeight:</td>
- <td><input type="text" name="World_FlatHeight" value="]] .. WorldIni:GetValue("Generator", "FlatHeight") .. [["></td></tr>]]
- end
- if string.find( WorldIni:GetValue( "Generator", "Structures" ), "MineShafts" ) ~= nil then
- Content = Content .. [[
- <th colspan="2">MineShafts</th>
- <tr><td>MineShaftsGridSize:</td>
- <td><input type="text" name="World_MineShaftsGridSize" value="]] .. WorldIni:GetValue("Generator", "MineShaftsGridSize") .. [["></td></tr>
- <tr><td>MineShaftsMaxSystemSize:</td>
- <td><input type="text" name="World_MineShaftsMaxSystemSize" value="]] .. WorldIni:GetValue("Generator", "MineShaftsMaxSystemSize") .. [["></td></tr>
- <tr><td>MineShaftsChanceCorridor:</td>
- <td><input type="text" name="World_MineShaftsChanceCorridor" value="]] .. WorldIni:GetValue("Generator", "MineShaftsChanceCorridor") .. [["></td></tr>
- <tr><td>MineShaftsChanceCrossing:</td>
- <td><input type="text" name="World_MineShaftsChanceCrossing" value="]] .. WorldIni:GetValue("Generator", "MineShaftsChanceCrossing") .. [["></td></tr>
- <tr><td>MineShaftsChanceStaircase:</td>
- <td><input type="text" name="World_MineShaftsChanceStaircase" value="]] .. WorldIni:GetValue("Generator", "MineShaftsChanceStaircase") .. [["></td></tr>]]
- end
- if string.find( WorldIni:GetValue( "Generator", "Structures" ), "LavaLakes" ) ~= nil then
- Content = Content .. [[
- <th colspan="2">LavaLakes</th>
- <tr><td>LavaLakesProbability:</td>
- <td><input type="text" name="World_LavaLakesProbability" value="]] .. WorldIni:GetValue("Generator", "LavaLakesProbability") .. [["></td></tr>]]
- end
- if string.find( WorldIni:GetValue( "Generator", "Structures" ), "WaterLakes" ) ~= nil then
- Content = Content .. [[
- <th colspan="2">WaterLakes</th>
- <tr><td>WaterLakesProbability:</td>
- <td><input type="text" name="World_WaterLakesProbability" value="]] .. WorldIni:GetValue("Generator", "WaterLakesProbability") .. [["></td></tr>]]
- end
- if string.find( WorldIni:GetValue( "Generator", "Finishers" ), "BottomLava" ) ~= nil then
- Content = Content .. [[
- <th colspan="2">BottomLavaLevel</th>
- <tr><td>BottomLavaLevel:</td>
- <td><input type="text" name="World_BottomLavaLevel" value="]] .. WorldIni:GetValue("Generator", "BottomLavaLevel") .. [["></td></tr>]]
- end
- Content = Content .. [[</table>]]
-
- Content = Content .. [[ <br />
- <input type="submit" value="Save Settings" name="world_submit"> </form>WARNING: Any changes made here might require a server restart in order to be applied!
- </form>]]
- return Content
-end
-
-
-
-function HandleRequest_ServerSettings( Request )
- local Content = ""
-
- Content = Content .. [[
- <p><b>Server Settings</b></p>
- <table>
- <tr>
- <td><a href="?tab=General">General</a></td>
- <td><a href="?tab=Monsters">Monsters</a></td>
- <td><a href="?tab=Worlds">Worlds</a></td>
- <td><a href="?tab=World">World</a></td>
- </tr>
- </table>
- <br />]]
-
- if( Request.Params["tab"] == "Monsters" ) then
- Content = Content .. ShowMonstersSettings( Request )
- elseif( Request.Params["tab"] == "Worlds" ) then
- Content = Content .. ShowWorldsSettings( Request )
- elseif( Request.Params["tab"] == "World" ) then
- Content = Content .. ShowWorldSettings( Request )
- else
- Content = Content .. ShowGeneralSettings( Request ) -- Default to general settings
- end
-
- return Content
+-- Some HTML helper functions
+local function HTML_Option( value, text, selected )
+ if( selected == true ) then
+ return [[<option value="]] .. value .. [[" selected>]] .. text .. [[</option>]]
+ else
+ return [[<option value="]] .. value .. [[">]] .. text .. [[</option>"]]
+ end
+end
+
+local function HTML_Select_On_Off( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("1", "On", defaultValue == 1 )
+ .. HTML_Option("0", "Off", defaultValue == 0 )
+ .. [[</select>]]
+end
+
+local function HTML_Select_Version( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("0", "Latest Version", defaultValue == 0 )
+ .. HTML_Option("61", "1.5.2", defaultValue == 1 )
+ .. HTML_Option("60", "1.5.0", defaultValue == 2 )
+ .. HTML_Option("49", "1.4.5", defaultValue == 3 )
+ .. HTML_Option("47", "1.4.2", defaultValue == 4 )
+ .. HTML_Option("39", "1.3.2", defaultValue == 5 )
+ .. HTML_Option("29", "1.2.5", defaultValue == 6 )
+ .. [[</select>]]
+end
+
+
+local function ShowGeneralSettings( Request )
+ local Content = ""
+ local InfoMsg = nil
+
+ local SettingsIni = cIniFile("settings.ini")
+ if( SettingsIni:ReadFile() == false ) then
+ InfoMsg = "<b style=\"color: red;\">ERROR: Could not read settings.ini!</b>"
+ end
+
+ if( Request.PostParams["general_submit"] ~= nil ) then
+
+ SettingsIni:SetValue("Server", "Description",Request.PostParams["Server_Description"],false )
+ if( tonumber( Request.PostParams["Server_MaxPlayers"] ) ~= nil ) then
+ SettingsIni:SetValue("Server", "MaxPlayers", Request.PostParams["Server_MaxPlayers"], false )
+ end
+ if( tonumber( Request.PostParams["Server_Port"] ) ~= nil ) then
+ if( tonumber( Request.PostParams["Server_Port"] ) > 0 ) then
+ SettingsIni:SetValue("Server", "Port", Request.PostParams["Server_Port"], false )
+ end
+ end
+ if( tonumber( Request.PostParams["Server_PortsIPv6"] ) ~= nil ) then
+ SettingsIni:SetValue("Server", "PortsIPv6", Request.PostParams["Server_PortsIPv6"], false )
+ end
+ if( tonumber( Request.PostParams["Server_Version"] ) ~= nil ) then
+ SettingsIni:SetValue("Server", "PrimaryServerVersion", Request.PostParams["Server_Version"], false )
+ end
+ if( tonumber( Request.PostParams["Authentication_Authenticate"] ) ~= nil ) then
+ SettingsIni:SetValue("Authentication", "Authenticate", Request.PostParams["Authentication_Authenticate"], false )
+ end
+ if( tonumber( Request.PostParams["Limit_World"] ) ~= nil ) then
+ SettingsIni:SetValue("Worlds", "LimitWorld", Request.PostParams["Limit_World"], false )
+ end
+ if( tonumber( Request.PostParams["LimitWorldWidth"] ) ~= nil ) then
+ SettingsIni:SetValue("Worlds", "LimitWorldWidth", Request.PostParams["LimitWorldWidth"], false )
+ end
+
+ if( SettingsIni:WriteFile() == false ) then
+ InfoMsg = [[<b style="color: red;">ERROR: Could not write to settings.ini!</b>]]
+ else
+ InfoMsg = [[<b style="color: green;">INFO: Successfully saved changes to settings.ini</b>]]
+ end
+ end
+
+
+ Content = Content .. [[
+ <form method="POST">
+ <h4>General Settings</h4>]]
+
+ if( InfoMsg ~= nil ) then
+ Content = Content .. "<p>" .. InfoMsg .. "</p>"
+ end
+ Content = Content .. [[
+ <table>
+ <th colspan="2">Server</th>
+ <tr><td style="width: 50%;">Description:</td>
+ <td><input type="text" name="Server_Description" value="]] .. SettingsIni:GetValue("Server", "Description") .. [["></td></tr>
+ <tr><td>Max Players:</td>
+ <td><input type="text" name="Server_MaxPlayers" value="]] .. SettingsIni:GetValue("Server", "MaxPlayers") .. [["></td></tr>
+ <tr><td>Port:</td>
+ <td><input type="text" name="Server_Port" value="]] .. SettingsIni:GetValue("Server", "Port") .. [["></td></tr>
+ <tr><td>PortsIPv6:</td>
+ <td><input type="text" name="Server_PortsIPv6" value="]] .. SettingsIni:GetValue("Server", "PortsIPv6") .. [["></td></tr>
+ <tr><td>Shown Version:</td>
+ <td>]] .. HTML_Select_Version("Server_Version", SettingsIni:GetValueI("Server", "PrimaryServerVersion") ) .. [[</td></tr>
+ </table><br />
+
+ <table>
+ <th colspan="2">Authentication</th>
+ <tr><td style="width: 50%;">Authenticate:</td>
+ <td>]] .. HTML_Select_On_Off("Authentication_Authenticate", SettingsIni:GetValueI("Authentication", "Authenticate") ) .. [[</td></tr>
+ </table><br />
+
+ <table>
+ <th colspan="2">LimitWorld</th>
+ <tr><td style="width: 50%;">Limit World:</td>
+ <td>]] .. HTML_Select_On_Off("Limit_World", SettingsIni:GetValueI("Worlds", "LimitWorld") ) .. [[</td></tr>
+ <tr><td>Max Chunks from spawn:</td>
+ <td><input type="text" name="LimitWorldWidth" value="]] .. SettingsIni:GetValue("Worlds", "LimitWorldWidth") .. [["></td></tr>
+ </table><br />
+ <input type="submit" value="Save Settings" name="general_submit"> WARNING: Any changes made here might require a server restart in order to be applied!
+ </form>]]
+
+ return Content
+end
+
+
+local function ShowMonstersSettings( Request )
+ local Content = ""
+ local InfoMsg = nil
+
+ local SettingsIni = cIniFile("settings.ini")
+ if( SettingsIni:ReadFile() == false ) then
+ InfoMsg = "<b style=\"color: red;\">ERROR: Could not read settings.ini!</b>"
+ end
+
+ if( Request.PostParams["monsters_submit"] ~= nil ) then
+
+ if( tonumber( Request.PostParams["Monsters_AnimalsOn"] ) ~= nil ) then
+ SettingsIni:SetValue("Monsters", "AnimalsOn", Request.PostParams["Monsters_AnimalsOn"], false )
+ end
+ if( tonumber( Request.PostParams["Monsters_AnimalSpawnInterval"] ) ~= nil ) then
+ SettingsIni:SetValue("Monsters", "AnimalSpawnInterval", Request.PostParams["Monsters_AnimalSpawnInterval"], false )
+ end
+ SettingsIni:SetValue("Monsters", "Types", Request.PostParams["Monsters_Types"], false )
+ if( SettingsIni:WriteFile() == false ) then
+ InfoMsg = "<b style=\"color: red;\">ERROR: Could not write to settings.ini!</b>"
+ else
+ InfoMsg = "<b style=\"color: green;\">INFO: Successfully saved changes to settings.ini</b>"
+ end
+ end
+
+
+ Content = Content .. "<form method=\"POST\">"
+
+ Content = Content .. "<h4>Monsters Settings</h4>"
+ if( InfoMsg ~= nil ) then
+ Content = Content .. "<p>" .. InfoMsg .. "</p>"
+ end
+
+ Content = Content .. [[
+ <table>
+ <th colspan="2">Monsters</th>
+ <tr><td style="width: 50%;">Animals On:</td>
+ <td>]] .. HTML_Select_On_Off("Monsters_AnimalsOn", SettingsIni:GetValueI("Monsters", "AnimalsOn") ) .. [[</td></tr>
+ <tr><td>Animal Spawn Interval:</td>
+ <td><input type="text" name="Monsters_AnimalSpawnInterval" value="]] .. SettingsIni:GetValue("Monsters", "AnimalSpawnInterval") .. [["></td></tr>
+ <tr><td>Monster Types:</td>
+ <td><input type="text" name="Monsters_Types" value="]] .. SettingsIni:GetValue("Monsters", "Types") .. [["></td></tr>
+ </table><br />
+ <input type="submit" value="Save Settings" name="monsters_submit"> WARNING: Any changes made here might require a server restart in order to be applied!
+ </form>]]
+
+ return Content
+end
+
+local function ShowWorldsSettings( Request )
+ local Content = ""
+ local InfoMsg = nil
+ local bSaveIni = false
+
+ local SettingsIni = cIniFile("settings.ini")
+ if( SettingsIni:ReadFile() == false ) then
+ InfoMsg = [[<b style="color: red;">ERROR: Could not read settings.ini!</b>]]
+ end
+
+ if( Request.PostParams["RemoveWorld"] ~= nil ) then
+ Content = Content .. Request.PostParams["RemoveWorld"]
+ local WorldIdx = string.sub( Request.PostParams["RemoveWorld"], string.len("Remove ") )
+ local KeyIdx = SettingsIni:FindKey("Worlds")
+ local WorldName = SettingsIni:GetValue( KeyIdx, WorldIdx )
+ if( SettingsIni:DeleteValueByID( KeyIdx, WorldIdx ) == true ) then
+ InfoMsg = "<b style=\"color: green;\">INFO: Successfully removed world " .. WorldName .. "!</b><br />"
+ bSaveIni = true
+ end
+ end
+
+ if( Request.PostParams["AddWorld"] ~= nil ) then
+ if( Request.PostParams["WorldName"] ~= nil and Request.PostParams["WorldName"] ~= "" ) then
+ SettingsIni:SetValue("Worlds", "World", Request.PostParams["WorldName"], true )
+ InfoMsg = "<b style=\"color: green;\">INFO: Successfully added world " .. Request.PostParams["WorldName"] .. "!</b><br />"
+ bSaveIni = true
+ end
+ end
+
+ if( Request.PostParams["worlds_submit"] ~= nil ) then
+ SettingsIni:SetValue("Worlds", "DefaultWorld", Request.PostParams["Worlds_DefaultWorld"], false )
+ if( Request.PostParams["Worlds_World"] ~= nil ) then
+ SettingsIni:SetValue("Worlds", "World", Request.PostParams["Worlds_World"], true )
+ end
+ bSaveIni = true
+ end
+
+ if( bSaveIni == true ) then
+ if( InfoMsg == nil ) then InfoMsg = "" end
+ if( SettingsIni:WriteFile() == false ) then
+ InfoMsg = InfoMsg .. "<b style=\"color: red;\">ERROR: Could not write to settings.ini!</b>"
+ else
+ InfoMsg = InfoMsg .. "<b style=\"color: green;\">INFO: Successfully saved changes to settings.ini</b>"
+ end
+ end
+
+ Content = Content .. "<h4>Worlds Settings</h4>"
+ if( InfoMsg ~= nil ) then
+ Content = Content .. "<p>" .. InfoMsg .. "</p>"
+ end
+
+ Content = Content .. [[
+ <form method="POST">
+ <table>
+ <th colspan="2">Worlds</th>
+ <tr><td style="width: 50%;">Default World:</td>
+ <td><input type="Submit" name="Worlds_DefaultWorld" value="]] .. SettingsIni:GetValue("Worlds", "DefaultWorld") .. [["></td></tr>]]
+
+ local KeyIdx = SettingsIni:FindKey("Worlds")
+ local NumValues = SettingsIni:GetNumValues( KeyIdx )
+ for i = 0, NumValues-1 do
+ local ValueName = SettingsIni:GetValueName(KeyIdx, i )
+ if( ValueName == "World" ) then
+ local WorldName = SettingsIni:GetValue(KeyIdx, i)
+ Content = Content .. [[
+ <tr><td>]] .. ValueName .. [[:</td><td><div style="width: 100px; display: inline-block;">]] .. WorldName .. [[</div><input type="submit" value="Remove ]] .. i .. [[" name="RemoveWorld"></td></tr>]]
+ end
+ end
+
+ Content = Content .. [[
+ <tr><td>Add World:</td>
+ <td><input type='text' name='WorldName'><input type='submit' name='AddWorld' value='Add World'></td></tr>
+ </table><br />
+
+ <input type="submit" value="Save Settings" name="worlds_submit"> WARNING: Any changes made here might require a server restart in order to be applied!
+ </form>]]
+ return Content
+end
+
+local function SelectWorldButton( WorldName )
+ return "<form method='POST'><input type='hidden' name='WorldName' value='"..WorldName.."'><input type='submit' name='SelectWorld' value='Select'></form>"
+end
+
+local function HTML_Select_Dimension( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("0", "Overworld", defaultValue == 0 )
+ .. HTML_Option("-1", "Nether", defaultValue == 1 )
+ .. HTML_Option("1", "The End", defaultValue == 2 )
+ .. [[</select>]]
+end
+
+local function HTML_Select_Scheme( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("Default", "Default", defaultValue == "Default" )
+ .. HTML_Option("Forgetful", "Forgetful", defaultValue == "Forgetful" )
+ .. HTML_Option("Compact", "Compact", defaultValue == "Compact" )
+ .. [[</select>]]
+end
+
+local function HTML_Select_GameMode( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("0", "Survival", defaultValue == 0 )
+ .. HTML_Option("1", "Creative", defaultValue == 1 )
+ .. HTML_Option("2", "Adventure", defaultValue == 2 )
+ .. [[</select>]]
+end
+
+local function HTML_Select_Simulator( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("Floody", "Floody", defaultValue == 0 )
+ .. HTML_Option("Noop", "Noop", defaultValue == 1 )
+ .. HTML_Option("Vaporize", "Vaporize", defaultValue == 2 )
+ .. [[</select>]]
+end
+
+local function HTML_Select_BiomeGen( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("MultiStepMap", "MultiStepMap", defaultValue == "MultiStepMap" )
+ .. HTML_Option("DistortedVoronoi", "DistortedVoronoi", defaultValue == "DistortedVoronoi" )
+ .. HTML_Option("Voronoi", "Voronoi", defaultValue == "Voronoi" )
+ .. HTML_Option("CheckerBoard", "CheckerBoard", defaultValue == "CheckerBoard" )
+ .. HTML_Option("Constant", "Constant", defaultValue == "Constant" )
+ .. [[</select>]]
+end
+
+local function HTML_Select_HeightGen( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("Noise3D", "Noise3D", defaultValue == "Noise3D" )
+ .. HTML_Option("Biomal", "Biomal", defaultValue == "Biomal" )
+ .. HTML_Option("Classic", "Classic", defaultValue == "Classic" )
+ .. HTML_Option("Flat", "Flat", defaultValue == "Flat" )
+ .. [[</select>]]
+end
+
+local function HTML_Select_CompositionGen( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("Noise3D", "Noise3D", defaultValue == "Noise3D" )
+ .. HTML_Option("Biomal", "Biomal", defaultValue == "Biomal" )
+ .. HTML_Option("Classic", "Classic", defaultValue == "Classic" )
+ .. HTML_Option("SameBlock", "SameBlock", defaultValue == "SameBlock" )
+ .. HTML_Option("DebugBiomes", "DebugBiomes", defaultValue == "DebugBiomes" )
+ .. [[</select>]]
+end
+
+local function HTML_Select_Generator( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("Composable", "Composable", defaultValue == "Composable" )
+ .. [[</select>]]
+end
+
+local function HTML_Select_Biome( name, defaultValue )
+ return [[<select name="]] .. name .. [[">]]
+ .. HTML_Option("Ocean", "Ocean", defaultValue == "Ocean" )
+ .. HTML_Option("Plains", "Plains", defaultValue == "Plains" )
+ .. HTML_Option("Extreme Hills", "Extreme Hills", defaultValue == "Extreme Hills" )
+ .. HTML_Option("Forest", "Forest", defaultValue == "Forest" )
+ .. HTML_Option("Taiga", "Taiga", defaultValue == "Taiga" )
+ .. HTML_Option("Swampland", "Swampland", defaultValue == "Swampland" )
+ .. HTML_Option("River", "River", defaultValue == "River" )
+ .. HTML_Option("Hell", "Hell", defaultValue == "Hell" )
+ .. HTML_Option("Sky", "Sky", defaultValue == "Sky" )
+ .. HTML_Option("FrozenOcean", "FrozenOcean", defaultValue == "FrozenOcean" )
+ .. HTML_Option("FrozenRiver", "FrozenRiver", defaultValue == "FrozenRiver" )
+ .. HTML_Option("Ice Plains", "Ice Plains", defaultValue == "Ice Plains" )
+ .. HTML_Option("Ice Mountains", "Ice Mountains", defaultValue == "Ice Mountains" )
+ .. HTML_Option("MushroomIsland", "MushroomIsland", defaultValue == "MushroomIsland" )
+ .. HTML_Option("MushroomIslandShore", "MushroomIslandShore", defaultValue == "MushroomIslandShore" )
+ .. HTML_Option("Beach", "Beach", defaultValue == "Beach" )
+ .. HTML_Option("DesertHills", "DesertHills", defaultValue == "DesertHills" )
+ .. HTML_Option("ForestHills", "ForestHills", defaultValue == "ForestHills" )
+ .. HTML_Option("TaigaHills", "TaigaHills", defaultValue == "TaigaHills" )
+ .. HTML_Option("Extreme Hills Edge", "Extreme Hills Edge", defaultValue == "Extreme Hills Edge" )
+ .. HTML_Option("Jungle", "Jungle", defaultValue == "Jungle" )
+ .. HTML_Option("JungleHills", "JungleHills", defaultValue == "JungleHills" )
+ .. [[</select>]]
+end
+
+function ShowWorldSettings( Request )
+ local Content = ""
+ local InfoMsg = nil
+ local SettingsIni = cIniFile("settings.ini")
+ if( SettingsIni:ReadFile() == false ) then
+ InfoMsg = [[<b style="color: red;">ERROR: Could not read settings.ini!</b>]]
+ end
+ if (Request.PostParams["SelectWorld"] ~= nil and Request.PostParams["WorldName"] ~= nil) then -- World is selected!
+ WORLD = Request.PostParams["WorldName"]
+ SelectedWorld = cRoot:Get():GetWorld(WORLD)
+ elseif SelectedWorld == nil then
+ WORLD = SettingsIni:GetValue("Worlds", "DefaultWorld")
+ SelectedWorld = cRoot:Get():GetWorld( WORLD )
+ end
+ local WorldIni = cIniFile(SelectedWorld:GetName() .. "/world.ini")
+ WorldIni:ReadFile()
+ if (Request.PostParams["world_submit"]) ~= nil then
+ if( tonumber( Request.PostParams["World_Dimension"] ) ~= nil ) then
+ WorldIni:DeleteValue( "General", "Dimension" )
+ WorldIni:SetValue( "General", "Dimension", Request.PostParams["World_Dimension"] )
+ end
+ if( tonumber( Request.PostParams["World_Schema"] ) ~= nil ) then
+ WorldIni:DeleteValue( "General", "Schema" )
+ WorldIni:SetValue( "General", "Schema", Request.PostParams["World_Schema"] )
+ end
+ if( tonumber( Request.PostParams["World_SpawnX"] ) ~= nil ) then
+ WorldIni:DeleteValue( "SpawnPosition", "X" )
+ WorldIni:SetValue( "SpawnPosition", "X", Request.PostParams["World_SpawnX"] )
+ end
+ if( tonumber( Request.PostParams["World_SpawnY"] ) ~= nil ) then
+ WorldIni:DeleteValue( "SpawnPosition", "Y" )
+ WorldIni:SetValue( "SpawnPosition", "Y", Request.PostParams["World_SpawnY"] )
+ end
+ if( tonumber( Request.PostParams["World_SpawnZ"] ) ~= nil ) then
+ WorldIni:DeleteValue( "SpawnPosition", "Z" )
+ WorldIni:SetValue( "SpawnPosition", "Z", Request.PostParams["World_SpawnZ"] )
+ end
+ if( tonumber( Request.PostParams["World_Seed"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Seed", "Seed" )
+ WorldIni:SetValue( "Seed", "Seed", Request.PostParams["World_Seed"] )
+ end
+ if( tonumber( Request.PostParams["World_PVP"] ) ~= nil ) then
+ WorldIni:DeleteValue( "PVP", "Enabled" )
+ WorldIni:SetValue( "PVP", "Enabled", Request.PostParams["World_PVP"] )
+ end
+ if( tonumber( Request.PostParams["World_GameMode"] ) ~= nil ) then
+ WorldIni:DeleteValue( "GameMode", "GameMode" )
+ WorldIni:SetValue( "GameMode", "GameMode", Request.PostParams["World_GameMode"] )
+ end
+ if( tonumber( Request.PostParams["World_DeepSnow"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Physics", "DeepSnow" )
+ WorldIni:SetValue( "Physics", "DeepSnow", Request.PostParams["World_DeepSnow"] )
+ end
+ if( tonumber( Request.PostParams["World_SandInstantFall"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Physics", "SandInstantFall" )
+ WorldIni:SetValue( "Physics", "SandInstantFall", Request.PostParams["World_SandInstantFall"] )
+ end
+ if( tonumber( Request.PostParams["World_WaterSimulator"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Physics", "WaterSimulator" )
+ WorldIni:SetValue( "Physics", "WaterSimulator", Request.PostParams["World_WaterSimulator"] )
+ end
+ if( tonumber( Request.PostParams["World_LavaSimulator"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Physics", "LavaSimulator" )
+ WorldIni:SetValue( "Physics", "LavaSimulator", Request.PostParams["World_LavaSimulator"] )
+ end
+ if( tonumber( Request.PostParams["World_MaxSugarcaneHeight"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "MaxSugarcaneHeight" )
+ WorldIni:SetValue( "Plants", "MaxSugarcaneHeight", Request.PostParams["World_MaxSugarcaneHeight"] )
+ end
+ if( tonumber( Request.PostParams["World_MaxCactusHeight"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "MaxCactusHeight" )
+ WorldIni:SetValue( "Plants", "MaxCactusHeight", Request.PostParams["World_MaxCactusHeight"] )
+ end
+ if( tonumber( Request.PostParams["World_CarrotsBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsCarrotsBonemealable" )
+ WorldIni:SetValue( "Plants", "IsCarrotsBonemealable", Request.PostParams["World_CarrotsBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_CropsBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsCropsBonemealable" )
+ WorldIni:SetValue( "Plants", "IsCropsBonemealable", Request.PostParams["World_CropsBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_GrassBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsGrassBonemealable" )
+ WorldIni:SetValue( "Plants", "IsGrassBonemealable", Request.PostParams["World_GrassBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_SaplingBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsSaplingBonemealable" )
+ WorldIni:SetValue( "Plants", "IsSaplingBonemealable", Request.PostParams["World_SaplingBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_MelonStemBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsMelonStemBonemealable" )
+ WorldIni:SetValue( "Plants", "IsMelonStemBonemealable", Request.PostParams["World_MelonStemBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_MelonBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsMelonBonemealable" )
+ WorldIni:SetValue( "Plants", "IsMelonBonemealable", Request.PostParams["World_MelonBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_PotatoesBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsPotatoesBonemealable" )
+ WorldIni:SetValue( "Plants", "IsPotatoesBonemealable", Request.PostParams["World_PotatoesBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_PumpkinStemBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsPumpkinStemBonemealable" )
+ WorldIni:SetValue( "Plants", "IsPumpkinStemBonemealable", Request.PostParams["World_PumpkinStemBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_PumpkinBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsPumpkinBonemealable" )
+ WorldIni:SetValue( "Plants", "IsPumpkinBonemealable", Request.PostParams["World_PumpkinBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_SugarCaneBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsSugarCaneBonemealable" )
+ WorldIni:SetValue( "Plants", "IsSugarCaneBonemealable", Request.PostParams["World_SugarCaneBonemealable"] )
+ end
+ if( tonumber( Request.PostParams["World_CactusBonemealable"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Plants", "IsCactusBonemealable" )
+ WorldIni:SetValue( "Plants", "IsCactusBonemealable", Request.PostParams["World_CactusBonemealable"] )
+ end
+ if( ( Request.PostParams["World_BiomeGen"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "BiomeGen" )
+ WorldIni:SetValue( "Generator", "BiomeGen", Request.PostParams["World_BiomeGen"] )
+ end
+ if( ( Request.PostParams["World_Biome"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ConstantBiome" )
+ WorldIni:SetValue( "Generator", "ConstantBiome", Request.PostParams["World_Biome"] )
+ end
+ if( ( Request.PostParams["World_MultiStepMapOceanCellSize"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MultiStepMapOceanCellSize" )
+ WorldIni:SetValue( "Generator", "MultiStepMapOceanCellSize", Request.PostParams["World_MultiStepMapOceanCellSize"] )
+ end
+ if( ( Request.PostParams["World_MultiStepMapMushroomIslandSize"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MultiStepMapMushroomIslandSize" )
+ WorldIni:SetValue( "Generator", "MultiStepMapMushroomIslandSize", Request.PostParams["World_MultiStepMapMushroomIslandSize"] )
+ end
+ if( ( Request.PostParams["World_MultiStepMapRiverCellSize"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MultiStepMapRiverCellSize" )
+ WorldIni:SetValue( "Generator", "MultiStepMapRiverCellSize", Request.PostParams["World_MultiStepMapRiverCellSize"] )
+ end
+ if( ( Request.PostParams["World_MultiStepMapRiverWidth"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MultiStepMapRiverWidth" )
+ WorldIni:SetValue( "Generator", "MultiStepMapRiverWidth", Request.PostParams["World_MultiStepMapRiverWidth"] )
+ end
+ if( ( Request.PostParams["World_MultiStepMapLandBiomeSize"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MultiStepMapLandBiomeSize" )
+ WorldIni:SetValue( "Generator", "MultiStepMapLandBiomeSize", Request.PostParams["World_MultiStepMapLandBiomeSize"] )
+ end
+ if( ( Request.PostParams["World_DistortedVoronoiCellSize"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "DistortedVoronoiCellSize" )
+ WorldIni:SetValue( "Generator", "DistortedVoronoiCellSize", Request.PostParams["World_DistortedVoronoiCellSize"] )
+ end
+ if( ( Request.PostParams["World_DistortedVoronoiBiomes"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "DistortedVoronoiBiomes" )
+ WorldIni:SetValue( "Generator", "DistortedVoronoiBiomes", Request.PostParams["World_DistortedVoronoiBiomes"] )
+ end
+ if( ( Request.PostParams["World_VoronoiCellSize"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "VoronoiCellSize" )
+ WorldIni:SetValue( "Generator", "VoronoiCellSize", Request.PostParams["World_VoronoiCellSize"] )
+ end
+ if( ( Request.PostParams["World_VoronoiBiomesdVoronoiBiomes"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "VoronoiBiomes" )
+ WorldIni:SetValue( "Generator", "VoronoiBiomes", Request.PostParams["World_VoronoiBiomes"] )
+ end
+ if( ( Request.PostParams["World_CheckerBoardBiomes"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "CheckerBoardBiomes" )
+ WorldIni:SetValue( "Generator", "CheckerBoardBiomes", Request.PostParams["World_CheckerBoardBiomes"] )
+ end
+ if( ( Request.PostParams["World_CheckerBoardBiomeSize"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "CheckerBoardBiomeSize" )
+ WorldIni:SetValue( "Generator", "CheckerBoardBiomeSize", Request.PostParams["World_CheckerBoardBiomeSize"] )
+ end
+ if( ( Request.PostParams["World_HeightGen"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "HeightGen" )
+ WorldIni:SetValue( "Generator", "HeightGen", Request.PostParams["World_HeightGen"] )
+ end
+ if( ( Request.PostParams["World_FlatHeight"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "FlatHeight" )
+ WorldIni:SetValue( "Generator", "FlatHeight", Request.PostParams["World_FlatHeight"] )
+ end
+ if( ( Request.PostParams["World_CompositionGen"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "CompositionGen" )
+ WorldIni:SetValue( "Generator", "CompositionGen", Request.PostParams["World_CompositionGen"] )
+ end
+ if( ( Request.PostParams["World_Noise3DSeaLevel"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Noise3DSeaLevel" )
+ WorldIni:SetValue( "Generator", "Noise3DSeaLevel", Request.PostParams["World_Noise3DSeaLevel"] )
+ end
+ if( ( Request.PostParams["World_Noise3DHeightAmplification"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Noise3DHeightAmplification" )
+ WorldIni:SetValue( "Generator", "Noise3DHeightAmplification", Request.PostParams["World_Noise3DHeightAmplification"] )
+ end
+ if( ( Request.PostParams["World_Noise3DMidPoint"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Noise3DMidPoint" )
+ WorldIni:SetValue( "Generator", "Noise3DMidPoint", Request.PostParams["World_Noise3DMidPoint"] )
+ end
+ if( ( Request.PostParams["World_Noise3DFrequencyX"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Noise3DFrequencyX" )
+ WorldIni:SetValue( "Generator", "Noise3DFrequencyX", Request.PostParams["World_Noise3DFrequencyX"] )
+ end
+ if( ( Request.PostParams["World_Noise3DFrequencyY"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Noise3DFrequencyY" )
+ WorldIni:SetValue( "Generator", "Noise3DFrequencyY", Request.PostParams["World_Noise3DFrequencyY"] )
+ end
+ if( ( Request.PostParams["World_Noise3DFrequencyZ"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Noise3DFrequencyZ" )
+ WorldIni:SetValue( "Generator", "Noise3DFrequencyZ", Request.PostParams["World_Noise3DFrequencyZ"] )
+ end
+ if( ( Request.PostParams["World_Noise3DAirThreshold"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Noise3DAirThreshold" )
+ WorldIni:SetValue( "Generator", "Noise3DAirThreshold", Request.PostParams["World_Noise3DAirThreshold"] )
+ end
+ if( ( Request.PostParams["World_ClassicSeaLevel"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ClassicSeaLevel" )
+ WorldIni:SetValue( "Generator", "ClassicSeaLevel", Request.PostParams["World_ClassicSeaLevel"] )
+ end
+ if( ( Request.PostParams["World_ClassicBeachHeight"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ClassicBeachHeight" )
+ WorldIni:SetValue( "Generator", "ClassicBeachHeight", Request.PostParams["World_ClassicBeachHeight"] )
+ end
+ if( ( Request.PostParams["World_ClassicBeachDepth"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ClassicBeachDepth" )
+ WorldIni:SetValue( "Generator", "ClassicBeachDepth", Request.PostParams["World_ClassicBeachDepth"] )
+ end
+ if( ( Request.PostParams["World_ClassicBlockTop"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ClassicBlockTop" )
+ WorldIni:SetValue( "Generator", "ClassicBlockTop", Request.PostParams["World_ClassicBlockTop"] )
+ end
+ if( ( Request.PostParams["World_ClassicBlockMiddle"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ClassicBlockMiddle" )
+ WorldIni:SetValue( "Generator", "ClassicBlockMiddle", Request.PostParams["World_ClassicBlockMiddle"] )
+ end
+ if( ( Request.PostParams["World_ClassicBlockBottom"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ClassicBlockBottom" )
+ WorldIni:SetValue( "Generator", "ClassicBlockBottom", Request.PostParams["World_ClassicBlockBottom"] )
+ end
+ if( ( Request.PostParams["World_ClassicBlockBeach"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ClassicBlockBeach" )
+ WorldIni:SetValue( "Generator", "ClassicBlockBeach", Request.PostParams["World_ClassicBlockBeach"] )
+ end
+ if( ( Request.PostParams["World_ClassicBlockBeachBottom"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ClassicBlockBeachBottom" )
+ WorldIni:SetValue( "Generator", "ClassicBlockBeachBottom", Request.PostParams["World_ClassicBlockBeachBottom"] )
+ end
+ if( ( Request.PostParams["World_ClassicBlockSea"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "ClassicBlockSea" )
+ WorldIni:SetValue( "Generator", "ClassicBlockSea", Request.PostParams["World_ClassicBlockSea"] )
+ end
+ if( ( Request.PostParams["World_SameBlockType"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "SameBlockType" )
+ WorldIni:SetValue( "Generator", "SameBlockType", Request.PostParams["World_SameBlockType"] )
+ end
+ if( ( Request.PostParams["World_SameBlockBedrocked"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "SameBlockBedrocked" )
+ WorldIni:SetValue( "Generator", "SameBlockBedrocked", Request.PostParams["World_SameBlockBedrocked"] )
+ end
+ if( ( Request.PostParams["World_Structures"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Structures" )
+ WorldIni:SetValue( "Generator", "Structures", Request.PostParams["World_Structures"] )
+ end
+ if( ( Request.PostParams["World_Finishers"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Finishers" )
+ WorldIni:SetValue( "Generator", "Finishers", Request.PostParams["World_Finishers"] )
+ end
+ if( ( Request.PostParams["World_Generator"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "Generator" )
+ WorldIni:SetValue( "Generator", "Generator", Request.PostParams["World_Generator"] )
+ end
+ if( ( Request.PostParams["World_MineShaftsGridSize"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MineShaftsGridSize" )
+ WorldIni:SetValue( "Generator", "MineShaftsGridSize", Request.PostParams["World_MineShaftsGridSize"] )
+ end
+ if( ( Request.PostParams["World_MineShaftsMaxSystemSize"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MineShaftsMaxSystemSize" )
+ WorldIni:SetValue( "Generator", "MineShaftsMaxSystemSize", Request.PostParams["World_MineShaftsMaxSystemSize"] )
+ end
+ if( ( Request.PostParams["World_MineShaftsChanceCorridor"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MineShaftsChanceCorridor" )
+ WorldIni:SetValue( "Generator", "MineShaftsChanceCorridor", Request.PostParams["World_MineShaftsChanceCorridor"] )
+ end
+ if( ( Request.PostParams["World_MineShaftsChanceCrossing"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MineShaftsChanceCrossing" )
+ WorldIni:SetValue( "Generator", "MineShaftsChanceCrossing", Request.PostParams["World_MineShaftsChanceCrossing"] )
+ end
+ if( ( Request.PostParams["World_MineShaftsChanceStaircase"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "MineShaftsChanceStaircase" )
+ WorldIni:SetValue( "Generator", "MineShaftsChanceStaircase", Request.PostParams["World_MineShaftsChanceStaircase"] )
+ end
+ if( ( Request.PostParams["World_LavaLakesProbability"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "LavaLakesProbability" )
+ WorldIni:SetValue( "Generator", "LavaLakesProbability", Request.PostParams["World_LavaLakesProbability"] )
+ end
+ if( ( Request.PostParams["World_WaterLakesProbability"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "WaterLakesProbability" )
+ WorldIni:SetValue( "Generator", "WaterLakesProbability", Request.PostParams["World_WaterLakesProbability"] )
+ end
+ if( ( Request.PostParams["World_BottomLavaLevel"] ) ~= nil ) then
+ WorldIni:DeleteValue( "Generator", "BottomLavaLevel" )
+ WorldIni:SetValue( "Generator", "BottomLavaLevel", Request.PostParams["World_BottomLavaLevel"] )
+ end
+
+ WorldIni:WriteFile()
+ end
+ Content = Content .. "<h4>World for operations: " .. WORLD .. "</h4>"
+ Content = Content .. "<table>"
+ local WorldNum = 0
+ local AddWorldToTable = function(World)
+ WorldNum = WorldNum + 1
+ Content = Content .. "<tr>"
+ Content = Content .. "<td style='width: 10px;'>" .. WorldNum .. ".</td>"
+ Content = Content .. "<td>" .. World:GetName() .. "</td>"
+ Content = Content .. "<td>" .. SelectWorldButton(World:GetName()) .. "</td>"
+ Content = Content .. "</tr>"
+ end
+ cRoot:Get():ForEachWorld(AddWorldToTable)
+ Content = Content .. "</table>"
+
+
+ Content = Content .. [[<table>
+ <form method="POST">
+ <br />
+ <th colspan="2">General</th>
+ <tr><td>Dimension:</td>
+ <td>]] .. HTML_Select_Dimension("World_Dimension", WorldIni:GetValueI("General", "Dimension") ) .. [[</td></tr>
+ </table>
+ <br />
+ <table>
+ <th colspan="2">Storage</th>
+ <tr><td>Schema:</td>
+ <td>]] .. HTML_Select_Scheme("World_Schema", WorldIni:GetValueI("Storage", "Schema") ) .. [[</td></tr>
+ </table>
+ <br />
+ <table>
+ <th colspan="2">Spawn Position</th>
+ <tr><td>X:</td>
+ <td><input type="text" name="World_SpawnX" value="]] .. WorldIni:GetValue("SpawnPosition", "X") .. [["></td></tr>
+ <tr><td>Y:</td>
+ <td><input type="text" name="World_SpawnY" value="]] .. WorldIni:GetValue("SpawnPosition", "Y") .. [["></td></tr>
+ <tr><td>Z:</td>
+ <td><input type="text" name="World_SpawnZ" value="]] .. WorldIni:GetValue("SpawnPosition", "Z") .. [["></td></tr>
+ </table>
+ <br />
+ <table>
+ <th colspan="2">Seed</th>
+ <tr><td>Seed:</td>
+ <td><input type="text" name="World_Seed" value="]] .. WorldIni:GetValue("Seed", "Seed") .. [["></td></tr>
+ </table>
+ <br />
+ <table>
+ <th colspan="2">PVP</th>
+ <tr><td style="width: 50%;">PVP:</td>
+ <td>]] .. HTML_Select_On_Off("World_PVP", WorldIni:GetValueI("PVP", "Enabled") ) .. [[</td></tr>
+ </table>
+ <br />
+ <table>
+ <th colspan="2">GameMode</th>
+ <tr><td style="width: 50%;">GameMode:</td>
+ <td>]] .. HTML_Select_GameMode("World_GameMode", WorldIni:GetValueI("GameMode", "GameMode") ) .. [[</td></tr>
+ </table>
+ <br />
+ <table>
+ <th colspan="2">Physics</th>
+ <tr><td style="width: 50%;">DeepSnow:</td>
+ <td>]] .. HTML_Select_On_Off("World_DeepSnow", WorldIni:GetValueI("Physics", "DeepSnow") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">SandInstantFall:</td>
+ <td>]] .. HTML_Select_On_Off("World_SandInstantFall", WorldIni:GetValueI("Physics", "SandInstantFall") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">WaterSimulator:</td>
+ <td>]] .. HTML_Select_Simulator("World_WaterSimulator", WorldIni:GetValue("Physics", "WaterSimulator") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">LavaSimulator:</td>
+ <td>]] .. HTML_Select_Simulator("World_LavaSimulator", WorldIni:GetValue("Physics", "LavaSimulator") ) .. [[</td></tr>
+ </table>
+ <br />
+ <table>
+ <th colspan="2">Plants</th>
+ <tr><td>MaxCactusHeight:</td>
+ <td><input type="text" name="World_MaxCactusHeight" value="]] .. WorldIni:GetValue("Plants", "MaxCactusHeight") .. [["></td></tr>
+ <tr><td>MaxSugarcaneHeigh:</td>
+ <td><input type="text" name="World_MaxSugarcaneHeight" value="]] .. WorldIni:GetValue("Plants", "MaxSugarcaneHeight") .. [["></td></tr>
+ <tr><td style="width: 50%;">CarrotsBonemealable:</td>
+ <td>]] .. HTML_Select_On_Off("World_CarrotsBonemealable", WorldIni:GetValueI("Plants", "IsCarrotsBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">CropsBonemealable:</td>
+ <td>]] .. HTML_Select_On_Off("World_CropsBonemealable", WorldIni:GetValueI("Plants", "IsCropsBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">GrassBonemealabl:</td>
+ <td>]] .. HTML_Select_On_Off("World_GrassBonemealable", WorldIni:GetValueI("Plants", "IsGrassBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">SaplingBonemealable:</td>
+ <td>]] .. HTML_Select_On_Off("World_SaplingBonemealable", WorldIni:GetValueI("Plants", "IsSaplingBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">MelonStemBonemealable:</td>
+ <td>]] .. HTML_Select_On_Off("World_MelonStemBonemealable", WorldIni:GetValueI("Plants", "IsMelonStemBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">MelonBonemealable:</td>
+ <td>]] .. HTML_Select_On_Off("World_MelonBonemealable", WorldIni:GetValueI("Plants", "IsMelonBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">PotatoesBonemealable:</td>
+ <td>]] .. HTML_Select_On_Off("World_PotatoesBonemealable", WorldIni:GetValueI("Plants", "IsPotatoesBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">PumpkinStemBonemealable:</td>
+ <td>]] .. HTML_Select_On_Off("World_PumpkinStemBonemealable", WorldIni:GetValueI("Plants", "IsPumpkinStemBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">PumpkinBonemealable:</td>
+ <td>]] .. HTML_Select_On_Off("World_PumpkinBonemealable", WorldIni:GetValueI("Plants", "IsPumpkinBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">SugarcaneBonemealabl:</td>
+ <td>]] .. HTML_Select_On_Off("World_SugarcaneBonemealable", WorldIni:GetValueI("Plants", "IsSugarcaneBonemealable") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">CactusBonemealable:</td>
+ <td>]] .. HTML_Select_On_Off("World_CactusBonemealable", WorldIni:GetValueI("Plants", "IsCactusBonemealable") ) .. [[</td></tr>
+ </table>
+ <br />
+ <table>
+ <th colspan="2">Generator</th>
+ <tr><td style="width: 50%;">BiomeGen:</td>
+ <td>]] .. HTML_Select_BiomeGen("World_BiomeGen", WorldIni:GetValue("Generator", "BiomeGen") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">HeightGen:</td>
+ <td>]] .. HTML_Select_HeightGen("World_HeightGen", WorldIni:GetValue("Generator", "HeightGen") ) .. [[</td></tr>
+ <tr><td style="width: 50%;">CompositionGen:</td>
+ <td>]] .. HTML_Select_CompositionGen("World_CompositionGen", WorldIni:GetValue("Generator", "CompositionGen") ) .. [[</td></tr>
+ <tr><td>Structures:</td>
+ <td><input type="text" size="50" name="World_Structures" value="]] .. WorldIni:GetValue("Generator", "Structures") .. [["></td></tr>
+ <tr><td>Finishers:</td>
+ <td><input type="text" size="50" name="World_Finishers" value="]] .. WorldIni:GetValue("Generator", "Finishers") .. [["></td></tr>
+ <tr><td style="width: 50%;">Generator:</td>
+ <td>]] .. HTML_Select_Generator("World_Generator", WorldIni:GetValue("Generator", "Generator") ) .. [[</td></tr>
+
+ </table>
+ <br />
+ <table>
+ <th colspan="1">Finetuning</th><br />
+ </table>
+ <table>
+ ]]
+ if WorldIni:GetValue( "Generator", "BiomeGen" ) == "Constant" then
+ Content = Content .. [[
+ <th colspan="2">Biome Generator</th>
+ <tr><td style="width: 50%;">ConstantBiome:</td>
+ <td>]] .. HTML_Select_Biome( "World_Biome", WorldIni:GetValue("Generator", "ConstantBiome" ) ) .. [[</td></tr>]]
+ elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "MultiStepMap" then
+ Content = Content .. [[
+ <th colspan="2">Biome Generator</th>
+ <tr><td>MultiStepMapOceanCellSize:</td>
+ <td><input type="text" name="World_MultiStepMapOceanCellSize" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapOceanCellSize") .. [["></td></tr>
+ <tr><td>MultiStepMapOceanCellSize:</td>
+ <td><input type="text" name="World_MultiStepMapMushroomIslandSize" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapMushroomIslandSize") .. [["></td></tr>
+ <tr><td>MultiStepMapOceanCellSize:</td>
+ <td><input type="text" name="World_MultiStepMapRiverCellSize" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapRiverCellSize") .. [["></td></tr>
+ <tr><td>MultiStepMapOceanCellSize:</td>
+ <td><input type="text" name="World_MultiStepMapRiverWidth" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapRiverWidth") .. [["></td></tr>
+ <tr><td>MultiStepMapOceanCellSize:</td>
+ <td><input type="text" name="World_MultiStepMapLandBiomeSize" value="]] .. WorldIni:GetValue("Generator", "MultiStepMapLandBiomeSize") .. [["></td></tr>]]
+ elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "DistortedVoronoi" then
+ Content = Content .. [[
+ <th colspan="2">Biome Generator</th>
+ <tr><td>DistortedVoronoiCellSize:</td>
+ <td><input type="text" name="World_DistortedVoronoiCellSize" value="]] .. WorldIni:GetValue("Generator", "DistortedVoronoiCellSize") .. [["></td></tr>
+ <tr><td>DistortedVoronoiBiomes:</td>
+ <td><input type="text" name="World_DistortedVoronoiBiomes" value="]] .. WorldIni:GetValue("Generator", "DistortedVoronoiBiomes") .. [["></td></tr>]]
+ elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "Voronoi" then
+ Content = Content .. [[
+ <th colspan="2">Biome Generator</th>
+ <tr><td>VoronoiCellSize:</td>
+ <td><input type="text" name="World_VoronoiCellSize" value="]] .. WorldIni:GetValue("Generator", "VoronoiCellSize") .. [["></td></tr>
+ <tr><td>VoronoiBiomes:</td>
+ <td><input type="text" name="World_VoronoiBiomes" value="]] .. WorldIni:GetValue("Generator", "VoronoiBiomes") .. [["></td></tr>]]
+ elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "CheckerBoard" then
+ Content = Content .. [[
+ <th colspan="2">Biome Generator</th>
+ <tr><td>CheckerBoardBiomes:</td>
+ <td><input type="text" name="World_CheckerBoardBiomes" value="]] .. WorldIni:GetValue("Generator", "CheckerBoardBiomes") .. [["></td></tr>
+ <tr><td>CheckerBoardBiomeSize:</td>
+ <td><input type="text" name="World_CheckerBoardBiomeSize" value="]] .. WorldIni:GetValue("Generator", "CheckerBoardBiomeSize") .. [["></td></tr>]]
+ end
+
+ if WorldIni:GetValue( "Generator", "CompositionGen" ) == "Noise3D" then
+ Content = Content .. [[
+ <th colspan="2">Composition Generator</th>
+ <tr><td>Noise3DSeaLevel:</td>
+ <td><input type="text" name="World_Noise3DSeaLevel" value="]] .. WorldIni:GetValue("Generator", "Noise3DSeaLevel") .. [["></td></tr>
+ <tr><td>Noise3DHeightAmplification:</td>
+ <td><input type="text" name="World_Noise3DHeightAmplification" value="]] .. WorldIni:GetValue("Generator", "Noise3DHeightAmplification") .. [["></td></tr>
+ <tr><td>Noise3DMidPoint:</td>
+ <td><input type="text" name="World_Noise3DMidPoint" value="]] .. WorldIni:GetValue("Generator", "Noise3DMidPoint") .. [["></td></tr>
+ <tr><td>Noise3DFrequencyX:</td>
+ <td><input type="text" name="World_Noise3DFrequencyX" value="]] .. WorldIni:GetValue("Generator", "Noise3DFrequencyX") .. [["></td></tr>
+ <tr><td>Noise3DFrequencyY:</td>
+ <td><input type="text" name="World_Noise3DFrequencyY" value="]] .. WorldIni:GetValue("Generator", "Noise3DFrequencyY") .. [["></td></tr>
+ <tr><td>Noise3DFrequencyZ:</td>
+ <td><input type="text" name="World_Noise3DFrequencyZ" value="]] .. WorldIni:GetValue("Generator", "Noise3DFrequencyZ") .. [["></td></tr>
+ <tr><td>Noise3DAirThreshold:</td>
+ <td><input type="text" name="World_Noise3DAirThreshold" value="]] .. WorldIni:GetValue("Generator", "Noise3DAirThreshold") .. [["></td></tr>]]
+ elseif WorldIni:GetValue( "Generator", "CompositionGen" ) == "Classic" then
+ Content = Content .. [[
+ <th colspan="2">Composition Generator</th>
+ <tr><td>ClassicSeaLevel:</td>
+ <td><input type="text" name="World_ClassicSeaLevel" value="]] .. WorldIni:GetValue("Generator", "ClassicSeaLevel") .. [["></td></tr>
+ <tr><td>ClassicBeachHeight:</td>
+ <td><input type="text" name="World_ClassicBeachHeight" value="]] .. WorldIni:GetValue("Generator", "ClassicBeachHeight") .. [["></td></tr>
+ <tr><td>ClassicBeachDepth:</td>
+ <td><input type="text" name="World_ClassicBeachDepth" value="]] .. WorldIni:GetValue("Generator", "ClassicBeachDepth") .. [["></td></tr>
+ <tr><td>ClassicBlockTop:</td>
+ <td><input type="text" name="World_ClassicBlockTop" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockTop") .. [["></td></tr>
+ <tr><td>ClassicBlockMiddle:</td>
+ <td><input type="text" name="World_ClassicBlockMiddle" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockMiddle") .. [["></td></tr>
+ <tr><td>ClassicBlockBottom:</td>
+ <td><input type="text" name="World_ClassicBlockBottom" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockBottom") .. [["></td></tr>
+ <tr><td>ClassicBlockBeach:</td>
+ <td><input type="text" name="World_ClassicBlockBeach" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockBeach") .. [["></td></tr>
+ <tr><td>ClassicBlockBeachBottom:</td>
+ <td><input type="text" name="World_ClassicBlockBeachBottom" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockBeachBottom") .. [["></td></tr>
+ <tr><td>ClassicBlockSea:</td>
+ <td><input type="text" name="World_ClassicBlockSea" value="]] .. WorldIni:GetValue("Generator", "ClassicBlockSea") .. [["></td></tr>]]
+ elseif WorldIni:GetValue( "Generator", "CompositionGen" ) == "SameBlock" then
+ Content = Content .. [[
+ <th colspan="2">Composition Generator</th>
+ <tr><td>SameBlockType:</td>
+ <td><input type="text" name="World_SameBlockType" value="]] .. WorldIni:GetValue("Generator", "SameBlockType") .. [["></td></tr>
+ <tr><td>SameBlockBedrocked:</td>
+ <td><input type="text" name="World_SameBlockBedrocked" value="]] .. WorldIni:GetValue("Generator", "SameBlockBedrocked") .. [["></td></tr>]]
+ end
+ if WorldIni:GetValue( "Generator", "HeightGen" ) == "Flat" then
+ Content = Content .. [[
+ <th colspan="2">Height Generator</th>
+ <tr><td>FlatHeight:</td>
+ <td><input type="text" name="World_FlatHeight" value="]] .. WorldIni:GetValue("Generator", "FlatHeight") .. [["></td></tr>]]
+ end
+ if string.find( WorldIni:GetValue( "Generator", "Structures" ), "MineShafts" ) ~= nil then
+ Content = Content .. [[
+ <th colspan="2">MineShafts</th>
+ <tr><td>MineShaftsGridSize:</td>
+ <td><input type="text" name="World_MineShaftsGridSize" value="]] .. WorldIni:GetValue("Generator", "MineShaftsGridSize") .. [["></td></tr>
+ <tr><td>MineShaftsMaxSystemSize:</td>
+ <td><input type="text" name="World_MineShaftsMaxSystemSize" value="]] .. WorldIni:GetValue("Generator", "MineShaftsMaxSystemSize") .. [["></td></tr>
+ <tr><td>MineShaftsChanceCorridor:</td>
+ <td><input type="text" name="World_MineShaftsChanceCorridor" value="]] .. WorldIni:GetValue("Generator", "MineShaftsChanceCorridor") .. [["></td></tr>
+ <tr><td>MineShaftsChanceCrossing:</td>
+ <td><input type="text" name="World_MineShaftsChanceCrossing" value="]] .. WorldIni:GetValue("Generator", "MineShaftsChanceCrossing") .. [["></td></tr>
+ <tr><td>MineShaftsChanceStaircase:</td>
+ <td><input type="text" name="World_MineShaftsChanceStaircase" value="]] .. WorldIni:GetValue("Generator", "MineShaftsChanceStaircase") .. [["></td></tr>]]
+ end
+ if string.find( WorldIni:GetValue( "Generator", "Structures" ), "LavaLakes" ) ~= nil then
+ Content = Content .. [[
+ <th colspan="2">LavaLakes</th>
+ <tr><td>LavaLakesProbability:</td>
+ <td><input type="text" name="World_LavaLakesProbability" value="]] .. WorldIni:GetValue("Generator", "LavaLakesProbability") .. [["></td></tr>]]
+ end
+ if string.find( WorldIni:GetValue( "Generator", "Structures" ), "WaterLakes" ) ~= nil then
+ Content = Content .. [[
+ <th colspan="2">WaterLakes</th>
+ <tr><td>WaterLakesProbability:</td>
+ <td><input type="text" name="World_WaterLakesProbability" value="]] .. WorldIni:GetValue("Generator", "WaterLakesProbability") .. [["></td></tr>]]
+ end
+ if string.find( WorldIni:GetValue( "Generator", "Finishers" ), "BottomLava" ) ~= nil then
+ Content = Content .. [[
+ <th colspan="2">BottomLavaLevel</th>
+ <tr><td>BottomLavaLevel:</td>
+ <td><input type="text" name="World_BottomLavaLevel" value="]] .. WorldIni:GetValue("Generator", "BottomLavaLevel") .. [["></td></tr>]]
+ end
+ Content = Content .. [[</table>]]
+
+ Content = Content .. [[ <br />
+ <input type="submit" value="Save Settings" name="world_submit"> </form>WARNING: Any changes made here might require a server restart in order to be applied!
+ </form>]]
+ return Content
+end
+
+
+
+function HandleRequest_ServerSettings( Request )
+ local Content = ""
+
+ Content = Content .. [[
+ <p><b>Server Settings</b></p>
+ <table>
+ <tr>
+ <td><a href="?tab=General">General</a></td>
+ <td><a href="?tab=Monsters">Monsters</a></td>
+ <td><a href="?tab=Worlds">Worlds</a></td>
+ <td><a href="?tab=World">World</a></td>
+ </tr>
+ </table>
+ <br />]]
+
+ if( Request.Params["tab"] == "Monsters" ) then
+ Content = Content .. ShowMonstersSettings( Request )
+ elseif( Request.Params["tab"] == "Worlds" ) then
+ Content = Content .. ShowWorldsSettings( Request )
+ elseif( Request.Params["tab"] == "World" ) then
+ Content = Content .. ShowWorldSettings( Request )
+ else
+ Content = Content .. ShowGeneralSettings( Request ) -- Default to general settings
+ end
+
+ return Content
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/web_whitelist.lua b/MCServer/Plugins/Core/web_whitelist.lua
index 2c9ddb953..61cc6fd8b 100644
--- a/MCServer/Plugins/Core/web_whitelist.lua
+++ b/MCServer/Plugins/Core/web_whitelist.lua
@@ -1,79 +1,79 @@
-local function HTMLDeleteButton( name )
- return "<form method=\"POST\"><input type=\"hidden\" name=\"whitelist-delete\" value=\"".. name .."\"><input type=\"submit\" value=\"Remove from whitelist\"></form>"
-end
-
-function HandleRequest_WhiteList( Request )
- local UpdateMessage = ""
- if( Request.PostParams["whitelist-add"] ~= nil ) then
- local PlayerName = Request.PostParams["whitelist-add"]
-
- if( WhiteListIni:GetValueB("WhiteList", PlayerName, false) == true ) then
- UpdateMessage = "<b>".. PlayerName.."</b> is already on the whitelist"
- else
- WhiteListIni:SetValueB("WhiteList", PlayerName, true )
- UpdateMessage = "Added <b>" .. PlayerName .. "</b> to whitelist."
- WhiteListIni:WriteFile()
- end
- elseif( Request.PostParams["whitelist-delete"] ~= nil ) then
- local PlayerName = Request.PostParams["whitelist-delete"]
- WhiteListIni:DeleteValue( "WhiteList", PlayerName )
- UpdateMessage = "Removed <b>" .. PlayerName .. "</b> from whitelist."
- WhiteListIni:WriteFile()
- elseif( Request.PostParams["whitelist-reload"] ~= nil ) then
- WhiteListIni:Erase() -- Empty entire loaded ini first, otherwise weird shit goes down
- WhiteListIni:ReadFile()
- UpdateMessage = "Loaded from disk"
- elseif( Request.Params["whitelist-setenable"] ~= nil ) then
- local Enabled = Request.Params["whitelist-setenable"]
- local CreateNewValue = false
- if( WhiteListIni:FindValue( WhiteListIni:FindKey("WhiteListSettings"), "WhiteListOn" ) == cIniFile.noID ) then -- Find out whether the value is in the ini
- CreateNewValue = true
- end
-
- if( Enabled == "1" ) then
- WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", true, CreateNewValue )
- else
- WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false, CreateNewValue )
- end
- WhiteListIni:WriteFile()
- end
-
-
- local Content = ""
-
- local WhiteListEnabled = WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false)
- if( WhiteListEnabled == false ) then
- Content = Content .. "<p>Whitelist is currently disabled! Click <a href='?whitelist-setenable=1'>here</a> to enable.</p>"
- end
-
-
- Content = Content .. "<h4>Whitelisted players</h4>"
- Content = Content .. "<table>"
- local KeyNum = WhiteListIni:FindKey("WhiteList")
- local NumValues = WhiteListIni:GetNumValues(KeyNum)
- if( NumValues > 0 ) then
- for Num = 0, NumValues-1 do
- if( WhiteListIni:GetValue(KeyNum, Num, "0") == "1" ) then
- local PlayerName = WhiteListIni:GetValueName(KeyNum, Num )
- Content = Content .. "<tr><td>" .. PlayerName .. "</td><td>" .. HTMLDeleteButton( PlayerName ) .. "</td></tr>"
- end
- end
- else
- Content = Content .. "<tr><td>None</td></tr>"
- end
- Content = Content .. "</table>"
- Content = Content .. "<br><h4>Add player to whitelist</h4>"
- Content = Content .. "<form method=\"POST\">"
- Content = Content .. "<input type=\"text\" name=\"whitelist-add\"><input type=\"submit\" value=\"Add player\">"
- Content = Content .. "</form>"
- Content = Content .. "<form method=\"POST\">"
- Content = Content .. "<input type=\"submit\" name=\"whitelist-reload\" value=\"Reload from disk\">"
- Content = Content .. "</form>"
- Content = Content .. "<br>"..UpdateMessage
-
- if( WhiteListEnabled == true ) then
- Content = Content .. "<br><br><p>Whitelist is currently enabled, click <a href='?whitelist-setenable=0'>here</a> to disable.</p>"
- end
-
- return Content
+local function HTMLDeleteButton( name )
+ return "<form method=\"POST\"><input type=\"hidden\" name=\"whitelist-delete\" value=\"".. name .."\"><input type=\"submit\" value=\"Remove from whitelist\"></form>"
+end
+
+function HandleRequest_WhiteList( Request )
+ local UpdateMessage = ""
+ if( Request.PostParams["whitelist-add"] ~= nil ) then
+ local PlayerName = Request.PostParams["whitelist-add"]
+
+ if( WhiteListIni:GetValueB("WhiteList", PlayerName, false) == true ) then
+ UpdateMessage = "<b>".. PlayerName.."</b> is already on the whitelist"
+ else
+ WhiteListIni:SetValueB("WhiteList", PlayerName, true )
+ UpdateMessage = "Added <b>" .. PlayerName .. "</b> to whitelist."
+ WhiteListIni:WriteFile()
+ end
+ elseif( Request.PostParams["whitelist-delete"] ~= nil ) then
+ local PlayerName = Request.PostParams["whitelist-delete"]
+ WhiteListIni:DeleteValue( "WhiteList", PlayerName )
+ UpdateMessage = "Removed <b>" .. PlayerName .. "</b> from whitelist."
+ WhiteListIni:WriteFile()
+ elseif( Request.PostParams["whitelist-reload"] ~= nil ) then
+ WhiteListIni:Erase() -- Empty entire loaded ini first, otherwise weird shit goes down
+ WhiteListIni:ReadFile()
+ UpdateMessage = "Loaded from disk"
+ elseif( Request.Params["whitelist-setenable"] ~= nil ) then
+ local Enabled = Request.Params["whitelist-setenable"]
+ local CreateNewValue = false
+ if( WhiteListIni:FindValue( WhiteListIni:FindKey("WhiteListSettings"), "WhiteListOn" ) == cIniFile.noID ) then -- Find out whether the value is in the ini
+ CreateNewValue = true
+ end
+
+ if( Enabled == "1" ) then
+ WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", true, CreateNewValue )
+ else
+ WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false, CreateNewValue )
+ end
+ WhiteListIni:WriteFile()
+ end
+
+
+ local Content = ""
+
+ local WhiteListEnabled = WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false)
+ if( WhiteListEnabled == false ) then
+ Content = Content .. "<p>Whitelist is currently disabled! Click <a href='?whitelist-setenable=1'>here</a> to enable.</p>"
+ end
+
+
+ Content = Content .. "<h4>Whitelisted players</h4>"
+ Content = Content .. "<table>"
+ local KeyNum = WhiteListIni:FindKey("WhiteList")
+ local NumValues = WhiteListIni:GetNumValues(KeyNum)
+ if( NumValues > 0 ) then
+ for Num = 0, NumValues-1 do
+ if( WhiteListIni:GetValue(KeyNum, Num, "0") == "1" ) then
+ local PlayerName = WhiteListIni:GetValueName(KeyNum, Num )
+ Content = Content .. "<tr><td>" .. PlayerName .. "</td><td>" .. HTMLDeleteButton( PlayerName ) .. "</td></tr>"
+ end
+ end
+ else
+ Content = Content .. "<tr><td>None</td></tr>"
+ end
+ Content = Content .. "</table>"
+ Content = Content .. "<br><h4>Add player to whitelist</h4>"
+ Content = Content .. "<form method=\"POST\">"
+ Content = Content .. "<input type=\"text\" name=\"whitelist-add\"><input type=\"submit\" value=\"Add player\">"
+ Content = Content .. "</form>"
+ Content = Content .. "<form method=\"POST\">"
+ Content = Content .. "<input type=\"submit\" name=\"whitelist-reload\" value=\"Reload from disk\">"
+ Content = Content .. "</form>"
+ Content = Content .. "<br>"..UpdateMessage
+
+ if( WhiteListEnabled == true ) then
+ Content = Content .. "<br><br><p>Whitelist is currently enabled, click <a href='?whitelist-setenable=0'>here</a> to disable.</p>"
+ end
+
+ return Content
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/onplayermoving.lua b/MCServer/Plugins/Core/worldlimiter.lua
index c95eb0c5a..8bd9b5509 100644
--- a/MCServer/Plugins/Core/onplayermoving.lua
+++ b/MCServer/Plugins/Core/worldlimiter.lua
@@ -1,21 +1,21 @@
-function OnPlayerMoving( Player )
- if LimitWorld == true then
- local World = Player:GetWorld()
- local SpawnX = math.floor(World:GetSpawnX() / 16)
- local SpawnZ = math.floor(World:GetSpawnZ() / 16)
- local X = math.floor(Player:GetPosX() / 16)
- local Z = math.floor(Player:GetPosZ() / 16)
- if ( (SpawnX + LimitWorldWidth - 1) < X ) then
- Player:TeleportToCoords(Player:GetPosX() - 1, Player:GetPosY(), Player:GetPosZ())
- end
- if ( (SpawnX - LimitWorldWidth + 1) > X ) then
- Player:TeleportToCoords(Player:GetPosX() + 1, Player:GetPosY(), Player:GetPosZ())
- end
- if ( (SpawnZ + LimitWorldWidth - 1) < Z ) then
- Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() - 1)
- end
- if ( (SpawnZ - LimitWorldWidth + 1) > Z ) then
- Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() + 1)
- end
- end
+function OnPlayerMoving( Player )
+ if LimitWorld == true then
+ local World = Player:GetWorld()
+ local SpawnX = math.floor(World:GetSpawnX() / 16)
+ local SpawnZ = math.floor(World:GetSpawnZ() / 16)
+ local X = math.floor(Player:GetPosX() / 16)
+ local Z = math.floor(Player:GetPosZ() / 16)
+ if ( (SpawnX + LimitWorldWidth - 1) < X ) then
+ Player:TeleportToCoords(Player:GetPosX() - 1, Player:GetPosY(), Player:GetPosZ())
+ end
+ if ( (SpawnX - LimitWorldWidth + 1) > X ) then
+ Player:TeleportToCoords(Player:GetPosX() + 1, Player:GetPosY(), Player:GetPosZ())
+ end
+ if ( (SpawnZ + LimitWorldWidth - 1) < Z ) then
+ Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() - 1)
+ end
+ if ( (SpawnZ - LimitWorldWidth + 1) > Z ) then
+ Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() + 1)
+ end
+ end
end \ No newline at end of file
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index e2523e63e..ab3397f74 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -1,717 +1,699 @@
-
--- Global variables
-PLUGIN = {}; -- Reference to own plugin object
-ShouldDumpFunctions = true; -- If set to true, all available functions are written to the API.txt file upon plugin initialization
-
-g_DropSpensersToActivate = {}; -- A list of dispensers and droppers (as {World, X, Y Z} quadruplets) that are to be activated every tick
-
-g_HungerReportTick = 10;
-
-
-
-
-
-function Initialize(Plugin)
- PLUGIN = Plugin
-
- Plugin:SetName("Debuggers")
- Plugin:SetVersion(1)
-
- PluginManager = cRoot:Get():GetPluginManager()
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_BLOCK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_ITEM);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_TAKE_DAMAGE);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_TICK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT);
-
- PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "Shows a list of all the loaded entities");
- PluginManager:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "Kills all the loaded entities");
- PluginManager:BindCommand("/wool", "debuggers", HandleWoolCmd, "Sets all your armor to blue wool");
- PluginManager:BindCommand("/testwnd", "debuggers", HandleTestWndCmd, "Opens up a window using plugin API");
- PluginManager:BindCommand("/gc", "debuggers", HandleGCCmd, "Activates the Lua garbage collector");
- PluginManager:BindCommand("/fast", "debuggers", HandleFastCmd, "Switches between fast and normal movement speed");
- PluginManager:BindCommand("/dash", "debuggers", HandleDashCmd, "Switches between fast and normal sprinting speed");
- PluginManager:BindCommand("/hunger", "debuggers", HandleHungerCmd, "Lists the current hunger-related variables");
- PluginManager:BindCommand("/poison", "debuggers", HandlePoisonCmd, "Sets food-poisoning for 15 seconds");
-
- -- Enable the following line for BlockArea / Generator interface testing:
- -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
-
- LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
-
- -- dump all available API functions and objects:
- if (ShouldDumpFunctions) then
- DumpAPI();
- end
-
-
- -- TestBlockAreas();
- -- TestSQLiteBindings();
- -- TestExpatBindings();
-
- return true
-end;
-
-
-
-
-
-function DumpAPI()
- LOG("Dumping all available functions to API.txt...");
- function dump (prefix, a, Output)
- for i, v in pairs (a) do
- if (type(v) == "table") then
- if (GetChar(i, 1) ~= ".") then
- if (v == _G) then
- LOG(prefix .. i .. " == _G, CYCLE, ignoring");
- elseif (v == _G.package) then
- LOG(prefix .. i .. " == _G.package, ignoring");
- else
- dump(prefix .. i .. ".", v, Output)
- end
- end
- elseif (type(v) == "function") then
- if (string.sub(i, 1, 2) ~= "__") then
- table.insert(Output, prefix .. i .. "()");
- end
- end
- end
- end
-
- local Output = {};
- dump("", _G, Output);
-
- table.sort(Output);
- local f = io.open("API.txt", "w");
- for i, n in ipairs(Output) do
- f:write(n, "\n");
- end
- f:close();
- LOG("API.txt written.");
-end
-
-
-
-
-
-function TestBlockAreas()
- LOG("Testing block areas...");
-
- -- Debug block area merging:
- local BA1 = cBlockArea();
- local BA2 = cBlockArea();
- if (BA1:LoadFromSchematicFile("schematics/test.schematic")) then
- if (BA2:LoadFromSchematicFile("schematics/fountain.schematic")) then
- BA2:SetRelBlockType(0, 0, 0, E_BLOCK_LAPIS_BLOCK);
- BA2:SetRelBlockType(1, 0, 0, E_BLOCK_LAPIS_BLOCK);
- BA2:SetRelBlockType(2, 0, 0, E_BLOCK_LAPIS_BLOCK);
- BA1:Merge(BA2, 1, 10, 1, cBlockArea.msImprint);
- BA1:SaveToSchematicFile("schematics/merge.schematic");
- end
- else
- BA1:Create(16, 16, 16);
- end
-
- -- Debug block area cuboid filling:
- BA1:FillRelCuboid(2, 9, 2, 8, 2, 8, cBlockArea.baTypes, E_BLOCK_GOLD_BLOCK);
- BA1:RelLine(2, 2, 2, 9, 8, 8, cBlockArea.baTypes or cBlockArea.baMetas, E_BLOCK_SAPLING, E_META_SAPLING_BIRCH);
- BA1:SaveToSchematicFile("schematics/fillrel.schematic");
-
- -- Debug block area mirroring:
- if (BA1:LoadFromSchematicFile("schematics/lt.schematic")) then
- BA1:MirrorXYNoMeta();
- BA1:SaveToSchematicFile("schematics/lt_XY.schematic");
- BA1:MirrorXYNoMeta();
- BA1:SaveToSchematicFile("schematics/lt_XY2.schematic");
-
- BA1:MirrorXZNoMeta();
- BA1:SaveToSchematicFile("schematics/lt_XZ.schematic");
- BA1:MirrorXZNoMeta();
- BA1:SaveToSchematicFile("schematics/lt_XZ2.schematic");
-
- BA1:MirrorYZNoMeta();
- BA1:SaveToSchematicFile("schematics/lt_YZ.schematic");
- BA1:MirrorYZNoMeta();
- BA1:SaveToSchematicFile("schematics/lt_YZ2.schematic");
- end
-
- -- Debug block area rotation:
- if (BA1:LoadFromSchematicFile("schematics/rot.schematic")) then
- BA1:RotateCWNoMeta();
- BA1:SaveToSchematicFile("schematics/rot1.schematic");
- BA1:RotateCWNoMeta();
- BA1:SaveToSchematicFile("schematics/rot2.schematic");
- BA1:RotateCWNoMeta();
- BA1:SaveToSchematicFile("schematics/rot3.schematic");
- BA1:RotateCWNoMeta();
- BA1:SaveToSchematicFile("schematics/rot4.schematic");
- end
-
- -- Debug block area rotation:
- if (BA1:LoadFromSchematicFile("schematics/rotm.schematic")) then
- BA1:RotateCCW();
- BA1:SaveToSchematicFile("schematics/rotm1.schematic");
- BA1:RotateCCW();
- BA1:SaveToSchematicFile("schematics/rotm2.schematic");
- BA1:RotateCCW();
- BA1:SaveToSchematicFile("schematics/rotm3.schematic");
- BA1:RotateCCW();
- BA1:SaveToSchematicFile("schematics/rotm4.schematic");
- end
-
- -- Debug block area mirroring:
- if (BA1:LoadFromSchematicFile("schematics/ltm.schematic")) then
- BA1:MirrorXY();
- BA1:SaveToSchematicFile("schematics/ltm_XY.schematic");
- BA1:MirrorXY();
- BA1:SaveToSchematicFile("schematics/ltm_XY2.schematic");
-
- BA1:MirrorXZ();
- BA1:SaveToSchematicFile("schematics/ltm_XZ.schematic");
- BA1:MirrorXZ();
- BA1:SaveToSchematicFile("schematics/ltm_XZ2.schematic");
-
- BA1:MirrorYZ();
- BA1:SaveToSchematicFile("schematics/ltm_YZ.schematic");
- BA1:MirrorYZ();
- BA1:SaveToSchematicFile("schematics/ltm_YZ2.schematic");
- end
-
- LOG("Block areas test ended");
-end
-
-
-
-
-
-
-function TestSQLiteBindings()
- LOG("Testing SQLite bindings...");
-
- -- Debug SQLite binding
- local TestDB, ErrCode, ErrMsg = sqlite3.open("test.sqlite");
- if (TestDB ~= nil) then
- local function ShowRow(UserData, NumCols, Values, Names)
- assert(UserData == 'UserData');
- LOG("New row");
- for i = 1, NumCols do
- LOG(" " .. Names[i] .. " = " .. Values[i]);
- end
- return 0;
- end
- local sql = [=[
- CREATE TABLE numbers(num1,num2,str);
- INSERT INTO numbers VALUES(1, 11, "ABC");
- INSERT INTO numbers VALUES(2, 22, "DEF");
- INSERT INTO numbers VALUES(3, 33, "UVW");
- INSERT INTO numbers VALUES(4, 44, "XYZ");
- SELECT * FROM numbers;
- ]=]
- local Res = TestDB:exec(sql, ShowRow, 'UserData');
- if (Res ~= sqlite3.OK) then
- LOG("TestDB:exec() failed: " .. Res .. " (" .. TestDB:errmsg() .. ")");
- end;
- TestDB:close();
- else
- -- This happens if for example SQLite cannot open the file (eg. a folder with the same name exists)
- LOG("SQLite3 failed to open DB! (" .. ErrCode .. ", " .. ErrMsg ..")");
- end
-
- LOG("SQLite bindings test ended");
-end
-
-
-
-
-
-function TestExpatBindings()
- LOG("Testing Expat bindings...");
-
- -- Debug LuaExpat bindings:
- local count = 0
- callbacks = {
- StartElement = function (parser, name)
- LOG("+ " .. string.rep(" ", count) .. name);
- count = count + 1;
- end,
- EndElement = function (parser, name)
- count = count - 1;
- LOG("- " .. string.rep(" ", count) .. name);
- end
- }
-
- local p = lxp.new(callbacks);
- p:parse("<elem1>\nnext line\nanother line");
- p:parse("text\n");
- p:parse("<elem2/>\n");
- p:parse("more text");
- p:parse("</elem1>");
- p:parse("\n");
- p:parse(); -- finishes the document
- p:close(); -- closes the parser
-
- LOG("Expat bindings test ended");
-end
-
-
-
-
-
-function OnUsingBlazeRod(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
- -- Magic rod of query: show block types and metas for both neighbors of the pointed face
- local Type, Meta, Valid = Player:GetWorld():GetBlockTypeMeta(BlockX, BlockY, BlockZ, Type, Meta);
-
- if (Type == E_BLOCK_AIR) then
- Player:SendMessage(cChatColor.LightGray .. "Block {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}: air:" .. Meta);
- else
- local TempItem = cItem(Type, 1, Meta);
- Player:SendMessage(cChatColor.LightGray .. "Block {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}: " .. ItemToFullString(TempItem) .. " (" .. Type .. ":" .. Meta .. ")");
- end
-
- local X, Y, Z = AddFaceDirection(BlockX, BlockY, BlockZ, BlockFace);
- Valid, Type, Meta = Player:GetWorld():GetBlockTypeMeta(X, Y, Z, Type, Meta);
- if (Type == E_BLOCK_AIR) then
- Player:SendMessage(cChatColor.LightGray .. "Block {" .. X .. ", " .. Y .. ", " .. Z .. "}: air:" .. Meta);
- else
- local TempItem = cItem(Type, 1, Meta);
- Player:SendMessage(cChatColor.LightGray .. "Block {" .. X .. ", " .. Y .. ", " .. Z .. "}: " .. ItemToFullString(TempItem) .. " (" .. Type .. ":" .. Meta .. ")");
- end
- return false;
-end
-
-
-
-
-
-function OnUsingDiamond(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
- -- Rclk with a diamond to test block area cropping and expanding
- local Area = cBlockArea();
- Area:Read(Player:GetWorld(),
- BlockX - 19, BlockX + 19,
- BlockY - 7, BlockY + 7,
- BlockZ - 19, BlockZ + 19
- );
-
- LOG("Size before cropping: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
- Area:DumpToRawFile("crop0.dat");
-
- Area:Crop(2, 3, 0, 0, 0, 0);
- LOG("Size after cropping 1: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
- Area:DumpToRawFile("crop1.dat");
-
- Area:Crop(2, 3, 0, 0, 0, 0);
- LOG("Size after cropping 2: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
- Area:DumpToRawFile("crop2.dat");
-
- Area:Expand(2, 3, 0, 0, 0, 0);
- LOG("Size after expanding 1: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
- Area:DumpToRawFile("expand1.dat");
-
- Area:Expand(3, 2, 1, 1, 0, 0);
- LOG("Size after expanding 2: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
- Area:DumpToRawFile("expand2.dat");
-
- Area:Crop(0, 0, 0, 0, 3, 2);
- LOG("Size after cropping 3: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
- Area:DumpToRawFile("crop3.dat");
-
- Area:Crop(0, 0, 3, 2, 0, 0);
- LOG("Size after cropping 4: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
- Area:DumpToRawFile("crop4.dat");
-
- LOG("Crop test done");
- Player:SendMessage("Crop / expand test done.");
- return false;
-end
-
-
-
-
-
-function OnUsingEyeOfEnder(Player, BlockX, BlockY, BlockZ)
- -- Rclk with an eye of ender places a predefined schematic at the cursor
- local Area = cBlockArea();
- if not(Area:LoadFromSchematicFile("schematics/test.schematic")) then
- LOG("Loading failed");
- return false;
- end
- LOG("Schematic loaded, placing now.");
- Area:Write(Player:GetWorld(), BlockX, BlockY, BlockZ);
- LOG("Done.");
- return false;
-end
-
-
-
-
-
-function OnUsingEnderPearl(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
- -- Rclk with an ender pearl saves a predefined area around the cursor into a .schematic file. Also tests area copying
- local Area = cBlockArea();
- if not(Area:Read(Player:GetWorld(),
- BlockX - 8, BlockX + 8, BlockY - 8, BlockY + 8, BlockZ - 8, BlockZ + 8)
- ) then
- LOG("LUA: Area couldn't be read");
- return false;
- end
- LOG("LUA: Area read, copying now.");
- local Area2 = cBlockArea();
- Area2:CopyFrom(Area);
- LOG("LUA: Copied, now saving.");
- if not(Area2:SaveToSchematicFile("schematics/test.schematic")) then
- LOG("LUA: Cannot save schematic file.");
- return false;
- end
- LOG("LUA: Done.");
- return false;
-end
-
-
-
-
-
-function OnUsingRedstoneTorch(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
- -- Redstone torch activates a rapid dispenser / dropper discharge (at every tick):
- local BlockType = Player:GetWorld():GetBlock(BlockX, BlockY, BlockZ);
- if (BlockType == E_BLOCK_DISPENSER) then
- table.insert(g_DropSpensersToActivate, {World = Player:GetWorld(), x = BlockX, y = BlockY, z = BlockZ});
- Player:SendMessage("Dispenser at {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "} discharging");
- return true;
- elseif (BlockType == E_BLOCK_DROPPER) then
- table.insert(g_DropSpensersToActivate, {World = Player:GetWorld(), x = BlockX, y = BlockY, z = BlockZ});
- Player:SendMessage("Dropper at {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "} discharging");
- return true;
- else
- Player:SendMessage("Neither a dispenser nor a dropper at {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}: " .. BlockType);
- end
- return false;
-end
-
-
-
-
-
-function OnPlayerUsingItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
-
- -- dont check if the direction is in the air
- if (BlockFace == BLOCK_FACE_NONE) then
- return false
- end
-
- local HeldItem = Player:GetEquippedItem();
- local HeldItemType = HeldItem.m_ItemType;
-
- if (HeldItemType == E_ITEM_STICK) then
- -- Magic sTick of ticking: set the pointed block for ticking at the next tick
- Player:SendMessage(cChatColor.LightGray .. "Setting next block tick to {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}")
- Player:GetWorld():SetNextBlockTick(BlockX, BlockY, BlockZ);
- return true
- elseif (HeldItemType == E_ITEM_BLAZE_ROD) then
- return OnUsingBlazeRod(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
- elseif (HeldItemType == E_ITEM_DIAMOND) then
- return OnUsingDiamond(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
- elseif (HeldItemType == E_ITEM_EYE_OF_ENDER) then
- return OnUsingEyeOfEnder(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
- elseif (HeldItemType == E_ITEM_ENDER_PEARL) then
- return OnUsingEnderPearl(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
- end
- return false;
-end
-
-
-
-
-
-function OnPlayerUsingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType, BlockMeta)
- -- dont check if the direction is in the air
- if (BlockFace == BLOCK_FACE_NONE) then
- return false
- end
-
- local HeldItem = Player:GetEquippedItem();
- local HeldItemType = HeldItem.m_ItemType;
-
- if (HeldItemType == E_BLOCK_REDSTONE_TORCH_ON) then
- return OnUsingRedstoneTorch(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
- end
-end
-
-
-
-
-
-function OnTakeDamage(Receiver, TDI)
- -- Receiver is cPawn
- -- TDI is TakeDamageInfo
-
- LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)");
- return false;
-end
-
-
-
-
-
---- When set to a positive number, the following OnTick() will perform GC and decrease until 0 again
-GCOnTick = 0;
-
-
-
-
-
-function OnTick()
- -- Activate all dropspensers in the g_DropSpensersToActivate list:
- local ActivateDrSp = function(DropSpenser)
- if (DropSpenser:GetContents():GetFirstUsedSlot() == -1) then
- return true;
- end
- DropSpenser:Activate();
- return false;
- end
- -- Walk the list backwards, because we're removing some items
- local idx = #g_DropSpensersToActivate;
- for i = idx, 1, -1 do
- local DrSp = g_DropSpensersToActivate[i];
- if not(DrSp.World:DoWithDropSpenserAt(DrSp.x, DrSp.y, DrSp.z, ActivateDrSp)) then
- table.remove(g_DropSpensersToActivate, i);
- end
- end
-
-
- -- If GCOnTick > 0, do a garbage-collect and decrease by one
- if (GCOnTick > 0) then
- collectgarbage();
- GCOnTick = GCOnTick - 1;
- end
-
- --[[
- if (g_HungerReportTick > 0) then
- g_HungerReportTick = g_HungerReportTick - 1;
- else
- g_HungerReportTick = 10;
- cRoot:Get():GetDefaultWorld():ForEachPlayer(
- function(a_Player)
- a_Player:SendMessage("FoodStat: " .. a_Player:GetFoodLevel() .. " / " .. a_Player:GetFoodExhaustionLevel());
- end
- );
- end
- ]]
-
- return false;
-end
-
-
-
-
-
-function OnChunkGenerated(World, ChunkX, ChunkZ, ChunkDesc)
- -- Test ChunkDesc / BlockArea interaction
- local BlockArea = cBlockArea();
- ChunkDesc:ReadBlockArea(BlockArea, 0, 15, 50, 70, 0, 15);
-
- -- BlockArea:SaveToSchematicFile("ChunkBlocks_" .. ChunkX .. "_" .. ChunkZ .. ".schematic");
-
- ChunkDesc:WriteBlockArea(BlockArea, 5, 115, 5);
- return false;
-end
-
-
-
-
-
-function OnChat(a_Player, a_Message)
- return false, "blabla " .. a_Message;
-end
-
-
-
-
-
--- Function "round" copied from http://lua-users.org/wiki/SimpleRound
-function round(num, idp)
- local mult = 10^(idp or 0)
- if num >= 0 then return math.floor(num * mult + 0.5) / mult
- else return math.ceil(num * mult - 0.5) / mult end
-end
-
-
-
-
-
-function HandleListEntitiesCmd(Split, Player)
- local NumEntities = 0;
-
- local ListEntity = function(Entity)
- if (Entity:IsDestroyed()) then
- -- The entity has already been destroyed, don't list it
- return false;
- end;
- Player:SendMessage(" " .. Entity:GetUniqueID() .. ": " .. Entity:GetClass() .. " {" .. round(Entity:GetPosX(), 2) .. ", " .. round(Entity:GetPosY(), 2) .. ", " .. round(Entity:GetPosZ(), 2) .."}");
- NumEntities = NumEntities + 1;
- end
-
- Player:SendMessage("Listing all entities...");
- Player:GetWorld():ForEachEntity(ListEntity);
- Player:SendMessage("List finished, " .. NumEntities .. " entities listed");
- return true;
-end
-
-
-
-
-
-function HandleKillEntitiesCmd(Split, Player)
- local NumEntities = 0;
-
- local KillEntity = function(Entity)
- -- kill everything except for players:
- if (Entity:GetEntityType() ~= cEntity.etPlayer) then
- Entity:Destroy();
- NumEntities = NumEntities + 1;
- end;
- end
-
- Player:SendMessage("Killing all entities...");
- Player:GetWorld():ForEachEntity(KillEntity);
- Player:SendMessage("Killed " .. NumEntities .. " entities.");
- return true;
-end
-
-
-
-
-
-function HandleWoolCmd(Split, Player)
- local Wool = cItem(E_BLOCK_WOOL, 1, E_META_WOOL_BLUE);
- Player:GetInventory():SetArmorSlot(0, Wool);
- Player:GetInventory():SetArmorSlot(1, Wool);
- Player:GetInventory():SetArmorSlot(2, Wool);
- Player:GetInventory():SetArmorSlot(3, Wool);
- Player:SendMessage("You have been bluewooled :)");
- return true;
-end
-
-
-
-
-
-function HandleTestWndCmd(a_Split, a_Player)
- local WindowType = cWindow.Hopper;
- local WindowSizeX = 5;
- local WindowSizeY = 1;
- if (#a_Split == 4) then
- WindowType = tonumber(a_Split[2]);
- WindowSizeX = tonumber(a_Split[3]);
- WindowSizeY = tonumber(a_Split[4]);
- elseif (#a_Split ~= 1) then
- a_Player:SendMessage("Usage: /testwnd [WindowType WindowSizeX WindowSizeY]");
- return true;
- end
-
- -- Test out the OnClosing callback's ability to refuse to close the window
- local attempt = 1;
- local OnClosing = function(Window, Player, CanRefuse)
- Player:SendMessage("Window closing attempt #" .. attempt .. "; CanRefuse = " .. tostring(CanRefuse));
- attempt = attempt + 1;
- return CanRefuse and (attempt <= 3); -- refuse twice, then allow, unless CanRefuse is set to true
- end
-
- -- Log the slot changes
- local OnSlotChanged = function(Window, SlotNum)
- LOG("Window \"" .. Window:GetWindowTitle() .. "\" slot " .. SlotNum .. " changed.");
- end
-
- local Window = cLuaWindow(WindowType, WindowSizeX, WindowSizeY, "TestWnd");
- local Item2 = cItem(E_ITEM_DIAMOND_SWORD, 1, 0, "1=1");
- local Item3 = cItem(E_ITEM_DIAMOND_SHOVEL);
- Item3.m_Enchantments:SetLevel(cEnchantments.enchUnbreaking, 4);
- local Item4 = cItem(Item3); -- Copy
- Item4.m_Enchantments:SetLevel(cEnchantments.enchEfficiency, 3); -- Add enchantment
- Item4.m_Enchantments:SetLevel(cEnchantments.enchUnbreaking, 5); -- Overwrite existing level
- local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3");
- Window:SetSlot(a_Player, 0, cItem(E_ITEM_DIAMOND, 64));
- Window:SetSlot(a_Player, 1, Item2);
- Window:SetSlot(a_Player, 2, Item3);
- Window:SetSlot(a_Player, 3, Item4);
- Window:SetSlot(a_Player, 4, Item5);
- Window:SetOnClosing(OnClosing);
- Window:SetOnSlotChanged(OnSlotChanged);
-
- a_Player:OpenWindow(Window);
-
- -- To make sure that the object has the correct life-management in Lua,
- -- let's garbage-collect in the following few ticks
- GCOnTick = 10;
-
- return true;
-end
-
-
-
-
-
-function HandleGCCmd(a_Split, a_Player)
- collectgarbage();
- return true;
-end
-
-
-
-
-
-
-function HandleFastCmd(a_Split, a_Player)
- if (a_Player:GetNormalMaxSpeed() <= 0.11) then
- -- The player has normal speed, set double speed:
- a_Player:SetNormalMaxSpeed(0.2);
- a_Player:SendMessage("You are now fast");
- else
- -- The player has fast speed, set normal speed:
- a_Player:SetNormalMaxSpeed(0.1);
- a_Player:SendMessage("Back to normal speed");
- end
- return true;
-end
-
-
-
-
-
-function HandleDashCmd(a_Split, a_Player)
- if (a_Player:GetSprintingMaxSpeed() <= 0.14) then
- -- The player has normal sprinting speed, set double Sprintingspeed:
- a_Player:SetSprintingMaxSpeed(0.4);
- a_Player:SendMessage("You can now sprint very fast");
- else
- -- The player has fast sprinting speed, set normal sprinting speed:
- a_Player:SetSprintingMaxSpeed(0.13);
- a_Player:SendMessage("Back to normal sprinting");
- end
- return true;
-end;
-
-
-
-
-
-function HandleHungerCmd(a_Split, a_Player)
- a_Player:SendMessage("FoodLevel: " .. a_Player:GetFoodLevel());
- a_Player:SendMessage("FoodSaturationLevel: " .. a_Player:GetFoodSaturationLevel());
- a_Player:SendMessage("FoodTickTimer: " .. a_Player:GetFoodTickTimer());
- a_Player:SendMessage("FoodExhaustionLevel: " .. a_Player:GetFoodExhaustionLevel());
- a_Player:SendMessage("FoodPoisonedTicksRemaining: " .. a_Player:GetFoodPoisonedTicksRemaining());
- return true;
-end
-
-
-
-
-
-function HandlePoisonCmd(a_Split, a_Player)
- a_Player:FoodPoison(15 * 20);
- return true;
-end
-
-
-
-
+-- Global variables
+PLUGIN = {}; -- Reference to own plugin object
+
+g_DropSpensersToActivate = {}; -- A list of dispensers and droppers (as {World, X, Y Z} quadruplets) that are to be activated every tick
+g_HungerReportTick = 10;
+
+
+
+
+
+
+function Initialize(Plugin)
+ PLUGIN = Plugin
+
+ Plugin:SetName("Debuggers")
+ Plugin:SetVersion(1)
+
+ PluginManager = cRoot:Get():GetPluginManager()
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_BLOCK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_ITEM);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_TAKE_DAMAGE);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_TICK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT);
+
+ PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "Shows a list of all the loaded entities");
+ PluginManager:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "Kills all the loaded entities");
+ PluginManager:BindCommand("/wool", "debuggers", HandleWoolCmd, "Sets all your armor to blue wool");
+ PluginManager:BindCommand("/testwnd", "debuggers", HandleTestWndCmd, "Opens up a window using plugin API");
+ PluginManager:BindCommand("/gc", "debuggers", HandleGCCmd, "Activates the Lua garbage collector");
+ PluginManager:BindCommand("/fast", "debuggers", HandleFastCmd, "Switches between fast and normal movement speed");
+ PluginManager:BindCommand("/dash", "debuggers", HandleDashCmd, "Switches between fast and normal sprinting speed");
+ PluginManager:BindCommand("/hunger", "debuggers", HandleHungerCmd, "Lists the current hunger-related variables");
+ PluginManager:BindCommand("/poison", "debuggers", HandlePoisonCmd, "Sets food-poisoning for 15 seconds");
+ PluginManager:BindCommand("/starve", "debuggers", HandleStarveCmd, "Sets the food level to zero");
+ PluginManager:BindCommand("/fl", "debuggers", HandleFoodLevelCmd, "Sets the food level to the given value");
+
+ -- Enable the following line for BlockArea / Generator interface testing:
+ -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
+
+ LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
+
+ -- TestBlockAreas();
+ -- TestSQLiteBindings();
+ -- TestExpatBindings();
+
+ return true
+end;
+
+
+
+
+
+
+function TestBlockAreas()
+ LOG("Testing block areas...");
+
+ -- Debug block area merging:
+ local BA1 = cBlockArea();
+ local BA2 = cBlockArea();
+ if (BA1:LoadFromSchematicFile("schematics/test.schematic")) then
+ if (BA2:LoadFromSchematicFile("schematics/fountain.schematic")) then
+ BA2:SetRelBlockType(0, 0, 0, E_BLOCK_LAPIS_BLOCK);
+ BA2:SetRelBlockType(1, 0, 0, E_BLOCK_LAPIS_BLOCK);
+ BA2:SetRelBlockType(2, 0, 0, E_BLOCK_LAPIS_BLOCK);
+ BA1:Merge(BA2, 1, 10, 1, cBlockArea.msImprint);
+ BA1:SaveToSchematicFile("schematics/merge.schematic");
+ end
+ else
+ BA1:Create(16, 16, 16);
+ end
+
+ -- Debug block area cuboid filling:
+ BA1:FillRelCuboid(2, 9, 2, 8, 2, 8, cBlockArea.baTypes, E_BLOCK_GOLD_BLOCK);
+ BA1:RelLine(2, 2, 2, 9, 8, 8, cBlockArea.baTypes or cBlockArea.baMetas, E_BLOCK_SAPLING, E_META_SAPLING_BIRCH);
+ BA1:SaveToSchematicFile("schematics/fillrel.schematic");
+
+ -- Debug block area mirroring:
+ if (BA1:LoadFromSchematicFile("schematics/lt.schematic")) then
+ BA1:MirrorXYNoMeta();
+ BA1:SaveToSchematicFile("schematics/lt_XY.schematic");
+ BA1:MirrorXYNoMeta();
+ BA1:SaveToSchematicFile("schematics/lt_XY2.schematic");
+
+ BA1:MirrorXZNoMeta();
+ BA1:SaveToSchematicFile("schematics/lt_XZ.schematic");
+ BA1:MirrorXZNoMeta();
+ BA1:SaveToSchematicFile("schematics/lt_XZ2.schematic");
+
+ BA1:MirrorYZNoMeta();
+ BA1:SaveToSchematicFile("schematics/lt_YZ.schematic");
+ BA1:MirrorYZNoMeta();
+ BA1:SaveToSchematicFile("schematics/lt_YZ2.schematic");
+ end
+
+ -- Debug block area rotation:
+ if (BA1:LoadFromSchematicFile("schematics/rot.schematic")) then
+ BA1:RotateCWNoMeta();
+ BA1:SaveToSchematicFile("schematics/rot1.schematic");
+ BA1:RotateCWNoMeta();
+ BA1:SaveToSchematicFile("schematics/rot2.schematic");
+ BA1:RotateCWNoMeta();
+ BA1:SaveToSchematicFile("schematics/rot3.schematic");
+ BA1:RotateCWNoMeta();
+ BA1:SaveToSchematicFile("schematics/rot4.schematic");
+ end
+
+ -- Debug block area rotation:
+ if (BA1:LoadFromSchematicFile("schematics/rotm.schematic")) then
+ BA1:RotateCCW();
+ BA1:SaveToSchematicFile("schematics/rotm1.schematic");
+ BA1:RotateCCW();
+ BA1:SaveToSchematicFile("schematics/rotm2.schematic");
+ BA1:RotateCCW();
+ BA1:SaveToSchematicFile("schematics/rotm3.schematic");
+ BA1:RotateCCW();
+ BA1:SaveToSchematicFile("schematics/rotm4.schematic");
+ end
+
+ -- Debug block area mirroring:
+ if (BA1:LoadFromSchematicFile("schematics/ltm.schematic")) then
+ BA1:MirrorXY();
+ BA1:SaveToSchematicFile("schematics/ltm_XY.schematic");
+ BA1:MirrorXY();
+ BA1:SaveToSchematicFile("schematics/ltm_XY2.schematic");
+
+ BA1:MirrorXZ();
+ BA1:SaveToSchematicFile("schematics/ltm_XZ.schematic");
+ BA1:MirrorXZ();
+ BA1:SaveToSchematicFile("schematics/ltm_XZ2.schematic");
+
+ BA1:MirrorYZ();
+ BA1:SaveToSchematicFile("schematics/ltm_YZ.schematic");
+ BA1:MirrorYZ();
+ BA1:SaveToSchematicFile("schematics/ltm_YZ2.schematic");
+ end
+
+ LOG("Block areas test ended");
+end
+
+
+
+
+
+
+function TestSQLiteBindings()
+ LOG("Testing SQLite bindings...");
+
+ -- Debug SQLite binding
+ local TestDB, ErrCode, ErrMsg = sqlite3.open("test.sqlite");
+ if (TestDB ~= nil) then
+ local function ShowRow(UserData, NumCols, Values, Names)
+ assert(UserData == 'UserData');
+ LOG("New row");
+ for i = 1, NumCols do
+ LOG(" " .. Names[i] .. " = " .. Values[i]);
+ end
+ return 0;
+ end
+ local sql = [=[
+ CREATE TABLE numbers(num1,num2,str);
+ INSERT INTO numbers VALUES(1, 11, "ABC");
+ INSERT INTO numbers VALUES(2, 22, "DEF");
+ INSERT INTO numbers VALUES(3, 33, "UVW");
+ INSERT INTO numbers VALUES(4, 44, "XYZ");
+ SELECT * FROM numbers;
+ ]=]
+ local Res = TestDB:exec(sql, ShowRow, 'UserData');
+ if (Res ~= sqlite3.OK) then
+ LOG("TestDB:exec() failed: " .. Res .. " (" .. TestDB:errmsg() .. ")");
+ end;
+ TestDB:close();
+ else
+ -- This happens if for example SQLite cannot open the file (eg. a folder with the same name exists)
+ LOG("SQLite3 failed to open DB! (" .. ErrCode .. ", " .. ErrMsg ..")");
+ end
+
+ LOG("SQLite bindings test ended");
+end
+
+
+
+
+
+function TestExpatBindings()
+ LOG("Testing Expat bindings...");
+
+ -- Debug LuaExpat bindings:
+ local count = 0
+ callbacks = {
+ StartElement = function (parser, name)
+ LOG("+ " .. string.rep(" ", count) .. name);
+ count = count + 1;
+ end,
+ EndElement = function (parser, name)
+ count = count - 1;
+ LOG("- " .. string.rep(" ", count) .. name);
+ end
+ }
+
+ local p = lxp.new(callbacks);
+ p:parse("<elem1>\nnext line\nanother line");
+ p:parse("text\n");
+ p:parse("<elem2/>\n");
+ p:parse("more text");
+ p:parse("</elem1>");
+ p:parse("\n");
+ p:parse(); -- finishes the document
+ p:close(); -- closes the parser
+
+ LOG("Expat bindings test ended");
+end
+
+
+
+
+
+function OnUsingBlazeRod(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
+ -- Magic rod of query: show block types and metas for both neighbors of the pointed face
+ local Type, Meta, Valid = Player:GetWorld():GetBlockTypeMeta(BlockX, BlockY, BlockZ, Type, Meta);
+
+ if (Type == E_BLOCK_AIR) then
+ Player:SendMessage(cChatColor.LightGray .. "Block {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}: air:" .. Meta);
+ else
+ local TempItem = cItem(Type, 1, Meta);
+ Player:SendMessage(cChatColor.LightGray .. "Block {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}: " .. ItemToFullString(TempItem) .. " (" .. Type .. ":" .. Meta .. ")");
+ end
+
+ local X, Y, Z = AddFaceDirection(BlockX, BlockY, BlockZ, BlockFace);
+ Valid, Type, Meta = Player:GetWorld():GetBlockTypeMeta(X, Y, Z, Type, Meta);
+ if (Type == E_BLOCK_AIR) then
+ Player:SendMessage(cChatColor.LightGray .. "Block {" .. X .. ", " .. Y .. ", " .. Z .. "}: air:" .. Meta);
+ else
+ local TempItem = cItem(Type, 1, Meta);
+ Player:SendMessage(cChatColor.LightGray .. "Block {" .. X .. ", " .. Y .. ", " .. Z .. "}: " .. ItemToFullString(TempItem) .. " (" .. Type .. ":" .. Meta .. ")");
+ end
+ return false;
+end
+
+
+
+
+
+function OnUsingDiamond(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
+ -- Rclk with a diamond to test block area cropping and expanding
+ local Area = cBlockArea();
+ Area:Read(Player:GetWorld(),
+ BlockX - 19, BlockX + 19,
+ BlockY - 7, BlockY + 7,
+ BlockZ - 19, BlockZ + 19
+ );
+
+ LOG("Size before cropping: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
+ Area:DumpToRawFile("crop0.dat");
+
+ Area:Crop(2, 3, 0, 0, 0, 0);
+ LOG("Size after cropping 1: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
+ Area:DumpToRawFile("crop1.dat");
+
+ Area:Crop(2, 3, 0, 0, 0, 0);
+ LOG("Size after cropping 2: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
+ Area:DumpToRawFile("crop2.dat");
+
+ Area:Expand(2, 3, 0, 0, 0, 0);
+ LOG("Size after expanding 1: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
+ Area:DumpToRawFile("expand1.dat");
+
+ Area:Expand(3, 2, 1, 1, 0, 0);
+ LOG("Size after expanding 2: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
+ Area:DumpToRawFile("expand2.dat");
+
+ Area:Crop(0, 0, 0, 0, 3, 2);
+ LOG("Size after cropping 3: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
+ Area:DumpToRawFile("crop3.dat");
+
+ Area:Crop(0, 0, 3, 2, 0, 0);
+ LOG("Size after cropping 4: " .. Area:GetSizeX() .. " x " .. Area:GetSizeY() .. " x " .. Area:GetSizeZ());
+ Area:DumpToRawFile("crop4.dat");
+
+ LOG("Crop test done");
+ Player:SendMessage("Crop / expand test done.");
+ return false;
+end
+
+
+
+
+
+function OnUsingEyeOfEnder(Player, BlockX, BlockY, BlockZ)
+ -- Rclk with an eye of ender places a predefined schematic at the cursor
+ local Area = cBlockArea();
+ if not(Area:LoadFromSchematicFile("schematics/test.schematic")) then
+ LOG("Loading failed");
+ return false;
+ end
+ LOG("Schematic loaded, placing now.");
+ Area:Write(Player:GetWorld(), BlockX, BlockY, BlockZ);
+ LOG("Done.");
+ return false;
+end
+
+
+
+
+
+function OnUsingEnderPearl(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
+ -- Rclk with an ender pearl saves a predefined area around the cursor into a .schematic file. Also tests area copying
+ local Area = cBlockArea();
+ if not(Area:Read(Player:GetWorld(),
+ BlockX - 8, BlockX + 8, BlockY - 8, BlockY + 8, BlockZ - 8, BlockZ + 8)
+ ) then
+ LOG("LUA: Area couldn't be read");
+ return false;
+ end
+ LOG("LUA: Area read, copying now.");
+ local Area2 = cBlockArea();
+ Area2:CopyFrom(Area);
+ LOG("LUA: Copied, now saving.");
+ if not(Area2:SaveToSchematicFile("schematics/test.schematic")) then
+ LOG("LUA: Cannot save schematic file.");
+ return false;
+ end
+ LOG("LUA: Done.");
+ return false;
+end
+
+
+
+
+
+function OnUsingRedstoneTorch(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
+ -- Redstone torch activates a rapid dispenser / dropper discharge (at every tick):
+ local BlockType = Player:GetWorld():GetBlock(BlockX, BlockY, BlockZ);
+ if (BlockType == E_BLOCK_DISPENSER) then
+ table.insert(g_DropSpensersToActivate, {World = Player:GetWorld(), x = BlockX, y = BlockY, z = BlockZ});
+ Player:SendMessage("Dispenser at {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "} discharging");
+ return true;
+ elseif (BlockType == E_BLOCK_DROPPER) then
+ table.insert(g_DropSpensersToActivate, {World = Player:GetWorld(), x = BlockX, y = BlockY, z = BlockZ});
+ Player:SendMessage("Dropper at {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "} discharging");
+ return true;
+ else
+ Player:SendMessage("Neither a dispenser nor a dropper at {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}: " .. BlockType);
+ end
+ return false;
+end
+
+
+
+
+
+function OnPlayerUsingItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
+
+ -- dont check if the direction is in the air
+ if (BlockFace == BLOCK_FACE_NONE) then
+ return false
+ end
+
+ local HeldItem = Player:GetEquippedItem();
+ local HeldItemType = HeldItem.m_ItemType;
+
+ if (HeldItemType == E_ITEM_STICK) then
+ -- Magic sTick of ticking: set the pointed block for ticking at the next tick
+ Player:SendMessage(cChatColor.LightGray .. "Setting next block tick to {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}")
+ Player:GetWorld():SetNextBlockTick(BlockX, BlockY, BlockZ);
+ return true
+ elseif (HeldItemType == E_ITEM_BLAZE_ROD) then
+ return OnUsingBlazeRod(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
+ elseif (HeldItemType == E_ITEM_DIAMOND) then
+ return OnUsingDiamond(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
+ elseif (HeldItemType == E_ITEM_EYE_OF_ENDER) then
+ return OnUsingEyeOfEnder(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
+ elseif (HeldItemType == E_ITEM_ENDER_PEARL) then
+ return OnUsingEnderPearl(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
+ end
+ return false;
+end
+
+
+
+
+
+function OnPlayerUsingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType, BlockMeta)
+ -- dont check if the direction is in the air
+ if (BlockFace == BLOCK_FACE_NONE) then
+ return false
+ end
+
+ local HeldItem = Player:GetEquippedItem();
+ local HeldItemType = HeldItem.m_ItemType;
+
+ if (HeldItemType == E_BLOCK_REDSTONE_TORCH_ON) then
+ return OnUsingRedstoneTorch(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ);
+ end
+end
+
+
+
+
+
+function OnTakeDamage(Receiver, TDI)
+ -- Receiver is cPawn
+ -- TDI is TakeDamageInfo
+
+ LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)");
+ return false;
+end
+
+
+
+
+
+--- When set to a positive number, the following OnTick() will perform GC and decrease until 0 again
+GCOnTick = 0;
+
+
+
+
+
+function OnTick()
+ -- Activate all dropspensers in the g_DropSpensersToActivate list:
+ local ActivateDrSp = function(DropSpenser)
+ if (DropSpenser:GetContents():GetFirstUsedSlot() == -1) then
+ return true;
+ end
+ DropSpenser:Activate();
+ return false;
+ end
+ -- Walk the list backwards, because we're removing some items
+ local idx = #g_DropSpensersToActivate;
+ for i = idx, 1, -1 do
+ local DrSp = g_DropSpensersToActivate[i];
+ if not(DrSp.World:DoWithDropSpenserAt(DrSp.x, DrSp.y, DrSp.z, ActivateDrSp)) then
+ table.remove(g_DropSpensersToActivate, i);
+ end
+ end
+
+
+ -- If GCOnTick > 0, do a garbage-collect and decrease by one
+ if (GCOnTick > 0) then
+ collectgarbage();
+ GCOnTick = GCOnTick - 1;
+ end
+
+ --[[
+ if (g_HungerReportTick > 0) then
+ g_HungerReportTick = g_HungerReportTick - 1;
+ else
+ g_HungerReportTick = 10;
+ cRoot:Get():GetDefaultWorld():ForEachPlayer(
+ function(a_Player)
+ a_Player:SendMessage("FoodStat: " .. a_Player:GetFoodLevel() .. " / " .. a_Player:GetFoodExhaustionLevel());
+ end
+ );
+ end
+ ]]
+
+ return false;
+end
+
+
+
+
+
+function OnChunkGenerated(World, ChunkX, ChunkZ, ChunkDesc)
+ -- Test ChunkDesc / BlockArea interaction
+ local BlockArea = cBlockArea();
+ ChunkDesc:ReadBlockArea(BlockArea, 0, 15, 50, 70, 0, 15);
+
+ -- BlockArea:SaveToSchematicFile("ChunkBlocks_" .. ChunkX .. "_" .. ChunkZ .. ".schematic");
+
+ ChunkDesc:WriteBlockArea(BlockArea, 5, 115, 5);
+ return false;
+end
+
+
+
+
+
+function OnChat(a_Player, a_Message)
+ return false, "blabla " .. a_Message;
+end
+
+
+
+
+
+-- Function "round" copied from http://lua-users.org/wiki/SimpleRound
+function round(num, idp)
+ local mult = 10^(idp or 0)
+ if num >= 0 then return math.floor(num * mult + 0.5) / mult
+ else return math.ceil(num * mult - 0.5) / mult end
+end
+
+
+
+
+
+function HandleListEntitiesCmd(Split, Player)
+ local NumEntities = 0;
+
+ local ListEntity = function(Entity)
+ if (Entity:IsDestroyed()) then
+ -- The entity has already been destroyed, don't list it
+ return false;
+ end;
+ Player:SendMessage(" " .. Entity:GetUniqueID() .. ": " .. Entity:GetClass() .. " {" .. round(Entity:GetPosX(), 2) .. ", " .. round(Entity:GetPosY(), 2) .. ", " .. round(Entity:GetPosZ(), 2) .."}");
+ NumEntities = NumEntities + 1;
+ end
+
+ Player:SendMessage("Listing all entities...");
+ Player:GetWorld():ForEachEntity(ListEntity);
+ Player:SendMessage("List finished, " .. NumEntities .. " entities listed");
+ return true;
+end
+
+
+
+
+
+function HandleKillEntitiesCmd(Split, Player)
+ local NumEntities = 0;
+
+ local KillEntity = function(Entity)
+ -- kill everything except for players:
+ if (Entity:GetEntityType() ~= cEntity.etPlayer) then
+ Entity:Destroy();
+ NumEntities = NumEntities + 1;
+ end;
+ end
+
+ Player:SendMessage("Killing all entities...");
+ Player:GetWorld():ForEachEntity(KillEntity);
+ Player:SendMessage("Killed " .. NumEntities .. " entities.");
+ return true;
+end
+
+
+
+
+
+function HandleWoolCmd(Split, Player)
+ local Wool = cItem(E_BLOCK_WOOL, 1, E_META_WOOL_BLUE);
+ Player:GetInventory():SetArmorSlot(0, Wool);
+ Player:GetInventory():SetArmorSlot(1, Wool);
+ Player:GetInventory():SetArmorSlot(2, Wool);
+ Player:GetInventory():SetArmorSlot(3, Wool);
+ Player:SendMessage("You have been bluewooled :)");
+ return true;
+end
+
+
+
+
+
+function HandleTestWndCmd(a_Split, a_Player)
+ local WindowType = cWindow.Hopper;
+ local WindowSizeX = 5;
+ local WindowSizeY = 1;
+ if (#a_Split == 4) then
+ WindowType = tonumber(a_Split[2]);
+ WindowSizeX = tonumber(a_Split[3]);
+ WindowSizeY = tonumber(a_Split[4]);
+ elseif (#a_Split ~= 1) then
+ a_Player:SendMessage("Usage: /testwnd [WindowType WindowSizeX WindowSizeY]");
+ return true;
+ end
+
+ -- Test out the OnClosing callback's ability to refuse to close the window
+ local attempt = 1;
+ local OnClosing = function(Window, Player, CanRefuse)
+ Player:SendMessage("Window closing attempt #" .. attempt .. "; CanRefuse = " .. tostring(CanRefuse));
+ attempt = attempt + 1;
+ return CanRefuse and (attempt <= 3); -- refuse twice, then allow, unless CanRefuse is set to true
+ end
+
+ -- Log the slot changes
+ local OnSlotChanged = function(Window, SlotNum)
+ LOG("Window \"" .. Window:GetWindowTitle() .. "\" slot " .. SlotNum .. " changed.");
+ end
+
+ local Window = cLuaWindow(WindowType, WindowSizeX, WindowSizeY, "TestWnd");
+ local Item2 = cItem(E_ITEM_DIAMOND_SWORD, 1, 0, "1=1");
+ local Item3 = cItem(E_ITEM_DIAMOND_SHOVEL);
+ Item3.m_Enchantments:SetLevel(cEnchantments.enchUnbreaking, 4);
+ local Item4 = cItem(Item3); -- Copy
+ Item4.m_Enchantments:SetLevel(cEnchantments.enchEfficiency, 3); -- Add enchantment
+ Item4.m_Enchantments:SetLevel(cEnchantments.enchUnbreaking, 5); -- Overwrite existing level
+ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3");
+ Window:SetSlot(a_Player, 0, cItem(E_ITEM_DIAMOND, 64));
+ Window:SetSlot(a_Player, 1, Item2);
+ Window:SetSlot(a_Player, 2, Item3);
+ Window:SetSlot(a_Player, 3, Item4);
+ Window:SetSlot(a_Player, 4, Item5);
+ Window:SetOnClosing(OnClosing);
+ Window:SetOnSlotChanged(OnSlotChanged);
+
+ a_Player:OpenWindow(Window);
+
+ -- To make sure that the object has the correct life-management in Lua,
+ -- let's garbage-collect in the following few ticks
+ GCOnTick = 10;
+
+ return true;
+end
+
+
+
+
+
+function HandleGCCmd(a_Split, a_Player)
+ collectgarbage();
+ return true;
+end
+
+
+
+
+
+
+function HandleFastCmd(a_Split, a_Player)
+ if (a_Player:GetNormalMaxSpeed() <= 0.11) then
+ -- The player has normal speed, set double speed:
+ a_Player:SetNormalMaxSpeed(0.2);
+ a_Player:SendMessage("You are now fast");
+ else
+ -- The player has fast speed, set normal speed:
+ a_Player:SetNormalMaxSpeed(0.1);
+ a_Player:SendMessage("Back to normal speed");
+ end
+ return true;
+end
+
+
+
+
+
+function HandleDashCmd(a_Split, a_Player)
+ if (a_Player:GetSprintingMaxSpeed() <= 0.14) then
+ -- The player has normal sprinting speed, set double Sprintingspeed:
+ a_Player:SetSprintingMaxSpeed(0.4);
+ a_Player:SendMessage("You can now sprint very fast");
+ else
+ -- The player has fast sprinting speed, set normal sprinting speed:
+ a_Player:SetSprintingMaxSpeed(0.13);
+ a_Player:SendMessage("Back to normal sprinting");
+ end
+ return true;
+end;
+
+
+
+
+
+function HandleHungerCmd(a_Split, a_Player)
+ a_Player:SendMessage("FoodLevel: " .. a_Player:GetFoodLevel());
+ a_Player:SendMessage("FoodSaturationLevel: " .. a_Player:GetFoodSaturationLevel());
+ a_Player:SendMessage("FoodTickTimer: " .. a_Player:GetFoodTickTimer());
+ a_Player:SendMessage("FoodExhaustionLevel: " .. a_Player:GetFoodExhaustionLevel());
+ a_Player:SendMessage("FoodPoisonedTicksRemaining: " .. a_Player:GetFoodPoisonedTicksRemaining());
+ return true;
+end
+
+
+
+
+
+function HandlePoisonCmd(a_Split, a_Player)
+ a_Player:FoodPoison(15 * 20);
+ return true;
+end
+
+
+
+
+
+function HandleStarveCmd(a_Split, a_Player)
+ a_Player:SetFoodLevel(0);
+ a_Player:SendMessage("You are now starving");
+ return true;
+end
+
+
+
+
+
+function HandleFoodLevelCmd(a_Split, a_Player)
+ if (#a_Split ~= 2) then
+ a_Player:SendMessage("Missing an argument: the food level to set");
+ return true;
+ end
+
+ a_Player:SetFoodLevel(tonumber(a_Split[2]));
+ a_Player:SendMessage("Food level set to " .. a_Player:GetFoodLevel());
+ return true;
+end
+
+
+
+
diff --git a/MCServer/Plugins/DiamondMover/DiamondMover.lua b/MCServer/Plugins/DiamondMover/DiamondMover.lua
index eaced1058..c89a3394f 100644
--- a/MCServer/Plugins/DiamondMover/DiamondMover.lua
+++ b/MCServer/Plugins/DiamondMover/DiamondMover.lua
@@ -1,83 +1,83 @@
-
--- DiamondMover.lua
-
--- An example Lua plugin using the cBlockArea object
--- When a player rclks with a diamond in their hand, an area around the clicked block is moved in the direction the player is facing
-
-
-
-
-
--- Global variables
-PLUGIN = {} -- Reference to own plugin object
-MOVER_SIZE_X = 4;
-MOVER_SIZE_Y = 4;
-MOVER_SIZE_Z = 4;
-
-
-
-
-
-function Initialize(Plugin)
- PLUGIN = Plugin;
-
- Plugin:SetName("DiamondMover");
- Plugin:SetVersion(1);
-
- PluginManager = cRoot:Get():GetPluginManager();
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USED_ITEM);
- return true;
-end
-
-
-
-
-
-function OnPlayerUsedItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
-
- -- Don't check if the direction is in the air
- if (BlockFace == -1) then
- return false;
- end;
-
- if (Player:HasPermission("diamondmover.move") == false) then
- return true;
- end;
-
- -- Rclk with a diamond to push in the direction the player is facing
- if (Player:GetEquippedItem().m_ItemType == E_ITEM_DIAMOND) then
- local Area = cBlockArea();
- Area:Read(Player:GetWorld(),
- BlockX - MOVER_SIZE_X, BlockX + MOVER_SIZE_X,
- BlockY - MOVER_SIZE_Y, BlockY + MOVER_SIZE_Y,
- BlockZ - MOVER_SIZE_Z, BlockZ + MOVER_SIZE_Z
- );
-
- local PlayerPitch = Player:GetPitch();
- if (PlayerPitch < -70) then -- looking up
- BlockY = BlockY + 1;
- else
- if (PlayerPitch > 70) then -- looking down
- BlockY = BlockY - 1;
- else
- local PlayerRot = Player:GetRotation() + 180; -- Convert [-180, 180] into [0, 360] for simpler conditions
- if ((PlayerRot < 45) or (PlayerRot > 315)) then
- BlockZ = BlockZ - 1;
- else
- if (PlayerRot < 135) then
- BlockX = BlockX + 1;
- else
- if (PlayerRot < 225) then
- BlockZ = BlockZ + 1;
- else
- BlockX = BlockX - 1;
- end;
- end;
- end;
- end;
- end;
-
- Area:Write(Player:GetWorld(), BlockX - MOVER_SIZE_X, BlockY - MOVER_SIZE_Y, BlockZ - MOVER_SIZE_Z);
- return false;
- end
+
+-- DiamondMover.lua
+
+-- An example Lua plugin using the cBlockArea object
+-- When a player rclks with a diamond in their hand, an area around the clicked block is moved in the direction the player is facing
+
+
+
+
+
+-- Global variables
+PLUGIN = {} -- Reference to own plugin object
+MOVER_SIZE_X = 4;
+MOVER_SIZE_Y = 4;
+MOVER_SIZE_Z = 4;
+
+
+
+
+
+function Initialize(Plugin)
+ PLUGIN = Plugin;
+
+ Plugin:SetName("DiamondMover");
+ Plugin:SetVersion(1);
+
+ PluginManager = cRoot:Get():GetPluginManager();
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USED_ITEM);
+ return true;
+end
+
+
+
+
+
+function OnPlayerUsedItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
+
+ -- Don't check if the direction is in the air
+ if (BlockFace == -1) then
+ return false;
+ end;
+
+ if (Player:HasPermission("diamondmover.move") == false) then
+ return true;
+ end;
+
+ -- Rclk with a diamond to push in the direction the player is facing
+ if (Player:GetEquippedItem().m_ItemType == E_ITEM_DIAMOND) then
+ local Area = cBlockArea();
+ Area:Read(Player:GetWorld(),
+ BlockX - MOVER_SIZE_X, BlockX + MOVER_SIZE_X,
+ BlockY - MOVER_SIZE_Y, BlockY + MOVER_SIZE_Y,
+ BlockZ - MOVER_SIZE_Z, BlockZ + MOVER_SIZE_Z
+ );
+
+ local PlayerPitch = Player:GetPitch();
+ if (PlayerPitch < -70) then -- looking up
+ BlockY = BlockY + 1;
+ else
+ if (PlayerPitch > 70) then -- looking down
+ BlockY = BlockY - 1;
+ else
+ local PlayerRot = Player:GetRotation() + 180; -- Convert [-180, 180] into [0, 360] for simpler conditions
+ if ((PlayerRot < 45) or (PlayerRot > 315)) then
+ BlockZ = BlockZ - 1;
+ else
+ if (PlayerRot < 135) then
+ BlockX = BlockX + 1;
+ else
+ if (PlayerRot < 225) then
+ BlockZ = BlockZ + 1;
+ else
+ BlockX = BlockX - 1;
+ end;
+ end;
+ end;
+ end;
+ end;
+
+ Area:Write(Player:GetWorld(), BlockX - MOVER_SIZE_X, BlockY - MOVER_SIZE_Y, BlockZ - MOVER_SIZE_Z);
+ return false;
+ end
end \ No newline at end of file
diff --git a/MCServer/Plugins/Handy/handy.lua b/MCServer/Plugins/Handy/handy.lua
index c2330abab..6d226ccaf 100644
--- a/MCServer/Plugins/Handy/handy.lua
+++ b/MCServer/Plugins/Handy/handy.lua
@@ -1,28 +1,28 @@
--- Global variables
-PLUGIN = {} -- Reference to own plugin object
-CHEST_WIDTH = 9
-HANDY_VERSION = 1
---[[
-
-Handy is a plugin for other plugins. It contain no commands, no hooks, but functions to ease plugins developers' life.
-
-API:
-
-
-TODO:
-1. GetChestSlot wrapper, so it will detect double chest neighbour chest and will be able to access it.
-]]
-
-function Initialize(Plugin)
- PLUGIN = Plugin
- PLUGIN:SetName("Handy")
- PLUGIN:SetVersion(HANDY_VERSION)
-
- PluginManager = cRoot:Get():GetPluginManager()
- LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
- return true
-end
-
-function OnDisable()
- LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...")
+-- Global variables
+PLUGIN = {} -- Reference to own plugin object
+CHEST_WIDTH = 9
+HANDY_VERSION = 1
+--[[
+
+Handy is a plugin for other plugins. It contain no commands, no hooks, but functions to ease plugins developers' life.
+
+API:
+
+
+TODO:
+1. GetChestSlot wrapper, so it will detect double chest neighbour chest and will be able to access it.
+]]
+
+function Initialize(Plugin)
+ PLUGIN = Plugin
+ PLUGIN:SetName("Handy")
+ PLUGIN:SetVersion(HANDY_VERSION)
+
+ PluginManager = cRoot:Get():GetPluginManager()
+ LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
+ return true
+end
+
+function OnDisable()
+ LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...")
end \ No newline at end of file
diff --git a/MCServer/Plugins/Handy/handy_functions.lua b/MCServer/Plugins/Handy/handy_functions.lua
index f8423312f..a76980c6e 100644
--- a/MCServer/Plugins/Handy/handy_functions.lua
+++ b/MCServer/Plugins/Handy/handy_functions.lua
@@ -1,355 +1,355 @@
---[[
-General stuff
-]]
--- Returns Handy plugin version number
-function GetHandyVersion()
- return HANDY_VERSION
-end
--- Checks if handy is in proper version
-function CheckForRequiedVersion(IN_version)
- if (IN_version > HANDY_VERSION) then return false end
- return true
-end
---[[
-MCS-specific _functions and nasty hacks :D
-]]
--- There's a "GetChestHeight" function inside source code, but it's not lua-exported
-function GetChestHeightCheat(IN_chest)
- if (IN_chest:GetSlot(28) == nil) then -- this means we're trying to get double chest slot and FAIL
- LOGWARN("HANDY: single chest checked")
- return 3
- end
- LOGWARN("HANDY: double chest checked")
- return 6
-end
--- Those two checks how many items of given IN_itemID chest and player have, and how much they could fit inside them
-function ReadChestForItem(IN_chest, IN_itemID)
- local _items_found = 0
- local _free_space = 0
- -- stalk through chest slots...
- local _slot_counter = 0
- local _slot_item
- local _item_max_stack = GetItemMaxStack(IN_itemID)
- while true do
- _slot_item = IN_chest:GetSlot(_slot_counter)
- if (_slot_item ~= nil) then
- if (_slot_item.m_ItemID == IN_itemID) then
- _items_found = _items_found + _slot_item.m_ItemCount
- _free_space = _free_space + (_item_max_stack - _slot_item.m_ItemCount)
- end
- if (_slot_item:IsEmpty() == true) then
- _free_space = _free_space + _item_max_stack
- end
- end
- _slot_counter = _slot_counter + 1
- if (_slot_counter == CHEST_WIDTH*GetChestHeightCheat(IN_chest)) then
- break
- end
- end
- return _items_found, _free_space
-end
-function ReadPlayerForItem(IN_player, IN_itemID)
- local _items_found = 0
- local _free_space = 0
- -- stalk through IN_player inventory slots...
- local _slot_counter = 9
- if (ItemIsArmor(IN_itemID) == true) then _slot_counter = 5 end
- local _slot_item
- local _item_max_stack = GetItemMaxStack(IN_itemID)
- while true do
- _slot_item = IN_player:GetInventory():GetSlot(_slot_counter)
- if (_slot_item ~= nil) then
- if (_slot_item.m_ItemID == IN_itemID) then
- _items_found = _items_found + _slot_item.m_ItemCount
- _free_space = _free_space + (_item_max_stack - _slot_item.m_ItemCount)
- end
- if (_slot_item:IsEmpty() == true) then
- _free_space = _free_space + _item_max_stack
- end
- end
- _slot_counter = _slot_counter + 1
- if (_slot_counter == 45) then
- break
- end
- end
- return _items_found, _free_space
-end
--- Following functions are for chest-related operations (since noone was bothered writing them in MCS code)
--- BEWARE! Those assume you did checked if chest has items/space in it!
-function TakeItemsFromChest(IN_chest, IN_itemID, IN_ammount) -- UNSAFE! CHECK FOR ITEMS FIRST!!
- -- stalk through chest slots...
- local _slot_counter = 0
- local _slot_item
- local _take_count = IN_ammount
- while true do
- _slot_item = IN_chest:GetSlot(_slot_counter)
- if (_slot_item ~= nil) then
- if (_slot_item.m_ItemID == IN_itemID) then
- -- assuming player have enought money
- if (_take_count > 0) then
- if (_take_count > _slot_item.m_ItemCount) then
- _take_count = _take_count - _slot_item.m_ItemCount
- IN_chest:SetSlot(_slot_counter, cItem()) -- a bit hacky, can't make cItem:Clear() work(
- else
- local _left_count = _slot_item.m_ItemCount - _take_count
- IN_chest:SetSlot(_slot_counter, cItem(_slot_item.m_ItemID, _left_count)) -- a bit hacky
- _take_count = 0
- end
- end
- if (_take_count == 0) then
- break
- end
- end
- end
- _slot_counter = _slot_counter + 1
- if (_slot_counter == CHEST_WIDTH*GetChestHeightCheat(IN_chest)) then
- break
- end
- end
-end
-function PutItemsToChest(IN_chest, IN_itemID, IN_ammount) -- UNSAFE! CHECK FOR SPACE FIRST!!
- -- stalk through chest slots...
- local _slot_counter = 0
- local _slot_item
- local _put_count = IN_ammount
- local _max_stack = GetItemMaxStack(IN_itemID)
- while true do
- _slot_item = IN_chest:GetSlot(_slot_counter)
- local _portion = 0
- local _ammount_to_set = 0
- if (_slot_item ~= nil) then
- if (_slot_item:IsEmpty() == true) then
- _portion = math.min(_max_stack, _put_count)
- _ammount_to_set = _portion
- else
- if (_slot_item.m_ItemID == IN_itemID) then
- -- choose between how much we need to put and how much free space left
- _portion = math.min(_put_count, _max_stack - _slot_item.m_ItemCount)
- _ammount_to_set = _slot_item.m_ItemCount + _portion
- end
- end
- end
- IN_chest:SetSlot(_slot_counter, cItem(IN_itemID, _ammount_to_set)) -- we add max stack to chest
- _put_count = _put_count - _portion
- if (_put_count == 0) then break end
- _slot_counter = _slot_counter + 1
- if (_slot_counter == CHEST_WIDTH*GetChestHeightCheat(IN_chest)) then
- break
- end
- end
-end
--- Similar to chest-related.
-function TakeItemsFromPlayer(IN_player, IN_itemID, IN_ammount) -- UNSAFE! CHECK FIRST!
- local _put_count = IN_ammount
- local _max_stack = GetItemMaxStack(IN_itemID)
- while true do
- local _portion = math.min(_max_stack, _put_count)
- IN_player:GetInventory():RemoveItem(cItem(IN_itemID, _portion))
- _put_count = _put_count - _portion
- if (_put_count == 0) then break end
- end
-end
-function GiveItemsToPlayer(IN_player, IN_itemID, IN_ammount) -- UNSAFE! CHECK FIRST!
- local _put_count = IN_ammount
- local _max_stack = GetItemMaxStack(IN_itemID)
- while true do
- local _portion = math.min(_max_stack, _put_count)
- IN_player:GetInventory():AddItem(cItem(IN_itemID, _portion))
- _put_count = _put_count - _portion
- if (_put_count == 0) then break end
- end
-end
--- This function returns item max stack for a given itemID. It uses vanilla max stack size, and uses several non-common items notations;
--- Those are:
--- oneonerecord (because aparently 11record wasn't the best idea in lua scripting application)
--- carrotonastick (because it wasn't added to items.txt yet)
--- waitrecord (for same reason)
--- Feel free to ignore the difference, or to add those to items.txt
-function GetItemMaxStack(IN_itemID)
- local _result = 64
- -- Tools and swords
- if (IN_itemID == woodensword) then _result = 1 end
- if (IN_itemID == woodenshovel) then _result = 1 end
- if (IN_itemID == woodenpickaxe) then _result = 1 end
- if (IN_itemID == woodenaxe) then _result = 1 end
- if (IN_itemID == woodenhoe) then _result = 1 end
- if (IN_itemID == stonesword) then _result = 1 end
- if (IN_itemID == stoneshovel) then _result = 1 end
- if (IN_itemID == stonepickaxe) then _result = 1 end
- if (IN_itemID == stoneaxe) then _result = 1 end
- if (IN_itemID == stonehoe) then _result = 1 end
- if (IN_itemID == ironsword) then _result = 1 end
- if (IN_itemID == ironshovel) then _result = 1 end
- if (IN_itemID == ironpickaxe) then _result = 1 end
- if (IN_itemID == ironaxe) then _result = 1 end
- if (IN_itemID == ironhoe) then _result = 1 end
- if (IN_itemID == diamondsword) then _result = 1 end
- if (IN_itemID == diamondshovel) then _result = 1 end
- if (IN_itemID == diamondpickaxe) then _result = 1 end
- if (IN_itemID == diamondaxe) then _result = 1 end
- if (IN_itemID == diamondhoe) then _result = 1 end
- if (IN_itemID == goldensword) then _result = 1 end
- if (IN_itemID == goldenshovel) then _result = 1 end
- if (IN_itemID == goldenpickaxe) then _result = 1 end
- if (IN_itemID == goldenaxe) then _result = 1 end
- if (IN_itemID == goldenhoe) then _result = 1 end
-
- if (IN_itemID == flintandsteel) then _result = 1 end
- if (IN_itemID == bow) then _result = 1 end
- if (IN_itemID == sign) then _result = 16 end
- if (IN_itemID == woodendoor) then _result = 1 end
- if (IN_itemID == irondoor) then _result = 1 end
- if (IN_itemID == cake) then _result = 1 end
- if (IN_itemID == cauldron) then _result = 1 end
- if (IN_itemID == mushroomstew) then _result = 1 end
- if (IN_itemID == painting) then _result = 1 end
- if (IN_itemID == bucket) then _result = 16 end
- if (IN_itemID == waterbucket) then _result = 1 end
- if (IN_itemID == lavabucket) then _result = 1 end
- if (IN_itemID == minecart) then _result = 1 end
- if (IN_itemID == saddle) then _result = 1 end
- if (IN_itemID == snowball) then _result = 16 end
- if (IN_itemID == boat) then _result = 1 end
- if (IN_itemID == milkbucket) then _result = 1 end
- if (IN_itemID == storageminecart) then _result = 1 end
- if (IN_itemID == poweredminecart) then _result = 1 end
- if (IN_itemID == egg) then _result = 16 end
- if (IN_itemID == fishingrod) then _result = 1 end
- if (IN_itemID == bed) then _result = 1 end
- if (IN_itemID == map) then _result = 1 end
- if (IN_itemID == shears) then _result = 1 end
- if (IN_itemID == enderpearl) then _result = 16 end
- if (IN_itemID == potion) then _result = 1 end
- if (IN_itemID == spawnegg) then _result = 1 end
- if (IN_itemID == bookandquill) then _result = 1 end
- if (IN_itemID == writtenbook) then _result = 1 end
- if (IN_itemID == carrotonastick) then _result = 1 end
-
- if (IN_itemID == goldrecord) then _result = 1 end
- if (IN_itemID == greenrecord) then _result = 1 end
- if (IN_itemID == blocksrecord) then _result = 1 end
- if (IN_itemID == chirprecord) then _result = 1 end
- if (IN_itemID == farrecord) then _result = 1 end
- if (IN_itemID == mallrecord) then _result = 1 end
- if (IN_itemID == mellohirecord) then _result = 1 end
- if (IN_itemID == stalrecord) then _result = 1 end
- if (IN_itemID == stradrecord) then _result = 1 end
- if (IN_itemID == wardrecord) then _result = 1 end
- if (IN_itemID == oneonerecord) then _result = 1 end
- if (IN_itemID == waitrecord) then _result = 1 end
-
- --if (IN_itemID == xxxxxxxxx) then _result = 1 end
-
- if (IN_itemID == leatherhelmet) then _result = 1 end
- if (IN_itemID == leatherchestplate) then _result = 1 end
- if (IN_itemID == leatherpants) then _result = 1 end
- if (IN_itemID == leatherboots) then _result = 1 end
-
- if (IN_itemID == chainmailhelmet) then _result = 1 end
- if (IN_itemID == chainmailchestplate) then _result = 1 end
- if (IN_itemID == chainmailpants) then _result = 1 end
- if (IN_itemID == chainmailboots) then _result = 1 end
-
- if (IN_itemID == ironhelmet) then _result = 1 end
- if (IN_itemID == ironchestplate) then _result = 1 end
- if (IN_itemID == ironpants) then _result = 1 end
- if (IN_itemID == ironboots) then _result = 1 end
-
- if (IN_itemID == diamondhelmet) then _result = 1 end
- if (IN_itemID == diamondchestplate) then _result = 1 end
- if (IN_itemID == diamondpants) then _result = 1 end
- if (IN_itemID == diamondboots) then _result = 1 end
-
- if (IN_itemID == goldenhelmet) then _result = 1 end
- if (IN_itemID == goldenchestplate) then _result = 1 end
- if (IN_itemID == goldenpants) then _result = 1 end
- if (IN_itemID == goldenboots) then _result = 1 end
- return _result
-end
-function ItemIsArmor(IN_itemID)
- local _result = false
- if (IN_itemID == leatherhelmet) then _result = true end
- if (IN_itemID == leatherchestplate) then _result = true end
- if (IN_itemID == leatherpants) then _result = true end
- if (IN_itemID == leatherboots) then _result = true end
-
- if (IN_itemID == chainmailhelmet) then _result = true end
- if (IN_itemID == chainmailchestplate) then _result = true end
- if (IN_itemID == chainmailpants) then _result = true end
- if (IN_itemID == chainmailboots) then _result = true end
-
- if (IN_itemID == ironhelmet) then _result = true end
- if (IN_itemID == ironchestplate) then _result = true end
- if (IN_itemID == ironpants) then _result = true end
- if (IN_itemID == ironboots) then _result = true end
-
- if (IN_itemID == diamondhelmet) then _result = true end
- if (IN_itemID == diamondchestplate) then _result = true end
- if (IN_itemID == diamondpants) then _result = true end
- if (IN_itemID == diamondboots) then _result = true end
-
- if (IN_itemID == goldenhelmet) then _result = true end
- if (IN_itemID == goldenchestplate) then _result = true end
- if (IN_itemID == goldenpants) then _result = true end
- if (IN_itemID == goldenboots) then _result = true end
- return _result
-end
--- Returns full-length playername for a short name (usefull for parsing commands)
-function GetExactPlayername(IN_playername)
- local _result = IN_playername
- local function SetProcessingPlayername(IN_player)
- _result = IN_player:GetName()
- end
- cRoot:Get():FindAndDoWithPlayer(IN_playername, SetProcessingPlayername)
- return _result
-end
-function GetPlayerByName(IN_playername)
- local _player
- local PlayerSetter = function (Player)
- _player = Player
- end
- cRoot:Get():FindAndDoWithPlayer(IN_playername, PlayerSetter)
- return _player
-end
---[[
-Not-so-usual math _functions
-]]
--- Rounds floating point number. Because lua guys think this function doesn't deserve to be presented in lua's math
-function round(IN_x)
- if (IN_x%2 ~= 0.5) then
- return math.floor(IN_x+0.5)
- end
- return IN_x-0.5
-end
---[[
-Functions I use for filework and stringswork
-]]
-function PluralString(IN_value, IN_singular_string, IN_plural_string)
- local _value_string = tostring(IN_value)
- if (_value_string[#_value_string] == "1") then
- return IN_singular_string
- end
- return IN_plural_string
-end
-function PluralItemName(IN_itemID, IN_ammount) -- BEWARE! TEMPORAL SOLUTION THERE! :D
- local _value_string = tostring(IN_value)
- local _name = ""
- if (_value_string[#_value_string] == "1") then
- -- singular names
- _name = ItemTypeToString(IN_itemID)
- else
- -- plural names
- _name = ItemTypeToString(IN_itemID).."s"
- end
- return _name
-end
--- for filewriting purposes. 0 = false, 1 = true
-function StringToBool(value)
- if value=="1" then return true end
- return false
-end
--- same, but reversal
-function BoolToString(value)
- if value==true then return 1 end
- return 0
+--[[
+General stuff
+]]
+-- Returns Handy plugin version number
+function GetHandyVersion()
+ return HANDY_VERSION
+end
+-- Checks if handy is in proper version
+function CheckForRequiedVersion(IN_version)
+ if (IN_version > HANDY_VERSION) then return false end
+ return true
+end
+--[[
+MCS-specific _functions and nasty hacks :D
+]]
+-- There's a "GetChestHeight" function inside source code, but it's not lua-exported
+function GetChestHeightCheat(IN_chest)
+ if (IN_chest:GetSlot(28) == nil) then -- this means we're trying to get double chest slot and FAIL
+ LOGWARN("HANDY: single chest checked")
+ return 3
+ end
+ LOGWARN("HANDY: double chest checked")
+ return 6
+end
+-- Those two checks how many items of given IN_itemID chest and player have, and how much they could fit inside them
+function ReadChestForItem(IN_chest, IN_itemID)
+ local _items_found = 0
+ local _free_space = 0
+ -- stalk through chest slots...
+ local _slot_counter = 0
+ local _slot_item
+ local _item_max_stack = GetItemMaxStack(IN_itemID)
+ while true do
+ _slot_item = IN_chest:GetSlot(_slot_counter)
+ if (_slot_item ~= nil) then
+ if (_slot_item.m_ItemID == IN_itemID) then
+ _items_found = _items_found + _slot_item.m_ItemCount
+ _free_space = _free_space + (_item_max_stack - _slot_item.m_ItemCount)
+ end
+ if (_slot_item:IsEmpty() == true) then
+ _free_space = _free_space + _item_max_stack
+ end
+ end
+ _slot_counter = _slot_counter + 1
+ if (_slot_counter == CHEST_WIDTH*GetChestHeightCheat(IN_chest)) then
+ break
+ end
+ end
+ return _items_found, _free_space
+end
+function ReadPlayerForItem(IN_player, IN_itemID)
+ local _items_found = 0
+ local _free_space = 0
+ -- stalk through IN_player inventory slots...
+ local _slot_counter = 9
+ if (ItemIsArmor(IN_itemID) == true) then _slot_counter = 5 end
+ local _slot_item
+ local _item_max_stack = GetItemMaxStack(IN_itemID)
+ while true do
+ _slot_item = IN_player:GetInventory():GetSlot(_slot_counter)
+ if (_slot_item ~= nil) then
+ if (_slot_item.m_ItemID == IN_itemID) then
+ _items_found = _items_found + _slot_item.m_ItemCount
+ _free_space = _free_space + (_item_max_stack - _slot_item.m_ItemCount)
+ end
+ if (_slot_item:IsEmpty() == true) then
+ _free_space = _free_space + _item_max_stack
+ end
+ end
+ _slot_counter = _slot_counter + 1
+ if (_slot_counter == 45) then
+ break
+ end
+ end
+ return _items_found, _free_space
+end
+-- Following functions are for chest-related operations (since noone was bothered writing them in MCS code)
+-- BEWARE! Those assume you did checked if chest has items/space in it!
+function TakeItemsFromChest(IN_chest, IN_itemID, IN_ammount) -- UNSAFE! CHECK FOR ITEMS FIRST!!
+ -- stalk through chest slots...
+ local _slot_counter = 0
+ local _slot_item
+ local _take_count = IN_ammount
+ while true do
+ _slot_item = IN_chest:GetSlot(_slot_counter)
+ if (_slot_item ~= nil) then
+ if (_slot_item.m_ItemID == IN_itemID) then
+ -- assuming player have enought money
+ if (_take_count > 0) then
+ if (_take_count > _slot_item.m_ItemCount) then
+ _take_count = _take_count - _slot_item.m_ItemCount
+ IN_chest:SetSlot(_slot_counter, cItem()) -- a bit hacky, can't make cItem:Clear() work(
+ else
+ local _left_count = _slot_item.m_ItemCount - _take_count
+ IN_chest:SetSlot(_slot_counter, cItem(_slot_item.m_ItemID, _left_count)) -- a bit hacky
+ _take_count = 0
+ end
+ end
+ if (_take_count == 0) then
+ break
+ end
+ end
+ end
+ _slot_counter = _slot_counter + 1
+ if (_slot_counter == CHEST_WIDTH*GetChestHeightCheat(IN_chest)) then
+ break
+ end
+ end
+end
+function PutItemsToChest(IN_chest, IN_itemID, IN_ammount) -- UNSAFE! CHECK FOR SPACE FIRST!!
+ -- stalk through chest slots...
+ local _slot_counter = 0
+ local _slot_item
+ local _put_count = IN_ammount
+ local _max_stack = GetItemMaxStack(IN_itemID)
+ while true do
+ _slot_item = IN_chest:GetSlot(_slot_counter)
+ local _portion = 0
+ local _ammount_to_set = 0
+ if (_slot_item ~= nil) then
+ if (_slot_item:IsEmpty() == true) then
+ _portion = math.min(_max_stack, _put_count)
+ _ammount_to_set = _portion
+ else
+ if (_slot_item.m_ItemID == IN_itemID) then
+ -- choose between how much we need to put and how much free space left
+ _portion = math.min(_put_count, _max_stack - _slot_item.m_ItemCount)
+ _ammount_to_set = _slot_item.m_ItemCount + _portion
+ end
+ end
+ end
+ IN_chest:SetSlot(_slot_counter, cItem(IN_itemID, _ammount_to_set)) -- we add max stack to chest
+ _put_count = _put_count - _portion
+ if (_put_count == 0) then break end
+ _slot_counter = _slot_counter + 1
+ if (_slot_counter == CHEST_WIDTH*GetChestHeightCheat(IN_chest)) then
+ break
+ end
+ end
+end
+-- Similar to chest-related.
+function TakeItemsFromPlayer(IN_player, IN_itemID, IN_ammount) -- UNSAFE! CHECK FIRST!
+ local _put_count = IN_ammount
+ local _max_stack = GetItemMaxStack(IN_itemID)
+ while true do
+ local _portion = math.min(_max_stack, _put_count)
+ IN_player:GetInventory():RemoveItem(cItem(IN_itemID, _portion))
+ _put_count = _put_count - _portion
+ if (_put_count == 0) then break end
+ end
+end
+function GiveItemsToPlayer(IN_player, IN_itemID, IN_ammount) -- UNSAFE! CHECK FIRST!
+ local _put_count = IN_ammount
+ local _max_stack = GetItemMaxStack(IN_itemID)
+ while true do
+ local _portion = math.min(_max_stack, _put_count)
+ IN_player:GetInventory():AddItem(cItem(IN_itemID, _portion))
+ _put_count = _put_count - _portion
+ if (_put_count == 0) then break end
+ end
+end
+-- This function returns item max stack for a given itemID. It uses vanilla max stack size, and uses several non-common items notations;
+-- Those are:
+-- oneonerecord (because aparently 11record wasn't the best idea in lua scripting application)
+-- carrotonastick (because it wasn't added to items.txt yet)
+-- waitrecord (for same reason)
+-- Feel free to ignore the difference, or to add those to items.txt
+function GetItemMaxStack(IN_itemID)
+ local _result = 64
+ -- Tools and swords
+ if (IN_itemID == woodensword) then _result = 1 end
+ if (IN_itemID == woodenshovel) then _result = 1 end
+ if (IN_itemID == woodenpickaxe) then _result = 1 end
+ if (IN_itemID == woodenaxe) then _result = 1 end
+ if (IN_itemID == woodenhoe) then _result = 1 end
+ if (IN_itemID == stonesword) then _result = 1 end
+ if (IN_itemID == stoneshovel) then _result = 1 end
+ if (IN_itemID == stonepickaxe) then _result = 1 end
+ if (IN_itemID == stoneaxe) then _result = 1 end
+ if (IN_itemID == stonehoe) then _result = 1 end
+ if (IN_itemID == ironsword) then _result = 1 end
+ if (IN_itemID == ironshovel) then _result = 1 end
+ if (IN_itemID == ironpickaxe) then _result = 1 end
+ if (IN_itemID == ironaxe) then _result = 1 end
+ if (IN_itemID == ironhoe) then _result = 1 end
+ if (IN_itemID == diamondsword) then _result = 1 end
+ if (IN_itemID == diamondshovel) then _result = 1 end
+ if (IN_itemID == diamondpickaxe) then _result = 1 end
+ if (IN_itemID == diamondaxe) then _result = 1 end
+ if (IN_itemID == diamondhoe) then _result = 1 end
+ if (IN_itemID == goldensword) then _result = 1 end
+ if (IN_itemID == goldenshovel) then _result = 1 end
+ if (IN_itemID == goldenpickaxe) then _result = 1 end
+ if (IN_itemID == goldenaxe) then _result = 1 end
+ if (IN_itemID == goldenhoe) then _result = 1 end
+
+ if (IN_itemID == flintandsteel) then _result = 1 end
+ if (IN_itemID == bow) then _result = 1 end
+ if (IN_itemID == sign) then _result = 16 end
+ if (IN_itemID == woodendoor) then _result = 1 end
+ if (IN_itemID == irondoor) then _result = 1 end
+ if (IN_itemID == cake) then _result = 1 end
+ if (IN_itemID == cauldron) then _result = 1 end
+ if (IN_itemID == mushroomstew) then _result = 1 end
+ if (IN_itemID == painting) then _result = 1 end
+ if (IN_itemID == bucket) then _result = 16 end
+ if (IN_itemID == waterbucket) then _result = 1 end
+ if (IN_itemID == lavabucket) then _result = 1 end
+ if (IN_itemID == minecart) then _result = 1 end
+ if (IN_itemID == saddle) then _result = 1 end
+ if (IN_itemID == snowball) then _result = 16 end
+ if (IN_itemID == boat) then _result = 1 end
+ if (IN_itemID == milkbucket) then _result = 1 end
+ if (IN_itemID == storageminecart) then _result = 1 end
+ if (IN_itemID == poweredminecart) then _result = 1 end
+ if (IN_itemID == egg) then _result = 16 end
+ if (IN_itemID == fishingrod) then _result = 1 end
+ if (IN_itemID == bed) then _result = 1 end
+ if (IN_itemID == map) then _result = 1 end
+ if (IN_itemID == shears) then _result = 1 end
+ if (IN_itemID == enderpearl) then _result = 16 end
+ if (IN_itemID == potion) then _result = 1 end
+ if (IN_itemID == spawnegg) then _result = 1 end
+ if (IN_itemID == bookandquill) then _result = 1 end
+ if (IN_itemID == writtenbook) then _result = 1 end
+ if (IN_itemID == carrotonastick) then _result = 1 end
+
+ if (IN_itemID == goldrecord) then _result = 1 end
+ if (IN_itemID == greenrecord) then _result = 1 end
+ if (IN_itemID == blocksrecord) then _result = 1 end
+ if (IN_itemID == chirprecord) then _result = 1 end
+ if (IN_itemID == farrecord) then _result = 1 end
+ if (IN_itemID == mallrecord) then _result = 1 end
+ if (IN_itemID == mellohirecord) then _result = 1 end
+ if (IN_itemID == stalrecord) then _result = 1 end
+ if (IN_itemID == stradrecord) then _result = 1 end
+ if (IN_itemID == wardrecord) then _result = 1 end
+ if (IN_itemID == oneonerecord) then _result = 1 end
+ if (IN_itemID == waitrecord) then _result = 1 end
+
+ --if (IN_itemID == xxxxxxxxx) then _result = 1 end
+
+ if (IN_itemID == leatherhelmet) then _result = 1 end
+ if (IN_itemID == leatherchestplate) then _result = 1 end
+ if (IN_itemID == leatherpants) then _result = 1 end
+ if (IN_itemID == leatherboots) then _result = 1 end
+
+ if (IN_itemID == chainmailhelmet) then _result = 1 end
+ if (IN_itemID == chainmailchestplate) then _result = 1 end
+ if (IN_itemID == chainmailpants) then _result = 1 end
+ if (IN_itemID == chainmailboots) then _result = 1 end
+
+ if (IN_itemID == ironhelmet) then _result = 1 end
+ if (IN_itemID == ironchestplate) then _result = 1 end
+ if (IN_itemID == ironpants) then _result = 1 end
+ if (IN_itemID == ironboots) then _result = 1 end
+
+ if (IN_itemID == diamondhelmet) then _result = 1 end
+ if (IN_itemID == diamondchestplate) then _result = 1 end
+ if (IN_itemID == diamondpants) then _result = 1 end
+ if (IN_itemID == diamondboots) then _result = 1 end
+
+ if (IN_itemID == goldenhelmet) then _result = 1 end
+ if (IN_itemID == goldenchestplate) then _result = 1 end
+ if (IN_itemID == goldenpants) then _result = 1 end
+ if (IN_itemID == goldenboots) then _result = 1 end
+ return _result
+end
+function ItemIsArmor(IN_itemID)
+ local _result = false
+ if (IN_itemID == leatherhelmet) then _result = true end
+ if (IN_itemID == leatherchestplate) then _result = true end
+ if (IN_itemID == leatherpants) then _result = true end
+ if (IN_itemID == leatherboots) then _result = true end
+
+ if (IN_itemID == chainmailhelmet) then _result = true end
+ if (IN_itemID == chainmailchestplate) then _result = true end
+ if (IN_itemID == chainmailpants) then _result = true end
+ if (IN_itemID == chainmailboots) then _result = true end
+
+ if (IN_itemID == ironhelmet) then _result = true end
+ if (IN_itemID == ironchestplate) then _result = true end
+ if (IN_itemID == ironpants) then _result = true end
+ if (IN_itemID == ironboots) then _result = true end
+
+ if (IN_itemID == diamondhelmet) then _result = true end
+ if (IN_itemID == diamondchestplate) then _result = true end
+ if (IN_itemID == diamondpants) then _result = true end
+ if (IN_itemID == diamondboots) then _result = true end
+
+ if (IN_itemID == goldenhelmet) then _result = true end
+ if (IN_itemID == goldenchestplate) then _result = true end
+ if (IN_itemID == goldenpants) then _result = true end
+ if (IN_itemID == goldenboots) then _result = true end
+ return _result
+end
+-- Returns full-length playername for a short name (usefull for parsing commands)
+function GetExactPlayername(IN_playername)
+ local _result = IN_playername
+ local function SetProcessingPlayername(IN_player)
+ _result = IN_player:GetName()
+ end
+ cRoot:Get():FindAndDoWithPlayer(IN_playername, SetProcessingPlayername)
+ return _result
+end
+function GetPlayerByName(IN_playername)
+ local _player
+ local PlayerSetter = function (Player)
+ _player = Player
+ end
+ cRoot:Get():FindAndDoWithPlayer(IN_playername, PlayerSetter)
+ return _player
+end
+--[[
+Not-so-usual math _functions
+]]
+-- Rounds floating point number. Because lua guys think this function doesn't deserve to be presented in lua's math
+function round(IN_x)
+ if (IN_x%2 ~= 0.5) then
+ return math.floor(IN_x+0.5)
+ end
+ return IN_x-0.5
+end
+--[[
+Functions I use for filework and stringswork
+]]
+function PluralString(IN_value, IN_singular_string, IN_plural_string)
+ local _value_string = tostring(IN_value)
+ if (_value_string[#_value_string] == "1") then
+ return IN_singular_string
+ end
+ return IN_plural_string
+end
+function PluralItemName(IN_itemID, IN_ammount) -- BEWARE! TEMPORAL SOLUTION THERE! :D
+ local _value_string = tostring(IN_value)
+ local _name = ""
+ if (_value_string[#_value_string] == "1") then
+ -- singular names
+ _name = ItemTypeToString(IN_itemID)
+ else
+ -- plural names
+ _name = ItemTypeToString(IN_itemID).."s"
+ end
+ return _name
+end
+-- for filewriting purposes. 0 = false, 1 = true
+function StringToBool(value)
+ if value=="1" then return true end
+ return false
+end
+-- same, but reversal
+function BoolToString(value)
+ if value==true then return 1 end
+ return 0
end \ No newline at end of file
diff --git a/MCServer/Plugins/HookNotify/HookNotify.lua b/MCServer/Plugins/HookNotify/HookNotify.lua
index ed463c5ca..09759451d 100644
--- a/MCServer/Plugins/HookNotify/HookNotify.lua
+++ b/MCServer/Plugins/HookNotify/HookNotify.lua
@@ -1,404 +1,404 @@
-
--- Global variables
-PLUGIN = {} -- Reference to own plugin object
-
-
-
-
-
-function Initialize(Plugin)
- PLUGIN = Plugin
-
- Plugin:SetName("HookNotify");
- Plugin:SetVersion(1);
-
- PluginManager = cPluginManager:Get();
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_BLOCK_TO_PICKUPS);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_AVAILABLE);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_UNLOADED);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_UNLOADING);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_COLLECTING_PICKUP);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_EXECUTE_COMMAND);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_HANDSHAKE);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BROKEN_BLOCK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_EATING);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_LEFT_CLICK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACED_BLOCK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_RIGHT_CLICK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_SHOOTING);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_SPAWNED);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_TOSSING_ITEM);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USED_BLOCK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USED_ITEM);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_BLOCK);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_ITEM);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_POST_CRAFTING);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PRE_CRAFTING);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_TAKE_DAMAGE);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_UPDATED_SIGN);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_UPDATING_SIGN);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_WEATHER_CHANGED);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_WEATHER_CHANGING);
-
- LOGINFO("HookNotify plugin is installed, beware, the log output may be quite large!");
- LOGINFO("You want this plugin enabled only when developing another plugin, not for regular gameplay.");
-
- return true
-end
-
-
-
-
-
-function LogHook(FnName, ...)
- LOG(FnName .. "(");
- for i, v in ipairs(arg) do
- local vt = tostring(v);
- local TypeString = type(v);
- if (type(v) == "userdata") then
- TypeString = tolua.type(v);
- end;
- LOG(" " .. tostring(i) .. ": " .. TypeString .. ": " .. tostring(v));
- end
- LOG(")");
-end
-
-
-
-
-
-function OnBlockToPickups(...)
- LogHook("OnBlockToPickups", unpack(arg));
- local World, Digger, BlockX, BlockY, BlockZ, BlockType, BlockMeta, Pickups = unpack(arg);
- if (Pickups ~= nil) then
- local Name = "NULL";
- if (Digger ~= nil) then
- Name = Digger:GetName()
- end
- LOG("Got cItems from " .. Name .. ", trying to manipulate them.");
- Pickups:Add(cItem:new(E_ITEM_DIAMOND_SHOVEL, 1));
- LOG("Current size: " .. Pickups:Size());
- end;
-end;
-
-
-
-
-
-function OnChat(...)
- LogHook("OnChat", unpack(arg));
-end
-
-
-
-
-
-function OnChunkAvailable(...)
- LogHook("OnChunkAvailable", unpack(arg));
-end
-
-
-
-
-
-function OnChunkGenerated(...)
- LogHook("OnChunkGenerated", unpack(arg));
-end
-
-
-
-
-
-function OnChunkGenerating(...)
- LogHook("OnChunkGenerating", unpack(arg));
-end
-
-
-
-
-
-function OnChunkUnloaded(...)
- LogHook("OnChunkUnloaded", unpack(arg));
-end
-
-
-
-
-
-function OnChunkUnloading(...)
- LogHook("OnChunkUnloading", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerUsingItem(...)
- LogHook("OnPlayerUsingItem", unpack(arg));
-end
-
-
-
-
-
-function OnCollectingPickup(...)
- LogHook("OnCollectingPickup", unpack(arg));
-end
-
-
-
-
-function OnCraftingNoRecipe(...)
- LogHook("OnCraftingNoRecipe", unpack(arg));
-end
-
-
-
-
-
-function OnDisconnect(...)
- LogHook("OnDisconnect", unpack(arg));
-end
-
-
-
-
-
-function OnExecuteCommand(...)
- LogHook("OnExecuteCommand", unpack(arg));
-
- -- For some reason logging doesn't work for this callback, so list some stuff manually to verify:
- LOG("arg1 type: " .. type(arg[1]));
- if (arg[1] ~= nil) then
- LOG("Player name: " .. arg[1]:GetName());
- end
- LOG("Command: " .. arg[2][1]);
-end
-
-
-
-
-
-function OnHandshake(...)
- LogHook("OnHandshake", unpack(arg));
-end
-
-
-
-
-
-function OnKilling(...)
- LogHook("OnKilling", unpack(arg));
-end
-
-
-
-
-
-function OnLogin(...)
- LogHook("OnLogin", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerBreakingBlock(...)
- LogHook("OnPlayerBreakingBlock", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerBrokenBlock(...)
- LogHook("OnPlayerBrokenBlock", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerEating(...)
- LogHook("OnPlayerEating", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerJoined(...)
- LogHook("OnPlayerJoined", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerLeftClick(...)
- LogHook("OnPlayerLeftClick", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerMoving(...)
- LogHook("OnPlayerMoving", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerPlacedBlock(...)
- LogHook("OnPlayerPlacedBlock", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerPlacingBlock(...)
- LogHook("OnPlayerPlacingBlock", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerRightClick(...)
- LogHook("OnPlayerRightClick", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerShooting(...)
- LogHook("OnPlayerShooting", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerSpawned(...)
- LogHook("OnPlayerSpawned", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerTossingItem(...)
- LogHook("OnPlayerTossingItem", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerUsedBlock(...)
- LogHook("OnPlayerUsedBlock", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerUsedItem(...)
- LogHook("OnPlayerUsedItem", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerUsingBlock(...)
- LogHook("OnPlayerUsingBlock", unpack(arg));
-end
-
-
-
-
-
-function OnPlayerUsingItem(...)
- LogHook("OnPlayerUsingItem", unpack(arg));
-end
-
-
-
-
-
-function OnPostCrafting(...)
- LogHook("OnPostCrafting", unpack(arg));
-end
-
-
-
-
-
-function OnPreCrafting(...)
- LogHook("OnPreCrafting", unpack(arg));
-end
-
-
-
-
-
-function OnUpdatedSign(...)
- LogHook("OnUpdatedSign", unpack(arg));
-end
-
-
-
-
-
-function OnUpdatingSign(...)
- LogHook("OnUpdatingSign", unpack(arg));
-end
-
-
-
-
-
-function OnWeatherChanged(...)
- LogHook("OnWeatherChanged", unpack(arg));
-end
-
-
-
-
-
-function OnWeatherChanging(...)
- LogHook("OnWeatherChanging", unpack(arg));
-end
-
-
-
-
-
-------------------------------------------------------------------
--- Special handling for OnTakeDamage to print the contents of TDI:
-
-function OnTakeDamage(Receiver, TDI)
- -- Receiver is cPawn
- -- TDI is TakeDamageInfo
-
- LOG("OnTakeDamage(): " .. Receiver:GetClass() .. " was dealt RawDamage " .. TDI.RawDamage .. ", FinalDamage " .. TDI.FinalDamage .. " (that is, " .. (TDI.RawDamage - TDI.FinalDamage) .. " HPs covered by armor)");
-end
-
-
-
+
+-- Global variables
+PLUGIN = {} -- Reference to own plugin object
+
+
+
+
+
+function Initialize(Plugin)
+ PLUGIN = Plugin
+
+ Plugin:SetName("HookNotify");
+ Plugin:SetVersion(1);
+
+ PluginManager = cPluginManager:Get();
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_BLOCK_TO_PICKUPS);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_AVAILABLE);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_UNLOADED);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_UNLOADING);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_COLLECTING_PICKUP);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_EXECUTE_COMMAND);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_HANDSHAKE);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BROKEN_BLOCK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_EATING);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_LEFT_CLICK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACED_BLOCK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_RIGHT_CLICK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_SHOOTING);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_SPAWNED);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_TOSSING_ITEM);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USED_BLOCK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USED_ITEM);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_BLOCK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_ITEM);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_POST_CRAFTING);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_PRE_CRAFTING);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_TAKE_DAMAGE);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_UPDATED_SIGN);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_UPDATING_SIGN);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_WEATHER_CHANGED);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_WEATHER_CHANGING);
+
+ LOGINFO("HookNotify plugin is installed, beware, the log output may be quite large!");
+ LOGINFO("You want this plugin enabled only when developing another plugin, not for regular gameplay.");
+
+ return true
+end
+
+
+
+
+
+function LogHook(FnName, ...)
+ LOG(FnName .. "(");
+ for i, v in ipairs(arg) do
+ local vt = tostring(v);
+ local TypeString = type(v);
+ if (type(v) == "userdata") then
+ TypeString = tolua.type(v);
+ end;
+ LOG(" " .. tostring(i) .. ": " .. TypeString .. ": " .. tostring(v));
+ end
+ LOG(")");
+end
+
+
+
+
+
+function OnBlockToPickups(...)
+ LogHook("OnBlockToPickups", unpack(arg));
+ local World, Digger, BlockX, BlockY, BlockZ, BlockType, BlockMeta, Pickups = unpack(arg);
+ if (Pickups ~= nil) then
+ local Name = "NULL";
+ if (Digger ~= nil) then
+ Name = Digger:GetName()
+ end
+ LOG("Got cItems from " .. Name .. ", trying to manipulate them.");
+ Pickups:Add(cItem:new(E_ITEM_DIAMOND_SHOVEL, 1));
+ LOG("Current size: " .. Pickups:Size());
+ end;
+end;
+
+
+
+
+
+function OnChat(...)
+ LogHook("OnChat", unpack(arg));
+end
+
+
+
+
+
+function OnChunkAvailable(...)
+ LogHook("OnChunkAvailable", unpack(arg));
+end
+
+
+
+
+
+function OnChunkGenerated(...)
+ LogHook("OnChunkGenerated", unpack(arg));
+end
+
+
+
+
+
+function OnChunkGenerating(...)
+ LogHook("OnChunkGenerating", unpack(arg));
+end
+
+
+
+
+
+function OnChunkUnloaded(...)
+ LogHook("OnChunkUnloaded", unpack(arg));
+end
+
+
+
+
+
+function OnChunkUnloading(...)
+ LogHook("OnChunkUnloading", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerUsingItem(...)
+ LogHook("OnPlayerUsingItem", unpack(arg));
+end
+
+
+
+
+
+function OnCollectingPickup(...)
+ LogHook("OnCollectingPickup", unpack(arg));
+end
+
+
+
+
+function OnCraftingNoRecipe(...)
+ LogHook("OnCraftingNoRecipe", unpack(arg));
+end
+
+
+
+
+
+function OnDisconnect(...)
+ LogHook("OnDisconnect", unpack(arg));
+end
+
+
+
+
+
+function OnExecuteCommand(...)
+ LogHook("OnExecuteCommand", unpack(arg));
+
+ -- For some reason logging doesn't work for this callback, so list some stuff manually to verify:
+ LOG("arg1 type: " .. type(arg[1]));
+ if (arg[1] ~= nil) then
+ LOG("Player name: " .. arg[1]:GetName());
+ end
+ LOG("Command: " .. arg[2][1]);
+end
+
+
+
+
+
+function OnHandshake(...)
+ LogHook("OnHandshake", unpack(arg));
+end
+
+
+
+
+
+function OnKilling(...)
+ LogHook("OnKilling", unpack(arg));
+end
+
+
+
+
+
+function OnLogin(...)
+ LogHook("OnLogin", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerBreakingBlock(...)
+ LogHook("OnPlayerBreakingBlock", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerBrokenBlock(...)
+ LogHook("OnPlayerBrokenBlock", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerEating(...)
+ LogHook("OnPlayerEating", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerJoined(...)
+ LogHook("OnPlayerJoined", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerLeftClick(...)
+ LogHook("OnPlayerLeftClick", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerMoving(...)
+ LogHook("OnPlayerMoving", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerPlacedBlock(...)
+ LogHook("OnPlayerPlacedBlock", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerPlacingBlock(...)
+ LogHook("OnPlayerPlacingBlock", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerRightClick(...)
+ LogHook("OnPlayerRightClick", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerShooting(...)
+ LogHook("OnPlayerShooting", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerSpawned(...)
+ LogHook("OnPlayerSpawned", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerTossingItem(...)
+ LogHook("OnPlayerTossingItem", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerUsedBlock(...)
+ LogHook("OnPlayerUsedBlock", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerUsedItem(...)
+ LogHook("OnPlayerUsedItem", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerUsingBlock(...)
+ LogHook("OnPlayerUsingBlock", unpack(arg));
+end
+
+
+
+
+
+function OnPlayerUsingItem(...)
+ LogHook("OnPlayerUsingItem", unpack(arg));
+end
+
+
+
+
+
+function OnPostCrafting(...)
+ LogHook("OnPostCrafting", unpack(arg));
+end
+
+
+
+
+
+function OnPreCrafting(...)
+ LogHook("OnPreCrafting", unpack(arg));
+end
+
+
+
+
+
+function OnUpdatedSign(...)
+ LogHook("OnUpdatedSign", unpack(arg));
+end
+
+
+
+
+
+function OnUpdatingSign(...)
+ LogHook("OnUpdatingSign", unpack(arg));
+end
+
+
+
+
+
+function OnWeatherChanged(...)
+ LogHook("OnWeatherChanged", unpack(arg));
+end
+
+
+
+
+
+function OnWeatherChanging(...)
+ LogHook("OnWeatherChanging", unpack(arg));
+end
+
+
+
+
+
+------------------------------------------------------------------
+-- Special handling for OnTakeDamage to print the contents of TDI:
+
+function OnTakeDamage(Receiver, TDI)
+ -- Receiver is cPawn
+ -- TDI is TakeDamageInfo
+
+ LOG("OnTakeDamage(): " .. Receiver:GetClass() .. " was dealt RawDamage " .. TDI.RawDamage .. ", FinalDamage " .. TDI.FinalDamage .. " (that is, " .. (TDI.RawDamage - TDI.FinalDamage) .. " HPs covered by armor)");
+end
+
+
+
diff --git a/MCServer/Plugins/MagicCarpet/objects.lua b/MCServer/Plugins/MagicCarpet/objects.lua
index 7c19fc232..8d81623a5 100644
--- a/MCServer/Plugins/MagicCarpet/objects.lua
+++ b/MCServer/Plugins/MagicCarpet/objects.lua
@@ -1,97 +1,97 @@
--- Location object
-cLocation = {}
-function cLocation:new( x, y, z )
- local object = { x = x, y = y, z = z }
- setmetatable(object, { __index = cLocation })
- return object
-end
-
--- Offsets
-cFibers = { }
-function cFibers:new()
- local object = {
- cLocation:new( 2, -1, 2 ),
- cLocation:new( 2, -1, 1 ),
- cLocation:new( 2, -1, 0 ),
- cLocation:new( 2, -1, -1 ),
- cLocation:new( 2, -1, -2 ),
- cLocation:new( 1, -1, 2 ),
- cLocation:new( 1, -1, 1 ),
- cLocation:new( 1, -1, 0 ),
- cLocation:new( 1, -1, -1 ),
- cLocation:new( 1, -1, -2 ),
- cLocation:new( 0, -1, 2 ),
- cLocation:new( 0, -1, 1 ),
- cLocation:new( 0, -1, 0 ),
- cLocation:new( 0, -1, -1 ),
- cLocation:new( 0, -1, -2 ),
- cLocation:new( -1, -1, 2 ),
- cLocation:new( -1, -1, 1 ),
- cLocation:new( -1, -1, 0 ),
- cLocation:new( -1, -1, -1 ),
- cLocation:new( -1, -1, -2 ),
- cLocation:new( -2, -1, 2 ),
- cLocation:new( -2, -1, 1 ),
- cLocation:new( -2, -1, 0 ),
- cLocation:new( -2, -1, -1 ),
- cLocation:new( -2, -1, -2 ),
- imadeit = false,
- }
- setmetatable(object, { __index = cFibers })
- return object;
-end
-
--- Carpet object
-cCarpet = {}
-function cCarpet:new()
- local object = { Location = cLocation:new(0,0,0),
- Fibers = cFibers:new(),
- }
- setmetatable(object, { __index = cCarpet })
- return object
-end
-
-function cCarpet:remove()
- local World = cRoot:Get():GetDefaultWorld()
- for i, fib in ipairs( self.Fibers ) do
- local x = self.Location.x + fib.x
- local y = self.Location.y + fib.y
- local z = self.Location.z + fib.z
- local BlockID = World:GetBlock( x, y, z )
- if( fib.imadeit == true and BlockID == E_BLOCK_GLASS ) then
- World:SetBlock( x, y, z, 0, 0 )
- fib.imadeit = false
- end
- end
-end
-
-function cCarpet:draw()
- local World = cRoot:Get():GetDefaultWorld()
- for i, fib in ipairs( self.Fibers ) do
- local x = self.Location.x + fib.x
- local y = self.Location.y + fib.y
- local z = self.Location.z + fib.z
- local BlockID = World:GetBlock( x, y, z )
- if( BlockID == 0 ) then
- fib.imadeit = true
- World:SetBlock( x, y, z, E_BLOCK_GLASS, 0 )
- else
- fib.imadeit = false
- end
- end
-end
-
-function cCarpet:moveTo( NewPos )
- local x = math.floor( NewPos.x )
- local y = math.floor( NewPos.y )
- local z = math.floor( NewPos.z )
- if( self.Location.x ~= x or self.Location.y ~= y or self.Location.z ~= z ) then
- self:remove()
- self.Location = cLocation:new( x, y, z )
- self:draw()
- end
-end
-
-function cCarpet:getY()
- return self.Location.y
+-- Location object
+cLocation = {}
+function cLocation:new( x, y, z )
+ local object = { x = x, y = y, z = z }
+ setmetatable(object, { __index = cLocation })
+ return object
+end
+
+-- Offsets
+cFibers = { }
+function cFibers:new()
+ local object = {
+ cLocation:new( 2, -1, 2 ),
+ cLocation:new( 2, -1, 1 ),
+ cLocation:new( 2, -1, 0 ),
+ cLocation:new( 2, -1, -1 ),
+ cLocation:new( 2, -1, -2 ),
+ cLocation:new( 1, -1, 2 ),
+ cLocation:new( 1, -1, 1 ),
+ cLocation:new( 1, -1, 0 ),
+ cLocation:new( 1, -1, -1 ),
+ cLocation:new( 1, -1, -2 ),
+ cLocation:new( 0, -1, 2 ),
+ cLocation:new( 0, -1, 1 ),
+ cLocation:new( 0, -1, 0 ),
+ cLocation:new( 0, -1, -1 ),
+ cLocation:new( 0, -1, -2 ),
+ cLocation:new( -1, -1, 2 ),
+ cLocation:new( -1, -1, 1 ),
+ cLocation:new( -1, -1, 0 ),
+ cLocation:new( -1, -1, -1 ),
+ cLocation:new( -1, -1, -2 ),
+ cLocation:new( -2, -1, 2 ),
+ cLocation:new( -2, -1, 1 ),
+ cLocation:new( -2, -1, 0 ),
+ cLocation:new( -2, -1, -1 ),
+ cLocation:new( -2, -1, -2 ),
+ imadeit = false,
+ }
+ setmetatable(object, { __index = cFibers })
+ return object;
+end
+
+-- Carpet object
+cCarpet = {}
+function cCarpet:new()
+ local object = { Location = cLocation:new(0,0,0),
+ Fibers = cFibers:new(),
+ }
+ setmetatable(object, { __index = cCarpet })
+ return object
+end
+
+function cCarpet:remove()
+ local World = cRoot:Get():GetDefaultWorld()
+ for i, fib in ipairs( self.Fibers ) do
+ local x = self.Location.x + fib.x
+ local y = self.Location.y + fib.y
+ local z = self.Location.z + fib.z
+ local BlockID = World:GetBlock( x, y, z )
+ if( fib.imadeit == true and BlockID == E_BLOCK_GLASS ) then
+ World:SetBlock( x, y, z, 0, 0 )
+ fib.imadeit = false
+ end
+ end
+end
+
+function cCarpet:draw()
+ local World = cRoot:Get():GetDefaultWorld()
+ for i, fib in ipairs( self.Fibers ) do
+ local x = self.Location.x + fib.x
+ local y = self.Location.y + fib.y
+ local z = self.Location.z + fib.z
+ local BlockID = World:GetBlock( x, y, z )
+ if( BlockID == 0 ) then
+ fib.imadeit = true
+ World:SetBlock( x, y, z, E_BLOCK_GLASS, 0 )
+ else
+ fib.imadeit = false
+ end
+ end
+end
+
+function cCarpet:moveTo( NewPos )
+ local x = math.floor( NewPos.x )
+ local y = math.floor( NewPos.y )
+ local z = math.floor( NewPos.z )
+ if( self.Location.x ~= x or self.Location.y ~= y or self.Location.z ~= z ) then
+ self:remove()
+ self.Location = cLocation:new( x, y, z )
+ self:draw()
+ end
+end
+
+function cCarpet:getY()
+ return self.Location.y
end \ No newline at end of file
diff --git a/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua b/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua
index b943df060..26df73075 100644
--- a/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua
+++ b/MCServer/Plugins/ProtectionAreas/CommandHandlers.lua
@@ -1,322 +1,322 @@
-
--- CommandHandlers.lua
--- Defines the individual command handlers
-
-
-
-
-
-function InitializeCommandHandlers()
- local PlgMgr = cRoot:Get():GetPluginManager();
- for idx, Cmd in ipairs(CommandReg()) do
- PlgMgr:BindCommand(Cmd[2], Cmd[3], Cmd[1], Cmd[4]);
- end
-end
-
-
-
-
-
---- Handles the ProtAdd command
-function HandleAddArea(a_Split, a_Player)
- -- Command syntax: ProtAdd username1 [username2] [username3] ...
- if (#a_Split < 2) then
- a_Player:SendMessage(g_Msgs.ErrExpectedListOfUsernames);
- return true;
- end
-
- -- Get the cuboid that the player had selected
- local CmdState = GetCommandStateForPlayer(a_Player);
- if (CmdState == nil) then
- a_Player:SendMessage(g_Msgs.ErrCmdStateNilAddArea);
- return true;
- end
- local Cuboid = CmdState:GetCurrentCuboid();
- if (Cuboid == nil) then
- a_Player:SendMessage(g_Msgs.ErrNoAreaWanded);
- return true;
- end
-
- -- Put all allowed players into a table:
- AllowedNames = {};
- for i = 2, #a_Split do
- table.insert(AllowedNames, a_Split[i]);
- end
-
- -- Add the area to the storage
- local AreaID = g_Storage:AddArea(Cuboid, a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames);
- a_Player:SendMessage(string.format(g_Msgs.AreaAdded, AreaID));
-
- -- Reload all currently logged in players
- ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
-
- return true;
-end
-
-
-
-
-
-function HandleAddAreaCoords(a_Split, a_Player)
- -- Command syntax: ProtAddCoords x1 z1 x2 z2 username1 [username2] [username3] ...
- if (#a_Split < 6) then
- a_Player:SendMessage(g_Msgs.ErrExpectedCoordsUsernames);
- return true;
- end
-
- -- Convert the coords to a cCuboid
- local x1, z1 = tonumber(a_Split[2]), tonumber(a_Split[3]);
- local x2, z2 = tonumber(a_Split[4]), tonumber(a_Split[5]);
- if ((x1 == nil) or (z1 == nil) or (x2 == nil) or (z2 == nil)) then
- a_Player:SendMessage(g_Msgs.ErrParseCoords);
- return true;
- end
- local Cuboid = cCuboid(x1, 0, z1, x2, 255, z1);
- Cuboid:Sort();
-
- -- Put all allowed players into a table:
- AllowedNames = {};
- for i = 6, #a_Split do
- table.insert(AllowedNames, a_Split[i]);
- end
-
- -- Add the area to the storage
- local AreaID = g_Storage:AddArea(Cuboid, a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames);
- a_Player:SendMessage(string.format(g_Msgs.AreaAdded, AreaID));
-
- -- Reload all currently logged in players
- ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
-
- return true;
-end
-
-
-
-
-
-function HandleAddAreaUser(a_Split, a_Player)
- -- Command syntax: ProtAddUser AreaID username1 [username2] [username3] ...
- if (#a_Split < 3) then
- a_Player:SendMessage(g_Msgs.ErrExpectedAreaIDUsernames);
- return true;
- end
-
- -- Put all allowed players into a table:
- AllowedNames = {};
- for i = 3, #a_Split do
- table.insert(AllowedNames, a_Split[i]);
- end
-
- -- Add the area to the storage
- if (not(g_Storage:AddAreaUsers(
- tonumber(a_Split[2]), a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames))
- ) then
- LOGWARNING("g_Storage:AddAreaUsers failed");
- a_Player:SendMessage(g_Msgs.ErrDBFailAddUsers);
- return true;
- end
- if (#AllowedNames == 0) then
- a_Player:SendMessage(g_Msgs.AllUsersAlreadyAllowed);
- else
- a_Player:SendMessage(string.format(g_Msgs.UsersAdded, table.concat(AllowedNames, ", ")));
- end
-
- -- Reload all currently logged in players
- ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
-
- return true;
-end
-
-
-
-
-
-function HandleDelArea(a_Split, a_Player)
- -- Command syntax: ProtDelArea AreaID
- if (#a_Split ~= 2) then
- a_Player:SendMessage(g_Msgs.ErrExpectedAreaID);
- return true;
- end
-
- -- Parse the AreaID
- local AreaID = tonumber(a_Split[2]);
- if (AreaID == nil) then
- a_Player:SendMessage(g_Msgs.ErrParseAreaID);
- return true;
- end
-
- -- Delete the area
- g_Storage:DelArea(a_Player:GetWorld():GetName(), AreaID);
-
- a_Player:SendMessage(string.format(g_Msgs.AreaDeleted, AreaID));
- -- Reload all currently logged in players
- ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
-
- return true;
-end
-
-
-
-
-
-function HandleGiveWand(a_Split, a_Player)
- local NumGiven = a_Player:GetInventory():AddItem(cConfig:GetWandItem());
- if (NumGiven == 1) then
- a_Player:SendMessage(g_Msgs.WandGiven);
- else
- a_Player:SendMessage(g_Msgs.ErrNoSpaceForWand);
- end
- return true;
-end
-
-
-
-
-
-function HandleListAreas(a_Split, a_Player)
- -- Command syntax: ProtListAreas [x, z]
-
- local x, z;
- if (#a_Split == 1) then
- -- Get the last "wanded" coord
- local CmdState = GetCommandStateForPlayer(a_Player);
- if (CmdState == nil) then
- a_Player:SendMessage(g_Msgs.ErrCmdStateNilListAreas);
- return true;
- end
- x, z = CmdState:GetLastCoords();
- if ((x == nil) or (z == nil)) then
- a_Player:SendMessage(g_Msgs.ErrListNotWanded);
- return true;
- end
- elseif (#a_Split == 3) then
- -- Parse the coords from the command params
- x = tonumber(a_Split[2]);
- z = tonumber(a_Split[3]);
- if ((x == nil) or (z == nil)) then
- a_Player:SendMessage(g_Msgs.ErrParseCoordsListAreas);
- return true;
- end
- else
- -- Wrong number of params, report back to the user
- a_Player:SendMessage(g_Msgs.ErrSyntaxErrorListAreas);
- return true;
- end
-
- a_Player:SendMessage(string.format(g_Msgs.ListAreasHeader, x, z));
-
- -- List areas intersecting the coords
- local PlayerName = a_Player:GetName();
- local WorldName = a_Player:GetWorld():GetName();
- g_Storage:ForEachArea(x, z, WorldName,
- function(AreaID, MinX, MinZ, MaxX, MaxZ, CreatorName)
- local Coords = string.format("%s: {%d, %d} - {%d, %d} ", AreaID, MinX, MinZ, MaxX, MaxZ);
- local Allowance;
- if (g_Storage:IsAreaAllowed(AreaID, PlayerName, WorldName)) then
- Allowance = g_Msgs.AreaAllowed;
- else
- Allowance = g_Msgs.AreaNotAllowed;
- end
- a_Player:SendMessage(string.format(g_Msgs.ListAreasRow, Coords, Allowance, CreatorName));
- end
- );
-
- a_Player:SendMessage(g_Msgs.ListAreasFooter);
- return true;
-end
-
-
-
-
---- Lists all allowed users for a particular area
-function HandleListUsers(a_Split, a_Player)
- -- Command syntax: ProtListUsers AreaID
- if (#a_Split ~= 2) then
- a_Player:SendMessage(g_Msgs.ErrExpectedAreaID);
- end
-
- -- Get the general info about the area
- local AreaID = a_Split[2];
- local WorldName = a_Player:GetWorld():GetName();
- local MinX, MinZ, MaxX, MaxZ, CreatorName = g_Storage:GetArea(AreaID, WorldName);
- if (MinX == nil) then
- a_Player:SendMessage(string.format(g_Msgs.ErrNoSuchArea, AreaID));
- return true;
- end
-
- -- Send the header
- a_Player:SendMessage(string.format(g_Msgs.ListUsersHeader, AreaID, MinX, MinZ, MaxX, MaxZ, CreatorName));
-
- -- List and count the allowed users
- local NumUsers = 0;
- g_Storage:ForEachUserInArea(AreaID, WorldName,
- function(UserName)
- a_Player:SendMessage(string.format(g_Msgs.ListUsersRow, UserName));
- NumUsers = NumUsers + 1;
- end
- );
-
- -- Send the footer
- a_Player:SendMessage(string.format(g_Msgs.ListUsersFooter, AreaID, NumUsers));
-
- return true;
-end
-
-
-
-
-
-function HandleRemoveUser(a_Split, a_Player)
- -- Command syntax: ProtRemUser AreaID UserName
- if (#a_Split ~= 3) then
- a_Player:SendMessage(g_Msgs.ErrExpectedAreaIDUserName);
- return true;
- end
-
- -- Parse the AreaID
- local AreaID = tonumber(a_Split[2]);
- if (AreaID == nil) then
- a_Player:SendMessage(g_Msgs.ErrParseAreaID);
- return true;
- end
-
- -- Remove the user from the DB
- local UserName = a_Split[3];
- g_Storage:RemoveUser(AreaID, UserName, a_Player:GetWorld():GetName());
-
- -- Send confirmation
- a_Player:SendMessage(string.format(g_Msgs.RemovedUser, UserName, AreaID));
-
- -- Reload all currently logged in players
- ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
-
- return true;
-end
-
-
-
-
-
-function HandleRemoveUserAll(a_Split, a_Player)
- -- Command syntax: ProtRemUserAll UserName
- if (#a_Split ~= 2) then
- a_Player:SendMessage(g_Msgs.ErrExpectedUserName);
- return true;
- end
-
- -- Remove the user from the DB
- g_Storage:RemoveUserAll(a_Split[2], a_Player:GetWorld():GetName());
-
- -- Send confirmation
- a_Player:SendMessage(string.format(g_Msgs.RemovedUserAll, UserName));
-
- -- Reload all currently logged in players
- ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
-
- return true;
-end
-
-
-
-
-
+
+-- CommandHandlers.lua
+-- Defines the individual command handlers
+
+
+
+
+
+function InitializeCommandHandlers()
+ local PlgMgr = cRoot:Get():GetPluginManager();
+ for idx, Cmd in ipairs(CommandReg()) do
+ PlgMgr:BindCommand(Cmd[2], Cmd[3], Cmd[1], Cmd[4]);
+ end
+end
+
+
+
+
+
+--- Handles the ProtAdd command
+function HandleAddArea(a_Split, a_Player)
+ -- Command syntax: ProtAdd username1 [username2] [username3] ...
+ if (#a_Split < 2) then
+ a_Player:SendMessage(g_Msgs.ErrExpectedListOfUsernames);
+ return true;
+ end
+
+ -- Get the cuboid that the player had selected
+ local CmdState = GetCommandStateForPlayer(a_Player);
+ if (CmdState == nil) then
+ a_Player:SendMessage(g_Msgs.ErrCmdStateNilAddArea);
+ return true;
+ end
+ local Cuboid = CmdState:GetCurrentCuboid();
+ if (Cuboid == nil) then
+ a_Player:SendMessage(g_Msgs.ErrNoAreaWanded);
+ return true;
+ end
+
+ -- Put all allowed players into a table:
+ AllowedNames = {};
+ for i = 2, #a_Split do
+ table.insert(AllowedNames, a_Split[i]);
+ end
+
+ -- Add the area to the storage
+ local AreaID = g_Storage:AddArea(Cuboid, a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames);
+ a_Player:SendMessage(string.format(g_Msgs.AreaAdded, AreaID));
+
+ -- Reload all currently logged in players
+ ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
+
+ return true;
+end
+
+
+
+
+
+function HandleAddAreaCoords(a_Split, a_Player)
+ -- Command syntax: ProtAddCoords x1 z1 x2 z2 username1 [username2] [username3] ...
+ if (#a_Split < 6) then
+ a_Player:SendMessage(g_Msgs.ErrExpectedCoordsUsernames);
+ return true;
+ end
+
+ -- Convert the coords to a cCuboid
+ local x1, z1 = tonumber(a_Split[2]), tonumber(a_Split[3]);
+ local x2, z2 = tonumber(a_Split[4]), tonumber(a_Split[5]);
+ if ((x1 == nil) or (z1 == nil) or (x2 == nil) or (z2 == nil)) then
+ a_Player:SendMessage(g_Msgs.ErrParseCoords);
+ return true;
+ end
+ local Cuboid = cCuboid(x1, 0, z1, x2, 255, z1);
+ Cuboid:Sort();
+
+ -- Put all allowed players into a table:
+ AllowedNames = {};
+ for i = 6, #a_Split do
+ table.insert(AllowedNames, a_Split[i]);
+ end
+
+ -- Add the area to the storage
+ local AreaID = g_Storage:AddArea(Cuboid, a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames);
+ a_Player:SendMessage(string.format(g_Msgs.AreaAdded, AreaID));
+
+ -- Reload all currently logged in players
+ ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
+
+ return true;
+end
+
+
+
+
+
+function HandleAddAreaUser(a_Split, a_Player)
+ -- Command syntax: ProtAddUser AreaID username1 [username2] [username3] ...
+ if (#a_Split < 3) then
+ a_Player:SendMessage(g_Msgs.ErrExpectedAreaIDUsernames);
+ return true;
+ end
+
+ -- Put all allowed players into a table:
+ AllowedNames = {};
+ for i = 3, #a_Split do
+ table.insert(AllowedNames, a_Split[i]);
+ end
+
+ -- Add the area to the storage
+ if (not(g_Storage:AddAreaUsers(
+ tonumber(a_Split[2]), a_Player:GetWorld():GetName(), a_Player:GetName(), AllowedNames))
+ ) then
+ LOGWARNING("g_Storage:AddAreaUsers failed");
+ a_Player:SendMessage(g_Msgs.ErrDBFailAddUsers);
+ return true;
+ end
+ if (#AllowedNames == 0) then
+ a_Player:SendMessage(g_Msgs.AllUsersAlreadyAllowed);
+ else
+ a_Player:SendMessage(string.format(g_Msgs.UsersAdded, table.concat(AllowedNames, ", ")));
+ end
+
+ -- Reload all currently logged in players
+ ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
+
+ return true;
+end
+
+
+
+
+
+function HandleDelArea(a_Split, a_Player)
+ -- Command syntax: ProtDelArea AreaID
+ if (#a_Split ~= 2) then
+ a_Player:SendMessage(g_Msgs.ErrExpectedAreaID);
+ return true;
+ end
+
+ -- Parse the AreaID
+ local AreaID = tonumber(a_Split[2]);
+ if (AreaID == nil) then
+ a_Player:SendMessage(g_Msgs.ErrParseAreaID);
+ return true;
+ end
+
+ -- Delete the area
+ g_Storage:DelArea(a_Player:GetWorld():GetName(), AreaID);
+
+ a_Player:SendMessage(string.format(g_Msgs.AreaDeleted, AreaID));
+ -- Reload all currently logged in players
+ ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
+
+ return true;
+end
+
+
+
+
+
+function HandleGiveWand(a_Split, a_Player)
+ local NumGiven = a_Player:GetInventory():AddItem(cConfig:GetWandItem());
+ if (NumGiven == 1) then
+ a_Player:SendMessage(g_Msgs.WandGiven);
+ else
+ a_Player:SendMessage(g_Msgs.ErrNoSpaceForWand);
+ end
+ return true;
+end
+
+
+
+
+
+function HandleListAreas(a_Split, a_Player)
+ -- Command syntax: ProtListAreas [x, z]
+
+ local x, z;
+ if (#a_Split == 1) then
+ -- Get the last "wanded" coord
+ local CmdState = GetCommandStateForPlayer(a_Player);
+ if (CmdState == nil) then
+ a_Player:SendMessage(g_Msgs.ErrCmdStateNilListAreas);
+ return true;
+ end
+ x, z = CmdState:GetLastCoords();
+ if ((x == nil) or (z == nil)) then
+ a_Player:SendMessage(g_Msgs.ErrListNotWanded);
+ return true;
+ end
+ elseif (#a_Split == 3) then
+ -- Parse the coords from the command params
+ x = tonumber(a_Split[2]);
+ z = tonumber(a_Split[3]);
+ if ((x == nil) or (z == nil)) then
+ a_Player:SendMessage(g_Msgs.ErrParseCoordsListAreas);
+ return true;
+ end
+ else
+ -- Wrong number of params, report back to the user
+ a_Player:SendMessage(g_Msgs.ErrSyntaxErrorListAreas);
+ return true;
+ end
+
+ a_Player:SendMessage(string.format(g_Msgs.ListAreasHeader, x, z));
+
+ -- List areas intersecting the coords
+ local PlayerName = a_Player:GetName();
+ local WorldName = a_Player:GetWorld():GetName();
+ g_Storage:ForEachArea(x, z, WorldName,
+ function(AreaID, MinX, MinZ, MaxX, MaxZ, CreatorName)
+ local Coords = string.format("%s: {%d, %d} - {%d, %d} ", AreaID, MinX, MinZ, MaxX, MaxZ);
+ local Allowance;
+ if (g_Storage:IsAreaAllowed(AreaID, PlayerName, WorldName)) then
+ Allowance = g_Msgs.AreaAllowed;
+ else
+ Allowance = g_Msgs.AreaNotAllowed;
+ end
+ a_Player:SendMessage(string.format(g_Msgs.ListAreasRow, Coords, Allowance, CreatorName));
+ end
+ );
+
+ a_Player:SendMessage(g_Msgs.ListAreasFooter);
+ return true;
+end
+
+
+
+
+--- Lists all allowed users for a particular area
+function HandleListUsers(a_Split, a_Player)
+ -- Command syntax: ProtListUsers AreaID
+ if (#a_Split ~= 2) then
+ a_Player:SendMessage(g_Msgs.ErrExpectedAreaID);
+ end
+
+ -- Get the general info about the area
+ local AreaID = a_Split[2];
+ local WorldName = a_Player:GetWorld():GetName();
+ local MinX, MinZ, MaxX, MaxZ, CreatorName = g_Storage:GetArea(AreaID, WorldName);
+ if (MinX == nil) then
+ a_Player:SendMessage(string.format(g_Msgs.ErrNoSuchArea, AreaID));
+ return true;
+ end
+
+ -- Send the header
+ a_Player:SendMessage(string.format(g_Msgs.ListUsersHeader, AreaID, MinX, MinZ, MaxX, MaxZ, CreatorName));
+
+ -- List and count the allowed users
+ local NumUsers = 0;
+ g_Storage:ForEachUserInArea(AreaID, WorldName,
+ function(UserName)
+ a_Player:SendMessage(string.format(g_Msgs.ListUsersRow, UserName));
+ NumUsers = NumUsers + 1;
+ end
+ );
+
+ -- Send the footer
+ a_Player:SendMessage(string.format(g_Msgs.ListUsersFooter, AreaID, NumUsers));
+
+ return true;
+end
+
+
+
+
+
+function HandleRemoveUser(a_Split, a_Player)
+ -- Command syntax: ProtRemUser AreaID UserName
+ if (#a_Split ~= 3) then
+ a_Player:SendMessage(g_Msgs.ErrExpectedAreaIDUserName);
+ return true;
+ end
+
+ -- Parse the AreaID
+ local AreaID = tonumber(a_Split[2]);
+ if (AreaID == nil) then
+ a_Player:SendMessage(g_Msgs.ErrParseAreaID);
+ return true;
+ end
+
+ -- Remove the user from the DB
+ local UserName = a_Split[3];
+ g_Storage:RemoveUser(AreaID, UserName, a_Player:GetWorld():GetName());
+
+ -- Send confirmation
+ a_Player:SendMessage(string.format(g_Msgs.RemovedUser, UserName, AreaID));
+
+ -- Reload all currently logged in players
+ ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
+
+ return true;
+end
+
+
+
+
+
+function HandleRemoveUserAll(a_Split, a_Player)
+ -- Command syntax: ProtRemUserAll UserName
+ if (#a_Split ~= 2) then
+ a_Player:SendMessage(g_Msgs.ErrExpectedUserName);
+ return true;
+ end
+
+ -- Remove the user from the DB
+ g_Storage:RemoveUserAll(a_Split[2], a_Player:GetWorld():GetName());
+
+ -- Send confirmation
+ a_Player:SendMessage(string.format(g_Msgs.RemovedUserAll, UserName));
+
+ -- Reload all currently logged in players
+ ReloadAllPlayersInWorld(a_Player:GetWorld():GetName());
+
+ return true;
+end
+
+
+
+
+
diff --git a/MCServer/Plugins/ProtectionAreas/CommandState.lua b/MCServer/Plugins/ProtectionAreas/CommandState.lua
index 2911688a8..f6d33d356 100644
--- a/MCServer/Plugins/ProtectionAreas/CommandState.lua
+++ b/MCServer/Plugins/ProtectionAreas/CommandState.lua
@@ -1,121 +1,121 @@
-
--- CommandState.lua
-
--- Implements the cCommandState class representing a command state for each VIP player
-
---[[
-The command state holds internal info, such as the coords they selected using the wand
-The command state needs to be held in a per-entity manner, so that we can support multiple logins
-from the same account (just for the fun of it)
-The OOP class implementation follows the PiL 16.1
-
-Also, a global table g_CommandStates is the map of PlayerEntityID -> cCommandState
---]]
-
-
-
-
-
-cCommandState = {
- -- Default coords
- m_Coords1 = {x = 0, z = 0}; -- lclk coords
- m_Coords2 = {x = 0, z = 0}; -- rclk coords
- m_LastCoords = 0; -- When Coords1 or Coords2 is set, this gets set to 1 or 2, signifying the last changed set of coords
- m_HasCoords1 = false; -- Set to true when m_Coords1 has been set by the user
- m_HasCoords2 = false; -- Set to true when m_Coords2 has been set by the user
-};
-
-g_CommandStates = {};
-
-
-
-
-
-function cCommandState:new(obj)
- obj = obj or {};
- setmetatable(obj, self);
- self.__index = self;
- return obj;
-end
-
-
-
-
-
---- Returns the current coord pair as a cCuboid object
-function cCommandState:GetCurrentCuboid()
- if (not(self.m_HasCoords1) or not(self.m_HasCoords2)) then
- -- Some of the coords haven't been set yet
- return nil;
- end
-
- local res = cCuboid(
- self.m_Coords1.x, 0, self.m_Coords1.z,
- self.m_Coords2.x, 255, self.m_Coords2.z
- );
- res:Sort();
- return res;
-end
-
-
-
-
-
---- Returns the x, z coords that were the set last,
--- That is, either m_Coords1 or m_Coords2, based on m_LastCoords member
--- Returns nothing if no coords were set yet
-function cCommandState:GetLastCoords()
- if (self.m_LastCoords == 0) then
- -- No coords have been set yet
- return;
- elseif (self.m_LastCoords == 1) then
- return self.m_Coords1.x, self.m_Coords1.z;
- elseif (self.m_LastCoords == 2) then
- return self.m_Coords2.x, self.m_Coords2.z;
- else
- LOGWARNING(PluginPrefix .. "cCommandState is in an unexpected state, m_LastCoords == " .. self.m_LastCoords);
- return;
- end
-end
-
-
-
-
-
---- Sets the first set of coords (upon rclk with a wand)
-function cCommandState:SetCoords1(a_BlockX, a_BlockZ)
- self.m_Coords1.x = a_BlockX;
- self.m_Coords1.z = a_BlockZ;
- self.m_LastCoords = 1;
- self.m_HasCoords1 = true;
-end
-
-
-
-
-
---- Sets the second set of coords (upon lclk with a wand)
-function cCommandState:SetCoords2(a_BlockX, a_BlockZ)
- self.m_Coords2.x = a_BlockX;
- self.m_Coords2.z = a_BlockZ;
- self.m_LastCoords = 2;
- self.m_HasCoords2 = true;
-end
-
-
-
-
-
---- Returns the cCommandState for the specified player; creates one if not existant
-function GetCommandStateForPlayer(a_Player)
- local res = g_CommandStates[a_Player:GetUniqueID()];
- if (res == nil) then
- res = cCommandState:new();
- g_CommandStates[a_Player:GetUniqueID()] = res;
- end
- return res;
-end;
-
-
-
-
+
+-- CommandState.lua
+
+-- Implements the cCommandState class representing a command state for each VIP player
+
+--[[
+The command state holds internal info, such as the coords they selected using the wand
+The command state needs to be held in a per-entity manner, so that we can support multiple logins
+from the same account (just for the fun of it)
+The OOP class implementation follows the PiL 16.1
+
+Also, a global table g_CommandStates is the map of PlayerEntityID -> cCommandState
+--]]
+
+
+
+
+
+cCommandState = {
+ -- Default coords
+ m_Coords1 = {x = 0, z = 0}; -- lclk coords
+ m_Coords2 = {x = 0, z = 0}; -- rclk coords
+ m_LastCoords = 0; -- When Coords1 or Coords2 is set, this gets set to 1 or 2, signifying the last changed set of coords
+ m_HasCoords1 = false; -- Set to true when m_Coords1 has been set by the user
+ m_HasCoords2 = false; -- Set to true when m_Coords2 has been set by the user
+};
+
+g_CommandStates = {};
+
+
+
+
+
+function cCommandState:new(obj)
+ obj = obj or {};
+ setmetatable(obj, self);
+ self.__index = self;
+ return obj;
+end
+
+
+
+
+
+--- Returns the current coord pair as a cCuboid object
+function cCommandState:GetCurrentCuboid()
+ if (not(self.m_HasCoords1) or not(self.m_HasCoords2)) then
+ -- Some of the coords haven't been set yet
+ return nil;
+ end
+
+ local res = cCuboid(
+ self.m_Coords1.x, 0, self.m_Coords1.z,
+ self.m_Coords2.x, 255, self.m_Coords2.z
+ );
+ res:Sort();
+ return res;
+end
+
+
+
+
+
+--- Returns the x, z coords that were the set last,
+-- That is, either m_Coords1 or m_Coords2, based on m_LastCoords member
+-- Returns nothing if no coords were set yet
+function cCommandState:GetLastCoords()
+ if (self.m_LastCoords == 0) then
+ -- No coords have been set yet
+ return;
+ elseif (self.m_LastCoords == 1) then
+ return self.m_Coords1.x, self.m_Coords1.z;
+ elseif (self.m_LastCoords == 2) then
+ return self.m_Coords2.x, self.m_Coords2.z;
+ else
+ LOGWARNING(PluginPrefix .. "cCommandState is in an unexpected state, m_LastCoords == " .. self.m_LastCoords);
+ return;
+ end
+end
+
+
+
+
+
+--- Sets the first set of coords (upon rclk with a wand)
+function cCommandState:SetCoords1(a_BlockX, a_BlockZ)
+ self.m_Coords1.x = a_BlockX;
+ self.m_Coords1.z = a_BlockZ;
+ self.m_LastCoords = 1;
+ self.m_HasCoords1 = true;
+end
+
+
+
+
+
+--- Sets the second set of coords (upon lclk with a wand)
+function cCommandState:SetCoords2(a_BlockX, a_BlockZ)
+ self.m_Coords2.x = a_BlockX;
+ self.m_Coords2.z = a_BlockZ;
+ self.m_LastCoords = 2;
+ self.m_HasCoords2 = true;
+end
+
+
+
+
+
+--- Returns the cCommandState for the specified player; creates one if not existant
+function GetCommandStateForPlayer(a_Player)
+ local res = g_CommandStates[a_Player:GetUniqueID()];
+ if (res == nil) then
+ res = cCommandState:new();
+ g_CommandStates[a_Player:GetUniqueID()] = res;
+ end
+ return res;
+end;
+
+
+
+
diff --git a/MCServer/Plugins/ProtectionAreas/Config.lua b/MCServer/Plugins/ProtectionAreas/Config.lua
index b6fe34535..b40be0c75 100644
--- a/MCServer/Plugins/ProtectionAreas/Config.lua
+++ b/MCServer/Plugins/ProtectionAreas/Config.lua
@@ -1,55 +1,55 @@
-
--- Config.lua
-
--- Implements the cConfig class that holds the general plugin configuration
-
-
-
-
-
-cConfig = {
- m_Wand = cItem(E_ITEM_STICK, 1, 1); -- The item to be used as the selection wand
- m_AllowInteractNoArea = true; -- If there's no area, is a player allowed to build / dig?
-};
-
-
-
-
-
---- Initializes the cConfig object, loads the configuration from an INI file
-function InitializeConfig()
- local ini = cIniFile("ProtectionAreas.ini");
- if (not(ini:ReadFile())) then
- LOGINFO(PluginPrefix .. "Cannot read ProtectionAreas.ini, all plugin configuration is set to defaults");
- end
- local WandItem = cItem();
- if (
- StringToItem(ini:GetValueSet("ProtectionAreas", "WandItem", ItemToString(cConfig.m_Wand)), WandItem) and
- IsValidItem(WandItem.m_ItemType)
- ) then
- cConfig.m_Wand = WandItem;
- end
- cConfig.m_AllowInteractNoArea = ini:GetValueSetB("ProtectionAreas", "AllowInteractNoArea", cConfig.m_AllowInteractNoArea);
- ini:WriteFile();
-end
-
-
-
-
-
---- Returns true if a_Item is the wand tool item
-function cConfig:IsWand(a_Item)
- return (
- (a_Item.m_ItemType == self.m_Wand.m_ItemType) and
- (a_Item.m_ItemDamage == self.m_Wand.m_ItemDamage)
- );
-end
-
-
-
-
-
---- Returns the wand tool item as a cItem object
-function cConfig:GetWandItem()
- return self.m_Wand;
+
+-- Config.lua
+
+-- Implements the cConfig class that holds the general plugin configuration
+
+
+
+
+
+cConfig = {
+ m_Wand = cItem(E_ITEM_STICK, 1, 1); -- The item to be used as the selection wand
+ m_AllowInteractNoArea = true; -- If there's no area, is a player allowed to build / dig?
+};
+
+
+
+
+
+--- Initializes the cConfig object, loads the configuration from an INI file
+function InitializeConfig()
+ local ini = cIniFile("ProtectionAreas.ini");
+ if (not(ini:ReadFile())) then
+ LOGINFO(PluginPrefix .. "Cannot read ProtectionAreas.ini, all plugin configuration is set to defaults");
+ end
+ local WandItem = cItem();
+ if (
+ StringToItem(ini:GetValueSet("ProtectionAreas", "WandItem", ItemToString(cConfig.m_Wand)), WandItem) and
+ IsValidItem(WandItem.m_ItemType)
+ ) then
+ cConfig.m_Wand = WandItem;
+ end
+ cConfig.m_AllowInteractNoArea = ini:GetValueSetB("ProtectionAreas", "AllowInteractNoArea", cConfig.m_AllowInteractNoArea);
+ ini:WriteFile();
+end
+
+
+
+
+
+--- Returns true if a_Item is the wand tool item
+function cConfig:IsWand(a_Item)
+ return (
+ (a_Item.m_ItemType == self.m_Wand.m_ItemType) and
+ (a_Item.m_ItemDamage == self.m_Wand.m_ItemDamage)
+ );
+end
+
+
+
+
+
+--- Returns the wand tool item as a cItem object
+function cConfig:GetWandItem()
+ return self.m_Wand;
end \ No newline at end of file
diff --git a/MCServer/Plugins/ProtectionAreas/CurrentLng.lua b/MCServer/Plugins/ProtectionAreas/CurrentLng.lua
index b0ad3863c..37ff135c5 100644
--- a/MCServer/Plugins/ProtectionAreas/CurrentLng.lua
+++ b/MCServer/Plugins/ProtectionAreas/CurrentLng.lua
@@ -1,76 +1,76 @@
-
--- CurrentLng.lua
--- This file provides all the translatable strings
--- The expectation is that the translators will create copies of this file, translate the texts and then the users will overwrite this file with a specific language version
--- Note that the individual languages must not have ".lua" extension, otherwise MCServer will load them and the plugin won't work!
-
-
-
-
--- Individual commands, and their help strings. Don't touch the first symbol on each line!
--- This needs to be implemented as a function, because it references other functions which might not yet be loaded while Lua is processing the globals
-
-function CommandReg()
- return {
- -- Handler function | Command | Permission | Help text
- {HandleAddArea, "/ProtAdd", "Prot.Add", "<UserNames> - Adds a new protected area"},
- {HandleAddAreaCoords, "/ProtAddCoords", "Prot.Add", "<x1> <z1> <x2> <z2> <UserNames> - Adds a new protected area by coords"},
- {HandleAddAreaUser, "/ProtAddUser", "Prot.AddUser", "<AreaID> <UserNames> - Adds new users to an existing protected area"},
- {HandleDelArea, "/ProtDelID", "Prot.Del", "<AreaID> - Deletes a protected area by ID"},
- {HandleGiveWand, "/ProtWand", "Prot.Wand", " - Gives you the wand used for protection"},
- {HandleListAreas, "/ProtList", "Prot.List", "[<x> <z>] - Lists all areas for the marked block or given coords"},
- {HandleListUsers, "/ProtUsers", "Prot.List", "<AreaID> - Lists all allowed users for a given area ID"},
- {HandleRemoveUser, "/ProtRemUser", "Prot.RemUser", "<AreaID> <UserName> - Removes a user from the protected area"},
- {HandleRemoveUserAll, "/ProtRemUserAll", "Prot.RemUser", "<UserName> - Removes a user from all protected areas"},
- };
-end;
-
-
-
-
-
---- Messages sent to players
-g_Msgs =
-{
- AllUsersAlreadyAllowed = "All the specified users were already allowed.";
- AreaAdded = "Area added, ID %s";
- AreaAllowed = "Allowed";
- AreaDeleted = "Area ID %s deleted";
- AreaNotAllowed = "NOT allowed";
- Coords1Set = "Coords1 set as {%d, %d}";
- Coords2Set = "Coords2 set as {%d, %d}";
- ErrCmdStateNilAddArea = "Cannot add area, internal plugin error (CmdState == nil)";
- ErrCmdStateNilListAreas = "Cannot list areas, internal plugin error (CmdState == nil)";
- ErrDBFailAddUsers = "Cannot add users, DB failure";
- ErrExpectedAreaID = "Parameter mismatch. Expected <AreaID>.";
- ErrExpectedAreaIDUserName = "Parameter mismatch. Expected <AreaID> <UserName>.";
- ErrExpectedAreaIDUsernames = "Not enough parameters. Expected <AreaID> and a list of usernames.";
- ErrExpectedCoordsUsernames = "Not enough parameters. Expected <x1> <z1> <x2> <z2> coords and a list of usernames.";
- ErrExpectedListOfUsernames = "Not enough parameters. Expected a list of usernames.";
- ErrExpectedUserName = "Parameter mismatch. Expected <UserName>.";
- ErrListNotWanded = "Cannot list areas, no query point has been selected. Use a ProtWand lclk / rclk to select a point first";
- ErrNoAreaWanded = "Cannot add area, no area has been selected. Use a ProtWand lclk / rclk to select area first";
- ErrNoSpaceForWand = "Cannot give wand, no space in your inventory";
- ErrNoSuchArea = "No such area: %s";
- ErrParseAreaID = "Cannot parse <AreaID>.";
- ErrParseCoords = "Cannot parse coords.";
- ErrParseCoordsListAreas = "Cannot list areas, cannot parse coords in params";
- ErrSyntaxErrorListAreas = "Cannot list areas, syntax error. Expected either no params or <x> <z>.";
- ListAreasFooter = "Area list finished";
- ListAreasHeader = "Listing protection areas intersecting block column {%d, %d}:";
- ListAreasRow = " %s, %s, created by %s";
- ListUsersFooter = "End of area %s user list, total %d users";
- ListUsersHeader = "Area ID %s: {%d, %d} - {%d, %d}, created by %s; allowed users:";
- ListUsersRow = " %s";
- NotAllowedToBuild = "You are not allowed to build here!";
- NotAllowedToDig = "You are not allowed to dig here!";
- RemovedUser = "Removed %s from area %d";
- RemovedUserAll = "Removed %s from all areas";
- UsersAdded = "Users added: %s";
- WandGiven = "Wand given";
-} ;
-
-
-
-
-
+
+-- CurrentLng.lua
+-- This file provides all the translatable strings
+-- The expectation is that the translators will create copies of this file, translate the texts and then the users will overwrite this file with a specific language version
+-- Note that the individual languages must not have ".lua" extension, otherwise MCServer will load them and the plugin won't work!
+
+
+
+
+-- Individual commands, and their help strings. Don't touch the first symbol on each line!
+-- This needs to be implemented as a function, because it references other functions which might not yet be loaded while Lua is processing the globals
+
+function CommandReg()
+ return {
+ -- Handler function | Command | Permission | Help text
+ {HandleAddArea, "/ProtAdd", "Prot.Add", "<UserNames> - Adds a new protected area"},
+ {HandleAddAreaCoords, "/ProtAddCoords", "Prot.Add", "<x1> <z1> <x2> <z2> <UserNames> - Adds a new protected area by coords"},
+ {HandleAddAreaUser, "/ProtAddUser", "Prot.AddUser", "<AreaID> <UserNames> - Adds new users to an existing protected area"},
+ {HandleDelArea, "/ProtDelID", "Prot.Del", "<AreaID> - Deletes a protected area by ID"},
+ {HandleGiveWand, "/ProtWand", "Prot.Wand", " - Gives you the wand used for protection"},
+ {HandleListAreas, "/ProtList", "Prot.List", "[<x> <z>] - Lists all areas for the marked block or given coords"},
+ {HandleListUsers, "/ProtUsers", "Prot.List", "<AreaID> - Lists all allowed users for a given area ID"},
+ {HandleRemoveUser, "/ProtRemUser", "Prot.RemUser", "<AreaID> <UserName> - Removes a user from the protected area"},
+ {HandleRemoveUserAll, "/ProtRemUserAll", "Prot.RemUser", "<UserName> - Removes a user from all protected areas"},
+ };
+end;
+
+
+
+
+
+--- Messages sent to players
+g_Msgs =
+{
+ AllUsersAlreadyAllowed = "All the specified users were already allowed.";
+ AreaAdded = "Area added, ID %s";
+ AreaAllowed = "Allowed";
+ AreaDeleted = "Area ID %s deleted";
+ AreaNotAllowed = "NOT allowed";
+ Coords1Set = "Coords1 set as {%d, %d}";
+ Coords2Set = "Coords2 set as {%d, %d}";
+ ErrCmdStateNilAddArea = "Cannot add area, internal plugin error (CmdState == nil)";
+ ErrCmdStateNilListAreas = "Cannot list areas, internal plugin error (CmdState == nil)";
+ ErrDBFailAddUsers = "Cannot add users, DB failure";
+ ErrExpectedAreaID = "Parameter mismatch. Expected <AreaID>.";
+ ErrExpectedAreaIDUserName = "Parameter mismatch. Expected <AreaID> <UserName>.";
+ ErrExpectedAreaIDUsernames = "Not enough parameters. Expected <AreaID> and a list of usernames.";
+ ErrExpectedCoordsUsernames = "Not enough parameters. Expected <x1> <z1> <x2> <z2> coords and a list of usernames.";
+ ErrExpectedListOfUsernames = "Not enough parameters. Expected a list of usernames.";
+ ErrExpectedUserName = "Parameter mismatch. Expected <UserName>.";
+ ErrListNotWanded = "Cannot list areas, no query point has been selected. Use a ProtWand lclk / rclk to select a point first";
+ ErrNoAreaWanded = "Cannot add area, no area has been selected. Use a ProtWand lclk / rclk to select area first";
+ ErrNoSpaceForWand = "Cannot give wand, no space in your inventory";
+ ErrNoSuchArea = "No such area: %s";
+ ErrParseAreaID = "Cannot parse <AreaID>.";
+ ErrParseCoords = "Cannot parse coords.";
+ ErrParseCoordsListAreas = "Cannot list areas, cannot parse coords in params";
+ ErrSyntaxErrorListAreas = "Cannot list areas, syntax error. Expected either no params or <x> <z>.";
+ ListAreasFooter = "Area list finished";
+ ListAreasHeader = "Listing protection areas intersecting block column {%d, %d}:";
+ ListAreasRow = " %s, %s, created by %s";
+ ListUsersFooter = "End of area %s user list, total %d users";
+ ListUsersHeader = "Area ID %s: {%d, %d} - {%d, %d}, created by %s; allowed users:";
+ ListUsersRow = " %s";
+ NotAllowedToBuild = "You are not allowed to build here!";
+ NotAllowedToDig = "You are not allowed to dig here!";
+ RemovedUser = "Removed %s from area %d";
+ RemovedUserAll = "Removed %s from all areas";
+ UsersAdded = "Users added: %s";
+ WandGiven = "Wand given";
+} ;
+
+
+
+
+
diff --git a/MCServer/Plugins/ProtectionAreas/HookHandlers.lua b/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
index 18fd4fa03..ded64d298 100644
--- a/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
+++ b/MCServer/Plugins/ProtectionAreas/HookHandlers.lua
@@ -1,139 +1,139 @@
-
--- HookHandlers.lua
--- Implements the handlers for individual hooks
-
-
-
-
-
---- Registers all the hooks that the plugin needs to know about
-function InitializeHooks(a_Plugin)
- local PlgMgr = cRoot:Get():GetPluginManager();
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_DISCONNECT);
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_LEFT_CLICK);
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_MOVING);
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_RIGHT_CLICK);
- PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_SPAWNED);
-end
-
-
-
-
-
---- Called by MCS when a player's connectino is lost - either they disconnected or timed out
-function OnDisconnect(a_Player, a_Reason)
- -- Remove the player's cProtectionArea object
- g_PlayerAreas[a_Player:GetUniqueID()] = nil;
-
- -- If the player is a VIP, they had a command state, remove that as well
- g_CommandStates[a_Player:GetUniqueID()] = nil;
-
- return false;
-end;
-
-
-
-
-
---- Called by MCS whenever a player enters a world (is spawned)
-function OnPlayerSpawned(a_Player)
- -- Create a new cPlayerAreas object for this player
- if (g_PlayerAreas[a_Player:GetUniqueID()] == nil) then
- LoadPlayerAreas(a_Player);
- end;
-
- return false;
-end
-
-
-
-
-
---- Called by MCS whenever a player is moving (at most once every tick)
-function OnPlayerMoving(a_Player)
- local PlayerID = a_Player:GetUniqueID();
-
- -- If for some reason we don't have a cPlayerAreas object for this player, load it up
- local PlayerAreas = g_PlayerAreas[PlayerID];
- if (PlayerAreas == nil) then
- LoadPlayerAreas(a_Player);
- return false;
- end;
-
- -- If the player is outside their areas' safe space, reload
- if (not(PlayerAreas:IsInSafe(a_Player:GetPosX(), a_Player:GetPosZ()))) then
- LoadPlayerAreas(a_Player);
- end
- return false;
-end
-
-
-
-
-
---- Called by MCS when a player left-clicks
-function OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status)
- -- If the player has lclked with the wand; regardless of their permissions, let's set the coords:
- if (cConfig:IsWand(a_Player:GetEquippedItem())) then
- -- BlockFace < 0 means "use item", for which the coords are not given by the client
- if (a_BlockFace < 0) then
- return true;
- end
-
- -- Convert the clicked coords into the block space
- a_BlockX, a_BlockY, a_BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
-
- -- Set the coords in the CommandState
- GetCommandStateForPlayer(a_Player):SetCoords1(a_BlockX, a_BlockZ);
- a_Player:SendMessage(string.format(g_Msgs.Coords1Set, a_BlockX, a_BlockZ));
- return true;
- end;
-
- -- Check the player areas to see whether to disable this action
- local Areas = g_PlayerAreas[a_Player:GetUniqueID()];
- if not(Areas:CanInteractWithBlock(a_BlockX, a_BlockZ)) then
- a_Player:SendMessage(g_Msgs.NotAllowedToDig);
- return true;
- end
-
- -- Allow interaction
- return false;
-end
-
-
-
-
-
---- Called by MCS when a player right-clicks
-function OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_Status)
-
- -- BlockFace < 0 means "use item", for which the coords are not given by the client
- if (a_BlockFace < 0) then
- return true;
- end
-
- -- Convert the clicked coords into the block space
- a_BlockX, a_BlockY, a_BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
-
- -- If the player has rclked with the wand; regardless of their permissions, let's set the coords
- if (cConfig:IsWand(a_Player:GetEquippedItem())) then
- -- Set the coords in the CommandState
- GetCommandStateForPlayer(a_Player):SetCoords2(a_BlockX, a_BlockZ);
- a_Player:SendMessage(string.format(g_Msgs.Coords2Set, a_BlockX, a_BlockZ));
- return true;
- end;
-
- -- Check the player areas to see whether to disable this action
- local Areas = g_PlayerAreas[a_Player:GetUniqueID()];
- if not(Areas:CanInteractWithBlock(a_BlockX, a_BlockZ)) then
- a_Player:SendMessage(g_Msgs.NotAllowedToBuild);
- return true;
- end
-
- -- Allow interaction
- return false;
-end
-
-
-
-
+
+-- HookHandlers.lua
+-- Implements the handlers for individual hooks
+
+
+
+
+
+--- Registers all the hooks that the plugin needs to know about
+function InitializeHooks(a_Plugin)
+ local PlgMgr = cRoot:Get():GetPluginManager();
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_DISCONNECT);
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_LEFT_CLICK);
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_MOVING);
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_RIGHT_CLICK);
+ PlgMgr:AddHook(a_Plugin, cPluginManager.HOOK_PLAYER_SPAWNED);
+end
+
+
+
+
+
+--- Called by MCS when a player's connectino is lost - either they disconnected or timed out
+function OnDisconnect(a_Player, a_Reason)
+ -- Remove the player's cProtectionArea object
+ g_PlayerAreas[a_Player:GetUniqueID()] = nil;
+
+ -- If the player is a VIP, they had a command state, remove that as well
+ g_CommandStates[a_Player:GetUniqueID()] = nil;
+
+ return false;
+end;
+
+
+
+
+
+--- Called by MCS whenever a player enters a world (is spawned)
+function OnPlayerSpawned(a_Player)
+ -- Create a new cPlayerAreas object for this player
+ if (g_PlayerAreas[a_Player:GetUniqueID()] == nil) then
+ LoadPlayerAreas(a_Player);
+ end;
+
+ return false;
+end
+
+
+
+
+
+--- Called by MCS whenever a player is moving (at most once every tick)
+function OnPlayerMoving(a_Player)
+ local PlayerID = a_Player:GetUniqueID();
+
+ -- If for some reason we don't have a cPlayerAreas object for this player, load it up
+ local PlayerAreas = g_PlayerAreas[PlayerID];
+ if (PlayerAreas == nil) then
+ LoadPlayerAreas(a_Player);
+ return false;
+ end;
+
+ -- If the player is outside their areas' safe space, reload
+ if (not(PlayerAreas:IsInSafe(a_Player:GetPosX(), a_Player:GetPosZ()))) then
+ LoadPlayerAreas(a_Player);
+ end
+ return false;
+end
+
+
+
+
+
+--- Called by MCS when a player left-clicks
+function OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status)
+ -- If the player has lclked with the wand; regardless of their permissions, let's set the coords:
+ if (cConfig:IsWand(a_Player:GetEquippedItem())) then
+ -- BlockFace < 0 means "use item", for which the coords are not given by the client
+ if (a_BlockFace < 0) then
+ return true;
+ end
+
+ -- Convert the clicked coords into the block space
+ a_BlockX, a_BlockY, a_BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+
+ -- Set the coords in the CommandState
+ GetCommandStateForPlayer(a_Player):SetCoords1(a_BlockX, a_BlockZ);
+ a_Player:SendMessage(string.format(g_Msgs.Coords1Set, a_BlockX, a_BlockZ));
+ return true;
+ end;
+
+ -- Check the player areas to see whether to disable this action
+ local Areas = g_PlayerAreas[a_Player:GetUniqueID()];
+ if not(Areas:CanInteractWithBlock(a_BlockX, a_BlockZ)) then
+ a_Player:SendMessage(g_Msgs.NotAllowedToDig);
+ return true;
+ end
+
+ -- Allow interaction
+ return false;
+end
+
+
+
+
+
+--- Called by MCS when a player right-clicks
+function OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_Status)
+
+ -- BlockFace < 0 means "use item", for which the coords are not given by the client
+ if (a_BlockFace < 0) then
+ return true;
+ end
+
+ -- Convert the clicked coords into the block space
+ a_BlockX, a_BlockY, a_BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+
+ -- If the player has rclked with the wand; regardless of their permissions, let's set the coords
+ if (cConfig:IsWand(a_Player:GetEquippedItem())) then
+ -- Set the coords in the CommandState
+ GetCommandStateForPlayer(a_Player):SetCoords2(a_BlockX, a_BlockZ);
+ a_Player:SendMessage(string.format(g_Msgs.Coords2Set, a_BlockX, a_BlockZ));
+ return true;
+ end;
+
+ -- Check the player areas to see whether to disable this action
+ local Areas = g_PlayerAreas[a_Player:GetUniqueID()];
+ if not(Areas:CanInteractWithBlock(a_BlockX, a_BlockZ)) then
+ a_Player:SendMessage(g_Msgs.NotAllowedToBuild);
+ return true;
+ end
+
+ -- Allow interaction
+ return false;
+end
+
+
+
+
diff --git a/MCServer/Plugins/ProtectionAreas/LICENSE.txt b/MCServer/Plugins/ProtectionAreas/LICENSE.txt
index c46949f66..86c9130cc 100644
--- a/MCServer/Plugins/ProtectionAreas/LICENSE.txt
+++ b/MCServer/Plugins/ProtectionAreas/LICENSE.txt
@@ -1,7 +1,7 @@
-
-ProtectionAreas license
-=======================
-
-The ProtectionAreas plugin is written by _Xoft(o) / Mattes and is hereby released as public domain.
-
-If you like it, I'd really appreciate a postcard, or something tiny typical from your country :) The current snailmail address is at my personal web, http://xoft.cz .
+
+ProtectionAreas license
+=======================
+
+The ProtectionAreas plugin is written by _Xoft(o) / Mattes and is hereby released as public domain.
+
+If you like it, I'd really appreciate a postcard, or something tiny typical from your country :) The current snailmail address is at my personal web, http://xoft.cz .
diff --git a/MCServer/Plugins/ProtectionAreas/PlayerAreas.lua b/MCServer/Plugins/ProtectionAreas/PlayerAreas.lua
index 5627f4d5f..f6106ee77 100644
--- a/MCServer/Plugins/ProtectionAreas/PlayerAreas.lua
+++ b/MCServer/Plugins/ProtectionAreas/PlayerAreas.lua
@@ -1,109 +1,109 @@
-
--- PlayerAreas.lua
--- Implements the cPlayerAreas class representing the per-player area storage object
-
---[[
-Each player instance is expected to have a separate object of type cPlayerAreas.
-Each object has an array of {cuboid, IsAllowed} tables, one for each area that is "within reach"
-The code can then ask each object, whether the player can interact with a certain block or not.
-A player can interact with a block if either one of these is true:
-1, There are no areas covering the block
-2, There is at least one area covering the block with IsAllowed set to true
-The object also has a m_SafeCuboid object that specified the area within which the player may move
-without the PlayerAreas needing a re-query.
-
-Also, a global table g_PlayerAreas is the actual map of PlayerID -> cPlayerAreas
---]]
-
-
-
-
-cPlayerAreas = {};
-
-g_PlayerAreas = {};
-
-
-
-
-
-function cPlayerAreas:new(a_SafeMinX, a_SafeMinZ, a_SafeMaxX, a_SafeMaxZ)
- assert(a_SafeMinX);
- assert(a_SafeMinZ);
- assert(a_SafeMaxX);
- assert(a_SafeMaxZ);
-
- local obj = {};
- setmetatable(obj, self);
- self.__index = self;
- self.m_SafeCuboid = cCuboid(a_SafeMinX, 0, a_SafeMinZ, a_SafeMaxX, 255, a_SafeMaxZ);
- return obj;
-end
-
-
-
-
--- Adds a new cuboid to the area list, where the player is either allowed or not, depending on the IsAllowed param
-function cPlayerAreas:AddArea(a_Cuboid, a_IsAllowed)
- table.insert(self, {m_Cuboid = a_Cuboid, m_IsAllowed = a_IsAllowed});
-end
-
-
-
-
-
---- returns true if the player owning this object can interact with the specified block
-function cPlayerAreas:CanInteractWithBlock(a_BlockX, a_BlockZ)
- assert(self);
-
- -- iterate through all the stored areas:
- local IsInsideAnyArea = false;
- for idx, Area in ipairs(self) do
- if (Area.m_Cuboid:IsInside(a_BlockX, 1, a_BlockZ)) then -- We don't care about Y coords, so use a dummy value
- if (Area.m_IsAllowed) then
- return true;
- end
- -- The coords are inside a cuboid for which the player doesn't have access, take a note of it
- IsInsideAnyArea = true;
- end
- end
-
- if (IsInsideAnyArea) then
- -- The specified coords are inside at least one area, but none of them allow the player to interact
- return false;
- end
-
- -- The coords are not inside any area
- return cConfig.m_AllowInteractNoArea;
-end
-
-
-
-
-
---- Calls the specified callback for each area contained within
--- a_Callback has a signature: function(a_Cuboid, a_IsAllowed)
--- Returns true if all areas have been enumerated, false if the callback has aborted by returning true
-function cPlayerAreas:ForEachArea(a_Callback)
- assert(self);
-
- for idx, Area in ipairs(self) do
- if (a_Callback(Area.m_Cuboid, Area.m_IsAllowed)) then
- return false;
- end
- end
- return true;
-end
-
-
-
-
-
---- Returns true if the player is withing the safe cuboid (no need to re-query the areas)
-function cPlayerAreas:IsInSafe(a_BlockX, a_BlockZ)
- assert(self);
- return self.m_SafeCuboid:IsInside(a_BlockX, 0, a_BlockZ);
-end
-
-
-
-
+
+-- PlayerAreas.lua
+-- Implements the cPlayerAreas class representing the per-player area storage object
+
+--[[
+Each player instance is expected to have a separate object of type cPlayerAreas.
+Each object has an array of {cuboid, IsAllowed} tables, one for each area that is "within reach"
+The code can then ask each object, whether the player can interact with a certain block or not.
+A player can interact with a block if either one of these is true:
+1, There are no areas covering the block
+2, There is at least one area covering the block with IsAllowed set to true
+The object also has a m_SafeCuboid object that specified the area within which the player may move
+without the PlayerAreas needing a re-query.
+
+Also, a global table g_PlayerAreas is the actual map of PlayerID -> cPlayerAreas
+--]]
+
+
+
+
+cPlayerAreas = {};
+
+g_PlayerAreas = {};
+
+
+
+
+
+function cPlayerAreas:new(a_SafeMinX, a_SafeMinZ, a_SafeMaxX, a_SafeMaxZ)
+ assert(a_SafeMinX);
+ assert(a_SafeMinZ);
+ assert(a_SafeMaxX);
+ assert(a_SafeMaxZ);
+
+ local obj = {};
+ setmetatable(obj, self);
+ self.__index = self;
+ self.m_SafeCuboid = cCuboid(a_SafeMinX, 0, a_SafeMinZ, a_SafeMaxX, 255, a_SafeMaxZ);
+ return obj;
+end
+
+
+
+
+-- Adds a new cuboid to the area list, where the player is either allowed or not, depending on the IsAllowed param
+function cPlayerAreas:AddArea(a_Cuboid, a_IsAllowed)
+ table.insert(self, {m_Cuboid = a_Cuboid, m_IsAllowed = a_IsAllowed});
+end
+
+
+
+
+
+--- returns true if the player owning this object can interact with the specified block
+function cPlayerAreas:CanInteractWithBlock(a_BlockX, a_BlockZ)
+ assert(self);
+
+ -- iterate through all the stored areas:
+ local IsInsideAnyArea = false;
+ for idx, Area in ipairs(self) do
+ if (Area.m_Cuboid:IsInside(a_BlockX, 1, a_BlockZ)) then -- We don't care about Y coords, so use a dummy value
+ if (Area.m_IsAllowed) then
+ return true;
+ end
+ -- The coords are inside a cuboid for which the player doesn't have access, take a note of it
+ IsInsideAnyArea = true;
+ end
+ end
+
+ if (IsInsideAnyArea) then
+ -- The specified coords are inside at least one area, but none of them allow the player to interact
+ return false;
+ end
+
+ -- The coords are not inside any area
+ return cConfig.m_AllowInteractNoArea;
+end
+
+
+
+
+
+--- Calls the specified callback for each area contained within
+-- a_Callback has a signature: function(a_Cuboid, a_IsAllowed)
+-- Returns true if all areas have been enumerated, false if the callback has aborted by returning true
+function cPlayerAreas:ForEachArea(a_Callback)
+ assert(self);
+
+ for idx, Area in ipairs(self) do
+ if (a_Callback(Area.m_Cuboid, Area.m_IsAllowed)) then
+ return false;
+ end
+ end
+ return true;
+end
+
+
+
+
+
+--- Returns true if the player is withing the safe cuboid (no need to re-query the areas)
+function cPlayerAreas:IsInSafe(a_BlockX, a_BlockZ)
+ assert(self);
+ return self.m_SafeCuboid:IsInside(a_BlockX, 0, a_BlockZ);
+end
+
+
+
+
diff --git a/MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua b/MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua
index 8c2db1387..cbe3fa94d 100644
--- a/MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua
+++ b/MCServer/Plugins/ProtectionAreas/ProtectionAreas.lua
@@ -1,71 +1,71 @@
-
--- ProtectionAreas.lua
--- Defines the main plugin entrypoint, as well as some utility functions
-
-
-
-
-
---- Prefix for all messages logged to the server console
-PluginPrefix = "ProtectionAreas: ";
-
---- Bounds for the area loading. Areas less this far in any direction from the player will be loaded into cPlayerAreas
-g_AreaBounds = 48;
-
---- If a player moves this close to the PlayerAreas bounds, the PlayerAreas will be re-queried
-g_AreaSafeEdge = 12;
-
-
-
-
-
---- Called by MCS when the plugin loads
--- Returns true if initialization successful, false otherwise
-function Initialize(a_Plugin)
- a_Plugin:SetName("ProtectionAreas");
- a_Plugin:SetVersion(1);
-
- InitializeConfig();
- if (not(InitializeStorage())) then
- LOGWARNING(PluginPrefix .. "failed to initialize Storage, plugin is disabled");
- return false;
- end
- InitializeHooks(a_Plugin);
- InitializeCommandHandlers();
-
- -- We might be reloading, so there may be players already present in the server; reload all of them
- cRoot:Get():ForEachWorld(
- function(a_World)
- ReloadAllPlayersInWorld(a_World:GetName());
- end
- );
-
- return true;
-end
-
-
-
-
-
---- Loads a cPlayerAreas object from the DB for the player, and assigns it to the player map
-function LoadPlayerAreas(a_Player)
- local PlayerID = a_Player:GetUniqueID();
- local PlayerX = math.floor(a_Player:GetPosX());
- local PlayerZ = math.floor(a_Player:GetPosZ());
- local WorldName = a_Player:GetWorld():GetName();
- g_PlayerAreas[PlayerID] = g_Storage:LoadPlayerAreas(a_Player:GetName(), PlayerX, PlayerZ, WorldName);
-end
-
-
-
-
-
-function ReloadAllPlayersInWorld(a_WorldName)
- local World = cRoot:Get():GetWorld(a_WorldName);
- World:ForEachPlayer(LoadPlayerAreas);
-end
-
-
-
-
-
+
+-- ProtectionAreas.lua
+-- Defines the main plugin entrypoint, as well as some utility functions
+
+
+
+
+
+--- Prefix for all messages logged to the server console
+PluginPrefix = "ProtectionAreas: ";
+
+--- Bounds for the area loading. Areas less this far in any direction from the player will be loaded into cPlayerAreas
+g_AreaBounds = 48;
+
+--- If a player moves this close to the PlayerAreas bounds, the PlayerAreas will be re-queried
+g_AreaSafeEdge = 12;
+
+
+
+
+
+--- Called by MCS when the plugin loads
+-- Returns true if initialization successful, false otherwise
+function Initialize(a_Plugin)
+ a_Plugin:SetName("ProtectionAreas");
+ a_Plugin:SetVersion(1);
+
+ InitializeConfig();
+ if (not(InitializeStorage())) then
+ LOGWARNING(PluginPrefix .. "failed to initialize Storage, plugin is disabled");
+ return false;
+ end
+ InitializeHooks(a_Plugin);
+ InitializeCommandHandlers();
+
+ -- We might be reloading, so there may be players already present in the server; reload all of them
+ cRoot:Get():ForEachWorld(
+ function(a_World)
+ ReloadAllPlayersInWorld(a_World:GetName());
+ end
+ );
+
+ return true;
+end
+
+
+
+
+
+--- Loads a cPlayerAreas object from the DB for the player, and assigns it to the player map
+function LoadPlayerAreas(a_Player)
+ local PlayerID = a_Player:GetUniqueID();
+ local PlayerX = math.floor(a_Player:GetPosX());
+ local PlayerZ = math.floor(a_Player:GetPosZ());
+ local WorldName = a_Player:GetWorld():GetName();
+ g_PlayerAreas[PlayerID] = g_Storage:LoadPlayerAreas(a_Player:GetName(), PlayerX, PlayerZ, WorldName);
+end
+
+
+
+
+
+function ReloadAllPlayersInWorld(a_WorldName)
+ local World = cRoot:Get():GetWorld(a_WorldName);
+ World:ForEachPlayer(LoadPlayerAreas);
+end
+
+
+
+
+
diff --git a/MCServer/Plugins/ProtectionAreas/Storage.lua b/MCServer/Plugins/ProtectionAreas/Storage.lua
index 07825b172..a6cf564bf 100644
--- a/MCServer/Plugins/ProtectionAreas/Storage.lua
+++ b/MCServer/Plugins/ProtectionAreas/Storage.lua
@@ -1,518 +1,518 @@
-
--- Storage.lua
--- Implements the storage access object, shielding the rest of the code away from the DB
-
---[[
-The cStorage class is the interface to the underlying storage, the SQLite database.
-This class knows how to load player areas from the DB, how to add or remove areas in the DB
-and other such operations.
-
-Also, a g_Storage global variable is declared, it holds the single instance of the storage.
---]]
-
-
-
-
-
-cStorage = {};
-
-g_Storage = {};
-
-
-
-
-
---- Initializes the storage subsystem, creates the g_Storage object
--- Returns true if successful, false if not
-function InitializeStorage()
- g_Storage = cStorage:new();
- if (not(g_Storage:OpenDB())) then
- return false;
- end
-
- return true;
-end
-
-
-
-
-
-function cStorage:new(obj)
- obj = obj or {};
- setmetatable(obj, self);
- self.__index = self;
- return obj;
-end
-
-
-
-
---- Opens the DB and makes sure it has all the columns needed
--- Returns true if successful, false otherwise
-function cStorage:OpenDB()
- local ErrCode, ErrMsg;
- self.DB, ErrCode, ErrMsg = sqlite3.open("ProtectionAreas.sqlite");
- if (self.DB == nil) then
- LOGWARNING(PluginPrefix .. "Cannot open ProtectionAreas.sqlite, error " .. ErrCode .. " (" .. ErrMsg ..")");
- return false;
- end
-
- if (
- not(self:CreateTable("Areas", {"ID INTEGER PRIMARY KEY AUTOINCREMENT", "MinX", "MaxX", "MinZ", "MaxZ", "WorldName", "CreatorUserName"})) or
- not(self:CreateTable("AllowedUsers", {"AreaID", "UserName"}))
- ) then
- LOGWARNING(PluginPrefix .. "Cannot create DB tables!");
- return false;
- end
-
- return true;
-end
-
-
-
-
-
---- Executes the SQL command given, calling the a_Callback for each result
--- If the SQL command fails, prints it out on the server console and returns false
--- Returns true on success
-function cStorage:DBExec(a_SQL, a_Callback, a_CallbackParam)
- local ErrCode = self.DB:exec(a_SQL, a_Callback, a_CallbackParam);
- if (ErrCode ~= sqlite3.OK) then
- LOGWARNING(PluginPrefix .. "Error " .. ErrCode .. " (" .. self.DB:errmsg() ..
- ") while processing SQL command >>" .. a_SQL .. "<<"
- );
- return false;
- end
- return true;
-end
-
-
-
-
-
---- Creates the table of the specified name and columns[]
--- If the table exists, any columns missing are added; existing data is kept
-function cStorage:CreateTable(a_TableName, a_Columns)
- -- Try to create the table first
- local sql = "CREATE TABLE IF NOT EXISTS '" .. a_TableName .. "' (";
- sql = sql .. table.concat(a_Columns, ", ");
- sql = sql .. ")";
- if (not(self:DBExec(sql))) then
- LOGWARNING(PluginPrefix .. "Cannot create DB Table " .. a_TableName);
- return false;
- end
- -- SQLite doesn't inform us if it created the table or not, so we have to continue anyway
-
- -- Check each column whether it exists
- -- Remove all the existing columns from a_Columns:
- local RemoveExistingColumn = function(UserData, NumCols, Values, Names)
- -- Remove the received column from a_Columns. Search for column name in the Names[] / Values[] pairs
- for i = 1, NumCols do
- if (Names[i] == "name") then
- local ColumnName = Values[i]:lower();
- -- Search the a_Columns if they have that column:
- for j = 1, #a_Columns do
- -- Cut away all column specifiers (after the first space), if any:
- local SpaceIdx = string.find(a_Columns[j], " ");
- if (SpaceIdx ~= nil) then
- SpaceIdx = SpaceIdx - 1;
- end
- local ColumnTemplate = string.lower(string.sub(a_Columns[j], 1, SpaceIdx));
- -- If it is a match, remove from a_Columns:
- if (ColumnTemplate == ColumnName) then
- table.remove(a_Columns, j);
- break; -- for j
- end
- end -- for j - a_Columns[]
- end
- end -- for i - Names[] / Values[]
- return 0;
- end
- if (not(self:DBExec("PRAGMA table_info(" .. a_TableName .. ")", RemoveExistingColumn))) then
- LOGWARNING(PluginPrefix .. "Cannot query DB table structure");
- return false;
- end
-
- -- Create the missing columns
- -- a_Columns now contains only those columns that are missing in the DB
- if (#a_Columns > 0) then
- LOGINFO(PluginPrefix .. "Database table \"" .. a_TableName .. "\" is missing " .. #a_Columns .. " columns, fixing now.");
- for idx, ColumnName in ipairs(a_Columns) do
- if (not(self:DBExec("ALTER TABLE '" .. a_TableName .. "' ADD COLUMN " .. ColumnName))) then
- LOGWARNING(PluginPrefix .. "Cannot add DB table \"" .. a_TableName .. "\" column \"" .. ColumnName .. "\"");
- return false;
- end
- end
- LOGINFO(PluginPrefix .. "Database table \"" .. a_TableName .. "\" columns fixed.");
- end
-
- return true;
-end
-
-
-
-
-
---- Returns true if the specified area is allowed for the specified player
-function cStorage:IsAreaAllowed(a_AreaID, a_PlayerName, a_WorldName)
- assert(a_AreaID);
- assert(a_PlayerName);
- assert(a_WorldName);
- assert(self);
-
- local lcPlayerName = string.lower(a_PlayerName);
- local res = false;
- local sql = "SELECT COUNT(*) FROM AllowedUsers WHERE (AreaID = " .. a_AreaID ..
- ") AND (UserName ='" .. lcPlayerName .. "')";
- local function SetResTrue(UserData, NumValues, Values, Names)
- res = (tonumber(Values[1]) > 0);
- return 0;
- end
- if (not(self:DBExec(sql, SetResTrue))) then
- LOGWARNING("SQL error while determining area allowance");
- return false;
- end
- return res;
-end
-
-
-
-
-
---- Loads cPlayerAreas for the specified player from the DB. Returns a cPlayerAreas object
-function cStorage:LoadPlayerAreas(a_PlayerName, a_PlayerX, a_PlayerZ, a_WorldName)
- assert(a_PlayerName);
- assert(a_PlayerX);
- assert(a_PlayerZ);
- assert(a_WorldName);
- assert(self);
-
- -- Bounds for which the areas are loaded
- local BoundsMinX = a_PlayerX - g_AreaBounds;
- local BoundsMaxX = a_PlayerX + g_AreaBounds;
- local BoundsMinZ = a_PlayerZ - g_AreaBounds;
- local BoundsMaxZ = a_PlayerZ + g_AreaBounds;
-
- local res = cPlayerAreas:new(
- BoundsMinX + g_AreaSafeEdge, BoundsMinZ + g_AreaSafeEdge,
- BoundsMaxX - g_AreaSafeEdge, BoundsMaxZ - g_AreaSafeEdge
- );
-
- --[[
- LOG("Loading protection areas for player " .. a_PlayerName .. " centered around {" .. a_PlayerX .. ", " .. a_PlayerZ ..
- "}, bounds are {" .. BoundsMinX .. ", " .. BoundsMinZ .. "} - {" ..
- BoundsMaxX .. ", " .. BoundsMaxZ .. "}"
- );
- --]]
-
- -- Load the areas from the DB, based on the player's location
- local lcWorldName = string.lower(a_WorldName);
- local sql =
- "SELECT ID, MinX, MaxX, MinZ, MaxZ FROM Areas WHERE " ..
- "MinX < " .. BoundsMaxX .. " AND MaxX > " .. BoundsMinX .. " AND " ..
- "MinZ < " .. BoundsMaxZ .. " AND MaxZ > " .. BoundsMinZ .. " AND " ..
- "WorldName = '" .. lcWorldName .."'";
-
- local function AddAreas(UserData, NumValues, Values, Names)
- if ((NumValues < 5) or ((Values[1] and Values[2] and Values[3] and Values[4] and Values[5]) == nil)) then
- LOGWARNING("SQL query didn't return all data");
- return 0;
- end
- res:AddArea(cCuboid(Values[2], 0, Values[4], Values[3], 255, Values[5]), self:IsAreaAllowed(Values[1], a_PlayerName, a_WorldName));
- return 0;
- end
-
- if (not(self:DBExec(sql, AddAreas))) then
- LOGWARNING("SQL error while querying areas");
- return res;
- end
-
- return res;
-end
-
-
-
-
-
---- Adds a new area into the DB. a_AllowedNames is a table listing all the players that are allowed in the area
--- Returns the ID of the new area, or -1 on failure
-function cStorage:AddArea(a_Cuboid, a_WorldName, a_CreatorName, a_AllowedNames)
- assert(a_Cuboid);
- assert(a_WorldName);
- assert(a_CreatorName);
- assert(a_AllowedNames);
- assert(self);
-
- -- Store the area in the DB
- local ID = -1;
- local function RememberID(UserData, NumCols, Values, Names)
- for i = 1, NumCols do
- if (Names[i] == "ID") then
- ID = Values[i];
- end
- end
- return 0;
- end
- local lcWorldName = string.lower(a_WorldName);
- local lcCreatorName = string.lower(a_CreatorName);
- local sql =
- "INSERT INTO Areas (ID, MinX, MaxX, MinZ, MaxZ, WorldName, CreatorUserName) VALUES (NULL, " ..
- a_Cuboid.p1.x .. ", " .. a_Cuboid.p2.x .. ", " .. a_Cuboid.p1.z .. ", " .. a_Cuboid.p2.z ..
- ", '" .. lcWorldName .. "', '" .. lcCreatorName ..
- "'); SELECT last_insert_rowid() AS ID";
- if (not(self:DBExec(sql, RememberID))) then
- LOGWARNING(PluginPrefix .. "SQL Error while inserting new area");
- return -1;
- end
- if (ID == -1) then
- LOGWARNING(PluginPrefix .. "SQL Error while retrieving INSERTion ID");
- return -1;
- end
-
- -- Store each allowed player in the DB
- for idx, Name in ipairs(a_AllowedNames) do
- local lcName = string.lower(Name);
- local sql = "INSERT INTO AllowedUsers (AreaID, UserName) VALUES (" .. ID .. ", '" .. lcName .. "')";
- if (not(self:DBExec(sql))) then
- LOGWARNING(PluginPrefix .. "SQL Error while inserting new area's allowed player " .. Name);
- end
- end
- return ID;
-end
-
-
-
-
-
-function cStorage:DelArea(a_WorldName, a_AreaID)
- assert(a_WorldName);
- assert(a_AreaID);
- assert(self);
-
- -- Since all areas are stored in a single DB (for now), the worldname parameter isn't used at all
- -- Later if we change to a per-world DB, we'll need the world name
-
- -- Delete from both tables simultaneously
- local sql =
- "DELETE FROM Areas WHERE ID = " .. a_AreaID .. ";" ..
- "DELETE FROM AllowedUsers WHERE AreaID = " .. a_AreaID;
- if (not(self:DBExec(sql))) then
- LOGWARNING(PluginPrefix .. "SQL error while deleting area " .. a_AreaID .. " from world \"" .. a_WorldName .. "\"");
- return false;
- end
-
- return true;
-end
-
-
-
-
-
---- Removes the user from the specified area
-function cStorage:RemoveUser(a_AreaID, a_UserName, a_WorldName)
- assert(a_AreaID);
- assert(a_UserName);
- assert(a_WorldName);
- assert(self);
-
- -- WorldName is not used yet, because all the worlds share the same DB in this version
-
- local lcUserName = string.lower(a_UserName);
- local sql = "DELETE FROM AllowedUsers WHERE " ..
- "AreaID = " .. a_AreaID .. " AND UserName = '" .. lcUserName .. "'";
- if (not(self:DBExec(sql))) then
- LOGWARNING("SQL error while removing user " .. a_UserName .. " from area ID " .. a_AreaID);
- return false;
- end
- return true;
-end
-
-
-
-
-
---- Removes the user from all areas in the specified world
-function cStorage:RemoveUserAll(a_UserName, a_WorldName)
- assert(a_UserName);
- assert(a_WorldName);
- assert(self);
-
- local lcUserName = string.lower(a_UserName);
- local sql = "DELETE FROM AllowedUsers WHERE UserName = '" .. lcUserName .."'";
- if (not(self:DBExec(sql))) then
- LOGWARNING("SQL error while removing user " .. a_UserName .. " from all areas");
- return false;
- end
- return true;
-end
-
-
-
-
-
---- Calls the callback for each area intersecting the specified coords
--- Callback signature: function(ID, MinX, MinZ, MaxX, MaxZ, CreatorName)
-function cStorage:ForEachArea(a_BlockX, a_BlockZ, a_WorldName, a_Callback)
- assert(a_BlockX);
- assert(a_BlockZ);
- assert(a_WorldName);
- assert(a_Callback);
- assert(self);
-
- -- SQL callback that parses the values and calls our callback
- function CallCallback(UserData, NumValues, Values, Names)
- if (NumValues ~= 6) then
- -- Not enough values returned, skip this row
- return 0;
- end
- local ID = Values[1];
- local MinX = Values[2];
- local MinZ = Values[3];
- local MaxX = Values[4];
- local MaxZ = Values[5];
- local CreatorName = Values[6];
- a_Callback(ID, MinX, MinZ, MaxX, MaxZ, CreatorName);
- return 0;
- end
-
- local lcWorldName = string.lower(a_WorldName);
- local sql = "SELECT ID, MinX, MinZ, MaxX, MaxZ, CreatorUserName FROM Areas WHERE " ..
- "MinX <= " .. a_BlockX .. " AND MaxX >= " .. a_BlockX .. " AND " ..
- "MinZ <= " .. a_BlockZ .. " AND MaxZ >= " .. a_BlockZ .. " AND " ..
- "WorldName = '" .. lcWorldName .. "'";
- if (not(self:DBExec(sql, CallCallback))) then
- LOGWARNING("SQL Error while iterating through areas (cStorage:ForEachArea())");
- return false;
- end
- return true;
-end
-
-
-
-
-
---- Returns the info on the specified area
--- Returns MinX, MinZ, MaxX, MaxZ, CreatorName on success, or nothing on failure
-function cStorage:GetArea(a_AreaID, a_WorldName)
- assert(a_AreaID);
- assert(a_WorldName);
- assert(self);
-
- local MinX, MinZ, MaxX, MaxZ, CreatorName;
- local HasValues = false;
-
- -- SQL callback that parses the values and remembers them in variables
- function RememberValues(UserData, NumValues, Values, Names)
- if (NumValues ~= 5) then
- -- Not enough values returned, skip this row
- return 0;
- end
- MinX = Values[1];
- MinZ = Values[2];
- MaxX = Values[3];
- MaxZ = Values[4];
- CreatorName = Values[5];
- HasValues = true;
- return 0;
- end
-
- local lcWorldName = string.lower(a_WorldName);
- local sql = "SELECT MinX, MinZ, MaxX, MaxZ, CreatorUserName FROM Areas WHERE " ..
- "ID = " .. a_AreaID .. " AND WorldName = '" .. lcWorldName .. "'";
- if (not(self:DBExec(sql, RememberValues))) then
- LOGWARNING("SQL Error while getting area info (cStorage:ForEachArea())");
- return;
- end
-
- -- If no data has been retrieved, return nothing
- if (not(HasValues)) then
- return;
- end
-
- return MinX, MinZ, MaxX, MaxZ, CreatorName;
-end
-
-
-
-
-
---- Calls the callback for each allowed user for the specified area
--- Callback signature: function(UserName)
-function cStorage:ForEachUserInArea(a_AreaID, a_WorldName, a_Callback)
- assert(a_AreaID);
- assert(a_WorldName);
- assert(a_Callback);
- assert(self);
-
- -- Since in this version all the worlds share a single DB, the a_WorldName parameter is not actually used
- -- But this may change in the future, when we have a per-world DB
-
- local function CallCallback(UserData, NumValues, Values)
- if (NumValues ~= 1) then
- return 0;
- end
- a_Callback(Values[1]);
- return 0;
- end
- local sql = "SELECT UserName FROM AllowedUsers WHERE AreaID = " .. a_AreaID;
- if (not(self:DBExec(sql, CallCallback))) then
- LOGWARNING("SQL error while iterating area users for AreaID" .. a_AreaID);
- return false;
- end
- return true;
-end
-
-
-
-
-
---- Adds the specified usernames to the specified area, if not already present
--- a_Users is an array table of usernames to add
-function cStorage:AddAreaUsers(a_AreaID, a_WorldName, a_AddedBy, a_Users)
- assert(a_AreaID);
- assert(a_WorldName);
- assert(a_Users);
- assert(self);
-
- -- Convert all usernames to lowercase
- for idx, Name in ipairs(a_Users) do
- a_Users[idx] = string.lower(Name);
- end
-
- -- Remove from a_Users the usernames already present in the area
- local sql = "SELECT UserName FROM AllowedUsers WHERE AreaID = " .. a_AreaID;
- local function RemovePresent(UserData, NumValues, Values, Names)
- if (NumValues ~= 1) then
- -- Invalid response format
- return 0;
- end
- local DBName = Values[1];
- -- Remove the name from a_Users, if exists
- for idx, Name in ipairs(a_Users) do
- if (Name == DBName) then
- table.remove(a_Users, idx);
- return 0;
- end
- end
- return 0;
- end
- if (not(self:DBExec(sql, RemovePresent))) then
- LOGWARNING("SQL error while iterating through users");
- return false;
- end
-
- -- Add the users
- for idx, Name in ipairs(a_Users) do
- local sql = "INSERT INTO AllowedUsers (AreaID, UserName) VALUES (" .. a_AreaID .. ", '" .. Name .. "')";
- if (not(self:DBExec(sql))) then
- LOGWARNING("SQL error while adding user " .. Name .. " to area " .. a_AreaID);
- end
- end
-
- return true;
-end
-
-
-
-
-
+
+-- Storage.lua
+-- Implements the storage access object, shielding the rest of the code away from the DB
+
+--[[
+The cStorage class is the interface to the underlying storage, the SQLite database.
+This class knows how to load player areas from the DB, how to add or remove areas in the DB
+and other such operations.
+
+Also, a g_Storage global variable is declared, it holds the single instance of the storage.
+--]]
+
+
+
+
+
+cStorage = {};
+
+g_Storage = {};
+
+
+
+
+
+--- Initializes the storage subsystem, creates the g_Storage object
+-- Returns true if successful, false if not
+function InitializeStorage()
+ g_Storage = cStorage:new();
+ if (not(g_Storage:OpenDB())) then
+ return false;
+ end
+
+ return true;
+end
+
+
+
+
+
+function cStorage:new(obj)
+ obj = obj or {};
+ setmetatable(obj, self);
+ self.__index = self;
+ return obj;
+end
+
+
+
+
+--- Opens the DB and makes sure it has all the columns needed
+-- Returns true if successful, false otherwise
+function cStorage:OpenDB()
+ local ErrCode, ErrMsg;
+ self.DB, ErrCode, ErrMsg = sqlite3.open("ProtectionAreas.sqlite");
+ if (self.DB == nil) then
+ LOGWARNING(PluginPrefix .. "Cannot open ProtectionAreas.sqlite, error " .. ErrCode .. " (" .. ErrMsg ..")");
+ return false;
+ end
+
+ if (
+ not(self:CreateTable("Areas", {"ID INTEGER PRIMARY KEY AUTOINCREMENT", "MinX", "MaxX", "MinZ", "MaxZ", "WorldName", "CreatorUserName"})) or
+ not(self:CreateTable("AllowedUsers", {"AreaID", "UserName"}))
+ ) then
+ LOGWARNING(PluginPrefix .. "Cannot create DB tables!");
+ return false;
+ end
+
+ return true;
+end
+
+
+
+
+
+--- Executes the SQL command given, calling the a_Callback for each result
+-- If the SQL command fails, prints it out on the server console and returns false
+-- Returns true on success
+function cStorage:DBExec(a_SQL, a_Callback, a_CallbackParam)
+ local ErrCode = self.DB:exec(a_SQL, a_Callback, a_CallbackParam);
+ if (ErrCode ~= sqlite3.OK) then
+ LOGWARNING(PluginPrefix .. "Error " .. ErrCode .. " (" .. self.DB:errmsg() ..
+ ") while processing SQL command >>" .. a_SQL .. "<<"
+ );
+ return false;
+ end
+ return true;
+end
+
+
+
+
+
+--- Creates the table of the specified name and columns[]
+-- If the table exists, any columns missing are added; existing data is kept
+function cStorage:CreateTable(a_TableName, a_Columns)
+ -- Try to create the table first
+ local sql = "CREATE TABLE IF NOT EXISTS '" .. a_TableName .. "' (";
+ sql = sql .. table.concat(a_Columns, ", ");
+ sql = sql .. ")";
+ if (not(self:DBExec(sql))) then
+ LOGWARNING(PluginPrefix .. "Cannot create DB Table " .. a_TableName);
+ return false;
+ end
+ -- SQLite doesn't inform us if it created the table or not, so we have to continue anyway
+
+ -- Check each column whether it exists
+ -- Remove all the existing columns from a_Columns:
+ local RemoveExistingColumn = function(UserData, NumCols, Values, Names)
+ -- Remove the received column from a_Columns. Search for column name in the Names[] / Values[] pairs
+ for i = 1, NumCols do
+ if (Names[i] == "name") then
+ local ColumnName = Values[i]:lower();
+ -- Search the a_Columns if they have that column:
+ for j = 1, #a_Columns do
+ -- Cut away all column specifiers (after the first space), if any:
+ local SpaceIdx = string.find(a_Columns[j], " ");
+ if (SpaceIdx ~= nil) then
+ SpaceIdx = SpaceIdx - 1;
+ end
+ local ColumnTemplate = string.lower(string.sub(a_Columns[j], 1, SpaceIdx));
+ -- If it is a match, remove from a_Columns:
+ if (ColumnTemplate == ColumnName) then
+ table.remove(a_Columns, j);
+ break; -- for j
+ end
+ end -- for j - a_Columns[]
+ end
+ end -- for i - Names[] / Values[]
+ return 0;
+ end
+ if (not(self:DBExec("PRAGMA table_info(" .. a_TableName .. ")", RemoveExistingColumn))) then
+ LOGWARNING(PluginPrefix .. "Cannot query DB table structure");
+ return false;
+ end
+
+ -- Create the missing columns
+ -- a_Columns now contains only those columns that are missing in the DB
+ if (#a_Columns > 0) then
+ LOGINFO(PluginPrefix .. "Database table \"" .. a_TableName .. "\" is missing " .. #a_Columns .. " columns, fixing now.");
+ for idx, ColumnName in ipairs(a_Columns) do
+ if (not(self:DBExec("ALTER TABLE '" .. a_TableName .. "' ADD COLUMN " .. ColumnName))) then
+ LOGWARNING(PluginPrefix .. "Cannot add DB table \"" .. a_TableName .. "\" column \"" .. ColumnName .. "\"");
+ return false;
+ end
+ end
+ LOGINFO(PluginPrefix .. "Database table \"" .. a_TableName .. "\" columns fixed.");
+ end
+
+ return true;
+end
+
+
+
+
+
+--- Returns true if the specified area is allowed for the specified player
+function cStorage:IsAreaAllowed(a_AreaID, a_PlayerName, a_WorldName)
+ assert(a_AreaID);
+ assert(a_PlayerName);
+ assert(a_WorldName);
+ assert(self);
+
+ local lcPlayerName = string.lower(a_PlayerName);
+ local res = false;
+ local sql = "SELECT COUNT(*) FROM AllowedUsers WHERE (AreaID = " .. a_AreaID ..
+ ") AND (UserName ='" .. lcPlayerName .. "')";
+ local function SetResTrue(UserData, NumValues, Values, Names)
+ res = (tonumber(Values[1]) > 0);
+ return 0;
+ end
+ if (not(self:DBExec(sql, SetResTrue))) then
+ LOGWARNING("SQL error while determining area allowance");
+ return false;
+ end
+ return res;
+end
+
+
+
+
+
+--- Loads cPlayerAreas for the specified player from the DB. Returns a cPlayerAreas object
+function cStorage:LoadPlayerAreas(a_PlayerName, a_PlayerX, a_PlayerZ, a_WorldName)
+ assert(a_PlayerName);
+ assert(a_PlayerX);
+ assert(a_PlayerZ);
+ assert(a_WorldName);
+ assert(self);
+
+ -- Bounds for which the areas are loaded
+ local BoundsMinX = a_PlayerX - g_AreaBounds;
+ local BoundsMaxX = a_PlayerX + g_AreaBounds;
+ local BoundsMinZ = a_PlayerZ - g_AreaBounds;
+ local BoundsMaxZ = a_PlayerZ + g_AreaBounds;
+
+ local res = cPlayerAreas:new(
+ BoundsMinX + g_AreaSafeEdge, BoundsMinZ + g_AreaSafeEdge,
+ BoundsMaxX - g_AreaSafeEdge, BoundsMaxZ - g_AreaSafeEdge
+ );
+
+ --[[
+ LOG("Loading protection areas for player " .. a_PlayerName .. " centered around {" .. a_PlayerX .. ", " .. a_PlayerZ ..
+ "}, bounds are {" .. BoundsMinX .. ", " .. BoundsMinZ .. "} - {" ..
+ BoundsMaxX .. ", " .. BoundsMaxZ .. "}"
+ );
+ --]]
+
+ -- Load the areas from the DB, based on the player's location
+ local lcWorldName = string.lower(a_WorldName);
+ local sql =
+ "SELECT ID, MinX, MaxX, MinZ, MaxZ FROM Areas WHERE " ..
+ "MinX < " .. BoundsMaxX .. " AND MaxX > " .. BoundsMinX .. " AND " ..
+ "MinZ < " .. BoundsMaxZ .. " AND MaxZ > " .. BoundsMinZ .. " AND " ..
+ "WorldName = '" .. lcWorldName .."'";
+
+ local function AddAreas(UserData, NumValues, Values, Names)
+ if ((NumValues < 5) or ((Values[1] and Values[2] and Values[3] and Values[4] and Values[5]) == nil)) then
+ LOGWARNING("SQL query didn't return all data");
+ return 0;
+ end
+ res:AddArea(cCuboid(Values[2], 0, Values[4], Values[3], 255, Values[5]), self:IsAreaAllowed(Values[1], a_PlayerName, a_WorldName));
+ return 0;
+ end
+
+ if (not(self:DBExec(sql, AddAreas))) then
+ LOGWARNING("SQL error while querying areas");
+ return res;
+ end
+
+ return res;
+end
+
+
+
+
+
+--- Adds a new area into the DB. a_AllowedNames is a table listing all the players that are allowed in the area
+-- Returns the ID of the new area, or -1 on failure
+function cStorage:AddArea(a_Cuboid, a_WorldName, a_CreatorName, a_AllowedNames)
+ assert(a_Cuboid);
+ assert(a_WorldName);
+ assert(a_CreatorName);
+ assert(a_AllowedNames);
+ assert(self);
+
+ -- Store the area in the DB
+ local ID = -1;
+ local function RememberID(UserData, NumCols, Values, Names)
+ for i = 1, NumCols do
+ if (Names[i] == "ID") then
+ ID = Values[i];
+ end
+ end
+ return 0;
+ end
+ local lcWorldName = string.lower(a_WorldName);
+ local lcCreatorName = string.lower(a_CreatorName);
+ local sql =
+ "INSERT INTO Areas (ID, MinX, MaxX, MinZ, MaxZ, WorldName, CreatorUserName) VALUES (NULL, " ..
+ a_Cuboid.p1.x .. ", " .. a_Cuboid.p2.x .. ", " .. a_Cuboid.p1.z .. ", " .. a_Cuboid.p2.z ..
+ ", '" .. lcWorldName .. "', '" .. lcCreatorName ..
+ "'); SELECT last_insert_rowid() AS ID";
+ if (not(self:DBExec(sql, RememberID))) then
+ LOGWARNING(PluginPrefix .. "SQL Error while inserting new area");
+ return -1;
+ end
+ if (ID == -1) then
+ LOGWARNING(PluginPrefix .. "SQL Error while retrieving INSERTion ID");
+ return -1;
+ end
+
+ -- Store each allowed player in the DB
+ for idx, Name in ipairs(a_AllowedNames) do
+ local lcName = string.lower(Name);
+ local sql = "INSERT INTO AllowedUsers (AreaID, UserName) VALUES (" .. ID .. ", '" .. lcName .. "')";
+ if (not(self:DBExec(sql))) then
+ LOGWARNING(PluginPrefix .. "SQL Error while inserting new area's allowed player " .. Name);
+ end
+ end
+ return ID;
+end
+
+
+
+
+
+function cStorage:DelArea(a_WorldName, a_AreaID)
+ assert(a_WorldName);
+ assert(a_AreaID);
+ assert(self);
+
+ -- Since all areas are stored in a single DB (for now), the worldname parameter isn't used at all
+ -- Later if we change to a per-world DB, we'll need the world name
+
+ -- Delete from both tables simultaneously
+ local sql =
+ "DELETE FROM Areas WHERE ID = " .. a_AreaID .. ";" ..
+ "DELETE FROM AllowedUsers WHERE AreaID = " .. a_AreaID;
+ if (not(self:DBExec(sql))) then
+ LOGWARNING(PluginPrefix .. "SQL error while deleting area " .. a_AreaID .. " from world \"" .. a_WorldName .. "\"");
+ return false;
+ end
+
+ return true;
+end
+
+
+
+
+
+--- Removes the user from the specified area
+function cStorage:RemoveUser(a_AreaID, a_UserName, a_WorldName)
+ assert(a_AreaID);
+ assert(a_UserName);
+ assert(a_WorldName);
+ assert(self);
+
+ -- WorldName is not used yet, because all the worlds share the same DB in this version
+
+ local lcUserName = string.lower(a_UserName);
+ local sql = "DELETE FROM AllowedUsers WHERE " ..
+ "AreaID = " .. a_AreaID .. " AND UserName = '" .. lcUserName .. "'";
+ if (not(self:DBExec(sql))) then
+ LOGWARNING("SQL error while removing user " .. a_UserName .. " from area ID " .. a_AreaID);
+ return false;
+ end
+ return true;
+end
+
+
+
+
+
+--- Removes the user from all areas in the specified world
+function cStorage:RemoveUserAll(a_UserName, a_WorldName)
+ assert(a_UserName);
+ assert(a_WorldName);
+ assert(self);
+
+ local lcUserName = string.lower(a_UserName);
+ local sql = "DELETE FROM AllowedUsers WHERE UserName = '" .. lcUserName .."'";
+ if (not(self:DBExec(sql))) then
+ LOGWARNING("SQL error while removing user " .. a_UserName .. " from all areas");
+ return false;
+ end
+ return true;
+end
+
+
+
+
+
+--- Calls the callback for each area intersecting the specified coords
+-- Callback signature: function(ID, MinX, MinZ, MaxX, MaxZ, CreatorName)
+function cStorage:ForEachArea(a_BlockX, a_BlockZ, a_WorldName, a_Callback)
+ assert(a_BlockX);
+ assert(a_BlockZ);
+ assert(a_WorldName);
+ assert(a_Callback);
+ assert(self);
+
+ -- SQL callback that parses the values and calls our callback
+ function CallCallback(UserData, NumValues, Values, Names)
+ if (NumValues ~= 6) then
+ -- Not enough values returned, skip this row
+ return 0;
+ end
+ local ID = Values[1];
+ local MinX = Values[2];
+ local MinZ = Values[3];
+ local MaxX = Values[4];
+ local MaxZ = Values[5];
+ local CreatorName = Values[6];
+ a_Callback(ID, MinX, MinZ, MaxX, MaxZ, CreatorName);
+ return 0;
+ end
+
+ local lcWorldName = string.lower(a_WorldName);
+ local sql = "SELECT ID, MinX, MinZ, MaxX, MaxZ, CreatorUserName FROM Areas WHERE " ..
+ "MinX <= " .. a_BlockX .. " AND MaxX >= " .. a_BlockX .. " AND " ..
+ "MinZ <= " .. a_BlockZ .. " AND MaxZ >= " .. a_BlockZ .. " AND " ..
+ "WorldName = '" .. lcWorldName .. "'";
+ if (not(self:DBExec(sql, CallCallback))) then
+ LOGWARNING("SQL Error while iterating through areas (cStorage:ForEachArea())");
+ return false;
+ end
+ return true;
+end
+
+
+
+
+
+--- Returns the info on the specified area
+-- Returns MinX, MinZ, MaxX, MaxZ, CreatorName on success, or nothing on failure
+function cStorage:GetArea(a_AreaID, a_WorldName)
+ assert(a_AreaID);
+ assert(a_WorldName);
+ assert(self);
+
+ local MinX, MinZ, MaxX, MaxZ, CreatorName;
+ local HasValues = false;
+
+ -- SQL callback that parses the values and remembers them in variables
+ function RememberValues(UserData, NumValues, Values, Names)
+ if (NumValues ~= 5) then
+ -- Not enough values returned, skip this row
+ return 0;
+ end
+ MinX = Values[1];
+ MinZ = Values[2];
+ MaxX = Values[3];
+ MaxZ = Values[4];
+ CreatorName = Values[5];
+ HasValues = true;
+ return 0;
+ end
+
+ local lcWorldName = string.lower(a_WorldName);
+ local sql = "SELECT MinX, MinZ, MaxX, MaxZ, CreatorUserName FROM Areas WHERE " ..
+ "ID = " .. a_AreaID .. " AND WorldName = '" .. lcWorldName .. "'";
+ if (not(self:DBExec(sql, RememberValues))) then
+ LOGWARNING("SQL Error while getting area info (cStorage:ForEachArea())");
+ return;
+ end
+
+ -- If no data has been retrieved, return nothing
+ if (not(HasValues)) then
+ return;
+ end
+
+ return MinX, MinZ, MaxX, MaxZ, CreatorName;
+end
+
+
+
+
+
+--- Calls the callback for each allowed user for the specified area
+-- Callback signature: function(UserName)
+function cStorage:ForEachUserInArea(a_AreaID, a_WorldName, a_Callback)
+ assert(a_AreaID);
+ assert(a_WorldName);
+ assert(a_Callback);
+ assert(self);
+
+ -- Since in this version all the worlds share a single DB, the a_WorldName parameter is not actually used
+ -- But this may change in the future, when we have a per-world DB
+
+ local function CallCallback(UserData, NumValues, Values)
+ if (NumValues ~= 1) then
+ return 0;
+ end
+ a_Callback(Values[1]);
+ return 0;
+ end
+ local sql = "SELECT UserName FROM AllowedUsers WHERE AreaID = " .. a_AreaID;
+ if (not(self:DBExec(sql, CallCallback))) then
+ LOGWARNING("SQL error while iterating area users for AreaID" .. a_AreaID);
+ return false;
+ end
+ return true;
+end
+
+
+
+
+
+--- Adds the specified usernames to the specified area, if not already present
+-- a_Users is an array table of usernames to add
+function cStorage:AddAreaUsers(a_AreaID, a_WorldName, a_AddedBy, a_Users)
+ assert(a_AreaID);
+ assert(a_WorldName);
+ assert(a_Users);
+ assert(self);
+
+ -- Convert all usernames to lowercase
+ for idx, Name in ipairs(a_Users) do
+ a_Users[idx] = string.lower(Name);
+ end
+
+ -- Remove from a_Users the usernames already present in the area
+ local sql = "SELECT UserName FROM AllowedUsers WHERE AreaID = " .. a_AreaID;
+ local function RemovePresent(UserData, NumValues, Values, Names)
+ if (NumValues ~= 1) then
+ -- Invalid response format
+ return 0;
+ end
+ local DBName = Values[1];
+ -- Remove the name from a_Users, if exists
+ for idx, Name in ipairs(a_Users) do
+ if (Name == DBName) then
+ table.remove(a_Users, idx);
+ return 0;
+ end
+ end
+ return 0;
+ end
+ if (not(self:DBExec(sql, RemovePresent))) then
+ LOGWARNING("SQL error while iterating through users");
+ return false;
+ end
+
+ -- Add the users
+ for idx, Name in ipairs(a_Users) do
+ local sql = "INSERT INTO AllowedUsers (AreaID, UserName) VALUES (" .. a_AreaID .. ", '" .. Name .. "')";
+ if (not(self:DBExec(sql))) then
+ LOGWARNING("SQL error while adding user " .. Name .. " to area " .. a_AreaID);
+ end
+ end
+
+ return true;
+end
+
+
+
+
+
diff --git a/MCServer/Plugins/SquirrelChatLog.nut b/MCServer/Plugins/SquirrelChatLog.nut
index 4ef0fd595..d90cef126 100644
--- a/MCServer/Plugins/SquirrelChatLog.nut
+++ b/MCServer/Plugins/SquirrelChatLog.nut
@@ -1,13 +1,13 @@
-class SquirrelChatLog extends Plugin
-{
- function Initialize()
- {
- this.AddHook(Hook.Chat);
- return true;
- }
-
- function OnChat(Message, Player)
- {
- ::print(Player.GetName() + ": " + Message);
- }
-}
+class SquirrelChatLog extends Plugin
+{
+ function Initialize()
+ {
+ this.AddHook(Hook.Chat);
+ return true;
+ }
+
+ function OnChat(Message, Player)
+ {
+ ::print(Player.GetName() + ": " + Message);
+ }
+}
diff --git a/MCServer/crafting.txt b/MCServer/crafting.txt
index 9e044dbec..41672ddda 100644
--- a/MCServer/crafting.txt
+++ b/MCServer/crafting.txt
@@ -1,392 +1,392 @@
-
-# This file describes the crafting recipes that MCServer knows.
-# The syntax is as follows:
-# <Line> = <Recipe>#<Comment>
-# <Recipe> = <Result> = <Ingredient1> | <Ingredient2> | ... | <IngredientN>
-# <IngredientN> = <ItemID>, <X1> : <Y1>, <X2> : <Y2>, ..., <Xn> : <Yn>
-# <ItemID> = <ItemType> [^<DamageValue>]
-# <Xn>, <Yn> = "1" .. "3", or "*" for any value. "*:*" can be replaced by a single "*".
-# <Result> = <ItemType> [^<DamageValue>] [, <Count>]
-#
-# The Xn, Yn coordinates are a reference to the crafting grid:
-# 1:1 | 2:1 | 3:1
-# 1:2 | 2:2 | 3:2
-# 1:3 | 2:3 | 3:3
-#
-# <ItemType> can be either a number, or an item name (checked against items.ini)
-#
-# ^<DamageValue> is optional, if not present, any damage value is matched for ingredients and zero is produced for the result
-#
-# Ingredients with an asterisk for a coord will not match already matched crafting grid items. This enables simplifying some of the recipes,
-# e. g. hoe: "Iron, 2:1, *:1"
-# -- this means "one iron at 2:1, and another one at either 1:1 or 3:1"
-#
-# To require multiple items of the same type in a slot, specify the slot number several times:
-# "Iron, 1:1, 2:2, 2:2"
-# -- this means "take one iron from slot 1:1 and two irons from slot 2:2"
-# Note that asterisked items cannot require multiple items in a single slot.
-#
-# Note that due to technical problems, it is NOT advised to use asterisked ingredients in crossing directions, such as "*:1, "2:*".
-# The parser may be unable to match such a recipe to the crafting grid!
-#
-# Whitespace is optional. Use it reasonably. Please do NOT use Tabs in the middle of lines!
-
-
-
-
-
-#******************************************************#
-# Basic Crafts
-#
-
-# Need to list each of the four log types, otherwise all logs would get converted into apple planks (^0)
-ApplePlanks, 4 = AppleLog, *
-ConiferPlanks, 4 = ConiferLog, *
-BirchPlanks, 4 = BirchLog, *
-JunglePlanks, 4 = JungleLog, *
-Stick, 4 = Planks, 2:2, 2:3
-Torch, 4 = Stick, 1:2 | Coal, 1:1
-Workbench = Planks, 1:1, 1:2, 2:1, 2:2
-Chest = Planks, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
-TrappedChest = TripWireHook, 1:1 | Chest, 2:1
-EnderChest = EyeOfEnder, 2:2 | Obsidian, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
-Furnace = Cobblestone, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
-
-
-
-
-
-#******************************************************#
-# Blocks
-#
-IronBlock = IronIngot, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
-GoldBlock = GoldIngot, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
-DiamondBlock = Diamond, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
-LapisBlock = LapisLazuli, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
-EmeraldBlock = Emerald, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
-RedstoneBlock = RedstoneDust, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
-QuartzBlock = NetherQuartz, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
-NetherBrick = netherbrickitem, 1:1, 1:2, 2:1, 2:2
-Glowstone = GlowstoneDust, 1:1, 1:2, 2:1, 2:2
-Wool = String, 1:1, 1:2, 2:1, 2:2
-TNT = Gunpowder, 1:1, 3:1, 2:2, 1:3, 3:3 | Sand, 2:1, 1:2, 3:2, 2:3
-PillarQuartzBlock = QuartzSlab, 1:1, 1:2
-ChiseledQuartzBlock, 2 = QuartzBlock, 1:1, 1:2
-
-# Slabs:
-StoneSlab, 6 = Stone, 1:1, 2:1, 3:1
-SandstoneSlab, 6 = Sandstone, 1:1, 2:1, 3:1
-WoodSlab, 6 = Planks, 1:1, 2:1, 3:1
-CobblestoneSlab, 6 = Cobblestone, 1:1, 2:1, 3:1
-BrickSlab, 6 = BrickBlock, 1:1, 2:1, 3:1
-StonebrickSlab, 6 = StoneBrick, 1:1, 2:1, 3:1
-NetherbrickSlab, 6 = NetherBrick, 1:1, 2:1, 3:1
-Quartzslab, 6 = QuartzBlock, 1:1, 2:1, 3:1
-snow, 6 = SnowBlock, 1:1, 2:1, 3:1
-
-# Stairs:
-WoodStairs, 4 = Planks, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
-WoodStairs, 4 = Planks, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
-cobblestoneStairs, 4 = Cobblestone, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
-cobblestoneStairs, 4 = Cobblestone, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
-BrickStairs, 4 = BrickBlock, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
-BrickStairs, 4 = BrickBlock, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
-SandstoneStairs, 4 = Sandstone, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
-SandstoneStairs, 4 = Sandstone, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
-NetherBrickStairs, 4 = NetherBrick, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
-quartzstairs, 4 = QuartzBlock, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
-SnowBlock = SnowBall, 1:1, 1:2, 2:1, 2:2
-ClayBlock = Clay, 1:1, 1:2, 2:1, 2:2
-BrickBlock = Brick, 1:1, 1:2, 2:1, 2:2
-StoneBrick, 4 = Stone, 1:1, 1:2, 2:1, 2:2
-BookShelf = Planks, 1:1, 2:1, 3:1, 1:3, 2:3, 3:3 | Book, 1:2, 2:2, 3:2
-Sandstone, 4 = Sand, 1:1, 1:2, 2:1, 2:2
-SmoothSandstone, 4 = Sandstone, 1:1, 1:2, 2:1, 2:2
-OrnamentSandstone = SandstoneSlab, 1:1, 1:2
-JackOLantern = Pumpkin, 1:1 | Torch, 1:2
-
-
-
-
-
-#******************************************************#
-# Tools
-#
-
-# Axes:
-WoodenAxe = Stick, 2:2, 2:3 | Planks, 2:1, 1:1, 1:2
-WoodenAxe = Stick, 2:2, 2:3 | Planks, 2:1, 3:1, 3:2
-StoneAxe = Stick, 2:2, 2:3 | Cobblestone, 2:1, 1:1, 1:2
-StoneAxe = Stick, 2:2, 2:3 | Cobblestone, 2:1, 3:1, 3:2
-GoldenAxe = Stick, 2:2, 2:3 | GoldIngot, 2:1, 1:1, 1:2
-GoldenAxe = Stick, 2:2, 2:3 | GoldIngot, 2:1, 3:1, 3:2
-IronAxe = Stick, 2:2, 2:3 | IronIngot, 2:1, 1:1, 1:2
-IronAxe = Stick, 2:2, 2:3 | IronIngot, 2:1, 3:1, 3:2
-DiamondAxe = Stick, 2:2, 2:3 | Diamond, 2:1, 1:1, 1:2
-DiamondAxe = Stick, 2:2, 2:3 | Diamond, 2:1, 3:1, 3:2
-
-# Pickaxes:
-WoodenPickaxe = Stick, 2:2, 2:3 | Planks, 1:1, 2:1, 3:1
-StonePickaxe = Stick, 2:2, 2:3 | Cobblestone, 1:1, 2:1, 3:1
-GoldenPickaxe = Stick, 2:2, 2:3 | GoldIngot, 1:1, 2:1, 3:1
-IronPickaxe = Stick, 2:2, 2:3 | IronIngot, 1:1, 2:1, 3:1
-DiamondPickaxe = Stick, 2:2, 2:3 | Diamond, 1:1, 2:1, 3:1
-
-# Shovels:
-WoodenShovel = Stick, 2:2, 2:3 | Planks, 2:1
-StoneShovel = Stick, 2:2, 2:3 | Cobblestone, 2:1
-GoldenShovel = Stick, 2:2, 2:3 | GoldIngot, 2:1
-IronShovel = Stick, 2:2, 2:3 | IronIngot, 2:1
-DiamondShovel = Stick, 2:2, 2:3 | Diamond, 2:1
-
-# Hoes:
-WoodenHoe = Stick, 2:2, 2:3 | Planks, 2:1, *:1
-StoneHoe = Stick, 2:2, 2:3 | Cobblestone, 2:1, *:1
-GoldenHoe = Stick, 2:2, 2:3 | GoldIngot, 2:1, *:1
-IronHoe = Stick, 2:2, 2:3 | IronIngot, 2:1, *:1
-DiamondHoe = Stick, 2:2, 2:3 | Diamond, 2:1, *:1
-
-Lighter = IronIngot, 1:1 | Flint, 2:2
-Lighter = IronIngot, 2:1 | Flint, 1:2
-Bucket = IronIngot, 1:1, 2:2, 3:1
-Compass = IronIngot, 2:1, 1:2, 3:2, 2:3 | RedstoneDust, 2:2
-Map = Paper, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Compass, 2:2
-Watch = GoldIngot, 2:1, 1:2, 3:2, 2:3 | RedstoneDust, 2:2
-FishingRod = Stick, 1:3, 2:2, 3:1 | String, 3:2, 3:3
-FishingRod = Stick, 3:3, 2:2, 1:1 | String, 1:2, 1:3
-Shears = IronIngot, 1:1, 2:2
-Shears = IronIngot, 2:1, 1:2
-FireCharge = BlazePowder, * | Coal, * | Gunpowder, *
-
-
-
-
-
-#******************************************************#
-# Weapons
-#
-WoodenSword = Stick, 2:3 | Planks, 2:1, 2:2
-StoneSword = Stick, 2:3 | Cobblestone, 2:1, 2:2
-GoldenSword = Stick, 2:3 | GoldIngot, 2:1, 2:2
-IronSword = Stick, 2:3 | IronIngot, 2:1, 2:2
-DiamondSword = Stick, 2:3 | Diamond, 2:1, 2:2
-Bow = Stick, 2:1, 1:2, 2:3 | String, 3:1, 3:2, 3:3
-Bow = Stick, 2:1, 3:2, 2:3 | String, 1:1, 1:2, 1:3
-Arrow, 4 = Flint, 1:1 | Stick, 1:2 | Feather, 1:3
-
-
-
-
-
-
-#******************************************************#
-# Armor
-#
-
-# Helmets:
-LeatherHelmet = Leather, 1:1, 2:1, 3:1, 1:2, 3:2
-ChainmailHelmet = Fire, 1:1, 2:1, 3:1, 1:2, 3:2
-GoldenHelmet = GoldIngot, 1:1, 2:1, 3:1, 1:2, 3:2
-IronHelmet = IronIngot, 1:1, 2:1, 3:1, 1:2, 3:2
-DiamondHelmet = Diamond, 1:1, 2:1, 3:1, 1:2, 3:2
-
-# Chestplates:
-LeatherChestplate = Leather, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
-ChainmailChestplate = Fire, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
-GoldenChestplate = GoldIngot, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
-IronChestplate = IronIngot, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
-DiamondChestplate = Diamond, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
-
-# Leggins:
-LeatherPants = Leather, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
-ChainmailPants = Fire, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
-GoldenPants = GoldIngot, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
-IronPants = IronIngot, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
-DiamondPants = Diamond, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
-
-# Boots:
-LeatherBoots = Leather, 1:1, 3:1, 1:2, 3:2
-ChainmailBoots = Fire, 1:1, 3:1, 1:2, 3:2
-GoldenBoots = GoldIngot, 1:1, 3:1, 1:2, 3:2
-IronBoots = IronIngot, 1:1, 3:1, 1:2, 3:2
-DiamondBoots = Diamond, 1:1, 3:1, 1:2, 3:2
-
-
-
-
-
-#******************************************************#
-# Transportation
-#
-CarrotOnAStick = FishingRod, 1:2 | Carrot, 2:3
-Minecart = IronIngot, 1:1, 3:1, 1:2, 2:2, 3:2
-PoweredMinecart = Minecart, * | Furnace, *
-StorageMinecart = Minecart, * | Chest, *
-TNTMinecart = Minecart, * | TNT, *
-hopperminecart = Minecart, * | Hopper, *
-Rails, 16 = IronIngot, 1:1, 3:1, 1:2, 3:2, 1:3, 3:3 | Stick, 2:2
-PoweredRail, 6 = GoldIngot, 1:1, 3:1, 1:2, 3:2, 1:3, 3:3 | Stick, 2:2 | RedstoneDust, 2:3
-DetectorRail, 6 = IronIngot, 1:1, 3:1, 1:2, 3:2, 1:3, 3:3 | StonePlate, 2:2 | RedstoneDust, 2:3
-Boat = Planks, 1:1, 3:1, 1:2, 2:2, 3:2
-ActivatorRail, 6 = IronIngot, 1:1, 1:2, 1:3, 3:1, 3:2, 3:3 | Stick, 2:1, 2:3 | RedstoneTorchon, 2:2
-
-
-
-
-#******************************************************#
-# Mechanisms
-#
-WoodenDoor = Planks, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3
-IronDoor = IronIngot, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3
-TrapDoor, 2 = Planks, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
-WoodPlate = Planks, 1:1, 2:1
-StonePlate = Stone, 1:1, 2:1
-StoneButton = Stone, 1:1
-WoodenButton = Planks, 1:1
-RedstoneTorchOn = Stick, 1:2 | RedstoneDust, 1:1
-Lever = Cobblestone, 1:2 | Stick, 1:1
-NoteBlock = Planks, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | RedstoneDust, 2:2
-Jukebox = Planks, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Diamond, 2:2
-Dispenser = Cobblestone, 1:1, 1:2, 1:3, 2:1, 3:1, 3:2, 3:3 | RedstoneDust, 2:3 | Bow, 2:2
-Dropper = Cobblestone, 1:1, 2:1, 3:1, 1:2, 1:3, 3:2, 3:3 | Hopper, 2:2 | RedstoneDust, 2:3
-Repeater = Stone, 1:2, 2:2, 3:2 | RedstoneTorchOn, 1:1, 3:1 | RedstoneDust, 2:1
-Comparator = RedstoneTorchOn, 2:1, 1:2, 3:2 | NetherQuartz, 2:2 | Stone, 1:3, 2:3, 3:3
-DaylightSensor = Glass, 1:1, 2:1, 3:1 | NetherQuartz, 1:2, 2:2, 3:2 | Woodslab, 1:3, 2:3, 3:3
-Hopper = Ironbars, 1:1, 3:1, 1:2, 3:2, 2:3 | Chest, 2:2
-Piston = Planks, 1:1, 2:1, 3:1 | RedstoneDust, 2:3 | Cobblestone, 1:2, 3:2, 1:3, 3:3 | IronIngot, 2:2
-StickyPiston = Piston, * | SlimeBall, *
-RedstoneLamp = RedstoneDust, 2:1, 1:2, 3:2, 2:3 | Glowstone, 2:2
-tripwirehook, 2 = planks, 2:3 | stick, 2:2 | ironbar, 2:1
-
-
-
-
-
-#******************************************************#
-# Food
-#
-Bowl, 4 = Planks, 1:1, 2:2, 3:1
-MushroomStew = Bowl, * | BrownMushroom, * | RedMushroom, *
-Bread = Wheat, 1:1, 2:1, 3:1
-Sugar = Sugarcane, *
-Cake = MilkBucket, 1:1, 2:1, 3:1 | Sugar, 1:2, 3:2 | Egg, 2:2 | Wheat, 1:3, 2:3, 3:3
-Cookie = Wheat, *, * | CocoaBeans, *
-GoldenApple = RedApple, 2:2 | GoldNugget, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
-EnchantedGoldenApple = RedApple, 2:2 | GoldBlock, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
-Melon = MelonSlice, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
-MelonSeeds = MelonSlice, *
-PumpkinSeeds, 4 = Pumpkin, *
-PumpkinPie = Pumpkin, * | Sugar, * | egg, *
-
-
-
-
-
-#******************************************************#
-# Miscellaneous
-#
-
-# Minerals:
-IronIngot, 9 = IronBlock, *
-GoldIngot, 9 = GoldBlock, *
-Diamond, 9 = DiamondBlock, *
-LapisLazuli, 9 = LapisBlock, *
-Emerald, 9 = EmeraldBlock, *
-RedstoneDust, 9 = RedstoneBlock, *
-
-Painting = Stick, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Wool, 2:2
-ItemFrame = Stick, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Leather, 2:2
-Sign = Planks, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2 | Stick, 2:3
-Ladder, 3 = Stick, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 3:3
-GlassPane, 16 = Glass, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
-IronBars, 16 = IronIngot, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
-Paper, 3 = Sugarcane, 1:1, 2:1, 3:1
-Book = Paper, *, *, * | leather, *
-Bookandquill = Book, * | feather, * | inksac, *
-Fence, 2 = Stick, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
-Cobblestonewall, 6 = cobblestone, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
-mossycobblestonewall, 6 = mossycobblestone, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
-NetherBrickFence, 6 = NetherBrick, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
-FenceGate = Stick, 1:1, 1:2, 3:1, 3:2 | Planks, 2:1, 2:2
-Bed = Planks, 1:2, 2:2, 3:2 | Wool, 1:1, 2:1, 3:1
-GoldIngot = GoldNugget, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
-EyeOfEnder = EnderPearl, * | BlazePowder, *
-Beacon = Glass, 1:1, 1:2, 2:1, 3:1, 3:2 | Obsidian, 1:3, 2:3, 3:3 | NetherStar, 2:2
-Anvil = IronBlock, 1:1, 2:1, 3:1 | IronIngot, 2:2, 1:3, 2:3, 3:3
-FlowerPot = Brick, 1:2, 2:3, 3:2
-
-
-
-
-
-#******************************************************#
-# Dyes
-#
-
-WhiteDye, 3 = Bone, *
-RedDye, 2 = Rose, *
-YellowDye, 2 = Flower, *
-
-# Color mixing, duals:
-OrangeDye, 2 = YellowDye, * | RedDye, *
-CyanDye, 2 = GreenDye, * | BlueDye, *
-PurpleDye, 2 = RedDye, * | BlueDye, *
-GrayDye, 2 = BlackDye, * | WhiteDye, *
-LtBlueDye, 2 = BlueDye, * | WhiteDye, *
-PinkDye, 2 = RedDye, * | WhiteDye, *
-LimeDye, 2 = GreenDye, * | WhiteDye, *
-MagentaDye, 2 = PurpleDye, * | PinkDye, *
-LtGrayDye, 2 = GrayDye, * | WhiteDye, *
-
-# triplets:
-LtGrayDye, 3 = BlackDye, * | WhiteDye, *, *
-MagentaDye, 3 = BlueDye, * | PinkDye, * | RedDye, *
-
-# quads:
-MagentaDye, 4 = BlueDye, * | WhiteDye, * | RedDye, *, *
-
-
-
-
-
-#******************************************************#
-# Colored wool:
-#
-WhiteWool = Wool, * | BoneMeal, *
-OrangeWool = Wool, * | OrangeDye, *
-MagentaWool = Wool, * | MagentaDye, *
-LightBlueWool = Wool, * | LightBlueDye, *
-YellowWool = Wool, * | YellowDye, *
-LimeWool = Wool, * | LimeDye, *
-PinkWool = Wool, * | PinkDye, *
-GrayWool = Wool, * | GrayDye, *
-LightGrayWool = Wool, * | LightGrayDye, *
-CyanWool = Wool, * | CyanDye, *
-VioletWool = Wool, * | VioletDye, *
-BlueWool = Wool, * | BlueDye, *
-BrownWool = Wool, * | BrownDye, *
-GreenWool = Wool, * | GreenDye, *
-RedWool = Wool, * | RedDye, *
-BlackWool = Wool, * | BlackDye, *
-
-
-
-
-
-#******************************************************#
-# Enchantment & Brewing
-#
-GlassBottle, 3 = Glass, 1:1, 2:2, 3:1
-Cauldron = IronIngot, 1:1, 3:1, 1:2, 3:2, 1:3, 2:3, 3:3
-BrewingStand = Cobblestone, 1:2, 2:2, 3:2 | BlazeRod, 2:1
-BlazePowder, 2 = BlazeRod, *
-MagmaCream = SlimeBall, * | BlazePowder, *
-FermentedSpiderEye = SpiderEye, * | Sugar, * | BrownMushroom, *
-GlisteringMelon = MelonSlice, * | GoldNugget, *
-GoldNugget, 9 = GoldIngot, *
-EnchantmentTable = Obsidian, 1:3, 2:3, 3:3, 2:2 | Diamond, 1:2, 3:2 | Book, 2:1
-
-
-
-
-
+
+# This file describes the crafting recipes that MCServer knows.
+# The syntax is as follows:
+# <Line> = <Recipe>#<Comment>
+# <Recipe> = <Result> = <Ingredient1> | <Ingredient2> | ... | <IngredientN>
+# <IngredientN> = <ItemID>, <X1> : <Y1>, <X2> : <Y2>, ..., <Xn> : <Yn>
+# <ItemID> = <ItemType> [^<DamageValue>]
+# <Xn>, <Yn> = "1" .. "3", or "*" for any value. "*:*" can be replaced by a single "*".
+# <Result> = <ItemType> [^<DamageValue>] [, <Count>]
+#
+# The Xn, Yn coordinates are a reference to the crafting grid:
+# 1:1 | 2:1 | 3:1
+# 1:2 | 2:2 | 3:2
+# 1:3 | 2:3 | 3:3
+#
+# <ItemType> can be either a number, or an item name (checked against items.ini)
+#
+# ^<DamageValue> is optional, if not present, any damage value is matched for ingredients and zero is produced for the result
+#
+# Ingredients with an asterisk for a coord will not match already matched crafting grid items. This enables simplifying some of the recipes,
+# e. g. hoe: "Iron, 2:1, *:1"
+# -- this means "one iron at 2:1, and another one at either 1:1 or 3:1"
+#
+# To require multiple items of the same type in a slot, specify the slot number several times:
+# "Iron, 1:1, 2:2, 2:2"
+# -- this means "take one iron from slot 1:1 and two irons from slot 2:2"
+# Note that asterisked items cannot require multiple items in a single slot.
+#
+# Note that due to technical problems, it is NOT advised to use asterisked ingredients in crossing directions, such as "*:1, "2:*".
+# The parser may be unable to match such a recipe to the crafting grid!
+#
+# Whitespace is optional. Use it reasonably. Please do NOT use Tabs in the middle of lines!
+
+
+
+
+
+#******************************************************#
+# Basic Crafts
+#
+
+# Need to list each of the four log types, otherwise all logs would get converted into apple planks (^0)
+ApplePlanks, 4 = AppleLog, *
+ConiferPlanks, 4 = ConiferLog, *
+BirchPlanks, 4 = BirchLog, *
+JunglePlanks, 4 = JungleLog, *
+Stick, 4 = Planks, 2:2, 2:3
+Torch, 4 = Stick, 1:2 | Coal, 1:1
+Workbench = Planks, 1:1, 1:2, 2:1, 2:2
+Chest = Planks, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
+TrappedChest = TripWireHook, 1:1 | Chest, 2:1
+EnderChest = EyeOfEnder, 2:2 | Obsidian, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
+Furnace = Cobblestone, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
+
+
+
+
+
+#******************************************************#
+# Blocks
+#
+IronBlock = IronIngot, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
+GoldBlock = GoldIngot, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
+DiamondBlock = Diamond, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
+LapisBlock = LapisLazuli, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
+EmeraldBlock = Emerald, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
+RedstoneBlock = RedstoneDust, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
+QuartzBlock = NetherQuartz, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
+NetherBrick = netherbrickitem, 1:1, 1:2, 2:1, 2:2
+Glowstone = GlowstoneDust, 1:1, 1:2, 2:1, 2:2
+Wool = String, 1:1, 1:2, 2:1, 2:2
+TNT = Gunpowder, 1:1, 3:1, 2:2, 1:3, 3:3 | Sand, 2:1, 1:2, 3:2, 2:3
+PillarQuartzBlock = QuartzSlab, 1:1, 1:2
+ChiseledQuartzBlock, 2 = QuartzBlock, 1:1, 1:2
+
+# Slabs:
+StoneSlab, 6 = Stone, 1:1, 2:1, 3:1
+SandstoneSlab, 6 = Sandstone, 1:1, 2:1, 3:1
+WoodSlab, 6 = Planks, 1:1, 2:1, 3:1
+CobblestoneSlab, 6 = Cobblestone, 1:1, 2:1, 3:1
+BrickSlab, 6 = BrickBlock, 1:1, 2:1, 3:1
+StonebrickSlab, 6 = StoneBrick, 1:1, 2:1, 3:1
+NetherbrickSlab, 6 = NetherBrick, 1:1, 2:1, 3:1
+Quartzslab, 6 = QuartzBlock, 1:1, 2:1, 3:1
+snow, 6 = SnowBlock, 1:1, 2:1, 3:1
+
+# Stairs:
+WoodStairs, 4 = Planks, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
+WoodStairs, 4 = Planks, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
+cobblestoneStairs, 4 = Cobblestone, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
+cobblestoneStairs, 4 = Cobblestone, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
+BrickStairs, 4 = BrickBlock, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
+BrickStairs, 4 = BrickBlock, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
+SandstoneStairs, 4 = Sandstone, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
+SandstoneStairs, 4 = Sandstone, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
+NetherBrickStairs, 4 = NetherBrick, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
+quartzstairs, 4 = QuartzBlock, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
+SnowBlock = SnowBall, 1:1, 1:2, 2:1, 2:2
+ClayBlock = Clay, 1:1, 1:2, 2:1, 2:2
+BrickBlock = Brick, 1:1, 1:2, 2:1, 2:2
+StoneBrick, 4 = Stone, 1:1, 1:2, 2:1, 2:2
+BookShelf = Planks, 1:1, 2:1, 3:1, 1:3, 2:3, 3:3 | Book, 1:2, 2:2, 3:2
+Sandstone, 4 = Sand, 1:1, 1:2, 2:1, 2:2
+SmoothSandstone, 4 = Sandstone, 1:1, 1:2, 2:1, 2:2
+OrnamentSandstone = SandstoneSlab, 1:1, 1:2
+JackOLantern = Pumpkin, 1:1 | Torch, 1:2
+
+
+
+
+
+#******************************************************#
+# Tools
+#
+
+# Axes:
+WoodenAxe = Stick, 2:2, 2:3 | Planks, 2:1, 1:1, 1:2
+WoodenAxe = Stick, 2:2, 2:3 | Planks, 2:1, 3:1, 3:2
+StoneAxe = Stick, 2:2, 2:3 | Cobblestone, 2:1, 1:1, 1:2
+StoneAxe = Stick, 2:2, 2:3 | Cobblestone, 2:1, 3:1, 3:2
+GoldenAxe = Stick, 2:2, 2:3 | GoldIngot, 2:1, 1:1, 1:2
+GoldenAxe = Stick, 2:2, 2:3 | GoldIngot, 2:1, 3:1, 3:2
+IronAxe = Stick, 2:2, 2:3 | IronIngot, 2:1, 1:1, 1:2
+IronAxe = Stick, 2:2, 2:3 | IronIngot, 2:1, 3:1, 3:2
+DiamondAxe = Stick, 2:2, 2:3 | Diamond, 2:1, 1:1, 1:2
+DiamondAxe = Stick, 2:2, 2:3 | Diamond, 2:1, 3:1, 3:2
+
+# Pickaxes:
+WoodenPickaxe = Stick, 2:2, 2:3 | Planks, 1:1, 2:1, 3:1
+StonePickaxe = Stick, 2:2, 2:3 | Cobblestone, 1:1, 2:1, 3:1
+GoldenPickaxe = Stick, 2:2, 2:3 | GoldIngot, 1:1, 2:1, 3:1
+IronPickaxe = Stick, 2:2, 2:3 | IronIngot, 1:1, 2:1, 3:1
+DiamondPickaxe = Stick, 2:2, 2:3 | Diamond, 1:1, 2:1, 3:1
+
+# Shovels:
+WoodenShovel = Stick, 2:2, 2:3 | Planks, 2:1
+StoneShovel = Stick, 2:2, 2:3 | Cobblestone, 2:1
+GoldenShovel = Stick, 2:2, 2:3 | GoldIngot, 2:1
+IronShovel = Stick, 2:2, 2:3 | IronIngot, 2:1
+DiamondShovel = Stick, 2:2, 2:3 | Diamond, 2:1
+
+# Hoes:
+WoodenHoe = Stick, 2:2, 2:3 | Planks, 2:1, *:1
+StoneHoe = Stick, 2:2, 2:3 | Cobblestone, 2:1, *:1
+GoldenHoe = Stick, 2:2, 2:3 | GoldIngot, 2:1, *:1
+IronHoe = Stick, 2:2, 2:3 | IronIngot, 2:1, *:1
+DiamondHoe = Stick, 2:2, 2:3 | Diamond, 2:1, *:1
+
+Lighter = IronIngot, 1:1 | Flint, 2:2
+Lighter = IronIngot, 2:1 | Flint, 1:2
+Bucket = IronIngot, 1:1, 2:2, 3:1
+Compass = IronIngot, 2:1, 1:2, 3:2, 2:3 | RedstoneDust, 2:2
+Map = Paper, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Compass, 2:2
+Watch = GoldIngot, 2:1, 1:2, 3:2, 2:3 | RedstoneDust, 2:2
+FishingRod = Stick, 1:3, 2:2, 3:1 | String, 3:2, 3:3
+FishingRod = Stick, 3:3, 2:2, 1:1 | String, 1:2, 1:3
+Shears = IronIngot, 1:1, 2:2
+Shears = IronIngot, 2:1, 1:2
+FireCharge = BlazePowder, * | Coal, * | Gunpowder, *
+
+
+
+
+
+#******************************************************#
+# Weapons
+#
+WoodenSword = Stick, 2:3 | Planks, 2:1, 2:2
+StoneSword = Stick, 2:3 | Cobblestone, 2:1, 2:2
+GoldenSword = Stick, 2:3 | GoldIngot, 2:1, 2:2
+IronSword = Stick, 2:3 | IronIngot, 2:1, 2:2
+DiamondSword = Stick, 2:3 | Diamond, 2:1, 2:2
+Bow = Stick, 2:1, 1:2, 2:3 | String, 3:1, 3:2, 3:3
+Bow = Stick, 2:1, 3:2, 2:3 | String, 1:1, 1:2, 1:3
+Arrow, 4 = Flint, 1:1 | Stick, 1:2 | Feather, 1:3
+
+
+
+
+
+
+#******************************************************#
+# Armor
+#
+
+# Helmets:
+LeatherHelmet = Leather, 1:1, 2:1, 3:1, 1:2, 3:2
+ChainmailHelmet = Fire, 1:1, 2:1, 3:1, 1:2, 3:2
+GoldenHelmet = GoldIngot, 1:1, 2:1, 3:1, 1:2, 3:2
+IronHelmet = IronIngot, 1:1, 2:1, 3:1, 1:2, 3:2
+DiamondHelmet = Diamond, 1:1, 2:1, 3:1, 1:2, 3:2
+
+# Chestplates:
+LeatherChestplate = Leather, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
+ChainmailChestplate = Fire, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
+GoldenChestplate = GoldIngot, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
+IronChestplate = IronIngot, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
+DiamondChestplate = Diamond, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 2:3, 3:3
+
+# Leggins:
+LeatherPants = Leather, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
+ChainmailPants = Fire, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
+GoldenPants = GoldIngot, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
+IronPants = IronIngot, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
+DiamondPants = Diamond, 1:1, 2:1, 3:1, 1:2, 3:2, 1:3, 3:3
+
+# Boots:
+LeatherBoots = Leather, 1:1, 3:1, 1:2, 3:2
+ChainmailBoots = Fire, 1:1, 3:1, 1:2, 3:2
+GoldenBoots = GoldIngot, 1:1, 3:1, 1:2, 3:2
+IronBoots = IronIngot, 1:1, 3:1, 1:2, 3:2
+DiamondBoots = Diamond, 1:1, 3:1, 1:2, 3:2
+
+
+
+
+
+#******************************************************#
+# Transportation
+#
+CarrotOnAStick = FishingRod, 1:2 | Carrot, 2:3
+Minecart = IronIngot, 1:1, 3:1, 1:2, 2:2, 3:2
+PoweredMinecart = Minecart, * | Furnace, *
+StorageMinecart = Minecart, * | Chest, *
+TNTMinecart = Minecart, * | TNT, *
+hopperminecart = Minecart, * | Hopper, *
+Rails, 16 = IronIngot, 1:1, 3:1, 1:2, 3:2, 1:3, 3:3 | Stick, 2:2
+PoweredRail, 6 = GoldIngot, 1:1, 3:1, 1:2, 3:2, 1:3, 3:3 | Stick, 2:2 | RedstoneDust, 2:3
+DetectorRail, 6 = IronIngot, 1:1, 3:1, 1:2, 3:2, 1:3, 3:3 | StonePlate, 2:2 | RedstoneDust, 2:3
+Boat = Planks, 1:1, 3:1, 1:2, 2:2, 3:2
+ActivatorRail, 6 = IronIngot, 1:1, 1:2, 1:3, 3:1, 3:2, 3:3 | Stick, 2:1, 2:3 | RedstoneTorchon, 2:2
+
+
+
+
+#******************************************************#
+# Mechanisms
+#
+WoodenDoor = Planks, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3
+IronDoor = IronIngot, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3
+TrapDoor, 2 = Planks, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
+WoodPlate = Planks, 1:1, 2:1
+StonePlate = Stone, 1:1, 2:1
+StoneButton = Stone, 1:1
+WoodenButton = Planks, 1:1
+RedstoneTorchOn = Stick, 1:2 | RedstoneDust, 1:1
+Lever = Cobblestone, 1:2 | Stick, 1:1
+NoteBlock = Planks, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | RedstoneDust, 2:2
+Jukebox = Planks, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Diamond, 2:2
+Dispenser = Cobblestone, 1:1, 1:2, 1:3, 2:1, 3:1, 3:2, 3:3 | RedstoneDust, 2:3 | Bow, 2:2
+Dropper = Cobblestone, 1:1, 2:1, 3:1, 1:2, 1:3, 3:2, 3:3 | Hopper, 2:2 | RedstoneDust, 2:3
+Repeater = Stone, 1:2, 2:2, 3:2 | RedstoneTorchOn, 1:1, 3:1 | RedstoneDust, 2:1
+Comparator = RedstoneTorchOn, 2:1, 1:2, 3:2 | NetherQuartz, 2:2 | Stone, 1:3, 2:3, 3:3
+DaylightSensor = Glass, 1:1, 2:1, 3:1 | NetherQuartz, 1:2, 2:2, 3:2 | Woodslab, 1:3, 2:3, 3:3
+Hopper = Ironbars, 1:1, 3:1, 1:2, 3:2, 2:3 | Chest, 2:2
+Piston = Planks, 1:1, 2:1, 3:1 | RedstoneDust, 2:3 | Cobblestone, 1:2, 3:2, 1:3, 3:3 | IronIngot, 2:2
+StickyPiston = Piston, * | SlimeBall, *
+RedstoneLamp = RedstoneDust, 2:1, 1:2, 3:2, 2:3 | Glowstone, 2:2
+tripwirehook, 2 = planks, 2:3 | stick, 2:2 | ironbar, 2:1
+
+
+
+
+
+#******************************************************#
+# Food
+#
+Bowl, 4 = Planks, 1:1, 2:2, 3:1
+MushroomStew = Bowl, * | BrownMushroom, * | RedMushroom, *
+Bread = Wheat, 1:1, 2:1, 3:1
+Sugar = Sugarcane, *
+Cake = MilkBucket, 1:1, 2:1, 3:1 | Sugar, 1:2, 3:2 | Egg, 2:2 | Wheat, 1:3, 2:3, 3:3
+Cookie = Wheat, *, * | CocoaBeans, *
+GoldenApple = RedApple, 2:2 | GoldNugget, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
+EnchantedGoldenApple = RedApple, 2:2 | GoldBlock, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3
+Melon = MelonSlice, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
+MelonSeeds = MelonSlice, *
+PumpkinSeeds, 4 = Pumpkin, *
+PumpkinPie = Pumpkin, * | Sugar, * | egg, *
+
+
+
+
+
+#******************************************************#
+# Miscellaneous
+#
+
+# Minerals:
+IronIngot, 9 = IronBlock, *
+GoldIngot, 9 = GoldBlock, *
+Diamond, 9 = DiamondBlock, *
+LapisLazuli, 9 = LapisBlock, *
+Emerald, 9 = EmeraldBlock, *
+RedstoneDust, 9 = RedstoneBlock, *
+
+Painting = Stick, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Wool, 2:2
+ItemFrame = Stick, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Leather, 2:2
+Sign = Planks, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2 | Stick, 2:3
+Ladder, 3 = Stick, 1:1, 3:1, 1:2, 2:2, 3:2, 1:3, 3:3
+GlassPane, 16 = Glass, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
+IronBars, 16 = IronIngot, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
+Paper, 3 = Sugarcane, 1:1, 2:1, 3:1
+Book = Paper, *, *, * | leather, *
+Bookandquill = Book, * | feather, * | inksac, *
+Fence, 2 = Stick, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
+Cobblestonewall, 6 = cobblestone, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+mossycobblestonewall, 6 = mossycobblestone, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+NetherBrickFence, 6 = NetherBrick, 1:1, 2:1, 3:1, 1:2, 2:2, 3:2
+FenceGate = Stick, 1:1, 1:2, 3:1, 3:2 | Planks, 2:1, 2:2
+Bed = Planks, 1:2, 2:2, 3:2 | Wool, 1:1, 2:1, 3:1
+GoldIngot = GoldNugget, 1:1, 1:2, 1:3, 2:1, 2:2, 2:3, 3:1, 3:2, 3:3
+EyeOfEnder = EnderPearl, * | BlazePowder, *
+Beacon = Glass, 1:1, 1:2, 2:1, 3:1, 3:2 | Obsidian, 1:3, 2:3, 3:3 | NetherStar, 2:2
+Anvil = IronBlock, 1:1, 2:1, 3:1 | IronIngot, 2:2, 1:3, 2:3, 3:3
+FlowerPot = Brick, 1:2, 2:3, 3:2
+
+
+
+
+
+#******************************************************#
+# Dyes
+#
+
+WhiteDye, 3 = Bone, *
+RedDye, 2 = Rose, *
+YellowDye, 2 = Flower, *
+
+# Color mixing, duals:
+OrangeDye, 2 = YellowDye, * | RedDye, *
+CyanDye, 2 = GreenDye, * | BlueDye, *
+PurpleDye, 2 = RedDye, * | BlueDye, *
+GrayDye, 2 = BlackDye, * | WhiteDye, *
+LtBlueDye, 2 = BlueDye, * | WhiteDye, *
+PinkDye, 2 = RedDye, * | WhiteDye, *
+LimeDye, 2 = GreenDye, * | WhiteDye, *
+MagentaDye, 2 = PurpleDye, * | PinkDye, *
+LtGrayDye, 2 = GrayDye, * | WhiteDye, *
+
+# triplets:
+LtGrayDye, 3 = BlackDye, * | WhiteDye, *, *
+MagentaDye, 3 = BlueDye, * | PinkDye, * | RedDye, *
+
+# quads:
+MagentaDye, 4 = BlueDye, * | WhiteDye, * | RedDye, *, *
+
+
+
+
+
+#******************************************************#
+# Colored wool:
+#
+WhiteWool = Wool, * | BoneMeal, *
+OrangeWool = Wool, * | OrangeDye, *
+MagentaWool = Wool, * | MagentaDye, *
+LightBlueWool = Wool, * | LightBlueDye, *
+YellowWool = Wool, * | YellowDye, *
+LimeWool = Wool, * | LimeDye, *
+PinkWool = Wool, * | PinkDye, *
+GrayWool = Wool, * | GrayDye, *
+LightGrayWool = Wool, * | LightGrayDye, *
+CyanWool = Wool, * | CyanDye, *
+VioletWool = Wool, * | VioletDye, *
+BlueWool = Wool, * | BlueDye, *
+BrownWool = Wool, * | BrownDye, *
+GreenWool = Wool, * | GreenDye, *
+RedWool = Wool, * | RedDye, *
+BlackWool = Wool, * | BlackDye, *
+
+
+
+
+
+#******************************************************#
+# Enchantment & Brewing
+#
+GlassBottle, 3 = Glass, 1:1, 2:2, 3:1
+Cauldron = IronIngot, 1:1, 3:1, 1:2, 3:2, 1:3, 2:3, 3:3
+BrewingStand = Cobblestone, 1:2, 2:2, 3:2 | BlazeRod, 2:1
+BlazePowder, 2 = BlazeRod, *
+MagmaCream = SlimeBall, * | BlazePowder, *
+FermentedSpiderEye = SpiderEye, * | Sugar, * | BrownMushroom, *
+GlisteringMelon = MelonSlice, * | GoldNugget, *
+GoldNugget, 9 = GoldIngot, *
+EnchantmentTable = Obsidian, 1:3, 2:3, 3:3, 2:2 | Diamond, 1:2, 3:2 | Book, 2:1
+
+
+
+
+
diff --git a/MCServer/furnace.txt b/MCServer/furnace.txt
index b25c79ab7..e5d4ca70f 100644
--- a/MCServer/furnace.txt
+++ b/MCServer/furnace.txt
@@ -1,75 +1,75 @@
-#*****************#
-# Furnace Recipes #
-#*****************#
-#
-#
-#******************************************************#
-# Basic Notation Help
-#
-# **** Item Definition ****
-# An Item is defined by an Item Type, an amount (and damage)
-# The damage is optional, and if not specified it's assumed to be 0
-#
-# -Cactus Green:
-# 351 : 1 ( : 2 )
-# ItemType : Amount ( : Damage )
-#
-#
-# **** Recipe and result ****
-#
-# 4:1@200=1:1 -> Produces 1 smooth stone from 1 cobblestone in 200 ticks (10 seconds)
-#
-# 4 : 1 @ 200 = 1 : 1
-# ItemType : Amount @ ticks = ItemID : Amount
-#
-#
-# **** Fuel ****
-#
-# !17:1 = 300 -> 1 Wood burns for 300 ticks (15 s)
-#
-# ! 17 : 1 = 300
-# Fuel ItemType : Amount = ticks
-#
-#******************************************************#
-
-
-
-
-
-#--------------------------
-# Smelting recipes
-
-4:1 @ 200 = 1:1 # 1 Cobblestone -> 1 Rock
-15:1 @ 200 = 265:1 # 1 Iron Ore -> 1 Iron Ingot
-14:1 @ 200 = 266:1 # 1 Gold Ore -> 1 Gold Ingot
-153:1 @ 200 = 406:1 # 1 Quartz Ore -> 1 Quartz
-12:1 @ 200 = 20:1 # 1 Sand -> 1 Glass
-319:1 @ 200 = 320:1 # 1 Raw Pork -> 1 Cooked Pork
-363:1 @ 200 = 364:1 # 1 Raw Beef -> 1 Cooked Beef (steak)
-365:1 @ 200 = 366:1 # 1 Raw Chicken -> 1 Cooked Chicken
-337:1 @ 200 = 336:1 # 1 Clay -> 1 Clay Brick
-87:1 @ 200 = 405:1 # 1 NetherRack -> 1 NetherBrick
-349:1 @ 200 = 350:1 # 1 Raw Fish -> 1 Cooked Fish
-17:1 @ 200 = 263:1:1 # 1 Log -> 1 Charcoal
-81:1 @ 200 = 351:1:2 # 1 Cactus -> 1 Green Dye
-
-
-
-
-
-#--------------------------
-# Fuels
-
-! 263:1 = 1600 # 1 Charcoal -> 80 sec
-! 42:126:1 = 150 # 1 Halfslab -> 7.5 seconds
-! 5:1 = 300 # 1 Planks -> 15 sec
-! 280:1 = 100 # 1 Stick -> 5 sec
-! 85:1 = 300 # 1 Fence -> 15 sec
-! 53:1 = 300 # 1 Wooden Stairs -> 15 sec
-! 58:1 = 300 # 1 Crafting Table -> 15 sec
-! 47:1 = 300 # 1 Bookshelf -> 15 sec
-! 54:1 = 300 # 1 Chest -> 15 sec
-! 84:1 = 300 # 1 Jukebox -> 15 sec
-! 327:1 = 200000 # 1 Lava Bucket -> 1000 sec
-! 17:1 = 300 # 1 Wood -> 15 sec
-! 6:1 = 100 # 1 Sapling -> 5 sec
+#*****************#
+# Furnace Recipes #
+#*****************#
+#
+#
+#******************************************************#
+# Basic Notation Help
+#
+# **** Item Definition ****
+# An Item is defined by an Item Type, an amount (and damage)
+# The damage is optional, and if not specified it's assumed to be 0
+#
+# -Cactus Green:
+# 351 : 1 ( : 2 )
+# ItemType : Amount ( : Damage )
+#
+#
+# **** Recipe and result ****
+#
+# 4:1@200=1:1 -> Produces 1 smooth stone from 1 cobblestone in 200 ticks (10 seconds)
+#
+# 4 : 1 @ 200 = 1 : 1
+# ItemType : Amount @ ticks = ItemID : Amount
+#
+#
+# **** Fuel ****
+#
+# !17:1 = 300 -> 1 Wood burns for 300 ticks (15 s)
+#
+# ! 17 : 1 = 300
+# Fuel ItemType : Amount = ticks
+#
+#******************************************************#
+
+
+
+
+
+#--------------------------
+# Smelting recipes
+
+4:1 @ 200 = 1:1 # 1 Cobblestone -> 1 Rock
+15:1 @ 200 = 265:1 # 1 Iron Ore -> 1 Iron Ingot
+14:1 @ 200 = 266:1 # 1 Gold Ore -> 1 Gold Ingot
+153:1 @ 200 = 406:1 # 1 Quartz Ore -> 1 Quartz
+12:1 @ 200 = 20:1 # 1 Sand -> 1 Glass
+319:1 @ 200 = 320:1 # 1 Raw Pork -> 1 Cooked Pork
+363:1 @ 200 = 364:1 # 1 Raw Beef -> 1 Cooked Beef (steak)
+365:1 @ 200 = 366:1 # 1 Raw Chicken -> 1 Cooked Chicken
+337:1 @ 200 = 336:1 # 1 Clay -> 1 Clay Brick
+87:1 @ 200 = 405:1 # 1 NetherRack -> 1 NetherBrick
+349:1 @ 200 = 350:1 # 1 Raw Fish -> 1 Cooked Fish
+17:1 @ 200 = 263:1:1 # 1 Log -> 1 Charcoal
+81:1 @ 200 = 351:1:2 # 1 Cactus -> 1 Green Dye
+
+
+
+
+
+#--------------------------
+# Fuels
+
+! 263:1 = 1600 # 1 Charcoal -> 80 sec
+! 42:126:1 = 150 # 1 Halfslab -> 7.5 seconds
+! 5:1 = 300 # 1 Planks -> 15 sec
+! 280:1 = 100 # 1 Stick -> 5 sec
+! 85:1 = 300 # 1 Fence -> 15 sec
+! 53:1 = 300 # 1 Wooden Stairs -> 15 sec
+! 58:1 = 300 # 1 Crafting Table -> 15 sec
+! 47:1 = 300 # 1 Bookshelf -> 15 sec
+! 54:1 = 300 # 1 Chest -> 15 sec
+! 84:1 = 300 # 1 Jukebox -> 15 sec
+! 327:1 = 200000 # 1 Lava Bucket -> 1000 sec
+! 17:1 = 300 # 1 Wood -> 15 sec
+! 6:1 = 100 # 1 Sapling -> 5 sec
diff --git a/MCServer/groups.ini b/MCServer/groups.ini
index 7f061204b..87b28b70d 100644
--- a/MCServer/groups.ini
+++ b/MCServer/groups.ini
@@ -1,17 +1,17 @@
-[Admins]
-Permissions=*
-Color=c
-
-[Mods]
-Color=5
-Inherits=Vips
-Permissions=core.time,core.item
-
-[Vips]
-Permissions=core.teleport
-Color=2
-Inherits=Default
-
-[Default]
-Permissions=core.build,core.help,core.playerlist,core.pluginlist,core.spawn
+[Admins]
+Permissions=*
+Color=c
+
+[Mods]
+Color=5
+Inherits=Vips
+Permissions=core.time,core.item
+
+[Vips]
+Permissions=core.teleport
+Color=2
+Inherits=Default
+
+[Default]
+Permissions=core.build,core.help,core.playerlist,core.pluginlist,core.spawn
Color=7 \ No newline at end of file
diff --git a/MCServer/hg.supp b/MCServer/hg.supp
index 048f1382f..27eb8c27a 100644
--- a/MCServer/hg.supp
+++ b/MCServer/hg.supp
@@ -1,22 +1,22 @@
-# This is a valgrind suppressions file for running helgrind on MCServer
-# Use by adding "--suppressions=hg.supp" to the helgrind commandline
-
-
-
-
-
-
-# This covers GCC bug 40518, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40518
-# "Erasing an empty string causes a global value write / race condition warning in helgrind"
-# Original suppression authored by Jonathan Wakely: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40518#c20
-# Modified by Mattes to match the mangled function name used on Ubuntu
-
-{
- libstdcxx_std_string_race_pr40518
- Helgrind:Race
- fun:_ZNSs9_M_mutateEjjj
-}
-
-
-
-
+# This is a valgrind suppressions file for running helgrind on MCServer
+# Use by adding "--suppressions=hg.supp" to the helgrind commandline
+
+
+
+
+
+
+# This covers GCC bug 40518, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40518
+# "Erasing an empty string causes a global value write / race condition warning in helgrind"
+# Original suppression authored by Jonathan Wakely: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40518#c20
+# Modified by Mattes to match the mangled function name used on Ubuntu
+
+{
+ libstdcxx_std_string_race_pr40518
+ Helgrind:Race
+ fun:_ZNSs9_M_mutateEjjj
+}
+
+
+
+
diff --git a/MCServer/items.ini b/MCServer/items.ini
index ec518cb0a..c9bd6df53 100644
--- a/MCServer/items.ini
+++ b/MCServer/items.ini
@@ -1,543 +1,543 @@
-[Items]
-rock=1
-stone=1
-grass=2
-dirt=3
-cobblestone=4
-cobble=4
-planks=5
-appleplanks=5:0
-oakplanks=5:0
-coniferplanks=5:1
-pineplanks=5:1
-spruceplanks=5:1
-darkplanks=5:1
-birchplanks=5:2
-lightplanks=5:2
-jungleplanks=5:3
-redplanks=5:3
-
-; Obsolete: do not use "wood", as its meaning is not clear - wiki uses log as wood, we use planks as wood.
-wood=5
-
-sapling=6
-applesapling=6:0
-oaksapling=6:0
-conifersapling=6:1
-pinesapling=6:1
-sprucesapling=6:1
-birchsapling=6:2
-junglesapling=6:3
-adminium=7
-bedrock=7
-water=8
-stillwater=9
-swater=9
-stationarywater=9
-lava=10
-stilllava=11
-slava=11
-stationarylava=11
-sand=12
-gravel=13
-goldore=14
-ironore=15
-coalore=16
-tree=17
-log=17
-applelog=17:0
-oaklog=17:0
-coniferlog=17:1
-pinelog=17:1
-sprucelog=17:1
-darklog=17:1
-birchlog=17:2
-whitelog=17:2
-junglelog=17:3
-leaves=18
-appleleaves=18:0
-oakleaves=18:0
-coniferleaves=18:1
-pineleaves=18:1
-spruceleaves=18:1
-birchleaves=18:2
-jungleleaves=18:3
-sponge=19
-glass=20
-lapisore=21
-lapisblock=22
-dispenser=23
-sandstone=24
-normalsandstone=24:0
-ornamentsandstone=24:1
-decorativesandstone=24:1
-smoothsandstone=24:2
-noteblock=25
-bedblock=26
-poweredrail=27
-detectorrail=28
-stickypiston=29
-cobweb=30
-tallgrass=31
-tallgrassone=31:1
-tallgrasstwo=31:2
-deadbush=32
-piston=33
-pistonextension=34
-pistonhead=34
-cloth=35
-wool=35
-whitewool=35:0
-orangewool=35:1
-magentawool=35:2
-lightbluewool=35:3
-yellowwool=35:4
-limewool=35:5
-lightgreenwool=35:5
-ltgreenwool=35:5
-pinkwool=35:6
-graywool=35:7
-greywool=35:7
-darkgraywool=35:7
-darkgreywool=35:7
-dkgraywool=35:7
-dkgreywool=35:7
-lightgraywool=35:8
-lightgreywool=35:8
-ltgraywool=35:8
-ltgreywool=35:8
-cyanwool=35:9
-purplewool=35:10
-violetwool=35:10
-bluewool=35:11
-darkbluewool=35:11
-brownwool=35:12
-greenwool=35:13
-darkgreenwool=35:13
-dkgreenwool=35:13
-redwool=35:14
-blackwool=35:15
-flower=37
-rose=38
-brownmushroom=39
-redmushroom=40
-gold=41
-goldblock=41
-iron=42
-ironblock=42
-doubleslab=43
-stonedoubleslab=43:0
-sandstonedoubleslab=43:1
-wooddoubleslab=43:2
-cobblestonedoubleslab=43:3
-brickdoubleslab=43:4
-stonebrickdoubleslab=43:5
-netherbrickdoubleslab=43:6
-quartzdoubleslab=43:7
-slab=44
-step=44
-stoneslab=44:0
-sandstoneslab=44:1
-woodslab=44:2
-cobblestoneslab=44:3
-brickslab=44:4
-stonebrickslab=44:5
-netherbrickslab=44:6
-quartzslab=44:7
-brickblock=45
-brickwall=45
-tnt=46
-bookshelf=47
-bookcase=47
-mossycobblestone=48
-mossy=48
-obsidian=49
-torch=50
-fire=51
-mobspawner=52
-woodstairs=53
-chest=54
-redstonedust=55
-redstonewire=55
-diamondore=56
-diamondblock=57
-workbench=58
-crop=59
-crops=59
-soil=60
-furnace=61
-litfurnace=62
-signblock=63
-wooddoorblock=64
-ladder=65
-rails=66
-rail=66
-track=66
-tracks=66
-cobblestonestairs=67
-stairs=67
-signblocktop=68
-wallsign=68
-lever=69
-rockplate=70
-stoneplate=70
-irondoorblock=71
-woodplate=72
-redstoneore=73
-redstoneorealt=74
-redstonetorchoff=75
-redstonetorchon=76
-stonebutton=77
-snow=78
-ice=79
-snowblock=80
-cactus=81
-clayblock=82
-reedblock=83
-jukebox=84
-fence=85
-pumpkin=86
-netherstone=87
-netherrack=87
-hellrock=87
-slowsand=88
-soulsand=88
-lightstone=89
-glowstone=89
-portal=90
-jackolantern=91
-jacko=91
-cakeblock=92
-lockedchest=95
-trapdoor=96
-silverfishblock=97
-stonebricks=98
-stonebrick=98
-mossystonebrick=98:1
-crackedstonebrick=98:2
-chiseledstonebrick=98:3
-hugebrownmushroom=99
-hugeredmushroom=100
-ironbars=101
-glasspane=102
-melon=103
-pumpkinstem=104
-melonstem=105
-vines=106
-fencegate=107
-brickstairs=108
-stonebrickstairs=109
-mycelium=110
-lilypad=111
-netherbrick=112
-netherbrickfence=113
-netherbrickstairs=114
-netherwartblock=115
-enchantmenttable=116
-brewingstandblock=117
-cauldronblock=118
-endportal=119
-endportalframe=120
-endstone=121
-dragonegg=122
-redstonelamp=123
-redstonelampoff=123
-redstonelampon=124
-woodendoubleslab=125
-woodenslab=126
-sandstonestairs=128
-emeraldore=129
-enderchest=130
-tripwirehook=131
-tripwire=132
-emeraldblock=133
-commandblock=137
-beacon=138
-cobblestonewall=139
-mossycobblestonewall=139:1
-flowerpotblock=140
-carrotcrop=141
-potatocrop=142
-woodenbutton=143
-skeletonhead=144
-witherhead=144:1
-zombiehead=144:2
-humanhead=144:3
-stevehead=144:3
-creeperhead=144:4
-anvil=145
-trappedchest=146
-lightweightedpressureplate=147
-heavyweightedpressureplate=148
-inactivecomparator=149
-activecomparator=150
-daylightsensor=151
-redstoneblock=152
-netherquartzore=153
-hopper=154
-quartzblock=155
-chiseledquartzblock=155:1
-pillarquartzblock=155:2
-quartzstairs=156
-activatorrail=157
-dropper=158
-
-ironshovel=256
-ironspade=256
-ironpickaxe=257
-ironpick=257
-ironaxe=258
-flintandsteel=259
-lighter=259
-apple=260
-redapple=260
-bow=261
-arrow=262
-coal=263
-charcoal=263:1
-diamond=264
-ironingot=265
-ironbar=265
-goldingot=266
-goldeningot=266
-goldbar=266
-goldenbar=266
-ironsword=267
-woodensword=268
-woodsword=268
-woodenshovel=269
-woodshovel=269
-woodenspade=269
-woodspade=269
-woodenpickaxe=270
-woodpickaxe=270
-woodenpick=270
-woodpick=270
-woodenaxe=271
-woodaxe=271
-stonesword=272
-stoneshovel=273
-stonespade=273
-stonepickaxe=274
-stonepick=274
-stoneaxe=275
-diamondsword=276
-diamondshovel=277
-diamondspade=277
-diamondpickaxe=278
-diamondpick=278
-diamondaxe=279
-stick=280
-bowl=281
-mushroomstew=282
-bowlwithsoup=282
-soupbowl=282
-soup=282
-goldensword=283
-goldsword=283
-goldenshovel=284
-goldshovel=284
-goldenspade=284
-goldspade=284
-goldenpickaxe=285
-goldpickaxe=285
-goldenpick=285
-goldpick=285
-goldenaxe=286
-goldaxe=286
-string=287
-feather=288
-gunpowder=289
-woodhoe=290
-woodenhoe=290
-stonehoe=291
-ironhoe=292
-diamondhoe=293
-goldhoe=294
-goldenhoe=294
-seeds=295
-wheat=296
-bread=297
-leatherhelmet=298
-leatherchestplate=299
-leatherpants=300
-leatherboots=301
-chainmailhelmet=302
-chainmailchestplate=303
-chainmailpants=304
-chainmailboots=305
-ironhelmet=306
-ironchestplate=307
-ironpants=308
-ironboots=309
-diamondhelmet=310
-diamondchestplate=311
-diamondpants=312
-diamondboots=313
-goldenhelmet=314
-goldhelmet=314
-goldenchestplate=315
-goldchestplate=315
-goldenpants=316
-goldpants=316
-goldenboots=317
-goldboots=317
-flint=318
-meat=319
-pork=319
-cookedmeat=320
-cookedpork=320
-painting=321
-paintings=321
-goldenapple=322
-goldapple=322
-enchantedgoldenapple=322:1
-enchantedgoldapple=322:1
-sign=323
-wooddoor=324
-woodendoor=324
-bucket=325
-waterbucket=326
-lavabucket=327
-minecart=328
-saddle=329
-irondoor=330
-redstonedust=331
-snowball=332
-boat=333
-leather=334
-milkbucket=335
-brick=336
-clay=337
-reed=338
-sugarcane=338
-paper=339
-book=340
-slimeorb=341
-slimeball=341
-storageminecart=342
-poweredminecart=343
-egg=344
-compass=345
-fishingrod=346
-watch=347
-lightstonedust=348
-lightdust=348
-glowstonedust=348
-glowdust=348
-rawfish=349
-fish=349
-cookedfish=350
-dye=351
-inksac=351:0
-blackdye=351:0
-reddye=351:1
-rosered=351:1
-greendye=351:2
-cactusgreen=351:2
-cocoabeans=351:3
-browndye=351:3
-lapislazuli=351:4
-bluedye=351:4
-darkbluedye=351:4
-dkbluedye=351:4
-purpledye=351:5
-violetdye=351:5
-cyandye=351:6
-lightgreydye=351:7
-lightgraydye=351:7
-ltgreydye=351:7
-ltgraydye=351:7
-greydye=351:8
-graydye=351:8
-darkgreydye=351:8
-darkgraydye=351:8
-dkgreydye=351:8
-dkgraydye=351:8
-pinkdye=351:9
-limedye=351:10
-lightgreendye=351:10
-ltgreendye=351:10
-dandellionyellow=351:11
-yellowdye=351:11
-lightbluedye=351:12
-ltbluedye=351:12
-magentadye=351:13
-orangedye=351:14
-bonemeal=351:15
-whitedye=351:15
-bone=352
-sugar=353
-cake=354
-bed=355
-repeater=356
-diode=356
-cookie=357
-map=358
-shears=359
-melonslice=360
-pumpkinseeds=361
-melonseeds=362
-rawbeef=363
-steak=364
-rawchicken=365
-cookedchicken=366
-rottenflesh=367
-enderpearl=368
-blazerod=369
-ghasttear=370
-goldnugget=371
-netherwart=372
-potion=373
-glassbottle=374
-spidereye=375
-fermentedspidereye=376
-blazepowder=377
-magmacream=378
-brewingstand=379
-cauldron=380
-eyeofender=381
-glisteringmelon=382
-spawnegg=383
-bottleoenchanting=384
-firecharge=385
-bookandquill=386
-writtenbook=387
-emerald=388
-itemframe=389
-flowerpot=390
-carrot=391
-potato=392
-bakedpotato=393
-poisonouspotato=394
-emptymap=395
-goldencarrot=396
-skeletonhead=397
-witherhead=397:1
-zombiehead=397:2
-stevehead=397:3
-creeperhead=397:4
-carrotonastick=398
-netherstar=399
-pumpkinpie=400
-fireworkrocket=401
-fireworkstar=402
-enchantedbook=403
-comparator=404
-netherbrickitem=405
-netherquartz=406
-tntminecart=407
-hopperminecart=408
-
-goldrecord=2256
-greenrecord=2257
-blocksrecord=2258
-chirprecord=2259
-farrecord=2260
-mallrecord=2261
-mellohirecord=2262
-stalrecord=2263
-stradrecord=2264
-wardrecord=2265
-11record=2266
-
+[Items]
+rock=1
+stone=1
+grass=2
+dirt=3
+cobblestone=4
+cobble=4
+planks=5
+appleplanks=5:0
+oakplanks=5:0
+coniferplanks=5:1
+pineplanks=5:1
+spruceplanks=5:1
+darkplanks=5:1
+birchplanks=5:2
+lightplanks=5:2
+jungleplanks=5:3
+redplanks=5:3
+
+; Obsolete: do not use "wood", as its meaning is not clear - wiki uses log as wood, we use planks as wood.
+wood=5
+
+sapling=6
+applesapling=6:0
+oaksapling=6:0
+conifersapling=6:1
+pinesapling=6:1
+sprucesapling=6:1
+birchsapling=6:2
+junglesapling=6:3
+adminium=7
+bedrock=7
+water=8
+stillwater=9
+swater=9
+stationarywater=9
+lava=10
+stilllava=11
+slava=11
+stationarylava=11
+sand=12
+gravel=13
+goldore=14
+ironore=15
+coalore=16
+tree=17
+log=17
+applelog=17:0
+oaklog=17:0
+coniferlog=17:1
+pinelog=17:1
+sprucelog=17:1
+darklog=17:1
+birchlog=17:2
+whitelog=17:2
+junglelog=17:3
+leaves=18
+appleleaves=18:0
+oakleaves=18:0
+coniferleaves=18:1
+pineleaves=18:1
+spruceleaves=18:1
+birchleaves=18:2
+jungleleaves=18:3
+sponge=19
+glass=20
+lapisore=21
+lapisblock=22
+dispenser=23
+sandstone=24
+normalsandstone=24:0
+ornamentsandstone=24:1
+decorativesandstone=24:1
+smoothsandstone=24:2
+noteblock=25
+bedblock=26
+poweredrail=27
+detectorrail=28
+stickypiston=29
+cobweb=30
+tallgrass=31
+tallgrassone=31:1
+tallgrasstwo=31:2
+deadbush=32
+piston=33
+pistonextension=34
+pistonhead=34
+cloth=35
+wool=35
+whitewool=35:0
+orangewool=35:1
+magentawool=35:2
+lightbluewool=35:3
+yellowwool=35:4
+limewool=35:5
+lightgreenwool=35:5
+ltgreenwool=35:5
+pinkwool=35:6
+graywool=35:7
+greywool=35:7
+darkgraywool=35:7
+darkgreywool=35:7
+dkgraywool=35:7
+dkgreywool=35:7
+lightgraywool=35:8
+lightgreywool=35:8
+ltgraywool=35:8
+ltgreywool=35:8
+cyanwool=35:9
+purplewool=35:10
+violetwool=35:10
+bluewool=35:11
+darkbluewool=35:11
+brownwool=35:12
+greenwool=35:13
+darkgreenwool=35:13
+dkgreenwool=35:13
+redwool=35:14
+blackwool=35:15
+flower=37
+rose=38
+brownmushroom=39
+redmushroom=40
+gold=41
+goldblock=41
+iron=42
+ironblock=42
+doubleslab=43
+stonedoubleslab=43:0
+sandstonedoubleslab=43:1
+wooddoubleslab=43:2
+cobblestonedoubleslab=43:3
+brickdoubleslab=43:4
+stonebrickdoubleslab=43:5
+netherbrickdoubleslab=43:6
+quartzdoubleslab=43:7
+slab=44
+step=44
+stoneslab=44:0
+sandstoneslab=44:1
+woodslab=44:2
+cobblestoneslab=44:3
+brickslab=44:4
+stonebrickslab=44:5
+netherbrickslab=44:6
+quartzslab=44:7
+brickblock=45
+brickwall=45
+tnt=46
+bookshelf=47
+bookcase=47
+mossycobblestone=48
+mossy=48
+obsidian=49
+torch=50
+fire=51
+mobspawner=52
+woodstairs=53
+chest=54
+redstonedust=55
+redstonewire=55
+diamondore=56
+diamondblock=57
+workbench=58
+crop=59
+crops=59
+soil=60
+furnace=61
+litfurnace=62
+signblock=63
+wooddoorblock=64
+ladder=65
+rails=66
+rail=66
+track=66
+tracks=66
+cobblestonestairs=67
+stairs=67
+signblocktop=68
+wallsign=68
+lever=69
+rockplate=70
+stoneplate=70
+irondoorblock=71
+woodplate=72
+redstoneore=73
+redstoneorealt=74
+redstonetorchoff=75
+redstonetorchon=76
+stonebutton=77
+snow=78
+ice=79
+snowblock=80
+cactus=81
+clayblock=82
+reedblock=83
+jukebox=84
+fence=85
+pumpkin=86
+netherstone=87
+netherrack=87
+hellrock=87
+slowsand=88
+soulsand=88
+lightstone=89
+glowstone=89
+portal=90
+jackolantern=91
+jacko=91
+cakeblock=92
+lockedchest=95
+trapdoor=96
+silverfishblock=97
+stonebricks=98
+stonebrick=98
+mossystonebrick=98:1
+crackedstonebrick=98:2
+chiseledstonebrick=98:3
+hugebrownmushroom=99
+hugeredmushroom=100
+ironbars=101
+glasspane=102
+melon=103
+pumpkinstem=104
+melonstem=105
+vines=106
+fencegate=107
+brickstairs=108
+stonebrickstairs=109
+mycelium=110
+lilypad=111
+netherbrick=112
+netherbrickfence=113
+netherbrickstairs=114
+netherwartblock=115
+enchantmenttable=116
+brewingstandblock=117
+cauldronblock=118
+endportal=119
+endportalframe=120
+endstone=121
+dragonegg=122
+redstonelamp=123
+redstonelampoff=123
+redstonelampon=124
+woodendoubleslab=125
+woodenslab=126
+sandstonestairs=128
+emeraldore=129
+enderchest=130
+tripwirehook=131
+tripwire=132
+emeraldblock=133
+commandblock=137
+beacon=138
+cobblestonewall=139
+mossycobblestonewall=139:1
+flowerpotblock=140
+carrotcrop=141
+potatocrop=142
+woodenbutton=143
+skeletonhead=144
+witherhead=144:1
+zombiehead=144:2
+humanhead=144:3
+stevehead=144:3
+creeperhead=144:4
+anvil=145
+trappedchest=146
+lightweightedpressureplate=147
+heavyweightedpressureplate=148
+inactivecomparator=149
+activecomparator=150
+daylightsensor=151
+redstoneblock=152
+netherquartzore=153
+hopper=154
+quartzblock=155
+chiseledquartzblock=155:1
+pillarquartzblock=155:2
+quartzstairs=156
+activatorrail=157
+dropper=158
+
+ironshovel=256
+ironspade=256
+ironpickaxe=257
+ironpick=257
+ironaxe=258
+flintandsteel=259
+lighter=259
+apple=260
+redapple=260
+bow=261
+arrow=262
+coal=263
+charcoal=263:1
+diamond=264
+ironingot=265
+ironbar=265
+goldingot=266
+goldeningot=266
+goldbar=266
+goldenbar=266
+ironsword=267
+woodensword=268
+woodsword=268
+woodenshovel=269
+woodshovel=269
+woodenspade=269
+woodspade=269
+woodenpickaxe=270
+woodpickaxe=270
+woodenpick=270
+woodpick=270
+woodenaxe=271
+woodaxe=271
+stonesword=272
+stoneshovel=273
+stonespade=273
+stonepickaxe=274
+stonepick=274
+stoneaxe=275
+diamondsword=276
+diamondshovel=277
+diamondspade=277
+diamondpickaxe=278
+diamondpick=278
+diamondaxe=279
+stick=280
+bowl=281
+mushroomstew=282
+bowlwithsoup=282
+soupbowl=282
+soup=282
+goldensword=283
+goldsword=283
+goldenshovel=284
+goldshovel=284
+goldenspade=284
+goldspade=284
+goldenpickaxe=285
+goldpickaxe=285
+goldenpick=285
+goldpick=285
+goldenaxe=286
+goldaxe=286
+string=287
+feather=288
+gunpowder=289
+woodhoe=290
+woodenhoe=290
+stonehoe=291
+ironhoe=292
+diamondhoe=293
+goldhoe=294
+goldenhoe=294
+seeds=295
+wheat=296
+bread=297
+leatherhelmet=298
+leatherchestplate=299
+leatherpants=300
+leatherboots=301
+chainmailhelmet=302
+chainmailchestplate=303
+chainmailpants=304
+chainmailboots=305
+ironhelmet=306
+ironchestplate=307
+ironpants=308
+ironboots=309
+diamondhelmet=310
+diamondchestplate=311
+diamondpants=312
+diamondboots=313
+goldenhelmet=314
+goldhelmet=314
+goldenchestplate=315
+goldchestplate=315
+goldenpants=316
+goldpants=316
+goldenboots=317
+goldboots=317
+flint=318
+meat=319
+pork=319
+cookedmeat=320
+cookedpork=320
+painting=321
+paintings=321
+goldenapple=322
+goldapple=322
+enchantedgoldenapple=322:1
+enchantedgoldapple=322:1
+sign=323
+wooddoor=324
+woodendoor=324
+bucket=325
+waterbucket=326
+lavabucket=327
+minecart=328
+saddle=329
+irondoor=330
+redstonedust=331
+snowball=332
+boat=333
+leather=334
+milkbucket=335
+brick=336
+clay=337
+reed=338
+sugarcane=338
+paper=339
+book=340
+slimeorb=341
+slimeball=341
+storageminecart=342
+poweredminecart=343
+egg=344
+compass=345
+fishingrod=346
+watch=347
+lightstonedust=348
+lightdust=348
+glowstonedust=348
+glowdust=348
+rawfish=349
+fish=349
+cookedfish=350
+dye=351
+inksac=351:0
+blackdye=351:0
+reddye=351:1
+rosered=351:1
+greendye=351:2
+cactusgreen=351:2
+cocoabeans=351:3
+browndye=351:3
+lapislazuli=351:4
+bluedye=351:4
+darkbluedye=351:4
+dkbluedye=351:4
+purpledye=351:5
+violetdye=351:5
+cyandye=351:6
+lightgreydye=351:7
+lightgraydye=351:7
+ltgreydye=351:7
+ltgraydye=351:7
+greydye=351:8
+graydye=351:8
+darkgreydye=351:8
+darkgraydye=351:8
+dkgreydye=351:8
+dkgraydye=351:8
+pinkdye=351:9
+limedye=351:10
+lightgreendye=351:10
+ltgreendye=351:10
+dandellionyellow=351:11
+yellowdye=351:11
+lightbluedye=351:12
+ltbluedye=351:12
+magentadye=351:13
+orangedye=351:14
+bonemeal=351:15
+whitedye=351:15
+bone=352
+sugar=353
+cake=354
+bed=355
+repeater=356
+diode=356
+cookie=357
+map=358
+shears=359
+melonslice=360
+pumpkinseeds=361
+melonseeds=362
+rawbeef=363
+steak=364
+rawchicken=365
+cookedchicken=366
+rottenflesh=367
+enderpearl=368
+blazerod=369
+ghasttear=370
+goldnugget=371
+netherwart=372
+potion=373
+glassbottle=374
+spidereye=375
+fermentedspidereye=376
+blazepowder=377
+magmacream=378
+brewingstand=379
+cauldron=380
+eyeofender=381
+glisteringmelon=382
+spawnegg=383
+bottleoenchanting=384
+firecharge=385
+bookandquill=386
+writtenbook=387
+emerald=388
+itemframe=389
+flowerpot=390
+carrot=391
+potato=392
+bakedpotato=393
+poisonouspotato=394
+emptymap=395
+goldencarrot=396
+skeletonhead=397
+witherhead=397:1
+zombiehead=397:2
+stevehead=397:3
+creeperhead=397:4
+carrotonastick=398
+netherstar=399
+pumpkinpie=400
+fireworkrocket=401
+fireworkstar=402
+enchantedbook=403
+comparator=404
+netherbrickitem=405
+netherquartz=406
+tntminecart=407
+hopperminecart=408
+
+goldrecord=2256
+greenrecord=2257
+blocksrecord=2258
+chirprecord=2259
+farrecord=2260
+mallrecord=2261
+mellohirecord=2262
+stalrecord=2263
+stradrecord=2264
+wardrecord=2265
+11record=2266
+
diff --git a/MCServer/monsters.ini b/MCServer/monsters.ini
index 6634c5bef..80a0c7dde 100644
--- a/MCServer/monsters.ini
+++ b/MCServer/monsters.ini
@@ -1,111 +1,111 @@
-[Spider]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=1.0
-SightDistance=25.0
-MaxHealth=10
-
-[Chicken]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=1.0
-SightDistance=25.0
-MaxHealth=4
-
-[Cow]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=1.0
-SightDistance=25.0
-MaxHealth=10
-
-[Pig]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=1.0
-SightDistance=25.0
-MaxHealth=10
-
-[Sheep]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=1.0
-SightDistance=25.0
-MaxHealth=8
-
-[Squid]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=1.0
-SightDistance=25.0
-MaxHealth=10
-
-[Enderman]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=4.0
-SightDistance=25.0
-MaxHealth=40
-
-[Zombiepigman]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=5.0
-SightDistance=25.0
-MaxHealth=20
-
-[Cavespider]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=2.0
-SightDistance=25.0
-MaxHealth=12
-
-[Creeper]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=0.0
-SightDistance=25.0
-MaxHealth=20
-
-[Ghast]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=0.0
-SightDistance=25.0
-MaxHealth=10
-
-[Silverfish]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=1.0
-SightDistance=25.0
-MaxHealth=8
-
-[Skeleton]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=4.0
-SightDistance=25.0
-MaxHealth=20
-
-[Slime]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=10.0
-SightDistance=25.0
-MaxHealth=32
-
-[Spider]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=2.0
-SightDistance=25.0
-MaxHealth=16
-
-[Zombie]
-AttackRange=5.0
-AttackRate=1
-AttackDamage=4.0
-SightDistance=25.0
+[Spider]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=1.0
+SightDistance=25.0
+MaxHealth=10
+
+[Chicken]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=1.0
+SightDistance=25.0
+MaxHealth=4
+
+[Cow]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=1.0
+SightDistance=25.0
+MaxHealth=10
+
+[Pig]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=1.0
+SightDistance=25.0
+MaxHealth=10
+
+[Sheep]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=1.0
+SightDistance=25.0
+MaxHealth=8
+
+[Squid]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=1.0
+SightDistance=25.0
+MaxHealth=10
+
+[Enderman]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=4.0
+SightDistance=25.0
+MaxHealth=40
+
+[Zombiepigman]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=5.0
+SightDistance=25.0
+MaxHealth=20
+
+[Cavespider]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=2.0
+SightDistance=25.0
+MaxHealth=12
+
+[Creeper]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=0.0
+SightDistance=25.0
+MaxHealth=20
+
+[Ghast]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=0.0
+SightDistance=25.0
+MaxHealth=10
+
+[Silverfish]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=1.0
+SightDistance=25.0
+MaxHealth=8
+
+[Skeleton]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=4.0
+SightDistance=25.0
+MaxHealth=20
+
+[Slime]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=10.0
+SightDistance=25.0
+MaxHealth=32
+
+[Spider]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=2.0
+SightDistance=25.0
+MaxHealth=16
+
+[Zombie]
+AttackRange=5.0
+AttackRate=1
+AttackDamage=4.0
+SightDistance=25.0
MaxHealth=20 \ No newline at end of file
diff --git a/MCServer/settings.ini b/MCServer/settings.example.ini
index 5e6ed4e2b..e2505368d 100644
--- a/MCServer/settings.ini
+++ b/MCServer/settings.example.ini
@@ -1,31 +1,31 @@
-; This is the main server configuration
-; For help, please visit the Wiki page: http://www.mc-server.org/wiki/doku.php?id=configure:settings.ini
-; Most of these settings can also be set using the webadmin interface, if it is enabled.
-
-[Server]
-Port=25565
-MaxPlayers=100
-Description=MCServer - in C++
-DefaultViewDistance=9
-
-[Worlds]
-DefaultWorld=world
-
-[Plugins]
-; Plugin=Debuggers
-; Plugin=DiamondMover
-; Plugin=HookNotify
-Plugin=Core
-Plugin=ChunkWorx
-Plugin=ChatLog
-
-[Monsters]
-AnimalsOn=0
-AnimalSpawnInterval=10
-Types=Spider,Chicken,Cow,Pig,Sheep,Squid,Enderman,Zombiepigman,Cavespider,Creeper,Ghast,Silverfish,Skeleton,Slime,Spider,Zombie
-
-[Authentication]
-Server=session.minecraft.net
-Address=/game/checkserver.jsp?user=%USERNAME%&serverId=%SERVERID%
-Authenticate=0
-
+; This is the main server configuration
+; For help, please visit the Wiki page: http://www.mc-server.org/wiki/doku.php?id=configure:settings.ini
+; Most of these settings can also be set using the webadmin interface, if it is enabled.
+
+[Server]
+Port=25565
+MaxPlayers=100
+Description=MCServer - in C++
+DefaultViewDistance=9
+
+[Worlds]
+DefaultWorld=world
+
+[Plugins]
+; Plugin=Debuggers
+; Plugin=DiamondMover
+; Plugin=HookNotify
+Plugin=Core
+Plugin=ChunkWorx
+Plugin=ChatLog
+
+[Monsters]
+AnimalsOn=0
+AnimalSpawnInterval=10
+Types=Spider,Chicken,Cow,Pig,Sheep,Squid,Enderman,Zombiepigman,Cavespider,Creeper,Ghast,Silverfish,Skeleton,Slime,Spider,Zombie
+
+[Authentication]
+Server=session.minecraft.net
+Address=/game/checkserver.jsp?user=%USERNAME%&serverId=%SERVERID%
+Authenticate=0
+
diff --git a/MCServer/terrain.ini b/MCServer/terrain.ini
deleted file mode 100644
index a917223f9..000000000
--- a/MCServer/terrain.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[Terrain]
-HeightFreq1=0.100000
-HeightFreq2=1.000000
-HeightFreq3=2.000000
-HeightAmp1=1.000000
-HeightAmp2=0.500000
-HeightAmp3=0.500000
-
diff --git a/MCServer/users.ini b/MCServer/users.ini
index 1015527cc..6726c0bf8 100644
--- a/MCServer/users.ini
+++ b/MCServer/users.ini
@@ -1,23 +1,23 @@
-[FakeTruth]
-Groups=Admins
-
-[Duralex]
-Groups=Admins
-
-[Luthrandel]
-Groups=Admins
-
-[cruisecho]
-Groups=Admins
-
-[Kwen]
-Groups=Admins
-
-[aloe_vera]
-Groups=Admins
-
-[xoft]
-Groups=Admins
-
-[Player]
+[FakeTruth]
+Groups=Admins
+
+[Duralex]
+Groups=Admins
+
+[Luthrandel]
+Groups=Admins
+
+[cruisecho]
+Groups=Admins
+
+[Kwen]
+Groups=Admins
+
+[aloe_vera]
+Groups=Admins
+
+[xoft]
+Groups=Admins
+
+[Player]
Groups=Admins \ No newline at end of file
diff --git a/MCServer/webadmin.ini b/MCServer/webadmin.example.ini
index 7384f0bde..8597225bb 100644
--- a/MCServer/webadmin.ini
+++ b/MCServer/webadmin.example.ini
@@ -1,6 +1,6 @@
-[WebAdmin]
-Enabled=1
-Port=8081
-
-[User:admin]
+[WebAdmin]
+Enabled=1
+Port=8081
+
+[User:admin]
Password=admin \ No newline at end of file
diff --git a/MCServer/webadmin/template.html b/MCServer/webadmin/template.html
index 4636959f2..822f73857 100644
--- a/MCServer/webadmin/template.html
+++ b/MCServer/webadmin/template.html
@@ -1,129 +1,129 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>{TITLE} | {PLUGIN_NAME}</title>
- <style type="text/css">
- body {
- line-height: 1;
- background: #B8B8B8;
- }
-
- #maincontent {
- padding: 0px 25px 10px 25px;
- }
-
- #wrapper {
- min-width: 850px;
- width: 75%;
- margin: 10px auto;
- background-color: white;
- border: 4px #888888 solid;
- border-radius: 10px;
- font-family: Calibri, Trebuchet MS;
- }
-
- header {
- text-align:center;
- padding: 10px; 0px;
- }
-
- span {
- text-align: right;
- float: right;
- border-left: 2px #C8C8C8 solid;
- border-bottom: 2px #C8C8C8 solid;
- padding: 2px 10px;
- }
-
- footer {
- font-family: helvetica;
- font-size: 10px;
- text-align: center;
- border-top: 1px #000 dotted;
- padding: 1px 0px 1px 0px;
- }
-
- table {
- border-collapse: collapse;
- border-spacing: 10;
- }
-
- table {
- border-top: 1px solid #ddd;
- width: 700px;
- }
-
- table tr th {
- text-align: left;
- background: #f6f6f6;
- padding: 0px 20px;
- height: 25px;
- line-height: 25px;
- border: 1px solid #ddd;
- border-radius: 3px;
- }
-
- table tr td {
- background: #f6f6f6;
- padding: 0px 20px;
- height: 29px;
- line-height: 29px;
- border: 1px solid #ddd;
- border-radius: 3px;
- }
- #main table tr.odd td {
- background: #fbfbfb;
- }
-
- table tr:hover td { background: #fdfcf6; }
- table .action {
- text-align: right;
- padding: 0 20px 0 10px;
- }
-
- table tr .action a { color: #9b9b9b; }
-
- #cssmenu{ height:10px; display:table; padding:0; margin: 0 auto; border:1px #707070 solid; border-radius:5px; }
- #cssmenu > ul {list-style:inside none; padding:0; margin:0;}
- #cssmenu > ul > li {list-style:inside none; padding:0; margin:0; float:left; display:block; position:relative;}
- #cssmenu > ul > li > a{ outline:none; display:block; position:relative; color:#E8E8E8; padding:10px 10px; font:bold 13px/100% Arial, Helvetica, sans-serif; text-align:center; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.4); }
- #cssmenu > ul > li:first-child > a{border-radius:5px 0 0 5px;}
- /* #cssmenu > ul > li > a:after{ content:''; position:absolute; border-right:1px solid #FFFFFF; top:-1px; bottom:-1px; right:-2px; z-index:99; } */
- #cssmenu ul li.has-sub:hover > a:after{top:0; bottom:0;}
- #cssmenu > ul > li.has-sub > a:before{ content:''; position:absolute; top:18px; right:6px; border:5px solid transparent; border-top:5px solid #707070; }
- #cssmenu > ul > li.has-sub:hover > a:before{top:19px;}
- #cssmenu ul li.has-sub:hover > a{ background:#3f3f3f; border-color:#707070; padding-bottom:13px; padding-top:13px; top:-1px; z-index:999; }
- #cssmenu ul li.has-sub:hover > ul, #cssmenu ul li.has-sub:hover > div{display:block;}
- #cssmenu ul li.has-sub > a:hover{background:#3f3f3f; border-color:#3f3f3f;}
- #cssmenu ul li > ul, #cssmenu ul li > div{ display:none; width:auto; position:absolute; top:38px; padding:10px 0; background:#3f3f3f; border-radius:0 0 5px 5px; z-index:999; }
- #cssmenu ul li > ul{width:200px;}
- #cssmenu ul li > ul li{display:block; list-style:inside none; padding:0; margin:0; position:relative;}
- #cssmenu ul li > ul li a{ outline:none; display:block; position:relative; margin:0; padding:8px 20px; font:10pt Arial, Helvetica, sans-serif; color:#fff; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.5); }
- #cssmenu, #cssmenu > ul > li > ul > li a:hover{ background:#C8C8C8;}
- #cssmenu > ul > li > a{border-right:1px solid #707070; color:#FFFFFF;}
- #cssmenu > ul > li > a:after{border-color:#707070;}
- #cssmenu > ul > li > a:hover{background:#B8B8B8;}
- </style>
- <meta name="msapplication-tooltip" content="MCServer WebAdministrator"/>
- <meta name="msapplication-navbutton-color" content="#B8B8B8" />
- <link rel="shortcut icon" href="http://mc-server.org/favicon.ico" />
-</head>
-
-<body>
- <div id="wrapper">
- <span><b>Login: {USERNAME}</b></span><br />
- <header>
- <img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAAkCAMAAAAXdeBDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAuVQTFRFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs7OzAAAAAAAAoqKiAAAAvLy8AAAAlZWVtbW1j4+Pra2tiYmJp6enAAAAhISEoaGhAAAAgICAm5ube3t7lZWVd3d3kZGRc3NzjIyMbGxsg4ODgICAeHh43NzcdXV1cnJyy8vLWVlZbGxswcHB09PTvLy8uLi4tLS0sLCwvLy8uLi4tbW1oaGhnp6era2tm5ubqqqq39/f29vblZWV09PT4ODgz8/P3NzckZGRxcXF0tLSwsLCzs7Oy8vLyMjIt7e3vLy85ubm7u7u3d3d5+fn2tra5OTk19fX1dXV3t7e29vb2dnZ1tbW0dHRv7+/8PDw7u7u6+vr8fHx5ubm4+Pj7Ozs4eHh3t7e5+fn5OTk2tra4uLi39/f1dXV3d3d29vb2dnZ19fX1dXV0tLS9fX18/Pzzs7O7u7u8/PzycnJ6urq6Ojo7+/v5ubm7Ozs4+Pj4eHh39/f5ubm5OTk4uLi4ODg2NjY3Nzc29vb19fX8vLy9/f39fX17e3t8/Pz6+vr8fHx7+/v5+fn7e3t5eXl6+vr6enp6Ojo4ODg39/f9PT0+Pj48fHx9vb27+/v9PT07e3t8/Pz7Ozs8fHx7+/v6Ojo7u7u5+fn7Ozs5eXl6urq5OTk6enp5+fn5ubm5OTk+Pj49/f39fX19PT0+fn58vLy8fHx9fX19PT08vLy8fHx6urq+Pj49vb29fX19PT08vLy8PDw+/v7+vr6+Pj49/f39vb29fX18/Pz/f39+/v7+vr6+fn5+Pj49/f3/f39/Pz8+vr6/v7+/f39a5KrdZmxf6G2iai8kq/BnLbHpr7NsMXSuszYxNPdxmZTynBeznpqztvj0YV11Y+B2OLp2ZmM3aOY4a2j4enu5Liv6MK66/D07MzG8NbR9ODd9fj59+vo+/X0ucu1kQAAANl0Uk5TAAECAwQFBgcICQoLDA0ODxAREhMUFBUWFhcXGBgYGRkaGhsbGxwcHB0dHh4fHyEhIiQkJSYnKCgpKSorLC0uLzAxMjIzMzc4Ojo6Ozs8Pj4/P0BBQ0VISUtLTExNTk5PUFFTV1dYWVpbXFxdXl5fYGBhYmJjZGVmZ2doaWprbGxtbW5ub3BxcXJzdHV2d3l6e3x9fX5+f4CAgYGCg4SIi4yNjY6Oj4+QkJGSkpOTlJSVlZaXmJqbnJ2dnp+foKGip6+wsbKztb6/wMHCw8TOz9DR0tPf4OHv8LXp8fEAAAi/SURBVHja3Zh/dBRXFcdhZ+a9eTPzZnaXmJam0FYUEQWLrVVbqdZaf6EWQW2txN/SWiAmxFqtIlWr9bdWqkbwF6WQYIq/+WFpwSZqTahhg6RhNptkl9nsbjeb2eyv+dv73g6wlcyewXMazvGek3Dm5jLv8+689733vTn/q81ldr5zzsWxuVWr55sbCAiiBCYKAeZ1nYIgigJ4Zh2Zj+0OXesTgQ987pOEZUVVVYXISIJQPi3mJETG0kXADggIL5CRWDMy57kCaDgdBMgK1de0gi2jGsESZJt5iXpjS8utGkHiLFMDIHrNgfJBFYs1i0Ei73iifIAggIEHrNDWnuGpFFg50vEKVYbcArNye0+lUCj13aUgYbahRbInbqbu1zAf2XXpR8bN1CZZYItA1jb0pcaiJrdYorxzIRYFYN7qZC2wTOVXMuR+dqGR2hU3Y4NLFSlwJtGIfmbKNFOt4BIkQndOj5rR8dMpsETMjCae+gASJbLKSSftUsWeSJbWz3aqgXBvPGomOnWWajfRoWOjAN2uIWBedOh0NJoYPvJgW1tb+47I1Jg5Vl6AsPrkZLLU+f5bdjjpzNOzDo1pdzw2Fi2vVlBVFgRMf5oyYXl8lmIk00MJc7S8e6mhU02jerC5JzFavgyRlztWbl9j2NC3lvJbpMDFgJ6Ojh/VZb4XA5KycmhkNAXQOpG1ncDfv9HQQNsQZsK3cNvTn5SQ0lKwCveEdYWQd25BrugxUQHjAl/fPKL9Q2t747F/x82pjSpXC0Gme+EJoNt1Vb2jHI1FVlMmawFWYiQgB6mWCIcOaVgCA2ZX3BEGQyI4vAsXWN1of9Bd8diJZ0dG+3QiwuSRsq4cHf8rgzao3jMWnX5Al88oMdNnAQRPlOlwMrcvrBMYk2WrWmyIqlGqqYRJPE+kwK2a0Jr8wo9nNPzRL/QvTpupH4HsAQ4DLX+ZQQeNN02b8W6DSLWVh5mA+EbcHaKkWhF5sdGWdfREIj0dyzSCBDAJY1nGCKo/r/9uguEB/uQZLQZ8Qe+JxwZffGx0ZGixgiSsbXzOTDz2RQYdDm1PmFNrNXTee+ZKMpO8fP+DhiYjAGLF5oYux86m01nb6bqBACr+4Id1/cZHH7pUxne+HkE63fp7522A5xn9IiHgF7ppM6DuokRWjD7Av+7zDHrevEgsFgkq0vndnVtcMvmhjkUKJFvEyqf7ckkrmU7Dr1zfXQTLXyoWv95ZydnblB8UKut5BYL/Rw4Uih9S6Qav6B9CnD/oSGPj0fFouVmn+sOwUH7W9DmmHg0Nw9H4Xp0IM1Z/KOOFjDVhR7ZqMpbVO5yMlS2eGhw8VYTJOC9RtOPp9Ak7adk/picnMv/UZL5jyO0ly+4INntGP+QfOhxeXY6O9c4L31QeGettaLyHQTeuKJsALQdm3PyI0Na+UtZKl3ZSjS7uzVr23z7e0Nj00t8Wk2nnZaoeSadtK1s6uJD+xLYKLSBOTJp6sklnxXLP6AOXin6XRyRoGLsS5nObm34HctccCrdz6GsYNJ0JmquFrOjNvcV0srQrFN5tW/bh5aHQvPm/KQHFVkULDsK3n/x7s0bURZDqPtAg+DxrSlau+5JOz2gVCX434nGod4uhpDzzielo/HFdD7bXzbSbbBHJmvEAbMjK5qZTyUz/8qCuhzsZxf0qUUODaSt94n06rB3aYVulZhVLMgXRcd5SL1oM+IamCtEeTpmn/wFyt1JV9ba6a9qlZtgKUE9kjn0vb+W/FdapsYtTaBgrDCP/3bAiQX4XD01ke6B8qisdkPf5364TDcy+oQkmRu/YyGmmITKhbXXVwy10DFtSgjsgjX/KWc41IeMshQj+wTT4dBxg3cx2iGHbvCuXdN58yb560XP8Q8sSUpunzOho/xICX73trE5P33yeTgOre0KDNYLp1Y5l/xkwrm0In6UICMSArTUYVmHGMLNlTjLbGw69chj+aWjorhftHxoECWrh43HoouEluAodNNZMzVQRWQty2wJJ5NRIexU0fAz6tU2dVQomyVUM+ExCtXGspvjnLOGh0N460RcELQQkcn15/AnAFxCHbvPqPUSE9xedKyBDHPpqBm1blXc/5lKwfkRSOIbBNwQ8vQEW8x+uexaWtqEb2z2jLxSaadjb/vJWLAUCLnRtlye4bQ7CYPK7Slb+ayrMhfUqt1Ss/PeLlv17RvFVqsisEcQqx2C7+FyqfwmJXqcp2ke9oi8YGl4tSkgSAM6Fph799KcU7SSkLEgJxoSGYYVW3v5MZqIAFN8I65qqvu6RLUQLcgx4r9ukO0n7X5lsr04w0fu9on1CI5VDY4F/fN5DAnRriq3u2pMLrTm5XKVBjcvvDoPTCO8uJSePzr+3YFlp5ztNDUEjuO6pXP4rtAaDp/rI5ETBKn5MRbDl2zyifUMrDFrFgdoeTuHQyrkz4hCcEcF29PMz4lXKlVAk8r3fXHtzey8rw+8JzTtsW5POH++9dkV7twM1ehtlH/w4K6duqteWLCgphiyyJeUd7cMAkDwK0AQ9D5psAuhN5NxpfMQ9jY/y07gsK6ucSSubL1UKWYttJ5UuBY5kruA4BWjf7IOXqxRaoLPJgK5Dh36j0Mo6EJjBEo9on9AifiQeG8BSLbSA7wbou7HHvYcsSUhZ9aQ9YYFN5CJbVRnJ6pLDxYzFLVM8dDkhykA6PSDDe91UQ39X7fV4i+gZ7ceA6tW/HviCVNumwAh4f3k/ljxvmAQBkSs7TpYKheLQnusVJIIMErqxr1TI5QqVvg0gZAjfNzBwH3Lfy0DJeod31ezBO9qXsfOPexqqnQlagGa8y1MJFqviB85bW1o+QiHNTHEENrn3tnZ1tb6RsmMBkyJUcznJ5PIyyRX8OtF+jEsGG/S/fPyIOdOtKZuf2+NhonAPBLqTI6qmKQTDLPhrmbjXjnPmuW60/wtqryt07/tp3oA8z8MdCHHXjBcC7mOd6Bfk7r3udC94aDf6/9T+AzWzIkAbVeu4AAAAAElFTkSuQmCC" />
- </header>
- <nav id="cssmenu">
- <ul>
- {MENU}
- </ul>
- </nav>
- <div id="maincontent">
- {CONTENT}
- </div>
- <footer><p>MCServer is using {MEM}MB of memory, with {NUMCHUNKS} chunks loaded.</p><p>Web Design by Tiger</p></footer>
- </div>
-</head>
-</html>
+<!DOCTYPE html>
+<html>
+<head>
+ <title>{TITLE} | {PLUGIN_NAME}</title>
+ <style type="text/css">
+ body {
+ line-height: 1;
+ background: #B8B8B8;
+ }
+
+ #maincontent {
+ padding: 0px 25px 10px 25px;
+ }
+
+ #wrapper {
+ min-width: 850px;
+ width: 75%;
+ margin: 10px auto;
+ background-color: white;
+ border: 4px #888888 solid;
+ border-radius: 10px;
+ font-family: Calibri, Trebuchet MS;
+ }
+
+ header {
+ text-align:center;
+ padding: 10px; 0px;
+ }
+
+ span {
+ text-align: right;
+ float: right;
+ border-left: 2px #C8C8C8 solid;
+ border-bottom: 2px #C8C8C8 solid;
+ padding: 2px 10px;
+ }
+
+ footer {
+ font-family: helvetica;
+ font-size: 10px;
+ text-align: center;
+ border-top: 1px #000 dotted;
+ padding: 1px 0px 1px 0px;
+ }
+
+ table {
+ border-collapse: collapse;
+ border-spacing: 10;
+ }
+
+ table {
+ border-top: 1px solid #ddd;
+ width: 700px;
+ }
+
+ table tr th {
+ text-align: left;
+ background: #f6f6f6;
+ padding: 0px 20px;
+ height: 25px;
+ line-height: 25px;
+ border: 1px solid #ddd;
+ border-radius: 3px;
+ }
+
+ table tr td {
+ background: #f6f6f6;
+ padding: 0px 20px;
+ height: 29px;
+ line-height: 29px;
+ border: 1px solid #ddd;
+ border-radius: 3px;
+ }
+ #main table tr.odd td {
+ background: #fbfbfb;
+ }
+
+ table tr:hover td { background: #fdfcf6; }
+ table .action {
+ text-align: right;
+ padding: 0 20px 0 10px;
+ }
+
+ table tr .action a { color: #9b9b9b; }
+
+ #cssmenu{ height:10px; display:table; padding:0; margin: 0 auto; border:1px #707070 solid; border-radius:5px; }
+ #cssmenu > ul {list-style:inside none; padding:0; margin:0;}
+ #cssmenu > ul > li {list-style:inside none; padding:0; margin:0; float:left; display:block; position:relative;}
+ #cssmenu > ul > li > a{ outline:none; display:block; position:relative; color:#E8E8E8; padding:10px 10px; font:bold 13px/100% Arial, Helvetica, sans-serif; text-align:center; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.4); }
+ #cssmenu > ul > li:first-child > a{border-radius:5px 0 0 5px;}
+ /* #cssmenu > ul > li > a:after{ content:''; position:absolute; border-right:1px solid #FFFFFF; top:-1px; bottom:-1px; right:-2px; z-index:99; } */
+ #cssmenu ul li.has-sub:hover > a:after{top:0; bottom:0;}
+ #cssmenu > ul > li.has-sub > a:before{ content:''; position:absolute; top:18px; right:6px; border:5px solid transparent; border-top:5px solid #707070; }
+ #cssmenu > ul > li.has-sub:hover > a:before{top:19px;}
+ #cssmenu ul li.has-sub:hover > a{ background:#3f3f3f; border-color:#707070; padding-bottom:13px; padding-top:13px; top:-1px; z-index:999; }
+ #cssmenu ul li.has-sub:hover > ul, #cssmenu ul li.has-sub:hover > div{display:block;}
+ #cssmenu ul li.has-sub > a:hover{background:#3f3f3f; border-color:#3f3f3f;}
+ #cssmenu ul li > ul, #cssmenu ul li > div{ display:none; width:auto; position:absolute; top:38px; padding:10px 0; background:#3f3f3f; border-radius:0 0 5px 5px; z-index:999; }
+ #cssmenu ul li > ul{width:200px;}
+ #cssmenu ul li > ul li{display:block; list-style:inside none; padding:0; margin:0; position:relative;}
+ #cssmenu ul li > ul li a{ outline:none; display:block; position:relative; margin:0; padding:8px 20px; font:10pt Arial, Helvetica, sans-serif; color:#fff; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.5); }
+ #cssmenu, #cssmenu > ul > li > ul > li a:hover{ background:#C8C8C8;}
+ #cssmenu > ul > li > a{border-right:1px solid #707070; color:#FFFFFF;}
+ #cssmenu > ul > li > a:after{border-color:#707070;}
+ #cssmenu > ul > li > a:hover{background:#B8B8B8;}
+ </style>
+ <meta name="msapplication-tooltip" content="MCServer WebAdministrator"/>
+ <meta name="msapplication-navbutton-color" content="#B8B8B8" />
+ <link rel="shortcut icon" href="http://mc-server.org/favicon.ico" />
+</head>
+
+<body>
+ <div id="wrapper">
+ <span><b>Login: {USERNAME}</b></span><br />
+ <header>
+ <img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAAkCAMAAAAXdeBDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAuVQTFRFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs7OzAAAAAAAAoqKiAAAAvLy8AAAAlZWVtbW1j4+Pra2tiYmJp6enAAAAhISEoaGhAAAAgICAm5ube3t7lZWVd3d3kZGRc3NzjIyMbGxsg4ODgICAeHh43NzcdXV1cnJyy8vLWVlZbGxswcHB09PTvLy8uLi4tLS0sLCwvLy8uLi4tbW1oaGhnp6era2tm5ubqqqq39/f29vblZWV09PT4ODgz8/P3NzckZGRxcXF0tLSwsLCzs7Oy8vLyMjIt7e3vLy85ubm7u7u3d3d5+fn2tra5OTk19fX1dXV3t7e29vb2dnZ1tbW0dHRv7+/8PDw7u7u6+vr8fHx5ubm4+Pj7Ozs4eHh3t7e5+fn5OTk2tra4uLi39/f1dXV3d3d29vb2dnZ19fX1dXV0tLS9fX18/Pzzs7O7u7u8/PzycnJ6urq6Ojo7+/v5ubm7Ozs4+Pj4eHh39/f5ubm5OTk4uLi4ODg2NjY3Nzc29vb19fX8vLy9/f39fX17e3t8/Pz6+vr8fHx7+/v5+fn7e3t5eXl6+vr6enp6Ojo4ODg39/f9PT0+Pj48fHx9vb27+/v9PT07e3t8/Pz7Ozs8fHx7+/v6Ojo7u7u5+fn7Ozs5eXl6urq5OTk6enp5+fn5ubm5OTk+Pj49/f39fX19PT0+fn58vLy8fHx9fX19PT08vLy8fHx6urq+Pj49vb29fX19PT08vLy8PDw+/v7+vr6+Pj49/f39vb29fX18/Pz/f39+/v7+vr6+fn5+Pj49/f3/f39/Pz8+vr6/v7+/f39a5KrdZmxf6G2iai8kq/BnLbHpr7NsMXSuszYxNPdxmZTynBeznpqztvj0YV11Y+B2OLp2ZmM3aOY4a2j4enu5Liv6MK66/D07MzG8NbR9ODd9fj59+vo+/X0ucu1kQAAANl0Uk5TAAECAwQFBgcICQoLDA0ODxAREhMUFBUWFhcXGBgYGRkaGhsbGxwcHB0dHh4fHyEhIiQkJSYnKCgpKSorLC0uLzAxMjIzMzc4Ojo6Ozs8Pj4/P0BBQ0VISUtLTExNTk5PUFFTV1dYWVpbXFxdXl5fYGBhYmJjZGVmZ2doaWprbGxtbW5ub3BxcXJzdHV2d3l6e3x9fX5+f4CAgYGCg4SIi4yNjY6Oj4+QkJGSkpOTlJSVlZaXmJqbnJ2dnp+foKGip6+wsbKztb6/wMHCw8TOz9DR0tPf4OHv8LXp8fEAAAi/SURBVHja3Zh/dBRXFcdhZ+a9eTPzZnaXmJam0FYUEQWLrVVbqdZaf6EWQW2txN/SWiAmxFqtIlWr9bdWqkbwF6WQYIq/+WFpwSZqTahhg6RhNptkl9nsbjeb2eyv+dv73g6wlcyewXMazvGek3Dm5jLv8+689733vTn/q81ldr5zzsWxuVWr55sbCAiiBCYKAeZ1nYIgigJ4Zh2Zj+0OXesTgQ987pOEZUVVVYXISIJQPi3mJETG0kXADggIL5CRWDMy57kCaDgdBMgK1de0gi2jGsESZJt5iXpjS8utGkHiLFMDIHrNgfJBFYs1i0Ei73iifIAggIEHrNDWnuGpFFg50vEKVYbcArNye0+lUCj13aUgYbahRbInbqbu1zAf2XXpR8bN1CZZYItA1jb0pcaiJrdYorxzIRYFYN7qZC2wTOVXMuR+dqGR2hU3Y4NLFSlwJtGIfmbKNFOt4BIkQndOj5rR8dMpsETMjCae+gASJbLKSSftUsWeSJbWz3aqgXBvPGomOnWWajfRoWOjAN2uIWBedOh0NJoYPvJgW1tb+47I1Jg5Vl6AsPrkZLLU+f5bdjjpzNOzDo1pdzw2Fi2vVlBVFgRMf5oyYXl8lmIk00MJc7S8e6mhU02jerC5JzFavgyRlztWbl9j2NC3lvJbpMDFgJ6Ojh/VZb4XA5KycmhkNAXQOpG1ncDfv9HQQNsQZsK3cNvTn5SQ0lKwCveEdYWQd25BrugxUQHjAl/fPKL9Q2t747F/x82pjSpXC0Gme+EJoNt1Vb2jHI1FVlMmawFWYiQgB6mWCIcOaVgCA2ZX3BEGQyI4vAsXWN1of9Bd8diJZ0dG+3QiwuSRsq4cHf8rgzao3jMWnX5Al88oMdNnAQRPlOlwMrcvrBMYk2WrWmyIqlGqqYRJPE+kwK2a0Jr8wo9nNPzRL/QvTpupH4HsAQ4DLX+ZQQeNN02b8W6DSLWVh5mA+EbcHaKkWhF5sdGWdfREIj0dyzSCBDAJY1nGCKo/r/9uguEB/uQZLQZ8Qe+JxwZffGx0ZGixgiSsbXzOTDz2RQYdDm1PmFNrNXTee+ZKMpO8fP+DhiYjAGLF5oYux86m01nb6bqBACr+4Id1/cZHH7pUxne+HkE63fp7522A5xn9IiHgF7ppM6DuokRWjD7Av+7zDHrevEgsFgkq0vndnVtcMvmhjkUKJFvEyqf7ckkrmU7Dr1zfXQTLXyoWv95ZydnblB8UKut5BYL/Rw4Uih9S6Qav6B9CnD/oSGPj0fFouVmn+sOwUH7W9DmmHg0Nw9H4Xp0IM1Z/KOOFjDVhR7ZqMpbVO5yMlS2eGhw8VYTJOC9RtOPp9Ak7adk/picnMv/UZL5jyO0ly+4INntGP+QfOhxeXY6O9c4L31QeGettaLyHQTeuKJsALQdm3PyI0Na+UtZKl3ZSjS7uzVr23z7e0Nj00t8Wk2nnZaoeSadtK1s6uJD+xLYKLSBOTJp6sklnxXLP6AOXin6XRyRoGLsS5nObm34HctccCrdz6GsYNJ0JmquFrOjNvcV0srQrFN5tW/bh5aHQvPm/KQHFVkULDsK3n/x7s0bURZDqPtAg+DxrSlau+5JOz2gVCX434nGod4uhpDzzielo/HFdD7bXzbSbbBHJmvEAbMjK5qZTyUz/8qCuhzsZxf0qUUODaSt94n06rB3aYVulZhVLMgXRcd5SL1oM+IamCtEeTpmn/wFyt1JV9ba6a9qlZtgKUE9kjn0vb+W/FdapsYtTaBgrDCP/3bAiQX4XD01ke6B8qisdkPf5364TDcy+oQkmRu/YyGmmITKhbXXVwy10DFtSgjsgjX/KWc41IeMshQj+wTT4dBxg3cx2iGHbvCuXdN58yb560XP8Q8sSUpunzOho/xICX73trE5P33yeTgOre0KDNYLp1Y5l/xkwrm0In6UICMSArTUYVmHGMLNlTjLbGw69chj+aWjorhftHxoECWrh43HoouEluAodNNZMzVQRWQty2wJJ5NRIexU0fAz6tU2dVQomyVUM+ExCtXGspvjnLOGh0N460RcELQQkcn15/AnAFxCHbvPqPUSE9xedKyBDHPpqBm1blXc/5lKwfkRSOIbBNwQ8vQEW8x+uexaWtqEb2z2jLxSaadjb/vJWLAUCLnRtlye4bQ7CYPK7Slb+ayrMhfUqt1Ss/PeLlv17RvFVqsisEcQqx2C7+FyqfwmJXqcp2ke9oi8YGl4tSkgSAM6Fph799KcU7SSkLEgJxoSGYYVW3v5MZqIAFN8I65qqvu6RLUQLcgx4r9ukO0n7X5lsr04w0fu9on1CI5VDY4F/fN5DAnRriq3u2pMLrTm5XKVBjcvvDoPTCO8uJSePzr+3YFlp5ztNDUEjuO6pXP4rtAaDp/rI5ETBKn5MRbDl2zyifUMrDFrFgdoeTuHQyrkz4hCcEcF29PMz4lXKlVAk8r3fXHtzey8rw+8JzTtsW5POH++9dkV7twM1ehtlH/w4K6duqteWLCgphiyyJeUd7cMAkDwK0AQ9D5psAuhN5NxpfMQ9jY/y07gsK6ucSSubL1UKWYttJ5UuBY5kruA4BWjf7IOXqxRaoLPJgK5Dh36j0Mo6EJjBEo9on9AifiQeG8BSLbSA7wbou7HHvYcsSUhZ9aQ9YYFN5CJbVRnJ6pLDxYzFLVM8dDkhykA6PSDDe91UQ39X7fV4i+gZ7ceA6tW/HviCVNumwAh4f3k/ljxvmAQBkSs7TpYKheLQnusVJIIMErqxr1TI5QqVvg0gZAjfNzBwH3Lfy0DJeod31ezBO9qXsfOPexqqnQlagGa8y1MJFqviB85bW1o+QiHNTHEENrn3tnZ1tb6RsmMBkyJUcznJ5PIyyRX8OtF+jEsGG/S/fPyIOdOtKZuf2+NhonAPBLqTI6qmKQTDLPhrmbjXjnPmuW60/wtqryt07/tp3oA8z8MdCHHXjBcC7mOd6Bfk7r3udC94aDf6/9T+AzWzIkAbVeu4AAAAAElFTkSuQmCC" />
+ </header>
+ <nav id="cssmenu">
+ <ul>
+ {MENU}
+ </ul>
+ </nav>
+ <div id="maincontent">
+ {CONTENT}
+ </div>
+ <footer><p>MCServer is using {MEM}MB of memory, with {NUMCHUNKS} chunks loaded.</p><p>Web Design by Tiger</p></footer>
+ </div>
+</head>
+</html>
diff --git a/MCServer/webadmin/template.lua b/MCServer/webadmin/template.lua
new file mode 100644
index 000000000..f508ad5aa
--- /dev/null
+++ b/MCServer/webadmin/template.lua
@@ -0,0 +1,453 @@
+-- Use a table for fast concatenation of strings
+local SiteContent = {}
+function Output(String)
+ table.insert(SiteContent, String)
+end
+
+function GetTableSize(Table)
+ local Size = 0
+ for key,value in pairs(Table) do
+ Size = Size + 1
+ end
+ return Size
+end
+
+function GetDefaultPage()
+ local PM = cRoot:Get():GetPluginManager()
+
+ local SubTitle = "Current Game"
+ local Content = ""
+
+ Content = Content .. "<h4>Server Name:</h4>"
+ Content = Content .. "<p>" .. cRoot:Get():GetServer():GetServerID() .. "</p>"
+
+ Content = Content .. "<h4>Plugins:</h4><ul>"
+ local AllPlugins = PM:GetAllPlugins()
+ for key,value in pairs(AllPlugins) do
+ if( value ~= nil and value ~= false ) then
+ Content = Content .. "<li>" .. key .. " V." .. value:GetVersion() .. "</li>"
+ end
+ end
+
+ Content = Content .. "</ul>"
+ Content = Content .. "<h4>Players:</h4><ul>"
+
+ local AddPlayerToTable = function( Player )
+ Content = Content .. "<li>" .. Player:GetName() .. "</li>"
+ end
+ cRoot:Get():ForEachPlayer( AddPlayerToTable )
+
+ Content = Content .. "</ul><br>";
+
+ return Content, SubTitle
+end
+
+function ShowPage(WebAdmin, TemplateRequest)
+ SiteContent = {}
+ local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path)
+ local Title = "MCServer"
+ local MemoryUsage = WebAdmin:GetMemoryUsage()
+ local NumChunks = cRoot:Get():GetTotalChunkCount()
+ local PluginPage = WebAdmin:GetPage(TemplateRequest.Request)
+ local PageContent = PluginPage.Content
+ local SubTitle = PluginPage.PluginName
+ if (PluginPage.TabName ~= "") then
+ SubTitle = PluginPage.PluginName .. " - " .. PluginPage.TabName
+ end
+ if (PageContent == "") then
+ PageContent, SubTitle = GetDefaultPage()
+ end
+
+ Output([[
+<!DOCTYPE html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<link rel="icon" href="data:application/octet-stream;base64,AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEBAQQAAAAAAgIDBRghJ5o5TlumCg0QCQAAAAABAgIEAAEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAgAAAAMAAAAACQwPMxsnL88jMz3/S2d6/0xoetcaIig6AAAAAAEBAQMBAQEDAAAAAAAAAAAAAAAAAQEBAwAAAAAEAwMEFhwhgRomMPwfLTj/IC86/DJHWPxKaH3/TGN0/jk+QYgEBgcFAAAAAAEBAgMAAAAAAAAAAgAAAAAKDRAuHSMpzB8rNP8dKTP8FiIp/QkXGv8sSEr/QV1u/UhnefxWdIb/P1dm0BIYHDEAAAAAAAEBAgAAAAARGB1oIC44/R0rNf8PGiL7DxUa/gwdHv8JKSP/HUdC/x9HQf81W17+Qllv+0lkef9ObYH+Ii42bAAAAAAAAAAAFyIqyBopMf8THSX6BRkY/wIbGP8HHhv/FTs1/yJhVP8lZ1b/H05I/xcuNf8jPET6UWp+/0xqfdAAAAAAAQECBxEcI9oOHh//BRgV/QwsJv8NKyb/EDEr/xU3Mv8zeW7/MHpr/ydqXP8oalz/HVtO/i9KUf9AW2zgBwkLDQEEBBgKGhfuCCMd/w4uKf4RNC7/FTcy/w8yLv8PMi7/LXFn/y55av86gW//OoV7/y11av4YTkj/GkFB8gUICh4BCActCSUf+xAxKv8TNjD/EzYx/w8xLP8PMCr/Fjgy/zp+c/8yfXP/OoN5/zN9cf86hHb/NHlt/y1xZP4LGhc0BhEORQ8zLP8SNC7+EDIt/xEzLf8PMCv/DTAs/w4xKv8vdWT/PYh4/y93bf8sdWj/N4R3/zWBdv43hHn/EysoTQgXFWEQMy//DzEs/Q8xK/8SNC3/FjUv/xEuK/8WPjf/OIBw/0OEdP83e27/N31w/zN8bP8vdWj8Mn5z/xg3MmgLHRp8FDkz/xExLPwNKyT/EjIs/xpEPP8kX1T/OY2C/0KVhv8zgG//NH9z/zuBdf8xeGX/PIF1/DSAdf8cRDyEDCMenBEvJ/8VODT4IVZM/C11af06inv/QZaG/z2Rgf84iXz/O5F+/z2Nff85iX3+OYJ2/DuBdPg5g3X/IVBIohIzLaUydGb/RJiJ/TyYiv88k4P/O4t6/j+Rg/w+j3/9PYt5/TyOgfwuhHf+Nox+/zyViP9Aloj9Q5WC/yxiVa0ECgkHEyciLh1BOWwsZV2sN39y4juNfv5Cmon/O5OF/z2Shf86kYT/NoyA/ziGeeUqZlywHEI8chAjHzQDBwUKAAAAAAAAAAAAAAAAAAAAAAQIBwsSKCQ9JU9GgDN2a8owdGjLH0xFghMpJUAFDAsNAAAAAAAAAAAAAAAAAAAAAP5/AAD8PwAA8A8AAOAHAADAAwAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAAAAAAAAAAAAAAA4AcAAPw/AAAoAAAAIAAAAEAAAAABACAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEBBAAAAAEAAAAAGB4leTRGUpAICQsDAAAAAAECAgQAAAEBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAgABAQQAAAAADA4RHRsjK7UaJi7/U3SH/1Z1isgbJCosAAAAAAEBAgMBAQECAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQMAAAABAAAAABgeJGEkMz3wHSw1/yExOvxLaHn8TWuA/2SJovkzRVB1AAAAAAAAAAACAgIEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQIBAQEEAAAAAAoLDhkcJS2xHy03/xkmL/0fLjb8IC85/0FabP9IZHX8O1Jj/GCFnP9KZHTBEhccIwAAAAABAQIEAQEBAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQEDAAAAAgAAAAAXHSJZICw27BQeJv8aJzD7JTZC/iQ1P/8nOUX/JzpJ/0hjdf9FX3H+V3iO+01tgv9Wanj0R0dHZwAAAAAAAAABAQICAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEBAQEBBAAAAAAMDAwUJCouqSAwOv8XIir9Exwj/CM0P/8eLDf/IzM+/xclLv8oPlD/NUla/0Vhc/9EXnH/OU5f/DxPX/xudHn/Ulxjtg8WGxsAAAAAAQICBAEBAQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEBAwAAAAIAAAAAFhofUTI0NugdJSv/Gicw+yQ0P/0YJC7/GCQt/xEbJP8QGSD/CxUb/yhMTf9AWmz/PVds/z5Xaf8+VWf/Q15x/jtTZPtJX3D/VneK7iUxOlsAAAAAAAAAAgECAgMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAACAkLER4oMKIdKTL/GCEn/RQfJ/weLDb/Gigy/x0lLP8aJS7/DiAj/wgOE/8HFRn/Gks8/0BNS/8xUFv/VXyS/0ZseP9Ye5D/XH+U/0Zhc/xFX3L9SGN2/ztPXqkPFBYUAAAAAAEBAQIAAAAAAAAAAAAAAAAAAAABAAAAABUbIUoqOkbjHy43/xIcJPseLTb9Gicv/xQgKP8NEhn/ISIk/xYkKv8MKyP/Bh0b/wYiHf8RQzz/JTE2/yNYT/8tTVX/KVRM/1N5if9dgJj/RmBy/0pmev1KZXn7Qltt/1NxhOcgKjJOAAAAAAAAAAEAAAAAAQEBBAAAAAATGiBhIjE8/xwrNPwXIyv8His1/yMzPf8OFh7/BgwS/wQSEv8IDxT/CxQa/wUfG/8HJyL/ES0m/ylrYv8YPD//E0I2/xg8Mv8UQTP/LklT/zJHWf80Slv/Ql1x/1yAmP8/VWf8Smd7/E5rgP8fKTFuAAAAAAEBAQQAAQEEAAAAABYhJ5QaJy//FSAo+RglLv8iMz3/Ex8o/wUOEv8GIR3/BB8a/wQYFv8EEBL/Ax4a/wsqJv8VODL/JGhY/xhXTP8kWUv/KWNT/ypuWf8aMDX/HCU0/yEwPv8iMD7/M0dY/0FdcP9egpr6W36T/zlQXacAAAAAAQEBBAAAAAMAAAAAFR8mrR0rNP8YJCz8Fykt/xYiKv8FCRD/BRkY/wglIf8FHhr/AxsY/wYhHf8PKyb/FTo2/xU7N/8ralj/IGRY/ydpV/8wdWr/JW1g/xw9P/8dSkn/FjQ0/xQ/O/8aMDf/TVhi/0ljdvxYe5D/R2NyvgAAAAAAAAACAAAAAQAAAAANFRzGEh0m/x0uN/wKHRn/Bg4T/wMUEv8JJyH/Dy0p/wYjH/8IJB//Gjsz/xQyK/8TNDD/DjMu/z96a/8veG3/J3Fg/zd8b/8oa1//FExD/yhjVv8aWEb/ImRa/xhXTv86SUz/QlNl/Uhmff9bfpPWAAAAAAAAAAAAAAAAAQIDAxEaI9wSIyj/CBYW/QYWE/8HGRr/CSsi/wosI/8RMSz/ES4o/wwtKP8QMy7/Cisn/w8uKv8YNzD/Pod9/zB/df82e3L/Mnho/yduWP8ueW3/N3Zq/ypyZf8nbV3/IFxT/xE4Of8zT1z+Mldc/ztRY+kHCwwNAAAAAAAAAAABBQUSER0d7wwcGP8IIxv+CSId/wsgHP8QMiz/EjYx/w4vKv8XODP/EjIu/w4yLv8KLir/Cywn/w8wKv8qcWj/MH50/ylzYf8ve2j/JnFb/zh+bf8+hHr/LXhu/zJ+bf8wcGf/E09G/x4/Qv4jVEz/IS8++QcKDR0AAAAAAAAAAAEIBiUGFBP+BxgU/wsrJP4HJSD/ES8q/w4xLv8OMi7/FjUu/xM3Mv8XOzf/FDg0/xEzL/8TODT/Cy4q/yRlW/83e3H/KG9g/zSEeP9AhXj/P35u/0GMgf8wf3b/NoR8/yxzaP8hXVT/ED88/xdQSP4gVFL/Bg4QMgAAAAAAAAAAAwsKOgUdGv8NJyH9Dy8p/w8xKf8WOjb/DDEs/xI2MP8UNzD/DTAo/xM2MP8MLib/FTUx/xU1MP8OMy7/PXdo/0KLgP8udW3/JnJo/zyFef9Ai4H/PYd+/y54a/8mcmn/O3xv/zR1aP8obmD/I2JY/CFmWf8LIBpJAAAAAAAAAAAGFBFSCSsk/wssJPwMLib/EjEo/xU3Mv8OMij/HEA4/w4zMP8OMSz/EDAq/wktJ/8NMCv/FDEp/xU3Mf89gnj/PYyA/zyDef8udWv/N4Z8/zB8cv8zd27/LnZj/0GOev9FjYD/OoR7/zuEdv8+gHD7O4Z6/xo2L2IAAAAAAAAAAAcYE20MMCn/EDEr+w4vJv8WODP/EzMv/w8yLP8TODT/DS8q/xAwKv8IKyf/DC8s/w8wK/8MLST/FTQt/zaBdv8pd2P/P4t2/zaEef85e27/Nnpt/y11bP8xeW//QJCD/zyMgf8we2n/N4N6/yduZPtBkYj/Ik5JfAAAAAAAAAAADyMfiBA0Lv8PMiz7GDk1/xAxLf8RMS3/DzIt/xAyLP8PMCf/FzQu/w4vKf8OMC3/EzQv/wgsJ/8JLCf/ImlT/zV3Zf9IkHv/OYh7/yNuaP80e2//KXJp/yNtXf82gnb/MH10/yp3av9AjoX/MH10+zB7cP8eT0mWAAAAAAAAAAARLCiiDjMu/wotJvsTODT/DC8r/wkqJf8PMCj/EDIr/w0yKv8ZOzb/FjUv/xQ2M/8TOjb/DS8r/xk8NP8ocGL/QIV0/0WBcf9Cf3D/Mnhu/zd6bv84e27/KXRk/zh7bP8tdmX/M3lt/zR6bP8veWj8MHxx/y1dUq8AAAAAAAAAAAsnJLsRMi7/DC4q/BU0Lv8OMSz/DS4p/xg4Mv8SNi//ETAq/xs/N/8aPTX/ETEs/xQvKv8YMyv/H05F/yZya/9Km4j/SI+A/zp6a/9Cf23/RYh7/zuGe/86e2v/RYuA/y57af86e2r/J29l/ypyZ/w+jIL/KWVbxwAAAAAAAAAADysn0Rc6Nf8PMS39DS8q/xUzLf8QMiz/DS8l/xEyKv8UNC//EzEs/xAtI/8QMyv/H1FN/zeBeP9CnI//Q5SF/0aRff87h3f/LXVl/yJsWv8xe3T/Q4l+/zh5Zf8reWT/Lnlm/zqHef84fHD/Im9p/Th/dP8pa2HcAAYGBwQIBw4TMy3kFjsy/xI1L/4PMSz/GTo1/xIyKv8KKyL/EzAq/xA0MP8ZQjr/JF1T/zp/cP8xiHb/LIh6/0egkf9Gn5D/NYZ2/ziGcv8whXr/NYuA/zN9dP9Ahnz/Mn91/yNrWP85emb/QYJ3/0SLe/8vd2/+NXpq/zF2ZuwHEREXBxAPIRI3MPQVNSv/GTcw/hY0Lv8UNDH/Cysn/xQ2MP8oX1f/KnFn/0ONf/8yinz/MIh9/z6JeP85in//No+H/yyBdv82iX7/QZOE/yt/aP87jnn/R417/zaFef89kIP/M3dq/0OHev84gXf/R5KA/0KJfv4yf3P/NXhn+hEeGysDDww3EjQr/hcyLP8JJx//Ciwp/yJQSv8ybmD/MYJv/zmUiP8ug3X/QIp8/zyOfP9ElYX/T5yN/0KWhf88i3f/PYh4/ziHfP9El4X/P5aC/zaMf/9Ek4b/M4R2/z2ThP85iX7/Qop9/y+BeP83emz/NHlm/zeCef4mcmn/CyAcQgQTEVQVOTH/GT85/CRYTfstdWr8QJWL/j+Thv8thHT/N4l7/zaIdP85hnL/PI58/zmOfv8+lIb/RZF+/0COe/9AkH7/Qot2/0CTgv8+mI3/MIh2/zOFcv88joL/OY+F/zeFev83in//N4x+/jyFcPw3f237OHpv+0iQf/8fRj1fCh4cTyRkWOxFnIj+TqSR/0idiP9Qo5P/M4N5/Sp9cPs+k4X8RJeL/jqLev8/j37/RpaH/z2SiP84hnn/PZKI/zCHdv86jXz/P46E/zSIfv8xiHv/J31x/y6Eef4rgG/8OYx9+zyPhv05jIH/SZ6Q/1Wyof8/lH//Oohx9yJHPV4AAAAABhAOChw2LzkmTEV3MGxcuDuHdu1Akob/QpuP/0uZiP8yh3r/MIB0/DuKffs4in38PpaD/j6ZjP89kYT/PpCC/0CNgP82g3b+MIV6/S6EevspfHP8Po5//0ihkP8+mon/N4+B/zKCdPM1c2jDH01FhBoyK0YEDQoRAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAQsKDxUuKkIsXliDMnRpwjeEcfRCloH/RJuK/zyRgP9AlIP/PYx+/TKEdvw8kIH8Q5eM/TSLf/8+lYX/SJyM/zuYjf8+lIj3O4F1ySVZU4wWMy1LBhAMFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQEBAgIDAQICBAEBAQIAAAAAAAAAAAAAAAAAAAAACxQRFhk2MkomWFGLOXhryEiZhvRElYf/N46G/zCGef9Dk4P/O5CF9SVpYMsrWlCQFzg0UAwZFxoAAAAAAAAAAAAAAAAAAAAAAAAAAgECAgQBAgIDAAEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQEBAgIDAQMCBAEBAQIAAAAAAAAAAAAAAAAAAAAACBcTHx4+OVw5dWmnK2peqBo5Ml0MHBkiAAICAQAAAAAAAAAAAAAAAAABAQEBAgIEAQICAwABAQIAAAAAAAAAAAAAAAAAAAAAAAAAAP//f////D////gf///gB///wAP//wAA//4AAH/4AAAf8AAAD+AAAAfAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAOAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAHwAAAH/gAAf//gB////n//">
+<title>]] .. Title .. [[</title>
+
+<style type="text/css" media="screen">
+
+ /* reset CSS */
+
+ html, body, div, span, applet, object, iframe,
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+ a, abbr, acronym, address, big, cite, code,
+ del, dfn, em, font, img, ins, kbd, q, s, samp,
+ small, strike, strong, sub, sup, tt, var,
+ b, u, i, center,
+ dl, dt, dd, ol, ul, li,
+ fieldset, form, label, legend,
+ table, caption, tbody, tfoot, thead, tr, th, td {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ outline: 0;
+ font-size: 100%;
+ vertical-align: baseline;
+ background: transparent;
+ }
+ body {
+ line-height: 1;
+ }
+ ol, ul {
+ list-style: none;
+ }
+ blockquote, q {
+ quotes: none;
+ }
+
+ /* remember to define focus styles! */
+ :focus {
+ outline: 0;
+ }
+
+ /* remove textarea resize at Safari */
+ textarea {
+ resize: none;
+ }
+
+ /* remember to highlight inserts somehow! */
+ ins {
+ text-decoration: none;
+ }
+ del {
+ text-decoration: line-through;
+ }
+
+ /* tables still need 'cellspacing="0"' in the markup */
+ table {
+ border-collapse: collapse;
+ border-spacing: 0;
+ }
+
+
+ /*
+ Origional from http://www.perspectived.com/
+ Modified by Ben Phelps
+ Made for FakeTruth - MCServer
+ */
+
+ /* Basic ---------------------------------------- */
+
+ .clear { clear: both; }
+
+ body {
+ background: white;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 12px;
+ color: #646464;
+ text-align: center;
+ }
+
+ #wrapper {
+ text-align: left;
+ width: 930px;
+ margin: 0 auto;
+ }
+
+ /* Logo ---------------------------------------- */
+
+ h1 {
+ margin: 15px 0 10px 5px;
+ width: 180px;
+ height: 36px;
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAAkCAMAAAAXdeBDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAuVQTFRFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs7OzAAAAAAAAoqKiAAAAvLy8AAAAlZWVtbW1j4+Pra2tiYmJp6enAAAAhISEoaGhAAAAgICAm5ube3t7lZWVd3d3kZGRc3NzjIyMbGxsg4ODgICAeHh43NzcdXV1cnJyy8vLWVlZbGxswcHB09PTvLy8uLi4tLS0sLCwvLy8uLi4tbW1oaGhnp6era2tm5ubqqqq39/f29vblZWV09PT4ODgz8/P3NzckZGRxcXF0tLSwsLCzs7Oy8vLyMjIt7e3vLy85ubm7u7u3d3d5+fn2tra5OTk19fX1dXV3t7e29vb2dnZ1tbW0dHRv7+/8PDw7u7u6+vr8fHx5ubm4+Pj7Ozs4eHh3t7e5+fn5OTk2tra4uLi39/f1dXV3d3d29vb2dnZ19fX1dXV0tLS9fX18/Pzzs7O7u7u8/PzycnJ6urq6Ojo7+/v5ubm7Ozs4+Pj4eHh39/f5ubm5OTk4uLi4ODg2NjY3Nzc29vb19fX8vLy9/f39fX17e3t8/Pz6+vr8fHx7+/v5+fn7e3t5eXl6+vr6enp6Ojo4ODg39/f9PT0+Pj48fHx9vb27+/v9PT07e3t8/Pz7Ozs8fHx7+/v6Ojo7u7u5+fn7Ozs5eXl6urq5OTk6enp5+fn5ubm5OTk+Pj49/f39fX19PT0+fn58vLy8fHx9fX19PT08vLy8fHx6urq+Pj49vb29fX19PT08vLy8PDw+/v7+vr6+Pj49/f39vb29fX18/Pz/f39+/v7+vr6+fn5+Pj49/f3/f39/Pz8+vr6/v7+/f39a5KrdZmxf6G2iai8kq/BnLbHpr7NsMXSuszYxNPdxmZTynBeznpqztvj0YV11Y+B2OLp2ZmM3aOY4a2j4enu5Liv6MK66/D07MzG8NbR9ODd9fj59+vo+/X0ucu1kQAAANl0Uk5TAAECAwQFBgcICQoLDA0ODxAREhMUFBUWFhcXGBgYGRkaGhsbGxwcHB0dHh4fHyEhIiQkJSYnKCgpKSorLC0uLzAxMjIzMzc4Ojo6Ozs8Pj4/P0BBQ0VISUtLTExNTk5PUFFTV1dYWVpbXFxdXl5fYGBhYmJjZGVmZ2doaWprbGxtbW5ub3BxcXJzdHV2d3l6e3x9fX5+f4CAgYGCg4SIi4yNjY6Oj4+QkJGSkpOTlJSVlZaXmJqbnJ2dnp+foKGip6+wsbKztb6/wMHCw8TOz9DR0tPf4OHv8LXp8fEAAAi/SURBVHja3Zh/dBRXFcdhZ+a9eTPzZnaXmJam0FYUEQWLrVVbqdZaf6EWQW2txN/SWiAmxFqtIlWr9bdWqkbwF6WQYIq/+WFpwSZqTahhg6RhNptkl9nsbjeb2eyv+dv73g6wlcyewXMazvGek3Dm5jLv8+689733vTn/q81ldr5zzsWxuVWr55sbCAiiBCYKAeZ1nYIgigJ4Zh2Zj+0OXesTgQ987pOEZUVVVYXISIJQPi3mJETG0kXADggIL5CRWDMy57kCaDgdBMgK1de0gi2jGsESZJt5iXpjS8utGkHiLFMDIHrNgfJBFYs1i0Ei73iifIAggIEHrNDWnuGpFFg50vEKVYbcArNye0+lUCj13aUgYbahRbInbqbu1zAf2XXpR8bN1CZZYItA1jb0pcaiJrdYorxzIRYFYN7qZC2wTOVXMuR+dqGR2hU3Y4NLFSlwJtGIfmbKNFOt4BIkQndOj5rR8dMpsETMjCae+gASJbLKSSftUsWeSJbWz3aqgXBvPGomOnWWajfRoWOjAN2uIWBedOh0NJoYPvJgW1tb+47I1Jg5Vl6AsPrkZLLU+f5bdjjpzNOzDo1pdzw2Fi2vVlBVFgRMf5oyYXl8lmIk00MJc7S8e6mhU02jerC5JzFavgyRlztWbl9j2NC3lvJbpMDFgJ6Ojh/VZb4XA5KycmhkNAXQOpG1ncDfv9HQQNsQZsK3cNvTn5SQ0lKwCveEdYWQd25BrugxUQHjAl/fPKL9Q2t747F/x82pjSpXC0Gme+EJoNt1Vb2jHI1FVlMmawFWYiQgB6mWCIcOaVgCA2ZX3BEGQyI4vAsXWN1of9Bd8diJZ0dG+3QiwuSRsq4cHf8rgzao3jMWnX5Al88oMdNnAQRPlOlwMrcvrBMYk2WrWmyIqlGqqYRJPE+kwK2a0Jr8wo9nNPzRL/QvTpupH4HsAQ4DLX+ZQQeNN02b8W6DSLWVh5mA+EbcHaKkWhF5sdGWdfREIj0dyzSCBDAJY1nGCKo/r/9uguEB/uQZLQZ8Qe+JxwZffGx0ZGixgiSsbXzOTDz2RQYdDm1PmFNrNXTee+ZKMpO8fP+DhiYjAGLF5oYux86m01nb6bqBACr+4Id1/cZHH7pUxne+HkE63fp7522A5xn9IiHgF7ppM6DuokRWjD7Av+7zDHrevEgsFgkq0vndnVtcMvmhjkUKJFvEyqf7ckkrmU7Dr1zfXQTLXyoWv95ZydnblB8UKut5BYL/Rw4Uih9S6Qav6B9CnD/oSGPj0fFouVmn+sOwUH7W9DmmHg0Nw9H4Xp0IM1Z/KOOFjDVhR7ZqMpbVO5yMlS2eGhw8VYTJOC9RtOPp9Ak7adk/picnMv/UZL5jyO0ly+4INntGP+QfOhxeXY6O9c4L31QeGettaLyHQTeuKJsALQdm3PyI0Na+UtZKl3ZSjS7uzVr23z7e0Nj00t8Wk2nnZaoeSadtK1s6uJD+xLYKLSBOTJp6sklnxXLP6AOXin6XRyRoGLsS5nObm34HctccCrdz6GsYNJ0JmquFrOjNvcV0srQrFN5tW/bh5aHQvPm/KQHFVkULDsK3n/x7s0bURZDqPtAg+DxrSlau+5JOz2gVCX434nGod4uhpDzzielo/HFdD7bXzbSbbBHJmvEAbMjK5qZTyUz/8qCuhzsZxf0qUUODaSt94n06rB3aYVulZhVLMgXRcd5SL1oM+IamCtEeTpmn/wFyt1JV9ba6a9qlZtgKUE9kjn0vb+W/FdapsYtTaBgrDCP/3bAiQX4XD01ke6B8qisdkPf5364TDcy+oQkmRu/YyGmmITKhbXXVwy10DFtSgjsgjX/KWc41IeMshQj+wTT4dBxg3cx2iGHbvCuXdN58yb560XP8Q8sSUpunzOho/xICX73trE5P33yeTgOre0KDNYLp1Y5l/xkwrm0In6UICMSArTUYVmHGMLNlTjLbGw69chj+aWjorhftHxoECWrh43HoouEluAodNNZMzVQRWQty2wJJ5NRIexU0fAz6tU2dVQomyVUM+ExCtXGspvjnLOGh0N460RcELQQkcn15/AnAFxCHbvPqPUSE9xedKyBDHPpqBm1blXc/5lKwfkRSOIbBNwQ8vQEW8x+uexaWtqEb2z2jLxSaadjb/vJWLAUCLnRtlye4bQ7CYPK7Slb+ayrMhfUqt1Ss/PeLlv17RvFVqsisEcQqx2C7+FyqfwmJXqcp2ke9oi8YGl4tSkgSAM6Fph799KcU7SSkLEgJxoSGYYVW3v5MZqIAFN8I65qqvu6RLUQLcgx4r9ukO0n7X5lsr04w0fu9on1CI5VDY4F/fN5DAnRriq3u2pMLrTm5XKVBjcvvDoPTCO8uJSePzr+3YFlp5ztNDUEjuO6pXP4rtAaDp/rI5ETBKn5MRbDl2zyifUMrDFrFgdoeTuHQyrkz4hCcEcF29PMz4lXKlVAk8r3fXHtzey8rw+8JzTtsW5POH++9dkV7twM1ehtlH/w4K6duqteWLCgphiyyJeUd7cMAkDwK0AQ9D5psAuhN5NxpfMQ9jY/y07gsK6ucSSubL1UKWYttJ5UuBY5kruA4BWjf7IOXqxRaoLPJgK5Dh36j0Mo6EJjBEo9on9AifiQeG8BSLbSA7wbou7HHvYcsSUhZ9aQ9YYFN5CJbVRnJ6pLDxYzFLVM8dDkhykA6PSDDe91UQ39X7fV4i+gZ7ceA6tW/HviCVNumwAh4f3k/ljxvmAQBkSs7TpYKheLQnusVJIIMErqxr1TI5QqVvg0gZAjfNzBwH3Lfy0DJeod31ezBO9qXsfOPexqqnQlagGa8y1MJFqviB85bW1o+QiHNTHEENrn3tnZ1tb6RsmMBkyJUcznJ5PIyyRX8OtF+jEsGG/S/fPyIOdOtKZuf2+NhonAPBLqTI6qmKQTDLPhrmbjXjnPmuW60/wtqryt07/tp3oA8z8MdCHHXjBcC7mOd6Bfk7r3udC94aDf6/9T+AzWzIkAbVeu4AAAAAElFTkSuQmCC) no-repeat left top;
+ }
+
+ h1 a {
+ display: block;
+ width: 225px;
+ height: 28px;
+ }
+
+ h1 span { display: none; }
+
+ a {
+ color: #646464;
+ }
+
+ /* Container ---------------------------------------- */
+
+ #containerHolder {
+ background: #eee;
+ padding: 5px;
+ }
+
+
+ #container {
+ background: #fff url(data:image/gif;base64,R0lGODlhtAABAIAAAN3d3f///yH5BAAAAAAALAAAAAC0AAEAAAIMjI+py+0Po5y0WgYKADs%3D) repeat-y left top;
+ border: 1px solid #ddd;
+ width: 918px;
+
+ }
+
+ #connectHolder {
+ background: #eee;
+ padding: 5px;
+ margin-bottom:8px;
+ }
+
+
+ #connect {
+ border: 1px solid #ddd;
+ background-color: #fff;
+ padding:5px;
+ width: 908px;
+ }
+
+ .pics {
+ height: 375px;
+ width: 600px;
+ }
+
+ .pics img {
+ padding: 5px;
+ border: 1px solid #ddd;
+ background-color: #eee;
+ width: 600px;
+ height: 375px;
+ margin-left: 15px;
+ }
+
+ /* Login -------------------------------------- */
+
+ #loginLogo {
+ margin: 0 auto;
+ margin-top:100px;
+ width: 180px;
+ height: 36px;
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAAkCAMAAAAXdeBDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAuVQTFRFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs7OzAAAAAAAAoqKiAAAAvLy8AAAAlZWVtbW1j4+Pra2tiYmJp6enAAAAhISEoaGhAAAAgICAm5ube3t7lZWVd3d3kZGRc3NzjIyMbGxsg4ODgICAeHh43NzcdXV1cnJyy8vLWVlZbGxswcHB09PTvLy8uLi4tLS0sLCwvLy8uLi4tbW1oaGhnp6era2tm5ubqqqq39/f29vblZWV09PT4ODgz8/P3NzckZGRxcXF0tLSwsLCzs7Oy8vLyMjIt7e3vLy85ubm7u7u3d3d5+fn2tra5OTk19fX1dXV3t7e29vb2dnZ1tbW0dHRv7+/8PDw7u7u6+vr8fHx5ubm4+Pj7Ozs4eHh3t7e5+fn5OTk2tra4uLi39/f1dXV3d3d29vb2dnZ19fX1dXV0tLS9fX18/Pzzs7O7u7u8/PzycnJ6urq6Ojo7+/v5ubm7Ozs4+Pj4eHh39/f5ubm5OTk4uLi4ODg2NjY3Nzc29vb19fX8vLy9/f39fX17e3t8/Pz6+vr8fHx7+/v5+fn7e3t5eXl6+vr6enp6Ojo4ODg39/f9PT0+Pj48fHx9vb27+/v9PT07e3t8/Pz7Ozs8fHx7+/v6Ojo7u7u5+fn7Ozs5eXl6urq5OTk6enp5+fn5ubm5OTk+Pj49/f39fX19PT0+fn58vLy8fHx9fX19PT08vLy8fHx6urq+Pj49vb29fX19PT08vLy8PDw+/v7+vr6+Pj49/f39vb29fX18/Pz/f39+/v7+vr6+fn5+Pj49/f3/f39/Pz8+vr6/v7+/f39a5KrdZmxf6G2iai8kq/BnLbHpr7NsMXSuszYxNPdxmZTynBeznpqztvj0YV11Y+B2OLp2ZmM3aOY4a2j4enu5Liv6MK66/D07MzG8NbR9ODd9fj59+vo+/X0ucu1kQAAANl0Uk5TAAECAwQFBgcICQoLDA0ODxAREhMUFBUWFhcXGBgYGRkaGhsbGxwcHB0dHh4fHyEhIiQkJSYnKCgpKSorLC0uLzAxMjIzMzc4Ojo6Ozs8Pj4/P0BBQ0VISUtLTExNTk5PUFFTV1dYWVpbXFxdXl5fYGBhYmJjZGVmZ2doaWprbGxtbW5ub3BxcXJzdHV2d3l6e3x9fX5+f4CAgYGCg4SIi4yNjY6Oj4+QkJGSkpOTlJSVlZaXmJqbnJ2dnp+foKGip6+wsbKztb6/wMHCw8TOz9DR0tPf4OHv8LXp8fEAAAi/SURBVHja3Zh/dBRXFcdhZ+a9eTPzZnaXmJam0FYUEQWLrVVbqdZaf6EWQW2txN/SWiAmxFqtIlWr9bdWqkbwF6WQYIq/+WFpwSZqTahhg6RhNptkl9nsbjeb2eyv+dv73g6wlcyewXMazvGek3Dm5jLv8+689733vTn/q81ldr5zzsWxuVWr55sbCAiiBCYKAeZ1nYIgigJ4Zh2Zj+0OXesTgQ987pOEZUVVVYXISIJQPi3mJETG0kXADggIL5CRWDMy57kCaDgdBMgK1de0gi2jGsESZJt5iXpjS8utGkHiLFMDIHrNgfJBFYs1i0Ei73iifIAggIEHrNDWnuGpFFg50vEKVYbcArNye0+lUCj13aUgYbahRbInbqbu1zAf2XXpR8bN1CZZYItA1jb0pcaiJrdYorxzIRYFYN7qZC2wTOVXMuR+dqGR2hU3Y4NLFSlwJtGIfmbKNFOt4BIkQndOj5rR8dMpsETMjCae+gASJbLKSSftUsWeSJbWz3aqgXBvPGomOnWWajfRoWOjAN2uIWBedOh0NJoYPvJgW1tb+47I1Jg5Vl6AsPrkZLLU+f5bdjjpzNOzDo1pdzw2Fi2vVlBVFgRMf5oyYXl8lmIk00MJc7S8e6mhU02jerC5JzFavgyRlztWbl9j2NC3lvJbpMDFgJ6Ojh/VZb4XA5KycmhkNAXQOpG1ncDfv9HQQNsQZsK3cNvTn5SQ0lKwCveEdYWQd25BrugxUQHjAl/fPKL9Q2t747F/x82pjSpXC0Gme+EJoNt1Vb2jHI1FVlMmawFWYiQgB6mWCIcOaVgCA2ZX3BEGQyI4vAsXWN1of9Bd8diJZ0dG+3QiwuSRsq4cHf8rgzao3jMWnX5Al88oMdNnAQRPlOlwMrcvrBMYk2WrWmyIqlGqqYRJPE+kwK2a0Jr8wo9nNPzRL/QvTpupH4HsAQ4DLX+ZQQeNN02b8W6DSLWVh5mA+EbcHaKkWhF5sdGWdfREIj0dyzSCBDAJY1nGCKo/r/9uguEB/uQZLQZ8Qe+JxwZffGx0ZGixgiSsbXzOTDz2RQYdDm1PmFNrNXTee+ZKMpO8fP+DhiYjAGLF5oYux86m01nb6bqBACr+4Id1/cZHH7pUxne+HkE63fp7522A5xn9IiHgF7ppM6DuokRWjD7Av+7zDHrevEgsFgkq0vndnVtcMvmhjkUKJFvEyqf7ckkrmU7Dr1zfXQTLXyoWv95ZydnblB8UKut5BYL/Rw4Uih9S6Qav6B9CnD/oSGPj0fFouVmn+sOwUH7W9DmmHg0Nw9H4Xp0IM1Z/KOOFjDVhR7ZqMpbVO5yMlS2eGhw8VYTJOC9RtOPp9Ak7adk/picnMv/UZL5jyO0ly+4INntGP+QfOhxeXY6O9c4L31QeGettaLyHQTeuKJsALQdm3PyI0Na+UtZKl3ZSjS7uzVr23z7e0Nj00t8Wk2nnZaoeSadtK1s6uJD+xLYKLSBOTJp6sklnxXLP6AOXin6XRyRoGLsS5nObm34HctccCrdz6GsYNJ0JmquFrOjNvcV0srQrFN5tW/bh5aHQvPm/KQHFVkULDsK3n/x7s0bURZDqPtAg+DxrSlau+5JOz2gVCX434nGod4uhpDzzielo/HFdD7bXzbSbbBHJmvEAbMjK5qZTyUz/8qCuhzsZxf0qUUODaSt94n06rB3aYVulZhVLMgXRcd5SL1oM+IamCtEeTpmn/wFyt1JV9ba6a9qlZtgKUE9kjn0vb+W/FdapsYtTaBgrDCP/3bAiQX4XD01ke6B8qisdkPf5364TDcy+oQkmRu/YyGmmITKhbXXVwy10DFtSgjsgjX/KWc41IeMshQj+wTT4dBxg3cx2iGHbvCuXdN58yb560XP8Q8sSUpunzOho/xICX73trE5P33yeTgOre0KDNYLp1Y5l/xkwrm0In6UICMSArTUYVmHGMLNlTjLbGw69chj+aWjorhftHxoECWrh43HoouEluAodNNZMzVQRWQty2wJJ5NRIexU0fAz6tU2dVQomyVUM+ExCtXGspvjnLOGh0N460RcELQQkcn15/AnAFxCHbvPqPUSE9xedKyBDHPpqBm1blXc/5lKwfkRSOIbBNwQ8vQEW8x+uexaWtqEb2z2jLxSaadjb/vJWLAUCLnRtlye4bQ7CYPK7Slb+ayrMhfUqt1Ss/PeLlv17RvFVqsisEcQqx2C7+FyqfwmJXqcp2ke9oi8YGl4tSkgSAM6Fph799KcU7SSkLEgJxoSGYYVW3v5MZqIAFN8I65qqvu6RLUQLcgx4r9ukO0n7X5lsr04w0fu9on1CI5VDY4F/fN5DAnRriq3u2pMLrTm5XKVBjcvvDoPTCO8uJSePzr+3YFlp5ztNDUEjuO6pXP4rtAaDp/rI5ETBKn5MRbDl2zyifUMrDFrFgdoeTuHQyrkz4hCcEcF29PMz4lXKlVAk8r3fXHtzey8rw+8JzTtsW5POH++9dkV7twM1ehtlH/w4K6duqteWLCgphiyyJeUd7cMAkDwK0AQ9D5psAuhN5NxpfMQ9jY/y07gsK6ucSSubL1UKWYttJ5UuBY5kruA4BWjf7IOXqxRaoLPJgK5Dh36j0Mo6EJjBEo9on9AifiQeG8BSLbSA7wbou7HHvYcsSUhZ9aQ9YYFN5CJbVRnJ6pLDxYzFLVM8dDkhykA6PSDDe91UQ39X7fV4i+gZ7ceA6tW/HviCVNumwAh4f3k/ljxvmAQBkSs7TpYKheLQnusVJIIMErqxr1TI5QqVvg0gZAjfNzBwH3Lfy0DJeod31ezBO9qXsfOPexqqnQlagGa8y1MJFqviB85bW1o+QiHNTHEENrn3tnZ1tb6RsmMBkyJUcznJ5PIyyRX8OtF+jEsGG/S/fPyIOdOtKZuf2+NhonAPBLqTI6qmKQTDLPhrmbjXjnPmuW60/wtqryt07/tp3oA8z8MdCHHXjBcC7mOd6Bfk7r3udC94aDf6/9T+AzWzIkAbVeu4AAAAAElFTkSuQmCC);
+ }
+
+ #loginHolder {
+ background: #eee;
+ padding: 5px;
+ width: 310px;
+ margin: 0 auto;
+ height: 90px;
+ margin-top:20px;
+ }
+
+ #login {
+ padding:10px;
+ width: 288px;
+ height: 68px;
+ border: 1px solid #ddd;
+ background:#fff;
+ text-align: left;
+ }
+
+
+ /* Sidebar ---------------------------------------- */
+
+ #sidebar {
+ width: 179px;
+ float: left;
+ }
+
+ #sidebar .sideNav { width: 179px; }
+
+ #sidebar .sideNav li { border-bottom: 1px solid #ddd; width: 179px; }
+
+ #sidebar .sideNav li a {
+ display: block;
+ color: #646464;
+ background: #f6f6f6;
+ text-decoration: none;
+ height: 29px;
+ line-height: 29px;
+ padding: 0 19px;
+ width: 141px;
+ }
+
+ #sidebar .sideNav li a:hover { background: #fdfcf6; }
+
+ #sidebar .sideNav li a.active, #sidebar .sideNav li a.active:hover {
+ background: #f0f7fa;
+ color: #c66653;
+ }
+
+ /* Breadcrumb ---------------------------------------- */
+
+ h2 {
+ width: 718px;
+ float: right;
+ color: #646464;
+ font-size: 16px;
+ line-height: 16px;
+ font-weight: bold;
+ margin: 20px 0 0 0;
+ padding: 0 0 10px 0;
+ border-bottom: 1px solid #ddd;
+ }
+
+ h2 a {
+ color: #646464;
+ text-decoration: none;
+ }
+
+ h2 a.active { color: #c66653; }
+
+ h2 a:hover { text-decoration: underline; }
+
+ /* Content ---------------------------------------- */
+
+ #main {
+ width: 700px;
+ float: right;
+ padding: 0 19px 0 0;
+ }
+
+ #main p {
+
+ padding: 10px;
+
+ }
+
+ h3 {
+ font-size: 14px;
+ line-height: 14px;
+ font-weight: bold;
+ color: #5494af;
+ padding: 0 0 0 10px;
+ margin: 20px 0 10px;
+ }
+
+ h4 {
+ padding: 0 0 0 10px;
+ margin: 20px 0 10px;
+ }
+
+ #main ul {
+ padding: 0 0 0 10px;
+ list-style-type: circle;
+ list-style-position: inside;
+ }
+
+ #main table {
+ border-top: 1px solid #ddd;
+ width: 700px;
+ }
+
+ #main table tr th {
+ text-align: left;
+ background: #f6f6f6;
+ padding: 0px 20px;
+ height: 20px;
+ line-height: 20px;
+ border-bottom: 1px solid #ddd;
+ }
+
+ #main table tr td {
+ background: #f6f6f6;
+ padding: 0px 20px;
+ height: 29px;
+ line-height: 29px;
+ border-bottom: 1px solid #ddd;
+ }
+
+ #main table tr.odd td {
+ background: #fbfbfb;
+ }
+
+ #main table tr:hover td { background: #fdfcf6; }
+
+ #main table .action {
+ text-align: right;
+ padding: 0 20px 0 10px;
+ }
+
+ #main table tr .action a { margin: 0 0 0 10px; text-decoration: none; color: #9b9b9b; }
+ #main table tr:hover .action .edit { color: #c5a059; }
+ #main table tr:hover .action .delete { color: #a02b2b; }
+ #main table tr:hover .action .view { color: #55a34a; }
+
+ #main table tr:hover .action a:hover { text-decoration: underline; }
+
+ fieldset {
+ border: 1px solid #ddd;
+ padding: 19px;
+ margin: 0 0 20px 0;
+ background: #fbfbfb;
+ }
+
+ form p { margin: 0 0 14px 0; float: left; width: 100%; }
+
+ label {
+ display: block;
+ width: 100%;
+ margin: 0 0 7px 0;
+ line-height: 12px;
+ }
+
+ /* Footer ---------------------------------------- */
+
+ #footer {
+ margin: 10px 0 30px 0;
+ font-size: 11px;
+ line-height: 11px;
+ color: #9B9B9B;
+ padding: 0 0 0 5px;
+ }
+
+ #footer a { color: #9B9B9B; }
+
+ #footer a:hover { text-decoration: none; }
+</style>
+
+</head>
+
+<body>
+ <div id="wrapper">
+ <!-- h1 tag stays for the logo, you can use the a tag for linking the index page -->
+ <h1>
+ <a href="]] .. BaseURL .. [["><span>MCServer</span></a>
+ </h1>
+ <div id="containerHolder">
+ <div id="container">
+ <div id="sidebar">
+ <ul class="sideNav">
+ ]])
+
+ local AllPlugins = WebAdmin:GetPlugins()
+ for key,value in pairs(AllPlugins) do
+ local PluginWebTitle = value:GetWebTitle()
+ local TabNames = value:GetTabNames()
+ if (GetTableSize(TabNames) > 0) then
+ Output("<li>"..PluginWebTitle.."</li>");
+
+ for webname,prettyname in pairs(TabNames) do
+ Output("<li><a href='" .. BaseURL .. PluginWebTitle .. "/" .. webname .. "'>" .. prettyname .. "</a></li>")
+ end
+ end
+ end
+
+ Output([[
+ </ul>
+ <!-- // .sideNav -->
+ </div>
+ <!-- // #sidebar -->
+ <!-- h2 stays for breadcrumbs -->
+ <h2>Welcome ]] .. TemplateRequest.Request.Username .. [[</h2>
+ <div id="main">
+ <h3>]] .. SubTitle .. [[</h3>
+ ]] .. PageContent .. [[
+ </div>
+ <!-- // #main -->
+
+ <div class="clear"></div>
+
+ </div>
+ <!-- // #container -->
+ </div>
+ <!-- // #containerHolder -->
+
+ <p id="footer">MCServer is using: ]] .. MemoryUsage .. [[MB of memory; Current chunk count: ]] .. NumChunks .. [[ </p>
+ </div>
+ <!-- // #wrapper -->
+</body>
+</html>
+ ]])
+
+ return table.concat(SiteContent)
+end \ No newline at end of file
diff --git a/Nightbuild2008.cmd b/Nightbuild2008.cmd
index 8d61ee598..fdd5d3de1 100644
--- a/Nightbuild2008.cmd
+++ b/Nightbuild2008.cmd
@@ -1,146 +1,171 @@
-@echo off
-:: Nightbbuild2008.cmd
-:: This script is run every night to produce a new version of MCServer, backup its PDB files and upload the packages to web.
-:: These sub-scripts are used:
-:: - WCRev.cmd together with subwcrev templating to obtain the version number as an environment var
-:: - UploadVersion.ftp FTP command template for uploading the version to the web (not included in the SVN, because it contains confidential passwords! Use your own :)
-:: When run without parameters, this script pauses at the end and waits for a keypress.
-:: To run in an automated scheduler, add any parameter to disable waiting for a keystroke
-::
-:: This script expects a few tools on specific paths, you can pass the correct paths for your system as env vars "zip", "vc" and "tsvn"
-
-
-:: 7-zip executable (by default it should be on PATH):
-if %zip%a == a set zip=7z
-
-:: Visual C++ compiler executable name:
-if %vc%a == a set vc="vcbuild.exe"
-
-:: TortoiseProc executable (for updating to the latest version):
-if %tsvn%a== a set tsvn="c:\program files\tortoisesvn\bin\tortoiseproc.exe"
-
-:: Subwcrev (from TortoiseSVN, for querying revision number; by default in PATH):
-if %subwcrev%a == a set subwcrev=subwcrev
-
-
-
-
-echo Performing nightbuild of MC-Server
-
-
-
-
-
-set DONOTPAUSE=y
-
-:: Update the sources to the latest revision:
-del source\Bindings.cpp
-del source\Bindings.h
-start "tsvn src" /b /min /wait %tsvn% /command:update /path:. /closeonend:1
-if errorlevel 1 goto haderror
-
-
-:: Copy all *.template files into their non-template versions, substituting SVN keywords:
-for /r %%X in (*.template) do (
- %subwcrev% . "%%X" "%%~dpX%%~nX"
- if errorlevel 1 goto haderror
-)
-
-
-:: Get the revision number into WCREV env var
-call Install\WCVersion.cmd
-echo WCREV = %WCREV%
-
-
-:: Test if the version is already present
-if exist Install\MCServer_Win_%WCREV%.7z (
- echo Latest version already present, bailing out
- goto end
-)
-
-
-
-:: Update Bindings.cpp
-del source\Bindings.cpp
-del source\Bindings.h
-echo Updating Lua bindings
-set ALLTOLUA_WAIT=N
-cd source
-call AllToLua.bat
-cd ..
-
-
-
-
-:: Compile using VC2008 Express. Do a full rebuild.
-echo Setting up VS environment...
-call "%VS90COMNTOOLS%\vsvars32.bat"
-echo Compiling MCServer...
-title MCS Nightbuild
-start "vc" /b /wait /low /min %vc% /r vc2008\MCServer.sln "Release|Win32"
-if errorlevel 1 goto haderror
-
-
-
-
-
-:: Use 7-zip to compress the resulting files into a single file:
-:: Note: the output filename here must be the same as in the upload_win.ftp.template script
-copy MCServer\MCServer.exe Install\MCServer.exe
-cd Install
-%zip% a -mx9 -y MCServer_Win_%WCREV%.7z -scsWIN @Zip2008.list
-if errorlevel 1 goto haderror
-cd ..
-
-:: Also pack PDBs into a separate archive:
-:: Note: the output filename here must be the same as in the upload_win.ftp.template script
-%zip% a -mx9 -y Install\MCServer_Win_%WCREV%_PDBs.7z -scsWIN @Install\Zip2008_PDBs.list
-if errorlevel 1 goto haderror
-
-
-
-
-
-:: upload to the FTP:
-:upload
-if "a%ftppass%" == "a" (
- echo You need to set FTP password in the ftppass environment variable to upload the files
- goto end
-)
-if "a%ftpuser%" == "a" (
- echo You need to set FTP username in the ftpuser environment variable to upload the files
- goto end
-)
-if "a%ftpsite%" == "a" (
- echo You need to set FTP server in the ftpsite environment variable to upload the files
- goto end
-)
-ncftpput -p %ftppass% -u %ftpuser% -T temp_ %ftpsite% / Install\MCServer_Win_%WCREV%.7z
-if errorlevel 1 goto haderror
-ncftpput -p %ftppass% -u %ftpuser% -T temp_ %ftpsite% /PDBs Install\MCServer_Win_%WCREV%_PDBs.7z
-if errorlevel 1 goto haderror
-echo Upload finished.
-
-
-
-
-goto end
-
-
-
-
-:haderror
-echo an error was encountered, check command output above
-pause
-goto finished
-
-
-
-
-
-:end
-if "a%1" == "a" pause
-
-
-
+@echo off
+:: Nightbbuild2008.cmd
+:: This script is run every night to produce a new version of MCServer, backup its PDB files and upload the packages to web.
+:: These sub-scripts are used:
+:: - UploadVersion.ftp FTP command template for uploading the version to the web
+:: When run without parameters, this script pauses at the end and waits for a keypress.
+:: To run in an automated scheduler, add any parameter to disable waiting for a keystroke
+::
+:: This script expects a few tools on specific paths, you can pass the correct paths for your system as env vars "zip" and "vc"
+:: This script assumes that "git", "symstore" and "touch" are available on PATH.
+:: git comes from msysgit
+:: symstore comes from Microsoft's Debugging Tools for Windows
+:: touch comes from unxtools
+:: This script is locale-dependent
+
+
+:: 7-zip executable (by default it should be on PATH):
+if %zip%a == a set zip=7z
+
+:: Visual C++ compiler executable name:
+if %vc%a == a set vc="vcbuild.exe"
+
+
+
+
+:: Get the date and time into vars:
+For /f "tokens=2-4 delims=/. " %%a in ('date /t') do (
+ set MYYEAR=%%c
+ set MYMONTH=%%b
+ set MYDAY=%%a
+)
+For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set MYTIME=%%a_%%b)
+
+echo MYYEAR = %MYYEAR%
+echo MYMONTH = %MYMONTH%
+echo MYDAY = %MYDAY%
+echo MYTIME = %MYTIME%
+
+echo Performing nightbuild of MC-Server
+
+
+
+
+
+set DONOTPAUSE=y
+
+:: Update the sources to the latest revision:
+del source\Bindings.cpp
+del source\Bindings.h
+git checkout -- source\Bindings.*
+git pull
+if errorlevel 1 goto haderror
+
+
+
+:: Get the Git commit ID into an environment var
+For /f "tokens=1 delims=/. " %%a in ('git log -1 --oneline --no-abbrev-commit') do (set COMMITID=%%a)
+if errorlevel 1 goto haderror
+
+
+
+:: Test if the version is already present, using a "tagfile" that we create upon successful build
+set TAGFILE=Install\built_%COMMITID%.tag
+if exist %TAGFILE% (
+ echo Latest version already present, bailing out
+ goto end
+)
+
+
+
+:: Update the Bindings:
+del source\Bindings.cpp
+del source\Bindings.h
+echo Updating Lua bindings
+set ALLTOLUA_WAIT=N
+cd source
+call AllToLua.bat
+cd ..
+
+
+
+
+:: Compile using VC2008 Express. Do a full rebuild.
+echo Setting up VS environment...
+call "%VS90COMNTOOLS%\vsvars32.bat"
+echo Compiling MCServer...
+title MCS Nightbuild
+start "vc" /b /wait /low /min %vc% /r vc2008\MCServer.sln "Release|Win32"
+if errorlevel 1 goto haderror
+
+
+
+
+
+:: Use 7-zip to compress the resulting files into a single file:
+set FILESUFFIX=%MYYEAR%_%MYMONTH%_%MYDAY%_%MYTIME%_%COMMITID%
+echo FILESUFFIX=%FILESUFFIX%
+copy MCServer\MCServer.exe Install\MCServer.exe
+cd Install
+%zip% a -mx9 -y MCServer_Win_%FILESUFFIX%.7z -scsWIN @Zip2008.list
+if errorlevel 1 goto haderror
+cd ..
+
+:: Also pack PDBs into a separate archive:
+%zip% a -mx9 -y Install\PDBs_%FILESUFFIX%.7z -scsWIN @Install\Zip2008_PDBs.list
+if errorlevel 1 goto haderror
+
+
+
+
+
+:: upload to the FTP:
+:upload
+if "a%ftppass%" == "a" (
+ echo You need to set FTP password in the ftppass environment variable to upload the files
+ goto end
+)
+if "a%ftpuser%" == "a" (
+ echo You need to set FTP username in the ftpuser environment variable to upload the files
+ goto end
+)
+if "a%ftpsite%" == "a" (
+ echo You need to set FTP server in the ftpsite environment variable to upload the files
+ goto end
+)
+ncftpput -p %ftppass% -u %ftpuser% -T temp_ %ftpsite% / Install\MCServer_Win_%FILESUFFIX%.7z
+if errorlevel 1 goto haderror
+ncftpput -p %ftppass% -u %ftpuser% -T temp_ %ftpsite% /PDBs Install\PDBs_%FILESUFFIX%.7z
+if errorlevel 1 goto haderror
+echo Upload finished.
+
+
+
+
+:: Create the tagfile so that we know that this CommitID has been built already
+touch %TAGFILE%
+
+
+
+
+
+:: Add the symbols to a global symbol cache
+:: We want per-month symbol caches, so that the old ones can be easily deleted
+set SYMBOLS=Symbols\%MYYEAR%_%MYMONTH%\
+echo Storing symbols in %SYMBOLS%
+
+symstore add /f MCServer\MCServer.* /s %SYMBOLS% /t MCServer
+if errorlevel 1 goto haderror
+
+
+
+goto end
+
+
+
+
+:haderror
+echo an error was encountered, check command output above
+pause
+goto finished
+
+
+
+
+
+:end
+if "a%1" == "a" pause
+
+
+
:finished \ No newline at end of file
diff --git a/Tests/NoiseTest/NoiseTest.cpp b/Tests/NoiseTest/NoiseTest.cpp
index eae024f2f..5542f3ca6 100644
--- a/Tests/NoiseTest/NoiseTest.cpp
+++ b/Tests/NoiseTest/NoiseTest.cpp
@@ -1,101 +1,101 @@
-
-// NoiseTest.cpp
-
-// Implements the main app entrypoint
-
-#include "Globals.h"
-#include <time.h>
-#include "Noise.h"
-
-
-
-
-
-void SaveValues(NOISE_DATATYPE * a_Values, const AString & a_FileName)
-{
- cFile f;
- if (!f.Open(a_FileName, cFile::fmWrite))
- {
- LOGWARNING("Cannot write file %s", a_FileName.c_str());
- return;
- }
- for (int y = 0; y < 256; y++)
- {
- unsigned char val[256];
- for (int x = 0; x < 256; x++)
- {
- val[x] = std::min(255, std::max(0, (int)(256 * a_Values[x + 256 * y])));
- }
- f.Write(val, 256);
- }
-}
-
-
-
-
-
-clock_t TestCubicNoise(void)
-{
- cCubicNoise Cubic(0);
- NOISE_DATATYPE Values[256 * 256];
-
- // Do a speed test:
- clock_t Begin = clock();
- for (int i = 0; i < 1000; i++)
- {
- Cubic.Generate2D(Values, 256, 256, 0, (NOISE_DATATYPE)25.6, 0, (NOISE_DATATYPE)25.6);
- }
- clock_t Ticks = clock() - Begin;
- LOG("cCubicNoise generating 1000 * 256x256 values took %d ticks (%.02f sec)", Ticks, (double)Ticks / CLOCKS_PER_SEC);
-
- // Save the results into a file for visual comparison:
- SaveValues(Values, "NoiseCubic.raw");
-
- return Ticks;
-}
-
-
-
-
-
-clock_t TestOldNoise(void)
-{
- cNoise Noise(0);
- NOISE_DATATYPE Values[256 * 256];
-
- // Do a speed test:
- clock_t Begin = clock();
- for (int i = 0; i < 1000; i++)
- {
- for (int y = 0; y < 256; y++)
- {
- float fy = (float)y / 10;
- for (int x = 0; x < 256; x++)
- {
- Values[x + 256 * y] = Noise.CubicNoise2D((float)x / 10, fy);
- } // for x
- } // for y
- }
- clock_t Ticks = clock() - Begin;
- LOG("cNoise generating 1000 * 256x256 values took %d ticks (%.02f sec)", Ticks, (double)Ticks / CLOCKS_PER_SEC);
-
- // Save the results into a file for visual comparison:
- SaveValues(Values, "NoiseOld.raw");
-
- return Ticks;
-}
-
-
-
-
-
-int main(int argc, char * argv[])
-{
- new cMCLogger(); // Create a logger (will set itself as the main instance
-
- clock_t NewTicks = TestCubicNoise();
- clock_t OldTicks = TestOldNoise();
- LOG("New method is %.02fx faster", (double)OldTicks / NewTicks);
- LOG("Press Enter to quit program");
- getchar();
-}
+
+// NoiseTest.cpp
+
+// Implements the main app entrypoint
+
+#include "Globals.h"
+#include <time.h>
+#include "Noise.h"
+
+
+
+
+
+void SaveValues(NOISE_DATATYPE * a_Values, const AString & a_FileName)
+{
+ cFile f;
+ if (!f.Open(a_FileName, cFile::fmWrite))
+ {
+ LOGWARNING("Cannot write file %s", a_FileName.c_str());
+ return;
+ }
+ for (int y = 0; y < 256; y++)
+ {
+ unsigned char val[256];
+ for (int x = 0; x < 256; x++)
+ {
+ val[x] = std::min(255, std::max(0, (int)(256 * a_Values[x + 256 * y])));
+ }
+ f.Write(val, 256);
+ }
+}
+
+
+
+
+
+clock_t TestCubicNoise(void)
+{
+ cCubicNoise Cubic(0);
+ NOISE_DATATYPE Values[256 * 256];
+
+ // Do a speed test:
+ clock_t Begin = clock();
+ for (int i = 0; i < 1000; i++)
+ {
+ Cubic.Generate2D(Values, 256, 256, 0, (NOISE_DATATYPE)25.6, 0, (NOISE_DATATYPE)25.6);
+ }
+ clock_t Ticks = clock() - Begin;
+ LOG("cCubicNoise generating 1000 * 256x256 values took %d ticks (%.02f sec)", Ticks, (double)Ticks / CLOCKS_PER_SEC);
+
+ // Save the results into a file for visual comparison:
+ SaveValues(Values, "NoiseCubic.raw");
+
+ return Ticks;
+}
+
+
+
+
+
+clock_t TestOldNoise(void)
+{
+ cNoise Noise(0);
+ NOISE_DATATYPE Values[256 * 256];
+
+ // Do a speed test:
+ clock_t Begin = clock();
+ for (int i = 0; i < 1000; i++)
+ {
+ for (int y = 0; y < 256; y++)
+ {
+ float fy = (float)y / 10;
+ for (int x = 0; x < 256; x++)
+ {
+ Values[x + 256 * y] = Noise.CubicNoise2D((float)x / 10, fy);
+ } // for x
+ } // for y
+ }
+ clock_t Ticks = clock() - Begin;
+ LOG("cNoise generating 1000 * 256x256 values took %d ticks (%.02f sec)", Ticks, (double)Ticks / CLOCKS_PER_SEC);
+
+ // Save the results into a file for visual comparison:
+ SaveValues(Values, "NoiseOld.raw");
+
+ return Ticks;
+}
+
+
+
+
+
+int main(int argc, char * argv[])
+{
+ new cMCLogger(); // Create a logger (will set itself as the main instance
+
+ clock_t NewTicks = TestCubicNoise();
+ clock_t OldTicks = TestOldNoise();
+ LOG("New method is %.02fx faster", (double)OldTicks / NewTicks);
+ LOG("Press Enter to quit program");
+ getchar();
+}
diff --git a/Tests/NoiseTest/NoiseTest.sln b/Tests/NoiseTest/NoiseTest.sln
index bd55aeef1..240e97d01 100644
--- a/Tests/NoiseTest/NoiseTest.sln
+++ b/Tests/NoiseTest/NoiseTest.sln
@@ -1,20 +1,20 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NoiseTest", "NoiseTest.vcproj", "{8FDBCFC4-E1CF-4704-999C-29A08F9D6053}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Debug|Win32.ActiveCfg = Debug|Win32
- {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Debug|Win32.Build.0 = Debug|Win32
- {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Release|Win32.ActiveCfg = Release|Win32
- {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NoiseTest", "NoiseTest.vcproj", "{8FDBCFC4-E1CF-4704-999C-29A08F9D6053}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Debug|Win32.Build.0 = Debug|Win32
+ {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Release|Win32.ActiveCfg = Release|Win32
+ {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Tests/NoiseTest/NoiseTest.vcproj b/Tests/NoiseTest/NoiseTest.vcproj
index a95740e82..d8741f74c 100644
--- a/Tests/NoiseTest/NoiseTest.vcproj
+++ b/Tests/NoiseTest/NoiseTest.vcproj
@@ -1,258 +1,258 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="NoiseTest"
- ProjectGUID="{8FDBCFC4-E1CF-4704-999C-29A08F9D6053}"
- RootNamespace="NoiseTest"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../../source"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="1"
- AdditionalIncludeDirectories="../../source"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\NoiseTest.cpp"
- >
- </File>
- <Filter
- Name="Shared"
- >
- <File
- RelativePath="..\..\source\Log.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\Log.h"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.h"
- >
- </File>
- <File
- RelativePath="..\..\source\Noise.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\Noise.h"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.h"
- >
- </File>
- <Filter
- Name="OSSupport"
- >
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.h"
- >
- </File>
- </Filter>
- </Filter>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="NoiseTest"
+ ProjectGUID="{8FDBCFC4-E1CF-4704-999C-29A08F9D6053}"
+ RootNamespace="NoiseTest"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../source"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="../../source"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\NoiseTest.cpp"
+ >
+ </File>
+ <Filter
+ Name="Shared"
+ >
+ <File
+ RelativePath="..\..\source\Log.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Log.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Noise.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Noise.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.h"
+ >
+ </File>
+ <Filter
+ Name="OSSupport"
+ >
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Tools/AnvilStats/.gitignore b/Tools/AnvilStats/.gitignore
new file mode 100644
index 000000000..4ed720fed
--- /dev/null
+++ b/Tools/AnvilStats/.gitignore
@@ -0,0 +1,5 @@
+.xls
+Statistics.txt
+*.bmp
+Profiling
+*.png
diff --git a/Tools/AnvilStats/AnvilStats.cpp b/Tools/AnvilStats/AnvilStats.cpp
index ae3f901dc..f0b9dd7e6 100644
--- a/Tools/AnvilStats/AnvilStats.cpp
+++ b/Tools/AnvilStats/AnvilStats.cpp
@@ -1,69 +1,69 @@
-
-// AnvilStats.cpp
-
-// Implements the main app entrypoint
-
-#include "Globals.h"
-#include "Processor.h"
-#include "Statistics.h"
-#include "BiomeMap.h"
-#include "HeightMap.h"
-#include "ChunkExtract.h"
-#include "SpringStats.h"
-
-
-
-
-
-int main(int argc, char * argv[])
-{
- if (argc < 2)
- {
- LOG("Usage: %s <method number> [<world folder>]", argv[0]);
- LOG("Available methods:");
- LOG(" 0 - statistics");
- LOG(" 1 - biome map");
- LOG(" 2 - height map");
- LOG(" 3 - extract chunks");
- LOG(" 4 - count lava- and water- springs");
- LOG("\nNo method number present, aborting.");
- return -1;
- }
-
- AString WorldFolder;
- if (argc > 2)
- {
- WorldFolder = argv[2];
- }
- else
- {
- WorldFolder = "." + cFile::PathSeparator;
- }
-
- cCallbackFactory * Factory = NULL;
- switch (atol(argv[1]))
- {
- case 0: Factory = new cStatisticsFactory; break;
- case 1: Factory = new cBiomeMapFactory; break;
- case 2: Factory = new cHeightMapFactory; break;
- case 3: Factory = new cChunkExtractFactory(WorldFolder); break;
- case 4: Factory = new cSpringStatsFactory; break;
- default:
- {
- LOG("Unknown method \"%s\", aborting.", argv[1]);
- return -2;
- }
- }
- cProcessor Processor;
- Processor.ProcessWorld(WorldFolder, *Factory);
-
- LOG("Processing finished");
-
- delete Factory;
-
- LOG("Done");
-}
-
-
-
-
+
+// AnvilStats.cpp
+
+// Implements the main app entrypoint
+
+#include "Globals.h"
+#include "Processor.h"
+#include "Statistics.h"
+#include "BiomeMap.h"
+#include "HeightMap.h"
+#include "ChunkExtract.h"
+#include "SpringStats.h"
+
+
+
+
+
+int main(int argc, char * argv[])
+{
+ if (argc < 2)
+ {
+ LOG("Usage: %s <method number> [<world folder>]", argv[0]);
+ LOG("Available methods:");
+ LOG(" 0 - statistics");
+ LOG(" 1 - biome map");
+ LOG(" 2 - height map");
+ LOG(" 3 - extract chunks");
+ LOG(" 4 - count lava- and water- springs");
+ LOG("\nNo method number present, aborting.");
+ return -1;
+ }
+
+ AString WorldFolder;
+ if (argc > 2)
+ {
+ WorldFolder = argv[2];
+ }
+ else
+ {
+ WorldFolder = "." + cFile::PathSeparator;
+ }
+
+ cCallbackFactory * Factory = NULL;
+ switch (atol(argv[1]))
+ {
+ case 0: Factory = new cStatisticsFactory; break;
+ case 1: Factory = new cBiomeMapFactory; break;
+ case 2: Factory = new cHeightMapFactory; break;
+ case 3: Factory = new cChunkExtractFactory(WorldFolder); break;
+ case 4: Factory = new cSpringStatsFactory; break;
+ default:
+ {
+ LOG("Unknown method \"%s\", aborting.", argv[1]);
+ return -2;
+ }
+ }
+ cProcessor Processor;
+ Processor.ProcessWorld(WorldFolder, *Factory);
+
+ LOG("Processing finished");
+
+ delete Factory;
+
+ LOG("Done");
+}
+
+
+
+
diff --git a/Tools/AnvilStats/AnvilStats.sln b/Tools/AnvilStats/AnvilStats.sln
index 886a7a8c8..6e2481d84 100644
--- a/Tools/AnvilStats/AnvilStats.sln
+++ b/Tools/AnvilStats/AnvilStats.sln
@@ -1,34 +1,34 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnvilStats", "AnvilStats.vcproj", "{CF996A5E-0A86-4004-9710-682B06B5AEBA}"
- ProjectSection(ProjectDependencies) = postProject
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA} = {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\VC2008\zlib.vcproj", "{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release profiled|Win32 = Release profiled|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Debug|Win32.ActiveCfg = Debug|Win32
- {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Debug|Win32.Build.0 = Debug|Win32
- {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release|Win32.ActiveCfg = Release|Win32
- {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release|Win32.Build.0 = Release|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.ActiveCfg = Debug|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.Build.0 = Debug|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.ActiveCfg = Release|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnvilStats", "AnvilStats.vcproj", "{CF996A5E-0A86-4004-9710-682B06B5AEBA}"
+ ProjectSection(ProjectDependencies) = postProject
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA} = {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\VC2008\zlib.vcproj", "{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release profiled|Win32 = Release profiled|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Debug|Win32.Build.0 = Debug|Win32
+ {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release|Win32.ActiveCfg = Release|Win32
+ {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release|Win32.Build.0 = Release|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.Build.0 = Debug|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.ActiveCfg = Release|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Tools/AnvilStats/AnvilStats.txt b/Tools/AnvilStats/AnvilStats.txt
index 07c518e4c..19aa4f324 100644
--- a/Tools/AnvilStats/AnvilStats.txt
+++ b/Tools/AnvilStats/AnvilStats.txt
@@ -1,27 +1,27 @@
-
-// AnvilStats.txt
-
-// A Readme for the project
-
-/*
-AnvilStats
-==========
-
-This is a project for measuring various metrics throughout an Anvil world, presumably created by a vanilla MC.
-It works by parsing the MCA files in the path specified as its param (or current directory, if no params) and
-feeding each decompressed chunk into the statistics-gathering callback function.
-
-Possible usage:
- - count the per-chunk density of specific blocks
- - count the per-chunk density of dungeons, by measuring the number of zombie/skeleton/regularspider spawners
- - count the per-chunk-per-biome density of trees, by measuring the number of dirt-log vertical transitions, correlating to biome data
-
-This project is Windows-only, although it shouldn't be too difficult to make it portable.
-
-Because this project uses NBT extensively, it runs much faster in Release mode.
-
-
-*/
-
-
-
+
+// AnvilStats.txt
+
+// A Readme for the project
+
+/*
+AnvilStats
+==========
+
+This is a project for measuring various metrics throughout an Anvil world, presumably created by a vanilla MC.
+It works by parsing the MCA files in the path specified as its param (or current directory, if no params) and
+feeding each decompressed chunk into the statistics-gathering callback function.
+
+Possible usage:
+ - count the per-chunk density of specific blocks
+ - count the per-chunk density of dungeons, by measuring the number of zombie/skeleton/regularspider spawners
+ - count the per-chunk-per-biome density of trees, by measuring the number of dirt-log vertical transitions, correlating to biome data
+
+This project is Windows-only, although it shouldn't be too difficult to make it portable.
+
+Because this project uses NBT extensively, it runs much faster in Release mode.
+
+
+*/
+
+
+
diff --git a/Tools/AnvilStats/AnvilStats.vcproj b/Tools/AnvilStats/AnvilStats.vcproj
index 1726cbfbf..ed4ffa9a5 100644
--- a/Tools/AnvilStats/AnvilStats.vcproj
+++ b/Tools/AnvilStats/AnvilStats.vcproj
@@ -1,452 +1,452 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="AnvilStats"
- ProjectGUID="{CF996A5E-0A86-4004-9710-682B06B5AEBA}"
- RootNamespace="AnvilStats"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="&quot;..\..\zlib-1.2.7&quot;"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- StackReserveSize="16777216"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="&quot;..\..\zlib-1.2.7&quot;"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- StackReserveSize="16777216"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release profiled|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="&quot;..\..\zlib-1.2.7&quot;"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- StackReserveSize="16777216"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- Profile="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\AnvilStats.cpp"
- >
- </File>
- <File
- RelativePath=".\BiomeMap.cpp"
- >
- </File>
- <File
- RelativePath=".\BiomeMap.h"
- >
- </File>
- <File
- RelativePath=".\Callback.h"
- >
- </File>
- <File
- RelativePath=".\ChunkExtract.cpp"
- >
- </File>
- <File
- RelativePath=".\ChunkExtract.h"
- >
- </File>
- <File
- RelativePath=".\Globals.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\Globals.h"
- >
- </File>
- <File
- RelativePath=".\HeightMap.cpp"
- >
- </File>
- <File
- RelativePath=".\HeightMap.h"
- >
- </File>
- <File
- RelativePath=".\Processor.cpp"
- >
- </File>
- <File
- RelativePath=".\Processor.h"
- >
- </File>
- <File
- RelativePath=".\SpringStats.cpp"
- >
- </File>
- <File
- RelativePath=".\SpringStats.h"
- >
- </File>
- <File
- RelativePath=".\Statistics.cpp"
- >
- </File>
- <File
- RelativePath=".\Statistics.h"
- >
- </File>
- <File
- RelativePath=".\Utils.cpp"
- >
- </File>
- <File
- RelativePath=".\Utils.h"
- >
- </File>
- </Filter>
- <Filter
- Name="shared"
- >
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.h"
- >
- </File>
- <File
- RelativePath="..\..\source\Endianness.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\Event.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\Event.h"
- >
- </File>
- <File
- RelativePath="..\..\source\WorldStorage\FastNBT.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="NBT_RESERVE_SIZE=10000"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="NBT_RESERVE_SIZE=10000"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="NBT_RESERVE_SIZE=10000"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\source\WorldStorage\FastNBT.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\GZipFile.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\GZipFile.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.h"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.h"
- >
- </File>
- </Filter>
- <File
- RelativePath=".\AnvilStats.txt"
- >
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="AnvilStats"
+ ProjectGUID="{CF996A5E-0A86-4004-9710-682B06B5AEBA}"
+ RootNamespace="AnvilStats"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;..\..\zlib-1.2.7&quot;"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ StackReserveSize="16777216"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="&quot;..\..\zlib-1.2.7&quot;"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ StackReserveSize="16777216"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="&quot;..\..\zlib-1.2.7&quot;"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ StackReserveSize="16777216"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ Profile="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\AnvilStats.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeMap.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeMap.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Callback.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ChunkExtract.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ChunkExtract.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Globals.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\Globals.h"
+ >
+ </File>
+ <File
+ RelativePath=".\HeightMap.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\HeightMap.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Processor.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Processor.h"
+ >
+ </File>
+ <File
+ RelativePath=".\SpringStats.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\SpringStats.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Statistics.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Statistics.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Utils.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Utils.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="shared"
+ >
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Endianness.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\Event.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\Event.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\WorldStorage\FastNBT.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="NBT_RESERVE_SIZE=10000"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="NBT_RESERVE_SIZE=10000"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="NBT_RESERVE_SIZE=10000"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\source\WorldStorage\FastNBT.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\GZipFile.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\GZipFile.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.h"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\AnvilStats.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Tools/AnvilStats/BiomeMap.cpp b/Tools/AnvilStats/BiomeMap.cpp
index eca235c5f..6505299ba 100644
--- a/Tools/AnvilStats/BiomeMap.cpp
+++ b/Tools/AnvilStats/BiomeMap.cpp
@@ -1,172 +1,172 @@
-
-// BiomeMap.cpp
-
-// Implements the cBiomeMap class representing a cCallback descendant that draws a map of biomes for the world
-
-#include "Globals.h"
-#include "BiomeMap.h"
-
-
-
-
-
-static const int g_BiomePalette[] =
-{
- // ARGB:
- 0xff0000ff, /* Ocean */
- 0xff00cf3f, /* Plains */
- 0xffffff00, /* Desert */
- 0xff7f7f7f, /* Extreme Hills */
- 0xff00cf00, /* Forest */
- 0xff007f3f, /* Taiga */
- 0xff3f7f00, /* Swampland */
- 0xff003fff, /* River */
- 0xff7f0000, /* Hell */
- 0xff007fff, /* Sky */
- 0xff3f3fff, /* Frozen Ocean */
- 0xff3f3fff, /* Frozen River */
- 0xff7fffcf, /* Ice Plains */
- 0xff3fcf7f, /* Ice Mountains */
- 0xffcf00cf, /* Mushroom Island */
- 0xff7f00ff, /* Mushroom Island Shore */
- 0xffffff3f, /* Beach */
- 0xffcfcf00, /* Desert Hills */
- 0xff00cf3f, /* Forest Hills */
- 0xff006f1f, /* Taiga Hills */
- 0xff7f8f7f, /* Extreme Hills Edge */
- 0xff004f00, /* Jungle */
- 0xff003f00, /* Jungle Hills */
-} ;
-
-
-
-
-
-static const unsigned char g_BMPHeader[] =
-{
- 0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-} ;
-
-
-
-
-
-cBiomeMap::cBiomeMap(void) :
- m_CurrentRegionX(0),
- m_CurrentRegionZ(0),
- m_IsCurrentRegionValid(false)
-{
-}
-
-
-
-
-
-void cBiomeMap::Finish(void)
-{
- if (m_IsCurrentRegionValid)
- {
- StartNewRegion(0, 0);
- }
-}
-
-
-
-
-
-bool cBiomeMap::OnNewChunk(int a_ChunkX, int a_ChunkZ)
-{
- int RegionX = (a_ChunkX < 0) ? (a_ChunkX - 31) / 32 : a_ChunkX / 32;
- int RegionZ = (a_ChunkZ < 0) ? (a_ChunkZ - 31) / 32 : a_ChunkZ / 32;
- if ((RegionX != m_CurrentRegionX) || (RegionZ != m_CurrentRegionZ))
- {
- if (m_IsCurrentRegionValid)
- {
- StartNewRegion(RegionX, RegionZ);
- }
- m_CurrentRegionX = RegionX;
- m_CurrentRegionZ = RegionZ;
- }
- m_IsCurrentRegionValid = true;
- m_CurrentChunkX = a_ChunkX;
- m_CurrentChunkZ = a_ChunkZ;
- m_CurrentChunkOffX = m_CurrentChunkX - m_CurrentRegionX * 32;
- m_CurrentChunkOffZ = m_CurrentChunkZ - m_CurrentRegionZ * 32;
- return false;
-}
-
-
-
-
-
-bool cBiomeMap::OnBiomes(const unsigned char * a_BiomeData)
-{
- ASSERT(m_CurrentChunkOffX >= 0);
- ASSERT(m_CurrentChunkOffX < 32);
- ASSERT(m_CurrentChunkOffZ >= 0);
- ASSERT(m_CurrentChunkOffZ < 32);
- char * BaseBiomes = m_Biomes + m_CurrentChunkOffZ * 16 * 512 + m_CurrentChunkOffX * 16;
- for (int z = 0; z < 16; z++)
- {
- char * Row = BaseBiomes + z * 512;
- memcpy(Row, a_BiomeData + z * 16, 16);
- } // for z
- return true;
-}
-
-
-
-
-
-void cBiomeMap::StartNewRegion(int a_RegionX, int a_RegionZ)
-{
- AString FileName;
- Printf(FileName, "Biomes.%d.%d.bmp", m_CurrentRegionX, m_CurrentRegionZ);
- cFile f;
- if (!f.Open(FileName, cFile::fmWrite))
- {
- LOG("Cannot open file \"%s\" for writing the biome map. Data for this region lost.", FileName.c_str());
- }
- else
- {
- f.Write(g_BMPHeader, sizeof(g_BMPHeader));
- for (int z = 0; z < 512; z++)
- {
- int RowData[512];
- unsigned char * BiomeRow = (unsigned char *)m_Biomes + z * 512;
- for (int x = 0; x < 512; x++)
- {
- RowData[x] = g_BiomePalette[BiomeRow[x]];
- }
- f.Write(RowData, sizeof(RowData));
- } // for z
- }
-
- memset(m_Biomes, 0, sizeof(m_Biomes));
- m_CurrentRegionX = a_RegionX;
- m_CurrentRegionZ = a_RegionZ;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cBiomeMapFactory:
-
-cBiomeMapFactory::~cBiomeMapFactory()
-{
- // Force all threads to save their last regions:
- for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
- {
- ((cBiomeMap *)(*itr))->Finish();
- }
- // TODO: Join all the files into one giant image file
-}
-
-
-
-
+
+// BiomeMap.cpp
+
+// Implements the cBiomeMap class representing a cCallback descendant that draws a map of biomes for the world
+
+#include "Globals.h"
+#include "BiomeMap.h"
+
+
+
+
+
+static const int g_BiomePalette[] =
+{
+ // ARGB:
+ 0xff0000ff, /* Ocean */
+ 0xff00cf3f, /* Plains */
+ 0xffffff00, /* Desert */
+ 0xff7f7f7f, /* Extreme Hills */
+ 0xff00cf00, /* Forest */
+ 0xff007f3f, /* Taiga */
+ 0xff3f7f00, /* Swampland */
+ 0xff003fff, /* River */
+ 0xff7f0000, /* Hell */
+ 0xff007fff, /* Sky */
+ 0xff3f3fff, /* Frozen Ocean */
+ 0xff3f3fff, /* Frozen River */
+ 0xff7fffcf, /* Ice Plains */
+ 0xff3fcf7f, /* Ice Mountains */
+ 0xffcf00cf, /* Mushroom Island */
+ 0xff7f00ff, /* Mushroom Island Shore */
+ 0xffffff3f, /* Beach */
+ 0xffcfcf00, /* Desert Hills */
+ 0xff00cf3f, /* Forest Hills */
+ 0xff006f1f, /* Taiga Hills */
+ 0xff7f8f7f, /* Extreme Hills Edge */
+ 0xff004f00, /* Jungle */
+ 0xff003f00, /* Jungle Hills */
+} ;
+
+
+
+
+
+static const unsigned char g_BMPHeader[] =
+{
+ 0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+} ;
+
+
+
+
+
+cBiomeMap::cBiomeMap(void) :
+ m_CurrentRegionX(0),
+ m_CurrentRegionZ(0),
+ m_IsCurrentRegionValid(false)
+{
+}
+
+
+
+
+
+void cBiomeMap::Finish(void)
+{
+ if (m_IsCurrentRegionValid)
+ {
+ StartNewRegion(0, 0);
+ }
+}
+
+
+
+
+
+bool cBiomeMap::OnNewChunk(int a_ChunkX, int a_ChunkZ)
+{
+ int RegionX = (a_ChunkX < 0) ? (a_ChunkX - 31) / 32 : a_ChunkX / 32;
+ int RegionZ = (a_ChunkZ < 0) ? (a_ChunkZ - 31) / 32 : a_ChunkZ / 32;
+ if ((RegionX != m_CurrentRegionX) || (RegionZ != m_CurrentRegionZ))
+ {
+ if (m_IsCurrentRegionValid)
+ {
+ StartNewRegion(RegionX, RegionZ);
+ }
+ m_CurrentRegionX = RegionX;
+ m_CurrentRegionZ = RegionZ;
+ }
+ m_IsCurrentRegionValid = true;
+ m_CurrentChunkX = a_ChunkX;
+ m_CurrentChunkZ = a_ChunkZ;
+ m_CurrentChunkOffX = m_CurrentChunkX - m_CurrentRegionX * 32;
+ m_CurrentChunkOffZ = m_CurrentChunkZ - m_CurrentRegionZ * 32;
+ return false;
+}
+
+
+
+
+
+bool cBiomeMap::OnBiomes(const unsigned char * a_BiomeData)
+{
+ ASSERT(m_CurrentChunkOffX >= 0);
+ ASSERT(m_CurrentChunkOffX < 32);
+ ASSERT(m_CurrentChunkOffZ >= 0);
+ ASSERT(m_CurrentChunkOffZ < 32);
+ char * BaseBiomes = m_Biomes + m_CurrentChunkOffZ * 16 * 512 + m_CurrentChunkOffX * 16;
+ for (int z = 0; z < 16; z++)
+ {
+ char * Row = BaseBiomes + z * 512;
+ memcpy(Row, a_BiomeData + z * 16, 16);
+ } // for z
+ return true;
+}
+
+
+
+
+
+void cBiomeMap::StartNewRegion(int a_RegionX, int a_RegionZ)
+{
+ AString FileName;
+ Printf(FileName, "Biomes.%d.%d.bmp", m_CurrentRegionX, m_CurrentRegionZ);
+ cFile f;
+ if (!f.Open(FileName, cFile::fmWrite))
+ {
+ LOG("Cannot open file \"%s\" for writing the biome map. Data for this region lost.", FileName.c_str());
+ }
+ else
+ {
+ f.Write(g_BMPHeader, sizeof(g_BMPHeader));
+ for (int z = 0; z < 512; z++)
+ {
+ int RowData[512];
+ unsigned char * BiomeRow = (unsigned char *)m_Biomes + z * 512;
+ for (int x = 0; x < 512; x++)
+ {
+ RowData[x] = g_BiomePalette[BiomeRow[x]];
+ }
+ f.Write(RowData, sizeof(RowData));
+ } // for z
+ }
+
+ memset(m_Biomes, 0, sizeof(m_Biomes));
+ m_CurrentRegionX = a_RegionX;
+ m_CurrentRegionZ = a_RegionZ;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cBiomeMapFactory:
+
+cBiomeMapFactory::~cBiomeMapFactory()
+{
+ // Force all threads to save their last regions:
+ for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
+ {
+ ((cBiomeMap *)(*itr))->Finish();
+ }
+ // TODO: Join all the files into one giant image file
+}
+
+
+
+
diff --git a/Tools/AnvilStats/BiomeMap.h b/Tools/AnvilStats/BiomeMap.h
index f0d306c04..c590a3c63 100644
--- a/Tools/AnvilStats/BiomeMap.h
+++ b/Tools/AnvilStats/BiomeMap.h
@@ -1,69 +1,69 @@
-
-// BiomeMap.h
-
-// Interfaces to the cBiomeMap class representing a cCallback descendant that draws a map of biomes for the world
-
-
-
-
-
-#pragma once
-
-#include "Callback.h"
-
-
-
-
-
-class cBiomeMap :
- public cCallback
-{
-public:
- cBiomeMap(void);
-
- /// Saves the last region that it was processing
- void Finish(void);
-
-protected:
- int m_CurrentChunkX; // Absolute chunk coords
- int m_CurrentChunkZ;
- int m_CurrentChunkOffX; // Chunk offset from the start of the region
- int m_CurrentChunkOffZ;
- int m_CurrentRegionX;
- int m_CurrentRegionZ;
- bool m_IsCurrentRegionValid;
- char m_Biomes[16 * 32 * 16 * 32]; // Biome map of the entire current region [x + 16 * 32 * z]
-
- // cCallback overrides:
- virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
- virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
- virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
- virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
- virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
- virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
- virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
-
- void StartNewRegion(int a_RegionX, int a_RegionZ);
-} ;
-
-
-
-
-
-class cBiomeMapFactory :
- public cCallbackFactory
-{
-public:
- virtual ~cBiomeMapFactory();
-
- virtual cCallback * CreateNewCallback(void) override
- {
- return new cBiomeMap;
- }
-
-} ;
-
-
-
-
+
+// BiomeMap.h
+
+// Interfaces to the cBiomeMap class representing a cCallback descendant that draws a map of biomes for the world
+
+
+
+
+
+#pragma once
+
+#include "Callback.h"
+
+
+
+
+
+class cBiomeMap :
+ public cCallback
+{
+public:
+ cBiomeMap(void);
+
+ /// Saves the last region that it was processing
+ void Finish(void);
+
+protected:
+ int m_CurrentChunkX; // Absolute chunk coords
+ int m_CurrentChunkZ;
+ int m_CurrentChunkOffX; // Chunk offset from the start of the region
+ int m_CurrentChunkOffZ;
+ int m_CurrentRegionX;
+ int m_CurrentRegionZ;
+ bool m_IsCurrentRegionValid;
+ char m_Biomes[16 * 32 * 16 * 32]; // Biome map of the entire current region [x + 16 * 32 * z]
+
+ // cCallback overrides:
+ virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
+ virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
+ virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
+ virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
+ virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
+ virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
+ virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
+
+ void StartNewRegion(int a_RegionX, int a_RegionZ);
+} ;
+
+
+
+
+
+class cBiomeMapFactory :
+ public cCallbackFactory
+{
+public:
+ virtual ~cBiomeMapFactory();
+
+ virtual cCallback * CreateNewCallback(void) override
+ {
+ return new cBiomeMap;
+ }
+
+} ;
+
+
+
+
diff --git a/Tools/AnvilStats/Callback.h b/Tools/AnvilStats/Callback.h
index 92d394d0e..83b330651 100644
--- a/Tools/AnvilStats/Callback.h
+++ b/Tools/AnvilStats/Callback.h
@@ -1,165 +1,165 @@
-
-// Callback.h
-
-// Interfaces to the cCallback base class used as the base class for all statistical callbacks
-
-
-
-
-
-#pragma once
-
-
-
-
-
-// fwd:
-class cParsedNBT;
-
-
-
-
-
-/** The base class for all chunk-processor callbacks, declares the interface.
-The processor calls each virtual function in the order they are declared here with the specified args.
-If the function returns true, the processor moves on to next chunk and starts calling the callbacks again from start with
-the new chunk data.
-So if a statistics collector doesn't need data decompression at all, it can stop the processor from doing so early-enough
-and still get meaningful data.
-A callback is guaranteed to run in a single thread and always the same thread.
-A callback is guaranteed to run on all chunks in a region and one region is guaranteed to be handled by only callback.
-*/
-class cCallback abstract
-{
-public:
- virtual ~cCallback() {} // Force a virtual destructor in each descendant
-
- /// Called to inform the stats module of the chunk coords for newly processing chunk
- virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) = 0;
-
- /// Called to inform about the chunk's data offset in the file (chunk mini-header), the number of sectors it uses and the timestamp field value
- virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) { return true; }
-
- /// Called to inform of the compressed chunk data size and position in the file (offset from file start to the actual data)
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) { return true; }
-
- /// Just in case you wanted to process the NBT yourself ;)
- virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) { return true; }
-
- /// The chunk's NBT should specify chunk coords, these are sent here:
- virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) { return true; }
-
- /// The chunk contains a LastUpdate value specifying the last tick in which it was saved.
- virtual bool OnLastUpdate(Int64 a_LastUpdate) { return true; }
-
- virtual bool OnTerrainPopulated(bool a_Populated) { return true; }
-
- virtual bool OnBiomes(const unsigned char * a_BiomeData) { return true; }
-
- /** Called when a heightmap for the chunk is read from the file.
- Note that the heightmap is given in big-endian ints, so if you want it, you need to ntohl() it first!
- */
- virtual bool OnHeightMap(const int * a_HeightMapBE) { return true; }
-
- /** If there is data for the section, this callback is called; otherwise OnEmptySection() is called instead.
- All OnSection() callbacks are called first, and only then all the remaining sections are reported in OnEmptySection().
- */
- virtual bool OnSection(
- unsigned char a_Y,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockAdditional,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight
- ) { return true; }
-
- /** If there is no data for a section, this callback is called; otherwise OnSection() is called instead.
- OnEmptySection() callbacks are called after all OnSection() callbacks.
- */
- virtual bool OnEmptySection(unsigned char a_Y) { return false; }
-
- /** Called after all sections have been processed via either OnSection() or OnEmptySection().
- */
- virtual bool OnSectionsFinished(void) { return true; }
-
- /** Called for each entity in the chunk.
- Common parameters are parsed from the NBT.
- The callback may parse any other param from the a_NBT and a_NBTTag parameters.
- The a_NBTTag parameter points to the entity compound tag inside the Entities tag.
- */
- virtual bool OnEntity(
- const AString & a_EntityType,
- double a_PosX, double a_PosY, double a_PosZ,
- double a_SpeedX, double a_SpeedY, double a_SpeedZ,
- float a_Yaw, float a_Pitch,
- float a_FallDistance,
- short a_FireTicksLeft,
- short a_AirTicks,
- char a_IsOnGround,
- cParsedNBT & a_NBT,
- int a_NBTTag
- ) { return true; }
-
- /** Called for each tile entity in the chunk.
- Common parameters are parsed from the NBT.
- The callback may parse any other param from the a_NBT and a_NBTTag parameters.
- The a_NBTTag parameter points to the tile entity compound tag inside the TileEntities tag.
- */
- virtual bool OnTileEntity(
- const AString & a_EntityType,
- int a_PosX, int a_PosY, int a_PosZ,
- cParsedNBT & a_NBT,
- int a_NBTTag
- ) { return true; }
-
- /// Called for each tile tick in the chunk
- virtual bool OnTileTick(
- int a_BlockType,
- int a_TicksLeft,
- int a_PosX, int a_PosY, int a_PosZ
- ) { return true; }
-} ;
-
-typedef std::vector<cCallback *> cCallbacks;
-
-
-
-
-
-/** The base class for a factory that creates callback objects for separate threads.
-The processor creates a callback for each thread on which it runs using this factory.
-The factory is guaranteed to be called from a single thread.
-The factory keeps track of all the callbacks that it has created and deletes them when destructed
-*/
-class cCallbackFactory
-{
-public:
- virtual ~cCallbackFactory()
- {
- for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
- {
- delete *itr;
- }
- }
-
- /// Descendants override this method to return the correct callback type
- virtual cCallback * CreateNewCallback(void) = 0;
-
- /// cProcessor uses this method to request a new callback
- cCallback * GetNewCallback(void)
- {
- cCallback * Callback = CreateNewCallback();
- if (Callback != NULL)
- {
- m_Callbacks.push_back(Callback);
- }
- return Callback;
- }
-
-protected:
- cCallbacks m_Callbacks;
-} ;
-
-
-
-
+
+// Callback.h
+
+// Interfaces to the cCallback base class used as the base class for all statistical callbacks
+
+
+
+
+
+#pragma once
+
+
+
+
+
+// fwd:
+class cParsedNBT;
+
+
+
+
+
+/** The base class for all chunk-processor callbacks, declares the interface.
+The processor calls each virtual function in the order they are declared here with the specified args.
+If the function returns true, the processor moves on to next chunk and starts calling the callbacks again from start with
+the new chunk data.
+So if a statistics collector doesn't need data decompression at all, it can stop the processor from doing so early-enough
+and still get meaningful data.
+A callback is guaranteed to run in a single thread and always the same thread.
+A callback is guaranteed to run on all chunks in a region and one region is guaranteed to be handled by only callback.
+*/
+class cCallback abstract
+{
+public:
+ virtual ~cCallback() {} // Force a virtual destructor in each descendant
+
+ /// Called to inform the stats module of the chunk coords for newly processing chunk
+ virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) = 0;
+
+ /// Called to inform about the chunk's data offset in the file (chunk mini-header), the number of sectors it uses and the timestamp field value
+ virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) { return true; }
+
+ /// Called to inform of the compressed chunk data size and position in the file (offset from file start to the actual data)
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) { return true; }
+
+ /// Just in case you wanted to process the NBT yourself ;)
+ virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) { return true; }
+
+ /// The chunk's NBT should specify chunk coords, these are sent here:
+ virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) { return true; }
+
+ /// The chunk contains a LastUpdate value specifying the last tick in which it was saved.
+ virtual bool OnLastUpdate(Int64 a_LastUpdate) { return true; }
+
+ virtual bool OnTerrainPopulated(bool a_Populated) { return true; }
+
+ virtual bool OnBiomes(const unsigned char * a_BiomeData) { return true; }
+
+ /** Called when a heightmap for the chunk is read from the file.
+ Note that the heightmap is given in big-endian ints, so if you want it, you need to ntohl() it first!
+ */
+ virtual bool OnHeightMap(const int * a_HeightMapBE) { return true; }
+
+ /** If there is data for the section, this callback is called; otherwise OnEmptySection() is called instead.
+ All OnSection() callbacks are called first, and only then all the remaining sections are reported in OnEmptySection().
+ */
+ virtual bool OnSection(
+ unsigned char a_Y,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockAdditional,
+ const NIBBLETYPE * a_BlockMeta,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_BlockSkyLight
+ ) { return true; }
+
+ /** If there is no data for a section, this callback is called; otherwise OnSection() is called instead.
+ OnEmptySection() callbacks are called after all OnSection() callbacks.
+ */
+ virtual bool OnEmptySection(unsigned char a_Y) { return false; }
+
+ /** Called after all sections have been processed via either OnSection() or OnEmptySection().
+ */
+ virtual bool OnSectionsFinished(void) { return true; }
+
+ /** Called for each entity in the chunk.
+ Common parameters are parsed from the NBT.
+ The callback may parse any other param from the a_NBT and a_NBTTag parameters.
+ The a_NBTTag parameter points to the entity compound tag inside the Entities tag.
+ */
+ virtual bool OnEntity(
+ const AString & a_EntityType,
+ double a_PosX, double a_PosY, double a_PosZ,
+ double a_SpeedX, double a_SpeedY, double a_SpeedZ,
+ float a_Yaw, float a_Pitch,
+ float a_FallDistance,
+ short a_FireTicksLeft,
+ short a_AirTicks,
+ char a_IsOnGround,
+ cParsedNBT & a_NBT,
+ int a_NBTTag
+ ) { return true; }
+
+ /** Called for each tile entity in the chunk.
+ Common parameters are parsed from the NBT.
+ The callback may parse any other param from the a_NBT and a_NBTTag parameters.
+ The a_NBTTag parameter points to the tile entity compound tag inside the TileEntities tag.
+ */
+ virtual bool OnTileEntity(
+ const AString & a_EntityType,
+ int a_PosX, int a_PosY, int a_PosZ,
+ cParsedNBT & a_NBT,
+ int a_NBTTag
+ ) { return true; }
+
+ /// Called for each tile tick in the chunk
+ virtual bool OnTileTick(
+ int a_BlockType,
+ int a_TicksLeft,
+ int a_PosX, int a_PosY, int a_PosZ
+ ) { return true; }
+} ;
+
+typedef std::vector<cCallback *> cCallbacks;
+
+
+
+
+
+/** The base class for a factory that creates callback objects for separate threads.
+The processor creates a callback for each thread on which it runs using this factory.
+The factory is guaranteed to be called from a single thread.
+The factory keeps track of all the callbacks that it has created and deletes them when destructed
+*/
+class cCallbackFactory
+{
+public:
+ virtual ~cCallbackFactory()
+ {
+ for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
+ {
+ delete *itr;
+ }
+ }
+
+ /// Descendants override this method to return the correct callback type
+ virtual cCallback * CreateNewCallback(void) = 0;
+
+ /// cProcessor uses this method to request a new callback
+ cCallback * GetNewCallback(void)
+ {
+ cCallback * Callback = CreateNewCallback();
+ if (Callback != NULL)
+ {
+ m_Callbacks.push_back(Callback);
+ }
+ return Callback;
+ }
+
+protected:
+ cCallbacks m_Callbacks;
+} ;
+
+
+
+
diff --git a/Tools/AnvilStats/ChunkExtract.cpp b/Tools/AnvilStats/ChunkExtract.cpp
index 08517a58d..71e804e73 100644
--- a/Tools/AnvilStats/ChunkExtract.cpp
+++ b/Tools/AnvilStats/ChunkExtract.cpp
@@ -1,104 +1,104 @@
-
-// ChunkExtract.cpp
-
-// Implements the cChunkExtract class representing a cCallback descendant that extracts raw chunk data into separate .chunk files
-
-#include "Globals.h"
-#include "ChunkExtract.h"
-#include "../../source/OSSupport/GZipFile.h"
-
-
-
-
-
-cChunkExtract::cChunkExtract(const AString & iWorldFolder) :
- mWorldFolder(iWorldFolder)
-{
-}
-
-
-
-
-
-bool cChunkExtract::OnNewChunk(int a_ChunkX, int a_ChunkZ)
-{
- int AnvilX = (a_ChunkX - ((a_ChunkX > 0) ? 0 : 31)) / 32;
- int AnvilZ = (a_ChunkZ - ((a_ChunkZ > 0) ? 0 : 31)) / 32;
- if ((AnvilX != mCurAnvilX) || (AnvilZ != mCurAnvilZ))
- {
- OpenAnvilFile(AnvilX, AnvilZ);
- }
- mCurChunkX = a_ChunkX;
- mCurChunkZ = a_ChunkZ;
- return false;
-}
-
-
-
-
-
-bool cChunkExtract::OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod)
-{
- if (!mAnvilFile.IsOpen())
- {
- return true;
- }
- cFile ChunkFile;
- AString ChunkPath = Printf("%d.%d.zchunk", mCurChunkX, mCurChunkZ);
- if (!ChunkFile.Open(ChunkPath, cFile::fmWrite))
- {
- LOG("Cannot open zchunk file \"%s\" for writing. Chunk [%d, %d] skipped.", ChunkPath.c_str(), mCurChunkX, mCurChunkZ);
- return false;
- }
-
- // Copy data from mAnvilFile to ChunkFile:
- mAnvilFile.Seek(a_DataOffset);
- for (int BytesToCopy = a_CompressedDataSize; BytesToCopy > 0; )
- {
- char Buffer[64000];
- int NumBytes = std::min(BytesToCopy, (int)sizeof(Buffer));
- int BytesRead = mAnvilFile.Read(Buffer, NumBytes);
- if (BytesRead != NumBytes)
- {
- LOG("Cannot copy chunk data, chunk [%d, %d] is probably corrupted. Skipping chunk.", mCurChunkX, mCurChunkZ);
- return false;
- }
- ChunkFile.Write(Buffer, BytesRead);
- BytesToCopy -= BytesRead;
- } // for BytesToCopy
- return false;
-}
-
-
-
-
-
-bool cChunkExtract::OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize)
-{
- ASSERT(mAnvilFile.IsOpen()); // If it weren't, the OnCompressedDataSizePos would've prevented this from running
- AString FileName = Printf("%d.%d.gzchunk", mCurChunkX, mCurChunkZ);
- cGZipFile GZipChunk;
- if (!GZipChunk.Open(FileName, cGZipFile::fmWrite))
- {
- LOG("Cannot open gzchunk file \"%s\" for writing. Chunk [%d, %d] skipped.", FileName.c_str(), mCurChunkX, mCurChunkZ);
- return true;
- }
- GZipChunk.Write(a_DecompressedNBT, a_DataSize);
- return true;
-}
-
-
-
-
-
-void cChunkExtract::OpenAnvilFile(int a_AnvilX, int a_AnvilZ)
-{
- mAnvilFile.Close();
- AString FileName = Printf("%s/r.%d.%d.mca", mWorldFolder.c_str(), a_AnvilX, a_AnvilZ);
- if (!mAnvilFile.Open(FileName, cFile::fmRead))
- {
- LOG("Cannot open Anvil file \"%s\" for reading", FileName.c_str());
- }
- mCurAnvilX = a_AnvilX;
- mCurAnvilZ = a_AnvilZ;
+
+// ChunkExtract.cpp
+
+// Implements the cChunkExtract class representing a cCallback descendant that extracts raw chunk data into separate .chunk files
+
+#include "Globals.h"
+#include "ChunkExtract.h"
+#include "../../source/OSSupport/GZipFile.h"
+
+
+
+
+
+cChunkExtract::cChunkExtract(const AString & iWorldFolder) :
+ mWorldFolder(iWorldFolder)
+{
+}
+
+
+
+
+
+bool cChunkExtract::OnNewChunk(int a_ChunkX, int a_ChunkZ)
+{
+ int AnvilX = (a_ChunkX - ((a_ChunkX > 0) ? 0 : 31)) / 32;
+ int AnvilZ = (a_ChunkZ - ((a_ChunkZ > 0) ? 0 : 31)) / 32;
+ if ((AnvilX != mCurAnvilX) || (AnvilZ != mCurAnvilZ))
+ {
+ OpenAnvilFile(AnvilX, AnvilZ);
+ }
+ mCurChunkX = a_ChunkX;
+ mCurChunkZ = a_ChunkZ;
+ return false;
+}
+
+
+
+
+
+bool cChunkExtract::OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod)
+{
+ if (!mAnvilFile.IsOpen())
+ {
+ return true;
+ }
+ cFile ChunkFile;
+ AString ChunkPath = Printf("%d.%d.zchunk", mCurChunkX, mCurChunkZ);
+ if (!ChunkFile.Open(ChunkPath, cFile::fmWrite))
+ {
+ LOG("Cannot open zchunk file \"%s\" for writing. Chunk [%d, %d] skipped.", ChunkPath.c_str(), mCurChunkX, mCurChunkZ);
+ return false;
+ }
+
+ // Copy data from mAnvilFile to ChunkFile:
+ mAnvilFile.Seek(a_DataOffset);
+ for (int BytesToCopy = a_CompressedDataSize; BytesToCopy > 0; )
+ {
+ char Buffer[64000];
+ int NumBytes = std::min(BytesToCopy, (int)sizeof(Buffer));
+ int BytesRead = mAnvilFile.Read(Buffer, NumBytes);
+ if (BytesRead != NumBytes)
+ {
+ LOG("Cannot copy chunk data, chunk [%d, %d] is probably corrupted. Skipping chunk.", mCurChunkX, mCurChunkZ);
+ return false;
+ }
+ ChunkFile.Write(Buffer, BytesRead);
+ BytesToCopy -= BytesRead;
+ } // for BytesToCopy
+ return false;
+}
+
+
+
+
+
+bool cChunkExtract::OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize)
+{
+ ASSERT(mAnvilFile.IsOpen()); // If it weren't, the OnCompressedDataSizePos would've prevented this from running
+ AString FileName = Printf("%d.%d.gzchunk", mCurChunkX, mCurChunkZ);
+ cGZipFile GZipChunk;
+ if (!GZipChunk.Open(FileName, cGZipFile::fmWrite))
+ {
+ LOG("Cannot open gzchunk file \"%s\" for writing. Chunk [%d, %d] skipped.", FileName.c_str(), mCurChunkX, mCurChunkZ);
+ return true;
+ }
+ GZipChunk.Write(a_DecompressedNBT, a_DataSize);
+ return true;
+}
+
+
+
+
+
+void cChunkExtract::OpenAnvilFile(int a_AnvilX, int a_AnvilZ)
+{
+ mAnvilFile.Close();
+ AString FileName = Printf("%s/r.%d.%d.mca", mWorldFolder.c_str(), a_AnvilX, a_AnvilZ);
+ if (!mAnvilFile.Open(FileName, cFile::fmRead))
+ {
+ LOG("Cannot open Anvil file \"%s\" for reading", FileName.c_str());
+ }
+ mCurAnvilX = a_AnvilX;
+ mCurAnvilZ = a_AnvilZ;
} \ No newline at end of file
diff --git a/Tools/AnvilStats/ChunkExtract.h b/Tools/AnvilStats/ChunkExtract.h
index 5e0ed8a9a..767523354 100644
--- a/Tools/AnvilStats/ChunkExtract.h
+++ b/Tools/AnvilStats/ChunkExtract.h
@@ -1,66 +1,66 @@
-
-// ChunkExtract.h
-
-// Declares the cChunkExtract class representing a cCallback descendant that extracts raw chunk data into separate .chunk files
-
-
-
-
-
-#pragma once
-
-#include "Callback.h"
-
-
-
-
-
-class cChunkExtract :
- public cCallback
-{
-public:
- cChunkExtract(const AString & iWorldFolder);
-
-protected:
- AString mWorldFolder;
- cFile mAnvilFile;
- int mCurAnvilX; // X-coord of mAnvilFile, in Anvil-coords (1 Anvil-coord = 32 chunks)
- int mCurAnvilZ; // Z-coord of mAnvilFile, -"-
- int mCurChunkX; // X-coord of the chunk being processed
- int mCurChunkZ; // Z-coord of the chunk being processed
-
- /// Opens new anvil file into mAnvilFile, sets mCurAnvilX and mCurAnvilZ
- void OpenAnvilFile(int a_AnvilX, int a_AnvilZ);
-
- // cCallback overrides:
- virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
- virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override;
- virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override;
-} ;
-
-
-
-
-
-class cChunkExtractFactory :
- public cCallbackFactory
-{
-public:
- cChunkExtractFactory(const AString & iWorldFolder) :
- mWorldFolder(iWorldFolder)
- {
- }
-
- virtual cCallback * CreateNewCallback(void) override
- {
- return new cChunkExtract(mWorldFolder);
- }
-
-protected:
- AString mWorldFolder;
-} ;
-
-
-
-
+
+// ChunkExtract.h
+
+// Declares the cChunkExtract class representing a cCallback descendant that extracts raw chunk data into separate .chunk files
+
+
+
+
+
+#pragma once
+
+#include "Callback.h"
+
+
+
+
+
+class cChunkExtract :
+ public cCallback
+{
+public:
+ cChunkExtract(const AString & iWorldFolder);
+
+protected:
+ AString mWorldFolder;
+ cFile mAnvilFile;
+ int mCurAnvilX; // X-coord of mAnvilFile, in Anvil-coords (1 Anvil-coord = 32 chunks)
+ int mCurAnvilZ; // Z-coord of mAnvilFile, -"-
+ int mCurChunkX; // X-coord of the chunk being processed
+ int mCurChunkZ; // Z-coord of the chunk being processed
+
+ /// Opens new anvil file into mAnvilFile, sets mCurAnvilX and mCurAnvilZ
+ void OpenAnvilFile(int a_AnvilX, int a_AnvilZ);
+
+ // cCallback overrides:
+ virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
+ virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override;
+ virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override;
+} ;
+
+
+
+
+
+class cChunkExtractFactory :
+ public cCallbackFactory
+{
+public:
+ cChunkExtractFactory(const AString & iWorldFolder) :
+ mWorldFolder(iWorldFolder)
+ {
+ }
+
+ virtual cCallback * CreateNewCallback(void) override
+ {
+ return new cChunkExtract(mWorldFolder);
+ }
+
+protected:
+ AString mWorldFolder;
+} ;
+
+
+
+
diff --git a/Tools/AnvilStats/Globals.cpp b/Tools/AnvilStats/Globals.cpp
index 2c60fd698..13c6ae709 100644
--- a/Tools/AnvilStats/Globals.cpp
+++ b/Tools/AnvilStats/Globals.cpp
@@ -1,10 +1,10 @@
-
-// Globals.cpp
-
-// This file is used for precompiled header generation in MSVC environments
-
-#include "Globals.h"
-
-
-
-
+
+// Globals.cpp
+
+// This file is used for precompiled header generation in MSVC environments
+
+#include "Globals.h"
+
+
+
+
diff --git a/Tools/AnvilStats/Globals.h b/Tools/AnvilStats/Globals.h
index b9d37e029..db5d3c635 100644
--- a/Tools/AnvilStats/Globals.h
+++ b/Tools/AnvilStats/Globals.h
@@ -1,228 +1,228 @@
-
-// Globals.h
-
-// This file gets included from every module in the project, so that global symbols may be introduced easily
-// Also used for precompiled header generation in MSVC environments
-
-
-
-
-
-// Compiler-dependent stuff:
-#if defined(_MSC_VER)
- // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
- #pragma warning(disable:4481)
-
- // Disable some warnings that we don't care about:
- #pragma warning(disable:4100)
-
- #define _CRT_SECURE_NO_WARNINGS
-
- #define OBSOLETE __declspec(deprecated)
-
- // No alignment needed in MSVC
- #define ALIGN_8
- #define ALIGN_16
-
-#elif defined(__GNUC__)
-
- // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
- #define abstract
-
- // TODO: Can GCC mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
- #define override
-
- #define OBSOLETE __attribute__((deprecated))
-
- #define ALIGN_8 __attribute__((aligned(8)))
- #define ALIGN_16 __attribute__((aligned(16)))
-
- // Some portability macros :)
- #define stricmp strcasecmp
-
-#else
-
- #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
-
- /*
- // Copy and uncomment this into another #elif section based on your compiler identification
-
- // Explicitly mark classes as abstract (no instances can be created)
- #define abstract
-
- // Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
- #define override
-
- // Mark functions as obsolete, so that their usage results in a compile-time warning
- #define OBSOLETE
-
- // Mark types / variables for alignment. Do the platforms need it?
- #define ALIGN_8
- #define ALIGN_16
- */
-
-#endif
-
-
-
-
-
-// Integral types with predefined sizes:
-typedef long long Int64;
-typedef int Int32;
-typedef short Int16;
-
-typedef unsigned long long UInt64;
-typedef unsigned int UInt32;
-typedef unsigned short UInt16;
-
-
-
-
-
-// A macro to disallow the copy constructor and operator= functions
-// This should be used in the private: declarations for any class that shouldn't allow copying itself
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName &); \
- void operator=(const TypeName &)
-
-// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
-#define UNUSED(X) (void)(X)
-
-
-
-
-// OS-dependent stuff:
-#ifdef _WIN32
- #define WIN32_LEAN_AND_MEAN
- #include <Windows.h>
- #include <winsock2.h>
-
- // Windows SDK defines min and max macros, messing up with our std::min and std::max usage
- #undef min
- #undef max
-
- // Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant
- #ifdef GetFreeSpace
- #undef GetFreeSpace
- #endif // GetFreeSpace
-#else
- #include <sys/types.h>
- #include <sys/stat.h> // for mkdir
- #include <sys/time.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <time.h>
- #include <dirent.h>
- #include <errno.h>
- #include <iostream>
-
- #include <cstdio>
- #include <cstring>
- #include <pthread.h>
- #include <semaphore.h>
- #include <errno.h>
- #include <fcntl.h>
-#endif
-
-
-
-
-
-#define FILE_IO_PREFIX ""
-
-
-
-
-
-// CRT stuff:
-#include <assert.h>
-#include <stdio.h>
-#include <math.h>
-#include <stdarg.h>
-
-
-
-
-
-// STL stuff:
-#include <vector>
-#include <list>
-#include <deque>
-#include <string>
-#include <map>
-#include <algorithm>
-#include <memory>
-#include <ctime>
-
-
-
-
-
-// Common headers (part 1, without macros):
-#include "../../source/StringUtils.h"
-#include "../../source/OSSupport/CriticalSection.h"
-#include "../../source/OSSupport/Semaphore.h"
-#include "../../source/OSSupport/Event.h"
-#include "../../source/OSSupport/IsThread.h"
-#include "../../source/OSSupport/File.h"
-
-
-
-
-
-// Common definitions:
-
-#define LOG(x,...) printf(x "\n", __VA_ARGS__)
-#define LOGERROR LOG
-#define LOGWARNING LOG
-#define LOGINFO LOG
-#define LOGWARN LOG
-
-/// 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)" )
-#define KiB * 1024
-
-/// Allows arithmetic expressions like "32 MiB" (but consider using parenthesis around it, "(32 MiB)" )
-#define MiB * 1024 * 1024
-
-/// Faster than (int)floorf((float)x / (float)div)
-#define FAST_FLOOR_DIV( x, div ) ( (x) < 0 ? (((int)x / div) - 1) : ((int)x / 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 ) )
-#else
- #define ASSERT(x) ((void)0)
-#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 ) )
-
-
-
-
-
-/// A generic interface used mainly in ForEach() functions
-template <typename Type> class cItemCallback
-{
-public:
- /// Called for each item in the internal list; return true to stop the loop, or false to continue enumerating
- virtual bool Item(Type * a_Type) = 0;
-} ;
-
-
-
-
-
-// Common headers (part 2, with macros):
-#include "../../source/ChunkDef.h"
-#include "../../source/BlockID.h"
-
-
-
-
+
+// Globals.h
+
+// This file gets included from every module in the project, so that global symbols may be introduced easily
+// Also used for precompiled header generation in MSVC environments
+
+
+
+
+
+// Compiler-dependent stuff:
+#if defined(_MSC_VER)
+ // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
+ #pragma warning(disable:4481)
+
+ // Disable some warnings that we don't care about:
+ #pragma warning(disable:4100)
+
+ #define _CRT_SECURE_NO_WARNINGS
+
+ #define OBSOLETE __declspec(deprecated)
+
+ // No alignment needed in MSVC
+ #define ALIGN_8
+ #define ALIGN_16
+
+#elif defined(__GNUC__)
+
+ // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
+ #define abstract
+
+ // TODO: Can GCC mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
+ #define override
+
+ #define OBSOLETE __attribute__((deprecated))
+
+ #define ALIGN_8 __attribute__((aligned(8)))
+ #define ALIGN_16 __attribute__((aligned(16)))
+
+ // Some portability macros :)
+ #define stricmp strcasecmp
+
+#else
+
+ #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
+
+ /*
+ // Copy and uncomment this into another #elif section based on your compiler identification
+
+ // Explicitly mark classes as abstract (no instances can be created)
+ #define abstract
+
+ // Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
+ #define override
+
+ // Mark functions as obsolete, so that their usage results in a compile-time warning
+ #define OBSOLETE
+
+ // Mark types / variables for alignment. Do the platforms need it?
+ #define ALIGN_8
+ #define ALIGN_16
+ */
+
+#endif
+
+
+
+
+
+// Integral types with predefined sizes:
+typedef long long Int64;
+typedef int Int32;
+typedef short Int16;
+
+typedef unsigned long long UInt64;
+typedef unsigned int UInt32;
+typedef unsigned short UInt16;
+
+
+
+
+
+// A macro to disallow the copy constructor and operator= functions
+// This should be used in the private: declarations for any class that shouldn't allow copying itself
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName &); \
+ void operator=(const TypeName &)
+
+// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
+#define UNUSED(X) (void)(X)
+
+
+
+
+// OS-dependent stuff:
+#ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <Windows.h>
+ #include <winsock2.h>
+
+ // Windows SDK defines min and max macros, messing up with our std::min and std::max usage
+ #undef min
+ #undef max
+
+ // Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant
+ #ifdef GetFreeSpace
+ #undef GetFreeSpace
+ #endif // GetFreeSpace
+#else
+ #include <sys/types.h>
+ #include <sys/stat.h> // for mkdir
+ #include <sys/time.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <netdb.h>
+ #include <time.h>
+ #include <dirent.h>
+ #include <errno.h>
+ #include <iostream>
+
+ #include <cstdio>
+ #include <cstring>
+ #include <pthread.h>
+ #include <semaphore.h>
+ #include <errno.h>
+ #include <fcntl.h>
+#endif
+
+
+
+
+
+#define FILE_IO_PREFIX ""
+
+
+
+
+
+// CRT stuff:
+#include <assert.h>
+#include <stdio.h>
+#include <math.h>
+#include <stdarg.h>
+
+
+
+
+
+// STL stuff:
+#include <vector>
+#include <list>
+#include <deque>
+#include <string>
+#include <map>
+#include <algorithm>
+#include <memory>
+#include <ctime>
+
+
+
+
+
+// Common headers (part 1, without macros):
+#include "../../source/StringUtils.h"
+#include "../../source/OSSupport/CriticalSection.h"
+#include "../../source/OSSupport/Semaphore.h"
+#include "../../source/OSSupport/Event.h"
+#include "../../source/OSSupport/IsThread.h"
+#include "../../source/OSSupport/File.h"
+
+
+
+
+
+// Common definitions:
+
+#define LOG(x,...) printf(x "\n", __VA_ARGS__)
+#define LOGERROR LOG
+#define LOGWARNING LOG
+#define LOGINFO LOG
+#define LOGWARN LOG
+
+/// 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)" )
+#define KiB * 1024
+
+/// Allows arithmetic expressions like "32 MiB" (but consider using parenthesis around it, "(32 MiB)" )
+#define MiB * 1024 * 1024
+
+/// Faster than (int)floorf((float)x / (float)div)
+#define FAST_FLOOR_DIV( x, div ) ( (x) < 0 ? (((int)x / div) - 1) : ((int)x / 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 ) )
+#else
+ #define ASSERT(x) ((void)0)
+#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 ) )
+
+
+
+
+
+/// A generic interface used mainly in ForEach() functions
+template <typename Type> class cItemCallback
+{
+public:
+ /// Called for each item in the internal list; return true to stop the loop, or false to continue enumerating
+ virtual bool Item(Type * a_Type) = 0;
+} ;
+
+
+
+
+
+// Common headers (part 2, with macros):
+#include "../../source/ChunkDef.h"
+#include "../../source/BlockID.h"
+
+
+
+
diff --git a/Tools/AnvilStats/HeightMap.cpp b/Tools/AnvilStats/HeightMap.cpp
index 9f52c2109..662ddf493 100644
--- a/Tools/AnvilStats/HeightMap.cpp
+++ b/Tools/AnvilStats/HeightMap.cpp
@@ -1,265 +1,265 @@
-
-// HeightMap.cpp
-
-// Implements the cHeightMap class representing a cCallback descendant that draws a B&W map of heights for the world
-
-#include "Globals.h"
-#include "HeightMap.h"
-
-
-
-
-static const unsigned char g_BMPHeader[] =
-{
- 0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-} ;
-
-
-
-
-
-cHeightMap::cHeightMap(void) :
- m_CurrentRegionX(0),
- m_CurrentRegionZ(0),
- m_IsCurrentRegionValid(false)
-{
-}
-
-
-
-
-
-void cHeightMap::Finish(void)
-{
- if (m_IsCurrentRegionValid)
- {
- StartNewRegion(0, 0);
- }
-}
-
-
-
-
-
-bool cHeightMap::OnNewChunk(int a_ChunkX, int a_ChunkZ)
-{
- int RegionX = (a_ChunkX < 0) ? (a_ChunkX - 31) / 32 : a_ChunkX / 32;
- int RegionZ = (a_ChunkZ < 0) ? (a_ChunkZ - 31) / 32 : a_ChunkZ / 32;
- if ((RegionX != m_CurrentRegionX) || (RegionZ != m_CurrentRegionZ))
- {
- if (m_IsCurrentRegionValid)
- {
- StartNewRegion(RegionX, RegionZ);
- }
- m_CurrentRegionX = RegionX;
- m_CurrentRegionZ = RegionZ;
- }
- m_IsCurrentRegionValid = true;
- m_CurrentChunkX = a_ChunkX;
- m_CurrentChunkZ = a_ChunkZ;
- m_CurrentChunkOffX = m_CurrentChunkX - m_CurrentRegionX * 32;
- m_CurrentChunkOffZ = m_CurrentChunkZ - m_CurrentRegionZ * 32;
- memset(m_BlockTypes, 0, sizeof(m_BlockTypes));
- return false;
-}
-
-
-
-
-
-bool cHeightMap::OnHeightMap(const int * a_HeightMapBE)
-{
- ASSERT(m_CurrentChunkOffX >= 0);
- ASSERT(m_CurrentChunkOffX < 32);
- ASSERT(m_CurrentChunkOffZ >= 0);
- ASSERT(m_CurrentChunkOffZ < 32);
- int * BaseHeight = m_Height + m_CurrentChunkOffZ * 16 * 512 + m_CurrentChunkOffX * 16;
- for (int z = 0; z < 16; z++)
- {
- int * Row = BaseHeight + z * 512;
- for (int x = 0; x < 16; x++)
- {
- Row[x] = ntohl(a_HeightMapBE[z * 16 + x]);
- }
- } // for z
- return false; // Still want blockdata to remove trees from the heightmap
-}
-
-
-
-
-
-bool cHeightMap::OnSection(
- unsigned char a_Y,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockAdditional,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight
-)
-{
- // Copy the section data into the appropriate place in the internal buffer
- memcpy(m_BlockTypes + a_Y * 16 * 16 * 16, a_BlockTypes, 16 * 16 * 16);
- return false;
-}
-
-
-
-
-
-bool cHeightMap::OnSectionsFinished(void)
-{
- // Remove trees from the heightmap:
- for (int z = 0; z < 16; z++)
- {
- for (int x = 0; x < 16; x++)
- {
- for (int y = m_Height[512 * (16 * m_CurrentChunkOffZ + z) + 16 * m_CurrentChunkOffX + x]; y >= 0; y--)
- {
- if (IsGround(m_BlockTypes[256 * y + 16 * z + x]))
- {
- m_Height[512 * (16 * m_CurrentChunkOffZ + z) + 16 * m_CurrentChunkOffX + x] = y;
- break; // for y
- }
- } // for y
- } // for x
- } // for z
- return true;
-}
-
-
-
-
-
-void cHeightMap::StartNewRegion(int a_RegionX, int a_RegionZ)
-{
- AString FileName;
- Printf(FileName, "Height.%d.%d.bmp", m_CurrentRegionX, m_CurrentRegionZ);
- cFile f;
- if (!f.Open(FileName, cFile::fmWrite))
- {
- LOG("Cannot open file \"%s\" for writing the height map. Data for this region lost.", FileName.c_str());
- }
- else
- {
- f.Write(g_BMPHeader, sizeof(g_BMPHeader));
- for (int z = 0; z < 512; z++)
- {
- int RowData[512];
- int * HeightRow = m_Height + z * 512;
- for (int x = 0; x < 512; x++)
- {
- RowData[x] = std::max(std::min(HeightRow[x], 255), 0) * 0x010101;
- }
- f.Write(RowData, sizeof(RowData));
- } // for z
- }
-
- memset(m_Height, 0, sizeof(m_Height));
- m_CurrentRegionX = a_RegionX;
- m_CurrentRegionZ = a_RegionZ;
-}
-
-
-
-
-
-bool cHeightMap::IsGround(BLOCKTYPE a_BlockType)
-{
- // Name all blocks that are NOT ground, return false for them:
- switch (a_BlockType)
- {
- case E_BLOCK_AIR:
- case E_BLOCK_BED:
- case E_BLOCK_BREWING_STAND:
- case E_BLOCK_BROWN_MUSHROOM:
- case E_BLOCK_CACTUS:
- case E_BLOCK_CAKE:
- case E_BLOCK_CARROTS:
- case E_BLOCK_CAULDRON:
- case E_BLOCK_CHEST:
- case E_BLOCK_COBBLESTONE_WALL:
- case E_BLOCK_COBWEB:
- case E_BLOCK_COCOA_POD:
- case E_BLOCK_CROPS:
- case E_BLOCK_DEAD_BUSH:
- case E_BLOCK_DETECTOR_RAIL:
- case E_BLOCK_DIRT:
- case E_BLOCK_DRAGON_EGG:
- case E_BLOCK_END_PORTAL:
- case E_BLOCK_ENDER_CHEST:
- case E_BLOCK_FENCE:
- case E_BLOCK_FENCE_GATE:
- case E_BLOCK_FIRE:
- case E_BLOCK_FLOWER_POT:
- case E_BLOCK_HEAD:
- case E_BLOCK_IRON_BARS:
- case E_BLOCK_LADDER:
- case E_BLOCK_LAVA:
- case E_BLOCK_LEAVES:
- case E_BLOCK_LEVER:
- case E_BLOCK_LILY_PAD:
- case E_BLOCK_LOG: // NOTE: This block is actually solid, but we don't want it because it's the thing that trees are made of, and we're getting rid of trees
- case E_BLOCK_MELON:
- case E_BLOCK_MELON_STEM:
- case E_BLOCK_NETHER_BRICK_FENCE:
- case E_BLOCK_NETHER_PORTAL:
- case E_BLOCK_POWERED_RAIL:
- case E_BLOCK_PUMPKIN:
- case E_BLOCK_PUMPKIN_STEM:
- case E_BLOCK_RAIL:
- case E_BLOCK_RED_ROSE:
- case E_BLOCK_RED_MUSHROOM:
- case E_BLOCK_REDSTONE_REPEATER_OFF:
- case E_BLOCK_REDSTONE_REPEATER_ON:
- case E_BLOCK_REDSTONE_TORCH_OFF:
- case E_BLOCK_REDSTONE_TORCH_ON:
- case E_BLOCK_REDSTONE_WIRE:
- case E_BLOCK_REEDS:
- case E_BLOCK_SAPLING:
- case E_BLOCK_SIGN_POST:
- case E_BLOCK_SNOW:
- case E_BLOCK_STATIONARY_LAVA:
- case E_BLOCK_STATIONARY_WATER:
- case E_BLOCK_STONE_BUTTON:
- case E_BLOCK_STONE_PRESSURE_PLATE:
- case E_BLOCK_TALL_GRASS:
- case E_BLOCK_TORCH:
- case E_BLOCK_TRIPWIRE:
- case E_BLOCK_TRIPWIRE_HOOK:
- case E_BLOCK_VINES:
- case E_BLOCK_WALLSIGN:
- case E_BLOCK_WATER:
- case E_BLOCK_WOODEN_BUTTON:
- case E_BLOCK_WOODEN_PRESSURE_PLATE:
- case E_BLOCK_YELLOW_FLOWER:
- {
- return false;
- }
- }
- return true;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cHeightMapFactory:
-
-cHeightMapFactory::~cHeightMapFactory()
-{
- // Force all threads to save their last regions:
- for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
- {
- ((cHeightMap *)(*itr))->Finish();
- }
- // TODO: Join all the files into one giant image file
-}
-
-
-
-
+
+// HeightMap.cpp
+
+// Implements the cHeightMap class representing a cCallback descendant that draws a B&W map of heights for the world
+
+#include "Globals.h"
+#include "HeightMap.h"
+
+
+
+
+static const unsigned char g_BMPHeader[] =
+{
+ 0x42, 0x4D, 0x36, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+} ;
+
+
+
+
+
+cHeightMap::cHeightMap(void) :
+ m_CurrentRegionX(0),
+ m_CurrentRegionZ(0),
+ m_IsCurrentRegionValid(false)
+{
+}
+
+
+
+
+
+void cHeightMap::Finish(void)
+{
+ if (m_IsCurrentRegionValid)
+ {
+ StartNewRegion(0, 0);
+ }
+}
+
+
+
+
+
+bool cHeightMap::OnNewChunk(int a_ChunkX, int a_ChunkZ)
+{
+ int RegionX = (a_ChunkX < 0) ? (a_ChunkX - 31) / 32 : a_ChunkX / 32;
+ int RegionZ = (a_ChunkZ < 0) ? (a_ChunkZ - 31) / 32 : a_ChunkZ / 32;
+ if ((RegionX != m_CurrentRegionX) || (RegionZ != m_CurrentRegionZ))
+ {
+ if (m_IsCurrentRegionValid)
+ {
+ StartNewRegion(RegionX, RegionZ);
+ }
+ m_CurrentRegionX = RegionX;
+ m_CurrentRegionZ = RegionZ;
+ }
+ m_IsCurrentRegionValid = true;
+ m_CurrentChunkX = a_ChunkX;
+ m_CurrentChunkZ = a_ChunkZ;
+ m_CurrentChunkOffX = m_CurrentChunkX - m_CurrentRegionX * 32;
+ m_CurrentChunkOffZ = m_CurrentChunkZ - m_CurrentRegionZ * 32;
+ memset(m_BlockTypes, 0, sizeof(m_BlockTypes));
+ return false;
+}
+
+
+
+
+
+bool cHeightMap::OnHeightMap(const int * a_HeightMapBE)
+{
+ ASSERT(m_CurrentChunkOffX >= 0);
+ ASSERT(m_CurrentChunkOffX < 32);
+ ASSERT(m_CurrentChunkOffZ >= 0);
+ ASSERT(m_CurrentChunkOffZ < 32);
+ int * BaseHeight = m_Height + m_CurrentChunkOffZ * 16 * 512 + m_CurrentChunkOffX * 16;
+ for (int z = 0; z < 16; z++)
+ {
+ int * Row = BaseHeight + z * 512;
+ for (int x = 0; x < 16; x++)
+ {
+ Row[x] = ntohl(a_HeightMapBE[z * 16 + x]);
+ }
+ } // for z
+ return false; // Still want blockdata to remove trees from the heightmap
+}
+
+
+
+
+
+bool cHeightMap::OnSection(
+ unsigned char a_Y,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockAdditional,
+ const NIBBLETYPE * a_BlockMeta,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_BlockSkyLight
+)
+{
+ // Copy the section data into the appropriate place in the internal buffer
+ memcpy(m_BlockTypes + a_Y * 16 * 16 * 16, a_BlockTypes, 16 * 16 * 16);
+ return false;
+}
+
+
+
+
+
+bool cHeightMap::OnSectionsFinished(void)
+{
+ // Remove trees from the heightmap:
+ for (int z = 0; z < 16; z++)
+ {
+ for (int x = 0; x < 16; x++)
+ {
+ for (int y = m_Height[512 * (16 * m_CurrentChunkOffZ + z) + 16 * m_CurrentChunkOffX + x]; y >= 0; y--)
+ {
+ if (IsGround(m_BlockTypes[256 * y + 16 * z + x]))
+ {
+ m_Height[512 * (16 * m_CurrentChunkOffZ + z) + 16 * m_CurrentChunkOffX + x] = y;
+ break; // for y
+ }
+ } // for y
+ } // for x
+ } // for z
+ return true;
+}
+
+
+
+
+
+void cHeightMap::StartNewRegion(int a_RegionX, int a_RegionZ)
+{
+ AString FileName;
+ Printf(FileName, "Height.%d.%d.bmp", m_CurrentRegionX, m_CurrentRegionZ);
+ cFile f;
+ if (!f.Open(FileName, cFile::fmWrite))
+ {
+ LOG("Cannot open file \"%s\" for writing the height map. Data for this region lost.", FileName.c_str());
+ }
+ else
+ {
+ f.Write(g_BMPHeader, sizeof(g_BMPHeader));
+ for (int z = 0; z < 512; z++)
+ {
+ int RowData[512];
+ int * HeightRow = m_Height + z * 512;
+ for (int x = 0; x < 512; x++)
+ {
+ RowData[x] = std::max(std::min(HeightRow[x], 255), 0) * 0x010101;
+ }
+ f.Write(RowData, sizeof(RowData));
+ } // for z
+ }
+
+ memset(m_Height, 0, sizeof(m_Height));
+ m_CurrentRegionX = a_RegionX;
+ m_CurrentRegionZ = a_RegionZ;
+}
+
+
+
+
+
+bool cHeightMap::IsGround(BLOCKTYPE a_BlockType)
+{
+ // Name all blocks that are NOT ground, return false for them:
+ switch (a_BlockType)
+ {
+ case E_BLOCK_AIR:
+ case E_BLOCK_BED:
+ case E_BLOCK_BREWING_STAND:
+ case E_BLOCK_BROWN_MUSHROOM:
+ case E_BLOCK_CACTUS:
+ case E_BLOCK_CAKE:
+ case E_BLOCK_CARROTS:
+ case E_BLOCK_CAULDRON:
+ case E_BLOCK_CHEST:
+ case E_BLOCK_COBBLESTONE_WALL:
+ case E_BLOCK_COBWEB:
+ case E_BLOCK_COCOA_POD:
+ case E_BLOCK_CROPS:
+ case E_BLOCK_DEAD_BUSH:
+ case E_BLOCK_DETECTOR_RAIL:
+ case E_BLOCK_DIRT:
+ case E_BLOCK_DRAGON_EGG:
+ case E_BLOCK_END_PORTAL:
+ case E_BLOCK_ENDER_CHEST:
+ case E_BLOCK_FENCE:
+ case E_BLOCK_FENCE_GATE:
+ case E_BLOCK_FIRE:
+ case E_BLOCK_FLOWER_POT:
+ case E_BLOCK_HEAD:
+ case E_BLOCK_IRON_BARS:
+ case E_BLOCK_LADDER:
+ case E_BLOCK_LAVA:
+ case E_BLOCK_LEAVES:
+ case E_BLOCK_LEVER:
+ case E_BLOCK_LILY_PAD:
+ case E_BLOCK_LOG: // NOTE: This block is actually solid, but we don't want it because it's the thing that trees are made of, and we're getting rid of trees
+ case E_BLOCK_MELON:
+ case E_BLOCK_MELON_STEM:
+ case E_BLOCK_NETHER_BRICK_FENCE:
+ case E_BLOCK_NETHER_PORTAL:
+ case E_BLOCK_POWERED_RAIL:
+ case E_BLOCK_PUMPKIN:
+ case E_BLOCK_PUMPKIN_STEM:
+ case E_BLOCK_RAIL:
+ case E_BLOCK_RED_ROSE:
+ case E_BLOCK_RED_MUSHROOM:
+ case E_BLOCK_REDSTONE_REPEATER_OFF:
+ case E_BLOCK_REDSTONE_REPEATER_ON:
+ case E_BLOCK_REDSTONE_TORCH_OFF:
+ case E_BLOCK_REDSTONE_TORCH_ON:
+ case E_BLOCK_REDSTONE_WIRE:
+ case E_BLOCK_REEDS:
+ case E_BLOCK_SAPLING:
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_SNOW:
+ case E_BLOCK_STATIONARY_LAVA:
+ case E_BLOCK_STATIONARY_WATER:
+ case E_BLOCK_STONE_BUTTON:
+ case E_BLOCK_STONE_PRESSURE_PLATE:
+ case E_BLOCK_TALL_GRASS:
+ case E_BLOCK_TORCH:
+ case E_BLOCK_TRIPWIRE:
+ case E_BLOCK_TRIPWIRE_HOOK:
+ case E_BLOCK_VINES:
+ case E_BLOCK_WALLSIGN:
+ case E_BLOCK_WATER:
+ case E_BLOCK_WOODEN_BUTTON:
+ case E_BLOCK_WOODEN_PRESSURE_PLATE:
+ case E_BLOCK_YELLOW_FLOWER:
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cHeightMapFactory:
+
+cHeightMapFactory::~cHeightMapFactory()
+{
+ // Force all threads to save their last regions:
+ for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
+ {
+ ((cHeightMap *)(*itr))->Finish();
+ }
+ // TODO: Join all the files into one giant image file
+}
+
+
+
+
diff --git a/Tools/AnvilStats/HeightMap.h b/Tools/AnvilStats/HeightMap.h
index 4f9e702d5..c0e71cbc1 100644
--- a/Tools/AnvilStats/HeightMap.h
+++ b/Tools/AnvilStats/HeightMap.h
@@ -1,81 +1,81 @@
-
-// HeightMap.h
-
-// Declares the cHeightMap class representing a cCallback descendant that draws a B&W map of heights for the world
-
-
-
-
-
-#pragma once
-
-#include "Callback.h"
-
-
-
-
-
-class cHeightMap :
- public cCallback
-{
-public:
- cHeightMap(void);
-
- void Finish(void);
-
-protected:
- int m_CurrentChunkX; // Absolute chunk coords
- int m_CurrentChunkZ;
- int m_CurrentChunkOffX; // Chunk offset from the start of the region
- int m_CurrentChunkOffZ;
- int m_CurrentRegionX;
- int m_CurrentRegionZ;
- bool m_IsCurrentRegionValid;
- int m_Height[16 * 32 * 16 * 32]; ///< Height-map of the entire current region [x + 16 * 32 * z]
- BLOCKTYPE m_BlockTypes[16 * 16 * 256]; ///< Block data of the currently processed chunk (between OnSection() and OnSectionsFinished() )
-
- // cCallback overrides:
- virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
- virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
- virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
- virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
- virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
- virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
- virtual bool OnBiomes(const unsigned char * a_BiomeData) { return false; }
- virtual bool OnHeightMap(const int * a_HeightMapBE) override;
- virtual bool OnSection(
- unsigned char a_Y,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockAdditional,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight
- ) override;
- virtual bool OnSectionsFinished(void) override;
-
- void StartNewRegion(int a_RegionX, int a_RegionZ);
-
- static bool IsGround(BLOCKTYPE a_BlockType);
-} ;
-
-
-
-
-
-class cHeightMapFactory :
- public cCallbackFactory
-{
-public:
- virtual ~cHeightMapFactory();
-
- virtual cCallback * CreateNewCallback(void) override
- {
- return new cHeightMap;
- }
-
-} ;
-
-
-
-
+
+// HeightMap.h
+
+// Declares the cHeightMap class representing a cCallback descendant that draws a B&W map of heights for the world
+
+
+
+
+
+#pragma once
+
+#include "Callback.h"
+
+
+
+
+
+class cHeightMap :
+ public cCallback
+{
+public:
+ cHeightMap(void);
+
+ void Finish(void);
+
+protected:
+ int m_CurrentChunkX; // Absolute chunk coords
+ int m_CurrentChunkZ;
+ int m_CurrentChunkOffX; // Chunk offset from the start of the region
+ int m_CurrentChunkOffZ;
+ int m_CurrentRegionX;
+ int m_CurrentRegionZ;
+ bool m_IsCurrentRegionValid;
+ int m_Height[16 * 32 * 16 * 32]; ///< Height-map of the entire current region [x + 16 * 32 * z]
+ BLOCKTYPE m_BlockTypes[16 * 16 * 256]; ///< Block data of the currently processed chunk (between OnSection() and OnSectionsFinished() )
+
+ // cCallback overrides:
+ virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
+ virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
+ virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
+ virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
+ virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
+ virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
+ virtual bool OnBiomes(const unsigned char * a_BiomeData) { return false; }
+ virtual bool OnHeightMap(const int * a_HeightMapBE) override;
+ virtual bool OnSection(
+ unsigned char a_Y,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockAdditional,
+ const NIBBLETYPE * a_BlockMeta,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_BlockSkyLight
+ ) override;
+ virtual bool OnSectionsFinished(void) override;
+
+ void StartNewRegion(int a_RegionX, int a_RegionZ);
+
+ static bool IsGround(BLOCKTYPE a_BlockType);
+} ;
+
+
+
+
+
+class cHeightMapFactory :
+ public cCallbackFactory
+{
+public:
+ virtual ~cHeightMapFactory();
+
+ virtual cCallback * CreateNewCallback(void) override
+ {
+ return new cHeightMap;
+ }
+
+} ;
+
+
+
+
diff --git a/Tools/AnvilStats/Processor.cpp b/Tools/AnvilStats/Processor.cpp
index d6c793182..e7f7eb21d 100644
--- a/Tools/AnvilStats/Processor.cpp
+++ b/Tools/AnvilStats/Processor.cpp
@@ -1,579 +1,579 @@
-
-// Processor.cpp
-
-// Implements the cProcessor class representing the overall processor engine that manages threads, calls callbacks etc.
-
-#include "Globals.h"
-#include "Processor.h"
-#include "Callback.h"
-#include "../../source/WorldStorage/FastNBT.h"
-#include "zlib.h"
-#include "Utils.h"
-
-
-
-
-
-const int CHUNK_INFLATE_MAX = 1 MiB;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cProcessor::cThread:
-
-cProcessor::cThread::cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor) :
- super("cProcessor::cThread"),
- m_Callback(a_Callback),
- m_ParentProcessor(a_ParentProcessor)
-{
- super::Start();
-}
-
-
-
-
-
-void cProcessor::cThread::Execute(void)
-{
- LOG("Started a new thread: %d", cIsThread::GetCurrentID());
-
- m_ParentProcessor.m_ThreadsHaveStarted.Set();
-
- for (;;)
- {
- AString FileName = m_ParentProcessor.GetOneFileName();
- if (FileName.empty())
- {
- // All done, terminate the thread
- break;
- }
- ProcessFile(FileName);
- } // for-ever
-
- LOG("Thread %d terminated", cIsThread::GetCurrentID());
-}
-
-
-
-
-
-void cProcessor::cThread::ProcessFile(const AString & a_FileName)
-{
- LOG("Processing file \"%s\"", a_FileName.c_str());
-
- size_t idx = a_FileName.rfind("r.");
- if (idx == AString::npos)
- {
- LOG("Cannot parse filename \"%s\", skipping file.", a_FileName.c_str());
- return;
- }
- int RegionX = 0, RegionZ = 0;
- if (sscanf_s(a_FileName.c_str() + idx, "r.%d.%d.mca", &RegionX, &RegionZ) != 2)
- {
- LOG("Cannot parse filename \"%s\" into coords, skipping file.", a_FileName.c_str());
- return;
- }
-
- cFile f;
- if (!f.Open(a_FileName, cFile::fmRead))
- {
- LOG("Cannot open file \"%s\", skipping file.", a_FileName.c_str());
- return;
- }
-
- AString FileContents;
- f.ReadRestOfFile(FileContents);
- if (FileContents.size() < sizeof(8 KiB))
- {
- LOG("Cannot read header in file \"%s\", skipping file.", a_FileName.c_str());
- return;
- }
-
- ProcessFileData(FileContents.data(), FileContents.size(), RegionX * 32, RegionZ * 32);
-}
-
-
-
-
-
-void cProcessor::cThread::ProcessFileData(const char * a_FileData, size_t a_Size, int a_ChunkBaseX, int a_ChunkBaseZ)
-{
- int Header[2048];
- int * HeaderPtr = (int *)a_FileData;
- for (int i = 0; i < ARRAYCOUNT(Header); i++)
- {
- Header[i] = ntohl(HeaderPtr[i]);
- }
-
- for (int i = 0; i < 1024; i++)
- {
- unsigned Location = Header[i];
- unsigned Timestamp = Header[i + 1024];
- if (
- ((Location == 0) && (Timestamp == 0)) || // Official docs' "not present"
- (Location >> 8 < 2) || // Logical - no chunk can start inside the header
- ((Location & 0xff) == 0) || // Logical - no chunk can be zero bytes
- ((Location >> 8) * 4096 > a_Size) // Logical - no chunk can start at beyond the file end
- )
- {
- // Chunk not present in the file
- continue;
- }
- int ChunkX = a_ChunkBaseX + (i % 32);
- int ChunkZ = a_ChunkBaseZ + (i / 32);
- if (m_Callback.OnNewChunk(ChunkX, ChunkZ))
- {
- continue;
- }
- ProcessChunk(a_FileData, ChunkX, ChunkZ, Location >> 8, Location & 0xff, Timestamp);
- } // for i - chunk index
-}
-
-
-
-
-
-void cProcessor::cThread::ProcessChunk(const char * a_FileData, int a_ChunkX, int a_ChunkZ, unsigned a_SectorStart, unsigned a_SectorSize, unsigned a_TimeStamp)
-{
- if (m_Callback.OnHeader(a_SectorStart * 4096, a_SectorSize, a_TimeStamp))
- {
- return;
- }
-
- const char * ChunkStart = a_FileData + a_SectorStart * 4096;
- int ByteSize = ntohl(*(int *)ChunkStart);
- char CompressionMethod = ChunkStart[4];
-
- if (m_Callback.OnCompressedDataSizePos(ByteSize, a_SectorStart * 4096 + 5, CompressionMethod))
- {
- return;
- }
-
- ProcessCompressedChunkData(a_ChunkX, a_ChunkZ, ChunkStart + 5, ByteSize);
-}
-
-
-
-
-
-void cProcessor::cThread::ProcessCompressedChunkData(int a_ChunkX, int a_ChunkZ, const char * a_CompressedData, int a_CompressedSize)
-{
- char Decompressed[CHUNK_INFLATE_MAX];
- z_stream strm;
- strm.zalloc = (alloc_func)NULL;
- strm.zfree = (free_func)NULL;
- strm.opaque = NULL;
- inflateInit(&strm);
- strm.next_out = (Bytef *)Decompressed;
- strm.avail_out = sizeof(Decompressed);
- strm.next_in = (Bytef *)a_CompressedData;
- strm.avail_in = a_CompressedSize;
- int res = inflate(&strm, Z_FINISH);
- inflateEnd(&strm);
- if (res != Z_STREAM_END)
- {
- LOG("Decompression failed, skipping chunk [%d, %d]", a_ChunkX, a_ChunkZ);
- return;
- }
-
- if (m_Callback.OnDecompressedData(Decompressed, strm.total_out))
- {
- return;
- }
-
- // Parse the NBT data:
- cParsedNBT NBT(Decompressed, strm.total_out);
- if (!NBT.IsValid())
- {
- LOG("NBT Parsing failed, skipping chunk [%d, %d]", a_ChunkX, a_ChunkZ);
- return;
- }
-
- ProcessParsedChunkData(a_ChunkX, a_ChunkZ, NBT);
-}
-
-
-
-
-
-void cProcessor::cThread::ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT)
-{
- int LevelTag = a_NBT.FindChildByName(0, "Level");
- if (LevelTag < 0)
- {
- LOG("Bad logical structure of the NBT, skipping chunk [%d, %d].", a_ChunkX, a_ChunkZ);
- return;
- }
- int XPosTag = a_NBT.FindChildByName(LevelTag, "xPos");
- int ZPosTag = a_NBT.FindChildByName(LevelTag, "zPos");
- if ((XPosTag < 0) || (ZPosTag < 0))
- {
- LOG("Pos tags missing in NTB, skipping chunk [%d, %d].", a_ChunkX, a_ChunkZ);
- return;
- }
- if (m_Callback.OnRealCoords(a_NBT.GetInt(XPosTag), a_NBT.GetInt(ZPosTag)))
- {
- return;
- }
-
- int LastUpdateTag = a_NBT.FindChildByName(LevelTag, "LastUpdate");
- if (LastUpdateTag > 0)
- {
- if (m_Callback.OnLastUpdate(a_NBT.GetLong(LastUpdateTag)))
- {
- return;
- }
- }
-
- int TerrainPopulatedTag = a_NBT.FindChildByName(LevelTag, "TerrainPopulated");
- bool TerrainPopulated = (TerrainPopulatedTag < 0) ? false : (a_NBT.GetByte(TerrainPopulatedTag) != 0);
- if (m_Callback.OnTerrainPopulated(TerrainPopulated))
- {
- return;
- }
-
- int BiomesTag = a_NBT.FindChildByName(LevelTag, "Biomes");
- if (BiomesTag > 0)
- {
- if (m_Callback.OnBiomes((const unsigned char *)(a_NBT.GetData(BiomesTag))))
- {
- return;
- }
- }
-
- int HeightMapTag = a_NBT.FindChildByName(LevelTag, "HeightMap");
- if (HeightMapTag > 0)
- {
- if (m_Callback.OnHeightMap((const int *)(a_NBT.GetData(HeightMapTag))))
- {
- return;
- }
- }
-
- if (ProcessChunkSections(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
- {
- return;
- }
-
- if (ProcessChunkEntities(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
- {
- return;
- }
-
- if (ProcessChunkTileEntities(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
- {
- return;
- }
-
- if (ProcessChunkTileTicks(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
- {
- return;
- }
-}
-
-
-
-
-
-bool cProcessor::cThread::ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag)
-{
- int Sections = a_NBT.FindChildByName(a_LevelTag, "Sections");
- if (Sections < 0)
- {
- return false;
- }
-
- bool SectionProcessed[16];
- memset(SectionProcessed, 0, sizeof(SectionProcessed));
- for (int Tag = a_NBT.GetFirstChild(Sections); Tag > 0; Tag = a_NBT.GetNextSibling(Tag))
- {
- int YTag = a_NBT.FindChildByName(Tag, "Y");
- int BlocksTag = a_NBT.FindChildByName(Tag, "Blocks");
- int AddTag = a_NBT.FindChildByName(Tag, "Add");
- int DataTag = a_NBT.FindChildByName(Tag, "Data");
- int BlockLightTag = a_NBT.FindChildByName(Tag, "BlockLightTag");
- int SkyLightTag = a_NBT.FindChildByName(Tag, "SkyLight");
-
- if ((YTag < 0) || (BlocksTag < 0) || (DataTag < 0))
- {
- continue;
- }
-
- unsigned char SectionY = a_NBT.GetByte(YTag);
- if (SectionY >= 16)
- {
- LOG("WARNING: Section Y >= 16 (%d), high world, wtf? Skipping section!", SectionY);
- continue;
- }
- if (m_Callback.OnSection(
- SectionY,
- (const BLOCKTYPE *) (a_NBT.GetData(BlocksTag)),
- (AddTag > 0) ? (const NIBBLETYPE *)(a_NBT.GetData(AddTag)) : NULL,
- (const NIBBLETYPE *)(a_NBT.GetData(DataTag)),
- (BlockLightTag > 0) ? (const NIBBLETYPE *)(a_NBT.GetData(BlockLightTag)) : NULL,
- (BlockLightTag > 0) ? (const NIBBLETYPE *)(a_NBT.GetData(BlockLightTag)) : NULL
- ))
- {
- return true;
- }
- SectionProcessed[SectionY] = true;
- } // for Tag - Sections[]
-
- // Call the callback for empty sections:
- for (unsigned char y = 0; y < 16; y++)
- {
- if (!SectionProcessed[y])
- {
- if (m_Callback.OnEmptySection(y))
- {
- return true;
- }
- }
- }
-
- if (m_Callback.OnSectionsFinished())
- {
- return true;
- }
-
- return false;
-}
-
-
-
-
-
-bool cProcessor::cThread::ProcessChunkEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag)
-{
- int EntitiesTag = a_NBT.FindChildByName(a_LevelTag, "Entities");
- if (EntitiesTag < 0)
- {
- return false;
- }
-
- for (int EntityTag = a_NBT.GetFirstChild(EntitiesTag); EntityTag > 0; EntityTag = a_NBT.GetNextSibling(EntityTag))
- {
- int PosTag = a_NBT.FindChildByName(EntityTag, "Pos");
- if (PosTag < 0)
- {
- continue;
- }
- int SpeedTag = a_NBT.FindChildByName(EntityTag, "Motion");
- if (SpeedTag < 0)
- {
- continue;
- }
- int RotTag = a_NBT.FindChildByName(EntityTag, "Rotation");
- if (RotTag < 0)
- {
- continue;
- }
- double Pos[3];
- for (int i = 0, tag = a_NBT.GetFirstChild(PosTag); (i < 3) && (tag > 0); i++)
- {
- Pos[i] = a_NBT.GetDouble(tag);
- }
- double Speed[3];
- for (int i = 0, tag = a_NBT.GetFirstChild(SpeedTag); (i < 3) && (tag > 0); i++)
- {
- Speed[i] = a_NBT.GetDouble(tag);
- }
- float Rot[2];
- for (int i = 0, tag = a_NBT.GetFirstChild(RotTag); (i < 2) && (tag > 0); i++)
- {
- Rot[i] = a_NBT.GetFloat(tag);
- }
-
- if (m_Callback.OnEntity(
- a_NBT.GetString(a_NBT.FindChildByName(EntityTag, "id")),
- Pos[0], Pos[1], Pos[2],
- Speed[0], Speed[1], Speed[2],
- Rot[0], Rot[1],
- a_NBT.GetFloat(a_NBT.FindChildByName(EntityTag, "FallDistance")),
- a_NBT.GetShort(a_NBT.FindChildByName(EntityTag, "Fire")),
- a_NBT.GetShort(a_NBT.FindChildByName(EntityTag, "Air")),
- a_NBT.GetByte(a_NBT.FindChildByName(EntityTag, "OnGround")),
- a_NBT, EntityTag
- ))
- {
- return true;
- }
- } // for EntityTag - Entities[]
- return false;
-}
-
-
-
-
-
-bool cProcessor::cThread::ProcessChunkTileEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag)
-{
- int TileEntitiesTag = a_NBT.FindChildByName(a_LevelTag, "TileEntities");
- if (TileEntitiesTag < 0)
- {
- return false;
- }
-
- for (int TileEntityTag = a_NBT.GetFirstChild(TileEntitiesTag); TileEntityTag > 0; TileEntityTag = a_NBT.GetNextSibling(TileEntityTag))
- {
- if (m_Callback.OnTileEntity(
- a_NBT.GetString(a_NBT.FindChildByName(TileEntityTag, "id")),
- a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "x")),
- a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "y")),
- a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "z")),
- a_NBT, TileEntityTag
- ))
- {
- return true;
- }
- } // for EntityTag - Entities[]
- return false;
-}
-
-
-
-
-
-bool cProcessor::cThread::ProcessChunkTileTicks(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag)
-{
- int TileTicksTag = a_NBT.FindChildByName(a_LevelTag, "TileTicks");
- if (TileTicksTag < 0)
- {
- return false;
- }
-
- for (int TileTickTag = a_NBT.GetFirstChild(TileTicksTag); TileTickTag > 0; TileTickTag = a_NBT.GetNextSibling(TileTickTag))
- {
- int iTag = a_NBT.FindChildByName(TileTicksTag, "i");
- int tTag = a_NBT.FindChildByName(TileTicksTag, "t");
- int xTag = a_NBT.FindChildByName(TileTicksTag, "x");
- int yTag = a_NBT.FindChildByName(TileTicksTag, "y");
- int zTag = a_NBT.FindChildByName(TileTicksTag, "z");
- if ((iTag < 0) || (tTag < 0) || (xTag < 0) || (yTag < 0) || (zTag < 0))
- {
- continue;
- }
- if (m_Callback.OnTileTick(
- a_NBT.GetInt(iTag),
- a_NBT.GetInt(iTag),
- a_NBT.GetInt(iTag),
- a_NBT.GetInt(iTag),
- a_NBT.GetInt(iTag)
- ))
- {
- return true;
- }
- } // for EntityTag - Entities[]
- return false;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cProcessor:
-
-cProcessor::cProcessor(void) :
- m_IsShuttingDown(false)
-{
-}
-
-
-
-
-
-cProcessor::~cProcessor()
-{
-}
-
-
-
-
-
-void cProcessor::ProcessWorld(const AString & a_WorldFolder, cCallbackFactory & a_CallbackFactory)
-{
- PopulateFileQueue(a_WorldFolder);
-
- if (m_FileQueue.empty())
- {
- LOG("No files to process, exitting.");
- return;
- }
-
- // Start as many threads as there are cores, plus one:
- // (One more thread can be in the file-read IO block while all other threads crunch the numbers)
- int NumThreads = GetNumCores() + 1;
-
- /*
- // Limit the number of threads in DEBUG mode to 1 for easier debugging
- #ifdef _DEBUG
- NumThreads = 1;
- #endif // _DEBUG
- //*/
-
- for (int i = 0; i < NumThreads; i++)
- {
- cCallback * Callback = a_CallbackFactory.GetNewCallback();
- m_Threads.push_back(new cThread(*Callback, *this));
- }
-
- // Wait for the first thread to start processing:
- m_ThreadsHaveStarted.Wait();
-
- // Wait for all threads to finish
- // simply by calling each thread's destructor sequentially
- LOG("Waiting for threads to finish");
- for (cThreads::iterator itr = m_Threads.begin(), end = m_Threads.end(); itr != end; ++itr)
- {
- delete *itr;
- } // for itr - m_Threads[]
- LOG("Processor finished");
-}
-
-
-
-
-
-void cProcessor::PopulateFileQueue(const AString & a_WorldFolder)
-{
- LOG("Processing world in \"%s\"...", a_WorldFolder.c_str());
-
- AString Path = a_WorldFolder;
- if (!Path.empty() && (Path[Path.length() - 1] != cFile::PathSeparator))
- {
- Path.push_back(cFile::PathSeparator);
- }
- AStringList AllFiles = GetDirectoryContents(Path.c_str());
- for (AStringList::iterator itr = AllFiles.begin(), end = AllFiles.end(); itr != end; ++itr)
- {
- if (itr->rfind(".mca") != itr->length() - 4)
- {
- // Not a .mca file
- continue;
- }
- m_FileQueue.push_back(Path + *itr);
- } // for itr - AllFiles[]
-}
-
-
-
-
-
-AString cProcessor::GetOneFileName(void)
-{
- cCSLock Lock(m_CS);
- if (m_FileQueue.empty())
- {
- return "";
- }
- AString res = m_FileQueue.back();
- m_FileQueue.pop_back();
- return res;
-}
-
-
-
-
+
+// Processor.cpp
+
+// Implements the cProcessor class representing the overall processor engine that manages threads, calls callbacks etc.
+
+#include "Globals.h"
+#include "Processor.h"
+#include "Callback.h"
+#include "../../source/WorldStorage/FastNBT.h"
+#include "zlib.h"
+#include "Utils.h"
+
+
+
+
+
+const int CHUNK_INFLATE_MAX = 1 MiB;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cProcessor::cThread:
+
+cProcessor::cThread::cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor) :
+ super("cProcessor::cThread"),
+ m_Callback(a_Callback),
+ m_ParentProcessor(a_ParentProcessor)
+{
+ super::Start();
+}
+
+
+
+
+
+void cProcessor::cThread::Execute(void)
+{
+ LOG("Started a new thread: %d", cIsThread::GetCurrentID());
+
+ m_ParentProcessor.m_ThreadsHaveStarted.Set();
+
+ for (;;)
+ {
+ AString FileName = m_ParentProcessor.GetOneFileName();
+ if (FileName.empty())
+ {
+ // All done, terminate the thread
+ break;
+ }
+ ProcessFile(FileName);
+ } // for-ever
+
+ LOG("Thread %d terminated", cIsThread::GetCurrentID());
+}
+
+
+
+
+
+void cProcessor::cThread::ProcessFile(const AString & a_FileName)
+{
+ LOG("Processing file \"%s\"", a_FileName.c_str());
+
+ size_t idx = a_FileName.rfind("r.");
+ if (idx == AString::npos)
+ {
+ LOG("Cannot parse filename \"%s\", skipping file.", a_FileName.c_str());
+ return;
+ }
+ int RegionX = 0, RegionZ = 0;
+ if (sscanf_s(a_FileName.c_str() + idx, "r.%d.%d.mca", &RegionX, &RegionZ) != 2)
+ {
+ LOG("Cannot parse filename \"%s\" into coords, skipping file.", a_FileName.c_str());
+ return;
+ }
+
+ cFile f;
+ if (!f.Open(a_FileName, cFile::fmRead))
+ {
+ LOG("Cannot open file \"%s\", skipping file.", a_FileName.c_str());
+ return;
+ }
+
+ AString FileContents;
+ f.ReadRestOfFile(FileContents);
+ if (FileContents.size() < sizeof(8 KiB))
+ {
+ LOG("Cannot read header in file \"%s\", skipping file.", a_FileName.c_str());
+ return;
+ }
+
+ ProcessFileData(FileContents.data(), FileContents.size(), RegionX * 32, RegionZ * 32);
+}
+
+
+
+
+
+void cProcessor::cThread::ProcessFileData(const char * a_FileData, size_t a_Size, int a_ChunkBaseX, int a_ChunkBaseZ)
+{
+ int Header[2048];
+ int * HeaderPtr = (int *)a_FileData;
+ for (int i = 0; i < ARRAYCOUNT(Header); i++)
+ {
+ Header[i] = ntohl(HeaderPtr[i]);
+ }
+
+ for (int i = 0; i < 1024; i++)
+ {
+ unsigned Location = Header[i];
+ unsigned Timestamp = Header[i + 1024];
+ if (
+ ((Location == 0) && (Timestamp == 0)) || // Official docs' "not present"
+ (Location >> 8 < 2) || // Logical - no chunk can start inside the header
+ ((Location & 0xff) == 0) || // Logical - no chunk can be zero bytes
+ ((Location >> 8) * 4096 > a_Size) // Logical - no chunk can start at beyond the file end
+ )
+ {
+ // Chunk not present in the file
+ continue;
+ }
+ int ChunkX = a_ChunkBaseX + (i % 32);
+ int ChunkZ = a_ChunkBaseZ + (i / 32);
+ if (m_Callback.OnNewChunk(ChunkX, ChunkZ))
+ {
+ continue;
+ }
+ ProcessChunk(a_FileData, ChunkX, ChunkZ, Location >> 8, Location & 0xff, Timestamp);
+ } // for i - chunk index
+}
+
+
+
+
+
+void cProcessor::cThread::ProcessChunk(const char * a_FileData, int a_ChunkX, int a_ChunkZ, unsigned a_SectorStart, unsigned a_SectorSize, unsigned a_TimeStamp)
+{
+ if (m_Callback.OnHeader(a_SectorStart * 4096, a_SectorSize, a_TimeStamp))
+ {
+ return;
+ }
+
+ const char * ChunkStart = a_FileData + a_SectorStart * 4096;
+ int ByteSize = ntohl(*(int *)ChunkStart);
+ char CompressionMethod = ChunkStart[4];
+
+ if (m_Callback.OnCompressedDataSizePos(ByteSize, a_SectorStart * 4096 + 5, CompressionMethod))
+ {
+ return;
+ }
+
+ ProcessCompressedChunkData(a_ChunkX, a_ChunkZ, ChunkStart + 5, ByteSize);
+}
+
+
+
+
+
+void cProcessor::cThread::ProcessCompressedChunkData(int a_ChunkX, int a_ChunkZ, const char * a_CompressedData, int a_CompressedSize)
+{
+ char Decompressed[CHUNK_INFLATE_MAX];
+ z_stream strm;
+ strm.zalloc = (alloc_func)NULL;
+ strm.zfree = (free_func)NULL;
+ strm.opaque = NULL;
+ inflateInit(&strm);
+ strm.next_out = (Bytef *)Decompressed;
+ strm.avail_out = sizeof(Decompressed);
+ strm.next_in = (Bytef *)a_CompressedData;
+ strm.avail_in = a_CompressedSize;
+ int res = inflate(&strm, Z_FINISH);
+ inflateEnd(&strm);
+ if (res != Z_STREAM_END)
+ {
+ LOG("Decompression failed, skipping chunk [%d, %d]", a_ChunkX, a_ChunkZ);
+ return;
+ }
+
+ if (m_Callback.OnDecompressedData(Decompressed, strm.total_out))
+ {
+ return;
+ }
+
+ // Parse the NBT data:
+ cParsedNBT NBT(Decompressed, strm.total_out);
+ if (!NBT.IsValid())
+ {
+ LOG("NBT Parsing failed, skipping chunk [%d, %d]", a_ChunkX, a_ChunkZ);
+ return;
+ }
+
+ ProcessParsedChunkData(a_ChunkX, a_ChunkZ, NBT);
+}
+
+
+
+
+
+void cProcessor::cThread::ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT)
+{
+ int LevelTag = a_NBT.FindChildByName(0, "Level");
+ if (LevelTag < 0)
+ {
+ LOG("Bad logical structure of the NBT, skipping chunk [%d, %d].", a_ChunkX, a_ChunkZ);
+ return;
+ }
+ int XPosTag = a_NBT.FindChildByName(LevelTag, "xPos");
+ int ZPosTag = a_NBT.FindChildByName(LevelTag, "zPos");
+ if ((XPosTag < 0) || (ZPosTag < 0))
+ {
+ LOG("Pos tags missing in NTB, skipping chunk [%d, %d].", a_ChunkX, a_ChunkZ);
+ return;
+ }
+ if (m_Callback.OnRealCoords(a_NBT.GetInt(XPosTag), a_NBT.GetInt(ZPosTag)))
+ {
+ return;
+ }
+
+ int LastUpdateTag = a_NBT.FindChildByName(LevelTag, "LastUpdate");
+ if (LastUpdateTag > 0)
+ {
+ if (m_Callback.OnLastUpdate(a_NBT.GetLong(LastUpdateTag)))
+ {
+ return;
+ }
+ }
+
+ int TerrainPopulatedTag = a_NBT.FindChildByName(LevelTag, "TerrainPopulated");
+ bool TerrainPopulated = (TerrainPopulatedTag < 0) ? false : (a_NBT.GetByte(TerrainPopulatedTag) != 0);
+ if (m_Callback.OnTerrainPopulated(TerrainPopulated))
+ {
+ return;
+ }
+
+ int BiomesTag = a_NBT.FindChildByName(LevelTag, "Biomes");
+ if (BiomesTag > 0)
+ {
+ if (m_Callback.OnBiomes((const unsigned char *)(a_NBT.GetData(BiomesTag))))
+ {
+ return;
+ }
+ }
+
+ int HeightMapTag = a_NBT.FindChildByName(LevelTag, "HeightMap");
+ if (HeightMapTag > 0)
+ {
+ if (m_Callback.OnHeightMap((const int *)(a_NBT.GetData(HeightMapTag))))
+ {
+ return;
+ }
+ }
+
+ if (ProcessChunkSections(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
+ {
+ return;
+ }
+
+ if (ProcessChunkEntities(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
+ {
+ return;
+ }
+
+ if (ProcessChunkTileEntities(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
+ {
+ return;
+ }
+
+ if (ProcessChunkTileTicks(a_ChunkX, a_ChunkZ, a_NBT, LevelTag))
+ {
+ return;
+ }
+}
+
+
+
+
+
+bool cProcessor::cThread::ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag)
+{
+ int Sections = a_NBT.FindChildByName(a_LevelTag, "Sections");
+ if (Sections < 0)
+ {
+ return false;
+ }
+
+ bool SectionProcessed[16];
+ memset(SectionProcessed, 0, sizeof(SectionProcessed));
+ for (int Tag = a_NBT.GetFirstChild(Sections); Tag > 0; Tag = a_NBT.GetNextSibling(Tag))
+ {
+ int YTag = a_NBT.FindChildByName(Tag, "Y");
+ int BlocksTag = a_NBT.FindChildByName(Tag, "Blocks");
+ int AddTag = a_NBT.FindChildByName(Tag, "Add");
+ int DataTag = a_NBT.FindChildByName(Tag, "Data");
+ int BlockLightTag = a_NBT.FindChildByName(Tag, "BlockLightTag");
+ int SkyLightTag = a_NBT.FindChildByName(Tag, "SkyLight");
+
+ if ((YTag < 0) || (BlocksTag < 0) || (DataTag < 0))
+ {
+ continue;
+ }
+
+ unsigned char SectionY = a_NBT.GetByte(YTag);
+ if (SectionY >= 16)
+ {
+ LOG("WARNING: Section Y >= 16 (%d), high world, wtf? Skipping section!", SectionY);
+ continue;
+ }
+ if (m_Callback.OnSection(
+ SectionY,
+ (const BLOCKTYPE *) (a_NBT.GetData(BlocksTag)),
+ (AddTag > 0) ? (const NIBBLETYPE *)(a_NBT.GetData(AddTag)) : NULL,
+ (const NIBBLETYPE *)(a_NBT.GetData(DataTag)),
+ (BlockLightTag > 0) ? (const NIBBLETYPE *)(a_NBT.GetData(BlockLightTag)) : NULL,
+ (BlockLightTag > 0) ? (const NIBBLETYPE *)(a_NBT.GetData(BlockLightTag)) : NULL
+ ))
+ {
+ return true;
+ }
+ SectionProcessed[SectionY] = true;
+ } // for Tag - Sections[]
+
+ // Call the callback for empty sections:
+ for (unsigned char y = 0; y < 16; y++)
+ {
+ if (!SectionProcessed[y])
+ {
+ if (m_Callback.OnEmptySection(y))
+ {
+ return true;
+ }
+ }
+ }
+
+ if (m_Callback.OnSectionsFinished())
+ {
+ return true;
+ }
+
+ return false;
+}
+
+
+
+
+
+bool cProcessor::cThread::ProcessChunkEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag)
+{
+ int EntitiesTag = a_NBT.FindChildByName(a_LevelTag, "Entities");
+ if (EntitiesTag < 0)
+ {
+ return false;
+ }
+
+ for (int EntityTag = a_NBT.GetFirstChild(EntitiesTag); EntityTag > 0; EntityTag = a_NBT.GetNextSibling(EntityTag))
+ {
+ int PosTag = a_NBT.FindChildByName(EntityTag, "Pos");
+ if (PosTag < 0)
+ {
+ continue;
+ }
+ int SpeedTag = a_NBT.FindChildByName(EntityTag, "Motion");
+ if (SpeedTag < 0)
+ {
+ continue;
+ }
+ int RotTag = a_NBT.FindChildByName(EntityTag, "Rotation");
+ if (RotTag < 0)
+ {
+ continue;
+ }
+ double Pos[3];
+ for (int i = 0, tag = a_NBT.GetFirstChild(PosTag); (i < 3) && (tag > 0); i++)
+ {
+ Pos[i] = a_NBT.GetDouble(tag);
+ }
+ double Speed[3];
+ for (int i = 0, tag = a_NBT.GetFirstChild(SpeedTag); (i < 3) && (tag > 0); i++)
+ {
+ Speed[i] = a_NBT.GetDouble(tag);
+ }
+ float Rot[2];
+ for (int i = 0, tag = a_NBT.GetFirstChild(RotTag); (i < 2) && (tag > 0); i++)
+ {
+ Rot[i] = a_NBT.GetFloat(tag);
+ }
+
+ if (m_Callback.OnEntity(
+ a_NBT.GetString(a_NBT.FindChildByName(EntityTag, "id")),
+ Pos[0], Pos[1], Pos[2],
+ Speed[0], Speed[1], Speed[2],
+ Rot[0], Rot[1],
+ a_NBT.GetFloat(a_NBT.FindChildByName(EntityTag, "FallDistance")),
+ a_NBT.GetShort(a_NBT.FindChildByName(EntityTag, "Fire")),
+ a_NBT.GetShort(a_NBT.FindChildByName(EntityTag, "Air")),
+ a_NBT.GetByte(a_NBT.FindChildByName(EntityTag, "OnGround")),
+ a_NBT, EntityTag
+ ))
+ {
+ return true;
+ }
+ } // for EntityTag - Entities[]
+ return false;
+}
+
+
+
+
+
+bool cProcessor::cThread::ProcessChunkTileEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag)
+{
+ int TileEntitiesTag = a_NBT.FindChildByName(a_LevelTag, "TileEntities");
+ if (TileEntitiesTag < 0)
+ {
+ return false;
+ }
+
+ for (int TileEntityTag = a_NBT.GetFirstChild(TileEntitiesTag); TileEntityTag > 0; TileEntityTag = a_NBT.GetNextSibling(TileEntityTag))
+ {
+ if (m_Callback.OnTileEntity(
+ a_NBT.GetString(a_NBT.FindChildByName(TileEntityTag, "id")),
+ a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "x")),
+ a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "y")),
+ a_NBT.GetInt(a_NBT.FindChildByName(TileEntityTag, "z")),
+ a_NBT, TileEntityTag
+ ))
+ {
+ return true;
+ }
+ } // for EntityTag - Entities[]
+ return false;
+}
+
+
+
+
+
+bool cProcessor::cThread::ProcessChunkTileTicks(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag)
+{
+ int TileTicksTag = a_NBT.FindChildByName(a_LevelTag, "TileTicks");
+ if (TileTicksTag < 0)
+ {
+ return false;
+ }
+
+ for (int TileTickTag = a_NBT.GetFirstChild(TileTicksTag); TileTickTag > 0; TileTickTag = a_NBT.GetNextSibling(TileTickTag))
+ {
+ int iTag = a_NBT.FindChildByName(TileTicksTag, "i");
+ int tTag = a_NBT.FindChildByName(TileTicksTag, "t");
+ int xTag = a_NBT.FindChildByName(TileTicksTag, "x");
+ int yTag = a_NBT.FindChildByName(TileTicksTag, "y");
+ int zTag = a_NBT.FindChildByName(TileTicksTag, "z");
+ if ((iTag < 0) || (tTag < 0) || (xTag < 0) || (yTag < 0) || (zTag < 0))
+ {
+ continue;
+ }
+ if (m_Callback.OnTileTick(
+ a_NBT.GetInt(iTag),
+ a_NBT.GetInt(iTag),
+ a_NBT.GetInt(iTag),
+ a_NBT.GetInt(iTag),
+ a_NBT.GetInt(iTag)
+ ))
+ {
+ return true;
+ }
+ } // for EntityTag - Entities[]
+ return false;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cProcessor:
+
+cProcessor::cProcessor(void) :
+ m_IsShuttingDown(false)
+{
+}
+
+
+
+
+
+cProcessor::~cProcessor()
+{
+}
+
+
+
+
+
+void cProcessor::ProcessWorld(const AString & a_WorldFolder, cCallbackFactory & a_CallbackFactory)
+{
+ PopulateFileQueue(a_WorldFolder);
+
+ if (m_FileQueue.empty())
+ {
+ LOG("No files to process, exitting.");
+ return;
+ }
+
+ // Start as many threads as there are cores, plus one:
+ // (One more thread can be in the file-read IO block while all other threads crunch the numbers)
+ int NumThreads = GetNumCores() + 1;
+
+ /*
+ // Limit the number of threads in DEBUG mode to 1 for easier debugging
+ #ifdef _DEBUG
+ NumThreads = 1;
+ #endif // _DEBUG
+ //*/
+
+ for (int i = 0; i < NumThreads; i++)
+ {
+ cCallback * Callback = a_CallbackFactory.GetNewCallback();
+ m_Threads.push_back(new cThread(*Callback, *this));
+ }
+
+ // Wait for the first thread to start processing:
+ m_ThreadsHaveStarted.Wait();
+
+ // Wait for all threads to finish
+ // simply by calling each thread's destructor sequentially
+ LOG("Waiting for threads to finish");
+ for (cThreads::iterator itr = m_Threads.begin(), end = m_Threads.end(); itr != end; ++itr)
+ {
+ delete *itr;
+ } // for itr - m_Threads[]
+ LOG("Processor finished");
+}
+
+
+
+
+
+void cProcessor::PopulateFileQueue(const AString & a_WorldFolder)
+{
+ LOG("Processing world in \"%s\"...", a_WorldFolder.c_str());
+
+ AString Path = a_WorldFolder;
+ if (!Path.empty() && (Path[Path.length() - 1] != cFile::PathSeparator))
+ {
+ Path.push_back(cFile::PathSeparator);
+ }
+ AStringList AllFiles = GetDirectoryContents(Path.c_str());
+ for (AStringList::iterator itr = AllFiles.begin(), end = AllFiles.end(); itr != end; ++itr)
+ {
+ if (itr->rfind(".mca") != itr->length() - 4)
+ {
+ // Not a .mca file
+ continue;
+ }
+ m_FileQueue.push_back(Path + *itr);
+ } // for itr - AllFiles[]
+}
+
+
+
+
+
+AString cProcessor::GetOneFileName(void)
+{
+ cCSLock Lock(m_CS);
+ if (m_FileQueue.empty())
+ {
+ return "";
+ }
+ AString res = m_FileQueue.back();
+ m_FileQueue.pop_back();
+ return res;
+}
+
+
+
+
diff --git a/Tools/AnvilStats/Processor.h b/Tools/AnvilStats/Processor.h
index b7d3f392e..72fea3081 100644
--- a/Tools/AnvilStats/Processor.h
+++ b/Tools/AnvilStats/Processor.h
@@ -1,77 +1,77 @@
-
-// Processor.h
-
-// Interfaces to the cProcessor class representing the overall processor engine that manages threads, calls callbacks etc.
-
-
-
-
-#pragma once
-
-
-
-
-
-// fwd:
-class cCallback;
-class cCallbackFactory;
-class cParsedNBT;
-
-
-
-
-
-class cProcessor
-{
- class cThread :
- public cIsThread
- {
- typedef cIsThread super;
-
- cCallback & m_Callback;
- cProcessor & m_ParentProcessor;
-
- // cIsThread override:
- virtual void Execute(void) override;
-
- void ProcessFile(const AString & a_FileName);
- void ProcessFileData(const char * a_FileData, size_t a_Size, int a_ChunkBaseX, int a_ChunkBaseZ);
- void ProcessChunk(const char * a_FileData, int a_ChunkX, int a_ChunkZ, unsigned a_SectorStart, unsigned a_SectorSize, unsigned a_TimeStamp);
- void ProcessCompressedChunkData(int a_ChunkX, int a_ChunkZ, const char * a_CompressedData, int a_CompressedSize);
- void ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT);
-
- // The following processing parts return true if they were interrupted by the callback, causing the processing of current chunk to abort
- bool ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
- bool ProcessChunkEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
- bool ProcessChunkTileEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
- bool ProcessChunkTileTicks(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
-
- public:
- cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor);
- } ;
-
- typedef std::vector<cThread *> cThreads;
-
-public:
- cProcessor(void);
- ~cProcessor();
-
- void ProcessWorld(const AString & a_WorldFolder, cCallbackFactory & a_CallbackFactory);
-
-protected:
- bool m_IsShuttingDown; // If true, the threads should stop ASAP
-
- cCriticalSection m_CS;
- AStringList m_FileQueue;
-
- cThreads m_Threads;
- cEvent m_ThreadsHaveStarted; // This is signalled by each thread to notify the parent thread that it can start waiting for those threads
-
- void PopulateFileQueue(const AString & a_WorldFolder);
-
- AString GetOneFileName(void);
-} ;
-
-
-
-
+
+// Processor.h
+
+// Interfaces to the cProcessor class representing the overall processor engine that manages threads, calls callbacks etc.
+
+
+
+
+#pragma once
+
+
+
+
+
+// fwd:
+class cCallback;
+class cCallbackFactory;
+class cParsedNBT;
+
+
+
+
+
+class cProcessor
+{
+ class cThread :
+ public cIsThread
+ {
+ typedef cIsThread super;
+
+ cCallback & m_Callback;
+ cProcessor & m_ParentProcessor;
+
+ // cIsThread override:
+ virtual void Execute(void) override;
+
+ void ProcessFile(const AString & a_FileName);
+ void ProcessFileData(const char * a_FileData, size_t a_Size, int a_ChunkBaseX, int a_ChunkBaseZ);
+ void ProcessChunk(const char * a_FileData, int a_ChunkX, int a_ChunkZ, unsigned a_SectorStart, unsigned a_SectorSize, unsigned a_TimeStamp);
+ void ProcessCompressedChunkData(int a_ChunkX, int a_ChunkZ, const char * a_CompressedData, int a_CompressedSize);
+ void ProcessParsedChunkData(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT);
+
+ // The following processing parts return true if they were interrupted by the callback, causing the processing of current chunk to abort
+ bool ProcessChunkSections(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
+ bool ProcessChunkEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
+ bool ProcessChunkTileEntities(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
+ bool ProcessChunkTileTicks(int a_ChunkX, int a_ChunkZ, cParsedNBT & a_NBT, int a_LevelTag);
+
+ public:
+ cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor);
+ } ;
+
+ typedef std::vector<cThread *> cThreads;
+
+public:
+ cProcessor(void);
+ ~cProcessor();
+
+ void ProcessWorld(const AString & a_WorldFolder, cCallbackFactory & a_CallbackFactory);
+
+protected:
+ bool m_IsShuttingDown; // If true, the threads should stop ASAP
+
+ cCriticalSection m_CS;
+ AStringList m_FileQueue;
+
+ cThreads m_Threads;
+ cEvent m_ThreadsHaveStarted; // This is signalled by each thread to notify the parent thread that it can start waiting for those threads
+
+ void PopulateFileQueue(const AString & a_WorldFolder);
+
+ AString GetOneFileName(void);
+} ;
+
+
+
+
diff --git a/Tools/AnvilStats/SpringStats.cpp b/Tools/AnvilStats/SpringStats.cpp
index 14ede6889..637cf20b6 100644
--- a/Tools/AnvilStats/SpringStats.cpp
+++ b/Tools/AnvilStats/SpringStats.cpp
@@ -1,279 +1,279 @@
-
-// SpringStats.cpp
-
-// Implements the cSpringStats class representing a cCallback descendant that collects statistics on lava and water springs
-
-#include "Globals.h"
-#include "SpringStats.h"
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSpringStats::cStats
-
-cSpringStats::cStats::cStats(void) :
- m_TotalChunks(0)
-{
- memset(m_LavaSprings, 0, sizeof(m_LavaSprings));
- memset(m_WaterSprings, 0, sizeof(m_WaterSprings));
-}
-
-
-
-
-
-void cSpringStats::cStats::Add(const cSpringStats::cStats & a_Other)
-{
- m_TotalChunks += a_Other.m_TotalChunks;
- for (int Biome = 0; Biome < 256; Biome++)
- {
- for (int Height = 0; Height < 256; Height++)
- {
- m_LavaSprings[Biome][Height] += a_Other.m_LavaSprings[Biome][Height];
- m_WaterSprings[Biome][Height] += a_Other.m_WaterSprings[Biome][Height];
- }
- }
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSpringStats:
-
-cSpringStats::cSpringStats(void) :
- m_AreBiomesValid(false)
-{
-}
-
-
-
-
-
-bool cSpringStats::OnNewChunk(int a_ChunkX, int a_ChunkZ)
-{
- memset(m_BlockTypes, 0, sizeof(m_BlockTypes));
- m_AreBiomesValid = false;
- return false;
-}
-
-
-
-
-
-bool cSpringStats::OnBiomes(const unsigned char * a_BiomeData)
-{
- memcpy(m_Biomes, a_BiomeData, sizeof(m_Biomes));
- m_AreBiomesValid = true;
- return false;
-}
-
-
-
-
-
-bool cSpringStats::OnSection(
- unsigned char a_Y,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockAdditional,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight
-)
-{
- memcpy(m_BlockTypes + ((int)a_Y) * 16 * 16 * 16, a_BlockTypes, 16 * 16 * 16);
- memcpy(m_BlockMetas + ((int)a_Y) * 16 * 16 * 16 / 2, a_BlockMeta, 16 * 16 * 16 / 2);
- return false;
-}
-
-
-
-
-
-bool cSpringStats::OnSectionsFinished(void)
-{
- if (!m_AreBiomesValid)
- {
- return true;
- }
-
- // Calc the spring stats:
- for (int y = 1; y < 255; y++)
- {
- int BaseY = y * 16 * 16;
- for (int z = 1; z < 15; z++)
- {
- int Base = BaseY + z * 16;
- for (int x = 1; x < 15; x++)
- {
- if (cChunkDef::GetNibble(m_BlockMetas, Base + x) != 0)
- {
- // Not a source block
- continue;
- }
- switch (m_BlockTypes[Base + x])
- {
- case E_BLOCK_WATER:
- case E_BLOCK_STATIONARY_WATER:
- {
- TestSpring(x, y, z, m_Stats.m_WaterSprings);
- break;
- }
- case E_BLOCK_LAVA:
- case E_BLOCK_STATIONARY_LAVA:
- {
- TestSpring(x, y, z, m_Stats.m_LavaSprings);
- break;
- }
- } // switch (BlockType)
- } // for x
- } // for z
- } // for y
- m_Stats.m_TotalChunks += 1;
- return true;
-}
-
-
-
-
-
-void cSpringStats::TestSpring(int a_RelX, int a_RelY, int a_RelZ, cSpringStats::cStats::SpringStats & a_Stats)
-{
- static const struct
- {
- int x, y, z;
- } Coords[] =
- {
- {-1, 0, 0},
- { 1, 0, 0},
- { 0, -1, 0},
- { 0, 1, 0},
- { 0, 0, -1},
- { 0, 0, 1},
- } ;
- bool HasFluidNextToIt = false;
- for (int i = 0; i < ARRAYCOUNT(Coords); i++)
- {
- switch (cChunkDef::GetBlock(m_BlockTypes, a_RelX + Coords[i].x, a_RelY + Coords[i].y, a_RelZ + Coords[i].z))
- {
- case E_BLOCK_WATER:
- case E_BLOCK_STATIONARY_WATER:
- case E_BLOCK_LAVA:
- case E_BLOCK_STATIONARY_LAVA:
- {
- if (cChunkDef::GetNibble(m_BlockMetas, a_RelX + Coords[i].x, a_RelY + Coords[i].y, a_RelZ + Coords[i].z) == 0)
- {
- // There is another source block next to this, so this is not a spring
- return;
- }
- HasFluidNextToIt = true;
- }
- } // switch (BlockType)
- } // for i - Coords[]
-
- if (!HasFluidNextToIt)
- {
- // Surrounded by solids on all sides, this is probably not a spring,
- // but rather a bedrocked lake or something similar. Dont want.
- return;
- }
-
- // No source blocks next to the specified block, so it is a spring. Add it to stats:
- a_Stats[a_RelY][((unsigned char *)m_Biomes)[a_RelX + 16 * a_RelZ]] += 1;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSpringStatsFactory:
-
-cSpringStatsFactory::~cSpringStatsFactory()
-{
- LOG("cSpringStats:");
- LOG(" Joining results...");
- JoinResults();
- LOG(" Total %llu chunks went through", m_CombinedStats.m_TotalChunks);
-
- // Save statistics:
- LOG(" Saving statistics into files:");
- LOG(" Springs.xls");
- SaveTotals("Springs.xls");
- LOG(" BiomeWaterSprings.xls");
- SaveStatistics(m_CombinedStats.m_WaterSprings, "BiomeWaterSprings.xls");
- LOG(" BiomeLavaSprings.xls");
- SaveStatistics(m_CombinedStats.m_LavaSprings, "BiomeLavaSprings.xls");
-}
-
-
-
-
-
-void cSpringStatsFactory::JoinResults(void)
-{
- for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
- {
- m_CombinedStats.Add(((cSpringStats *)(*itr))->GetStats());
- } // for itr - m_Callbacks[]
-}
-
-
-
-
-
-void cSpringStatsFactory::SaveTotals(const AString & a_FileName)
-{
- cFile f(a_FileName, cFile::fmWrite);
- if (!f.IsOpen())
- {
- LOG("Cannot open file \"%s\" for writing!", a_FileName.c_str());
- return;
- }
- f.Printf("Height\tWater\tLava\n");
- for (int Height = 0; Height < 256; Height++)
- {
- UInt64 TotalW = 0;
- UInt64 TotalL = 0;
- for (int Biome = 0; Biome < 256; Biome++)
- {
- TotalW += m_CombinedStats.m_WaterSprings[Height][Biome];
- TotalL += m_CombinedStats.m_LavaSprings[Height][Biome];
- }
- f.Printf("%d\t%llu\t%llu\n", Height, TotalW, TotalL);
- }
- f.Printf("\n# Chunks\t%llu", m_CombinedStats.m_TotalChunks);
-}
-
-
-
-
-
-void cSpringStatsFactory::SaveStatistics(const cSpringStats::cStats::SpringStats & a_Stats, const AString & a_FileName)
-{
- cFile f(a_FileName, cFile::fmWrite);
- if (!f.IsOpen())
- {
- LOG("Cannot open file \"%s\" for writing!", a_FileName.c_str());
- return;
- }
- for (int Height = 0; Height < 256; Height++)
- {
- AString Line;
- Line.reserve(2000);
- Printf(Line, "%d\t", Height);
- for (int Biome = 0; Biome < 256; Biome++)
- {
- AppendPrintf(Line, "%llu\t", a_Stats[Height][Biome]);
- }
- Line.append("\n");
- f.Write(Line.c_str(), Line.size());
- }
-}
-
-
-
-
+
+// SpringStats.cpp
+
+// Implements the cSpringStats class representing a cCallback descendant that collects statistics on lava and water springs
+
+#include "Globals.h"
+#include "SpringStats.h"
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSpringStats::cStats
+
+cSpringStats::cStats::cStats(void) :
+ m_TotalChunks(0)
+{
+ memset(m_LavaSprings, 0, sizeof(m_LavaSprings));
+ memset(m_WaterSprings, 0, sizeof(m_WaterSprings));
+}
+
+
+
+
+
+void cSpringStats::cStats::Add(const cSpringStats::cStats & a_Other)
+{
+ m_TotalChunks += a_Other.m_TotalChunks;
+ for (int Biome = 0; Biome < 256; Biome++)
+ {
+ for (int Height = 0; Height < 256; Height++)
+ {
+ m_LavaSprings[Biome][Height] += a_Other.m_LavaSprings[Biome][Height];
+ m_WaterSprings[Biome][Height] += a_Other.m_WaterSprings[Biome][Height];
+ }
+ }
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSpringStats:
+
+cSpringStats::cSpringStats(void) :
+ m_AreBiomesValid(false)
+{
+}
+
+
+
+
+
+bool cSpringStats::OnNewChunk(int a_ChunkX, int a_ChunkZ)
+{
+ memset(m_BlockTypes, 0, sizeof(m_BlockTypes));
+ m_AreBiomesValid = false;
+ return false;
+}
+
+
+
+
+
+bool cSpringStats::OnBiomes(const unsigned char * a_BiomeData)
+{
+ memcpy(m_Biomes, a_BiomeData, sizeof(m_Biomes));
+ m_AreBiomesValid = true;
+ return false;
+}
+
+
+
+
+
+bool cSpringStats::OnSection(
+ unsigned char a_Y,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockAdditional,
+ const NIBBLETYPE * a_BlockMeta,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_BlockSkyLight
+)
+{
+ memcpy(m_BlockTypes + ((int)a_Y) * 16 * 16 * 16, a_BlockTypes, 16 * 16 * 16);
+ memcpy(m_BlockMetas + ((int)a_Y) * 16 * 16 * 16 / 2, a_BlockMeta, 16 * 16 * 16 / 2);
+ return false;
+}
+
+
+
+
+
+bool cSpringStats::OnSectionsFinished(void)
+{
+ if (!m_AreBiomesValid)
+ {
+ return true;
+ }
+
+ // Calc the spring stats:
+ for (int y = 1; y < 255; y++)
+ {
+ int BaseY = y * 16 * 16;
+ for (int z = 1; z < 15; z++)
+ {
+ int Base = BaseY + z * 16;
+ for (int x = 1; x < 15; x++)
+ {
+ if (cChunkDef::GetNibble(m_BlockMetas, Base + x) != 0)
+ {
+ // Not a source block
+ continue;
+ }
+ switch (m_BlockTypes[Base + x])
+ {
+ case E_BLOCK_WATER:
+ case E_BLOCK_STATIONARY_WATER:
+ {
+ TestSpring(x, y, z, m_Stats.m_WaterSprings);
+ break;
+ }
+ case E_BLOCK_LAVA:
+ case E_BLOCK_STATIONARY_LAVA:
+ {
+ TestSpring(x, y, z, m_Stats.m_LavaSprings);
+ break;
+ }
+ } // switch (BlockType)
+ } // for x
+ } // for z
+ } // for y
+ m_Stats.m_TotalChunks += 1;
+ return true;
+}
+
+
+
+
+
+void cSpringStats::TestSpring(int a_RelX, int a_RelY, int a_RelZ, cSpringStats::cStats::SpringStats & a_Stats)
+{
+ static const struct
+ {
+ int x, y, z;
+ } Coords[] =
+ {
+ {-1, 0, 0},
+ { 1, 0, 0},
+ { 0, -1, 0},
+ { 0, 1, 0},
+ { 0, 0, -1},
+ { 0, 0, 1},
+ } ;
+ bool HasFluidNextToIt = false;
+ for (int i = 0; i < ARRAYCOUNT(Coords); i++)
+ {
+ switch (cChunkDef::GetBlock(m_BlockTypes, a_RelX + Coords[i].x, a_RelY + Coords[i].y, a_RelZ + Coords[i].z))
+ {
+ case E_BLOCK_WATER:
+ case E_BLOCK_STATIONARY_WATER:
+ case E_BLOCK_LAVA:
+ case E_BLOCK_STATIONARY_LAVA:
+ {
+ if (cChunkDef::GetNibble(m_BlockMetas, a_RelX + Coords[i].x, a_RelY + Coords[i].y, a_RelZ + Coords[i].z) == 0)
+ {
+ // There is another source block next to this, so this is not a spring
+ return;
+ }
+ HasFluidNextToIt = true;
+ }
+ } // switch (BlockType)
+ } // for i - Coords[]
+
+ if (!HasFluidNextToIt)
+ {
+ // Surrounded by solids on all sides, this is probably not a spring,
+ // but rather a bedrocked lake or something similar. Dont want.
+ return;
+ }
+
+ // No source blocks next to the specified block, so it is a spring. Add it to stats:
+ a_Stats[a_RelY][((unsigned char *)m_Biomes)[a_RelX + 16 * a_RelZ]] += 1;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSpringStatsFactory:
+
+cSpringStatsFactory::~cSpringStatsFactory()
+{
+ LOG("cSpringStats:");
+ LOG(" Joining results...");
+ JoinResults();
+ LOG(" Total %llu chunks went through", m_CombinedStats.m_TotalChunks);
+
+ // Save statistics:
+ LOG(" Saving statistics into files:");
+ LOG(" Springs.xls");
+ SaveTotals("Springs.xls");
+ LOG(" BiomeWaterSprings.xls");
+ SaveStatistics(m_CombinedStats.m_WaterSprings, "BiomeWaterSprings.xls");
+ LOG(" BiomeLavaSprings.xls");
+ SaveStatistics(m_CombinedStats.m_LavaSprings, "BiomeLavaSprings.xls");
+}
+
+
+
+
+
+void cSpringStatsFactory::JoinResults(void)
+{
+ for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
+ {
+ m_CombinedStats.Add(((cSpringStats *)(*itr))->GetStats());
+ } // for itr - m_Callbacks[]
+}
+
+
+
+
+
+void cSpringStatsFactory::SaveTotals(const AString & a_FileName)
+{
+ cFile f(a_FileName, cFile::fmWrite);
+ if (!f.IsOpen())
+ {
+ LOG("Cannot open file \"%s\" for writing!", a_FileName.c_str());
+ return;
+ }
+ f.Printf("Height\tWater\tLava\n");
+ for (int Height = 0; Height < 256; Height++)
+ {
+ UInt64 TotalW = 0;
+ UInt64 TotalL = 0;
+ for (int Biome = 0; Biome < 256; Biome++)
+ {
+ TotalW += m_CombinedStats.m_WaterSprings[Height][Biome];
+ TotalL += m_CombinedStats.m_LavaSprings[Height][Biome];
+ }
+ f.Printf("%d\t%llu\t%llu\n", Height, TotalW, TotalL);
+ }
+ f.Printf("\n# Chunks\t%llu", m_CombinedStats.m_TotalChunks);
+}
+
+
+
+
+
+void cSpringStatsFactory::SaveStatistics(const cSpringStats::cStats::SpringStats & a_Stats, const AString & a_FileName)
+{
+ cFile f(a_FileName, cFile::fmWrite);
+ if (!f.IsOpen())
+ {
+ LOG("Cannot open file \"%s\" for writing!", a_FileName.c_str());
+ return;
+ }
+ for (int Height = 0; Height < 256; Height++)
+ {
+ AString Line;
+ Line.reserve(2000);
+ Printf(Line, "%d\t", Height);
+ for (int Biome = 0; Biome < 256; Biome++)
+ {
+ AppendPrintf(Line, "%llu\t", a_Stats[Height][Biome]);
+ }
+ Line.append("\n");
+ f.Write(Line.c_str(), Line.size());
+ }
+}
+
+
+
+
diff --git a/Tools/AnvilStats/SpringStats.h b/Tools/AnvilStats/SpringStats.h
index 292c5b82d..43b9f00d5 100644
--- a/Tools/AnvilStats/SpringStats.h
+++ b/Tools/AnvilStats/SpringStats.h
@@ -1,102 +1,102 @@
-
-// SpringStats.h
-
-// Declares the cSpringStats class representing a cCallback descendant that collects statistics on lava and water springs
-
-
-
-
-
-#pragma once
-
-#include "Callback.h"
-
-
-
-
-
-class cSpringStats :
- public cCallback
-{
-public:
- class cStats
- {
- public:
- /// Per-height, per-biome frequencies of springs
- typedef UInt64 SpringStats[256][256];
-
- SpringStats m_LavaSprings;
- SpringStats m_WaterSprings;
-
- UInt64 m_TotalChunks; ///< Total number of chunks that are fully processed through this callback(OnSectionsFinished())
-
- cStats(void);
- void Add(const cStats & a_Other);
- } ;
-
- cSpringStats(void);
-
- const cStats & GetStats(void) const { return m_Stats; }
-
-protected:
-
- BLOCKTYPE m_BlockTypes[16 * 16 * 256];
- NIBBLETYPE m_BlockMetas[16 * 16 * 256 / 2];
- char m_Biomes[16 * 16];
- bool m_AreBiomesValid;
-
- cStats m_Stats;
-
- // cCallback overrides:
- virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
- virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
- virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
- virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
- virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
- virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
- virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
- virtual bool OnHeightMap(const int * a_HeightMap) override { return false; }
- virtual bool OnSection(
- unsigned char a_Y,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockAdditional,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight
- ) override;
- virtual bool OnSectionsFinished(void) override;
-
- /// Tests the specified block, if it appears to be a spring, it is added to a_Stats
- void TestSpring(int a_RelX, int a_RelY, int a_RelZ, cStats::SpringStats & a_Stats);
-} ;
-
-
-
-
-
-class cSpringStatsFactory :
- public cCallbackFactory
-{
-public:
- virtual ~cSpringStatsFactory();
-
- virtual cCallback * CreateNewCallback(void) override
- {
- return new cSpringStats;
- }
-
- cSpringStats::cStats m_CombinedStats;
-
- void JoinResults(void);
-
- /// Saves total per-height data (summed through biomes) for both spring types to the file
- void SaveTotals(const AString & a_FileName);
-
- /// Saves complete per-height, per-biome statistics for the springs to the file
- void SaveStatistics(const cSpringStats::cStats::SpringStats & a_Stats, const AString & a_FileName);
-} ;
-
-
-
-
+
+// SpringStats.h
+
+// Declares the cSpringStats class representing a cCallback descendant that collects statistics on lava and water springs
+
+
+
+
+
+#pragma once
+
+#include "Callback.h"
+
+
+
+
+
+class cSpringStats :
+ public cCallback
+{
+public:
+ class cStats
+ {
+ public:
+ /// Per-height, per-biome frequencies of springs
+ typedef UInt64 SpringStats[256][256];
+
+ SpringStats m_LavaSprings;
+ SpringStats m_WaterSprings;
+
+ UInt64 m_TotalChunks; ///< Total number of chunks that are fully processed through this callback(OnSectionsFinished())
+
+ cStats(void);
+ void Add(const cStats & a_Other);
+ } ;
+
+ cSpringStats(void);
+
+ const cStats & GetStats(void) const { return m_Stats; }
+
+protected:
+
+ BLOCKTYPE m_BlockTypes[16 * 16 * 256];
+ NIBBLETYPE m_BlockMetas[16 * 16 * 256 / 2];
+ char m_Biomes[16 * 16];
+ bool m_AreBiomesValid;
+
+ cStats m_Stats;
+
+ // cCallback overrides:
+ virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
+ virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
+ virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
+ virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
+ virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
+ virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
+ virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
+ virtual bool OnHeightMap(const int * a_HeightMap) override { return false; }
+ virtual bool OnSection(
+ unsigned char a_Y,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockAdditional,
+ const NIBBLETYPE * a_BlockMeta,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_BlockSkyLight
+ ) override;
+ virtual bool OnSectionsFinished(void) override;
+
+ /// Tests the specified block, if it appears to be a spring, it is added to a_Stats
+ void TestSpring(int a_RelX, int a_RelY, int a_RelZ, cStats::SpringStats & a_Stats);
+} ;
+
+
+
+
+
+class cSpringStatsFactory :
+ public cCallbackFactory
+{
+public:
+ virtual ~cSpringStatsFactory();
+
+ virtual cCallback * CreateNewCallback(void) override
+ {
+ return new cSpringStats;
+ }
+
+ cSpringStats::cStats m_CombinedStats;
+
+ void JoinResults(void);
+
+ /// Saves total per-height data (summed through biomes) for both spring types to the file
+ void SaveTotals(const AString & a_FileName);
+
+ /// Saves complete per-height, per-biome statistics for the springs to the file
+ void SaveStatistics(const cSpringStats::cStats::SpringStats & a_Stats, const AString & a_FileName);
+} ;
+
+
+
+
diff --git a/Tools/AnvilStats/Statistics.cpp b/Tools/AnvilStats/Statistics.cpp
index 2f30e158a..b5b3cb176 100644
--- a/Tools/AnvilStats/Statistics.cpp
+++ b/Tools/AnvilStats/Statistics.cpp
@@ -1,523 +1,523 @@
-
-// Statistics.cpp
-
-// Implements the various statistics-collecting classes
-
-#include "Globals.h"
-#include "Statistics.h"
-#include "../../source/WorldStorage/FastNBT.h"
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cStatistics::cStats:
-
-cStatistics::cStats::cStats(void) :
- m_TotalChunks(0),
- m_BiomeNumChunks(0),
- m_BlockNumChunks(0),
- m_NumEntities(0),
- m_NumTileEntities(0),
- m_NumTileTicks(0),
- m_MinChunkX(0x7fffffff),
- m_MaxChunkX(0x80000000),
- m_MinChunkZ(0x7fffffff),
- m_MaxChunkZ(0x80000000)
-{
- memset(m_BiomeCounts, 0, sizeof(m_BiomeCounts));
- memset(m_BlockCounts, 0, sizeof(m_BlockCounts));
- memset(m_SpawnerEntity, 0, sizeof(m_SpawnerEntity));
-}
-
-
-
-
-
-void cStatistics::cStats::Add(const cStatistics::cStats & a_Stats)
-{
- for (int i = 0; i <= 255; i++)
- {
- m_BiomeCounts[i] += a_Stats.m_BiomeCounts[i];
- }
- for (int i = 0; i <= 255; i++)
- {
- for (int j = 0; j <= 255; j++)
- {
- m_BlockCounts[i][j] += a_Stats.m_BlockCounts[i][j];
- }
- }
- for (int i = 0; i < ARRAYCOUNT(m_SpawnerEntity); i++)
- {
- m_SpawnerEntity[i] += a_Stats.m_SpawnerEntity[i];
- }
- m_BiomeNumChunks += a_Stats.m_BiomeNumChunks;
- m_BlockNumChunks += a_Stats.m_BlockNumChunks;
- m_TotalChunks += a_Stats.m_TotalChunks;
- m_NumEntities += a_Stats.m_NumEntities;
- m_NumTileEntities += a_Stats.m_NumTileEntities;
- m_NumTileTicks += a_Stats.m_NumTileTicks;
- UpdateCoordsRange(a_Stats.m_MinChunkX, a_Stats.m_MinChunkZ);
- UpdateCoordsRange(a_Stats.m_MinChunkX, a_Stats.m_MinChunkZ);
-}
-
-
-
-
-
-void cStatistics::cStats::UpdateCoordsRange(int a_ChunkX, int a_ChunkZ)
-{
- if (a_ChunkX < m_MinChunkX)
- {
- m_MinChunkX = a_ChunkX;
- }
- if (a_ChunkX > m_MaxChunkX)
- {
- m_MaxChunkX = a_ChunkX;
- }
- if (a_ChunkZ < m_MinChunkZ)
- {
- m_MinChunkZ = a_ChunkZ;
- }
- if (a_ChunkZ > m_MaxChunkZ)
- {
- m_MaxChunkZ = a_ChunkZ;
- }
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cStatistics:
-
-cStatistics::cStatistics(void)
-{
-}
-
-
-
-
-
-bool cStatistics::OnNewChunk(int a_ChunkX, int a_ChunkZ)
-{
- m_Stats.m_TotalChunks++;
- m_Stats.UpdateCoordsRange(a_ChunkX, a_ChunkZ);
- m_IsBiomesValid = false;
- m_IsFirstSectionInChunk = true;
- return false;
-}
-
-
-
-
-
-bool cStatistics::OnBiomes(const unsigned char * a_BiomeData)
-{
- for (int i = 0; i < 16 * 16; i++)
- {
- m_Stats.m_BiomeCounts[a_BiomeData[i]] += 1;
- }
- m_Stats.m_BiomeNumChunks += 1;
- memcpy(m_BiomeData, a_BiomeData, sizeof(m_BiomeData));
- m_IsBiomesValid = true;
- return false;
-}
-
-
-
-
-
-
-bool cStatistics::OnSection
-(
- unsigned char a_Y,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockAdditional,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight
-)
-{
- if (!m_IsBiomesValid)
- {
- // The current biome data is not valid, we don't have the means for sorting the BlockTypes into per-biome arrays
- return true;
- }
-
- for (int y = 0; y < 16; y++)
- {
- for (int z = 0; z < 16; z++)
- {
- for (int x = 0; x < 16; x++)
- {
- unsigned char Biome = m_BiomeData[x + 16 * z]; // Cannot use cChunkDef, different datatype
- unsigned char BlockType = cChunkDef::GetBlock(a_BlockTypes, x, y, z);
- m_Stats.m_BlockCounts[Biome][BlockType] += 1;
- }
- }
- }
-
- m_Stats.m_BlockNumChunks += m_IsFirstSectionInChunk ? 1 : 0;
- m_IsFirstSectionInChunk = false;
-
- return false;
-}
-
-
-
-
-
-bool cStatistics::OnEmptySection(unsigned char a_Y)
-{
- if (!m_IsBiomesValid)
- {
- // The current biome data is not valid, we don't have the means for sorting the BlockTypes into per-biome arrays
- return true;
- }
-
- // Add air to all columns:
- for (int z = 0; z < 16; z++)
- {
- for (int x = 0; x < 16; x++)
- {
- unsigned char Biome = m_BiomeData[x + 16 * z]; // Cannot use cChunkDef, different datatype
- m_Stats.m_BlockCounts[Biome][0] += 16; // 16 blocks in a column, all air
- }
- }
-
- m_Stats.m_BlockNumChunks += m_IsFirstSectionInChunk ? 1 : 0;
- m_IsFirstSectionInChunk = false;
-
- return false;
-}
-
-
-
-
-
-bool cStatistics::OnEntity(
- const AString & a_EntityType,
- double a_PosX, double a_PosY, double a_PosZ,
- double a_SpeedX, double a_SpeedY, double a_SpeedZ,
- float a_Yaw, float a_Pitch,
- float a_FallDistance,
- short a_FireTicksLeft,
- short a_AirTicks,
- char a_IsOnGround,
- cParsedNBT & a_NBT,
- int a_NBTTag
-)
-{
- m_Stats.m_NumEntities += 1;
-
- // TODO
-
- return false;
-}
-
-
-
-
-
-bool cStatistics::OnTileEntity(
- const AString & a_EntityType,
- int a_PosX, int a_PosY, int a_PosZ,
- cParsedNBT & a_NBT,
- int a_NBTTag
-)
-{
- m_Stats.m_NumTileEntities += 1;
-
- if (a_EntityType == "MobSpawner")
- {
- OnSpawner(a_NBT, a_NBTTag);
- }
-
- return false;
-}
-
-
-
-
-
-bool cStatistics::OnTileTick(
- int a_BlockType,
- int a_TicksLeft,
- int a_PosX, int a_PosY, int a_PosZ
-)
-{
- m_Stats.m_NumTileTicks += 1;
- return false;
-}
-
-
-
-
-
-void cStatistics::OnSpawner(cParsedNBT & a_NBT, int a_TileEntityTag)
-{
- int EntityIDTag = a_NBT.FindChildByName(a_TileEntityTag, "EntityId");
- if ((EntityIDTag < 0) || (a_NBT.GetType(EntityIDTag) != TAG_String))
- {
- return;
- }
- eEntityType Ent = GetEntityType(a_NBT.GetString(EntityIDTag));
- if (Ent < ARRAYCOUNT(m_Stats.m_SpawnerEntity))
- {
- m_Stats.m_SpawnerEntity[Ent] += 1;
- }
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cStatisticsFactory:
-
-cStatisticsFactory::cStatisticsFactory(void) :
- m_BeginTick(clock())
-{
-}
-
-
-
-
-
-cStatisticsFactory::~cStatisticsFactory()
-{
- // Join the results together:
- LOG("cStatistics:");
- LOG(" Joining results...");
- JoinResults();
- LOG(" Total %llu chunks went through", m_CombinedStats.m_TotalChunks);
- LOG(" Biomes processed for %llu chunks", m_CombinedStats.m_BiomeNumChunks);
-
- // Check the number of blocks processed
- UInt64 TotalBlocks = 0;
- for (int i = 0; i <= 255; i++)
- {
- for (int j = 0; j < 255; j++)
- {
- TotalBlocks += m_CombinedStats.m_BlockCounts[i][j];
- }
- }
- UInt64 ExpTotalBlocks = m_CombinedStats.m_BlockNumChunks * 16LL * 16LL * 256LL;
- LOG(" BlockIDs processed for %llu chunks, %llu blocks (exp %llu; %s)", m_CombinedStats.m_BlockNumChunks, TotalBlocks, ExpTotalBlocks, (TotalBlocks == ExpTotalBlocks) ? "match" : "failed");
-
- // Save statistics:
- LOG(" Saving statistics into files:");
- LOG(" Statistics.txt");
- SaveStatistics();
- LOG(" Biomes.xls");
- SaveBiomes();
- LOG(" BlockTypes.xls");
- SaveBlockTypes();
- LOG(" BiomeBlockTypes.xls");
- SaveBiomeBlockTypes();
- LOG(" Spawners.xls");
- SaveSpawners();
-}
-
-
-
-
-
-void cStatisticsFactory::JoinResults(void)
-{
- for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
- {
- m_CombinedStats.Add(((cStatistics *)(*itr))->GetStats());
- } // for itr - m_Callbacks[]
-}
-
-
-
-
-
-void cStatisticsFactory::SaveBiomes(void)
-{
- cFile f;
- if (!f.Open("Biomes.xls", cFile::fmWrite))
- {
- LOG("Cannot write to file Biomes.xls. Statistics not written.");
- return;
- }
- double TotalColumns = (double)(m_CombinedStats.m_BiomeNumChunks) * 16 * 16 / 100; // Total number of columns processed; convert into percent
- if (TotalColumns < 1)
- {
- // Avoid division by zero
- TotalColumns = 1;
- }
- for (int i = 0; i <= 255; i++)
- {
- AString Line;
- Printf(Line, "%s\t%d\t%llu\t%.05f\n", GetBiomeString(i), i, m_CombinedStats.m_BiomeCounts[i], ((double)(m_CombinedStats.m_BiomeCounts[i])) / TotalColumns);
- f.Write(Line.c_str(), Line.length());
- }
-}
-
-
-
-
-
-void cStatisticsFactory::SaveBlockTypes(void)
-{
- cFile f;
- if (!f.Open("BlockTypes.xls", cFile::fmWrite))
- {
- LOG("Cannot write to file Biomes.xls. Statistics not written.");
- return;
- }
- double TotalBlocks = ((double)(m_CombinedStats.m_BlockNumChunks)) * 16 * 16 * 256 / 100; // Total number of blocks processed; convert into percent
- if (TotalBlocks < 1)
- {
- // Avoid division by zero
- TotalBlocks = 1;
- }
- for (int i = 0; i <= 255; i++)
- {
- UInt64 Count = 0;
- for (int Biome = 0; Biome <= 255; ++Biome)
- {
- Count += m_CombinedStats.m_BlockCounts[Biome][i];
- }
- AString Line;
- Printf(Line, "%s\t%d\t%llu\t%.08f\n", GetBlockTypeString(i), i, Count, ((double)Count) / TotalBlocks);
- f.Write(Line.c_str(), Line.length());
- }
-}
-
-
-
-
-
-void cStatisticsFactory::SaveBiomeBlockTypes(void)
-{
- // Export as two tables: biomes 0-127 and 128-255, because OpenOffice doesn't support more than 256 columns
- cFile f;
- if (!f.Open("BiomeBlockTypes.xls", cFile::fmWrite))
- {
- LOG("Cannot write to file BiomeBlockTypes.xls. Statistics not written.");
- return;
- }
-
- AString FileHeader("Biomes 0-127:\n");
- f.Write(FileHeader.c_str(), FileHeader.length());
-
- AString Header("BlockType\tBlockType");
- for (int Biome = 0; Biome <= 127; Biome++)
- {
- const char * BiomeName = GetBiomeString(Biome);
- if ((BiomeName != NULL) && (BiomeName[0] != 0))
- {
- AppendPrintf(Header, "\t%s (%d)", BiomeName, Biome);
- }
- else
- {
- AppendPrintf(Header, "\t%d", Biome);
- }
- }
- Header.append("\n");
- f.Write(Header.c_str(), Header.length());
-
- for (int BlockType = 0; BlockType <= 255; BlockType++)
- {
- AString Line;
- Printf(Line, "%s\t%d", GetBlockTypeString(BlockType), BlockType);
- for (int Biome = 0; Biome <= 127; Biome++)
- {
- AppendPrintf(Line, "\t%llu", m_CombinedStats.m_BlockCounts[Biome][BlockType]);
- }
- Line.append("\n");
- f.Write(Line.c_str(), Line.length());
- }
-
- Header.assign("\n\nBiomes 127-255:\nBlockType\tBlockType");
- for (int Biome = 0; Biome <= 127; Biome++)
- {
- const char * BiomeName = GetBiomeString(Biome);
- if ((BiomeName != NULL) && (BiomeName[0] != 0))
- {
- AppendPrintf(Header, "\t%s (%d)", BiomeName, Biome);
- }
- else
- {
- AppendPrintf(Header, "\t%d", Biome);
- }
- }
- Header.append("\n");
- f.Write(Header.c_str(), Header.length());
-
- for (int BlockType = 0; BlockType <= 255; BlockType++)
- {
- AString Line;
- Printf(Line, "%s\t%d", GetBlockTypeString(BlockType), BlockType);
- for (int Biome = 128; Biome <= 255; Biome++)
- {
- AppendPrintf(Line, "\t%llu", m_CombinedStats.m_BlockCounts[Biome][BlockType]);
- }
- Line.append("\n");
- f.Write(Line.c_str(), Line.length());
- }
-}
-
-
-
-
-
-
-void cStatisticsFactory::SaveStatistics(void)
-{
- cFile f;
- if (!f.Open("Statistics.txt", cFile::fmWrite))
- {
- LOG("Cannot write to file Statistics.txt. Statistics not written.");
- return;
- }
-
- int Elapsed = (clock() - m_BeginTick) / CLOCKS_PER_SEC;
- f.Printf("Time elapsed: %d seconds (%d hours, %d minutes and %d seconds)\n", Elapsed, Elapsed / 3600, (Elapsed / 60) % 60, Elapsed % 60);
- f.Printf("Total chunks processed: %llu\n", m_CombinedStats.m_TotalChunks);
- if (Elapsed > 0)
- {
- f.Printf("Chunk processing speed: %.02f chunks per second\n", (double)(m_CombinedStats.m_TotalChunks) / Elapsed);
- }
- f.Printf("Biomes counted for %llu chunks.\n", m_CombinedStats.m_BiomeNumChunks);
- f.Printf("Blocktypes counted for %llu chunks.\n", m_CombinedStats.m_BlockNumChunks);
- f.Printf("Total blocks counted: %llu\n", m_CombinedStats.m_BlockNumChunks * 16 * 16 * 256);
- f.Printf("Total biomes counted: %llu\n", m_CombinedStats.m_BiomeNumChunks * 16 * 16);
- f.Printf("Total entities counted: %llu\n", m_CombinedStats.m_NumEntities);
- f.Printf("Total tile entities counted: %llu\n", m_CombinedStats.m_NumTileEntities);
- f.Printf("Total tile ticks counted: %llu\n", m_CombinedStats.m_NumTileTicks);
- f.Printf("Chunk coord ranges:\n");
- f.Printf("\tX: %d .. %d\n", m_CombinedStats.m_MinChunkX, m_CombinedStats.m_MaxChunkX);
- f.Printf("\tZ: %d .. %d\n", m_CombinedStats.m_MinChunkZ, m_CombinedStats.m_MaxChunkZ);
-}
-
-
-
-
-
-void cStatisticsFactory::SaveSpawners(void)
-{
- cFile f;
- if (!f.Open("Spawners.xls", cFile::fmWrite))
- {
- LOG("Cannot write to file Spawners.xls. Statistics not written.");
- return;
- }
-
- f.Printf("Entity type\tTotal count\tCount per chunk\n");
- for (int i = 0; i < entMax; i++)
- {
- f.Printf("%s\t%llu\t%0.4f\n", GetEntityTypeString((eEntityType)i), m_CombinedStats.m_SpawnerEntity[i], (double)(m_CombinedStats.m_SpawnerEntity[i]) / m_CombinedStats.m_BlockNumChunks);
- }
-}
-
-
-
-
+
+// Statistics.cpp
+
+// Implements the various statistics-collecting classes
+
+#include "Globals.h"
+#include "Statistics.h"
+#include "../../source/WorldStorage/FastNBT.h"
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cStatistics::cStats:
+
+cStatistics::cStats::cStats(void) :
+ m_TotalChunks(0),
+ m_BiomeNumChunks(0),
+ m_BlockNumChunks(0),
+ m_NumEntities(0),
+ m_NumTileEntities(0),
+ m_NumTileTicks(0),
+ m_MinChunkX(0x7fffffff),
+ m_MaxChunkX(0x80000000),
+ m_MinChunkZ(0x7fffffff),
+ m_MaxChunkZ(0x80000000)
+{
+ memset(m_BiomeCounts, 0, sizeof(m_BiomeCounts));
+ memset(m_BlockCounts, 0, sizeof(m_BlockCounts));
+ memset(m_SpawnerEntity, 0, sizeof(m_SpawnerEntity));
+}
+
+
+
+
+
+void cStatistics::cStats::Add(const cStatistics::cStats & a_Stats)
+{
+ for (int i = 0; i <= 255; i++)
+ {
+ m_BiomeCounts[i] += a_Stats.m_BiomeCounts[i];
+ }
+ for (int i = 0; i <= 255; i++)
+ {
+ for (int j = 0; j <= 255; j++)
+ {
+ m_BlockCounts[i][j] += a_Stats.m_BlockCounts[i][j];
+ }
+ }
+ for (int i = 0; i < ARRAYCOUNT(m_SpawnerEntity); i++)
+ {
+ m_SpawnerEntity[i] += a_Stats.m_SpawnerEntity[i];
+ }
+ m_BiomeNumChunks += a_Stats.m_BiomeNumChunks;
+ m_BlockNumChunks += a_Stats.m_BlockNumChunks;
+ m_TotalChunks += a_Stats.m_TotalChunks;
+ m_NumEntities += a_Stats.m_NumEntities;
+ m_NumTileEntities += a_Stats.m_NumTileEntities;
+ m_NumTileTicks += a_Stats.m_NumTileTicks;
+ UpdateCoordsRange(a_Stats.m_MinChunkX, a_Stats.m_MinChunkZ);
+ UpdateCoordsRange(a_Stats.m_MinChunkX, a_Stats.m_MinChunkZ);
+}
+
+
+
+
+
+void cStatistics::cStats::UpdateCoordsRange(int a_ChunkX, int a_ChunkZ)
+{
+ if (a_ChunkX < m_MinChunkX)
+ {
+ m_MinChunkX = a_ChunkX;
+ }
+ if (a_ChunkX > m_MaxChunkX)
+ {
+ m_MaxChunkX = a_ChunkX;
+ }
+ if (a_ChunkZ < m_MinChunkZ)
+ {
+ m_MinChunkZ = a_ChunkZ;
+ }
+ if (a_ChunkZ > m_MaxChunkZ)
+ {
+ m_MaxChunkZ = a_ChunkZ;
+ }
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cStatistics:
+
+cStatistics::cStatistics(void)
+{
+}
+
+
+
+
+
+bool cStatistics::OnNewChunk(int a_ChunkX, int a_ChunkZ)
+{
+ m_Stats.m_TotalChunks++;
+ m_Stats.UpdateCoordsRange(a_ChunkX, a_ChunkZ);
+ m_IsBiomesValid = false;
+ m_IsFirstSectionInChunk = true;
+ return false;
+}
+
+
+
+
+
+bool cStatistics::OnBiomes(const unsigned char * a_BiomeData)
+{
+ for (int i = 0; i < 16 * 16; i++)
+ {
+ m_Stats.m_BiomeCounts[a_BiomeData[i]] += 1;
+ }
+ m_Stats.m_BiomeNumChunks += 1;
+ memcpy(m_BiomeData, a_BiomeData, sizeof(m_BiomeData));
+ m_IsBiomesValid = true;
+ return false;
+}
+
+
+
+
+
+
+bool cStatistics::OnSection
+(
+ unsigned char a_Y,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockAdditional,
+ const NIBBLETYPE * a_BlockMeta,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_BlockSkyLight
+)
+{
+ if (!m_IsBiomesValid)
+ {
+ // The current biome data is not valid, we don't have the means for sorting the BlockTypes into per-biome arrays
+ return true;
+ }
+
+ for (int y = 0; y < 16; y++)
+ {
+ for (int z = 0; z < 16; z++)
+ {
+ for (int x = 0; x < 16; x++)
+ {
+ unsigned char Biome = m_BiomeData[x + 16 * z]; // Cannot use cChunkDef, different datatype
+ unsigned char BlockType = cChunkDef::GetBlock(a_BlockTypes, x, y, z);
+ m_Stats.m_BlockCounts[Biome][BlockType] += 1;
+ }
+ }
+ }
+
+ m_Stats.m_BlockNumChunks += m_IsFirstSectionInChunk ? 1 : 0;
+ m_IsFirstSectionInChunk = false;
+
+ return false;
+}
+
+
+
+
+
+bool cStatistics::OnEmptySection(unsigned char a_Y)
+{
+ if (!m_IsBiomesValid)
+ {
+ // The current biome data is not valid, we don't have the means for sorting the BlockTypes into per-biome arrays
+ return true;
+ }
+
+ // Add air to all columns:
+ for (int z = 0; z < 16; z++)
+ {
+ for (int x = 0; x < 16; x++)
+ {
+ unsigned char Biome = m_BiomeData[x + 16 * z]; // Cannot use cChunkDef, different datatype
+ m_Stats.m_BlockCounts[Biome][0] += 16; // 16 blocks in a column, all air
+ }
+ }
+
+ m_Stats.m_BlockNumChunks += m_IsFirstSectionInChunk ? 1 : 0;
+ m_IsFirstSectionInChunk = false;
+
+ return false;
+}
+
+
+
+
+
+bool cStatistics::OnEntity(
+ const AString & a_EntityType,
+ double a_PosX, double a_PosY, double a_PosZ,
+ double a_SpeedX, double a_SpeedY, double a_SpeedZ,
+ float a_Yaw, float a_Pitch,
+ float a_FallDistance,
+ short a_FireTicksLeft,
+ short a_AirTicks,
+ char a_IsOnGround,
+ cParsedNBT & a_NBT,
+ int a_NBTTag
+)
+{
+ m_Stats.m_NumEntities += 1;
+
+ // TODO
+
+ return false;
+}
+
+
+
+
+
+bool cStatistics::OnTileEntity(
+ const AString & a_EntityType,
+ int a_PosX, int a_PosY, int a_PosZ,
+ cParsedNBT & a_NBT,
+ int a_NBTTag
+)
+{
+ m_Stats.m_NumTileEntities += 1;
+
+ if (a_EntityType == "MobSpawner")
+ {
+ OnSpawner(a_NBT, a_NBTTag);
+ }
+
+ return false;
+}
+
+
+
+
+
+bool cStatistics::OnTileTick(
+ int a_BlockType,
+ int a_TicksLeft,
+ int a_PosX, int a_PosY, int a_PosZ
+)
+{
+ m_Stats.m_NumTileTicks += 1;
+ return false;
+}
+
+
+
+
+
+void cStatistics::OnSpawner(cParsedNBT & a_NBT, int a_TileEntityTag)
+{
+ int EntityIDTag = a_NBT.FindChildByName(a_TileEntityTag, "EntityId");
+ if ((EntityIDTag < 0) || (a_NBT.GetType(EntityIDTag) != TAG_String))
+ {
+ return;
+ }
+ eEntityType Ent = GetEntityType(a_NBT.GetString(EntityIDTag));
+ if (Ent < ARRAYCOUNT(m_Stats.m_SpawnerEntity))
+ {
+ m_Stats.m_SpawnerEntity[Ent] += 1;
+ }
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cStatisticsFactory:
+
+cStatisticsFactory::cStatisticsFactory(void) :
+ m_BeginTick(clock())
+{
+}
+
+
+
+
+
+cStatisticsFactory::~cStatisticsFactory()
+{
+ // Join the results together:
+ LOG("cStatistics:");
+ LOG(" Joining results...");
+ JoinResults();
+ LOG(" Total %llu chunks went through", m_CombinedStats.m_TotalChunks);
+ LOG(" Biomes processed for %llu chunks", m_CombinedStats.m_BiomeNumChunks);
+
+ // Check the number of blocks processed
+ UInt64 TotalBlocks = 0;
+ for (int i = 0; i <= 255; i++)
+ {
+ for (int j = 0; j < 255; j++)
+ {
+ TotalBlocks += m_CombinedStats.m_BlockCounts[i][j];
+ }
+ }
+ UInt64 ExpTotalBlocks = m_CombinedStats.m_BlockNumChunks * 16LL * 16LL * 256LL;
+ LOG(" BlockIDs processed for %llu chunks, %llu blocks (exp %llu; %s)", m_CombinedStats.m_BlockNumChunks, TotalBlocks, ExpTotalBlocks, (TotalBlocks == ExpTotalBlocks) ? "match" : "failed");
+
+ // Save statistics:
+ LOG(" Saving statistics into files:");
+ LOG(" Statistics.txt");
+ SaveStatistics();
+ LOG(" Biomes.xls");
+ SaveBiomes();
+ LOG(" BlockTypes.xls");
+ SaveBlockTypes();
+ LOG(" BiomeBlockTypes.xls");
+ SaveBiomeBlockTypes();
+ LOG(" Spawners.xls");
+ SaveSpawners();
+}
+
+
+
+
+
+void cStatisticsFactory::JoinResults(void)
+{
+ for (cCallbacks::iterator itr = m_Callbacks.begin(), end = m_Callbacks.end(); itr != end; ++itr)
+ {
+ m_CombinedStats.Add(((cStatistics *)(*itr))->GetStats());
+ } // for itr - m_Callbacks[]
+}
+
+
+
+
+
+void cStatisticsFactory::SaveBiomes(void)
+{
+ cFile f;
+ if (!f.Open("Biomes.xls", cFile::fmWrite))
+ {
+ LOG("Cannot write to file Biomes.xls. Statistics not written.");
+ return;
+ }
+ double TotalColumns = (double)(m_CombinedStats.m_BiomeNumChunks) * 16 * 16 / 100; // Total number of columns processed; convert into percent
+ if (TotalColumns < 1)
+ {
+ // Avoid division by zero
+ TotalColumns = 1;
+ }
+ for (int i = 0; i <= 255; i++)
+ {
+ AString Line;
+ Printf(Line, "%s\t%d\t%llu\t%.05f\n", GetBiomeString(i), i, m_CombinedStats.m_BiomeCounts[i], ((double)(m_CombinedStats.m_BiomeCounts[i])) / TotalColumns);
+ f.Write(Line.c_str(), Line.length());
+ }
+}
+
+
+
+
+
+void cStatisticsFactory::SaveBlockTypes(void)
+{
+ cFile f;
+ if (!f.Open("BlockTypes.xls", cFile::fmWrite))
+ {
+ LOG("Cannot write to file Biomes.xls. Statistics not written.");
+ return;
+ }
+ double TotalBlocks = ((double)(m_CombinedStats.m_BlockNumChunks)) * 16 * 16 * 256 / 100; // Total number of blocks processed; convert into percent
+ if (TotalBlocks < 1)
+ {
+ // Avoid division by zero
+ TotalBlocks = 1;
+ }
+ for (int i = 0; i <= 255; i++)
+ {
+ UInt64 Count = 0;
+ for (int Biome = 0; Biome <= 255; ++Biome)
+ {
+ Count += m_CombinedStats.m_BlockCounts[Biome][i];
+ }
+ AString Line;
+ Printf(Line, "%s\t%d\t%llu\t%.08f\n", GetBlockTypeString(i), i, Count, ((double)Count) / TotalBlocks);
+ f.Write(Line.c_str(), Line.length());
+ }
+}
+
+
+
+
+
+void cStatisticsFactory::SaveBiomeBlockTypes(void)
+{
+ // Export as two tables: biomes 0-127 and 128-255, because OpenOffice doesn't support more than 256 columns
+ cFile f;
+ if (!f.Open("BiomeBlockTypes.xls", cFile::fmWrite))
+ {
+ LOG("Cannot write to file BiomeBlockTypes.xls. Statistics not written.");
+ return;
+ }
+
+ AString FileHeader("Biomes 0-127:\n");
+ f.Write(FileHeader.c_str(), FileHeader.length());
+
+ AString Header("BlockType\tBlockType");
+ for (int Biome = 0; Biome <= 127; Biome++)
+ {
+ const char * BiomeName = GetBiomeString(Biome);
+ if ((BiomeName != NULL) && (BiomeName[0] != 0))
+ {
+ AppendPrintf(Header, "\t%s (%d)", BiomeName, Biome);
+ }
+ else
+ {
+ AppendPrintf(Header, "\t%d", Biome);
+ }
+ }
+ Header.append("\n");
+ f.Write(Header.c_str(), Header.length());
+
+ for (int BlockType = 0; BlockType <= 255; BlockType++)
+ {
+ AString Line;
+ Printf(Line, "%s\t%d", GetBlockTypeString(BlockType), BlockType);
+ for (int Biome = 0; Biome <= 127; Biome++)
+ {
+ AppendPrintf(Line, "\t%llu", m_CombinedStats.m_BlockCounts[Biome][BlockType]);
+ }
+ Line.append("\n");
+ f.Write(Line.c_str(), Line.length());
+ }
+
+ Header.assign("\n\nBiomes 127-255:\nBlockType\tBlockType");
+ for (int Biome = 0; Biome <= 127; Biome++)
+ {
+ const char * BiomeName = GetBiomeString(Biome);
+ if ((BiomeName != NULL) && (BiomeName[0] != 0))
+ {
+ AppendPrintf(Header, "\t%s (%d)", BiomeName, Biome);
+ }
+ else
+ {
+ AppendPrintf(Header, "\t%d", Biome);
+ }
+ }
+ Header.append("\n");
+ f.Write(Header.c_str(), Header.length());
+
+ for (int BlockType = 0; BlockType <= 255; BlockType++)
+ {
+ AString Line;
+ Printf(Line, "%s\t%d", GetBlockTypeString(BlockType), BlockType);
+ for (int Biome = 128; Biome <= 255; Biome++)
+ {
+ AppendPrintf(Line, "\t%llu", m_CombinedStats.m_BlockCounts[Biome][BlockType]);
+ }
+ Line.append("\n");
+ f.Write(Line.c_str(), Line.length());
+ }
+}
+
+
+
+
+
+
+void cStatisticsFactory::SaveStatistics(void)
+{
+ cFile f;
+ if (!f.Open("Statistics.txt", cFile::fmWrite))
+ {
+ LOG("Cannot write to file Statistics.txt. Statistics not written.");
+ return;
+ }
+
+ int Elapsed = (clock() - m_BeginTick) / CLOCKS_PER_SEC;
+ f.Printf("Time elapsed: %d seconds (%d hours, %d minutes and %d seconds)\n", Elapsed, Elapsed / 3600, (Elapsed / 60) % 60, Elapsed % 60);
+ f.Printf("Total chunks processed: %llu\n", m_CombinedStats.m_TotalChunks);
+ if (Elapsed > 0)
+ {
+ f.Printf("Chunk processing speed: %.02f chunks per second\n", (double)(m_CombinedStats.m_TotalChunks) / Elapsed);
+ }
+ f.Printf("Biomes counted for %llu chunks.\n", m_CombinedStats.m_BiomeNumChunks);
+ f.Printf("Blocktypes counted for %llu chunks.\n", m_CombinedStats.m_BlockNumChunks);
+ f.Printf("Total blocks counted: %llu\n", m_CombinedStats.m_BlockNumChunks * 16 * 16 * 256);
+ f.Printf("Total biomes counted: %llu\n", m_CombinedStats.m_BiomeNumChunks * 16 * 16);
+ f.Printf("Total entities counted: %llu\n", m_CombinedStats.m_NumEntities);
+ f.Printf("Total tile entities counted: %llu\n", m_CombinedStats.m_NumTileEntities);
+ f.Printf("Total tile ticks counted: %llu\n", m_CombinedStats.m_NumTileTicks);
+ f.Printf("Chunk coord ranges:\n");
+ f.Printf("\tX: %d .. %d\n", m_CombinedStats.m_MinChunkX, m_CombinedStats.m_MaxChunkX);
+ f.Printf("\tZ: %d .. %d\n", m_CombinedStats.m_MinChunkZ, m_CombinedStats.m_MaxChunkZ);
+}
+
+
+
+
+
+void cStatisticsFactory::SaveSpawners(void)
+{
+ cFile f;
+ if (!f.Open("Spawners.xls", cFile::fmWrite))
+ {
+ LOG("Cannot write to file Spawners.xls. Statistics not written.");
+ return;
+ }
+
+ f.Printf("Entity type\tTotal count\tCount per chunk\n");
+ for (int i = 0; i < entMax; i++)
+ {
+ f.Printf("%s\t%llu\t%0.4f\n", GetEntityTypeString((eEntityType)i), m_CombinedStats.m_SpawnerEntity[i], (double)(m_CombinedStats.m_SpawnerEntity[i]) / m_CombinedStats.m_BlockNumChunks);
+ }
+}
+
+
+
+
diff --git a/Tools/AnvilStats/Statistics.h b/Tools/AnvilStats/Statistics.h
index 2c0a86cc1..53e353f22 100644
--- a/Tools/AnvilStats/Statistics.h
+++ b/Tools/AnvilStats/Statistics.h
@@ -1,138 +1,138 @@
-
-// Statistics.h
-
-// Interfaces to the cStatistics class representing a statistics-collecting callback
-
-
-
-
-
-#pragma once
-
-#include "Callback.h"
-#include "Utils.h"
-
-
-
-
-
-class cStatistics :
- public cCallback
-{
-public:
- class cStats
- {
- public:
- UInt64 m_TotalChunks; // Total number of chunks that go through this callback (OnNewChunk())
- UInt64 m_BiomeCounts[256];
- UInt64 m_BlockCounts[256][256]; // First dimension is the biome, second dimension is BlockType
- UInt64 m_BiomeNumChunks; // Num chunks that have been processed for biome stats
- UInt64 m_BlockNumChunks; // Num chunks that have been processed for block stats
- UInt64 m_NumEntities;
- UInt64 m_NumTileEntities;
- UInt64 m_NumTileTicks;
- int m_MinChunkX, m_MaxChunkX; // X coords range
- int m_MinChunkZ, m_MaxChunkZ; // Z coords range
-
- Int64 m;
- UInt64 m_SpawnerEntity[entMax + 1];
-
- cStats(void);
- void Add(const cStats & a_Stats);
- void UpdateCoordsRange(int a_ChunkX, int a_ChunkZ);
- } ;
-
- cStatistics(void);
-
- const cStats & GetStats(void) const { return m_Stats; }
-
-protected:
- cStats m_Stats;
-
- bool m_IsBiomesValid; // Set to true in OnBiomes(), reset to false in OnNewChunk(); if true, the m_BiomeData is valid for the current chunk
- unsigned char m_BiomeData[16 * 16];
- bool m_IsFirstSectionInChunk; // True if there was no section in the chunk yet. Set by OnNewChunk(), reset by OnSection()
-
- // cCallback overrides:
- virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
- virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
- virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
- virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
- virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
- virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
- virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
- virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
- virtual bool OnHeightMap(const int * a_HeightMap) override { return false; }
- virtual bool OnSection(
- unsigned char a_Y,
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockAdditional,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight
- ) override;
-
- virtual bool OnEmptySection(unsigned char a_Y) override;
-
- virtual bool OnEntity(
- const AString & a_EntityType,
- double a_PosX, double a_PosY, double a_PosZ,
- double a_SpeedX, double a_SpeedY, double a_SpeedZ,
- float a_Yaw, float a_Pitch,
- float a_FallDistance,
- short a_FireTicksLeft,
- short a_AirTicks,
- char a_IsOnGround,
- cParsedNBT & a_NBT,
- int a_NBTTag
- ) override;
-
- virtual bool OnTileEntity(
- const AString & a_EntityType,
- int a_PosX, int a_PosY, int a_PosZ,
- cParsedNBT & a_NBT,
- int a_NBTTag
- ) override;
-
- virtual bool OnTileTick(
- int a_BlockType,
- int a_TicksLeft,
- int a_PosX, int a_PosY, int a_PosZ
- ) override;
-
- void OnSpawner(cParsedNBT & a_NBT, int a_TileEntityTag);
-} ;
-
-
-
-
-
-class cStatisticsFactory :
- public cCallbackFactory
-{
-public:
- cStatisticsFactory(void);
- virtual ~cStatisticsFactory();
-
- virtual cCallback * CreateNewCallback(void)
- {
- return new cStatistics;
- }
-
-protected:
- // The results, combined, are stored here:
- cStatistics::cStats m_CombinedStats;
-
- clock_t m_BeginTick;
-
- void JoinResults(void);
- void SaveBiomes(void);
- void SaveBlockTypes(void);
- void SaveBiomeBlockTypes(void);
- void SaveStatistics(void);
- void SaveSpawners(void);
-} ;
-
-
-
-
+
+// Statistics.h
+
+// Interfaces to the cStatistics class representing a statistics-collecting callback
+
+
+
+
+
+#pragma once
+
+#include "Callback.h"
+#include "Utils.h"
+
+
+
+
+
+class cStatistics :
+ public cCallback
+{
+public:
+ class cStats
+ {
+ public:
+ UInt64 m_TotalChunks; // Total number of chunks that go through this callback (OnNewChunk())
+ UInt64 m_BiomeCounts[256];
+ UInt64 m_BlockCounts[256][256]; // First dimension is the biome, second dimension is BlockType
+ UInt64 m_BiomeNumChunks; // Num chunks that have been processed for biome stats
+ UInt64 m_BlockNumChunks; // Num chunks that have been processed for block stats
+ UInt64 m_NumEntities;
+ UInt64 m_NumTileEntities;
+ UInt64 m_NumTileTicks;
+ int m_MinChunkX, m_MaxChunkX; // X coords range
+ int m_MinChunkZ, m_MaxChunkZ; // Z coords range
+
+ Int64 m;
+ UInt64 m_SpawnerEntity[entMax + 1];
+
+ cStats(void);
+ void Add(const cStats & a_Stats);
+ void UpdateCoordsRange(int a_ChunkX, int a_ChunkZ);
+ } ;
+
+ cStatistics(void);
+
+ const cStats & GetStats(void) const { return m_Stats; }
+
+protected:
+ cStats m_Stats;
+
+ bool m_IsBiomesValid; // Set to true in OnBiomes(), reset to false in OnNewChunk(); if true, the m_BiomeData is valid for the current chunk
+ unsigned char m_BiomeData[16 * 16];
+ bool m_IsFirstSectionInChunk; // True if there was no section in the chunk yet. Set by OnNewChunk(), reset by OnSection()
+
+ // cCallback overrides:
+ virtual bool OnNewChunk(int a_ChunkX, int a_ChunkZ) override;
+ virtual bool OnHeader(int a_FileOffset, unsigned char a_NumSectors, int a_Timestamp) override { return false; }
+ virtual bool OnCompressedDataSizePos(int a_CompressedDataSize, int a_DataOffset, char a_CompressionMethod) override { return false; }
+ virtual bool OnDecompressedData(const char * a_DecompressedNBT, int a_DataSize) override { return false; }
+ virtual bool OnRealCoords(int a_ChunkX, int a_ChunkZ) override { return false; }
+ virtual bool OnLastUpdate(Int64 a_LastUpdate) override { return false; }
+ virtual bool OnTerrainPopulated(bool a_Populated) override { return !a_Populated; } // If not populated, we don't want it!
+ virtual bool OnBiomes(const unsigned char * a_BiomeData) override;
+ virtual bool OnHeightMap(const int * a_HeightMap) override { return false; }
+ virtual bool OnSection(
+ unsigned char a_Y,
+ const BLOCKTYPE * a_BlockTypes,
+ const NIBBLETYPE * a_BlockAdditional,
+ const NIBBLETYPE * a_BlockMeta,
+ const NIBBLETYPE * a_BlockLight,
+ const NIBBLETYPE * a_BlockSkyLight
+ ) override;
+
+ virtual bool OnEmptySection(unsigned char a_Y) override;
+
+ virtual bool OnEntity(
+ const AString & a_EntityType,
+ double a_PosX, double a_PosY, double a_PosZ,
+ double a_SpeedX, double a_SpeedY, double a_SpeedZ,
+ float a_Yaw, float a_Pitch,
+ float a_FallDistance,
+ short a_FireTicksLeft,
+ short a_AirTicks,
+ char a_IsOnGround,
+ cParsedNBT & a_NBT,
+ int a_NBTTag
+ ) override;
+
+ virtual bool OnTileEntity(
+ const AString & a_EntityType,
+ int a_PosX, int a_PosY, int a_PosZ,
+ cParsedNBT & a_NBT,
+ int a_NBTTag
+ ) override;
+
+ virtual bool OnTileTick(
+ int a_BlockType,
+ int a_TicksLeft,
+ int a_PosX, int a_PosY, int a_PosZ
+ ) override;
+
+ void OnSpawner(cParsedNBT & a_NBT, int a_TileEntityTag);
+} ;
+
+
+
+
+
+class cStatisticsFactory :
+ public cCallbackFactory
+{
+public:
+ cStatisticsFactory(void);
+ virtual ~cStatisticsFactory();
+
+ virtual cCallback * CreateNewCallback(void)
+ {
+ return new cStatistics;
+ }
+
+protected:
+ // The results, combined, are stored here:
+ cStatistics::cStats m_CombinedStats;
+
+ clock_t m_BeginTick;
+
+ void JoinResults(void);
+ void SaveBiomes(void);
+ void SaveBlockTypes(void);
+ void SaveBiomeBlockTypes(void);
+ void SaveStatistics(void);
+ void SaveSpawners(void);
+} ;
+
+
+
+
diff --git a/Tools/AnvilStats/Utils.cpp b/Tools/AnvilStats/Utils.cpp
index be1f067c0..baa87bd69 100644
--- a/Tools/AnvilStats/Utils.cpp
+++ b/Tools/AnvilStats/Utils.cpp
@@ -1,291 +1,291 @@
-
-// Utils.cpp
-
-// Implements utility functions
-
-#include "Globals.h"
-#include "Utils.h"
-
-
-
-
-
-struct
-{
- eEntityType Type;
- const char * String;
-} g_EntityTypes[] =
-{
- {entBat, "Bat"},
- {entBlaze, "Blaze"},
- {entCaveSpider, "CaveSpider"},
- {entChicken, "Chicken"},
- {entCow, "Cow"},
- {entCreeper, "Creeper"},
- {entEnderDragon, "EnderDragon"},
- {entEnderman, "Enderman"},
- {entGhast, "Ghast"},
- {entGiant, "Giant"},
- {entLavaSlime, "LavaSlime"},
- {entMushroomCow, "MushroomCow"},
- {entOzelot, "Ozelot"},
- {entPig, "Pig"},
- {entPigZombie, "PigZombie"},
- {entSheep, "Sheep"},
- {entSilverfish, "Slverfish"},
- {entSkeleton, "Skeleton"},
- {entSlime, "Slime"},
- {entSnowMan, "SnowMan"},
- {entSpider, "Spider"},
- {entSquid, "Squid"},
- {entVillager, "Villager"},
- {entVillagerGolem, "VillagerGolem"},
- {entWitch, "Witch"},
- {entWitherBoss, "WitherBoss"},
- {entWolf, "Wolf"},
- {entZombie, "Zombie"},
- {entUnknown, "Unknown"},
-} ;
-
-
-
-
-
-const char * GetBiomeString(unsigned char a_Biome)
-{
- static const char * BiomeNames[] = // Biome names, as equivalent to their index
- {
- "Ocean",
- "Plains",
- "Desert",
- "Extreme Hills",
- "Forest",
- "Taiga",
- "Swampland",
- "River",
- "Hell",
- "Sky",
- "Frozen Ocean",
- "Frozen River",
- "Ice Plains",
- "Ice Mountains",
- "Mushroom Island",
- "Mushroom Island Shore",
- "Beach",
- "Desert Hills",
- "Forest Hills",
- "Taiga Hills",
- "Extreme Hills Edge",
- "Jungle",
- "Jungle Hills",
- } ;
- return (a_Biome < ARRAYCOUNT(BiomeNames)) ? BiomeNames[a_Biome] : "";
-}
-
-
-
-
-
-const char * GetBlockTypeString(unsigned char a_BlockType)
-{
- static const char * BlockTypeNames[] = // Block type names, as equivalent to their index
- {
- "air",
- "stone",
- "grass",
- "dirt",
- "cobblestone",
- "planks",
- "sapling",
- "bedrock",
- "water",
- "stillwater",
- "lava",
- "stilllava",
- "sand",
- "gravel",
- "goldore",
- "ironore",
- "coalore",
- "log",
- "leaves",
- "sponge",
- "glass",
- "lapisore",
- "lapisblock",
- "dispenser",
- "sandstone",
- "noteblock",
- "bedblock",
- "poweredrail",
- "detectorrail",
- "stickypiston",
- "cobweb",
- "tallgrass",
- "deadbush",
- "piston",
- "pistonhead",
- "wool",
- "pistonmovedblock",
- "flower",
- "rose",
- "brownmushroom",
- "redmushroom",
- "goldblock",
- "ironblock",
- "doubleslab",
- "slab",
- "brickblock",
- "tnt",
- "bookcase",
- "mossycobblestone",
- "obsidian",
- "torch",
- "fire",
- "mobspawner",
- "woodstairs",
- "chest",
- "redstonedust",
- "diamondore",
- "diamondblock",
- "workbench",
- "crops",
- "soil",
- "furnace",
- "litfurnace",
- "signblock",
- "wooddoorblock",
- "ladder",
- "tracks",
- "cobblestonestairs",
- "wallsign",
- "lever",
- "stoneplate",
- "irondoorblock",
- "woodplate",
- "redstoneore",
- "redstoneorealt",
- "redstonetorchoff",
- "redstonetorchon",
- "button",
- "snow",
- "ice",
- "snowblock",
- "cactus",
- "clayblock",
- "reedblock",
- "jukebox",
- "fence",
- "pumpkin",
- "netherrack",
- "soulsand",
- "glowstone",
- "portal",
- "jack-o-lantern",
- "cakeblock",
- "repeateroff",
- "repeateron",
- "lockedchest",
- "trapdoor",
- "silverfishblock",
- "stonebricks",
- "hugebrownmushroom",
- "hugeredmushroom",
- "ironbars",
- "glasspane",
- "melon",
- "pumpkinstem",
- "melonstem",
- "vines",
- "fencegate",
- "brickstairs",
- "stonebrickstairs",
- "mycelium",
- "lilypad",
- "netherbrick",
- "netherbrickfence",
- "netherbrickstairs",
- "netherwartblock",
- "enchantmenttable",
- "brewingstandblock",
- "cauldronblock",
- "endportal",
- "endportalframe",
- "endstone",
- "dragonegg",
- "redstonelampoff",
- "redstonelampon",
- "woodendoubleslab",
- "woodenslab",
- "cocoapod",
- "sandstonestairs", /* 128 */
- "Emerald Ore",
- "Ender Chest",
- "Tripwire Hook",
- "Tripwire",
- "Block of Emerald",
- "Spruce Wood Stairs",
- "Birch Wood Stairs",
- "Jungle Wood Stairs",
- "Command Block",
- "Beacon",
- "Cobblestone Wall",
- "Flower Pot",
- "Carrots",
- "Potatoes",
- "Wooden Button",
- "Head",
- } ;
-
- return (a_BlockType < ARRAYCOUNT(BlockTypeNames)) ? BlockTypeNames[a_BlockType] : "";
-}
-
-
-
-
-
-eEntityType GetEntityType(const AString & a_EntityTypeString)
-{
- for (int i = 0; i < ARRAYCOUNT(g_EntityTypes); i++)
- {
- if (a_EntityTypeString == g_EntityTypes[i].String)
- {
- return g_EntityTypes[i].Type;
- }
- }
- return entUnknown;
-}
-
-
-
-
-
-extern const char * GetEntityTypeString(eEntityType a_EntityType)
-{
- return g_EntityTypes[a_EntityType].String;
-}
-
-
-
-
-
-int GetNumCores(void)
-{
- // Get number of cores by querying the system process affinity mask (Windows-specific)
- DWORD Affinity, ProcAffinity;
- GetProcessAffinityMask(GetCurrentProcess(), &ProcAffinity, &Affinity);
- int NumCores = 0;
- while (Affinity > 0)
- {
- if ((Affinity & 1) == 1)
- {
- ++NumCores;
- }
- Affinity >>= 1;
- } // while (Affinity > 0)
- return NumCores;
-}
-
-
-
-
+
+// Utils.cpp
+
+// Implements utility functions
+
+#include "Globals.h"
+#include "Utils.h"
+
+
+
+
+
+struct
+{
+ eEntityType Type;
+ const char * String;
+} g_EntityTypes[] =
+{
+ {entBat, "Bat"},
+ {entBlaze, "Blaze"},
+ {entCaveSpider, "CaveSpider"},
+ {entChicken, "Chicken"},
+ {entCow, "Cow"},
+ {entCreeper, "Creeper"},
+ {entEnderDragon, "EnderDragon"},
+ {entEnderman, "Enderman"},
+ {entGhast, "Ghast"},
+ {entGiant, "Giant"},
+ {entLavaSlime, "LavaSlime"},
+ {entMushroomCow, "MushroomCow"},
+ {entOzelot, "Ozelot"},
+ {entPig, "Pig"},
+ {entPigZombie, "PigZombie"},
+ {entSheep, "Sheep"},
+ {entSilverfish, "Slverfish"},
+ {entSkeleton, "Skeleton"},
+ {entSlime, "Slime"},
+ {entSnowMan, "SnowMan"},
+ {entSpider, "Spider"},
+ {entSquid, "Squid"},
+ {entVillager, "Villager"},
+ {entVillagerGolem, "VillagerGolem"},
+ {entWitch, "Witch"},
+ {entWitherBoss, "WitherBoss"},
+ {entWolf, "Wolf"},
+ {entZombie, "Zombie"},
+ {entUnknown, "Unknown"},
+} ;
+
+
+
+
+
+const char * GetBiomeString(unsigned char a_Biome)
+{
+ static const char * BiomeNames[] = // Biome names, as equivalent to their index
+ {
+ "Ocean",
+ "Plains",
+ "Desert",
+ "Extreme Hills",
+ "Forest",
+ "Taiga",
+ "Swampland",
+ "River",
+ "Hell",
+ "Sky",
+ "Frozen Ocean",
+ "Frozen River",
+ "Ice Plains",
+ "Ice Mountains",
+ "Mushroom Island",
+ "Mushroom Island Shore",
+ "Beach",
+ "Desert Hills",
+ "Forest Hills",
+ "Taiga Hills",
+ "Extreme Hills Edge",
+ "Jungle",
+ "Jungle Hills",
+ } ;
+ return (a_Biome < ARRAYCOUNT(BiomeNames)) ? BiomeNames[a_Biome] : "";
+}
+
+
+
+
+
+const char * GetBlockTypeString(unsigned char a_BlockType)
+{
+ static const char * BlockTypeNames[] = // Block type names, as equivalent to their index
+ {
+ "air",
+ "stone",
+ "grass",
+ "dirt",
+ "cobblestone",
+ "planks",
+ "sapling",
+ "bedrock",
+ "water",
+ "stillwater",
+ "lava",
+ "stilllava",
+ "sand",
+ "gravel",
+ "goldore",
+ "ironore",
+ "coalore",
+ "log",
+ "leaves",
+ "sponge",
+ "glass",
+ "lapisore",
+ "lapisblock",
+ "dispenser",
+ "sandstone",
+ "noteblock",
+ "bedblock",
+ "poweredrail",
+ "detectorrail",
+ "stickypiston",
+ "cobweb",
+ "tallgrass",
+ "deadbush",
+ "piston",
+ "pistonhead",
+ "wool",
+ "pistonmovedblock",
+ "flower",
+ "rose",
+ "brownmushroom",
+ "redmushroom",
+ "goldblock",
+ "ironblock",
+ "doubleslab",
+ "slab",
+ "brickblock",
+ "tnt",
+ "bookcase",
+ "mossycobblestone",
+ "obsidian",
+ "torch",
+ "fire",
+ "mobspawner",
+ "woodstairs",
+ "chest",
+ "redstonedust",
+ "diamondore",
+ "diamondblock",
+ "workbench",
+ "crops",
+ "soil",
+ "furnace",
+ "litfurnace",
+ "signblock",
+ "wooddoorblock",
+ "ladder",
+ "tracks",
+ "cobblestonestairs",
+ "wallsign",
+ "lever",
+ "stoneplate",
+ "irondoorblock",
+ "woodplate",
+ "redstoneore",
+ "redstoneorealt",
+ "redstonetorchoff",
+ "redstonetorchon",
+ "button",
+ "snow",
+ "ice",
+ "snowblock",
+ "cactus",
+ "clayblock",
+ "reedblock",
+ "jukebox",
+ "fence",
+ "pumpkin",
+ "netherrack",
+ "soulsand",
+ "glowstone",
+ "portal",
+ "jack-o-lantern",
+ "cakeblock",
+ "repeateroff",
+ "repeateron",
+ "lockedchest",
+ "trapdoor",
+ "silverfishblock",
+ "stonebricks",
+ "hugebrownmushroom",
+ "hugeredmushroom",
+ "ironbars",
+ "glasspane",
+ "melon",
+ "pumpkinstem",
+ "melonstem",
+ "vines",
+ "fencegate",
+ "brickstairs",
+ "stonebrickstairs",
+ "mycelium",
+ "lilypad",
+ "netherbrick",
+ "netherbrickfence",
+ "netherbrickstairs",
+ "netherwartblock",
+ "enchantmenttable",
+ "brewingstandblock",
+ "cauldronblock",
+ "endportal",
+ "endportalframe",
+ "endstone",
+ "dragonegg",
+ "redstonelampoff",
+ "redstonelampon",
+ "woodendoubleslab",
+ "woodenslab",
+ "cocoapod",
+ "sandstonestairs", /* 128 */
+ "Emerald Ore",
+ "Ender Chest",
+ "Tripwire Hook",
+ "Tripwire",
+ "Block of Emerald",
+ "Spruce Wood Stairs",
+ "Birch Wood Stairs",
+ "Jungle Wood Stairs",
+ "Command Block",
+ "Beacon",
+ "Cobblestone Wall",
+ "Flower Pot",
+ "Carrots",
+ "Potatoes",
+ "Wooden Button",
+ "Head",
+ } ;
+
+ return (a_BlockType < ARRAYCOUNT(BlockTypeNames)) ? BlockTypeNames[a_BlockType] : "";
+}
+
+
+
+
+
+eEntityType GetEntityType(const AString & a_EntityTypeString)
+{
+ for (int i = 0; i < ARRAYCOUNT(g_EntityTypes); i++)
+ {
+ if (a_EntityTypeString == g_EntityTypes[i].String)
+ {
+ return g_EntityTypes[i].Type;
+ }
+ }
+ return entUnknown;
+}
+
+
+
+
+
+extern const char * GetEntityTypeString(eEntityType a_EntityType)
+{
+ return g_EntityTypes[a_EntityType].String;
+}
+
+
+
+
+
+int GetNumCores(void)
+{
+ // Get number of cores by querying the system process affinity mask (Windows-specific)
+ DWORD Affinity, ProcAffinity;
+ GetProcessAffinityMask(GetCurrentProcess(), &ProcAffinity, &Affinity);
+ int NumCores = 0;
+ while (Affinity > 0)
+ {
+ if ((Affinity & 1) == 1)
+ {
+ ++NumCores;
+ }
+ Affinity >>= 1;
+ } // while (Affinity > 0)
+ return NumCores;
+}
+
+
+
+
diff --git a/Tools/AnvilStats/Utils.h b/Tools/AnvilStats/Utils.h
index 095abc99e..ab2d7166c 100644
--- a/Tools/AnvilStats/Utils.h
+++ b/Tools/AnvilStats/Utils.h
@@ -1,61 +1,61 @@
-
-// Utils.h
-
-// Interfaces to utility functions
-
-
-
-
-
-#pragma once
-
-
-
-
-
-enum eEntityType
-{
- entBat,
- entBlaze,
- entCaveSpider,
- entChicken,
- entCow,
- entCreeper,
- entEnderDragon,
- entEnderman,
- entGhast,
- entGiant,
- entLavaSlime,
- entMushroomCow,
- entOzelot,
- entPig,
- entPigZombie,
- entSheep,
- entSilverfish,
- entSkeleton,
- entSlime,
- entSnowMan,
- entSpider,
- entSquid,
- entVillager,
- entVillagerGolem,
- entWitch,
- entWitherBoss,
- entWolf,
- entZombie,
- entUnknown,
- entMax = entUnknown,
-} ;
-
-
-
-
-
-extern const char * GetBiomeString(unsigned char a_Biome);
-extern const char * GetBlockTypeString(unsigned char a_BlockType);
-extern eEntityType GetEntityType(const AString & a_EntityTypeString);
-extern const char * GetEntityTypeString(eEntityType a_EntityType);
-extern int GetNumCores(void);
-
-
-
+
+// Utils.h
+
+// Interfaces to utility functions
+
+
+
+
+
+#pragma once
+
+
+
+
+
+enum eEntityType
+{
+ entBat,
+ entBlaze,
+ entCaveSpider,
+ entChicken,
+ entCow,
+ entCreeper,
+ entEnderDragon,
+ entEnderman,
+ entGhast,
+ entGiant,
+ entLavaSlime,
+ entMushroomCow,
+ entOzelot,
+ entPig,
+ entPigZombie,
+ entSheep,
+ entSilverfish,
+ entSkeleton,
+ entSlime,
+ entSnowMan,
+ entSpider,
+ entSquid,
+ entVillager,
+ entVillagerGolem,
+ entWitch,
+ entWitherBoss,
+ entWolf,
+ entZombie,
+ entUnknown,
+ entMax = entUnknown,
+} ;
+
+
+
+
+
+extern const char * GetBiomeString(unsigned char a_Biome);
+extern const char * GetBlockTypeString(unsigned char a_BlockType);
+extern eEntityType GetEntityType(const AString & a_EntityTypeString);
+extern const char * GetEntityTypeString(eEntityType a_EntityType);
+extern int GetNumCores(void);
+
+
+
diff --git a/Tools/AnvilStats/profile_run.cmd b/Tools/AnvilStats/profile_run.cmd
index 2a9285614..0edb6f23d 100644
--- a/Tools/AnvilStats/profile_run.cmd
+++ b/Tools/AnvilStats/profile_run.cmd
@@ -1,70 +1,70 @@
-@echo off
-::
-:: Profiling using a MSVC standalone profiler
-::
-:: See http://www.codeproject.com/Articles/144643/Profiling-of-C-Applications-in-Visual-Studio-for-F for details
-::
-
-
-
-
-set pt="C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools"
-set appdir="Release profiled"
-set app="Release profiled\AnvilStats.exe"
-set args="0 c:\Games\MLG\world\region"
-
-:: outputdir is relative to appdir!
-set outputdir=Profiling
-set output=profile.vsp
-
-
-
-
-
-::Create the output directory, if it didn't exist
-mkdir %outputdir%
-
-
-
-
-
-:: Start the profiler
-%pt%\vsperfcmd /start:sample /output:%outputdir%\%output%
-if errorlevel 1 goto haderror
-
-:: Launch the application via the profiler
-%pt%\vsperfcmd /launch:%app% /args:%args%
-if errorlevel 1 goto haderror
-
-:: Shut down the profiler (this command waits, until the application is terminated)
-%pt%\vsperfcmd /shutdown
-if errorlevel 1 goto haderror
-
-
-
-
-
-:: cd to outputdir, so that the reports are generated there
-cd %outputdir%
-
-:: generate the report files (.csv)
-%pt%\vsperfreport /summary:all %output% /symbolpath:"srv*C:\Programovani\Symbols*http://msdl.microsoft.com/download/symbols"
-if errorlevel 1 goto haderror
-
-
-
-
-
-goto finished
-
-
-
-
-:haderror
-echo An error was encountered
-pause
-
-
-
-
-:finished
+@echo off
+::
+:: Profiling using a MSVC standalone profiler
+::
+:: See http://www.codeproject.com/Articles/144643/Profiling-of-C-Applications-in-Visual-Studio-for-F for details
+::
+
+
+
+
+set pt="C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools"
+set appdir="Release profiled"
+set app="Release profiled\AnvilStats.exe"
+set args="0 c:\Games\MLG\world\region"
+
+:: outputdir is relative to appdir!
+set outputdir=Profiling
+set output=profile.vsp
+
+
+
+
+
+::Create the output directory, if it didn't exist
+mkdir %outputdir%
+
+
+
+
+
+:: Start the profiler
+%pt%\vsperfcmd /start:sample /output:%outputdir%\%output%
+if errorlevel 1 goto haderror
+
+:: Launch the application via the profiler
+%pt%\vsperfcmd /launch:%app% /args:%args%
+if errorlevel 1 goto haderror
+
+:: Shut down the profiler (this command waits, until the application is terminated)
+%pt%\vsperfcmd /shutdown
+if errorlevel 1 goto haderror
+
+
+
+
+
+:: cd to outputdir, so that the reports are generated there
+cd %outputdir%
+
+:: generate the report files (.csv)
+%pt%\vsperfreport /summary:all %output% /symbolpath:"srv*C:\Programovani\Symbols*http://msdl.microsoft.com/download/symbols"
+if errorlevel 1 goto haderror
+
+
+
+
+
+goto finished
+
+
+
+
+:haderror
+echo An error was encountered
+pause
+
+
+
+
+:finished
diff --git a/Tools/BiomeVisualiser/BiomeCache.cpp b/Tools/BiomeVisualiser/BiomeCache.cpp
index 12133b8b6..b3c308422 100644
--- a/Tools/BiomeVisualiser/BiomeCache.cpp
+++ b/Tools/BiomeVisualiser/BiomeCache.cpp
@@ -1,333 +1,333 @@
-
-// BiomeCache.cpp
-
-// Implements the cBiomeCache class representing a biome source that caches data from the underlying biome source
-
-#include "Globals.h"
-#include "BiomeCache.h"
-#include "Timer.h"
-
-
-
-
-
-static int GetNumCores(void)
-{
- // Get number of cores by querying the system process affinity mask
- DWORD Affinity, ProcAffinity;
- GetProcessAffinityMask(GetCurrentProcess(), &ProcAffinity, &Affinity);
- int NumCores = 0;
- while (Affinity > 0)
- {
- if ((Affinity & 1) == 1)
- {
- NumCores++;
- }
- Affinity >>= 1;
- } // while (Affinity > 0)
- return NumCores;
-}
-
-
-
-
-
-cBiomeCache::cBiomeCache(void) :
- m_Source(NULL),
- m_BaseX(-100000),
- m_BaseZ(-100000),
- m_Available(NULL),
- m_IsTerminatingThreads(false)
-{
- int NumThreads = GetNumCores();
- NumThreads--; // One core should be left for the system to run on ;)
- for (int i = NumThreads; i > 0; i--)
- {
- cThread * Thread = new cThread(*this);
- m_Threads.push_back(Thread);
- Thread->Start();
- }
-}
-
-
-
-
-cBiomeCache::~cBiomeCache()
-{
- m_IsTerminatingThreads = true;
- for (cThreads::iterator itr = m_Threads.begin(), end = m_Threads.end(); itr != end; ++itr)
- {
- m_evtQueued.Set();
- }
- for (cThreads::iterator itr = m_Threads.begin(), end = m_Threads.end(); itr != end; ++itr)
- {
- delete *itr;
- }
- m_Threads.clear();
-
- SetSource(NULL);
-}
-
-
-
-
-
-cBiomeSource::eAvailability cBiomeCache::GetBiome(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes)
-{
- if (m_Source == NULL)
- {
- return baNever;
- }
-
- // Look up using the cache:
- int x = a_ChunkX - m_BaseX;
- int z = a_ChunkZ - m_BaseZ;
- if ((x < 0) || (x >= m_Width) || (z < 0) || (z >= m_Height))
- {
- // Outside the cached region
- return baNever;
- }
-
- cCSLock Lock(m_CS);
- cItem * Item = m_Available[x + m_Width * z];
- if (Item == NULL)
- {
- // Item hasn't been processed yet
- return baLater;
- }
- if (Item->m_IsValid)
- {
- memcpy(a_Biomes, Item->m_Biomes, sizeof(a_Biomes));
- return baNow;
- }
-
- // Item has been processed, but the underlying source refused to give the data to us
- return baNever;
-}
-
-
-
-
-
-void cBiomeCache::HintViewArea(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ)
-{
- cTimer Timer("Cache: HintViewArea");
-
- if (
- (a_MinChunkX == m_BaseX) &&
- (a_MaxChunkX == m_BaseX + m_Width - 1) &&
- (a_MinChunkZ == m_BaseZ) &&
- (a_MaxChunkZ == m_BaseZ + m_Height - 1)
- )
- {
- // The same set of parameters, bail out
- return;
- }
-
- if (m_Source != NULL)
- {
- m_Source->HintViewArea(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ);
- }
-
- int NewWidth = a_MaxChunkX - a_MinChunkX + 1;
- int NewHeight = a_MaxChunkZ - a_MinChunkZ + 1;
-
- // Make a new empty cache table:
- pItem * NewAvailable = new pItem[NewWidth * NewHeight];
- for (int i = NewWidth * NewHeight - 1; i >= 0; --i)
- {
- NewAvailable[i] = NULL;
- }
-
- // Move the common contents of the old table into the new table:
- cCSLock Lock(m_CS);
- for (int z = 0; z < NewHeight; z++)
- {
- int OldZ = z + a_MinChunkZ - m_BaseZ;
- if ((OldZ < 0) || (OldZ >= m_Height))
- {
- continue;
- }
- for (int x = 0; x < NewWidth; x++)
- {
- int OldX = x + a_MinChunkX - m_BaseX;
- if ((OldX < 0) || (OldX >= m_Width))
- {
- continue;
- }
- NewAvailable[x + NewWidth * z] = m_Available[OldX + m_Width * OldZ];
- m_Available[OldX + m_Width * OldZ] = NULL;
- } // for x
- } // for z
-
- // All items that aren't common go into the pool:
- for (int idx = 0, z = 0; z < m_Height; z++)
- {
- for (int x = 0; x < m_Width; ++x, ++idx)
- {
- if (m_Available[idx] != NULL)
- {
- m_Pool.push_back(m_Available[idx]);
- m_Available[idx] = NULL;
- }
- }
- }
-
- // Replace the cache table:
- delete m_Available;
- m_Available = NewAvailable;
- m_Width = NewWidth;
- m_Height = NewHeight;
- m_BaseX = a_MinChunkX;
- m_BaseZ = a_MinChunkZ;
-
- // Remove all items outside the coords:
- FilterOutItems(m_Queue, a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ);
-
- // Queue all items from inside the coords into m_Queue:
- for (int z = 0; z < NewHeight; z++)
- {
- for (int x = 0; x < NewWidth; x++)
- {
- if (m_Available[x + m_Width * z] != NULL)
- {
- // Already calculated, skip
- continue;
- }
-
- if (m_Pool.empty())
- {
- m_Pool.push_back(new cItem(x + a_MinChunkX, z + a_MinChunkZ));
- }
- ASSERT(!m_Pool.empty());
- m_Pool.back()->m_ChunkX = x + a_MinChunkX;
- m_Pool.back()->m_ChunkZ = z + a_MinChunkZ;
- m_Queue.push_back(m_Pool.back());
- m_Pool.pop_back();
- m_evtQueued.Set();
- } // for x
- } // for z
-}
-
-
-
-
-
-void cBiomeCache::SetSource(cBiomeSource * a_Source)
-{
- // TODO: Stop all threads, so that they don't use the source anymore!
-
- delete m_Source;
- m_Source = a_Source;
-
- // Invalidate cache contents:
- cCSLock Lock(m_CS);
- m_BaseX = -10000;
- m_BaseZ = -10000;
- m_Pool.splice(m_Pool.end(), m_Queue);
-}
-
-
-
-
-
-void cBiomeCache::FilterOutItems(cItems & a_Items, int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ)
-{
- for (cItems::iterator itr = a_Items.begin(); itr != a_Items.end();)
- {
- if (
- ((*itr)->m_ChunkX < a_MinChunkX) ||
- ((*itr)->m_ChunkX > a_MaxChunkX) ||
- ((*itr)->m_ChunkX < a_MinChunkX) ||
- ((*itr)->m_ChunkX > a_MaxChunkX)
- )
- {
- m_Pool.push_back(*itr);
- itr = a_Items.erase(itr);
- }
- else
- {
- ++itr;
- }
- }
-}
-
-
-
-
-
-void cBiomeCache::thrProcessQueueItem(void)
-{
- cItem * Item = NULL;
- {
- cCSLock Lock(m_CS);
- if (m_Queue.empty())
- {
- cCSUnlock Unlock(Lock);
- m_evtQueued.Wait();
- }
- if (m_IsTerminatingThreads || m_Queue.empty())
- {
- // We've been woken up only to die / spurious wakeup
- return;
- }
- Item = m_Queue.back();
- m_Queue.pop_back();
- }
-
- // Process the item:
- Item->m_IsValid = (m_Source->GetBiome(Item->m_ChunkX, Item->m_ChunkZ, Item->m_Biomes) == baNow);
-
- // Store result:
- cCSLock Lock(m_CS);
- int x = Item->m_ChunkX - m_BaseX;
- int z = Item->m_ChunkZ - m_BaseZ;
- if ((x < 0) || (x >= m_Width) || (z < 0) || (z >= m_Height))
- {
- // The cache rectangle has changed under our fingers, drop this chunk
- return;
- }
- m_Available[x + m_Width * z] = Item;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cBiomeCache::cItem:
-
-cBiomeCache::cItem::cItem(int a_ChunkX, int a_ChunkZ) :
- m_ChunkX(a_ChunkX),
- m_ChunkZ(a_ChunkZ)
-{
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cBiomeCache::cThread:
-
-cBiomeCache::cThread::cThread(cBiomeCache & a_Parent) :
- super("Biome cache thread"),
- m_Parent(a_Parent)
-{
-}
-
-
-
-
-
-void cBiomeCache::cThread::Execute(void)
-{
- while (!m_ShouldTerminate && !m_Parent.m_IsTerminatingThreads)
- {
- m_Parent.thrProcessQueueItem();
- }
-}
-
-
-
-
+
+// BiomeCache.cpp
+
+// Implements the cBiomeCache class representing a biome source that caches data from the underlying biome source
+
+#include "Globals.h"
+#include "BiomeCache.h"
+#include "Timer.h"
+
+
+
+
+
+static int GetNumCores(void)
+{
+ // Get number of cores by querying the system process affinity mask
+ DWORD Affinity, ProcAffinity;
+ GetProcessAffinityMask(GetCurrentProcess(), &ProcAffinity, &Affinity);
+ int NumCores = 0;
+ while (Affinity > 0)
+ {
+ if ((Affinity & 1) == 1)
+ {
+ NumCores++;
+ }
+ Affinity >>= 1;
+ } // while (Affinity > 0)
+ return NumCores;
+}
+
+
+
+
+
+cBiomeCache::cBiomeCache(void) :
+ m_Source(NULL),
+ m_BaseX(-100000),
+ m_BaseZ(-100000),
+ m_Available(NULL),
+ m_IsTerminatingThreads(false)
+{
+ int NumThreads = GetNumCores();
+ NumThreads--; // One core should be left for the system to run on ;)
+ for (int i = NumThreads; i > 0; i--)
+ {
+ cThread * Thread = new cThread(*this);
+ m_Threads.push_back(Thread);
+ Thread->Start();
+ }
+}
+
+
+
+
+cBiomeCache::~cBiomeCache()
+{
+ m_IsTerminatingThreads = true;
+ for (cThreads::iterator itr = m_Threads.begin(), end = m_Threads.end(); itr != end; ++itr)
+ {
+ m_evtQueued.Set();
+ }
+ for (cThreads::iterator itr = m_Threads.begin(), end = m_Threads.end(); itr != end; ++itr)
+ {
+ delete *itr;
+ }
+ m_Threads.clear();
+
+ SetSource(NULL);
+}
+
+
+
+
+
+cBiomeSource::eAvailability cBiomeCache::GetBiome(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes)
+{
+ if (m_Source == NULL)
+ {
+ return baNever;
+ }
+
+ // Look up using the cache:
+ int x = a_ChunkX - m_BaseX;
+ int z = a_ChunkZ - m_BaseZ;
+ if ((x < 0) || (x >= m_Width) || (z < 0) || (z >= m_Height))
+ {
+ // Outside the cached region
+ return baNever;
+ }
+
+ cCSLock Lock(m_CS);
+ cItem * Item = m_Available[x + m_Width * z];
+ if (Item == NULL)
+ {
+ // Item hasn't been processed yet
+ return baLater;
+ }
+ if (Item->m_IsValid)
+ {
+ memcpy(a_Biomes, Item->m_Biomes, sizeof(a_Biomes));
+ return baNow;
+ }
+
+ // Item has been processed, but the underlying source refused to give the data to us
+ return baNever;
+}
+
+
+
+
+
+void cBiomeCache::HintViewArea(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ)
+{
+ cTimer Timer("Cache: HintViewArea");
+
+ if (
+ (a_MinChunkX == m_BaseX) &&
+ (a_MaxChunkX == m_BaseX + m_Width - 1) &&
+ (a_MinChunkZ == m_BaseZ) &&
+ (a_MaxChunkZ == m_BaseZ + m_Height - 1)
+ )
+ {
+ // The same set of parameters, bail out
+ return;
+ }
+
+ if (m_Source != NULL)
+ {
+ m_Source->HintViewArea(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ);
+ }
+
+ int NewWidth = a_MaxChunkX - a_MinChunkX + 1;
+ int NewHeight = a_MaxChunkZ - a_MinChunkZ + 1;
+
+ // Make a new empty cache table:
+ pItem * NewAvailable = new pItem[NewWidth * NewHeight];
+ for (int i = NewWidth * NewHeight - 1; i >= 0; --i)
+ {
+ NewAvailable[i] = NULL;
+ }
+
+ // Move the common contents of the old table into the new table:
+ cCSLock Lock(m_CS);
+ for (int z = 0; z < NewHeight; z++)
+ {
+ int OldZ = z + a_MinChunkZ - m_BaseZ;
+ if ((OldZ < 0) || (OldZ >= m_Height))
+ {
+ continue;
+ }
+ for (int x = 0; x < NewWidth; x++)
+ {
+ int OldX = x + a_MinChunkX - m_BaseX;
+ if ((OldX < 0) || (OldX >= m_Width))
+ {
+ continue;
+ }
+ NewAvailable[x + NewWidth * z] = m_Available[OldX + m_Width * OldZ];
+ m_Available[OldX + m_Width * OldZ] = NULL;
+ } // for x
+ } // for z
+
+ // All items that aren't common go into the pool:
+ for (int idx = 0, z = 0; z < m_Height; z++)
+ {
+ for (int x = 0; x < m_Width; ++x, ++idx)
+ {
+ if (m_Available[idx] != NULL)
+ {
+ m_Pool.push_back(m_Available[idx]);
+ m_Available[idx] = NULL;
+ }
+ }
+ }
+
+ // Replace the cache table:
+ delete m_Available;
+ m_Available = NewAvailable;
+ m_Width = NewWidth;
+ m_Height = NewHeight;
+ m_BaseX = a_MinChunkX;
+ m_BaseZ = a_MinChunkZ;
+
+ // Remove all items outside the coords:
+ FilterOutItems(m_Queue, a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ);
+
+ // Queue all items from inside the coords into m_Queue:
+ for (int z = 0; z < NewHeight; z++)
+ {
+ for (int x = 0; x < NewWidth; x++)
+ {
+ if (m_Available[x + m_Width * z] != NULL)
+ {
+ // Already calculated, skip
+ continue;
+ }
+
+ if (m_Pool.empty())
+ {
+ m_Pool.push_back(new cItem(x + a_MinChunkX, z + a_MinChunkZ));
+ }
+ ASSERT(!m_Pool.empty());
+ m_Pool.back()->m_ChunkX = x + a_MinChunkX;
+ m_Pool.back()->m_ChunkZ = z + a_MinChunkZ;
+ m_Queue.push_back(m_Pool.back());
+ m_Pool.pop_back();
+ m_evtQueued.Set();
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cBiomeCache::SetSource(cBiomeSource * a_Source)
+{
+ // TODO: Stop all threads, so that they don't use the source anymore!
+
+ delete m_Source;
+ m_Source = a_Source;
+
+ // Invalidate cache contents:
+ cCSLock Lock(m_CS);
+ m_BaseX = -10000;
+ m_BaseZ = -10000;
+ m_Pool.splice(m_Pool.end(), m_Queue);
+}
+
+
+
+
+
+void cBiomeCache::FilterOutItems(cItems & a_Items, int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ)
+{
+ for (cItems::iterator itr = a_Items.begin(); itr != a_Items.end();)
+ {
+ if (
+ ((*itr)->m_ChunkX < a_MinChunkX) ||
+ ((*itr)->m_ChunkX > a_MaxChunkX) ||
+ ((*itr)->m_ChunkX < a_MinChunkX) ||
+ ((*itr)->m_ChunkX > a_MaxChunkX)
+ )
+ {
+ m_Pool.push_back(*itr);
+ itr = a_Items.erase(itr);
+ }
+ else
+ {
+ ++itr;
+ }
+ }
+}
+
+
+
+
+
+void cBiomeCache::thrProcessQueueItem(void)
+{
+ cItem * Item = NULL;
+ {
+ cCSLock Lock(m_CS);
+ if (m_Queue.empty())
+ {
+ cCSUnlock Unlock(Lock);
+ m_evtQueued.Wait();
+ }
+ if (m_IsTerminatingThreads || m_Queue.empty())
+ {
+ // We've been woken up only to die / spurious wakeup
+ return;
+ }
+ Item = m_Queue.back();
+ m_Queue.pop_back();
+ }
+
+ // Process the item:
+ Item->m_IsValid = (m_Source->GetBiome(Item->m_ChunkX, Item->m_ChunkZ, Item->m_Biomes) == baNow);
+
+ // Store result:
+ cCSLock Lock(m_CS);
+ int x = Item->m_ChunkX - m_BaseX;
+ int z = Item->m_ChunkZ - m_BaseZ;
+ if ((x < 0) || (x >= m_Width) || (z < 0) || (z >= m_Height))
+ {
+ // The cache rectangle has changed under our fingers, drop this chunk
+ return;
+ }
+ m_Available[x + m_Width * z] = Item;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cBiomeCache::cItem:
+
+cBiomeCache::cItem::cItem(int a_ChunkX, int a_ChunkZ) :
+ m_ChunkX(a_ChunkX),
+ m_ChunkZ(a_ChunkZ)
+{
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cBiomeCache::cThread:
+
+cBiomeCache::cThread::cThread(cBiomeCache & a_Parent) :
+ super("Biome cache thread"),
+ m_Parent(a_Parent)
+{
+}
+
+
+
+
+
+void cBiomeCache::cThread::Execute(void)
+{
+ while (!m_ShouldTerminate && !m_Parent.m_IsTerminatingThreads)
+ {
+ m_Parent.thrProcessQueueItem();
+ }
+}
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeCache.h b/Tools/BiomeVisualiser/BiomeCache.h
index 86602a19d..bf1503d4c 100644
--- a/Tools/BiomeVisualiser/BiomeCache.h
+++ b/Tools/BiomeVisualiser/BiomeCache.h
@@ -1,96 +1,96 @@
-
-// BiomeCache.h
-
-// Declares the cBiomeCache class representing a biome source that caches data from the underlying biome source
-
-/*
-This cache works a bit differently than regular caches.
-It first receives the hint of area that it will need to provide.
-The Cache uses several threads to request biomes from the underlying source to fill that area.
-While the area is being filled, requests for biomes may already come, such requests are answered with baLater if no data yet.
-*/
-
-#pragma once
-
-
-
-
-
-#include "BiomeSource.h"
-#include "../source/OSSupport/IsThread.h"
-
-
-
-
-
-class cBiomeCache :
- public cBiomeSource
-{
-public:
- cBiomeCache(void);
- ~cBiomeCache();
-
- // cBiomeSource overrides:
- virtual eAvailability GetBiome(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes) override;
- virtual void HintViewArea(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ) override;
-
- void SetSource(cBiomeSource * a_Source); // Takes ownership of the source ptr
-
-protected:
- class cItem
- {
- public:
- cItem(int a_ChunkX, int a_ChunkZ);
-
- int m_ChunkX;
- int m_ChunkZ;
- bool m_IsValid;
- cChunkDef::BiomeMap m_Biomes;
- } ;
-
- typedef cItem * pItem;
- typedef std::list<pItem> cItems;
-
- class cThread :
- public cIsThread
- {
- typedef cIsThread super;
-
- public:
- cThread(cBiomeCache & a_Parent);
-
- // cIsThread overrides:
- virtual void Execute(void) override;
-
- protected:
- cBiomeCache & m_Parent;
- } ;
-
- typedef std::list<cThread *> cThreads;
-
- cBiomeSource * m_Source;
-
- cCriticalSection m_CS;
- int m_BaseX; ///< MinChunkX for the m_Available rectangle
- int m_BaseZ; ///< MinChunkZ for the m_Available rectangle
- int m_Width; ///< Width of the m_Available rectangle
- int m_Height; ///< Height of the m_Available rectangle
- pItem * m_Available; ///< Items that have already been processed (baNow or baNever), [x + m_Width * z]
- cItems m_Queue; ///< Items that are queued for processing (baLater)
- cItems m_Pool; ///< Items that are not needed anymore, can be reused for other coords
-
- cEvent m_evtQueued; // Triggerred when an item is added to m_Queue
-
- cThreads m_Threads; // Threads that update the cache.
- bool m_IsTerminatingThreads; // Set to true to indicate to all threads that they should exit
-
- /// Removes from a_Items all items that are outside of the given coords, moves those into m_Pool
- void FilterOutItems(cItems & a_Items, int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ);
-
- /// Processes one item from m_Queue into m_Available. Blocks if m_Queue is empty; respects m_IsTerminatingThreads
- void thrProcessQueueItem(void);
-} ;
-
-
-
-
+
+// BiomeCache.h
+
+// Declares the cBiomeCache class representing a biome source that caches data from the underlying biome source
+
+/*
+This cache works a bit differently than regular caches.
+It first receives the hint of area that it will need to provide.
+The Cache uses several threads to request biomes from the underlying source to fill that area.
+While the area is being filled, requests for biomes may already come, such requests are answered with baLater if no data yet.
+*/
+
+#pragma once
+
+
+
+
+
+#include "BiomeSource.h"
+#include "../source/OSSupport/IsThread.h"
+
+
+
+
+
+class cBiomeCache :
+ public cBiomeSource
+{
+public:
+ cBiomeCache(void);
+ ~cBiomeCache();
+
+ // cBiomeSource overrides:
+ virtual eAvailability GetBiome(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes) override;
+ virtual void HintViewArea(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ) override;
+
+ void SetSource(cBiomeSource * a_Source); // Takes ownership of the source ptr
+
+protected:
+ class cItem
+ {
+ public:
+ cItem(int a_ChunkX, int a_ChunkZ);
+
+ int m_ChunkX;
+ int m_ChunkZ;
+ bool m_IsValid;
+ cChunkDef::BiomeMap m_Biomes;
+ } ;
+
+ typedef cItem * pItem;
+ typedef std::list<pItem> cItems;
+
+ class cThread :
+ public cIsThread
+ {
+ typedef cIsThread super;
+
+ public:
+ cThread(cBiomeCache & a_Parent);
+
+ // cIsThread overrides:
+ virtual void Execute(void) override;
+
+ protected:
+ cBiomeCache & m_Parent;
+ } ;
+
+ typedef std::list<cThread *> cThreads;
+
+ cBiomeSource * m_Source;
+
+ cCriticalSection m_CS;
+ int m_BaseX; ///< MinChunkX for the m_Available rectangle
+ int m_BaseZ; ///< MinChunkZ for the m_Available rectangle
+ int m_Width; ///< Width of the m_Available rectangle
+ int m_Height; ///< Height of the m_Available rectangle
+ pItem * m_Available; ///< Items that have already been processed (baNow or baNever), [x + m_Width * z]
+ cItems m_Queue; ///< Items that are queued for processing (baLater)
+ cItems m_Pool; ///< Items that are not needed anymore, can be reused for other coords
+
+ cEvent m_evtQueued; // Triggerred when an item is added to m_Queue
+
+ cThreads m_Threads; // Threads that update the cache.
+ bool m_IsTerminatingThreads; // Set to true to indicate to all threads that they should exit
+
+ /// Removes from a_Items all items that are outside of the given coords, moves those into m_Pool
+ void FilterOutItems(cItems & a_Items, int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ);
+
+ /// Processes one item from m_Queue into m_Available. Blocks if m_Queue is empty; respects m_IsTerminatingThreads
+ void thrProcessQueueItem(void);
+} ;
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeRenderer.cpp b/Tools/BiomeVisualiser/BiomeRenderer.cpp
index 7c4302d70..98548179c 100644
--- a/Tools/BiomeVisualiser/BiomeRenderer.cpp
+++ b/Tools/BiomeVisualiser/BiomeRenderer.cpp
@@ -1,147 +1,147 @@
-
-// BiomeRenderer.cpp
-
-// Implements the cBiomeRenderer class representing the rendering engine
-
-#include "Globals.h"
-#include "BiomeRenderer.h"
-#include "Pixmap.h"
-#include "Timer.h"
-
-
-
-
-
-cBiomeRenderer::cBiomeRenderer(void) :
- m_OriginX(160),
- m_OriginY(160),
- m_Zoom(1)
-{
-}
-
-
-
-
-void cBiomeRenderer::SetSource(cBiomeSource * a_Source)
-{
- m_Cache.SetSource(a_Source);
-}
-
-
-
-
-
-bool cBiomeRenderer::Render(cPixmap & a_Pixmap)
-{
- cTimer Timer("cBiomeRenderer::Render");
-
- int Wid = a_Pixmap.GetWidth();
- int Hei = a_Pixmap.GetHeight();
-
- // Hint the approximate view area to the biome source so that it can adjust its caches:
- int MinBlockX = ( - m_OriginX) / m_Zoom;
- int MaxBlockX = (Wid - m_OriginX) / m_Zoom;
- int MinBlockZ = ( - m_OriginY) / m_Zoom;
- int MaxBlockZ = (Hei - m_OriginY) / m_Zoom;
- m_Cache.HintViewArea(MinBlockX / 16 - 1, MaxBlockX / 16 + 1, MinBlockZ / 16 - 1, MaxBlockZ / 16 + 1);
-
- // Hold one current chunk of biome data:
- int CurChunkX = -10000;
- int CurChunkZ = -10000;
- cChunkDef::BiomeMap CurBiomes;
-
- bool res = false;
-
- for (int y = 0; y < Hei; y++)
- {
- int BlockZ = (y - m_OriginY) / m_Zoom;
- int ChunkZ = (BlockZ >= 0) ? (BlockZ / 16) : ((BlockZ + 1) / 16 - 1);
- int RelZ = BlockZ - ChunkZ * 16;
- for (int x = 0; x < Wid; x++)
- {
- int BlockX = (x - m_OriginX) / m_Zoom;
- int ChunkX = (BlockX >= 0) ? (BlockX / 16) : ((BlockX + 1) / 16 - 1);
- int RelX = BlockX - ChunkX * 16;
- if ((ChunkZ != CurChunkZ) || (ChunkX != CurChunkX))
- {
- CurChunkX = ChunkX;
- CurChunkZ = ChunkZ;
- switch (m_Cache.GetBiome(CurChunkX, CurChunkZ, CurBiomes))
- {
- case cBiomeSource::baLater:
- {
- res = true;
- // fallthrough:
- }
- case cBiomeSource::baNever:
- {
- for (int i = 0; i < ARRAYCOUNT(CurBiomes); i++)
- {
- CurBiomes[i] = (EMCSBiome)-1;
- }
- break;
- }
- } // switch (Biome availability)
- }
- EMCSBiome Biome = cChunkDef::GetBiome(CurBiomes, RelX, RelZ);
- a_Pixmap.SetPixel(x, y, GetBiomeColor(Biome));
- } // for x
- } // for y
- return res;
-}
-
-
-
-
-
-int cBiomeRenderer::GetBiomeColor(EMCSBiome a_Biome)
-{
- if ((a_Biome < 0) || (a_Biome > biMaxBiome))
- {
- return 0xcfcfcf; // LtGray for unknown biomes
- }
-
- static int BiomeColor[] =
- {
- // RGB:
- 0x0000ff, /* Ocean */
- 0x00cf3f, /* Plains */
- 0xffff00, /* Desert */
- 0x7f7f7f, /* Extreme Hills */
- 0x00cf00, /* Forest */
- 0x007f3f, /* Taiga */
- 0x3f7f00, /* Swampland */
- 0x003fff, /* River */
- 0x7f0000, /* Hell */
- 0x007fff, /* Sky */
- 0x3f3fff, /* Frozen Ocean */
- 0x3f3fff, /* Frozen River */
- 0x7fffcf, /* Ice Plains */
- 0x3fcf7f, /* Ice Mountains */
- 0xcf00cf, /* Mushroom Island */
- 0x7f00ff, /* Mushroom Island Shore */
- 0xffff3f, /* Beach */
- 0xcfcf00, /* Desert Hills */
- 0x00cf3f, /* Forest Hills */
- 0x006f1f, /* Taiga Hills */
- 0x7f8f7f, /* Extreme Hills Edge */
- 0x004f00, /* Jungle */
- 0x003f00, /* Jungle Hills */
- } ;
-
- return BiomeColor[a_Biome];
-}
-
-
-
-
-
-void cBiomeRenderer::MoveViewBy(int a_OffsX, int a_OffsY)
-{
- m_OriginX += a_OffsX;
- m_OriginY += a_OffsY;
-}
-
-
-
-
+
+// BiomeRenderer.cpp
+
+// Implements the cBiomeRenderer class representing the rendering engine
+
+#include "Globals.h"
+#include "BiomeRenderer.h"
+#include "Pixmap.h"
+#include "Timer.h"
+
+
+
+
+
+cBiomeRenderer::cBiomeRenderer(void) :
+ m_OriginX(160),
+ m_OriginY(160),
+ m_Zoom(1)
+{
+}
+
+
+
+
+void cBiomeRenderer::SetSource(cBiomeSource * a_Source)
+{
+ m_Cache.SetSource(a_Source);
+}
+
+
+
+
+
+bool cBiomeRenderer::Render(cPixmap & a_Pixmap)
+{
+ cTimer Timer("cBiomeRenderer::Render");
+
+ int Wid = a_Pixmap.GetWidth();
+ int Hei = a_Pixmap.GetHeight();
+
+ // Hint the approximate view area to the biome source so that it can adjust its caches:
+ int MinBlockX = ( - m_OriginX) / m_Zoom;
+ int MaxBlockX = (Wid - m_OriginX) / m_Zoom;
+ int MinBlockZ = ( - m_OriginY) / m_Zoom;
+ int MaxBlockZ = (Hei - m_OriginY) / m_Zoom;
+ m_Cache.HintViewArea(MinBlockX / 16 - 1, MaxBlockX / 16 + 1, MinBlockZ / 16 - 1, MaxBlockZ / 16 + 1);
+
+ // Hold one current chunk of biome data:
+ int CurChunkX = -10000;
+ int CurChunkZ = -10000;
+ cChunkDef::BiomeMap CurBiomes;
+
+ bool res = false;
+
+ for (int y = 0; y < Hei; y++)
+ {
+ int BlockZ = (y - m_OriginY) / m_Zoom;
+ int ChunkZ = (BlockZ >= 0) ? (BlockZ / 16) : ((BlockZ + 1) / 16 - 1);
+ int RelZ = BlockZ - ChunkZ * 16;
+ for (int x = 0; x < Wid; x++)
+ {
+ int BlockX = (x - m_OriginX) / m_Zoom;
+ int ChunkX = (BlockX >= 0) ? (BlockX / 16) : ((BlockX + 1) / 16 - 1);
+ int RelX = BlockX - ChunkX * 16;
+ if ((ChunkZ != CurChunkZ) || (ChunkX != CurChunkX))
+ {
+ CurChunkX = ChunkX;
+ CurChunkZ = ChunkZ;
+ switch (m_Cache.GetBiome(CurChunkX, CurChunkZ, CurBiomes))
+ {
+ case cBiomeSource::baLater:
+ {
+ res = true;
+ // fallthrough:
+ }
+ case cBiomeSource::baNever:
+ {
+ for (int i = 0; i < ARRAYCOUNT(CurBiomes); i++)
+ {
+ CurBiomes[i] = (EMCSBiome)-1;
+ }
+ break;
+ }
+ } // switch (Biome availability)
+ }
+ EMCSBiome Biome = cChunkDef::GetBiome(CurBiomes, RelX, RelZ);
+ a_Pixmap.SetPixel(x, y, GetBiomeColor(Biome));
+ } // for x
+ } // for y
+ return res;
+}
+
+
+
+
+
+int cBiomeRenderer::GetBiomeColor(EMCSBiome a_Biome)
+{
+ if ((a_Biome < 0) || (a_Biome > biMaxBiome))
+ {
+ return 0xcfcfcf; // LtGray for unknown biomes
+ }
+
+ static int BiomeColor[] =
+ {
+ // RGB:
+ 0x0000ff, /* Ocean */
+ 0x00cf3f, /* Plains */
+ 0xffff00, /* Desert */
+ 0x7f7f7f, /* Extreme Hills */
+ 0x00cf00, /* Forest */
+ 0x007f3f, /* Taiga */
+ 0x3f7f00, /* Swampland */
+ 0x003fff, /* River */
+ 0x7f0000, /* Hell */
+ 0x007fff, /* Sky */
+ 0x3f3fff, /* Frozen Ocean */
+ 0x3f3fff, /* Frozen River */
+ 0x7fffcf, /* Ice Plains */
+ 0x3fcf7f, /* Ice Mountains */
+ 0xcf00cf, /* Mushroom Island */
+ 0x7f00ff, /* Mushroom Island Shore */
+ 0xffff3f, /* Beach */
+ 0xcfcf00, /* Desert Hills */
+ 0x00cf3f, /* Forest Hills */
+ 0x006f1f, /* Taiga Hills */
+ 0x7f8f7f, /* Extreme Hills Edge */
+ 0x004f00, /* Jungle */
+ 0x003f00, /* Jungle Hills */
+ } ;
+
+ return BiomeColor[a_Biome];
+}
+
+
+
+
+
+void cBiomeRenderer::MoveViewBy(int a_OffsX, int a_OffsY)
+{
+ m_OriginX += a_OffsX;
+ m_OriginY += a_OffsY;
+}
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeRenderer.h b/Tools/BiomeVisualiser/BiomeRenderer.h
index 369c0f114..2590e0406 100644
--- a/Tools/BiomeVisualiser/BiomeRenderer.h
+++ b/Tools/BiomeVisualiser/BiomeRenderer.h
@@ -1,50 +1,50 @@
-
-// BiomeRenderer.h
-
-// Declares the cBiomeRenderer class representing the rendering engine
-
-
-
-
-
-#pragma once
-
-#include "BiomeCache.h"
-
-
-
-
-
-// fwd: Pixmap.h
-class cPixmap;
-
-
-
-
-
-class cBiomeRenderer
-{
-public:
- cBiomeRenderer(void);
-
- void SetSource(cBiomeSource * a_Source); // Takes ownership of the source
-
- /// Renders the biomes into the given pixmap. Returns true if some biome data was missing and can be retrieved later
- bool Render(cPixmap & a_Pixmap);
-
- /// Returns the RGB color value for the specified biome
- int GetBiomeColor(EMCSBiome a_Biome);
-
- void MoveViewBy(int a_OffsX, int a_OffsY);
-
-protected:
- cBiomeCache m_Cache;
-
- int m_OriginX;
- int m_OriginY;
- int m_Zoom;
-} ;
-
-
-
-
+
+// BiomeRenderer.h
+
+// Declares the cBiomeRenderer class representing the rendering engine
+
+
+
+
+
+#pragma once
+
+#include "BiomeCache.h"
+
+
+
+
+
+// fwd: Pixmap.h
+class cPixmap;
+
+
+
+
+
+class cBiomeRenderer
+{
+public:
+ cBiomeRenderer(void);
+
+ void SetSource(cBiomeSource * a_Source); // Takes ownership of the source
+
+ /// Renders the biomes into the given pixmap. Returns true if some biome data was missing and can be retrieved later
+ bool Render(cPixmap & a_Pixmap);
+
+ /// Returns the RGB color value for the specified biome
+ int GetBiomeColor(EMCSBiome a_Biome);
+
+ void MoveViewBy(int a_OffsX, int a_OffsY);
+
+protected:
+ cBiomeCache m_Cache;
+
+ int m_OriginX;
+ int m_OriginY;
+ int m_Zoom;
+} ;
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeSource.h b/Tools/BiomeVisualiser/BiomeSource.h
index e09242d04..4a5153457 100644
--- a/Tools/BiomeVisualiser/BiomeSource.h
+++ b/Tools/BiomeVisualiser/BiomeSource.h
@@ -1,37 +1,37 @@
-
-// BiomeSource.h
-
-// Declares the cBiomeSource abstract class used as an interface for getting biomes from any source
-
-#pragma once
-
-
-
-
-
-#include "ChunkDef.h"
-
-
-
-
-
-class cBiomeSource abstract
-{
-public:
- enum eAvailability
- {
- baNow, // Data returned now
- baLater, // Data not returned, but will be available later, try again after a while
- baNever, // Data not returned, will not be available at all
- } ;
-
- /// Fills a_Biomes with the biomes for the chunk specified
- virtual eAvailability GetBiome(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes) = 0;
-
- /// Used to inform the source about the view area that will be queried in the near future.
- virtual void HintViewArea(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ) = 0;
-} ;
-
-
-
-
+
+// BiomeSource.h
+
+// Declares the cBiomeSource abstract class used as an interface for getting biomes from any source
+
+#pragma once
+
+
+
+
+
+#include "ChunkDef.h"
+
+
+
+
+
+class cBiomeSource abstract
+{
+public:
+ enum eAvailability
+ {
+ baNow, // Data returned now
+ baLater, // Data not returned, but will be available later, try again after a while
+ baNever, // Data not returned, will not be available at all
+ } ;
+
+ /// Fills a_Biomes with the biomes for the chunk specified
+ virtual eAvailability GetBiome(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes) = 0;
+
+ /// Used to inform the source about the view area that will be queried in the near future.
+ virtual void HintViewArea(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ) = 0;
+} ;
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp
index 503b94f0c..3dd1bb4e0 100644
--- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp
+++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp
@@ -1,190 +1,190 @@
-
-// BiomeViewWnd.cpp
-
-// Implements the cBiomeViewWnd class representing the window that displays biomes
-
-#include "Globals.h"
-#include "BiomeViewWnd.h"
-#include "BiomeCache.h"
-#include "GeneratorBiomeSource.h"
-#include "../iniFile/iniFile.h"
-
-
-
-
-
-const int TIMER_RERENDER = 1200;
-
-
-
-
-
-cBiomeViewWnd::cBiomeViewWnd(void) :
- m_Wnd(NULL),
- m_Thunk(&cBiomeViewWnd::WndProc, this),
- m_IsLButtonDown(false)
-{
-}
-
-
-
-
-
-bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title)
-{
- ASSERT(m_Wnd == NULL);
-
- // Create a regular STATIC window, then override its window procedure with our own. No need for obnoxious RegisterWindowClass() stuff.
- m_Wnd = CreateWindow("STATIC", a_Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 400, 300, a_ParentWnd, NULL, GetModuleHandle(NULL), NULL);
- if (m_Wnd == NULL)
- {
- LOGERROR("Cannot create main window: %d", GetLastError());
- return false;
- }
- SetWindowLongPtr(m_Wnd, GWLP_WNDPROC, m_Thunk);
-
- cIniFile IniFile;
- cBiomeGen * BioGen = new cBioGenMultiStepMap(2);
- BioGen->Initialize(IniFile);
- m_Renderer.SetSource(new cGeneratorBiomeSource(BioGen));
-
- return true;
-}
-
-
-
-
-
-
-LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam)
-{
- switch (a_Msg)
- {
- case WM_CLOSE: return OnClose();
- case WM_COMMAND: return OnCommand(wParam, lParam);
- case WM_LBUTTONDOWN: return OnLButtonDown(wParam, lParam);
- case WM_LBUTTONUP: return OnLButtonUp (wParam, lParam);
- case WM_MOUSEMOVE: return OnMouseMove (wParam, lParam);
- case WM_PAINT: return OnPaint();
- case WM_TIMER: return OnTimer(wParam);
- }
- return ::DefWindowProc(a_Wnd, a_Msg, wParam, lParam);
-}
-
-
-
-
-
-LRESULT cBiomeViewWnd::OnClose(void)
-{
- PostQuitMessage(0);
- return 0;
-}
-
-
-
-
-
-LRESULT cBiomeViewWnd::OnCommand(WPARAM wParam, LPARAM lParam)
-{
- // TODO: Handle menu commands, when we get menu
- return 0;
-}
-
-
-
-
-
-LRESULT cBiomeViewWnd::OnLButtonDown(WPARAM wParam, LPARAM lParam)
-{
- m_IsLButtonDown = true;
- GetCursorPos(&m_MouseDown);
- return 0;
-}
-
-
-
-
-
-LRESULT cBiomeViewWnd::OnMouseMove(WPARAM wParam, LPARAM lParam)
-{
- if (!m_IsLButtonDown)
- {
- return 0;
- }
- POINT pnt;
- GetCursorPos(&pnt);
- m_Renderer.MoveViewBy(pnt.x - m_MouseDown.x, pnt.y - m_MouseDown.y);
- if (m_Renderer.Render(m_Pixmap))
- {
- SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL);
- }
- m_MouseDown = pnt;
- InvalidateRect(m_Wnd, NULL, FALSE);
- return 0;
-}
-
-
-
-
-
-LRESULT cBiomeViewWnd::OnLButtonUp(WPARAM wParam, LPARAM lParam)
-{
- OnMouseMove(wParam, lParam); // Last movement - if the mouse move hasn't been reported due to speed
- m_IsLButtonDown = false;
- InvalidateRect(m_Wnd, NULL, FALSE);
- return 0;
-}
-
-
-
-
-
-LRESULT cBiomeViewWnd::OnPaint(void)
-{
- PAINTSTRUCT ps;
- HDC DC = BeginPaint(m_Wnd, &ps);
-
- RECT rc;
- GetClientRect(m_Wnd, &rc);
- int Wid = rc.right - rc.left;
- int Hei = rc.bottom - rc.top;
- if ((m_Pixmap.GetWidth() != Wid) || (m_Pixmap.GetHeight() != Hei))
- {
- m_Pixmap.SetSize(Wid, Hei);
- if (m_Renderer.Render(m_Pixmap))
- {
- SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL);
- }
- }
-
- m_Pixmap.DrawToDC(DC, 0, 0);
-
- EndPaint(m_Wnd, &ps);
- return 0;
-}
-
-
-
-
-
-LRESULT cBiomeViewWnd::OnTimer(WPARAM wParam)
-{
- switch (wParam)
- {
- case TIMER_RERENDER:
- {
- if (!m_Renderer.Render(m_Pixmap))
- {
- KillTimer(m_Wnd, TIMER_RERENDER);
- }
- InvalidateRect(m_Wnd, NULL, FALSE);
- break;
- }
- }
- return 0;
-}
-
-
-
-
+
+// BiomeViewWnd.cpp
+
+// Implements the cBiomeViewWnd class representing the window that displays biomes
+
+#include "Globals.h"
+#include "BiomeViewWnd.h"
+#include "BiomeCache.h"
+#include "GeneratorBiomeSource.h"
+#include "../iniFile/iniFile.h"
+
+
+
+
+
+const int TIMER_RERENDER = 1200;
+
+
+
+
+
+cBiomeViewWnd::cBiomeViewWnd(void) :
+ m_Wnd(NULL),
+ m_Thunk(&cBiomeViewWnd::WndProc, this),
+ m_IsLButtonDown(false)
+{
+}
+
+
+
+
+
+bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title)
+{
+ ASSERT(m_Wnd == NULL);
+
+ // Create a regular STATIC window, then override its window procedure with our own. No need for obnoxious RegisterWindowClass() stuff.
+ m_Wnd = CreateWindow("STATIC", a_Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 400, 300, a_ParentWnd, NULL, GetModuleHandle(NULL), NULL);
+ if (m_Wnd == NULL)
+ {
+ LOGERROR("Cannot create main window: %d", GetLastError());
+ return false;
+ }
+ SetWindowLongPtr(m_Wnd, GWLP_WNDPROC, m_Thunk);
+
+ cIniFile IniFile;
+ cBiomeGen * BioGen = new cBioGenMultiStepMap(2);
+ BioGen->Initialize(IniFile);
+ m_Renderer.SetSource(new cGeneratorBiomeSource(BioGen));
+
+ return true;
+}
+
+
+
+
+
+
+LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (a_Msg)
+ {
+ case WM_CLOSE: return OnClose();
+ case WM_COMMAND: return OnCommand(wParam, lParam);
+ case WM_LBUTTONDOWN: return OnLButtonDown(wParam, lParam);
+ case WM_LBUTTONUP: return OnLButtonUp (wParam, lParam);
+ case WM_MOUSEMOVE: return OnMouseMove (wParam, lParam);
+ case WM_PAINT: return OnPaint();
+ case WM_TIMER: return OnTimer(wParam);
+ }
+ return ::DefWindowProc(a_Wnd, a_Msg, wParam, lParam);
+}
+
+
+
+
+
+LRESULT cBiomeViewWnd::OnClose(void)
+{
+ PostQuitMessage(0);
+ return 0;
+}
+
+
+
+
+
+LRESULT cBiomeViewWnd::OnCommand(WPARAM wParam, LPARAM lParam)
+{
+ // TODO: Handle menu commands, when we get menu
+ return 0;
+}
+
+
+
+
+
+LRESULT cBiomeViewWnd::OnLButtonDown(WPARAM wParam, LPARAM lParam)
+{
+ m_IsLButtonDown = true;
+ GetCursorPos(&m_MouseDown);
+ return 0;
+}
+
+
+
+
+
+LRESULT cBiomeViewWnd::OnMouseMove(WPARAM wParam, LPARAM lParam)
+{
+ if (!m_IsLButtonDown)
+ {
+ return 0;
+ }
+ POINT pnt;
+ GetCursorPos(&pnt);
+ m_Renderer.MoveViewBy(pnt.x - m_MouseDown.x, pnt.y - m_MouseDown.y);
+ if (m_Renderer.Render(m_Pixmap))
+ {
+ SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL);
+ }
+ m_MouseDown = pnt;
+ InvalidateRect(m_Wnd, NULL, FALSE);
+ return 0;
+}
+
+
+
+
+
+LRESULT cBiomeViewWnd::OnLButtonUp(WPARAM wParam, LPARAM lParam)
+{
+ OnMouseMove(wParam, lParam); // Last movement - if the mouse move hasn't been reported due to speed
+ m_IsLButtonDown = false;
+ InvalidateRect(m_Wnd, NULL, FALSE);
+ return 0;
+}
+
+
+
+
+
+LRESULT cBiomeViewWnd::OnPaint(void)
+{
+ PAINTSTRUCT ps;
+ HDC DC = BeginPaint(m_Wnd, &ps);
+
+ RECT rc;
+ GetClientRect(m_Wnd, &rc);
+ int Wid = rc.right - rc.left;
+ int Hei = rc.bottom - rc.top;
+ if ((m_Pixmap.GetWidth() != Wid) || (m_Pixmap.GetHeight() != Hei))
+ {
+ m_Pixmap.SetSize(Wid, Hei);
+ if (m_Renderer.Render(m_Pixmap))
+ {
+ SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL);
+ }
+ }
+
+ m_Pixmap.DrawToDC(DC, 0, 0);
+
+ EndPaint(m_Wnd, &ps);
+ return 0;
+}
+
+
+
+
+
+LRESULT cBiomeViewWnd::OnTimer(WPARAM wParam)
+{
+ switch (wParam)
+ {
+ case TIMER_RERENDER:
+ {
+ if (!m_Renderer.Render(m_Pixmap))
+ {
+ KillTimer(m_Wnd, TIMER_RERENDER);
+ }
+ InvalidateRect(m_Wnd, NULL, FALSE);
+ break;
+ }
+ }
+ return 0;
+}
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.h b/Tools/BiomeVisualiser/BiomeViewWnd.h
index d8ad8d182..88e808ab3 100644
--- a/Tools/BiomeVisualiser/BiomeViewWnd.h
+++ b/Tools/BiomeVisualiser/BiomeViewWnd.h
@@ -1,46 +1,46 @@
-
-// BiomeViewWnd.h
-
-// Declares the cBiomeViewWnd class representing the window that displays biomes
-
-#include "WndProcThunk.h"
-#include "BiomeRenderer.h"
-#include "BiomeCache.h"
-#include "Pixmap.h"
-
-
-
-
-
-class cBiomeViewWnd
-{
-public:
- cBiomeViewWnd(void);
-
- bool Create(HWND a_ParentWnd, LPCTSTR a_Title);
-
-protected:
- HWND m_Wnd;
- CWndProcThunk<cBiomeViewWnd> m_Thunk;
-
- cBiomeRenderer m_Renderer;
- cPixmap m_Pixmap;
-
- bool m_IsLButtonDown;
- POINT m_MouseDown;
-
- LRESULT WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam);
-
- // Message handlers:
- LRESULT OnClose (void);
- LRESULT OnCommand (WPARAM wParam, LPARAM lParam);
- LRESULT OnLButtonDown(WPARAM wParam, LPARAM lParam);
- LRESULT OnMouseMove (WPARAM wParam, LPARAM lParam);
- LRESULT OnLButtonUp (WPARAM wParam, LPARAM lParam);
- LRESULT OnPaint (void);
- LRESULT OnTimer (WPARAM wParam);
-} ;
-
-
-
-
+
+// BiomeViewWnd.h
+
+// Declares the cBiomeViewWnd class representing the window that displays biomes
+
+#include "WndProcThunk.h"
+#include "BiomeRenderer.h"
+#include "BiomeCache.h"
+#include "Pixmap.h"
+
+
+
+
+
+class cBiomeViewWnd
+{
+public:
+ cBiomeViewWnd(void);
+
+ bool Create(HWND a_ParentWnd, LPCTSTR a_Title);
+
+protected:
+ HWND m_Wnd;
+ CWndProcThunk<cBiomeViewWnd> m_Thunk;
+
+ cBiomeRenderer m_Renderer;
+ cPixmap m_Pixmap;
+
+ bool m_IsLButtonDown;
+ POINT m_MouseDown;
+
+ LRESULT WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam);
+
+ // Message handlers:
+ LRESULT OnClose (void);
+ LRESULT OnCommand (WPARAM wParam, LPARAM lParam);
+ LRESULT OnLButtonDown(WPARAM wParam, LPARAM lParam);
+ LRESULT OnMouseMove (WPARAM wParam, LPARAM lParam);
+ LRESULT OnLButtonUp (WPARAM wParam, LPARAM lParam);
+ LRESULT OnPaint (void);
+ LRESULT OnTimer (WPARAM wParam);
+} ;
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.cpp b/Tools/BiomeVisualiser/BiomeVisualiser.cpp
index dc1d490e8..e1d379f83 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.cpp
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.cpp
@@ -1,52 +1,52 @@
-
-// BiomeVisualiser.cpp
-
-// Implements the cBiomeVisualiser class representing the entire app. Also implements the WinMain() entrypoint
-
-#include "Globals.h"
-#include "time.h"
-#include "BiomeVisualiser.h"
-
-
-
-
-
-int WINAPI WinMain(HINSTANCE a_Instance, HINSTANCE a_PrevInstance, LPSTR a_CmdLine, int a_ShowCmd)
-{
- cBiomeVisualiser App;
- return App.Run();
-}
-
-
-
-
-
-cBiomeVisualiser::cBiomeVisualiser(void)
- // : m_Logger(Printf("BiomeVisualiser_%08x", time(NULL)))
-{
-}
-
-
-
-
-
-int cBiomeVisualiser::Run(void)
-{
- if (!m_MainWnd.Create(GetDesktopWindow(), TEXT("BiomeVisualiser")))
- {
- LOGERROR("Cannot create main window: %d", GetLastError());
- return 1;
- }
-
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- } // while (GetMessage)
- return msg.lParam;
-}
-
-
-
-
+
+// BiomeVisualiser.cpp
+
+// Implements the cBiomeVisualiser class representing the entire app. Also implements the WinMain() entrypoint
+
+#include "Globals.h"
+#include "time.h"
+#include "BiomeVisualiser.h"
+
+
+
+
+
+int WINAPI WinMain(HINSTANCE a_Instance, HINSTANCE a_PrevInstance, LPSTR a_CmdLine, int a_ShowCmd)
+{
+ cBiomeVisualiser App;
+ return App.Run();
+}
+
+
+
+
+
+cBiomeVisualiser::cBiomeVisualiser(void)
+ // : m_Logger(Printf("BiomeVisualiser_%08x", time(NULL)))
+{
+}
+
+
+
+
+
+int cBiomeVisualiser::Run(void)
+{
+ if (!m_MainWnd.Create(GetDesktopWindow(), TEXT("BiomeVisualiser")))
+ {
+ LOGERROR("Cannot create main window: %d", GetLastError());
+ return 1;
+ }
+
+ MSG msg;
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ } // while (GetMessage)
+ return msg.lParam;
+}
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.h b/Tools/BiomeVisualiser/BiomeVisualiser.h
index 4788bb7ea..3fa90646b 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.h
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.h
@@ -1,31 +1,31 @@
-
-// BiomeVisualiser.h
-
-// Declares the cBiomeVisualiser class representing the entire application
-
-
-
-
-
-#include "BiomeViewWnd.h"
-
-
-
-
-
-class cBiomeVisualiser
-{
-public:
- cBiomeVisualiser(void);
-
- int Run(void);
-
-protected:
- cBiomeViewWnd m_MainWnd;
-
- cMCLogger m_Logger;
-} ;
-
-
-
-
+
+// BiomeVisualiser.h
+
+// Declares the cBiomeVisualiser class representing the entire application
+
+
+
+
+
+#include "BiomeViewWnd.h"
+
+
+
+
+
+class cBiomeVisualiser
+{
+public:
+ cBiomeVisualiser(void);
+
+ int Run(void);
+
+protected:
+ cBiomeViewWnd m_MainWnd;
+
+ cMCLogger m_Logger;
+} ;
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.sln b/Tools/BiomeVisualiser/BiomeVisualiser.sln
index b10d65f2f..bdfb586b1 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.sln
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.sln
@@ -1,23 +1,23 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BiomeVisualiser", "BiomeVisualiser.vcproj", "{6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release profiled|Win32 = Release profiled|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Debug|Win32.ActiveCfg = Debug|Win32
- {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Debug|Win32.Build.0 = Debug|Win32
- {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Release|Win32.ActiveCfg = Release|Win32
- {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BiomeVisualiser", "BiomeVisualiser.vcproj", "{6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release profiled|Win32 = Release profiled|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Debug|Win32.Build.0 = Debug|Win32
+ {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Release|Win32.ActiveCfg = Release|Win32
+ {6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
index 0e1f1bfe0..522606d60 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
@@ -1,483 +1,483 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="BiomeVisualiser"
- ProjectGUID="{6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}"
- RootNamespace="BiomeVisualiser"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../../source"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="2"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="1"
- AdditionalIncludeDirectories="../../source"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- EnableEnhancedInstructionSet="2"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release profiled|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="2"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="1"
- AdditionalIncludeDirectories="../../source"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- EnableEnhancedInstructionSet="2"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- Profile="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\BiomeCache.cpp"
- >
- </File>
- <File
- RelativePath=".\BiomeCache.h"
- >
- </File>
- <File
- RelativePath=".\BiomeRenderer.cpp"
- >
- </File>
- <File
- RelativePath=".\BiomeRenderer.h"
- >
- </File>
- <File
- RelativePath=".\BiomeSource.h"
- >
- </File>
- <File
- RelativePath=".\BiomeViewWnd.cpp"
- >
- </File>
- <File
- RelativePath=".\BiomeViewWnd.h"
- >
- </File>
- <File
- RelativePath=".\BiomeVisualiser.cpp"
- >
- </File>
- <File
- RelativePath=".\BiomeVisualiser.h"
- >
- </File>
- <File
- RelativePath=".\GeneratorBiomeSource.h"
- >
- </File>
- <File
- RelativePath=".\Pixmap.cpp"
- >
- </File>
- <File
- RelativePath=".\Pixmap.h"
- >
- </File>
- <File
- RelativePath=".\Timer.h"
- >
- </File>
- <File
- RelativePath=".\WndProcThunk.h"
- >
- </File>
- <Filter
- Name="Shared"
- >
- <File
- RelativePath="..\..\source\BlockID.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\BlockID.h"
- >
- </File>
- <File
- RelativePath="..\..\source\ChunkDef.h"
- >
- </File>
- <File
- RelativePath="..\..\source\Globals.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\source\Globals.h"
- >
- </File>
- <File
- RelativePath="..\..\source\Log.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\Log.h"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.h"
- >
- </File>
- <File
- RelativePath="..\..\source\Noise.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\Noise.h"
- >
- </File>
- <File
- RelativePath="..\..\source\Noise.inc"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.h"
- >
- </File>
- <Filter
- Name="OSSupport"
- >
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\Event.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\Event.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\Sleep.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Generating"
- >
- <File
- RelativePath="..\..\source\Generating\BioGen.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\Generating\BioGen.h"
- >
- </File>
- <File
- RelativePath="..\..\source\Generating\ComposableGenerator.h"
- >
- </File>
- </Filter>
- <Filter
- Name="iniFile"
- >
- <File
- RelativePath="..\..\iniFile\iniFile.cpp"
- >
- </File>
- <File
- RelativePath="..\..\iniFile\iniFile.h"
- >
- </File>
- </Filter>
- </Filter>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="BiomeVisualiser"
+ ProjectGUID="{6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}"
+ RootNamespace="BiomeVisualiser"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../source"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="../../source"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="2"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="../../source"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="2"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ Profile="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\BiomeCache.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeCache.h"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeRenderer.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeRenderer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeSource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeViewWnd.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeViewWnd.h"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeVisualiser.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\BiomeVisualiser.h"
+ >
+ </File>
+ <File
+ RelativePath=".\GeneratorBiomeSource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Pixmap.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Pixmap.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Timer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\WndProcThunk.h"
+ >
+ </File>
+ <Filter
+ Name="Shared"
+ >
+ <File
+ RelativePath="..\..\source\BlockID.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\BlockID.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\ChunkDef.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Globals.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\source\Globals.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Log.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Log.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Noise.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Noise.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Noise.inc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.h"
+ >
+ </File>
+ <Filter
+ Name="OSSupport"
+ >
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\Event.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\Event.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\Sleep.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Generating"
+ >
+ <File
+ RelativePath="..\..\source\Generating\BioGen.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Generating\BioGen.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Generating\ComposableGenerator.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="iniFile"
+ >
+ <File
+ RelativePath="..\..\iniFile\iniFile.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\iniFile\iniFile.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Tools/BiomeVisualiser/GeneratorBiomeSource.h b/Tools/BiomeVisualiser/GeneratorBiomeSource.h
index 34970491e..0b47e5f93 100644
--- a/Tools/BiomeVisualiser/GeneratorBiomeSource.h
+++ b/Tools/BiomeVisualiser/GeneratorBiomeSource.h
@@ -1,42 +1,42 @@
-
-// GeneratorBiomeSource.h
-
-// Declares the cGeneratorBiomeSource that adapts a cBiomeGen into a cBiomeSource
-
-#include "../source/Generating/BioGen.h"
-#include "BiomeSource.h"
-
-
-
-
-
-class cGeneratorBiomeSource :
- public cBiomeSource
-{
-public:
- cGeneratorBiomeSource(cBiomeGen * a_Generator) : m_Generator(a_Generator) {} // Takes ownership of the generator ptr
-
- ~cGeneratorBiomeSource()
- {
- delete m_Generator;
- }
-
- // cBiomeSource overrides:
- virtual eAvailability GetBiome(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes) override
- {
- m_Generator->GenBiomes(a_ChunkX, a_ChunkZ, a_Biomes);
- return baNow;
- }
-
- virtual void HintViewArea(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ) override
- {
- // Nothing needed
- }
-
-protected:
- cBiomeGen * m_Generator;
-} ;
-
-
-
-
+
+// GeneratorBiomeSource.h
+
+// Declares the cGeneratorBiomeSource that adapts a cBiomeGen into a cBiomeSource
+
+#include "../source/Generating/BioGen.h"
+#include "BiomeSource.h"
+
+
+
+
+
+class cGeneratorBiomeSource :
+ public cBiomeSource
+{
+public:
+ cGeneratorBiomeSource(cBiomeGen * a_Generator) : m_Generator(a_Generator) {} // Takes ownership of the generator ptr
+
+ ~cGeneratorBiomeSource()
+ {
+ delete m_Generator;
+ }
+
+ // cBiomeSource overrides:
+ virtual eAvailability GetBiome(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes) override
+ {
+ m_Generator->GenBiomes(a_ChunkX, a_ChunkZ, a_Biomes);
+ return baNow;
+ }
+
+ virtual void HintViewArea(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ) override
+ {
+ // Nothing needed
+ }
+
+protected:
+ cBiomeGen * m_Generator;
+} ;
+
+
+
+
diff --git a/Tools/BiomeVisualiser/Pixmap.cpp b/Tools/BiomeVisualiser/Pixmap.cpp
index 39a015b9c..1a80cf465 100644
--- a/Tools/BiomeVisualiser/Pixmap.cpp
+++ b/Tools/BiomeVisualiser/Pixmap.cpp
@@ -1,120 +1,120 @@
-
-// Pixmap.cpp
-
-// Implements the cPixmap class that represents a RGB pixmap and allows simple operations on it
-
-#include "Globals.h"
-#include "Pixmap.h"
-
-
-
-
-
-cPixmap::cPixmap(void) :
- m_Width(0),
- m_Height(0),
- m_Stride(0),
- m_Pixels(NULL)
-{
-}
-
-
-
-
-
-cPixmap::cPixmap(int a_Width, int a_Height) :
- m_Width(0),
- m_Height(0),
- m_Stride(0),
- m_Pixels(NULL)
-{
- SetSize(a_Width, a_Height);
-}
-
-
-
-
-
-cPixmap::~cPixmap()
-{
- delete m_Pixels;
-}
-
-
-
-
-
-void cPixmap::SetSize(int a_Width, int a_Height)
-{
- delete m_Pixels;
- m_Pixels = new int[a_Width * a_Height];
- m_Width = a_Width;
- m_Height = a_Height;
- m_Stride = m_Width; // Currently we don't need a special stride value, but let's support it for the future :)
-}
-
-
-
-
-
-void cPixmap::SetPixel(int a_X, int a_Y, int a_Color)
-{
- ASSERT(a_X >= 0);
- ASSERT(a_X < m_Width);
- ASSERT(a_Y >= 0);
- ASSERT(a_Y < m_Height);
-
- m_Pixels[a_X + a_Y * m_Stride] = a_Color;
-}
-
-
-
-
-
-int cPixmap::GetPixel(int a_X, int a_Y) const
-{
- ASSERT(a_X >= 0);
- ASSERT(a_X < m_Width);
- ASSERT(a_Y >= 0);
- ASSERT(a_Y < m_Height);
-
- return m_Pixels[a_X + a_Y * m_Stride];
-}
-
-
-
-
-
-void cPixmap::Fill(int a_Color)
-{
- int NumElements = m_Height * m_Stride;
- for (int i = 0; i < NumElements; i++)
- {
- m_Pixels[i] = a_Color;
- }
-}
-
-
-
-
-
-void cPixmap::DrawToDC(HDC a_DC, int a_OriginX, int a_OriginY)
-{
- BITMAPINFO bmi;
- bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
- bmi.bmiHeader.biWidth = m_Width;
- bmi.bmiHeader.biHeight = -m_Height; // Negative, we are top-down, unlike BMPs
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = m_Stride * m_Height * 4;
- bmi.bmiHeader.biXPelsPerMeter = 1440;
- bmi.bmiHeader.biYPelsPerMeter = 1440;
- bmi.bmiHeader.biClrUsed = 0;
- bmi.bmiHeader.biClrImportant = 0;
- SetDIBitsToDevice(a_DC, a_OriginX, a_OriginY, m_Width, m_Height, 0, 0, 0, m_Height, m_Pixels, &bmi, DIB_RGB_COLORS);
-}
-
-
-
-
+
+// Pixmap.cpp
+
+// Implements the cPixmap class that represents a RGB pixmap and allows simple operations on it
+
+#include "Globals.h"
+#include "Pixmap.h"
+
+
+
+
+
+cPixmap::cPixmap(void) :
+ m_Width(0),
+ m_Height(0),
+ m_Stride(0),
+ m_Pixels(NULL)
+{
+}
+
+
+
+
+
+cPixmap::cPixmap(int a_Width, int a_Height) :
+ m_Width(0),
+ m_Height(0),
+ m_Stride(0),
+ m_Pixels(NULL)
+{
+ SetSize(a_Width, a_Height);
+}
+
+
+
+
+
+cPixmap::~cPixmap()
+{
+ delete m_Pixels;
+}
+
+
+
+
+
+void cPixmap::SetSize(int a_Width, int a_Height)
+{
+ delete m_Pixels;
+ m_Pixels = new int[a_Width * a_Height];
+ m_Width = a_Width;
+ m_Height = a_Height;
+ m_Stride = m_Width; // Currently we don't need a special stride value, but let's support it for the future :)
+}
+
+
+
+
+
+void cPixmap::SetPixel(int a_X, int a_Y, int a_Color)
+{
+ ASSERT(a_X >= 0);
+ ASSERT(a_X < m_Width);
+ ASSERT(a_Y >= 0);
+ ASSERT(a_Y < m_Height);
+
+ m_Pixels[a_X + a_Y * m_Stride] = a_Color;
+}
+
+
+
+
+
+int cPixmap::GetPixel(int a_X, int a_Y) const
+{
+ ASSERT(a_X >= 0);
+ ASSERT(a_X < m_Width);
+ ASSERT(a_Y >= 0);
+ ASSERT(a_Y < m_Height);
+
+ return m_Pixels[a_X + a_Y * m_Stride];
+}
+
+
+
+
+
+void cPixmap::Fill(int a_Color)
+{
+ int NumElements = m_Height * m_Stride;
+ for (int i = 0; i < NumElements; i++)
+ {
+ m_Pixels[i] = a_Color;
+ }
+}
+
+
+
+
+
+void cPixmap::DrawToDC(HDC a_DC, int a_OriginX, int a_OriginY)
+{
+ BITMAPINFO bmi;
+ bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
+ bmi.bmiHeader.biWidth = m_Width;
+ bmi.bmiHeader.biHeight = -m_Height; // Negative, we are top-down, unlike BMPs
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 32;
+ bmi.bmiHeader.biCompression = BI_RGB;
+ bmi.bmiHeader.biSizeImage = m_Stride * m_Height * 4;
+ bmi.bmiHeader.biXPelsPerMeter = 1440;
+ bmi.bmiHeader.biYPelsPerMeter = 1440;
+ bmi.bmiHeader.biClrUsed = 0;
+ bmi.bmiHeader.biClrImportant = 0;
+ SetDIBitsToDevice(a_DC, a_OriginX, a_OriginY, m_Width, m_Height, 0, 0, 0, m_Height, m_Pixels, &bmi, DIB_RGB_COLORS);
+}
+
+
+
+
diff --git a/Tools/BiomeVisualiser/Pixmap.h b/Tools/BiomeVisualiser/Pixmap.h
index d0159a886..e50f6e946 100644
--- a/Tools/BiomeVisualiser/Pixmap.h
+++ b/Tools/BiomeVisualiser/Pixmap.h
@@ -1,39 +1,39 @@
-
-// Pixmap.h
-
-// Declares a cPixmap class that represents a RGB pixmap and allows simple operations on it
-
-#pragma once
-
-
-
-
-
-class cPixmap
-{
-public:
- cPixmap(void);
- cPixmap(int a_Width, int a_Height);
- ~cPixmap();
-
- void SetSize(int a_Width, int a_Height);
-
- int GetWidth (void) const { return m_Width; }
- int GetHeight(void) const { return m_Height; }
-
- void SetPixel(int a_X, int a_Y, int a_Color);
- int GetPixel(int a_X, int a_Y) const;
- void Fill(int a_Color);
-
- void DrawToDC(HDC a_DC, int a_OriginX, int a_OriginY);
-
-protected:
- int m_Width;
- int m_Height;
- int m_Stride;
- int * m_Pixels;
-} ;
-
-
-
-
+
+// Pixmap.h
+
+// Declares a cPixmap class that represents a RGB pixmap and allows simple operations on it
+
+#pragma once
+
+
+
+
+
+class cPixmap
+{
+public:
+ cPixmap(void);
+ cPixmap(int a_Width, int a_Height);
+ ~cPixmap();
+
+ void SetSize(int a_Width, int a_Height);
+
+ int GetWidth (void) const { return m_Width; }
+ int GetHeight(void) const { return m_Height; }
+
+ void SetPixel(int a_X, int a_Y, int a_Color);
+ int GetPixel(int a_X, int a_Y) const;
+ void Fill(int a_Color);
+
+ void DrawToDC(HDC a_DC, int a_OriginX, int a_OriginY);
+
+protected:
+ int m_Width;
+ int m_Height;
+ int m_Stride;
+ int * m_Pixels;
+} ;
+
+
+
+
diff --git a/Tools/BiomeVisualiser/Timer.h b/Tools/BiomeVisualiser/Timer.h
index b18d37cb7..78c4b42c7 100644
--- a/Tools/BiomeVisualiser/Timer.h
+++ b/Tools/BiomeVisualiser/Timer.h
@@ -1,40 +1,40 @@
-
-// Timer.h
-
-// Declares the cTimer class representing a RAII class that measures time from its creation till its destruction
-
-
-
-
-
-#pragma once
-
-#include "time.h"
-
-
-
-
-
-class cTimer
-{
-public:
- cTimer(const AString & a_Title) :
- m_Title(a_Title),
- m_StartTime(clock())
- {
- }
-
- ~cTimer()
- {
- clock_t NumTicks = clock() - m_StartTime;
- LOG("%s took %d ticks (%.02f sec)", m_Title.c_str(), NumTicks, (double)NumTicks / CLOCKS_PER_SEC);
- }
-
-protected:
- AString m_Title;
- clock_t m_StartTime;
-} ;
-
-
-
-
+
+// Timer.h
+
+// Declares the cTimer class representing a RAII class that measures time from its creation till its destruction
+
+
+
+
+
+#pragma once
+
+#include "time.h"
+
+
+
+
+
+class cTimer
+{
+public:
+ cTimer(const AString & a_Title) :
+ m_Title(a_Title),
+ m_StartTime(clock())
+ {
+ }
+
+ ~cTimer()
+ {
+ clock_t NumTicks = clock() - m_StartTime;
+ LOG("%s took %d ticks (%.02f sec)", m_Title.c_str(), NumTicks, (double)NumTicks / CLOCKS_PER_SEC);
+ }
+
+protected:
+ AString m_Title;
+ clock_t m_StartTime;
+} ;
+
+
+
+
diff --git a/Tools/BiomeVisualiser/WndProcThunk.h b/Tools/BiomeVisualiser/WndProcThunk.h
index 6f33b5c3f..da995eb5f 100644
--- a/Tools/BiomeVisualiser/WndProcThunk.h
+++ b/Tools/BiomeVisualiser/WndProcThunk.h
@@ -1,143 +1,143 @@
-
-// WndProcThunk.h
-
-// Interfaces to the CWndProcThunk class responsible for WNDPROC class-thunking
-// For details, see http://www.hackcraft.net/cpp/windowsThunk/thiscall/
-// Also available is a CDlgProcThunk class doing the same work for DIALOGPROC
-
-// MD: Made NX-compat by allocating the code structure using VirtualAlloc(..., PAGE_EXECUTE_READWRITE)
-
-
-
-
-
-// fwd:
-template <class W> class CWndProcThunk;
-
-
-
-
-
-#ifndef WNDPROCTHUNK_H_INCLUDED
-#define WNDPROCTHUNK_H_INCLUDED
-
-
-
-
-template<typename To, typename From> inline To union_cast(From fr) throw()
-{
- union
- {
- From f;
- To t;
- } uc;
- uc.f = fr;
- return uc.t;
-}
-
-
-
-
-
-#pragma warning(push)
-#pragma warning(disable : 4355)
-
-#if defined(_M_IX86)
-
-#pragma pack(push,1)
-
-template <class W> class CWndProcThunk
-{
- typedef ::LRESULT (W::* WndProc)(::HWND, ::UINT, ::WPARAM, ::LPARAM);
- typedef CWndProcThunk ThisClass;
-
- struct SCode
- {
- BYTE m_mov; // mov ECX, m_this
- W * m_this; //
- BYTE m_jmp; // jmp m_relproc
- ptrdiff_t m_relproc; // relative jmp
- };
-
- SCode * Code;
-
-public:
- ThisClass(WndProc proc, W * obj)
- {
- Code = (SCode *)VirtualAlloc(NULL, sizeof(SCode), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- Code->m_mov = 0xB9,
- Code->m_this = obj,
- Code->m_jmp = 0xE9,
- Code->m_relproc = union_cast<char *>(proc) - reinterpret_cast<char *>(Code) - sizeof(*Code);
- ::FlushInstructionCache(::GetCurrentProcess(), Code, sizeof(*Code));
- }
-
- virtual ~CWndProcThunk()
- {
- VirtualFree(Code, sizeof(*Code), MEM_RELEASE);
- Code = NULL;
- }
-
- operator ::WNDPROC() const {return reinterpret_cast<::WNDPROC>(Code); }
- operator ::LONG_PTR() const {return reinterpret_cast<::LONG_PTR>(Code); }
-} ;
-
-
-
-
-
-template <class W> class CDlgProcThunk
-{
- typedef ::BOOL (W::* DlgProc)(::HWND, ::UINT, ::WPARAM, ::LPARAM);
- typedef CDlgProcThunk ThisClass;
-
- struct SCode
- {
- BYTE m_mov; // mov ECX, m_this
- W * m_this; //
- BYTE m_jmp; // jmp m_relproc
- ptrdiff_t m_relproc; // relative jmp
- };
-
- SCode * Code;
-
-public:
- CDlgProcThunk(DlgProc proc, W * obj)
- {
- Code = (SCode *)VirtualAlloc(NULL, sizeof(SCode), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- Code->m_mov = 0xB9,
- Code->m_this = obj,
- Code->m_jmp = 0xE9,
- Code->m_relproc = union_cast<char *>(proc) - reinterpret_cast<char *>(Code) - sizeof(*Code);
- ::FlushInstructionCache(::GetCurrentProcess(), Code, sizeof(*Code));
- }
-
- virtual ~CDlgProcThunk()
- {
- VirtualFree(Code, sizeof(*Code), MEM_RELEASE);
- Code = NULL;
- }
-
- operator ::DLGPROC() const {return reinterpret_cast<::DLGPROC>(Code); }
- operator ::LONG_PTR() const {return reinterpret_cast<::LONG_PTR>(Code); }
-} ;
-
-
-
-
-
- #pragma pack(pop)
-
-#else // _M_IX86
- #error Only X86 supported
-#endif
-
-
-
-
-
-#endif // WNDPROCTHUNK_H_INCLUDED
-
-
-
-
+
+// WndProcThunk.h
+
+// Interfaces to the CWndProcThunk class responsible for WNDPROC class-thunking
+// For details, see http://www.hackcraft.net/cpp/windowsThunk/thiscall/
+// Also available is a CDlgProcThunk class doing the same work for DIALOGPROC
+
+// MD: Made NX-compat by allocating the code structure using VirtualAlloc(..., PAGE_EXECUTE_READWRITE)
+
+
+
+
+
+// fwd:
+template <class W> class CWndProcThunk;
+
+
+
+
+
+#ifndef WNDPROCTHUNK_H_INCLUDED
+#define WNDPROCTHUNK_H_INCLUDED
+
+
+
+
+template<typename To, typename From> inline To union_cast(From fr) throw()
+{
+ union
+ {
+ From f;
+ To t;
+ } uc;
+ uc.f = fr;
+ return uc.t;
+}
+
+
+
+
+
+#pragma warning(push)
+#pragma warning(disable : 4355)
+
+#if defined(_M_IX86)
+
+#pragma pack(push,1)
+
+template <class W> class CWndProcThunk
+{
+ typedef ::LRESULT (W::* WndProc)(::HWND, ::UINT, ::WPARAM, ::LPARAM);
+ typedef CWndProcThunk ThisClass;
+
+ struct SCode
+ {
+ BYTE m_mov; // mov ECX, m_this
+ W * m_this; //
+ BYTE m_jmp; // jmp m_relproc
+ ptrdiff_t m_relproc; // relative jmp
+ };
+
+ SCode * Code;
+
+public:
+ ThisClass(WndProc proc, W * obj)
+ {
+ Code = (SCode *)VirtualAlloc(NULL, sizeof(SCode), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ Code->m_mov = 0xB9,
+ Code->m_this = obj,
+ Code->m_jmp = 0xE9,
+ Code->m_relproc = union_cast<char *>(proc) - reinterpret_cast<char *>(Code) - sizeof(*Code);
+ ::FlushInstructionCache(::GetCurrentProcess(), Code, sizeof(*Code));
+ }
+
+ virtual ~CWndProcThunk()
+ {
+ VirtualFree(Code, sizeof(*Code), MEM_RELEASE);
+ Code = NULL;
+ }
+
+ operator ::WNDPROC() const {return reinterpret_cast<::WNDPROC>(Code); }
+ operator ::LONG_PTR() const {return reinterpret_cast<::LONG_PTR>(Code); }
+} ;
+
+
+
+
+
+template <class W> class CDlgProcThunk
+{
+ typedef ::BOOL (W::* DlgProc)(::HWND, ::UINT, ::WPARAM, ::LPARAM);
+ typedef CDlgProcThunk ThisClass;
+
+ struct SCode
+ {
+ BYTE m_mov; // mov ECX, m_this
+ W * m_this; //
+ BYTE m_jmp; // jmp m_relproc
+ ptrdiff_t m_relproc; // relative jmp
+ };
+
+ SCode * Code;
+
+public:
+ CDlgProcThunk(DlgProc proc, W * obj)
+ {
+ Code = (SCode *)VirtualAlloc(NULL, sizeof(SCode), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ Code->m_mov = 0xB9,
+ Code->m_this = obj,
+ Code->m_jmp = 0xE9,
+ Code->m_relproc = union_cast<char *>(proc) - reinterpret_cast<char *>(Code) - sizeof(*Code);
+ ::FlushInstructionCache(::GetCurrentProcess(), Code, sizeof(*Code));
+ }
+
+ virtual ~CDlgProcThunk()
+ {
+ VirtualFree(Code, sizeof(*Code), MEM_RELEASE);
+ Code = NULL;
+ }
+
+ operator ::DLGPROC() const {return reinterpret_cast<::DLGPROC>(Code); }
+ operator ::LONG_PTR() const {return reinterpret_cast<::LONG_PTR>(Code); }
+} ;
+
+
+
+
+
+ #pragma pack(pop)
+
+#else // _M_IX86
+ #error Only X86 supported
+#endif
+
+
+
+
+
+#endif // WNDPROCTHUNK_H_INCLUDED
+
+
+
+
diff --git a/Tools/BiomeVisualiser/profile_run.cmd b/Tools/BiomeVisualiser/profile_run.cmd
index 753ff18fb..d4826d06a 100644
--- a/Tools/BiomeVisualiser/profile_run.cmd
+++ b/Tools/BiomeVisualiser/profile_run.cmd
@@ -1,70 +1,70 @@
-@echo off
-::
-:: Profiling using a MSVC standalone profiler
-::
-:: See http://www.codeproject.com/Articles/144643/Profiling-of-C-Applications-in-Visual-Studio-for-F for details
-::
-
-
-
-
-set pt="C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools"
-set appdir="Release profiled"
-set app="Release profiled\BiomeVisualiser.exe"
-set args=""
-
-:: outputdir is relative to appdir!
-set outputdir=Profiling
-set output=profile.vsp
-
-
-
-
-
-::Create the output directory, if it didn't exist
-mkdir %outputdir%
-
-
-
-
-
-:: Start the profiler
-%pt%\vsperfcmd /start:sample /output:%outputdir%\%output%
-if errorlevel 1 goto haderror
-
-:: Launch the application via the profiler
-%pt%\vsperfcmd /launch:%app% /args:%args%
-if errorlevel 1 goto haderror
-
-:: Shut down the profiler (this command waits, until the application is terminated)
-%pt%\vsperfcmd /shutdown
-if errorlevel 1 goto haderror
-
-
-
-
-
-:: cd to outputdir, so that the reports are generated there
-cd %outputdir%
-
-:: generate the report files (.csv)
-%pt%\vsperfreport /summary:all %output% /symbolpath:"srv*C:\Programovani\Symbols*http://msdl.microsoft.com/download/symbols"
-if errorlevel 1 goto haderror
-
-
-
-
-
-goto finished
-
-
-
-
-:haderror
-echo An error was encountered
-pause
-
-
-
-
-:finished
+@echo off
+::
+:: Profiling using a MSVC standalone profiler
+::
+:: See http://www.codeproject.com/Articles/144643/Profiling-of-C-Applications-in-Visual-Studio-for-F for details
+::
+
+
+
+
+set pt="C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools"
+set appdir="Release profiled"
+set app="Release profiled\BiomeVisualiser.exe"
+set args=""
+
+:: outputdir is relative to appdir!
+set outputdir=Profiling
+set output=profile.vsp
+
+
+
+
+
+::Create the output directory, if it didn't exist
+mkdir %outputdir%
+
+
+
+
+
+:: Start the profiler
+%pt%\vsperfcmd /start:sample /output:%outputdir%\%output%
+if errorlevel 1 goto haderror
+
+:: Launch the application via the profiler
+%pt%\vsperfcmd /launch:%app% /args:%args%
+if errorlevel 1 goto haderror
+
+:: Shut down the profiler (this command waits, until the application is terminated)
+%pt%\vsperfcmd /shutdown
+if errorlevel 1 goto haderror
+
+
+
+
+
+:: cd to outputdir, so that the reports are generated there
+cd %outputdir%
+
+:: generate the report files (.csv)
+%pt%\vsperfreport /summary:all %output% /symbolpath:"srv*C:\Programovani\Symbols*http://msdl.microsoft.com/download/symbols"
+if errorlevel 1 goto haderror
+
+
+
+
+
+goto finished
+
+
+
+
+:haderror
+echo An error was encountered
+pause
+
+
+
+
+:finished
diff --git a/Tools/BlockZapper/BlockZapper.cpp b/Tools/BlockZapper/BlockZapper.cpp
index fb2050d56..c2a0a4fac 100644
--- a/Tools/BlockZapper/BlockZapper.cpp
+++ b/Tools/BlockZapper/BlockZapper.cpp
@@ -1,97 +1,97 @@
-
-// BlockZapper.cpp
-
-// Implements the main app entrypoint
-
-#include "Globals.h"
-
-#include <fstream>
-
-#include "Regions.h"
-#include "Zapper.h"
-
-
-
-
-
-#ifdef _MSC_VER
- // Under MSVC, link to WinSock2 (needed by FastNBT's byteswapping)
- #pragma comment(lib, "ws2_32.lib")
-#endif
-
-
-
-
-
-void ShowHelp(const char * a_ProgramFullName)
-{
- AString ProgramName(a_ProgramFullName);
- size_t idx = ProgramName.rfind(cFile::PathSeparator);
- if (idx != AString::npos)
- {
- ProgramName.erase(0, idx + 1);
- }
- printf("Tool written by _Xoft(o), code is public domain.\n");
- printf("Usage:\n");
- printf("%s [-w <MCAFolder>]\n", ProgramName.c_str());
- printf("Zaps blocks and / or entities in specified regions.\n");
- printf("Regions are read from stdin, the format is:\n");
- printf(" x1 x2 y1 y2 z1 z2 [B|E|BE]\n");
- printf("B or no specifier zaps blocks only\n");
- printf("E zaps entities only\n");
- printf("BE zaps blocks and entities\n");
- printf("MCA files are searched in the <MCAFolder>; if not specified, in the current folder.\n");
-}
-
-
-
-
-
-int main(int argc, char * argv[])
-{
- new cMCLogger; // Create a new logger, it will assign itself as the main logger instance
-
- AString MCAFolder = ".";
- for (int i = 1; i < argc; i++)
- {
- if (strcmp(argv[i], "-w") == 0)
- {
- if (i < argc - 1)
- {
- MCAFolder = argv[i + 1];
- }
- i++;
- }
- else if (
- (strcmp(argv[i], "help") == 0) ||
- (strcmp(argv[i], "-?") == 0) ||
- (strcmp(argv[i], "/?") == 0) ||
- (strcmp(argv[i], "-h") == 0) ||
- (strcmp(argv[i], "--help") == 0)
- )
- {
- ShowHelp(argv[0]);
- return 0;
- }
- }
-
- cRegions Regions;
-
- /*
- // DEBUG: Read input from a file instead of stdin:
- std::fstream fs("test_in.txt");
- Regions.Read(fs);
- //*/
-
- Regions.Read(std::cin);
-
- cZapper Zapper(MCAFolder);
- Zapper.ZapRegions(Regions.GetAll());
-
- LOGINFO("Done");
- return 0;
-} ;
-
-
-
-
+
+// BlockZapper.cpp
+
+// Implements the main app entrypoint
+
+#include "Globals.h"
+
+#include <fstream>
+
+#include "Regions.h"
+#include "Zapper.h"
+
+
+
+
+
+#ifdef _MSC_VER
+ // Under MSVC, link to WinSock2 (needed by FastNBT's byteswapping)
+ #pragma comment(lib, "ws2_32.lib")
+#endif
+
+
+
+
+
+void ShowHelp(const char * a_ProgramFullName)
+{
+ AString ProgramName(a_ProgramFullName);
+ size_t idx = ProgramName.rfind(cFile::PathSeparator);
+ if (idx != AString::npos)
+ {
+ ProgramName.erase(0, idx + 1);
+ }
+ printf("Tool written by _Xoft(o), code is public domain.\n");
+ printf("Usage:\n");
+ printf("%s [-w <MCAFolder>]\n", ProgramName.c_str());
+ printf("Zaps blocks and / or entities in specified regions.\n");
+ printf("Regions are read from stdin, the format is:\n");
+ printf(" x1 x2 y1 y2 z1 z2 [B|E|BE]\n");
+ printf("B or no specifier zaps blocks only\n");
+ printf("E zaps entities only\n");
+ printf("BE zaps blocks and entities\n");
+ printf("MCA files are searched in the <MCAFolder>; if not specified, in the current folder.\n");
+}
+
+
+
+
+
+int main(int argc, char * argv[])
+{
+ new cMCLogger; // Create a new logger, it will assign itself as the main logger instance
+
+ AString MCAFolder = ".";
+ for (int i = 1; i < argc; i++)
+ {
+ if (strcmp(argv[i], "-w") == 0)
+ {
+ if (i < argc - 1)
+ {
+ MCAFolder = argv[i + 1];
+ }
+ i++;
+ }
+ else if (
+ (strcmp(argv[i], "help") == 0) ||
+ (strcmp(argv[i], "-?") == 0) ||
+ (strcmp(argv[i], "/?") == 0) ||
+ (strcmp(argv[i], "-h") == 0) ||
+ (strcmp(argv[i], "--help") == 0)
+ )
+ {
+ ShowHelp(argv[0]);
+ return 0;
+ }
+ }
+
+ cRegions Regions;
+
+ /*
+ // DEBUG: Read input from a file instead of stdin:
+ std::fstream fs("test_in.txt");
+ Regions.Read(fs);
+ //*/
+
+ Regions.Read(std::cin);
+
+ cZapper Zapper(MCAFolder);
+ Zapper.ZapRegions(Regions.GetAll());
+
+ LOGINFO("Done");
+ return 0;
+} ;
+
+
+
+
diff --git a/Tools/BlockZapper/BlockZapper.sln b/Tools/BlockZapper/BlockZapper.sln
index fd8029ed0..9a71b9311 100644
--- a/Tools/BlockZapper/BlockZapper.sln
+++ b/Tools/BlockZapper/BlockZapper.sln
@@ -1,34 +1,34 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlockZapper", "BlockZapper.vcproj", "{CE317695-CCCC-4B11-B07B-21729A110FC2}"
- ProjectSection(ProjectDependencies) = postProject
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA} = {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\mc-server.clean\VC2008\zlib.vcproj", "{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release profiled|Win32 = Release profiled|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {CE317695-CCCC-4B11-B07B-21729A110FC2}.Debug|Win32.ActiveCfg = Debug|Win32
- {CE317695-CCCC-4B11-B07B-21729A110FC2}.Debug|Win32.Build.0 = Debug|Win32
- {CE317695-CCCC-4B11-B07B-21729A110FC2}.Release profiled|Win32.ActiveCfg = Release|Win32
- {CE317695-CCCC-4B11-B07B-21729A110FC2}.Release profiled|Win32.Build.0 = Release|Win32
- {CE317695-CCCC-4B11-B07B-21729A110FC2}.Release|Win32.ActiveCfg = Release|Win32
- {CE317695-CCCC-4B11-B07B-21729A110FC2}.Release|Win32.Build.0 = Release|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.ActiveCfg = Debug|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.Build.0 = Debug|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.ActiveCfg = Release|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlockZapper", "BlockZapper.vcproj", "{CE317695-CCCC-4B11-B07B-21729A110FC2}"
+ ProjectSection(ProjectDependencies) = postProject
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA} = {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\mc-server.clean\VC2008\zlib.vcproj", "{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release profiled|Win32 = Release profiled|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {CE317695-CCCC-4B11-B07B-21729A110FC2}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CE317695-CCCC-4B11-B07B-21729A110FC2}.Debug|Win32.Build.0 = Debug|Win32
+ {CE317695-CCCC-4B11-B07B-21729A110FC2}.Release profiled|Win32.ActiveCfg = Release|Win32
+ {CE317695-CCCC-4B11-B07B-21729A110FC2}.Release profiled|Win32.Build.0 = Release|Win32
+ {CE317695-CCCC-4B11-B07B-21729A110FC2}.Release|Win32.ActiveCfg = Release|Win32
+ {CE317695-CCCC-4B11-B07B-21729A110FC2}.Release|Win32.Build.0 = Release|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.Build.0 = Debug|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.ActiveCfg = Release|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Tools/BlockZapper/BlockZapper.txt b/Tools/BlockZapper/BlockZapper.txt
index af6b94054..2b52c477e 100644
--- a/Tools/BlockZapper/BlockZapper.txt
+++ b/Tools/BlockZapper/BlockZapper.txt
@@ -1,19 +1,19 @@
-
-// BlockZapper.txt
-
-/*
-This project implements a simple tool that can "zap" blocks out of an Anvil-stored MineCraft world.
-It is usually used by server admins when their servers fail with a bug and store an invalid block in the world.
-This tool takes a coord triplet and a radius triplet and replaces all blocks within the (new york-metric) radius of the coords with air.
-The triplets pair is given on stdin, and multiple such specifiers are allowed, each on a separate file.
-If the specifier line ends with an additional " E", entities within that radius are zapped instead of blocks
-If the specifier line ends with an additional " BE", both blocks and entities are zapped.
-
-The tool is aware of extended blocktypes (256 .. 4096).
-
-The source code for this tool is public domain, but note that it depends on a few shared sources in MCServer that may be under other licenses.
-*/
-
-
-
-
+
+// BlockZapper.txt
+
+/*
+This project implements a simple tool that can "zap" blocks out of an Anvil-stored MineCraft world.
+It is usually used by server admins when their servers fail with a bug and store an invalid block in the world.
+This tool takes a coord triplet and a radius triplet and replaces all blocks within the (new york-metric) radius of the coords with air.
+The triplets pair is given on stdin, and multiple such specifiers are allowed, each on a separate file.
+If the specifier line ends with an additional " E", entities within that radius are zapped instead of blocks
+If the specifier line ends with an additional " BE", both blocks and entities are zapped.
+
+The tool is aware of extended blocktypes (256 .. 4096).
+
+The source code for this tool is public domain, but note that it depends on a few shared sources in MCServer that may be under other licenses.
+*/
+
+
+
+
diff --git a/Tools/BlockZapper/BlockZapper.vcproj b/Tools/BlockZapper/BlockZapper.vcproj
index 195cdafbe..2a98197eb 100644
--- a/Tools/BlockZapper/BlockZapper.vcproj
+++ b/Tools/BlockZapper/BlockZapper.vcproj
@@ -1,313 +1,313 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="BlockZapper"
- ProjectGUID="{CE317695-CCCC-4B11-B07B-21729A110FC2}"
- RootNamespace="BlockZapper"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../../source;../../zlib-1.2.7"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../../source;../../zlib-1.2.7"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\BlockZapper.cpp"
- >
- </File>
- <File
- RelativePath=".\Globals.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\Globals.h"
- >
- </File>
- <File
- RelativePath=".\Regions.cpp"
- >
- </File>
- <File
- RelativePath=".\Regions.h"
- >
- </File>
- <File
- RelativePath=".\Zapper.cpp"
- >
- </File>
- <File
- RelativePath=".\Zapper.h"
- >
- </File>
- <Filter
- Name="shared"
- >
- <File
- RelativePath="..\..\source\Log.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\Log.h"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.h"
- >
- </File>
- <File
- RelativePath="..\..\source\StringCompression.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\StringCompression.h"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.h"
- >
- </File>
- <Filter
- Name="OSSupport"
- >
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.h"
- >
- </File>
- </Filter>
- <Filter
- Name="WorldStorage"
- >
- <File
- RelativePath="..\..\source\WorldStorage\FastNBT.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\WorldStorage\FastNBT.h"
- >
- </File>
- </Filter>
- </Filter>
- </Filter>
- <File
- RelativePath=".\BlockZapper.txt"
- >
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="BlockZapper"
+ ProjectGUID="{CE317695-CCCC-4B11-B07B-21729A110FC2}"
+ RootNamespace="BlockZapper"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../source;../../zlib-1.2.7"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="../../source;../../zlib-1.2.7"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\BlockZapper.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Globals.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\Globals.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Regions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Regions.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Zapper.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Zapper.h"
+ >
+ </File>
+ <Filter
+ Name="shared"
+ >
+ <File
+ RelativePath="..\..\source\Log.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Log.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringCompression.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringCompression.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.h"
+ >
+ </File>
+ <Filter
+ Name="OSSupport"
+ >
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="WorldStorage"
+ >
+ <File
+ RelativePath="..\..\source\WorldStorage\FastNBT.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\WorldStorage\FastNBT.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ <File
+ RelativePath=".\BlockZapper.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Tools/BlockZapper/Globals.cpp b/Tools/BlockZapper/Globals.cpp
index 31440fd44..d73265a60 100644
--- a/Tools/BlockZapper/Globals.cpp
+++ b/Tools/BlockZapper/Globals.cpp
@@ -1,10 +1,10 @@
-
-// Globals.cpp
-
-// Used for precompiled header generation in MSVC
-
-#include "Globals.h"
-
-
-
-
+
+// Globals.cpp
+
+// Used for precompiled header generation in MSVC
+
+#include "Globals.h"
+
+
+
+
diff --git a/Tools/BlockZapper/Globals.h b/Tools/BlockZapper/Globals.h
index e90fa96bd..e27315ec5 100644
--- a/Tools/BlockZapper/Globals.h
+++ b/Tools/BlockZapper/Globals.h
@@ -1,14 +1,14 @@
-
-// Globals.h
-
-// This file is used for precompiled header generation in MSVC
-
-
-
-
-
-#include "../../source/Globals.h"
-
-
-
-
+
+// Globals.h
+
+// This file is used for precompiled header generation in MSVC
+
+
+
+
+
+#include "../../source/Globals.h"
+
+
+
+
diff --git a/Tools/BlockZapper/Regions.cpp b/Tools/BlockZapper/Regions.cpp
index b4c8bddcd..515699532 100644
--- a/Tools/BlockZapper/Regions.cpp
+++ b/Tools/BlockZapper/Regions.cpp
@@ -1,167 +1,167 @@
-
-// Regions.cpp
-
-// Implements the cRegions class representing the list of regions to zap
-
-#include "Globals.h"
-
-#include "Regions.h"
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cRegion:
-
-cRegion::cRegion(void) :
- m_MinX(0),
- m_MaxX(0),
- m_MinY(0),
- m_MaxY(0),
- m_MinZ(0),
- m_MaxZ(0),
- m_ShouldZapBlocks(false),
- m_ShouldZapEntities(false)
-{
-}
-
-
-
-
-
-cRegion::cRegion(int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ, bool a_ShouldZapBlocks, bool a_ShouldZapEntities) :
- m_MinX(a_MinX),
- m_MaxX(a_MaxX),
- m_MinY(std::max(0, std::min(255, a_MinY))),
- m_MaxY(std::max(0, std::min(255, a_MaxY))),
- m_MinZ(a_MinZ),
- m_MaxZ(a_MaxZ),
- m_ShouldZapBlocks(a_ShouldZapBlocks),
- m_ShouldZapEntities(a_ShouldZapEntities)
-{
-}
-
-
-
-
-
-bool cRegion::TouchesChunk(int a_ChunkX, int a_ChunkZ) const
-{
- int ChunkBeginX = a_ChunkX * 16;
- int ChunkEndX = a_ChunkX * 16 + 15;
- int ChunkBeginZ = a_ChunkZ * 16;
- int ChunkEndZ = a_ChunkZ * 16 + 15;
- if (
- (m_MinX > ChunkEndX) || (m_MaxX < ChunkBeginX) ||
- (m_MinZ > ChunkEndZ) || (m_MaxZ < ChunkBeginZ)
- )
- {
- return false;
- }
- return true;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cRegions:
-
-void cRegions::Read(std::istream & a_Stream)
-{
- while (!a_Stream.eof())
- {
- AString Line;
- std::getline(a_Stream, Line);
-
- // Process the line
- AStringVector Split = StringSplit(Line, " \t");
- AStringVector NonEmpty;
- for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
- {
- if (!itr->empty())
- {
- NonEmpty.push_back(*itr);
- }
- } // for itr - Split[]
- switch (NonEmpty.size())
- {
- case 6:
- case 7:
- {
- AddRegion(NonEmpty);
- break;
- }
- default:
- {
- fprintf(stderr, "Cannot parse line \"%s\", ignoring", Line.c_str());
- break;
- }
- }
- }
-}
-
-
-
-
-
-void cRegions::AddRegion(const AStringVector & a_Split)
-{
- ASSERT((a_Split.size() == 6) || (a_Split.size() == 7));
-
- int Coords[6];
- for (int i = 0; i < 6; i++)
- {
- Coords[i] = atoi(a_Split[i].c_str());
- if ((Coords[i] == 0) && (a_Split[i] != "0"))
- {
- fprintf(stderr, "Bad coord: \"%s\". Ignoring line.", a_Split[i].c_str());
- return;
- }
- } // for i - a_Split[]
-
- bool ShouldZapBlocks = true;
- bool ShouldZapEntities = false;
-
- if (a_Split.size() == 7)
- {
- AString Upper = a_Split[6];
- StrToUpper(Upper);
- if (Upper == "E")
- {
- ShouldZapEntities = true;
- ShouldZapBlocks = false;
- }
- else if (Upper == "BE")
- {
- ShouldZapEntities = true;
- }
- else if (Upper == "B")
- {
- // Nothing needed
- }
- else
- {
- fprintf(stderr, "Bad zap specifier: \"%s\". Ignoring line.", a_Split[6].c_str());
- return;
- }
- }
-
- // Swap coords, if needed:
- for (int i = 0; i < 3; i++)
- {
- if (Coords[2 * i] > Coords[2 * i + 1])
- {
- std::swap(Coords[2 * i], Coords[2 * i + 1]);
- }
- }
-
- // Store the region
- m_Regions.push_back(cRegion(Coords[0], Coords[1], Coords[2], Coords[3], Coords[4], Coords[5], ShouldZapBlocks, ShouldZapEntities));
-}
-
-
-
-
+
+// Regions.cpp
+
+// Implements the cRegions class representing the list of regions to zap
+
+#include "Globals.h"
+
+#include "Regions.h"
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cRegion:
+
+cRegion::cRegion(void) :
+ m_MinX(0),
+ m_MaxX(0),
+ m_MinY(0),
+ m_MaxY(0),
+ m_MinZ(0),
+ m_MaxZ(0),
+ m_ShouldZapBlocks(false),
+ m_ShouldZapEntities(false)
+{
+}
+
+
+
+
+
+cRegion::cRegion(int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ, bool a_ShouldZapBlocks, bool a_ShouldZapEntities) :
+ m_MinX(a_MinX),
+ m_MaxX(a_MaxX),
+ m_MinY(std::max(0, std::min(255, a_MinY))),
+ m_MaxY(std::max(0, std::min(255, a_MaxY))),
+ m_MinZ(a_MinZ),
+ m_MaxZ(a_MaxZ),
+ m_ShouldZapBlocks(a_ShouldZapBlocks),
+ m_ShouldZapEntities(a_ShouldZapEntities)
+{
+}
+
+
+
+
+
+bool cRegion::TouchesChunk(int a_ChunkX, int a_ChunkZ) const
+{
+ int ChunkBeginX = a_ChunkX * 16;
+ int ChunkEndX = a_ChunkX * 16 + 15;
+ int ChunkBeginZ = a_ChunkZ * 16;
+ int ChunkEndZ = a_ChunkZ * 16 + 15;
+ if (
+ (m_MinX > ChunkEndX) || (m_MaxX < ChunkBeginX) ||
+ (m_MinZ > ChunkEndZ) || (m_MaxZ < ChunkBeginZ)
+ )
+ {
+ return false;
+ }
+ return true;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cRegions:
+
+void cRegions::Read(std::istream & a_Stream)
+{
+ while (!a_Stream.eof())
+ {
+ AString Line;
+ std::getline(a_Stream, Line);
+
+ // Process the line
+ AStringVector Split = StringSplit(Line, " \t");
+ AStringVector NonEmpty;
+ for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
+ {
+ if (!itr->empty())
+ {
+ NonEmpty.push_back(*itr);
+ }
+ } // for itr - Split[]
+ switch (NonEmpty.size())
+ {
+ case 6:
+ case 7:
+ {
+ AddRegion(NonEmpty);
+ break;
+ }
+ default:
+ {
+ fprintf(stderr, "Cannot parse line \"%s\", ignoring", Line.c_str());
+ break;
+ }
+ }
+ }
+}
+
+
+
+
+
+void cRegions::AddRegion(const AStringVector & a_Split)
+{
+ ASSERT((a_Split.size() == 6) || (a_Split.size() == 7));
+
+ int Coords[6];
+ for (int i = 0; i < 6; i++)
+ {
+ Coords[i] = atoi(a_Split[i].c_str());
+ if ((Coords[i] == 0) && (a_Split[i] != "0"))
+ {
+ fprintf(stderr, "Bad coord: \"%s\". Ignoring line.", a_Split[i].c_str());
+ return;
+ }
+ } // for i - a_Split[]
+
+ bool ShouldZapBlocks = true;
+ bool ShouldZapEntities = false;
+
+ if (a_Split.size() == 7)
+ {
+ AString Upper = a_Split[6];
+ StrToUpper(Upper);
+ if (Upper == "E")
+ {
+ ShouldZapEntities = true;
+ ShouldZapBlocks = false;
+ }
+ else if (Upper == "BE")
+ {
+ ShouldZapEntities = true;
+ }
+ else if (Upper == "B")
+ {
+ // Nothing needed
+ }
+ else
+ {
+ fprintf(stderr, "Bad zap specifier: \"%s\". Ignoring line.", a_Split[6].c_str());
+ return;
+ }
+ }
+
+ // Swap coords, if needed:
+ for (int i = 0; i < 3; i++)
+ {
+ if (Coords[2 * i] > Coords[2 * i + 1])
+ {
+ std::swap(Coords[2 * i], Coords[2 * i + 1]);
+ }
+ }
+
+ // Store the region
+ m_Regions.push_back(cRegion(Coords[0], Coords[1], Coords[2], Coords[3], Coords[4], Coords[5], ShouldZapBlocks, ShouldZapEntities));
+}
+
+
+
+
diff --git a/Tools/BlockZapper/Regions.h b/Tools/BlockZapper/Regions.h
index d959200d2..997b9a047 100644
--- a/Tools/BlockZapper/Regions.h
+++ b/Tools/BlockZapper/Regions.h
@@ -1,58 +1,58 @@
-
-// Regions.h
-
-// Declares the cRegions class representing individual regions to zap
-
-
-
-
-
-#pragma once
-
-#include <iostream>
-
-
-
-
-
-struct cRegion
-{
- int m_MinX, m_MaxX;
- int m_MinY, m_MaxY;
- int m_MinZ, m_MaxZ;
-
- bool m_ShouldZapBlocks;
- bool m_ShouldZapEntities;
-
- cRegion(void);
- cRegion(int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ, bool a_ShouldZapBlocks, bool a_ShouldZapEntities);
-
- bool TouchesChunk(int a_ChunkX, int a_ChunkZ) const;
-} ;
-
-typedef std::vector<cRegion> cRegionVector;
-
-
-
-
-
-class cRegions
-{
-public:
- /// Reads the list of regions from the specified stream
- void Read(std::istream & a_Stream);
-
- /// Returns all regions in this container
- const cRegionVector & GetAll(void) const { return m_Regions; }
-
-protected:
- cRegionVector m_Regions;
-
- /// Adds a new region based on the contents of the split line. The split must already be the correct size
- void AddRegion(const AStringVector & a_Split);
-
-} ;
-
-
-
-
+
+// Regions.h
+
+// Declares the cRegions class representing individual regions to zap
+
+
+
+
+
+#pragma once
+
+#include <iostream>
+
+
+
+
+
+struct cRegion
+{
+ int m_MinX, m_MaxX;
+ int m_MinY, m_MaxY;
+ int m_MinZ, m_MaxZ;
+
+ bool m_ShouldZapBlocks;
+ bool m_ShouldZapEntities;
+
+ cRegion(void);
+ cRegion(int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ, bool a_ShouldZapBlocks, bool a_ShouldZapEntities);
+
+ bool TouchesChunk(int a_ChunkX, int a_ChunkZ) const;
+} ;
+
+typedef std::vector<cRegion> cRegionVector;
+
+
+
+
+
+class cRegions
+{
+public:
+ /// Reads the list of regions from the specified stream
+ void Read(std::istream & a_Stream);
+
+ /// Returns all regions in this container
+ const cRegionVector & GetAll(void) const { return m_Regions; }
+
+protected:
+ cRegionVector m_Regions;
+
+ /// Adds a new region based on the contents of the split line. The split must already be the correct size
+ void AddRegion(const AStringVector & a_Split);
+
+} ;
+
+
+
+
diff --git a/Tools/BlockZapper/Zapper.cpp b/Tools/BlockZapper/Zapper.cpp
index d5bc576ba..702f968ab 100644
--- a/Tools/BlockZapper/Zapper.cpp
+++ b/Tools/BlockZapper/Zapper.cpp
@@ -1,440 +1,440 @@
-
-// Zapper.cpp
-
-// Implements the cZapper class representing the processor that actually zaps blocks and entities
-
-#include "Globals.h"
-
-#include "WorldStorage/FastNBT.h"
-#include "StringCompression.h"
-#include "zlib.h"
-
-#include "Zapper.h"
-
-
-
-
-
-/// The maximum size of an inflated chunk; raw chunk data is 192 KiB, allow 64 KiB more of entities
-#define CHUNK_INFLATE_MAX 256 KiB
-
-
-
-
-
-cZapper::cZapper(const AString & a_MCAFolder) :
- m_MCAFolder(a_MCAFolder)
-{
-}
-
-
-
-
-
-void cZapper::ZapRegions(const cRegionVector & a_Regions)
-{
- for (cRegionVector::const_iterator itr = a_Regions.begin(), end = a_Regions.end(); itr != end; ++itr)
- {
- int MinAnvX, MinAnvZ;
- int MaxAnvX, MaxAnvZ;
- BlockToMCA(itr->m_MinX, itr->m_MinZ, MinAnvX, MinAnvZ);
- BlockToMCA(itr->m_MaxX, itr->m_MaxZ, MaxAnvX, MaxAnvZ);
- for (int x = MinAnvX; x <= MaxAnvX; x++)
- {
- for (int z = MinAnvZ; z <= MaxAnvZ; z++)
- {
- ZapRegionInMCAFile(*itr, x, z);
- }
- }
- } // for itr - a_Regions
-}
-
-
-
-
-
-void cZapper::BlockToMCA(int a_BlockX, int a_BlockZ, int & a_MCAX, int & a_MCAZ)
-{
- // These need to be arithmetic shifts, consult your compiler documentation to see if it's so
- // MSVC and GCC both use arithmetic shifts
- a_MCAX = a_BlockX >> 10;
- a_MCAZ = a_BlockZ >> 10;
-}
-
-
-
-
-
-void cZapper::BlockToChunk(int a_BlockX, int a_BlockZ, int & a_ChunkX, int & a_ChunkZ)
-{
- // These need to be arithmetic shifts, consult your compiler documentation to see if it's so
- // MSVC and GCC both use arithmetic shifts
- a_ChunkX = a_BlockX >> 4;
- a_ChunkZ = a_BlockZ >> 4;
-}
-
-
-
-
-
-void cZapper::ZapRegionInMCAFile(const cRegion & a_Region, int a_MCAX, int a_MCAZ)
-{
- cFile fIn;
- AString FileNameIn = Printf("%s/r.%d.%d.mca", m_MCAFolder.c_str(), a_MCAX, a_MCAZ);
- if (!fIn.Open(FileNameIn, cFile::fmRead))
- {
- return;
- }
- cFile fOut;
- AString FileNameOut = Printf("%s/r.%d.%d.zap", m_MCAFolder.c_str(), a_MCAX, a_MCAZ);
- if (!fOut.Open(FileNameOut, cFile::fmWrite))
- {
- fprintf(stderr, "Cannot open temporary file \"%s\" for writing, skipping file \"%s\".", FileNameOut.c_str(), FileNameIn.c_str());
- return;
- }
-
- AString DataOut;
- DataOut.reserve(fIn.GetSize());
-
- int HeaderIn[2048];
- if (fIn.Read(HeaderIn, sizeof(HeaderIn)) != sizeof(HeaderIn))
- {
- fprintf(stderr, "Cannot read header from file \"%s\", skipping file.", FileNameIn.c_str());
- }
- int HeaderOut[2048];
- for (int i = 0; i < 1024; i++)
- {
- if (HeaderIn[i] == 0)
- {
- // Chunk not present
- HeaderOut[i] = 0;
- continue;
- }
- AString ChunkData;
- int ChunkX = a_MCAX * ChunksPerMCAX + (i % ChunksPerMCAX);
- int ChunkZ = a_MCAZ * ChunksPerMCAZ + (i / ChunksPerMCAX);
-
- LoadChunkData(fIn, HeaderIn[i], ChunkData, ChunkX, ChunkZ);
-
- if (a_Region.TouchesChunk(ChunkX, ChunkZ))
- {
- ZapRegionInRawChunkData(a_Region, ChunkData, ChunkX, ChunkZ);
- }
- unsigned char ChunkHeader[5];
- size_t DataSize = ChunkData.size() + 1;
- ChunkHeader[0] = (DataSize >> 24) & 0xff;
- ChunkHeader[1] = (DataSize >> 16) & 0xff;
- ChunkHeader[2] = (DataSize >> 8) & 0xff;
- ChunkHeader[3] = DataSize & 0xff;
- ChunkHeader[4] = 2; // zlib compression
- size_t Alignment = 4096 - (ChunkData.size() + 5) % 4096; // 5 bytes of the header are appended outside of ChunkData
- if (Alignment > 0)
- {
- ChunkData.append(Alignment, (char)0);
- }
- HeaderOut[i] = htonl(((DataOut.size() / 4096 + 2) << 8) | ((ChunkData.size() + 5) / 4096));
- DataOut.append((const char *)ChunkHeader, sizeof(ChunkHeader));
- DataOut.append(ChunkData);
- } // for i - chunks in fIn
- for (int i = 1024; i < 2048; i++)
- {
- HeaderOut[i] = HeaderIn[i];
- }
- fIn.Close();
- fOut.Write(HeaderOut, sizeof(HeaderOut));
- fOut.Write(DataOut.data(), DataOut.size());
- fOut.Close();
- cFile::Delete(FileNameIn);
- cFile::Rename(FileNameOut, FileNameIn);
-}
-
-
-
-
-
-void cZapper::LoadChunkData(cFile & a_InFile, int a_ChunkHeaderValue, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ)
-{
- a_ChunkHeaderValue = ntohl(a_ChunkHeaderValue); // Convert from big-endian to system-endian
- int ChunkOffset = (a_ChunkHeaderValue >> 8) * 4096;
- int ChunkSize = (a_ChunkHeaderValue & 0xff) * 4096;
- a_InFile.Seek(ChunkOffset);
- unsigned char ChunkHeader[5];
- a_InFile.Read(ChunkHeader, sizeof(ChunkHeader));
- if (ChunkHeader[4] != 2)
- {
- fprintf(stderr, "Chunk [%d, %d] is compressed in an unknown scheme (%d), skipping", a_ChunkX, a_ChunkZ, ChunkHeader[5]);
- return;
- }
- int ActualSize = (ChunkHeader[0] << 24) | (ChunkHeader[1] << 16) | (ChunkHeader[2] << 8) | ChunkHeader[3];
- ActualSize -= 1; // Compression took 1 byte
- a_ChunkData.resize(ActualSize);
- int BytesRead = a_InFile.Read((void *)(a_ChunkData.data()), ActualSize);
- if (BytesRead != ActualSize)
- {
- fprintf(stderr, "Chunk is truncated in file (%d bytes out of %d), skipping.", BytesRead, ActualSize);
- a_ChunkData.clear();
- return;
- }
-}
-
-
-
-
-
-void cZapper::ZapRegionInRawChunkData(const cRegion & a_Region, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ)
-{
- // Decompress the data:
- char Uncompressed[CHUNK_INFLATE_MAX];
- z_stream strm;
- strm.zalloc = (alloc_func)NULL;
- strm.zfree = (free_func)NULL;
- strm.opaque = NULL;
- inflateInit(&strm);
- strm.next_out = (Bytef *)Uncompressed;
- strm.avail_out = sizeof(Uncompressed);
- strm.next_in = (Bytef *)a_ChunkData.data();
- strm.avail_in = a_ChunkData.size();
- int res = inflate(&strm, Z_FINISH);
- inflateEnd(&strm);
- if (res != Z_STREAM_END)
- {
- fprintf(stderr, "Chunk [%d, %d] failed to decompress: error %d. Skipping chunk.", a_ChunkX, a_ChunkZ, res);
- return;
- }
-
- /*
- // DEBUG: Output src to a file:
- cFile f1;
- if (f1.Open(Printf("chunk_%d_%d_in.nbt", a_ChunkX, a_ChunkZ), cFile::fmWrite))
- {
- f1.Write(Uncompressed, strm.total_out);
- }
- //*/
-
- cParsedNBT NBT(Uncompressed, strm.total_out);
- if (!NBT.IsValid())
- {
- fprintf(stderr, "Chunk [%d, %d] failed to parse. Skipping chunk.", a_ChunkX, a_ChunkZ);
- return;
- }
- ZapRegionInNBTChunk(a_Region, NBT, a_ChunkX, a_ChunkZ);
-
- cFastNBTWriter Writer;
- for (int ch = NBT.GetFirstChild(0); ch >= 0; ch = NBT.GetNextSibling(ch))
- {
- SerializeNBTTag(NBT, ch, Writer);
- }
- Writer.Finish();
-
- /*
- // DEBUG: Output dst to a file:
- cFile f2;
- if (f2.Open(Printf("chunk_%d_%d_out.nbt", a_ChunkX, a_ChunkZ), cFile::fmWrite))
- {
- f2.Write(Writer.GetResult().data(), Writer.GetResult().size());
- }
- //*/
-
- // Compress the serialized data into "Uncompressed" (reuse buffer)
- CompressString(Writer.GetResult().data(), Writer.GetResult().size(), a_ChunkData);
-}
-
-
-
-
-
-void cZapper::ZapRegionInNBTChunk(const cRegion & a_Region, cParsedNBT & a_NBT, int a_ChunkX, int a_ChunkZ)
-{
- int LevelTag = a_NBT.FindChildByName(a_NBT.GetRoot(), "Level");
- if (LevelTag < 0)
- {
- fprintf(stderr, "Cannot find Level tag in chunk [%d, %d]'s NBT. Skipping chunk.", a_ChunkX, a_ChunkZ);
- return;
- }
-
- // Create a copy of the region and limit it to the current chunk:
- int BlockX = a_ChunkX * 16;
- int BlockZ = a_ChunkZ * 16;
- cRegion Local;
- Local.m_MinX = std::max(0, a_Region.m_MinX - BlockX);
- Local.m_MaxX = std::min(15, a_Region.m_MaxX - BlockX);
- Local.m_MinY = a_Region.m_MinY;
- Local.m_MaxY = a_Region.m_MaxY;
- Local.m_MinZ = std::max(0, a_Region.m_MinZ - BlockZ);
- Local.m_MaxZ = std::min(15, a_Region.m_MaxZ - BlockZ);
-
- if (a_Region.m_ShouldZapBlocks)
- {
- int SectionsTag = a_NBT.FindChildByName(LevelTag, "Sections");
- if (SectionsTag < 0)
- {
- fprintf(stderr, "Cannot find the Sections tag in the Level tag in chunk [%d, %d]'s NBT. Skipping block-zapping in chunk.", a_ChunkX, a_ChunkZ);
- return;
- }
- ZapRegionBlocksInNBT(Local, a_NBT, SectionsTag);
- }
-
- if (a_Region.m_ShouldZapEntities)
- {
- int EntitiesTag = a_NBT.FindChildByName(LevelTag, "Entities");
- if (EntitiesTag < 0)
- {
- fprintf(stderr, "Cannot find the Entities tag in the Level tag in chunk [%d, %d]'s NBT. Skipping entity-zapping in chunk.", a_ChunkX, a_ChunkZ);
- return;
- }
- ZapRegionEntitiesInNBT(Local, a_NBT, EntitiesTag);
- }
-}
-
-
-
-
-
-void cZapper::ZapRegionBlocksInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_SectionsTag)
-{
- for (int Child = a_NBT.GetFirstChild(a_SectionsTag); Child >= 0; Child = a_NBT.GetNextSibling(Child))
- {
- int y = 0;
- int SectionY = a_NBT.FindChildByName(Child, "Y");
- if ((SectionY < 0) || (a_NBT.GetType(SectionY) != TAG_Byte))
- {
- continue;
- }
- y = a_NBT.GetByte(SectionY);
- if ((y * 16 > a_Region.m_MaxY) || (y * 16 + 16 < a_Region.m_MinY))
- {
- continue;
- }
- int BlockDataTag = a_NBT.FindChildByName(Child, "Blocks");
- int BlockMetaTag = a_NBT.FindChildByName(Child, "Data");
- int BlockAddTag = a_NBT.FindChildByName(Child, "Add");
- if (BlockDataTag > 0)
- {
- ZapRegionInNBTSectionBytes(a_Region, y, (unsigned char *)(a_NBT.GetData(BlockDataTag)));
- }
- if (BlockMetaTag > 0)
- {
- ZapRegionInNBTSectionNibbles(a_Region, y, (unsigned char *)(a_NBT.GetData(BlockMetaTag)));
- }
- if (BlockAddTag > 0)
- {
- ZapRegionInNBTSectionNibbles(a_Region, y, (unsigned char *)(a_NBT.GetData(BlockAddTag)));
- }
- } // for Child - Level/Sections/[]
-}
-
-
-
-
-
-void cZapper::ZapRegionInNBTSectionBytes(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockBytes)
-{
- int MinY = std::max(0, a_Region.m_MinY - a_SectionY * 16);
- int MaxY = std::min(15, a_Region.m_MaxY - a_SectionY * 16);
- ASSERT(MinY >= 0);
- ASSERT(MaxY >= 0);
- for (int y = MinY; y <= MaxY; y++)
- {
- for (int z = a_Region.m_MinZ; z <= a_Region.m_MaxZ; z++)
- {
- for (int x = a_Region.m_MinX; x <= a_Region.m_MaxX; x++)
- {
- a_BlockBytes[x + z * 16 + y * 16 * 16] = 0;
- }
- }
- }
-}
-
-
-
-
-
-void cZapper::ZapRegionInNBTSectionNibbles(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockNibbles)
-{
- int MinY = std::max(0, a_Region.m_MinY - a_SectionY * 16);
- int MaxY = std::min(15, a_Region.m_MaxY - a_SectionY * 16);
- ASSERT(MinY >= 0);
- ASSERT(MaxY >= 0);
- for (int y = MinY; y <= MaxY; y++)
- {
- for (int z = a_Region.m_MinZ; z < a_Region.m_MaxZ; z++)
- {
- for (int x = a_Region.m_MinX; x < a_Region.m_MaxX; x++)
- {
- cChunkDef::SetNibble(a_BlockNibbles, x, y, z, 0);
- }
- }
- }
-}
-
-
-
-
-
-void cZapper::ZapRegionEntitiesInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_EntitiesTag)
-{
- // TODO
-}
-
-
-
-
-
-void cZapper::SerializeNBTTag(const cParsedNBT & a_NBT, int a_Tag, cFastNBTWriter & a_Writer)
-{
- switch (a_NBT.GetType(a_Tag))
- {
- case TAG_Byte: a_Writer.AddByte (a_NBT.GetName(a_Tag), a_NBT.GetByte (a_Tag)); break;
- case TAG_Short: a_Writer.AddShort (a_NBT.GetName(a_Tag), a_NBT.GetShort (a_Tag)); break;
- case TAG_Int: a_Writer.AddInt (a_NBT.GetName(a_Tag), a_NBT.GetInt (a_Tag)); break;
- case TAG_Long: a_Writer.AddLong (a_NBT.GetName(a_Tag), a_NBT.GetLong (a_Tag)); break;
- case TAG_Float: a_Writer.AddFloat (a_NBT.GetName(a_Tag), a_NBT.GetFloat (a_Tag)); break;
- case TAG_Double: a_Writer.AddDouble (a_NBT.GetName(a_Tag), a_NBT.GetDouble(a_Tag)); break;
- case TAG_ByteArray: a_Writer.AddByteArray(a_NBT.GetName(a_Tag), a_NBT.GetData (a_Tag), a_NBT.GetDataLength(a_Tag)); break;
- case TAG_String: a_Writer.AddString (a_NBT.GetName(a_Tag), a_NBT.GetString(a_Tag)); break;
- case TAG_IntArray:
- {
- std::vector<int> Data;
- int NumInts = a_NBT.GetDataLength(a_Tag) / 4;
- Data.reserve(NumInts);
- int * OrigData = (int *)(a_NBT.GetData(a_Tag));
- for (int i = 0; i < NumInts; i++)
- {
- Data.push_back(ntohl(OrigData[i]));
- }
- a_Writer.AddIntArray (a_NBT.GetName(a_Tag), &Data.front(), Data.size()); break;
- }
-
- case TAG_List:
- {
- a_Writer.BeginList(a_NBT.GetName(a_Tag), a_NBT.GetChildrenType(a_Tag));
- for (int ch = a_NBT.GetFirstChild(a_Tag); ch >= 0; ch = a_NBT.GetNextSibling(ch))
- {
- SerializeNBTTag(a_NBT, ch, a_Writer);
- } // for ch - children[]
- a_Writer.EndList();
- break;
- }
-
- case TAG_Compound:
- {
- a_Writer.BeginCompound(a_NBT.GetName(a_Tag));
- for (int ch = a_NBT.GetFirstChild(a_Tag); ch >= 0; ch = a_NBT.GetNextSibling(ch))
- {
- SerializeNBTTag(a_NBT, ch, a_Writer);
- } // for ch - children[]
- a_Writer.EndCompound();
- break;
- }
-
- default:
- {
- ASSERT(!"Unknown NBT tag");
- break;
- }
- }
-}
-
-
-
-
+
+// Zapper.cpp
+
+// Implements the cZapper class representing the processor that actually zaps blocks and entities
+
+#include "Globals.h"
+
+#include "WorldStorage/FastNBT.h"
+#include "StringCompression.h"
+#include "zlib.h"
+
+#include "Zapper.h"
+
+
+
+
+
+/// The maximum size of an inflated chunk; raw chunk data is 192 KiB, allow 64 KiB more of entities
+#define CHUNK_INFLATE_MAX 256 KiB
+
+
+
+
+
+cZapper::cZapper(const AString & a_MCAFolder) :
+ m_MCAFolder(a_MCAFolder)
+{
+}
+
+
+
+
+
+void cZapper::ZapRegions(const cRegionVector & a_Regions)
+{
+ for (cRegionVector::const_iterator itr = a_Regions.begin(), end = a_Regions.end(); itr != end; ++itr)
+ {
+ int MinAnvX, MinAnvZ;
+ int MaxAnvX, MaxAnvZ;
+ BlockToMCA(itr->m_MinX, itr->m_MinZ, MinAnvX, MinAnvZ);
+ BlockToMCA(itr->m_MaxX, itr->m_MaxZ, MaxAnvX, MaxAnvZ);
+ for (int x = MinAnvX; x <= MaxAnvX; x++)
+ {
+ for (int z = MinAnvZ; z <= MaxAnvZ; z++)
+ {
+ ZapRegionInMCAFile(*itr, x, z);
+ }
+ }
+ } // for itr - a_Regions
+}
+
+
+
+
+
+void cZapper::BlockToMCA(int a_BlockX, int a_BlockZ, int & a_MCAX, int & a_MCAZ)
+{
+ // These need to be arithmetic shifts, consult your compiler documentation to see if it's so
+ // MSVC and GCC both use arithmetic shifts
+ a_MCAX = a_BlockX >> 10;
+ a_MCAZ = a_BlockZ >> 10;
+}
+
+
+
+
+
+void cZapper::BlockToChunk(int a_BlockX, int a_BlockZ, int & a_ChunkX, int & a_ChunkZ)
+{
+ // These need to be arithmetic shifts, consult your compiler documentation to see if it's so
+ // MSVC and GCC both use arithmetic shifts
+ a_ChunkX = a_BlockX >> 4;
+ a_ChunkZ = a_BlockZ >> 4;
+}
+
+
+
+
+
+void cZapper::ZapRegionInMCAFile(const cRegion & a_Region, int a_MCAX, int a_MCAZ)
+{
+ cFile fIn;
+ AString FileNameIn = Printf("%s/r.%d.%d.mca", m_MCAFolder.c_str(), a_MCAX, a_MCAZ);
+ if (!fIn.Open(FileNameIn, cFile::fmRead))
+ {
+ return;
+ }
+ cFile fOut;
+ AString FileNameOut = Printf("%s/r.%d.%d.zap", m_MCAFolder.c_str(), a_MCAX, a_MCAZ);
+ if (!fOut.Open(FileNameOut, cFile::fmWrite))
+ {
+ fprintf(stderr, "Cannot open temporary file \"%s\" for writing, skipping file \"%s\".", FileNameOut.c_str(), FileNameIn.c_str());
+ return;
+ }
+
+ AString DataOut;
+ DataOut.reserve(fIn.GetSize());
+
+ int HeaderIn[2048];
+ if (fIn.Read(HeaderIn, sizeof(HeaderIn)) != sizeof(HeaderIn))
+ {
+ fprintf(stderr, "Cannot read header from file \"%s\", skipping file.", FileNameIn.c_str());
+ }
+ int HeaderOut[2048];
+ for (int i = 0; i < 1024; i++)
+ {
+ if (HeaderIn[i] == 0)
+ {
+ // Chunk not present
+ HeaderOut[i] = 0;
+ continue;
+ }
+ AString ChunkData;
+ int ChunkX = a_MCAX * ChunksPerMCAX + (i % ChunksPerMCAX);
+ int ChunkZ = a_MCAZ * ChunksPerMCAZ + (i / ChunksPerMCAX);
+
+ LoadChunkData(fIn, HeaderIn[i], ChunkData, ChunkX, ChunkZ);
+
+ if (a_Region.TouchesChunk(ChunkX, ChunkZ))
+ {
+ ZapRegionInRawChunkData(a_Region, ChunkData, ChunkX, ChunkZ);
+ }
+ unsigned char ChunkHeader[5];
+ size_t DataSize = ChunkData.size() + 1;
+ ChunkHeader[0] = (DataSize >> 24) & 0xff;
+ ChunkHeader[1] = (DataSize >> 16) & 0xff;
+ ChunkHeader[2] = (DataSize >> 8) & 0xff;
+ ChunkHeader[3] = DataSize & 0xff;
+ ChunkHeader[4] = 2; // zlib compression
+ size_t Alignment = 4096 - (ChunkData.size() + 5) % 4096; // 5 bytes of the header are appended outside of ChunkData
+ if (Alignment > 0)
+ {
+ ChunkData.append(Alignment, (char)0);
+ }
+ HeaderOut[i] = htonl(((DataOut.size() / 4096 + 2) << 8) | ((ChunkData.size() + 5) / 4096));
+ DataOut.append((const char *)ChunkHeader, sizeof(ChunkHeader));
+ DataOut.append(ChunkData);
+ } // for i - chunks in fIn
+ for (int i = 1024; i < 2048; i++)
+ {
+ HeaderOut[i] = HeaderIn[i];
+ }
+ fIn.Close();
+ fOut.Write(HeaderOut, sizeof(HeaderOut));
+ fOut.Write(DataOut.data(), DataOut.size());
+ fOut.Close();
+ cFile::Delete(FileNameIn);
+ cFile::Rename(FileNameOut, FileNameIn);
+}
+
+
+
+
+
+void cZapper::LoadChunkData(cFile & a_InFile, int a_ChunkHeaderValue, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ)
+{
+ a_ChunkHeaderValue = ntohl(a_ChunkHeaderValue); // Convert from big-endian to system-endian
+ int ChunkOffset = (a_ChunkHeaderValue >> 8) * 4096;
+ int ChunkSize = (a_ChunkHeaderValue & 0xff) * 4096;
+ a_InFile.Seek(ChunkOffset);
+ unsigned char ChunkHeader[5];
+ a_InFile.Read(ChunkHeader, sizeof(ChunkHeader));
+ if (ChunkHeader[4] != 2)
+ {
+ fprintf(stderr, "Chunk [%d, %d] is compressed in an unknown scheme (%d), skipping", a_ChunkX, a_ChunkZ, ChunkHeader[5]);
+ return;
+ }
+ int ActualSize = (ChunkHeader[0] << 24) | (ChunkHeader[1] << 16) | (ChunkHeader[2] << 8) | ChunkHeader[3];
+ ActualSize -= 1; // Compression took 1 byte
+ a_ChunkData.resize(ActualSize);
+ int BytesRead = a_InFile.Read((void *)(a_ChunkData.data()), ActualSize);
+ if (BytesRead != ActualSize)
+ {
+ fprintf(stderr, "Chunk is truncated in file (%d bytes out of %d), skipping.", BytesRead, ActualSize);
+ a_ChunkData.clear();
+ return;
+ }
+}
+
+
+
+
+
+void cZapper::ZapRegionInRawChunkData(const cRegion & a_Region, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ)
+{
+ // Decompress the data:
+ char Uncompressed[CHUNK_INFLATE_MAX];
+ z_stream strm;
+ strm.zalloc = (alloc_func)NULL;
+ strm.zfree = (free_func)NULL;
+ strm.opaque = NULL;
+ inflateInit(&strm);
+ strm.next_out = (Bytef *)Uncompressed;
+ strm.avail_out = sizeof(Uncompressed);
+ strm.next_in = (Bytef *)a_ChunkData.data();
+ strm.avail_in = a_ChunkData.size();
+ int res = inflate(&strm, Z_FINISH);
+ inflateEnd(&strm);
+ if (res != Z_STREAM_END)
+ {
+ fprintf(stderr, "Chunk [%d, %d] failed to decompress: error %d. Skipping chunk.", a_ChunkX, a_ChunkZ, res);
+ return;
+ }
+
+ /*
+ // DEBUG: Output src to a file:
+ cFile f1;
+ if (f1.Open(Printf("chunk_%d_%d_in.nbt", a_ChunkX, a_ChunkZ), cFile::fmWrite))
+ {
+ f1.Write(Uncompressed, strm.total_out);
+ }
+ //*/
+
+ cParsedNBT NBT(Uncompressed, strm.total_out);
+ if (!NBT.IsValid())
+ {
+ fprintf(stderr, "Chunk [%d, %d] failed to parse. Skipping chunk.", a_ChunkX, a_ChunkZ);
+ return;
+ }
+ ZapRegionInNBTChunk(a_Region, NBT, a_ChunkX, a_ChunkZ);
+
+ cFastNBTWriter Writer;
+ for (int ch = NBT.GetFirstChild(0); ch >= 0; ch = NBT.GetNextSibling(ch))
+ {
+ SerializeNBTTag(NBT, ch, Writer);
+ }
+ Writer.Finish();
+
+ /*
+ // DEBUG: Output dst to a file:
+ cFile f2;
+ if (f2.Open(Printf("chunk_%d_%d_out.nbt", a_ChunkX, a_ChunkZ), cFile::fmWrite))
+ {
+ f2.Write(Writer.GetResult().data(), Writer.GetResult().size());
+ }
+ //*/
+
+ // Compress the serialized data into "Uncompressed" (reuse buffer)
+ CompressString(Writer.GetResult().data(), Writer.GetResult().size(), a_ChunkData);
+}
+
+
+
+
+
+void cZapper::ZapRegionInNBTChunk(const cRegion & a_Region, cParsedNBT & a_NBT, int a_ChunkX, int a_ChunkZ)
+{
+ int LevelTag = a_NBT.FindChildByName(a_NBT.GetRoot(), "Level");
+ if (LevelTag < 0)
+ {
+ fprintf(stderr, "Cannot find Level tag in chunk [%d, %d]'s NBT. Skipping chunk.", a_ChunkX, a_ChunkZ);
+ return;
+ }
+
+ // Create a copy of the region and limit it to the current chunk:
+ int BlockX = a_ChunkX * 16;
+ int BlockZ = a_ChunkZ * 16;
+ cRegion Local;
+ Local.m_MinX = std::max(0, a_Region.m_MinX - BlockX);
+ Local.m_MaxX = std::min(15, a_Region.m_MaxX - BlockX);
+ Local.m_MinY = a_Region.m_MinY;
+ Local.m_MaxY = a_Region.m_MaxY;
+ Local.m_MinZ = std::max(0, a_Region.m_MinZ - BlockZ);
+ Local.m_MaxZ = std::min(15, a_Region.m_MaxZ - BlockZ);
+
+ if (a_Region.m_ShouldZapBlocks)
+ {
+ int SectionsTag = a_NBT.FindChildByName(LevelTag, "Sections");
+ if (SectionsTag < 0)
+ {
+ fprintf(stderr, "Cannot find the Sections tag in the Level tag in chunk [%d, %d]'s NBT. Skipping block-zapping in chunk.", a_ChunkX, a_ChunkZ);
+ return;
+ }
+ ZapRegionBlocksInNBT(Local, a_NBT, SectionsTag);
+ }
+
+ if (a_Region.m_ShouldZapEntities)
+ {
+ int EntitiesTag = a_NBT.FindChildByName(LevelTag, "Entities");
+ if (EntitiesTag < 0)
+ {
+ fprintf(stderr, "Cannot find the Entities tag in the Level tag in chunk [%d, %d]'s NBT. Skipping entity-zapping in chunk.", a_ChunkX, a_ChunkZ);
+ return;
+ }
+ ZapRegionEntitiesInNBT(Local, a_NBT, EntitiesTag);
+ }
+}
+
+
+
+
+
+void cZapper::ZapRegionBlocksInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_SectionsTag)
+{
+ for (int Child = a_NBT.GetFirstChild(a_SectionsTag); Child >= 0; Child = a_NBT.GetNextSibling(Child))
+ {
+ int y = 0;
+ int SectionY = a_NBT.FindChildByName(Child, "Y");
+ if ((SectionY < 0) || (a_NBT.GetType(SectionY) != TAG_Byte))
+ {
+ continue;
+ }
+ y = a_NBT.GetByte(SectionY);
+ if ((y * 16 > a_Region.m_MaxY) || (y * 16 + 16 < a_Region.m_MinY))
+ {
+ continue;
+ }
+ int BlockDataTag = a_NBT.FindChildByName(Child, "Blocks");
+ int BlockMetaTag = a_NBT.FindChildByName(Child, "Data");
+ int BlockAddTag = a_NBT.FindChildByName(Child, "Add");
+ if (BlockDataTag > 0)
+ {
+ ZapRegionInNBTSectionBytes(a_Region, y, (unsigned char *)(a_NBT.GetData(BlockDataTag)));
+ }
+ if (BlockMetaTag > 0)
+ {
+ ZapRegionInNBTSectionNibbles(a_Region, y, (unsigned char *)(a_NBT.GetData(BlockMetaTag)));
+ }
+ if (BlockAddTag > 0)
+ {
+ ZapRegionInNBTSectionNibbles(a_Region, y, (unsigned char *)(a_NBT.GetData(BlockAddTag)));
+ }
+ } // for Child - Level/Sections/[]
+}
+
+
+
+
+
+void cZapper::ZapRegionInNBTSectionBytes(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockBytes)
+{
+ int MinY = std::max(0, a_Region.m_MinY - a_SectionY * 16);
+ int MaxY = std::min(15, a_Region.m_MaxY - a_SectionY * 16);
+ ASSERT(MinY >= 0);
+ ASSERT(MaxY >= 0);
+ for (int y = MinY; y <= MaxY; y++)
+ {
+ for (int z = a_Region.m_MinZ; z <= a_Region.m_MaxZ; z++)
+ {
+ for (int x = a_Region.m_MinX; x <= a_Region.m_MaxX; x++)
+ {
+ a_BlockBytes[x + z * 16 + y * 16 * 16] = 0;
+ }
+ }
+ }
+}
+
+
+
+
+
+void cZapper::ZapRegionInNBTSectionNibbles(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockNibbles)
+{
+ int MinY = std::max(0, a_Region.m_MinY - a_SectionY * 16);
+ int MaxY = std::min(15, a_Region.m_MaxY - a_SectionY * 16);
+ ASSERT(MinY >= 0);
+ ASSERT(MaxY >= 0);
+ for (int y = MinY; y <= MaxY; y++)
+ {
+ for (int z = a_Region.m_MinZ; z < a_Region.m_MaxZ; z++)
+ {
+ for (int x = a_Region.m_MinX; x < a_Region.m_MaxX; x++)
+ {
+ cChunkDef::SetNibble(a_BlockNibbles, x, y, z, 0);
+ }
+ }
+ }
+}
+
+
+
+
+
+void cZapper::ZapRegionEntitiesInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_EntitiesTag)
+{
+ // TODO
+}
+
+
+
+
+
+void cZapper::SerializeNBTTag(const cParsedNBT & a_NBT, int a_Tag, cFastNBTWriter & a_Writer)
+{
+ switch (a_NBT.GetType(a_Tag))
+ {
+ case TAG_Byte: a_Writer.AddByte (a_NBT.GetName(a_Tag), a_NBT.GetByte (a_Tag)); break;
+ case TAG_Short: a_Writer.AddShort (a_NBT.GetName(a_Tag), a_NBT.GetShort (a_Tag)); break;
+ case TAG_Int: a_Writer.AddInt (a_NBT.GetName(a_Tag), a_NBT.GetInt (a_Tag)); break;
+ case TAG_Long: a_Writer.AddLong (a_NBT.GetName(a_Tag), a_NBT.GetLong (a_Tag)); break;
+ case TAG_Float: a_Writer.AddFloat (a_NBT.GetName(a_Tag), a_NBT.GetFloat (a_Tag)); break;
+ case TAG_Double: a_Writer.AddDouble (a_NBT.GetName(a_Tag), a_NBT.GetDouble(a_Tag)); break;
+ case TAG_ByteArray: a_Writer.AddByteArray(a_NBT.GetName(a_Tag), a_NBT.GetData (a_Tag), a_NBT.GetDataLength(a_Tag)); break;
+ case TAG_String: a_Writer.AddString (a_NBT.GetName(a_Tag), a_NBT.GetString(a_Tag)); break;
+ case TAG_IntArray:
+ {
+ std::vector<int> Data;
+ int NumInts = a_NBT.GetDataLength(a_Tag) / 4;
+ Data.reserve(NumInts);
+ int * OrigData = (int *)(a_NBT.GetData(a_Tag));
+ for (int i = 0; i < NumInts; i++)
+ {
+ Data.push_back(ntohl(OrigData[i]));
+ }
+ a_Writer.AddIntArray (a_NBT.GetName(a_Tag), &Data.front(), Data.size()); break;
+ }
+
+ case TAG_List:
+ {
+ a_Writer.BeginList(a_NBT.GetName(a_Tag), a_NBT.GetChildrenType(a_Tag));
+ for (int ch = a_NBT.GetFirstChild(a_Tag); ch >= 0; ch = a_NBT.GetNextSibling(ch))
+ {
+ SerializeNBTTag(a_NBT, ch, a_Writer);
+ } // for ch - children[]
+ a_Writer.EndList();
+ break;
+ }
+
+ case TAG_Compound:
+ {
+ a_Writer.BeginCompound(a_NBT.GetName(a_Tag));
+ for (int ch = a_NBT.GetFirstChild(a_Tag); ch >= 0; ch = a_NBT.GetNextSibling(ch))
+ {
+ SerializeNBTTag(a_NBT, ch, a_Writer);
+ } // for ch - children[]
+ a_Writer.EndCompound();
+ break;
+ }
+
+ default:
+ {
+ ASSERT(!"Unknown NBT tag");
+ break;
+ }
+ }
+}
+
+
+
+
diff --git a/Tools/BlockZapper/Zapper.h b/Tools/BlockZapper/Zapper.h
index 585c3a5ca..6bcd6aa2a 100644
--- a/Tools/BlockZapper/Zapper.h
+++ b/Tools/BlockZapper/Zapper.h
@@ -1,80 +1,80 @@
-
-// Zapper.h
-
-// Declares the cZapper class representing the processor that actually zaps blocks and entities
-
-
-
-
-
-#pragma once
-
-#include "Regions.h"
-
-
-
-
-
-// fwd: ParsedNBT.h
-class cParsedNBT;
-class cFastNBTWriter;
-
-
-
-
-
-class cZapper
-{
-public:
- cZapper(const AString & a_MCAFolder);
-
- /// Zaps all the specified regions
- void ZapRegions(const cRegionVector & a_Regions);
-
-protected:
- static const int BlocksPerChunkX = 16;
- static const int BlocksPerChunkZ = 16;
- static const int ChunksPerMCAX = 32;
- static const int ChunksPerMCAZ = 32;
-
- AString m_MCAFolder;
-
- /// Converts from block coords to MCA coords
- void BlockToMCA(int a_BlockX, int a_BlockZ, int & a_MCAX, int & a_MCAZ);
-
- /// Converts from block coords to chunk coords
- void BlockToChunk(int a_BlockX, int a_BlockZ, int & a_ChunkX, int & a_ChunkZ);
-
- /// Zaps the specified region in the MCA file with the specified MCA coords
- void ZapRegionInMCAFile(const cRegion & a_Region, int a_MCAX, int a_MCAZ);
-
- /** Loads raw compressed chunk data from the specified file
- * chunk is specified by ChunkHeaderValue, which is the int describing the chunk in file header.
- */
- void LoadChunkData(cFile & a_InFile, int a_ChunkHeaderValue, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ);
-
- /// Zaps the specified region in the raw (compressed) chunk data.
- void ZapRegionInRawChunkData(const cRegion & a_Region, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ);
-
- /// Zaps the specified region in the specified NBT structure
- void ZapRegionInNBTChunk(const cRegion & a_Region, cParsedNBT & a_NBT, int a_ChunkX, int a_ChunkZ);
-
- /// Zaps the blocks in the specified region from the specified NBT
- void ZapRegionBlocksInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_SectionsTag);
-
- /// Zaps the blocks in the specified bytes (types) from one vertical section (16^3 blocks) of a chunk.
- void ZapRegionInNBTSectionBytes(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockBytes);
-
- /// Zaps the blocks in the specified nibbles (meta, add) from one vertical section (16^3 blocks) of a chunk.
- void ZapRegionInNBTSectionNibbles(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockNibbles);
-
- /// Zaps entities in the specified region from the specified NBT
- void ZapRegionEntitiesInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_EntitiesTag);
-
- /// Serializes the NBT subtree into a writer
- void SerializeNBTTag(const cParsedNBT & a_NBT, int a_Tag, cFastNBTWriter & a_Writer);
-} ;
-
-
-
-
+
+// Zapper.h
+
+// Declares the cZapper class representing the processor that actually zaps blocks and entities
+
+
+
+
+
+#pragma once
+
+#include "Regions.h"
+
+
+
+
+
+// fwd: ParsedNBT.h
+class cParsedNBT;
+class cFastNBTWriter;
+
+
+
+
+
+class cZapper
+{
+public:
+ cZapper(const AString & a_MCAFolder);
+
+ /// Zaps all the specified regions
+ void ZapRegions(const cRegionVector & a_Regions);
+
+protected:
+ static const int BlocksPerChunkX = 16;
+ static const int BlocksPerChunkZ = 16;
+ static const int ChunksPerMCAX = 32;
+ static const int ChunksPerMCAZ = 32;
+
+ AString m_MCAFolder;
+
+ /// Converts from block coords to MCA coords
+ void BlockToMCA(int a_BlockX, int a_BlockZ, int & a_MCAX, int & a_MCAZ);
+
+ /// Converts from block coords to chunk coords
+ void BlockToChunk(int a_BlockX, int a_BlockZ, int & a_ChunkX, int & a_ChunkZ);
+
+ /// Zaps the specified region in the MCA file with the specified MCA coords
+ void ZapRegionInMCAFile(const cRegion & a_Region, int a_MCAX, int a_MCAZ);
+
+ /** Loads raw compressed chunk data from the specified file
+ * chunk is specified by ChunkHeaderValue, which is the int describing the chunk in file header.
+ */
+ void LoadChunkData(cFile & a_InFile, int a_ChunkHeaderValue, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ);
+
+ /// Zaps the specified region in the raw (compressed) chunk data.
+ void ZapRegionInRawChunkData(const cRegion & a_Region, AString & a_ChunkData, int a_ChunkX, int a_ChunkZ);
+
+ /// Zaps the specified region in the specified NBT structure
+ void ZapRegionInNBTChunk(const cRegion & a_Region, cParsedNBT & a_NBT, int a_ChunkX, int a_ChunkZ);
+
+ /// Zaps the blocks in the specified region from the specified NBT
+ void ZapRegionBlocksInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_SectionsTag);
+
+ /// Zaps the blocks in the specified bytes (types) from one vertical section (16^3 blocks) of a chunk.
+ void ZapRegionInNBTSectionBytes(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockBytes);
+
+ /// Zaps the blocks in the specified nibbles (meta, add) from one vertical section (16^3 blocks) of a chunk.
+ void ZapRegionInNBTSectionNibbles(const cRegion & a_Region, int a_SectionY, unsigned char * a_BlockNibbles);
+
+ /// Zaps entities in the specified region from the specified NBT
+ void ZapRegionEntitiesInNBT(const cRegion & a_Region, cParsedNBT & a_NBT, int a_EntitiesTag);
+
+ /// Serializes the NBT subtree into a writer
+ void SerializeNBTTag(const cParsedNBT & a_NBT, int a_Tag, cFastNBTWriter & a_Writer);
+} ;
+
+
+
+
diff --git a/Tools/MemDumpAnalysis/Globals.cpp b/Tools/MemDumpAnalysis/Globals.cpp
index 6ec09efda..5b366f68e 100644
--- a/Tools/MemDumpAnalysis/Globals.cpp
+++ b/Tools/MemDumpAnalysis/Globals.cpp
@@ -1,10 +1,10 @@
-
-// Globals.cpp
-
-// Used for precompiled header generation
-
-#include "Globals.h"
-
-
-
-
+
+// Globals.cpp
+
+// Used for precompiled header generation
+
+#include "Globals.h"
+
+
+
+
diff --git a/Tools/MemDumpAnalysis/Globals.h b/Tools/MemDumpAnalysis/Globals.h
index 5208a9fa5..92d27da2c 100644
--- a/Tools/MemDumpAnalysis/Globals.h
+++ b/Tools/MemDumpAnalysis/Globals.h
@@ -1,35 +1,35 @@
-
-// Globals.h
-
-// Used for precompiled header generation
-
-
-
-
-
-#pragma once
-
-#include "../../source/Globals.h"
-
-/*
-// System headers:
-#include "targetver.h"
-#include <stdio.h>
-
-// STL headers:
-#include <vector>
-#include <list>
-#include <map>
-#include <string>
-
-// Common:
-#include "../source/StringUtils.h"
-#include "../source/OSSupport/File.h"
-*/
-
-// Libraries:
-#include "../../expat/expat.h"
-
-
-
-
+
+// Globals.h
+
+// Used for precompiled header generation
+
+
+
+
+
+#pragma once
+
+#include "../../source/Globals.h"
+
+/*
+// System headers:
+#include "targetver.h"
+#include <stdio.h>
+
+// STL headers:
+#include <vector>
+#include <list>
+#include <map>
+#include <string>
+
+// Common:
+#include "../source/StringUtils.h"
+#include "../source/OSSupport/File.h"
+*/
+
+// Libraries:
+#include "../../expat/expat.h"
+
+
+
+
diff --git a/Tools/MemDumpAnalysis/MemDumpAnalysis.cpp b/Tools/MemDumpAnalysis/MemDumpAnalysis.cpp
index 9e7759085..9faaef20f 100644
--- a/Tools/MemDumpAnalysis/MemDumpAnalysis.cpp
+++ b/Tools/MemDumpAnalysis/MemDumpAnalysis.cpp
@@ -1,321 +1,321 @@
-
-// MemDumpAnalysis.cpp
-
-// Defines the entry point for the console application.
-
-#include "Globals.h"
-
-#ifdef _WIN32
- #pragma comment(lib, "ws2_32.lib") // Needed for StringUtils' RawBEToUtf8() et al.
-#endif // _WIN32
-
-
-
-
-
-typedef std::set<AString> AStringSet;
-
-
-
-
-
-class cFunction
-{
-public:
- int m_Size; ///< Sum of memory block sizes allocated by this function or its children
- int m_Count; ///< Total number of memory blocks allocated by this function or its children
- AStringSet m_ChildrenNames;
-
- cFunction(void) :
- m_Size(0),
- m_Count(0)
- {
- }
-} ;
-
-typedef std::map<AString, cFunction> FunctionMap;
-
-
-
-
-
-int g_CurrentID = 0;
-int g_CurrentSize = 0;
-FunctionMap g_FnMap;
-AString g_PrevFunctionName;
-
-
-
-
-
-bool IsFnBlackListed(const char * a_FnName)
-{
- static const char * BlackList[] =
- {
- "MyAllocHook",
- "_heap_alloc_dbg_impl",
- "_nh_malloc_dbg_impl",
- "_nh_malloc_dbg",
- "malloc",
- "operator new",
- "_malloc_dbg",
- "realloc_help",
- "_realloc_dbg",
- "realloc",
- "l_alloc",
- "luaM_realloc_",
- "",
- } ;
-
- for (int i = 0; i < ARRAYCOUNT(BlackList); i++)
- {
- if (strcmp(BlackList[i], a_FnName) == 0)
- {
- return true;
- }
- }
- return false;
-}
-
-
-
-
-
-const char * FindAttr(const char ** a_Attrs, const char * a_AttrName)
-{
- for (const char ** Attr = a_Attrs; *Attr != NULL; Attr += 2)
- {
- if (strcmp(*Attr, a_AttrName) == 0)
- {
- return *(Attr + 1);
- }
- } // for Attr - a_Attrs[]
- return NULL;
-}
-
-
-
-
-
-void OnStartElement(void * a_Data, const char * a_Element, const char ** a_Attrs)
-{
- if (strcmp(a_Element, "LEAK") == 0)
- {
- const char * attrID = FindAttr(a_Attrs, "requestID");
- const char * attrSize = FindAttr(a_Attrs, "size");
- g_CurrentID = atoi((attrID == NULL) ? "-1" : attrID);
- g_CurrentSize = atoi((attrSize == NULL) ? "-1" : attrSize);
- g_PrevFunctionName.clear();
- return;
- }
- if (strcmp(a_Element, "STACKENTRY") == 0)
- {
- const char * fnName = FindAttr(a_Attrs, "decl");
- if (fnName == NULL)
- {
- g_CurrentID = -1;
- g_CurrentSize = -1;
- return;
- }
- if (g_CurrentSize < 0)
- {
- return;
- }
- if (IsFnBlackListed(fnName))
- {
- return;
- }
- AString FunctionName = fnName;
- cFunction & Function = g_FnMap[FunctionName];
- Function.m_Size += g_CurrentSize;
- Function.m_Count += 1;
- if (!g_PrevFunctionName.empty())
- {
- Function.m_ChildrenNames.insert(g_PrevFunctionName);
- }
- std::swap(g_PrevFunctionName, FunctionName); // We only care about moving FunctionName into g_PrevFunctionName
- return;
- }
-}
-
-
-
-
-
-void OnEndElement(void * a_Data, const char * a_Element)
-{
- if (strcmp(a_Element, "LEAK") == 0)
- {
- g_CurrentID = -1;
- g_CurrentSize = -1;
- return;
- }
-}
-
-
-
-
-
-bool CompareFnInt(const std::pair<AString, int> & a_First, const std::pair<AString, int> & a_Second)
-{
- return (a_First.second < a_Second.second);
-}
-
-
-
-
-
-void WriteSizeStatistics(void)
-{
- typedef std::vector<std::pair<AString, int> > StringIntPairs;
- StringIntPairs FnSizes;
-
- cFile f("memdump_totals.txt", cFile::fmWrite);
- if (!f.IsOpen())
- {
- LOGERROR("Cannot open memdump_totals.txt");
- return;
- }
-
- for (FunctionMap::iterator itr = g_FnMap.begin(), end = g_FnMap.end(); itr != end; ++itr)
- {
- FnSizes.push_back(std::pair<AString, int>(itr->first, itr->second.m_Size));
- } // for itr - g_FnSizes[]
- std::sort(FnSizes.begin(), FnSizes.end(), CompareFnInt);
-
- for (StringIntPairs::const_iterator itr = FnSizes.begin(), end = FnSizes.end(); itr != end; ++itr)
- {
- f.Printf("%d\t%s\n", itr->second, itr->first.c_str());
- } // for itr - FnSizes[]
-}
-
-
-
-
-
-void WriteCountStatistics(void)
-{
- typedef std::vector<std::pair<AString, int> > StringIntPairs;
- StringIntPairs FnCounts;
-
- cFile f("memdump_counts.txt", cFile::fmWrite);
- if (!f.IsOpen())
- {
- LOGERROR("Cannot open memdump_counts.txt");
- return;
- }
-
- for (FunctionMap::iterator itr = g_FnMap.begin(), end = g_FnMap.end(); itr != end; ++itr)
- {
- FnCounts.push_back(std::pair<AString, int>(itr->first, itr->second.m_Count));
- } // for itr - g_FnSizes[]
- std::sort(FnCounts.begin(), FnCounts.end(), CompareFnInt);
-
- for (StringIntPairs::const_iterator itr = FnCounts.begin(), end = FnCounts.end(); itr != end; ++itr)
- {
- f.Printf("%d\t%s\n", itr->second, itr->first.c_str());
- } // for itr - FnSizes[]
-}
-
-
-
-
-
-AString HTMLEscape(const AString & a_Text)
-{
- AString res;
- res.reserve(a_Text.size());
- size_t len = a_Text.length();
- for (size_t i = 0; i < len; i++)
- {
- switch (a_Text[i])
- {
- case '<': res.append("&lt;<BR/>"); break;
- case '>': res.append("<BR/>&gt;"); break;
- case '&': res.append("&amp;"); break;
- default:
- {
- res.push_back(a_Text[i]);
- }
- }
- } // for i - a_Text[]
- return res;
-}
-
-
-
-
-
-void WriteDotGraph(void)
-{
- cFile f("memdump.dot", cFile::fmWrite);
- if (!f.IsOpen())
- {
- LOGERROR("Cannot open memdump.dot");
- return;
- }
-
- f.Printf("digraph {\n\tnode [shape=plaintext]\n\n");
- for (FunctionMap::const_iterator itrF = g_FnMap.begin(), endF = g_FnMap.end(); itrF != endF; ++itrF)
- {
- f.Printf("\t\"%s\" [label=<%s<BR/>%d bytes (%d KiB)<BR/>%d blocks>]\n",
- itrF->first.c_str(),
- HTMLEscape(itrF->first).c_str(),
- itrF->second.m_Size,
- (itrF->second.m_Size + 1023) / 1024,
- itrF->second.m_Count
- );
- const AStringSet & Children = itrF->second.m_ChildrenNames;
- for (AStringSet::const_iterator itrN = Children.begin(), endN = Children.end(); itrN != endN; ++itrN)
- {
- f.Printf("\t\t\"%s\" -> \"%s\"\n", itrF->first.c_str(), itrN->c_str());
- }
- f.Printf("\n");
- } // for itr
- f.Printf("}\n");
-}
-
-
-
-
-
-int main(int argc, char * argv[])
-{
- // Open the dump file:
- cFile f("memdump.xml", cFile::fmRead);
- if (!f.IsOpen())
- {
- printf("Cannot open memdump.xml\n");
- return 1;
- }
-
- // Create the XML parser:
- XML_Parser Parser = XML_ParserCreate(NULL);
- XML_SetElementHandler(Parser, OnStartElement, OnEndElement);
-
- // Feed the file through XML parser:
- char Buffer[512 KiB];
- while (true)
- {
- int NumBytes = f.Read(Buffer, sizeof(Buffer));
- if (NumBytes <= 0)
- {
- break;
- }
- XML_Parse(Parser, Buffer, NumBytes, false);
- putc('.', stdout);
- }
- XML_Parse(Parser, "", 0, true);
- f.Close();
-
- // Output the statistics
- WriteSizeStatistics();
- WriteCountStatistics();
- WriteDotGraph();
-
- return 0;
-}
-
-
-
-
+
+// MemDumpAnalysis.cpp
+
+// Defines the entry point for the console application.
+
+#include "Globals.h"
+
+#ifdef _WIN32
+ #pragma comment(lib, "ws2_32.lib") // Needed for StringUtils' RawBEToUtf8() et al.
+#endif // _WIN32
+
+
+
+
+
+typedef std::set<AString> AStringSet;
+
+
+
+
+
+class cFunction
+{
+public:
+ int m_Size; ///< Sum of memory block sizes allocated by this function or its children
+ int m_Count; ///< Total number of memory blocks allocated by this function or its children
+ AStringSet m_ChildrenNames;
+
+ cFunction(void) :
+ m_Size(0),
+ m_Count(0)
+ {
+ }
+} ;
+
+typedef std::map<AString, cFunction> FunctionMap;
+
+
+
+
+
+int g_CurrentID = 0;
+int g_CurrentSize = 0;
+FunctionMap g_FnMap;
+AString g_PrevFunctionName;
+
+
+
+
+
+bool IsFnBlackListed(const char * a_FnName)
+{
+ static const char * BlackList[] =
+ {
+ "MyAllocHook",
+ "_heap_alloc_dbg_impl",
+ "_nh_malloc_dbg_impl",
+ "_nh_malloc_dbg",
+ "malloc",
+ "operator new",
+ "_malloc_dbg",
+ "realloc_help",
+ "_realloc_dbg",
+ "realloc",
+ "l_alloc",
+ "luaM_realloc_",
+ "",
+ } ;
+
+ for (int i = 0; i < ARRAYCOUNT(BlackList); i++)
+ {
+ if (strcmp(BlackList[i], a_FnName) == 0)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
+const char * FindAttr(const char ** a_Attrs, const char * a_AttrName)
+{
+ for (const char ** Attr = a_Attrs; *Attr != NULL; Attr += 2)
+ {
+ if (strcmp(*Attr, a_AttrName) == 0)
+ {
+ return *(Attr + 1);
+ }
+ } // for Attr - a_Attrs[]
+ return NULL;
+}
+
+
+
+
+
+void OnStartElement(void * a_Data, const char * a_Element, const char ** a_Attrs)
+{
+ if (strcmp(a_Element, "LEAK") == 0)
+ {
+ const char * attrID = FindAttr(a_Attrs, "requestID");
+ const char * attrSize = FindAttr(a_Attrs, "size");
+ g_CurrentID = atoi((attrID == NULL) ? "-1" : attrID);
+ g_CurrentSize = atoi((attrSize == NULL) ? "-1" : attrSize);
+ g_PrevFunctionName.clear();
+ return;
+ }
+ if (strcmp(a_Element, "STACKENTRY") == 0)
+ {
+ const char * fnName = FindAttr(a_Attrs, "decl");
+ if (fnName == NULL)
+ {
+ g_CurrentID = -1;
+ g_CurrentSize = -1;
+ return;
+ }
+ if (g_CurrentSize < 0)
+ {
+ return;
+ }
+ if (IsFnBlackListed(fnName))
+ {
+ return;
+ }
+ AString FunctionName = fnName;
+ cFunction & Function = g_FnMap[FunctionName];
+ Function.m_Size += g_CurrentSize;
+ Function.m_Count += 1;
+ if (!g_PrevFunctionName.empty())
+ {
+ Function.m_ChildrenNames.insert(g_PrevFunctionName);
+ }
+ std::swap(g_PrevFunctionName, FunctionName); // We only care about moving FunctionName into g_PrevFunctionName
+ return;
+ }
+}
+
+
+
+
+
+void OnEndElement(void * a_Data, const char * a_Element)
+{
+ if (strcmp(a_Element, "LEAK") == 0)
+ {
+ g_CurrentID = -1;
+ g_CurrentSize = -1;
+ return;
+ }
+}
+
+
+
+
+
+bool CompareFnInt(const std::pair<AString, int> & a_First, const std::pair<AString, int> & a_Second)
+{
+ return (a_First.second < a_Second.second);
+}
+
+
+
+
+
+void WriteSizeStatistics(void)
+{
+ typedef std::vector<std::pair<AString, int> > StringIntPairs;
+ StringIntPairs FnSizes;
+
+ cFile f("memdump_totals.txt", cFile::fmWrite);
+ if (!f.IsOpen())
+ {
+ LOGERROR("Cannot open memdump_totals.txt");
+ return;
+ }
+
+ for (FunctionMap::iterator itr = g_FnMap.begin(), end = g_FnMap.end(); itr != end; ++itr)
+ {
+ FnSizes.push_back(std::pair<AString, int>(itr->first, itr->second.m_Size));
+ } // for itr - g_FnSizes[]
+ std::sort(FnSizes.begin(), FnSizes.end(), CompareFnInt);
+
+ for (StringIntPairs::const_iterator itr = FnSizes.begin(), end = FnSizes.end(); itr != end; ++itr)
+ {
+ f.Printf("%d\t%s\n", itr->second, itr->first.c_str());
+ } // for itr - FnSizes[]
+}
+
+
+
+
+
+void WriteCountStatistics(void)
+{
+ typedef std::vector<std::pair<AString, int> > StringIntPairs;
+ StringIntPairs FnCounts;
+
+ cFile f("memdump_counts.txt", cFile::fmWrite);
+ if (!f.IsOpen())
+ {
+ LOGERROR("Cannot open memdump_counts.txt");
+ return;
+ }
+
+ for (FunctionMap::iterator itr = g_FnMap.begin(), end = g_FnMap.end(); itr != end; ++itr)
+ {
+ FnCounts.push_back(std::pair<AString, int>(itr->first, itr->second.m_Count));
+ } // for itr - g_FnSizes[]
+ std::sort(FnCounts.begin(), FnCounts.end(), CompareFnInt);
+
+ for (StringIntPairs::const_iterator itr = FnCounts.begin(), end = FnCounts.end(); itr != end; ++itr)
+ {
+ f.Printf("%d\t%s\n", itr->second, itr->first.c_str());
+ } // for itr - FnSizes[]
+}
+
+
+
+
+
+AString HTMLEscape(const AString & a_Text)
+{
+ AString res;
+ res.reserve(a_Text.size());
+ size_t len = a_Text.length();
+ for (size_t i = 0; i < len; i++)
+ {
+ switch (a_Text[i])
+ {
+ case '<': res.append("&lt;<BR/>"); break;
+ case '>': res.append("<BR/>&gt;"); break;
+ case '&': res.append("&amp;"); break;
+ default:
+ {
+ res.push_back(a_Text[i]);
+ }
+ }
+ } // for i - a_Text[]
+ return res;
+}
+
+
+
+
+
+void WriteDotGraph(void)
+{
+ cFile f("memdump.dot", cFile::fmWrite);
+ if (!f.IsOpen())
+ {
+ LOGERROR("Cannot open memdump.dot");
+ return;
+ }
+
+ f.Printf("digraph {\n\tnode [shape=plaintext]\n\n");
+ for (FunctionMap::const_iterator itrF = g_FnMap.begin(), endF = g_FnMap.end(); itrF != endF; ++itrF)
+ {
+ f.Printf("\t\"%s\" [label=<%s<BR/>%d bytes (%d KiB)<BR/>%d blocks>]\n",
+ itrF->first.c_str(),
+ HTMLEscape(itrF->first).c_str(),
+ itrF->second.m_Size,
+ (itrF->second.m_Size + 1023) / 1024,
+ itrF->second.m_Count
+ );
+ const AStringSet & Children = itrF->second.m_ChildrenNames;
+ for (AStringSet::const_iterator itrN = Children.begin(), endN = Children.end(); itrN != endN; ++itrN)
+ {
+ f.Printf("\t\t\"%s\" -> \"%s\"\n", itrF->first.c_str(), itrN->c_str());
+ }
+ f.Printf("\n");
+ } // for itr
+ f.Printf("}\n");
+}
+
+
+
+
+
+int main(int argc, char * argv[])
+{
+ // Open the dump file:
+ cFile f("memdump.xml", cFile::fmRead);
+ if (!f.IsOpen())
+ {
+ printf("Cannot open memdump.xml\n");
+ return 1;
+ }
+
+ // Create the XML parser:
+ XML_Parser Parser = XML_ParserCreate(NULL);
+ XML_SetElementHandler(Parser, OnStartElement, OnEndElement);
+
+ // Feed the file through XML parser:
+ char Buffer[512 KiB];
+ while (true)
+ {
+ int NumBytes = f.Read(Buffer, sizeof(Buffer));
+ if (NumBytes <= 0)
+ {
+ break;
+ }
+ XML_Parse(Parser, Buffer, NumBytes, false);
+ putc('.', stdout);
+ }
+ XML_Parse(Parser, "", 0, true);
+ f.Close();
+
+ // Output the statistics
+ WriteSizeStatistics();
+ WriteCountStatistics();
+ WriteDotGraph();
+
+ return 0;
+}
+
+
+
+
diff --git a/Tools/MemDumpAnalysis/MemDumpAnalysis.sln b/Tools/MemDumpAnalysis/MemDumpAnalysis.sln
index 45fbd933f..096a9009c 100644
--- a/Tools/MemDumpAnalysis/MemDumpAnalysis.sln
+++ b/Tools/MemDumpAnalysis/MemDumpAnalysis.sln
@@ -1,20 +1,20 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MemDumpAnalysis", "MemDumpAnalysis.vcproj", "{110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}.Debug|Win32.ActiveCfg = Debug|Win32
- {110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}.Debug|Win32.Build.0 = Debug|Win32
- {110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}.Release|Win32.ActiveCfg = Release|Win32
- {110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MemDumpAnalysis", "MemDumpAnalysis.vcproj", "{110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}.Debug|Win32.ActiveCfg = Debug|Win32
+ {110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}.Debug|Win32.Build.0 = Debug|Win32
+ {110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}.Release|Win32.ActiveCfg = Release|Win32
+ {110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj b/Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj
index ffb935868..345dfa962 100644
--- a/Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj
+++ b/Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj
@@ -1,439 +1,439 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="MemDumpAnalysis"
- ProjectGUID="{110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}"
- RootNamespace="MemDumpAnalysis"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;COMPILED_FROM_DSP;XML_STATIC"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName)_debug.exe"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;COMPILED_FROM_DSP;XML_STATIC"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName).exe"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\Globals.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\Globals.h"
- >
- </File>
- <File
- RelativePath=".\MemDumpAnalysis.cpp"
- >
- </File>
- <File
- RelativePath=".\targetver.h"
- >
- </File>
- </Filter>
- <Filter
- Name="expat"
- >
- <File
- RelativePath="..\..\expat\ascii.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\asciitab.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\expat.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\expat_external.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\iasciitab.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\internal.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\latin1tab.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\nametab.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\utf8tab.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\winconfig.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\xmlparse.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\expat\xmlrole.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\expat\xmlrole.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\xmltok.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\expat\xmltok.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\xmltok_impl.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\expat\xmltok_impl.h"
- >
- </File>
- <File
- RelativePath="..\..\expat\xmltok_ns.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- <Filter
- Name="shared"
- >
- <File
- RelativePath="..\..\source\Log.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\Log.h"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.h"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.h"
- >
- </File>
- <Filter
- Name="OSSupport"
- >
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.h"
- >
- </File>
- </Filter>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="MemDumpAnalysis"
+ ProjectGUID="{110861A3-EF64-494F-8FC2-7F7ACFD3FEAC}"
+ RootNamespace="MemDumpAnalysis"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;COMPILED_FROM_DSP;XML_STATIC"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName)_debug.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;COMPILED_FROM_DSP;XML_STATIC"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName).exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\Globals.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\Globals.h"
+ >
+ </File>
+ <File
+ RelativePath=".\MemDumpAnalysis.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\targetver.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="expat"
+ >
+ <File
+ RelativePath="..\..\expat\ascii.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\asciitab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\expat.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\expat_external.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\iasciitab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\internal.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\latin1tab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\nametab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\utf8tab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\winconfig.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\xmlparse.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\expat\xmlrole.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\expat\xmlrole.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\xmltok.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\expat\xmltok.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\xmltok_impl.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\expat\xmltok_impl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\expat\xmltok_ns.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <Filter
+ Name="shared"
+ >
+ <File
+ RelativePath="..\..\source\Log.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Log.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.h"
+ >
+ </File>
+ <Filter
+ Name="OSSupport"
+ >
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj.user b/Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj.user
index 11ddaa32b..f4ced837a 100644
--- a/Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj.user
+++ b/Tools/MemDumpAnalysis/MemDumpAnalysis.vcproj.user
@@ -1,31 +1,31 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioUserFile
- ProjectType="Visual C++"
- Version="9,00"
- ShowAllFiles="false"
- >
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- >
- <DebugSettings
- Command="$(TargetPath)"
- WorkingDirectory="$(TargetDir)"
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- >
- <DebugSettings
- Command="$(TargetPath)"
- WorkingDirectory="$(TargetDir)"
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- />
- </Configuration>
- </Configurations>
-</VisualStudioUserFile>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioUserFile
+ ProjectType="Visual C++"
+ Version="9,00"
+ ShowAllFiles="false"
+ >
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory="$(TargetDir)"
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory="$(TargetDir)"
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ />
+ </Configuration>
+ </Configurations>
+</VisualStudioUserFile>
diff --git a/Tools/MemDumpAnalysis/targetver.h b/Tools/MemDumpAnalysis/targetver.h
index 56ab74a5e..7f4aeaca1 100644
--- a/Tools/MemDumpAnalysis/targetver.h
+++ b/Tools/MemDumpAnalysis/targetver.h
@@ -1,25 +1,25 @@
-
-// targetver.h
-
-// Used by MSWin builds to target the appropriate OS version
-
-
-
-
-
-#pragma once
-
-// The following macros define the minimum required platform. The minimum required platform
-// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
-// your application. The macros work by enabling all features available on platform versions up to and
-// including the version specified.
-
-// Modify the following defines if you have to target a platform prior to the ones specified below.
-// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
-#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
-#endif
-
-
-
-
+
+// targetver.h
+
+// Used by MSWin builds to target the appropriate OS version
+
+
+
+
+
+#pragma once
+
+// The following macros define the minimum required platform. The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+
+
+
diff --git a/Tools/ProtoProxy/.gitignore b/Tools/ProtoProxy/.gitignore
new file mode 100644
index 000000000..3097f7aab
--- /dev/null
+++ b/Tools/ProtoProxy/.gitignore
@@ -0,0 +1,4 @@
+Debug
+Release
+*.log
+*.nbt
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index a3d3191fc..7c808f2c1 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -1,2516 +1,2551 @@
-
-// Connection.cpp
-
-// Interfaces to the cConnection class representing a single pair of connected sockets
-
-#include "Globals.h"
-#include "Connection.h"
-#include "Server.h"
-#include <iostream>
-
-
-
-
-
-#ifdef _DEBUG
- #define DebugSleep Sleep
-#else
- #define DebugSleep(X)
-#endif // else _DEBUG
-
-
-
-
-
-#define HANDLE_CLIENT_PACKET_READ(Proc, Type, Var) \
- Type Var; \
- { \
- if (!m_ClientBuffer.Proc(Var)) \
- { \
- return false; \
- } \
- }
-
-#define HANDLE_SERVER_PACKET_READ(Proc, Type, Var) \
- Type Var; \
- { \
- if (!m_ServerBuffer.Proc(Var)) \
- { \
- return false; \
- } \
- }
-
-#define CLIENTSEND(...) SendData(m_ClientSocket, __VA_ARGS__, "Client")
-#define SERVERSEND(...) SendData(m_ServerSocket, __VA_ARGS__, "Server")
-#define CLIENTENCRYPTSEND(...) SendEncryptedData(m_ClientSocket, m_ClientEncryptor, __VA_ARGS__, "Client")
-#define SERVERENCRYPTSEND(...) SendEncryptedData(m_ServerSocket, m_ServerEncryptor, __VA_ARGS__, "Server")
-
-#define COPY_TO_SERVER() \
- { \
- AString ToServer; \
- m_ClientBuffer.ReadAgain(ToServer); \
- if (m_ServerState == csUnencrypted) \
- { \
- SERVERSEND(ToServer.data(), ToServer.size()); \
- } \
- else \
- { \
- SERVERENCRYPTSEND(ToServer.data(), ToServer.size()); \
- } \
- DebugSleep(50); \
- }
-
-#define COPY_TO_CLIENT() \
- { \
- AString ToClient; \
- m_ServerBuffer.ReadAgain(ToClient); \
- if (m_ClientState == csUnencrypted) \
- { \
- CLIENTSEND(ToClient.data(), ToClient.size()); \
- } \
- else \
- { \
- CLIENTENCRYPTSEND(ToClient.data(), ToClient.size()); \
- } \
- DebugSleep(50); \
- }
-
-#define HANDLE_CLIENT_READ(Proc) \
- { \
- if (!Proc()) \
- { \
- AString Leftover; \
- m_ClientBuffer.ReadAgain(Leftover); \
- DataLog(Leftover.data(), Leftover.size(), "Leftover data after client packet parsing, %d bytes:", Leftover.size()); \
- m_ClientBuffer.ResetRead(); \
- return true; \
- } \
- }
-
-#define HANDLE_SERVER_READ(Proc) \
- { \
- if (!Proc()) \
- { \
- m_ServerBuffer.ResetRead(); \
- return true; \
- } \
- }
-
-
-#define MAX_ENC_LEN 1024
-
-
-
-
-typedef unsigned char Byte;
-
-
-
-
-
-enum
-{
- PACKET_KEEPALIVE = 0x00,
- PACKET_LOGIN = 0x01,
- PACKET_HANDSHAKE = 0x02,
- PACKET_CHAT_MESSAGE = 0x03,
- PACKET_TIME_UPDATE = 0x04,
- PACKET_ENTITY_EQUIPMENT = 0x05,
- PACKET_COMPASS = 0x06,
- PACKET_USE_ENTITY = 0x07,
- PACKET_UPDATE_HEALTH = 0x08,
- PACKET_PLAYER_ON_GROUND = 0x0a,
- PACKET_PLAYER_POSITION = 0x0b,
- PACKET_PLAYER_LOOK = 0x0c,
- PACKET_PLAYER_POSITION_LOOK = 0x0d,
- PACKET_BLOCK_DIG = 0x0e,
- PACKET_BLOCK_PLACE = 0x0f,
- PACKET_SLOT_SELECT = 0x10,
- PACKET_PLAYER_ANIMATION = 0x12,
- PACKET_ENTITY_ACTION = 0x13,
- PACKET_SPAWN_NAMED_ENTITY = 0x14,
- PACKET_SPAWN_PICKUP = 0x15,
- PACKET_COLLECT_PICKUP = 0x16,
- PACKET_SPAWN_OBJECT_VEHICLE = 0x17,
- PACKET_SPAWN_MOB = 0x18,
- PACKET_SPAWN_PAINTING = 0x19,
- PACKET_SPAWN_EXPERIENCE_ORB = 0x1a,
- PACKET_ENTITY_VELOCITY = 0x1c,
- PACKET_DESTROY_ENTITIES = 0x1d,
- PACKET_ENTITY = 0x1e,
- PACKET_ENTITY_RELATIVE_MOVE = 0x1f,
- PACKET_ENTITY_LOOK = 0x20,
- PACKET_ENTITY_RELATIVE_MOVE_LOOK = 0x21,
- PACKET_ENTITY_TELEPORT = 0x22,
- PACKET_ENTITY_HEAD_LOOK = 0x23,
- PACKET_ENTITY_STATUS = 0x26,
- PACKET_ATTACH_ENTITY = 0x27,
- PACKET_ENTITY_METADATA = 0x28,
- PACKET_ENTITY_EFFECT = 0x29,
- PACKET_ENTITY_EFFECT_REMOVE = 0x2a,
- PACKET_SET_EXPERIENCE = 0x2b,
- PACKET_ENTITY_PROPERTIES = 0x2c,
- PACKET_MAP_CHUNK = 0x33,
- PACKET_MULTI_BLOCK_CHANGE = 0x34,
- PACKET_BLOCK_CHANGE = 0x35,
- PACKET_BLOCK_ACTION = 0x36,
- PACKET_MAP_CHUNK_BULK = 0x38,
- PACKET_SOUND_EFFECT = 0x3d,
- PACKET_NAMED_SOUND_EFFECT = 0x3e,
- PACKET_CHANGE_GAME_STATE = 0x46,
- PACKET_WINDOW_OPEN = 0x64,
- PACKET_WINDOW_CLOSE = 0x65,
- PACKET_WINDOW_CLICK = 0x66,
- PACKET_SET_SLOT = 0x67,
- PACKET_WINDOW_CONTENTS = 0x68,
- PACKET_CREATIVE_INVENTORY_ACTION = 0x6b,
- PACKET_UPDATE_SIGN = 0x82,
- PACKET_UPDATE_TILE_ENTITY = 0x84,
- PACKET_PLAYER_LIST_ITEM = 0xc9,
- PACKET_PLAYER_ABILITIES = 0xca,
- PACKET_INCREMENT_STATISTIC = 0xc8,
- PACKET_LOCALE_AND_VIEW = 0xcc,
- PACKET_CLIENT_STATUSES = 0xcd,
- PACKET_PLUGIN_MESSAGE = 0xfa,
- PACKET_ENCRYPTION_KEY_RESPONSE = 0xfc,
- PACKET_ENCRYPTION_KEY_REQUEST = 0xfd,
- PACKET_PING = 0xfe,
- PACKET_KICK = 0xff,
-} ;
-
-
-
-
-enum
-{
- OBJECT_BOAT = 1,
- OBJECT_MINECART = 10,
- OBJECT_MINECART_STORAGE = 11,
- OBJECT_MINECART_POWERED = 12,
- OBJECT_TNT = 50,
- OBJECT_ENDERCRYSTAL = 51,
- OBJECT_ARROW = 60,
- OBJECT_SNOWBALL = 61,
- OBJECT_EGG = 62,
- OBJECT_FALLING_BLOCK = 70,
- OBJECT_EYE_OF_ENDER = 72,
- OBJECT_DRAGON_EGG = 74,
- OBJECT_FISHING_FLOAT = 90,
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cConnection:
-
-cConnection::cConnection(SOCKET a_ClientSocket, cServer & a_Server) :
- m_ItemIdx(0),
- m_LogFile(NULL),
- m_Server(a_Server),
- m_ClientSocket(a_ClientSocket),
- m_ServerSocket(-1),
- m_BeginTick(clock()),
- m_ClientState(csUnencrypted),
- m_ServerState(csUnencrypted),
- m_Nonce(0),
- m_ClientBuffer(1024 KiB),
- m_ServerBuffer(1024 KiB),
- m_HasClientPinged(false)
-{
- Printf(m_LogNameBase, "Log_%d", (int)time(NULL));
- AString fnam(m_LogNameBase);
- fnam.append(".log");
- m_LogFile = fopen(fnam.c_str(), "w");
- Log("Log file created");
- printf("Connection is logged to file \"%s\"\n", fnam.c_str());
-}
-
-
-
-
-
-cConnection::~cConnection()
-{
- fclose(m_LogFile);
-}
-
-
-
-
-
-void cConnection::Run(void)
-{
- if (!ConnectToServer())
- {
- Log("Cannot connect to server; aborting");
- return;
- }
-
- while (true)
- {
- fd_set ReadFDs;
- FD_ZERO(&ReadFDs);
- FD_SET(m_ServerSocket, &ReadFDs);
- FD_SET(m_ClientSocket, &ReadFDs);
- int res = select(2, &ReadFDs, NULL, NULL, NULL);
- if (res <= 0)
- {
- printf("select() failed: %d; aborting client", WSAGetLastError());
- break;
- }
- if (FD_ISSET(m_ServerSocket, &ReadFDs))
- {
- if (!RelayFromServer())
- {
- break;
- }
- }
- if (FD_ISSET(m_ClientSocket, &ReadFDs))
- {
- if (!RelayFromClient())
- {
- break;
- }
- }
- }
- Log("Relaying ended, closing sockets");
- closesocket(m_ServerSocket);
- closesocket(m_ClientSocket);
-}
-
-
-
-
-
-void cConnection::Log(const char * a_Format, ...)
-{
- va_list args;
- va_start(args, a_Format);
- AString msg;
- AppendVPrintf(msg, a_Format, args);
- va_end(args);
- AString FullMsg;
- Printf(FullMsg, "[%5.3f] %s\n", GetRelativeTime(), msg.c_str());
-
- // Log to file:
- cCSLock Lock(m_CSLog);
- fputs(FullMsg.c_str(), m_LogFile);
-
- // Log to screen:
- // std::cout << FullMsg;
-}
-
-
-
-
-
-void cConnection::DataLog(const void * a_Data, int a_Size, const char * a_Format, ...)
-{
- va_list args;
- va_start(args, a_Format);
- AString msg;
- AppendVPrintf(msg, a_Format, args);
- va_end(args);
- AString FullMsg;
- AString Hex;
- Printf(FullMsg, "[%5.3f] %s\n%s\n", GetRelativeTime(), msg.c_str(), CreateHexDump(Hex, a_Data, a_Size, 16).c_str());
-
- // Log to file:
- cCSLock Lock(m_CSLog);
- fputs(FullMsg.c_str(), m_LogFile);
-
- /*
- // Log to screen:
- std::cout << FullMsg;
- //*/
-}
-
-
-
-
-
-void cConnection::LogFlush(void)
-{
- fflush(m_LogFile);
-}
-
-
-
-
-
-bool cConnection::ConnectToServer(void)
-{
- m_ServerSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (m_ServerSocket == INVALID_SOCKET)
- {
- return false;
- }
- sockaddr_in localhost;
- localhost.sin_family = AF_INET;
- localhost.sin_port = htons(m_Server.GetConnectPort());
- localhost.sin_addr.s_addr = htonl(0x7f000001); // localhost
- if (connect(m_ServerSocket, (sockaddr *)&localhost, sizeof(localhost)) != 0)
- {
- printf("connection to server failed: %d\n", WSAGetLastError());
- return false;
- }
- Log("Connected to SERVER");
- return true;
-}
-
-
-
-
-
-bool cConnection::RelayFromServer(void)
-{
- char Buffer[64 KiB];
- int res = recv(m_ServerSocket, Buffer, sizeof(Buffer), 0);
- if (res <= 0)
- {
- Log("Server closed the socket: %d; %d; aborting connection", res, WSAGetLastError());
- return false;
- }
-
- DataLog(Buffer, res, "Received %d bytes from the SERVER", res);
-
- switch (m_ServerState)
- {
- case csUnencrypted:
- {
- return DecodeServersPackets(Buffer, res);
- }
- case csEncryptedUnderstood:
- {
- m_ServerDecryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
- DataLog(Buffer, res, "Decrypted %d bytes from the SERVER", res);
- return DecodeServersPackets(Buffer, res);
- }
- case csEncryptedUnknown:
- {
- m_ServerDecryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
- DataLog(Buffer, res, "Decrypted %d bytes from the SERVER", res);
- m_ClientEncryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
- return CLIENTSEND(Buffer, res);
- }
- }
-
- return true;
-}
-
-
-
-
-
-bool cConnection::RelayFromClient(void)
-{
- char Buffer[64 KiB];
- int res = recv(m_ClientSocket, Buffer, sizeof(Buffer), 0);
- if (res <= 0)
- {
- Log("Client closed the socket: %d; %d; aborting connection", res, WSAGetLastError());
- return false;
- }
-
- DataLog(Buffer, res, "Received %d bytes from the CLIENT", res);
-
- switch (m_ClientState)
- {
- case csUnencrypted:
- {
- return DecodeClientsPackets(Buffer, res);
- }
- case csEncryptedUnderstood:
- {
- m_ClientDecryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
- DataLog(Buffer, res, "Decrypted %d bytes from the CLIENT", res);
- return DecodeClientsPackets(Buffer, res);
- }
- case csEncryptedUnknown:
- {
- m_ClientDecryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
- DataLog(Buffer, res, "Decrypted %d bytes from the CLIENT", res);
- m_ServerEncryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
- return SERVERSEND(Buffer, res);
- }
- }
-
- return true;
-}
-
-
-
-
-
-double cConnection::GetRelativeTime(void)
-{
- return (double)(clock() - m_BeginTick) / CLOCKS_PER_SEC;
-
-}
-
-
-
-
-
-bool cConnection::SendData(SOCKET a_Socket, const char * a_Data, int a_Size, const char * a_Peer)
-{
- DataLog(a_Data, a_Size, "Sending data to %s", a_Peer);
-
- int res = send(a_Socket, a_Data, a_Size, 0);
- if (res <= 0)
- {
- Log("%s closed the socket: %d, %d; aborting connection", a_Peer, res, WSAGetLastError());
- return false;
- }
- return true;
-}
-
-
-
-
-
-bool cConnection::SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a_Peer)
-{
- AString All;
- a_Data.ReadAll(All);
- a_Data.CommitRead();
- return SendData(a_Socket, All.data(), All.size(), a_Peer);
-}
-
-
-
-
-
-bool cConnection::SendEncryptedData(SOCKET a_Socket, Encryptor & a_Encryptor, const char * a_Data, int a_Size, const char * a_Peer)
-{
- DataLog(a_Data, a_Size, "Encrypting %d bytes to %s", a_Size, a_Peer);
- const byte * Data = (const byte *)a_Data;
- while (a_Size > 0)
- {
- byte Buffer[64 KiB];
- int NumBytes = (a_Size > sizeof(Buffer)) ? sizeof(Buffer) : a_Size;
- a_Encryptor.ProcessData(Buffer, Data, NumBytes);
- bool res = SendData(a_Socket, (const char *)Buffer, NumBytes, a_Peer);
- if (!res)
- {
- return false;
- }
- Data += NumBytes;
- a_Size -= NumBytes;
- }
- return true;
-}
-
-
-
-
-
-bool cConnection::SendEncryptedData(SOCKET a_Socket, Encryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer)
-{
- AString All;
- a_Data.ReadAll(All);
- a_Data.CommitRead();
- return SendEncryptedData(a_Socket, a_Encryptor, All.data(), All.size(), a_Peer);
-}
-
-
-
-
-
-bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size)
-{
- if (!m_ClientBuffer.Write(a_Data, a_Size))
- {
- Log("Too much queued data for the server, aborting connection");
- return false;
- }
-
- while (m_ClientBuffer.CanReadBytes(1))
- {
- Log("Decoding client's packets, there are now %d bytes in the queue", m_ClientBuffer.GetReadableSpace());
- unsigned char PacketType;
- m_ClientBuffer.ReadByte(PacketType);
- switch (PacketType)
- {
- case PACKET_BLOCK_DIG: HANDLE_CLIENT_READ(HandleClientBlockDig); break;
- case PACKET_BLOCK_PLACE: HANDLE_CLIENT_READ(HandleClientBlockPlace); break;
- case PACKET_CHAT_MESSAGE: HANDLE_CLIENT_READ(HandleClientChatMessage); break;
- case PACKET_CLIENT_STATUSES: HANDLE_CLIENT_READ(HandleClientClientStatuses); break;
- case PACKET_CREATIVE_INVENTORY_ACTION: HANDLE_CLIENT_READ(HandleClientCreativeInventoryAction); break;
- case PACKET_ENCRYPTION_KEY_RESPONSE: HANDLE_CLIENT_READ(HandleClientEncryptionKeyResponse); break;
- case PACKET_ENTITY_ACTION: HANDLE_CLIENT_READ(HandleClientEntityAction); break;
- case PACKET_HANDSHAKE: HANDLE_CLIENT_READ(HandleClientHandshake); break;
- case PACKET_KEEPALIVE: HANDLE_CLIENT_READ(HandleClientKeepAlive); break;
- case PACKET_LOCALE_AND_VIEW: HANDLE_CLIENT_READ(HandleClientLocaleAndView); break;
- case PACKET_PING: HANDLE_CLIENT_READ(HandleClientPing); break;
- case PACKET_PLAYER_ABILITIES: HANDLE_CLIENT_READ(HandleClientPlayerAbilities); break;
- case PACKET_PLAYER_ANIMATION: HANDLE_CLIENT_READ(HandleClientAnimation); break;
- case PACKET_PLAYER_LOOK: HANDLE_CLIENT_READ(HandleClientPlayerLook); break;
- case PACKET_PLAYER_ON_GROUND: HANDLE_CLIENT_READ(HandleClientPlayerOnGround); break;
- case PACKET_PLAYER_POSITION: HANDLE_CLIENT_READ(HandleClientPlayerPosition); break;
- case PACKET_PLAYER_POSITION_LOOK: HANDLE_CLIENT_READ(HandleClientPlayerPositionLook); break;
- case PACKET_PLUGIN_MESSAGE: HANDLE_CLIENT_READ(HandleClientPluginMessage); break;
- case PACKET_SLOT_SELECT: HANDLE_CLIENT_READ(HandleClientSlotSelect); break;
- case PACKET_UPDATE_SIGN: HANDLE_CLIENT_READ(HandleClientUpdateSign); break;
- case PACKET_USE_ENTITY: HANDLE_CLIENT_READ(HandleClientUseEntity); break;
- case PACKET_WINDOW_CLICK: HANDLE_CLIENT_READ(HandleClientWindowClick); break;
- case PACKET_WINDOW_CLOSE: HANDLE_CLIENT_READ(HandleClientWindowClose); break;
- default:
- {
- if (m_ClientState == csEncryptedUnderstood)
- {
- Log("****************** Unknown packet 0x%02x from the client while encrypted; continuing to relay blind only", PacketType);
- AString Data;
- m_ClientBuffer.ResetRead();
- m_ClientBuffer.ReadAll(Data);
- DataLog(Data.data(), Data.size(), "Current data in the client packet queue: %d bytes", Data.size());
- m_ClientState = csEncryptedUnknown;
- m_ClientBuffer.ResetRead();
- if (m_ServerState == csUnencrypted)
- {
- SERVERSEND(m_ClientBuffer);
- }
- else
- {
- SERVERENCRYPTSEND(m_ClientBuffer);
- }
- return true;
- }
- else
- {
- Log("Unknown packet 0x%02x from the client while unencrypted; aborting connection", PacketType);
- return false;
- }
- }
- } // switch (PacketType)
- m_ClientBuffer.CommitRead();
- } // while (CanReadBytes(1))
- return true;
-}
-
-
-
-
-
-bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
-{
- if (!m_ServerBuffer.Write(a_Data, a_Size))
- {
- Log("Too much queued data for the client, aborting connection");
- return false;
- }
-
- if (
- (m_ServerState == csEncryptedUnderstood) &&
- (m_ClientState == csUnencrypted)
- )
- {
- // Client hasn't finished encryption handshake yet, don't send them any data yet
- }
-
- while (m_ServerBuffer.CanReadBytes(1))
- {
- unsigned char PacketType;
- m_ServerBuffer.ReadByte(PacketType);
- Log("Decoding server's packets, there are now %d bytes in the queue; next packet is 0x%x", m_ServerBuffer.GetReadableSpace(), PacketType);
- LogFlush();
- switch (PacketType)
- {
- case PACKET_ATTACH_ENTITY: HANDLE_SERVER_READ(HandleServerAttachEntity); break;
- case PACKET_BLOCK_ACTION: HANDLE_SERVER_READ(HandleServerBlockAction); break;
- case PACKET_BLOCK_CHANGE: HANDLE_SERVER_READ(HandleServerBlockChange); break;
- case PACKET_CHANGE_GAME_STATE: HANDLE_SERVER_READ(HandleServerChangeGameState); break;
- case PACKET_CHAT_MESSAGE: HANDLE_SERVER_READ(HandleServerChatMessage); break;
- case PACKET_COLLECT_PICKUP: HANDLE_SERVER_READ(HandleServerCollectPickup); break;
- case PACKET_COMPASS: HANDLE_SERVER_READ(HandleServerCompass); break;
- case PACKET_DESTROY_ENTITIES: HANDLE_SERVER_READ(HandleServerDestroyEntities); break;
- case PACKET_ENCRYPTION_KEY_REQUEST: HANDLE_SERVER_READ(HandleServerEncryptionKeyRequest); break;
- case PACKET_ENCRYPTION_KEY_RESPONSE: HANDLE_SERVER_READ(HandleServerEncryptionKeyResponse); break;
- case PACKET_ENTITY: HANDLE_SERVER_READ(HandleServerEntity); break;
- case PACKET_ENTITY_EQUIPMENT: HANDLE_SERVER_READ(HandleServerEntityEquipment); break;
- case PACKET_ENTITY_HEAD_LOOK: HANDLE_SERVER_READ(HandleServerEntityHeadLook); break;
- case PACKET_ENTITY_LOOK: HANDLE_SERVER_READ(HandleServerEntityLook); break;
- case PACKET_ENTITY_METADATA: HANDLE_SERVER_READ(HandleServerEntityMetadata); break;
- case PACKET_ENTITY_PROPERTIES: HANDLE_SERVER_READ(HandleServerEntityProperties); break;
- case PACKET_ENTITY_RELATIVE_MOVE: HANDLE_SERVER_READ(HandleServerEntityRelativeMove); break;
- case PACKET_ENTITY_RELATIVE_MOVE_LOOK: HANDLE_SERVER_READ(HandleServerEntityRelativeMoveLook); break;
- case PACKET_ENTITY_STATUS: HANDLE_SERVER_READ(HandleServerEntityStatus); break;
- case PACKET_ENTITY_TELEPORT: HANDLE_SERVER_READ(HandleServerEntityTeleport); break;
- case PACKET_ENTITY_VELOCITY: HANDLE_SERVER_READ(HandleServerEntityVelocity); break;
- case PACKET_INCREMENT_STATISTIC: HANDLE_SERVER_READ(HandleServerIncrementStatistic); break;
- case PACKET_KEEPALIVE: HANDLE_SERVER_READ(HandleServerKeepAlive); break;
- case PACKET_KICK: HANDLE_SERVER_READ(HandleServerKick); break;
- case PACKET_LOGIN: HANDLE_SERVER_READ(HandleServerLogin); break;
- case PACKET_MAP_CHUNK: HANDLE_SERVER_READ(HandleServerMapChunk); break;
- case PACKET_MAP_CHUNK_BULK: HANDLE_SERVER_READ(HandleServerMapChunkBulk); break;
- case PACKET_MULTI_BLOCK_CHANGE: HANDLE_SERVER_READ(HandleServerMultiBlockChange); break;
- case PACKET_NAMED_SOUND_EFFECT: HANDLE_SERVER_READ(HandleServerNamedSoundEffect); break;
- case PACKET_PLAYER_ABILITIES: HANDLE_SERVER_READ(HandleServerPlayerAbilities); break;
- case PACKET_PLAYER_ANIMATION: HANDLE_SERVER_READ(HandleServerPlayerAnimation); break;
- case PACKET_PLAYER_LIST_ITEM: HANDLE_SERVER_READ(HandleServerPlayerListItem); break;
- case PACKET_PLAYER_POSITION_LOOK: HANDLE_SERVER_READ(HandleServerPlayerPositionLook); break;
- case PACKET_PLUGIN_MESSAGE: HANDLE_SERVER_READ(HandleServerPluginMessage); break;
- case PACKET_SET_EXPERIENCE: HANDLE_SERVER_READ(HandleServerSetExperience); break;
- case PACKET_SET_SLOT: HANDLE_SERVER_READ(HandleServerSetSlot); break;
- case PACKET_SLOT_SELECT: HANDLE_SERVER_READ(HandleServerSlotSelect); break;
- case PACKET_SOUND_EFFECT: HANDLE_SERVER_READ(HandleServerSoundEffect); break;
- case PACKET_SPAWN_MOB: HANDLE_SERVER_READ(HandleServerSpawnMob); break;
- case PACKET_SPAWN_NAMED_ENTITY: HANDLE_SERVER_READ(HandleServerSpawnNamedEntity); break;
- case PACKET_SPAWN_OBJECT_VEHICLE: HANDLE_SERVER_READ(HandleServerSpawnObjectVehicle); break;
- case PACKET_SPAWN_PAINTING: HANDLE_SERVER_READ(HandleServerSpawnPainting); break;
- case PACKET_SPAWN_PICKUP: HANDLE_SERVER_READ(HandleServerSpawnPickup); break;
- case PACKET_TIME_UPDATE: HANDLE_SERVER_READ(HandleServerTimeUpdate); break;
- case PACKET_UPDATE_HEALTH: HANDLE_SERVER_READ(HandleServerUpdateHealth); break;
- case PACKET_UPDATE_SIGN: HANDLE_SERVER_READ(HandleServerUpdateSign); break;
- case PACKET_UPDATE_TILE_ENTITY: HANDLE_SERVER_READ(HandleServerUpdateTileEntity); break;
- case PACKET_WINDOW_CLOSE: HANDLE_SERVER_READ(HandleServerWindowClose); break;
- case PACKET_WINDOW_CONTENTS: HANDLE_SERVER_READ(HandleServerWindowContents); break;
- case PACKET_WINDOW_OPEN: HANDLE_SERVER_READ(HandleServerWindowOpen); break;
- default:
- {
- if (m_ServerState == csEncryptedUnderstood)
- {
- Log("********************** Unknown packet 0x%02x from the server while encrypted; continuing to relay blind only", PacketType);
- AString Data;
- m_ServerBuffer.ResetRead();
- m_ServerBuffer.ReadAll(Data);
- DataLog(Data.data(), Data.size(), "Current data in the server packet queue: %d bytes", Data.size());
- m_ServerState = csEncryptedUnknown;
- m_ServerBuffer.ResetRead();
- if (m_ClientState == csUnencrypted)
- {
- CLIENTSEND(m_ServerBuffer);
- }
- else
- {
- CLIENTENCRYPTSEND(m_ServerBuffer);
- }
- return true;
- }
- else
- {
- Log("Unknown packet 0x%02x from the server while unencrypted; aborting connection", PacketType);
- return false;
- }
- }
- } // switch (PacketType)
- m_ServerBuffer.CommitRead();
- } // while (CanReadBytes(1))
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientAnimation(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, Animation);
- Log("Received a PACKET_ANIMATION from the client:");
- Log(" EntityID: %d", EntityID);
- Log(" Animation: %d", Animation);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientBlockDig(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, Status);
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockX);
- HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, BlockY);
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockZ);
- HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, BlockFace);
- Log("Received a PACKET_BLOCK_DIG from the client:");
- Log(" Status = %d", Status);
- Log(" Pos = <%d, %d, %d>", BlockX, BlockY, BlockZ);
- Log(" BlockFace = %d", BlockFace);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientBlockPlace(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockX);
- HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, BlockY);
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockZ);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, Face);
- AString Desc;
- if (!ParseSlot(m_ClientBuffer, Desc))
- {
- return false;
- }
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, CursorX);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, CursorY);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, CursorZ);
- Log("Received a PACKET_BLOCK_PLACE from the client:");
- Log(" Block = {%d, %d, %d}", BlockX, BlockY, BlockZ);
- Log(" Face = %d", Face);
- Log(" Item = %s", Desc.c_str());
- Log(" Cursor = <%d, %d, %d>", CursorX, CursorY, CursorZ);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientChatMessage(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Message);
- Log("Received a PACKET_CHAT_MESSAGE from the client:");
- Log(" Message = \"%s\"", Message.c_str());
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientClientStatuses(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, Statuses);
- Log("Received a PACKET_CLIENT_STATUSES from the CLIENT:");
- Log(" Statuses = %d", Statuses);
-
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientCreativeInventoryAction(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, SlotNum);
- AString Item;
- if (!ParseSlot(m_ClientBuffer, Item))
- {
- return false;
- }
- Log("Received a PACKET_CREATIVE_INVENTORY_ACTION from the client:");
- Log(" SlotNum = %d", SlotNum);
- Log(" Item = %s", Item.c_str());
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientEncryptionKeyResponse(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, EncKeyLength);
- AString EncKey;
- if (!m_ClientBuffer.ReadString(EncKey, EncKeyLength))
- {
- return true;
- }
- HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, EncNonceLength);
- AString EncNonce;
- if (!m_ClientBuffer.ReadString(EncNonce, EncNonceLength))
- {
- return true;
- }
- if ((EncKeyLength > MAX_ENC_LEN) || (EncNonceLength > MAX_ENC_LEN))
- {
- Log("Client: Too long encryption params");
- return true;
- }
- StartClientEncryption(EncKey, EncNonce);
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientEntityAction(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, PlayerID);
- HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, ActionType);
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, UnknownHorseVal);
- Log("Received a PACKET_ENTITY_ACTION from the client:");
- Log(" PlayerID = %d", PlayerID);
- Log(" ActionType = %d", ActionType);
- Log(" UnknownHorseVal = %d (0x%08x)", UnknownHorseVal, UnknownHorseVal);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientHandshake(void)
-{
- // Read the packet from the client:
- HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, ProtocolVersion);
- HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Username);
- HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, ServerHost);
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, ServerPort);
- m_ClientBuffer.CommitRead();
-
- Log("Received a PACKET_HANDSHAKE from the client:");
- Log(" ProtocolVersion = %d", ProtocolVersion);
- Log(" Username = \"%s\"", Username.c_str());
- Log(" ServerHost = \"%s\"", ServerHost.c_str());
- Log(" ServerPort = %d", ServerPort);
-
- // Send the same packet to the server, but with our port:
- cByteBuffer ToServer(512);
- ToServer.WriteByte (PACKET_HANDSHAKE);
- ToServer.WriteByte (ProtocolVersion);
- ToServer.WriteBEUTF16String16(Username);
- ToServer.WriteBEUTF16String16(ServerHost);
- ToServer.WriteBEInt (m_Server.GetConnectPort());
- SERVERSEND(ToServer);
-
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientKeepAlive(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, ID);
- Log("Received a PACKET_KEEPALIVE from the client");
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientLocaleAndView(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Locale);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, ViewDistance);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, ChatFlags);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, Difficulty);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, ShowCape);
- Log("Received a PACKET_LOCALE_AND_VIEW from the client");
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientPing(void)
-{
- m_HasClientPinged = true;
- Log("Received a PACKET_PING from the client");
- m_ClientBuffer.ResetRead();
- SERVERSEND(m_ClientBuffer);
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientPlayerAbilities(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, Flags);
- HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, FlyingSpeed);
- HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, WalkingSpeed);
- Log("Receives a PACKET_PLAYER_ABILITIES from the client:");
- Log(" Flags = %d (0x%02x)", Flags, Flags);
- Log(" FlyingSpeed = %f", FlyingSpeed);
- Log(" WalkingSpeed = %f", WalkingSpeed);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientPlayerLook(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, Yaw);
- HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, Pitch);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, OnGround);
- Log("Received a PACKET_PLAYER_LOOK from the client");
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientPlayerOnGround(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, OnGround);
- Log("Received a PACKET_PLAYER_ON_GROUND from the client");
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientPlayerPosition(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosX);
- HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, Stance);
- HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosY);
- HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosZ);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, IsOnGround);
- Log("Received a PACKET_PLAYER_POSITION from the client");
-
- // TODO: list packet contents
-
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientPlayerPositionLook(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosX);
- HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, Stance);
- HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosY);
- HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosZ);
- HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, Yaw);
- HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, Pitch);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, IsOnGround);
- Log("Received a PACKET_PLAYER_POSITION_LOOK from the client");
- Log(" Pos = {%.03f, %.03f, %.03f}", PosX, PosY, PosZ);
- Log(" Stance = %.03f", Stance);
- Log(" Y, P = %.03f, %.03f", Yaw, Pitch);
- Log(" IsOnGround = %s", IsOnGround ? "true" : "false");
-
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientPluginMessage(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, ChannelName);
- HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, Length);
- AString Data;
- if (!m_ClientBuffer.ReadString(Data, Length))
- {
- return false;
- }
- Log("Received a PACKET_PLUGIN_MESSAGE from the client");
- Log(" ChannelName = \"%s\"", ChannelName.c_str());
- DataLog(Data.data(), Length, " Data: %d bytes", Length);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientSlotSelect(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, SlotNum);
- Log("Received a PACKET_SLOT_SELECT from the client");
- Log(" SlotNum = %d", SlotNum);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientUpdateSign(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockX);
- HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, BlockY);
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockZ);
- HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Line1);
- HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Line2);
- HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Line3);
- HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Line4);
- Log("Received a PACKET_UPDATE_SIGN from the client:");
- Log(" Block = {%d, %d, %d}", BlockX, BlockY, BlockZ);
- Log(" Lines = \"%s\", \"%s\", \"%s\", \"%s\"", Line1.c_str(), Line2.c_str(), Line3.c_str(), Line4.c_str());
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientUseEntity(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, PlayerID);
- HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, MouseButton);
- Log("Received a PACKET_USE_ENTITY from the client:");
- Log(" PlayerID = %d", PlayerID);
- Log(" EntityID = %d", EntityID);
- Log(" MouseButton = %d", MouseButton);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientWindowClick(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, WindowID);
- HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, SlotNum);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, IsRightClick);
- HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, TransactionID);
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, IsShiftClick);
- AString Item;
- if (!ParseSlot(m_ClientBuffer, Item))
- {
- return false;
- }
- Log("Received a PACKET_WINDOW_CLICK from the client");
- Log(" WindowID = %d", WindowID);
- Log(" SlotNum = %d", SlotNum);
- Log(" IsRclk = %d, IsShift = %d", IsRightClick, IsShiftClick);
- Log(" TransactionID = 0x%x", TransactionID);
- Log(" ClickedItem = %s", Item.c_str());
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleClientWindowClose(void)
-{
- HANDLE_CLIENT_PACKET_READ(ReadChar, char, WindowID);
- Log("Received a PACKET_WINDOW_CLOSE from the client:");
- Log(" WindowID = %d", WindowID);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerAttachEntity(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, VehicleID);
- HANDLE_SERVER_PACKET_READ(ReadBool, bool, Leash);
- Log("Received a PACKET_ATTACH_ENTITY from the server:");
- Log(" EntityID = %d (0x%x)", EntityID, EntityID);
- Log(" VehicleID = %d (0x%x)", VehicleID, VehicleID);
- Log(" Leash = %s", Leash ? "true" : "false");
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerBlockAction(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Byte1);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Byte2);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockID);
- Log("Received a PACKET_BLOCK_ACTION from the server:");
- Log(" Pos = {%d, %d, %d}", BlockX, BlockY, BlockZ);
- Log(" Bytes = (%d, %d) == (0x%x, 0x%x)", Byte1, Byte2, Byte1, Byte2);
- Log(" BlockID = %d", BlockID);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerBlockChange(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, BlockY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockType);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, BlockMeta);
- Log("Received a PACKET_BLOCK_CHANGE from the server");
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerChangeGameState(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadChar, char, Reason);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, Data);
- Log("Received a PACKET_CHANGE_GAME_STATE from the server:");
- Log(" Reason = %d", Reason);
- Log(" Data = %d", Data);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerChatMessage(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Message);
- Log("Received a PACKET_CHAT_MESSAGE from the server:");
- Log(" Message = \"%s\"", Message.c_str());
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerCollectPickup(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, CollectedID);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, CollectorID);
- Log("Received a PACKET_COLLECT_PICKUP from the server:");
- Log(" CollectedID = %d", CollectedID);
- Log(" CollectorID = %d", CollectorID);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerCompass(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, SpawnX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, SpawnY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, SpawnZ);
- Log("Received PACKET_COMPASS from the server:");
- Log(" Spawn = {%d, %d, %d}", SpawnX, SpawnY, SpawnZ);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerDestroyEntities(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, NumEntities);
- if (!m_ServerBuffer.SkipRead((int)NumEntities * 4))
- {
- return false;
- }
- Log("Received PACKET_DESTROY_ENTITIES from the server:");
- Log(" NumEntities = %d", NumEntities);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEncryptionKeyRequest(void)
-{
- // Read the packet from the server:
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, ServerID);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, PublicKeyLength);
- AString PublicKey;
- if (!m_ServerBuffer.ReadString(PublicKey, PublicKeyLength))
- {
- return false;
- }
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, NonceLength);
- AString Nonce;
- if (!m_ServerBuffer.ReadString(Nonce, NonceLength))
- {
- return false;
- }
- Log("Got PACKET_ENCRYPTION_KEY_REQUEST from the SERVER:");
- Log(" ServerID = %s", ServerID.c_str());
-
- // Reply to the server:
- SendEncryptionKeyResponse(PublicKey, Nonce);
-
- // Send a 0xFD Encryption Key Request http://wiki.vg/Protocol#0xFD to the client, using our own key:
- Log("Sending PACKET_ENCRYPTION_KEY_REQUEST to the CLIENT");
- AString key;
- StringSink sink(key); // GCC won't allow inline instantiation in the following line, damned temporary refs
- m_Server.GetPublicKey().Save(sink);
- cByteBuffer ToClient(512);
- ToClient.WriteByte (PACKET_ENCRYPTION_KEY_REQUEST);
- ToClient.WriteBEUTF16String16(ServerID);
- ToClient.WriteBEShort ((short)key.size());
- ToClient.WriteBuf (key.data(), key.size());
- ToClient.WriteBEShort (4);
- ToClient.WriteBEInt (m_Nonce); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
- CLIENTSEND(ToClient);
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntity(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- Log("Received a PACKET_ENTITY from the server:");
- Log(" EntityID = %d", EntityID);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityEquipment(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SlotNum);
- AString Item;
- if (!ParseSlot(m_ServerBuffer, Item))
- {
- return false;
- }
- Log("Received a PACKET_ENTITY_EQUIPMENT from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" SlotNum = %d", SlotNum);
- Log(" Item = %s", Item.c_str());
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityHeadLook(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, HeadYaw);
- Log("Received a PACKET_ENTITY_HEAD_LOOK from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" HeadYaw = %d", HeadYaw);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityLook(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
- Log("Received a PACKET_ENTITY_LOOK from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" Yaw = %d", Yaw);
- Log(" Pitch = %d", Pitch);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityMetadata(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- AString Metadata;
- if (!ParseMetadata(m_ServerBuffer, Metadata))
- {
- return false;
- }
- AString HexDump;
- CreateHexDump(HexDump, Metadata.data(), Metadata.size(), 32);
- Log("Received a PACKET_ENTITY_METADATA from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" Metadata, length = %d (0x%x):\n%s", Metadata.length(), Metadata.length(), HexDump.c_str());
- LogMetadata(Metadata, 4);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityProperties(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Count);
- Log("Received a PACKET_ENTITY_PROPERTIES from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" Count = %d", Count);
-
- for (int i = 0; i < Count; i++)
- {
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Key);
- HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, Value);
- Log(" \"%s\" = %f", Key.c_str(), Value);
- } // for i
-
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, ListLength);
- Log(" ListLength = %d", ListLength);
- for (int i = 0; i < ListLength; i++)
- {
- HANDLE_SERVER_PACKET_READ(ReadBEInt64, Int64, UUIDHi);
- HANDLE_SERVER_PACKET_READ(ReadBEInt64, Int64, UUIDLo);
- HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, DblVal);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, ByteVal);
- Log(" [%d] = {0x%08llx%08llx, %f, %i}", i, UUIDHi, UUIDLo, DblVal, ByteVal);
- } // for i
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityRelativeMove(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dx);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dy);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dz);
- Log("Received a PACKET_ENTITY_RELATIVE_MOVE from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" RelMove = <%d, %d, %d>", dx, dy, dz);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityRelativeMoveLook(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dx);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dy);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dz);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
- Log("Received a PACKET_ENTITY_RELATIVE_MOVE_LOOK from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" RelMove = <%d, %d, %d>", dx, dy, dz);
- Log(" Yaw = %d", Yaw);
- Log(" Pitch = %d", Pitch);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityStatus(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Status);
- Log("Received a PACKET_ENTITY_STATUS from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" Status = %d", Status);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityTeleport(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
- Log("Received a PACKET_ENTITY_TELEPORT from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" Pos = {%d, %d, %d}", BlockX, BlockY, BlockZ);
- Log(" Yaw = %d", Yaw);
- Log(" Pitch = %d", Pitch);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEntityVelocity(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityX);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityY);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityZ);
- Log("Received a PACKET_ENTITY_VELOCITY from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" Velocity = <%d, %d, %d>", VelocityX, VelocityY, VelocityZ);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerIncrementStatistic(void)
-{
- // 0xc8
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, StatisticID);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Amount);
- Log("Received a PACKET_INCREMENT_STATISTIC from the server:");
- Log(" StatisticID = %d (0x%x)", StatisticID, StatisticID);
- Log(" Amount = %d", Amount);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerKeepAlive(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PingID);
- Log("Received a PACKET_KEEP_ALIVE from the server:");
- Log(" ID = %d", PingID);
- COPY_TO_CLIENT()
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerEncryptionKeyResponse(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Lengths);
- if (Lengths != 0)
- {
- Log("Lengths are not zero!");
- return true;
- }
- Log("Server communication is now encrypted");
- m_ServerState = csEncryptedUnderstood;
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerKick(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Reason);
- Log("Received PACKET_KICK from the SERVER:");
- if (m_HasClientPinged)
- {
- Log(" This was a std reply to client's PING");
- AStringVector Split;
-
- // Split by NULL chars (StringSplit() won't work here):
- size_t Last = 0;
- for (size_t i = 0; i < Reason.size(); i++)
- {
- if (Reason[i] == 0)
- {
- Split.push_back(Reason.substr(Last, i - Last));
- Last = i + 1;
- }
- }
-
- if (Split.size() == 5)
- {
- Log(" Protocol version: \"%s\"", Split[0].c_str());
- Log(" Server version: \"%s\"", Split[1].c_str());
- Log(" MOTD: \"%s\"", Split[2].c_str());
- Log(" Cur players: \"%s\"", Split[3].c_str());
- Log(" Max players: \"%s\"", Split[4].c_str());
- }
- else
- {
- DataLog(Reason.data(), Reason.size(), " Unknown reply format, dumping hex:");
- }
- }
- else
- {
- Log(" Reason = \"%s\"", Reason.c_str());
- }
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerLogin(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, LevelType);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, GameMode);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, Dimension);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, Difficulty);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, Unused);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, MaxPlayers);
- Log("Received a PACKET_LOGIN from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" LevelType = \"%s\"", LevelType.c_str());
- Log(" GameMode = %d", GameMode);
- Log(" Dimension = %d", Dimension);
- Log(" Difficulty = %d", Difficulty);
- Log(" Unused = %d", Unused);
- Log(" MaxPlayers = %d", MaxPlayers);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerMapChunk(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkZ);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, IsContiguous);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, PrimaryBitmap);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, AdditionalBitmap);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, CompressedSize);
- AString CompressedData;
- if (!m_ServerBuffer.ReadString(CompressedData, CompressedSize))
- {
- return false;
- }
- Log("Received a PACKET_MAP_CHUNK from the server:");
- Log(" ChunkPos = [%d, %d]", ChunkX, ChunkZ);
- Log(" Compressed size = %d (0x%x)", CompressedSize, CompressedSize);
-
- // TODO: Save the compressed data into a file for later analysis
-
- COPY_TO_CLIENT()
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerMapChunkBulk(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, ChunkCount);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, CompressedSize);
- HANDLE_SERVER_PACKET_READ(ReadBool, bool, IsSkyLightSent);
- AString CompressedData;
- if (!m_ServerBuffer.ReadString(CompressedData, CompressedSize))
- {
- return false;
- }
- AString Meta;
- if (!m_ServerBuffer.ReadString(Meta, ChunkCount * 12))
- {
- return false;
- }
- Log("Received a PACKET_MAP_CHUNK_BULK from the server:");
- Log(" ChunkCount = %d", ChunkCount);
- Log(" Compressed size = %d (0x%x)", CompressedSize, CompressedSize);
- Log(" IsSkyLightSent = %s", IsSkyLightSent ? "true" : "false");
-
- // TODO: Save the compressed data into a file for later analysis
-
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerMultiBlockChange(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkZ);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, NumBlocks);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, DataSize);
- AString BlockChangeData;
- if (!m_ServerBuffer.ReadString(BlockChangeData, DataSize))
- {
- return false;
- }
- Log("Received a PACKET_MULTI_BLOCK_CHANGE packet from the server:");
- Log(" Chunk = [%d, %d]", ChunkX, ChunkZ);
- Log(" NumBlocks = %d", NumBlocks);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerNamedSoundEffect(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, SoundName);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Volume);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
- Log("Received a PACKET_NAMED_SOUND_EFFECT from the server:");
- Log(" SoundName = \"%s\"", SoundName.c_str());
- Log(" Pos = (%d, %d, %d) ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 8, PosY / 8, PosZ / 8);
- Log(" Volume = %f", Volume);
- Log(" Pitch = %d", Pitch);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerPlayerAbilities(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadChar, char, Flags);
- HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, FlyingSpeed);
- HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, WalkingSpeed);
- Log("Received a PACKET_PLAYER_ABILITIES from the server:");
- Log(" Flags = %d (0x%02x)", Flags, Flags);
- Log(" FlyingSpeed = %f", FlyingSpeed);
- Log(" WalkingSpeed = %f", WalkingSpeed);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerPlayerAnimation(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PlayerID);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, AnimationID);
- Log("Received a PACKET_PLAYER_ANIMATION from the server:");
- Log(" PlayerID: %d (0x%x)", PlayerID, PlayerID);
- Log(" Animation: %d", AnimationID);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerPlayerListItem(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, PlayerName);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, IsOnline);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, Ping);
- Log("Received a PACKET_PLAYERLIST_ITEM from the server:");
- Log(" PlayerName = \"%s\"", PlayerName.c_str());
- Log(" Ping = %d", Ping);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerPlayerPositionLook(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosX);
- HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, Stance);
- HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosY);
- HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosZ);
- HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Yaw);
- HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Pitch);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, IsOnGround);
- Log("Received a PACKET_PLAYER_POSITION_LOOK from the server");
-
- // TODO: list packet contents
-
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerPluginMessage(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, ChannelName);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, Length);
- AString Data;
- if (!m_ServerBuffer.ReadString(Data, Length))
- {
- return false;
- }
- Log("Received a PACKET_PLUGIN_MESSAGE from the server");
- Log(" ChannelName = \"%s\"", ChannelName.c_str());
- DataLog(Data.data(), Length, " Data: %d bytes", Length);
- COPY_TO_SERVER();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerSetExperience(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, ExperienceBar);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, Level);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, TotalExperience);
- Log("Received a PACKET_SET_EXPERIENCE from the server:");
- Log(" ExperienceBar = %.05f", ExperienceBar);
- Log(" Level = %d", Level);
- Log(" TotalExperience = %d", TotalExperience);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerSetSlot(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowID);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SlotNum);
- AString Item;
- if (!ParseSlot(m_ServerBuffer, Item))
- {
- return false;
- }
- Log("Received a PACKET_SET_SLOT from the server:");
- Log(" WindowID = %d", WindowID);
- Log(" SlotNum = %d", SlotNum);
- Log(" Item = %s", Item.c_str());
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerSlotSelect(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SlotNum);
- Log("Received a PACKET_SLOT_SELECT from the server:");
- Log(" SlotNum = %d", SlotNum);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerSoundEffect(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EffectID);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, PosY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Data);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, NoVolumeDecrease);
- Log("Received a PACKET_SOUND_EFFECT from the server:");
- Log(" EffectID = %d", EffectID);
- Log(" Pos = {%d, %d, %d}", PosX, PosY, PosZ);
- Log(" Data = %d", Data);
- Log(" NoVolumeDecrease = %d", NoVolumeDecrease);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerSpawnMob(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, MobType);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, HeadYaw);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityX);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityY);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityZ);
- AString Metadata;
- if (!ParseMetadata(m_ServerBuffer, Metadata))
- {
- return false;
- }
- AString HexDump;
- CreateHexDump(HexDump, Metadata.data(), Metadata.size(), 32);
- Log("Received a PACKET_SPAWN_MOB from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" MobType = %d", MobType);
- Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
- Log(" Angles = [%d, %d, %d]", Yaw, Pitch, HeadYaw);
- Log(" Velocity = <%d, %d, %d>", VelocityX, VelocityY, VelocityZ);
- Log(" Metadata, length = %d (0x%x):\n%s", Metadata.length(), Metadata.length(), HexDump.c_str());
- LogMetadata(Metadata, 4);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerSpawnNamedEntity(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, EntityName);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, CurrentItem);
- AString Metadata;
- if (!ParseMetadata(m_ServerBuffer, Metadata))
- {
- return false;
- }
- AString HexDump;
- CreateHexDump(HexDump, Metadata.data(), Metadata.size(), 32);
- Log("Received a PACKET_SPAWN_NAMED_ENTITY from the server:");
- Log(" EntityID = %d (0x%x)", EntityID, EntityID);
- Log(" Name = %s", EntityName.c_str());
- Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
- Log(" Rotation = <yaw %d, pitch %d>", Yaw, Pitch);
- Log(" CurrentItem = %d", CurrentItem);
- Log(" Metadata, length = %d (0x%x):\n%s", Metadata.length(), Metadata.length(), HexDump.c_str());
- LogMetadata(Metadata, 4);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerSpawnObjectVehicle(void)
-{
- #ifdef _DEBUG
- // DEBUG:
- // This packet is still troublesome when DataIndicator != 0
- AString Buffer;
- m_ServerBuffer.ResetRead();
- m_ServerBuffer.ReadAll(Buffer);
- m_ServerBuffer.ResetRead();
- m_ServerBuffer.SkipRead(1);
- if (Buffer.size() > 128)
- {
- // Only log up to 128 bytes
- Buffer.erase(128, AString::npos);
- }
- DataLog(Buffer.data(), Buffer.size(), "Buffer while parsing the PACKET_SPAWN_OBJECT_VEHICLE packet (%d bytes):", Buffer.size());
- #endif // _DEBUG
-
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, ObjType);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, DataIndicator);
- AString ExtraData;
- short VelocityX, VelocityY, VelocityZ;
- if (DataIndicator != 0)
- {
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SpeedX);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SpeedY);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SpeedZ);
- VelocityX = SpeedX; VelocityY = SpeedY; VelocityZ = SpeedZ; // Speed vars are local to this scope, but we need them available later
- /*
- // This doesn't seem to work - for a falling block I'm getting no extra data at all
- int ExtraLen = 0;
- switch (ObjType)
- {
- case OBJECT_FALLING_BLOCK: ExtraLen = 4; break; // int: BlockType | (BlockMeta << 12)
- case OBJECT_ARROW:
- case OBJECT_SNOWBALL:
- case OBJECT_EGG:
- case OBJECT_EYE_OF_ENDER:
- case OBJECT_DRAGON_EGG:
- case OBJECT_FISHING_FLOAT:
- {
- ExtraLen = 4; break; // int: EntityID of the thrower
- }
- // TODO: Splash potions
- }
- if ((ExtraLen > 0) && !m_ServerBuffer.ReadString(ExtraData, ExtraLen))
- {
- return false;
- }
- */
- }
- Log("Received a PACKET_SPAWN_OBJECT_VEHICLE from the server:");
- Log(" EntityID = %d (0x%x)", EntityID, EntityID);
- Log(" ObjType = %d (0x%x)", ObjType, ObjType);
- Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
- Log(" Rotation = <yaw %d, pitch %d>", Yaw, Pitch);
- Log(" DataIndicator = %d (0x%x)", DataIndicator, DataIndicator);
- if (DataIndicator != 0)
- {
- Log(" Velocity = <%d, %d, %d>", VelocityX, VelocityY, VelocityZ);
- DataLog(ExtraData.data(), ExtraData.size(), " ExtraData size = %d:", ExtraData.size());
- }
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerSpawnPainting(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, ImageName);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Direction);
- Log("Received a PACKET_SPAWN_PAINTING from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" ImageName = \"%s\"", ImageName.c_str());
- Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
- Log(" Direction = %d", Direction);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerSpawnPickup(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
- AString ItemDesc;
- if (!ParseSlot(m_ServerBuffer, ItemDesc))
- {
- return false;
- }
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Rotation);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Roll);
- Log("Received a PACKET_SPAWN_PICKUP from the server:");
- Log(" EntityID = %d", EntityID);
- Log(" Item = %s", ItemDesc.c_str());
- Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
- Log(" Angles = [%d, %d, %d]", Rotation, Pitch, Roll);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerTimeUpdate(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt64, Int64, WorldAge);
- HANDLE_SERVER_PACKET_READ(ReadBEInt64, Int64, TimeOfDay);
- Log("Received a PACKET_TIME_UPDATE from the server");
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerUpdateHealth(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Health);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, Food);
- HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Saturation);
- Log("Received a PACKET_UPDATE_HEALTH from the server");
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerUpdateSign(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Line1);
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Line2);
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Line3);
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Line4);
- Log("Received a PACKET_UPDATE_SIGN from the server:");
- Log(" Block = {%d, %d, %d}", BlockX, BlockY, BlockZ);
- Log(" Lines = \"%s\", \"%s\", \"%s\", \"%s\"", Line1.c_str(), Line2.c_str(), Line3.c_str(), Line4.c_str());
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerUpdateTileEntity(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockY);
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Action);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, DataLength);
- AString Data;
- if ((DataLength > 0) && !m_ServerBuffer.ReadString(Data, DataLength))
- {
- return false;
- }
- Log("Received a PACKET_UPDATE_TILE_ENTITY from the server:");
- Log(" Block = {%d, %d, %d}", BlockX, BlockY, BlockZ);
- Log(" Action = %d", Action);
- DataLog(Data.data(), Data.size(), " Data (%d bytes)", Data.size());
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerWindowClose(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowID);
- Log("Received a PACKET_WINDOW_CLOSE from the server:");
- Log(" WindowID = %d", WindowID);
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerWindowContents(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowID);
- HANDLE_SERVER_PACKET_READ(ReadBEShort, short, NumSlots);
- Log("Received a PACKET_WINDOW_CONTENTS from the server:");
- Log(" WindowID = %d", WindowID);
- Log(" NumSlots = %d", NumSlots);
- AStringVector Items;
- for (short i = 0; i < NumSlots; i++)
- {
- AString Item;
- if (!ParseSlot(m_ServerBuffer, Item))
- {
- return false;
- }
- Log(" %d: %s", i, Item.c_str());
- }
-
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::HandleServerWindowOpen(void)
-{
- HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowID);
- HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowType);
- HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Title);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, NumSlots);
- HANDLE_SERVER_PACKET_READ(ReadByte, Byte, UseProvidedTitle);
- int HorseInt = 0;
- if (WindowType == 11) // Horse / Donkey / Mule
- {
- HANDLE_SERVER_PACKET_READ(ReadBEInt, int, intHorseInt);
- HorseInt = intHorseInt;
- }
- Log("Received a PACKET_WINDOW_OPEN from the server:");
- Log(" WindowID = %d", WindowID);
- Log(" WindowType = %d", WindowType);
- Log(" Title = \"%s\", Use = %d", Title.c_str(), UseProvidedTitle);
- Log(" NumSlots = %d", NumSlots);
- if (WindowType == 11)
- {
- Log(" HorseInt = %d (0x%08x)", HorseInt, HorseInt);
- }
- COPY_TO_CLIENT();
- return true;
-}
-
-
-
-
-
-bool cConnection::ParseSlot(cByteBuffer & a_Buffer, AString & a_ItemDesc)
-{
- short ItemType;
- if (!a_Buffer.ReadBEShort(ItemType))
- {
- return false;
- }
- if (ItemType <= 0)
- {
- a_ItemDesc = "<empty>";
- return true;
- }
- if (!a_Buffer.CanReadBytes(5))
- {
- return false;
- }
- char ItemCount;
- short ItemDamage;
- short MetadataLength;
- a_Buffer.ReadChar(ItemCount);
- a_Buffer.ReadBEShort(ItemDamage);
- a_Buffer.ReadBEShort(MetadataLength);
- Printf(a_ItemDesc, "%d:%d * %d", ItemType, ItemDamage, ItemCount);
- if (MetadataLength <= 0)
- {
- return true;
- }
- AString Metadata;
- Metadata.resize(MetadataLength);
- if (!a_Buffer.ReadBuf((void *)Metadata.data(), MetadataLength))
- {
- return false;
- }
- AString MetaHex;
- CreateHexDump(MetaHex, Metadata.data(), Metadata.size(), 16);
- AppendPrintf(a_ItemDesc, "; %d bytes of meta:\n%s", MetadataLength, MetaHex.c_str());
-
- // Save metadata to a file:
- AString fnam;
- Printf(fnam, "%s_item_%08x.nbt", m_LogNameBase.c_str(), m_ItemIdx++);
- FILE * f = fopen(fnam.c_str(), "wb");
- if (f != NULL)
- {
- fwrite(Metadata.data(), 1, Metadata.size(), f);
- fclose(f);
- AppendPrintf(a_ItemDesc, "\n (saved to file \"%s\")", fnam.c_str());
- }
-
- return true;
-}
-
-
-
-
-
-bool cConnection::ParseMetadata(cByteBuffer & a_Buffer, AString & a_Metadata)
-{
- char x;
- if (!a_Buffer.ReadChar(x))
- {
- return false;
- }
- a_Metadata.push_back(x);
- while (x != 0x7f)
- {
- int Index = ((unsigned)((unsigned char)x)) & 0x1f; // Lower 5 bits = index
- int Type = ((unsigned)((unsigned char)x)) >> 5; // Upper 3 bits = type
- int Length = 0;
- switch (Type)
- {
- case 0: Length = 1; break; // byte
- case 1: Length = 2; break; // short
- case 2: Length = 4; break; // int
- case 3: Length = 4; break; // float
- case 4: // string16
- {
- short Len = 0;
- if (!a_Buffer.ReadBEShort(Len))
- {
- return false;
- }
- short NetLen = htons(Len);
- a_Metadata.append((char *)&NetLen, 2);
- Length = Len;
- break;
- }
- case 5:
- {
- int Before = a_Buffer.GetReadableSpace();
- AString ItemDesc;
- if (!ParseSlot(a_Buffer, ItemDesc))
- {
- return false;
- }
- int After = a_Buffer.GetReadableSpace();
- a_Buffer.ResetRead();
- a_Buffer.SkipRead(a_Buffer.GetReadableSpace() - Before);
- Length = Before - After;
- break;
- }
- case 6: Length = 12; break; // 3 * int
- default:
- {
- ASSERT(!"Unknown metadata type");
- break;
- }
- } // switch (Type)
- AString data;
- if (!a_Buffer.ReadString(data, Length))
- {
- return false;
- }
- a_Metadata.append(data);
- if (!a_Buffer.ReadChar(x))
- {
- return false;
- }
- a_Metadata.push_back(x);
- } // while (x != 0x7f)
- return true;
-}
-
-
-
-
-
-void cConnection::LogMetadata(const AString & a_Metadata, size_t a_IndentCount)
-{
- AString Indent(a_IndentCount, ' ');
- int pos = 0;
- while (a_Metadata[pos] != 0x7f)
- {
- int Index = ((unsigned)((unsigned char)a_Metadata[pos])) & 0x1f; // Lower 5 bits = index
- int Type = ((unsigned)((unsigned char)a_Metadata[pos])) >> 5; // Upper 3 bits = type
- int Length = 0;
- switch (Type)
- {
- case 0:
- {
- Log("%sbyte[%d] = %d", Indent.c_str(), Index, a_Metadata[pos + 1]);
- pos += 1;
- break;
- }
- case 1:
- {
- Log("%sshort[%d] = %d", Indent.c_str(), Index, (a_Metadata[pos + 1] << 8) | a_Metadata[pos + 2]);
- pos += 2;
- break;
- }
- case 2:
- {
- Log("%sint[%d] = %d", Indent.c_str(), Index, (a_Metadata[pos + 1] << 24) | (a_Metadata[pos + 2] << 16) | (a_Metadata[pos + 3] << 8) | a_Metadata[pos + 4]);
- pos += 4;
- break;
- }
- case 3:
- {
- Log("%sfloat[%d] = 0x%x", Indent.c_str(), Index, (a_Metadata[pos + 1] << 24) | (a_Metadata[pos + 2] << 16) | (a_Metadata[pos + 3] << 8) | a_Metadata[pos + 4]);
- pos += 4;
- break;
- }
- case 4: // string16
- {
- short Length = (a_Metadata[pos + 1] << 8) | a_Metadata[pos + 2];
- Log("%sstring[%d] = \"%*s\"", Indent.c_str(), Index, Length, a_Metadata.c_str() + pos + 3);
- pos += Length + 2;
- break;
- }
- case 5:
- {
- int BytesLeft = a_Metadata.size() - pos - 1;
- cByteBuffer bb(BytesLeft);
- bb.Write(a_Metadata.data() + pos + 1, BytesLeft);
- AString ItemDesc;
- if (!ParseSlot(bb, ItemDesc))
- {
- ASSERT(!"Cannot parse item description from metadata");
- return;
- }
- int After = bb.GetReadableSpace();
- int BytesConsumed = BytesLeft - bb.GetReadableSpace();
-
- Log("%sslot[%d] = %s (%d bytes)", Indent.c_str(), Index, ItemDesc.c_str(), BytesConsumed);
- pos += BytesConsumed;
- break;
- }
- case 6:
- {
- Log("%spos[%d] = <%d, %d, %d>", Indent.c_str(), Index,
- (a_Metadata[pos + 1] << 24) | (a_Metadata[pos + 2] << 16) | (a_Metadata[pos + 3] << 8) | a_Metadata[pos + 4],
- (a_Metadata[pos + 5] << 24) | (a_Metadata[pos + 6] << 16) | (a_Metadata[pos + 7] << 8) | a_Metadata[pos + 8],
- (a_Metadata[pos + 9] << 24) | (a_Metadata[pos + 10] << 16) | (a_Metadata[pos + 11] << 8) | a_Metadata[pos + 12]
- );
- pos += 12;
- break;
- }
- default:
- {
- ASSERT(!"Unknown metadata type");
- break;
- }
- } // switch (Type)
- pos += 1;
- } // while (x != 0x7f)
-}
-
-
-
-
-
-void cConnection::SendEncryptionKeyResponse(const AString & a_ServerPublicKey, const AString & a_Nonce)
-{
- // Generate the shared secret and encrypt using the server's public key
- byte SharedSecret[16];
- byte EncryptedSecret[128];
- memset(SharedSecret, 0, sizeof(SharedSecret)); // Use all zeroes for the initial secret
- RSA::PublicKey pk;
- CryptoPP::StringSource src(a_ServerPublicKey, true);
- ByteQueue bq;
- src.TransferTo(bq);
- bq.MessageEnd();
- pk.Load(bq);
- RSAES<PKCS1v15>::Encryptor rsaEncryptor(pk);
- RandomPool rng;
- time_t CurTime = time(NULL);
- rng.Put((const byte *)&CurTime, sizeof(CurTime));
- int EncryptedLength = rsaEncryptor.FixedCiphertextLength();
- ASSERT(EncryptedLength <= sizeof(EncryptedSecret));
- rsaEncryptor.Encrypt(rng, SharedSecret, sizeof(SharedSecret), EncryptedSecret);
- m_ServerEncryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
- m_ServerDecryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
-
- // Encrypt the nonce:
- byte EncryptedNonce[128];
- rsaEncryptor.Encrypt(rng, (const byte *)(a_Nonce.data()), a_Nonce.size(), EncryptedNonce);
-
- // Send the packet to the server:
- Log("Sending PACKET_ENCRYPTION_KEY_RESPONSE to the SERVER");
- cByteBuffer ToServer(1024);
- ToServer.WriteByte(PACKET_ENCRYPTION_KEY_RESPONSE);
- ToServer.WriteBEShort(EncryptedLength);
- ToServer.WriteBuf(EncryptedSecret, EncryptedLength);
- ToServer.WriteBEShort(EncryptedLength);
- ToServer.WriteBuf(EncryptedNonce, EncryptedLength);
- SERVERSEND(ToServer);
-}
-
-
-
-
-
-void cConnection::StartClientEncryption(const AString & a_EncKey, const AString & a_EncNonce)
-{
- // Decrypt EncNonce using privkey
- RSAES<PKCS1v15>::Decryptor rsaDecryptor(m_Server.GetPrivateKey());
- time_t CurTime = time(NULL);
- RandomPool rng;
- rng.Put((const byte *)&CurTime, sizeof(CurTime));
- byte DecryptedNonce[MAX_ENC_LEN];
- DecodingResult res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncNonce.data(), a_EncNonce.size(), DecryptedNonce);
- if (!res.isValidCoding || (res.messageLength != 4))
- {
- Log("Client: Bad nonce length");
- return;
- }
- if (ntohl(*((int *)DecryptedNonce)) != m_Nonce)
- {
- Log("Bad nonce value");
- return;
- }
-
- // Decrypt the symmetric encryption key using privkey:
- byte SharedSecret[MAX_ENC_LEN];
- res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncKey.data(), a_EncKey.size(), SharedSecret);
- if (!res.isValidCoding || (res.messageLength != 16))
- {
- Log("Bad key length");
- return;
- }
-
- // Send encryption key response:
- cByteBuffer ToClient(6);
- ToClient.WriteByte((char)0xfc);
- ToClient.WriteBEShort(0);
- ToClient.WriteBEShort(0);
- CLIENTSEND(ToClient);
-
- // Start the encryption:
- m_ClientEncryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
- m_ClientDecryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
- Log("Client connection is now encrypted");
- m_ClientState = csEncryptedUnderstood;
-
- // Handle all postponed server data
- DecodeServersPackets(NULL, 0);
-}
-
-
-
-
+
+// Connection.cpp
+
+// Interfaces to the cConnection class representing a single pair of connected sockets
+
+#include "Globals.h"
+#include "Connection.h"
+#include "Server.h"
+#include <iostream>
+
+
+
+
+
+#ifdef _DEBUG
+ #define DebugSleep Sleep
+#else
+ #define DebugSleep(X)
+#endif // else _DEBUG
+
+
+
+
+
+#define HANDLE_CLIENT_PACKET_READ(Proc, Type, Var) \
+ Type Var; \
+ { \
+ if (!m_ClientBuffer.Proc(Var)) \
+ { \
+ return false; \
+ } \
+ }
+
+#define HANDLE_SERVER_PACKET_READ(Proc, Type, Var) \
+ Type Var; \
+ { \
+ if (!m_ServerBuffer.Proc(Var)) \
+ { \
+ return false; \
+ } \
+ }
+
+#define CLIENTSEND(...) SendData(m_ClientSocket, __VA_ARGS__, "Client")
+#define SERVERSEND(...) SendData(m_ServerSocket, __VA_ARGS__, "Server")
+#define CLIENTENCRYPTSEND(...) SendEncryptedData(m_ClientSocket, m_ClientEncryptor, __VA_ARGS__, "Client")
+#define SERVERENCRYPTSEND(...) SendEncryptedData(m_ServerSocket, m_ServerEncryptor, __VA_ARGS__, "Server")
+
+#define COPY_TO_SERVER() \
+ { \
+ AString ToServer; \
+ m_ClientBuffer.ReadAgain(ToServer); \
+ switch (m_ServerState) \
+ { \
+ case csUnencrypted: \
+ { \
+ SERVERSEND(ToServer.data(), ToServer.size()); \
+ break; \
+ } \
+ case csEncryptedUnderstood: \
+ case csEncryptedUnknown: \
+ { \
+ SERVERENCRYPTSEND(ToServer.data(), ToServer.size()); \
+ break; \
+ } \
+ case csWaitingForEncryption: \
+ { \
+ Log("Waiting for server encryption, queued %u bytes", ToServer.size()); \
+ m_ServerEncryptionBuffer.append(ToServer.data(), ToServer.size()); \
+ break; \
+ } \
+ } \
+ DebugSleep(50); \
+ }
+
+#define COPY_TO_CLIENT() \
+ { \
+ AString ToClient; \
+ m_ServerBuffer.ReadAgain(ToClient); \
+ switch (m_ClientState) \
+ { \
+ case csUnencrypted: \
+ { \
+ CLIENTSEND(ToClient.data(), ToClient.size()); \
+ break; \
+ } \
+ case csEncryptedUnderstood: \
+ case csEncryptedUnknown: \
+ { \
+ CLIENTENCRYPTSEND(ToClient.data(), ToClient.size()); \
+ break; \
+ } \
+ case csWaitingForEncryption: \
+ { \
+ Log("Waiting for client encryption, queued %u bytes", ToClient.size()); \
+ m_ClientEncryptionBuffer.append(ToClient.data(), ToClient.size()); \
+ break; \
+ } \
+ } \
+ DebugSleep(50); \
+ }
+
+#define HANDLE_CLIENT_READ(Proc) \
+ { \
+ if (!Proc()) \
+ { \
+ AString Leftover; \
+ m_ClientBuffer.ReadAgain(Leftover); \
+ DataLog(Leftover.data(), Leftover.size(), "Leftover data after client packet parsing, %d bytes:", Leftover.size()); \
+ m_ClientBuffer.ResetRead(); \
+ return true; \
+ } \
+ }
+
+#define HANDLE_SERVER_READ(Proc) \
+ { \
+ if (!Proc()) \
+ { \
+ m_ServerBuffer.ResetRead(); \
+ return true; \
+ } \
+ }
+
+
+#define MAX_ENC_LEN 1024
+
+
+
+
+typedef unsigned char Byte;
+
+
+
+
+
+enum
+{
+ PACKET_KEEPALIVE = 0x00,
+ PACKET_LOGIN = 0x01,
+ PACKET_HANDSHAKE = 0x02,
+ PACKET_CHAT_MESSAGE = 0x03,
+ PACKET_TIME_UPDATE = 0x04,
+ PACKET_ENTITY_EQUIPMENT = 0x05,
+ PACKET_COMPASS = 0x06,
+ PACKET_USE_ENTITY = 0x07,
+ PACKET_UPDATE_HEALTH = 0x08,
+ PACKET_PLAYER_ON_GROUND = 0x0a,
+ PACKET_PLAYER_POSITION = 0x0b,
+ PACKET_PLAYER_LOOK = 0x0c,
+ PACKET_PLAYER_POSITION_LOOK = 0x0d,
+ PACKET_BLOCK_DIG = 0x0e,
+ PACKET_BLOCK_PLACE = 0x0f,
+ PACKET_SLOT_SELECT = 0x10,
+ PACKET_PLAYER_ANIMATION = 0x12,
+ PACKET_ENTITY_ACTION = 0x13,
+ PACKET_SPAWN_NAMED_ENTITY = 0x14,
+ PACKET_SPAWN_PICKUP = 0x15,
+ PACKET_COLLECT_PICKUP = 0x16,
+ PACKET_SPAWN_OBJECT_VEHICLE = 0x17,
+ PACKET_SPAWN_MOB = 0x18,
+ PACKET_SPAWN_PAINTING = 0x19,
+ PACKET_SPAWN_EXPERIENCE_ORB = 0x1a,
+ PACKET_ENTITY_VELOCITY = 0x1c,
+ PACKET_DESTROY_ENTITIES = 0x1d,
+ PACKET_ENTITY = 0x1e,
+ PACKET_ENTITY_RELATIVE_MOVE = 0x1f,
+ PACKET_ENTITY_LOOK = 0x20,
+ PACKET_ENTITY_RELATIVE_MOVE_LOOK = 0x21,
+ PACKET_ENTITY_TELEPORT = 0x22,
+ PACKET_ENTITY_HEAD_LOOK = 0x23,
+ PACKET_ENTITY_STATUS = 0x26,
+ PACKET_ATTACH_ENTITY = 0x27,
+ PACKET_ENTITY_METADATA = 0x28,
+ PACKET_ENTITY_EFFECT = 0x29,
+ PACKET_ENTITY_EFFECT_REMOVE = 0x2a,
+ PACKET_SET_EXPERIENCE = 0x2b,
+ PACKET_ENTITY_PROPERTIES = 0x2c,
+ PACKET_MAP_CHUNK = 0x33,
+ PACKET_MULTI_BLOCK_CHANGE = 0x34,
+ PACKET_BLOCK_CHANGE = 0x35,
+ PACKET_BLOCK_ACTION = 0x36,
+ PACKET_MAP_CHUNK_BULK = 0x38,
+ PACKET_SOUND_EFFECT = 0x3d,
+ PACKET_NAMED_SOUND_EFFECT = 0x3e,
+ PACKET_CHANGE_GAME_STATE = 0x46,
+ PACKET_WINDOW_OPEN = 0x64,
+ PACKET_WINDOW_CLOSE = 0x65,
+ PACKET_WINDOW_CLICK = 0x66,
+ PACKET_SET_SLOT = 0x67,
+ PACKET_WINDOW_CONTENTS = 0x68,
+ PACKET_CREATIVE_INVENTORY_ACTION = 0x6b,
+ PACKET_UPDATE_SIGN = 0x82,
+ PACKET_UPDATE_TILE_ENTITY = 0x84,
+ PACKET_PLAYER_LIST_ITEM = 0xc9,
+ PACKET_PLAYER_ABILITIES = 0xca,
+ PACKET_INCREMENT_STATISTIC = 0xc8,
+ PACKET_LOCALE_AND_VIEW = 0xcc,
+ PACKET_CLIENT_STATUSES = 0xcd,
+ PACKET_PLUGIN_MESSAGE = 0xfa,
+ PACKET_ENCRYPTION_KEY_RESPONSE = 0xfc,
+ PACKET_ENCRYPTION_KEY_REQUEST = 0xfd,
+ PACKET_PING = 0xfe,
+ PACKET_KICK = 0xff,
+} ;
+
+
+
+
+enum
+{
+ OBJECT_BOAT = 1,
+ OBJECT_MINECART = 10,
+ OBJECT_MINECART_STORAGE = 11,
+ OBJECT_MINECART_POWERED = 12,
+ OBJECT_TNT = 50,
+ OBJECT_ENDERCRYSTAL = 51,
+ OBJECT_ARROW = 60,
+ OBJECT_SNOWBALL = 61,
+ OBJECT_EGG = 62,
+ OBJECT_FALLING_BLOCK = 70,
+ OBJECT_EYE_OF_ENDER = 72,
+ OBJECT_DRAGON_EGG = 74,
+ OBJECT_FISHING_FLOAT = 90,
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cConnection:
+
+cConnection::cConnection(SOCKET a_ClientSocket, cServer & a_Server) :
+ m_ItemIdx(0),
+ m_LogFile(NULL),
+ m_Server(a_Server),
+ m_ClientSocket(a_ClientSocket),
+ m_ServerSocket(-1),
+ m_BeginTick(clock()),
+ m_ClientState(csUnencrypted),
+ m_ServerState(csUnencrypted),
+ m_Nonce(0),
+ m_ClientBuffer(1024 KiB),
+ m_ServerBuffer(1024 KiB),
+ m_HasClientPinged(false)
+{
+ Printf(m_LogNameBase, "Log_%d", (int)time(NULL));
+ AString fnam(m_LogNameBase);
+ fnam.append(".log");
+ m_LogFile = fopen(fnam.c_str(), "w");
+ Log("Log file created");
+ printf("Connection is logged to file \"%s\"\n", fnam.c_str());
+}
+
+
+
+
+
+cConnection::~cConnection()
+{
+ fclose(m_LogFile);
+}
+
+
+
+
+
+void cConnection::Run(void)
+{
+ if (!ConnectToServer())
+ {
+ Log("Cannot connect to server; aborting");
+ return;
+ }
+
+ while (true)
+ {
+ fd_set ReadFDs;
+ FD_ZERO(&ReadFDs);
+ FD_SET(m_ServerSocket, &ReadFDs);
+ FD_SET(m_ClientSocket, &ReadFDs);
+ int res = select(2, &ReadFDs, NULL, NULL, NULL);
+ if (res <= 0)
+ {
+ printf("select() failed: %d; aborting client", WSAGetLastError());
+ break;
+ }
+ if (FD_ISSET(m_ServerSocket, &ReadFDs))
+ {
+ if (!RelayFromServer())
+ {
+ break;
+ }
+ }
+ if (FD_ISSET(m_ClientSocket, &ReadFDs))
+ {
+ if (!RelayFromClient())
+ {
+ break;
+ }
+ }
+ }
+ Log("Relaying ended, closing sockets");
+ closesocket(m_ServerSocket);
+ closesocket(m_ClientSocket);
+}
+
+
+
+
+
+void cConnection::Log(const char * a_Format, ...)
+{
+ va_list args;
+ va_start(args, a_Format);
+ AString msg;
+ AppendVPrintf(msg, a_Format, args);
+ va_end(args);
+ AString FullMsg;
+ Printf(FullMsg, "[%5.3f] %s\n", GetRelativeTime(), msg.c_str());
+
+ // Log to file:
+ cCSLock Lock(m_CSLog);
+ fputs(FullMsg.c_str(), m_LogFile);
+
+ // Log to screen:
+ // std::cout << FullMsg;
+}
+
+
+
+
+
+void cConnection::DataLog(const void * a_Data, int a_Size, const char * a_Format, ...)
+{
+ va_list args;
+ va_start(args, a_Format);
+ AString msg;
+ AppendVPrintf(msg, a_Format, args);
+ va_end(args);
+ AString FullMsg;
+ AString Hex;
+ Printf(FullMsg, "[%5.3f] %s\n%s\n", GetRelativeTime(), msg.c_str(), CreateHexDump(Hex, a_Data, a_Size, 16).c_str());
+
+ // Log to file:
+ cCSLock Lock(m_CSLog);
+ fputs(FullMsg.c_str(), m_LogFile);
+
+ /*
+ // Log to screen:
+ std::cout << FullMsg;
+ //*/
+}
+
+
+
+
+
+void cConnection::LogFlush(void)
+{
+ fflush(m_LogFile);
+}
+
+
+
+
+
+bool cConnection::ConnectToServer(void)
+{
+ m_ServerSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (m_ServerSocket == INVALID_SOCKET)
+ {
+ return false;
+ }
+ sockaddr_in localhost;
+ localhost.sin_family = AF_INET;
+ localhost.sin_port = htons(m_Server.GetConnectPort());
+ localhost.sin_addr.s_addr = htonl(0x7f000001); // localhost
+ if (connect(m_ServerSocket, (sockaddr *)&localhost, sizeof(localhost)) != 0)
+ {
+ printf("connection to server failed: %d\n", WSAGetLastError());
+ return false;
+ }
+ Log("Connected to SERVER");
+ return true;
+}
+
+
+
+
+
+bool cConnection::RelayFromServer(void)
+{
+ char Buffer[64 KiB];
+ int res = recv(m_ServerSocket, Buffer, sizeof(Buffer), 0);
+ if (res <= 0)
+ {
+ Log("Server closed the socket: %d; %d; aborting connection", res, WSAGetLastError());
+ return false;
+ }
+
+ DataLog(Buffer, res, "Received %d bytes from the SERVER", res);
+
+ switch (m_ServerState)
+ {
+ case csUnencrypted:
+ case csWaitingForEncryption:
+ {
+ return DecodeServersPackets(Buffer, res);
+ }
+ case csEncryptedUnderstood:
+ {
+ m_ServerDecryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
+ DataLog(Buffer, res, "Decrypted %d bytes from the SERVER", res);
+ return DecodeServersPackets(Buffer, res);
+ }
+ case csEncryptedUnknown:
+ {
+ m_ServerDecryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
+ DataLog(Buffer, res, "Decrypted %d bytes from the SERVER", res);
+ m_ClientEncryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
+ return CLIENTSEND(Buffer, res);
+ }
+ }
+
+ return true;
+}
+
+
+
+
+
+bool cConnection::RelayFromClient(void)
+{
+ char Buffer[64 KiB];
+ int res = recv(m_ClientSocket, Buffer, sizeof(Buffer), 0);
+ if (res <= 0)
+ {
+ Log("Client closed the socket: %d; %d; aborting connection", res, WSAGetLastError());
+ return false;
+ }
+
+ DataLog(Buffer, res, "Received %d bytes from the CLIENT", res);
+
+ switch (m_ClientState)
+ {
+ case csUnencrypted:
+ case csWaitingForEncryption:
+ {
+ return DecodeClientsPackets(Buffer, res);
+ }
+ case csEncryptedUnderstood:
+ {
+ m_ClientDecryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
+ DataLog(Buffer, res, "Decrypted %d bytes from the CLIENT", res);
+ return DecodeClientsPackets(Buffer, res);
+ }
+ case csEncryptedUnknown:
+ {
+ m_ClientDecryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
+ DataLog(Buffer, res, "Decrypted %d bytes from the CLIENT", res);
+ m_ServerEncryptor.ProcessData((byte *)Buffer, (byte *)Buffer, res);
+ return SERVERSEND(Buffer, res);
+ }
+ }
+
+ return true;
+}
+
+
+
+
+
+double cConnection::GetRelativeTime(void)
+{
+ return (double)(clock() - m_BeginTick) / CLOCKS_PER_SEC;
+
+}
+
+
+
+
+
+bool cConnection::SendData(SOCKET a_Socket, const char * a_Data, int a_Size, const char * a_Peer)
+{
+ DataLog(a_Data, a_Size, "Sending data to %s", a_Peer);
+
+ int res = send(a_Socket, a_Data, a_Size, 0);
+ if (res <= 0)
+ {
+ Log("%s closed the socket: %d, %d; aborting connection", a_Peer, res, WSAGetLastError());
+ return false;
+ }
+ return true;
+}
+
+
+
+
+
+bool cConnection::SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a_Peer)
+{
+ AString All;
+ a_Data.ReadAll(All);
+ a_Data.CommitRead();
+ return SendData(a_Socket, All.data(), All.size(), a_Peer);
+}
+
+
+
+
+
+bool cConnection::SendEncryptedData(SOCKET a_Socket, Encryptor & a_Encryptor, const char * a_Data, int a_Size, const char * a_Peer)
+{
+ DataLog(a_Data, a_Size, "Encrypting %d bytes to %s", a_Size, a_Peer);
+ const byte * Data = (const byte *)a_Data;
+ while (a_Size > 0)
+ {
+ byte Buffer[64 KiB];
+ int NumBytes = (a_Size > sizeof(Buffer)) ? sizeof(Buffer) : a_Size;
+ a_Encryptor.ProcessData(Buffer, Data, NumBytes);
+ bool res = SendData(a_Socket, (const char *)Buffer, NumBytes, a_Peer);
+ if (!res)
+ {
+ return false;
+ }
+ Data += NumBytes;
+ a_Size -= NumBytes;
+ }
+ return true;
+}
+
+
+
+
+
+bool cConnection::SendEncryptedData(SOCKET a_Socket, Encryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer)
+{
+ AString All;
+ a_Data.ReadAll(All);
+ a_Data.CommitRead();
+ return SendEncryptedData(a_Socket, a_Encryptor, All.data(), All.size(), a_Peer);
+}
+
+
+
+
+
+bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size)
+{
+ if (!m_ClientBuffer.Write(a_Data, a_Size))
+ {
+ Log("Too much queued data for the server, aborting connection");
+ return false;
+ }
+
+ while (m_ClientBuffer.CanReadBytes(1))
+ {
+ Log("Decoding client's packets, there are now %d bytes in the queue", m_ClientBuffer.GetReadableSpace());
+ unsigned char PacketType;
+ m_ClientBuffer.ReadByte(PacketType);
+ switch (PacketType)
+ {
+ case PACKET_BLOCK_DIG: HANDLE_CLIENT_READ(HandleClientBlockDig); break;
+ case PACKET_BLOCK_PLACE: HANDLE_CLIENT_READ(HandleClientBlockPlace); break;
+ case PACKET_CHAT_MESSAGE: HANDLE_CLIENT_READ(HandleClientChatMessage); break;
+ case PACKET_CLIENT_STATUSES: HANDLE_CLIENT_READ(HandleClientClientStatuses); break;
+ case PACKET_CREATIVE_INVENTORY_ACTION: HANDLE_CLIENT_READ(HandleClientCreativeInventoryAction); break;
+ case PACKET_ENCRYPTION_KEY_RESPONSE: HANDLE_CLIENT_READ(HandleClientEncryptionKeyResponse); break;
+ case PACKET_ENTITY_ACTION: HANDLE_CLIENT_READ(HandleClientEntityAction); break;
+ case PACKET_HANDSHAKE: HANDLE_CLIENT_READ(HandleClientHandshake); break;
+ case PACKET_KEEPALIVE: HANDLE_CLIENT_READ(HandleClientKeepAlive); break;
+ case PACKET_LOCALE_AND_VIEW: HANDLE_CLIENT_READ(HandleClientLocaleAndView); break;
+ case PACKET_PING: HANDLE_CLIENT_READ(HandleClientPing); break;
+ case PACKET_PLAYER_ABILITIES: HANDLE_CLIENT_READ(HandleClientPlayerAbilities); break;
+ case PACKET_PLAYER_ANIMATION: HANDLE_CLIENT_READ(HandleClientAnimation); break;
+ case PACKET_PLAYER_LOOK: HANDLE_CLIENT_READ(HandleClientPlayerLook); break;
+ case PACKET_PLAYER_ON_GROUND: HANDLE_CLIENT_READ(HandleClientPlayerOnGround); break;
+ case PACKET_PLAYER_POSITION: HANDLE_CLIENT_READ(HandleClientPlayerPosition); break;
+ case PACKET_PLAYER_POSITION_LOOK: HANDLE_CLIENT_READ(HandleClientPlayerPositionLook); break;
+ case PACKET_PLUGIN_MESSAGE: HANDLE_CLIENT_READ(HandleClientPluginMessage); break;
+ case PACKET_SLOT_SELECT: HANDLE_CLIENT_READ(HandleClientSlotSelect); break;
+ case PACKET_UPDATE_SIGN: HANDLE_CLIENT_READ(HandleClientUpdateSign); break;
+ case PACKET_USE_ENTITY: HANDLE_CLIENT_READ(HandleClientUseEntity); break;
+ case PACKET_WINDOW_CLICK: HANDLE_CLIENT_READ(HandleClientWindowClick); break;
+ case PACKET_WINDOW_CLOSE: HANDLE_CLIENT_READ(HandleClientWindowClose); break;
+ default:
+ {
+ if (m_ClientState == csEncryptedUnderstood)
+ {
+ Log("****************** Unknown packet 0x%02x from the client while encrypted; continuing to relay blind only", PacketType);
+ AString Data;
+ m_ClientBuffer.ResetRead();
+ m_ClientBuffer.ReadAll(Data);
+ DataLog(Data.data(), Data.size(), "Current data in the client packet queue: %d bytes", Data.size());
+ m_ClientState = csEncryptedUnknown;
+ m_ClientBuffer.ResetRead();
+ if (m_ServerState == csUnencrypted)
+ {
+ SERVERSEND(m_ClientBuffer);
+ }
+ else
+ {
+ SERVERENCRYPTSEND(m_ClientBuffer);
+ }
+ return true;
+ }
+ else
+ {
+ Log("Unknown packet 0x%02x from the client while unencrypted; aborting connection", PacketType);
+ return false;
+ }
+ }
+ } // switch (PacketType)
+ m_ClientBuffer.CommitRead();
+ } // while (CanReadBytes(1))
+ return true;
+}
+
+
+
+
+
+bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
+{
+ if (!m_ServerBuffer.Write(a_Data, a_Size))
+ {
+ Log("Too much queued data for the client, aborting connection");
+ return false;
+ }
+
+ if (
+ (m_ServerState == csEncryptedUnderstood) &&
+ (m_ClientState == csUnencrypted)
+ )
+ {
+ // Client hasn't finished encryption handshake yet, don't send them any data yet
+ }
+
+ while (m_ServerBuffer.CanReadBytes(1))
+ {
+ unsigned char PacketType;
+ m_ServerBuffer.ReadByte(PacketType);
+ Log("Decoding server's packets, there are now %d bytes in the queue; next packet is 0x%x", m_ServerBuffer.GetReadableSpace(), PacketType);
+ LogFlush();
+ switch (PacketType)
+ {
+ case PACKET_ATTACH_ENTITY: HANDLE_SERVER_READ(HandleServerAttachEntity); break;
+ case PACKET_BLOCK_ACTION: HANDLE_SERVER_READ(HandleServerBlockAction); break;
+ case PACKET_BLOCK_CHANGE: HANDLE_SERVER_READ(HandleServerBlockChange); break;
+ case PACKET_CHANGE_GAME_STATE: HANDLE_SERVER_READ(HandleServerChangeGameState); break;
+ case PACKET_CHAT_MESSAGE: HANDLE_SERVER_READ(HandleServerChatMessage); break;
+ case PACKET_COLLECT_PICKUP: HANDLE_SERVER_READ(HandleServerCollectPickup); break;
+ case PACKET_COMPASS: HANDLE_SERVER_READ(HandleServerCompass); break;
+ case PACKET_DESTROY_ENTITIES: HANDLE_SERVER_READ(HandleServerDestroyEntities); break;
+ case PACKET_ENCRYPTION_KEY_REQUEST: HANDLE_SERVER_READ(HandleServerEncryptionKeyRequest); break;
+ case PACKET_ENCRYPTION_KEY_RESPONSE: HANDLE_SERVER_READ(HandleServerEncryptionKeyResponse); break;
+ case PACKET_ENTITY: HANDLE_SERVER_READ(HandleServerEntity); break;
+ case PACKET_ENTITY_EQUIPMENT: HANDLE_SERVER_READ(HandleServerEntityEquipment); break;
+ case PACKET_ENTITY_HEAD_LOOK: HANDLE_SERVER_READ(HandleServerEntityHeadLook); break;
+ case PACKET_ENTITY_LOOK: HANDLE_SERVER_READ(HandleServerEntityLook); break;
+ case PACKET_ENTITY_METADATA: HANDLE_SERVER_READ(HandleServerEntityMetadata); break;
+ case PACKET_ENTITY_PROPERTIES: HANDLE_SERVER_READ(HandleServerEntityProperties); break;
+ case PACKET_ENTITY_RELATIVE_MOVE: HANDLE_SERVER_READ(HandleServerEntityRelativeMove); break;
+ case PACKET_ENTITY_RELATIVE_MOVE_LOOK: HANDLE_SERVER_READ(HandleServerEntityRelativeMoveLook); break;
+ case PACKET_ENTITY_STATUS: HANDLE_SERVER_READ(HandleServerEntityStatus); break;
+ case PACKET_ENTITY_TELEPORT: HANDLE_SERVER_READ(HandleServerEntityTeleport); break;
+ case PACKET_ENTITY_VELOCITY: HANDLE_SERVER_READ(HandleServerEntityVelocity); break;
+ case PACKET_INCREMENT_STATISTIC: HANDLE_SERVER_READ(HandleServerIncrementStatistic); break;
+ case PACKET_KEEPALIVE: HANDLE_SERVER_READ(HandleServerKeepAlive); break;
+ case PACKET_KICK: HANDLE_SERVER_READ(HandleServerKick); break;
+ case PACKET_LOGIN: HANDLE_SERVER_READ(HandleServerLogin); break;
+ case PACKET_MAP_CHUNK: HANDLE_SERVER_READ(HandleServerMapChunk); break;
+ case PACKET_MAP_CHUNK_BULK: HANDLE_SERVER_READ(HandleServerMapChunkBulk); break;
+ case PACKET_MULTI_BLOCK_CHANGE: HANDLE_SERVER_READ(HandleServerMultiBlockChange); break;
+ case PACKET_NAMED_SOUND_EFFECT: HANDLE_SERVER_READ(HandleServerNamedSoundEffect); break;
+ case PACKET_PLAYER_ABILITIES: HANDLE_SERVER_READ(HandleServerPlayerAbilities); break;
+ case PACKET_PLAYER_ANIMATION: HANDLE_SERVER_READ(HandleServerPlayerAnimation); break;
+ case PACKET_PLAYER_LIST_ITEM: HANDLE_SERVER_READ(HandleServerPlayerListItem); break;
+ case PACKET_PLAYER_POSITION_LOOK: HANDLE_SERVER_READ(HandleServerPlayerPositionLook); break;
+ case PACKET_PLUGIN_MESSAGE: HANDLE_SERVER_READ(HandleServerPluginMessage); break;
+ case PACKET_SET_EXPERIENCE: HANDLE_SERVER_READ(HandleServerSetExperience); break;
+ case PACKET_SET_SLOT: HANDLE_SERVER_READ(HandleServerSetSlot); break;
+ case PACKET_SLOT_SELECT: HANDLE_SERVER_READ(HandleServerSlotSelect); break;
+ case PACKET_SOUND_EFFECT: HANDLE_SERVER_READ(HandleServerSoundEffect); break;
+ case PACKET_SPAWN_MOB: HANDLE_SERVER_READ(HandleServerSpawnMob); break;
+ case PACKET_SPAWN_NAMED_ENTITY: HANDLE_SERVER_READ(HandleServerSpawnNamedEntity); break;
+ case PACKET_SPAWN_OBJECT_VEHICLE: HANDLE_SERVER_READ(HandleServerSpawnObjectVehicle); break;
+ case PACKET_SPAWN_PAINTING: HANDLE_SERVER_READ(HandleServerSpawnPainting); break;
+ case PACKET_SPAWN_PICKUP: HANDLE_SERVER_READ(HandleServerSpawnPickup); break;
+ case PACKET_TIME_UPDATE: HANDLE_SERVER_READ(HandleServerTimeUpdate); break;
+ case PACKET_UPDATE_HEALTH: HANDLE_SERVER_READ(HandleServerUpdateHealth); break;
+ case PACKET_UPDATE_SIGN: HANDLE_SERVER_READ(HandleServerUpdateSign); break;
+ case PACKET_UPDATE_TILE_ENTITY: HANDLE_SERVER_READ(HandleServerUpdateTileEntity); break;
+ case PACKET_WINDOW_CLOSE: HANDLE_SERVER_READ(HandleServerWindowClose); break;
+ case PACKET_WINDOW_CONTENTS: HANDLE_SERVER_READ(HandleServerWindowContents); break;
+ case PACKET_WINDOW_OPEN: HANDLE_SERVER_READ(HandleServerWindowOpen); break;
+ default:
+ {
+ if (m_ServerState == csEncryptedUnderstood)
+ {
+ Log("********************** Unknown packet 0x%02x from the server while encrypted; continuing to relay blind only", PacketType);
+ AString Data;
+ m_ServerBuffer.ResetRead();
+ m_ServerBuffer.ReadAll(Data);
+ DataLog(Data.data(), Data.size(), "Current data in the server packet queue: %d bytes", Data.size());
+ m_ServerState = csEncryptedUnknown;
+ m_ServerBuffer.ResetRead();
+ if (m_ClientState == csUnencrypted)
+ {
+ CLIENTSEND(m_ServerBuffer);
+ }
+ else
+ {
+ CLIENTENCRYPTSEND(m_ServerBuffer);
+ }
+ return true;
+ }
+ else
+ {
+ Log("Unknown packet 0x%02x from the server while unencrypted; aborting connection", PacketType);
+ return false;
+ }
+ }
+ } // switch (PacketType)
+ m_ServerBuffer.CommitRead();
+ } // while (CanReadBytes(1))
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientAnimation(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, Animation);
+ Log("Received a PACKET_ANIMATION from the client:");
+ Log(" EntityID: %d", EntityID);
+ Log(" Animation: %d", Animation);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientBlockDig(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, Status);
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, BlockY);
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, BlockFace);
+ Log("Received a PACKET_BLOCK_DIG from the client:");
+ Log(" Status = %d", Status);
+ Log(" Pos = <%d, %d, %d>", BlockX, BlockY, BlockZ);
+ Log(" BlockFace = %d", BlockFace);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientBlockPlace(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, BlockY);
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, Face);
+ AString Desc;
+ if (!ParseSlot(m_ClientBuffer, Desc))
+ {
+ return false;
+ }
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, CursorX);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, CursorY);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, CursorZ);
+ Log("Received a PACKET_BLOCK_PLACE from the client:");
+ Log(" Block = {%d, %d, %d}", BlockX, BlockY, BlockZ);
+ Log(" Face = %d", Face);
+ Log(" Item = %s", Desc.c_str());
+ Log(" Cursor = <%d, %d, %d>", CursorX, CursorY, CursorZ);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientChatMessage(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Message);
+ Log("Received a PACKET_CHAT_MESSAGE from the client:");
+ Log(" Message = \"%s\"", Message.c_str());
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientClientStatuses(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, Statuses);
+ Log("Received a PACKET_CLIENT_STATUSES from the CLIENT:");
+ Log(" Statuses = %d", Statuses);
+
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientCreativeInventoryAction(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, SlotNum);
+ AString Item;
+ if (!ParseSlot(m_ClientBuffer, Item))
+ {
+ return false;
+ }
+ Log("Received a PACKET_CREATIVE_INVENTORY_ACTION from the client:");
+ Log(" SlotNum = %d", SlotNum);
+ Log(" Item = %s", Item.c_str());
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientEncryptionKeyResponse(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, EncKeyLength);
+ AString EncKey;
+ if (!m_ClientBuffer.ReadString(EncKey, EncKeyLength))
+ {
+ return true;
+ }
+ HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, EncNonceLength);
+ AString EncNonce;
+ if (!m_ClientBuffer.ReadString(EncNonce, EncNonceLength))
+ {
+ return true;
+ }
+ if ((EncKeyLength > MAX_ENC_LEN) || (EncNonceLength > MAX_ENC_LEN))
+ {
+ Log("Client: Too long encryption params");
+ return true;
+ }
+ StartClientEncryption(EncKey, EncNonce);
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientEntityAction(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, PlayerID);
+ HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, ActionType);
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, UnknownHorseVal);
+ Log("Received a PACKET_ENTITY_ACTION from the client:");
+ Log(" PlayerID = %d", PlayerID);
+ Log(" ActionType = %d", ActionType);
+ Log(" UnknownHorseVal = %d (0x%08x)", UnknownHorseVal, UnknownHorseVal);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientHandshake(void)
+{
+ // Read the packet from the client:
+ HANDLE_CLIENT_PACKET_READ(ReadByte, Byte, ProtocolVersion);
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Username);
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, ServerHost);
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, ServerPort);
+ m_ClientBuffer.CommitRead();
+
+ Log("Received a PACKET_HANDSHAKE from the client:");
+ Log(" ProtocolVersion = %d", ProtocolVersion);
+ Log(" Username = \"%s\"", Username.c_str());
+ Log(" ServerHost = \"%s\"", ServerHost.c_str());
+ Log(" ServerPort = %d", ServerPort);
+
+ // Send the same packet to the server, but with our port:
+ cByteBuffer ToServer(512);
+ ToServer.WriteByte (PACKET_HANDSHAKE);
+ ToServer.WriteByte (ProtocolVersion);
+ ToServer.WriteBEUTF16String16(Username);
+ ToServer.WriteBEUTF16String16(ServerHost);
+ ToServer.WriteBEInt (m_Server.GetConnectPort());
+ SERVERSEND(ToServer);
+
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientKeepAlive(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, ID);
+ Log("Received a PACKET_KEEPALIVE from the client");
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientLocaleAndView(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Locale);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, ViewDistance);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, ChatFlags);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, Difficulty);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, ShowCape);
+ Log("Received a PACKET_LOCALE_AND_VIEW from the client");
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientPing(void)
+{
+ m_HasClientPinged = true;
+ Log("Received a PACKET_PING from the client");
+ m_ClientBuffer.ResetRead();
+ SERVERSEND(m_ClientBuffer);
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientPlayerAbilities(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, Flags);
+ HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, FlyingSpeed);
+ HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, WalkingSpeed);
+ Log("Receives a PACKET_PLAYER_ABILITIES from the client:");
+ Log(" Flags = %d (0x%02x)", Flags, Flags);
+ Log(" FlyingSpeed = %f", FlyingSpeed);
+ Log(" WalkingSpeed = %f", WalkingSpeed);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientPlayerLook(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, Yaw);
+ HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, Pitch);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, OnGround);
+ Log("Received a PACKET_PLAYER_LOOK from the client");
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientPlayerOnGround(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, OnGround);
+ Log("Received a PACKET_PLAYER_ON_GROUND from the client");
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientPlayerPosition(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosX);
+ HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, Stance);
+ HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosY);
+ HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosZ);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, IsOnGround);
+ Log("Received a PACKET_PLAYER_POSITION from the client");
+
+ // TODO: list packet contents
+
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientPlayerPositionLook(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosX);
+ HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, Stance);
+ HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosY);
+ HANDLE_CLIENT_PACKET_READ(ReadBEDouble, double, PosZ);
+ HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, Yaw);
+ HANDLE_CLIENT_PACKET_READ(ReadBEFloat, float, Pitch);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, IsOnGround);
+ Log("Received a PACKET_PLAYER_POSITION_LOOK from the client");
+ Log(" Pos = {%.03f, %.03f, %.03f}", PosX, PosY, PosZ);
+ Log(" Stance = %.03f", Stance);
+ Log(" Y, P = %.03f, %.03f", Yaw, Pitch);
+ Log(" IsOnGround = %s", IsOnGround ? "true" : "false");
+
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientPluginMessage(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, ChannelName);
+ HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, Length);
+ AString Data;
+ if (!m_ClientBuffer.ReadString(Data, Length))
+ {
+ return false;
+ }
+ Log("Received a PACKET_PLUGIN_MESSAGE from the client");
+ Log(" ChannelName = \"%s\"", ChannelName.c_str());
+ DataLog(Data.data(), Length, " Data: %d bytes", Length);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientSlotSelect(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, SlotNum);
+ Log("Received a PACKET_SLOT_SELECT from the client");
+ Log(" SlotNum = %d", SlotNum);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientUpdateSign(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, BlockY);
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Line1);
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Line2);
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Line3);
+ HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Line4);
+ Log("Received a PACKET_UPDATE_SIGN from the client:");
+ Log(" Block = {%d, %d, %d}", BlockX, BlockY, BlockZ);
+ Log(" Lines = \"%s\", \"%s\", \"%s\", \"%s\"", Line1.c_str(), Line2.c_str(), Line3.c_str(), Line4.c_str());
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientUseEntity(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, PlayerID);
+ HANDLE_CLIENT_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, MouseButton);
+ Log("Received a PACKET_USE_ENTITY from the client:");
+ Log(" PlayerID = %d", PlayerID);
+ Log(" EntityID = %d", EntityID);
+ Log(" MouseButton = %d", MouseButton);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientWindowClick(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, WindowID);
+ HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, SlotNum);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, IsRightClick);
+ HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, TransactionID);
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, IsShiftClick);
+ AString Item;
+ if (!ParseSlot(m_ClientBuffer, Item))
+ {
+ return false;
+ }
+ Log("Received a PACKET_WINDOW_CLICK from the client");
+ Log(" WindowID = %d", WindowID);
+ Log(" SlotNum = %d", SlotNum);
+ Log(" IsRclk = %d, IsShift = %d", IsRightClick, IsShiftClick);
+ Log(" TransactionID = 0x%x", TransactionID);
+ Log(" ClickedItem = %s", Item.c_str());
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleClientWindowClose(void)
+{
+ HANDLE_CLIENT_PACKET_READ(ReadChar, char, WindowID);
+ Log("Received a PACKET_WINDOW_CLOSE from the client:");
+ Log(" WindowID = %d", WindowID);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerAttachEntity(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, VehicleID);
+ HANDLE_SERVER_PACKET_READ(ReadBool, bool, Leash);
+ Log("Received a PACKET_ATTACH_ENTITY from the server:");
+ Log(" EntityID = %d (0x%x)", EntityID, EntityID);
+ Log(" VehicleID = %d (0x%x)", VehicleID, VehicleID);
+ Log(" Leash = %s", Leash ? "true" : "false");
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerBlockAction(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Byte1);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Byte2);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockID);
+ Log("Received a PACKET_BLOCK_ACTION from the server:");
+ Log(" Pos = {%d, %d, %d}", BlockX, BlockY, BlockZ);
+ Log(" Bytes = (%d, %d) == (0x%x, 0x%x)", Byte1, Byte2, Byte1, Byte2);
+ Log(" BlockID = %d", BlockID);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerBlockChange(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, BlockY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockType);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, BlockMeta);
+ Log("Received a PACKET_BLOCK_CHANGE from the server");
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerChangeGameState(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, Reason);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, Data);
+ Log("Received a PACKET_CHANGE_GAME_STATE from the server:");
+ Log(" Reason = %d", Reason);
+ Log(" Data = %d", Data);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerChatMessage(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Message);
+ Log("Received a PACKET_CHAT_MESSAGE from the server:");
+ Log(" Message = \"%s\"", Message.c_str());
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerCollectPickup(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, CollectedID);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, CollectorID);
+ Log("Received a PACKET_COLLECT_PICKUP from the server:");
+ Log(" CollectedID = %d", CollectedID);
+ Log(" CollectorID = %d", CollectorID);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerCompass(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, SpawnX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, SpawnY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, SpawnZ);
+ Log("Received PACKET_COMPASS from the server:");
+ Log(" Spawn = {%d, %d, %d}", SpawnX, SpawnY, SpawnZ);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerDestroyEntities(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, NumEntities);
+ if (!m_ServerBuffer.SkipRead((int)NumEntities * 4))
+ {
+ return false;
+ }
+ Log("Received PACKET_DESTROY_ENTITIES from the server:");
+ Log(" NumEntities = %d", NumEntities);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEncryptionKeyRequest(void)
+{
+ // Read the packet from the server:
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, ServerID);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, PublicKeyLength);
+ AString PublicKey;
+ if (!m_ServerBuffer.ReadString(PublicKey, PublicKeyLength))
+ {
+ return false;
+ }
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, NonceLength);
+ AString Nonce;
+ if (!m_ServerBuffer.ReadString(Nonce, NonceLength))
+ {
+ return false;
+ }
+ Log("Got PACKET_ENCRYPTION_KEY_REQUEST from the SERVER:");
+ Log(" ServerID = %s", ServerID.c_str());
+
+ // Reply to the server:
+ SendEncryptionKeyResponse(PublicKey, Nonce);
+
+ // Send a 0xFD Encryption Key Request http://wiki.vg/Protocol#0xFD to the client, using our own key:
+ Log("Sending PACKET_ENCRYPTION_KEY_REQUEST to the CLIENT");
+ AString key;
+ StringSink sink(key); // GCC won't allow inline instantiation in the following line, damned temporary refs
+ m_Server.GetPublicKey().Save(sink);
+ cByteBuffer ToClient(512);
+ ToClient.WriteByte (PACKET_ENCRYPTION_KEY_REQUEST);
+ ToClient.WriteBEUTF16String16(ServerID);
+ ToClient.WriteBEShort ((short)key.size());
+ ToClient.WriteBuf (key.data(), key.size());
+ ToClient.WriteBEShort (4);
+ ToClient.WriteBEInt (m_Nonce); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
+ CLIENTSEND(ToClient);
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntity(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ Log("Received a PACKET_ENTITY from the server:");
+ Log(" EntityID = %d", EntityID);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityEquipment(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SlotNum);
+ AString Item;
+ if (!ParseSlot(m_ServerBuffer, Item))
+ {
+ return false;
+ }
+ Log("Received a PACKET_ENTITY_EQUIPMENT from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" SlotNum = %d", SlotNum);
+ Log(" Item = %s", Item.c_str());
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityHeadLook(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, HeadYaw);
+ Log("Received a PACKET_ENTITY_HEAD_LOOK from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" HeadYaw = %d", HeadYaw);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityLook(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
+ Log("Received a PACKET_ENTITY_LOOK from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" Yaw = %d", Yaw);
+ Log(" Pitch = %d", Pitch);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityMetadata(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ AString Metadata;
+ if (!ParseMetadata(m_ServerBuffer, Metadata))
+ {
+ return false;
+ }
+ AString HexDump;
+ CreateHexDump(HexDump, Metadata.data(), Metadata.size(), 32);
+ Log("Received a PACKET_ENTITY_METADATA from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" Metadata, length = %d (0x%x):\n%s", Metadata.length(), Metadata.length(), HexDump.c_str());
+ LogMetadata(Metadata, 4);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityProperties(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Count);
+ Log("Received a PACKET_ENTITY_PROPERTIES from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" Count = %d", Count);
+
+ for (int i = 0; i < Count; i++)
+ {
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Key);
+ HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, Value);
+ Log(" \"%s\" = %f", Key.c_str(), Value);
+ } // for i
+
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, ListLength);
+ Log(" ListLength = %d", ListLength);
+ for (int i = 0; i < ListLength; i++)
+ {
+ HANDLE_SERVER_PACKET_READ(ReadBEInt64, Int64, UUIDHi);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt64, Int64, UUIDLo);
+ HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, DblVal);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, ByteVal);
+ Log(" [%d] = {0x%08llx%08llx, %f, %i}", i, UUIDHi, UUIDLo, DblVal, ByteVal);
+ } // for i
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityRelativeMove(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dx);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dy);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dz);
+ Log("Received a PACKET_ENTITY_RELATIVE_MOVE from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" RelMove = <%d, %d, %d>", dx, dy, dz);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityRelativeMoveLook(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dx);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dy);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, dz);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
+ Log("Received a PACKET_ENTITY_RELATIVE_MOVE_LOOK from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" RelMove = <%d, %d, %d>", dx, dy, dz);
+ Log(" Yaw = %d", Yaw);
+ Log(" Pitch = %d", Pitch);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityStatus(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Status);
+ Log("Received a PACKET_ENTITY_STATUS from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" Status = %d", Status);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityTeleport(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
+ Log("Received a PACKET_ENTITY_TELEPORT from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" Pos = {%d, %d, %d}", BlockX, BlockY, BlockZ);
+ Log(" Yaw = %d", Yaw);
+ Log(" Pitch = %d", Pitch);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEntityVelocity(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityX);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityY);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityZ);
+ Log("Received a PACKET_ENTITY_VELOCITY from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" Velocity = <%d, %d, %d>", VelocityX, VelocityY, VelocityZ);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerIncrementStatistic(void)
+{
+ // 0xc8
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, StatisticID);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Amount);
+ Log("Received a PACKET_INCREMENT_STATISTIC from the server:");
+ Log(" StatisticID = %d (0x%x)", StatisticID, StatisticID);
+ Log(" Amount = %d", Amount);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerKeepAlive(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PingID);
+ Log("Received a PACKET_KEEP_ALIVE from the server:");
+ Log(" ID = %d", PingID);
+ COPY_TO_CLIENT()
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerEncryptionKeyResponse(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Lengths);
+ if (Lengths != 0)
+ {
+ Log("Lengths are not zero!");
+ return true;
+ }
+ Log("Server communication is now encrypted");
+ m_ServerState = csEncryptedUnderstood;
+ DataLog(m_ServerEncryptionBuffer.data(), m_ServerEncryptionBuffer.size(), "Sending the queued data to server (%u bytes):", m_ServerEncryptionBuffer.size());
+ SERVERENCRYPTSEND(m_ServerEncryptionBuffer.data(), m_ServerEncryptionBuffer.size());
+ m_ServerEncryptionBuffer.clear();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerKick(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Reason);
+ Log("Received PACKET_KICK from the SERVER:");
+ if (m_HasClientPinged)
+ {
+ Log(" This was a std reply to client's PING");
+ AStringVector Split;
+
+ // Split by NULL chars (StringSplit() won't work here):
+ size_t Last = 0;
+ for (size_t i = 0; i < Reason.size(); i++)
+ {
+ if (Reason[i] == 0)
+ {
+ Split.push_back(Reason.substr(Last, i - Last));
+ Last = i + 1;
+ }
+ }
+
+ if (Split.size() == 5)
+ {
+ Log(" Protocol version: \"%s\"", Split[0].c_str());
+ Log(" Server version: \"%s\"", Split[1].c_str());
+ Log(" MOTD: \"%s\"", Split[2].c_str());
+ Log(" Cur players: \"%s\"", Split[3].c_str());
+ Log(" Max players: \"%s\"", Split[4].c_str());
+ }
+ else
+ {
+ DataLog(Reason.data(), Reason.size(), " Unknown reply format, dumping hex:");
+ }
+ }
+ else
+ {
+ Log(" Reason = \"%s\"", Reason.c_str());
+ }
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerLogin(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, LevelType);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, GameMode);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, Dimension);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, Difficulty);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, Unused);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, MaxPlayers);
+ Log("Received a PACKET_LOGIN from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" LevelType = \"%s\"", LevelType.c_str());
+ Log(" GameMode = %d", GameMode);
+ Log(" Dimension = %d", Dimension);
+ Log(" Difficulty = %d", Difficulty);
+ Log(" Unused = %d", Unused);
+ Log(" MaxPlayers = %d", MaxPlayers);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerMapChunk(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkZ);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, IsContiguous);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, PrimaryBitmap);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, AdditionalBitmap);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, CompressedSize);
+ AString CompressedData;
+ if (!m_ServerBuffer.ReadString(CompressedData, CompressedSize))
+ {
+ return false;
+ }
+ Log("Received a PACKET_MAP_CHUNK from the server:");
+ Log(" ChunkPos = [%d, %d]", ChunkX, ChunkZ);
+ Log(" Compressed size = %d (0x%x)", CompressedSize, CompressedSize);
+
+ // TODO: Save the compressed data into a file for later analysis
+
+ COPY_TO_CLIENT()
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerMapChunkBulk(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, ChunkCount);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, CompressedSize);
+ HANDLE_SERVER_PACKET_READ(ReadBool, bool, IsSkyLightSent);
+ AString CompressedData;
+ if (!m_ServerBuffer.ReadString(CompressedData, CompressedSize))
+ {
+ return false;
+ }
+ AString Meta;
+ if (!m_ServerBuffer.ReadString(Meta, ChunkCount * 12))
+ {
+ return false;
+ }
+ Log("Received a PACKET_MAP_CHUNK_BULK from the server:");
+ Log(" ChunkCount = %d", ChunkCount);
+ Log(" Compressed size = %d (0x%x)", CompressedSize, CompressedSize);
+ Log(" IsSkyLightSent = %s", IsSkyLightSent ? "true" : "false");
+
+ // TODO: Save the compressed data into a file for later analysis
+
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerMultiBlockChange(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkZ);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, NumBlocks);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, DataSize);
+ AString BlockChangeData;
+ if (!m_ServerBuffer.ReadString(BlockChangeData, DataSize))
+ {
+ return false;
+ }
+ Log("Received a PACKET_MULTI_BLOCK_CHANGE packet from the server:");
+ Log(" Chunk = [%d, %d]", ChunkX, ChunkZ);
+ Log(" NumBlocks = %d", NumBlocks);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerNamedSoundEffect(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, SoundName);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Volume);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
+ Log("Received a PACKET_NAMED_SOUND_EFFECT from the server:");
+ Log(" SoundName = \"%s\"", SoundName.c_str());
+ Log(" Pos = (%d, %d, %d) ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 8, PosY / 8, PosZ / 8);
+ Log(" Volume = %f", Volume);
+ Log(" Pitch = %d", Pitch);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerPlayerAbilities(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, Flags);
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, FlyingSpeed);
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, WalkingSpeed);
+ Log("Received a PACKET_PLAYER_ABILITIES from the server:");
+ Log(" Flags = %d (0x%02x)", Flags, Flags);
+ Log(" FlyingSpeed = %f", FlyingSpeed);
+ Log(" WalkingSpeed = %f", WalkingSpeed);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerPlayerAnimation(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PlayerID);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, AnimationID);
+ Log("Received a PACKET_PLAYER_ANIMATION from the server:");
+ Log(" PlayerID: %d (0x%x)", PlayerID, PlayerID);
+ Log(" Animation: %d", AnimationID);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerPlayerListItem(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, PlayerName);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, IsOnline);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, Ping);
+ Log("Received a PACKET_PLAYERLIST_ITEM from the server:");
+ Log(" PlayerName = \"%s\"", PlayerName.c_str());
+ Log(" Ping = %d", Ping);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerPlayerPositionLook(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosX);
+ HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, Stance);
+ HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosY);
+ HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosZ);
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Yaw);
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Pitch);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, IsOnGround);
+ Log("Received a PACKET_PLAYER_POSITION_LOOK from the server");
+
+ // TODO: list packet contents
+
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerPluginMessage(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, ChannelName);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, Length);
+ AString Data;
+ if (!m_ServerBuffer.ReadString(Data, Length))
+ {
+ return false;
+ }
+ Log("Received a PACKET_PLUGIN_MESSAGE from the server");
+ Log(" ChannelName = \"%s\"", ChannelName.c_str());
+ DataLog(Data.data(), Length, " Data: %d bytes", Length);
+ COPY_TO_SERVER();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerSetExperience(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, ExperienceBar);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, Level);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, TotalExperience);
+ Log("Received a PACKET_SET_EXPERIENCE from the server:");
+ Log(" ExperienceBar = %.05f", ExperienceBar);
+ Log(" Level = %d", Level);
+ Log(" TotalExperience = %d", TotalExperience);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerSetSlot(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowID);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SlotNum);
+ AString Item;
+ if (!ParseSlot(m_ServerBuffer, Item))
+ {
+ return false;
+ }
+ Log("Received a PACKET_SET_SLOT from the server:");
+ Log(" WindowID = %d", WindowID);
+ Log(" SlotNum = %d", SlotNum);
+ Log(" Item = %s", Item.c_str());
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerSlotSelect(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SlotNum);
+ Log("Received a PACKET_SLOT_SELECT from the server:");
+ Log(" SlotNum = %d", SlotNum);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerSoundEffect(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EffectID);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, PosY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Data);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, NoVolumeDecrease);
+ Log("Received a PACKET_SOUND_EFFECT from the server:");
+ Log(" EffectID = %d", EffectID);
+ Log(" Pos = {%d, %d, %d}", PosX, PosY, PosZ);
+ Log(" Data = %d", Data);
+ Log(" NoVolumeDecrease = %d", NoVolumeDecrease);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerSpawnMob(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, MobType);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, HeadYaw);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityX);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityY);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, VelocityZ);
+ AString Metadata;
+ if (!ParseMetadata(m_ServerBuffer, Metadata))
+ {
+ return false;
+ }
+ AString HexDump;
+ CreateHexDump(HexDump, Metadata.data(), Metadata.size(), 32);
+ Log("Received a PACKET_SPAWN_MOB from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" MobType = %d", MobType);
+ Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
+ Log(" Angles = [%d, %d, %d]", Yaw, Pitch, HeadYaw);
+ Log(" Velocity = <%d, %d, %d>", VelocityX, VelocityY, VelocityZ);
+ Log(" Metadata, length = %d (0x%x):\n%s", Metadata.length(), Metadata.length(), HexDump.c_str());
+ LogMetadata(Metadata, 4);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerSpawnNamedEntity(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, EntityName);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, CurrentItem);
+ AString Metadata;
+ if (!ParseMetadata(m_ServerBuffer, Metadata))
+ {
+ return false;
+ }
+ AString HexDump;
+ CreateHexDump(HexDump, Metadata.data(), Metadata.size(), 32);
+ Log("Received a PACKET_SPAWN_NAMED_ENTITY from the server:");
+ Log(" EntityID = %d (0x%x)", EntityID, EntityID);
+ Log(" Name = %s", EntityName.c_str());
+ Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
+ Log(" Rotation = <yaw %d, pitch %d>", Yaw, Pitch);
+ Log(" CurrentItem = %d", CurrentItem);
+ Log(" Metadata, length = %d (0x%x):\n%s", Metadata.length(), Metadata.length(), HexDump.c_str());
+ LogMetadata(Metadata, 4);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerSpawnObjectVehicle(void)
+{
+ #ifdef _DEBUG
+ // DEBUG:
+ // This packet is still troublesome when DataIndicator != 0
+ AString Buffer;
+ m_ServerBuffer.ResetRead();
+ m_ServerBuffer.ReadAll(Buffer);
+ m_ServerBuffer.ResetRead();
+ m_ServerBuffer.SkipRead(1);
+ if (Buffer.size() > 128)
+ {
+ // Only log up to 128 bytes
+ Buffer.erase(128, AString::npos);
+ }
+ DataLog(Buffer.data(), Buffer.size(), "Buffer while parsing the PACKET_SPAWN_OBJECT_VEHICLE packet (%d bytes):", Buffer.size());
+ #endif // _DEBUG
+
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, ObjType);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, DataIndicator);
+ AString ExtraData;
+ short VelocityX, VelocityY, VelocityZ;
+ if (DataIndicator != 0)
+ {
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SpeedX);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SpeedY);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SpeedZ);
+ VelocityX = SpeedX; VelocityY = SpeedY; VelocityZ = SpeedZ; // Speed vars are local to this scope, but we need them available later
+ /*
+ // This doesn't seem to work - for a falling block I'm getting no extra data at all
+ int ExtraLen = 0;
+ switch (ObjType)
+ {
+ case OBJECT_FALLING_BLOCK: ExtraLen = 4; break; // int: BlockType | (BlockMeta << 12)
+ case OBJECT_ARROW:
+ case OBJECT_SNOWBALL:
+ case OBJECT_EGG:
+ case OBJECT_EYE_OF_ENDER:
+ case OBJECT_DRAGON_EGG:
+ case OBJECT_FISHING_FLOAT:
+ {
+ ExtraLen = 4; break; // int: EntityID of the thrower
+ }
+ // TODO: Splash potions
+ }
+ if ((ExtraLen > 0) && !m_ServerBuffer.ReadString(ExtraData, ExtraLen))
+ {
+ return false;
+ }
+ */
+ }
+ Log("Received a PACKET_SPAWN_OBJECT_VEHICLE from the server:");
+ Log(" EntityID = %d (0x%x)", EntityID, EntityID);
+ Log(" ObjType = %d (0x%x)", ObjType, ObjType);
+ Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
+ Log(" Rotation = <yaw %d, pitch %d>", Yaw, Pitch);
+ Log(" DataIndicator = %d (0x%x)", DataIndicator, DataIndicator);
+ if (DataIndicator != 0)
+ {
+ Log(" Velocity = <%d, %d, %d>", VelocityX, VelocityY, VelocityZ);
+ DataLog(ExtraData.data(), ExtraData.size(), " ExtraData size = %d:", ExtraData.size());
+ }
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerSpawnPainting(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, ImageName);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, Direction);
+ Log("Received a PACKET_SPAWN_PAINTING from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" ImageName = \"%s\"", ImageName.c_str());
+ Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
+ Log(" Direction = %d", Direction);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerSpawnPickup(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, EntityID);
+ AString ItemDesc;
+ if (!ParseSlot(m_ServerBuffer, ItemDesc))
+ {
+ return false;
+ }
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Rotation);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Roll);
+ Log("Received a PACKET_SPAWN_PICKUP from the server:");
+ Log(" EntityID = %d", EntityID);
+ Log(" Item = %s", ItemDesc.c_str());
+ Log(" Pos = <%d, %d, %d> ~ {%d, %d, %d}", PosX, PosY, PosZ, PosX / 32, PosY / 32, PosZ / 32);
+ Log(" Angles = [%d, %d, %d]", Rotation, Pitch, Roll);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerTimeUpdate(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt64, Int64, WorldAge);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt64, Int64, TimeOfDay);
+ Log("Received a PACKET_TIME_UPDATE from the server");
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerUpdateHealth(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Health);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, Food);
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Saturation);
+ Log("Received a PACKET_UPDATE_HEALTH from the server");
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerUpdateSign(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Line1);
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Line2);
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Line3);
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Line4);
+ Log("Received a PACKET_UPDATE_SIGN from the server:");
+ Log(" Block = {%d, %d, %d}", BlockX, BlockY, BlockZ);
+ Log(" Lines = \"%s\", \"%s\", \"%s\", \"%s\"", Line1.c_str(), Line2.c_str(), Line3.c_str(), Line4.c_str());
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerUpdateTileEntity(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, BlockY);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Action);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, DataLength);
+ AString Data;
+ if ((DataLength > 0) && !m_ServerBuffer.ReadString(Data, DataLength))
+ {
+ return false;
+ }
+ Log("Received a PACKET_UPDATE_TILE_ENTITY from the server:");
+ Log(" Block = {%d, %d, %d}", BlockX, BlockY, BlockZ);
+ Log(" Action = %d", Action);
+ DataLog(Data.data(), Data.size(), " Data (%d bytes)", Data.size());
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerWindowClose(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowID);
+ Log("Received a PACKET_WINDOW_CLOSE from the server:");
+ Log(" WindowID = %d", WindowID);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerWindowContents(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowID);
+ HANDLE_SERVER_PACKET_READ(ReadBEShort, short, NumSlots);
+ Log("Received a PACKET_WINDOW_CONTENTS from the server:");
+ Log(" WindowID = %d", WindowID);
+ Log(" NumSlots = %d", NumSlots);
+ AStringVector Items;
+ for (short i = 0; i < NumSlots; i++)
+ {
+ AString Item;
+ if (!ParseSlot(m_ServerBuffer, Item))
+ {
+ return false;
+ }
+ Log(" %d: %s", i, Item.c_str());
+ }
+
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::HandleServerWindowOpen(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowID);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, WindowType);
+ HANDLE_SERVER_PACKET_READ(ReadBEUTF16String16, AString, Title);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, NumSlots);
+ HANDLE_SERVER_PACKET_READ(ReadByte, Byte, UseProvidedTitle);
+ int HorseInt = 0;
+ if (WindowType == 11) // Horse / Donkey / Mule
+ {
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, intHorseInt);
+ HorseInt = intHorseInt;
+ }
+ Log("Received a PACKET_WINDOW_OPEN from the server:");
+ Log(" WindowID = %d", WindowID);
+ Log(" WindowType = %d", WindowType);
+ Log(" Title = \"%s\", Use = %d", Title.c_str(), UseProvidedTitle);
+ Log(" NumSlots = %d", NumSlots);
+ if (WindowType == 11)
+ {
+ Log(" HorseInt = %d (0x%08x)", HorseInt, HorseInt);
+ }
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
+bool cConnection::ParseSlot(cByteBuffer & a_Buffer, AString & a_ItemDesc)
+{
+ short ItemType;
+ if (!a_Buffer.ReadBEShort(ItemType))
+ {
+ return false;
+ }
+ if (ItemType <= 0)
+ {
+ a_ItemDesc = "<empty>";
+ return true;
+ }
+ if (!a_Buffer.CanReadBytes(5))
+ {
+ return false;
+ }
+ char ItemCount;
+ short ItemDamage;
+ short MetadataLength;
+ a_Buffer.ReadChar(ItemCount);
+ a_Buffer.ReadBEShort(ItemDamage);
+ a_Buffer.ReadBEShort(MetadataLength);
+ Printf(a_ItemDesc, "%d:%d * %d", ItemType, ItemDamage, ItemCount);
+ if (MetadataLength <= 0)
+ {
+ return true;
+ }
+ AString Metadata;
+ Metadata.resize(MetadataLength);
+ if (!a_Buffer.ReadBuf((void *)Metadata.data(), MetadataLength))
+ {
+ return false;
+ }
+ AString MetaHex;
+ CreateHexDump(MetaHex, Metadata.data(), Metadata.size(), 16);
+ AppendPrintf(a_ItemDesc, "; %d bytes of meta:\n%s", MetadataLength, MetaHex.c_str());
+
+ // Save metadata to a file:
+ AString fnam;
+ Printf(fnam, "%s_item_%08x.nbt", m_LogNameBase.c_str(), m_ItemIdx++);
+ FILE * f = fopen(fnam.c_str(), "wb");
+ if (f != NULL)
+ {
+ fwrite(Metadata.data(), 1, Metadata.size(), f);
+ fclose(f);
+ AppendPrintf(a_ItemDesc, "\n (saved to file \"%s\")", fnam.c_str());
+ }
+
+ return true;
+}
+
+
+
+
+
+bool cConnection::ParseMetadata(cByteBuffer & a_Buffer, AString & a_Metadata)
+{
+ char x;
+ if (!a_Buffer.ReadChar(x))
+ {
+ return false;
+ }
+ a_Metadata.push_back(x);
+ while (x != 0x7f)
+ {
+ int Index = ((unsigned)((unsigned char)x)) & 0x1f; // Lower 5 bits = index
+ int Type = ((unsigned)((unsigned char)x)) >> 5; // Upper 3 bits = type
+ int Length = 0;
+ switch (Type)
+ {
+ case 0: Length = 1; break; // byte
+ case 1: Length = 2; break; // short
+ case 2: Length = 4; break; // int
+ case 3: Length = 4; break; // float
+ case 4: // string16
+ {
+ short Len = 0;
+ if (!a_Buffer.ReadBEShort(Len))
+ {
+ return false;
+ }
+ short NetLen = htons(Len);
+ a_Metadata.append((char *)&NetLen, 2);
+ Length = Len;
+ break;
+ }
+ case 5:
+ {
+ int Before = a_Buffer.GetReadableSpace();
+ AString ItemDesc;
+ if (!ParseSlot(a_Buffer, ItemDesc))
+ {
+ return false;
+ }
+ int After = a_Buffer.GetReadableSpace();
+ a_Buffer.ResetRead();
+ a_Buffer.SkipRead(a_Buffer.GetReadableSpace() - Before);
+ Length = Before - After;
+ break;
+ }
+ case 6: Length = 12; break; // 3 * int
+ default:
+ {
+ ASSERT(!"Unknown metadata type");
+ break;
+ }
+ } // switch (Type)
+ AString data;
+ if (!a_Buffer.ReadString(data, Length))
+ {
+ return false;
+ }
+ a_Metadata.append(data);
+ if (!a_Buffer.ReadChar(x))
+ {
+ return false;
+ }
+ a_Metadata.push_back(x);
+ } // while (x != 0x7f)
+ return true;
+}
+
+
+
+
+
+void cConnection::LogMetadata(const AString & a_Metadata, size_t a_IndentCount)
+{
+ AString Indent(a_IndentCount, ' ');
+ int pos = 0;
+ while (a_Metadata[pos] != 0x7f)
+ {
+ int Index = ((unsigned)((unsigned char)a_Metadata[pos])) & 0x1f; // Lower 5 bits = index
+ int Type = ((unsigned)((unsigned char)a_Metadata[pos])) >> 5; // Upper 3 bits = type
+ int Length = 0;
+ switch (Type)
+ {
+ case 0:
+ {
+ Log("%sbyte[%d] = %d", Indent.c_str(), Index, a_Metadata[pos + 1]);
+ pos += 1;
+ break;
+ }
+ case 1:
+ {
+ Log("%sshort[%d] = %d", Indent.c_str(), Index, (a_Metadata[pos + 1] << 8) | a_Metadata[pos + 2]);
+ pos += 2;
+ break;
+ }
+ case 2:
+ {
+ Log("%sint[%d] = %d", Indent.c_str(), Index, (a_Metadata[pos + 1] << 24) | (a_Metadata[pos + 2] << 16) | (a_Metadata[pos + 3] << 8) | a_Metadata[pos + 4]);
+ pos += 4;
+ break;
+ }
+ case 3:
+ {
+ Log("%sfloat[%d] = 0x%x", Indent.c_str(), Index, (a_Metadata[pos + 1] << 24) | (a_Metadata[pos + 2] << 16) | (a_Metadata[pos + 3] << 8) | a_Metadata[pos + 4]);
+ pos += 4;
+ break;
+ }
+ case 4: // string16
+ {
+ short Length = (a_Metadata[pos + 1] << 8) | a_Metadata[pos + 2];
+ Log("%sstring[%d] = \"%*s\"", Indent.c_str(), Index, Length, a_Metadata.c_str() + pos + 3);
+ pos += Length + 2;
+ break;
+ }
+ case 5:
+ {
+ int BytesLeft = a_Metadata.size() - pos - 1;
+ cByteBuffer bb(BytesLeft);
+ bb.Write(a_Metadata.data() + pos + 1, BytesLeft);
+ AString ItemDesc;
+ if (!ParseSlot(bb, ItemDesc))
+ {
+ ASSERT(!"Cannot parse item description from metadata");
+ return;
+ }
+ int After = bb.GetReadableSpace();
+ int BytesConsumed = BytesLeft - bb.GetReadableSpace();
+
+ Log("%sslot[%d] = %s (%d bytes)", Indent.c_str(), Index, ItemDesc.c_str(), BytesConsumed);
+ pos += BytesConsumed;
+ break;
+ }
+ case 6:
+ {
+ Log("%spos[%d] = <%d, %d, %d>", Indent.c_str(), Index,
+ (a_Metadata[pos + 1] << 24) | (a_Metadata[pos + 2] << 16) | (a_Metadata[pos + 3] << 8) | a_Metadata[pos + 4],
+ (a_Metadata[pos + 5] << 24) | (a_Metadata[pos + 6] << 16) | (a_Metadata[pos + 7] << 8) | a_Metadata[pos + 8],
+ (a_Metadata[pos + 9] << 24) | (a_Metadata[pos + 10] << 16) | (a_Metadata[pos + 11] << 8) | a_Metadata[pos + 12]
+ );
+ pos += 12;
+ break;
+ }
+ default:
+ {
+ ASSERT(!"Unknown metadata type");
+ break;
+ }
+ } // switch (Type)
+ pos += 1;
+ } // while (x != 0x7f)
+}
+
+
+
+
+
+void cConnection::SendEncryptionKeyResponse(const AString & a_ServerPublicKey, const AString & a_Nonce)
+{
+ // Generate the shared secret and encrypt using the server's public key
+ byte SharedSecret[16];
+ byte EncryptedSecret[128];
+ memset(SharedSecret, 0, sizeof(SharedSecret)); // Use all zeroes for the initial secret
+ RSA::PublicKey pk;
+ CryptoPP::StringSource src(a_ServerPublicKey, true);
+ ByteQueue bq;
+ src.TransferTo(bq);
+ bq.MessageEnd();
+ pk.Load(bq);
+ RSAES<PKCS1v15>::Encryptor rsaEncryptor(pk);
+ RandomPool rng;
+ time_t CurTime = time(NULL);
+ rng.Put((const byte *)&CurTime, sizeof(CurTime));
+ int EncryptedLength = rsaEncryptor.FixedCiphertextLength();
+ ASSERT(EncryptedLength <= sizeof(EncryptedSecret));
+ rsaEncryptor.Encrypt(rng, SharedSecret, sizeof(SharedSecret), EncryptedSecret);
+ m_ServerEncryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
+ m_ServerDecryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
+
+ // Encrypt the nonce:
+ byte EncryptedNonce[128];
+ rsaEncryptor.Encrypt(rng, (const byte *)(a_Nonce.data()), a_Nonce.size(), EncryptedNonce);
+
+ // Send the packet to the server:
+ Log("Sending PACKET_ENCRYPTION_KEY_RESPONSE to the SERVER");
+ cByteBuffer ToServer(1024);
+ ToServer.WriteByte(PACKET_ENCRYPTION_KEY_RESPONSE);
+ ToServer.WriteBEShort(EncryptedLength);
+ ToServer.WriteBuf(EncryptedSecret, EncryptedLength);
+ ToServer.WriteBEShort(EncryptedLength);
+ ToServer.WriteBuf(EncryptedNonce, EncryptedLength);
+ SERVERSEND(ToServer);
+ m_ServerState = csWaitingForEncryption;
+}
+
+
+
+
+
+void cConnection::StartClientEncryption(const AString & a_EncKey, const AString & a_EncNonce)
+{
+ // Decrypt EncNonce using privkey
+ RSAES<PKCS1v15>::Decryptor rsaDecryptor(m_Server.GetPrivateKey());
+ time_t CurTime = time(NULL);
+ RandomPool rng;
+ rng.Put((const byte *)&CurTime, sizeof(CurTime));
+ byte DecryptedNonce[MAX_ENC_LEN];
+ DecodingResult res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncNonce.data(), a_EncNonce.size(), DecryptedNonce);
+ if (!res.isValidCoding || (res.messageLength != 4))
+ {
+ Log("Client: Bad nonce length");
+ return;
+ }
+ if (ntohl(*((int *)DecryptedNonce)) != m_Nonce)
+ {
+ Log("Bad nonce value");
+ return;
+ }
+
+ // Decrypt the symmetric encryption key using privkey:
+ byte SharedSecret[MAX_ENC_LEN];
+ res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncKey.data(), a_EncKey.size(), SharedSecret);
+ if (!res.isValidCoding || (res.messageLength != 16))
+ {
+ Log("Bad key length");
+ return;
+ }
+
+ // Send encryption key response:
+ cByteBuffer ToClient(6);
+ ToClient.WriteByte((char)0xfc);
+ ToClient.WriteBEShort(0);
+ ToClient.WriteBEShort(0);
+ CLIENTSEND(ToClient);
+
+ // Start the encryption:
+ m_ClientEncryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
+ m_ClientDecryptor.SetKey(SharedSecret, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(SharedSecret, 16))(Name::FeedbackSize(), 1));
+ Log("Client connection is now encrypted");
+ m_ClientState = csEncryptedUnderstood;
+
+ // Send the queued data:
+ DataLog(m_ClientEncryptionBuffer.data(), m_ClientEncryptionBuffer.size(), "Sending the queued data to client (%u bytes):", m_ClientEncryptionBuffer.size());
+ CLIENTENCRYPTSEND(m_ClientEncryptionBuffer.data(), m_ClientEncryptionBuffer.size());
+ m_ClientEncryptionBuffer.clear();
+
+ // Handle all postponed server data
+ DecodeServersPackets(NULL, 0);
+}
+
+
+
+
diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h
index 7f3a6f8bb..942ee6e06 100644
--- a/Tools/ProtoProxy/Connection.h
+++ b/Tools/ProtoProxy/Connection.h
@@ -1,202 +1,206 @@
-
-// Connection.h
-
-// Interfaces to the cConnection class representing a single pair of connected sockets
-
-
-
-
-
-#pragma once
-
-#include <time.h>
-#include "ByteBuffer.h"
-
-
-
-
-
-class cServer;
-
-
-
-
-
-class cConnection
-{
- AString m_LogNameBase; ///< Base for the log filename and all files connected to this log
-
- int m_ItemIdx; ///< Index for the next file into which item metadata should be written (ParseSlot() function)
-
- cCriticalSection m_CSLog;
- FILE * m_LogFile;
-
- cServer & m_Server;
- SOCKET m_ClientSocket;
- SOCKET m_ServerSocket;
-
- clock_t m_BeginTick; // Tick when the relative time was first retrieved (used for GetRelativeTime())
-
- enum eConnectionState
- {
- csUnencrypted, // The connection is not encrypted. Packets must be decoded in order to be able to start decryption.
- csEncryptedUnderstood, // The communication is encrypted and so far all packets have been understood, so they can be still decoded
- csEncryptedUnknown, // The communication is encrypted, but an unknown packet has been received, so packets cannot be decoded anymore
- };
-
- eConnectionState m_ClientState;
- eConnectionState m_ServerState;
-
- int m_Nonce;
-
-public:
- cConnection(SOCKET a_ClientSocket, cServer & a_Server);
- ~cConnection();
-
- void Run(void);
-
- void Log(const char * a_Format, ...);
- void DataLog(const void * a_Data, int a_Size, const char * a_Format, ...);
- void LogFlush(void);
-
-protected:
- typedef CFB_Mode<AES>::Encryption Encryptor;
- typedef CFB_Mode<AES>::Decryption Decryptor;
-
- cByteBuffer m_ClientBuffer;
- cByteBuffer m_ServerBuffer;
-
- Decryptor m_ServerDecryptor;
- Encryptor m_ServerEncryptor;
-
- Decryptor m_ClientDecryptor;
- Encryptor m_ClientEncryptor;
-
- /// Set to true when PACKET_PING is received from the client; will cause special parsing for server kick
- bool m_HasClientPinged;
-
- bool ConnectToServer(void);
-
- /// Relays data from server to client; returns false if connection aborted
- bool RelayFromServer(void);
-
- /// Relays data from client to server; returns false if connection aborted
- bool RelayFromClient(void);
-
- /// Returns the time relative to the first call of this function, in the fractional seconds elapsed
- double GetRelativeTime(void);
-
- /// Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false.
- bool SendData(SOCKET a_Socket, const char * a_Data, int a_Size, const char * a_Peer);
-
- /// Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false.
- bool SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a_Peer);
-
- /// Sends data to the specfied socket, after encrypting it using a_Encryptor. If sending fails, prints a fail message using a_Peer and returns false
- bool SendEncryptedData(SOCKET a_Socket, Encryptor & a_Encryptor, const char * a_Data, int a_Size, const char * a_Peer);
-
- /// Sends data to the specfied socket, after encrypting it using a_Encryptor. If sending fails, prints a fail message using a_Peer and returns false
- bool SendEncryptedData(SOCKET a_Socket, Encryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer);
-
- /// Decodes packets coming from the client, sends appropriate counterparts to the server; returns false if the connection is to be dropped
- bool DecodeClientsPackets(const char * a_Data, int a_Size);
-
- /// Decodes packets coming from the server, sends appropriate counterparts to the client; returns false if the connection is to be dropped
- bool DecodeServersPackets(const char * a_Data, int a_Size);
-
- // Packet handling, client-side:
- bool HandleClientAnimation(void);
- bool HandleClientBlockDig(void);
- bool HandleClientBlockPlace(void);
- bool HandleClientChatMessage(void);
- bool HandleClientClientStatuses(void);
- bool HandleClientCreativeInventoryAction(void);
- bool HandleClientEncryptionKeyResponse(void);
- bool HandleClientEntityAction(void);
- bool HandleClientHandshake(void);
- bool HandleClientKeepAlive(void);
- bool HandleClientLocaleAndView(void);
- bool HandleClientPing(void);
- bool HandleClientPlayerAbilities(void);
- bool HandleClientPlayerLook(void);
- bool HandleClientPlayerOnGround(void);
- bool HandleClientPlayerPosition(void);
- bool HandleClientPlayerPositionLook(void);
- bool HandleClientPluginMessage(void);
- bool HandleClientSlotSelect(void);
- bool HandleClientUpdateSign(void);
- bool HandleClientUseEntity(void);
- bool HandleClientWindowClick(void);
- bool HandleClientWindowClose(void);
-
- // Packet handling, server-side:
- bool HandleServerAttachEntity(void);
- bool HandleServerBlockAction(void);
- bool HandleServerBlockChange(void);
- bool HandleServerChangeGameState(void);
- bool HandleServerChatMessage(void);
- bool HandleServerCollectPickup(void);
- bool HandleServerCompass(void);
- bool HandleServerDestroyEntities(void);
- bool HandleServerEncryptionKeyRequest(void);
- bool HandleServerEncryptionKeyResponse(void);
- bool HandleServerEntity(void);
- bool HandleServerEntityEquipment(void);
- bool HandleServerEntityHeadLook(void);
- bool HandleServerEntityLook(void);
- bool HandleServerEntityMetadata(void);
- bool HandleServerEntityProperties(void);
- bool HandleServerEntityRelativeMove(void);
- bool HandleServerEntityRelativeMoveLook(void);
- bool HandleServerEntityStatus(void);
- bool HandleServerEntityTeleport(void);
- bool HandleServerEntityVelocity(void);
- bool HandleServerIncrementStatistic(void);
- bool HandleServerKeepAlive(void);
- bool HandleServerKick(void);
- bool HandleServerLogin(void);
- bool HandleServerMapChunk(void);
- bool HandleServerMapChunkBulk(void);
- bool HandleServerMultiBlockChange(void);
- bool HandleServerNamedSoundEffect(void);
- bool HandleServerPlayerAbilities(void);
- bool HandleServerPlayerAnimation(void);
- bool HandleServerPlayerListItem(void);
- bool HandleServerPlayerPositionLook(void);
- bool HandleServerPluginMessage(void);
- bool HandleServerSetExperience(void);
- bool HandleServerSetSlot(void);
- bool HandleServerSlotSelect(void);
- bool HandleServerSoundEffect(void);
- bool HandleServerSpawnMob(void);
- bool HandleServerSpawnNamedEntity(void);
- bool HandleServerSpawnObjectVehicle(void);
- bool HandleServerSpawnPainting(void);
- bool HandleServerSpawnPickup(void);
- bool HandleServerTimeUpdate(void);
- bool HandleServerUpdateHealth(void);
- bool HandleServerUpdateSign(void);
- bool HandleServerUpdateTileEntity(void);
- bool HandleServerWindowClose(void);
- bool HandleServerWindowContents(void);
- bool HandleServerWindowOpen(void);
-
- /// Parses the slot data in a_Buffer into item description; returns true if successful, false if not enough data
- bool ParseSlot(cByteBuffer & a_Buffer, AString & a_ItemDesc);
-
- /// Parses the metadata in a_Buffer into raw metadata in an AString; returns true if successful, false if not enough data
- bool ParseMetadata(cByteBuffer & a_Buffer, AString & a_Metadata);
-
- /// Logs the contents of the metadata in the AString, using Log(). Assumes a_Metadata is valid (parsed by ParseMetadata()). The log is indented by a_IndentCount spaces
- void LogMetadata(const AString & a_Metadata, size_t a_IndentCount);
-
- /// Send EKResp to the server:
- void SendEncryptionKeyResponse(const AString & a_ServerPublicKey, const AString & a_Nonce);
-
- /// Starts client encryption based on the parameters received
- void StartClientEncryption(const AString & a_EncryptedSecret, const AString & a_EncryptedNonce);
-} ;
-
-
-
-
+
+// Connection.h
+
+// Interfaces to the cConnection class representing a single pair of connected sockets
+
+
+
+
+
+#pragma once
+
+#include <time.h>
+#include "ByteBuffer.h"
+
+
+
+
+
+class cServer;
+
+
+
+
+
+class cConnection
+{
+ AString m_LogNameBase; ///< Base for the log filename and all files connected to this log
+
+ int m_ItemIdx; ///< Index for the next file into which item metadata should be written (ParseSlot() function)
+
+ cCriticalSection m_CSLog;
+ FILE * m_LogFile;
+
+ cServer & m_Server;
+ SOCKET m_ClientSocket;
+ SOCKET m_ServerSocket;
+
+ clock_t m_BeginTick; // Tick when the relative time was first retrieved (used for GetRelativeTime())
+
+ enum eConnectionState
+ {
+ csUnencrypted, // The connection is not encrypted. Packets must be decoded in order to be able to start decryption.
+ csEncryptedUnderstood, // The communication is encrypted and so far all packets have been understood, so they can be still decoded
+ csEncryptedUnknown, // The communication is encrypted, but an unknown packet has been received, so packets cannot be decoded anymore
+ csWaitingForEncryption, // The communication is waiting for the other line to establish encryption
+ };
+
+ eConnectionState m_ClientState;
+ eConnectionState m_ServerState;
+
+ int m_Nonce;
+
+public:
+ cConnection(SOCKET a_ClientSocket, cServer & a_Server);
+ ~cConnection();
+
+ void Run(void);
+
+ void Log(const char * a_Format, ...);
+ void DataLog(const void * a_Data, int a_Size, const char * a_Format, ...);
+ void LogFlush(void);
+
+protected:
+ typedef CFB_Mode<AES>::Encryption Encryptor;
+ typedef CFB_Mode<AES>::Decryption Decryptor;
+
+ cByteBuffer m_ClientBuffer;
+ cByteBuffer m_ServerBuffer;
+
+ Decryptor m_ServerDecryptor;
+ Encryptor m_ServerEncryptor;
+
+ Decryptor m_ClientDecryptor;
+ Encryptor m_ClientEncryptor;
+
+ AString m_ClientEncryptionBuffer; // Buffer for the data to be sent to the client once encryption is established
+ AString m_ServerEncryptionBuffer; // Buffer for the data to be sent to the server once encryption is established
+
+ /// Set to true when PACKET_PING is received from the client; will cause special parsing for server kick
+ bool m_HasClientPinged;
+
+ bool ConnectToServer(void);
+
+ /// Relays data from server to client; returns false if connection aborted
+ bool RelayFromServer(void);
+
+ /// Relays data from client to server; returns false if connection aborted
+ bool RelayFromClient(void);
+
+ /// Returns the time relative to the first call of this function, in the fractional seconds elapsed
+ double GetRelativeTime(void);
+
+ /// Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false.
+ bool SendData(SOCKET a_Socket, const char * a_Data, int a_Size, const char * a_Peer);
+
+ /// Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false.
+ bool SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a_Peer);
+
+ /// Sends data to the specfied socket, after encrypting it using a_Encryptor. If sending fails, prints a fail message using a_Peer and returns false
+ bool SendEncryptedData(SOCKET a_Socket, Encryptor & a_Encryptor, const char * a_Data, int a_Size, const char * a_Peer);
+
+ /// Sends data to the specfied socket, after encrypting it using a_Encryptor. If sending fails, prints a fail message using a_Peer and returns false
+ bool SendEncryptedData(SOCKET a_Socket, Encryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer);
+
+ /// Decodes packets coming from the client, sends appropriate counterparts to the server; returns false if the connection is to be dropped
+ bool DecodeClientsPackets(const char * a_Data, int a_Size);
+
+ /// Decodes packets coming from the server, sends appropriate counterparts to the client; returns false if the connection is to be dropped
+ bool DecodeServersPackets(const char * a_Data, int a_Size);
+
+ // Packet handling, client-side:
+ bool HandleClientAnimation(void);
+ bool HandleClientBlockDig(void);
+ bool HandleClientBlockPlace(void);
+ bool HandleClientChatMessage(void);
+ bool HandleClientClientStatuses(void);
+ bool HandleClientCreativeInventoryAction(void);
+ bool HandleClientEncryptionKeyResponse(void);
+ bool HandleClientEntityAction(void);
+ bool HandleClientHandshake(void);
+ bool HandleClientKeepAlive(void);
+ bool HandleClientLocaleAndView(void);
+ bool HandleClientPing(void);
+ bool HandleClientPlayerAbilities(void);
+ bool HandleClientPlayerLook(void);
+ bool HandleClientPlayerOnGround(void);
+ bool HandleClientPlayerPosition(void);
+ bool HandleClientPlayerPositionLook(void);
+ bool HandleClientPluginMessage(void);
+ bool HandleClientSlotSelect(void);
+ bool HandleClientUpdateSign(void);
+ bool HandleClientUseEntity(void);
+ bool HandleClientWindowClick(void);
+ bool HandleClientWindowClose(void);
+
+ // Packet handling, server-side:
+ bool HandleServerAttachEntity(void);
+ bool HandleServerBlockAction(void);
+ bool HandleServerBlockChange(void);
+ bool HandleServerChangeGameState(void);
+ bool HandleServerChatMessage(void);
+ bool HandleServerCollectPickup(void);
+ bool HandleServerCompass(void);
+ bool HandleServerDestroyEntities(void);
+ bool HandleServerEncryptionKeyRequest(void);
+ bool HandleServerEncryptionKeyResponse(void);
+ bool HandleServerEntity(void);
+ bool HandleServerEntityEquipment(void);
+ bool HandleServerEntityHeadLook(void);
+ bool HandleServerEntityLook(void);
+ bool HandleServerEntityMetadata(void);
+ bool HandleServerEntityProperties(void);
+ bool HandleServerEntityRelativeMove(void);
+ bool HandleServerEntityRelativeMoveLook(void);
+ bool HandleServerEntityStatus(void);
+ bool HandleServerEntityTeleport(void);
+ bool HandleServerEntityVelocity(void);
+ bool HandleServerIncrementStatistic(void);
+ bool HandleServerKeepAlive(void);
+ bool HandleServerKick(void);
+ bool HandleServerLogin(void);
+ bool HandleServerMapChunk(void);
+ bool HandleServerMapChunkBulk(void);
+ bool HandleServerMultiBlockChange(void);
+ bool HandleServerNamedSoundEffect(void);
+ bool HandleServerPlayerAbilities(void);
+ bool HandleServerPlayerAnimation(void);
+ bool HandleServerPlayerListItem(void);
+ bool HandleServerPlayerPositionLook(void);
+ bool HandleServerPluginMessage(void);
+ bool HandleServerSetExperience(void);
+ bool HandleServerSetSlot(void);
+ bool HandleServerSlotSelect(void);
+ bool HandleServerSoundEffect(void);
+ bool HandleServerSpawnMob(void);
+ bool HandleServerSpawnNamedEntity(void);
+ bool HandleServerSpawnObjectVehicle(void);
+ bool HandleServerSpawnPainting(void);
+ bool HandleServerSpawnPickup(void);
+ bool HandleServerTimeUpdate(void);
+ bool HandleServerUpdateHealth(void);
+ bool HandleServerUpdateSign(void);
+ bool HandleServerUpdateTileEntity(void);
+ bool HandleServerWindowClose(void);
+ bool HandleServerWindowContents(void);
+ bool HandleServerWindowOpen(void);
+
+ /// Parses the slot data in a_Buffer into item description; returns true if successful, false if not enough data
+ bool ParseSlot(cByteBuffer & a_Buffer, AString & a_ItemDesc);
+
+ /// Parses the metadata in a_Buffer into raw metadata in an AString; returns true if successful, false if not enough data
+ bool ParseMetadata(cByteBuffer & a_Buffer, AString & a_Metadata);
+
+ /// Logs the contents of the metadata in the AString, using Log(). Assumes a_Metadata is valid (parsed by ParseMetadata()). The log is indented by a_IndentCount spaces
+ void LogMetadata(const AString & a_Metadata, size_t a_IndentCount);
+
+ /// Send EKResp to the server:
+ void SendEncryptionKeyResponse(const AString & a_ServerPublicKey, const AString & a_Nonce);
+
+ /// Starts client encryption based on the parameters received
+ void StartClientEncryption(const AString & a_EncryptedSecret, const AString & a_EncryptedNonce);
+} ;
+
+
+
+
diff --git a/Tools/ProtoProxy/Globals.cpp b/Tools/ProtoProxy/Globals.cpp
index 2c60fd698..13c6ae709 100644
--- a/Tools/ProtoProxy/Globals.cpp
+++ b/Tools/ProtoProxy/Globals.cpp
@@ -1,10 +1,10 @@
-
-// Globals.cpp
-
-// This file is used for precompiled header generation in MSVC environments
-
-#include "Globals.h"
-
-
-
-
+
+// Globals.cpp
+
+// This file is used for precompiled header generation in MSVC environments
+
+#include "Globals.h"
+
+
+
+
diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h
index 404044a5f..f2c47e96f 100644
--- a/Tools/ProtoProxy/Globals.h
+++ b/Tools/ProtoProxy/Globals.h
@@ -1,221 +1,221 @@
-
-// Globals.h
-
-// This file gets included from every module in the project, so that global symbols may be introduced easily
-// Also used for precompiled header generation in MSVC environments
-
-
-
-
-
-// Compiler-dependent stuff:
-#if defined(_MSC_VER)
- // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
- #pragma warning(disable:4481)
-
- // Disable some warnings that we don't care about:
- #pragma warning(disable:4100)
-
- #define OBSOLETE __declspec(deprecated)
-
- // No alignment needed in MSVC
- #define ALIGN_8
- #define ALIGN_16
-
-#elif defined(__GNUC__)
-
- // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
- #define abstract
-
- // TODO: Can GCC mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
- #define override
-
- #define OBSOLETE __attribute__((deprecated))
-
- #define ALIGN_8 __attribute__((aligned(8)))
- #define ALIGN_16 __attribute__((aligned(16)))
-
- // Some portability macros :)
- #define stricmp strcasecmp
-
-#else
-
- #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
-
- /*
- // Copy and uncomment this into another #elif section based on your compiler identification
-
- // Explicitly mark classes as abstract (no instances can be created)
- #define abstract
-
- // Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
- #define override
-
- // Mark functions as obsolete, so that their usage results in a compile-time warning
- #define OBSOLETE
-
- // Mark types / variables for alignment. Do the platforms need it?
- #define ALIGN_8
- #define ALIGN_16
- */
-
-#endif
-
-
-
-
-
-// Integral types with predefined sizes:
-typedef long long Int64;
-typedef int Int32;
-typedef short Int16;
-
-
-
-
-
-// A macro to disallow the copy constructor and operator= functions
-// This should be used in the private: declarations for any class that shouldn't allow copying itself
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName &); \
- void operator=(const TypeName &)
-
-// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
-#define UNUSED(X) (void)(X)
-
-
-
-
-// OS-dependent stuff:
-#ifdef _WIN32
- #define WIN32_LEAN_AND_MEAN
- #include <Windows.h>
- #include <winsock2.h>
-
- // Windows SDK defines min and max macros, messing up with our std::min and std::max usage
- #undef min
- #undef max
-
- // Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant
- #ifdef GetFreeSpace
- #undef GetFreeSpace
- #endif // GetFreeSpace
-#else
- #include <sys/types.h>
- #include <sys/stat.h> // for mkdir
- #include <sys/time.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <time.h>
- #include <dirent.h>
- #include <errno.h>
- #include <iostream>
-
- #include <cstdio>
- #include <cstring>
- #include <pthread.h>
- #include <semaphore.h>
- #include <errno.h>
- #include <fcntl.h>
-#if !defined(ANDROID_NDK)
- #include <tr1/memory>
-#endif
-#endif
-
-#if !defined(ANDROID_NDK)
- #define USE_SQUIRREL
-#endif
-
-#if defined(ANDROID_NDK)
- #define FILE_IO_PREFIX "/sdcard/mcserver/"
-#else
- #define FILE_IO_PREFIX ""
-#endif
-
-
-
-
-
-// CRT stuff:
-#include <assert.h>
-#include <stdio.h>
-#include <math.h>
-#include <stdarg.h>
-
-
-
-
-
-// STL stuff:
-#include <vector>
-#include <list>
-#include <deque>
-#include <string>
-#include <map>
-#include <algorithm>
-#include <memory>
-
-
-
-
-
-// Common headers (part 1, without macros):
-#include "StringUtils.h"
-#include "OSSupport/CriticalSection.h"
-
-
-
-
-
-// Common definitions:
-
-/// 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)" )
-#define KiB * 1024
-
-/// Faster than (int)floorf((float)x / (float)div)
-#define FAST_FLOOR_DIV( x, div ) ( (x) < 0 ? (((int)x / div) - 1) : ((int)x / div) )
-
-// Own version of assert() that writes failed assertions to the log for review
-#ifdef NDEBUG
- #define ASSERT(x) ((void)0)
-#else
- #define ASSERT assert
-#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 ) )
-
-
-
-
-
-/// A generic interface used mainly in ForEach() functions
-template <typename Type> class cItemCallback
-{
-public:
- /// Called for each item in the internal list; return true to stop the loop, or false to continue enumerating
- virtual bool Item(Type * a_Type) = 0;
-} ;
-
-
-
-
-
-#include "CryptoPP/randpool.h"
-#include "CryptoPP/aes.h"
-#include "CryptoPP/rsa.h"
-#include "CryptoPP/modes.h"
-
-using namespace CryptoPP;
-
-
-
-
-#define LOGERROR printf
-#define LOGINFO printf
+
+// Globals.h
+
+// This file gets included from every module in the project, so that global symbols may be introduced easily
+// Also used for precompiled header generation in MSVC environments
+
+
+
+
+
+// Compiler-dependent stuff:
+#if defined(_MSC_VER)
+ // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
+ #pragma warning(disable:4481)
+
+ // Disable some warnings that we don't care about:
+ #pragma warning(disable:4100)
+
+ #define OBSOLETE __declspec(deprecated)
+
+ // No alignment needed in MSVC
+ #define ALIGN_8
+ #define ALIGN_16
+
+#elif defined(__GNUC__)
+
+ // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
+ #define abstract
+
+ // TODO: Can GCC mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
+ #define override
+
+ #define OBSOLETE __attribute__((deprecated))
+
+ #define ALIGN_8 __attribute__((aligned(8)))
+ #define ALIGN_16 __attribute__((aligned(16)))
+
+ // Some portability macros :)
+ #define stricmp strcasecmp
+
+#else
+
+ #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
+
+ /*
+ // Copy and uncomment this into another #elif section based on your compiler identification
+
+ // Explicitly mark classes as abstract (no instances can be created)
+ #define abstract
+
+ // Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
+ #define override
+
+ // Mark functions as obsolete, so that their usage results in a compile-time warning
+ #define OBSOLETE
+
+ // Mark types / variables for alignment. Do the platforms need it?
+ #define ALIGN_8
+ #define ALIGN_16
+ */
+
+#endif
+
+
+
+
+
+// Integral types with predefined sizes:
+typedef long long Int64;
+typedef int Int32;
+typedef short Int16;
+
+
+
+
+
+// A macro to disallow the copy constructor and operator= functions
+// This should be used in the private: declarations for any class that shouldn't allow copying itself
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName &); \
+ void operator=(const TypeName &)
+
+// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
+#define UNUSED(X) (void)(X)
+
+
+
+
+// OS-dependent stuff:
+#ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <Windows.h>
+ #include <winsock2.h>
+
+ // Windows SDK defines min and max macros, messing up with our std::min and std::max usage
+ #undef min
+ #undef max
+
+ // Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant
+ #ifdef GetFreeSpace
+ #undef GetFreeSpace
+ #endif // GetFreeSpace
+#else
+ #include <sys/types.h>
+ #include <sys/stat.h> // for mkdir
+ #include <sys/time.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <netdb.h>
+ #include <time.h>
+ #include <dirent.h>
+ #include <errno.h>
+ #include <iostream>
+
+ #include <cstdio>
+ #include <cstring>
+ #include <pthread.h>
+ #include <semaphore.h>
+ #include <errno.h>
+ #include <fcntl.h>
+#if !defined(ANDROID_NDK)
+ #include <tr1/memory>
+#endif
+#endif
+
+#if !defined(ANDROID_NDK)
+ #define USE_SQUIRREL
+#endif
+
+#if defined(ANDROID_NDK)
+ #define FILE_IO_PREFIX "/sdcard/mcserver/"
+#else
+ #define FILE_IO_PREFIX ""
+#endif
+
+
+
+
+
+// CRT stuff:
+#include <assert.h>
+#include <stdio.h>
+#include <math.h>
+#include <stdarg.h>
+
+
+
+
+
+// STL stuff:
+#include <vector>
+#include <list>
+#include <deque>
+#include <string>
+#include <map>
+#include <algorithm>
+#include <memory>
+
+
+
+
+
+// Common headers (part 1, without macros):
+#include "StringUtils.h"
+#include "OSSupport/CriticalSection.h"
+
+
+
+
+
+// Common definitions:
+
+/// 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)" )
+#define KiB * 1024
+
+/// Faster than (int)floorf((float)x / (float)div)
+#define FAST_FLOOR_DIV( x, div ) ( (x) < 0 ? (((int)x / div) - 1) : ((int)x / div) )
+
+// Own version of assert() that writes failed assertions to the log for review
+#ifdef NDEBUG
+ #define ASSERT(x) ((void)0)
+#else
+ #define ASSERT assert
+#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 ) )
+
+
+
+
+
+/// A generic interface used mainly in ForEach() functions
+template <typename Type> class cItemCallback
+{
+public:
+ /// Called for each item in the internal list; return true to stop the loop, or false to continue enumerating
+ virtual bool Item(Type * a_Type) = 0;
+} ;
+
+
+
+
+
+#include "CryptoPP/randpool.h"
+#include "CryptoPP/aes.h"
+#include "CryptoPP/rsa.h"
+#include "CryptoPP/modes.h"
+
+using namespace CryptoPP;
+
+
+
+
+#define LOGERROR printf
+#define LOGINFO printf
#define LOGWARNING printf \ No newline at end of file
diff --git a/Tools/ProtoProxy/ProtoProxy.cpp b/Tools/ProtoProxy/ProtoProxy.cpp
index 0d61835e7..2724ef704 100644
--- a/Tools/ProtoProxy/ProtoProxy.cpp
+++ b/Tools/ProtoProxy/ProtoProxy.cpp
@@ -1,32 +1,32 @@
-
-// ProtoProxy.cpp
-
-// Implements the main app entrypoint
-
-#include "Globals.h"
-#include "Server.h"
-
-
-
-
-
-int main(int argc, char ** argv)
-{
- int ListenPort = (argc > 1) ? atoi(argv[1]) : 25564;
- int ConnectPort = (argc > 2) ? atoi(argv[2]) : 25565;
- cServer Server;
- int res = Server.Init(ListenPort, ConnectPort);
- if (res != 0)
- {
- printf("Server initialization failed: %d", res);
- return res;
- }
-
- Server.Run();
-
- return 0;
-}
-
-
-
-
+
+// ProtoProxy.cpp
+
+// Implements the main app entrypoint
+
+#include "Globals.h"
+#include "Server.h"
+
+
+
+
+
+int main(int argc, char ** argv)
+{
+ int ListenPort = (argc > 1) ? atoi(argv[1]) : 25564;
+ int ConnectPort = (argc > 2) ? atoi(argv[2]) : 25565;
+ cServer Server;
+ int res = Server.Init(ListenPort, ConnectPort);
+ if (res != 0)
+ {
+ printf("Server initialization failed: %d", res);
+ return res;
+ }
+
+ Server.Run();
+
+ return 0;
+}
+
+
+
+
diff --git a/Tools/ProtoProxy/ProtoProxy.sln b/Tools/ProtoProxy/ProtoProxy.sln
index 5488abd41..1c8c1a2a7 100644
--- a/Tools/ProtoProxy/ProtoProxy.sln
+++ b/Tools/ProtoProxy/ProtoProxy.sln
@@ -1,29 +1,29 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProtoProxy", "ProtoProxy.vcproj", "{EFEC8F76-1397-49A4-885B-314CB4244231}"
- ProjectSection(ProjectDependencies) = postProject
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CryptoPP", "..\..\VC2008\CryptoPP.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {EFEC8F76-1397-49A4-885B-314CB4244231}.Debug|Win32.ActiveCfg = Debug|Win32
- {EFEC8F76-1397-49A4-885B-314CB4244231}.Debug|Win32.Build.0 = Debug|Win32
- {EFEC8F76-1397-49A4-885B-314CB4244231}.Release|Win32.ActiveCfg = Release|Win32
- {EFEC8F76-1397-49A4-885B-314CB4244231}.Release|Win32.Build.0 = Release|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.ActiveCfg = Debug|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.Build.0 = Debug|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.ActiveCfg = Release|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProtoProxy", "ProtoProxy.vcproj", "{EFEC8F76-1397-49A4-885B-314CB4244231}"
+ ProjectSection(ProjectDependencies) = postProject
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CryptoPP", "..\..\VC2008\CryptoPP.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EFEC8F76-1397-49A4-885B-314CB4244231}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EFEC8F76-1397-49A4-885B-314CB4244231}.Debug|Win32.Build.0 = Debug|Win32
+ {EFEC8F76-1397-49A4-885B-314CB4244231}.Release|Win32.ActiveCfg = Release|Win32
+ {EFEC8F76-1397-49A4-885B-314CB4244231}.Release|Win32.Build.0 = Release|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.Build.0 = Debug|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.ActiveCfg = Release|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Tools/ProtoProxy/ProtoProxy.txt b/Tools/ProtoProxy/ProtoProxy.txt
index d232d41fd..e25d513f3 100644
--- a/Tools/ProtoProxy/ProtoProxy.txt
+++ b/Tools/ProtoProxy/ProtoProxy.txt
@@ -1,31 +1,31 @@
-
-// ProtoProxy.txt
-
-// A readme for the project
-
-/*
-ProtoProxy
-==========
-
-This is a project to create a proxy for the MineCraft protocol, allowing anyone to view the data sent over a network connection between a client and a server. This, in fact, performs a kind of Man-In-The-Middle (MITM) attack on the protocol by tapping in between the connection points and providing a decrypter and an encrypter for each.
-
-In order to catch the encryption parameters, the MC protocol needs to be understood at least a little bit at the beginning, when the cryptography parameters are exchanged.
-
-This project is currently Windows-only and I don't plan on making it multi-platform, although the effort needed for doing so should be minimal.
-
-The proxy only works on the localhost connection. It listens on port 25564 and expects the underlying MC server to run on port 25565. Ports can be changed by cmdline args: ProtoProxy <listen-port> <server-port>.
-
-You need to set the server *not* to verify usernames ("online-mode=false" in server.properties) in order to be able to connect through ProtoProxy - since the full server name, including the port, is used for verification, the client uses different servername than the server and thus the verification fails.
-
-
-
-ProtoProxy is not much dependent on the protocol - it will work with unknown packets, it just won't parse them into human-readable format.
-The latest protocol which has been tested is 1.6.1 (#73).
-
-
-*/
-
-
-
-
-
+
+// ProtoProxy.txt
+
+// A readme for the project
+
+/*
+ProtoProxy
+==========
+
+This is a project to create a proxy for the MineCraft protocol, allowing anyone to view the data sent over a network connection between a client and a server. This, in fact, performs a kind of Man-In-The-Middle (MITM) attack on the protocol by tapping in between the connection points and providing a decrypter and an encrypter for each.
+
+In order to catch the encryption parameters, the MC protocol needs to be understood at least a little bit at the beginning, when the cryptography parameters are exchanged.
+
+This project is currently Windows-only and I don't plan on making it multi-platform, although the effort needed for doing so should be minimal.
+
+The proxy only works on the localhost connection. It listens on port 25564 and expects the underlying MC server to run on port 25565. Ports can be changed by cmdline args: ProtoProxy <listen-port> <server-port>.
+
+You need to set the server *not* to verify usernames ("online-mode=false" in server.properties) in order to be able to connect through ProtoProxy - since the full server name, including the port, is used for verification, the client uses different servername than the server and thus the verification fails.
+
+
+
+ProtoProxy is not much dependent on the protocol - it will work with unknown packets, it just won't parse them into human-readable format.
+The latest protocol which has been tested is 1.6.1 (#73).
+
+
+*/
+
+
+
+
+
diff --git a/Tools/ProtoProxy/ProtoProxy.vcproj b/Tools/ProtoProxy/ProtoProxy.vcproj
index b7384ee8a..695e01e76 100644
--- a/Tools/ProtoProxy/ProtoProxy.vcproj
+++ b/Tools/ProtoProxy/ProtoProxy.vcproj
@@ -1,267 +1,267 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="ProtoProxy"
- ProjectGUID="{EFEC8F76-1397-49A4-885B-314CB4244231}"
- RootNamespace="ProtoProxy"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../..;../../source"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../..;../../source"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hpp"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\Connection.cpp"
- >
- </File>
- <File
- RelativePath=".\Connection.h"
- >
- </File>
- <File
- RelativePath=".\Globals.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\Globals.h"
- >
- </File>
- <File
- RelativePath=".\ProtoProxy.cpp"
- >
- </File>
- <File
- RelativePath=".\Server.cpp"
- >
- </File>
- <File
- RelativePath=".\Server.h"
- >
- </File>
- </Filter>
- <Filter
- Name="shared"
- >
- <File
- RelativePath="..\..\source\ByteBuffer.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\ByteBuffer.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.h"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.h"
- >
- </File>
- </Filter>
- <File
- RelativePath=".\ProtoProxy.txt"
- >
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="ProtoProxy"
+ ProjectGUID="{EFEC8F76-1397-49A4-885B-314CB4244231}"
+ RootNamespace="ProtoProxy"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../..;../../source"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="../..;../../source"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hpp"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\Connection.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Connection.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Globals.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\Globals.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ProtoProxy.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Server.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Server.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="shared"
+ >
+ <File
+ RelativePath="..\..\source\ByteBuffer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\ByteBuffer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.h"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\ProtoProxy.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Tools/ProtoProxy/Server.cpp b/Tools/ProtoProxy/Server.cpp
index 3d4913355..35732764c 100644
--- a/Tools/ProtoProxy/Server.cpp
+++ b/Tools/ProtoProxy/Server.cpp
@@ -1,82 +1,82 @@
-
-// Server.cpp
-
-// Interfaces to the cServer class encapsulating the entire "server"
-
-#include "Globals.h"
-#include "Server.h"
-#include "Connection.h"
-
-
-
-
-
-cServer::cServer(void)
-{
-}
-
-
-
-
-
-int cServer::Init(short a_ListenPort, short a_ConnectPort)
-{
- m_ConnectPort = a_ConnectPort;
- WSAData wsa;
- int res = WSAStartup(0x0202, &wsa);
- if (res != 0)
- {
- printf("Cannot initialize WinSock: %d\n", res);
- return res;
- }
-
- printf("Generating protocol encryption keypair...\n");
- time_t CurTime = time(NULL);
- RandomPool rng;
- rng.Put((const byte *)&CurTime, sizeof(CurTime));
- m_PrivateKey.GenerateRandomWithKeySize(rng, 1024);
- RSA::PublicKey pk(m_PrivateKey);
- m_PublicKey = pk;
-
- m_ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- sockaddr_in local;
- memset(&local, 0, sizeof(local));
- local.sin_family = AF_INET;
- local.sin_addr.s_addr = 0; // All interfaces
- local.sin_port = htons(a_ListenPort);
- bind(m_ListenSocket, (sockaddr *)&local, sizeof(local));
- listen(m_ListenSocket, 1);
-
- printf("Listening on port %d, connecting to localhost:%d\n", a_ListenPort, a_ConnectPort);
-
- return 0;
-}
-
-
-
-
-
-void cServer::Run(void)
-{
- printf("Server running.\n");
- while (true)
- {
- sockaddr_in Addr;
- ZeroMemory(&Addr, sizeof(Addr));
- int AddrSize = sizeof(Addr);
- SOCKET client = accept(m_ListenSocket, (sockaddr *)&Addr, &AddrSize);
- if (client == INVALID_SOCKET)
- {
- printf("accept returned an error: %d; bailing out.\n", WSAGetLastError());
- return;
- }
- printf("Client connected, proxying...\n");
- cConnection Connection(client, *this);
- Connection.Run();
- printf("Client disconnected. Ready for another connection.\n");
- }
-}
-
-
-
-
+
+// Server.cpp
+
+// Interfaces to the cServer class encapsulating the entire "server"
+
+#include "Globals.h"
+#include "Server.h"
+#include "Connection.h"
+
+
+
+
+
+cServer::cServer(void)
+{
+}
+
+
+
+
+
+int cServer::Init(short a_ListenPort, short a_ConnectPort)
+{
+ m_ConnectPort = a_ConnectPort;
+ WSAData wsa;
+ int res = WSAStartup(0x0202, &wsa);
+ if (res != 0)
+ {
+ printf("Cannot initialize WinSock: %d\n", res);
+ return res;
+ }
+
+ printf("Generating protocol encryption keypair...\n");
+ time_t CurTime = time(NULL);
+ RandomPool rng;
+ rng.Put((const byte *)&CurTime, sizeof(CurTime));
+ m_PrivateKey.GenerateRandomWithKeySize(rng, 1024);
+ RSA::PublicKey pk(m_PrivateKey);
+ m_PublicKey = pk;
+
+ m_ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ sockaddr_in local;
+ memset(&local, 0, sizeof(local));
+ local.sin_family = AF_INET;
+ local.sin_addr.s_addr = 0; // All interfaces
+ local.sin_port = htons(a_ListenPort);
+ bind(m_ListenSocket, (sockaddr *)&local, sizeof(local));
+ listen(m_ListenSocket, 1);
+
+ printf("Listening on port %d, connecting to localhost:%d\n", a_ListenPort, a_ConnectPort);
+
+ return 0;
+}
+
+
+
+
+
+void cServer::Run(void)
+{
+ printf("Server running.\n");
+ while (true)
+ {
+ sockaddr_in Addr;
+ ZeroMemory(&Addr, sizeof(Addr));
+ int AddrSize = sizeof(Addr);
+ SOCKET client = accept(m_ListenSocket, (sockaddr *)&Addr, &AddrSize);
+ if (client == INVALID_SOCKET)
+ {
+ printf("accept returned an error: %d; bailing out.\n", WSAGetLastError());
+ return;
+ }
+ printf("Client connected, proxying...\n");
+ cConnection Connection(client, *this);
+ Connection.Run();
+ printf("Client disconnected. Ready for another connection.\n");
+ }
+}
+
+
+
+
diff --git a/Tools/ProtoProxy/Server.h b/Tools/ProtoProxy/Server.h
index da64036b4..e69dbb5e0 100644
--- a/Tools/ProtoProxy/Server.h
+++ b/Tools/ProtoProxy/Server.h
@@ -1,38 +1,38 @@
-
-// Server.h
-
-// Interfaces to the cServer class encapsulating the entire "server"
-
-
-
-
-
-#pragma once
-
-
-
-
-
-
-class cServer
-{
- SOCKET m_ListenSocket;
- RSA::PrivateKey m_PrivateKey;
- RSA::PublicKey m_PublicKey;
- short m_ConnectPort;
-
-public:
- cServer(void);
-
- int Init(short a_ListenPort, short a_ConnectPort);
- void Run(void);
-
- RSA::PrivateKey & GetPrivateKey(void) { return m_PrivateKey; }
- RSA::PublicKey & GetPublicKey (void) { return m_PublicKey; }
-
- short GetConnectPort(void) const { return m_ConnectPort; }
-} ;
-
-
-
-
+
+// Server.h
+
+// Interfaces to the cServer class encapsulating the entire "server"
+
+
+
+
+
+#pragma once
+
+
+
+
+
+
+class cServer
+{
+ SOCKET m_ListenSocket;
+ RSA::PrivateKey m_PrivateKey;
+ RSA::PublicKey m_PublicKey;
+ short m_ConnectPort;
+
+public:
+ cServer(void);
+
+ int Init(short a_ListenPort, short a_ConnectPort);
+ void Run(void);
+
+ RSA::PrivateKey & GetPrivateKey(void) { return m_PrivateKey; }
+ RSA::PublicKey & GetPublicKey (void) { return m_PublicKey; }
+
+ short GetConnectPort(void) const { return m_ConnectPort; }
+} ;
+
+
+
+
diff --git a/Tools/ToLuaDoxy/Globals.cpp b/Tools/ToLuaDoxy/Globals.cpp
index 31440fd44..d73265a60 100644
--- a/Tools/ToLuaDoxy/Globals.cpp
+++ b/Tools/ToLuaDoxy/Globals.cpp
@@ -1,10 +1,10 @@
-
-// Globals.cpp
-
-// Used for precompiled header generation in MSVC
-
-#include "Globals.h"
-
-
-
-
+
+// Globals.cpp
+
+// Used for precompiled header generation in MSVC
+
+#include "Globals.h"
+
+
+
+
diff --git a/Tools/ToLuaDoxy/Globals.h b/Tools/ToLuaDoxy/Globals.h
index 1b92a1349..b9100a297 100644
--- a/Tools/ToLuaDoxy/Globals.h
+++ b/Tools/ToLuaDoxy/Globals.h
@@ -1,101 +1,101 @@
-
-// Globals.h
-
-// This file is used for precompiled header generation in MSVC
-
-
-
-
-// OS-dependent stuff:
-#ifdef _WIN32
- #define WIN32_LEAN_AND_MEAN
-
- #define _WIN32_WINNT 0x501 // We want to target WinXP and higher
-
- #include <Windows.h>
- #include <winsock2.h>
- #include <Ws2tcpip.h> // IPv6 stuff
-
- // Windows SDK defines min and max macros, messing up with our std::min and std::max usage
- #undef min
- #undef max
-
- // Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant
- #ifdef GetFreeSpace
- #undef GetFreeSpace
- #endif // GetFreeSpace
-#else
- #include <sys/types.h>
- #include <sys/stat.h> // for mkdir
- #include <sys/time.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <time.h>
- #include <dirent.h>
- #include <errno.h>
- #include <iostream>
-
- #include <cstdio>
- #include <cstring>
- #include <pthread.h>
- #include <semaphore.h>
- #include <errno.h>
- #include <fcntl.h>
-
- #if !defined(ANDROID_NDK)
- #include <tr1/memory>
- #endif
-#endif
-
-
-
-
-
-// CRT stuff:
-#include <assert.h>
-#include <stdio.h>
-#include <math.h>
-#include <stdarg.h>
-
-
-
-
-
-// STL stuff:
-#include <vector>
-#include <list>
-#include <deque>
-#include <string>
-#include <map>
-#include <algorithm>
-#include <memory>
-#include <set>
-#include <queue>
-
-
-
-
-
-// Common headers (part 1, without macros):
-#include "../../source/StringUtils.h"
-
-
-
-
-
-// Common definitions:
-
-/// 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)" )
-#define KiB * 1024
-#define MiB * 1024 * 1024
-
-#define ASSERT assert
-
-
-
-
+
+// Globals.h
+
+// This file is used for precompiled header generation in MSVC
+
+
+
+
+// OS-dependent stuff:
+#ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+
+ #define _WIN32_WINNT 0x501 // We want to target WinXP and higher
+
+ #include <Windows.h>
+ #include <winsock2.h>
+ #include <Ws2tcpip.h> // IPv6 stuff
+
+ // Windows SDK defines min and max macros, messing up with our std::min and std::max usage
+ #undef min
+ #undef max
+
+ // Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant
+ #ifdef GetFreeSpace
+ #undef GetFreeSpace
+ #endif // GetFreeSpace
+#else
+ #include <sys/types.h>
+ #include <sys/stat.h> // for mkdir
+ #include <sys/time.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <netdb.h>
+ #include <time.h>
+ #include <dirent.h>
+ #include <errno.h>
+ #include <iostream>
+
+ #include <cstdio>
+ #include <cstring>
+ #include <pthread.h>
+ #include <semaphore.h>
+ #include <errno.h>
+ #include <fcntl.h>
+
+ #if !defined(ANDROID_NDK)
+ #include <tr1/memory>
+ #endif
+#endif
+
+
+
+
+
+// CRT stuff:
+#include <assert.h>
+#include <stdio.h>
+#include <math.h>
+#include <stdarg.h>
+
+
+
+
+
+// STL stuff:
+#include <vector>
+#include <list>
+#include <deque>
+#include <string>
+#include <map>
+#include <algorithm>
+#include <memory>
+#include <set>
+#include <queue>
+
+
+
+
+
+// Common headers (part 1, without macros):
+#include "../../source/StringUtils.h"
+
+
+
+
+
+// Common definitions:
+
+/// 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)" )
+#define KiB * 1024
+#define MiB * 1024 * 1024
+
+#define ASSERT assert
+
+
+
+
diff --git a/Tools/ToLuaDoxy/ToLuaDoxy.cpp b/Tools/ToLuaDoxy/ToLuaDoxy.cpp
index cadb4b32e..8b692bb75 100644
--- a/Tools/ToLuaDoxy/ToLuaDoxy.cpp
+++ b/Tools/ToLuaDoxy/ToLuaDoxy.cpp
@@ -1,222 +1,222 @@
-
-// ToLuaDoxy.cpp
-
-// Implements the main app entrypoint
-
-#include "Globals.h"
-#include <fstream>
-#include <iostream>
-
-
-
-
-
-typedef std::vector<AString> AStrings;
-
-
-
-
-
-class cProcessor
-{
-public:
- cProcessor(const AString & a_FileOut) :
- m_Out(a_FileOut.c_str(), std::ios::out),
- m_IsInToLua(false),
- m_IsInComment(false)
- {
- }
-
-
- bool IsGood(void) const
- {
- return !m_Out.fail();
- }
-
-
- void ProcessFile(const AString & a_FileIn)
- {
- std::ifstream In(a_FileIn.c_str());
- if (In.fail())
- {
- std::cerr << "Cannot open input file " << a_FileIn << "." << std::endl;
- return;
- }
- while (!In.eof())
- {
- AString Line;
- std::getline(In, Line);
- PushLine(Line);
- }
- }
-
-protected:
- std::ofstream m_Out;
- bool m_IsInToLua; ///< Set to true if inside a tolua_begin .. tolua_end block
- bool m_IsInComment; ///< Set to true if previous line has started a multiline comment; only outside tolua blocks
- AString m_LastComment; ///< Accumulator for a multiline comment preceding a tolua block
-
-
- void PushLine(const AString & a_Line)
- {
- if (m_IsInToLua)
- {
- // Inside a tolua block
- if (TrimString(a_Line) == "// tolua_end")
- {
- // End of a tolua block
- m_IsInToLua = false;
- return;
- }
- m_Out << a_Line << std::endl;
- return;
- }
-
- if (m_IsInComment)
- {
- // Inside a multiline comment block, outside of a tolua block; accumulate m_LastComment
- m_LastComment += a_Line + "\n";
- m_IsInComment = (a_Line.find("*/") == AString::npos);
- return;
- }
-
- AString Trimmed(TrimString(a_Line));
-
- if (Trimmed == "// tolua_begin")
- {
- // Beginning of a tolua block
- m_IsInToLua = true;
- if (!m_LastComment.empty())
- {
- m_Out << m_LastComment << std::endl;
- m_LastComment.clear();
- }
- return;
- }
-
- size_t CommentBegin = a_Line.find("/*");
- if (CommentBegin != AString::npos)
- {
- m_IsInComment = (a_Line.find("*/", CommentBegin) == AString::npos);
- m_LastComment = a_Line;
- }
-
- size_t ExportIdx = a_Line.find("// tolua_export");
- if (ExportIdx != AString::npos)
- {
- // Single-line tolua block
-
- // Strip the export comment and right-trim the line:
- AString Stripped(a_Line.substr(0, ExportIdx));
- int End = Stripped.length() - 1;
- while ((End > 0) && (Stripped[End] <= 32))
- {
- End--;
- }
- Stripped.erase(End + 1);
-
- if (!m_LastComment.empty())
- {
- m_Out << m_LastComment << std::endl;
- m_LastComment.clear();
- }
- m_Out << Stripped << std::endl;
- return;
- }
-
- if (!m_IsInComment)
- {
- m_LastComment.clear();
- }
- }
-} ;
-
-
-
-
-
-/** Parses the specified package file into a list of $cfile-included files and all the other contents
-Returns true if successful.
-Returns false and prints error if unsuccessful
-*/
-bool ParsePackageFile(const AString & a_FileName, AStrings & a_CFiles, AStrings & a_DirectContentsLines)
-{
- std::ifstream PkgFile(a_FileName.c_str());
- if (PkgFile.fail())
- {
- std::cerr << "Cannot open the package file " << a_FileName << "." << std::endl;
- return false;
- }
-
- while (!PkgFile.eof())
- {
- AString Line;
- std::getline(PkgFile, Line);
- Line = TrimString(Line);
- if (strncmp(Line.c_str(), "$cfile \"", 8) == 0)
- {
- a_CFiles.push_back(Line.substr(8, Line.length() - 9));
- }
- else
- {
- a_DirectContentsLines.push_back(Line);
- }
- }
- return true;
-}
-
-
-
-
-
-/// Processes the specified input header file into the output file
-void ProcessCFile(const AString & a_CFileIn, const AString & a_CFileOut)
-{
- cProcessor p(a_CFileOut);
- if (!p.IsGood())
- {
- std::cerr << "Cannot open output file " << a_CFileOut << "." << std::endl;
- return;
- }
- p.ProcessFile(a_CFileIn);
-}
-
-
-
-
-
-int main(int argc, char * argv[])
-{
- AString BaseDir = (argc > 1) ? argv[1] : ".";
- AString OutDir = (argc > 2) ? argv[2] : "Out";
-
- // Create the output directory:
- #ifdef _WIN32
- CreateDirectory(OutDir.c_str(), NULL);
- #else
- mkdir(OutDir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
- #endif
-
- // Parse the package file
- AStrings CFiles;
- AStrings DirectLines;
- if (!ParsePackageFile(Printf("%s/AllToLua.pkg", BaseDir.c_str()), CFiles, DirectLines))
- {
- return 1;
- }
-
- // Process header files:
- for (AStrings::const_iterator itr = CFiles.begin(), end = CFiles.end(); itr != end; ++itr)
- {
- static int cnt = 0;
- AString In = Printf("%s/%s", BaseDir.c_str(), itr->c_str());
- AString Out = Printf("%s/%04x.h", OutDir.c_str(), cnt++);
- ProcessCFile(In, Out);
- } // for itr - CFiles[]
-
- return 0;
-}
-
-
-
-
+
+// ToLuaDoxy.cpp
+
+// Implements the main app entrypoint
+
+#include "Globals.h"
+#include <fstream>
+#include <iostream>
+
+
+
+
+
+typedef std::vector<AString> AStrings;
+
+
+
+
+
+class cProcessor
+{
+public:
+ cProcessor(const AString & a_FileOut) :
+ m_Out(a_FileOut.c_str(), std::ios::out),
+ m_IsInToLua(false),
+ m_IsInComment(false)
+ {
+ }
+
+
+ bool IsGood(void) const
+ {
+ return !m_Out.fail();
+ }
+
+
+ void ProcessFile(const AString & a_FileIn)
+ {
+ std::ifstream In(a_FileIn.c_str());
+ if (In.fail())
+ {
+ std::cerr << "Cannot open input file " << a_FileIn << "." << std::endl;
+ return;
+ }
+ while (!In.eof())
+ {
+ AString Line;
+ std::getline(In, Line);
+ PushLine(Line);
+ }
+ }
+
+protected:
+ std::ofstream m_Out;
+ bool m_IsInToLua; ///< Set to true if inside a tolua_begin .. tolua_end block
+ bool m_IsInComment; ///< Set to true if previous line has started a multiline comment; only outside tolua blocks
+ AString m_LastComment; ///< Accumulator for a multiline comment preceding a tolua block
+
+
+ void PushLine(const AString & a_Line)
+ {
+ if (m_IsInToLua)
+ {
+ // Inside a tolua block
+ if (TrimString(a_Line) == "// tolua_end")
+ {
+ // End of a tolua block
+ m_IsInToLua = false;
+ return;
+ }
+ m_Out << a_Line << std::endl;
+ return;
+ }
+
+ if (m_IsInComment)
+ {
+ // Inside a multiline comment block, outside of a tolua block; accumulate m_LastComment
+ m_LastComment += a_Line + "\n";
+ m_IsInComment = (a_Line.find("*/") == AString::npos);
+ return;
+ }
+
+ AString Trimmed(TrimString(a_Line));
+
+ if (Trimmed == "// tolua_begin")
+ {
+ // Beginning of a tolua block
+ m_IsInToLua = true;
+ if (!m_LastComment.empty())
+ {
+ m_Out << m_LastComment << std::endl;
+ m_LastComment.clear();
+ }
+ return;
+ }
+
+ size_t CommentBegin = a_Line.find("/*");
+ if (CommentBegin != AString::npos)
+ {
+ m_IsInComment = (a_Line.find("*/", CommentBegin) == AString::npos);
+ m_LastComment = a_Line;
+ }
+
+ size_t ExportIdx = a_Line.find("// tolua_export");
+ if (ExportIdx != AString::npos)
+ {
+ // Single-line tolua block
+
+ // Strip the export comment and right-trim the line:
+ AString Stripped(a_Line.substr(0, ExportIdx));
+ int End = Stripped.length() - 1;
+ while ((End > 0) && (Stripped[End] <= 32))
+ {
+ End--;
+ }
+ Stripped.erase(End + 1);
+
+ if (!m_LastComment.empty())
+ {
+ m_Out << m_LastComment << std::endl;
+ m_LastComment.clear();
+ }
+ m_Out << Stripped << std::endl;
+ return;
+ }
+
+ if (!m_IsInComment)
+ {
+ m_LastComment.clear();
+ }
+ }
+} ;
+
+
+
+
+
+/** Parses the specified package file into a list of $cfile-included files and all the other contents
+Returns true if successful.
+Returns false and prints error if unsuccessful
+*/
+bool ParsePackageFile(const AString & a_FileName, AStrings & a_CFiles, AStrings & a_DirectContentsLines)
+{
+ std::ifstream PkgFile(a_FileName.c_str());
+ if (PkgFile.fail())
+ {
+ std::cerr << "Cannot open the package file " << a_FileName << "." << std::endl;
+ return false;
+ }
+
+ while (!PkgFile.eof())
+ {
+ AString Line;
+ std::getline(PkgFile, Line);
+ Line = TrimString(Line);
+ if (strncmp(Line.c_str(), "$cfile \"", 8) == 0)
+ {
+ a_CFiles.push_back(Line.substr(8, Line.length() - 9));
+ }
+ else
+ {
+ a_DirectContentsLines.push_back(Line);
+ }
+ }
+ return true;
+}
+
+
+
+
+
+/// Processes the specified input header file into the output file
+void ProcessCFile(const AString & a_CFileIn, const AString & a_CFileOut)
+{
+ cProcessor p(a_CFileOut);
+ if (!p.IsGood())
+ {
+ std::cerr << "Cannot open output file " << a_CFileOut << "." << std::endl;
+ return;
+ }
+ p.ProcessFile(a_CFileIn);
+}
+
+
+
+
+
+int main(int argc, char * argv[])
+{
+ AString BaseDir = (argc > 1) ? argv[1] : ".";
+ AString OutDir = (argc > 2) ? argv[2] : "Out";
+
+ // Create the output directory:
+ #ifdef _WIN32
+ CreateDirectory(OutDir.c_str(), NULL);
+ #else
+ mkdir(OutDir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
+ #endif
+
+ // Parse the package file
+ AStrings CFiles;
+ AStrings DirectLines;
+ if (!ParsePackageFile(Printf("%s/AllToLua.pkg", BaseDir.c_str()), CFiles, DirectLines))
+ {
+ return 1;
+ }
+
+ // Process header files:
+ for (AStrings::const_iterator itr = CFiles.begin(), end = CFiles.end(); itr != end; ++itr)
+ {
+ static int cnt = 0;
+ AString In = Printf("%s/%s", BaseDir.c_str(), itr->c_str());
+ AString Out = Printf("%s/%04x.h", OutDir.c_str(), cnt++);
+ ProcessCFile(In, Out);
+ } // for itr - CFiles[]
+
+ return 0;
+}
+
+
+
+
diff --git a/Tools/ToLuaDoxy/ToLuaDoxy.sln b/Tools/ToLuaDoxy/ToLuaDoxy.sln
index 8df530779..2d8e78b1b 100644
--- a/Tools/ToLuaDoxy/ToLuaDoxy.sln
+++ b/Tools/ToLuaDoxy/ToLuaDoxy.sln
@@ -1,20 +1,20 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToLuaDoxy", "ToLuaDoxy.vcproj", "{137140AF-4E9D-404F-BC87-982A6517AC12}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {137140AF-4E9D-404F-BC87-982A6517AC12}.Debug|Win32.ActiveCfg = Debug|Win32
- {137140AF-4E9D-404F-BC87-982A6517AC12}.Debug|Win32.Build.0 = Debug|Win32
- {137140AF-4E9D-404F-BC87-982A6517AC12}.Release|Win32.ActiveCfg = Release|Win32
- {137140AF-4E9D-404F-BC87-982A6517AC12}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToLuaDoxy", "ToLuaDoxy.vcproj", "{137140AF-4E9D-404F-BC87-982A6517AC12}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {137140AF-4E9D-404F-BC87-982A6517AC12}.Debug|Win32.ActiveCfg = Debug|Win32
+ {137140AF-4E9D-404F-BC87-982A6517AC12}.Debug|Win32.Build.0 = Debug|Win32
+ {137140AF-4E9D-404F-BC87-982A6517AC12}.Release|Win32.ActiveCfg = Release|Win32
+ {137140AF-4E9D-404F-BC87-982A6517AC12}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Tools/ToLuaDoxy/ToLuaDoxy.vcproj b/Tools/ToLuaDoxy/ToLuaDoxy.vcproj
index 0c9f4ec5b..cd4c89cee 100644
--- a/Tools/ToLuaDoxy/ToLuaDoxy.vcproj
+++ b/Tools/ToLuaDoxy/ToLuaDoxy.vcproj
@@ -1,221 +1,221 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="ToLuaDoxy"
- ProjectGUID="{137140AF-4E9D-404F-BC87-982A6517AC12}"
- RootNamespace="ToLuaDoxy"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../../source"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../../source"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\Globals.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\Globals.h"
- >
- </File>
- <File
- RelativePath=".\ToLuaDoxy.cpp"
- >
- </File>
- <Filter
- Name="shared"
- >
- <File
- RelativePath="..\..\source\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.h"
- >
- </File>
- </Filter>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="ToLuaDoxy"
+ ProjectGUID="{137140AF-4E9D-404F-BC87-982A6517AC12}"
+ RootNamespace="ToLuaDoxy"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../source"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="../../source"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\Globals.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\Globals.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ToLuaDoxy.cpp"
+ >
+ </File>
+ <Filter
+ Name="shared"
+ >
+ <File
+ RelativePath="..\..\source\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/UpdateVersions.cmd b/UpdateVersions.cmd
index b724990bb..1d4b00bca 100644
--- a/UpdateVersions.cmd
+++ b/UpdateVersions.cmd
@@ -1,39 +1,39 @@
-@echo off
-:: UpdateVersions.cmd
-:: This script processes all *.template files into their non-templated variants using subwcrev, substituting WC-related keywords in the process
-:: subwcrev is expected to be in path; you can pass the correct path for your system as env var "subwcrev"
-
-
-:: Subwcrev (from TortoiseSVN, for querying revision number; by default in PATH):
-if %subwcrev%a == a set subwcrev=subwcrev
-
-
-
-
-:: Copy all *.template files into their non-template versions, substituting SVN keywords:
-for /r %%X in (*.template) do (
- %subwcrev% . "%%X" "%%~dpX%%~nX"
- if errorlevel 1 goto haderror
-)
-
-
-goto end
-
-
-
-
-:haderror
-echo an error was encountered, check command output above
-pause
-goto finished
-
-
-
-
-
-:end
-if "a%1" == "a" pause
-
-
-
+@echo off
+:: UpdateVersions.cmd
+:: This script processes all *.template files into their non-templated variants using subwcrev, substituting WC-related keywords in the process
+:: subwcrev is expected to be in path; you can pass the correct path for your system as env var "subwcrev"
+
+
+:: Subwcrev (from TortoiseSVN, for querying revision number; by default in PATH):
+if %subwcrev%a == a set subwcrev=subwcrev
+
+
+
+
+:: Copy all *.template files into their non-template versions, substituting SVN keywords:
+for /r %%X in (*.template) do (
+ %subwcrev% . "%%X" "%%~dpX%%~nX"
+ if errorlevel 1 goto haderror
+)
+
+
+goto end
+
+
+
+
+:haderror
+echo an error was encountered, check command output above
+pause
+goto finished
+
+
+
+
+
+:end
+if "a%1" == "a" pause
+
+
+
:finished \ No newline at end of file
diff --git a/VC2008/.gitignore b/VC2008/.gitignore
new file mode 100644
index 000000000..3b3be3257
--- /dev/null
+++ b/VC2008/.gitignore
@@ -0,0 +1,5 @@
+Debug/
+Release/
+*.user
+*.ncb
+*.suo
diff --git a/VC2008/CryptoPP.vcproj b/VC2008/CryptoPP.vcproj
index 45f01b22c..6c56d3cce 100644
--- a/VC2008/CryptoPP.vcproj
+++ b/VC2008/CryptoPP.vcproj
@@ -1,5101 +1,5101 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="CryptoPP"
- ProjectGUID="{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
- RootNamespace="cryptlib"
- SccLocalPath="."
- TargetFrameworkVersion="131072"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\CryptoPP"
- IntermediateDirectory="$(ConfigurationName)\CryptoPP"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="2"
- EnableIntrinsicFunctions="true"
- OmitFramePointers="true"
- PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32"
- StringPooling="true"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="pch.h"
- ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
- WarningLevel="3"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\CryptoPP"
- IntermediateDirectory="$(ConfigurationName)\CryptoPP"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="_DEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32"
- RuntimeLibrary="1"
- EnableEnhancedInstructionSet="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="pch.h"
- ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
- WarningLevel="3"
- SuppressStartupBanner="true"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="$(PlatformName)\Output\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="2"
- EnableIntrinsicFunctions="true"
- OmitFramePointers="true"
- PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32"
- StringPooling="true"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="pch.h"
- ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
- WarningLevel="3"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="DLL-Import Release|x64"
- OutputDirectory="$(PlatformName)\DLL_Output\Release"
- IntermediateDirectory="$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="2"
- EnableIntrinsicFunctions="true"
- OmitFramePointers="true"
- WholeProgramOptimization="true"
- PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32;CRYPTOPP_IMPORTS"
- StringPooling="true"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="pch.h"
- ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
- WarningLevel="3"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="$(PlatformName)\Output\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="_DEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="pch.h"
- ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
- WarningLevel="3"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="DLL-Import Debug|x64"
- OutputDirectory="$(PlatformName)\DLL_Output\Debug"
- IntermediateDirectory="$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="_DEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32;CRYPTOPP_IMPORTS"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="pch.h"
- ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
- WarningLevel="3"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter=".cpp"
- >
- <File
- RelativePath="..\CryptoPP\adler32.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\algebra.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\algparam.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\asn.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\.\authenc.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\base32.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\base64.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\basecode.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\cbcmac.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\.\ccm.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\channels.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\.\cmac.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\cpu.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\crc.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\cryptlib.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\default.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\des.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\dessp.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\dh.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\dh2.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\dll.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\dsa.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\.\eax.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\ec2n.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\eccrypto.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\ecp.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\elgamal.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\emsa2.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\eprecomp.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\esign.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\files.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\filters.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\fips140.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\.\gcm.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\gf256.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\gf2_32.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\gf2n.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\gfpcrypt.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\hex.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\hmac.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\hrtimer.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\integer.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- AssemblerListingLocation=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\iterhash.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\luc.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\md2.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\md4.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\md5.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\misc.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\modes.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\mqueue.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\mqv.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\nbtheory.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\network.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\oaep.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\osrng.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\pch.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\pkcspad.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\polynomi.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\pssr.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\pubkey.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\queue.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\rabin.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\randpool.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\rdtables.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\rijndael.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\rng.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\rsa.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\rw.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\safer.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\seal.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\.\seed.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\sha.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\shacal2.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\simple.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\socketft.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\square.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\squaretb.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\strciphr.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\tea.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\tiger.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\tigertab.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\trdlocal.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\ttmac.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\.\vmac.cpp"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\wait.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\CryptoPP\winpipes.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DLL-Import Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter=".;.h"
- >
- <File
- RelativePath="..\CryptoPP\adler32.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\aes.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\algebra.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\algparam.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\arc4.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\argnames.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\asn.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\authenc.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\base32.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\base64.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\basecode.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\cbcmac.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\ccm.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\channels.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\cmac.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\config.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\cpu.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\crc.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\cryptlib.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\default.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\des.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\dh.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\dh2.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\dmac.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\dsa.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\eax.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\ec2n.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\eccrypto.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\ecp.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\elgamal.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\emsa2.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\eprecomp.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\esign.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\files.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\filters.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\fips140.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\fltrimpl.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\gcm.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\gf256.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\gf2_32.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\gf2n.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\gfpcrypt.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\gzip.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\hex.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\hmac.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\hrtimer.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\integer.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\iterhash.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\lubyrack.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\luc.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\md2.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\md4.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\md5.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\mdc.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\misc.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\modarith.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\modes.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\modexppc.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\mqueue.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\mqv.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\nbtheory.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\network.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\nr.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\oaep.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\oids.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\osrng.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\pch.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\pkcspad.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\polynomi.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\pssr.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\pubkey.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\pwdbased.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\queue.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\rabin.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\randpool.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\rijndael.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\rng.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\rsa.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\rw.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\safer.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\seal.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\secblock.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\seckey.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\seed.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\sha.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\shacal2.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\simple.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\smartptr.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\socketft.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\square.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\stdcpp.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\strciphr.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\tea.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\tiger.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\trdlocal.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\trunhash.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\ttmac.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\vmac.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\wait.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\wake.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\winpipes.h"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\words.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Miscellaneous"
- >
- <File
- RelativePath="..\CryptoPP\Doxyfile"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\GNUmakefile"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\License.txt"
- >
- </File>
- <File
- RelativePath="..\CryptoPP\.\Readme.txt"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="CryptoPP"
+ ProjectGUID="{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
+ RootNamespace="cryptlib"
+ SccLocalPath="."
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\CryptoPP"
+ IntermediateDirectory="$(ConfigurationName)\CryptoPP"
+ ConfigurationType="4"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ OmitFramePointers="true"
+ PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="pch.h"
+ ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\CryptoPP"
+ IntermediateDirectory="$(ConfigurationName)\CryptoPP"
+ ConfigurationType="4"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="_DEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32"
+ RuntimeLibrary="1"
+ EnableEnhancedInstructionSet="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="pch.h"
+ ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="$(PlatformName)\Output\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ OmitFramePointers="true"
+ PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="pch.h"
+ ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="DLL-Import Release|x64"
+ OutputDirectory="$(PlatformName)\DLL_Output\Release"
+ IntermediateDirectory="$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ OmitFramePointers="true"
+ WholeProgramOptimization="true"
+ PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32;CRYPTOPP_IMPORTS"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="pch.h"
+ ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(PlatformName)\Output\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="_DEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="pch.h"
+ ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="DLL-Import Debug|x64"
+ OutputDirectory="$(PlatformName)\DLL_Output\Debug"
+ IntermediateDirectory="$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="_DEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32;CRYPTOPP_IMPORTS"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="pch.h"
+ ProgramDataBaseFileName="$(OutDir)\vc80.pdb"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter=".cpp"
+ >
+ <File
+ RelativePath="..\CryptoPP\adler32.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\algebra.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\algparam.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\asn.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\authenc.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\base32.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\base64.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\basecode.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\cbcmac.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\ccm.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\channels.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\cmac.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\cpu.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\crc.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\cryptlib.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\default.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\des.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\dessp.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\dh.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\dh2.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\dll.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\dsa.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\eax.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\ec2n.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\eccrypto.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\ecp.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\elgamal.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\emsa2.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\eprecomp.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\esign.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\files.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\filters.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\fips140.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\gcm.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\gf256.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\gf2_32.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\gf2n.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\gfpcrypt.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\hex.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\hmac.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\hrtimer.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\integer.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ AssemblerListingLocation=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\iterhash.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\luc.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\md2.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\md4.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\md5.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\misc.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\modes.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\mqueue.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\mqv.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\nbtheory.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\network.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\oaep.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\osrng.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\pch.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\pkcspad.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\polynomi.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\pssr.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\pubkey.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\queue.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rabin.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\randpool.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rdtables.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rijndael.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rng.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rsa.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rw.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\safer.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\seal.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\seed.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\sha.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\shacal2.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\simple.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\socketft.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\square.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\squaretb.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\strciphr.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\tea.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\tiger.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\tigertab.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\trdlocal.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\ttmac.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\vmac.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\wait.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\CryptoPP\winpipes.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DLL-Import Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter=".;.h"
+ >
+ <File
+ RelativePath="..\CryptoPP\adler32.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\aes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\algebra.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\algparam.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\arc4.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\argnames.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\asn.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\authenc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\base32.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\base64.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\basecode.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\cbcmac.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\ccm.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\channels.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\cmac.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\config.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\cpu.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\crc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\cryptlib.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\default.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\des.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\dh.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\dh2.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\dmac.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\dsa.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\eax.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\ec2n.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\eccrypto.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\ecp.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\elgamal.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\emsa2.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\eprecomp.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\esign.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\files.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\filters.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\fips140.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\fltrimpl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\gcm.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\gf256.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\gf2_32.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\gf2n.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\gfpcrypt.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\gzip.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\hex.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\hmac.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\hrtimer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\integer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\iterhash.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\lubyrack.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\luc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\md2.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\md4.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\md5.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\mdc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\misc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\modarith.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\modes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\modexppc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\mqueue.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\mqv.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\nbtheory.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\network.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\nr.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\oaep.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\oids.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\osrng.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\pch.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\pkcspad.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\polynomi.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\pssr.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\pubkey.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\pwdbased.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\queue.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rabin.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\randpool.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rijndael.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rng.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rsa.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\rw.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\safer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\seal.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\secblock.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\seckey.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\seed.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\sha.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\shacal2.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\simple.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\smartptr.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\socketft.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\square.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\stdcpp.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\strciphr.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\tea.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\tiger.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\trdlocal.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\trunhash.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\ttmac.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\vmac.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\wait.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\wake.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\winpipes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\words.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Miscellaneous"
+ >
+ <File
+ RelativePath="..\CryptoPP\Doxyfile"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\GNUmakefile"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\License.txt"
+ >
+ </File>
+ <File
+ RelativePath="..\CryptoPP\.\Readme.txt"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/VC2008/GenerateBindings.cmd b/VC2008/GenerateBindings.cmd
index 73670d5e8..ac470234f 100644
--- a/VC2008/GenerateBindings.cmd
+++ b/VC2008/GenerateBindings.cmd
@@ -1,3 +1,3 @@
-set ALLTOLUA_WAIT=N
-cd ..\source
+set ALLTOLUA_WAIT=N
+cd ..\source
AllToLua.bat \ No newline at end of file
diff --git a/VC2008/JsonCpp.vcproj b/VC2008/JsonCpp.vcproj
index 0c8f6ccc8..4ed04067a 100644
--- a/VC2008/JsonCpp.vcproj
+++ b/VC2008/JsonCpp.vcproj
@@ -1,248 +1,248 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="JsonCpp"
- ProjectGUID="{5AAA90B9-946D-4034-83F3-676B06A6E326}"
- RootNamespace="JsonCpp"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\JsonCpp"
- IntermediateDirectory="$(ConfigurationName)\JsonCpp"
- ConfigurationType="4"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../jsoncpp-src-0.5.0/include"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\JsonCpp"
- IntermediateDirectory="$(ConfigurationName)\JsonCpp"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../jsoncpp-src-0.5.0/include"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release profiled|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\JsonCpp"
- IntermediateDirectory="$(ConfigurationName)\JsonCpp"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../jsoncpp-src-0.5.0/include"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_batchallocator.h"
- >
- </File>
- <File
- RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_internalarray.inl"
- >
- </File>
- <File
- RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_internalmap.inl"
- >
- </File>
- <File
- RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_reader.cpp"
- >
- </File>
- <File
- RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_value.cpp"
- >
- </File>
- <File
- RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_valueiterator.inl"
- >
- </File>
- <File
- RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_writer.cpp"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="JsonCpp"
+ ProjectGUID="{5AAA90B9-946D-4034-83F3-676B06A6E326}"
+ RootNamespace="JsonCpp"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\JsonCpp"
+ IntermediateDirectory="$(ConfigurationName)\JsonCpp"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../jsoncpp-src-0.5.0/include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\JsonCpp"
+ IntermediateDirectory="$(ConfigurationName)\JsonCpp"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="../jsoncpp-src-0.5.0/include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\JsonCpp"
+ IntermediateDirectory="$(ConfigurationName)\JsonCpp"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="../jsoncpp-src-0.5.0/include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_batchallocator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_internalarray.inl"
+ >
+ </File>
+ <File
+ RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_internalmap.inl"
+ >
+ </File>
+ <File
+ RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_reader.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_value.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_valueiterator.inl"
+ >
+ </File>
+ <File
+ RelativePath="..\jsoncpp-src-0.5.0\src\lib_json\json_writer.cpp"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/VC2008/Lua.vcproj b/VC2008/Lua.vcproj
index 6e9a5fe87..83cf4baf2 100644
--- a/VC2008/Lua.vcproj
+++ b/VC2008/Lua.vcproj
@@ -1,437 +1,437 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="Lua"
- ProjectGUID="{082E8185-7B3A-4945-8C82-9132341A329D}"
- RootNamespace="Lua"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua"
- IntermediateDirectory="$(ConfigurationName)\Lua"
- ConfigurationType="4"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua"
- IntermediateDirectory="$(ConfigurationName)\Lua"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release profiled|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua"
- IntermediateDirectory="$(ConfigurationName)\Lua"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\lua-5.1.4\src\lapi.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lauxlib.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lbaselib.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lcode.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ldblib.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ldebug.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ldo.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ldump.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lfunc.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lgc.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\linit.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\liolib.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\llex.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lmathlib.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lmem.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\loadlib.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lobject.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lopcodes.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\loslib.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lparser.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lstate.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lstring.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lstrlib.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ltable.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ltablib.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ltm.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lua.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\luac.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lundump.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lvm.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lzio.c"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\print.c"
- >
- </File>
- </Filter>
- <File
- RelativePath="..\lua-5.1.4\src\lapi.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lauxlib.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lcode.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ldebug.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ldo.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lfunc.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lgc.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\llex.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\llimits.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lmem.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lobject.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lopcodes.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lparser.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lstate.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lstring.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ltable.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\ltm.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lua.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\luaconf.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lualib.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lundump.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lvm.h"
- >
- </File>
- <File
- RelativePath="..\lua-5.1.4\src\lzio.h"
- >
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="Lua"
+ ProjectGUID="{082E8185-7B3A-4945-8C82-9132341A329D}"
+ RootNamespace="Lua"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua"
+ IntermediateDirectory="$(ConfigurationName)\Lua"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua"
+ IntermediateDirectory="$(ConfigurationName)\Lua"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua"
+ IntermediateDirectory="$(ConfigurationName)\Lua"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\lua-5.1.4\src\lapi.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lauxlib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lbaselib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lcode.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ldblib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ldebug.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ldo.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ldump.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lfunc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lgc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\linit.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\liolib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\llex.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lmathlib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lmem.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\loadlib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lobject.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lopcodes.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\loslib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lparser.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lstate.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lstring.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lstrlib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ltable.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ltablib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ltm.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lua.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\luac.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lundump.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lvm.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lzio.c"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\print.c"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath="..\lua-5.1.4\src\lapi.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lauxlib.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lcode.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ldebug.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ldo.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lfunc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lgc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\llex.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\llimits.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lmem.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lobject.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lopcodes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lparser.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lstate.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lstring.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ltable.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\ltm.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lua.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\luaconf.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lualib.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lundump.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lvm.h"
+ >
+ </File>
+ <File
+ RelativePath="..\lua-5.1.4\src\lzio.h"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/VC2008/MCServer.rc b/VC2008/MCServer.rc
index 9ecb06221..e0fbbea5d 100644
--- a/VC2008/MCServer.rc
+++ b/VC2008/MCServer.rc
@@ -1,17 +1,17 @@
-// Generated by ResEdit 1.5.11
-// Copyright (C) 2006-2012
-// http://www.resedit.net
-
-#include <windows.h>
-#include <commctrl.h>
-#include <richedit.h>
-#include "resource_MCServer.h"
-
-
-
-
-//
-// Icon resources
-//
-LANGUAGE 9, SUBLANG_DEFAULT
-IDI_ICON1 ICON "icon.ico"
+// Generated by ResEdit 1.5.11
+// Copyright (C) 2006-2012
+// http://www.resedit.net
+
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+#include "resource_MCServer.h"
+
+
+
+
+//
+// Icon resources
+//
+LANGUAGE 9, SUBLANG_DEFAULT
+IDI_ICON1 ICON "icon.ico"
diff --git a/VC2008/MCServer.sln b/VC2008/MCServer.sln
index 05b8c55ce..bdf3a0408 100644
--- a/VC2008/MCServer.sln
+++ b/VC2008/MCServer.sln
@@ -1,93 +1,93 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MCServer", "MCServer.vcproj", "{32012054-0C96-4C43-AB27-174FF8E72D66}"
- ProjectSection(ProjectDependencies) = postProject
- {9A476537-42C0-4848-AB40-15CFE83D17A8} = {9A476537-42C0-4848-AB40-15CFE83D17A8}
- {082E8185-7B3A-4945-8C82-9132341A329D} = {082E8185-7B3A-4945-8C82-9132341A329D}
- {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96} = {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
- {EEAB54AD-114C-4AB8-8482-0A52D502BD35} = {EEAB54AD-114C-4AB8-8482-0A52D502BD35}
- {5AAA90B9-946D-4034-83F3-676B06A6E326} = {5AAA90B9-946D-4034-83F3-676B06A6E326}
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA} = {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib.vcproj", "{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JsonCpp", "JsonCpp.vcproj", "{5AAA90B9-946D-4034-83F3-676B06A6E326}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lua", "Lua.vcproj", "{082E8185-7B3A-4945-8C82-9132341A329D}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToLua", "ToLua.vcproj", "{EEAB54AD-114C-4AB8-8482-0A52D502BD35}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebServer", "WebServer.vcproj", "{9A476537-42C0-4848-AB40-15CFE83D17A8}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Squirrel3", "Squirrel3.vcproj", "{54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CryptoPP", "CryptoPP.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "expat", "expat.vcproj", "{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release profiled|Win32 = Release profiled|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug|Win32.ActiveCfg = Debug|Win32
- {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug|Win32.Build.0 = Debug|Win32
- {32012054-0C96-4C43-AB27-174FF8E72D66}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {32012054-0C96-4C43-AB27-174FF8E72D66}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {32012054-0C96-4C43-AB27-174FF8E72D66}.Release|Win32.ActiveCfg = Release|Win32
- {32012054-0C96-4C43-AB27-174FF8E72D66}.Release|Win32.Build.0 = Release|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.ActiveCfg = Debug|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.Build.0 = Debug|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.ActiveCfg = Release|Win32
- {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.Build.0 = Release|Win32
- {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug|Win32.ActiveCfg = Debug|Win32
- {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug|Win32.Build.0 = Debug|Win32
- {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release|Win32.ActiveCfg = Release|Win32
- {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release|Win32.Build.0 = Release|Win32
- {082E8185-7B3A-4945-8C82-9132341A329D}.Debug|Win32.ActiveCfg = Debug|Win32
- {082E8185-7B3A-4945-8C82-9132341A329D}.Debug|Win32.Build.0 = Debug|Win32
- {082E8185-7B3A-4945-8C82-9132341A329D}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {082E8185-7B3A-4945-8C82-9132341A329D}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {082E8185-7B3A-4945-8C82-9132341A329D}.Release|Win32.ActiveCfg = Release|Win32
- {082E8185-7B3A-4945-8C82-9132341A329D}.Release|Win32.Build.0 = Release|Win32
- {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug|Win32.ActiveCfg = Debug|Win32
- {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug|Win32.Build.0 = Debug|Win32
- {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release|Win32.ActiveCfg = Release|Win32
- {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release|Win32.Build.0 = Release|Win32
- {9A476537-42C0-4848-AB40-15CFE83D17A8}.Debug|Win32.ActiveCfg = Debug|Win32
- {9A476537-42C0-4848-AB40-15CFE83D17A8}.Debug|Win32.Build.0 = Debug|Win32
- {9A476537-42C0-4848-AB40-15CFE83D17A8}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {9A476537-42C0-4848-AB40-15CFE83D17A8}.Release profiled|Win32.Build.0 = Release profiled|Win32
- {9A476537-42C0-4848-AB40-15CFE83D17A8}.Release|Win32.ActiveCfg = Release|Win32
- {9A476537-42C0-4848-AB40-15CFE83D17A8}.Release|Win32.Build.0 = Release|Win32
- {54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}.Debug|Win32.ActiveCfg = Debug|Win32
- {54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
- {54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}.Release|Win32.ActiveCfg = Release|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.ActiveCfg = Debug|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.Build.0 = Debug|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release profiled|Win32.ActiveCfg = Release|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release profiled|Win32.Build.0 = Release|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.ActiveCfg = Release|Win32
- {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32
- {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.ActiveCfg = Debug|Win32
- {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.Build.0 = Debug|Win32
- {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release profiled|Win32.ActiveCfg = Release|Win32
- {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release profiled|Win32.Build.0 = Release|Win32
- {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release|Win32.ActiveCfg = Release|Win32
- {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MCServer", "MCServer.vcproj", "{32012054-0C96-4C43-AB27-174FF8E72D66}"
+ ProjectSection(ProjectDependencies) = postProject
+ {9A476537-42C0-4848-AB40-15CFE83D17A8} = {9A476537-42C0-4848-AB40-15CFE83D17A8}
+ {082E8185-7B3A-4945-8C82-9132341A329D} = {082E8185-7B3A-4945-8C82-9132341A329D}
+ {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96} = {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
+ {EEAB54AD-114C-4AB8-8482-0A52D502BD35} = {EEAB54AD-114C-4AB8-8482-0A52D502BD35}
+ {5AAA90B9-946D-4034-83F3-676B06A6E326} = {5AAA90B9-946D-4034-83F3-676B06A6E326}
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA} = {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib.vcproj", "{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JsonCpp", "JsonCpp.vcproj", "{5AAA90B9-946D-4034-83F3-676B06A6E326}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lua", "Lua.vcproj", "{082E8185-7B3A-4945-8C82-9132341A329D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToLua", "ToLua.vcproj", "{EEAB54AD-114C-4AB8-8482-0A52D502BD35}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebServer", "WebServer.vcproj", "{9A476537-42C0-4848-AB40-15CFE83D17A8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Squirrel3", "Squirrel3.vcproj", "{54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CryptoPP", "CryptoPP.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "expat", "expat.vcproj", "{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release profiled|Win32 = Release profiled|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug|Win32.ActiveCfg = Debug|Win32
+ {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug|Win32.Build.0 = Debug|Win32
+ {32012054-0C96-4C43-AB27-174FF8E72D66}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {32012054-0C96-4C43-AB27-174FF8E72D66}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {32012054-0C96-4C43-AB27-174FF8E72D66}.Release|Win32.ActiveCfg = Release|Win32
+ {32012054-0C96-4C43-AB27-174FF8E72D66}.Release|Win32.Build.0 = Release|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.Build.0 = Debug|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.ActiveCfg = Release|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.Build.0 = Release|Win32
+ {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug|Win32.Build.0 = Debug|Win32
+ {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release|Win32.ActiveCfg = Release|Win32
+ {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release|Win32.Build.0 = Release|Win32
+ {082E8185-7B3A-4945-8C82-9132341A329D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {082E8185-7B3A-4945-8C82-9132341A329D}.Debug|Win32.Build.0 = Debug|Win32
+ {082E8185-7B3A-4945-8C82-9132341A329D}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {082E8185-7B3A-4945-8C82-9132341A329D}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {082E8185-7B3A-4945-8C82-9132341A329D}.Release|Win32.ActiveCfg = Release|Win32
+ {082E8185-7B3A-4945-8C82-9132341A329D}.Release|Win32.Build.0 = Release|Win32
+ {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug|Win32.Build.0 = Debug|Win32
+ {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release|Win32.ActiveCfg = Release|Win32
+ {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release|Win32.Build.0 = Release|Win32
+ {9A476537-42C0-4848-AB40-15CFE83D17A8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9A476537-42C0-4848-AB40-15CFE83D17A8}.Debug|Win32.Build.0 = Debug|Win32
+ {9A476537-42C0-4848-AB40-15CFE83D17A8}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {9A476537-42C0-4848-AB40-15CFE83D17A8}.Release profiled|Win32.Build.0 = Release profiled|Win32
+ {9A476537-42C0-4848-AB40-15CFE83D17A8}.Release|Win32.ActiveCfg = Release|Win32
+ {9A476537-42C0-4848-AB40-15CFE83D17A8}.Release|Win32.Build.0 = Release|Win32
+ {54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
+ {54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}.Release|Win32.ActiveCfg = Release|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.Build.0 = Debug|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release profiled|Win32.ActiveCfg = Release|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release profiled|Win32.Build.0 = Release|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.ActiveCfg = Release|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32
+ {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.Build.0 = Debug|Win32
+ {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release profiled|Win32.ActiveCfg = Release|Win32
+ {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release profiled|Win32.Build.0 = Release|Win32
+ {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release|Win32.ActiveCfg = Release|Win32
+ {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index 5d674ba43..6fcd55388 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -1,2628 +1,2636 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="MCServer"
- ProjectGUID="{32012054-0C96-4C43-AB27-174FF8E72D66}"
- RootNamespace="MCServer"
- Keyword="Win32Proj"
- TargetFrameworkVersion="0"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/MP"
- Optimization="0"
- AdditionalIncludeDirectories="&quot;../zlib-1.2.7&quot;;&quot;../jsoncpp-src-0.5.0/include&quot;;&quot;../lua-5.1.4/src&quot;;&quot;../tolua++-1.0.93/include&quot;;../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;..;../expat"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;XML_STATIC"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib Psapi.lib"
- OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName)_debug.exe"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/MP"
- Optimization="3"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="1"
- WholeProgramOptimization="true"
- AdditionalIncludeDirectories="&quot;../zlib-1.2.7&quot;;&quot;../jsoncpp-src-0.5.0/include&quot;;&quot;../lua-5.1.4/src&quot;;&quot;../tolua++-1.0.93/include&quot;;../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;..;../expat"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;XML_STATIC"
- RuntimeLibrary="0"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib Psapi.lib"
- OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName).exe"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- LinkTimeCodeGeneration="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release profiled|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/MP"
- Optimization="3"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="1"
- WholeProgramOptimization="true"
- AdditionalIncludeDirectories="&quot;../zlib-1.2.7&quot;;&quot;../jsoncpp-src-0.5.0/include&quot;;&quot;../lua-5.1.4/src&quot;;&quot;../tolua++-1.0.93/include&quot;;../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;..;../expat"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;XML_STATIC"
- RuntimeLibrary="0"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib Psapi.lib"
- OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName)_profiled.exe"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- LinkTimeCodeGeneration="1"
- TargetMachine="1"
- Profile="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- <File
- RelativePath=".\icon.ico"
- >
- </File>
- <File
- RelativePath=".\MCServer.rc"
- >
- </File>
- <File
- RelativePath=".\resource_MCServer.h"
- >
- </File>
- <File
- RelativePath="..\webadmin\template.html"
- >
- </File>
- </Filter>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\source\Authenticator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Authenticator.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockArea.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockArea.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockID.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockID.h"
- >
- </File>
- <File
- RelativePath="..\source\ByteBuffer.cpp"
- >
- </File>
- <File
- RelativePath="..\source\ByteBuffer.h"
- >
- </File>
- <File
- RelativePath="..\source\ChatColor.cpp"
- >
- </File>
- <File
- RelativePath="..\source\ChatColor.h"
- >
- </File>
- <File
- RelativePath="..\source\Chunk.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Chunk.h"
- >
- </File>
- <File
- RelativePath="..\source\Chunk.inl.h"
- >
- </File>
- <File
- RelativePath="..\source\ChunkDef.h"
- >
- </File>
- <File
- RelativePath="..\source\ChunkMap.cpp"
- >
- </File>
- <File
- RelativePath="..\source\ChunkMap.h"
- >
- </File>
- <File
- RelativePath="..\source\ChunkSender.cpp"
- >
- </File>
- <File
- RelativePath="..\source\ChunkSender.h"
- >
- </File>
- <File
- RelativePath="..\source\ClientHandle.cpp"
- >
- </File>
- <File
- RelativePath="..\source\ClientHandle.h"
- >
- </File>
- <File
- RelativePath="..\source\CommandOutput.cpp"
- >
- </File>
- <File
- RelativePath="..\source\CommandOutput.h"
- >
- </File>
- <File
- RelativePath="..\source\CraftingRecipes.cpp"
- >
- </File>
- <File
- RelativePath="..\source\CraftingRecipes.h"
- >
- </File>
- <File
- RelativePath="..\source\Cuboid.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Cuboid.h"
- >
- </File>
- <File
- RelativePath="..\source\Defines.h"
- >
- </File>
- <File
- RelativePath="..\source\Enchantments.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Enchantments.h"
- >
- </File>
- <File
- RelativePath="..\source\Endianness.h"
- >
- </File>
- <File
- RelativePath="..\source\FastRandom.cpp"
- >
- </File>
- <File
- RelativePath="..\source\FastRandom.h"
- >
- </File>
- <File
- RelativePath="..\source\FurnaceRecipe.cpp"
- >
- </File>
- <File
- RelativePath="..\source\FurnaceRecipe.h"
- >
- </File>
- <File
- RelativePath="..\source\Globals.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\source\Globals.h"
- >
- </File>
- <File
- RelativePath="..\source\Group.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Group.h"
- >
- </File>
- <File
- RelativePath="..\source\GroupManager.cpp"
- >
- </File>
- <File
- RelativePath="..\source\GroupManager.h"
- >
- </File>
- <File
- RelativePath="..\source\Inventory.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Inventory.h"
- >
- </File>
- <File
- RelativePath="..\source\Item.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Item.h"
- >
- </File>
- <File
- RelativePath="..\source\ItemGrid.cpp"
- >
- </File>
- <File
- RelativePath="..\source\ItemGrid.h"
- >
- </File>
- <File
- RelativePath="..\source\LeakFinder.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\source\LeakFinder.h"
- >
- </File>
- <File
- RelativePath="..\source\LightingThread.cpp"
- >
- </File>
- <File
- RelativePath="..\source\LightingThread.h"
- >
- </File>
- <File
- RelativePath="..\source\LinearInterpolation.cpp"
- >
- </File>
- <File
- RelativePath="..\source\LinearInterpolation.h"
- >
- </File>
- <File
- RelativePath="..\source\LinearUpscale.h"
- >
- </File>
- <File
- RelativePath="..\source\Log.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Log.h"
- >
- </File>
- <File
- RelativePath="..\source\main.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Matrix4f.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Matrix4f.h"
- >
- </File>
- <File
- RelativePath="..\source\MCLogger.cpp"
- >
- </File>
- <File
- RelativePath="..\source\MCLogger.h"
- >
- </File>
- <File
- RelativePath="..\source\MemoryLeak.h"
- >
- </File>
- <File
- RelativePath="..\source\MersenneTwister.h"
- >
- </File>
- <File
- RelativePath="..\source\MonsterConfig.cpp"
- >
- </File>
- <File
- RelativePath="..\source\MonsterConfig.h"
- >
- </File>
- <File
- RelativePath="..\source\Noise.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="1"
- OmitFramePointers="true"
- BasicRuntimeChecks="0"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\source\Noise.h"
- >
- </File>
- <File
- RelativePath="..\source\Piston.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Piston.h"
- >
- </File>
- <File
- RelativePath="..\source\ProbabDistrib.cpp"
- >
- </File>
- <File
- RelativePath="..\source\ProbabDistrib.h"
- >
- </File>
- <File
- RelativePath="..\source\RCONServer.cpp"
- >
- </File>
- <File
- RelativePath="..\source\RCONServer.h"
- >
- </File>
- <File
- RelativePath="..\source\ReferenceManager.cpp"
- >
- </File>
- <File
- RelativePath="..\source\ReferenceManager.h"
- >
- </File>
- <File
- RelativePath="..\source\Root.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Root.h"
- >
- </File>
- <File
- RelativePath="..\source\Server.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Server.h"
- >
- </File>
- <File
- RelativePath="..\source\StackWalker.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\source\StackWalker.h"
- >
- </File>
- <File
- RelativePath="..\source\StringCompression.cpp"
- >
- </File>
- <File
- RelativePath="..\source\StringCompression.h"
- >
- </File>
- <File
- RelativePath="..\source\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\source\StringUtils.h"
- >
- </File>
- <File
- RelativePath="..\source\Tracer.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Tracer.h"
- >
- </File>
- <File
- RelativePath="..\source\Vector3d.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Vector3d.h"
- >
- </File>
- <File
- RelativePath="..\source\Vector3f.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Vector3f.h"
- >
- </File>
- <File
- RelativePath="..\source\Vector3i.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Vector3i.h"
- >
- </File>
- <File
- RelativePath="..\source\WebAdmin.cpp"
- >
- </File>
- <File
- RelativePath="..\source\WebAdmin.h"
- >
- </File>
- <File
- RelativePath="..\source\World.cpp"
- >
- </File>
- <File
- RelativePath="..\source\World.h"
- >
- </File>
- <Filter
- Name="Mobs"
- >
- <File
- RelativePath="..\source\Mobs\AggressiveMonster.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\AggressiveMonster.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Bat.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Blaze.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Blaze.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Cavespider.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Cavespider.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Chicken.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Chicken.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Cow.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Cow.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Creeper.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Creeper.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Enderman.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Enderman.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Ghast.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Ghast.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Magmacube.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Magmacube.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Monster.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Monster.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Mooshroom.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Mooshroom.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Ocelot.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\PassiveAggressiveMonster.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\PassiveAggressiveMonster.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\PassiveMonster.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\PassiveMonster.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Pig.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Pig.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Sheep.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Sheep.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Silverfish.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Skeleton.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Skeleton.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Slime.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Slime.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Spider.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Spider.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Squid.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Squid.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Villager.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Villager.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Witch.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Witch.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Wolf.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Zombie.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Zombie.h"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Zombiepigman.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Mobs\Zombiepigman.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Entities"
- >
- <File
- RelativePath="..\source\Doors.h"
- >
- </File>
- <File
- RelativePath="..\source\Entity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Entity.h"
- >
- </File>
- <File
- RelativePath="..\source\FallingBlock.cpp"
- >
- </File>
- <File
- RelativePath="..\source\FallingBlock.h"
- >
- </File>
- <File
- RelativePath="..\source\Ladder.h"
- >
- </File>
- <File
- RelativePath="..\source\Minecart.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Minecart.h"
- >
- </File>
- <File
- RelativePath="..\source\Pawn.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Pawn.h"
- >
- </File>
- <File
- RelativePath="..\source\Pickup.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Pickup.h"
- >
- </File>
- <File
- RelativePath="..\source\Player.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Player.h"
- >
- </File>
- <File
- RelativePath="..\source\Sign.h"
- >
- </File>
- <File
- RelativePath="..\source\TNTEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\TNTEntity.h"
- >
- </File>
- </Filter>
- <Filter
- Name="UI"
- >
- <File
- RelativePath="..\source\UI\SlotArea.cpp"
- >
- </File>
- <File
- RelativePath="..\source\UI\SlotArea.h"
- >
- </File>
- <File
- RelativePath="..\source\UI\Window.cpp"
- >
- </File>
- <File
- RelativePath="..\source\UI\Window.h"
- >
- </File>
- <File
- RelativePath="..\source\UI\WindowOwner.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Simulator"
- >
- <File
- RelativePath="..\source\Simulator\DelayedFluidSimulator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\DelayedFluidSimulator.h"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\FireSimulator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\FireSimulator.h"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\FloodyFluidSimulator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\FloodyFluidSimulator.h"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\FluidSimulator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\FluidSimulator.h"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\NoopFluidSimulator.h"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\RedstoneSimulator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\RedstoneSimulator.h"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\SandSimulator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\SandSimulator.h"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\Simulator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\Simulator.h"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\SimulatorManager.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\SimulatorManager.h"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\VaporizeFluidSimulator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Simulator\VaporizeFluidSimulator.h"
- >
- </File>
- </Filter>
- <Filter
- Name="OSSupport"
- >
- <File
- RelativePath="..\source\OSSupport\BlockingTCPLink.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\BlockingTCPLink.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\CriticalSection.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\CriticalSection.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Event.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Event.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\File.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\File.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\GZipFile.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\GZipFile.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\IsThread.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\IsThread.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\ListenThread.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\ListenThread.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\MakeDir.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\MakeDir.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Semaphore.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Semaphore.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Sleep.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Sleep.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Socket.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Socket.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\SocketThreads.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\SocketThreads.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Thread.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Thread.h"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Timer.cpp"
- >
- </File>
- <File
- RelativePath="..\source\OSSupport\Timer.h"
- >
- </File>
- <Filter
- Name="Android Specific"
- >
- <File
- RelativePath="..\Android\jni\Android.mk"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\Android\jni\app-android.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\Android\jni\Application.mk"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\Android\jni\ToJava.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\Android\jni\ToJava.h"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- />
- </FileConfiguration>
- </File>
- </Filter>
- </Filter>
- <Filter
- Name="Bindings"
- >
- <File
- RelativePath="..\source\AllToLua.pkg"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- CommandLine="GenerateBindings.cmd&#x0D;&#x0A;"
- AdditionalDependencies="&quot;cTorch.h&quot;;&quot;cStairs.h&quot;;&quot;cLadder.h&quot;;&quot;../iniFile/iniFile.h&quot;;&quot;BlockID.h&quot;;&quot;PacketID.h&quot;;&quot;Defines.h&quot;;&quot;LuaFunctions.h&quot;;&quot;cStringMap.h&quot;;&quot;cChatColor.h&quot;;&quot;cClientHandle.h&quot;;&quot;cEntity.h&quot;;&quot;cPawn.h&quot;;&quot;cPlayer.h&quot;;&quot;cPluginManager.h&quot;;&quot;cPlugin.h&quot;;&quot;cPlugin_NewLua.h&quot;;&quot;cPlugin_Lua.h&quot;;&quot;cServer.h&quot;;&quot;cWorld.h&quot;;&quot;cInventory.h&quot;;&quot;cItem.h&quot;;&quot;cWebAdmin.h&quot;;&quot;cWebPlugin.h&quot;;&quot;cWebPlugin_Lua.h&quot;;&quot;cPickup.h&quot;;&quot;cRoot.h&quot;;&quot;cTCPLink.h&quot;;&quot;Vector3f.h&quot;;&quot;Vector3d.h&quot;;&quot;Vector3i.h&quot;;&quot;Matrix4f.h&quot;;&quot;cCuboid.h&quot;;&quot;cMCLogger.h&quot;;&quot;cTracer.h&quot;;&quot;cGroup.h&quot;;&quot;BlockArea.h&quot;;&quot;packets/cPacket_Login.h&quot;;&quot;packets/cPacket_BlockDig.h&quot;;&quot;packets/cPacket_BlockPlace.h&quot;"
- Outputs="Bindings.cpp"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- CommandLine="GenerateBindings.cmd&#x0D;&#x0A;"
- AdditionalDependencies="&quot;cTorch.h&quot;;&quot;cStairs.h&quot;;&quot;cLadder.h&quot;;&quot;../iniFile/iniFile.h&quot;;&quot;BlockID.h&quot;;&quot;PacketID.h&quot;;&quot;Defines.h&quot;;&quot;LuaFunctions.h&quot;;&quot;cStringMap.h&quot;;&quot;cChatColor.h&quot;;&quot;cClientHandle.h&quot;;&quot;cEntity.h&quot;;&quot;cPawn.h&quot;;&quot;cPlayer.h&quot;;&quot;cPluginManager.h&quot;;&quot;cPlugin.h&quot;;&quot;cPlugin_NewLua.h&quot;;&quot;cPlugin_Lua.h&quot;;&quot;cServer.h&quot;;&quot;cWorld.h&quot;;&quot;cInventory.h&quot;;&quot;cItem.h&quot;;&quot;cWebAdmin.h&quot;;&quot;cWebPlugin.h&quot;;&quot;cWebPlugin_Lua.h&quot;;&quot;cPickup.h&quot;;&quot;cRoot.h&quot;;&quot;cTCPLink.h&quot;;&quot;Vector3f.h&quot;;&quot;Vector3d.h&quot;;&quot;Vector3i.h&quot;;&quot;Matrix4f.h&quot;;&quot;cCuboid.h&quot;;&quot;cMCLogger.h&quot;;&quot;cTracer.h&quot;;&quot;cGroup.h&quot;;&quot;BlockArea.h&quot;;&quot;packets/cPacket_Login.h&quot;;&quot;packets/cPacket_BlockDig.h&quot;;&quot;packets/cPacket_BlockPlace.h&quot;"
- Outputs="Bindings.cpp"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCustomBuildTool"
- CommandLine="GenerateBindings.cmd&#x0D;&#x0A;"
- AdditionalDependencies="&quot;cTorch.h&quot;;&quot;cStairs.h&quot;;&quot;cLadder.h&quot;;&quot;../iniFile/iniFile.h&quot;;&quot;BlockID.h&quot;;&quot;PacketID.h&quot;;&quot;Defines.h&quot;;&quot;LuaFunctions.h&quot;;&quot;cStringMap.h&quot;;&quot;cChatColor.h&quot;;&quot;cClientHandle.h&quot;;&quot;cEntity.h&quot;;&quot;cPawn.h&quot;;&quot;cPlayer.h&quot;;&quot;cPluginManager.h&quot;;&quot;cPlugin.h&quot;;&quot;cPlugin_NewLua.h&quot;;&quot;cPlugin_Lua.h&quot;;&quot;cServer.h&quot;;&quot;cWorld.h&quot;;&quot;cInventory.h&quot;;&quot;cItem.h&quot;;&quot;cWebAdmin.h&quot;;&quot;cWebPlugin.h&quot;;&quot;cWebPlugin_Lua.h&quot;;&quot;cPickup.h&quot;;&quot;cRoot.h&quot;;&quot;cTCPLink.h&quot;;&quot;Vector3f.h&quot;;&quot;Vector3d.h&quot;;&quot;Vector3i.h&quot;;&quot;Matrix4f.h&quot;;&quot;cCuboid.h&quot;;&quot;cMCLogger.h&quot;;&quot;cTracer.h&quot;;&quot;cGroup.h&quot;;&quot;BlockArea.h&quot;;&quot;packets/cPacket_Login.h&quot;;&quot;packets/cPacket_BlockDig.h&quot;;&quot;packets/cPacket_BlockPlace.h&quot;"
- Outputs="Bindings.cpp"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\MCServer\API.txt"
- >
- </File>
- <File
- RelativePath="..\source\Bindings.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\source\Bindings.h"
- >
- </File>
- <File
- RelativePath="..\source\LuaFunctions.h"
- >
- </File>
- <File
- RelativePath="..\source\LuaWindow.cpp"
- >
- </File>
- <File
- RelativePath="..\source\LuaWindow.h"
- >
- </File>
- <File
- RelativePath="..\source\ManualBindings.cpp"
- >
- </File>
- <File
- RelativePath="..\source\ManualBindings.h"
- >
- </File>
- <File
- RelativePath="..\source\Plugin.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Plugin.h"
- >
- </File>
- <File
- RelativePath="..\source\Plugin_NewLua.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Plugin_NewLua.h"
- >
- </File>
- <File
- RelativePath="..\source\Plugin_Squirrel.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Plugin_Squirrel.h"
- >
- </File>
- <File
- RelativePath="..\source\PluginManager.cpp"
- >
- </File>
- <File
- RelativePath="..\source\PluginManager.h"
- >
- </File>
- <File
- RelativePath="..\source\SquirrelCommandBinder.cpp"
- >
- </File>
- <File
- RelativePath="..\source\SquirrelCommandBinder.h"
- >
- </File>
- <File
- RelativePath="..\source\StringMap.cpp"
- >
- </File>
- <File
- RelativePath="..\source\StringMap.h"
- >
- </File>
- <File
- RelativePath="..\source\tolua++.h"
- >
- </File>
- <File
- RelativePath="..\source\tolua_base.h"
- >
- </File>
- <File
- RelativePath="..\source\WebPlugin.cpp"
- >
- </File>
- <File
- RelativePath="..\source\WebPlugin.h"
- >
- </File>
- <Filter
- Name="Squirrel"
- >
- <File
- RelativePath="..\source\squirrelbindings\SquirrelArray.h"
- >
- </File>
- <File
- RelativePath="..\source\squirrelbindings\SquirrelBaseClass.h"
- >
- </File>
- <File
- RelativePath="..\source\squirrelbindings\SquirrelBindings.cpp"
- >
- </File>
- <File
- RelativePath="..\source\squirrelbindings\SquirrelBindings.h"
- >
- </File>
- <File
- RelativePath="..\source\squirrelbindings\SquirrelFunctions.cpp"
- >
- </File>
- <File
- RelativePath="..\source\squirrelbindings\SquirrelFunctions.h"
- >
- </File>
- <File
- RelativePath="..\source\squirrelbindings\SquirrelObject.h"
- >
- </File>
- </Filter>
- </Filter>
- <Filter
- Name="External"
- >
- <File
- RelativePath="..\iniFile\iniFile.cpp"
- >
- </File>
- <File
- RelativePath="..\iniFile\iniFile.h"
- >
- </File>
- <File
- RelativePath="..\source\md5\md5.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\source\md5\md5.h"
- >
- </File>
- </Filter>
- <Filter
- Name="WorldStorage"
- >
- <File
- RelativePath="..\source\WorldStorage\FastNBT.cpp"
- >
- </File>
- <File
- RelativePath="..\source\WorldStorage\FastNBT.h"
- >
- </File>
- <File
- RelativePath="..\source\WorldStorage\NBTChunkSerializer.cpp"
- >
- </File>
- <File
- RelativePath="..\source\WorldStorage\NBTChunkSerializer.h"
- >
- </File>
- <File
- RelativePath="..\source\WorldStorage\WorldStorage.cpp"
- >
- </File>
- <File
- RelativePath="..\source\WorldStorage\WorldStorage.h"
- >
- </File>
- <File
- RelativePath="..\source\WorldStorage\WSSAnvil.cpp"
- >
- </File>
- <File
- RelativePath="..\source\WorldStorage\WSSAnvil.h"
- >
- </File>
- <File
- RelativePath="..\source\WorldStorage\WSSCompact.cpp"
- >
- </File>
- <File
- RelativePath="..\source\WorldStorage\WSSCompact.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Generating"
- >
- <File
- RelativePath="..\source\Generating\BioGen.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\BioGen.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\Caves.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\Caves.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\ChunkDesc.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\ChunkDesc.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\ChunkGenerator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\ChunkGenerator.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\CompoGen.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\CompoGen.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\ComposableGenerator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\ComposableGenerator.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\DistortedHeightmap.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\DistortedHeightmap.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\EndGen.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\EndGen.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\FinishGen.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\FinishGen.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\HeiGen.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\HeiGen.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\MineShafts.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\MineShafts.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\Noise3DGenerator.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\Noise3DGenerator.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\Ravines.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\Ravines.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\StructGen.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\StructGen.h"
- >
- </File>
- <File
- RelativePath="..\source\Generating\Trees.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Generating\Trees.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Blocks"
- >
- <File
- RelativePath="..\source\Blocks\BlockBed.cpp"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockBed.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockBrewingStand.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockCactus.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockCauldron.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockChest.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockCloth.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockCobWeb.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockCrops.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockDeadBush.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockDirt.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockDoor.cpp"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockDoor.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockDropSpenser.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockEnderchest.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockFarmland.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockFenceGate.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockFire.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockFlower.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockFlowerPot.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockFluid.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockFurnace.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockGlass.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockGlowstone.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockGravel.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockHandler.cpp"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockHandler.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockHopper.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockIce.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockLadder.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockLeaves.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockLever.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockLever.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockMelon.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockMushroom.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockMycelium.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockNote.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockOre.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockPiston.cpp"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockPiston.h"
- >
- </File>
- <File
- RelativePath="..\source\Blocks\BlockRail.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockRedstone.cpp"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockRedstone.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockRedstoneOre.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockRedstoneRepeater.cpp"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockRedstoneRepeater.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockRedstoneTorch.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockSand.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockSapling.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockSign.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockSlab.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockSnow.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockStairs.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockStems.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockStone.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockSugarcane.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockTallGrass.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockTorch.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockVine.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockWood.h"
- >
- </File>
- <File
- RelativePath="..\source\blocks\BlockWorkbench.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Items"
- >
- <File
- RelativePath="..\source\items\ItemBed.h"
- >
- </File>
- <File
- RelativePath="..\source\Items\ItemBrewingStand.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemBucket.h"
- >
- </File>
- <File
- RelativePath="..\source\Items\ItemCauldron.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemCloth.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemDoor.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemDye.h"
- >
- </File>
- <File
- RelativePath="..\source\Items\ItemFlowerPot.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemFood.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemHandler.cpp"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemHandler.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemHoe.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemLeaves.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemLighter.h"
- >
- </File>
- <File
- RelativePath="..\source\Items\ItemMinecart.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemPickaxe.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemRedstoneDust.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemRedstoneRepeater.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemSapling.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemSeeds.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemShears.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemShovel.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemSign.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemSlab.h"
- >
- </File>
- <File
- RelativePath="..\source\Items\ItemSpawnEgg.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemSugarcane.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemSword.h"
- >
- </File>
- <File
- RelativePath="..\source\items\ItemWood.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Protocol"
- >
- <File
- RelativePath="..\source\Protocol\ChunkDataSerializer.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\ChunkDataSerializer.h"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol.h"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol125.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol125.h"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol132.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol132.h"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol14x.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol14x.h"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol15x.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol15x.h"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol16x.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\Protocol16x.h"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\ProtocolRecognizer.cpp"
- >
- </File>
- <File
- RelativePath="..\source\Protocol\ProtocolRecognizer.h"
- >
- </File>
- </Filter>
- <Filter
- Name="SQLite"
- >
- <File
- RelativePath="..\source\sqlite\lsqlite3.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\source\sqlite\sqlite3.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\source\sqlite\sqlite3.h"
- >
- </File>
- <File
- RelativePath="..\source\sqlite\urls.txt"
- >
- </File>
- </Filter>
- <Filter
- Name="LuaExpat"
- >
- <File
- RelativePath="..\source\LuaExpat\lxplib.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="0"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\source\LuaExpat\lxplib.h"
- >
- </File>
- </Filter>
- <Filter
- Name="BlockEntities"
- >
- <File
- RelativePath="..\source\BlockEntities\BlockEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\BlockEntityWithItems.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\ChestEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\ChestEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\DispenserEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\DispenserEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\DropperEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\DropperEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\DropSpenserEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\DropSpenserEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\FurnaceEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\FurnaceEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\HopperEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\HopperEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\JukeboxEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\JukeboxEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\NoteEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\NoteEntity.h"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\SignEntity.cpp"
- >
- </File>
- <File
- RelativePath="..\source\BlockEntities\SignEntity.h"
- >
- </File>
- </Filter>
- </Filter>
- <Filter
- Name="Config files"
- >
- <File
- RelativePath="..\MCServer\crafting.txt"
- >
- </File>
- <File
- RelativePath="..\MCServer\furnace.txt"
- >
- </File>
- <File
- RelativePath="..\MCServer\groups.ini"
- >
- </File>
- <File
- RelativePath="..\MCServer\items.ini"
- >
- </File>
- <File
- RelativePath="..\MCServer\monsters.ini"
- >
- </File>
- <File
- RelativePath="..\MCServer\settings.ini"
- >
- </File>
- <File
- RelativePath="..\MCServer\terrain.ini"
- >
- </File>
- <File
- RelativePath="..\MCServer\users.ini"
- >
- </File>
- <File
- RelativePath="..\MCServer\webadmin.ini"
- >
- </File>
- </Filter>
- <Filter
- Name="Plugins"
- >
- <Filter
- Name="Core"
- >
- <File
- RelativePath="..\MCServer\Plugins\Core\ban.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\console.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\coords.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\gamemode.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\gotoworld.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\help.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\item.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\kick.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\main.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\motd.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\onblockdig.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\onblockplace.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\oncraftingnorecipe.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\onkilled.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\onlogin.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\onplayerjoin.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\playerlist.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\pluginlist.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\regeneratechunk.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\reload.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\spawn.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\stop.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\teleport.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\time.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\top.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\unban.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\viewdistance.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\web_chat.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\web_manageplugins.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\web_permissions.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\web_playerlist.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\web_serversettings.lua"
- >
- </File>
- <File
- RelativePath="..\MCServer\Plugins\Core\web_whitelist.lua"
- >
- </File>
- </Filter>
- <Filter
- Name="ChatLog"
- >
- <File
- RelativePath="..\MCServer\Plugins\ChatLog\plugin.lua"
- >
- </File>
- </Filter>
- <Filter
- Name="Debuggers"
- >
- <File
- RelativePath="..\MCServer\Plugins\Debuggers\Debuggers.lua"
- >
- </File>
- </Filter>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="UTF-8"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="MCServer"
+ ProjectGUID="{32012054-0C96-4C43-AB27-174FF8E72D66}"
+ RootNamespace="MCServer"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="0"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;../zlib-1.2.7&quot;;&quot;../jsoncpp-src-0.5.0/include&quot;;&quot;../lua-5.1.4/src&quot;;&quot;../tolua++-1.0.93/include&quot;;../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;..;../expat"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;XML_STATIC"
+ MinimalRebuild="false"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib Psapi.lib"
+ OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName)_debug.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
+ Optimization="3"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ WholeProgramOptimization="true"
+ AdditionalIncludeDirectories="&quot;../zlib-1.2.7&quot;;&quot;../jsoncpp-src-0.5.0/include&quot;;&quot;../lua-5.1.4/src&quot;;&quot;../tolua++-1.0.93/include&quot;;../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;..;../expat"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;XML_STATIC"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib Psapi.lib"
+ OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName).exe"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ LinkTimeCodeGeneration="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release profiled|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
+ Optimization="3"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ WholeProgramOptimization="true"
+ AdditionalIncludeDirectories="&quot;../zlib-1.2.7&quot;;&quot;../jsoncpp-src-0.5.0/include&quot;;&quot;../lua-5.1.4/src&quot;;&quot;../tolua++-1.0.93/include&quot;;../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;..;../expat"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;XML_STATIC"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib Psapi.lib"
+ OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName)_profiled.exe"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ LinkTimeCodeGeneration="1"
+ TargetMachine="1"
+ Profile="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\icon.ico"
+ >
+ </File>
+ <File
+ RelativePath=".\MCServer.rc"
+ >
+ </File>
+ <File
+ RelativePath=".\resource_MCServer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\webadmin\template.html"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\source\Authenticator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Authenticator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockArea.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockArea.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockID.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockID.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ByteBuffer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ByteBuffer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ChatColor.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ChatColor.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Chunk.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Chunk.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Chunk.inl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ChunkDef.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ChunkMap.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ChunkMap.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ChunkSender.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ChunkSender.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ClientHandle.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ClientHandle.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\CommandOutput.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\CommandOutput.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\CraftingRecipes.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\CraftingRecipes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Cuboid.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Cuboid.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Defines.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Enchantments.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Enchantments.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Endianness.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\FastRandom.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\FastRandom.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\FurnaceRecipe.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\FurnaceRecipe.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Globals.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\source\Globals.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Group.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Group.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\GroupManager.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\GroupManager.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Inventory.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Inventory.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Item.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Item.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ItemGrid.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ItemGrid.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LeakFinder.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\source\LeakFinder.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LightingThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LightingThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LinearInterpolation.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LinearInterpolation.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LinearUpscale.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Log.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Log.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\main.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Matrix4f.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Matrix4f.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\MCLogger.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\MCLogger.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\MemoryLeak.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\MersenneTwister.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\MonsterConfig.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\MonsterConfig.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Noise.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ OmitFramePointers="true"
+ BasicRuntimeChecks="0"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\source\Noise.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Piston.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Piston.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ProbabDistrib.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ProbabDistrib.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\RCONServer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\RCONServer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ReferenceManager.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ReferenceManager.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Root.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Root.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Server.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Server.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\StackWalker.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\source\StackWalker.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\StringCompression.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\StringCompression.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\StringUtils.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Tracer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Tracer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Vector3d.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Vector3d.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Vector3f.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Vector3f.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Vector3i.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Vector3i.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WebAdmin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WebAdmin.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\World.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\World.h"
+ >
+ </File>
+ <Filter
+ Name="Mobs"
+ >
+ <File
+ RelativePath="..\source\Mobs\AggressiveMonster.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\AggressiveMonster.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Bat.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Blaze.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Blaze.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Cavespider.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Cavespider.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Chicken.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Chicken.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Cow.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Cow.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Creeper.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Creeper.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Enderman.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Enderman.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Ghast.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Ghast.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Magmacube.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Magmacube.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Monster.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Monster.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Mooshroom.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Mooshroom.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Ocelot.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\PassiveAggressiveMonster.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\PassiveAggressiveMonster.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\PassiveMonster.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\PassiveMonster.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Pig.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Pig.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Sheep.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Sheep.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Silverfish.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Skeleton.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Skeleton.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Slime.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Slime.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Spider.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Spider.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Squid.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Squid.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Villager.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Villager.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Witch.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Witch.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Wolf.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Zombie.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Zombie.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Zombiepigman.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Mobs\Zombiepigman.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Entities"
+ >
+ <File
+ RelativePath="..\source\Doors.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Entity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Entity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\FallingBlock.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\FallingBlock.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Ladder.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Minecart.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Minecart.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Pawn.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Pawn.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Pickup.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Pickup.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Player.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Player.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Sign.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\TNTEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\TNTEntity.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="UI"
+ >
+ <File
+ RelativePath="..\source\UI\SlotArea.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\UI\SlotArea.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\UI\Window.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\UI\Window.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\UI\WindowOwner.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Simulator"
+ >
+ <File
+ RelativePath="..\source\Simulator\DelayedFluidSimulator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\DelayedFluidSimulator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\FireSimulator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\FireSimulator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\FloodyFluidSimulator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\FloodyFluidSimulator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\FluidSimulator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\FluidSimulator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\NoopFluidSimulator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\RedstoneSimulator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\RedstoneSimulator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\SandSimulator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\SandSimulator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\Simulator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\Simulator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\SimulatorManager.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\SimulatorManager.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\VaporizeFluidSimulator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Simulator\VaporizeFluidSimulator.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="OSSupport"
+ >
+ <File
+ RelativePath="..\source\OSSupport\BlockingTCPLink.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\BlockingTCPLink.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\CriticalSection.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\CriticalSection.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Event.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Event.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\File.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\File.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\GZipFile.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\GZipFile.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\IsThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\IsThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\ListenThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\ListenThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\MakeDir.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\MakeDir.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Semaphore.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Semaphore.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Sleep.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Sleep.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Socket.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Socket.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\SocketThreads.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\SocketThreads.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Thread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Thread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Timer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\OSSupport\Timer.h"
+ >
+ </File>
+ <Filter
+ Name="Android Specific"
+ >
+ <File
+ RelativePath="..\Android\jni\Android.mk"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Android\jni\app-android.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Android\jni\Application.mk"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Android\jni\ToJava.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Android\jni\ToJava.h"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Bindings"
+ >
+ <File
+ RelativePath="..\source\AllToLua.pkg"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="GenerateBindings.cmd&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;cTorch.h&quot;;&quot;cStairs.h&quot;;&quot;cLadder.h&quot;;&quot;../iniFile/iniFile.h&quot;;&quot;BlockID.h&quot;;&quot;PacketID.h&quot;;&quot;Defines.h&quot;;&quot;LuaFunctions.h&quot;;&quot;cStringMap.h&quot;;&quot;cChatColor.h&quot;;&quot;cClientHandle.h&quot;;&quot;cEntity.h&quot;;&quot;cPawn.h&quot;;&quot;cPlayer.h&quot;;&quot;cPluginManager.h&quot;;&quot;cPlugin.h&quot;;&quot;cPlugin_NewLua.h&quot;;&quot;cPlugin_Lua.h&quot;;&quot;cServer.h&quot;;&quot;cWorld.h&quot;;&quot;cInventory.h&quot;;&quot;cItem.h&quot;;&quot;cWebAdmin.h&quot;;&quot;cWebPlugin.h&quot;;&quot;cWebPlugin_Lua.h&quot;;&quot;cPickup.h&quot;;&quot;cRoot.h&quot;;&quot;cTCPLink.h&quot;;&quot;Vector3f.h&quot;;&quot;Vector3d.h&quot;;&quot;Vector3i.h&quot;;&quot;Matrix4f.h&quot;;&quot;cCuboid.h&quot;;&quot;cMCLogger.h&quot;;&quot;cTracer.h&quot;;&quot;cGroup.h&quot;;&quot;BlockArea.h&quot;;&quot;packets/cPacket_Login.h&quot;;&quot;packets/cPacket_BlockDig.h&quot;;&quot;packets/cPacket_BlockPlace.h&quot;"
+ Outputs="Bindings.cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="GenerateBindings.cmd&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;cTorch.h&quot;;&quot;cStairs.h&quot;;&quot;cLadder.h&quot;;&quot;../iniFile/iniFile.h&quot;;&quot;BlockID.h&quot;;&quot;PacketID.h&quot;;&quot;Defines.h&quot;;&quot;LuaFunctions.h&quot;;&quot;cStringMap.h&quot;;&quot;cChatColor.h&quot;;&quot;cClientHandle.h&quot;;&quot;cEntity.h&quot;;&quot;cPawn.h&quot;;&quot;cPlayer.h&quot;;&quot;cPluginManager.h&quot;;&quot;cPlugin.h&quot;;&quot;cPlugin_NewLua.h&quot;;&quot;cPlugin_Lua.h&quot;;&quot;cServer.h&quot;;&quot;cWorld.h&quot;;&quot;cInventory.h&quot;;&quot;cItem.h&quot;;&quot;cWebAdmin.h&quot;;&quot;cWebPlugin.h&quot;;&quot;cWebPlugin_Lua.h&quot;;&quot;cPickup.h&quot;;&quot;cRoot.h&quot;;&quot;cTCPLink.h&quot;;&quot;Vector3f.h&quot;;&quot;Vector3d.h&quot;;&quot;Vector3i.h&quot;;&quot;Matrix4f.h&quot;;&quot;cCuboid.h&quot;;&quot;cMCLogger.h&quot;;&quot;cTracer.h&quot;;&quot;cGroup.h&quot;;&quot;BlockArea.h&quot;;&quot;packets/cPacket_Login.h&quot;;&quot;packets/cPacket_BlockDig.h&quot;;&quot;packets/cPacket_BlockPlace.h&quot;"
+ Outputs="Bindings.cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="GenerateBindings.cmd&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;cTorch.h&quot;;&quot;cStairs.h&quot;;&quot;cLadder.h&quot;;&quot;../iniFile/iniFile.h&quot;;&quot;BlockID.h&quot;;&quot;PacketID.h&quot;;&quot;Defines.h&quot;;&quot;LuaFunctions.h&quot;;&quot;cStringMap.h&quot;;&quot;cChatColor.h&quot;;&quot;cClientHandle.h&quot;;&quot;cEntity.h&quot;;&quot;cPawn.h&quot;;&quot;cPlayer.h&quot;;&quot;cPluginManager.h&quot;;&quot;cPlugin.h&quot;;&quot;cPlugin_NewLua.h&quot;;&quot;cPlugin_Lua.h&quot;;&quot;cServer.h&quot;;&quot;cWorld.h&quot;;&quot;cInventory.h&quot;;&quot;cItem.h&quot;;&quot;cWebAdmin.h&quot;;&quot;cWebPlugin.h&quot;;&quot;cWebPlugin_Lua.h&quot;;&quot;cPickup.h&quot;;&quot;cRoot.h&quot;;&quot;cTCPLink.h&quot;;&quot;Vector3f.h&quot;;&quot;Vector3d.h&quot;;&quot;Vector3i.h&quot;;&quot;Matrix4f.h&quot;;&quot;cCuboid.h&quot;;&quot;cMCLogger.h&quot;;&quot;cTracer.h&quot;;&quot;cGroup.h&quot;;&quot;BlockArea.h&quot;;&quot;packets/cPacket_Login.h&quot;;&quot;packets/cPacket_BlockDig.h&quot;;&quot;packets/cPacket_BlockPlace.h&quot;"
+ Outputs="Bindings.cpp"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\MCServer\API.txt"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Bindings.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\source\Bindings.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LuaFunctions.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LuaScript.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LuaScript.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LuaWindow.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\LuaWindow.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ManualBindings.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\ManualBindings.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Plugin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Plugin.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Plugin_NewLua.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Plugin_NewLua.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Plugin_Squirrel.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Plugin_Squirrel.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\PluginManager.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\PluginManager.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\SquirrelCommandBinder.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\SquirrelCommandBinder.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\StringMap.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\StringMap.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\tolua++.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\tolua_base.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WebPlugin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WebPlugin.h"
+ >
+ </File>
+ <Filter
+ Name="Squirrel"
+ >
+ <File
+ RelativePath="..\source\squirrelbindings\SquirrelArray.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\squirrelbindings\SquirrelBaseClass.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\squirrelbindings\SquirrelBindings.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\squirrelbindings\SquirrelBindings.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\squirrelbindings\SquirrelFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\squirrelbindings\SquirrelFunctions.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\squirrelbindings\SquirrelObject.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="External"
+ >
+ <File
+ RelativePath="..\iniFile\iniFile.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\iniFile\iniFile.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\md5\md5.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\source\md5\md5.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="WorldStorage"
+ >
+ <File
+ RelativePath="..\source\WorldStorage\FastNBT.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WorldStorage\FastNBT.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WorldStorage\NBTChunkSerializer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WorldStorage\NBTChunkSerializer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WorldStorage\WorldStorage.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WorldStorage\WorldStorage.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WorldStorage\WSSAnvil.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WorldStorage\WSSAnvil.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WorldStorage\WSSCompact.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\WorldStorage\WSSCompact.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Generating"
+ >
+ <File
+ RelativePath="..\source\Generating\BioGen.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\BioGen.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\Caves.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\Caves.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\ChunkDesc.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\ChunkDesc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\ChunkGenerator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\ChunkGenerator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\CompoGen.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\CompoGen.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\ComposableGenerator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\ComposableGenerator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\DistortedHeightmap.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\DistortedHeightmap.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\EndGen.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\EndGen.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\FinishGen.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\FinishGen.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\HeiGen.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\HeiGen.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\MineShafts.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\MineShafts.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\Noise3DGenerator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\Noise3DGenerator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\Ravines.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\Ravines.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\StructGen.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\StructGen.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\Trees.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Generating\Trees.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Blocks"
+ >
+ <File
+ RelativePath="..\source\Blocks\BlockBed.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockBed.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockBrewingStand.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockCactus.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockCauldron.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockChest.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockCloth.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockCobWeb.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockCrops.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockDeadBush.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockDirt.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockDoor.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockDoor.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockDropSpenser.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockEnderchest.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockFarmland.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockFenceGate.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockFire.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockFlower.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockFlowerPot.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockFluid.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockFurnace.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockGlass.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockGlowstone.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockGravel.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockHandler.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockHandler.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockHopper.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockIce.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockLadder.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockLeaves.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockLever.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockLever.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockMelon.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockMushroom.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockMycelium.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockNote.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockOre.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockPiston.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockPiston.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Blocks\BlockRail.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockRedstone.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockRedstone.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockRedstoneOre.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockRedstoneRepeater.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockRedstoneRepeater.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockRedstoneTorch.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockSand.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockSapling.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockSign.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockSlab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockSnow.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockStairs.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockStems.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockStone.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockSugarcane.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockTallGrass.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockTorch.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockVine.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockWood.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\blocks\BlockWorkbench.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Items"
+ >
+ <File
+ RelativePath="..\source\items\ItemBed.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Items\ItemBrewingStand.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemBucket.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Items\ItemCauldron.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemCloth.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemDoor.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemDye.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Items\ItemFlowerPot.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemFood.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemHandler.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemHandler.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemHoe.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemLeaves.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemLighter.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Items\ItemMinecart.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemPickaxe.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemRedstoneDust.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemRedstoneRepeater.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemSapling.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemSeeds.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemShears.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemShovel.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemSign.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemSlab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Items\ItemSpawnEgg.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemSugarcane.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemSword.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\items\ItemWood.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Protocol"
+ >
+ <File
+ RelativePath="..\source\Protocol\ChunkDataSerializer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\ChunkDataSerializer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol125.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol125.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol132.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol132.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol14x.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol14x.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol15x.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol15x.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol16x.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\Protocol16x.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\ProtocolRecognizer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\Protocol\ProtocolRecognizer.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="SQLite"
+ >
+ <File
+ RelativePath="..\source\sqlite\lsqlite3.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\source\sqlite\sqlite3.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\source\sqlite\sqlite3.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\sqlite\urls.txt"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="LuaExpat"
+ >
+ <File
+ RelativePath="..\source\LuaExpat\lxplib.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\source\LuaExpat\lxplib.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="BlockEntities"
+ >
+ <File
+ RelativePath="..\source\BlockEntities\BlockEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\BlockEntityWithItems.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\ChestEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\ChestEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\DispenserEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\DispenserEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\DropperEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\DropperEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\DropSpenserEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\DropSpenserEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\FurnaceEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\FurnaceEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\HopperEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\HopperEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\JukeboxEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\JukeboxEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\NoteEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\NoteEntity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\SignEntity.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\source\BlockEntities\SignEntity.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Config files"
+ >
+ <File
+ RelativePath="..\MCServer\crafting.txt"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\furnace.txt"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\groups.ini"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\items.ini"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\monsters.ini"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\settings.ini"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\terrain.ini"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\users.ini"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\webadmin.ini"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Plugins"
+ >
+ <Filter
+ Name="Core"
+ >
+ <File
+ RelativePath="..\MCServer\Plugins\Core\ban.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\console.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\coords.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\gamemode.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\gotoworld.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\help.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\item.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\kick.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\main.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\motd.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\onblockdig.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\onblockplace.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\oncraftingnorecipe.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\onkilled.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\onlogin.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\onplayerjoin.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\playerlist.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\pluginlist.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\regeneratechunk.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\reload.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\spawn.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\stop.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\teleport.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\time.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\top.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\unban.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\viewdistance.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\web_chat.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\web_manageplugins.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\web_permissions.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\web_playerlist.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\web_serversettings.lua"
+ >
+ </File>
+ <File
+ RelativePath="..\MCServer\Plugins\Core\web_whitelist.lua"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="ChatLog"
+ >
+ <File
+ RelativePath="..\MCServer\Plugins\ChatLog\plugin.lua"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Debuggers"
+ >
+ <File
+ RelativePath="..\MCServer\Plugins\Debuggers\Debuggers.lua"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/VC2008/Squirrel3.vcproj b/VC2008/Squirrel3.vcproj
index 928930842..f0067c72e 100644
--- a/VC2008/Squirrel3.vcproj
+++ b/VC2008/Squirrel3.vcproj
@@ -1,384 +1,384 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="Squirrel3"
- ProjectGUID="{54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}"
- RootNamespace="Squirrel3"
- Keyword="ManagedCProj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\Squirrel3"
- IntermediateDirectory="$(ConfigurationName)\Squirrel3"
- ConfigurationType="4"
- CharacterSet="0"
- ManagedExtensions="0"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\squirrel_3_0_1_stable\include"
- PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\Squirrel3"
- IntermediateDirectory="$(ConfigurationName)\Squirrel3"
- ConfigurationType="4"
- CharacterSet="0"
- ManagedExtensions="0"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="../squirrel_3_0_1_stable/include"
- PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release profiled|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\Squirrel3"
- IntermediateDirectory="$(ConfigurationName)\Squirrel3"
- ConfigurationType="4"
- CharacterSet="0"
- ManagedExtensions="0"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="../squirrel_3_0_1_stable/include"
- PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- <AssemblyReference
- RelativePath="System.dll"
- AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
- MinFrameworkVersion="131072"
- />
- <AssemblyReference
- RelativePath="System.Data.dll"
- AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
- MinFrameworkVersion="131072"
- />
- <AssemblyReference
- RelativePath="System.XML.dll"
- AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
- MinFrameworkVersion="131072"
- />
- </References>
- <Files>
- <Filter
- Name="sqstdlib"
- >
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdaux.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdblob.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdblobimpl.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdio.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdmath.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdrex.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdstream.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdstream.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdstring.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdsystem.cpp"
- >
- </File>
- </Filter>
- <Filter
- Name="squirrel"
- >
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqapi.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqarray.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqbaselib.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqclass.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqclass.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqclosure.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqcompiler.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqcompiler.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqdebug.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqfuncproto.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqfuncstate.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqfuncstate.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqlexer.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqlexer.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqmem.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqobject.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqobject.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqopcodes.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqpcheader.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqstate.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqstate.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqstring.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqtable.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqtable.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\squserdata.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\squtils.h"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqvm.cpp"
- >
- </File>
- <File
- RelativePath="..\squirrel_3_0_1_stable\squirrel\sqvm.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="Squirrel3"
+ ProjectGUID="{54DBF6CE-D1A8-4CCB-A249-4BF1CA9B7E4C}"
+ RootNamespace="Squirrel3"
+ Keyword="ManagedCProj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\Squirrel3"
+ IntermediateDirectory="$(ConfigurationName)\Squirrel3"
+ ConfigurationType="4"
+ CharacterSet="0"
+ ManagedExtensions="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\squirrel_3_0_1_stable\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\Squirrel3"
+ IntermediateDirectory="$(ConfigurationName)\Squirrel3"
+ ConfigurationType="4"
+ CharacterSet="0"
+ ManagedExtensions="0"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../squirrel_3_0_1_stable/include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\Squirrel3"
+ IntermediateDirectory="$(ConfigurationName)\Squirrel3"
+ ConfigurationType="4"
+ CharacterSet="0"
+ ManagedExtensions="0"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../squirrel_3_0_1_stable/include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ <AssemblyReference
+ RelativePath="System.dll"
+ AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
+ MinFrameworkVersion="131072"
+ />
+ <AssemblyReference
+ RelativePath="System.Data.dll"
+ AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
+ MinFrameworkVersion="131072"
+ />
+ <AssemblyReference
+ RelativePath="System.XML.dll"
+ AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
+ MinFrameworkVersion="131072"
+ />
+ </References>
+ <Files>
+ <Filter
+ Name="sqstdlib"
+ >
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdaux.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdblob.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdblobimpl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdio.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdmath.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdrex.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdstream.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdstream.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdstring.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\sqstdlib\sqstdsystem.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="squirrel"
+ >
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqapi.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqarray.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqbaselib.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqclass.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqclass.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqclosure.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqcompiler.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqcompiler.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqdebug.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqfuncproto.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqfuncstate.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqfuncstate.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqlexer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqlexer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqmem.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqobject.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqobject.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqopcodes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqpcheader.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqstate.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqstate.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqstring.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqtable.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqtable.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\squserdata.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\squtils.h"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqvm.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\squirrel_3_0_1_stable\squirrel\sqvm.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/VC2008/ToLua.vcproj b/VC2008/ToLua.vcproj
index b1210bb17..21875818b 100644
--- a/VC2008/ToLua.vcproj
+++ b/VC2008/ToLua.vcproj
@@ -1,248 +1,248 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="ToLua"
- ProjectGUID="{EEAB54AD-114C-4AB8-8482-0A52D502BD35}"
- RootNamespace="ToLua"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\ToLua"
- IntermediateDirectory="$(ConfigurationName)\ToLua"
- ConfigurationType="4"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../tolua++-1.0.93/include;../lua-5.1.4/src"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\ToLua"
- IntermediateDirectory="$(ConfigurationName)\ToLua"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../tolua++-1.0.93/include;../lua-5.1.4/src"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release profiled|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\tolua"
- IntermediateDirectory="$(ConfigurationName)\tolua"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../tolua++-1.0.93/include;../lua-5.1.4/src"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\tolua++-1.0.93\src\bin\tolua.c"
- >
- </File>
- <File
- RelativePath="..\tolua++-1.0.93\src\lib\tolua_event.c"
- >
- </File>
- <File
- RelativePath="..\tolua++-1.0.93\src\lib\tolua_event.h"
- >
- </File>
- <File
- RelativePath="..\tolua++-1.0.93\src\lib\tolua_is.c"
- >
- </File>
- <File
- RelativePath="..\tolua++-1.0.93\src\lib\tolua_map.c"
- >
- </File>
- <File
- RelativePath="..\tolua++-1.0.93\src\lib\tolua_push.c"
- >
- </File>
- <File
- RelativePath="..\tolua++-1.0.93\src\lib\tolua_to.c"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="ToLua"
+ ProjectGUID="{EEAB54AD-114C-4AB8-8482-0A52D502BD35}"
+ RootNamespace="ToLua"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\ToLua"
+ IntermediateDirectory="$(ConfigurationName)\ToLua"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../tolua++-1.0.93/include;../lua-5.1.4/src"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\ToLua"
+ IntermediateDirectory="$(ConfigurationName)\ToLua"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="../tolua++-1.0.93/include;../lua-5.1.4/src"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\tolua"
+ IntermediateDirectory="$(ConfigurationName)\tolua"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="../tolua++-1.0.93/include;../lua-5.1.4/src"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\tolua++-1.0.93\src\bin\tolua.c"
+ >
+ </File>
+ <File
+ RelativePath="..\tolua++-1.0.93\src\lib\tolua_event.c"
+ >
+ </File>
+ <File
+ RelativePath="..\tolua++-1.0.93\src\lib\tolua_event.h"
+ >
+ </File>
+ <File
+ RelativePath="..\tolua++-1.0.93\src\lib\tolua_is.c"
+ >
+ </File>
+ <File
+ RelativePath="..\tolua++-1.0.93\src\lib\tolua_map.c"
+ >
+ </File>
+ <File
+ RelativePath="..\tolua++-1.0.93\src\lib\tolua_push.c"
+ >
+ </File>
+ <File
+ RelativePath="..\tolua++-1.0.93\src\lib\tolua_to.c"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/VC2008/WebServer.vcproj b/VC2008/WebServer.vcproj
index 078100bfd..36519d86a 100644
--- a/VC2008/WebServer.vcproj
+++ b/VC2008/WebServer.vcproj
@@ -1,304 +1,304 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="WebServer"
- ProjectGUID="{9A476537-42C0-4848-AB40-15CFE83D17A8}"
- RootNamespace="WebServer"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\WebServer"
- IntermediateDirectory="$(ConfigurationName)\webserver"
- ConfigurationType="4"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\WebServer"
- IntermediateDirectory="$(ConfigurationName)\webserver"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release profiled|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\webserver"
- IntermediateDirectory="$(ConfigurationName)\webserver"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="Globals.h"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\WebServer\base64.cpp"
- >
- </File>
- <File
- RelativePath="..\WebServer\base64.h"
- >
- </File>
- <File
- RelativePath="..\WebServer\Events.cpp"
- >
- </File>
- <File
- RelativePath="..\WebServer\Events.h"
- >
- </File>
- <File
- RelativePath="..\WebServer\Globals.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release profiled|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\WebServer\Globals.h"
- >
- </File>
- <File
- RelativePath="..\WebServer\Socket.cpp"
- >
- </File>
- <File
- RelativePath="..\WebServer\Socket.h"
- >
- </File>
- <File
- RelativePath="..\WebServer\StdHelpers.cpp"
- >
- </File>
- <File
- RelativePath="..\WebServer\StdHelpers.h"
- >
- </File>
- <File
- RelativePath="..\WebServer\Tracer.h"
- >
- </File>
- <File
- RelativePath="..\WebServer\UrlHelper.cpp"
- >
- </File>
- <File
- RelativePath="..\WebServer\UrlHelper.h"
- >
- </File>
- <File
- RelativePath="..\WebServer\WebServer.cpp"
- >
- </File>
- <File
- RelativePath="..\WebServer\WebServer.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="WebServer"
+ ProjectGUID="{9A476537-42C0-4848-AB40-15CFE83D17A8}"
+ RootNamespace="WebServer"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\WebServer"
+ IntermediateDirectory="$(ConfigurationName)\webserver"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\WebServer"
+ IntermediateDirectory="$(ConfigurationName)\webserver"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\webserver"
+ IntermediateDirectory="$(ConfigurationName)\webserver"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\WebServer\base64.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\base64.h"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\Events.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\Events.h"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\Globals.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\WebServer\Globals.h"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\Socket.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\Socket.h"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\StdHelpers.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\StdHelpers.h"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\Tracer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\UrlHelper.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\UrlHelper.h"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\WebServer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\WebServer\WebServer.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/VC2008/expat.vcproj b/VC2008/expat.vcproj
index 4ae896e2c..edd401e04 100644
--- a/VC2008/expat.vcproj
+++ b/VC2008/expat.vcproj
@@ -1,227 +1,227 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="expat"
- ProjectGUID="{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}"
- RootNamespace="expat"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)/expat"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;COMPILED_FROM_DSP"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)/expat"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\expat\ascii.h"
- >
- </File>
- <File
- RelativePath="..\expat\asciitab.h"
- >
- </File>
- <File
- RelativePath="..\expat\expat.h"
- >
- </File>
- <File
- RelativePath="..\expat\expat_external.h"
- >
- </File>
- <File
- RelativePath="..\expat\iasciitab.h"
- >
- </File>
- <File
- RelativePath="..\expat\internal.h"
- >
- </File>
- <File
- RelativePath="..\expat\latin1tab.h"
- >
- </File>
- <File
- RelativePath="..\expat\nametab.h"
- >
- </File>
- <File
- RelativePath="..\expat\utf8tab.h"
- >
- </File>
- <File
- RelativePath="..\expat\winconfig.h"
- >
- </File>
- <File
- RelativePath="..\expat\xmlparse.c"
- >
- </File>
- <File
- RelativePath="..\expat\xmlrole.c"
- >
- </File>
- <File
- RelativePath="..\expat\xmlrole.h"
- >
- </File>
- <File
- RelativePath="..\expat\xmltok.c"
- >
- </File>
- <File
- RelativePath="..\expat\xmltok.h"
- >
- </File>
- <File
- RelativePath="..\expat\xmltok_impl.c"
- >
- </File>
- <File
- RelativePath="..\expat\xmltok_impl.h"
- >
- </File>
- <File
- RelativePath="..\expat\xmltok_ns.c"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="expat"
+ ProjectGUID="{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}"
+ RootNamespace="expat"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)/expat"
+ ConfigurationType="4"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;COMPILED_FROM_DSP"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)/expat"
+ ConfigurationType="4"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\expat\ascii.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\asciitab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\expat.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\expat_external.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\iasciitab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\internal.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\latin1tab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\nametab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\utf8tab.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\winconfig.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\xmlparse.c"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\xmlrole.c"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\xmlrole.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\xmltok.c"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\xmltok.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\xmltok_impl.c"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\xmltok_impl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\expat\xmltok_ns.c"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/VC2008/icon_128.png b/VC2008/icon_128.png
new file mode 100644
index 000000000..87d939a04
--- /dev/null
+++ b/VC2008/icon_128.png
Binary files differ
diff --git a/VC2008/icon_256.png b/VC2008/icon_256.png
new file mode 100644
index 000000000..9a77a490f
--- /dev/null
+++ b/VC2008/icon_256.png
Binary files differ
diff --git a/VC2008/profile_run.cmd b/VC2008/profile_run.cmd
index 47c2630d2..e8e6eb11b 100644
--- a/VC2008/profile_run.cmd
+++ b/VC2008/profile_run.cmd
@@ -1,73 +1,73 @@
-@echo off
-::
-:: Profiling using a MSVC standalone profiler
-::
-:: See http://www.codeproject.com/Articles/144643/Profiling-of-C-Applications-in-Visual-Studio-for-F for details
-::
-
-
-
-
-set pt="C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools"
-set appdir=..\MCServer
-set app=MCServer_profiled.exe
-
-:: outputdir is relative to appdir!
-set outputdir=..\Profiling
-set outputname=profile.vsp
-set output=%outputdir%\%outputname%
-
-
-
-
-
-:: Must cd to MCServer's directory so that it can find settings.ini etc.
-cd %appdir%
-
-::Create the output directory, if it didn't exist
-mkdir %outputdir%
-
-
-
-
-
-:: Start the profiler
-%pt%\vsperfcmd /start:sample /output:%output%
-if errorlevel 1 goto haderror
-
-:: Launch the application via the profiler
-%pt%\vsperfcmd /launch:%app%
-if errorlevel 1 goto haderror
-
-:: Shut down the profiler (this command waits, until the application is terminated)
-%pt%\vsperfcmd /shutdown
-if errorlevel 1 goto haderror
-
-
-
-
-
-:: cd to outputdir, so that the reports are generated there
-cd %outputdir%
-
-:: generate the report files (.csv)
-%pt%\vsperfreport /summary:all %outputname% /symbolpath:"srv*C:\Programovani\Symbols*http://msdl.microsoft.com/download/symbols"
-if errorlevel 1 goto haderror
-
-
-
-
-
-goto finished
-
-
-
-
-:haderror
-echo An error was encountered
-pause
-
-
-
-
-:finished
+@echo off
+::
+:: Profiling using a MSVC standalone profiler
+::
+:: See http://www.codeproject.com/Articles/144643/Profiling-of-C-Applications-in-Visual-Studio-for-F for details
+::
+
+
+
+
+set pt="C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools"
+set appdir=..\MCServer
+set app=MCServer_profiled.exe
+
+:: outputdir is relative to appdir!
+set outputdir=..\Profiling
+set outputname=profile.vsp
+set output=%outputdir%\%outputname%
+
+
+
+
+
+:: Must cd to MCServer's directory so that it can find settings.ini etc.
+cd %appdir%
+
+::Create the output directory, if it didn't exist
+mkdir %outputdir%
+
+
+
+
+
+:: Start the profiler
+%pt%\vsperfcmd /start:sample /output:%output%
+if errorlevel 1 goto haderror
+
+:: Launch the application via the profiler
+%pt%\vsperfcmd /launch:%app%
+if errorlevel 1 goto haderror
+
+:: Shut down the profiler (this command waits, until the application is terminated)
+%pt%\vsperfcmd /shutdown
+if errorlevel 1 goto haderror
+
+
+
+
+
+:: cd to outputdir, so that the reports are generated there
+cd %outputdir%
+
+:: generate the report files (.csv)
+%pt%\vsperfreport /summary:all %outputname% /symbolpath:"srv*C:\Programovani\Symbols*http://msdl.microsoft.com/download/symbols"
+if errorlevel 1 goto haderror
+
+
+
+
+
+goto finished
+
+
+
+
+:haderror
+echo An error was encountered
+pause
+
+
+
+
+:finished
diff --git a/VC2008/resource_MCServer.h b/VC2008/resource_MCServer.h
index 2b306eb98..42f6c4eaf 100644
--- a/VC2008/resource_MCServer.h
+++ b/VC2008/resource_MCServer.h
@@ -1,5 +1,5 @@
-#ifndef IDC_STATIC
-#define IDC_STATIC (-1)
-#endif
-
-#define IDI_ICON1 101
+#ifndef IDC_STATIC
+#define IDC_STATIC (-1)
+#endif
+
+#define IDI_ICON1 101
diff --git a/VC2008/zlib.vcproj b/VC2008/zlib.vcproj
index adc62ac0b..4693c7284 100644
--- a/VC2008/zlib.vcproj
+++ b/VC2008/zlib.vcproj
@@ -1,324 +1,324 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="zlib"
- ProjectGUID="{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}"
- RootNamespace="zlib"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\zlib"
- IntermediateDirectory="$(ConfigurationName)\zlib"
- ConfigurationType="4"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\zlib"
- IntermediateDirectory="$(ConfigurationName)\zlib"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release profiled|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)\zlib"
- IntermediateDirectory="$(ConfigurationName)\zlib"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\zlib-1.2.7\adler32.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\compress.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\crc32.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\crc32.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\deflate.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\deflate.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\gzclose.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\gzguts.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\gzlib.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\gzread.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\gzwrite.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\infback.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\inffast.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\inffast.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\inffixed.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\inflate.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\inflate.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\inftrees.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\inftrees.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\trees.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\trees.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\uncompr.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\zconf.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\zlib.h"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\zutil.c"
- >
- </File>
- <File
- RelativePath="..\zlib-1.2.7\zutil.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="zlib"
+ ProjectGUID="{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}"
+ RootNamespace="zlib"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\zlib"
+ IntermediateDirectory="$(ConfigurationName)\zlib"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\zlib"
+ IntermediateDirectory="$(ConfigurationName)\zlib"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\zlib"
+ IntermediateDirectory="$(ConfigurationName)\zlib"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\zlib-1.2.7\adler32.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\compress.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\crc32.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\crc32.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\deflate.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\deflate.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\gzclose.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\gzguts.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\gzlib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\gzread.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\gzwrite.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\infback.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\inffast.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\inffast.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\inffixed.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\inflate.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\inflate.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\inftrees.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\inftrees.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\trees.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\trees.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\uncompr.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\zconf.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\zlib.h"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\zutil.c"
+ >
+ </File>
+ <File
+ RelativePath="..\zlib-1.2.7\zutil.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/WebServer/Events.h b/WebServer/Events.h
index c8a6a7df9..352dc4056 100644
--- a/WebServer/Events.h
+++ b/WebServer/Events.h
@@ -1,18 +1,18 @@
-#pragma once
-
-class cEvents
-{
-public:
- cEvents( unsigned int a_NumEvents = 1 );
- ~cEvents();
-
- void Wait();
- void Set(unsigned int a_EventNum = 0);
-private:
- unsigned int m_NumEvents;
- void* m_Handle; // HANDLE[] pointer
-
-#ifndef _WIN32
- bool m_bNamed;
-#endif
-};
+#pragma once
+
+class cEvents
+{
+public:
+ cEvents( unsigned int a_NumEvents = 1 );
+ ~cEvents();
+
+ void Wait();
+ void Set(unsigned int a_EventNum = 0);
+private:
+ unsigned int m_NumEvents;
+ void* m_Handle; // HANDLE[] pointer
+
+#ifndef _WIN32
+ bool m_bNamed;
+#endif
+};
diff --git a/WebServer/Globals.h b/WebServer/Globals.h
index fd31ba703..d60f34720 100644
--- a/WebServer/Globals.h
+++ b/WebServer/Globals.h
@@ -1,15 +1,15 @@
-
-// Globals.h
-
-// This file gets included from every module in the project, so that global symbols may be introduced easily
-// Also used for precompiled header generation in MSVC environments
-
-
-
-
-
-#include "../source/Globals.h"
-
-
-
-
+
+// Globals.h
+
+// This file gets included from every module in the project, so that global symbols may be introduced easily
+// Also used for precompiled header generation in MSVC environments
+
+
+
+
+
+#include "../source/Globals.h"
+
+
+
+
diff --git a/WebServer/Socket.h b/WebServer/Socket.h
index 5f1248107..b144659c7 100644
--- a/WebServer/Socket.h
+++ b/WebServer/Socket.h
@@ -1,127 +1,127 @@
-/*
- Socket.h
-
- Copyright (C) 2002-2004 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-
-#ifndef SOCKET_H
-#define SOCKET_H
-
-
-
-
-
-#ifndef _WIN32
- typedef int SOCKET;
- #define SOCKET_ERROR (-1)
- #define INVALID_SOCKET (-1)
- #define closesocket close
-#endif // !_WIN32
-
-
-
-
-
-enum TypeSocket {BlockingSocket, NonBlockingSocket};
-
-
-
-
-
-class Socket
-{
-public:
-
- virtual ~Socket();
- Socket(const Socket&);
- Socket& operator=(Socket&);
-
- std::string ReceiveLine();
- std::string ReceiveBytes( unsigned int a_Length );
-
- bool IsValid(void) const;
-
- void Close( bool a_WaitSend = false );
-
- // The parameter of SendLine is not a const reference
- // because SendLine modifes the std::string passed.
- void SendLine (std::string);
-
- // The parameter of SendBytes is a const reference
- // because SendBytes does not modify the std::string passed
- // (in contrast to SendLine).
- void SendBytes(const std::string&);
-
-protected:
- friend class SocketServer;
- friend class SocketSelect;
-
- Socket(SOCKET s);
- Socket();
-
-
- SOCKET s_;
-
- int* refCounter_;
-
-private:
- static void Start();
- static void End();
- static int nofSockets_;
-};
-
-
-
-
-
-class SocketServer :
- public Socket
-{
-public:
- SocketServer(int port, int connections, TypeSocket type=BlockingSocket);
-
- Socket* Accept();
-};
-
-
-
-
-
-// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/wsapiref_2tiq.asp
-class SocketSelect
-{
-public:
- SocketSelect(Socket const * const s1, Socket const * const s2=NULL, TypeSocket type=BlockingSocket);
-
- bool Readable(Socket const * const s);
-
-private:
- fd_set fds_;
-};
-
-#endif
+/*
+ Socket.h
+
+ Copyright (C) 2002-2004 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+
+#ifndef SOCKET_H
+#define SOCKET_H
+
+
+
+
+
+#ifndef _WIN32
+ typedef int SOCKET;
+ #define SOCKET_ERROR (-1)
+ #define INVALID_SOCKET (-1)
+ #define closesocket close
+#endif // !_WIN32
+
+
+
+
+
+enum TypeSocket {BlockingSocket, NonBlockingSocket};
+
+
+
+
+
+class Socket
+{
+public:
+
+ virtual ~Socket();
+ Socket(const Socket&);
+ Socket& operator=(Socket&);
+
+ std::string ReceiveLine();
+ std::string ReceiveBytes( unsigned int a_Length );
+
+ bool IsValid(void) const;
+
+ void Close( bool a_WaitSend = false );
+
+ // The parameter of SendLine is not a const reference
+ // because SendLine modifes the std::string passed.
+ void SendLine (std::string);
+
+ // The parameter of SendBytes is a const reference
+ // because SendBytes does not modify the std::string passed
+ // (in contrast to SendLine).
+ void SendBytes(const std::string&);
+
+protected:
+ friend class SocketServer;
+ friend class SocketSelect;
+
+ Socket(SOCKET s);
+ Socket();
+
+
+ SOCKET s_;
+
+ int* refCounter_;
+
+private:
+ static void Start();
+ static void End();
+ static int nofSockets_;
+};
+
+
+
+
+
+class SocketServer :
+ public Socket
+{
+public:
+ SocketServer(int port, int connections, TypeSocket type=BlockingSocket);
+
+ Socket* Accept();
+};
+
+
+
+
+
+// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/wsapiref_2tiq.asp
+class SocketSelect
+{
+public:
+ SocketSelect(Socket const * const s1, Socket const * const s2=NULL, TypeSocket type=BlockingSocket);
+
+ bool Readable(Socket const * const s);
+
+private:
+ fd_set fds_;
+};
+
+#endif
diff --git a/WebServer/StdHelpers.h b/WebServer/StdHelpers.h
index e9efa3dc2..1011881f8 100644
--- a/WebServer/StdHelpers.h
+++ b/WebServer/StdHelpers.h
@@ -1,65 +1,65 @@
-/*
- stdHelpers.h
-
- Copyright (C) 2002-2005 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-
-#ifndef STDHELPERS_H__
-#define STDHELPERS_H__
-
-#include <string>
-#include <sstream>
-
-std::string ReplaceInStr(const std::string& in, const std::string& search_for, const std::string& replace_with);
-
-void ToUpper(std::string& s);
-void ToLower(std::string& s);
-
-template <class T>
-T To(std::string const& s) {
- T ret;
-
- std::stringstream stream;
- stream << s;
- stream >> ret;
-
- return ret;
-}
-
-template<class T>
-std::string StringFrom(T const& t) {
- std::string ret;
-
- std::stringstream stream;
- stream << t;
- stream >> ret;
-
- return ret;
-}
-
+/*
+ stdHelpers.h
+
+ Copyright (C) 2002-2005 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+
+#ifndef STDHELPERS_H__
+#define STDHELPERS_H__
+
+#include <string>
+#include <sstream>
+
+std::string ReplaceInStr(const std::string& in, const std::string& search_for, const std::string& replace_with);
+
+void ToUpper(std::string& s);
+void ToLower(std::string& s);
+
+template <class T>
+T To(std::string const& s) {
+ T ret;
+
+ std::stringstream stream;
+ stream << s;
+ stream >> ret;
+
+ return ret;
+}
+
+template<class T>
+std::string StringFrom(T const& t) {
+ std::string ret;
+
+ std::stringstream stream;
+ stream << t;
+ stream >> ret;
+
+ return ret;
+}
+
#endif \ No newline at end of file
diff --git a/WebServer/Tracer.h b/WebServer/Tracer.h
index bce350219..c13d5128f 100644
--- a/WebServer/Tracer.h
+++ b/WebServer/Tracer.h
@@ -1,113 +1,113 @@
-/*
- Tracer.h
-
- Copyright (C) 2002-2004 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- The most current version of Tracer.h can be found at
- http://www.adp-gmbh.ch/cpp/common/Tracer.html
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-
-#ifndef TRACER_H__
-#define TRACER_H__
-
-#ifdef DO_TRACE
-
-#include <string>
-#include <sstream>
-
-#include <windows.h>
-
-#define StartTrace(x) TraceFunc_::StartTrace_(x)
-#define Trace(x) dummy_____for_trace_func______.Trace_(x)
-#define Trace2(x,y) dummy_____for_trace_func______.Trace_(x,y)
-#define TraceFunc(x) TraceFunc_ dummy_____for_trace_func______(x)
-#define TraceFunc2(x,y) TraceFunc_ dummy_____for_trace_func______(x,y)
-
-class TraceFunc_ {
- std::string func_name_;
- public:
- /*
- Calling TraceFunc_ indents the output until the enclosing scope ( {...} )
- is left.
- */
- TraceFunc_(std::string const&);
- TraceFunc_(std::string const&, std::string const& something);
- ~TraceFunc_();
-
- /*
- Creates the trace output file named by filename.
- Must be called before any other tracing function.
- Use the StartTrace macro for it.
- */
- static void StartTrace_(std::string const& filename);
-
- template <class T>
- void Trace_(T const& t) {
- DWORD d;
- std::string indent_s;
- std::stringstream s;
-
- s << t;
-
- for (int i=0; i< indent; i++) indent_s += " ";
-
- ::WriteFile(trace_file_,indent_s.c_str(), indent_s.size(), &d, 0);
- ::WriteFile(trace_file_, s.str().c_str(), s.str().size() ,&d, 0);
- ::WriteFile(trace_file_,"\x0a",1,&d,0);
- }
-
- template <class T, class U>
- void Trace_(T const& t, U const& u) {
- std::string indent_s;
- std::stringstream s;
-
- s << t;
- s << u;
- Trace_(s.str());
- }
-
- static int indent;
- /* trace_file_ is a HANDLE for the file in which the traced output goes.
- The file is opened (that is, created) by calling StartTrace_.
- Better yet, use the StartTrace macro
- to create the file.
- */
- static HANDLE trace_file_;
-};
-
-#else
-
-#define StartTrace(x)
-#define Trace(x)
-#define Trace2(x,y)
-#define TraceFunc(x)
-#define TraceFunc2(x,y)
-
-#endif
-
-#endif // TRACER_H__
+/*
+ Tracer.h
+
+ Copyright (C) 2002-2004 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ The most current version of Tracer.h can be found at
+ http://www.adp-gmbh.ch/cpp/common/Tracer.html
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+
+#ifndef TRACER_H__
+#define TRACER_H__
+
+#ifdef DO_TRACE
+
+#include <string>
+#include <sstream>
+
+#include <windows.h>
+
+#define StartTrace(x) TraceFunc_::StartTrace_(x)
+#define Trace(x) dummy_____for_trace_func______.Trace_(x)
+#define Trace2(x,y) dummy_____for_trace_func______.Trace_(x,y)
+#define TraceFunc(x) TraceFunc_ dummy_____for_trace_func______(x)
+#define TraceFunc2(x,y) TraceFunc_ dummy_____for_trace_func______(x,y)
+
+class TraceFunc_ {
+ std::string func_name_;
+ public:
+ /*
+ Calling TraceFunc_ indents the output until the enclosing scope ( {...} )
+ is left.
+ */
+ TraceFunc_(std::string const&);
+ TraceFunc_(std::string const&, std::string const& something);
+ ~TraceFunc_();
+
+ /*
+ Creates the trace output file named by filename.
+ Must be called before any other tracing function.
+ Use the StartTrace macro for it.
+ */
+ static void StartTrace_(std::string const& filename);
+
+ template <class T>
+ void Trace_(T const& t) {
+ DWORD d;
+ std::string indent_s;
+ std::stringstream s;
+
+ s << t;
+
+ for (int i=0; i< indent; i++) indent_s += " ";
+
+ ::WriteFile(trace_file_,indent_s.c_str(), indent_s.size(), &d, 0);
+ ::WriteFile(trace_file_, s.str().c_str(), s.str().size() ,&d, 0);
+ ::WriteFile(trace_file_,"\x0a",1,&d,0);
+ }
+
+ template <class T, class U>
+ void Trace_(T const& t, U const& u) {
+ std::string indent_s;
+ std::stringstream s;
+
+ s << t;
+ s << u;
+ Trace_(s.str());
+ }
+
+ static int indent;
+ /* trace_file_ is a HANDLE for the file in which the traced output goes.
+ The file is opened (that is, created) by calling StartTrace_.
+ Better yet, use the StartTrace macro
+ to create the file.
+ */
+ static HANDLE trace_file_;
+};
+
+#else
+
+#define StartTrace(x)
+#define Trace(x)
+#define Trace2(x,y)
+#define TraceFunc(x)
+#define TraceFunc2(x,y)
+
+#endif
+
+#endif // TRACER_H__
diff --git a/WebServer/UrlHelper.h b/WebServer/UrlHelper.h
index 06ab00446..12f12c6fe 100644
--- a/WebServer/UrlHelper.h
+++ b/WebServer/UrlHelper.h
@@ -1,42 +1,42 @@
-/*
- UrlHelper.h
-
- Copyright (C) 2002-2004 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-#ifndef __URL_HELPER_H__
-#define __URL_HELPER_H__
-
-#include <string>
-#include <map>
-
-void SplitUrl (std::string const& url, std::string& protocol, std::string& server, std::string& path);
-bool RemoveProtocolFromUrl(std::string const& url, std::string& protocol, std::string& rest);
-
-void SplitGetReq (std::string et_req, std::string& path, std::map<std::string, std::string>& params);
-
-#endif
+/*
+ UrlHelper.h
+
+ Copyright (C) 2002-2004 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+#ifndef __URL_HELPER_H__
+#define __URL_HELPER_H__
+
+#include <string>
+#include <map>
+
+void SplitUrl (std::string const& url, std::string& protocol, std::string& server, std::string& path);
+bool RemoveProtocolFromUrl(std::string const& url, std::string& protocol, std::string& rest);
+
+void SplitGetReq (std::string et_req, std::string& path, std::map<std::string, std::string>& params);
+
+#endif
diff --git a/WebServer/WebServer.h b/WebServer/WebServer.h
index 044974cb8..882624db5 100644
--- a/WebServer/WebServer.h
+++ b/WebServer/WebServer.h
@@ -1,108 +1,108 @@
-/*
- WebServer.h
-
- Copyright (C) 2003-2004 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-
-
-class cEvents;
-class Socket;
-class SocketServer;
-class webserver {
-public:
- struct formdata
- {
- std::string name_;
- std::string filename_;
- std::string content_type_;
- std::string value_;
- };
-
- struct http_request {
-
- http_request()
- : s_( 0 )
- , content_length_( 0 )
- , authentication_given_(false)
- {}
-
- Socket* s_;
- std::string method_;
- std::string path_;
- std::map<std::string, std::string> params_;
- std::map<std::string, std::string> params_post_;
-
- std::string accept_;
- std::string accept_language_;
- std::string accept_encoding_;
- std::string user_agent_;
- int content_length_;
- std::string content_type_;
- std::vector< formdata > multipart_formdata_;
-
- /* status_: used to transmit server's error status, such as
- o 202 OK
- o 404 Not Found
- and so on */
- std::string status_;
-
- /* auth_realm_: allows to set the basic realm for an authentication,
- no need to additionally set status_ if set */
- std::string auth_realm_;
-
- std::string answer_;
-
- /* authentication_given_ is true when the user has entered a username and password.
- These can then be read from username_ and password_ */
- bool authentication_given_;
- std::string username_;
- std::string password_;
- };
-
- typedef void (*request_func) (http_request*);
- webserver(unsigned int port_to_listen, request_func);
- ~webserver();
-
- bool Begin();
- void Stop();
-
-private:
- bool m_bStop;
-
- #ifdef _WIN32
- static unsigned __stdcall Request(void*);
- #else
- static void* Request(void*);
- #endif
-
- static request_func request_func_;
-
- cEvents * m_Events;
- SocketServer* m_Socket;
-};
+/*
+ WebServer.h
+
+ Copyright (C) 2003-2004 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+
+
+class cEvents;
+class Socket;
+class SocketServer;
+class webserver {
+public:
+ struct formdata
+ {
+ std::string name_;
+ std::string filename_;
+ std::string content_type_;
+ std::string value_;
+ };
+
+ struct http_request {
+
+ http_request()
+ : s_( 0 )
+ , content_length_( 0 )
+ , authentication_given_(false)
+ {}
+
+ Socket* s_;
+ std::string method_;
+ std::string path_;
+ std::map<std::string, std::string> params_;
+ std::map<std::string, std::string> params_post_;
+
+ std::string accept_;
+ std::string accept_language_;
+ std::string accept_encoding_;
+ std::string user_agent_;
+ int content_length_;
+ std::string content_type_;
+ std::vector< formdata > multipart_formdata_;
+
+ /* status_: used to transmit server's error status, such as
+ o 202 OK
+ o 404 Not Found
+ and so on */
+ std::string status_;
+
+ /* auth_realm_: allows to set the basic realm for an authentication,
+ no need to additionally set status_ if set */
+ std::string auth_realm_;
+
+ std::string answer_;
+
+ /* authentication_given_ is true when the user has entered a username and password.
+ These can then be read from username_ and password_ */
+ bool authentication_given_;
+ std::string username_;
+ std::string password_;
+ };
+
+ typedef void (*request_func) (http_request*);
+ webserver(unsigned int port_to_listen, request_func);
+ ~webserver();
+
+ bool Begin();
+ void Stop();
+
+private:
+ bool m_bStop;
+
+ #ifdef _WIN32
+ static unsigned __stdcall Request(void*);
+ #else
+ static void* Request(void*);
+ #endif
+
+ static request_func request_func_;
+
+ cEvents * m_Events;
+ SocketServer* m_Socket;
+};
diff --git a/WebServer/base64.h b/WebServer/base64.h
index 91b731417..65d5db8b2 100644
--- a/WebServer/base64.h
+++ b/WebServer/base64.h
@@ -1,4 +1,4 @@
-#include <string>
-
-std::string base64_encode(unsigned char const* , unsigned int len);
-std::string base64_decode(std::string const& s);
+#include <string>
+
+std::string base64_encode(unsigned char const* , unsigned int len);
+std::string base64_decode(std::string const& s);
diff --git a/clean.bat b/clean.bat
index efe5b3b6b..08e4cc610 100644
--- a/clean.bat
+++ b/clean.bat
@@ -1,24 +1,24 @@
-del *.ncb
-del *.ilk
-del *.lib
-del *.exp
-del *.map
-del *.pdb
-del log.txt
-del *.bsc
-del applog.txt
-del *.suo /AH
-del *.user
-del debug\*.* /Q
-del release\*.* /Q
-rd release /Q
-rd debug /Q
-
-cd MCServer
-del MCServer.exe
-del MCServer_debug.exe
-cd ..
-
-cd VC2010
-call clean.bat
+del *.ncb
+del *.ilk
+del *.lib
+del *.exp
+del *.map
+del *.pdb
+del log.txt
+del *.bsc
+del applog.txt
+del *.suo /AH
+del *.user
+del debug\*.* /Q
+del release\*.* /Q
+rd release /Q
+rd debug /Q
+
+cd MCServer
+del MCServer.exe
+del MCServer_debug.exe
+cd ..
+
+cd VC2010
+call clean.bat
cd .. \ No newline at end of file
diff --git a/cloc-exclude.txt b/cloc-exclude.txt
index 20460169c..03c9531a8 100644
--- a/cloc-exclude.txt
+++ b/cloc-exclude.txt
@@ -1,27 +1,27 @@
-CryptoPP
-expat
-jsoncpp-src-0.5.0
-lua-5.1.4
-MemDumpAnalysis/expat
-source/LuaExpat
-source/SQLite
-squirrel_3_0_1_stable
-VC2008/CryptoPP.vcproj
-zlib-1.2.5
-zlib-1.2.7
-source/Bindings.cpp
-source/Bindings.h
-source/LeakFinder.cpp
-source/LeakFinder.h
-source/StackWalker.cpp
-source/StackWalker.h
-BiomeVisualiser/BiomeVisualiser.vcproj
-MemDumpAnalysis/MemDumpAnalysis.vcproj
-ProtoProxy/ProtoProxy.vcproj
-Tests/NoiseTest/NoiseTest.vcproj
-Tools/BlockZapper/BlockZapper.vcproj
-Tools/ToLuaDoxy/ToLuaDoxy.vcproj
-VC2008
-Install
-log.xml
+CryptoPP
+expat
+jsoncpp-src-0.5.0
+lua-5.1.4
+MemDumpAnalysis/expat
+source/LuaExpat
+source/SQLite
+squirrel_3_0_1_stable
+VC2008/CryptoPP.vcproj
+zlib-1.2.5
+zlib-1.2.7
+source/Bindings.cpp
+source/Bindings.h
+source/LeakFinder.cpp
+source/LeakFinder.h
+source/StackWalker.cpp
+source/StackWalker.h
+BiomeVisualiser/BiomeVisualiser.vcproj
+MemDumpAnalysis/MemDumpAnalysis.vcproj
+ProtoProxy/ProtoProxy.vcproj
+Tests/NoiseTest/NoiseTest.vcproj
+Tools/BlockZapper/BlockZapper.vcproj
+Tools/ToLuaDoxy/ToLuaDoxy.vcproj
+VC2008
+Install
+log.xml
build \ No newline at end of file
diff --git a/docs/API class inheritance - blockentities.gv b/docs/API class inheritance - blockentities.gv
index b913a9787..966588c5f 100644
--- a/docs/API class inheritance - blockentities.gv
+++ b/docs/API class inheritance - blockentities.gv
@@ -1,15 +1,15 @@
-digraph
-{
-rankdir=LR
-
-cBlockEntity -> cBlockEntityWithItems
-cBlockEntity -> cJukeboxEntity
-cBlockEntity -> cNoteEntity
-cBlockEntity -> cSignEntity
-cBlockEntityWithItems -> cChestEntity
-cBlockEntityWithItems -> cDropSpenserEntity
-cBlockEntityWithItems -> cFurnaceEntity
-cBlockEntityWithItems -> cHopperEntity
-cDropSpenserEntity -> cDropperEntity
-cDropSpenserEntity -> cDispenserEntity
+digraph
+{
+rankdir=LR
+
+cBlockEntity -> cBlockEntityWithItems
+cBlockEntity -> cJukeboxEntity
+cBlockEntity -> cNoteEntity
+cBlockEntity -> cSignEntity
+cBlockEntityWithItems -> cChestEntity
+cBlockEntityWithItems -> cDropSpenserEntity
+cBlockEntityWithItems -> cFurnaceEntity
+cBlockEntityWithItems -> cHopperEntity
+cDropSpenserEntity -> cDropperEntity
+cDropSpenserEntity -> cDispenserEntity
} \ No newline at end of file
diff --git a/docs/API class inheritance - entities.gv b/docs/API class inheritance - entities.gv
index 92cfb9a3e..4e167e1d3 100644
--- a/docs/API class inheritance - entities.gv
+++ b/docs/API class inheritance - entities.gv
@@ -1,44 +1,44 @@
-digraph
-{
-rankdir=LR
-
-# Entities:
-cEntity -> cFallingBlock
-cEntity -> cMinecart
-cEntity -> cPawn
-cEntity -> cPickup
-cEntity -> cTNT
-cMinecart -> cEmptyMinecart
-cMinecart -> cMinecartWithChest
-cMinecart -> cMinecartWithFurnace
-
-# Mobs:
-cPawn -> cMonster
-cMonster -> cAggressiveMonster
-cMonster -> cPassiveMonster
-cAggressiveMonster -> cPassiveAggressiveMonster
-cPassiveMonster -> cBat
-cAggressiveMonster -> cBlaze
-cAggressiveMonster -> cCaveSpider
-cPassiveMonster -> cChicken
-cPassiveMonster -> cCow
-cAggressiveMonster -> cCreeper
-cPassiveAggressiveMonster -> cEnderman
-cAggressiveMonster -> cGhast
-cAggressiveMonster -> cMagmaCube
-cPassiveMonster -> cMooshroom
-cPassiveMonster -> cOcelot
-cPassiveMonster -> cPig
-cPassiveMonster -> cSheep
-cAggressiveMonster -> cSilverfish
-cAggressiveMonster -> cSkeleton
-cAggressiveMonster -> cSlime
-cAggressiveMonster -> cSpider
-cPassiveMonster -> cSquid
-cPassiveMonster -> cVillager
-cAggressiveMonster -> cWitch
-cPassiveAggressiveMonster -> cWolf
-cAggressiveMonster -> cZombie
-cPassiveAggressiveMonster -> cZombiePigman
-cPawn -> cPlayer
+digraph
+{
+rankdir=LR
+
+# Entities:
+cEntity -> cFallingBlock
+cEntity -> cMinecart
+cEntity -> cPawn
+cEntity -> cPickup
+cEntity -> cTNT
+cMinecart -> cEmptyMinecart
+cMinecart -> cMinecartWithChest
+cMinecart -> cMinecartWithFurnace
+
+# Mobs:
+cPawn -> cMonster
+cMonster -> cAggressiveMonster
+cMonster -> cPassiveMonster
+cAggressiveMonster -> cPassiveAggressiveMonster
+cPassiveMonster -> cBat
+cAggressiveMonster -> cBlaze
+cAggressiveMonster -> cCaveSpider
+cPassiveMonster -> cChicken
+cPassiveMonster -> cCow
+cAggressiveMonster -> cCreeper
+cPassiveAggressiveMonster -> cEnderman
+cAggressiveMonster -> cGhast
+cAggressiveMonster -> cMagmaCube
+cPassiveMonster -> cMooshroom
+cPassiveMonster -> cOcelot
+cPassiveMonster -> cPig
+cPassiveMonster -> cSheep
+cAggressiveMonster -> cSilverfish
+cAggressiveMonster -> cSkeleton
+cAggressiveMonster -> cSlime
+cAggressiveMonster -> cSpider
+cPassiveMonster -> cSquid
+cPassiveMonster -> cVillager
+cAggressiveMonster -> cWitch
+cPassiveAggressiveMonster -> cWolf
+cAggressiveMonster -> cZombie
+cPassiveAggressiveMonster -> cZombiePigman
+cPawn -> cPlayer
} \ No newline at end of file
diff --git a/docs/Object ownership.gv b/docs/Object ownership.gv
index 007432154..29e0407a6 100644
--- a/docs/Object ownership.gv
+++ b/docs/Object ownership.gv
@@ -1,29 +1,29 @@
-digraph
-{
-rankdir=LR
-Root -> Server
-Root -> MonsterConfig
-Root -> GroupManager
-Root -> CraftingRecipes
-Root -> FurnaceRecipe
-Root -> PluginManager
-Root -> Authenticator
-Root -> World
-Server -> ListenThreadIPv4
-Server -> ListenThreadIPv6
-Server -> ClientHandle
-Server -> RCONServer
-PluginManager -> Plugin_NewLua
-PluginManager -> Plugin
-World -> SimulatorManager
-World -> SandSimulator
-World -> WaterSimulator
-World -> LavaSimulator
-World -> FireSimulator
-World -> RedstoneSimulator
-World -> WorldStorage
-World -> Player
-World -> Generator
-World -> ChunkSender
-World -> LightingThread
+digraph
+{
+rankdir=LR
+Root -> Server
+Root -> MonsterConfig
+Root -> GroupManager
+Root -> CraftingRecipes
+Root -> FurnaceRecipe
+Root -> PluginManager
+Root -> Authenticator
+Root -> World
+Server -> ListenThreadIPv4
+Server -> ListenThreadIPv6
+Server -> ClientHandle
+Server -> RCONServer
+PluginManager -> Plugin_NewLua
+PluginManager -> Plugin
+World -> SimulatorManager
+World -> SandSimulator
+World -> WaterSimulator
+World -> LavaSimulator
+World -> FireSimulator
+World -> RedstoneSimulator
+World -> WorldStorage
+World -> Player
+World -> Generator
+World -> ChunkSender
+World -> LightingThread
} \ No newline at end of file
diff --git a/docs/_files.txt b/docs/_files.txt
index 31e5de926..a8e204334 100644
--- a/docs/_files.txt
+++ b/docs/_files.txt
@@ -1,7 +1,7 @@
-
-Contents of this folder:
-
-API class inheritance - blockentities.gv - a GraphViz file to visualise inheritance in the API classes in the Wiki for the cBlockEntity class' descendants
-API class inheritance - entities.gv - a GraphViz file to visualise inheritance in the API classes in the Wiki for the cEntity class' descendants
-Object ownership.gv - a GraphViz file to visualise ownership relations in the MCServer code architecture
-Springs.ods - a spreadsheet with collected statistics about the occurrence of lava / water springs based on height.
+
+Contents of this folder:
+
+API class inheritance - blockentities.gv - a GraphViz file to visualise inheritance in the API classes in the Wiki for the cBlockEntity class' descendants
+API class inheritance - entities.gv - a GraphViz file to visualise inheritance in the API classes in the Wiki for the cEntity class' descendants
+Object ownership.gv - a GraphViz file to visualise ownership relations in the MCServer code architecture
+Springs.ods - a spreadsheet with collected statistics about the occurrence of lava / water springs based on height.
diff --git a/nbt examples/single chunk NBT data.txt b/nbt examples/single chunk NBT data.txt
index b0953c08a..905d6465c 100644
--- a/nbt examples/single chunk NBT data.txt
+++ b/nbt examples/single chunk NBT data.txt
@@ -1,71 +1,71 @@
-TAG_Compound(""): 1 items
-{
- TAG_Compound("Level"): 10 items
- {
- TAG_List("TileTicks"): 0 items of type 1
- {
- }
- TAG_List("Entities"): 0 items of type 1
- {
- }
- TAG_ByteArray("Biomes"): 256 bytes
- TAG_Long("LastUpdate"): 1041959
- TAG_Int("xPos"): 0
- TAG_Int("zPos"): 0
- TAG_List("TileEntities"): 0 items of type 1
- {
- }
- TAG_Byte("TerrainPopulated"): 1
- TAG_List("Sections"): 6 items of type 10
- {
- TAG_Compound(""): 5 items
- {
- TAG_ByteArray("Data"): 2048 bytes
- TAG_ByteArray("SkyLight"): 2048 bytes
- TAG_ByteArray("BlockLight"): 2048 bytes
- TAG_Byte("Y"): 0
- TAG_ByteArray("Blocks"): 4096 bytes
- }
- TAG_Compound(""): 5 items
- {
- TAG_ByteArray("Data"): 2048 bytes
- TAG_ByteArray("SkyLight"): 2048 bytes
- TAG_ByteArray("BlockLight"): 2048 bytes
- TAG_Byte("Y"): 1
- TAG_ByteArray("Blocks"): 4096 bytes
- }
- TAG_Compound(""): 5 items
- {
- TAG_ByteArray("Data"): 2048 bytes
- TAG_ByteArray("SkyLight"): 2048 bytes
- TAG_ByteArray("BlockLight"): 2048 bytes
- TAG_Byte("Y"): 2
- TAG_ByteArray("Blocks"): 4096 bytes
- }
- TAG_Compound(""): 5 items
- {
- TAG_ByteArray("Data"): 2048 bytes
- TAG_ByteArray("SkyLight"): 2048 bytes
- TAG_ByteArray("BlockLight"): 2048 bytes
- TAG_Byte("Y"): 3
- TAG_ByteArray("Blocks"): 4096 bytes
- }
- TAG_Compound(""): 5 items
- {
- TAG_ByteArray("Data"): 2048 bytes
- TAG_ByteArray("SkyLight"): 2048 bytes
- TAG_ByteArray("BlockLight"): 2048 bytes
- TAG_Byte("Y"): 4
- TAG_ByteArray("Blocks"): 4096 bytes
- }
- TAG_Compound(""): 5 items
- {
- TAG_ByteArray("Data"): 2048 bytes
- TAG_ByteArray("SkyLight"): 2048 bytes
- TAG_ByteArray("BlockLight"): 2048 bytes
- TAG_Byte("Y"): 5
- TAG_ByteArray("Blocks"): 4096 bytes
- }
- }
- }
-}
+TAG_Compound(""): 1 items
+{
+ TAG_Compound("Level"): 10 items
+ {
+ TAG_List("TileTicks"): 0 items of type 1
+ {
+ }
+ TAG_List("Entities"): 0 items of type 1
+ {
+ }
+ TAG_ByteArray("Biomes"): 256 bytes
+ TAG_Long("LastUpdate"): 1041959
+ TAG_Int("xPos"): 0
+ TAG_Int("zPos"): 0
+ TAG_List("TileEntities"): 0 items of type 1
+ {
+ }
+ TAG_Byte("TerrainPopulated"): 1
+ TAG_List("Sections"): 6 items of type 10
+ {
+ TAG_Compound(""): 5 items
+ {
+ TAG_ByteArray("Data"): 2048 bytes
+ TAG_ByteArray("SkyLight"): 2048 bytes
+ TAG_ByteArray("BlockLight"): 2048 bytes
+ TAG_Byte("Y"): 0
+ TAG_ByteArray("Blocks"): 4096 bytes
+ }
+ TAG_Compound(""): 5 items
+ {
+ TAG_ByteArray("Data"): 2048 bytes
+ TAG_ByteArray("SkyLight"): 2048 bytes
+ TAG_ByteArray("BlockLight"): 2048 bytes
+ TAG_Byte("Y"): 1
+ TAG_ByteArray("Blocks"): 4096 bytes
+ }
+ TAG_Compound(""): 5 items
+ {
+ TAG_ByteArray("Data"): 2048 bytes
+ TAG_ByteArray("SkyLight"): 2048 bytes
+ TAG_ByteArray("BlockLight"): 2048 bytes
+ TAG_Byte("Y"): 2
+ TAG_ByteArray("Blocks"): 4096 bytes
+ }
+ TAG_Compound(""): 5 items
+ {
+ TAG_ByteArray("Data"): 2048 bytes
+ TAG_ByteArray("SkyLight"): 2048 bytes
+ TAG_ByteArray("BlockLight"): 2048 bytes
+ TAG_Byte("Y"): 3
+ TAG_ByteArray("Blocks"): 4096 bytes
+ }
+ TAG_Compound(""): 5 items
+ {
+ TAG_ByteArray("Data"): 2048 bytes
+ TAG_ByteArray("SkyLight"): 2048 bytes
+ TAG_ByteArray("BlockLight"): 2048 bytes
+ TAG_Byte("Y"): 4
+ TAG_ByteArray("Blocks"): 4096 bytes
+ }
+ TAG_Compound(""): 5 items
+ {
+ TAG_ByteArray("Data"): 2048 bytes
+ TAG_ByteArray("SkyLight"): 2048 bytes
+ TAG_ByteArray("BlockLight"): 2048 bytes
+ TAG_Byte("Y"): 5
+ TAG_ByteArray("Blocks"): 4096 bytes
+ }
+ }
+ }
+}
diff --git a/nbt examples/tile entities.txt b/nbt examples/tile entities.txt
index 5d6bf7c20..e16ae45a7 100644
--- a/nbt examples/tile entities.txt
+++ b/nbt examples/tile entities.txt
@@ -1,109 +1,109 @@
-TAG_List("TileEntities"): 3 items of type 10
-{
- TAG_Compound(""): 6 items
- {
- TAG_String("id"): 10 bytes: "MobSpawner"
- TAG_Short("Delay"): 20
- TAG_Int("z"): 180
- TAG_String("EntityId"): 6 bytes: "Spider"
- TAG_Int("y"): 11
- TAG_Int("x"): -6
- }
- TAG_Compound(""): 5 items
- {
- TAG_List("Items"): 6 items of type 10
- {
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 325
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 1
- TAG_Byte("Slot"): 3
- }
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 296
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 4
- TAG_Byte("Slot"): 5
- }
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 325
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 1
- TAG_Byte("Slot"): 11
- }
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 351
- TAG_Short("Damage"): 3
- TAG_Byte("Count"): 1
- TAG_Byte("Slot"): 13
- }
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 296
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 1
- TAG_Byte("Slot"): 14
- }
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 287
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 2
- TAG_Byte("Slot"): 15
- }
- }
- TAG_String("id"): 5 bytes: "Chest"
- TAG_Int("z"): 182
- TAG_Int("y"): 11
- TAG_Int("x"): -7
- }
- TAG_Compound(""): 5 items
- {
- TAG_List("Items"): 5 items of type 10
- {
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 289
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 1
- TAG_Byte("Slot"): 5
- }
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 329
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 1
- TAG_Byte("Slot"): 12
- }
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 265
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 4
- TAG_Byte("Slot"): 17
- }
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 296
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 4
- TAG_Byte("Slot"): 21
- }
- TAG_Compound(""): 4 items
- {
- TAG_Short("id"): 289
- TAG_Short("Damage"): 0
- TAG_Byte("Count"): 2
- TAG_Byte("Slot"): 22
- }
- }
- TAG_String("id"): 5 bytes: "Chest"
- TAG_Int("z"): 181
- TAG_Int("y"): 11
- TAG_Int("x"): -8
- }
+TAG_List("TileEntities"): 3 items of type 10
+{
+ TAG_Compound(""): 6 items
+ {
+ TAG_String("id"): 10 bytes: "MobSpawner"
+ TAG_Short("Delay"): 20
+ TAG_Int("z"): 180
+ TAG_String("EntityId"): 6 bytes: "Spider"
+ TAG_Int("y"): 11
+ TAG_Int("x"): -6
+ }
+ TAG_Compound(""): 5 items
+ {
+ TAG_List("Items"): 6 items of type 10
+ {
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 325
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 1
+ TAG_Byte("Slot"): 3
+ }
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 296
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 4
+ TAG_Byte("Slot"): 5
+ }
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 325
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 1
+ TAG_Byte("Slot"): 11
+ }
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 351
+ TAG_Short("Damage"): 3
+ TAG_Byte("Count"): 1
+ TAG_Byte("Slot"): 13
+ }
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 296
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 1
+ TAG_Byte("Slot"): 14
+ }
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 287
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 2
+ TAG_Byte("Slot"): 15
+ }
+ }
+ TAG_String("id"): 5 bytes: "Chest"
+ TAG_Int("z"): 182
+ TAG_Int("y"): 11
+ TAG_Int("x"): -7
+ }
+ TAG_Compound(""): 5 items
+ {
+ TAG_List("Items"): 5 items of type 10
+ {
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 289
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 1
+ TAG_Byte("Slot"): 5
+ }
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 329
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 1
+ TAG_Byte("Slot"): 12
+ }
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 265
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 4
+ TAG_Byte("Slot"): 17
+ }
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 296
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 4
+ TAG_Byte("Slot"): 21
+ }
+ TAG_Compound(""): 4 items
+ {
+ TAG_Short("id"): 289
+ TAG_Short("Damage"): 0
+ TAG_Byte("Count"): 2
+ TAG_Byte("Slot"): 22
+ }
+ }
+ TAG_String("id"): 5 bytes: "Chest"
+ TAG_Int("z"): 181
+ TAG_Int("y"): 11
+ TAG_Int("x"): -8
+ }
} \ No newline at end of file
diff --git a/source/AllToLua.bat b/source/AllToLua.bat
index 584f57423..60520e6f3 100644
--- a/source/AllToLua.bat
+++ b/source/AllToLua.bat
@@ -1,3 +1,3 @@
-"tolua++.exe" -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
-
-if %ALLTOLUA_WAIT%N == N pause
+"tolua++.exe" -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+
+if %ALLTOLUA_WAIT%N == N pause
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index fd85abba9..40927fe96 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/26/13 21:48:46.
+** Generated automatically by tolua++-1.0.92 on 07/29/13 19:22:49.
*/
#ifndef __cplusplus
@@ -70,9 +70,9 @@ static int tolua_collect_cItem (lua_State* tolua_S)
return 0;
}
-static int tolua_collect_Vector3f (lua_State* tolua_S)
+static int tolua_collect_cFurnaceEntity (lua_State* tolua_S)
{
- Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
+ cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
@@ -140,9 +140,9 @@ static int tolua_collect_cPickup (lua_State* tolua_S)
return 0;
}
-static int tolua_collect_cItems (lua_State* tolua_S)
+static int tolua_collect_sWebAdminPage (lua_State* tolua_S)
{
- cItems* self = (cItems*) tolua_tousertype(tolua_S,1,0);
+ sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
@@ -161,16 +161,16 @@ static int tolua_collect_cTracer (lua_State* tolua_S)
return 0;
}
-static int tolua_collect_Vector3i (lua_State* tolua_S)
+static int tolua_collect_Vector3f (lua_State* tolua_S)
{
- Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
-static int tolua_collect_cFurnaceEntity (lua_State* tolua_S)
+static int tolua_collect_Vector3i (lua_State* tolua_S)
{
- cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
@@ -182,6 +182,13 @@ static int tolua_collect_cIniFile (lua_State* tolua_S)
return 0;
}
+static int tolua_collect_cItems (lua_State* tolua_S)
+{
+ cItems* self = (cItems*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
static int tolua_collect_Vector3d (lua_State* tolua_S)
{
Vector3d* self = (Vector3d*) tolua_tousertype(tolua_S,1,0);
@@ -205,32 +212,34 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cInventory");
tolua_usertype(tolua_S,"cRoot");
tolua_usertype(tolua_S,"cWindow");
+ tolua_usertype(tolua_S,"cCraftingGrid");
+ tolua_usertype(tolua_S,"cTracer");
tolua_usertype(tolua_S,"cPickup");
tolua_usertype(tolua_S,"cItems");
- tolua_usertype(tolua_S,"cCraftingGrid");
+ tolua_usertype(tolua_S,"cGroup");
tolua_usertype(tolua_S,"cClientHandle");
tolua_usertype(tolua_S,"cChunkDesc");
tolua_usertype(tolua_S,"cFurnaceRecipe");
- tolua_usertype(tolua_S,"cGroup");
- tolua_usertype(tolua_S,"cChatColor");
- tolua_usertype(tolua_S,"cTracer");
tolua_usertype(tolua_S,"cCuboid");
- tolua_usertype(tolua_S,"Lua__cWebPlugin");
+ tolua_usertype(tolua_S,"cChatColor");
tolua_usertype(tolua_S,"Vector3i");
tolua_usertype(tolua_S,"cEntity");
+ tolua_usertype(tolua_S,"Lua__cWebPlugin");
+ tolua_usertype(tolua_S,"cPlugin");
+ tolua_usertype(tolua_S,"cCraftingRecipes");
tolua_usertype(tolua_S,"cItem");
tolua_usertype(tolua_S,"Vector3f");
- tolua_usertype(tolua_S,"cWebAdmin");
+ tolua_usertype(tolua_S,"Lua__cPickup");
tolua_usertype(tolua_S,"cDropSpenserEntity");
tolua_usertype(tolua_S,"Lua__cPlayer");
- tolua_usertype(tolua_S,"cCraftingRecipes");
+ tolua_usertype(tolua_S,"cWebPlugin");
tolua_usertype(tolua_S,"cChestEntity");
tolua_usertype(tolua_S,"cDispenserEntity");
- tolua_usertype(tolua_S,"cPlugin");
+ tolua_usertype(tolua_S,"cWebAdmin");
tolua_usertype(tolua_S,"cBlockEntity");
tolua_usertype(tolua_S,"cCriticalSection");
- tolua_usertype(tolua_S,"Lua__cPickup");
- tolua_usertype(tolua_S,"cWebPlugin");
+ tolua_usertype(tolua_S,"HTTPTemplateRequest");
+ tolua_usertype(tolua_S,"sWebAdminPage");
tolua_usertype(tolua_S,"HTTPRequest");
tolua_usertype(tolua_S,"HTTPFormData");
tolua_usertype(tolua_S,"cFurnaceEntity");
@@ -8439,194 +8448,162 @@ static int tolua_AllToLua_cPlayer_GetGameMode00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetIP of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetIP00
-static int tolua_AllToLua_cPlayer_GetIP00(lua_State* tolua_S)
+/* method: SetGameMode of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetGameMode00
+static int tolua_AllToLua_cPlayer_SetGameMode00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ eGameMode a_GameMode = ((eGameMode) (int) tolua_tonumber(tolua_S,2,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetIP'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetGameMode'", NULL);
#endif
{
- std::string tolua_ret = (std::string) self->GetIP();
- tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ self->SetGameMode(a_GameMode);
}
}
- return 1;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetIP'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetGameMode'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetLastBlockActionTime of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetLastBlockActionTime00
-static int tolua_AllToLua_cPlayer_GetLastBlockActionTime00(lua_State* tolua_S)
+/* method: IsGameModeCreative of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsGameModeCreative00
+static int tolua_AllToLua_cPlayer_IsGameModeCreative00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLastBlockActionTime'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeCreative'", NULL);
#endif
{
- float tolua_ret = (float) self->GetLastBlockActionTime();
- tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ bool tolua_ret = (bool) self->IsGameModeCreative();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetLastBlockActionTime'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeCreative'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetLastBlockActionCnt of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetLastBlockActionCnt00
-static int tolua_AllToLua_cPlayer_GetLastBlockActionCnt00(lua_State* tolua_S)
+/* method: IsGameModeSurvival of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsGameModeSurvival00
+static int tolua_AllToLua_cPlayer_IsGameModeSurvival00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLastBlockActionCnt'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeSurvival'", NULL);
#endif
{
- int tolua_ret = (int) self->GetLastBlockActionCnt();
- tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ bool tolua_ret = (bool) self->IsGameModeSurvival();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetLastBlockActionCnt'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
-/* method: SetLastBlockActionCnt of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetLastBlockActionCnt00
-static int tolua_AllToLua_cPlayer_SetLastBlockActionCnt00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
- )
- goto tolua_lerror;
- else
-#endif
- {
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
- int tolua_var_1 = ((int) tolua_tonumber(tolua_S,2,0));
-#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLastBlockActionCnt'", NULL);
-#endif
- {
- self->SetLastBlockActionCnt(tolua_var_1);
- }
- }
- return 0;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetLastBlockActionCnt'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeSurvival'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetLastBlockActionTime of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetLastBlockActionTime00
-static int tolua_AllToLua_cPlayer_SetLastBlockActionTime00(lua_State* tolua_S)
+/* method: IsGameModeAdventure of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsGameModeAdventure00
+static int tolua_AllToLua_cPlayer_IsGameModeAdventure00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLastBlockActionTime'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeAdventure'", NULL);
#endif
{
- self->SetLastBlockActionTime();
+ bool tolua_ret = (bool) self->IsGameModeAdventure();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
- return 0;
+ return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetLastBlockActionTime'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeAdventure'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetGameMode of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetGameMode00
-static int tolua_AllToLua_cPlayer_SetGameMode00(lua_State* tolua_S)
+/* method: GetIP of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetIP00
+static int tolua_AllToLua_cPlayer_GetIP00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
- eGameMode a_GameMode = ((eGameMode) (int) tolua_tonumber(tolua_S,2,0));
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetGameMode'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetIP'", NULL);
#endif
{
- self->SetGameMode(a_GameMode);
+ AString tolua_ret = (AString) self->GetIP();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
}
}
- return 0;
+ return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetGameMode'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetIP'.",&tolua_err);
return 0;
#endif
}
@@ -9334,6 +9311,38 @@ static int tolua_AllToLua_cPlayer_GetFoodPoisonedTicksRemaining00(lua_State* tol
}
#endif //#ifndef TOLUA_DISABLE
+/* method: IsSatiated of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsSatiated00
+static int tolua_AllToLua_cPlayer_IsSatiated00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsSatiated'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsSatiated();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsSatiated'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: SetFoodLevel of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetFoodLevel00
static int tolua_AllToLua_cPlayer_SetFoodLevel00(lua_State* tolua_S)
@@ -9601,6 +9610,38 @@ static int tolua_AllToLua_cPlayer_FoodPoison00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: IsEating of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsEating00
+static int tolua_AllToLua_cPlayer_IsEating00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsEating'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsEating();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsEating'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: Respawn of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_Respawn00
static int tolua_AllToLua_cPlayer_Respawn00(lua_State* tolua_S)
@@ -11092,6 +11133,38 @@ static int tolua_AllToLua_cServer_SendMessage00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetServerID of class cServer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cServer_GetServerID00
+static int tolua_AllToLua_cServer_GetServerID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cServer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cServer* self = (const cServer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetServerID'", NULL);
+#endif
+ {
+ const AString tolua_ret = (const AString) self->GetServerID();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetServerID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetClassStatic of class cWorld */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetClassStatic00
static int tolua_AllToLua_cWorld_GetClassStatic00(lua_State* tolua_S)
@@ -11375,6 +11448,102 @@ static int tolua_AllToLua_cWorld_GetGameMode00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: IsGameModeCreative of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_IsGameModeCreative00
+static int tolua_AllToLua_cWorld_IsGameModeCreative00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cWorld* self = (const cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeCreative'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsGameModeCreative();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeCreative'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsGameModeSurvival of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_IsGameModeSurvival00
+static int tolua_AllToLua_cWorld_IsGameModeSurvival00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cWorld* self = (const cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeSurvival'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsGameModeSurvival();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeSurvival'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsGameModeAdventure of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_IsGameModeAdventure00
+static int tolua_AllToLua_cWorld_IsGameModeAdventure00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cWorld* self = (const cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeAdventure'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsGameModeAdventure();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeAdventure'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: IsPVPEnabled of class cWorld */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_IsPVPEnabled00
static int tolua_AllToLua_cWorld_IsPVPEnabled00(lua_State* tolua_S)
@@ -18410,7 +18579,7 @@ static int tolua_set_HTTPRequest_Method(lua_State* tolua_S)
if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
- self->Method = ((std::string) tolua_tocppstring(tolua_S,2,0))
+ self->Method = ((AString) tolua_tocppstring(tolua_S,2,0))
;
return 0;
}
@@ -18440,7 +18609,7 @@ static int tolua_set_HTTPRequest_Path(lua_State* tolua_S)
if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
- self->Path = ((std::string) tolua_tocppstring(tolua_S,2,0))
+ self->Path = ((AString) tolua_tocppstring(tolua_S,2,0))
;
return 0;
}
@@ -18470,12 +18639,303 @@ static int tolua_set_HTTPRequest_Username(lua_State* tolua_S)
if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
- self->Username = ((std::string) tolua_tocppstring(tolua_S,2,0))
+ self->Username = ((AString) tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Request of class HTTPTemplateRequest */
+#ifndef TOLUA_DISABLE_tolua_get_HTTPTemplateRequest_Request
+static int tolua_get_HTTPTemplateRequest_Request(lua_State* tolua_S)
+{
+ HTTPTemplateRequest* self = (HTTPTemplateRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Request'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->Request,"HTTPRequest");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Request of class HTTPTemplateRequest */
+#ifndef TOLUA_DISABLE_tolua_set_HTTPTemplateRequest_Request
+static int tolua_set_HTTPTemplateRequest_Request(lua_State* tolua_S)
+{
+ HTTPTemplateRequest* self = (HTTPTemplateRequest*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Request'",NULL);
+ if ((tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"HTTPRequest",0,&tolua_err)))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->Request = *((HTTPRequest*) tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: Content of class sWebAdminPage */
+#ifndef TOLUA_DISABLE_tolua_get_sWebAdminPage_Content
+static int tolua_get_sWebAdminPage_Content(lua_State* tolua_S)
+{
+ sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Content'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->Content);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: Content of class sWebAdminPage */
+#ifndef TOLUA_DISABLE_tolua_set_sWebAdminPage_Content
+static int tolua_set_sWebAdminPage_Content(lua_State* tolua_S)
+{
+ sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Content'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->Content = ((AString) tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: PluginName of class sWebAdminPage */
+#ifndef TOLUA_DISABLE_tolua_get_sWebAdminPage_PluginName
+static int tolua_get_sWebAdminPage_PluginName(lua_State* tolua_S)
+{
+ sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'PluginName'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->PluginName);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: PluginName of class sWebAdminPage */
+#ifndef TOLUA_DISABLE_tolua_set_sWebAdminPage_PluginName
+static int tolua_set_sWebAdminPage_PluginName(lua_State* tolua_S)
+{
+ sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'PluginName'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->PluginName = ((AString) tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: TabName of class sWebAdminPage */
+#ifndef TOLUA_DISABLE_tolua_get_sWebAdminPage_TabName
+static int tolua_get_sWebAdminPage_TabName(lua_State* tolua_S)
+{
+ sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'TabName'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->TabName);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: TabName of class sWebAdminPage */
+#ifndef TOLUA_DISABLE_tolua_set_sWebAdminPage_TabName
+static int tolua_set_sWebAdminPage_TabName(lua_State* tolua_S)
+{
+ sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'TabName'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->TabName = ((AString) tolua_tocppstring(tolua_S,2,0))
;
return 0;
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetPort of class cWebAdmin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebAdmin_GetPort00
+static int tolua_AllToLua_cWebAdmin_GetPort00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWebAdmin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWebAdmin* self = (cWebAdmin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPort'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetPort();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPort'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPage of class cWebAdmin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebAdmin_GetPage00
+static int tolua_AllToLua_cWebAdmin_GetPage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWebAdmin",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const HTTPRequest",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWebAdmin* self = (cWebAdmin*) tolua_tousertype(tolua_S,1,0);
+ const HTTPRequest* a_Request = ((const HTTPRequest*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPage'", NULL);
+#endif
+ {
+ sWebAdminPage tolua_ret = (sWebAdminPage) self->GetPage(*a_Request);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((sWebAdminPage)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"sWebAdminPage");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(sWebAdminPage));
+ tolua_pushusertype(tolua_S,tolua_obj,"sWebAdminPage");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetBaseURL of class cWebAdmin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebAdmin_GetBaseURL00
+static int tolua_AllToLua_cWebAdmin_GetBaseURL00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWebAdmin",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWebAdmin* self = (cWebAdmin*) tolua_tousertype(tolua_S,1,0);
+ const AString a_URL = ((const AString) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBaseURL'", NULL);
+#endif
+ {
+ AString tolua_ret = (AString) self->GetBaseURL(a_URL);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)a_URL);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetBaseURL'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetMemoryUsage of class cWebAdmin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebAdmin_GetMemoryUsage00
+static int tolua_AllToLua_cWebAdmin_GetMemoryUsage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cWebAdmin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+ AString tolua_ret = (AString) cWebAdmin::GetMemoryUsage();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetMemoryUsage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetWebTitle of class cWebPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_GetWebTitle00
+static int tolua_AllToLua_cWebPlugin_GetWebTitle00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cWebPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cWebPlugin* self = (const cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetWebTitle'", NULL);
+#endif
+ {
+ const AString tolua_ret = (const AString) self->GetWebTitle();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetWebTitle'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: HandleWebRequest of class cWebPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_HandleWebRequest00
static int tolua_AllToLua_cWebPlugin_HandleWebRequest00(lua_State* tolua_S)
@@ -18484,7 +18944,7 @@ static int tolua_AllToLua_cWebPlugin_HandleWebRequest00(lua_State* tolua_S)
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cWebPlugin",0,&tolua_err) ||
- !tolua_isusertype(tolua_S,2,"HTTPRequest",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const HTTPRequest",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
@@ -18492,7 +18952,7 @@ static int tolua_AllToLua_cWebPlugin_HandleWebRequest00(lua_State* tolua_S)
#endif
{
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
- HTTPRequest* a_Request = ((HTTPRequest*) tolua_tousertype(tolua_S,2,0));
+ const HTTPRequest* a_Request = ((const HTTPRequest*) tolua_tousertype(tolua_S,2,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HandleWebRequest'", NULL);
#endif
@@ -18543,9 +19003,25 @@ static int tolua_AllToLua_cWebPlugin_SafeString00(lua_State* tolua_S)
class Lua__cWebPlugin : public cWebPlugin, public ToluaBase {
public:
- AString HandleWebRequest( HTTPRequest* a_Request) {
+ const AString GetWebTitle( void )const {
+ if (push_method("GetWebTitle", tolua_AllToLua_cWebPlugin_GetWebTitle00)) {
+ ToluaBase::dbcall(lua_state, 1, 1);
+ const AString tolua_ret = ( const AString )tolua_tocppstring(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ if (lua_state)
+ LOG("pure-virtual method cWebPlugin::GetWebTitle not implemented.");
+ else {
+ LOG("pure-virtual method cWebPlugin::GetWebTitle called with no lua_state. Aborting");
+ ::abort();
+ };
+ return ( const AString )0;
+ };
+ };
+ AString HandleWebRequest( const HTTPRequest* a_Request) {
if (push_method("HandleWebRequest", tolua_AllToLua_cWebPlugin_HandleWebRequest00)) {
- tolua_pushusertype(lua_state, (void*)a_Request, "HTTPRequest");
+ tolua_pushusertype(lua_state, (void*)a_Request, "const HTTPRequest");
ToluaBase::dbcall(lua_state, 2, 1);
AString tolua_ret = ( AString )tolua_tocppstring(lua_state, -1, 0);
lua_pop(lua_state, 1);
@@ -28665,6 +29141,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"gmSurvival",gmSurvival);
tolua_constant(tolua_S,"gmCreative",gmCreative);
tolua_constant(tolua_S,"gmAdventure",gmAdventure);
+ tolua_constant(tolua_S,"gmMax",gmMax);
+ tolua_constant(tolua_S,"gmMin",gmMin);
tolua_constant(tolua_S,"eWeather_Sunny",eWeather_Sunny);
tolua_constant(tolua_S,"eWeather_Rain",eWeather_Rain);
tolua_constant(tolua_S,"eWeather_ThunderStorm",eWeather_ThunderStorm);
@@ -28892,6 +29370,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_beginmodule(tolua_S,"cPlayer");
tolua_constant(tolua_S,"MAX_HEALTH",cPlayer::MAX_HEALTH);
tolua_constant(tolua_S,"MAX_FOOD_LEVEL",cPlayer::MAX_FOOD_LEVEL);
+ tolua_constant(tolua_S,"EATING_TICKS",cPlayer::EATING_TICKS);
tolua_function(tolua_S,"Initialize",tolua_AllToLua_cPlayer_Initialize00);
tolua_function(tolua_S,"GetEyeHeight",tolua_AllToLua_cPlayer_GetEyeHeight00);
tolua_function(tolua_S,"GetEyePosition",tolua_AllToLua_cPlayer_GetEyePosition00);
@@ -28900,12 +29379,11 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetInventory",tolua_AllToLua_cPlayer_GetInventory00);
tolua_function(tolua_S,"GetEquippedItem",tolua_AllToLua_cPlayer_GetEquippedItem00);
tolua_function(tolua_S,"GetGameMode",tolua_AllToLua_cPlayer_GetGameMode00);
- tolua_function(tolua_S,"GetIP",tolua_AllToLua_cPlayer_GetIP00);
- tolua_function(tolua_S,"GetLastBlockActionTime",tolua_AllToLua_cPlayer_GetLastBlockActionTime00);
- tolua_function(tolua_S,"GetLastBlockActionCnt",tolua_AllToLua_cPlayer_GetLastBlockActionCnt00);
- tolua_function(tolua_S,"SetLastBlockActionCnt",tolua_AllToLua_cPlayer_SetLastBlockActionCnt00);
- tolua_function(tolua_S,"SetLastBlockActionTime",tolua_AllToLua_cPlayer_SetLastBlockActionTime00);
tolua_function(tolua_S,"SetGameMode",tolua_AllToLua_cPlayer_SetGameMode00);
+ tolua_function(tolua_S,"IsGameModeCreative",tolua_AllToLua_cPlayer_IsGameModeCreative00);
+ tolua_function(tolua_S,"IsGameModeSurvival",tolua_AllToLua_cPlayer_IsGameModeSurvival00);
+ tolua_function(tolua_S,"IsGameModeAdventure",tolua_AllToLua_cPlayer_IsGameModeAdventure00);
+ tolua_function(tolua_S,"GetIP",tolua_AllToLua_cPlayer_GetIP00);
tolua_function(tolua_S,"MoveTo",tolua_AllToLua_cPlayer_MoveTo00);
tolua_function(tolua_S,"GetWindow",tolua_AllToLua_cPlayer_GetWindow00);
tolua_function(tolua_S,"CloseWindow",tolua_AllToLua_cPlayer_CloseWindow00);
@@ -28927,6 +29405,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetFoodTickTimer",tolua_AllToLua_cPlayer_GetFoodTickTimer00);
tolua_function(tolua_S,"GetFoodExhaustionLevel",tolua_AllToLua_cPlayer_GetFoodExhaustionLevel00);
tolua_function(tolua_S,"GetFoodPoisonedTicksRemaining",tolua_AllToLua_cPlayer_GetFoodPoisonedTicksRemaining00);
+ tolua_function(tolua_S,"IsSatiated",tolua_AllToLua_cPlayer_IsSatiated00);
tolua_function(tolua_S,"SetFoodLevel",tolua_AllToLua_cPlayer_SetFoodLevel00);
tolua_function(tolua_S,"SetFoodSaturationLevel",tolua_AllToLua_cPlayer_SetFoodSaturationLevel00);
tolua_function(tolua_S,"SetFoodTickTimer",tolua_AllToLua_cPlayer_SetFoodTickTimer00);
@@ -28935,6 +29414,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"Feed",tolua_AllToLua_cPlayer_Feed00);
tolua_function(tolua_S,"AddFoodExhaustion",tolua_AllToLua_cPlayer_AddFoodExhaustion00);
tolua_function(tolua_S,"FoodPoison",tolua_AllToLua_cPlayer_FoodPoison00);
+ tolua_function(tolua_S,"IsEating",tolua_AllToLua_cPlayer_IsEating00);
tolua_function(tolua_S,"Respawn",tolua_AllToLua_cPlayer_Respawn00);
tolua_function(tolua_S,"SetVisible",tolua_AllToLua_cPlayer_SetVisible00);
tolua_function(tolua_S,"IsVisible",tolua_AllToLua_cPlayer_IsVisible00);
@@ -29025,6 +29505,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_beginmodule(tolua_S,"cServer");
tolua_function(tolua_S,"BroadcastChat",tolua_AllToLua_cServer_BroadcastChat00);
tolua_function(tolua_S,"SendMessage",tolua_AllToLua_cServer_SendMessage00);
+ tolua_function(tolua_S,"GetServerID",tolua_AllToLua_cServer_GetServerID00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cWorld","cWorld","",NULL);
tolua_beginmodule(tolua_S,"cWorld");
@@ -29037,6 +29518,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetTimeOfDay",tolua_AllToLua_cWorld_SetTimeOfDay00);
tolua_function(tolua_S,"SetWorldTime",tolua_AllToLua_cWorld_SetWorldTime00);
tolua_function(tolua_S,"GetGameMode",tolua_AllToLua_cWorld_GetGameMode00);
+ tolua_function(tolua_S,"IsGameModeCreative",tolua_AllToLua_cWorld_IsGameModeCreative00);
+ tolua_function(tolua_S,"IsGameModeSurvival",tolua_AllToLua_cWorld_IsGameModeSurvival00);
+ tolua_function(tolua_S,"IsGameModeAdventure",tolua_AllToLua_cWorld_IsGameModeAdventure00);
tolua_function(tolua_S,"IsPVPEnabled",tolua_AllToLua_cWorld_IsPVPEnabled00);
tolua_function(tolua_S,"IsDeepSnowEnabled",tolua_AllToLua_cWorld_IsDeepSnowEnabled00);
tolua_function(tolua_S,"GetDimension",tolua_AllToLua_cWorld_GetDimension00);
@@ -29372,8 +29856,30 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_variable(tolua_S,"Path",tolua_get_HTTPRequest_Path,tolua_set_HTTPRequest_Path);
tolua_variable(tolua_S,"Username",tolua_get_HTTPRequest_Username,tolua_set_HTTPRequest_Username);
tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"HTTPTemplateRequest","HTTPTemplateRequest","",NULL);
+ tolua_beginmodule(tolua_S,"HTTPTemplateRequest");
+ tolua_variable(tolua_S,"Request",tolua_get_HTTPTemplateRequest_Request,tolua_set_HTTPTemplateRequest_Request);
+ tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"sWebAdminPage","sWebAdminPage","",tolua_collect_sWebAdminPage);
+ #else
+ tolua_cclass(tolua_S,"sWebAdminPage","sWebAdminPage","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"sWebAdminPage");
+ tolua_variable(tolua_S,"Content",tolua_get_sWebAdminPage_Content,tolua_set_sWebAdminPage_Content);
+ tolua_variable(tolua_S,"PluginName",tolua_get_sWebAdminPage_PluginName,tolua_set_sWebAdminPage_PluginName);
+ tolua_variable(tolua_S,"TabName",tolua_get_sWebAdminPage_TabName,tolua_set_sWebAdminPage_TabName);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cWebAdmin","cWebAdmin","",NULL);
+ tolua_beginmodule(tolua_S,"cWebAdmin");
+ tolua_function(tolua_S,"GetPort",tolua_AllToLua_cWebAdmin_GetPort00);
+ tolua_function(tolua_S,"GetPage",tolua_AllToLua_cWebAdmin_GetPage00);
+ tolua_function(tolua_S,"GetBaseURL",tolua_AllToLua_cWebAdmin_GetBaseURL00);
+ tolua_function(tolua_S,"GetMemoryUsage",tolua_AllToLua_cWebAdmin_GetMemoryUsage00);
+ tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cWebPlugin","cWebPlugin","",NULL);
tolua_beginmodule(tolua_S,"cWebPlugin");
+ tolua_function(tolua_S,"GetWebTitle",tolua_AllToLua_cWebPlugin_GetWebTitle00);
tolua_function(tolua_S,"HandleWebRequest",tolua_AllToLua_cWebPlugin_HandleWebRequest00);
tolua_function(tolua_S,"SafeString",tolua_AllToLua_cWebPlugin_SafeString00);
tolua_endmodule(tolua_S);
diff --git a/source/Bindings.h b/source/Bindings.h
index c21612525..b2f26025c 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/26/13 21:48:46.
+** Generated automatically by tolua++-1.0.92 on 07/29/13 19:22:49.
*/
/* Exported function */
diff --git a/source/BlockArea.cpp b/source/BlockArea.cpp
index 6134843bb..5c15adfef 100644
--- a/source/BlockArea.cpp
+++ b/source/BlockArea.cpp
@@ -1,2124 +1,2124 @@
-
-// BlockArea.cpp
-
-// Implements the cBlockArea object representing an area of block data that can be queried from cWorld and then accessed again without further queries
-// The object also supports writing the blockdata back into cWorld, even into other coords
-
-#include "Globals.h"
-#include "BlockArea.h"
-#include "World.h"
-#include "OSSupport/GZipFile.h"
-#include "WorldStorage/FastNBT.h"
-#include "Blocks/BlockHandler.h"
-
-
-
-
-
-// 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(
- BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes,
- 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
-)
-{
- for (int y = 0; y < a_SizeY; y++)
- {
- int SrcBaseY = (y + a_SrcOffY) * a_SrcSizeX * a_SrcSizeZ;
- int DstBaseY = (y + a_DstOffY) * a_DstSizeX * a_DstSizeZ;
- for (int z = 0; z < a_SizeZ; z++)
- {
- int SrcBaseZ = SrcBaseY + (z + a_SrcOffZ) * a_SrcSizeX;
- int DstBaseZ = DstBaseY + (z + a_DstOffZ) * a_DstSizeX;
- int SrcIdx = SrcBaseZ + a_SrcOffX;
- 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]);
- ++DstIdx;
- ++SrcIdx;
- } // for x
- } // for z
- } // for y
-}
-
-
-
-
-
-/// Combinator used for cBlockArea::msOverwrite merging
-static void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
-{
- a_DstType = a_SrcType;
- a_DstMeta = a_SrcMeta;
-}
-
-
-
-
-
-/// Combinator used for cBlockArea::msFillAir merging
-static 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;
- }
- // "else" is the default, already in place
-}
-
-
-
-
-
-/// Combinator used for cBlockArea::msImprint merging
-static 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;
- }
- // "else" is the default, already in place
-}
-
-
-
-
-
-/// Combinator used for cBlockArea::msLake merging
-static 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)
- {
- return;
- }
-
- // Air is always hollowed out
- if (a_SrcType == E_BLOCK_AIR)
- {
- a_DstType = E_BLOCK_AIR;
- a_DstMeta = 0;
- return;
- }
-
- // Water and lava are never overwritten
- switch (a_DstType)
- {
- case E_BLOCK_WATER:
- case E_BLOCK_STATIONARY_WATER:
- case E_BLOCK_LAVA:
- case E_BLOCK_STATIONARY_LAVA:
- {
- return;
- }
- }
-
- // Water and lava always overwrite
- switch (a_SrcType)
- {
- case E_BLOCK_WATER:
- case E_BLOCK_STATIONARY_WATER:
- case E_BLOCK_LAVA:
- case E_BLOCK_STATIONARY_LAVA:
- {
- a_DstType = a_SrcType;
- a_DstMeta = a_DstMeta;
- return;
- }
- }
-
- if (a_SrcType == E_BLOCK_STONE)
- {
- switch (a_DstType)
- {
- case E_BLOCK_DIRT:
- case E_BLOCK_GRASS:
- case E_BLOCK_MYCELIUM:
- {
- a_DstType = E_BLOCK_STONE;
- a_DstMeta = 0;
- return;
- }
- }
- }
- // Everything else is left as it is
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cBlockArea:
-
-cBlockArea::cBlockArea(void) :
- m_SizeX(0),
- m_SizeY(0),
- m_SizeZ(0),
- m_BlockTypes(NULL),
- m_BlockMetas(NULL),
- m_BlockLight(NULL),
- m_BlockSkyLight(NULL)
-{
-}
-
-
-
-
-
-cBlockArea::~cBlockArea()
-{
- Clear();
-}
-
-
-
-
-
-void cBlockArea::Clear(void)
-{
- 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_SizeX = 0;
- m_SizeY = 0;
- m_SizeZ = 0;
-}
-
-
-
-
-
-void cBlockArea::Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
-{
- Clear();
- int BlockCount = a_SizeX * a_SizeY * a_SizeZ;
- if ((a_DataTypes & baTypes) != 0)
- {
- m_BlockTypes = new BLOCKTYPE[BlockCount];
- for (int i = 0; i < BlockCount; i++)
- {
- m_BlockTypes[i] = E_BLOCK_AIR;
- }
- }
- if ((a_DataTypes & baMetas) != 0)
- {
- m_BlockMetas = new NIBBLETYPE[BlockCount];
- for (int i = 0; i < BlockCount; i++)
- {
- m_BlockMetas[i] = 0;
- }
- }
- if ((a_DataTypes & baLight) != 0)
- {
- m_BlockLight = new NIBBLETYPE[BlockCount];
- for (int i = 0; i < BlockCount; i++)
- {
- m_BlockLight[i] = 0;
- }
- }
- if ((a_DataTypes & baSkyLight) != 0)
- {
- m_BlockSkyLight = new NIBBLETYPE[BlockCount];
- for (int i = 0; i < BlockCount; i++)
- {
- m_BlockSkyLight[i] = 0x0f;
- }
- }
- m_SizeX = a_SizeX;
- m_SizeY = a_SizeY;
- m_SizeZ = a_SizeZ;
- m_OriginX = 0;
- m_OriginY = 0;
- m_OriginZ = 0;
-}
-
-
-
-
-
-void cBlockArea::SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ)
-{
- m_OriginX = a_OriginX;
- m_OriginY = a_OriginY;
- m_OriginZ = a_OriginZ;
-}
-
-
-
-
-
-bool cBlockArea::Read(cWorld * a_World, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes)
-{
- // Normalize the coords:
- if (a_MinBlockX > a_MaxBlockX)
- {
- std::swap(a_MinBlockX, a_MaxBlockX);
- }
- if (a_MinBlockY > a_MaxBlockY)
- {
- std::swap(a_MinBlockY, a_MaxBlockY);
- }
- if (a_MinBlockZ > a_MaxBlockZ)
- {
- std::swap(a_MinBlockZ, a_MaxBlockZ);
- }
-
- // Include the Max coords:
- a_MaxBlockX += 1;
- a_MaxBlockY += 1;
- a_MaxBlockZ += 1;
-
- // Check coords validity:
- if (a_MinBlockY < 0)
- {
- LOGWARNING("%s: MinBlockY less than zero, adjusting to zero", __FUNCTION__);
- a_MinBlockY = 0;
- }
- else if (a_MinBlockY >= cChunkDef::Height)
- {
- LOGWARNING("%s: MinBlockY more than chunk height, adjusting to chunk height", __FUNCTION__);
- a_MinBlockY = cChunkDef::Height - 1;
- }
- if (a_MaxBlockY < 0)
- {
- LOGWARNING("%s: MaxBlockY less than zero, adjusting to zero", __FUNCTION__);
- a_MaxBlockY = 0;
- }
- else if (a_MaxBlockY >= cChunkDef::Height)
- {
- LOGWARNING("%s: MaxBlockY more than chunk height, adjusting to chunk height", __FUNCTION__);
- a_MaxBlockY = cChunkDef::Height - 1;
- }
-
- // Allocate the needed memory:
- Clear();
- if (!SetSize(a_MaxBlockX - a_MinBlockX, a_MaxBlockY - a_MinBlockY, a_MaxBlockZ - a_MinBlockZ, a_DataTypes))
- {
- return false;
- }
- m_OriginX = a_MinBlockX;
- m_OriginY = a_MinBlockY;
- m_OriginZ = a_MinBlockZ;
- cChunkReader Reader(*this);
-
- // Convert block coords to chunks coords:
- int MinChunkX, MaxChunkX;
- int MinChunkZ, MaxChunkZ;
- cChunkDef::AbsoluteToRelative(a_MinBlockX, a_MinBlockY, a_MinBlockZ, MinChunkX, MinChunkZ);
- cChunkDef::AbsoluteToRelative(a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ, MaxChunkX, MaxChunkZ);
-
- // Query block data:
- if (!a_World->ForEachChunkInRect(MinChunkX, MaxChunkX, MinChunkZ, MaxChunkZ, Reader))
- {
- Clear();
- return false;
- }
-
- return true;
-}
-
-
-
-
-
-bool cBlockArea::Write(cWorld * a_World, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
-{
- ASSERT((a_DataTypes & GetDataTypes()) == a_DataTypes); // Are you requesting only the data that I have?
- a_DataTypes = a_DataTypes & GetDataTypes(); // For release builds, silently cut off the datatypes that I don't have
-
- // Check coords validity:
- if (a_MinBlockY < 0)
- {
- LOGWARNING("%s: MinBlockY less than zero, adjusting to zero", __FUNCTION__);
- a_MinBlockY = 0;
- }
- else if (a_MinBlockY >= cChunkDef::Height - m_SizeY)
- {
- LOGWARNING("%s: MinBlockY + m_SizeY more than chunk height, adjusting to chunk height", __FUNCTION__);
- a_MinBlockY = cChunkDef::Height - m_SizeY - 1;
- }
-
- return a_World->WriteBlockArea(*this, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
-}
-
-
-
-
-
-void cBlockArea::CopyTo(cBlockArea & a_Into) const
-{
- if (&a_Into == this)
- {
- LOGWARNING("Trying to copy a cBlockArea into self, ignoring.");
- return;
- }
-
- a_Into.Clear();
- a_Into.SetSize(m_SizeX, m_SizeY, m_SizeZ, GetDataTypes());
- a_Into.m_OriginX = m_OriginX;
- a_Into.m_OriginY = m_OriginY;
- a_Into.m_OriginZ = m_OriginZ;
- int BlockCount = GetBlockCount();
- if (HasBlockTypes())
- {
- memcpy(a_Into.m_BlockTypes, m_BlockTypes, BlockCount * sizeof(BLOCKTYPE));
- }
- if (HasBlockMetas())
- {
- memcpy(a_Into.m_BlockMetas, m_BlockMetas, BlockCount * sizeof(NIBBLETYPE));
- }
- if (HasBlockLights())
- {
- memcpy(a_Into.m_BlockLight, m_BlockLight, BlockCount * sizeof(NIBBLETYPE));
- }
- if (HasBlockSkyLights())
- {
- memcpy(a_Into.m_BlockSkyLight, m_BlockSkyLight, BlockCount * sizeof(NIBBLETYPE));
- }
-}
-
-
-
-
-
-void cBlockArea::CopyFrom(const cBlockArea & a_From)
-{
- a_From.CopyTo(*this);
-}
-
-
-
-
-
-void cBlockArea::DumpToRawFile(const AString & a_FileName)
-{
- cFile f;
- if (!f.Open(a_FileName, cFile::fmWrite))
- {
- LOGWARNING("cBlockArea: Cannot open file \"%s\" for raw dump", a_FileName.c_str());
- return;
- }
- UInt32 SizeX = ntohl(m_SizeX);
- UInt32 SizeY = ntohl(m_SizeY);
- UInt32 SizeZ = ntohl(m_SizeZ);
- f.Write(&SizeX, 4);
- f.Write(&SizeY, 4);
- f.Write(&SizeZ, 4);
- unsigned char DataTypes = GetDataTypes();
- f.Write(&DataTypes, 1);
- int NumBlocks = GetBlockCount();
- if (HasBlockTypes())
- {
- f.Write(m_BlockTypes, NumBlocks * sizeof(BLOCKTYPE));
- }
- if (HasBlockMetas())
- {
- f.Write(m_BlockMetas, NumBlocks);
- }
- if (HasBlockLights())
- {
- f.Write(m_BlockLight, NumBlocks);
- }
- if (HasBlockSkyLights())
- {
- f.Write(m_BlockSkyLight, NumBlocks);
- }
-}
-
-
-
-
-
-bool cBlockArea::LoadFromSchematicFile(const AString & a_FileName)
-{
- // Un-GZip the contents:
- AString Contents;
- cGZipFile File;
- if (!File.Open(a_FileName, cGZipFile::fmRead))
- {
- LOG("Cannot open the schematic file \"%s\".", a_FileName.c_str());
- return false;
- }
- int NumBytesRead = File.ReadRestOfFile(Contents);
- if (NumBytesRead < 0)
- {
- LOG("Cannot read GZipped data in the schematic file \"%s\", error %d", a_FileName.c_str(), NumBytesRead);
- return false;
- }
- File.Close();
-
- // Parse the NBT:
- cParsedNBT NBT(Contents.data(), Contents.size());
- if (!NBT.IsValid())
- {
- LOG("Cannot parse the NBT in the schematic file \"%s\".", a_FileName.c_str());
- return false;
- }
-
- return LoadFromSchematicNBT(NBT);
-}
-
-
-
-
-
-bool cBlockArea::SaveToSchematicFile(const AString & a_FileName)
-{
- cFastNBTWriter Writer("Schematic");
- Writer.AddShort("Width", m_SizeX);
- Writer.AddShort("Height", m_SizeY);
- Writer.AddShort("Length", m_SizeZ);
- Writer.AddString("Materials", "Alpha");
- if (HasBlockTypes())
- {
- Writer.AddByteArray("Blocks", (const char *)m_BlockTypes, GetBlockCount());
- }
- else
- {
- AString Dummy(GetBlockCount(), 0);
- Writer.AddByteArray("Blocks", Dummy.data(), Dummy.size());
- }
- if (HasBlockMetas())
- {
- Writer.AddByteArray("Data", (const char *)m_BlockMetas, GetBlockCount());
- }
- else
- {
- AString Dummy(GetBlockCount(), 0);
- Writer.AddByteArray("Data", Dummy.data(), Dummy.size());
- }
- // TODO: Save entities and block entities
- Writer.BeginList("Entities", TAG_Compound);
- Writer.EndList();
- Writer.BeginList("TileEntities", TAG_Compound);
- Writer.EndList();
- Writer.Finish();
-
- // Save to file
- cGZipFile File;
- if (!File.Open(a_FileName, cGZipFile::fmWrite))
- {
- LOG("Cannot open file \"%s\" for writing.", a_FileName.c_str());
- return false;
- }
- if (!File.Write(Writer.GetResult()))
- {
- LOG("Cannot write data to file \"%s\".", a_FileName.c_str());
- return false;
- }
- return true;
-}
-
-
-
-
-
-void cBlockArea::Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ)
-{
- if (
- (a_AddMinX + a_SubMaxX >= m_SizeX) ||
- (a_AddMinY + a_SubMaxY >= m_SizeY) ||
- (a_AddMinZ + a_SubMaxZ >= m_SizeZ)
- )
- {
- LOGWARNING("cBlockArea:Crop called with more croping than the dimensions: %d x %d x %d with cropping %d, %d and %d",
- m_SizeX, m_SizeY, m_SizeZ,
- a_AddMinX + a_SubMaxX, a_AddMinY + a_SubMaxY, a_AddMinZ + a_SubMaxZ
- );
- return;
- }
-
- if (HasBlockTypes())
- {
- CropBlockTypes(a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ);
- }
- if (HasBlockMetas())
- {
- CropNibbles(m_BlockMetas, a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ);
- }
- if (HasBlockLights())
- {
- CropNibbles(m_BlockLight, a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ);
- }
- if (HasBlockSkyLights())
- {
- CropNibbles(m_BlockSkyLight, a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ);
- }
- m_OriginX += a_AddMinX;
- m_OriginY += a_AddMinY;
- m_OriginZ += a_AddMinZ;
- m_SizeX -= a_AddMinX + a_SubMaxX;
- m_SizeY -= a_AddMinY + a_SubMaxY;
- m_SizeZ -= a_AddMinZ + a_SubMaxZ;
-}
-
-
-
-
-
-void cBlockArea::Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
-{
- if (HasBlockTypes())
- {
- ExpandBlockTypes(a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
- }
- if (HasBlockMetas())
- {
- ExpandNibbles(m_BlockMetas, a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
- }
- if (HasBlockLights())
- {
- ExpandNibbles(m_BlockLight, a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
- }
- if (HasBlockSkyLights())
- {
- ExpandNibbles(m_BlockSkyLight, a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
- }
- m_OriginX -= a_SubMinX;
- m_OriginY -= a_SubMinY;
- m_OriginZ -= a_SubMinZ;
- m_SizeX += a_SubMinX + a_AddMaxX;
- m_SizeY += a_SubMinY + a_AddMaxY;
- m_SizeZ += a_SubMinZ + a_AddMaxZ;
-}
-
-
-
-
-
-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()];
- }
-
- 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_SizeX, m_SizeY, m_SizeZ,
- 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_SizeX, m_SizeY, m_SizeZ,
- 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_SizeX, m_SizeY, m_SizeZ,
- 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_SizeX, m_SizeY, m_SizeZ,
- MergeCombinatorLake
- );
- break;
- } // case msLake
-
- default:
- {
- LOGWARNING("Unknown block area merge strategy: %d", a_Strategy);
- ASSERT(!"Unknown block area merge strategy");
- break;
- }
- } // switch (a_Strategy)
-
- if (IsDummyMetas)
- {
- delete[] SrcMetas;
- delete[] DstMetas;
- }
-}
-
-
-
-
-
-void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight)
-{
- if ((a_DataTypes & GetDataTypes()) != a_DataTypes)
- {
- LOGWARNING("%s: requested datatypes that are not present in the BlockArea object, trimming those away (req 0x%x, stor 0x%x)",
- __FUNCTION__, a_DataTypes, GetDataTypes()
- );
- a_DataTypes = a_DataTypes & GetDataTypes();
- }
-
- int BlockCount = GetBlockCount();
- if ((a_DataTypes & baTypes) != 0)
- {
- for (int i = 0; i < BlockCount; i++)
- {
- m_BlockTypes[i] = a_BlockType;
- }
- }
- if ((a_DataTypes & baMetas) != 0)
- {
- for (int i = 0; i < BlockCount; i++)
- {
- m_BlockMetas[i] = a_BlockMeta;
- }
- }
- if ((a_DataTypes & baLight) != 0)
- {
- for (int i = 0; i < BlockCount; i++)
- {
- m_BlockLight[i] = a_BlockLight;
- }
- }
- if ((a_DataTypes & baSkyLight) != 0)
- {
- for (int i = 0; i < BlockCount; i++)
- {
- m_BlockSkyLight[i] = a_BlockSkyLight;
- }
- }
-}
-
-
-
-
-
-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
-)
-{
- if ((a_DataTypes & GetDataTypes()) != a_DataTypes)
- {
- LOGWARNING("%s: requested datatypes that are not present in the BlockArea object, trimming those away (req 0x%x, stor 0x%x)",
- __FUNCTION__, a_DataTypes, GetDataTypes()
- );
- a_DataTypes = a_DataTypes & GetDataTypes();
- }
-
- if ((a_DataTypes & baTypes) != 0)
- {
- for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++)
- {
- m_BlockTypes[MakeIndex(x, y, z)] = a_BlockType;
- } // for x, z, y
- }
- if ((a_DataTypes & baMetas) != 0)
- {
- for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++)
- {
- m_BlockMetas[MakeIndex(x, y, z)] = a_BlockMeta;
- } // for x, z, y
- }
- if ((a_DataTypes & baLight) != 0)
- {
- for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++)
- {
- m_BlockLight[MakeIndex(x, y, z)] = a_BlockLight;
- } // for x, z, y
- }
- if ((a_DataTypes & baSkyLight) != 0)
- {
- for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++)
- {
- m_BlockSkyLight[MakeIndex(x, y, z)] = a_BlockSkyLight;
- } // for x, z, y
- }
-}
-
-
-
-
-
-void cBlockArea::RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2,
- int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
- NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
-)
-{
- // Bresenham-3D algorithm for drawing lines:
- int dx = abs(a_RelX2 - a_RelX1);
- int dy = abs(a_RelY2 - a_RelY1);
- int dz = abs(a_RelZ2 - a_RelZ1);
- int sx = (a_RelX1 < a_RelX2) ? 1 : -1;
- int sy = (a_RelY1 < a_RelY2) ? 1 : -1;
- int sz = (a_RelZ1 < a_RelZ2) ? 1 : -1;
- int err = dx - dz;
-
- if (dx >= std::max(dy, dz)) // x dominant
- {
- int yd = dy - dx / 2;
- int zd = dz - dx / 2;
-
- while (true)
- {
- RelSetData(a_RelX1, a_RelY1, a_RelZ1, a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight);
-
- if (a_RelX1 == a_RelX2)
- {
- break;
- }
-
- if (yd >= 0) // move along y
- {
- a_RelY1 += sy;
- yd -= dx;
- }
-
- if (zd >= 0) // move along z
- {
- a_RelZ1 += sz;
- zd -= dx;
- }
-
- // move along x
- a_RelX1 += sx;
- yd += dy;
- zd += dz;
- }
- }
- else if (dy >= std::max(dx, dz)) // y dominant
- {
- int xd = dx - dy / 2;
- int zd = dz - dy / 2;
-
- while (true)
- {
- RelSetData(a_RelX1, a_RelY1, a_RelZ1, a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight);
-
- if (a_RelY1 == a_RelY2)
- {
- break;
- }
-
- if (xd >= 0) // move along x
- {
- a_RelX1 += sx;
- xd -= dy;
- }
-
- if (zd >= 0) // move along z
- {
- a_RelZ1 += sz;
- zd -= dy;
- }
-
- // move along y
- a_RelY1 += sy;
- xd += dx;
- zd += dz;
- }
- }
- else
- {
- // z dominant
- ASSERT(dz >= std::max(dx, dy));
- int xd = dx - dz / 2;
- int yd = dy - dz / 2;
-
- while (true)
- {
- RelSetData(a_RelX1, a_RelY1, a_RelZ1, a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight);
-
- if (a_RelZ1 == a_RelZ2)
- {
- break;
- }
-
- if (xd >= 0) // move along x
- {
- a_RelX1 += sx;
- xd -= dz;
- }
-
- if (yd >= 0) // move along y
- {
- a_RelY1 += sy;
- yd -= dz;
- }
-
- // move along z
- a_RelZ1 += sz;
- xd += dx;
- yd += dy;
- }
- } // if (which dimension is dominant)
-}
-
-
-
-
-
-void cBlockArea::RotateCCW(void)
-{
- if (!HasBlockTypes())
- {
- LOGWARNING("cBlockArea: Cannot rotate blockmeta without blocktypes!");
- return;
- }
-
- if (!HasBlockMetas())
- {
- // There are no blockmetas to rotate, just use the NoMeta function
- RotateCCWNoMeta();
- return;
- }
-
- // We are guaranteed that both blocktypes and blockmetas exist; rotate both at the same time:
- BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
- NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
- for (int x = 0; x < m_SizeX; x++)
- {
- int NewZ = m_SizeX - x - 1;
- for (int z = 0; z < m_SizeZ; z++)
- {
- int NewX = z;
- for (int y = 0; y < m_SizeY; y++)
- {
- int NewIdx = NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ;
- int OldIdx = MakeIndex(x, y, z);
- NewTypes[NewIdx] = m_BlockTypes[OldIdx];
- NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCCW(m_BlockMetas[OldIdx]);
- } // for y
- } // for z
- } // for x
- std::swap(m_BlockTypes, NewTypes);
- std::swap(m_BlockMetas, NewMetas);
- delete[] NewTypes;
- delete[] NewMetas;
-
- std::swap(m_SizeX, m_SizeZ);
-}
-
-
-
-
-
-void cBlockArea::RotateCW(void)
-{
- if (!HasBlockTypes())
- {
- LOGWARNING("cBlockArea: Cannot rotate blockmeta without blocktypes!");
- return;
- }
-
- if (!HasBlockMetas())
- {
- // There are no blockmetas to rotate, just use the NoMeta function
- RotateCWNoMeta();
- return;
- }
-
- // We are guaranteed that both blocktypes and blockmetas exist; rotate both at the same time:
- BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
- NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
- for (int x = 0; x < m_SizeX; x++)
- {
- int NewZ = x;
- for (int z = 0; z < m_SizeZ; z++)
- {
- int NewX = m_SizeZ - z - 1;
- for (int y = 0; y < m_SizeY; y++)
- {
- int NewIdx = NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ;
- int OldIdx = MakeIndex(x, y, z);
- NewTypes[NewIdx] = m_BlockTypes[OldIdx];
- NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCW(m_BlockMetas[OldIdx]);
- } // for y
- } // for z
- } // for x
- std::swap(m_BlockTypes, NewTypes);
- std::swap(m_BlockMetas, NewMetas);
- delete[] NewTypes;
- delete[] NewMetas;
-
- std::swap(m_SizeX, m_SizeZ);
-}
-
-
-
-
-
-void cBlockArea::MirrorXY(void)
-{
- if (!HasBlockTypes())
- {
- LOGWARNING("cBlockArea: Cannot mirror meta without blocktypes!");
- return;
- }
-
- if (!HasBlockMetas())
- {
- // There are no blockmetas to mirror, just use the NoMeta function
- MirrorXYNoMeta();
- return;
- }
-
- // We are guaranteed that both blocktypes and blockmetas exist; mirror both at the same time:
- int HalfZ = m_SizeZ / 2;
- int MaxZ = m_SizeZ - 1;
- for (int y = 0; y < m_SizeY; y++)
- {
- for (int z = 0; z < HalfZ; z++)
- {
- for (int x = 0; x < m_SizeX; x++)
- {
- int Idx1 = MakeIndex(x, y, z);
- int Idx2 = MakeIndex(x, y, MaxZ - z);
- std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
- NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorXY(m_BlockMetas[Idx1]);
- NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorXY(m_BlockMetas[Idx2]);
- m_BlockMetas[Idx1] = Meta2;
- m_BlockMetas[Idx2] = Meta1;
- } // for x
- } // for z
- } // for y
-}
-
-
-
-
-
-void cBlockArea::MirrorXZ(void)
-{
- if (!HasBlockTypes())
- {
- LOGWARNING("cBlockArea: Cannot mirror meta without blocktypes!");
- return;
- }
-
- if (!HasBlockMetas())
- {
- // There are no blockmetas to mirror, just use the NoMeta function
- MirrorXZNoMeta();
- return;
- }
-
- // We are guaranteed that both blocktypes and blockmetas exist; mirror both at the same time:
- int HalfY = m_SizeY / 2;
- int MaxY = m_SizeY - 1;
- for (int y = 0; y < HalfY; y++)
- {
- for (int z = 0; z < m_SizeZ; z++)
- {
- for (int x = 0; x < m_SizeX; x++)
- {
- int Idx1 = MakeIndex(x, y, z);
- int Idx2 = MakeIndex(x, MaxY - y, z);
- std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
- NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorXZ(m_BlockMetas[Idx1]);
- NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorXZ(m_BlockMetas[Idx2]);
- m_BlockMetas[Idx1] = Meta2;
- m_BlockMetas[Idx2] = Meta1;
- } // for x
- } // for z
- } // for y
-}
-
-
-
-
-
-void cBlockArea::MirrorYZ(void)
-{
- if (!HasBlockTypes())
- {
- LOGWARNING("cBlockArea: Cannot mirror meta without blocktypes!");
- return;
- }
-
- if (!HasBlockMetas())
- {
- // There are no blockmetas to mirror, just use the NoMeta function
- MirrorYZNoMeta();
- return;
- }
-
- // We are guaranteed that both blocktypes and blockmetas exist; mirror both at the same time:
- int HalfX = m_SizeX / 2;
- int MaxX = m_SizeX - 1;
- for (int y = 0; y < m_SizeY; y++)
- {
- for (int z = 0; z < m_SizeZ; z++)
- {
- for (int x = 0; x < HalfX; x++)
- {
- int Idx1 = MakeIndex(x, y, z);
- int Idx2 = MakeIndex(MaxX - x, y, z);
- std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
- NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorYZ(m_BlockMetas[Idx1]);
- NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorYZ(m_BlockMetas[Idx2]);
- m_BlockMetas[Idx1] = Meta2;
- m_BlockMetas[Idx2] = Meta1;
- } // for x
- } // for z
- } // for y
-}
-
-
-
-
-
-void cBlockArea::RotateCCWNoMeta(void)
-{
- if (HasBlockTypes())
- {
- BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
- for (int x = 0; x < m_SizeX; x++)
- {
- int NewZ = m_SizeX - x - 1;
- for (int z = 0; z < m_SizeZ; z++)
- {
- int NewX = z;
- for (int y = 0; y < m_SizeY; y++)
- {
- NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
- } // for y
- } // for z
- } // for x
- std::swap(m_BlockTypes, NewTypes);
- delete[] NewTypes;
- }
- if (HasBlockMetas())
- {
- NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
- for (int x = 0; x < m_SizeX; x++)
- {
- int NewZ = m_SizeX - x - 1;
- for (int z = 0; z < m_SizeZ; z++)
- {
- int NewX = z;
- for (int y = 0; y < m_SizeY; y++)
- {
- NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
- } // for y
- } // for z
- } // for x
- std::swap(m_BlockMetas, NewMetas);
- delete[] NewMetas;
- }
- std::swap(m_SizeX, m_SizeZ);
-}
-
-
-
-
-
-void cBlockArea::RotateCWNoMeta(void)
-{
- if (HasBlockTypes())
- {
- BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
- for (int z = 0; z < m_SizeZ; z++)
- {
- int NewX = m_SizeZ - z - 1;
- for (int x = 0; x < m_SizeX; x++)
- {
- int NewZ = x;
- for (int y = 0; y < m_SizeY; y++)
- {
- NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
- } // for y
- } // for x
- } // for z
- std::swap(m_BlockTypes, NewTypes);
- delete[] NewTypes;
- }
- if (HasBlockMetas())
- {
- NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
- for (int z = 0; z < m_SizeZ; z++)
- {
- int NewX = m_SizeZ - z - 1;
- for (int x = 0; x < m_SizeX; x++)
- {
- int NewZ = x;
- for (int y = 0; y < m_SizeY; y++)
- {
- NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
- } // for y
- } // for x
- } // for z
- std::swap(m_BlockMetas, NewMetas);
- delete[] NewMetas;
- }
- std::swap(m_SizeX, m_SizeZ);
-}
-
-
-
-
-
-void cBlockArea::MirrorXYNoMeta(void)
-{
- int HalfZ = m_SizeZ / 2;
- int MaxZ = m_SizeZ - 1;
- if (HasBlockTypes())
- {
- for (int y = 0; y < m_SizeY; y++)
- {
- for (int z = 0; z < HalfZ; z++)
- {
- for (int x = 0; x < m_SizeX; x++)
- {
- std::swap(m_BlockTypes[MakeIndex(x, y, z)], m_BlockTypes[MakeIndex(x, y, MaxZ - z)]);
- } // for x
- } // for z
- } // for y
- } // if (HasBlockTypes)
-
- if (HasBlockMetas())
- {
- for (int y = 0; y < m_SizeY; y++)
- {
- for (int z = 0; z < HalfZ; z++)
- {
- for (int x = 0; x < m_SizeX; x++)
- {
- std::swap(m_BlockMetas[MakeIndex(x, y, z)], m_BlockMetas[MakeIndex(x, y, MaxZ - z)]);
- } // for x
- } // for z
- } // for y
- } // if (HasBlockMetas)
-}
-
-
-
-
-
-void cBlockArea::MirrorXZNoMeta(void)
-{
- int HalfY = m_SizeY / 2;
- int MaxY = m_SizeY - 1;
- if (HasBlockTypes())
- {
- for (int y = 0; y < HalfY; y++)
- {
- for (int z = 0; z < m_SizeZ; z++)
- {
- for (int x = 0; x < m_SizeX; x++)
- {
- std::swap(m_BlockTypes[MakeIndex(x, y, z)], m_BlockTypes[MakeIndex(x, MaxY - y, z)]);
- } // for x
- } // for z
- } // for y
- } // if (HasBlockTypes)
-
- if (HasBlockMetas())
- {
- for (int y = 0; y < HalfY; y++)
- {
- for (int z = 0; z < m_SizeZ; z++)
- {
- for (int x = 0; x < m_SizeX; x++)
- {
- std::swap(m_BlockMetas[MakeIndex(x, y, z)], m_BlockMetas[MakeIndex(x, MaxY - y, z)]);
- } // for x
- } // for z
- } // for y
- } // if (HasBlockMetas)
-}
-
-
-
-
-
-void cBlockArea::MirrorYZNoMeta(void)
-{
- int HalfX = m_SizeX / 2;
- int MaxX = m_SizeX - 1;
- if (HasBlockTypes())
- {
- for (int y = 0; y < m_SizeY; y++)
- {
- for (int z = 0; z < m_SizeZ; z++)
- {
- for (int x = 0; x < HalfX; x++)
- {
- std::swap(m_BlockTypes[MakeIndex(x, y, z)], m_BlockTypes[MakeIndex(MaxX - x, y, z)]);
- } // for x
- } // for z
- } // for y
- } // if (HasBlockTypes)
-
- if (HasBlockMetas())
- {
- for (int y = 0; y < m_SizeY; y++)
- {
- for (int z = 0; z < m_SizeZ; z++)
- {
- for (int x = 0; x < HalfX; x++)
- {
- std::swap(m_BlockMetas[MakeIndex(x, y, z)], m_BlockMetas[MakeIndex(MaxX - x, y, z)]);
- } // for x
- } // for z
- } // for y
- } // if (HasBlockMetas)
-}
-
-
-
-
-
-void cBlockArea::SetRelBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
-{
- if (m_BlockTypes == NULL)
- {
- LOGWARNING("cBlockArea: BlockTypes have not been read!");
- return;
- }
- m_BlockTypes[MakeIndex(a_RelX, a_RelY, a_RelZ)] = a_BlockType;
-}
-
-
-
-
-
-void cBlockArea::SetBlockType(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType)
-{
- SetRelBlockType(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_BlockType);
-}
-
-
-
-
-
-void cBlockArea::SetRelBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta)
-{
- SetRelNibble(a_RelX, a_RelY, a_RelZ, a_BlockMeta, m_BlockMetas);
-}
-
-
-
-
-
-void cBlockArea::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockMeta)
-{
- SetNibble(a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta, m_BlockMetas);
-}
-
-
-
-
-
-void cBlockArea::SetRelBlockLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockLight)
-{
- SetRelNibble(a_RelX, a_RelY, a_RelZ, a_BlockLight, m_BlockLight);
-}
-
-
-
-
-
-void cBlockArea::SetBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockLight)
-{
- SetNibble(a_BlockX, a_BlockY, a_BlockZ, a_BlockLight, m_BlockLight);
-}
-
-
-
-
-
-void cBlockArea::SetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockSkyLight)
-{
- SetRelNibble(a_RelX, a_RelY, a_RelZ, a_BlockSkyLight, m_BlockSkyLight);
-}
-
-
-
-
-
-void cBlockArea::SetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockSkyLight)
-{
- SetNibble(a_BlockX, a_BlockY, a_BlockZ, a_BlockSkyLight, m_BlockSkyLight);
-}
-
-
-
-
-
-BLOCKTYPE cBlockArea::GetRelBlockType(int a_RelX, int a_RelY, int a_RelZ) const
-{
- if (m_BlockTypes == NULL)
- {
- LOGWARNING("cBlockArea: BlockTypes have not been read!");
- return E_BLOCK_AIR;
- }
- return m_BlockTypes[MakeIndex(a_RelX, a_RelY, a_RelZ)];
-}
-
-
-
-
-
-BLOCKTYPE cBlockArea::GetBlockType(int a_BlockX, int a_BlockY, int a_BlockZ) const
-{
- return GetRelBlockType(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ);
-}
-
-
-
-
-
-NIBBLETYPE cBlockArea::GetRelBlockMeta(int a_RelX, int a_RelY, int a_RelZ) const
-{
- return GetRelNibble(a_RelX, a_RelY, a_RelZ, m_BlockMetas);
-}
-
-
-
-
-
-NIBBLETYPE cBlockArea::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) const
-{
- return GetNibble(a_BlockX, a_BlockY, a_BlockZ, m_BlockMetas);
-}
-
-
-
-
-
-NIBBLETYPE cBlockArea::GetRelBlockLight(int a_RelX, int a_RelY, int a_RelZ) const
-{
- return GetRelNibble(a_RelX, a_RelY, a_RelZ, m_BlockLight);
-}
-
-
-
-
-
-NIBBLETYPE cBlockArea::GetBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ) const
-{
- return GetNibble(a_BlockX, a_BlockY, a_BlockZ, m_BlockLight);
-}
-
-
-
-
-
-NIBBLETYPE cBlockArea::GetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ) const
-{
- return GetRelNibble(a_RelX, a_RelY, a_RelZ, m_BlockSkyLight);
-}
-
-
-
-
-
-NIBBLETYPE cBlockArea::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ) const
-{
- return GetNibble(a_BlockX, a_BlockY, a_BlockZ, m_BlockSkyLight);
-}
-
-
-
-
-
-void cBlockArea::SetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- SetRelBlockTypeMeta(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_BlockType, a_BlockMeta);
-}
-
-
-
-
-
-void cBlockArea::SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- int idx = MakeIndex(a_RelX, a_RelY, a_RelZ);
- if (m_BlockTypes == NULL)
- {
- LOGWARNING("%s: BlockTypes not available but requested to be written to.", __FUNCTION__);
- }
- else
- {
- m_BlockTypes[idx] = a_BlockType;
- }
- if (m_BlockMetas == NULL)
- {
- LOGWARNING("%s: BlockMetas not available but requested to be written to.", __FUNCTION__);
- }
- else
- {
- m_BlockMetas[idx] = a_BlockMeta;
- }
-}
-
-
-
-
-
-void cBlockArea::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
-{
- return GetRelBlockTypeMeta(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_BlockType, a_BlockMeta);
-}
-
-
-
-
-
-void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
-{
- int idx = MakeIndex(a_RelX, a_RelY, a_RelZ);
- if (m_BlockTypes == NULL)
- {
- LOGWARNING("cBlockArea: BlockTypes have not been read!");
- a_BlockType = E_BLOCK_AIR;
- }
- else
- {
- a_BlockType = m_BlockTypes[idx];
- }
-
- if (m_BlockMetas == NULL)
- {
- LOGWARNING("cBlockArea: BlockMetas have not been read!");
- a_BlockMeta = 0;
- }
- else
- {
- a_BlockMeta = m_BlockMetas[idx];
- }
-}
-
-
-
-
-
-int cBlockArea::GetDataTypes(void) const
-{
- int res = 0;
- if (m_BlockTypes != NULL)
- {
- res |= baTypes;
- }
- if (m_BlockMetas != NULL)
- {
- res |= baMetas;
- }
- if (m_BlockLight != NULL)
- {
- res |= baLight;
- }
- if (m_BlockSkyLight != NULL)
- {
- res |= baSkyLight;
- }
- return res;
-}
-
-
-
-
-
-bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
-{
- ASSERT(m_BlockTypes == NULL); // Has been cleared
-
- if (a_DataTypes & baTypes)
- {
- m_BlockTypes = new BLOCKTYPE[a_SizeX * a_SizeY * a_SizeZ];
- if (m_BlockTypes == NULL)
- {
- return false;
- }
- }
- if (a_DataTypes & baMetas)
- {
- m_BlockMetas = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
- if (m_BlockMetas == NULL)
- {
- delete[] m_BlockTypes;
- return false;
- }
- }
- if (a_DataTypes & baLight)
- {
- m_BlockLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
- if (m_BlockLight == NULL)
- {
- delete[] m_BlockMetas;
- delete[] m_BlockTypes;
- return false;
- }
- }
- if (a_DataTypes & baSkyLight)
- {
- m_BlockSkyLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
- if (m_BlockSkyLight == NULL)
- {
- delete[] m_BlockLight;
- delete[] m_BlockMetas;
- delete[] m_BlockTypes;
- return false;
- }
- }
- m_SizeX = a_SizeX;
- m_SizeY = a_SizeY;
- m_SizeZ = a_SizeZ;
- return true;
-}
-
-
-
-
-
-int cBlockArea::MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const
-{
- ASSERT(a_RelX >= 0);
- ASSERT(a_RelX < m_SizeX);
- ASSERT(a_RelY >= 0);
- ASSERT(a_RelY < m_SizeY);
- ASSERT(a_RelZ >= 0);
- ASSERT(a_RelZ < m_SizeZ);
-
- return a_RelX + a_RelZ * m_SizeX + a_RelY * m_SizeX * m_SizeZ;
-}
-
-
-
-
-
-void cBlockArea::SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array)
-{
- if (a_Array == NULL)
- {
- LOGWARNING("cBlockArea: datatype has not been read!");
- return;
- }
- a_Array[MakeIndex(a_RelX, a_RelY, a_RelZ)] = a_Value;
-}
-
-
-
-
-
-void cBlockArea::SetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array)
-{
- SetRelNibble(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_Value, a_Array);
-}
-
-
-
-
-
-NIBBLETYPE cBlockArea::GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const
-{
- if (a_Array == NULL)
- {
- LOGWARNING("cBlockArea: datatype has not been read!");
- return 16;
- }
- return a_Array[MakeIndex(a_RelX, a_RelY, a_RelZ)];
-}
-
-
-
-
-
-NIBBLETYPE cBlockArea::GetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE * a_Array) const
-{
- return GetRelNibble(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_Array);
-}
-
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cBlockArea::cChunkReader:
-
-cBlockArea::cChunkReader::cChunkReader(cBlockArea & a_Area) :
- m_Area(a_Area),
- m_OriginX(a_Area.m_OriginX),
- m_OriginY(a_Area.m_OriginY),
- m_OriginZ(a_Area.m_OriginZ)
-{
-}
-
-
-
-
-
-void cBlockArea::cChunkReader::CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc)
-{
- int SizeY = m_Area.m_SizeY;
- int MinY = m_OriginY;
-
- // SizeX, SizeZ are the dmensions 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;
- int SizeZ = cChunkDef::Width;
- int OffX, OffZ;
- int BaseX, BaseZ;
- OffX = m_CurrentChunkX * cChunkDef::Width - m_OriginX;
- if (OffX < 0)
- {
- BaseX = -OffX;
- SizeX += OffX; // SizeX is decreased, OffX is negative
- OffX = 0;
- }
- else
- {
- BaseX = 0;
- }
- OffZ = m_CurrentChunkZ * cChunkDef::Width - m_OriginZ;
- if (OffZ < 0)
- {
- BaseZ = -OffZ;
- SizeZ += OffZ; // SizeZ is decreased, OffZ is negative
- OffZ = 0;
- }
- else
- {
- BaseZ = 0;
- }
- // If the chunk extends beyond the area in the X or Z axis, cut off the Size:
- if ((m_CurrentChunkX + 1) * cChunkDef::Width > m_OriginX + m_Area.m_SizeX)
- {
- SizeX -= (m_CurrentChunkX + 1) * cChunkDef::Width - (m_OriginX + m_Area.m_SizeX);
- }
- if ((m_CurrentChunkZ + 1) * cChunkDef::Width > m_OriginZ + m_Area.m_SizeZ)
- {
- SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_OriginZ + m_Area.m_SizeZ);
- }
-
- for (int y = 0; y < SizeY; y++)
- {
- int ChunkY = MinY + y;
- int AreaY = y;
- for (int z = 0; z < SizeZ; z++)
- {
- int ChunkZ = BaseZ + z;
- int AreaZ = OffZ + z;
- for (int x = 0; x < SizeX; x++)
- {
- int ChunkX = BaseX + x;
- int AreaX = OffX + x;
- a_AreaDst[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = cChunkDef::GetNibble(a_ChunkSrc, ChunkX, ChunkY, ChunkZ);
- } // for x
- } // for z
- } // for y
-}
-
-
-
-
-
-bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ)
-{
- m_CurrentChunkX = a_ChunkX;
- m_CurrentChunkZ = a_ChunkZ;
- return true;
-}
-
-
-
-
-
-void cBlockArea::cChunkReader::BlockTypes(const BLOCKTYPE * a_BlockTypes)
-{
- if (m_Area.m_BlockTypes == NULL)
- {
- // Don't want BlockTypes
- return;
- }
-
- int SizeY = m_Area.m_SizeY;
- int MinY = m_OriginY;
-
- // SizeX, SizeZ are the dmensions 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;
- int SizeZ = cChunkDef::Width;
- int OffX, OffZ;
- int BaseX, BaseZ;
- OffX = m_CurrentChunkX * cChunkDef::Width - m_OriginX;
- if (OffX < 0)
- {
- BaseX = -OffX;
- SizeX += OffX; // SizeX is decreased, OffX is negative
- OffX = 0;
- }
- else
- {
- BaseX = 0;
- }
- OffZ = m_CurrentChunkZ * cChunkDef::Width - m_OriginZ;
- if (OffZ < 0)
- {
- BaseZ = -OffZ;
- SizeZ += OffZ; // SizeZ is decreased, OffZ is negative
- OffZ = 0;
- }
- else
- {
- BaseZ = 0;
- }
- // If the chunk extends beyond the area in the X or Z axis, cut off the Size:
- if ((m_CurrentChunkX + 1) * cChunkDef::Width > m_OriginX + m_Area.m_SizeX)
- {
- SizeX -= (m_CurrentChunkX + 1) * cChunkDef::Width - (m_OriginX + m_Area.m_SizeX);
- }
- if ((m_CurrentChunkZ + 1) * cChunkDef::Width > m_OriginZ + m_Area.m_SizeZ)
- {
- SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_OriginZ + m_Area.m_SizeZ);
- }
-
- for (int y = 0; y < SizeY; y++)
- {
- int ChunkY = MinY + y;
- int AreaY = y;
- for (int z = 0; z < SizeZ; z++)
- {
- int ChunkZ = BaseZ + z;
- int AreaZ = OffZ + z;
- for (int x = 0; x < SizeX; x++)
- {
- 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
-}
-
-
-
-
-
-void cBlockArea::cChunkReader::BlockMeta(const NIBBLETYPE * a_BlockMetas)
-{
- if (m_Area.m_BlockMetas == NULL)
- {
- // Don't want metas
- return;
- }
- CopyNibbles(m_Area.m_BlockMetas, a_BlockMetas);
-}
-
-
-
-
-
-void cBlockArea::cChunkReader::BlockLight(const NIBBLETYPE * a_BlockLight)
-{
- if (m_Area.m_BlockLight == NULL)
- {
- // Don't want light
- return;
- }
- CopyNibbles(m_Area.m_BlockLight, a_BlockLight);
-}
-
-
-
-
-
-void cBlockArea::cChunkReader::BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight)
-{
- if (m_Area.m_BlockSkyLight == NULL)
- {
- // Don't want skylight
- return;
- }
- 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;
- int NewSizeY = GetSizeY() - a_AddMinY - a_SubMaxY;
- int NewSizeZ = GetSizeZ() - a_AddMinZ - a_SubMaxZ;
- BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[NewSizeX * NewSizeY * NewSizeZ];
- int idx = 0;
- for (int y = 0; y < NewSizeY; y++)
- {
- for (int z = 0; z < NewSizeZ; z++)
- {
- for (int x = 0; x < NewSizeX; x++)
- {
- int OldIndex = MakeIndex(x + a_AddMinX, y + a_AddMinY, z + a_AddMinZ);
- NewBlockTypes[idx++] = m_BlockTypes[OldIndex];
- } // for x
- } // for z
- } // for y
- delete m_BlockTypes;
- m_BlockTypes = NewBlockTypes;
-}
-
-
-
-
-
-void cBlockArea::CropNibbles(NIBBLEARRAY & a_Array, 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;
- int NewSizeY = GetSizeY() - a_AddMinY - a_SubMaxY;
- int NewSizeZ = GetSizeZ() - a_AddMinZ - a_SubMaxZ;
- NIBBLETYPE * NewNibbles = new NIBBLETYPE[NewSizeX * NewSizeY * NewSizeZ];
- int idx = 0;
- for (int y = 0; y < NewSizeY; y++)
- {
- for (int z = 0; z < NewSizeZ; z++)
- {
- for (int x = 0; x < NewSizeX; x++)
- {
- NewNibbles[idx++] = a_Array[MakeIndex(x + a_AddMinX, y + a_AddMinY, z + a_AddMinZ)];
- } // for x
- } // for z
- } // for y
- delete a_Array;
- a_Array = NewNibbles;
-}
-
-
-
-
-
-void cBlockArea::ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
-{
- int NewSizeX = m_SizeX + a_SubMinX + a_AddMaxX;
- int NewSizeY = m_SizeY + a_SubMinY + a_AddMaxY;
- int NewSizeZ = m_SizeZ + a_SubMinZ + a_AddMaxZ;
- int BlockCount = NewSizeX * NewSizeY * NewSizeZ;
- BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[BlockCount];
- memset(NewBlockTypes, 0, BlockCount * sizeof(BLOCKTYPE));
- int OldIndex = 0;
- for (int y = 0; y < m_SizeY; y++)
- {
- int IndexBaseY = (y + a_SubMinY) * m_SizeX * m_SizeZ;
- for (int z = 0; z < m_SizeZ; z++)
- {
- int IndexBaseZ = IndexBaseY + (z + a_SubMinZ) * m_SizeX;
- int idx = IndexBaseZ + a_SubMinX;
- for (int x = 0; x < m_SizeX; x++)
- {
- NewBlockTypes[idx++] = m_BlockTypes[OldIndex++];
- } // for x
- } // for z
- } // for y
- delete m_BlockTypes;
- m_BlockTypes = NewBlockTypes;
-}
-
-
-
-
-
-void cBlockArea::ExpandNibbles(NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
-{
- int NewSizeX = m_SizeX + a_SubMinX + a_AddMaxX;
- int NewSizeY = m_SizeY + a_SubMinY + a_AddMaxY;
- int NewSizeZ = m_SizeZ + a_SubMinZ + a_AddMaxZ;
- int BlockCount = NewSizeX * NewSizeY * NewSizeZ;
- NIBBLETYPE * NewNibbles = new NIBBLETYPE[BlockCount];
- memset(NewNibbles, 0, BlockCount * sizeof(NIBBLETYPE));
- int OldIndex = 0;
- for (int y = 0; y < m_SizeY; y++)
- {
- int IndexBaseY = (y + a_SubMinY) * m_SizeX * m_SizeZ;
- for (int z = 0; z < m_SizeZ; z++)
- {
- int IndexBaseZ = IndexBaseY + (z + a_SubMinZ) * m_SizeX;
- int idx = IndexBaseZ + a_SubMinX;
- for (int x = 0; x < m_SizeX; x++)
- {
- NewNibbles[idx++] = a_Array[OldIndex++];
- } // for x
- } // for z
- } // for y
- delete a_Array;
- a_Array = NewNibbles;
-}
-
-
-
-
-
-bool cBlockArea::LoadFromSchematicNBT(cParsedNBT & a_NBT)
-{
- int TMaterials = a_NBT.FindChildByName(a_NBT.GetRoot(), "Materials");
- if ((TMaterials > 0) && (a_NBT.GetType(TMaterials) == TAG_String))
- {
- AString Materials = a_NBT.GetString(TMaterials);
- if (Materials.compare("Alpha") != 0)
- {
- LOG("Materials tag is present and \"%s\" instead of \"Alpha\". Possibly a wrong-format schematic file.", Materials.c_str());
- return false;
- }
- }
- int TSizeX = a_NBT.FindChildByName(a_NBT.GetRoot(), "Width");
- int TSizeY = a_NBT.FindChildByName(a_NBT.GetRoot(), "Height");
- int TSizeZ = a_NBT.FindChildByName(a_NBT.GetRoot(), "Length");
- if (
- (TSizeX < 0) || (TSizeY < 0) || (TSizeZ < 0) ||
- (a_NBT.GetType(TSizeX) != TAG_Short) ||
- (a_NBT.GetType(TSizeY) != TAG_Short) ||
- (a_NBT.GetType(TSizeZ) != TAG_Short)
- )
- {
- LOG("Dimensions are missing from the schematic file (%d, %d, %d), (%d, %d, %d)",
- TSizeX, TSizeY, TSizeZ,
- a_NBT.GetType(TSizeX), a_NBT.GetType(TSizeY), a_NBT.GetType(TSizeZ)
- );
- return false;
- }
-
- 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))
- {
- LOG("Dimensions are invalid in the schematic file: %d, %d, %d", SizeX, SizeY, SizeZ);
- return false;
- }
-
- int TBlockTypes = a_NBT.FindChildByName(a_NBT.GetRoot(), "Blocks");
- int TBlockMetas = a_NBT.FindChildByName(a_NBT.GetRoot(), "Data");
- if ((TBlockTypes < 0) || (a_NBT.GetType(TBlockTypes) != TAG_ByteArray))
- {
- LOG("BlockTypes are invalid in the schematic file: %d", TBlockTypes);
- return false;
- }
- bool AreMetasPresent = (TBlockMetas > 0) && (a_NBT.GetType(TBlockMetas) == TAG_ByteArray);
-
- Clear();
- SetSize(SizeX, SizeY, SizeZ, AreMetasPresent ? (baTypes | baMetas) : baTypes);
-
- // Copy the block types and metas:
- int NumBytes = m_SizeX * m_SizeY * m_SizeZ;
- 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)
- );
- NumBytes = a_NBT.GetDataLength(TBlockTypes);
- }
- memcpy(m_BlockTypes, a_NBT.GetData(TBlockTypes), NumBytes);
-
- if (AreMetasPresent)
- {
- int NumBytes = m_SizeX * m_SizeY * m_SizeZ;
- 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)
- );
- NumBytes = a_NBT.GetDataLength(TBlockMetas);
- }
- memcpy(m_BlockMetas, a_NBT.GetData(TBlockMetas), NumBytes);
- }
-
- return true;
-}
-
-
-
-
-void cBlockArea::RelSetData(
- int a_RelX, int a_RelY, int a_RelZ,
- int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
- NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
-)
-{
- int Index = MakeIndex(a_RelX, a_RelY, a_RelZ);
- if ((a_DataTypes & baTypes) != 0)
- {
- m_BlockTypes[Index] = a_BlockType;
- }
- if ((a_DataTypes & baMetas) != 0)
- {
- m_BlockMetas[Index] = a_BlockMeta;
- }
- if ((a_DataTypes & baLight) != 0)
- {
- m_BlockLight[Index] = a_BlockLight;
- }
- if ((a_DataTypes & baSkyLight) != 0)
- {
- m_BlockSkyLight[Index] = a_BlockSkyLight;
- }
-}
-
-
-
-
+
+// BlockArea.cpp
+
+// Implements the cBlockArea object representing an area of block data that can be queried from cWorld and then accessed again without further queries
+// The object also supports writing the blockdata back into cWorld, even into other coords
+
+#include "Globals.h"
+#include "BlockArea.h"
+#include "World.h"
+#include "OSSupport/GZipFile.h"
+#include "WorldStorage/FastNBT.h"
+#include "Blocks/BlockHandler.h"
+
+
+
+
+
+// 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(
+ BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes,
+ 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
+)
+{
+ for (int y = 0; y < a_SizeY; y++)
+ {
+ int SrcBaseY = (y + a_SrcOffY) * a_SrcSizeX * a_SrcSizeZ;
+ int DstBaseY = (y + a_DstOffY) * a_DstSizeX * a_DstSizeZ;
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ int SrcBaseZ = SrcBaseY + (z + a_SrcOffZ) * a_SrcSizeX;
+ int DstBaseZ = DstBaseY + (z + a_DstOffZ) * a_DstSizeX;
+ int SrcIdx = SrcBaseZ + a_SrcOffX;
+ 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]);
+ ++DstIdx;
+ ++SrcIdx;
+ } // for x
+ } // for z
+ } // for y
+}
+
+
+
+
+
+/// Combinator used for cBlockArea::msOverwrite merging
+static void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
+{
+ a_DstType = a_SrcType;
+ a_DstMeta = a_SrcMeta;
+}
+
+
+
+
+
+/// Combinator used for cBlockArea::msFillAir merging
+static 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;
+ }
+ // "else" is the default, already in place
+}
+
+
+
+
+
+/// Combinator used for cBlockArea::msImprint merging
+static 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;
+ }
+ // "else" is the default, already in place
+}
+
+
+
+
+
+/// Combinator used for cBlockArea::msLake merging
+static 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)
+ {
+ return;
+ }
+
+ // Air is always hollowed out
+ if (a_SrcType == E_BLOCK_AIR)
+ {
+ a_DstType = E_BLOCK_AIR;
+ a_DstMeta = 0;
+ return;
+ }
+
+ // Water and lava are never overwritten
+ switch (a_DstType)
+ {
+ case E_BLOCK_WATER:
+ case E_BLOCK_STATIONARY_WATER:
+ case E_BLOCK_LAVA:
+ case E_BLOCK_STATIONARY_LAVA:
+ {
+ return;
+ }
+ }
+
+ // Water and lava always overwrite
+ switch (a_SrcType)
+ {
+ case E_BLOCK_WATER:
+ case E_BLOCK_STATIONARY_WATER:
+ case E_BLOCK_LAVA:
+ case E_BLOCK_STATIONARY_LAVA:
+ {
+ a_DstType = a_SrcType;
+ a_DstMeta = a_DstMeta;
+ return;
+ }
+ }
+
+ if (a_SrcType == E_BLOCK_STONE)
+ {
+ switch (a_DstType)
+ {
+ case E_BLOCK_DIRT:
+ case E_BLOCK_GRASS:
+ case E_BLOCK_MYCELIUM:
+ {
+ a_DstType = E_BLOCK_STONE;
+ a_DstMeta = 0;
+ return;
+ }
+ }
+ }
+ // Everything else is left as it is
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cBlockArea:
+
+cBlockArea::cBlockArea(void) :
+ m_SizeX(0),
+ m_SizeY(0),
+ m_SizeZ(0),
+ m_BlockTypes(NULL),
+ m_BlockMetas(NULL),
+ m_BlockLight(NULL),
+ m_BlockSkyLight(NULL)
+{
+}
+
+
+
+
+
+cBlockArea::~cBlockArea()
+{
+ Clear();
+}
+
+
+
+
+
+void cBlockArea::Clear(void)
+{
+ 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_SizeX = 0;
+ m_SizeY = 0;
+ m_SizeZ = 0;
+}
+
+
+
+
+
+void cBlockArea::Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
+{
+ Clear();
+ int BlockCount = a_SizeX * a_SizeY * a_SizeZ;
+ if ((a_DataTypes & baTypes) != 0)
+ {
+ m_BlockTypes = new BLOCKTYPE[BlockCount];
+ for (int i = 0; i < BlockCount; i++)
+ {
+ m_BlockTypes[i] = E_BLOCK_AIR;
+ }
+ }
+ if ((a_DataTypes & baMetas) != 0)
+ {
+ m_BlockMetas = new NIBBLETYPE[BlockCount];
+ for (int i = 0; i < BlockCount; i++)
+ {
+ m_BlockMetas[i] = 0;
+ }
+ }
+ if ((a_DataTypes & baLight) != 0)
+ {
+ m_BlockLight = new NIBBLETYPE[BlockCount];
+ for (int i = 0; i < BlockCount; i++)
+ {
+ m_BlockLight[i] = 0;
+ }
+ }
+ if ((a_DataTypes & baSkyLight) != 0)
+ {
+ m_BlockSkyLight = new NIBBLETYPE[BlockCount];
+ for (int i = 0; i < BlockCount; i++)
+ {
+ m_BlockSkyLight[i] = 0x0f;
+ }
+ }
+ m_SizeX = a_SizeX;
+ m_SizeY = a_SizeY;
+ m_SizeZ = a_SizeZ;
+ m_OriginX = 0;
+ m_OriginY = 0;
+ m_OriginZ = 0;
+}
+
+
+
+
+
+void cBlockArea::SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ)
+{
+ m_OriginX = a_OriginX;
+ m_OriginY = a_OriginY;
+ m_OriginZ = a_OriginZ;
+}
+
+
+
+
+
+bool cBlockArea::Read(cWorld * a_World, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes)
+{
+ // Normalize the coords:
+ if (a_MinBlockX > a_MaxBlockX)
+ {
+ std::swap(a_MinBlockX, a_MaxBlockX);
+ }
+ if (a_MinBlockY > a_MaxBlockY)
+ {
+ std::swap(a_MinBlockY, a_MaxBlockY);
+ }
+ if (a_MinBlockZ > a_MaxBlockZ)
+ {
+ std::swap(a_MinBlockZ, a_MaxBlockZ);
+ }
+
+ // Include the Max coords:
+ a_MaxBlockX += 1;
+ a_MaxBlockY += 1;
+ a_MaxBlockZ += 1;
+
+ // Check coords validity:
+ if (a_MinBlockY < 0)
+ {
+ LOGWARNING("%s: MinBlockY less than zero, adjusting to zero", __FUNCTION__);
+ a_MinBlockY = 0;
+ }
+ else if (a_MinBlockY >= cChunkDef::Height)
+ {
+ LOGWARNING("%s: MinBlockY more than chunk height, adjusting to chunk height", __FUNCTION__);
+ a_MinBlockY = cChunkDef::Height - 1;
+ }
+ if (a_MaxBlockY < 0)
+ {
+ LOGWARNING("%s: MaxBlockY less than zero, adjusting to zero", __FUNCTION__);
+ a_MaxBlockY = 0;
+ }
+ else if (a_MaxBlockY >= cChunkDef::Height)
+ {
+ LOGWARNING("%s: MaxBlockY more than chunk height, adjusting to chunk height", __FUNCTION__);
+ a_MaxBlockY = cChunkDef::Height - 1;
+ }
+
+ // Allocate the needed memory:
+ Clear();
+ if (!SetSize(a_MaxBlockX - a_MinBlockX, a_MaxBlockY - a_MinBlockY, a_MaxBlockZ - a_MinBlockZ, a_DataTypes))
+ {
+ return false;
+ }
+ m_OriginX = a_MinBlockX;
+ m_OriginY = a_MinBlockY;
+ m_OriginZ = a_MinBlockZ;
+ cChunkReader Reader(*this);
+
+ // Convert block coords to chunks coords:
+ int MinChunkX, MaxChunkX;
+ int MinChunkZ, MaxChunkZ;
+ cChunkDef::AbsoluteToRelative(a_MinBlockX, a_MinBlockY, a_MinBlockZ, MinChunkX, MinChunkZ);
+ cChunkDef::AbsoluteToRelative(a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ, MaxChunkX, MaxChunkZ);
+
+ // Query block data:
+ if (!a_World->ForEachChunkInRect(MinChunkX, MaxChunkX, MinChunkZ, MaxChunkZ, Reader))
+ {
+ Clear();
+ return false;
+ }
+
+ return true;
+}
+
+
+
+
+
+bool cBlockArea::Write(cWorld * a_World, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
+{
+ ASSERT((a_DataTypes & GetDataTypes()) == a_DataTypes); // Are you requesting only the data that I have?
+ a_DataTypes = a_DataTypes & GetDataTypes(); // For release builds, silently cut off the datatypes that I don't have
+
+ // Check coords validity:
+ if (a_MinBlockY < 0)
+ {
+ LOGWARNING("%s: MinBlockY less than zero, adjusting to zero", __FUNCTION__);
+ a_MinBlockY = 0;
+ }
+ else if (a_MinBlockY >= cChunkDef::Height - m_SizeY)
+ {
+ LOGWARNING("%s: MinBlockY + m_SizeY more than chunk height, adjusting to chunk height", __FUNCTION__);
+ a_MinBlockY = cChunkDef::Height - m_SizeY - 1;
+ }
+
+ return a_World->WriteBlockArea(*this, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
+}
+
+
+
+
+
+void cBlockArea::CopyTo(cBlockArea & a_Into) const
+{
+ if (&a_Into == this)
+ {
+ LOGWARNING("Trying to copy a cBlockArea into self, ignoring.");
+ return;
+ }
+
+ a_Into.Clear();
+ a_Into.SetSize(m_SizeX, m_SizeY, m_SizeZ, GetDataTypes());
+ a_Into.m_OriginX = m_OriginX;
+ a_Into.m_OriginY = m_OriginY;
+ a_Into.m_OriginZ = m_OriginZ;
+ int BlockCount = GetBlockCount();
+ if (HasBlockTypes())
+ {
+ memcpy(a_Into.m_BlockTypes, m_BlockTypes, BlockCount * sizeof(BLOCKTYPE));
+ }
+ if (HasBlockMetas())
+ {
+ memcpy(a_Into.m_BlockMetas, m_BlockMetas, BlockCount * sizeof(NIBBLETYPE));
+ }
+ if (HasBlockLights())
+ {
+ memcpy(a_Into.m_BlockLight, m_BlockLight, BlockCount * sizeof(NIBBLETYPE));
+ }
+ if (HasBlockSkyLights())
+ {
+ memcpy(a_Into.m_BlockSkyLight, m_BlockSkyLight, BlockCount * sizeof(NIBBLETYPE));
+ }
+}
+
+
+
+
+
+void cBlockArea::CopyFrom(const cBlockArea & a_From)
+{
+ a_From.CopyTo(*this);
+}
+
+
+
+
+
+void cBlockArea::DumpToRawFile(const AString & a_FileName)
+{
+ cFile f;
+ if (!f.Open(a_FileName, cFile::fmWrite))
+ {
+ LOGWARNING("cBlockArea: Cannot open file \"%s\" for raw dump", a_FileName.c_str());
+ return;
+ }
+ UInt32 SizeX = ntohl(m_SizeX);
+ UInt32 SizeY = ntohl(m_SizeY);
+ UInt32 SizeZ = ntohl(m_SizeZ);
+ f.Write(&SizeX, 4);
+ f.Write(&SizeY, 4);
+ f.Write(&SizeZ, 4);
+ unsigned char DataTypes = GetDataTypes();
+ f.Write(&DataTypes, 1);
+ int NumBlocks = GetBlockCount();
+ if (HasBlockTypes())
+ {
+ f.Write(m_BlockTypes, NumBlocks * sizeof(BLOCKTYPE));
+ }
+ if (HasBlockMetas())
+ {
+ f.Write(m_BlockMetas, NumBlocks);
+ }
+ if (HasBlockLights())
+ {
+ f.Write(m_BlockLight, NumBlocks);
+ }
+ if (HasBlockSkyLights())
+ {
+ f.Write(m_BlockSkyLight, NumBlocks);
+ }
+}
+
+
+
+
+
+bool cBlockArea::LoadFromSchematicFile(const AString & a_FileName)
+{
+ // Un-GZip the contents:
+ AString Contents;
+ cGZipFile File;
+ if (!File.Open(a_FileName, cGZipFile::fmRead))
+ {
+ LOG("Cannot open the schematic file \"%s\".", a_FileName.c_str());
+ return false;
+ }
+ int NumBytesRead = File.ReadRestOfFile(Contents);
+ if (NumBytesRead < 0)
+ {
+ LOG("Cannot read GZipped data in the schematic file \"%s\", error %d", a_FileName.c_str(), NumBytesRead);
+ return false;
+ }
+ File.Close();
+
+ // Parse the NBT:
+ cParsedNBT NBT(Contents.data(), Contents.size());
+ if (!NBT.IsValid())
+ {
+ LOG("Cannot parse the NBT in the schematic file \"%s\".", a_FileName.c_str());
+ return false;
+ }
+
+ return LoadFromSchematicNBT(NBT);
+}
+
+
+
+
+
+bool cBlockArea::SaveToSchematicFile(const AString & a_FileName)
+{
+ cFastNBTWriter Writer("Schematic");
+ Writer.AddShort("Width", m_SizeX);
+ Writer.AddShort("Height", m_SizeY);
+ Writer.AddShort("Length", m_SizeZ);
+ Writer.AddString("Materials", "Alpha");
+ if (HasBlockTypes())
+ {
+ Writer.AddByteArray("Blocks", (const char *)m_BlockTypes, GetBlockCount());
+ }
+ else
+ {
+ AString Dummy(GetBlockCount(), 0);
+ Writer.AddByteArray("Blocks", Dummy.data(), Dummy.size());
+ }
+ if (HasBlockMetas())
+ {
+ Writer.AddByteArray("Data", (const char *)m_BlockMetas, GetBlockCount());
+ }
+ else
+ {
+ AString Dummy(GetBlockCount(), 0);
+ Writer.AddByteArray("Data", Dummy.data(), Dummy.size());
+ }
+ // TODO: Save entities and block entities
+ Writer.BeginList("Entities", TAG_Compound);
+ Writer.EndList();
+ Writer.BeginList("TileEntities", TAG_Compound);
+ Writer.EndList();
+ Writer.Finish();
+
+ // Save to file
+ cGZipFile File;
+ if (!File.Open(a_FileName, cGZipFile::fmWrite))
+ {
+ LOG("Cannot open file \"%s\" for writing.", a_FileName.c_str());
+ return false;
+ }
+ if (!File.Write(Writer.GetResult()))
+ {
+ LOG("Cannot write data to file \"%s\".", a_FileName.c_str());
+ return false;
+ }
+ return true;
+}
+
+
+
+
+
+void cBlockArea::Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ)
+{
+ if (
+ (a_AddMinX + a_SubMaxX >= m_SizeX) ||
+ (a_AddMinY + a_SubMaxY >= m_SizeY) ||
+ (a_AddMinZ + a_SubMaxZ >= m_SizeZ)
+ )
+ {
+ LOGWARNING("cBlockArea:Crop called with more croping than the dimensions: %d x %d x %d with cropping %d, %d and %d",
+ m_SizeX, m_SizeY, m_SizeZ,
+ a_AddMinX + a_SubMaxX, a_AddMinY + a_SubMaxY, a_AddMinZ + a_SubMaxZ
+ );
+ return;
+ }
+
+ if (HasBlockTypes())
+ {
+ CropBlockTypes(a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ);
+ }
+ if (HasBlockMetas())
+ {
+ CropNibbles(m_BlockMetas, a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ);
+ }
+ if (HasBlockLights())
+ {
+ CropNibbles(m_BlockLight, a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ);
+ }
+ if (HasBlockSkyLights())
+ {
+ CropNibbles(m_BlockSkyLight, a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ);
+ }
+ m_OriginX += a_AddMinX;
+ m_OriginY += a_AddMinY;
+ m_OriginZ += a_AddMinZ;
+ m_SizeX -= a_AddMinX + a_SubMaxX;
+ m_SizeY -= a_AddMinY + a_SubMaxY;
+ m_SizeZ -= a_AddMinZ + a_SubMaxZ;
+}
+
+
+
+
+
+void cBlockArea::Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
+{
+ if (HasBlockTypes())
+ {
+ ExpandBlockTypes(a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
+ }
+ if (HasBlockMetas())
+ {
+ ExpandNibbles(m_BlockMetas, a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
+ }
+ if (HasBlockLights())
+ {
+ ExpandNibbles(m_BlockLight, a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
+ }
+ if (HasBlockSkyLights())
+ {
+ ExpandNibbles(m_BlockSkyLight, a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
+ }
+ m_OriginX -= a_SubMinX;
+ m_OriginY -= a_SubMinY;
+ m_OriginZ -= a_SubMinZ;
+ m_SizeX += a_SubMinX + a_AddMaxX;
+ m_SizeY += a_SubMinY + a_AddMaxY;
+ m_SizeZ += a_SubMinZ + a_AddMaxZ;
+}
+
+
+
+
+
+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()];
+ }
+
+ 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_SizeX, m_SizeY, m_SizeZ,
+ 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_SizeX, m_SizeY, m_SizeZ,
+ 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_SizeX, m_SizeY, m_SizeZ,
+ 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_SizeX, m_SizeY, m_SizeZ,
+ MergeCombinatorLake
+ );
+ break;
+ } // case msLake
+
+ default:
+ {
+ LOGWARNING("Unknown block area merge strategy: %d", a_Strategy);
+ ASSERT(!"Unknown block area merge strategy");
+ break;
+ }
+ } // switch (a_Strategy)
+
+ if (IsDummyMetas)
+ {
+ delete[] SrcMetas;
+ delete[] DstMetas;
+ }
+}
+
+
+
+
+
+void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight)
+{
+ if ((a_DataTypes & GetDataTypes()) != a_DataTypes)
+ {
+ LOGWARNING("%s: requested datatypes that are not present in the BlockArea object, trimming those away (req 0x%x, stor 0x%x)",
+ __FUNCTION__, a_DataTypes, GetDataTypes()
+ );
+ a_DataTypes = a_DataTypes & GetDataTypes();
+ }
+
+ int BlockCount = GetBlockCount();
+ if ((a_DataTypes & baTypes) != 0)
+ {
+ for (int i = 0; i < BlockCount; i++)
+ {
+ m_BlockTypes[i] = a_BlockType;
+ }
+ }
+ if ((a_DataTypes & baMetas) != 0)
+ {
+ for (int i = 0; i < BlockCount; i++)
+ {
+ m_BlockMetas[i] = a_BlockMeta;
+ }
+ }
+ if ((a_DataTypes & baLight) != 0)
+ {
+ for (int i = 0; i < BlockCount; i++)
+ {
+ m_BlockLight[i] = a_BlockLight;
+ }
+ }
+ if ((a_DataTypes & baSkyLight) != 0)
+ {
+ for (int i = 0; i < BlockCount; i++)
+ {
+ m_BlockSkyLight[i] = a_BlockSkyLight;
+ }
+ }
+}
+
+
+
+
+
+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
+)
+{
+ if ((a_DataTypes & GetDataTypes()) != a_DataTypes)
+ {
+ LOGWARNING("%s: requested datatypes that are not present in the BlockArea object, trimming those away (req 0x%x, stor 0x%x)",
+ __FUNCTION__, a_DataTypes, GetDataTypes()
+ );
+ a_DataTypes = a_DataTypes & GetDataTypes();
+ }
+
+ if ((a_DataTypes & baTypes) != 0)
+ {
+ for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++)
+ {
+ m_BlockTypes[MakeIndex(x, y, z)] = a_BlockType;
+ } // for x, z, y
+ }
+ if ((a_DataTypes & baMetas) != 0)
+ {
+ for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++)
+ {
+ m_BlockMetas[MakeIndex(x, y, z)] = a_BlockMeta;
+ } // for x, z, y
+ }
+ if ((a_DataTypes & baLight) != 0)
+ {
+ for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++)
+ {
+ m_BlockLight[MakeIndex(x, y, z)] = a_BlockLight;
+ } // for x, z, y
+ }
+ if ((a_DataTypes & baSkyLight) != 0)
+ {
+ for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++)
+ {
+ m_BlockSkyLight[MakeIndex(x, y, z)] = a_BlockSkyLight;
+ } // for x, z, y
+ }
+}
+
+
+
+
+
+void cBlockArea::RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2,
+ int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
+)
+{
+ // Bresenham-3D algorithm for drawing lines:
+ int dx = abs(a_RelX2 - a_RelX1);
+ int dy = abs(a_RelY2 - a_RelY1);
+ int dz = abs(a_RelZ2 - a_RelZ1);
+ int sx = (a_RelX1 < a_RelX2) ? 1 : -1;
+ int sy = (a_RelY1 < a_RelY2) ? 1 : -1;
+ int sz = (a_RelZ1 < a_RelZ2) ? 1 : -1;
+ int err = dx - dz;
+
+ if (dx >= std::max(dy, dz)) // x dominant
+ {
+ int yd = dy - dx / 2;
+ int zd = dz - dx / 2;
+
+ while (true)
+ {
+ RelSetData(a_RelX1, a_RelY1, a_RelZ1, a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight);
+
+ if (a_RelX1 == a_RelX2)
+ {
+ break;
+ }
+
+ if (yd >= 0) // move along y
+ {
+ a_RelY1 += sy;
+ yd -= dx;
+ }
+
+ if (zd >= 0) // move along z
+ {
+ a_RelZ1 += sz;
+ zd -= dx;
+ }
+
+ // move along x
+ a_RelX1 += sx;
+ yd += dy;
+ zd += dz;
+ }
+ }
+ else if (dy >= std::max(dx, dz)) // y dominant
+ {
+ int xd = dx - dy / 2;
+ int zd = dz - dy / 2;
+
+ while (true)
+ {
+ RelSetData(a_RelX1, a_RelY1, a_RelZ1, a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight);
+
+ if (a_RelY1 == a_RelY2)
+ {
+ break;
+ }
+
+ if (xd >= 0) // move along x
+ {
+ a_RelX1 += sx;
+ xd -= dy;
+ }
+
+ if (zd >= 0) // move along z
+ {
+ a_RelZ1 += sz;
+ zd -= dy;
+ }
+
+ // move along y
+ a_RelY1 += sy;
+ xd += dx;
+ zd += dz;
+ }
+ }
+ else
+ {
+ // z dominant
+ ASSERT(dz >= std::max(dx, dy));
+ int xd = dx - dz / 2;
+ int yd = dy - dz / 2;
+
+ while (true)
+ {
+ RelSetData(a_RelX1, a_RelY1, a_RelZ1, a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight);
+
+ if (a_RelZ1 == a_RelZ2)
+ {
+ break;
+ }
+
+ if (xd >= 0) // move along x
+ {
+ a_RelX1 += sx;
+ xd -= dz;
+ }
+
+ if (yd >= 0) // move along y
+ {
+ a_RelY1 += sy;
+ yd -= dz;
+ }
+
+ // move along z
+ a_RelZ1 += sz;
+ xd += dx;
+ yd += dy;
+ }
+ } // if (which dimension is dominant)
+}
+
+
+
+
+
+void cBlockArea::RotateCCW(void)
+{
+ if (!HasBlockTypes())
+ {
+ LOGWARNING("cBlockArea: Cannot rotate blockmeta without blocktypes!");
+ return;
+ }
+
+ if (!HasBlockMetas())
+ {
+ // There are no blockmetas to rotate, just use the NoMeta function
+ RotateCCWNoMeta();
+ return;
+ }
+
+ // We are guaranteed that both blocktypes and blockmetas exist; rotate both at the same time:
+ BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
+ NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = m_SizeX - x - 1;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = z;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ int NewIdx = NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ;
+ int OldIdx = MakeIndex(x, y, z);
+ NewTypes[NewIdx] = m_BlockTypes[OldIdx];
+ NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCCW(m_BlockMetas[OldIdx]);
+ } // for y
+ } // for z
+ } // for x
+ std::swap(m_BlockTypes, NewTypes);
+ std::swap(m_BlockMetas, NewMetas);
+ delete[] NewTypes;
+ delete[] NewMetas;
+
+ std::swap(m_SizeX, m_SizeZ);
+}
+
+
+
+
+
+void cBlockArea::RotateCW(void)
+{
+ if (!HasBlockTypes())
+ {
+ LOGWARNING("cBlockArea: Cannot rotate blockmeta without blocktypes!");
+ return;
+ }
+
+ if (!HasBlockMetas())
+ {
+ // There are no blockmetas to rotate, just use the NoMeta function
+ RotateCWNoMeta();
+ return;
+ }
+
+ // We are guaranteed that both blocktypes and blockmetas exist; rotate both at the same time:
+ BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
+ NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = x;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = m_SizeZ - z - 1;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ int NewIdx = NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ;
+ int OldIdx = MakeIndex(x, y, z);
+ NewTypes[NewIdx] = m_BlockTypes[OldIdx];
+ NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCW(m_BlockMetas[OldIdx]);
+ } // for y
+ } // for z
+ } // for x
+ std::swap(m_BlockTypes, NewTypes);
+ std::swap(m_BlockMetas, NewMetas);
+ delete[] NewTypes;
+ delete[] NewMetas;
+
+ std::swap(m_SizeX, m_SizeZ);
+}
+
+
+
+
+
+void cBlockArea::MirrorXY(void)
+{
+ if (!HasBlockTypes())
+ {
+ LOGWARNING("cBlockArea: Cannot mirror meta without blocktypes!");
+ return;
+ }
+
+ if (!HasBlockMetas())
+ {
+ // There are no blockmetas to mirror, just use the NoMeta function
+ MirrorXYNoMeta();
+ return;
+ }
+
+ // We are guaranteed that both blocktypes and blockmetas exist; mirror both at the same time:
+ int HalfZ = m_SizeZ / 2;
+ int MaxZ = m_SizeZ - 1;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ for (int z = 0; z < HalfZ; z++)
+ {
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int Idx1 = MakeIndex(x, y, z);
+ int Idx2 = MakeIndex(x, y, MaxZ - z);
+ std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
+ NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorXY(m_BlockMetas[Idx1]);
+ NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorXY(m_BlockMetas[Idx2]);
+ m_BlockMetas[Idx1] = Meta2;
+ m_BlockMetas[Idx2] = Meta1;
+ } // for x
+ } // for z
+ } // for y
+}
+
+
+
+
+
+void cBlockArea::MirrorXZ(void)
+{
+ if (!HasBlockTypes())
+ {
+ LOGWARNING("cBlockArea: Cannot mirror meta without blocktypes!");
+ return;
+ }
+
+ if (!HasBlockMetas())
+ {
+ // There are no blockmetas to mirror, just use the NoMeta function
+ MirrorXZNoMeta();
+ return;
+ }
+
+ // We are guaranteed that both blocktypes and blockmetas exist; mirror both at the same time:
+ int HalfY = m_SizeY / 2;
+ int MaxY = m_SizeY - 1;
+ for (int y = 0; y < HalfY; y++)
+ {
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int Idx1 = MakeIndex(x, y, z);
+ int Idx2 = MakeIndex(x, MaxY - y, z);
+ std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
+ NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorXZ(m_BlockMetas[Idx1]);
+ NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorXZ(m_BlockMetas[Idx2]);
+ m_BlockMetas[Idx1] = Meta2;
+ m_BlockMetas[Idx2] = Meta1;
+ } // for x
+ } // for z
+ } // for y
+}
+
+
+
+
+
+void cBlockArea::MirrorYZ(void)
+{
+ if (!HasBlockTypes())
+ {
+ LOGWARNING("cBlockArea: Cannot mirror meta without blocktypes!");
+ return;
+ }
+
+ if (!HasBlockMetas())
+ {
+ // There are no blockmetas to mirror, just use the NoMeta function
+ MirrorYZNoMeta();
+ return;
+ }
+
+ // We are guaranteed that both blocktypes and blockmetas exist; mirror both at the same time:
+ int HalfX = m_SizeX / 2;
+ int MaxX = m_SizeX - 1;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ for (int x = 0; x < HalfX; x++)
+ {
+ int Idx1 = MakeIndex(x, y, z);
+ int Idx2 = MakeIndex(MaxX - x, y, z);
+ std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
+ NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorYZ(m_BlockMetas[Idx1]);
+ NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorYZ(m_BlockMetas[Idx2]);
+ m_BlockMetas[Idx1] = Meta2;
+ m_BlockMetas[Idx2] = Meta1;
+ } // for x
+ } // for z
+ } // for y
+}
+
+
+
+
+
+void cBlockArea::RotateCCWNoMeta(void)
+{
+ if (HasBlockTypes())
+ {
+ BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = m_SizeX - x - 1;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = z;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
+ } // for y
+ } // for z
+ } // for x
+ std::swap(m_BlockTypes, NewTypes);
+ delete[] NewTypes;
+ }
+ if (HasBlockMetas())
+ {
+ NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = m_SizeX - x - 1;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = z;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
+ } // for y
+ } // for z
+ } // for x
+ std::swap(m_BlockMetas, NewMetas);
+ delete[] NewMetas;
+ }
+ std::swap(m_SizeX, m_SizeZ);
+}
+
+
+
+
+
+void cBlockArea::RotateCWNoMeta(void)
+{
+ if (HasBlockTypes())
+ {
+ BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = m_SizeZ - z - 1;
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = x;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
+ } // for y
+ } // for x
+ } // for z
+ std::swap(m_BlockTypes, NewTypes);
+ delete[] NewTypes;
+ }
+ if (HasBlockMetas())
+ {
+ NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = m_SizeZ - z - 1;
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = x;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
+ } // for y
+ } // for x
+ } // for z
+ std::swap(m_BlockMetas, NewMetas);
+ delete[] NewMetas;
+ }
+ std::swap(m_SizeX, m_SizeZ);
+}
+
+
+
+
+
+void cBlockArea::MirrorXYNoMeta(void)
+{
+ int HalfZ = m_SizeZ / 2;
+ int MaxZ = m_SizeZ - 1;
+ if (HasBlockTypes())
+ {
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ for (int z = 0; z < HalfZ; z++)
+ {
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ std::swap(m_BlockTypes[MakeIndex(x, y, z)], m_BlockTypes[MakeIndex(x, y, MaxZ - z)]);
+ } // for x
+ } // for z
+ } // for y
+ } // if (HasBlockTypes)
+
+ if (HasBlockMetas())
+ {
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ for (int z = 0; z < HalfZ; z++)
+ {
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ std::swap(m_BlockMetas[MakeIndex(x, y, z)], m_BlockMetas[MakeIndex(x, y, MaxZ - z)]);
+ } // for x
+ } // for z
+ } // for y
+ } // if (HasBlockMetas)
+}
+
+
+
+
+
+void cBlockArea::MirrorXZNoMeta(void)
+{
+ int HalfY = m_SizeY / 2;
+ int MaxY = m_SizeY - 1;
+ if (HasBlockTypes())
+ {
+ for (int y = 0; y < HalfY; y++)
+ {
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ std::swap(m_BlockTypes[MakeIndex(x, y, z)], m_BlockTypes[MakeIndex(x, MaxY - y, z)]);
+ } // for x
+ } // for z
+ } // for y
+ } // if (HasBlockTypes)
+
+ if (HasBlockMetas())
+ {
+ for (int y = 0; y < HalfY; y++)
+ {
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ std::swap(m_BlockMetas[MakeIndex(x, y, z)], m_BlockMetas[MakeIndex(x, MaxY - y, z)]);
+ } // for x
+ } // for z
+ } // for y
+ } // if (HasBlockMetas)
+}
+
+
+
+
+
+void cBlockArea::MirrorYZNoMeta(void)
+{
+ int HalfX = m_SizeX / 2;
+ int MaxX = m_SizeX - 1;
+ if (HasBlockTypes())
+ {
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ for (int x = 0; x < HalfX; x++)
+ {
+ std::swap(m_BlockTypes[MakeIndex(x, y, z)], m_BlockTypes[MakeIndex(MaxX - x, y, z)]);
+ } // for x
+ } // for z
+ } // for y
+ } // if (HasBlockTypes)
+
+ if (HasBlockMetas())
+ {
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ for (int x = 0; x < HalfX; x++)
+ {
+ std::swap(m_BlockMetas[MakeIndex(x, y, z)], m_BlockMetas[MakeIndex(MaxX - x, y, z)]);
+ } // for x
+ } // for z
+ } // for y
+ } // if (HasBlockMetas)
+}
+
+
+
+
+
+void cBlockArea::SetRelBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
+{
+ if (m_BlockTypes == NULL)
+ {
+ LOGWARNING("cBlockArea: BlockTypes have not been read!");
+ return;
+ }
+ m_BlockTypes[MakeIndex(a_RelX, a_RelY, a_RelZ)] = a_BlockType;
+}
+
+
+
+
+
+void cBlockArea::SetBlockType(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType)
+{
+ SetRelBlockType(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_BlockType);
+}
+
+
+
+
+
+void cBlockArea::SetRelBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta)
+{
+ SetRelNibble(a_RelX, a_RelY, a_RelZ, a_BlockMeta, m_BlockMetas);
+}
+
+
+
+
+
+void cBlockArea::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockMeta)
+{
+ SetNibble(a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta, m_BlockMetas);
+}
+
+
+
+
+
+void cBlockArea::SetRelBlockLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockLight)
+{
+ SetRelNibble(a_RelX, a_RelY, a_RelZ, a_BlockLight, m_BlockLight);
+}
+
+
+
+
+
+void cBlockArea::SetBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockLight)
+{
+ SetNibble(a_BlockX, a_BlockY, a_BlockZ, a_BlockLight, m_BlockLight);
+}
+
+
+
+
+
+void cBlockArea::SetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockSkyLight)
+{
+ SetRelNibble(a_RelX, a_RelY, a_RelZ, a_BlockSkyLight, m_BlockSkyLight);
+}
+
+
+
+
+
+void cBlockArea::SetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockSkyLight)
+{
+ SetNibble(a_BlockX, a_BlockY, a_BlockZ, a_BlockSkyLight, m_BlockSkyLight);
+}
+
+
+
+
+
+BLOCKTYPE cBlockArea::GetRelBlockType(int a_RelX, int a_RelY, int a_RelZ) const
+{
+ if (m_BlockTypes == NULL)
+ {
+ LOGWARNING("cBlockArea: BlockTypes have not been read!");
+ return E_BLOCK_AIR;
+ }
+ return m_BlockTypes[MakeIndex(a_RelX, a_RelY, a_RelZ)];
+}
+
+
+
+
+
+BLOCKTYPE cBlockArea::GetBlockType(int a_BlockX, int a_BlockY, int a_BlockZ) const
+{
+ return GetRelBlockType(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ);
+}
+
+
+
+
+
+NIBBLETYPE cBlockArea::GetRelBlockMeta(int a_RelX, int a_RelY, int a_RelZ) const
+{
+ return GetRelNibble(a_RelX, a_RelY, a_RelZ, m_BlockMetas);
+}
+
+
+
+
+
+NIBBLETYPE cBlockArea::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) const
+{
+ return GetNibble(a_BlockX, a_BlockY, a_BlockZ, m_BlockMetas);
+}
+
+
+
+
+
+NIBBLETYPE cBlockArea::GetRelBlockLight(int a_RelX, int a_RelY, int a_RelZ) const
+{
+ return GetRelNibble(a_RelX, a_RelY, a_RelZ, m_BlockLight);
+}
+
+
+
+
+
+NIBBLETYPE cBlockArea::GetBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ) const
+{
+ return GetNibble(a_BlockX, a_BlockY, a_BlockZ, m_BlockLight);
+}
+
+
+
+
+
+NIBBLETYPE cBlockArea::GetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ) const
+{
+ return GetRelNibble(a_RelX, a_RelY, a_RelZ, m_BlockSkyLight);
+}
+
+
+
+
+
+NIBBLETYPE cBlockArea::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ) const
+{
+ return GetNibble(a_BlockX, a_BlockY, a_BlockZ, m_BlockSkyLight);
+}
+
+
+
+
+
+void cBlockArea::SetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+{
+ SetRelBlockTypeMeta(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_BlockType, a_BlockMeta);
+}
+
+
+
+
+
+void cBlockArea::SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+{
+ int idx = MakeIndex(a_RelX, a_RelY, a_RelZ);
+ if (m_BlockTypes == NULL)
+ {
+ LOGWARNING("%s: BlockTypes not available but requested to be written to.", __FUNCTION__);
+ }
+ else
+ {
+ m_BlockTypes[idx] = a_BlockType;
+ }
+ if (m_BlockMetas == NULL)
+ {
+ LOGWARNING("%s: BlockMetas not available but requested to be written to.", __FUNCTION__);
+ }
+ else
+ {
+ m_BlockMetas[idx] = a_BlockMeta;
+ }
+}
+
+
+
+
+
+void cBlockArea::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
+{
+ return GetRelBlockTypeMeta(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_BlockType, a_BlockMeta);
+}
+
+
+
+
+
+void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
+{
+ int idx = MakeIndex(a_RelX, a_RelY, a_RelZ);
+ if (m_BlockTypes == NULL)
+ {
+ LOGWARNING("cBlockArea: BlockTypes have not been read!");
+ a_BlockType = E_BLOCK_AIR;
+ }
+ else
+ {
+ a_BlockType = m_BlockTypes[idx];
+ }
+
+ if (m_BlockMetas == NULL)
+ {
+ LOGWARNING("cBlockArea: BlockMetas have not been read!");
+ a_BlockMeta = 0;
+ }
+ else
+ {
+ a_BlockMeta = m_BlockMetas[idx];
+ }
+}
+
+
+
+
+
+int cBlockArea::GetDataTypes(void) const
+{
+ int res = 0;
+ if (m_BlockTypes != NULL)
+ {
+ res |= baTypes;
+ }
+ if (m_BlockMetas != NULL)
+ {
+ res |= baMetas;
+ }
+ if (m_BlockLight != NULL)
+ {
+ res |= baLight;
+ }
+ if (m_BlockSkyLight != NULL)
+ {
+ res |= baSkyLight;
+ }
+ return res;
+}
+
+
+
+
+
+bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
+{
+ ASSERT(m_BlockTypes == NULL); // Has been cleared
+
+ if (a_DataTypes & baTypes)
+ {
+ m_BlockTypes = new BLOCKTYPE[a_SizeX * a_SizeY * a_SizeZ];
+ if (m_BlockTypes == NULL)
+ {
+ return false;
+ }
+ }
+ if (a_DataTypes & baMetas)
+ {
+ m_BlockMetas = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
+ if (m_BlockMetas == NULL)
+ {
+ delete[] m_BlockTypes;
+ return false;
+ }
+ }
+ if (a_DataTypes & baLight)
+ {
+ m_BlockLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
+ if (m_BlockLight == NULL)
+ {
+ delete[] m_BlockMetas;
+ delete[] m_BlockTypes;
+ return false;
+ }
+ }
+ if (a_DataTypes & baSkyLight)
+ {
+ m_BlockSkyLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
+ if (m_BlockSkyLight == NULL)
+ {
+ delete[] m_BlockLight;
+ delete[] m_BlockMetas;
+ delete[] m_BlockTypes;
+ return false;
+ }
+ }
+ m_SizeX = a_SizeX;
+ m_SizeY = a_SizeY;
+ m_SizeZ = a_SizeZ;
+ return true;
+}
+
+
+
+
+
+int cBlockArea::MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const
+{
+ ASSERT(a_RelX >= 0);
+ ASSERT(a_RelX < m_SizeX);
+ ASSERT(a_RelY >= 0);
+ ASSERT(a_RelY < m_SizeY);
+ ASSERT(a_RelZ >= 0);
+ ASSERT(a_RelZ < m_SizeZ);
+
+ return a_RelX + a_RelZ * m_SizeX + a_RelY * m_SizeX * m_SizeZ;
+}
+
+
+
+
+
+void cBlockArea::SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array)
+{
+ if (a_Array == NULL)
+ {
+ LOGWARNING("cBlockArea: datatype has not been read!");
+ return;
+ }
+ a_Array[MakeIndex(a_RelX, a_RelY, a_RelZ)] = a_Value;
+}
+
+
+
+
+
+void cBlockArea::SetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array)
+{
+ SetRelNibble(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_Value, a_Array);
+}
+
+
+
+
+
+NIBBLETYPE cBlockArea::GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const
+{
+ if (a_Array == NULL)
+ {
+ LOGWARNING("cBlockArea: datatype has not been read!");
+ return 16;
+ }
+ return a_Array[MakeIndex(a_RelX, a_RelY, a_RelZ)];
+}
+
+
+
+
+
+NIBBLETYPE cBlockArea::GetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE * a_Array) const
+{
+ return GetRelNibble(a_BlockX - m_OriginX, a_BlockY - m_OriginY, a_BlockZ - m_OriginZ, a_Array);
+}
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cBlockArea::cChunkReader:
+
+cBlockArea::cChunkReader::cChunkReader(cBlockArea & a_Area) :
+ m_Area(a_Area),
+ m_OriginX(a_Area.m_OriginX),
+ m_OriginY(a_Area.m_OriginY),
+ m_OriginZ(a_Area.m_OriginZ)
+{
+}
+
+
+
+
+
+void cBlockArea::cChunkReader::CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc)
+{
+ int SizeY = m_Area.m_SizeY;
+ int MinY = m_OriginY;
+
+ // SizeX, SizeZ are the dmensions 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;
+ int SizeZ = cChunkDef::Width;
+ int OffX, OffZ;
+ int BaseX, BaseZ;
+ OffX = m_CurrentChunkX * cChunkDef::Width - m_OriginX;
+ if (OffX < 0)
+ {
+ BaseX = -OffX;
+ SizeX += OffX; // SizeX is decreased, OffX is negative
+ OffX = 0;
+ }
+ else
+ {
+ BaseX = 0;
+ }
+ OffZ = m_CurrentChunkZ * cChunkDef::Width - m_OriginZ;
+ if (OffZ < 0)
+ {
+ BaseZ = -OffZ;
+ SizeZ += OffZ; // SizeZ is decreased, OffZ is negative
+ OffZ = 0;
+ }
+ else
+ {
+ BaseZ = 0;
+ }
+ // If the chunk extends beyond the area in the X or Z axis, cut off the Size:
+ if ((m_CurrentChunkX + 1) * cChunkDef::Width > m_OriginX + m_Area.m_SizeX)
+ {
+ SizeX -= (m_CurrentChunkX + 1) * cChunkDef::Width - (m_OriginX + m_Area.m_SizeX);
+ }
+ if ((m_CurrentChunkZ + 1) * cChunkDef::Width > m_OriginZ + m_Area.m_SizeZ)
+ {
+ SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_OriginZ + m_Area.m_SizeZ);
+ }
+
+ for (int y = 0; y < SizeY; y++)
+ {
+ int ChunkY = MinY + y;
+ int AreaY = y;
+ for (int z = 0; z < SizeZ; z++)
+ {
+ int ChunkZ = BaseZ + z;
+ int AreaZ = OffZ + z;
+ for (int x = 0; x < SizeX; x++)
+ {
+ int ChunkX = BaseX + x;
+ int AreaX = OffX + x;
+ a_AreaDst[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = cChunkDef::GetNibble(a_ChunkSrc, ChunkX, ChunkY, ChunkZ);
+ } // for x
+ } // for z
+ } // for y
+}
+
+
+
+
+
+bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ)
+{
+ m_CurrentChunkX = a_ChunkX;
+ m_CurrentChunkZ = a_ChunkZ;
+ return true;
+}
+
+
+
+
+
+void cBlockArea::cChunkReader::BlockTypes(const BLOCKTYPE * a_BlockTypes)
+{
+ if (m_Area.m_BlockTypes == NULL)
+ {
+ // Don't want BlockTypes
+ return;
+ }
+
+ int SizeY = m_Area.m_SizeY;
+ int MinY = m_OriginY;
+
+ // SizeX, SizeZ are the dmensions 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;
+ int SizeZ = cChunkDef::Width;
+ int OffX, OffZ;
+ int BaseX, BaseZ;
+ OffX = m_CurrentChunkX * cChunkDef::Width - m_OriginX;
+ if (OffX < 0)
+ {
+ BaseX = -OffX;
+ SizeX += OffX; // SizeX is decreased, OffX is negative
+ OffX = 0;
+ }
+ else
+ {
+ BaseX = 0;
+ }
+ OffZ = m_CurrentChunkZ * cChunkDef::Width - m_OriginZ;
+ if (OffZ < 0)
+ {
+ BaseZ = -OffZ;
+ SizeZ += OffZ; // SizeZ is decreased, OffZ is negative
+ OffZ = 0;
+ }
+ else
+ {
+ BaseZ = 0;
+ }
+ // If the chunk extends beyond the area in the X or Z axis, cut off the Size:
+ if ((m_CurrentChunkX + 1) * cChunkDef::Width > m_OriginX + m_Area.m_SizeX)
+ {
+ SizeX -= (m_CurrentChunkX + 1) * cChunkDef::Width - (m_OriginX + m_Area.m_SizeX);
+ }
+ if ((m_CurrentChunkZ + 1) * cChunkDef::Width > m_OriginZ + m_Area.m_SizeZ)
+ {
+ SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_OriginZ + m_Area.m_SizeZ);
+ }
+
+ for (int y = 0; y < SizeY; y++)
+ {
+ int ChunkY = MinY + y;
+ int AreaY = y;
+ for (int z = 0; z < SizeZ; z++)
+ {
+ int ChunkZ = BaseZ + z;
+ int AreaZ = OffZ + z;
+ for (int x = 0; x < SizeX; x++)
+ {
+ 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
+}
+
+
+
+
+
+void cBlockArea::cChunkReader::BlockMeta(const NIBBLETYPE * a_BlockMetas)
+{
+ if (m_Area.m_BlockMetas == NULL)
+ {
+ // Don't want metas
+ return;
+ }
+ CopyNibbles(m_Area.m_BlockMetas, a_BlockMetas);
+}
+
+
+
+
+
+void cBlockArea::cChunkReader::BlockLight(const NIBBLETYPE * a_BlockLight)
+{
+ if (m_Area.m_BlockLight == NULL)
+ {
+ // Don't want light
+ return;
+ }
+ CopyNibbles(m_Area.m_BlockLight, a_BlockLight);
+}
+
+
+
+
+
+void cBlockArea::cChunkReader::BlockSkyLight(const NIBBLETYPE * a_BlockSkyLight)
+{
+ if (m_Area.m_BlockSkyLight == NULL)
+ {
+ // Don't want skylight
+ return;
+ }
+ 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;
+ int NewSizeY = GetSizeY() - a_AddMinY - a_SubMaxY;
+ int NewSizeZ = GetSizeZ() - a_AddMinZ - a_SubMaxZ;
+ BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[NewSizeX * NewSizeY * NewSizeZ];
+ int idx = 0;
+ for (int y = 0; y < NewSizeY; y++)
+ {
+ for (int z = 0; z < NewSizeZ; z++)
+ {
+ for (int x = 0; x < NewSizeX; x++)
+ {
+ int OldIndex = MakeIndex(x + a_AddMinX, y + a_AddMinY, z + a_AddMinZ);
+ NewBlockTypes[idx++] = m_BlockTypes[OldIndex];
+ } // for x
+ } // for z
+ } // for y
+ delete m_BlockTypes;
+ m_BlockTypes = NewBlockTypes;
+}
+
+
+
+
+
+void cBlockArea::CropNibbles(NIBBLEARRAY & a_Array, 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;
+ int NewSizeY = GetSizeY() - a_AddMinY - a_SubMaxY;
+ int NewSizeZ = GetSizeZ() - a_AddMinZ - a_SubMaxZ;
+ NIBBLETYPE * NewNibbles = new NIBBLETYPE[NewSizeX * NewSizeY * NewSizeZ];
+ int idx = 0;
+ for (int y = 0; y < NewSizeY; y++)
+ {
+ for (int z = 0; z < NewSizeZ; z++)
+ {
+ for (int x = 0; x < NewSizeX; x++)
+ {
+ NewNibbles[idx++] = a_Array[MakeIndex(x + a_AddMinX, y + a_AddMinY, z + a_AddMinZ)];
+ } // for x
+ } // for z
+ } // for y
+ delete a_Array;
+ a_Array = NewNibbles;
+}
+
+
+
+
+
+void cBlockArea::ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
+{
+ int NewSizeX = m_SizeX + a_SubMinX + a_AddMaxX;
+ int NewSizeY = m_SizeY + a_SubMinY + a_AddMaxY;
+ int NewSizeZ = m_SizeZ + a_SubMinZ + a_AddMaxZ;
+ int BlockCount = NewSizeX * NewSizeY * NewSizeZ;
+ BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[BlockCount];
+ memset(NewBlockTypes, 0, BlockCount * sizeof(BLOCKTYPE));
+ int OldIndex = 0;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ int IndexBaseY = (y + a_SubMinY) * m_SizeX * m_SizeZ;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int IndexBaseZ = IndexBaseY + (z + a_SubMinZ) * m_SizeX;
+ int idx = IndexBaseZ + a_SubMinX;
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ NewBlockTypes[idx++] = m_BlockTypes[OldIndex++];
+ } // for x
+ } // for z
+ } // for y
+ delete m_BlockTypes;
+ m_BlockTypes = NewBlockTypes;
+}
+
+
+
+
+
+void cBlockArea::ExpandNibbles(NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
+{
+ int NewSizeX = m_SizeX + a_SubMinX + a_AddMaxX;
+ int NewSizeY = m_SizeY + a_SubMinY + a_AddMaxY;
+ int NewSizeZ = m_SizeZ + a_SubMinZ + a_AddMaxZ;
+ int BlockCount = NewSizeX * NewSizeY * NewSizeZ;
+ NIBBLETYPE * NewNibbles = new NIBBLETYPE[BlockCount];
+ memset(NewNibbles, 0, BlockCount * sizeof(NIBBLETYPE));
+ int OldIndex = 0;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ int IndexBaseY = (y + a_SubMinY) * m_SizeX * m_SizeZ;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int IndexBaseZ = IndexBaseY + (z + a_SubMinZ) * m_SizeX;
+ int idx = IndexBaseZ + a_SubMinX;
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ NewNibbles[idx++] = a_Array[OldIndex++];
+ } // for x
+ } // for z
+ } // for y
+ delete a_Array;
+ a_Array = NewNibbles;
+}
+
+
+
+
+
+bool cBlockArea::LoadFromSchematicNBT(cParsedNBT & a_NBT)
+{
+ int TMaterials = a_NBT.FindChildByName(a_NBT.GetRoot(), "Materials");
+ if ((TMaterials > 0) && (a_NBT.GetType(TMaterials) == TAG_String))
+ {
+ AString Materials = a_NBT.GetString(TMaterials);
+ if (Materials.compare("Alpha") != 0)
+ {
+ LOG("Materials tag is present and \"%s\" instead of \"Alpha\". Possibly a wrong-format schematic file.", Materials.c_str());
+ return false;
+ }
+ }
+ int TSizeX = a_NBT.FindChildByName(a_NBT.GetRoot(), "Width");
+ int TSizeY = a_NBT.FindChildByName(a_NBT.GetRoot(), "Height");
+ int TSizeZ = a_NBT.FindChildByName(a_NBT.GetRoot(), "Length");
+ if (
+ (TSizeX < 0) || (TSizeY < 0) || (TSizeZ < 0) ||
+ (a_NBT.GetType(TSizeX) != TAG_Short) ||
+ (a_NBT.GetType(TSizeY) != TAG_Short) ||
+ (a_NBT.GetType(TSizeZ) != TAG_Short)
+ )
+ {
+ LOG("Dimensions are missing from the schematic file (%d, %d, %d), (%d, %d, %d)",
+ TSizeX, TSizeY, TSizeZ,
+ a_NBT.GetType(TSizeX), a_NBT.GetType(TSizeY), a_NBT.GetType(TSizeZ)
+ );
+ return false;
+ }
+
+ 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))
+ {
+ LOG("Dimensions are invalid in the schematic file: %d, %d, %d", SizeX, SizeY, SizeZ);
+ return false;
+ }
+
+ int TBlockTypes = a_NBT.FindChildByName(a_NBT.GetRoot(), "Blocks");
+ int TBlockMetas = a_NBT.FindChildByName(a_NBT.GetRoot(), "Data");
+ if ((TBlockTypes < 0) || (a_NBT.GetType(TBlockTypes) != TAG_ByteArray))
+ {
+ LOG("BlockTypes are invalid in the schematic file: %d", TBlockTypes);
+ return false;
+ }
+ bool AreMetasPresent = (TBlockMetas > 0) && (a_NBT.GetType(TBlockMetas) == TAG_ByteArray);
+
+ Clear();
+ SetSize(SizeX, SizeY, SizeZ, AreMetasPresent ? (baTypes | baMetas) : baTypes);
+
+ // Copy the block types and metas:
+ int NumBytes = m_SizeX * m_SizeY * m_SizeZ;
+ 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)
+ );
+ NumBytes = a_NBT.GetDataLength(TBlockTypes);
+ }
+ memcpy(m_BlockTypes, a_NBT.GetData(TBlockTypes), NumBytes);
+
+ if (AreMetasPresent)
+ {
+ int NumBytes = m_SizeX * m_SizeY * m_SizeZ;
+ 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)
+ );
+ NumBytes = a_NBT.GetDataLength(TBlockMetas);
+ }
+ memcpy(m_BlockMetas, a_NBT.GetData(TBlockMetas), NumBytes);
+ }
+
+ return true;
+}
+
+
+
+
+void cBlockArea::RelSetData(
+ int a_RelX, int a_RelY, int a_RelZ,
+ int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
+)
+{
+ int Index = MakeIndex(a_RelX, a_RelY, a_RelZ);
+ if ((a_DataTypes & baTypes) != 0)
+ {
+ m_BlockTypes[Index] = a_BlockType;
+ }
+ if ((a_DataTypes & baMetas) != 0)
+ {
+ m_BlockMetas[Index] = a_BlockMeta;
+ }
+ if ((a_DataTypes & baLight) != 0)
+ {
+ m_BlockLight[Index] = a_BlockLight;
+ }
+ if ((a_DataTypes & baSkyLight) != 0)
+ {
+ m_BlockSkyLight[Index] = a_BlockSkyLight;
+ }
+}
+
+
+
+
diff --git a/source/BlockArea.h b/source/BlockArea.h
index 76c4f749a..075cc99ec 100644
--- a/source/BlockArea.h
+++ b/source/BlockArea.h
@@ -1,310 +1,310 @@
-
-// BlockArea.h
-
-// Interfaces to the cBlockArea object representing an area of block data that can be queried from cWorld and then accessed again without further queries
-// The object also supports writing the blockdata back into cWorld, even into other coords
-
-// NOTE: All Nibble values (meta, blocklight, skylight) are stored one-nibble-per-byte for faster access / editting!
-
-
-
-
-
-#pragma once
-
-
-
-
-
-// fwd: World.h
-class cWorld;
-
-// fwd: FastNBT.h
-class cParsedNBT;
-
-
-
-
-
-// tolua_begin
-class cBlockArea
-{
- // tolua_end
- DISALLOW_COPY_AND_ASSIGN(cBlockArea);
- // tolua_begin
-
-public:
-
- /// What data is to be queried (bit-mask)
- enum
- {
- baTypes = 1,
- baMetas = 2,
- baLight = 4,
- baSkyLight = 8,
- } ;
-
- enum eMergeStrategy
- {
- msOverwrite,
- msFillAir,
- msImprint,
- msLake,
- } ;
-
- cBlockArea(void);
- ~cBlockArea();
-
- /// Clears the data stored to reclaim memory
- void Clear(void);
-
- /** Creates a new area of the specified size and contents.
- Origin is set to all zeroes.
- BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light.
- */
- void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes = baTypes | baMetas);
-
- /// Resets the origin. No other changes are made, contents are untouched.
- void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ);
-
- /// Reads an area of blocks specified. Returns true if successful. All coords are inclusive.
- bool Read(cWorld * a_World, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas);
-
- // TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write
- // A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again
-
- /// Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all
- bool Write(cWorld * a_World, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas);
-
- /// Copies this object's contents into the specified BlockArea.
- void CopyTo(cBlockArea & a_Into) const;
-
- /// Copies the contents from the specified BlockArea into this object.
- void CopyFrom(const cBlockArea & a_From);
-
- /// For testing purposes only, dumps the area into a file.
- void DumpToRawFile(const AString & a_FileName);
-
- /// Loads an area from a .schematic file. Returns true if successful
- bool LoadFromSchematicFile(const AString & a_FileName);
-
- /// Saves the area into a .schematic file. Returns true if successful
- bool SaveToSchematicFile(const AString & a_FileName);
-
- /// Crops the internal contents by the specified amount of blocks from each border.
- void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
-
- /// Expands the internal contents by the specified amount of blocks from each border
- void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
-
- /** Merges another block area into this one, using the specified block combinating strategy
- This function combines another BlockArea into the current object.
- The strategy parameter specifies how individual blocks are combined together, using the table below.
-
- | area block | result |
- | this | Src | msOverwrite | msFillAir | msImprint |
- +------+-----+-------------+-----------+-----------+
- | air | air | air | air | air |
- | A | air | air | A | A |
- | air | B | B | B | B |
- | A | B | B | A | B |
-
- So to sum up:
- - msOverwrite completely overwrites all blocks with the Src's blocks
- - msFillAir overwrites only those blocks that were air
- - msImprint overwrites with only those blocks that are non-air
-
- Special strategies:
- msLake (evaluate top-down, first match wins):
- | area block | |
- | this | Src | result |
- +----------+--------+--------+
- | A | sponge | A | Sponge is the NOP block
- | * | air | air | Air always gets hollowed out, even under the oceans
- | water | * | water | Water is never overwritten
- | lava | * | lava | Lava is never overwritten
- | * | water | water | Water always overwrites anything
- | * | lava | lava | Lava always overwrites anything
- | dirt | stone | stone | Stone overwrites dirt
- | grass | stone | stone | ... and grass
- | mycelium | stone | stone | ... and mycelium
- | A | stone | A | ... but nothing else
- | A | * | A | Everything else is left as it is
-
- */
- void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy);
-
- /// Fills the entire block area with the specified data
- 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,
- int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
- NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
- );
-
- /// Draws a line from between two points with the specified data
- void RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2,
- int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
- NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
- );
-
- /// Rotates the entire area counter-clockwise around the Y axis
- void RotateCCW(void);
-
- /// Rotates the entire area clockwise around the Y axis
- void RotateCW(void);
-
- /// Mirrors the entire area around the XY plane
- void MirrorXY(void);
-
- /// Mirrors the entire area around the XZ plane
- void MirrorXZ(void);
-
- /// Mirrors the entire area around the YZ plane
- void MirrorYZ(void);
-
- /// Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta
- void RotateCCWNoMeta(void);
-
- /// Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta
- void RotateCWNoMeta(void);
-
- /// Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta
- void MirrorXYNoMeta(void);
-
- /// Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta
- void MirrorXZNoMeta(void);
-
- /// Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta
- void MirrorYZNoMeta(void);
-
- // Setters:
- void SetRelBlockType (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType);
- void SetBlockType (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType);
- void SetRelBlockMeta (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta);
- void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockMeta);
- void SetRelBlockLight (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockLight);
- void SetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockLight);
- void SetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockSkyLight);
- void SetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockSkyLight);
-
- // Getters:
- BLOCKTYPE GetRelBlockType (int a_RelX, int a_RelY, int a_RelZ) const;
- BLOCKTYPE GetBlockType (int a_BlockX, int a_BlockY, int a_BlockZ) const;
- NIBBLETYPE GetRelBlockMeta (int a_RelX, int a_RelY, int a_RelZ) const;
- NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ) const;
- NIBBLETYPE GetRelBlockLight (int a_RelX, int a_RelY, int a_RelZ) const;
- NIBBLETYPE GetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ) const;
- NIBBLETYPE GetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ) const;
- NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ) const;
-
- void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
- void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
- void GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
- void GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
-
- int GetSizeX(void) const { return m_SizeX; }
- int GetSizeY(void) const { return m_SizeY; }
- int GetSizeZ(void) const { return m_SizeZ; }
-
- int GetOriginX(void) const { return m_OriginX; }
- int GetOriginY(void) const { return m_OriginY; }
- int GetOriginZ(void) const { return m_OriginZ; }
-
- /// Returns the datatypes that are stored in the object (bitmask of baXXX values)
- int GetDataTypes(void) const;
-
- bool HasBlockTypes (void) const { return (m_BlockTypes != NULL); }
- bool HasBlockMetas (void) const { return (m_BlockMetas != NULL); }
- bool HasBlockLights (void) const { return (m_BlockLight != NULL); }
- bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != NULL); }
-
- // tolua_end
-
- // Clients can use these for faster access to all blocktypes. Be careful though!
- /// Returns the internal pointer to the block types
- BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; }
- 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_SizeX * m_SizeY * m_SizeZ; }
- int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const;
-
-protected:
- friend class cChunkDesc;
-
- class cChunkReader :
- public cChunkDataCallback
- {
- public:
- cChunkReader(cBlockArea & a_Area);
-
- protected:
- cBlockArea & m_Area;
- int m_OriginX;
- int m_OriginY;
- int m_OriginZ;
- int m_CurrentChunkX;
- int m_CurrentChunkZ;
-
- 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;
- } ;
-
- typedef NIBBLETYPE * NIBBLEARRAY;
-
-
- int m_OriginX;
- int m_OriginY;
- int m_OriginZ;
- int m_SizeX;
- int m_SizeY;
- int m_SizeZ;
-
- BLOCKTYPE * m_BlockTypes;
- NIBBLETYPE * m_BlockMetas; // Each meta is stored as a separate byte for faster access
- NIBBLETYPE * m_BlockLight; // Each light value is stored as a separate byte for faster access
- NIBBLETYPE * m_BlockSkyLight; // Each light value is stored as a separate byte for faster access
-
- /// Clears the data stored and prepares a fresh new block area with the specified dimensions
- bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes);
-
- // Basic Setters:
- void SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array);
- void SetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array);
-
- // Basic Getters:
- NIBBLETYPE GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const;
- NIBBLETYPE GetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE * a_Array) const;
-
- // Crop helpers:
- void CropBlockTypes(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
- void CropNibbles (NIBBLEARRAY & a_Array, int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
-
- // Expand helpers:
- void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
- void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
-
- /// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful.
- bool LoadFromSchematicNBT(cParsedNBT & a_NBT);
-
- /// Sets the specified datatypes at the specified location.
- void RelSetData(
- int a_RelX, int a_RelY, int a_RelZ,
- int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
- NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
- );
- // tolua_begin
-} ;
-// tolua_end
-
-
-
-
+
+// BlockArea.h
+
+// Interfaces to the cBlockArea object representing an area of block data that can be queried from cWorld and then accessed again without further queries
+// The object also supports writing the blockdata back into cWorld, even into other coords
+
+// NOTE: All Nibble values (meta, blocklight, skylight) are stored one-nibble-per-byte for faster access / editting!
+
+
+
+
+
+#pragma once
+
+
+
+
+
+// fwd: World.h
+class cWorld;
+
+// fwd: FastNBT.h
+class cParsedNBT;
+
+
+
+
+
+// tolua_begin
+class cBlockArea
+{
+ // tolua_end
+ DISALLOW_COPY_AND_ASSIGN(cBlockArea);
+ // tolua_begin
+
+public:
+
+ /// What data is to be queried (bit-mask)
+ enum
+ {
+ baTypes = 1,
+ baMetas = 2,
+ baLight = 4,
+ baSkyLight = 8,
+ } ;
+
+ enum eMergeStrategy
+ {
+ msOverwrite,
+ msFillAir,
+ msImprint,
+ msLake,
+ } ;
+
+ cBlockArea(void);
+ ~cBlockArea();
+
+ /// Clears the data stored to reclaim memory
+ void Clear(void);
+
+ /** Creates a new area of the specified size and contents.
+ Origin is set to all zeroes.
+ BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light.
+ */
+ void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes = baTypes | baMetas);
+
+ /// Resets the origin. No other changes are made, contents are untouched.
+ void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ);
+
+ /// Reads an area of blocks specified. Returns true if successful. All coords are inclusive.
+ bool Read(cWorld * a_World, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas);
+
+ // TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write
+ // A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again
+
+ /// Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all
+ bool Write(cWorld * a_World, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas);
+
+ /// Copies this object's contents into the specified BlockArea.
+ void CopyTo(cBlockArea & a_Into) const;
+
+ /// Copies the contents from the specified BlockArea into this object.
+ void CopyFrom(const cBlockArea & a_From);
+
+ /// For testing purposes only, dumps the area into a file.
+ void DumpToRawFile(const AString & a_FileName);
+
+ /// Loads an area from a .schematic file. Returns true if successful
+ bool LoadFromSchematicFile(const AString & a_FileName);
+
+ /// Saves the area into a .schematic file. Returns true if successful
+ bool SaveToSchematicFile(const AString & a_FileName);
+
+ /// Crops the internal contents by the specified amount of blocks from each border.
+ void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
+
+ /// Expands the internal contents by the specified amount of blocks from each border
+ void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
+
+ /** Merges another block area into this one, using the specified block combinating strategy
+ This function combines another BlockArea into the current object.
+ The strategy parameter specifies how individual blocks are combined together, using the table below.
+
+ | area block | result |
+ | this | Src | msOverwrite | msFillAir | msImprint |
+ +------+-----+-------------+-----------+-----------+
+ | air | air | air | air | air |
+ | A | air | air | A | A |
+ | air | B | B | B | B |
+ | A | B | B | A | B |
+
+ So to sum up:
+ - msOverwrite completely overwrites all blocks with the Src's blocks
+ - msFillAir overwrites only those blocks that were air
+ - msImprint overwrites with only those blocks that are non-air
+
+ Special strategies:
+ msLake (evaluate top-down, first match wins):
+ | area block | |
+ | this | Src | result |
+ +----------+--------+--------+
+ | A | sponge | A | Sponge is the NOP block
+ | * | air | air | Air always gets hollowed out, even under the oceans
+ | water | * | water | Water is never overwritten
+ | lava | * | lava | Lava is never overwritten
+ | * | water | water | Water always overwrites anything
+ | * | lava | lava | Lava always overwrites anything
+ | dirt | stone | stone | Stone overwrites dirt
+ | grass | stone | stone | ... and grass
+ | mycelium | stone | stone | ... and mycelium
+ | A | stone | A | ... but nothing else
+ | A | * | A | Everything else is left as it is
+
+ */
+ void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy);
+
+ /// Fills the entire block area with the specified data
+ 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,
+ int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
+ NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
+ );
+
+ /// Draws a line from between two points with the specified data
+ void RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2,
+ int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
+ NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
+ );
+
+ /// Rotates the entire area counter-clockwise around the Y axis
+ void RotateCCW(void);
+
+ /// Rotates the entire area clockwise around the Y axis
+ void RotateCW(void);
+
+ /// Mirrors the entire area around the XY plane
+ void MirrorXY(void);
+
+ /// Mirrors the entire area around the XZ plane
+ void MirrorXZ(void);
+
+ /// Mirrors the entire area around the YZ plane
+ void MirrorYZ(void);
+
+ /// Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta
+ void RotateCCWNoMeta(void);
+
+ /// Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta
+ void RotateCWNoMeta(void);
+
+ /// Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta
+ void MirrorXYNoMeta(void);
+
+ /// Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta
+ void MirrorXZNoMeta(void);
+
+ /// Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta
+ void MirrorYZNoMeta(void);
+
+ // Setters:
+ void SetRelBlockType (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType);
+ void SetBlockType (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType);
+ void SetRelBlockMeta (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta);
+ void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockMeta);
+ void SetRelBlockLight (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockLight);
+ void SetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockLight);
+ void SetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockSkyLight);
+ void SetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockSkyLight);
+
+ // Getters:
+ BLOCKTYPE GetRelBlockType (int a_RelX, int a_RelY, int a_RelZ) const;
+ BLOCKTYPE GetBlockType (int a_BlockX, int a_BlockY, int a_BlockZ) const;
+ NIBBLETYPE GetRelBlockMeta (int a_RelX, int a_RelY, int a_RelZ) const;
+ NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ) const;
+ NIBBLETYPE GetRelBlockLight (int a_RelX, int a_RelY, int a_RelZ) const;
+ NIBBLETYPE GetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ) const;
+ NIBBLETYPE GetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ) const;
+ NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ) const;
+
+ void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ void GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
+ void GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
+
+ int GetSizeX(void) const { return m_SizeX; }
+ int GetSizeY(void) const { return m_SizeY; }
+ int GetSizeZ(void) const { return m_SizeZ; }
+
+ int GetOriginX(void) const { return m_OriginX; }
+ int GetOriginY(void) const { return m_OriginY; }
+ int GetOriginZ(void) const { return m_OriginZ; }
+
+ /// Returns the datatypes that are stored in the object (bitmask of baXXX values)
+ int GetDataTypes(void) const;
+
+ bool HasBlockTypes (void) const { return (m_BlockTypes != NULL); }
+ bool HasBlockMetas (void) const { return (m_BlockMetas != NULL); }
+ bool HasBlockLights (void) const { return (m_BlockLight != NULL); }
+ bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != NULL); }
+
+ // tolua_end
+
+ // Clients can use these for faster access to all blocktypes. Be careful though!
+ /// Returns the internal pointer to the block types
+ BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; }
+ 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_SizeX * m_SizeY * m_SizeZ; }
+ int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const;
+
+protected:
+ friend class cChunkDesc;
+
+ class cChunkReader :
+ public cChunkDataCallback
+ {
+ public:
+ cChunkReader(cBlockArea & a_Area);
+
+ protected:
+ cBlockArea & m_Area;
+ int m_OriginX;
+ int m_OriginY;
+ int m_OriginZ;
+ int m_CurrentChunkX;
+ int m_CurrentChunkZ;
+
+ 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;
+ } ;
+
+ typedef NIBBLETYPE * NIBBLEARRAY;
+
+
+ int m_OriginX;
+ int m_OriginY;
+ int m_OriginZ;
+ int m_SizeX;
+ int m_SizeY;
+ int m_SizeZ;
+
+ BLOCKTYPE * m_BlockTypes;
+ NIBBLETYPE * m_BlockMetas; // Each meta is stored as a separate byte for faster access
+ NIBBLETYPE * m_BlockLight; // Each light value is stored as a separate byte for faster access
+ NIBBLETYPE * m_BlockSkyLight; // Each light value is stored as a separate byte for faster access
+
+ /// Clears the data stored and prepares a fresh new block area with the specified dimensions
+ bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes);
+
+ // Basic Setters:
+ void SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array);
+ void SetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array);
+
+ // Basic Getters:
+ NIBBLETYPE GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const;
+ NIBBLETYPE GetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE * a_Array) const;
+
+ // Crop helpers:
+ void CropBlockTypes(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
+ void CropNibbles (NIBBLEARRAY & a_Array, int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
+
+ // Expand helpers:
+ void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
+ void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
+
+ /// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful.
+ bool LoadFromSchematicNBT(cParsedNBT & a_NBT);
+
+ /// Sets the specified datatypes at the specified location.
+ void RelSetData(
+ int a_RelX, int a_RelY, int a_RelZ,
+ int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
+ );
+ // tolua_begin
+} ;
+// tolua_end
+
+
+
+
diff --git a/source/BlockEntities/BlockEntityWithItems.h b/source/BlockEntities/BlockEntityWithItems.h
index 587b10461..0846ae17e 100644
--- a/source/BlockEntities/BlockEntityWithItems.h
+++ b/source/BlockEntities/BlockEntityWithItems.h
@@ -1,86 +1,86 @@
-
-// BlockEntityWithItems.h
-
-// Declares the cBlockEntityWithItems class representing a common ancestor for all block entities that have an ItemGrid
-
-
-
-
-
-#pragma once
-
-#include "BlockEntity.h"
-#include "../ItemGrid.h"
-
-
-
-
-
-// tolua_begin
-class cBlockEntityWithItems :
- public cBlockEntity
- // tolua_end
- // tolua doesn't seem to support multiple inheritance?
- , public cItemGrid::cListener
- // tolua_begin
-{
- typedef cBlockEntity super;
-
-public:
- // tolua_end
-
- cBlockEntityWithItems(
- BLOCKTYPE a_BlockType, // Type of the block that the entity represents
- int a_BlockX, int a_BlockY, int a_BlockZ, // Position of the block entity
- int a_ItemGridWidth, int a_ItemGridHeight, // Dimensions of the ItemGrid
- cWorld * a_World // Optional world to assign to the entity
- ) :
- super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World),
- m_Contents(a_ItemGridWidth, a_ItemGridHeight)
- {
- m_Contents.AddListener(*this);
- }
-
- virtual void Destroy(void) override
- {
- // Drop the contents as pickups:
- ASSERT(m_World != NULL);
- cItems Pickups;
- m_Contents.CopyToItems(Pickups);
- m_Contents.Clear();
- m_World->SpawnItemPickups(Pickups, m_PosX, m_PosY, m_PosZ);
- }
-
- // tolua_begin
-
- const cItem & GetSlot(int a_SlotNum) const { return m_Contents.GetSlot(a_SlotNum); }
- const cItem & GetSlot(int a_X, int a_Y) const { return m_Contents.GetSlot(a_X, a_Y); }
-
- void SetSlot(int a_SlotNum, const cItem & a_Item) { m_Contents.SetSlot(a_SlotNum, a_Item); }
- void SetSlot(int a_X, int a_Y, const cItem & a_Item) { m_Contents.SetSlot(a_X, a_Y, a_Item); }
-
- /// Returns the ItemGrid used for storing the contents
- cItemGrid & GetContents(void) { return m_Contents; }
-
- // tolua_end
-
- /// Const version of the GetContents() function for C++ type-safety
- const cItemGrid & GetContents(void) const { return m_Contents; }
-
-protected:
- cItemGrid m_Contents;
-
- // cItemGrid::cListener overrides:
- virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum)
- {
- ASSERT(a_Grid == &m_Contents);
- if (m_World != NULL)
- {
- m_World->MarkChunkDirty(GetChunkX(), GetChunkZ());
- }
- }
-} ; // tolua_export
-
-
-
-
+
+// BlockEntityWithItems.h
+
+// Declares the cBlockEntityWithItems class representing a common ancestor for all block entities that have an ItemGrid
+
+
+
+
+
+#pragma once
+
+#include "BlockEntity.h"
+#include "../ItemGrid.h"
+
+
+
+
+
+// tolua_begin
+class cBlockEntityWithItems :
+ public cBlockEntity
+ // tolua_end
+ // tolua doesn't seem to support multiple inheritance?
+ , public cItemGrid::cListener
+ // tolua_begin
+{
+ typedef cBlockEntity super;
+
+public:
+ // tolua_end
+
+ cBlockEntityWithItems(
+ BLOCKTYPE a_BlockType, // Type of the block that the entity represents
+ int a_BlockX, int a_BlockY, int a_BlockZ, // Position of the block entity
+ int a_ItemGridWidth, int a_ItemGridHeight, // Dimensions of the ItemGrid
+ cWorld * a_World // Optional world to assign to the entity
+ ) :
+ super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World),
+ m_Contents(a_ItemGridWidth, a_ItemGridHeight)
+ {
+ m_Contents.AddListener(*this);
+ }
+
+ virtual void Destroy(void) override
+ {
+ // Drop the contents as pickups:
+ ASSERT(m_World != NULL);
+ cItems Pickups;
+ m_Contents.CopyToItems(Pickups);
+ m_Contents.Clear();
+ m_World->SpawnItemPickups(Pickups, m_PosX, m_PosY, m_PosZ);
+ }
+
+ // tolua_begin
+
+ const cItem & GetSlot(int a_SlotNum) const { return m_Contents.GetSlot(a_SlotNum); }
+ const cItem & GetSlot(int a_X, int a_Y) const { return m_Contents.GetSlot(a_X, a_Y); }
+
+ void SetSlot(int a_SlotNum, const cItem & a_Item) { m_Contents.SetSlot(a_SlotNum, a_Item); }
+ void SetSlot(int a_X, int a_Y, const cItem & a_Item) { m_Contents.SetSlot(a_X, a_Y, a_Item); }
+
+ /// Returns the ItemGrid used for storing the contents
+ cItemGrid & GetContents(void) { return m_Contents; }
+
+ // tolua_end
+
+ /// Const version of the GetContents() function for C++ type-safety
+ const cItemGrid & GetContents(void) const { return m_Contents; }
+
+protected:
+ cItemGrid m_Contents;
+
+ // cItemGrid::cListener overrides:
+ virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum)
+ {
+ ASSERT(a_Grid == &m_Contents);
+ if (m_World != NULL)
+ {
+ m_World->MarkChunkDirty(GetChunkX(), GetChunkZ());
+ }
+ }
+} ; // tolua_export
+
+
+
+
diff --git a/source/BlockEntities/DispenserEntity.cpp b/source/BlockEntities/DispenserEntity.cpp
index ab4c8e519..cde67bb41 100644
--- a/source/BlockEntities/DispenserEntity.cpp
+++ b/source/BlockEntities/DispenserEntity.cpp
@@ -1,225 +1,225 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "DispenserEntity.h"
-#include "../Player.h"
-#include "../Simulator/FluidSimulator.h"
-#include "../Chunk.h"
-
-
-
-
-
-cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
- super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, NULL)
-{
- SetBlockEntity(this); // cBlockEntityWindowOwner
-}
-
-
-
-
-
-cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
- super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, a_World)
-{
- SetBlockEntity(this); // cBlockEntityWindowOwner
-}
-
-
-
-
-
-void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
-{
- int DispX = m_RelX;
- int DispY = m_PosY;
- int DispZ = m_RelZ;
- NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
- AddDropSpenserDir(DispX, DispY, DispZ, Meta);
- cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ);
- if (DispChunk == NULL)
- {
- // Would dispense into / interact with a non-loaded chunk, ignore the tick
- return;
- }
- BLOCKTYPE DispBlock = DispChunk->GetBlock(DispX, DispY, DispZ);
-
- // Dispense the item:
- switch (m_Contents.GetSlot(a_SlotNum).m_ItemType)
- {
- case E_ITEM_BUCKET:
- {
- LOGD("Dispensing empty bucket in slot %d; DispBlock is \"%s\" (%d).", a_SlotNum, ItemTypeToString(DispBlock).c_str(), DispBlock);
- switch (DispBlock)
- {
- case E_BLOCK_STATIONARY_WATER:
- case E_BLOCK_WATER:
- {
- if (ScoopUpLiquid(a_SlotNum, E_ITEM_WATER_BUCKET))
- {
- DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_AIR, 0);
- }
- break;
- }
- case E_BLOCK_STATIONARY_LAVA:
- case E_BLOCK_LAVA:
- {
- if (ScoopUpLiquid(a_SlotNum, E_ITEM_LAVA_BUCKET))
- {
- DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_AIR, 0);
- }
- break;
- }
- default:
- {
- DropFromSlot(a_Chunk, a_SlotNum);
- break;
- }
- }
- 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);
- if (EmptyLiquidBucket(DispBlock, a_SlotNum))
- {
- DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_WATER, 0);
- }
- else
- {
- DropFromSlot(a_Chunk, 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);
- if (EmptyLiquidBucket(DispBlock, a_SlotNum))
- {
- DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_LAVA, 0);
- }
- else
- {
- DropFromSlot(a_Chunk, a_SlotNum);
- }
- break;
- }
-
- case E_ITEM_SPAWN_EGG:
- {
- double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
- double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
- if (m_World->SpawnMob(MobX, DispY, MobZ, m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0)
- {
- m_Contents.ChangeSlotCount(a_SlotNum, -1);
- }
- break;
- }
-
- case E_BLOCK_TNT:
- {
- // Spawn a primed TNT entity, if space allows:
- if (DispChunk->GetBlock(DispX, DispY, DispZ) == E_BLOCK_AIR)
- {
- double TNTX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
- double TNTZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
- m_World->SpawnPrimedTNT(TNTX, DispY + 0.5, TNTZ, 4, 0); // 4 seconds fuse, no initial velocity
- m_Contents.ChangeSlotCount(a_SlotNum, -1);
- }
- break;
- }
-
- case E_ITEM_FLINT_AND_STEEL:
- {
- // Spawn fire if the block in front is air.
- if (DispChunk->GetBlock(DispX, DispY, DispZ) == E_BLOCK_AIR)
- {
- DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_FIRE, 0);
- m_Contents.SetSlot(a_SlotNum, m_Contents.GetSlot(a_SlotNum).m_ItemType, m_Contents.GetSlot(a_SlotNum).m_ItemCount, m_Contents.GetSlot(a_SlotNum).m_ItemDamage + 1);
- // If the durability has run out destroy the item.
- if (m_Contents.GetSlot(a_SlotNum).m_ItemDamage > 64)
- {
- m_Contents.ChangeSlotCount(a_SlotNum, -1);
- }
- }
- break;
- }
-
- default:
- {
- DropFromSlot(a_Chunk, a_SlotNum);
- break;
- }
- } // switch (ItemType)
-}
-
-
-
-
-
-
-bool cDispenserEntity::ScoopUpLiquid(int a_SlotNum, short a_BucketItemType)
-{
- cItem LiquidBucket(a_BucketItemType, 1);
- if (m_Contents.GetSlot(a_SlotNum).m_ItemCount == 1)
- {
- // Special case: replacing one empty bucket with one full bucket
- 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;
-}
-
-
-
-
-
-bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum)
-{
- if (
- (a_BlockInFront != E_BLOCK_AIR) &&
- !IsBlockLiquid(a_BlockInFront) &&
- !cFluidSimulator::CanWashAway(a_BlockInFront)
- )
- {
- // Not a suitable block in front
- return false;
- }
-
- cItem EmptyBucket(E_ITEM_BUCKET, 1);
- if (m_Contents.GetSlot(a_SlotNum).m_ItemCount == 1)
- {
- // Change the single full bucket present into a single empty bucket
- 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);
- return true;
-}
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "DispenserEntity.h"
+#include "../Player.h"
+#include "../Simulator/FluidSimulator.h"
+#include "../Chunk.h"
+
+
+
+
+
+cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
+ super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, NULL)
+{
+ SetBlockEntity(this); // cBlockEntityWindowOwner
+}
+
+
+
+
+
+cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
+ super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, a_World)
+{
+ SetBlockEntity(this); // cBlockEntityWindowOwner
+}
+
+
+
+
+
+void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
+{
+ int DispX = m_RelX;
+ int DispY = m_PosY;
+ int DispZ = m_RelZ;
+ NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
+ AddDropSpenserDir(DispX, DispY, DispZ, Meta);
+ cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ);
+ if (DispChunk == NULL)
+ {
+ // Would dispense into / interact with a non-loaded chunk, ignore the tick
+ return;
+ }
+ BLOCKTYPE DispBlock = DispChunk->GetBlock(DispX, DispY, DispZ);
+
+ // Dispense the item:
+ switch (m_Contents.GetSlot(a_SlotNum).m_ItemType)
+ {
+ case E_ITEM_BUCKET:
+ {
+ LOGD("Dispensing empty bucket in slot %d; DispBlock is \"%s\" (%d).", a_SlotNum, ItemTypeToString(DispBlock).c_str(), DispBlock);
+ switch (DispBlock)
+ {
+ case E_BLOCK_STATIONARY_WATER:
+ case E_BLOCK_WATER:
+ {
+ if (ScoopUpLiquid(a_SlotNum, E_ITEM_WATER_BUCKET))
+ {
+ DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_AIR, 0);
+ }
+ break;
+ }
+ case E_BLOCK_STATIONARY_LAVA:
+ case E_BLOCK_LAVA:
+ {
+ if (ScoopUpLiquid(a_SlotNum, E_ITEM_LAVA_BUCKET))
+ {
+ DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_AIR, 0);
+ }
+ break;
+ }
+ default:
+ {
+ DropFromSlot(a_Chunk, a_SlotNum);
+ break;
+ }
+ }
+ 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);
+ if (EmptyLiquidBucket(DispBlock, a_SlotNum))
+ {
+ DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_WATER, 0);
+ }
+ else
+ {
+ DropFromSlot(a_Chunk, 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);
+ if (EmptyLiquidBucket(DispBlock, a_SlotNum))
+ {
+ DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_LAVA, 0);
+ }
+ else
+ {
+ DropFromSlot(a_Chunk, a_SlotNum);
+ }
+ break;
+ }
+
+ case E_ITEM_SPAWN_EGG:
+ {
+ double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
+ double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
+ if (m_World->SpawnMob(MobX, DispY, MobZ, m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0)
+ {
+ m_Contents.ChangeSlotCount(a_SlotNum, -1);
+ }
+ break;
+ }
+
+ case E_BLOCK_TNT:
+ {
+ // Spawn a primed TNT entity, if space allows:
+ if (DispChunk->GetBlock(DispX, DispY, DispZ) == E_BLOCK_AIR)
+ {
+ double TNTX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
+ double TNTZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
+ m_World->SpawnPrimedTNT(TNTX, DispY + 0.5, TNTZ, 4, 0); // 4 seconds fuse, no initial velocity
+ m_Contents.ChangeSlotCount(a_SlotNum, -1);
+ }
+ break;
+ }
+
+ case E_ITEM_FLINT_AND_STEEL:
+ {
+ // Spawn fire if the block in front is air.
+ if (DispChunk->GetBlock(DispX, DispY, DispZ) == E_BLOCK_AIR)
+ {
+ DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_FIRE, 0);
+ m_Contents.SetSlot(a_SlotNum, m_Contents.GetSlot(a_SlotNum).m_ItemType, m_Contents.GetSlot(a_SlotNum).m_ItemCount, m_Contents.GetSlot(a_SlotNum).m_ItemDamage + 1);
+ // If the durability has run out destroy the item.
+ if (m_Contents.GetSlot(a_SlotNum).m_ItemDamage > 64)
+ {
+ m_Contents.ChangeSlotCount(a_SlotNum, -1);
+ }
+ }
+ break;
+ }
+
+ default:
+ {
+ DropFromSlot(a_Chunk, a_SlotNum);
+ break;
+ }
+ } // switch (ItemType)
+}
+
+
+
+
+
+
+bool cDispenserEntity::ScoopUpLiquid(int a_SlotNum, short a_BucketItemType)
+{
+ cItem LiquidBucket(a_BucketItemType, 1);
+ if (m_Contents.GetSlot(a_SlotNum).m_ItemCount == 1)
+ {
+ // Special case: replacing one empty bucket with one full bucket
+ 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;
+}
+
+
+
+
+
+bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum)
+{
+ if (
+ (a_BlockInFront != E_BLOCK_AIR) &&
+ !IsBlockLiquid(a_BlockInFront) &&
+ !cFluidSimulator::CanWashAway(a_BlockInFront)
+ )
+ {
+ // Not a suitable block in front
+ return false;
+ }
+
+ cItem EmptyBucket(E_ITEM_BUCKET, 1);
+ if (m_Contents.GetSlot(a_SlotNum).m_ItemCount == 1)
+ {
+ // Change the single full bucket present into a single empty bucket
+ 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);
+ return true;
+}
+
+
+
+
diff --git a/source/BlockEntities/DispenserEntity.h b/source/BlockEntities/DispenserEntity.h
index 09270e7f8..5e3327f18 100644
--- a/source/BlockEntities/DispenserEntity.h
+++ b/source/BlockEntities/DispenserEntity.h
@@ -1,41 +1,41 @@
-
-#pragma once
-
-#include "DropSpenserEntity.h"
-
-
-
-
-
-// tolua_begin
-class cDispenserEntity :
- public cDropSpenserEntity
-{
- typedef cDropSpenserEntity super;
-
-public:
-
- /// Constructor used while generating a chunk; sets m_World to NULL
- cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
-
- // tolua_end
-
- /// 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"; }
-
-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
- 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
- bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum);
-} ; // tolua_export
-
-
-
-
+
+#pragma once
+
+#include "DropSpenserEntity.h"
+
+
+
+
+
+// tolua_begin
+class cDispenserEntity :
+ public cDropSpenserEntity
+{
+ typedef cDropSpenserEntity super;
+
+public:
+
+ /// Constructor used while generating a chunk; sets m_World to NULL
+ cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ // tolua_end
+
+ /// 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"; }
+
+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
+ 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
+ bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum);
+} ; // tolua_export
+
+
+
+
diff --git a/source/BlockEntities/DropSpenserEntity.cpp b/source/BlockEntities/DropSpenserEntity.cpp
index a9860d812..eb8257a21 100644
--- a/source/BlockEntities/DropSpenserEntity.cpp
+++ b/source/BlockEntities/DropSpenserEntity.cpp
@@ -1,245 +1,245 @@
-
-// DropSpenserEntity.cpp
-
-// Declares the cDropSpenserEntity class representing a common ancestor to the cDispenserEntity and cDropperEntity
-// The dropper and dispenser only needs to override the DropSpenseFromSlot() function to provide the specific item behavior
-
-#include "Globals.h"
-#include "DropSpenserEntity.h"
-#include "../Player.h"
-#include "../Chunk.h"
-
-
-
-
-
-cDropSpenserEntity::cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
- super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
- m_ShouldDropSpense(false),
- m_IsPowered(false)
-{
- SetBlockEntity(this); // cBlockEntityWindowOwner
-}
-
-
-
-
-
-cDropSpenserEntity::~cDropSpenserEntity()
-{
- // Tell window its owner is destroyed
- cWindow * Window = GetWindow();
- if (Window != NULL)
- {
- Window->OwnerDestroyed();
- }
-}
-
-
-
-
-
-void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction)
-{
- switch (a_Direction)
- {
- case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return;
- case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return;
- case E_META_DROPSPENSER_FACING_ZM: a_BlockZ--; return;
- case E_META_DROPSPENSER_FACING_ZP: a_BlockZ++; return;
- case E_META_DROPSPENSER_FACING_XM: a_BlockX--; return;
- case E_META_DROPSPENSER_FACING_XP: a_BlockX++; return;
- }
- LOGWARNING("%s: Unhandled direction: %d", __FUNCTION__, a_Direction);
- return;
-}
-
-
-
-
-
-void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
-{
- // Pick one of the occupied slots:
- int OccupiedSlots[9];
- int SlotsCnt = 0;
- for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--)
- {
- if (!m_Contents.GetSlot(i).IsEmpty())
- {
- OccupiedSlots[SlotsCnt] = i;
- SlotsCnt++;
- }
- } // for i - m_Contents[]
-
- if (SlotsCnt == 0)
- {
- // Nothing in the dropspenser, play the click sound
- m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.2f);
- return;
- }
-
- int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1);
-
- // DropSpense the item, using the specialized behavior in the subclasses:
- DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]);
-
- // Broadcast a smoke and click effects:
- NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
- int SmokeDir = 0;
- switch (Meta)
- {
- case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break;
- case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break;
- case E_META_DROPSPENSER_FACING_ZM: SmokeDir = 1; break;
- case E_META_DROPSPENSER_FACING_ZP: SmokeDir = 7; break;
- }
- m_World->BroadcastSoundParticleEffect(2000, m_PosX * 8, m_PosY * 8, m_PosZ * 8, SmokeDir);
- m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
-
- // Update the UI window, if open:
- cWindow * Window = GetWindow();
- if (Window != NULL)
- {
- Window->BroadcastWholeWindow();
- }
-}
-
-
-
-
-
-void cDropSpenserEntity::Activate(void)
-{
- m_ShouldDropSpense = true;
-}
-
-
-
-
-
-void cDropSpenserEntity::SetRedstonePower(bool a_IsPowered)
-{
- if (a_IsPowered && !m_IsPowered)
- {
- Activate();
- }
- m_IsPowered = a_IsPowered;
-}
-
-
-
-
-
-bool cDropSpenserEntity::Tick(float a_Dt, cChunk & a_Chunk)
-{
- if (!m_ShouldDropSpense)
- {
- return false;
- }
-
- m_ShouldDropSpense = false;
- DropSpense(a_Chunk);
- return true;
-}
-
-
-
-
-
-bool cDropSpenserEntity::LoadFromJson(const Json::Value & a_Value)
-{
- 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)
- {
- cItem Contents;
- Contents.FromJson(*itr);
- m_Contents.SetSlot(SlotIdx, Contents);
- SlotIdx++;
- if (SlotIdx >= m_Contents.GetNumSlots())
- {
- return true;
- }
- }
-
- return true;
-}
-
-
-
-
-
-void cDropSpenserEntity::SaveToJson(Json::Value & a_Value)
-{
- a_Value["x"] = m_PosX;
- a_Value["y"] = m_PosY;
- a_Value["z"] = m_PosZ;
-
- Json::Value AllSlots;
- int NumSlots = m_Contents.GetNumSlots();
- for (int i = 0; i < NumSlots; i++)
- {
- Json::Value Slot;
- m_Contents.GetSlot(i).GetJson(Slot);
- AllSlots.append(Slot);
- }
- a_Value["Slots"] = AllSlots;
-}
-
-
-
-
-
-void cDropSpenserEntity::SendTo(cClientHandle & a_Client)
-{
- // Nothing needs to be sent
- UNUSED(a_Client);
-}
-
-
-
-
-
-void cDropSpenserEntity::UsedBy(cPlayer * a_Player)
-{
- cWindow * Window = GetWindow();
- if (Window == NULL)
- {
- OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this));
- Window = GetWindow();
- }
-
- if (Window != NULL)
- {
- if (a_Player->GetWindow() != Window)
- {
- a_Player->OpenWindow(Window);
- }
- }
-}
-
-
-
-
-
-void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
-{
- int DispX = m_PosX;
- int DispY = m_PosY;
- int DispZ = m_PosZ;
- NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
- AddDropSpenserDir(DispX, DispY, DispZ, Meta);
-
- cItems Pickups;
- Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum));
- m_World->SpawnItemPickups(Pickups, DispX, DispY, DispZ);
-}
-
-
-
-
+
+// DropSpenserEntity.cpp
+
+// Declares the cDropSpenserEntity class representing a common ancestor to the cDispenserEntity and cDropperEntity
+// The dropper and dispenser only needs to override the DropSpenseFromSlot() function to provide the specific item behavior
+
+#include "Globals.h"
+#include "DropSpenserEntity.h"
+#include "../Player.h"
+#include "../Chunk.h"
+
+
+
+
+
+cDropSpenserEntity::cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
+ super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
+ m_ShouldDropSpense(false),
+ m_IsPowered(false)
+{
+ SetBlockEntity(this); // cBlockEntityWindowOwner
+}
+
+
+
+
+
+cDropSpenserEntity::~cDropSpenserEntity()
+{
+ // Tell window its owner is destroyed
+ cWindow * Window = GetWindow();
+ if (Window != NULL)
+ {
+ Window->OwnerDestroyed();
+ }
+}
+
+
+
+
+
+void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction)
+{
+ switch (a_Direction)
+ {
+ case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return;
+ case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return;
+ case E_META_DROPSPENSER_FACING_ZM: a_BlockZ--; return;
+ case E_META_DROPSPENSER_FACING_ZP: a_BlockZ++; return;
+ case E_META_DROPSPENSER_FACING_XM: a_BlockX--; return;
+ case E_META_DROPSPENSER_FACING_XP: a_BlockX++; return;
+ }
+ LOGWARNING("%s: Unhandled direction: %d", __FUNCTION__, a_Direction);
+ return;
+}
+
+
+
+
+
+void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
+{
+ // Pick one of the occupied slots:
+ int OccupiedSlots[9];
+ int SlotsCnt = 0;
+ for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--)
+ {
+ if (!m_Contents.GetSlot(i).IsEmpty())
+ {
+ OccupiedSlots[SlotsCnt] = i;
+ SlotsCnt++;
+ }
+ } // for i - m_Contents[]
+
+ if (SlotsCnt == 0)
+ {
+ // Nothing in the dropspenser, play the click sound
+ m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.2f);
+ return;
+ }
+
+ int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1);
+
+ // DropSpense the item, using the specialized behavior in the subclasses:
+ DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]);
+
+ // Broadcast a smoke and click effects:
+ NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
+ int SmokeDir = 0;
+ switch (Meta)
+ {
+ case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break;
+ case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break;
+ case E_META_DROPSPENSER_FACING_ZM: SmokeDir = 1; break;
+ case E_META_DROPSPENSER_FACING_ZP: SmokeDir = 7; break;
+ }
+ m_World->BroadcastSoundParticleEffect(2000, m_PosX * 8, m_PosY * 8, m_PosZ * 8, SmokeDir);
+ m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
+
+ // Update the UI window, if open:
+ cWindow * Window = GetWindow();
+ if (Window != NULL)
+ {
+ Window->BroadcastWholeWindow();
+ }
+}
+
+
+
+
+
+void cDropSpenserEntity::Activate(void)
+{
+ m_ShouldDropSpense = true;
+}
+
+
+
+
+
+void cDropSpenserEntity::SetRedstonePower(bool a_IsPowered)
+{
+ if (a_IsPowered && !m_IsPowered)
+ {
+ Activate();
+ }
+ m_IsPowered = a_IsPowered;
+}
+
+
+
+
+
+bool cDropSpenserEntity::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ if (!m_ShouldDropSpense)
+ {
+ return false;
+ }
+
+ m_ShouldDropSpense = false;
+ DropSpense(a_Chunk);
+ return true;
+}
+
+
+
+
+
+bool cDropSpenserEntity::LoadFromJson(const Json::Value & a_Value)
+{
+ 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)
+ {
+ cItem Contents;
+ Contents.FromJson(*itr);
+ m_Contents.SetSlot(SlotIdx, Contents);
+ SlotIdx++;
+ if (SlotIdx >= m_Contents.GetNumSlots())
+ {
+ return true;
+ }
+ }
+
+ return true;
+}
+
+
+
+
+
+void cDropSpenserEntity::SaveToJson(Json::Value & a_Value)
+{
+ a_Value["x"] = m_PosX;
+ a_Value["y"] = m_PosY;
+ a_Value["z"] = m_PosZ;
+
+ Json::Value AllSlots;
+ int NumSlots = m_Contents.GetNumSlots();
+ for (int i = 0; i < NumSlots; i++)
+ {
+ Json::Value Slot;
+ m_Contents.GetSlot(i).GetJson(Slot);
+ AllSlots.append(Slot);
+ }
+ a_Value["Slots"] = AllSlots;
+}
+
+
+
+
+
+void cDropSpenserEntity::SendTo(cClientHandle & a_Client)
+{
+ // Nothing needs to be sent
+ UNUSED(a_Client);
+}
+
+
+
+
+
+void cDropSpenserEntity::UsedBy(cPlayer * a_Player)
+{
+ cWindow * Window = GetWindow();
+ if (Window == NULL)
+ {
+ OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this));
+ Window = GetWindow();
+ }
+
+ if (Window != NULL)
+ {
+ if (a_Player->GetWindow() != Window)
+ {
+ a_Player->OpenWindow(Window);
+ }
+ }
+}
+
+
+
+
+
+void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
+{
+ int DispX = m_PosX;
+ int DispY = m_PosY;
+ int DispZ = m_PosZ;
+ NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
+ AddDropSpenserDir(DispX, DispY, DispZ, Meta);
+
+ cItems Pickups;
+ Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum));
+ m_World->SpawnItemPickups(Pickups, DispX, DispY, DispZ);
+}
+
+
+
+
diff --git a/source/BlockEntities/DropSpenserEntity.h b/source/BlockEntities/DropSpenserEntity.h
index ca9f7dfa3..f2f1eba36 100644
--- a/source/BlockEntities/DropSpenserEntity.h
+++ b/source/BlockEntities/DropSpenserEntity.h
@@ -1,89 +1,89 @@
-
-// DropSpenser.h
-
-// Declares the cDropSpenser class representing a common ancestor to the cDispenserEntity and cDropperEntity
-// The dropper and dispenser only needs to override the DropSpenseFromSlot() function to provide the specific item behavior
-
-
-
-
-
-#pragma once
-
-#include "BlockEntityWithItems.h"
-#include "../UI/WindowOwner.h"
-
-
-
-
-
-namespace Json
-{
- class Value;
-}
-
-class cClientHandle;
-class cServer;
-
-
-
-
-
-// tolua_begin
-class cDropSpenserEntity :
- public cBlockEntityWithItems,
- public cBlockEntityWindowOwner
-{
- typedef cBlockEntityWithItems super;
-
-public:
- enum {
- ContentsHeight = 3,
- ContentsWidth = 3,
- } ;
-
- // tolua_end
-
- cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
- virtual ~cDropSpenserEntity();
-
- static const char * GetClassStatic(void) { return "cDropSpenserEntity"; }
-
- bool LoadFromJson(const Json::Value & a_Value);
-
- // cBlockEntity overrides:
- 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;
- virtual void UsedBy(cPlayer * a_Player) override;
-
- // tolua_begin
-
- /// Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups should materialize)
- void AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction);
-
- /// Sets the dropspenser to dropspense an item in the next tick
- void Activate(void);
-
- /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
- void SetRedstonePower(bool a_IsPowered);
-
- // tolua_end
-
-protected:
- bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick
- bool m_IsPowered; ///< Set to true when the dropspenser receives redstone power.
-
- /// Does the actual work on dropspensing an item. Chooses the slot, calls DropSpenseFromSlot() and handles smoke / sound effects
- void DropSpense(cChunk & a_Chunk);
-
- /// Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...)
- virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) = 0;
-
- /// Helper function, drops one item from the specified slot (like a dropper)
- void DropFromSlot(cChunk & a_Chunk, int a_SlotNum);
-} ; // tolua_export
-
-
-
-
+
+// DropSpenser.h
+
+// Declares the cDropSpenser class representing a common ancestor to the cDispenserEntity and cDropperEntity
+// The dropper and dispenser only needs to override the DropSpenseFromSlot() function to provide the specific item behavior
+
+
+
+
+
+#pragma once
+
+#include "BlockEntityWithItems.h"
+#include "../UI/WindowOwner.h"
+
+
+
+
+
+namespace Json
+{
+ class Value;
+}
+
+class cClientHandle;
+class cServer;
+
+
+
+
+
+// tolua_begin
+class cDropSpenserEntity :
+ public cBlockEntityWithItems,
+ public cBlockEntityWindowOwner
+{
+ typedef cBlockEntityWithItems super;
+
+public:
+ enum {
+ ContentsHeight = 3,
+ ContentsWidth = 3,
+ } ;
+
+ // tolua_end
+
+ cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+ virtual ~cDropSpenserEntity();
+
+ static const char * GetClassStatic(void) { return "cDropSpenserEntity"; }
+
+ bool LoadFromJson(const Json::Value & a_Value);
+
+ // cBlockEntity overrides:
+ 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;
+ virtual void UsedBy(cPlayer * a_Player) override;
+
+ // tolua_begin
+
+ /// Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups should materialize)
+ void AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction);
+
+ /// Sets the dropspenser to dropspense an item in the next tick
+ void Activate(void);
+
+ /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
+ void SetRedstonePower(bool a_IsPowered);
+
+ // tolua_end
+
+protected:
+ bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick
+ bool m_IsPowered; ///< Set to true when the dropspenser receives redstone power.
+
+ /// Does the actual work on dropspensing an item. Chooses the slot, calls DropSpenseFromSlot() and handles smoke / sound effects
+ void DropSpense(cChunk & a_Chunk);
+
+ /// Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...)
+ virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) = 0;
+
+ /// Helper function, drops one item from the specified slot (like a dropper)
+ void DropFromSlot(cChunk & a_Chunk, int a_SlotNum);
+} ; // tolua_export
+
+
+
+
diff --git a/source/BlockEntities/DropperEntity.cpp b/source/BlockEntities/DropperEntity.cpp
index ebb52c8a1..44d679e02 100644
--- a/source/BlockEntities/DropperEntity.cpp
+++ b/source/BlockEntities/DropperEntity.cpp
@@ -1,42 +1,42 @@
-
-// DropperEntity.cpp
-
-// Implements the cRtopperEntity class representing a Dropper block entity
-
-#include "Globals.h"
-#include "DropperEntity.h"
-#include "../Player.h"
-#include "../Simulator/FluidSimulator.h"
-
-
-
-
-
-cDropperEntity::cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
- super(E_BLOCK_DROPPER, a_BlockX, a_BlockY, a_BlockZ, NULL)
-{
- SetBlockEntity(this); // cBlockEntityWindowOwner
-}
-
-
-
-
-
-cDropperEntity::cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
- super(E_BLOCK_DROPPER, a_BlockX, a_BlockY, a_BlockZ, a_World)
-{
- SetBlockEntity(this); // cBlockEntityWindowOwner
-}
-
-
-
-
-
-void cDropperEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
-{
- DropFromSlot(a_Chunk, a_SlotNum);
-}
-
-
-
-
+
+// DropperEntity.cpp
+
+// Implements the cRtopperEntity class representing a Dropper block entity
+
+#include "Globals.h"
+#include "DropperEntity.h"
+#include "../Player.h"
+#include "../Simulator/FluidSimulator.h"
+
+
+
+
+
+cDropperEntity::cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
+ super(E_BLOCK_DROPPER, a_BlockX, a_BlockY, a_BlockZ, NULL)
+{
+ SetBlockEntity(this); // cBlockEntityWindowOwner
+}
+
+
+
+
+
+cDropperEntity::cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
+ super(E_BLOCK_DROPPER, a_BlockX, a_BlockY, a_BlockZ, a_World)
+{
+ SetBlockEntity(this); // cBlockEntityWindowOwner
+}
+
+
+
+
+
+void cDropperEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
+{
+ DropFromSlot(a_Chunk, a_SlotNum);
+}
+
+
+
+
diff --git a/source/BlockEntities/DropperEntity.h b/source/BlockEntities/DropperEntity.h
index ed29bfe95..af74e7f7c 100644
--- a/source/BlockEntities/DropperEntity.h
+++ b/source/BlockEntities/DropperEntity.h
@@ -1,49 +1,49 @@
-
-// DropperEntity.h
-
-// Declares the cDropperEntity class representing a dropper block entity
-
-
-
-
-
-#pragma once
-
-#include "DropSpenserEntity.h"
-
-
-
-
-
-// tolua_begin
-class cDropperEntity :
- public cDropSpenserEntity
-{
- typedef cDropSpenserEntity super;
-
-public:
-
- /// Constructor used while generating a chunk; sets m_World to NULL
- cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
-
- // tolua_end
-
- /// Constructor used for normal operation
- cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
-
- static const char * GetClassStatic(void) { return "cDropperEntity"; }
-
-protected:
- // cDropSpenserEntity overrides:
- virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override;
-
- /** Takes an item from slot a_SlotNum and puts it into the container in front of the dropper.
- Called when there's a container directly in front of the dropper,
- so the dropper should store items there, rather than dropping.
- */
- void PutIntoContainer(cChunk & a_Chunk, int a_SlotNum, BLOCKTYPE a_ContainerBlock, int a_ContainerX, int a_ContainerY, int a_ContainerZ);
-} ; // tolua_export
-
-
-
-
+
+// DropperEntity.h
+
+// Declares the cDropperEntity class representing a dropper block entity
+
+
+
+
+
+#pragma once
+
+#include "DropSpenserEntity.h"
+
+
+
+
+
+// tolua_begin
+class cDropperEntity :
+ public cDropSpenserEntity
+{
+ typedef cDropSpenserEntity super;
+
+public:
+
+ /// Constructor used while generating a chunk; sets m_World to NULL
+ cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ // tolua_end
+
+ /// Constructor used for normal operation
+ cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+
+ static const char * GetClassStatic(void) { return "cDropperEntity"; }
+
+protected:
+ // cDropSpenserEntity overrides:
+ virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override;
+
+ /** Takes an item from slot a_SlotNum and puts it into the container in front of the dropper.
+ Called when there's a container directly in front of the dropper,
+ so the dropper should store items there, rather than dropping.
+ */
+ void PutIntoContainer(cChunk & a_Chunk, int a_SlotNum, BLOCKTYPE a_ContainerBlock, int a_ContainerX, int a_ContainerY, int a_ContainerZ);
+} ; // tolua_export
+
+
+
+
diff --git a/source/BlockEntities/HopperEntity.cpp b/source/BlockEntities/HopperEntity.cpp
index 3fadf727c..23e4b8096 100644
--- a/source/BlockEntities/HopperEntity.cpp
+++ b/source/BlockEntities/HopperEntity.cpp
@@ -1,523 +1,523 @@
-
-// HopperEntity.cpp
-
-// Implements the cHopperEntity representing a hopper block entity
-
-#include "Globals.h"
-#include "HopperEntity.h"
-#include "../Chunk.h"
-#include "../Player.h"
-#include "ChestEntity.h"
-#include "DropSpenserEntity.h"
-#include "FurnaceEntity.h"
-
-
-
-
-
-cHopperEntity::cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
- super(E_BLOCK_HOPPER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, NULL),
- m_LastMoveItemsInTick(0),
- m_LastMoveItemsOutTick(0)
-{
-}
-
-
-
-
-
-cHopperEntity::cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
- super(E_BLOCK_HOPPER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
- m_LastMoveItemsInTick(0),
- m_LastMoveItemsOutTick(0)
-{
-}
-
-
-
-
-
-/** Returns the block coords of the block receiving the output items, based on the meta
-Returns false if unattached
-*/
-bool cHopperEntity::GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, int & a_OutputY, int & a_OutputZ)
-{
- a_OutputX = m_PosX;
- a_OutputY = m_PosY;
- a_OutputZ = m_PosZ;
- switch (a_BlockMeta)
- {
- case E_META_HOPPER_FACING_XM: a_OutputX--; return true;
- case E_META_HOPPER_FACING_XP: a_OutputX++; return true;
- case E_META_HOPPER_FACING_YM: a_OutputY--; return true;
- case E_META_HOPPER_FACING_ZM: a_OutputZ--; return true;
- case E_META_HOPPER_FACING_ZP: a_OutputZ++; return true;
- default:
- {
- // Not attached
- return false;
- }
- }
-}
-
-
-
-
-
-bool cHopperEntity::Tick(float a_Dt, cChunk & a_Chunk)
-{
- Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
-
- bool res = false;
- res = MoveItemsIn (a_Chunk, CurrentTick) || res;
- res = MovePickupsIn(a_Chunk, CurrentTick) || res;
- res = MoveItemsOut (a_Chunk, CurrentTick) || res;
- return res;
-}
-
-
-
-
-
-void cHopperEntity::SaveToJson(Json::Value & a_Value)
-{
- // TODO
- LOGWARNING("%s: Not implemented yet", __FUNCTION__);
-}
-
-
-
-
-
-void cHopperEntity::SendTo(cClientHandle & a_Client)
-{
- // The hopper 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 hopper is rclked
-
- UNUSED(a_Client);
-}
-
-
-
-
-
-void cHopperEntity::UsedBy(cPlayer * a_Player)
-{
- // 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)
- {
- if (a_Player->GetWindow() != Window)
- {
- a_Player->OpenWindow(Window);
- }
- }
-
- // 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_PosY, m_PosZ, ChunkX, ChunkZ);
- m_World->MarkChunkDirty(ChunkX, ChunkZ);
-}
-
-
-
-
-
-/// Opens a new window UI for this hopper
-void cHopperEntity::OpenNewWindow(void)
-{
- OpenWindow(new cHopperWindow(m_PosX, m_PosY, m_PosZ, this));
-}
-
-
-
-
-
-/// Moves items from the container above it into this hopper. Returns true if the contents have changed.
-bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
-{
- if (m_PosY >= cChunkDef::Height)
- {
- // This hopper is at the top of the world, no more blocks above
- return false;
- }
-
- if (a_CurrentTick - m_LastMoveItemsInTick < TICKS_PER_TRANSFER)
- {
- // Too early after the previous transfer
- return false;
- }
-
- // Try moving an item in:
- bool res = false;
- switch (a_Chunk.GetBlock(m_RelX, m_PosY + 1, m_RelZ))
- {
- case E_BLOCK_CHEST: res = MoveItemsFromChest(a_Chunk); break;
- case E_BLOCK_FURNACE: res = MoveItemsFromFurnace(a_Chunk); break;
- case E_BLOCK_DISPENSER:
- case E_BLOCK_DROPPER: res = MoveItemsFromGrid(((cDropSpenserEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ))->GetContents()); break;
- case E_BLOCK_HOPPER: res = MoveItemsFromGrid(((cHopperEntity *) a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ))->GetContents()); break;
- case E_BLOCK_LIT_FURNACE: res = MoveItemsFromFurnace(a_Chunk); break;
- }
-
- // If the item has been moved, reset the last tick:
- if (res)
- {
- m_LastMoveItemsInTick = a_CurrentTick;
- }
-
- return res;
-}
-
-
-
-
-
-/// Moves pickups from above this hopper into it. Returns true if the contents have changed.
-bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
-{
- // TODO
- return false;
-}
-
-
-
-
-
-/// Moves items out from this hopper into the destination. Returns true if the contents have changed.
-bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
-{
- if (a_CurrentTick - m_LastMoveItemsOutTick < TICKS_PER_TRANSFER)
- {
- // Too early after the previous transfer
- return false;
- }
-
- int bx, by, bz;
- NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
- if (!GetOutputBlockPos(Meta, bx, by, bz))
- {
- // Not attached to another container
- return false;
- }
- if (by < 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);
- if (DestChunk == NULL)
- {
- // The destination chunk has been unloaded, don't tick
- return false;
- }
-
- // Call proper moving function, based on the blocktype present at the coords:
- bool res = false;
- switch (DestChunk->GetBlock(rx, by, rz))
- {
- case E_BLOCK_CHEST: res = MoveItemsToChest(*DestChunk, bx, by, bz); break;
- case E_BLOCK_FURNACE: res = MoveItemsToFurnace(*DestChunk, bx, by, bz, Meta); break;
- case E_BLOCK_DISPENSER:
- case E_BLOCK_DROPPER: res = MoveItemsToGrid(((cDropSpenserEntity *)DestChunk->GetBlockEntity(bx, by, bz))->GetContents()); break;
- case E_BLOCK_HOPPER: res = MoveItemsToGrid(((cHopperEntity *) DestChunk->GetBlockEntity(bx, by, bz))->GetContents()); break;
- case E_BLOCK_LIT_FURNACE: res = MoveItemsToFurnace(*DestChunk, bx, by, bz, Meta); break;
- }
-
- // If the item has been moved, reset the last tick:
- if (res)
- {
- m_LastMoveItemsOutTick = a_CurrentTick;
- }
-
- return res;
-}
-
-
-
-
-
-/// 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))->GetContents()))
- {
- // 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:
- static const struct
- {
- int x, z;
- }
- Coords [] =
- {
- {1, 0},
- {-1, 0},
- {0, 1},
- {0, -1},
- } ;
- for (int i = 0; i < ARRAYCOUNT(Coords); i++)
- {
- 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)
- )
- {
- continue;
- }
- if (MoveItemsFromGrid(((cChestEntity *)Neighbor->GetBlockEntity(x, m_PosY, z))->GetContents()))
- {
- return true;
- }
- return false;
- }
-
- // The chest was single and nothing could be moved
- return false;
-}
-
-
-
-
-
-/// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
-bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
-{
- cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
- ASSERT(Furnace != NULL);
-
- // Try move from the output slot:
- if (MoveItemsFromSlot(Furnace->GetOutputSlot(), true))
- {
- cItem NewOutput(Furnace->GetOutputSlot());
- Furnace->SetOutputSlot(NewOutput.AddCount(-1));
- return true;
- }
-
- // No output moved, check if we can move an empty bucket out of the fuel slot:
- if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET)
- {
- if (MoveItemsFromSlot(Furnace->GetFuelSlot(), true))
- {
- Furnace->SetFuelSlot(cItem());
- return true;
- }
- }
-
- // Nothing can be moved
- return false;
-}
-
-
-
-
-
-/// Moves items from the specified ItemGrid into this hopper. Returns true if contents have changed.
-bool cHopperEntity::MoveItemsFromGrid(cItemGrid & a_Grid)
-{
- int NumSlots = a_Grid.GetNumSlots();
-
- // First try adding items of types already in the hopper:
- for (int i = 0; i < NumSlots; i++)
- {
- if (a_Grid.IsSlotEmpty(i))
- {
- continue;
- }
- if (MoveItemsFromSlot(a_Grid.GetSlot(i), false))
- {
- a_Grid.ChangeSlotCount(i, -1);
- return true;
- }
- }
-
- // No already existing stack can be topped up, try again with allowing new stacks:
- for (int i = 0; i < NumSlots; i++)
- {
- if (a_Grid.IsSlotEmpty(i))
- {
- continue;
- }
- if (MoveItemsFromSlot(a_Grid.GetSlot(i), true))
- {
- a_Grid.ChangeSlotCount(i, -1);
- return true;
- }
- }
- return false;
-}
-
-
-
-
-
-/// Moves one of the specified itemstack into this hopper. Returns true if contents have changed. Doesn't change the itemstack.
-bool cHopperEntity::MoveItemsFromSlot(const cItem & a_ItemStack, bool a_AllowNewStacks)
-{
- cItem One(a_ItemStack.CopyOne());
- if (m_Contents.AddItem(One, a_AllowNewStacks) > 0)
- {
- return true;
- }
- return false;
-}
-
-
-
-
-
-/// Moves items to the chest at the specified coords. Returns true if contents have changed
-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))->GetContents()))
- {
- return true;
- }
-
- // Check if the chest is a double-chest, if so, try to move into the other half:
- static const struct
- {
- int x, z;
- }
- Coords [] =
- {
- {1, 0},
- {-1, 0},
- {0, 1},
- {0, -1},
- } ;
- for (int i = 0; i < ARRAYCOUNT(Coords); i++)
- {
- 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)
- )
- {
- continue;
- }
- if (MoveItemsToGrid(((cChestEntity *)Neighbor->GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ))->GetContents()))
- {
- return true;
- }
- return false;
- }
-
- // The chest was single and nothing could be moved
- return false;
-}
-
-
-
-
-
-/// Moves items to the furnace at the specified coords. Returns true if contents have changed
-bool cHopperEntity::MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_HopperMeta)
-{
- cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
- if (a_HopperMeta == E_META_HOPPER_FACING_YM)
- {
- // Feed the input slot of the furnace
- return MoveItemsToSlot(Furnace->GetContents(), cFurnaceEntity::fsInput);
- }
- else
- {
- // Feed the fuel slot of the furnace
- return MoveItemsToSlot(Furnace->GetContents(), cFurnaceEntity::fsFuel);
- }
- return false;
-}
-
-
-
-
-
-/// Moves items to the specified ItemGrid. Returns true if contents have changed
-bool cHopperEntity::MoveItemsToGrid(cItemGrid & a_ItemGrid)
-{
- // Iterate through our slots, try to move from each one:
- for (int i = 0; i < ContentsWidth * ContentsHeight; i++)
- {
- const cItem & SrcItem = m_Contents.GetSlot(i);
- if (SrcItem.IsEmpty())
- {
- continue;
- }
-
- cItem ToAdd = SrcItem.CopyOne();
- if (a_ItemGrid.AddItem(ToAdd) > 0)
- {
- m_Contents.ChangeSlotCount(i, -1);
- return true;
- }
- }
- return false;
-}
-
-
-
-
-
-/// Moves one piece to the specified ItemGrid's slot. Returns true if contents have changed.
-bool cHopperEntity::MoveItemsToSlot(cItemGrid & a_ItemGrid, int a_DestSlotNum)
-{
- if (a_ItemGrid.IsSlotEmpty(a_DestSlotNum))
- {
- // The slot is empty, move the first non-empty slot from our contents:
- for (int i = 0; i < ContentsWidth * ContentsHeight; i++)
- {
- if (!m_Contents.IsSlotEmpty(i))
- {
- a_ItemGrid.SetSlot(a_DestSlotNum, m_Contents.GetSlot(i).CopyOne());
- m_Contents.ChangeSlotCount(i, -1);
- return true;
- }
- }
- return false;
- }
- else
- {
- // The slot is taken, try to top it up:
- const cItem & DestSlot = a_ItemGrid.GetSlot(a_DestSlotNum);
- if (DestSlot.IsFullStack())
- {
- return false;
- }
- for (int i = 0; i < ContentsWidth * ContentsHeight; i++)
- {
- if (m_Contents.GetSlot(i).IsStackableWith(DestSlot))
- {
- a_ItemGrid.ChangeSlotCount(a_DestSlotNum, 1);
- m_Contents.ChangeSlotCount(i, -1);
- return true;
- }
- }
- return false;
- }
-}
-
-
-
-
+
+// HopperEntity.cpp
+
+// Implements the cHopperEntity representing a hopper block entity
+
+#include "Globals.h"
+#include "HopperEntity.h"
+#include "../Chunk.h"
+#include "../Player.h"
+#include "ChestEntity.h"
+#include "DropSpenserEntity.h"
+#include "FurnaceEntity.h"
+
+
+
+
+
+cHopperEntity::cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
+ super(E_BLOCK_HOPPER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, NULL),
+ m_LastMoveItemsInTick(0),
+ m_LastMoveItemsOutTick(0)
+{
+}
+
+
+
+
+
+cHopperEntity::cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
+ super(E_BLOCK_HOPPER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
+ m_LastMoveItemsInTick(0),
+ m_LastMoveItemsOutTick(0)
+{
+}
+
+
+
+
+
+/** Returns the block coords of the block receiving the output items, based on the meta
+Returns false if unattached
+*/
+bool cHopperEntity::GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, int & a_OutputY, int & a_OutputZ)
+{
+ a_OutputX = m_PosX;
+ a_OutputY = m_PosY;
+ a_OutputZ = m_PosZ;
+ switch (a_BlockMeta)
+ {
+ case E_META_HOPPER_FACING_XM: a_OutputX--; return true;
+ case E_META_HOPPER_FACING_XP: a_OutputX++; return true;
+ case E_META_HOPPER_FACING_YM: a_OutputY--; return true;
+ case E_META_HOPPER_FACING_ZM: a_OutputZ--; return true;
+ case E_META_HOPPER_FACING_ZP: a_OutputZ++; return true;
+ default:
+ {
+ // Not attached
+ return false;
+ }
+ }
+}
+
+
+
+
+
+bool cHopperEntity::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
+
+ bool res = false;
+ res = MoveItemsIn (a_Chunk, CurrentTick) || res;
+ res = MovePickupsIn(a_Chunk, CurrentTick) || res;
+ res = MoveItemsOut (a_Chunk, CurrentTick) || res;
+ return res;
+}
+
+
+
+
+
+void cHopperEntity::SaveToJson(Json::Value & a_Value)
+{
+ // TODO
+ LOGWARNING("%s: Not implemented yet", __FUNCTION__);
+}
+
+
+
+
+
+void cHopperEntity::SendTo(cClientHandle & a_Client)
+{
+ // The hopper 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 hopper is rclked
+
+ UNUSED(a_Client);
+}
+
+
+
+
+
+void cHopperEntity::UsedBy(cPlayer * a_Player)
+{
+ // 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)
+ {
+ if (a_Player->GetWindow() != Window)
+ {
+ a_Player->OpenWindow(Window);
+ }
+ }
+
+ // 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_PosY, m_PosZ, ChunkX, ChunkZ);
+ m_World->MarkChunkDirty(ChunkX, ChunkZ);
+}
+
+
+
+
+
+/// Opens a new window UI for this hopper
+void cHopperEntity::OpenNewWindow(void)
+{
+ OpenWindow(new cHopperWindow(m_PosX, m_PosY, m_PosZ, this));
+}
+
+
+
+
+
+/// Moves items from the container above it into this hopper. Returns true if the contents have changed.
+bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
+{
+ if (m_PosY >= cChunkDef::Height)
+ {
+ // This hopper is at the top of the world, no more blocks above
+ return false;
+ }
+
+ if (a_CurrentTick - m_LastMoveItemsInTick < TICKS_PER_TRANSFER)
+ {
+ // Too early after the previous transfer
+ return false;
+ }
+
+ // Try moving an item in:
+ bool res = false;
+ switch (a_Chunk.GetBlock(m_RelX, m_PosY + 1, m_RelZ))
+ {
+ case E_BLOCK_CHEST: res = MoveItemsFromChest(a_Chunk); break;
+ case E_BLOCK_FURNACE: res = MoveItemsFromFurnace(a_Chunk); break;
+ case E_BLOCK_DISPENSER:
+ case E_BLOCK_DROPPER: res = MoveItemsFromGrid(((cDropSpenserEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ))->GetContents()); break;
+ case E_BLOCK_HOPPER: res = MoveItemsFromGrid(((cHopperEntity *) a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ))->GetContents()); break;
+ case E_BLOCK_LIT_FURNACE: res = MoveItemsFromFurnace(a_Chunk); break;
+ }
+
+ // If the item has been moved, reset the last tick:
+ if (res)
+ {
+ m_LastMoveItemsInTick = a_CurrentTick;
+ }
+
+ return res;
+}
+
+
+
+
+
+/// Moves pickups from above this hopper into it. Returns true if the contents have changed.
+bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
+{
+ // TODO
+ return false;
+}
+
+
+
+
+
+/// Moves items out from this hopper into the destination. Returns true if the contents have changed.
+bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
+{
+ if (a_CurrentTick - m_LastMoveItemsOutTick < TICKS_PER_TRANSFER)
+ {
+ // Too early after the previous transfer
+ return false;
+ }
+
+ int bx, by, bz;
+ NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
+ if (!GetOutputBlockPos(Meta, bx, by, bz))
+ {
+ // Not attached to another container
+ return false;
+ }
+ if (by < 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);
+ if (DestChunk == NULL)
+ {
+ // The destination chunk has been unloaded, don't tick
+ return false;
+ }
+
+ // Call proper moving function, based on the blocktype present at the coords:
+ bool res = false;
+ switch (DestChunk->GetBlock(rx, by, rz))
+ {
+ case E_BLOCK_CHEST: res = MoveItemsToChest(*DestChunk, bx, by, bz); break;
+ case E_BLOCK_FURNACE: res = MoveItemsToFurnace(*DestChunk, bx, by, bz, Meta); break;
+ case E_BLOCK_DISPENSER:
+ case E_BLOCK_DROPPER: res = MoveItemsToGrid(((cDropSpenserEntity *)DestChunk->GetBlockEntity(bx, by, bz))->GetContents()); break;
+ case E_BLOCK_HOPPER: res = MoveItemsToGrid(((cHopperEntity *) DestChunk->GetBlockEntity(bx, by, bz))->GetContents()); break;
+ case E_BLOCK_LIT_FURNACE: res = MoveItemsToFurnace(*DestChunk, bx, by, bz, Meta); break;
+ }
+
+ // If the item has been moved, reset the last tick:
+ if (res)
+ {
+ m_LastMoveItemsOutTick = a_CurrentTick;
+ }
+
+ return res;
+}
+
+
+
+
+
+/// 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))->GetContents()))
+ {
+ // 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:
+ static const struct
+ {
+ int x, z;
+ }
+ Coords [] =
+ {
+ {1, 0},
+ {-1, 0},
+ {0, 1},
+ {0, -1},
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(Coords); i++)
+ {
+ 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)
+ )
+ {
+ continue;
+ }
+ if (MoveItemsFromGrid(((cChestEntity *)Neighbor->GetBlockEntity(x, m_PosY, z))->GetContents()))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ // The chest was single and nothing could be moved
+ return false;
+}
+
+
+
+
+
+/// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
+bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
+{
+ cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
+ ASSERT(Furnace != NULL);
+
+ // Try move from the output slot:
+ if (MoveItemsFromSlot(Furnace->GetOutputSlot(), true))
+ {
+ cItem NewOutput(Furnace->GetOutputSlot());
+ Furnace->SetOutputSlot(NewOutput.AddCount(-1));
+ return true;
+ }
+
+ // No output moved, check if we can move an empty bucket out of the fuel slot:
+ if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET)
+ {
+ if (MoveItemsFromSlot(Furnace->GetFuelSlot(), true))
+ {
+ Furnace->SetFuelSlot(cItem());
+ return true;
+ }
+ }
+
+ // Nothing can be moved
+ return false;
+}
+
+
+
+
+
+/// Moves items from the specified ItemGrid into this hopper. Returns true if contents have changed.
+bool cHopperEntity::MoveItemsFromGrid(cItemGrid & a_Grid)
+{
+ int NumSlots = a_Grid.GetNumSlots();
+
+ // First try adding items of types already in the hopper:
+ for (int i = 0; i < NumSlots; i++)
+ {
+ if (a_Grid.IsSlotEmpty(i))
+ {
+ continue;
+ }
+ if (MoveItemsFromSlot(a_Grid.GetSlot(i), false))
+ {
+ a_Grid.ChangeSlotCount(i, -1);
+ return true;
+ }
+ }
+
+ // No already existing stack can be topped up, try again with allowing new stacks:
+ for (int i = 0; i < NumSlots; i++)
+ {
+ if (a_Grid.IsSlotEmpty(i))
+ {
+ continue;
+ }
+ if (MoveItemsFromSlot(a_Grid.GetSlot(i), true))
+ {
+ a_Grid.ChangeSlotCount(i, -1);
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
+/// Moves one of the specified itemstack into this hopper. Returns true if contents have changed. Doesn't change the itemstack.
+bool cHopperEntity::MoveItemsFromSlot(const cItem & a_ItemStack, bool a_AllowNewStacks)
+{
+ cItem One(a_ItemStack.CopyOne());
+ if (m_Contents.AddItem(One, a_AllowNewStacks) > 0)
+ {
+ return true;
+ }
+ return false;
+}
+
+
+
+
+
+/// Moves items to the chest at the specified coords. Returns true if contents have changed
+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))->GetContents()))
+ {
+ return true;
+ }
+
+ // Check if the chest is a double-chest, if so, try to move into the other half:
+ static const struct
+ {
+ int x, z;
+ }
+ Coords [] =
+ {
+ {1, 0},
+ {-1, 0},
+ {0, 1},
+ {0, -1},
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(Coords); i++)
+ {
+ 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)
+ )
+ {
+ continue;
+ }
+ if (MoveItemsToGrid(((cChestEntity *)Neighbor->GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ))->GetContents()))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ // The chest was single and nothing could be moved
+ return false;
+}
+
+
+
+
+
+/// Moves items to the furnace at the specified coords. Returns true if contents have changed
+bool cHopperEntity::MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_HopperMeta)
+{
+ cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
+ if (a_HopperMeta == E_META_HOPPER_FACING_YM)
+ {
+ // Feed the input slot of the furnace
+ return MoveItemsToSlot(Furnace->GetContents(), cFurnaceEntity::fsInput);
+ }
+ else
+ {
+ // Feed the fuel slot of the furnace
+ return MoveItemsToSlot(Furnace->GetContents(), cFurnaceEntity::fsFuel);
+ }
+ return false;
+}
+
+
+
+
+
+/// Moves items to the specified ItemGrid. Returns true if contents have changed
+bool cHopperEntity::MoveItemsToGrid(cItemGrid & a_ItemGrid)
+{
+ // Iterate through our slots, try to move from each one:
+ for (int i = 0; i < ContentsWidth * ContentsHeight; i++)
+ {
+ const cItem & SrcItem = m_Contents.GetSlot(i);
+ if (SrcItem.IsEmpty())
+ {
+ continue;
+ }
+
+ cItem ToAdd = SrcItem.CopyOne();
+ if (a_ItemGrid.AddItem(ToAdd) > 0)
+ {
+ m_Contents.ChangeSlotCount(i, -1);
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
+/// Moves one piece to the specified ItemGrid's slot. Returns true if contents have changed.
+bool cHopperEntity::MoveItemsToSlot(cItemGrid & a_ItemGrid, int a_DestSlotNum)
+{
+ if (a_ItemGrid.IsSlotEmpty(a_DestSlotNum))
+ {
+ // The slot is empty, move the first non-empty slot from our contents:
+ for (int i = 0; i < ContentsWidth * ContentsHeight; i++)
+ {
+ if (!m_Contents.IsSlotEmpty(i))
+ {
+ a_ItemGrid.SetSlot(a_DestSlotNum, m_Contents.GetSlot(i).CopyOne());
+ m_Contents.ChangeSlotCount(i, -1);
+ return true;
+ }
+ }
+ return false;
+ }
+ else
+ {
+ // The slot is taken, try to top it up:
+ const cItem & DestSlot = a_ItemGrid.GetSlot(a_DestSlotNum);
+ if (DestSlot.IsFullStack())
+ {
+ return false;
+ }
+ for (int i = 0; i < ContentsWidth * ContentsHeight; i++)
+ {
+ if (m_Contents.GetSlot(i).IsStackableWith(DestSlot))
+ {
+ a_ItemGrid.ChangeSlotCount(a_DestSlotNum, 1);
+ m_Contents.ChangeSlotCount(i, -1);
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
+
+
+
diff --git a/source/BlockEntities/HopperEntity.h b/source/BlockEntities/HopperEntity.h
index 7f5eb23d1..8fc17b631 100644
--- a/source/BlockEntities/HopperEntity.h
+++ b/source/BlockEntities/HopperEntity.h
@@ -1,102 +1,102 @@
-
-// HopperEntity.h
-
-// Declares the cHopperEntity representing a hopper block entity
-
-
-
-
-
-#pragma once
-
-#include "BlockEntityWithItems.h"
-#include "../UI/WindowOwner.h"
-
-
-
-
-
-class cHopperEntity : // tolua_export
- public cBlockEntityWindowOwner,
- // tolua_begin
- public cBlockEntityWithItems
-{
- typedef cBlockEntityWithItems super;
-
-public:
- enum {
- ContentsHeight = 1,
- ContentsWidth = 5,
- TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper
- } ;
-
- /// Constructor used while generating a chunk; sets m_World to NULL
- cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
-
- // tolua_end
-
- /// Constructor used for normal operation
- cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
-
- // tolua_begin
-
- /** Returns the block coords of the block receiving the output items, based on the meta
- Returns false if unattached
- */
- bool GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, int & a_OutputY, int & a_OutputZ);
-
- // tolua_end
-
- static const char * GetClassStatic(void) { return "cHopperEntity"; }
-
-protected:
-
- Int64 m_LastMoveItemsInTick;
- Int64 m_LastMoveItemsOutTick;
-
- // cBlockEntity overrides:
- virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void SaveToJson(Json::Value & a_Value) override;
- 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.
- void OpenNewWindow(void);
-
- /// Moves items from the container above it into this hopper. Returns true if the contents have changed.
- bool MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick);
-
- /// Moves pickups from above this hopper into it. Returns true if the contents have changed.
- bool MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick);
-
- /// Moves items out from this hopper into the destination. Returns true if the contents have changed.
- bool 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 MoveItemsFromChest(cChunk & a_Chunk);
-
- /// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
- bool MoveItemsFromFurnace(cChunk & a_Chunk);
-
- /// Moves items from the specified ItemGrid into this hopper. Returns true if contents have changed.
- bool MoveItemsFromGrid(cItemGrid & a_Grid);
-
- /// Moves one piece from the specified itemstack into this hopper. Returns true if contents have changed. Doesn't change the itemstack.
- bool MoveItemsFromSlot(const cItem & a_ItemStack, bool a_AllowNewStacks);
-
- /// Moves items to the chest at the specified coords. Returns true if contents have changed
- bool MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ);
-
- /// Moves items to the furnace at the specified coords. Returns true if contents have changed
- bool MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_HopperMeta);
-
- /// Moves items to the specified ItemGrid. Returns true if contents have changed
- bool MoveItemsToGrid(cItemGrid & a_ItemGrid);
-
- /// Moves one piece to the specified ItemGrid's slot. Returns true if contents have changed.
- bool MoveItemsToSlot(cItemGrid & a_ItemGrid, int a_DestSlotNum);
-} ;
-
-
-
-
+
+// HopperEntity.h
+
+// Declares the cHopperEntity representing a hopper block entity
+
+
+
+
+
+#pragma once
+
+#include "BlockEntityWithItems.h"
+#include "../UI/WindowOwner.h"
+
+
+
+
+
+class cHopperEntity : // tolua_export
+ public cBlockEntityWindowOwner,
+ // tolua_begin
+ public cBlockEntityWithItems
+{
+ typedef cBlockEntityWithItems super;
+
+public:
+ enum {
+ ContentsHeight = 1,
+ ContentsWidth = 5,
+ TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper
+ } ;
+
+ /// Constructor used while generating a chunk; sets m_World to NULL
+ cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ // tolua_end
+
+ /// Constructor used for normal operation
+ cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+
+ // tolua_begin
+
+ /** Returns the block coords of the block receiving the output items, based on the meta
+ Returns false if unattached
+ */
+ bool GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, int & a_OutputY, int & a_OutputZ);
+
+ // tolua_end
+
+ static const char * GetClassStatic(void) { return "cHopperEntity"; }
+
+protected:
+
+ Int64 m_LastMoveItemsInTick;
+ Int64 m_LastMoveItemsOutTick;
+
+ // cBlockEntity overrides:
+ virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void SaveToJson(Json::Value & a_Value) override;
+ 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.
+ void OpenNewWindow(void);
+
+ /// Moves items from the container above it into this hopper. Returns true if the contents have changed.
+ bool MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick);
+
+ /// Moves pickups from above this hopper into it. Returns true if the contents have changed.
+ bool MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick);
+
+ /// Moves items out from this hopper into the destination. Returns true if the contents have changed.
+ bool 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 MoveItemsFromChest(cChunk & a_Chunk);
+
+ /// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
+ bool MoveItemsFromFurnace(cChunk & a_Chunk);
+
+ /// Moves items from the specified ItemGrid into this hopper. Returns true if contents have changed.
+ bool MoveItemsFromGrid(cItemGrid & a_Grid);
+
+ /// Moves one piece from the specified itemstack into this hopper. Returns true if contents have changed. Doesn't change the itemstack.
+ bool MoveItemsFromSlot(const cItem & a_ItemStack, bool a_AllowNewStacks);
+
+ /// Moves items to the chest at the specified coords. Returns true if contents have changed
+ bool MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ /// Moves items to the furnace at the specified coords. Returns true if contents have changed
+ bool MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_HopperMeta);
+
+ /// Moves items to the specified ItemGrid. Returns true if contents have changed
+ bool MoveItemsToGrid(cItemGrid & a_ItemGrid);
+
+ /// Moves one piece to the specified ItemGrid's slot. Returns true if contents have changed.
+ bool MoveItemsToSlot(cItemGrid & a_ItemGrid, int a_DestSlotNum);
+} ;
+
+
+
+
diff --git a/source/BlockEntities/JukeboxEntity.cpp b/source/BlockEntities/JukeboxEntity.cpp
index 617b7bd00..ec6d13282 100644
--- a/source/BlockEntities/JukeboxEntity.cpp
+++ b/source/BlockEntities/JukeboxEntity.cpp
@@ -1,123 +1,123 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "JukeboxEntity.h"
-#include "../World.h"
-#include <json/json.h>
-
-
-
-
-
-cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
- : cBlockEntity(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, a_World)
- , m_Record( 0 )
-{
-}
-
-
-
-
-
-cJukeboxEntity::~cJukeboxEntity()
-{
- if (m_Record >= 2256 && m_Record <= 2267)
- {
- EjectRecord();
- m_Record = 0;
- }
-}
-
-
-
-
-
-void cJukeboxEntity::UsedBy(cPlayer * a_Player)
-{
- if (m_Record == 0)
- {
- const cItem & HeldItem = a_Player->GetEquippedItem();
- if (HeldItem.m_ItemType >= 2256 && HeldItem.m_ItemType <= 2267)
- {
- m_Record = HeldItem.m_ItemType;
- a_Player->GetInventory().RemoveOneEquippedItem();
- PlayRecord();
- }
- }
- else if (m_Record >= 2256 && m_Record <= 2267)
- {
- EjectRecord();
- m_Record = 0;
- }
-}
-
-
-
-
-
-void cJukeboxEntity::PlayRecord( void )
-{
- m_World->BroadcastSoundParticleEffect(1005, m_PosX * 8, m_PosY * 8, m_PosZ * 8, m_Record);
-}
-
-
-
-
-
-void cJukeboxEntity::EjectRecord( void )
-{
- cItems Drops;
- Drops.push_back(cItem(m_Record, 1, 0));
- m_World->SpawnItemPickups(Drops, m_PosX, m_PosY+1, m_PosZ);
- m_World->BroadcastSoundParticleEffect(1005, m_PosX * 8, m_PosY * 8, m_PosZ * 8, 0);
-}
-
-
-
-
-
-int cJukeboxEntity::GetRecord( void )
-{
- return m_Record;
-}
-
-
-
-
-
-void cJukeboxEntity::SetRecord( int a_Record )
-{
- m_Record = a_Record;
-}
-
-
-
-
-
-bool cJukeboxEntity::LoadFromJson( const Json::Value & a_Value )
-{
- m_PosX = a_Value.get("x", 0).asInt();
- m_PosY = a_Value.get("y", 0).asInt();
- m_PosZ = a_Value.get("z", 0).asInt();
-
- m_Record = a_Value.get("Record", 0).asInt();
-
- return true;
-}
-
-
-
-
-
-void cJukeboxEntity::SaveToJson( Json::Value & a_Value )
-{
- a_Value["x"] = m_PosX;
- a_Value["y"] = m_PosY;
- a_Value["z"] = m_PosZ;
-
- a_Value["Record"] = m_Record;
-}
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "JukeboxEntity.h"
+#include "../World.h"
+#include <json/json.h>
+
+
+
+
+
+cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
+ : cBlockEntity(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, a_World)
+ , m_Record( 0 )
+{
+}
+
+
+
+
+
+cJukeboxEntity::~cJukeboxEntity()
+{
+ if (m_Record >= 2256 && m_Record <= 2267)
+ {
+ EjectRecord();
+ m_Record = 0;
+ }
+}
+
+
+
+
+
+void cJukeboxEntity::UsedBy(cPlayer * a_Player)
+{
+ if (m_Record == 0)
+ {
+ const cItem & HeldItem = a_Player->GetEquippedItem();
+ if (HeldItem.m_ItemType >= 2256 && HeldItem.m_ItemType <= 2267)
+ {
+ m_Record = HeldItem.m_ItemType;
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ PlayRecord();
+ }
+ }
+ else if (m_Record >= 2256 && m_Record <= 2267)
+ {
+ EjectRecord();
+ m_Record = 0;
+ }
+}
+
+
+
+
+
+void cJukeboxEntity::PlayRecord( void )
+{
+ m_World->BroadcastSoundParticleEffect(1005, m_PosX * 8, m_PosY * 8, m_PosZ * 8, m_Record);
+}
+
+
+
+
+
+void cJukeboxEntity::EjectRecord( void )
+{
+ cItems Drops;
+ Drops.push_back(cItem(m_Record, 1, 0));
+ m_World->SpawnItemPickups(Drops, m_PosX, m_PosY+1, m_PosZ);
+ m_World->BroadcastSoundParticleEffect(1005, m_PosX * 8, m_PosY * 8, m_PosZ * 8, 0);
+}
+
+
+
+
+
+int cJukeboxEntity::GetRecord( void )
+{
+ return m_Record;
+}
+
+
+
+
+
+void cJukeboxEntity::SetRecord( int a_Record )
+{
+ m_Record = a_Record;
+}
+
+
+
+
+
+bool cJukeboxEntity::LoadFromJson( const Json::Value & a_Value )
+{
+ m_PosX = a_Value.get("x", 0).asInt();
+ m_PosY = a_Value.get("y", 0).asInt();
+ m_PosZ = a_Value.get("z", 0).asInt();
+
+ m_Record = a_Value.get("Record", 0).asInt();
+
+ return true;
+}
+
+
+
+
+
+void cJukeboxEntity::SaveToJson( Json::Value & a_Value )
+{
+ a_Value["x"] = m_PosX;
+ a_Value["y"] = m_PosY;
+ a_Value["z"] = m_PosZ;
+
+ a_Value["Record"] = m_Record;
+}
+
+
+
+
diff --git a/source/BlockEntities/JukeboxEntity.h b/source/BlockEntities/JukeboxEntity.h
index 063453607..74d40ecef 100644
--- a/source/BlockEntities/JukeboxEntity.h
+++ b/source/BlockEntities/JukeboxEntity.h
@@ -1,43 +1,43 @@
-
-#pragma once
-
-#include "BlockEntity.h"
-#include "../Player.h"
-
-
-
-
-
-namespace Json
-{
- class Value;
-}
-
-
-
-
-
-class cJukeboxEntity :
- public cBlockEntity
-{
-public:
- cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
- virtual ~cJukeboxEntity();
-
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson( Json::Value& a_Value ) override;
-
- int GetRecord( void );
- void SetRecord( int a_Record );
- void PlayRecord( void );
- void EjectRecord( void );
- virtual void UsedBy( cPlayer * a_Player ) override;
- virtual void SendTo(cClientHandle & a_Client) override { };
-
-private:
- int m_Record;
-};
-
-
-
-
+
+#pragma once
+
+#include "BlockEntity.h"
+#include "../Player.h"
+
+
+
+
+
+namespace Json
+{
+ class Value;
+}
+
+
+
+
+
+class cJukeboxEntity :
+ public cBlockEntity
+{
+public:
+ cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+ virtual ~cJukeboxEntity();
+
+ bool LoadFromJson( const Json::Value& a_Value );
+ virtual void SaveToJson( Json::Value& a_Value ) override;
+
+ int GetRecord( void );
+ void SetRecord( int a_Record );
+ void PlayRecord( void );
+ void EjectRecord( void );
+ virtual void UsedBy( cPlayer * a_Player ) override;
+ virtual void SendTo(cClientHandle & a_Client) override { };
+
+private:
+ int m_Record;
+};
+
+
+
+
diff --git a/source/BlockEntities/NoteEntity.cpp b/source/BlockEntities/NoteEntity.cpp
index 36da13692..6dc0e20a1 100644
--- a/source/BlockEntities/NoteEntity.cpp
+++ b/source/BlockEntities/NoteEntity.cpp
@@ -1,159 +1,159 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "NoteEntity.h"
-#include "../World.h"
-#include <json/json.h>
-
-
-cNoteEntity::cNoteEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
- : cBlockEntity(E_BLOCK_NOTE_BLOCK, a_BlockX, a_BlockY, a_BlockZ, a_World)
- , m_Pitch( 0 )
-{
-}
-
-
-
-
-
-cNoteEntity::~cNoteEntity()
-{
-}
-
-
-
-
-
-void cNoteEntity::UsedBy( cPlayer * a_Player )
-{
- IncrementPitch();
- MakeSound();
-}
-
-
-
-
-
-void cNoteEntity::MakeSound( void )
-{
- char instrument;
- AString sampleName;
-
- switch (m_World->GetBlock(m_PosX, m_PosY - 1, m_PosZ))
- {
- case E_BLOCK_PLANKS:
- case E_BLOCK_LOG:
- case E_BLOCK_NOTE_BLOCK:
- {
- // TODO: add other wood-based blocks if needed
- instrument = E_INST_DOUBLE_BASS;
- sampleName = "note.db";
- break;
- }
-
- case E_BLOCK_SAND:
- case E_BLOCK_GRAVEL:
- case E_BLOCK_SOULSAND:
- {
- instrument = E_INST_SNARE_DRUM;
- sampleName = "note.snare";
- break;
- }
-
- case E_BLOCK_GLASS:
- case E_BLOCK_GLASS_PANE:
- case E_BLOCK_GLOWSTONE:
- {
- instrument = E_INST_CLICKS;
- sampleName = "note.hat";
- break;
- }
-
- case E_BLOCK_STONE:
- case E_BLOCK_STONE_BRICKS:
- case E_BLOCK_COBBLESTONE:
- case E_BLOCK_OBSIDIAN:
- case E_BLOCK_NETHERRACK:
- case E_BLOCK_BRICK:
- case E_BLOCK_NETHER_BRICK:
- {
- // TODO: add other stone-based blocks if needed
- instrument = E_INST_BASS_DRUM;
- sampleName = "note.bassattack";
- break;
- }
-
- default:
- {
- instrument = E_INST_HARP_PIANO;
- sampleName = "note.harp";
- break;
- }
- }
-
- m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, instrument, m_Pitch, E_BLOCK_NOTE_BLOCK);
-
- // 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);
-}
-
-
-
-
-
-char cNoteEntity::GetPitch( void )
-{
- return m_Pitch;
-}
-
-
-
-
-
-void cNoteEntity::SetPitch( char a_Pitch )
-{
- m_Pitch = a_Pitch % 25;
-}
-
-
-
-
-
-void cNoteEntity::IncrementPitch( void )
-{
- SetPitch( m_Pitch + 1 );
-}
-
-
-
-
-
-bool cNoteEntity::LoadFromJson( const Json::Value & a_Value )
-{
-
- m_PosX = a_Value.get("x", 0).asInt();
- m_PosY = a_Value.get("y", 0).asInt();
- m_PosZ = a_Value.get("z", 0).asInt();
-
- m_Pitch = (char)a_Value.get("p", 0).asInt();
-
- return true;
-}
-
-
-
-
-
-void cNoteEntity::SaveToJson( Json::Value & a_Value )
-{
- a_Value["x"] = m_PosX;
- a_Value["y"] = m_PosY;
- a_Value["z"] = m_PosZ;
-
- a_Value["p"] = m_Pitch;
-}
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "NoteEntity.h"
+#include "../World.h"
+#include <json/json.h>
+
+
+cNoteEntity::cNoteEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
+ : cBlockEntity(E_BLOCK_NOTE_BLOCK, a_BlockX, a_BlockY, a_BlockZ, a_World)
+ , m_Pitch( 0 )
+{
+}
+
+
+
+
+
+cNoteEntity::~cNoteEntity()
+{
+}
+
+
+
+
+
+void cNoteEntity::UsedBy( cPlayer * a_Player )
+{
+ IncrementPitch();
+ MakeSound();
+}
+
+
+
+
+
+void cNoteEntity::MakeSound( void )
+{
+ char instrument;
+ AString sampleName;
+
+ switch (m_World->GetBlock(m_PosX, m_PosY - 1, m_PosZ))
+ {
+ case E_BLOCK_PLANKS:
+ case E_BLOCK_LOG:
+ case E_BLOCK_NOTE_BLOCK:
+ {
+ // TODO: add other wood-based blocks if needed
+ instrument = E_INST_DOUBLE_BASS;
+ sampleName = "note.db";
+ break;
+ }
+
+ case E_BLOCK_SAND:
+ case E_BLOCK_GRAVEL:
+ case E_BLOCK_SOULSAND:
+ {
+ instrument = E_INST_SNARE_DRUM;
+ sampleName = "note.snare";
+ break;
+ }
+
+ case E_BLOCK_GLASS:
+ case E_BLOCK_GLASS_PANE:
+ case E_BLOCK_GLOWSTONE:
+ {
+ instrument = E_INST_CLICKS;
+ sampleName = "note.hat";
+ break;
+ }
+
+ case E_BLOCK_STONE:
+ case E_BLOCK_STONE_BRICKS:
+ case E_BLOCK_COBBLESTONE:
+ case E_BLOCK_OBSIDIAN:
+ case E_BLOCK_NETHERRACK:
+ case E_BLOCK_BRICK:
+ case E_BLOCK_NETHER_BRICK:
+ {
+ // TODO: add other stone-based blocks if needed
+ instrument = E_INST_BASS_DRUM;
+ sampleName = "note.bassattack";
+ break;
+ }
+
+ default:
+ {
+ instrument = E_INST_HARP_PIANO;
+ sampleName = "note.harp";
+ break;
+ }
+ }
+
+ m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, instrument, m_Pitch, E_BLOCK_NOTE_BLOCK);
+
+ // 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);
+}
+
+
+
+
+
+char cNoteEntity::GetPitch( void )
+{
+ return m_Pitch;
+}
+
+
+
+
+
+void cNoteEntity::SetPitch( char a_Pitch )
+{
+ m_Pitch = a_Pitch % 25;
+}
+
+
+
+
+
+void cNoteEntity::IncrementPitch( void )
+{
+ SetPitch( m_Pitch + 1 );
+}
+
+
+
+
+
+bool cNoteEntity::LoadFromJson( const Json::Value & a_Value )
+{
+
+ m_PosX = a_Value.get("x", 0).asInt();
+ m_PosY = a_Value.get("y", 0).asInt();
+ m_PosZ = a_Value.get("z", 0).asInt();
+
+ m_Pitch = (char)a_Value.get("p", 0).asInt();
+
+ return true;
+}
+
+
+
+
+
+void cNoteEntity::SaveToJson( Json::Value & a_Value )
+{
+ a_Value["x"] = m_PosX;
+ a_Value["y"] = m_PosY;
+ a_Value["z"] = m_PosZ;
+
+ a_Value["p"] = m_Pitch;
+}
+
+
+
+
diff --git a/source/BlockEntities/NoteEntity.h b/source/BlockEntities/NoteEntity.h
index 29ce4ef8f..385591df6 100644
--- a/source/BlockEntities/NoteEntity.h
+++ b/source/BlockEntities/NoteEntity.h
@@ -1,52 +1,52 @@
-
-#pragma once
-
-#include "BlockEntity.h"
-
-
-namespace Json
-{
- class Value;
-}
-
-
-
-
-
-enum ENUM_NOTE_INSTRUMENTS
-{
- E_INST_HARP_PIANO = 0,
- E_INST_DOUBLE_BASS = 1,
- E_INST_SNARE_DRUM = 2,
- E_INST_CLICKS = 3,
- E_INST_BASS_DRUM = 4
-};
-
-
-
-
-
-class cNoteEntity :
- public cBlockEntity
-{
-public:
- cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
- virtual ~cNoteEntity();
-
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson( Json::Value& a_Value ) override;
-
- char GetPitch( void );
- void SetPitch( char a_Pitch );
- void IncrementPitch( void );
- void MakeSound( void );
- virtual void UsedBy( cPlayer * a_Player ) override;
- virtual void SendTo(cClientHandle & a_Client) override { };
-
-private:
- unsigned char m_Pitch;
-};
-
-
-
-
+
+#pragma once
+
+#include "BlockEntity.h"
+
+
+namespace Json
+{
+ class Value;
+}
+
+
+
+
+
+enum ENUM_NOTE_INSTRUMENTS
+{
+ E_INST_HARP_PIANO = 0,
+ E_INST_DOUBLE_BASS = 1,
+ E_INST_SNARE_DRUM = 2,
+ E_INST_CLICKS = 3,
+ E_INST_BASS_DRUM = 4
+};
+
+
+
+
+
+class cNoteEntity :
+ public cBlockEntity
+{
+public:
+ cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
+ virtual ~cNoteEntity();
+
+ bool LoadFromJson( const Json::Value& a_Value );
+ virtual void SaveToJson( Json::Value& a_Value ) override;
+
+ char GetPitch( void );
+ void SetPitch( char a_Pitch );
+ void IncrementPitch( void );
+ void MakeSound( void );
+ virtual void UsedBy( cPlayer * a_Player ) override;
+ virtual void SendTo(cClientHandle & a_Client) override { };
+
+private:
+ unsigned char m_Pitch;
+};
+
+
+
+
diff --git a/source/Blocks/BlockBed.cpp b/source/Blocks/BlockBed.cpp
index 513874252..2ae6980ac 100644
--- a/source/Blocks/BlockBed.cpp
+++ b/source/Blocks/BlockBed.cpp
@@ -1,85 +1,85 @@
-#include "Globals.h"
-#include "BlockBed.h"
-
-
-
-
-
-void cBlockBedHandler::OnPlacedByPlayer(
- cWorld * a_World, 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
-)
-{
- if (a_BlockMeta < 8)
- {
- Vector3i Direction = MetaDataToDirection(a_BlockMeta);
- a_World->SetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8);
- }
-}
-
-
-
-
-
-void cBlockBedHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- NIBBLETYPE OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
-
- Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ );
- Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 );
- if (OldMeta & 0x8)
- {
- // Was pillow
- if (a_World->GetBlock(ThisPos - Direction) == E_BLOCK_BED)
- {
- a_World->FastSetBlock(ThisPos - Direction, E_BLOCK_AIR, 0);
- }
- }
- else
- {
- // Was foot end
- if (a_World->GetBlock(ThisPos + Direction) == E_BLOCK_BED)
- {
- a_World->FastSetBlock(ThisPos + Direction, E_BLOCK_AIR, 0);
- }
- }
-}
-
-
-
-
-
-void cBlockBedHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
-{
- if (a_World->GetDimension() != 0)
- {
- a_World->DoExplosiontAt(5, a_BlockX, a_BlockY, a_BlockZ);
- } else {
- if (a_World->GetTimeOfDay() > 13000)
- {
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if (Meta & 0x8)
- {
- // Is pillow
- a_World->BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ);
- }
- else
- {
- // Is foot end
- Vector3i Direction = MetaDataToDirection( Meta & 0x7 );
- if (a_World->GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
- {
- a_World->BroadcastUseBed(*a_Player, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z);
- }
- }
- } else {
- a_Player->SendMessage("You can only sleep at night");
- }
- }
-}
-
-
-
-
+#include "Globals.h"
+#include "BlockBed.h"
+
+
+
+
+
+void cBlockBedHandler::OnPlacedByPlayer(
+ cWorld * a_World, 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
+)
+{
+ if (a_BlockMeta < 8)
+ {
+ Vector3i Direction = MetaDataToDirection(a_BlockMeta);
+ a_World->SetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8);
+ }
+}
+
+
+
+
+
+void cBlockBedHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ NIBBLETYPE OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+
+ Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ );
+ Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 );
+ if (OldMeta & 0x8)
+ {
+ // Was pillow
+ if (a_World->GetBlock(ThisPos - Direction) == E_BLOCK_BED)
+ {
+ a_World->FastSetBlock(ThisPos - Direction, E_BLOCK_AIR, 0);
+ }
+ }
+ else
+ {
+ // Was foot end
+ if (a_World->GetBlock(ThisPos + Direction) == E_BLOCK_BED)
+ {
+ a_World->FastSetBlock(ThisPos + Direction, E_BLOCK_AIR, 0);
+ }
+ }
+}
+
+
+
+
+
+void cBlockBedHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+{
+ if (a_World->GetDimension() != 0)
+ {
+ a_World->DoExplosiontAt(5, a_BlockX, a_BlockY, a_BlockZ);
+ } else {
+ if (a_World->GetTimeOfDay() > 13000)
+ {
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ if (Meta & 0x8)
+ {
+ // Is pillow
+ a_World->BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ);
+ }
+ else
+ {
+ // Is foot end
+ Vector3i Direction = MetaDataToDirection( Meta & 0x7 );
+ if (a_World->GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
+ {
+ a_World->BroadcastUseBed(*a_Player, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z);
+ }
+ }
+ } else {
+ a_Player->SendMessage("You can only sleep at night");
+ }
+ }
+}
+
+
+
+
diff --git a/source/Blocks/BlockBed.h b/source/Blocks/BlockBed.h
index bf8906750..8286ceb11 100644
--- a/source/Blocks/BlockBed.h
+++ b/source/Blocks/BlockBed.h
@@ -1,73 +1,73 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-#include "../Player.h"
-
-
-
-
-
-class cBlockBedHandler :
- public cBlockHandler
-{
-public:
- cBlockBedHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void OnPlacedByPlayer(cWorld * a_World, 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) override;
- virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
- virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
-
-
- virtual bool IsUseable(void) override
- {
- return true;
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Reset meta to zero
- a_Pickups.push_back(cItem(E_ITEM_BED, 1, 0));
- }
-
-
- virtual bool DoesAllowBlockOnTop() override
- {
- return false;
- }
-
-
- // Bed specific helper functions
- static NIBBLETYPE RotationToMetaData(double a_Rotation)
- {
- a_Rotation += 180 + (180 / 4); // So its not aligned with axis
- if (a_Rotation > 360) a_Rotation -= 360;
-
- a_Rotation = (a_Rotation / 360) * 4;
-
- return ((char)a_Rotation + 2) % 4;
- }
-
-
- static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData)
- {
- switch (a_MetaData)
- {
- case 0: return Vector3i(0, 0, 1);
- case 1: return Vector3i(-1, 0, 0);
- case 2: return Vector3i(0, 0, -1);
- case 3: return Vector3i(1, 0, 0);
- }
- return Vector3i();
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+#include "../Player.h"
+
+
+
+
+
+class cBlockBedHandler :
+ public cBlockHandler
+{
+public:
+ cBlockBedHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void OnPlacedByPlayer(cWorld * a_World, 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) override;
+ virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
+
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to zero
+ a_Pickups.push_back(cItem(E_ITEM_BED, 1, 0));
+ }
+
+
+ virtual bool DoesAllowBlockOnTop() override
+ {
+ return false;
+ }
+
+
+ // Bed specific helper functions
+ static NIBBLETYPE RotationToMetaData(double a_Rotation)
+ {
+ a_Rotation += 180 + (180 / 4); // So its not aligned with axis
+ if (a_Rotation > 360) a_Rotation -= 360;
+
+ a_Rotation = (a_Rotation / 360) * 4;
+
+ return ((char)a_Rotation + 2) % 4;
+ }
+
+
+ static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData)
+ {
+ switch (a_MetaData)
+ {
+ case 0: return Vector3i(0, 0, 1);
+ case 1: return Vector3i(-1, 0, 0);
+ case 2: return Vector3i(0, 0, -1);
+ case 3: return Vector3i(1, 0, 0);
+ }
+ return Vector3i();
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockBrewingStand.h b/source/Blocks/BlockBrewingStand.h
index 34a2b6c56..57642bcb6 100644
--- a/source/Blocks/BlockBrewingStand.h
+++ b/source/Blocks/BlockBrewingStand.h
@@ -1,32 +1,32 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockBrewingStandHandler :
- public cBlockHandler
-{
-public:
- cBlockBrewingStandHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_BREWING_STAND, 1, 0));
- }
-
- virtual bool IsUseable() override
- {
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockBrewingStandHandler :
+ public cBlockHandler
+{
+public:
+ cBlockBrewingStandHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_BREWING_STAND, 1, 0));
+ }
+
+ virtual bool IsUseable() override
+ {
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockCactus.h b/source/Blocks/BlockCactus.h
index 516f024d8..1d123bc0a 100644
--- a/source/Blocks/BlockCactus.h
+++ b/source/Blocks/BlockCactus.h
@@ -1,88 +1,88 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockCactusHandler :
- public cBlockHandler
-{
-public:
- cBlockCactusHandler(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(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- if (a_RelY <= 0)
- {
- return false;
- }
- BLOCKTYPE Surface = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
- if ((Surface != E_BLOCK_SAND) && (Surface != E_BLOCK_CACTUS))
- {
- // Cactus can only be placed on sand and itself
- return false;
- }
-
- // Check surroundings. Cacti may ONLY be surrounded by air
- static const struct
- {
- int x, z;
- } Coords[] =
- {
- {-1, 0},
- { 1, 0},
- { 0, -1},
- { 0, 1},
- } ;
- for (int i = 0; i < ARRAYCOUNT(Coords); i++)
- {
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (
- a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta) &&
- (BlockType != E_BLOCK_AIR)
- )
- {
- return false;
- }
- } // for i - Coords[]
-
- return true;
- }
-
-
- virtual bool CanBePlacedOnSide(void) override
- {
- return false;
- }
-
-
- void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- a_World->GrowCactus(a_BlockX, a_BlockY, a_BlockZ, 1);
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.cloth";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockCactusHandler :
+ public cBlockHandler
+{
+public:
+ cBlockCactusHandler(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(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+ BLOCKTYPE Surface = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
+ if ((Surface != E_BLOCK_SAND) && (Surface != E_BLOCK_CACTUS))
+ {
+ // Cactus can only be placed on sand and itself
+ return false;
+ }
+
+ // Check surroundings. Cacti may ONLY be surrounded by air
+ static const struct
+ {
+ int x, z;
+ } Coords[] =
+ {
+ {-1, 0},
+ { 1, 0},
+ { 0, -1},
+ { 0, 1},
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(Coords); i++)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (
+ a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta) &&
+ (BlockType != E_BLOCK_AIR)
+ )
+ {
+ return false;
+ }
+ } // for i - Coords[]
+
+ return true;
+ }
+
+
+ virtual bool CanBePlacedOnSide(void) override
+ {
+ return false;
+ }
+
+
+ void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ a_World->GrowCactus(a_BlockX, a_BlockY, a_BlockZ, 1);
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.cloth";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockCauldron.h b/source/Blocks/BlockCauldron.h
index 571235441..b0e00f869 100644
--- a/source/Blocks/BlockCauldron.h
+++ b/source/Blocks/BlockCauldron.h
@@ -1,59 +1,59 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockCauldronHandler :
- public cBlockHandler
-{
-public:
- cBlockCauldronHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_CAULDRON, 1, 0));
- }
-
- void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
- {
- char Meta = a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ );
- switch( a_Player->GetEquippedItem().m_ItemType )
- {
- case E_ITEM_WATER_BUCKET:
- {
- a_World->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, 3 );
- a_Player->GetInventory().RemoveOneEquippedItem();
- cItem NewItem(E_ITEM_BUCKET, 1);
- a_Player->GetInventory().AddItem(NewItem);
- break;
- }
- case E_ITEM_GLASS_BOTTLE:
- {
- if( Meta > 0 )
- {
- a_World->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, --Meta);
- a_Player->GetInventory().RemoveOneEquippedItem();
- cItem NewItem(E_ITEM_POTIONS, 1, 0);
- a_Player->GetInventory().AddItem(NewItem);
- }
- break;
- }
- }
- }
-
- virtual bool IsUseable() override
- {
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockCauldronHandler :
+ public cBlockHandler
+{
+public:
+ cBlockCauldronHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_CAULDRON, 1, 0));
+ }
+
+ void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ char Meta = a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ );
+ switch( a_Player->GetEquippedItem().m_ItemType )
+ {
+ case E_ITEM_WATER_BUCKET:
+ {
+ a_World->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, 3 );
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ cItem NewItem(E_ITEM_BUCKET, 1);
+ a_Player->GetInventory().AddItem(NewItem);
+ break;
+ }
+ case E_ITEM_GLASS_BOTTLE:
+ {
+ if( Meta > 0 )
+ {
+ a_World->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, --Meta);
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ cItem NewItem(E_ITEM_POTIONS, 1, 0);
+ a_Player->GetInventory().AddItem(NewItem);
+ }
+ break;
+ }
+ }
+ }
+
+ virtual bool IsUseable() override
+ {
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockChest.h b/source/Blocks/BlockChest.h
index 5a64a16bb..1975e11b2 100644
--- a/source/Blocks/BlockChest.h
+++ b/source/Blocks/BlockChest.h
@@ -1,222 +1,222 @@
-
-#pragma once
-
-#include "BlockEntity.h"
-#include "../World.h"
-#include "../Player.h"
-
-
-
-
-
-class cBlockChestHandler :
- public cBlockEntityHandler
-{
-public:
- cBlockChestHandler(BLOCKTYPE a_BlockType)
- : cBlockEntityHandler(a_BlockType)
- {
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = m_BlockType;
-
- // Is there a doublechest already next to this block?
- if (!CanBeAt(a_World, a_BlockX, a_BlockY, a_BlockZ))
- {
- // Yup, cannot form a triple-chest, refuse:
- return false;
- }
-
- // Check if this forms a doublechest, if so, need to adjust the meta:
- cBlockArea Area;
- if (!Area.Read(a_World, a_BlockX - 1, a_BlockX + 1, a_BlockY, a_BlockY, a_BlockZ - 1, a_BlockZ + 1))
- {
- return false;
- }
- double rot = a_Player->GetRotation();
- if (
- (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
- )
- {
- a_BlockMeta = ((rot >= -90) && (rot < 90)) ? 2 : 3;
- return true;
- }
- if (
- (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
- )
- {
- a_BlockMeta = (rot < 0) ? 4 : 5;
- return true;
- }
-
- // Single chest, get meta from rotation only
- a_BlockMeta = RotationToMetaData(rot);
- return true;
- }
-
-
- virtual void OnPlacedByPlayer(
- cWorld * a_World, 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
- ) override
- {
- // Check if this forms a doublechest, if so, need to adjust the meta:
- cBlockArea Area;
- if (!Area.Read(a_World, a_BlockX - 1, a_BlockX + 1, a_BlockY, a_BlockY, a_BlockZ - 1, a_BlockZ + 1))
- {
- return;
- }
-
- double rot = a_Player->GetRotation();
- // Choose meta from player rotation, choose only between 2 or 3
- NIBBLETYPE NewMeta = ((rot >= -90) && (rot < 90)) ? 2 : 3;
- if (
- CheckAndAdjustNeighbor(a_World, Area, 0, 1, NewMeta) ||
- CheckAndAdjustNeighbor(a_World, Area, 2, 1, NewMeta)
- )
- {
- // Forming a double chest in the X direction
- return;
- }
- // Choose meta from player rotation, choose only between 4 or 5
- NewMeta = (rot < 0) ? 4 : 5;
- if (
- CheckAndAdjustNeighbor(a_World, Area, 1, 0, NewMeta) ||
- CheckAndAdjustNeighbor(a_World, Area, 2, 2, NewMeta)
- )
- {
- // Forming a double chest in the Z direction
- return;
- }
-
- // Single chest, no further processing needed
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-
-
- virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
- {
- cBlockArea Area;
- if (!Area.Read(a_World, a_BlockX - 2, a_BlockX + 2, a_BlockY, a_BlockY, a_BlockZ - 2, a_BlockZ + 2))
- {
- // Cannot read the surroundings, probably at the edge of loaded chunks. Disallow.
- return false;
- }
-
- int NumChestNeighbors = 0;
- if (Area.GetRelBlockType(1, 0, 2) == E_BLOCK_CHEST)
- {
- 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)
- )
- {
- // Already a doublechest neighbor, disallow:
- return false;
- }
- NumChestNeighbors += 1;
- }
- if (Area.GetRelBlockType(3, 0, 2) == E_BLOCK_CHEST)
- {
- 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)
- )
- {
- // Already a doublechest neighbor, disallow:
- return false;
- }
- NumChestNeighbors += 1;
- }
- if (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
- {
- 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)
- )
- {
- // Already a doublechest neighbor, disallow:
- return false;
- }
- NumChestNeighbors += 1;
- }
- if (Area.GetRelBlockType(2, 0, 3) == E_BLOCK_CHEST)
- {
- 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)
- )
- {
- // Already a doublechest neighbor, disallow:
- return false;
- }
- NumChestNeighbors += 1;
- }
- return (NumChestNeighbors < 2);
- }
-
-
- /// Translates player rotation when placing a chest into the chest block metadata. Valid for single chests only
- static NIBBLETYPE RotationToMetaData(double a_Rotation)
- {
- a_Rotation += 90 + 45; // So its not aligned with axis
-
- if (a_Rotation > 360.f)
- {
- a_Rotation -= 360.f;
- }
- if ((a_Rotation >= 0.f) && (a_Rotation < 90.f))
- {
- 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;
- }
- }
-
-
- /// If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true.
- bool CheckAndAdjustNeighbor(cWorld * a_World, 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)
- {
- return false;
- }
- a_World->SetBlockMeta(a_Area.GetOriginX() + a_RelX, a_Area.GetOriginY(), a_Area.GetOriginZ() + a_RelZ, a_NewMeta);
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockEntity.h"
+#include "../World.h"
+#include "../Player.h"
+
+
+
+
+
+class cBlockChestHandler :
+ public cBlockEntityHandler
+{
+public:
+ cBlockChestHandler(BLOCKTYPE a_BlockType)
+ : cBlockEntityHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = m_BlockType;
+
+ // Is there a doublechest already next to this block?
+ if (!CanBeAt(a_World, a_BlockX, a_BlockY, a_BlockZ))
+ {
+ // Yup, cannot form a triple-chest, refuse:
+ return false;
+ }
+
+ // Check if this forms a doublechest, if so, need to adjust the meta:
+ cBlockArea Area;
+ if (!Area.Read(a_World, a_BlockX - 1, a_BlockX + 1, a_BlockY, a_BlockY, a_BlockZ - 1, a_BlockZ + 1))
+ {
+ return false;
+ }
+ double rot = a_Player->GetRotation();
+ if (
+ (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
+ (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
+ )
+ {
+ a_BlockMeta = ((rot >= -90) && (rot < 90)) ? 2 : 3;
+ return true;
+ }
+ if (
+ (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
+ (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
+ )
+ {
+ a_BlockMeta = (rot < 0) ? 4 : 5;
+ return true;
+ }
+
+ // Single chest, get meta from rotation only
+ a_BlockMeta = RotationToMetaData(rot);
+ return true;
+ }
+
+
+ virtual void OnPlacedByPlayer(
+ cWorld * a_World, 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
+ ) override
+ {
+ // Check if this forms a doublechest, if so, need to adjust the meta:
+ cBlockArea Area;
+ if (!Area.Read(a_World, a_BlockX - 1, a_BlockX + 1, a_BlockY, a_BlockY, a_BlockZ - 1, a_BlockZ + 1))
+ {
+ return;
+ }
+
+ double rot = a_Player->GetRotation();
+ // Choose meta from player rotation, choose only between 2 or 3
+ NIBBLETYPE NewMeta = ((rot >= -90) && (rot < 90)) ? 2 : 3;
+ if (
+ CheckAndAdjustNeighbor(a_World, Area, 0, 1, NewMeta) ||
+ CheckAndAdjustNeighbor(a_World, Area, 2, 1, NewMeta)
+ )
+ {
+ // Forming a double chest in the X direction
+ return;
+ }
+ // Choose meta from player rotation, choose only between 4 or 5
+ NewMeta = (rot < 0) ? 4 : 5;
+ if (
+ CheckAndAdjustNeighbor(a_World, Area, 1, 0, NewMeta) ||
+ CheckAndAdjustNeighbor(a_World, Area, 2, 2, NewMeta)
+ )
+ {
+ // Forming a double chest in the Z direction
+ return;
+ }
+
+ // Single chest, no further processing needed
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+
+
+ virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ cBlockArea Area;
+ if (!Area.Read(a_World, a_BlockX - 2, a_BlockX + 2, a_BlockY, a_BlockY, a_BlockZ - 2, a_BlockZ + 2))
+ {
+ // Cannot read the surroundings, probably at the edge of loaded chunks. Disallow.
+ return false;
+ }
+
+ int NumChestNeighbors = 0;
+ if (Area.GetRelBlockType(1, 0, 2) == E_BLOCK_CHEST)
+ {
+ 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)
+ )
+ {
+ // Already a doublechest neighbor, disallow:
+ return false;
+ }
+ NumChestNeighbors += 1;
+ }
+ if (Area.GetRelBlockType(3, 0, 2) == E_BLOCK_CHEST)
+ {
+ 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)
+ )
+ {
+ // Already a doublechest neighbor, disallow:
+ return false;
+ }
+ NumChestNeighbors += 1;
+ }
+ if (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
+ {
+ 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)
+ )
+ {
+ // Already a doublechest neighbor, disallow:
+ return false;
+ }
+ NumChestNeighbors += 1;
+ }
+ if (Area.GetRelBlockType(2, 0, 3) == E_BLOCK_CHEST)
+ {
+ 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)
+ )
+ {
+ // Already a doublechest neighbor, disallow:
+ return false;
+ }
+ NumChestNeighbors += 1;
+ }
+ return (NumChestNeighbors < 2);
+ }
+
+
+ /// Translates player rotation when placing a chest into the chest block metadata. Valid for single chests only
+ static NIBBLETYPE RotationToMetaData(double a_Rotation)
+ {
+ a_Rotation += 90 + 45; // So its not aligned with axis
+
+ if (a_Rotation > 360.f)
+ {
+ a_Rotation -= 360.f;
+ }
+ if ((a_Rotation >= 0.f) && (a_Rotation < 90.f))
+ {
+ 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;
+ }
+ }
+
+
+ /// If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true.
+ bool CheckAndAdjustNeighbor(cWorld * a_World, 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)
+ {
+ return false;
+ }
+ a_World->SetBlockMeta(a_Area.GetOriginX() + a_RelX, a_Area.GetOriginY(), a_Area.GetOriginZ() + a_RelZ, a_NewMeta);
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockCloth.h b/source/Blocks/BlockCloth.h
index a95f12500..a136d3b9d 100644
--- a/source/Blocks/BlockCloth.h
+++ b/source/Blocks/BlockCloth.h
@@ -1,34 +1,34 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockClothHandler :
- public cBlockHandler
-{
-public:
- cBlockClothHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- 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";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockClothHandler :
+ public cBlockHandler
+{
+public:
+ cBlockClothHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ 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/source/Blocks/BlockCobWeb.h b/source/Blocks/BlockCobWeb.h
index 86bb6e773..982bfaa30 100644
--- a/source/Blocks/BlockCobWeb.h
+++ b/source/Blocks/BlockCobWeb.h
@@ -1,30 +1,30 @@
-
-// BlockCobWeb.h
-
-// Declares the cBlockCobWebHandler object representing the BlockHandler for cobwebs
-
-#pragma once
-
-
-
-
-
-class cBlockCobWebHandler :
- public cBlockHandler
-{
-public:
- cBlockCobWebHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0));
- }
-} ;
-
-
-
-
+
+// BlockCobWeb.h
+
+// Declares the cBlockCobWebHandler object representing the BlockHandler for cobwebs
+
+#pragma once
+
+
+
+
+
+class cBlockCobWebHandler :
+ public cBlockHandler
+{
+public:
+ cBlockCobWebHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0));
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h
index 7658d2633..4bc76fd50 100644
--- a/source/Blocks/BlockCrops.h
+++ b/source/Blocks/BlockCrops.h
@@ -1,108 +1,108 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../MersenneTwister.h"
-#include "../World.h"
-
-
-
-
-
-/// Common class that takes care of carrots, potatoes and wheat
-class cBlockCropsHandler :
- public cBlockHandler
-{
-public:
- cBlockCropsHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual bool DoesAllowBlockOnTop() override
- {
- return false;
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
- {
- MTRand rand;
-
- if (a_Meta == 0x7)
- {
- // Is fully grown, drop the entire produce:
- switch (m_BlockType)
- {
- case E_BLOCK_CROPS:
- {
- a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0));
- a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
- break;
- }
- case E_BLOCK_CARROTS:
- {
- a_Pickups.push_back(cItem(E_ITEM_CARROT, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
- break;
- }
- case E_BLOCK_POTATOES:
- {
- a_Pickups.push_back(cItem(E_ITEM_POTATO, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
- if (rand.randInt(20) == 0)
- {
- // With a 5% chance, drop a poisonous potato as well
- a_Pickups.push_back(cItem(E_ITEM_POISONOUS_POTATO, 1, 0));
- }
- break;
- }
- default:
- {
- ASSERT(!"Unhandled block type");
- break;
- }
- } // switch (m_BlockType)
- }
- else
- {
- // Drop 1 item of whatever is growing
- switch (m_BlockType)
- {
- case E_BLOCK_CROPS: a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0)); break;
- case E_BLOCK_CARROTS: a_Pickups.push_back(cItem(E_ITEM_CARROT, 1, 0)); break;
- case E_BLOCK_POTATOES: a_Pickups.push_back(cItem(E_ITEM_POTATO, 1, 0)); break;
- default:
- {
- ASSERT(!"Unhandled block type");
- break;
- }
- }
- }
- }
-
-
- void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if (Meta < 7)
- {
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_CROPS, ++Meta);
- }
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_FARMLAND));
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.grass";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../MersenneTwister.h"
+#include "../World.h"
+
+
+
+
+
+/// Common class that takes care of carrots, potatoes and wheat
+class cBlockCropsHandler :
+ public cBlockHandler
+{
+public:
+ cBlockCropsHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool DoesAllowBlockOnTop() override
+ {
+ return false;
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
+ {
+ MTRand rand;
+
+ if (a_Meta == 0x7)
+ {
+ // Is fully grown, drop the entire produce:
+ switch (m_BlockType)
+ {
+ case E_BLOCK_CROPS:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0));
+ a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
+ break;
+ }
+ case E_BLOCK_CARROTS:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_CARROT, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
+ break;
+ }
+ case E_BLOCK_POTATOES:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_POTATO, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
+ if (rand.randInt(20) == 0)
+ {
+ // With a 5% chance, drop a poisonous potato as well
+ a_Pickups.push_back(cItem(E_ITEM_POISONOUS_POTATO, 1, 0));
+ }
+ break;
+ }
+ default:
+ {
+ ASSERT(!"Unhandled block type");
+ break;
+ }
+ } // switch (m_BlockType)
+ }
+ else
+ {
+ // Drop 1 item of whatever is growing
+ switch (m_BlockType)
+ {
+ case E_BLOCK_CROPS: a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0)); break;
+ case E_BLOCK_CARROTS: a_Pickups.push_back(cItem(E_ITEM_CARROT, 1, 0)); break;
+ case E_BLOCK_POTATOES: a_Pickups.push_back(cItem(E_ITEM_POTATO, 1, 0)); break;
+ default:
+ {
+ ASSERT(!"Unhandled block type");
+ break;
+ }
+ }
+ }
+ }
+
+
+ void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ if (Meta < 7)
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_CROPS, ++Meta);
+ }
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_FARMLAND));
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.grass";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockDeadBush.h b/source/Blocks/BlockDeadBush.h
index be0e77e55..379e8e5df 100644
--- a/source/Blocks/BlockDeadBush.h
+++ b/source/Blocks/BlockDeadBush.h
@@ -1,47 +1,47 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockDeadBushHandler :
- public cBlockHandler
-{
-public:
- cBlockDeadBushHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Don't drop anything
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return (a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_SAND);
- }
-
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- virtual bool CanBePlacedOnSide() override
- {
- return false;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockDeadBushHandler :
+ public cBlockHandler
+{
+public:
+ cBlockDeadBushHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Don't drop anything
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ return (a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_SAND);
+ }
+
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ virtual bool CanBePlacedOnSide() override
+ {
+ return false;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockDirt.h b/source/Blocks/BlockDirt.h
index 6cec5d99e..b2bc4756c 100644
--- a/source/Blocks/BlockDirt.h
+++ b/source/Blocks/BlockDirt.h
@@ -1,88 +1,88 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../MersenneTwister.h"
-#include "../World.h"
-
-
-
-
-
-/// Handler used for both dirt and grass
-class cBlockDirtHandler :
- public cBlockHandler
-{
-public:
- cBlockDirtHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0));
- }
-
-
- virtual void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- if (m_BlockType != E_BLOCK_GRASS)
- {
- return;
- }
-
- // Grass becomes dirt if there is something on top of it:
- if (a_BlockY < cChunkDef::Height - 1)
- {
- BLOCKTYPE Above = a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ);
- if (!g_BlockTransparent[Above] && !g_BlockOneHitDig[Above])
- {
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DIRT, 0);
- return;
- }
- }
-
- // Grass spreads to adjacent blocks:
- MTRand rand;
- for (int i = 0; i < 2; i++) // Pick two blocks to grow to
- {
- int OfsX = rand.randInt(2) - 1; // [-1 .. 1]
- int OfsY = rand.randInt(4) - 3; // [-3 .. 1]
- int OfsZ = rand.randInt(2) - 1; // [-1 .. 1]
-
- BLOCKTYPE DestBlock;
- NIBBLETYPE DestMeta;
- if ((a_BlockY + OfsY < 0) || (a_BlockY + OfsY >= cChunkDef::Height - 1))
- {
- // Y Coord out of range
- continue;
- }
- bool IsValid = a_World->GetBlockTypeMeta(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, DestBlock, DestMeta);
- if (!IsValid || (DestBlock != E_BLOCK_DIRT))
- {
- continue;
- }
-
- BLOCKTYPE AboveDest;
- NIBBLETYPE AboveMeta;
- IsValid = a_World->GetBlockTypeMeta(a_BlockX + OfsX, a_BlockY + OfsY + 1, a_BlockZ + OfsZ, AboveDest, AboveMeta);
- ASSERT(IsValid); // WTF - how did we get the DestBlock if AboveBlock is not valid?
- if (g_BlockOneHitDig[AboveDest] || g_BlockTransparent[AboveDest])
- {
- a_World->FastSetBlock(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, E_BLOCK_GRASS, 0);
- }
- } // for i - repeat twice
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.gravel";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../MersenneTwister.h"
+#include "../World.h"
+
+
+
+
+
+/// Handler used for both dirt and grass
+class cBlockDirtHandler :
+ public cBlockHandler
+{
+public:
+ cBlockDirtHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0));
+ }
+
+
+ virtual void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ if (m_BlockType != E_BLOCK_GRASS)
+ {
+ return;
+ }
+
+ // Grass becomes dirt if there is something on top of it:
+ if (a_BlockY < cChunkDef::Height - 1)
+ {
+ BLOCKTYPE Above = a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ);
+ if (!g_BlockTransparent[Above] && !g_BlockOneHitDig[Above])
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DIRT, 0);
+ return;
+ }
+ }
+
+ // Grass spreads to adjacent blocks:
+ MTRand rand;
+ for (int i = 0; i < 2; i++) // Pick two blocks to grow to
+ {
+ int OfsX = rand.randInt(2) - 1; // [-1 .. 1]
+ int OfsY = rand.randInt(4) - 3; // [-3 .. 1]
+ int OfsZ = rand.randInt(2) - 1; // [-1 .. 1]
+
+ BLOCKTYPE DestBlock;
+ NIBBLETYPE DestMeta;
+ if ((a_BlockY + OfsY < 0) || (a_BlockY + OfsY >= cChunkDef::Height - 1))
+ {
+ // Y Coord out of range
+ continue;
+ }
+ bool IsValid = a_World->GetBlockTypeMeta(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, DestBlock, DestMeta);
+ if (!IsValid || (DestBlock != E_BLOCK_DIRT))
+ {
+ continue;
+ }
+
+ BLOCKTYPE AboveDest;
+ NIBBLETYPE AboveMeta;
+ IsValid = a_World->GetBlockTypeMeta(a_BlockX + OfsX, a_BlockY + OfsY + 1, a_BlockZ + OfsZ, AboveDest, AboveMeta);
+ ASSERT(IsValid); // WTF - how did we get the DestBlock if AboveBlock is not valid?
+ if (g_BlockOneHitDig[AboveDest] || g_BlockTransparent[AboveDest])
+ {
+ a_World->FastSetBlock(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, E_BLOCK_GRASS, 0);
+ }
+ } // for i - repeat twice
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.gravel";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockDoor.cpp b/source/Blocks/BlockDoor.cpp
index 49ce56e07..b2fe273c5 100644
--- a/source/Blocks/BlockDoor.cpp
+++ b/source/Blocks/BlockDoor.cpp
@@ -1,88 +1,88 @@
-
-#include "Globals.h"
-#include "BlockDoor.h"
-#include "../Item.h"
-#include "../World.h"
-#include "../Doors.h"
-#include "../Player.h"
-
-
-
-
-
-cBlockDoorHandler::cBlockDoorHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockDoorHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- NIBBLETYPE OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
-
- if (OldMeta & 8)
- {
- // Was upper part of door
- if (cDoors::IsDoor(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ)))
- {
- a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_AIR, 0);
- }
- }
- else
- {
- // Was lower part
- if (cDoors::IsDoor(a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ)))
- {
- a_World->FastSetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, E_BLOCK_AIR, 0);
- }
- }
-}
-
-
-
-
-
-void cBlockDoorHandler::OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
-{
- cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
-}
-
-
-
-
-
-void cBlockDoorHandler::OnPlacedByPlayer(
- cWorld * a_World, 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
-)
-{
- NIBBLETYPE a_TopBlockMeta = 8;
- if (
- (a_BlockMeta == 0) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1) == m_BlockType) ||
- (a_BlockMeta == 1) && (a_World->GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) == m_BlockType) ||
- (a_BlockMeta == 2) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) == m_BlockType) ||
- (a_BlockMeta == 3) && (a_World->GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) == m_BlockType)
- )
- {
- a_TopBlockMeta = 9;
- }
- a_World->SetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, m_BlockType, a_TopBlockMeta);
-}
-
-
-
-
-
-const char * cBlockDoorHandler::GetStepSound(void)
-{
- return (m_BlockType == E_BLOCK_WOODEN_DOOR) ? "step.wood" : "step.stone";
-}
-
-
-
-
+
+#include "Globals.h"
+#include "BlockDoor.h"
+#include "../Item.h"
+#include "../World.h"
+#include "../Doors.h"
+#include "../Player.h"
+
+
+
+
+
+cBlockDoorHandler::cBlockDoorHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+{
+}
+
+
+
+
+
+void cBlockDoorHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ NIBBLETYPE OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+
+ if (OldMeta & 8)
+ {
+ // Was upper part of door
+ if (cDoors::IsDoor(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ)))
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_AIR, 0);
+ }
+ }
+ else
+ {
+ // Was lower part
+ if (cDoors::IsDoor(a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ)))
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, E_BLOCK_AIR, 0);
+ }
+ }
+}
+
+
+
+
+
+void cBlockDoorHandler::OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+{
+ cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
+}
+
+
+
+
+
+void cBlockDoorHandler::OnPlacedByPlayer(
+ cWorld * a_World, 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
+)
+{
+ NIBBLETYPE a_TopBlockMeta = 8;
+ if (
+ (a_BlockMeta == 0) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1) == m_BlockType) ||
+ (a_BlockMeta == 1) && (a_World->GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) == m_BlockType) ||
+ (a_BlockMeta == 2) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) == m_BlockType) ||
+ (a_BlockMeta == 3) && (a_World->GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) == m_BlockType)
+ )
+ {
+ a_TopBlockMeta = 9;
+ }
+ a_World->SetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, m_BlockType, a_TopBlockMeta);
+}
+
+
+
+
+
+const char * cBlockDoorHandler::GetStepSound(void)
+{
+ return (m_BlockType == E_BLOCK_WOODEN_DOOR) ? "step.wood" : "step.stone";
+}
+
+
+
+
diff --git a/source/Blocks/BlockDoor.h b/source/Blocks/BlockDoor.h
index a988c2d4b..19701ffc9 100644
--- a/source/Blocks/BlockDoor.h
+++ b/source/Blocks/BlockDoor.h
@@ -1,105 +1,105 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-#include "../Doors.h"
-#include "../Player.h"
-
-
-
-
-
-class cBlockDoorHandler :
- public cBlockHandler
-{
-public:
- cBlockDoorHandler(BLOCKTYPE a_BlockType);
-
- virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
- virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
- virtual const char * GetStepSound(void) override;
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- // If clicking a bottom face, place the door one block lower:
- if (a_BlockFace == BLOCK_FACE_BOTTOM)
- {
- a_BlockY--;
- }
-
- if (
- !CanReplaceBlock(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ)) ||
- !CanReplaceBlock(a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))
- )
- {
- return false;
- }
-
- a_BlockType = m_BlockType;
- a_BlockMeta = cDoors::RotationToMetaData(a_Player->GetRotation());
- 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));
- }
-
-
- virtual void OnPlacedByPlayer(
- cWorld * a_World, 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
- ) override;
-
-
- virtual bool IsUseable(void) override
- {
- return true;
- }
-
-
- virtual bool CanBePlacedOnSide(void) override
- {
- return false;
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- 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)
- {
- case E_BLOCK_AIR:
- case E_BLOCK_TALL_GRASS:
- case E_BLOCK_WATER:
- case E_BLOCK_STATIONARY_WATER:
- case E_BLOCK_LAVA:
- case E_BLOCK_STATIONARY_LAVA:
- case E_BLOCK_SNOW:
- case E_BLOCK_FIRE:
- {
- return true;
- }
- }
- return false;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+#include "../Doors.h"
+#include "../Player.h"
+
+
+
+
+
+class cBlockDoorHandler :
+ public cBlockHandler
+{
+public:
+ cBlockDoorHandler(BLOCKTYPE a_BlockType);
+
+ virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
+ virtual const char * GetStepSound(void) override;
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ // If clicking a bottom face, place the door one block lower:
+ if (a_BlockFace == BLOCK_FACE_BOTTOM)
+ {
+ a_BlockY--;
+ }
+
+ if (
+ !CanReplaceBlock(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ)) ||
+ !CanReplaceBlock(a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))
+ )
+ {
+ return false;
+ }
+
+ a_BlockType = m_BlockType;
+ a_BlockMeta = cDoors::RotationToMetaData(a_Player->GetRotation());
+ 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));
+ }
+
+
+ virtual void OnPlacedByPlayer(
+ cWorld * a_World, 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
+ ) override;
+
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+
+
+ virtual bool CanBePlacedOnSide(void) override
+ {
+ return false;
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ 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)
+ {
+ case E_BLOCK_AIR:
+ case E_BLOCK_TALL_GRASS:
+ case E_BLOCK_WATER:
+ case E_BLOCK_STATIONARY_WATER:
+ case E_BLOCK_LAVA:
+ case E_BLOCK_STATIONARY_LAVA:
+ case E_BLOCK_SNOW:
+ case E_BLOCK_FIRE:
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockDropSpenser.h b/source/Blocks/BlockDropSpenser.h
index bcc75758d..cfb607a7b 100644
--- a/source/Blocks/BlockDropSpenser.h
+++ b/source/Blocks/BlockDropSpenser.h
@@ -1,39 +1,39 @@
-
-// BlockDropSpenser.h
-
-// Declares the cBlockDropSpenserHandler class representing the BlockHandler for Dropper and Dispenser blocks
-
-#pragma once
-
-
-
-
-
-class cBlockDropSpenserHandler :
- public cBlockEntityHandler
-{
-public:
- cBlockDropSpenserHandler(BLOCKTYPE a_BlockType) :
- cBlockEntityHandler(a_BlockType)
- {
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = m_BlockType;
-
- // FIXME: Do not use cPiston class for dispenser placement!
- a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0);
- return true;
- }
-} ;
-
-
-
-
+
+// BlockDropSpenser.h
+
+// Declares the cBlockDropSpenserHandler class representing the BlockHandler for Dropper and Dispenser blocks
+
+#pragma once
+
+
+
+
+
+class cBlockDropSpenserHandler :
+ public cBlockEntityHandler
+{
+public:
+ cBlockDropSpenserHandler(BLOCKTYPE a_BlockType) :
+ cBlockEntityHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = m_BlockType;
+
+ // FIXME: Do not use cPiston class for dispenser placement!
+ a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0);
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockEnderchest.h b/source/Blocks/BlockEnderchest.h
index b40deb1f7..0ce813f1c 100644
--- a/source/Blocks/BlockEnderchest.h
+++ b/source/Blocks/BlockEnderchest.h
@@ -1,28 +1,28 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockEnderchestHandler :
- public cBlockHandler
-{
-public:
- cBlockEnderchestHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- //todo: Drop Ender Chest if using silk touch pickaxe
- a_Pickups.push_back(cItem(E_BLOCK_OBSIDIAN, 8, 0));
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockEnderchestHandler :
+ public cBlockHandler
+{
+public:
+ cBlockEnderchestHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ //todo: Drop Ender Chest if using silk touch pickaxe
+ a_Pickups.push_back(cItem(E_BLOCK_OBSIDIAN, 8, 0));
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockEntity.h b/source/Blocks/BlockEntity.h
index 8b82b43a6..9c6b23665 100644
--- a/source/Blocks/BlockEntity.h
+++ b/source/Blocks/BlockEntity.h
@@ -1,31 +1,31 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockEntityHandler : public cBlockHandler
-{
-public:
- cBlockEntityHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void OnUse(cWorld * a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
- {
- a_World->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
- }
-
- virtual bool IsUseable() override
- {
- return true;
- }
-};
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockEntityHandler : public cBlockHandler
+{
+public:
+ cBlockEntityHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void OnUse(cWorld * a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
+ {
+ a_World->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
+ }
+
+ virtual bool IsUseable() override
+ {
+ return true;
+ }
+};
+
+
+
+
diff --git a/source/Blocks/BlockFarmland.h b/source/Blocks/BlockFarmland.h
index fb2d91a86..6cab1fa38 100644
--- a/source/Blocks/BlockFarmland.h
+++ b/source/Blocks/BlockFarmland.h
@@ -1,99 +1,99 @@
-
-// BlockFarmland.h
-
-// Declares the cBlcokFarmlandHandler representing the block handler for farmland
-
-
-
-
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../BlockArea.h"
-
-
-
-
-
-class cBlockFarmlandHandler :
- public cBlockHandler
-{
- typedef cBlockHandler super;
-
-public:
- cBlockFarmlandHandler(void) :
- super(E_BLOCK_FARMLAND)
- {
- }
-
-
- virtual void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- // TODO: Rain hydrates farmland, too. Check world weather, don't search for water if raining.
- // NOTE: The desert biomes do not get precipitation, so another check needs to be made.
-
- // Search for water in a close proximity:
- // Ref.: http://www.minecraftwiki.net/wiki/Farmland#Hydrated_Farmland_Tiles
- cBlockArea Area;
- if (!Area.Read(a_World, a_BlockX - 4, a_BlockX + 4, a_BlockY, a_BlockY + 1, a_BlockZ - 4, a_BlockZ + 4))
- {
- // Too close to the world edge, cannot check surroudnings; don't tick at all
- return;
- }
- bool Found = false;
- int NumBlocks = Area.GetBlockCount();
- BLOCKTYPE * BlockTypes = Area.GetBlockTypes();
- for (int i = 0; i < NumBlocks; i++)
- {
- if (
- (BlockTypes[i] == E_BLOCK_WATER) ||
- (BlockTypes[i] == E_BLOCK_STATIONARY_WATER)
- )
- {
- Found = true;
- break;
- }
- }
-
- NIBBLETYPE BlockMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
-
- if (Found)
- {
- // Water was found, hydrate the block until hydration reaches 7:
- if (BlockMeta < 7)
- {
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, ++BlockMeta);
- }
- return;
- }
-
- // Water wasn't found, de-hydrate block:
- if (BlockMeta > 0)
- {
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FARMLAND, --BlockMeta);
- return;
- }
-
- // Farmland too dry. If nothing is growing on top, turn back to dirt:
- switch (a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))
- {
- case E_BLOCK_CROPS:
- case E_BLOCK_MELON_STEM:
- case E_BLOCK_PUMPKIN_STEM:
- {
- // Produce on top, don't revert
- break;
- }
- default:
- {
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DIRT, 0);
- break;
- }
- }
- }
-} ;
-
-
-
-
+
+// BlockFarmland.h
+
+// Declares the cBlcokFarmlandHandler representing the block handler for farmland
+
+
+
+
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../BlockArea.h"
+
+
+
+
+
+class cBlockFarmlandHandler :
+ public cBlockHandler
+{
+ typedef cBlockHandler super;
+
+public:
+ cBlockFarmlandHandler(void) :
+ super(E_BLOCK_FARMLAND)
+ {
+ }
+
+
+ virtual void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ // TODO: Rain hydrates farmland, too. Check world weather, don't search for water if raining.
+ // NOTE: The desert biomes do not get precipitation, so another check needs to be made.
+
+ // Search for water in a close proximity:
+ // Ref.: http://www.minecraftwiki.net/wiki/Farmland#Hydrated_Farmland_Tiles
+ cBlockArea Area;
+ if (!Area.Read(a_World, a_BlockX - 4, a_BlockX + 4, a_BlockY, a_BlockY + 1, a_BlockZ - 4, a_BlockZ + 4))
+ {
+ // Too close to the world edge, cannot check surroudnings; don't tick at all
+ return;
+ }
+ bool Found = false;
+ int NumBlocks = Area.GetBlockCount();
+ BLOCKTYPE * BlockTypes = Area.GetBlockTypes();
+ for (int i = 0; i < NumBlocks; i++)
+ {
+ if (
+ (BlockTypes[i] == E_BLOCK_WATER) ||
+ (BlockTypes[i] == E_BLOCK_STATIONARY_WATER)
+ )
+ {
+ Found = true;
+ break;
+ }
+ }
+
+ NIBBLETYPE BlockMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+
+ if (Found)
+ {
+ // Water was found, hydrate the block until hydration reaches 7:
+ if (BlockMeta < 7)
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, ++BlockMeta);
+ }
+ return;
+ }
+
+ // Water wasn't found, de-hydrate block:
+ if (BlockMeta > 0)
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FARMLAND, --BlockMeta);
+ return;
+ }
+
+ // Farmland too dry. If nothing is growing on top, turn back to dirt:
+ switch (a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))
+ {
+ case E_BLOCK_CROPS:
+ case E_BLOCK_MELON_STEM:
+ case E_BLOCK_PUMPKIN_STEM:
+ {
+ // Produce on top, don't revert
+ break;
+ }
+ default:
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DIRT, 0);
+ break;
+ }
+ }
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockFenceGate.h b/source/Blocks/BlockFenceGate.h
index a84ce8303..d6f8aa85f 100644
--- a/source/Blocks/BlockFenceGate.h
+++ b/source/Blocks/BlockFenceGate.h
@@ -1,60 +1,60 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../Doors.h"
-
-
-
-
-
-class cBlockFenceGateHandler :
- public cBlockHandler
-{
-public:
- cBlockFenceGateHandler(BLOCKTYPE a_BlockType) :
- cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = m_BlockType;
- a_BlockMeta = cDoors::RotationToMetaData(a_Player->GetRotation() + 270);
- return true;
- }
-
-
- virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
- {
- NIBBLETYPE OldMetaData = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- NIBBLETYPE NewMetaData = cDoors::RotationToMetaData(a_Player->GetRotation() + 270);
- OldMetaData ^= 4; // Toggle the gate
- if ((OldMetaData & 1) == (NewMetaData & 1))
- {
- // Standing in front of the gate - apply new direction
- a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, (OldMetaData & 4) | (NewMetaData & 3));
- }
- else
- {
- // Standing aside - use last direction
- a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, OldMetaData);
- }
- }
-
-
- virtual bool IsUseable(void) override
- {
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../Doors.h"
+
+
+
+
+
+class cBlockFenceGateHandler :
+ public cBlockHandler
+{
+public:
+ cBlockFenceGateHandler(BLOCKTYPE a_BlockType) :
+ cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = m_BlockType;
+ a_BlockMeta = cDoors::RotationToMetaData(a_Player->GetRotation() + 270);
+ return true;
+ }
+
+
+ virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
+ {
+ NIBBLETYPE OldMetaData = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ NIBBLETYPE NewMetaData = cDoors::RotationToMetaData(a_Player->GetRotation() + 270);
+ OldMetaData ^= 4; // Toggle the gate
+ if ((OldMetaData & 1) == (NewMetaData & 1))
+ {
+ // Standing in front of the gate - apply new direction
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, (OldMetaData & 4) | (NewMetaData & 3));
+ }
+ else
+ {
+ // Standing aside - use last direction
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, OldMetaData);
+ }
+ }
+
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockFire.h b/source/Blocks/BlockFire.h
index 7da66f982..d3ba499b1 100644
--- a/source/Blocks/BlockFire.h
+++ b/source/Blocks/BlockFire.h
@@ -1,42 +1,42 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockFireHandler :
- public cBlockHandler
-{
-public:
- cBlockFireHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- a_World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // No pickups from this block
- }
-
- virtual bool IsClickedThrough(void) override
- {
- return true;
- }
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockFireHandler :
+ public cBlockHandler
+{
+public:
+ cBlockFireHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ a_World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // No pickups from this block
+ }
+
+ virtual bool IsClickedThrough(void) override
+ {
+ return true;
+ }
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockFlower.h b/source/Blocks/BlockFlower.h
index b46273c51..202609538 100644
--- a/source/Blocks/BlockFlower.h
+++ b/source/Blocks/BlockFlower.h
@@ -1,53 +1,53 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockFlowerHandler :
- public cBlockHandler
-{
-public:
- cBlockFlowerHandler(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(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ));
- }
-
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- virtual bool CanBePlacedOnSide(void) override
- {
- return false;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.grass";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockFlowerHandler :
+ public cBlockHandler
+{
+public:
+ cBlockFlowerHandler(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(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ));
+ }
+
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ virtual bool CanBePlacedOnSide(void) override
+ {
+ return false;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.grass";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockFlowerPot.h b/source/Blocks/BlockFlowerPot.h
index 12cd594de..b0faf5218 100644
--- a/source/Blocks/BlockFlowerPot.h
+++ b/source/Blocks/BlockFlowerPot.h
@@ -1,105 +1,105 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockFlowerPotHandler :
- public cBlockHandler
-{
-public:
- cBlockFlowerPotHandler(BLOCKTYPE a_BlockType) :
- cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0));
- if (a_BlockMeta == 0)
- {
- return;
- }
- cItem Plant;
- switch (a_BlockMeta)
- {
- case 1: Plant = cItem(E_BLOCK_RED_ROSE, 1, 0); break;
- case 2: Plant = cItem(E_BLOCK_YELLOW_FLOWER, 1, 0); break;
- case 3: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_APPLE); break;
- case 4: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_CONIFER); break;
- case 5: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_BIRCH); break;
- case 6: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_JUNGLE); break;
- case 7: Plant = cItem(E_BLOCK_RED_MUSHROOM, 1, 0); break;
- case 8: Plant = cItem(E_BLOCK_BROWN_MUSHROOM, 1, 0); break;
- case 9: Plant = cItem(E_BLOCK_CACTUS, 1, 0); break;
- case 10: Plant = cItem(E_BLOCK_DEAD_BUSH, 1, 0); break;
- case 11: Plant = cItem(E_BLOCK_TALL_GRASS, 1, E_META_TALL_GRASS_FERN); break;
- default: return;
- }
- a_Pickups.push_back(Plant);
- }
-
-
- void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
- {
- NIBBLETYPE Meta = a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ );
- if (Meta != 0)
- {
- // Already filled
- return;
- }
-
- switch (a_Player->GetEquippedItem().m_ItemType)
- {
- case E_BLOCK_RED_ROSE: Meta = 1; break;
- case E_BLOCK_YELLOW_FLOWER: Meta = 2; break;
- case E_BLOCK_SAPLING:
- {
- switch (a_Player->GetEquippedItem().m_ItemDamage)
- {
- case E_META_SAPLING_APPLE: Meta = 3; break;
- case E_META_SAPLING_CONIFER: Meta = 4; break;
- case E_META_SAPLING_BIRCH: Meta = 5; break;
- case E_META_SAPLING_JUNGLE: Meta = 6; break;
- }
- break;
- }
- case E_BLOCK_RED_MUSHROOM: Meta = 7; break;
- case E_BLOCK_BROWN_MUSHROOM: Meta = 8; break;
- case E_BLOCK_CACTUS: Meta = 9; break;
- case E_BLOCK_DEAD_BUSH: Meta = 10; break;
- case E_BLOCK_TALL_GRASS:
- {
- if (a_Player->GetEquippedItem().m_ItemDamage == E_META_TALL_GRASS_FERN)
- {
- Meta = 11;
- }
- else
- {
- return;
- }
- break;
- }
- }
-
- if (a_Player->GetGameMode() != gmCreative)
- {
- a_Player->GetInventory().RemoveOneEquippedItem();
- }
- a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
- }
-
-
- virtual bool IsUseable(void) override
- {
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockFlowerPotHandler :
+ public cBlockHandler
+{
+public:
+ cBlockFlowerPotHandler(BLOCKTYPE a_BlockType) :
+ cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0));
+ if (a_BlockMeta == 0)
+ {
+ return;
+ }
+ cItem Plant;
+ switch (a_BlockMeta)
+ {
+ case 1: Plant = cItem(E_BLOCK_RED_ROSE, 1, 0); break;
+ case 2: Plant = cItem(E_BLOCK_YELLOW_FLOWER, 1, 0); break;
+ case 3: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_APPLE); break;
+ case 4: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_CONIFER); break;
+ case 5: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_BIRCH); break;
+ case 6: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_JUNGLE); break;
+ case 7: Plant = cItem(E_BLOCK_RED_MUSHROOM, 1, 0); break;
+ case 8: Plant = cItem(E_BLOCK_BROWN_MUSHROOM, 1, 0); break;
+ case 9: Plant = cItem(E_BLOCK_CACTUS, 1, 0); break;
+ case 10: Plant = cItem(E_BLOCK_DEAD_BUSH, 1, 0); break;
+ case 11: Plant = cItem(E_BLOCK_TALL_GRASS, 1, E_META_TALL_GRASS_FERN); break;
+ default: return;
+ }
+ a_Pickups.push_back(Plant);
+ }
+
+
+ void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ NIBBLETYPE Meta = a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ );
+ if (Meta != 0)
+ {
+ // Already filled
+ return;
+ }
+
+ switch (a_Player->GetEquippedItem().m_ItemType)
+ {
+ case E_BLOCK_RED_ROSE: Meta = 1; break;
+ case E_BLOCK_YELLOW_FLOWER: Meta = 2; break;
+ case E_BLOCK_SAPLING:
+ {
+ switch (a_Player->GetEquippedItem().m_ItemDamage)
+ {
+ case E_META_SAPLING_APPLE: Meta = 3; break;
+ case E_META_SAPLING_CONIFER: Meta = 4; break;
+ case E_META_SAPLING_BIRCH: Meta = 5; break;
+ case E_META_SAPLING_JUNGLE: Meta = 6; break;
+ }
+ break;
+ }
+ case E_BLOCK_RED_MUSHROOM: Meta = 7; break;
+ case E_BLOCK_BROWN_MUSHROOM: Meta = 8; break;
+ case E_BLOCK_CACTUS: Meta = 9; break;
+ case E_BLOCK_DEAD_BUSH: Meta = 10; break;
+ case E_BLOCK_TALL_GRASS:
+ {
+ if (a_Player->GetEquippedItem().m_ItemDamage == E_META_TALL_GRASS_FERN)
+ {
+ Meta = 11;
+ }
+ else
+ {
+ return;
+ }
+ break;
+ }
+ }
+
+ if (a_Player->GetGameMode() != gmCreative)
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ }
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
+ }
+
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockFluid.h b/source/Blocks/BlockFluid.h
index b184a5b33..696bfb3ce 100644
--- a/source/Blocks/BlockFluid.h
+++ b/source/Blocks/BlockFluid.h
@@ -1,50 +1,50 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockFluidHandler :
- public cBlockHandler
-{
- typedef cBlockHandler super;
-
-public:
- cBlockFluidHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
-
- }
-
-
- virtual bool DoesIgnoreBuildCollision(void) override
- {
- return true;
- }
-
-
- virtual void Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
- {
- switch (m_BlockType)
- {
- case E_BLOCK_STATIONARY_LAVA:
- {
- a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_LAVA, a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
- break;
- }
- case E_BLOCK_STATIONARY_WATER:
- {
- a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_WATER, a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
- break;
- }
- }
- super::Check(a_RelX, a_RelY, a_RelZ, a_Chunk);
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockFluidHandler :
+ public cBlockHandler
+{
+ typedef cBlockHandler super;
+
+public:
+ cBlockFluidHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+
+ }
+
+
+ virtual bool DoesIgnoreBuildCollision(void) override
+ {
+ return true;
+ }
+
+
+ virtual void Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
+ {
+ switch (m_BlockType)
+ {
+ case E_BLOCK_STATIONARY_LAVA:
+ {
+ a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_LAVA, a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
+ break;
+ }
+ case E_BLOCK_STATIONARY_WATER:
+ {
+ a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_WATER, a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
+ break;
+ }
+ }
+ super::Check(a_RelX, a_RelY, a_RelZ, a_Chunk);
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockFurnace.h b/source/Blocks/BlockFurnace.h
index 7231c4d65..b358a1d71 100644
--- a/source/Blocks/BlockFurnace.h
+++ b/source/Blocks/BlockFurnace.h
@@ -1,47 +1,47 @@
-
-#pragma once
-
-#include "BlockEntity.h"
-#include "../World.h"
-#include "../Piston.h"
-#include "../Player.h"
-
-
-
-
-
-class cBlockFurnaceHandler :
- public cBlockEntityHandler
-{
-public:
- cBlockFurnaceHandler(BLOCKTYPE a_BlockType) :
- cBlockEntityHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_BLOCK_FURNACE, 1, 0));
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = m_BlockType;
-
- // FIXME: Do not use cPiston class for furnace placement!
- a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0);
-
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockEntity.h"
+#include "../World.h"
+#include "../Piston.h"
+#include "../Player.h"
+
+
+
+
+
+class cBlockFurnaceHandler :
+ public cBlockEntityHandler
+{
+public:
+ cBlockFurnaceHandler(BLOCKTYPE a_BlockType) :
+ cBlockEntityHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_BLOCK_FURNACE, 1, 0));
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = m_BlockType;
+
+ // FIXME: Do not use cPiston class for furnace placement!
+ a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0);
+
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockGlass.h b/source/Blocks/BlockGlass.h
index d5147af96..f6958bbb6 100644
--- a/source/Blocks/BlockGlass.h
+++ b/source/Blocks/BlockGlass.h
@@ -1,26 +1,26 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockGlassHandler :
- public cBlockHandler
-{
-public:
- cBlockGlassHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockGlassHandler :
+ public cBlockHandler
+{
+public:
+ cBlockGlassHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockGlowstone.h b/source/Blocks/BlockGlowstone.h
index 5ff9394b7..5f0d95dee 100644
--- a/source/Blocks/BlockGlowstone.h
+++ b/source/Blocks/BlockGlowstone.h
@@ -1,30 +1,30 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockGlowstoneHandler :
- public cBlockHandler
-{
-public:
- cBlockGlowstoneHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Reset meta to 0
- // TODO: More drops?
- a_Pickups.push_back(cItem(E_ITEM_GLOWSTONE_DUST, 1, 0));
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockGlowstoneHandler :
+ public cBlockHandler
+{
+public:
+ cBlockGlowstoneHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ // TODO: More drops?
+ a_Pickups.push_back(cItem(E_ITEM_GLOWSTONE_DUST, 1, 0));
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockGravel.h b/source/Blocks/BlockGravel.h
index 6324fe06f..e1c9ff390 100644
--- a/source/Blocks/BlockGravel.h
+++ b/source/Blocks/BlockGravel.h
@@ -1,27 +1,27 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockGravelHandler :
- public cBlockHandler
-{
-public:
- cBlockGravelHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual const char * GetStepSound(void) override
- {
- return "step.gravel";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockGravelHandler :
+ public cBlockHandler
+{
+public:
+ cBlockGravelHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.gravel";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp
index a853c6f68..550a6795c 100644
--- a/source/Blocks/BlockHandler.cpp
+++ b/source/Blocks/BlockHandler.cpp
@@ -1,453 +1,453 @@
-
-#include "Globals.h"
-#include "BlockHandler.h"
-#include "../Item.h"
-#include "../World.h"
-#include "../Root.h"
-#include "../PluginManager.h"
-#include "BlockSand.h"
-#include "BlockGravel.h"
-#include "BlockDoor.h"
-#include "BlockFire.h"
-#include "BlockRedstone.h"
-#include "BlockRedstoneTorch.h"
-#include "BlockRedstoneRepeater.h"
-#include "BlockPiston.h"
-#include "BlockWorkbench.h"
-#include "BlockEntity.h"
-#include "BlockVine.h"
-#include "BlockTallGrass.h"
-#include "BlockSnow.h"
-#include "BlockCloth.h"
-#include "BlockSlab.h"
-#include "BlockDirt.h"
-#include "BlockTorch.h"
-#include "BlockWood.h"
-#include "BlockLeaves.h"
-#include "BlockSapling.h"
-#include "BlockFluid.h"
-#include "BlockChest.h"
-#include "BlockFurnace.h"
-#include "BlockDropSpenser.h"
-#include "BlockStairs.h"
-#include "BlockLadder.h"
-#include "BlockLever.h"
-#include "BlockSign.h"
-#include "BlockCrops.h"
-#include "BlockSugarcane.h"
-#include "BlockFlower.h"
-#include "BlockMushroom.h"
-#include "BlockCactus.h"
-#include "BlockStems.h"
-#include "BlockGlowstone.h"
-#include "BlockStone.h"
-#include "BlockMelon.h"
-#include "BlockIce.h"
-#include "BlockOre.h"
-#include "BlockNote.h"
-#include "BlockBed.h"
-#include "BlockFarmland.h"
-#include "BlockMycelium.h"
-#include "BlockRail.h"
-#include "BlockGlass.h"
-#include "BlockEnderchest.h"
-#include "BlockFenceGate.h"
-#include "BlockFlowerPot.h"
-#include "BlockCauldron.h"
-#include "BlockBrewingStand.h"
-#include "BlockCobWeb.h"
-#include "BlockDeadBush.h"
-#include "BlockHopper.h"
-
-
-
-
-
-bool cBlockHandler::m_HandlerInitialized = false;
-cBlockHandler * cBlockHandler::m_BlockHandler[256];
-
-
-
-
-
-cBlockHandler * cBlockHandler::GetBlockHandler(BLOCKTYPE a_BlockType)
-{
- if (!m_HandlerInitialized)
- {
- // We have to initialize
- memset(m_BlockHandler, 0, sizeof(m_BlockHandler));
- m_HandlerInitialized = true;
- }
- if (m_BlockHandler[a_BlockType] != NULL)
- {
- return m_BlockHandler[a_BlockType];
- }
-
- return m_BlockHandler[a_BlockType] = CreateBlockHandler(a_BlockType);
-}
-
-
-
-
-
-cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
-{
- switch(a_BlockType)
- {
- // Block handlers, alphabetically sorted:
- case E_BLOCK_BED: return new cBlockBedHandler (a_BlockType);
- case E_BLOCK_BIRCH_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
- case E_BLOCK_BREWING_STAND: return new cBlockBrewingStandHandler (a_BlockType);
- case E_BLOCK_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
- case E_BLOCK_BROWN_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
- case E_BLOCK_CACTUS: return new cBlockCactusHandler (a_BlockType);
- case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
- case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
- case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
- case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
- case E_BLOCK_COBBLESTONE: return new cBlockStoneHandler (a_BlockType);
- case E_BLOCK_COBBLESTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
- case E_BLOCK_COBWEB: return new cBlockCobWebHandler (a_BlockType);
- case E_BLOCK_CROPS: return new cBlockCropsHandler (a_BlockType);
- case E_BLOCK_DEAD_BUSH: return new cBlockDeadBushHandler (a_BlockType);
- case E_BLOCK_DETECTOR_RAIL: return new cBlockRailHandler (a_BlockType);
- case E_BLOCK_DIAMOND_ORE: return new cBlockOreHandler (a_BlockType);
- case E_BLOCK_DIRT: return new cBlockDirtHandler (a_BlockType);
- case E_BLOCK_DISPENSER: return new cBlockDropSpenserHandler (a_BlockType);
- case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
- case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
- case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType);
- case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
- case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
- case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler;
- 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);
- case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (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_GRASS: return new cBlockDirtHandler (a_BlockType);
- case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType);
- case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType);
- case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
- case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType);
- case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType);
- case E_BLOCK_JUKEBOX: return new cBlockEntityHandler (a_BlockType);
- case E_BLOCK_JUNGLE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
- case E_BLOCK_LADDER: return new cBlockLadderHandler (a_BlockType);
- case E_BLOCK_LEVER: return new cBlockLeverHandler (a_BlockType);
- case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType);
- case E_BLOCK_LAVA: return new cBlockFluidHandler (a_BlockType);
- case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType);
- case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
- case E_BLOCK_LOG: return new cBlockWoodHandler (a_BlockType);
- case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType);
- case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType);
- case E_BLOCK_MYCELIUM: return new cBlockMyceliumHandler (a_BlockType);
- case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
- case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
- case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
- case E_BLOCK_PLANKS: return new cBlockWoodHandler (a_BlockType);
- case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType);
- case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType);
- case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType);
- case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (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);
- case E_BLOCK_REDSTONE_REPEATER_ON: return new cBlockRedstoneRepeaterHandler(a_BlockType);
- case E_BLOCK_REDSTONE_TORCH_OFF: return new cBlockRedstoneTorchHandler (a_BlockType);
- case E_BLOCK_REDSTONE_TORCH_ON: return new cBlockRedstoneTorchHandler (a_BlockType);
- case E_BLOCK_REDSTONE_WIRE: return new cBlockRedstoneHandler (a_BlockType);
- case E_BLOCK_RED_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
- case E_BLOCK_RED_ROSE: return new cBlockFlowerHandler (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_SNOW: return new cBlockSnowHandler (a_BlockType);
- case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
- case E_BLOCK_STATIONARY_LAVA: return new cBlockFluidHandler (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_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_VINES: return new cBlockVineHandler (a_BlockType);
- case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType);
- case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
- case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (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);
- case E_BLOCK_WORKBENCH: return new cBlockWorkbenchHandler (a_BlockType);
- case E_BLOCK_YELLOW_FLOWER: return new cBlockFlowerHandler (a_BlockType);
-
- default: return new cBlockHandler(a_BlockType);
- }
-}
-
-
-
-
-
-void cBlockHandler::Deinit()
-{
- for (int i = 0; i < 256; i++)
- {
- delete m_BlockHandler[i];
- }
- memset(m_BlockHandler, 0, sizeof(m_BlockHandler)); // Don't leave any dangling pointers around, just in case
- m_HandlerInitialized = false;
-}
-
-
-
-
-
-cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
-{
- m_BlockType = a_BlockType;
-}
-
-
-
-
-
-bool cBlockHandler::GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
-)
-{
- // By default, all blocks can be placed and the meta is copied over from the item's damage value:
- a_BlockType = m_BlockType;
- a_BlockMeta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x0f);
- return true;
-}
-
-
-
-
-
-void cBlockHandler::OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
-}
-
-
-
-
-
-void cBlockHandler::OnPlacedByPlayer(cWorld * a_World, 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)
-{
-}
-
-
-
-
-
-void cBlockHandler::OnDestroyedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
-}
-
-
-
-
-
-void cBlockHandler::OnPlaced(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- // Notify the neighbors
- NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
- NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
- NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
-}
-
-
-
-
-
-void cBlockHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- // Notify the neighbors
- NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
- NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
- NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
-}
-
-
-
-
-
-void cBlockHandler::NeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- if ((a_BlockY >= 0) && (a_BlockY < cChunkDef::Height))
- {
- GetBlockHandler(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ))->OnNeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ);
- }
-}
-
-
-
-
-
-void cBlockHandler::OnNeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
-}
-
-
-
-
-
-void cBlockHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
-}
-
-
-
-
-
-void cBlockHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
-{
-}
-
-
-
-
-
-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.
- a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta));
-}
-
-
-
-
-
-void cBlockHandler::DropBlock(cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- cItems Pickups;
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- ConvertToPickups(Pickups, Meta);
-
- // Allow plugins to modify the pickups:
- cRoot::Get()->GetPluginManager()->CallHookBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
-
- if (!Pickups.empty())
- {
- a_World->SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
- }
-}
-
-
-
-
-
-const char * cBlockHandler::GetStepSound()
-{
- return "step.stone";
-}
-
-
-
-
-
-bool cBlockHandler::CanBeAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cChunk & a_Chunk)
-{
- return true;
-}
-
-
-
-
-
-bool cBlockHandler::IsUseable()
-{
- return false;
-}
-
-
-
-
-
-bool cBlockHandler::IsClickedThrough(void)
-{
- return false;
-}
-
-
-
-
-
-bool cBlockHandler::DoesIgnoreBuildCollision(void)
-{
- return (m_BlockType == E_BLOCK_AIR);
-}
-
-
-
-
-
-bool cBlockHandler::DoesAllowBlockOnTop(void)
-{
- return true;
-}
-
-
-
-
-
-bool cBlockHandler::CanBePlacedOnSide(void)
-{
- return true;
-}
-
-
-
-
-
-bool cBlockHandler::DoesDropOnUnsuitable(void)
-{
- return true;
-}
-
-
-
-
-
-void cBlockHandler::Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
-{
- if (!CanBeAt(a_RelX, a_RelY, a_RelZ, a_Chunk))
- {
- if (DoesDropOnUnsuitable())
- {
- int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
- int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
- DropBlock(a_Chunk.GetWorld(), NULL, BlockX, a_RelY, BlockZ);
- }
-
- a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
- }
- else
- {
- // Wake up the simulators for this block:
- int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
- int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
- a_Chunk.GetWorld()->GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, &a_Chunk);
- }
-}
-
-
-
-
+
+#include "Globals.h"
+#include "BlockHandler.h"
+#include "../Item.h"
+#include "../World.h"
+#include "../Root.h"
+#include "../PluginManager.h"
+#include "BlockSand.h"
+#include "BlockGravel.h"
+#include "BlockDoor.h"
+#include "BlockFire.h"
+#include "BlockRedstone.h"
+#include "BlockRedstoneTorch.h"
+#include "BlockRedstoneRepeater.h"
+#include "BlockPiston.h"
+#include "BlockWorkbench.h"
+#include "BlockEntity.h"
+#include "BlockVine.h"
+#include "BlockTallGrass.h"
+#include "BlockSnow.h"
+#include "BlockCloth.h"
+#include "BlockSlab.h"
+#include "BlockDirt.h"
+#include "BlockTorch.h"
+#include "BlockWood.h"
+#include "BlockLeaves.h"
+#include "BlockSapling.h"
+#include "BlockFluid.h"
+#include "BlockChest.h"
+#include "BlockFurnace.h"
+#include "BlockDropSpenser.h"
+#include "BlockStairs.h"
+#include "BlockLadder.h"
+#include "BlockLever.h"
+#include "BlockSign.h"
+#include "BlockCrops.h"
+#include "BlockSugarcane.h"
+#include "BlockFlower.h"
+#include "BlockMushroom.h"
+#include "BlockCactus.h"
+#include "BlockStems.h"
+#include "BlockGlowstone.h"
+#include "BlockStone.h"
+#include "BlockMelon.h"
+#include "BlockIce.h"
+#include "BlockOre.h"
+#include "BlockNote.h"
+#include "BlockBed.h"
+#include "BlockFarmland.h"
+#include "BlockMycelium.h"
+#include "BlockRail.h"
+#include "BlockGlass.h"
+#include "BlockEnderchest.h"
+#include "BlockFenceGate.h"
+#include "BlockFlowerPot.h"
+#include "BlockCauldron.h"
+#include "BlockBrewingStand.h"
+#include "BlockCobWeb.h"
+#include "BlockDeadBush.h"
+#include "BlockHopper.h"
+
+
+
+
+
+bool cBlockHandler::m_HandlerInitialized = false;
+cBlockHandler * cBlockHandler::m_BlockHandler[256];
+
+
+
+
+
+cBlockHandler * cBlockHandler::GetBlockHandler(BLOCKTYPE a_BlockType)
+{
+ if (!m_HandlerInitialized)
+ {
+ // We have to initialize
+ memset(m_BlockHandler, 0, sizeof(m_BlockHandler));
+ m_HandlerInitialized = true;
+ }
+ if (m_BlockHandler[a_BlockType] != NULL)
+ {
+ return m_BlockHandler[a_BlockType];
+ }
+
+ return m_BlockHandler[a_BlockType] = CreateBlockHandler(a_BlockType);
+}
+
+
+
+
+
+cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
+{
+ switch(a_BlockType)
+ {
+ // Block handlers, alphabetically sorted:
+ case E_BLOCK_BED: return new cBlockBedHandler (a_BlockType);
+ case E_BLOCK_BIRCH_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
+ case E_BLOCK_BREWING_STAND: return new cBlockBrewingStandHandler (a_BlockType);
+ case E_BLOCK_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
+ case E_BLOCK_BROWN_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
+ case E_BLOCK_CACTUS: return new cBlockCactusHandler (a_BlockType);
+ case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
+ case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
+ case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
+ case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
+ case E_BLOCK_COBBLESTONE: return new cBlockStoneHandler (a_BlockType);
+ case E_BLOCK_COBBLESTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
+ case E_BLOCK_COBWEB: return new cBlockCobWebHandler (a_BlockType);
+ case E_BLOCK_CROPS: return new cBlockCropsHandler (a_BlockType);
+ case E_BLOCK_DEAD_BUSH: return new cBlockDeadBushHandler (a_BlockType);
+ case E_BLOCK_DETECTOR_RAIL: return new cBlockRailHandler (a_BlockType);
+ case E_BLOCK_DIAMOND_ORE: return new cBlockOreHandler (a_BlockType);
+ case E_BLOCK_DIRT: return new cBlockDirtHandler (a_BlockType);
+ case E_BLOCK_DISPENSER: return new cBlockDropSpenserHandler (a_BlockType);
+ case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
+ case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
+ case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType);
+ case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
+ case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
+ case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler;
+ 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);
+ case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (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_GRASS: return new cBlockDirtHandler (a_BlockType);
+ case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType);
+ case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType);
+ case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
+ case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType);
+ case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType);
+ case E_BLOCK_JUKEBOX: return new cBlockEntityHandler (a_BlockType);
+ case E_BLOCK_JUNGLE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
+ case E_BLOCK_LADDER: return new cBlockLadderHandler (a_BlockType);
+ case E_BLOCK_LEVER: return new cBlockLeverHandler (a_BlockType);
+ case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType);
+ case E_BLOCK_LAVA: return new cBlockFluidHandler (a_BlockType);
+ case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType);
+ case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
+ case E_BLOCK_LOG: return new cBlockWoodHandler (a_BlockType);
+ case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType);
+ case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType);
+ case E_BLOCK_MYCELIUM: return new cBlockMyceliumHandler (a_BlockType);
+ case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
+ case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
+ case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
+ case E_BLOCK_PLANKS: return new cBlockWoodHandler (a_BlockType);
+ case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType);
+ case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType);
+ case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType);
+ case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (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);
+ case E_BLOCK_REDSTONE_REPEATER_ON: return new cBlockRedstoneRepeaterHandler(a_BlockType);
+ case E_BLOCK_REDSTONE_TORCH_OFF: return new cBlockRedstoneTorchHandler (a_BlockType);
+ case E_BLOCK_REDSTONE_TORCH_ON: return new cBlockRedstoneTorchHandler (a_BlockType);
+ case E_BLOCK_REDSTONE_WIRE: return new cBlockRedstoneHandler (a_BlockType);
+ case E_BLOCK_RED_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
+ case E_BLOCK_RED_ROSE: return new cBlockFlowerHandler (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_SNOW: return new cBlockSnowHandler (a_BlockType);
+ case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
+ case E_BLOCK_STATIONARY_LAVA: return new cBlockFluidHandler (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_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_VINES: return new cBlockVineHandler (a_BlockType);
+ case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType);
+ case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
+ case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (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);
+ case E_BLOCK_WORKBENCH: return new cBlockWorkbenchHandler (a_BlockType);
+ case E_BLOCK_YELLOW_FLOWER: return new cBlockFlowerHandler (a_BlockType);
+
+ default: return new cBlockHandler(a_BlockType);
+ }
+}
+
+
+
+
+
+void cBlockHandler::Deinit()
+{
+ for (int i = 0; i < 256; i++)
+ {
+ delete m_BlockHandler[i];
+ }
+ memset(m_BlockHandler, 0, sizeof(m_BlockHandler)); // Don't leave any dangling pointers around, just in case
+ m_HandlerInitialized = false;
+}
+
+
+
+
+
+cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
+{
+ m_BlockType = a_BlockType;
+}
+
+
+
+
+
+bool cBlockHandler::GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+)
+{
+ // By default, all blocks can be placed and the meta is copied over from the item's damage value:
+ a_BlockType = m_BlockType;
+ a_BlockMeta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x0f);
+ return true;
+}
+
+
+
+
+
+void cBlockHandler::OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+}
+
+
+
+
+
+void cBlockHandler::OnPlacedByPlayer(cWorld * a_World, 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)
+{
+}
+
+
+
+
+
+void cBlockHandler::OnDestroyedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+}
+
+
+
+
+
+void cBlockHandler::OnPlaced(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+{
+ // Notify the neighbors
+ NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
+ NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
+ NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
+ NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
+ NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
+ NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
+}
+
+
+
+
+
+void cBlockHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ // Notify the neighbors
+ NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
+ NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
+ NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
+ NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
+ NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
+ NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
+}
+
+
+
+
+
+void cBlockHandler::NeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ if ((a_BlockY >= 0) && (a_BlockY < cChunkDef::Height))
+ {
+ GetBlockHandler(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ))->OnNeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ }
+}
+
+
+
+
+
+void cBlockHandler::OnNeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+}
+
+
+
+
+
+void cBlockHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+}
+
+
+
+
+
+void cBlockHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+{
+}
+
+
+
+
+
+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.
+ a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta));
+}
+
+
+
+
+
+void cBlockHandler::DropBlock(cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ cItems Pickups;
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ ConvertToPickups(Pickups, Meta);
+
+ // Allow plugins to modify the pickups:
+ cRoot::Get()->GetPluginManager()->CallHookBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
+
+ if (!Pickups.empty())
+ {
+ a_World->SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
+ }
+}
+
+
+
+
+
+const char * cBlockHandler::GetStepSound()
+{
+ return "step.stone";
+}
+
+
+
+
+
+bool cBlockHandler::CanBeAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cChunk & a_Chunk)
+{
+ return true;
+}
+
+
+
+
+
+bool cBlockHandler::IsUseable()
+{
+ return false;
+}
+
+
+
+
+
+bool cBlockHandler::IsClickedThrough(void)
+{
+ return false;
+}
+
+
+
+
+
+bool cBlockHandler::DoesIgnoreBuildCollision(void)
+{
+ return (m_BlockType == E_BLOCK_AIR);
+}
+
+
+
+
+
+bool cBlockHandler::DoesAllowBlockOnTop(void)
+{
+ return true;
+}
+
+
+
+
+
+bool cBlockHandler::CanBePlacedOnSide(void)
+{
+ return true;
+}
+
+
+
+
+
+bool cBlockHandler::DoesDropOnUnsuitable(void)
+{
+ return true;
+}
+
+
+
+
+
+void cBlockHandler::Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
+{
+ if (!CanBeAt(a_RelX, a_RelY, a_RelZ, a_Chunk))
+ {
+ if (DoesDropOnUnsuitable())
+ {
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ DropBlock(a_Chunk.GetWorld(), NULL, BlockX, a_RelY, BlockZ);
+ }
+
+ a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
+ }
+ else
+ {
+ // Wake up the simulators for this block:
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ a_Chunk.GetWorld()->GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, &a_Chunk);
+ }
+}
+
+
+
+
diff --git a/source/Blocks/BlockHandler.h b/source/Blocks/BlockHandler.h
index cb52be497..228ce174b 100644
--- a/source/Blocks/BlockHandler.h
+++ b/source/Blocks/BlockHandler.h
@@ -1,158 +1,158 @@
-
-#pragma once
-
-#include "../Defines.h"
-#include "../Item.h"
-#include "../Chunk.h"
-
-
-
-
-
-// fwd:
-class cWorld;
-class cPlayer;
-
-
-
-
-
-class cBlockHandler
-{
-public:
- cBlockHandler(BLOCKTYPE a_BlockType);
-
- /// Called when the block gets ticked either by a random tick or by a queued tick
- virtual void OnUpdate(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
-
- /** 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(
- cWorld * a_World, 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
- );
-
- /// Called by cWorld::SetBlock() after the block has been set
- virtual void OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
-
- /// Called by cClientHandle::HandlePlaceBlock() after the player has placed a new block. Called after OnPlaced().
- virtual void OnPlacedByPlayer(
- cWorld * a_World, 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
- );
-
- /// Called before the player has destroyed a block
- virtual void OnDestroyedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
-
- /// Called before a block gets destroyed / replaced with air
- virtual void OnDestroyed(cWorld * a_World, 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(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
-
- /// Notifies all neighbors of the given block about a change
- static void NeighborChanged(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
-
- /// Called while the player diggs the block.
- virtual void OnDigging(cWorld * a_World, 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(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
-
- /// Called when the item is mined to convert it into pickups. Pickups may specify multiple items.
- 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(cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ);
-
- /// 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(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk);
-
- /** Checks if the block can be placed at this point.
- 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);
-
- /// Called when the player tries to place a block on top of this block (Only if he aims directly on this block); return false to disallow
- virtual bool DoesAllowBlockOnTop(void);
-
- /// 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.
- 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.
- For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision
- */
- virtual bool DoesIgnoreBuildCollision(void);
-
- /// Indicates this block can be placed on the side of other blocks. Default: true
- virtual bool CanBePlacedOnSide(void);
-
- /// Does this block drop if it gets destroyed by an unsuitable situation? Default: true
- virtual bool DoesDropOnUnsuitable(void);
-
- /** 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.
- */
- virtual void Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk);
-
- /// Returns the meta for a block after rotating it counter-clockwise from the specified meta. Default: no change
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) { return a_Meta; }
-
- /// Returns the meta for a block after rotating it clockwise from the specified meta. Default: no change
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) { return a_Meta; }
-
- /// Returns the meta for a block after mirroring it around the XY plane. Default: no change
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) { return a_Meta; }
-
- /// Returns the meta for a block after mirroring it around the XZ plane. Default: no change
- virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) { return a_Meta; }
-
- /// Returns the meta for a block after mirroring it around the YZ plane. Default: no change
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) { return a_Meta; }
-
-
- /// Get the blockhandler for a specific block id
- static cBlockHandler * GetBlockHandler(BLOCKTYPE a_BlockType);
-
- /// Deletes all initialised block handlers
- static void Deinit();
-
-protected:
- BLOCKTYPE m_BlockType;
-
- // Creates a new blockhandler for the given block type. For internal use only, use ::GetBlockHandler() instead.
- static cBlockHandler *CreateBlockHandler(BLOCKTYPE a_BlockType);
- static cBlockHandler *m_BlockHandler[256];
- static bool m_HandlerInitialized; //used to detect if the blockhandlers are initialized
-};
-
-
-
-
-
-// Shortcut to get the blockhandler for a specific block
-inline cBlockHandler * BlockHandler(BLOCKTYPE a_BlockType)
-{
- return cBlockHandler::GetBlockHandler(a_BlockType);
-}
-
-
-
-
+
+#pragma once
+
+#include "../Defines.h"
+#include "../Item.h"
+#include "../Chunk.h"
+
+
+
+
+
+// fwd:
+class cWorld;
+class cPlayer;
+
+
+
+
+
+class cBlockHandler
+{
+public:
+ cBlockHandler(BLOCKTYPE a_BlockType);
+
+ /// Called when the block gets ticked either by a random tick or by a queued tick
+ virtual void OnUpdate(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ /** 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(
+ cWorld * a_World, 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
+ );
+
+ /// Called by cWorld::SetBlock() after the block has been set
+ virtual void OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+
+ /// Called by cClientHandle::HandlePlaceBlock() after the player has placed a new block. Called after OnPlaced().
+ virtual void OnPlacedByPlayer(
+ cWorld * a_World, 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
+ );
+
+ /// Called before the player has destroyed a block
+ virtual void OnDestroyedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ /// Called before a block gets destroyed / replaced with air
+ virtual void OnDestroyed(cWorld * a_World, 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(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ /// Notifies all neighbors of the given block about a change
+ static void NeighborChanged(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ /// Called while the player diggs the block.
+ virtual void OnDigging(cWorld * a_World, 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(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
+
+ /// Called when the item is mined to convert it into pickups. Pickups may specify multiple items.
+ 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(cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ);
+
+ /// 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(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk);
+
+ /** Checks if the block can be placed at this point.
+ 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);
+
+ /// Called when the player tries to place a block on top of this block (Only if he aims directly on this block); return false to disallow
+ virtual bool DoesAllowBlockOnTop(void);
+
+ /// 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.
+ 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.
+ For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision
+ */
+ virtual bool DoesIgnoreBuildCollision(void);
+
+ /// Indicates this block can be placed on the side of other blocks. Default: true
+ virtual bool CanBePlacedOnSide(void);
+
+ /// Does this block drop if it gets destroyed by an unsuitable situation? Default: true
+ virtual bool DoesDropOnUnsuitable(void);
+
+ /** 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.
+ */
+ virtual void Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk);
+
+ /// Returns the meta for a block after rotating it counter-clockwise from the specified meta. Default: no change
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) { return a_Meta; }
+
+ /// Returns the meta for a block after rotating it clockwise from the specified meta. Default: no change
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) { return a_Meta; }
+
+ /// Returns the meta for a block after mirroring it around the XY plane. Default: no change
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) { return a_Meta; }
+
+ /// Returns the meta for a block after mirroring it around the XZ plane. Default: no change
+ virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) { return a_Meta; }
+
+ /// Returns the meta for a block after mirroring it around the YZ plane. Default: no change
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) { return a_Meta; }
+
+
+ /// Get the blockhandler for a specific block id
+ static cBlockHandler * GetBlockHandler(BLOCKTYPE a_BlockType);
+
+ /// Deletes all initialised block handlers
+ static void Deinit();
+
+protected:
+ BLOCKTYPE m_BlockType;
+
+ // Creates a new blockhandler for the given block type. For internal use only, use ::GetBlockHandler() instead.
+ static cBlockHandler *CreateBlockHandler(BLOCKTYPE a_BlockType);
+ static cBlockHandler *m_BlockHandler[256];
+ static bool m_HandlerInitialized; //used to detect if the blockhandlers are initialized
+};
+
+
+
+
+
+// Shortcut to get the blockhandler for a specific block
+inline cBlockHandler * BlockHandler(BLOCKTYPE a_BlockType)
+{
+ return cBlockHandler::GetBlockHandler(a_BlockType);
+}
+
+
+
+
diff --git a/source/Blocks/BlockHopper.h b/source/Blocks/BlockHopper.h
index 10f865564..3998276d7 100644
--- a/source/Blocks/BlockHopper.h
+++ b/source/Blocks/BlockHopper.h
@@ -1,46 +1,46 @@
-
-// BlockHopper.h
-
-// Declares the cBlockHopperHandler class representing the handler for the Hopper block
-
-
-
-
-
-class cBlockHopperHandler :
- public cBlockEntityHandler
-{
-public:
- cBlockHopperHandler(BLOCKTYPE a_BlockType)
- : cBlockEntityHandler(a_BlockType)
- {
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = m_BlockType;
-
- // Convert the blockface into meta:
- switch (a_BlockFace)
- {
- case BLOCK_FACE_BOTTOM: a_BlockMeta = E_META_HOPPER_FACING_YM; break;
- case BLOCK_FACE_TOP: a_BlockMeta = E_META_HOPPER_FACING_YM; break;
- case BLOCK_FACE_EAST: a_BlockMeta = E_META_HOPPER_FACING_XM; break;
- case BLOCK_FACE_NORTH: a_BlockMeta = E_META_HOPPER_FACING_ZP; break;
- case BLOCK_FACE_SOUTH: a_BlockMeta = E_META_HOPPER_FACING_ZM; break;
- case BLOCK_FACE_WEST: a_BlockMeta = E_META_HOPPER_FACING_XP; break;
- default: a_BlockMeta = E_META_HOPPER_UNATTACHED; break;
- }
- return true;
- }
-} ;
-
-
-
-
+
+// BlockHopper.h
+
+// Declares the cBlockHopperHandler class representing the handler for the Hopper block
+
+
+
+
+
+class cBlockHopperHandler :
+ public cBlockEntityHandler
+{
+public:
+ cBlockHopperHandler(BLOCKTYPE a_BlockType)
+ : cBlockEntityHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = m_BlockType;
+
+ // Convert the blockface into meta:
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_BOTTOM: a_BlockMeta = E_META_HOPPER_FACING_YM; break;
+ case BLOCK_FACE_TOP: a_BlockMeta = E_META_HOPPER_FACING_YM; break;
+ case BLOCK_FACE_EAST: a_BlockMeta = E_META_HOPPER_FACING_XM; break;
+ case BLOCK_FACE_NORTH: a_BlockMeta = E_META_HOPPER_FACING_ZP; break;
+ case BLOCK_FACE_SOUTH: a_BlockMeta = E_META_HOPPER_FACING_ZM; break;
+ case BLOCK_FACE_WEST: a_BlockMeta = E_META_HOPPER_FACING_XP; break;
+ default: a_BlockMeta = E_META_HOPPER_UNATTACHED; break;
+ }
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockIce.h b/source/Blocks/BlockIce.h
index 605a8ae1d..11fe425f3 100644
--- a/source/Blocks/BlockIce.h
+++ b/source/Blocks/BlockIce.h
@@ -1,37 +1,37 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockIceHandler :
- public cBlockHandler
-{
-public:
- cBlockIceHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // No pickups
- }
-
-
- virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- // TODO: Ice destroyed with air below it should turn into air instead of water
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_STATIONARY_WATER, 8);
- // This is called later than the real destroying of this ice block
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockIceHandler :
+ public cBlockHandler
+{
+public:
+ cBlockIceHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // No pickups
+ }
+
+
+ virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ // TODO: Ice destroyed with air below it should turn into air instead of water
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_STATIONARY_WATER, 8);
+ // This is called later than the real destroying of this ice block
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockLadder.h b/source/Blocks/BlockLadder.h
index 93473f757..c0aa25f60 100644
--- a/source/Blocks/BlockLadder.h
+++ b/source/Blocks/BlockLadder.h
@@ -1,115 +1,115 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockLadderHandler :
- public cBlockHandler
-{
-public:
- cBlockLadderHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- if (!LadderCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace))
- {
- a_BlockFace = FindSuitableBlockFace(a_World, a_BlockX, a_BlockY, a_BlockZ);
-
- if (a_BlockFace == BLOCK_FACE_BOTTOM)
- {
- return false;
- }
- }
-
- a_BlockType = m_BlockType;
- a_BlockMeta = DirectionToMetaData(a_BlockFace);
- return true;
- }
-
-
- static NIBBLETYPE DirectionToMetaData(char a_Direction) // tolua_export
- { // tolua_export
- switch (a_Direction)
- {
- case 0x2: return 0x2;
- case 0x3: return 0x3;
- case 0x4: return 0x4;
- case 0x5: return 0x5;
- default: return 0x2;
- }
- } // tolua_export
-
-
- static char MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export
- { // tolua_export
- switch (a_MetaData)
- {
- case 0x2: return 0x2;
- case 0x3: return 0x3;
- case 0x4: return 0x4;
- case 0x5: return 0x5;
- default: return 0x2;
- }
- } // tolua_export
-
-
- /// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure
- static char FindSuitableBlockFace(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
- {
- for (int Face = 2; Face <= 5; Face++)
- {
- if (LadderCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, Face))
- {
- return Face;
- }
- }
- return BLOCK_FACE_BOTTOM;
- }
-
-
- static bool LadderCanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
- {
- if ((a_BlockFace == BLOCK_FACE_BOTTOM) || (a_BlockFace == BLOCK_FACE_TOP))
- {
- return false;
- }
-
- AddFaceDirection( a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true);
-
- return g_BlockIsSolid[a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ)];
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
- char BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
- int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
- int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
- return LadderCanBePlacedAt(a_Chunk.GetWorld(), BlockX, a_RelY, BlockZ, BlockFace);
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockLadderHandler :
+ public cBlockHandler
+{
+public:
+ cBlockLadderHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ if (!LadderCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace))
+ {
+ a_BlockFace = FindSuitableBlockFace(a_World, a_BlockX, a_BlockY, a_BlockZ);
+
+ if (a_BlockFace == BLOCK_FACE_BOTTOM)
+ {
+ return false;
+ }
+ }
+
+ a_BlockType = m_BlockType;
+ a_BlockMeta = DirectionToMetaData(a_BlockFace);
+ return true;
+ }
+
+
+ static NIBBLETYPE DirectionToMetaData(char a_Direction) // tolua_export
+ { // tolua_export
+ switch (a_Direction)
+ {
+ case 0x2: return 0x2;
+ case 0x3: return 0x3;
+ case 0x4: return 0x4;
+ case 0x5: return 0x5;
+ default: return 0x2;
+ }
+ } // tolua_export
+
+
+ static char MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export
+ { // tolua_export
+ switch (a_MetaData)
+ {
+ case 0x2: return 0x2;
+ case 0x3: return 0x3;
+ case 0x4: return 0x4;
+ case 0x5: return 0x5;
+ default: return 0x2;
+ }
+ } // tolua_export
+
+
+ /// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure
+ static char FindSuitableBlockFace(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ for (int Face = 2; Face <= 5; Face++)
+ {
+ if (LadderCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, Face))
+ {
+ return Face;
+ }
+ }
+ return BLOCK_FACE_BOTTOM;
+ }
+
+
+ static bool LadderCanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
+ {
+ if ((a_BlockFace == BLOCK_FACE_BOTTOM) || (a_BlockFace == BLOCK_FACE_TOP))
+ {
+ return false;
+ }
+
+ AddFaceDirection( a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true);
+
+ return g_BlockIsSolid[a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ)];
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
+ char BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ return LadderCanBePlacedAt(a_Chunk.GetWorld(), BlockX, a_RelY, BlockZ, BlockFace);
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockLeaves.h b/source/Blocks/BlockLeaves.h
index 3563babcf..6e015b8fa 100644
--- a/source/Blocks/BlockLeaves.h
+++ b/source/Blocks/BlockLeaves.h
@@ -1,184 +1,184 @@
-#pragma once
-#include "BlockHandler.h"
-#include "../MersenneTwister.h"
-#include "../World.h"
-#include "../BlockArea.h"
-
-
-
-
-
-// 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) \
- switch (a_Area.GetBlockType(x, y, z)) \
- { \
- case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \
- case E_BLOCK_LOG: return true; \
- }
-
-bool HasNearLog(cBlockArea &a_Area, int a_BlockX, int a_BlockY, int a_BlockZ);
-
-
-
-
-
-class cBlockLeavesHandler :
- public cBlockHandler
-{
-public:
- cBlockLeavesHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- MTRand rand;
-
- // Only the first 2 bits contain the display information, the others are for growing
- if (rand.randInt(5) == 0)
- {
- a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3));
- }
- if ((a_BlockMeta & 3) == E_META_SAPLING_APPLE)
- {
- if (rand.rand(100) == 0)
- {
- a_Pickups.push_back(cItem(E_ITEM_RED_APPLE, 1, 0));
- }
- }
- }
-
-
- void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- cBlockHandler::OnDestroyed(a_World, a_BlockX, a_BlockY, a_BlockZ);
-
- //0.5% chance of dropping an apple
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- //check if Oak (0x1 and 0x2 bit not set)
- MTRand rand;
- if(!(Meta & 3) && rand.randInt(200) == 100)
- {
- cItems Drops;
- Drops.push_back(cItem(E_ITEM_RED_APPLE, 1, 0));
- a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
- }
- }
-
-
- virtual void OnNeighborChanged(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
- }
-
-
- virtual void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if ((Meta & 0x04) != 0)
- {
- // Player-placed leaves, don't decay
- return;
- }
-
- if ((Meta & 0x8) != 0)
- {
- // These leaves have been checked for decay lately and nothing around them changed
- return;
- }
-
- // Get the data around the leaves:
- cBlockArea Area;
- if (!Area.Read(
- a_World,
- a_BlockX - LEAVES_CHECK_DISTANCE, a_BlockX + LEAVES_CHECK_DISTANCE,
- a_BlockY - LEAVES_CHECK_DISTANCE, a_BlockY + LEAVES_CHECK_DISTANCE,
- a_BlockZ - LEAVES_CHECK_DISTANCE, a_BlockZ + LEAVES_CHECK_DISTANCE,
- cBlockArea::baTypes)
- )
- {
- // Cannot check leaves, a chunk is missing too close
- return;
- }
-
- if (HasNearLog(Area, a_BlockX, a_BlockY, a_BlockZ))
- {
- // Wood found, the leaves stay; mark them as checked:
- a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x8);
- return;
- }
- // Decay the leaves:
- DropBlock(a_World, NULL, a_BlockX, a_BlockY, a_BlockZ);
-
- a_World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
-
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.grass";
- }
-} ;
-
-
-
-
-
-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--)
- {
- switch (Types[i])
- {
- case E_BLOCK_LEAVES:
- case E_BLOCK_LOG:
- {
- break;
- }
- default:
- {
- Types[i] = E_BLOCK_AIR;
- break;
- }
- }
- } // for i - Types[]
-
- // Perform a breadth-first search to see if there's a log connected within 4 blocks of the leaves block:
- // Simply replace all reachable leaves blocks with a sponge block plus iteration (in the Area) and see if we can reach a log in 4 iterations
- a_Area.SetBlockType(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_SPONGE);
- for (int i = 0; i < LEAVES_CHECK_DISTANCE; i++)
- {
- for (int y = a_BlockY - i; y <= a_BlockY + i; y++)
- {
- for (int z = a_BlockZ - i; z <= a_BlockZ + i; z++)
- {
- for (int x = a_BlockX - i; x <= a_BlockX + i; x++)
- {
- if (a_Area.GetBlockType(x, y, z) != E_BLOCK_SPONGE + i)
- {
- continue;
- }
- PROCESS_NEIGHBOR(x - 1, y, z);
- PROCESS_NEIGHBOR(x + 1, y, z);
- PROCESS_NEIGHBOR(x, y, z - 1);
- PROCESS_NEIGHBOR(x, y, z + 1);
- PROCESS_NEIGHBOR(x, y + 1, z);
- PROCESS_NEIGHBOR(x, y - 1, z);
- } // for x
- } // for z
- } // for y
- } // for i - BFS iterations
- return false;
-}
-
-
-
-
+#pragma once
+#include "BlockHandler.h"
+#include "../MersenneTwister.h"
+#include "../World.h"
+#include "../BlockArea.h"
+
+
+
+
+
+// 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) \
+ switch (a_Area.GetBlockType(x, y, z)) \
+ { \
+ case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \
+ case E_BLOCK_LOG: return true; \
+ }
+
+bool HasNearLog(cBlockArea &a_Area, int a_BlockX, int a_BlockY, int a_BlockZ);
+
+
+
+
+
+class cBlockLeavesHandler :
+ public cBlockHandler
+{
+public:
+ cBlockLeavesHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ MTRand rand;
+
+ // Only the first 2 bits contain the display information, the others are for growing
+ if (rand.randInt(5) == 0)
+ {
+ a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3));
+ }
+ if ((a_BlockMeta & 3) == E_META_SAPLING_APPLE)
+ {
+ if (rand.rand(100) == 0)
+ {
+ a_Pickups.push_back(cItem(E_ITEM_RED_APPLE, 1, 0));
+ }
+ }
+ }
+
+
+ void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ cBlockHandler::OnDestroyed(a_World, a_BlockX, a_BlockY, a_BlockZ);
+
+ //0.5% chance of dropping an apple
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ //check if Oak (0x1 and 0x2 bit not set)
+ MTRand rand;
+ if(!(Meta & 3) && rand.randInt(200) == 100)
+ {
+ cItems Drops;
+ Drops.push_back(cItem(E_ITEM_RED_APPLE, 1, 0));
+ a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
+ }
+ }
+
+
+ virtual void OnNeighborChanged(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
+ }
+
+
+ virtual void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ if ((Meta & 0x04) != 0)
+ {
+ // Player-placed leaves, don't decay
+ return;
+ }
+
+ if ((Meta & 0x8) != 0)
+ {
+ // These leaves have been checked for decay lately and nothing around them changed
+ return;
+ }
+
+ // Get the data around the leaves:
+ cBlockArea Area;
+ if (!Area.Read(
+ a_World,
+ a_BlockX - LEAVES_CHECK_DISTANCE, a_BlockX + LEAVES_CHECK_DISTANCE,
+ a_BlockY - LEAVES_CHECK_DISTANCE, a_BlockY + LEAVES_CHECK_DISTANCE,
+ a_BlockZ - LEAVES_CHECK_DISTANCE, a_BlockZ + LEAVES_CHECK_DISTANCE,
+ cBlockArea::baTypes)
+ )
+ {
+ // Cannot check leaves, a chunk is missing too close
+ return;
+ }
+
+ if (HasNearLog(Area, a_BlockX, a_BlockY, a_BlockZ))
+ {
+ // Wood found, the leaves stay; mark them as checked:
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x8);
+ return;
+ }
+ // Decay the leaves:
+ DropBlock(a_World, NULL, a_BlockX, a_BlockY, a_BlockZ);
+
+ a_World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
+
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.grass";
+ }
+} ;
+
+
+
+
+
+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--)
+ {
+ switch (Types[i])
+ {
+ case E_BLOCK_LEAVES:
+ case E_BLOCK_LOG:
+ {
+ break;
+ }
+ default:
+ {
+ Types[i] = E_BLOCK_AIR;
+ break;
+ }
+ }
+ } // for i - Types[]
+
+ // Perform a breadth-first search to see if there's a log connected within 4 blocks of the leaves block:
+ // Simply replace all reachable leaves blocks with a sponge block plus iteration (in the Area) and see if we can reach a log in 4 iterations
+ a_Area.SetBlockType(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_SPONGE);
+ for (int i = 0; i < LEAVES_CHECK_DISTANCE; i++)
+ {
+ for (int y = a_BlockY - i; y <= a_BlockY + i; y++)
+ {
+ for (int z = a_BlockZ - i; z <= a_BlockZ + i; z++)
+ {
+ for (int x = a_BlockX - i; x <= a_BlockX + i; x++)
+ {
+ if (a_Area.GetBlockType(x, y, z) != E_BLOCK_SPONGE + i)
+ {
+ continue;
+ }
+ PROCESS_NEIGHBOR(x - 1, y, z);
+ PROCESS_NEIGHBOR(x + 1, y, z);
+ PROCESS_NEIGHBOR(x, y, z - 1);
+ PROCESS_NEIGHBOR(x, y, z + 1);
+ PROCESS_NEIGHBOR(x, y + 1, z);
+ PROCESS_NEIGHBOR(x, y - 1, z);
+ } // for x
+ } // for z
+ } // for y
+ } // for i - BFS iterations
+ return false;
+}
+
+
+
+
diff --git a/source/Blocks/BlockLever.cpp b/source/Blocks/BlockLever.cpp
index a9ab1fbbb..6dbff10c1 100644
--- a/source/Blocks/BlockLever.cpp
+++ b/source/Blocks/BlockLever.cpp
@@ -1,48 +1,48 @@
-
-#include "Globals.h"
-#include "BlockLever.h"
-#include "../Item.h"
-#include "../World.h"
-#include "../Player.h"
-#include "../Simulator/RedstoneSimulator.h"
-
-
-
-
-
-cBlockLeverHandler::cBlockLeverHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockLeverHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
-{
- // Flip the ON bit on/off. Using XOR bitwise operation to turn it on/off.
- NIBBLETYPE Meta = ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f);
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta);
- if (Meta & 0x08)
- {
- a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
- }
- else
- {
- a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.5f);
- }
-}
-
-
-
-
-
-void cBlockLeverHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NONE, 8, 8, 8);
-}
-
-
-
-
+
+#include "Globals.h"
+#include "BlockLever.h"
+#include "../Item.h"
+#include "../World.h"
+#include "../Player.h"
+#include "../Simulator/RedstoneSimulator.h"
+
+
+
+
+
+cBlockLeverHandler::cBlockLeverHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+{
+}
+
+
+
+
+
+void cBlockLeverHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+{
+ // Flip the ON bit on/off. Using XOR bitwise operation to turn it on/off.
+ NIBBLETYPE Meta = ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f);
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta);
+ if (Meta & 0x08)
+ {
+ a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
+ }
+ else
+ {
+ a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.5f);
+ }
+}
+
+
+
+
+
+void cBlockLeverHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NONE, 8, 8, 8);
+}
+
+
+
+
diff --git a/source/Blocks/BlockLever.h b/source/Blocks/BlockLever.h
index 42a16fd9b..362cf563e 100644
--- a/source/Blocks/BlockLever.h
+++ b/source/Blocks/BlockLever.h
@@ -1,61 +1,61 @@
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-#include "../Simulator/RedstoneSimulator.h"
-
-
-
-
-
-class cBlockLeverHandler :
- public cBlockHandler
-{
-public:
- cBlockLeverHandler(BLOCKTYPE a_BlockType);
-
- virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
- virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Reset meta to 0
- a_Pickups.push_back(cItem(E_BLOCK_LEVER, 1, 0));
- }
-
-
- virtual bool IsUseable(void) override
- {
- return true;
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = m_BlockType;
- a_BlockMeta = cRedstoneSimulator::LeverDirectionToMetaData(a_BlockFace);
- return true;
- }
-
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-} ;
-
-
-
-
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+#include "../Simulator/RedstoneSimulator.h"
+
+
+
+
+
+class cBlockLeverHandler :
+ public cBlockHandler
+{
+public:
+ cBlockLeverHandler(BLOCKTYPE a_BlockType);
+
+ virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(E_BLOCK_LEVER, 1, 0));
+ }
+
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = m_BlockType;
+ a_BlockMeta = cRedstoneSimulator::LeverDirectionToMetaData(a_BlockFace);
+ return true;
+ }
+
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockMelon.h b/source/Blocks/BlockMelon.h
index d985ef126..2f7d9a461 100644
--- a/source/Blocks/BlockMelon.h
+++ b/source/Blocks/BlockMelon.h
@@ -1,35 +1,35 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockMelonHandler :
- public cBlockHandler
-{
-public:
- cBlockMelonHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- MTRand r1;
- a_Pickups.push_back(cItem(E_ITEM_MELON_SLICE, (char)(3 + r1.randInt(4)), 0));
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockMelonHandler :
+ public cBlockHandler
+{
+public:
+ cBlockMelonHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ MTRand r1;
+ a_Pickups.push_back(cItem(E_ITEM_MELON_SLICE, (char)(3 + r1.randInt(4)), 0));
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockMushroom.h b/source/Blocks/BlockMushroom.h
index 62cc898c0..b3b23e2ba 100644
--- a/source/Blocks/BlockMushroom.h
+++ b/source/Blocks/BlockMushroom.h
@@ -1,71 +1,71 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockMushroomHandler :
- public cBlockHandler
-{
-public:
- cBlockMushroomHandler(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(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- if (a_RelY <= 0)
- {
- return false;
- }
-
- // TODO: Cannot be at too much daylight
-
- switch (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))
- {
- case E_BLOCK_GLASS:
- case E_BLOCK_CACTUS:
- case E_BLOCK_ICE:
- case E_BLOCK_LEAVES:
- case E_BLOCK_AIR:
- {
- return false;
- }
- }
- return true;
- }
-
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- virtual bool CanBePlacedOnSide(void) override
- {
- return false;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.grass";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockMushroomHandler :
+ public cBlockHandler
+{
+public:
+ cBlockMushroomHandler(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(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+
+ // TODO: Cannot be at too much daylight
+
+ switch (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))
+ {
+ case E_BLOCK_GLASS:
+ case E_BLOCK_CACTUS:
+ case E_BLOCK_ICE:
+ case E_BLOCK_LEAVES:
+ case E_BLOCK_AIR:
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ virtual bool CanBePlacedOnSide(void) override
+ {
+ return false;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.grass";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockMycelium.h b/source/Blocks/BlockMycelium.h
index 8e1f577e1..0ed7162ac 100644
--- a/source/Blocks/BlockMycelium.h
+++ b/source/Blocks/BlockMycelium.h
@@ -1,27 +1,27 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockMyceliumHandler :
- public cBlockHandler
-{
-public:
- cBlockMyceliumHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0));
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockMyceliumHandler :
+ public cBlockHandler
+{
+public:
+ cBlockMyceliumHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0));
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockNote.h b/source/Blocks/BlockNote.h
index 5884a1eb3..fef38d845 100644
--- a/source/Blocks/BlockNote.h
+++ b/source/Blocks/BlockNote.h
@@ -1,13 +1,13 @@
-#pragma once
-#include "BlockHandler.h"
-#include "BlockEntity.h"
-
-class cBlockNoteHandler : public cBlockEntityHandler
-{
-public:
- cBlockNoteHandler(BLOCKTYPE a_BlockType)
- : cBlockEntityHandler(a_BlockType)
- {
- }
-
-};
+#pragma once
+#include "BlockHandler.h"
+#include "BlockEntity.h"
+
+class cBlockNoteHandler : public cBlockEntityHandler
+{
+public:
+ cBlockNoteHandler(BLOCKTYPE a_BlockType)
+ : cBlockEntityHandler(a_BlockType)
+ {
+ }
+
+};
diff --git a/source/Blocks/BlockOre.h b/source/Blocks/BlockOre.h
index 1bfd8d17c..9684dbb19 100644
--- a/source/Blocks/BlockOre.h
+++ b/source/Blocks/BlockOre.h
@@ -1,80 +1,80 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../MersenneTwister.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockOreHandler :
- public cBlockHandler
-{
-public:
- cBlockOreHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- short ItemType = m_BlockType;
- char Count = 1;
- short Meta = 0;
-
- MTRand r1;
- switch (m_BlockType)
- {
- case E_BLOCK_LAPIS_ORE:
- {
- ItemType = E_ITEM_DYE;
- Count = 4 + (char)r1.randInt(4);
- Meta = 4;
- break;
- }
- case E_BLOCK_REDSTONE_ORE:
- case E_BLOCK_REDSTONE_ORE_GLOWING:
- {
- Count = 4 + (char)r1.randInt(1);
- break;
- }
- default:
- {
- Count = 1;
- break;
- }
- }
-
- switch (m_BlockType)
- {
- case E_BLOCK_DIAMOND_ORE:
- {
- ItemType = E_ITEM_DIAMOND;
- break;
- }
- case E_BLOCK_REDSTONE_ORE:
- case E_BLOCK_REDSTONE_ORE_GLOWING:
- {
- ItemType = E_ITEM_REDSTONE_DUST;
- break;
- }
- case E_BLOCK_EMERALD_ORE:
- {
- ItemType = E_ITEM_EMERALD;
- break;
- }
- case E_BLOCK_COAL_ORE:
- {
- ItemType = E_ITEM_COAL;
- break;
- }
- }
- a_Pickups.push_back(cItem(ItemType, Count, Meta));
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../MersenneTwister.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockOreHandler :
+ public cBlockHandler
+{
+public:
+ cBlockOreHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ short ItemType = m_BlockType;
+ char Count = 1;
+ short Meta = 0;
+
+ MTRand r1;
+ switch (m_BlockType)
+ {
+ case E_BLOCK_LAPIS_ORE:
+ {
+ ItemType = E_ITEM_DYE;
+ Count = 4 + (char)r1.randInt(4);
+ Meta = 4;
+ break;
+ }
+ case E_BLOCK_REDSTONE_ORE:
+ case E_BLOCK_REDSTONE_ORE_GLOWING:
+ {
+ Count = 4 + (char)r1.randInt(1);
+ break;
+ }
+ default:
+ {
+ Count = 1;
+ break;
+ }
+ }
+
+ switch (m_BlockType)
+ {
+ case E_BLOCK_DIAMOND_ORE:
+ {
+ ItemType = E_ITEM_DIAMOND;
+ break;
+ }
+ case E_BLOCK_REDSTONE_ORE:
+ case E_BLOCK_REDSTONE_ORE_GLOWING:
+ {
+ ItemType = E_ITEM_REDSTONE_DUST;
+ break;
+ }
+ case E_BLOCK_EMERALD_ORE:
+ {
+ ItemType = E_ITEM_EMERALD;
+ break;
+ }
+ case E_BLOCK_COAL_ORE:
+ {
+ ItemType = E_ITEM_COAL;
+ break;
+ }
+ }
+ a_Pickups.push_back(cItem(ItemType, Count, Meta));
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockPiston.cpp b/source/Blocks/BlockPiston.cpp
index 29312e97c..d0f90559e 100644
--- a/source/Blocks/BlockPiston.cpp
+++ b/source/Blocks/BlockPiston.cpp
@@ -1,69 +1,69 @@
-
-#include "Globals.h"
-#include "BlockPiston.h"
-#include "../Item.h"
-#include "../World.h"
-#include "../Player.h"
-#include "../Piston.h"
-
-
-
-
-
-#define AddPistonDir(x, y, z, dir, amount) \
- switch (dir) \
- { \
- case 0: (y) -= (amount); break; \
- case 1: (y) += (amount); break; \
- case 2: (z) -= (amount); break; \
- case 3: (z) += (amount); break; \
- case 4: (x) -= (amount); break; \
- case 5: (x) += (amount); break; \
- }
-
-
-
-
-cBlockPistonHandler::cBlockPistonHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockPistonHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- char OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
-
- int newX = a_BlockX;
- int newY = a_BlockY;
- int newZ = a_BlockZ;
- AddPistonDir(newX, newY, newZ, OldMeta & ~(8), 1);
-
- if (a_World->GetBlock(newX, newY, newZ) == E_BLOCK_PISTON_EXTENSION)
- {
- a_World->SetBlock(newX, newY, newZ, E_BLOCK_AIR, 0);
- }
-}
-
-
-
-
-
-bool cBlockPistonHandler::GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
-)
-{
- a_BlockType = m_BlockType;
- a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetRotation(), a_Player->GetPitch());
- return true;
-}
-
-
-
-
+
+#include "Globals.h"
+#include "BlockPiston.h"
+#include "../Item.h"
+#include "../World.h"
+#include "../Player.h"
+#include "../Piston.h"
+
+
+
+
+
+#define AddPistonDir(x, y, z, dir, amount) \
+ switch (dir) \
+ { \
+ case 0: (y) -= (amount); break; \
+ case 1: (y) += (amount); break; \
+ case 2: (z) -= (amount); break; \
+ case 3: (z) += (amount); break; \
+ case 4: (x) -= (amount); break; \
+ case 5: (x) += (amount); break; \
+ }
+
+
+
+
+cBlockPistonHandler::cBlockPistonHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+{
+}
+
+
+
+
+
+void cBlockPistonHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ char OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+
+ int newX = a_BlockX;
+ int newY = a_BlockY;
+ int newZ = a_BlockZ;
+ AddPistonDir(newX, newY, newZ, OldMeta & ~(8), 1);
+
+ if (a_World->GetBlock(newX, newY, newZ) == E_BLOCK_PISTON_EXTENSION)
+ {
+ a_World->SetBlock(newX, newY, newZ, E_BLOCK_AIR, 0);
+ }
+}
+
+
+
+
+
+bool cBlockPistonHandler::GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+)
+{
+ a_BlockType = m_BlockType;
+ a_BlockMeta = cPiston::RotationPitchToMetaData(a_Player->GetRotation(), a_Player->GetPitch());
+ return true;
+}
+
+
+
+
diff --git a/source/Blocks/BlockPiston.h b/source/Blocks/BlockPiston.h
index 5d9d5c2b7..ef6a4fa97 100644
--- a/source/Blocks/BlockPiston.h
+++ b/source/Blocks/BlockPiston.h
@@ -1,28 +1,28 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockPistonHandler :
- public cBlockHandler
-{
-public:
- cBlockPistonHandler(BLOCKTYPE a_BlockType);
-
- virtual void OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override;
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockPistonHandler :
+ public cBlockHandler
+{
+public:
+ cBlockPistonHandler(BLOCKTYPE a_BlockType);
+
+ virtual void OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override;
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockRail.h b/source/Blocks/BlockRail.h
index 60865abf5..65d120923 100644
--- a/source/Blocks/BlockRail.h
+++ b/source/Blocks/BlockRail.h
@@ -1,421 +1,421 @@
-
-#pragma once
-
-#include "BlockEntity.h"
-#include "../World.h"
-
-
-
-
-
-/// Meta values for the rail
-enum ENUM_RAIL_DIRECTIONS
-{
- E_RAIL_NORTH_SOUTH = 0,
- E_RAIL_EAST_WEST = 1,
- E_RAIL_ASCEND_EAST = 2,
- E_RAIL_ASCEND_WEST = 3,
- E_RAIL_ASCEND_NORTH = 4,
- E_RAIL_ASCEND_SOUTH = 5,
- E_RAIL_CURVED_SOUTH_EAST = 6,
- E_RAIL_CURVED_SOUTH_WEST = 7,
- E_RAIL_CURVED_NORTH_WEST = 8,
- E_RAIL_CURVED_NORTH_EAST = 9,
-
- // Some useful synonyms:
- E_RAIL_DIR_X = E_RAIL_EAST_WEST,
- E_RAIL_DIR_Z = E_RAIL_NORTH_SOUTH,
- E_RAIL_ASCEND_XP = E_RAIL_ASCEND_EAST,
- E_RAIL_ASCEND_XM = E_RAIL_ASCEND_WEST,
- E_RAIL_ASCEND_ZM = E_RAIL_ASCEND_NORTH,
- E_RAIL_ASCEND_ZP = E_RAIL_ASCEND_SOUTH,
- E_RAIL_CURVED_XPZP = E_RAIL_CURVED_SOUTH_EAST,
- E_RAIL_CURVED_XMZP = E_RAIL_CURVED_SOUTH_WEST,
- E_RAIL_CURVED_XMZM = E_RAIL_CURVED_NORTH_WEST,
- E_RAIL_CURVED_XPZM = E_RAIL_CURVED_NORTH_EAST,
-} ;
-
-
-
-
-
-enum ENUM_PURE
-{
- E_PURE_UPDOWN = 0,
- E_PURE_DOWN = 1,
- E_PURE_NONE = 2
-};
-
-
-
-
-
-class cBlockRailHandler :
- public cBlockHandler
-{
-public:
- cBlockRailHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = m_BlockType;
- a_BlockMeta = FindMeta(a_World, a_BlockX, a_BlockY, a_BlockZ);
- return true;
- }
-
-
- virtual void OnNeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if (IsUnstable(a_World, a_BlockX, a_BlockY, a_BlockZ) && (Meta != FindMeta(a_World, a_BlockX, a_BlockY, a_BlockZ)))
- {
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, FindMeta(a_World, a_BlockX, a_BlockY, a_BlockZ));
- }
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- if (a_RelY <= 0)
- {
- return false;
- }
- if (!g_BlockIsSolid[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)])
- {
- return false;
- }
-
- NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
- switch (Meta)
- {
- case E_RAIL_ASCEND_EAST:
- case E_RAIL_ASCEND_WEST:
- case E_RAIL_ASCEND_NORTH:
- case E_RAIL_ASCEND_SOUTH:
- {
- // Mapping between the meta and the neighbors that need checking
- Meta -= E_RAIL_ASCEND_EAST; // Base index at zero
- static const struct
- {
- int x, z;
- } Coords[] =
- {
- { 1, 0}, // east, XP
- {-1, 0}, // west, XM
- { 0, -1}, // north, ZM
- { 0, 1}, // south, ZP
- } ;
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (!a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[Meta].x, a_RelY, a_RelZ + Coords[Meta].z, BlockType, BlockMeta))
- {
- // Too close to the edge, cannot simulate
- return true;
- }
- return g_BlockIsSolid[BlockType];
- }
- }
- return true;
- }
-
- NIBBLETYPE FindMeta(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
- {
- 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
- memset(Neighbors, false, sizeof(Neighbors));
- Neighbors[0] = (IsUnstable(a_World, a_BlockX + 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN));
- Neighbors[1] = (IsUnstable(a_World, a_BlockX - 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN));
- Neighbors[2] = (IsUnstable(a_World, a_BlockX, a_BlockY, a_BlockZ - 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN));
- Neighbors[3] = (IsUnstable(a_World, a_BlockX, a_BlockY, a_BlockZ + 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_DOWN));
- Neighbors[4] = (IsUnstable(a_World, a_BlockX + 1, a_BlockY + 1, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST, E_PURE_NONE));
- Neighbors[5] = (IsUnstable(a_World, a_BlockX - 1, a_BlockY + 1, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_WEST, E_PURE_NONE));
- Neighbors[6] = (IsUnstable(a_World, a_BlockX, a_BlockY + 1, a_BlockZ - 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_NONE));
- Neighbors[7] = (IsUnstable(a_World, a_BlockX, a_BlockY + 1, a_BlockZ + 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_NONE));
- if (IsUnstable(a_World, a_BlockX + 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_EAST))
- Neighbors[0] = true;
- if (IsUnstable(a_World, a_BlockX - 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_WEST))
- Neighbors[1] = true;
- if (IsUnstable(a_World, a_BlockX, a_BlockY - 1, a_BlockZ - 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_NORTH))
- Neighbors[2] = true;
- if (IsUnstable(a_World, a_BlockX, a_BlockY - 1, a_BlockZ + 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_SOUTH))
- Neighbors[3] = true;
- for (int i = 0; i < 8; i++)
- {
- if (Neighbors[i])
- {
- RailsCnt++;
- }
- }
- if (RailsCnt == 1)
- {
- if (Neighbors[7]) return E_RAIL_ASCEND_SOUTH;
- else if (Neighbors[6]) return E_RAIL_ASCEND_NORTH;
- else if (Neighbors[5]) return E_RAIL_ASCEND_WEST;
- else if (Neighbors[4]) return E_RAIL_ASCEND_EAST;
- else if (Neighbors[0] || Neighbors[1]) return E_RAIL_EAST_WEST;
- else if (Neighbors[2] || Neighbors[3]) return E_RAIL_NORTH_SOUTH;
- ASSERT(!"Weird neighbor count");
- return Meta;
- }
- for (int i = 0; i < 4; i++)
- {
- if (Neighbors[i + 4])
- {
- Neighbors[i] = true;
- }
- }
- if (RailsCnt > 1)
- {
- if (Neighbors[3] && Neighbors[0]) return E_RAIL_CURVED_SOUTH_EAST;
- else if (Neighbors[3] && Neighbors[1]) return E_RAIL_CURVED_SOUTH_WEST;
- else if (Neighbors[2] && Neighbors[0]) return E_RAIL_CURVED_NORTH_EAST;
- else if (Neighbors[2] && Neighbors[1]) return E_RAIL_CURVED_NORTH_WEST;
- else if (Neighbors[7] && Neighbors[2]) return E_RAIL_ASCEND_SOUTH;
- else if (Neighbors[3] && Neighbors[6]) return E_RAIL_ASCEND_NORTH;
- else if (Neighbors[5] && Neighbors[0]) return E_RAIL_ASCEND_WEST;
- else if (Neighbors[4] && Neighbors[1]) return E_RAIL_ASCEND_EAST;
- else if (Neighbors[0] && Neighbors[1]) return E_RAIL_EAST_WEST;
- else if (Neighbors[2] && Neighbors[3]) return E_RAIL_NORTH_SOUTH;
- ASSERT(!"Weird neighbor count");
- }
- return Meta;
- }
-
-
- bool IsUnstable(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
- {
- if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_RAIL)
- {
- return false;
- }
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- switch (Meta)
- {
- case E_RAIL_NORTH_SOUTH:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_DOWN)
- )
- {
- return true;
- }
- break;
- }
-
- case E_RAIL_EAST_WEST:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN)
- )
- {
- return true;
- }
- break;
- }
-
- case E_RAIL_ASCEND_EAST:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
- )
- {
- return true;
- }
- break;
- }
-
- case E_RAIL_ASCEND_WEST:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_WEST)
- )
- {
- return true;
- }
- break;
- }
-
- case E_RAIL_ASCEND_NORTH:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH)
- )
- {
- return true;
- }
- break;
- }
-
- case E_RAIL_ASCEND_SOUTH:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH)
- )
- {
- return true;
- }
- break;
- }
-
- case E_RAIL_CURVED_SOUTH_EAST:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST)
- )
- {
- return true;
- }
- break;
- }
-
- case E_RAIL_CURVED_SOUTH_WEST:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
- )
- {
- return true;
- }
- break;
- }
-
- case E_RAIL_CURVED_NORTH_WEST:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
- )
- {
- return true;
- }
- break;
- }
-
- case E_RAIL_CURVED_NORTH_EAST:
- {
- if (
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
- IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST)
- )
- {
- return true;
- }
- break;
- }
- }
- return false;
- }
-
-
- bool IsNotConnected(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Pure = 0)
- {
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false);
- NIBBLETYPE Meta;
- if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_RAIL)
- {
- if ((a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ) != E_BLOCK_RAIL) || (a_Pure != E_PURE_UPDOWN))
- {
- if ((a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) != E_BLOCK_RAIL) || (a_Pure == E_PURE_NONE))
- {
- return true;
- }
- else
- {
- Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ);
- }
- }
- else
- {
- Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ);
- }
- }
- else
- {
- Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- }
-
- switch (a_BlockFace)
- {
- case BLOCK_FACE_NORTH:
- {
- if (
- (Meta == E_RAIL_NORTH_SOUTH) ||
- (Meta == E_RAIL_ASCEND_NORTH) ||
- (Meta == E_RAIL_ASCEND_SOUTH) ||
- (Meta == E_RAIL_CURVED_SOUTH_EAST) ||
- (Meta == E_RAIL_CURVED_SOUTH_WEST)
- )
- {
- return false;
- }
- break;
- }
-
- case BLOCK_FACE_SOUTH:
- {
- if (
- (Meta == E_RAIL_NORTH_SOUTH) ||
- (Meta == E_RAIL_ASCEND_NORTH) ||
- (Meta == E_RAIL_ASCEND_SOUTH) ||
- (Meta == E_RAIL_CURVED_NORTH_EAST) ||
- (Meta == E_RAIL_CURVED_NORTH_WEST)
- )
- {
- return false;
- }
- break;
- }
-
- case BLOCK_FACE_EAST:
- {
- if (
- (Meta == E_RAIL_EAST_WEST) ||
- (Meta == E_RAIL_ASCEND_EAST) ||
- (Meta == E_RAIL_ASCEND_WEST) ||
- (Meta == E_RAIL_CURVED_SOUTH_WEST) ||
- (Meta == E_RAIL_CURVED_NORTH_WEST)
- )
- {
- return false;
- }
- break;
- }
- case BLOCK_FACE_WEST:
- {
- if (
- (Meta == E_RAIL_EAST_WEST) ||
- (Meta == E_RAIL_ASCEND_EAST) ||
- (Meta == E_RAIL_ASCEND_WEST) ||
- (Meta == E_RAIL_CURVED_SOUTH_EAST) ||
- (Meta == E_RAIL_CURVED_NORTH_EAST)
- )
- {
- return false;
- }
- break;
- }
- }
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockEntity.h"
+#include "../World.h"
+
+
+
+
+
+/// Meta values for the rail
+enum ENUM_RAIL_DIRECTIONS
+{
+ E_RAIL_NORTH_SOUTH = 0,
+ E_RAIL_EAST_WEST = 1,
+ E_RAIL_ASCEND_EAST = 2,
+ E_RAIL_ASCEND_WEST = 3,
+ E_RAIL_ASCEND_NORTH = 4,
+ E_RAIL_ASCEND_SOUTH = 5,
+ E_RAIL_CURVED_SOUTH_EAST = 6,
+ E_RAIL_CURVED_SOUTH_WEST = 7,
+ E_RAIL_CURVED_NORTH_WEST = 8,
+ E_RAIL_CURVED_NORTH_EAST = 9,
+
+ // Some useful synonyms:
+ E_RAIL_DIR_X = E_RAIL_EAST_WEST,
+ E_RAIL_DIR_Z = E_RAIL_NORTH_SOUTH,
+ E_RAIL_ASCEND_XP = E_RAIL_ASCEND_EAST,
+ E_RAIL_ASCEND_XM = E_RAIL_ASCEND_WEST,
+ E_RAIL_ASCEND_ZM = E_RAIL_ASCEND_NORTH,
+ E_RAIL_ASCEND_ZP = E_RAIL_ASCEND_SOUTH,
+ E_RAIL_CURVED_XPZP = E_RAIL_CURVED_SOUTH_EAST,
+ E_RAIL_CURVED_XMZP = E_RAIL_CURVED_SOUTH_WEST,
+ E_RAIL_CURVED_XMZM = E_RAIL_CURVED_NORTH_WEST,
+ E_RAIL_CURVED_XPZM = E_RAIL_CURVED_NORTH_EAST,
+} ;
+
+
+
+
+
+enum ENUM_PURE
+{
+ E_PURE_UPDOWN = 0,
+ E_PURE_DOWN = 1,
+ E_PURE_NONE = 2
+};
+
+
+
+
+
+class cBlockRailHandler :
+ public cBlockHandler
+{
+public:
+ cBlockRailHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = m_BlockType;
+ a_BlockMeta = FindMeta(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ return true;
+ }
+
+
+ virtual void OnNeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ if (IsUnstable(a_World, a_BlockX, a_BlockY, a_BlockZ) && (Meta != FindMeta(a_World, a_BlockX, a_BlockY, a_BlockZ)))
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, FindMeta(a_World, a_BlockX, a_BlockY, a_BlockZ));
+ }
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+ if (!g_BlockIsSolid[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)])
+ {
+ return false;
+ }
+
+ NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
+ switch (Meta)
+ {
+ case E_RAIL_ASCEND_EAST:
+ case E_RAIL_ASCEND_WEST:
+ case E_RAIL_ASCEND_NORTH:
+ case E_RAIL_ASCEND_SOUTH:
+ {
+ // Mapping between the meta and the neighbors that need checking
+ Meta -= E_RAIL_ASCEND_EAST; // Base index at zero
+ static const struct
+ {
+ int x, z;
+ } Coords[] =
+ {
+ { 1, 0}, // east, XP
+ {-1, 0}, // west, XM
+ { 0, -1}, // north, ZM
+ { 0, 1}, // south, ZP
+ } ;
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (!a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[Meta].x, a_RelY, a_RelZ + Coords[Meta].z, BlockType, BlockMeta))
+ {
+ // Too close to the edge, cannot simulate
+ return true;
+ }
+ return g_BlockIsSolid[BlockType];
+ }
+ }
+ return true;
+ }
+
+ NIBBLETYPE FindMeta(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ 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
+ memset(Neighbors, false, sizeof(Neighbors));
+ Neighbors[0] = (IsUnstable(a_World, a_BlockX + 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN));
+ Neighbors[1] = (IsUnstable(a_World, a_BlockX - 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN));
+ Neighbors[2] = (IsUnstable(a_World, a_BlockX, a_BlockY, a_BlockZ - 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN));
+ Neighbors[3] = (IsUnstable(a_World, a_BlockX, a_BlockY, a_BlockZ + 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_DOWN));
+ Neighbors[4] = (IsUnstable(a_World, a_BlockX + 1, a_BlockY + 1, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST, E_PURE_NONE));
+ Neighbors[5] = (IsUnstable(a_World, a_BlockX - 1, a_BlockY + 1, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_WEST, E_PURE_NONE));
+ Neighbors[6] = (IsUnstable(a_World, a_BlockX, a_BlockY + 1, a_BlockZ - 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_NONE));
+ Neighbors[7] = (IsUnstable(a_World, a_BlockX, a_BlockY + 1, a_BlockZ + 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_NONE));
+ if (IsUnstable(a_World, a_BlockX + 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_EAST))
+ Neighbors[0] = true;
+ if (IsUnstable(a_World, a_BlockX - 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_World, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_WEST))
+ Neighbors[1] = true;
+ if (IsUnstable(a_World, a_BlockX, a_BlockY - 1, a_BlockZ - 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_NORTH))
+ Neighbors[2] = true;
+ if (IsUnstable(a_World, a_BlockX, a_BlockY - 1, a_BlockZ + 1) || !IsNotConnected(a_World, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_SOUTH))
+ Neighbors[3] = true;
+ for (int i = 0; i < 8; i++)
+ {
+ if (Neighbors[i])
+ {
+ RailsCnt++;
+ }
+ }
+ if (RailsCnt == 1)
+ {
+ if (Neighbors[7]) return E_RAIL_ASCEND_SOUTH;
+ else if (Neighbors[6]) return E_RAIL_ASCEND_NORTH;
+ else if (Neighbors[5]) return E_RAIL_ASCEND_WEST;
+ else if (Neighbors[4]) return E_RAIL_ASCEND_EAST;
+ else if (Neighbors[0] || Neighbors[1]) return E_RAIL_EAST_WEST;
+ else if (Neighbors[2] || Neighbors[3]) return E_RAIL_NORTH_SOUTH;
+ ASSERT(!"Weird neighbor count");
+ return Meta;
+ }
+ for (int i = 0; i < 4; i++)
+ {
+ if (Neighbors[i + 4])
+ {
+ Neighbors[i] = true;
+ }
+ }
+ if (RailsCnt > 1)
+ {
+ if (Neighbors[3] && Neighbors[0]) return E_RAIL_CURVED_SOUTH_EAST;
+ else if (Neighbors[3] && Neighbors[1]) return E_RAIL_CURVED_SOUTH_WEST;
+ else if (Neighbors[2] && Neighbors[0]) return E_RAIL_CURVED_NORTH_EAST;
+ else if (Neighbors[2] && Neighbors[1]) return E_RAIL_CURVED_NORTH_WEST;
+ else if (Neighbors[7] && Neighbors[2]) return E_RAIL_ASCEND_SOUTH;
+ else if (Neighbors[3] && Neighbors[6]) return E_RAIL_ASCEND_NORTH;
+ else if (Neighbors[5] && Neighbors[0]) return E_RAIL_ASCEND_WEST;
+ else if (Neighbors[4] && Neighbors[1]) return E_RAIL_ASCEND_EAST;
+ else if (Neighbors[0] && Neighbors[1]) return E_RAIL_EAST_WEST;
+ else if (Neighbors[2] && Neighbors[3]) return E_RAIL_NORTH_SOUTH;
+ ASSERT(!"Weird neighbor count");
+ }
+ return Meta;
+ }
+
+
+ bool IsUnstable(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_RAIL)
+ {
+ return false;
+ }
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ switch (Meta)
+ {
+ case E_RAIL_NORTH_SOUTH:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_DOWN)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+
+ case E_RAIL_EAST_WEST:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+
+ case E_RAIL_ASCEND_EAST:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+
+ case E_RAIL_ASCEND_WEST:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_WEST)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+
+ case E_RAIL_ASCEND_NORTH:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+
+ case E_RAIL_ASCEND_SOUTH:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+
+ case E_RAIL_CURVED_SOUTH_EAST:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+
+ case E_RAIL_CURVED_SOUTH_WEST:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+
+ case E_RAIL_CURVED_NORTH_WEST:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+
+ case E_RAIL_CURVED_NORTH_EAST:
+ {
+ if (
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
+ IsNotConnected(a_World, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST)
+ )
+ {
+ return true;
+ }
+ break;
+ }
+ }
+ return false;
+ }
+
+
+ bool IsNotConnected(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Pure = 0)
+ {
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false);
+ NIBBLETYPE Meta;
+ if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_RAIL)
+ {
+ if ((a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ) != E_BLOCK_RAIL) || (a_Pure != E_PURE_UPDOWN))
+ {
+ if ((a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) != E_BLOCK_RAIL) || (a_Pure == E_PURE_NONE))
+ {
+ return true;
+ }
+ else
+ {
+ Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ);
+ }
+ }
+ else
+ {
+ Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ);
+ }
+ }
+ else
+ {
+ Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ }
+
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_NORTH:
+ {
+ if (
+ (Meta == E_RAIL_NORTH_SOUTH) ||
+ (Meta == E_RAIL_ASCEND_NORTH) ||
+ (Meta == E_RAIL_ASCEND_SOUTH) ||
+ (Meta == E_RAIL_CURVED_SOUTH_EAST) ||
+ (Meta == E_RAIL_CURVED_SOUTH_WEST)
+ )
+ {
+ return false;
+ }
+ break;
+ }
+
+ case BLOCK_FACE_SOUTH:
+ {
+ if (
+ (Meta == E_RAIL_NORTH_SOUTH) ||
+ (Meta == E_RAIL_ASCEND_NORTH) ||
+ (Meta == E_RAIL_ASCEND_SOUTH) ||
+ (Meta == E_RAIL_CURVED_NORTH_EAST) ||
+ (Meta == E_RAIL_CURVED_NORTH_WEST)
+ )
+ {
+ return false;
+ }
+ break;
+ }
+
+ case BLOCK_FACE_EAST:
+ {
+ if (
+ (Meta == E_RAIL_EAST_WEST) ||
+ (Meta == E_RAIL_ASCEND_EAST) ||
+ (Meta == E_RAIL_ASCEND_WEST) ||
+ (Meta == E_RAIL_CURVED_SOUTH_WEST) ||
+ (Meta == E_RAIL_CURVED_NORTH_WEST)
+ )
+ {
+ return false;
+ }
+ break;
+ }
+ case BLOCK_FACE_WEST:
+ {
+ if (
+ (Meta == E_RAIL_EAST_WEST) ||
+ (Meta == E_RAIL_ASCEND_EAST) ||
+ (Meta == E_RAIL_ASCEND_WEST) ||
+ (Meta == E_RAIL_CURVED_SOUTH_EAST) ||
+ (Meta == E_RAIL_CURVED_NORTH_EAST)
+ )
+ {
+ return false;
+ }
+ break;
+ }
+ }
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockRedstone.cpp b/source/Blocks/BlockRedstone.cpp
index f433be4ef..35cdc34cf 100644
--- a/source/Blocks/BlockRedstone.cpp
+++ b/source/Blocks/BlockRedstone.cpp
@@ -1,27 +1,27 @@
-
-#include "Globals.h"
-#include "BlockRedstone.h"
-#include "../Item.h"
-#include "../World.h"
-
-
-
-
-
-cBlockRedstoneHandler::cBlockRedstoneHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockRedstoneHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- // Nothing needed yet
-}
-
-
-
-
+
+#include "Globals.h"
+#include "BlockRedstone.h"
+#include "../Item.h"
+#include "../World.h"
+
+
+
+
+
+cBlockRedstoneHandler::cBlockRedstoneHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+{
+}
+
+
+
+
+
+void cBlockRedstoneHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ // Nothing needed yet
+}
+
+
+
+
diff --git a/source/Blocks/BlockRedstone.h b/source/Blocks/BlockRedstone.h
index 3a4649d7e..ae0466937 100644
--- a/source/Blocks/BlockRedstone.h
+++ b/source/Blocks/BlockRedstone.h
@@ -1,46 +1,46 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockRedstoneHandler :
- public cBlockHandler
-{
-public:
- cBlockRedstoneHandler(BLOCKTYPE a_BlockType);
-
- virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return ((a_RelY > 0) && g_BlockIsSolid[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)]);
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Reset meta to 0
- a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, 1));
- }
-
-
- virtual bool CanBePlacedOnSide(void) override
- {
- return false;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockRedstoneHandler :
+ public cBlockHandler
+{
+public:
+ cBlockRedstoneHandler(BLOCKTYPE a_BlockType);
+
+ virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ return ((a_RelY > 0) && g_BlockIsSolid[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)]);
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, 1));
+ }
+
+
+ virtual bool CanBePlacedOnSide(void) override
+ {
+ return false;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockRedstoneRepeater.cpp b/source/Blocks/BlockRedstoneRepeater.cpp
index 15b736cbc..9857dd223 100644
--- a/source/Blocks/BlockRedstoneRepeater.cpp
+++ b/source/Blocks/BlockRedstoneRepeater.cpp
@@ -1,47 +1,47 @@
-
-#include "Globals.h"
-#include "BlockRedstoneRepeater.h"
-#include "../Item.h"
-#include "../World.h"
-#include "../Player.h"
-#include "../Simulator/RedstoneSimulator.h"
-
-
-
-
-
-cBlockRedstoneRepeaterHandler::cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockRedstoneRepeaterHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- // Nothing needed yet
-}
-
-
-
-
-
-void cBlockRedstoneRepeaterHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
-{
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
-}
-
-
-
-
-
-void cBlockRedstoneRepeaterHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NONE, 8, 8, 8);
-}
-
-
-
-
+
+#include "Globals.h"
+#include "BlockRedstoneRepeater.h"
+#include "../Item.h"
+#include "../World.h"
+#include "../Player.h"
+#include "../Simulator/RedstoneSimulator.h"
+
+
+
+
+
+cBlockRedstoneRepeaterHandler::cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+{
+}
+
+
+
+
+
+void cBlockRedstoneRepeaterHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ // Nothing needed yet
+}
+
+
+
+
+
+void cBlockRedstoneRepeaterHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+{
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
+}
+
+
+
+
+
+void cBlockRedstoneRepeaterHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NONE, 8, 8, 8);
+}
+
+
+
+
diff --git a/source/Blocks/BlockRedstoneRepeater.h b/source/Blocks/BlockRedstoneRepeater.h
index 4a16149fd..f3e250963 100644
--- a/source/Blocks/BlockRedstoneRepeater.h
+++ b/source/Blocks/BlockRedstoneRepeater.h
@@ -1,60 +1,60 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockRedstoneRepeaterHandler :
- public cBlockHandler
-{
-public:
- cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType);
- virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
-
- virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
- virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Reset meta to 0
- a_Pickups.push_back(cItem(E_ITEM_REDSTONE_REPEATER, 1, 0));
- }
-
-
- virtual bool IsUseable(void) override
- {
- return true;
- }
-
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
- }
-
-
- virtual bool CanBePlacedOnSide(void) override
- {
- return false;
- }
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockRedstoneRepeaterHandler :
+ public cBlockHandler
+{
+public:
+ cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType);
+ virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+
+ virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(E_ITEM_REDSTONE_REPEATER, 1, 0));
+ }
+
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
+ }
+
+
+ virtual bool CanBePlacedOnSide(void) override
+ {
+ return false;
+ }
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockRedstoneTorch.h b/source/Blocks/BlockRedstoneTorch.h
index c8256ce64..cb897ba3f 100644
--- a/source/Blocks/BlockRedstoneTorch.h
+++ b/source/Blocks/BlockRedstoneTorch.h
@@ -1,36 +1,36 @@
-
-#pragma once
-
-#include "BlockRedstone.h"
-#include "BlockTorch.h"
-
-
-
-
-
-class cBlockRedstoneTorchHandler :
- public cBlockTorchHandler
-{
-public:
- cBlockRedstoneTorchHandler(BLOCKTYPE a_BlockType)
- : cBlockTorchHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Always drop the ON torch, meta 0
- a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_TORCH_ON, 1, 0));
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockRedstone.h"
+#include "BlockTorch.h"
+
+
+
+
+
+class cBlockRedstoneTorchHandler :
+ public cBlockTorchHandler
+{
+public:
+ cBlockRedstoneTorchHandler(BLOCKTYPE a_BlockType)
+ : cBlockTorchHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Always drop the ON torch, meta 0
+ a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_TORCH_ON, 1, 0));
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockSand.h b/source/Blocks/BlockSand.h
index 878770d22..3fc271483 100644
--- a/source/Blocks/BlockSand.h
+++ b/source/Blocks/BlockSand.h
@@ -1,28 +1,28 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockSandHandler :
- public cBlockHandler
-{
-public:
- cBlockSandHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual const char * GetStepSound(void) override
- {
- return "step.sand";
- }
-
-};
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockSandHandler :
+ public cBlockHandler
+{
+public:
+ cBlockSandHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.sand";
+ }
+
+};
+
+
+
+
diff --git a/source/Blocks/BlockSapling.h b/source/Blocks/BlockSapling.h
index 957331886..17ef4984f 100644
--- a/source/Blocks/BlockSapling.h
+++ b/source/Blocks/BlockSapling.h
@@ -1,69 +1,69 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockSaplingHandler :
- public cBlockHandler
-{
-public:
- cBlockSaplingHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- 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));
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ));
- }
-
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
-
- if ((Meta & 0x08) != 0)
- {
- a_World->GrowTree(a_BlockX, a_BlockY, a_BlockZ);
- }
- else
- {
- a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x08);
- }
- }
-
-
- virtual bool CanBePlacedOnSide() override
- {
- return false;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.grass";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockSaplingHandler :
+ public cBlockHandler
+{
+public:
+ cBlockSaplingHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ 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));
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ));
+ }
+
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+
+ if ((Meta & 0x08) != 0)
+ {
+ a_World->GrowTree(a_BlockX, a_BlockY, a_BlockZ);
+ }
+ else
+ {
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x08);
+ }
+ }
+
+
+ virtual bool CanBePlacedOnSide() override
+ {
+ return false;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.grass";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockSign.h b/source/Blocks/BlockSign.h
index 4bdccb47e..09fa721b6 100644
--- a/source/Blocks/BlockSign.h
+++ b/source/Blocks/BlockSign.h
@@ -1,73 +1,84 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-#include "../Player.h"
-
-
-
-
-
-class cBlockSignHandler :
- public cBlockHandler
-{
-public:
- cBlockSignHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
- }
-
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-
-
- static char RotationToMetaData(double a_Rotation)
- {
- a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
- if (a_Rotation > 360)
- {
- a_Rotation -= 360;
- }
-
- a_Rotation = (a_Rotation / 360) * 16;
-
- return ((char)a_Rotation) % 16;
- }
-
-
- static char DirectionToMetaData(char 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;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+#include "../Player.h"
+
+
+
+
+
+class cBlockSignHandler :
+ public cBlockHandler
+{
+public:
+ cBlockSignHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
+ }
+
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+
+
+ static char RotationToMetaData(double a_Rotation)
+ {
+ a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
+ if (a_Rotation > 360)
+ {
+ a_Rotation -= 360;
+ }
+
+ a_Rotation = (a_Rotation / 360) * 16;
+
+ return ((char)a_Rotation) % 16;
+ }
+
+
+ static char DirectionToMetaData(char 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(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h
index 2abcc6364..f34f42bae 100644
--- a/source/Blocks/BlockSlab.h
+++ b/source/Blocks/BlockSlab.h
@@ -1,70 +1,70 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockSlabHandler :
- public cBlockHandler
-{
-public:
- cBlockSlabHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- char Count = ((m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? 2 : 1;
- a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta));
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = m_BlockType;
- NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07);
- switch (a_BlockFace)
- {
- case BLOCK_FACE_TOP: a_BlockMeta = Meta & 0x7; break; // Always bottom half of the slab when placing on top of something
- case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; // Always top half of the slab when placing on bottom of something
- case BLOCK_FACE_EAST:
- case BLOCK_FACE_NORTH:
- case BLOCK_FACE_SOUTH:
- case BLOCK_FACE_WEST:
- {
- if (a_CursorY > 7)
- {
- // Cursor at the top half of the face, place a top half of slab
- a_BlockMeta = Meta | 0x8;
- }
- else
- {
- // Cursor at the bottom half of the face, place a bottom half of slab:
- a_BlockMeta = Meta & 0x7;
- }
- break;
- }
- } // switch (a_BlockFace)
- return true;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockSlabHandler :
+ public cBlockHandler
+{
+public:
+ cBlockSlabHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ char Count = ((m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? 2 : 1;
+ a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta));
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = m_BlockType;
+ NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07);
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_TOP: a_BlockMeta = Meta & 0x7; break; // Always bottom half of the slab when placing on top of something
+ case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; // Always top half of the slab when placing on bottom of something
+ case BLOCK_FACE_EAST:
+ case BLOCK_FACE_NORTH:
+ case BLOCK_FACE_SOUTH:
+ case BLOCK_FACE_WEST:
+ {
+ if (a_CursorY > 7)
+ {
+ // Cursor at the top half of the face, place a top half of slab
+ a_BlockMeta = Meta | 0x8;
+ }
+ else
+ {
+ // Cursor at the bottom half of the face, place a bottom half of slab:
+ a_BlockMeta = Meta & 0x7;
+ }
+ break;
+ }
+ } // switch (a_BlockFace)
+ return true;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockSnow.h b/source/Blocks/BlockSnow.h
index f150f497c..bdd9f0b87 100644
--- a/source/Blocks/BlockSnow.h
+++ b/source/Blocks/BlockSnow.h
@@ -1,52 +1,52 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockSnowHandler :
- public cBlockHandler
-{
-public:
- cBlockSnowHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual bool DoesIgnoreBuildCollision(void) override
- {
- return true;
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_SNOWBALL, 1, 0));
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return (a_RelY > 0) && g_BlockIsSnowable[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)];
- }
-
-
- virtual bool DoesDropOnUnsuitable(void) override
- {
- return false;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.cloth";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockSnowHandler :
+ public cBlockHandler
+{
+public:
+ cBlockSnowHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool DoesIgnoreBuildCollision(void) override
+ {
+ return true;
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_SNOWBALL, 1, 0));
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ return (a_RelY > 0) && g_BlockIsSnowable[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)];
+ }
+
+
+ virtual bool DoesDropOnUnsuitable(void) override
+ {
+ return false;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.cloth";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockStairs.h b/source/Blocks/BlockStairs.h
index 6fc316e45..485ebda1a 100644
--- a/source/Blocks/BlockStairs.h
+++ b/source/Blocks/BlockStairs.h
@@ -1,153 +1,153 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockStairsHandler :
- public cBlockHandler
-{
-public:
- cBlockStairsHandler(BLOCKTYPE a_BlockType) :
- cBlockHandler(a_BlockType)
- {
-
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = m_BlockType;
- a_BlockMeta = RotationToMetaData(a_Player->GetRotation());
- switch (a_BlockFace)
- {
- case BLOCK_FACE_TOP: break;
- case BLOCK_FACE_BOTTOM: a_BlockMeta = a_BlockMeta | 0x4; break; // When placing onto a bottom face, always place an upside-down stairs block
- case BLOCK_FACE_EAST:
- case BLOCK_FACE_NORTH:
- case BLOCK_FACE_SOUTH:
- case BLOCK_FACE_WEST:
- {
- // When placing onto a sideways face, check cursor, if in top half, make it an upside-down stairs block
- if (a_CursorY > 8)
- {
- a_BlockMeta |= 0x4;
- }
- break;
- }
- }
- return true;
- }
-
- // TODO: step sound
-
-
- static NIBBLETYPE RotationToMetaData(double a_Rotation)
- {
- a_Rotation += 90 + 45; // So its not aligned with axis
- NIBBLETYPE result = 0x0;
- if (a_Rotation > 360)
- {
- a_Rotation -= 360;
- }
- if ((a_Rotation >= 0) && (a_Rotation < 90))
- {
- return 0x0;
- }
- else if ((a_Rotation >= 180) && (a_Rotation < 270))
- {
- return 0x1;
- }
- else if ((a_Rotation >= 90) && (a_Rotation < 180))
- {
- return 0x2;
- }
- else
- {
- return 0x3;
- }
- }
-
-
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
- {
- // Bits 3 and 4 stay, the rest is swapped around according to a table:
- NIBBLETYPE TopBits = (a_Meta & 0x0c);
- switch (a_Meta & 0x03)
- {
- case 0x00: return TopBits | 0x03; // East -> North
- case 0x01: return TopBits | 0x02; // West -> South
- case 0x02: return TopBits | 0x00; // South -> East
- case 0x03: return TopBits | 0x01; // North -> West
- }
- // Not reachable, but to avoid a compiler warning:
- return 0;
- }
-
-
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
- {
- // Bits 3 and 4 stay, the rest is swapped around according to a table:
- NIBBLETYPE TopBits = (a_Meta & 0x0c);
- switch (a_Meta & 0x03)
- {
- case 0x00: return TopBits | 0x02; // East -> South
- case 0x01: return TopBits | 0x03; // West -> North
- case 0x02: return TopBits | 0x01; // South -> West
- case 0x03: return TopBits | 0x00; // North -> East
- }
- // Not reachable, but to avoid a compiler warning:
- return 0;
- }
-
-
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
- {
- // Bits 3 and 4 stay, the rest is swapped around according to a table:
- NIBBLETYPE TopBits = (a_Meta & 0x0c);
- switch (a_Meta & 0x03)
- {
- case 0x00: return TopBits | 0x00; // East -> East
- case 0x01: return TopBits | 0x01; // West -> West
- case 0x02: return TopBits | 0x03; // South -> North
- case 0x03: return TopBits | 0x02; // North -> South
- }
- // Not reachable, but to avoid a compiler warning:
- return 0;
- }
-
-
- virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
- {
- // Toggle bit 3:
- return (a_Meta & 0x0b) | ((~a_Meta) & 0x04);
- }
-
-
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
- {
- // Bits 3 and 4 stay, the rest is swapped around according to a table:
- NIBBLETYPE TopBits = (a_Meta & 0x0c);
- switch (a_Meta & 0x03)
- {
- case 0x00: return TopBits | 0x01; // East -> West
- case 0x01: return TopBits | 0x00; // West -> East
- case 0x02: return TopBits | 0x02; // South -> South
- case 0x03: return TopBits | 0x03; // North -> North
- }
- // Not reachable, but to avoid a compiler warning:
- return 0;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockStairsHandler :
+ public cBlockHandler
+{
+public:
+ cBlockStairsHandler(BLOCKTYPE a_BlockType) :
+ cBlockHandler(a_BlockType)
+ {
+
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = m_BlockType;
+ a_BlockMeta = RotationToMetaData(a_Player->GetRotation());
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_TOP: break;
+ case BLOCK_FACE_BOTTOM: a_BlockMeta = a_BlockMeta | 0x4; break; // When placing onto a bottom face, always place an upside-down stairs block
+ case BLOCK_FACE_EAST:
+ case BLOCK_FACE_NORTH:
+ case BLOCK_FACE_SOUTH:
+ case BLOCK_FACE_WEST:
+ {
+ // When placing onto a sideways face, check cursor, if in top half, make it an upside-down stairs block
+ if (a_CursorY > 8)
+ {
+ a_BlockMeta |= 0x4;
+ }
+ break;
+ }
+ }
+ return true;
+ }
+
+ // TODO: step sound
+
+
+ static NIBBLETYPE RotationToMetaData(double a_Rotation)
+ {
+ a_Rotation += 90 + 45; // So its not aligned with axis
+ NIBBLETYPE result = 0x0;
+ if (a_Rotation > 360)
+ {
+ a_Rotation -= 360;
+ }
+ if ((a_Rotation >= 0) && (a_Rotation < 90))
+ {
+ return 0x0;
+ }
+ else if ((a_Rotation >= 180) && (a_Rotation < 270))
+ {
+ return 0x1;
+ }
+ else if ((a_Rotation >= 90) && (a_Rotation < 180))
+ {
+ return 0x2;
+ }
+ else
+ {
+ return 0x3;
+ }
+ }
+
+
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
+ {
+ // Bits 3 and 4 stay, the rest is swapped around according to a table:
+ NIBBLETYPE TopBits = (a_Meta & 0x0c);
+ switch (a_Meta & 0x03)
+ {
+ case 0x00: return TopBits | 0x03; // East -> North
+ case 0x01: return TopBits | 0x02; // West -> South
+ case 0x02: return TopBits | 0x00; // South -> East
+ case 0x03: return TopBits | 0x01; // North -> West
+ }
+ // Not reachable, but to avoid a compiler warning:
+ return 0;
+ }
+
+
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
+ {
+ // Bits 3 and 4 stay, the rest is swapped around according to a table:
+ NIBBLETYPE TopBits = (a_Meta & 0x0c);
+ switch (a_Meta & 0x03)
+ {
+ case 0x00: return TopBits | 0x02; // East -> South
+ case 0x01: return TopBits | 0x03; // West -> North
+ case 0x02: return TopBits | 0x01; // South -> West
+ case 0x03: return TopBits | 0x00; // North -> East
+ }
+ // Not reachable, but to avoid a compiler warning:
+ return 0;
+ }
+
+
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
+ {
+ // Bits 3 and 4 stay, the rest is swapped around according to a table:
+ NIBBLETYPE TopBits = (a_Meta & 0x0c);
+ switch (a_Meta & 0x03)
+ {
+ case 0x00: return TopBits | 0x00; // East -> East
+ case 0x01: return TopBits | 0x01; // West -> West
+ case 0x02: return TopBits | 0x03; // South -> North
+ case 0x03: return TopBits | 0x02; // North -> South
+ }
+ // Not reachable, but to avoid a compiler warning:
+ return 0;
+ }
+
+
+ virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
+ {
+ // Toggle bit 3:
+ return (a_Meta & 0x0b) | ((~a_Meta) & 0x04);
+ }
+
+
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
+ {
+ // Bits 3 and 4 stay, the rest is swapped around according to a table:
+ NIBBLETYPE TopBits = (a_Meta & 0x0c);
+ switch (a_Meta & 0x03)
+ {
+ case 0x00: return TopBits | 0x01; // East -> West
+ case 0x01: return TopBits | 0x00; // West -> East
+ case 0x02: return TopBits | 0x02; // South -> South
+ case 0x03: return TopBits | 0x03; // North -> North
+ }
+ // Not reachable, but to avoid a compiler warning:
+ return 0;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockStems.h b/source/Blocks/BlockStems.h
index 44c4d9cc9..ce02d9cb8 100644
--- a/source/Blocks/BlockStems.h
+++ b/source/Blocks/BlockStems.h
@@ -1,58 +1,58 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../MersenneTwister.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockStemsHandler :
- public cBlockHandler
-{
-public:
- cBlockStemsHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- int ItemType = (m_BlockType == E_BLOCK_MELON_STEM) ? E_ITEM_MELON_SEEDS : E_ITEM_PUMPKIN_SEEDS;
- a_Pickups.push_back(cItem(ItemType, 1, 0));
- }
-
-
- void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if (Meta >= 7)
- {
- // Grow the produce:
- a_World->GrowMelonPumpkin(a_BlockX, a_BlockY, a_BlockZ, m_BlockType);
- }
- else
- {
- // Grow the stem:
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta + 1);
- }
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_FARMLAND));
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../MersenneTwister.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockStemsHandler :
+ public cBlockHandler
+{
+public:
+ cBlockStemsHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ int ItemType = (m_BlockType == E_BLOCK_MELON_STEM) ? E_ITEM_MELON_SEEDS : E_ITEM_PUMPKIN_SEEDS;
+ a_Pickups.push_back(cItem(ItemType, 1, 0));
+ }
+
+
+ void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ if (Meta >= 7)
+ {
+ // Grow the produce:
+ a_World->GrowMelonPumpkin(a_BlockX, a_BlockY, a_BlockZ, m_BlockType);
+ }
+ else
+ {
+ // Grow the stem:
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta + 1);
+ }
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_FARMLAND));
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockStone.h b/source/Blocks/BlockStone.h
index 89bef5969..af4c6509a 100644
--- a/source/Blocks/BlockStone.h
+++ b/source/Blocks/BlockStone.h
@@ -1,29 +1,29 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../MersenneTwister.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockStoneHandler :
- public cBlockHandler
-{
-public:
- cBlockStoneHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_BLOCK_COBBLESTONE, 1, 0));
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../MersenneTwister.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockStoneHandler :
+ public cBlockHandler
+{
+public:
+ cBlockStoneHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_BLOCK_COBBLESTONE, 1, 0));
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockSugarcane.h b/source/Blocks/BlockSugarcane.h
index a9503ba37..9d66d6be6 100644
--- a/source/Blocks/BlockSugarcane.h
+++ b/source/Blocks/BlockSugarcane.h
@@ -1,96 +1,96 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockSugarcaneHandler :
- public cBlockHandler
-{
-public:
- cBlockSugarcaneHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_SUGARCANE, 1, 0));
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- if (a_RelY <= 0)
- {
- return false;
- }
- switch (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))
- {
- case E_BLOCK_DIRT:
- case E_BLOCK_GRASS:
- case E_BLOCK_FARMLAND:
- case E_BLOCK_SAND:
- {
- static const struct
- {
- int x, z;
- } Coords[] =
- {
- {-1, 0},
- { 1, 0},
- { 0, -1},
- { 0, 1},
- } ;
- a_RelY -= 1;
- for (int i = 0; i < ARRAYCOUNT(Coords); i++)
- {
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (!a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta))
- {
- // Too close to the edge, cannot simulate
- return true;
- }
- if (IsBlockWater(BlockType))
- {
- return true;
- }
- } // for i - Coords[]
- // Not directly neighboring a water block
- return false;
- }
- case E_BLOCK_SUGARCANE:
- {
- return true;
- }
- }
- return false;
- }
-
-
- void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
- {
- a_World->GrowSugarcane(a_BlockX, a_BlockY, a_BlockZ, 1);
- }
-
-
- virtual bool CanBePlacedOnSide() override
- {
- return false;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.grass";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockSugarcaneHandler :
+ public cBlockHandler
+{
+public:
+ cBlockSugarcaneHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_SUGARCANE, 1, 0));
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+ switch (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))
+ {
+ case E_BLOCK_DIRT:
+ case E_BLOCK_GRASS:
+ case E_BLOCK_FARMLAND:
+ case E_BLOCK_SAND:
+ {
+ static const struct
+ {
+ int x, z;
+ } Coords[] =
+ {
+ {-1, 0},
+ { 1, 0},
+ { 0, -1},
+ { 0, 1},
+ } ;
+ a_RelY -= 1;
+ for (int i = 0; i < ARRAYCOUNT(Coords); i++)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (!a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta))
+ {
+ // Too close to the edge, cannot simulate
+ return true;
+ }
+ if (IsBlockWater(BlockType))
+ {
+ return true;
+ }
+ } // for i - Coords[]
+ // Not directly neighboring a water block
+ return false;
+ }
+ case E_BLOCK_SUGARCANE:
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ a_World->GrowSugarcane(a_BlockX, a_BlockY, a_BlockZ, 1);
+ }
+
+
+ virtual bool CanBePlacedOnSide() override
+ {
+ return false;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.grass";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockTallGrass.h b/source/Blocks/BlockTallGrass.h
index eea629bf5..cd27ab7e6 100644
--- a/source/Blocks/BlockTallGrass.h
+++ b/source/Blocks/BlockTallGrass.h
@@ -1,51 +1,51 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockTallGrassHandler :
- public cBlockHandler
-{
-public:
- cBlockTallGrassHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual bool DoesIgnoreBuildCollision(void) override
- {
- return true;
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Drop seeds, sometimes
- MTRand r1;
- if (r1.randInt(10) == 5)
- {
- a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0));
- }
- }
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.grass";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockTallGrassHandler :
+ public cBlockHandler
+{
+public:
+ cBlockTallGrassHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool DoesIgnoreBuildCollision(void) override
+ {
+ return true;
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Drop seeds, sometimes
+ MTRand r1;
+ if (r1.randInt(10) == 5)
+ {
+ a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0));
+ }
+ }
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.grass";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockTorch.h b/source/Blocks/BlockTorch.h
index 9951b8ea4..00e0a585c 100644
--- a/source/Blocks/BlockTorch.h
+++ b/source/Blocks/BlockTorch.h
@@ -1,259 +1,259 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cBlockTorchHandler :
- public cBlockHandler
-{
-public:
- cBlockTorchHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- // Find proper placement. Use the player-supplied one as the default, but fix if not okay:
- if (!TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace))
- {
- a_BlockFace = FindSuitableFace(a_World, a_BlockX, a_BlockY, a_BlockZ);
-
- if (a_BlockFace == BLOCK_FACE_BOTTOM)
- {
- return false;
- }
- }
- a_BlockType = m_BlockType;
- a_BlockMeta = DirectionToMetaData(a_BlockFace);
- return true;
- }
-
-
- static NIBBLETYPE DirectionToMetaData(char a_Direction) // tolua_export
- { // tolua_export
- switch (a_Direction)
- {
- case BLOCK_FACE_BOTTOM: ASSERT(!"Shouldn't be getting this face"); return 0;
- case BLOCK_FACE_TOP: return E_META_TORCH_FLOOR;
- case BLOCK_FACE_EAST: return E_META_TORCH_EAST;
- case BLOCK_FACE_WEST: return E_META_TORCH_WEST;
- case BLOCK_FACE_NORTH: return E_META_TORCH_NORTH;
- case BLOCK_FACE_SOUTH: return E_META_TORCH_SOUTH;
- default:
- {
- ASSERT(!"Unhandled torch direction!");
- break;
- }
- };
- return 0x0;
- } // tolua_export
-
-
- static char MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export
- { // tolua_export
- switch (a_MetaData)
- {
- case 0: return BLOCK_FACE_TOP; // by default, the torches stand on the ground
- case E_META_TORCH_FLOOR: return BLOCK_FACE_TOP;
- case E_META_TORCH_EAST: return BLOCK_FACE_EAST;
- case E_META_TORCH_WEST: return BLOCK_FACE_WEST;
- case E_META_TORCH_NORTH: return BLOCK_FACE_NORTH;
- case E_META_TORCH_SOUTH: return BLOCK_FACE_SOUTH;
- default:
- {
- ASSERT(!"Unhandled torch metadata");
- break;
- }
- }
- return 0;
- } // tolua_export
-
-
- static bool IsAttachedTo(const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos)
- {
- switch (a_TorchMeta)
- {
- case 0x0:
- case E_META_TORCH_FLOOR: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 1, 0)));
- case E_META_TORCH_EAST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, -1)));
- case E_META_TORCH_WEST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, 1)));
- case E_META_TORCH_NORTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(-1, 0, 0)));
- case E_META_TORCH_SOUTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(1, 0, 0)));
- default:
- {
- ASSERT(!"Unhandled torch meta!");
- break;
- }
- }
- return false;
- }
-
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- static bool CanBePlacedOn(BLOCKTYPE a_BlockType, char a_Direction)
- {
- switch (a_BlockType)
- {
- case E_BLOCK_GLASS:
- case E_BLOCK_FENCE:
- case E_BLOCK_NETHER_BRICK_FENCE:
- {
- return (a_Direction == 0x1); // allow only direction "standing on floor"
- }
-
- default:
- {
- return g_BlockIsSolid[a_BlockType];
- }
- }
- }
-
-
- static bool TorchCanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
- {
- // TODO: If placing a torch from below, check all 4 XZ neighbors, place it on that neighbor instead
- // How to propagate that change up?
- // Simon: The easiest way is to calculate the position two times, shouldn´t cost much cpu power :)
-
- if (a_BlockFace == BLOCK_FACE_BOTTOM)
- {
- return false;
- }
-
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true);
-
- return CanBePlacedOn(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ), a_BlockFace);
- }
-
-
- /// Finds a suitable Face for the Torch. Returns BLOCK_FACE_BOTTOM on failure
- static char FindSuitableFace(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
- {
- for (int i = 1; i <= 5; i++)
- {
- if (TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, i))
- {
- return i;
- }
- }
- return BLOCK_FACE_BOTTOM;
- }
-
-
- /*
- virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override
- {
- if (TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace))
- {
- return true;
- }
-
- return (FindSuitableFace(a_World, a_BlockX, a_BlockY, a_BlockZ) != BLOCK_FACE_BOTTOM);
- }
- */
-
-
- virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
- {
- // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
- char Face = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
- int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
- int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
- return TorchCanBePlacedAt(a_Chunk.GetWorld(), BlockX, a_RelY, BlockZ, Face);
- }
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Always drop meta = 0
- a_Pickups.push_back(cItem(m_BlockType, 1, 0));
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-
-
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
- {
- // Bit 4 stays, the rest is swapped around according to a table:
- NIBBLETYPE TopBits = (a_Meta & 0x08);
- switch (a_Meta & 0x07)
- {
- case 0x01: return TopBits | 0x04; // East -> North
- case 0x02: return TopBits | 0x03; // West -> South
- case 0x03: return TopBits | 0x01; // South -> East
- case 0x04: return TopBits | 0x02; // North -> West
- default: return a_Meta; // Floor -> Floor
- }
- }
-
-
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
- {
- // Bit 4 stays, the rest is swapped around according to a table:
- NIBBLETYPE TopBits = (a_Meta & 0x08);
- switch (a_Meta & 0x07)
- {
- case 0x01: return TopBits | 0x03; // East -> South
- case 0x02: return TopBits | 0x04; // West -> North
- case 0x03: return TopBits | 0x02; // South -> West
- case 0x04: return TopBits | 0x01; // North -> East
- default: return a_Meta; // Floor -> Floor
- }
- }
-
-
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
- {
- // Bit 4 stays, the rest is swapped around according to a table:
- NIBBLETYPE TopBits = (a_Meta & 0x08);
- switch (a_Meta & 0x07)
- {
- case 0x03: return TopBits | 0x04; // South -> North
- case 0x04: return TopBits | 0x03; // North -> South
- default: return a_Meta; // Keep the rest
- }
- }
-
-
- // Mirroring around the XZ plane doesn't make sense for floor torches,
- // the others stay the same, so let's keep all the metas the same.
- // The base class does tht for us, no need to override MetaMirrorXZ()
-
-
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
- {
- // Bit 4 stays, the rest is swapped around according to a table:
- NIBBLETYPE TopBits = (a_Meta & 0x08);
- switch (a_Meta & 0x07)
- {
- case 0x01: return TopBits | 0x02; // East -> West
- case 0x02: return TopBits | 0x01; // West -> East
- default: return a_Meta; // Keep the rest
- }
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cBlockTorchHandler :
+ public cBlockHandler
+{
+public:
+ cBlockTorchHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ // Find proper placement. Use the player-supplied one as the default, but fix if not okay:
+ if (!TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace))
+ {
+ a_BlockFace = FindSuitableFace(a_World, a_BlockX, a_BlockY, a_BlockZ);
+
+ if (a_BlockFace == BLOCK_FACE_BOTTOM)
+ {
+ return false;
+ }
+ }
+ a_BlockType = m_BlockType;
+ a_BlockMeta = DirectionToMetaData(a_BlockFace);
+ return true;
+ }
+
+
+ static NIBBLETYPE DirectionToMetaData(char a_Direction) // tolua_export
+ { // tolua_export
+ switch (a_Direction)
+ {
+ case BLOCK_FACE_BOTTOM: ASSERT(!"Shouldn't be getting this face"); return 0;
+ case BLOCK_FACE_TOP: return E_META_TORCH_FLOOR;
+ case BLOCK_FACE_EAST: return E_META_TORCH_EAST;
+ case BLOCK_FACE_WEST: return E_META_TORCH_WEST;
+ case BLOCK_FACE_NORTH: return E_META_TORCH_NORTH;
+ case BLOCK_FACE_SOUTH: return E_META_TORCH_SOUTH;
+ default:
+ {
+ ASSERT(!"Unhandled torch direction!");
+ break;
+ }
+ };
+ return 0x0;
+ } // tolua_export
+
+
+ static char MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export
+ { // tolua_export
+ switch (a_MetaData)
+ {
+ case 0: return BLOCK_FACE_TOP; // by default, the torches stand on the ground
+ case E_META_TORCH_FLOOR: return BLOCK_FACE_TOP;
+ case E_META_TORCH_EAST: return BLOCK_FACE_EAST;
+ case E_META_TORCH_WEST: return BLOCK_FACE_WEST;
+ case E_META_TORCH_NORTH: return BLOCK_FACE_NORTH;
+ case E_META_TORCH_SOUTH: return BLOCK_FACE_SOUTH;
+ default:
+ {
+ ASSERT(!"Unhandled torch metadata");
+ break;
+ }
+ }
+ return 0;
+ } // tolua_export
+
+
+ static bool IsAttachedTo(const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos)
+ {
+ switch (a_TorchMeta)
+ {
+ case 0x0:
+ case E_META_TORCH_FLOOR: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 1, 0)));
+ case E_META_TORCH_EAST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, -1)));
+ case E_META_TORCH_WEST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, 1)));
+ case E_META_TORCH_NORTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(-1, 0, 0)));
+ case E_META_TORCH_SOUTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(1, 0, 0)));
+ default:
+ {
+ ASSERT(!"Unhandled torch meta!");
+ break;
+ }
+ }
+ return false;
+ }
+
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ static bool CanBePlacedOn(BLOCKTYPE a_BlockType, char a_Direction)
+ {
+ switch (a_BlockType)
+ {
+ case E_BLOCK_GLASS:
+ case E_BLOCK_FENCE:
+ case E_BLOCK_NETHER_BRICK_FENCE:
+ {
+ return (a_Direction == 0x1); // allow only direction "standing on floor"
+ }
+
+ default:
+ {
+ return g_BlockIsSolid[a_BlockType];
+ }
+ }
+ }
+
+
+ static bool TorchCanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
+ {
+ // TODO: If placing a torch from below, check all 4 XZ neighbors, place it on that neighbor instead
+ // How to propagate that change up?
+ // Simon: The easiest way is to calculate the position two times, shouldn´t cost much cpu power :)
+
+ if (a_BlockFace == BLOCK_FACE_BOTTOM)
+ {
+ return false;
+ }
+
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true);
+
+ return CanBePlacedOn(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ), a_BlockFace);
+ }
+
+
+ /// Finds a suitable Face for the Torch. Returns BLOCK_FACE_BOTTOM on failure
+ static char FindSuitableFace(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ for (int i = 1; i <= 5; i++)
+ {
+ if (TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, i))
+ {
+ return i;
+ }
+ }
+ return BLOCK_FACE_BOTTOM;
+ }
+
+
+ /*
+ virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override
+ {
+ if (TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace))
+ {
+ return true;
+ }
+
+ return (FindSuitableFace(a_World, a_BlockX, a_BlockY, a_BlockZ) != BLOCK_FACE_BOTTOM);
+ }
+ */
+
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
+ char Face = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ return TorchCanBePlacedAt(a_Chunk.GetWorld(), BlockX, a_RelY, BlockZ, Face);
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Always drop meta = 0
+ a_Pickups.push_back(cItem(m_BlockType, 1, 0));
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+
+
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
+ {
+ // Bit 4 stays, the rest is swapped around according to a table:
+ NIBBLETYPE TopBits = (a_Meta & 0x08);
+ switch (a_Meta & 0x07)
+ {
+ case 0x01: return TopBits | 0x04; // East -> North
+ case 0x02: return TopBits | 0x03; // West -> South
+ case 0x03: return TopBits | 0x01; // South -> East
+ case 0x04: return TopBits | 0x02; // North -> West
+ default: return a_Meta; // Floor -> Floor
+ }
+ }
+
+
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
+ {
+ // Bit 4 stays, the rest is swapped around according to a table:
+ NIBBLETYPE TopBits = (a_Meta & 0x08);
+ switch (a_Meta & 0x07)
+ {
+ case 0x01: return TopBits | 0x03; // East -> South
+ case 0x02: return TopBits | 0x04; // West -> North
+ case 0x03: return TopBits | 0x02; // South -> West
+ case 0x04: return TopBits | 0x01; // North -> East
+ default: return a_Meta; // Floor -> Floor
+ }
+ }
+
+
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
+ {
+ // Bit 4 stays, the rest is swapped around according to a table:
+ NIBBLETYPE TopBits = (a_Meta & 0x08);
+ switch (a_Meta & 0x07)
+ {
+ case 0x03: return TopBits | 0x04; // South -> North
+ case 0x04: return TopBits | 0x03; // North -> South
+ default: return a_Meta; // Keep the rest
+ }
+ }
+
+
+ // Mirroring around the XZ plane doesn't make sense for floor torches,
+ // the others stay the same, so let's keep all the metas the same.
+ // The base class does tht for us, no need to override MetaMirrorXZ()
+
+
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
+ {
+ // Bit 4 stays, the rest is swapped around according to a table:
+ NIBBLETYPE TopBits = (a_Meta & 0x08);
+ switch (a_Meta & 0x07)
+ {
+ case 0x01: return TopBits | 0x02; // East -> West
+ case 0x02: return TopBits | 0x01; // West -> East
+ default: return a_Meta; // Keep the rest
+ }
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockVine.h b/source/Blocks/BlockVine.h
index 2a88c9b68..0bc935272 100644
--- a/source/Blocks/BlockVine.h
+++ b/source/Blocks/BlockVine.h
@@ -1,200 +1,200 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockVineHandler :
- public cBlockHandler
-{
-public:
- cBlockVineHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- // TODO: Disallow placement where the vine doesn't attach to something properly
- BLOCKTYPE BlockType = 0;
- NIBBLETYPE BlockMeta;
- a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
- if (BlockType == m_BlockType)
- {
- a_BlockMeta = BlockMeta | DirectionToMetaData(a_BlockFace);
- }
- else
- {
- a_BlockMeta = DirectionToMetaData(a_BlockFace);
- }
- a_BlockType = m_BlockType;
- return true;
- }
-
-
- static NIBBLETYPE DirectionToMetaData(char a_BlockFace)
- {
- switch (a_BlockFace)
- {
- case BLOCK_FACE_NORTH: return 0x1;
- case BLOCK_FACE_SOUTH: return 0x4;
- case BLOCK_FACE_WEST: return 0x8;
- case BLOCK_FACE_EAST: return 0x2;
- default: return 0x0;
- }
- }
-
-
- static char MetaDataToDirection(NIBBLETYPE a_MetaData)
- {
- switch(a_MetaData)
- {
- case 0x1: return BLOCK_FACE_NORTH;
- case 0x4: return BLOCK_FACE_SOUTH;
- case 0x8: return BLOCK_FACE_WEST;
- case 0x2: return BLOCK_FACE_EAST;
- default: return BLOCK_FACE_TOP;
- }
- }
-
-
- /// Returns true if the specified block type is good for vines to attach to
- static bool IsBlockAttachable(BLOCKTYPE a_BlockType)
- {
- return (a_BlockType == E_BLOCK_LEAVES) || g_BlockIsSolid[a_BlockType];
- }
-
-
- /// Returns the meta that has the maximum allowable sides of the vine, given the surroundings
- NIBBLETYPE GetMaxMeta(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
- {
- static const struct
- {
- int x, z;
- int Bit;
- } Coords[] =
- {
- { 0, 1, 1}, // south, ZP
- {-1, 0, 2}, // west, XM
- { 0, -1, 4}, // north, ZM
- { 1, 0, 8}, // east, XP
- } ;
- int res = 0;
- for (int i = 0; i < ARRAYCOUNT(Coords); i++)
- {
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (
- a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta) &&
- IsBlockAttachable(BlockType)
- )
- {
- res |= Coords[i].Bit;
- }
- }
- return res;
- }
-
-
- void Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
- {
- NIBBLETYPE CurMeta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
- NIBBLETYPE MaxMeta = GetMaxMeta(a_Chunk, a_RelX, a_RelY, a_RelZ);
-
- // Check if vine above us, add its meta to MaxMeta
- if ((a_RelY < cChunkDef::Height - 1) && (a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ) == m_BlockType))
- {
- MaxMeta |= a_Chunk.GetMeta(a_RelX, a_RelY + 1, a_RelZ);
- }
-
- NIBBLETYPE Common = CurMeta & MaxMeta; // Neighbors that we have and are legal
- if (Common != CurMeta)
- {
- // There is a neighbor missing, need to update the meta or even destroy the block
- bool HasTop = (a_RelY < cChunkDef::Height - 1) && IsBlockAttachable(a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ));
- if ((Common == 0) && !HasTop)
- {
- // The vine just lost all its support, destroy the block:
- if (DoesDropOnUnsuitable())
- {
- int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
- int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
- DropBlock(a_Chunk.GetWorld(), NULL, BlockX, a_RelY, BlockZ);
- }
- a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
- return;
- }
- a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, m_BlockType, Common);
- }
- else
- {
- // Wake up the simulators for this block:
- int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
- int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
- a_Chunk.GetWorld()->GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, &a_Chunk);
- }
- }
-
-
- virtual bool DoesIgnoreBuildCollision(void) override
- {
- return true;
- }
-
-
- virtual bool DoesAllowBlockOnTop(void) override
- {
- return false;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.grass";
- }
-
-
- virtual bool DoesDropOnUnsuitable(void) override
- {
- return false;
- }
-
-
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
- {
- return ((a_Meta >> 1) | (a_Meta << 3)) & 0x0f; // Rotate bits to the right
- }
-
-
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
- {
- return ((a_Meta << 1) | (a_Meta >> 3)) & 0x0f; // Rotate bits to the left
- }
-
-
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
- {
- // Bits 2 and 4 stay, bits 1 and 3 swap
- return ((a_Meta & 0x0a) | ((a_Meta & 0x01) << 2) | ((a_Meta & 0x04) >> 2));
- }
-
-
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
- {
- // Bits 1 and 3 stay, bits 2 and 4 swap
- return ((a_Meta & 0x05) | ((a_Meta & 0x02) << 2) | ((a_Meta & 0x08) >> 2));
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockVineHandler :
+ public cBlockHandler
+{
+public:
+ cBlockVineHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ // TODO: Disallow placement where the vine doesn't attach to something properly
+ BLOCKTYPE BlockType = 0;
+ NIBBLETYPE BlockMeta;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
+ if (BlockType == m_BlockType)
+ {
+ a_BlockMeta = BlockMeta | DirectionToMetaData(a_BlockFace);
+ }
+ else
+ {
+ a_BlockMeta = DirectionToMetaData(a_BlockFace);
+ }
+ a_BlockType = m_BlockType;
+ return true;
+ }
+
+
+ static NIBBLETYPE DirectionToMetaData(char a_BlockFace)
+ {
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_NORTH: return 0x1;
+ case BLOCK_FACE_SOUTH: return 0x4;
+ case BLOCK_FACE_WEST: return 0x8;
+ case BLOCK_FACE_EAST: return 0x2;
+ default: return 0x0;
+ }
+ }
+
+
+ static char MetaDataToDirection(NIBBLETYPE a_MetaData)
+ {
+ switch(a_MetaData)
+ {
+ case 0x1: return BLOCK_FACE_NORTH;
+ case 0x4: return BLOCK_FACE_SOUTH;
+ case 0x8: return BLOCK_FACE_WEST;
+ case 0x2: return BLOCK_FACE_EAST;
+ default: return BLOCK_FACE_TOP;
+ }
+ }
+
+
+ /// Returns true if the specified block type is good for vines to attach to
+ static bool IsBlockAttachable(BLOCKTYPE a_BlockType)
+ {
+ return (a_BlockType == E_BLOCK_LEAVES) || g_BlockIsSolid[a_BlockType];
+ }
+
+
+ /// Returns the meta that has the maximum allowable sides of the vine, given the surroundings
+ NIBBLETYPE GetMaxMeta(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
+ {
+ static const struct
+ {
+ int x, z;
+ int Bit;
+ } Coords[] =
+ {
+ { 0, 1, 1}, // south, ZP
+ {-1, 0, 2}, // west, XM
+ { 0, -1, 4}, // north, ZM
+ { 1, 0, 8}, // east, XP
+ } ;
+ int res = 0;
+ for (int i = 0; i < ARRAYCOUNT(Coords); i++)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (
+ a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta) &&
+ IsBlockAttachable(BlockType)
+ )
+ {
+ res |= Coords[i].Bit;
+ }
+ }
+ return res;
+ }
+
+
+ void Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
+ {
+ NIBBLETYPE CurMeta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
+ NIBBLETYPE MaxMeta = GetMaxMeta(a_Chunk, a_RelX, a_RelY, a_RelZ);
+
+ // Check if vine above us, add its meta to MaxMeta
+ if ((a_RelY < cChunkDef::Height - 1) && (a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ) == m_BlockType))
+ {
+ MaxMeta |= a_Chunk.GetMeta(a_RelX, a_RelY + 1, a_RelZ);
+ }
+
+ NIBBLETYPE Common = CurMeta & MaxMeta; // Neighbors that we have and are legal
+ if (Common != CurMeta)
+ {
+ // There is a neighbor missing, need to update the meta or even destroy the block
+ bool HasTop = (a_RelY < cChunkDef::Height - 1) && IsBlockAttachable(a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ));
+ if ((Common == 0) && !HasTop)
+ {
+ // The vine just lost all its support, destroy the block:
+ if (DoesDropOnUnsuitable())
+ {
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ DropBlock(a_Chunk.GetWorld(), NULL, BlockX, a_RelY, BlockZ);
+ }
+ a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
+ return;
+ }
+ a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, m_BlockType, Common);
+ }
+ else
+ {
+ // Wake up the simulators for this block:
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ a_Chunk.GetWorld()->GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, &a_Chunk);
+ }
+ }
+
+
+ virtual bool DoesIgnoreBuildCollision(void) override
+ {
+ return true;
+ }
+
+
+ virtual bool DoesAllowBlockOnTop(void) override
+ {
+ return false;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.grass";
+ }
+
+
+ virtual bool DoesDropOnUnsuitable(void) override
+ {
+ return false;
+ }
+
+
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
+ {
+ return ((a_Meta >> 1) | (a_Meta << 3)) & 0x0f; // Rotate bits to the right
+ }
+
+
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
+ {
+ return ((a_Meta << 1) | (a_Meta >> 3)) & 0x0f; // Rotate bits to the left
+ }
+
+
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
+ {
+ // Bits 2 and 4 stay, bits 1 and 3 swap
+ return ((a_Meta & 0x0a) | ((a_Meta & 0x01) << 2) | ((a_Meta & 0x04) >> 2));
+ }
+
+
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
+ {
+ // Bits 1 and 3 stay, bits 2 and 4 swap
+ return ((a_Meta & 0x05) | ((a_Meta & 0x02) << 2) | ((a_Meta & 0x08) >> 2));
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockWood.h b/source/Blocks/BlockWood.h
index 907fb587c..4e2246506 100644
--- a/source/Blocks/BlockWood.h
+++ b/source/Blocks/BlockWood.h
@@ -1,27 +1,27 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-
-class cBlockWoodHandler : public cBlockHandler
-{
-public:
- cBlockWoodHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockWoodHandler : public cBlockHandler
+{
+public:
+ cBlockWoodHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockWorkbench.h b/source/Blocks/BlockWorkbench.h
index ccd1ded9a..60aa1791b 100644
--- a/source/Blocks/BlockWorkbench.h
+++ b/source/Blocks/BlockWorkbench.h
@@ -1,43 +1,43 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-#include "../UI/Window.h"
-#include "../Player.h"
-
-
-
-
-
-class cBlockWorkbenchHandler:
- public cBlockHandler
-{
-public:
- cBlockWorkbenchHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
- virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
- {
- cWindow * Window = new cCraftingWindow(a_BlockX, a_BlockY, a_BlockZ);
- a_Player->OpenWindow(Window);
- }
-
-
- virtual bool IsUseable(void) override
- {
- return true;
- }
-
-
- virtual const char * GetStepSound(void) override
- {
- return "step.wood";
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../UI/Window.h"
+#include "../Player.h"
+
+
+
+
+
+class cBlockWorkbenchHandler:
+ public cBlockHandler
+{
+public:
+ cBlockWorkbenchHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
+ {
+ cWindow * Window = new cCraftingWindow(a_BlockX, a_BlockY, a_BlockZ);
+ a_Player->OpenWindow(Window);
+ }
+
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+} ;
+
+
+
+
diff --git a/source/ByteBuffer.cpp b/source/ByteBuffer.cpp
index 6d630068a..c82951271 100644
--- a/source/ByteBuffer.cpp
+++ b/source/ByteBuffer.cpp
@@ -1,661 +1,661 @@
-
-// ByteBuffer.cpp
-
-// Implements the cByteBuffer class representing a ringbuffer of bytes
-
-#include "Globals.h"
-
-#include "ByteBuffer.h"
-#include "Endianness.h"
-#include "OSSupport/IsThread.h"
-
-
-
-
-
-#define NEEDBYTES(Num) if (!CanReadBytes(Num)) return false;
-#define PUTBYTES(Num) if (!CanWriteBytes(Num)) return false;
-
-
-
-
-
-#ifdef _DEBUG
-
-/// Simple RAII class that uses one internal unsigned long for checking if two threads are using an object simultanously
-class cSingleThreadAccessChecker
-{
-public:
- cSingleThreadAccessChecker(unsigned long * a_ThreadID) :
- m_ThreadID(a_ThreadID)
- {
- ASSERT((*a_ThreadID == 0) || (*a_ThreadID == cIsThread::GetCurrentID()));
- }
-
- ~cSingleThreadAccessChecker()
- {
- *m_ThreadID = 0;
- }
-
-protected:
- unsigned long * m_ThreadID;
-} ;
-
-#define CHECK_THREAD cSingleThreadAccessChecker Checker(const_cast<unsigned long *>(&m_ThreadID))
-
-#else
- #define CHECK_THREAD
-#endif
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cByteBuffer:
-
-cByteBuffer::cByteBuffer(int a_BufferSize) :
- m_Buffer(new char[a_BufferSize + 1]),
- m_BufferSize(a_BufferSize + 1),
- #ifdef _DEBUG
- m_ThreadID(0),
- #endif // _DEBUG
- m_DataStart(0),
- m_WritePos(0),
- m_ReadPos(0)
-{
- // Allocating one byte more than the buffer size requested, so that we can distinguish between
- // completely-full and completely-empty states
-}
-
-
-
-
-
-cByteBuffer::~cByteBuffer()
-{
- CheckValid();
- delete[] m_Buffer;
-}
-
-
-
-
-
-bool cByteBuffer::Write(const char * a_Bytes, int a_Count)
-{
- CHECK_THREAD;
- CheckValid();
-
- // Store the current free space for a check after writing:
- int CurFreeSpace = GetFreeSpace();
- int CurReadableSpace = GetReadableSpace();
- int WrittenBytes = 0;
-
- if (GetFreeSpace() < a_Count)
- {
- return false;
- }
- int TillEnd = m_BufferSize - m_WritePos;
- 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;
- a_Count -= TillEnd;
- WrittenBytes = TillEnd;
- }
- m_WritePos = 0;
- }
-
- // 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);
- m_WritePos += a_Count;
- WrittenBytes += a_Count;
- }
-
- ASSERT(GetFreeSpace() == CurFreeSpace - WrittenBytes);
- ASSERT(GetReadableSpace() == CurReadableSpace + WrittenBytes);
- return true;
-}
-
-
-
-
-
-int cByteBuffer::GetFreeSpace(void) const
-{
- CHECK_THREAD;
- CheckValid();
- if (m_WritePos >= m_DataStart)
- {
- // Wrap around the buffer end:
- return m_BufferSize - m_WritePos + m_DataStart - 1;
- }
- // Single free space partition:
- return m_DataStart - m_WritePos - 1;
-}
-
-
-
-
-
-/// Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes()
-int cByteBuffer::GetUsedSpace(void) const
-{
- CHECK_THREAD;
- CheckValid();
- return m_BufferSize - GetFreeSpace();
-}
-
-
-
-
-
-/// Returns the number of bytes that are currently available for reading (may be less than UsedSpace due to some data having been read already)
-int cByteBuffer::GetReadableSpace(void) const
-{
- CHECK_THREAD;
- CheckValid();
- if (m_ReadPos > m_WritePos)
- {
- // Wrap around the buffer end:
- return m_BufferSize - m_ReadPos + m_WritePos;
- }
- // Single readable space partition:
- return m_WritePos - m_ReadPos ;
-}
-
-
-
-
-
-bool cByteBuffer::CanReadBytes(int a_Count) const
-{
- CHECK_THREAD;
- CheckValid();
- return (a_Count <= GetReadableSpace());
-}
-
-
-
-
-
-bool cByteBuffer::CanWriteBytes(int a_Count) const
-{
- CHECK_THREAD;
- CheckValid();
- return (a_Count <= GetFreeSpace());
-}
-
-
-
-
-
-bool cByteBuffer::ReadChar(char & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- NEEDBYTES(1);
- ReadBuf(&a_Value, 1);
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadByte(unsigned char & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- NEEDBYTES(1);
- ReadBuf(&a_Value, 1);
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadBEShort(short & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- NEEDBYTES(2);
- ReadBuf(&a_Value, 2);
- a_Value = ntohs(a_Value);
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadBEInt(int & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- NEEDBYTES(4);
- ReadBuf(&a_Value, 4);
- a_Value = ntohl(a_Value);
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadBEInt64(Int64 & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- NEEDBYTES(8);
- ReadBuf(&a_Value, 8);
- a_Value = NetworkToHostLong8(&a_Value);
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadBEFloat(float & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- NEEDBYTES(4);
- ReadBuf(&a_Value, 4);
- a_Value = NetworkToHostFloat4(&a_Value);
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadBEDouble(double & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- NEEDBYTES(8);
- ReadBuf(&a_Value, 8);
- a_Value = NetworkToHostDouble8(&a_Value);
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadBool(bool & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- NEEDBYTES(1);
- char Value = 0;
- ReadBuf(&Value, 1);
- a_Value = (Value != 0);
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadBEUTF16String16(AString & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- short Length;
- if (!ReadBEShort(Length))
- {
- return false;
- }
- if (Length < 0)
- {
- ASSERT(!"Negative string length? Are you sure?");
- return true;
- }
- return ReadUTF16String(a_Value, Length);
-}
-
-
-
-
-
-bool cByteBuffer::WriteChar(char a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- PUTBYTES(1);
- return WriteBuf(&a_Value, 1);
-}
-
-
-
-
-
-bool cByteBuffer::WriteByte(unsigned char a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- PUTBYTES(1);
- return WriteBuf(&a_Value, 1);
-}
-
-
-
-
-
-bool cByteBuffer::WriteBEShort(short a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- PUTBYTES(2);
- short Converted = htons(a_Value);
- return WriteBuf(&Converted, 2);
-}
-
-
-
-
-
-bool cByteBuffer::WriteBEInt(int a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- PUTBYTES(4);
- int Converted = HostToNetwork4(&a_Value);
- return WriteBuf(&Converted, 4);
-}
-
-
-
-
-
-bool cByteBuffer::WriteBEInt64(Int64 a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- PUTBYTES(8);
- Int64 Converted = HostToNetwork8(&a_Value);
- return WriteBuf(&Converted, 8);
-}
-
-
-
-
-
-bool cByteBuffer::WriteBEFloat(float a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- PUTBYTES(4);
- int Converted = HostToNetwork4(&a_Value);
- return WriteBuf(&Converted, 4);
-}
-
-
-
-
-
-bool cByteBuffer::WriteBEDouble(double a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- PUTBYTES(8);
- Int64 Converted = HostToNetwork8(&a_Value);
- return WriteBuf(&Converted, 8);
-}
-
-
-
-
-
-
-bool cByteBuffer::WriteBool(bool a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- return WriteChar(a_Value ? 1 : 0);
-}
-
-
-
-
-
-bool cByteBuffer::WriteBEUTF16String16(const AString & a_Value)
-{
- CHECK_THREAD;
- CheckValid();
- PUTBYTES(2);
- AString UTF16BE;
- UTF8ToRawBEUTF16(a_Value.data(), a_Value.size(), UTF16BE);
- WriteBEShort((short)(UTF16BE.size() / 2));
- PUTBYTES(UTF16BE.size());
- WriteBuf(UTF16BE.data(), UTF16BE.size());
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadBuf(void * a_Buffer, int a_Count)
-{
- CHECK_THREAD;
- CheckValid();
- ASSERT(a_Count >= 0);
- NEEDBYTES(a_Count);
- char * Dst = (char *)a_Buffer; // So that we can do byte math
- int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
- ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
- if (BytesToEndOfBuffer <= a_Count)
- {
- // Reading across the ringbuffer end, read the first part and adjust parameters:
- if (BytesToEndOfBuffer > 0)
- {
- memcpy(Dst, m_Buffer + m_ReadPos, BytesToEndOfBuffer);
- Dst += BytesToEndOfBuffer;
- a_Count -= BytesToEndOfBuffer;
- }
- m_ReadPos = 0;
- }
-
- // Read the rest of the bytes in a single read (guaranteed to fit):
- if (a_Count > 0)
- {
- memcpy(Dst, m_Buffer + m_ReadPos, a_Count);
- m_ReadPos += a_Count;
- }
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::WriteBuf(const void * a_Buffer, int a_Count)
-{
- CHECK_THREAD;
- CheckValid();
- ASSERT(a_Count >= 0);
- PUTBYTES(a_Count);
- char * Src = (char *)a_Buffer; // So that we can do byte math
- int BytesToEndOfBuffer = m_BufferSize - m_WritePos;
- if (BytesToEndOfBuffer <= a_Count)
- {
- // Reading across the ringbuffer end, read the first part and adjust parameters:
- memcpy(m_Buffer + m_WritePos, Src, BytesToEndOfBuffer);
- Src += BytesToEndOfBuffer;
- a_Count -= BytesToEndOfBuffer;
- m_WritePos = 0;
- }
-
- // Read the rest of the bytes in a single read (guaranteed to fit):
- if (a_Count > 0)
- {
- memcpy(m_Buffer + m_WritePos, Src, a_Count);
- m_WritePos += a_Count;
- }
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadString(AString & a_String, int a_Count)
-{
- CHECK_THREAD;
- CheckValid();
- ASSERT(a_Count >= 0);
- NEEDBYTES(a_Count);
- a_String.clear();
- a_String.reserve(a_Count);
- int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
- ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
- if (BytesToEndOfBuffer <= a_Count)
- {
- // Reading across the ringbuffer end, read the first part and adjust parameters:
- if (BytesToEndOfBuffer > 0)
- {
- a_String.assign(m_Buffer + m_ReadPos, BytesToEndOfBuffer);
- a_Count -= BytesToEndOfBuffer;
- }
- m_ReadPos = 0;
- }
-
- // Read the rest of the bytes in a single read (guaranteed to fit):
- if (a_Count > 0)
- {
- a_String.append(m_Buffer + m_ReadPos, a_Count);
- m_ReadPos += a_Count;
- }
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::ReadUTF16String(AString & a_String, int 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))
- {
- return false;
- }
- RawBEToUTF8((short *)(RawData.data()), a_NumChars, a_String);
- return true;
-}
-
-
-
-
-
-bool cByteBuffer::SkipRead(int a_Count)
-{
- CHECK_THREAD;
- CheckValid();
- ASSERT(a_Count >= 0);
- if (!CanReadBytes(a_Count))
- {
- return false;
- }
- AdvanceReadPos(a_Count);
- return true;
-}
-
-
-
-
-
-void cByteBuffer::ReadAll(AString & a_Data)
-{
- CHECK_THREAD;
- CheckValid();
- ReadString(a_Data, GetReadableSpace());
-}
-
-
-
-
-
-void cByteBuffer::CommitRead(void)
-{
- CHECK_THREAD;
- CheckValid();
- m_DataStart = m_ReadPos;
-}
-
-
-
-
-
-void cByteBuffer::ResetRead(void)
-{
- CHECK_THREAD;
- CheckValid();
- m_ReadPos = m_DataStart;
-}
-
-
-
-
-
-void cByteBuffer::ReadAgain(AString & a_Out)
-{
- // Return the data between m_DataStart and m_ReadPos (the data that has been read but not committed)
- // Used by ProtoProxy to repeat communication twice, once for parsing and the other time for the remote party
- CHECK_THREAD;
- CheckValid();
- int DataStart = m_DataStart;
- if (m_ReadPos < m_DataStart)
- {
- // Across the ringbuffer end, read the first part and adjust next part's start:
- a_Out.append(m_Buffer + m_DataStart, m_BufferSize - m_DataStart);
- DataStart = 0;
- }
- a_Out.append(m_Buffer + DataStart, m_ReadPos - DataStart);
-}
-
-
-
-
-
-void cByteBuffer::AdvanceReadPos(int a_Count)
-{
- CHECK_THREAD;
- CheckValid();
- m_ReadPos += a_Count;
- if (m_ReadPos > m_BufferSize)
- {
- m_ReadPos -= m_BufferSize;
- }
-}
-
-
-
-
-
-void cByteBuffer::CheckValid(void) const
-{
- ASSERT(m_ReadPos >= 0);
- ASSERT(m_ReadPos < m_BufferSize);
- ASSERT(m_WritePos >= 0);
- ASSERT(m_WritePos < m_BufferSize);
-}
-
-
-
-
+
+// ByteBuffer.cpp
+
+// Implements the cByteBuffer class representing a ringbuffer of bytes
+
+#include "Globals.h"
+
+#include "ByteBuffer.h"
+#include "Endianness.h"
+#include "OSSupport/IsThread.h"
+
+
+
+
+
+#define NEEDBYTES(Num) if (!CanReadBytes(Num)) return false;
+#define PUTBYTES(Num) if (!CanWriteBytes(Num)) return false;
+
+
+
+
+
+#ifdef _DEBUG
+
+/// Simple RAII class that uses one internal unsigned long for checking if two threads are using an object simultanously
+class cSingleThreadAccessChecker
+{
+public:
+ cSingleThreadAccessChecker(unsigned long * a_ThreadID) :
+ m_ThreadID(a_ThreadID)
+ {
+ ASSERT((*a_ThreadID == 0) || (*a_ThreadID == cIsThread::GetCurrentID()));
+ }
+
+ ~cSingleThreadAccessChecker()
+ {
+ *m_ThreadID = 0;
+ }
+
+protected:
+ unsigned long * m_ThreadID;
+} ;
+
+#define CHECK_THREAD cSingleThreadAccessChecker Checker(const_cast<unsigned long *>(&m_ThreadID))
+
+#else
+ #define CHECK_THREAD
+#endif
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cByteBuffer:
+
+cByteBuffer::cByteBuffer(int a_BufferSize) :
+ m_Buffer(new char[a_BufferSize + 1]),
+ m_BufferSize(a_BufferSize + 1),
+ #ifdef _DEBUG
+ m_ThreadID(0),
+ #endif // _DEBUG
+ m_DataStart(0),
+ m_WritePos(0),
+ m_ReadPos(0)
+{
+ // Allocating one byte more than the buffer size requested, so that we can distinguish between
+ // completely-full and completely-empty states
+}
+
+
+
+
+
+cByteBuffer::~cByteBuffer()
+{
+ CheckValid();
+ delete[] m_Buffer;
+}
+
+
+
+
+
+bool cByteBuffer::Write(const char * a_Bytes, int a_Count)
+{
+ CHECK_THREAD;
+ CheckValid();
+
+ // Store the current free space for a check after writing:
+ int CurFreeSpace = GetFreeSpace();
+ int CurReadableSpace = GetReadableSpace();
+ int WrittenBytes = 0;
+
+ if (GetFreeSpace() < a_Count)
+ {
+ return false;
+ }
+ int TillEnd = m_BufferSize - m_WritePos;
+ 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;
+ a_Count -= TillEnd;
+ WrittenBytes = TillEnd;
+ }
+ m_WritePos = 0;
+ }
+
+ // 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);
+ m_WritePos += a_Count;
+ WrittenBytes += a_Count;
+ }
+
+ ASSERT(GetFreeSpace() == CurFreeSpace - WrittenBytes);
+ ASSERT(GetReadableSpace() == CurReadableSpace + WrittenBytes);
+ return true;
+}
+
+
+
+
+
+int cByteBuffer::GetFreeSpace(void) const
+{
+ CHECK_THREAD;
+ CheckValid();
+ if (m_WritePos >= m_DataStart)
+ {
+ // Wrap around the buffer end:
+ return m_BufferSize - m_WritePos + m_DataStart - 1;
+ }
+ // Single free space partition:
+ return m_DataStart - m_WritePos - 1;
+}
+
+
+
+
+
+/// Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes()
+int cByteBuffer::GetUsedSpace(void) const
+{
+ CHECK_THREAD;
+ CheckValid();
+ return m_BufferSize - GetFreeSpace();
+}
+
+
+
+
+
+/// Returns the number of bytes that are currently available for reading (may be less than UsedSpace due to some data having been read already)
+int cByteBuffer::GetReadableSpace(void) const
+{
+ CHECK_THREAD;
+ CheckValid();
+ if (m_ReadPos > m_WritePos)
+ {
+ // Wrap around the buffer end:
+ return m_BufferSize - m_ReadPos + m_WritePos;
+ }
+ // Single readable space partition:
+ return m_WritePos - m_ReadPos ;
+}
+
+
+
+
+
+bool cByteBuffer::CanReadBytes(int a_Count) const
+{
+ CHECK_THREAD;
+ CheckValid();
+ return (a_Count <= GetReadableSpace());
+}
+
+
+
+
+
+bool cByteBuffer::CanWriteBytes(int a_Count) const
+{
+ CHECK_THREAD;
+ CheckValid();
+ return (a_Count <= GetFreeSpace());
+}
+
+
+
+
+
+bool cByteBuffer::ReadChar(char & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ NEEDBYTES(1);
+ ReadBuf(&a_Value, 1);
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadByte(unsigned char & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ NEEDBYTES(1);
+ ReadBuf(&a_Value, 1);
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadBEShort(short & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ NEEDBYTES(2);
+ ReadBuf(&a_Value, 2);
+ a_Value = ntohs(a_Value);
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadBEInt(int & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ NEEDBYTES(4);
+ ReadBuf(&a_Value, 4);
+ a_Value = ntohl(a_Value);
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadBEInt64(Int64 & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ NEEDBYTES(8);
+ ReadBuf(&a_Value, 8);
+ a_Value = NetworkToHostLong8(&a_Value);
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadBEFloat(float & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ NEEDBYTES(4);
+ ReadBuf(&a_Value, 4);
+ a_Value = NetworkToHostFloat4(&a_Value);
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadBEDouble(double & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ NEEDBYTES(8);
+ ReadBuf(&a_Value, 8);
+ a_Value = NetworkToHostDouble8(&a_Value);
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadBool(bool & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ NEEDBYTES(1);
+ char Value = 0;
+ ReadBuf(&Value, 1);
+ a_Value = (Value != 0);
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadBEUTF16String16(AString & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ short Length;
+ if (!ReadBEShort(Length))
+ {
+ return false;
+ }
+ if (Length < 0)
+ {
+ ASSERT(!"Negative string length? Are you sure?");
+ return true;
+ }
+ return ReadUTF16String(a_Value, Length);
+}
+
+
+
+
+
+bool cByteBuffer::WriteChar(char a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ PUTBYTES(1);
+ return WriteBuf(&a_Value, 1);
+}
+
+
+
+
+
+bool cByteBuffer::WriteByte(unsigned char a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ PUTBYTES(1);
+ return WriteBuf(&a_Value, 1);
+}
+
+
+
+
+
+bool cByteBuffer::WriteBEShort(short a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ PUTBYTES(2);
+ short Converted = htons(a_Value);
+ return WriteBuf(&Converted, 2);
+}
+
+
+
+
+
+bool cByteBuffer::WriteBEInt(int a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ PUTBYTES(4);
+ int Converted = HostToNetwork4(&a_Value);
+ return WriteBuf(&Converted, 4);
+}
+
+
+
+
+
+bool cByteBuffer::WriteBEInt64(Int64 a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ PUTBYTES(8);
+ Int64 Converted = HostToNetwork8(&a_Value);
+ return WriteBuf(&Converted, 8);
+}
+
+
+
+
+
+bool cByteBuffer::WriteBEFloat(float a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ PUTBYTES(4);
+ int Converted = HostToNetwork4(&a_Value);
+ return WriteBuf(&Converted, 4);
+}
+
+
+
+
+
+bool cByteBuffer::WriteBEDouble(double a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ PUTBYTES(8);
+ Int64 Converted = HostToNetwork8(&a_Value);
+ return WriteBuf(&Converted, 8);
+}
+
+
+
+
+
+
+bool cByteBuffer::WriteBool(bool a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ return WriteChar(a_Value ? 1 : 0);
+}
+
+
+
+
+
+bool cByteBuffer::WriteBEUTF16String16(const AString & a_Value)
+{
+ CHECK_THREAD;
+ CheckValid();
+ PUTBYTES(2);
+ AString UTF16BE;
+ UTF8ToRawBEUTF16(a_Value.data(), a_Value.size(), UTF16BE);
+ WriteBEShort((short)(UTF16BE.size() / 2));
+ PUTBYTES(UTF16BE.size());
+ WriteBuf(UTF16BE.data(), UTF16BE.size());
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadBuf(void * a_Buffer, int a_Count)
+{
+ CHECK_THREAD;
+ CheckValid();
+ ASSERT(a_Count >= 0);
+ NEEDBYTES(a_Count);
+ char * Dst = (char *)a_Buffer; // So that we can do byte math
+ int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
+ ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
+ if (BytesToEndOfBuffer <= a_Count)
+ {
+ // Reading across the ringbuffer end, read the first part and adjust parameters:
+ if (BytesToEndOfBuffer > 0)
+ {
+ memcpy(Dst, m_Buffer + m_ReadPos, BytesToEndOfBuffer);
+ Dst += BytesToEndOfBuffer;
+ a_Count -= BytesToEndOfBuffer;
+ }
+ m_ReadPos = 0;
+ }
+
+ // Read the rest of the bytes in a single read (guaranteed to fit):
+ if (a_Count > 0)
+ {
+ memcpy(Dst, m_Buffer + m_ReadPos, a_Count);
+ m_ReadPos += a_Count;
+ }
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::WriteBuf(const void * a_Buffer, int a_Count)
+{
+ CHECK_THREAD;
+ CheckValid();
+ ASSERT(a_Count >= 0);
+ PUTBYTES(a_Count);
+ char * Src = (char *)a_Buffer; // So that we can do byte math
+ int BytesToEndOfBuffer = m_BufferSize - m_WritePos;
+ if (BytesToEndOfBuffer <= a_Count)
+ {
+ // Reading across the ringbuffer end, read the first part and adjust parameters:
+ memcpy(m_Buffer + m_WritePos, Src, BytesToEndOfBuffer);
+ Src += BytesToEndOfBuffer;
+ a_Count -= BytesToEndOfBuffer;
+ m_WritePos = 0;
+ }
+
+ // Read the rest of the bytes in a single read (guaranteed to fit):
+ if (a_Count > 0)
+ {
+ memcpy(m_Buffer + m_WritePos, Src, a_Count);
+ m_WritePos += a_Count;
+ }
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadString(AString & a_String, int a_Count)
+{
+ CHECK_THREAD;
+ CheckValid();
+ ASSERT(a_Count >= 0);
+ NEEDBYTES(a_Count);
+ a_String.clear();
+ a_String.reserve(a_Count);
+ int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
+ ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
+ if (BytesToEndOfBuffer <= a_Count)
+ {
+ // Reading across the ringbuffer end, read the first part and adjust parameters:
+ if (BytesToEndOfBuffer > 0)
+ {
+ a_String.assign(m_Buffer + m_ReadPos, BytesToEndOfBuffer);
+ a_Count -= BytesToEndOfBuffer;
+ }
+ m_ReadPos = 0;
+ }
+
+ // Read the rest of the bytes in a single read (guaranteed to fit):
+ if (a_Count > 0)
+ {
+ a_String.append(m_Buffer + m_ReadPos, a_Count);
+ m_ReadPos += a_Count;
+ }
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadUTF16String(AString & a_String, int 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))
+ {
+ return false;
+ }
+ RawBEToUTF8((short *)(RawData.data()), a_NumChars, a_String);
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::SkipRead(int a_Count)
+{
+ CHECK_THREAD;
+ CheckValid();
+ ASSERT(a_Count >= 0);
+ if (!CanReadBytes(a_Count))
+ {
+ return false;
+ }
+ AdvanceReadPos(a_Count);
+ return true;
+}
+
+
+
+
+
+void cByteBuffer::ReadAll(AString & a_Data)
+{
+ CHECK_THREAD;
+ CheckValid();
+ ReadString(a_Data, GetReadableSpace());
+}
+
+
+
+
+
+void cByteBuffer::CommitRead(void)
+{
+ CHECK_THREAD;
+ CheckValid();
+ m_DataStart = m_ReadPos;
+}
+
+
+
+
+
+void cByteBuffer::ResetRead(void)
+{
+ CHECK_THREAD;
+ CheckValid();
+ m_ReadPos = m_DataStart;
+}
+
+
+
+
+
+void cByteBuffer::ReadAgain(AString & a_Out)
+{
+ // Return the data between m_DataStart and m_ReadPos (the data that has been read but not committed)
+ // Used by ProtoProxy to repeat communication twice, once for parsing and the other time for the remote party
+ CHECK_THREAD;
+ CheckValid();
+ int DataStart = m_DataStart;
+ if (m_ReadPos < m_DataStart)
+ {
+ // Across the ringbuffer end, read the first part and adjust next part's start:
+ a_Out.append(m_Buffer + m_DataStart, m_BufferSize - m_DataStart);
+ DataStart = 0;
+ }
+ a_Out.append(m_Buffer + DataStart, m_ReadPos - DataStart);
+}
+
+
+
+
+
+void cByteBuffer::AdvanceReadPos(int a_Count)
+{
+ CHECK_THREAD;
+ CheckValid();
+ m_ReadPos += a_Count;
+ if (m_ReadPos > m_BufferSize)
+ {
+ m_ReadPos -= m_BufferSize;
+ }
+}
+
+
+
+
+
+void cByteBuffer::CheckValid(void) const
+{
+ ASSERT(m_ReadPos >= 0);
+ ASSERT(m_ReadPos < m_BufferSize);
+ ASSERT(m_WritePos >= 0);
+ ASSERT(m_WritePos < m_BufferSize);
+}
+
+
+
+
diff --git a/source/ByteBuffer.h b/source/ByteBuffer.h
index ccc1ddfa1..650eda5b0 100644
--- a/source/ByteBuffer.h
+++ b/source/ByteBuffer.h
@@ -1,121 +1,121 @@
-
-// ByteStream.h
-
-// Interfaces to the cByteBuffer class representing a ringbuffer of bytes
-
-
-
-
-
-#pragma once
-
-
-
-
-
-/** An object that can store incoming bytes and lets its clients read the bytes sequentially
-The bytes are stored in a ringbuffer of constant size; if more than that size
-is requested, the write operation fails.
-The bytes stored can be retrieved using various ReadXXX functions; these assume that the needed
-number of bytes are present in the buffer (ASSERT; for performance reasons).
-The reading doesn't actually remove the bytes, it only moves the internal read ptr.
-To remove the bytes, call CommitRead().
-To re-start reading from the beginning, call ResetRead().
-This class doesn't implement thread safety, the clients of this class need to provide
-their own synchronization.
-*/
-class cByteBuffer
-{
-public:
- cByteBuffer(int a_BufferSize);
- ~cByteBuffer();
-
- /// Writes the bytes specified to the ringbuffer. Returns true if successful, false if not
- bool Write(const char * a_Bytes, int a_Count);
-
- /// Returns the number of bytes that can be successfully written to the ringbuffer
- int GetFreeSpace(void) const;
-
- /// Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes()
- int 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)
- int GetReadableSpace(void) const;
-
- /// Returns true if the specified amount of bytes are available for reading
- bool CanReadBytes(int a_Count) const;
-
- /// Returns true if the specified amount of bytes are available for writing
- bool CanWriteBytes(int a_Count) const;
-
- // Read the specified datatype and advance the read pointer; return true if successfully read:
- bool ReadChar (char & a_Value);
- bool ReadByte (unsigned char & a_Value);
- bool ReadBEShort (short & a_Value);
- bool ReadBEInt (int & a_Value);
- bool ReadBEInt64 (Int64 & a_Value);
- bool ReadBEFloat (float & a_Value);
- bool ReadBEDouble (double & a_Value);
- bool ReadBool (bool & a_Value);
- bool ReadBEUTF16String16(AString & a_Value);
-
- // Write the specified datatype; return true if successfully written
- bool WriteChar (char a_Value);
- bool WriteByte (unsigned char a_Value);
- bool WriteBEShort (short a_Value);
- bool WriteBEInt (int a_Value);
- bool WriteBEInt64 (Int64 a_Value);
- bool WriteBEFloat (float a_Value);
- bool WriteBEDouble (double a_Value);
- bool WriteBool (bool a_Value);
- bool WriteBEUTF16String16(const AString & a_Value);
-
- /// Reads a_Count bytes into a_Buffer; returns true if successful
- bool ReadBuf(void * a_Buffer, int a_Count);
-
- /// Writes a_Count bytes into a_Buffer; returns true if successful
- bool WriteBuf(const void * a_Buffer, int a_Count);
-
- /// Reads a_Count bytes into a_String; returns true if successful
- bool ReadString(AString & a_String, int 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);
-
- /// Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer
- bool SkipRead(int a_Count);
-
- /// Reads all available data into a_Data
- void ReadAll(AString & a_Data);
-
- /// Removes the bytes that have been read from the ringbuffer
- void CommitRead(void);
-
- /// 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
- void ReadAgain(AString & a_Out);
-
- /// Checks if the internal state is valid (read and write positions in the correct bounds) using ASSERTs
- void CheckValid(void) const;
-
-protected:
- char * m_Buffer;
- int m_BufferSize; // Total size of the ringbuffer
-
- #ifdef _DEBUG
- unsigned long m_ThreadID; // Thread that is currently accessing the object, checked via cSingleThreadAccessChecker
- #endif // _DEBUG
-
- int m_DataStart; // Where the data starts in the ringbuffer
- int m_WritePos; // Where the data ends in the ringbuffer
- int m_ReadPos; // Where the next read will start in the ringbuffer
-
- /// Advances the m_ReadPos by a_Count bytes
- void AdvanceReadPos(int a_Count);
-} ;
-
-
-
-
+
+// ByteStream.h
+
+// Interfaces to the cByteBuffer class representing a ringbuffer of bytes
+
+
+
+
+
+#pragma once
+
+
+
+
+
+/** An object that can store incoming bytes and lets its clients read the bytes sequentially
+The bytes are stored in a ringbuffer of constant size; if more than that size
+is requested, the write operation fails.
+The bytes stored can be retrieved using various ReadXXX functions; these assume that the needed
+number of bytes are present in the buffer (ASSERT; for performance reasons).
+The reading doesn't actually remove the bytes, it only moves the internal read ptr.
+To remove the bytes, call CommitRead().
+To re-start reading from the beginning, call ResetRead().
+This class doesn't implement thread safety, the clients of this class need to provide
+their own synchronization.
+*/
+class cByteBuffer
+{
+public:
+ cByteBuffer(int a_BufferSize);
+ ~cByteBuffer();
+
+ /// Writes the bytes specified to the ringbuffer. Returns true if successful, false if not
+ bool Write(const char * a_Bytes, int a_Count);
+
+ /// Returns the number of bytes that can be successfully written to the ringbuffer
+ int GetFreeSpace(void) const;
+
+ /// Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes()
+ int 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)
+ int GetReadableSpace(void) const;
+
+ /// Returns true if the specified amount of bytes are available for reading
+ bool CanReadBytes(int a_Count) const;
+
+ /// Returns true if the specified amount of bytes are available for writing
+ bool CanWriteBytes(int a_Count) const;
+
+ // Read the specified datatype and advance the read pointer; return true if successfully read:
+ bool ReadChar (char & a_Value);
+ bool ReadByte (unsigned char & a_Value);
+ bool ReadBEShort (short & a_Value);
+ bool ReadBEInt (int & a_Value);
+ bool ReadBEInt64 (Int64 & a_Value);
+ bool ReadBEFloat (float & a_Value);
+ bool ReadBEDouble (double & a_Value);
+ bool ReadBool (bool & a_Value);
+ bool ReadBEUTF16String16(AString & a_Value);
+
+ // Write the specified datatype; return true if successfully written
+ bool WriteChar (char a_Value);
+ bool WriteByte (unsigned char a_Value);
+ bool WriteBEShort (short a_Value);
+ bool WriteBEInt (int a_Value);
+ bool WriteBEInt64 (Int64 a_Value);
+ bool WriteBEFloat (float a_Value);
+ bool WriteBEDouble (double a_Value);
+ bool WriteBool (bool a_Value);
+ bool WriteBEUTF16String16(const AString & a_Value);
+
+ /// Reads a_Count bytes into a_Buffer; returns true if successful
+ bool ReadBuf(void * a_Buffer, int a_Count);
+
+ /// Writes a_Count bytes into a_Buffer; returns true if successful
+ bool WriteBuf(const void * a_Buffer, int a_Count);
+
+ /// Reads a_Count bytes into a_String; returns true if successful
+ bool ReadString(AString & a_String, int 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);
+
+ /// Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer
+ bool SkipRead(int a_Count);
+
+ /// Reads all available data into a_Data
+ void ReadAll(AString & a_Data);
+
+ /// Removes the bytes that have been read from the ringbuffer
+ void CommitRead(void);
+
+ /// 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
+ void ReadAgain(AString & a_Out);
+
+ /// Checks if the internal state is valid (read and write positions in the correct bounds) using ASSERTs
+ void CheckValid(void) const;
+
+protected:
+ char * m_Buffer;
+ int m_BufferSize; // Total size of the ringbuffer
+
+ #ifdef _DEBUG
+ unsigned long m_ThreadID; // Thread that is currently accessing the object, checked via cSingleThreadAccessChecker
+ #endif // _DEBUG
+
+ int m_DataStart; // Where the data starts in the ringbuffer
+ int m_WritePos; // Where the data ends in the ringbuffer
+ int m_ReadPos; // Where the next read will start in the ringbuffer
+
+ /// Advances the m_ReadPos by a_Count bytes
+ void AdvanceReadPos(int a_Count);
+} ;
+
+
+
+
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 155eac38a..526d00b98 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -555,11 +555,8 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, ch
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
if (ItemHandler->IsFood())
{
- if (PlgMgr->CallHookPlayerEating(*m_Player))
- {
- // A plugin doesn't agree with the action. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
- return;
- }
+ m_Player->AbortEating();
+ return;
}
else
{
@@ -569,7 +566,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, ch
return;
}
}
- LOGINFO("%s: Status SHOOT / EAT not implemented", __FUNCTION__);
+ LOGINFO("%s: Status SHOOT not implemented", __FUNCTION__);
return;
}
@@ -804,15 +801,19 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, c
}
else if (ItemHandler->IsFood())
{
- cItem Item;
- Item.m_ItemType = Equipped.m_ItemType;
- Item.m_ItemCount = 1;
- if (ItemHandler->EatItem(m_Player, &Item))
+ if (m_Player->IsSatiated())
+ {
+ // The player is satiated, they cannot eat
+ return;
+ }
+ m_Player->StartEating();
+ if (PlgMgr->CallHookPlayerEating(*m_Player))
{
- ItemHandler->OnFoodEaten(World, m_Player, &Item);
- m_Player->GetInventory().RemoveOneEquippedItem();
+ // A plugin won't let us eat, abort (send the proper packets to the client, too):
+ m_Player->AbortEating();
return;
}
+ return;
}
else
{
@@ -1490,6 +1491,15 @@ void cClientHandle::SendDisconnect(const AString & a_Reason)
+void cClientHandle::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ m_Protocol->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
+}
+
+
+
+
+
void cClientHandle::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
m_Protocol->SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
diff --git a/source/ClientHandle.h b/source/ClientHandle.h
index a06aca39f..0f1daa72c 100644
--- a/source/ClientHandle.h
+++ b/source/ClientHandle.h
@@ -97,6 +97,7 @@ public:
void SendCollectPickup (const cPickup & a_Pickup, 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);
void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item);
void SendEntityHeadLook (const cEntity & a_Entity);
void SendEntityLook (const cEntity & a_Entity);
@@ -281,6 +282,9 @@ private:
/// Buffer for received messages to be processed in the Tick thread
AStringList m_PendingMessages;
+
+ static int s_ClientCount;
+ int m_UniqueID;
@@ -307,14 +311,11 @@ private:
/// Processes the messages in m_PendingMessages; called from the Tick thread
void ProcessPendingMessages(void);
-
+
// cSocketThreads::cCallback overrides:
virtual void DataReceived (const char * a_Data, int 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
-
- static int s_ClientCount;
- int m_UniqueID;
}; // tolua_export
diff --git a/source/CommandOutput.cpp b/source/CommandOutput.cpp
index 49102b38c..c221682a1 100644
--- a/source/CommandOutput.cpp
+++ b/source/CommandOutput.cpp
@@ -1,71 +1,71 @@
-
-// CommandOutput.cpp
-
-// Implements the various classes that process command output
-
-#include "Globals.h"
-#include "CommandOutput.h"
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cCommandOutputCallback:
-
-void cCommandOutputCallback::Out(const char * a_Fmt, ...)
-{
- AString Output;
- va_list args;
- va_start(args, a_Fmt);
- AppendVPrintf(Output, a_Fmt, args);
- va_end(args);
- Output.append("\n");
- Out(Output);
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cLogCommandOutputCallback:
-
-void cLogCommandOutputCallback::Out(const AString & a_Text)
-{
- m_Buffer.append(a_Text);
-}
-
-
-
-
-
-void cLogCommandOutputCallback::Finished(void)
-{
- // Log each line separately:
- size_t len = m_Buffer.length();
- size_t last = 0;
- for (size_t i = 0; i < len; i++)
- {
- switch (m_Buffer[i])
- {
- case '\n':
- {
- LOG(m_Buffer.substr(last, i - last).c_str());
- last = i + 1;
- break;
- }
- }
- } // for i - m_Buffer[]
- if (last < len)
- {
- LOG(m_Buffer.substr(last).c_str());
- }
-
- // Clear the buffer for the next command output:
- m_Buffer.clear();
-}
-
-
-
-
+
+// CommandOutput.cpp
+
+// Implements the various classes that process command output
+
+#include "Globals.h"
+#include "CommandOutput.h"
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cCommandOutputCallback:
+
+void cCommandOutputCallback::Out(const char * a_Fmt, ...)
+{
+ AString Output;
+ va_list args;
+ va_start(args, a_Fmt);
+ AppendVPrintf(Output, a_Fmt, args);
+ va_end(args);
+ Output.append("\n");
+ Out(Output);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cLogCommandOutputCallback:
+
+void cLogCommandOutputCallback::Out(const AString & a_Text)
+{
+ m_Buffer.append(a_Text);
+}
+
+
+
+
+
+void cLogCommandOutputCallback::Finished(void)
+{
+ // Log each line separately:
+ size_t len = m_Buffer.length();
+ size_t last = 0;
+ for (size_t i = 0; i < len; i++)
+ {
+ switch (m_Buffer[i])
+ {
+ case '\n':
+ {
+ LOG(m_Buffer.substr(last, i - last).c_str());
+ last = i + 1;
+ break;
+ }
+ }
+ } // for i - m_Buffer[]
+ if (last < len)
+ {
+ LOG(m_Buffer.substr(last).c_str());
+ }
+
+ // Clear the buffer for the next command output:
+ m_Buffer.clear();
+}
+
+
+
+
diff --git a/source/CommandOutput.h b/source/CommandOutput.h
index 68217dbb4..bdf675238 100644
--- a/source/CommandOutput.h
+++ b/source/CommandOutput.h
@@ -1,82 +1,82 @@
-
-// CommandOutput.h
-
-// Declares various classes that process command output
-
-
-
-
-
-/** Interface for a callback that receives command output
-The Out() function is called for any output the command has produced.
-Descendants override that function to provide specific processing of the output.
-*/
-class cCommandOutputCallback
-{
-public:
- virtual ~cCommandOutputCallback() {}; // Force a virtual destructor in subclasses
-
- /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a "\n"
- void Out(const char * a_Fmt, ...);
-
- /// 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) {};
-} ;
-
-
-
-
-
-/// Class that discards all command output
-class cNullCommandOutputCallback :
- public cCommandOutputCallback
-{
- // cCommandOutputCallback overrides:
- virtual void Out(const AString & a_Text) override
- {
- // Do nothing
- }
-} ;
-
-
-
-
-
-
-/// Sends all command output to a log, line by line, when the command finishes processing
-class cLogCommandOutputCallback :
- public cCommandOutputCallback
-{
-public:
- // cCommandOutputCallback overrides:
- virtual void Out(const AString & a_Text) override;
- virtual void Finished(void) override;
-
-protected:
- /// Output is stored here until the command finishes processing
- AString m_Buffer;
-} ;
-
-
-
-
-
-/// Sends all command output to a log, line by line; deletes self when command finishes processing
-class cLogCommandDeleteSelfOutputCallback :
- public cLogCommandOutputCallback
-{
- typedef cLogCommandOutputCallback super;
-
- virtual void Finished(void) override
- {
- super::Finished();
- delete this;
- }
-} ;
-
-
-
-
+
+// CommandOutput.h
+
+// Declares various classes that process command output
+
+
+
+
+
+/** Interface for a callback that receives command output
+The Out() function is called for any output the command has produced.
+Descendants override that function to provide specific processing of the output.
+*/
+class cCommandOutputCallback
+{
+public:
+ virtual ~cCommandOutputCallback() {}; // Force a virtual destructor in subclasses
+
+ /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a "\n"
+ void Out(const char * a_Fmt, ...);
+
+ /// 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) {};
+} ;
+
+
+
+
+
+/// Class that discards all command output
+class cNullCommandOutputCallback :
+ public cCommandOutputCallback
+{
+ // cCommandOutputCallback overrides:
+ virtual void Out(const AString & a_Text) override
+ {
+ // Do nothing
+ }
+} ;
+
+
+
+
+
+
+/// Sends all command output to a log, line by line, when the command finishes processing
+class cLogCommandOutputCallback :
+ public cCommandOutputCallback
+{
+public:
+ // cCommandOutputCallback overrides:
+ virtual void Out(const AString & a_Text) override;
+ virtual void Finished(void) override;
+
+protected:
+ /// Output is stored here until the command finishes processing
+ AString m_Buffer;
+} ;
+
+
+
+
+
+/// Sends all command output to a log, line by line; deletes self when command finishes processing
+class cLogCommandDeleteSelfOutputCallback :
+ public cLogCommandOutputCallback
+{
+ typedef cLogCommandOutputCallback super;
+
+ virtual void Finished(void) override
+ {
+ super::Finished();
+ delete this;
+ }
+} ;
+
+
+
+
diff --git a/source/Defines.h b/source/Defines.h
index f52050a9b..94e618eb0 100644
--- a/source/Defines.h
+++ b/source/Defines.h
@@ -116,6 +116,10 @@ enum eGameMode
gmSurvival = eGameMode_Survival,
gmCreative = eGameMode_Creative,
gmAdventure = eGameMode_Adventure,
+
+ // These two are used to check GameMode for validity when converting from integers.
+ gmMax, // Gets automatically assigned
+ gmMin = 0,
} ;
diff --git a/source/Enchantments.cpp b/source/Enchantments.cpp
index 08a24d8f3..0caf4eb11 100644
--- a/source/Enchantments.cpp
+++ b/source/Enchantments.cpp
@@ -1,298 +1,298 @@
-
-// Enchantments.cpp
-
-// Implements the cEnchantments class representing a storage for item enchantments and stored-enchantments
-
-#include "Globals.h"
-#include "Enchantments.h"
-#include "WorldStorage/FastNBT.h"
-
-
-
-
-
-cEnchantments::cEnchantments(void)
-{
- // Nothing needed yet, but the constructor needs to be declared and impemented in order to be usable
-}
-
-
-
-
-
-cEnchantments::cEnchantments(const AString & a_StringSpec)
-{
- AddFromString(a_StringSpec);
-}
-
-
-
-
-
-void cEnchantments::AddFromString(const AString & a_StringSpec)
-{
- // Add enchantments in the stringspec; if a specified enchantment already exists, overwrites it
-
- // Split the StringSpec into separate declarations, each in the form "id=lvl":
- AStringVector Decls = StringSplit(a_StringSpec, ";");
- for (AStringVector::const_iterator itr = Decls.begin(), end = Decls.end(); itr != end; ++itr)
- {
- // Split each declaration into the id and lvl part:
- if (itr->empty())
- {
- // The decl is empty (may happen if there's an extra semicolon at the end), ignore silently
- continue;
- }
- AStringVector Split = StringSplitAndTrim(*itr, "=");
- if (Split.size() != 2)
- {
- // Malformed decl
- LOG("%s: Malformed enchantment decl: \"%s\", skipping.", __FUNCTION__, itr->c_str());
- continue;
- }
- int id = atoi(Split[0].c_str());
- if ((id == 0) && (Split[0] != "0"))
- {
- id = StringToEnchantmentID(Split[0]);
- }
- int lvl = atoi(Split[1].c_str());
- if (
- ((id <= 0) && (Split[0] != "0")) ||
- ((lvl == 0) && (Split[1] != "0"))
- )
- {
- // Numbers failed to parse
- LOG("%s: Failed to parse enchantment declaration for numbers: \"%s\" and \"%s\", skipping.",
- __FUNCTION__, Split[0].c_str(), Split[1].c_str()
- );
- continue;
- }
- SetLevel(id, lvl);
- } // for itr - Decls[]
-}
-
-
-
-
-
-AString cEnchantments::ToString(void) const
-{
- // Serialize all the enchantments into a string
- AString res;
- for (cEnchantments::cMap::const_iterator itr = m_Enchantments.begin(), end = m_Enchantments.end(); itr != end; ++itr)
- {
- AppendPrintf(res, "%d=%d;", itr->first, itr->second);
- } // for itr - m_Enchantments[]
- return res;
-}
-
-
-
-
-
-int cEnchantments::GetLevel(int a_EnchantmentID) const
-{
- // Return the level for the specified enchantment; 0 if not stored
- cMap::const_iterator itr = m_Enchantments.find(a_EnchantmentID);
- if (itr != m_Enchantments.end())
- {
- return itr->second;
- }
-
- // Not stored, return zero
- return 0;
-}
-
-
-
-
-
-void cEnchantments::SetLevel(int a_EnchantmentID, int a_Level)
-{
- // Sets the level for the specified enchantment, adding it if not stored before or removing it if level <= 0
- if (a_Level == 0)
- {
- // Delete enchantment, if present:
- cMap::iterator itr = m_Enchantments.find(a_EnchantmentID);
- if (itr != m_Enchantments.end())
- {
- m_Enchantments.erase(itr);
- }
- }
- else
- {
- // Add / overwrite enchantment
- m_Enchantments[a_EnchantmentID] = a_Level;
- }
-}
-
-
-
-
-
-
-void cEnchantments::Clear(void)
-{
- m_Enchantments.clear();
-}
-
-
-
-
-
-bool cEnchantments::IsEmpty(void) const
-{
- return m_Enchantments.empty();
-}
-
-
-
-
-
-int cEnchantments::StringToEnchantmentID(const AString & a_EnchantmentName)
-{
- struct
- {
- int m_Value;
- const char * m_Name;
- } EnchantmentNames[] =
- {
- { enchProtection, "Protection"},
- { enchFireProtection, "FireProtection"},
- { enchFeatherFalling, "FeatherFalling"},
- { enchBlastProtection, "BlastProtection"},
- { enchProjectileProtection, "ProjectileProtection"},
- { enchRespiration, "Respiration"},
- { enchAquaAffinity, "AquaAffinity"},
- { enchThorns, "Thorns"},
- { enchSharpness, "Sharpness"},
- { enchSmite, "Smite"},
- { enchBaneOfArthropods, "BaneOfArthropods"},
- { enchKnockback, "Knockback"},
- { enchFireAspect, "FireAspect"},
- { enchLooting, "Looting"},
- { enchEfficiency, "Efficiency"},
- { enchSilkTouch, "SilkTouch"},
- { enchUnbreaking, "Unbreaking"},
- { enchFortune, "Fortune"},
- { enchPower, "Power"},
- { enchPunch, "Punch"},
- { enchFlame, "Flame"},
- { enchInfinity, "Infinity"},
- } ;
- for (int i = 0; i < ARRAYCOUNT(EnchantmentNames); i++)
- {
- if (NoCaseCompare(EnchantmentNames[i].m_Name, a_EnchantmentName) == 0)
- {
- return EnchantmentNames[i].m_Value;
- }
- } // for i - EnchantmentNames[]
- return -1;
-}
-
-
-
-
-
-bool cEnchantments::operator ==(const cEnchantments & a_Other) const
-{
- return m_Enchantments == a_Other.m_Enchantments;
-}
-
-
-
-
-
-bool cEnchantments::operator !=(const cEnchantments & a_Other) const
-{
- return m_Enchantments != a_Other.m_Enchantments;
-}
-
-
-
-
-
-void cEnchantments::WriteToNBTCompound(cFastNBTWriter & a_Writer, const AString & a_ListTagName) const
-{
- // Write the enchantments into the specified NBT writer
- // begin with the LIST tag of the specified name ("ench" or "StoredEnchantments")
-
- a_Writer.BeginList(a_ListTagName, TAG_Compound);
- for (cMap::const_iterator itr = m_Enchantments.begin(), end = m_Enchantments.end(); itr != end; ++itr)
- {
- a_Writer.BeginCompound("");
- a_Writer.AddShort("id", itr->first);
- a_Writer.AddShort("lvl", itr->second);
- a_Writer.EndCompound();
- } // for itr - m_Enchantments[]
- a_Writer.EndList();
-}
-
-
-
-
-
-void cEnchantments::ParseFromNBT(const cParsedNBT & a_NBT, int a_EnchListTagIdx)
-{
- // Read the enchantments from the specified NBT list tag (ench or StoredEnchantments)
-
- // Verify that the tag is a list:
- if (a_NBT.GetType(a_EnchListTagIdx) != TAG_List)
- {
- LOGWARNING("%s: Invalid EnchListTag type: exp %d, got %d. Enchantments not parsed",
- __FUNCTION__, TAG_List, a_NBT.GetType(a_EnchListTagIdx)
- );
- ASSERT(!"Bad EnchListTag type");
- return;
- }
-
- // Verify that the list is of Compounds:
- if (a_NBT.GetChildrenType(a_EnchListTagIdx) != TAG_Compound)
- {
- LOGWARNING("%s: Invalid NBT list children type: exp %d, got %d. Enchantments not parsed",
- __FUNCTION__, TAG_Compound, a_NBT.GetChildrenType(a_EnchListTagIdx)
- );
- ASSERT(!"Bad EnchListTag children type");
- return;
- }
-
- Clear();
-
- // Iterate over all the compound children, parse an enchantment from each:
- for (int tag = a_NBT.GetFirstChild(a_EnchListTagIdx); tag >= 0; tag = a_NBT.GetNextSibling(tag))
- {
- // tag is the compound inside the "ench" list tag
- ASSERT(a_NBT.GetType(tag) == TAG_Compound);
-
- // Search for the id and lvl tags' values:
- int id = -1, lvl = -1;
- for (int ch = a_NBT.GetFirstChild(tag); ch >= 0; ch = a_NBT.GetNextSibling(ch))
- {
- if (a_NBT.GetType(ch) != TAG_Short)
- {
- continue;
- }
- if (a_NBT.GetName(ch) == "id")
- {
- id = a_NBT.GetShort(ch);
- }
- else if (a_NBT.GetName(ch) == "lvl")
- {
- lvl = a_NBT.GetShort(ch);
- }
- } // for ch - children of the compound tag
-
- if ((id == -1) || (lvl <= 0))
- {
- // Failed to parse either the id or the lvl, skip this compound
- continue;
- }
-
- // Store the enchantment:
- m_Enchantments[id] = lvl;
- } // for tag - children of the ench list tag
-}
-
-
-
-
+
+// Enchantments.cpp
+
+// Implements the cEnchantments class representing a storage for item enchantments and stored-enchantments
+
+#include "Globals.h"
+#include "Enchantments.h"
+#include "WorldStorage/FastNBT.h"
+
+
+
+
+
+cEnchantments::cEnchantments(void)
+{
+ // Nothing needed yet, but the constructor needs to be declared and impemented in order to be usable
+}
+
+
+
+
+
+cEnchantments::cEnchantments(const AString & a_StringSpec)
+{
+ AddFromString(a_StringSpec);
+}
+
+
+
+
+
+void cEnchantments::AddFromString(const AString & a_StringSpec)
+{
+ // Add enchantments in the stringspec; if a specified enchantment already exists, overwrites it
+
+ // Split the StringSpec into separate declarations, each in the form "id=lvl":
+ AStringVector Decls = StringSplit(a_StringSpec, ";");
+ for (AStringVector::const_iterator itr = Decls.begin(), end = Decls.end(); itr != end; ++itr)
+ {
+ // Split each declaration into the id and lvl part:
+ if (itr->empty())
+ {
+ // The decl is empty (may happen if there's an extra semicolon at the end), ignore silently
+ continue;
+ }
+ AStringVector Split = StringSplitAndTrim(*itr, "=");
+ if (Split.size() != 2)
+ {
+ // Malformed decl
+ LOG("%s: Malformed enchantment decl: \"%s\", skipping.", __FUNCTION__, itr->c_str());
+ continue;
+ }
+ int id = atoi(Split[0].c_str());
+ if ((id == 0) && (Split[0] != "0"))
+ {
+ id = StringToEnchantmentID(Split[0]);
+ }
+ int lvl = atoi(Split[1].c_str());
+ if (
+ ((id <= 0) && (Split[0] != "0")) ||
+ ((lvl == 0) && (Split[1] != "0"))
+ )
+ {
+ // Numbers failed to parse
+ LOG("%s: Failed to parse enchantment declaration for numbers: \"%s\" and \"%s\", skipping.",
+ __FUNCTION__, Split[0].c_str(), Split[1].c_str()
+ );
+ continue;
+ }
+ SetLevel(id, lvl);
+ } // for itr - Decls[]
+}
+
+
+
+
+
+AString cEnchantments::ToString(void) const
+{
+ // Serialize all the enchantments into a string
+ AString res;
+ for (cEnchantments::cMap::const_iterator itr = m_Enchantments.begin(), end = m_Enchantments.end(); itr != end; ++itr)
+ {
+ AppendPrintf(res, "%d=%d;", itr->first, itr->second);
+ } // for itr - m_Enchantments[]
+ return res;
+}
+
+
+
+
+
+int cEnchantments::GetLevel(int a_EnchantmentID) const
+{
+ // Return the level for the specified enchantment; 0 if not stored
+ cMap::const_iterator itr = m_Enchantments.find(a_EnchantmentID);
+ if (itr != m_Enchantments.end())
+ {
+ return itr->second;
+ }
+
+ // Not stored, return zero
+ return 0;
+}
+
+
+
+
+
+void cEnchantments::SetLevel(int a_EnchantmentID, int a_Level)
+{
+ // Sets the level for the specified enchantment, adding it if not stored before or removing it if level <= 0
+ if (a_Level == 0)
+ {
+ // Delete enchantment, if present:
+ cMap::iterator itr = m_Enchantments.find(a_EnchantmentID);
+ if (itr != m_Enchantments.end())
+ {
+ m_Enchantments.erase(itr);
+ }
+ }
+ else
+ {
+ // Add / overwrite enchantment
+ m_Enchantments[a_EnchantmentID] = a_Level;
+ }
+}
+
+
+
+
+
+
+void cEnchantments::Clear(void)
+{
+ m_Enchantments.clear();
+}
+
+
+
+
+
+bool cEnchantments::IsEmpty(void) const
+{
+ return m_Enchantments.empty();
+}
+
+
+
+
+
+int cEnchantments::StringToEnchantmentID(const AString & a_EnchantmentName)
+{
+ struct
+ {
+ int m_Value;
+ const char * m_Name;
+ } EnchantmentNames[] =
+ {
+ { enchProtection, "Protection"},
+ { enchFireProtection, "FireProtection"},
+ { enchFeatherFalling, "FeatherFalling"},
+ { enchBlastProtection, "BlastProtection"},
+ { enchProjectileProtection, "ProjectileProtection"},
+ { enchRespiration, "Respiration"},
+ { enchAquaAffinity, "AquaAffinity"},
+ { enchThorns, "Thorns"},
+ { enchSharpness, "Sharpness"},
+ { enchSmite, "Smite"},
+ { enchBaneOfArthropods, "BaneOfArthropods"},
+ { enchKnockback, "Knockback"},
+ { enchFireAspect, "FireAspect"},
+ { enchLooting, "Looting"},
+ { enchEfficiency, "Efficiency"},
+ { enchSilkTouch, "SilkTouch"},
+ { enchUnbreaking, "Unbreaking"},
+ { enchFortune, "Fortune"},
+ { enchPower, "Power"},
+ { enchPunch, "Punch"},
+ { enchFlame, "Flame"},
+ { enchInfinity, "Infinity"},
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(EnchantmentNames); i++)
+ {
+ if (NoCaseCompare(EnchantmentNames[i].m_Name, a_EnchantmentName) == 0)
+ {
+ return EnchantmentNames[i].m_Value;
+ }
+ } // for i - EnchantmentNames[]
+ return -1;
+}
+
+
+
+
+
+bool cEnchantments::operator ==(const cEnchantments & a_Other) const
+{
+ return m_Enchantments == a_Other.m_Enchantments;
+}
+
+
+
+
+
+bool cEnchantments::operator !=(const cEnchantments & a_Other) const
+{
+ return m_Enchantments != a_Other.m_Enchantments;
+}
+
+
+
+
+
+void cEnchantments::WriteToNBTCompound(cFastNBTWriter & a_Writer, const AString & a_ListTagName) const
+{
+ // Write the enchantments into the specified NBT writer
+ // begin with the LIST tag of the specified name ("ench" or "StoredEnchantments")
+
+ a_Writer.BeginList(a_ListTagName, TAG_Compound);
+ for (cMap::const_iterator itr = m_Enchantments.begin(), end = m_Enchantments.end(); itr != end; ++itr)
+ {
+ a_Writer.BeginCompound("");
+ a_Writer.AddShort("id", itr->first);
+ a_Writer.AddShort("lvl", itr->second);
+ a_Writer.EndCompound();
+ } // for itr - m_Enchantments[]
+ a_Writer.EndList();
+}
+
+
+
+
+
+void cEnchantments::ParseFromNBT(const cParsedNBT & a_NBT, int a_EnchListTagIdx)
+{
+ // Read the enchantments from the specified NBT list tag (ench or StoredEnchantments)
+
+ // Verify that the tag is a list:
+ if (a_NBT.GetType(a_EnchListTagIdx) != TAG_List)
+ {
+ LOGWARNING("%s: Invalid EnchListTag type: exp %d, got %d. Enchantments not parsed",
+ __FUNCTION__, TAG_List, a_NBT.GetType(a_EnchListTagIdx)
+ );
+ ASSERT(!"Bad EnchListTag type");
+ return;
+ }
+
+ // Verify that the list is of Compounds:
+ if (a_NBT.GetChildrenType(a_EnchListTagIdx) != TAG_Compound)
+ {
+ LOGWARNING("%s: Invalid NBT list children type: exp %d, got %d. Enchantments not parsed",
+ __FUNCTION__, TAG_Compound, a_NBT.GetChildrenType(a_EnchListTagIdx)
+ );
+ ASSERT(!"Bad EnchListTag children type");
+ return;
+ }
+
+ Clear();
+
+ // Iterate over all the compound children, parse an enchantment from each:
+ for (int tag = a_NBT.GetFirstChild(a_EnchListTagIdx); tag >= 0; tag = a_NBT.GetNextSibling(tag))
+ {
+ // tag is the compound inside the "ench" list tag
+ ASSERT(a_NBT.GetType(tag) == TAG_Compound);
+
+ // Search for the id and lvl tags' values:
+ int id = -1, lvl = -1;
+ for (int ch = a_NBT.GetFirstChild(tag); ch >= 0; ch = a_NBT.GetNextSibling(ch))
+ {
+ if (a_NBT.GetType(ch) != TAG_Short)
+ {
+ continue;
+ }
+ if (a_NBT.GetName(ch) == "id")
+ {
+ id = a_NBT.GetShort(ch);
+ }
+ else if (a_NBT.GetName(ch) == "lvl")
+ {
+ lvl = a_NBT.GetShort(ch);
+ }
+ } // for ch - children of the compound tag
+
+ if ((id == -1) || (lvl <= 0))
+ {
+ // Failed to parse either the id or the lvl, skip this compound
+ continue;
+ }
+
+ // Store the enchantment:
+ m_Enchantments[id] = lvl;
+ } // for tag - children of the ench list tag
+}
+
+
+
+
diff --git a/source/Enchantments.h b/source/Enchantments.h
index c20da654b..cda743daf 100644
--- a/source/Enchantments.h
+++ b/source/Enchantments.h
@@ -1,114 +1,114 @@
-
-// Enchantments.h
-
-// Declares the cEnchantments class representing a storage for item enchantments and stored-enchantments
-
-
-
-
-
-#pragma once
-
-
-
-
-
-// fwd: WorldStorage/FastNBT.h
-class cFastNBTWriter;
-class cParsedNBT;
-
-
-
-
-
-// tolua_begin
-
-/** Class that stores item enchantments or stored-enchantments
-The enchantments may be serialized to a stringspec and read back from such stringspec.
-The format for the stringspec is "id=lvl;id=lvl;id=lvl...", with an optional semicolon at the end,
-mapping each enchantment's id onto its level. ID may be either a number or the enchantment name.
-Level value of 0 means no such enchantment, and it will not be stored in the m_Enchantments.
-Serialization will never put zero-level enchantments into the stringspec and will always use numeric IDs.
-*/
-class cEnchantments
-{
-public:
- /// Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs )
- enum
- {
- enchProtection = 0,
- enchFireProtection = 1,
- enchFeatherFalling = 2,
- enchBlastProtection = 3,
- enchProjectileProtection = 4,
- enchRespiration = 5,
- enchAquaAffinity = 6,
- enchThorns = 7,
- enchSharpness = 16,
- enchSmite = 17,
- enchBaneOfArthropods = 18,
- enchKnockback = 19,
- enchFireAspect = 20,
- enchLooting = 21,
- enchEfficiency = 32,
- enchSilkTouch = 33,
- enchUnbreaking = 34,
- enchFortune = 35,
- enchPower = 48,
- enchPunch = 49,
- enchFlame = 50,
- enchInfinity = 51,
- } ;
-
- /// Creates an empty enchantments container
- cEnchantments(void);
-
- /// Creates an enchantments container filled with enchantments parsed from stringspec
- cEnchantments(const AString & a_StringSpec);
-
- /// Adds enchantments in the stringspec; if a specified enchantment already exists, overwrites it
- void AddFromString(const AString & a_StringSpec);
-
- /// Serializes all the enchantments into a string
- AString ToString(void) const;
-
- /// Returns the level for the specified enchantment; 0 if not stored
- int GetLevel(int a_EnchantmentID) const;
-
- /// Sets the level for the specified enchantment, adding it if not stored before or removing it if level <= 0
- void SetLevel(int a_EnchantmentID, int a_Level);
-
- /// Removes all enchantments
- void Clear(void);
-
- /// Returns true if there are no enchantments
- bool IsEmpty(void) const;
-
- /// Converts enchantment name to the numeric representation; returns -1 if enchantment name not found; case insensitive
- static int StringToEnchantmentID(const AString & a_EnchantmentName);
-
- /// Returns true if a_Other contains exactly the same enchantments and levels
- bool operator ==(const cEnchantments & a_Other) const;
-
- // tolua_end
-
- /// Returns true if a_Other doesn't contain exactly the same enchantments and levels
- bool operator !=(const cEnchantments & a_Other) const;
-
- /// Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments")
- void WriteToNBTCompound(cFastNBTWriter & a_Writer, const AString & a_ListTagName) const;
-
- /// Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments)
- void ParseFromNBT(const cParsedNBT & a_NBT, int a_EnchListTagIdx);
-
-protected:
- /// Maps enchantment ID -> enchantment level
- typedef std::map<int, int> cMap;
-
- /// Currently stored enchantments
- cMap m_Enchantments;
-} ; // tolua_export
-
-
-
-
+
+// Enchantments.h
+
+// Declares the cEnchantments class representing a storage for item enchantments and stored-enchantments
+
+
+
+
+
+#pragma once
+
+
+
+
+
+// fwd: WorldStorage/FastNBT.h
+class cFastNBTWriter;
+class cParsedNBT;
+
+
+
+
+
+// tolua_begin
+
+/** Class that stores item enchantments or stored-enchantments
+The enchantments may be serialized to a stringspec and read back from such stringspec.
+The format for the stringspec is "id=lvl;id=lvl;id=lvl...", with an optional semicolon at the end,
+mapping each enchantment's id onto its level. ID may be either a number or the enchantment name.
+Level value of 0 means no such enchantment, and it will not be stored in the m_Enchantments.
+Serialization will never put zero-level enchantments into the stringspec and will always use numeric IDs.
+*/
+class cEnchantments
+{
+public:
+ /// Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs )
+ enum
+ {
+ enchProtection = 0,
+ enchFireProtection = 1,
+ enchFeatherFalling = 2,
+ enchBlastProtection = 3,
+ enchProjectileProtection = 4,
+ enchRespiration = 5,
+ enchAquaAffinity = 6,
+ enchThorns = 7,
+ enchSharpness = 16,
+ enchSmite = 17,
+ enchBaneOfArthropods = 18,
+ enchKnockback = 19,
+ enchFireAspect = 20,
+ enchLooting = 21,
+ enchEfficiency = 32,
+ enchSilkTouch = 33,
+ enchUnbreaking = 34,
+ enchFortune = 35,
+ enchPower = 48,
+ enchPunch = 49,
+ enchFlame = 50,
+ enchInfinity = 51,
+ } ;
+
+ /// Creates an empty enchantments container
+ cEnchantments(void);
+
+ /// Creates an enchantments container filled with enchantments parsed from stringspec
+ cEnchantments(const AString & a_StringSpec);
+
+ /// Adds enchantments in the stringspec; if a specified enchantment already exists, overwrites it
+ void AddFromString(const AString & a_StringSpec);
+
+ /// Serializes all the enchantments into a string
+ AString ToString(void) const;
+
+ /// Returns the level for the specified enchantment; 0 if not stored
+ int GetLevel(int a_EnchantmentID) const;
+
+ /// Sets the level for the specified enchantment, adding it if not stored before or removing it if level <= 0
+ void SetLevel(int a_EnchantmentID, int a_Level);
+
+ /// Removes all enchantments
+ void Clear(void);
+
+ /// Returns true if there are no enchantments
+ bool IsEmpty(void) const;
+
+ /// Converts enchantment name to the numeric representation; returns -1 if enchantment name not found; case insensitive
+ static int StringToEnchantmentID(const AString & a_EnchantmentName);
+
+ /// Returns true if a_Other contains exactly the same enchantments and levels
+ bool operator ==(const cEnchantments & a_Other) const;
+
+ // tolua_end
+
+ /// Returns true if a_Other doesn't contain exactly the same enchantments and levels
+ bool operator !=(const cEnchantments & a_Other) const;
+
+ /// Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments")
+ void WriteToNBTCompound(cFastNBTWriter & a_Writer, const AString & a_ListTagName) const;
+
+ /// Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments)
+ void ParseFromNBT(const cParsedNBT & a_NBT, int a_EnchListTagIdx);
+
+protected:
+ /// Maps enchantment ID -> enchantment level
+ typedef std::map<int, int> cMap;
+
+ /// Currently stored enchantments
+ cMap m_Enchantments;
+} ; // tolua_export
+
+
+
+
diff --git a/source/FallingBlock.cpp b/source/FallingBlock.cpp
index c3f980303..5dc99c771 100644
--- a/source/FallingBlock.cpp
+++ b/source/FallingBlock.cpp
@@ -1,103 +1,103 @@
-#include "Globals.h"
-
-#include "FallingBlock.h"
-#include "World.h"
-#include "ClientHandle.h"
-#include "Simulator/SandSimulator.h"
-#include "Chunk.h"
-
-
-
-
-
-cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
- super(etFallingBlock, a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f, 0.98, 0.98),
- m_BlockType(a_BlockType),
- m_BlockMeta(a_BlockMeta),
- m_OriginalPosition(a_BlockPosition)
-{
-}
-
-
-
-
-
-void cFallingBlock::Initialize(cWorld * a_World)
-{
- super::Initialize(a_World);
- a_World->BroadcastSpawnEntity(*this);
-}
-
-
-
-
-
-void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
-{
- a_ClientHandle.SendSpawnFallingBlock(*this);
-}
-
-
-
-
-
-void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
-{
- float MilliDt = a_Dt * 0.001f;
- AddSpeedY(MilliDt * -9.8f);
- AddPosY(GetSpeedY() * MilliDt);
-
- // GetWorld()->BroadcastTeleportEntity(*this); // Test position
-
- int BlockX = m_OriginalPosition.x;
- int BlockY = (int)(GetPosY() - 0.5);
- int BlockZ = m_OriginalPosition.z;
-
- if (BlockY < 0)
- {
- // Fallen out of this world, just continue falling until out of sight, then destroy:
- if (BlockY < 100)
- {
- Destroy(true);
- }
- return;
- }
-
- if (BlockY >= cChunkDef::Height)
- {
- // Above the world, just wait for it to fall back down
- 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);
- if (cSandSimulator::DoesBreakFallingThrough(BlockBelow, BelowMeta))
- {
- // Fallen onto a block that breaks this into pickups (e. g. half-slab)
- // Must finish the fall with coords one below the block:
- cSandSimulator::FinishFalling(m_World, BlockX, BlockY, BlockZ, m_BlockType, m_BlockMeta);
- Destroy(true);
- return;
- }
- else if (!cSandSimulator::CanContinueFallThrough(BlockBelow))
- {
- // Fallen onto a solid block
- /*
- LOGD(
- "Sand: Checked below at {%d, %d, %d} (rel {%d, %d, %d}), it's %s, finishing the fall.",
- BlockX, BlockY, BlockZ,
- BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width,
- ItemTypeToString(BlockBelow).c_str()
- );
- */
-
- cSandSimulator::FinishFalling(m_World, BlockX, BlockY + 1, BlockZ, m_BlockType, m_BlockMeta);
- Destroy(true);
- return;
- }
-}
-
-
-
-
+#include "Globals.h"
+
+#include "FallingBlock.h"
+#include "World.h"
+#include "ClientHandle.h"
+#include "Simulator/SandSimulator.h"
+#include "Chunk.h"
+
+
+
+
+
+cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
+ super(etFallingBlock, a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f, 0.98, 0.98),
+ m_BlockType(a_BlockType),
+ m_BlockMeta(a_BlockMeta),
+ m_OriginalPosition(a_BlockPosition)
+{
+}
+
+
+
+
+
+void cFallingBlock::Initialize(cWorld * a_World)
+{
+ super::Initialize(a_World);
+ a_World->BroadcastSpawnEntity(*this);
+}
+
+
+
+
+
+void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
+{
+ a_ClientHandle.SendSpawnFallingBlock(*this);
+}
+
+
+
+
+
+void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ float MilliDt = a_Dt * 0.001f;
+ AddSpeedY(MilliDt * -9.8f);
+ AddPosY(GetSpeedY() * MilliDt);
+
+ // GetWorld()->BroadcastTeleportEntity(*this); // Test position
+
+ int BlockX = m_OriginalPosition.x;
+ int BlockY = (int)(GetPosY() - 0.5);
+ int BlockZ = m_OriginalPosition.z;
+
+ if (BlockY < 0)
+ {
+ // Fallen out of this world, just continue falling until out of sight, then destroy:
+ if (BlockY < 100)
+ {
+ Destroy(true);
+ }
+ return;
+ }
+
+ if (BlockY >= cChunkDef::Height)
+ {
+ // Above the world, just wait for it to fall back down
+ 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);
+ if (cSandSimulator::DoesBreakFallingThrough(BlockBelow, BelowMeta))
+ {
+ // Fallen onto a block that breaks this into pickups (e. g. half-slab)
+ // Must finish the fall with coords one below the block:
+ cSandSimulator::FinishFalling(m_World, BlockX, BlockY, BlockZ, m_BlockType, m_BlockMeta);
+ Destroy(true);
+ return;
+ }
+ else if (!cSandSimulator::CanContinueFallThrough(BlockBelow))
+ {
+ // Fallen onto a solid block
+ /*
+ LOGD(
+ "Sand: Checked below at {%d, %d, %d} (rel {%d, %d, %d}), it's %s, finishing the fall.",
+ BlockX, BlockY, BlockZ,
+ BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width,
+ ItemTypeToString(BlockBelow).c_str()
+ );
+ */
+
+ cSandSimulator::FinishFalling(m_World, BlockX, BlockY + 1, BlockZ, m_BlockType, m_BlockMeta);
+ Destroy(true);
+ return;
+ }
+}
+
+
+
+
diff --git a/source/FallingBlock.h b/source/FallingBlock.h
index b7d448327..887ae6268 100644
--- a/source/FallingBlock.h
+++ b/source/FallingBlock.h
@@ -1,45 +1,45 @@
-
-#pragma once
-
-#include "Entity.h"
-#include "Defines.h"
-
-
-
-
-class cPlayer;
-class cItem;
-
-
-
-
-
-
-class cFallingBlock :
- public cEntity
-{
- typedef cEntity super;
-
-public:
- 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);
-
- BLOCKTYPE GetBlockType(void) const { return m_BlockType; }
- NIBBLETYPE GetBlockMeta(void) const { return m_BlockMeta; }
-
- // cEntity overrides:
- virtual void Initialize(cWorld * a_World) override;
- virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
-
-private:
- BLOCKTYPE m_BlockType;
- NIBBLETYPE m_BlockMeta;
- Vector3i m_OriginalPosition; // Position where the falling block has started, in world coords
-} ;
-
-
-
-
+
+#pragma once
+
+#include "Entity.h"
+#include "Defines.h"
+
+
+
+
+class cPlayer;
+class cItem;
+
+
+
+
+
+
+class cFallingBlock :
+ public cEntity
+{
+ typedef cEntity super;
+
+public:
+ 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);
+
+ BLOCKTYPE GetBlockType(void) const { return m_BlockType; }
+ NIBBLETYPE GetBlockMeta(void) const { return m_BlockMeta; }
+
+ // cEntity overrides:
+ virtual void Initialize(cWorld * a_World) override;
+ virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+
+private:
+ BLOCKTYPE m_BlockType;
+ NIBBLETYPE m_BlockMeta;
+ Vector3i m_OriginalPosition; // Position where the falling block has started, in world coords
+} ;
+
+
+
+
diff --git a/source/FastRandom.cpp b/source/FastRandom.cpp
index b778fb4bb..887e4426d 100644
--- a/source/FastRandom.cpp
+++ b/source/FastRandom.cpp
@@ -1,174 +1,174 @@
-
-// FastRandom.cpp
-
-// Implements the cFastRandom class representing a fast random number generator
-
-#include "Globals.h"
-#include <time.h>
-#include "FastRandom.h"
-
-
-
-
-
-#if 0 && defined(_DEBUG)
-// Self-test
-// Both ints and floats are quick-tested to see if the random is calculated correctly, checking the range in ASSERTs,
-// and if it performs well in terms of distribution (checked by avg, expected to be in the range midpoint
-class cFastRandomTest
-{
-public:
- cFastRandomTest(void)
- {
- TestInts();
- TestFloats();
- }
-
-
- void TestInts(void)
- {
- printf("Testing ints...\n");
- cFastRandom rnd;
- int sum = 0;
- const int BUCKETS = 8;
- int Counts[BUCKETS];
- memset(Counts, 0, sizeof(Counts));
- const int ITER = 10000;
- for (int i = 0; i < ITER; i++)
- {
- int v = rnd.NextInt(1000);
- ASSERT(v >= 0);
- ASSERT(v < 1000);
- Counts[v % BUCKETS]++;
- sum += v;
- }
- double avg = (double)sum / ITER;
- printf("avg: %f\n", avg);
- for (int i = 0; i < BUCKETS; i++)
- {
- printf(" bucket %d: %d\n", i, Counts[i]);
- }
- }
-
-
- void TestFloats(void)
- {
- printf("Testing floats...\n");
- cFastRandom rnd;
- float sum = 0;
- const int BUCKETS = 8;
- int Counts[BUCKETS];
- memset(Counts, 0, sizeof(Counts));
- const int ITER = 10000;
- for (int i = 0; i < ITER; i++)
- {
- float v = rnd.NextFloat(1000);
- ASSERT(v >= 0);
- ASSERT(v <= 1000);
- Counts[((int)v) % BUCKETS]++;
- sum += v;
- }
- sum = sum / ITER;
- printf("avg: %f\n", sum);
- for (int i = 0; i < BUCKETS; i++)
- {
- printf(" bucket %d: %d\n", i, Counts[i]);
- }
- }
-} g_Test;
-
-#endif
-
-
-
-
-
-
-int cFastRandom::m_SeedCounter = 0;
-
-
-
-
-
-cFastRandom::cFastRandom(void) :
- m_Seed(m_SeedCounter++)
-{
-}
-
-
-
-
-
-int cFastRandom::NextInt(int a_Range)
-{
- ASSERT(a_Range <= 1000000); // The random is not sufficiently linearly distributed with bigger ranges
- ASSERT(a_Range > 0);
-
- // Make the m_Counter operations as minimal as possible, to emulate atomicity
- int Counter = m_Counter++;
-
- // Use a_Range, m_Counter and m_Seed as inputs to the pseudorandom function:
- int n = a_Range + m_Counter * 57 + m_Seed * 57 * 57;
- n = (n << 13) ^ n;
- n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
- return ((n / 11) % a_Range);
-}
-
-
-
-
-
-int cFastRandom::NextInt(int a_Range, int a_Salt)
-{
- ASSERT(a_Range <= 1000000); // The random is not sufficiently linearly distributed with bigger ranges
- ASSERT(a_Range > 0);
-
- // Make the m_Counter operations as minimal as possible, to emulate atomicity
- int Counter = m_Counter++;
-
- // Use a_Range, a_Salt, m_Counter and m_Seed as inputs to the pseudorandom function:
- int n = a_Range + m_Counter * 57 + m_Seed * 57 * 57 + a_Salt * 57 * 57 * 57;
- n = (n << 13) ^ n;
- n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
- return ((n / 11) % a_Range);
-}
-
-
-
-
-
-float cFastRandom::NextFloat(float a_Range)
-{
- // Make the m_Counter operations as minimal as possible, to emulate atomicity
- int Counter = m_Counter++;
-
- // Use a_Range, a_Salt, m_Counter and m_Seed as inputs to the pseudorandom function:
- int n = (int)a_Range + m_Counter * 57 + m_Seed * 57 * 57;
- n = (n << 13) ^ n;
- n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
-
- // Convert the integer into float with the specified range:
- return (((float)n / (float)0x7fffffff) * a_Range);
-}
-
-
-
-
-
-float cFastRandom::NextFloat(float a_Range, int a_Salt)
-{
- // Make the m_Counter operations as minimal as possible, to emulate atomicity
- int Counter = m_Counter++;
-
- // Use a_Range, a_Salt, m_Counter and m_Seed as inputs to the pseudorandom function:
- int n = (int)a_Range + m_Counter * 57 + m_Seed * 57 * 57 + a_Salt * 57 * 57 * 57;
- n = (n << 13) ^ n;
- n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
-
- // Convert the integer into float with the specified range:
- return (((float)n / (float)0x7fffffff) * a_Range);
-}
-
-
-
-
+
+// FastRandom.cpp
+
+// Implements the cFastRandom class representing a fast random number generator
+
+#include "Globals.h"
+#include <time.h>
+#include "FastRandom.h"
+
+
+
+
+
+#if 0 && defined(_DEBUG)
+// Self-test
+// Both ints and floats are quick-tested to see if the random is calculated correctly, checking the range in ASSERTs,
+// and if it performs well in terms of distribution (checked by avg, expected to be in the range midpoint
+class cFastRandomTest
+{
+public:
+ cFastRandomTest(void)
+ {
+ TestInts();
+ TestFloats();
+ }
+
+
+ void TestInts(void)
+ {
+ printf("Testing ints...\n");
+ cFastRandom rnd;
+ int sum = 0;
+ const int BUCKETS = 8;
+ int Counts[BUCKETS];
+ memset(Counts, 0, sizeof(Counts));
+ const int ITER = 10000;
+ for (int i = 0; i < ITER; i++)
+ {
+ int v = rnd.NextInt(1000);
+ ASSERT(v >= 0);
+ ASSERT(v < 1000);
+ Counts[v % BUCKETS]++;
+ sum += v;
+ }
+ double avg = (double)sum / ITER;
+ printf("avg: %f\n", avg);
+ for (int i = 0; i < BUCKETS; i++)
+ {
+ printf(" bucket %d: %d\n", i, Counts[i]);
+ }
+ }
+
+
+ void TestFloats(void)
+ {
+ printf("Testing floats...\n");
+ cFastRandom rnd;
+ float sum = 0;
+ const int BUCKETS = 8;
+ int Counts[BUCKETS];
+ memset(Counts, 0, sizeof(Counts));
+ const int ITER = 10000;
+ for (int i = 0; i < ITER; i++)
+ {
+ float v = rnd.NextFloat(1000);
+ ASSERT(v >= 0);
+ ASSERT(v <= 1000);
+ Counts[((int)v) % BUCKETS]++;
+ sum += v;
+ }
+ sum = sum / ITER;
+ printf("avg: %f\n", sum);
+ for (int i = 0; i < BUCKETS; i++)
+ {
+ printf(" bucket %d: %d\n", i, Counts[i]);
+ }
+ }
+} g_Test;
+
+#endif
+
+
+
+
+
+
+int cFastRandom::m_SeedCounter = 0;
+
+
+
+
+
+cFastRandom::cFastRandom(void) :
+ m_Seed(m_SeedCounter++)
+{
+}
+
+
+
+
+
+int cFastRandom::NextInt(int a_Range)
+{
+ ASSERT(a_Range <= 1000000); // The random is not sufficiently linearly distributed with bigger ranges
+ ASSERT(a_Range > 0);
+
+ // Make the m_Counter operations as minimal as possible, to emulate atomicity
+ int Counter = m_Counter++;
+
+ // Use a_Range, m_Counter and m_Seed as inputs to the pseudorandom function:
+ int n = a_Range + m_Counter * 57 + m_Seed * 57 * 57;
+ n = (n << 13) ^ n;
+ n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
+ return ((n / 11) % a_Range);
+}
+
+
+
+
+
+int cFastRandom::NextInt(int a_Range, int a_Salt)
+{
+ ASSERT(a_Range <= 1000000); // The random is not sufficiently linearly distributed with bigger ranges
+ ASSERT(a_Range > 0);
+
+ // Make the m_Counter operations as minimal as possible, to emulate atomicity
+ int Counter = m_Counter++;
+
+ // Use a_Range, a_Salt, m_Counter and m_Seed as inputs to the pseudorandom function:
+ int n = a_Range + m_Counter * 57 + m_Seed * 57 * 57 + a_Salt * 57 * 57 * 57;
+ n = (n << 13) ^ n;
+ n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
+ return ((n / 11) % a_Range);
+}
+
+
+
+
+
+float cFastRandom::NextFloat(float a_Range)
+{
+ // Make the m_Counter operations as minimal as possible, to emulate atomicity
+ int Counter = m_Counter++;
+
+ // Use a_Range, a_Salt, m_Counter and m_Seed as inputs to the pseudorandom function:
+ int n = (int)a_Range + m_Counter * 57 + m_Seed * 57 * 57;
+ n = (n << 13) ^ n;
+ n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
+
+ // Convert the integer into float with the specified range:
+ return (((float)n / (float)0x7fffffff) * a_Range);
+}
+
+
+
+
+
+float cFastRandom::NextFloat(float a_Range, int a_Salt)
+{
+ // Make the m_Counter operations as minimal as possible, to emulate atomicity
+ int Counter = m_Counter++;
+
+ // Use a_Range, a_Salt, m_Counter and m_Seed as inputs to the pseudorandom function:
+ int n = (int)a_Range + m_Counter * 57 + m_Seed * 57 * 57 + a_Salt * 57 * 57 * 57;
+ n = (n << 13) ^ n;
+ n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
+
+ // Convert the integer into float with the specified range:
+ return (((float)n / (float)0x7fffffff) * a_Range);
+}
+
+
+
+
diff --git a/source/FastRandom.h b/source/FastRandom.h
index 011c0c8da..bf70822cf 100644
--- a/source/FastRandom.h
+++ b/source/FastRandom.h
@@ -1,57 +1,57 @@
-
-// FastRandom.h
-
-// Declares the cFastRandom class representing a fast random number generator
-
-/*
-The cFastRandom aims to provide a very fast, although not very cryptographically secure, random generator.
-It is fast to instantiate, fast to query next, and partially multi-thread-safe.
-It is multi-thread-safe in the sense that it can be accessed from multiple threads without crashing, but it may
-yield duplicate numbers in that case.
-
-Internally, this works similar to cNoise's integral noise generation, with some predefined inputs: the seed is
-taken from a global counter and the random is calculated using a counter that is incremented on each use (hence
-the multi-thread duplication). Two alternatives exists for each function, one that takes a range parameter,
-and another that takes an additional "salt" parameter; this salt is used as an additional input to the random,
-in order to avoid multi-thread duplication. If two threads both use the class at the same time with different
-salts, the values they get will be different.
-*/
-
-
-
-
-
-#pragma once
-
-
-
-
-
-class cFastRandom
-{
-public:
- cFastRandom(void);
-
- /// Returns a random int in the range [0 .. a_Range - 1]; a_Range must be less than 1M
- int NextInt(int a_Range);
-
- /// Returns a random int in the range [0 .. a_Range - 1]; a_Range must be less than 1M; a_Salt is additional source of randomness
- int NextInt(int a_Range, int a_Salt);
-
- /// Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M
- float NextFloat(float a_Range);
-
- /// 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);
-
-protected:
- int m_Seed;
- int m_Counter;
-
- /// Counter that is used to initialize the seed, incremented for each object created
- static int m_SeedCounter;
-} ;
-
-
-
-
+
+// FastRandom.h
+
+// Declares the cFastRandom class representing a fast random number generator
+
+/*
+The cFastRandom aims to provide a very fast, although not very cryptographically secure, random generator.
+It is fast to instantiate, fast to query next, and partially multi-thread-safe.
+It is multi-thread-safe in the sense that it can be accessed from multiple threads without crashing, but it may
+yield duplicate numbers in that case.
+
+Internally, this works similar to cNoise's integral noise generation, with some predefined inputs: the seed is
+taken from a global counter and the random is calculated using a counter that is incremented on each use (hence
+the multi-thread duplication). Two alternatives exists for each function, one that takes a range parameter,
+and another that takes an additional "salt" parameter; this salt is used as an additional input to the random,
+in order to avoid multi-thread duplication. If two threads both use the class at the same time with different
+salts, the values they get will be different.
+*/
+
+
+
+
+
+#pragma once
+
+
+
+
+
+class cFastRandom
+{
+public:
+ cFastRandom(void);
+
+ /// Returns a random int in the range [0 .. a_Range - 1]; a_Range must be less than 1M
+ int NextInt(int a_Range);
+
+ /// Returns a random int in the range [0 .. a_Range - 1]; a_Range must be less than 1M; a_Salt is additional source of randomness
+ int NextInt(int a_Range, int a_Salt);
+
+ /// Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M
+ float NextFloat(float a_Range);
+
+ /// 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);
+
+protected:
+ int m_Seed;
+ int m_Counter;
+
+ /// Counter that is used to initialize the seed, incremented for each object created
+ static int m_SeedCounter;
+} ;
+
+
+
+
diff --git a/source/Generating/Caves.cpp b/source/Generating/Caves.cpp
index 2bfef8054..4221ea187 100644
--- a/source/Generating/Caves.cpp
+++ b/source/Generating/Caves.cpp
@@ -1,970 +1,970 @@
-
-// Caves.cpp
-
-// Implements the various cave structure generators:
-// - cStructGenWormNestCaves
-// - cStructGenDualRidgeCaves
-// - cStructGenMarbleCaves
-// - cStructGenNetherCaves
-
-/*
-WormNestCave generator:
-Caves are generated in "nests" - groups of tunnels generated from a single point.
-For each chunk, all the nests that could intersect it are generated.
-For each nest, first the schematic structure is generated (tunnel from ... to ..., branch, tunnel2 from ... to ...)
-Then each tunnel is randomized by inserting points in between its ends.
-Finally each tunnel is smoothed and Bresenham-3D-ed so that it is a collection of spheres with their centers next to each other.
-When the tunnels are ready, they are simply carved into the chunk, one by one.
-To optimize, each tunnel keeps track of its bounding box, so that it can be skipped for chunks that don't intersect it.
-
-MarbleCaves generator:
-For each voxel a 3D noise function is evaluated, if the value crosses a boundary, the voxel is dug out, otherwise it is kept.
-Problem with this is the amount of CPU work needed for each chunk.
-Also the overall shape of the generated holes is unsatisfactory - there are whole "sheets" of holes in the ground.
-
-DualRidgeCaves generator:
-Instead of evaluating a single noise function, two different noise functions are multiplied. This produces
-regular tunnels instead of sheets. However due to the sheer amount of CPU work needed, the noise functions need to be
-reduced in complexity in order for this generator to be useful, so the caves' shapes are "bubbly" at best.
-*/
-
-#include "Globals.h"
-#include "Caves.h"
-
-
-
-
-
-/// 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;
-
-
-
-
-
-struct cCaveDefPoint
-{
- int m_BlockX;
- int m_BlockY;
- int m_BlockZ;
- int m_Radius;
-
- cCaveDefPoint(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Radius) :
- m_BlockX(a_BlockX),
- m_BlockY(a_BlockY),
- m_BlockZ(a_BlockZ),
- m_Radius(a_Radius)
- {
- }
-} ;
-
-typedef std::vector<cCaveDefPoint> cCaveDefPoints;
-
-
-
-
-
-/// A single non-branching tunnel of a WormNestCave
-class cCaveTunnel
-{
- // The bounding box, including the radii around defpoints:
- int m_MinBlockX, m_MaxBlockX;
- int m_MinBlockY, m_MaxBlockY;
- int m_MinBlockZ, m_MaxBlockZ;
-
- /// Generates the shaping defpoints for the ravine, based on the ravine block coords and noise
- void Randomize(cNoise & a_Noise);
-
- /// Refines (adds and smooths) defpoints from a_Src into a_Dst; returns false if no refinement possible (segments too short)
- bool RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst);
-
- /// Does rounds of smoothing, two passes of RefineDefPoints(), as long as they return true
- void Smooth(void);
-
- /// Linearly interpolates the points so that the maximum distance between two neighbors is max 1 block
- void FinishLinear(void);
-
- /// Calculates the bounding box of the points present
- void CalcBoundingBox(void);
-
-public:
- cCaveDefPoints m_Points;
-
- cCaveTunnel(
- int a_BlockStartX, int a_BlockStartY, int a_BlockStartZ, int a_StartRadius,
- int a_BlockEndX, int a_BlockEndY, int a_BlockEndZ, int a_EndRadius,
- cNoise & a_Noise
- );
-
- /// Carves the tunnel 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
-} ;
-
-typedef std::vector<cCaveTunnel *> cCaveTunnels;
-
-
-
-
-
-/// A collection of connected tunnels, possibly branching.
-class cStructGenWormNestCaves::cCaveSystem
-{
-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();
-
- /// 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;
-
- void Clear(void);
-
- /// Generates a_Segment successive tunnels, with possible branches. Generates the same output for the same [x, y, z, a_Segments]
- void GenerateTunnelsFromPoint(
- int a_OriginX, int a_OriginY, int a_OriginZ,
- cNoise & a_Noise, int a_Segments
- );
-
- /// Returns a radius based on the location provided.
- int GetRadius(cNoise & a_Noise, int a_OriginX, int a_OriginY, int a_OriginZ);
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cCaveTunnel:
-
-cCaveTunnel::cCaveTunnel(
- int a_BlockStartX, int a_BlockStartY, int a_BlockStartZ, int a_StartRadius,
- int a_BlockEndX, int a_BlockEndY, int a_BlockEndZ, int a_EndRadius,
- cNoise & a_Noise
-)
-{
- m_Points.push_back(cCaveDefPoint(a_BlockStartX, a_BlockStartY, a_BlockStartZ, a_StartRadius));
- m_Points.push_back(cCaveDefPoint(a_BlockEndX, a_BlockEndY, a_BlockEndZ, a_EndRadius));
-
- if ((a_BlockStartY <= 0) && (a_BlockEndY <= 0))
- {
- // Don't bother detailing this cave, it's under the world anyway
- return;
- }
-
- Randomize(a_Noise);
- Smooth();
-
- // We know that the linear finishing won't affect the bounding box, so let's calculate it now, as we have less data:
- CalcBoundingBox();
-
- FinishLinear();
-}
-
-
-
-
-
-void cCaveTunnel::Randomize(cNoise & a_Noise)
-{
- // Repeat 4 times:
- for (int i = 0; i < 4; i++)
- {
- // For each already present point, insert a point in between it and its predecessor, shifted randomly.
- int PrevX = m_Points.front().m_BlockX;
- int PrevY = m_Points.front().m_BlockY;
- int PrevZ = m_Points.front().m_BlockZ;
- int PrevR = m_Points.front().m_Radius;
- cCaveDefPoints Pts;
- Pts.reserve(m_Points.size() * 2 + 1);
- Pts.push_back(m_Points.front());
- for (cCaveDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr)
- {
- int Random = a_Noise.IntNoise3DInt(PrevX, PrevY, PrevZ + i) / 11;
- int len = (PrevX - itr->m_BlockX) * (PrevX - itr->m_BlockX);
- len += (PrevY - itr->m_BlockY) * (PrevY - itr->m_BlockY);
- len += (PrevZ - itr->m_BlockZ) * (PrevZ - itr->m_BlockZ);
- len = 3 * (int)sqrt((double)len) / 4;
- int Rad = std::min(MAX_RADIUS, std::max(MIN_RADIUS, (PrevR + itr->m_Radius) / 2 + (Random % 3) - 1));
- Random /= 4;
- int x = (itr->m_BlockX + PrevX) / 2 + (Random % (len + 1) - len / 2);
- Random /= 256;
- int y = (itr->m_BlockY + PrevY) / 2 + (Random % (len / 2 + 1) - len / 4);
- Random /= 256;
- int z = (itr->m_BlockZ + PrevZ) / 2 + (Random % (len + 1) - len / 2);
- Pts.push_back(cCaveDefPoint(x, y, z, Rad));
- Pts.push_back(*itr);
- PrevX = itr->m_BlockX;
- PrevY = itr->m_BlockY;
- PrevZ = itr->m_BlockZ;
- PrevR = itr->m_Radius;
- }
- std::swap(Pts, m_Points);
- }
-}
-
-
-
-
-
-bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst)
-{
- // 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
- a_Dst.clear();
- a_Dst.reserve(Num * 2 + 2);
- cCaveDefPoints::const_iterator itr = a_Src.begin() + 1;
- a_Dst.push_back(a_Src.front());
- int PrevX = a_Src.front().m_BlockX;
- int PrevY = a_Src.front().m_BlockY;
- int PrevZ = a_Src.front().m_BlockZ;
- int PrevR = a_Src.front().m_Radius;
- for (int i = 0; i <= Num; ++i, ++itr)
- {
- int dx = itr->m_BlockX - PrevX;
- int dy = itr->m_BlockY - PrevY;
- int dz = itr->m_BlockZ - PrevZ;
- if (abs(dx) + abs(dz) + abs(dy) < 6)
- {
- // Too short a segment to smooth-subdivide into quarters
- PrevX = itr->m_BlockX;
- PrevY = itr->m_BlockY;
- PrevZ = itr->m_BlockZ;
- PrevR = itr->m_Radius;
- continue;
- }
- int dr = itr->m_Radius - PrevR;
- int Rad1 = std::max(PrevR + 1 * dr / 4, 1);
- int Rad2 = std::max(PrevR + 3 * dr / 4, 1);
- a_Dst.push_back(cCaveDefPoint(PrevX + 1 * dx / 4, PrevY + 1 * dy / 4, PrevZ + 1 * dz / 4, Rad1));
- a_Dst.push_back(cCaveDefPoint(PrevX + 3 * dx / 4, PrevY + 3 * dy / 4, PrevZ + 3 * dz / 4, Rad2));
- PrevX = itr->m_BlockX;
- PrevY = itr->m_BlockY;
- PrevZ = itr->m_BlockZ;
- PrevR = itr->m_Radius;
- res = true;
- }
- a_Dst.push_back(a_Src.back());
- return res && (a_Src.size() < a_Dst.size());
-}
-
-
-
-
-
-void cCaveTunnel::Smooth(void)
-{
- cCaveDefPoints Pts;
- while (true)
- {
- if (!RefineDefPoints(m_Points, Pts))
- {
- std::swap(Pts, m_Points);
- return;
- }
- if (!RefineDefPoints(Pts, m_Points))
- {
- return;
- }
- }
-}
-
-
-
-
-
-void cCaveTunnel::FinishLinear(void)
-{
- // For each segment, use Bresenham's 3D line algorithm to draw a "line" of defpoints
- cCaveDefPoints Pts;
- std::swap(Pts, m_Points);
-
- m_Points.reserve(Pts.size() * 3);
- int PrevX = Pts.front().m_BlockX;
- int PrevY = Pts.front().m_BlockY;
- int PrevZ = Pts.front().m_BlockZ;
- for (cCaveDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr)
- {
- int x1 = itr->m_BlockX;
- int y1 = itr->m_BlockY;
- int z1 = itr->m_BlockZ;
- int dx = abs(x1 - PrevX);
- int dy = abs(y1 - PrevY);
- int dz = abs(z1 - PrevZ);
- int sx = (PrevX < x1) ? 1 : -1;
- int sy = (PrevY < y1) ? 1 : -1;
- int sz = (PrevZ < z1) ? 1 : -1;
- int err = dx - dz;
- int R = itr->m_Radius;
-
- if (dx >= std::max(dy, dz)) // x dominant
- {
- int yd = dy - dx / 2;
- int zd = dz - dx / 2;
-
- while (true)
- {
- m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R));
-
- if (PrevX == x1)
- {
- break;
- }
-
- if (yd >= 0) // move along y
- {
- PrevY += sy;
- yd -= dx;
- }
-
- if (zd >= 0) // move along z
- {
- PrevZ += sz;
- zd -= dx;
- }
-
- // move along x
- PrevX += sx;
- yd += dy;
- zd += dz;
- }
- }
- else if (dy >= std::max(dx, dz)) // y dominant
- {
- int xd = dx - dy / 2;
- int zd = dz - dy / 2;
-
- while (true)
- {
- m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R));
-
- if (PrevY == y1)
- {
- break;
- }
-
- if (xd >= 0) // move along x
- {
- PrevX += sx;
- xd -= dy;
- }
-
- if (zd >= 0) // move along z
- {
- PrevZ += sz;
- zd -= dy;
- }
-
- // move along y
- PrevY += sy;
- xd += dx;
- zd += dz;
- }
- }
- else
- {
- // z dominant
- ASSERT(dz >= std::max(dx, dy));
- int xd = dx - dz / 2;
- int yd = dy - dz / 2;
-
- while (true)
- {
- m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R));
-
- if (PrevZ == z1)
- {
- break;
- }
-
- if (xd >= 0) // move along x
- {
- PrevX += sx;
- xd -= dz;
- }
-
- if (yd >= 0) // move along y
- {
- PrevY += sy;
- yd -= dz;
- }
-
- // move along z
- PrevZ += sz;
- xd += dx;
- yd += dy;
- }
- } // if (which dimension is dominant)
- } // for itr
-}
-
-
-
-
-
-void cCaveTunnel::CalcBoundingBox(void)
-{
- m_MinBlockX = m_MaxBlockX = m_Points.front().m_BlockX;
- m_MinBlockY = m_MaxBlockY = m_Points.front().m_BlockY;
- m_MinBlockZ = m_MaxBlockZ = m_Points.front().m_BlockZ;
- for (cCaveDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr)
- {
- m_MinBlockX = std::min(m_MinBlockX, itr->m_BlockX - itr->m_Radius);
- m_MaxBlockX = std::max(m_MaxBlockX, itr->m_BlockX + itr->m_Radius);
- m_MinBlockY = std::min(m_MinBlockY, itr->m_BlockY - itr->m_Radius);
- m_MaxBlockY = std::max(m_MaxBlockY, itr->m_BlockY + itr->m_Radius);
- m_MinBlockZ = std::min(m_MinBlockZ, itr->m_BlockZ - itr->m_Radius);
- m_MaxBlockZ = std::max(m_MaxBlockZ, itr->m_BlockZ + itr->m_Radius);
- } // for itr - m_Points[]
-}
-
-
-
-
-
-void cCaveTunnel::ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
- cChunkDef::HeightMap & a_HeightMap
-)
-{
- int BaseX = a_ChunkX * cChunkDef::Width;
- int BaseZ = a_ChunkZ * cChunkDef::Width;
- if (
- (BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX) ||
- (BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX)
- )
- {
- // Tunnel does not intersect the chunk at all, bail out
- return;
- }
-
- int BlockStartX = a_ChunkX * cChunkDef::Width;
- int BlockStartZ = a_ChunkZ * cChunkDef::Width;
- int BlockEndX = BlockStartX + cChunkDef::Width;
- int BlockEndZ = BlockStartZ + cChunkDef::Width;
- for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr)
- {
- if (
- (itr->m_BlockX + itr->m_Radius < BlockStartX) ||
- (itr->m_BlockX - itr->m_Radius > BlockEndX) ||
- (itr->m_BlockZ + itr->m_Radius < BlockStartZ) ||
- (itr->m_BlockZ - itr->m_Radius > BlockEndZ)
- )
- {
- // Cannot intersect, bail out early
- continue;
- }
-
- // Carve out a sphere around the xyz point, m_Radius in diameter; skip 3/7 off the top and bottom:
- int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc
- int DifY = itr->m_BlockY;
- int DifZ = itr->m_BlockZ - BlockStartZ; // substitution for faster calc
- int Bottom = std::max(itr->m_BlockY - 3 * itr->m_Radius / 7, 1);
- int Top = std::min(itr->m_BlockY + 3 * itr->m_Radius / 7, (int)(cChunkDef::Height));
- int SqRad = itr->m_Radius * itr->m_Radius;
- for (int z = 0; z < cChunkDef::Width; z++) for (int x = 0; x < cChunkDef::Width; x++)
- {
- for (int y = Bottom; y <= Top; y++)
- {
- int SqDist = (DifX - x) * (DifX - x) + (DifY - y) * (DifY - y) + (DifZ - z) * (DifZ - z);
- if (4 * SqDist <= SqRad)
- {
- switch (cChunkDef::GetBlock(a_BlockTypes, 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:
- {
- cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR);
- break;
- }
- default: break;
- }
- }
- } // for y
- } // for x, z
- } // for itr - m_Points[]
-
- /*
- #ifdef _DEBUG
- // For debugging purposes, outline the shape of the cave using glowstone, *after* carving the entire cave:
- for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr)
- {
- int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc
- int DifZ = itr->m_BlockZ - BlockStartZ; // substitution for faster calc
- if (
- (DifX >= 0) && (DifX < cChunkDef::Width) &&
- (itr->m_BlockY > 0) && (itr->m_BlockY < cChunkDef::Height) &&
- (DifZ >= 0) && (DifZ < cChunkDef::Width)
- )
- {
- cChunkDef::SetBlock(a_BlockTypes, DifX, itr->m_BlockY, DifZ, E_BLOCK_GLOWSTONE);
- }
- } // for itr - m_Points[]
- #endif // _DEBUG
- //*/
-}
-
-
-
-
-
-#ifdef _DEBUG
-AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const
-{
- 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);
- Prefix = 'L';
- }
- SVG.append("\"/>\n");
- return SVG;
-}
-#endif // _DEBUG
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// 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),
- m_Size(a_Size)
-{
- int Num = 1 + a_Noise.IntNoise2DInt(a_BlockX, a_BlockZ) % 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;
-
- // Generate three branches from the origin point:
- // The tunnels generated depend on X, Y, Z and Branches,
- // for the same set of numbers it generates the same offsets!
- // That's why we add a +1 to X in the third line
- GenerateTunnelsFromPoint(OriginX, OriginY, OriginZ, a_Noise, 3);
- GenerateTunnelsFromPoint(OriginX, OriginY, OriginZ, a_Noise, 2);
- GenerateTunnelsFromPoint(OriginX + 1, OriginY, OriginZ, a_Noise, 3);
- }
-}
-
-
-
-
-
-cStructGenWormNestCaves::cCaveSystem::~cCaveSystem()
-{
- Clear();
-}
-
-
-
-
-
-
-void cStructGenWormNestCaves::cCaveSystem::ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
- cChunkDef::HeightMap & a_HeightMap
-)
-{
- 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));
- } // 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
-
-
-
-
-
-void cStructGenWormNestCaves::cCaveSystem::Clear(void)
-{
- for (cCaveTunnels::const_iterator itr = m_Tunnels.begin(), end = m_Tunnels.end(); itr != end; ++itr)
- {
- delete *itr;
- }
- m_Tunnels.clear();
-}
-
-
-
-
-
-void cStructGenWormNestCaves::cCaveSystem::GenerateTunnelsFromPoint(
- int a_OriginX, int a_OriginY, int a_OriginZ,
- cNoise & a_Noise, int a_NumSegments
-)
-{
- int DoubleSize = m_Size * 2;
- int Radius = GetRadius(a_Noise, a_OriginX + a_OriginY, a_OriginY + a_OriginZ, a_OriginZ + a_OriginX);
- for (int i = a_NumSegments - 1; i >= 0; --i)
- {
- int EndX = a_OriginX + (((a_Noise.IntNoise3DInt(a_OriginX, a_OriginY, a_OriginZ + 11 * a_NumSegments) / 7) % DoubleSize) - m_Size) / 2;
- int EndY = a_OriginY + (((a_Noise.IntNoise3DInt(a_OriginY, 13 * a_NumSegments, a_OriginZ + a_OriginX) / 7) % DoubleSize) - m_Size) / 4;
- int EndZ = a_OriginZ + (((a_Noise.IntNoise3DInt(a_OriginZ + 17 * a_NumSegments, a_OriginX, a_OriginY) / 7) % DoubleSize) - m_Size) / 2;
- int EndR = GetRadius(a_Noise, a_OriginX + 7 * i, a_OriginY + 11 * i, a_OriginZ + a_OriginX);
- m_Tunnels.push_back(new cCaveTunnel(a_OriginX, a_OriginY, a_OriginZ, Radius, EndX, EndY, EndZ, EndR, a_Noise));
- GenerateTunnelsFromPoint(EndX, EndY, EndZ, a_Noise, i);
- a_OriginX = EndX;
- a_OriginY = EndY;
- a_OriginZ = EndZ;
- Radius = EndR;
- } // for i - a_NumSegments
-}
-
-
-
-
-
-int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_OriginX, int a_OriginY, int a_OriginZ)
-{
- // Instead of a flat distribution noise function, we need to shape it, so that most caves are smallish and only a few select are large
- int rnd = a_Noise.IntNoise3DInt(a_OriginX, a_OriginY, a_OriginZ) / 11;
- /*
- // Not good enough:
- // The algorithm of choice: emulate gauss-distribution noise by adding 3 flat noises, then fold it in half using absolute value.
- // To save on processing, use one random value and extract 3 bytes to be separately added as the gaussian noise
- int sum = (rnd & 0xff) + ((rnd >> 8) & 0xff) + ((rnd >> 16) & 0xff);
- // sum is now a gaussian-distribution noise within [0 .. 767], with center at 384.
- // We want mapping 384 -> 3, 0 -> 19, 768 -> 19, so divide by 24 to get [0 .. 31] with center at 16, then use abs() to fold around the center
- int res = 3 + abs((sum / 24) - 16);
- */
-
- // Algorithm of choice: random value in the range of zero to random value - heavily towards zero
- int res = MIN_RADIUS + (rnd >> 8) % ((rnd % (MAX_RADIUS - MIN_RADIUS)) + 1);
- return res;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// 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::GenStructures(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)
-{
- 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
- //*/
-}
-
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cStructGenMarbleCaves:
-
-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;
-
- oct1 = oct1 * oct1 * oct1;
- if (oct1 < 0.f) oct1 = PI_2;
- if (oct1 > PI_2) oct1 = PI_2;
-
- return oct1;
-}
-
-
-
-
-
-void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc)
-{
- cNoise Noise(m_Seed);
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z);
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x);
-
- int Top = a_ChunkDesc.GetHeight(x, z);
- for (int y = 1; y < Top; ++y )
- {
- if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_STONE)
- {
- continue;
- }
-
- const float yy = (float)y;
- const float WaveNoise = 1;
- if (cosf(GetMarbleNoise(xx, yy * 0.5f, zz, Noise)) * fabs(cosf(yy * 0.2f + WaveNoise * 2) * 0.75f + WaveNoise) > 0.0005f)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
- }
- } // for y
- } // for x
- } // for z
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cStructGenDualRidgeCaves:
-
-void cStructGenDualRidgeCaves::GenStructures(cChunkDesc & a_ChunkDesc)
-{
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10;
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10;
-
- int Top = a_ChunkDesc.GetHeight(x, z);
- for (int y = 1; y <= Top; ++y)
- {
- const float yy = (float)y / 10;
- const float WaveNoise = 1;
- float n1 = m_Noise1.CubicNoise3D(xx, yy, zz);
- float n2 = m_Noise2.CubicNoise3D(xx, yy, zz);
- float n3 = m_Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
- float n4 = m_Noise2.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
- if ((abs(n1 + n3) * abs(n2 + n4)) > m_Threshold)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
- }
- } // for y
- } // for x
- } // for z
-}
-
-
-
-
+
+// Caves.cpp
+
+// Implements the various cave structure generators:
+// - cStructGenWormNestCaves
+// - cStructGenDualRidgeCaves
+// - cStructGenMarbleCaves
+// - cStructGenNetherCaves
+
+/*
+WormNestCave generator:
+Caves are generated in "nests" - groups of tunnels generated from a single point.
+For each chunk, all the nests that could intersect it are generated.
+For each nest, first the schematic structure is generated (tunnel from ... to ..., branch, tunnel2 from ... to ...)
+Then each tunnel is randomized by inserting points in between its ends.
+Finally each tunnel is smoothed and Bresenham-3D-ed so that it is a collection of spheres with their centers next to each other.
+When the tunnels are ready, they are simply carved into the chunk, one by one.
+To optimize, each tunnel keeps track of its bounding box, so that it can be skipped for chunks that don't intersect it.
+
+MarbleCaves generator:
+For each voxel a 3D noise function is evaluated, if the value crosses a boundary, the voxel is dug out, otherwise it is kept.
+Problem with this is the amount of CPU work needed for each chunk.
+Also the overall shape of the generated holes is unsatisfactory - there are whole "sheets" of holes in the ground.
+
+DualRidgeCaves generator:
+Instead of evaluating a single noise function, two different noise functions are multiplied. This produces
+regular tunnels instead of sheets. However due to the sheer amount of CPU work needed, the noise functions need to be
+reduced in complexity in order for this generator to be useful, so the caves' shapes are "bubbly" at best.
+*/
+
+#include "Globals.h"
+#include "Caves.h"
+
+
+
+
+
+/// 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;
+
+
+
+
+
+struct cCaveDefPoint
+{
+ int m_BlockX;
+ int m_BlockY;
+ int m_BlockZ;
+ int m_Radius;
+
+ cCaveDefPoint(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Radius) :
+ m_BlockX(a_BlockX),
+ m_BlockY(a_BlockY),
+ m_BlockZ(a_BlockZ),
+ m_Radius(a_Radius)
+ {
+ }
+} ;
+
+typedef std::vector<cCaveDefPoint> cCaveDefPoints;
+
+
+
+
+
+/// A single non-branching tunnel of a WormNestCave
+class cCaveTunnel
+{
+ // The bounding box, including the radii around defpoints:
+ int m_MinBlockX, m_MaxBlockX;
+ int m_MinBlockY, m_MaxBlockY;
+ int m_MinBlockZ, m_MaxBlockZ;
+
+ /// Generates the shaping defpoints for the ravine, based on the ravine block coords and noise
+ void Randomize(cNoise & a_Noise);
+
+ /// Refines (adds and smooths) defpoints from a_Src into a_Dst; returns false if no refinement possible (segments too short)
+ bool RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst);
+
+ /// Does rounds of smoothing, two passes of RefineDefPoints(), as long as they return true
+ void Smooth(void);
+
+ /// Linearly interpolates the points so that the maximum distance between two neighbors is max 1 block
+ void FinishLinear(void);
+
+ /// Calculates the bounding box of the points present
+ void CalcBoundingBox(void);
+
+public:
+ cCaveDefPoints m_Points;
+
+ cCaveTunnel(
+ int a_BlockStartX, int a_BlockStartY, int a_BlockStartZ, int a_StartRadius,
+ int a_BlockEndX, int a_BlockEndY, int a_BlockEndZ, int a_EndRadius,
+ cNoise & a_Noise
+ );
+
+ /// Carves the tunnel 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
+} ;
+
+typedef std::vector<cCaveTunnel *> cCaveTunnels;
+
+
+
+
+
+/// A collection of connected tunnels, possibly branching.
+class cStructGenWormNestCaves::cCaveSystem
+{
+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();
+
+ /// 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;
+
+ void Clear(void);
+
+ /// Generates a_Segment successive tunnels, with possible branches. Generates the same output for the same [x, y, z, a_Segments]
+ void GenerateTunnelsFromPoint(
+ int a_OriginX, int a_OriginY, int a_OriginZ,
+ cNoise & a_Noise, int a_Segments
+ );
+
+ /// Returns a radius based on the location provided.
+ int GetRadius(cNoise & a_Noise, int a_OriginX, int a_OriginY, int a_OriginZ);
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cCaveTunnel:
+
+cCaveTunnel::cCaveTunnel(
+ int a_BlockStartX, int a_BlockStartY, int a_BlockStartZ, int a_StartRadius,
+ int a_BlockEndX, int a_BlockEndY, int a_BlockEndZ, int a_EndRadius,
+ cNoise & a_Noise
+)
+{
+ m_Points.push_back(cCaveDefPoint(a_BlockStartX, a_BlockStartY, a_BlockStartZ, a_StartRadius));
+ m_Points.push_back(cCaveDefPoint(a_BlockEndX, a_BlockEndY, a_BlockEndZ, a_EndRadius));
+
+ if ((a_BlockStartY <= 0) && (a_BlockEndY <= 0))
+ {
+ // Don't bother detailing this cave, it's under the world anyway
+ return;
+ }
+
+ Randomize(a_Noise);
+ Smooth();
+
+ // We know that the linear finishing won't affect the bounding box, so let's calculate it now, as we have less data:
+ CalcBoundingBox();
+
+ FinishLinear();
+}
+
+
+
+
+
+void cCaveTunnel::Randomize(cNoise & a_Noise)
+{
+ // Repeat 4 times:
+ for (int i = 0; i < 4; i++)
+ {
+ // For each already present point, insert a point in between it and its predecessor, shifted randomly.
+ int PrevX = m_Points.front().m_BlockX;
+ int PrevY = m_Points.front().m_BlockY;
+ int PrevZ = m_Points.front().m_BlockZ;
+ int PrevR = m_Points.front().m_Radius;
+ cCaveDefPoints Pts;
+ Pts.reserve(m_Points.size() * 2 + 1);
+ Pts.push_back(m_Points.front());
+ for (cCaveDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr)
+ {
+ int Random = a_Noise.IntNoise3DInt(PrevX, PrevY, PrevZ + i) / 11;
+ int len = (PrevX - itr->m_BlockX) * (PrevX - itr->m_BlockX);
+ len += (PrevY - itr->m_BlockY) * (PrevY - itr->m_BlockY);
+ len += (PrevZ - itr->m_BlockZ) * (PrevZ - itr->m_BlockZ);
+ len = 3 * (int)sqrt((double)len) / 4;
+ int Rad = std::min(MAX_RADIUS, std::max(MIN_RADIUS, (PrevR + itr->m_Radius) / 2 + (Random % 3) - 1));
+ Random /= 4;
+ int x = (itr->m_BlockX + PrevX) / 2 + (Random % (len + 1) - len / 2);
+ Random /= 256;
+ int y = (itr->m_BlockY + PrevY) / 2 + (Random % (len / 2 + 1) - len / 4);
+ Random /= 256;
+ int z = (itr->m_BlockZ + PrevZ) / 2 + (Random % (len + 1) - len / 2);
+ Pts.push_back(cCaveDefPoint(x, y, z, Rad));
+ Pts.push_back(*itr);
+ PrevX = itr->m_BlockX;
+ PrevY = itr->m_BlockY;
+ PrevZ = itr->m_BlockZ;
+ PrevR = itr->m_Radius;
+ }
+ std::swap(Pts, m_Points);
+ }
+}
+
+
+
+
+
+bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst)
+{
+ // 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
+ a_Dst.clear();
+ a_Dst.reserve(Num * 2 + 2);
+ cCaveDefPoints::const_iterator itr = a_Src.begin() + 1;
+ a_Dst.push_back(a_Src.front());
+ int PrevX = a_Src.front().m_BlockX;
+ int PrevY = a_Src.front().m_BlockY;
+ int PrevZ = a_Src.front().m_BlockZ;
+ int PrevR = a_Src.front().m_Radius;
+ for (int i = 0; i <= Num; ++i, ++itr)
+ {
+ int dx = itr->m_BlockX - PrevX;
+ int dy = itr->m_BlockY - PrevY;
+ int dz = itr->m_BlockZ - PrevZ;
+ if (abs(dx) + abs(dz) + abs(dy) < 6)
+ {
+ // Too short a segment to smooth-subdivide into quarters
+ PrevX = itr->m_BlockX;
+ PrevY = itr->m_BlockY;
+ PrevZ = itr->m_BlockZ;
+ PrevR = itr->m_Radius;
+ continue;
+ }
+ int dr = itr->m_Radius - PrevR;
+ int Rad1 = std::max(PrevR + 1 * dr / 4, 1);
+ int Rad2 = std::max(PrevR + 3 * dr / 4, 1);
+ a_Dst.push_back(cCaveDefPoint(PrevX + 1 * dx / 4, PrevY + 1 * dy / 4, PrevZ + 1 * dz / 4, Rad1));
+ a_Dst.push_back(cCaveDefPoint(PrevX + 3 * dx / 4, PrevY + 3 * dy / 4, PrevZ + 3 * dz / 4, Rad2));
+ PrevX = itr->m_BlockX;
+ PrevY = itr->m_BlockY;
+ PrevZ = itr->m_BlockZ;
+ PrevR = itr->m_Radius;
+ res = true;
+ }
+ a_Dst.push_back(a_Src.back());
+ return res && (a_Src.size() < a_Dst.size());
+}
+
+
+
+
+
+void cCaveTunnel::Smooth(void)
+{
+ cCaveDefPoints Pts;
+ while (true)
+ {
+ if (!RefineDefPoints(m_Points, Pts))
+ {
+ std::swap(Pts, m_Points);
+ return;
+ }
+ if (!RefineDefPoints(Pts, m_Points))
+ {
+ return;
+ }
+ }
+}
+
+
+
+
+
+void cCaveTunnel::FinishLinear(void)
+{
+ // For each segment, use Bresenham's 3D line algorithm to draw a "line" of defpoints
+ cCaveDefPoints Pts;
+ std::swap(Pts, m_Points);
+
+ m_Points.reserve(Pts.size() * 3);
+ int PrevX = Pts.front().m_BlockX;
+ int PrevY = Pts.front().m_BlockY;
+ int PrevZ = Pts.front().m_BlockZ;
+ for (cCaveDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr)
+ {
+ int x1 = itr->m_BlockX;
+ int y1 = itr->m_BlockY;
+ int z1 = itr->m_BlockZ;
+ int dx = abs(x1 - PrevX);
+ int dy = abs(y1 - PrevY);
+ int dz = abs(z1 - PrevZ);
+ int sx = (PrevX < x1) ? 1 : -1;
+ int sy = (PrevY < y1) ? 1 : -1;
+ int sz = (PrevZ < z1) ? 1 : -1;
+ int err = dx - dz;
+ int R = itr->m_Radius;
+
+ if (dx >= std::max(dy, dz)) // x dominant
+ {
+ int yd = dy - dx / 2;
+ int zd = dz - dx / 2;
+
+ while (true)
+ {
+ m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R));
+
+ if (PrevX == x1)
+ {
+ break;
+ }
+
+ if (yd >= 0) // move along y
+ {
+ PrevY += sy;
+ yd -= dx;
+ }
+
+ if (zd >= 0) // move along z
+ {
+ PrevZ += sz;
+ zd -= dx;
+ }
+
+ // move along x
+ PrevX += sx;
+ yd += dy;
+ zd += dz;
+ }
+ }
+ else if (dy >= std::max(dx, dz)) // y dominant
+ {
+ int xd = dx - dy / 2;
+ int zd = dz - dy / 2;
+
+ while (true)
+ {
+ m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R));
+
+ if (PrevY == y1)
+ {
+ break;
+ }
+
+ if (xd >= 0) // move along x
+ {
+ PrevX += sx;
+ xd -= dy;
+ }
+
+ if (zd >= 0) // move along z
+ {
+ PrevZ += sz;
+ zd -= dy;
+ }
+
+ // move along y
+ PrevY += sy;
+ xd += dx;
+ zd += dz;
+ }
+ }
+ else
+ {
+ // z dominant
+ ASSERT(dz >= std::max(dx, dy));
+ int xd = dx - dz / 2;
+ int yd = dy - dz / 2;
+
+ while (true)
+ {
+ m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R));
+
+ if (PrevZ == z1)
+ {
+ break;
+ }
+
+ if (xd >= 0) // move along x
+ {
+ PrevX += sx;
+ xd -= dz;
+ }
+
+ if (yd >= 0) // move along y
+ {
+ PrevY += sy;
+ yd -= dz;
+ }
+
+ // move along z
+ PrevZ += sz;
+ xd += dx;
+ yd += dy;
+ }
+ } // if (which dimension is dominant)
+ } // for itr
+}
+
+
+
+
+
+void cCaveTunnel::CalcBoundingBox(void)
+{
+ m_MinBlockX = m_MaxBlockX = m_Points.front().m_BlockX;
+ m_MinBlockY = m_MaxBlockY = m_Points.front().m_BlockY;
+ m_MinBlockZ = m_MaxBlockZ = m_Points.front().m_BlockZ;
+ for (cCaveDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr)
+ {
+ m_MinBlockX = std::min(m_MinBlockX, itr->m_BlockX - itr->m_Radius);
+ m_MaxBlockX = std::max(m_MaxBlockX, itr->m_BlockX + itr->m_Radius);
+ m_MinBlockY = std::min(m_MinBlockY, itr->m_BlockY - itr->m_Radius);
+ m_MaxBlockY = std::max(m_MaxBlockY, itr->m_BlockY + itr->m_Radius);
+ m_MinBlockZ = std::min(m_MinBlockZ, itr->m_BlockZ - itr->m_Radius);
+ m_MaxBlockZ = std::max(m_MaxBlockZ, itr->m_BlockZ + itr->m_Radius);
+ } // for itr - m_Points[]
+}
+
+
+
+
+
+void cCaveTunnel::ProcessChunk(
+ int a_ChunkX, int a_ChunkZ,
+ cChunkDef::BlockTypes & a_BlockTypes,
+ cChunkDef::HeightMap & a_HeightMap
+)
+{
+ int BaseX = a_ChunkX * cChunkDef::Width;
+ int BaseZ = a_ChunkZ * cChunkDef::Width;
+ if (
+ (BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX) ||
+ (BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX)
+ )
+ {
+ // Tunnel does not intersect the chunk at all, bail out
+ return;
+ }
+
+ int BlockStartX = a_ChunkX * cChunkDef::Width;
+ int BlockStartZ = a_ChunkZ * cChunkDef::Width;
+ int BlockEndX = BlockStartX + cChunkDef::Width;
+ int BlockEndZ = BlockStartZ + cChunkDef::Width;
+ for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr)
+ {
+ if (
+ (itr->m_BlockX + itr->m_Radius < BlockStartX) ||
+ (itr->m_BlockX - itr->m_Radius > BlockEndX) ||
+ (itr->m_BlockZ + itr->m_Radius < BlockStartZ) ||
+ (itr->m_BlockZ - itr->m_Radius > BlockEndZ)
+ )
+ {
+ // Cannot intersect, bail out early
+ continue;
+ }
+
+ // Carve out a sphere around the xyz point, m_Radius in diameter; skip 3/7 off the top and bottom:
+ int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc
+ int DifY = itr->m_BlockY;
+ int DifZ = itr->m_BlockZ - BlockStartZ; // substitution for faster calc
+ int Bottom = std::max(itr->m_BlockY - 3 * itr->m_Radius / 7, 1);
+ int Top = std::min(itr->m_BlockY + 3 * itr->m_Radius / 7, (int)(cChunkDef::Height));
+ int SqRad = itr->m_Radius * itr->m_Radius;
+ for (int z = 0; z < cChunkDef::Width; z++) for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ for (int y = Bottom; y <= Top; y++)
+ {
+ int SqDist = (DifX - x) * (DifX - x) + (DifY - y) * (DifY - y) + (DifZ - z) * (DifZ - z);
+ if (4 * SqDist <= SqRad)
+ {
+ switch (cChunkDef::GetBlock(a_BlockTypes, 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:
+ {
+ cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR);
+ break;
+ }
+ default: break;
+ }
+ }
+ } // for y
+ } // for x, z
+ } // for itr - m_Points[]
+
+ /*
+ #ifdef _DEBUG
+ // For debugging purposes, outline the shape of the cave using glowstone, *after* carving the entire cave:
+ for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr)
+ {
+ int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc
+ int DifZ = itr->m_BlockZ - BlockStartZ; // substitution for faster calc
+ if (
+ (DifX >= 0) && (DifX < cChunkDef::Width) &&
+ (itr->m_BlockY > 0) && (itr->m_BlockY < cChunkDef::Height) &&
+ (DifZ >= 0) && (DifZ < cChunkDef::Width)
+ )
+ {
+ cChunkDef::SetBlock(a_BlockTypes, DifX, itr->m_BlockY, DifZ, E_BLOCK_GLOWSTONE);
+ }
+ } // for itr - m_Points[]
+ #endif // _DEBUG
+ //*/
+}
+
+
+
+
+
+#ifdef _DEBUG
+AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const
+{
+ 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);
+ Prefix = 'L';
+ }
+ SVG.append("\"/>\n");
+ return SVG;
+}
+#endif // _DEBUG
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// 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),
+ m_Size(a_Size)
+{
+ int Num = 1 + a_Noise.IntNoise2DInt(a_BlockX, a_BlockZ) % 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;
+
+ // Generate three branches from the origin point:
+ // The tunnels generated depend on X, Y, Z and Branches,
+ // for the same set of numbers it generates the same offsets!
+ // That's why we add a +1 to X in the third line
+ GenerateTunnelsFromPoint(OriginX, OriginY, OriginZ, a_Noise, 3);
+ GenerateTunnelsFromPoint(OriginX, OriginY, OriginZ, a_Noise, 2);
+ GenerateTunnelsFromPoint(OriginX + 1, OriginY, OriginZ, a_Noise, 3);
+ }
+}
+
+
+
+
+
+cStructGenWormNestCaves::cCaveSystem::~cCaveSystem()
+{
+ Clear();
+}
+
+
+
+
+
+
+void cStructGenWormNestCaves::cCaveSystem::ProcessChunk(
+ int a_ChunkX, int a_ChunkZ,
+ cChunkDef::BlockTypes & a_BlockTypes,
+ cChunkDef::HeightMap & a_HeightMap
+)
+{
+ 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));
+ } // 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
+
+
+
+
+
+void cStructGenWormNestCaves::cCaveSystem::Clear(void)
+{
+ for (cCaveTunnels::const_iterator itr = m_Tunnels.begin(), end = m_Tunnels.end(); itr != end; ++itr)
+ {
+ delete *itr;
+ }
+ m_Tunnels.clear();
+}
+
+
+
+
+
+void cStructGenWormNestCaves::cCaveSystem::GenerateTunnelsFromPoint(
+ int a_OriginX, int a_OriginY, int a_OriginZ,
+ cNoise & a_Noise, int a_NumSegments
+)
+{
+ int DoubleSize = m_Size * 2;
+ int Radius = GetRadius(a_Noise, a_OriginX + a_OriginY, a_OriginY + a_OriginZ, a_OriginZ + a_OriginX);
+ for (int i = a_NumSegments - 1; i >= 0; --i)
+ {
+ int EndX = a_OriginX + (((a_Noise.IntNoise3DInt(a_OriginX, a_OriginY, a_OriginZ + 11 * a_NumSegments) / 7) % DoubleSize) - m_Size) / 2;
+ int EndY = a_OriginY + (((a_Noise.IntNoise3DInt(a_OriginY, 13 * a_NumSegments, a_OriginZ + a_OriginX) / 7) % DoubleSize) - m_Size) / 4;
+ int EndZ = a_OriginZ + (((a_Noise.IntNoise3DInt(a_OriginZ + 17 * a_NumSegments, a_OriginX, a_OriginY) / 7) % DoubleSize) - m_Size) / 2;
+ int EndR = GetRadius(a_Noise, a_OriginX + 7 * i, a_OriginY + 11 * i, a_OriginZ + a_OriginX);
+ m_Tunnels.push_back(new cCaveTunnel(a_OriginX, a_OriginY, a_OriginZ, Radius, EndX, EndY, EndZ, EndR, a_Noise));
+ GenerateTunnelsFromPoint(EndX, EndY, EndZ, a_Noise, i);
+ a_OriginX = EndX;
+ a_OriginY = EndY;
+ a_OriginZ = EndZ;
+ Radius = EndR;
+ } // for i - a_NumSegments
+}
+
+
+
+
+
+int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_OriginX, int a_OriginY, int a_OriginZ)
+{
+ // Instead of a flat distribution noise function, we need to shape it, so that most caves are smallish and only a few select are large
+ int rnd = a_Noise.IntNoise3DInt(a_OriginX, a_OriginY, a_OriginZ) / 11;
+ /*
+ // Not good enough:
+ // The algorithm of choice: emulate gauss-distribution noise by adding 3 flat noises, then fold it in half using absolute value.
+ // To save on processing, use one random value and extract 3 bytes to be separately added as the gaussian noise
+ int sum = (rnd & 0xff) + ((rnd >> 8) & 0xff) + ((rnd >> 16) & 0xff);
+ // sum is now a gaussian-distribution noise within [0 .. 767], with center at 384.
+ // We want mapping 384 -> 3, 0 -> 19, 768 -> 19, so divide by 24 to get [0 .. 31] with center at 16, then use abs() to fold around the center
+ int res = 3 + abs((sum / 24) - 16);
+ */
+
+ // Algorithm of choice: random value in the range of zero to random value - heavily towards zero
+ int res = MIN_RADIUS + (rnd >> 8) % ((rnd % (MAX_RADIUS - MIN_RADIUS)) + 1);
+ return res;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// 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::GenStructures(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)
+{
+ 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
+ //*/
+}
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cStructGenMarbleCaves:
+
+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;
+
+ oct1 = oct1 * oct1 * oct1;
+ if (oct1 < 0.f) oct1 = PI_2;
+ if (oct1 > PI_2) oct1 = PI_2;
+
+ return oct1;
+}
+
+
+
+
+
+void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc)
+{
+ cNoise Noise(m_Seed);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z);
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x);
+
+ int Top = a_ChunkDesc.GetHeight(x, z);
+ for (int y = 1; y < Top; ++y )
+ {
+ if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_STONE)
+ {
+ continue;
+ }
+
+ const float yy = (float)y;
+ const float WaveNoise = 1;
+ if (cosf(GetMarbleNoise(xx, yy * 0.5f, zz, Noise)) * fabs(cosf(yy * 0.2f + WaveNoise * 2) * 0.75f + WaveNoise) > 0.0005f)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cStructGenDualRidgeCaves:
+
+void cStructGenDualRidgeCaves::GenStructures(cChunkDesc & a_ChunkDesc)
+{
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10;
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10;
+
+ int Top = a_ChunkDesc.GetHeight(x, z);
+ for (int y = 1; y <= Top; ++y)
+ {
+ const float yy = (float)y / 10;
+ const float WaveNoise = 1;
+ float n1 = m_Noise1.CubicNoise3D(xx, yy, zz);
+ float n2 = m_Noise2.CubicNoise3D(xx, yy, zz);
+ float n3 = m_Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
+ float n4 = m_Noise2.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
+ if ((abs(n1 + n3) * abs(n2 + n4)) > m_Threshold)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
diff --git a/source/Generating/Caves.h b/source/Generating/Caves.h
index bb69550a8..70cf6fe8c 100644
--- a/source/Generating/Caves.h
+++ b/source/Generating/Caves.h
@@ -1,102 +1,102 @@
-
-// Caves.h
-
-// Interfaces to the various cave structure generators:
-// - cStructGenWormNestCaves
-// - cStructGenMarbleCaves
-// - cStructGenNetherCaves
-
-
-
-
-
-#pragma once
-
-#include "ComposableGenerator.h"
-#include "../Noise.h"
-
-
-
-
-
-class cStructGenMarbleCaves :
- public cStructureGen
-{
-public:
- cStructGenMarbleCaves(int a_Seed) : m_Seed(a_Seed) {}
-
-protected:
-
- int m_Seed;
-
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
-} ;
-
-
-
-
-
-class cStructGenDualRidgeCaves :
- public cStructureGen
-{
-public:
- cStructGenDualRidgeCaves(int a_Seed, float a_Threshold) :
- m_Noise1(a_Seed),
- m_Noise2(2 * a_Seed + 19999),
- m_Seed(a_Seed),
- m_Threshold(a_Threshold)
- {
- }
-
-protected:
- cNoise m_Noise1;
- cNoise m_Noise2;
- int m_Seed;
- float m_Threshold;
-
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
-} ;
-
-
-
-
-
-class cStructGenWormNestCaves :
- public cStructureGen
-{
-public:
- cStructGenWormNestCaves(int a_Seed, int a_Size = 64, int a_Grid = 96, int a_MaxOffset = 128) :
- m_Noise(a_Seed),
- m_Size(a_Size),
- m_Grid(a_Grid),
- m_MaxOffset(a_MaxOffset)
- {
- }
-
- ~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 GenStructures(cChunkDesc & a_ChunkDesc) override;
-} ;
-
-
-
-
+
+// Caves.h
+
+// Interfaces to the various cave structure generators:
+// - cStructGenWormNestCaves
+// - cStructGenMarbleCaves
+// - cStructGenNetherCaves
+
+
+
+
+
+#pragma once
+
+#include "ComposableGenerator.h"
+#include "../Noise.h"
+
+
+
+
+
+class cStructGenMarbleCaves :
+ public cStructureGen
+{
+public:
+ cStructGenMarbleCaves(int a_Seed) : m_Seed(a_Seed) {}
+
+protected:
+
+ int m_Seed;
+
+ // cStructureGen override:
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
+
+class cStructGenDualRidgeCaves :
+ public cStructureGen
+{
+public:
+ cStructGenDualRidgeCaves(int a_Seed, float a_Threshold) :
+ m_Noise1(a_Seed),
+ m_Noise2(2 * a_Seed + 19999),
+ m_Seed(a_Seed),
+ m_Threshold(a_Threshold)
+ {
+ }
+
+protected:
+ cNoise m_Noise1;
+ cNoise m_Noise2;
+ int m_Seed;
+ float m_Threshold;
+
+ // cStructureGen override:
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
+
+class cStructGenWormNestCaves :
+ public cStructureGen
+{
+public:
+ cStructGenWormNestCaves(int a_Seed, int a_Size = 64, int a_Grid = 96, int a_MaxOffset = 128) :
+ m_Noise(a_Seed),
+ m_Size(a_Size),
+ m_Grid(a_Grid),
+ m_MaxOffset(a_MaxOffset)
+ {
+ }
+
+ ~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 GenStructures(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp
index 5c59055f7..dc6c74a3c 100644
--- a/source/Generating/ChunkDesc.cpp
+++ b/source/Generating/ChunkDesc.cpp
@@ -1,578 +1,578 @@
-
-// ChunkDesc.cpp
-
-// Implements the cChunkDesc class representing the chunk description used while generating a chunk. This class is also exported to Lua for HOOK_CHUNK_GENERATING.
-
-#include "Globals.h"
-#include "ChunkDesc.h"
-#include "../BlockArea.h"
-#include "../Cuboid.h"
-#include "../Noise.h"
-
-
-
-
-
-cChunkDesc::cChunkDesc(int a_ChunkX, int a_ChunkZ) :
- m_ChunkX(a_ChunkX),
- m_ChunkZ(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);
- /*
- memset(m_BlockTypes, 0, sizeof(cChunkDef::BlockTypes));
- memset(m_BlockMeta, 0, sizeof(cChunkDef::BlockNibbles));
- */
- memset(m_BiomeMap, 0, sizeof(cChunkDef::BiomeMap));
- memset(m_HeightMap, 0, sizeof(cChunkDef::HeightMap));
-}
-
-
-
-
-
-cChunkDesc::~cChunkDesc()
-{
- // Nothing needed yet
-}
-
-
-
-
-
-void cChunkDesc::SetChunkCoords(int a_ChunkX, int a_ChunkZ)
-{
- m_ChunkX = a_ChunkX;
- m_ChunkZ = a_ChunkZ;
-}
-
-
-
-
-
-void cChunkDesc::FillBlocks(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- m_BlockArea.Fill(cBlockArea::baTypes | cBlockArea::baMetas, a_BlockType, a_BlockMeta);
-}
-
-
-
-
-
-void cChunkDesc::SetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- m_BlockArea.SetRelBlockTypeMeta(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta);
-}
-
-
-
-
-
-void cChunkDesc::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
-{
- m_BlockArea.GetRelBlockTypeMeta(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta);
-}
-
-
-
-
-
-void cChunkDesc::SetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
-{
- cChunkDef::SetBlock(m_BlockArea.GetBlockTypes(), a_RelX, a_RelY, a_RelZ, a_BlockType);
-}
-
-
-
-
-
-BLOCKTYPE cChunkDesc::GetBlockType(int a_RelX, int a_RelY, int a_RelZ)
-{
- return cChunkDef::GetBlock(m_BlockArea.GetBlockTypes(), a_RelX, a_RelY, a_RelZ);
-}
-
-
-
-
-
-NIBBLETYPE cChunkDesc::GetBlockMeta(int a_RelX, int a_RelY, int a_RelZ)
-{
- return m_BlockArea.GetRelBlockMeta(a_RelX, a_RelY, a_RelZ);
-}
-
-
-
-
-
-void cChunkDesc::SetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta)
-{
- m_BlockArea.SetRelBlockMeta(a_RelX, a_RelY, a_RelZ, a_BlockMeta);
-}
-
-
-
-
-
-void cChunkDesc::SetBiome(int a_RelX, int a_RelZ, int a_BiomeID)
-{
- cChunkDef::SetBiome(m_BiomeMap, a_RelX, a_RelZ, (EMCSBiome)a_BiomeID);
-}
-
-
-
-
-EMCSBiome cChunkDesc::GetBiome(int a_RelX, int a_RelZ)
-{
- return cChunkDef::GetBiome(m_BiomeMap, a_RelX, a_RelZ);
-}
-
-
-
-
-
-void cChunkDesc::SetHeight(int a_RelX, int a_RelZ, int a_Height)
-{
- cChunkDef::SetHeight(m_HeightMap, a_RelX, a_RelZ, a_Height);
-}
-
-
-
-
-
-int cChunkDesc::GetHeight(int a_RelX, int a_RelZ)
-{
- return cChunkDef::GetHeight(m_HeightMap, a_RelX, a_RelZ);
-}
-
-
-
-
-
-void cChunkDesc::SetUseDefaultBiomes(bool a_bUseDefaultBiomes)
-{
- m_bUseDefaultBiomes = a_bUseDefaultBiomes;
-}
-
-
-
-
-
-bool cChunkDesc::IsUsingDefaultBiomes(void) const
-{
- return m_bUseDefaultBiomes;
-}
-
-
-
-
-
-void cChunkDesc::SetUseDefaultHeight(bool a_bUseDefaultHeight)
-{
- m_bUseDefaultHeight = a_bUseDefaultHeight;
-}
-
-
-
-
-
-bool cChunkDesc::IsUsingDefaultHeight(void) const
-{
- return m_bUseDefaultHeight;
-}
-
-
-
-
-
-void cChunkDesc::SetUseDefaultComposition(bool a_bUseDefaultComposition)
-{
- m_bUseDefaultComposition = a_bUseDefaultComposition;
-}
-
-
-
-
-
-bool cChunkDesc::IsUsingDefaultComposition(void) const
-{
- return m_bUseDefaultComposition;
-}
-
-
-
-
-
-void cChunkDesc::SetUseDefaultStructures(bool a_bUseDefaultStructures)
-{
- m_bUseDefaultStructures = a_bUseDefaultStructures;
-}
-
-
-
-
-
-bool cChunkDesc::IsUsingDefaultStructures(void) const
-{
- return m_bUseDefaultStructures;
-}
-
-
-
-
-
-void cChunkDesc::SetUseDefaultFinish(bool a_bUseDefaultFinish)
-{
- m_bUseDefaultFinish = a_bUseDefaultFinish;
-}
-
-
-
-
-
-bool cChunkDesc::IsUsingDefaultFinish(void) const
-{
- return m_bUseDefaultFinish;
-}
-
-
-
-
-void cChunkDesc::WriteBlockArea(const cBlockArea & a_BlockArea, int a_RelX, int a_RelY, int a_RelZ, cBlockArea::eMergeStrategy a_MergeStrategy)
-{
- m_BlockArea.Merge(a_BlockArea, a_RelX, a_RelY, a_RelZ, a_MergeStrategy);
-}
-
-
-
-
-
-void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ)
-{
- // Normalize the coords:
- if (a_MinRelX > a_MaxRelX)
- {
- std::swap(a_MinRelX, a_MaxRelX);
- }
- if (a_MinRelY > a_MaxRelY)
- {
- std::swap(a_MinRelY, a_MaxRelY);
- }
- if (a_MinRelZ > a_MaxRelZ)
- {
- std::swap(a_MinRelZ, a_MaxRelZ);
- }
-
- // Include the Max coords:
- a_MaxRelX += 1;
- a_MaxRelY += 1;
- a_MaxRelZ += 1;
-
- // Check coords validity:
- if (a_MinRelX < 0)
- {
- LOGWARNING("%s: MinRelX less than zero, adjusting to zero", __FUNCTION__);
- a_MinRelX = 0;
- }
- else if (a_MinRelX >= cChunkDef::Width)
- {
- LOGWARNING("%s: MinRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
- a_MinRelX = cChunkDef::Width - 1;
- }
- if (a_MaxRelX < 0)
- {
- LOGWARNING("%s: MaxRelX less than zero, adjusting to zero", __FUNCTION__);
- a_MaxRelX = 0;
- }
- else if (a_MinRelX >= cChunkDef::Width)
- {
- LOGWARNING("%s: MaxRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
- a_MaxRelX = cChunkDef::Width - 1;
- }
-
- if (a_MinRelY < 0)
- {
- LOGWARNING("%s: MinRelY less than zero, adjusting to zero", __FUNCTION__);
- a_MinRelY = 0;
- }
- else if (a_MinRelY >= cChunkDef::Height)
- {
- LOGWARNING("%s: MinRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
- a_MinRelY = cChunkDef::Height - 1;
- }
- if (a_MaxRelY < 0)
- {
- LOGWARNING("%s: MaxRelY less than zero, adjusting to zero", __FUNCTION__);
- a_MaxRelY = 0;
- }
- else if (a_MinRelY >= cChunkDef::Height)
- {
- LOGWARNING("%s: MaxRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
- a_MaxRelY = cChunkDef::Height - 1;
- }
-
- if (a_MinRelZ < 0)
- {
- LOGWARNING("%s: MinRelZ less than zero, adjusting to zero", __FUNCTION__);
- a_MinRelZ = 0;
- }
- else if (a_MinRelZ >= cChunkDef::Width)
- {
- LOGWARNING("%s: MinRelZ more than chunk width, adjusting to chunk width", __FUNCTION__);
- a_MinRelZ = cChunkDef::Width - 1;
- }
- if (a_MaxRelZ < 0)
- {
- LOGWARNING("%s: MaxRelZ less than zero, adjusting to zero", __FUNCTION__);
- a_MaxRelZ = 0;
- }
- else if (a_MinRelZ >= cChunkDef::Width)
- {
- LOGWARNING("%s: MaxRelZ more than chunk width, adjusting to chunk width", __FUNCTION__);
- a_MaxRelZ = cChunkDef::Width - 1;
- }
-
- // Prepare the block area:
- int SizeX = a_MaxRelX - a_MinRelX;
- int SizeY = a_MaxRelY - a_MinRelY;
- int SizeZ = a_MaxRelZ - a_MinRelZ;
- a_Dest.Clear();
- a_Dest.m_OriginX = m_ChunkX * cChunkDef::Width + a_MinRelX;
- a_Dest.m_OriginY = a_MinRelY;
- a_Dest.m_OriginZ = m_ChunkZ * cChunkDef::Width + a_MinRelZ;
- a_Dest.SetSize(SizeX, SizeY, SizeZ, cBlockArea::baTypes | cBlockArea::baMetas);
-
- for (int y = 0; y < SizeY; y++)
- {
- int CDY = a_MinRelY + y;
- for (int z = 0; z < SizeZ; z++)
- {
- int CDZ = a_MinRelZ + z;
- for (int x = 0; x < SizeX; x++)
- {
- int CDX = a_MinRelX + x;
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- GetBlockTypeMeta(CDX, CDY, CDZ, BlockType, BlockMeta);
- a_Dest.SetRelBlockTypeMeta(x, y, z, BlockType, BlockMeta);
- } // for x
- } // for z
- } // for y
-}
-
-
-
-
-
-HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const
-{
- HEIGHTTYPE MaxHeight = m_HeightMap[0];
- for (int i = 1; i < ARRAYCOUNT(m_HeightMap); i++)
- {
- if (m_HeightMap[i] > MaxHeight)
- {
- MaxHeight = m_HeightMap[i];
- }
- }
- return MaxHeight;
-}
-
-
-
-
-
-void cChunkDesc::FillRelCuboid(
- int a_MinX, int a_MaxX,
- int a_MinY, int a_MaxY,
- int a_MinZ, int a_MaxZ,
- BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
-)
-{
- int MinX = std::max(a_MinX, 0);
- int MinY = std::max(a_MinY, 0);
- int MinZ = std::max(a_MinZ, 0);
- int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
- int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
- int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
-
- for (int y = MinY; y <= MaxY; y++)
- {
- for (int z = MinZ; z <= MaxZ; z++)
- {
- for (int x = MinX; x <= MaxX; x++)
- {
- SetBlockTypeMeta(x, y, z, a_BlockType, a_BlockMeta);
- }
- } // for z
- } // for y
-}
-
-
-
-
-
-void cChunkDesc::ReplaceRelCuboid(
- int a_MinX, int a_MaxX,
- int a_MinY, int a_MaxY,
- int a_MinZ, int a_MaxZ,
- BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta,
- BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta
-)
-{
- int MinX = std::max(a_MinX, 0);
- int MinY = std::max(a_MinY, 0);
- int MinZ = std::max(a_MinZ, 0);
- int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
- int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
- int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
-
- for (int y = MinY; y <= MaxY; y++)
- {
- for (int z = MinZ; z <= MaxZ; z++)
- {
- for (int x = MinX; x <= MaxX; x++)
- {
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- GetBlockTypeMeta(x, y, z, BlockType, BlockMeta);
- if ((BlockType == a_SrcType) && (BlockMeta == a_SrcMeta))
- {
- SetBlockTypeMeta(x, y, z, a_DstType, a_DstMeta);
- }
- }
- } // for z
- } // for y
-}
-
-
-
-
-
-void cChunkDesc::FloorRelCuboid(
- int a_MinX, int a_MaxX,
- int a_MinY, int a_MaxY,
- int a_MinZ, int a_MaxZ,
- BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta
-)
-{
- int MinX = std::max(a_MinX, 0);
- int MinY = std::max(a_MinY, 0);
- int MinZ = std::max(a_MinZ, 0);
- int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
- int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
- int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
-
- for (int y = MinY; y <= MaxY; y++)
- {
- for (int z = MinZ; z <= MaxZ; z++)
- {
- for (int x = MinX; x <= MaxX; x++)
- {
- switch (GetBlockType(x, y, z))
- {
- case E_BLOCK_AIR:
- case E_BLOCK_WATER:
- case E_BLOCK_STATIONARY_WATER:
- {
- SetBlockTypeMeta(x, y, z, a_DstType, a_DstMeta);
- break;
- }
- } // switch (GetBlockType)
- } // for x
- } // for z
- } // for y
-}
-
-
-
-
-
-void cChunkDesc::RandomFillRelCuboid(
- int a_MinX, int a_MaxX,
- int a_MinY, int a_MaxY,
- int a_MinZ, int a_MaxZ,
- BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
- int a_RandomSeed, int a_ChanceOutOf10k
-)
-{
- cNoise Noise(a_RandomSeed);
- int MinX = std::max(a_MinX, 0);
- int MinY = std::max(a_MinY, 0);
- int MinZ = std::max(a_MinZ, 0);
- int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
- int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
- int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
-
- for (int y = MinY; y <= MaxY; y++)
- {
- for (int z = MinZ; z <= MaxZ; z++)
- {
- for (int x = MinX; x <= MaxX; x++)
- {
- int rnd = (Noise.IntNoise3DInt(x, y, z) / 7) % 10000;
- if (rnd <= a_ChanceOutOf10k)
- {
- SetBlockTypeMeta(x, y, z, a_BlockType, a_BlockMeta);
- }
- }
- } // for z
- } // for y
-}
-
-
-
-
-
-void cChunkDesc::AddBlockEntity(cBlockEntity * a_BlockEntity)
-{
- m_BlockEntities.push_back(a_BlockEntity);
-}
-
-
-
-
-
-void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
-{
- const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas();
- for (int i = 0; i < ARRAYCOUNT(a_DestMetas); i++)
- {
- a_DestMetas[i] = AreaMetas[2 * i] | (AreaMetas[2 * i + 1] << 4);
- }
-}
-
-
-
-
-
-#ifdef _DEBUG
-
-void cChunkDesc::VerifyHeightmap(void)
-{
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int y = cChunkDef::Height - 1; y > 0; y--)
- {
- BLOCKTYPE BlockType = GetBlockType(x, y, z);
- if (BlockType != E_BLOCK_AIR)
- {
- int Height = GetHeight(x, z);
- ASSERT(Height == y);
- break;
- }
- } // for y
- } // for z
- } // for x
-}
-
-#endif // _DEBUG
-
-
-
-
-
+
+// ChunkDesc.cpp
+
+// Implements the cChunkDesc class representing the chunk description used while generating a chunk. This class is also exported to Lua for HOOK_CHUNK_GENERATING.
+
+#include "Globals.h"
+#include "ChunkDesc.h"
+#include "../BlockArea.h"
+#include "../Cuboid.h"
+#include "../Noise.h"
+
+
+
+
+
+cChunkDesc::cChunkDesc(int a_ChunkX, int a_ChunkZ) :
+ m_ChunkX(a_ChunkX),
+ m_ChunkZ(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);
+ /*
+ memset(m_BlockTypes, 0, sizeof(cChunkDef::BlockTypes));
+ memset(m_BlockMeta, 0, sizeof(cChunkDef::BlockNibbles));
+ */
+ memset(m_BiomeMap, 0, sizeof(cChunkDef::BiomeMap));
+ memset(m_HeightMap, 0, sizeof(cChunkDef::HeightMap));
+}
+
+
+
+
+
+cChunkDesc::~cChunkDesc()
+{
+ // Nothing needed yet
+}
+
+
+
+
+
+void cChunkDesc::SetChunkCoords(int a_ChunkX, int a_ChunkZ)
+{
+ m_ChunkX = a_ChunkX;
+ m_ChunkZ = a_ChunkZ;
+}
+
+
+
+
+
+void cChunkDesc::FillBlocks(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+{
+ m_BlockArea.Fill(cBlockArea::baTypes | cBlockArea::baMetas, a_BlockType, a_BlockMeta);
+}
+
+
+
+
+
+void cChunkDesc::SetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+{
+ m_BlockArea.SetRelBlockTypeMeta(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta);
+}
+
+
+
+
+
+void cChunkDesc::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
+{
+ m_BlockArea.GetRelBlockTypeMeta(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta);
+}
+
+
+
+
+
+void cChunkDesc::SetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
+{
+ cChunkDef::SetBlock(m_BlockArea.GetBlockTypes(), a_RelX, a_RelY, a_RelZ, a_BlockType);
+}
+
+
+
+
+
+BLOCKTYPE cChunkDesc::GetBlockType(int a_RelX, int a_RelY, int a_RelZ)
+{
+ return cChunkDef::GetBlock(m_BlockArea.GetBlockTypes(), a_RelX, a_RelY, a_RelZ);
+}
+
+
+
+
+
+NIBBLETYPE cChunkDesc::GetBlockMeta(int a_RelX, int a_RelY, int a_RelZ)
+{
+ return m_BlockArea.GetRelBlockMeta(a_RelX, a_RelY, a_RelZ);
+}
+
+
+
+
+
+void cChunkDesc::SetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta)
+{
+ m_BlockArea.SetRelBlockMeta(a_RelX, a_RelY, a_RelZ, a_BlockMeta);
+}
+
+
+
+
+
+void cChunkDesc::SetBiome(int a_RelX, int a_RelZ, int a_BiomeID)
+{
+ cChunkDef::SetBiome(m_BiomeMap, a_RelX, a_RelZ, (EMCSBiome)a_BiomeID);
+}
+
+
+
+
+EMCSBiome cChunkDesc::GetBiome(int a_RelX, int a_RelZ)
+{
+ return cChunkDef::GetBiome(m_BiomeMap, a_RelX, a_RelZ);
+}
+
+
+
+
+
+void cChunkDesc::SetHeight(int a_RelX, int a_RelZ, int a_Height)
+{
+ cChunkDef::SetHeight(m_HeightMap, a_RelX, a_RelZ, a_Height);
+}
+
+
+
+
+
+int cChunkDesc::GetHeight(int a_RelX, int a_RelZ)
+{
+ return cChunkDef::GetHeight(m_HeightMap, a_RelX, a_RelZ);
+}
+
+
+
+
+
+void cChunkDesc::SetUseDefaultBiomes(bool a_bUseDefaultBiomes)
+{
+ m_bUseDefaultBiomes = a_bUseDefaultBiomes;
+}
+
+
+
+
+
+bool cChunkDesc::IsUsingDefaultBiomes(void) const
+{
+ return m_bUseDefaultBiomes;
+}
+
+
+
+
+
+void cChunkDesc::SetUseDefaultHeight(bool a_bUseDefaultHeight)
+{
+ m_bUseDefaultHeight = a_bUseDefaultHeight;
+}
+
+
+
+
+
+bool cChunkDesc::IsUsingDefaultHeight(void) const
+{
+ return m_bUseDefaultHeight;
+}
+
+
+
+
+
+void cChunkDesc::SetUseDefaultComposition(bool a_bUseDefaultComposition)
+{
+ m_bUseDefaultComposition = a_bUseDefaultComposition;
+}
+
+
+
+
+
+bool cChunkDesc::IsUsingDefaultComposition(void) const
+{
+ return m_bUseDefaultComposition;
+}
+
+
+
+
+
+void cChunkDesc::SetUseDefaultStructures(bool a_bUseDefaultStructures)
+{
+ m_bUseDefaultStructures = a_bUseDefaultStructures;
+}
+
+
+
+
+
+bool cChunkDesc::IsUsingDefaultStructures(void) const
+{
+ return m_bUseDefaultStructures;
+}
+
+
+
+
+
+void cChunkDesc::SetUseDefaultFinish(bool a_bUseDefaultFinish)
+{
+ m_bUseDefaultFinish = a_bUseDefaultFinish;
+}
+
+
+
+
+
+bool cChunkDesc::IsUsingDefaultFinish(void) const
+{
+ return m_bUseDefaultFinish;
+}
+
+
+
+
+void cChunkDesc::WriteBlockArea(const cBlockArea & a_BlockArea, int a_RelX, int a_RelY, int a_RelZ, cBlockArea::eMergeStrategy a_MergeStrategy)
+{
+ m_BlockArea.Merge(a_BlockArea, a_RelX, a_RelY, a_RelZ, a_MergeStrategy);
+}
+
+
+
+
+
+void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ)
+{
+ // Normalize the coords:
+ if (a_MinRelX > a_MaxRelX)
+ {
+ std::swap(a_MinRelX, a_MaxRelX);
+ }
+ if (a_MinRelY > a_MaxRelY)
+ {
+ std::swap(a_MinRelY, a_MaxRelY);
+ }
+ if (a_MinRelZ > a_MaxRelZ)
+ {
+ std::swap(a_MinRelZ, a_MaxRelZ);
+ }
+
+ // Include the Max coords:
+ a_MaxRelX += 1;
+ a_MaxRelY += 1;
+ a_MaxRelZ += 1;
+
+ // Check coords validity:
+ if (a_MinRelX < 0)
+ {
+ LOGWARNING("%s: MinRelX less than zero, adjusting to zero", __FUNCTION__);
+ a_MinRelX = 0;
+ }
+ else if (a_MinRelX >= cChunkDef::Width)
+ {
+ LOGWARNING("%s: MinRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
+ a_MinRelX = cChunkDef::Width - 1;
+ }
+ if (a_MaxRelX < 0)
+ {
+ LOGWARNING("%s: MaxRelX less than zero, adjusting to zero", __FUNCTION__);
+ a_MaxRelX = 0;
+ }
+ else if (a_MinRelX >= cChunkDef::Width)
+ {
+ LOGWARNING("%s: MaxRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
+ a_MaxRelX = cChunkDef::Width - 1;
+ }
+
+ if (a_MinRelY < 0)
+ {
+ LOGWARNING("%s: MinRelY less than zero, adjusting to zero", __FUNCTION__);
+ a_MinRelY = 0;
+ }
+ else if (a_MinRelY >= cChunkDef::Height)
+ {
+ LOGWARNING("%s: MinRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
+ a_MinRelY = cChunkDef::Height - 1;
+ }
+ if (a_MaxRelY < 0)
+ {
+ LOGWARNING("%s: MaxRelY less than zero, adjusting to zero", __FUNCTION__);
+ a_MaxRelY = 0;
+ }
+ else if (a_MinRelY >= cChunkDef::Height)
+ {
+ LOGWARNING("%s: MaxRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
+ a_MaxRelY = cChunkDef::Height - 1;
+ }
+
+ if (a_MinRelZ < 0)
+ {
+ LOGWARNING("%s: MinRelZ less than zero, adjusting to zero", __FUNCTION__);
+ a_MinRelZ = 0;
+ }
+ else if (a_MinRelZ >= cChunkDef::Width)
+ {
+ LOGWARNING("%s: MinRelZ more than chunk width, adjusting to chunk width", __FUNCTION__);
+ a_MinRelZ = cChunkDef::Width - 1;
+ }
+ if (a_MaxRelZ < 0)
+ {
+ LOGWARNING("%s: MaxRelZ less than zero, adjusting to zero", __FUNCTION__);
+ a_MaxRelZ = 0;
+ }
+ else if (a_MinRelZ >= cChunkDef::Width)
+ {
+ LOGWARNING("%s: MaxRelZ more than chunk width, adjusting to chunk width", __FUNCTION__);
+ a_MaxRelZ = cChunkDef::Width - 1;
+ }
+
+ // Prepare the block area:
+ int SizeX = a_MaxRelX - a_MinRelX;
+ int SizeY = a_MaxRelY - a_MinRelY;
+ int SizeZ = a_MaxRelZ - a_MinRelZ;
+ a_Dest.Clear();
+ a_Dest.m_OriginX = m_ChunkX * cChunkDef::Width + a_MinRelX;
+ a_Dest.m_OriginY = a_MinRelY;
+ a_Dest.m_OriginZ = m_ChunkZ * cChunkDef::Width + a_MinRelZ;
+ a_Dest.SetSize(SizeX, SizeY, SizeZ, cBlockArea::baTypes | cBlockArea::baMetas);
+
+ for (int y = 0; y < SizeY; y++)
+ {
+ int CDY = a_MinRelY + y;
+ for (int z = 0; z < SizeZ; z++)
+ {
+ int CDZ = a_MinRelZ + z;
+ for (int x = 0; x < SizeX; x++)
+ {
+ int CDX = a_MinRelX + x;
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ GetBlockTypeMeta(CDX, CDY, CDZ, BlockType, BlockMeta);
+ a_Dest.SetRelBlockTypeMeta(x, y, z, BlockType, BlockMeta);
+ } // for x
+ } // for z
+ } // for y
+}
+
+
+
+
+
+HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const
+{
+ HEIGHTTYPE MaxHeight = m_HeightMap[0];
+ for (int i = 1; i < ARRAYCOUNT(m_HeightMap); i++)
+ {
+ if (m_HeightMap[i] > MaxHeight)
+ {
+ MaxHeight = m_HeightMap[i];
+ }
+ }
+ return MaxHeight;
+}
+
+
+
+
+
+void cChunkDesc::FillRelCuboid(
+ int a_MinX, int a_MaxX,
+ int a_MinY, int a_MaxY,
+ int a_MinZ, int a_MaxZ,
+ BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
+)
+{
+ int MinX = std::max(a_MinX, 0);
+ int MinY = std::max(a_MinY, 0);
+ int MinZ = std::max(a_MinZ, 0);
+ int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
+ int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
+ int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
+
+ for (int y = MinY; y <= MaxY; y++)
+ {
+ for (int z = MinZ; z <= MaxZ; z++)
+ {
+ for (int x = MinX; x <= MaxX; x++)
+ {
+ SetBlockTypeMeta(x, y, z, a_BlockType, a_BlockMeta);
+ }
+ } // for z
+ } // for y
+}
+
+
+
+
+
+void cChunkDesc::ReplaceRelCuboid(
+ int a_MinX, int a_MaxX,
+ int a_MinY, int a_MaxY,
+ int a_MinZ, int a_MaxZ,
+ BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta,
+ BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta
+)
+{
+ int MinX = std::max(a_MinX, 0);
+ int MinY = std::max(a_MinY, 0);
+ int MinZ = std::max(a_MinZ, 0);
+ int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
+ int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
+ int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
+
+ for (int y = MinY; y <= MaxY; y++)
+ {
+ for (int z = MinZ; z <= MaxZ; z++)
+ {
+ for (int x = MinX; x <= MaxX; x++)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ GetBlockTypeMeta(x, y, z, BlockType, BlockMeta);
+ if ((BlockType == a_SrcType) && (BlockMeta == a_SrcMeta))
+ {
+ SetBlockTypeMeta(x, y, z, a_DstType, a_DstMeta);
+ }
+ }
+ } // for z
+ } // for y
+}
+
+
+
+
+
+void cChunkDesc::FloorRelCuboid(
+ int a_MinX, int a_MaxX,
+ int a_MinY, int a_MaxY,
+ int a_MinZ, int a_MaxZ,
+ BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta
+)
+{
+ int MinX = std::max(a_MinX, 0);
+ int MinY = std::max(a_MinY, 0);
+ int MinZ = std::max(a_MinZ, 0);
+ int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
+ int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
+ int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
+
+ for (int y = MinY; y <= MaxY; y++)
+ {
+ for (int z = MinZ; z <= MaxZ; z++)
+ {
+ for (int x = MinX; x <= MaxX; x++)
+ {
+ switch (GetBlockType(x, y, z))
+ {
+ case E_BLOCK_AIR:
+ case E_BLOCK_WATER:
+ case E_BLOCK_STATIONARY_WATER:
+ {
+ SetBlockTypeMeta(x, y, z, a_DstType, a_DstMeta);
+ break;
+ }
+ } // switch (GetBlockType)
+ } // for x
+ } // for z
+ } // for y
+}
+
+
+
+
+
+void cChunkDesc::RandomFillRelCuboid(
+ int a_MinX, int a_MaxX,
+ int a_MinY, int a_MaxY,
+ int a_MinZ, int a_MaxZ,
+ BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ int a_RandomSeed, int a_ChanceOutOf10k
+)
+{
+ cNoise Noise(a_RandomSeed);
+ int MinX = std::max(a_MinX, 0);
+ int MinY = std::max(a_MinY, 0);
+ int MinZ = std::max(a_MinZ, 0);
+ int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
+ int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
+ int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
+
+ for (int y = MinY; y <= MaxY; y++)
+ {
+ for (int z = MinZ; z <= MaxZ; z++)
+ {
+ for (int x = MinX; x <= MaxX; x++)
+ {
+ int rnd = (Noise.IntNoise3DInt(x, y, z) / 7) % 10000;
+ if (rnd <= a_ChanceOutOf10k)
+ {
+ SetBlockTypeMeta(x, y, z, a_BlockType, a_BlockMeta);
+ }
+ }
+ } // for z
+ } // for y
+}
+
+
+
+
+
+void cChunkDesc::AddBlockEntity(cBlockEntity * a_BlockEntity)
+{
+ m_BlockEntities.push_back(a_BlockEntity);
+}
+
+
+
+
+
+void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
+{
+ const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas();
+ for (int i = 0; i < ARRAYCOUNT(a_DestMetas); i++)
+ {
+ a_DestMetas[i] = AreaMetas[2 * i] | (AreaMetas[2 * i + 1] << 4);
+ }
+}
+
+
+
+
+
+#ifdef _DEBUG
+
+void cChunkDesc::VerifyHeightmap(void)
+{
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int y = cChunkDef::Height - 1; y > 0; y--)
+ {
+ BLOCKTYPE BlockType = GetBlockType(x, y, z);
+ if (BlockType != E_BLOCK_AIR)
+ {
+ int Height = GetHeight(x, z);
+ ASSERT(Height == y);
+ break;
+ }
+ } // for y
+ } // for z
+ } // for x
+}
+
+#endif // _DEBUG
+
+
+
+
+
diff --git a/source/Generating/ComposableGenerator.cpp b/source/Generating/ComposableGenerator.cpp
index c038712aa..fb31ec7b2 100644
--- a/source/Generating/ComposableGenerator.cpp
+++ b/source/Generating/ComposableGenerator.cpp
@@ -1,524 +1,524 @@
-
-// ComposableGenerator.cpp
-
-// Implements the cComposableGenerator class representing the chunk generator that takes the composition approach to generating chunks
-
-#include "Globals.h"
-
-#include "ComposableGenerator.h"
-#include "../World.h"
-#include "../../iniFile/iniFile.h"
-#include "../Root.h"
-
-// Individual composed algorithms:
-#include "BioGen.h"
-#include "HeiGen.h"
-#include "CompoGen.h"
-#include "StructGen.h"
-#include "FinishGen.h"
-
-#include "Caves.h"
-#include "DistortedHeightmap.h"
-#include "EndGen.h"
-#include "MineShafts.h"
-#include "Noise3DGenerator.h"
-#include "Ravines.h"
-
-
-
-
-
-
-
-
-
-
-cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) :
- super(a_ChunkGenerator),
- m_BiomeGen(NULL),
- m_HeightGen(NULL),
- m_CompositionGen(NULL),
- m_UnderlyingBiomeGen(NULL),
- m_UnderlyingHeightGen(NULL),
- m_UnderlyingCompositionGen(NULL)
-{
-}
-
-
-
-
-
-cComposableGenerator::~cComposableGenerator()
-{
- // Delete the generating composition:
- for (cFinishGenList::const_iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
- {
- delete *itr;
- }
- m_FinishGens.clear();
- for (cStructureGenList::const_iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
- {
- delete *itr;
- }
- m_StructureGens.clear();
-
- delete m_CompositionGen;
- m_CompositionGen = NULL;
- delete m_HeightGen;
- m_HeightGen = NULL;
- delete m_BiomeGen;
- m_BiomeGen = NULL;
- delete m_UnderlyingCompositionGen;
- m_UnderlyingCompositionGen = NULL;
- delete m_UnderlyingHeightGen;
- m_UnderlyingHeightGen = NULL;
- delete m_UnderlyingBiomeGen;
- m_UnderlyingBiomeGen = NULL;
-}
-
-
-
-
-
-void cComposableGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile)
-{
- super::Initialize(a_World, a_IniFile);
-
- InitBiomeGen(a_IniFile);
- InitHeightGen(a_IniFile);
- InitCompositionGen(a_IniFile);
- InitStructureGens(a_IniFile);
- InitFinishGens(a_IniFile);
-}
-
-
-
-
-
-void cComposableGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
-{
- if (m_BiomeGen != NULL) // Quick fix for generator deinitializing before the world storage finishes loading
- {
- m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap);
- }
-}
-
-
-
-
-
-void cComposableGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc)
-{
- if (a_ChunkDesc.IsUsingDefaultBiomes())
- {
- m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, a_ChunkDesc.GetBiomeMap());
- }
-
- if (a_ChunkDesc.IsUsingDefaultHeight())
- {
- m_HeightGen->GenHeightMap(a_ChunkX, a_ChunkZ, a_ChunkDesc.GetHeightMap());
- }
-
- if (a_ChunkDesc.IsUsingDefaultComposition())
- {
- m_CompositionGen->ComposeTerrain(a_ChunkDesc);
- }
-
- if (a_ChunkDesc.IsUsingDefaultStructures())
- {
- for (cStructureGenList::iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
- {
- (*itr)->GenStructures(a_ChunkDesc);
- } // for itr - m_StructureGens[]
- }
-
- if (a_ChunkDesc.IsUsingDefaultFinish())
- {
- for (cFinishGenList::iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
- {
- (*itr)->GenFinish(a_ChunkDesc);
- } // for itr - m_FinishGens[]
- }
-}
-
-
-
-
-
-void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile)
-{
- AString BiomeGenName = a_IniFile.GetValueSet("Generator", "BiomeGen", "");
- if (BiomeGenName.empty())
- {
- LOGWARN("[Generator]::BiomeGen value not found in world.ini, using \"MultiStepMap\".");
- BiomeGenName = "MultiStepMap";
- }
-
- int Seed = m_ChunkGenerator.GetSeed();
- bool CacheOffByDefault = false;
- if (NoCaseCompare(BiomeGenName, "constant") == 0)
- {
- m_BiomeGen = new cBioGenConstant;
- CacheOffByDefault = true; // we're generating faster than a cache would retrieve data :)
- }
- else if (NoCaseCompare(BiomeGenName, "checkerboard") == 0)
- {
- m_BiomeGen = new cBioGenCheckerboard;
- CacheOffByDefault = true; // we're (probably) generating faster than a cache would retrieve data
- }
- else if (NoCaseCompare(BiomeGenName, "voronoi") == 0)
- {
- m_BiomeGen = new cBioGenVoronoi(Seed);
- }
- else if (NoCaseCompare(BiomeGenName, "distortedvoronoi") == 0)
- {
- m_BiomeGen = new cBioGenDistortedVoronoi(Seed);
- }
- else
- {
- if (NoCaseCompare(BiomeGenName, "multistepmap") != 0)
- {
- LOGWARNING("Unknown BiomeGen \"%s\", using \"MultiStepMap\" instead.", BiomeGenName.c_str());
- }
- m_BiomeGen = new cBioGenMultiStepMap(Seed);
-
- /*
- // Performance-testing:
- LOGINFO("Measuring performance of cBioGenMultiStepMap...");
- clock_t BeginTick = clock();
- for (int x = 0; x < 5000; x++)
- {
- cChunkDef::BiomeMap Biomes;
- m_BiomeGen->GenBiomes(x * 5, x * 5, Biomes);
- }
- clock_t Duration = clock() - BeginTick;
- LOGINFO("cBioGenMultiStepMap for 5000 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
- //*/
- }
-
- // Add a cache, if requested:
- int CacheSize = a_IniFile.GetValueSetI("Generator", "BiomeGenCacheSize", CacheOffByDefault ? 0 : 64);
- if (CacheSize > 0)
- {
- if (CacheSize < 4)
- {
- LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
- CacheSize, 4
- );
- CacheSize = 4;
- }
- LOGINFO("Using a cache for biomegen of size %d.", CacheSize);
- m_UnderlyingBiomeGen = m_BiomeGen;
- m_BiomeGen = new cBioGenCache(m_UnderlyingBiomeGen, CacheSize);
- }
- m_BiomeGen->Initialize(a_IniFile);
-}
-
-
-
-
-
-void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
-{
- AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", "");
- if (HeightGenName.empty())
- {
- LOGWARN("[Generator]::HeightGen value not found in world.ini, using \"Biomal\".");
- HeightGenName = "Biomal";
- }
-
- int Seed = m_ChunkGenerator.GetSeed();
- bool CacheOffByDefault = false;
- if (NoCaseCompare(HeightGenName, "flat") == 0)
- {
- int Height = a_IniFile.GetValueSetI("Generator", "FlatHeight", 5);
- m_HeightGen = new cHeiGenFlat(Height);
- CacheOffByDefault = true; // We're generating faster than a cache would retrieve data
- }
- else if (NoCaseCompare(HeightGenName, "classic") == 0)
- {
- // These used to be in terrain.ini, but now they are in world.ini (so that multiple worlds can have different values):
- float HeightFreq1 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightFreq1", 0.1);
- float HeightFreq2 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightFreq2", 1.0);
- float HeightFreq3 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightFreq3", 2.0);
- float HeightAmp1 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp1", 1.0);
- float HeightAmp2 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp2", 0.5);
- float HeightAmp3 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp3", 0.5);
- m_HeightGen = new cHeiGenClassic(Seed, HeightFreq1, HeightAmp1, HeightFreq2, HeightAmp2, HeightFreq3, HeightAmp3);
- }
- else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0)
- {
- m_HeightGen = new cDistortedHeightmap(Seed, *m_BiomeGen);
- ((cDistortedHeightmap *)m_HeightGen)->Initialize(a_IniFile);
- }
- else if (NoCaseCompare(HeightGenName, "End") == 0)
- {
- m_HeightGen = new cEndGen(Seed);
- ((cEndGen *)m_HeightGen)->Initialize(a_IniFile);
- }
- else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
- {
- m_HeightGen = new cNoise3DComposable(Seed);
- ((cNoise3DComposable *)m_HeightGen)->Initialize(a_IniFile);
- }
- else // "biomal" or <not found>
- {
- if (NoCaseCompare(HeightGenName, "biomal") != 0)
- {
- LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str());
- }
- m_HeightGen = new cHeiGenBiomal(Seed, *m_BiomeGen);
-
- /*
- // Performance-testing:
- LOGINFO("Measuring performance of cHeiGenBiomal...");
- clock_t BeginTick = clock();
- for (int x = 0; x < 500; x++)
- {
- cChunkDef::HeightMap Heights;
- m_HeightGen->GenHeightMap(x * 5, x * 5, Heights);
- }
- clock_t Duration = clock() - BeginTick;
- LOGINFO("HeightGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
- //*/
- }
-
- // Add a cache, if requested:
- int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64);
- if (CacheSize > 0)
- {
- if (CacheSize < 4)
- {
- LOGWARNING("Heightgen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
- CacheSize, 4
- );
- CacheSize = 4;
- }
- LOGINFO("Using a cache for Heightgen of size %d.", CacheSize);
- m_UnderlyingHeightGen = m_HeightGen;
- m_HeightGen = new cHeiGenCache(m_UnderlyingHeightGen, CacheSize);
- }
-}
-
-
-
-
-
-void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile)
-{
- AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", "");
- if (CompoGenName.empty())
- {
- LOGWARN("[Generator]::CompositionGen value not found in world.ini, using \"Biomal\".");
- CompoGenName = "Biomal";
- }
- if (NoCaseCompare(CompoGenName, "sameblock") == 0)
- {
- int Block = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "SameBlockType", "stone");
- bool Bedrocked = (a_IniFile.GetValueSetI("Generator", "SameBlockBedrocked", 1) != 0);
- m_CompositionGen = new cCompoGenSameBlock((BLOCKTYPE)Block, Bedrocked);
- }
- else if (NoCaseCompare(CompoGenName, "debugbiomes") == 0)
- {
- m_CompositionGen = new cCompoGenDebugBiomes;
- }
- else if (NoCaseCompare(CompoGenName, "classic") == 0)
- {
- int SeaLevel = a_IniFile.GetValueSetI("Generator", "ClassicSeaLevel", 60);
- int BeachHeight = a_IniFile.GetValueSetI("Generator", "ClassicBeachHeight", 2);
- int BeachDepth = a_IniFile.GetValueSetI("Generator", "ClassicBeachDepth", 4);
- BLOCKTYPE BlockTop = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockTop", "grass");
- BLOCKTYPE BlockMiddle = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockMiddle", "dirt");
- BLOCKTYPE BlockBottom = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockBottom", "stone");
- BLOCKTYPE BlockBeach = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockBeach", "sand");
- BLOCKTYPE BlockBeachBottom = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockBeachBottom", "sandstone");
- BLOCKTYPE BlockSea = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockSea", "stationarywater");
- m_CompositionGen = new cCompoGenClassic(
- SeaLevel, BeachHeight, BeachDepth, BlockTop, BlockMiddle, BlockBottom, BlockBeach,
- BlockBeachBottom, BlockSea
- );
- }
- else if (NoCaseCompare(CompoGenName, "DistortedHeightmap") == 0)
- {
- m_CompositionGen = new cDistortedHeightmap(m_ChunkGenerator.GetSeed(), *m_BiomeGen);
- ((cDistortedHeightmap *)m_CompositionGen)->Initialize(a_IniFile);
- }
- else if (NoCaseCompare(CompoGenName, "end") == 0)
- {
- m_CompositionGen = new cEndGen(m_ChunkGenerator.GetSeed());
- ((cEndGen *)m_CompositionGen)->Initialize(a_IniFile);
- }
- else if (NoCaseCompare(CompoGenName, "nether") == 0)
- {
- m_CompositionGen = new cCompoGenNether(m_ChunkGenerator.GetSeed());
- }
- else if (NoCaseCompare(CompoGenName, "Noise3D") == 0)
- {
- m_CompositionGen = new cNoise3DComposable(m_ChunkGenerator.GetSeed());
- ((cNoise3DComposable *)m_CompositionGen)->Initialize(a_IniFile);
- }
- else
- {
- if (NoCaseCompare(CompoGenName, "biomal") != 0)
- {
- LOGWARN("Unknown CompositionGen \"%s\", using \"biomal\" instead.", CompoGenName.c_str());
- }
- int SeaLevel = a_IniFile.GetValueSetI("Generator", "BiomalSeaLevel", 62);
- int Seed = m_ChunkGenerator.GetSeed();
- m_CompositionGen = new cCompoGenBiomal(Seed, SeaLevel);
-
- /*
- // Performance-testing:
- LOGINFO("Measuring performance of cCompoGenBiomal...");
- clock_t BeginTick = clock();
- for (int x = 0; x < 500; x++)
- {
- cChunkDesc Desc(200 + x * 8, 200 + x * 8);
- m_BiomeGen->GenBiomes(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetBiomeMap());
- m_HeightGen->GenHeightMap(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetHeightMap());
- m_CompositionGen->ComposeTerrain(Desc);
- }
- clock_t Duration = clock() - BeginTick;
- LOGINFO("CompositionGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
- //*/
- }
-
- int CompoGenCacheSize = a_IniFile.GetValueSetI("Generator", "CompositionGenCacheSize", 64);
- if (CompoGenCacheSize > 1)
- {
- m_UnderlyingCompositionGen = m_CompositionGen;
- m_CompositionGen = new cCompoGenCache(m_UnderlyingCompositionGen, 32);
- }
-}
-
-
-
-
-
-void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
-{
- AString Structures = a_IniFile.GetValueSet("Generator", "Structures", "Ravines, WormNestCaves, WaterLakes, LavaLakes, OreNests, Trees");
-
- int Seed = m_ChunkGenerator.GetSeed();
- AStringVector Str = StringSplitAndTrim(Structures, ",");
- for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
- {
- if (NoCaseCompare(*itr, "DualRidgeCaves") == 0)
- {
- float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3);
- m_StructureGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold));
- }
- else if (NoCaseCompare(*itr, "DirectOverhangs") == 0)
- {
- m_StructureGens.push_back(new cStructGenDirectOverhangs(Seed));
- }
- else if (NoCaseCompare(*itr, "DistortedMembraneOverhangs") == 0)
- {
- m_StructureGens.push_back(new cStructGenDistortedMembraneOverhangs(Seed));
- }
- else if (NoCaseCompare(*itr, "LavaLakes") == 0)
- {
- int Probability = a_IniFile.GetValueSetI("Generator", "LavaLakesProbability", 10);
- m_StructureGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen, Probability));
- }
- else if (NoCaseCompare(*itr, "MarbleCaves") == 0)
- {
- m_StructureGens.push_back(new cStructGenMarbleCaves(Seed));
- }
- else if (NoCaseCompare(*itr, "MineShafts") == 0)
- {
- int GridSize = a_IniFile.GetValueSetI("Generator", "MineShaftsGridSize", 512);
- 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_StructureGens.push_back(new cStructGenMineShafts(
- Seed, GridSize, MaxSystemSize,
- ChanceCorridor, ChanceCrossing, ChanceStaircase
- ));
- }
- else if (NoCaseCompare(*itr, "OreNests") == 0)
- {
- m_StructureGens.push_back(new cStructGenOreNests(Seed));
- }
- else if (NoCaseCompare(*itr, "Ravines") == 0)
- {
- m_StructureGens.push_back(new cStructGenRavines(Seed, 128));
- }
- else if (NoCaseCompare(*itr, "Trees") == 0)
- {
- m_StructureGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen));
- }
- else if (NoCaseCompare(*itr, "WaterLakes") == 0)
- {
- int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
- m_StructureGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen, Probability));
- }
- else if (NoCaseCompare(*itr, "WormNestCaves") == 0)
- {
- m_StructureGens.push_back(new cStructGenWormNestCaves(Seed));
- }
- else
- {
- LOGWARNING("Unknown structure generator: \"%s\". Ignoring.", itr->c_str());
- }
- } // for itr - Str[]
-}
-
-
-
-
-
-void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
-{
- int Seed = m_ChunkGenerator.GetSeed();
- AString Structures = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator");
-
- AStringVector Str = StringSplitAndTrim(Structures, ",");
- for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
- {
- // Finishers, alpha-sorted:
- if (NoCaseCompare(*itr, "BottomLava") == 0)
- {
- int DefaultBottomLavaLevel = (m_World->GetDimension() == dimNether) ? 30 : 10;
- int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel);
- m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
- }
- 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));
- }
- else if (NoCaseCompare(*itr, "Ice") == 0)
- {
- m_FinishGens.push_back(new cFinishGenIce);
- }
- else if (NoCaseCompare(*itr, "LavaSprings") == 0)
- {
- m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, *m_World));
- }
- 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));
- }
- else if (NoCaseCompare(*itr, "PreSimulator") == 0)
- {
- m_FinishGens.push_back(new cFinishGenPreSimulator);
- }
- else if (NoCaseCompare(*itr, "Snow") == 0)
- {
- m_FinishGens.push_back(new cFinishGenSnow);
- }
- else if (NoCaseCompare(*itr, "SprinkleFoliage") == 0)
- {
- m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed));
- }
- else if (NoCaseCompare(*itr, "WaterSprings") == 0)
- {
- m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_WATER, a_IniFile, *m_World));
- }
- } // for itr - Str[]
-}
-
-
-
-
+
+// ComposableGenerator.cpp
+
+// Implements the cComposableGenerator class representing the chunk generator that takes the composition approach to generating chunks
+
+#include "Globals.h"
+
+#include "ComposableGenerator.h"
+#include "../World.h"
+#include "../../iniFile/iniFile.h"
+#include "../Root.h"
+
+// Individual composed algorithms:
+#include "BioGen.h"
+#include "HeiGen.h"
+#include "CompoGen.h"
+#include "StructGen.h"
+#include "FinishGen.h"
+
+#include "Caves.h"
+#include "DistortedHeightmap.h"
+#include "EndGen.h"
+#include "MineShafts.h"
+#include "Noise3DGenerator.h"
+#include "Ravines.h"
+
+
+
+
+
+
+
+
+
+
+cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) :
+ super(a_ChunkGenerator),
+ m_BiomeGen(NULL),
+ m_HeightGen(NULL),
+ m_CompositionGen(NULL),
+ m_UnderlyingBiomeGen(NULL),
+ m_UnderlyingHeightGen(NULL),
+ m_UnderlyingCompositionGen(NULL)
+{
+}
+
+
+
+
+
+cComposableGenerator::~cComposableGenerator()
+{
+ // Delete the generating composition:
+ for (cFinishGenList::const_iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
+ {
+ delete *itr;
+ }
+ m_FinishGens.clear();
+ for (cStructureGenList::const_iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
+ {
+ delete *itr;
+ }
+ m_StructureGens.clear();
+
+ delete m_CompositionGen;
+ m_CompositionGen = NULL;
+ delete m_HeightGen;
+ m_HeightGen = NULL;
+ delete m_BiomeGen;
+ m_BiomeGen = NULL;
+ delete m_UnderlyingCompositionGen;
+ m_UnderlyingCompositionGen = NULL;
+ delete m_UnderlyingHeightGen;
+ m_UnderlyingHeightGen = NULL;
+ delete m_UnderlyingBiomeGen;
+ m_UnderlyingBiomeGen = NULL;
+}
+
+
+
+
+
+void cComposableGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile)
+{
+ super::Initialize(a_World, a_IniFile);
+
+ InitBiomeGen(a_IniFile);
+ InitHeightGen(a_IniFile);
+ InitCompositionGen(a_IniFile);
+ InitStructureGens(a_IniFile);
+ InitFinishGens(a_IniFile);
+}
+
+
+
+
+
+void cComposableGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
+{
+ if (m_BiomeGen != NULL) // Quick fix for generator deinitializing before the world storage finishes loading
+ {
+ m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap);
+ }
+}
+
+
+
+
+
+void cComposableGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc)
+{
+ if (a_ChunkDesc.IsUsingDefaultBiomes())
+ {
+ m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, a_ChunkDesc.GetBiomeMap());
+ }
+
+ if (a_ChunkDesc.IsUsingDefaultHeight())
+ {
+ m_HeightGen->GenHeightMap(a_ChunkX, a_ChunkZ, a_ChunkDesc.GetHeightMap());
+ }
+
+ if (a_ChunkDesc.IsUsingDefaultComposition())
+ {
+ m_CompositionGen->ComposeTerrain(a_ChunkDesc);
+ }
+
+ if (a_ChunkDesc.IsUsingDefaultStructures())
+ {
+ for (cStructureGenList::iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
+ {
+ (*itr)->GenStructures(a_ChunkDesc);
+ } // for itr - m_StructureGens[]
+ }
+
+ if (a_ChunkDesc.IsUsingDefaultFinish())
+ {
+ for (cFinishGenList::iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
+ {
+ (*itr)->GenFinish(a_ChunkDesc);
+ } // for itr - m_FinishGens[]
+ }
+}
+
+
+
+
+
+void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile)
+{
+ AString BiomeGenName = a_IniFile.GetValueSet("Generator", "BiomeGen", "");
+ if (BiomeGenName.empty())
+ {
+ LOGWARN("[Generator]::BiomeGen value not found in world.ini, using \"MultiStepMap\".");
+ BiomeGenName = "MultiStepMap";
+ }
+
+ int Seed = m_ChunkGenerator.GetSeed();
+ bool CacheOffByDefault = false;
+ if (NoCaseCompare(BiomeGenName, "constant") == 0)
+ {
+ m_BiomeGen = new cBioGenConstant;
+ CacheOffByDefault = true; // we're generating faster than a cache would retrieve data :)
+ }
+ else if (NoCaseCompare(BiomeGenName, "checkerboard") == 0)
+ {
+ m_BiomeGen = new cBioGenCheckerboard;
+ CacheOffByDefault = true; // we're (probably) generating faster than a cache would retrieve data
+ }
+ else if (NoCaseCompare(BiomeGenName, "voronoi") == 0)
+ {
+ m_BiomeGen = new cBioGenVoronoi(Seed);
+ }
+ else if (NoCaseCompare(BiomeGenName, "distortedvoronoi") == 0)
+ {
+ m_BiomeGen = new cBioGenDistortedVoronoi(Seed);
+ }
+ else
+ {
+ if (NoCaseCompare(BiomeGenName, "multistepmap") != 0)
+ {
+ LOGWARNING("Unknown BiomeGen \"%s\", using \"MultiStepMap\" instead.", BiomeGenName.c_str());
+ }
+ m_BiomeGen = new cBioGenMultiStepMap(Seed);
+
+ /*
+ // Performance-testing:
+ LOGINFO("Measuring performance of cBioGenMultiStepMap...");
+ clock_t BeginTick = clock();
+ for (int x = 0; x < 5000; x++)
+ {
+ cChunkDef::BiomeMap Biomes;
+ m_BiomeGen->GenBiomes(x * 5, x * 5, Biomes);
+ }
+ clock_t Duration = clock() - BeginTick;
+ LOGINFO("cBioGenMultiStepMap for 5000 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
+ //*/
+ }
+
+ // Add a cache, if requested:
+ int CacheSize = a_IniFile.GetValueSetI("Generator", "BiomeGenCacheSize", CacheOffByDefault ? 0 : 64);
+ if (CacheSize > 0)
+ {
+ if (CacheSize < 4)
+ {
+ LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
+ CacheSize, 4
+ );
+ CacheSize = 4;
+ }
+ LOGINFO("Using a cache for biomegen of size %d.", CacheSize);
+ m_UnderlyingBiomeGen = m_BiomeGen;
+ m_BiomeGen = new cBioGenCache(m_UnderlyingBiomeGen, CacheSize);
+ }
+ m_BiomeGen->Initialize(a_IniFile);
+}
+
+
+
+
+
+void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
+{
+ AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", "");
+ if (HeightGenName.empty())
+ {
+ LOGWARN("[Generator]::HeightGen value not found in world.ini, using \"Biomal\".");
+ HeightGenName = "Biomal";
+ }
+
+ int Seed = m_ChunkGenerator.GetSeed();
+ bool CacheOffByDefault = false;
+ if (NoCaseCompare(HeightGenName, "flat") == 0)
+ {
+ int Height = a_IniFile.GetValueSetI("Generator", "FlatHeight", 5);
+ m_HeightGen = new cHeiGenFlat(Height);
+ CacheOffByDefault = true; // We're generating faster than a cache would retrieve data
+ }
+ else if (NoCaseCompare(HeightGenName, "classic") == 0)
+ {
+ // These used to be in terrain.ini, but now they are in world.ini (so that multiple worlds can have different values):
+ float HeightFreq1 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightFreq1", 0.1);
+ float HeightFreq2 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightFreq2", 1.0);
+ float HeightFreq3 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightFreq3", 2.0);
+ float HeightAmp1 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp1", 1.0);
+ float HeightAmp2 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp2", 0.5);
+ float HeightAmp3 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp3", 0.5);
+ m_HeightGen = new cHeiGenClassic(Seed, HeightFreq1, HeightAmp1, HeightFreq2, HeightAmp2, HeightFreq3, HeightAmp3);
+ }
+ else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0)
+ {
+ m_HeightGen = new cDistortedHeightmap(Seed, *m_BiomeGen);
+ ((cDistortedHeightmap *)m_HeightGen)->Initialize(a_IniFile);
+ }
+ else if (NoCaseCompare(HeightGenName, "End") == 0)
+ {
+ m_HeightGen = new cEndGen(Seed);
+ ((cEndGen *)m_HeightGen)->Initialize(a_IniFile);
+ }
+ else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
+ {
+ m_HeightGen = new cNoise3DComposable(Seed);
+ ((cNoise3DComposable *)m_HeightGen)->Initialize(a_IniFile);
+ }
+ else // "biomal" or <not found>
+ {
+ if (NoCaseCompare(HeightGenName, "biomal") != 0)
+ {
+ LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str());
+ }
+ m_HeightGen = new cHeiGenBiomal(Seed, *m_BiomeGen);
+
+ /*
+ // Performance-testing:
+ LOGINFO("Measuring performance of cHeiGenBiomal...");
+ clock_t BeginTick = clock();
+ for (int x = 0; x < 500; x++)
+ {
+ cChunkDef::HeightMap Heights;
+ m_HeightGen->GenHeightMap(x * 5, x * 5, Heights);
+ }
+ clock_t Duration = clock() - BeginTick;
+ LOGINFO("HeightGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
+ //*/
+ }
+
+ // Add a cache, if requested:
+ int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64);
+ if (CacheSize > 0)
+ {
+ if (CacheSize < 4)
+ {
+ LOGWARNING("Heightgen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
+ CacheSize, 4
+ );
+ CacheSize = 4;
+ }
+ LOGINFO("Using a cache for Heightgen of size %d.", CacheSize);
+ m_UnderlyingHeightGen = m_HeightGen;
+ m_HeightGen = new cHeiGenCache(m_UnderlyingHeightGen, CacheSize);
+ }
+}
+
+
+
+
+
+void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile)
+{
+ AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", "");
+ if (CompoGenName.empty())
+ {
+ LOGWARN("[Generator]::CompositionGen value not found in world.ini, using \"Biomal\".");
+ CompoGenName = "Biomal";
+ }
+ if (NoCaseCompare(CompoGenName, "sameblock") == 0)
+ {
+ int Block = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "SameBlockType", "stone");
+ bool Bedrocked = (a_IniFile.GetValueSetI("Generator", "SameBlockBedrocked", 1) != 0);
+ m_CompositionGen = new cCompoGenSameBlock((BLOCKTYPE)Block, Bedrocked);
+ }
+ else if (NoCaseCompare(CompoGenName, "debugbiomes") == 0)
+ {
+ m_CompositionGen = new cCompoGenDebugBiomes;
+ }
+ else if (NoCaseCompare(CompoGenName, "classic") == 0)
+ {
+ int SeaLevel = a_IniFile.GetValueSetI("Generator", "ClassicSeaLevel", 60);
+ int BeachHeight = a_IniFile.GetValueSetI("Generator", "ClassicBeachHeight", 2);
+ int BeachDepth = a_IniFile.GetValueSetI("Generator", "ClassicBeachDepth", 4);
+ BLOCKTYPE BlockTop = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockTop", "grass");
+ BLOCKTYPE BlockMiddle = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockMiddle", "dirt");
+ BLOCKTYPE BlockBottom = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockBottom", "stone");
+ BLOCKTYPE BlockBeach = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockBeach", "sand");
+ BLOCKTYPE BlockBeachBottom = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockBeachBottom", "sandstone");
+ BLOCKTYPE BlockSea = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockSea", "stationarywater");
+ m_CompositionGen = new cCompoGenClassic(
+ SeaLevel, BeachHeight, BeachDepth, BlockTop, BlockMiddle, BlockBottom, BlockBeach,
+ BlockBeachBottom, BlockSea
+ );
+ }
+ else if (NoCaseCompare(CompoGenName, "DistortedHeightmap") == 0)
+ {
+ m_CompositionGen = new cDistortedHeightmap(m_ChunkGenerator.GetSeed(), *m_BiomeGen);
+ ((cDistortedHeightmap *)m_CompositionGen)->Initialize(a_IniFile);
+ }
+ else if (NoCaseCompare(CompoGenName, "end") == 0)
+ {
+ m_CompositionGen = new cEndGen(m_ChunkGenerator.GetSeed());
+ ((cEndGen *)m_CompositionGen)->Initialize(a_IniFile);
+ }
+ else if (NoCaseCompare(CompoGenName, "nether") == 0)
+ {
+ m_CompositionGen = new cCompoGenNether(m_ChunkGenerator.GetSeed());
+ }
+ else if (NoCaseCompare(CompoGenName, "Noise3D") == 0)
+ {
+ m_CompositionGen = new cNoise3DComposable(m_ChunkGenerator.GetSeed());
+ ((cNoise3DComposable *)m_CompositionGen)->Initialize(a_IniFile);
+ }
+ else
+ {
+ if (NoCaseCompare(CompoGenName, "biomal") != 0)
+ {
+ LOGWARN("Unknown CompositionGen \"%s\", using \"biomal\" instead.", CompoGenName.c_str());
+ }
+ int SeaLevel = a_IniFile.GetValueSetI("Generator", "BiomalSeaLevel", 62);
+ int Seed = m_ChunkGenerator.GetSeed();
+ m_CompositionGen = new cCompoGenBiomal(Seed, SeaLevel);
+
+ /*
+ // Performance-testing:
+ LOGINFO("Measuring performance of cCompoGenBiomal...");
+ clock_t BeginTick = clock();
+ for (int x = 0; x < 500; x++)
+ {
+ cChunkDesc Desc(200 + x * 8, 200 + x * 8);
+ m_BiomeGen->GenBiomes(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetBiomeMap());
+ m_HeightGen->GenHeightMap(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetHeightMap());
+ m_CompositionGen->ComposeTerrain(Desc);
+ }
+ clock_t Duration = clock() - BeginTick;
+ LOGINFO("CompositionGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
+ //*/
+ }
+
+ int CompoGenCacheSize = a_IniFile.GetValueSetI("Generator", "CompositionGenCacheSize", 64);
+ if (CompoGenCacheSize > 1)
+ {
+ m_UnderlyingCompositionGen = m_CompositionGen;
+ m_CompositionGen = new cCompoGenCache(m_UnderlyingCompositionGen, 32);
+ }
+}
+
+
+
+
+
+void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
+{
+ AString Structures = a_IniFile.GetValueSet("Generator", "Structures", "Ravines, WormNestCaves, WaterLakes, LavaLakes, OreNests, Trees");
+
+ int Seed = m_ChunkGenerator.GetSeed();
+ AStringVector Str = StringSplitAndTrim(Structures, ",");
+ for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
+ {
+ if (NoCaseCompare(*itr, "DualRidgeCaves") == 0)
+ {
+ float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3);
+ m_StructureGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold));
+ }
+ else if (NoCaseCompare(*itr, "DirectOverhangs") == 0)
+ {
+ m_StructureGens.push_back(new cStructGenDirectOverhangs(Seed));
+ }
+ else if (NoCaseCompare(*itr, "DistortedMembraneOverhangs") == 0)
+ {
+ m_StructureGens.push_back(new cStructGenDistortedMembraneOverhangs(Seed));
+ }
+ else if (NoCaseCompare(*itr, "LavaLakes") == 0)
+ {
+ int Probability = a_IniFile.GetValueSetI("Generator", "LavaLakesProbability", 10);
+ m_StructureGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen, Probability));
+ }
+ else if (NoCaseCompare(*itr, "MarbleCaves") == 0)
+ {
+ m_StructureGens.push_back(new cStructGenMarbleCaves(Seed));
+ }
+ else if (NoCaseCompare(*itr, "MineShafts") == 0)
+ {
+ int GridSize = a_IniFile.GetValueSetI("Generator", "MineShaftsGridSize", 512);
+ 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_StructureGens.push_back(new cStructGenMineShafts(
+ Seed, GridSize, MaxSystemSize,
+ ChanceCorridor, ChanceCrossing, ChanceStaircase
+ ));
+ }
+ else if (NoCaseCompare(*itr, "OreNests") == 0)
+ {
+ m_StructureGens.push_back(new cStructGenOreNests(Seed));
+ }
+ else if (NoCaseCompare(*itr, "Ravines") == 0)
+ {
+ m_StructureGens.push_back(new cStructGenRavines(Seed, 128));
+ }
+ else if (NoCaseCompare(*itr, "Trees") == 0)
+ {
+ m_StructureGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen));
+ }
+ else if (NoCaseCompare(*itr, "WaterLakes") == 0)
+ {
+ int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
+ m_StructureGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen, Probability));
+ }
+ else if (NoCaseCompare(*itr, "WormNestCaves") == 0)
+ {
+ m_StructureGens.push_back(new cStructGenWormNestCaves(Seed));
+ }
+ else
+ {
+ LOGWARNING("Unknown structure generator: \"%s\". Ignoring.", itr->c_str());
+ }
+ } // for itr - Str[]
+}
+
+
+
+
+
+void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
+{
+ int Seed = m_ChunkGenerator.GetSeed();
+ AString Structures = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator");
+
+ AStringVector Str = StringSplitAndTrim(Structures, ",");
+ for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
+ {
+ // Finishers, alpha-sorted:
+ if (NoCaseCompare(*itr, "BottomLava") == 0)
+ {
+ int DefaultBottomLavaLevel = (m_World->GetDimension() == dimNether) ? 30 : 10;
+ int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel);
+ m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
+ }
+ 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));
+ }
+ else if (NoCaseCompare(*itr, "Ice") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenIce);
+ }
+ else if (NoCaseCompare(*itr, "LavaSprings") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, *m_World));
+ }
+ 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));
+ }
+ else if (NoCaseCompare(*itr, "PreSimulator") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenPreSimulator);
+ }
+ else if (NoCaseCompare(*itr, "Snow") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenSnow);
+ }
+ else if (NoCaseCompare(*itr, "SprinkleFoliage") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed));
+ }
+ else if (NoCaseCompare(*itr, "WaterSprings") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_WATER, a_IniFile, *m_World));
+ }
+ } // for itr - Str[]
+}
+
+
+
+
diff --git a/source/Generating/ComposableGenerator.h b/source/Generating/ComposableGenerator.h
index c32e7181f..1d5c98e5d 100644
--- a/source/Generating/ComposableGenerator.h
+++ b/source/Generating/ComposableGenerator.h
@@ -1,175 +1,175 @@
-
-// ComposableGenerator.h
-
-// Declares the cComposableGenerator class representing the chunk generator that takes the composition approach to generating chunks
-
-/*
-Generating works by composing several algorithms:
-Biome, TerrainHeight, TerrainComposition, Ores, Structures and SmallFoliage
-Each algorithm may be chosen from a pool of available algorithms in the same class and combined with others,
-based on user's preferences in the world.ini.
-See http://forum.mc-server.org/showthread.php?tid=409 for details.
-*/
-
-
-
-
-
-#pragma once
-
-#include "ChunkGenerator.h"
-#include "ChunkDesc.h"
-
-
-
-
-
-// fwd: Noise3DGenerator.h
-class cNoise3DComposable;
-
-// fwd: DistortedHeightmap.h
-class cDistortedHeightmap;
-
-
-
-
-
-/** The interface that a biome generator must implement
-A biome generator takes chunk coords on input and outputs an array of biome indices for that chunk on output.
-The output array is sequenced in the same way as the MapChunk packet's biome data.
-*/
-class cBiomeGen
-{
-public:
- virtual ~cBiomeGen() {} // Force a virtual destructor in descendants
-
- /// Generates biomes for the given chunk
- virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) = 0;
-
- /// Reads parameters from the ini file, prepares generator for use.
- virtual void Initialize(cIniFile & a_IniFile) {}
-} ;
-
-
-
-
-
-/** The interface that a terrain height generator must implement
-A terrain height generator takes chunk coords on input and outputs an array of terrain heights for that chunk.
-The output array is sequenced in the same way as the BiomeGen's biome data.
-The generator may request biome information from the underlying BiomeGen, it may even request information for
-other chunks than the one it's currently generating (possibly neighbors - for averaging)
-*/
-class cTerrainHeightGen
-{
-public:
- virtual ~cTerrainHeightGen() {} // Force a virtual destructor in descendants
-
- /// Generates heightmap for the given chunk
- virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) = 0;
-} ;
-
-
-
-
-
-/** The interface that a terrain composition generator must implement
-Terrain composition takes chunk coords on input and outputs the blockdata for that entire chunk, along with
-the list of entities. It is supposed to make use of the underlying TerrainHeightGen and BiomeGen for that purpose,
-but it may request information for other chunks than the one it's currently generating from them.
-*/
-class cTerrainCompositionGen
-{
-public:
- virtual ~cTerrainCompositionGen() {} // Force a virtual destructor in descendants
-
- virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) = 0;
-} ;
-
-
-
-
-
-/** The interface that a structure generator must implement
-Structures are generated after the terrain composition took place. It should modify the blocktype data to account
-for whatever structures the generator is generating.
-Note that ores are considered structures too, at least from the interface point of view.
-Also note that a worldgenerator may contain multiple structure generators, one for each type of structure
-*/
-class cStructureGen
-{
-public:
- virtual ~cStructureGen() {} // Force a virtual destructor in descendants
-
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) = 0;
-} ;
-
-typedef std::list<cStructureGen *> cStructureGenList;
-
-
-
-
-
-/** The interface that a finisher must implement
-Finisher implements small additions after all structures have been generated.
-*/
-class cFinishGen
-{
-public:
- virtual ~cFinishGen() {} // Force a virtual destructor in descendants
-
- virtual void GenFinish(cChunkDesc & a_ChunkDesc) = 0;
-} ;
-
-typedef std::list<cFinishGen *> cFinishGenList;
-
-
-
-
-
-class cComposableGenerator :
- public cChunkGenerator::cGenerator
-{
- typedef cChunkGenerator::cGenerator super;
-
-public:
- cComposableGenerator(cChunkGenerator & a_ChunkGenerator);
- virtual ~cComposableGenerator();
-
- virtual void Initialize(cWorld * a_World, cIniFile & a_IniFile) override;
- virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
- virtual void DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) override;
-
-protected:
- // The generation composition:
- cBiomeGen * m_BiomeGen;
- cTerrainHeightGen * m_HeightGen;
- cTerrainCompositionGen * m_CompositionGen;
- cStructureGenList m_StructureGens;
- cFinishGenList m_FinishGens;
-
- // Generators underlying the caches:
- cBiomeGen * m_UnderlyingBiomeGen;
- cTerrainHeightGen * m_UnderlyingHeightGen;
- cTerrainCompositionGen * m_UnderlyingCompositionGen;
-
-
- /// Reads the biome gen settings from the ini and initializes m_BiomeGen accordingly
- void InitBiomeGen(cIniFile & a_IniFile);
-
- /// Reads the HeightGen settings from the ini and initializes m_HeightGen accordingly
- void InitHeightGen(cIniFile & a_IniFile);
-
- /// Reads the CompositionGen settings from the ini and initializes m_CompositionGen accordingly
- void InitCompositionGen(cIniFile & a_IniFile);
-
- /// Reads the structures to generate from the ini and initializes m_StructureGens accordingly
- void InitStructureGens(cIniFile & a_IniFile);
-
- /// Reads the finishers from the ini and initializes m_FinishGens accordingly
- void InitFinishGens(cIniFile & a_IniFile);
-} ;
-
-
-
-
+
+// ComposableGenerator.h
+
+// Declares the cComposableGenerator class representing the chunk generator that takes the composition approach to generating chunks
+
+/*
+Generating works by composing several algorithms:
+Biome, TerrainHeight, TerrainComposition, Ores, Structures and SmallFoliage
+Each algorithm may be chosen from a pool of available algorithms in the same class and combined with others,
+based on user's preferences in the world.ini.
+See http://forum.mc-server.org/showthread.php?tid=409 for details.
+*/
+
+
+
+
+
+#pragma once
+
+#include "ChunkGenerator.h"
+#include "ChunkDesc.h"
+
+
+
+
+
+// fwd: Noise3DGenerator.h
+class cNoise3DComposable;
+
+// fwd: DistortedHeightmap.h
+class cDistortedHeightmap;
+
+
+
+
+
+/** The interface that a biome generator must implement
+A biome generator takes chunk coords on input and outputs an array of biome indices for that chunk on output.
+The output array is sequenced in the same way as the MapChunk packet's biome data.
+*/
+class cBiomeGen
+{
+public:
+ virtual ~cBiomeGen() {} // Force a virtual destructor in descendants
+
+ /// Generates biomes for the given chunk
+ virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) = 0;
+
+ /// Reads parameters from the ini file, prepares generator for use.
+ virtual void Initialize(cIniFile & a_IniFile) {}
+} ;
+
+
+
+
+
+/** The interface that a terrain height generator must implement
+A terrain height generator takes chunk coords on input and outputs an array of terrain heights for that chunk.
+The output array is sequenced in the same way as the BiomeGen's biome data.
+The generator may request biome information from the underlying BiomeGen, it may even request information for
+other chunks than the one it's currently generating (possibly neighbors - for averaging)
+*/
+class cTerrainHeightGen
+{
+public:
+ virtual ~cTerrainHeightGen() {} // Force a virtual destructor in descendants
+
+ /// Generates heightmap for the given chunk
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) = 0;
+} ;
+
+
+
+
+
+/** The interface that a terrain composition generator must implement
+Terrain composition takes chunk coords on input and outputs the blockdata for that entire chunk, along with
+the list of entities. It is supposed to make use of the underlying TerrainHeightGen and BiomeGen for that purpose,
+but it may request information for other chunks than the one it's currently generating from them.
+*/
+class cTerrainCompositionGen
+{
+public:
+ virtual ~cTerrainCompositionGen() {} // Force a virtual destructor in descendants
+
+ virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) = 0;
+} ;
+
+
+
+
+
+/** The interface that a structure generator must implement
+Structures are generated after the terrain composition took place. It should modify the blocktype data to account
+for whatever structures the generator is generating.
+Note that ores are considered structures too, at least from the interface point of view.
+Also note that a worldgenerator may contain multiple structure generators, one for each type of structure
+*/
+class cStructureGen
+{
+public:
+ virtual ~cStructureGen() {} // Force a virtual destructor in descendants
+
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) = 0;
+} ;
+
+typedef std::list<cStructureGen *> cStructureGenList;
+
+
+
+
+
+/** The interface that a finisher must implement
+Finisher implements small additions after all structures have been generated.
+*/
+class cFinishGen
+{
+public:
+ virtual ~cFinishGen() {} // Force a virtual destructor in descendants
+
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) = 0;
+} ;
+
+typedef std::list<cFinishGen *> cFinishGenList;
+
+
+
+
+
+class cComposableGenerator :
+ public cChunkGenerator::cGenerator
+{
+ typedef cChunkGenerator::cGenerator super;
+
+public:
+ cComposableGenerator(cChunkGenerator & a_ChunkGenerator);
+ virtual ~cComposableGenerator();
+
+ virtual void Initialize(cWorld * a_World, cIniFile & a_IniFile) override;
+ virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
+ virtual void DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) override;
+
+protected:
+ // The generation composition:
+ cBiomeGen * m_BiomeGen;
+ cTerrainHeightGen * m_HeightGen;
+ cTerrainCompositionGen * m_CompositionGen;
+ cStructureGenList m_StructureGens;
+ cFinishGenList m_FinishGens;
+
+ // Generators underlying the caches:
+ cBiomeGen * m_UnderlyingBiomeGen;
+ cTerrainHeightGen * m_UnderlyingHeightGen;
+ cTerrainCompositionGen * m_UnderlyingCompositionGen;
+
+
+ /// Reads the biome gen settings from the ini and initializes m_BiomeGen accordingly
+ void InitBiomeGen(cIniFile & a_IniFile);
+
+ /// Reads the HeightGen settings from the ini and initializes m_HeightGen accordingly
+ void InitHeightGen(cIniFile & a_IniFile);
+
+ /// Reads the CompositionGen settings from the ini and initializes m_CompositionGen accordingly
+ void InitCompositionGen(cIniFile & a_IniFile);
+
+ /// Reads the structures to generate from the ini and initializes m_StructureGens accordingly
+ void InitStructureGens(cIniFile & a_IniFile);
+
+ /// Reads the finishers from the ini and initializes m_FinishGens accordingly
+ void InitFinishGens(cIniFile & a_IniFile);
+} ;
+
+
+
+
diff --git a/source/Generating/DistortedHeightmap.cpp b/source/Generating/DistortedHeightmap.cpp
index 5efc27895..6ac4d61d5 100644
--- a/source/Generating/DistortedHeightmap.cpp
+++ b/source/Generating/DistortedHeightmap.cpp
@@ -1,419 +1,419 @@
-
-// DistortedHeightmap.cpp
-
-// Implements the cDistortedHeightmap class representing the height and composition generator capable of overhangs
-
-#include "Globals.h"
-
-#include "DistortedHeightmap.h"
-#include "../OSSupport/File.h"
-#include "../../iniFile/iniFile.h"
-#include "../LinearUpscale.h"
-
-
-
-
-
-/** This table assigns a relative maximum overhang size in each direction to biomes.
-Both numbers indicate a number which will multiply the noise value for each coord;
-this means that you can have different-sized overhangs in each direction.
-Usually you'd want to keep both numbers the same.
-The numbers are "relative", not absolute maximum; overhangs of a slightly larger size are possible
-due to the way that noise is calculated.
-*/
-const cDistortedHeightmap::sGenParam cDistortedHeightmap::m_GenParam[biNumBiomes] =
-{
- /* Biome | AmpX | AmpZ */
- /* biOcean */ { 1.5f, 1.5f},
- /* biPlains */ { 0.5f, 0.5f},
- /* biDesert */ { 0.5f, 0.5f},
- /* biExtremeHills */ {16.0f, 16.0f},
- /* biForest */ { 3.0f, 3.0f},
- /* biTaiga */ { 1.5f, 1.5f},
-
- /* biSwampland */ { 0.0f, 0.0f},
- /* biRiver */ { 0.0f, 0.0f},
- /* biNether */ { 0.0f, 0.0f}, // Unused, but must be here due to indexing
- /* biSky */ { 0.0f, 0.0f}, // Unused, but must be here due to indexing
- /* biFrozenOcean */ { 0.0f, 0.0f},
- /* biFrozenRiver */ { 0.0f, 0.0f},
- /* biIcePlains */ { 0.0f, 0.0f},
- /* biIceMountains */ { 8.0f, 8.0f},
- /* biMushroomIsland */ { 4.0f, 4.0f},
- /* biMushroomShore */ { 0.0f, 0.0f},
- /* biBeach */ { 0.0f, 0.0f},
- /* biDesertHills */ { 5.0f, 5.0f},
- /* biForestHills */ { 6.0f, 6.0f},
- /* biTaigaHills */ { 8.0f, 8.0f},
- /* biExtremeHillsEdge */ { 7.0f, 7.0f},
- /* biJungle */ { 0.0f, 0.0f},
- /* biJungleHills */ { 8.0f, 8.0f},
-} ;
-
-
-
-
-
-cDistortedHeightmap::cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen) :
- m_NoiseDistortX(a_Seed + 1000),
- m_NoiseDistortZ(a_Seed + 2000),
- m_OceanFloorSelect(a_Seed + 3000),
- m_BiomeGen(a_BiomeGen),
- m_UnderlyingHeiGen(a_Seed, a_BiomeGen),
- m_HeightGen(&m_UnderlyingHeiGen, 64)
-{
- m_NoiseDistortX.AddOctave((NOISE_DATATYPE)1, (NOISE_DATATYPE)0.5);
- m_NoiseDistortX.AddOctave((NOISE_DATATYPE)0.5, (NOISE_DATATYPE)1);
- m_NoiseDistortX.AddOctave((NOISE_DATATYPE)0.25, (NOISE_DATATYPE)2);
-
- m_NoiseDistortZ.AddOctave((NOISE_DATATYPE)1, (NOISE_DATATYPE)0.5);
- m_NoiseDistortZ.AddOctave((NOISE_DATATYPE)0.5, (NOISE_DATATYPE)1);
- m_NoiseDistortZ.AddOctave((NOISE_DATATYPE)0.25, (NOISE_DATATYPE)2);
-}
-
-
-
-
-
-void cDistortedHeightmap::Initialize(cIniFile & a_IniFile)
-{
- // Read the params from the INI file:
- m_SeaLevel = a_IniFile.GetValueSetI("Generator", "DistortedHeightmapSeaLevel", 62);
- m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyX", 10);
- m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyY", 10);
- m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyZ", 10);
-}
-
-
-
-
-
-void cDistortedHeightmap::PrepareState(int a_ChunkX, int a_ChunkZ)
-{
- if ((m_CurChunkX == a_ChunkX) && (m_CurChunkZ == a_ChunkZ))
- {
- return;
- }
- m_CurChunkX = a_ChunkX;
- m_CurChunkZ = a_ChunkZ;
-
-
- m_HeightGen.GenHeightMap(a_ChunkX, a_ChunkZ, m_CurChunkHeights);
- UpdateDistortAmps();
- GenerateHeightArray();
-}
-
-
-
-
-
-void cDistortedHeightmap::GenerateHeightArray(void)
-{
- // Generate distortion noise:
- NOISE_DATATYPE DistortNoiseX[DIM_X * DIM_Y * DIM_Z];
- NOISE_DATATYPE DistortNoiseZ[DIM_X * DIM_Y * DIM_Z];
- NOISE_DATATYPE Workspace[DIM_X * DIM_Y * DIM_Z];
- NOISE_DATATYPE StartX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width)) / m_FrequencyX;
- NOISE_DATATYPE EndX = ((NOISE_DATATYPE)((m_CurChunkX + 1) * cChunkDef::Width - 1)) / m_FrequencyX;
- NOISE_DATATYPE StartY = 0;
- NOISE_DATATYPE EndY = ((NOISE_DATATYPE)(257)) / m_FrequencyY;
- NOISE_DATATYPE StartZ = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width)) / m_FrequencyZ;
- NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((m_CurChunkZ + 1) * cChunkDef::Width - 1)) / m_FrequencyZ;
-
- m_NoiseDistortX.Generate3D(DistortNoiseX, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, Workspace);
- m_NoiseDistortZ.Generate3D(DistortNoiseZ, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, Workspace);
-
- // The distorted heightmap, before linear upscaling
- NOISE_DATATYPE DistHei[DIM_X * DIM_Y * DIM_Z];
-
- // Distort the heightmap using the distortion:
- for (int z = 0; z < DIM_Z; z++)
- {
- int AmpIdx = z * DIM_X;
- for (int y = 0; y < DIM_Y; y++)
- {
- int NoiseArrayIdx = z * DIM_X * DIM_Y + y * DIM_X;
- for (int x = 0; x < DIM_X; x++)
- {
- NOISE_DATATYPE DistX = DistortNoiseX[NoiseArrayIdx + x] * m_DistortAmpX[AmpIdx + x];
- NOISE_DATATYPE DistZ = DistortNoiseZ[NoiseArrayIdx + x] * m_DistortAmpZ[AmpIdx + x];
- DistX += (NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + x * INTERPOL_X);
- DistZ += (NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + z * INTERPOL_Z);
- // Adding 0.5 helps alleviate the interpolation artifacts
- DistHei[NoiseArrayIdx + x] = (NOISE_DATATYPE)GetHeightmapAt(DistX, DistZ) + (NOISE_DATATYPE)0.5;
- }
- }
- }
-
- // Upscale the distorted heightmap into full dimensions:
- LinearUpscale3DArray(
- DistHei, DIM_X, DIM_Y, DIM_Z,
- m_DistortedHeightmap, INTERPOL_X, INTERPOL_Y, INTERPOL_Z
- );
-
- // DEBUG: Debug3DNoise(m_DistortedHeightmap, 17, 257, 17, Printf("DistortedHeightmap_%d_%d", m_CurChunkX, m_CurChunkZ));
-}
-
-
-
-
-
-void cDistortedHeightmap::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
-{
- PrepareState(a_ChunkX, a_ChunkZ);
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- int NoiseArrayIdx = x + 17 * 257 * z;
- cChunkDef::SetHeight(a_HeightMap, x, z, m_SeaLevel - 1);
- for (int y = cChunkDef::Height - 1; y > m_SeaLevel - 1; y--)
- {
- int HeightMapHeight = (int)m_DistortedHeightmap[NoiseArrayIdx + 17 * y];
- if (y < HeightMapHeight)
- {
- cChunkDef::SetHeight(a_HeightMap, x, z, y);
- break;
- }
- } // for y
- } // for x
- } // for z
-}
-
-
-
-
-
-void cDistortedHeightmap::ComposeTerrain(cChunkDesc & a_ChunkDesc)
-{
- // Frequencies for the ocean floor selecting noise:
- NOISE_DATATYPE FrequencyX = 3;
- NOISE_DATATYPE FrequencyZ = 3;
-
- // Prepare the internal state for generating this chunk:
- PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
-
- // Compose:
- a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- int NoiseArrayIdx = x + 17 * 257 * z;
- int LastAir = a_ChunkDesc.GetHeight(x, z) + 1;
- bool HasHadWater = false;
- for (int y = LastAir - 1; y > 0; y--)
- {
- int HeightMapHeight = (int)m_DistortedHeightmap[NoiseArrayIdx + 17 * y];
-
- if (y >= HeightMapHeight)
- {
- // "air" part
- LastAir = y;
- if (y < m_SeaLevel)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STATIONARY_WATER);
- HasHadWater = true;
- }
- continue;
- }
- // "ground" part:
- if (y < LastAir - 4)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STONE);
- continue;
- }
- if (HasHadWater)
- {
- // Decide between clay, sand and dirt
- NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + x)) / FrequencyX;
- NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + z)) / FrequencyZ;
- NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY);
- if (Val < -0.95)
- {
- // Clay:
- switch (LastAir - y)
- {
- case 0:
- case 1:
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_CLAY);
- break;
- }
- case 2:
- case 3:
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SAND);
- break;
- }
- case 4:
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SANDSTONE);
- break;
- }
- } // switch (floor depth)
- }
- else if (Val < 0)
- {
- a_ChunkDesc.SetBlockType(x, y, z, (y < LastAir - 3) ? E_BLOCK_SANDSTONE : E_BLOCK_SAND);
- }
- else
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_DIRT);
- }
- }
- else
- {
- switch (a_ChunkDesc.GetBiome(x, z))
- {
- case biOcean:
- case biPlains:
- case biExtremeHills:
- case biForest:
- case biTaiga:
- case biSwampland:
- case biRiver:
- case biFrozenOcean:
- case biFrozenRiver:
- case biIcePlains:
- case biIceMountains:
- case biForestHills:
- case biTaigaHills:
- case biExtremeHillsEdge:
- case biJungle:
- case biJungleHills:
- {
- a_ChunkDesc.SetBlockType(x, y, z, (y == LastAir - 1) ? E_BLOCK_GRASS : E_BLOCK_DIRT);
- break;
- }
- case biDesertHills:
- case biDesert:
- case biBeach:
- {
- a_ChunkDesc.SetBlockType(x, y, z, (y < LastAir - 3) ? E_BLOCK_SANDSTONE : E_BLOCK_SAND);
- break;
- }
- case biMushroomIsland:
- case biMushroomShore:
- {
- a_ChunkDesc.SetBlockType(x, y, z, (y == LastAir - 1) ? E_BLOCK_MYCELIUM : E_BLOCK_DIRT);
- break;
- }
- }
- }
- } // for y
- a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK);
- } // for x
- } // for z
-}
-
-
-
-
-
-int cDistortedHeightmap::GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z)
-{
- int ChunkX = (int)floor(a_X / (NOISE_DATATYPE)16);
- int ChunkZ = (int)floor(a_Z / (NOISE_DATATYPE)16);
- int RelX = (int)(a_X - (NOISE_DATATYPE)ChunkX * cChunkDef::Width);
- int RelZ = (int)(a_Z - (NOISE_DATATYPE)ChunkZ * cChunkDef::Width);
-
- // If we're withing the same chunk, return the pre-cached heightmap:
- if ((ChunkX == m_CurChunkX) && (ChunkZ == m_CurChunkZ))
- {
- return cChunkDef::GetHeight(m_CurChunkHeights, RelX, RelZ);
- }
-
- // Ask the cache:
- HEIGHTTYPE res = 0;
- if (m_HeightGen.GetHeightAt(ChunkX, ChunkZ, RelX, RelZ, res))
- {
- // The height was in the cache
- return res;
- }
-
- // The height is not in the cache, generate full heightmap and get it there:
- cChunkDef::HeightMap Heightmap;
- m_HeightGen.GenHeightMap(ChunkX, ChunkZ, Heightmap);
- return cChunkDef::GetHeight(Heightmap, RelX, RelZ);
-}
-
-
-
-
-
-void cDistortedHeightmap::UpdateDistortAmps(void)
-{
- BiomeNeighbors Biomes;
- for (int z = -1; z <= 1; z++)
- {
- for (int x = -1; x <= 1; x++)
- {
- m_BiomeGen.GenBiomes(m_CurChunkX + x, m_CurChunkZ + z, Biomes[x + 1][z + 1]);
- } // for x
- } // for z
-
- for (int z = 0; z < DIM_Z; z++)
- {
- for (int x = 0; x < DIM_Z; x++)
- {
- GetDistortAmpsAt(Biomes, x * INTERPOL_X, z * INTERPOL_Z, m_DistortAmpX[x + DIM_X * z], m_DistortAmpZ[x + DIM_X * z]);
- }
- }
-}
-
-
-
-
-
-void cDistortedHeightmap::GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_RelX, int a_RelZ, NOISE_DATATYPE & a_DistortAmpX, NOISE_DATATYPE & a_DistortAmpZ)
-{
- // Sum up how many biomes of each type there are in the neighborhood:
- int BiomeCounts[biNumBiomes];
- memset(BiomeCounts, 0, sizeof(BiomeCounts));
- int Sum = 0;
- for (int z = -8; z <= 8; z++)
- {
- int FinalZ = a_RelZ + z + cChunkDef::Width;
- int IdxZ = FinalZ / cChunkDef::Width;
- int ModZ = FinalZ % cChunkDef::Width;
- int WeightZ = 9 - abs(z);
- for (int x = -8; x <= 8; x++)
- {
- int FinalX = a_RelX + x + cChunkDef::Width;
- int IdxX = FinalX / cChunkDef::Width;
- int ModX = FinalX % cChunkDef::Width;
- EMCSBiome Biome = cChunkDef::GetBiome(a_Neighbors[IdxX][IdxZ], ModX, ModZ);
- if ((Biome < 0) || (Biome >= ARRAYCOUNT(BiomeCounts)))
- {
- continue;
- }
- int WeightX = 9 - abs(x);
- BiomeCounts[Biome] += WeightX + WeightZ;
- Sum += WeightX + WeightZ;
- } // for x
- } // for z
-
- if (Sum <= 0)
- {
- // No known biome around? Weird. Return a bogus value:
- ASSERT(!"cHeiGenBiomal: Biome sum failed, no known biome around");
- a_DistortAmpX = 16;
- a_DistortAmpZ = 16;
- }
-
- // For each biome type that has a nonzero count, calc its amps and add it:
- NOISE_DATATYPE AmpX = 0;
- NOISE_DATATYPE AmpZ = 0;
- for (int i = 0; i < ARRAYCOUNT(BiomeCounts); i++)
- {
- AmpX += BiomeCounts[i] * m_GenParam[i].m_DistortAmpX;
- AmpZ += BiomeCounts[i] * m_GenParam[i].m_DistortAmpZ;
- }
- a_DistortAmpX = AmpX / Sum;
- a_DistortAmpZ = AmpZ / Sum;
-}
-
-
-
-
+
+// DistortedHeightmap.cpp
+
+// Implements the cDistortedHeightmap class representing the height and composition generator capable of overhangs
+
+#include "Globals.h"
+
+#include "DistortedHeightmap.h"
+#include "../OSSupport/File.h"
+#include "../../iniFile/iniFile.h"
+#include "../LinearUpscale.h"
+
+
+
+
+
+/** This table assigns a relative maximum overhang size in each direction to biomes.
+Both numbers indicate a number which will multiply the noise value for each coord;
+this means that you can have different-sized overhangs in each direction.
+Usually you'd want to keep both numbers the same.
+The numbers are "relative", not absolute maximum; overhangs of a slightly larger size are possible
+due to the way that noise is calculated.
+*/
+const cDistortedHeightmap::sGenParam cDistortedHeightmap::m_GenParam[biNumBiomes] =
+{
+ /* Biome | AmpX | AmpZ */
+ /* biOcean */ { 1.5f, 1.5f},
+ /* biPlains */ { 0.5f, 0.5f},
+ /* biDesert */ { 0.5f, 0.5f},
+ /* biExtremeHills */ {16.0f, 16.0f},
+ /* biForest */ { 3.0f, 3.0f},
+ /* biTaiga */ { 1.5f, 1.5f},
+
+ /* biSwampland */ { 0.0f, 0.0f},
+ /* biRiver */ { 0.0f, 0.0f},
+ /* biNether */ { 0.0f, 0.0f}, // Unused, but must be here due to indexing
+ /* biSky */ { 0.0f, 0.0f}, // Unused, but must be here due to indexing
+ /* biFrozenOcean */ { 0.0f, 0.0f},
+ /* biFrozenRiver */ { 0.0f, 0.0f},
+ /* biIcePlains */ { 0.0f, 0.0f},
+ /* biIceMountains */ { 8.0f, 8.0f},
+ /* biMushroomIsland */ { 4.0f, 4.0f},
+ /* biMushroomShore */ { 0.0f, 0.0f},
+ /* biBeach */ { 0.0f, 0.0f},
+ /* biDesertHills */ { 5.0f, 5.0f},
+ /* biForestHills */ { 6.0f, 6.0f},
+ /* biTaigaHills */ { 8.0f, 8.0f},
+ /* biExtremeHillsEdge */ { 7.0f, 7.0f},
+ /* biJungle */ { 0.0f, 0.0f},
+ /* biJungleHills */ { 8.0f, 8.0f},
+} ;
+
+
+
+
+
+cDistortedHeightmap::cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen) :
+ m_NoiseDistortX(a_Seed + 1000),
+ m_NoiseDistortZ(a_Seed + 2000),
+ m_OceanFloorSelect(a_Seed + 3000),
+ m_BiomeGen(a_BiomeGen),
+ m_UnderlyingHeiGen(a_Seed, a_BiomeGen),
+ m_HeightGen(&m_UnderlyingHeiGen, 64)
+{
+ m_NoiseDistortX.AddOctave((NOISE_DATATYPE)1, (NOISE_DATATYPE)0.5);
+ m_NoiseDistortX.AddOctave((NOISE_DATATYPE)0.5, (NOISE_DATATYPE)1);
+ m_NoiseDistortX.AddOctave((NOISE_DATATYPE)0.25, (NOISE_DATATYPE)2);
+
+ m_NoiseDistortZ.AddOctave((NOISE_DATATYPE)1, (NOISE_DATATYPE)0.5);
+ m_NoiseDistortZ.AddOctave((NOISE_DATATYPE)0.5, (NOISE_DATATYPE)1);
+ m_NoiseDistortZ.AddOctave((NOISE_DATATYPE)0.25, (NOISE_DATATYPE)2);
+}
+
+
+
+
+
+void cDistortedHeightmap::Initialize(cIniFile & a_IniFile)
+{
+ // Read the params from the INI file:
+ m_SeaLevel = a_IniFile.GetValueSetI("Generator", "DistortedHeightmapSeaLevel", 62);
+ m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyX", 10);
+ m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyY", 10);
+ m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyZ", 10);
+}
+
+
+
+
+
+void cDistortedHeightmap::PrepareState(int a_ChunkX, int a_ChunkZ)
+{
+ if ((m_CurChunkX == a_ChunkX) && (m_CurChunkZ == a_ChunkZ))
+ {
+ return;
+ }
+ m_CurChunkX = a_ChunkX;
+ m_CurChunkZ = a_ChunkZ;
+
+
+ m_HeightGen.GenHeightMap(a_ChunkX, a_ChunkZ, m_CurChunkHeights);
+ UpdateDistortAmps();
+ GenerateHeightArray();
+}
+
+
+
+
+
+void cDistortedHeightmap::GenerateHeightArray(void)
+{
+ // Generate distortion noise:
+ NOISE_DATATYPE DistortNoiseX[DIM_X * DIM_Y * DIM_Z];
+ NOISE_DATATYPE DistortNoiseZ[DIM_X * DIM_Y * DIM_Z];
+ NOISE_DATATYPE Workspace[DIM_X * DIM_Y * DIM_Z];
+ NOISE_DATATYPE StartX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width)) / m_FrequencyX;
+ NOISE_DATATYPE EndX = ((NOISE_DATATYPE)((m_CurChunkX + 1) * cChunkDef::Width - 1)) / m_FrequencyX;
+ NOISE_DATATYPE StartY = 0;
+ NOISE_DATATYPE EndY = ((NOISE_DATATYPE)(257)) / m_FrequencyY;
+ NOISE_DATATYPE StartZ = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width)) / m_FrequencyZ;
+ NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((m_CurChunkZ + 1) * cChunkDef::Width - 1)) / m_FrequencyZ;
+
+ m_NoiseDistortX.Generate3D(DistortNoiseX, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, Workspace);
+ m_NoiseDistortZ.Generate3D(DistortNoiseZ, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, Workspace);
+
+ // The distorted heightmap, before linear upscaling
+ NOISE_DATATYPE DistHei[DIM_X * DIM_Y * DIM_Z];
+
+ // Distort the heightmap using the distortion:
+ for (int z = 0; z < DIM_Z; z++)
+ {
+ int AmpIdx = z * DIM_X;
+ for (int y = 0; y < DIM_Y; y++)
+ {
+ int NoiseArrayIdx = z * DIM_X * DIM_Y + y * DIM_X;
+ for (int x = 0; x < DIM_X; x++)
+ {
+ NOISE_DATATYPE DistX = DistortNoiseX[NoiseArrayIdx + x] * m_DistortAmpX[AmpIdx + x];
+ NOISE_DATATYPE DistZ = DistortNoiseZ[NoiseArrayIdx + x] * m_DistortAmpZ[AmpIdx + x];
+ DistX += (NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + x * INTERPOL_X);
+ DistZ += (NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + z * INTERPOL_Z);
+ // Adding 0.5 helps alleviate the interpolation artifacts
+ DistHei[NoiseArrayIdx + x] = (NOISE_DATATYPE)GetHeightmapAt(DistX, DistZ) + (NOISE_DATATYPE)0.5;
+ }
+ }
+ }
+
+ // Upscale the distorted heightmap into full dimensions:
+ LinearUpscale3DArray(
+ DistHei, DIM_X, DIM_Y, DIM_Z,
+ m_DistortedHeightmap, INTERPOL_X, INTERPOL_Y, INTERPOL_Z
+ );
+
+ // DEBUG: Debug3DNoise(m_DistortedHeightmap, 17, 257, 17, Printf("DistortedHeightmap_%d_%d", m_CurChunkX, m_CurChunkZ));
+}
+
+
+
+
+
+void cDistortedHeightmap::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
+{
+ PrepareState(a_ChunkX, a_ChunkZ);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int NoiseArrayIdx = x + 17 * 257 * z;
+ cChunkDef::SetHeight(a_HeightMap, x, z, m_SeaLevel - 1);
+ for (int y = cChunkDef::Height - 1; y > m_SeaLevel - 1; y--)
+ {
+ int HeightMapHeight = (int)m_DistortedHeightmap[NoiseArrayIdx + 17 * y];
+ if (y < HeightMapHeight)
+ {
+ cChunkDef::SetHeight(a_HeightMap, x, z, y);
+ break;
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cDistortedHeightmap::ComposeTerrain(cChunkDesc & a_ChunkDesc)
+{
+ // Frequencies for the ocean floor selecting noise:
+ NOISE_DATATYPE FrequencyX = 3;
+ NOISE_DATATYPE FrequencyZ = 3;
+
+ // Prepare the internal state for generating this chunk:
+ PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
+
+ // Compose:
+ a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int NoiseArrayIdx = x + 17 * 257 * z;
+ int LastAir = a_ChunkDesc.GetHeight(x, z) + 1;
+ bool HasHadWater = false;
+ for (int y = LastAir - 1; y > 0; y--)
+ {
+ int HeightMapHeight = (int)m_DistortedHeightmap[NoiseArrayIdx + 17 * y];
+
+ if (y >= HeightMapHeight)
+ {
+ // "air" part
+ LastAir = y;
+ if (y < m_SeaLevel)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STATIONARY_WATER);
+ HasHadWater = true;
+ }
+ continue;
+ }
+ // "ground" part:
+ if (y < LastAir - 4)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STONE);
+ continue;
+ }
+ if (HasHadWater)
+ {
+ // Decide between clay, sand and dirt
+ NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + x)) / FrequencyX;
+ NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + z)) / FrequencyZ;
+ NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY);
+ if (Val < -0.95)
+ {
+ // Clay:
+ switch (LastAir - y)
+ {
+ case 0:
+ case 1:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_CLAY);
+ break;
+ }
+ case 2:
+ case 3:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SAND);
+ break;
+ }
+ case 4:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SANDSTONE);
+ break;
+ }
+ } // switch (floor depth)
+ }
+ else if (Val < 0)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, (y < LastAir - 3) ? E_BLOCK_SANDSTONE : E_BLOCK_SAND);
+ }
+ else
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_DIRT);
+ }
+ }
+ else
+ {
+ switch (a_ChunkDesc.GetBiome(x, z))
+ {
+ case biOcean:
+ case biPlains:
+ case biExtremeHills:
+ case biForest:
+ case biTaiga:
+ case biSwampland:
+ case biRiver:
+ case biFrozenOcean:
+ case biFrozenRiver:
+ case biIcePlains:
+ case biIceMountains:
+ case biForestHills:
+ case biTaigaHills:
+ case biExtremeHillsEdge:
+ case biJungle:
+ case biJungleHills:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, (y == LastAir - 1) ? E_BLOCK_GRASS : E_BLOCK_DIRT);
+ break;
+ }
+ case biDesertHills:
+ case biDesert:
+ case biBeach:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, (y < LastAir - 3) ? E_BLOCK_SANDSTONE : E_BLOCK_SAND);
+ break;
+ }
+ case biMushroomIsland:
+ case biMushroomShore:
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, (y == LastAir - 1) ? E_BLOCK_MYCELIUM : E_BLOCK_DIRT);
+ break;
+ }
+ }
+ }
+ } // for y
+ a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK);
+ } // for x
+ } // for z
+}
+
+
+
+
+
+int cDistortedHeightmap::GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z)
+{
+ int ChunkX = (int)floor(a_X / (NOISE_DATATYPE)16);
+ int ChunkZ = (int)floor(a_Z / (NOISE_DATATYPE)16);
+ int RelX = (int)(a_X - (NOISE_DATATYPE)ChunkX * cChunkDef::Width);
+ int RelZ = (int)(a_Z - (NOISE_DATATYPE)ChunkZ * cChunkDef::Width);
+
+ // If we're withing the same chunk, return the pre-cached heightmap:
+ if ((ChunkX == m_CurChunkX) && (ChunkZ == m_CurChunkZ))
+ {
+ return cChunkDef::GetHeight(m_CurChunkHeights, RelX, RelZ);
+ }
+
+ // Ask the cache:
+ HEIGHTTYPE res = 0;
+ if (m_HeightGen.GetHeightAt(ChunkX, ChunkZ, RelX, RelZ, res))
+ {
+ // The height was in the cache
+ return res;
+ }
+
+ // The height is not in the cache, generate full heightmap and get it there:
+ cChunkDef::HeightMap Heightmap;
+ m_HeightGen.GenHeightMap(ChunkX, ChunkZ, Heightmap);
+ return cChunkDef::GetHeight(Heightmap, RelX, RelZ);
+}
+
+
+
+
+
+void cDistortedHeightmap::UpdateDistortAmps(void)
+{
+ BiomeNeighbors Biomes;
+ for (int z = -1; z <= 1; z++)
+ {
+ for (int x = -1; x <= 1; x++)
+ {
+ m_BiomeGen.GenBiomes(m_CurChunkX + x, m_CurChunkZ + z, Biomes[x + 1][z + 1]);
+ } // for x
+ } // for z
+
+ for (int z = 0; z < DIM_Z; z++)
+ {
+ for (int x = 0; x < DIM_Z; x++)
+ {
+ GetDistortAmpsAt(Biomes, x * INTERPOL_X, z * INTERPOL_Z, m_DistortAmpX[x + DIM_X * z], m_DistortAmpZ[x + DIM_X * z]);
+ }
+ }
+}
+
+
+
+
+
+void cDistortedHeightmap::GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_RelX, int a_RelZ, NOISE_DATATYPE & a_DistortAmpX, NOISE_DATATYPE & a_DistortAmpZ)
+{
+ // Sum up how many biomes of each type there are in the neighborhood:
+ int BiomeCounts[biNumBiomes];
+ memset(BiomeCounts, 0, sizeof(BiomeCounts));
+ int Sum = 0;
+ for (int z = -8; z <= 8; z++)
+ {
+ int FinalZ = a_RelZ + z + cChunkDef::Width;
+ int IdxZ = FinalZ / cChunkDef::Width;
+ int ModZ = FinalZ % cChunkDef::Width;
+ int WeightZ = 9 - abs(z);
+ for (int x = -8; x <= 8; x++)
+ {
+ int FinalX = a_RelX + x + cChunkDef::Width;
+ int IdxX = FinalX / cChunkDef::Width;
+ int ModX = FinalX % cChunkDef::Width;
+ EMCSBiome Biome = cChunkDef::GetBiome(a_Neighbors[IdxX][IdxZ], ModX, ModZ);
+ if ((Biome < 0) || (Biome >= ARRAYCOUNT(BiomeCounts)))
+ {
+ continue;
+ }
+ int WeightX = 9 - abs(x);
+ BiomeCounts[Biome] += WeightX + WeightZ;
+ Sum += WeightX + WeightZ;
+ } // for x
+ } // for z
+
+ if (Sum <= 0)
+ {
+ // No known biome around? Weird. Return a bogus value:
+ ASSERT(!"cHeiGenBiomal: Biome sum failed, no known biome around");
+ a_DistortAmpX = 16;
+ a_DistortAmpZ = 16;
+ }
+
+ // For each biome type that has a nonzero count, calc its amps and add it:
+ NOISE_DATATYPE AmpX = 0;
+ NOISE_DATATYPE AmpZ = 0;
+ for (int i = 0; i < ARRAYCOUNT(BiomeCounts); i++)
+ {
+ AmpX += BiomeCounts[i] * m_GenParam[i].m_DistortAmpX;
+ AmpZ += BiomeCounts[i] * m_GenParam[i].m_DistortAmpZ;
+ }
+ a_DistortAmpX = AmpX / Sum;
+ a_DistortAmpZ = AmpZ / Sum;
+}
+
+
+
+
diff --git a/source/Generating/DistortedHeightmap.h b/source/Generating/DistortedHeightmap.h
index 41a781b84..b2b235e61 100644
--- a/source/Generating/DistortedHeightmap.h
+++ b/source/Generating/DistortedHeightmap.h
@@ -1,102 +1,102 @@
-
-// DistortedHeightmap.h
-
-// Declares the cDistortedHeightmap class representing the height and composition generator capable of overhangs
-
-
-
-
-
-#pragma once
-
-#include "ComposableGenerator.h"
-#include "HeiGen.h"
-#include "../Noise.h"
-
-
-
-
-
-#define NOISE_SIZE_Y (257 + 32)
-
-
-
-
-
-class cDistortedHeightmap :
- public cTerrainHeightGen,
- public cTerrainCompositionGen
-{
-public:
- cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen);
-
- void Initialize(cIniFile & a_IniFile);
-
-protected:
- typedef cChunkDef::BiomeMap BiomeNeighbors[3][3];
-
- // Linear upscaling step sizes, must be divisors of cChunkDef::Width and cChunkDef::Height, respectively:
- static const int INTERPOL_X = 8;
- static const int INTERPOL_Y = 4;
- static const int INTERPOL_Z = 8;
-
- // Linear upscaling buffer dimensions, calculated from the step sizes:
- static const int DIM_X = 1 + (17 / INTERPOL_X);
- static const int DIM_Y = 1 + (257 / INTERPOL_Y);
- static const int DIM_Z = 1 + (17 / INTERPOL_Z);
-
- cPerlinNoise m_NoiseDistortX;
- cPerlinNoise m_NoiseDistortZ;
- cNoise m_OceanFloorSelect; ///< Used for selecting between dirt and sand on the ocean floor
-
- int m_SeaLevel;
- NOISE_DATATYPE m_FrequencyX;
- NOISE_DATATYPE m_FrequencyY;
- NOISE_DATATYPE m_FrequencyZ;
-
- int m_CurChunkX;
- int m_CurChunkZ;
- NOISE_DATATYPE m_DistortedHeightmap[17 * 257 * 17];
-
- cBiomeGen & m_BiomeGen;
- cHeiGenBiomal m_UnderlyingHeiGen; // This generator provides us with base heightmap (before distortion)
- cHeiGenCache m_HeightGen; // Cache above m_UnderlyingHeiGen
-
- /// Heightmap for the current chunk, before distortion (from m_HeightGen). Used for optimization.
- cChunkDef::HeightMap m_CurChunkHeights;
-
- // Per-biome terrain generator parameters:
- struct sGenParam
- {
- NOISE_DATATYPE m_DistortAmpX;
- NOISE_DATATYPE m_DistortAmpZ;
- } ;
- static const sGenParam m_GenParam[biNumBiomes];
-
- // Distortion amplitudes for each direction, before linear upscaling
- NOISE_DATATYPE m_DistortAmpX[DIM_X * DIM_Z];
- NOISE_DATATYPE m_DistortAmpZ[DIM_X * DIM_Z];
-
-
- /// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise arrays, heightmap)
- void PrepareState(int a_ChunkX, int a_ChunkZ);
-
- /// Generates the m_DistortedHeightmap array for the current chunk
- void GenerateHeightArray(void);
-
- /// Calculates the heightmap value (before distortion) at the specified (floating-point) coords
- int GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z);
-
- /// Updates m_DistortAmpX/Z[] based on m_CurChunkX and m_CurChunkZ
- void UpdateDistortAmps(void);
-
- /// Calculates the X and Z distortion amplitudes based on the neighbors' biomes
- void GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_RelX, int a_RelZ, NOISE_DATATYPE & a_DistortAmpX, NOISE_DATATYPE & a_DistortAmpZ);
-
-
- // cTerrainHeightGen overrides:
- virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
-
- // cTerrainCompositionGen overrides:
- virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
-} ;
+
+// DistortedHeightmap.h
+
+// Declares the cDistortedHeightmap class representing the height and composition generator capable of overhangs
+
+
+
+
+
+#pragma once
+
+#include "ComposableGenerator.h"
+#include "HeiGen.h"
+#include "../Noise.h"
+
+
+
+
+
+#define NOISE_SIZE_Y (257 + 32)
+
+
+
+
+
+class cDistortedHeightmap :
+ public cTerrainHeightGen,
+ public cTerrainCompositionGen
+{
+public:
+ cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen);
+
+ void Initialize(cIniFile & a_IniFile);
+
+protected:
+ typedef cChunkDef::BiomeMap BiomeNeighbors[3][3];
+
+ // Linear upscaling step sizes, must be divisors of cChunkDef::Width and cChunkDef::Height, respectively:
+ static const int INTERPOL_X = 8;
+ static const int INTERPOL_Y = 4;
+ static const int INTERPOL_Z = 8;
+
+ // Linear upscaling buffer dimensions, calculated from the step sizes:
+ static const int DIM_X = 1 + (17 / INTERPOL_X);
+ static const int DIM_Y = 1 + (257 / INTERPOL_Y);
+ static const int DIM_Z = 1 + (17 / INTERPOL_Z);
+
+ cPerlinNoise m_NoiseDistortX;
+ cPerlinNoise m_NoiseDistortZ;
+ cNoise m_OceanFloorSelect; ///< Used for selecting between dirt and sand on the ocean floor
+
+ int m_SeaLevel;
+ NOISE_DATATYPE m_FrequencyX;
+ NOISE_DATATYPE m_FrequencyY;
+ NOISE_DATATYPE m_FrequencyZ;
+
+ int m_CurChunkX;
+ int m_CurChunkZ;
+ NOISE_DATATYPE m_DistortedHeightmap[17 * 257 * 17];
+
+ cBiomeGen & m_BiomeGen;
+ cHeiGenBiomal m_UnderlyingHeiGen; // This generator provides us with base heightmap (before distortion)
+ cHeiGenCache m_HeightGen; // Cache above m_UnderlyingHeiGen
+
+ /// Heightmap for the current chunk, before distortion (from m_HeightGen). Used for optimization.
+ cChunkDef::HeightMap m_CurChunkHeights;
+
+ // Per-biome terrain generator parameters:
+ struct sGenParam
+ {
+ NOISE_DATATYPE m_DistortAmpX;
+ NOISE_DATATYPE m_DistortAmpZ;
+ } ;
+ static const sGenParam m_GenParam[biNumBiomes];
+
+ // Distortion amplitudes for each direction, before linear upscaling
+ NOISE_DATATYPE m_DistortAmpX[DIM_X * DIM_Z];
+ NOISE_DATATYPE m_DistortAmpZ[DIM_X * DIM_Z];
+
+
+ /// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise arrays, heightmap)
+ void PrepareState(int a_ChunkX, int a_ChunkZ);
+
+ /// Generates the m_DistortedHeightmap array for the current chunk
+ void GenerateHeightArray(void);
+
+ /// Calculates the heightmap value (before distortion) at the specified (floating-point) coords
+ int GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z);
+
+ /// Updates m_DistortAmpX/Z[] based on m_CurChunkX and m_CurChunkZ
+ void UpdateDistortAmps(void);
+
+ /// Calculates the X and Z distortion amplitudes based on the neighbors' biomes
+ void GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_RelX, int a_RelZ, NOISE_DATATYPE & a_DistortAmpX, NOISE_DATATYPE & a_DistortAmpZ);
+
+
+ // cTerrainHeightGen overrides:
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
+
+ // cTerrainCompositionGen overrides:
+ virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
+} ;
diff --git a/source/Generating/EndGen.cpp b/source/Generating/EndGen.cpp
index 30fa457db..3eba5c47b 100644
--- a/source/Generating/EndGen.cpp
+++ b/source/Generating/EndGen.cpp
@@ -1,217 +1,217 @@
-
-// EndGen.cpp
-
-// Implements the cEndGen class representing the generator for the End, both as a HeightGen and CompositionGen
-
-#include "Globals.h"
-#include "EndGen.h"
-#include "../../iniFile/iniFile.h"
-#include "../LinearUpscale.h"
-
-
-
-
-
-enum
-{
- // Interpolation cell size:
- INTERPOL_X = 4,
- INTERPOL_Y = 4,
- INTERPOL_Z = 4,
-
- // Size of chunk data, downscaled before interpolation:
- DIM_X = 16 / INTERPOL_X + 1,
- DIM_Y = 256 / INTERPOL_Y + 1,
- DIM_Z = 16 / INTERPOL_Z + 1,
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cEndGen:
-
-cEndGen::cEndGen(int a_Seed) :
- m_Seed(a_Seed),
- m_IslandSizeX(256),
- m_IslandSizeY(96),
- m_IslandSizeZ(256),
- m_FrequencyX(80),
- m_FrequencyY(80),
- m_FrequencyZ(80)
-{
- m_Perlin.AddOctave(1, 1);
- m_Perlin.AddOctave(2, 0.5);
- m_Perlin.AddOctave(4, 0.25);
-}
-
-
-
-
-
-void cEndGen::Initialize(cIniFile & a_IniFile)
-{
- m_IslandSizeX = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeX", m_IslandSizeX);
- m_IslandSizeY = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeY", m_IslandSizeY);
- m_IslandSizeZ = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeZ", m_IslandSizeZ);
-
- m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyX", m_FrequencyX);
- m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyY", m_FrequencyY);
- m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyZ", m_FrequencyZ);
-
- // Recalculate the min and max chunk coords of the island
- m_MaxChunkX = (m_IslandSizeX + cChunkDef::Width - 1) / cChunkDef::Width;
- m_MinChunkX = -m_MaxChunkX;
- m_MaxChunkZ = (m_IslandSizeZ + cChunkDef::Width - 1) / cChunkDef::Width;
- m_MinChunkZ = -m_MaxChunkZ;
-}
-
-
-
-
-
-/// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise array)
-void cEndGen::PrepareState(int a_ChunkX, int a_ChunkZ)
-{
- ASSERT(!IsChunkOutsideRange(a_ChunkX, a_ChunkZ)); // Should be filtered before calling this function
-
- if ((m_LastChunkX == a_ChunkX) && (m_LastChunkZ == a_ChunkZ))
- {
- return;
- }
-
- m_LastChunkX = a_ChunkX;
- m_LastChunkZ = a_ChunkZ;
-
- GenerateNoiseArray();
-}
-
-
-
-
-
-/// Generates the m_NoiseArray array for the current chunk
-void cEndGen::GenerateNoiseArray(void)
-{
- NOISE_DATATYPE NoiseData[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y]
- NOISE_DATATYPE Workspace[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y]
-
- // Generate the downscaled noise:
- NOISE_DATATYPE StartX = ((NOISE_DATATYPE)(m_LastChunkX * cChunkDef::Width)) / m_FrequencyX;
- NOISE_DATATYPE EndX = ((NOISE_DATATYPE)((m_LastChunkX + 1) * cChunkDef::Width)) / m_FrequencyX;
- NOISE_DATATYPE StartZ = ((NOISE_DATATYPE)(m_LastChunkZ * cChunkDef::Width)) / m_FrequencyZ;
- NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((m_LastChunkZ + 1) * cChunkDef::Width)) / m_FrequencyZ;
- NOISE_DATATYPE StartY = 0;
- NOISE_DATATYPE EndY = ((NOISE_DATATYPE)257) / m_FrequencyY;
- m_Perlin.Generate3D(NoiseData, DIM_X, DIM_Z, DIM_Y, StartX, EndX, StartZ, EndZ, StartY, EndY, Workspace);
-
- // Add distance:
- int idx = 0;
- for (int y = 0; y < DIM_Y; y++)
- {
- NOISE_DATATYPE ValY = (NOISE_DATATYPE)(2 * INTERPOL_Y * y - m_IslandSizeY) / m_IslandSizeY;
- ValY = ValY * ValY;
- for (int z = 0; z < DIM_Z; z++)
- {
- NOISE_DATATYPE ValZ = (NOISE_DATATYPE)(m_LastChunkZ * cChunkDef::Width + (z * cChunkDef::Width / (DIM_Z - 1))) / m_IslandSizeZ;
- ValZ = ValZ * ValZ;
- for (int x = 0; x < DIM_X; x++)
- {
- // NOISE_DATATYPE ValX = StartX + (EndX - StartX) * x / (DIM_X - 1);
- NOISE_DATATYPE ValX = (NOISE_DATATYPE)(m_LastChunkX * cChunkDef::Width + (x * cChunkDef::Width / (DIM_X - 1))) / m_IslandSizeX;
- ValX = ValX * ValX;
- NoiseData[idx++] += ValX + ValZ + ValY;
- } // for x
- } // for z
- } // for y
-
- // Upscale into real chunk size:
- LinearUpscale3DArray(NoiseData, DIM_X, DIM_Z, DIM_Y, m_NoiseArray, INTERPOL_X, INTERPOL_Z, INTERPOL_Y);
-}
-
-
-
-
-
-/// Returns true if the chunk is outside of the island's dimensions
-bool cEndGen::IsChunkOutsideRange(int a_ChunkX, int a_ChunkZ)
-{
- return (
- (a_ChunkX < m_MinChunkX) || (a_ChunkX > m_MaxChunkX) ||
- (a_ChunkZ < m_MinChunkZ) || (a_ChunkZ > m_MaxChunkZ)
- );
-}
-
-
-
-
-
-void cEndGen::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
-{
- if (IsChunkOutsideRange(a_ChunkX, a_ChunkZ))
- {
- for (int i = 0; i < ARRAYCOUNT(a_HeightMap); i++)
- {
- a_HeightMap[i] = 0;
- }
- return;
- }
-
- PrepareState(a_ChunkX, a_ChunkZ);
-
- int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1);
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- cChunkDef::SetHeight(a_HeightMap, x, z, MaxY);
- for (int y = MaxY; y > 0; y--)
- {
- if (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= 0)
- {
- cChunkDef::SetHeight(a_HeightMap, x, z, y);
- break;
- }
- } // for y
- } // for x
- } // for z
-}
-
-
-
-
-
-void cEndGen::ComposeTerrain(cChunkDesc & a_ChunkDesc)
-{
- if (IsChunkOutsideRange(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()))
- {
- a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
- return;
- }
-
- PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
-
- int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1);
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- for (int y = MaxY; y > 0; y--)
- {
- if (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= 0)
- {
- a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_END_STONE, 0);
- }
- else
- {
- a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_AIR, 0);
- }
- } // for y
- } // for x
- } // for z
-}
-
-
-
-
+
+// EndGen.cpp
+
+// Implements the cEndGen class representing the generator for the End, both as a HeightGen and CompositionGen
+
+#include "Globals.h"
+#include "EndGen.h"
+#include "../../iniFile/iniFile.h"
+#include "../LinearUpscale.h"
+
+
+
+
+
+enum
+{
+ // Interpolation cell size:
+ INTERPOL_X = 4,
+ INTERPOL_Y = 4,
+ INTERPOL_Z = 4,
+
+ // Size of chunk data, downscaled before interpolation:
+ DIM_X = 16 / INTERPOL_X + 1,
+ DIM_Y = 256 / INTERPOL_Y + 1,
+ DIM_Z = 16 / INTERPOL_Z + 1,
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cEndGen:
+
+cEndGen::cEndGen(int a_Seed) :
+ m_Seed(a_Seed),
+ m_IslandSizeX(256),
+ m_IslandSizeY(96),
+ m_IslandSizeZ(256),
+ m_FrequencyX(80),
+ m_FrequencyY(80),
+ m_FrequencyZ(80)
+{
+ m_Perlin.AddOctave(1, 1);
+ m_Perlin.AddOctave(2, 0.5);
+ m_Perlin.AddOctave(4, 0.25);
+}
+
+
+
+
+
+void cEndGen::Initialize(cIniFile & a_IniFile)
+{
+ m_IslandSizeX = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeX", m_IslandSizeX);
+ m_IslandSizeY = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeY", m_IslandSizeY);
+ m_IslandSizeZ = a_IniFile.GetValueSetI("Generator", "EndGenIslandSizeZ", m_IslandSizeZ);
+
+ m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyX", m_FrequencyX);
+ m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyY", m_FrequencyY);
+ m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyZ", m_FrequencyZ);
+
+ // Recalculate the min and max chunk coords of the island
+ m_MaxChunkX = (m_IslandSizeX + cChunkDef::Width - 1) / cChunkDef::Width;
+ m_MinChunkX = -m_MaxChunkX;
+ m_MaxChunkZ = (m_IslandSizeZ + cChunkDef::Width - 1) / cChunkDef::Width;
+ m_MinChunkZ = -m_MaxChunkZ;
+}
+
+
+
+
+
+/// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise array)
+void cEndGen::PrepareState(int a_ChunkX, int a_ChunkZ)
+{
+ ASSERT(!IsChunkOutsideRange(a_ChunkX, a_ChunkZ)); // Should be filtered before calling this function
+
+ if ((m_LastChunkX == a_ChunkX) && (m_LastChunkZ == a_ChunkZ))
+ {
+ return;
+ }
+
+ m_LastChunkX = a_ChunkX;
+ m_LastChunkZ = a_ChunkZ;
+
+ GenerateNoiseArray();
+}
+
+
+
+
+
+/// Generates the m_NoiseArray array for the current chunk
+void cEndGen::GenerateNoiseArray(void)
+{
+ NOISE_DATATYPE NoiseData[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y]
+ NOISE_DATATYPE Workspace[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y]
+
+ // Generate the downscaled noise:
+ NOISE_DATATYPE StartX = ((NOISE_DATATYPE)(m_LastChunkX * cChunkDef::Width)) / m_FrequencyX;
+ NOISE_DATATYPE EndX = ((NOISE_DATATYPE)((m_LastChunkX + 1) * cChunkDef::Width)) / m_FrequencyX;
+ NOISE_DATATYPE StartZ = ((NOISE_DATATYPE)(m_LastChunkZ * cChunkDef::Width)) / m_FrequencyZ;
+ NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((m_LastChunkZ + 1) * cChunkDef::Width)) / m_FrequencyZ;
+ NOISE_DATATYPE StartY = 0;
+ NOISE_DATATYPE EndY = ((NOISE_DATATYPE)257) / m_FrequencyY;
+ m_Perlin.Generate3D(NoiseData, DIM_X, DIM_Z, DIM_Y, StartX, EndX, StartZ, EndZ, StartY, EndY, Workspace);
+
+ // Add distance:
+ int idx = 0;
+ for (int y = 0; y < DIM_Y; y++)
+ {
+ NOISE_DATATYPE ValY = (NOISE_DATATYPE)(2 * INTERPOL_Y * y - m_IslandSizeY) / m_IslandSizeY;
+ ValY = ValY * ValY;
+ for (int z = 0; z < DIM_Z; z++)
+ {
+ NOISE_DATATYPE ValZ = (NOISE_DATATYPE)(m_LastChunkZ * cChunkDef::Width + (z * cChunkDef::Width / (DIM_Z - 1))) / m_IslandSizeZ;
+ ValZ = ValZ * ValZ;
+ for (int x = 0; x < DIM_X; x++)
+ {
+ // NOISE_DATATYPE ValX = StartX + (EndX - StartX) * x / (DIM_X - 1);
+ NOISE_DATATYPE ValX = (NOISE_DATATYPE)(m_LastChunkX * cChunkDef::Width + (x * cChunkDef::Width / (DIM_X - 1))) / m_IslandSizeX;
+ ValX = ValX * ValX;
+ NoiseData[idx++] += ValX + ValZ + ValY;
+ } // for x
+ } // for z
+ } // for y
+
+ // Upscale into real chunk size:
+ LinearUpscale3DArray(NoiseData, DIM_X, DIM_Z, DIM_Y, m_NoiseArray, INTERPOL_X, INTERPOL_Z, INTERPOL_Y);
+}
+
+
+
+
+
+/// Returns true if the chunk is outside of the island's dimensions
+bool cEndGen::IsChunkOutsideRange(int a_ChunkX, int a_ChunkZ)
+{
+ return (
+ (a_ChunkX < m_MinChunkX) || (a_ChunkX > m_MaxChunkX) ||
+ (a_ChunkZ < m_MinChunkZ) || (a_ChunkZ > m_MaxChunkZ)
+ );
+}
+
+
+
+
+
+void cEndGen::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
+{
+ if (IsChunkOutsideRange(a_ChunkX, a_ChunkZ))
+ {
+ for (int i = 0; i < ARRAYCOUNT(a_HeightMap); i++)
+ {
+ a_HeightMap[i] = 0;
+ }
+ return;
+ }
+
+ PrepareState(a_ChunkX, a_ChunkZ);
+
+ int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ cChunkDef::SetHeight(a_HeightMap, x, z, MaxY);
+ for (int y = MaxY; y > 0; y--)
+ {
+ if (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= 0)
+ {
+ cChunkDef::SetHeight(a_HeightMap, x, z, y);
+ break;
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cEndGen::ComposeTerrain(cChunkDesc & a_ChunkDesc)
+{
+ if (IsChunkOutsideRange(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()))
+ {
+ a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
+ return;
+ }
+
+ PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
+
+ int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ for (int y = MaxY; y > 0; y--)
+ {
+ if (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= 0)
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_END_STONE, 0);
+ }
+ else
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_AIR, 0);
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
diff --git a/source/Generating/EndGen.h b/source/Generating/EndGen.h
index cd316ed67..4904a0e3d 100644
--- a/source/Generating/EndGen.h
+++ b/source/Generating/EndGen.h
@@ -1,69 +1,69 @@
-
-// EndGen.h
-
-// Declares the cEndGen class representing the generator for the End, both as a HeightGen and CompositionGen
-
-
-
-
-
-#pragma once
-
-#include "ComposableGenerator.h"
-#include "../Noise.h"
-
-
-
-
-
-class cEndGen :
- public cTerrainHeightGen,
- public cTerrainCompositionGen
-{
-public:
- cEndGen(int a_Seed);
-
- void Initialize(cIniFile & a_IniFile);
-
-protected:
-
- /// Seed for the noise
- int m_Seed;
-
- /// The Perlin noise used for generating
- cPerlinNoise m_Perlin;
-
- // XYZ size of the "island", in blocks:
- int m_IslandSizeX;
- int m_IslandSizeY;
- int m_IslandSizeZ;
-
- // XYZ Frequencies of the noise functions:
- NOISE_DATATYPE m_FrequencyX;
- NOISE_DATATYPE m_FrequencyY;
- NOISE_DATATYPE m_FrequencyZ;
-
- // Minimum and maximum chunk coords for chunks inside the island area. Chunks outside won't get calculated at all
- int m_MinChunkX, m_MaxChunkX;
- int m_MinChunkZ, m_MaxChunkZ;
-
- // Noise array for the last chunk (in the noise range)
- int m_LastChunkX;
- int m_LastChunkZ;
- NOISE_DATATYPE m_NoiseArray[17 * 17 * 257]; // x + 17 * z + 17 * 17 * y
-
- /// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise array)
- void PrepareState(int a_ChunkX, int a_ChunkZ);
-
- /// Generates the m_NoiseArray array for the current chunk
- void GenerateNoiseArray(void);
-
- /// Returns true if the chunk is outside of the island's dimensions
- bool IsChunkOutsideRange(int a_ChunkX, int a_ChunkZ);
-
- // cTerrainHeightGen overrides:
- virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
-
- // cTerrainCompositionGen overrides:
- virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
-} ;
+
+// EndGen.h
+
+// Declares the cEndGen class representing the generator for the End, both as a HeightGen and CompositionGen
+
+
+
+
+
+#pragma once
+
+#include "ComposableGenerator.h"
+#include "../Noise.h"
+
+
+
+
+
+class cEndGen :
+ public cTerrainHeightGen,
+ public cTerrainCompositionGen
+{
+public:
+ cEndGen(int a_Seed);
+
+ void Initialize(cIniFile & a_IniFile);
+
+protected:
+
+ /// Seed for the noise
+ int m_Seed;
+
+ /// The Perlin noise used for generating
+ cPerlinNoise m_Perlin;
+
+ // XYZ size of the "island", in blocks:
+ int m_IslandSizeX;
+ int m_IslandSizeY;
+ int m_IslandSizeZ;
+
+ // XYZ Frequencies of the noise functions:
+ NOISE_DATATYPE m_FrequencyX;
+ NOISE_DATATYPE m_FrequencyY;
+ NOISE_DATATYPE m_FrequencyZ;
+
+ // Minimum and maximum chunk coords for chunks inside the island area. Chunks outside won't get calculated at all
+ int m_MinChunkX, m_MaxChunkX;
+ int m_MinChunkZ, m_MaxChunkZ;
+
+ // Noise array for the last chunk (in the noise range)
+ int m_LastChunkX;
+ int m_LastChunkZ;
+ NOISE_DATATYPE m_NoiseArray[17 * 17 * 257]; // x + 17 * z + 17 * 17 * y
+
+ /// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise array)
+ void PrepareState(int a_ChunkX, int a_ChunkZ);
+
+ /// Generates the m_NoiseArray array for the current chunk
+ void GenerateNoiseArray(void);
+
+ /// Returns true if the chunk is outside of the island's dimensions
+ bool IsChunkOutsideRange(int a_ChunkX, int a_ChunkZ);
+
+ // cTerrainHeightGen overrides:
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
+
+ // cTerrainCompositionGen overrides:
+ virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
+} ;
diff --git a/source/Generating/MineShafts.cpp b/source/Generating/MineShafts.cpp
index 0f7f78e19..3131b5429 100644
--- a/source/Generating/MineShafts.cpp
+++ b/source/Generating/MineShafts.cpp
@@ -1,1423 +1,1423 @@
-
-// MineShafts.cpp
-
-// Implements the cStructGenMineShafts class representing the structure generator for abandoned mineshafts
-
-/*
-Algorithm:
-The cStructGenMineShafts::cMineShaftSystem class is the main controller, which knows what mineshaft
-classes there are and their random weights. It gets asked to produce a new class everytime a connection is to be made.
-The cMineShaft class is a base class for each mineshaft structure.
-Each cMineShaft descendant knows how large it is, how to imprint itself into the chunk data and where to connect to
-other descendants. Its PivotPoint is always a walkable column. Its Direction determines in which direction the structure
-is facing.
-
-The generation starts with the central dirt room, from there corridors, crossings and staircases are added
-in a depth-first processing. Each of the descendants will branch randomly, if not beyond the allowed recursion level
-*/
-
-#include "Globals.h"
-#include "MineShafts.h"
-#include "../Cuboid.h"
-#include "../BlockEntities/ChestEntity.h"
-
-
-
-
-
-static const int NEIGHBORHOOD_SIZE = 3;
-
-
-
-
-
-class cMineShaft abstract
-{
-public:
- enum eKind
- {
- mskDirtRoom,
- mskCorridor,
- mskCrossing,
- mskStaircase,
- } ;
-
-
- enum eDirection
- {
- dirXP,
- dirZP,
- dirXM,
- dirZM,
- } ;
-
-
- cStructGenMineShafts::cMineShaftSystem & m_ParentSystem;
- eKind m_Kind;
- cCuboid m_BoundingBox;
-
-
- cMineShaft(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, eKind a_Kind) :
- m_ParentSystem(a_ParentSystem),
- m_Kind(a_Kind)
- {
- }
-
- cMineShaft(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, eKind a_Kind, const cCuboid & a_BoundingBox) :
- m_ParentSystem(a_ParentSystem),
- m_Kind(a_Kind),
- m_BoundingBox(a_BoundingBox)
- {
- }
-
- /// Returns true if this mineshaft intersects the specified cuboid
- bool DoesIntersect(const cCuboid & a_Other)
- {
- return m_BoundingBox.DoesIntersect(a_Other);
- }
-
- /** If recursion level is not too large, appends more branches to the parent system,
- using exit points specific to this class.
- */
- virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) = 0;
-
- /// Imprints this shape into the specified chunk's data
- virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) = 0;
-} ;
-
-typedef std::vector<cMineShaft *> cMineShafts;
-
-
-
-
-
-class cMineShaftDirtRoom :
- public cMineShaft
-{
- typedef cMineShaft super;
-
-public:
- cMineShaftDirtRoom(cStructGenMineShafts::cMineShaftSystem & a_Parent, cNoise & a_Noise);
-
- // cMineShaft overrides:
- virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
- virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
-} ;
-
-
-
-
-
-class cMineShaftCorridor :
- public cMineShaft
-{
- typedef cMineShaft super;
-
-public:
- /** Creates a new Corridor attached to the specified pivot point and direction.
- Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
- May return NULL if cannot fit.
- */
- static cMineShaft * CreateAndFit(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
- cNoise & a_Noise
- );
-
-protected:
- static const int MAX_SEGMENTS = 5;
-
- int m_NumSegments;
- eDirection m_Direction;
- bool m_HasFullBeam[MAX_SEGMENTS]; ///< If true, segment at that index has a full beam support (planks in the top center block)
- int m_ChestPosition; ///< If <0, no chest; otherwise an offset from m_BoundingBox's p1.x or p1.z, depenging on m_Direction
- int m_SpawnerPosition; ///< If <0, no spawner; otherwise an offset from m_BoundingBox's p1.x or p1.z, depenging on m_Direction
- bool m_HasTracks; ///< If true, random tracks will be placed on the floor
-
- cMineShaftCorridor(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- const cCuboid & a_BoundingBox, int a_NumSegments, eDirection a_Direction,
- cNoise & a_Noise
- );
-
- // cMineShaft overrides:
- virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
- virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
-
- /// Places a chest, if the corridor has one
- void PlaceChest(cChunkDesc & a_ChunkDesc);
-
- /// If this corridor has tracks, places them randomly
- void PlaceTracks(cChunkDesc & a_ChunkDesc);
-
- /// If this corridor has a spawner, places the spawner
- void PlaceSpawner(cChunkDesc & a_ChunkDesc);
-
- /// Randomly places torches around the central beam block
- void PlaceTorches(cChunkDesc & a_ChunkDesc);
-} ;
-
-
-
-
-
-class cMineShaftCrossing :
- public cMineShaft
-{
- typedef cMineShaft super;
-
-public:
- /** Creates a new Crossing attached to the specified pivot point and direction.
- Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
- May return NULL if cannot fit.
- */
- static cMineShaft * CreateAndFit(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
- cNoise & a_Noise
- );
-
-protected:
- cMineShaftCrossing(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox);
-
- // cMineShaft overrides:
- virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
- virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
-} ;
-
-
-
-
-
-class cMineShaftStaircase :
- public cMineShaft
-{
- typedef cMineShaft super;
-
-public:
- enum eSlope
- {
- sUp,
- sDown,
- } ;
-
- /** Creates a new Staircase attached to the specified pivot point and direction.
- Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
- May return NULL if cannot fit.
- */
- static cMineShaft * CreateAndFit(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
- cNoise & a_Noise
- );
-
-protected:
- eDirection m_Direction;
- eSlope m_Slope;
-
-
- cMineShaftStaircase(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- const cCuboid & a_BoundingBox,
- eDirection a_Direction,
- eSlope a_Slope
- );
-
- // cMineShaft overrides:
- virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
- virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
-} ;
-
-
-
-
-
-class cStructGenMineShafts::cMineShaftSystem
-{
-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
- 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
- int m_ChanceChest; ///< Chance [0 .. 250] that a corridor has a chest in it
- int m_ChanceSpawner; ///< Chance [0 .. 250] that a corridor has a spawner in it
- int m_ChanceTorch; ///< Chance [0 .. 10k] for a torch appearing attached to a corridor's beam
- 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
- cMineShaftSystem(
- int a_BlockX, int a_BlockZ, 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()
- */
- void AppendBranch(
- int a_BlockX, int a_BlockY, int a_BlockZ,
- cMineShaft::eDirection a_Direction, cNoise & a_Noise,
- 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
- bool CanAppend(const cCuboid & a_BoundingBox);
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cStructGenMineShafts::cMineShaftSystem:
-
-cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem(
- int a_BlockX, int a_BlockZ, 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),
- m_GridSize(a_GridSize),
- m_MaxRecursion(8), // TODO: settable
- m_ProbLevelCorridor(a_ProbLevelCorridor),
- m_ProbLevelCrossing(a_ProbLevelCrossing),
- m_ProbLevelStaircase(a_ProbLevelStaircase + 1),
- m_ChanceChest(12), // TODO: settable
- m_ChanceSpawner(12), // TODO: settable
- m_ChanceTorch(1000) // TODO: settable
-{
- m_MineShafts.reserve(100);
-
- cMineShaft * Start = new cMineShaftDirtRoom(*this, a_Noise);
- m_MineShafts.push_back(Start);
-
- m_BoundingBox.Assign(
- Start->m_BoundingBox.p1.x - a_MaxSystemSize / 2, 2, Start->m_BoundingBox.p1.z - a_MaxSystemSize / 2,
- Start->m_BoundingBox.p2.x + a_MaxSystemSize / 2, 50, Start->m_BoundingBox.p2.z + a_MaxSystemSize / 2
- );
-
- Start->AppendBranches(0, a_Noise);
-
- for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
- {
- ASSERT((*itr)->m_BoundingBox.IsSorted());
- } // for itr - m_MineShafts[]
-}
-
-
-
-
-
-cStructGenMineShafts::cMineShaftSystem::~cMineShaftSystem()
-{
- for (cMineShafts::iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
- {
- delete *itr;
- } // for itr - m_MineShafts[]
- m_MineShafts.clear();
-}
-
-
-
-
-
-void cStructGenMineShafts::cMineShaftSystem::ProcessChunk(cChunkDesc & a_Chunk)
-{
- for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
- {
- (*itr)->ProcessChunk(a_Chunk);
- } // for itr - m_MineShafts[]
-}
-
-
-
-
-
-void cStructGenMineShafts::cMineShaftSystem::AppendBranch(
- int a_PivotX, int a_PivotY, int a_PivotZ,
- cMineShaft::eDirection a_Direction, cNoise & a_Noise,
- int a_RecursionLevel
-)
-{
- if (a_RecursionLevel > m_MaxRecursion)
- {
- return;
- }
-
- cMineShaft * Next = NULL;
- int rnd = (a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_RecursionLevel * 16, a_PivotZ) / 13) % m_ProbLevelStaircase;
- if (rnd < m_ProbLevelCorridor)
- {
- Next = cMineShaftCorridor::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise);
- }
- else if (rnd < m_ProbLevelCrossing)
- {
- Next = cMineShaftCrossing::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise);
- }
- else
- {
- Next = cMineShaftStaircase::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise);
- }
- if (Next == NULL)
- {
- return;
- }
- m_MineShafts.push_back(Next);
- Next->AppendBranches(a_RecursionLevel + 1, a_Noise);
-}
-
-
-
-
-
-bool cStructGenMineShafts::cMineShaftSystem::CanAppend(const cCuboid & a_BoundingBox)
-{
- if (!a_BoundingBox.IsCompletelyInside(m_BoundingBox))
- {
- // Too far away, or too low / too high
- return false;
- }
-
- // Check intersections:
- for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
- {
- if ((*itr)->DoesIntersect(a_BoundingBox))
- {
- return false;
- }
- } // for itr - m_MineShafts[]
- return true;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// 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 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;
- m_BoundingBox.p2.x = m_BoundingBox.p1.x + 10 + (rnd % 8);
- rnd >>= 4;
- m_BoundingBox.p1.z = a_Parent.m_BlockZ + OfsZ;
- m_BoundingBox.p2.z = m_BoundingBox.p1.z + 10 + (rnd % 8);
- rnd >>= 4;
- m_BoundingBox.p1.y = 20;
- m_BoundingBox.p2.y = 24 + rnd % 8;
-}
-
-
-
-
-
-void cMineShaftDirtRoom::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
-{
- int Height = m_BoundingBox.DifY() - 3;
- for (int x = m_BoundingBox.p1.x + 1; x < m_BoundingBox.p2.x; x += 4)
- {
- int rnd = a_Noise.IntNoise3DInt(x, a_RecursionLevel, m_BoundingBox.p1.z) / 7;
- m_ParentSystem.AppendBranch(x, m_BoundingBox.p1.y + (rnd % Height), m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
- rnd >>= 4;
- m_ParentSystem.AppendBranch(x, m_BoundingBox.p1.y + (rnd % Height), m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
- }
-
- for (int z = m_BoundingBox.p1.z + 1; z < m_BoundingBox.p2.z; z += 4)
- {
- int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, a_RecursionLevel, z) / 13;
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, m_BoundingBox.p1.y + (rnd % Height), z, dirXM, a_Noise, a_RecursionLevel);
- rnd >>= 4;
- m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, m_BoundingBox.p1.y + (rnd % Height), z, dirXP, a_Noise, a_RecursionLevel);
- }
-}
-
-
-
-
-
-void cMineShaftDirtRoom::ProcessChunk(cChunkDesc & a_ChunkDesc)
-{
- int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
- int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
- if (
- (m_BoundingBox.p1.x > BlockX + cChunkDef::Width) ||
- (m_BoundingBox.p1.z > BlockZ + cChunkDef::Width) ||
- (m_BoundingBox.p2.x < BlockX) ||
- (m_BoundingBox.p2.z < BlockZ)
- )
- {
- // Early bailout - cannot intersect this chunk
- return;
- }
-
- // Chunk-relative coords of the boundaries:
- int MinX = std::max(BlockX, m_BoundingBox.p1.x) - BlockX;
- int MaxX = std::min(BlockX + cChunkDef::Width, m_BoundingBox.p2.x + 1) - BlockX;
- int MinZ = std::max(BlockZ, m_BoundingBox.p1.z) - BlockZ;
- int MaxZ = std::min(BlockZ + cChunkDef::Width, m_BoundingBox.p2.z + 1) - BlockZ;
-
- // Carve the room out:
- for (int z = MinZ; z < MaxZ; z++)
- {
- for (int x = MinX; x < MaxX; x++)
- {
- for (int y = m_BoundingBox.p1.y + 1; y < m_BoundingBox.p2.y; y++)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
- }
- if (a_ChunkDesc.GetBlockType(x, m_BoundingBox.p1.y, z) != E_BLOCK_AIR)
- {
- a_ChunkDesc.SetBlockType(x, m_BoundingBox.p1.y, z, E_BLOCK_DIRT);
- }
- } // for x
- } // for z
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cMineShaftCorridor:
-
-cMineShaftCorridor::cMineShaftCorridor(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- const cCuboid & a_BoundingBox, int a_NumSegments, eDirection a_Direction,
- cNoise & a_Noise
-) :
- super(a_ParentSystem, mskCorridor, a_BoundingBox),
- m_NumSegments(a_NumSegments),
- m_Direction(a_Direction),
- m_ChestPosition(-1),
- m_SpawnerPosition(-1)
-{
- int rnd = a_Noise.IntNoise3DInt(a_BoundingBox.p1.x, a_BoundingBox.p1.y, a_BoundingBox.p1.z) / 7;
- for (int i = 0; i < a_NumSegments; i++)
- {
- m_HasFullBeam[i] = (rnd % 4) < 3; // 75 % chance of full beam
- rnd >>= 2;
- }
- m_HasTracks = ((rnd % 4) < 2); // 50 % chance of tracks
-
- rnd = a_Noise.IntNoise3DInt(a_BoundingBox.p1.z, a_BoundingBox.p1.x, a_BoundingBox.p1.y) / 7;
- int ChestCheck = rnd % 250;
- rnd >>= 8;
- int SpawnerCheck = rnd % 250;
- rnd >>= 8;
- if (ChestCheck < a_ParentSystem.m_ChanceChest)
- {
- m_ChestPosition = rnd % (a_NumSegments * 5);
- }
- if ((a_NumSegments < 4) && (SpawnerCheck < a_ParentSystem.m_ChanceSpawner))
- {
- m_SpawnerPosition = rnd % (a_NumSegments * 5);
- }
-}
-
-
-
-
-
-cMineShaft * cMineShaftCorridor::CreateAndFit(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
- cNoise & a_Noise
-)
-{
- 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 NumSegments = 2 + (rnd) % (MAX_SEGMENTS - 1); // 2 .. MAX_SEGMENTS
- switch (a_Direction)
- {
- case dirXP: BoundingBox.p2.x += NumSegments * 5 - 1; BoundingBox.p1.z -= 1; BoundingBox.p2.z += 1; break;
- case dirXM: BoundingBox.p1.x -= NumSegments * 5 - 1; BoundingBox.p1.z -= 1; BoundingBox.p2.z += 1; break;
- case dirZP: BoundingBox.p2.z += NumSegments * 5 - 1; BoundingBox.p1.x -= 1; BoundingBox.p2.x += 1; break;
- case dirZM: BoundingBox.p1.z -= NumSegments * 5 - 1; BoundingBox.p1.x -= 1; BoundingBox.p2.x += 1; break;
- }
- if (!a_ParentSystem.CanAppend(BoundingBox))
- {
- return NULL;
- }
- return new cMineShaftCorridor(a_ParentSystem, BoundingBox, NumSegments, a_Direction, a_Noise);
-}
-
-
-
-
-
-void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
-{
- int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 7;
- // Prefer the same height, but allow for up to one block height displacement:
- int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
- switch (m_Direction)
- {
- case dirXM:
- {
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + 1, dirXM, a_Noise, a_RecursionLevel);
- for (int i = m_NumSegments; i >= 0; i--)
- {
- int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
- int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
- rnd >>= 6;
- int Ofs = 1 + rnd % (m_NumSegments * 5 - 2);
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Ofs, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Ofs, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
- }
- break;
- }
-
- case dirXP:
- {
- m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + 1, dirXP, a_Noise, a_RecursionLevel);
- for (int i = m_NumSegments; i >= 0; i--)
- {
- int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
- int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
- rnd >>= 6;
- int Ofs = 1 + rnd % (m_NumSegments * 5 - 2);
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Ofs, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Ofs, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
- }
- break;
- }
-
- case dirZM:
- {
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
- for (int i = m_NumSegments; i >= 0; i--)
- {
- int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
- int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
- rnd >>= 6;
- int Ofs = 1 + rnd % (m_NumSegments * 5 - 2);
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + Ofs, dirXM, a_Noise, a_RecursionLevel);
- m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + Ofs, dirXP, a_Noise, a_RecursionLevel);
- }
- break;
- }
-
- case dirZP:
- {
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
- for (int i = m_NumSegments; i >= 0; i--)
- {
- int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
- int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
- rnd >>= 6;
- int Ofs = 1 + rnd % (m_NumSegments * 5 - 2);
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + Ofs, dirXM, a_Noise, a_RecursionLevel);
- m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + Ofs, dirXP, a_Noise, a_RecursionLevel);
- }
- break;
- }
- } // switch (m_Direction)
-}
-
-
-
-
-
-void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc)
-{
- int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
- int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
- cCuboid RelBoundingBox(m_BoundingBox);
- RelBoundingBox.Move(-BlockX, 0, -BlockZ);
- RelBoundingBox.p1.y += 1;
- RelBoundingBox.p2.y -= 1;
- cCuboid Top(RelBoundingBox);
- Top.p2.y += 1;
- Top.p1.y = Top.p2.y;
- a_ChunkDesc.FillRelCuboid(RelBoundingBox, E_BLOCK_AIR, 0);
- a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_AIR, 0, BlockX ^ BlockZ + BlockX, 8000);
- if (m_SpawnerPosition >= 0)
- {
- // Cobwebs around the spider spawner
- a_ChunkDesc.RandomFillRelCuboid(RelBoundingBox, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockZ, 8000);
- a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX, 5000);
- }
- a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX + 10, 500);
- RelBoundingBox.p1.y = m_BoundingBox.p1.y;
- RelBoundingBox.p2.y = m_BoundingBox.p1.y;
- a_ChunkDesc.FloorRelCuboid(RelBoundingBox, E_BLOCK_PLANKS, 0);
- switch (m_Direction)
- {
- case dirXM:
- case dirXP:
- {
- int y1 = m_BoundingBox.p1.y + 1;
- int y2 = m_BoundingBox.p1.y + 2;
- int y3 = m_BoundingBox.p1.y + 3;
- int z1 = m_BoundingBox.p1.z - BlockZ;
- int z2 = m_BoundingBox.p2.z - BlockZ;
- for (int i = 0; i < m_NumSegments; i++)
- {
- int x = m_BoundingBox.p1.x + i * 5 + 2 - BlockX;
- if ((x < 0) || (x >= cChunkDef::Width))
- {
- continue;
- }
- if ((z1 >= 0) && (z1 < cChunkDef::Width))
- {
- a_ChunkDesc.SetBlockTypeMeta(x, y1, z1, E_BLOCK_FENCE, 0);
- a_ChunkDesc.SetBlockTypeMeta(x, y2, z1, E_BLOCK_FENCE, 0);
- a_ChunkDesc.SetBlockTypeMeta(x, y3, z1, E_BLOCK_PLANKS, 0);
- }
- if ((z2 >= 0) && (z2 < cChunkDef::Width))
- {
- a_ChunkDesc.SetBlockTypeMeta(x, y1, z2, E_BLOCK_FENCE, 0);
- a_ChunkDesc.SetBlockTypeMeta(x, y2, z2, E_BLOCK_FENCE, 0);
- a_ChunkDesc.SetBlockTypeMeta(x, y3, z2, E_BLOCK_PLANKS, 0);
- }
- if ((z1 >= -1) && (z1 < cChunkDef::Width - 1) && m_HasFullBeam[i])
- {
- a_ChunkDesc.SetBlockTypeMeta(x, y3, z1 + 1, E_BLOCK_PLANKS, 0);
- }
- } // for i - NumSegments
- break;
- }
-
- case dirZM:
- case dirZP:
- {
- int y1 = m_BoundingBox.p1.y + 1;
- int y2 = m_BoundingBox.p1.y + 2;
- int y3 = m_BoundingBox.p1.y + 3;
- int x1 = m_BoundingBox.p1.x - BlockX;
- int x2 = m_BoundingBox.p2.x - BlockX;
- for (int i = 0; i < m_NumSegments; i++)
- {
- int z = m_BoundingBox.p1.z + i * 5 + 2 - BlockZ;
- if ((z < 0) || (z >= cChunkDef::Width))
- {
- continue;
- }
- if ((x1 >= 0) && (x1 < cChunkDef::Width))
- {
- a_ChunkDesc.SetBlockTypeMeta(x1, y1, z, E_BLOCK_FENCE, 0);
- a_ChunkDesc.SetBlockTypeMeta(x1, y2, z, E_BLOCK_FENCE, 0);
- a_ChunkDesc.SetBlockTypeMeta(x1, y3, z, E_BLOCK_PLANKS, 0);
- }
- if ((x2 >= 0) && (x2 < cChunkDef::Width))
- {
- a_ChunkDesc.SetBlockTypeMeta(x2, y1, z, E_BLOCK_FENCE, 0);
- a_ChunkDesc.SetBlockTypeMeta(x2, y2, z, E_BLOCK_FENCE, 0);
- a_ChunkDesc.SetBlockTypeMeta(x2, y3, z, E_BLOCK_PLANKS, 0);
- }
- if ((x1 >= -1) && (x1 < cChunkDef::Width - 1) && m_HasFullBeam[i])
- {
- a_ChunkDesc.SetBlockTypeMeta(x1 + 1, y3, z, E_BLOCK_PLANKS, 0);
- }
- } // for i - NumSegments
- break;
- } // case dirZ?
- } // for i
-
- PlaceChest(a_ChunkDesc);
- PlaceTracks(a_ChunkDesc);
- PlaceSpawner(a_ChunkDesc); // (must be after Tracks!)
- PlaceTorches(a_ChunkDesc);
-}
-
-
-
-
-
-void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
-{
- static const cLootProbab LootProbab[] =
- {
- // Item, MinAmount, MaxAmount, Weight
- { cItem(E_ITEM_IRON), 1, 5, 10 },
- { cItem(E_ITEM_GOLD), 1, 3, 5 },
- { cItem(E_ITEM_REDSTONE_DUST), 4, 9, 5 },
- { cItem(E_ITEM_DIAMOND), 1, 2, 3 },
- { cItem(E_ITEM_DYE, 1, 4), 4, 9, 5 }, // lapis lazuli dye
- { cItem(E_ITEM_COAL), 3, 8, 10 },
- { cItem(E_ITEM_BREAD), 1, 3, 15 },
- { cItem(E_ITEM_IRON_PICKAXE), 1, 1, 1 },
- { cItem(E_BLOCK_MINECART_TRACKS), 4, 8, 1 },
- { cItem(E_ITEM_MELON_SEEDS), 2, 4, 10 },
- { cItem(E_ITEM_PUMPKIN_SEEDS), 2, 4, 10 },
- } ;
-
- if (m_ChestPosition < 0)
- {
- return;
- }
-
- int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
- int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
- int x, z;
- NIBBLETYPE Meta = 0;
- switch (m_Direction)
- {
- case dirXM:
- case dirXP:
- {
- x = m_BoundingBox.p1.x + m_ChestPosition - BlockX;
- z = m_BoundingBox.p1.z - BlockZ;
- Meta = E_META_CHEST_FACING_ZP;
- break;
- }
-
- case dirZM:
- case dirZP:
- {
- x = m_BoundingBox.p1.x - BlockX;
- z = m_BoundingBox.p1.z + m_ChestPosition - BlockZ;
- Meta = E_META_CHEST_FACING_XP;
- break;
- }
- } // switch (Dir)
-
- if (
- (x >= 0) && (x < cChunkDef::Width) &&
- (z >= 0) && (z < cChunkDef::Width)
- )
- {
- a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, Meta);
- cChestEntity * ChestEntity = new cChestEntity(BlockX + x, m_BoundingBox.p1.y + 1, BlockZ + z);
- cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ());
- int NumSlots = 3 + ((Noise.IntNoise3DInt(x, m_BoundingBox.p1.y, z) / 11) % 4);
- int Seed = Noise.IntNoise2DInt(x, z);
- ChestEntity->GetContents().GenerateRandomLootWithBooks(LootProbab, ARRAYCOUNT(LootProbab), NumSlots, Seed);
- a_ChunkDesc.AddBlockEntity(ChestEntity);
- }
-}
-
-
-
-
-
-void cMineShaftCorridor::PlaceTracks(cChunkDesc & a_ChunkDesc)
-{
- if (!m_HasTracks)
- {
- return;
- }
- cCuboid Box(m_BoundingBox);
- Box.Move(-a_ChunkDesc.GetChunkX() * cChunkDef::Width, 1, -a_ChunkDesc.GetChunkZ() * cChunkDef::Width);
- Box.p2.y = Box.p1.y;
- Box.p1.x += 1;
- Box.p2.x -= 1;
- Box.p1.z += 1;
- Box.p2.z -= 1;
- NIBBLETYPE Meta = 0;
- switch (m_Direction)
- {
- case dirXM:
- case dirXP:
- {
- Meta = E_META_TRACKS_X;
- break;
- }
-
- case dirZM:
- case dirZP:
- {
- Meta = E_META_TRACKS_Z;
- break;
- }
- } // switch (direction)
- a_ChunkDesc.RandomFillRelCuboid(Box, E_BLOCK_MINECART_TRACKS, Meta, a_ChunkDesc.GetChunkX() + a_ChunkDesc.GetChunkZ(), 6000);
-}
-
-
-
-
-
-void cMineShaftCorridor::PlaceSpawner(cChunkDesc & a_ChunkDesc)
-{
- if (m_SpawnerPosition < 0)
- {
- // No spawner in this corridor
- return;
- }
- int SpawnerRelX = m_BoundingBox.p1.x + 1 - a_ChunkDesc.GetChunkX() * cChunkDef::Width;
- int SpawnerRelZ = m_BoundingBox.p1.z + 1 - a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
- switch (m_Direction)
- {
- case dirXM:
- case dirXP:
- {
- SpawnerRelX += m_SpawnerPosition - 1;
- break;
- }
- case dirZM:
- case dirZP:
- {
- SpawnerRelZ += m_SpawnerPosition - 1;
- break;
- }
- }
- if (
- (SpawnerRelX >= 0) && (SpawnerRelX < cChunkDef::Width) &&
- (SpawnerRelZ >= 0) && (SpawnerRelZ < cChunkDef::Width)
- )
- {
- a_ChunkDesc.SetBlockTypeMeta(SpawnerRelX, m_BoundingBox.p1.y + 1, SpawnerRelZ, E_BLOCK_MOB_SPAWNER, 0);
- // TODO: The spawner needs its accompanying cMobSpawnerEntity, when implemented
- }
-}
-
-
-
-
-
-void cMineShaftCorridor::PlaceTorches(cChunkDesc & a_ChunkDesc)
-{
- cNoise Noise(m_BoundingBox.p1.x);
- switch (m_Direction)
- {
- case dirXM:
- case dirXP:
- {
- int z = m_BoundingBox.p1.z + 1 - a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
- if ((z < 0) || (z >= cChunkDef::Width))
- {
- return;
- }
- int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
- for (int i = 0; i < m_NumSegments; i++)
- {
- if (!m_HasFullBeam[i])
- {
- continue;
- }
- int x = m_BoundingBox.p1.x + i * 5 + 1 - BlockX;
- if ((x >= 0) && (x < cChunkDef::Width))
- {
- if (((Noise.IntNoise2DInt(x, z) / 7) % 10000) < m_ParentSystem.m_ChanceTorch)
- {
- a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p2.y, z, E_BLOCK_TORCH, E_META_TORCH_XP);
- }
- }
- x += 2;
- if ((x >= 0) && (x < cChunkDef::Width))
- {
- if (((Noise.IntNoise2DInt(x, z) / 7) % 10000) < m_ParentSystem.m_ChanceTorch)
- {
- a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p2.y, z, E_BLOCK_TORCH, E_META_TORCH_XM);
- }
- }
- } // for i
- break;
- }
-
- case dirZM:
- case dirZP:
- {
- int x = m_BoundingBox.p1.x + 1 - a_ChunkDesc.GetChunkX() * cChunkDef::Width;
- if ((x < 0) || (x >= cChunkDef::Width))
- {
- return;
- }
- int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
- for (int i = 0; i < m_NumSegments; i++)
- {
- if (!m_HasFullBeam[i])
- {
- continue;
- }
- int z = m_BoundingBox.p1.z + i * 5 + 1 - BlockZ;
- if ((z >= 0) && (z < cChunkDef::Width))
- {
- if (((Noise.IntNoise2DInt(x, z) / 7) % 10000) < m_ParentSystem.m_ChanceTorch)
- {
- a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p2.y, z, E_BLOCK_TORCH, E_META_TORCH_ZP);
- }
- }
- z += 2;
- if ((z >= 0) && (z < cChunkDef::Width))
- {
- if (((Noise.IntNoise2DInt(x, z) / 7) % 10000) < m_ParentSystem.m_ChanceTorch)
- {
- a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p2.y, z, E_BLOCK_TORCH, E_META_TORCH_ZM);
- }
- }
- } // for i
- break;
- }
- } // switch (direction)
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cMineShaftCrossing:
-
-cMineShaftCrossing::cMineShaftCrossing(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox) :
- super(a_ParentSystem, mskCrossing, a_BoundingBox)
-{
-}
-
-
-
-
-
-cMineShaft * cMineShaftCrossing::CreateAndFit(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
- cNoise & a_Noise
-)
-{
- 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;
- BoundingBox.p2.y += 3;
- if ((rnd % 4) < 2)
- {
- // 2-level crossing:
- BoundingBox.p2.y += 4;
- rnd >>= 2;
- if ((rnd % 4) < 2)
- {
- // This is the higher level:
- BoundingBox.p1.y -= 4;
- BoundingBox.p2.y -= 4;
- }
- }
- rnd >>= 2;
- switch (a_Direction)
- {
- case dirXP: BoundingBox.p2.x += 4; BoundingBox.p1.z -= 2; BoundingBox.p2.z += 2; break;
- case dirXM: BoundingBox.p1.x -= 4; BoundingBox.p1.z -= 2; BoundingBox.p2.z += 2; break;
- case dirZP: BoundingBox.p2.z += 4; BoundingBox.p1.x -= 2; BoundingBox.p2.x += 2; break;
- case dirZM: BoundingBox.p1.z -= 4; BoundingBox.p1.x -= 2; BoundingBox.p2.x += 2; break;
- }
- if (!a_ParentSystem.CanAppend(BoundingBox))
- {
- return NULL;
- }
- return new cMineShaftCrossing(a_ParentSystem, BoundingBox);
-}
-
-
-
-
-
-void cMineShaftCrossing::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
-{
- struct
- {
- int x, y, z;
- eDirection dir;
- } Exits[] =
- {
- // Bottom level:
- {-1, 1, 2, dirXM},
- { 2, 1, -1, dirZM},
- { 5, 1, 2, dirXP},
- { 2, 1, 5, dirZP},
- // Top level:
- {-1, 5, 2, dirXM},
- { 2, 5, -1, dirZM},
- { 5, 5, 2, dirXP},
- { 2, 5, 5, dirZP},
- } ;
- for (int i = 0; i < ARRAYCOUNT(Exits); i++)
- {
- if (m_BoundingBox.p1.y + Exits[i].y >= m_BoundingBox.p2.y)
- {
- // This exit is not available (two-level exit on a one-level crossing)
- continue;
- }
-
- int Height = m_BoundingBox.p1.y + Exits[i].y;
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Exits[i].x, Height, m_BoundingBox.p1.z + Exits[i].z, Exits[i].dir, a_Noise, a_RecursionLevel);
- } // for i
-}
-
-
-
-
-
-void cMineShaftCrossing::ProcessChunk(cChunkDesc & a_ChunkDesc)
-{
- int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
- int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
- cCuboid box(m_BoundingBox);
- box.Move(-BlockX, 0, -BlockZ);
- if ((box.p2.x < 0) || (box.p2.z < 0) || (box.p1.x >= cChunkDef::Width) || (box.p1.z > cChunkDef::Width))
- {
- // Does not intersect this chunk
- return;
- }
- int Floor = box.p1.y + 1;
- int Ceil = box.p2.y;
-
- // The supports:
- a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p1.x + 1, Floor, Ceil, box.p1.z + 1, box.p1.z + 1, E_BLOCK_PLANKS, 0);
- a_ChunkDesc.FillRelCuboid(box.p2.x - 1, box.p2.x - 1, Floor, Ceil, box.p1.z + 1, box.p1.z + 1, E_BLOCK_PLANKS, 0);
- a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p1.x + 1, Floor, Ceil, box.p2.z - 1, box.p2.z - 1, E_BLOCK_PLANKS, 0);
- a_ChunkDesc.FillRelCuboid(box.p2.x - 1, box.p2.x - 1, Floor, Ceil, box.p2.z - 1, box.p2.z - 1, E_BLOCK_PLANKS, 0);
-
- // The air in between:
- a_ChunkDesc.FillRelCuboid(box.p1.x + 2, box.p1.x + 2, Floor, Ceil, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Floor, Ceil, box.p1.z + 2, box.p1.z + 2, E_BLOCK_AIR, 0);
-
- // The air on the edges:
- int Mid = Floor + 2;
- a_ChunkDesc.FillRelCuboid(box.p1.x, box.p1.x, Floor, Mid, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid(box.p2.x, box.p2.x, Floor, Mid, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Floor, Mid, box.p1.z, box.p1.z, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Floor, Mid, box.p2.z, box.p2.z, E_BLOCK_AIR, 0);
- Mid += 2;
- if (Mid < Ceil)
- {
- a_ChunkDesc.FillRelCuboid(box.p1.x, box.p1.x, Mid, Ceil, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid(box.p2.x, box.p2.x, Mid, Ceil, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Mid, Ceil, box.p1.z, box.p1.z, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Mid, Ceil, box.p2.z, box.p2.z, E_BLOCK_AIR, 0);
- }
-
- // The floor, if needed:
- box.p2.y = box.p1.y;
- a_ChunkDesc.FloorRelCuboid(box, E_BLOCK_PLANKS, 0);
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cMineShaftStaircase:
-
-cMineShaftStaircase::cMineShaftStaircase(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- const cCuboid & a_BoundingBox,
- eDirection a_Direction,
- eSlope a_Slope
-) :
- super(a_ParentSystem, mskStaircase, a_BoundingBox),
- m_Direction(a_Direction),
- m_Slope(a_Slope)
-{
-}
-
-
-
-
-
-cMineShaft * cMineShaftStaircase::CreateAndFit(
- cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
- int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
- cNoise & a_Noise
-)
-{
- int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
- cCuboid Box;
- switch (a_Direction)
- {
- case dirXM:
- {
- Box.Assign(a_PivotX - 7, a_PivotY - 1, a_PivotZ - 1, a_PivotX, a_PivotY + 6, a_PivotZ + 1);
- break;
- }
- case dirXP:
- {
- Box.Assign(a_PivotX, a_PivotY - 1, a_PivotZ - 1, a_PivotX + 7, a_PivotY + 6, a_PivotZ + 1);
- break;
- }
- case dirZM:
- {
- Box.Assign(a_PivotX - 1, a_PivotY - 1, a_PivotZ - 7, a_PivotX + 1, a_PivotY + 6, a_PivotZ);
- break;
- }
- case dirZP:
- {
- Box.Assign(a_PivotX - 1, a_PivotY - 1, a_PivotZ, a_PivotX + 1, a_PivotY + 6, a_PivotZ + 7);
- break;
- }
- }
- eSlope Slope = sUp;
- if ((rnd % 4) < 2) // 50 %
- {
- Slope = sDown;
- Box.Move(0, -4, 0);
- }
- if (!a_ParentSystem.CanAppend(Box))
- {
- return NULL;
- }
- return new cMineShaftStaircase(a_ParentSystem, Box, a_Direction, Slope);
-}
-
-
-
-
-
-void cMineShaftStaircase::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
-{
- int Height = m_BoundingBox.p1.y + ((m_Slope == sDown) ? 1 : 5);
- switch (m_Direction)
- {
- case dirXM: m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + 1, dirXM, a_Noise, a_RecursionLevel); break;
- case dirXP: m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + 1, dirXP, a_Noise, a_RecursionLevel); break;
- case dirZM: m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel); break;
- case dirZP: m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel); break;
- }
-}
-
-
-
-
-
-void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc)
-{
- int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
- int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
- cCuboid RelB(m_BoundingBox);
- RelB.Move(-BlockX, 0, -BlockZ);
- if (
- (RelB.p1.x >= cChunkDef::Width) ||
- (RelB.p1.z >= cChunkDef::Width) ||
- (RelB.p2.x < 0) ||
- (RelB.p2.z < 0)
- )
- {
- // No intersection between this staircase and this chunk
- return;
- }
-
- int SFloor = RelB.p1.y + ((m_Slope == sDown) ? 5 : 1);
- int DFloor = RelB.p1.y + ((m_Slope == sDown) ? 1 : 5);
- int Add = (m_Slope == sDown) ? -1 : 1;
- int InitAdd = (m_Slope == sDown) ? -1 : 0;
- cCuboid Box;
- switch (m_Direction)
- {
- case dirXM:
- {
- a_ChunkDesc.FillRelCuboid (RelB.p2.x - 1, RelB.p2.x, SFloor, SFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p1.x + 1, DFloor, DFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0);
- a_ChunkDesc.FloorRelCuboid(RelB.p2.x - 1, RelB.p2.x, SFloor - 1, SFloor - 1, RelB.p1.z, RelB.p2.z, E_BLOCK_PLANKS, 0);
- a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p1.x + 1, DFloor - 1, DFloor - 1, RelB.p1.z, RelB.p2.z, E_BLOCK_PLANKS, 0);
- Box.Assign(RelB.p2.x - 2, SFloor + InitAdd, RelB.p1.z, RelB.p2.x - 2, SFloor + 3 + InitAdd, RelB.p2.z);
- for (int i = 0; i < 4; i++)
- {
- a_ChunkDesc.FillRelCuboid(Box, E_BLOCK_AIR, 0);
- a_ChunkDesc.FloorRelCuboid(Box.p1.x, Box.p2.x, Box.p1.y - 1, Box.p1.y - 1, Box.p1.z, Box.p2.z, E_BLOCK_PLANKS, 0);
- Box.Move(-1, Add, 0);
- }
- break;
- }
-
- case dirXP:
- {
- a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p1.x + 1, SFloor, SFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid (RelB.p2.x - 1, RelB.p2.x, DFloor, DFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0);
- a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p1.x + 1, SFloor - 1, SFloor - 1, RelB.p1.z, RelB.p2.z, E_BLOCK_PLANKS, 0);
- a_ChunkDesc.FloorRelCuboid(RelB.p2.x - 1, RelB.p2.x, DFloor - 1, DFloor - 1, RelB.p1.z, RelB.p2.z, E_BLOCK_PLANKS, 0);
- Box.Assign(RelB.p1.x + 2, SFloor + InitAdd, RelB.p1.z, RelB.p1.x + 2, SFloor + 3 + InitAdd, RelB.p2.z);
- for (int i = 0; i < 4; i++)
- {
- a_ChunkDesc.FillRelCuboid(Box, E_BLOCK_AIR, 0);
- a_ChunkDesc.FloorRelCuboid(Box.p1.x, Box.p2.x, Box.p1.y - 1, Box.p1.y - 1, Box.p1.z, Box.p2.z, E_BLOCK_PLANKS, 0);
- Box.Move(1, Add, 0);
- }
- break;
- }
-
- case dirZM:
- {
- a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, SFloor, SFloor + 2, RelB.p2.z - 1, RelB.p2.z, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, DFloor, DFloor + 2, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_AIR, 0);
- a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p2.x, SFloor - 1, SFloor - 1, RelB.p2.z - 1, RelB.p2.z, E_BLOCK_PLANKS, 0);
- a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p2.x, DFloor - 1, DFloor - 1, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_PLANKS, 0);
- Box.Assign(RelB.p1.x, SFloor + InitAdd, RelB.p2.z - 2, RelB.p2.x, SFloor + 3 + InitAdd, RelB.p2.z - 2);
- for (int i = 0; i < 4; i++)
- {
- a_ChunkDesc.FillRelCuboid(Box, E_BLOCK_AIR, 0);
- a_ChunkDesc.FloorRelCuboid(Box.p1.x, Box.p2.x, Box.p1.y - 1, Box.p1.y - 1, Box.p1.z, Box.p2.z, E_BLOCK_PLANKS, 0);
- Box.Move(0, Add, -1);
- }
- break;
- }
-
- case dirZP:
- {
- a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, SFloor, SFloor + 2, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_AIR, 0);
- a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, DFloor, DFloor + 2, RelB.p2.z - 1, RelB.p2.z, E_BLOCK_AIR, 0);
- a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p2.x, SFloor - 1, SFloor - 1, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_PLANKS, 0);
- a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p2.x, DFloor - 1, DFloor - 1, RelB.p2.z - 1, RelB.p2.z, E_BLOCK_PLANKS, 0);
- Box.Assign(RelB.p1.x, SFloor + InitAdd, RelB.p1.z + 2, RelB.p2.x, SFloor + 3 + InitAdd, RelB.p1.z + 2);
- for (int i = 0; i < 4; i++)
- {
- a_ChunkDesc.FillRelCuboid(Box, E_BLOCK_AIR, 0);
- a_ChunkDesc.FloorRelCuboid(Box.p1.x, Box.p2.x, Box.p1.y - 1, Box.p1.y - 1, Box.p1.z, Box.p2.z, E_BLOCK_PLANKS, 0);
- Box.Move(0, Add, 1);
- }
- break;
- }
-
- } // switch (m_Direction)
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cStructGenMineShafts:
-
-cStructGenMineShafts::cStructGenMineShafts(
- int a_Seed, int a_GridSize, int a_MaxSystemSize,
- int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase
-) :
- m_Noise(a_Seed),
- m_GridSize(a_GridSize),
- m_MaxSystemSize(a_MaxSystemSize),
- m_ProbLevelCorridor(std::max(0, a_ChanceCorridor)),
- m_ProbLevelCrossing(std::max(0, a_ChanceCorridor + a_ChanceCrossing)),
- m_ProbLevelStaircase(std::max(0, a_ChanceCorridor + a_ChanceCrossing + a_ChanceStaircase))
-{
-}
-
-
-
-
-
-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_Caves:
- 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::GenStructures(cChunkDesc & a_ChunkDesc)
-{
- 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[]
-}
-
-
-
-
+
+// MineShafts.cpp
+
+// Implements the cStructGenMineShafts class representing the structure generator for abandoned mineshafts
+
+/*
+Algorithm:
+The cStructGenMineShafts::cMineShaftSystem class is the main controller, which knows what mineshaft
+classes there are and their random weights. It gets asked to produce a new class everytime a connection is to be made.
+The cMineShaft class is a base class for each mineshaft structure.
+Each cMineShaft descendant knows how large it is, how to imprint itself into the chunk data and where to connect to
+other descendants. Its PivotPoint is always a walkable column. Its Direction determines in which direction the structure
+is facing.
+
+The generation starts with the central dirt room, from there corridors, crossings and staircases are added
+in a depth-first processing. Each of the descendants will branch randomly, if not beyond the allowed recursion level
+*/
+
+#include "Globals.h"
+#include "MineShafts.h"
+#include "../Cuboid.h"
+#include "../BlockEntities/ChestEntity.h"
+
+
+
+
+
+static const int NEIGHBORHOOD_SIZE = 3;
+
+
+
+
+
+class cMineShaft abstract
+{
+public:
+ enum eKind
+ {
+ mskDirtRoom,
+ mskCorridor,
+ mskCrossing,
+ mskStaircase,
+ } ;
+
+
+ enum eDirection
+ {
+ dirXP,
+ dirZP,
+ dirXM,
+ dirZM,
+ } ;
+
+
+ cStructGenMineShafts::cMineShaftSystem & m_ParentSystem;
+ eKind m_Kind;
+ cCuboid m_BoundingBox;
+
+
+ cMineShaft(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, eKind a_Kind) :
+ m_ParentSystem(a_ParentSystem),
+ m_Kind(a_Kind)
+ {
+ }
+
+ cMineShaft(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, eKind a_Kind, const cCuboid & a_BoundingBox) :
+ m_ParentSystem(a_ParentSystem),
+ m_Kind(a_Kind),
+ m_BoundingBox(a_BoundingBox)
+ {
+ }
+
+ /// Returns true if this mineshaft intersects the specified cuboid
+ bool DoesIntersect(const cCuboid & a_Other)
+ {
+ return m_BoundingBox.DoesIntersect(a_Other);
+ }
+
+ /** If recursion level is not too large, appends more branches to the parent system,
+ using exit points specific to this class.
+ */
+ virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) = 0;
+
+ /// Imprints this shape into the specified chunk's data
+ virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) = 0;
+} ;
+
+typedef std::vector<cMineShaft *> cMineShafts;
+
+
+
+
+
+class cMineShaftDirtRoom :
+ public cMineShaft
+{
+ typedef cMineShaft super;
+
+public:
+ cMineShaftDirtRoom(cStructGenMineShafts::cMineShaftSystem & a_Parent, cNoise & a_Noise);
+
+ // cMineShaft overrides:
+ virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
+ virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
+
+class cMineShaftCorridor :
+ public cMineShaft
+{
+ typedef cMineShaft super;
+
+public:
+ /** Creates a new Corridor attached to the specified pivot point and direction.
+ Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
+ May return NULL if cannot fit.
+ */
+ static cMineShaft * CreateAndFit(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
+ cNoise & a_Noise
+ );
+
+protected:
+ static const int MAX_SEGMENTS = 5;
+
+ int m_NumSegments;
+ eDirection m_Direction;
+ bool m_HasFullBeam[MAX_SEGMENTS]; ///< If true, segment at that index has a full beam support (planks in the top center block)
+ int m_ChestPosition; ///< If <0, no chest; otherwise an offset from m_BoundingBox's p1.x or p1.z, depenging on m_Direction
+ int m_SpawnerPosition; ///< If <0, no spawner; otherwise an offset from m_BoundingBox's p1.x or p1.z, depenging on m_Direction
+ bool m_HasTracks; ///< If true, random tracks will be placed on the floor
+
+ cMineShaftCorridor(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ const cCuboid & a_BoundingBox, int a_NumSegments, eDirection a_Direction,
+ cNoise & a_Noise
+ );
+
+ // cMineShaft overrides:
+ virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
+ virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
+
+ /// Places a chest, if the corridor has one
+ void PlaceChest(cChunkDesc & a_ChunkDesc);
+
+ /// If this corridor has tracks, places them randomly
+ void PlaceTracks(cChunkDesc & a_ChunkDesc);
+
+ /// If this corridor has a spawner, places the spawner
+ void PlaceSpawner(cChunkDesc & a_ChunkDesc);
+
+ /// Randomly places torches around the central beam block
+ void PlaceTorches(cChunkDesc & a_ChunkDesc);
+} ;
+
+
+
+
+
+class cMineShaftCrossing :
+ public cMineShaft
+{
+ typedef cMineShaft super;
+
+public:
+ /** Creates a new Crossing attached to the specified pivot point and direction.
+ Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
+ May return NULL if cannot fit.
+ */
+ static cMineShaft * CreateAndFit(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
+ cNoise & a_Noise
+ );
+
+protected:
+ cMineShaftCrossing(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox);
+
+ // cMineShaft overrides:
+ virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
+ virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
+
+class cMineShaftStaircase :
+ public cMineShaft
+{
+ typedef cMineShaft super;
+
+public:
+ enum eSlope
+ {
+ sUp,
+ sDown,
+ } ;
+
+ /** Creates a new Staircase attached to the specified pivot point and direction.
+ Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
+ May return NULL if cannot fit.
+ */
+ static cMineShaft * CreateAndFit(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
+ cNoise & a_Noise
+ );
+
+protected:
+ eDirection m_Direction;
+ eSlope m_Slope;
+
+
+ cMineShaftStaircase(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ const cCuboid & a_BoundingBox,
+ eDirection a_Direction,
+ eSlope a_Slope
+ );
+
+ // cMineShaft overrides:
+ virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
+ virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
+
+class cStructGenMineShafts::cMineShaftSystem
+{
+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
+ 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
+ int m_ChanceChest; ///< Chance [0 .. 250] that a corridor has a chest in it
+ int m_ChanceSpawner; ///< Chance [0 .. 250] that a corridor has a spawner in it
+ int m_ChanceTorch; ///< Chance [0 .. 10k] for a torch appearing attached to a corridor's beam
+ 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
+ cMineShaftSystem(
+ int a_BlockX, int a_BlockZ, 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()
+ */
+ void AppendBranch(
+ int a_BlockX, int a_BlockY, int a_BlockZ,
+ cMineShaft::eDirection a_Direction, cNoise & a_Noise,
+ 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
+ bool CanAppend(const cCuboid & a_BoundingBox);
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cStructGenMineShafts::cMineShaftSystem:
+
+cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem(
+ int a_BlockX, int a_BlockZ, 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),
+ m_GridSize(a_GridSize),
+ m_MaxRecursion(8), // TODO: settable
+ m_ProbLevelCorridor(a_ProbLevelCorridor),
+ m_ProbLevelCrossing(a_ProbLevelCrossing),
+ m_ProbLevelStaircase(a_ProbLevelStaircase + 1),
+ m_ChanceChest(12), // TODO: settable
+ m_ChanceSpawner(12), // TODO: settable
+ m_ChanceTorch(1000) // TODO: settable
+{
+ m_MineShafts.reserve(100);
+
+ cMineShaft * Start = new cMineShaftDirtRoom(*this, a_Noise);
+ m_MineShafts.push_back(Start);
+
+ m_BoundingBox.Assign(
+ Start->m_BoundingBox.p1.x - a_MaxSystemSize / 2, 2, Start->m_BoundingBox.p1.z - a_MaxSystemSize / 2,
+ Start->m_BoundingBox.p2.x + a_MaxSystemSize / 2, 50, Start->m_BoundingBox.p2.z + a_MaxSystemSize / 2
+ );
+
+ Start->AppendBranches(0, a_Noise);
+
+ for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
+ {
+ ASSERT((*itr)->m_BoundingBox.IsSorted());
+ } // for itr - m_MineShafts[]
+}
+
+
+
+
+
+cStructGenMineShafts::cMineShaftSystem::~cMineShaftSystem()
+{
+ for (cMineShafts::iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
+ {
+ delete *itr;
+ } // for itr - m_MineShafts[]
+ m_MineShafts.clear();
+}
+
+
+
+
+
+void cStructGenMineShafts::cMineShaftSystem::ProcessChunk(cChunkDesc & a_Chunk)
+{
+ for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
+ {
+ (*itr)->ProcessChunk(a_Chunk);
+ } // for itr - m_MineShafts[]
+}
+
+
+
+
+
+void cStructGenMineShafts::cMineShaftSystem::AppendBranch(
+ int a_PivotX, int a_PivotY, int a_PivotZ,
+ cMineShaft::eDirection a_Direction, cNoise & a_Noise,
+ int a_RecursionLevel
+)
+{
+ if (a_RecursionLevel > m_MaxRecursion)
+ {
+ return;
+ }
+
+ cMineShaft * Next = NULL;
+ int rnd = (a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_RecursionLevel * 16, a_PivotZ) / 13) % m_ProbLevelStaircase;
+ if (rnd < m_ProbLevelCorridor)
+ {
+ Next = cMineShaftCorridor::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise);
+ }
+ else if (rnd < m_ProbLevelCrossing)
+ {
+ Next = cMineShaftCrossing::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise);
+ }
+ else
+ {
+ Next = cMineShaftStaircase::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise);
+ }
+ if (Next == NULL)
+ {
+ return;
+ }
+ m_MineShafts.push_back(Next);
+ Next->AppendBranches(a_RecursionLevel + 1, a_Noise);
+}
+
+
+
+
+
+bool cStructGenMineShafts::cMineShaftSystem::CanAppend(const cCuboid & a_BoundingBox)
+{
+ if (!a_BoundingBox.IsCompletelyInside(m_BoundingBox))
+ {
+ // Too far away, or too low / too high
+ return false;
+ }
+
+ // Check intersections:
+ for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
+ {
+ if ((*itr)->DoesIntersect(a_BoundingBox))
+ {
+ return false;
+ }
+ } // for itr - m_MineShafts[]
+ return true;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// 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 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;
+ m_BoundingBox.p2.x = m_BoundingBox.p1.x + 10 + (rnd % 8);
+ rnd >>= 4;
+ m_BoundingBox.p1.z = a_Parent.m_BlockZ + OfsZ;
+ m_BoundingBox.p2.z = m_BoundingBox.p1.z + 10 + (rnd % 8);
+ rnd >>= 4;
+ m_BoundingBox.p1.y = 20;
+ m_BoundingBox.p2.y = 24 + rnd % 8;
+}
+
+
+
+
+
+void cMineShaftDirtRoom::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
+{
+ int Height = m_BoundingBox.DifY() - 3;
+ for (int x = m_BoundingBox.p1.x + 1; x < m_BoundingBox.p2.x; x += 4)
+ {
+ int rnd = a_Noise.IntNoise3DInt(x, a_RecursionLevel, m_BoundingBox.p1.z) / 7;
+ m_ParentSystem.AppendBranch(x, m_BoundingBox.p1.y + (rnd % Height), m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
+ rnd >>= 4;
+ m_ParentSystem.AppendBranch(x, m_BoundingBox.p1.y + (rnd % Height), m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
+ }
+
+ for (int z = m_BoundingBox.p1.z + 1; z < m_BoundingBox.p2.z; z += 4)
+ {
+ int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, a_RecursionLevel, z) / 13;
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, m_BoundingBox.p1.y + (rnd % Height), z, dirXM, a_Noise, a_RecursionLevel);
+ rnd >>= 4;
+ m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, m_BoundingBox.p1.y + (rnd % Height), z, dirXP, a_Noise, a_RecursionLevel);
+ }
+}
+
+
+
+
+
+void cMineShaftDirtRoom::ProcessChunk(cChunkDesc & a_ChunkDesc)
+{
+ int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ if (
+ (m_BoundingBox.p1.x > BlockX + cChunkDef::Width) ||
+ (m_BoundingBox.p1.z > BlockZ + cChunkDef::Width) ||
+ (m_BoundingBox.p2.x < BlockX) ||
+ (m_BoundingBox.p2.z < BlockZ)
+ )
+ {
+ // Early bailout - cannot intersect this chunk
+ return;
+ }
+
+ // Chunk-relative coords of the boundaries:
+ int MinX = std::max(BlockX, m_BoundingBox.p1.x) - BlockX;
+ int MaxX = std::min(BlockX + cChunkDef::Width, m_BoundingBox.p2.x + 1) - BlockX;
+ int MinZ = std::max(BlockZ, m_BoundingBox.p1.z) - BlockZ;
+ int MaxZ = std::min(BlockZ + cChunkDef::Width, m_BoundingBox.p2.z + 1) - BlockZ;
+
+ // Carve the room out:
+ for (int z = MinZ; z < MaxZ; z++)
+ {
+ for (int x = MinX; x < MaxX; x++)
+ {
+ for (int y = m_BoundingBox.p1.y + 1; y < m_BoundingBox.p2.y; y++)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
+ }
+ if (a_ChunkDesc.GetBlockType(x, m_BoundingBox.p1.y, z) != E_BLOCK_AIR)
+ {
+ a_ChunkDesc.SetBlockType(x, m_BoundingBox.p1.y, z, E_BLOCK_DIRT);
+ }
+ } // for x
+ } // for z
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cMineShaftCorridor:
+
+cMineShaftCorridor::cMineShaftCorridor(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ const cCuboid & a_BoundingBox, int a_NumSegments, eDirection a_Direction,
+ cNoise & a_Noise
+) :
+ super(a_ParentSystem, mskCorridor, a_BoundingBox),
+ m_NumSegments(a_NumSegments),
+ m_Direction(a_Direction),
+ m_ChestPosition(-1),
+ m_SpawnerPosition(-1)
+{
+ int rnd = a_Noise.IntNoise3DInt(a_BoundingBox.p1.x, a_BoundingBox.p1.y, a_BoundingBox.p1.z) / 7;
+ for (int i = 0; i < a_NumSegments; i++)
+ {
+ m_HasFullBeam[i] = (rnd % 4) < 3; // 75 % chance of full beam
+ rnd >>= 2;
+ }
+ m_HasTracks = ((rnd % 4) < 2); // 50 % chance of tracks
+
+ rnd = a_Noise.IntNoise3DInt(a_BoundingBox.p1.z, a_BoundingBox.p1.x, a_BoundingBox.p1.y) / 7;
+ int ChestCheck = rnd % 250;
+ rnd >>= 8;
+ int SpawnerCheck = rnd % 250;
+ rnd >>= 8;
+ if (ChestCheck < a_ParentSystem.m_ChanceChest)
+ {
+ m_ChestPosition = rnd % (a_NumSegments * 5);
+ }
+ if ((a_NumSegments < 4) && (SpawnerCheck < a_ParentSystem.m_ChanceSpawner))
+ {
+ m_SpawnerPosition = rnd % (a_NumSegments * 5);
+ }
+}
+
+
+
+
+
+cMineShaft * cMineShaftCorridor::CreateAndFit(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
+ cNoise & a_Noise
+)
+{
+ 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 NumSegments = 2 + (rnd) % (MAX_SEGMENTS - 1); // 2 .. MAX_SEGMENTS
+ switch (a_Direction)
+ {
+ case dirXP: BoundingBox.p2.x += NumSegments * 5 - 1; BoundingBox.p1.z -= 1; BoundingBox.p2.z += 1; break;
+ case dirXM: BoundingBox.p1.x -= NumSegments * 5 - 1; BoundingBox.p1.z -= 1; BoundingBox.p2.z += 1; break;
+ case dirZP: BoundingBox.p2.z += NumSegments * 5 - 1; BoundingBox.p1.x -= 1; BoundingBox.p2.x += 1; break;
+ case dirZM: BoundingBox.p1.z -= NumSegments * 5 - 1; BoundingBox.p1.x -= 1; BoundingBox.p2.x += 1; break;
+ }
+ if (!a_ParentSystem.CanAppend(BoundingBox))
+ {
+ return NULL;
+ }
+ return new cMineShaftCorridor(a_ParentSystem, BoundingBox, NumSegments, a_Direction, a_Noise);
+}
+
+
+
+
+
+void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
+{
+ int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 7;
+ // Prefer the same height, but allow for up to one block height displacement:
+ int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
+ switch (m_Direction)
+ {
+ case dirXM:
+ {
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + 1, dirXM, a_Noise, a_RecursionLevel);
+ for (int i = m_NumSegments; i >= 0; i--)
+ {
+ int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
+ int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
+ rnd >>= 6;
+ int Ofs = 1 + rnd % (m_NumSegments * 5 - 2);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Ofs, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Ofs, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
+ }
+ break;
+ }
+
+ case dirXP:
+ {
+ m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + 1, dirXP, a_Noise, a_RecursionLevel);
+ for (int i = m_NumSegments; i >= 0; i--)
+ {
+ int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
+ int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
+ rnd >>= 6;
+ int Ofs = 1 + rnd % (m_NumSegments * 5 - 2);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Ofs, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Ofs, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
+ }
+ break;
+ }
+
+ case dirZM:
+ {
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
+ for (int i = m_NumSegments; i >= 0; i--)
+ {
+ int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
+ int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
+ rnd >>= 6;
+ int Ofs = 1 + rnd % (m_NumSegments * 5 - 2);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + Ofs, dirXM, a_Noise, a_RecursionLevel);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + Ofs, dirXP, a_Noise, a_RecursionLevel);
+ }
+ break;
+ }
+
+ case dirZP:
+ {
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
+ for (int i = m_NumSegments; i >= 0; i--)
+ {
+ int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
+ int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
+ rnd >>= 6;
+ int Ofs = 1 + rnd % (m_NumSegments * 5 - 2);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + Ofs, dirXM, a_Noise, a_RecursionLevel);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + Ofs, dirXP, a_Noise, a_RecursionLevel);
+ }
+ break;
+ }
+ } // switch (m_Direction)
+}
+
+
+
+
+
+void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc)
+{
+ int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ cCuboid RelBoundingBox(m_BoundingBox);
+ RelBoundingBox.Move(-BlockX, 0, -BlockZ);
+ RelBoundingBox.p1.y += 1;
+ RelBoundingBox.p2.y -= 1;
+ cCuboid Top(RelBoundingBox);
+ Top.p2.y += 1;
+ Top.p1.y = Top.p2.y;
+ a_ChunkDesc.FillRelCuboid(RelBoundingBox, E_BLOCK_AIR, 0);
+ a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_AIR, 0, BlockX ^ BlockZ + BlockX, 8000);
+ if (m_SpawnerPosition >= 0)
+ {
+ // Cobwebs around the spider spawner
+ a_ChunkDesc.RandomFillRelCuboid(RelBoundingBox, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockZ, 8000);
+ a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX, 5000);
+ }
+ a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX + 10, 500);
+ RelBoundingBox.p1.y = m_BoundingBox.p1.y;
+ RelBoundingBox.p2.y = m_BoundingBox.p1.y;
+ a_ChunkDesc.FloorRelCuboid(RelBoundingBox, E_BLOCK_PLANKS, 0);
+ switch (m_Direction)
+ {
+ case dirXM:
+ case dirXP:
+ {
+ int y1 = m_BoundingBox.p1.y + 1;
+ int y2 = m_BoundingBox.p1.y + 2;
+ int y3 = m_BoundingBox.p1.y + 3;
+ int z1 = m_BoundingBox.p1.z - BlockZ;
+ int z2 = m_BoundingBox.p2.z - BlockZ;
+ for (int i = 0; i < m_NumSegments; i++)
+ {
+ int x = m_BoundingBox.p1.x + i * 5 + 2 - BlockX;
+ if ((x < 0) || (x >= cChunkDef::Width))
+ {
+ continue;
+ }
+ if ((z1 >= 0) && (z1 < cChunkDef::Width))
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, y1, z1, E_BLOCK_FENCE, 0);
+ a_ChunkDesc.SetBlockTypeMeta(x, y2, z1, E_BLOCK_FENCE, 0);
+ a_ChunkDesc.SetBlockTypeMeta(x, y3, z1, E_BLOCK_PLANKS, 0);
+ }
+ if ((z2 >= 0) && (z2 < cChunkDef::Width))
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, y1, z2, E_BLOCK_FENCE, 0);
+ a_ChunkDesc.SetBlockTypeMeta(x, y2, z2, E_BLOCK_FENCE, 0);
+ a_ChunkDesc.SetBlockTypeMeta(x, y3, z2, E_BLOCK_PLANKS, 0);
+ }
+ if ((z1 >= -1) && (z1 < cChunkDef::Width - 1) && m_HasFullBeam[i])
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, y3, z1 + 1, E_BLOCK_PLANKS, 0);
+ }
+ } // for i - NumSegments
+ break;
+ }
+
+ case dirZM:
+ case dirZP:
+ {
+ int y1 = m_BoundingBox.p1.y + 1;
+ int y2 = m_BoundingBox.p1.y + 2;
+ int y3 = m_BoundingBox.p1.y + 3;
+ int x1 = m_BoundingBox.p1.x - BlockX;
+ int x2 = m_BoundingBox.p2.x - BlockX;
+ for (int i = 0; i < m_NumSegments; i++)
+ {
+ int z = m_BoundingBox.p1.z + i * 5 + 2 - BlockZ;
+ if ((z < 0) || (z >= cChunkDef::Width))
+ {
+ continue;
+ }
+ if ((x1 >= 0) && (x1 < cChunkDef::Width))
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x1, y1, z, E_BLOCK_FENCE, 0);
+ a_ChunkDesc.SetBlockTypeMeta(x1, y2, z, E_BLOCK_FENCE, 0);
+ a_ChunkDesc.SetBlockTypeMeta(x1, y3, z, E_BLOCK_PLANKS, 0);
+ }
+ if ((x2 >= 0) && (x2 < cChunkDef::Width))
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x2, y1, z, E_BLOCK_FENCE, 0);
+ a_ChunkDesc.SetBlockTypeMeta(x2, y2, z, E_BLOCK_FENCE, 0);
+ a_ChunkDesc.SetBlockTypeMeta(x2, y3, z, E_BLOCK_PLANKS, 0);
+ }
+ if ((x1 >= -1) && (x1 < cChunkDef::Width - 1) && m_HasFullBeam[i])
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x1 + 1, y3, z, E_BLOCK_PLANKS, 0);
+ }
+ } // for i - NumSegments
+ break;
+ } // case dirZ?
+ } // for i
+
+ PlaceChest(a_ChunkDesc);
+ PlaceTracks(a_ChunkDesc);
+ PlaceSpawner(a_ChunkDesc); // (must be after Tracks!)
+ PlaceTorches(a_ChunkDesc);
+}
+
+
+
+
+
+void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
+{
+ static const cLootProbab LootProbab[] =
+ {
+ // Item, MinAmount, MaxAmount, Weight
+ { cItem(E_ITEM_IRON), 1, 5, 10 },
+ { cItem(E_ITEM_GOLD), 1, 3, 5 },
+ { cItem(E_ITEM_REDSTONE_DUST), 4, 9, 5 },
+ { cItem(E_ITEM_DIAMOND), 1, 2, 3 },
+ { cItem(E_ITEM_DYE, 1, 4), 4, 9, 5 }, // lapis lazuli dye
+ { cItem(E_ITEM_COAL), 3, 8, 10 },
+ { cItem(E_ITEM_BREAD), 1, 3, 15 },
+ { cItem(E_ITEM_IRON_PICKAXE), 1, 1, 1 },
+ { cItem(E_BLOCK_MINECART_TRACKS), 4, 8, 1 },
+ { cItem(E_ITEM_MELON_SEEDS), 2, 4, 10 },
+ { cItem(E_ITEM_PUMPKIN_SEEDS), 2, 4, 10 },
+ } ;
+
+ if (m_ChestPosition < 0)
+ {
+ return;
+ }
+
+ int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ int x, z;
+ NIBBLETYPE Meta = 0;
+ switch (m_Direction)
+ {
+ case dirXM:
+ case dirXP:
+ {
+ x = m_BoundingBox.p1.x + m_ChestPosition - BlockX;
+ z = m_BoundingBox.p1.z - BlockZ;
+ Meta = E_META_CHEST_FACING_ZP;
+ break;
+ }
+
+ case dirZM:
+ case dirZP:
+ {
+ x = m_BoundingBox.p1.x - BlockX;
+ z = m_BoundingBox.p1.z + m_ChestPosition - BlockZ;
+ Meta = E_META_CHEST_FACING_XP;
+ break;
+ }
+ } // switch (Dir)
+
+ if (
+ (x >= 0) && (x < cChunkDef::Width) &&
+ (z >= 0) && (z < cChunkDef::Width)
+ )
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, Meta);
+ cChestEntity * ChestEntity = new cChestEntity(BlockX + x, m_BoundingBox.p1.y + 1, BlockZ + z);
+ cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ());
+ int NumSlots = 3 + ((Noise.IntNoise3DInt(x, m_BoundingBox.p1.y, z) / 11) % 4);
+ int Seed = Noise.IntNoise2DInt(x, z);
+ ChestEntity->GetContents().GenerateRandomLootWithBooks(LootProbab, ARRAYCOUNT(LootProbab), NumSlots, Seed);
+ a_ChunkDesc.AddBlockEntity(ChestEntity);
+ }
+}
+
+
+
+
+
+void cMineShaftCorridor::PlaceTracks(cChunkDesc & a_ChunkDesc)
+{
+ if (!m_HasTracks)
+ {
+ return;
+ }
+ cCuboid Box(m_BoundingBox);
+ Box.Move(-a_ChunkDesc.GetChunkX() * cChunkDef::Width, 1, -a_ChunkDesc.GetChunkZ() * cChunkDef::Width);
+ Box.p2.y = Box.p1.y;
+ Box.p1.x += 1;
+ Box.p2.x -= 1;
+ Box.p1.z += 1;
+ Box.p2.z -= 1;
+ NIBBLETYPE Meta = 0;
+ switch (m_Direction)
+ {
+ case dirXM:
+ case dirXP:
+ {
+ Meta = E_META_TRACKS_X;
+ break;
+ }
+
+ case dirZM:
+ case dirZP:
+ {
+ Meta = E_META_TRACKS_Z;
+ break;
+ }
+ } // switch (direction)
+ a_ChunkDesc.RandomFillRelCuboid(Box, E_BLOCK_MINECART_TRACKS, Meta, a_ChunkDesc.GetChunkX() + a_ChunkDesc.GetChunkZ(), 6000);
+}
+
+
+
+
+
+void cMineShaftCorridor::PlaceSpawner(cChunkDesc & a_ChunkDesc)
+{
+ if (m_SpawnerPosition < 0)
+ {
+ // No spawner in this corridor
+ return;
+ }
+ int SpawnerRelX = m_BoundingBox.p1.x + 1 - a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ int SpawnerRelZ = m_BoundingBox.p1.z + 1 - a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ switch (m_Direction)
+ {
+ case dirXM:
+ case dirXP:
+ {
+ SpawnerRelX += m_SpawnerPosition - 1;
+ break;
+ }
+ case dirZM:
+ case dirZP:
+ {
+ SpawnerRelZ += m_SpawnerPosition - 1;
+ break;
+ }
+ }
+ if (
+ (SpawnerRelX >= 0) && (SpawnerRelX < cChunkDef::Width) &&
+ (SpawnerRelZ >= 0) && (SpawnerRelZ < cChunkDef::Width)
+ )
+ {
+ a_ChunkDesc.SetBlockTypeMeta(SpawnerRelX, m_BoundingBox.p1.y + 1, SpawnerRelZ, E_BLOCK_MOB_SPAWNER, 0);
+ // TODO: The spawner needs its accompanying cMobSpawnerEntity, when implemented
+ }
+}
+
+
+
+
+
+void cMineShaftCorridor::PlaceTorches(cChunkDesc & a_ChunkDesc)
+{
+ cNoise Noise(m_BoundingBox.p1.x);
+ switch (m_Direction)
+ {
+ case dirXM:
+ case dirXP:
+ {
+ int z = m_BoundingBox.p1.z + 1 - a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ if ((z < 0) || (z >= cChunkDef::Width))
+ {
+ return;
+ }
+ int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ for (int i = 0; i < m_NumSegments; i++)
+ {
+ if (!m_HasFullBeam[i])
+ {
+ continue;
+ }
+ int x = m_BoundingBox.p1.x + i * 5 + 1 - BlockX;
+ if ((x >= 0) && (x < cChunkDef::Width))
+ {
+ if (((Noise.IntNoise2DInt(x, z) / 7) % 10000) < m_ParentSystem.m_ChanceTorch)
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p2.y, z, E_BLOCK_TORCH, E_META_TORCH_XP);
+ }
+ }
+ x += 2;
+ if ((x >= 0) && (x < cChunkDef::Width))
+ {
+ if (((Noise.IntNoise2DInt(x, z) / 7) % 10000) < m_ParentSystem.m_ChanceTorch)
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p2.y, z, E_BLOCK_TORCH, E_META_TORCH_XM);
+ }
+ }
+ } // for i
+ break;
+ }
+
+ case dirZM:
+ case dirZP:
+ {
+ int x = m_BoundingBox.p1.x + 1 - a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ if ((x < 0) || (x >= cChunkDef::Width))
+ {
+ return;
+ }
+ int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ for (int i = 0; i < m_NumSegments; i++)
+ {
+ if (!m_HasFullBeam[i])
+ {
+ continue;
+ }
+ int z = m_BoundingBox.p1.z + i * 5 + 1 - BlockZ;
+ if ((z >= 0) && (z < cChunkDef::Width))
+ {
+ if (((Noise.IntNoise2DInt(x, z) / 7) % 10000) < m_ParentSystem.m_ChanceTorch)
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p2.y, z, E_BLOCK_TORCH, E_META_TORCH_ZP);
+ }
+ }
+ z += 2;
+ if ((z >= 0) && (z < cChunkDef::Width))
+ {
+ if (((Noise.IntNoise2DInt(x, z) / 7) % 10000) < m_ParentSystem.m_ChanceTorch)
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p2.y, z, E_BLOCK_TORCH, E_META_TORCH_ZM);
+ }
+ }
+ } // for i
+ break;
+ }
+ } // switch (direction)
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cMineShaftCrossing:
+
+cMineShaftCrossing::cMineShaftCrossing(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox) :
+ super(a_ParentSystem, mskCrossing, a_BoundingBox)
+{
+}
+
+
+
+
+
+cMineShaft * cMineShaftCrossing::CreateAndFit(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
+ cNoise & a_Noise
+)
+{
+ 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;
+ BoundingBox.p2.y += 3;
+ if ((rnd % 4) < 2)
+ {
+ // 2-level crossing:
+ BoundingBox.p2.y += 4;
+ rnd >>= 2;
+ if ((rnd % 4) < 2)
+ {
+ // This is the higher level:
+ BoundingBox.p1.y -= 4;
+ BoundingBox.p2.y -= 4;
+ }
+ }
+ rnd >>= 2;
+ switch (a_Direction)
+ {
+ case dirXP: BoundingBox.p2.x += 4; BoundingBox.p1.z -= 2; BoundingBox.p2.z += 2; break;
+ case dirXM: BoundingBox.p1.x -= 4; BoundingBox.p1.z -= 2; BoundingBox.p2.z += 2; break;
+ case dirZP: BoundingBox.p2.z += 4; BoundingBox.p1.x -= 2; BoundingBox.p2.x += 2; break;
+ case dirZM: BoundingBox.p1.z -= 4; BoundingBox.p1.x -= 2; BoundingBox.p2.x += 2; break;
+ }
+ if (!a_ParentSystem.CanAppend(BoundingBox))
+ {
+ return NULL;
+ }
+ return new cMineShaftCrossing(a_ParentSystem, BoundingBox);
+}
+
+
+
+
+
+void cMineShaftCrossing::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
+{
+ struct
+ {
+ int x, y, z;
+ eDirection dir;
+ } Exits[] =
+ {
+ // Bottom level:
+ {-1, 1, 2, dirXM},
+ { 2, 1, -1, dirZM},
+ { 5, 1, 2, dirXP},
+ { 2, 1, 5, dirZP},
+ // Top level:
+ {-1, 5, 2, dirXM},
+ { 2, 5, -1, dirZM},
+ { 5, 5, 2, dirXP},
+ { 2, 5, 5, dirZP},
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(Exits); i++)
+ {
+ if (m_BoundingBox.p1.y + Exits[i].y >= m_BoundingBox.p2.y)
+ {
+ // This exit is not available (two-level exit on a one-level crossing)
+ continue;
+ }
+
+ int Height = m_BoundingBox.p1.y + Exits[i].y;
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Exits[i].x, Height, m_BoundingBox.p1.z + Exits[i].z, Exits[i].dir, a_Noise, a_RecursionLevel);
+ } // for i
+}
+
+
+
+
+
+void cMineShaftCrossing::ProcessChunk(cChunkDesc & a_ChunkDesc)
+{
+ int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ cCuboid box(m_BoundingBox);
+ box.Move(-BlockX, 0, -BlockZ);
+ if ((box.p2.x < 0) || (box.p2.z < 0) || (box.p1.x >= cChunkDef::Width) || (box.p1.z > cChunkDef::Width))
+ {
+ // Does not intersect this chunk
+ return;
+ }
+ int Floor = box.p1.y + 1;
+ int Ceil = box.p2.y;
+
+ // The supports:
+ a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p1.x + 1, Floor, Ceil, box.p1.z + 1, box.p1.z + 1, E_BLOCK_PLANKS, 0);
+ a_ChunkDesc.FillRelCuboid(box.p2.x - 1, box.p2.x - 1, Floor, Ceil, box.p1.z + 1, box.p1.z + 1, E_BLOCK_PLANKS, 0);
+ a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p1.x + 1, Floor, Ceil, box.p2.z - 1, box.p2.z - 1, E_BLOCK_PLANKS, 0);
+ a_ChunkDesc.FillRelCuboid(box.p2.x - 1, box.p2.x - 1, Floor, Ceil, box.p2.z - 1, box.p2.z - 1, E_BLOCK_PLANKS, 0);
+
+ // The air in between:
+ a_ChunkDesc.FillRelCuboid(box.p1.x + 2, box.p1.x + 2, Floor, Ceil, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Floor, Ceil, box.p1.z + 2, box.p1.z + 2, E_BLOCK_AIR, 0);
+
+ // The air on the edges:
+ int Mid = Floor + 2;
+ a_ChunkDesc.FillRelCuboid(box.p1.x, box.p1.x, Floor, Mid, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid(box.p2.x, box.p2.x, Floor, Mid, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Floor, Mid, box.p1.z, box.p1.z, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Floor, Mid, box.p2.z, box.p2.z, E_BLOCK_AIR, 0);
+ Mid += 2;
+ if (Mid < Ceil)
+ {
+ a_ChunkDesc.FillRelCuboid(box.p1.x, box.p1.x, Mid, Ceil, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid(box.p2.x, box.p2.x, Mid, Ceil, box.p1.z + 1, box.p2.z - 1, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Mid, Ceil, box.p1.z, box.p1.z, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Mid, Ceil, box.p2.z, box.p2.z, E_BLOCK_AIR, 0);
+ }
+
+ // The floor, if needed:
+ box.p2.y = box.p1.y;
+ a_ChunkDesc.FloorRelCuboid(box, E_BLOCK_PLANKS, 0);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cMineShaftStaircase:
+
+cMineShaftStaircase::cMineShaftStaircase(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ const cCuboid & a_BoundingBox,
+ eDirection a_Direction,
+ eSlope a_Slope
+) :
+ super(a_ParentSystem, mskStaircase, a_BoundingBox),
+ m_Direction(a_Direction),
+ m_Slope(a_Slope)
+{
+}
+
+
+
+
+
+cMineShaft * cMineShaftStaircase::CreateAndFit(
+ cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
+ int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
+ cNoise & a_Noise
+)
+{
+ int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
+ cCuboid Box;
+ switch (a_Direction)
+ {
+ case dirXM:
+ {
+ Box.Assign(a_PivotX - 7, a_PivotY - 1, a_PivotZ - 1, a_PivotX, a_PivotY + 6, a_PivotZ + 1);
+ break;
+ }
+ case dirXP:
+ {
+ Box.Assign(a_PivotX, a_PivotY - 1, a_PivotZ - 1, a_PivotX + 7, a_PivotY + 6, a_PivotZ + 1);
+ break;
+ }
+ case dirZM:
+ {
+ Box.Assign(a_PivotX - 1, a_PivotY - 1, a_PivotZ - 7, a_PivotX + 1, a_PivotY + 6, a_PivotZ);
+ break;
+ }
+ case dirZP:
+ {
+ Box.Assign(a_PivotX - 1, a_PivotY - 1, a_PivotZ, a_PivotX + 1, a_PivotY + 6, a_PivotZ + 7);
+ break;
+ }
+ }
+ eSlope Slope = sUp;
+ if ((rnd % 4) < 2) // 50 %
+ {
+ Slope = sDown;
+ Box.Move(0, -4, 0);
+ }
+ if (!a_ParentSystem.CanAppend(Box))
+ {
+ return NULL;
+ }
+ return new cMineShaftStaircase(a_ParentSystem, Box, a_Direction, Slope);
+}
+
+
+
+
+
+void cMineShaftStaircase::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
+{
+ int Height = m_BoundingBox.p1.y + ((m_Slope == sDown) ? 1 : 5);
+ switch (m_Direction)
+ {
+ case dirXM: m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + 1, dirXM, a_Noise, a_RecursionLevel); break;
+ case dirXP: m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + 1, dirXP, a_Noise, a_RecursionLevel); break;
+ case dirZM: m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel); break;
+ case dirZP: m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel); break;
+ }
+}
+
+
+
+
+
+void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc)
+{
+ int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ cCuboid RelB(m_BoundingBox);
+ RelB.Move(-BlockX, 0, -BlockZ);
+ if (
+ (RelB.p1.x >= cChunkDef::Width) ||
+ (RelB.p1.z >= cChunkDef::Width) ||
+ (RelB.p2.x < 0) ||
+ (RelB.p2.z < 0)
+ )
+ {
+ // No intersection between this staircase and this chunk
+ return;
+ }
+
+ int SFloor = RelB.p1.y + ((m_Slope == sDown) ? 5 : 1);
+ int DFloor = RelB.p1.y + ((m_Slope == sDown) ? 1 : 5);
+ int Add = (m_Slope == sDown) ? -1 : 1;
+ int InitAdd = (m_Slope == sDown) ? -1 : 0;
+ cCuboid Box;
+ switch (m_Direction)
+ {
+ case dirXM:
+ {
+ a_ChunkDesc.FillRelCuboid (RelB.p2.x - 1, RelB.p2.x, SFloor, SFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p1.x + 1, DFloor, DFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FloorRelCuboid(RelB.p2.x - 1, RelB.p2.x, SFloor - 1, SFloor - 1, RelB.p1.z, RelB.p2.z, E_BLOCK_PLANKS, 0);
+ a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p1.x + 1, DFloor - 1, DFloor - 1, RelB.p1.z, RelB.p2.z, E_BLOCK_PLANKS, 0);
+ Box.Assign(RelB.p2.x - 2, SFloor + InitAdd, RelB.p1.z, RelB.p2.x - 2, SFloor + 3 + InitAdd, RelB.p2.z);
+ for (int i = 0; i < 4; i++)
+ {
+ a_ChunkDesc.FillRelCuboid(Box, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FloorRelCuboid(Box.p1.x, Box.p2.x, Box.p1.y - 1, Box.p1.y - 1, Box.p1.z, Box.p2.z, E_BLOCK_PLANKS, 0);
+ Box.Move(-1, Add, 0);
+ }
+ break;
+ }
+
+ case dirXP:
+ {
+ a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p1.x + 1, SFloor, SFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid (RelB.p2.x - 1, RelB.p2.x, DFloor, DFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p1.x + 1, SFloor - 1, SFloor - 1, RelB.p1.z, RelB.p2.z, E_BLOCK_PLANKS, 0);
+ a_ChunkDesc.FloorRelCuboid(RelB.p2.x - 1, RelB.p2.x, DFloor - 1, DFloor - 1, RelB.p1.z, RelB.p2.z, E_BLOCK_PLANKS, 0);
+ Box.Assign(RelB.p1.x + 2, SFloor + InitAdd, RelB.p1.z, RelB.p1.x + 2, SFloor + 3 + InitAdd, RelB.p2.z);
+ for (int i = 0; i < 4; i++)
+ {
+ a_ChunkDesc.FillRelCuboid(Box, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FloorRelCuboid(Box.p1.x, Box.p2.x, Box.p1.y - 1, Box.p1.y - 1, Box.p1.z, Box.p2.z, E_BLOCK_PLANKS, 0);
+ Box.Move(1, Add, 0);
+ }
+ break;
+ }
+
+ case dirZM:
+ {
+ a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, SFloor, SFloor + 2, RelB.p2.z - 1, RelB.p2.z, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, DFloor, DFloor + 2, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p2.x, SFloor - 1, SFloor - 1, RelB.p2.z - 1, RelB.p2.z, E_BLOCK_PLANKS, 0);
+ a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p2.x, DFloor - 1, DFloor - 1, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_PLANKS, 0);
+ Box.Assign(RelB.p1.x, SFloor + InitAdd, RelB.p2.z - 2, RelB.p2.x, SFloor + 3 + InitAdd, RelB.p2.z - 2);
+ for (int i = 0; i < 4; i++)
+ {
+ a_ChunkDesc.FillRelCuboid(Box, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FloorRelCuboid(Box.p1.x, Box.p2.x, Box.p1.y - 1, Box.p1.y - 1, Box.p1.z, Box.p2.z, E_BLOCK_PLANKS, 0);
+ Box.Move(0, Add, -1);
+ }
+ break;
+ }
+
+ case dirZP:
+ {
+ a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, SFloor, SFloor + 2, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, DFloor, DFloor + 2, RelB.p2.z - 1, RelB.p2.z, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p2.x, SFloor - 1, SFloor - 1, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_PLANKS, 0);
+ a_ChunkDesc.FloorRelCuboid(RelB.p1.x, RelB.p2.x, DFloor - 1, DFloor - 1, RelB.p2.z - 1, RelB.p2.z, E_BLOCK_PLANKS, 0);
+ Box.Assign(RelB.p1.x, SFloor + InitAdd, RelB.p1.z + 2, RelB.p2.x, SFloor + 3 + InitAdd, RelB.p1.z + 2);
+ for (int i = 0; i < 4; i++)
+ {
+ a_ChunkDesc.FillRelCuboid(Box, E_BLOCK_AIR, 0);
+ a_ChunkDesc.FloorRelCuboid(Box.p1.x, Box.p2.x, Box.p1.y - 1, Box.p1.y - 1, Box.p1.z, Box.p2.z, E_BLOCK_PLANKS, 0);
+ Box.Move(0, Add, 1);
+ }
+ break;
+ }
+
+ } // switch (m_Direction)
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cStructGenMineShafts:
+
+cStructGenMineShafts::cStructGenMineShafts(
+ int a_Seed, int a_GridSize, int a_MaxSystemSize,
+ int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase
+) :
+ m_Noise(a_Seed),
+ m_GridSize(a_GridSize),
+ m_MaxSystemSize(a_MaxSystemSize),
+ m_ProbLevelCorridor(std::max(0, a_ChanceCorridor)),
+ m_ProbLevelCrossing(std::max(0, a_ChanceCorridor + a_ChanceCrossing)),
+ m_ProbLevelStaircase(std::max(0, a_ChanceCorridor + a_ChanceCrossing + a_ChanceStaircase))
+{
+}
+
+
+
+
+
+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_Caves:
+ 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::GenStructures(cChunkDesc & a_ChunkDesc)
+{
+ 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[]
+}
+
+
+
+
diff --git a/source/Generating/MineShafts.h b/source/Generating/MineShafts.h
index a2191b665..c53d3bc53 100644
--- a/source/Generating/MineShafts.h
+++ b/source/Generating/MineShafts.h
@@ -1,61 +1,61 @@
-
-// MineShafts.h
-
-// Declares the cStructGenMineShafts class representing the structure generator for abandoned mineshafts
-
-
-
-
-
-#pragma once
-
-#include "ComposableGenerator.h"
-#include "../Noise.h"
-
-
-
-
-
-class cStructGenMineShafts :
- public cStructureGen
-{
-public:
- cStructGenMineShafts(
- int a_Seed, int a_GridSize, int a_MaxSystemSize,
- int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase
- );
-
- virtual ~cStructGenMineShafts();
-
-protected:
- friend class cMineShaft;
- friend class cMineShaftDirtRoom;
- friend class cMineShaftCorridor;
- 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.
-
- /// 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);
-
- // cStructureGen overrides:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
-} ;
-
-
-
-
+
+// MineShafts.h
+
+// Declares the cStructGenMineShafts class representing the structure generator for abandoned mineshafts
+
+
+
+
+
+#pragma once
+
+#include "ComposableGenerator.h"
+#include "../Noise.h"
+
+
+
+
+
+class cStructGenMineShafts :
+ public cStructureGen
+{
+public:
+ cStructGenMineShafts(
+ int a_Seed, int a_GridSize, int a_MaxSystemSize,
+ int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase
+ );
+
+ virtual ~cStructGenMineShafts();
+
+protected:
+ friend class cMineShaft;
+ friend class cMineShaftDirtRoom;
+ friend class cMineShaftCorridor;
+ 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.
+
+ /// 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);
+
+ // cStructureGen overrides:
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp
index dcf84abeb..f47c64430 100644
--- a/source/Generating/Noise3DGenerator.cpp
+++ b/source/Generating/Noise3DGenerator.cpp
@@ -1,581 +1,581 @@
-
-// Nosie3DGenerator.cpp
-
-// Generates terrain using 3D noise, rather than composing. Is a test.
-
-#include "Globals.h"
-#include "Noise3DGenerator.h"
-#include "../OSSupport/File.h"
-#include "../../iniFile/iniFile.h"
-#include "../LinearInterpolation.h"
-#include "../LinearUpscale.h"
-
-
-
-
-
-/*
-// Perform an automatic test of upscaling upon program start (use breakpoints to debug):
-
-class Test
-{
-public:
- Test(void)
- {
- DoTest1();
- DoTest2();
- }
-
-
- void DoTest1(void)
- {
- float In[3 * 3 * 3];
- for (int i = 0; i < ARRAYCOUNT(In); i++)
- {
- In[i] = (float)(i % 5);
- }
- Debug3DNoise(In, 3, 3, 3, "Upscale3D in");
- float Out[17 * 33 * 35];
- LinearUpscale3DArray(In, 3, 3, 3, Out, 8, 16, 17);
- Debug3DNoise(Out, 17, 33, 35, "Upscale3D test");
- }
-
-
- void DoTest2(void)
- {
- float In[3 * 3];
- for (int i = 0; i < ARRAYCOUNT(In); i++)
- {
- In[i] = (float)(i % 5);
- }
- Debug2DNoise(In, 3, 3, "Upscale2D in");
- float Out[17 * 33];
- LinearUpscale2DArray(In, 3, 3, Out, 8, 16);
- Debug2DNoise(Out, 17, 33, "Upscale2D test");
- }
-
-} gTest;
-//*/
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cNoise3DGenerator:
-
-cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) :
- super(a_ChunkGenerator),
- m_Perlin(1000),
- m_Cubic(1000)
-{
- m_Perlin.AddOctave(1, (NOISE_DATATYPE)0.5);
- m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 1);
- m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 2);
-
- #if 0
- // DEBUG: Test the noise generation:
- // NOTE: In order to be able to run MCS with this code, you need to increase the default thread stack size
- // In MSVC, it is done in Project Settings -> Configuration Properties -> Linker -> System, set Stack reserve size to at least 64M
- m_SeaLevel = 62;
- m_HeightAmplification = 0;
- m_MidPoint = 75;
- m_FrequencyX = 4;
- m_FrequencyY = 4;
- m_FrequencyZ = 4;
- m_AirThreshold = 0.5;
-
- const int NumChunks = 4;
- NOISE_DATATYPE Noise[NumChunks][cChunkDef::Width * cChunkDef::Width * cChunkDef::Height];
- for (int x = 0; x < NumChunks; x++)
- {
- GenerateNoiseArray(x, 5, Noise[x]);
- }
-
- // Save in XY cuts:
- cFile f1;
- if (f1.Open("Test_XY.grab", cFile::fmWrite))
- {
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int y = 0; y < cChunkDef::Height; y++)
- {
- for (int i = 0; i < NumChunks; i++)
- {
- int idx = y * cChunkDef::Width + z * cChunkDef::Width * cChunkDef::Height;
- unsigned char buf[cChunkDef::Width];
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 32 * Noise[i][idx++]))));
- }
- f1.Write(buf, cChunkDef::Width);
- }
- } // for y
- } // for z
- } // if (XY file open)
-
- cFile f2;
- if (f2.Open("Test_XZ.grab", cFile::fmWrite))
- {
- for (int y = 0; y < cChunkDef::Height; y++)
- {
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int i = 0; i < NumChunks; i++)
- {
- int idx = y * cChunkDef::Width + z * cChunkDef::Width * cChunkDef::Height;
- unsigned char buf[cChunkDef::Width];
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 32 * Noise[i][idx++]))));
- }
- f2.Write(buf, cChunkDef::Width);
- }
- } // for z
- } // for y
- } // if (XZ file open)
- #endif // 0
-}
-
-
-
-
-
-cNoise3DGenerator::~cNoise3DGenerator()
-{
- // Nothing needed yet
-}
-
-
-
-
-
-void cNoise3DGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile)
-{
- m_World = a_World;
-
- // Params:
- m_SeaLevel = a_IniFile.GetValueSetI("Generator", "Noise3DSeaLevel", 62);
- m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0);
- m_MidPoint = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DMidPoint", 75);
- m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyX", 8);
- m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyY", 8);
- m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyZ", 8);
- m_AirThreshold = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DAirThreshold", 0.5);
-}
-
-
-
-
-
-void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
-{
- for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
- {
- a_BiomeMap[i] = biExtremeHills;
- }
-}
-
-
-
-
-
-void cNoise3DGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc)
-{
- NOISE_DATATYPE Noise[17 * 257 * 17];
- GenerateNoiseArray(a_ChunkX, a_ChunkZ, Noise);
-
- // Output noise into chunk:
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int y = 0; y < cChunkDef::Height; y++)
- {
- int idx = z * 17 * 257 + y * 17;
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- NOISE_DATATYPE n = Noise[idx++];
- BLOCKTYPE BlockType;
- if (n > m_AirThreshold)
- {
- BlockType = (y > m_SeaLevel) ? E_BLOCK_AIR : E_BLOCK_STATIONARY_WATER;
- }
- else
- {
- BlockType = E_BLOCK_STONE;
- }
- a_ChunkDesc.SetBlockType(x, y, z, BlockType);
- }
- }
- }
-
- UpdateHeightmap(a_ChunkDesc);
- ComposeTerrain (a_ChunkDesc);
-}
-
-
-
-
-
-void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DATATYPE * a_OutNoise)
-{
- NOISE_DATATYPE NoiseO[DIM_X * DIM_Y * DIM_Z]; // Output for the Perlin noise
- NOISE_DATATYPE NoiseW[DIM_X * DIM_Y * DIM_Z]; // Workspace that the noise calculation can use and trash
-
- // Our noise array has different layout, XZY, instead of regular chunk's XYZ, that's why the coords are "renamed"
- NOISE_DATATYPE StartX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width)) / m_FrequencyX;
- NOISE_DATATYPE EndX = ((NOISE_DATATYPE)((a_ChunkX + 1) * cChunkDef::Width) - 1) / m_FrequencyX;
- NOISE_DATATYPE StartZ = ((NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width)) / m_FrequencyZ;
- NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((a_ChunkZ + 1) * cChunkDef::Width) - 1) / m_FrequencyZ;
- NOISE_DATATYPE StartY = 0;
- NOISE_DATATYPE EndY = ((NOISE_DATATYPE)256) / m_FrequencyY;
-
- m_Perlin.Generate3D(NoiseO, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, NoiseW);
-
- // DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_orig", a_ChunkX, a_ChunkZ));
-
- // Precalculate a "height" array:
- NOISE_DATATYPE Height[DIM_X * DIM_Z]; // Output for the cubic noise heightmap ("source")
- m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 25, EndX / 25, StartZ / 25, EndZ / 25);
- for (int i = 0; i < ARRAYCOUNT(Height); i++)
- {
- Height[i] = abs(Height[i]) * m_HeightAmplification + 1;
- }
-
- // Modify the noise by height data:
- for (int y = 0; y < DIM_Y; y++)
- {
- NOISE_DATATYPE AddHeight = (y * UPSCALE_Y - m_MidPoint) / 20;
- AddHeight *= AddHeight * AddHeight;
- for (int z = 0; z < DIM_Z; z++)
- {
- NOISE_DATATYPE * CurRow = &(NoiseO[y * DIM_X + z * DIM_X * DIM_Y]);
- for (int x = 0; x < DIM_X; x++)
- {
- CurRow[x] += AddHeight / Height[x + DIM_X * z];
- }
- }
- }
-
- // DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_hei", a_ChunkX, a_ChunkZ));
-
- // Upscale the Perlin noise into full-blown chunk dimensions:
- LinearUpscale3DArray(
- NoiseO, DIM_X, DIM_Y, DIM_Z,
- a_OutNoise, UPSCALE_X, UPSCALE_Y, UPSCALE_Z
- );
-
- // DEBUG: Debug3DNoise(a_OutNoise, 17, 257, 17, Printf("Chunk_%d_%d_lerp", a_ChunkX, a_ChunkZ));
-}
-
-
-
-
-
-void cNoise3DGenerator::UpdateHeightmap(cChunkDesc & a_ChunkDesc)
-{
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- for (int y = cChunkDef::Height - 1; y > 0; y--)
- {
- if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR)
- {
- a_ChunkDesc.SetHeight(x, z, y);
- break;
- }
- } // for y
- } // for x
- } // for z
-}
-
-
-
-
-
-void cNoise3DGenerator::ComposeTerrain(cChunkDesc & a_ChunkDesc)
-{
- // Make basic terrain composition:
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- int LastAir = a_ChunkDesc.GetHeight(x, z) + 1;
- bool HasHadWater = false;
- for (int y = LastAir - 1; y > 0; y--)
- {
- switch (a_ChunkDesc.GetBlockType(x, y, z))
- {
- case E_BLOCK_AIR:
- {
- LastAir = y;
- break;
- }
- case E_BLOCK_STONE:
- {
- if (LastAir - y > 3)
- {
- break;
- }
- if (HasHadWater)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SAND);
- }
- else
- {
- a_ChunkDesc.SetBlockType(x, y, z, (LastAir == y + 1) ? E_BLOCK_GRASS : E_BLOCK_DIRT);
- }
- break;
- }
- case E_BLOCK_STATIONARY_WATER:
- {
- LastAir = y;
- HasHadWater = true;
- break;
- }
- } // switch (GetBlockType())
- } // for y
- a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK);
- } // for x
- } // for z
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cNoise3DComposable:
-
-cNoise3DComposable::cNoise3DComposable(int a_Seed) :
- m_Noise1(a_Seed + 1000),
- m_Noise2(a_Seed + 2000),
- m_Noise3(a_Seed + 3000)
-{
-}
-
-
-
-
-
-void cNoise3DComposable::Initialize(cIniFile & a_IniFile)
-{
- // Params:
- m_SeaLevel = a_IniFile.GetValueSetI("Generator", "Noise3DSeaLevel", 62);
- m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0);
- m_MidPoint = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DMidPoint", 75);
- m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyX", 10);
- m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyY", 10);
- m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyZ", 10);
- m_AirThreshold = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DAirThreshold", 0.5);
-}
-
-
-
-
-
-void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
-{
- if ((a_ChunkX == m_LastChunkX) && (a_ChunkZ == m_LastChunkZ))
- {
- // The noise for this chunk is already generated in m_Noise
- return;
- }
- m_LastChunkX = a_ChunkX;
- m_LastChunkZ = a_ChunkZ;
-
- // Upscaling parameters:
- const int UPSCALE_X = 8;
- const int UPSCALE_Y = 4;
- const int UPSCALE_Z = 8;
-
- const int DIM_X = 1 + cChunkDef::Width / UPSCALE_X;
- const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y;
- const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z;
-
- // Precalculate a "height" array:
- NOISE_DATATYPE Height[17 * 17]; // x + 17 * z
- for (int z = 0; z < 17; z += UPSCALE_Z)
- {
- NOISE_DATATYPE NoiseZ = ((NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + z)) / m_FrequencyZ;
- for (int x = 0; x < 17; x += UPSCALE_X)
- {
- NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
- NOISE_DATATYPE val = abs(m_Noise1.CubicNoise2D(NoiseX / 5, NoiseZ / 5)) * m_HeightAmplification + 1;
- Height[x + 17 * z] = val * val * val;
- }
- }
-
- int idx = 0;
- for (int y = 0; y < 257; y += UPSCALE_Y)
- {
- NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)y) / m_FrequencyY;
- NOISE_DATATYPE AddHeight = (y - m_MidPoint) / 20;
- AddHeight *= AddHeight * AddHeight;
- NOISE_DATATYPE * CurFloor = &(m_NoiseArray[y * 17 * 17]);
- for (int z = 0; z < 17; z += UPSCALE_Z)
- {
- NOISE_DATATYPE NoiseZ = ((NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + z)) / m_FrequencyZ;
- for (int x = 0; x < 17; x += UPSCALE_X)
- {
- NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
- CurFloor[x + 17 * z] =
- m_Noise1.CubicNoise3D(NoiseX, NoiseY, NoiseZ) * (NOISE_DATATYPE)0.5 +
- m_Noise2.CubicNoise3D(NoiseX / 2, NoiseY / 2, NoiseZ / 2) +
- m_Noise3.CubicNoise3D(NoiseX / 4, NoiseY / 4, NoiseZ / 4) * 2 +
- AddHeight / Height[x + 17 * z];
- }
- }
- // Linear-interpolate this XZ floor:
- LinearUpscale2DArrayInPlace(CurFloor, 17, 17, UPSCALE_X, UPSCALE_Z);
- }
-
- // Finish the 3D linear interpolation by interpolating between each XZ-floors on the Y axis
- for (int y = 1; y < cChunkDef::Height; y++)
- {
- if ((y % UPSCALE_Y) == 0)
- {
- // This is the interpolation source floor, already calculated
- continue;
- }
- int LoFloorY = (y / UPSCALE_Y) * UPSCALE_Y;
- int HiFloorY = LoFloorY + UPSCALE_Y;
- NOISE_DATATYPE * LoFloor = &(m_NoiseArray[LoFloorY * 17 * 17]);
- NOISE_DATATYPE * HiFloor = &(m_NoiseArray[HiFloorY * 17 * 17]);
- NOISE_DATATYPE * CurFloor = &(m_NoiseArray[y * 17 * 17]);
- NOISE_DATATYPE Ratio = ((NOISE_DATATYPE)(y % UPSCALE_Y)) / UPSCALE_Y;
- int idx = 0;
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- CurFloor[idx] = LoFloor[idx] + (HiFloor[idx] - LoFloor[idx]) * Ratio;
- idx += 1;
- }
- idx += 1; // Skipping one X column
- }
- }
-
- // The noise array is now fully interpolated
- /*
- // DEBUG: Output two images of the array, sliced by XY and XZ:
- cFile f1;
- if (f1.Open(Printf("Chunk_%d_%d_XY.raw", a_ChunkX, a_ChunkZ), cFile::fmWrite))
- {
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int y = 0; y < cChunkDef::Height; y++)
- {
- int idx = y * 17 * 17 + z * 17;
- unsigned char buf[16];
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 128 * m_Noise[idx++]))));
- }
- f1.Write(buf, 16);
- } // for y
- } // for z
- } // if (XY file open)
-
- cFile f2;
- if (f2.Open(Printf("Chunk_%d_%d_XZ.raw", a_ChunkX, a_ChunkZ), cFile::fmWrite))
- {
- for (int y = 0; y < cChunkDef::Height; y++)
- {
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- int idx = y * 17 * 17 + z * 17;
- unsigned char buf[16];
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 128 * m_Noise[idx++]))));
- }
- f2.Write(buf, 16);
- } // for z
- } // for y
- } // if (XZ file open)
- */
-}
-
-
-
-
-
-void cNoise3DComposable::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
-{
- GenerateNoiseArrayIfNeeded(a_ChunkX, a_ChunkZ);
-
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- cChunkDef::SetHeight(a_HeightMap, x, z, m_SeaLevel);
- for (int y = cChunkDef::Height - 1; y > m_SeaLevel; y--)
- {
- if (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= m_AirThreshold)
- {
- cChunkDef::SetHeight(a_HeightMap, x, z, y);
- break;
- }
- } // for y
- } // for x
- } // for z
-}
-
-
-
-
-
-void cNoise3DComposable::ComposeTerrain(cChunkDesc & a_ChunkDesc)
-{
- GenerateNoiseArrayIfNeeded(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
-
- a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
-
- // Make basic terrain composition:
- for (int z = 0; z < cChunkDef::Width; z++)
- {
- for (int x = 0; x < cChunkDef::Width; x++)
- {
- int LastAir = a_ChunkDesc.GetHeight(x, z) + 1;
- bool HasHadWater = false;
- for (int y = LastAir; y < m_SeaLevel; y++)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STATIONARY_WATER);
- }
- for (int y = LastAir - 1; y > 0; y--)
- {
- if (m_NoiseArray[x + 17 * z + 17 * 17 * y] > m_AirThreshold)
- {
- // "air" part
- LastAir = y;
- if (y < m_SeaLevel)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STATIONARY_WATER);
- HasHadWater = true;
- }
- continue;
- }
- // "ground" part:
- if (LastAir - y > 4)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STONE);
- continue;
- }
- if (HasHadWater)
- {
- a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SAND);
- }
- else
- {
- a_ChunkDesc.SetBlockType(x, y, z, (LastAir == y + 1) ? E_BLOCK_GRASS : E_BLOCK_DIRT);
- }
- } // for y
- a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK);
- } // for x
- } // for z
-}
-
-
-
-
+
+// Nosie3DGenerator.cpp
+
+// Generates terrain using 3D noise, rather than composing. Is a test.
+
+#include "Globals.h"
+#include "Noise3DGenerator.h"
+#include "../OSSupport/File.h"
+#include "../../iniFile/iniFile.h"
+#include "../LinearInterpolation.h"
+#include "../LinearUpscale.h"
+
+
+
+
+
+/*
+// Perform an automatic test of upscaling upon program start (use breakpoints to debug):
+
+class Test
+{
+public:
+ Test(void)
+ {
+ DoTest1();
+ DoTest2();
+ }
+
+
+ void DoTest1(void)
+ {
+ float In[3 * 3 * 3];
+ for (int i = 0; i < ARRAYCOUNT(In); i++)
+ {
+ In[i] = (float)(i % 5);
+ }
+ Debug3DNoise(In, 3, 3, 3, "Upscale3D in");
+ float Out[17 * 33 * 35];
+ LinearUpscale3DArray(In, 3, 3, 3, Out, 8, 16, 17);
+ Debug3DNoise(Out, 17, 33, 35, "Upscale3D test");
+ }
+
+
+ void DoTest2(void)
+ {
+ float In[3 * 3];
+ for (int i = 0; i < ARRAYCOUNT(In); i++)
+ {
+ In[i] = (float)(i % 5);
+ }
+ Debug2DNoise(In, 3, 3, "Upscale2D in");
+ float Out[17 * 33];
+ LinearUpscale2DArray(In, 3, 3, Out, 8, 16);
+ Debug2DNoise(Out, 17, 33, "Upscale2D test");
+ }
+
+} gTest;
+//*/
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cNoise3DGenerator:
+
+cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) :
+ super(a_ChunkGenerator),
+ m_Perlin(1000),
+ m_Cubic(1000)
+{
+ m_Perlin.AddOctave(1, (NOISE_DATATYPE)0.5);
+ m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 1);
+ m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 2);
+
+ #if 0
+ // DEBUG: Test the noise generation:
+ // NOTE: In order to be able to run MCS with this code, you need to increase the default thread stack size
+ // In MSVC, it is done in Project Settings -> Configuration Properties -> Linker -> System, set Stack reserve size to at least 64M
+ m_SeaLevel = 62;
+ m_HeightAmplification = 0;
+ m_MidPoint = 75;
+ m_FrequencyX = 4;
+ m_FrequencyY = 4;
+ m_FrequencyZ = 4;
+ m_AirThreshold = 0.5;
+
+ const int NumChunks = 4;
+ NOISE_DATATYPE Noise[NumChunks][cChunkDef::Width * cChunkDef::Width * cChunkDef::Height];
+ for (int x = 0; x < NumChunks; x++)
+ {
+ GenerateNoiseArray(x, 5, Noise[x]);
+ }
+
+ // Save in XY cuts:
+ cFile f1;
+ if (f1.Open("Test_XY.grab", cFile::fmWrite))
+ {
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int y = 0; y < cChunkDef::Height; y++)
+ {
+ for (int i = 0; i < NumChunks; i++)
+ {
+ int idx = y * cChunkDef::Width + z * cChunkDef::Width * cChunkDef::Height;
+ unsigned char buf[cChunkDef::Width];
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 32 * Noise[i][idx++]))));
+ }
+ f1.Write(buf, cChunkDef::Width);
+ }
+ } // for y
+ } // for z
+ } // if (XY file open)
+
+ cFile f2;
+ if (f2.Open("Test_XZ.grab", cFile::fmWrite))
+ {
+ for (int y = 0; y < cChunkDef::Height; y++)
+ {
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int i = 0; i < NumChunks; i++)
+ {
+ int idx = y * cChunkDef::Width + z * cChunkDef::Width * cChunkDef::Height;
+ unsigned char buf[cChunkDef::Width];
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 32 * Noise[i][idx++]))));
+ }
+ f2.Write(buf, cChunkDef::Width);
+ }
+ } // for z
+ } // for y
+ } // if (XZ file open)
+ #endif // 0
+}
+
+
+
+
+
+cNoise3DGenerator::~cNoise3DGenerator()
+{
+ // Nothing needed yet
+}
+
+
+
+
+
+void cNoise3DGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile)
+{
+ m_World = a_World;
+
+ // Params:
+ m_SeaLevel = a_IniFile.GetValueSetI("Generator", "Noise3DSeaLevel", 62);
+ m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0);
+ m_MidPoint = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DMidPoint", 75);
+ m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyX", 8);
+ m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyY", 8);
+ m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyZ", 8);
+ m_AirThreshold = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DAirThreshold", 0.5);
+}
+
+
+
+
+
+void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
+{
+ for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
+ {
+ a_BiomeMap[i] = biExtremeHills;
+ }
+}
+
+
+
+
+
+void cNoise3DGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc)
+{
+ NOISE_DATATYPE Noise[17 * 257 * 17];
+ GenerateNoiseArray(a_ChunkX, a_ChunkZ, Noise);
+
+ // Output noise into chunk:
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int y = 0; y < cChunkDef::Height; y++)
+ {
+ int idx = z * 17 * 257 + y * 17;
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ NOISE_DATATYPE n = Noise[idx++];
+ BLOCKTYPE BlockType;
+ if (n > m_AirThreshold)
+ {
+ BlockType = (y > m_SeaLevel) ? E_BLOCK_AIR : E_BLOCK_STATIONARY_WATER;
+ }
+ else
+ {
+ BlockType = E_BLOCK_STONE;
+ }
+ a_ChunkDesc.SetBlockType(x, y, z, BlockType);
+ }
+ }
+ }
+
+ UpdateHeightmap(a_ChunkDesc);
+ ComposeTerrain (a_ChunkDesc);
+}
+
+
+
+
+
+void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DATATYPE * a_OutNoise)
+{
+ NOISE_DATATYPE NoiseO[DIM_X * DIM_Y * DIM_Z]; // Output for the Perlin noise
+ NOISE_DATATYPE NoiseW[DIM_X * DIM_Y * DIM_Z]; // Workspace that the noise calculation can use and trash
+
+ // Our noise array has different layout, XZY, instead of regular chunk's XYZ, that's why the coords are "renamed"
+ NOISE_DATATYPE StartX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width)) / m_FrequencyX;
+ NOISE_DATATYPE EndX = ((NOISE_DATATYPE)((a_ChunkX + 1) * cChunkDef::Width) - 1) / m_FrequencyX;
+ NOISE_DATATYPE StartZ = ((NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width)) / m_FrequencyZ;
+ NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((a_ChunkZ + 1) * cChunkDef::Width) - 1) / m_FrequencyZ;
+ NOISE_DATATYPE StartY = 0;
+ NOISE_DATATYPE EndY = ((NOISE_DATATYPE)256) / m_FrequencyY;
+
+ m_Perlin.Generate3D(NoiseO, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, NoiseW);
+
+ // DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_orig", a_ChunkX, a_ChunkZ));
+
+ // Precalculate a "height" array:
+ NOISE_DATATYPE Height[DIM_X * DIM_Z]; // Output for the cubic noise heightmap ("source")
+ m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 25, EndX / 25, StartZ / 25, EndZ / 25);
+ for (int i = 0; i < ARRAYCOUNT(Height); i++)
+ {
+ Height[i] = abs(Height[i]) * m_HeightAmplification + 1;
+ }
+
+ // Modify the noise by height data:
+ for (int y = 0; y < DIM_Y; y++)
+ {
+ NOISE_DATATYPE AddHeight = (y * UPSCALE_Y - m_MidPoint) / 20;
+ AddHeight *= AddHeight * AddHeight;
+ for (int z = 0; z < DIM_Z; z++)
+ {
+ NOISE_DATATYPE * CurRow = &(NoiseO[y * DIM_X + z * DIM_X * DIM_Y]);
+ for (int x = 0; x < DIM_X; x++)
+ {
+ CurRow[x] += AddHeight / Height[x + DIM_X * z];
+ }
+ }
+ }
+
+ // DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_hei", a_ChunkX, a_ChunkZ));
+
+ // Upscale the Perlin noise into full-blown chunk dimensions:
+ LinearUpscale3DArray(
+ NoiseO, DIM_X, DIM_Y, DIM_Z,
+ a_OutNoise, UPSCALE_X, UPSCALE_Y, UPSCALE_Z
+ );
+
+ // DEBUG: Debug3DNoise(a_OutNoise, 17, 257, 17, Printf("Chunk_%d_%d_lerp", a_ChunkX, a_ChunkZ));
+}
+
+
+
+
+
+void cNoise3DGenerator::UpdateHeightmap(cChunkDesc & a_ChunkDesc)
+{
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ for (int y = cChunkDef::Height - 1; y > 0; y--)
+ {
+ if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR)
+ {
+ a_ChunkDesc.SetHeight(x, z, y);
+ break;
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cNoise3DGenerator::ComposeTerrain(cChunkDesc & a_ChunkDesc)
+{
+ // Make basic terrain composition:
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int LastAir = a_ChunkDesc.GetHeight(x, z) + 1;
+ bool HasHadWater = false;
+ for (int y = LastAir - 1; y > 0; y--)
+ {
+ switch (a_ChunkDesc.GetBlockType(x, y, z))
+ {
+ case E_BLOCK_AIR:
+ {
+ LastAir = y;
+ break;
+ }
+ case E_BLOCK_STONE:
+ {
+ if (LastAir - y > 3)
+ {
+ break;
+ }
+ if (HasHadWater)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SAND);
+ }
+ else
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, (LastAir == y + 1) ? E_BLOCK_GRASS : E_BLOCK_DIRT);
+ }
+ break;
+ }
+ case E_BLOCK_STATIONARY_WATER:
+ {
+ LastAir = y;
+ HasHadWater = true;
+ break;
+ }
+ } // switch (GetBlockType())
+ } // for y
+ a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK);
+ } // for x
+ } // for z
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cNoise3DComposable:
+
+cNoise3DComposable::cNoise3DComposable(int a_Seed) :
+ m_Noise1(a_Seed + 1000),
+ m_Noise2(a_Seed + 2000),
+ m_Noise3(a_Seed + 3000)
+{
+}
+
+
+
+
+
+void cNoise3DComposable::Initialize(cIniFile & a_IniFile)
+{
+ // Params:
+ m_SeaLevel = a_IniFile.GetValueSetI("Generator", "Noise3DSeaLevel", 62);
+ m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0);
+ m_MidPoint = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DMidPoint", 75);
+ m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyX", 10);
+ m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyY", 10);
+ m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyZ", 10);
+ m_AirThreshold = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DAirThreshold", 0.5);
+}
+
+
+
+
+
+void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
+{
+ if ((a_ChunkX == m_LastChunkX) && (a_ChunkZ == m_LastChunkZ))
+ {
+ // The noise for this chunk is already generated in m_Noise
+ return;
+ }
+ m_LastChunkX = a_ChunkX;
+ m_LastChunkZ = a_ChunkZ;
+
+ // Upscaling parameters:
+ const int UPSCALE_X = 8;
+ const int UPSCALE_Y = 4;
+ const int UPSCALE_Z = 8;
+
+ const int DIM_X = 1 + cChunkDef::Width / UPSCALE_X;
+ const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y;
+ const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z;
+
+ // Precalculate a "height" array:
+ NOISE_DATATYPE Height[17 * 17]; // x + 17 * z
+ for (int z = 0; z < 17; z += UPSCALE_Z)
+ {
+ NOISE_DATATYPE NoiseZ = ((NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + z)) / m_FrequencyZ;
+ for (int x = 0; x < 17; x += UPSCALE_X)
+ {
+ NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
+ NOISE_DATATYPE val = abs(m_Noise1.CubicNoise2D(NoiseX / 5, NoiseZ / 5)) * m_HeightAmplification + 1;
+ Height[x + 17 * z] = val * val * val;
+ }
+ }
+
+ int idx = 0;
+ for (int y = 0; y < 257; y += UPSCALE_Y)
+ {
+ NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)y) / m_FrequencyY;
+ NOISE_DATATYPE AddHeight = (y - m_MidPoint) / 20;
+ AddHeight *= AddHeight * AddHeight;
+ NOISE_DATATYPE * CurFloor = &(m_NoiseArray[y * 17 * 17]);
+ for (int z = 0; z < 17; z += UPSCALE_Z)
+ {
+ NOISE_DATATYPE NoiseZ = ((NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + z)) / m_FrequencyZ;
+ for (int x = 0; x < 17; x += UPSCALE_X)
+ {
+ NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
+ CurFloor[x + 17 * z] =
+ m_Noise1.CubicNoise3D(NoiseX, NoiseY, NoiseZ) * (NOISE_DATATYPE)0.5 +
+ m_Noise2.CubicNoise3D(NoiseX / 2, NoiseY / 2, NoiseZ / 2) +
+ m_Noise3.CubicNoise3D(NoiseX / 4, NoiseY / 4, NoiseZ / 4) * 2 +
+ AddHeight / Height[x + 17 * z];
+ }
+ }
+ // Linear-interpolate this XZ floor:
+ LinearUpscale2DArrayInPlace(CurFloor, 17, 17, UPSCALE_X, UPSCALE_Z);
+ }
+
+ // Finish the 3D linear interpolation by interpolating between each XZ-floors on the Y axis
+ for (int y = 1; y < cChunkDef::Height; y++)
+ {
+ if ((y % UPSCALE_Y) == 0)
+ {
+ // This is the interpolation source floor, already calculated
+ continue;
+ }
+ int LoFloorY = (y / UPSCALE_Y) * UPSCALE_Y;
+ int HiFloorY = LoFloorY + UPSCALE_Y;
+ NOISE_DATATYPE * LoFloor = &(m_NoiseArray[LoFloorY * 17 * 17]);
+ NOISE_DATATYPE * HiFloor = &(m_NoiseArray[HiFloorY * 17 * 17]);
+ NOISE_DATATYPE * CurFloor = &(m_NoiseArray[y * 17 * 17]);
+ NOISE_DATATYPE Ratio = ((NOISE_DATATYPE)(y % UPSCALE_Y)) / UPSCALE_Y;
+ int idx = 0;
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ CurFloor[idx] = LoFloor[idx] + (HiFloor[idx] - LoFloor[idx]) * Ratio;
+ idx += 1;
+ }
+ idx += 1; // Skipping one X column
+ }
+ }
+
+ // The noise array is now fully interpolated
+ /*
+ // DEBUG: Output two images of the array, sliced by XY and XZ:
+ cFile f1;
+ if (f1.Open(Printf("Chunk_%d_%d_XY.raw", a_ChunkX, a_ChunkZ), cFile::fmWrite))
+ {
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int y = 0; y < cChunkDef::Height; y++)
+ {
+ int idx = y * 17 * 17 + z * 17;
+ unsigned char buf[16];
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 128 * m_Noise[idx++]))));
+ }
+ f1.Write(buf, 16);
+ } // for y
+ } // for z
+ } // if (XY file open)
+
+ cFile f2;
+ if (f2.Open(Printf("Chunk_%d_%d_XZ.raw", a_ChunkX, a_ChunkZ), cFile::fmWrite))
+ {
+ for (int y = 0; y < cChunkDef::Height; y++)
+ {
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ int idx = y * 17 * 17 + z * 17;
+ unsigned char buf[16];
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 128 * m_Noise[idx++]))));
+ }
+ f2.Write(buf, 16);
+ } // for z
+ } // for y
+ } // if (XZ file open)
+ */
+}
+
+
+
+
+
+void cNoise3DComposable::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
+{
+ GenerateNoiseArrayIfNeeded(a_ChunkX, a_ChunkZ);
+
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ cChunkDef::SetHeight(a_HeightMap, x, z, m_SeaLevel);
+ for (int y = cChunkDef::Height - 1; y > m_SeaLevel; y--)
+ {
+ if (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= m_AirThreshold)
+ {
+ cChunkDef::SetHeight(a_HeightMap, x, z, y);
+ break;
+ }
+ } // for y
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cNoise3DComposable::ComposeTerrain(cChunkDesc & a_ChunkDesc)
+{
+ GenerateNoiseArrayIfNeeded(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
+
+ a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
+
+ // Make basic terrain composition:
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int LastAir = a_ChunkDesc.GetHeight(x, z) + 1;
+ bool HasHadWater = false;
+ for (int y = LastAir; y < m_SeaLevel; y++)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STATIONARY_WATER);
+ }
+ for (int y = LastAir - 1; y > 0; y--)
+ {
+ if (m_NoiseArray[x + 17 * z + 17 * 17 * y] > m_AirThreshold)
+ {
+ // "air" part
+ LastAir = y;
+ if (y < m_SeaLevel)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STATIONARY_WATER);
+ HasHadWater = true;
+ }
+ continue;
+ }
+ // "ground" part:
+ if (LastAir - y > 4)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_STONE);
+ continue;
+ }
+ if (HasHadWater)
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SAND);
+ }
+ else
+ {
+ a_ChunkDesc.SetBlockType(x, y, z, (LastAir == y + 1) ? E_BLOCK_GRASS : E_BLOCK_DIRT);
+ }
+ } // for y
+ a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK);
+ } // for x
+ } // for z
+}
+
+
+
+
diff --git a/source/Generating/Noise3DGenerator.h b/source/Generating/Noise3DGenerator.h
index b23e8645b..0d211cddc 100644
--- a/source/Generating/Noise3DGenerator.h
+++ b/source/Generating/Noise3DGenerator.h
@@ -1,106 +1,106 @@
-
-// Noise3DGenerator.h
-
-// Generates terrain using 3D noise, rather than composing. Is a test.
-
-
-
-
-#pragma once
-
-#include "ComposableGenerator.h"
-#include "../Noise.h"
-
-
-
-
-
-class cNoise3DGenerator :
- public cChunkGenerator::cGenerator
-{
- typedef cChunkGenerator::cGenerator super;
-
-public:
- cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator);
- virtual ~cNoise3DGenerator();
-
- virtual void Initialize(cWorld * a_World, cIniFile & a_IniFile) override;
- virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
- virtual void DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) override;
-
-protected:
- // Linear interpolation step sizes, must be divisors of cChunkDef::Width and cChunkDef::Height, respectively:
- static const int UPSCALE_X = 8;
- static const int UPSCALE_Y = 4;
- static const int UPSCALE_Z = 8;
-
- // Linear interpolation buffer dimensions, calculated from the step sizes:
- static const int DIM_X = 1 + cChunkDef::Width / UPSCALE_X;
- static const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y;
- static const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z;
-
- cPerlinNoise m_Perlin; // The base 3D noise source for the actual composition
- cCubicNoise m_Cubic; // The noise used for heightmap directing
-
- int m_SeaLevel;
- NOISE_DATATYPE m_HeightAmplification;
- NOISE_DATATYPE m_MidPoint; // Where the vertical "center" of the noise should be
- NOISE_DATATYPE m_FrequencyX;
- NOISE_DATATYPE m_FrequencyY;
- NOISE_DATATYPE m_FrequencyZ;
- NOISE_DATATYPE m_AirThreshold;
-
- /// Generates the 3D noise array used for terrain generation; a_Noise is of ChunkData-size
- void GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DATATYPE * a_Noise);
-
- /// Updates heightmap based on the chunk's contents
- void UpdateHeightmap(cChunkDesc & a_ChunkDesc);
-
- /// Composes terrain - adds dirt, grass and sand
- void ComposeTerrain(cChunkDesc & a_ChunkDesc);
-} ;
-
-
-
-
-
-class cNoise3DComposable :
- public cTerrainHeightGen,
- public cTerrainCompositionGen
-{
-public:
- cNoise3DComposable(int a_Seed);
-
- void Initialize(cIniFile & a_IniFile);
-
-protected:
- cNoise m_Noise1;
- cNoise m_Noise2;
- cNoise m_Noise3;
-
- int m_SeaLevel;
- NOISE_DATATYPE m_HeightAmplification;
- NOISE_DATATYPE m_MidPoint; // Where the vertical "center" of the noise should be
- NOISE_DATATYPE m_FrequencyX;
- NOISE_DATATYPE m_FrequencyY;
- NOISE_DATATYPE m_FrequencyZ;
- NOISE_DATATYPE m_AirThreshold;
-
- int m_LastChunkX;
- int m_LastChunkZ;
- NOISE_DATATYPE m_NoiseArray[17 * 17 * 257]; // x + 17 * z + 17 * 17 * y
-
-
- /// Generates the 3D noise array used for terrain generation, unless the LastChunk coords are equal to coords given
- void GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ);
-
- // cTerrainHeightGen overrides:
- virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
-
- // cTerrainCompositionGen overrides:
- virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
-} ;
-
-
-
-
+
+// Noise3DGenerator.h
+
+// Generates terrain using 3D noise, rather than composing. Is a test.
+
+
+
+
+#pragma once
+
+#include "ComposableGenerator.h"
+#include "../Noise.h"
+
+
+
+
+
+class cNoise3DGenerator :
+ public cChunkGenerator::cGenerator
+{
+ typedef cChunkGenerator::cGenerator super;
+
+public:
+ cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator);
+ virtual ~cNoise3DGenerator();
+
+ virtual void Initialize(cWorld * a_World, cIniFile & a_IniFile) override;
+ virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
+ virtual void DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) override;
+
+protected:
+ // Linear interpolation step sizes, must be divisors of cChunkDef::Width and cChunkDef::Height, respectively:
+ static const int UPSCALE_X = 8;
+ static const int UPSCALE_Y = 4;
+ static const int UPSCALE_Z = 8;
+
+ // Linear interpolation buffer dimensions, calculated from the step sizes:
+ static const int DIM_X = 1 + cChunkDef::Width / UPSCALE_X;
+ static const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y;
+ static const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z;
+
+ cPerlinNoise m_Perlin; // The base 3D noise source for the actual composition
+ cCubicNoise m_Cubic; // The noise used for heightmap directing
+
+ int m_SeaLevel;
+ NOISE_DATATYPE m_HeightAmplification;
+ NOISE_DATATYPE m_MidPoint; // Where the vertical "center" of the noise should be
+ NOISE_DATATYPE m_FrequencyX;
+ NOISE_DATATYPE m_FrequencyY;
+ NOISE_DATATYPE m_FrequencyZ;
+ NOISE_DATATYPE m_AirThreshold;
+
+ /// Generates the 3D noise array used for terrain generation; a_Noise is of ChunkData-size
+ void GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DATATYPE * a_Noise);
+
+ /// Updates heightmap based on the chunk's contents
+ void UpdateHeightmap(cChunkDesc & a_ChunkDesc);
+
+ /// Composes terrain - adds dirt, grass and sand
+ void ComposeTerrain(cChunkDesc & a_ChunkDesc);
+} ;
+
+
+
+
+
+class cNoise3DComposable :
+ public cTerrainHeightGen,
+ public cTerrainCompositionGen
+{
+public:
+ cNoise3DComposable(int a_Seed);
+
+ void Initialize(cIniFile & a_IniFile);
+
+protected:
+ cNoise m_Noise1;
+ cNoise m_Noise2;
+ cNoise m_Noise3;
+
+ int m_SeaLevel;
+ NOISE_DATATYPE m_HeightAmplification;
+ NOISE_DATATYPE m_MidPoint; // Where the vertical "center" of the noise should be
+ NOISE_DATATYPE m_FrequencyX;
+ NOISE_DATATYPE m_FrequencyY;
+ NOISE_DATATYPE m_FrequencyZ;
+ NOISE_DATATYPE m_AirThreshold;
+
+ int m_LastChunkX;
+ int m_LastChunkZ;
+ NOISE_DATATYPE m_NoiseArray[17 * 17 * 257]; // x + 17 * z + 17 * 17 * y
+
+
+ /// Generates the 3D noise array used for terrain generation, unless the LastChunk coords are equal to coords given
+ void GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ);
+
+ // cTerrainHeightGen overrides:
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
+
+ // cTerrainCompositionGen overrides:
+ virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
diff --git a/source/Generating/Ravines.cpp b/source/Generating/Ravines.cpp
index 94d91c0bb..6413b963b 100644
--- a/source/Generating/Ravines.cpp
+++ b/source/Generating/Ravines.cpp
@@ -1,531 +1,531 @@
-
-// Ravines.cpp
-
-// Implements the cStructGenRavines class representing the ravine structure generator
-
-#include "Globals.h"
-#include "Ravines.h"
-
-
-
-
-/// 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;
-
-
-
-
-
-struct cRavDefPoint
-{
- int m_BlockX;
- int m_BlockZ;
- int m_Radius;
- int m_Top;
- int m_Bottom;
-
- cRavDefPoint(int a_BlockX, int a_BlockZ, int a_Radius, int a_Top, int a_Bottom) :
- m_BlockX(a_BlockX),
- m_BlockZ(a_BlockZ),
- m_Radius(a_Radius),
- m_Top (a_Top),
- m_Bottom(a_Bottom)
- {
- }
-} ;
-
-typedef std::vector<cRavDefPoint> cRavDefPoints;
-
-
-
-
-
-class cStructGenRavines::cRavine
-{
- cRavDefPoints m_Points;
-
- /// 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
- void RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst);
-
- /// 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
- 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
- );
-
- #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
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cStructGenRavines:
-
-cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) :
- m_Noise(a_Seed),
- m_Size(a_Size)
-{
-}
-
-
-
-
-
-cStructGenRavines::~cStructGenRavines()
-{
- ClearCache();
-}
-
-
-
-
-
-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::GenStructures(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)
-{
- // Calculate the ravine shape-defining points:
- GenerateBaseDefPoints(a_BlockX, a_BlockZ, a_Size, a_Noise);
-
- // Smooth the ravine. A two passes are needed:
- Smooth();
- Smooth();
-
- // Linearly interpolate the neighbors so that they're close enough together:
- FinishLinear();
-}
-
-
-
-
-
-void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise)
-{
- // Modify the size slightly to have different-sized ravines (1/2 to 1/1 of a_Size):
- 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 CenterX = a_BlockX + OffsetX;
- int CenterZ = a_BlockZ + OffsetZ;
-
- // Get the base angle in which the ravine "axis" goes:
- float Angle = (float)(((float)((a_Noise.IntNoise3DInt(20 * a_BlockX, 70 * a_BlockZ, 6000) / 9) % 16384)) / 16384.0 * 3.141592653);
- float xc = sin(Angle);
- float zc = cos(Angle);
-
- // Calculate the definition points and radii:
- int MaxRadius = (int)(sqrt(12.0 + ((a_Noise.IntNoise2DInt(61 * a_BlockX, 97 * a_BlockZ) / 13) % a_Size) / 16));
- int Top = 32 + ((a_Noise.IntNoise2DInt(13 * a_BlockX, 17 * a_BlockZ) / 23) % 32);
- int Bottom = 5 + ((a_Noise.IntNoise2DInt(17 * a_BlockX, 29 * a_BlockZ) / 13) % 32);
- int Mid = (Top + Bottom) / 2;
- int PointX = CenterX - (int)(xc * a_Size / 2);
- int PointZ = CenterZ - (int)(zc * a_Size / 2);
- m_Points.push_back(cRavDefPoint(PointX, PointZ, 0, (Mid + Top) / 2, (Mid + Bottom) / 2));
- for (int i = 1; i < NUM_RAVINE_POINTS - 1; i++)
- {
- int LineX = CenterX + (int)(xc * a_Size * (i - NUM_RAVINE_POINTS / 2) / NUM_RAVINE_POINTS);
- int LineZ = CenterZ + (int)(zc * a_Size * (i - NUM_RAVINE_POINTS / 2) / NUM_RAVINE_POINTS);
- // Amplitude is the amount of blocks that this point is away from the ravine "axis"
- int Amplitude = (a_Noise.IntNoise3DInt(70 * a_BlockX, 20 * a_BlockZ + 31 * i, 10000 * i) / 9) % a_Size;
- Amplitude = Amplitude / 4 - a_Size / 8; // Amplitude is in interval [-a_Size / 4, a_Size / 4]
- int PointX = LineX + (int)(zc * Amplitude);
- int PointZ = LineZ - (int)(xc * Amplitude);
- int Radius = MaxRadius - abs(i - NUM_RAVINE_POINTS / 2); // TODO: better radius function
- int ThisTop = Top + ((a_Noise.IntNoise3DInt(7 * a_BlockX, 19 * a_BlockZ, i * 31) / 13) % 8) - 4;
- int ThisBottom = Bottom + ((a_Noise.IntNoise3DInt(19 * a_BlockX, 7 * a_BlockZ, i * 31) / 13) % 8) - 4;
- m_Points.push_back(cRavDefPoint(PointX, PointZ, Radius, ThisTop, ThisBottom));
- } // for i - m_Points[]
- PointX = CenterX + (int)(xc * a_Size / 2);
- PointZ = CenterZ + (int)(zc * a_Size / 2);
- m_Points.push_back(cRavDefPoint(PointX, PointZ, 0, Mid, Mid));
-}
-
-
-
-
-
-void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst)
-{
- // Smoothing: for each line segment, add points on its 1/4 lengths
- int 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;
- a_Dst.push_back(a_Src.front());
- int PrevX = a_Src.front().m_BlockX;
- int PrevZ = a_Src.front().m_BlockZ;
- int PrevR = a_Src.front().m_Radius;
- int PrevT = a_Src.front().m_Top;
- int PrevB = a_Src.front().m_Bottom;
- for (int i = 0; i <= Num; ++i, ++itr)
- {
- int dx = itr->m_BlockX - PrevX;
- int dz = itr->m_BlockZ - PrevZ;
- if (abs(dx) + abs(dz) < 4)
- {
- // Too short a segment to smooth-subdivide into quarters
- continue;
- }
- int dr = itr->m_Radius - PrevR;
- int dt = itr->m_Top - PrevT;
- int db = itr->m_Bottom - PrevB;
- int Rad1 = std::max(PrevR + 1 * dr / 4, 1);
- int Rad2 = std::max(PrevR + 3 * dr / 4, 1);
- a_Dst.push_back(cRavDefPoint(PrevX + 1 * dx / 4, PrevZ + 1 * dz / 4, Rad1, PrevT + 1 * dt / 4, PrevB + 1 * db / 4));
- a_Dst.push_back(cRavDefPoint(PrevX + 3 * dx / 4, PrevZ + 3 * dz / 4, Rad2, PrevT + 3 * dt / 4, PrevB + 3 * db / 4));
- PrevX = itr->m_BlockX;
- PrevZ = itr->m_BlockZ;
- PrevR = itr->m_Radius;
- PrevT = itr->m_Top;
- PrevB = itr->m_Bottom;
- }
- a_Dst.push_back(a_Src.back());
-}
-
-
-
-
-
-void cStructGenRavines::cRavine::Smooth(void)
-{
- cRavDefPoints Pts;
- RefineDefPoints(m_Points, Pts); // Refine m_Points -> Pts
- RefineDefPoints(Pts, m_Points); // Refine Pts -> m_Points
-}
-
-
-
-
-
-void cStructGenRavines::cRavine::FinishLinear(void)
-{
- // For each segment, use Bresenham's line algorithm to draw a "line" of defpoints
- // _X 2012_07_20: I tried modifying this algorithm to produce "thick" lines (only one coord change per point)
- // But the results were about the same as the original, so I disposed of it again - no need to use twice the count of points
-
- cRavDefPoints Pts;
- std::swap(Pts, m_Points);
-
- m_Points.reserve(Pts.size() * 3);
- int PrevX = Pts.front().m_BlockX;
- int PrevZ = Pts.front().m_BlockZ;
- for (cRavDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr)
- {
- int x1 = itr->m_BlockX;
- int z1 = itr->m_BlockZ;
- int dx = abs(x1 - PrevX);
- int dz = abs(z1 - PrevZ);
- int sx = (PrevX < x1) ? 1 : -1;
- int sz = (PrevZ < z1) ? 1 : -1;
- int err = dx - dz;
- int R = itr->m_Radius;
- int T = itr->m_Top;
- int B = itr->m_Bottom;
- while (true)
- {
- m_Points.push_back(cRavDefPoint(PrevX, PrevZ, R, T, B));
- if ((PrevX == x1) && (PrevZ == z1))
- {
- break;
- }
- int e2 = 2 * err;
- if (e2 > -dz)
- {
- err -= dz;
- PrevX += sx;
- }
- if (e2 < dx)
- {
- err += dx;
- PrevZ += sz;
- }
- } // while (true)
- } // for itr
-}
-
-
-
-
-
-#ifdef _DEBUG
-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);
- 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
- );
- 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_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",
- 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
-
-
-
-
-
-void cStructGenRavines::cRavine::ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
- cChunkDef::HeightMap & a_HeightMap
-)
-{
- int BlockStartX = a_ChunkX * cChunkDef::Width;
- int BlockStartZ = a_ChunkZ * 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)
- {
- if (
- (itr->m_BlockX + itr->m_Radius < BlockStartX) ||
- (itr->m_BlockX - itr->m_Radius > BlockEndX) ||
- (itr->m_BlockZ + itr->m_Radius < BlockStartZ) ||
- (itr->m_BlockZ - itr->m_Radius > BlockEndZ)
- )
- {
- // Cannot intersect, bail out early
- continue;
- }
-
- // Carve out a cylinder around the xz point, m_Radius in diameter, from Bottom to Top:
- int RadiusSq = itr->m_Radius * itr->m_Radius; // instead of doing sqrt for each distance, we do sqr of the radius
- int DifX = BlockStartX - itr->m_BlockX; // substitution for faster calc
- int DifZ = BlockStartZ - itr->m_BlockZ; // 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 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);
- }
- #endif // _DEBUG
-
- int DistSq = (DifX + x) * (DifX + x) + (DifZ + z) * (DifZ + z);
- if (DistSq <= RadiusSq)
- {
- 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))
- {
- // 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:
- {
- cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR);
- break;
- }
- default: break;
- }
- }
- }
- } // for x, z - a_BlockTypes
- } // for itr - m_Points[]
-}
-
-
-
-
+
+// Ravines.cpp
+
+// Implements the cStructGenRavines class representing the ravine structure generator
+
+#include "Globals.h"
+#include "Ravines.h"
+
+
+
+
+/// 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;
+
+
+
+
+
+struct cRavDefPoint
+{
+ int m_BlockX;
+ int m_BlockZ;
+ int m_Radius;
+ int m_Top;
+ int m_Bottom;
+
+ cRavDefPoint(int a_BlockX, int a_BlockZ, int a_Radius, int a_Top, int a_Bottom) :
+ m_BlockX(a_BlockX),
+ m_BlockZ(a_BlockZ),
+ m_Radius(a_Radius),
+ m_Top (a_Top),
+ m_Bottom(a_Bottom)
+ {
+ }
+} ;
+
+typedef std::vector<cRavDefPoint> cRavDefPoints;
+
+
+
+
+
+class cStructGenRavines::cRavine
+{
+ cRavDefPoints m_Points;
+
+ /// 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
+ void RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst);
+
+ /// 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
+ 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
+ );
+
+ #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
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cStructGenRavines:
+
+cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) :
+ m_Noise(a_Seed),
+ m_Size(a_Size)
+{
+}
+
+
+
+
+
+cStructGenRavines::~cStructGenRavines()
+{
+ ClearCache();
+}
+
+
+
+
+
+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::GenStructures(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)
+{
+ // Calculate the ravine shape-defining points:
+ GenerateBaseDefPoints(a_BlockX, a_BlockZ, a_Size, a_Noise);
+
+ // Smooth the ravine. A two passes are needed:
+ Smooth();
+ Smooth();
+
+ // Linearly interpolate the neighbors so that they're close enough together:
+ FinishLinear();
+}
+
+
+
+
+
+void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise)
+{
+ // Modify the size slightly to have different-sized ravines (1/2 to 1/1 of a_Size):
+ 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 CenterX = a_BlockX + OffsetX;
+ int CenterZ = a_BlockZ + OffsetZ;
+
+ // Get the base angle in which the ravine "axis" goes:
+ float Angle = (float)(((float)((a_Noise.IntNoise3DInt(20 * a_BlockX, 70 * a_BlockZ, 6000) / 9) % 16384)) / 16384.0 * 3.141592653);
+ float xc = sin(Angle);
+ float zc = cos(Angle);
+
+ // Calculate the definition points and radii:
+ int MaxRadius = (int)(sqrt(12.0 + ((a_Noise.IntNoise2DInt(61 * a_BlockX, 97 * a_BlockZ) / 13) % a_Size) / 16));
+ int Top = 32 + ((a_Noise.IntNoise2DInt(13 * a_BlockX, 17 * a_BlockZ) / 23) % 32);
+ int Bottom = 5 + ((a_Noise.IntNoise2DInt(17 * a_BlockX, 29 * a_BlockZ) / 13) % 32);
+ int Mid = (Top + Bottom) / 2;
+ int PointX = CenterX - (int)(xc * a_Size / 2);
+ int PointZ = CenterZ - (int)(zc * a_Size / 2);
+ m_Points.push_back(cRavDefPoint(PointX, PointZ, 0, (Mid + Top) / 2, (Mid + Bottom) / 2));
+ for (int i = 1; i < NUM_RAVINE_POINTS - 1; i++)
+ {
+ int LineX = CenterX + (int)(xc * a_Size * (i - NUM_RAVINE_POINTS / 2) / NUM_RAVINE_POINTS);
+ int LineZ = CenterZ + (int)(zc * a_Size * (i - NUM_RAVINE_POINTS / 2) / NUM_RAVINE_POINTS);
+ // Amplitude is the amount of blocks that this point is away from the ravine "axis"
+ int Amplitude = (a_Noise.IntNoise3DInt(70 * a_BlockX, 20 * a_BlockZ + 31 * i, 10000 * i) / 9) % a_Size;
+ Amplitude = Amplitude / 4 - a_Size / 8; // Amplitude is in interval [-a_Size / 4, a_Size / 4]
+ int PointX = LineX + (int)(zc * Amplitude);
+ int PointZ = LineZ - (int)(xc * Amplitude);
+ int Radius = MaxRadius - abs(i - NUM_RAVINE_POINTS / 2); // TODO: better radius function
+ int ThisTop = Top + ((a_Noise.IntNoise3DInt(7 * a_BlockX, 19 * a_BlockZ, i * 31) / 13) % 8) - 4;
+ int ThisBottom = Bottom + ((a_Noise.IntNoise3DInt(19 * a_BlockX, 7 * a_BlockZ, i * 31) / 13) % 8) - 4;
+ m_Points.push_back(cRavDefPoint(PointX, PointZ, Radius, ThisTop, ThisBottom));
+ } // for i - m_Points[]
+ PointX = CenterX + (int)(xc * a_Size / 2);
+ PointZ = CenterZ + (int)(zc * a_Size / 2);
+ m_Points.push_back(cRavDefPoint(PointX, PointZ, 0, Mid, Mid));
+}
+
+
+
+
+
+void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst)
+{
+ // Smoothing: for each line segment, add points on its 1/4 lengths
+ int 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;
+ a_Dst.push_back(a_Src.front());
+ int PrevX = a_Src.front().m_BlockX;
+ int PrevZ = a_Src.front().m_BlockZ;
+ int PrevR = a_Src.front().m_Radius;
+ int PrevT = a_Src.front().m_Top;
+ int PrevB = a_Src.front().m_Bottom;
+ for (int i = 0; i <= Num; ++i, ++itr)
+ {
+ int dx = itr->m_BlockX - PrevX;
+ int dz = itr->m_BlockZ - PrevZ;
+ if (abs(dx) + abs(dz) < 4)
+ {
+ // Too short a segment to smooth-subdivide into quarters
+ continue;
+ }
+ int dr = itr->m_Radius - PrevR;
+ int dt = itr->m_Top - PrevT;
+ int db = itr->m_Bottom - PrevB;
+ int Rad1 = std::max(PrevR + 1 * dr / 4, 1);
+ int Rad2 = std::max(PrevR + 3 * dr / 4, 1);
+ a_Dst.push_back(cRavDefPoint(PrevX + 1 * dx / 4, PrevZ + 1 * dz / 4, Rad1, PrevT + 1 * dt / 4, PrevB + 1 * db / 4));
+ a_Dst.push_back(cRavDefPoint(PrevX + 3 * dx / 4, PrevZ + 3 * dz / 4, Rad2, PrevT + 3 * dt / 4, PrevB + 3 * db / 4));
+ PrevX = itr->m_BlockX;
+ PrevZ = itr->m_BlockZ;
+ PrevR = itr->m_Radius;
+ PrevT = itr->m_Top;
+ PrevB = itr->m_Bottom;
+ }
+ a_Dst.push_back(a_Src.back());
+}
+
+
+
+
+
+void cStructGenRavines::cRavine::Smooth(void)
+{
+ cRavDefPoints Pts;
+ RefineDefPoints(m_Points, Pts); // Refine m_Points -> Pts
+ RefineDefPoints(Pts, m_Points); // Refine Pts -> m_Points
+}
+
+
+
+
+
+void cStructGenRavines::cRavine::FinishLinear(void)
+{
+ // For each segment, use Bresenham's line algorithm to draw a "line" of defpoints
+ // _X 2012_07_20: I tried modifying this algorithm to produce "thick" lines (only one coord change per point)
+ // But the results were about the same as the original, so I disposed of it again - no need to use twice the count of points
+
+ cRavDefPoints Pts;
+ std::swap(Pts, m_Points);
+
+ m_Points.reserve(Pts.size() * 3);
+ int PrevX = Pts.front().m_BlockX;
+ int PrevZ = Pts.front().m_BlockZ;
+ for (cRavDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr)
+ {
+ int x1 = itr->m_BlockX;
+ int z1 = itr->m_BlockZ;
+ int dx = abs(x1 - PrevX);
+ int dz = abs(z1 - PrevZ);
+ int sx = (PrevX < x1) ? 1 : -1;
+ int sz = (PrevZ < z1) ? 1 : -1;
+ int err = dx - dz;
+ int R = itr->m_Radius;
+ int T = itr->m_Top;
+ int B = itr->m_Bottom;
+ while (true)
+ {
+ m_Points.push_back(cRavDefPoint(PrevX, PrevZ, R, T, B));
+ if ((PrevX == x1) && (PrevZ == z1))
+ {
+ break;
+ }
+ int e2 = 2 * err;
+ if (e2 > -dz)
+ {
+ err -= dz;
+ PrevX += sx;
+ }
+ if (e2 < dx)
+ {
+ err += dx;
+ PrevZ += sz;
+ }
+ } // while (true)
+ } // for itr
+}
+
+
+
+
+
+#ifdef _DEBUG
+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);
+ 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
+ );
+ 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_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",
+ 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
+
+
+
+
+
+void cStructGenRavines::cRavine::ProcessChunk(
+ int a_ChunkX, int a_ChunkZ,
+ cChunkDef::BlockTypes & a_BlockTypes,
+ cChunkDef::HeightMap & a_HeightMap
+)
+{
+ int BlockStartX = a_ChunkX * cChunkDef::Width;
+ int BlockStartZ = a_ChunkZ * 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)
+ {
+ if (
+ (itr->m_BlockX + itr->m_Radius < BlockStartX) ||
+ (itr->m_BlockX - itr->m_Radius > BlockEndX) ||
+ (itr->m_BlockZ + itr->m_Radius < BlockStartZ) ||
+ (itr->m_BlockZ - itr->m_Radius > BlockEndZ)
+ )
+ {
+ // Cannot intersect, bail out early
+ continue;
+ }
+
+ // Carve out a cylinder around the xz point, m_Radius in diameter, from Bottom to Top:
+ int RadiusSq = itr->m_Radius * itr->m_Radius; // instead of doing sqrt for each distance, we do sqr of the radius
+ int DifX = BlockStartX - itr->m_BlockX; // substitution for faster calc
+ int DifZ = BlockStartZ - itr->m_BlockZ; // 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 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);
+ }
+ #endif // _DEBUG
+
+ int DistSq = (DifX + x) * (DifX + x) + (DifZ + z) * (DifZ + z);
+ if (DistSq <= RadiusSq)
+ {
+ 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))
+ {
+ // 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:
+ {
+ cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR);
+ break;
+ }
+ default: break;
+ }
+ }
+ }
+ } // for x, z - a_BlockTypes
+ } // for itr - m_Points[]
+}
+
+
+
+
diff --git a/source/Generating/Ravines.h b/source/Generating/Ravines.h
index 1c559c70d..05164a5b2 100644
--- a/source/Generating/Ravines.h
+++ b/source/Generating/Ravines.h
@@ -1,46 +1,46 @@
-
-// Ravines.h
-
-// Interfaces to the cStructGenRavines class representing the ravine structure generator
-
-
-
-
-
-#pragma once
-
-#include "ComposableGenerator.h"
-#include "../Noise.h"
-
-
-
-
-
-class cStructGenRavines :
- public cStructureGen
-{
-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);
-
- /// 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);
-
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
-} ;
-
-
-
-
+
+// Ravines.h
+
+// Interfaces to the cStructGenRavines class representing the ravine structure generator
+
+
+
+
+
+#pragma once
+
+#include "ComposableGenerator.h"
+#include "../Noise.h"
+
+
+
+
+
+class cStructGenRavines :
+ public cStructureGen
+{
+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);
+
+ /// 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);
+
+ // cStructureGen override:
+ virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+} ;
+
+
+
+
diff --git a/source/ItemGrid.cpp b/source/ItemGrid.cpp
index 4e424a668..a977a9b6d 100644
--- a/source/ItemGrid.cpp
+++ b/source/ItemGrid.cpp
@@ -1,662 +1,662 @@
-
-// ItemGrid.cpp
-
-// Implements the cItemGrid class representing a storage for items in a XY grid (chests, dispensers, inventory etc.)
-
-#include "Globals.h"
-#include "ItemGrid.h"
-#include "Items/ItemHandler.h"
-#include "Noise.h"
-
-
-
-
-
-cItemGrid::cItemGrid(int a_Width, int a_Height) :
- m_Width(a_Width),
- m_Height(a_Height),
- m_NumSlots(a_Width * a_Height),
- m_Slots(new cItem[a_Width * a_Height]),
- m_IsInTriggerListeners(false)
-{
-}
-
-
-
-
-
-cItemGrid::~cItemGrid()
-{
- delete[] m_Slots;
-}
-
-
-
-
-
-int cItemGrid::GetSlotNum(int a_X, int a_Y) const
-{
- if (
- (a_X < 0) || (a_X >= m_Width) ||
- (a_Y < 0) || (a_Y >= m_Height)
- )
- {
- LOGWARNING("%s: coords out of range: (%d, %d) in grid of size (%d, %d)",
- __FUNCTION__, a_X, a_Y, m_Width, m_Height
- );
- return -1;
- }
- return a_X + m_Width * a_Y;
-}
-
-
-
-
-
-void cItemGrid::GetSlotCoords(int a_SlotNum, int & a_X, int & a_Y) const
-{
- if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
- {
- LOGWARNING("%s: SlotNum out of range: %d in grid of range %d",
- __FUNCTION__, a_SlotNum, m_NumSlots
- );
- a_X = -1;
- a_Y = -1;
- return;
- }
- a_X = a_SlotNum % m_Width;
- a_Y = a_SlotNum / m_Width;
-}
-
-
-
-
-
-const cItem & cItemGrid::GetSlot(int a_X, int a_Y) const
-{
- return GetSlot(GetSlotNum(a_X, a_Y));
-}
-
-
-
-
-
-const cItem & cItemGrid::GetSlot(int a_SlotNum) const
-{
- if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
- {
- LOGWARNING("%s: Invalid slot number, %d out of %d slots",
- __FUNCTION__, a_SlotNum, m_NumSlots
- );
- return m_Slots[0];
- }
- return m_Slots[a_SlotNum];
-}
-
-
-
-
-
-void cItemGrid::SetSlot(int a_X, int a_Y, const cItem & a_Item)
-{
- SetSlot(GetSlotNum(a_X, a_Y), a_Item);
-}
-
-
-
-
-
-void cItemGrid::SetSlot(int a_X, int a_Y, short a_ItemType, char a_ItemCount, short a_ItemDamage)
-{
- SetSlot(GetSlotNum(a_X, a_Y), cItem(a_ItemType, a_ItemCount, a_ItemDamage));
-}
-
-
-
-
-
-void cItemGrid::SetSlot(int a_SlotNum, const cItem & a_Item)
-{
- if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
- {
- LOGWARNING("%s: Invalid slot number %d out of %d slots",
- __FUNCTION__, a_SlotNum, m_NumSlots
- );
- return;
- }
- m_Slots[a_SlotNum] = a_Item;
- TriggerListeners(a_SlotNum);
-}
-
-
-
-
-
-void cItemGrid::SetSlot(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage)
-{
- SetSlot(a_SlotNum, cItem(a_ItemType, a_ItemCount, a_ItemDamage));
-}
-
-
-
-
-
-void cItemGrid::EmptySlot(int a_X, int a_Y)
-{
- EmptySlot(GetSlotNum(a_X, a_Y));
-}
-
-
-
-
-
-void cItemGrid::EmptySlot(int a_SlotNum)
-{
- if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
- {
- LOGWARNING("%s: Invalid slot number %d out of %d slots",
- __FUNCTION__, a_SlotNum, m_NumSlots
- );
- return;
- }
-
- // Check if already empty:
- if (m_Slots[a_SlotNum].IsEmpty())
- {
- return;
- }
-
- // Empty and notify
- m_Slots[a_SlotNum].Empty();
- TriggerListeners(a_SlotNum);
-}
-
-
-
-
-
-bool cItemGrid::IsSlotEmpty(int a_SlotNum) const
-{
- if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
- {
- LOGWARNING("%s: Invalid slot number %d out of %d slots",
- __FUNCTION__, a_SlotNum, m_NumSlots
- );
- return true;
- }
- return m_Slots[a_SlotNum].IsEmpty();
-}
-
-
-
-
-
-bool cItemGrid::IsSlotEmpty(int a_X, int a_Y) const
-{
- return IsSlotEmpty(GetSlotNum(a_X, a_Y));
-}
-
-
-
-
-
-void cItemGrid::Clear(void)
-{
- for (int i = 0; i < m_NumSlots; i++)
- {
- m_Slots[i].Empty();
- TriggerListeners(i);
- }
-}
-
-
-
-
-
-int cItemGrid::HowManyCanFit(const cItem & a_ItemStack)
-{
- char NumLeft = a_ItemStack.m_ItemCount;
- int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize();
- for (int i = m_NumSlots - 1; i >= 0; i--)
- {
- if (m_Slots[i].IsEmpty())
- {
- NumLeft -= MaxStack;
- }
- else if (m_Slots[i].IsStackableWith(a_ItemStack))
- {
- NumLeft -= MaxStack - m_Slots[i].m_ItemCount;
- }
- if (NumLeft <= 0)
- {
- // All items fit
- return a_ItemStack.m_ItemCount;
- }
- } // for i - m_Slots[]
- return a_ItemStack.m_ItemCount - NumLeft;
-}
-
-
-
-
-
-int cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, int a_MaxStack)
-{
- int PrevCount = 0;
- if (m_Slots[a_Slot].IsEmpty())
- {
- m_Slots[a_Slot] = a_ItemStack;
- PrevCount = 0;
- }
- else
- {
- PrevCount = m_Slots[a_Slot].m_ItemCount;
- }
- m_Slots[a_Slot].m_ItemCount = std::min(a_MaxStack, PrevCount + a_Num);
- int toReturn = m_Slots[a_Slot].m_ItemCount - PrevCount;
- TriggerListeners(a_Slot);
- return toReturn;
-}
-
-
-
-
-
-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();
-
- // Try prioritarySlot first:
- if (
- (a_PrioritarySlot != -1) &&
- (
- m_Slots[a_PrioritarySlot].IsEmpty() ||
- m_Slots[a_PrioritarySlot].IsStackableWith(a_ItemStack)
- )
- )
- {
- NumLeft -= AddItemToSlot(a_ItemStack, a_PrioritarySlot, NumLeft, MaxStack);
- }
-
- // Scan existing stacks:
- for (int i = m_NumSlots - 1; i >= 0; i--)
- {
- if (m_Slots[i].IsStackableWith(a_ItemStack))
- {
- NumLeft -= AddItemToSlot(a_ItemStack, i, NumLeft, MaxStack);
- }
- if (NumLeft <= 0)
- {
- // All items fit
- return a_ItemStack.m_ItemCount;
- }
- } // for i - m_Slots[]
-
- if (!a_AllowNewStacks)
- {
- return (a_ItemStack.m_ItemCount - NumLeft);
- }
-
- for (int i = m_NumSlots - 1; i >= 0; i--)
- {
- if (m_Slots[i].IsEmpty())
- {
- NumLeft -= AddItemToSlot(a_ItemStack, i, NumLeft, MaxStack);
- }
- if (NumLeft <= 0)
- {
- // All items fit
- return a_ItemStack.m_ItemCount;
- }
- } // for i - m_Slots[]
- return (a_ItemStack.m_ItemCount - NumLeft);
-}
-
-
-
-
-
-int cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_PrioritarySlot)
-{
- int TotalAdded = 0;
- for (cItems::iterator itr = a_ItemStackList.begin(); itr != a_ItemStackList.end();)
- {
- int NumAdded = AddItem(*itr, a_AllowNewStacks, a_PrioritarySlot);
- if (itr->m_ItemCount == NumAdded)
- {
- itr = a_ItemStackList.erase(itr);
- }
- else
- {
- itr->m_ItemCount -= NumAdded;
- ++itr;
- }
- TotalAdded += NumAdded;
- }
- return TotalAdded;
-}
-
-
-
-
-
-int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount)
-{
- if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
- {
- LOGWARNING("%s: Invalid slot number %d out of %d slots, ignoring the call, returning -1",
- __FUNCTION__, a_SlotNum, m_NumSlots
- );
- return -1;
- }
-
- if (m_Slots[a_SlotNum].IsEmpty())
- {
- // The item is empty, it's not gonna change
- return 0;
- }
-
- if (m_Slots[a_SlotNum].m_ItemCount <= -a_AddToCount)
- {
- // Trying to remove more items than there already are, make the item empty
- m_Slots[a_SlotNum].Empty();
- TriggerListeners(a_SlotNum);
- return 0;
- }
-
- m_Slots[a_SlotNum].m_ItemCount += a_AddToCount;
- TriggerListeners(a_SlotNum);
- return m_Slots[a_SlotNum].m_ItemCount;
-}
-
-
-
-
-
-int cItemGrid::ChangeSlotCount(int a_X, int a_Y, int a_AddToCount)
-{
- return ChangeSlotCount(GetSlotNum(a_X, a_Y), a_AddToCount);
-}
-
-
-
-
-
-cItem cItemGrid::RemoveOneItem(int a_SlotNum)
-{
- if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
- {
- LOGWARNING("%s: Invalid slot number %d out of %d slots, ignoring the call, returning empty item",
- __FUNCTION__, a_SlotNum, m_NumSlots
- );
- return cItem();
- }
-
- // If the slot is empty, return an empty item
- if (m_Slots[a_SlotNum].IsEmpty())
- {
- return cItem();
- }
-
- // Make a copy of the item in slot, set count to 1 and remove one from the slot
- cItem res = m_Slots[a_SlotNum];
- res.m_ItemCount = 1;
- m_Slots[a_SlotNum].m_ItemCount -= 1;
-
- // Emptying the slot correctly if appropriate
- if (m_Slots[a_SlotNum].m_ItemCount == 0)
- {
- m_Slots[a_SlotNum].Empty();
- }
-
- // Notify everyone of the change
- TriggerListeners(a_SlotNum);
-
- // Return the stored one item
- return res;
-}
-
-
-
-
-
-cItem cItemGrid::RemoveOneItem(int a_X, int a_Y)
-{
- return RemoveOneItem(GetSlotNum(a_X, a_Y));
-}
-
-
-
-
-
-int cItemGrid::HowManyItems(const cItem & a_Item)
-{
- int res = 0;
- for (int i = 0; i < m_NumSlots; i++)
- {
- if (m_Slots[i].IsStackableWith(a_Item))
- {
- res += m_Slots[i].m_ItemCount;
- }
- }
- return res;
-}
-
-
-
-
-
-bool cItemGrid::HasItems(const cItem & a_ItemStack)
-{
- int CurrentlyHave = HowManyItems(a_ItemStack);
- return (CurrentlyHave >= a_ItemStack.m_ItemCount);
-}
-
-
-
-
-
-int cItemGrid::GetFirstEmptySlot(void) const
-{
- return GetNextEmptySlot(-1);
-}
-
-
-
-
-
-int cItemGrid::GetFirstUsedSlot(void) const
-{
- return GetNextUsedSlot(-1);
-}
-
-
-
-
-
-int cItemGrid::GetLastEmptySlot(void) const
-{
- for (int i = m_NumSlots - 1; i >= 0; i--)
- {
- if (m_Slots[i].IsEmpty())
- {
- return i;
- }
- }
- return -1;
-}
-
-
-
-
-
-int cItemGrid::GetLastUsedSlot(void) const
-{
- for (int i = m_NumSlots - 1; i >= 0; i--)
- {
- if (!m_Slots[i].IsEmpty())
- {
- return i;
- }
- }
- return -1;
-}
-
-
-
-
-
-int cItemGrid::GetNextEmptySlot(int a_StartFrom) const
-{
- for (int i = a_StartFrom + 1; i < m_NumSlots; i++)
- {
- if (m_Slots[i].IsEmpty())
- {
- return i;
- }
- }
- return -1;
-}
-
-
-
-
-
-int cItemGrid::GetNextUsedSlot(int a_StartFrom) const
-{
- for (int i = a_StartFrom + 1; i < m_NumSlots; i++)
- {
- if (!m_Slots[i].IsEmpty())
- {
- return i;
- }
- }
- return -1;
-}
-
-
-
-
-
-void cItemGrid::CopyToItems(cItems & a_Items) const
-{
- for (int i = 0; i < m_NumSlots; i++)
- {
- if (!m_Slots[i].IsEmpty())
- {
- a_Items.push_back(m_Slots[i]);
- }
- } // for i - m_Slots[]
-}
-
-
-
-
-
-bool cItemGrid::DamageItem(int a_SlotNum, short a_Amount)
-{
- if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
- {
- LOGWARNING("%s: invalid slot number %d out of %d slots, ignoring.", __FUNCTION__, a_SlotNum, m_NumSlots);
- return false;
- }
- return m_Slots[a_SlotNum].DamageItem(a_Amount);
-}
-
-
-
-
-
-bool cItemGrid::DamageItem(int a_X, int a_Y, short a_Amount)
-{
- return DamageItem(GetSlotNum(a_X, a_Y), a_Amount);
-}
-
-
-
-
-
-void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, int a_CountLootProbabs, int a_NumSlots, int a_Seed)
-{
- // Calculate the total weight:
- int TotalProbab = 1;
- for (int i = 0; i < a_CountLootProbabs; i++)
- {
- TotalProbab += a_LootProbabs[i].m_Weight;
- }
-
- // Pick the loot items:
- cNoise Noise(a_Seed);
- for (int i = 0; i < a_NumSlots; i++)
- {
- int Rnd = (Noise.IntNoise1DInt(i) / 7);
- int LootRnd = Rnd % TotalProbab;
- Rnd >>= 8;
- cItem CurrentLoot = cItem(E_ITEM_BOOK, 1, 0); // TODO: enchantment
- for (int j = 0; j < a_CountLootProbabs; j++)
- {
- LootRnd -= a_LootProbabs[i].m_Weight;
- if (LootRnd < 0)
- {
- CurrentLoot = a_LootProbabs[i].m_Item;
- CurrentLoot.m_ItemCount = a_LootProbabs[i].m_MinAmount + (Rnd % (a_LootProbabs[i].m_MaxAmount - a_LootProbabs[i].m_MinAmount));
- Rnd >>= 8;
- break;
- }
- } // for j - a_LootProbabs[]
- SetSlot(Rnd % m_NumSlots, CurrentLoot);
- } // for i - NumSlots
-}
-
-
-
-
-
-void cItemGrid::AddListener(cListener & a_Listener)
-{
- cCSLock Lock(m_CSListeners);
- ASSERT(!m_IsInTriggerListeners); // Must not call this while in TriggerListeners()
- m_Listeners.push_back(&a_Listener);
-}
-
-
-
-
-
-void cItemGrid::RemoveListener(cListener & a_Listener)
-{
- cCSLock Lock(m_CSListeners);
- ASSERT(!m_IsInTriggerListeners); // Must not call this while in TriggerListeners()
- for (cListeners::iterator itr = m_Listeners.begin(), end = m_Listeners.end(); itr != end; ++itr)
- {
- if (*itr == &a_Listener)
- {
- m_Listeners.erase(itr);
- return;
- }
- } // for itr - m_Listeners[]
-}
-
-
-
-
-
-void cItemGrid::TriggerListeners(int a_SlotNum)
-{
- cListeners Listeners;
- {
- cCSLock Lock(m_CSListeners);
- m_IsInTriggerListeners = true;
- Listeners = m_Listeners;
- }
- for (cListeners::iterator itr = Listeners.begin(), end = Listeners.end(); itr != end; ++itr)
- {
- (*itr)->OnSlotChanged(this, a_SlotNum);
- } // for itr - m_Listeners[]
- m_IsInTriggerListeners = false;
-}
-
-
-
-
+
+// ItemGrid.cpp
+
+// Implements the cItemGrid class representing a storage for items in a XY grid (chests, dispensers, inventory etc.)
+
+#include "Globals.h"
+#include "ItemGrid.h"
+#include "Items/ItemHandler.h"
+#include "Noise.h"
+
+
+
+
+
+cItemGrid::cItemGrid(int a_Width, int a_Height) :
+ m_Width(a_Width),
+ m_Height(a_Height),
+ m_NumSlots(a_Width * a_Height),
+ m_Slots(new cItem[a_Width * a_Height]),
+ m_IsInTriggerListeners(false)
+{
+}
+
+
+
+
+
+cItemGrid::~cItemGrid()
+{
+ delete[] m_Slots;
+}
+
+
+
+
+
+int cItemGrid::GetSlotNum(int a_X, int a_Y) const
+{
+ if (
+ (a_X < 0) || (a_X >= m_Width) ||
+ (a_Y < 0) || (a_Y >= m_Height)
+ )
+ {
+ LOGWARNING("%s: coords out of range: (%d, %d) in grid of size (%d, %d)",
+ __FUNCTION__, a_X, a_Y, m_Width, m_Height
+ );
+ return -1;
+ }
+ return a_X + m_Width * a_Y;
+}
+
+
+
+
+
+void cItemGrid::GetSlotCoords(int a_SlotNum, int & a_X, int & a_Y) const
+{
+ if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
+ {
+ LOGWARNING("%s: SlotNum out of range: %d in grid of range %d",
+ __FUNCTION__, a_SlotNum, m_NumSlots
+ );
+ a_X = -1;
+ a_Y = -1;
+ return;
+ }
+ a_X = a_SlotNum % m_Width;
+ a_Y = a_SlotNum / m_Width;
+}
+
+
+
+
+
+const cItem & cItemGrid::GetSlot(int a_X, int a_Y) const
+{
+ return GetSlot(GetSlotNum(a_X, a_Y));
+}
+
+
+
+
+
+const cItem & cItemGrid::GetSlot(int a_SlotNum) const
+{
+ if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
+ {
+ LOGWARNING("%s: Invalid slot number, %d out of %d slots",
+ __FUNCTION__, a_SlotNum, m_NumSlots
+ );
+ return m_Slots[0];
+ }
+ return m_Slots[a_SlotNum];
+}
+
+
+
+
+
+void cItemGrid::SetSlot(int a_X, int a_Y, const cItem & a_Item)
+{
+ SetSlot(GetSlotNum(a_X, a_Y), a_Item);
+}
+
+
+
+
+
+void cItemGrid::SetSlot(int a_X, int a_Y, short a_ItemType, char a_ItemCount, short a_ItemDamage)
+{
+ SetSlot(GetSlotNum(a_X, a_Y), cItem(a_ItemType, a_ItemCount, a_ItemDamage));
+}
+
+
+
+
+
+void cItemGrid::SetSlot(int a_SlotNum, const cItem & a_Item)
+{
+ if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
+ {
+ LOGWARNING("%s: Invalid slot number %d out of %d slots",
+ __FUNCTION__, a_SlotNum, m_NumSlots
+ );
+ return;
+ }
+ m_Slots[a_SlotNum] = a_Item;
+ TriggerListeners(a_SlotNum);
+}
+
+
+
+
+
+void cItemGrid::SetSlot(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage)
+{
+ SetSlot(a_SlotNum, cItem(a_ItemType, a_ItemCount, a_ItemDamage));
+}
+
+
+
+
+
+void cItemGrid::EmptySlot(int a_X, int a_Y)
+{
+ EmptySlot(GetSlotNum(a_X, a_Y));
+}
+
+
+
+
+
+void cItemGrid::EmptySlot(int a_SlotNum)
+{
+ if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
+ {
+ LOGWARNING("%s: Invalid slot number %d out of %d slots",
+ __FUNCTION__, a_SlotNum, m_NumSlots
+ );
+ return;
+ }
+
+ // Check if already empty:
+ if (m_Slots[a_SlotNum].IsEmpty())
+ {
+ return;
+ }
+
+ // Empty and notify
+ m_Slots[a_SlotNum].Empty();
+ TriggerListeners(a_SlotNum);
+}
+
+
+
+
+
+bool cItemGrid::IsSlotEmpty(int a_SlotNum) const
+{
+ if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
+ {
+ LOGWARNING("%s: Invalid slot number %d out of %d slots",
+ __FUNCTION__, a_SlotNum, m_NumSlots
+ );
+ return true;
+ }
+ return m_Slots[a_SlotNum].IsEmpty();
+}
+
+
+
+
+
+bool cItemGrid::IsSlotEmpty(int a_X, int a_Y) const
+{
+ return IsSlotEmpty(GetSlotNum(a_X, a_Y));
+}
+
+
+
+
+
+void cItemGrid::Clear(void)
+{
+ for (int i = 0; i < m_NumSlots; i++)
+ {
+ m_Slots[i].Empty();
+ TriggerListeners(i);
+ }
+}
+
+
+
+
+
+int cItemGrid::HowManyCanFit(const cItem & a_ItemStack)
+{
+ char NumLeft = a_ItemStack.m_ItemCount;
+ int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize();
+ for (int i = m_NumSlots - 1; i >= 0; i--)
+ {
+ if (m_Slots[i].IsEmpty())
+ {
+ NumLeft -= MaxStack;
+ }
+ else if (m_Slots[i].IsStackableWith(a_ItemStack))
+ {
+ NumLeft -= MaxStack - m_Slots[i].m_ItemCount;
+ }
+ if (NumLeft <= 0)
+ {
+ // All items fit
+ return a_ItemStack.m_ItemCount;
+ }
+ } // for i - m_Slots[]
+ return a_ItemStack.m_ItemCount - NumLeft;
+}
+
+
+
+
+
+int cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, int a_MaxStack)
+{
+ int PrevCount = 0;
+ if (m_Slots[a_Slot].IsEmpty())
+ {
+ m_Slots[a_Slot] = a_ItemStack;
+ PrevCount = 0;
+ }
+ else
+ {
+ PrevCount = m_Slots[a_Slot].m_ItemCount;
+ }
+ m_Slots[a_Slot].m_ItemCount = std::min(a_MaxStack, PrevCount + a_Num);
+ int toReturn = m_Slots[a_Slot].m_ItemCount - PrevCount;
+ TriggerListeners(a_Slot);
+ return toReturn;
+}
+
+
+
+
+
+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();
+
+ // Try prioritarySlot first:
+ if (
+ (a_PrioritarySlot != -1) &&
+ (
+ m_Slots[a_PrioritarySlot].IsEmpty() ||
+ m_Slots[a_PrioritarySlot].IsStackableWith(a_ItemStack)
+ )
+ )
+ {
+ NumLeft -= AddItemToSlot(a_ItemStack, a_PrioritarySlot, NumLeft, MaxStack);
+ }
+
+ // Scan existing stacks:
+ for (int i = m_NumSlots - 1; i >= 0; i--)
+ {
+ if (m_Slots[i].IsStackableWith(a_ItemStack))
+ {
+ NumLeft -= AddItemToSlot(a_ItemStack, i, NumLeft, MaxStack);
+ }
+ if (NumLeft <= 0)
+ {
+ // All items fit
+ return a_ItemStack.m_ItemCount;
+ }
+ } // for i - m_Slots[]
+
+ if (!a_AllowNewStacks)
+ {
+ return (a_ItemStack.m_ItemCount - NumLeft);
+ }
+
+ for (int i = m_NumSlots - 1; i >= 0; i--)
+ {
+ if (m_Slots[i].IsEmpty())
+ {
+ NumLeft -= AddItemToSlot(a_ItemStack, i, NumLeft, MaxStack);
+ }
+ if (NumLeft <= 0)
+ {
+ // All items fit
+ return a_ItemStack.m_ItemCount;
+ }
+ } // for i - m_Slots[]
+ return (a_ItemStack.m_ItemCount - NumLeft);
+}
+
+
+
+
+
+int cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_PrioritarySlot)
+{
+ int TotalAdded = 0;
+ for (cItems::iterator itr = a_ItemStackList.begin(); itr != a_ItemStackList.end();)
+ {
+ int NumAdded = AddItem(*itr, a_AllowNewStacks, a_PrioritarySlot);
+ if (itr->m_ItemCount == NumAdded)
+ {
+ itr = a_ItemStackList.erase(itr);
+ }
+ else
+ {
+ itr->m_ItemCount -= NumAdded;
+ ++itr;
+ }
+ TotalAdded += NumAdded;
+ }
+ return TotalAdded;
+}
+
+
+
+
+
+int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount)
+{
+ if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
+ {
+ LOGWARNING("%s: Invalid slot number %d out of %d slots, ignoring the call, returning -1",
+ __FUNCTION__, a_SlotNum, m_NumSlots
+ );
+ return -1;
+ }
+
+ if (m_Slots[a_SlotNum].IsEmpty())
+ {
+ // The item is empty, it's not gonna change
+ return 0;
+ }
+
+ if (m_Slots[a_SlotNum].m_ItemCount <= -a_AddToCount)
+ {
+ // Trying to remove more items than there already are, make the item empty
+ m_Slots[a_SlotNum].Empty();
+ TriggerListeners(a_SlotNum);
+ return 0;
+ }
+
+ m_Slots[a_SlotNum].m_ItemCount += a_AddToCount;
+ TriggerListeners(a_SlotNum);
+ return m_Slots[a_SlotNum].m_ItemCount;
+}
+
+
+
+
+
+int cItemGrid::ChangeSlotCount(int a_X, int a_Y, int a_AddToCount)
+{
+ return ChangeSlotCount(GetSlotNum(a_X, a_Y), a_AddToCount);
+}
+
+
+
+
+
+cItem cItemGrid::RemoveOneItem(int a_SlotNum)
+{
+ if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
+ {
+ LOGWARNING("%s: Invalid slot number %d out of %d slots, ignoring the call, returning empty item",
+ __FUNCTION__, a_SlotNum, m_NumSlots
+ );
+ return cItem();
+ }
+
+ // If the slot is empty, return an empty item
+ if (m_Slots[a_SlotNum].IsEmpty())
+ {
+ return cItem();
+ }
+
+ // Make a copy of the item in slot, set count to 1 and remove one from the slot
+ cItem res = m_Slots[a_SlotNum];
+ res.m_ItemCount = 1;
+ m_Slots[a_SlotNum].m_ItemCount -= 1;
+
+ // Emptying the slot correctly if appropriate
+ if (m_Slots[a_SlotNum].m_ItemCount == 0)
+ {
+ m_Slots[a_SlotNum].Empty();
+ }
+
+ // Notify everyone of the change
+ TriggerListeners(a_SlotNum);
+
+ // Return the stored one item
+ return res;
+}
+
+
+
+
+
+cItem cItemGrid::RemoveOneItem(int a_X, int a_Y)
+{
+ return RemoveOneItem(GetSlotNum(a_X, a_Y));
+}
+
+
+
+
+
+int cItemGrid::HowManyItems(const cItem & a_Item)
+{
+ int res = 0;
+ for (int i = 0; i < m_NumSlots; i++)
+ {
+ if (m_Slots[i].IsStackableWith(a_Item))
+ {
+ res += m_Slots[i].m_ItemCount;
+ }
+ }
+ return res;
+}
+
+
+
+
+
+bool cItemGrid::HasItems(const cItem & a_ItemStack)
+{
+ int CurrentlyHave = HowManyItems(a_ItemStack);
+ return (CurrentlyHave >= a_ItemStack.m_ItemCount);
+}
+
+
+
+
+
+int cItemGrid::GetFirstEmptySlot(void) const
+{
+ return GetNextEmptySlot(-1);
+}
+
+
+
+
+
+int cItemGrid::GetFirstUsedSlot(void) const
+{
+ return GetNextUsedSlot(-1);
+}
+
+
+
+
+
+int cItemGrid::GetLastEmptySlot(void) const
+{
+ for (int i = m_NumSlots - 1; i >= 0; i--)
+ {
+ if (m_Slots[i].IsEmpty())
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+
+
+
+
+int cItemGrid::GetLastUsedSlot(void) const
+{
+ for (int i = m_NumSlots - 1; i >= 0; i--)
+ {
+ if (!m_Slots[i].IsEmpty())
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+
+
+
+
+int cItemGrid::GetNextEmptySlot(int a_StartFrom) const
+{
+ for (int i = a_StartFrom + 1; i < m_NumSlots; i++)
+ {
+ if (m_Slots[i].IsEmpty())
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+
+
+
+
+int cItemGrid::GetNextUsedSlot(int a_StartFrom) const
+{
+ for (int i = a_StartFrom + 1; i < m_NumSlots; i++)
+ {
+ if (!m_Slots[i].IsEmpty())
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+
+
+
+
+void cItemGrid::CopyToItems(cItems & a_Items) const
+{
+ for (int i = 0; i < m_NumSlots; i++)
+ {
+ if (!m_Slots[i].IsEmpty())
+ {
+ a_Items.push_back(m_Slots[i]);
+ }
+ } // for i - m_Slots[]
+}
+
+
+
+
+
+bool cItemGrid::DamageItem(int a_SlotNum, short a_Amount)
+{
+ if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
+ {
+ LOGWARNING("%s: invalid slot number %d out of %d slots, ignoring.", __FUNCTION__, a_SlotNum, m_NumSlots);
+ return false;
+ }
+ return m_Slots[a_SlotNum].DamageItem(a_Amount);
+}
+
+
+
+
+
+bool cItemGrid::DamageItem(int a_X, int a_Y, short a_Amount)
+{
+ return DamageItem(GetSlotNum(a_X, a_Y), a_Amount);
+}
+
+
+
+
+
+void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, int a_CountLootProbabs, int a_NumSlots, int a_Seed)
+{
+ // Calculate the total weight:
+ int TotalProbab = 1;
+ for (int i = 0; i < a_CountLootProbabs; i++)
+ {
+ TotalProbab += a_LootProbabs[i].m_Weight;
+ }
+
+ // Pick the loot items:
+ cNoise Noise(a_Seed);
+ for (int i = 0; i < a_NumSlots; i++)
+ {
+ int Rnd = (Noise.IntNoise1DInt(i) / 7);
+ int LootRnd = Rnd % TotalProbab;
+ Rnd >>= 8;
+ cItem CurrentLoot = cItem(E_ITEM_BOOK, 1, 0); // TODO: enchantment
+ for (int j = 0; j < a_CountLootProbabs; j++)
+ {
+ LootRnd -= a_LootProbabs[i].m_Weight;
+ if (LootRnd < 0)
+ {
+ CurrentLoot = a_LootProbabs[i].m_Item;
+ CurrentLoot.m_ItemCount = a_LootProbabs[i].m_MinAmount + (Rnd % (a_LootProbabs[i].m_MaxAmount - a_LootProbabs[i].m_MinAmount));
+ Rnd >>= 8;
+ break;
+ }
+ } // for j - a_LootProbabs[]
+ SetSlot(Rnd % m_NumSlots, CurrentLoot);
+ } // for i - NumSlots
+}
+
+
+
+
+
+void cItemGrid::AddListener(cListener & a_Listener)
+{
+ cCSLock Lock(m_CSListeners);
+ ASSERT(!m_IsInTriggerListeners); // Must not call this while in TriggerListeners()
+ m_Listeners.push_back(&a_Listener);
+}
+
+
+
+
+
+void cItemGrid::RemoveListener(cListener & a_Listener)
+{
+ cCSLock Lock(m_CSListeners);
+ ASSERT(!m_IsInTriggerListeners); // Must not call this while in TriggerListeners()
+ for (cListeners::iterator itr = m_Listeners.begin(), end = m_Listeners.end(); itr != end; ++itr)
+ {
+ if (*itr == &a_Listener)
+ {
+ m_Listeners.erase(itr);
+ return;
+ }
+ } // for itr - m_Listeners[]
+}
+
+
+
+
+
+void cItemGrid::TriggerListeners(int a_SlotNum)
+{
+ cListeners Listeners;
+ {
+ cCSLock Lock(m_CSListeners);
+ m_IsInTriggerListeners = true;
+ Listeners = m_Listeners;
+ }
+ for (cListeners::iterator itr = Listeners.begin(), end = Listeners.end(); itr != end; ++itr)
+ {
+ (*itr)->OnSlotChanged(this, a_SlotNum);
+ } // for itr - m_Listeners[]
+ m_IsInTriggerListeners = false;
+}
+
+
+
+
diff --git a/source/ItemGrid.h b/source/ItemGrid.h
index 45f978530..9eba5b452 100644
--- a/source/ItemGrid.h
+++ b/source/ItemGrid.h
@@ -1,191 +1,191 @@
-
-// ItemGrid.h
-
-// Declares the cItemGrid class representing a storage for items in a XY grid (chests, dispensers, inventory etc.)
-
-
-
-
-#pragma once
-
-#include "Item.h"
-
-
-
-
-
-// tolua_begin
-class cItemGrid
-{
-public:
- // tolua_end
-
- /// This class is used as a callback for when a slot changes
- class cListener
- {
- public:
- /// Called whenever a slot changes
- virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) = 0;
- } ;
- typedef std::vector<cListener *> cListeners;
-
- cItemGrid(int a_Width, int a_Height);
-
- ~cItemGrid();
-
- // tolua_begin
- int GetWidth (void) const { return m_Width; }
- int GetHeight (void) const { return m_Height; }
- int GetNumSlots(void) const { return m_NumSlots; }
-
- /// Converts XY coords into slot number; returns -1 on invalid coords
- int GetSlotNum(int a_X, int a_Y) const;
-
- // tolua_end
-
- /// Converts slot number into XY coords; sets coords to -1 on invalid slot number. Exported in ManualBindings.cpp
- void GetSlotCoords(int a_SlotNum, int & a_X, int & a_Y) const;
-
- // tolua_begin
-
- // Retrieve slots by coords or slot number; Logs warning and returns the first slot on invalid coords / slotnum
- const cItem & GetSlot(int a_X, int a_Y) const;
- const cItem & GetSlot(int a_SlotNum) const;
-
- // Set slot by coords or slot number; Logs warning and doesn't set on invalid coords / slotnum
- void SetSlot(int a_X, int a_Y, const cItem & a_Item);
- void SetSlot(int a_X, int a_Y, short a_ItemType, char a_ItemCount, short a_ItemDamage);
- void SetSlot(int a_SlotNum, const cItem & a_Item);
- void SetSlot(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage);
-
- // Empty the specified slot; Logs warning and doesn't set on invalid coords / slotnum
- void EmptySlot(int a_X, int a_Y);
- void EmptySlot(int a_SlotNum);
-
- /// Returns true if the specified slot is empty or the slot doesn't exist
- bool IsSlotEmpty(int a_SlotNum) const;
-
- /// Returns true if the specified slot is empty or the slot doesn't exist
- bool IsSlotEmpty(int a_X, int a_Y) const;
-
- /// Sets all items as empty
- void Clear(void);
-
- /// Returns number of items out of a_ItemStack that can fit in the storage
- int HowManyCanFit(const cItem & a_ItemStack);
-
- /** Adds as many items out of a_ItemStack as can fit.
- If a_AllowNewStacks is set to false, only existing stacks can be topped up;
- if a_AllowNewStacks is set to true, empty slots can be used for the rest.
- If a_PrioritarySlot is set to a positive value, then the corresponding slot will be used in
- first (if empty or compatible with added items)
- if a_PrioritarySlot is set to -1, regular order apply
- Returns the number of items that fit.
- */
- int AddItem(cItem & a_ItemStack, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1);
-
- /** Same as AddItem, but works on an entire list of item stacks.
- The a_ItemStackList is modified to reflect the leftover items.
- If a_AllowNewStacks is set to false, only existing stacks can be topped up;
- if a_AllowNewStacks is set to true, empty slots can be used for the rest.
- If a_PrioritarySlot is set to a positive value, then the corresponding slot will be used in
- first (if empty or compatible with added items)
- if a_PrioritarySlot is set to -1, regular order apply
- Returns the total number of items that fit.
- */
- int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1);
-
- /** 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.
- Returns the new count.
- */
- int ChangeSlotCount(int a_SlotNum, int a_AddToCount);
-
- /** 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.
- Returns the new count.
- */
- int ChangeSlotCount(int a_X, int a_Y, int a_AddToCount);
-
- /** Removes one item from the stack in the specified slot, and returns it.
- If the slot was empty, returns an empty item
- */
- cItem RemoveOneItem(int a_SlotNum);
-
- /** Removes one item from the stack in the specified slot, and returns it.
- If the slot was empty, returns an empty item
- */
- cItem RemoveOneItem(int a_X, int a_Y);
-
- /// 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
- bool HasItems(const cItem & a_ItemStack);
-
- /// Returns the index of the first empty slot; -1 if all full
- int GetFirstEmptySlot(void) const;
-
- /// Returns the index of the first non-empty slot; -1 if all empty
- int GetFirstUsedSlot(void) const;
-
- /// Returns the index of the last empty slot; -1 if all full
- int GetLastEmptySlot(void) const;
-
- /// Returns the index of the last used slot; -1 if all empty
- int GetLastUsedSlot(void) const;
-
- /// Returns the index of the first empty slot following a_StartFrom (a_StartFrom is not checked)
- int GetNextEmptySlot(int a_StartFrom) const;
-
- /// Returns the index of the first used slot following a_StartFrom (a_StartFrom is not checked)
- int GetNextUsedSlot(int a_StartFrom) const;
-
- /// Copies the contents into a cItems object; preserves the original a_Items contents
- void CopyToItems(cItems & a_Items) const;
-
- /// Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact)
- bool DamageItem(int a_SlotNum, short a_Amount);
-
- /// Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact)
- bool DamageItem(int a_X, int a_Y, short a_Amount);
-
- // tolua_end
-
-
- /** Generates random loot from the specified loot probability table, with a chance of enchanted books added.
- A total of a_NumSlots are taken by the loot.
- Cannot export to Lua due to raw array a_LootProbabs. TODO: Make this exportable / export through ManualBindings.cpp with a Lua table as LootProbabs
- */
- void GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, int a_CountLootProbabs, int a_NumSlots, int a_Seed);
-
- /// Adds a callback that gets called whenever a slot changes. Must not be called from within the listener callback!
- void AddListener(cListener & a_Listener);
-
- /// Removes a slot-change-callback. Must not be called from within the listener callback!
- void RemoveListener(cListener & a_Listener);
-
- // tolua_begin
-
-protected:
- int m_Width;
- int m_Height;
- int m_NumSlots; // m_Width * m_Height, for easier validity checking in the access functions
- cItem * m_Slots; // x + m_Width * y
-
- cListeners m_Listeners; ///< Listeners which should be notified on slot changes; the pointers are not owned by this object
- cCriticalSection m_CSListeners; ///< CS that guards the m_Listeners against multi-thread access
- bool m_IsInTriggerListeners; ///< Set to true while TriggerListeners is running, to detect attempts to manipulate listener list while triggerring
-
- /// Calls all m_Listeners for the specified slot number
- void TriggerListeners(int a_SlotNum);
-
- /** Adds up to a_Num items out of a_ItemStack, as many as can fit, in specified slot
- Returns the number of items that did fit.
- */
- int AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, int a_MaxStack);
-} ;
-// tolua_end
-
-
-
+
+// ItemGrid.h
+
+// Declares the cItemGrid class representing a storage for items in a XY grid (chests, dispensers, inventory etc.)
+
+
+
+
+#pragma once
+
+#include "Item.h"
+
+
+
+
+
+// tolua_begin
+class cItemGrid
+{
+public:
+ // tolua_end
+
+ /// This class is used as a callback for when a slot changes
+ class cListener
+ {
+ public:
+ /// Called whenever a slot changes
+ virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) = 0;
+ } ;
+ typedef std::vector<cListener *> cListeners;
+
+ cItemGrid(int a_Width, int a_Height);
+
+ ~cItemGrid();
+
+ // tolua_begin
+ int GetWidth (void) const { return m_Width; }
+ int GetHeight (void) const { return m_Height; }
+ int GetNumSlots(void) const { return m_NumSlots; }
+
+ /// Converts XY coords into slot number; returns -1 on invalid coords
+ int GetSlotNum(int a_X, int a_Y) const;
+
+ // tolua_end
+
+ /// Converts slot number into XY coords; sets coords to -1 on invalid slot number. Exported in ManualBindings.cpp
+ void GetSlotCoords(int a_SlotNum, int & a_X, int & a_Y) const;
+
+ // tolua_begin
+
+ // Retrieve slots by coords or slot number; Logs warning and returns the first slot on invalid coords / slotnum
+ const cItem & GetSlot(int a_X, int a_Y) const;
+ const cItem & GetSlot(int a_SlotNum) const;
+
+ // Set slot by coords or slot number; Logs warning and doesn't set on invalid coords / slotnum
+ void SetSlot(int a_X, int a_Y, const cItem & a_Item);
+ void SetSlot(int a_X, int a_Y, short a_ItemType, char a_ItemCount, short a_ItemDamage);
+ void SetSlot(int a_SlotNum, const cItem & a_Item);
+ void SetSlot(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage);
+
+ // Empty the specified slot; Logs warning and doesn't set on invalid coords / slotnum
+ void EmptySlot(int a_X, int a_Y);
+ void EmptySlot(int a_SlotNum);
+
+ /// Returns true if the specified slot is empty or the slot doesn't exist
+ bool IsSlotEmpty(int a_SlotNum) const;
+
+ /// Returns true if the specified slot is empty or the slot doesn't exist
+ bool IsSlotEmpty(int a_X, int a_Y) const;
+
+ /// Sets all items as empty
+ void Clear(void);
+
+ /// Returns number of items out of a_ItemStack that can fit in the storage
+ int HowManyCanFit(const cItem & a_ItemStack);
+
+ /** Adds as many items out of a_ItemStack as can fit.
+ If a_AllowNewStacks is set to false, only existing stacks can be topped up;
+ if a_AllowNewStacks is set to true, empty slots can be used for the rest.
+ If a_PrioritarySlot is set to a positive value, then the corresponding slot will be used in
+ first (if empty or compatible with added items)
+ if a_PrioritarySlot is set to -1, regular order apply
+ Returns the number of items that fit.
+ */
+ int AddItem(cItem & a_ItemStack, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1);
+
+ /** Same as AddItem, but works on an entire list of item stacks.
+ The a_ItemStackList is modified to reflect the leftover items.
+ If a_AllowNewStacks is set to false, only existing stacks can be topped up;
+ if a_AllowNewStacks is set to true, empty slots can be used for the rest.
+ If a_PrioritarySlot is set to a positive value, then the corresponding slot will be used in
+ first (if empty or compatible with added items)
+ if a_PrioritarySlot is set to -1, regular order apply
+ Returns the total number of items that fit.
+ */
+ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1);
+
+ /** 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.
+ Returns the new count.
+ */
+ int ChangeSlotCount(int a_SlotNum, int a_AddToCount);
+
+ /** 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.
+ Returns the new count.
+ */
+ int ChangeSlotCount(int a_X, int a_Y, int a_AddToCount);
+
+ /** Removes one item from the stack in the specified slot, and returns it.
+ If the slot was empty, returns an empty item
+ */
+ cItem RemoveOneItem(int a_SlotNum);
+
+ /** Removes one item from the stack in the specified slot, and returns it.
+ If the slot was empty, returns an empty item
+ */
+ cItem RemoveOneItem(int a_X, int a_Y);
+
+ /// 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
+ bool HasItems(const cItem & a_ItemStack);
+
+ /// Returns the index of the first empty slot; -1 if all full
+ int GetFirstEmptySlot(void) const;
+
+ /// Returns the index of the first non-empty slot; -1 if all empty
+ int GetFirstUsedSlot(void) const;
+
+ /// Returns the index of the last empty slot; -1 if all full
+ int GetLastEmptySlot(void) const;
+
+ /// Returns the index of the last used slot; -1 if all empty
+ int GetLastUsedSlot(void) const;
+
+ /// Returns the index of the first empty slot following a_StartFrom (a_StartFrom is not checked)
+ int GetNextEmptySlot(int a_StartFrom) const;
+
+ /// Returns the index of the first used slot following a_StartFrom (a_StartFrom is not checked)
+ int GetNextUsedSlot(int a_StartFrom) const;
+
+ /// Copies the contents into a cItems object; preserves the original a_Items contents
+ void CopyToItems(cItems & a_Items) const;
+
+ /// Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact)
+ bool DamageItem(int a_SlotNum, short a_Amount);
+
+ /// Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact)
+ bool DamageItem(int a_X, int a_Y, short a_Amount);
+
+ // tolua_end
+
+
+ /** Generates random loot from the specified loot probability table, with a chance of enchanted books added.
+ A total of a_NumSlots are taken by the loot.
+ Cannot export to Lua due to raw array a_LootProbabs. TODO: Make this exportable / export through ManualBindings.cpp with a Lua table as LootProbabs
+ */
+ void GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, int a_CountLootProbabs, int a_NumSlots, int a_Seed);
+
+ /// Adds a callback that gets called whenever a slot changes. Must not be called from within the listener callback!
+ void AddListener(cListener & a_Listener);
+
+ /// Removes a slot-change-callback. Must not be called from within the listener callback!
+ void RemoveListener(cListener & a_Listener);
+
+ // tolua_begin
+
+protected:
+ int m_Width;
+ int m_Height;
+ int m_NumSlots; // m_Width * m_Height, for easier validity checking in the access functions
+ cItem * m_Slots; // x + m_Width * y
+
+ cListeners m_Listeners; ///< Listeners which should be notified on slot changes; the pointers are not owned by this object
+ cCriticalSection m_CSListeners; ///< CS that guards the m_Listeners against multi-thread access
+ bool m_IsInTriggerListeners; ///< Set to true while TriggerListeners is running, to detect attempts to manipulate listener list while triggerring
+
+ /// Calls all m_Listeners for the specified slot number
+ void TriggerListeners(int a_SlotNum);
+
+ /** Adds up to a_Num items out of a_ItemStack, as many as can fit, in specified slot
+ Returns the number of items that did fit.
+ */
+ int AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, int a_MaxStack);
+} ;
+// tolua_end
+
+
+
diff --git a/source/Items/ItemBed.h b/source/Items/ItemBed.h
index c9fec9064..ab4182eea 100644
--- a/source/Items/ItemBed.h
+++ b/source/Items/ItemBed.h
@@ -1,56 +1,56 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Blocks/BlockBed.h"
-
-
-
-
-
-class cItemBedHandler :
- public cItemHandler
-{
-public:
- cItemBedHandler(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, char a_BlockFace,
- int a_CursorX, int a_CursorY, int a_CursorZ,
- BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
- {
- if (a_BlockFace != BLOCK_FACE_TOP)
- {
- // Can only be placed on the floor
- return false;
- }
-
- a_BlockMeta = cBlockBedHandler::RotationToMetaData(a_Player->GetRotation());
-
- // Check if there is empty space for the foot section:
- Vector3i Direction = cBlockBedHandler::MetaDataToDirection(a_BlockMeta);
- if (a_World->GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) != E_BLOCK_AIR)
- {
- return false;
- }
-
- a_BlockType = E_BLOCK_BED;
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Blocks/BlockBed.h"
+
+
+
+
+
+class cItemBedHandler :
+ public cItemHandler
+{
+public:
+ cItemBedHandler(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, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ if (a_BlockFace != BLOCK_FACE_TOP)
+ {
+ // Can only be placed on the floor
+ return false;
+ }
+
+ a_BlockMeta = cBlockBedHandler::RotationToMetaData(a_Player->GetRotation());
+
+ // Check if there is empty space for the foot section:
+ Vector3i Direction = cBlockBedHandler::MetaDataToDirection(a_BlockMeta);
+ if (a_World->GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) != E_BLOCK_AIR)
+ {
+ return false;
+ }
+
+ a_BlockType = E_BLOCK_BED;
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemBrewingStand.h b/source/Items/ItemBrewingStand.h
index 07ee7dfeb..4ff14d4b4 100644
--- a/source/Items/ItemBrewingStand.h
+++ b/source/Items/ItemBrewingStand.h
@@ -1,41 +1,41 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-
-
-
-class cItemBrewingStandHandler :
- public cItemHandler
-{
-public:
- cItemBrewingStandHandler(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, char a_BlockFace,
- int a_CursorX, int a_CursorY, int a_CursorZ,
- BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
- {
- a_BlockType = E_BLOCK_BREWING_STAND;
- a_BlockMeta = 0;
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemBrewingStandHandler :
+ public cItemHandler
+{
+public:
+ cItemBrewingStandHandler(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, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = E_BLOCK_BREWING_STAND;
+ a_BlockMeta = 0;
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemBucket.h b/source/Items/ItemBucket.h
index e4adc98b8..fa3d48da1 100644
--- a/source/Items/ItemBucket.h
+++ b/source/Items/ItemBucket.h
@@ -1,160 +1,160 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Simulator/FluidSimulator.h"
-#include "../Blocks/BlockHandler.h"
-
-
-
-
-
-class cItemBucketHandler :
- public cItemHandler
-{
-public:
- cItemBucketHandler(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, char a_Dir) override
- {
- switch (m_ItemType)
- {
- case E_ITEM_BUCKET: return ScoopUpFluid(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
- case E_ITEM_LAVA_BUCKET: return PlaceFluid (a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_Dir, E_BLOCK_LAVA);
- case E_ITEM_WATER_BUCKET: return PlaceFluid (a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_Dir, E_BLOCK_WATER);
- default:
- {
- ASSERT(!"Unhandled ItemType");
- return false;
- }
- }
- }
-
-
-
- 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)
- {
- return false;
- }
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- BLOCKTYPE ClickedBlock;
- NIBBLETYPE ClickedMeta;
- a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedMeta);
- LOGD("Bucket Clicked BlockType %d, meta %d", ClickedBlock, ClickedMeta);
- if (ClickedMeta != 0)
- {
- // Not a source block
- return false;
- }
-
- if (a_Player->GetGameMode() == gmCreative)
- {
- // In creative mode don't modify the inventory, just remove the fluid:
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- return true;
- }
-
- ENUM_ITEM_ID NewItem = E_ITEM_EMPTY;
- switch (ClickedBlock)
- {
- case E_BLOCK_WATER:
- case E_BLOCK_STATIONARY_WATER:
- {
- NewItem = E_ITEM_WATER_BUCKET;
- break;
- }
- case E_BLOCK_LAVA:
- case E_BLOCK_STATIONARY_LAVA:
- {
- NewItem = E_ITEM_LAVA_BUCKET;
- break;
- }
-
- default: return false;
- }
-
- // Remove the bucket from the inventory
- if (!a_Player->GetInventory().RemoveOneEquippedItem())
- {
- LOG("Clicked with an empty bucket, but cannot remove one from the inventory? WTF?");
- ASSERT(!"Inventory bucket mismatch");
- return true;
- }
-
- // Give new bucket, filled with fluid:
- cItem Item(NewItem, 1);
- a_Player->GetInventory().AddItem(Item, true, true);
-
- // Remove water / lava block
- a_Player->GetWorld()->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- return true;
- }
-
-
- bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_FluidBlock)
- {
- if (a_BlockFace < 0)
- {
- return false;
- }
-
- BLOCKTYPE CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
- if (!CanWashAway)
- {
- // 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;
- }
-
- if (a_Player->GetGameMode() != gmCreative)
- {
- // Remove fluid bucket, add empty bucket:
- if (!a_Player->GetInventory().RemoveOneEquippedItem())
- {
- LOG("Clicked with a full bucket, but cannot remove one from the inventory? WTF?");
- ASSERT(!"Inventory bucket mismatch");
- return false;
- }
- cItem Item(E_ITEM_BUCKET, 1);
- if (!a_Player->GetInventory().AddItem(Item,true,true))
- {
- return false;
- }
- }
-
- // Wash away anything that was there prior to placing:
- if (CanWashAway)
- {
- cBlockHandler * Handler = BlockHandler(CurrentBlock);
- if (Handler->DoesDropOnUnsuitable())
- {
- Handler->DropBlock(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ);
- }
- }
-
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FluidBlock, 0);
-
- return true;
- }
-
-};
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Simulator/FluidSimulator.h"
+#include "../Blocks/BlockHandler.h"
+
+
+
+
+
+class cItemBucketHandler :
+ public cItemHandler
+{
+public:
+ cItemBucketHandler(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, char a_Dir) override
+ {
+ switch (m_ItemType)
+ {
+ case E_ITEM_BUCKET: return ScoopUpFluid(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
+ case E_ITEM_LAVA_BUCKET: return PlaceFluid (a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_Dir, E_BLOCK_LAVA);
+ case E_ITEM_WATER_BUCKET: return PlaceFluid (a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_Dir, E_BLOCK_WATER);
+ default:
+ {
+ ASSERT(!"Unhandled ItemType");
+ return false;
+ }
+ }
+ }
+
+
+
+ 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)
+ {
+ return false;
+ }
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ BLOCKTYPE ClickedBlock;
+ NIBBLETYPE ClickedMeta;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedMeta);
+ LOGD("Bucket Clicked BlockType %d, meta %d", ClickedBlock, ClickedMeta);
+ if (ClickedMeta != 0)
+ {
+ // Not a source block
+ return false;
+ }
+
+ if (a_Player->GetGameMode() == gmCreative)
+ {
+ // In creative mode don't modify the inventory, just remove the fluid:
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ return true;
+ }
+
+ ENUM_ITEM_ID NewItem = E_ITEM_EMPTY;
+ switch (ClickedBlock)
+ {
+ case E_BLOCK_WATER:
+ case E_BLOCK_STATIONARY_WATER:
+ {
+ NewItem = E_ITEM_WATER_BUCKET;
+ break;
+ }
+ case E_BLOCK_LAVA:
+ case E_BLOCK_STATIONARY_LAVA:
+ {
+ NewItem = E_ITEM_LAVA_BUCKET;
+ break;
+ }
+
+ default: return false;
+ }
+
+ // Remove the bucket from the inventory
+ if (!a_Player->GetInventory().RemoveOneEquippedItem())
+ {
+ LOG("Clicked with an empty bucket, but cannot remove one from the inventory? WTF?");
+ ASSERT(!"Inventory bucket mismatch");
+ return true;
+ }
+
+ // Give new bucket, filled with fluid:
+ cItem Item(NewItem, 1);
+ a_Player->GetInventory().AddItem(Item, true, true);
+
+ // Remove water / lava block
+ a_Player->GetWorld()->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ return true;
+ }
+
+
+ bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_FluidBlock)
+ {
+ if (a_BlockFace < 0)
+ {
+ return false;
+ }
+
+ BLOCKTYPE CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
+ if (!CanWashAway)
+ {
+ // 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;
+ }
+
+ if (a_Player->GetGameMode() != gmCreative)
+ {
+ // Remove fluid bucket, add empty bucket:
+ if (!a_Player->GetInventory().RemoveOneEquippedItem())
+ {
+ LOG("Clicked with a full bucket, but cannot remove one from the inventory? WTF?");
+ ASSERT(!"Inventory bucket mismatch");
+ return false;
+ }
+ cItem Item(E_ITEM_BUCKET, 1);
+ if (!a_Player->GetInventory().AddItem(Item,true,true))
+ {
+ return false;
+ }
+ }
+
+ // Wash away anything that was there prior to placing:
+ if (CanWashAway)
+ {
+ cBlockHandler * Handler = BlockHandler(CurrentBlock);
+ if (Handler->DoesDropOnUnsuitable())
+ {
+ Handler->DropBlock(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ);
+ }
+ }
+
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FluidBlock, 0);
+
+ return true;
+ }
+
+};
diff --git a/source/Items/ItemCauldron.h b/source/Items/ItemCauldron.h
index 216766cf8..8b2ddc29f 100644
--- a/source/Items/ItemCauldron.h
+++ b/source/Items/ItemCauldron.h
@@ -1,41 +1,41 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-
-
-
-class cItemCauldronHandler :
- public cItemHandler
-{
-public:
- cItemCauldronHandler(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, char a_BlockFace,
- int a_CursorX, int a_CursorY, int a_CursorZ,
- BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
- {
- a_BlockType = E_BLOCK_CAULDRON;
- a_BlockMeta = 0;
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemCauldronHandler :
+ public cItemHandler
+{
+public:
+ cItemCauldronHandler(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, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = E_BLOCK_CAULDRON;
+ a_BlockMeta = 0;
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemCloth.h b/source/Items/ItemCloth.h
index f6e2c1906..aca27a299 100644
--- a/source/Items/ItemCloth.h
+++ b/source/Items/ItemCloth.h
@@ -1,23 +1,23 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-
-
-
-class cItemClothHandler :
- public cItemHandler
-{
-public:
- cItemClothHandler(int a_ItemType)
- : cItemHandler(a_ItemType)
- {
-
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemClothHandler :
+ public cItemHandler
+{
+public:
+ cItemClothHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemDoor.h b/source/Items/ItemDoor.h
index 6ebeab43a..72ea0beed 100644
--- a/source/Items/ItemDoor.h
+++ b/source/Items/ItemDoor.h
@@ -1,45 +1,45 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cItemDoorHandler :
- public cItemHandler
-{
-public:
- cItemDoorHandler(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, char a_BlockFace,
- int a_CursorX, int a_CursorY, int a_CursorZ,
- BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
- {
- a_BlockType = (m_ItemType == E_ITEM_WOODEN_DOOR) ? E_BLOCK_WOODEN_DOOR : E_BLOCK_IRON_DOOR;
- return BlockHandler(a_BlockType)->GetPlacementBlockTypeMeta(
- a_World, a_Player,
- a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
- a_CursorX, a_CursorY, a_CursorZ,
- a_BlockType, a_BlockMeta
- );
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cItemDoorHandler :
+ public cItemHandler
+{
+public:
+ cItemDoorHandler(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, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = (m_ItemType == E_ITEM_WOODEN_DOOR) ? E_BLOCK_WOODEN_DOOR : E_BLOCK_IRON_DOOR;
+ return BlockHandler(a_BlockType)->GetPlacementBlockTypeMeta(
+ a_World, a_Player,
+ a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
+ a_CursorX, a_CursorY, a_CursorZ,
+ a_BlockType, a_BlockMeta
+ );
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemDye.h b/source/Items/ItemDye.h
index e4c31fa4b..984d452b7 100644
--- a/source/Items/ItemDye.h
+++ b/source/Items/ItemDye.h
@@ -1,44 +1,44 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Player.h"
-
-
-
-
-
-class cItemDyeHandler :
- public cItemHandler
-{
-public:
- cItemDyeHandler(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, char a_Dir) override
- {
- // TODO: Handle coloring the sheep, too (OnItemUseOnEntity maybe)
-
- // Handle growing the plants:
- if (a_Item.m_ItemDamage == E_META_DYE_WHITE)
- {
- if (a_World->GrowRipePlant(a_BlockX, a_BlockY, a_BlockZ, true))
- {
- if (a_Player->GetGameMode() != gmCreative)
- {
- a_Player->GetInventory().RemoveOneEquippedItem();
- return true;
- }
- }
- }
- return false;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Player.h"
+
+
+
+
+
+class cItemDyeHandler :
+ public cItemHandler
+{
+public:
+ cItemDyeHandler(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, char a_Dir) override
+ {
+ // TODO: Handle coloring the sheep, too (OnItemUseOnEntity maybe)
+
+ // Handle growing the plants:
+ if (a_Item.m_ItemDamage == E_META_DYE_WHITE)
+ {
+ if (a_World->GrowRipePlant(a_BlockX, a_BlockY, a_BlockZ, true))
+ {
+ if (a_Player->GetGameMode() != gmCreative)
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemFlowerPot.h b/source/Items/ItemFlowerPot.h
index 0e55ddb51..befa2ff21 100644
--- a/source/Items/ItemFlowerPot.h
+++ b/source/Items/ItemFlowerPot.h
@@ -1,41 +1,41 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-
-
-
-class cItemFlowerPotHandler :
- public cItemHandler
-{
-public:
- cItemFlowerPotHandler(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, char a_BlockFace,
- int a_CursorX, int a_CursorY, int a_CursorZ,
- BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
- {
- a_BlockType = E_BLOCK_FLOWER_POT;
- a_BlockMeta = 0;
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemFlowerPotHandler :
+ public cItemHandler
+{
+public:
+ cItemFlowerPotHandler(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, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = E_BLOCK_FLOWER_POT;
+ a_BlockMeta = 0;
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemFood.h b/source/Items/ItemFood.h
index d4c0a012a..8a6898103 100644
--- a/source/Items/ItemFood.h
+++ b/source/Items/ItemFood.h
@@ -1,56 +1,56 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-class cItemFoodHandler : public cItemHandler
-{
-public:
- cItemFoodHandler(int a_ItemType)
- : cItemHandler(a_ItemType)
- {
- }
-
- virtual bool IsFood() override
- {
- return true;
- }
-
- virtual FoodInfo GetFoodInfo() override
- {
- switch(m_ItemType)
- {
- case E_ITEM_BREAD:
- return FoodInfo(5, 6.f);
- case E_ITEM_COOKIE:
- return FoodInfo(2, 0.4f);
- case E_ITEM_MELON_SLICE:
- return FoodInfo(2, 1.2f);
- case E_ITEM_RAW_CHICKEN:
- return FoodInfo(2, 1.2f, 30);
- case E_ITEM_COOKED_CHICKEN:
- return FoodInfo(6, 7.2f);
- case E_ITEM_RAW_BEEF:
- case E_ITEM_RAW_PORKCHOP:
- return FoodInfo(3, 1.8f);
- case E_ITEM_STEAK:
- case E_ITEM_COOKED_PORKCHOP:
- return FoodInfo(8, 12.8f);
- case E_ITEM_RAW_FISH:
- return FoodInfo(2, 1.2f);
- case E_ITEM_COOKED_FISH:
- return FoodInfo(5, 6.f);
- case E_ITEM_RED_APPLE:
- return FoodInfo(4, 2.4f);
- case E_ITEM_GOLDEN_APPLE:
- return FoodInfo(4, 9.6f);
- case E_ITEM_ROTTEN_FLESH:
- return FoodInfo(4, 0.8f, 80);
- case E_ITEM_SPIDER_EYE:
- return FoodInfo(2, 3.2f, 100);
- }
- return FoodInfo(0, 0.f);
- }
-
-}; \ No newline at end of file
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemFoodHandler :
+ public cItemHandler
+{
+ typedef cItemHandler super;
+
+public:
+ cItemFoodHandler(int a_ItemType)
+ : super(a_ItemType)
+ {
+ }
+
+
+ virtual bool IsFood(void) override
+ {
+ return true;
+ }
+
+
+ virtual FoodInfo GetFoodInfo(void) override
+ {
+ switch(m_ItemType)
+ {
+ case E_ITEM_BREAD: return FoodInfo(5, 6);
+ case E_ITEM_COOKIE: return FoodInfo(2, 0.4);
+ case E_ITEM_MELON_SLICE: return FoodInfo(2, 1.2);
+ case E_ITEM_RAW_CHICKEN: return FoodInfo(2, 1.2, 30);
+ case E_ITEM_COOKED_CHICKEN: return FoodInfo(6, 7.2);
+ case E_ITEM_RAW_BEEF: return FoodInfo(3, 1.8);
+ case E_ITEM_RAW_PORKCHOP: return FoodInfo(3, 1.8);
+ case E_ITEM_STEAK: return FoodInfo(8, 12.8);
+ case E_ITEM_COOKED_PORKCHOP: return FoodInfo(8, 12.8);
+ case E_ITEM_RAW_FISH: return FoodInfo(2, 1.2);
+ case E_ITEM_COOKED_FISH: return FoodInfo(5, 6);
+ case E_ITEM_RED_APPLE: return FoodInfo(4, 2.4);
+ case E_ITEM_GOLDEN_APPLE: return FoodInfo(4, 9.6);
+ case E_ITEM_ROTTEN_FLESH: return FoodInfo(4, 0.8, 80);
+ case E_ITEM_SPIDER_EYE: return FoodInfo(2, 3.2, 100);
+ }
+ LOGWARNING("%s: Unknown food item (%d), returning zero nutrition", __FUNCTION__, m_ItemType);
+ return FoodInfo(0, 0.f);
+ }
+
+};
+
+
+
+
diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp
index d99457029..c81916f5f 100644
--- a/source/Items/ItemHandler.cpp
+++ b/source/Items/ItemHandler.cpp
@@ -1,497 +1,500 @@
-
-#include "Globals.h"
-#include "ItemHandler.h"
-#include "../Item.h"
-#include "../World.h"
-#include "../Player.h"
-
-// Handlers:
-#include "ItemBed.h"
-#include "ItemBrewingStand.h"
-#include "ItemBucket.h"
-#include "ItemCauldron.h"
-#include "ItemCloth.h"
-#include "ItemDoor.h"
-#include "ItemDye.h"
-#include "ItemFlowerPot.h"
-#include "ItemFood.h"
-#include "ItemHoe.h"
-#include "ItemLeaves.h"
-#include "ItemLighter.h"
-#include "ItemMinecart.h"
-#include "ItemPickaxe.h"
-#include "ItemRedstoneDust.h"
-#include "ItemRedstoneRepeater.h"
-#include "ItemSapling.h"
-#include "ItemSeeds.h"
-#include "ItemShears.h"
-#include "ItemShovel.h"
-#include "ItemSign.h"
-#include "ItemSlab.h"
-#include "ItemSpawnEgg.h"
-#include "ItemSugarcane.h"
-#include "ItemSword.h"
-#include "ItemWood.h"
-
-#include "../Blocks/BlockHandler.h"
-
-
-
-
-
-bool cItemHandler::m_HandlerInitialized = false;
-cItemHandler * cItemHandler::m_ItemHandler[2268];
-
-
-
-
-
-cItemHandler *cItemHandler::GetItemHandler(int a_ItemType)
-{
- if(a_ItemType < 0) a_ItemType = 0;
-
- if(!m_HandlerInitialized)
- { //We have to initialize
- memset(m_ItemHandler, 0, sizeof(m_ItemHandler));
- m_HandlerInitialized = true;
- }
- if(m_ItemHandler[a_ItemType])
- return m_ItemHandler[a_ItemType];
- m_ItemHandler[a_ItemType] = CreateItemHandler(a_ItemType);
- return m_ItemHandler[a_ItemType];
-}
-
-
-
-
-
-cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
-{
- switch(a_ItemType)
- {
- default: return new cItemHandler(a_ItemType);
-
- // Single item per handler, alphabetically sorted:
- case E_BLOCK_LEAVES: return new cItemLeavesHandler(a_ItemType);
- case E_BLOCK_SAPLING: return new cItemSaplingHandler(a_ItemType);
- case E_BLOCK_WOOL: return new cItemClothHandler(a_ItemType);
- case E_ITEM_BED: return new cItemBedHandler(a_ItemType);
- case E_ITEM_BREWING_STAND: return new cItemBrewingStandHandler(a_ItemType);
- case E_ITEM_CAULDRON: return new cItemCauldronHandler(a_ItemType);
- case E_ITEM_DYE: return new cItemDyeHandler(a_ItemType);
- case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemType);
- case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType);
- 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);
- case E_ITEM_SIGN: return new cItemSignHandler(a_ItemType);
- case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemType);
- case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemType);
-
- case E_ITEM_WOODEN_HOE:
- case E_ITEM_STONE_HOE:
- case E_ITEM_IRON_HOE:
- case E_ITEM_GOLD_HOE:
- case E_ITEM_DIAMOND_HOE:
- {
- return new cItemHoeHandler(a_ItemType);
- }
-
- case E_ITEM_WOODEN_PICKAXE:
- case E_ITEM_STONE_PICKAXE:
- case E_ITEM_IRON_PICKAXE:
- case E_ITEM_GOLD_PICKAXE:
- case E_ITEM_DIAMOND_PICKAXE:
- {
- return new cItemPickaxeHandler(a_ItemType);
- }
-
- case E_ITEM_WOODEN_SHOVEL:
- case E_ITEM_STONE_SHOVEL:
- case E_ITEM_IRON_SHOVEL:
- case E_ITEM_GOLD_SHOVEL:
- case E_ITEM_DIAMOND_SHOVEL:
- {
- return new cItemShovelHandler(a_ItemType);
- }
-
- case E_ITEM_WOODEN_SWORD:
- case E_ITEM_STONE_SWORD:
- case E_ITEM_IRON_SWORD:
- case E_ITEM_GOLD_SWORD:
- case E_ITEM_DIAMOND_SWORD:
- {
- return new cItemSwordHandler(a_ItemType);
- }
-
- case E_BLOCK_STONE_SLAB:
- case E_BLOCK_WOODEN_SLAB:
- {
- return new cItemSlabHandler(a_ItemType);
- }
-
- case E_BLOCK_LOG:
- case E_BLOCK_PLANKS:
- {
- return new cItemWoodHandler(a_ItemType);
- }
-
- case E_ITEM_BUCKET:
- case E_ITEM_WATER_BUCKET:
- case E_ITEM_LAVA_BUCKET:
- {
- return new cItemBucketHandler(a_ItemType);
- }
-
- case E_ITEM_CARROT:
- case E_ITEM_MELON_SEEDS:
- case E_ITEM_POTATO:
- case E_ITEM_PUMPKIN_SEEDS:
- case E_ITEM_SEEDS:
- {
- return new cItemSeedsHandler(a_ItemType);
- }
-
- case E_ITEM_IRON_DOOR:
- case E_ITEM_WOODEN_DOOR:
- {
- return new cItemDoorHandler(a_ItemType);
- }
-
- case E_ITEM_MINECART:
- case E_ITEM_CHEST_MINECART:
- case E_ITEM_FURNACE_MINECART:
- {
- return new cItemMinecartHandler(a_ItemType);
- }
-
- // Food:
- case E_ITEM_BREAD:
- case E_ITEM_COOKIE:
- case E_ITEM_MELON_SLICE:
- case E_ITEM_RAW_CHICKEN:
- case E_ITEM_COOKED_CHICKEN:
- case E_ITEM_RAW_BEEF:
- case E_ITEM_RAW_PORKCHOP:
- case E_ITEM_STEAK:
- case E_ITEM_COOKED_PORKCHOP:
- case E_ITEM_RAW_FISH:
- case E_ITEM_COOKED_FISH:
- case E_ITEM_RED_APPLE:
- case E_ITEM_GOLDEN_APPLE:
- case E_ITEM_ROTTEN_FLESH:
- case E_ITEM_SPIDER_EYE:
- {
- return new cItemFoodHandler(a_ItemType);
- }
- }
-}
-
-
-
-
-
-void cItemHandler::Deinit()
-{
- for(int i = 0; i < 2267; i++)
- {
- delete m_ItemHandler[i];
- }
- memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); // Don't leave any dangling pointers around, just in case
- m_HandlerInitialized = false;
-}
-
-
-
-
-
-cItemHandler::cItemHandler(int a_ItemType)
-{
- m_ItemType = a_ItemType;
-}
-
-
-
-
-
-bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
-{
- return false;
-}
-
-
-
-
-
-bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
-{
- return false;
-}
-
-
-
-
-
-void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- cBlockHandler * Handler = cBlockHandler::GetBlockHandler(Block);
-
- if (a_Player->GetGameMode() == gmSurvival)
- {
- if (!BlockRequiresSpecialTool(Block) || CanHarvestBlock(Block))
- {
- Handler->DropBlock(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ);
- }
- }
-
- a_Player->UseEquippedItem();
-}
-
-
-
-
-
-void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_Item)
-{
-
-}
-
-
-
-
-
-char cItemHandler::GetMaxStackSize(void)
-{
- if (m_ItemType < 256)
- {
- // All blocks can stack up to 64
- return 64;
- }
-
- switch (m_ItemType) //sorted by id
- {
- case E_ITEM_ARROW: return 64;
- case E_ITEM_BAKED_POTATO: return 64;
- case E_ITEM_BLAZE_POWDER: return 64;
- case E_ITEM_BLAZE_ROD: return 64;
- case E_ITEM_BONE: return 64;
- case E_ITEM_BOOK: return 64;
- case E_ITEM_BOTTLE_O_ENCHANTING: return 64;
- case E_ITEM_BOWL: return 64;
- case E_ITEM_BREAD: return 64;
- case E_ITEM_BREWING_STAND: return 64;
- case E_ITEM_BUCKET: return 1; // TODO: change this to 16 when turning compatibility to 1.3
- case E_ITEM_CARROT: return 64;
- case E_ITEM_CAULDRON: return 64;
- case E_ITEM_CLAY: return 64;
- case E_ITEM_CLAY_BRICK: return 64;
- case E_ITEM_CLOCK: return 64;
- case E_ITEM_COAL: return 64;
- case E_ITEM_COMPARATOR: return 64;
- case E_ITEM_COMPASS: return 64;
- case E_ITEM_COOKED_CHICKEN: return 64;
- case E_ITEM_COOKED_FISH: return 64;
- case E_ITEM_COOKED_PORKCHOP: return 64;
- case E_ITEM_COOKIE: return 64;
- case E_ITEM_DIAMOND: return 64;
- case E_ITEM_DYE: return 64;
- case E_ITEM_EGG: return 16;
- case E_ITEM_EMERALD: return 64;
- case E_ITEM_ENDER_PEARL: return 16;
- case E_ITEM_EYE_OF_ENDER: return 64;
- case E_ITEM_FEATHER: return 64;
- case E_ITEM_FERMENTED_SPIDER_EYE: return 64;
- case E_ITEM_FIRE_CHARGE: return 64;
- case E_ITEM_FIREWORK_ROCKET: return 64;
- case E_ITEM_FIREWORK_STAR: return 64;
- case E_ITEM_FLINT: return 64;
- case E_ITEM_FLOWER_POT: return 64;
- case E_ITEM_GHAST_TEAR: return 64;
- case E_ITEM_GLASS_BOTTLE: return 64;
- case E_ITEM_GLISTERING_MELON: return 64;
- case E_ITEM_GLOWSTONE_DUST: return 64;
- case E_ITEM_GOLD: return 64;
- case E_ITEM_GOLDEN_APPLE: return 64;
- case E_ITEM_GOLDEN_CARROT: return 64;
- case E_ITEM_GOLD_NUGGET: return 64;
- case E_ITEM_GUNPOWDER: return 64;
- case E_ITEM_HEAD: return 64;
- case E_ITEM_IRON: return 64;
- case E_ITEM_LEATHER: return 64;
- case E_ITEM_MAGMA_CREAM: return 64;
- case E_ITEM_MAP: return 64;
- case E_ITEM_MELON_SEEDS: return 64;
- case E_ITEM_MELON_SLICE: return 64;
- case E_ITEM_NETHER_BRICK: return 64;
- case E_ITEM_NETHER_WART: return 64;
- case E_ITEM_PAINTINGS: return 64;
- case E_ITEM_PAPER: return 64;
- case E_ITEM_POISONOUS_POTATO: return 64;
- case E_ITEM_POTATO: return 64;
- case E_ITEM_PUMPKIN_PIE: return 64;
- case E_ITEM_PUMPKIN_SEEDS: return 64;
- case E_ITEM_RAW_BEEF: return 64;
- case E_ITEM_RAW_CHICKEN: return 64;
- case E_ITEM_RAW_FISH: return 64;
- case E_ITEM_RAW_PORKCHOP: return 64;
- case E_ITEM_RED_APPLE: return 64;
- case E_ITEM_REDSTONE_DUST: return 64;
- case E_ITEM_REDSTONE_REPEATER: return 64;
- case E_ITEM_ROTTEN_FLESH: return 64;
- case E_ITEM_SEEDS: return 64;
- case E_ITEM_SIGN: return 16;
- case E_ITEM_SLIMEBALL: return 64;
- case E_ITEM_SNOWBALL: return 16;
- case E_ITEM_SPAWN_EGG: return 64;
- case E_ITEM_SPIDER_EYE: return 64;
- case E_ITEM_STEAK: return 64;
- case E_ITEM_STICK: return 64;
- case E_ITEM_STRING: return 64;
- case E_ITEM_SUGAR: return 64;
- case E_ITEM_SUGAR_CANE: return 64;
- case E_ITEM_WHEAT: return 64;
- }
- // By default items don't stack:
- return 1;
-}
-
-
-
-
-
-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 >= 256 && m_ItemType <= 259)
- || (m_ItemType == 325)
- || (m_ItemType == 346);
-}
-
-
-
-
-
-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::IsPlaceable(void)
-{
- // We can place any block that has a corresponding E_BLOCK_TYPE:
- return (m_ItemType >= 1) && (m_ItemType <= E_BLOCK_MAX_TYPE_ID);
-}
-
-
-
-
-
-bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
-{
- return false;
-}
-
-
-
-
-
-bool cItemHandler::GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
-)
-{
- ASSERT(m_ItemType < 256); // Items with IDs above 255 should all be handled by specific handlers
-
- if (m_ItemType > 256)
- {
- LOGERROR("%s: Item %d has no valid block!", __FUNCTION__, m_ItemType);
- return false;
- }
-
- cBlockHandler * BlockH = BlockHandler(m_ItemType);
- return BlockH->GetPlacementBlockTypeMeta(
- a_World, a_Player,
- a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
- a_CursorX, a_CursorY, a_CursorZ,
- a_BlockType, a_BlockMeta
- );
-}
-
-
-
-
-
-bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
-{
- FoodInfo Info = GetFoodInfo();
-
- if(Info.FoodLevel > 0 || Info.Saturation > 0.f)
- {
- bool Success = a_Player->Feed(Info.FoodLevel, Info.Saturation);
- if(Success && Info.PoisionChance > 0)
- {
- MTRand r1;
- if((r1.randInt(100) - Info.PoisionChance) <= 0)
- { //Unlucky guy :D
- //TODO: Make player ill
- }
- }
-
- return Success;
- }
-
- return false;
-}
-
-
-
-
-
-cItemHandler::FoodInfo cItemHandler::GetFoodInfo()
-{
- return FoodInfo(0, 0.f);
-}
-
-
-
-
+
+#include "Globals.h"
+#include "ItemHandler.h"
+#include "../Item.h"
+#include "../World.h"
+#include "../Player.h"
+#include "../FastRandom.h"
+
+// Handlers:
+#include "ItemBed.h"
+#include "ItemBrewingStand.h"
+#include "ItemBucket.h"
+#include "ItemCauldron.h"
+#include "ItemCloth.h"
+#include "ItemDoor.h"
+#include "ItemDye.h"
+#include "ItemFlowerPot.h"
+#include "ItemFood.h"
+#include "ItemHoe.h"
+#include "ItemLeaves.h"
+#include "ItemLighter.h"
+#include "ItemMinecart.h"
+#include "ItemPickaxe.h"
+#include "ItemRedstoneDust.h"
+#include "ItemRedstoneRepeater.h"
+#include "ItemSapling.h"
+#include "ItemSeeds.h"
+#include "ItemShears.h"
+#include "ItemShovel.h"
+#include "ItemSign.h"
+#include "ItemSlab.h"
+#include "ItemSpawnEgg.h"
+#include "ItemSugarcane.h"
+#include "ItemSword.h"
+#include "ItemWood.h"
+
+#include "../Blocks/BlockHandler.h"
+
+
+
+
+
+bool cItemHandler::m_HandlerInitialized = false;
+cItemHandler * cItemHandler::m_ItemHandler[2268];
+
+
+
+
+
+cItemHandler *cItemHandler::GetItemHandler(int a_ItemType)
+{
+ if(a_ItemType < 0) a_ItemType = 0;
+
+ if(!m_HandlerInitialized)
+ { //We have to initialize
+ memset(m_ItemHandler, 0, sizeof(m_ItemHandler));
+ m_HandlerInitialized = true;
+ }
+ if(m_ItemHandler[a_ItemType])
+ return m_ItemHandler[a_ItemType];
+ m_ItemHandler[a_ItemType] = CreateItemHandler(a_ItemType);
+ return m_ItemHandler[a_ItemType];
+}
+
+
+
+
+
+cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
+{
+ switch(a_ItemType)
+ {
+ default: return new cItemHandler(a_ItemType);
+
+ // Single item per handler, alphabetically sorted:
+ case E_BLOCK_LEAVES: return new cItemLeavesHandler(a_ItemType);
+ case E_BLOCK_SAPLING: return new cItemSaplingHandler(a_ItemType);
+ case E_BLOCK_WOOL: return new cItemClothHandler(a_ItemType);
+ case E_ITEM_BED: return new cItemBedHandler(a_ItemType);
+ case E_ITEM_BREWING_STAND: return new cItemBrewingStandHandler(a_ItemType);
+ case E_ITEM_CAULDRON: return new cItemCauldronHandler(a_ItemType);
+ case E_ITEM_DYE: return new cItemDyeHandler(a_ItemType);
+ case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemType);
+ case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType);
+ 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);
+ case E_ITEM_SIGN: return new cItemSignHandler(a_ItemType);
+ case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemType);
+ case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemType);
+
+ case E_ITEM_WOODEN_HOE:
+ case E_ITEM_STONE_HOE:
+ case E_ITEM_IRON_HOE:
+ case E_ITEM_GOLD_HOE:
+ case E_ITEM_DIAMOND_HOE:
+ {
+ return new cItemHoeHandler(a_ItemType);
+ }
+
+ case E_ITEM_WOODEN_PICKAXE:
+ case E_ITEM_STONE_PICKAXE:
+ case E_ITEM_IRON_PICKAXE:
+ case E_ITEM_GOLD_PICKAXE:
+ case E_ITEM_DIAMOND_PICKAXE:
+ {
+ return new cItemPickaxeHandler(a_ItemType);
+ }
+
+ case E_ITEM_WOODEN_SHOVEL:
+ case E_ITEM_STONE_SHOVEL:
+ case E_ITEM_IRON_SHOVEL:
+ case E_ITEM_GOLD_SHOVEL:
+ case E_ITEM_DIAMOND_SHOVEL:
+ {
+ return new cItemShovelHandler(a_ItemType);
+ }
+
+ case E_ITEM_WOODEN_SWORD:
+ case E_ITEM_STONE_SWORD:
+ case E_ITEM_IRON_SWORD:
+ case E_ITEM_GOLD_SWORD:
+ case E_ITEM_DIAMOND_SWORD:
+ {
+ return new cItemSwordHandler(a_ItemType);
+ }
+
+ case E_BLOCK_STONE_SLAB:
+ case E_BLOCK_WOODEN_SLAB:
+ {
+ return new cItemSlabHandler(a_ItemType);
+ }
+
+ case E_BLOCK_LOG:
+ case E_BLOCK_PLANKS:
+ {
+ return new cItemWoodHandler(a_ItemType);
+ }
+
+ case E_ITEM_BUCKET:
+ case E_ITEM_WATER_BUCKET:
+ case E_ITEM_LAVA_BUCKET:
+ {
+ return new cItemBucketHandler(a_ItemType);
+ }
+
+ case E_ITEM_CARROT:
+ case E_ITEM_MELON_SEEDS:
+ case E_ITEM_POTATO:
+ case E_ITEM_PUMPKIN_SEEDS:
+ case E_ITEM_SEEDS:
+ {
+ return new cItemSeedsHandler(a_ItemType);
+ }
+
+ case E_ITEM_IRON_DOOR:
+ case E_ITEM_WOODEN_DOOR:
+ {
+ return new cItemDoorHandler(a_ItemType);
+ }
+
+ case E_ITEM_MINECART:
+ case E_ITEM_CHEST_MINECART:
+ case E_ITEM_FURNACE_MINECART:
+ {
+ return new cItemMinecartHandler(a_ItemType);
+ }
+
+ // Food:
+ case E_ITEM_BREAD:
+ case E_ITEM_COOKIE:
+ case E_ITEM_MELON_SLICE:
+ case E_ITEM_RAW_CHICKEN:
+ case E_ITEM_COOKED_CHICKEN:
+ case E_ITEM_RAW_BEEF:
+ case E_ITEM_RAW_PORKCHOP:
+ case E_ITEM_STEAK:
+ case E_ITEM_COOKED_PORKCHOP:
+ case E_ITEM_RAW_FISH:
+ case E_ITEM_COOKED_FISH:
+ case E_ITEM_RED_APPLE:
+ case E_ITEM_GOLDEN_APPLE:
+ case E_ITEM_ROTTEN_FLESH:
+ case E_ITEM_SPIDER_EYE:
+ {
+ return new cItemFoodHandler(a_ItemType);
+ }
+ }
+}
+
+
+
+
+
+void cItemHandler::Deinit()
+{
+ for(int i = 0; i < 2267; i++)
+ {
+ delete m_ItemHandler[i];
+ }
+ memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); // Don't leave any dangling pointers around, just in case
+ m_HandlerInitialized = false;
+}
+
+
+
+
+
+cItemHandler::cItemHandler(int a_ItemType)
+{
+ m_ItemType = a_ItemType;
+}
+
+
+
+
+
+bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
+{
+ return false;
+}
+
+
+
+
+
+bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
+{
+ return false;
+}
+
+
+
+
+
+void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ cBlockHandler * Handler = cBlockHandler::GetBlockHandler(Block);
+
+ if (a_Player->GetGameMode() == gmSurvival)
+ {
+ if (!BlockRequiresSpecialTool(Block) || CanHarvestBlock(Block))
+ {
+ Handler->DropBlock(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ);
+ }
+ }
+
+ a_Player->UseEquippedItem();
+}
+
+
+
+
+
+void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_Item)
+{
+
+}
+
+
+
+
+
+char cItemHandler::GetMaxStackSize(void)
+{
+ if (m_ItemType < 256)
+ {
+ // All blocks can stack up to 64
+ return 64;
+ }
+
+ switch (m_ItemType) //sorted by id
+ {
+ case E_ITEM_ARROW: return 64;
+ case E_ITEM_BAKED_POTATO: return 64;
+ case E_ITEM_BLAZE_POWDER: return 64;
+ case E_ITEM_BLAZE_ROD: return 64;
+ case E_ITEM_BONE: return 64;
+ case E_ITEM_BOOK: return 64;
+ case E_ITEM_BOTTLE_O_ENCHANTING: return 64;
+ case E_ITEM_BOWL: return 64;
+ case E_ITEM_BREAD: return 64;
+ case E_ITEM_BREWING_STAND: return 64;
+ case E_ITEM_BUCKET: return 1; // TODO: change this to 16 when turning compatibility to 1.3
+ case E_ITEM_CARROT: return 64;
+ case E_ITEM_CAULDRON: return 64;
+ case E_ITEM_CLAY: return 64;
+ case E_ITEM_CLAY_BRICK: return 64;
+ case E_ITEM_CLOCK: return 64;
+ case E_ITEM_COAL: return 64;
+ case E_ITEM_COMPARATOR: return 64;
+ case E_ITEM_COMPASS: return 64;
+ case E_ITEM_COOKED_CHICKEN: return 64;
+ case E_ITEM_COOKED_FISH: return 64;
+ case E_ITEM_COOKED_PORKCHOP: return 64;
+ case E_ITEM_COOKIE: return 64;
+ case E_ITEM_DIAMOND: return 64;
+ case E_ITEM_DYE: return 64;
+ case E_ITEM_EGG: return 16;
+ case E_ITEM_EMERALD: return 64;
+ case E_ITEM_ENDER_PEARL: return 16;
+ case E_ITEM_EYE_OF_ENDER: return 64;
+ case E_ITEM_FEATHER: return 64;
+ case E_ITEM_FERMENTED_SPIDER_EYE: return 64;
+ case E_ITEM_FIRE_CHARGE: return 64;
+ case E_ITEM_FIREWORK_ROCKET: return 64;
+ case E_ITEM_FIREWORK_STAR: return 64;
+ case E_ITEM_FLINT: return 64;
+ case E_ITEM_FLOWER_POT: return 64;
+ case E_ITEM_GHAST_TEAR: return 64;
+ case E_ITEM_GLASS_BOTTLE: return 64;
+ case E_ITEM_GLISTERING_MELON: return 64;
+ case E_ITEM_GLOWSTONE_DUST: return 64;
+ case E_ITEM_GOLD: return 64;
+ case E_ITEM_GOLDEN_APPLE: return 64;
+ case E_ITEM_GOLDEN_CARROT: return 64;
+ case E_ITEM_GOLD_NUGGET: return 64;
+ case E_ITEM_GUNPOWDER: return 64;
+ case E_ITEM_HEAD: return 64;
+ case E_ITEM_IRON: return 64;
+ case E_ITEM_LEATHER: return 64;
+ case E_ITEM_MAGMA_CREAM: return 64;
+ case E_ITEM_MAP: return 64;
+ case E_ITEM_MELON_SEEDS: return 64;
+ case E_ITEM_MELON_SLICE: return 64;
+ case E_ITEM_NETHER_BRICK: return 64;
+ case E_ITEM_NETHER_WART: return 64;
+ case E_ITEM_PAINTINGS: return 64;
+ case E_ITEM_PAPER: return 64;
+ case E_ITEM_POISONOUS_POTATO: return 64;
+ case E_ITEM_POTATO: return 64;
+ case E_ITEM_PUMPKIN_PIE: return 64;
+ case E_ITEM_PUMPKIN_SEEDS: return 64;
+ case E_ITEM_RAW_BEEF: return 64;
+ case E_ITEM_RAW_CHICKEN: return 64;
+ case E_ITEM_RAW_FISH: return 64;
+ case E_ITEM_RAW_PORKCHOP: return 64;
+ case E_ITEM_RED_APPLE: return 64;
+ case E_ITEM_REDSTONE_DUST: return 64;
+ case E_ITEM_REDSTONE_REPEATER: return 64;
+ case E_ITEM_ROTTEN_FLESH: return 64;
+ case E_ITEM_SEEDS: return 64;
+ case E_ITEM_SIGN: return 16;
+ case E_ITEM_SLIMEBALL: return 64;
+ case E_ITEM_SNOWBALL: return 16;
+ case E_ITEM_SPAWN_EGG: return 64;
+ case E_ITEM_SPIDER_EYE: return 64;
+ case E_ITEM_STEAK: return 64;
+ case E_ITEM_STICK: return 64;
+ case E_ITEM_STRING: return 64;
+ case E_ITEM_SUGAR: return 64;
+ case E_ITEM_SUGAR_CANE: return 64;
+ case E_ITEM_WHEAT: return 64;
+ }
+ // By default items don't stack:
+ return 1;
+}
+
+
+
+
+
+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 >= 256 && m_ItemType <= 259)
+ || (m_ItemType == 325)
+ || (m_ItemType == 346);
+}
+
+
+
+
+
+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::IsPlaceable(void)
+{
+ // We can place any block that has a corresponding E_BLOCK_TYPE:
+ return (m_ItemType >= 1) && (m_ItemType <= E_BLOCK_MAX_TYPE_ID);
+}
+
+
+
+
+
+bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
+{
+ return false;
+}
+
+
+
+
+
+bool cItemHandler::GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+)
+{
+ ASSERT(m_ItemType < 256); // Items with IDs above 255 should all be handled by specific handlers
+
+ if (m_ItemType > 256)
+ {
+ LOGERROR("%s: Item %d has no valid block!", __FUNCTION__, m_ItemType);
+ return false;
+ }
+
+ cBlockHandler * BlockH = BlockHandler(m_ItemType);
+ return BlockH->GetPlacementBlockTypeMeta(
+ a_World, a_Player,
+ a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
+ a_CursorX, a_CursorY, a_CursorZ,
+ a_BlockType, a_BlockMeta
+ );
+}
+
+
+
+
+
+bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
+{
+ FoodInfo Info = GetFoodInfo();
+
+ if ((Info.FoodLevel > 0) || (Info.Saturation > 0.f))
+ {
+ bool Success = a_Player->Feed(Info.FoodLevel, Info.Saturation);
+
+ // If consumed and there's chance of foodpoisoning, do it:
+ if (Success && (Info.PoisonChance > 0))
+ {
+ cFastRandom r1;
+ if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0)
+ {
+ a_Player->FoodPoison(300);
+ }
+ }
+
+ return Success;
+ }
+
+ return false;
+}
+
+
+
+
+
+cItemHandler::FoodInfo cItemHandler::GetFoodInfo()
+{
+ return FoodInfo(0, 0.f);
+}
+
+
+
+
diff --git a/source/Items/ItemHandler.h b/source/Items/ItemHandler.h
index 0c141dea0..44d43e8f7 100644
--- a/source/Items/ItemHandler.h
+++ b/source/Items/ItemHandler.h
@@ -1,95 +1,96 @@
-
-#pragma once
-
-#include "../Defines.h"
-#include "../Item.h"
-
-
-
-
-
-// fwd:
-class cWorld;
-class cPlayer;
-
-
-
-
-
-class cItemHandler
-{
-public:
- cItemHandler(int a_ItemType);
-
- /// Called when the player tries to use the item. Return false to make the item unusable. DEFAULT: False
- virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); //eg for fishing or hoes
-
- /// Called while the player diggs a block using this item
- virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char 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);
-
- /// Called after the player has eaten this item.
- virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item);
-
- /// Returns the maximum stack size for a given item
- virtual char GetMaxStackSize(void);
-
- struct FoodInfo
- {
- FoodInfo(short a_FoodLevel, float a_Saturation, char a_PoisionChance = 0)
- {
- FoodLevel = a_FoodLevel;
- Saturation = a_Saturation;
- PoisionChance = a_PoisionChance;
- }
- short FoodLevel;
- float Saturation;
- char PoisionChance; //0 - 100
- };
-
- /// Returns the FoodInfo for this item. (FoodRecovery, Saturation and PoisionChance)
- virtual FoodInfo GetFoodInfo();
-
- /// Lets the player eat a selected item. Returns true if the player ate the item
- virtual bool EatItem(cPlayer *a_Player, cItem *a_Item);
-
- /// Indicates if this item is a tool
- virtual bool IsTool(void);
-
- /// Indicates if this item is food
- virtual bool IsFood(void);
-
- /// Blocks simply get placed
- virtual bool IsPlaceable(void);
-
- /** 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, char 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
- virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType);
-
- static cItemHandler * GetItemHandler(int a_ItemType);
- static cItemHandler * GetItemHandler(const cItem & a_Item) { return GetItemHandler(a_Item.m_ItemType); }
-
- static void Deinit();
-
-protected:
- int m_ItemType;
- static cItemHandler *CreateItemHandler(int m_ItemType);
-
- static cItemHandler *m_ItemHandler[2268];
- static bool m_HandlerInitialized; //used to detect if the itemhandlers are initialized
-};
-
-//Short function
-inline cItemHandler *ItemHandler(int a_ItemType) { return cItemHandler::GetItemHandler(a_ItemType); }
+
+#pragma once
+
+#include "../Defines.h"
+#include "../Item.h"
+
+
+
+
+
+// fwd:
+class cWorld;
+class cPlayer;
+
+
+
+
+
+class cItemHandler
+{
+public:
+ cItemHandler(int a_ItemType);
+
+ /// Called when the player tries to use the item. Return false to make the item unusable. DEFAULT: False
+ virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); //eg for fishing or hoes
+
+ /// Called while the player diggs a block using this item
+ virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char 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);
+
+ /// Called after the player has eaten this item.
+ virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item);
+
+ /// Returns the maximum stack size for a given item
+ virtual char GetMaxStackSize(void);
+
+ struct FoodInfo
+ {
+ int FoodLevel;
+ double Saturation;
+ 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) :
+ FoodLevel(a_FoodLevel),
+ Saturation(a_Saturation),
+ PoisonChance(a_PoisonChance)
+ {
+ }
+ } ;
+
+ /// Returns the FoodInfo for this item. (FoodRecovery, Saturation and PoisionChance)
+ virtual FoodInfo GetFoodInfo();
+
+ /// Lets the player eat a selected item. Returns true if the player ate the item
+ virtual bool EatItem(cPlayer *a_Player, cItem *a_Item);
+
+ /// Indicates if this item is a tool
+ virtual bool IsTool(void);
+
+ /// Indicates if this item is food
+ virtual bool IsFood(void);
+
+ /// Blocks simply get placed
+ virtual bool IsPlaceable(void);
+
+ /** 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, char 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
+ virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType);
+
+ static cItemHandler * GetItemHandler(int a_ItemType);
+ static cItemHandler * GetItemHandler(const cItem & a_Item) { return GetItemHandler(a_Item.m_ItemType); }
+
+ static void Deinit();
+
+protected:
+ int m_ItemType;
+ static cItemHandler *CreateItemHandler(int m_ItemType);
+
+ static cItemHandler *m_ItemHandler[2268];
+ static bool m_HandlerInitialized; //used to detect if the itemhandlers are initialized
+};
+
+//Short function
+inline cItemHandler *ItemHandler(int a_ItemType) { return cItemHandler::GetItemHandler(a_ItemType); }
diff --git a/source/Items/ItemHoe.h b/source/Items/ItemHoe.h
index 58f989341..577463f21 100644
--- a/source/Items/ItemHoe.h
+++ b/source/Items/ItemHoe.h
@@ -1,31 +1,31 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Player.h"
-
-class cItemHoeHandler : public cItemHandler
-{
-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, char a_Dir) override
- {
- BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
-
- 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;
- }
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Player.h"
+
+class cItemHoeHandler : public cItemHandler
+{
+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, char a_Dir) override
+ {
+ BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+
+ 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;
+ }
}; \ No newline at end of file
diff --git a/source/Items/ItemLeaves.h b/source/Items/ItemLeaves.h
index 14d63a630..60222eaa9 100644
--- a/source/Items/ItemLeaves.h
+++ b/source/Items/ItemLeaves.h
@@ -1,41 +1,41 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-
-
-
-class cItemLeavesHandler :
- public cItemHandler
-{
- typedef cItemHandler super;
-
-public:
- cItemLeavesHandler(int a_ItemType)
- : cItemHandler(a_ItemType)
- {
- }
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- bool res = super::GetPlacementBlockTypeMeta(
- a_World, a_Player,
- a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
- 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
- return res;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemLeavesHandler :
+ public cItemHandler
+{
+ typedef cItemHandler super;
+
+public:
+ cItemLeavesHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+ }
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ bool res = super::GetPlacementBlockTypeMeta(
+ a_World, a_Player,
+ a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
+ 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
+ return res;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemLighter.h b/source/Items/ItemLighter.h
index dcca08d47..cf7822832 100644
--- a/source/Items/ItemLighter.h
+++ b/source/Items/ItemLighter.h
@@ -1,56 +1,56 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Player.h"
-#include "../TNTEntity.h"
-
-
-
-
-
-class cItemLighterHandler :
- public cItemHandler
-{
-public:
- cItemLighterHandler(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, char a_BlockFace) override
- {
- if (a_BlockFace < 0)
- {
- return false;
- }
-
- a_Player->UseEquippedItem();
-
- switch (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ))
- {
- case E_BLOCK_TNT:
- {
- // Activate the TNT:
- a_World->BroadcastSoundEffect("random.fuse", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
- a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, 4); // 4 seconds to boom
- a_World->SetBlock(a_BlockX,a_BlockY,a_BlockZ, E_BLOCK_AIR, 0);
- break;
- }
- default:
- {
- // Light a fire next to the block:
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
- break;
- }
- }
-
- return false;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Player.h"
+#include "../TNTEntity.h"
+
+
+
+
+
+class cItemLighterHandler :
+ public cItemHandler
+{
+public:
+ cItemLighterHandler(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, char a_BlockFace) override
+ {
+ if (a_BlockFace < 0)
+ {
+ return false;
+ }
+
+ a_Player->UseEquippedItem();
+
+ switch (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ))
+ {
+ case E_BLOCK_TNT:
+ {
+ // Activate the TNT:
+ a_World->BroadcastSoundEffect("random.fuse", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
+ a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, 4); // 4 seconds to boom
+ a_World->SetBlock(a_BlockX,a_BlockY,a_BlockZ, E_BLOCK_AIR, 0);
+ break;
+ }
+ default:
+ {
+ // Light a fire next to the block:
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
+ break;
+ }
+ }
+
+ return false;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemMinecart.h b/source/Items/ItemMinecart.h
index ca8cc16aa..1470104a3 100644
--- a/source/Items/ItemMinecart.h
+++ b/source/Items/ItemMinecart.h
@@ -1,80 +1,80 @@
-
-// ItemMinecart.h
-
-// Declares the various minecart ItemHandlers
-
-
-
-
-
-#pragma once
-
-// Not needed, we're being included only from ItemHandler.cpp which already has this file: #include "ItemHandler.h"
-#include "../Minecart.h"
-
-
-
-
-
-class cItemMinecartHandler :
- public cItemHandler
-{
- typedef cItemHandler super;
-
-public:
- cItemMinecartHandler(int a_ItemType) :
- super(a_ItemType)
- {
- }
-
-
-
- virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
- {
- if (a_Dir < 0)
- {
- return false;
- }
-
- // Check that there's rail in there:
- BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- switch (Block)
- {
- case E_BLOCK_MINECART_TRACKS:
- case E_BLOCK_POWERED_RAIL:
- case E_BLOCK_DETECTOR_RAIL:
- {
- // These are allowed
- break;
- }
- default:
- {
- LOGD("Used minecart on an unsuitable block %d (%s)", Block, ItemTypeToString(Block).c_str());
- return false;
- }
- }
-
- double x = (double)a_BlockX + 0.5;
- double y = (double)a_BlockY + 0.5;
- double z = (double)a_BlockZ + 0.5;
- cMinecart * Minecart = NULL;
- switch (m_ItemType)
- {
- case E_ITEM_MINECART: Minecart = new cEmptyMinecart (x, y, z); break;
- case E_ITEM_CHEST_MINECART: Minecart = new cMinecartWithChest (x, y, z); break;
- case E_ITEM_FURNACE_MINECART: Minecart = new cMinecartWithFurnace(x, y, z); break;
- default:
- {
- ASSERT(!"Unhandled minecart item");
- return false;
- }
- } // switch (m_ItemType)
- Minecart->Initialize(a_World);
- return true;
- }
-
-} ;
-
-
-
-
+
+// ItemMinecart.h
+
+// Declares the various minecart ItemHandlers
+
+
+
+
+
+#pragma once
+
+// Not needed, we're being included only from ItemHandler.cpp which already has this file: #include "ItemHandler.h"
+#include "../Minecart.h"
+
+
+
+
+
+class cItemMinecartHandler :
+ public cItemHandler
+{
+ typedef cItemHandler super;
+
+public:
+ cItemMinecartHandler(int a_ItemType) :
+ super(a_ItemType)
+ {
+ }
+
+
+
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ {
+ if (a_Dir < 0)
+ {
+ return false;
+ }
+
+ // Check that there's rail in there:
+ BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ switch (Block)
+ {
+ case E_BLOCK_MINECART_TRACKS:
+ case E_BLOCK_POWERED_RAIL:
+ case E_BLOCK_DETECTOR_RAIL:
+ {
+ // These are allowed
+ break;
+ }
+ default:
+ {
+ LOGD("Used minecart on an unsuitable block %d (%s)", Block, ItemTypeToString(Block).c_str());
+ return false;
+ }
+ }
+
+ double x = (double)a_BlockX + 0.5;
+ double y = (double)a_BlockY + 0.5;
+ double z = (double)a_BlockZ + 0.5;
+ cMinecart * Minecart = NULL;
+ switch (m_ItemType)
+ {
+ case E_ITEM_MINECART: Minecart = new cEmptyMinecart (x, y, z); break;
+ case E_ITEM_CHEST_MINECART: Minecart = new cMinecartWithChest (x, y, z); break;
+ case E_ITEM_FURNACE_MINECART: Minecart = new cMinecartWithFurnace(x, y, z); break;
+ default:
+ {
+ ASSERT(!"Unhandled minecart item");
+ return false;
+ }
+ } // switch (m_ItemType)
+ Minecart->Initialize(a_World);
+ return true;
+ }
+
+} ;
+
+
+
+
diff --git a/source/Items/ItemPickaxe.h b/source/Items/ItemPickaxe.h
index 26d0d5ade..1a2c205c0 100644
--- a/source/Items/ItemPickaxe.h
+++ b/source/Items/ItemPickaxe.h
@@ -1,76 +1,76 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Player.h"
-
-class cItemPickaxeHandler : public cItemHandler
-{
-public:
- cItemPickaxeHandler(int a_ItemType)
- : cItemHandler(a_ItemType)
- {
-
- }
-
- char PickaxeLevel()
- {
- switch(m_ItemType)
- {
- case E_ITEM_WOODEN_PICKAXE:
- case E_ITEM_GOLD_PICKAXE:
- return 1;
- case E_ITEM_STONE_PICKAXE:
- return 2;
- case E_ITEM_IRON_PICKAXE:
- return 3;
- case E_ITEM_DIAMOND_PICKAXE:
- return 4;
- default:
- return 0;
- }
- }
-
- virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
- {
- switch(a_BlockType)
- {
- case E_BLOCK_OBSIDIAN:
- return PickaxeLevel() >= 4;
- 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:
- return PickaxeLevel() >= 3;
- case E_BLOCK_IRON_BLOCK:
- case E_BLOCK_IRON_ORE:
- case E_BLOCK_LAPIS_ORE:
- case E_BLOCK_LAPIS_BLOCK:
- return PickaxeLevel() >= 2;
- 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_STONE_BRICK_STAIRS:
- case E_BLOCK_NETHER_BRICK_STAIRS:
- case E_BLOCK_CAULDRON:
- return PickaxeLevel() >= 1;
- }
- return false;
- }
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Player.h"
+
+class cItemPickaxeHandler : public cItemHandler
+{
+public:
+ cItemPickaxeHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+
+ }
+
+ char PickaxeLevel()
+ {
+ switch(m_ItemType)
+ {
+ case E_ITEM_WOODEN_PICKAXE:
+ case E_ITEM_GOLD_PICKAXE:
+ return 1;
+ case E_ITEM_STONE_PICKAXE:
+ return 2;
+ case E_ITEM_IRON_PICKAXE:
+ return 3;
+ case E_ITEM_DIAMOND_PICKAXE:
+ return 4;
+ default:
+ return 0;
+ }
+ }
+
+ virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
+ {
+ switch(a_BlockType)
+ {
+ case E_BLOCK_OBSIDIAN:
+ return PickaxeLevel() >= 4;
+ 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:
+ return PickaxeLevel() >= 3;
+ case E_BLOCK_IRON_BLOCK:
+ case E_BLOCK_IRON_ORE:
+ case E_BLOCK_LAPIS_ORE:
+ case E_BLOCK_LAPIS_BLOCK:
+ return PickaxeLevel() >= 2;
+ 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_STONE_BRICK_STAIRS:
+ case E_BLOCK_NETHER_BRICK_STAIRS:
+ case E_BLOCK_CAULDRON:
+ return PickaxeLevel() >= 1;
+ }
+ return false;
+ }
}; \ No newline at end of file
diff --git a/source/Items/ItemRedstoneDust.h b/source/Items/ItemRedstoneDust.h
index 4179893d7..b7860b187 100644
--- a/source/Items/ItemRedstoneDust.h
+++ b/source/Items/ItemRedstoneDust.h
@@ -1,38 +1,38 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-
-
-
-class cItemRedstoneDustHandler : public cItemHandler
-{
-public:
- cItemRedstoneDustHandler(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, char a_BlockFace,
- int a_CursorX, int a_CursorY, int a_CursorZ,
- BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
- {
- a_BlockType = E_BLOCK_REDSTONE_WIRE;
- a_BlockMeta = 0;
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemRedstoneDustHandler : public cItemHandler
+{
+public:
+ cItemRedstoneDustHandler(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, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = E_BLOCK_REDSTONE_WIRE;
+ a_BlockMeta = 0;
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemRedstoneRepeater.h b/source/Items/ItemRedstoneRepeater.h
index ce3008d01..459070579 100644
--- a/source/Items/ItemRedstoneRepeater.h
+++ b/source/Items/ItemRedstoneRepeater.h
@@ -1,40 +1,40 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../Simulator/RedstoneSimulator.h"
-
-
-
-
-
-class cItemRedstoneRepeaterHandler :
- public cItemHandler
-{
-public:
- cItemRedstoneRepeaterHandler(int a_ItemType)
- : cItemHandler(a_ItemType)
- {
- }
-
- virtual bool IsPlaceable() override
- {
- return true;
- }
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- a_BlockType = E_BLOCK_REDSTONE_REPEATER_OFF;
- a_BlockMeta = cRedstoneSimulator::RepeaterRotationToMetaData(a_Player->GetRotation());
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../Simulator/RedstoneSimulator.h"
+
+
+
+
+
+class cItemRedstoneRepeaterHandler :
+ public cItemHandler
+{
+public:
+ cItemRedstoneRepeaterHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+ }
+
+ virtual bool IsPlaceable() override
+ {
+ return true;
+ }
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ a_BlockType = E_BLOCK_REDSTONE_REPEATER_OFF;
+ a_BlockMeta = cRedstoneSimulator::RepeaterRotationToMetaData(a_Player->GetRotation());
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemSapling.h b/source/Items/ItemSapling.h
index 313968ea5..dc0810a45 100644
--- a/source/Items/ItemSapling.h
+++ b/source/Items/ItemSapling.h
@@ -1,42 +1,42 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-
-
-
-class cItemSaplingHandler : public cItemHandler
-{
- typedef cItemHandler super;
-
-public:
- cItemSaplingHandler(int a_ItemType)
- : cItemHandler(a_ItemType)
- {
-
- }
-
- virtual bool GetPlacementBlockTypeMeta(
- cWorld * a_World, 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
- ) override
- {
- bool res = super::GetPlacementBlockTypeMeta(
- a_World, a_Player,
- a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
- a_CursorX, a_CursorY, a_CursorZ,
- a_BlockType, a_BlockMeta
- );
- // Only the lowest 3 bits are important
- a_BlockMeta = a_BlockMeta & 0x7;
- return res;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemSaplingHandler : public cItemHandler
+{
+ typedef cItemHandler super;
+
+public:
+ cItemSaplingHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+
+ }
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, 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
+ ) override
+ {
+ bool res = super::GetPlacementBlockTypeMeta(
+ a_World, a_Player,
+ a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
+ a_CursorX, a_CursorY, a_CursorZ,
+ a_BlockType, a_BlockMeta
+ );
+ // Only the lowest 3 bits are important
+ a_BlockMeta = a_BlockMeta & 0x7;
+ return res;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemSeeds.h b/source/Items/ItemSeeds.h
index 7a5f77b80..8ca86663f 100644
--- a/source/Items/ItemSeeds.h
+++ b/source/Items/ItemSeeds.h
@@ -1,65 +1,65 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cItemSeedsHandler :
- public cItemHandler
-{
-public:
- cItemSeedsHandler(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, char a_BlockFace,
- int a_CursorX, int a_CursorY, int a_CursorZ,
- BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
- {
- if (a_BlockFace != BLOCK_FACE_TOP)
- {
- // Only allow planting seeds from the top side of the block
- return false;
- }
-
- // Only allow placement on farmland
- int X = a_BlockX;
- int Y = a_BlockY;
- int Z = a_BlockZ;
- AddFaceDirection(X, Y, Z, a_BlockFace, true);
- if (a_World->GetBlock(X, Y, Z) != E_BLOCK_FARMLAND)
- {
- return false;
- }
-
- a_BlockMeta = 0;
- switch (m_ItemType)
- {
- case E_ITEM_CARROT: a_BlockType = E_BLOCK_CARROTS; return true;
- case E_ITEM_MELON_SEEDS: a_BlockType = E_BLOCK_MELON_STEM; return true;
- case E_ITEM_POTATO: a_BlockType = E_BLOCK_POTATOES; return true;
- case E_ITEM_PUMPKIN_SEEDS: a_BlockType = E_BLOCK_PUMPKIN_STEM; return true;
- case E_ITEM_SEEDS: a_BlockType = E_BLOCK_CROPS; return true;
- default: a_BlockType = E_BLOCK_AIR; return true;
- }
- return false;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cItemSeedsHandler :
+ public cItemHandler
+{
+public:
+ cItemSeedsHandler(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, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ if (a_BlockFace != BLOCK_FACE_TOP)
+ {
+ // Only allow planting seeds from the top side of the block
+ return false;
+ }
+
+ // Only allow placement on farmland
+ int X = a_BlockX;
+ int Y = a_BlockY;
+ int Z = a_BlockZ;
+ AddFaceDirection(X, Y, Z, a_BlockFace, true);
+ if (a_World->GetBlock(X, Y, Z) != E_BLOCK_FARMLAND)
+ {
+ return false;
+ }
+
+ a_BlockMeta = 0;
+ switch (m_ItemType)
+ {
+ case E_ITEM_CARROT: a_BlockType = E_BLOCK_CARROTS; return true;
+ case E_ITEM_MELON_SEEDS: a_BlockType = E_BLOCK_MELON_STEM; return true;
+ case E_ITEM_POTATO: a_BlockType = E_BLOCK_POTATOES; return true;
+ case E_ITEM_PUMPKIN_SEEDS: a_BlockType = E_BLOCK_PUMPKIN_STEM; return true;
+ case E_ITEM_SEEDS: a_BlockType = E_BLOCK_CROPS; return true;
+ default: a_BlockType = E_BLOCK_AIR; return true;
+ }
+ return false;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemShears.h b/source/Items/ItemShears.h
index 5c1c248f4..a904dd1ae 100644
--- a/source/Items/ItemShears.h
+++ b/source/Items/ItemShears.h
@@ -1,63 +1,63 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Player.h"
-
-
-
-
-
-class cItemShearsHandler :
- public cItemHandler
-{
-public:
- cItemShearsHandler(int a_ItemType) :
- cItemHandler(a_ItemType)
- {
- }
-
-
- virtual bool IsTool(void) override
- {
- return true;
- }
-
-
- virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
- {
- BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- if (Block == E_BLOCK_LEAVES)
- {
- cItems Drops;
- Drops.push_back(cItem(E_BLOCK_LEAVES, 1, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x03));
- a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
-
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- a_Player->UseEquippedItem();
- return true;
- }
- // TODO: cobweb, vines
- return false;
- }
-
-
- virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
- {
- switch (a_BlockType)
- {
- case E_BLOCK_COBWEB:
- case E_BLOCK_VINES:
- case E_BLOCK_LEAVES:
- {
- return true;
- }
- } // switch (a_BlockType)
- return false;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Player.h"
+
+
+
+
+
+class cItemShearsHandler :
+ public cItemHandler
+{
+public:
+ cItemShearsHandler(int a_ItemType) :
+ cItemHandler(a_ItemType)
+ {
+ }
+
+
+ virtual bool IsTool(void) override
+ {
+ return true;
+ }
+
+
+ virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ {
+ BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ if (Block == E_BLOCK_LEAVES)
+ {
+ cItems Drops;
+ Drops.push_back(cItem(E_BLOCK_LEAVES, 1, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x03));
+ a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
+
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ a_Player->UseEquippedItem();
+ return true;
+ }
+ // TODO: cobweb, vines
+ return false;
+ }
+
+
+ virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
+ {
+ switch (a_BlockType)
+ {
+ case E_BLOCK_COBWEB:
+ case E_BLOCK_VINES:
+ case E_BLOCK_LEAVES:
+ {
+ return true;
+ }
+ } // switch (a_BlockType)
+ return false;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemShovel.h b/source/Items/ItemShovel.h
index f26e393c8..a26e7d34e 100644
--- a/source/Items/ItemShovel.h
+++ b/source/Items/ItemShovel.h
@@ -1,41 +1,41 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Player.h"
-
-#include "../Blocks/BlockHandler.h"
-
-
-
-
-
-class cItemShovelHandler : public cItemHandler
-{
-public:
- cItemShovelHandler(int a_ItemType)
- : cItemHandler(a_ItemType)
- {
-
- }
-
- virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
- {
- BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- if (Block == E_BLOCK_SNOW)
- {
- BlockHandler(Block)->DropBlock(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ);
-
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- a_Player->UseEquippedItem();
- return true;
- }
- return false;
- }
-
- virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
- {
- return (a_BlockType == E_BLOCK_SNOW);
- }
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Player.h"
+
+#include "../Blocks/BlockHandler.h"
+
+
+
+
+
+class cItemShovelHandler : public cItemHandler
+{
+public:
+ cItemShovelHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+
+ }
+
+ virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ {
+ BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ if (Block == E_BLOCK_SNOW)
+ {
+ BlockHandler(Block)->DropBlock(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ);
+
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ a_Player->UseEquippedItem();
+ return true;
+ }
+ return false;
+ }
+
+ virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
+ {
+ return (a_BlockType == E_BLOCK_SNOW);
+ }
}; \ No newline at end of file
diff --git a/source/Items/ItemSign.h b/source/Items/ItemSign.h
index 7a0924147..5ccd79e29 100644
--- a/source/Items/ItemSign.h
+++ b/source/Items/ItemSign.h
@@ -1,51 +1,51 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Blocks/BlockSign.h"
-
-
-
-
-
-class cItemSignHandler :
- public cItemHandler
-{
-public:
- cItemSignHandler(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, char 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->GetRotation());
- a_BlockType = E_BLOCK_SIGN_POST;
- }
- else
- {
- a_BlockMeta = cBlockSignHandler::DirectionToMetaData(a_BlockFace);
- a_BlockType = E_BLOCK_WALLSIGN;
- }
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Blocks/BlockSign.h"
+
+
+
+
+
+class cItemSignHandler :
+ public cItemHandler
+{
+public:
+ cItemSignHandler(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, char 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->GetRotation());
+ a_BlockType = E_BLOCK_SIGN_POST;
+ }
+ else
+ {
+ a_BlockMeta = cBlockSignHandler::DirectionToMetaData(a_BlockFace);
+ a_BlockType = E_BLOCK_WALLSIGN;
+ }
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemSlab.h b/source/Items/ItemSlab.h
index 9b3aaed03..80de05eb5 100644
--- a/source/Items/ItemSlab.h
+++ b/source/Items/ItemSlab.h
@@ -1,52 +1,52 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-
-
-
-
-
-class cItemSlabHandler : public cItemHandler
-{
-public:
- cItemSlabHandler(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, char a_Dir) override
- {
- BLOCKTYPE Block;
- NIBBLETYPE Meta;
- a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, Meta);
-
- if (
- ((a_Dir == 0) || (a_Dir == 1)) // Only when clicking on top or on bottom of the block
- && ((Block == E_BLOCK_WOODEN_SLAB) || (Block == E_BLOCK_STONE_SLAB)) // It is a slab
- && (Block == a_Item.m_ItemType) // Same slab
- && ((Meta & 0x7) == (a_Item.m_ItemDamage & 0x7))) // Same Texture
- {
- if (a_Player->GetGameMode() == eGameMode_Creative)
- {
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, Block - 1, Meta); // Block - 1 simple hack to save one if statement
- return true;
- }
- else
- {
- if (a_Player->GetInventory().RemoveOneEquippedItem())
- {
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, Block - 1, Meta); // Block - 1 simple hack to save one if statement
- return true;
- }
- }
- }
- return false;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cItemSlabHandler : public cItemHandler
+{
+public:
+ cItemSlabHandler(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, char a_Dir) override
+ {
+ BLOCKTYPE Block;
+ NIBBLETYPE Meta;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, Meta);
+
+ if (
+ ((a_Dir == 0) || (a_Dir == 1)) // Only when clicking on top or on bottom of the block
+ && ((Block == E_BLOCK_WOODEN_SLAB) || (Block == E_BLOCK_STONE_SLAB)) // It is a slab
+ && (Block == a_Item.m_ItemType) // Same slab
+ && ((Meta & 0x7) == (a_Item.m_ItemDamage & 0x7))) // Same Texture
+ {
+ if (a_Player->GetGameMode() == eGameMode_Creative)
+ {
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, Block - 1, Meta); // Block - 1 simple hack to save one if statement
+ return true;
+ }
+ else
+ {
+ if (a_Player->GetInventory().RemoveOneEquippedItem())
+ {
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, Block - 1, Meta); // Block - 1 simple hack to save one if statement
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemSpawnEgg.h b/source/Items/ItemSpawnEgg.h
index 7f5b253ef..e563d7e15 100644
--- a/source/Items/ItemSpawnEgg.h
+++ b/source/Items/ItemSpawnEgg.h
@@ -1,52 +1,52 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Player.h"
-
-
-
-
-
-class cItemSpawnEggHandler : public cItemHandler
-{
-public:
- cItemSpawnEggHandler(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, char a_BlockFace) override
- {
- if (a_BlockFace < 0)
- {
- return false;
- }
-
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
-
- if (a_BlockFace == BLOCK_FACE_BOTTOM)
- {
- a_BlockY--;
- }
-
- if (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, a_Item.m_ItemDamage) >= 0)
- {
- if (a_Player->GetGameMode() != 1)
- {
- // The mob was spawned, "use" the item:
- a_Player->GetInventory().RemoveOneEquippedItem();
- }
- return true;
- }
-
- return false;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Player.h"
+
+
+
+
+
+class cItemSpawnEggHandler : public cItemHandler
+{
+public:
+ cItemSpawnEggHandler(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, char a_BlockFace) override
+ {
+ if (a_BlockFace < 0)
+ {
+ return false;
+ }
+
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+
+ if (a_BlockFace == BLOCK_FACE_BOTTOM)
+ {
+ a_BlockY--;
+ }
+
+ if (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, a_Item.m_ItemDamage) >= 0)
+ {
+ if (a_Player->GetGameMode() != 1)
+ {
+ // The mob was spawned, "use" the item:
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ }
+ return true;
+ }
+
+ return false;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemSugarcane.h b/source/Items/ItemSugarcane.h
index 9a0875939..ce93aa3e5 100644
--- a/source/Items/ItemSugarcane.h
+++ b/source/Items/ItemSugarcane.h
@@ -1,39 +1,39 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-
-
-
-class cItemSugarcaneHandler :
- public cItemHandler
-{
-public:
- cItemSugarcaneHandler(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, char a_BlockFace,
- int a_CursorX, int a_CursorY, int a_CursorZ,
- BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
- {
- a_BlockType = E_BLOCK_SUGARCANE;
- a_BlockMeta = 0;
- return true;
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemSugarcaneHandler :
+ public cItemHandler
+{
+public:
+ cItemSugarcaneHandler(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, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = E_BLOCK_SUGARCANE;
+ a_BlockMeta = 0;
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Items/ItemSword.h b/source/Items/ItemSword.h
index 37b9ef32d..15351b55c 100644
--- a/source/Items/ItemSword.h
+++ b/source/Items/ItemSword.h
@@ -1,21 +1,21 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-#include "../World.h"
-#include "../Player.h"
-
-class cItemSwordHandler : public cItemHandler
-{
-public:
- cItemSwordHandler(int a_ItemType)
- : cItemHandler(a_ItemType)
- {
-
- }
-
- virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
- {
- return (a_BlockType == E_BLOCK_COBWEB);
- }
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+#include "../Player.h"
+
+class cItemSwordHandler : public cItemHandler
+{
+public:
+ cItemSwordHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+
+ }
+
+ virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
+ {
+ return (a_BlockType == E_BLOCK_COBWEB);
+ }
}; \ No newline at end of file
diff --git a/source/Items/ItemWood.h b/source/Items/ItemWood.h
index 5304ec316..476256c5d 100644
--- a/source/Items/ItemWood.h
+++ b/source/Items/ItemWood.h
@@ -1,22 +1,22 @@
-
-#pragma once
-
-#include "ItemHandler.h"
-
-
-
-
-
-class cItemWoodHandler :
- public cItemHandler
-{
-public:
- cItemWoodHandler(int a_ItemType)
- : cItemHandler(a_ItemType)
- {
- }
-} ;
-
-
-
-
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemWoodHandler :
+ public cItemHandler
+{
+public:
+ cItemWoodHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+ }
+} ;
+
+
+
+
diff --git a/source/LinearInterpolation.cpp b/source/LinearInterpolation.cpp
index d4536662e..d4975418b 100644
--- a/source/LinearInterpolation.cpp
+++ b/source/LinearInterpolation.cpp
@@ -1,251 +1,251 @@
-
-// LinearInterpolation.cpp
-
-// Implements methods for linear interpolation over 1D, 2D and 3D arrays
-
-#include "Globals.h"
-#include "LinearInterpolation.h"
-
-
-
-
-
-/*
-// Perform an automatic test upon program start (use breakpoints to debug):
-
-extern void Debug3DNoise(float * a_Noise, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase);
-
-class Test
-{
-public:
- Test(void)
- {
- // DoTest1();
- DoTest2();
- }
-
-
- void DoTest1(void)
- {
- float In[8] = {0, 1, 2, 3, 1, 2, 2, 2};
- float Out[3 * 3 * 3];
- LinearInterpolate1DArray(In, 4, Out, 9);
- LinearInterpolate2DArray(In, 2, 2, Out, 3, 3);
- LinearInterpolate3DArray(In, 2, 2, 2, Out, 3, 3, 3);
- LOGD("Out[0]: %f", Out[0]);
- }
-
-
- void DoTest2(void)
- {
- float In[3 * 3 * 3];
- for (int i = 0; i < ARRAYCOUNT(In); i++)
- {
- In[i] = (float)(i % 5);
- }
- float Out[15 * 16 * 17];
- LinearInterpolate3DArray(In, 3, 3, 3, Out, 15, 16, 17);
- Debug3DNoise(Out, 15, 16, 17, "LERP test");
- }
-} gTest;
-//*/
-
-
-
-
-
-// Puts linearly interpolated values from one array into another array. 1D version
-void LinearInterpolate1DArray(
- float * a_Src,
- int a_SrcSizeX,
- float * a_Dst,
- int a_DstSizeX
-)
-{
- a_Dst[0] = a_Src[0];
- int DstSizeXm1 = a_DstSizeX - 1;
- int SrcSizeXm1 = a_SrcSizeX - 1;
- float fDstSizeXm1 = (float)DstSizeXm1;
- float fSrcSizeXm1 = (float)SrcSizeXm1;
- for (int x = 1; x < DstSizeXm1; x++)
- {
- int SrcIdx = x * SrcSizeXm1 / DstSizeXm1;
- float ValLo = a_Src[SrcIdx];
- float ValHi = a_Src[SrcIdx + 1];
- float Ratio = (float)x * fSrcSizeXm1 / fDstSizeXm1 - SrcIdx;
- a_Dst[x] = ValLo + (ValHi - ValLo) * Ratio;
- }
- a_Dst[a_DstSizeX - 1] = a_Src[a_SrcSizeX - 1];
-}
-
-
-
-
-
-// Puts linearly interpolated values from one array into another array. 2D version
-void LinearInterpolate2DArray(
- float * a_Src,
- int a_SrcSizeX, int a_SrcSizeY,
- float * a_Dst,
- int a_DstSizeX, int a_DstSizeY
-)
-{
- ASSERT(a_DstSizeX > 0);
- ASSERT(a_DstSizeX < MAX_INTERPOL_SIZEX);
- ASSERT(a_DstSizeY > 0);
- ASSERT(a_DstSizeY < MAX_INTERPOL_SIZEY);
-
- // Calculate interpolation ratios and src indices along each axis:
- float RatioX[MAX_INTERPOL_SIZEX];
- float RatioY[MAX_INTERPOL_SIZEY];
- int SrcIdxX[MAX_INTERPOL_SIZEX];
- int SrcIdxY[MAX_INTERPOL_SIZEY];
- for (int x = 1; x < a_DstSizeX; x++)
- {
- SrcIdxX[x] = x * (a_SrcSizeX - 1) / (a_DstSizeX - 1);
- RatioX[x] = ((float)(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
- }
- for (int y = 1; y < a_DstSizeY; y++)
- {
- SrcIdxY[y] = y * (a_SrcSizeY - 1) / (a_DstSizeY - 1);
- RatioY[y] = ((float)(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
- }
-
- // Special values at the ends. Notice especially the last indices being (size - 2) with ratio set to 1, to avoid index overflow:
- SrcIdxX[0] = 0;
- RatioX[0] = 0;
- SrcIdxY[0] = 0;
- RatioY[0] = 0;
- SrcIdxX[a_DstSizeX - 1] = a_SrcSizeX - 2;
- RatioX[a_DstSizeX - 1] = 1;
- SrcIdxY[a_DstSizeY - 1] = a_SrcSizeY - 2;
- RatioY[a_DstSizeY - 1] = 1;
-
- // Output all the dst array values using the indices and ratios:
- int idx = 0;
- for (int y = 0; y < a_DstSizeY; y++)
- {
- int idxLoY = a_SrcSizeX * SrcIdxY[y];
- int idxHiY = a_SrcSizeX * (SrcIdxY[y] + 1);
- float ry = RatioY[y];
- for (int x = 0; x < a_DstSizeX; x++)
- {
- // The four src corners of the current "cell":
- float LoXLoY = a_Src[SrcIdxX[x] + idxLoY];
- float HiXLoY = a_Src[SrcIdxX[x] + 1 + idxLoY];
- float LoXHiY = a_Src[SrcIdxX[x] + idxHiY];
- float HiXHiY = a_Src[SrcIdxX[x] + 1 + idxHiY];
-
- // Linear interpolation along the X axis:
- float InterpXLoY = LoXLoY + (HiXLoY - LoXLoY) * RatioX[x];
- float InterpXHiY = LoXHiY + (HiXHiY - LoXHiY) * RatioX[x];
-
- // Linear interpolation along the Y axis:
- a_Dst[idx] = InterpXLoY + (InterpXHiY - InterpXLoY) * ry;
- idx += 1;
- }
- }
-}
-
-
-
-
-
-/// Puts linearly interpolated values from one array into another array. 3D version
-void LinearInterpolate3DArray(
- float * a_Src,
- int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ,
- float * a_Dst,
- int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ
-)
-{
- ASSERT(a_DstSizeX > 0);
- ASSERT(a_DstSizeX < MAX_INTERPOL_SIZEX);
- ASSERT(a_DstSizeY > 0);
- ASSERT(a_DstSizeY < MAX_INTERPOL_SIZEY);
- ASSERT(a_DstSizeZ > 0);
- ASSERT(a_DstSizeZ < MAX_INTERPOL_SIZEZ);
-
- // Calculate interpolation ratios and src indices along each axis:
- float RatioX[MAX_INTERPOL_SIZEX];
- float RatioY[MAX_INTERPOL_SIZEY];
- float RatioZ[MAX_INTERPOL_SIZEZ];
- int SrcIdxX[MAX_INTERPOL_SIZEX];
- int SrcIdxY[MAX_INTERPOL_SIZEY];
- int SrcIdxZ[MAX_INTERPOL_SIZEZ];
- for (int x = 1; x < a_DstSizeX; x++)
- {
- SrcIdxX[x] = x * (a_SrcSizeX - 1) / (a_DstSizeX - 1);
- RatioX[x] = ((float)(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
- }
- for (int y = 1; y < a_DstSizeY; y++)
- {
- SrcIdxY[y] = y * (a_SrcSizeY - 1) / (a_DstSizeY - 1);
- RatioY[y] = ((float)(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
- }
- for (int z = 1; z < a_DstSizeZ; z++)
- {
- SrcIdxZ[z] = z * (a_SrcSizeZ - 1) / (a_DstSizeZ - 1);
- RatioZ[z] = ((float)(z * (a_SrcSizeZ - 1)) / (a_DstSizeZ - 1)) - SrcIdxZ[z];
- }
-
- // Special values at the ends. Notice especially the last indices being (size - 2) with ratio set to 1, to avoid index overflow:
- SrcIdxX[0] = 0;
- RatioX[0] = 0;
- SrcIdxY[0] = 0;
- RatioY[0] = 0;
- SrcIdxZ[0] = 0;
- RatioZ[0] = 0;
- SrcIdxX[a_DstSizeX - 1] = a_SrcSizeX - 2;
- RatioX[a_DstSizeX - 1] = 1;
- SrcIdxY[a_DstSizeY - 1] = a_SrcSizeY - 2;
- RatioY[a_DstSizeY - 1] = 1;
- SrcIdxZ[a_DstSizeZ - 1] = a_SrcSizeZ - 2;
- RatioZ[a_DstSizeZ - 1] = 1;
-
- // Output all the dst array values using the indices and ratios:
- int idx = 0;
- for (int z = 0; z < a_DstSizeZ; z++)
- {
- int idxLoZ = a_SrcSizeX * a_SrcSizeY * SrcIdxZ[z];
- int idxHiZ = a_SrcSizeX * a_SrcSizeY * (SrcIdxZ[z] + 1);
- float rz = RatioZ[z];
- for (int y = 0; y < a_DstSizeY; y++)
- {
- int idxLoY = a_SrcSizeX * SrcIdxY[y];
- int idxHiY = a_SrcSizeX * (SrcIdxY[y] + 1);
- float ry = RatioY[y];
- for (int x = 0; x < a_DstSizeX; x++)
- {
- // The eight src corners of the current "cell":
- float LoXLoYLoZ = a_Src[SrcIdxX[x] + idxLoY + idxLoZ];
- float HiXLoYLoZ = a_Src[SrcIdxX[x] + 1 + idxLoY + idxLoZ];
- float LoXHiYLoZ = a_Src[SrcIdxX[x] + idxHiY + idxLoZ];
- float HiXHiYLoZ = a_Src[SrcIdxX[x] + 1 + idxHiY + idxLoZ];
- float LoXLoYHiZ = a_Src[SrcIdxX[x] + idxLoY + idxHiZ];
- float HiXLoYHiZ = a_Src[SrcIdxX[x] + 1 + idxLoY + idxHiZ];
- float LoXHiYHiZ = a_Src[SrcIdxX[x] + idxHiY + idxHiZ];
- float HiXHiYHiZ = a_Src[SrcIdxX[x] + 1 + idxHiY + idxHiZ];
-
- // Linear interpolation along the Z axis:
- float LoXLoYInZ = LoXLoYLoZ + (LoXLoYHiZ - LoXLoYLoZ) * rz;
- float HiXLoYInZ = HiXLoYLoZ + (HiXLoYHiZ - HiXLoYLoZ) * rz;
- float LoXHiYInZ = LoXHiYLoZ + (LoXHiYHiZ - LoXHiYLoZ) * rz;
- float HiXHiYInZ = HiXHiYLoZ + (HiXHiYHiZ - HiXHiYLoZ) * rz;
-
- // Linear interpolation along the Y axis:
- float LoXInYInZ = LoXLoYInZ + (LoXHiYInZ - LoXLoYInZ) * ry;
- float HiXInYInZ = HiXLoYInZ + (HiXHiYInZ - HiXLoYInZ) * ry;
-
- // Linear interpolation along the X axis:
- a_Dst[idx] = LoXInYInZ + (HiXInYInZ - LoXInYInZ) * RatioX[x];
- idx += 1;
- } // for x
- } // for y
- } // for z
-}
-
-
-
-
-
+
+// LinearInterpolation.cpp
+
+// Implements methods for linear interpolation over 1D, 2D and 3D arrays
+
+#include "Globals.h"
+#include "LinearInterpolation.h"
+
+
+
+
+
+/*
+// Perform an automatic test upon program start (use breakpoints to debug):
+
+extern void Debug3DNoise(float * a_Noise, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase);
+
+class Test
+{
+public:
+ Test(void)
+ {
+ // DoTest1();
+ DoTest2();
+ }
+
+
+ void DoTest1(void)
+ {
+ float In[8] = {0, 1, 2, 3, 1, 2, 2, 2};
+ float Out[3 * 3 * 3];
+ LinearInterpolate1DArray(In, 4, Out, 9);
+ LinearInterpolate2DArray(In, 2, 2, Out, 3, 3);
+ LinearInterpolate3DArray(In, 2, 2, 2, Out, 3, 3, 3);
+ LOGD("Out[0]: %f", Out[0]);
+ }
+
+
+ void DoTest2(void)
+ {
+ float In[3 * 3 * 3];
+ for (int i = 0; i < ARRAYCOUNT(In); i++)
+ {
+ In[i] = (float)(i % 5);
+ }
+ float Out[15 * 16 * 17];
+ LinearInterpolate3DArray(In, 3, 3, 3, Out, 15, 16, 17);
+ Debug3DNoise(Out, 15, 16, 17, "LERP test");
+ }
+} gTest;
+//*/
+
+
+
+
+
+// Puts linearly interpolated values from one array into another array. 1D version
+void LinearInterpolate1DArray(
+ float * a_Src,
+ int a_SrcSizeX,
+ float * a_Dst,
+ int a_DstSizeX
+)
+{
+ a_Dst[0] = a_Src[0];
+ int DstSizeXm1 = a_DstSizeX - 1;
+ int SrcSizeXm1 = a_SrcSizeX - 1;
+ float fDstSizeXm1 = (float)DstSizeXm1;
+ float fSrcSizeXm1 = (float)SrcSizeXm1;
+ for (int x = 1; x < DstSizeXm1; x++)
+ {
+ int SrcIdx = x * SrcSizeXm1 / DstSizeXm1;
+ float ValLo = a_Src[SrcIdx];
+ float ValHi = a_Src[SrcIdx + 1];
+ float Ratio = (float)x * fSrcSizeXm1 / fDstSizeXm1 - SrcIdx;
+ a_Dst[x] = ValLo + (ValHi - ValLo) * Ratio;
+ }
+ a_Dst[a_DstSizeX - 1] = a_Src[a_SrcSizeX - 1];
+}
+
+
+
+
+
+// Puts linearly interpolated values from one array into another array. 2D version
+void LinearInterpolate2DArray(
+ float * a_Src,
+ int a_SrcSizeX, int a_SrcSizeY,
+ float * a_Dst,
+ int a_DstSizeX, int a_DstSizeY
+)
+{
+ ASSERT(a_DstSizeX > 0);
+ ASSERT(a_DstSizeX < MAX_INTERPOL_SIZEX);
+ ASSERT(a_DstSizeY > 0);
+ ASSERT(a_DstSizeY < MAX_INTERPOL_SIZEY);
+
+ // Calculate interpolation ratios and src indices along each axis:
+ float RatioX[MAX_INTERPOL_SIZEX];
+ float RatioY[MAX_INTERPOL_SIZEY];
+ int SrcIdxX[MAX_INTERPOL_SIZEX];
+ int SrcIdxY[MAX_INTERPOL_SIZEY];
+ for (int x = 1; x < a_DstSizeX; x++)
+ {
+ SrcIdxX[x] = x * (a_SrcSizeX - 1) / (a_DstSizeX - 1);
+ RatioX[x] = ((float)(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
+ }
+ for (int y = 1; y < a_DstSizeY; y++)
+ {
+ SrcIdxY[y] = y * (a_SrcSizeY - 1) / (a_DstSizeY - 1);
+ RatioY[y] = ((float)(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
+ }
+
+ // Special values at the ends. Notice especially the last indices being (size - 2) with ratio set to 1, to avoid index overflow:
+ SrcIdxX[0] = 0;
+ RatioX[0] = 0;
+ SrcIdxY[0] = 0;
+ RatioY[0] = 0;
+ SrcIdxX[a_DstSizeX - 1] = a_SrcSizeX - 2;
+ RatioX[a_DstSizeX - 1] = 1;
+ SrcIdxY[a_DstSizeY - 1] = a_SrcSizeY - 2;
+ RatioY[a_DstSizeY - 1] = 1;
+
+ // Output all the dst array values using the indices and ratios:
+ int idx = 0;
+ for (int y = 0; y < a_DstSizeY; y++)
+ {
+ int idxLoY = a_SrcSizeX * SrcIdxY[y];
+ int idxHiY = a_SrcSizeX * (SrcIdxY[y] + 1);
+ float ry = RatioY[y];
+ for (int x = 0; x < a_DstSizeX; x++)
+ {
+ // The four src corners of the current "cell":
+ float LoXLoY = a_Src[SrcIdxX[x] + idxLoY];
+ float HiXLoY = a_Src[SrcIdxX[x] + 1 + idxLoY];
+ float LoXHiY = a_Src[SrcIdxX[x] + idxHiY];
+ float HiXHiY = a_Src[SrcIdxX[x] + 1 + idxHiY];
+
+ // Linear interpolation along the X axis:
+ float InterpXLoY = LoXLoY + (HiXLoY - LoXLoY) * RatioX[x];
+ float InterpXHiY = LoXHiY + (HiXHiY - LoXHiY) * RatioX[x];
+
+ // Linear interpolation along the Y axis:
+ a_Dst[idx] = InterpXLoY + (InterpXHiY - InterpXLoY) * ry;
+ idx += 1;
+ }
+ }
+}
+
+
+
+
+
+/// Puts linearly interpolated values from one array into another array. 3D version
+void LinearInterpolate3DArray(
+ float * a_Src,
+ int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ,
+ float * a_Dst,
+ int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ
+)
+{
+ ASSERT(a_DstSizeX > 0);
+ ASSERT(a_DstSizeX < MAX_INTERPOL_SIZEX);
+ ASSERT(a_DstSizeY > 0);
+ ASSERT(a_DstSizeY < MAX_INTERPOL_SIZEY);
+ ASSERT(a_DstSizeZ > 0);
+ ASSERT(a_DstSizeZ < MAX_INTERPOL_SIZEZ);
+
+ // Calculate interpolation ratios and src indices along each axis:
+ float RatioX[MAX_INTERPOL_SIZEX];
+ float RatioY[MAX_INTERPOL_SIZEY];
+ float RatioZ[MAX_INTERPOL_SIZEZ];
+ int SrcIdxX[MAX_INTERPOL_SIZEX];
+ int SrcIdxY[MAX_INTERPOL_SIZEY];
+ int SrcIdxZ[MAX_INTERPOL_SIZEZ];
+ for (int x = 1; x < a_DstSizeX; x++)
+ {
+ SrcIdxX[x] = x * (a_SrcSizeX - 1) / (a_DstSizeX - 1);
+ RatioX[x] = ((float)(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
+ }
+ for (int y = 1; y < a_DstSizeY; y++)
+ {
+ SrcIdxY[y] = y * (a_SrcSizeY - 1) / (a_DstSizeY - 1);
+ RatioY[y] = ((float)(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
+ }
+ for (int z = 1; z < a_DstSizeZ; z++)
+ {
+ SrcIdxZ[z] = z * (a_SrcSizeZ - 1) / (a_DstSizeZ - 1);
+ RatioZ[z] = ((float)(z * (a_SrcSizeZ - 1)) / (a_DstSizeZ - 1)) - SrcIdxZ[z];
+ }
+
+ // Special values at the ends. Notice especially the last indices being (size - 2) with ratio set to 1, to avoid index overflow:
+ SrcIdxX[0] = 0;
+ RatioX[0] = 0;
+ SrcIdxY[0] = 0;
+ RatioY[0] = 0;
+ SrcIdxZ[0] = 0;
+ RatioZ[0] = 0;
+ SrcIdxX[a_DstSizeX - 1] = a_SrcSizeX - 2;
+ RatioX[a_DstSizeX - 1] = 1;
+ SrcIdxY[a_DstSizeY - 1] = a_SrcSizeY - 2;
+ RatioY[a_DstSizeY - 1] = 1;
+ SrcIdxZ[a_DstSizeZ - 1] = a_SrcSizeZ - 2;
+ RatioZ[a_DstSizeZ - 1] = 1;
+
+ // Output all the dst array values using the indices and ratios:
+ int idx = 0;
+ for (int z = 0; z < a_DstSizeZ; z++)
+ {
+ int idxLoZ = a_SrcSizeX * a_SrcSizeY * SrcIdxZ[z];
+ int idxHiZ = a_SrcSizeX * a_SrcSizeY * (SrcIdxZ[z] + 1);
+ float rz = RatioZ[z];
+ for (int y = 0; y < a_DstSizeY; y++)
+ {
+ int idxLoY = a_SrcSizeX * SrcIdxY[y];
+ int idxHiY = a_SrcSizeX * (SrcIdxY[y] + 1);
+ float ry = RatioY[y];
+ for (int x = 0; x < a_DstSizeX; x++)
+ {
+ // The eight src corners of the current "cell":
+ float LoXLoYLoZ = a_Src[SrcIdxX[x] + idxLoY + idxLoZ];
+ float HiXLoYLoZ = a_Src[SrcIdxX[x] + 1 + idxLoY + idxLoZ];
+ float LoXHiYLoZ = a_Src[SrcIdxX[x] + idxHiY + idxLoZ];
+ float HiXHiYLoZ = a_Src[SrcIdxX[x] + 1 + idxHiY + idxLoZ];
+ float LoXLoYHiZ = a_Src[SrcIdxX[x] + idxLoY + idxHiZ];
+ float HiXLoYHiZ = a_Src[SrcIdxX[x] + 1 + idxLoY + idxHiZ];
+ float LoXHiYHiZ = a_Src[SrcIdxX[x] + idxHiY + idxHiZ];
+ float HiXHiYHiZ = a_Src[SrcIdxX[x] + 1 + idxHiY + idxHiZ];
+
+ // Linear interpolation along the Z axis:
+ float LoXLoYInZ = LoXLoYLoZ + (LoXLoYHiZ - LoXLoYLoZ) * rz;
+ float HiXLoYInZ = HiXLoYLoZ + (HiXLoYHiZ - HiXLoYLoZ) * rz;
+ float LoXHiYInZ = LoXHiYLoZ + (LoXHiYHiZ - LoXHiYLoZ) * rz;
+ float HiXHiYInZ = HiXHiYLoZ + (HiXHiYHiZ - HiXHiYLoZ) * rz;
+
+ // Linear interpolation along the Y axis:
+ float LoXInYInZ = LoXLoYInZ + (LoXHiYInZ - LoXLoYInZ) * ry;
+ float HiXInYInZ = HiXLoYInZ + (HiXHiYInZ - HiXLoYInZ) * ry;
+
+ // Linear interpolation along the X axis:
+ a_Dst[idx] = LoXInYInZ + (HiXInYInZ - LoXInYInZ) * RatioX[x];
+ idx += 1;
+ } // for x
+ } // for y
+ } // for z
+}
+
+
+
+
+
diff --git a/source/LinearInterpolation.h b/source/LinearInterpolation.h
index ea9e93455..4b798d9bc 100644
--- a/source/LinearInterpolation.h
+++ b/source/LinearInterpolation.h
@@ -1,60 +1,60 @@
-
-// LinearInterpolation.h
-
-// Declares methods for linear interpolation over 1D, 2D and 3D arrays
-
-
-
-
-
-#pragma once
-
-
-
-
-
-// 2D and 3D Interpolation is optimized by precalculating the ratios into static-sized arrays
-// These arrays enforce a max size of the dest array, but the limits are settable here:
-const int MAX_INTERPOL_SIZEX = 256; ///< Maximum X-size of the interpolated array
-const int MAX_INTERPOL_SIZEY = 512; ///< Maximum Y-size of the interpolated array
-const int MAX_INTERPOL_SIZEZ = 256; ///< Maximum Z-size of the interpolated array
-
-
-
-
-
-/// Puts linearly interpolated values from one array into another array. 1D version
-void LinearInterpolate1DArray(
- float * a_Src, ///< Src array
- int a_SrcSizeX, ///< Count of the src array
- float * a_Dst, ///< Src array
- int a_DstSizeX ///< Count of the dst array
-);
-
-
-
-
-
-/// Puts linearly interpolated values from one array into another array. 2D version
-void LinearInterpolate2DArray(
- float * a_Src, ///< Src array, [x + a_SrcSizeX * y]
- int a_SrcSizeX, int a_SrcSizeY, ///< Count of the src array, in each direction
- float * a_Dst, ///< Dst array, [x + a_DstSizeX * y]
- int a_DstSizeX, int a_DstSizeY ///< Count of the dst array, in each direction
-);
-
-
-
-
-
-/// Puts linearly interpolated values from one array into another array. 3D version
-void LinearInterpolate3DArray(
- float * a_Src, ///< Src array, [x + a_SrcSizeX * y + a_SrcSizeX * a_SrcSizeY * z]
- int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, ///< Count of the src array, in each direction
- float * a_Dst, ///< Dst array, [x + a_DstSizeX * y + a_DstSizeX * a_DstSizeY * z]
- int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ ///< Count of the dst array, in each direction
-);
-
-
-
-
+
+// LinearInterpolation.h
+
+// Declares methods for linear interpolation over 1D, 2D and 3D arrays
+
+
+
+
+
+#pragma once
+
+
+
+
+
+// 2D and 3D Interpolation is optimized by precalculating the ratios into static-sized arrays
+// These arrays enforce a max size of the dest array, but the limits are settable here:
+const int MAX_INTERPOL_SIZEX = 256; ///< Maximum X-size of the interpolated array
+const int MAX_INTERPOL_SIZEY = 512; ///< Maximum Y-size of the interpolated array
+const int MAX_INTERPOL_SIZEZ = 256; ///< Maximum Z-size of the interpolated array
+
+
+
+
+
+/// Puts linearly interpolated values from one array into another array. 1D version
+void LinearInterpolate1DArray(
+ float * a_Src, ///< Src array
+ int a_SrcSizeX, ///< Count of the src array
+ float * a_Dst, ///< Src array
+ int a_DstSizeX ///< Count of the dst array
+);
+
+
+
+
+
+/// Puts linearly interpolated values from one array into another array. 2D version
+void LinearInterpolate2DArray(
+ float * a_Src, ///< Src array, [x + a_SrcSizeX * y]
+ int a_SrcSizeX, int a_SrcSizeY, ///< Count of the src array, in each direction
+ float * a_Dst, ///< Dst array, [x + a_DstSizeX * y]
+ int a_DstSizeX, int a_DstSizeY ///< Count of the dst array, in each direction
+);
+
+
+
+
+
+/// Puts linearly interpolated values from one array into another array. 3D version
+void LinearInterpolate3DArray(
+ float * a_Src, ///< Src array, [x + a_SrcSizeX * y + a_SrcSizeX * a_SrcSizeY * z]
+ int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, ///< Count of the src array, in each direction
+ float * a_Dst, ///< Dst array, [x + a_DstSizeX * y + a_DstSizeX * a_DstSizeY * z]
+ int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ ///< Count of the dst array, in each direction
+);
+
+
+
+
diff --git a/source/LinearUpscale.h b/source/LinearUpscale.h
index 9f40b5d81..b7ac84c6a 100644
--- a/source/LinearUpscale.h
+++ b/source/LinearUpscale.h
@@ -1,244 +1,244 @@
-
-// LinearUpscale.h
-
-// Declares the functions for linearly upscaling arrays
-
-/*
-Upscaling means that the array is divided into same-size "cells", and each cell is
-linearly interpolated between its corners. The array's dimensions are therefore
-1 + CellSize * NumCells, for each direction.
-
-Upscaling is more efficient than linear interpolation, because the cell sizes are integral
-and therefore the cells' boundaries are on the array points.
-
-However, upscaling usually requires generating the "1 +" in each direction.
-
-Upscaling is implemented in templates, so that it's compatible with multiple datatypes.
-Therefore, there is no cpp file.
-
-InPlace upscaling works on a single array and assumes that the values to work on have already
-been interspersed into the array to the cell boundaries.
-Specifically, a_Array[x * a_AnchorStepX + y * a_AnchorStepY] contains the anchor value.
-
-Regular upscaling takes two arrays and "moves" the input from src to dst; src is expected packed.
-*/
-
-
-
-
-/**
-Linearly interpolates values in the array between the equidistant anchor points (upscales).
-Works in-place (input is already present at the correct output coords)
-*/
-template<typename TYPE> void LinearUpscale2DArrayInPlace(
- TYPE * a_Array,
- int a_SizeX, int a_SizeY, // Dimensions of the array
- int a_AnchorStepX, int a_AnchorStepY // Distances between the anchor points in each direction
-)
-{
- // First interpolate columns where the anchor points are:
- int LastYCell = a_SizeY - a_AnchorStepY;
- for (int y = 0; y < LastYCell; y += a_AnchorStepY)
- {
- int Idx = a_SizeX * y;
- for (int x = 0; x < a_SizeX; x += a_AnchorStepX)
- {
- TYPE StartValue = a_Array[Idx];
- TYPE EndValue = a_Array[Idx + a_SizeX * a_AnchorStepY];
- TYPE Diff = EndValue - StartValue;
- for (int CellY = 1; CellY < a_AnchorStepY; CellY++)
- {
- a_Array[Idx + a_SizeX * CellY] = StartValue + Diff * CellY / a_AnchorStepY;
- } // for CellY
- Idx += a_AnchorStepX;
- } // for x
- } // for y
-
- // Now interpolate in rows, each row has values in the anchor columns
- int LastXCell = a_SizeX - a_AnchorStepX;
- for (int y = 0; y < a_SizeY; y++)
- {
- int Idx = a_SizeX * y;
- for (int x = 0; x < LastXCell; x += a_AnchorStepX)
- {
- TYPE StartValue = a_Array[Idx];
- TYPE EndValue = a_Array[Idx + a_AnchorStepX];
- TYPE Diff = EndValue - StartValue;
- for (int CellX = 1; CellX < a_AnchorStepX; CellX++)
- {
- a_Array[Idx + CellX] = StartValue + CellX * Diff / a_AnchorStepX;
- } // for CellY
- Idx += a_AnchorStepX;
- }
- }
-}
-
-
-
-
-
-/**
-Linearly interpolates values in the array between the equidistant anchor points (upscales).
-Works on two arrays, input is packed and output is to be completely constructed.
-*/
-template<typename TYPE> void LinearUpscale2DArray(
- TYPE * a_Src, ///< Source array of size a_SrcSizeX x a_SrcSizeY
- int a_SrcSizeX, int a_SrcSizeY, ///< Dimensions of the src array
- TYPE * a_Dst, ///< Dest array, of size (a_SrcSizeX * a_UpscaleX + 1) x (a_SrcSizeY * a_UpscaleY + 1)
- int a_UpscaleX, int a_UpscaleY ///< Upscale factor for each direction
-)
-{
- // For optimization reasons, we're storing the upscaling ratios in a fixed-size arrays of these sizes
- // Feel free to enlarge them if needed, but keep in mind that they're on the stack
- const int MAX_UPSCALE_X = 128;
- const int MAX_UPSCALE_Y = 128;
-
- ASSERT(a_Src != NULL);
- ASSERT(a_Dst != NULL);
- ASSERT(a_SrcSizeX > 0);
- ASSERT(a_SrcSizeY > 0);
- ASSERT(a_UpscaleX > 0);
- ASSERT(a_UpscaleY > 0);
- ASSERT(a_UpscaleX <= MAX_UPSCALE_X);
- ASSERT(a_UpscaleY <= MAX_UPSCALE_Y);
-
- // Pre-calculate the upscaling ratios:
- TYPE RatioX[MAX_UPSCALE_X];
- TYPE RatioY[MAX_UPSCALE_Y];
- for (int x = 0; x <= a_UpscaleX; x++)
- {
- RatioX[x] = (TYPE)x / a_UpscaleX;
- }
- for (int y = 0; y <= a_UpscaleY; y++)
- {
- RatioY[y] = (TYPE)y / a_UpscaleY;
- }
-
- // Interpolate each XY cell:
- int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
- int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
- for (int y = 0; y < (a_SrcSizeY - 1); y++)
- {
- int DstY = y * a_UpscaleY;
- int idx = y * a_SrcSizeX;
- for (int x = 0; x < (a_SrcSizeX - 1); x++, idx++)
- {
- int DstX = x * a_UpscaleX;
- TYPE LoXLoY = a_Src[idx];
- TYPE LoXHiY = a_Src[idx + a_SrcSizeX];
- TYPE HiXLoY = a_Src[idx + 1];
- TYPE HiXHiY = a_Src[idx + 1 + a_SrcSizeX];
- for (int CellY = 0; CellY <= a_UpscaleY; CellY++)
- {
- int DestIdx = (DstY + CellY) * DstSizeX + DstX;
- ASSERT(DestIdx + a_UpscaleX < DstSizeX * DstSizeY);
- TYPE LoXInY = LoXLoY + (LoXHiY - LoXLoY) * RatioY[CellY];
- TYPE HiXInY = HiXLoY + (HiXHiY - HiXLoY) * RatioY[CellY];
- for (int CellX = 0; CellX <= a_UpscaleX; CellX++, DestIdx++)
- {
- a_Dst[DestIdx] = LoXInY + (HiXInY - LoXInY) * RatioX[CellX];
- }
- } // for CellY
- } // for x
- } // for y
-}
-
-
-
-
-
-/**
-Linearly interpolates values in the array between the equidistant anchor points (upscales).
-Works on two arrays, input is packed and output is to be completely constructed.
-*/
-template<typename TYPE> void LinearUpscale3DArray(
- TYPE * a_Src, ///< Source array of size a_SrcSizeX x a_SrcSizeY x a_SrcSizeZ
- int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, ///< Dimensions of the src array
- TYPE * a_Dst, ///< Dest array, of size (a_SrcSizeX * a_UpscaleX + 1) x (a_SrcSizeY * a_UpscaleY + 1) x (a_SrcSizeZ * a_UpscaleZ + 1)
- int a_UpscaleX, int a_UpscaleY, int a_UpscaleZ ///< Upscale factor for each direction
-)
-{
- // For optimization reasons, we're storing the upscaling ratios in a fixed-size arrays of these sizes
- // Feel free to enlarge them if needed, but keep in mind that they're on the stack
- const int MAX_UPSCALE_X = 128;
- const int MAX_UPSCALE_Y = 128;
- const int MAX_UPSCALE_Z = 128;
-
- ASSERT(a_Src != NULL);
- ASSERT(a_Dst != NULL);
- ASSERT(a_SrcSizeX > 0);
- ASSERT(a_SrcSizeY > 0);
- ASSERT(a_SrcSizeZ > 0);
- ASSERT(a_UpscaleX > 0);
- ASSERT(a_UpscaleY > 0);
- ASSERT(a_UpscaleZ > 0);
- ASSERT(a_UpscaleX <= MAX_UPSCALE_X);
- ASSERT(a_UpscaleY <= MAX_UPSCALE_Y);
- ASSERT(a_UpscaleZ <= MAX_UPSCALE_Z);
-
- // Pre-calculate the upscaling ratios:
- TYPE RatioX[MAX_UPSCALE_X];
- TYPE RatioY[MAX_UPSCALE_Y];
- TYPE RatioZ[MAX_UPSCALE_Y];
- for (int x = 0; x <= a_UpscaleX; x++)
- {
- RatioX[x] = (TYPE)x / a_UpscaleX;
- }
- for (int y = 0; y <= a_UpscaleY; y++)
- {
- RatioY[y] = (TYPE)y / a_UpscaleY;
- }
- for (int z = 0; z <= a_UpscaleZ; z++)
- {
- RatioZ[z] = (TYPE)z / a_UpscaleZ;
- }
-
- // Interpolate each XYZ cell:
- int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
- int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
- int DstSizeZ = (a_SrcSizeZ - 1) * a_UpscaleZ + 1;
- for (int z = 0; z < (a_SrcSizeZ - 1); z++)
- {
- int DstZ = z * a_UpscaleZ;
- for (int y = 0; y < (a_SrcSizeY - 1); y++)
- {
- int DstY = y * a_UpscaleY;
- int idx = y * a_SrcSizeX + z * a_SrcSizeX * a_SrcSizeY;
- for (int x = 0; x < (a_SrcSizeX - 1); x++, idx++)
- {
- int DstX = x * a_UpscaleX;
- TYPE LoXLoYLoZ = a_Src[idx];
- TYPE LoXLoYHiZ = a_Src[idx + a_SrcSizeX * a_SrcSizeY];
- TYPE LoXHiYLoZ = a_Src[idx + a_SrcSizeX];
- TYPE LoXHiYHiZ = a_Src[idx + a_SrcSizeX + a_SrcSizeX * a_SrcSizeY];
- TYPE HiXLoYLoZ = a_Src[idx + 1];
- TYPE HiXLoYHiZ = a_Src[idx + 1 + a_SrcSizeX * a_SrcSizeY];
- TYPE HiXHiYLoZ = a_Src[idx + 1 + a_SrcSizeX];
- TYPE HiXHiYHiZ = a_Src[idx + 1 + a_SrcSizeX + a_SrcSizeX * a_SrcSizeY];
- for (int CellZ = 0; CellZ <= a_UpscaleZ; CellZ++)
- {
- TYPE LoXLoYInZ = LoXLoYLoZ + (LoXLoYHiZ - LoXLoYLoZ) * RatioZ[CellZ];
- TYPE LoXHiYInZ = LoXHiYLoZ + (LoXHiYHiZ - LoXHiYLoZ) * RatioZ[CellZ];
- TYPE HiXLoYInZ = HiXLoYLoZ + (HiXLoYHiZ - HiXLoYLoZ) * RatioZ[CellZ];
- TYPE HiXHiYInZ = HiXHiYLoZ + (HiXHiYHiZ - HiXHiYLoZ) * RatioZ[CellZ];
- for (int CellY = 0; CellY <= a_UpscaleY; CellY++)
- {
- int DestIdx = (DstZ + CellZ) * DstSizeX * DstSizeY + (DstY + CellY) * DstSizeX + DstX;
- ASSERT(DestIdx + a_UpscaleX < DstSizeX * DstSizeY * DstSizeZ);
- TYPE LoXInY = LoXLoYInZ + (LoXHiYInZ - LoXLoYInZ) * RatioY[CellY];
- TYPE HiXInY = HiXLoYInZ + (HiXHiYInZ - HiXLoYInZ) * RatioY[CellY];
- for (int CellX = 0; CellX <= a_UpscaleX; CellX++, DestIdx++)
- {
- a_Dst[DestIdx] = LoXInY + (HiXInY - LoXInY) * RatioX[CellX];
- }
- } // for CellY
- } // for CellZ
- } // for x
- } // for y
- } // for z
-}
-
-
-
-
-
+
+// LinearUpscale.h
+
+// Declares the functions for linearly upscaling arrays
+
+/*
+Upscaling means that the array is divided into same-size "cells", and each cell is
+linearly interpolated between its corners. The array's dimensions are therefore
+1 + CellSize * NumCells, for each direction.
+
+Upscaling is more efficient than linear interpolation, because the cell sizes are integral
+and therefore the cells' boundaries are on the array points.
+
+However, upscaling usually requires generating the "1 +" in each direction.
+
+Upscaling is implemented in templates, so that it's compatible with multiple datatypes.
+Therefore, there is no cpp file.
+
+InPlace upscaling works on a single array and assumes that the values to work on have already
+been interspersed into the array to the cell boundaries.
+Specifically, a_Array[x * a_AnchorStepX + y * a_AnchorStepY] contains the anchor value.
+
+Regular upscaling takes two arrays and "moves" the input from src to dst; src is expected packed.
+*/
+
+
+
+
+/**
+Linearly interpolates values in the array between the equidistant anchor points (upscales).
+Works in-place (input is already present at the correct output coords)
+*/
+template<typename TYPE> void LinearUpscale2DArrayInPlace(
+ TYPE * a_Array,
+ int a_SizeX, int a_SizeY, // Dimensions of the array
+ int a_AnchorStepX, int a_AnchorStepY // Distances between the anchor points in each direction
+)
+{
+ // First interpolate columns where the anchor points are:
+ int LastYCell = a_SizeY - a_AnchorStepY;
+ for (int y = 0; y < LastYCell; y += a_AnchorStepY)
+ {
+ int Idx = a_SizeX * y;
+ for (int x = 0; x < a_SizeX; x += a_AnchorStepX)
+ {
+ TYPE StartValue = a_Array[Idx];
+ TYPE EndValue = a_Array[Idx + a_SizeX * a_AnchorStepY];
+ TYPE Diff = EndValue - StartValue;
+ for (int CellY = 1; CellY < a_AnchorStepY; CellY++)
+ {
+ a_Array[Idx + a_SizeX * CellY] = StartValue + Diff * CellY / a_AnchorStepY;
+ } // for CellY
+ Idx += a_AnchorStepX;
+ } // for x
+ } // for y
+
+ // Now interpolate in rows, each row has values in the anchor columns
+ int LastXCell = a_SizeX - a_AnchorStepX;
+ for (int y = 0; y < a_SizeY; y++)
+ {
+ int Idx = a_SizeX * y;
+ for (int x = 0; x < LastXCell; x += a_AnchorStepX)
+ {
+ TYPE StartValue = a_Array[Idx];
+ TYPE EndValue = a_Array[Idx + a_AnchorStepX];
+ TYPE Diff = EndValue - StartValue;
+ for (int CellX = 1; CellX < a_AnchorStepX; CellX++)
+ {
+ a_Array[Idx + CellX] = StartValue + CellX * Diff / a_AnchorStepX;
+ } // for CellY
+ Idx += a_AnchorStepX;
+ }
+ }
+}
+
+
+
+
+
+/**
+Linearly interpolates values in the array between the equidistant anchor points (upscales).
+Works on two arrays, input is packed and output is to be completely constructed.
+*/
+template<typename TYPE> void LinearUpscale2DArray(
+ TYPE * a_Src, ///< Source array of size a_SrcSizeX x a_SrcSizeY
+ int a_SrcSizeX, int a_SrcSizeY, ///< Dimensions of the src array
+ TYPE * a_Dst, ///< Dest array, of size (a_SrcSizeX * a_UpscaleX + 1) x (a_SrcSizeY * a_UpscaleY + 1)
+ int a_UpscaleX, int a_UpscaleY ///< Upscale factor for each direction
+)
+{
+ // For optimization reasons, we're storing the upscaling ratios in a fixed-size arrays of these sizes
+ // Feel free to enlarge them if needed, but keep in mind that they're on the stack
+ const int MAX_UPSCALE_X = 128;
+ const int MAX_UPSCALE_Y = 128;
+
+ ASSERT(a_Src != NULL);
+ ASSERT(a_Dst != NULL);
+ ASSERT(a_SrcSizeX > 0);
+ ASSERT(a_SrcSizeY > 0);
+ ASSERT(a_UpscaleX > 0);
+ ASSERT(a_UpscaleY > 0);
+ ASSERT(a_UpscaleX <= MAX_UPSCALE_X);
+ ASSERT(a_UpscaleY <= MAX_UPSCALE_Y);
+
+ // Pre-calculate the upscaling ratios:
+ TYPE RatioX[MAX_UPSCALE_X];
+ TYPE RatioY[MAX_UPSCALE_Y];
+ for (int x = 0; x <= a_UpscaleX; x++)
+ {
+ RatioX[x] = (TYPE)x / a_UpscaleX;
+ }
+ for (int y = 0; y <= a_UpscaleY; y++)
+ {
+ RatioY[y] = (TYPE)y / a_UpscaleY;
+ }
+
+ // Interpolate each XY cell:
+ int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
+ int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
+ for (int y = 0; y < (a_SrcSizeY - 1); y++)
+ {
+ int DstY = y * a_UpscaleY;
+ int idx = y * a_SrcSizeX;
+ for (int x = 0; x < (a_SrcSizeX - 1); x++, idx++)
+ {
+ int DstX = x * a_UpscaleX;
+ TYPE LoXLoY = a_Src[idx];
+ TYPE LoXHiY = a_Src[idx + a_SrcSizeX];
+ TYPE HiXLoY = a_Src[idx + 1];
+ TYPE HiXHiY = a_Src[idx + 1 + a_SrcSizeX];
+ for (int CellY = 0; CellY <= a_UpscaleY; CellY++)
+ {
+ int DestIdx = (DstY + CellY) * DstSizeX + DstX;
+ ASSERT(DestIdx + a_UpscaleX < DstSizeX * DstSizeY);
+ TYPE LoXInY = LoXLoY + (LoXHiY - LoXLoY) * RatioY[CellY];
+ TYPE HiXInY = HiXLoY + (HiXHiY - HiXLoY) * RatioY[CellY];
+ for (int CellX = 0; CellX <= a_UpscaleX; CellX++, DestIdx++)
+ {
+ a_Dst[DestIdx] = LoXInY + (HiXInY - LoXInY) * RatioX[CellX];
+ }
+ } // for CellY
+ } // for x
+ } // for y
+}
+
+
+
+
+
+/**
+Linearly interpolates values in the array between the equidistant anchor points (upscales).
+Works on two arrays, input is packed and output is to be completely constructed.
+*/
+template<typename TYPE> void LinearUpscale3DArray(
+ TYPE * a_Src, ///< Source array of size a_SrcSizeX x a_SrcSizeY x a_SrcSizeZ
+ int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, ///< Dimensions of the src array
+ TYPE * a_Dst, ///< Dest array, of size (a_SrcSizeX * a_UpscaleX + 1) x (a_SrcSizeY * a_UpscaleY + 1) x (a_SrcSizeZ * a_UpscaleZ + 1)
+ int a_UpscaleX, int a_UpscaleY, int a_UpscaleZ ///< Upscale factor for each direction
+)
+{
+ // For optimization reasons, we're storing the upscaling ratios in a fixed-size arrays of these sizes
+ // Feel free to enlarge them if needed, but keep in mind that they're on the stack
+ const int MAX_UPSCALE_X = 128;
+ const int MAX_UPSCALE_Y = 128;
+ const int MAX_UPSCALE_Z = 128;
+
+ ASSERT(a_Src != NULL);
+ ASSERT(a_Dst != NULL);
+ ASSERT(a_SrcSizeX > 0);
+ ASSERT(a_SrcSizeY > 0);
+ ASSERT(a_SrcSizeZ > 0);
+ ASSERT(a_UpscaleX > 0);
+ ASSERT(a_UpscaleY > 0);
+ ASSERT(a_UpscaleZ > 0);
+ ASSERT(a_UpscaleX <= MAX_UPSCALE_X);
+ ASSERT(a_UpscaleY <= MAX_UPSCALE_Y);
+ ASSERT(a_UpscaleZ <= MAX_UPSCALE_Z);
+
+ // Pre-calculate the upscaling ratios:
+ TYPE RatioX[MAX_UPSCALE_X];
+ TYPE RatioY[MAX_UPSCALE_Y];
+ TYPE RatioZ[MAX_UPSCALE_Y];
+ for (int x = 0; x <= a_UpscaleX; x++)
+ {
+ RatioX[x] = (TYPE)x / a_UpscaleX;
+ }
+ for (int y = 0; y <= a_UpscaleY; y++)
+ {
+ RatioY[y] = (TYPE)y / a_UpscaleY;
+ }
+ for (int z = 0; z <= a_UpscaleZ; z++)
+ {
+ RatioZ[z] = (TYPE)z / a_UpscaleZ;
+ }
+
+ // Interpolate each XYZ cell:
+ int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
+ int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
+ int DstSizeZ = (a_SrcSizeZ - 1) * a_UpscaleZ + 1;
+ for (int z = 0; z < (a_SrcSizeZ - 1); z++)
+ {
+ int DstZ = z * a_UpscaleZ;
+ for (int y = 0; y < (a_SrcSizeY - 1); y++)
+ {
+ int DstY = y * a_UpscaleY;
+ int idx = y * a_SrcSizeX + z * a_SrcSizeX * a_SrcSizeY;
+ for (int x = 0; x < (a_SrcSizeX - 1); x++, idx++)
+ {
+ int DstX = x * a_UpscaleX;
+ TYPE LoXLoYLoZ = a_Src[idx];
+ TYPE LoXLoYHiZ = a_Src[idx + a_SrcSizeX * a_SrcSizeY];
+ TYPE LoXHiYLoZ = a_Src[idx + a_SrcSizeX];
+ TYPE LoXHiYHiZ = a_Src[idx + a_SrcSizeX + a_SrcSizeX * a_SrcSizeY];
+ TYPE HiXLoYLoZ = a_Src[idx + 1];
+ TYPE HiXLoYHiZ = a_Src[idx + 1 + a_SrcSizeX * a_SrcSizeY];
+ TYPE HiXHiYLoZ = a_Src[idx + 1 + a_SrcSizeX];
+ TYPE HiXHiYHiZ = a_Src[idx + 1 + a_SrcSizeX + a_SrcSizeX * a_SrcSizeY];
+ for (int CellZ = 0; CellZ <= a_UpscaleZ; CellZ++)
+ {
+ TYPE LoXLoYInZ = LoXLoYLoZ + (LoXLoYHiZ - LoXLoYLoZ) * RatioZ[CellZ];
+ TYPE LoXHiYInZ = LoXHiYLoZ + (LoXHiYHiZ - LoXHiYLoZ) * RatioZ[CellZ];
+ TYPE HiXLoYInZ = HiXLoYLoZ + (HiXLoYHiZ - HiXLoYLoZ) * RatioZ[CellZ];
+ TYPE HiXHiYInZ = HiXHiYLoZ + (HiXHiYHiZ - HiXHiYLoZ) * RatioZ[CellZ];
+ for (int CellY = 0; CellY <= a_UpscaleY; CellY++)
+ {
+ int DestIdx = (DstZ + CellZ) * DstSizeX * DstSizeY + (DstY + CellY) * DstSizeX + DstX;
+ ASSERT(DestIdx + a_UpscaleX < DstSizeX * DstSizeY * DstSizeZ);
+ TYPE LoXInY = LoXLoYInZ + (LoXHiYInZ - LoXLoYInZ) * RatioY[CellY];
+ TYPE HiXInY = HiXLoYInZ + (HiXHiYInZ - HiXLoYInZ) * RatioY[CellY];
+ for (int CellX = 0; CellX <= a_UpscaleX; CellX++, DestIdx++)
+ {
+ a_Dst[DestIdx] = LoXInY + (HiXInY - LoXInY) * RatioX[CellX];
+ }
+ } // for CellY
+ } // for CellZ
+ } // for x
+ } // for y
+ } // for z
+}
+
+
+
+
+
diff --git a/source/LuaScript.cpp b/source/LuaScript.cpp
new file mode 100644
index 000000000..8d92c238f
--- /dev/null
+++ b/source/LuaScript.cpp
@@ -0,0 +1,278 @@
+
+// LuaScript.cpp
+
+// Implements the cLuaScript class that loads a Lua script file to produce a web template out of it
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "LuaScript.h"
+
+extern "C"
+{
+#include "lualib.h"
+}
+
+#include "tolua++.h"
+#include "Bindings.h"
+#include "ManualBindings.h"
+
+// fwd: SQLite/lsqlite3.c
+extern "C"
+{
+ LUALIB_API int luaopen_lsqlite3(lua_State * L);
+}
+
+// fwd: LuaExpat/lxplib.c:
+extern "C"
+{
+ int luaopen_lxp(lua_State * L);
+}
+
+
+
+
+
+cLuaScript::cLuaScript()
+ : m_LuaState(NULL)
+{
+
+}
+
+
+
+
+
+cLuaScript::~cLuaScript()
+{
+ if( m_LuaState )
+ {
+ lua_close( m_LuaState );
+ m_LuaState = 0;
+ }
+}
+
+
+
+
+
+void cLuaScript::Initialize()
+{
+ // Check to see if this script has not been initialized before
+ ASSERT(!m_LuaState);
+
+ // Create a Lua state and bind all libraries to it
+ m_LuaState = lua_open();
+ luaL_openlibs(m_LuaState);
+ tolua_AllToLua_open(m_LuaState);
+ ManualBindings::Bind(m_LuaState);
+ luaopen_lsqlite3(m_LuaState);
+ luaopen_lxp(m_LuaState);
+}
+
+
+
+
+
+bool cLuaScript::LoadFile( const char* a_FilePath )
+{
+ // Make sure the plugin is initialized
+ ASSERT(m_LuaState);
+
+ // Load the file into the Lua state
+ int s = luaL_loadfile(m_LuaState, a_FilePath );
+ if (ReportErrors(s))
+ {
+ return false;
+ }
+ return true;
+}
+
+
+
+
+
+bool cLuaScript::Execute()
+{
+ // Make sure we got a Lua state
+ ASSERT(m_LuaState);
+
+ // Execute the script as it is right now
+ int s = lua_pcall(m_LuaState, 0, LUA_MULTRET, 0);
+ if( ReportErrors( s ) )
+ {
+ return false;
+ }
+ return true;
+}
+
+
+
+
+
+bool cLuaScript::ReportErrors( int a_Status )
+{
+ if (a_Status == 0)
+ {
+ // No error to report
+ return false;
+ }
+
+ // Status was set to error so get the error from the Lua state and log it
+ LOGERROR("LUA: %s", lua_tostring(m_LuaState, -1));
+ lua_pop(m_LuaState, 1);
+
+ // Return true to indicate that an error was returned
+ return true;
+}
+
+
+
+
+
+bool cLuaScript::LuaPushFunction( const char * a_FunctionName, bool a_bLogError /*= true*/ )
+{
+ ASSERT(m_LuaState);
+
+ // Find and push the function on the Lua stack
+ lua_getglobal(m_LuaState, a_FunctionName);
+
+ // Make sure we found a function
+ if (!lua_isfunction(m_LuaState, -1))
+ {
+ if (a_bLogError)
+ {
+ LOGWARN("LUA: Could not find function %s()", a_FunctionName);
+ }
+
+ // Pop the pushed 'object' back
+ lua_pop(m_LuaState, 1);
+ return false;
+ }
+
+ // Successfully pushed a function to the Lua stack
+ return true;
+}
+
+
+
+
+
+bool cLuaScript::LuaCallFunction( int a_NumArgs, int a_NumResults, const char * a_FunctionName )
+{
+ ASSERT(m_LuaState);
+
+ // Make sure there's a lua function on the stack
+ ASSERT(lua_isfunction(m_LuaState, -a_NumArgs - 1));
+
+ // Call the desired function
+ int s = lua_pcall(m_LuaState, a_NumArgs, a_NumResults, 0);
+
+ // Check for errors
+ if (ReportErrors(s))
+ {
+ LOGWARN("LUA: Error calling function %s()", a_FunctionName);
+ return false;
+ }
+
+ // Successfully executed function
+ return true;
+}
+
+
+
+
+
+bool cLuaScript::CallFunction( const char* a_Function, AString& ReturnedString )
+{
+ // Make sure we have the required things to call a function
+ ASSERT(m_LuaState);
+ ASSERT(a_Function);
+
+ // Push the desired function on the stack
+ if (!LuaPushFunction(a_Function))
+ {
+ return false;
+ }
+
+ if (!LuaCallFunction(0, 1, a_Function))
+ {
+ return false;
+ }
+
+ if (lua_isstring(m_LuaState, -1))
+ {
+ ReturnedString = tolua_tostring(m_LuaState, -1, "");
+ }
+ lua_pop(m_LuaState, 1);
+ return true;
+}
+
+
+
+
+
+bool cLuaScript::CallFunction( const char* a_Function, const sLuaUsertype& a_UserType, AString& ReturnedString )
+{
+ // Make sure we have the required things to call a function
+ ASSERT(m_LuaState);
+ ASSERT(a_Function);
+
+ // Push the desired function on the stack
+ if (!LuaPushFunction(a_Function))
+ {
+ return false;
+ }
+
+ tolua_pushusertype(m_LuaState, a_UserType.Object, a_UserType.ClassName);
+
+ if (!LuaCallFunction(1, 1, a_Function))
+ {
+ return false;
+ }
+
+ if (lua_isstring(m_LuaState, -1))
+ {
+ ReturnedString = tolua_tostring(m_LuaState, -1, "");
+ }
+ lua_pop(m_LuaState, 1);
+ return true;
+}
+
+
+
+
+
+bool cLuaScript::CallFunction( const char* a_Function, const sLuaUsertype& a_UserType1, const sLuaUsertype& a_UserType2, AString& ReturnedString )
+{
+ // Make sure we have the required things to call a function
+ ASSERT(m_LuaState);
+ ASSERT(a_Function);
+
+ // Push the desired function on the stack
+ if (!LuaPushFunction(a_Function))
+ {
+ return false;
+ }
+
+ tolua_pushusertype(m_LuaState, a_UserType1.Object, a_UserType1.ClassName);
+ tolua_pushusertype(m_LuaState, a_UserType2.Object, a_UserType2.ClassName);
+
+ if (!LuaCallFunction(2, 1, a_Function))
+ {
+ return false;
+ }
+
+ if (lua_isstring(m_LuaState, -1))
+ {
+ ReturnedString = tolua_tostring(m_LuaState, -1, "");
+ }
+ lua_pop(m_LuaState, 1);
+ return true;
+}
+
+
+
+
+
+
+
diff --git a/source/LuaScript.h b/source/LuaScript.h
new file mode 100644
index 000000000..f98b2e65b
--- /dev/null
+++ b/source/LuaScript.h
@@ -0,0 +1,63 @@
+
+// LuaScript.h
+
+// Declares the cLuaScript class that loads a Lua script file to produce a web template out of it
+
+
+
+
+
+#pragma once
+
+struct lua_State;
+
+
+
+
+
+struct sLuaUsertype
+{
+ sLuaUsertype(void* a_pObject, const char* a_pClassName) : Object(a_pObject), ClassName(a_pClassName) {}
+ //
+ void* Object;
+ const char* ClassName;
+} ;
+
+
+
+
+
+class cLuaScript
+{
+public:
+ cLuaScript();
+ ~cLuaScript();
+
+ /// Prepares a Lua state
+ void Initialize();
+
+ /// Load a Lua script on the given path
+ bool LoadFile(const char* a_FilePath);
+
+ /// Execute the loaded Lua script
+ bool Execute();
+
+ /// Call a function on the Lua script. Put all overloads here
+ bool CallFunction(const char* a_Function, AString& ReturnedString);
+ bool CallFunction(const char* a_Function, const sLuaUsertype& a_UserType, AString& ReturnedString);
+ bool CallFunction(const char* a_Function, const sLuaUsertype& a_UserType1, const sLuaUsertype& a_UserType2, AString& ReturnedString);
+
+protected:
+ /// Reports an error in the log if a_Status is flagged as an error. Returns true when a_Status is flagged as error, returns false when no error occured.
+ bool ReportErrors(int a_Status);
+
+ /// Helper functions for calling functions in Lua
+ bool LuaPushFunction(const char * a_FunctionName, bool a_bLogError = true);
+ bool LuaCallFunction(int a_NumArgs, int a_NumResults, const char * a_FunctionName ); // a_FunctionName is only used for error messages, nothing else
+private:
+ lua_State* m_LuaState;
+} ;
+
+
+
+
diff --git a/source/LuaWindow.cpp b/source/LuaWindow.cpp
index 13d06eeb6..c36fabd3c 100644
--- a/source/LuaWindow.cpp
+++ b/source/LuaWindow.cpp
@@ -1,175 +1,175 @@
-
-// LuaWindow.cpp
-
-// Implements the cLuaWindow class representing a virtual window that plugins may create and open for the player
-
-#include "Globals.h"
-#include "LuaWindow.h"
-#include "UI/SlotArea.h"
-#include "Plugin_NewLua.h"
-#include "Player.h"
-#include "lauxlib.h" // Needed for LUA_REFNIL
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cLuaWindow:
-
-cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) :
- super(a_WindowType, a_Title),
- m_Contents(a_SlotsX, a_SlotsY),
- m_Plugin(NULL),
- m_LuaRef(LUA_REFNIL),
- m_OnClosingFnRef(LUA_REFNIL),
- m_OnSlotChangedFnRef(LUA_REFNIL)
-{
- m_Contents.AddListener(*this);
- m_SlotAreas.push_back(new cSlotAreaItemGrid(m_Contents, *this));
-
- // If appropriate, add an Armor slot area:
- switch (a_WindowType)
- {
- case cWindow::Inventory:
- case cWindow::Workbench:
- {
- m_SlotAreas.push_back(new cSlotAreaArmor(*this));
- break;
- }
- }
- m_SlotAreas.push_back(new cSlotAreaInventory(*this));
- m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
-}
-
-
-
-
-
-cLuaWindow::~cLuaWindow()
-{
- ASSERT(m_OpenedBy.empty());
-}
-
-
-
-
-
-void cLuaWindow::SetLuaRef(cPlugin_NewLua * a_Plugin, int a_LuaRef)
-{
- // Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
- ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
- ASSERT(m_LuaRef == LUA_REFNIL);
- m_Plugin = a_Plugin;
- m_LuaRef = a_LuaRef;
-}
-
-
-
-
-
-bool cLuaWindow::IsLuaReferenced(void) const
-{
- return ((m_Plugin != NULL) && (m_LuaRef != LUA_REFNIL));
-}
-
-
-
-
-
-void cLuaWindow::SetOnClosing(cPlugin_NewLua * a_Plugin, int a_FnRef)
-{
- // Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
- ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
-
- // If there already was a function, unreference it first
- if (m_OnClosingFnRef != LUA_REFNIL)
- {
- m_Plugin->Unreference(m_OnClosingFnRef);
- }
-
- // Store the new reference
- m_Plugin = a_Plugin;
- m_OnClosingFnRef = a_FnRef;
-}
-
-
-
-
-
-void cLuaWindow::SetOnSlotChanged(cPlugin_NewLua * a_Plugin, int a_FnRef)
-{
- // Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
- ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
-
- // If there already was a function, unreference it first
- if (m_OnSlotChangedFnRef != LUA_REFNIL)
- {
- m_Plugin->Unreference(m_OnSlotChangedFnRef);
- }
-
- // Store the new reference
- m_Plugin = a_Plugin;
- m_OnSlotChangedFnRef = a_FnRef;
-}
-
-
-
-
-
-bool cLuaWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
-{
- // First notify the plugin through the registered callback:
- if (m_OnClosingFnRef != LUA_REFNIL)
- {
- ASSERT(m_Plugin != NULL);
- if (m_Plugin->CallbackWindowClosing(m_OnClosingFnRef, *this, a_Player, a_CanRefuse))
- {
- // The callback disagrees (the higher levels check the CanRefuse flag compliance)
- return false;
- }
- }
-
- return super::ClosedByPlayer(a_Player, a_CanRefuse);
-}
-
-
-
-
-
-void cLuaWindow::Destroy(void)
-{
- super::Destroy();
-
- if ((m_LuaRef != LUA_REFNIL) && (m_Plugin != NULL))
- {
- // The object is referenced by Lua, un-reference it
- m_Plugin->Unreference(m_LuaRef);
- }
-
- // Lua will take care of this object, it will garbage-collect it, so we *must not* delete it!
- m_IsDestroyed = false;
-}
-
-
-
-
-
-void cLuaWindow::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
-{
- if (a_ItemGrid != &m_Contents)
- {
- ASSERT(!"Invalid ItemGrid in callback");
- return;
- }
-
- // If an OnSlotChanged callback has been registered, call it:
- if (m_OnSlotChangedFnRef != LUA_REFNIL)
- {
- m_Plugin->CallbackWindowSlotChanged(m_OnSlotChangedFnRef, *this, a_SlotNum);
- }
-}
-
-
-
-
+
+// LuaWindow.cpp
+
+// Implements the cLuaWindow class representing a virtual window that plugins may create and open for the player
+
+#include "Globals.h"
+#include "LuaWindow.h"
+#include "UI/SlotArea.h"
+#include "Plugin_NewLua.h"
+#include "Player.h"
+#include "lauxlib.h" // Needed for LUA_REFNIL
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cLuaWindow:
+
+cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) :
+ super(a_WindowType, a_Title),
+ m_Contents(a_SlotsX, a_SlotsY),
+ m_Plugin(NULL),
+ m_LuaRef(LUA_REFNIL),
+ m_OnClosingFnRef(LUA_REFNIL),
+ m_OnSlotChangedFnRef(LUA_REFNIL)
+{
+ m_Contents.AddListener(*this);
+ m_SlotAreas.push_back(new cSlotAreaItemGrid(m_Contents, *this));
+
+ // If appropriate, add an Armor slot area:
+ switch (a_WindowType)
+ {
+ case cWindow::Inventory:
+ case cWindow::Workbench:
+ {
+ m_SlotAreas.push_back(new cSlotAreaArmor(*this));
+ break;
+ }
+ }
+ m_SlotAreas.push_back(new cSlotAreaInventory(*this));
+ m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
+}
+
+
+
+
+
+cLuaWindow::~cLuaWindow()
+{
+ ASSERT(m_OpenedBy.empty());
+}
+
+
+
+
+
+void cLuaWindow::SetLuaRef(cPlugin_NewLua * a_Plugin, int a_LuaRef)
+{
+ // Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
+ ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
+ ASSERT(m_LuaRef == LUA_REFNIL);
+ m_Plugin = a_Plugin;
+ m_LuaRef = a_LuaRef;
+}
+
+
+
+
+
+bool cLuaWindow::IsLuaReferenced(void) const
+{
+ return ((m_Plugin != NULL) && (m_LuaRef != LUA_REFNIL));
+}
+
+
+
+
+
+void cLuaWindow::SetOnClosing(cPlugin_NewLua * a_Plugin, int a_FnRef)
+{
+ // Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
+ ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
+
+ // If there already was a function, unreference it first
+ if (m_OnClosingFnRef != LUA_REFNIL)
+ {
+ m_Plugin->Unreference(m_OnClosingFnRef);
+ }
+
+ // Store the new reference
+ m_Plugin = a_Plugin;
+ m_OnClosingFnRef = a_FnRef;
+}
+
+
+
+
+
+void cLuaWindow::SetOnSlotChanged(cPlugin_NewLua * a_Plugin, int a_FnRef)
+{
+ // Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
+ ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
+
+ // If there already was a function, unreference it first
+ if (m_OnSlotChangedFnRef != LUA_REFNIL)
+ {
+ m_Plugin->Unreference(m_OnSlotChangedFnRef);
+ }
+
+ // Store the new reference
+ m_Plugin = a_Plugin;
+ m_OnSlotChangedFnRef = a_FnRef;
+}
+
+
+
+
+
+bool cLuaWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
+{
+ // First notify the plugin through the registered callback:
+ if (m_OnClosingFnRef != LUA_REFNIL)
+ {
+ ASSERT(m_Plugin != NULL);
+ if (m_Plugin->CallbackWindowClosing(m_OnClosingFnRef, *this, a_Player, a_CanRefuse))
+ {
+ // The callback disagrees (the higher levels check the CanRefuse flag compliance)
+ return false;
+ }
+ }
+
+ return super::ClosedByPlayer(a_Player, a_CanRefuse);
+}
+
+
+
+
+
+void cLuaWindow::Destroy(void)
+{
+ super::Destroy();
+
+ if ((m_LuaRef != LUA_REFNIL) && (m_Plugin != NULL))
+ {
+ // The object is referenced by Lua, un-reference it
+ m_Plugin->Unreference(m_LuaRef);
+ }
+
+ // Lua will take care of this object, it will garbage-collect it, so we *must not* delete it!
+ m_IsDestroyed = false;
+}
+
+
+
+
+
+void cLuaWindow::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
+{
+ if (a_ItemGrid != &m_Contents)
+ {
+ ASSERT(!"Invalid ItemGrid in callback");
+ return;
+ }
+
+ // If an OnSlotChanged callback has been registered, call it:
+ if (m_OnSlotChangedFnRef != LUA_REFNIL)
+ {
+ m_Plugin->CallbackWindowSlotChanged(m_OnSlotChangedFnRef, *this, a_SlotNum);
+ }
+}
+
+
+
+
diff --git a/source/LuaWindow.h b/source/LuaWindow.h
index de24170df..60c24996d 100644
--- a/source/LuaWindow.h
+++ b/source/LuaWindow.h
@@ -1,96 +1,96 @@
-
-// LuaWindow.h
-
-// Declares the cLuaWindow class representing a virtual window that plugins may create and open for the player
-
-
-
-
-
-#pragma once
-
-#include "UI/Window.h"
-#include "ItemGrid.h"
-
-
-
-
-
-// fwd: Plugin_NewLua.h
-class cPlugin_NewLua;
-
-
-
-
-
-// tolua_begin
-
-/** A window that has been created by a Lua plugin and is handled entirely by that plugin
-This object needs extra care with its lifetime management:
-- It is created by Lua, so Lua expects to garbage-collect it later
-- normal cWindow objects are deleted in their ClosedByPlayer() function if the last player closes them
-To overcome this, this object overloads the Destroy functions, which doesn't let the ClosedByPlayer()
-delete the window, but rather leaves it dangling, with only Lua having the reference to it.
-Additionally, to forbid Lua from deleting this object while it is used by players, the manual bindings for
-cPlayer:OpenWindow check if the window is of this class, and if so, make a global Lua reference for this object.
-This reference needs to be unreferenced in the Destroy() function.
-*/
-class cLuaWindow :
- public cWindow,
- public cItemGrid::cListener
-{
- typedef cWindow super;
-
-public:
- /// Create a window of the specified type, with a slot grid of a_SlotsX * a_SlotsY size
- cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title);
-
- virtual ~cLuaWindow();
-
- /// Returns the internal representation of the contents that are manipulated by Lua
- cItemGrid & GetContents(void) { return m_Contents; }
-
- // tolua_end
-
- /** Sets the plugin reference and the internal Lua object reference index
- used for preventing Lua's GC to collect this class while the window is open
- */
- void SetLuaRef(cPlugin_NewLua * a_Plugin, int a_LuaRef);
-
- /// Returns true if SetLuaRef() has been called
- bool IsLuaReferenced(void) const;
-
- /// Sets the callback function (Lua reference) to call when the window is about to close
- void SetOnClosing(cPlugin_NewLua * a_Plugin, int a_FnRef);
-
- /// Sets the callback function (Lua reference) to call when a slot is changed
- void SetOnSlotChanged(cPlugin_NewLua * a_Plugin, int a_FnRef);
-
-protected:
- /// Contents of the non-inventory part
- cItemGrid m_Contents;
-
- /// The plugin that has opened the window and owns the m_LuaRef
- cPlugin_NewLua * m_Plugin;
-
- /// The Lua object reference, used for keeping the object alive as long as any player has the window open
- int m_LuaRef;
-
- /// The Lua reference for the callback to call when the window is closing for any player
- int m_OnClosingFnRef;
-
- /// The Lua reference for the callback to call when a slot has changed
- int m_OnSlotChangedFnRef;
-
- // cWindow overrides:
- virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override;
- virtual void Destroy(void) override;
-
- // cItemGrid::cListener overrides:
- virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
-} ; // tolua_export
-
-
-
-
-
+
+// LuaWindow.h
+
+// Declares the cLuaWindow class representing a virtual window that plugins may create and open for the player
+
+
+
+
+
+#pragma once
+
+#include "UI/Window.h"
+#include "ItemGrid.h"
+
+
+
+
+
+// fwd: Plugin_NewLua.h
+class cPlugin_NewLua;
+
+
+
+
+
+// tolua_begin
+
+/** A window that has been created by a Lua plugin and is handled entirely by that plugin
+This object needs extra care with its lifetime management:
+- It is created by Lua, so Lua expects to garbage-collect it later
+- normal cWindow objects are deleted in their ClosedByPlayer() function if the last player closes them
+To overcome this, this object overloads the Destroy functions, which doesn't let the ClosedByPlayer()
+delete the window, but rather leaves it dangling, with only Lua having the reference to it.
+Additionally, to forbid Lua from deleting this object while it is used by players, the manual bindings for
+cPlayer:OpenWindow check if the window is of this class, and if so, make a global Lua reference for this object.
+This reference needs to be unreferenced in the Destroy() function.
+*/
+class cLuaWindow :
+ public cWindow,
+ public cItemGrid::cListener
+{
+ typedef cWindow super;
+
+public:
+ /// Create a window of the specified type, with a slot grid of a_SlotsX * a_SlotsY size
+ cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title);
+
+ virtual ~cLuaWindow();
+
+ /// Returns the internal representation of the contents that are manipulated by Lua
+ cItemGrid & GetContents(void) { return m_Contents; }
+
+ // tolua_end
+
+ /** Sets the plugin reference and the internal Lua object reference index
+ used for preventing Lua's GC to collect this class while the window is open
+ */
+ void SetLuaRef(cPlugin_NewLua * a_Plugin, int a_LuaRef);
+
+ /// Returns true if SetLuaRef() has been called
+ bool IsLuaReferenced(void) const;
+
+ /// Sets the callback function (Lua reference) to call when the window is about to close
+ void SetOnClosing(cPlugin_NewLua * a_Plugin, int a_FnRef);
+
+ /// Sets the callback function (Lua reference) to call when a slot is changed
+ void SetOnSlotChanged(cPlugin_NewLua * a_Plugin, int a_FnRef);
+
+protected:
+ /// Contents of the non-inventory part
+ cItemGrid m_Contents;
+
+ /// The plugin that has opened the window and owns the m_LuaRef
+ cPlugin_NewLua * m_Plugin;
+
+ /// The Lua object reference, used for keeping the object alive as long as any player has the window open
+ int m_LuaRef;
+
+ /// The Lua reference for the callback to call when the window is closing for any player
+ int m_OnClosingFnRef;
+
+ /// The Lua reference for the callback to call when a slot has changed
+ int m_OnSlotChangedFnRef;
+
+ // cWindow overrides:
+ virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override;
+ virtual void Destroy(void) override;
+
+ // cItemGrid::cListener overrides:
+ virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
+} ; // tolua_export
+
+
+
+
+
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index 30648a8b7..7a13d94c0 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -1272,6 +1272,59 @@ 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,0);
+
+ const cWebAdmin::PluginList & AllPlugins = self->GetPlugins();
+
+ lua_createtable(tolua_S, AllPlugins.size(), 0);
+ int newTable = lua_gettop(tolua_S);
+ int index = 1;
+ cWebAdmin::PluginList::const_iterator iter = AllPlugins.begin();
+ while(iter != AllPlugins.end())
+ {
+ const cWebPlugin* Plugin = *iter;
+ tolua_pushusertype( tolua_S, (void*)Plugin, "const cWebPlugin" );
+ lua_rawseti(tolua_S, newTable, index);
+ ++iter;
+ ++index;
+ }
+ return 1;
+}
+
+
+
+
+
+static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
+{
+ cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+
+ const cWebPlugin::TabNameList & TabNames = self->GetTabNames();
+
+ lua_newtable(tolua_S);
+ int newTable = lua_gettop(tolua_S);
+ int index = 1;
+ cWebPlugin::TabNameList::const_iterator iter = TabNames.begin();
+ 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() );
+ //
+ lua_rawset(tolua_S, -3);
+ ++iter;
+ ++index;
+ }
+ return 1;
+}
+
+
+
+
+
static int Lua_ItemGrid_GetSlotCoords(lua_State * L)
{
tolua_Error tolua_err;
@@ -1377,6 +1430,14 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_variable(tolua_S,"PostParams",tolua_get_HTTPRequest_PostParams,0);
tolua_variable(tolua_S,"FormData",tolua_get_HTTPRequest_FormData,0);
tolua_endmodule(tolua_S);
+
+ tolua_beginmodule(tolua_S, "cWebAdmin");
+ tolua_function(tolua_S, "GetPlugins", tolua_cWebAdmin_GetPlugins);
+ tolua_endmodule(tolua_S);
+
+ tolua_beginmodule(tolua_S, "cWebPlugin");
+ tolua_function(tolua_S, "GetTabNames", tolua_cWebPlugin_GetTabNames);
+ tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cClientHandle");
tolua_constant(tolua_S, "MIN_VIEW_DISTANCE", cClientHandle::MIN_VIEW_DISTANCE);
diff --git a/source/Minecart.cpp b/source/Minecart.cpp
index 232f44f7d..bae56d582 100644
--- a/source/Minecart.cpp
+++ b/source/Minecart.cpp
@@ -1,160 +1,160 @@
-
-// Minecart.cpp
-
-// Implements the cMinecart class representing a minecart in the world
-
-#include "Globals.h"
-#include "Minecart.h"
-#include "World.h"
-#include "ClientHandle.h"
-#include "Player.h"
-
-
-
-
-
-cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
- super(etMinecart, a_X, a_Y, a_Z, 0.98, 0.7),
- m_Payload(a_Payload)
-{
-}
-
-
-
-
-void cMinecart::Initialize(cWorld * a_World)
-{
- super::Initialize(a_World);
- a_World->BroadcastSpawnEntity(*this);
-}
-
-
-
-
-
-void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
-{
- char Type = 0;
- switch (m_Payload)
- {
- case mpNone: Type = 10; break;
- case mpChest: Type = 11; break;
- case mpFurnace: Type = 12; break;
- default:
- {
- ASSERT(!"Unknown payload, cannot spawn on client");
- return;
- }
- }
- a_ClientHandle.SendSpawnVehicle(*this, Type);
-}
-
-
-
-
-
-void cMinecart::Tick(float a_Dt, cChunk & a_Chunk)
-{
- // TODO: the physics
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cEmptyMinecart:
-
-cEmptyMinecart::cEmptyMinecart(double a_X, double a_Y, double a_Z) :
- super(mpNone, a_X, a_Y, a_Z)
-{
-}
-
-
-
-
-
-void cEmptyMinecart::OnRightClicked(cPlayer & a_Player)
-{
- if (m_Attachee != NULL)
- {
- if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
- {
- // This player is already sitting in, they want out.
- a_Player.Detach();
- return;
- }
-
- if (m_Attachee->IsPlayer())
- {
- // Another player is already sitting in here, cannot attach
- return;
- }
-
- // Detach whatever is sitting in this minecart now:
- m_Attachee->Detach();
- }
-
- // Attach the player to this minecart
- a_Player.AttachTo(this);
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cMinecartWithChest:
-
-cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
- super(mpChest, a_X, a_Y, a_Z)
-{
-}
-
-
-
-
-
-void cMinecartWithChest::SetSlot(int a_Idx, const cItem & a_Item)
-{
- ASSERT((a_Idx >= 0) && (a_Idx < ARRAYCOUNT(m_Items)));
-
- m_Items[a_Idx] = a_Item;
-}
-
-
-
-
-
-void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
-{
- // Show the chest UI window to the player
- // TODO
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cMinecartWithFurnace:
-
-cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) :
- super(mpFurnace, a_X, a_Y, a_Z)
-{
-}
-
-
-
-
-
-void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player)
-{
- // Try to power the furnace with whatever the player is holding
- // TODO
-}
-
-
-
-
-
+
+// Minecart.cpp
+
+// Implements the cMinecart class representing a minecart in the world
+
+#include "Globals.h"
+#include "Minecart.h"
+#include "World.h"
+#include "ClientHandle.h"
+#include "Player.h"
+
+
+
+
+
+cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
+ super(etMinecart, a_X, a_Y, a_Z, 0.98, 0.7),
+ m_Payload(a_Payload)
+{
+}
+
+
+
+
+void cMinecart::Initialize(cWorld * a_World)
+{
+ super::Initialize(a_World);
+ a_World->BroadcastSpawnEntity(*this);
+}
+
+
+
+
+
+void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
+{
+ char Type = 0;
+ switch (m_Payload)
+ {
+ case mpNone: Type = 10; break;
+ case mpChest: Type = 11; break;
+ case mpFurnace: Type = 12; break;
+ default:
+ {
+ ASSERT(!"Unknown payload, cannot spawn on client");
+ return;
+ }
+ }
+ a_ClientHandle.SendSpawnVehicle(*this, Type);
+}
+
+
+
+
+
+void cMinecart::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ // TODO: the physics
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cEmptyMinecart:
+
+cEmptyMinecart::cEmptyMinecart(double a_X, double a_Y, double a_Z) :
+ super(mpNone, a_X, a_Y, a_Z)
+{
+}
+
+
+
+
+
+void cEmptyMinecart::OnRightClicked(cPlayer & a_Player)
+{
+ if (m_Attachee != NULL)
+ {
+ if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
+ {
+ // This player is already sitting in, they want out.
+ a_Player.Detach();
+ return;
+ }
+
+ if (m_Attachee->IsPlayer())
+ {
+ // Another player is already sitting in here, cannot attach
+ return;
+ }
+
+ // Detach whatever is sitting in this minecart now:
+ m_Attachee->Detach();
+ }
+
+ // Attach the player to this minecart
+ a_Player.AttachTo(this);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cMinecartWithChest:
+
+cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
+ super(mpChest, a_X, a_Y, a_Z)
+{
+}
+
+
+
+
+
+void cMinecartWithChest::SetSlot(int a_Idx, const cItem & a_Item)
+{
+ ASSERT((a_Idx >= 0) && (a_Idx < ARRAYCOUNT(m_Items)));
+
+ m_Items[a_Idx] = a_Item;
+}
+
+
+
+
+
+void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
+{
+ // Show the chest UI window to the player
+ // TODO
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cMinecartWithFurnace:
+
+cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) :
+ super(mpFurnace, a_X, a_Y, a_Z)
+{
+}
+
+
+
+
+
+void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player)
+{
+ // Try to power the furnace with whatever the player is holding
+ // TODO
+}
+
+
+
+
+
diff --git a/source/Minecart.h b/source/Minecart.h
index db61997d8..b7b4c2b04 100644
--- a/source/Minecart.h
+++ b/source/Minecart.h
@@ -1,117 +1,117 @@
-
-// Minecart.h
-
-// Declares the cMinecart class representing a minecart in the world
-
-
-
-
-
-#pragma once
-
-#include "Entity.h"
-#include "Item.h"
-
-
-
-
-
-class cMinecart :
- public cEntity
-{
- typedef cEntity super;
-
-public:
- CLASS_PROTODEF(cMinecart);
-
- 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
- // TODO: Other 1.5 features: hopper, tnt, dispenser, spawner
- } ;
-
- // cEntity overrides:
- virtual void Initialize(cWorld * a_World) override;
- virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
-
- ePayload GetPayload(void) const { return m_Payload; }
-
-protected:
- ePayload m_Payload;
-
- cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z);
-} ;
-
-
-
-
-
-class cEmptyMinecart :
- public cMinecart
-{
- typedef cMinecart super;
-
-public:
- CLASS_PROTODEF(cEmptyMinecart);
-
- cEmptyMinecart(double a_X, double a_Y, double a_Z);
-
- // cEntity overrides:
- virtual void OnRightClicked(cPlayer & a_Player) override;
-} ;
-
-
-
-
-
-class cMinecartWithChest :
- public cMinecart
-{
- typedef cMinecart super;
-
-public:
- CLASS_PROTODEF(cMinecartWithChest);
-
- /// Number of item slots in the chest
- static const int NumSlots = 9 * 3;
-
- cMinecartWithChest(double a_X, double a_Y, double a_Z);
-
- const cItem & GetSlot(int a_Idx) const { return m_Items[a_Idx]; }
- cItem & GetSlot(int a_Idx) { return m_Items[a_Idx]; }
-
- void SetSlot(int a_Idx, const cItem & a_Item);
-
-protected:
-
- /// The chest contents:
- cItem m_Items[NumSlots];
-
- // cEntity overrides:
- virtual void OnRightClicked(cPlayer & a_Player) override;
-} ;
-
-
-
-
-
-class cMinecartWithFurnace :
- public cMinecart
-{
- typedef cMinecart super;
-
-public:
- CLASS_PROTODEF(cMinecartWithFurnace);
-
- cMinecartWithFurnace(double a_X, double a_Y, double a_Z);
-
- // cEntity overrides:
- virtual void OnRightClicked(cPlayer & a_Player) override;
-} ;
-
-
-
-
+
+// Minecart.h
+
+// Declares the cMinecart class representing a minecart in the world
+
+
+
+
+
+#pragma once
+
+#include "Entity.h"
+#include "Item.h"
+
+
+
+
+
+class cMinecart :
+ public cEntity
+{
+ typedef cEntity super;
+
+public:
+ CLASS_PROTODEF(cMinecart);
+
+ 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
+ // TODO: Other 1.5 features: hopper, tnt, dispenser, spawner
+ } ;
+
+ // cEntity overrides:
+ virtual void Initialize(cWorld * a_World) override;
+ virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+
+ ePayload GetPayload(void) const { return m_Payload; }
+
+protected:
+ ePayload m_Payload;
+
+ cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z);
+} ;
+
+
+
+
+
+class cEmptyMinecart :
+ public cMinecart
+{
+ typedef cMinecart super;
+
+public:
+ CLASS_PROTODEF(cEmptyMinecart);
+
+ cEmptyMinecart(double a_X, double a_Y, double a_Z);
+
+ // cEntity overrides:
+ virtual void OnRightClicked(cPlayer & a_Player) override;
+} ;
+
+
+
+
+
+class cMinecartWithChest :
+ public cMinecart
+{
+ typedef cMinecart super;
+
+public:
+ CLASS_PROTODEF(cMinecartWithChest);
+
+ /// Number of item slots in the chest
+ static const int NumSlots = 9 * 3;
+
+ cMinecartWithChest(double a_X, double a_Y, double a_Z);
+
+ const cItem & GetSlot(int a_Idx) const { return m_Items[a_Idx]; }
+ cItem & GetSlot(int a_Idx) { return m_Items[a_Idx]; }
+
+ void SetSlot(int a_Idx, const cItem & a_Item);
+
+protected:
+
+ /// The chest contents:
+ cItem m_Items[NumSlots];
+
+ // cEntity overrides:
+ virtual void OnRightClicked(cPlayer & a_Player) override;
+} ;
+
+
+
+
+
+class cMinecartWithFurnace :
+ public cMinecart
+{
+ typedef cMinecart super;
+
+public:
+ CLASS_PROTODEF(cMinecartWithFurnace);
+
+ cMinecartWithFurnace(double a_X, double a_Y, double a_Z);
+
+ // cEntity overrides:
+ virtual void OnRightClicked(cPlayer & a_Player) override;
+} ;
+
+
+
+
diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h
index df6745fe5..8e4cde29f 100644
--- a/source/Mobs/Bat.h
+++ b/source/Mobs/Bat.h
@@ -1,27 +1,27 @@
-
-#pragma once
-
-#include "PassiveMonster.h"
-
-
-
-
-
-class cBat :
- public cPassiveMonster
-{
- typedef cPassiveMonster super;
-
-public:
- cBat(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Bat", 65, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7)
- {
- }
-
- CLASS_PROTODEF(cBat);
-} ;
-
-
-
-
+
+#pragma once
+
+#include "PassiveMonster.h"
+
+
+
+
+
+class cBat :
+ public cPassiveMonster
+{
+ typedef cPassiveMonster super;
+
+public:
+ cBat(void) :
+ // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
+ super("Bat", 65, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7)
+ {
+ }
+
+ CLASS_PROTODEF(cBat);
+} ;
+
+
+
+
diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp
index 069ee8934..dbbccf417 100644
--- a/source/Mobs/Blaze.cpp
+++ b/source/Mobs/Blaze.cpp
@@ -1,27 +1,27 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Blaze.h"
-
-
-
-
-
-cBlaze::cBlaze(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Blaze", 61, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8)
-{
-}
-
-
-
-
-
-void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-{
- AddRandomDropItem(a_Drops, 0, 1, E_ITEM_BLAZE_ROD);
-}
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Blaze.h"
+
+
+
+
+
+cBlaze::cBlaze(void) :
+ // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
+ super("Blaze", 61, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8)
+{
+}
+
+
+
+
+
+void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+{
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_BLAZE_ROD);
+}
+
+
+
+
diff --git a/source/Mobs/Blaze.h b/source/Mobs/Blaze.h
index 8b7a15848..9df57530e 100644
--- a/source/Mobs/Blaze.h
+++ b/source/Mobs/Blaze.h
@@ -1,25 +1,25 @@
-
-#pragma once
-
-#include "AggressiveMonster.h"
-
-
-
-
-
-class cBlaze :
- public cAggressiveMonster
-{
- typedef cAggressiveMonster super;
-
-public:
- cBlaze(void);
-
- CLASS_PROTODEF(cBlaze);
-
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
-} ;
-
-
-
-
+
+#pragma once
+
+#include "AggressiveMonster.h"
+
+
+
+
+
+class cBlaze :
+ public cAggressiveMonster
+{
+ typedef cAggressiveMonster super;
+
+public:
+ cBlaze(void);
+
+ CLASS_PROTODEF(cBlaze);
+
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+} ;
+
+
+
+
diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp
index 156a29607..0b9b57e3c 100644
--- a/source/Mobs/Magmacube.cpp
+++ b/source/Mobs/Magmacube.cpp
@@ -1,27 +1,27 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Magmacube.h"
-
-
-
-
-
-cMagmacube::cMagmacube(int a_Size) :
- super("Magmacube", 62, "mob.magmacube.big", "mob.magmacube.big", 0.6 * a_Size, 0.6 * a_Size),
- m_Size(a_Size)
-{
-}
-
-
-
-
-
-void cMagmacube::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-{
- AddRandomDropItem(a_Drops, 0, 1, E_ITEM_MAGMA_CREAM);
-}
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Magmacube.h"
+
+
+
+
+
+cMagmacube::cMagmacube(int a_Size) :
+ super("Magmacube", 62, "mob.magmacube.big", "mob.magmacube.big", 0.6 * a_Size, 0.6 * a_Size),
+ m_Size(a_Size)
+{
+}
+
+
+
+
+
+void cMagmacube::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+{
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_MAGMA_CREAM);
+}
+
+
+
+
diff --git a/source/Mobs/Magmacube.h b/source/Mobs/Magmacube.h
index da62b9615..e4df4f33d 100644
--- a/source/Mobs/Magmacube.h
+++ b/source/Mobs/Magmacube.h
@@ -1,31 +1,31 @@
-
-#pragma once
-
-#include "AggressiveMonster.h"
-
-
-
-
-
-class cMagmacube :
- public cAggressiveMonster
-{
- typedef cAggressiveMonster super;
-
-public:
- /// Creates a magmacube of the specified size; size is 1 .. 3, with 1 being the smallest
- cMagmacube(int a_Size);
-
- CLASS_PROTODEF(cMagmacube);
-
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
-
-protected:
-
- /// Size of the magmacube, 1 .. 3, with 1 being the smallest
- int m_Size;
-} ;
-
-
-
-
+
+#pragma once
+
+#include "AggressiveMonster.h"
+
+
+
+
+
+class cMagmacube :
+ public cAggressiveMonster
+{
+ typedef cAggressiveMonster super;
+
+public:
+ /// Creates a magmacube of the specified size; size is 1 .. 3, with 1 being the smallest
+ cMagmacube(int a_Size);
+
+ CLASS_PROTODEF(cMagmacube);
+
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+
+protected:
+
+ /// Size of the magmacube, 1 .. 3, with 1 being the smallest
+ int m_Size;
+} ;
+
+
+
+
diff --git a/source/Mobs/Mooshroom.cpp b/source/Mobs/Mooshroom.cpp
index c85ceda3a..5d2c901ba 100644
--- a/source/Mobs/Mooshroom.cpp
+++ b/source/Mobs/Mooshroom.cpp
@@ -1,33 +1,33 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Mooshroom.h"
-
-
-
-
-
-// TODO: Milk Cow
-
-
-
-
-
-cMooshroom::cMooshroom(void) :
- super("Mooshroom", 96, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
-{
-}
-
-
-
-
-
-void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-{
- AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
- AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
-}
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Mooshroom.h"
+
+
+
+
+
+// TODO: Milk Cow
+
+
+
+
+
+cMooshroom::cMooshroom(void) :
+ super("Mooshroom", 96, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
+{
+}
+
+
+
+
+
+void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+{
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
+ AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
+}
+
+
+
+
diff --git a/source/Mobs/Mooshroom.h b/source/Mobs/Mooshroom.h
index 20fc293b9..73f6348b6 100644
--- a/source/Mobs/Mooshroom.h
+++ b/source/Mobs/Mooshroom.h
@@ -1,25 +1,25 @@
-
-#pragma once
-
-#include "PassiveMonster.h"
-
-
-
-
-
-class cMooshroom :
- public cPassiveMonster
-{
- typedef cPassiveMonster super;
-
-public:
- cMooshroom(void);
-
- CLASS_PROTODEF(cMooshroom);
-
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
-} ;
-
-
-
-
+
+#pragma once
+
+#include "PassiveMonster.h"
+
+
+
+
+
+class cMooshroom :
+ public cPassiveMonster
+{
+ typedef cPassiveMonster super;
+
+public:
+ cMooshroom(void);
+
+ CLASS_PROTODEF(cMooshroom);
+
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+} ;
+
+
+
+
diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h
index 4d22575f2..98ea224e2 100644
--- a/source/Mobs/Ocelot.h
+++ b/source/Mobs/Ocelot.h
@@ -1,27 +1,27 @@
-
-#pragma once
-
-#include "PassiveMonster.h"
-
-
-
-
-
-class cOcelot :
- public cPassiveMonster
-{
- typedef cPassiveMonster super;
-
-public:
- cOcelot(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Ocelot", 98, "mob.cat.hitt", "mob.cat.hitt", 0.9, 0.5)
- {
- }
-
- CLASS_PROTODEF(cOcelot);
-} ;
-
-
-
-
+
+#pragma once
+
+#include "PassiveMonster.h"
+
+
+
+
+
+class cOcelot :
+ public cPassiveMonster
+{
+ typedef cPassiveMonster super;
+
+public:
+ cOcelot(void) :
+ // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
+ super("Ocelot", 98, "mob.cat.hitt", "mob.cat.hitt", 0.9, 0.5)
+ {
+ }
+
+ CLASS_PROTODEF(cOcelot);
+} ;
+
+
+
+
diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp
index 0ec2cf76c..98e5276e1 100644
--- a/source/Mobs/Villager.cpp
+++ b/source/Mobs/Villager.cpp
@@ -1,17 +1,17 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Villager.h"
-
-
-
-
-
-cVillager::cVillager(void) :
- super("Villager", 120, "", "", 0.6, 1.8)
-{
-}
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Villager.h"
+
+
+
+
+
+cVillager::cVillager(void) :
+ super("Villager", 120, "", "", 0.6, 1.8)
+{
+}
+
+
+
+
diff --git a/source/Mobs/Villager.h b/source/Mobs/Villager.h
index 4b50ed35e..92267a979 100644
--- a/source/Mobs/Villager.h
+++ b/source/Mobs/Villager.h
@@ -1,23 +1,23 @@
-
-#pragma once
-
-#include "PassiveMonster.h"
-
-
-
-
-
-class cVillager :
- public cPassiveMonster
-{
- typedef cPassiveMonster super;
-
-public:
- cVillager();
-
- CLASS_PROTODEF(cVillager);
-} ;
-
-
-
-
+
+#pragma once
+
+#include "PassiveMonster.h"
+
+
+
+
+
+class cVillager :
+ public cPassiveMonster
+{
+ typedef cPassiveMonster super;
+
+public:
+ cVillager();
+
+ CLASS_PROTODEF(cVillager);
+} ;
+
+
+
+
diff --git a/source/Mobs/Witch.cpp b/source/Mobs/Witch.cpp
index 66295ed1b..b29783853 100644
--- a/source/Mobs/Witch.cpp
+++ b/source/Mobs/Witch.cpp
@@ -1,32 +1,32 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Witch.h"
-
-
-
-
-
-cWitch::cWitch(void) :
- super("Witch", 66, "", "", 0.6, 1.8)
-{
-}
-
-
-
-
-
-void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-{
- AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLASS_BOTTLE);
- AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLOWSTONE_DUST);
- AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GUNPOWDER);
- AddRandomDropItem(a_Drops, 0, 6, E_ITEM_REDSTONE_DUST);
- AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SPIDER_EYE);
- AddRandomDropItem(a_Drops, 0, 6, E_ITEM_STICK);
- AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SUGAR);
-}
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Witch.h"
+
+
+
+
+
+cWitch::cWitch(void) :
+ super("Witch", 66, "", "", 0.6, 1.8)
+{
+}
+
+
+
+
+
+void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+{
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLASS_BOTTLE);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLOWSTONE_DUST);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GUNPOWDER);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_REDSTONE_DUST);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SPIDER_EYE);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_STICK);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SUGAR);
+}
+
+
+
+
diff --git a/source/Mobs/Witch.h b/source/Mobs/Witch.h
index 2ca2c081f..ce0b49deb 100644
--- a/source/Mobs/Witch.h
+++ b/source/Mobs/Witch.h
@@ -1,25 +1,25 @@
-
-#pragma once
-
-#include "AggressiveMonster.h"
-
-
-
-
-
-class cWitch :
- public cAggressiveMonster
-{
- typedef cAggressiveMonster super;
-
-public:
- cWitch();
-
- CLASS_PROTODEF(cWitch);
-
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
-} ;
-
-
-
-
+
+#pragma once
+
+#include "AggressiveMonster.h"
+
+
+
+
+
+class cWitch :
+ public cAggressiveMonster
+{
+ typedef cAggressiveMonster super;
+
+public:
+ cWitch();
+
+ CLASS_PROTODEF(cWitch);
+
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+} ;
+
+
+
+
diff --git a/source/OSSupport/GZipFile.cpp b/source/OSSupport/GZipFile.cpp
index c57de5198..cbf6be6c4 100644
--- a/source/OSSupport/GZipFile.cpp
+++ b/source/OSSupport/GZipFile.cpp
@@ -1,107 +1,107 @@
-
-// GZipFile.cpp
-
-// Implements the cGZipFile class representing a RAII wrapper over zlib's GZip file routines
-
-#include "Globals.h"
-#include "GZipFile.h"
-
-
-
-
-
-cGZipFile::cGZipFile(void) :
- m_File(NULL)
-{
-}
-
-
-
-
-
-cGZipFile::~cGZipFile()
-{
- Close();
-}
-
-
-
-
-
-bool cGZipFile::Open(const AString & a_FileName, eMode a_Mode)
-{
- if (m_File != NULL)
- {
- ASSERT(!"A file is already open in this object");
- return false;
- }
- m_File = gzopen(a_FileName.c_str(), (a_Mode == fmRead) ? "r" : "w");
- m_Mode = a_Mode;
- return (m_File != NULL);
-}
-
-
-
-
-
-void cGZipFile::Close(void)
-{
- if (m_File != NULL)
- {
- gzclose(m_File);
- m_File = NULL;
- }
-}
-
-
-
-
-
-int cGZipFile::ReadRestOfFile(AString & a_Contents)
-{
- if (m_File == NULL)
- {
- ASSERT(!"No file has been opened");
- return -1;
- }
-
- if (m_Mode != fmRead)
- {
- ASSERT(!"Bad file mode, cannot read");
- return -1;
- }
-
- // Since the gzip format doesn't really support getting the uncompressed length, we need to read incrementally. Yuck!
- int NumBytesRead = 0;
- char Buffer[64 KiB];
- while ((NumBytesRead = gzread(m_File, Buffer, sizeof(Buffer))) > 0)
- {
- a_Contents.append(Buffer, NumBytesRead);
- }
- return NumBytesRead;
-}
-
-
-
-
-
-bool cGZipFile::Write(const char * a_Contents, int a_Size)
-{
- if (m_File == NULL)
- {
- ASSERT(!"No file has been opened");
- return false;
- }
-
- if (m_Mode != fmWrite)
- {
- ASSERT(!"Bad file mode, cannot write");
- return false;
- }
-
- return (gzwrite(m_File, a_Contents, a_Size) != 0);
-}
-
-
-
-
+
+// GZipFile.cpp
+
+// Implements the cGZipFile class representing a RAII wrapper over zlib's GZip file routines
+
+#include "Globals.h"
+#include "GZipFile.h"
+
+
+
+
+
+cGZipFile::cGZipFile(void) :
+ m_File(NULL)
+{
+}
+
+
+
+
+
+cGZipFile::~cGZipFile()
+{
+ Close();
+}
+
+
+
+
+
+bool cGZipFile::Open(const AString & a_FileName, eMode a_Mode)
+{
+ if (m_File != NULL)
+ {
+ ASSERT(!"A file is already open in this object");
+ return false;
+ }
+ m_File = gzopen(a_FileName.c_str(), (a_Mode == fmRead) ? "r" : "w");
+ m_Mode = a_Mode;
+ return (m_File != NULL);
+}
+
+
+
+
+
+void cGZipFile::Close(void)
+{
+ if (m_File != NULL)
+ {
+ gzclose(m_File);
+ m_File = NULL;
+ }
+}
+
+
+
+
+
+int cGZipFile::ReadRestOfFile(AString & a_Contents)
+{
+ if (m_File == NULL)
+ {
+ ASSERT(!"No file has been opened");
+ return -1;
+ }
+
+ if (m_Mode != fmRead)
+ {
+ ASSERT(!"Bad file mode, cannot read");
+ return -1;
+ }
+
+ // Since the gzip format doesn't really support getting the uncompressed length, we need to read incrementally. Yuck!
+ int NumBytesRead = 0;
+ char Buffer[64 KiB];
+ while ((NumBytesRead = gzread(m_File, Buffer, sizeof(Buffer))) > 0)
+ {
+ a_Contents.append(Buffer, NumBytesRead);
+ }
+ return NumBytesRead;
+}
+
+
+
+
+
+bool cGZipFile::Write(const char * a_Contents, int a_Size)
+{
+ if (m_File == NULL)
+ {
+ ASSERT(!"No file has been opened");
+ return false;
+ }
+
+ if (m_Mode != fmWrite)
+ {
+ ASSERT(!"Bad file mode, cannot write");
+ return false;
+ }
+
+ return (gzwrite(m_File, a_Contents, a_Size) != 0);
+}
+
+
+
+
diff --git a/source/OSSupport/GZipFile.h b/source/OSSupport/GZipFile.h
index f20b4d11e..e5aa68afa 100644
--- a/source/OSSupport/GZipFile.h
+++ b/source/OSSupport/GZipFile.h
@@ -1,52 +1,52 @@
-
-// GZipFile.h
-
-// Declares the cGZipFile class representing a RAII wrapper over zlib's GZip file routines
-
-
-
-
-
-#pragma once
-
-#include "zlib.h"
-
-
-
-
-
-class cGZipFile
-{
-public:
- enum eMode
- {
- fmRead, // Read-only. If the file doesn't exist, object will not be valid
- fmWrite, // Write-only. If the file already exists, it will be overwritten
- } ;
-
- cGZipFile(void);
- ~cGZipFile();
-
- /// Opens the file. Returns true if successful. Fails if a file has already been opened through this object.
- bool Open(const AString & a_FileName, eMode a_Mode);
-
- /// Closes the file, flushing all buffers. This object may be then reused for a different file and / or mode
- void Close(void);
-
- /// Reads the rest of the file and decompresses it into a_Contents. Returns the number of decompressed bytes, <0 for error
- int ReadRestOfFile(AString & a_Contents);
-
- /// Writes a_Contents into file, compressing it along the way. Returns true if successful. Multiple writes are supported.
- bool Write(const AString & a_Contents) { return Write(a_Contents.data(), (int)(a_Contents.size())); }
-
- bool Write(const char * a_Data, int a_Size);
-
-protected:
- gzFile m_File;
- eMode m_Mode;
-} ;
-
-
-
-
-
+
+// GZipFile.h
+
+// Declares the cGZipFile class representing a RAII wrapper over zlib's GZip file routines
+
+
+
+
+
+#pragma once
+
+#include "zlib.h"
+
+
+
+
+
+class cGZipFile
+{
+public:
+ enum eMode
+ {
+ fmRead, // Read-only. If the file doesn't exist, object will not be valid
+ fmWrite, // Write-only. If the file already exists, it will be overwritten
+ } ;
+
+ cGZipFile(void);
+ ~cGZipFile();
+
+ /// Opens the file. Returns true if successful. Fails if a file has already been opened through this object.
+ bool Open(const AString & a_FileName, eMode a_Mode);
+
+ /// Closes the file, flushing all buffers. This object may be then reused for a different file and / or mode
+ void Close(void);
+
+ /// Reads the rest of the file and decompresses it into a_Contents. Returns the number of decompressed bytes, <0 for error
+ int ReadRestOfFile(AString & a_Contents);
+
+ /// Writes a_Contents into file, compressing it along the way. Returns true if successful. Multiple writes are supported.
+ bool Write(const AString & a_Contents) { return Write(a_Contents.data(), (int)(a_Contents.size())); }
+
+ bool Write(const char * a_Data, int a_Size);
+
+protected:
+ gzFile m_File;
+ eMode m_Mode;
+} ;
+
+
+
+
+
diff --git a/source/OSSupport/ListenThread.cpp b/source/OSSupport/ListenThread.cpp
index 89aa6ea75..4542326ef 100644
--- a/source/OSSupport/ListenThread.cpp
+++ b/source/OSSupport/ListenThread.cpp
@@ -1,231 +1,231 @@
-
-// ListenThread.cpp
-
-// Implements the cListenThread class representing the thread that listens for client connections
-
-#include "Globals.h"
-#include "ListenThread.h"
-
-
-
-
-
-cListenThread::cListenThread(cCallback & a_Callback, cSocket::eFamily a_Family, const AString & a_ServiceName) :
- super(Printf("ListenThread %s", a_ServiceName.c_str())),
- m_Callback(a_Callback),
- m_Family(a_Family),
- m_ShouldReuseAddr(false),
- m_ServiceName(a_ServiceName)
-{
-}
-
-
-
-
-
-cListenThread::~cListenThread()
-{
- // TODO
-}
-
-
-
-
-
-bool cListenThread::Initialize(const AString & a_PortsString)
-{
- ASSERT(m_Sockets.empty()); // Not yet started
-
- if (!CreateSockets(a_PortsString))
- {
- return false;
- }
-
- return true;
-}
-
-
-
-
-
-bool cListenThread::Start(void)
-{
- if (m_Sockets.empty())
- {
- // There are no sockets listening, either forgotten to initialize or the user specified no listening ports
- // Report as successful, though
- return true;
- }
- return super::Start();
-}
-
-
-
-
-
-void cListenThread::Stop(void)
-{
- if (m_Sockets.empty())
- {
- // No sockets means no thread was running in the first place
- return;
- }
-
- m_ShouldTerminate = true;
-
- // Close one socket to wake the thread up from the select() call
- m_Sockets[0].CloseSocket();
-
- // Wait for the thread to finish
- super::Wait();
-
- // Clean up all sockets
- m_Sockets.clear();
-}
-
-
-
-
-
-void cListenThread::SetReuseAddr(bool a_Reuse)
-{
- ASSERT(m_Sockets.empty()); // Must not have been Initialize()d yet
-
- m_ShouldReuseAddr = a_Reuse;
-}
-
-
-
-
-
-bool cListenThread::CreateSockets(const AString & a_PortsString)
-{
- AStringVector Ports = StringSplitAndTrim(a_PortsString, ",");
-
- if (Ports.empty())
- {
- return false;
- }
-
- AString FamilyStr = m_ServiceName;
- switch (m_Family)
- {
- case cSocket::IPv4: FamilyStr.append(" IPv4"); break;
- case cSocket::IPv6: FamilyStr.append(" IPv6"); break;
- default:
- {
- ASSERT(!"Unknown address family");
- break;
- }
- }
-
- for (AStringVector::const_iterator itr = Ports.begin(), end = Ports.end(); itr != end; ++itr)
- {
- int Port = atoi(itr->c_str());
- if ((Port <= 0) || (Port > 65535))
- {
- LOGWARNING("%s: Invalid port specified: \"%s\".", FamilyStr.c_str(), itr->c_str());
- continue;
- }
- m_Sockets.push_back(cSocket::CreateSocket(m_Family));
- if (!m_Sockets.back().IsValid())
- {
- LOGWARNING("%s: Cannot create listening socket for port %d: \"%s\"", FamilyStr.c_str(), Port, cSocket::GetLastErrorString().c_str());
- m_Sockets.pop_back();
- continue;
- }
-
- if (m_ShouldReuseAddr)
- {
- if (!m_Sockets.back().SetReuseAddress())
- {
- LOG("%s: Port %d cannot reuse addr, syscall failed: \"%s\".", FamilyStr.c_str(), Port, cSocket::GetLastErrorString().c_str());
- }
- }
-
- // Bind to port:
- bool res = false;
- switch (m_Family)
- {
- case cSocket::IPv4: res = m_Sockets.back().BindToAnyIPv4(Port); break;
- case cSocket::IPv6: res = m_Sockets.back().BindToAnyIPv6(Port); break;
- default:
- {
- ASSERT(!"Unknown address family");
- res = false;
- }
- }
- if (!res)
- {
- LOGWARNING("%s: Cannot bind port %d: \"%s\".", FamilyStr.c_str(), Port, cSocket::GetLastErrorString().c_str());
- m_Sockets.pop_back();
- continue;
- }
-
- if (!m_Sockets.back().Listen())
- {
- LOGWARNING("%s: Cannot listen on port %d: \"%s\".", FamilyStr.c_str(), Port, cSocket::GetLastErrorString().c_str());
- m_Sockets.pop_back();
- continue;
- }
-
- LOGINFO("%s: Port %d is open for connections", FamilyStr.c_str(), Port);
- } // for itr - Ports[]
-
- return !(m_Sockets.empty());
-}
-
-
-
-
-
-void cListenThread::Execute(void)
-{
- if (m_Sockets.empty())
- {
- LOGD("Empty cListenThread, ending thread now.");
- return;
- }
-
- // Find the highest socket number:
- cSocket::xSocket Highest = m_Sockets[0].GetSocket();
- for (cSockets::iterator itr = m_Sockets.begin(), end = m_Sockets.end(); itr != end; ++itr)
- {
- if (itr->GetSocket() > Highest)
- {
- Highest = itr->GetSocket();
- }
- } // for itr - m_Sockets[]
-
- while (!m_ShouldTerminate)
- {
- // Put all sockets into a FD set:
- fd_set fdRead;
- FD_ZERO(&fdRead);
- for (cSockets::iterator itr = m_Sockets.begin(), end = m_Sockets.end(); itr != end; ++itr)
- {
- FD_SET(itr->GetSocket(), &fdRead);
- } // for itr - m_Sockets[]
-
- 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)
- {
- LOG("select(R) call failed in cListenThread: \"%s\"", cSocket::GetLastErrorString().c_str());
- continue;
- }
- for (cSockets::iterator itr = m_Sockets.begin(), end = m_Sockets.end(); itr != end; ++itr)
- {
- if (itr->IsValid() && FD_ISSET(itr->GetSocket(), &fdRead))
- {
- cSocket Client = (m_Family == cSocket::IPv4) ? itr->AcceptIPv4() : itr->AcceptIPv6();
- m_Callback.OnConnectionAccepted(Client);
- }
- } // for itr - m_Sockets[]
- } // while (!m_ShouldTerminate)
-}
-
-
-
-
+
+// ListenThread.cpp
+
+// Implements the cListenThread class representing the thread that listens for client connections
+
+#include "Globals.h"
+#include "ListenThread.h"
+
+
+
+
+
+cListenThread::cListenThread(cCallback & a_Callback, cSocket::eFamily a_Family, const AString & a_ServiceName) :
+ super(Printf("ListenThread %s", a_ServiceName.c_str())),
+ m_Callback(a_Callback),
+ m_Family(a_Family),
+ m_ShouldReuseAddr(false),
+ m_ServiceName(a_ServiceName)
+{
+}
+
+
+
+
+
+cListenThread::~cListenThread()
+{
+ // TODO
+}
+
+
+
+
+
+bool cListenThread::Initialize(const AString & a_PortsString)
+{
+ ASSERT(m_Sockets.empty()); // Not yet started
+
+ if (!CreateSockets(a_PortsString))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+
+
+
+
+bool cListenThread::Start(void)
+{
+ if (m_Sockets.empty())
+ {
+ // There are no sockets listening, either forgotten to initialize or the user specified no listening ports
+ // Report as successful, though
+ return true;
+ }
+ return super::Start();
+}
+
+
+
+
+
+void cListenThread::Stop(void)
+{
+ if (m_Sockets.empty())
+ {
+ // No sockets means no thread was running in the first place
+ return;
+ }
+
+ m_ShouldTerminate = true;
+
+ // Close one socket to wake the thread up from the select() call
+ m_Sockets[0].CloseSocket();
+
+ // Wait for the thread to finish
+ super::Wait();
+
+ // Clean up all sockets
+ m_Sockets.clear();
+}
+
+
+
+
+
+void cListenThread::SetReuseAddr(bool a_Reuse)
+{
+ ASSERT(m_Sockets.empty()); // Must not have been Initialize()d yet
+
+ m_ShouldReuseAddr = a_Reuse;
+}
+
+
+
+
+
+bool cListenThread::CreateSockets(const AString & a_PortsString)
+{
+ AStringVector Ports = StringSplitAndTrim(a_PortsString, ",");
+
+ if (Ports.empty())
+ {
+ return false;
+ }
+
+ AString FamilyStr = m_ServiceName;
+ switch (m_Family)
+ {
+ case cSocket::IPv4: FamilyStr.append(" IPv4"); break;
+ case cSocket::IPv6: FamilyStr.append(" IPv6"); break;
+ default:
+ {
+ ASSERT(!"Unknown address family");
+ break;
+ }
+ }
+
+ for (AStringVector::const_iterator itr = Ports.begin(), end = Ports.end(); itr != end; ++itr)
+ {
+ int Port = atoi(itr->c_str());
+ if ((Port <= 0) || (Port > 65535))
+ {
+ LOGWARNING("%s: Invalid port specified: \"%s\".", FamilyStr.c_str(), itr->c_str());
+ continue;
+ }
+ m_Sockets.push_back(cSocket::CreateSocket(m_Family));
+ if (!m_Sockets.back().IsValid())
+ {
+ LOGWARNING("%s: Cannot create listening socket for port %d: \"%s\"", FamilyStr.c_str(), Port, cSocket::GetLastErrorString().c_str());
+ m_Sockets.pop_back();
+ continue;
+ }
+
+ if (m_ShouldReuseAddr)
+ {
+ if (!m_Sockets.back().SetReuseAddress())
+ {
+ LOG("%s: Port %d cannot reuse addr, syscall failed: \"%s\".", FamilyStr.c_str(), Port, cSocket::GetLastErrorString().c_str());
+ }
+ }
+
+ // Bind to port:
+ bool res = false;
+ switch (m_Family)
+ {
+ case cSocket::IPv4: res = m_Sockets.back().BindToAnyIPv4(Port); break;
+ case cSocket::IPv6: res = m_Sockets.back().BindToAnyIPv6(Port); break;
+ default:
+ {
+ ASSERT(!"Unknown address family");
+ res = false;
+ }
+ }
+ if (!res)
+ {
+ LOGWARNING("%s: Cannot bind port %d: \"%s\".", FamilyStr.c_str(), Port, cSocket::GetLastErrorString().c_str());
+ m_Sockets.pop_back();
+ continue;
+ }
+
+ if (!m_Sockets.back().Listen())
+ {
+ LOGWARNING("%s: Cannot listen on port %d: \"%s\".", FamilyStr.c_str(), Port, cSocket::GetLastErrorString().c_str());
+ m_Sockets.pop_back();
+ continue;
+ }
+
+ LOGINFO("%s: Port %d is open for connections", FamilyStr.c_str(), Port);
+ } // for itr - Ports[]
+
+ return !(m_Sockets.empty());
+}
+
+
+
+
+
+void cListenThread::Execute(void)
+{
+ if (m_Sockets.empty())
+ {
+ LOGD("Empty cListenThread, ending thread now.");
+ return;
+ }
+
+ // Find the highest socket number:
+ cSocket::xSocket Highest = m_Sockets[0].GetSocket();
+ for (cSockets::iterator itr = m_Sockets.begin(), end = m_Sockets.end(); itr != end; ++itr)
+ {
+ if (itr->GetSocket() > Highest)
+ {
+ Highest = itr->GetSocket();
+ }
+ } // for itr - m_Sockets[]
+
+ while (!m_ShouldTerminate)
+ {
+ // Put all sockets into a FD set:
+ fd_set fdRead;
+ FD_ZERO(&fdRead);
+ for (cSockets::iterator itr = m_Sockets.begin(), end = m_Sockets.end(); itr != end; ++itr)
+ {
+ FD_SET(itr->GetSocket(), &fdRead);
+ } // for itr - m_Sockets[]
+
+ 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)
+ {
+ LOG("select(R) call failed in cListenThread: \"%s\"", cSocket::GetLastErrorString().c_str());
+ continue;
+ }
+ for (cSockets::iterator itr = m_Sockets.begin(), end = m_Sockets.end(); itr != end; ++itr)
+ {
+ if (itr->IsValid() && FD_ISSET(itr->GetSocket(), &fdRead))
+ {
+ cSocket Client = (m_Family == cSocket::IPv4) ? itr->AcceptIPv4() : itr->AcceptIPv6();
+ m_Callback.OnConnectionAccepted(Client);
+ }
+ } // for itr - m_Sockets[]
+ } // while (!m_ShouldTerminate)
+}
+
+
+
+
diff --git a/source/OSSupport/ListenThread.h b/source/OSSupport/ListenThread.h
index c29140ed3..4e337d814 100644
--- a/source/OSSupport/ListenThread.h
+++ b/source/OSSupport/ListenThread.h
@@ -1,83 +1,83 @@
-
-// ListenThread.h
-
-// Declares the cListenThread class representing the thread that listens for client connections
-
-
-
-
-
-#pragma once
-
-#include "IsThread.h"
-#include "Socket.h"
-
-
-
-
-
-// fwd:
-class cServer;
-
-
-
-
-
-class cListenThread :
- public cIsThread
-{
- typedef cIsThread super;
-
-public:
- /// Used as the callback for connection events
- class cCallback
- {
- public:
- /// This callback is called whenever a socket connection is accepted
- virtual void OnConnectionAccepted(cSocket & a_Socket) = 0;
- } ;
-
- cListenThread(cCallback & a_Callback, cSocket::eFamily a_Family, const AString & a_ServiceName = "");
- ~cListenThread();
-
- /// Creates all the sockets, returns trus if successful, false if not.
- bool Initialize(const AString & a_PortsString);
-
- bool Start(void);
-
- void Stop(void);
-
- /// Call before Initialize() to set the "reuse" flag on the sockets
- void SetReuseAddr(bool a_Reuse = true);
-
-protected:
- typedef std::vector<cSocket> cSockets;
-
- /// The callback which to notify of incoming connections
- cCallback & m_Callback;
-
- /// Socket address family to use
- cSocket::eFamily m_Family;
-
- /// Sockets that are being monitored
- cSockets m_Sockets;
-
- /// If set to true, the SO_REUSEADDR socket option is set to true
- bool m_ShouldReuseAddr;
-
- /// Name of the service that's listening on the ports; for logging purposes only
- AString m_ServiceName;
-
-
- /** Fills in m_Sockets with individual sockets, each for one port specified in a_PortsString.
- Returns true if successful and at least one socket has been created
- */
- bool CreateSockets(const AString & a_PortsString);
-
- // cIsThread override:
- virtual void Execute(void) override;
-} ;
-
-
-
-
+
+// ListenThread.h
+
+// Declares the cListenThread class representing the thread that listens for client connections
+
+
+
+
+
+#pragma once
+
+#include "IsThread.h"
+#include "Socket.h"
+
+
+
+
+
+// fwd:
+class cServer;
+
+
+
+
+
+class cListenThread :
+ public cIsThread
+{
+ typedef cIsThread super;
+
+public:
+ /// Used as the callback for connection events
+ class cCallback
+ {
+ public:
+ /// This callback is called whenever a socket connection is accepted
+ virtual void OnConnectionAccepted(cSocket & a_Socket) = 0;
+ } ;
+
+ cListenThread(cCallback & a_Callback, cSocket::eFamily a_Family, const AString & a_ServiceName = "");
+ ~cListenThread();
+
+ /// Creates all the sockets, returns trus if successful, false if not.
+ bool Initialize(const AString & a_PortsString);
+
+ bool Start(void);
+
+ void Stop(void);
+
+ /// Call before Initialize() to set the "reuse" flag on the sockets
+ void SetReuseAddr(bool a_Reuse = true);
+
+protected:
+ typedef std::vector<cSocket> cSockets;
+
+ /// The callback which to notify of incoming connections
+ cCallback & m_Callback;
+
+ /// Socket address family to use
+ cSocket::eFamily m_Family;
+
+ /// Sockets that are being monitored
+ cSockets m_Sockets;
+
+ /// If set to true, the SO_REUSEADDR socket option is set to true
+ bool m_ShouldReuseAddr;
+
+ /// Name of the service that's listening on the ports; for logging purposes only
+ AString m_ServiceName;
+
+
+ /** Fills in m_Sockets with individual sockets, each for one port specified in a_PortsString.
+ Returns true if successful and at least one socket has been created
+ */
+ bool CreateSockets(const AString & a_PortsString);
+
+ // cIsThread override:
+ virtual void Execute(void) override;
+} ;
+
+
+
+
diff --git a/source/Player.cpp b/source/Player.cpp
index 83181dda6..d59204e35 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -1,1326 +1,1423 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Player.h"
-#include "Server.h"
-#include "ClientHandle.h"
-#include "UI/Window.h"
-#include "UI/WindowOwner.h"
-#include "World.h"
-#include "Pickup.h"
-#include "PluginManager.h"
-#include "BlockEntities/BlockEntity.h"
-#include "GroupManager.h"
-#include "Group.h"
-#include "ChatColor.h"
-#include "Item.h"
-#include "Tracer.h"
-#include "Root.h"
-#include "OSSupport/MakeDir.h"
-#include "OSSupport/Timer.h"
-#include "MersenneTwister.h"
-#include "Chunk.h"
-
-#include "Vector3d.h"
-#include "Vector3f.h"
-
-#include "../iniFile/iniFile.h"
-#include <json/json.h>
-
-#define float2int(x) ((x)<0 ? ((int)(x))-1 : (int)(x))
-
-
-
-
-
-cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
- : super(etPlayer, 0.6, 1.8)
- , m_GameMode(eGameMode_NotSet)
- , m_IP("")
- , m_LastBlockActionTime( 0 )
- , m_LastBlockActionCnt( 0 )
- , m_bVisible( true )
- , m_LastGroundHeight( 0 )
- , m_bTouchGround( false )
- , m_Stance( 0.0 )
- , m_Inventory(*this)
- , m_CurrentWindow(NULL)
- , m_InventoryWindow(NULL)
- , m_TimeLastPickupCheck( 0.f )
- , m_Color('-')
- , m_ClientHandle( a_Client )
- , m_FoodLevel(20)
- , m_FoodSaturationLevel(5)
- , m_FoodTickTimer(0)
- , m_FoodExhaustionLevel(0)
- , m_FoodPoisonedTicksRemaining(0)
- , m_NormalMaxSpeed(0.1)
- , m_SprintingMaxSpeed(0.13)
- , m_IsCrouched(false)
- , m_IsSprinting(false)
-{
- LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
- a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
- this, GetUniqueID()
- );
-
- m_InventoryWindow = new cInventoryWindow(*this);
- m_CurrentWindow = m_InventoryWindow;
- m_InventoryWindow->OpenedByPlayer(*this);
-
- SetMaxHealth(20);
-
- cTimer t1;
- m_LastPlayerListTime = t1.GetNowTime();
-
- m_TimeLastTeleportPacket = 0;
- m_TimeLastPickupCheck = 0;
-
- m_PlayerName = a_PlayerName;
- m_bDirtyPosition = true; // So chunks are streamed to player at spawn
-
- if (!LoadFromDisk())
- {
- m_Inventory.Clear();
- SetPosX(cRoot::Get()->GetDefaultWorld()->GetSpawnX());
- SetPosY(cRoot::Get()->GetDefaultWorld()->GetSpawnY());
- SetPosZ(cRoot::Get()->GetDefaultWorld()->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()
- );
- }
- m_LastJumpHeight = (float)(GetPosY());
- m_LastGroundHeight = (float)(GetPosY());
- m_Stance = GetPosY() + 1.62;
-}
-
-
-
-
-
-cPlayer::~cPlayer(void)
-{
- LOG("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID());
-
- SaveToDisk();
-
- m_World->RemovePlayer( this );
-
- m_ClientHandle = NULL;
-
- delete m_InventoryWindow;
-
- LOGD("Player %p deleted", this);
-}
-
-
-
-
-
-void cPlayer::Initialize(cWorld * a_World)
-{
- super::Initialize(a_World);
- GetWorld()->AddPlayer(this);
-}
-
-
-
-
-
-void cPlayer::Destroyed()
-{
- CloseWindow(false);
- m_ClientHandle = NULL;
-}
-
-
-
-
-
-void cPlayer::SpawnOn(cClientHandle & a_Client)
-{
- /*
- LOGD("cPlayer::SpawnOn(%s) for \"%s\" at pos {%.2f, %.2f, %.2f}",
- a_Client.GetUsername().c_str(), m_PlayerName.c_str(), m_Pos.x, m_Pos.y, m_Pos.z
- );
- */
-
- if (m_bVisible && (m_ClientHandle != (&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() );
- }
-}
-
-
-
-
-
-void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
-{
- if (!m_ClientHandle->IsPlaying())
- {
- // We're not yet in the game, ignore everything
- return;
- }
-
- super::Tick(a_Dt, a_Chunk);
- if (m_bDirtyPosition)
- {
- // Apply food exhaustion from movement:
- ApplyFoodExhaustionFromMovement(a_Chunk);
-
- cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this);
- BroadcastMovementUpdate(m_ClientHandle);
- m_ClientHandle->StreamChunks();
- }
- else
- {
- BroadcastMovementUpdate(m_ClientHandle);
- }
-
- if (m_Health > 0) // make sure player is alive
- {
- m_World->CollectPickupsByPlayer(this);
-
- HandleFood();
- }
-
- // Send Player List (Once per m_LastPlayerListTime/1000 ms)
- cTimer t1;
- if (m_LastPlayerListTime + cPlayer::PLAYER_LIST_TIME_MS <= t1.GetNowTime())
- {
- m_World->SendPlayerList(this);
- m_LastPlayerListTime = t1.GetNowTime();
- }
-}
-
-
-
-
-
-void cPlayer::SetTouchGround(bool a_bTouchGround)
-{
- // If just
- m_bTouchGround = a_bTouchGround;
-
- if (!m_bTouchGround)
- {
- if (GetPosY() > m_LastJumpHeight)
- {
- m_LastJumpHeight = (float)GetPosY();
- }
- cWorld * World = GetWorld();
- if ((GetPosY() >= 0) && (GetPosY() < 256))
- {
- BLOCKTYPE BlockType = World->GetBlock( float2int(GetPosX()), float2int(GetPosY()), float2int(GetPosZ()) );
- if (BlockType != E_BLOCK_AIR)
- {
- // LOGD("TouchGround set to true by server");
- m_bTouchGround = true;
- }
- if (
- (BlockType == E_BLOCK_WATER) ||
- (BlockType == E_BLOCK_STATIONARY_WATER) ||
- (BlockType == E_BLOCK_LADDER) ||
- (BlockType == E_BLOCK_VINES)
- )
- {
- // LOGD("Water / Ladder / Torch");
- m_LastGroundHeight = (float)GetPosY();
- }
- }
- }
-
- if (m_bTouchGround)
- {
- float Dist = (float)(m_LastGroundHeight - floor(GetPosY()));
- int Damage = (int)(Dist - 3.f);
- if(m_LastJumpHeight > m_LastGroundHeight) Damage++;
- m_LastJumpHeight = (float)GetPosY();
- if (Damage > 0)
- {
- TakeDamage(dtFalling, NULL, Damage, Damage, 0);
- }
-
- m_LastGroundHeight = (float)GetPosY();
- }
-}
-
-
-
-
-
-void cPlayer::Heal(int a_Health)
-{
- if (m_Health < GetMaxHealth())
- {
- m_Health = (short)std::min((int)a_Health + m_Health, (int)GetMaxHealth());
- SendHealth();
- }
-}
-
-
-
-
-
-void cPlayer::SetFoodLevel(int a_FoodLevel)
-{
- m_FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL));
- SendHealth();
-}
-
-
-
-
-
-void cPlayer::SetFoodSaturationLevel(double a_FoodSaturationLevel)
-{
- m_FoodSaturationLevel = std::max(0.0, std::min(a_FoodSaturationLevel, (double)m_FoodLevel));
-}
-
-
-
-
-
-void cPlayer::SetFoodTickTimer(int a_FoodTickTimer)
-{
- m_FoodTickTimer = a_FoodTickTimer;
-}
-
-
-
-
-
-void cPlayer::SetFoodExhaustionLevel(double a_FoodSaturationLevel)
-{
- m_FoodExhaustionLevel = std::max(0.0, std::min(a_FoodSaturationLevel, 4.0));
-}
-
-
-
-
-
-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)
- {
- 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();
- return true;
-}
-
-
-
-
-
-void cPlayer::FoodPoison(int a_NumTicks)
-{
- bool HasBeenFoodPoisoned = (m_FoodPoisonedTicksRemaining > 0);
- m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
- if (!HasBeenFoodPoisoned)
- {
- // TODO: Send the poisoning indication to the client - how?
- SendHealth();
- }
-}
-
-
-
-
-
-void cPlayer::SendHealth(void)
-{
- if (m_ClientHandle != NULL)
- {
- m_ClientHandle->SendHealth();
- }
-}
-
-
-
-
-
-void cPlayer::ClearInventoryPaintSlots(void)
-{
- // Clear the list of slots that are being inventory-painted. Used by cWindow only
- m_InventoryPaintSlots.clear();
-}
-
-
-
-
-
-void cPlayer::AddInventoryPaintSlot(int a_SlotNum)
-{
- // Add a slot to the list for inventory painting. Used by cWindow only
- m_InventoryPaintSlots.push_back(a_SlotNum);
-}
-
-
-
-
-
-const cSlotNums & cPlayer::GetInventoryPaintSlots(void) const
-{
- // Return the list of slots currently stored for inventory painting. Used by cWindow only
- return m_InventoryPaintSlots;
-}
-
-
-
-
-
-double cPlayer::GetMaxSpeed(void) const
-{
- return m_IsSprinting ? m_SprintingMaxSpeed : m_NormalMaxSpeed;
-}
-
-
-
-
-
-void cPlayer::SetNormalMaxSpeed(double a_Speed)
-{
- m_NormalMaxSpeed = a_Speed;
- if (!m_IsSprinting)
- {
- m_ClientHandle->SendPlayerMaxSpeed();
- }
-}
-
-
-
-
-
-void cPlayer::SetSprintingMaxSpeed(double a_Speed)
-{
- m_SprintingMaxSpeed = a_Speed;
- if (m_IsSprinting)
- {
- m_ClientHandle->SendPlayerMaxSpeed();
- }
-}
-
-
-
-
-
-void cPlayer::SetCrouch(bool a_IsCrouched)
-{
- // Set the crouch status, broadcast to all visible players
-
- if (a_IsCrouched == m_IsCrouched)
- {
- // No change
- return;
- }
- m_IsCrouched = a_IsCrouched;
- m_World->BroadcastEntityMetadata(*this);
-}
-
-
-
-
-
-void cPlayer::SetSprint(bool a_IsSprinting)
-{
- if (a_IsSprinting == m_IsSprinting)
- {
- // No change
- return;
- }
-
- m_IsSprinting = a_IsSprinting;
- m_ClientHandle->SendPlayerMaxSpeed();
-}
-
-
-
-
-
-void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
-{
- if (m_GameMode == eGameMode_Creative)
- {
- // No damage / health in creative mode
- return;
- }
-
- super::DoTakeDamage(a_TDI);
-
- // Any kind of damage adds food exhaustion
- AddFoodExhaustion(0.3f);
-
- SendHealth();
-}
-
-
-
-
-
-void cPlayer::KilledBy(cEntity * a_Killer)
-{
- super::KilledBy(a_Killer);
-
- if (m_Health > 0)
- {
- return; // not dead yet =]
- }
-
- m_bVisible = false; // So new clients don't see the player
-
- // Puke out all the items
- cItems Pickups;
- m_Inventory.CopyToItems(Pickups);
- m_Inventory.Clear();
- m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
- SaveToDisk(); // Save it, yeah the world is a tough place !
-}
-
-
-
-
-
-void cPlayer::Respawn(void)
-{
- m_Health = GetMaxHealth();
- m_FoodLevel = 20;
-
- m_ClientHandle->SendRespawn();
-
- // Extinguish the fire:
- StopBurning();
-
- TeleportToCoords(GetWorld()->GetSpawnX(), GetWorld()->GetSpawnY(), GetWorld()->GetSpawnZ());
-
- SetVisible(true);
-}
-
-
-
-
-
-double cPlayer::GetEyeHeight(void) const
-{
- return m_Stance;
-}
-
-
-
-
-Vector3d cPlayer::GetEyePosition(void) const
-{
- return Vector3d( GetPosX(), m_Stance, GetPosZ() );
-}
-
-
-
-
-
-void cPlayer::OpenWindow(cWindow * a_Window)
-{
- if (a_Window != m_CurrentWindow)
- {
- CloseWindow(false);
- }
- a_Window->OpenedByPlayer(*this);
- m_CurrentWindow = a_Window;
- a_Window->SendWholeWindow(*GetClientHandle());
-}
-
-
-
-
-
-void cPlayer::CloseWindow(bool a_CanRefuse)
-{
- if (m_CurrentWindow == NULL)
- {
- m_CurrentWindow = m_InventoryWindow;
- return;
- }
-
- if (m_CurrentWindow->ClosedByPlayer(*this, a_CanRefuse) || !a_CanRefuse)
- {
- // Close accepted, go back to inventory window (the default):
- m_CurrentWindow = m_InventoryWindow;
- }
- else
- {
- // Re-open the window
- m_CurrentWindow->OpenedByPlayer(*this);
- m_CurrentWindow->SendWholeWindow(*GetClientHandle());
- }
-}
-
-
-
-
-
-void cPlayer::CloseWindowIfID(char a_WindowID, bool a_CanRefuse)
-{
- if ((m_CurrentWindow == NULL) || (m_CurrentWindow->GetWindowID() != a_WindowID))
- {
- return;
- }
- CloseWindow();
-}
-
-
-
-
-
-void cPlayer::SetLastBlockActionTime()
-{
- if (m_World != NULL)
- {
- m_LastBlockActionTime = m_World->GetWorldAge() / 20.0f;
- }
-}
-
-
-
-
-
-void cPlayer::SetLastBlockActionCnt( int a_LastBlockActionCnt )
-{
- m_LastBlockActionCnt = a_LastBlockActionCnt;
-}
-
-
-
-
-
-void cPlayer::SetGameMode(eGameMode a_GameMode)
-{
- if ((a_GameMode >= 3) || (a_GameMode < 0))
- {
- LOGWARNING("%s: Setting invalid gamemode: %d", GetName().c_str(), a_GameMode);
- return;
- }
-
- if (m_GameMode == a_GameMode)
- {
- // Gamemode already set
- return;
- }
-
- m_GameMode = a_GameMode;
- m_ClientHandle->SendGameMode(a_GameMode);
-}
-
-
-
-
-
-void cPlayer::LoginSetGameMode( eGameMode a_GameMode )
-{
- m_GameMode = a_GameMode;
-}
-
-
-
-
-
-void cPlayer::SetIP(const AString & a_IP)
-{
- m_IP = a_IP;
-}
-
-
-
-
-
-void cPlayer::SendMessage(const AString & a_Message)
-{
- m_ClientHandle->SendChat(a_Message);
-}
-
-
-
-
-
-void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
-{
- SetPosition( a_PosX, a_PosY, a_PosZ );
-
- m_World->BroadcastTeleportEntity(*this, GetClientHandle());
- m_ClientHandle->SendPlayerMoveLook();
-}
-
-
-
-
-
-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
- // the client may still send more of these nonsensical packets.
- if (m_AttachedTo != NULL)
- {
- Vector3d AddSpeed(a_NewPos);
- AddSpeed.y = 0;
- m_AttachedTo->AddSpeed(AddSpeed);
- }
- return;
- }
-
- // 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
-
- SetPosition( a_NewPos );
- SetStance(a_NewPos.y + 1.62);
-}
-
-
-
-
-
-void cPlayer::SetVisible(bool a_bVisible)
-{
- if (a_bVisible && !m_bVisible) // Make visible
- {
- m_bVisible = true;
- m_World->BroadcastSpawnEntity(*this);
- }
- if (!a_bVisible && m_bVisible)
- {
- m_bVisible = false;
- m_World->BroadcastDestroyEntity(*this, m_ClientHandle); // Destroy on all clients
- }
-}
-
-
-
-
-
-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() );
- ResolveGroups();
- ResolvePermissions();
-}
-
-
-
-
-
-void cPlayer::RemoveFromGroup( const AString & a_GroupName )
-{
- bool bRemoved = false;
- for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
- {
- if( (*itr)->GetName().compare(a_GroupName ) == 0 )
- {
- m_Groups.erase( itr );
- bRemoved = true;
- break;
- }
- }
-
- if( bRemoved )
- {
- LOGD("Removed %s from group %s", m_PlayerName.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() );
- }
-}
-
-
-
-
-
-bool cPlayer::CanUseCommand( const AString & a_Command )
-{
- for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
- {
- if( (*itr)->HasCommand( a_Command ) ) return true;
- }
- return false;
-}
-
-
-
-
-
-bool cPlayer::HasPermission(const AString & a_Permission)
-{
- if (a_Permission.empty())
- {
- // Empty permission request is always granted
- return true;
- }
-
- AStringVector Split = StringSplit( a_Permission, "." );
- PermissionMap Possibilities = m_ResolvedPermissions;
- // Now search the namespaces
- while( Possibilities.begin() != Possibilities.end() )
- {
- PermissionMap::iterator itr = Possibilities.begin();
- if( itr->second )
- {
- AStringVector OtherSplit = StringSplit( itr->first, "." );
- if( OtherSplit.size() <= Split.size() )
- {
- unsigned int i;
- for( i = 0; i < OtherSplit.size(); ++i )
- {
- if( OtherSplit[i].compare( Split[i] ) != 0 )
- {
- if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard!
- break;
- }
- }
- if( i == Split.size() ) return true;
- }
- }
- Possibilities.erase( itr );
- }
-
- // Nothing that matched :(
- return false;
-}
-
-
-
-
-
-bool cPlayer::IsInGroup( const AString & a_Group )
-{
- for( GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr )
- {
- if( a_Group.compare( (*itr)->GetName().c_str() ) == 0 )
- return true;
- }
- return false;
-}
-
-
-
-
-
-void cPlayer::ResolvePermissions()
-{
- m_ResolvedPermissions.clear(); // Start with an empty map yo~
-
- // Copy all player specific permissions into the resolved permissions map
- 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 )
- {
- const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions();
- for( cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr )
- {
- m_ResolvedPermissions[ itr->first ] = itr->second;
- }
- }
-}
-
-
-
-
-
-void cPlayer::ResolveGroups()
-{
- // Clear resolved groups first
- 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
- GroupList ToIterate;
- for( GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr )
- {
- ToIterate.push_back( *GroupItr );
- }
- while( ToIterate.begin() != ToIterate.end() )
- {
- cGroup* CurrentGroup = *ToIterate.begin();
- 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()
- );
- }
- else
- {
- AllGroups[ CurrentGroup ] = true;
- 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 )
- {
- 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() );
- continue;
- }
- ToIterate.push_back( *itr );
- }
- }
- ToIterate.erase( ToIterate.begin() );
- }
-}
-
-
-
-
-
-AString cPlayer::GetColor(void) const
-{
- if ( m_Color != '-' )
- {
- return cChatColor::MakeColor( m_Color );
- }
-
- if ( m_Groups.size() < 1 )
- {
- return cChatColor::White;
- }
-
- return (*m_Groups.begin())->GetColor();
-}
-
-
-
-
-
-void cPlayer::TossItem(
- bool a_bDraggingItem,
- char a_Amount /* = 1 */,
- short a_CreateType /* = 0 */,
- short a_CreateHealth /* = 0 */
-)
-{
- cItems Drops;
- if (a_CreateType != 0)
- {
- // Just create item without touching the inventory (used in creative mode)
- Drops.push_back(cItem(a_CreateType, a_Amount, a_CreateHealth));
- }
- else
- {
- // Drop an item from the inventory:
- if (a_bDraggingItem)
- {
- cItem & Item = GetDraggingItem();
- if (!Item.IsEmpty())
- {
- 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 - (char)a_Amount;
- }
- else
- {
- Item.Empty();
- }
- }
- }
- else
- {
- // Else drop equipped item
- cItem DroppedItem(GetInventory().GetEquippedItem());
- if (!DroppedItem.IsEmpty())
- {
- if (GetInventory().RemoveOneEquippedItem())
- {
- DroppedItem.m_ItemCount = 1; // RemoveItem decreases the count, so set it to 1 again
- Drops.push_back(DroppedItem);
- }
- }
- }
- }
- double vX = 0, vY = 0, vZ = 0;
- EulerToVector(-GetRotation(), GetPitch(), vZ, vX, vY);
- vY = -vY * 2 + 1.f;
- m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY() + 1.6f, GetPosZ(), vX * 2, vY * 2, vZ * 2);
-}
-
-
-
-
-
-bool cPlayer::MoveToWorld(const char * a_WorldName)
-{
- cWorld * World = cRoot::Get()->GetWorld(a_WorldName);
- if (World == NULL)
- {
- LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName);
- 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);
-
- // Add player to all the necessary parts of the new world
- SetWorld(World);
- World->AddEntity(this);
- World->AddPlayer(this);
-
- // 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
- if (OldDimension != World->GetDimension())
- {
- m_ClientHandle->SendRespawn();
- }
-
- // Stream the new chunks:
- m_ClientHandle->StreamChunks();
- return true;
-}
-
-
-
-
-
-void cPlayer::LoadPermissionsFromDisk()
-{
- m_Groups.clear();
- m_Permissions.clear();
-
- cIniFile IniFile("users.ini");
- if( IniFile.ReadFile() )
- {
- std::string Groups = IniFile.GetValue(m_PlayerName, "Groups", "");
- if( Groups.size() > 0 )
- {
- AStringVector Split = StringSplit( Groups, "," );
- for( unsigned int i = 0; i < Split.size(); i++ )
- {
- AddToGroup( Split[i].c_str() );
- }
- }
- else
- {
- AddToGroup("Default");
- }
-
- m_Color = IniFile.GetValue(m_PlayerName, "Color", "-")[0];
- }
- else
- {
- LOGWARN("WARNING: Failed to read ini file users.ini");
- AddToGroup("Default");
- }
- ResolvePermissions();
-}
-
-
-
-
-bool cPlayer::LoadFromDisk()
-{
- 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 )
- {
- if( itr->second ) LOGINFO("%s", itr->first.c_str() );
- }
-
- AString SourceFile;
- Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() );
-
- cFile f;
- if (!f.Open(SourceFile, cFile::fmRead))
- {
- LOGWARNING("Cannot open player data file \"%s\" for reading", SourceFile.c_str());
- return false;
- }
-
- AString buffer;
- if (f.ReadRestOfFile(buffer) != f.GetSize())
- {
- LOGWARNING("Cannot read player data from file \"%s\"", SourceFile.c_str());
- return false;
- }
- f.Close();
-
- 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());
- }
-
- 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();
- }
-
- Json::Value & JSON_PlayerRotation = root["rotation"];
- if (JSON_PlayerRotation.size() == 3)
- {
- SetRotation ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());
- SetPitch ((float)JSON_PlayerRotation[(unsigned int)1].asDouble());
- SetRoll ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
- }
-
- m_Health = root.get("health", 0).asInt();
-
- m_FoodLevel = root.get("food", MAX_FOOD_LEVEL).asInt();
- m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
- m_FoodTickTimer = root.get("foodTickTimer", 0).asInt();
- m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble();
-
- m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();
-
- m_Inventory.LoadFromJson(root["inventory"]);
-
- m_LoadedWorldName = root.get("world", "world").asString();
-
- 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()
- );
-
- return true;
-}
-
-
-
-
-
-bool cPlayer::SaveToDisk()
-{
- cMakeDir::MakeDir("players");
-
- // create the JSON data
- Json::Value JSON_PlayerPosition;
- JSON_PlayerPosition.append(Json::Value(GetPosX()));
- JSON_PlayerPosition.append(Json::Value(GetPosY()));
- JSON_PlayerPosition.append(Json::Value(GetPosZ()));
-
- Json::Value JSON_PlayerRotation;
- JSON_PlayerRotation.append(Json::Value(GetRotation()));
- JSON_PlayerRotation.append(Json::Value(GetPitch()));
- JSON_PlayerRotation.append(Json::Value(GetRoll()));
-
- Json::Value JSON_Inventory;
- m_Inventory.SaveToJson(JSON_Inventory);
-
- Json::Value root;
- root["position"] = JSON_PlayerPosition;
- root["rotation"] = JSON_PlayerRotation;
- root["inventory"] = JSON_Inventory;
- root["health"] = m_Health;
- root["food"] = m_FoodLevel;
- root["foodSaturation"] = m_FoodSaturationLevel;
- root["foodTickTimer"] = m_FoodTickTimer;
- root["foodExhaustion"] = m_FoodExhaustionLevel;
- root["world"] = GetWorld()->GetName();
-
- if (m_GameMode == GetWorld()->GetGameMode())
- {
- root["gamemode"] = (int) eGameMode_NotSet;
- }
- else
- {
- root["gamemode"] = (int) m_GameMode;
- }
-
- Json::StyledWriter writer;
- std::string JsonData = writer.write(root);
-
- AString SourceFile;
- Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() );
-
- 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());
- return false;
- }
- if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size())
- {
- LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str());
- return false;
- }
- return true;
-}
-
-
-
-
-
-cPlayer::StringList cPlayer::GetResolvedPermissions()
-{
- StringList Permissions;
-
- const PermissionMap& ResolvedPermissions = m_ResolvedPermissions;
- for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr )
- {
- if( itr->second ) Permissions.push_back( itr->first );
- }
-
- return Permissions;
-}
-
-
-
-
-
-void cPlayer::UseEquippedItem()
-{
- if (GetGameMode() == gmCreative) // No damage in creative
- {
- return;
- }
-
- GetInventory().DamageEquippedItem();
-}
-
-
-
-
-
-void cPlayer::HandleFood(void)
-{
- // Ref.: http://www.minecraftwiki.net/wiki/Hunger
-
- // 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))
- {
- m_FoodTickTimer++;
- if (m_FoodTickTimer >= 80)
- {
- m_FoodTickTimer = 0;
-
- if (m_FoodLevel >= 17)
- {
- // Regenerate health from food, incur 3 pts of food exhaustion:
- Heal(1);
- m_FoodExhaustionLevel += 3;
- }
- else if (m_FoodLevel <= 0)
- {
- // Damage from starving
- TakeDamage(dtStarving, NULL, 1, 1, 0);
- }
- }
- }
-
- // Apply food poisoning food exhaustion:
- if (m_FoodPoisonedTicksRemaining > 0)
- {
- m_FoodPoisonedTicksRemaining--;
- m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
- }
-
- // Apply food exhaustion that has accumulated:
- if (m_FoodExhaustionLevel >= 4)
- {
- m_FoodExhaustionLevel -= 4;
-
- if (m_FoodSaturationLevel >= 1)
- {
- m_FoodSaturationLevel -= 1;
- }
- else
- {
- m_FoodLevel = std::max(m_FoodLevel - 1, 0);
- }
- }
-
- if (m_FoodLevel != LastFoodLevel)
- {
- SendHealth();
- }
-}
-
-
-
-
-
-void cPlayer::ApplyFoodExhaustionFromMovement(cChunk & a_Chunk)
-{
- // Calculate the distance travelled, update the last pos:
- Vector3d Movement(GetPosition() - m_LastFoodPos);
- m_LastFoodPos = GetPosition();
-
- // If riding anything, apply no food exhaustion
- if (m_AttachedTo != NULL)
- {
- return;
- }
-
- // Get the type of block the player's standing in:
- BLOCKTYPE BlockIn;
- int RelX = (int)floor(m_LastPosX) - a_Chunk.GetPosX() * cChunkDef::Width;
- int RelY = (int)floor(m_LastPosY + 0.1);
- int RelZ = (int)floor(m_LastPosZ) - a_Chunk.GetPosZ() * cChunkDef::Width;
- // Use Unbounded, because we're being called *after* processing super::Tick(), which could have changed our chunk
- VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockIn));
-
- // Apply the exhaustion based on distance travelled:
- double BaseExhaustion = Movement.Length();
- if (IsSprinting())
- {
- // 0.1 pt per meter sprinted
- BaseExhaustion = BaseExhaustion * 0.1;
- }
- else if (IsBlockWater(BlockIn))
- {
- // 0.015 pt per meter swum
- BaseExhaustion = BaseExhaustion * 0.015;
- }
- else
- {
- // 0.01 pt per meter walked / sneaked
- BaseExhaustion = BaseExhaustion * 0.01;
- }
- m_FoodExhaustionLevel += BaseExhaustion;
-}
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Player.h"
+#include "Server.h"
+#include "ClientHandle.h"
+#include "UI/Window.h"
+#include "UI/WindowOwner.h"
+#include "World.h"
+#include "Pickup.h"
+#include "PluginManager.h"
+#include "BlockEntities/BlockEntity.h"
+#include "GroupManager.h"
+#include "Group.h"
+#include "ChatColor.h"
+#include "Item.h"
+#include "Tracer.h"
+#include "Root.h"
+#include "OSSupport/MakeDir.h"
+#include "OSSupport/Timer.h"
+#include "MersenneTwister.h"
+#include "Chunk.h"
+#include "Items/ItemHandler.h"
+
+#include "Vector3d.h"
+#include "Vector3f.h"
+
+#include "../iniFile/iniFile.h"
+#include <json/json.h>
+
+#define float2int(x) ((x)<0 ? ((int)(x))-1 : (int)(x))
+
+
+
+
+
+cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
+ : super(etPlayer, 0.6, 1.8)
+ , m_GameMode(eGameMode_NotSet)
+ , m_IP("")
+ , m_LastBlockActionTime( 0 )
+ , m_LastBlockActionCnt( 0 )
+ , m_bVisible( true )
+ , m_LastGroundHeight( 0 )
+ , m_bTouchGround( false )
+ , m_Stance( 0.0 )
+ , m_Inventory(*this)
+ , m_CurrentWindow(NULL)
+ , m_InventoryWindow(NULL)
+ , m_TimeLastPickupCheck( 0.f )
+ , m_Color('-')
+ , m_ClientHandle( a_Client )
+ , m_FoodLevel(20)
+ , m_FoodSaturationLevel(5)
+ , m_FoodTickTimer(0)
+ , m_FoodExhaustionLevel(0)
+ , m_FoodPoisonedTicksRemaining(0)
+ , m_NormalMaxSpeed(0.1)
+ , m_SprintingMaxSpeed(0.13)
+ , m_IsCrouched(false)
+ , m_IsSprinting(false)
+ , m_EatingFinishTick(-1)
+{
+ LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
+ a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
+ this, GetUniqueID()
+ );
+
+ m_InventoryWindow = new cInventoryWindow(*this);
+ m_CurrentWindow = m_InventoryWindow;
+ m_InventoryWindow->OpenedByPlayer(*this);
+
+ SetMaxHealth(20);
+
+ cTimer t1;
+ m_LastPlayerListTime = t1.GetNowTime();
+
+ m_TimeLastTeleportPacket = 0;
+ m_TimeLastPickupCheck = 0;
+
+ m_PlayerName = a_PlayerName;
+ m_bDirtyPosition = true; // So chunks are streamed to player at spawn
+
+ if (!LoadFromDisk())
+ {
+ m_Inventory.Clear();
+ SetPosX(cRoot::Get()->GetDefaultWorld()->GetSpawnX());
+ SetPosY(cRoot::Get()->GetDefaultWorld()->GetSpawnY());
+ SetPosZ(cRoot::Get()->GetDefaultWorld()->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()
+ );
+ }
+ m_LastJumpHeight = (float)(GetPosY());
+ m_LastGroundHeight = (float)(GetPosY());
+ m_Stance = GetPosY() + 1.62;
+}
+
+
+
+
+
+cPlayer::~cPlayer(void)
+{
+ LOG("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID());
+
+ SaveToDisk();
+
+ m_World->RemovePlayer( this );
+
+ m_ClientHandle = NULL;
+
+ delete m_InventoryWindow;
+
+ LOGD("Player %p deleted", this);
+}
+
+
+
+
+
+void cPlayer::Initialize(cWorld * a_World)
+{
+ super::Initialize(a_World);
+ GetWorld()->AddPlayer(this);
+}
+
+
+
+
+
+void cPlayer::Destroyed()
+{
+ CloseWindow(false);
+ m_ClientHandle = NULL;
+}
+
+
+
+
+
+void cPlayer::SpawnOn(cClientHandle & a_Client)
+{
+ /*
+ LOGD("cPlayer::SpawnOn(%s) for \"%s\" at pos {%.2f, %.2f, %.2f}",
+ a_Client.GetUsername().c_str(), m_PlayerName.c_str(), m_Pos.x, m_Pos.y, m_Pos.z
+ );
+ */
+
+ if (m_bVisible && (m_ClientHandle != (&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() );
+ }
+}
+
+
+
+
+
+void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ if (!m_ClientHandle->IsPlaying())
+ {
+ // We're not yet in the game, ignore everything
+ return;
+ }
+
+ super::Tick(a_Dt, a_Chunk);
+ if (m_bDirtyPosition)
+ {
+ // Apply food exhaustion from movement:
+ ApplyFoodExhaustionFromMovement(a_Chunk);
+
+ cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this);
+ BroadcastMovementUpdate(m_ClientHandle);
+ m_ClientHandle->StreamChunks();
+ }
+ else
+ {
+ BroadcastMovementUpdate(m_ClientHandle);
+ }
+
+ if (m_Health > 0) // make sure player is alive
+ {
+ m_World->CollectPickupsByPlayer(this);
+
+ if ((m_EatingFinishTick >= 0) && (m_EatingFinishTick <= m_World->GetWorldAge()))
+ {
+ FinishEating();
+ }
+
+ HandleFood();
+ }
+
+ // Send Player List (Once per m_LastPlayerListTime/1000 ms)
+ cTimer t1;
+ if (m_LastPlayerListTime + cPlayer::PLAYER_LIST_TIME_MS <= t1.GetNowTime())
+ {
+ m_World->SendPlayerList(this);
+ m_LastPlayerListTime = t1.GetNowTime();
+ }
+}
+
+
+
+
+
+void cPlayer::SetTouchGround(bool a_bTouchGround)
+{
+ // If just
+ m_bTouchGround = a_bTouchGround;
+
+ if (!m_bTouchGround)
+ {
+ if (GetPosY() > m_LastJumpHeight)
+ {
+ m_LastJumpHeight = (float)GetPosY();
+ }
+ cWorld * World = GetWorld();
+ if ((GetPosY() >= 0) && (GetPosY() < 256))
+ {
+ BLOCKTYPE BlockType = World->GetBlock( float2int(GetPosX()), float2int(GetPosY()), float2int(GetPosZ()) );
+ if (BlockType != E_BLOCK_AIR)
+ {
+ // LOGD("TouchGround set to true by server");
+ m_bTouchGround = true;
+ }
+ if (
+ (BlockType == E_BLOCK_WATER) ||
+ (BlockType == E_BLOCK_STATIONARY_WATER) ||
+ (BlockType == E_BLOCK_LADDER) ||
+ (BlockType == E_BLOCK_VINES)
+ )
+ {
+ // LOGD("Water / Ladder / Torch");
+ m_LastGroundHeight = (float)GetPosY();
+ }
+ }
+ }
+
+ if (m_bTouchGround)
+ {
+ float Dist = (float)(m_LastGroundHeight - floor(GetPosY()));
+ int Damage = (int)(Dist - 3.f);
+ if(m_LastJumpHeight > m_LastGroundHeight) Damage++;
+ m_LastJumpHeight = (float)GetPosY();
+ if (Damage > 0)
+ {
+ TakeDamage(dtFalling, NULL, Damage, Damage, 0);
+ }
+
+ m_LastGroundHeight = (float)GetPosY();
+ }
+}
+
+
+
+
+
+void cPlayer::Heal(int a_Health)
+{
+ if (m_Health < GetMaxHealth())
+ {
+ m_Health = (short)std::min((int)a_Health + m_Health, (int)GetMaxHealth());
+ SendHealth();
+ }
+}
+
+
+
+
+
+void cPlayer::SetFoodLevel(int a_FoodLevel)
+{
+ m_FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL));
+ SendHealth();
+}
+
+
+
+
+
+void cPlayer::SetFoodSaturationLevel(double a_FoodSaturationLevel)
+{
+ m_FoodSaturationLevel = std::max(0.0, std::min(a_FoodSaturationLevel, (double)m_FoodLevel));
+}
+
+
+
+
+
+void cPlayer::SetFoodTickTimer(int a_FoodTickTimer)
+{
+ m_FoodTickTimer = a_FoodTickTimer;
+}
+
+
+
+
+
+void cPlayer::SetFoodExhaustionLevel(double a_FoodSaturationLevel)
+{
+ m_FoodExhaustionLevel = std::max(0.0, std::min(a_FoodSaturationLevel, 4.0));
+}
+
+
+
+
+
+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)
+ {
+ 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();
+ return true;
+}
+
+
+
+
+
+void cPlayer::FoodPoison(int a_NumTicks)
+{
+ bool HasBeenFoodPoisoned = (m_FoodPoisonedTicksRemaining > 0);
+ m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
+ if (!HasBeenFoodPoisoned)
+ {
+ // TODO: Send the poisoning indication to the client - how?
+ SendHealth();
+ }
+}
+
+
+
+
+
+void cPlayer::StartEating(void)
+{
+ // Set the timer:
+ m_EatingFinishTick = m_World->GetWorldAge() + EATING_TICKS;
+
+ // Send the packets:
+ m_World->BroadcastPlayerAnimation(*this, 5);
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+
+
+void cPlayer::FinishEating(void)
+{
+ // Reset the timer:
+ m_EatingFinishTick = -1;
+
+ // Send the packets:
+ m_ClientHandle->SendEntityStatus(*this, ENTITY_STATUS_EATING_ACCEPTED);
+ m_World->BroadcastPlayerAnimation(*this, 0);
+ m_World->BroadcastEntityMetadata(*this);
+
+ // consume the item:
+ cItem Item(GetEquippedItem());
+ Item.m_ItemCount = 1;
+ cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Item.m_ItemType);
+ if (!ItemHandler->EatItem(this, &Item))
+ {
+ return;
+ }
+ ItemHandler->OnFoodEaten(m_World, this, &Item);
+ GetInventory().RemoveOneEquippedItem();
+}
+
+
+
+
+
+void cPlayer::AbortEating(void)
+{
+ m_EatingFinishTick = -1;
+ m_World->BroadcastPlayerAnimation(*this, 0);
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+
+
+void cPlayer::SendHealth(void)
+{
+ if (m_ClientHandle != NULL)
+ {
+ m_ClientHandle->SendHealth();
+ }
+}
+
+
+
+
+
+void cPlayer::ClearInventoryPaintSlots(void)
+{
+ // Clear the list of slots that are being inventory-painted. Used by cWindow only
+ m_InventoryPaintSlots.clear();
+}
+
+
+
+
+
+void cPlayer::AddInventoryPaintSlot(int a_SlotNum)
+{
+ // Add a slot to the list for inventory painting. Used by cWindow only
+ m_InventoryPaintSlots.push_back(a_SlotNum);
+}
+
+
+
+
+
+const cSlotNums & cPlayer::GetInventoryPaintSlots(void) const
+{
+ // Return the list of slots currently stored for inventory painting. Used by cWindow only
+ return m_InventoryPaintSlots;
+}
+
+
+
+
+
+double cPlayer::GetMaxSpeed(void) const
+{
+ return m_IsSprinting ? m_SprintingMaxSpeed : m_NormalMaxSpeed;
+}
+
+
+
+
+
+void cPlayer::SetNormalMaxSpeed(double a_Speed)
+{
+ m_NormalMaxSpeed = a_Speed;
+ if (!m_IsSprinting)
+ {
+ m_ClientHandle->SendPlayerMaxSpeed();
+ }
+}
+
+
+
+
+
+void cPlayer::SetSprintingMaxSpeed(double a_Speed)
+{
+ m_SprintingMaxSpeed = a_Speed;
+ if (m_IsSprinting)
+ {
+ m_ClientHandle->SendPlayerMaxSpeed();
+ }
+}
+
+
+
+
+
+void cPlayer::SetCrouch(bool a_IsCrouched)
+{
+ // Set the crouch status, broadcast to all visible players
+
+ if (a_IsCrouched == m_IsCrouched)
+ {
+ // No change
+ return;
+ }
+ m_IsCrouched = a_IsCrouched;
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+
+
+void cPlayer::SetSprint(bool a_IsSprinting)
+{
+ if (a_IsSprinting == m_IsSprinting)
+ {
+ // No change
+ return;
+ }
+
+ m_IsSprinting = a_IsSprinting;
+ m_ClientHandle->SendPlayerMaxSpeed();
+}
+
+
+
+
+
+void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
+{
+ if (m_GameMode == eGameMode_Creative)
+ {
+ // No damage / health in creative mode
+ return;
+ }
+
+ super::DoTakeDamage(a_TDI);
+
+ // Any kind of damage adds food exhaustion
+ AddFoodExhaustion(0.3f);
+
+ SendHealth();
+}
+
+
+
+
+
+void cPlayer::KilledBy(cEntity * a_Killer)
+{
+ super::KilledBy(a_Killer);
+
+ if (m_Health > 0)
+ {
+ return; // not dead yet =]
+ }
+
+ m_bVisible = false; // So new clients don't see the player
+
+ // Puke out all the items
+ cItems Pickups;
+ m_Inventory.CopyToItems(Pickups);
+ m_Inventory.Clear();
+ m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
+ SaveToDisk(); // Save it, yeah the world is a tough place !
+}
+
+
+
+
+
+void cPlayer::Respawn(void)
+{
+ m_Health = GetMaxHealth();
+
+ // Reset food level:
+ m_FoodLevel = 20;
+ m_FoodSaturationLevel = 5;
+
+ m_ClientHandle->SendRespawn();
+
+ // Extinguish the fire:
+ StopBurning();
+
+ TeleportToCoords(GetWorld()->GetSpawnX(), GetWorld()->GetSpawnY(), GetWorld()->GetSpawnZ());
+
+ SetVisible(true);
+}
+
+
+
+
+
+double cPlayer::GetEyeHeight(void) const
+{
+ return m_Stance;
+}
+
+
+
+
+Vector3d cPlayer::GetEyePosition(void) const
+{
+ return Vector3d( GetPosX(), m_Stance, GetPosZ() );
+}
+
+
+
+
+
+bool cPlayer::IsGameModeCreative(void) const
+{
+ return (m_GameMode == gmCreative) || // Either the player is explicitly in Creative
+ ((m_GameMode == gmNotSet) && m_World->IsGameModeCreative()); // or they inherit from the world and the world is Creative
+}
+
+
+
+
+
+bool cPlayer::IsGameModeSurvival(void) const
+{
+ return (m_GameMode == gmSurvival) || // Either the player is explicitly in Survival
+ ((m_GameMode == gmNotSet) && m_World->IsGameModeSurvival()); // or they inherit from the world and the world is Survival
+}
+
+
+
+
+
+bool cPlayer::IsGameModeAdventure(void) const
+{
+ return (m_GameMode == gmCreative) || // Either the player is explicitly in Adventure
+ ((m_GameMode == gmNotSet) && m_World->IsGameModeCreative()); // or they inherit from the world and the world is Adventure
+}
+
+
+
+
+
+void cPlayer::OpenWindow(cWindow * a_Window)
+{
+ if (a_Window != m_CurrentWindow)
+ {
+ CloseWindow(false);
+ }
+ a_Window->OpenedByPlayer(*this);
+ m_CurrentWindow = a_Window;
+ a_Window->SendWholeWindow(*GetClientHandle());
+}
+
+
+
+
+
+void cPlayer::CloseWindow(bool a_CanRefuse)
+{
+ if (m_CurrentWindow == NULL)
+ {
+ m_CurrentWindow = m_InventoryWindow;
+ return;
+ }
+
+ if (m_CurrentWindow->ClosedByPlayer(*this, a_CanRefuse) || !a_CanRefuse)
+ {
+ // Close accepted, go back to inventory window (the default):
+ m_CurrentWindow = m_InventoryWindow;
+ }
+ else
+ {
+ // Re-open the window
+ m_CurrentWindow->OpenedByPlayer(*this);
+ m_CurrentWindow->SendWholeWindow(*GetClientHandle());
+ }
+}
+
+
+
+
+
+void cPlayer::CloseWindowIfID(char a_WindowID, bool a_CanRefuse)
+{
+ if ((m_CurrentWindow == NULL) || (m_CurrentWindow->GetWindowID() != a_WindowID))
+ {
+ return;
+ }
+ CloseWindow();
+}
+
+
+
+
+
+void cPlayer::SetLastBlockActionTime()
+{
+ if (m_World != NULL)
+ {
+ m_LastBlockActionTime = m_World->GetWorldAge() / 20.0f;
+ }
+}
+
+
+
+
+
+void cPlayer::SetLastBlockActionCnt( int a_LastBlockActionCnt )
+{
+ m_LastBlockActionCnt = a_LastBlockActionCnt;
+}
+
+
+
+
+
+void cPlayer::SetGameMode(eGameMode a_GameMode)
+{
+ if ((a_GameMode < gmMin) || (a_GameMode >= gmMax))
+ {
+ LOGWARNING("%s: Setting invalid gamemode: %d", GetName().c_str(), a_GameMode);
+ return;
+ }
+
+ if (m_GameMode == a_GameMode)
+ {
+ // Gamemode already set
+ return;
+ }
+
+ m_GameMode = a_GameMode;
+ m_ClientHandle->SendGameMode(a_GameMode);
+}
+
+
+
+
+
+void cPlayer::LoginSetGameMode( eGameMode a_GameMode )
+{
+ m_GameMode = a_GameMode;
+}
+
+
+
+
+
+void cPlayer::SetIP(const AString & a_IP)
+{
+ m_IP = a_IP;
+}
+
+
+
+
+
+void cPlayer::SendMessage(const AString & a_Message)
+{
+ m_ClientHandle->SendChat(a_Message);
+}
+
+
+
+
+
+void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
+{
+ SetPosition( a_PosX, a_PosY, a_PosZ );
+
+ m_World->BroadcastTeleportEntity(*this, GetClientHandle());
+ m_ClientHandle->SendPlayerMoveLook();
+}
+
+
+
+
+
+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
+ // the client may still send more of these nonsensical packets.
+ if (m_AttachedTo != NULL)
+ {
+ Vector3d AddSpeed(a_NewPos);
+ AddSpeed.y = 0;
+ m_AttachedTo->AddSpeed(AddSpeed);
+ }
+ return;
+ }
+
+ // 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
+
+ SetPosition( a_NewPos );
+ SetStance(a_NewPos.y + 1.62);
+}
+
+
+
+
+
+void cPlayer::SetVisible(bool a_bVisible)
+{
+ if (a_bVisible && !m_bVisible) // Make visible
+ {
+ m_bVisible = true;
+ m_World->BroadcastSpawnEntity(*this);
+ }
+ if (!a_bVisible && m_bVisible)
+ {
+ m_bVisible = false;
+ m_World->BroadcastDestroyEntity(*this, m_ClientHandle); // Destroy on all clients
+ }
+}
+
+
+
+
+
+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() );
+ ResolveGroups();
+ ResolvePermissions();
+}
+
+
+
+
+
+void cPlayer::RemoveFromGroup( const AString & a_GroupName )
+{
+ bool bRemoved = false;
+ for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
+ {
+ if( (*itr)->GetName().compare(a_GroupName ) == 0 )
+ {
+ m_Groups.erase( itr );
+ bRemoved = true;
+ break;
+ }
+ }
+
+ if( bRemoved )
+ {
+ LOGD("Removed %s from group %s", m_PlayerName.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() );
+ }
+}
+
+
+
+
+
+bool cPlayer::CanUseCommand( const AString & a_Command )
+{
+ for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
+ {
+ if( (*itr)->HasCommand( a_Command ) ) return true;
+ }
+ return false;
+}
+
+
+
+
+
+bool cPlayer::HasPermission(const AString & a_Permission)
+{
+ if (a_Permission.empty())
+ {
+ // Empty permission request is always granted
+ return true;
+ }
+
+ AStringVector Split = StringSplit( a_Permission, "." );
+ PermissionMap Possibilities = m_ResolvedPermissions;
+ // Now search the namespaces
+ while( Possibilities.begin() != Possibilities.end() )
+ {
+ PermissionMap::iterator itr = Possibilities.begin();
+ if( itr->second )
+ {
+ AStringVector OtherSplit = StringSplit( itr->first, "." );
+ if( OtherSplit.size() <= Split.size() )
+ {
+ unsigned int i;
+ for( i = 0; i < OtherSplit.size(); ++i )
+ {
+ if( OtherSplit[i].compare( Split[i] ) != 0 )
+ {
+ if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard!
+ break;
+ }
+ }
+ if( i == Split.size() ) return true;
+ }
+ }
+ Possibilities.erase( itr );
+ }
+
+ // Nothing that matched :(
+ return false;
+}
+
+
+
+
+
+bool cPlayer::IsInGroup( const AString & a_Group )
+{
+ for( GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr )
+ {
+ if( a_Group.compare( (*itr)->GetName().c_str() ) == 0 )
+ return true;
+ }
+ return false;
+}
+
+
+
+
+
+void cPlayer::ResolvePermissions()
+{
+ m_ResolvedPermissions.clear(); // Start with an empty map yo~
+
+ // Copy all player specific permissions into the resolved permissions map
+ 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 )
+ {
+ const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions();
+ for( cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr )
+ {
+ m_ResolvedPermissions[ itr->first ] = itr->second;
+ }
+ }
+}
+
+
+
+
+
+void cPlayer::ResolveGroups()
+{
+ // Clear resolved groups first
+ 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
+ GroupList ToIterate;
+ for( GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr )
+ {
+ ToIterate.push_back( *GroupItr );
+ }
+ while( ToIterate.begin() != ToIterate.end() )
+ {
+ cGroup* CurrentGroup = *ToIterate.begin();
+ 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()
+ );
+ }
+ else
+ {
+ AllGroups[ CurrentGroup ] = true;
+ 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 )
+ {
+ 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() );
+ continue;
+ }
+ ToIterate.push_back( *itr );
+ }
+ }
+ ToIterate.erase( ToIterate.begin() );
+ }
+}
+
+
+
+
+
+AString cPlayer::GetColor(void) const
+{
+ if ( m_Color != '-' )
+ {
+ return cChatColor::MakeColor( m_Color );
+ }
+
+ if ( m_Groups.size() < 1 )
+ {
+ return cChatColor::White;
+ }
+
+ return (*m_Groups.begin())->GetColor();
+}
+
+
+
+
+
+void cPlayer::TossItem(
+ bool a_bDraggingItem,
+ char a_Amount /* = 1 */,
+ short a_CreateType /* = 0 */,
+ short a_CreateHealth /* = 0 */
+)
+{
+ cItems Drops;
+ if (a_CreateType != 0)
+ {
+ // Just create item without touching the inventory (used in creative mode)
+ Drops.push_back(cItem(a_CreateType, a_Amount, a_CreateHealth));
+ }
+ else
+ {
+ // Drop an item from the inventory:
+ if (a_bDraggingItem)
+ {
+ cItem & Item = GetDraggingItem();
+ if (!Item.IsEmpty())
+ {
+ 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 - (char)a_Amount;
+ }
+ else
+ {
+ Item.Empty();
+ }
+ }
+ }
+ else
+ {
+ // Else drop equipped item
+ cItem DroppedItem(GetInventory().GetEquippedItem());
+ if (!DroppedItem.IsEmpty())
+ {
+ if (GetInventory().RemoveOneEquippedItem())
+ {
+ DroppedItem.m_ItemCount = 1; // RemoveItem decreases the count, so set it to 1 again
+ Drops.push_back(DroppedItem);
+ }
+ }
+ }
+ }
+ double vX = 0, vY = 0, vZ = 0;
+ EulerToVector(-GetRotation(), GetPitch(), vZ, vX, vY);
+ vY = -vY * 2 + 1.f;
+ m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY() + 1.6f, GetPosZ(), vX * 2, vY * 2, vZ * 2);
+}
+
+
+
+
+
+bool cPlayer::MoveToWorld(const char * a_WorldName)
+{
+ cWorld * World = cRoot::Get()->GetWorld(a_WorldName);
+ if (World == NULL)
+ {
+ LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName);
+ 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);
+
+ // Add player to all the necessary parts of the new world
+ SetWorld(World);
+ World->AddEntity(this);
+ World->AddPlayer(this);
+
+ // 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
+ if (OldDimension != World->GetDimension())
+ {
+ m_ClientHandle->SendRespawn();
+ }
+
+ // Stream the new chunks:
+ m_ClientHandle->StreamChunks();
+ return true;
+}
+
+
+
+
+
+void cPlayer::LoadPermissionsFromDisk()
+{
+ m_Groups.clear();
+ m_Permissions.clear();
+
+ cIniFile IniFile("users.ini");
+ if( IniFile.ReadFile() )
+ {
+ std::string Groups = IniFile.GetValue(m_PlayerName, "Groups", "");
+ if( Groups.size() > 0 )
+ {
+ AStringVector Split = StringSplit( Groups, "," );
+ for( unsigned int i = 0; i < Split.size(); i++ )
+ {
+ AddToGroup( Split[i].c_str() );
+ }
+ }
+ else
+ {
+ AddToGroup("Default");
+ }
+
+ m_Color = IniFile.GetValue(m_PlayerName, "Color", "-")[0];
+ }
+ else
+ {
+ LOGWARN("WARNING: Failed to read ini file users.ini");
+ AddToGroup("Default");
+ }
+ ResolvePermissions();
+}
+
+
+
+
+bool cPlayer::LoadFromDisk()
+{
+ 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 )
+ {
+ if( itr->second ) LOGINFO("%s", itr->first.c_str() );
+ }
+
+ AString SourceFile;
+ Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() );
+
+ cFile f;
+ if (!f.Open(SourceFile, cFile::fmRead))
+ {
+ LOGWARNING("Cannot open player data file \"%s\" for reading", SourceFile.c_str());
+ return false;
+ }
+
+ AString buffer;
+ if (f.ReadRestOfFile(buffer) != f.GetSize())
+ {
+ LOGWARNING("Cannot read player data from file \"%s\"", SourceFile.c_str());
+ return false;
+ }
+ f.Close();
+
+ 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());
+ }
+
+ 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();
+ }
+
+ Json::Value & JSON_PlayerRotation = root["rotation"];
+ if (JSON_PlayerRotation.size() == 3)
+ {
+ SetRotation ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());
+ SetPitch ((float)JSON_PlayerRotation[(unsigned int)1].asDouble());
+ SetRoll ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
+ }
+
+ m_Health = root.get("health", 0).asInt();
+
+ m_FoodLevel = root.get("food", MAX_FOOD_LEVEL).asInt();
+ m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
+ m_FoodTickTimer = root.get("foodTickTimer", 0).asInt();
+ m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble();
+
+ m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();
+
+ m_Inventory.LoadFromJson(root["inventory"]);
+
+ m_LoadedWorldName = root.get("world", "world").asString();
+
+ 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()
+ );
+
+ return true;
+}
+
+
+
+
+
+bool cPlayer::SaveToDisk()
+{
+ cMakeDir::MakeDir("players");
+
+ // create the JSON data
+ Json::Value JSON_PlayerPosition;
+ JSON_PlayerPosition.append(Json::Value(GetPosX()));
+ JSON_PlayerPosition.append(Json::Value(GetPosY()));
+ JSON_PlayerPosition.append(Json::Value(GetPosZ()));
+
+ Json::Value JSON_PlayerRotation;
+ JSON_PlayerRotation.append(Json::Value(GetRotation()));
+ JSON_PlayerRotation.append(Json::Value(GetPitch()));
+ JSON_PlayerRotation.append(Json::Value(GetRoll()));
+
+ Json::Value JSON_Inventory;
+ m_Inventory.SaveToJson(JSON_Inventory);
+
+ Json::Value root;
+ root["position"] = JSON_PlayerPosition;
+ root["rotation"] = JSON_PlayerRotation;
+ root["inventory"] = JSON_Inventory;
+ root["health"] = m_Health;
+ root["food"] = m_FoodLevel;
+ root["foodSaturation"] = m_FoodSaturationLevel;
+ root["foodTickTimer"] = m_FoodTickTimer;
+ root["foodExhaustion"] = m_FoodExhaustionLevel;
+ root["world"] = GetWorld()->GetName();
+
+ if (m_GameMode == GetWorld()->GetGameMode())
+ {
+ root["gamemode"] = (int) eGameMode_NotSet;
+ }
+ else
+ {
+ root["gamemode"] = (int) m_GameMode;
+ }
+
+ Json::StyledWriter writer;
+ std::string JsonData = writer.write(root);
+
+ AString SourceFile;
+ Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() );
+
+ 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());
+ return false;
+ }
+ if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size())
+ {
+ LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str());
+ return false;
+ }
+ return true;
+}
+
+
+
+
+
+cPlayer::StringList cPlayer::GetResolvedPermissions()
+{
+ StringList Permissions;
+
+ const PermissionMap& ResolvedPermissions = m_ResolvedPermissions;
+ for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr )
+ {
+ if( itr->second ) Permissions.push_back( itr->first );
+ }
+
+ return Permissions;
+}
+
+
+
+
+
+void cPlayer::UseEquippedItem()
+{
+ if (GetGameMode() == gmCreative) // No damage in creative
+ {
+ return;
+ }
+
+ GetInventory().DamageEquippedItem();
+}
+
+
+
+
+
+void cPlayer::HandleFood(void)
+{
+ // Ref.: http://www.minecraftwiki.net/wiki/Hunger
+
+ // 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))
+ {
+ m_FoodTickTimer++;
+ if (m_FoodTickTimer >= 80)
+ {
+ m_FoodTickTimer = 0;
+
+ if (m_FoodLevel >= 17)
+ {
+ // Regenerate health from food, incur 3 pts of food exhaustion:
+ Heal(1);
+ m_FoodExhaustionLevel += 3;
+ }
+ else if (m_FoodLevel <= 0)
+ {
+ // Damage from starving
+ TakeDamage(dtStarving, NULL, 1, 1, 0);
+ }
+ }
+ }
+
+ // Apply food poisoning food exhaustion:
+ if (m_FoodPoisonedTicksRemaining > 0)
+ {
+ m_FoodPoisonedTicksRemaining--;
+ m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
+ }
+
+ // Apply food exhaustion that has accumulated:
+ if (m_FoodExhaustionLevel >= 4)
+ {
+ m_FoodExhaustionLevel -= 4;
+
+ if (m_FoodSaturationLevel >= 1)
+ {
+ m_FoodSaturationLevel -= 1;
+ }
+ else
+ {
+ m_FoodLevel = std::max(m_FoodLevel - 1, 0);
+ }
+ }
+
+ if (m_FoodLevel != LastFoodLevel)
+ {
+ SendHealth();
+ }
+}
+
+
+
+
+
+void cPlayer::ApplyFoodExhaustionFromMovement(cChunk & a_Chunk)
+{
+ 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 riding anything, apply no food exhaustion
+ if (m_AttachedTo != NULL)
+ {
+ return;
+ }
+
+ // Get the type of block the player's standing in:
+ BLOCKTYPE BlockIn;
+ int RelX = (int)floor(m_LastPosX) - a_Chunk.GetPosX() * cChunkDef::Width;
+ int RelY = (int)floor(m_LastPosY + 0.1);
+ int RelZ = (int)floor(m_LastPosZ) - a_Chunk.GetPosZ() * cChunkDef::Width;
+ // Use Unbounded, because we're being called *after* processing super::Tick(), which could have changed our chunk
+ VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockIn));
+
+ // Apply the exhaustion based on distance travelled:
+ double BaseExhaustion = Movement.Length();
+ if (IsSprinting())
+ {
+ // 0.1 pt per meter sprinted
+ BaseExhaustion = BaseExhaustion * 0.1;
+ }
+ else if (IsBlockWater(BlockIn))
+ {
+ // 0.015 pt per meter swum
+ BaseExhaustion = BaseExhaustion * 0.015;
+ }
+ else
+ {
+ // 0.01 pt per meter walked / sneaked
+ BaseExhaustion = BaseExhaustion * 0.01;
+ }
+ m_FoodExhaustionLevel += BaseExhaustion;
+}
+
+
+
+
diff --git a/source/Player.h b/source/Player.h
index fed222157..eea8c1596 100644
--- a/source/Player.h
+++ b/source/Player.h
@@ -28,6 +28,7 @@ public:
{
MAX_HEALTH = 20,
MAX_FOOD_LEVEL = 20,
+ EATING_TICKS = 30, ///< Number of ticks it takes to eat an item
} ;
// tolua_end
@@ -65,7 +66,7 @@ public:
double GetEyeHeight(void) const; // tolua_export
Vector3d GetEyePosition(void) const; // tolua_export
inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export
- inline const double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc.
+ inline const 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 const cInventory & GetInventory(void) const { return m_Inventory; }
@@ -73,18 +74,42 @@ public:
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override;
- eGameMode GetGameMode(void) const { return m_GameMode; } // tolua_export
- std::string GetIP() { return m_IP; } // tolua_export
- float GetLastBlockActionTime() { return m_LastBlockActionTime; } // tolua_export
- int GetLastBlockActionCnt() { return m_LastBlockActionCnt; } // tolua_export
- void SetLastBlockActionCnt( int ); // tolua_export
- void SetLastBlockActionTime(); // tolua_export
- void SetGameMode( eGameMode a_GameMode ); // tolua_export
- void LoginSetGameMode( eGameMode a_GameMode );
+ // tolua_begin
+
+ /// Returns the current gamemode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable
+ eGameMode GetGameMode(void) const { return m_GameMode; }
+
+ /** Sets the gamemode for the player.
+ The gamemode may be gmNotSet, in that case the player inherits the world's gamemode.
+ Updates the gamemode on the client (sends the packet)
+ */
+ void SetGameMode(eGameMode a_GameMode);
+
+ /// Returns true if the player is in Creative mode, either explicitly, or by inheriting from current world
+ bool IsGameModeCreative(void) const;
+
+ /// Returns true if the player is in Survival mode, either explicitly, or by inheriting from current world
+ bool IsGameModeSurvival(void) const;
+
+ /// Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current world
+ bool IsGameModeAdventure(void) const;
+
+ AString GetIP(void) const { return m_IP; } // tolua_export
+
+ // tolua_end
+
void SetIP(const AString & a_IP);
+ float GetLastBlockActionTime() { return m_LastBlockActionTime; }
+ int GetLastBlockActionCnt() { return m_LastBlockActionCnt; }
+ void SetLastBlockActionCnt( int );
+ void SetLastBlockActionTime();
+
+ // Sets the current gamemode, doesn't check validity, doesn't send update packets to client
+ void LoginSetGameMode(eGameMode a_GameMode);
+
/// Tries to move to a new position, with collision checks and stuff
- virtual void MoveTo( const Vector3d & a_NewPos ); // tolua_export
+ virtual void MoveTo( const Vector3d & a_NewPos ); // tolua_export
cWindow * GetWindow(void) { return m_CurrentWindow; } // tolua_export
const cWindow * GetWindow(void) const { return m_CurrentWindow; }
@@ -136,6 +161,9 @@ public:
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); }
+
void SetFoodLevel (int a_FoodLevel);
void SetFoodSaturationLevel (double a_FoodSaturationLevel);
void SetFoodTickTimer (int a_FoodTickTimer);
@@ -151,8 +179,20 @@ public:
/// Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two
void FoodPoison(int a_NumTicks);
+ /// Returns true if the player is currently in the process of eating the currently equipped item
+ bool IsEating(void) const { return (m_EatingFinishTick >= 0); }
+
// tolua_end
+ /// Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet
+ void StartEating(void);
+
+ /// Finishes eating the currently equipped item. Consumes the item, updates health and broadcasts the packets
+ void FinishEating(void);
+
+ /// Aborts the current eating operation
+ void AbortEating(void);
+
virtual void KilledBy(cEntity * a_Killer) override;
void Respawn(void); // tolua_export
@@ -214,6 +254,7 @@ public:
// 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(); }
protected:
typedef std::map< std::string, bool > PermissionMap;
@@ -285,6 +326,9 @@ protected:
bool m_IsCrouched;
bool m_IsSprinting;
+ /// The world tick in which eating will be finished. -1 if not eating
+ Int64 m_EatingFinishTick;
+
virtual void Destroyed(void);
diff --git a/source/Plugin_NewLua.cpp b/source/Plugin_NewLua.cpp
index c79106761..f4c05ab42 100644
--- a/source/Plugin_NewLua.cpp
+++ b/source/Plugin_NewLua.cpp
@@ -1565,7 +1565,7 @@ const char * cPlugin_NewLua::GetHookFnName(cPluginManager::PluginHook a_Hook)
-AString cPlugin_NewLua::HandleWebRequest( HTTPRequest * a_Request )
+AString cPlugin_NewLua::HandleWebRequest(const HTTPRequest * a_Request )
{
cCSLock Lock(m_CriticalSection);
std::string RetVal = "";
@@ -1592,7 +1592,7 @@ AString cPlugin_NewLua::HandleWebRequest( HTTPRequest * a_Request )
//LOGINFO("2. Stack size: %i", lua_gettop(m_LuaState) );
// Push HTTPRequest
- tolua_pushusertype( m_LuaState, a_Request, "HTTPRequest" );
+ tolua_pushusertype( m_LuaState, (void*)a_Request, "const HTTPRequest" );
//LOGINFO("Calling bound function! :D");
int s = lua_pcall( m_LuaState, 1, 1, 0);
diff --git a/source/Plugin_NewLua.h b/source/Plugin_NewLua.h
index 8d51c86f6..1ca208e9d 100644
--- a/source/Plugin_NewLua.h
+++ b/source/Plugin_NewLua.h
@@ -86,10 +86,10 @@ public:
virtual bool CanAddHook(cPluginManager::PluginHook a_Hook) override;
// cWebPlugin override
- virtual const AString & GetWebTitle(void) const {return GetName(); }
+ virtual const AString GetWebTitle(void) const {return GetName(); }
// cWebPlugin and WebAdmin stuff
- virtual AString HandleWebRequest( HTTPRequest * a_Request ) override;
+ 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.
diff --git a/source/Plugin_Squirrel.cpp b/source/Plugin_Squirrel.cpp
index 27fd01a09..adca4b519 100644
--- a/source/Plugin_Squirrel.cpp
+++ b/source/Plugin_Squirrel.cpp
@@ -1,409 +1,409 @@
-
-#include "Globals.h"
-
-
-
-
-#ifdef USE_SUIRREL
-
-
-
-
-
-#include "Plugin_Squirrel.h"
-#include "squirrelbindings/SquirrelFunctions.h"
-#include "squirrelbindings/SquirrelBindings.h"
-#include "squirrelbindings/SquirrelBaseClass.h"
-
-
-cPlugin_Squirrel::cPlugin_Squirrel( const char* a_PluginName )
- : cPlugin( a_PluginName )
-{
- SetLanguage( cPlugin::E_SQUIRREL );
- m_PluginName = a_PluginName;
-}
-
-cPlugin_Squirrel::~cPlugin_Squirrel()
-{
- delete m_Plugin;
-}
-
-bool cPlugin_Squirrel::Initialize()
-{
- cCSLock Lock(m_CriticalSection);
-
- std::string PluginPath = std::string("Plugins/") + m_PluginName + ".nut";
-
- Sqrat::Script script;
- script.CompileFile(PluginPath);
- if(script.IsNull())
- {
- LOGERROR("Unable to run script \"%s\"", m_PluginName);
- }
-
- try {
- script.Run();
-
- Sqrat::Function construct(Sqrat::RootTable(), m_PluginName);
-
- if(construct.IsNull())
- {
- LOGERROR("Constructor for Plugin \"%s\" not found.", m_PluginName);
- return false;
- }
-
- Sqrat::Object obj = construct.Evaluate<Sqrat::Object>();
-
- ((cSquirrelBaseClass *) obj.GetInstanceUP())->setInstance(this);
-
- m_Plugin = new SquirrelObject(obj);
-
-
- Sqrat::Object PluginName = obj.GetSlot("name");
- if(!PluginName.IsNull())
- {
- this->SetName(PluginName.Cast<const char*>());
- }
-
- Sqrat::Function init = m_Plugin->GetFunction("Initialize");
- if(init.IsNull())
- {
- LOGERROR("Can not initialize plugin \"%s\"", m_PluginName);
- return false;
- }
-
- return init.Evaluate<bool>();
-
- } catch(Sqrat::Exception &e)
- {
- LOGERROR("Initialisation of \"%s\" failed: %s", m_PluginName, e.Message().c_str());
- return false;
- }
-}
-
-
-
-
-
-void cPlugin_Squirrel::OnDisable()
-{
- cCSLock Lock(m_CriticalSection);
-
- if(!m_Plugin->HasFunction("OnDisable")) return;
-
- m_Plugin->GetFunction("OnDisable").Execute();
-}
-
-
-
-
-
-void cPlugin_Squirrel::Tick(float a_Dt)
-{
- cCSLock Lock( m_CriticalSection );
-
- if(!m_Plugin->HasFunction("OnTick")) return;
-
- m_Plugin->GetFunction("OnTick").Execute(a_Dt);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnCollectPickup(cPlayer * a_Player, cPickup * a_Pickup)
-{
- cCSLock Lock(m_CriticalSection);
-
- if (!m_Plugin->HasFunction("OnCollectPickup"))
- {
- return false;
- }
-
- return m_Plugin->GetFunction("OnCollectPickup").Evaluate<bool>(a_Player, a_Pickup);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnDisconnect(cPlayer* a_Player, const AString & a_Reason)
-{
- cCSLock Lock( m_CriticalSection );
-
- if (!m_Plugin->HasFunction("OnDisconnect")) return false;
-
- return m_Plugin->GetFunction("OnDisconnect").Evaluate<bool>(a_Player, a_Reason);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnBlockPlace(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem)
-{
- cCSLock Lock(m_CriticalSection);
-
- if (!m_Plugin->HasFunction("OnBlockPlace")) return false;
-
- return m_Plugin->GetFunction("OnBlockPlace").Evaluate<bool>(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_HeldItem);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnBlockDig(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta)
-{
- cCSLock Lock(m_CriticalSection);
-
- if (!m_Plugin->HasFunction("OnBlockDig")) return false;
-
- return m_Plugin->GetFunction("OnBlockDig").Evaluate<bool>(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status, a_OldBlock, a_OldMeta);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnChat(cPlayer * a_Player, const AString & a_Message)
-{
- cCSLock Lock(m_CriticalSection);
-
- if (!m_Plugin->HasFunction("OnChat")) return false;
-
- return m_Plugin->GetFunction("OnChat").Evaluate<bool>(a_Player, a_Message);
-
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username)
-{
- cCSLock Lock( m_CriticalSection );
-
- if (!m_Plugin->HasFunction("OnLogin"))
- {
- return false;
- }
-
- return m_Plugin->GetFunction("OnLogin").Evaluate<bool>(a_Client, a_ProtocolVersion, a_Username);
-}
-
-
-
-
-
-void cPlugin_Squirrel::OnPlayerSpawn( cPlayer* a_Player )
-{
- cCSLock Lock( m_CriticalSection );
-
- if(!m_Plugin->HasFunction("OnPlayerSpawn")) return;
-
- return m_Plugin->GetFunction("OnPlayerSpawn").Execute(a_Player);
-
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnPlayerJoin( cPlayer* a_Player )
-{
- cCSLock Lock( m_CriticalSection );
-
- if(!m_Plugin->HasFunction("OnPlayerJoin")) return false;
-
- return m_Plugin->GetFunction("OnPlayerJoin").Evaluate<bool>(a_Player);
-}
-
-
-
-
-
-void cPlugin_Squirrel::OnPlayerMove( cPlayer* a_Player )
-{
- cCSLock Lock( m_CriticalSection );
-
- if(!m_Plugin->HasFunction("OnPlayerMove")) return;
-
- return m_Plugin->GetFunction("OnPlayerMove").Execute(a_Player);
-
-}
-
-
-
-
-
-void cPlugin_Squirrel::OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo )
-{
- cCSLock Lock( m_CriticalSection );
-
- if(!m_Plugin->HasFunction("OnTakeDamage")) return;
-
- return m_Plugin->GetFunction("OnTakeDamage")(a_Pawn, a_TakeDamageInfo);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnKilled( cPawn* a_Killed, cEntity* a_Killer )
-{
- cCSLock Lock( m_CriticalSection );
- if(!m_Plugin->HasFunction("OnKilled")) return false;
- return m_Plugin->GetFunction("OnKilled").Evaluate<bool>(a_Killed, a_Killer);
-}
-
-
-
-
-
-void cPlugin_Squirrel::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
-{
- cCSLock Lock(m_CriticalSection);
- if(!m_Plugin->HasFunction("OnChunkGenerated")) return;
- return m_Plugin->GetFunction("OnChunkGenerated")(a_World, a_ChunkX, a_ChunkZ);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_pLuaChunk)
-{
- cCSLock Lock(m_CriticalSection);
- if(!m_Plugin->HasFunction("OnChunkGenerating")) return false;
- return m_Plugin->GetFunction("OnChunkGenerating").Evaluate<bool>(a_World, a_ChunkX, a_ChunkZ, a_pLuaChunk);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
-{
- cCSLock Lock(m_CriticalSection);
- if(!m_Plugin->HasFunction("OnPreCrafting")) return false;
- return m_Plugin->GetFunction("OnPreCrafting").Evaluate<bool>((cPlayer *) a_Player, (cCraftingGrid *) a_Grid, a_Recipe);
-
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
-{
- cCSLock Lock(m_CriticalSection);
- if(!m_Plugin->HasFunction("OnCraftingNoRecipe")) return false;
- return m_Plugin->GetFunction("OnCraftingNoRecipe").Evaluate<bool>((cPlayer *) a_Player, (cCraftingGrid *) a_Grid, a_Recipe);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
-{
- cCSLock Lock(m_CriticalSection);
-
- if(!m_Plugin->HasFunction("OnPostCrafting")) return false;
- return m_Plugin->GetFunction("OnPostCrafting").Evaluate<bool>((cPlayer *) a_Player, (cCraftingGrid *) a_Grid, a_Recipe);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnBlockToPickup(
- BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
- const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups
-)
-{
- cCSLock Lock(m_CriticalSection);
-
- if(!m_Plugin->HasFunction("OnBlockToPickup")) return false;
- return m_Plugin->GetFunction("OnBlockToPickup").Evaluate<bool>(a_BlockType, a_BlockMeta, (cPlayer *) a_Player, a_EquippedItem, a_Pickups);
-
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnWeatherChanged(cWorld * a_World)
-{
- cCSLock Lock(m_CriticalSection);
-
- if(!m_Plugin->HasFunction("OnWeatherChanged")) return false;
- return m_Plugin->GetFunction("OnWeatherChanged").Evaluate<bool>(a_World);
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnUpdatingSign(
- 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
-)
-{
- cCSLock Lock(m_CriticalSection);
-
- if(!m_Plugin->HasFunction("OnUpdatingSign")) return false;
- return m_Plugin->GetFunction("OnUpdatingSign")
- .Evaluate<bool>(
- a_World,
- a_BlockX,
- a_BlockY,
- a_BlockZ,
- a_Line1,
- a_Line2,
- a_Line3,
- a_Line4,
- a_Player
- );
-}
-
-
-
-
-
-bool cPlugin_Squirrel::OnUpdatedSign(
- 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
-)
-{
- cCSLock Lock(m_CriticalSection);
-
- if(!m_Plugin->HasFunction("OnUpdatedSign")) return false;
- return m_Plugin->GetFunction("OnUpdatedSign")
- .Evaluate<bool>(
- a_World,
- a_BlockX,
- a_BlockY,
- a_BlockZ,
- a_Line1,
- a_Line2,
- a_Line3,
- a_Line4,
- a_Player
- );
-}
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#include "Globals.h"
+
+
+
+
+#ifdef USE_SUIRREL
+
+
+
+
+
+#include "Plugin_Squirrel.h"
+#include "squirrelbindings/SquirrelFunctions.h"
+#include "squirrelbindings/SquirrelBindings.h"
+#include "squirrelbindings/SquirrelBaseClass.h"
+
+
+cPlugin_Squirrel::cPlugin_Squirrel( const char* a_PluginName )
+ : cPlugin( a_PluginName )
+{
+ SetLanguage( cPlugin::E_SQUIRREL );
+ m_PluginName = a_PluginName;
+}
+
+cPlugin_Squirrel::~cPlugin_Squirrel()
+{
+ delete m_Plugin;
+}
+
+bool cPlugin_Squirrel::Initialize()
+{
+ cCSLock Lock(m_CriticalSection);
+
+ std::string PluginPath = std::string("Plugins/") + m_PluginName + ".nut";
+
+ Sqrat::Script script;
+ script.CompileFile(PluginPath);
+ if(script.IsNull())
+ {
+ LOGERROR("Unable to run script \"%s\"", m_PluginName);
+ }
+
+ try {
+ script.Run();
+
+ Sqrat::Function construct(Sqrat::RootTable(), m_PluginName);
+
+ if(construct.IsNull())
+ {
+ LOGERROR("Constructor for Plugin \"%s\" not found.", m_PluginName);
+ return false;
+ }
+
+ Sqrat::Object obj = construct.Evaluate<Sqrat::Object>();
+
+ ((cSquirrelBaseClass *) obj.GetInstanceUP())->setInstance(this);
+
+ m_Plugin = new SquirrelObject(obj);
+
+
+ Sqrat::Object PluginName = obj.GetSlot("name");
+ if(!PluginName.IsNull())
+ {
+ this->SetName(PluginName.Cast<const char*>());
+ }
+
+ Sqrat::Function init = m_Plugin->GetFunction("Initialize");
+ if(init.IsNull())
+ {
+ LOGERROR("Can not initialize plugin \"%s\"", m_PluginName);
+ return false;
+ }
+
+ return init.Evaluate<bool>();
+
+ } catch(Sqrat::Exception &e)
+ {
+ LOGERROR("Initialisation of \"%s\" failed: %s", m_PluginName, e.Message().c_str());
+ return false;
+ }
+}
+
+
+
+
+
+void cPlugin_Squirrel::OnDisable()
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if(!m_Plugin->HasFunction("OnDisable")) return;
+
+ m_Plugin->GetFunction("OnDisable").Execute();
+}
+
+
+
+
+
+void cPlugin_Squirrel::Tick(float a_Dt)
+{
+ cCSLock Lock( m_CriticalSection );
+
+ if(!m_Plugin->HasFunction("OnTick")) return;
+
+ m_Plugin->GetFunction("OnTick").Execute(a_Dt);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnCollectPickup(cPlayer * a_Player, cPickup * a_Pickup)
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if (!m_Plugin->HasFunction("OnCollectPickup"))
+ {
+ return false;
+ }
+
+ return m_Plugin->GetFunction("OnCollectPickup").Evaluate<bool>(a_Player, a_Pickup);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnDisconnect(cPlayer* a_Player, const AString & a_Reason)
+{
+ cCSLock Lock( m_CriticalSection );
+
+ if (!m_Plugin->HasFunction("OnDisconnect")) return false;
+
+ return m_Plugin->GetFunction("OnDisconnect").Evaluate<bool>(a_Player, a_Reason);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnBlockPlace(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem)
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if (!m_Plugin->HasFunction("OnBlockPlace")) return false;
+
+ return m_Plugin->GetFunction("OnBlockPlace").Evaluate<bool>(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_HeldItem);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnBlockDig(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta)
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if (!m_Plugin->HasFunction("OnBlockDig")) return false;
+
+ return m_Plugin->GetFunction("OnBlockDig").Evaluate<bool>(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status, a_OldBlock, a_OldMeta);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnChat(cPlayer * a_Player, const AString & a_Message)
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if (!m_Plugin->HasFunction("OnChat")) return false;
+
+ return m_Plugin->GetFunction("OnChat").Evaluate<bool>(a_Player, a_Message);
+
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username)
+{
+ cCSLock Lock( m_CriticalSection );
+
+ if (!m_Plugin->HasFunction("OnLogin"))
+ {
+ return false;
+ }
+
+ return m_Plugin->GetFunction("OnLogin").Evaluate<bool>(a_Client, a_ProtocolVersion, a_Username);
+}
+
+
+
+
+
+void cPlugin_Squirrel::OnPlayerSpawn( cPlayer* a_Player )
+{
+ cCSLock Lock( m_CriticalSection );
+
+ if(!m_Plugin->HasFunction("OnPlayerSpawn")) return;
+
+ return m_Plugin->GetFunction("OnPlayerSpawn").Execute(a_Player);
+
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnPlayerJoin( cPlayer* a_Player )
+{
+ cCSLock Lock( m_CriticalSection );
+
+ if(!m_Plugin->HasFunction("OnPlayerJoin")) return false;
+
+ return m_Plugin->GetFunction("OnPlayerJoin").Evaluate<bool>(a_Player);
+}
+
+
+
+
+
+void cPlugin_Squirrel::OnPlayerMove( cPlayer* a_Player )
+{
+ cCSLock Lock( m_CriticalSection );
+
+ if(!m_Plugin->HasFunction("OnPlayerMove")) return;
+
+ return m_Plugin->GetFunction("OnPlayerMove").Execute(a_Player);
+
+}
+
+
+
+
+
+void cPlugin_Squirrel::OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo )
+{
+ cCSLock Lock( m_CriticalSection );
+
+ if(!m_Plugin->HasFunction("OnTakeDamage")) return;
+
+ return m_Plugin->GetFunction("OnTakeDamage")(a_Pawn, a_TakeDamageInfo);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnKilled( cPawn* a_Killed, cEntity* a_Killer )
+{
+ cCSLock Lock( m_CriticalSection );
+ if(!m_Plugin->HasFunction("OnKilled")) return false;
+ return m_Plugin->GetFunction("OnKilled").Evaluate<bool>(a_Killed, a_Killer);
+}
+
+
+
+
+
+void cPlugin_Squirrel::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
+{
+ cCSLock Lock(m_CriticalSection);
+ if(!m_Plugin->HasFunction("OnChunkGenerated")) return;
+ return m_Plugin->GetFunction("OnChunkGenerated")(a_World, a_ChunkX, a_ChunkZ);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_pLuaChunk)
+{
+ cCSLock Lock(m_CriticalSection);
+ if(!m_Plugin->HasFunction("OnChunkGenerating")) return false;
+ return m_Plugin->GetFunction("OnChunkGenerating").Evaluate<bool>(a_World, a_ChunkX, a_ChunkZ, a_pLuaChunk);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
+{
+ cCSLock Lock(m_CriticalSection);
+ if(!m_Plugin->HasFunction("OnPreCrafting")) return false;
+ return m_Plugin->GetFunction("OnPreCrafting").Evaluate<bool>((cPlayer *) a_Player, (cCraftingGrid *) a_Grid, a_Recipe);
+
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
+{
+ cCSLock Lock(m_CriticalSection);
+ if(!m_Plugin->HasFunction("OnCraftingNoRecipe")) return false;
+ return m_Plugin->GetFunction("OnCraftingNoRecipe").Evaluate<bool>((cPlayer *) a_Player, (cCraftingGrid *) a_Grid, a_Recipe);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if(!m_Plugin->HasFunction("OnPostCrafting")) return false;
+ return m_Plugin->GetFunction("OnPostCrafting").Evaluate<bool>((cPlayer *) a_Player, (cCraftingGrid *) a_Grid, a_Recipe);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnBlockToPickup(
+ BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups
+)
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if(!m_Plugin->HasFunction("OnBlockToPickup")) return false;
+ return m_Plugin->GetFunction("OnBlockToPickup").Evaluate<bool>(a_BlockType, a_BlockMeta, (cPlayer *) a_Player, a_EquippedItem, a_Pickups);
+
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnWeatherChanged(cWorld * a_World)
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if(!m_Plugin->HasFunction("OnWeatherChanged")) return false;
+ return m_Plugin->GetFunction("OnWeatherChanged").Evaluate<bool>(a_World);
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnUpdatingSign(
+ 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
+)
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if(!m_Plugin->HasFunction("OnUpdatingSign")) return false;
+ return m_Plugin->GetFunction("OnUpdatingSign")
+ .Evaluate<bool>(
+ a_World,
+ a_BlockX,
+ a_BlockY,
+ a_BlockZ,
+ a_Line1,
+ a_Line2,
+ a_Line3,
+ a_Line4,
+ a_Player
+ );
+}
+
+
+
+
+
+bool cPlugin_Squirrel::OnUpdatedSign(
+ 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
+)
+{
+ cCSLock Lock(m_CriticalSection);
+
+ if(!m_Plugin->HasFunction("OnUpdatedSign")) return false;
+ return m_Plugin->GetFunction("OnUpdatedSign")
+ .Evaluate<bool>(
+ a_World,
+ a_BlockX,
+ a_BlockY,
+ a_BlockZ,
+ a_Line1,
+ a_Line2,
+ a_Line3,
+ a_Line4,
+ a_Player
+ );
+}
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/Plugin_Squirrel.h b/source/Plugin_Squirrel.h
index 27b1dd909..1a56172e9 100644
--- a/source/Plugin_Squirrel.h
+++ b/source/Plugin_Squirrel.h
@@ -1,69 +1,69 @@
-
-#pragma once
-
-
-
-
-
-#ifdef USE_SQUIRREL
-
-
-
-
-
-#include "Plugin.h"
-#include <sqrat.h>
-#include "squirrelbindings/SquirrelObject.h"
-
-
-
-
-
-class cPlugin_Squirrel :
- public cPlugin
-{
-public:
- cPlugin_Squirrel(const char* a_PluginName);
- ~cPlugin_Squirrel();
-
- void OnDisable();
- bool Initialize();
-
- void Tick(float a_Dt);
-
- virtual bool OnBlockDig (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) override;
- virtual bool OnBlockPlace (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) override;
- virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups);
- virtual bool OnChat (cPlayer * a_Player, const AString & a_Message) override;
- virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
- virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_pLuaChunk ) override;
- virtual bool OnCollectPickup (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 OnKilled (cPawn* a_Killed, cEntity* a_Killer ) override;
- virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override;
- virtual bool OnPlayerJoin (cPlayer* a_Player ) override;
- virtual void OnPlayerMove (cPlayer* a_Player ) override;
- virtual void OnPlayerSpawn (cPlayer* a_Player ) 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 void OnTakeDamage (cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ) override;
- virtual bool OnUpdatedSign (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) override;
- virtual bool OnUpdatingSign (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) override;
- virtual bool OnWeatherChanged (cWorld * a_World) override;
-
-protected:
- const char * m_PluginName;
- cCriticalSection m_CriticalSection;
- SquirrelObject *m_Plugin;
-};
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#pragma once
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
+#include "Plugin.h"
+#include <sqrat.h>
+#include "squirrelbindings/SquirrelObject.h"
+
+
+
+
+
+class cPlugin_Squirrel :
+ public cPlugin
+{
+public:
+ cPlugin_Squirrel(const char* a_PluginName);
+ ~cPlugin_Squirrel();
+
+ void OnDisable();
+ bool Initialize();
+
+ void Tick(float a_Dt);
+
+ virtual bool OnBlockDig (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) override;
+ virtual bool OnBlockPlace (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) override;
+ virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups);
+ virtual bool OnChat (cPlayer * a_Player, const AString & a_Message) override;
+ virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
+ virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_pLuaChunk ) override;
+ virtual bool OnCollectPickup (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 OnKilled (cPawn* a_Killed, cEntity* a_Killer ) override;
+ virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override;
+ virtual bool OnPlayerJoin (cPlayer* a_Player ) override;
+ virtual void OnPlayerMove (cPlayer* a_Player ) override;
+ virtual void OnPlayerSpawn (cPlayer* a_Player ) 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 void OnTakeDamage (cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ) override;
+ virtual bool OnUpdatedSign (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) override;
+ virtual bool OnUpdatingSign (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) override;
+ virtual bool OnWeatherChanged (cWorld * a_World) override;
+
+protected:
+ const char * m_PluginName;
+ cCriticalSection m_CriticalSection;
+ SquirrelObject *m_Plugin;
+};
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/ProbabDistrib.cpp b/source/ProbabDistrib.cpp
index 98c18b8e1..5fa17c276 100644
--- a/source/ProbabDistrib.cpp
+++ b/source/ProbabDistrib.cpp
@@ -1,142 +1,142 @@
-
-// ProbabDistrib.cpp
-
-// Implements the cProbabDistrib class representing a discrete probability distribution curve and random generator
-
-#include "Globals.h"
-#include "ProbabDistrib.h"
-#include "MersenneTwister.h"
-
-
-
-
-
-
-cProbabDistrib::cProbabDistrib(int a_MaxValue) :
- m_MaxValue(a_MaxValue),
- m_Sum(-1)
-{
-}
-
-
-
-
-
-
-void cProbabDistrib::SetPoints(const cProbabDistrib::cPoints & a_Points)
-{
- ASSERT(!a_Points.empty());
- m_Sum = 0;
- m_Cumulative.clear();
- m_Cumulative.reserve(a_Points.size() + 1);
- int ProbSum = 0;
- int LastProb = 0;
- int LastValue = -1;
- if (a_Points[0].m_Value != 0)
- {
- m_Cumulative.push_back(cPoint(0, 0)); // Always push in the [0, 0] point for easier search algorithm bounds
- LastValue = 0;
- }
- for (cPoints::const_iterator itr = a_Points.begin(), end = a_Points.end(); itr != end; ++itr)
- {
- if (itr->m_Value == LastValue)
- {
- continue;
- }
-
- // Add the current trapezoid to the sum:
- ProbSum += (LastProb + itr->m_Probability) * (itr->m_Value - LastValue) / 2;
- LastProb = itr->m_Probability;
- LastValue = itr->m_Value;
- m_Cumulative.push_back(cPoint(itr->m_Value, ProbSum));
- } // for itr - a_Points[]
- if (LastValue != m_MaxValue)
- {
- m_Cumulative.push_back(cPoint(m_MaxValue, 0)); // Always push in the last point for easier search algorithm bounds
- }
- m_Sum = ProbSum;
-}
-
-
-
-
-
-bool cProbabDistrib::SetDefString(const AString & a_DefString)
-{
- AStringVector Points = StringSplitAndTrim(a_DefString, ";");
- if (Points.empty())
- {
- return false;
- }
- cPoints Pts;
- for (AStringVector::const_iterator itr = Points.begin(), end = Points.end(); itr != end; ++itr)
- {
- AStringVector Split = StringSplitAndTrim(*itr, ",");
- if (Split.size() != 2)
- {
- // Bad format
- return false;
- }
- int Value = atoi(Split[0].c_str());
- int Prob = atoi(Split[1].c_str());
- if (
- ((Value == 0) && (Split[0] != "0")) ||
- ((Prob == 0) && (Split[1] != "0"))
- )
- {
- // Number parse error
- return false;
- }
- Pts.push_back(cPoint(Value, Prob));
- } // for itr - Points[]
-
- SetPoints(Pts);
- return true;
-}
-
-
-
-
-
-int cProbabDistrib::Random(MTRand & a_Rand) const
-{
- int v = a_Rand.randInt(m_Sum);
- return MapValue(v);
-}
-
-
-
-
-
-int cProbabDistrib::MapValue(int a_OrigValue) const
-{
- ASSERT(a_OrigValue >= 0);
- ASSERT(a_OrigValue < m_Sum);
-
- // Binary search through m_Cumulative for placement:
- size_t Lo = 0;
- size_t Hi = m_Cumulative.size() - 1;
- while (Hi - Lo > 1)
- {
- int Mid = (Lo + Hi) / 2;
- int MidProbab = m_Cumulative[Mid].m_Probability;
- if (MidProbab < a_OrigValue)
- {
- Lo = Mid;
- }
- else
- {
- Hi = Mid;
- }
- }
- ASSERT(Hi - Lo == 1);
-
- // Linearly interpolate between Lo and Hi:
- int ProbDif = m_Cumulative[Hi].m_Probability - m_Cumulative[Lo].m_Probability;
- int ValueDif = m_Cumulative[Hi].m_Value - m_Cumulative[Lo].m_Value;
- return m_Cumulative[Lo].m_Value + (a_OrigValue - m_Cumulative[Lo].m_Probability) * ValueDif / ProbDif;
-}
-
-
-
-
+
+// ProbabDistrib.cpp
+
+// Implements the cProbabDistrib class representing a discrete probability distribution curve and random generator
+
+#include "Globals.h"
+#include "ProbabDistrib.h"
+#include "MersenneTwister.h"
+
+
+
+
+
+
+cProbabDistrib::cProbabDistrib(int a_MaxValue) :
+ m_MaxValue(a_MaxValue),
+ m_Sum(-1)
+{
+}
+
+
+
+
+
+
+void cProbabDistrib::SetPoints(const cProbabDistrib::cPoints & a_Points)
+{
+ ASSERT(!a_Points.empty());
+ m_Sum = 0;
+ m_Cumulative.clear();
+ m_Cumulative.reserve(a_Points.size() + 1);
+ int ProbSum = 0;
+ int LastProb = 0;
+ int LastValue = -1;
+ if (a_Points[0].m_Value != 0)
+ {
+ m_Cumulative.push_back(cPoint(0, 0)); // Always push in the [0, 0] point for easier search algorithm bounds
+ LastValue = 0;
+ }
+ for (cPoints::const_iterator itr = a_Points.begin(), end = a_Points.end(); itr != end; ++itr)
+ {
+ if (itr->m_Value == LastValue)
+ {
+ continue;
+ }
+
+ // Add the current trapezoid to the sum:
+ ProbSum += (LastProb + itr->m_Probability) * (itr->m_Value - LastValue) / 2;
+ LastProb = itr->m_Probability;
+ LastValue = itr->m_Value;
+ m_Cumulative.push_back(cPoint(itr->m_Value, ProbSum));
+ } // for itr - a_Points[]
+ if (LastValue != m_MaxValue)
+ {
+ m_Cumulative.push_back(cPoint(m_MaxValue, 0)); // Always push in the last point for easier search algorithm bounds
+ }
+ m_Sum = ProbSum;
+}
+
+
+
+
+
+bool cProbabDistrib::SetDefString(const AString & a_DefString)
+{
+ AStringVector Points = StringSplitAndTrim(a_DefString, ";");
+ if (Points.empty())
+ {
+ return false;
+ }
+ cPoints Pts;
+ for (AStringVector::const_iterator itr = Points.begin(), end = Points.end(); itr != end; ++itr)
+ {
+ AStringVector Split = StringSplitAndTrim(*itr, ",");
+ if (Split.size() != 2)
+ {
+ // Bad format
+ return false;
+ }
+ int Value = atoi(Split[0].c_str());
+ int Prob = atoi(Split[1].c_str());
+ if (
+ ((Value == 0) && (Split[0] != "0")) ||
+ ((Prob == 0) && (Split[1] != "0"))
+ )
+ {
+ // Number parse error
+ return false;
+ }
+ Pts.push_back(cPoint(Value, Prob));
+ } // for itr - Points[]
+
+ SetPoints(Pts);
+ return true;
+}
+
+
+
+
+
+int cProbabDistrib::Random(MTRand & a_Rand) const
+{
+ int v = a_Rand.randInt(m_Sum);
+ return MapValue(v);
+}
+
+
+
+
+
+int cProbabDistrib::MapValue(int a_OrigValue) const
+{
+ ASSERT(a_OrigValue >= 0);
+ ASSERT(a_OrigValue < m_Sum);
+
+ // Binary search through m_Cumulative for placement:
+ size_t Lo = 0;
+ size_t Hi = m_Cumulative.size() - 1;
+ while (Hi - Lo > 1)
+ {
+ int Mid = (Lo + Hi) / 2;
+ int MidProbab = m_Cumulative[Mid].m_Probability;
+ if (MidProbab < a_OrigValue)
+ {
+ Lo = Mid;
+ }
+ else
+ {
+ Hi = Mid;
+ }
+ }
+ ASSERT(Hi - Lo == 1);
+
+ // Linearly interpolate between Lo and Hi:
+ int ProbDif = m_Cumulative[Hi].m_Probability - m_Cumulative[Lo].m_Probability;
+ int ValueDif = m_Cumulative[Hi].m_Value - m_Cumulative[Lo].m_Value;
+ return m_Cumulative[Lo].m_Value + (a_OrigValue - m_Cumulative[Lo].m_Probability) * ValueDif / ProbDif;
+}
+
+
+
+
diff --git a/source/ProbabDistrib.h b/source/ProbabDistrib.h
index ac5f24894..ddaadd9b7 100644
--- a/source/ProbabDistrib.h
+++ b/source/ProbabDistrib.h
@@ -1,74 +1,74 @@
-
-// ProbabDistrib.h
-
-// Declares the cProbabDistrib class representing a discrete probability distribution curve and random generator
-
-/*
-Usage:
-1, Create a cProbabDistrib instance
-2, Initialize the distribution either programmatically, using the SetPoints() function, or using a definition string
-3, Ask for random numbers in that probability distribution using the Random() function
-*/
-
-
-
-
-
-#pragma once
-
-
-
-
-
-// fwd:
-class MTRand;
-
-
-
-
-
-class cProbabDistrib
-{
-public:
- class cPoint
- {
- public:
- int m_Value;
- int m_Probability;
-
- cPoint(int a_Value, int a_Probability) :
- m_Value(a_Value),
- m_Probability(a_Probability)
- {
- }
- } ;
-
- typedef std::vector<cPoint> cPoints;
-
-
- cProbabDistrib(int a_MaxValue);
-
- /// Sets the distribution curve using an array of [value, probability] points, linearly interpolated. a_Points must not be empty.
- void SetPoints(const cPoints & a_Points);
-
- /// Sets the distribution curve using a definition string; returns true on successful parse
- bool SetDefString(const AString & a_DefString);
-
- /// Gets a random value from a_Rand, shapes it into the distribution curve and returns the value.
- int Random(MTRand & a_Rand) const;
-
- /// Maps value in range [0, m_Sum] into the range [0, m_MaxValue] using the stored probability
- int MapValue(int a_OrigValue) const;
-
- int GetSum(void) const { return m_Sum; }
-
-protected:
-
- int m_MaxValue;
- cPoints m_Cumulative; ///< Cumulative probability of the values, sorted, for fast bsearch lookup
- int m_Sum; ///< Sum of all the probabilities across all values in the domain; -1 if not set
-} ;
-
-
-
-
+
+// ProbabDistrib.h
+
+// Declares the cProbabDistrib class representing a discrete probability distribution curve and random generator
+
+/*
+Usage:
+1, Create a cProbabDistrib instance
+2, Initialize the distribution either programmatically, using the SetPoints() function, or using a definition string
+3, Ask for random numbers in that probability distribution using the Random() function
+*/
+
+
+
+
+
+#pragma once
+
+
+
+
+
+// fwd:
+class MTRand;
+
+
+
+
+
+class cProbabDistrib
+{
+public:
+ class cPoint
+ {
+ public:
+ int m_Value;
+ int m_Probability;
+
+ cPoint(int a_Value, int a_Probability) :
+ m_Value(a_Value),
+ m_Probability(a_Probability)
+ {
+ }
+ } ;
+
+ typedef std::vector<cPoint> cPoints;
+
+
+ cProbabDistrib(int a_MaxValue);
+
+ /// Sets the distribution curve using an array of [value, probability] points, linearly interpolated. a_Points must not be empty.
+ void SetPoints(const cPoints & a_Points);
+
+ /// Sets the distribution curve using a definition string; returns true on successful parse
+ bool SetDefString(const AString & a_DefString);
+
+ /// Gets a random value from a_Rand, shapes it into the distribution curve and returns the value.
+ int Random(MTRand & a_Rand) const;
+
+ /// Maps value in range [0, m_Sum] into the range [0, m_MaxValue] using the stored probability
+ int MapValue(int a_OrigValue) const;
+
+ int GetSum(void) const { return m_Sum; }
+
+protected:
+
+ int m_MaxValue;
+ cPoints m_Cumulative; ///< Cumulative probability of the values, sorted, for fast bsearch lookup
+ int m_Sum; ///< Sum of all the probabilities across all values in the domain; -1 if not set
+} ;
+
+
+
+
diff --git a/source/Protocol/ChunkDataSerializer.cpp b/source/Protocol/ChunkDataSerializer.cpp
index 7af07f331..2a9230fee 100644
--- a/source/Protocol/ChunkDataSerializer.cpp
+++ b/source/Protocol/ChunkDataSerializer.cpp
@@ -1,176 +1,176 @@
-
-// ChunkDataSerializer.cpp
-
-// Implements the cChunkDataSerializer class representing the object that can:
-// - serialize chunk data to different protocol versions
-// - cache such serialized data for multiple clients
-
-#include "Globals.h"
-#include "ChunkDataSerializer.h"
-#include "zlib.h"
-
-
-
-
-cChunkDataSerializer::cChunkDataSerializer(
- const cChunkDef::BlockTypes & a_BlockTypes,
- const cChunkDef::BlockNibbles & a_BlockMetas,
- const cChunkDef::BlockNibbles & a_BlockLight,
- const cChunkDef::BlockNibbles & a_BlockSkyLight,
- const unsigned char * a_BiomeData
-) :
- m_BlockTypes(a_BlockTypes),
- m_BlockMetas(a_BlockMetas),
- m_BlockLight(a_BlockLight),
- m_BlockSkyLight(a_BlockSkyLight),
- m_BiomeData(a_BiomeData)
-{
-}
-
-
-
-
-const AString & cChunkDataSerializer::Serialize(int a_Version)
-{
- Serializations::const_iterator itr = m_Serializations.find(a_Version);
- if (itr != m_Serializations.end())
- {
- return itr->second;
- }
-
- AString data;
- switch (a_Version)
- {
- case RELEASE_1_2_5: Serialize29(data); break;
- case RELEASE_1_3_2: Serialize39(data); break;
- // TODO: Other protocol versions may serialize the data differently; implement here
-
- default:
- {
- LOGERROR("cChunkDataSerializer::Serialize(): Unknown version: %d", a_Version);
- ASSERT(!"Unknown chunk data serialization version");
- break;
- }
- }
- m_Serializations[a_Version] = data;
- return m_Serializations[a_Version];
-}
-
-
-
-
-
-void cChunkDataSerializer::Serialize29(AString & a_Data)
-{
- // TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib *can* stream)
-
- const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width;
- const int MetadataOffset = sizeof(m_BlockTypes);
- const int BlockLightOffset = MetadataOffset + sizeof(m_BlockMetas);
- const int SkyLightOffset = BlockLightOffset + sizeof(m_BlockLight);
- const int BiomeOffset = SkyLightOffset + sizeof(m_BlockSkyLight);
- const int DataSize = BiomeOffset + BiomeDataSize;
-
- // Temporary buffer for the composed data:
- char AllData [DataSize];
-
- memcpy(AllData, m_BlockTypes, sizeof(m_BlockTypes));
- memcpy(AllData + MetadataOffset, m_BlockMetas, sizeof(m_BlockMetas));
- memcpy(AllData + BlockLightOffset, m_BlockLight, sizeof(m_BlockLight));
- memcpy(AllData + SkyLightOffset, m_BlockSkyLight, sizeof(m_BlockSkyLight));
- memcpy(AllData + BiomeOffset, m_BiomeData, BiomeDataSize);
-
- // Compress the data:
- // In order not to use allocation, use a fixed-size buffer, with the size
- // that uses the same calculation as compressBound():
- const uLongf CompressedMaxSize = DataSize + (DataSize >> 12) + (DataSize >> 14) + (DataSize >> 25) + 16;
- char CompressedBlockData[CompressedMaxSize];
-
- uLongf CompressedSize = compressBound(DataSize);
-
- // Run-time check that our compile-time guess about CompressedMaxSize was enough:
- ASSERT(CompressedSize <= CompressedMaxSize);
-
- compress2((Bytef*)CompressedBlockData, &CompressedSize, (const Bytef*)AllData, sizeof(AllData), Z_DEFAULT_COMPRESSION);
-
- // Now put all those data into a_Data:
-
- // "Ground-up continuous", or rather, "biome data present" flag:
- a_Data.push_back('\x01');
-
- // Two bitmaps; we're aways sending the full chunk with no additional data, so the bitmaps are 0xffff and 0, respectively
- // Also, no endian flipping is needed because of the const values
- unsigned short BitMap1 = 0xffff;
- unsigned short BitMap2 = 0;
- a_Data.append((const char *)&BitMap1, sizeof(short));
- a_Data.append((const char *)&BitMap2, sizeof(short));
-
- Int32 CompressedSizeBE = htonl(CompressedSize);
- a_Data.append((const char *)&CompressedSizeBE, sizeof(CompressedSizeBE));
-
- Int32 UnusedInt32 = 0;
- a_Data.append((const char *)&UnusedInt32, sizeof(UnusedInt32));
-
- a_Data.append(CompressedBlockData, CompressedSize);
-}
-
-
-
-
-
-void cChunkDataSerializer::Serialize39(AString & a_Data)
-{
- // TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib *can* stream)
-
- const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width;
- const int MetadataOffset = sizeof(m_BlockTypes);
- const int BlockLightOffset = MetadataOffset + sizeof(m_BlockMetas);
- const int SkyLightOffset = BlockLightOffset + sizeof(m_BlockLight);
- const int BiomeOffset = SkyLightOffset + sizeof(m_BlockSkyLight);
- const int DataSize = BiomeOffset + BiomeDataSize;
-
- // Temporary buffer for the composed data:
- char AllData [DataSize];
-
- memcpy(AllData, m_BlockTypes, sizeof(m_BlockTypes));
- memcpy(AllData + MetadataOffset, m_BlockMetas, sizeof(m_BlockMetas));
- memcpy(AllData + BlockLightOffset, m_BlockLight, sizeof(m_BlockLight));
- memcpy(AllData + SkyLightOffset, m_BlockSkyLight, sizeof(m_BlockSkyLight));
- memcpy(AllData + BiomeOffset, m_BiomeData, BiomeDataSize);
-
- // Compress the data:
- // In order not to use allocation, use a fixed-size buffer, with the size
- // that uses the same calculation as compressBound():
- const uLongf CompressedMaxSize = DataSize + (DataSize >> 12) + (DataSize >> 14) + (DataSize >> 25) + 16;
- char CompressedBlockData[CompressedMaxSize];
-
- uLongf CompressedSize = compressBound(DataSize);
-
- // Run-time check that our compile-time guess about CompressedMaxSize was enough:
- ASSERT(CompressedSize <= CompressedMaxSize);
-
- compress2((Bytef*)CompressedBlockData, &CompressedSize, (const Bytef*)AllData, sizeof(AllData), Z_DEFAULT_COMPRESSION);
-
- // Now put all those data into a_Data:
-
- // "Ground-up continuous", or rather, "biome data present" flag:
- a_Data.push_back('\x01');
-
- // Two bitmaps; we're aways sending the full chunk with no additional data, so the bitmaps are 0xffff and 0, respectively
- // Also, no endian flipping is needed because of the const values
- unsigned short BitMap1 = 0xffff;
- unsigned short BitMap2 = 0;
- a_Data.append((const char *)&BitMap1, sizeof(short));
- a_Data.append((const char *)&BitMap2, sizeof(short));
-
- Int32 CompressedSizeBE = htonl(CompressedSize);
- a_Data.append((const char *)&CompressedSizeBE, sizeof(CompressedSizeBE));
-
- // Unlike 29, 39 doesn't have the "unused" int
-
- a_Data.append(CompressedBlockData, CompressedSize);
-}
-
-
-
-
+
+// ChunkDataSerializer.cpp
+
+// Implements the cChunkDataSerializer class representing the object that can:
+// - serialize chunk data to different protocol versions
+// - cache such serialized data for multiple clients
+
+#include "Globals.h"
+#include "ChunkDataSerializer.h"
+#include "zlib.h"
+
+
+
+
+cChunkDataSerializer::cChunkDataSerializer(
+ const cChunkDef::BlockTypes & a_BlockTypes,
+ const cChunkDef::BlockNibbles & a_BlockMetas,
+ const cChunkDef::BlockNibbles & a_BlockLight,
+ const cChunkDef::BlockNibbles & a_BlockSkyLight,
+ const unsigned char * a_BiomeData
+) :
+ m_BlockTypes(a_BlockTypes),
+ m_BlockMetas(a_BlockMetas),
+ m_BlockLight(a_BlockLight),
+ m_BlockSkyLight(a_BlockSkyLight),
+ m_BiomeData(a_BiomeData)
+{
+}
+
+
+
+
+const AString & cChunkDataSerializer::Serialize(int a_Version)
+{
+ Serializations::const_iterator itr = m_Serializations.find(a_Version);
+ if (itr != m_Serializations.end())
+ {
+ return itr->second;
+ }
+
+ AString data;
+ switch (a_Version)
+ {
+ case RELEASE_1_2_5: Serialize29(data); break;
+ case RELEASE_1_3_2: Serialize39(data); break;
+ // TODO: Other protocol versions may serialize the data differently; implement here
+
+ default:
+ {
+ LOGERROR("cChunkDataSerializer::Serialize(): Unknown version: %d", a_Version);
+ ASSERT(!"Unknown chunk data serialization version");
+ break;
+ }
+ }
+ m_Serializations[a_Version] = data;
+ return m_Serializations[a_Version];
+}
+
+
+
+
+
+void cChunkDataSerializer::Serialize29(AString & a_Data)
+{
+ // TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib *can* stream)
+
+ const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width;
+ const int MetadataOffset = sizeof(m_BlockTypes);
+ const int BlockLightOffset = MetadataOffset + sizeof(m_BlockMetas);
+ const int SkyLightOffset = BlockLightOffset + sizeof(m_BlockLight);
+ const int BiomeOffset = SkyLightOffset + sizeof(m_BlockSkyLight);
+ const int DataSize = BiomeOffset + BiomeDataSize;
+
+ // Temporary buffer for the composed data:
+ char AllData [DataSize];
+
+ memcpy(AllData, m_BlockTypes, sizeof(m_BlockTypes));
+ memcpy(AllData + MetadataOffset, m_BlockMetas, sizeof(m_BlockMetas));
+ memcpy(AllData + BlockLightOffset, m_BlockLight, sizeof(m_BlockLight));
+ memcpy(AllData + SkyLightOffset, m_BlockSkyLight, sizeof(m_BlockSkyLight));
+ memcpy(AllData + BiomeOffset, m_BiomeData, BiomeDataSize);
+
+ // Compress the data:
+ // In order not to use allocation, use a fixed-size buffer, with the size
+ // that uses the same calculation as compressBound():
+ const uLongf CompressedMaxSize = DataSize + (DataSize >> 12) + (DataSize >> 14) + (DataSize >> 25) + 16;
+ char CompressedBlockData[CompressedMaxSize];
+
+ uLongf CompressedSize = compressBound(DataSize);
+
+ // Run-time check that our compile-time guess about CompressedMaxSize was enough:
+ ASSERT(CompressedSize <= CompressedMaxSize);
+
+ compress2((Bytef*)CompressedBlockData, &CompressedSize, (const Bytef*)AllData, sizeof(AllData), Z_DEFAULT_COMPRESSION);
+
+ // Now put all those data into a_Data:
+
+ // "Ground-up continuous", or rather, "biome data present" flag:
+ a_Data.push_back('\x01');
+
+ // Two bitmaps; we're aways sending the full chunk with no additional data, so the bitmaps are 0xffff and 0, respectively
+ // Also, no endian flipping is needed because of the const values
+ unsigned short BitMap1 = 0xffff;
+ unsigned short BitMap2 = 0;
+ a_Data.append((const char *)&BitMap1, sizeof(short));
+ a_Data.append((const char *)&BitMap2, sizeof(short));
+
+ Int32 CompressedSizeBE = htonl(CompressedSize);
+ a_Data.append((const char *)&CompressedSizeBE, sizeof(CompressedSizeBE));
+
+ Int32 UnusedInt32 = 0;
+ a_Data.append((const char *)&UnusedInt32, sizeof(UnusedInt32));
+
+ a_Data.append(CompressedBlockData, CompressedSize);
+}
+
+
+
+
+
+void cChunkDataSerializer::Serialize39(AString & a_Data)
+{
+ // TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib *can* stream)
+
+ const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width;
+ const int MetadataOffset = sizeof(m_BlockTypes);
+ const int BlockLightOffset = MetadataOffset + sizeof(m_BlockMetas);
+ const int SkyLightOffset = BlockLightOffset + sizeof(m_BlockLight);
+ const int BiomeOffset = SkyLightOffset + sizeof(m_BlockSkyLight);
+ const int DataSize = BiomeOffset + BiomeDataSize;
+
+ // Temporary buffer for the composed data:
+ char AllData [DataSize];
+
+ memcpy(AllData, m_BlockTypes, sizeof(m_BlockTypes));
+ memcpy(AllData + MetadataOffset, m_BlockMetas, sizeof(m_BlockMetas));
+ memcpy(AllData + BlockLightOffset, m_BlockLight, sizeof(m_BlockLight));
+ memcpy(AllData + SkyLightOffset, m_BlockSkyLight, sizeof(m_BlockSkyLight));
+ memcpy(AllData + BiomeOffset, m_BiomeData, BiomeDataSize);
+
+ // Compress the data:
+ // In order not to use allocation, use a fixed-size buffer, with the size
+ // that uses the same calculation as compressBound():
+ const uLongf CompressedMaxSize = DataSize + (DataSize >> 12) + (DataSize >> 14) + (DataSize >> 25) + 16;
+ char CompressedBlockData[CompressedMaxSize];
+
+ uLongf CompressedSize = compressBound(DataSize);
+
+ // Run-time check that our compile-time guess about CompressedMaxSize was enough:
+ ASSERT(CompressedSize <= CompressedMaxSize);
+
+ compress2((Bytef*)CompressedBlockData, &CompressedSize, (const Bytef*)AllData, sizeof(AllData), Z_DEFAULT_COMPRESSION);
+
+ // Now put all those data into a_Data:
+
+ // "Ground-up continuous", or rather, "biome data present" flag:
+ a_Data.push_back('\x01');
+
+ // Two bitmaps; we're aways sending the full chunk with no additional data, so the bitmaps are 0xffff and 0, respectively
+ // Also, no endian flipping is needed because of the const values
+ unsigned short BitMap1 = 0xffff;
+ unsigned short BitMap2 = 0;
+ a_Data.append((const char *)&BitMap1, sizeof(short));
+ a_Data.append((const char *)&BitMap2, sizeof(short));
+
+ Int32 CompressedSizeBE = htonl(CompressedSize);
+ a_Data.append((const char *)&CompressedSizeBE, sizeof(CompressedSizeBE));
+
+ // Unlike 29, 39 doesn't have the "unused" int
+
+ a_Data.append(CompressedBlockData, CompressedSize);
+}
+
+
+
+
diff --git a/source/Protocol/ChunkDataSerializer.h b/source/Protocol/ChunkDataSerializer.h
index 513a232b9..a42856356 100644
--- a/source/Protocol/ChunkDataSerializer.h
+++ b/source/Protocol/ChunkDataSerializer.h
@@ -1,48 +1,48 @@
-
-// ChunkDataSerializer.h
-
-// Interfaces to the cChunkDataSerializer class representing the object that can:
-// - serialize chunk data to different protocol versions
-// - cache such serialized data for multiple clients
-
-
-
-
-
-class cChunkDataSerializer
-{
-protected:
- const cChunkDef::BlockTypes & m_BlockTypes;
- const cChunkDef::BlockNibbles & m_BlockMetas;
- const cChunkDef::BlockNibbles & m_BlockLight;
- const cChunkDef::BlockNibbles & m_BlockSkyLight;
- const unsigned char * m_BiomeData;
-
- typedef std::map<int, AString> Serializations;
-
- Serializations m_Serializations;
-
- void Serialize29(AString & a_Data); // Release 1.2.4 and 1.2.5
- void Serialize39(AString & a_Data); // Release 1.3.1 and 1.3.2
-
-public:
- enum
- {
- RELEASE_1_2_5 = 29,
- RELEASE_1_3_2 = 39,
- } ;
-
- cChunkDataSerializer(
- const cChunkDef::BlockTypes & a_BlockTypes,
- const cChunkDef::BlockNibbles & a_BlockMetas,
- const cChunkDef::BlockNibbles & a_BlockLight,
- const cChunkDef::BlockNibbles & a_BlockSkyLight,
- const unsigned char * a_BiomeData
- );
-
- const AString & Serialize(int a_Version); // Returns one of the internal m_Serializations[]
-} ;
-
-
-
-
+
+// ChunkDataSerializer.h
+
+// Interfaces to the cChunkDataSerializer class representing the object that can:
+// - serialize chunk data to different protocol versions
+// - cache such serialized data for multiple clients
+
+
+
+
+
+class cChunkDataSerializer
+{
+protected:
+ const cChunkDef::BlockTypes & m_BlockTypes;
+ const cChunkDef::BlockNibbles & m_BlockMetas;
+ const cChunkDef::BlockNibbles & m_BlockLight;
+ const cChunkDef::BlockNibbles & m_BlockSkyLight;
+ const unsigned char * m_BiomeData;
+
+ typedef std::map<int, AString> Serializations;
+
+ Serializations m_Serializations;
+
+ void Serialize29(AString & a_Data); // Release 1.2.4 and 1.2.5
+ void Serialize39(AString & a_Data); // Release 1.3.1 and 1.3.2
+
+public:
+ enum
+ {
+ RELEASE_1_2_5 = 29,
+ RELEASE_1_3_2 = 39,
+ } ;
+
+ cChunkDataSerializer(
+ const cChunkDef::BlockTypes & a_BlockTypes,
+ const cChunkDef::BlockNibbles & a_BlockMetas,
+ const cChunkDef::BlockNibbles & a_BlockLight,
+ const cChunkDef::BlockNibbles & a_BlockSkyLight,
+ const unsigned char * a_BiomeData
+ );
+
+ const AString & Serialize(int a_Version); // Returns one of the internal m_Serializations[]
+} ;
+
+
+
+
diff --git a/source/Protocol/Protocol.h b/source/Protocol/Protocol.h
index fe9d4d10e..1a154ea95 100644
--- a/source/Protocol/Protocol.h
+++ b/source/Protocol/Protocol.h
@@ -1,192 +1,193 @@
-
-// Protocol.h
-
-// Interfaces to the cProtocol class representing the generic interface that a protocol
-// parser and serializer must implement
-
-
-
-
-
-#pragma once
-
-#include "../Defines.h"
-#include "../Endianness.h"
-
-
-
-
-class cPlayer;
-class cEntity;
-class cWindow;
-class cInventory;
-class cPawn;
-class cPickup;
-class cMonster;
-class cChunkDataSerializer;
-class cWorld;
-class cFallingBlock;
-
-
-
-
-
-typedef unsigned char Byte;
-
-
-
-
-
-class cProtocol
-{
-public:
- cProtocol(cClientHandle * a_Client) :
- m_Client(a_Client)
- {
- }
- virtual ~cProtocol() {}
-
- /// Called when client sends some data
- virtual void DataReceived(const char * a_Data, int a_Size) = 0;
-
- // Sending stuff to clients (alphabetically sorted):
- virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle) = 0;
- virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) = 0;
- virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) = 0;
- virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
- virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) = 0;
- virtual void SendChat (const AString & 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 SendDestroyEntity (const cEntity & a_Entity) = 0;
- virtual void SendDisconnect (const AString & a_Reason) = 0;
- virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0;
- virtual void SendEntityHeadLook (const cEntity & a_Entity) = 0;
- virtual void SendEntityLook (const cEntity & a_Entity) = 0;
- virtual void SendEntityMetadata (const cEntity & a_Entity) = 0;
- virtual void SendEntityProperties (const cEntity & a_Entity) = 0;
- virtual void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
- virtual void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
- virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) = 0;
- virtual void SendEntityVelocity (const cEntity & a_Entity) = 0;
- virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) = 0;
- virtual void SendGameMode (eGameMode a_GameMode) = 0;
- virtual void SendHealth (void) = 0;
- virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) = 0;
- virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) = 0;
- virtual void SendKeepAlive (int a_PingID) = 0;
- virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) = 0;
- virtual void SendPickupSpawn (const cPickup & a_Pickup) = 0;
- virtual void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation) = 0;
- virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) = 0;
- virtual void SendPlayerMaxSpeed (void) = 0; ///< Informs the client of the maximum player speed (1.6.1+)
- virtual void SendPlayerMoveLook (void) = 0;
- virtual void SendPlayerPosition (void) = 0;
- virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
- virtual void SendRespawn (void) = 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 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) = 0;
- virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
- virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
- virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay) = 0;
- virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) = 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 SendWeather (eWeather a_Weather) = 0;
- virtual void SendWholeInventory (const cInventory & a_Inventory) = 0;
- virtual void SendWholeInventory (const cWindow & a_Window) = 0;
- virtual void SendWindowClose (const cWindow & a_Window) = 0;
- virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) = 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
-
- /// 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, int a_Size) = 0;
-
- /// Called after writing each packet, enables descendants to flush their buffers
- virtual void Flush(void) {};
-
- // Helpers for writing partial packet data, write using SendData()
- void WriteByte(Byte a_Value)
- {
- SendData((const char *)&a_Value, 1);
- }
-
- void WriteShort(short a_Value)
- {
- a_Value = htons(a_Value);
- SendData((const char *)&a_Value, 2);
- }
-
- /*
- void WriteShort(unsigned short a_Value)
- {
- a_Value = htons(a_Value);
- SendData((const char *)&a_Value, 2);
- }
- */
-
- void WriteInt(int a_Value)
- {
- a_Value = htonl(a_Value);
- SendData((const char *)&a_Value, 4);
- }
-
- void WriteUInt(unsigned int a_Value)
- {
- a_Value = htonl(a_Value);
- SendData((const char *)&a_Value, 4);
- }
-
- void WriteInt64 (Int64 a_Value)
- {
- a_Value = HostToNetwork8(&a_Value);
- SendData((const char *)&a_Value, 8);
- }
-
- void WriteFloat (float a_Value)
- {
- unsigned int val = HostToNetwork4(&a_Value);
- SendData((const char *)&val, 4);
- }
-
- void WriteDouble(double a_Value)
- {
- unsigned long long val = HostToNetwork8(&a_Value);
- SendData((const char *)&val, 8);
- }
-
- void WriteString(const AString & a_Value)
- {
- AString UTF16;
- UTF8ToRawBEUTF16(a_Value.c_str(), a_Value.length(), UTF16);
- WriteShort((unsigned short)(UTF16.size() / 2));
- SendData(UTF16.data(), UTF16.size());
- }
-
- void WriteBool(bool a_Value)
- {
- WriteByte(a_Value ? 1 : 0);
- }
-
- void WriteVectorI(const Vector3i & a_Vector)
- {
- WriteInt(a_Vector.x);
- WriteInt(a_Vector.y);
- WriteInt(a_Vector.z);
- }
-} ;
-
-
-
-
-
+
+// Protocol.h
+
+// Interfaces to the cProtocol class representing the generic interface that a protocol
+// parser and serializer must implement
+
+
+
+
+
+#pragma once
+
+#include "../Defines.h"
+#include "../Endianness.h"
+
+
+
+
+class cPlayer;
+class cEntity;
+class cWindow;
+class cInventory;
+class cPawn;
+class cPickup;
+class cMonster;
+class cChunkDataSerializer;
+class cWorld;
+class cFallingBlock;
+
+
+
+
+
+typedef unsigned char Byte;
+
+
+
+
+
+class cProtocol
+{
+public:
+ cProtocol(cClientHandle * a_Client) :
+ m_Client(a_Client)
+ {
+ }
+ virtual ~cProtocol() {}
+
+ /// Called when client sends some data
+ virtual void DataReceived(const char * a_Data, int a_Size) = 0;
+
+ // Sending stuff to clients (alphabetically sorted):
+ virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle) = 0;
+ virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) = 0;
+ virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) = 0;
+ virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
+ virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) = 0;
+ virtual void SendChat (const AString & 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 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+)
+ virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0;
+ virtual void SendEntityHeadLook (const cEntity & a_Entity) = 0;
+ virtual void SendEntityLook (const cEntity & a_Entity) = 0;
+ virtual void SendEntityMetadata (const cEntity & a_Entity) = 0;
+ virtual void SendEntityProperties (const cEntity & a_Entity) = 0;
+ virtual void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
+ virtual void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
+ virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) = 0;
+ virtual void SendEntityVelocity (const cEntity & a_Entity) = 0;
+ virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) = 0;
+ virtual void SendGameMode (eGameMode a_GameMode) = 0;
+ virtual void SendHealth (void) = 0;
+ virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) = 0;
+ virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) = 0;
+ virtual void SendKeepAlive (int a_PingID) = 0;
+ virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) = 0;
+ virtual void SendPickupSpawn (const cPickup & a_Pickup) = 0;
+ virtual void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation) = 0;
+ virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) = 0;
+ virtual void SendPlayerMaxSpeed (void) = 0; ///< Informs the client of the maximum player speed (1.6.1+)
+ virtual void SendPlayerMoveLook (void) = 0;
+ virtual void SendPlayerPosition (void) = 0;
+ virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
+ virtual void SendRespawn (void) = 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 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) = 0;
+ virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
+ virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
+ virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay) = 0;
+ virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) = 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 SendWeather (eWeather a_Weather) = 0;
+ virtual void SendWholeInventory (const cInventory & a_Inventory) = 0;
+ virtual void SendWholeInventory (const cWindow & a_Window) = 0;
+ virtual void SendWindowClose (const cWindow & a_Window) = 0;
+ virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) = 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
+
+ /// 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, int a_Size) = 0;
+
+ /// Called after writing each packet, enables descendants to flush their buffers
+ virtual void Flush(void) {};
+
+ // Helpers for writing partial packet data, write using SendData()
+ void WriteByte(Byte a_Value)
+ {
+ SendData((const char *)&a_Value, 1);
+ }
+
+ void WriteShort(short a_Value)
+ {
+ a_Value = htons(a_Value);
+ SendData((const char *)&a_Value, 2);
+ }
+
+ /*
+ void WriteShort(unsigned short a_Value)
+ {
+ a_Value = htons(a_Value);
+ SendData((const char *)&a_Value, 2);
+ }
+ */
+
+ void WriteInt(int a_Value)
+ {
+ a_Value = htonl(a_Value);
+ SendData((const char *)&a_Value, 4);
+ }
+
+ void WriteUInt(unsigned int a_Value)
+ {
+ a_Value = htonl(a_Value);
+ SendData((const char *)&a_Value, 4);
+ }
+
+ void WriteInt64 (Int64 a_Value)
+ {
+ a_Value = HostToNetwork8(&a_Value);
+ SendData((const char *)&a_Value, 8);
+ }
+
+ void WriteFloat (float a_Value)
+ {
+ unsigned int val = HostToNetwork4(&a_Value);
+ SendData((const char *)&val, 4);
+ }
+
+ void WriteDouble(double a_Value)
+ {
+ unsigned long long val = HostToNetwork8(&a_Value);
+ SendData((const char *)&val, 8);
+ }
+
+ void WriteString(const AString & a_Value)
+ {
+ AString UTF16;
+ UTF8ToRawBEUTF16(a_Value.c_str(), a_Value.length(), UTF16);
+ WriteShort((unsigned short)(UTF16.size() / 2));
+ SendData(UTF16.data(), UTF16.size());
+ }
+
+ void WriteBool(bool a_Value)
+ {
+ WriteByte(a_Value ? 1 : 0);
+ }
+
+ void WriteVectorI(const Vector3i & a_Vector)
+ {
+ WriteInt(a_Vector.x);
+ WriteInt(a_Vector.y);
+ WriteInt(a_Vector.z);
+ }
+} ;
+
+
+
+
+
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index fddf7d324..1f6dcdec9 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -1,1636 +1,1649 @@
-
-// Protocol125.cpp
-
-// Implements the cProtocol125 class representing the release 1.2.5 protocol (#29)
-/*
-Documentation:
- - protocol: http://wiki.vg/wiki/index.php?title=Protocol&oldid=2513
- - session handling: http://wiki.vg/wiki/index.php?title=Session&oldid=2262
- - slot format: http://wiki.vg/wiki/index.php?title=Slot_Data&oldid=2152
-*/
-
-#include "Globals.h"
-
-#include "Protocol125.h"
-
-#include "../ClientHandle.h"
-#include "ChunkDataSerializer.h"
-#include "../Entity.h"
-#include "../Mobs/Monster.h"
-#include "../Pickup.h"
-#include "../Player.h"
-#include "../ChatColor.h"
-#include "../UI/Window.h"
-#include "../Root.h"
-#include "../Server.h"
-#include "../FallingBlock.h"
-
-
-
-
-
-enum
-{
- PACKET_KEEP_ALIVE = 0x00,
- PACKET_LOGIN = 0x01,
- PACKET_HANDSHAKE = 0x02,
- PACKET_CHAT = 0x03,
- PACKET_UPDATE_TIME = 0x04,
- PACKET_ENTITY_EQUIPMENT = 0x05,
- PACKET_USE_ENTITY = 0x07,
- PACKET_UPDATE_HEALTH = 0x08,
- PACKET_RESPAWN = 0x09,
- PACKET_PLAYER_ON_GROUND = 0x0a,
- PACKET_PLAYER_POS = 0x0b,
- PACKET_PLAYER_LOOK = 0x0c,
- PACKET_PLAYER_MOVE_LOOK = 0x0d,
- PACKET_BLOCK_DIG = 0x0e,
- PACKET_BLOCK_PLACE = 0x0f,
- PACKET_SLOT_SELECTED = 0x10,
- PACKET_USE_BED = 0x11,
- PACKET_ANIMATION = 0x12,
- PACKET_PACKET_ENTITY_ACTION = 0x13,
- PACKET_PLAYER_SPAWN = 0x14,
- PACKET_PICKUP_SPAWN = 0x15,
- PACKET_COLLECT_PICKUP = 0x16,
- PACKET_SPAWN_OBJECT = 0x17,
- PACKET_SPAWN_MOB = 0x18,
- PACKET_ENTITY_VELOCITY = 0x1c,
- PACKET_DESTROY_ENTITY = 0x1d,
- PACKET_ENTITY = 0x1e,
- PACKET_ENT_REL_MOVE = 0x1f,
- PACKET_ENT_LOOK = 0x20,
- PACKET_ENT_REL_MOVE_LOOK = 0x21,
- PACKET_ENT_TELEPORT = 0x22,
- PACKET_ENT_HEAD_LOOK = 0x23,
- PACKET_ENT_STATUS = 0x26,
- PACKET_ATTACH_ENTITY = 0x27,
- PACKET_METADATA = 0x28,
- PACKET_PRE_CHUNK = 0x32,
- PACKET_MAP_CHUNK = 0x33,
- PACKET_MULTI_BLOCK = 0x34,
- PACKET_BLOCK_CHANGE = 0x35,
- PACKET_BLOCK_ACTION = 0x36,
- PACKET_EXPLOSION = 0x3C,
- PACKET_SOUND_EFFECT = 0x3e,
- PACKET_SOUND_PARTICLE_EFFECT = 0x3d,
- PACKET_CHANGE_GAME_STATE = 0x46,
- PACKET_THUNDERBOLT = 0x47,
- PACKET_WINDOW_OPEN = 0x64,
- PACKET_WINDOW_CLOSE = 0x65,
- PACKET_WINDOW_CLICK = 0x66,
- PACKET_INVENTORY_SLOT = 0x67,
- PACKET_INVENTORY_WHOLE = 0x68,
- PACKET_INVENTORY_PROGRESS = 0x69,
- PACKET_CREATIVE_INVENTORY_ACTION = 0x6B,
- PACKET_UPDATE_SIGN = 0x82,
- PACKET_PLAYER_LIST_ITEM = 0xC9,
- PACKET_PLAYER_ABILITIES = 0xca,
- PACKET_PLUGIN_MESSAGE = 0xfa,
- PACKET_PING = 0xfe,
- PACKET_DISCONNECT = 0xff
-} ;
-
-
-
-
-
-#define HANDLE_PACKET_READ(Proc, Type, Var) \
- Type Var; \
- { \
- if (!m_ReceivedData.Proc(Var)) \
- { \
- m_ReceivedData.CheckValid(); \
- return PARSE_INCOMPLETE; \
- } \
- m_ReceivedData.CheckValid(); \
- }
-
-
-
-
-typedef unsigned char Byte;
-
-
-
-
-
-cProtocol125::cProtocol125(cClientHandle * a_Client) :
- super(a_Client),
- m_ReceivedData(32 KiB)
-{
-}
-
-
-
-
-
-void cProtocol125::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ATTACH_ENTITY);
- WriteInt(a_Entity.GetUniqueID());
- WriteInt((a_Vehicle == NULL) ? -1 : a_Vehicle->GetUniqueID());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
-{
- UNUSED(a_BlockType);
-
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_BLOCK_ACTION);
- WriteInt (a_BlockX);
- WriteShort((short)a_BlockY);
- WriteInt (a_BlockZ);
- WriteByte (a_Byte1);
- WriteByte (a_Byte2);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
-{
- // Not supported in this protocol version
-}
-
-
-
-
-
-void cProtocol125::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_BLOCK_CHANGE);
- WriteInt (a_BlockX);
- WriteByte((unsigned char)a_BlockY);
- WriteInt (a_BlockZ);
- WriteByte(a_BlockType);
- WriteByte(a_BlockMeta);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes)
-{
- cCSLock Lock(m_CSPacket);
- if (a_Changes.size() == 1)
- {
- // Special packet for single-block changes
- const sSetBlock & blk = a_Changes.front();
- SendBlockChange(a_ChunkX * cChunkDef::Width + blk.x, blk.y, a_ChunkZ * cChunkDef::Width + blk.z, blk.BlockType, blk.BlockMeta);
- return;
- }
-
- WriteByte (PACKET_MULTI_BLOCK);
- WriteInt (a_ChunkX);
- WriteInt (a_ChunkZ);
- WriteShort((unsigned short)a_Changes.size());
- WriteUInt (sizeof(int) * a_Changes.size());
- 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);
- unsigned int Blocks = itr->BlockMeta | (itr->BlockType << 4);
- WriteUInt(Coords << 16 | Blocks);
- }
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendChat(const AString & a_Message)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_CHAT);
- WriteString(a_Message);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
-{
- cCSLock Lock(m_CSPacket);
-
- // Send the pre-chunk:
- SendPreChunk(a_ChunkX, a_ChunkZ, true);
-
- // Send the chunk data:
- AString Serialized = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_2_5);
- WriteByte(PACKET_MAP_CHUNK);
- WriteInt (a_ChunkX);
- WriteInt (a_ChunkZ);
- SendData(Serialized.data(), Serialized.size());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_COLLECT_PICKUP);
- WriteInt (a_Pickup.GetUniqueID());
- WriteInt (a_Player.GetUniqueID());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendDestroyEntity(const cEntity & a_Entity)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_DESTROY_ENTITY);
- WriteInt (a_Entity.GetUniqueID());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendDisconnect(const AString & a_Reason)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte ((unsigned char)PACKET_DISCONNECT);
- WriteString(a_Reason);
- Flush();
-}
-
-
-
-
-void cProtocol125::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_ENTITY_EQUIPMENT);
- WriteInt (a_Entity.GetUniqueID());
- WriteShort(a_SlotNum);
- WriteShort(a_Item.m_ItemType);
- WriteShort(a_Item.m_ItemDamage);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendEntityHeadLook(const cEntity & a_Entity)
-{
- ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
-
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENT_HEAD_LOOK);
- WriteInt (a_Entity.GetUniqueID());
- WriteByte((char)((a_Entity.GetHeadYaw() / 360.f) * 256));
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendEntityLook(const cEntity & a_Entity)
-{
- ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
-
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENT_LOOK);
- WriteInt (a_Entity.GetUniqueID());
- WriteByte((char)((a_Entity.GetRotation() / 360.f) * 256));
- WriteByte((char)((a_Entity.GetPitch() / 360.f) * 256));
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendEntityMetadata(const cEntity & a_Entity)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_METADATA);
- WriteInt (a_Entity.GetUniqueID());
- AString MetaData = GetEntityMetaData(a_Entity);
- SendData(MetaData.data(), MetaData.size());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendEntityProperties(const cEntity & a_Entity)
-{
- // Not supported in this protocol version
-}
-
-
-
-
-
-void cProtocol125::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
-{
- ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
-
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENT_REL_MOVE);
- WriteInt (a_Entity.GetUniqueID());
- WriteByte(a_RelX);
- WriteByte(a_RelY);
- WriteByte(a_RelZ);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
-{
- ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
-
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENT_REL_MOVE_LOOK);
- WriteInt (a_Entity.GetUniqueID());
- WriteByte(a_RelX);
- WriteByte(a_RelY);
- WriteByte(a_RelZ);
- WriteByte((char)((a_Entity.GetRotation() / 360.f) * 256));
- WriteByte((char)((a_Entity.GetPitch() / 360.f) * 256));
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendEntityStatus(const cEntity & a_Entity, char a_Status)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENT_STATUS);
- WriteInt (a_Entity.GetUniqueID());
- WriteByte(a_Status);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendEntityVelocity(const cEntity & a_Entity)
-{
- ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
-
- 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.GetSpeedY() * 400));
- WriteShort((short) (a_Entity.GetSpeedZ() * 400));
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_EXPLOSION);
- WriteDouble (a_BlockX);
- WriteDouble (a_BlockY);
- WriteDouble (a_BlockZ);
- WriteFloat (a_Radius);
- WriteInt (a_BlocksAffected.size());
- for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
- {
- WriteByte ((Byte)(itr->x - a_BlockX));
- WriteByte ((Byte)(itr->y - a_BlockY));
- WriteByte ((Byte)(itr->z - a_BlockZ));
- }
- WriteFloat ((float)a_PlayerMotion.x);
- WriteFloat ((float)a_PlayerMotion.y);
- WriteFloat ((float)a_PlayerMotion.z);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendGameMode(eGameMode a_GameMode)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_CHANGE_GAME_STATE);
- WriteByte(3);
- WriteByte((char)a_GameMode);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendHandshake(const AString & a_ConnectionHash)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_HANDSHAKE);
- WriteString(a_ConnectionHash);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendHealth(void)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_UPDATE_HEALTH);
- WriteShort((short)m_Client->GetPlayer()->GetHealth());
- WriteShort(m_Client->GetPlayer()->GetFoodLevel());
- WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendInventoryProgress(char a_WindowID, short a_ProgressBar, short a_Value)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_INVENTORY_PROGRESS);
- WriteByte (a_WindowID);
- WriteShort(a_ProgressBar);
- WriteShort(a_Value);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_INVENTORY_SLOT);
- WriteByte (a_WindowID);
- WriteShort(a_SlotNum);
- WriteItem (a_Item);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendKeepAlive(int a_PingID)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_KEEP_ALIVE);
- WriteInt (a_PingID);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
-{
- UNUSED(a_World);
- cCSLock Lock(m_CSPacket);
-
- WriteByte (PACKET_LOGIN);
- WriteInt (a_Player.GetUniqueID()); // EntityID of the player
- WriteString(""); // Username, not used
- WriteString("default"); // Level type
- WriteInt ((int)a_Player.GetGameMode());
- WriteInt ((int)(a_World.GetDimension()));
- WriteByte (2); // TODO: Difficulty
- WriteByte (0); // Unused
- WriteByte (60); // Client list width or something
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendPickupSpawn(const cPickup & a_Pickup)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_PICKUP_SPAWN);
- WriteInt (a_Pickup.GetUniqueID());
- WriteShort (a_Pickup.GetItem().m_ItemType);
- WriteByte (a_Pickup.GetItem().m_ItemCount);
- WriteShort (a_Pickup.GetItem().m_ItemDamage);
- WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
- WriteByte ((char)(a_Pickup.GetSpeed().x * 8));
- WriteByte ((char)(a_Pickup.GetSpeed().y * 8));
- WriteByte ((char)(a_Pickup.GetSpeed().z * 8));
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ANIMATION);
- WriteInt (a_Player.GetUniqueID());
- WriteByte(a_Animation);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
-{
- cCSLock Lock(m_CSPacket);
- AString PlayerName(a_Player.GetColor());
- PlayerName.append(a_Player.GetName());
- if (PlayerName.length() > 14)
- {
- PlayerName.erase(14);
- }
- PlayerName += cChatColor::White;
-
- WriteByte ((unsigned char)PACKET_PLAYER_LIST_ITEM);
- WriteString(PlayerName);
- WriteBool (a_IsOnline);
- WriteShort (a_Player.GetClientHandle()->GetPing());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendPlayerMaxSpeed(void)
-{
- // Not supported by this protocol version
-}
-
-
-
-
-
-void cProtocol125::SendPlayerMoveLook(void)
-{
- cCSLock Lock(m_CSPacket);
-
- /*
- LOGD("Sending PlayerMoveLook: {%0.2f, %0.2f, %0.2f}, stance %0.2f, OnGround: %d",
- m_Player->GetPosX(), m_Player->GetPosY(), m_Player->GetPosZ(), m_Player->GetStance(), m_Player->IsOnGround() ? 1 : 0
- );
- */
-
- 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
- WriteDouble(Player->GetPosY() + 0.03); // Add a small amount so that the player doesn't start inside a block
- WriteDouble(Player->GetPosZ());
- WriteFloat ((float)(Player->GetRotation()));
- WriteFloat ((float)(Player->GetPitch()));
- WriteBool (Player->IsOnGround());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendPlayerPosition(void)
-{
- cCSLock Lock(m_CSPacket);
- LOGD("Ignore send PlayerPos"); // PlayerPos is a C->S packet only now
-}
-
-
-
-
-
-void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player)
-{
- const cItem & HeldItem = a_Player.GetEquippedItem();
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_PLAYER_SPAWN);
- WriteInt (a_Player.GetUniqueID());
- WriteString(a_Player.GetName());
- WriteInt ((int)(a_Player.GetPosX() * 32));
- WriteInt ((int)(a_Player.GetPosY() * 32));
- WriteInt ((int)(a_Player.GetPosZ() * 32));
- WriteByte ((char)((a_Player.GetRot().x / 360.f) * 256));
- WriteByte ((char)((a_Player.GetRot().y / 360.f) * 256));
- WriteShort (HeldItem.IsEmpty() ? 0 : HeldItem.m_ItemType);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendRespawn(void)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_RESPAWN);
- WriteInt ((int)(m_Client->GetPlayer()->GetWorld()->GetDimension()));
- WriteByte (2); // TODO: Difficulty; 2 = Normal
- WriteByte ((char)m_Client->GetPlayer()->GetGameMode());
- WriteShort (256); // Current world height
- WriteString("default");
-}
-
-
-
-
-
-void cProtocol125::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
-{
- // Not needed in this protocol version
-}
-
-
-
-
-
-void cProtocol125::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
-{
- // Not implemented in this protocol version
-}
-
-
-
-
-
-void cProtocol125::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
-{
- // This protocol version implements falling blocks using the spawn object / vehicle packet:
- SendSpawnObject(a_FallingBlock, 70, a_FallingBlock.GetBlockType(), 0, 0);
-}
-
-
-
-
-
-void cProtocol125::SendSpawnMob(const cMonster & a_Mob)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_SPAWN_MOB);
- WriteInt (a_Mob.GetUniqueID());
- WriteByte (a_Mob.GetMobType());
- WriteVectorI((Vector3i)(a_Mob.GetPosition() * 32));
- WriteByte (0);
- WriteByte (0);
- WriteByte (0);
- AString MetaData = GetEntityMetaData(a_Mob);
- SendData (MetaData.data(), MetaData.size());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
-{
- UNUSED(a_Yaw);
- UNUSED(a_Pitch);
-
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_SPAWN_OBJECT);
- WriteInt (a_Entity.GetUniqueID());
- WriteByte(a_ObjectType);
- WriteInt ((int)(a_Entity.GetPosX() * 32));
- WriteInt ((int)(a_Entity.GetPosY() * 32));
- WriteInt ((int)(a_Entity.GetPosZ() * 32));
- WriteByte(a_Pitch);
- WriteByte(a_Yaw);
- WriteInt (a_ObjectData);
- if (a_ObjectData != 0)
- {
- WriteShort((short)(a_Entity.GetSpeedX() * 400));
- WriteShort((short)(a_Entity.GetSpeedY() * 400));
- WriteShort((short)(a_Entity.GetSpeedZ() * 400));
- }
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_SPAWN_OBJECT);
- WriteInt (a_Vehicle.GetUniqueID());
- WriteByte (a_VehicleType);
- WriteInt ((int)(a_Vehicle.GetPosX() * 32));
- WriteInt ((int)(a_Vehicle.GetPosY() * 32));
- WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
- WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256));
- WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256));
- WriteInt (1);
- WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
- WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
- WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendTeleportEntity(const cEntity & a_Entity)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_ENT_TELEPORT);
- WriteInt (a_Entity.GetUniqueID());
- WriteInt ((int)(floor(a_Entity.GetPosX() * 32)));
- WriteInt ((int)(floor(a_Entity.GetPosY() * 32)));
- WriteInt ((int)(floor(a_Entity.GetPosZ() * 32)));
- WriteByte ((char)((a_Entity.GetRotation() / 360.f) * 256));
- WriteByte ((char)((a_Entity.GetPitch() / 360.f) * 256));
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_THUNDERBOLT);
- WriteInt (0x7fffffff); // Entity ID of the thunderbolt; we use a constant one
- WriteBool(true); // Unknown bool
- WriteInt (a_BlockX * 32);
- WriteInt (a_BlockY * 32);
- WriteInt (a_BlockZ * 32);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_UPDATE_TIME);
- // Use a_WorldAge for daycount, and a_TimeOfDay for the proper time of day:
- WriteInt64((24000 * (a_WorldAge / 24000)) + (a_TimeOfDay % 24000));
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
-{
- cCSLock Lock(m_CSPacket);
- SendPreChunk(a_ChunkX, a_ChunkZ, false);
-}
-
-
-
-
-
-void cProtocol125::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
-)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte ((unsigned char)PACKET_UPDATE_SIGN);
- WriteInt (a_BlockX);
- WriteShort ((short)a_BlockY);
- WriteInt (a_BlockZ);
- WriteString(a_Line1);
- WriteString(a_Line2);
- WriteString(a_Line3);
- WriteString(a_Line4);
- Flush();
-}
-
-
-
-
-
-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
- WriteInt (a_BlockX);
- WriteByte(a_BlockY);
- WriteInt (a_BlockZ);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendWeather(eWeather a_Weather)
-{
- cCSLock Lock(m_CSPacket);
- switch( a_Weather )
- {
- case eWeather_Sunny:
- {
- WriteByte(PACKET_CHANGE_GAME_STATE);
- WriteByte(2); // Stop rain
- WriteByte(0); // Unused
- Flush();
- break;
- }
-
- case eWeather_Rain:
- case eWeather_ThunderStorm:
- {
- WriteByte(PACKET_CHANGE_GAME_STATE);
- WriteByte(1); // Begin rain
- WriteByte(0); // Unused
- Flush();
- break;
- }
- }
-}
-
-
-
-
-
-void cProtocol125::SendWholeInventory(const cInventory & a_Inventory)
-{
- SendWholeInventory(*(a_Inventory.GetOwner().GetWindow()));
-}
-
-
-
-
-
-void cProtocol125::SendWholeInventory(const cWindow & a_Window)
-{
- cCSLock Lock(m_CSPacket);
- cItems Slots;
- a_Window.GetSlots(*(m_Client->GetPlayer()), Slots);
- SendWindowSlots(a_Window.GetWindowID(), Slots.size(), &(Slots[0]));
-}
-
-
-
-
-
-void cProtocol125::SendWindowClose(const cWindow & a_Window)
-{
- if (a_Window.GetWindowType() == cWindow::Inventory)
- {
- // Do not send inventory-window-close
- return;
- }
-
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_WINDOW_CLOSE);
- WriteByte(a_Window.GetWindowID());
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
-{
- if (a_WindowType < 0)
- {
- // Do not send for inventory windows
- return;
- }
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_WINDOW_OPEN);
- WriteByte (a_WindowID);
- WriteByte (a_WindowType);
- WriteString(a_WindowTitle);
- WriteByte (a_NumSlots);
- Flush();
-}
-
-
-
-
-
-AString cProtocol125::GetAuthServerID(void)
-{
- // http://wiki.vg/wiki/index.php?title=Session&oldid=2262
- // The server generates a random hash and that is used for all clients, unmodified
- return cRoot::Get()->GetServer()->GetServerID();
-}
-
-
-
-
-
-void cProtocol125::SendData(const char * a_Data, int a_Size)
-{
- m_Client->SendData(a_Data, a_Size);
-}
-
-
-
-
-
-void cProtocol125::DataReceived(const char * a_Data, int a_Size)
-{
- if (!m_ReceivedData.Write(a_Data, a_Size))
- {
- // Too much data in the incoming queue, report to caller:
- m_Client->PacketBufferFull();
- return;
- }
-
- // Parse and handle all complete packets in m_ReceivedData:
- while (m_ReceivedData.CanReadBytes(1))
- {
- unsigned char PacketType;
- m_ReceivedData.ReadByte(PacketType);
- switch (ParsePacket(PacketType))
- {
- case PARSE_UNKNOWN:
- {
- // An unknown packet has been received, notify the client and abort:
- m_Client->PacketUnknown(PacketType);
- return;
- }
- case PARSE_ERROR:
- {
- // An error occurred while parsing a known packet, notify the client and abort:
- m_Client->PacketError(PacketType);
- return;
- }
- case PARSE_INCOMPLETE:
- {
- // Incomplete packet, bail out and process with the next batch of data
- m_ReceivedData.ResetRead();
- return;
- }
- default:
- {
- // Packet successfully parsed, commit the read data and try again one more packet
- m_ReceivedData.CommitRead();
- break;
- }
- }
- }
-}
-
-
-
-
-
-int cProtocol125::ParsePacket(unsigned char a_PacketType)
-{
- switch (a_PacketType)
- {
- default: return PARSE_UNKNOWN;
- case PACKET_ANIMATION: return ParseArmAnim();
- case PACKET_BLOCK_DIG: return ParseBlockDig();
- case PACKET_BLOCK_PLACE: return ParseBlockPlace();
- case PACKET_CHAT: return ParseChat();
- case PACKET_CREATIVE_INVENTORY_ACTION: return ParseCreativeInventoryAction();
- case PACKET_DISCONNECT: return ParseDisconnect();
- case PACKET_HANDSHAKE: return ParseHandshake();
- case PACKET_KEEP_ALIVE: return ParseKeepAlive();
- case PACKET_LOGIN: return ParseLogin();
- case PACKET_PACKET_ENTITY_ACTION: return ParseEntityAction();
- case PACKET_PING: return ParsePing();
- case PACKET_PLAYER_ABILITIES: return ParsePlayerAbilities();
- case PACKET_PLAYER_LOOK: return ParsePlayerLook();
- case PACKET_PLAYER_MOVE_LOOK: return ParsePlayerMoveLook();
- case PACKET_PLAYER_ON_GROUND: return ParsePlayerOnGround();
- case PACKET_PLAYER_POS: return ParsePlayerPosition();
- case PACKET_PLUGIN_MESSAGE: return ParsePluginMessage();
- case PACKET_RESPAWN: return ParseRespawn();
- case PACKET_SLOT_SELECTED: return ParseSlotSelected();
- case PACKET_UPDATE_SIGN: return ParseUpdateSign();
- case PACKET_USE_ENTITY: return ParseUseEntity();
- case PACKET_WINDOW_CLICK: return ParseWindowClick();
- case PACKET_WINDOW_CLOSE: return ParseWindowClose();
- }
-}
-
-
-
-
-
-#define HANDLE_PACKET_PARSE(Packet) \
- { \
- int res = Packet.Parse(m_ReceivedData); \
- if (res < 0) \
- { \
- return res; \
- } \
- }
-
-
-
-
-
-int cProtocol125::ParseArmAnim(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_PACKET_READ(ReadChar, char, Animation);
- m_Client->HandleAnimation(Animation);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseBlockDig(void)
-{
- HANDLE_PACKET_READ(ReadChar, char, Status);
- HANDLE_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_PACKET_READ(ReadByte, Byte, PosY);
- HANDLE_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_PACKET_READ(ReadChar, char, BlockFace);
- m_Client->HandleLeftClick(PosX, PosY, PosZ, BlockFace, Status);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseBlockPlace(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_PACKET_READ(ReadByte, Byte, PosY);
- HANDLE_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_PACKET_READ(ReadChar, char, BlockFace);
-
- cItem HeldItem;
- int res = ParseItem(HeldItem);
- if (res < 0)
- {
- return res;
- }
-
- // 1.2.5 didn't have any cursor position, so use 8, 8, 8, so that halfslabs and stairs work correctly and the special value is recognizable.
- m_Client->HandleRightClick(PosX, PosY, PosZ, BlockFace, 8, 8, 8, HeldItem);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseChat(void)
-{
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Message);
- m_Client->HandleChat(Message);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseCreativeInventoryAction(void)
-{
- HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
- cItem HeldItem;
- int res = ParseItem(HeldItem);
- if (res < 0)
- {
- return res;
- }
- m_Client->HandleCreativeInventory(SlotNum, HeldItem);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseDisconnect(void)
-{
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Reason);
- m_Client->HandleDisconnect(Reason);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseEntityAction(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_PACKET_READ(ReadChar, char, ActionID);
- m_Client->HandleEntityAction(EntityID, ActionID);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseHandshake(void)
-{
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
-
- AStringVector UserData = StringSplit(Username, ";"); // "FakeTruth;localhost:25565"
- if (UserData.empty())
- {
- m_Client->Kick("Did not receive username");
- return PARSE_OK;
- }
- m_Username = UserData[0];
-
- LOGD("HANDSHAKE %s", Username.c_str());
-
- if (!m_Client->HandleHandshake( m_Username ))
- {
- return PARSE_OK; // Player is not allowed into the server
- }
-
- SendHandshake(cRoot::Get()->GetServer()->GetServerID());
- LOGD("User \"%s\" was sent a handshake response", m_Username.c_str());
-
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseKeepAlive(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, KeepAliveID);
- m_Client->HandleKeepAlive(KeepAliveID);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseLogin(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, ProtocolVersion);
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, LevelType);
- HANDLE_PACKET_READ(ReadBEInt, int, ServerMode);
- HANDLE_PACKET_READ(ReadBEInt, int, Dimension);
- HANDLE_PACKET_READ(ReadChar, char, Difficulty);
- HANDLE_PACKET_READ(ReadByte, Byte, WorldHeight);
- HANDLE_PACKET_READ(ReadByte, Byte, MaxPlayers);
-
- if (ProtocolVersion < 29)
- {
- m_Client->Kick("Your client is outdated!");
- return PARSE_OK;
- }
- else if (ProtocolVersion > 29)
- {
- m_Client->Kick("Your client version is higher than the server!");
- return PARSE_OK;
- }
-
- if (m_Username.compare(Username) != 0)
- {
- LOGWARNING("Login Username (\"%s\") does not match Handshake username (\"%s\") for client @ \"%s\", kicking",
- Username.c_str(),
- m_Username.c_str(),
- m_Client->GetIPString().c_str()
- );
- m_Client->Kick("Hacked client"); // Don't tell them why we don't want them
- return PARSE_OK;
- }
-
- m_Client->HandleLogin(ProtocolVersion, Username);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParsePing(void)
-{
- // Packet has no more data
- m_Client->HandlePing();
- return PARSE_OK;
-}
-
-
-
-
-
-
-int cProtocol125::ParsePlayerAbilities(void)
-{
- HANDLE_PACKET_READ(ReadBool, bool, Invulnerable);
- HANDLE_PACKET_READ(ReadBool, bool, IsFlying);
- HANDLE_PACKET_READ(ReadBool, bool, CanFly);
- HANDLE_PACKET_READ(ReadBool, bool, InstaMine);
- // TODO: m_Client->HandlePlayerAbilities(...);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParsePlayerLook(void)
-{
- HANDLE_PACKET_READ(ReadBEFloat, float, Rotation);
- HANDLE_PACKET_READ(ReadBEFloat, float, Pitch);
- HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
- m_Client->HandlePlayerLook(Rotation, Pitch, IsOnGround);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParsePlayerMoveLook(void)
-{
- HANDLE_PACKET_READ(ReadBEDouble, double, PosX);
- HANDLE_PACKET_READ(ReadBEDouble, double, PosY);
- HANDLE_PACKET_READ(ReadBEDouble, double, Stance);
- HANDLE_PACKET_READ(ReadBEDouble, double, PosZ);
- HANDLE_PACKET_READ(ReadBEFloat, float, Rotation);
- HANDLE_PACKET_READ(ReadBEFloat, float, Pitch);
- HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
- // LOGD("Recv PML: {%0.2f, %0.2f, %0.2f}, Stance %0.2f, Gnd: %d", PosX, PosY, PosZ, Stance, IsOnGround ? 1 : 0);
- m_Client->HandlePlayerMoveLook(PosX, PosY, PosZ, Stance, Rotation, Pitch, IsOnGround);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParsePlayerOnGround(void)
-{
- HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
- // TODO: m_Client->HandleFlying(IsOnGround);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParsePlayerPosition(void)
-{
- HANDLE_PACKET_READ(ReadBEDouble, double, PosX);
- HANDLE_PACKET_READ(ReadBEDouble, double, PosY);
- HANDLE_PACKET_READ(ReadBEDouble, double, Stance);
- HANDLE_PACKET_READ(ReadBEDouble, double, PosZ);
- HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
- m_Client->HandlePlayerPos(PosX, PosY, PosZ, Stance, IsOnGround);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParsePluginMessage(void)
-{
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, ChannelName);
- HANDLE_PACKET_READ(ReadBEShort, short, Length);
- AString Data;
- if (!m_ReceivedData.ReadString(Data, Length))
- {
- m_ReceivedData.CheckValid();
- return PARSE_INCOMPLETE;
- }
- m_ReceivedData.CheckValid();
-
- // TODO: Process the data
- LOGD("Received %d bytes of plugin data on channel \"%s\".", Length, ChannelName.c_str());
-
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseRespawn(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, Dimension);
- HANDLE_PACKET_READ(ReadChar, char, Difficulty);
- HANDLE_PACKET_READ(ReadChar, char, CreativeMode);
- HANDLE_PACKET_READ(ReadBEShort, short, WorldHeight);
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, LevelType);
- m_Client->HandleRespawn();
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseSlotSelected(void)
-{
- HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
- m_Client->HandleSlotSelected(SlotNum);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseUpdateSign(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, BlockX);
- HANDLE_PACKET_READ(ReadBEShort, short, BlockY);
- HANDLE_PACKET_READ(ReadBEInt, int, BlockZ);
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line1);
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line2);
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line3);
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line4);
- m_Client->HandleUpdateSign(BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseUseEntity(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, SourceEntityID);
- HANDLE_PACKET_READ(ReadBEInt, int, TargetEntityID);
- HANDLE_PACKET_READ(ReadBool, bool, IsLeftClick);
- m_Client->HandleUseEntity(TargetEntityID, IsLeftClick);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseWindowClick(void)
-{
- HANDLE_PACKET_READ(ReadChar, char, WindowID);
- HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
- HANDLE_PACKET_READ(ReadBool, bool, IsRightClick);
- HANDLE_PACKET_READ(ReadBEShort, short, TransactionID);
- HANDLE_PACKET_READ(ReadBool, bool, IsShiftPressed);
- cItem HeldItem;
- int res = ParseItem(HeldItem);
- if (res < 0)
- {
- return res;
- }
-
- // Convert IsShiftPressed, IsRightClick, SlotNum and HeldItem into eClickAction used in the newer protocols:
- eClickAction Action;
- if (IsRightClick)
- {
- if (IsShiftPressed)
- {
- Action = caShiftRightClick;
- }
- else
- {
- if (SlotNum == -999)
- {
- Action = (HeldItem.IsEmpty()) ? caRightClickOutsideHoldNothing : caRightClickOutside;
- }
- else
- {
- Action = caRightClick;
- }
- }
- }
- else
- {
- // IsLeftClick
- if (IsShiftPressed)
- {
- Action = caShiftLeftClick;
- }
- else
- {
- if (SlotNum == -999)
- {
- Action = (HeldItem.IsEmpty()) ? caLeftClickOutsideHoldNothing : caRightClickOutside;
- }
- else
- {
- Action = caLeftClick;
- }
- }
- }
- m_Client->HandleWindowClick(WindowID, SlotNum, Action, HeldItem);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol125::ParseWindowClose(void)
-{
- HANDLE_PACKET_READ(ReadChar, char, WindowID);
- m_Client->HandleWindowClose(WindowID);
- return PARSE_OK;
-}
-
-
-
-
-
-void cProtocol125::SendPreChunk(int a_ChunkX, int a_ChunkZ, bool a_ShouldLoad)
-{
- WriteByte(PACKET_PRE_CHUNK);
- WriteInt (a_ChunkX);
- WriteInt (a_ChunkZ);
- WriteBool(a_ShouldLoad);
- Flush();
-}
-
-
-
-
-
-void cProtocol125::SendWindowSlots(char a_WindowID, int a_NumItems, const cItem * a_Items)
-{
- WriteByte (PACKET_INVENTORY_WHOLE);
- WriteByte (a_WindowID);
- WriteShort((short)a_NumItems);
-
- for (int j = 0; j < a_NumItems; j++)
- {
- WriteItem(a_Items[j]);
- }
- Flush();
-}
-
-
-
-
-
-void cProtocol125::WriteItem(const cItem & a_Item)
-{
- short ItemType = a_Item.m_ItemType;
- ASSERT(ItemType >= -1); // Check validity of packets in debug runtime
- if (ItemType <= 0)
- {
- // Fix, to make sure no invalid values are sent.
- ItemType = -1;
- }
-
- WriteShort(ItemType);
- if (a_Item.IsEmpty())
- {
- return;
- }
-
- WriteByte (a_Item.m_ItemCount);
- WriteShort(a_Item.m_ItemDamage);
-
- if (cItem::IsEnchantable(a_Item.m_ItemType))
- {
- // TODO: Implement enchantments
- WriteShort(-1);
- }
-}
-
-
-
-
-
-int cProtocol125::ParseItem(cItem & a_Item)
-{
- HANDLE_PACKET_READ(ReadBEShort, short, ItemType);
-
- if (ItemType <= -1)
- {
- a_Item.Empty();
- return PARSE_OK;
- }
- a_Item.m_ItemType = ItemType;
-
- HANDLE_PACKET_READ(ReadChar, char, ItemCount);
- HANDLE_PACKET_READ(ReadBEShort, short, ItemDamage);
- a_Item.m_ItemCount = ItemCount;
- a_Item.m_ItemDamage = ItemDamage;
- if (ItemCount <= 0)
- {
- a_Item.Empty();
- }
-
- if (!cItem::IsEnchantable(ItemType))
- {
- return PARSE_OK;
- }
-
- HANDLE_PACKET_READ(ReadBEShort, short, EnchantNumBytes);
-
- if (EnchantNumBytes <= 0)
- {
- return PARSE_OK;
- }
-
- // TODO: Enchantment not implemented yet!
- if (!m_ReceivedData.SkipRead(EnchantNumBytes))
- {
- return PARSE_INCOMPLETE;
- }
-
- return PARSE_OK;
-}
-
-
-
-
-
-AString cProtocol125::GetEntityMetaData(const cEntity & a_Entity)
-{
- // We should send all the metadata here
- AString MetaData;
- // Common metadata (index 0, byte):
- MetaData.push_back(0);
- MetaData.push_back(GetEntityMetadataFlags(a_Entity));
-
- // TODO: Add more entity-specific metadata
-
- MetaData.push_back(0x7f); // End metadata
- return MetaData;
-}
-
-
-
-
-
-char cProtocol125::GetEntityMetadataFlags(const cEntity & a_Entity)
-{
- char Flags = 0;
- if (a_Entity.IsOnFire())
- {
- Flags |= 1;
- }
- if (a_Entity.IsCrouched())
- {
- Flags |= 2;
- }
- if (a_Entity.IsRiding())
- {
- Flags |= 4;
- }
- if (a_Entity.IsSprinting())
- {
- Flags |= 8;
- }
- if (a_Entity.IsRclking())
- {
- Flags |= 16;
- }
- return Flags;
-}
-
-
-
-
+
+// Protocol125.cpp
+
+// Implements the cProtocol125 class representing the release 1.2.5 protocol (#29)
+/*
+Documentation:
+ - protocol: http://wiki.vg/wiki/index.php?title=Protocol&oldid=2513
+ - session handling: http://wiki.vg/wiki/index.php?title=Session&oldid=2262
+ - slot format: http://wiki.vg/wiki/index.php?title=Slot_Data&oldid=2152
+*/
+
+#include "Globals.h"
+
+#include "Protocol125.h"
+
+#include "../ClientHandle.h"
+#include "ChunkDataSerializer.h"
+#include "../Entity.h"
+#include "../Mobs/Monster.h"
+#include "../Pickup.h"
+#include "../Player.h"
+#include "../ChatColor.h"
+#include "../UI/Window.h"
+#include "../Root.h"
+#include "../Server.h"
+#include "../FallingBlock.h"
+
+
+
+
+
+enum
+{
+ PACKET_KEEP_ALIVE = 0x00,
+ PACKET_LOGIN = 0x01,
+ PACKET_HANDSHAKE = 0x02,
+ PACKET_CHAT = 0x03,
+ PACKET_UPDATE_TIME = 0x04,
+ PACKET_ENTITY_EQUIPMENT = 0x05,
+ PACKET_USE_ENTITY = 0x07,
+ PACKET_UPDATE_HEALTH = 0x08,
+ PACKET_RESPAWN = 0x09,
+ PACKET_PLAYER_ON_GROUND = 0x0a,
+ PACKET_PLAYER_POS = 0x0b,
+ PACKET_PLAYER_LOOK = 0x0c,
+ PACKET_PLAYER_MOVE_LOOK = 0x0d,
+ PACKET_BLOCK_DIG = 0x0e,
+ PACKET_BLOCK_PLACE = 0x0f,
+ PACKET_SLOT_SELECTED = 0x10,
+ PACKET_USE_BED = 0x11,
+ PACKET_ANIMATION = 0x12,
+ PACKET_PACKET_ENTITY_ACTION = 0x13,
+ PACKET_PLAYER_SPAWN = 0x14,
+ PACKET_PICKUP_SPAWN = 0x15,
+ PACKET_COLLECT_PICKUP = 0x16,
+ PACKET_SPAWN_OBJECT = 0x17,
+ PACKET_SPAWN_MOB = 0x18,
+ PACKET_ENTITY_VELOCITY = 0x1c,
+ PACKET_DESTROY_ENTITY = 0x1d,
+ PACKET_ENTITY = 0x1e,
+ PACKET_ENT_REL_MOVE = 0x1f,
+ PACKET_ENT_LOOK = 0x20,
+ PACKET_ENT_REL_MOVE_LOOK = 0x21,
+ PACKET_ENT_TELEPORT = 0x22,
+ PACKET_ENT_HEAD_LOOK = 0x23,
+ PACKET_ENT_STATUS = 0x26,
+ PACKET_ATTACH_ENTITY = 0x27,
+ PACKET_METADATA = 0x28,
+ PACKET_PRE_CHUNK = 0x32,
+ PACKET_MAP_CHUNK = 0x33,
+ PACKET_MULTI_BLOCK = 0x34,
+ PACKET_BLOCK_CHANGE = 0x35,
+ PACKET_BLOCK_ACTION = 0x36,
+ PACKET_EXPLOSION = 0x3C,
+ PACKET_SOUND_EFFECT = 0x3e,
+ PACKET_SOUND_PARTICLE_EFFECT = 0x3d,
+ PACKET_CHANGE_GAME_STATE = 0x46,
+ PACKET_THUNDERBOLT = 0x47,
+ PACKET_WINDOW_OPEN = 0x64,
+ PACKET_WINDOW_CLOSE = 0x65,
+ PACKET_WINDOW_CLICK = 0x66,
+ PACKET_INVENTORY_SLOT = 0x67,
+ PACKET_INVENTORY_WHOLE = 0x68,
+ PACKET_INVENTORY_PROGRESS = 0x69,
+ PACKET_CREATIVE_INVENTORY_ACTION = 0x6B,
+ PACKET_UPDATE_SIGN = 0x82,
+ PACKET_PLAYER_LIST_ITEM = 0xC9,
+ PACKET_PLAYER_ABILITIES = 0xca,
+ PACKET_PLUGIN_MESSAGE = 0xfa,
+ PACKET_PING = 0xfe,
+ PACKET_DISCONNECT = 0xff
+} ;
+
+
+
+
+
+#define HANDLE_PACKET_READ(Proc, Type, Var) \
+ Type Var; \
+ { \
+ if (!m_ReceivedData.Proc(Var)) \
+ { \
+ m_ReceivedData.CheckValid(); \
+ return PARSE_INCOMPLETE; \
+ } \
+ m_ReceivedData.CheckValid(); \
+ }
+
+
+
+
+typedef unsigned char Byte;
+
+
+
+
+
+cProtocol125::cProtocol125(cClientHandle * a_Client) :
+ super(a_Client),
+ m_ReceivedData(32 KiB)
+{
+}
+
+
+
+
+
+void cProtocol125::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ATTACH_ENTITY);
+ WriteInt(a_Entity.GetUniqueID());
+ WriteInt((a_Vehicle == NULL) ? -1 : a_Vehicle->GetUniqueID());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
+{
+ UNUSED(a_BlockType);
+
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_BLOCK_ACTION);
+ WriteInt (a_BlockX);
+ WriteShort((short)a_BlockY);
+ WriteInt (a_BlockZ);
+ WriteByte (a_Byte1);
+ WriteByte (a_Byte2);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
+{
+ // Not supported in this protocol version
+}
+
+
+
+
+
+void cProtocol125::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_BLOCK_CHANGE);
+ WriteInt (a_BlockX);
+ WriteByte((unsigned char)a_BlockY);
+ WriteInt (a_BlockZ);
+ WriteByte(a_BlockType);
+ WriteByte(a_BlockMeta);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes)
+{
+ cCSLock Lock(m_CSPacket);
+ if (a_Changes.size() == 1)
+ {
+ // Special packet for single-block changes
+ const sSetBlock & blk = a_Changes.front();
+ SendBlockChange(a_ChunkX * cChunkDef::Width + blk.x, blk.y, a_ChunkZ * cChunkDef::Width + blk.z, blk.BlockType, blk.BlockMeta);
+ return;
+ }
+
+ WriteByte (PACKET_MULTI_BLOCK);
+ WriteInt (a_ChunkX);
+ WriteInt (a_ChunkZ);
+ WriteShort((unsigned short)a_Changes.size());
+ WriteUInt (sizeof(int) * a_Changes.size());
+ 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);
+ unsigned int Blocks = itr->BlockMeta | (itr->BlockType << 4);
+ WriteUInt(Coords << 16 | Blocks);
+ }
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendChat(const AString & a_Message)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_CHAT);
+ WriteString(a_Message);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
+{
+ cCSLock Lock(m_CSPacket);
+
+ // Send the pre-chunk:
+ SendPreChunk(a_ChunkX, a_ChunkZ, true);
+
+ // Send the chunk data:
+ AString Serialized = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_2_5);
+ WriteByte(PACKET_MAP_CHUNK);
+ WriteInt (a_ChunkX);
+ WriteInt (a_ChunkZ);
+ SendData(Serialized.data(), Serialized.size());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_COLLECT_PICKUP);
+ WriteInt (a_Pickup.GetUniqueID());
+ WriteInt (a_Player.GetUniqueID());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendDestroyEntity(const cEntity & a_Entity)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_DESTROY_ENTITY);
+ WriteInt (a_Entity.GetUniqueID());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendDisconnect(const AString & a_Reason)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte ((unsigned char)PACKET_DISCONNECT);
+ WriteString(a_Reason);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ // This protocol version doesn't support this packet, sign editor is invoked by the client automatically
+ UNUSED(a_BlockX);
+ UNUSED(a_BlockY);
+ UNUSED(a_BlockZ);
+}
+
+
+
+
+
+void cProtocol125::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_ENTITY_EQUIPMENT);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteShort(a_SlotNum);
+ WriteShort(a_Item.m_ItemType);
+ WriteShort(a_Item.m_ItemDamage);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendEntityHeadLook(const cEntity & a_Entity)
+{
+ ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
+
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ENT_HEAD_LOOK);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte((char)((a_Entity.GetHeadYaw() / 360.f) * 256));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendEntityLook(const cEntity & a_Entity)
+{
+ ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
+
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ENT_LOOK);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte((char)((a_Entity.GetRotation() / 360.f) * 256));
+ WriteByte((char)((a_Entity.GetPitch() / 360.f) * 256));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendEntityMetadata(const cEntity & a_Entity)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_METADATA);
+ WriteInt (a_Entity.GetUniqueID());
+ AString MetaData = GetEntityMetaData(a_Entity);
+ SendData(MetaData.data(), MetaData.size());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendEntityProperties(const cEntity & a_Entity)
+{
+ // Not supported in this protocol version
+}
+
+
+
+
+
+void cProtocol125::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+{
+ ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
+
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ENT_REL_MOVE);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte(a_RelX);
+ WriteByte(a_RelY);
+ WriteByte(a_RelZ);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+{
+ ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
+
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ENT_REL_MOVE_LOOK);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte(a_RelX);
+ WriteByte(a_RelY);
+ WriteByte(a_RelZ);
+ WriteByte((char)((a_Entity.GetRotation() / 360.f) * 256));
+ WriteByte((char)((a_Entity.GetPitch() / 360.f) * 256));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendEntityStatus(const cEntity & a_Entity, char a_Status)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ENT_STATUS);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte(a_Status);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendEntityVelocity(const cEntity & a_Entity)
+{
+ ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID()); // Must not send for self
+
+ 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.GetSpeedY() * 400));
+ WriteShort((short) (a_Entity.GetSpeedZ() * 400));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_EXPLOSION);
+ WriteDouble (a_BlockX);
+ WriteDouble (a_BlockY);
+ WriteDouble (a_BlockZ);
+ WriteFloat (a_Radius);
+ WriteInt (a_BlocksAffected.size());
+ for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
+ {
+ WriteByte ((Byte)(itr->x - a_BlockX));
+ WriteByte ((Byte)(itr->y - a_BlockY));
+ WriteByte ((Byte)(itr->z - a_BlockZ));
+ }
+ WriteFloat ((float)a_PlayerMotion.x);
+ WriteFloat ((float)a_PlayerMotion.y);
+ WriteFloat ((float)a_PlayerMotion.z);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendGameMode(eGameMode a_GameMode)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_CHANGE_GAME_STATE);
+ WriteByte(3);
+ WriteByte((char)a_GameMode);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendHandshake(const AString & a_ConnectionHash)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_HANDSHAKE);
+ WriteString(a_ConnectionHash);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendHealth(void)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_UPDATE_HEALTH);
+ WriteShort((short)m_Client->GetPlayer()->GetHealth());
+ WriteShort(m_Client->GetPlayer()->GetFoodLevel());
+ WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendInventoryProgress(char a_WindowID, short a_ProgressBar, short a_Value)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_INVENTORY_PROGRESS);
+ WriteByte (a_WindowID);
+ WriteShort(a_ProgressBar);
+ WriteShort(a_Value);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_INVENTORY_SLOT);
+ WriteByte (a_WindowID);
+ WriteShort(a_SlotNum);
+ WriteItem (a_Item);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendKeepAlive(int a_PingID)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_KEEP_ALIVE);
+ WriteInt (a_PingID);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
+{
+ UNUSED(a_World);
+ cCSLock Lock(m_CSPacket);
+
+ WriteByte (PACKET_LOGIN);
+ WriteInt (a_Player.GetUniqueID()); // EntityID of the player
+ WriteString(""); // Username, not used
+ WriteString("default"); // Level type
+ WriteInt ((int)a_Player.GetGameMode());
+ WriteInt ((int)(a_World.GetDimension()));
+ WriteByte (2); // TODO: Difficulty
+ WriteByte (0); // Unused
+ WriteByte (60); // Client list width or something
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendPickupSpawn(const cPickup & a_Pickup)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_PICKUP_SPAWN);
+ WriteInt (a_Pickup.GetUniqueID());
+ WriteShort (a_Pickup.GetItem().m_ItemType);
+ WriteByte (a_Pickup.GetItem().m_ItemCount);
+ WriteShort (a_Pickup.GetItem().m_ItemDamage);
+ WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
+ WriteByte ((char)(a_Pickup.GetSpeed().x * 8));
+ WriteByte ((char)(a_Pickup.GetSpeed().y * 8));
+ WriteByte ((char)(a_Pickup.GetSpeed().z * 8));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ANIMATION);
+ WriteInt (a_Player.GetUniqueID());
+ WriteByte(a_Animation);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
+{
+ cCSLock Lock(m_CSPacket);
+ AString PlayerName(a_Player.GetColor());
+ PlayerName.append(a_Player.GetName());
+ if (PlayerName.length() > 14)
+ {
+ PlayerName.erase(14);
+ }
+ PlayerName += cChatColor::White;
+
+ WriteByte ((unsigned char)PACKET_PLAYER_LIST_ITEM);
+ WriteString(PlayerName);
+ WriteBool (a_IsOnline);
+ WriteShort (a_Player.GetClientHandle()->GetPing());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendPlayerMaxSpeed(void)
+{
+ // Not supported by this protocol version
+}
+
+
+
+
+
+void cProtocol125::SendPlayerMoveLook(void)
+{
+ cCSLock Lock(m_CSPacket);
+
+ /*
+ LOGD("Sending PlayerMoveLook: {%0.2f, %0.2f, %0.2f}, stance %0.2f, OnGround: %d",
+ m_Player->GetPosX(), m_Player->GetPosY(), m_Player->GetPosZ(), m_Player->GetStance(), m_Player->IsOnGround() ? 1 : 0
+ );
+ */
+
+ 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
+ WriteDouble(Player->GetPosY() + 0.03); // Add a small amount so that the player doesn't start inside a block
+ WriteDouble(Player->GetPosZ());
+ WriteFloat ((float)(Player->GetRotation()));
+ WriteFloat ((float)(Player->GetPitch()));
+ WriteBool (Player->IsOnGround());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendPlayerPosition(void)
+{
+ cCSLock Lock(m_CSPacket);
+ LOGD("Ignore send PlayerPos"); // PlayerPos is a C->S packet only now
+}
+
+
+
+
+
+void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player)
+{
+ const cItem & HeldItem = a_Player.GetEquippedItem();
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_PLAYER_SPAWN);
+ WriteInt (a_Player.GetUniqueID());
+ WriteString(a_Player.GetName());
+ WriteInt ((int)(a_Player.GetPosX() * 32));
+ WriteInt ((int)(a_Player.GetPosY() * 32));
+ WriteInt ((int)(a_Player.GetPosZ() * 32));
+ WriteByte ((char)((a_Player.GetRot().x / 360.f) * 256));
+ WriteByte ((char)((a_Player.GetRot().y / 360.f) * 256));
+ WriteShort (HeldItem.IsEmpty() ? 0 : HeldItem.m_ItemType);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendRespawn(void)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_RESPAWN);
+ WriteInt ((int)(m_Client->GetPlayer()->GetWorld()->GetDimension()));
+ WriteByte (2); // TODO: Difficulty; 2 = Normal
+ WriteByte ((char)m_Client->GetPlayer()->GetGameMode());
+ WriteShort (256); // Current world height
+ WriteString("default");
+}
+
+
+
+
+
+void cProtocol125::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+{
+ // Not needed in this protocol version
+}
+
+
+
+
+
+void cProtocol125::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
+{
+ // Not implemented in this protocol version
+}
+
+
+
+
+
+void cProtocol125::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
+{
+ // This protocol version implements falling blocks using the spawn object / vehicle packet:
+ SendSpawnObject(a_FallingBlock, 70, a_FallingBlock.GetBlockType(), 0, 0);
+}
+
+
+
+
+
+void cProtocol125::SendSpawnMob(const cMonster & a_Mob)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_SPAWN_MOB);
+ WriteInt (a_Mob.GetUniqueID());
+ WriteByte (a_Mob.GetMobType());
+ WriteVectorI((Vector3i)(a_Mob.GetPosition() * 32));
+ WriteByte (0);
+ WriteByte (0);
+ WriteByte (0);
+ AString MetaData = GetEntityMetaData(a_Mob);
+ SendData (MetaData.data(), MetaData.size());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
+{
+ UNUSED(a_Yaw);
+ UNUSED(a_Pitch);
+
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_SPAWN_OBJECT);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte(a_ObjectType);
+ WriteInt ((int)(a_Entity.GetPosX() * 32));
+ WriteInt ((int)(a_Entity.GetPosY() * 32));
+ WriteInt ((int)(a_Entity.GetPosZ() * 32));
+ WriteByte(a_Pitch);
+ WriteByte(a_Yaw);
+ WriteInt (a_ObjectData);
+ if (a_ObjectData != 0)
+ {
+ WriteShort((short)(a_Entity.GetSpeedX() * 400));
+ WriteShort((short)(a_Entity.GetSpeedY() * 400));
+ WriteShort((short)(a_Entity.GetSpeedZ() * 400));
+ }
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_SPAWN_OBJECT);
+ WriteInt (a_Vehicle.GetUniqueID());
+ WriteByte (a_VehicleType);
+ WriteInt ((int)(a_Vehicle.GetPosX() * 32));
+ WriteInt ((int)(a_Vehicle.GetPosY() * 32));
+ WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
+ WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256));
+ WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256));
+ WriteInt (1);
+ WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
+ WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
+ WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendTeleportEntity(const cEntity & a_Entity)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_ENT_TELEPORT);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteInt ((int)(floor(a_Entity.GetPosX() * 32)));
+ WriteInt ((int)(floor(a_Entity.GetPosY() * 32)));
+ WriteInt ((int)(floor(a_Entity.GetPosZ() * 32)));
+ WriteByte ((char)((a_Entity.GetRotation() / 360.f) * 256));
+ WriteByte ((char)((a_Entity.GetPitch() / 360.f) * 256));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_THUNDERBOLT);
+ WriteInt (0x7fffffff); // Entity ID of the thunderbolt; we use a constant one
+ WriteBool(true); // Unknown bool
+ WriteInt (a_BlockX * 32);
+ WriteInt (a_BlockY * 32);
+ WriteInt (a_BlockZ * 32);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_UPDATE_TIME);
+ // Use a_WorldAge for daycount, and a_TimeOfDay for the proper time of day:
+ WriteInt64((24000 * (a_WorldAge / 24000)) + (a_TimeOfDay % 24000));
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
+{
+ cCSLock Lock(m_CSPacket);
+ SendPreChunk(a_ChunkX, a_ChunkZ, false);
+}
+
+
+
+
+
+void cProtocol125::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
+)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte ((unsigned char)PACKET_UPDATE_SIGN);
+ WriteInt (a_BlockX);
+ WriteShort ((short)a_BlockY);
+ WriteInt (a_BlockZ);
+ WriteString(a_Line1);
+ WriteString(a_Line2);
+ WriteString(a_Line3);
+ WriteString(a_Line4);
+ Flush();
+}
+
+
+
+
+
+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
+ WriteInt (a_BlockX);
+ WriteByte(a_BlockY);
+ WriteInt (a_BlockZ);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendWeather(eWeather a_Weather)
+{
+ cCSLock Lock(m_CSPacket);
+ switch( a_Weather )
+ {
+ case eWeather_Sunny:
+ {
+ WriteByte(PACKET_CHANGE_GAME_STATE);
+ WriteByte(2); // Stop rain
+ WriteByte(0); // Unused
+ Flush();
+ break;
+ }
+
+ case eWeather_Rain:
+ case eWeather_ThunderStorm:
+ {
+ WriteByte(PACKET_CHANGE_GAME_STATE);
+ WriteByte(1); // Begin rain
+ WriteByte(0); // Unused
+ Flush();
+ break;
+ }
+ }
+}
+
+
+
+
+
+void cProtocol125::SendWholeInventory(const cInventory & a_Inventory)
+{
+ SendWholeInventory(*(a_Inventory.GetOwner().GetWindow()));
+}
+
+
+
+
+
+void cProtocol125::SendWholeInventory(const cWindow & a_Window)
+{
+ cCSLock Lock(m_CSPacket);
+ cItems Slots;
+ a_Window.GetSlots(*(m_Client->GetPlayer()), Slots);
+ SendWindowSlots(a_Window.GetWindowID(), Slots.size(), &(Slots[0]));
+}
+
+
+
+
+
+void cProtocol125::SendWindowClose(const cWindow & a_Window)
+{
+ if (a_Window.GetWindowType() == cWindow::Inventory)
+ {
+ // Do not send inventory-window-close
+ return;
+ }
+
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_WINDOW_CLOSE);
+ WriteByte(a_Window.GetWindowID());
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
+{
+ if (a_WindowType < 0)
+ {
+ // Do not send for inventory windows
+ return;
+ }
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_WINDOW_OPEN);
+ WriteByte (a_WindowID);
+ WriteByte (a_WindowType);
+ WriteString(a_WindowTitle);
+ WriteByte (a_NumSlots);
+ Flush();
+}
+
+
+
+
+
+AString cProtocol125::GetAuthServerID(void)
+{
+ // http://wiki.vg/wiki/index.php?title=Session&oldid=2262
+ // The server generates a random hash and that is used for all clients, unmodified
+ return cRoot::Get()->GetServer()->GetServerID();
+}
+
+
+
+
+
+void cProtocol125::SendData(const char * a_Data, int a_Size)
+{
+ m_Client->SendData(a_Data, a_Size);
+}
+
+
+
+
+
+void cProtocol125::DataReceived(const char * a_Data, int a_Size)
+{
+ if (!m_ReceivedData.Write(a_Data, a_Size))
+ {
+ // Too much data in the incoming queue, report to caller:
+ m_Client->PacketBufferFull();
+ return;
+ }
+
+ // Parse and handle all complete packets in m_ReceivedData:
+ while (m_ReceivedData.CanReadBytes(1))
+ {
+ unsigned char PacketType;
+ m_ReceivedData.ReadByte(PacketType);
+ switch (ParsePacket(PacketType))
+ {
+ case PARSE_UNKNOWN:
+ {
+ // An unknown packet has been received, notify the client and abort:
+ m_Client->PacketUnknown(PacketType);
+ return;
+ }
+ case PARSE_ERROR:
+ {
+ // An error occurred while parsing a known packet, notify the client and abort:
+ m_Client->PacketError(PacketType);
+ return;
+ }
+ case PARSE_INCOMPLETE:
+ {
+ // Incomplete packet, bail out and process with the next batch of data
+ m_ReceivedData.ResetRead();
+ return;
+ }
+ default:
+ {
+ // Packet successfully parsed, commit the read data and try again one more packet
+ m_ReceivedData.CommitRead();
+ break;
+ }
+ }
+ }
+}
+
+
+
+
+
+int cProtocol125::ParsePacket(unsigned char a_PacketType)
+{
+ switch (a_PacketType)
+ {
+ default: return PARSE_UNKNOWN;
+ case PACKET_ANIMATION: return ParseArmAnim();
+ case PACKET_BLOCK_DIG: return ParseBlockDig();
+ case PACKET_BLOCK_PLACE: return ParseBlockPlace();
+ case PACKET_CHAT: return ParseChat();
+ case PACKET_CREATIVE_INVENTORY_ACTION: return ParseCreativeInventoryAction();
+ case PACKET_DISCONNECT: return ParseDisconnect();
+ case PACKET_HANDSHAKE: return ParseHandshake();
+ case PACKET_KEEP_ALIVE: return ParseKeepAlive();
+ case PACKET_LOGIN: return ParseLogin();
+ case PACKET_PACKET_ENTITY_ACTION: return ParseEntityAction();
+ case PACKET_PING: return ParsePing();
+ case PACKET_PLAYER_ABILITIES: return ParsePlayerAbilities();
+ case PACKET_PLAYER_LOOK: return ParsePlayerLook();
+ case PACKET_PLAYER_MOVE_LOOK: return ParsePlayerMoveLook();
+ case PACKET_PLAYER_ON_GROUND: return ParsePlayerOnGround();
+ case PACKET_PLAYER_POS: return ParsePlayerPosition();
+ case PACKET_PLUGIN_MESSAGE: return ParsePluginMessage();
+ case PACKET_RESPAWN: return ParseRespawn();
+ case PACKET_SLOT_SELECTED: return ParseSlotSelected();
+ case PACKET_UPDATE_SIGN: return ParseUpdateSign();
+ case PACKET_USE_ENTITY: return ParseUseEntity();
+ case PACKET_WINDOW_CLICK: return ParseWindowClick();
+ case PACKET_WINDOW_CLOSE: return ParseWindowClose();
+ }
+}
+
+
+
+
+
+#define HANDLE_PACKET_PARSE(Packet) \
+ { \
+ int res = Packet.Parse(m_ReceivedData); \
+ if (res < 0) \
+ { \
+ return res; \
+ } \
+ }
+
+
+
+
+
+int cProtocol125::ParseArmAnim(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_PACKET_READ(ReadChar, char, Animation);
+ m_Client->HandleAnimation(Animation);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseBlockDig(void)
+{
+ HANDLE_PACKET_READ(ReadChar, char, Status);
+ HANDLE_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_PACKET_READ(ReadByte, Byte, PosY);
+ HANDLE_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_PACKET_READ(ReadChar, char, BlockFace);
+ m_Client->HandleLeftClick(PosX, PosY, PosZ, BlockFace, Status);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseBlockPlace(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_PACKET_READ(ReadByte, Byte, PosY);
+ HANDLE_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_PACKET_READ(ReadChar, char, BlockFace);
+
+ cItem HeldItem;
+ int res = ParseItem(HeldItem);
+ if (res < 0)
+ {
+ return res;
+ }
+
+ // 1.2.5 didn't have any cursor position, so use 8, 8, 8, so that halfslabs and stairs work correctly and the special value is recognizable.
+ m_Client->HandleRightClick(PosX, PosY, PosZ, BlockFace, 8, 8, 8, HeldItem);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseChat(void)
+{
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Message);
+ m_Client->HandleChat(Message);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseCreativeInventoryAction(void)
+{
+ HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
+ cItem HeldItem;
+ int res = ParseItem(HeldItem);
+ if (res < 0)
+ {
+ return res;
+ }
+ m_Client->HandleCreativeInventory(SlotNum, HeldItem);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseDisconnect(void)
+{
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Reason);
+ m_Client->HandleDisconnect(Reason);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseEntityAction(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_PACKET_READ(ReadChar, char, ActionID);
+ m_Client->HandleEntityAction(EntityID, ActionID);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseHandshake(void)
+{
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
+
+ AStringVector UserData = StringSplit(Username, ";"); // "FakeTruth;localhost:25565"
+ if (UserData.empty())
+ {
+ m_Client->Kick("Did not receive username");
+ return PARSE_OK;
+ }
+ m_Username = UserData[0];
+
+ LOGD("HANDSHAKE %s", Username.c_str());
+
+ if (!m_Client->HandleHandshake( m_Username ))
+ {
+ return PARSE_OK; // Player is not allowed into the server
+ }
+
+ SendHandshake(cRoot::Get()->GetServer()->GetServerID());
+ LOGD("User \"%s\" was sent a handshake response", m_Username.c_str());
+
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseKeepAlive(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, KeepAliveID);
+ m_Client->HandleKeepAlive(KeepAliveID);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseLogin(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, ProtocolVersion);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, LevelType);
+ HANDLE_PACKET_READ(ReadBEInt, int, ServerMode);
+ HANDLE_PACKET_READ(ReadBEInt, int, Dimension);
+ HANDLE_PACKET_READ(ReadChar, char, Difficulty);
+ HANDLE_PACKET_READ(ReadByte, Byte, WorldHeight);
+ HANDLE_PACKET_READ(ReadByte, Byte, MaxPlayers);
+
+ if (ProtocolVersion < 29)
+ {
+ m_Client->Kick("Your client is outdated!");
+ return PARSE_OK;
+ }
+ else if (ProtocolVersion > 29)
+ {
+ m_Client->Kick("Your client version is higher than the server!");
+ return PARSE_OK;
+ }
+
+ if (m_Username.compare(Username) != 0)
+ {
+ LOGWARNING("Login Username (\"%s\") does not match Handshake username (\"%s\") for client @ \"%s\", kicking",
+ Username.c_str(),
+ m_Username.c_str(),
+ m_Client->GetIPString().c_str()
+ );
+ m_Client->Kick("Hacked client"); // Don't tell them why we don't want them
+ return PARSE_OK;
+ }
+
+ m_Client->HandleLogin(ProtocolVersion, Username);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParsePing(void)
+{
+ // Packet has no more data
+ m_Client->HandlePing();
+ return PARSE_OK;
+}
+
+
+
+
+
+
+int cProtocol125::ParsePlayerAbilities(void)
+{
+ HANDLE_PACKET_READ(ReadBool, bool, Invulnerable);
+ HANDLE_PACKET_READ(ReadBool, bool, IsFlying);
+ HANDLE_PACKET_READ(ReadBool, bool, CanFly);
+ HANDLE_PACKET_READ(ReadBool, bool, InstaMine);
+ // TODO: m_Client->HandlePlayerAbilities(...);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParsePlayerLook(void)
+{
+ HANDLE_PACKET_READ(ReadBEFloat, float, Rotation);
+ HANDLE_PACKET_READ(ReadBEFloat, float, Pitch);
+ HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
+ m_Client->HandlePlayerLook(Rotation, Pitch, IsOnGround);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParsePlayerMoveLook(void)
+{
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosX);
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosY);
+ HANDLE_PACKET_READ(ReadBEDouble, double, Stance);
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosZ);
+ HANDLE_PACKET_READ(ReadBEFloat, float, Rotation);
+ HANDLE_PACKET_READ(ReadBEFloat, float, Pitch);
+ HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
+ // LOGD("Recv PML: {%0.2f, %0.2f, %0.2f}, Stance %0.2f, Gnd: %d", PosX, PosY, PosZ, Stance, IsOnGround ? 1 : 0);
+ m_Client->HandlePlayerMoveLook(PosX, PosY, PosZ, Stance, Rotation, Pitch, IsOnGround);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParsePlayerOnGround(void)
+{
+ HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
+ // TODO: m_Client->HandleFlying(IsOnGround);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParsePlayerPosition(void)
+{
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosX);
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosY);
+ HANDLE_PACKET_READ(ReadBEDouble, double, Stance);
+ HANDLE_PACKET_READ(ReadBEDouble, double, PosZ);
+ HANDLE_PACKET_READ(ReadBool, bool, IsOnGround);
+ m_Client->HandlePlayerPos(PosX, PosY, PosZ, Stance, IsOnGround);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParsePluginMessage(void)
+{
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, ChannelName);
+ HANDLE_PACKET_READ(ReadBEShort, short, Length);
+ AString Data;
+ if (!m_ReceivedData.ReadString(Data, Length))
+ {
+ m_ReceivedData.CheckValid();
+ return PARSE_INCOMPLETE;
+ }
+ m_ReceivedData.CheckValid();
+
+ // TODO: Process the data
+ LOGD("Received %d bytes of plugin data on channel \"%s\".", Length, ChannelName.c_str());
+
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseRespawn(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, Dimension);
+ HANDLE_PACKET_READ(ReadChar, char, Difficulty);
+ HANDLE_PACKET_READ(ReadChar, char, CreativeMode);
+ HANDLE_PACKET_READ(ReadBEShort, short, WorldHeight);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, LevelType);
+ m_Client->HandleRespawn();
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseSlotSelected(void)
+{
+ HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
+ m_Client->HandleSlotSelected(SlotNum);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseUpdateSign(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, BlockX);
+ HANDLE_PACKET_READ(ReadBEShort, short, BlockY);
+ HANDLE_PACKET_READ(ReadBEInt, int, BlockZ);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line1);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line2);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line3);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Line4);
+ m_Client->HandleUpdateSign(BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseUseEntity(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, SourceEntityID);
+ HANDLE_PACKET_READ(ReadBEInt, int, TargetEntityID);
+ HANDLE_PACKET_READ(ReadBool, bool, IsLeftClick);
+ m_Client->HandleUseEntity(TargetEntityID, IsLeftClick);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseWindowClick(void)
+{
+ HANDLE_PACKET_READ(ReadChar, char, WindowID);
+ HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
+ HANDLE_PACKET_READ(ReadBool, bool, IsRightClick);
+ HANDLE_PACKET_READ(ReadBEShort, short, TransactionID);
+ HANDLE_PACKET_READ(ReadBool, bool, IsShiftPressed);
+ cItem HeldItem;
+ int res = ParseItem(HeldItem);
+ if (res < 0)
+ {
+ return res;
+ }
+
+ // Convert IsShiftPressed, IsRightClick, SlotNum and HeldItem into eClickAction used in the newer protocols:
+ eClickAction Action;
+ if (IsRightClick)
+ {
+ if (IsShiftPressed)
+ {
+ Action = caShiftRightClick;
+ }
+ else
+ {
+ if (SlotNum == -999)
+ {
+ Action = (HeldItem.IsEmpty()) ? caRightClickOutsideHoldNothing : caRightClickOutside;
+ }
+ else
+ {
+ Action = caRightClick;
+ }
+ }
+ }
+ else
+ {
+ // IsLeftClick
+ if (IsShiftPressed)
+ {
+ Action = caShiftLeftClick;
+ }
+ else
+ {
+ if (SlotNum == -999)
+ {
+ Action = (HeldItem.IsEmpty()) ? caLeftClickOutsideHoldNothing : caRightClickOutside;
+ }
+ else
+ {
+ Action = caLeftClick;
+ }
+ }
+ }
+ m_Client->HandleWindowClick(WindowID, SlotNum, Action, HeldItem);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol125::ParseWindowClose(void)
+{
+ HANDLE_PACKET_READ(ReadChar, char, WindowID);
+ m_Client->HandleWindowClose(WindowID);
+ return PARSE_OK;
+}
+
+
+
+
+
+void cProtocol125::SendPreChunk(int a_ChunkX, int a_ChunkZ, bool a_ShouldLoad)
+{
+ WriteByte(PACKET_PRE_CHUNK);
+ WriteInt (a_ChunkX);
+ WriteInt (a_ChunkZ);
+ WriteBool(a_ShouldLoad);
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::SendWindowSlots(char a_WindowID, int a_NumItems, const cItem * a_Items)
+{
+ WriteByte (PACKET_INVENTORY_WHOLE);
+ WriteByte (a_WindowID);
+ WriteShort((short)a_NumItems);
+
+ for (int j = 0; j < a_NumItems; j++)
+ {
+ WriteItem(a_Items[j]);
+ }
+ Flush();
+}
+
+
+
+
+
+void cProtocol125::WriteItem(const cItem & a_Item)
+{
+ short ItemType = a_Item.m_ItemType;
+ ASSERT(ItemType >= -1); // Check validity of packets in debug runtime
+ if (ItemType <= 0)
+ {
+ // Fix, to make sure no invalid values are sent.
+ ItemType = -1;
+ }
+
+ WriteShort(ItemType);
+ if (a_Item.IsEmpty())
+ {
+ return;
+ }
+
+ WriteByte (a_Item.m_ItemCount);
+ WriteShort(a_Item.m_ItemDamage);
+
+ if (cItem::IsEnchantable(a_Item.m_ItemType))
+ {
+ // TODO: Implement enchantments
+ WriteShort(-1);
+ }
+}
+
+
+
+
+
+int cProtocol125::ParseItem(cItem & a_Item)
+{
+ HANDLE_PACKET_READ(ReadBEShort, short, ItemType);
+
+ if (ItemType <= -1)
+ {
+ a_Item.Empty();
+ return PARSE_OK;
+ }
+ a_Item.m_ItemType = ItemType;
+
+ HANDLE_PACKET_READ(ReadChar, char, ItemCount);
+ HANDLE_PACKET_READ(ReadBEShort, short, ItemDamage);
+ a_Item.m_ItemCount = ItemCount;
+ a_Item.m_ItemDamage = ItemDamage;
+ if (ItemCount <= 0)
+ {
+ a_Item.Empty();
+ }
+
+ if (!cItem::IsEnchantable(ItemType))
+ {
+ return PARSE_OK;
+ }
+
+ HANDLE_PACKET_READ(ReadBEShort, short, EnchantNumBytes);
+
+ if (EnchantNumBytes <= 0)
+ {
+ return PARSE_OK;
+ }
+
+ // TODO: Enchantment not implemented yet!
+ if (!m_ReceivedData.SkipRead(EnchantNumBytes))
+ {
+ return PARSE_INCOMPLETE;
+ }
+
+ return PARSE_OK;
+}
+
+
+
+
+
+AString cProtocol125::GetEntityMetaData(const cEntity & a_Entity)
+{
+ // We should send all the metadata here
+ AString MetaData;
+ // Common metadata (index 0, byte):
+ MetaData.push_back(0);
+ MetaData.push_back(GetEntityMetadataFlags(a_Entity));
+
+ // TODO: Add more entity-specific metadata
+
+ MetaData.push_back(0x7f); // End metadata
+ return MetaData;
+}
+
+
+
+
+
+char cProtocol125::GetEntityMetadataFlags(const cEntity & a_Entity)
+{
+ char Flags = 0;
+ if (a_Entity.IsOnFire())
+ {
+ Flags |= 1;
+ }
+ if (a_Entity.IsCrouched())
+ {
+ Flags |= 2;
+ }
+ if (a_Entity.IsRiding())
+ {
+ Flags |= 4;
+ }
+ if (a_Entity.IsSprinting())
+ {
+ Flags |= 8;
+ }
+ if (a_Entity.IsRclking())
+ {
+ Flags |= 16;
+ }
+ return Flags;
+}
+
+
+
+
diff --git a/source/Protocol/Protocol125.h b/source/Protocol/Protocol125.h
index 2f769f362..6d0fe2408 100644
--- a/source/Protocol/Protocol125.h
+++ b/source/Protocol/Protocol125.h
@@ -1,152 +1,153 @@
-
-// Protocol125.h
-
-// Interfaces to the cProtocol125 class representing the release 1.2.5 protocol (#29)
-
-
-
-
-
-#pragma once
-
-#include "Protocol.h"
-#include "../ByteBuffer.h"
-
-
-
-
-
-class cProtocol125 :
- public cProtocol
-{
- typedef cProtocol super;
-public:
- cProtocol125(cClientHandle * a_Client);
-
- /// Called when client sends some data:
- virtual void DataReceived(const char * a_Data, int a_Size) override;
-
- /// Sending stuff to clients (alphabetically sorted):
- virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle) override;
- virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
- 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 SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
- virtual void SendChat (const AString & 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 SendDestroyEntity (const cEntity & a_Entity) override;
- virtual void SendDisconnect (const AString & a_Reason) override;
- virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
- virtual void SendEntityHeadLook (const cEntity & a_Entity) override;
- virtual void SendEntityLook (const cEntity & a_Entity) override;
- virtual void SendEntityMetadata (const cEntity & a_Entity) override;
- virtual void SendEntityProperties (const cEntity & a_Entity) override;
- virtual void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
- virtual void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
- virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
- virtual void SendEntityVelocity (const cEntity & a_Entity) override;
- virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override;
- virtual void SendGameMode (eGameMode a_GameMode) override;
- virtual void SendHealth (void) override;
- virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
- virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override;
- virtual void SendKeepAlive (int a_PingID) override;
- virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
- virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
- virtual void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation) override;
- virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
- virtual void SendPlayerMaxSpeed (void) override;
- virtual void SendPlayerMoveLook (void) override;
- virtual void SendPlayerPosition (void) override;
- virtual void SendPlayerSpawn (const cPlayer & a_Player) 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 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) 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 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 SendWeather (eWeather a_Weather) override;
- virtual void SendWholeInventory (const cInventory & a_Inventory) override;
- virtual void SendWholeInventory (const cWindow & a_Window) override;
- virtual void SendWindowClose (const cWindow & a_Window) override;
- virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
-
- virtual AString GetAuthServerID(void) override;
-
-protected:
- /// Results of packet-parsing:
- enum {
- PARSE_OK = 1,
- PARSE_ERROR = -1,
- PARSE_UNKNOWN = -2,
- PARSE_INCOMPLETE = -3,
- } ;
-
- cByteBuffer m_ReceivedData; //< Buffer for the received data
-
- AString m_Username; //< Stored in ParseHandshake(), compared to Login username
-
- virtual void SendData(const char * a_Data, int 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() )
- virtual int ParsePacket(unsigned char a_PacketType);
-
- // Specific packet parsers:
- virtual int ParseArmAnim (void);
- virtual int ParseBlockDig (void);
- virtual int ParseBlockPlace (void);
- virtual int ParseChat (void);
- virtual int ParseCreativeInventoryAction(void);
- virtual int ParseDisconnect (void);
- virtual int ParseEntityAction (void);
- virtual int ParseHandshake (void);
- virtual int ParseKeepAlive (void);
- virtual int ParseLogin (void);
- virtual int ParsePing (void);
- virtual int ParsePlayerAbilities (void);
- virtual int ParsePlayerLook (void);
- virtual int ParsePlayerMoveLook (void);
- virtual int ParsePlayerOnGround (void);
- virtual int ParsePlayerPosition (void);
- virtual int ParsePluginMessage (void);
- virtual int ParseRespawn (void);
- virtual int ParseSlotSelected (void);
- virtual int ParseUpdateSign (void);
- virtual int ParseUseEntity (void);
- virtual int ParseWindowClick (void);
- virtual int ParseWindowClose (void);
-
- // Utility functions:
- /// Writes a "pre-chunk" packet
- void SendPreChunk(int a_ChunkX, int a_ChunkZ, bool a_ShouldLoad);
-
- /// Writes a "set window items" packet with the specified params
- void SendWindowSlots(char a_WindowID, int a_NumItems, const cItem * a_Items);
-
- /// Writes one item, "slot" as the protocol wiki calls it
- virtual void WriteItem(const cItem & a_Item);
-
- /// Parses one item, "slot" as the protocol wiki calls it, from m_ReceivedData; returns the usual ParsePacket() codes
- virtual int ParseItem(cItem & a_Item);
-
- /// Returns the entity metadata representation
- AString GetEntityMetaData(const cEntity & a_Entity);
-
- /// Returns the entity common metadata, index 0 (generic flags)
- char GetEntityMetadataFlags(const cEntity & a_Entity);
-} ;
-
-
-
-
+
+// Protocol125.h
+
+// Interfaces to the cProtocol125 class representing the release 1.2.5 protocol (#29)
+
+
+
+
+
+#pragma once
+
+#include "Protocol.h"
+#include "../ByteBuffer.h"
+
+
+
+
+
+class cProtocol125 :
+ public cProtocol
+{
+ typedef cProtocol super;
+public:
+ cProtocol125(cClientHandle * a_Client);
+
+ /// Called when client sends some data:
+ virtual void DataReceived(const char * a_Data, int a_Size) override;
+
+ /// Sending stuff to clients (alphabetically sorted):
+ virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle) override;
+ virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
+ 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 SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
+ virtual void SendChat (const AString & 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 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+)
+ virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
+ virtual void SendEntityHeadLook (const cEntity & a_Entity) override;
+ virtual void SendEntityLook (const cEntity & a_Entity) override;
+ virtual void SendEntityMetadata (const cEntity & a_Entity) override;
+ virtual void SendEntityProperties (const cEntity & a_Entity) override;
+ virtual void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
+ virtual void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
+ virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
+ virtual void SendEntityVelocity (const cEntity & a_Entity) override;
+ virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override;
+ virtual void SendGameMode (eGameMode a_GameMode) override;
+ virtual void SendHealth (void) override;
+ virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
+ virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override;
+ virtual void SendKeepAlive (int a_PingID) override;
+ virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
+ virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
+ virtual void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation) override;
+ virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
+ virtual void SendPlayerMaxSpeed (void) override;
+ virtual void SendPlayerMoveLook (void) override;
+ virtual void SendPlayerPosition (void) override;
+ virtual void SendPlayerSpawn (const cPlayer & a_Player) 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 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) 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 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 SendWeather (eWeather a_Weather) override;
+ virtual void SendWholeInventory (const cInventory & a_Inventory) override;
+ virtual void SendWholeInventory (const cWindow & a_Window) override;
+ virtual void SendWindowClose (const cWindow & a_Window) override;
+ virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
+
+ virtual AString GetAuthServerID(void) override;
+
+protected:
+ /// Results of packet-parsing:
+ enum {
+ PARSE_OK = 1,
+ PARSE_ERROR = -1,
+ PARSE_UNKNOWN = -2,
+ PARSE_INCOMPLETE = -3,
+ } ;
+
+ cByteBuffer m_ReceivedData; //< Buffer for the received data
+
+ AString m_Username; //< Stored in ParseHandshake(), compared to Login username
+
+ virtual void SendData(const char * a_Data, int 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() )
+ virtual int ParsePacket(unsigned char a_PacketType);
+
+ // Specific packet parsers:
+ virtual int ParseArmAnim (void);
+ virtual int ParseBlockDig (void);
+ virtual int ParseBlockPlace (void);
+ virtual int ParseChat (void);
+ virtual int ParseCreativeInventoryAction(void);
+ virtual int ParseDisconnect (void);
+ virtual int ParseEntityAction (void);
+ virtual int ParseHandshake (void);
+ virtual int ParseKeepAlive (void);
+ virtual int ParseLogin (void);
+ virtual int ParsePing (void);
+ virtual int ParsePlayerAbilities (void);
+ virtual int ParsePlayerLook (void);
+ virtual int ParsePlayerMoveLook (void);
+ virtual int ParsePlayerOnGround (void);
+ virtual int ParsePlayerPosition (void);
+ virtual int ParsePluginMessage (void);
+ virtual int ParseRespawn (void);
+ virtual int ParseSlotSelected (void);
+ virtual int ParseUpdateSign (void);
+ virtual int ParseUseEntity (void);
+ virtual int ParseWindowClick (void);
+ virtual int ParseWindowClose (void);
+
+ // Utility functions:
+ /// Writes a "pre-chunk" packet
+ void SendPreChunk(int a_ChunkX, int a_ChunkZ, bool a_ShouldLoad);
+
+ /// Writes a "set window items" packet with the specified params
+ void SendWindowSlots(char a_WindowID, int a_NumItems, const cItem * a_Items);
+
+ /// Writes one item, "slot" as the protocol wiki calls it
+ virtual void WriteItem(const cItem & a_Item);
+
+ /// Parses one item, "slot" as the protocol wiki calls it, from m_ReceivedData; returns the usual ParsePacket() codes
+ virtual int ParseItem(cItem & a_Item);
+
+ /// Returns the entity metadata representation
+ AString GetEntityMetaData(const cEntity & a_Entity);
+
+ /// Returns the entity common metadata, index 0 (generic flags)
+ char GetEntityMetadataFlags(const cEntity & a_Entity);
+} ;
+
+
+
+
diff --git a/source/Protocol/Protocol132.cpp b/source/Protocol/Protocol132.cpp
index f34401b55..9a985ec1f 100644
--- a/source/Protocol/Protocol132.cpp
+++ b/source/Protocol/Protocol132.cpp
@@ -1,902 +1,902 @@
-
-// Protocol132.cpp
-
-// Implements the cProtocol132 class representing the release 1.3.2 protocol (#39)
-
-#include "Globals.h"
-#include "Protocol132.h"
-#include "../Root.h"
-#include "../Server.h"
-#include "../ClientHandle.h"
-#include "../../CryptoPP/randpool.h"
-#include "../Item.h"
-#include "ChunkDataSerializer.h"
-#include "../Player.h"
-#include "../Mobs/Monster.h"
-#include "../UI/Window.h"
-#include "../Pickup.h"
-#include "../WorldStorage/FastNBT.h"
-#include "../StringCompression.h"
-
-
-
-
-
-#define HANDLE_PACKET_READ(Proc, Type, Var) \
- Type Var; \
- { \
- if (!m_ReceivedData.Proc(Var)) \
- { \
- m_ReceivedData.CheckValid(); \
- return PARSE_INCOMPLETE; \
- } \
- m_ReceivedData.CheckValid(); \
- }
-
-
-
-
-typedef unsigned char Byte;
-
-
-
-
-
-using namespace CryptoPP;
-
-
-
-
-
-const int MAX_ENC_LEN = 512; // Maximum size of the encrypted message; should be 128, but who knows...
-
-
-
-
-
-enum
-{
- PACKET_KEEP_ALIVE = 0x00,
- PACKET_LOGIN = 0x01,
- PACKET_ENTITY_EQUIPMENT = 0x05,
- PACKET_COMPASS = 0x06,
- PACKET_PLAYER_SPAWN = 0x14,
- PACKET_COLLECT_PICKUP = 0x16,
- PACKET_SPAWN_MOB = 0x18,
- PACKET_DESTROY_ENTITIES = 0x1d,
- PACKET_CHUNK_DATA = 0x33,
- PACKET_BLOCK_CHANGE = 0x35,
- PACKET_BLOCK_ACTION = 0x36,
- PACKET_BLOCK_BREAK_ANIM = 0x37,
- PACKET_SOUND_EFFECT = 0x3e,
- PACKET_SOUND_PARTICLE_EFFECT = 0x3d,
- PACKET_LOCALE_VIEW_DISTANCE = 0xcc,
- PACKET_CLIENT_STATUSES = 0xcd,
- PACKET_ENCRYPTION_KEY_RESP = 0xfc,
-} ;
-
-
-
-
-
-// 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(byte a_Digest[20], AString & a_Out)
-{
- bool IsNegative = (a_Digest[0] >= 0x80);
- if (IsNegative)
- {
- // Two's complement:
- bool carry = true; // Add one to the whole number
- for (int i = 19; i >= 0; i--)
- {
- a_Digest[i] = ~a_Digest[i];
- if (carry)
- {
- carry = (a_Digest[i] == 0xff);
- a_Digest[i]++;
- }
- }
- }
- a_Out.clear();
- a_Out.reserve(40);
- for (int i = 0; i < 20; i++)
- {
- AppendPrintf(a_Out, "%02x", a_Digest[i]);
- }
- while ((a_Out.length() > 0) && (a_Out[0] == '0'))
- {
- a_Out.erase(0, 1);
- }
- if (IsNegative)
- {
- a_Out.insert(0, "-");
- }
-}
-
-
-
-
-
-/*
-// 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];
- CryptoPP::SHA1 Checksum;
- Checksum.Update((const byte *)"Notch", 5);
- Checksum.Final(Digest);
- DigestToJava(Digest, DigestNotch);
- Checksum.Restart();
- Checksum.Update((const byte *)"jeb_", 4);
- Checksum.Final(Digest);
- DigestToJava(Digest, DigestJeb);
- Checksum.Restart();
- Checksum.Update((const byte *)"simon", 5);
- Checksum.Final(Digest);
- DigestToJava(Digest, DigestSimon);
- printf("Notch: \"%s\"", DigestNotch.c_str());
- printf("jeb_: \"%s\"", DigestJeb.c_str());
- printf("simon: \"%s\"", DigestSimon.c_str());
- }
-} test;
-*/
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cProtocol132:
-
-cProtocol132::cProtocol132(cClientHandle * a_Client) :
- super(a_Client),
- m_IsEncrypted(false)
-{
-}
-
-
-
-
-
-cProtocol132::~cProtocol132()
-{
- if (!m_DataToSend.empty())
- {
- LOGD("There are %d unsent bytes while deleting cProtocol132", m_DataToSend.size());
- }
-}
-
-
-
-
-
-void cProtocol132::DataReceived(const char * a_Data, int a_Size)
-{
- if (m_IsEncrypted)
- {
- byte Decrypted[512];
- while (a_Size > 0)
- {
- int NumBytes = (a_Size > sizeof(Decrypted)) ? sizeof(Decrypted) : a_Size;
- m_Decryptor.ProcessData(Decrypted, (byte *)a_Data, NumBytes);
- super::DataReceived((const char *)Decrypted, NumBytes);
- a_Size -= NumBytes;
- a_Data += NumBytes;
- }
- }
- else
- {
- super::DataReceived(a_Data, a_Size);
- }
-}
-
-
-
-
-
-void cProtocol132::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_BLOCK_ACTION);
- WriteInt (a_BlockX);
- WriteShort((short)a_BlockY);
- WriteInt (a_BlockZ);
- WriteByte (a_Byte1);
- WriteByte (a_Byte2);
- WriteShort(a_BlockType);
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_BLOCK_BREAK_ANIM);
- WriteInt (a_entityID);
- WriteInt (a_BlockX);
- WriteInt (a_BlockY);
- WriteInt (a_BlockZ);
- WriteByte (stage);
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_BLOCK_CHANGE);
- WriteInt (a_BlockX);
- WriteByte ((unsigned char)a_BlockY);
- WriteInt (a_BlockZ);
- WriteShort(a_BlockType);
- WriteByte (a_BlockMeta);
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
-{
- cCSLock Lock(m_CSPacket);
-
- // Pre-chunk not used in 1.3.2. Finally.
-
- // Send the chunk data:
- AString Serialized = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_3_2);
- WriteByte(PACKET_CHUNK_DATA);
- WriteInt (a_ChunkX);
- WriteInt (a_ChunkZ);
- SendData(Serialized.data(), Serialized.size());
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_COLLECT_PICKUP);
- WriteInt (a_Pickup.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)
- );
-}
-
-
-
-
-
-void cProtocol132::SendDestroyEntity(const cEntity & a_Entity)
-{
- if (a_Entity.GetUniqueID() == m_Client->GetPlayer()->GetUniqueID())
- {
- // Do not send "destroy self" to the client, the client would crash (FS #254)
- return;
- }
-
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_DESTROY_ENTITIES);
- WriteByte(1); // entity count
- WriteInt (a_Entity.GetUniqueID());
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_ENTITY_EQUIPMENT);
- WriteInt (a_Entity.GetUniqueID());
- WriteShort(a_SlotNum);
- WriteItem (a_Item);
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_LOGIN);
- WriteInt (a_Player.GetUniqueID()); // EntityID of the player
- WriteString("default"); // Level type
- WriteByte ((int)a_Player.GetGameMode());
- WriteByte ((Byte)(a_World.GetDimension()));
- WriteByte (2); // TODO: Difficulty
- WriteByte (0); // Unused, used to be world height
- WriteByte (8); // Client list width or something
- Flush();
-
- SendCompass(a_World);
-
- // Send the initial position (so that confirmation works, FS #245):
- SendPlayerMoveLook();
-}
-
-
-
-
-
-void cProtocol132::SendPlayerSpawn(const cPlayer & a_Player)
-{
- const cItem & HeldItem = a_Player.GetEquippedItem();
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_PLAYER_SPAWN);
- WriteInt (a_Player.GetUniqueID());
- WriteString(a_Player.GetName());
- WriteInt ((int)(a_Player.GetPosX() * 32));
- WriteInt ((int)(a_Player.GetPosY() * 32));
- WriteInt ((int)(a_Player.GetPosZ() * 32));
- WriteByte ((char)((a_Player.GetRot().x / 360.f) * 256));
- WriteByte ((char)((a_Player.GetRot().y / 360.f) * 256));
- WriteShort (HeldItem.IsEmpty() ? 0 : HeldItem.m_ItemType);
- // Player metadata: just use a default metadata value, since the client doesn't like starting without any metadata:
- WriteByte (0); // Index 0, byte (flags)
- WriteByte (0); // Flags, empty
- WriteByte (0x7f); // End of metadata
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, 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);
- WriteFloat (a_Volume);
- WriteByte ((char)(a_Pitch * 63.0f));
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_SOUND_PARTICLE_EFFECT);
- WriteInt (a_EffectID);
- WriteInt (a_SrcX / 8);
- WriteByte(a_SrcY / 8);
- WriteInt (a_SrcZ / 8);
- WriteInt (a_Data);
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendSpawnMob(const cMonster & a_Mob)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_SPAWN_MOB);
- WriteInt (a_Mob.GetUniqueID());
- WriteByte (a_Mob.GetMobType());
- WriteVectorI((Vector3i)(a_Mob.GetPosition() * 32));
- WriteByte ((Byte)((a_Mob.GetRotation() / 360.f) * 256));
- WriteByte ((Byte)((a_Mob.GetPitch() / 360.f) * 256));
- WriteByte ((Byte)((a_Mob.GetHeadYaw() / 360.f) * 256));
- WriteShort ((short)(a_Mob.GetSpeedX() * 400));
- WriteShort ((short)(a_Mob.GetSpeedY() * 400));
- WriteShort ((short)(a_Mob.GetSpeedZ() * 400));
- AString MetaData = GetEntityMetaData(a_Mob);
- SendData (MetaData.data(), MetaData.size());
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
-{
- // Not used in 1.3.2
- // Does it unload chunks on its own?
-}
-
-
-
-
-
-void cProtocol132::SendWholeInventory(const cWindow & a_Window)
-{
- // 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:
- super::SendWholeInventory(a_Window);
-
- // Send the player inventory and hotbar:
- const cInventory & Inventory = m_Client->GetPlayer()->GetInventory();
- int BaseOffset = a_Window.GetNumSlots() - (cInventory::invNumSlots - cInventory::invInventoryOffset); // Number of non-inventory slots
- char WindowID = a_Window.GetWindowID();
- for (int i = 0; i < cInventory::invInventoryCount; i++)
- {
- SendInventorySlot(WindowID, BaseOffset + i, Inventory.GetInventorySlot(i));
- } // for i - Inventory[]
- BaseOffset += cInventory::invInventoryCount;
- for (int i = 0; i < cInventory::invHotbarCount; i++)
- {
- SendInventorySlot(WindowID, BaseOffset + i, Inventory.GetHotbarSlot(i));
- } // for i - Hotbar[]
-
- // Send even the item being dragged:
- SendInventorySlot(-1, -1, m_Client->GetPlayer()->GetDraggingItem());
-}
-
-
-
-
-
-AString cProtocol132::GetAuthServerID(void)
-{
- // http://wiki.vg/wiki/index.php?title=Session&oldid=2615
- // Server uses SHA1 to mix ServerID, Client secret and server public key together
- // The mixing is done in StartEncryption, the result is in m_AuthServerID
-
- return m_AuthServerID;
-}
-
-
-
-
-
-int cProtocol132::ParsePacket(unsigned char a_PacketType)
-{
- switch (a_PacketType)
- {
- default: return super::ParsePacket(a_PacketType); // off-load previously known packets into cProtocol125
- case PACKET_LOCALE_VIEW_DISTANCE: return ParseLocaleViewDistance();
- case PACKET_CLIENT_STATUSES: return ParseClientStatuses();
- case PACKET_ENCRYPTION_KEY_RESP: return ParseEncryptionKeyResponse();
- }
-}
-
-
-
-
-
-int cProtocol132::ParseBlockPlace(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, PosX);
- HANDLE_PACKET_READ(ReadByte, Byte, PosY);
- HANDLE_PACKET_READ(ReadBEInt, int, PosZ);
- HANDLE_PACKET_READ(ReadChar, char, BlockFace);
-
- cItem HeldItem;
- int res = ParseItem(HeldItem);
- if (res < 0)
- {
- return res;
- }
-
- HANDLE_PACKET_READ(ReadChar, char, CursorX);
- HANDLE_PACKET_READ(ReadChar, char, CursorY);
- HANDLE_PACKET_READ(ReadChar, char, CursorZ);
-
- m_Client->HandleRightClick(PosX, PosY, PosZ, BlockFace, CursorX, CursorY, CursorZ, HeldItem);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol132::ParseHandshake(void)
-{
- HANDLE_PACKET_READ(ReadByte, Byte, ProtocolVersion);
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, ServerHost);
- HANDLE_PACKET_READ(ReadBEInt, int, ServerPort);
- m_Username = Username;
-
- if (!m_Client->HandleHandshake( m_Username ))
- {
- return PARSE_OK; // Player is not allowed into the server
- }
-
- // Send a 0xFD Encryption Key Request http://wiki.vg/Protocol#0xFD
- CryptoPP::StringSink sink(m_ServerPublicKey); // GCC won't allow inline instantiation in the following line, damned temporary refs
- cRoot::Get()->GetServer()->GetPublicKey().Save(sink);
- SendEncryptionKeyRequest();
-
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol132::ParseClientStatuses(void)
-{
- HANDLE_PACKET_READ(ReadByte, byte, Status);
- if ((Status & 1) == 0)
- {
- m_Client->HandleLogin(39, m_Username);
- }
- else
- {
- m_Client->HandleRespawn();
- }
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol132::ParseEncryptionKeyResponse(void)
-{
- HANDLE_PACKET_READ(ReadBEShort, short, EncKeyLength);
- AString EncKey;
- if (!m_ReceivedData.ReadString(EncKey, EncKeyLength))
- {
- return PARSE_INCOMPLETE;
- }
- HANDLE_PACKET_READ(ReadBEShort, short, EncNonceLength);
- AString EncNonce;
- if (!m_ReceivedData.ReadString(EncNonce, EncNonceLength))
- {
- return PARSE_INCOMPLETE;
- }
- if ((EncKeyLength > MAX_ENC_LEN) || (EncNonceLength > MAX_ENC_LEN))
- {
- LOGD("Too long encryption");
- m_Client->Kick("Hacked client");
- return PARSE_OK;
- }
-
- HandleEncryptionKeyResponse(EncKey, EncNonce);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol132::ParseLocaleViewDistance(void)
-{
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Locale);
- HANDLE_PACKET_READ(ReadChar, char, ViewDistance);
- HANDLE_PACKET_READ(ReadChar, char, ChatFlags);
- HANDLE_PACKET_READ(ReadChar, char, ClientDifficulty);
- // TODO: m_Client->HandleLocale(Locale);
- // TODO: m_Client->HandleViewDistance(ViewDistance);
- // TODO: m_Client->HandleChatFlags(ChatFlags);
- // Ignoring client difficulty
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol132::ParseLogin(void)
-{
- // Login packet not used in 1.3.2
- return PARSE_ERROR;
-}
-
-
-
-
-
-int cProtocol132::ParsePlayerAbilities(void)
-{
- HANDLE_PACKET_READ(ReadBool, bool, Flags);
- HANDLE_PACKET_READ(ReadChar, char, FlyingSpeed);
- HANDLE_PACKET_READ(ReadChar, char, WalkingSpeed);
- // TODO: m_Client->HandlePlayerAbilities(...);
- return PARSE_OK;
-}
-
-
-
-
-
-void cProtocol132::SendData(const char * a_Data, int a_Size)
-{
- m_DataToSend.append(a_Data, a_Size);
-}
-
-
-
-
-
-void cProtocol132::Flush(void)
-{
- ASSERT(m_CSPacket.IsLockedByCurrentThread()); // Did all packets lock the CS properly?
-
- if (m_DataToSend.empty())
- {
- LOGD("Flushing empty");
- return;
- }
- const char * a_Data = m_DataToSend.data();
- int a_Size = m_DataToSend.size();
- if (m_IsEncrypted)
- {
- byte Encrypted[8192]; // Larger buffer, we may be sending lots of data (chunks)
- while (a_Size > 0)
- {
- int NumBytes = (a_Size > sizeof(Encrypted)) ? sizeof(Encrypted) : a_Size;
- m_Encryptor.ProcessData(Encrypted, (byte *)a_Data, NumBytes);
- super::SendData((const char *)Encrypted, NumBytes);
- a_Size -= NumBytes;
- a_Data += NumBytes;
- }
- }
- else
- {
- super::SendData(a_Data, a_Size);
- }
- m_DataToSend.clear();
-}
-
-
-
-
-
-void cProtocol132::WriteItem(const cItem & a_Item)
-{
- short ItemType = a_Item.m_ItemType;
- ASSERT(ItemType >= -1); // Check validity of packets in debug runtime
- if (ItemType <= 0)
- {
- // Fix, to make sure no invalid values are sent.
- ItemType = -1;
- }
-
- if (a_Item.IsEmpty())
- {
- WriteShort(-1);
- return;
- }
-
- WriteShort(ItemType);
- WriteByte (a_Item.m_ItemCount);
- WriteShort(a_Item.m_ItemDamage);
-
- if (a_Item.m_Enchantments.IsEmpty())
- {
- WriteShort(-1);
- return;
- }
-
- // Send the enchantments:
- cFastNBTWriter Writer;
- const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
- a_Item.m_Enchantments.WriteToNBTCompound(Writer, TagName);
- Writer.Finish();
- AString Compressed;
- CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed);
- WriteShort(Compressed.size());
- SendData(Compressed.data(), Compressed.size());
-}
-
-
-
-
-
-int cProtocol132::ParseItem(cItem & a_Item)
-{
- HANDLE_PACKET_READ(ReadBEShort, short, ItemType);
-
- if (ItemType <= -1)
- {
- a_Item.Empty();
- return PARSE_OK;
- }
- a_Item.m_ItemType = ItemType;
-
- HANDLE_PACKET_READ(ReadChar, char, ItemCount);
- HANDLE_PACKET_READ(ReadBEShort, short, ItemDamage);
- a_Item.m_ItemCount = ItemCount;
- a_Item.m_ItemDamage = ItemDamage;
- if (ItemCount <= 0)
- {
- a_Item.Empty();
- }
-
- HANDLE_PACKET_READ(ReadBEShort, short, MetadataLength);
- if (MetadataLength <= 0)
- {
- return PARSE_OK;
- }
-
- // Read the metadata
- AString Metadata;
- Metadata.resize(MetadataLength);
- if (!m_ReceivedData.ReadBuf((void *)Metadata.data(), MetadataLength))
- {
- return PARSE_INCOMPLETE;
- }
-
- return ParseItemMetadata(a_Item, Metadata);
-}
-
-
-
-
-
-int cProtocol132::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
-{
- // Uncompress the GZIPped data:
- AString Uncompressed;
- if (UncompressStringGZIP(a_Metadata.data(), a_Metadata.size(), Uncompressed) != Z_OK)
- {
- AString HexDump;
- CreateHexDump(HexDump, a_Metadata.data(), a_Metadata.size(), 16);
- LOG("Cannot unGZIP item metadata:\n%s", HexDump.c_str());
- return PARSE_ERROR;
- }
-
- // Parse into NBT:
- cParsedNBT NBT(Uncompressed.data(), Uncompressed.size());
- if (!NBT.IsValid())
- {
- AString HexDump;
- CreateHexDump(HexDump, Uncompressed.data(), Uncompressed.size(), 16);
- LOG("Cannot parse NBT item metadata:\n%s", HexDump.c_str());
- return PARSE_ERROR;
- }
-
- // Load enchantments from the NBT:
- for (int tag = NBT.GetFirstChild(NBT.GetRoot()); tag >= 0; tag = NBT.GetNextSibling(tag))
- {
- if (
- (NBT.GetType(tag) == TAG_List) &&
- (
- (NBT.GetName(tag) == "ench") ||
- (NBT.GetName(tag) == "StoredEnchantments")
- )
- )
- {
- a_Item.m_Enchantments.ParseFromNBT(NBT, tag);
- }
- }
-
- return PARSE_OK;
-}
-
-
-
-
-
-void cProtocol132::SendCompass(const cWorld & a_World)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_COMPASS);
- WriteInt((int)(a_World.GetSpawnX()));
- WriteInt((int)(a_World.GetSpawnY()));
- WriteInt((int)(a_World.GetSpawnZ()));
- Flush();
-}
-
-
-
-
-
-void cProtocol132::SendEncryptionKeyRequest(void)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte((char)0xfd);
- WriteString(cRoot::Get()->GetServer()->GetServerID());
- WriteShort((short)m_ServerPublicKey.size());
- SendData(m_ServerPublicKey.data(), m_ServerPublicKey.size());
- WriteShort(4);
- WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
- Flush();
-}
-
-
-
-
-
-void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const AString & a_EncNonce)
-{
- // Decrypt EncNonce using privkey
- RSAES<PKCS1v15>::Decryptor rsaDecryptor(cRoot::Get()->GetServer()->GetPrivateKey());
- time_t CurTime = time(NULL);
- CryptoPP::RandomPool rng;
- rng.Put((const byte *)&CurTime, sizeof(CurTime));
- byte DecryptedNonce[MAX_ENC_LEN];
- DecodingResult res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncNonce.data(), a_EncNonce.size(), DecryptedNonce);
- if (!res.isValidCoding || (res.messageLength != 4))
- {
- LOGD("Bad nonce length");
- m_Client->Kick("Hacked client");
- return;
- }
- if (ntohl(*((int *)DecryptedNonce)) != (unsigned)(uintptr_t)this)
- {
- LOGD("Bad nonce value");
- m_Client->Kick("Hacked client");
- return;
- }
-
- // Decrypt the symmetric encryption key using privkey:
- byte DecryptedKey[MAX_ENC_LEN];
- res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncKey.data(), a_EncKey.size(), DecryptedKey);
- if (!res.isValidCoding || (res.messageLength != 16))
- {
- LOGD("Bad key length");
- m_Client->Kick("Hacked client");
- return;
- }
-
- {
- // Send encryption key response:
- cCSLock Lock(m_CSPacket);
- WriteByte((char)0xfc);
- WriteShort(0);
- WriteShort(0);
- Flush();
- }
-
- StartEncryption(DecryptedKey);
- return;
-}
-
-
-
-
-
-void cProtocol132::StartEncryption(const byte * a_Key)
-{
- m_Encryptor.SetKey(a_Key, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(a_Key, 16))(Name::FeedbackSize(), 1));
- m_Decryptor.SetKey(a_Key, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(a_Key, 16))(Name::FeedbackSize(), 1));
- m_IsEncrypted = true;
-
- // Prepare the m_AuthServerID:
- CryptoPP::SHA1 Checksum;
- AString ServerID = cRoot::Get()->GetServer()->GetServerID();
- Checksum.Update((const byte *)ServerID.c_str(), ServerID.length());
- Checksum.Update(a_Key, 16);
- Checksum.Update((const byte *)m_ServerPublicKey.c_str(), m_ServerPublicKey.length());
- byte Digest[20];
- Checksum.Final(Digest);
- DigestToJava(Digest, m_AuthServerID);
-}
-
-
-
-
+
+// Protocol132.cpp
+
+// Implements the cProtocol132 class representing the release 1.3.2 protocol (#39)
+
+#include "Globals.h"
+#include "Protocol132.h"
+#include "../Root.h"
+#include "../Server.h"
+#include "../ClientHandle.h"
+#include "../../CryptoPP/randpool.h"
+#include "../Item.h"
+#include "ChunkDataSerializer.h"
+#include "../Player.h"
+#include "../Mobs/Monster.h"
+#include "../UI/Window.h"
+#include "../Pickup.h"
+#include "../WorldStorage/FastNBT.h"
+#include "../StringCompression.h"
+
+
+
+
+
+#define HANDLE_PACKET_READ(Proc, Type, Var) \
+ Type Var; \
+ { \
+ if (!m_ReceivedData.Proc(Var)) \
+ { \
+ m_ReceivedData.CheckValid(); \
+ return PARSE_INCOMPLETE; \
+ } \
+ m_ReceivedData.CheckValid(); \
+ }
+
+
+
+
+typedef unsigned char Byte;
+
+
+
+
+
+using namespace CryptoPP;
+
+
+
+
+
+const int MAX_ENC_LEN = 512; // Maximum size of the encrypted message; should be 128, but who knows...
+
+
+
+
+
+enum
+{
+ PACKET_KEEP_ALIVE = 0x00,
+ PACKET_LOGIN = 0x01,
+ PACKET_ENTITY_EQUIPMENT = 0x05,
+ PACKET_COMPASS = 0x06,
+ PACKET_PLAYER_SPAWN = 0x14,
+ PACKET_COLLECT_PICKUP = 0x16,
+ PACKET_SPAWN_MOB = 0x18,
+ PACKET_DESTROY_ENTITIES = 0x1d,
+ PACKET_CHUNK_DATA = 0x33,
+ PACKET_BLOCK_CHANGE = 0x35,
+ PACKET_BLOCK_ACTION = 0x36,
+ PACKET_BLOCK_BREAK_ANIM = 0x37,
+ PACKET_SOUND_EFFECT = 0x3e,
+ PACKET_SOUND_PARTICLE_EFFECT = 0x3d,
+ PACKET_LOCALE_VIEW_DISTANCE = 0xcc,
+ PACKET_CLIENT_STATUSES = 0xcd,
+ PACKET_ENCRYPTION_KEY_RESP = 0xfc,
+} ;
+
+
+
+
+
+// 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(byte a_Digest[20], AString & a_Out)
+{
+ bool IsNegative = (a_Digest[0] >= 0x80);
+ if (IsNegative)
+ {
+ // Two's complement:
+ bool carry = true; // Add one to the whole number
+ for (int i = 19; i >= 0; i--)
+ {
+ a_Digest[i] = ~a_Digest[i];
+ if (carry)
+ {
+ carry = (a_Digest[i] == 0xff);
+ a_Digest[i]++;
+ }
+ }
+ }
+ a_Out.clear();
+ a_Out.reserve(40);
+ for (int i = 0; i < 20; i++)
+ {
+ AppendPrintf(a_Out, "%02x", a_Digest[i]);
+ }
+ while ((a_Out.length() > 0) && (a_Out[0] == '0'))
+ {
+ a_Out.erase(0, 1);
+ }
+ if (IsNegative)
+ {
+ a_Out.insert(0, "-");
+ }
+}
+
+
+
+
+
+/*
+// 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];
+ CryptoPP::SHA1 Checksum;
+ Checksum.Update((const byte *)"Notch", 5);
+ Checksum.Final(Digest);
+ DigestToJava(Digest, DigestNotch);
+ Checksum.Restart();
+ Checksum.Update((const byte *)"jeb_", 4);
+ Checksum.Final(Digest);
+ DigestToJava(Digest, DigestJeb);
+ Checksum.Restart();
+ Checksum.Update((const byte *)"simon", 5);
+ Checksum.Final(Digest);
+ DigestToJava(Digest, DigestSimon);
+ printf("Notch: \"%s\"", DigestNotch.c_str());
+ printf("jeb_: \"%s\"", DigestJeb.c_str());
+ printf("simon: \"%s\"", DigestSimon.c_str());
+ }
+} test;
+*/
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cProtocol132:
+
+cProtocol132::cProtocol132(cClientHandle * a_Client) :
+ super(a_Client),
+ m_IsEncrypted(false)
+{
+}
+
+
+
+
+
+cProtocol132::~cProtocol132()
+{
+ if (!m_DataToSend.empty())
+ {
+ LOGD("There are %d unsent bytes while deleting cProtocol132", m_DataToSend.size());
+ }
+}
+
+
+
+
+
+void cProtocol132::DataReceived(const char * a_Data, int a_Size)
+{
+ if (m_IsEncrypted)
+ {
+ byte Decrypted[512];
+ while (a_Size > 0)
+ {
+ int NumBytes = (a_Size > sizeof(Decrypted)) ? sizeof(Decrypted) : a_Size;
+ m_Decryptor.ProcessData(Decrypted, (byte *)a_Data, NumBytes);
+ super::DataReceived((const char *)Decrypted, NumBytes);
+ a_Size -= NumBytes;
+ a_Data += NumBytes;
+ }
+ }
+ else
+ {
+ super::DataReceived(a_Data, a_Size);
+ }
+}
+
+
+
+
+
+void cProtocol132::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_BLOCK_ACTION);
+ WriteInt (a_BlockX);
+ WriteShort((short)a_BlockY);
+ WriteInt (a_BlockZ);
+ WriteByte (a_Byte1);
+ WriteByte (a_Byte2);
+ WriteShort(a_BlockType);
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_BLOCK_BREAK_ANIM);
+ WriteInt (a_entityID);
+ WriteInt (a_BlockX);
+ WriteInt (a_BlockY);
+ WriteInt (a_BlockZ);
+ WriteByte (stage);
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_BLOCK_CHANGE);
+ WriteInt (a_BlockX);
+ WriteByte ((unsigned char)a_BlockY);
+ WriteInt (a_BlockZ);
+ WriteShort(a_BlockType);
+ WriteByte (a_BlockMeta);
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
+{
+ cCSLock Lock(m_CSPacket);
+
+ // Pre-chunk not used in 1.3.2. Finally.
+
+ // Send the chunk data:
+ AString Serialized = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_3_2);
+ WriteByte(PACKET_CHUNK_DATA);
+ WriteInt (a_ChunkX);
+ WriteInt (a_ChunkZ);
+ SendData(Serialized.data(), Serialized.size());
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_COLLECT_PICKUP);
+ WriteInt (a_Pickup.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)
+ );
+}
+
+
+
+
+
+void cProtocol132::SendDestroyEntity(const cEntity & a_Entity)
+{
+ if (a_Entity.GetUniqueID() == m_Client->GetPlayer()->GetUniqueID())
+ {
+ // Do not send "destroy self" to the client, the client would crash (FS #254)
+ return;
+ }
+
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_DESTROY_ENTITIES);
+ WriteByte(1); // entity count
+ WriteInt (a_Entity.GetUniqueID());
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_ENTITY_EQUIPMENT);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteShort(a_SlotNum);
+ WriteItem (a_Item);
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_LOGIN);
+ WriteInt (a_Player.GetUniqueID()); // EntityID of the player
+ WriteString("default"); // Level type
+ WriteByte ((int)a_Player.GetGameMode());
+ WriteByte ((Byte)(a_World.GetDimension()));
+ WriteByte (2); // TODO: Difficulty
+ WriteByte (0); // Unused, used to be world height
+ WriteByte (8); // Client list width or something
+ Flush();
+
+ SendCompass(a_World);
+
+ // Send the initial position (so that confirmation works, FS #245):
+ SendPlayerMoveLook();
+}
+
+
+
+
+
+void cProtocol132::SendPlayerSpawn(const cPlayer & a_Player)
+{
+ const cItem & HeldItem = a_Player.GetEquippedItem();
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_PLAYER_SPAWN);
+ WriteInt (a_Player.GetUniqueID());
+ WriteString(a_Player.GetName());
+ WriteInt ((int)(a_Player.GetPosX() * 32));
+ WriteInt ((int)(a_Player.GetPosY() * 32));
+ WriteInt ((int)(a_Player.GetPosZ() * 32));
+ WriteByte ((char)((a_Player.GetRot().x / 360.f) * 256));
+ WriteByte ((char)((a_Player.GetRot().y / 360.f) * 256));
+ WriteShort (HeldItem.IsEmpty() ? 0 : HeldItem.m_ItemType);
+ // Player metadata: just use a default metadata value, since the client doesn't like starting without any metadata:
+ WriteByte (0); // Index 0, byte (flags)
+ WriteByte (0); // Flags, empty
+ WriteByte (0x7f); // End of metadata
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, 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);
+ WriteFloat (a_Volume);
+ WriteByte ((char)(a_Pitch * 63.0f));
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_SOUND_PARTICLE_EFFECT);
+ WriteInt (a_EffectID);
+ WriteInt (a_SrcX / 8);
+ WriteByte(a_SrcY / 8);
+ WriteInt (a_SrcZ / 8);
+ WriteInt (a_Data);
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendSpawnMob(const cMonster & a_Mob)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_SPAWN_MOB);
+ WriteInt (a_Mob.GetUniqueID());
+ WriteByte (a_Mob.GetMobType());
+ WriteVectorI((Vector3i)(a_Mob.GetPosition() * 32));
+ WriteByte ((Byte)((a_Mob.GetRotation() / 360.f) * 256));
+ WriteByte ((Byte)((a_Mob.GetPitch() / 360.f) * 256));
+ WriteByte ((Byte)((a_Mob.GetHeadYaw() / 360.f) * 256));
+ WriteShort ((short)(a_Mob.GetSpeedX() * 400));
+ WriteShort ((short)(a_Mob.GetSpeedY() * 400));
+ WriteShort ((short)(a_Mob.GetSpeedZ() * 400));
+ AString MetaData = GetEntityMetaData(a_Mob);
+ SendData (MetaData.data(), MetaData.size());
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
+{
+ // Not used in 1.3.2
+ // Does it unload chunks on its own?
+}
+
+
+
+
+
+void cProtocol132::SendWholeInventory(const cWindow & a_Window)
+{
+ // 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:
+ super::SendWholeInventory(a_Window);
+
+ // Send the player inventory and hotbar:
+ const cInventory & Inventory = m_Client->GetPlayer()->GetInventory();
+ int BaseOffset = a_Window.GetNumSlots() - (cInventory::invNumSlots - cInventory::invInventoryOffset); // Number of non-inventory slots
+ char WindowID = a_Window.GetWindowID();
+ for (int i = 0; i < cInventory::invInventoryCount; i++)
+ {
+ SendInventorySlot(WindowID, BaseOffset + i, Inventory.GetInventorySlot(i));
+ } // for i - Inventory[]
+ BaseOffset += cInventory::invInventoryCount;
+ for (int i = 0; i < cInventory::invHotbarCount; i++)
+ {
+ SendInventorySlot(WindowID, BaseOffset + i, Inventory.GetHotbarSlot(i));
+ } // for i - Hotbar[]
+
+ // Send even the item being dragged:
+ SendInventorySlot(-1, -1, m_Client->GetPlayer()->GetDraggingItem());
+}
+
+
+
+
+
+AString cProtocol132::GetAuthServerID(void)
+{
+ // http://wiki.vg/wiki/index.php?title=Session&oldid=2615
+ // Server uses SHA1 to mix ServerID, Client secret and server public key together
+ // The mixing is done in StartEncryption, the result is in m_AuthServerID
+
+ return m_AuthServerID;
+}
+
+
+
+
+
+int cProtocol132::ParsePacket(unsigned char a_PacketType)
+{
+ switch (a_PacketType)
+ {
+ default: return super::ParsePacket(a_PacketType); // off-load previously known packets into cProtocol125
+ case PACKET_LOCALE_VIEW_DISTANCE: return ParseLocaleViewDistance();
+ case PACKET_CLIENT_STATUSES: return ParseClientStatuses();
+ case PACKET_ENCRYPTION_KEY_RESP: return ParseEncryptionKeyResponse();
+ }
+}
+
+
+
+
+
+int cProtocol132::ParseBlockPlace(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, PosX);
+ HANDLE_PACKET_READ(ReadByte, Byte, PosY);
+ HANDLE_PACKET_READ(ReadBEInt, int, PosZ);
+ HANDLE_PACKET_READ(ReadChar, char, BlockFace);
+
+ cItem HeldItem;
+ int res = ParseItem(HeldItem);
+ if (res < 0)
+ {
+ return res;
+ }
+
+ HANDLE_PACKET_READ(ReadChar, char, CursorX);
+ HANDLE_PACKET_READ(ReadChar, char, CursorY);
+ HANDLE_PACKET_READ(ReadChar, char, CursorZ);
+
+ m_Client->HandleRightClick(PosX, PosY, PosZ, BlockFace, CursorX, CursorY, CursorZ, HeldItem);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol132::ParseHandshake(void)
+{
+ HANDLE_PACKET_READ(ReadByte, Byte, ProtocolVersion);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, ServerHost);
+ HANDLE_PACKET_READ(ReadBEInt, int, ServerPort);
+ m_Username = Username;
+
+ if (!m_Client->HandleHandshake( m_Username ))
+ {
+ return PARSE_OK; // Player is not allowed into the server
+ }
+
+ // Send a 0xFD Encryption Key Request http://wiki.vg/Protocol#0xFD
+ CryptoPP::StringSink sink(m_ServerPublicKey); // GCC won't allow inline instantiation in the following line, damned temporary refs
+ cRoot::Get()->GetServer()->GetPublicKey().Save(sink);
+ SendEncryptionKeyRequest();
+
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol132::ParseClientStatuses(void)
+{
+ HANDLE_PACKET_READ(ReadByte, byte, Status);
+ if ((Status & 1) == 0)
+ {
+ m_Client->HandleLogin(39, m_Username);
+ }
+ else
+ {
+ m_Client->HandleRespawn();
+ }
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol132::ParseEncryptionKeyResponse(void)
+{
+ HANDLE_PACKET_READ(ReadBEShort, short, EncKeyLength);
+ AString EncKey;
+ if (!m_ReceivedData.ReadString(EncKey, EncKeyLength))
+ {
+ return PARSE_INCOMPLETE;
+ }
+ HANDLE_PACKET_READ(ReadBEShort, short, EncNonceLength);
+ AString EncNonce;
+ if (!m_ReceivedData.ReadString(EncNonce, EncNonceLength))
+ {
+ return PARSE_INCOMPLETE;
+ }
+ if ((EncKeyLength > MAX_ENC_LEN) || (EncNonceLength > MAX_ENC_LEN))
+ {
+ LOGD("Too long encryption");
+ m_Client->Kick("Hacked client");
+ return PARSE_OK;
+ }
+
+ HandleEncryptionKeyResponse(EncKey, EncNonce);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol132::ParseLocaleViewDistance(void)
+{
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Locale);
+ HANDLE_PACKET_READ(ReadChar, char, ViewDistance);
+ HANDLE_PACKET_READ(ReadChar, char, ChatFlags);
+ HANDLE_PACKET_READ(ReadChar, char, ClientDifficulty);
+ // TODO: m_Client->HandleLocale(Locale);
+ // TODO: m_Client->HandleViewDistance(ViewDistance);
+ // TODO: m_Client->HandleChatFlags(ChatFlags);
+ // Ignoring client difficulty
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol132::ParseLogin(void)
+{
+ // Login packet not used in 1.3.2
+ return PARSE_ERROR;
+}
+
+
+
+
+
+int cProtocol132::ParsePlayerAbilities(void)
+{
+ HANDLE_PACKET_READ(ReadBool, bool, Flags);
+ HANDLE_PACKET_READ(ReadChar, char, FlyingSpeed);
+ HANDLE_PACKET_READ(ReadChar, char, WalkingSpeed);
+ // TODO: m_Client->HandlePlayerAbilities(...);
+ return PARSE_OK;
+}
+
+
+
+
+
+void cProtocol132::SendData(const char * a_Data, int a_Size)
+{
+ m_DataToSend.append(a_Data, a_Size);
+}
+
+
+
+
+
+void cProtocol132::Flush(void)
+{
+ ASSERT(m_CSPacket.IsLockedByCurrentThread()); // Did all packets lock the CS properly?
+
+ if (m_DataToSend.empty())
+ {
+ LOGD("Flushing empty");
+ return;
+ }
+ const char * a_Data = m_DataToSend.data();
+ int a_Size = m_DataToSend.size();
+ if (m_IsEncrypted)
+ {
+ byte Encrypted[8192]; // Larger buffer, we may be sending lots of data (chunks)
+ while (a_Size > 0)
+ {
+ int NumBytes = (a_Size > sizeof(Encrypted)) ? sizeof(Encrypted) : a_Size;
+ m_Encryptor.ProcessData(Encrypted, (byte *)a_Data, NumBytes);
+ super::SendData((const char *)Encrypted, NumBytes);
+ a_Size -= NumBytes;
+ a_Data += NumBytes;
+ }
+ }
+ else
+ {
+ super::SendData(a_Data, a_Size);
+ }
+ m_DataToSend.clear();
+}
+
+
+
+
+
+void cProtocol132::WriteItem(const cItem & a_Item)
+{
+ short ItemType = a_Item.m_ItemType;
+ ASSERT(ItemType >= -1); // Check validity of packets in debug runtime
+ if (ItemType <= 0)
+ {
+ // Fix, to make sure no invalid values are sent.
+ ItemType = -1;
+ }
+
+ if (a_Item.IsEmpty())
+ {
+ WriteShort(-1);
+ return;
+ }
+
+ WriteShort(ItemType);
+ WriteByte (a_Item.m_ItemCount);
+ WriteShort(a_Item.m_ItemDamage);
+
+ if (a_Item.m_Enchantments.IsEmpty())
+ {
+ WriteShort(-1);
+ return;
+ }
+
+ // Send the enchantments:
+ cFastNBTWriter Writer;
+ const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
+ a_Item.m_Enchantments.WriteToNBTCompound(Writer, TagName);
+ Writer.Finish();
+ AString Compressed;
+ CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed);
+ WriteShort(Compressed.size());
+ SendData(Compressed.data(), Compressed.size());
+}
+
+
+
+
+
+int cProtocol132::ParseItem(cItem & a_Item)
+{
+ HANDLE_PACKET_READ(ReadBEShort, short, ItemType);
+
+ if (ItemType <= -1)
+ {
+ a_Item.Empty();
+ return PARSE_OK;
+ }
+ a_Item.m_ItemType = ItemType;
+
+ HANDLE_PACKET_READ(ReadChar, char, ItemCount);
+ HANDLE_PACKET_READ(ReadBEShort, short, ItemDamage);
+ a_Item.m_ItemCount = ItemCount;
+ a_Item.m_ItemDamage = ItemDamage;
+ if (ItemCount <= 0)
+ {
+ a_Item.Empty();
+ }
+
+ HANDLE_PACKET_READ(ReadBEShort, short, MetadataLength);
+ if (MetadataLength <= 0)
+ {
+ return PARSE_OK;
+ }
+
+ // Read the metadata
+ AString Metadata;
+ Metadata.resize(MetadataLength);
+ if (!m_ReceivedData.ReadBuf((void *)Metadata.data(), MetadataLength))
+ {
+ return PARSE_INCOMPLETE;
+ }
+
+ return ParseItemMetadata(a_Item, Metadata);
+}
+
+
+
+
+
+int cProtocol132::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
+{
+ // Uncompress the GZIPped data:
+ AString Uncompressed;
+ if (UncompressStringGZIP(a_Metadata.data(), a_Metadata.size(), Uncompressed) != Z_OK)
+ {
+ AString HexDump;
+ CreateHexDump(HexDump, a_Metadata.data(), a_Metadata.size(), 16);
+ LOG("Cannot unGZIP item metadata:\n%s", HexDump.c_str());
+ return PARSE_ERROR;
+ }
+
+ // Parse into NBT:
+ cParsedNBT NBT(Uncompressed.data(), Uncompressed.size());
+ if (!NBT.IsValid())
+ {
+ AString HexDump;
+ CreateHexDump(HexDump, Uncompressed.data(), Uncompressed.size(), 16);
+ LOG("Cannot parse NBT item metadata:\n%s", HexDump.c_str());
+ return PARSE_ERROR;
+ }
+
+ // Load enchantments from the NBT:
+ for (int tag = NBT.GetFirstChild(NBT.GetRoot()); tag >= 0; tag = NBT.GetNextSibling(tag))
+ {
+ if (
+ (NBT.GetType(tag) == TAG_List) &&
+ (
+ (NBT.GetName(tag) == "ench") ||
+ (NBT.GetName(tag) == "StoredEnchantments")
+ )
+ )
+ {
+ a_Item.m_Enchantments.ParseFromNBT(NBT, tag);
+ }
+ }
+
+ return PARSE_OK;
+}
+
+
+
+
+
+void cProtocol132::SendCompass(const cWorld & a_World)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_COMPASS);
+ WriteInt((int)(a_World.GetSpawnX()));
+ WriteInt((int)(a_World.GetSpawnY()));
+ WriteInt((int)(a_World.GetSpawnZ()));
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::SendEncryptionKeyRequest(void)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte((char)0xfd);
+ WriteString(cRoot::Get()->GetServer()->GetServerID());
+ WriteShort((short)m_ServerPublicKey.size());
+ SendData(m_ServerPublicKey.data(), m_ServerPublicKey.size());
+ WriteShort(4);
+ WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
+ Flush();
+}
+
+
+
+
+
+void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const AString & a_EncNonce)
+{
+ // Decrypt EncNonce using privkey
+ RSAES<PKCS1v15>::Decryptor rsaDecryptor(cRoot::Get()->GetServer()->GetPrivateKey());
+ time_t CurTime = time(NULL);
+ CryptoPP::RandomPool rng;
+ rng.Put((const byte *)&CurTime, sizeof(CurTime));
+ byte DecryptedNonce[MAX_ENC_LEN];
+ DecodingResult res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncNonce.data(), a_EncNonce.size(), DecryptedNonce);
+ if (!res.isValidCoding || (res.messageLength != 4))
+ {
+ LOGD("Bad nonce length");
+ m_Client->Kick("Hacked client");
+ return;
+ }
+ if (ntohl(*((int *)DecryptedNonce)) != (unsigned)(uintptr_t)this)
+ {
+ LOGD("Bad nonce value");
+ m_Client->Kick("Hacked client");
+ return;
+ }
+
+ // Decrypt the symmetric encryption key using privkey:
+ byte DecryptedKey[MAX_ENC_LEN];
+ res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncKey.data(), a_EncKey.size(), DecryptedKey);
+ if (!res.isValidCoding || (res.messageLength != 16))
+ {
+ LOGD("Bad key length");
+ m_Client->Kick("Hacked client");
+ return;
+ }
+
+ {
+ // Send encryption key response:
+ cCSLock Lock(m_CSPacket);
+ WriteByte((char)0xfc);
+ WriteShort(0);
+ WriteShort(0);
+ Flush();
+ }
+
+ StartEncryption(DecryptedKey);
+ return;
+}
+
+
+
+
+
+void cProtocol132::StartEncryption(const byte * a_Key)
+{
+ m_Encryptor.SetKey(a_Key, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(a_Key, 16))(Name::FeedbackSize(), 1));
+ m_Decryptor.SetKey(a_Key, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(a_Key, 16))(Name::FeedbackSize(), 1));
+ m_IsEncrypted = true;
+
+ // Prepare the m_AuthServerID:
+ CryptoPP::SHA1 Checksum;
+ AString ServerID = cRoot::Get()->GetServer()->GetServerID();
+ Checksum.Update((const byte *)ServerID.c_str(), ServerID.length());
+ Checksum.Update(a_Key, 16);
+ Checksum.Update((const byte *)m_ServerPublicKey.c_str(), m_ServerPublicKey.length());
+ byte Digest[20];
+ Checksum.Final(Digest);
+ DigestToJava(Digest, m_AuthServerID);
+}
+
+
+
+
diff --git a/source/Protocol/Protocol132.h b/source/Protocol/Protocol132.h
index cf559f1ca..bf8b4ff0e 100644
--- a/source/Protocol/Protocol132.h
+++ b/source/Protocol/Protocol132.h
@@ -1,100 +1,100 @@
-
-// Protocol132.h
-
-// Interfaces to the cProtocol132 class representing the release 1.3.2 protocol (#39)
-
-
-
-
-
-#pragma once
-
-#include "Protocol125.h"
-#include "../../CryptoPP/modes.h"
-#include "../../CryptoPP/aes.h"
-
-
-
-
-
-class cProtocol132 :
- public cProtocol125
-{
- typedef cProtocol125 super;
-public:
-
- cProtocol132(cClientHandle * a_Client);
- virtual ~cProtocol132();
-
- /// Called when client sends some data:
- virtual void DataReceived(const char * a_Data, int a_Size) override;
-
- // Sending commands (alphabetically sorted):
- virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
- 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 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 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 SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
- virtual void SendWholeInventory (const cWindow & a_Window) override;
-
- virtual AString GetAuthServerID(void) override;
-
- /// Handling of the additional packets:
- virtual int ParsePacket(unsigned char a_PacketType) override;
-
- // Modified packets:
- virtual int ParseBlockPlace (void) override;
- virtual int ParseHandshake (void) override;
- virtual int ParseLogin (void) override;
- virtual int ParsePlayerAbilities(void) override;
-
- // New packets:
- virtual int ParseClientStatuses (void);
- virtual int ParseEncryptionKeyResponse(void);
- virtual int ParseLocaleViewDistance (void);
-
-protected:
- bool m_IsEncrypted;
- CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption m_Decryptor;
- CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption m_Encryptor;
- AString m_DataToSend;
-
- /// The ServerID used for session authentication; set in StartEncryption(), used in GetAuthServerID()
- AString m_AuthServerID;
-
- /// The server's public key, as used by SendEncryptionKeyRequest() and StartEncryption()
- AString m_ServerPublicKey;
-
- virtual void SendData(const char * a_Data, int a_Size) override;
-
- // DEBUG:
- virtual void Flush(void) override;
-
- // Items in slots are sent differently
- virtual void WriteItem(const cItem & a_Item) override;
- virtual int ParseItem(cItem & a_Item) override;
-
- /// Parses the metadata that may come with the item.
- int ParseItemMetadata(cItem & a_Item, const AString & a_Metadata);
-
- virtual void SendCompass(const cWorld & a_World);
- virtual void SendEncryptionKeyRequest(void);
-
- /// Decrypts the key and nonce, checks nonce, starts the symmetric encryption
- void HandleEncryptionKeyResponse(const AString & a_EncKey, const AString & a_EncNonce);
-
- /// Starts the symmetric encryption with the specified key; also sets m_AuthServerID
- void StartEncryption(const byte * a_Key);
-} ;
-
-
-
-
+
+// Protocol132.h
+
+// Interfaces to the cProtocol132 class representing the release 1.3.2 protocol (#39)
+
+
+
+
+
+#pragma once
+
+#include "Protocol125.h"
+#include "../../CryptoPP/modes.h"
+#include "../../CryptoPP/aes.h"
+
+
+
+
+
+class cProtocol132 :
+ public cProtocol125
+{
+ typedef cProtocol125 super;
+public:
+
+ cProtocol132(cClientHandle * a_Client);
+ virtual ~cProtocol132();
+
+ /// Called when client sends some data:
+ virtual void DataReceived(const char * a_Data, int a_Size) override;
+
+ // Sending commands (alphabetically sorted):
+ virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
+ 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 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 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 SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
+ virtual void SendWholeInventory (const cWindow & a_Window) override;
+
+ virtual AString GetAuthServerID(void) override;
+
+ /// Handling of the additional packets:
+ virtual int ParsePacket(unsigned char a_PacketType) override;
+
+ // Modified packets:
+ virtual int ParseBlockPlace (void) override;
+ virtual int ParseHandshake (void) override;
+ virtual int ParseLogin (void) override;
+ virtual int ParsePlayerAbilities(void) override;
+
+ // New packets:
+ virtual int ParseClientStatuses (void);
+ virtual int ParseEncryptionKeyResponse(void);
+ virtual int ParseLocaleViewDistance (void);
+
+protected:
+ bool m_IsEncrypted;
+ CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption m_Decryptor;
+ CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption m_Encryptor;
+ AString m_DataToSend;
+
+ /// The ServerID used for session authentication; set in StartEncryption(), used in GetAuthServerID()
+ AString m_AuthServerID;
+
+ /// The server's public key, as used by SendEncryptionKeyRequest() and StartEncryption()
+ AString m_ServerPublicKey;
+
+ virtual void SendData(const char * a_Data, int a_Size) override;
+
+ // DEBUG:
+ virtual void Flush(void) override;
+
+ // Items in slots are sent differently
+ virtual void WriteItem(const cItem & a_Item) override;
+ virtual int ParseItem(cItem & a_Item) override;
+
+ /// Parses the metadata that may come with the item.
+ int ParseItemMetadata(cItem & a_Item, const AString & a_Metadata);
+
+ virtual void SendCompass(const cWorld & a_World);
+ virtual void SendEncryptionKeyRequest(void);
+
+ /// Decrypts the key and nonce, checks nonce, starts the symmetric encryption
+ void HandleEncryptionKeyResponse(const AString & a_EncKey, const AString & a_EncNonce);
+
+ /// Starts the symmetric encryption with the specified key; also sets m_AuthServerID
+ void StartEncryption(const byte * a_Key);
+} ;
+
+
+
+
diff --git a/source/Protocol/Protocol14x.cpp b/source/Protocol/Protocol14x.cpp
index b7d3c91df..35fe0ce1c 100644
--- a/source/Protocol/Protocol14x.cpp
+++ b/source/Protocol/Protocol14x.cpp
@@ -1,253 +1,253 @@
-
-// Protocol14x.cpp
-
-/*
-Implements the 1.4.x protocol classes representing these protocols:
-- cProtocol142:
- - release 1.4.2 protocol (#47)
- - release 1.4.4 protocol (#49) - the same protocol class is used, because the only difference is in a packet that MCServer doesn't implement yet (ITEM_DATA)
- - release 1.4.5 protocol (same as 1.4.4)
-- cProtocol146:
- - release 1.4.6 protocol (#51)
-*/
-
-#include "Globals.h"
-#include "Protocol14x.h"
-#include "../Root.h"
-#include "../Server.h"
-#include "../ClientHandle.h"
-#include "../../CryptoPP/randpool.h"
-#include "../Item.h"
-#include "ChunkDataSerializer.h"
-#include "../Player.h"
-#include "../Mobs/Monster.h"
-#include "../UI/Window.h"
-#include "../Pickup.h"
-#include "../FallingBlock.h"
-
-
-
-
-
-#define HANDLE_PACKET_READ(Proc, Type, Var) \
- Type Var; \
- { \
- if (!m_ReceivedData.Proc(Var)) \
- { \
- m_ReceivedData.CheckValid(); \
- return PARSE_INCOMPLETE; \
- } \
- m_ReceivedData.CheckValid(); \
- }
-
-
-
-
-
-enum
-{
- PACKET_UPDATE_TIME = 0x04,
- PACKET_PICKUP_SPAWN = 0x15,
- PACKET_SPAWN_OBJECT = 0x17,
- PACKET_ENTITY_METADATA = 0x28,
- PACKET_SOUND_PARTICLE_EFFECT = 0x3d
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cProtocol142:
-
-cProtocol142::cProtocol142(cClientHandle * a_Client) :
- super(a_Client)
-{
-}
-
-
-
-
-
-int cProtocol142::ParseLocaleViewDistance(void)
-{
- HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Locale);
- HANDLE_PACKET_READ(ReadChar, char, ViewDistance);
- HANDLE_PACKET_READ(ReadChar, char, ChatFlags);
- HANDLE_PACKET_READ(ReadChar, char, ClientDifficulty);
- HANDLE_PACKET_READ(ReadChar, char, ShouldShowCape); // <-- new in 1.4.2
- // TODO: m_Client->HandleLocale(Locale);
- // TODO: m_Client->HandleViewDistance(ViewDistance);
- // TODO: m_Client->HandleChatFlags(ChatFlags);
- // Ignoring client difficulty
- return PARSE_OK;
-}
-
-
-
-
-
-void cProtocol142::SendPickupSpawn(const cPickup & a_Pickup)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_PICKUP_SPAWN);
- WriteInt (a_Pickup.GetUniqueID());
- WriteItem (a_Pickup.GetItem());
- WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
- WriteByte ((char)(a_Pickup.GetSpeed().x * 8));
- WriteByte ((char)(a_Pickup.GetSpeed().y * 8));
- WriteByte ((char)(a_Pickup.GetSpeed().z * 8));
- Flush();
-}
-
-
-
-
-
-void cProtocol142::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_SOUND_PARTICLE_EFFECT);
- WriteInt (a_EffectID);
- WriteInt (a_SrcX / 8);
- WriteByte(a_SrcY / 8);
- WriteInt (a_SrcZ / 8);
- WriteInt (a_Data);
- WriteBool(0);
- Flush();
-}
-
-
-
-
-
-void cProtocol142::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_UPDATE_TIME);
- WriteInt64(a_WorldAge);
- WriteInt64(a_TimeOfDay);
- Flush();
-}
-
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cProtocol146:
-
-cProtocol146::cProtocol146(cClientHandle * a_Client) :
- super(a_Client)
-{
-}
-
-
-
-
-
-void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
-{
- ASSERT(!a_Pickup.GetItem().IsEmpty());
-
- cCSLock Lock(m_CSPacket);
-
- // Send a SPAWN_OBJECT packet for the base entity:
- WriteByte(PACKET_SPAWN_OBJECT);
- WriteInt (a_Pickup.GetUniqueID());
- WriteByte(0x02);
- WriteInt ((int)(a_Pickup.GetPosX() * 32));
- WriteInt ((int)(a_Pickup.GetPosY() * 32));
- WriteInt ((int)(a_Pickup.GetPosZ() * 32));
- WriteInt (1);
- WriteShort((short)(a_Pickup.GetSpeed().x * 32));
- WriteShort((short)(a_Pickup.GetSpeed().y * 32));
- WriteShort((short)(a_Pickup.GetSpeed().z * 32));
- WriteByte(0);
- WriteByte(0);
-
- // Send a ENTITY_METADATA packet with the slot info:
- WriteByte(PACKET_ENTITY_METADATA);
- WriteInt(a_Pickup.GetUniqueID());
- WriteByte(0xaa); // a slot value at index 10
- WriteItem(a_Pickup.GetItem());
- WriteByte(0x7f); // End of metadata
- Flush();
-}
-
-
-
-
-
-void cProtocol146::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
-{
- // Send a spawn object / vehicle packet
- cCSLock Lock(m_CSPacket);
-
- WriteByte(PACKET_SPAWN_OBJECT);
- WriteInt (a_FallingBlock.GetUniqueID());
- WriteByte(70);
- WriteInt ((int)(a_FallingBlock.GetPosX() * 32));
- WriteInt ((int)(a_FallingBlock.GetPosY() * 32));
- WriteInt ((int)(a_FallingBlock.GetPosZ() * 32));
- WriteByte (0); // Pitch
- WriteByte (0); // Yaw
- WriteInt (a_FallingBlock.GetBlockType()); // data indicator = blocktype
- WriteShort((short)(a_FallingBlock.GetSpeedX() * 400));
- WriteShort((short)(a_FallingBlock.GetSpeedY() * 400));
- WriteShort((short)(a_FallingBlock.GetSpeedZ() * 400));
- Flush();
-}
-
-
-
-
-
-void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_SPAWN_OBJECT);
- WriteInt (a_Entity.GetUniqueID());
- WriteByte(a_ObjectType);
- WriteInt ((int)(a_Entity.GetPosX() * 32));
- WriteInt ((int)(a_Entity.GetPosY() * 32));
- WriteInt ((int)(a_Entity.GetPosZ() * 32));
- WriteByte(a_Pitch);
- WriteByte(a_Yaw);
- WriteInt (a_ObjectData);
- if (a_ObjectData != 0)
- {
- WriteShort((short)(a_Entity.GetSpeedX() * 400));
- WriteShort((short)(a_Entity.GetSpeedY() * 400));
- WriteShort((short)(a_Entity.GetSpeedZ() * 400));
- }
- Flush();
-}
-
-
-
-
-
-void cProtocol146::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_SPAWN_OBJECT);
- WriteInt (a_Vehicle.GetUniqueID());
- WriteByte(a_VehicleType);
- WriteInt ((int)(a_Vehicle.GetPosX() * 32));
- WriteInt ((int)(a_Vehicle.GetPosY() * 32));
- WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
- WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256));
- WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256));
- WriteInt (1);
- WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
- WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
- WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
- Flush();
-}
-
-
-
-
-
+
+// Protocol14x.cpp
+
+/*
+Implements the 1.4.x protocol classes representing these protocols:
+- cProtocol142:
+ - release 1.4.2 protocol (#47)
+ - release 1.4.4 protocol (#49) - the same protocol class is used, because the only difference is in a packet that MCServer doesn't implement yet (ITEM_DATA)
+ - release 1.4.5 protocol (same as 1.4.4)
+- cProtocol146:
+ - release 1.4.6 protocol (#51)
+*/
+
+#include "Globals.h"
+#include "Protocol14x.h"
+#include "../Root.h"
+#include "../Server.h"
+#include "../ClientHandle.h"
+#include "../../CryptoPP/randpool.h"
+#include "../Item.h"
+#include "ChunkDataSerializer.h"
+#include "../Player.h"
+#include "../Mobs/Monster.h"
+#include "../UI/Window.h"
+#include "../Pickup.h"
+#include "../FallingBlock.h"
+
+
+
+
+
+#define HANDLE_PACKET_READ(Proc, Type, Var) \
+ Type Var; \
+ { \
+ if (!m_ReceivedData.Proc(Var)) \
+ { \
+ m_ReceivedData.CheckValid(); \
+ return PARSE_INCOMPLETE; \
+ } \
+ m_ReceivedData.CheckValid(); \
+ }
+
+
+
+
+
+enum
+{
+ PACKET_UPDATE_TIME = 0x04,
+ PACKET_PICKUP_SPAWN = 0x15,
+ PACKET_SPAWN_OBJECT = 0x17,
+ PACKET_ENTITY_METADATA = 0x28,
+ PACKET_SOUND_PARTICLE_EFFECT = 0x3d
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cProtocol142:
+
+cProtocol142::cProtocol142(cClientHandle * a_Client) :
+ super(a_Client)
+{
+}
+
+
+
+
+
+int cProtocol142::ParseLocaleViewDistance(void)
+{
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Locale);
+ HANDLE_PACKET_READ(ReadChar, char, ViewDistance);
+ HANDLE_PACKET_READ(ReadChar, char, ChatFlags);
+ HANDLE_PACKET_READ(ReadChar, char, ClientDifficulty);
+ HANDLE_PACKET_READ(ReadChar, char, ShouldShowCape); // <-- new in 1.4.2
+ // TODO: m_Client->HandleLocale(Locale);
+ // TODO: m_Client->HandleViewDistance(ViewDistance);
+ // TODO: m_Client->HandleChatFlags(ChatFlags);
+ // Ignoring client difficulty
+ return PARSE_OK;
+}
+
+
+
+
+
+void cProtocol142::SendPickupSpawn(const cPickup & a_Pickup)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_PICKUP_SPAWN);
+ WriteInt (a_Pickup.GetUniqueID());
+ WriteItem (a_Pickup.GetItem());
+ WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
+ WriteByte ((char)(a_Pickup.GetSpeed().x * 8));
+ WriteByte ((char)(a_Pickup.GetSpeed().y * 8));
+ WriteByte ((char)(a_Pickup.GetSpeed().z * 8));
+ Flush();
+}
+
+
+
+
+
+void cProtocol142::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_SOUND_PARTICLE_EFFECT);
+ WriteInt (a_EffectID);
+ WriteInt (a_SrcX / 8);
+ WriteByte(a_SrcY / 8);
+ WriteInt (a_SrcZ / 8);
+ WriteInt (a_Data);
+ WriteBool(0);
+ Flush();
+}
+
+
+
+
+
+void cProtocol142::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_UPDATE_TIME);
+ WriteInt64(a_WorldAge);
+ WriteInt64(a_TimeOfDay);
+ Flush();
+}
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cProtocol146:
+
+cProtocol146::cProtocol146(cClientHandle * a_Client) :
+ super(a_Client)
+{
+}
+
+
+
+
+
+void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
+{
+ ASSERT(!a_Pickup.GetItem().IsEmpty());
+
+ cCSLock Lock(m_CSPacket);
+
+ // Send a SPAWN_OBJECT packet for the base entity:
+ WriteByte(PACKET_SPAWN_OBJECT);
+ WriteInt (a_Pickup.GetUniqueID());
+ WriteByte(0x02);
+ WriteInt ((int)(a_Pickup.GetPosX() * 32));
+ WriteInt ((int)(a_Pickup.GetPosY() * 32));
+ WriteInt ((int)(a_Pickup.GetPosZ() * 32));
+ WriteInt (1);
+ WriteShort((short)(a_Pickup.GetSpeed().x * 32));
+ WriteShort((short)(a_Pickup.GetSpeed().y * 32));
+ WriteShort((short)(a_Pickup.GetSpeed().z * 32));
+ WriteByte(0);
+ WriteByte(0);
+
+ // Send a ENTITY_METADATA packet with the slot info:
+ WriteByte(PACKET_ENTITY_METADATA);
+ WriteInt(a_Pickup.GetUniqueID());
+ WriteByte(0xaa); // a slot value at index 10
+ WriteItem(a_Pickup.GetItem());
+ WriteByte(0x7f); // End of metadata
+ Flush();
+}
+
+
+
+
+
+void cProtocol146::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
+{
+ // Send a spawn object / vehicle packet
+ cCSLock Lock(m_CSPacket);
+
+ WriteByte(PACKET_SPAWN_OBJECT);
+ WriteInt (a_FallingBlock.GetUniqueID());
+ WriteByte(70);
+ WriteInt ((int)(a_FallingBlock.GetPosX() * 32));
+ WriteInt ((int)(a_FallingBlock.GetPosY() * 32));
+ WriteInt ((int)(a_FallingBlock.GetPosZ() * 32));
+ WriteByte (0); // Pitch
+ WriteByte (0); // Yaw
+ WriteInt (a_FallingBlock.GetBlockType()); // data indicator = blocktype
+ WriteShort((short)(a_FallingBlock.GetSpeedX() * 400));
+ WriteShort((short)(a_FallingBlock.GetSpeedY() * 400));
+ WriteShort((short)(a_FallingBlock.GetSpeedZ() * 400));
+ Flush();
+}
+
+
+
+
+
+void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_SPAWN_OBJECT);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte(a_ObjectType);
+ WriteInt ((int)(a_Entity.GetPosX() * 32));
+ WriteInt ((int)(a_Entity.GetPosY() * 32));
+ WriteInt ((int)(a_Entity.GetPosZ() * 32));
+ WriteByte(a_Pitch);
+ WriteByte(a_Yaw);
+ WriteInt (a_ObjectData);
+ if (a_ObjectData != 0)
+ {
+ WriteShort((short)(a_Entity.GetSpeedX() * 400));
+ WriteShort((short)(a_Entity.GetSpeedY() * 400));
+ WriteShort((short)(a_Entity.GetSpeedZ() * 400));
+ }
+ Flush();
+}
+
+
+
+
+
+void cProtocol146::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_SPAWN_OBJECT);
+ WriteInt (a_Vehicle.GetUniqueID());
+ WriteByte(a_VehicleType);
+ WriteInt ((int)(a_Vehicle.GetPosX() * 32));
+ WriteInt ((int)(a_Vehicle.GetPosY() * 32));
+ WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
+ WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256));
+ WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256));
+ WriteInt (1);
+ WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
+ WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
+ WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
+ Flush();
+}
+
+
+
+
+
diff --git a/source/Protocol/Protocol14x.h b/source/Protocol/Protocol14x.h
index a9ff14d84..c3193a3e7 100644
--- a/source/Protocol/Protocol14x.h
+++ b/source/Protocol/Protocol14x.h
@@ -1,63 +1,63 @@
-
-// Protocol14x.h
-
-/*
-Interfaces to the 1.4.x protocol classes representing these protocols:
-- cProtocol142:
- - release 1.4.2 protocol (#47)
- - release 1.4.4 protocol (#49) - the same protocol class is used, because the only difference is in a packet that MCServer doesn't implement yet (ITEM_DATA)
- - release 1.4.5 protocol (same as 1.4.4)
-- cProtocol146:
- - release 1.4.6 protocol (#51)
-*/
-
-
-
-
-
-#pragma once
-
-#include "Protocol132.h"
-
-
-
-
-
-class cProtocol142 :
- public cProtocol132
-{
- typedef cProtocol132 super;
-
-public:
- cProtocol142(cClientHandle * a_Client);
-
- // Sending commands (alphabetically sorted):
- virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
- virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
- virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay) override;
-
- // Specific packet parsers:
- virtual int ParseLocaleViewDistance(void) override;
-} ;
-
-
-
-
-
-class cProtocol146 :
- public cProtocol142
-{
- typedef cProtocol142 super;
-
-public:
- cProtocol146(cClientHandle * a_Client);
-
- virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
- virtual void SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) 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) override;
-} ;
-
-
-
-
+
+// Protocol14x.h
+
+/*
+Interfaces to the 1.4.x protocol classes representing these protocols:
+- cProtocol142:
+ - release 1.4.2 protocol (#47)
+ - release 1.4.4 protocol (#49) - the same protocol class is used, because the only difference is in a packet that MCServer doesn't implement yet (ITEM_DATA)
+ - release 1.4.5 protocol (same as 1.4.4)
+- cProtocol146:
+ - release 1.4.6 protocol (#51)
+*/
+
+
+
+
+
+#pragma once
+
+#include "Protocol132.h"
+
+
+
+
+
+class cProtocol142 :
+ public cProtocol132
+{
+ typedef cProtocol132 super;
+
+public:
+ cProtocol142(cClientHandle * a_Client);
+
+ // Sending commands (alphabetically sorted):
+ virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
+ virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
+ virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay) override;
+
+ // Specific packet parsers:
+ virtual int ParseLocaleViewDistance(void) override;
+} ;
+
+
+
+
+
+class cProtocol146 :
+ public cProtocol142
+{
+ typedef cProtocol142 super;
+
+public:
+ cProtocol146(cClientHandle * a_Client);
+
+ virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
+ virtual void SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) 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) override;
+} ;
+
+
+
+
diff --git a/source/Protocol/Protocol15x.cpp b/source/Protocol/Protocol15x.cpp
index cb7fc9fb6..cbae0700e 100644
--- a/source/Protocol/Protocol15x.cpp
+++ b/source/Protocol/Protocol15x.cpp
@@ -1,137 +1,137 @@
-
-// Protocol15x.cpp
-
-/*
-Implements the 1.5.x protocol classes:
- - cProtocol150
- - release 1.5 protocol (#60)
- - release 1.5.2 protocol (#61, no relevant changes found)
-*/
-
-#include "Globals.h"
-#include "Protocol15x.h"
-#include "../ClientHandle.h"
-#include "../Item.h"
-
-
-
-
-
-#define HANDLE_PACKET_READ(Proc, Type, Var) \
- Type Var; \
- { \
- if (!m_ReceivedData.Proc(Var)) \
- { \
- m_ReceivedData.CheckValid(); \
- return PARSE_INCOMPLETE; \
- } \
- m_ReceivedData.CheckValid(); \
- }
-
-
-
-
-
-enum
-{
- PACKET_WINDOW_OPEN = 0x64,
-} ;
-
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cProtocol150:
-
-cProtocol150::cProtocol150(cClientHandle * a_Client) :
- super(a_Client)
-{
-}
-
-
-
-
-
-void cProtocol150::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
-{
- if (a_WindowType < 0)
- {
- // Do not send for inventory windows
- return;
- }
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_WINDOW_OPEN);
- WriteByte (a_WindowID);
- WriteByte (a_WindowType);
- WriteString(a_WindowTitle);
- WriteByte (a_NumSlots);
- WriteByte (1); // Use title
- Flush();
-}
-
-
-
-
-
-int cProtocol150::ParseWindowClick(void)
-{
- HANDLE_PACKET_READ(ReadChar, char, WindowID);
- HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
- HANDLE_PACKET_READ(ReadByte, Byte, Button);
- HANDLE_PACKET_READ(ReadBEShort, short, TransactionID);
- HANDLE_PACKET_READ(ReadByte, Byte, Mode);
- cItem HeldItem;
- int res = ParseItem(HeldItem);
- if (res < 0)
- {
- return res;
- }
-
- // Convert Button, Mode, SlotNum and HeldItem into eClickAction:
- eClickAction Action;
- switch ((Mode << 8) | Button)
- {
- case 0x0000: Action = (SlotNum != -999) ? caLeftClick : caLeftClickOutside; break;
- case 0x0001: Action = (SlotNum != -999) ? caRightClick : caRightClickOutside; break;
- case 0x0100: Action = caShiftLeftClick; break;
- case 0x0101: Action = caShiftRightClick; break;
- case 0x0200: Action = caNumber1; break;
- case 0x0201: Action = caNumber2; break;
- case 0x0202: Action = caNumber3; break;
- case 0x0203: Action = caNumber4; break;
- case 0x0204: Action = caNumber5; break;
- case 0x0205: Action = caNumber6; break;
- case 0x0206: Action = caNumber7; break;
- case 0x0207: Action = caNumber8; break;
- case 0x0208: Action = caNumber9; break;
- case 0x0300: Action = caMiddleClick; break;
- case 0x0400: Action = (SlotNum == -999) ? caLeftClickOutsideHoldNothing : caDropKey; break;
- case 0x0401: Action = (SlotNum == -999) ? caRightClickOutsideHoldNothing : caCtrlDropKey; break;
- case 0x0500: Action = (SlotNum == -999) ? caLeftPaintBegin : caUnknown; break;
- case 0x0501: Action = (SlotNum != -999) ? caLeftPaintProgress : caUnknown; break;
- case 0x0502: Action = (SlotNum == -999) ? caLeftPaintEnd : caUnknown; break;
- case 0x0504: Action = (SlotNum == -999) ? caRightPaintBegin : caUnknown; break;
- case 0x0505: Action = (SlotNum != -999) ? caRightPaintProgress : caUnknown; break;
- case 0x0506: Action = (SlotNum == -999) ? caRightPaintEnd : caUnknown; break;
- case 0x0600: Action = caDblClick; break;
- }
-
- if (Action == caUnknown)
- {
- LOGWARNING("Received an unknown click action combination: Mode = %d, Button = %d, Slot = %d, HeldItem = %s. Ignoring packet.",
- Mode, Button, SlotNum, ItemToFullString(HeldItem).c_str()
- );
- ASSERT(!"Unknown click action");
- return PARSE_OK;
- }
-
- m_Client->HandleWindowClick(WindowID, SlotNum, Action, HeldItem);
- return PARSE_OK;
-}
-
-
-
-
-
+
+// Protocol15x.cpp
+
+/*
+Implements the 1.5.x protocol classes:
+ - cProtocol150
+ - release 1.5 protocol (#60)
+ - release 1.5.2 protocol (#61, no relevant changes found)
+*/
+
+#include "Globals.h"
+#include "Protocol15x.h"
+#include "../ClientHandle.h"
+#include "../Item.h"
+
+
+
+
+
+#define HANDLE_PACKET_READ(Proc, Type, Var) \
+ Type Var; \
+ { \
+ if (!m_ReceivedData.Proc(Var)) \
+ { \
+ m_ReceivedData.CheckValid(); \
+ return PARSE_INCOMPLETE; \
+ } \
+ m_ReceivedData.CheckValid(); \
+ }
+
+
+
+
+
+enum
+{
+ PACKET_WINDOW_OPEN = 0x64,
+} ;
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cProtocol150:
+
+cProtocol150::cProtocol150(cClientHandle * a_Client) :
+ super(a_Client)
+{
+}
+
+
+
+
+
+void cProtocol150::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
+{
+ if (a_WindowType < 0)
+ {
+ // Do not send for inventory windows
+ return;
+ }
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_WINDOW_OPEN);
+ WriteByte (a_WindowID);
+ WriteByte (a_WindowType);
+ WriteString(a_WindowTitle);
+ WriteByte (a_NumSlots);
+ WriteByte (1); // Use title
+ Flush();
+}
+
+
+
+
+
+int cProtocol150::ParseWindowClick(void)
+{
+ HANDLE_PACKET_READ(ReadChar, char, WindowID);
+ HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
+ HANDLE_PACKET_READ(ReadByte, Byte, Button);
+ HANDLE_PACKET_READ(ReadBEShort, short, TransactionID);
+ HANDLE_PACKET_READ(ReadByte, Byte, Mode);
+ cItem HeldItem;
+ int res = ParseItem(HeldItem);
+ if (res < 0)
+ {
+ return res;
+ }
+
+ // Convert Button, Mode, SlotNum and HeldItem into eClickAction:
+ eClickAction Action;
+ switch ((Mode << 8) | Button)
+ {
+ case 0x0000: Action = (SlotNum != -999) ? caLeftClick : caLeftClickOutside; break;
+ case 0x0001: Action = (SlotNum != -999) ? caRightClick : caRightClickOutside; break;
+ case 0x0100: Action = caShiftLeftClick; break;
+ case 0x0101: Action = caShiftRightClick; break;
+ case 0x0200: Action = caNumber1; break;
+ case 0x0201: Action = caNumber2; break;
+ case 0x0202: Action = caNumber3; break;
+ case 0x0203: Action = caNumber4; break;
+ case 0x0204: Action = caNumber5; break;
+ case 0x0205: Action = caNumber6; break;
+ case 0x0206: Action = caNumber7; break;
+ case 0x0207: Action = caNumber8; break;
+ case 0x0208: Action = caNumber9; break;
+ case 0x0300: Action = caMiddleClick; break;
+ case 0x0400: Action = (SlotNum == -999) ? caLeftClickOutsideHoldNothing : caDropKey; break;
+ case 0x0401: Action = (SlotNum == -999) ? caRightClickOutsideHoldNothing : caCtrlDropKey; break;
+ case 0x0500: Action = (SlotNum == -999) ? caLeftPaintBegin : caUnknown; break;
+ case 0x0501: Action = (SlotNum != -999) ? caLeftPaintProgress : caUnknown; break;
+ case 0x0502: Action = (SlotNum == -999) ? caLeftPaintEnd : caUnknown; break;
+ case 0x0504: Action = (SlotNum == -999) ? caRightPaintBegin : caUnknown; break;
+ case 0x0505: Action = (SlotNum != -999) ? caRightPaintProgress : caUnknown; break;
+ case 0x0506: Action = (SlotNum == -999) ? caRightPaintEnd : caUnknown; break;
+ case 0x0600: Action = caDblClick; break;
+ }
+
+ if (Action == caUnknown)
+ {
+ LOGWARNING("Received an unknown click action combination: Mode = %d, Button = %d, Slot = %d, HeldItem = %s. Ignoring packet.",
+ Mode, Button, SlotNum, ItemToFullString(HeldItem).c_str()
+ );
+ ASSERT(!"Unknown click action");
+ return PARSE_OK;
+ }
+
+ m_Client->HandleWindowClick(WindowID, SlotNum, Action, HeldItem);
+ return PARSE_OK;
+}
+
+
+
+
+
diff --git a/source/Protocol/Protocol15x.h b/source/Protocol/Protocol15x.h
index 73d73780d..3e1547df8 100644
--- a/source/Protocol/Protocol15x.h
+++ b/source/Protocol/Protocol15x.h
@@ -1,38 +1,38 @@
-
-// Protocol15x.h
-
-/*
-Declares the 1.5.x protocol classes:
- - cProtocol150
- - release 1.5 and 1.5.1 protocol (#60)
- - release 1.5.2 protocol (#61; no relevant changes found)
-*/
-
-
-
-
-
-#pragma once
-
-#include "Protocol14x.h"
-
-
-
-
-
-class cProtocol150 :
- public cProtocol146
-{
- typedef cProtocol146 super;
-
-public:
- cProtocol150(cClientHandle * a_Client);
-
- virtual void SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
-
- virtual int ParseWindowClick(void);
-} ;
-
-
-
-
+
+// Protocol15x.h
+
+/*
+Declares the 1.5.x protocol classes:
+ - cProtocol150
+ - release 1.5 and 1.5.1 protocol (#60)
+ - release 1.5.2 protocol (#61; no relevant changes found)
+*/
+
+
+
+
+
+#pragma once
+
+#include "Protocol14x.h"
+
+
+
+
+
+class cProtocol150 :
+ public cProtocol146
+{
+ typedef cProtocol146 super;
+
+public:
+ cProtocol150(cClientHandle * a_Client);
+
+ virtual void SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
+
+ virtual int ParseWindowClick(void);
+} ;
+
+
+
+
diff --git a/source/Protocol/Protocol16x.cpp b/source/Protocol/Protocol16x.cpp
index d06980228..4e8fd1887 100644
--- a/source/Protocol/Protocol16x.cpp
+++ b/source/Protocol/Protocol16x.cpp
@@ -1,245 +1,262 @@
-
-// Protocol16x.cpp
-
-/*
-Implements the 1.6.x protocol classes:
- - cProtocol161
- - release 1.6.1 protocol (#73)
- - cProtocol162
- - release 1.6.2 protocol (#74)
-(others may be added later in the future for the 1.6 release series)
-*/
-
-#include "Globals.h"
-#include "Protocol16x.h"
-#include "../ClientHandle.h"
-#include "../Entity.h"
-#include "../Player.h"
-
-
-
-
-
-#define HANDLE_PACKET_READ(Proc, Type, Var) \
- Type Var; \
- { \
- if (!m_ReceivedData.Proc(Var)) \
- { \
- m_ReceivedData.CheckValid(); \
- return PARSE_INCOMPLETE; \
- } \
- m_ReceivedData.CheckValid(); \
- }
-
-
-
-
-
-enum
-{
- PACKET_CHAT = 0x03,
- PACKET_UPDATE_HEALTH = 0x08,
- PACKET_STEER_VEHICLE = 0x1b,
- PACKET_ATTACH_ENTITY = 0x27,
- PACKET_ENTITY_PROPERTIES = 0x2c,
- PACKET_WINDOW_OPEN = 0x64,
- PACKET_PLAYER_ABILITIES = 0xca,
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cProtocol161:
-
-cProtocol161::cProtocol161(cClientHandle * a_Client) :
- super(a_Client)
-{
-}
-
-
-
-
-
-void cProtocol161::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ATTACH_ENTITY);
- WriteInt(a_Entity.GetUniqueID());
- WriteInt((a_Vehicle == NULL) ? -1 : a_Vehicle->GetUniqueID());
- WriteBool(false); // TODO: "Should use leash?" -> no
- Flush();
-}
-
-
-
-
-
-void cProtocol161::SendChat(const AString & a_Message)
-{
- super::SendChat(Printf("{\"text\":\"%s\"}", EscapeString(a_Message).c_str()));
-}
-
-
-
-
-void cProtocol161::SendGameMode(eGameMode a_GameMode)
-{
- super::SendGameMode(a_GameMode);
- SendPlayerMaxSpeed();
-}
-
-
-
-
-
-void cProtocol161::SendHealth(void)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_UPDATE_HEALTH);
- WriteFloat((float)m_Client->GetPlayer()->GetHealth());
- WriteShort(m_Client->GetPlayer()->GetFoodLevel());
- WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
- Flush();
-}
-
-
-
-
-
-void cProtocol161::SendPlayerMaxSpeed(void)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENTITY_PROPERTIES);
- WriteInt(m_Client->GetPlayer()->GetUniqueID());
- WriteInt(1);
- WriteString("generic.movementSpeed");
- WriteDouble(m_Client->GetPlayer()->GetMaxSpeed());
- Flush();
-}
-
-
-
-
-
-void cProtocol161::SendRespawn(void)
-{
- // Besides sending the respawn, we need to also send the player max speed, otherwise the client reverts to super-fast
- super::SendRespawn();
- SendPlayerMaxSpeed();
-}
-
-
-
-
-
-void cProtocol161::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
-{
- if (a_WindowType < 0)
- {
- // Do not send for inventory windows
- return;
- }
- cCSLock Lock(m_CSPacket);
- WriteByte (PACKET_WINDOW_OPEN);
- WriteByte (a_WindowID);
- WriteByte (a_WindowType);
- WriteString(a_WindowTitle);
- WriteByte (a_NumSlots);
- WriteByte (1); // Use title
- if (a_WindowType == 11) // horse / donkey
- {
- WriteInt(0); // Unknown value sent only when window type is 11 (horse / donkey)
- }
- Flush();
-}
-
-
-
-
-
-int cProtocol161::ParseEntityAction(void)
-{
- HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
- HANDLE_PACKET_READ(ReadChar, char, ActionID);
- HANDLE_PACKET_READ(ReadBEInt, int, UnknownHorseVal);
- m_Client->HandleEntityAction(EntityID, ActionID);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol161::ParsePlayerAbilities(void)
-{
- HANDLE_PACKET_READ(ReadByte, Byte, Flags);
- HANDLE_PACKET_READ(ReadBEFloat, float, FlyingSpeed);
- HANDLE_PACKET_READ(ReadBEFloat, float, WalkingSpeed);
- // TODO: m_Client->HandlePlayerAbilities(...);
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol161::ParseSteerVehicle(void)
-{
- HANDLE_PACKET_READ(ReadBEFloat, float, Sideways);
- HANDLE_PACKET_READ(ReadBEFloat, float, Forward);
- HANDLE_PACKET_READ(ReadBool, bool, Jump);
- HANDLE_PACKET_READ(ReadBool, bool, Unmount);
- // TODO: m_Client->HandleSteerVehicle(...);
- if (Unmount)
- {
- m_Client->HandleUnmount();
- }
- return PARSE_OK;
-}
-
-
-
-
-
-int cProtocol161::ParsePacket(unsigned char a_PacketType)
-{
- switch (a_PacketType)
- {
- case PACKET_STEER_VEHICLE: return ParseSteerVehicle();
- default: return super::ParsePacket(a_PacketType);
- }
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cProtocol162:
-
-cProtocol162::cProtocol162(cClientHandle * a_Client) :
- super(a_Client)
-{
-}
-
-
-
-
-
-void cProtocol162::SendPlayerMaxSpeed(void)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_ENTITY_PROPERTIES);
- WriteInt(m_Client->GetPlayer()->GetUniqueID());
- WriteInt(1);
- WriteString("generic.movementSpeed");
- WriteDouble(m_Client->GetPlayer()->GetMaxSpeed());
- WriteShort(0);
- Flush();
-}
-
-
-
-
+
+// Protocol16x.cpp
+
+/*
+Implements the 1.6.x protocol classes:
+ - cProtocol161
+ - release 1.6.1 protocol (#73)
+ - cProtocol162
+ - release 1.6.2 protocol (#74)
+(others may be added later in the future for the 1.6 release series)
+*/
+
+#include "Globals.h"
+#include "Protocol16x.h"
+#include "../ClientHandle.h"
+#include "../Entity.h"
+#include "../Player.h"
+
+
+
+
+
+#define HANDLE_PACKET_READ(Proc, Type, Var) \
+ Type Var; \
+ { \
+ if (!m_ReceivedData.Proc(Var)) \
+ { \
+ m_ReceivedData.CheckValid(); \
+ return PARSE_INCOMPLETE; \
+ } \
+ m_ReceivedData.CheckValid(); \
+ }
+
+
+
+
+
+enum
+{
+ PACKET_CHAT = 0x03,
+ PACKET_UPDATE_HEALTH = 0x08,
+ PACKET_STEER_VEHICLE = 0x1b,
+ PACKET_ATTACH_ENTITY = 0x27,
+ PACKET_ENTITY_PROPERTIES = 0x2c,
+ PACKET_WINDOW_OPEN = 0x64,
+ PACKET_TILE_EDITOR_OPEN = 0x85,
+ PACKET_PLAYER_ABILITIES = 0xca,
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cProtocol161:
+
+cProtocol161::cProtocol161(cClientHandle * a_Client) :
+ super(a_Client)
+{
+}
+
+
+
+
+
+void cProtocol161::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ATTACH_ENTITY);
+ WriteInt(a_Entity.GetUniqueID());
+ WriteInt((a_Vehicle == NULL) ? -1 : a_Vehicle->GetUniqueID());
+ WriteBool(false); // TODO: "Should use leash?" -> no
+ Flush();
+}
+
+
+
+
+
+void cProtocol161::SendChat(const AString & a_Message)
+{
+ super::SendChat(Printf("{\"text\":\"%s\"}", EscapeString(a_Message).c_str()));
+}
+
+
+
+
+
+void cProtocol161::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_TILE_EDITOR_OPEN);
+ WriteByte(0);
+ WriteInt(a_BlockX);
+ WriteInt(a_BlockY);
+ WriteInt(a_BlockZ);
+ Flush();
+}
+
+
+
+
+
+void cProtocol161::SendGameMode(eGameMode a_GameMode)
+{
+ super::SendGameMode(a_GameMode);
+ SendPlayerMaxSpeed();
+}
+
+
+
+
+
+void cProtocol161::SendHealth(void)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_UPDATE_HEALTH);
+ WriteFloat((float)m_Client->GetPlayer()->GetHealth());
+ WriteShort(m_Client->GetPlayer()->GetFoodLevel());
+ WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
+ Flush();
+}
+
+
+
+
+
+void cProtocol161::SendPlayerMaxSpeed(void)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ENTITY_PROPERTIES);
+ WriteInt(m_Client->GetPlayer()->GetUniqueID());
+ WriteInt(1);
+ WriteString("generic.movementSpeed");
+ WriteDouble(m_Client->GetPlayer()->GetMaxSpeed());
+ Flush();
+}
+
+
+
+
+
+void cProtocol161::SendRespawn(void)
+{
+ // Besides sending the respawn, we need to also send the player max speed, otherwise the client reverts to super-fast
+ super::SendRespawn();
+ SendPlayerMaxSpeed();
+}
+
+
+
+
+
+void cProtocol161::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
+{
+ if (a_WindowType < 0)
+ {
+ // Do not send for inventory windows
+ return;
+ }
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_WINDOW_OPEN);
+ WriteByte (a_WindowID);
+ WriteByte (a_WindowType);
+ WriteString(a_WindowTitle);
+ WriteByte (a_NumSlots);
+ WriteByte (1); // Use title
+ if (a_WindowType == 11) // horse / donkey
+ {
+ WriteInt(0); // Unknown value sent only when window type is 11 (horse / donkey)
+ }
+ Flush();
+}
+
+
+
+
+
+int cProtocol161::ParseEntityAction(void)
+{
+ HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
+ HANDLE_PACKET_READ(ReadChar, char, ActionID);
+ HANDLE_PACKET_READ(ReadBEInt, int, UnknownHorseVal);
+ m_Client->HandleEntityAction(EntityID, ActionID);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol161::ParsePlayerAbilities(void)
+{
+ HANDLE_PACKET_READ(ReadByte, Byte, Flags);
+ HANDLE_PACKET_READ(ReadBEFloat, float, FlyingSpeed);
+ HANDLE_PACKET_READ(ReadBEFloat, float, WalkingSpeed);
+ // TODO: m_Client->HandlePlayerAbilities(...);
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol161::ParseSteerVehicle(void)
+{
+ HANDLE_PACKET_READ(ReadBEFloat, float, Sideways);
+ HANDLE_PACKET_READ(ReadBEFloat, float, Forward);
+ HANDLE_PACKET_READ(ReadBool, bool, Jump);
+ HANDLE_PACKET_READ(ReadBool, bool, Unmount);
+ // TODO: m_Client->HandleSteerVehicle(...);
+ if (Unmount)
+ {
+ m_Client->HandleUnmount();
+ }
+ return PARSE_OK;
+}
+
+
+
+
+
+int cProtocol161::ParsePacket(unsigned char a_PacketType)
+{
+ switch (a_PacketType)
+ {
+ case PACKET_STEER_VEHICLE: return ParseSteerVehicle();
+ default: return super::ParsePacket(a_PacketType);
+ }
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cProtocol162:
+
+cProtocol162::cProtocol162(cClientHandle * a_Client) :
+ super(a_Client)
+{
+}
+
+
+
+
+
+void cProtocol162::SendPlayerMaxSpeed(void)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_ENTITY_PROPERTIES);
+ WriteInt(m_Client->GetPlayer()->GetUniqueID());
+ WriteInt(1);
+ WriteString("generic.movementSpeed");
+ WriteDouble(m_Client->GetPlayer()->GetMaxSpeed());
+ WriteShort(0);
+ Flush();
+}
+
+
+
+
diff --git a/source/Protocol/Protocol16x.h b/source/Protocol/Protocol16x.h
index e012585d1..077c7958b 100644
--- a/source/Protocol/Protocol16x.h
+++ b/source/Protocol/Protocol16x.h
@@ -1,73 +1,74 @@
-
-// Protocol16x.h
-
-/*
-Declares the 1.6.x protocol classes:
- - cProtocol161
- - release 1.6.1 protocol (#73)
- - cProtocol162
- - release 1.6.2 protocol (#74)
-(others may be added later in the future for the 1.6 release series)
-*/
-
-
-
-
-
-#pragma once
-
-#include "Protocol15x.h"
-
-
-
-
-
-class cProtocol161 :
- public cProtocol150
-{
- typedef cProtocol150 super;
-
-public:
- cProtocol161(cClientHandle * a_Client);
-
-protected:
-
- // cProtocol150 overrides:
- virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle) override;
- virtual void SendChat (const AString & a_Message) override;
- virtual void SendGameMode (eGameMode a_GameMode) override;
- virtual void SendHealth (void) override;
- virtual void SendPlayerMaxSpeed(void) override;
- virtual void SendRespawn (void) override;
- virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
-
- virtual int ParseEntityAction (void) override;
- virtual int ParsePlayerAbilities(void) override;
-
- // New packets:
- virtual int ParseSteerVehicle(void);
-
- // Enable new packets' handling
- virtual int ParsePacket(unsigned char a_PacketType) override;
-} ;
-
-
-
-
-
-class cProtocol162 :
- public cProtocol161
-{
- typedef cProtocol161 super;
-
-public:
- cProtocol162(cClientHandle * a_Client);
-
-protected:
- // cProtocol161 overrides:
- virtual void SendPlayerMaxSpeed(void) override;
-} ;
-
-
-
-
+
+// Protocol16x.h
+
+/*
+Declares the 1.6.x protocol classes:
+ - cProtocol161
+ - release 1.6.1 protocol (#73)
+ - cProtocol162
+ - release 1.6.2 protocol (#74)
+(others may be added later in the future for the 1.6 release series)
+*/
+
+
+
+
+
+#pragma once
+
+#include "Protocol15x.h"
+
+
+
+
+
+class cProtocol161 :
+ public cProtocol150
+{
+ typedef cProtocol150 super;
+
+public:
+ cProtocol161(cClientHandle * a_Client);
+
+protected:
+
+ // cProtocol150 overrides:
+ virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle) override;
+ virtual void SendChat (const AString & a_Message) 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+)
+ virtual void SendGameMode (eGameMode a_GameMode) override;
+ virtual void SendHealth (void) override;
+ virtual void SendPlayerMaxSpeed(void) override;
+ virtual void SendRespawn (void) override;
+ virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
+
+ virtual int ParseEntityAction (void) override;
+ virtual int ParsePlayerAbilities(void) override;
+
+ // New packets:
+ virtual int ParseSteerVehicle(void);
+
+ // Enable new packets' handling
+ virtual int ParsePacket(unsigned char a_PacketType) override;
+} ;
+
+
+
+
+
+class cProtocol162 :
+ public cProtocol161
+{
+ typedef cProtocol161 super;
+
+public:
+ cProtocol162(cClientHandle * a_Client);
+
+protected:
+ // cProtocol161 overrides:
+ virtual void SendPlayerMaxSpeed(void) override;
+} ;
+
+
+
+
diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp
index ec10eeb12..3cff9789e 100644
--- a/source/Protocol/ProtocolRecognizer.cpp
+++ b/source/Protocol/ProtocolRecognizer.cpp
@@ -1,771 +1,781 @@
-
-// ProtocolRecognizer.cpp
-
-// Implements the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple
-// protocol versions and redirects everything to them
-
-#include "Globals.h"
-
-#include "ProtocolRecognizer.h"
-#include "Protocol125.h"
-#include "Protocol132.h"
-#include "Protocol14x.h"
-#include "Protocol15x.h"
-#include "Protocol16x.h"
-#include "../ClientHandle.h"
-#include "../Root.h"
-#include "../World.h"
-#include "../ChatColor.h"
-
-
-
-
-
-cProtocolRecognizer::cProtocolRecognizer(cClientHandle * a_Client) :
- super(a_Client),
- m_Protocol(NULL),
- m_Buffer(512)
-{
-}
-
-
-
-
-
-cProtocolRecognizer::~cProtocolRecognizer()
-{
- delete m_Protocol;
-}
-
-
-
-
-
-AString cProtocolRecognizer::GetVersionTextFromInt(int a_ProtocolVersion)
-{
- switch (a_ProtocolVersion)
- {
- case PROTO_VERSION_1_2_5: return "1.2.5";
- case PROTO_VERSION_1_3_2: return "1.3.2";
- case PROTO_VERSION_1_4_2: return "1.4.2";
- case PROTO_VERSION_1_4_4: return "1.4.4";
- case PROTO_VERSION_1_4_6: return "1.4.6";
- case PROTO_VERSION_1_5_0: return "1.5";
- case PROTO_VERSION_1_5_2: return "1.5.2";
- case PROTO_VERSION_1_6_1: return "1.6.1";
- case PROTO_VERSION_1_6_2: return "1.6.2";
- }
- ASSERT(!"Unknown protocol version");
- return Printf("Unknown protocol (%d)", a_ProtocolVersion);
-}
-
-
-
-
-
-void cProtocolRecognizer::DataReceived(const char * a_Data, int a_Size)
-{
- if (m_Protocol == NULL)
- {
- if (!m_Buffer.Write(a_Data, a_Size))
- {
- m_Client->Kick("Unsupported protocol version");
- return;
- }
-
- if (!TryRecognizeProtocol())
- {
- return;
- }
-
- // The protocol has just been recognized, dump the whole m_Buffer contents into it for parsing:
- AString Dump;
- m_Buffer.ResetRead();
- m_Buffer.ReadAll(Dump);
- m_Protocol->DataReceived(Dump.data(), Dump.size());
- }
- else
- {
- m_Protocol->DataReceived(a_Data, a_Size);
- }
-}
-
-
-
-
-
-void cProtocolRecognizer::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendAttachEntity(a_Entity, a_Vehicle);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendBlockBreakAnim(a_entityID, a_BlockX, a_BlockY, a_BlockZ, stage);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendBlockChange(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendBlockChanges(a_ChunkX, a_ChunkZ, a_Changes);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendChat(const AString & a_Message)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendChat(a_Message);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendChunkData(a_ChunkX, a_ChunkZ, a_Serializer);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendCollectPickup(a_Pickup, a_Player);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendDestroyEntity(const cEntity & a_Entity)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendDestroyEntity(a_Entity);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendDisconnect(const AString & a_Reason)
-{
- if (m_Protocol != NULL)
- {
- m_Protocol->SendDisconnect(a_Reason);
- }
- else
- {
- // This is used when the client sends a server-ping, respond with the default packet:
- WriteByte ((char)0xff); // PACKET_DISCONNECT
- WriteString(a_Reason);
- }
-}
-
-
-
-
-void cProtocolRecognizer::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendEntityHeadLook(const cEntity & a_Entity)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityHeadLook(a_Entity);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendEntityLook(const cEntity & a_Entity)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityLook(a_Entity);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendEntityMetadata(const cEntity & a_Entity)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityMetadata(a_Entity);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendEntityProperties(const cEntity & a_Entity)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityProperties(a_Entity);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityRelMove(a_Entity, a_RelX, a_RelY, a_RelZ);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendEntityStatus(const cEntity & a_Entity, char a_Status)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityStatus(a_Entity, a_Status);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendEntityVelocity(const cEntity & a_Entity)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendEntityVelocity(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);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendGameMode(eGameMode a_GameMode)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendGameMode(a_GameMode);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendHealth(void)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendHealth();
-}
-
-
-
-
-
-void cProtocolRecognizer::SendInventoryProgress(char a_WindowID, short a_Progressbar, short a_Value)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendInventoryProgress(a_WindowID, a_Progressbar, a_Value);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendInventorySlot(a_WindowID, a_SlotNum, a_Item);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendKeepAlive(int a_PingID)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendKeepAlive(a_PingID);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendLogin(a_Player, a_World);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendPickupSpawn(const cPickup & a_Pickup)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendPickupSpawn(a_Pickup);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerAnimation(a_Player, a_Animation);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerListItem(a_Player, a_IsOnline);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendPlayerMaxSpeed(void)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerMaxSpeed();
-}
-
-
-
-
-
-void cProtocolRecognizer::SendPlayerMoveLook(void)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerMoveLook();
-}
-
-
-
-
-
-void cProtocolRecognizer::SendPlayerPosition(void)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerPosition();
-}
-
-
-
-
-
-void cProtocolRecognizer::SendPlayerSpawn(const cPlayer & a_Player)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendPlayerSpawn(a_Player);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendRespawn(void)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendRespawn();
-}
-
-
-
-
-
-void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, 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);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendSpawnFallingBlock(a_FallingBlock);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendSpawnMob(const cMonster & a_Mob)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendSpawnMob(a_Mob);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendSpawnObject(a_Entity, a_ObjectType, a_ObjectData, a_Yaw, a_Pitch);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendTeleportEntity(const cEntity & a_Entity)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendTeleportEntity(a_Entity);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendThunderbolt(a_BlockX, a_BlockY, a_BlockZ);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendTimeUpdate(a_WorldAge, a_TimeOfDay);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendUnloadChunk(a_ChunkX, a_ChunkZ);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendUpdateSign(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4);
-}
-
-
-
-
-
-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);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendWeather(eWeather a_Weather)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendWeather(a_Weather);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendWholeInventory(const cInventory & a_Inventory)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendWholeInventory(a_Inventory);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendWholeInventory(const cWindow & a_Window)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendWholeInventory(a_Window);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendWindowClose(const cWindow & a_Window)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendWindowClose(a_Window);
-}
-
-
-
-
-
-void cProtocolRecognizer::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
-{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendWindowOpen(a_WindowID, a_WindowType, a_WindowTitle, a_NumSlots);
-}
-
-
-
-
-
-AString cProtocolRecognizer::GetAuthServerID(void)
-{
- ASSERT(m_Protocol != NULL);
- return m_Protocol->GetAuthServerID();
-}
-
-
-
-
-
-void cProtocolRecognizer::SendData(const char * a_Data, int a_Size)
-{
- // This is used only when handling the server ping
- m_Client->SendData(a_Data, a_Size);
-}
-
-
-
-
-
-bool cProtocolRecognizer::TryRecognizeProtocol(void)
-{
- // 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:
- unsigned char PacketType;
- if (!m_Buffer.ReadByte(PacketType))
- {
- return false;
- }
- switch (PacketType)
- {
- case 0x02: break; // Handshake, continue recognizing
- case 0xfe: HandleServerPing(); return false;
- default: return false;
- }
-
- // 1.3.2 starts with 0x02 0x39 <name-length-short>
- // 1.2.5 starts with 0x02 <name-length-short> and name is expected to less than 0x3900 long :)
- char ch;
- if (!m_Buffer.ReadChar(ch))
- {
- return false;
- }
- switch (ch)
- {
- case PROTO_VERSION_1_3_2:
- {
- m_Protocol = new cProtocol132(m_Client);
- return true;
- }
- case PROTO_VERSION_1_4_2:
- case PROTO_VERSION_1_4_4:
- {
- m_Protocol = new cProtocol142(m_Client);
- return true;
- }
- case PROTO_VERSION_1_4_6:
- {
- m_Protocol = new cProtocol146(m_Client);
- return true;
- }
- case PROTO_VERSION_1_5_0:
- case PROTO_VERSION_1_5_2:
- {
- m_Protocol = new cProtocol150(m_Client);
- return true;
- }
- case PROTO_VERSION_1_6_1:
- {
- m_Protocol = new cProtocol161(m_Client);
- return true;
- }
- case PROTO_VERSION_1_6_2:
- {
- m_Protocol = new cProtocol162(m_Client);
- return true;
- }
- }
- m_Protocol = new cProtocol125(m_Client);
- return true;
-}
-
-
-
-
-
-void cProtocolRecognizer::HandleServerPing(void)
-{
- AString Reply;
- switch (cRoot::Get()->m_PrimaryServerVersion)
- {
- case PROTO_VERSION_1_2_5:
- 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",
- cRoot::Get()->GetDefaultWorld()->GetDescription().c_str(),
- cChatColor::Delimiter.c_str(),
- cRoot::Get()->GetDefaultWorld()->GetNumPlayers(),
- cChatColor::Delimiter.c_str(),
- cRoot::Get()->GetDefaultWorld()->GetMaxPlayers()
- );
- break;
- }
-
- case PROTO_VERSION_1_4_2:
- case PROTO_VERSION_1_4_4:
- case PROTO_VERSION_1_4_6:
- case PROTO_VERSION_1_5_0:
- case PROTO_VERSION_1_5_2:
- case PROTO_VERSION_1_6_1:
- case PROTO_VERSION_1_6_2:
- {
- // The server list ping now has 1 more byte of "magic". Mojang just loves to complicate stuff.
- // http://wiki.vg/wiki/index.php?title=Protocol&oldid=3101#Server_List_Ping_.280xFE.29
- // _X 2012_10_31: I know that this needn't eat the byte, since it still may be in transit.
- // Who cares? We're disconnecting anyway.
- if (m_Buffer.CanReadBytes(1))
- {
- byte val;
- m_Buffer.ReadByte(val);
- ASSERT(val == 0x01);
- }
-
- // http://wiki.vg/wiki/index.php?title=Server_List_Ping&oldid=3100
- AString NumPlayers;
- Printf(NumPlayers, "%d", cRoot::Get()->GetDefaultWorld()->GetNumPlayers());
- AString MaxPlayers;
- Printf(MaxPlayers, "%d", cRoot::Get()->GetDefaultWorld()->GetMaxPlayers());
-
- AString ProtocolVersionNum;
- Printf(ProtocolVersionNum, "%d", cRoot::Get()->m_PrimaryServerVersion);
- AString ProtocolVersionTxt(GetVersionTextFromInt(cRoot::Get()->m_PrimaryServerVersion));
-
- // Cannot use Printf() because of in-string NUL bytes.
- Reply = cChatColor::Delimiter;
- Reply.append("1");
- Reply.push_back(0);
- Reply.append(ProtocolVersionNum);
- Reply.push_back(0);
- Reply.append(ProtocolVersionTxt);
- Reply.push_back(0);
- Reply.append(cRoot::Get()->GetDefaultWorld()->GetDescription());
- Reply.push_back(0);
- Reply.append(NumPlayers);
- Reply.push_back(0);
- Reply.append(MaxPlayers);
- break;
- }
- } // switch (m_PrimaryServerVersion)
- m_Client->Kick(Reply);
-}
-
-
-
-
+
+// ProtocolRecognizer.cpp
+
+// Implements the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple
+// protocol versions and redirects everything to them
+
+#include "Globals.h"
+
+#include "ProtocolRecognizer.h"
+#include "Protocol125.h"
+#include "Protocol132.h"
+#include "Protocol14x.h"
+#include "Protocol15x.h"
+#include "Protocol16x.h"
+#include "../ClientHandle.h"
+#include "../Root.h"
+#include "../World.h"
+#include "../ChatColor.h"
+
+
+
+
+
+cProtocolRecognizer::cProtocolRecognizer(cClientHandle * a_Client) :
+ super(a_Client),
+ m_Protocol(NULL),
+ m_Buffer(512)
+{
+}
+
+
+
+
+
+cProtocolRecognizer::~cProtocolRecognizer()
+{
+ delete m_Protocol;
+}
+
+
+
+
+
+AString cProtocolRecognizer::GetVersionTextFromInt(int a_ProtocolVersion)
+{
+ switch (a_ProtocolVersion)
+ {
+ case PROTO_VERSION_1_2_5: return "1.2.5";
+ case PROTO_VERSION_1_3_2: return "1.3.2";
+ case PROTO_VERSION_1_4_2: return "1.4.2";
+ case PROTO_VERSION_1_4_4: return "1.4.4";
+ case PROTO_VERSION_1_4_6: return "1.4.6";
+ case PROTO_VERSION_1_5_0: return "1.5";
+ case PROTO_VERSION_1_5_2: return "1.5.2";
+ case PROTO_VERSION_1_6_1: return "1.6.1";
+ case PROTO_VERSION_1_6_2: return "1.6.2";
+ }
+ ASSERT(!"Unknown protocol version");
+ return Printf("Unknown protocol (%d)", a_ProtocolVersion);
+}
+
+
+
+
+
+void cProtocolRecognizer::DataReceived(const char * a_Data, int a_Size)
+{
+ if (m_Protocol == NULL)
+ {
+ if (!m_Buffer.Write(a_Data, a_Size))
+ {
+ m_Client->Kick("Unsupported protocol version");
+ return;
+ }
+
+ if (!TryRecognizeProtocol())
+ {
+ return;
+ }
+
+ // The protocol has just been recognized, dump the whole m_Buffer contents into it for parsing:
+ AString Dump;
+ m_Buffer.ResetRead();
+ m_Buffer.ReadAll(Dump);
+ m_Protocol->DataReceived(Dump.data(), Dump.size());
+ }
+ else
+ {
+ m_Protocol->DataReceived(a_Data, a_Size);
+ }
+}
+
+
+
+
+
+void cProtocolRecognizer::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendAttachEntity(a_Entity, a_Vehicle);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendBlockBreakAnim(a_entityID, a_BlockX, a_BlockY, a_BlockZ, stage);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendBlockChange(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendBlockChanges(a_ChunkX, a_ChunkZ, a_Changes);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendChat(const AString & a_Message)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendChat(a_Message);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendChunkData(a_ChunkX, a_ChunkZ, a_Serializer);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendCollectPickup(a_Pickup, a_Player);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendDestroyEntity(const cEntity & a_Entity)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendDestroyEntity(a_Entity);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendDisconnect(const AString & a_Reason)
+{
+ if (m_Protocol != NULL)
+ {
+ m_Protocol->SendDisconnect(a_Reason);
+ }
+ else
+ {
+ // This is used when the client sends a server-ping, respond with the default packet:
+ WriteByte ((char)0xff); // PACKET_DISCONNECT
+ WriteString(a_Reason);
+ }
+}
+
+
+
+
+void cProtocolRecognizer::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityHeadLook(const cEntity & a_Entity)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityHeadLook(a_Entity);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityLook(const cEntity & a_Entity)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityLook(a_Entity);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityMetadata(const cEntity & a_Entity)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityMetadata(a_Entity);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityProperties(const cEntity & a_Entity)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityProperties(a_Entity);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityRelMove(a_Entity, a_RelX, a_RelY, a_RelZ);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityRelMoveLook(a_Entity, a_RelX, a_RelY, a_RelZ);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityStatus(const cEntity & a_Entity, char a_Status)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityStatus(a_Entity, a_Status);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendEntityVelocity(const cEntity & a_Entity)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendEntityVelocity(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);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendGameMode(eGameMode a_GameMode)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendGameMode(a_GameMode);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendHealth(void)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendHealth();
+}
+
+
+
+
+
+void cProtocolRecognizer::SendInventoryProgress(char a_WindowID, short a_Progressbar, short a_Value)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendInventoryProgress(a_WindowID, a_Progressbar, a_Value);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendInventorySlot(a_WindowID, a_SlotNum, a_Item);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendKeepAlive(int a_PingID)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendKeepAlive(a_PingID);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendLogin(a_Player, a_World);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendPickupSpawn(const cPickup & a_Pickup)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendPickupSpawn(a_Pickup);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendPlayerAnimation(a_Player, a_Animation);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendPlayerListItem(a_Player, a_IsOnline);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendPlayerMaxSpeed(void)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendPlayerMaxSpeed();
+}
+
+
+
+
+
+void cProtocolRecognizer::SendPlayerMoveLook(void)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendPlayerMoveLook();
+}
+
+
+
+
+
+void cProtocolRecognizer::SendPlayerPosition(void)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendPlayerPosition();
+}
+
+
+
+
+
+void cProtocolRecognizer::SendPlayerSpawn(const cPlayer & a_Player)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendPlayerSpawn(a_Player);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendRespawn(void)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendRespawn();
+}
+
+
+
+
+
+void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, 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);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendSpawnFallingBlock(a_FallingBlock);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendSpawnMob(const cMonster & a_Mob)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendSpawnMob(a_Mob);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendSpawnObject(a_Entity, a_ObjectType, a_ObjectData, a_Yaw, a_Pitch);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendTeleportEntity(const cEntity & a_Entity)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendTeleportEntity(a_Entity);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendThunderbolt(a_BlockX, a_BlockY, a_BlockZ);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendTimeUpdate(a_WorldAge, a_TimeOfDay);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendUnloadChunk(a_ChunkX, a_ChunkZ);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendUpdateSign(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4);
+}
+
+
+
+
+
+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);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendWeather(eWeather a_Weather)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendWeather(a_Weather);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendWholeInventory(const cInventory & a_Inventory)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendWholeInventory(a_Inventory);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendWholeInventory(const cWindow & a_Window)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendWholeInventory(a_Window);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendWindowClose(const cWindow & a_Window)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendWindowClose(a_Window);
+}
+
+
+
+
+
+void cProtocolRecognizer::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendWindowOpen(a_WindowID, a_WindowType, a_WindowTitle, a_NumSlots);
+}
+
+
+
+
+
+AString cProtocolRecognizer::GetAuthServerID(void)
+{
+ ASSERT(m_Protocol != NULL);
+ return m_Protocol->GetAuthServerID();
+}
+
+
+
+
+
+void cProtocolRecognizer::SendData(const char * a_Data, int a_Size)
+{
+ // This is used only when handling the server ping
+ m_Client->SendData(a_Data, a_Size);
+}
+
+
+
+
+
+bool cProtocolRecognizer::TryRecognizeProtocol(void)
+{
+ // 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:
+ unsigned char PacketType;
+ if (!m_Buffer.ReadByte(PacketType))
+ {
+ return false;
+ }
+ switch (PacketType)
+ {
+ case 0x02: break; // Handshake, continue recognizing
+ case 0xfe: HandleServerPing(); return false;
+ default: return false;
+ }
+
+ // 1.3.2 starts with 0x02 0x39 <name-length-short>
+ // 1.2.5 starts with 0x02 <name-length-short> and name is expected to less than 0x3900 long :)
+ char ch;
+ if (!m_Buffer.ReadChar(ch))
+ {
+ return false;
+ }
+ switch (ch)
+ {
+ case PROTO_VERSION_1_3_2:
+ {
+ m_Protocol = new cProtocol132(m_Client);
+ return true;
+ }
+ case PROTO_VERSION_1_4_2:
+ case PROTO_VERSION_1_4_4:
+ {
+ m_Protocol = new cProtocol142(m_Client);
+ return true;
+ }
+ case PROTO_VERSION_1_4_6:
+ {
+ m_Protocol = new cProtocol146(m_Client);
+ return true;
+ }
+ case PROTO_VERSION_1_5_0:
+ case PROTO_VERSION_1_5_2:
+ {
+ m_Protocol = new cProtocol150(m_Client);
+ return true;
+ }
+ case PROTO_VERSION_1_6_1:
+ {
+ m_Protocol = new cProtocol161(m_Client);
+ return true;
+ }
+ case PROTO_VERSION_1_6_2:
+ {
+ m_Protocol = new cProtocol162(m_Client);
+ return true;
+ }
+ }
+ m_Protocol = new cProtocol125(m_Client);
+ return true;
+}
+
+
+
+
+
+void cProtocolRecognizer::HandleServerPing(void)
+{
+ AString Reply;
+ switch (cRoot::Get()->m_PrimaryServerVersion)
+ {
+ case PROTO_VERSION_1_2_5:
+ 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",
+ cRoot::Get()->GetDefaultWorld()->GetDescription().c_str(),
+ cChatColor::Delimiter.c_str(),
+ cRoot::Get()->GetDefaultWorld()->GetNumPlayers(),
+ cChatColor::Delimiter.c_str(),
+ cRoot::Get()->GetDefaultWorld()->GetMaxPlayers()
+ );
+ break;
+ }
+
+ case PROTO_VERSION_1_4_2:
+ case PROTO_VERSION_1_4_4:
+ case PROTO_VERSION_1_4_6:
+ case PROTO_VERSION_1_5_0:
+ case PROTO_VERSION_1_5_2:
+ case PROTO_VERSION_1_6_1:
+ case PROTO_VERSION_1_6_2:
+ {
+ // The server list ping now has 1 more byte of "magic". Mojang just loves to complicate stuff.
+ // http://wiki.vg/wiki/index.php?title=Protocol&oldid=3101#Server_List_Ping_.280xFE.29
+ // _X 2012_10_31: I know that this needn't eat the byte, since it still may be in transit.
+ // Who cares? We're disconnecting anyway.
+ if (m_Buffer.CanReadBytes(1))
+ {
+ byte val;
+ m_Buffer.ReadByte(val);
+ ASSERT(val == 0x01);
+ }
+
+ // http://wiki.vg/wiki/index.php?title=Server_List_Ping&oldid=3100
+ AString NumPlayers;
+ Printf(NumPlayers, "%d", cRoot::Get()->GetDefaultWorld()->GetNumPlayers());
+ AString MaxPlayers;
+ Printf(MaxPlayers, "%d", cRoot::Get()->GetDefaultWorld()->GetMaxPlayers());
+
+ AString ProtocolVersionNum;
+ Printf(ProtocolVersionNum, "%d", cRoot::Get()->m_PrimaryServerVersion);
+ AString ProtocolVersionTxt(GetVersionTextFromInt(cRoot::Get()->m_PrimaryServerVersion));
+
+ // Cannot use Printf() because of in-string NUL bytes.
+ Reply = cChatColor::Delimiter;
+ Reply.append("1");
+ Reply.push_back(0);
+ Reply.append(ProtocolVersionNum);
+ Reply.push_back(0);
+ Reply.append(ProtocolVersionTxt);
+ Reply.push_back(0);
+ Reply.append(cRoot::Get()->GetDefaultWorld()->GetDescription());
+ Reply.push_back(0);
+ Reply.append(NumPlayers);
+ Reply.push_back(0);
+ Reply.append(MaxPlayers);
+ break;
+ }
+ } // switch (m_PrimaryServerVersion)
+ m_Client->Kick(Reply);
+}
+
+
+
+
diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h
index 96d03082d..1256f38e0 100644
--- a/source/Protocol/ProtocolRecognizer.h
+++ b/source/Protocol/ProtocolRecognizer.h
@@ -1,130 +1,131 @@
-
-// ProtocolRecognizer.h
-
-// Interfaces to the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple
-// protocol versions and redirects everything to them
-
-
-
-
-
-#pragma once
-
-#include "Protocol.h"
-#include "../ByteBuffer.h"
-
-
-
-
-
-// Adjust these if a new protocol is added or an old one is removed:
-#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2"
-#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49, 51, 60, 61, 73, 74"
-
-
-
-
-
-class cProtocolRecognizer :
- public cProtocol
-{
- typedef cProtocol super;
-
-public:
- enum
- {
- PROTO_VERSION_1_2_5 = 29,
- PROTO_VERSION_1_3_2 = 39,
- PROTO_VERSION_1_4_2 = 47,
- PROTO_VERSION_1_4_4 = 49,
- PROTO_VERSION_1_4_6 = 51,
- PROTO_VERSION_1_5_0 = 60,
- PROTO_VERSION_1_5_2 = 61,
- PROTO_VERSION_1_6_1 = 73,
- PROTO_VERSION_1_6_2 = 74,
-
- PROTO_VERSION_NEXT,
- PROTO_VERSION_LATEST = PROTO_VERSION_NEXT - 1, ///< Automatically assigned to the last protocol version, this serves as the default for PrimaryServerVersion
- } ;
-
- cProtocolRecognizer(cClientHandle * a_Client);
- virtual ~cProtocolRecognizer();
-
- /// Translates protocol version number into protocol version text: 49 -> "1.4.4"
- static AString GetVersionTextFromInt(int a_ProtocolVersion);
-
- /// Called when client sends some data:
- virtual void DataReceived(const char * a_Data, int a_Size) override;
-
- /// Sending stuff to clients (alphabetically sorted):
- virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle) override;
- virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
- 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 SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
- virtual void SendChat (const AString & 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 SendDestroyEntity (const cEntity & a_Entity) override;
- virtual void SendDisconnect (const AString & a_Reason) override;
- virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
- virtual void SendEntityHeadLook (const cEntity & a_Entity) override;
- virtual void SendEntityLook (const cEntity & a_Entity) override;
- virtual void SendEntityMetadata (const cEntity & a_Entity) override;
- virtual void SendEntityProperties (const cEntity & a_Entity) override;
- virtual void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
- virtual void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
- virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
- virtual void SendEntityVelocity (const cEntity & a_Entity) override;
- virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override;
- virtual void SendGameMode (eGameMode a_GameMode) override;
- virtual void SendHealth (void) override;
- virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
- virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override;
- virtual void SendKeepAlive (int a_PingID) override;
- virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
- virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
- virtual void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation) override;
- virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
- virtual void SendPlayerMaxSpeed (void) override;
- virtual void SendPlayerMoveLook (void) override;
- virtual void SendPlayerPosition (void) override;
- virtual void SendPlayerSpawn (const cPlayer & a_Player) 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;
- 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) 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 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 SendWeather (eWeather a_Weather) override;
- virtual void SendWholeInventory (const cInventory & a_Inventory) override;
- virtual void SendWholeInventory (const cWindow & a_Window) override;
- virtual void SendWindowClose (const cWindow & a_Window) override;
- virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
-
- virtual AString GetAuthServerID(void) override;
-
- virtual void SendData(const char * a_Data, int a_Size) override;
-
-protected:
- 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);
-
- /// Called when the recognizer gets a server ping packet; responds with server stats and destroys the client
- void HandleServerPing(void);
-} ;
-
-
-
-
-
+
+// ProtocolRecognizer.h
+
+// Interfaces to the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple
+// protocol versions and redirects everything to them
+
+
+
+
+
+#pragma once
+
+#include "Protocol.h"
+#include "../ByteBuffer.h"
+
+
+
+
+
+// Adjust these if a new protocol is added or an old one is removed:
+#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2"
+#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49, 51, 60, 61, 73, 74"
+
+
+
+
+
+class cProtocolRecognizer :
+ public cProtocol
+{
+ typedef cProtocol super;
+
+public:
+ enum
+ {
+ PROTO_VERSION_1_2_5 = 29,
+ PROTO_VERSION_1_3_2 = 39,
+ PROTO_VERSION_1_4_2 = 47,
+ PROTO_VERSION_1_4_4 = 49,
+ PROTO_VERSION_1_4_6 = 51,
+ PROTO_VERSION_1_5_0 = 60,
+ PROTO_VERSION_1_5_2 = 61,
+ PROTO_VERSION_1_6_1 = 73,
+ PROTO_VERSION_1_6_2 = 74,
+
+ PROTO_VERSION_NEXT,
+ PROTO_VERSION_LATEST = PROTO_VERSION_NEXT - 1, ///< Automatically assigned to the last protocol version, this serves as the default for PrimaryServerVersion
+ } ;
+
+ cProtocolRecognizer(cClientHandle * a_Client);
+ virtual ~cProtocolRecognizer();
+
+ /// Translates protocol version number into protocol version text: 49 -> "1.4.4"
+ static AString GetVersionTextFromInt(int a_ProtocolVersion);
+
+ /// Called when client sends some data:
+ virtual void DataReceived(const char * a_Data, int a_Size) override;
+
+ /// Sending stuff to clients (alphabetically sorted):
+ virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle) override;
+ virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
+ 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 SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
+ virtual void SendChat (const AString & 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 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+)
+ virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
+ virtual void SendEntityHeadLook (const cEntity & a_Entity) override;
+ virtual void SendEntityLook (const cEntity & a_Entity) override;
+ virtual void SendEntityMetadata (const cEntity & a_Entity) override;
+ virtual void SendEntityProperties (const cEntity & a_Entity) override;
+ virtual void SendEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
+ virtual void SendEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
+ virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
+ virtual void SendEntityVelocity (const cEntity & a_Entity) override;
+ virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override;
+ virtual void SendGameMode (eGameMode a_GameMode) override;
+ virtual void SendHealth (void) override;
+ virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
+ virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override;
+ virtual void SendKeepAlive (int a_PingID) override;
+ virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
+ virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
+ virtual void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation) override;
+ virtual void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline) override;
+ virtual void SendPlayerMaxSpeed (void) override;
+ virtual void SendPlayerMoveLook (void) override;
+ virtual void SendPlayerPosition (void) override;
+ virtual void SendPlayerSpawn (const cPlayer & a_Player) 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;
+ 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) 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 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 SendWeather (eWeather a_Weather) override;
+ virtual void SendWholeInventory (const cInventory & a_Inventory) override;
+ virtual void SendWholeInventory (const cWindow & a_Window) override;
+ virtual void SendWindowClose (const cWindow & a_Window) override;
+ virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
+
+ virtual AString GetAuthServerID(void) override;
+
+ virtual void SendData(const char * a_Data, int a_Size) override;
+
+protected:
+ 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);
+
+ /// Called when the recognizer gets a server ping packet; responds with server stats and destroys the client
+ void HandleServerPing(void);
+} ;
+
+
+
+
+
diff --git a/source/RCONServer.cpp b/source/RCONServer.cpp
index cf6ed8b0c..04c06c887 100644
--- a/source/RCONServer.cpp
+++ b/source/RCONServer.cpp
@@ -1,332 +1,332 @@
-
-// RCONServer.cpp
-
-// Implements the cRCONServer class representing the RCON server
-
-#include "Globals.h"
-#include "../iniFile/iniFile.h"
-#include "RCONServer.h"
-#include "Server.h"
-#include "Root.h"
-#include "CommandOutput.h"
-
-
-
-
-
-// Disable MSVC warnings:
-#if defined(_MSC_VER)
- #pragma warning(push)
- #pragma warning(disable:4355) // 'this' : used in base member initializer list
-#endif
-
-
-
-
-
-enum
-{
- // Client -> Server:
- RCON_PACKET_COMMAND = 2,
- RCON_PACKET_LOGIN = 3,
-
- // Server -> Client:
- RCON_PACKET_RESPONSE = 2,
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cRCONCommandOutput:
-
-class cRCONCommandOutput :
- public cCommandOutputCallback
-{
-public:
- cRCONCommandOutput(cRCONServer::cConnection & a_Connection, int a_RequestID) :
- m_Connection(a_Connection),
- m_RequestID(a_RequestID)
- {
- }
-
- // cCommandOutputCallback overrides:
- virtual void Out(const AString & a_Text) override
- {
- m_Buffer.append(a_Text);
- }
-
- virtual void Finished(void) override
- {
- m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, m_Buffer.size(), m_Buffer.c_str());
- delete this;
- }
-
-protected:
- cRCONServer::cConnection & m_Connection;
- int m_RequestID;
- AString m_Buffer;
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cRCONServer:
-
-cRCONServer::cRCONServer(cServer & a_Server) :
- m_Server(a_Server),
- m_ListenThread4(*this, cSocket::IPv4, "RCON"),
- m_ListenThread6(*this, cSocket::IPv6, "RCON")
-{
-}
-
-
-
-
-
-cRCONServer::~cRCONServer()
-{
- m_ListenThread4.Stop();
- m_ListenThread6.Stop();
-}
-
-
-
-
-
-void cRCONServer::Initialize(cIniFile & a_IniFile)
-{
- if (!a_IniFile.GetValueSetB("RCON", "Enabled", false))
- {
- return;
- }
-
- // Read the password, don't allow an empty one:
- m_Password = a_IniFile.GetValueSet("RCON", "Password", "");
- if (m_Password.empty())
- {
- LOGWARNING("RCON is requested, but the password is not set. RCON is now disabled.");
- return;
- }
-
- // Read and initialize both IPv4 and IPv6 ports for RCON
- bool HasAnyPorts = false;
- AString Ports4 = a_IniFile.GetValueSet("RCON", "PortsIPv4", "25575");
- if (m_ListenThread4.Initialize(Ports4))
- {
- HasAnyPorts = true;
- m_ListenThread4.Start();
- }
- AString Ports6 = a_IniFile.GetValueSet("RCON", "PortsIPv6", "25575");
- if (m_ListenThread6.Initialize(Ports6))
- {
- HasAnyPorts = true;
- m_ListenThread6.Start();
- }
- if (!HasAnyPorts)
- {
- LOGWARNING("RCON is requested, but no ports are specified. Specify at least one port in PortsIPv4 or PortsIPv6. RCON is now disabled.");
- return;
- }
-}
-
-
-
-
-
-void cRCONServer::OnConnectionAccepted(cSocket & a_Socket)
-{
- if (!a_Socket.IsValid())
- {
- return;
- }
-
- LOG("RCON Client \"%s\" connected!", a_Socket.GetIPString().c_str());
-
- // Create a new cConnection object, it will be deleted when the connection is closed
- m_SocketThreads.AddClient(a_Socket, new cConnection(*this, a_Socket));
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cRCONServer::cConnection:
-
-cRCONServer::cConnection::cConnection(cRCONServer & a_RCONServer, cSocket & a_Socket) :
- m_IsAuthenticated(false),
- m_RCONServer(a_RCONServer),
- m_Socket(a_Socket),
- m_IPAddress(a_Socket.GetIPString())
-{
-}
-
-
-
-
-
-void cRCONServer::cConnection::DataReceived(const char * a_Data, int a_Size)
-{
- // Append data to the buffer:
- m_Buffer.append(a_Data, a_Size);
-
- // Process the packets in the buffer:
- while (m_Buffer.size() >= 14)
- {
- int Length = IntFromBuffer(m_Buffer.data());
- if (Length > 1500)
- {
- // Too long, drop the connection
- LOGWARNING("Received an invalid RCON packet length (%d), dropping RCON connection to %s.",
- Length, m_IPAddress.c_str()
- );
- m_RCONServer.m_SocketThreads.RemoveClient(this);
- m_Socket.CloseSocket();
- delete this;
- return;
- }
- if (Length > (int)(m_Buffer.size() + 4))
- {
- // Incomplete packet yet, wait for more data to come
- return;
- }
-
- int RequestID = IntFromBuffer(m_Buffer.data() + 4);
- int PacketType = IntFromBuffer(m_Buffer.data() + 8);
- if (!ProcessPacket(RequestID, PacketType, Length - 10, m_Buffer.data() + 12))
- {
- m_RCONServer.m_SocketThreads.RemoveClient(this);
- m_Socket.CloseSocket();
- delete this;
- return;
- }
- m_Buffer.erase(0, Length + 4);
- } // while (m_Buffer.size() >= 14)
-}
-
-
-
-
-
-void cRCONServer::cConnection::GetOutgoingData(AString & a_Data)
-{
- a_Data.assign(m_Outgoing);
- m_Outgoing.clear();
-}
-
-
-
-
-
-void cRCONServer::cConnection::SocketClosed(void)
-{
- m_RCONServer.m_SocketThreads.RemoveClient(this);
- delete this;
-}
-
-
-
-
-
-bool cRCONServer::cConnection::ProcessPacket(int a_RequestID, int a_PacketType, int a_PayloadLength, const char * a_Payload)
-{
- switch (a_PacketType)
- {
- case RCON_PACKET_LOGIN:
- {
- if (strncmp(a_Payload, m_RCONServer.m_Password.c_str(), a_PayloadLength) != 0)
- {
- LOGINFO("RCON: Invalid password from client %s, dropping connection.", m_IPAddress.c_str());
- return false;
- }
- m_IsAuthenticated = true;
-
- LOGD("RCON: Client at %s has successfully authenticated", m_IPAddress.c_str());
-
- // Send OK response:
- SendResponse(a_RequestID, RCON_PACKET_RESPONSE, 0, NULL);
- return true;
- }
-
- case RCON_PACKET_COMMAND:
- {
- if (!m_IsAuthenticated)
- {
- char AuthNeeded[] = "You need to authenticate first!";
- SendResponse(a_RequestID, RCON_PACKET_RESPONSE, sizeof(AuthNeeded), AuthNeeded);
- return false;
- }
-
- AString cmd(a_Payload, a_PayloadLength);
- LOGD("RCON command from %s: \"%s\"", m_IPAddress.c_str(), cmd.c_str());
- cRoot::Get()->ExecuteConsoleCommand(cmd, *(new cRCONCommandOutput(*this, a_RequestID)));
-
- // Send an empty response:
- SendResponse(a_RequestID, RCON_PACKET_RESPONSE, 0, NULL);
- return true;
- }
- }
-
- // Unknown packet type, drop the connection:
- LOGWARNING("RCON: Client at %s has sent an unknown packet type %d, dropping connection.",
- m_IPAddress.c_str(), a_PacketType
- );
- return false;
-}
-
-
-
-
-
-/// Reads 4 bytes from a_Buffer and returns the int they represent
-int cRCONServer::cConnection::IntFromBuffer(const char * a_Buffer)
-{
- return ((unsigned char)a_Buffer[3] << 24) | ((unsigned char)a_Buffer[2] << 16) | ((unsigned char)a_Buffer[1] << 8) | (unsigned char)a_Buffer[0];
-}
-
-
-
-
-
-/// Puts 4 bytes representing the int into the buffer
-void cRCONServer::cConnection::IntToBuffer(int a_Value, char * a_Buffer)
-{
- a_Buffer[0] = a_Value & 0xff;
- a_Buffer[1] = (a_Value >> 8) & 0xff;
- a_Buffer[2] = (a_Value >> 16) & 0xff;
- a_Buffer[3] = (a_Value >> 24) & 0xff;
-}
-
-
-
-
-
-/// Sends a RCON packet back to the client
-void cRCONServer::cConnection::SendResponse(int a_RequestID, int a_PacketType, int a_PayloadLength, const char * a_Payload)
-{
- ASSERT((a_PayloadLength == 0) || (a_Payload != NULL)); // Either zero data to send, or a valid payload ptr
-
- char Buffer[4];
- int Length = a_PayloadLength + 10;
- IntToBuffer(Length, Buffer);
- m_Outgoing.append(Buffer, 4);
- IntToBuffer(a_RequestID, Buffer);
- m_Outgoing.append(Buffer, 4);
- IntToBuffer(a_PacketType, Buffer);
- m_Outgoing.append(Buffer, 4);
- if (a_PayloadLength > 0)
- {
- m_Outgoing.append(a_Payload, a_PayloadLength);
- }
- m_Outgoing.push_back(0);
- m_Outgoing.push_back(0);
- m_RCONServer.m_SocketThreads.NotifyWrite(this);
-}
-
-
-
-
+
+// RCONServer.cpp
+
+// Implements the cRCONServer class representing the RCON server
+
+#include "Globals.h"
+#include "../iniFile/iniFile.h"
+#include "RCONServer.h"
+#include "Server.h"
+#include "Root.h"
+#include "CommandOutput.h"
+
+
+
+
+
+// Disable MSVC warnings:
+#if defined(_MSC_VER)
+ #pragma warning(push)
+ #pragma warning(disable:4355) // 'this' : used in base member initializer list
+#endif
+
+
+
+
+
+enum
+{
+ // Client -> Server:
+ RCON_PACKET_COMMAND = 2,
+ RCON_PACKET_LOGIN = 3,
+
+ // Server -> Client:
+ RCON_PACKET_RESPONSE = 2,
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cRCONCommandOutput:
+
+class cRCONCommandOutput :
+ public cCommandOutputCallback
+{
+public:
+ cRCONCommandOutput(cRCONServer::cConnection & a_Connection, int a_RequestID) :
+ m_Connection(a_Connection),
+ m_RequestID(a_RequestID)
+ {
+ }
+
+ // cCommandOutputCallback overrides:
+ virtual void Out(const AString & a_Text) override
+ {
+ m_Buffer.append(a_Text);
+ }
+
+ virtual void Finished(void) override
+ {
+ m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, m_Buffer.size(), m_Buffer.c_str());
+ delete this;
+ }
+
+protected:
+ cRCONServer::cConnection & m_Connection;
+ int m_RequestID;
+ AString m_Buffer;
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cRCONServer:
+
+cRCONServer::cRCONServer(cServer & a_Server) :
+ m_Server(a_Server),
+ m_ListenThread4(*this, cSocket::IPv4, "RCON"),
+ m_ListenThread6(*this, cSocket::IPv6, "RCON")
+{
+}
+
+
+
+
+
+cRCONServer::~cRCONServer()
+{
+ m_ListenThread4.Stop();
+ m_ListenThread6.Stop();
+}
+
+
+
+
+
+void cRCONServer::Initialize(cIniFile & a_IniFile)
+{
+ if (!a_IniFile.GetValueSetB("RCON", "Enabled", false))
+ {
+ return;
+ }
+
+ // Read the password, don't allow an empty one:
+ m_Password = a_IniFile.GetValueSet("RCON", "Password", "");
+ if (m_Password.empty())
+ {
+ LOGWARNING("RCON is requested, but the password is not set. RCON is now disabled.");
+ return;
+ }
+
+ // Read and initialize both IPv4 and IPv6 ports for RCON
+ bool HasAnyPorts = false;
+ AString Ports4 = a_IniFile.GetValueSet("RCON", "PortsIPv4", "25575");
+ if (m_ListenThread4.Initialize(Ports4))
+ {
+ HasAnyPorts = true;
+ m_ListenThread4.Start();
+ }
+ AString Ports6 = a_IniFile.GetValueSet("RCON", "PortsIPv6", "25575");
+ if (m_ListenThread6.Initialize(Ports6))
+ {
+ HasAnyPorts = true;
+ m_ListenThread6.Start();
+ }
+ if (!HasAnyPorts)
+ {
+ LOGWARNING("RCON is requested, but no ports are specified. Specify at least one port in PortsIPv4 or PortsIPv6. RCON is now disabled.");
+ return;
+ }
+}
+
+
+
+
+
+void cRCONServer::OnConnectionAccepted(cSocket & a_Socket)
+{
+ if (!a_Socket.IsValid())
+ {
+ return;
+ }
+
+ LOG("RCON Client \"%s\" connected!", a_Socket.GetIPString().c_str());
+
+ // Create a new cConnection object, it will be deleted when the connection is closed
+ m_SocketThreads.AddClient(a_Socket, new cConnection(*this, a_Socket));
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cRCONServer::cConnection:
+
+cRCONServer::cConnection::cConnection(cRCONServer & a_RCONServer, cSocket & a_Socket) :
+ m_IsAuthenticated(false),
+ m_RCONServer(a_RCONServer),
+ m_Socket(a_Socket),
+ m_IPAddress(a_Socket.GetIPString())
+{
+}
+
+
+
+
+
+void cRCONServer::cConnection::DataReceived(const char * a_Data, int a_Size)
+{
+ // Append data to the buffer:
+ m_Buffer.append(a_Data, a_Size);
+
+ // Process the packets in the buffer:
+ while (m_Buffer.size() >= 14)
+ {
+ int Length = IntFromBuffer(m_Buffer.data());
+ if (Length > 1500)
+ {
+ // Too long, drop the connection
+ LOGWARNING("Received an invalid RCON packet length (%d), dropping RCON connection to %s.",
+ Length, m_IPAddress.c_str()
+ );
+ m_RCONServer.m_SocketThreads.RemoveClient(this);
+ m_Socket.CloseSocket();
+ delete this;
+ return;
+ }
+ if (Length > (int)(m_Buffer.size() + 4))
+ {
+ // Incomplete packet yet, wait for more data to come
+ return;
+ }
+
+ int RequestID = IntFromBuffer(m_Buffer.data() + 4);
+ int PacketType = IntFromBuffer(m_Buffer.data() + 8);
+ if (!ProcessPacket(RequestID, PacketType, Length - 10, m_Buffer.data() + 12))
+ {
+ m_RCONServer.m_SocketThreads.RemoveClient(this);
+ m_Socket.CloseSocket();
+ delete this;
+ return;
+ }
+ m_Buffer.erase(0, Length + 4);
+ } // while (m_Buffer.size() >= 14)
+}
+
+
+
+
+
+void cRCONServer::cConnection::GetOutgoingData(AString & a_Data)
+{
+ a_Data.assign(m_Outgoing);
+ m_Outgoing.clear();
+}
+
+
+
+
+
+void cRCONServer::cConnection::SocketClosed(void)
+{
+ m_RCONServer.m_SocketThreads.RemoveClient(this);
+ delete this;
+}
+
+
+
+
+
+bool cRCONServer::cConnection::ProcessPacket(int a_RequestID, int a_PacketType, int a_PayloadLength, const char * a_Payload)
+{
+ switch (a_PacketType)
+ {
+ case RCON_PACKET_LOGIN:
+ {
+ if (strncmp(a_Payload, m_RCONServer.m_Password.c_str(), a_PayloadLength) != 0)
+ {
+ LOGINFO("RCON: Invalid password from client %s, dropping connection.", m_IPAddress.c_str());
+ return false;
+ }
+ m_IsAuthenticated = true;
+
+ LOGD("RCON: Client at %s has successfully authenticated", m_IPAddress.c_str());
+
+ // Send OK response:
+ SendResponse(a_RequestID, RCON_PACKET_RESPONSE, 0, NULL);
+ return true;
+ }
+
+ case RCON_PACKET_COMMAND:
+ {
+ if (!m_IsAuthenticated)
+ {
+ char AuthNeeded[] = "You need to authenticate first!";
+ SendResponse(a_RequestID, RCON_PACKET_RESPONSE, sizeof(AuthNeeded), AuthNeeded);
+ return false;
+ }
+
+ AString cmd(a_Payload, a_PayloadLength);
+ LOGD("RCON command from %s: \"%s\"", m_IPAddress.c_str(), cmd.c_str());
+ cRoot::Get()->ExecuteConsoleCommand(cmd, *(new cRCONCommandOutput(*this, a_RequestID)));
+
+ // Send an empty response:
+ SendResponse(a_RequestID, RCON_PACKET_RESPONSE, 0, NULL);
+ return true;
+ }
+ }
+
+ // Unknown packet type, drop the connection:
+ LOGWARNING("RCON: Client at %s has sent an unknown packet type %d, dropping connection.",
+ m_IPAddress.c_str(), a_PacketType
+ );
+ return false;
+}
+
+
+
+
+
+/// Reads 4 bytes from a_Buffer and returns the int they represent
+int cRCONServer::cConnection::IntFromBuffer(const char * a_Buffer)
+{
+ return ((unsigned char)a_Buffer[3] << 24) | ((unsigned char)a_Buffer[2] << 16) | ((unsigned char)a_Buffer[1] << 8) | (unsigned char)a_Buffer[0];
+}
+
+
+
+
+
+/// Puts 4 bytes representing the int into the buffer
+void cRCONServer::cConnection::IntToBuffer(int a_Value, char * a_Buffer)
+{
+ a_Buffer[0] = a_Value & 0xff;
+ a_Buffer[1] = (a_Value >> 8) & 0xff;
+ a_Buffer[2] = (a_Value >> 16) & 0xff;
+ a_Buffer[3] = (a_Value >> 24) & 0xff;
+}
+
+
+
+
+
+/// Sends a RCON packet back to the client
+void cRCONServer::cConnection::SendResponse(int a_RequestID, int a_PacketType, int a_PayloadLength, const char * a_Payload)
+{
+ ASSERT((a_PayloadLength == 0) || (a_Payload != NULL)); // Either zero data to send, or a valid payload ptr
+
+ char Buffer[4];
+ int Length = a_PayloadLength + 10;
+ IntToBuffer(Length, Buffer);
+ m_Outgoing.append(Buffer, 4);
+ IntToBuffer(a_RequestID, Buffer);
+ m_Outgoing.append(Buffer, 4);
+ IntToBuffer(a_PacketType, Buffer);
+ m_Outgoing.append(Buffer, 4);
+ if (a_PayloadLength > 0)
+ {
+ m_Outgoing.append(a_Payload, a_PayloadLength);
+ }
+ m_Outgoing.push_back(0);
+ m_Outgoing.push_back(0);
+ m_RCONServer.m_SocketThreads.NotifyWrite(this);
+}
+
+
+
+
diff --git a/source/RCONServer.h b/source/RCONServer.h
index a4a0d20fe..0e89800a2 100644
--- a/source/RCONServer.h
+++ b/source/RCONServer.h
@@ -1,109 +1,109 @@
-
-// RCONServer.h
-
-// Declares the cRCONServer class representing the RCON server
-
-
-
-
-
-#pragma once
-
-#include "OSSupport/SocketThreads.h"
-#include "OSSupport/ListenThread.h"
-
-
-
-
-
-// fwd:
-class cServer;
-class cIniFile;
-
-
-
-
-
-class cRCONServer :
- public cListenThread::cCallback
-{
-public:
- cRCONServer(cServer & a_Server);
- ~cRCONServer();
-
- void Initialize(cIniFile & a_IniFile);
-
-protected:
- friend class cRCONCommandOutput;
-
- class cConnection :
- public cSocketThreads::cCallback
- {
- public:
- cConnection(cRCONServer & a_RCONServer, cSocket & a_Socket);
-
- protected:
- friend class cRCONCommandOutput;
-
- /// Set to true if the client has successfully authenticated
- bool m_IsAuthenticated;
-
- /// Buffer for the incoming data
- AString m_Buffer;
-
- /// Buffer for the outgoing data
- AString m_Outgoing;
-
- /// Server that owns this connection and processes requests
- cRCONServer & m_RCONServer;
-
- /// The socket belonging to the client
- cSocket & m_Socket;
-
- /// Address of the client
- AString m_IPAddress;
-
-
- // cSocketThreads::cCallback overrides:
- virtual void DataReceived(const char * a_Data, int a_Size) override;
- virtual void GetOutgoingData(AString & a_Data) override;
- virtual void SocketClosed(void) override;
-
- /// Processes the given packet and sends the response; returns true if successful, false if the connection is to be dropped
- bool ProcessPacket(int a_RequestID, int a_PacketType, int a_PayloadLength, const char * a_Payload);
-
- /// Reads 4 bytes from a_Buffer and returns the int they represent
- int IntFromBuffer(const char * a_Buffer);
-
- /// Puts 4 bytes representing the int into the buffer
- void IntToBuffer(int a_Value, char * a_Buffer);
-
- /// Sends a RCON packet back to the client
- void SendResponse(int a_RequestID, int a_PacketType, int a_PayloadLength, const char * a_Payload);
- } ;
-
-
- /// The server object that will process the commands received
- cServer & m_Server;
-
- /// The thread(s) that take care of all the traffic on the RCON ports
- cSocketThreads m_SocketThreads;
-
- /// The thread for accepting IPv4 RCON connections
- cListenThread m_ListenThread4;
-
- /// The thread for accepting IPv6 RCON connections
- cListenThread m_ListenThread6;
-
- /// Password for authentication
- AString m_Password;
-
-
- // cListenThread::cCallback overrides:
- virtual void OnConnectionAccepted(cSocket & a_Socket) override;
-} ;
-
-
-
-
-
+
+// RCONServer.h
+
+// Declares the cRCONServer class representing the RCON server
+
+
+
+
+
+#pragma once
+
+#include "OSSupport/SocketThreads.h"
+#include "OSSupport/ListenThread.h"
+
+
+
+
+
+// fwd:
+class cServer;
+class cIniFile;
+
+
+
+
+
+class cRCONServer :
+ public cListenThread::cCallback
+{
+public:
+ cRCONServer(cServer & a_Server);
+ ~cRCONServer();
+
+ void Initialize(cIniFile & a_IniFile);
+
+protected:
+ friend class cRCONCommandOutput;
+
+ class cConnection :
+ public cSocketThreads::cCallback
+ {
+ public:
+ cConnection(cRCONServer & a_RCONServer, cSocket & a_Socket);
+
+ protected:
+ friend class cRCONCommandOutput;
+
+ /// Set to true if the client has successfully authenticated
+ bool m_IsAuthenticated;
+
+ /// Buffer for the incoming data
+ AString m_Buffer;
+
+ /// Buffer for the outgoing data
+ AString m_Outgoing;
+
+ /// Server that owns this connection and processes requests
+ cRCONServer & m_RCONServer;
+
+ /// The socket belonging to the client
+ cSocket & m_Socket;
+
+ /// Address of the client
+ AString m_IPAddress;
+
+
+ // cSocketThreads::cCallback overrides:
+ virtual void DataReceived(const char * a_Data, int a_Size) override;
+ virtual void GetOutgoingData(AString & a_Data) override;
+ virtual void SocketClosed(void) override;
+
+ /// Processes the given packet and sends the response; returns true if successful, false if the connection is to be dropped
+ bool ProcessPacket(int a_RequestID, int a_PacketType, int a_PayloadLength, const char * a_Payload);
+
+ /// Reads 4 bytes from a_Buffer and returns the int they represent
+ int IntFromBuffer(const char * a_Buffer);
+
+ /// Puts 4 bytes representing the int into the buffer
+ void IntToBuffer(int a_Value, char * a_Buffer);
+
+ /// Sends a RCON packet back to the client
+ void SendResponse(int a_RequestID, int a_PacketType, int a_PayloadLength, const char * a_Payload);
+ } ;
+
+
+ /// The server object that will process the commands received
+ cServer & m_Server;
+
+ /// The thread(s) that take care of all the traffic on the RCON ports
+ cSocketThreads m_SocketThreads;
+
+ /// The thread for accepting IPv4 RCON connections
+ cListenThread m_ListenThread4;
+
+ /// The thread for accepting IPv6 RCON connections
+ cListenThread m_ListenThread6;
+
+ /// Password for authentication
+ AString m_Password;
+
+
+ // cListenThread::cCallback overrides:
+ virtual void OnConnectionAccepted(cSocket & a_Socket) override;
+} ;
+
+
+
+
+
diff --git a/source/SQLite/urls.txt b/source/SQLite/urls.txt
index 8b5869be6..131d70bbf 100644
--- a/source/SQLite/urls.txt
+++ b/source/SQLite/urls.txt
@@ -1,9 +1,9 @@
-
-SQLite:
-http://www.sqlite.org
-SQLite is in public domain
-
-LuaSQLite3:
-http://lua.sqlite.org
-http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki -- documentation
+
+SQLite:
+http://www.sqlite.org
+SQLite is in public domain
+
+LuaSQLite3:
+http://lua.sqlite.org
+http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki -- documentation
License for LuaSQLite is stored in $/install/LuaSQLite3-LICENSE.txt and distributed with the executables \ No newline at end of file
diff --git a/source/Server.h b/source/Server.h
index 542673b49..dd7a08735 100644
--- a/source/Server.h
+++ b/source/Server.h
@@ -60,7 +60,7 @@ public: // tolua_export
void KickUser(int a_ClientID, const AString & a_Reason);
void AuthenticateUser(int a_ClientID); // Called by cAuthenticator to auth the specified user
- const AString & GetServerID(void) const;
+ const AString & GetServerID(void) const; // tolua_export
void ClientDestroying(const cClientHandle * a_Client); // Called by cClientHandle::Destroy(); stop m_SocketThreads from calling back into a_Client
diff --git a/source/Simulator/DelayedFluidSimulator.cpp b/source/Simulator/DelayedFluidSimulator.cpp
index 6cc982e3d..a4645ca09 100644
--- a/source/Simulator/DelayedFluidSimulator.cpp
+++ b/source/Simulator/DelayedFluidSimulator.cpp
@@ -1,158 +1,158 @@
-
-// DelayedFluidSimulator.cpp
-
-// Interfaces to the cDelayedFluidSimulator class representing a fluid simulator that has a configurable delay
-// before simulating a block. Each tick it takes a consecutive delay "slot" and simulates only blocks in that slot.
-
-#include "Globals.h"
-
-#include "DelayedFluidSimulator.h"
-#include "../World.h"
-#include "../Chunk.h"
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cDelayedFluidSimulatorChunkData::cSlot
-
-bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ)
-{
- ASSERT(a_RelZ >= 0);
- ASSERT(a_RelZ < ARRAYCOUNT(m_Blocks));
-
- cCoordWithIntVector & Blocks = m_Blocks[a_RelZ];
- int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
- for (cCoordWithIntVector::const_iterator itr = Blocks.begin(), end = Blocks.end(); itr != end; ++itr)
- {
- if (itr->Data == Index)
- {
- // Already present
- return false;
- }
- } // for itr - Blocks[]
- Blocks.push_back(cCoordWithInt(a_RelX, a_RelY, a_RelZ, Index));
- return true;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cDelayedFluidSimulatorChunkData:
-
-cDelayedFluidSimulatorChunkData::cDelayedFluidSimulatorChunkData(int a_TickDelay) :
- m_Slots(new cSlot[a_TickDelay])
-{
-}
-
-
-
-
-
-cDelayedFluidSimulatorChunkData::~cDelayedFluidSimulatorChunkData()
-{
- delete[] m_Slots;
- m_Slots = NULL;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cDelayedFluidSimulator:
-
-cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay) :
- super(a_World, a_Fluid, a_StationaryFluid),
- m_TickDelay(a_TickDelay),
- m_AddSlotNum(a_TickDelay - 1),
- m_SimSlotNum(0),
- m_TotalBlocks(0)
-{
-}
-
-
-
-
-
-void cDelayedFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
-{
- if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
- {
- // Not inside the world (may happen when rclk with a full bucket - the client sends Y = -1)
- return;
- }
-
- if ((a_Chunk == NULL) || !a_Chunk->IsValid())
- {
- return;
- }
-
- int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
- BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
- if (BlockType != m_FluidBlock)
- {
- return;
- }
-
- void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
- cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw;
- cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_AddSlotNum];
-
- // Add, if not already present:
- if (!Slot.Add(RelX, a_BlockY, RelZ))
- {
- return;
- }
-
- ++m_TotalBlocks;
-}
-
-
-
-
-
-void cDelayedFluidSimulator::Simulate(float a_Dt)
-{
- m_AddSlotNum = m_SimSlotNum;
- m_SimSlotNum += 1;
- if (m_SimSlotNum >= m_TickDelay)
- {
- m_SimSlotNum = 0;
- }
-}
-
-
-
-
-
-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];
-
- // Simulate all the blocks in the scheduled slot:
- for (int i = 0; i < ARRAYCOUNT(Slot.m_Blocks); i++)
- {
- cCoordWithIntVector & Blocks = Slot.m_Blocks[i];
- if (Blocks.empty())
- {
- continue;
- }
- for (cCoordWithIntVector::iterator itr = Blocks.begin(), end = Blocks.end(); itr != end; ++itr)
- {
- SimulateBlock(a_Chunk, itr->x, itr->y, itr->z);
- }
- m_TotalBlocks -= Blocks.size();
- Blocks.clear();
- }
-}
-
-
-
-
+
+// DelayedFluidSimulator.cpp
+
+// Interfaces to the cDelayedFluidSimulator class representing a fluid simulator that has a configurable delay
+// before simulating a block. Each tick it takes a consecutive delay "slot" and simulates only blocks in that slot.
+
+#include "Globals.h"
+
+#include "DelayedFluidSimulator.h"
+#include "../World.h"
+#include "../Chunk.h"
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cDelayedFluidSimulatorChunkData::cSlot
+
+bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ)
+{
+ ASSERT(a_RelZ >= 0);
+ ASSERT(a_RelZ < ARRAYCOUNT(m_Blocks));
+
+ cCoordWithIntVector & Blocks = m_Blocks[a_RelZ];
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
+ for (cCoordWithIntVector::const_iterator itr = Blocks.begin(), end = Blocks.end(); itr != end; ++itr)
+ {
+ if (itr->Data == Index)
+ {
+ // Already present
+ return false;
+ }
+ } // for itr - Blocks[]
+ Blocks.push_back(cCoordWithInt(a_RelX, a_RelY, a_RelZ, Index));
+ return true;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cDelayedFluidSimulatorChunkData:
+
+cDelayedFluidSimulatorChunkData::cDelayedFluidSimulatorChunkData(int a_TickDelay) :
+ m_Slots(new cSlot[a_TickDelay])
+{
+}
+
+
+
+
+
+cDelayedFluidSimulatorChunkData::~cDelayedFluidSimulatorChunkData()
+{
+ delete[] m_Slots;
+ m_Slots = NULL;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cDelayedFluidSimulator:
+
+cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay) :
+ super(a_World, a_Fluid, a_StationaryFluid),
+ m_TickDelay(a_TickDelay),
+ m_AddSlotNum(a_TickDelay - 1),
+ m_SimSlotNum(0),
+ m_TotalBlocks(0)
+{
+}
+
+
+
+
+
+void cDelayedFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
+{
+ if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
+ {
+ // Not inside the world (may happen when rclk with a full bucket - the client sends Y = -1)
+ return;
+ }
+
+ if ((a_Chunk == NULL) || !a_Chunk->IsValid())
+ {
+ return;
+ }
+
+ int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
+ BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
+ if (BlockType != m_FluidBlock)
+ {
+ return;
+ }
+
+ void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
+ cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw;
+ cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_AddSlotNum];
+
+ // Add, if not already present:
+ if (!Slot.Add(RelX, a_BlockY, RelZ))
+ {
+ return;
+ }
+
+ ++m_TotalBlocks;
+}
+
+
+
+
+
+void cDelayedFluidSimulator::Simulate(float a_Dt)
+{
+ m_AddSlotNum = m_SimSlotNum;
+ m_SimSlotNum += 1;
+ if (m_SimSlotNum >= m_TickDelay)
+ {
+ m_SimSlotNum = 0;
+ }
+}
+
+
+
+
+
+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];
+
+ // Simulate all the blocks in the scheduled slot:
+ for (int i = 0; i < ARRAYCOUNT(Slot.m_Blocks); i++)
+ {
+ cCoordWithIntVector & Blocks = Slot.m_Blocks[i];
+ if (Blocks.empty())
+ {
+ continue;
+ }
+ for (cCoordWithIntVector::iterator itr = Blocks.begin(), end = Blocks.end(); itr != end; ++itr)
+ {
+ SimulateBlock(a_Chunk, itr->x, itr->y, itr->z);
+ }
+ m_TotalBlocks -= Blocks.size();
+ Blocks.clear();
+ }
+}
+
+
+
+
diff --git a/source/Simulator/DelayedFluidSimulator.h b/source/Simulator/DelayedFluidSimulator.h
index 6f7433877..c81500741 100644
--- a/source/Simulator/DelayedFluidSimulator.h
+++ b/source/Simulator/DelayedFluidSimulator.h
@@ -1,82 +1,82 @@
-
-// DelayedFluidSimulator.h
-
-// Interfaces to the cDelayedFluidSimulator class representing a fluid simulator that has a configurable delay
-// before simulating a block. Each tick it takes a consecutive delay "slot" and simulates only blocks in that slot.
-
-
-
-
-#pragma once
-
-#include "FluidSimulator.h"
-
-
-
-
-
-class cDelayedFluidSimulatorChunkData :
- public cFluidSimulatorData
-{
-public:
- class cSlot
- {
- public:
- /// Returns true if the specified block is stored
- bool HasBlock(int a_RelX, int a_RelY, int a_RelZ);
-
- /// Adds the specified block unless already present; returns true if added, false if the block was already present
- bool Add(int a_RelX, int a_RelY, int a_RelZ);
-
- /** Array of block containers, each item stores blocks for one Z coord
- Int param is the block index (for faster duplicate comparison in Add())
- */
- cCoordWithIntVector m_Blocks[16];
- } ;
-
- cDelayedFluidSimulatorChunkData(int a_TickDelay);
- virtual ~cDelayedFluidSimulatorChunkData();
-
- /// Slots, one for each delay tick, each containing the blocks to simulate
- cSlot * m_Slots;
-} ;
-
-
-
-
-
-class cDelayedFluidSimulator :
- public cFluidSimulator
-{
- typedef cFluidSimulator super;
-
-public:
- cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay);
-
- // cSimulator overrides:
- virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
- virtual void Simulate(float a_Dt) override;
- virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
- virtual cFluidSimulatorData * CreateChunkData(void) override { return new cDelayedFluidSimulatorChunkData(m_TickDelay); }
-
-protected:
-
- int m_TickDelay; // Count of the m_Slots array in each ChunkData
- int m_AddSlotNum; // Index into m_Slots[] where to add new blocks in each ChunkData
- int m_SimSlotNum; // Index into m_Slots[] where to simulate blocks in each ChunkData
-
- int m_TotalBlocks; // Statistics only: the total number of blocks currently queued
-
- /*
- Slots:
- | 0 | 1 | ... | m_AddSlotNum | m_SimSlotNum | ... | m_TickDelay - 1 |
- 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.
- virtual void SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) = 0;
-} ;
-
-
-
-
+
+// DelayedFluidSimulator.h
+
+// Interfaces to the cDelayedFluidSimulator class representing a fluid simulator that has a configurable delay
+// before simulating a block. Each tick it takes a consecutive delay "slot" and simulates only blocks in that slot.
+
+
+
+
+#pragma once
+
+#include "FluidSimulator.h"
+
+
+
+
+
+class cDelayedFluidSimulatorChunkData :
+ public cFluidSimulatorData
+{
+public:
+ class cSlot
+ {
+ public:
+ /// Returns true if the specified block is stored
+ bool HasBlock(int a_RelX, int a_RelY, int a_RelZ);
+
+ /// Adds the specified block unless already present; returns true if added, false if the block was already present
+ bool Add(int a_RelX, int a_RelY, int a_RelZ);
+
+ /** Array of block containers, each item stores blocks for one Z coord
+ Int param is the block index (for faster duplicate comparison in Add())
+ */
+ cCoordWithIntVector m_Blocks[16];
+ } ;
+
+ cDelayedFluidSimulatorChunkData(int a_TickDelay);
+ virtual ~cDelayedFluidSimulatorChunkData();
+
+ /// Slots, one for each delay tick, each containing the blocks to simulate
+ cSlot * m_Slots;
+} ;
+
+
+
+
+
+class cDelayedFluidSimulator :
+ public cFluidSimulator
+{
+ typedef cFluidSimulator super;
+
+public:
+ cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay);
+
+ // cSimulator overrides:
+ virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
+ virtual void Simulate(float a_Dt) override;
+ virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
+ virtual cFluidSimulatorData * CreateChunkData(void) override { return new cDelayedFluidSimulatorChunkData(m_TickDelay); }
+
+protected:
+
+ int m_TickDelay; // Count of the m_Slots array in each ChunkData
+ int m_AddSlotNum; // Index into m_Slots[] where to add new blocks in each ChunkData
+ int m_SimSlotNum; // Index into m_Slots[] where to simulate blocks in each ChunkData
+
+ int m_TotalBlocks; // Statistics only: the total number of blocks currently queued
+
+ /*
+ Slots:
+ | 0 | 1 | ... | m_AddSlotNum | m_SimSlotNum | ... | m_TickDelay - 1 |
+ 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.
+ virtual void SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) = 0;
+} ;
+
+
+
+
diff --git a/source/Simulator/FloodyFluidSimulator.cpp b/source/Simulator/FloodyFluidSimulator.cpp
index f2cc068e8..9374bbab3 100644
--- a/source/Simulator/FloodyFluidSimulator.cpp
+++ b/source/Simulator/FloodyFluidSimulator.cpp
@@ -1,334 +1,334 @@
-
-// FloodyFluidSimulator.cpp
-
-// Interfaces to the cFloodyFluidSimulator that represents a fluid simulator that tries to flood everything :)
-// http://forum.mc-server.org/showthread.php?tid=565
-
-#include "Globals.h"
-
-#include "FloodyFluidSimulator.h"
-#include "../World.h"
-#include "../Chunk.h"
-#include "../BlockArea.h"
-#include "../Blocks/BlockHandler.h"
-
-
-
-
-
-// Enable or disable detailed logging
-#if 0
- #define FLOG LOGD
-#else
- #define FLOG(...)
-#endif
-
-
-
-
-
-cFloodyFluidSimulator::cFloodyFluidSimulator(
- cWorld & a_World,
- BLOCKTYPE a_Fluid,
- BLOCKTYPE a_StationaryFluid,
- NIBBLETYPE a_Falloff,
- int a_TickDelay,
- int a_NumNeighborsForSource
-) :
- super(a_World, a_Fluid, a_StationaryFluid, a_TickDelay),
- m_Falloff(a_Falloff),
- m_NumNeighborsForSource(a_NumNeighborsForSource)
-{
-}
-
-
-
-
-
-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",
- 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)
- );
-
- NIBBLETYPE MyMeta = a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ);
- if (!IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ)))
- {
- // Can happen - if a block is scheduled for simulating and gets replaced in the meantime.
- FLOG(" BadBlockType exit");
- return;
- }
-
- if (MyMeta != 0)
- {
- // Source blocks aren't checked for tributaries, others are.
- if (CheckTributaries(a_Chunk, a_RelX, a_RelY, a_RelZ, MyMeta))
- {
- // Has no tributary, has been decreased (in CheckTributaries()),
- // no more processing needed (neighbors have been scheduled by the decrease)
- FLOG(" CheckTributaries exit");
- return;
- }
- }
-
- // New meta for the spreading to neighbors:
- // If this is a source block or was falling, the new meta is just the falloff
- // Otherwise it is the current meta plus falloff (may be larger than max height, will be checked later)
- NIBBLETYPE NewMeta = ((MyMeta == 0) || ((MyMeta & 0x08) != 0)) ? m_Falloff : (MyMeta + m_Falloff);
- bool SpreadFurther = true;
- if (a_RelY > 0)
- {
- BLOCKTYPE Below = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ);
- if (IsPassableForFluid(Below) || IsBlockLava(Below) || IsBlockWater(Below))
- {
- // Spread only down, possibly washing away what's there or turning lava to stone / cobble / obsidian:
- SpreadToNeighbor(a_Chunk, a_RelX, a_RelY - 1, a_RelZ, 8);
- SpreadFurther = false;
- }
- // If source creation is on, check for it here:
- else if (
- (m_NumNeighborsForSource > 0) && // Source creation is on
- (MyMeta == m_Falloff) && // Only exactly one block away from a source (fast bail-out)
- !IsPassableForFluid(Below) && // Only exactly 1 block deep
- CheckNeighborsForSource(a_Chunk, a_RelX, a_RelY, a_RelZ) // Did we create a source?
- )
- {
- // We created a source, no more spreading is to be done now
- // Also has been re-scheduled for ticking in the next wave, so no marking is needed
- return;
- }
- }
-
- if (SpreadFurther && (NewMeta < 8))
- {
- // Spread to the neighbors:
- SpreadToNeighbor(a_Chunk, a_RelX - 1, a_RelY, a_RelZ, NewMeta);
- SpreadToNeighbor(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, NewMeta);
- SpreadToNeighbor(a_Chunk, a_RelX, a_RelY, a_RelZ - 1, NewMeta);
- SpreadToNeighbor(a_Chunk, a_RelX, a_RelY, a_RelZ + 1, NewMeta);
- }
-
- // Mark as processed:
- a_Chunk->FastSetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, MyMeta);
-}
-
-
-
-
-
-bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_MyMeta)
-{
- // If we have a section above, check if there's fluid above this block that would feed it:
- if (a_RelY < cChunkDef::Height - 1)
- {
- if (IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY + 1, a_RelZ)))
- {
- // This block is fed from above, no more processing needed
- FLOG(" Fed from above");
- return false;
- }
- }
-
- // Not fed from above, check if there's a feed from the side (but not if it's a downward-flowing block):
- if (a_MyMeta != 8)
- {
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- static const Vector3i Coords[] =
- {
- Vector3i( 1, 0, 0),
- Vector3i(-1, 0, 0),
- Vector3i( 0, 0, 1),
- Vector3i( 0, 0, -1),
- } ;
- for (int i = 0; i < ARRAYCOUNT(Coords); i++)
- {
- if (!a_Chunk->UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta))
- {
- continue;
- }
- if (IsAllowedBlock(BlockType) && IsHigherMeta(BlockMeta, a_MyMeta))
- {
- // This block is fed, no more processing needed
- FLOG(" Fed from {%d, %d, %d}, type %d, meta %d",
- a_Chunk->GetPosX() * cChunkDef::Width + a_RelX + Coords[i].x,
- a_RelY,
- a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ + Coords[i].z,
- BlockType, BlockMeta
- );
- return false;
- }
- } // for i - Coords[]
- } // if not fed from above
-
- // Block is not fed, decrease by m_Falloff levels:
- if (a_MyMeta >= 8)
- {
- FLOG(" Not fed and downwards, turning into non-downwards meta %d", m_Falloff);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, m_Falloff);
- }
- else
- {
- a_MyMeta += m_Falloff;
- if (a_MyMeta < 8)
- {
- FLOG(" Not fed, decreasing from %d to %d", a_MyMeta - m_Falloff, a_MyMeta);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, a_MyMeta);
- }
- else
- {
- FLOG(" Not fed, meta %d, erasing altogether", a_MyMeta);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
- }
- }
- return true;
-}
-
-
-
-
-
-void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta)
-{
- 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))
- {
- // Chunk not available
- return;
- }
-
- if (IsAllowedBlock(BlockType))
- {
- if ((BlockMeta == a_NewMeta) || IsHigherMeta(BlockMeta, a_NewMeta))
- {
- // Don't spread there, there's already a higher or same level there
- return;
- }
- }
-
- // Check water - lava interaction:
- if (m_FluidBlock == E_BLOCK_LAVA)
- {
- if (IsBlockWater(BlockType))
- {
- // 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",
- a_RelX, a_RelY, a_RelZ,
- ItemTypeToString(NewBlock).c_str()
- );
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
-
- // TODO: Sound effect
-
- return;
- }
- }
- else if (m_FluidBlock == E_BLOCK_WATER)
- {
- if (IsBlockLava(BlockType))
- {
- // 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",
- a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str()
- );
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
-
- // TODO: Sound effect
-
- return;
- }
- }
- else
- {
- ASSERT(!"Unknown fluid!");
- }
-
- if (!IsPassableForFluid(BlockType))
- {
- // Can't spread there
- return;
- }
-
- // Wash away the block there, if possible:
- if (CanWashAway(BlockType))
- {
- cBlockHandler * Handler = BlockHandler(BlockType);
- if (Handler->DoesDropOnUnsuitable())
- {
- Handler->DropBlock(
- &m_World, NULL,
- a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
- a_RelY,
- a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ
- );
- }
- } // 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);
-}
-
-
-
-
-
-bool cFloodyFluidSimulator::CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
-{
- FLOG(" Checking neighbors for source creation");
-
- static const Vector3i NeighborCoords[] =
- {
- Vector3i(-1, 0, 0),
- Vector3i( 1, 0, 0),
- Vector3i( 0, 0, -1),
- Vector3i( 0, 0, 1),
- } ;
-
- int NumNeeded = m_NumNeighborsForSource;
- for (int i = 0; i < ARRAYCOUNT(NeighborCoords); i++)
- {
- int x = a_RelX + NeighborCoords[i].x;
- int y = a_RelY + NeighborCoords[i].y;
- int z = a_RelZ + NeighborCoords[i].z;
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (!a_Chunk->UnboundedRelGetBlock(x, y, z, BlockType, BlockMeta))
- {
- // Neighbor not available, skip it
- continue;
- }
- // FLOG(" Neighbor at {%d, %d, %d}: %s", x, y, z, ItemToFullString(cItem(BlockType, 1, BlockMeta)).c_str());
- if ((BlockMeta == 0) && IsAnyFluidBlock(BlockType))
- {
- NumNeeded--;
- // FLOG(" Found a neighbor source at {%d, %d, %d}, NumNeeded := %d", x, y, z, NumNeeded);
- if (NumNeeded == 0)
- {
- // Found enough, turn into a source and bail out
- // FLOG(" Found enough neighbor sources, turning into a source");
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, 0);
- return true;
- }
- }
- }
- // FLOG(" Not enough neighbors for turning into a source, NumNeeded = %d", NumNeeded);
- return false;
-}
-
-
-
-
+
+// FloodyFluidSimulator.cpp
+
+// Interfaces to the cFloodyFluidSimulator that represents a fluid simulator that tries to flood everything :)
+// http://forum.mc-server.org/showthread.php?tid=565
+
+#include "Globals.h"
+
+#include "FloodyFluidSimulator.h"
+#include "../World.h"
+#include "../Chunk.h"
+#include "../BlockArea.h"
+#include "../Blocks/BlockHandler.h"
+
+
+
+
+
+// Enable or disable detailed logging
+#if 0
+ #define FLOG LOGD
+#else
+ #define FLOG(...)
+#endif
+
+
+
+
+
+cFloodyFluidSimulator::cFloodyFluidSimulator(
+ cWorld & a_World,
+ BLOCKTYPE a_Fluid,
+ BLOCKTYPE a_StationaryFluid,
+ NIBBLETYPE a_Falloff,
+ int a_TickDelay,
+ int a_NumNeighborsForSource
+) :
+ super(a_World, a_Fluid, a_StationaryFluid, a_TickDelay),
+ m_Falloff(a_Falloff),
+ m_NumNeighborsForSource(a_NumNeighborsForSource)
+{
+}
+
+
+
+
+
+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",
+ 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)
+ );
+
+ NIBBLETYPE MyMeta = a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ);
+ if (!IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ)))
+ {
+ // Can happen - if a block is scheduled for simulating and gets replaced in the meantime.
+ FLOG(" BadBlockType exit");
+ return;
+ }
+
+ if (MyMeta != 0)
+ {
+ // Source blocks aren't checked for tributaries, others are.
+ if (CheckTributaries(a_Chunk, a_RelX, a_RelY, a_RelZ, MyMeta))
+ {
+ // Has no tributary, has been decreased (in CheckTributaries()),
+ // no more processing needed (neighbors have been scheduled by the decrease)
+ FLOG(" CheckTributaries exit");
+ return;
+ }
+ }
+
+ // New meta for the spreading to neighbors:
+ // If this is a source block or was falling, the new meta is just the falloff
+ // Otherwise it is the current meta plus falloff (may be larger than max height, will be checked later)
+ NIBBLETYPE NewMeta = ((MyMeta == 0) || ((MyMeta & 0x08) != 0)) ? m_Falloff : (MyMeta + m_Falloff);
+ bool SpreadFurther = true;
+ if (a_RelY > 0)
+ {
+ BLOCKTYPE Below = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ);
+ if (IsPassableForFluid(Below) || IsBlockLava(Below) || IsBlockWater(Below))
+ {
+ // Spread only down, possibly washing away what's there or turning lava to stone / cobble / obsidian:
+ SpreadToNeighbor(a_Chunk, a_RelX, a_RelY - 1, a_RelZ, 8);
+ SpreadFurther = false;
+ }
+ // If source creation is on, check for it here:
+ else if (
+ (m_NumNeighborsForSource > 0) && // Source creation is on
+ (MyMeta == m_Falloff) && // Only exactly one block away from a source (fast bail-out)
+ !IsPassableForFluid(Below) && // Only exactly 1 block deep
+ CheckNeighborsForSource(a_Chunk, a_RelX, a_RelY, a_RelZ) // Did we create a source?
+ )
+ {
+ // We created a source, no more spreading is to be done now
+ // Also has been re-scheduled for ticking in the next wave, so no marking is needed
+ return;
+ }
+ }
+
+ if (SpreadFurther && (NewMeta < 8))
+ {
+ // Spread to the neighbors:
+ SpreadToNeighbor(a_Chunk, a_RelX - 1, a_RelY, a_RelZ, NewMeta);
+ SpreadToNeighbor(a_Chunk, a_RelX + 1, a_RelY, a_RelZ, NewMeta);
+ SpreadToNeighbor(a_Chunk, a_RelX, a_RelY, a_RelZ - 1, NewMeta);
+ SpreadToNeighbor(a_Chunk, a_RelX, a_RelY, a_RelZ + 1, NewMeta);
+ }
+
+ // Mark as processed:
+ a_Chunk->FastSetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, MyMeta);
+}
+
+
+
+
+
+bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_MyMeta)
+{
+ // If we have a section above, check if there's fluid above this block that would feed it:
+ if (a_RelY < cChunkDef::Height - 1)
+ {
+ if (IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY + 1, a_RelZ)))
+ {
+ // This block is fed from above, no more processing needed
+ FLOG(" Fed from above");
+ return false;
+ }
+ }
+
+ // Not fed from above, check if there's a feed from the side (but not if it's a downward-flowing block):
+ if (a_MyMeta != 8)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ static const Vector3i Coords[] =
+ {
+ Vector3i( 1, 0, 0),
+ Vector3i(-1, 0, 0),
+ Vector3i( 0, 0, 1),
+ Vector3i( 0, 0, -1),
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(Coords); i++)
+ {
+ if (!a_Chunk->UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta))
+ {
+ continue;
+ }
+ if (IsAllowedBlock(BlockType) && IsHigherMeta(BlockMeta, a_MyMeta))
+ {
+ // This block is fed, no more processing needed
+ FLOG(" Fed from {%d, %d, %d}, type %d, meta %d",
+ a_Chunk->GetPosX() * cChunkDef::Width + a_RelX + Coords[i].x,
+ a_RelY,
+ a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ + Coords[i].z,
+ BlockType, BlockMeta
+ );
+ return false;
+ }
+ } // for i - Coords[]
+ } // if not fed from above
+
+ // Block is not fed, decrease by m_Falloff levels:
+ if (a_MyMeta >= 8)
+ {
+ FLOG(" Not fed and downwards, turning into non-downwards meta %d", m_Falloff);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, m_Falloff);
+ }
+ else
+ {
+ a_MyMeta += m_Falloff;
+ if (a_MyMeta < 8)
+ {
+ FLOG(" Not fed, decreasing from %d to %d", a_MyMeta - m_Falloff, a_MyMeta);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, a_MyMeta);
+ }
+ else
+ {
+ FLOG(" Not fed, meta %d, erasing altogether", a_MyMeta);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
+ }
+ }
+ return true;
+}
+
+
+
+
+
+void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta)
+{
+ 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))
+ {
+ // Chunk not available
+ return;
+ }
+
+ if (IsAllowedBlock(BlockType))
+ {
+ if ((BlockMeta == a_NewMeta) || IsHigherMeta(BlockMeta, a_NewMeta))
+ {
+ // Don't spread there, there's already a higher or same level there
+ return;
+ }
+ }
+
+ // Check water - lava interaction:
+ if (m_FluidBlock == E_BLOCK_LAVA)
+ {
+ if (IsBlockWater(BlockType))
+ {
+ // 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",
+ a_RelX, a_RelY, a_RelZ,
+ ItemTypeToString(NewBlock).c_str()
+ );
+ a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
+
+ // TODO: Sound effect
+
+ return;
+ }
+ }
+ else if (m_FluidBlock == E_BLOCK_WATER)
+ {
+ if (IsBlockLava(BlockType))
+ {
+ // 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",
+ a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str()
+ );
+ a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
+
+ // TODO: Sound effect
+
+ return;
+ }
+ }
+ else
+ {
+ ASSERT(!"Unknown fluid!");
+ }
+
+ if (!IsPassableForFluid(BlockType))
+ {
+ // Can't spread there
+ return;
+ }
+
+ // Wash away the block there, if possible:
+ if (CanWashAway(BlockType))
+ {
+ cBlockHandler * Handler = BlockHandler(BlockType);
+ if (Handler->DoesDropOnUnsuitable())
+ {
+ Handler->DropBlock(
+ &m_World, NULL,
+ a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
+ a_RelY,
+ a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ
+ );
+ }
+ } // 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);
+}
+
+
+
+
+
+bool cFloodyFluidSimulator::CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
+{
+ FLOG(" Checking neighbors for source creation");
+
+ static const Vector3i NeighborCoords[] =
+ {
+ Vector3i(-1, 0, 0),
+ Vector3i( 1, 0, 0),
+ Vector3i( 0, 0, -1),
+ Vector3i( 0, 0, 1),
+ } ;
+
+ int NumNeeded = m_NumNeighborsForSource;
+ for (int i = 0; i < ARRAYCOUNT(NeighborCoords); i++)
+ {
+ int x = a_RelX + NeighborCoords[i].x;
+ int y = a_RelY + NeighborCoords[i].y;
+ int z = a_RelZ + NeighborCoords[i].z;
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (!a_Chunk->UnboundedRelGetBlock(x, y, z, BlockType, BlockMeta))
+ {
+ // Neighbor not available, skip it
+ continue;
+ }
+ // FLOG(" Neighbor at {%d, %d, %d}: %s", x, y, z, ItemToFullString(cItem(BlockType, 1, BlockMeta)).c_str());
+ if ((BlockMeta == 0) && IsAnyFluidBlock(BlockType))
+ {
+ NumNeeded--;
+ // FLOG(" Found a neighbor source at {%d, %d, %d}, NumNeeded := %d", x, y, z, NumNeeded);
+ if (NumNeeded == 0)
+ {
+ // Found enough, turn into a source and bail out
+ // FLOG(" Found enough neighbor sources, turning into a source");
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, 0);
+ return true;
+ }
+ }
+ }
+ // FLOG(" Not enough neighbors for turning into a source, NumNeeded = %d", NumNeeded);
+ return false;
+}
+
+
+
+
diff --git a/source/Simulator/FloodyFluidSimulator.h b/source/Simulator/FloodyFluidSimulator.h
index e6ce38d61..c4af2e246 100644
--- a/source/Simulator/FloodyFluidSimulator.h
+++ b/source/Simulator/FloodyFluidSimulator.h
@@ -1,53 +1,53 @@
-
-// FloodyFluidSimulator.h
-
-// Interfaces to the cFloodyFluidSimulator that represents a fluid simulator that tries to flood everything :)
-// http://forum.mc-server.org/showthread.php?tid=565
-
-
-
-
-
-#pragma once
-
-#include "DelayedFluidSimulator.h"
-
-
-
-
-
-// fwd:
-class cBlockArea;
-
-
-
-
-
-class cFloodyFluidSimulator :
- public cDelayedFluidSimulator
-{
- typedef cDelayedFluidSimulator super;
-
-public:
- cFloodyFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, NIBBLETYPE a_Falloff, int a_TickDelay, int a_NumNeighborsForSource);
-
-protected:
- NIBBLETYPE m_Falloff;
- int m_NumNeighborsForSource;
-
- // cDelayedFluidSimulator overrides:
- virtual void SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override;
-
- /// Checks tributaries, if not fed, decreases the block's level and returns true
- bool CheckTributaries(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_MyMeta);
-
- /// Spreads into the specified block, if the blocktype there allows. a_Area is for checking.
- void SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta);
-
- /// Checks if there are enough neighbors to create a source at the coords specified; turns into source and returns true if so
- bool CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
-} ;
-
-
-
-
+
+// FloodyFluidSimulator.h
+
+// Interfaces to the cFloodyFluidSimulator that represents a fluid simulator that tries to flood everything :)
+// http://forum.mc-server.org/showthread.php?tid=565
+
+
+
+
+
+#pragma once
+
+#include "DelayedFluidSimulator.h"
+
+
+
+
+
+// fwd:
+class cBlockArea;
+
+
+
+
+
+class cFloodyFluidSimulator :
+ public cDelayedFluidSimulator
+{
+ typedef cDelayedFluidSimulator super;
+
+public:
+ cFloodyFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, NIBBLETYPE a_Falloff, int a_TickDelay, int a_NumNeighborsForSource);
+
+protected:
+ NIBBLETYPE m_Falloff;
+ int m_NumNeighborsForSource;
+
+ // cDelayedFluidSimulator overrides:
+ virtual void SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override;
+
+ /// Checks tributaries, if not fed, decreases the block's level and returns true
+ bool CheckTributaries(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_MyMeta);
+
+ /// Spreads into the specified block, if the blocktype there allows. a_Area is for checking.
+ void SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_NewMeta);
+
+ /// Checks if there are enough neighbors to create a source at the coords specified; turns into source and returns true if so
+ bool CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
+} ;
+
+
+
+
diff --git a/source/Simulator/NoopFluidSimulator.h b/source/Simulator/NoopFluidSimulator.h
index 9120fe868..8f894433f 100644
--- a/source/Simulator/NoopFluidSimulator.h
+++ b/source/Simulator/NoopFluidSimulator.h
@@ -1,36 +1,36 @@
-
-// NoopFluidSimulator.h
-
-// Declares the cNoopFluidSimulator class representing a fluid simulator that performs nothing, it ignores all blocks
-
-
-
-
-
-#pragma once
-
-#include "FluidSimulator.h"
-
-
-
-
-
-class cNoopFluidSimulator :
- public cFluidSimulator
-{
- typedef cFluidSimulator super;
-
-public:
- cNoopFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid) :
- super(a_World, a_Fluid, a_StationaryFluid)
- {
- }
-
- // cSimulator overrides:
- virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override {}
- virtual void Simulate(float a_Dt) override {}
-} ;
-
-
-
-
+
+// NoopFluidSimulator.h
+
+// Declares the cNoopFluidSimulator class representing a fluid simulator that performs nothing, it ignores all blocks
+
+
+
+
+
+#pragma once
+
+#include "FluidSimulator.h"
+
+
+
+
+
+class cNoopFluidSimulator :
+ public cFluidSimulator
+{
+ typedef cFluidSimulator super;
+
+public:
+ cNoopFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid) :
+ super(a_World, a_Fluid, a_StationaryFluid)
+ {
+ }
+
+ // cSimulator overrides:
+ virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override {}
+ virtual void Simulate(float a_Dt) override {}
+} ;
+
+
+
+
diff --git a/source/Simulator/VaporizeFluidSimulator.cpp b/source/Simulator/VaporizeFluidSimulator.cpp
index 792783915..4206c64d1 100644
--- a/source/Simulator/VaporizeFluidSimulator.cpp
+++ b/source/Simulator/VaporizeFluidSimulator.cpp
@@ -1,53 +1,53 @@
-
-// VaporizeFluidSimulator.cpp
-
-// Implements the cVaporizeFluidSimulator class representing a fluid simulator that replaces all fluid blocks with air
-
-#include "Globals.h"
-#include "VaporizeFluidSimulator.h"
-#include "../Chunk.h"
-
-
-
-
-
-cVaporizeFluidSimulator::cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid) :
- super(a_World, a_Fluid, a_StationaryFluid)
-{
-}
-
-
-
-
-
-void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
-{
- if (a_Chunk == NULL)
- {
- return;
- }
- int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
- BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
- if (
- (BlockType == m_FluidBlock) ||
- (BlockType == m_StationaryFluidBlock)
- )
- {
- 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);
- }
-}
-
-
-
-
-
-void cVaporizeFluidSimulator::Simulate(float a_Dt)
-{
- // Nothing needed
-}
-
-
-
-
+
+// VaporizeFluidSimulator.cpp
+
+// Implements the cVaporizeFluidSimulator class representing a fluid simulator that replaces all fluid blocks with air
+
+#include "Globals.h"
+#include "VaporizeFluidSimulator.h"
+#include "../Chunk.h"
+
+
+
+
+
+cVaporizeFluidSimulator::cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid) :
+ super(a_World, a_Fluid, a_StationaryFluid)
+{
+}
+
+
+
+
+
+void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
+{
+ if (a_Chunk == NULL)
+ {
+ return;
+ }
+ int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
+ BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
+ if (
+ (BlockType == m_FluidBlock) ||
+ (BlockType == m_StationaryFluidBlock)
+ )
+ {
+ 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);
+ }
+}
+
+
+
+
+
+void cVaporizeFluidSimulator::Simulate(float a_Dt)
+{
+ // Nothing needed
+}
+
+
+
+
diff --git a/source/Simulator/VaporizeFluidSimulator.h b/source/Simulator/VaporizeFluidSimulator.h
index c179c8ec4..c8eb7802b 100644
--- a/source/Simulator/VaporizeFluidSimulator.h
+++ b/source/Simulator/VaporizeFluidSimulator.h
@@ -1,34 +1,34 @@
-
-// VaporizeFluidSimulator.h
-
-// Declares the cVaporizeFluidSimulator class representing a fluid simulator that replaces all fluid blocks with air
-// Useful for water simulation in the Nether
-
-
-
-
-
-#pragma once
-
-#include "FluidSimulator.h"
-
-
-
-
-
-class cVaporizeFluidSimulator :
- public cFluidSimulator
-{
- typedef cFluidSimulator super;
-
-public:
- cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid);
-
- // cSimulator overrides:
- virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
- virtual void Simulate(float a_Dt) override;
-} ;
-
-
-
-
+
+// VaporizeFluidSimulator.h
+
+// Declares the cVaporizeFluidSimulator class representing a fluid simulator that replaces all fluid blocks with air
+// Useful for water simulation in the Nether
+
+
+
+
+
+#pragma once
+
+#include "FluidSimulator.h"
+
+
+
+
+
+class cVaporizeFluidSimulator :
+ public cFluidSimulator
+{
+ typedef cFluidSimulator super;
+
+public:
+ cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid);
+
+ // cSimulator overrides:
+ virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
+ virtual void Simulate(float a_Dt) override;
+} ;
+
+
+
+
diff --git a/source/SquirrelCommandBinder.cpp b/source/SquirrelCommandBinder.cpp
index 9ff8a43f9..66b456ace 100644
--- a/source/SquirrelCommandBinder.cpp
+++ b/source/SquirrelCommandBinder.cpp
@@ -1,118 +1,118 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-
-
-
-
-#ifdef USE_SQUIRREL
-
-
-
-
-
-#include "SquirrelCommandBinder.h"
-#include "Player.h"
-#include "Plugin.h"
-#include "Plugin_Squirrel.h"
-#include "squirrelbindings/SquirrelArray.h"
-
-
-cSquirrelCommandBinder::cSquirrelCommandBinder()
-{
-}
-
-cSquirrelCommandBinder::~cSquirrelCommandBinder()
-{
-}
-
-void cSquirrelCommandBinder::ClearBindings()
-{
- m_BoundCommands.clear();
-}
-
-void cSquirrelCommandBinder::RemoveBindingsForPlugin( cPlugin* a_Plugin )
-{
- for( CommandMap::iterator itr = m_BoundCommands.begin(); itr != m_BoundCommands.end(); )
- {
- if( itr->second.Plugin == a_Plugin )
- {
- LOGINFO("Unbinding %s ", itr->first.c_str( ) );
- CommandMap::iterator eraseme = itr;
- ++itr;
- m_BoundCommands.erase( eraseme );
- continue;
- }
- ++itr;
- }
-}
-
-bool cSquirrelCommandBinder::BindCommand( const std::string & a_Command, const std::string & a_Permission, cPlugin* a_Plugin, Sqrat::Function a_Callback )
-{
- if( !a_Plugin->CanBindCommands() )
- {
- LOGERROR("ERROR: Trying to bind command \"%s\" to a plugin that is not initialized.", a_Command.c_str() );
- return false;
- }
- if( m_BoundCommands.find( a_Command ) != m_BoundCommands.end() )
- {
- LOGERROR("ERROR: Trying to bind command \"%s\" that has already been bound.", a_Command.c_str() );
- return false;
- }
- LOGINFO("Binding %s (%s)", a_Command.c_str(), a_Permission.c_str() );
-
- BoundFunction Callback;
- Callback.Callback = a_Callback;
- Callback.Plugin = a_Plugin;
- Callback.Permission = a_Permission;
-
- m_BoundCommands[ a_Command ] = Callback;
- return true;
-}
-
-bool cSquirrelCommandBinder::HandleCommand( const std::string & a_Command, cPlayer* a_Player )
-{
- AStringVector Split = StringSplit(a_Command, " ");
- if (Split.size() == 0)
- {
- return false;
- }
-
- CommandMap::iterator FoundCommand = m_BoundCommands.find( Split[0] );
- if( FoundCommand != m_BoundCommands.end() )
- {
- const BoundFunction & func = FoundCommand->second;
- if( func.Permission.size() > 0 )
- {
- if( !a_Player->HasPermission( func.Permission.c_str() ) )
- {
- return false;
- }
- }
-
-
- // Push the split
- SquirrelStringArray SplitData;
-
- std::vector<std::string>::const_iterator iter = Split.begin();
- while(iter != Split.end()) {
- SplitData.Add(*iter);
- ++iter;
- }
-
- // Push player
- Sqrat::Function callback = func.Callback;
- return callback.Evaluate<bool>(&SplitData, a_Player);
- }
- return false;
-}
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
+#include "SquirrelCommandBinder.h"
+#include "Player.h"
+#include "Plugin.h"
+#include "Plugin_Squirrel.h"
+#include "squirrelbindings/SquirrelArray.h"
+
+
+cSquirrelCommandBinder::cSquirrelCommandBinder()
+{
+}
+
+cSquirrelCommandBinder::~cSquirrelCommandBinder()
+{
+}
+
+void cSquirrelCommandBinder::ClearBindings()
+{
+ m_BoundCommands.clear();
+}
+
+void cSquirrelCommandBinder::RemoveBindingsForPlugin( cPlugin* a_Plugin )
+{
+ for( CommandMap::iterator itr = m_BoundCommands.begin(); itr != m_BoundCommands.end(); )
+ {
+ if( itr->second.Plugin == a_Plugin )
+ {
+ LOGINFO("Unbinding %s ", itr->first.c_str( ) );
+ CommandMap::iterator eraseme = itr;
+ ++itr;
+ m_BoundCommands.erase( eraseme );
+ continue;
+ }
+ ++itr;
+ }
+}
+
+bool cSquirrelCommandBinder::BindCommand( const std::string & a_Command, const std::string & a_Permission, cPlugin* a_Plugin, Sqrat::Function a_Callback )
+{
+ if( !a_Plugin->CanBindCommands() )
+ {
+ LOGERROR("ERROR: Trying to bind command \"%s\" to a plugin that is not initialized.", a_Command.c_str() );
+ return false;
+ }
+ if( m_BoundCommands.find( a_Command ) != m_BoundCommands.end() )
+ {
+ LOGERROR("ERROR: Trying to bind command \"%s\" that has already been bound.", a_Command.c_str() );
+ return false;
+ }
+ LOGINFO("Binding %s (%s)", a_Command.c_str(), a_Permission.c_str() );
+
+ BoundFunction Callback;
+ Callback.Callback = a_Callback;
+ Callback.Plugin = a_Plugin;
+ Callback.Permission = a_Permission;
+
+ m_BoundCommands[ a_Command ] = Callback;
+ return true;
+}
+
+bool cSquirrelCommandBinder::HandleCommand( const std::string & a_Command, cPlayer* a_Player )
+{
+ AStringVector Split = StringSplit(a_Command, " ");
+ if (Split.size() == 0)
+ {
+ return false;
+ }
+
+ CommandMap::iterator FoundCommand = m_BoundCommands.find( Split[0] );
+ if( FoundCommand != m_BoundCommands.end() )
+ {
+ const BoundFunction & func = FoundCommand->second;
+ if( func.Permission.size() > 0 )
+ {
+ if( !a_Player->HasPermission( func.Permission.c_str() ) )
+ {
+ return false;
+ }
+ }
+
+
+ // Push the split
+ SquirrelStringArray SplitData;
+
+ std::vector<std::string>::const_iterator iter = Split.begin();
+ while(iter != Split.end()) {
+ SplitData.Add(*iter);
+ ++iter;
+ }
+
+ // Push player
+ Sqrat::Function callback = func.Callback;
+ return callback.Evaluate<bool>(&SplitData, a_Player);
+ }
+ return false;
+}
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/SquirrelCommandBinder.h b/source/SquirrelCommandBinder.h
index c2bc4bafe..49e6fd003 100644
--- a/source/SquirrelCommandBinder.h
+++ b/source/SquirrelCommandBinder.h
@@ -1,51 +1,51 @@
-
-#pragma once
-
-
-
-
-
-#ifdef USE_SQUIRREL
-
-
-
-
-
-#include <sqrat.h>
-
-class cPlugin;
-class cPlayer;
-
-class cSquirrelCommandBinder
-{
-public:
- cSquirrelCommandBinder();
- ~cSquirrelCommandBinder();
-
- bool HandleCommand( const std::string & a_Command, cPlayer* a_Player );
-
- bool BindCommand( const std::string & a_Command, const std::string & a_Permission, cPlugin* a_Plugin, Sqrat::Function a_Callback);
-
- void ClearBindings();
- void RemoveBindingsForPlugin( cPlugin* a_Plugin );
-private:
- struct BoundFunction
- {
- Sqrat::Function Callback;
- cPlugin *Plugin;
- std::string Permission;
- };
-
- typedef std::map< std::string, BoundFunction > CommandMap;
- CommandMap m_BoundCommands;
-};
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#pragma once
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
+#include <sqrat.h>
+
+class cPlugin;
+class cPlayer;
+
+class cSquirrelCommandBinder
+{
+public:
+ cSquirrelCommandBinder();
+ ~cSquirrelCommandBinder();
+
+ bool HandleCommand( const std::string & a_Command, cPlayer* a_Player );
+
+ bool BindCommand( const std::string & a_Command, const std::string & a_Permission, cPlugin* a_Plugin, Sqrat::Function a_Callback);
+
+ void ClearBindings();
+ void RemoveBindingsForPlugin( cPlugin* a_Plugin );
+private:
+ struct BoundFunction
+ {
+ Sqrat::Function Callback;
+ cPlugin *Plugin;
+ std::string Permission;
+ };
+
+ typedef std::map< std::string, BoundFunction > CommandMap;
+ CommandMap m_BoundCommands;
+};
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/TNTEntity.cpp b/source/TNTEntity.cpp
index 22f343e88..e431464b3 100644
--- a/source/TNTEntity.cpp
+++ b/source/TNTEntity.cpp
@@ -1,72 +1,72 @@
-#include "Globals.h"
-
-#include "TNTEntity.h"
-#include "World.h"
-#include "ClientHandle.h"
-
-
-
-
-
-cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, float a_FuseTimeInSec) :
- super(etTNT, a_X, a_Y, a_Z, 0.98, 0.98),
- m_Counter(0),
- m_MaxFuseTime(a_FuseTimeInSec)
-{
-}
-
-
-
-
-
-cTNTEntity::cTNTEntity(const Vector3d & a_Pos, float a_FuseTimeInSec) :
- super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
- m_Counter(0),
- m_MaxFuseTime(a_FuseTimeInSec)
-{
-}
-
-
-
-
-void cTNTEntity::Initialize(cWorld * a_World)
-{
- super::Initialize(a_World);
- a_World->BroadcastSpawnEntity(*this);
-}
-
-
-
-
-
-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;
-}
-
-
-
-
-
-void cTNTEntity::Tick(float a_Dt, cChunk & a_Chunk)
-{
- super::Tick(a_Dt, a_Chunk);
- BroadcastMovementUpdate();
- float delta_time = a_Dt / 1000; // Convert miliseconds to seconds
- m_Counter += delta_time;
- if (m_Counter > m_MaxFuseTime) // Check if we go KABOOOM
- {
- Destroy(true);
- LOGD("BOOM at {%f,%f,%f}", GetPosX(), GetPosY(), GetPosZ());
- m_World->DoExplosiontAt(4.0, (int)floor(GetPosX()), (int)floor(GetPosY()), (int)floor(GetPosZ()));
- return;
- }
-}
-
-
-
-
+#include "Globals.h"
+
+#include "TNTEntity.h"
+#include "World.h"
+#include "ClientHandle.h"
+
+
+
+
+
+cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, float a_FuseTimeInSec) :
+ super(etTNT, a_X, a_Y, a_Z, 0.98, 0.98),
+ m_Counter(0),
+ m_MaxFuseTime(a_FuseTimeInSec)
+{
+}
+
+
+
+
+
+cTNTEntity::cTNTEntity(const Vector3d & a_Pos, float a_FuseTimeInSec) :
+ super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
+ m_Counter(0),
+ m_MaxFuseTime(a_FuseTimeInSec)
+{
+}
+
+
+
+
+void cTNTEntity::Initialize(cWorld * a_World)
+{
+ super::Initialize(a_World);
+ a_World->BroadcastSpawnEntity(*this);
+}
+
+
+
+
+
+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;
+}
+
+
+
+
+
+void cTNTEntity::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ super::Tick(a_Dt, a_Chunk);
+ BroadcastMovementUpdate();
+ float delta_time = a_Dt / 1000; // Convert miliseconds to seconds
+ m_Counter += delta_time;
+ if (m_Counter > m_MaxFuseTime) // Check if we go KABOOOM
+ {
+ Destroy(true);
+ LOGD("BOOM at {%f,%f,%f}", GetPosX(), GetPosY(), GetPosZ());
+ m_World->DoExplosiontAt(4.0, (int)floor(GetPosX()), (int)floor(GetPosY()), (int)floor(GetPosZ()));
+ return;
+ }
+}
+
+
+
+
diff --git a/source/TNTEntity.h b/source/TNTEntity.h
index d20b6aca4..5dbfd2d43 100644
--- a/source/TNTEntity.h
+++ b/source/TNTEntity.h
@@ -1,34 +1,34 @@
-
-#pragma once
-
-#include "Entity.h"
-#include "Defines.h"
-
-
-
-
-
-class cTNTEntity :
- public cEntity
-{
- typedef cEntity super;
-
-public:
- CLASS_PROTODEF(cTNTEntity);
-
- cTNTEntity(double a_X, double a_Y, double a_Z, float a_FuseTimeInSec);
- cTNTEntity(const Vector3d & a_Pos, float a_FuseTimeInSec);
-
- // cEntity overrides:
- virtual void Initialize(cWorld * a_World) override;
- virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
-
-protected:
- float m_Counter; ///< How much time has elapsed since the object was created, in seconds
- float m_MaxFuseTime; ///< How long the fuse is, in seconds
-};
-
-
-
-
+
+#pragma once
+
+#include "Entity.h"
+#include "Defines.h"
+
+
+
+
+
+class cTNTEntity :
+ public cEntity
+{
+ typedef cEntity super;
+
+public:
+ CLASS_PROTODEF(cTNTEntity);
+
+ cTNTEntity(double a_X, double a_Y, double a_Z, float a_FuseTimeInSec);
+ cTNTEntity(const Vector3d & a_Pos, float a_FuseTimeInSec);
+
+ // cEntity overrides:
+ virtual void Initialize(cWorld * a_World) override;
+ virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+
+protected:
+ float m_Counter; ///< How much time has elapsed since the object was created, in seconds
+ float m_MaxFuseTime; ///< How long the fuse is, in seconds
+};
+
+
+
+
diff --git a/source/UI/SlotArea.cpp b/source/UI/SlotArea.cpp
index fc3f248f5..dddb20885 100644
--- a/source/UI/SlotArea.cpp
+++ b/source/UI/SlotArea.cpp
@@ -1,815 +1,815 @@
-
-// SlotArea.cpp
-
-// Implements the cSlotArea class and its descendants
-
-#include "Globals.h"
-#include "SlotArea.h"
-#include "../Player.h"
-#include "../BlockEntities/ChestEntity.h"
-#include "../BlockEntities/DropSpenserEntity.h"
-#include "../BlockEntities/FurnaceEntity.h"
-#include "../Items/ItemHandler.h"
-#include "Window.h"
-#include "../CraftingRecipes.h"
-#include "../Root.h"
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotArea:
-
-cSlotArea::cSlotArea(int a_NumSlots, cWindow & a_ParentWindow) :
- m_NumSlots(a_NumSlots),
- m_ParentWindow(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,
- ItemToFullString(a_ClickedItem).c_str(),
- ItemToFullString(*GetSlot(a_SlotNum, a_Player)).c_str()
- );
- */
-
- ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots()));
-
- bool bAsync = false;
- if (GetSlot(a_SlotNum, a_Player) == NULL)
- {
- LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
- return;
- }
-
- if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick))
- {
- if (!a_Player.IsDraggingItem())
- {
- ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
- return;
- }
- LOGD("Shift clicked, but the player is dragging an item: %s", ItemToFullString(a_Player.GetDraggingItem()).c_str());
- 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;
- }
- cItem & DraggingItem = a_Player.GetDraggingItem();
- switch (a_ClickAction)
- {
- case caRightClick:
- {
- if (DraggingItem.m_ItemType <= 0) // Empty-handed?
- {
- DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f);
- Slot.m_ItemCount -= DraggingItem.m_ItemCount;
- DraggingItem.m_ItemType = Slot.m_ItemType;
- DraggingItem.m_ItemDamage = Slot.m_ItemDamage;
-
- if (Slot.m_ItemCount <= 0)
- {
- Slot.Empty();
- }
- }
- else if ((Slot.m_ItemType <= 0) || DraggingItem.IsEqual(Slot))
- {
- // Drop one item in slot
- cItemHandler * Handler = ItemHandler(Slot.m_ItemType);
- if ((DraggingItem.m_ItemCount > 0) && (Slot.m_ItemCount < Handler->GetMaxStackSize()))
- {
- Slot.m_ItemType = DraggingItem.m_ItemType;
- Slot.m_ItemCount++;
- Slot.m_ItemDamage = DraggingItem.m_ItemDamage;
- DraggingItem.m_ItemCount--;
- }
- if (DraggingItem.m_ItemCount <= 0)
- {
- DraggingItem.Empty();
- }
- }
- else if (!DraggingItem.IsEqual(Slot))
- {
- // Swap contents
- cItem tmp(DraggingItem);
- DraggingItem = Slot;
- Slot = tmp;
- }
- break;
- }
-
- case caLeftClick:
- {
- // Left-clicked
- if (!DraggingItem.IsEqual(Slot))
- {
- // Switch contents
- cItem tmp(DraggingItem);
- DraggingItem = Slot;
- Slot = tmp;
- }
- else
- {
- // Same type, add items:
- cItemHandler * Handler = ItemHandler(DraggingItem.m_ItemType);
- int FreeSlots = Handler->GetMaxStackSize() - Slot.m_ItemCount;
- if (FreeSlots < 0)
- {
- ASSERT(!"Bad item stack size - where did we get more items in a slot than allowed?");
- FreeSlots = 0;
- }
- int Filling = (FreeSlots > DraggingItem.m_ItemCount) ? DraggingItem.m_ItemCount : FreeSlots;
- Slot.m_ItemCount += (char)Filling;
- DraggingItem.m_ItemCount -= (char)Filling;
- if (DraggingItem.m_ItemCount <= 0)
- {
- DraggingItem.Empty();
- }
- }
- break;
- }
- default:
- {
- LOGWARNING("SlotArea: Unhandled click action: %d (%s)", a_ClickAction, ClickActionToString(a_ClickAction));
- m_ParentWindow.BroadcastWholeWindow();
- return;
- }
- } // switch (a_ClickAction
-
- SetSlot(a_SlotNum, a_Player, Slot);
- if (bAsync)
- {
- m_ParentWindow.BroadcastWholeWindow();
- }
-
-}
-
-
-
-
-
-void cSlotArea::ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem)
-{
- // 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));
- m_ParentWindow.DistributeStack(Slot, a_Player, this, true);
- if (Slot.IsEmpty())
- {
- // Empty the slot completely, the cilent doesn't like left-over ItemType with zero count
- Slot.Empty();
- }
- 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 cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_Apply, bool a_KeepEmptySlots)
-{
- for (int i = 0; i < m_NumSlots; i++)
- {
- const cItem * Slot = GetSlot(i, a_Player);
- if (!Slot->IsSameType(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_Apply)
- {
- 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
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaChest:
-
-cSlotAreaChest::cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow) :
- cSlotArea(27, a_ParentWindow),
- m_Chest(a_Chest)
-{
-}
-
-
-
-
-
-const cItem * cSlotAreaChest::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_Chest->GetSlot(a_SlotNum));
-}
-
-
-
-
-
-void cSlotAreaChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
-{
- m_Chest->SetSlot(a_SlotNum, a_Item);
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaDoubleChest:
-
-cSlotAreaDoubleChest::cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow) :
- cSlotArea(54, a_ParentWindow),
- m_TopChest(a_TopChest),
- m_BottomChest(a_BottomChest)
-{
-}
-
-
-
-
-
-const cItem * cSlotAreaDoubleChest::GetSlot(int a_SlotNum, cPlayer & a_Player) const
-{
- // a_SlotNum ranges from 0 to 53, use that to index the correct chest's inventory:
- if (a_SlotNum < 27)
- {
- return &(m_TopChest->GetSlot(a_SlotNum));
- }
- else
- {
- return &(m_BottomChest->GetSlot(a_SlotNum - 27));
- }
-}
-
-
-
-
-
-void cSlotAreaDoubleChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
-{
- if (a_SlotNum < 27)
- {
- m_TopChest->SetSlot(a_SlotNum, a_Item);
- }
- else
- {
- m_BottomChest->SetSlot(a_SlotNum - 27, a_Item);
- }
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaCrafting:
-
-cSlotAreaCrafting::cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow) :
- cSlotAreaTemporary(1 + a_GridSize * a_GridSize, a_ParentWindow),
- m_GridSize(a_GridSize)
-{
- ASSERT((a_GridSize == 2) || (a_GridSize == 3));
-}
-
-
-
-
-
-void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
-{
- // Override for craft result slot
- if (a_SlotNum == 0)
- {
- if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick))
- {
- ShiftClickedResult(a_Player);
- }
- else
- {
- ClickedResult(a_Player);
- }
- return;
- }
- super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
- UpdateRecipe(a_Player);
-}
-
-
-
-
-
-void cSlotAreaCrafting::OnPlayerRemoved(cPlayer & a_Player)
-{
- // Toss all items on the crafting grid:
- TossItems(a_Player, 1, m_NumSlots);
-
- // Remove the current recipe from the player -> recipe map:
- for (cRecipeMap::iterator itr = m_Recipes.begin(), end = m_Recipes.end(); itr != end; ++itr)
- {
- if (itr->first == a_Player.GetUniqueID())
- {
- // Remove the player from the recipe map:
- m_Recipes.erase(itr);
- return;
- }
- } // for itr - m_Recipes[]
- // Player not found - that is acceptable
-}
-
-
-
-
-
-void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
-{
- const cItem * ResultSlot = GetSlot(0, a_Player);
- cItem & DraggingItem = a_Player.GetDraggingItem();
-
- // Get the current recipe:
- cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
-
- cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1;
- cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize);
-
- // If possible, craft:
- if (DraggingItem.IsEmpty())
- {
- DraggingItem = Recipe.GetResult();
- Recipe.ConsumeIngredients(Grid);
- Grid.CopyToItems(PlayerSlots);
- }
- else if (DraggingItem.IsEqual(Recipe.GetResult()))
- {
- cItemHandler * Handler = ItemHandler(Recipe.GetResult().m_ItemType);
- if (DraggingItem.m_ItemCount + Recipe.GetResult().m_ItemCount <= Handler->GetMaxStackSize())
- {
- DraggingItem.m_ItemCount += Recipe.GetResult().m_ItemCount;
- Recipe.ConsumeIngredients(Grid);
- Grid.CopyToItems(PlayerSlots);
- }
- }
-
- // Get the new recipe and update the result slot:
- UpdateRecipe(a_Player);
-
- // We're done. Send all changes to the client and bail out:
- m_ParentWindow.BroadcastWholeWindow();
-}
-
-
-
-
-
-void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player)
-{
- cItem Result(*GetSlot(0, a_Player));
- if (Result.IsEmpty())
- {
- return;
- }
- cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1;
- do
- {
- // Try distributing the result. If it fails, bail out:
- cItem ResultCopy(Result);
- m_ParentWindow.DistributeStack(ResultCopy, a_Player, this, false);
- if (!ResultCopy.IsEmpty())
- {
- // Couldn't distribute all of it. Bail out
- return;
- }
-
- // 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);
- if (!Recipe.GetResult().IsEqual(Result))
- {
- // The recipe has changed, bail out
- return;
- }
- } while (true);
-}
-
-
-
-
-
-void cSlotAreaCrafting::UpdateRecipe(cPlayer & a_Player)
-{
- cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
- cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
- cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe);
- SetSlot(0, a_Player, Recipe.GetResult());
- m_ParentWindow.SendSlot(a_Player, this, 0);
-}
-
-
-
-
-
-cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player)
-{
- for (cRecipeMap::iterator itr = m_Recipes.begin(), end = m_Recipes.end(); itr != end; ++itr)
- {
- if (itr->first == a_Player.GetUniqueID())
- {
- return itr->second;
- }
- } // for itr - m_Recipes[]
-
- // Not found. Add a new one:
- cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
- cCraftingRecipe Recipe(Grid);
- cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe);
- m_Recipes.push_back(std::make_pair(a_Player.GetUniqueID(), Recipe));
- return m_Recipes.back().second;
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaFurnace:
-
-cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow) :
- cSlotArea(3, a_ParentWindow),
- m_Furnace(a_Furnace)
-{
- m_Furnace->GetContents().AddListener(*this);
-}
-
-
-
-
-
-cSlotAreaFurnace::~cSlotAreaFurnace()
-{
- m_Furnace->GetContents().RemoveListener(*this);
-}
-
-
-
-
-
-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;
- }
-}
-
-
-
-
-
-const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const
-{
- // a_SlotNum ranges from 0 to 2, query the items from the underlying furnace:
- return &(m_Furnace->GetSlot(a_SlotNum));
-}
-
-
-
-
-
-void cSlotAreaFurnace::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
-{
- m_Furnace->SetSlot(a_SlotNum, a_Item);
-}
-
-
-
-
-
-void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
-{
- // Something has changed in the window, broadcast the entire window to all clients
- ASSERT(a_ItemGrid == &(m_Furnace->GetContents()));
-
- m_ParentWindow.BroadcastWholeWindow();
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaInventoryBase:
-
-cSlotAreaInventoryBase::cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow) :
- cSlotArea(a_NumSlots, a_ParentWindow),
- m_SlotOffset(a_SlotOffset)
-{
-}
-
-
-
-
-
-void cSlotAreaInventoryBase::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
-{
- if ((a_Player.GetGameMode() == eGameMode_Creative) && (m_ParentWindow.GetWindowType() == cWindow::Inventory))
- {
- // Creative inventory must treat a_ClickedItem as a DraggedItem instead, replacing the inventory slot with it
- SetSlot(a_SlotNum, a_Player, a_ClickedItem);
- return;
- }
-
- // Survival inventory and all other windows' inventory has the same handling as normal slot areas
- super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
- return;
-}
-
-
-
-
-
-const cItem * cSlotAreaInventoryBase::GetSlot(int a_SlotNum, cPlayer & a_Player) const
-{
- // a_SlotNum ranges from 0 to 35, map that to the player's inventory slots according to the internal offset
- return &a_Player.GetInventory().GetSlot(a_SlotNum + m_SlotOffset);
-}
-
-
-
-
-
-void cSlotAreaInventoryBase::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
-{
- a_Player.GetInventory().SetSlot(a_SlotNum + m_SlotOffset, a_Item);
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaArmor:
-
-void cSlotAreaArmor::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
-{
- if (ItemCategory::IsHelmet(a_ItemStack.m_ItemType) && GetSlot(0, a_Player)->IsEmpty())
- {
- if (a_ShouldApply)
- {
- SetSlot(0, a_Player, a_ItemStack.CopyOne());
- }
- a_ItemStack.m_ItemCount -= 1;
- }
- else if (ItemCategory::IsChestPlate(a_ItemStack.m_ItemType) && GetSlot(1, a_Player)->IsEmpty())
- {
- if (a_ShouldApply)
- {
- SetSlot(1, a_Player, a_ItemStack.CopyOne());
- }
- a_ItemStack.m_ItemCount -= 1;
- }
- else if (ItemCategory::IsLeggings(a_ItemStack.m_ItemType) && GetSlot(2, a_Player)->IsEmpty())
- {
- if (a_ShouldApply)
- {
- SetSlot(2, a_Player, a_ItemStack.CopyOne());
- }
- a_ItemStack.m_ItemCount -= 1;
- }
- else if (ItemCategory::IsBoots(a_ItemStack.m_ItemType) && GetSlot(3, a_Player)->IsEmpty())
- {
- if (a_ShouldApply)
- {
- SetSlot(3, a_Player, a_ItemStack.CopyOne());
- }
- a_ItemStack.m_ItemCount -= 1;
- }
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaItemGrid:
-
-cSlotAreaItemGrid::cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow) :
- super(a_ItemGrid.GetNumSlots(), a_ParentWindow),
- m_ItemGrid(a_ItemGrid)
-{
- m_ItemGrid.AddListener(*this);
-}
-
-
-
-
-
-cSlotAreaItemGrid::~cSlotAreaItemGrid()
-{
- m_ItemGrid.RemoveListener(*this);
-}
-
-
-
-
-
-const cItem * cSlotAreaItemGrid::GetSlot(int a_SlotNum, cPlayer & a_Player) const
-{
- return &m_ItemGrid.GetSlot(a_SlotNum);
-}
-
-
-
-
-
-void cSlotAreaItemGrid::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
-{
- m_ItemGrid.SetSlot(a_SlotNum, a_Item);
-}
-
-
-
-
-
-void cSlotAreaItemGrid::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
-{
- ASSERT(a_ItemGrid == &m_ItemGrid);
- m_ParentWindow.BroadcastSlot(this, a_SlotNum);
-}
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaTemporary:
-
-cSlotAreaTemporary::cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow) :
- cSlotArea(a_NumSlots, a_ParentWindow)
-{
-}
-
-
-
-
-
-const cItem * cSlotAreaTemporary::GetSlot(int a_SlotNum, cPlayer & a_Player) const
-{
- cItemMap::const_iterator itr = m_Items.find(a_Player.GetUniqueID());
- if (itr == m_Items.end())
- {
- LOGERROR("cSlotAreaTemporary: player \"%s\" not found for slot %d!", a_Player.GetName().c_str(), a_SlotNum);
- ASSERT(!"cSlotAreaTemporary: player not found!");
-
- // Player not found, this should not happen, ever! Return NULL, but things may break by this.
- return NULL;
- }
-
- if (a_SlotNum >= (int)(itr->second.size()))
- {
- LOGERROR("cSlotAreaTemporary: asking for more slots than actually stored!");
- ASSERT(!"cSlotAreaTemporary: asking for more slots than actually stored!");
- return NULL;
- }
-
- return &(itr->second[a_SlotNum]);
-}
-
-
-
-
-
-void cSlotAreaTemporary::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
-{
- cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
- if (itr == m_Items.end())
- {
- // Player not found
- LOGWARNING("cSlotAreaTemporary: player not found!");
- return;
- }
-
- if (a_SlotNum >= (int)(itr->second.size()))
- {
- LOGERROR("cSlotAreaTemporary: asking for more slots than actually stored!");
- return;
- }
-
- itr->second[a_SlotNum] = a_Item;
-}
-
-
-
-
-
-void cSlotAreaTemporary::OnPlayerAdded(cPlayer & a_Player)
-{
- ASSERT(m_Items.find(a_Player.GetUniqueID()) == m_Items.end()); // The player shouldn't be in the itemmap, otherwise we probably have a leak
- m_Items[a_Player.GetUniqueID()].resize(m_NumSlots); // Make the vector the specified size of empty items
-}
-
-
-
-
-
-void cSlotAreaTemporary::OnPlayerRemoved(cPlayer & a_Player)
-{
- cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
- ASSERT(itr != m_Items.end()); // The player should be in the list, otherwise a call to OnPlayerAdded() was mismatched
- m_Items.erase(itr);
-}
-
-
-
-
-
-void cSlotAreaTemporary::TossItems(cPlayer & a_Player, int a_Begin, int a_End)
-{
- cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
- if (itr == m_Items.end())
- {
- LOGWARNING("Player tossing items (%s) not found in the item map", a_Player.GetName().c_str());
- return;
- }
-
- cItems Drops;
- for (int i = a_Begin; i < a_End; i++)
- {
- cItem & Item = itr->second[i];
- if (!Item.IsEmpty())
- {
- Drops.push_back(Item);
- }
- Item.Empty();
- } // for i - itr->second[]
-
- double vX = 0, vY = 0, vZ = 0;
- EulerToVector(-a_Player.GetRotation(), 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 * 2, vY * 2, vZ * 2);
-}
-
-
-
-
-
-cItem * cSlotAreaTemporary::GetPlayerSlots(cPlayer & a_Player)
-{
- cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
- if (itr == m_Items.end())
- {
- return NULL;
- }
- return &(itr->second[0]);
-}
-
-
-
-
+
+// SlotArea.cpp
+
+// Implements the cSlotArea class and its descendants
+
+#include "Globals.h"
+#include "SlotArea.h"
+#include "../Player.h"
+#include "../BlockEntities/ChestEntity.h"
+#include "../BlockEntities/DropSpenserEntity.h"
+#include "../BlockEntities/FurnaceEntity.h"
+#include "../Items/ItemHandler.h"
+#include "Window.h"
+#include "../CraftingRecipes.h"
+#include "../Root.h"
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotArea:
+
+cSlotArea::cSlotArea(int a_NumSlots, cWindow & a_ParentWindow) :
+ m_NumSlots(a_NumSlots),
+ m_ParentWindow(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,
+ ItemToFullString(a_ClickedItem).c_str(),
+ ItemToFullString(*GetSlot(a_SlotNum, a_Player)).c_str()
+ );
+ */
+
+ ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots()));
+
+ bool bAsync = false;
+ if (GetSlot(a_SlotNum, a_Player) == NULL)
+ {
+ LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ return;
+ }
+
+ if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick))
+ {
+ if (!a_Player.IsDraggingItem())
+ {
+ ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
+ return;
+ }
+ LOGD("Shift clicked, but the player is dragging an item: %s", ItemToFullString(a_Player.GetDraggingItem()).c_str());
+ 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;
+ }
+ cItem & DraggingItem = a_Player.GetDraggingItem();
+ switch (a_ClickAction)
+ {
+ case caRightClick:
+ {
+ if (DraggingItem.m_ItemType <= 0) // Empty-handed?
+ {
+ DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f);
+ Slot.m_ItemCount -= DraggingItem.m_ItemCount;
+ DraggingItem.m_ItemType = Slot.m_ItemType;
+ DraggingItem.m_ItemDamage = Slot.m_ItemDamage;
+
+ if (Slot.m_ItemCount <= 0)
+ {
+ Slot.Empty();
+ }
+ }
+ else if ((Slot.m_ItemType <= 0) || DraggingItem.IsEqual(Slot))
+ {
+ // Drop one item in slot
+ cItemHandler * Handler = ItemHandler(Slot.m_ItemType);
+ if ((DraggingItem.m_ItemCount > 0) && (Slot.m_ItemCount < Handler->GetMaxStackSize()))
+ {
+ Slot.m_ItemType = DraggingItem.m_ItemType;
+ Slot.m_ItemCount++;
+ Slot.m_ItemDamage = DraggingItem.m_ItemDamage;
+ DraggingItem.m_ItemCount--;
+ }
+ if (DraggingItem.m_ItemCount <= 0)
+ {
+ DraggingItem.Empty();
+ }
+ }
+ else if (!DraggingItem.IsEqual(Slot))
+ {
+ // Swap contents
+ cItem tmp(DraggingItem);
+ DraggingItem = Slot;
+ Slot = tmp;
+ }
+ break;
+ }
+
+ case caLeftClick:
+ {
+ // Left-clicked
+ if (!DraggingItem.IsEqual(Slot))
+ {
+ // Switch contents
+ cItem tmp(DraggingItem);
+ DraggingItem = Slot;
+ Slot = tmp;
+ }
+ else
+ {
+ // Same type, add items:
+ cItemHandler * Handler = ItemHandler(DraggingItem.m_ItemType);
+ int FreeSlots = Handler->GetMaxStackSize() - Slot.m_ItemCount;
+ if (FreeSlots < 0)
+ {
+ ASSERT(!"Bad item stack size - where did we get more items in a slot than allowed?");
+ FreeSlots = 0;
+ }
+ int Filling = (FreeSlots > DraggingItem.m_ItemCount) ? DraggingItem.m_ItemCount : FreeSlots;
+ Slot.m_ItemCount += (char)Filling;
+ DraggingItem.m_ItemCount -= (char)Filling;
+ if (DraggingItem.m_ItemCount <= 0)
+ {
+ DraggingItem.Empty();
+ }
+ }
+ break;
+ }
+ default:
+ {
+ LOGWARNING("SlotArea: Unhandled click action: %d (%s)", a_ClickAction, ClickActionToString(a_ClickAction));
+ m_ParentWindow.BroadcastWholeWindow();
+ return;
+ }
+ } // switch (a_ClickAction
+
+ SetSlot(a_SlotNum, a_Player, Slot);
+ if (bAsync)
+ {
+ m_ParentWindow.BroadcastWholeWindow();
+ }
+
+}
+
+
+
+
+
+void cSlotArea::ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem)
+{
+ // 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));
+ m_ParentWindow.DistributeStack(Slot, a_Player, this, true);
+ if (Slot.IsEmpty())
+ {
+ // Empty the slot completely, the cilent doesn't like left-over ItemType with zero count
+ Slot.Empty();
+ }
+ 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 cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_Apply, bool a_KeepEmptySlots)
+{
+ for (int i = 0; i < m_NumSlots; i++)
+ {
+ const cItem * Slot = GetSlot(i, a_Player);
+ if (!Slot->IsSameType(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_Apply)
+ {
+ 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
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaChest:
+
+cSlotAreaChest::cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow) :
+ cSlotArea(27, a_ParentWindow),
+ m_Chest(a_Chest)
+{
+}
+
+
+
+
+
+const cItem * cSlotAreaChest::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_Chest->GetSlot(a_SlotNum));
+}
+
+
+
+
+
+void cSlotAreaChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+{
+ m_Chest->SetSlot(a_SlotNum, a_Item);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaDoubleChest:
+
+cSlotAreaDoubleChest::cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow) :
+ cSlotArea(54, a_ParentWindow),
+ m_TopChest(a_TopChest),
+ m_BottomChest(a_BottomChest)
+{
+}
+
+
+
+
+
+const cItem * cSlotAreaDoubleChest::GetSlot(int a_SlotNum, cPlayer & a_Player) const
+{
+ // a_SlotNum ranges from 0 to 53, use that to index the correct chest's inventory:
+ if (a_SlotNum < 27)
+ {
+ return &(m_TopChest->GetSlot(a_SlotNum));
+ }
+ else
+ {
+ return &(m_BottomChest->GetSlot(a_SlotNum - 27));
+ }
+}
+
+
+
+
+
+void cSlotAreaDoubleChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+{
+ if (a_SlotNum < 27)
+ {
+ m_TopChest->SetSlot(a_SlotNum, a_Item);
+ }
+ else
+ {
+ m_BottomChest->SetSlot(a_SlotNum - 27, a_Item);
+ }
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaCrafting:
+
+cSlotAreaCrafting::cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow) :
+ cSlotAreaTemporary(1 + a_GridSize * a_GridSize, a_ParentWindow),
+ m_GridSize(a_GridSize)
+{
+ ASSERT((a_GridSize == 2) || (a_GridSize == 3));
+}
+
+
+
+
+
+void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
+{
+ // Override for craft result slot
+ if (a_SlotNum == 0)
+ {
+ if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick))
+ {
+ ShiftClickedResult(a_Player);
+ }
+ else
+ {
+ ClickedResult(a_Player);
+ }
+ return;
+ }
+ super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
+ UpdateRecipe(a_Player);
+}
+
+
+
+
+
+void cSlotAreaCrafting::OnPlayerRemoved(cPlayer & a_Player)
+{
+ // Toss all items on the crafting grid:
+ TossItems(a_Player, 1, m_NumSlots);
+
+ // Remove the current recipe from the player -> recipe map:
+ for (cRecipeMap::iterator itr = m_Recipes.begin(), end = m_Recipes.end(); itr != end; ++itr)
+ {
+ if (itr->first == a_Player.GetUniqueID())
+ {
+ // Remove the player from the recipe map:
+ m_Recipes.erase(itr);
+ return;
+ }
+ } // for itr - m_Recipes[]
+ // Player not found - that is acceptable
+}
+
+
+
+
+
+void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
+{
+ const cItem * ResultSlot = GetSlot(0, a_Player);
+ cItem & DraggingItem = a_Player.GetDraggingItem();
+
+ // Get the current recipe:
+ cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
+
+ cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1;
+ cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize);
+
+ // If possible, craft:
+ if (DraggingItem.IsEmpty())
+ {
+ DraggingItem = Recipe.GetResult();
+ Recipe.ConsumeIngredients(Grid);
+ Grid.CopyToItems(PlayerSlots);
+ }
+ else if (DraggingItem.IsEqual(Recipe.GetResult()))
+ {
+ cItemHandler * Handler = ItemHandler(Recipe.GetResult().m_ItemType);
+ if (DraggingItem.m_ItemCount + Recipe.GetResult().m_ItemCount <= Handler->GetMaxStackSize())
+ {
+ DraggingItem.m_ItemCount += Recipe.GetResult().m_ItemCount;
+ Recipe.ConsumeIngredients(Grid);
+ Grid.CopyToItems(PlayerSlots);
+ }
+ }
+
+ // Get the new recipe and update the result slot:
+ UpdateRecipe(a_Player);
+
+ // We're done. Send all changes to the client and bail out:
+ m_ParentWindow.BroadcastWholeWindow();
+}
+
+
+
+
+
+void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player)
+{
+ cItem Result(*GetSlot(0, a_Player));
+ if (Result.IsEmpty())
+ {
+ return;
+ }
+ cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1;
+ do
+ {
+ // Try distributing the result. If it fails, bail out:
+ cItem ResultCopy(Result);
+ m_ParentWindow.DistributeStack(ResultCopy, a_Player, this, false);
+ if (!ResultCopy.IsEmpty())
+ {
+ // Couldn't distribute all of it. Bail out
+ return;
+ }
+
+ // 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);
+ if (!Recipe.GetResult().IsEqual(Result))
+ {
+ // The recipe has changed, bail out
+ return;
+ }
+ } while (true);
+}
+
+
+
+
+
+void cSlotAreaCrafting::UpdateRecipe(cPlayer & a_Player)
+{
+ cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
+ cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe);
+ SetSlot(0, a_Player, Recipe.GetResult());
+ m_ParentWindow.SendSlot(a_Player, this, 0);
+}
+
+
+
+
+
+cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player)
+{
+ for (cRecipeMap::iterator itr = m_Recipes.begin(), end = m_Recipes.end(); itr != end; ++itr)
+ {
+ if (itr->first == a_Player.GetUniqueID())
+ {
+ return itr->second;
+ }
+ } // for itr - m_Recipes[]
+
+ // Not found. Add a new one:
+ cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
+ cCraftingRecipe Recipe(Grid);
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe);
+ m_Recipes.push_back(std::make_pair(a_Player.GetUniqueID(), Recipe));
+ return m_Recipes.back().second;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaFurnace:
+
+cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow) :
+ cSlotArea(3, a_ParentWindow),
+ m_Furnace(a_Furnace)
+{
+ m_Furnace->GetContents().AddListener(*this);
+}
+
+
+
+
+
+cSlotAreaFurnace::~cSlotAreaFurnace()
+{
+ m_Furnace->GetContents().RemoveListener(*this);
+}
+
+
+
+
+
+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;
+ }
+}
+
+
+
+
+
+const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const
+{
+ // a_SlotNum ranges from 0 to 2, query the items from the underlying furnace:
+ return &(m_Furnace->GetSlot(a_SlotNum));
+}
+
+
+
+
+
+void cSlotAreaFurnace::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+{
+ m_Furnace->SetSlot(a_SlotNum, a_Item);
+}
+
+
+
+
+
+void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
+{
+ // Something has changed in the window, broadcast the entire window to all clients
+ ASSERT(a_ItemGrid == &(m_Furnace->GetContents()));
+
+ m_ParentWindow.BroadcastWholeWindow();
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaInventoryBase:
+
+cSlotAreaInventoryBase::cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow) :
+ cSlotArea(a_NumSlots, a_ParentWindow),
+ m_SlotOffset(a_SlotOffset)
+{
+}
+
+
+
+
+
+void cSlotAreaInventoryBase::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
+{
+ if ((a_Player.GetGameMode() == eGameMode_Creative) && (m_ParentWindow.GetWindowType() == cWindow::Inventory))
+ {
+ // Creative inventory must treat a_ClickedItem as a DraggedItem instead, replacing the inventory slot with it
+ SetSlot(a_SlotNum, a_Player, a_ClickedItem);
+ return;
+ }
+
+ // Survival inventory and all other windows' inventory has the same handling as normal slot areas
+ super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
+ return;
+}
+
+
+
+
+
+const cItem * cSlotAreaInventoryBase::GetSlot(int a_SlotNum, cPlayer & a_Player) const
+{
+ // a_SlotNum ranges from 0 to 35, map that to the player's inventory slots according to the internal offset
+ return &a_Player.GetInventory().GetSlot(a_SlotNum + m_SlotOffset);
+}
+
+
+
+
+
+void cSlotAreaInventoryBase::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+{
+ a_Player.GetInventory().SetSlot(a_SlotNum + m_SlotOffset, a_Item);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaArmor:
+
+void cSlotAreaArmor::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
+{
+ if (ItemCategory::IsHelmet(a_ItemStack.m_ItemType) && GetSlot(0, a_Player)->IsEmpty())
+ {
+ if (a_ShouldApply)
+ {
+ SetSlot(0, a_Player, a_ItemStack.CopyOne());
+ }
+ a_ItemStack.m_ItemCount -= 1;
+ }
+ else if (ItemCategory::IsChestPlate(a_ItemStack.m_ItemType) && GetSlot(1, a_Player)->IsEmpty())
+ {
+ if (a_ShouldApply)
+ {
+ SetSlot(1, a_Player, a_ItemStack.CopyOne());
+ }
+ a_ItemStack.m_ItemCount -= 1;
+ }
+ else if (ItemCategory::IsLeggings(a_ItemStack.m_ItemType) && GetSlot(2, a_Player)->IsEmpty())
+ {
+ if (a_ShouldApply)
+ {
+ SetSlot(2, a_Player, a_ItemStack.CopyOne());
+ }
+ a_ItemStack.m_ItemCount -= 1;
+ }
+ else if (ItemCategory::IsBoots(a_ItemStack.m_ItemType) && GetSlot(3, a_Player)->IsEmpty())
+ {
+ if (a_ShouldApply)
+ {
+ SetSlot(3, a_Player, a_ItemStack.CopyOne());
+ }
+ a_ItemStack.m_ItemCount -= 1;
+ }
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaItemGrid:
+
+cSlotAreaItemGrid::cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow) :
+ super(a_ItemGrid.GetNumSlots(), a_ParentWindow),
+ m_ItemGrid(a_ItemGrid)
+{
+ m_ItemGrid.AddListener(*this);
+}
+
+
+
+
+
+cSlotAreaItemGrid::~cSlotAreaItemGrid()
+{
+ m_ItemGrid.RemoveListener(*this);
+}
+
+
+
+
+
+const cItem * cSlotAreaItemGrid::GetSlot(int a_SlotNum, cPlayer & a_Player) const
+{
+ return &m_ItemGrid.GetSlot(a_SlotNum);
+}
+
+
+
+
+
+void cSlotAreaItemGrid::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+{
+ m_ItemGrid.SetSlot(a_SlotNum, a_Item);
+}
+
+
+
+
+
+void cSlotAreaItemGrid::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
+{
+ ASSERT(a_ItemGrid == &m_ItemGrid);
+ m_ParentWindow.BroadcastSlot(this, a_SlotNum);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaTemporary:
+
+cSlotAreaTemporary::cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow) :
+ cSlotArea(a_NumSlots, a_ParentWindow)
+{
+}
+
+
+
+
+
+const cItem * cSlotAreaTemporary::GetSlot(int a_SlotNum, cPlayer & a_Player) const
+{
+ cItemMap::const_iterator itr = m_Items.find(a_Player.GetUniqueID());
+ if (itr == m_Items.end())
+ {
+ LOGERROR("cSlotAreaTemporary: player \"%s\" not found for slot %d!", a_Player.GetName().c_str(), a_SlotNum);
+ ASSERT(!"cSlotAreaTemporary: player not found!");
+
+ // Player not found, this should not happen, ever! Return NULL, but things may break by this.
+ return NULL;
+ }
+
+ if (a_SlotNum >= (int)(itr->second.size()))
+ {
+ LOGERROR("cSlotAreaTemporary: asking for more slots than actually stored!");
+ ASSERT(!"cSlotAreaTemporary: asking for more slots than actually stored!");
+ return NULL;
+ }
+
+ return &(itr->second[a_SlotNum]);
+}
+
+
+
+
+
+void cSlotAreaTemporary::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+{
+ cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
+ if (itr == m_Items.end())
+ {
+ // Player not found
+ LOGWARNING("cSlotAreaTemporary: player not found!");
+ return;
+ }
+
+ if (a_SlotNum >= (int)(itr->second.size()))
+ {
+ LOGERROR("cSlotAreaTemporary: asking for more slots than actually stored!");
+ return;
+ }
+
+ itr->second[a_SlotNum] = a_Item;
+}
+
+
+
+
+
+void cSlotAreaTemporary::OnPlayerAdded(cPlayer & a_Player)
+{
+ ASSERT(m_Items.find(a_Player.GetUniqueID()) == m_Items.end()); // The player shouldn't be in the itemmap, otherwise we probably have a leak
+ m_Items[a_Player.GetUniqueID()].resize(m_NumSlots); // Make the vector the specified size of empty items
+}
+
+
+
+
+
+void cSlotAreaTemporary::OnPlayerRemoved(cPlayer & a_Player)
+{
+ cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
+ ASSERT(itr != m_Items.end()); // The player should be in the list, otherwise a call to OnPlayerAdded() was mismatched
+ m_Items.erase(itr);
+}
+
+
+
+
+
+void cSlotAreaTemporary::TossItems(cPlayer & a_Player, int a_Begin, int a_End)
+{
+ cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
+ if (itr == m_Items.end())
+ {
+ LOGWARNING("Player tossing items (%s) not found in the item map", a_Player.GetName().c_str());
+ return;
+ }
+
+ cItems Drops;
+ for (int i = a_Begin; i < a_End; i++)
+ {
+ cItem & Item = itr->second[i];
+ if (!Item.IsEmpty())
+ {
+ Drops.push_back(Item);
+ }
+ Item.Empty();
+ } // for i - itr->second[]
+
+ double vX = 0, vY = 0, vZ = 0;
+ EulerToVector(-a_Player.GetRotation(), 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 * 2, vY * 2, vZ * 2);
+}
+
+
+
+
+
+cItem * cSlotAreaTemporary::GetPlayerSlots(cPlayer & a_Player)
+{
+ cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
+ if (itr == m_Items.end())
+ {
+ return NULL;
+ }
+ return &(itr->second[0]);
+}
+
+
+
+
diff --git a/source/UI/SlotArea.h b/source/UI/SlotArea.h
index 516e6d644..943452feb 100644
--- a/source/UI/SlotArea.h
+++ b/source/UI/SlotArea.h
@@ -1,303 +1,303 @@
-
-// SlotArea.h
-
-// Interfaces to the cSlotArea class representing a contiguous area of slots in a UI window
-
-
-
-
-#pragma once
-
-#include "../Inventory.h"
-
-
-
-class cWindow;
-class cPlayer;
-class cChestEntity;
-class cDropSpenserEntity;
-class cFurnaceEntity;
-class cCraftingRecipe;
-
-
-
-
-
-class cSlotArea
-{
-public:
- cSlotArea(int a_NumSlots, cWindow & a_ParentWindow);
- virtual ~cSlotArea() {} // force a virtual destructor in all subclasses
-
- int GetNumSlots(void) const { return m_NumSlots; }
-
- /// Called to retrieve an item in the specified slot for the specified player. Must return a valid cItem.
- virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const = 0;
-
- /// Called to set an item in the specified slot for the specified player
- virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) = 0;
-
- /// 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);
-
- /// Called from Clicked if it is a valid shiftclick
- virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem);
-
- /// Called when a new player opens the same parent window. The window already tracks the player. CS-locked.
- virtual void OnPlayerAdded(cPlayer & a_Player) {} ;
-
- /// Called when one of the players closes the parent window. The window already doesn't track the player. CS-locked.
- virtual void OnPlayerRemoved(cPlayer & a_Player) {} ;
-
- /** Called to store as much of a_ItemStack in the area as possible. a_ItemStack is modified to reflect the change.
- The default implementation searches each slot for available space and distributes the stack there.
- if a_ShouldApply is true, the changes are written into the slots;
- if a_ShouldApply is false, only a_ItemStack is modified to reflect the number of fits (for fit-testing purposes)
- If a_KeepEmptySlots is true, empty slots will be skipped and won't be filled
- */
- virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots);
-
-protected:
- int m_NumSlots;
- cWindow & m_ParentWindow;
-} ;
-
-
-
-
-
-/// Handles any part of the inventory, using parameters in constructor to distinguish between the parts
-class cSlotAreaInventoryBase :
- public cSlotArea
-{
- typedef cSlotArea super;
-
-public:
- cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow);
-
- // Creative inventory's click handling is somewhat different from survival inventory's, handle that here:
- virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) 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;
-
-protected:
- int m_SlotOffset; // Index that this area's slot 0 has in the underlying cInventory
-} ;
-
-
-
-
-
-/// Handles the main inventory of each player, excluding the armor and hotbar
-class cSlotAreaInventory :
- public cSlotAreaInventoryBase
-{
- typedef cSlotAreaInventoryBase super;
-
-public:
- cSlotAreaInventory(cWindow & a_ParentWindow) :
- cSlotAreaInventoryBase(cInventory::invInventoryCount, cInventory::invInventoryOffset, a_ParentWindow)
- {
- }
-} ;
-
-
-
-
-
-/// Handles the hotbar of each player
-class cSlotAreaHotBar :
- public cSlotAreaInventoryBase
-{
- typedef cSlotAreaInventoryBase super;
-
-public:
- cSlotAreaHotBar(cWindow & a_ParentWindow) :
- cSlotAreaInventoryBase(cInventory::invHotbarCount, cInventory::invHotbarOffset, a_ParentWindow)
- {
- }
-} ;
-
-
-
-
-
-/// Handles the armor area of the player's inventory
-class cSlotAreaArmor :
- public cSlotAreaInventoryBase
-{
-public:
- cSlotAreaArmor(cWindow & a_ParentWindow) :
- cSlotAreaInventoryBase(cInventory::invArmorCount, cInventory::invArmorOffset, a_ParentWindow)
- {
- }
-
- // Distributing the stack is allowed only for compatible items (helmets into helmet slot etc.)
- virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
-} ;
-
-
-
-
-
-/// Handles any slot area that is representing a cItemGrid; same items for all the players
-class cSlotAreaItemGrid :
- public cSlotArea,
- public cItemGrid::cListener
-{
- typedef cSlotArea super;
-
-public:
- cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow);
-
- virtual ~cSlotAreaItemGrid();
-
- 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;
-
-protected:
- cItemGrid & m_ItemGrid;
-
- // cItemGrid::cListener overrides:
- virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
-} ;
-
-
-
-
-
-/** A cSlotArea with items layout that is private to each player and is temporary, such as
-a crafting grid or an enchantment table.
-This common ancestor stores the items in a per-player map. It also implements tossing items from the map.
-*/
-class cSlotAreaTemporary :
- public cSlotArea
-{
- typedef cSlotArea super;
-
-public:
- cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow);
-
- // cSlotArea overrides:
- 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;
- virtual void OnPlayerAdded (cPlayer & a_Player) override;
- virtual void OnPlayerRemoved(cPlayer & a_Player) override;
-
- /// Tosses the player's items in slots [a_Begin, a_End) (ie. incl. a_Begin, but excl. a_End)
- void TossItems(cPlayer & a_Player, int a_Begin, int a_End);
-
-protected:
- typedef std::map<int, std::vector<cItem> > cItemMap; // Maps EntityID -> items
-
- cItemMap m_Items;
-
- /// Returns the pointer to the slot array for the player specified.
- cItem * GetPlayerSlots(cPlayer & a_Player);
-} ;
-
-
-
-
-
-class cSlotAreaCrafting :
- public cSlotAreaTemporary
-{
- typedef cSlotAreaTemporary super;
-
-public:
- /// a_GridSize is allowed to be only 2 or 3
- cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow);
-
- // cSlotAreaTemporary overrides:
- virtual void Clicked (cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
- virtual void OnPlayerRemoved(cPlayer & a_Player) 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;
-
- int m_GridSize;
- cRecipeMap m_Recipes;
-
- /// Handles a click in the result slot. Crafts using the current recipe, if possible
- void ClickedResult(cPlayer & a_Player);
-
- /// 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);
-
- /// 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);
-} ;
-
-
-
-
-
-class cSlotAreaChest :
- public cSlotArea
-{
-public:
- cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow);
-
- 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;
-
-protected:
- cChestEntity * m_Chest;
-} ;
-
-
-
-
-
-class cSlotAreaDoubleChest :
- public cSlotArea
-{
-public:
- cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow);
-
- 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;
-
-protected:
- cChestEntity * m_TopChest;
- cChestEntity * m_BottomChest;
-} ;
-
-
-
-
-
-class cSlotAreaFurnace :
- public cSlotArea,
- public cItemGrid::cListener
-{
- typedef cSlotArea super;
-
-public:
- cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow);
-
- virtual ~cSlotAreaFurnace();
-
- virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) 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;
-
-protected:
- cFurnaceEntity * m_Furnace;
-
- // cItemGrid::cListener overrides:
- virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
-} ;
-
-
-
-
+
+// SlotArea.h
+
+// Interfaces to the cSlotArea class representing a contiguous area of slots in a UI window
+
+
+
+
+#pragma once
+
+#include "../Inventory.h"
+
+
+
+class cWindow;
+class cPlayer;
+class cChestEntity;
+class cDropSpenserEntity;
+class cFurnaceEntity;
+class cCraftingRecipe;
+
+
+
+
+
+class cSlotArea
+{
+public:
+ cSlotArea(int a_NumSlots, cWindow & a_ParentWindow);
+ virtual ~cSlotArea() {} // force a virtual destructor in all subclasses
+
+ int GetNumSlots(void) const { return m_NumSlots; }
+
+ /// Called to retrieve an item in the specified slot for the specified player. Must return a valid cItem.
+ virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const = 0;
+
+ /// Called to set an item in the specified slot for the specified player
+ virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) = 0;
+
+ /// 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);
+
+ /// Called from Clicked if it is a valid shiftclick
+ virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem);
+
+ /// Called when a new player opens the same parent window. The window already tracks the player. CS-locked.
+ virtual void OnPlayerAdded(cPlayer & a_Player) {} ;
+
+ /// Called when one of the players closes the parent window. The window already doesn't track the player. CS-locked.
+ virtual void OnPlayerRemoved(cPlayer & a_Player) {} ;
+
+ /** Called to store as much of a_ItemStack in the area as possible. a_ItemStack is modified to reflect the change.
+ The default implementation searches each slot for available space and distributes the stack there.
+ if a_ShouldApply is true, the changes are written into the slots;
+ if a_ShouldApply is false, only a_ItemStack is modified to reflect the number of fits (for fit-testing purposes)
+ If a_KeepEmptySlots is true, empty slots will be skipped and won't be filled
+ */
+ virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots);
+
+protected:
+ int m_NumSlots;
+ cWindow & m_ParentWindow;
+} ;
+
+
+
+
+
+/// Handles any part of the inventory, using parameters in constructor to distinguish between the parts
+class cSlotAreaInventoryBase :
+ public cSlotArea
+{
+ typedef cSlotArea super;
+
+public:
+ cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow);
+
+ // Creative inventory's click handling is somewhat different from survival inventory's, handle that here:
+ virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) 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;
+
+protected:
+ int m_SlotOffset; // Index that this area's slot 0 has in the underlying cInventory
+} ;
+
+
+
+
+
+/// Handles the main inventory of each player, excluding the armor and hotbar
+class cSlotAreaInventory :
+ public cSlotAreaInventoryBase
+{
+ typedef cSlotAreaInventoryBase super;
+
+public:
+ cSlotAreaInventory(cWindow & a_ParentWindow) :
+ cSlotAreaInventoryBase(cInventory::invInventoryCount, cInventory::invInventoryOffset, a_ParentWindow)
+ {
+ }
+} ;
+
+
+
+
+
+/// Handles the hotbar of each player
+class cSlotAreaHotBar :
+ public cSlotAreaInventoryBase
+{
+ typedef cSlotAreaInventoryBase super;
+
+public:
+ cSlotAreaHotBar(cWindow & a_ParentWindow) :
+ cSlotAreaInventoryBase(cInventory::invHotbarCount, cInventory::invHotbarOffset, a_ParentWindow)
+ {
+ }
+} ;
+
+
+
+
+
+/// Handles the armor area of the player's inventory
+class cSlotAreaArmor :
+ public cSlotAreaInventoryBase
+{
+public:
+ cSlotAreaArmor(cWindow & a_ParentWindow) :
+ cSlotAreaInventoryBase(cInventory::invArmorCount, cInventory::invArmorOffset, a_ParentWindow)
+ {
+ }
+
+ // Distributing the stack is allowed only for compatible items (helmets into helmet slot etc.)
+ virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
+} ;
+
+
+
+
+
+/// Handles any slot area that is representing a cItemGrid; same items for all the players
+class cSlotAreaItemGrid :
+ public cSlotArea,
+ public cItemGrid::cListener
+{
+ typedef cSlotArea super;
+
+public:
+ cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow);
+
+ virtual ~cSlotAreaItemGrid();
+
+ 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;
+
+protected:
+ cItemGrid & m_ItemGrid;
+
+ // cItemGrid::cListener overrides:
+ virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
+} ;
+
+
+
+
+
+/** A cSlotArea with items layout that is private to each player and is temporary, such as
+a crafting grid or an enchantment table.
+This common ancestor stores the items in a per-player map. It also implements tossing items from the map.
+*/
+class cSlotAreaTemporary :
+ public cSlotArea
+{
+ typedef cSlotArea super;
+
+public:
+ cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow);
+
+ // cSlotArea overrides:
+ 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;
+ virtual void OnPlayerAdded (cPlayer & a_Player) override;
+ virtual void OnPlayerRemoved(cPlayer & a_Player) override;
+
+ /// Tosses the player's items in slots [a_Begin, a_End) (ie. incl. a_Begin, but excl. a_End)
+ void TossItems(cPlayer & a_Player, int a_Begin, int a_End);
+
+protected:
+ typedef std::map<int, std::vector<cItem> > cItemMap; // Maps EntityID -> items
+
+ cItemMap m_Items;
+
+ /// Returns the pointer to the slot array for the player specified.
+ cItem * GetPlayerSlots(cPlayer & a_Player);
+} ;
+
+
+
+
+
+class cSlotAreaCrafting :
+ public cSlotAreaTemporary
+{
+ typedef cSlotAreaTemporary super;
+
+public:
+ /// a_GridSize is allowed to be only 2 or 3
+ cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow);
+
+ // cSlotAreaTemporary overrides:
+ virtual void Clicked (cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
+ virtual void OnPlayerRemoved(cPlayer & a_Player) 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;
+
+ int m_GridSize;
+ cRecipeMap m_Recipes;
+
+ /// Handles a click in the result slot. Crafts using the current recipe, if possible
+ void ClickedResult(cPlayer & a_Player);
+
+ /// 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);
+
+ /// 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);
+} ;
+
+
+
+
+
+class cSlotAreaChest :
+ public cSlotArea
+{
+public:
+ cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow);
+
+ 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;
+
+protected:
+ cChestEntity * m_Chest;
+} ;
+
+
+
+
+
+class cSlotAreaDoubleChest :
+ public cSlotArea
+{
+public:
+ cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow);
+
+ 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;
+
+protected:
+ cChestEntity * m_TopChest;
+ cChestEntity * m_BottomChest;
+} ;
+
+
+
+
+
+class cSlotAreaFurnace :
+ public cSlotArea,
+ public cItemGrid::cListener
+{
+ typedef cSlotArea super;
+
+public:
+ cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow);
+
+ virtual ~cSlotAreaFurnace();
+
+ virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) 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;
+
+protected:
+ cFurnaceEntity * m_Furnace;
+
+ // cItemGrid::cListener overrides:
+ virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
+} ;
+
+
+
+
diff --git a/source/WebAdmin.cpp b/source/WebAdmin.cpp
index dd1a695ee..3d04ce8f3 100644
--- a/source/WebAdmin.cpp
+++ b/source/WebAdmin.cpp
@@ -13,6 +13,7 @@
#include "Player.h"
#include "Server.h"
#include "Root.h"
+#include "LuaScript.h"
#include "../iniFile/iniFile.h"
@@ -59,6 +60,7 @@ cWebAdmin::cWebAdmin( int a_Port /* = 8080 */ )
{
WebAdmin = this;
m_Event = new cEvent();
+ m_pTemplate = new cLuaScript();
Init( m_Port );
}
@@ -68,10 +70,12 @@ cWebAdmin::cWebAdmin( int a_Port /* = 8080 */ )
cWebAdmin::~cWebAdmin()
{
+
WebAdmin = 0;
m_WebServer->Stop();
delete m_WebServer;
+ delete m_pTemplate;
delete m_IniFile;
m_Event->Wait();
@@ -146,40 +150,17 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
bDontShowTemplate = true;
}
- std::string UserPassword = WebAdmin->m_IniFile->GetValue( "User:"+r->username_, "Password", "");
+ AString UserPassword = WebAdmin->m_IniFile->GetValue( "User:"+r->username_, "Password", "");
if ((UserPassword != "") && (r->password_ == UserPassword))
{
- std::string BaseURL = "./";
- if (Split.size() > 1)
- {
- for (unsigned int i = 0; i < Split.size(); i++)
- {
- BaseURL += "../";
- }
- BaseURL += "webadmin/";
- }
+ AString Template;
- std::string Menu;
- std::string Content;
- std::string Template = bDontShowTemplate ? "{CONTENT}" : WebAdmin->GetTemplate();
- std::string FoundPlugin;
-
- for (PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr)
- {
- cWebPlugin* WebPlugin = *itr;
- std::list< std::pair<std::string, std::string> > NameList = WebPlugin->GetTabNames();
- for( std::list< std::pair<std::string, std::string> >::iterator Names = NameList.begin(); Names != NameList.end(); ++Names )
- {
- Menu += "<li><a href='" + BaseURL + WebPlugin->GetWebTitle().c_str() + "/" + (*Names).second + "'>" + (*Names).first + "</a></li>";
- }
- }
-
- HTTPRequest Request;
- Request.Username = r->username_;
- Request.Method = r->method_;
- Request.Params = r->params_;
- Request.PostParams = r->params_post_;
- Request.Path = r->path_.substr(1);
+ HTTPTemplateRequest TemplateRequest;
+ TemplateRequest.Request.Username = r->username_;
+ TemplateRequest.Request.Method = r->method_;
+ TemplateRequest.Request.Params = r->params_;
+ TemplateRequest.Request.PostParams = r->params_post_;
+ TemplateRequest.Request.Path = r->path_.substr(1);
for( unsigned int i = 0; i < r->multipart_formdata_.size(); ++i )
{
@@ -190,101 +171,90 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
HTTPfd.Type = fd.content_type_;
HTTPfd.Name = fd.name_;
LOGINFO("Form data name: %s", fd.name_.c_str() );
- Request.FormData[ fd.name_ ] = HTTPfd;
+ TemplateRequest.Request.FormData[ fd.name_ ] = HTTPfd;
}
- if (Split.size() > 1)
+ bool bLuaTemplateSuccessful = false;
+ if (!bDontShowTemplate)
{
+ // New Lua web template
+ bLuaTemplateSuccessful = WebAdmin->m_pTemplate->CallFunction("ShowPage", sLuaUsertype(WebAdmin, "cWebAdmin"), sLuaUsertype(&TemplateRequest, "HTTPTemplateRequest"), Template);
+ }
+
+ if (!bLuaTemplateSuccessful)
+ {
+ AString BaseURL = WebAdmin->GetBaseURL(Split);
+ AString Menu;
+ Template = bDontShowTemplate ? "{CONTENT}" : WebAdmin->GetTemplate();
+ AString FoundPlugin;
+
for (PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr)
{
- if ((*itr)->GetWebTitle() == Split[1])
+ cWebPlugin* WebPlugin = *itr;
+ std::list< std::pair<AString, AString> > NameList = WebPlugin->GetTabNames();
+ for( std::list< std::pair<AString, AString> >::iterator Names = NameList.begin(); Names != NameList.end(); ++Names )
{
- Content = (*itr)->HandleWebRequest(&Request);
- cWebPlugin * WebPlugin = *itr;
- FoundPlugin = WebPlugin->GetWebTitle();
- AString TabName = WebPlugin->GetTabNameForRequest(&Request).first;
- if (!TabName.empty())
- {
- FoundPlugin += " - " + TabName;
- }
- break;
+ Menu += "<li><a href='" + BaseURL + WebPlugin->GetWebTitle().c_str() + "/" + (*Names).second + "'>" + (*Names).first + "</a></li>";
}
}
- }
- if( FoundPlugin.empty() ) // Default page
- {
- Content.clear();
- FoundPlugin = "Current Game";
- Content += "<h4>Server Name:</h4>";
- Content += "<p>" + std::string( cRoot::Get()->GetServer()->GetServerID() ) + "</p>";
-
- Content += "<h4>Plugins:</h4><ul>";
- cPluginManager* PM = cRoot::Get()->GetPluginManager();
- if( PM )
+ sWebAdminPage Page = WebAdmin->GetPage(TemplateRequest.Request);
+ AString Content = Page.Content;
+ FoundPlugin = Page.PluginName;
+ if (!Page.TabName.empty())
+ FoundPlugin += " - " + Page.TabName;
+
+ if( FoundPlugin.empty() ) // Default page
{
- const cPluginManager::PluginMap & List = PM->GetAllPlugins();
- for( cPluginManager::PluginMap::const_iterator itr = List.begin(); itr != List.end(); ++itr )
+ Content.clear();
+ FoundPlugin = "Current Game";
+ Content += "<h4>Server Name:</h4>";
+ Content += "<p>" + AString( cRoot::Get()->GetServer()->GetServerID() ) + "</p>";
+
+ Content += "<h4>Plugins:</h4><ul>";
+ cPluginManager* PM = cRoot::Get()->GetPluginManager();
+ if( PM )
{
- if( itr->second == NULL ) continue;
- AString VersionNum;
- AppendPrintf(Content, "<li>%s V.%i</li>", itr->second->GetName().c_str(), itr->second->GetVersion());
+ const cPluginManager::PluginMap & List = PM->GetAllPlugins();
+ for( cPluginManager::PluginMap::const_iterator itr = List.begin(); itr != List.end(); ++itr )
+ {
+ if( itr->second == NULL ) continue;
+ AString VersionNum;
+ AppendPrintf(Content, "<li>%s V.%i</li>", itr->second->GetName().c_str(), itr->second->GetVersion());
+ }
}
- }
- Content += "</ul>";
- Content += "<h4>Players:</h4><ul>";
+ Content += "</ul>";
+ Content += "<h4>Players:</h4><ul>";
- cPlayerAccum PlayerAccum;
- cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players
- if( World != NULL )
- {
- World->ForEachPlayer(PlayerAccum);
- Content.append(PlayerAccum.m_Contents);
+ cPlayerAccum PlayerAccum;
+ cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players
+ if( World != NULL )
+ {
+ World->ForEachPlayer(PlayerAccum);
+ Content.append(PlayerAccum.m_Contents);
+ }
+ Content += "</ul><br>";
}
- Content += "</ul><br>";
- }
-
+
- if (!bDontShowTemplate && (Split.size() > 1))
- {
- Content += "\n<p><a href='" + BaseURL + "'>Go back</a></p>";
- }
+ if (!bDontShowTemplate && (Split.size() > 1))
+ {
+ Content += "\n<p><a href='" + BaseURL + "'>Go back</a></p>";
+ }
- // mem usage
-#ifndef _WIN32
- rusage resource_usage;
- if (getrusage(RUSAGE_SELF, &resource_usage) != 0)
- {
- ReplaceString( Template, std::string("{MEM}"), "Error :(" );
+ AString MemUsage = GetMemoryUsage();
+ ReplaceString(Template, "{MEM}", MemUsage);
+ ReplaceString(Template, "{USERNAME}", r->username_);
+ ReplaceString(Template, "{MENU}", Menu);
+ ReplaceString(Template, "{PLUGIN_NAME}", FoundPlugin);
+ ReplaceString(Template, "{CONTENT}", Content);
+ ReplaceString(Template, "{TITLE}", "MCServer");
+
+ AString NumChunks;
+ Printf(NumChunks, "%d", cRoot::Get()->GetTotalChunkCount());
+ ReplaceString(Template, "{NUMCHUNKS}", NumChunks);
}
- else
- {
- AString MemUsage;
- Printf(MemUsage, "%0.2f", ((double)resource_usage.ru_maxrss / 1024 / 1024) );
- ReplaceString(Template, std::string("{MEM}"), MemUsage);
- }
-#else
- HANDLE hProcess = GetCurrentProcess();
- PROCESS_MEMORY_COUNTERS pmc;
- if( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc) ) )
- {
- AString MemUsage;
- Printf(MemUsage, "%0.2f", (pmc.WorkingSetSize / 1024.f / 1024.f) );
- ReplaceString( Template, "{MEM}", MemUsage );
- }
-#endif
- // end mem usage
-
- ReplaceString( Template, "{USERNAME}", r->username_ );
- ReplaceString( Template, "{MENU}", Menu );
- ReplaceString( Template, "{PLUGIN_NAME}", FoundPlugin );
- ReplaceString( Template, "{CONTENT}", Content );
- ReplaceString( Template, "{TITLE}", "MCServer" );
-
- AString NumChunks;
- Printf(NumChunks, "%d", cRoot::Get()->GetTotalChunkCount());
- ReplaceString(Template, "{NUMCHUNKS}", NumChunks);
r->answer_ = Template;
}
@@ -309,6 +279,14 @@ bool cWebAdmin::Init( int a_Port )
m_Port = m_IniFile->GetValueI("WebAdmin", "Port", 8080 );
}
+ // Initialize the WebAdmin template script and load the file
+ m_pTemplate->Initialize();
+ if (!m_pTemplate->LoadFile( FILE_IO_PREFIX "webadmin/template.lua") || !m_pTemplate->Execute())
+ {
+ LOGWARN("Could not load WebAdmin template.");
+ }
+
+
LOG("Starting WebAdmin on port %i", m_Port);
#ifdef _WIN32
@@ -354,9 +332,9 @@ void *cWebAdmin::ListenThread( void *lpParam )
-std::string cWebAdmin::GetTemplate()
+AString cWebAdmin::GetTemplate()
{
- std::string retVal = "";
+ AString retVal = "";
char SourceFile[] = "webadmin/template.html";
@@ -370,4 +348,91 @@ std::string cWebAdmin::GetTemplate()
f.ReadRestOfFile(retVal);
return retVal;
-} \ No newline at end of file
+}
+
+
+
+
+
+sWebAdminPage cWebAdmin::GetPage(const HTTPRequest& a_Request)
+{
+ sWebAdminPage Page;
+ AStringVector Split = StringSplit(a_Request.Path, "/");
+
+ // Find the plugin that corresponds to the requested path
+ AString FoundPlugin;
+ if (Split.size() > 1)
+ {
+ for (PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr)
+ {
+ if ((*itr)->GetWebTitle() == Split[1])
+ {
+ Page.Content = (*itr)->HandleWebRequest(&a_Request);
+ cWebPlugin * WebPlugin = *itr;
+ FoundPlugin = WebPlugin->GetWebTitle();
+ AString TabName = WebPlugin->GetTabNameForRequest(&a_Request).first;
+ Page.PluginName = FoundPlugin;
+ Page.TabName = TabName;
+ break;
+ }
+ }
+ }
+
+ // Return the page contents
+ return Page;
+}
+
+
+
+
+
+AString cWebAdmin::GetBaseURL( const AString& a_URL )
+{
+ return GetBaseURL(StringSplit(a_URL, "/"));
+}
+
+
+
+
+
+AString cWebAdmin::GetBaseURL( const AStringVector& a_URLSplit )
+{
+ AString BaseURL = "./";
+ if (a_URLSplit.size() > 1)
+ {
+ for (unsigned int i = 0; i < a_URLSplit.size(); i++)
+ {
+ BaseURL += "../";
+ }
+ BaseURL += "webadmin/";
+ }
+ return BaseURL;
+}
+
+
+
+
+
+AString cWebAdmin::GetMemoryUsage(void)
+{
+ AString MemUsage;
+#ifndef _WIN32
+ rusage resource_usage;
+ if (getrusage(RUSAGE_SELF, &resource_usage) != 0)
+ {
+ MemUsage = "Error :(";
+ }
+ else
+ {
+ Printf(MemUsage, "%0.2f", ((double)resource_usage.ru_maxrss / 1024 / 1024) );
+ }
+#else
+ HANDLE hProcess = GetCurrentProcess();
+ PROCESS_MEMORY_COUNTERS pmc;
+ if( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc) ) )
+ {
+ Printf(MemUsage, "%0.2f", (pmc.WorkingSetSize / 1024.f / 1024.f) );
+ }
+#endif
+ return MemUsage;
+}
diff --git a/source/WebAdmin.h b/source/WebAdmin.h
index ad733e704..4b12b955e 100644
--- a/source/WebAdmin.h
+++ b/source/WebAdmin.h
@@ -4,66 +4,93 @@
#include "OSSupport/Socket.h"
class cStringMap;
+class cLuaScript;
-struct HTTPFormData // tolua_export
-{ // tolua_export
- std::string Name; // tolua_export
- std::string Value; // tolua_export
- std::string Type; // tolua_export
+struct HTTPFormData // tolua_export
+{ // tolua_export
+ std::string Name; // tolua_export
+ std::string Value; // tolua_export
+ std::string Type; // tolua_export
};// tolua_export
-struct HTTPRequest // tolua_export
-{ // tolua_export
+struct HTTPRequest // tolua_export
+{ // tolua_export
typedef std::map< std::string, std::string > StringStringMap;
typedef std::map< std::string, HTTPFormData > FormDataMap;
- std::string Method; // tolua_export
- std::string Path; // tolua_export
- StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS <<
- StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS <<
- std::string Username; // tolua_export
- FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS <<
+ AString Method; // tolua_export
+ AString Path; // tolua_export
+ StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS <<
+ StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS <<
+ AString Username; // tolua_export
+ FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS <<
}; // tolua_export
+struct HTTPTemplateRequest // tolua_export
+{ // tolua_export
+ HTTPRequest Request; // tolua_export
+
+}; // tolua_export
+
+// tolua_begin
+struct sWebAdminPage
+{
+ AString Content;
+ AString PluginName;
+ AString TabName;
+};
+// tolua_end
+
struct lua_State;
class cEvent;
class cIniFile;
class cWebPlugin;
-class cWebAdmin
-{
-public:
+
+class cWebAdmin // tolua_export
+{ // tolua_export
+public: // tolua_export
cWebAdmin( int a_Port = 8080 );
~cWebAdmin();
- bool Init( int a_Port );
+ bool Init( int a_Port );
- void AddPlugin( cWebPlugin* a_Plugin );
- void RemovePlugin( cWebPlugin* a_Plugin );
+ void AddPlugin( cWebPlugin* a_Plugin );
+ void RemovePlugin( cWebPlugin* a_Plugin );
typedef std::list< cWebPlugin* > PluginList;
- PluginList GetPlugins() { return m_Plugins; }
- static void Request_Handler(webserver::http_request* r);
+ // 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 <<
+
+ static void Request_Handler(webserver::http_request* r);
+
+ int GetPort() { return m_Port; } // tolua_export
- int GetPort() { return m_Port; }
+ sWebAdminPage GetPage(const HTTPRequest& a_Request); // tolua_export
+ AString GetBaseURL(const AString& a_URL); // tolua_export
+ AString GetBaseURL(const AStringVector& a_URLSplit);
+
+ static AString GetMemoryUsage(void); // tolua_export
private:
#ifdef _WIN32
static DWORD WINAPI ListenThread(LPVOID lpParam);
#else
- static void *ListenThread( void *lpParam );
+ static void * ListenThread( void *lpParam );
#endif
- std::string GetTemplate();
+ AString GetTemplate();
+
+ cLuaScript* m_pTemplate;
- int m_Port;
+ int m_Port;
- bool m_bConnected;
- cSocket m_ListenSocket;
+ bool m_bConnected;
+ cSocket m_ListenSocket;
- cIniFile* m_IniFile;
- PluginList m_Plugins;
+ cIniFile* m_IniFile;
+ PluginList m_Plugins;
- cEvent* m_Event;
+ cEvent* m_Event;
- webserver* m_WebServer;
-}; \ No newline at end of file
+ webserver* m_WebServer;
+}; // tolua_export \ No newline at end of file
diff --git a/source/WebPlugin.cpp b/source/WebPlugin.cpp
index 343ca64fa..48ddb2076 100644
--- a/source/WebPlugin.cpp
+++ b/source/WebPlugin.cpp
@@ -59,7 +59,7 @@ std::list<std::pair<AString, AString> > cWebPlugin::GetTabNames(void)
-std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(HTTPRequest * a_Request)
+std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest * a_Request)
{
std::pair< AString, AString > Names;
AStringVector Split = StringSplit(a_Request->Path, "/");
diff --git a/source/WebPlugin.h b/source/WebPlugin.h
index 160c3c126..22587b892 100644
--- a/source/WebPlugin.h
+++ b/source/WebPlugin.h
@@ -16,10 +16,10 @@ public:
cWebPlugin();
virtual ~cWebPlugin();
- virtual const AString & GetWebTitle(void) const = 0;
// tolua_begin
+ virtual const AString GetWebTitle(void) const = 0;
- virtual AString HandleWebRequest( HTTPRequest * a_Request ) = 0;
+ virtual AString HandleWebRequest(const HTTPRequest * a_Request ) = 0;
static AString SafeString( const AString & a_String );
// tolua_end
@@ -35,8 +35,9 @@ public:
typedef std::list< sWebPluginTab* > TabList;
TabList & GetTabs() { return m_Tabs; }
- std::list< std::pair<AString, AString> > GetTabNames();
- std::pair< AString, AString > GetTabNameForRequest( HTTPRequest* a_Request );
+ typedef std::list< std::pair<AString, AString> > TabNameList;
+ TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS <<
+ std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request );
private:
TabList m_Tabs;
diff --git a/source/World.h b/source/World.h
index 5da7218e2..e67b06789 100644
--- a/source/World.h
+++ b/source/World.h
@@ -106,7 +106,18 @@ public:
SetTimeOfDay(a_TimeOfDay);
}
+ /// Returns the current game mode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable
eGameMode GetGameMode(void) const { return m_GameMode; }
+
+ /// Returns true if the world is in Creative mode
+ bool IsGameModeCreative(void) const { return (m_GameMode == gmCreative); }
+
+ /// Returns true if the world is in Survival mode
+ bool IsGameModeSurvival(void) const { return (m_GameMode == gmSurvival); }
+
+ /// Returns true if the world is in Adventure mode
+ bool IsGameModeAdventure(void) const { return (m_GameMode == gmAdventure); }
+
bool IsPVPEnabled(void) const { return m_bEnabledPVP; }
bool IsDeepSnowEnabled(void) const { return m_IsDeepSnowEnabled; }
diff --git a/source/WorldStorage/NBTChunkSerializer.cpp b/source/WorldStorage/NBTChunkSerializer.cpp
index d391325c9..da1b9e1c4 100644
--- a/source/WorldStorage/NBTChunkSerializer.cpp
+++ b/source/WorldStorage/NBTChunkSerializer.cpp
@@ -1,459 +1,459 @@
-
-// NBTChunkSerializer.cpp
-
-
-#include "Globals.h"
-#include "NBTChunkSerializer.h"
-#include "../BlockID.h"
-#include "../BlockEntities/ChestEntity.h"
-#include "../BlockEntities/DispenserEntity.h"
-#include "../BlockEntities/DropperEntity.h"
-#include "../BlockEntities/FurnaceEntity.h"
-#include "../BlockEntities/HopperEntity.h"
-#include "../BlockEntities/JukeboxEntity.h"
-#include "../BlockEntities/NoteEntity.h"
-#include "../BlockEntities/SignEntity.h"
-#include "../ItemGrid.h"
-#include "../StringCompression.h"
-#include "../Entity.h"
-#include "../OSSupport/MakeDir.h"
-#include "FastNBT.h"
-#include "../FallingBlock.h"
-#include "../Minecart.h"
-#include "../Mobs/Monster.h"
-#include "../Pickup.h"
-
-
-
-
-cNBTChunkSerializer::cNBTChunkSerializer(cFastNBTWriter & a_Writer) :
- m_BiomesAreValid(false),
- m_Writer(a_Writer),
- m_IsTagOpen(false),
- m_HasHadEntity(false),
- m_HasHadBlockEntity(false),
- m_IsLightValid(false)
-{
-}
-
-
-
-
-
-void cNBTChunkSerializer::Finish(void)
-{
- if (m_IsTagOpen)
- {
- m_Writer.EndList();
- }
-
- // If light not valid, reset it to all zeroes:
- if (!m_IsLightValid)
- {
- memset(m_BlockLight, 0, sizeof(m_BlockLight));
- memset(m_BlockSkyLight, 0, sizeof(m_BlockSkyLight));
- }
-}
-
-
-
-
-
-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);
- if (a_Slot >= 0)
- {
- m_Writer.AddByte ("Slot", (unsigned char)a_Slot);
- }
-
- // Write the enchantments:
- if (!a_Item.m_Enchantments.IsEmpty())
- {
- const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
- m_Writer.BeginCompound("tag");
- a_Item.m_Enchantments.WriteToNBTCompound(m_Writer, TagName);
- m_Writer.EndCompound();
- }
-
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddItemGrid(const cItemGrid & a_Grid, int a_BeginSlotNum)
-{
- int NumSlots = a_Grid.GetNumSlots();
- for (int i = 0; i < NumSlots; i++)
- {
- const cItem & Item = a_Grid.GetSlot(i);
- if (Item.IsEmpty())
- {
- continue;
- }
- AddItem(Item, i + a_BeginSlotNum);
- } // for i - chest slots[]
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID)
-{
- m_Writer.AddInt ("x", a_Entity->GetPosX());
- m_Writer.AddInt ("y", a_Entity->GetPosY());
- m_Writer.AddInt ("z", a_Entity->GetPosZ());
- m_Writer.AddString("id", a_EntityTypeID);
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity)
-{
- m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Chest");
- m_Writer.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Entity->GetContents());
- m_Writer.EndList();
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddDispenserEntity(cDispenserEntity * a_Entity)
-{
- m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Trap");
- m_Writer.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Entity->GetContents());
- m_Writer.EndList();
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddDropperEntity(cDropperEntity * a_Entity)
-{
- m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Dropper");
- m_Writer.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Entity->GetContents());
- m_Writer.EndList();
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddFurnaceEntity(cFurnaceEntity * a_Furnace)
-{
- m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Furnace, "Furnace");
- m_Writer.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Furnace->GetContents());
- m_Writer.EndList();
- m_Writer.AddShort("BurnTime", a_Furnace->GetFuelBurnTimeLeft());
- m_Writer.AddShort("CookTime", a_Furnace->GetTimeCooked());
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddHopperEntity(cHopperEntity * a_Entity)
-{
- m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Hopper");
- m_Writer.BeginList("Items", TAG_Compound);
- AddItemGrid(a_Entity->GetContents());
- m_Writer.EndList();
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddJukeboxEntity(cJukeboxEntity * a_Jukebox)
-{
- m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Jukebox, "RecordPlayer");
- m_Writer.AddInt("Record", a_Jukebox->GetRecord());
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddNoteEntity(cNoteEntity * a_Note)
-{
- m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Note, "Music");
- m_Writer.AddByte("note", a_Note->GetPitch());
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddSignEntity(cSignEntity * a_Sign)
-{
- m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Sign, "Sign");
- m_Writer.AddString("Text1", a_Sign->GetLine(0));
- m_Writer.AddString("Text2", a_Sign->GetLine(1));
- m_Writer.AddString("Text3", a_Sign->GetLine(2));
- m_Writer.AddString("Text4", a_Sign->GetLine(3));
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddBasicEntity(cEntity * a_Entity, const AString & a_ClassName)
-{
- m_Writer.AddString("id", a_ClassName);
- m_Writer.BeginList("Pos", TAG_Double);
- m_Writer.AddDouble("", a_Entity->GetPosX());
- m_Writer.AddDouble("", a_Entity->GetPosY());
- m_Writer.AddDouble("", a_Entity->GetPosZ());
- m_Writer.EndList();
- m_Writer.BeginList("Motion", TAG_Double);
- m_Writer.AddDouble("", a_Entity->GetSpeedX());
- m_Writer.AddDouble("", a_Entity->GetSpeedY());
- m_Writer.AddDouble("", a_Entity->GetSpeedZ());
- m_Writer.EndList();
- m_Writer.BeginList("Rotation", TAG_Double);
- m_Writer.AddDouble("", a_Entity->GetRotation());
- m_Writer.AddDouble("", a_Entity->GetPitch());
- m_Writer.EndList();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddFallingBlockEntity(cFallingBlock * a_FallingBlock)
-{
- m_Writer.BeginCompound("");
- AddBasicEntity(a_FallingBlock, "FallingSand");
- m_Writer.AddInt("TileID", a_FallingBlock->GetBlockType());
- m_Writer.AddByte("Data", a_FallingBlock->GetBlockMeta());
- m_Writer.AddByte("Time", 1); // Unused in MCServer, Vanilla said to need nonzero
- m_Writer.AddByte("DropItem", 1);
- m_Writer.AddByte("HurtEntities", a_FallingBlock->GetBlockType() == E_BLOCK_ANVIL);
- m_Writer.EndCompound();
-}
-
-
-
-
-
-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;
- default:
- {
- ASSERT(!"Unhandled minecart payload type");
- return;
- }
- } // switch (payload)
-
- m_Writer.BeginCompound("");
- AddBasicEntity(a_Minecart, EntityClass);
- switch (a_Minecart->GetPayload())
- {
- case cMinecart::mpChest:
- {
- // Add chest contents into the Items tag:
- AddMinecartChestContents((cMinecartWithChest *)a_Minecart);
- break;
- }
-
- case cMinecart::mpFurnace:
- {
- // TODO: Add "Push" and "Fuel" tags
- break;
- }
- } // switch (Payload)
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
-{
- // TODO
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddPickupEntity(cPickup * a_Pickup)
-{
- m_Writer.BeginCompound("");
- AddBasicEntity(a_Pickup, "Item");
- AddItem(a_Pickup->GetItem(), -1, "Item");
- m_Writer.AddShort("Health", a_Pickup->GetHealth());
- m_Writer.AddShort("Age", a_Pickup->GetAge());
- m_Writer.EndCompound();
-}
-
-
-
-
-
-void cNBTChunkSerializer::AddMinecartChestContents(cMinecartWithChest * a_Minecart)
-{
- m_Writer.BeginList("Items", TAG_Compound);
- for (int i = 0; i < cMinecartWithChest::NumSlots; i++)
- {
- const cItem & Item = a_Minecart->GetSlot(i);
- if (Item.IsEmpty())
- {
- continue;
- }
- AddItem(Item, i);
- }
- m_Writer.EndList();
-}
-
-
-
-
-
-bool cNBTChunkSerializer::LightIsValid(bool a_IsLightValid)
-{
- m_IsLightValid = a_IsLightValid;
- return a_IsLightValid; // We want lighting only if it's valid, otherwise don't bother
-}
-
-
-
-
-
-void cNBTChunkSerializer::BiomeData(const cChunkDef::BiomeMap * a_BiomeMap)
-{
- memcpy(m_Biomes, a_BiomeMap, sizeof(m_Biomes));
- for (int i = 0; i < ARRAYCOUNT(m_Biomes); i++)
- {
- if ((*a_BiomeMap)[i] < 255)
- {
- // Normal MC biome, copy as-is:
- m_VanillaBiomes[i] = (unsigned char)((*a_BiomeMap)[i]);
- }
- else
- {
- // TODO: MCS-specific biome, need to map to some basic MC biome:
- ASSERT(!"Unimplemented MCS-specific biome");
- return;
- }
- } // for i - m_BiomeMap[]
- m_BiomesAreValid = true;
-}
-
-
-
-
-
-void cNBTChunkSerializer::Entity(cEntity * a_Entity)
-{
- // Add entity into NBT:
- if (m_IsTagOpen)
- {
- if (!m_HasHadEntity)
- {
- m_Writer.EndList();
- m_Writer.BeginList("Entities", TAG_Compound);
- }
- }
- else
- {
- m_Writer.BeginList("Entities", TAG_Compound);
- }
- m_IsTagOpen = true;
- m_HasHadEntity = true;
-
- switch (a_Entity->GetEntityType())
- {
- case cEntity::etFallingBlock: AddFallingBlockEntity((cFallingBlock *)a_Entity); break;
- case cEntity::etMinecart: AddMinecartEntity ((cMinecart *) a_Entity); break;
- case cEntity::etMonster: AddMonsterEntity ((cMonster *) a_Entity); break;
- case cEntity::etPickup: AddPickupEntity ((cPickup *) a_Entity); break;
- case cEntity::etPlayer: return; // Players aren't saved into the world
- default:
- {
- ASSERT(!"Unhandled entity type is being saved");
- break;
- }
- }
-}
-
-
-
-
-
-void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
-{
- if (m_IsTagOpen)
- {
- if (!m_HasHadBlockEntity)
- {
- m_Writer.EndList();
- m_Writer.BeginList("TileEntities", TAG_Compound);
- }
- }
- else
- {
- m_Writer.BeginList("TileEntities", TAG_Compound);
- }
- m_IsTagOpen = true;
-
- // 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_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_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
- case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break;
- default:
- {
- ASSERT(!"Unhandled block entity saved into Anvil");
- }
- }
- m_HasHadBlockEntity = true;
-}
-
-
-
-
+
+// NBTChunkSerializer.cpp
+
+
+#include "Globals.h"
+#include "NBTChunkSerializer.h"
+#include "../BlockID.h"
+#include "../BlockEntities/ChestEntity.h"
+#include "../BlockEntities/DispenserEntity.h"
+#include "../BlockEntities/DropperEntity.h"
+#include "../BlockEntities/FurnaceEntity.h"
+#include "../BlockEntities/HopperEntity.h"
+#include "../BlockEntities/JukeboxEntity.h"
+#include "../BlockEntities/NoteEntity.h"
+#include "../BlockEntities/SignEntity.h"
+#include "../ItemGrid.h"
+#include "../StringCompression.h"
+#include "../Entity.h"
+#include "../OSSupport/MakeDir.h"
+#include "FastNBT.h"
+#include "../FallingBlock.h"
+#include "../Minecart.h"
+#include "../Mobs/Monster.h"
+#include "../Pickup.h"
+
+
+
+
+cNBTChunkSerializer::cNBTChunkSerializer(cFastNBTWriter & a_Writer) :
+ m_BiomesAreValid(false),
+ m_Writer(a_Writer),
+ m_IsTagOpen(false),
+ m_HasHadEntity(false),
+ m_HasHadBlockEntity(false),
+ m_IsLightValid(false)
+{
+}
+
+
+
+
+
+void cNBTChunkSerializer::Finish(void)
+{
+ if (m_IsTagOpen)
+ {
+ m_Writer.EndList();
+ }
+
+ // If light not valid, reset it to all zeroes:
+ if (!m_IsLightValid)
+ {
+ memset(m_BlockLight, 0, sizeof(m_BlockLight));
+ memset(m_BlockSkyLight, 0, sizeof(m_BlockSkyLight));
+ }
+}
+
+
+
+
+
+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);
+ if (a_Slot >= 0)
+ {
+ m_Writer.AddByte ("Slot", (unsigned char)a_Slot);
+ }
+
+ // Write the enchantments:
+ if (!a_Item.m_Enchantments.IsEmpty())
+ {
+ const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
+ m_Writer.BeginCompound("tag");
+ a_Item.m_Enchantments.WriteToNBTCompound(m_Writer, TagName);
+ m_Writer.EndCompound();
+ }
+
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddItemGrid(const cItemGrid & a_Grid, int a_BeginSlotNum)
+{
+ int NumSlots = a_Grid.GetNumSlots();
+ for (int i = 0; i < NumSlots; i++)
+ {
+ const cItem & Item = a_Grid.GetSlot(i);
+ if (Item.IsEmpty())
+ {
+ continue;
+ }
+ AddItem(Item, i + a_BeginSlotNum);
+ } // for i - chest slots[]
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID)
+{
+ m_Writer.AddInt ("x", a_Entity->GetPosX());
+ m_Writer.AddInt ("y", a_Entity->GetPosY());
+ m_Writer.AddInt ("z", a_Entity->GetPosZ());
+ m_Writer.AddString("id", a_EntityTypeID);
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity)
+{
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Entity, "Chest");
+ m_Writer.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Entity->GetContents());
+ m_Writer.EndList();
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddDispenserEntity(cDispenserEntity * a_Entity)
+{
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Entity, "Trap");
+ m_Writer.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Entity->GetContents());
+ m_Writer.EndList();
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddDropperEntity(cDropperEntity * a_Entity)
+{
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Entity, "Dropper");
+ m_Writer.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Entity->GetContents());
+ m_Writer.EndList();
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddFurnaceEntity(cFurnaceEntity * a_Furnace)
+{
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Furnace, "Furnace");
+ m_Writer.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Furnace->GetContents());
+ m_Writer.EndList();
+ m_Writer.AddShort("BurnTime", a_Furnace->GetFuelBurnTimeLeft());
+ m_Writer.AddShort("CookTime", a_Furnace->GetTimeCooked());
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddHopperEntity(cHopperEntity * a_Entity)
+{
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Entity, "Hopper");
+ m_Writer.BeginList("Items", TAG_Compound);
+ AddItemGrid(a_Entity->GetContents());
+ m_Writer.EndList();
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddJukeboxEntity(cJukeboxEntity * a_Jukebox)
+{
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Jukebox, "RecordPlayer");
+ m_Writer.AddInt("Record", a_Jukebox->GetRecord());
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddNoteEntity(cNoteEntity * a_Note)
+{
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Note, "Music");
+ m_Writer.AddByte("note", a_Note->GetPitch());
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddSignEntity(cSignEntity * a_Sign)
+{
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Sign, "Sign");
+ m_Writer.AddString("Text1", a_Sign->GetLine(0));
+ m_Writer.AddString("Text2", a_Sign->GetLine(1));
+ m_Writer.AddString("Text3", a_Sign->GetLine(2));
+ m_Writer.AddString("Text4", a_Sign->GetLine(3));
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddBasicEntity(cEntity * a_Entity, const AString & a_ClassName)
+{
+ m_Writer.AddString("id", a_ClassName);
+ m_Writer.BeginList("Pos", TAG_Double);
+ m_Writer.AddDouble("", a_Entity->GetPosX());
+ m_Writer.AddDouble("", a_Entity->GetPosY());
+ m_Writer.AddDouble("", a_Entity->GetPosZ());
+ m_Writer.EndList();
+ m_Writer.BeginList("Motion", TAG_Double);
+ m_Writer.AddDouble("", a_Entity->GetSpeedX());
+ m_Writer.AddDouble("", a_Entity->GetSpeedY());
+ m_Writer.AddDouble("", a_Entity->GetSpeedZ());
+ m_Writer.EndList();
+ m_Writer.BeginList("Rotation", TAG_Double);
+ m_Writer.AddDouble("", a_Entity->GetRotation());
+ m_Writer.AddDouble("", a_Entity->GetPitch());
+ m_Writer.EndList();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddFallingBlockEntity(cFallingBlock * a_FallingBlock)
+{
+ m_Writer.BeginCompound("");
+ AddBasicEntity(a_FallingBlock, "FallingSand");
+ m_Writer.AddInt("TileID", a_FallingBlock->GetBlockType());
+ m_Writer.AddByte("Data", a_FallingBlock->GetBlockMeta());
+ m_Writer.AddByte("Time", 1); // Unused in MCServer, Vanilla said to need nonzero
+ m_Writer.AddByte("DropItem", 1);
+ m_Writer.AddByte("HurtEntities", a_FallingBlock->GetBlockType() == E_BLOCK_ANVIL);
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+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;
+ default:
+ {
+ ASSERT(!"Unhandled minecart payload type");
+ return;
+ }
+ } // switch (payload)
+
+ m_Writer.BeginCompound("");
+ AddBasicEntity(a_Minecart, EntityClass);
+ switch (a_Minecart->GetPayload())
+ {
+ case cMinecart::mpChest:
+ {
+ // Add chest contents into the Items tag:
+ AddMinecartChestContents((cMinecartWithChest *)a_Minecart);
+ break;
+ }
+
+ case cMinecart::mpFurnace:
+ {
+ // TODO: Add "Push" and "Fuel" tags
+ break;
+ }
+ } // switch (Payload)
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
+{
+ // TODO
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddPickupEntity(cPickup * a_Pickup)
+{
+ m_Writer.BeginCompound("");
+ AddBasicEntity(a_Pickup, "Item");
+ AddItem(a_Pickup->GetItem(), -1, "Item");
+ m_Writer.AddShort("Health", a_Pickup->GetHealth());
+ m_Writer.AddShort("Age", a_Pickup->GetAge());
+ m_Writer.EndCompound();
+}
+
+
+
+
+
+void cNBTChunkSerializer::AddMinecartChestContents(cMinecartWithChest * a_Minecart)
+{
+ m_Writer.BeginList("Items", TAG_Compound);
+ for (int i = 0; i < cMinecartWithChest::NumSlots; i++)
+ {
+ const cItem & Item = a_Minecart->GetSlot(i);
+ if (Item.IsEmpty())
+ {
+ continue;
+ }
+ AddItem(Item, i);
+ }
+ m_Writer.EndList();
+}
+
+
+
+
+
+bool cNBTChunkSerializer::LightIsValid(bool a_IsLightValid)
+{
+ m_IsLightValid = a_IsLightValid;
+ return a_IsLightValid; // We want lighting only if it's valid, otherwise don't bother
+}
+
+
+
+
+
+void cNBTChunkSerializer::BiomeData(const cChunkDef::BiomeMap * a_BiomeMap)
+{
+ memcpy(m_Biomes, a_BiomeMap, sizeof(m_Biomes));
+ for (int i = 0; i < ARRAYCOUNT(m_Biomes); i++)
+ {
+ if ((*a_BiomeMap)[i] < 255)
+ {
+ // Normal MC biome, copy as-is:
+ m_VanillaBiomes[i] = (unsigned char)((*a_BiomeMap)[i]);
+ }
+ else
+ {
+ // TODO: MCS-specific biome, need to map to some basic MC biome:
+ ASSERT(!"Unimplemented MCS-specific biome");
+ return;
+ }
+ } // for i - m_BiomeMap[]
+ m_BiomesAreValid = true;
+}
+
+
+
+
+
+void cNBTChunkSerializer::Entity(cEntity * a_Entity)
+{
+ // Add entity into NBT:
+ if (m_IsTagOpen)
+ {
+ if (!m_HasHadEntity)
+ {
+ m_Writer.EndList();
+ m_Writer.BeginList("Entities", TAG_Compound);
+ }
+ }
+ else
+ {
+ m_Writer.BeginList("Entities", TAG_Compound);
+ }
+ m_IsTagOpen = true;
+ m_HasHadEntity = true;
+
+ switch (a_Entity->GetEntityType())
+ {
+ case cEntity::etFallingBlock: AddFallingBlockEntity((cFallingBlock *)a_Entity); break;
+ case cEntity::etMinecart: AddMinecartEntity ((cMinecart *) a_Entity); break;
+ case cEntity::etMonster: AddMonsterEntity ((cMonster *) a_Entity); break;
+ case cEntity::etPickup: AddPickupEntity ((cPickup *) a_Entity); break;
+ case cEntity::etPlayer: return; // Players aren't saved into the world
+ default:
+ {
+ ASSERT(!"Unhandled entity type is being saved");
+ break;
+ }
+ }
+}
+
+
+
+
+
+void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
+{
+ if (m_IsTagOpen)
+ {
+ if (!m_HasHadBlockEntity)
+ {
+ m_Writer.EndList();
+ m_Writer.BeginList("TileEntities", TAG_Compound);
+ }
+ }
+ else
+ {
+ m_Writer.BeginList("TileEntities", TAG_Compound);
+ }
+ m_IsTagOpen = true;
+
+ // 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_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_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
+ case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break;
+ default:
+ {
+ ASSERT(!"Unhandled block entity saved into Anvil");
+ }
+ }
+ m_HasHadBlockEntity = true;
+}
+
+
+
+
diff --git a/source/WorldStorage/NBTChunkSerializer.h b/source/WorldStorage/NBTChunkSerializer.h
index c71286797..1ccd356b0 100644
--- a/source/WorldStorage/NBTChunkSerializer.h
+++ b/source/WorldStorage/NBTChunkSerializer.h
@@ -1,110 +1,110 @@
-
-// NBTChunkSerializer.h
-
-// Declares the cNBTChunkSerializer class that is used for saving individual chunks into NBT format used by Anvil
-
-
-
-
-
-#pragma once
-
-#include "../ChunkDef.h"
-
-
-
-
-
-// fwd:
-class cFastNBTWriter;
-class cEntity;
-class cBlockEntity;
-class cChestEntity;
-class cDispenserEntity;
-class cDropperEntity;
-class cFurnaceEntity;
-class cHopperEntity;
-class cJukeboxEntity;
-class cNoteEntity;
-class cSignEntity;
-class cFallingBlock;
-class cMinecart;
-class cMinecartWithChest;
-class cMinecartWithFurnace;
-class cMonster;
-class cPickup;
-class cItemGrid;
-
-
-
-
-
-class cNBTChunkSerializer :
- public cChunkDataSeparateCollector
-{
-public:
- cChunkDef::BiomeMap m_Biomes;
- unsigned char m_VanillaBiomes[cChunkDef::Width * cChunkDef::Width];
- bool m_BiomesAreValid;
-
-
- cNBTChunkSerializer(cFastNBTWriter & a_Writer);
-
- /// Close NBT tags that we've opened
- void Finish(void);
-
- bool IsLightValid(void) const {return m_IsLightValid; }
-
-protected:
-
- /* From cChunkDataSeparateCollector we inherit:
- - m_BlockTypes[]
- - m_BlockMetas[]
- - m_BlockLight[]
- - m_BlockSkyLight[]
- */
-
- cFastNBTWriter & m_Writer;
-
- bool m_IsTagOpen; // True if a tag has been opened in the callbacks and not yet closed.
- bool m_HasHadEntity; // True if any Entity has already been received and processed
- bool m_HasHadBlockEntity; // True if any BlockEntity has already been received and processed
- bool m_IsLightValid; // True if the chunk lighting is valid
-
-
- /// Writes an item into the writer, if slot >= 0, adds the Slot tag. The compound is named as requested.
- void AddItem(const cItem & a_Item, int a_Slot, const AString & a_CompoundName = "");
-
- /// Writes an item grid into the writer; begins the stored slot numbers with a_BeginSlotNum. Note that it doesn't begin nor end the list tag
- void AddItemGrid(const cItemGrid & a_Grid, int a_BeginSlotNum = 0);
-
- // Block entities:
- void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID);
- void AddChestEntity (cChestEntity * a_Entity);
- void AddDispenserEntity(cDispenserEntity * a_Entity);
- void AddDropperEntity (cDropperEntity * a_Entity);
- void AddFurnaceEntity (cFurnaceEntity * a_Furnace);
- void AddHopperEntity (cHopperEntity * a_Entity);
- void AddJukeboxEntity (cJukeboxEntity * a_Jukebox);
- void AddNoteEntity (cNoteEntity * a_Note);
- void AddSignEntity (cSignEntity * a_Sign);
-
- // Entities:
- void AddBasicEntity (cEntity * a_Entity, const AString & a_ClassName);
- void AddFallingBlockEntity(cFallingBlock * a_FallingBlock);
- void AddMinecartEntity (cMinecart * a_Minecart);
- void AddMonsterEntity (cMonster * a_Monster);
- void AddPickupEntity (cPickup * a_Pickup);
-
- void AddMinecartChestContents(cMinecartWithChest * a_Minecart);
-
- // cChunkDataSeparateCollector overrides:
- virtual bool 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;
-} ; // class cNBTChunkSerializer
-
-
-
-
+
+// NBTChunkSerializer.h
+
+// Declares the cNBTChunkSerializer class that is used for saving individual chunks into NBT format used by Anvil
+
+
+
+
+
+#pragma once
+
+#include "../ChunkDef.h"
+
+
+
+
+
+// fwd:
+class cFastNBTWriter;
+class cEntity;
+class cBlockEntity;
+class cChestEntity;
+class cDispenserEntity;
+class cDropperEntity;
+class cFurnaceEntity;
+class cHopperEntity;
+class cJukeboxEntity;
+class cNoteEntity;
+class cSignEntity;
+class cFallingBlock;
+class cMinecart;
+class cMinecartWithChest;
+class cMinecartWithFurnace;
+class cMonster;
+class cPickup;
+class cItemGrid;
+
+
+
+
+
+class cNBTChunkSerializer :
+ public cChunkDataSeparateCollector
+{
+public:
+ cChunkDef::BiomeMap m_Biomes;
+ unsigned char m_VanillaBiomes[cChunkDef::Width * cChunkDef::Width];
+ bool m_BiomesAreValid;
+
+
+ cNBTChunkSerializer(cFastNBTWriter & a_Writer);
+
+ /// Close NBT tags that we've opened
+ void Finish(void);
+
+ bool IsLightValid(void) const {return m_IsLightValid; }
+
+protected:
+
+ /* From cChunkDataSeparateCollector we inherit:
+ - m_BlockTypes[]
+ - m_BlockMetas[]
+ - m_BlockLight[]
+ - m_BlockSkyLight[]
+ */
+
+ cFastNBTWriter & m_Writer;
+
+ bool m_IsTagOpen; // True if a tag has been opened in the callbacks and not yet closed.
+ bool m_HasHadEntity; // True if any Entity has already been received and processed
+ bool m_HasHadBlockEntity; // True if any BlockEntity has already been received and processed
+ bool m_IsLightValid; // True if the chunk lighting is valid
+
+
+ /// Writes an item into the writer, if slot >= 0, adds the Slot tag. The compound is named as requested.
+ void AddItem(const cItem & a_Item, int a_Slot, const AString & a_CompoundName = "");
+
+ /// Writes an item grid into the writer; begins the stored slot numbers with a_BeginSlotNum. Note that it doesn't begin nor end the list tag
+ void AddItemGrid(const cItemGrid & a_Grid, int a_BeginSlotNum = 0);
+
+ // Block entities:
+ void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID);
+ void AddChestEntity (cChestEntity * a_Entity);
+ void AddDispenserEntity(cDispenserEntity * a_Entity);
+ void AddDropperEntity (cDropperEntity * a_Entity);
+ void AddFurnaceEntity (cFurnaceEntity * a_Furnace);
+ void AddHopperEntity (cHopperEntity * a_Entity);
+ void AddJukeboxEntity (cJukeboxEntity * a_Jukebox);
+ void AddNoteEntity (cNoteEntity * a_Note);
+ void AddSignEntity (cSignEntity * a_Sign);
+
+ // Entities:
+ void AddBasicEntity (cEntity * a_Entity, const AString & a_ClassName);
+ void AddFallingBlockEntity(cFallingBlock * a_FallingBlock);
+ void AddMinecartEntity (cMinecart * a_Minecart);
+ void AddMonsterEntity (cMonster * a_Monster);
+ void AddPickupEntity (cPickup * a_Pickup);
+
+ void AddMinecartChestContents(cMinecartWithChest * a_Minecart);
+
+ // cChunkDataSeparateCollector overrides:
+ virtual bool 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;
+} ; // class cNBTChunkSerializer
+
+
+
+
diff --git a/source/XMLParser.h b/source/XMLParser.h
index a6b571862..f492d1a5d 100644
--- a/source/XMLParser.h
+++ b/source/XMLParser.h
@@ -1,701 +1,701 @@
-
-// XMLParser.h
-
-// Interfaces to the CXMLParser class representing the base class for XML parsing
-
-// To use, derive a class from this base and override its OnStartElement(), OnEndElement() and OnCharacters() functions
-
-
-
-
-
-#pragma once
-
-#include "expat/expat.h"
-
-
-
-
-
-class CXMLParser
-{
-public:
- CXMLParser(void);
- virtual ~CXMLParser();
-
- // The actual parsing, may be called several times; the last time needs iIsFinal == true (-> flush)
- int Parse(const char * iData, size_t iLength, bool iIsFinal = false);
-
-private:
- // LibExpat stuff:
- XML_Parser mParser;
-
- static void StartElementHandler(void * iContext, const XML_Char * iElement, const XML_Char ** iAttributes)
- {
- ((CXMLParser *)iContext)->OnStartElement(iElement, iAttributes);
- }
-
- static void EndElementHandler (void * iContext, const XML_Char * iElement)
- {
- ((CXMLParser *)iContext)->OnEndElement(iElement);
- }
-
- static void CharacterDataHandler (void * iContext, const XML_Char * iData, int iLength)
- {
- ((CXMLParser *)iContext)->OnCharacters(iData, iLength);
- }
-
-protected:
- virtual void OnStartElement(const XML_Char * iElement, const XML_Char ** iAttributes) = 0;
- virtual void OnEndElement (const XML_Char * iElement) = 0;
- virtual void OnCharacters (const XML_Char * iCharacters, int iLength) = 0;
-} ;
-
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// 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:
- class CMyParser : public CExpatImpl<CMyParser>
-2, Declare handlers that you want in that subclass:
- void CMyParser::OnEndElement(const XML_Char * iTagName);
-3, Create an instance of your class:
- CMyParser Parser;
-4, Call Create():
- Parser.Create(NULL, NULL);
-4, Call Parse(), repeatedly:
- Parser.Parse(Buffer, Length);
-*/
-
-template <class _T>
-class CExpatImpl
-{
-
-// @access Constructors and destructors
-public:
-
- // @cmember General constructor
-
- CExpatImpl ()
- {
- m_p = NULL;
- }
-
- // @cmember Destructor
-
- ~CExpatImpl ()
- {
- Destroy ();
- }
-
-// @access Parser creation and deletion methods
-public:
-
- // @cmember Create a parser
-
- bool Create (const XML_Char * pszEncoding = NULL, const XML_Char * pszSep = NULL)
- {
- // Destroy the old parser
- Destroy ();
-
- // If the encoding or seperator are empty, then NULL
- if (pszEncoding != NULL && pszEncoding [0] == 0)
- {
- pszEncoding = NULL;
- }
- if (pszSep != NULL && pszSep [0] == 0)
- {
- pszSep = NULL;
- }
-
- // Create the new parser
- m_p = XML_ParserCreate_MM (pszEncoding, NULL, pszSep);
- if (m_p == NULL)
- {
- return false;
- }
-
- // Invoke the post create routine
- _T * pThis = static_cast <_T *> (this);
- pThis ->OnPostCreate ();
-
- // Set the user data used in callbacks
- XML_SetUserData (m_p, (void *) this);
- return true;
- }
-
- // @cmember Destroy the parser
-
- void Destroy (void)
- {
- if (m_p != NULL)
- {
- XML_ParserFree (m_p);
- }
- m_p = NULL;
- }
-
-
- // @cmember Parse a block of data
-
- bool Parse (const char *pszBuffer, int nLength, bool fIsFinal = true)
- {
- assert (m_p != NULL);
- return XML_Parse (m_p, pszBuffer, nLength, fIsFinal) != 0;
- }
-
- // @cmember Parse internal buffer
-
- bool ParseBuffer (int nLength, bool fIsFinal = true)
- {
- assert (m_p != NULL);
- return XML_ParseBuffer (m_p, nLength, fIsFinal) != 0;
- }
-
- // @cmember Get the internal buffer
-
- void *GetBuffer (int nLength)
- {
- assert (m_p != NULL);
- return XML_GetBuffer (m_p, nLength);
- }
-
-
-protected:
- // Parser callback enable/disable methods:
-
- // @cmember Enable/Disable the start element handler
-
- void EnableStartElementHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetStartElementHandler (m_p, fEnable ? StartElementHandler : NULL);
- }
-
- // @cmember Enable/Disable the end element handler
-
- void EnableEndElementHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetEndElementHandler (m_p, fEnable ? EndElementHandler : NULL);
- }
-
- // @cmember Enable/Disable the element handlers
-
- void EnableElementHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- EnableStartElementHandler (fEnable);
- EnableEndElementHandler (fEnable);
- }
-
- // @cmember Enable/Disable the character data handler
-
- void EnableCharacterDataHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetCharacterDataHandler (m_p, fEnable ? CharacterDataHandler : NULL);
- }
-
- // @cmember Enable/Disable the processing instruction handler
-
- void EnableProcessingInstructionHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetProcessingInstructionHandler (m_p, fEnable ? ProcessingInstructionHandler : NULL);
- }
-
- // @cmember Enable/Disable the comment handler
-
- void EnableCommentHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetCommentHandler (m_p, fEnable ? CommentHandler : NULL);
- }
-
- // @cmember Enable/Disable the start CDATA section handler
-
- void EnableStartCdataSectionHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetStartCdataSectionHandler (m_p, fEnable ? StartCdataSectionHandler : NULL);
- }
-
- // @cmember Enable/Disable the end CDATA section handler
-
- void EnableEndCdataSectionHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetEndCdataSectionHandler (m_p, fEnable ? EndCdataSectionHandler : NULL);
- }
-
- // @cmember Enable/Disable the CDATA section handlers
-
- void EnableCdataSectionHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- EnableStartCdataSectionHandler (fEnable);
- EnableEndCdataSectionHandler (fEnable);
- }
-
- // @cmember Enable/Disable default handler
-
- void EnableDefaultHandler (bool fEnable = true, bool fExpand = true)
- {
- assert (m_p != NULL);
- if (fExpand)
- {
- XML_SetDefaultHandlerExpand (m_p, fEnable ? DefaultHandler : NULL);
- }
- else
- XML_SetDefaultHandler (m_p, fEnable ? DefaultHandler : NULL);
- }
-
- // @cmember Enable/Disable external entity ref handler
-
- void EnableExternalEntityRefHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetExternalEntityRefHandler (m_p, fEnable ? ExternalEntityRefHandler : NULL);
- }
-
- // @cmember Enable/Disable unknown encoding handler
-
- void EnableUnknownEncodingHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetUnknownEncodingHandler (m_p, fEnable ? UnknownEncodingHandler : NULL);
- }
-
- // @cmember Enable/Disable start namespace handler
-
- void EnableStartNamespaceDeclHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetStartNamespaceDeclHandler (m_p, fEnable ? StartNamespaceDeclHandler : NULL);
- }
-
- // @cmember Enable/Disable end namespace handler
-
- void EnableEndNamespaceDeclHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetEndNamespaceDeclHandler (m_p, fEnable ? EndNamespaceDeclHandler : NULL);
- }
-
- // @cmember Enable/Disable namespace handlers
-
- void EnableNamespaceDeclHandler (bool fEnable = true)
- {
- EnableStartNamespaceDeclHandler (fEnable);
- EnableEndNamespaceDeclHandler (fEnable);
- }
-
- // @cmember Enable/Disable the XML declaration handler
-
- void EnableXmlDeclHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetXmlDeclHandler (m_p, fEnable ? XmlDeclHandler : NULL);
- }
-
- // @cmember Enable/Disable the start DOCTYPE declaration handler
-
- void EnableStartDoctypeDeclHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetStartDoctypeDeclHandler (m_p, fEnable ? StartDoctypeDeclHandler : NULL);
- }
-
- // @cmember Enable/Disable the end DOCTYPE declaration handler
-
- void EnableEndDoctypeDeclHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- XML_SetEndDoctypeDeclHandler (m_p,
- fEnable ? EndDoctypeDeclHandler : NULL);
- }
-
- // @cmember Enable/Disable the DOCTYPE declaration handler
-
- void EnableDoctypeDeclHandler (bool fEnable = true)
- {
- assert (m_p != NULL);
- EnableStartDoctypeDeclHandler (fEnable);
- EnableEndDoctypeDeclHandler (fEnable);
- }
-
-public:
- // Parser error reporting methods
-
- // @cmember Get last error
-
- enum XML_Error GetErrorCode ()
- {
- assert (m_p != NULL);
- return XML_GetErrorCode (m_p);
- }
-
- // @cmember Get the current byte index
-
- long GetCurrentByteIndex ()
- {
- assert (m_p != NULL);
- return XML_GetCurrentByteIndex (m_p);
- }
-
- // @cmember Get the current line number
-
- int GetCurrentLineNumber ()
- {
- assert (m_p != NULL);
- return XML_GetCurrentLineNumber (m_p);
- }
-
- // @cmember Get the current column number
-
- int GetCurrentColumnNumber ()
- {
- assert (m_p != NULL);
- return XML_GetCurrentColumnNumber (m_p);
- }
-
- // @cmember Get the current byte count
-
- int GetCurrentByteCount ()
- {
- assert (m_p != NULL);
- return XML_GetCurrentByteCount (m_p);
- }
-
- // @cmember Get the input context
-
- const char *GetInputContext (int *pnOffset, int *pnSize)
- {
- assert (m_p != NULL);
- return XML_GetInputContext (m_p, pnOffset, pnSize);
- }
-
- // @cmember Get last error string
-
- const XML_LChar *GetErrorString ()
- {
- return XML_ErrorString (GetErrorCode ());
- }
-
- // @cmember Return the version string
-
- static const XML_LChar *GetExpatVersion ()
- {
- return XML_ExpatVersion ();
- }
-
- // @cmember Get the version information
-
- static void GetExpatVersion (int *pnMajor, int *pnMinor, int *pnMicro)
- {
- XML_expat_version v = XML_ExpatVersionInfo ();
- if (pnMajor)
- *pnMajor = v .major;
- if (pnMinor)
- *pnMinor = v .minor;
- if (pnMicro)
- *pnMicro = v .micro;
- }
-
- // @cmember Get last error string
-
- static const XML_LChar *GetErrorString (enum XML_Error nError)
- {
- return XML_ErrorString (nError);
- }
-
-
- // Public handler methods:
- // The template parameter should provide their own implementation for those handlers that they want
-
- // @cmember Start element handler
-
- void OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs)
- {
- return;
- }
-
- // @cmember End element handler
-
- void OnEndElement (const XML_Char *pszName)
- {
- return;
- }
-
- // @cmember Character data handler
-
- void OnCharacterData (const XML_Char *pszData, int nLength)
- {
- return;
- }
-
- // @cmember Processing instruction handler
-
- void OnProcessingInstruction (const XML_Char *pszTarget,
- const XML_Char *pszData)
- {
- return;
- }
-
- // @cmember Comment handler
-
- void OnComment (const XML_Char *pszData)
- {
- return;
- }
-
- // @cmember Start CDATA section handler
-
- void OnStartCdataSection ()
- {
- return;
- }
-
- // @cmember End CDATA section handler
-
- void OnEndCdataSection ()
- {
- return;
- }
-
- // @cmember Default handler
-
- void OnDefault (const XML_Char *pszData, int nLength)
- {
- return;
- }
-
- // @cmember External entity ref handler
-
- bool OnExternalEntityRef (const XML_Char *pszContext,
- const XML_Char *pszBase, const XML_Char *pszSystemID,
- const XML_Char *pszPublicID)
- {
- return false;
- }
-
- // @cmember Unknown encoding handler
-
- bool OnUnknownEncoding (const XML_Char *pszName, XML_Encoding *pInfo)
- {
- return false;
- }
-
- // @cmember Start namespace declaration handler
-
- void OnStartNamespaceDecl (const XML_Char *pszPrefix,
- const XML_Char *pszURI)
- {
- return;
- }
-
- // @cmember End namespace declaration handler
-
- void OnEndNamespaceDecl (const XML_Char *pszPrefix)
- {
- return;
- }
-
- // @cmember XML declaration handler
-
- void OnXmlDecl (const XML_Char *pszVersion, const XML_Char *pszEncoding,
- bool fStandalone)
- {
- return;
- }
-
- // @cmember Start DOCTYPE declaration handler
-
- void OnStartDoctypeDecl (const XML_Char *pszDoctypeName,
- const XML_Char *pszSysID, const XML_Char *pszPubID,
- bool fHasInternalSubset)
- {
- return;
- }
-
- // @cmember End DOCTYPE declaration handler
-
- void OnEndDoctypeDecl ()
- {
- return;
- }
-
-// @access Protected methods
-protected:
-
- // @cmember Handle any post creation
-
- void OnPostCreate ()
- {
- }
-
-// @access Protected static methods
-protected:
-
- // @cmember Start element handler wrapper
-
- static void __cdecl StartElementHandler (void *pUserData,
- const XML_Char *pszName, const XML_Char **papszAttrs)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnStartElement (pszName, papszAttrs);
- }
-
- // @cmember End element handler wrapper
-
- static void __cdecl EndElementHandler (void *pUserData,
- const XML_Char *pszName)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnEndElement (pszName);
- }
-
- // @cmember Character data handler wrapper
-
- static void __cdecl CharacterDataHandler (void *pUserData,
- const XML_Char *pszData, int nLength)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnCharacterData (pszData, nLength);
- }
-
- // @cmember Processing instruction handler wrapper
-
- static void __cdecl ProcessingInstructionHandler (void *pUserData,
- const XML_Char *pszTarget, const XML_Char *pszData)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnProcessingInstruction (pszTarget, pszData);
- }
-
- // @cmember Comment handler wrapper
-
- static void __cdecl CommentHandler (void *pUserData,
- const XML_Char *pszData)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnComment (pszData);
- }
-
- // @cmember Start CDATA section wrapper
-
- static void __cdecl StartCdataSectionHandler (void *pUserData)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnStartCdataSection ();
- }
-
- // @cmember End CDATA section wrapper
-
- static void __cdecl EndCdataSectionHandler (void *pUserData)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnEndCdataSection ();
- }
-
- // @cmember Default wrapper
-
- static void __cdecl DefaultHandler (void *pUserData,
- const XML_Char *pszData, int nLength)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnDefault (pszData, nLength);
- }
-
- // @cmember External entity ref wrapper
-
- 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,
- pszBase, pszSystemID, pszPublicID) ? 1 : 0;
- }
-
- // @cmember Unknown encoding wrapper
-
- static int __cdecl UnknownEncodingHandler (void * pUserData, const XML_Char * pszName, XML_Encoding * pInfo)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- return pThis ->OnUnknownEncoding (pszName, pInfo) ? 1 : 0;
- }
-
- // @cmember Start namespace decl wrapper
-
- static void __cdecl StartNamespaceDeclHandler (void * pUserData, const XML_Char * pszPrefix, const XML_Char * pszURI)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnStartNamespaceDecl (pszPrefix, pszURI);
- }
-
- // @cmember End namespace decl wrapper
-
- static void __cdecl EndNamespaceDeclHandler (void * pUserData, const XML_Char * pszPrefix)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnEndNamespaceDecl (pszPrefix);
- }
-
- // @cmember XML declaration wrapper
-
- static void __cdecl XmlDeclHandler (void *pUserData, const XML_Char *pszVersion, const XML_Char *pszEncoding, int nStandalone)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnXmlDecl (pszVersion, pszEncoding, nStandalone != 0);
- }
-
- // @cmember Start Doctype declaration wrapper
-
- static void __cdecl StartDoctypeDeclHandler (
- 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,
- pszPubID, nHasInternalSubset != 0);
- }
-
- // @cmember End Doctype declaration wrapper
-
- static void __cdecl EndDoctypeDeclHandler (void *pUserData)
- {
- _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnEndDoctypeDecl ();
- }
-
-
-protected:
-
- XML_Parser m_p;
-
- /// Returns the value of the specified attribute, if found; NULL otherwise
- static const XML_Char * FindAttr(const XML_Char ** iAttrs, const XML_Char * iAttrToFind)
- {
- for (const XML_Char ** Attr = iAttrs; *Attr != NULL; Attr += 2)
- {
- if (strcmp(*Attr, iAttrToFind) == 0)
- {
- return *(Attr + 1);
- }
- } // for Attr - iAttrs[]
- return NULL;
- }
-} ;
-
-
-
-
+
+// XMLParser.h
+
+// Interfaces to the CXMLParser class representing the base class for XML parsing
+
+// To use, derive a class from this base and override its OnStartElement(), OnEndElement() and OnCharacters() functions
+
+
+
+
+
+#pragma once
+
+#include "expat/expat.h"
+
+
+
+
+
+class CXMLParser
+{
+public:
+ CXMLParser(void);
+ virtual ~CXMLParser();
+
+ // The actual parsing, may be called several times; the last time needs iIsFinal == true (-> flush)
+ int Parse(const char * iData, size_t iLength, bool iIsFinal = false);
+
+private:
+ // LibExpat stuff:
+ XML_Parser mParser;
+
+ static void StartElementHandler(void * iContext, const XML_Char * iElement, const XML_Char ** iAttributes)
+ {
+ ((CXMLParser *)iContext)->OnStartElement(iElement, iAttributes);
+ }
+
+ static void EndElementHandler (void * iContext, const XML_Char * iElement)
+ {
+ ((CXMLParser *)iContext)->OnEndElement(iElement);
+ }
+
+ static void CharacterDataHandler (void * iContext, const XML_Char * iData, int iLength)
+ {
+ ((CXMLParser *)iContext)->OnCharacters(iData, iLength);
+ }
+
+protected:
+ virtual void OnStartElement(const XML_Char * iElement, const XML_Char ** iAttributes) = 0;
+ virtual void OnEndElement (const XML_Char * iElement) = 0;
+ virtual void OnCharacters (const XML_Char * iCharacters, int iLength) = 0;
+} ;
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// 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:
+ class CMyParser : public CExpatImpl<CMyParser>
+2, Declare handlers that you want in that subclass:
+ void CMyParser::OnEndElement(const XML_Char * iTagName);
+3, Create an instance of your class:
+ CMyParser Parser;
+4, Call Create():
+ Parser.Create(NULL, NULL);
+4, Call Parse(), repeatedly:
+ Parser.Parse(Buffer, Length);
+*/
+
+template <class _T>
+class CExpatImpl
+{
+
+// @access Constructors and destructors
+public:
+
+ // @cmember General constructor
+
+ CExpatImpl ()
+ {
+ m_p = NULL;
+ }
+
+ // @cmember Destructor
+
+ ~CExpatImpl ()
+ {
+ Destroy ();
+ }
+
+// @access Parser creation and deletion methods
+public:
+
+ // @cmember Create a parser
+
+ bool Create (const XML_Char * pszEncoding = NULL, const XML_Char * pszSep = NULL)
+ {
+ // Destroy the old parser
+ Destroy ();
+
+ // If the encoding or seperator are empty, then NULL
+ if (pszEncoding != NULL && pszEncoding [0] == 0)
+ {
+ pszEncoding = NULL;
+ }
+ if (pszSep != NULL && pszSep [0] == 0)
+ {
+ pszSep = NULL;
+ }
+
+ // Create the new parser
+ m_p = XML_ParserCreate_MM (pszEncoding, NULL, pszSep);
+ if (m_p == NULL)
+ {
+ return false;
+ }
+
+ // Invoke the post create routine
+ _T * pThis = static_cast <_T *> (this);
+ pThis ->OnPostCreate ();
+
+ // Set the user data used in callbacks
+ XML_SetUserData (m_p, (void *) this);
+ return true;
+ }
+
+ // @cmember Destroy the parser
+
+ void Destroy (void)
+ {
+ if (m_p != NULL)
+ {
+ XML_ParserFree (m_p);
+ }
+ m_p = NULL;
+ }
+
+
+ // @cmember Parse a block of data
+
+ bool Parse (const char *pszBuffer, int nLength, bool fIsFinal = true)
+ {
+ assert (m_p != NULL);
+ return XML_Parse (m_p, pszBuffer, nLength, fIsFinal) != 0;
+ }
+
+ // @cmember Parse internal buffer
+
+ bool ParseBuffer (int nLength, bool fIsFinal = true)
+ {
+ assert (m_p != NULL);
+ return XML_ParseBuffer (m_p, nLength, fIsFinal) != 0;
+ }
+
+ // @cmember Get the internal buffer
+
+ void *GetBuffer (int nLength)
+ {
+ assert (m_p != NULL);
+ return XML_GetBuffer (m_p, nLength);
+ }
+
+
+protected:
+ // Parser callback enable/disable methods:
+
+ // @cmember Enable/Disable the start element handler
+
+ void EnableStartElementHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetStartElementHandler (m_p, fEnable ? StartElementHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the end element handler
+
+ void EnableEndElementHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetEndElementHandler (m_p, fEnable ? EndElementHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the element handlers
+
+ void EnableElementHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ EnableStartElementHandler (fEnable);
+ EnableEndElementHandler (fEnable);
+ }
+
+ // @cmember Enable/Disable the character data handler
+
+ void EnableCharacterDataHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetCharacterDataHandler (m_p, fEnable ? CharacterDataHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the processing instruction handler
+
+ void EnableProcessingInstructionHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetProcessingInstructionHandler (m_p, fEnable ? ProcessingInstructionHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the comment handler
+
+ void EnableCommentHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetCommentHandler (m_p, fEnable ? CommentHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the start CDATA section handler
+
+ void EnableStartCdataSectionHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetStartCdataSectionHandler (m_p, fEnable ? StartCdataSectionHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the end CDATA section handler
+
+ void EnableEndCdataSectionHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetEndCdataSectionHandler (m_p, fEnable ? EndCdataSectionHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the CDATA section handlers
+
+ void EnableCdataSectionHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ EnableStartCdataSectionHandler (fEnable);
+ EnableEndCdataSectionHandler (fEnable);
+ }
+
+ // @cmember Enable/Disable default handler
+
+ void EnableDefaultHandler (bool fEnable = true, bool fExpand = true)
+ {
+ assert (m_p != NULL);
+ if (fExpand)
+ {
+ XML_SetDefaultHandlerExpand (m_p, fEnable ? DefaultHandler : NULL);
+ }
+ else
+ XML_SetDefaultHandler (m_p, fEnable ? DefaultHandler : NULL);
+ }
+
+ // @cmember Enable/Disable external entity ref handler
+
+ void EnableExternalEntityRefHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetExternalEntityRefHandler (m_p, fEnable ? ExternalEntityRefHandler : NULL);
+ }
+
+ // @cmember Enable/Disable unknown encoding handler
+
+ void EnableUnknownEncodingHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetUnknownEncodingHandler (m_p, fEnable ? UnknownEncodingHandler : NULL);
+ }
+
+ // @cmember Enable/Disable start namespace handler
+
+ void EnableStartNamespaceDeclHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetStartNamespaceDeclHandler (m_p, fEnable ? StartNamespaceDeclHandler : NULL);
+ }
+
+ // @cmember Enable/Disable end namespace handler
+
+ void EnableEndNamespaceDeclHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetEndNamespaceDeclHandler (m_p, fEnable ? EndNamespaceDeclHandler : NULL);
+ }
+
+ // @cmember Enable/Disable namespace handlers
+
+ void EnableNamespaceDeclHandler (bool fEnable = true)
+ {
+ EnableStartNamespaceDeclHandler (fEnable);
+ EnableEndNamespaceDeclHandler (fEnable);
+ }
+
+ // @cmember Enable/Disable the XML declaration handler
+
+ void EnableXmlDeclHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetXmlDeclHandler (m_p, fEnable ? XmlDeclHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the start DOCTYPE declaration handler
+
+ void EnableStartDoctypeDeclHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetStartDoctypeDeclHandler (m_p, fEnable ? StartDoctypeDeclHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the end DOCTYPE declaration handler
+
+ void EnableEndDoctypeDeclHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ XML_SetEndDoctypeDeclHandler (m_p,
+ fEnable ? EndDoctypeDeclHandler : NULL);
+ }
+
+ // @cmember Enable/Disable the DOCTYPE declaration handler
+
+ void EnableDoctypeDeclHandler (bool fEnable = true)
+ {
+ assert (m_p != NULL);
+ EnableStartDoctypeDeclHandler (fEnable);
+ EnableEndDoctypeDeclHandler (fEnable);
+ }
+
+public:
+ // Parser error reporting methods
+
+ // @cmember Get last error
+
+ enum XML_Error GetErrorCode ()
+ {
+ assert (m_p != NULL);
+ return XML_GetErrorCode (m_p);
+ }
+
+ // @cmember Get the current byte index
+
+ long GetCurrentByteIndex ()
+ {
+ assert (m_p != NULL);
+ return XML_GetCurrentByteIndex (m_p);
+ }
+
+ // @cmember Get the current line number
+
+ int GetCurrentLineNumber ()
+ {
+ assert (m_p != NULL);
+ return XML_GetCurrentLineNumber (m_p);
+ }
+
+ // @cmember Get the current column number
+
+ int GetCurrentColumnNumber ()
+ {
+ assert (m_p != NULL);
+ return XML_GetCurrentColumnNumber (m_p);
+ }
+
+ // @cmember Get the current byte count
+
+ int GetCurrentByteCount ()
+ {
+ assert (m_p != NULL);
+ return XML_GetCurrentByteCount (m_p);
+ }
+
+ // @cmember Get the input context
+
+ const char *GetInputContext (int *pnOffset, int *pnSize)
+ {
+ assert (m_p != NULL);
+ return XML_GetInputContext (m_p, pnOffset, pnSize);
+ }
+
+ // @cmember Get last error string
+
+ const XML_LChar *GetErrorString ()
+ {
+ return XML_ErrorString (GetErrorCode ());
+ }
+
+ // @cmember Return the version string
+
+ static const XML_LChar *GetExpatVersion ()
+ {
+ return XML_ExpatVersion ();
+ }
+
+ // @cmember Get the version information
+
+ static void GetExpatVersion (int *pnMajor, int *pnMinor, int *pnMicro)
+ {
+ XML_expat_version v = XML_ExpatVersionInfo ();
+ if (pnMajor)
+ *pnMajor = v .major;
+ if (pnMinor)
+ *pnMinor = v .minor;
+ if (pnMicro)
+ *pnMicro = v .micro;
+ }
+
+ // @cmember Get last error string
+
+ static const XML_LChar *GetErrorString (enum XML_Error nError)
+ {
+ return XML_ErrorString (nError);
+ }
+
+
+ // Public handler methods:
+ // The template parameter should provide their own implementation for those handlers that they want
+
+ // @cmember Start element handler
+
+ void OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs)
+ {
+ return;
+ }
+
+ // @cmember End element handler
+
+ void OnEndElement (const XML_Char *pszName)
+ {
+ return;
+ }
+
+ // @cmember Character data handler
+
+ void OnCharacterData (const XML_Char *pszData, int nLength)
+ {
+ return;
+ }
+
+ // @cmember Processing instruction handler
+
+ void OnProcessingInstruction (const XML_Char *pszTarget,
+ const XML_Char *pszData)
+ {
+ return;
+ }
+
+ // @cmember Comment handler
+
+ void OnComment (const XML_Char *pszData)
+ {
+ return;
+ }
+
+ // @cmember Start CDATA section handler
+
+ void OnStartCdataSection ()
+ {
+ return;
+ }
+
+ // @cmember End CDATA section handler
+
+ void OnEndCdataSection ()
+ {
+ return;
+ }
+
+ // @cmember Default handler
+
+ void OnDefault (const XML_Char *pszData, int nLength)
+ {
+ return;
+ }
+
+ // @cmember External entity ref handler
+
+ bool OnExternalEntityRef (const XML_Char *pszContext,
+ const XML_Char *pszBase, const XML_Char *pszSystemID,
+ const XML_Char *pszPublicID)
+ {
+ return false;
+ }
+
+ // @cmember Unknown encoding handler
+
+ bool OnUnknownEncoding (const XML_Char *pszName, XML_Encoding *pInfo)
+ {
+ return false;
+ }
+
+ // @cmember Start namespace declaration handler
+
+ void OnStartNamespaceDecl (const XML_Char *pszPrefix,
+ const XML_Char *pszURI)
+ {
+ return;
+ }
+
+ // @cmember End namespace declaration handler
+
+ void OnEndNamespaceDecl (const XML_Char *pszPrefix)
+ {
+ return;
+ }
+
+ // @cmember XML declaration handler
+
+ void OnXmlDecl (const XML_Char *pszVersion, const XML_Char *pszEncoding,
+ bool fStandalone)
+ {
+ return;
+ }
+
+ // @cmember Start DOCTYPE declaration handler
+
+ void OnStartDoctypeDecl (const XML_Char *pszDoctypeName,
+ const XML_Char *pszSysID, const XML_Char *pszPubID,
+ bool fHasInternalSubset)
+ {
+ return;
+ }
+
+ // @cmember End DOCTYPE declaration handler
+
+ void OnEndDoctypeDecl ()
+ {
+ return;
+ }
+
+// @access Protected methods
+protected:
+
+ // @cmember Handle any post creation
+
+ void OnPostCreate ()
+ {
+ }
+
+// @access Protected static methods
+protected:
+
+ // @cmember Start element handler wrapper
+
+ static void __cdecl StartElementHandler (void *pUserData,
+ const XML_Char *pszName, const XML_Char **papszAttrs)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnStartElement (pszName, papszAttrs);
+ }
+
+ // @cmember End element handler wrapper
+
+ static void __cdecl EndElementHandler (void *pUserData,
+ const XML_Char *pszName)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnEndElement (pszName);
+ }
+
+ // @cmember Character data handler wrapper
+
+ static void __cdecl CharacterDataHandler (void *pUserData,
+ const XML_Char *pszData, int nLength)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnCharacterData (pszData, nLength);
+ }
+
+ // @cmember Processing instruction handler wrapper
+
+ static void __cdecl ProcessingInstructionHandler (void *pUserData,
+ const XML_Char *pszTarget, const XML_Char *pszData)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnProcessingInstruction (pszTarget, pszData);
+ }
+
+ // @cmember Comment handler wrapper
+
+ static void __cdecl CommentHandler (void *pUserData,
+ const XML_Char *pszData)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnComment (pszData);
+ }
+
+ // @cmember Start CDATA section wrapper
+
+ static void __cdecl StartCdataSectionHandler (void *pUserData)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnStartCdataSection ();
+ }
+
+ // @cmember End CDATA section wrapper
+
+ static void __cdecl EndCdataSectionHandler (void *pUserData)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnEndCdataSection ();
+ }
+
+ // @cmember Default wrapper
+
+ static void __cdecl DefaultHandler (void *pUserData,
+ const XML_Char *pszData, int nLength)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnDefault (pszData, nLength);
+ }
+
+ // @cmember External entity ref wrapper
+
+ 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,
+ pszBase, pszSystemID, pszPublicID) ? 1 : 0;
+ }
+
+ // @cmember Unknown encoding wrapper
+
+ static int __cdecl UnknownEncodingHandler (void * pUserData, const XML_Char * pszName, XML_Encoding * pInfo)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ return pThis ->OnUnknownEncoding (pszName, pInfo) ? 1 : 0;
+ }
+
+ // @cmember Start namespace decl wrapper
+
+ static void __cdecl StartNamespaceDeclHandler (void * pUserData, const XML_Char * pszPrefix, const XML_Char * pszURI)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnStartNamespaceDecl (pszPrefix, pszURI);
+ }
+
+ // @cmember End namespace decl wrapper
+
+ static void __cdecl EndNamespaceDeclHandler (void * pUserData, const XML_Char * pszPrefix)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnEndNamespaceDecl (pszPrefix);
+ }
+
+ // @cmember XML declaration wrapper
+
+ static void __cdecl XmlDeclHandler (void *pUserData, const XML_Char *pszVersion, const XML_Char *pszEncoding, int nStandalone)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnXmlDecl (pszVersion, pszEncoding, nStandalone != 0);
+ }
+
+ // @cmember Start Doctype declaration wrapper
+
+ static void __cdecl StartDoctypeDeclHandler (
+ 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,
+ pszPubID, nHasInternalSubset != 0);
+ }
+
+ // @cmember End Doctype declaration wrapper
+
+ static void __cdecl EndDoctypeDeclHandler (void *pUserData)
+ {
+ _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
+ pThis ->OnEndDoctypeDecl ();
+ }
+
+
+protected:
+
+ XML_Parser m_p;
+
+ /// Returns the value of the specified attribute, if found; NULL otherwise
+ static const XML_Char * FindAttr(const XML_Char ** iAttrs, const XML_Char * iAttrToFind)
+ {
+ for (const XML_Char ** Attr = iAttrs; *Attr != NULL; Attr += 2)
+ {
+ if (strcmp(*Attr, iAttrToFind) == 0)
+ {
+ return *(Attr + 1);
+ }
+ } // for Attr - iAttrs[]
+ return NULL;
+ }
+} ;
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelArray.h b/source/squirrelbindings/SquirrelArray.h
index c54315aae..de5027f86 100644
--- a/source/squirrelbindings/SquirrelArray.h
+++ b/source/squirrelbindings/SquirrelArray.h
@@ -1,56 +1,56 @@
-
-#pragma once
-
-
-
-
-
-#ifdef USE_SQUIRREL
-
-
-
-
-
-template <typename T>
-class SquirrelArray
-{
-public:
- SquirrelArray()
- {
- }
-
- unsigned int Size()
- {
- return m_Values.size();
- }
-
- T Get(unsigned int a_Index)
- {
- if(m_Values.size() < a_Index)
- {
- return T();
- }
- return m_Values.at(a_Index);
- }
-
- void Add(T a_Value)
- {
- m_Values.push_back(a_Value);
- }
-
-protected:
- std::vector<T> m_Values;
-
-};
-
-class SquirrelStringArray : public SquirrelArray<std::string> { };
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#pragma once
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
+template <typename T>
+class SquirrelArray
+{
+public:
+ SquirrelArray()
+ {
+ }
+
+ unsigned int Size()
+ {
+ return m_Values.size();
+ }
+
+ T Get(unsigned int a_Index)
+ {
+ if(m_Values.size() < a_Index)
+ {
+ return T();
+ }
+ return m_Values.at(a_Index);
+ }
+
+ void Add(T a_Value)
+ {
+ m_Values.push_back(a_Value);
+ }
+
+protected:
+ std::vector<T> m_Values;
+
+};
+
+class SquirrelStringArray : public SquirrelArray<std::string> { };
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelBaseClass.h b/source/squirrelbindings/SquirrelBaseClass.h
index 36f532611..fb5e95c05 100644
--- a/source/squirrelbindings/SquirrelBaseClass.h
+++ b/source/squirrelbindings/SquirrelBaseClass.h
@@ -1,66 +1,66 @@
-
-#pragma once
-
-
-
-
-#ifdef USE_SQUIRREL
-
-
-
-
-
-#include "SquirrelBindings.h"
-#include "../Plugin_Squirrel.h"
-#include "../PluginManager.h"
-#include "../Root.h"
-#include "../SquirrelCommandBinder.h"
-
-
-
-
-
-// The baseclass for squirrel plugins
-class cSquirrelBaseClass
-{
-public:
- cSquirrelBaseClass()
- : m_Instance(0)
- {
- }
-
- void setInstance(cPlugin_Squirrel *a_Instance)
- {
- m_Instance = a_Instance;
- }
-
- void AddHook(short a_Hook)
- {
- if(m_Instance)
- cRoot::Get()->GetPluginManager()->AddHook(m_Instance, (cPluginManager::PluginHook) a_Hook);
- }
-
- void AddCommand( std::string a_Command, std::string a_Description, std::string a_Permission )
- {
- if(m_Instance) m_Instance->AddCommand(a_Command, a_Description, a_Permission);
- }
-
- bool BindCommand( const std::string a_Command, const std::string a_Permission, Sqrat::Function a_Callback)
- {
- if(!m_Instance) return false;
- return cRoot::Get()->GetPluginManager()->GetSquirrelCommandBinder()->BindCommand(a_Command, a_Permission, m_Instance, a_Callback);
- }
-
-protected:
- cPlugin_Squirrel *m_Instance;
-};
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#pragma once
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
+#include "SquirrelBindings.h"
+#include "../Plugin_Squirrel.h"
+#include "../PluginManager.h"
+#include "../Root.h"
+#include "../SquirrelCommandBinder.h"
+
+
+
+
+
+// The baseclass for squirrel plugins
+class cSquirrelBaseClass
+{
+public:
+ cSquirrelBaseClass()
+ : m_Instance(0)
+ {
+ }
+
+ void setInstance(cPlugin_Squirrel *a_Instance)
+ {
+ m_Instance = a_Instance;
+ }
+
+ void AddHook(short a_Hook)
+ {
+ if(m_Instance)
+ cRoot::Get()->GetPluginManager()->AddHook(m_Instance, (cPluginManager::PluginHook) a_Hook);
+ }
+
+ void AddCommand( std::string a_Command, std::string a_Description, std::string a_Permission )
+ {
+ if(m_Instance) m_Instance->AddCommand(a_Command, a_Description, a_Permission);
+ }
+
+ bool BindCommand( const std::string a_Command, const std::string a_Permission, Sqrat::Function a_Callback)
+ {
+ if(!m_Instance) return false;
+ return cRoot::Get()->GetPluginManager()->GetSquirrelCommandBinder()->BindCommand(a_Command, a_Permission, m_Instance, a_Callback);
+ }
+
+protected:
+ cPlugin_Squirrel *m_Instance;
+};
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelBindings.cpp b/source/squirrelbindings/SquirrelBindings.cpp
index ac212b101..51acc184f 100644
--- a/source/squirrelbindings/SquirrelBindings.cpp
+++ b/source/squirrelbindings/SquirrelBindings.cpp
@@ -1,195 +1,195 @@
-
-#include "Globals.h"
-
-
-
-
-
-#ifdef USE_SQUIRREL
-
-
-
-
-#include "SquirrelBindings.h"
-#include "SquirrelFunctions.h"
-
-#include "SquirrelBaseClass.h"
-#include "SquirrelArray.h"
-
-#include "../Player.h"
-
-
-
-
-
-using namespace Sqrat;
-
-
-
-
-
-void BindSquirrel(HSQUIRRELVM vm)
-{
- RootTable()
- .Bind("Plugin", Class<cSquirrelBaseClass>()
- .Func("AddHook", &cSquirrelBaseClass::AddHook)
- .Func("AddCommand", &cSquirrelBaseClass::AddCommand)
- .Func("BindCommand", &cSquirrelBaseClass::BindCommand)
- );
-
- RootTable().Bind("Vector3f", Class<Vector3f, NoConstructor>()
- .Func("Set", &Vector3f::Set)
- .Func("Normalize", &Vector3f::Normalize)
- .Func("Length", &Vector3f::Length)
- .Func("SqrLength", &Vector3f::SqrLength)
- .Var("x", &Vector3f::x)
- .Var("y", &Vector3f::y)
- .Var("z", &Vector3f::z)
- );
-
- RootTable().Bind("Vector3d", Class<Vector3d, NoConstructor>()
- .Func("Set", &Vector3d::Set)
- .Func("Normalize", &Vector3d::Normalize)
- .Func("Length", &Vector3d::Length)
- .Func("SqrLength", &Vector3d::SqrLength)
- .Var("x", &Vector3d::x)
- .Var("y", &Vector3d::y)
- .Var("z", &Vector3d::z)
- );
-
- RootTable().Bind("cEntity", Class<cEntity, NoConstructor>()
- .Func("GetEntityType", &cEntity::GetEntityType)
- .Func("IsA", &cEntity::IsA)
- .Func("GetWorld", &cEntity::GetWorld)
- .Func("GetPosition", &cEntity::GetPosition)
- .Func("GetPosX", &cEntity::GetPosX)
- .Func("GetPosY", &cEntity::GetPosY)
- .Func("GetPosZ", &cEntity::GetPosZ)
- .Func("GetRot", &cEntity::GetRot)
- .Func("GetRotation", &cEntity::GetRotation)
- .Func("GetPitch", &cEntity::GetPitch)
- .Func("GetRoll", &cEntity::GetRoll)
- .Func("SetRotation", &cEntity::SetRotation)
- .Func("SetPitch", &cEntity::SetPitch)
- .Func("SetRoll", &cEntity::SetRoll)
- .Func("GetLookVector", &cEntity::GetLookVector)
- .Func("GetChunkX", &cEntity::GetChunkX)
- .Func("GetChunkY", &cEntity::GetChunkY)
- .Func("GetChunkZ", &cEntity::GetChunkZ)
- .Func("SetPosX", &cEntity::SetPosX)
- .Func("SetPosY", &cEntity::SetPosY)
- .Func("SetPosZ", &cEntity::SetPosZ)
- .Func<void (cEntity::*) (double, double, double)>("SetPosition", &cEntity::SetPosition)
- .Func("GetUniqueID", &cEntity::GetUniqueID)
- .Func("IsDestroyed", &cEntity::IsDestroyed)
- .Func("Destroy", &cEntity::Destroy)
- );
-
- ConstTable().Enum("MetaData", Enumeration()
- .Const("Normal", cPawn::NORMAL)
- .Const("Burning", cPawn::BURNING)
- .Const("Crouched", cPawn::CROUCHED)
- .Const("Riding", cPawn::RIDING)
- .Const("Sprinting", cPawn::SPRINTING)
- .Const("Eating", cPawn::EATING)
- .Const("Blocking", cPawn::BLOCKING)
- );
-
- RootTable().Bind("cPawn", DerivedClass<cPawn, cEntity, NoConstructor>()
- .Func("TeleportToEntity", &cPawn::TeleportToEntity)
- .Func("TeleportTo", &cPawn::TeleportTo)
- .Func("Heal", &cPawn::Heal)
- .Func("TakeDamage", &cPawn::TakeDamage)
- .Func("KilledBy", &cPawn::KilledBy)
- .Func("GetHealth", &cPawn::GetHealth)
- .Func("SetMetaData", &cPawn::SetMetaData)
- .Func("GetMetaData", &cPawn::GetMetaData)
- .Func("SetMaxHealth", &cPawn::SetMaxHealth)
- .Func("GetMaxHealth", &cPawn::GetMaxHealth)
- );
-
- RootTable().Bind("cPlayer", DerivedClass<cPlayer, cPawn, NoConstructor>()
- .Func("GetName", &cPlayer::GetName)
- .Func("SetTouchGround", &cPlayer::SetTouchGround)
- .Func("SetStance", &cPlayer::SetStance)
- .Func("GetEyeHeight", &cPlayer::GetEyeHeight)
- .Func("GetEyePosition", &cPlayer::GetEyePosition)
- .Func("GetFlying", &cPlayer::GetFlying)
- .Func("GetStance", &cPlayer::GetStance)
- //TODO .Func("GetInventory", &cPlayer::GetInventory)
- .Func("TeleportTo", &cPlayer::TeleportTo)
- .Func("GetGameMode", &cPlayer::GetGameMode)
- .Func("GetIP", &cPlayer::GetIP)
- .Func("GetLastBlockActionTime", &cPlayer::GetLastBlockActionTime)
- .Func("GetLastBlockActionCnt", &cPlayer::GetLastBlockActionCnt)
- .Func("SetLastBlockActionCnt", &cPlayer::SetLastBlockActionCnt)
- .Func("SetLastBlockActionTime", &cPlayer::SetLastBlockActionTime)
- .Func("SetGameMode", &cPlayer::SetGameMode)
- .Func("LoginSetGameMode", &cPlayer::LoginSetGameMode)
- .Func("SetIP", &cPlayer::SetIP)
- .Func("MoveTo", &cPlayer::MoveTo)
- .Func("GetClientHandle", &cPlayer::GetClientHandle)
- .Func("SendMessage", &cPlayer::SendMessage)
- .Func("AddToGroup", &cPlayer::AddToGroup)
- .Func("CanUseCommand", &cPlayer::CanUseCommand)
- .Func("HasPermission", &cPlayer::HasPermission)
- .Func("IsInGroup", &cPlayer::IsInGroup)
- .Func("GetColor", &cPlayer::GetColor)
- .Func("TossItem", &cPlayer::TossItem)
- .Func("Heal", &cPlayer::Heal)
- .Func("Feed", &cPlayer::Feed)
- .Func("TakeDamage", &cPlayer::TakeDamage)
- .Func("KilledBy", &cPlayer::KilledBy)
- .Func("Respawn", &cPlayer::Respawn)
- .Func("SetVisible", &cPlayer::SetVisible)
- .Func("IsVisible", &cPlayer::IsVisible)
- .Func("MoveToWorld", &cPlayer::MoveToWorld)
- .Func("GetLoadedWorldName", &cPlayer::GetLoadedWorldName)
- .Func("UseEquippedItem", &cPlayer::UseEquippedItem)
- );
-
- RootTable().Bind("StringArray", Class<SquirrelStringArray>()
- .Func("Get", &SquirrelStringArray::Get)
- .Func("Add", &SquirrelStringArray::Add)
- .Func("Size", &SquirrelStringArray::Size)
- );
-
-
- RootTable().Func("print", &sqPrint);
-
-
- ConstTable().Enum("Hook", Enumeration()
- .Const("Tick", cPluginManager::HOOK_TICK)
- .Const("Chat", cPluginManager::HOOK_CHAT)
- .Const("CollectPickup", cPluginManager::HOOK_COLLECT_PICKUP)
- .Const("BlockDig", cPluginManager::HOOK_BLOCK_DIG)
- .Const("BlockPlace", cPluginManager::HOOK_BLOCK_PLACE)
- .Const("Disconnect", cPluginManager::HOOK_DISCONNECT)
- .Const("Handshake", cPluginManager::HOOK_HANDSHAKE)
- .Const("Login", cPluginManager::HOOK_LOGIN)
- .Const("PlayerSpawn", cPluginManager::HOOK_PLAYER_SPAWN)
- .Const("PlayerJoin", cPluginManager::HOOK_PLAYER_JOIN)
- .Const("PlayerMove", cPluginManager::HOOK_PLAYER_MOVE)
- .Const("TakeDamage", cPluginManager::HOOK_TAKE_DAMAGE)
- .Const("Killed", cPluginManager::HOOK_KILLED)
- .Const("ChunkGenerated", cPluginManager::HOOK_CHUNK_GENERATED)
- .Const("ChunkGenerating", cPluginManager::HOOK_CHUNK_GENERATING)
- .Const("BlockToDrops", cPluginManager::HOOK_BLOCK_TO_DROPS)
- .Const("PreCrafting", cPluginManager::HOOK_PRE_CRAFTING)
- .Const("CraftingNoRecipe", cPluginManager::HOOK_CRAFTING_NO_RECIPE)
- .Const("PostCrafting", cPluginManager::HOOK_POST_CRAFTING)
- .Const("BlockToPickup", cPluginManager::HOOK_BLOCK_TO_PICKUP)
- .Const("WeatherChanged", cPluginManager::HOOK_WEATHER_CHANGED)
- .Const("UpdatingSign", cPluginManager::HOOK_UPDATING_SIGN)
- .Const("UpdatedSign", cPluginManager::HOOK_UPDATED_SIGN));
-}
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#include "Globals.h"
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+#include "SquirrelBindings.h"
+#include "SquirrelFunctions.h"
+
+#include "SquirrelBaseClass.h"
+#include "SquirrelArray.h"
+
+#include "../Player.h"
+
+
+
+
+
+using namespace Sqrat;
+
+
+
+
+
+void BindSquirrel(HSQUIRRELVM vm)
+{
+ RootTable()
+ .Bind("Plugin", Class<cSquirrelBaseClass>()
+ .Func("AddHook", &cSquirrelBaseClass::AddHook)
+ .Func("AddCommand", &cSquirrelBaseClass::AddCommand)
+ .Func("BindCommand", &cSquirrelBaseClass::BindCommand)
+ );
+
+ RootTable().Bind("Vector3f", Class<Vector3f, NoConstructor>()
+ .Func("Set", &Vector3f::Set)
+ .Func("Normalize", &Vector3f::Normalize)
+ .Func("Length", &Vector3f::Length)
+ .Func("SqrLength", &Vector3f::SqrLength)
+ .Var("x", &Vector3f::x)
+ .Var("y", &Vector3f::y)
+ .Var("z", &Vector3f::z)
+ );
+
+ RootTable().Bind("Vector3d", Class<Vector3d, NoConstructor>()
+ .Func("Set", &Vector3d::Set)
+ .Func("Normalize", &Vector3d::Normalize)
+ .Func("Length", &Vector3d::Length)
+ .Func("SqrLength", &Vector3d::SqrLength)
+ .Var("x", &Vector3d::x)
+ .Var("y", &Vector3d::y)
+ .Var("z", &Vector3d::z)
+ );
+
+ RootTable().Bind("cEntity", Class<cEntity, NoConstructor>()
+ .Func("GetEntityType", &cEntity::GetEntityType)
+ .Func("IsA", &cEntity::IsA)
+ .Func("GetWorld", &cEntity::GetWorld)
+ .Func("GetPosition", &cEntity::GetPosition)
+ .Func("GetPosX", &cEntity::GetPosX)
+ .Func("GetPosY", &cEntity::GetPosY)
+ .Func("GetPosZ", &cEntity::GetPosZ)
+ .Func("GetRot", &cEntity::GetRot)
+ .Func("GetRotation", &cEntity::GetRotation)
+ .Func("GetPitch", &cEntity::GetPitch)
+ .Func("GetRoll", &cEntity::GetRoll)
+ .Func("SetRotation", &cEntity::SetRotation)
+ .Func("SetPitch", &cEntity::SetPitch)
+ .Func("SetRoll", &cEntity::SetRoll)
+ .Func("GetLookVector", &cEntity::GetLookVector)
+ .Func("GetChunkX", &cEntity::GetChunkX)
+ .Func("GetChunkY", &cEntity::GetChunkY)
+ .Func("GetChunkZ", &cEntity::GetChunkZ)
+ .Func("SetPosX", &cEntity::SetPosX)
+ .Func("SetPosY", &cEntity::SetPosY)
+ .Func("SetPosZ", &cEntity::SetPosZ)
+ .Func<void (cEntity::*) (double, double, double)>("SetPosition", &cEntity::SetPosition)
+ .Func("GetUniqueID", &cEntity::GetUniqueID)
+ .Func("IsDestroyed", &cEntity::IsDestroyed)
+ .Func("Destroy", &cEntity::Destroy)
+ );
+
+ ConstTable().Enum("MetaData", Enumeration()
+ .Const("Normal", cPawn::NORMAL)
+ .Const("Burning", cPawn::BURNING)
+ .Const("Crouched", cPawn::CROUCHED)
+ .Const("Riding", cPawn::RIDING)
+ .Const("Sprinting", cPawn::SPRINTING)
+ .Const("Eating", cPawn::EATING)
+ .Const("Blocking", cPawn::BLOCKING)
+ );
+
+ RootTable().Bind("cPawn", DerivedClass<cPawn, cEntity, NoConstructor>()
+ .Func("TeleportToEntity", &cPawn::TeleportToEntity)
+ .Func("TeleportTo", &cPawn::TeleportTo)
+ .Func("Heal", &cPawn::Heal)
+ .Func("TakeDamage", &cPawn::TakeDamage)
+ .Func("KilledBy", &cPawn::KilledBy)
+ .Func("GetHealth", &cPawn::GetHealth)
+ .Func("SetMetaData", &cPawn::SetMetaData)
+ .Func("GetMetaData", &cPawn::GetMetaData)
+ .Func("SetMaxHealth", &cPawn::SetMaxHealth)
+ .Func("GetMaxHealth", &cPawn::GetMaxHealth)
+ );
+
+ RootTable().Bind("cPlayer", DerivedClass<cPlayer, cPawn, NoConstructor>()
+ .Func("GetName", &cPlayer::GetName)
+ .Func("SetTouchGround", &cPlayer::SetTouchGround)
+ .Func("SetStance", &cPlayer::SetStance)
+ .Func("GetEyeHeight", &cPlayer::GetEyeHeight)
+ .Func("GetEyePosition", &cPlayer::GetEyePosition)
+ .Func("GetFlying", &cPlayer::GetFlying)
+ .Func("GetStance", &cPlayer::GetStance)
+ //TODO .Func("GetInventory", &cPlayer::GetInventory)
+ .Func("TeleportTo", &cPlayer::TeleportTo)
+ .Func("GetGameMode", &cPlayer::GetGameMode)
+ .Func("GetIP", &cPlayer::GetIP)
+ .Func("GetLastBlockActionTime", &cPlayer::GetLastBlockActionTime)
+ .Func("GetLastBlockActionCnt", &cPlayer::GetLastBlockActionCnt)
+ .Func("SetLastBlockActionCnt", &cPlayer::SetLastBlockActionCnt)
+ .Func("SetLastBlockActionTime", &cPlayer::SetLastBlockActionTime)
+ .Func("SetGameMode", &cPlayer::SetGameMode)
+ .Func("LoginSetGameMode", &cPlayer::LoginSetGameMode)
+ .Func("SetIP", &cPlayer::SetIP)
+ .Func("MoveTo", &cPlayer::MoveTo)
+ .Func("GetClientHandle", &cPlayer::GetClientHandle)
+ .Func("SendMessage", &cPlayer::SendMessage)
+ .Func("AddToGroup", &cPlayer::AddToGroup)
+ .Func("CanUseCommand", &cPlayer::CanUseCommand)
+ .Func("HasPermission", &cPlayer::HasPermission)
+ .Func("IsInGroup", &cPlayer::IsInGroup)
+ .Func("GetColor", &cPlayer::GetColor)
+ .Func("TossItem", &cPlayer::TossItem)
+ .Func("Heal", &cPlayer::Heal)
+ .Func("Feed", &cPlayer::Feed)
+ .Func("TakeDamage", &cPlayer::TakeDamage)
+ .Func("KilledBy", &cPlayer::KilledBy)
+ .Func("Respawn", &cPlayer::Respawn)
+ .Func("SetVisible", &cPlayer::SetVisible)
+ .Func("IsVisible", &cPlayer::IsVisible)
+ .Func("MoveToWorld", &cPlayer::MoveToWorld)
+ .Func("GetLoadedWorldName", &cPlayer::GetLoadedWorldName)
+ .Func("UseEquippedItem", &cPlayer::UseEquippedItem)
+ );
+
+ RootTable().Bind("StringArray", Class<SquirrelStringArray>()
+ .Func("Get", &SquirrelStringArray::Get)
+ .Func("Add", &SquirrelStringArray::Add)
+ .Func("Size", &SquirrelStringArray::Size)
+ );
+
+
+ RootTable().Func("print", &sqPrint);
+
+
+ ConstTable().Enum("Hook", Enumeration()
+ .Const("Tick", cPluginManager::HOOK_TICK)
+ .Const("Chat", cPluginManager::HOOK_CHAT)
+ .Const("CollectPickup", cPluginManager::HOOK_COLLECT_PICKUP)
+ .Const("BlockDig", cPluginManager::HOOK_BLOCK_DIG)
+ .Const("BlockPlace", cPluginManager::HOOK_BLOCK_PLACE)
+ .Const("Disconnect", cPluginManager::HOOK_DISCONNECT)
+ .Const("Handshake", cPluginManager::HOOK_HANDSHAKE)
+ .Const("Login", cPluginManager::HOOK_LOGIN)
+ .Const("PlayerSpawn", cPluginManager::HOOK_PLAYER_SPAWN)
+ .Const("PlayerJoin", cPluginManager::HOOK_PLAYER_JOIN)
+ .Const("PlayerMove", cPluginManager::HOOK_PLAYER_MOVE)
+ .Const("TakeDamage", cPluginManager::HOOK_TAKE_DAMAGE)
+ .Const("Killed", cPluginManager::HOOK_KILLED)
+ .Const("ChunkGenerated", cPluginManager::HOOK_CHUNK_GENERATED)
+ .Const("ChunkGenerating", cPluginManager::HOOK_CHUNK_GENERATING)
+ .Const("BlockToDrops", cPluginManager::HOOK_BLOCK_TO_DROPS)
+ .Const("PreCrafting", cPluginManager::HOOK_PRE_CRAFTING)
+ .Const("CraftingNoRecipe", cPluginManager::HOOK_CRAFTING_NO_RECIPE)
+ .Const("PostCrafting", cPluginManager::HOOK_POST_CRAFTING)
+ .Const("BlockToPickup", cPluginManager::HOOK_BLOCK_TO_PICKUP)
+ .Const("WeatherChanged", cPluginManager::HOOK_WEATHER_CHANGED)
+ .Const("UpdatingSign", cPluginManager::HOOK_UPDATING_SIGN)
+ .Const("UpdatedSign", cPluginManager::HOOK_UPDATED_SIGN));
+}
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelBindings.h b/source/squirrelbindings/SquirrelBindings.h
index fef563f4a..dd2affda0 100644
--- a/source/squirrelbindings/SquirrelBindings.h
+++ b/source/squirrelbindings/SquirrelBindings.h
@@ -1,32 +1,32 @@
-
-#pragma once
-
-
-
-
-
-#ifdef USE_SQUIRREL
-
-
-
-
-
-#include <squirrel.h>
-#include <sqrat.h>
-
-
-
-
-
-void BindSquirrel(HSQUIRRELVM vm);
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
-
+
+#pragma once
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
+#include <squirrel.h>
+#include <sqrat.h>
+
+
+
+
+
+void BindSquirrel(HSQUIRRELVM vm);
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelFunctions.cpp b/source/squirrelbindings/SquirrelFunctions.cpp
index 0e35f7361..9407670d4 100644
--- a/source/squirrelbindings/SquirrelFunctions.cpp
+++ b/source/squirrelbindings/SquirrelFunctions.cpp
@@ -1,94 +1,94 @@
-
-#include "Globals.h"
-
-
-
-
-
-#ifdef USE_SQUIRREL
-
-
-
-
-
-#include "SquirrelFunctions.h"
-#include "SquirrelBindings.h"
-
-
-
-
-
-static HSQUIRRELVM squirrelvm = NULL;
-
-
-
-
-
-SQInteger runtimeErrorHandler(HSQUIRRELVM a_VM)
-{
- const SQChar *sErr = 0;
- if(sq_gettop(a_VM) >= 1)
- {
- if(SQ_SUCCEEDED(sq_getstring(a_VM, 2, &sErr)))
- {
- LOGERROR("Squirrel Error: %s", sErr);
- }
- else
- {
- LOGERROR("Squirrel Error: Unknown Error");
- }
- }
- return 0;
-}
-
-void compilerErrorHandler(HSQUIRRELVM v,
- const SQChar* a_Desc,
- const SQChar* a_Source,
- SQInteger a_Line,
- SQInteger a_Column)
-{
-
- LOGERROR("Squirrel Error: %s (%d:%d) %s", a_Source, a_Line, a_Column, a_Desc);
-}
-
-HSQUIRRELVM OpenSquirrelVM()
-{
- if(!squirrelvm)
- {
- squirrelvm = sq_open(1024);
- Sqrat::DefaultVM::Set(squirrelvm);
-
- sq_newclosure(squirrelvm, runtimeErrorHandler, 0);
- sq_seterrorhandler(squirrelvm);
-
- sq_setcompilererrorhandler(squirrelvm, compilerErrorHandler);
-
- BindSquirrel(squirrelvm);
- }
- return squirrelvm;
-}
-
-void CloseSquirrelVM()
-{
- if(squirrelvm)
- {
- sq_close(squirrelvm);
- squirrelvm = NULL;
- }
-}
-
-
-void sqPrint(SQChar * text)
-{
- LOGINFO("%s", text);
-}
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#include "Globals.h"
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
+#include "SquirrelFunctions.h"
+#include "SquirrelBindings.h"
+
+
+
+
+
+static HSQUIRRELVM squirrelvm = NULL;
+
+
+
+
+
+SQInteger runtimeErrorHandler(HSQUIRRELVM a_VM)
+{
+ const SQChar *sErr = 0;
+ if(sq_gettop(a_VM) >= 1)
+ {
+ if(SQ_SUCCEEDED(sq_getstring(a_VM, 2, &sErr)))
+ {
+ LOGERROR("Squirrel Error: %s", sErr);
+ }
+ else
+ {
+ LOGERROR("Squirrel Error: Unknown Error");
+ }
+ }
+ return 0;
+}
+
+void compilerErrorHandler(HSQUIRRELVM v,
+ const SQChar* a_Desc,
+ const SQChar* a_Source,
+ SQInteger a_Line,
+ SQInteger a_Column)
+{
+
+ LOGERROR("Squirrel Error: %s (%d:%d) %s", a_Source, a_Line, a_Column, a_Desc);
+}
+
+HSQUIRRELVM OpenSquirrelVM()
+{
+ if(!squirrelvm)
+ {
+ squirrelvm = sq_open(1024);
+ Sqrat::DefaultVM::Set(squirrelvm);
+
+ sq_newclosure(squirrelvm, runtimeErrorHandler, 0);
+ sq_seterrorhandler(squirrelvm);
+
+ sq_setcompilererrorhandler(squirrelvm, compilerErrorHandler);
+
+ BindSquirrel(squirrelvm);
+ }
+ return squirrelvm;
+}
+
+void CloseSquirrelVM()
+{
+ if(squirrelvm)
+ {
+ sq_close(squirrelvm);
+ squirrelvm = NULL;
+ }
+}
+
+
+void sqPrint(SQChar * text)
+{
+ LOGINFO("%s", text);
+}
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelFunctions.h b/source/squirrelbindings/SquirrelFunctions.h
index 2b74fb52d..272b79c3e 100644
--- a/source/squirrelbindings/SquirrelFunctions.h
+++ b/source/squirrelbindings/SquirrelFunctions.h
@@ -1,28 +1,28 @@
-
-#pragma once
-
-#ifdef USE_SQUIRREL
-
-
-
-
-#include <sqrat.h>
-
-
-
-
-
-HSQUIRRELVM OpenSquirrelVM();
-void CloseSquirrelVM();
-
-void sqPrint(SQChar * text);
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#pragma once
+
+#ifdef USE_SQUIRREL
+
+
+
+
+#include <sqrat.h>
+
+
+
+
+
+HSQUIRRELVM OpenSquirrelVM();
+void CloseSquirrelVM();
+
+void sqPrint(SQChar * text);
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelObject.h b/source/squirrelbindings/SquirrelObject.h
index a7a44d531..248a5e02c 100644
--- a/source/squirrelbindings/SquirrelObject.h
+++ b/source/squirrelbindings/SquirrelObject.h
@@ -1,55 +1,55 @@
-
-#pragma once
-
-
-
-
-
-#ifdef USE_SQUIRREL
-
-
-
-
-
-#include <sqrat.h>
-
-
-
-
-
-class SquirrelObject
-{
-public:
- SquirrelObject(Sqrat::Object a_Obj)
- {
- m_SquirrelObject = a_Obj;
- }
-
- Sqrat::Function GetFunction(const char *a_MethodName)
- {
- if(m_SquirrelObject.IsNull())
- return Sqrat::Function();
-
- Sqrat::Function method(m_SquirrelObject, a_MethodName);
- return method;
- }
-
- bool HasFunction(const char *a_MethodName)
- {
- return !this->GetFunction(a_MethodName).IsNull();
- }
-
-protected:
- Sqrat::Object m_SquirrelObject;
-
-};
-
-
-
-
-
-#endif // USE_SQUIRREL
-
-
-
-
+
+#pragma once
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
+#include <sqrat.h>
+
+
+
+
+
+class SquirrelObject
+{
+public:
+ SquirrelObject(Sqrat::Object a_Obj)
+ {
+ m_SquirrelObject = a_Obj;
+ }
+
+ Sqrat::Function GetFunction(const char *a_MethodName)
+ {
+ if(m_SquirrelObject.IsNull())
+ return Sqrat::Function();
+
+ Sqrat::Function method(m_SquirrelObject, a_MethodName);
+ return method;
+ }
+
+ bool HasFunction(const char *a_MethodName)
+ {
+ return !this->GetFunction(a_MethodName).IsNull();
+ }
+
+protected:
+ Sqrat::Object m_SquirrelObject;
+
+};
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/virtual_method_hooks.lua b/source/virtual_method_hooks.lua
index 407b61627..b6cbe8268 100644
--- a/source/virtual_method_hooks.lua
+++ b/source/virtual_method_hooks.lua
@@ -1,506 +1,506 @@
--- flags
-local disable_virtual_hooks = false
-local enable_pure_virtual = true
-local default_private_access = false
-
-local access = {public = 0, protected = 1, private = 2}
-
-function preparse_hook(p)
-
- if default_private_access then
- -- we need to make all structs 'public' by default
- p.code = string.gsub(p.code, "(struct[^;]*{)", "%1\npublic:\n")
- end
-end
-
-
-function parser_hook(s)
-
- local container = classContainer.curr -- get the current container
-
- if default_private_access then
- if not container.curr_member_access and container.classtype == 'class' then
- -- default access for classes is private
- container.curr_member_access = access.private
- end
- end
-
- -- try labels (public, private, etc)
- do
- local b,e,label = string.find(s, "^%s*(%w*)%s*:[^:]") -- we need to check for [^:], otherwise it would match 'namespace::type'
- if b then
-
- -- found a label, get the new access value from the global 'access' table
- if access[label] then
- container.curr_member_access = access[label]
- end -- else ?
-
- return strsub(s, e) -- normally we would use 'e+1', but we need to preserve the [^:]
- end
- end
-
-
- local ret = nil
-
- if disable_virtual_hooks then
-
- return ret
- end
-
- local b,e,decl,arg = string.find(s, "^%s*virtual%s+([^%({~]+)(%b())")
- local const
- if b then
- local ret = string.sub(s, e+1)
- if string.find(ret, "^%s*const") then
- const = "const"
- ret = string.gsub(ret, "^%s*const", "")
- end
- local purev = false
- if string.find(ret, "^%s*=%s*0") then
- purev = true
- ret = string.gsub(ret, "^%s*=%s*0", "")
- end
- ret = string.gsub(ret, "^%s*%b{}", "")
-
- local func = Function(decl, arg, const)
- func.pure_virtual = purev
- --func.access = access
- func.original_sig = decl
-
- local curflags = classContainer.curr.flags
- if not curflags.virtual_class then
-
- curflags.virtual_class = VirtualClass()
- end
- curflags.virtual_class:add(func)
- curflags.pure_virtual = curflags.pure_virtual or purev
-
- return ret
- end
-
- return ret
-end
-
-
--- class VirtualClass
-classVirtualClass = {
- classtype = 'class',
- name = '',
- base = '',
- type = '',
- btype = '',
- ctype = '',
-}
-classVirtualClass.__index = classVirtualClass
-setmetatable(classVirtualClass,classClass)
-
-function classVirtualClass:add(f)
-
- local parent = classContainer.curr
- pop()
-
- table.insert(self.methods, {f=f})
-
- local name,sig
-
- -- doble negative means positive
- if f.name == 'new' and ((not self.flags.parent_object.flags.pure_virtual) or (enable_pure_virtual)) then
-
- name = self.original_name
- elseif f.name == 'delete' then
- name = '~'..self.original_name
- else
- if f.access ~= 2 and (not f.pure_virtual) and f.name ~= 'new' and f.name ~= 'delete' then
- name = f.mod.." "..f.type..f.ptr.." "..self.flags.parent_object.lname.."__"..f.name
- end
- end
-
- if name then
- sig = name..self:get_arg_list(f, true)..";\n"
- push(self)
- sig = preprocess(sig)
- self:parse(sig)
- pop()
- end
-
- push(parent)
-end
-
-function preprocess(sig)
-
- sig = gsub(sig,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
- sig = gsub(sig,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
- sig = gsub(sig,"([^%w_])char%s*%*","%1_cstring ") -- substitute 'char*'
- sig = gsub(sig,"([^%w_])lua_State%s*%*","%1_lstate ") -- substitute 'lua_State*'
-
- return sig
-end
-
-function classVirtualClass:get_arg_list(f, decl)
-
- local ret = ""
- local sep = ""
- local i=1
- while f.args[i] do
-
- local arg = f.args[i]
- if decl then
- local ptr
- if arg.ret ~= '' then
- ptr = arg.ret
- else
- ptr = arg.ptr
- end
- local def = ""
- if arg.def and arg.def ~= "" then
-
- def = " = "..arg.def
- end
- ret = ret..sep..arg.mod.." "..arg.type..ptr.." "..arg.name..def
- else
- ret = ret..sep..arg.name
- end
-
- sep = ","
- i = i+1
- end
-
- return "("..ret..")"
-end
-
-function classVirtualClass:add_parent_virtual_methods(parent)
-
- parent = parent or _global_classes[self.flags.parent_object.btype]
-
- if not parent then return end
-
- if parent.flags.virtual_class then
-
- local vclass = parent.flags.virtual_class
- for k,v in ipairs(vclass.methods) do
- if v.f.name ~= 'new' and v.f.name ~= 'delete' and (not self:has_method(v.f)) then
- table.insert(self.methods, {f=v.f})
- end
- end
- end
-
- parent = _global_classes[parent.btype]
- if parent then
- self:add_parent_virtual_methods(parent)
- end
-end
-
-function classVirtualClass:has_method(f)
-
- for k,v in pairs(self.methods) do
- -- just match name for now
- if v.f.name == f.name then
- return true
- end
- end
-
- return false
-end
-
-function classVirtualClass:add_constructors()
-
- local i=1
- while self.flags.parent_object[i] do
-
- local v = self.flags.parent_object[i]
- if getmetatable(v) == classFunction and (v.name == 'new' or v.name == 'delete') then
-
- self:add(v)
- end
-
- i = i+1
- end
-
-end
-
---[[
-function classVirtualClass:requirecollection(t)
-
- self:add_constructors()
- local req = classClass.requirecollection(self, t)
- if req then
- output('class ',self.name,";")
- end
- return req
-end
---]]
-
-function classVirtualClass:supcode()
-
- -- pure virtual classes can have no default constructors on gcc 4
-
- if self.flags.parent_object.flags.pure_virtual and not enable_pure_virtual then
- output('#if (__GNUC__ == 4) || (__GNUC__ > 4 ) // I hope this works on Microsoft Visual studio .net server 2003 XP Compiler\n')
- end
-
- local ns
- if self.prox.classtype == 'namespace' then
- output('namespace ',self.prox.name, " {")
- ns = true
- end
-
- output("class "..self.original_name.." : public "..self.btype..", public ToluaBase {")
-
- output("public:\n")
-
- self:add_parent_virtual_methods()
-
- self:output_methods(self.btype)
- self:output_parent_methods()
-
- self:add_constructors()
-
- -- no constructor for pure virtual classes
- if (not self.flags.parent_object.flags.pure_virtual) or enable_pure_virtual then
-
- self:output_constructors()
- end
-
- output("};\n\n")
-
- if ns then
- output("};")
- end
-
- classClass.supcode(self)
-
- if self.flags.parent_object.flags.pure_virtual and not enable_pure_virtual then
- output('#endif // __GNUC__ >= 4\n')
- end
-
- -- output collector for custom class if required
- if self:requirecollection(_collect) and _collect[self.type] then
-
- output('\n')
- output('/* function to release collected object via destructor */')
- output('#ifdef __cplusplus\n')
- --for i,v in pairs(collect) do
- i,v = self.type, _collect[self.type]
- output('\nstatic int '..v..' (lua_State* tolua_S)')
- output('{')
- output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);')
- output(' delete self;')
- output(' return 0;')
- output('}')
- --end
- output('#endif\n\n')
- end
-
-end
-
-function classVirtualClass:register(pre)
-
- -- pure virtual classes can have no default constructors on gcc 4
- if self.flags.parent_object.flags.pure_virtual and not enable_pure_virtual then
- output('#if (__GNUC__ == 4) || (__GNUC__ > 4 )\n')
- end
-
- classClass.register(self, pre)
-
- if self.flags.parent_object.flags.pure_virtual and not enable_pure_virtual then
- output('#endif // __GNUC__ >= 4\n')
- end
-end
-
-
---function classVirtualClass:requirecollection(_c)
--- if self.flags.parent_object.flags.pure_virtual then
--- return false
--- end
--- return classClass.requirecollection(self, _c)
---end
-
-function classVirtualClass:output_parent_methods()
-
- for k,v in ipairs(self.methods) do
-
- if v.f.access ~= 2 and (not v.f.pure_virtual) and v.f.name ~= 'new' and v.f.name ~= 'delete' then
-
- local rettype = v.f.mod.." "..v.f.type..v.f.ptr.." "
- local parent_name = rettype..self.btype.."__"..v.f.name
-
- local par_list = self:get_arg_list(v.f, true)
- local var_list = self:get_arg_list(v.f, false)
-
- -- the parent's virtual function
- output("\t"..parent_name..par_list.." {")
-
- output("\t\treturn (",rettype,")"..self.btype.."::"..v.f.name..var_list..";")
- output("\t};")
- end
- end
-end
-
-function classVirtualClass:output_methods(btype)
-
- for k,v in ipairs(self.methods) do
-
- if v.f.name ~= 'new' and v.f.name ~= 'delete' then
-
- self:output_method(v.f, btype)
- end
- end
- output("\n")
-end
-
-function classVirtualClass:output_constructors()
-
- for k,v in ipairs(self.methods) do
-
- if v.f.name == 'new' then
-
- local par_list = self:get_arg_list(v.f, true)
- local var_list = self:get_arg_list(v.f, false)
-
- output("\t",self.original_name,par_list,":",self.btype,var_list,"{};")
- end
- end
-end
-
-function classVirtualClass:output_method(f, btype)
-
- if f.access == 2 then -- private
- return
- end
-
- local ptr
- if f.ret ~= '' then
- ptr = f.ret
- else
- ptr = f.ptr
- end
-
- local rettype = f.mod.." "..f.type..f.ptr.." "
- local par_list = self:get_arg_list(f, true)
- local var_list = self:get_arg_list(f, false)
-
- if string.find(rettype, "%s*LuaQtGenericFlags%s*") then
-
- _,_,rettype = string.find(f.original_sig, "^%s*([^%s]+)%s+")
- end
-
- -- the caller of the lua method
- output("\t"..rettype.." "..f.name..par_list..f.const.." {")
- local fn = f.cname
- if f.access == 1 then
- fn = "NULL"
- end
- output('\t\tif (push_method("',f.lname,'", ',fn,')) {')
-
- --if f.type ~= 'void' then
- -- output("\t\t\tint top = lua_gettop(lua_state)-1;")
- --end
-
- -- push the parameters
- local argn = 0
- for i,arg in ipairs(f.args) do
- if arg.type ~= 'void' then
- local t,ct = isbasic(arg.type)
- if t and t ~= '' then
- if arg.ret == "*" then
- t = 'userdata'
- ct = 'void*'
- end
- output("\t\t\ttolua_push"..t.."(lua_state, ("..ct..")"..arg.name..");");
- else
- local m = arg.ptr
- if m and m~= "" then
- if m == "*" then m = "" end
- output("\t\t\ttolua_pushusertype(lua_state, (void*)"..m..arg.name..", \""..arg.type.."\");")
- else
- output("\t\t\tvoid* tolua_obj" .. argn .." = (void*)new "..arg.type.."("..arg.name..");\n")
- output('\t\t\ttolua_pushusertype_and_takeownership(lua_state, tolua_obj' .. argn .. ', "'..arg.type..'");\n')
- end
- end
- argn = argn+1
- end
- end
-
- -- call the function
- output("\t\t\tToluaBase::dbcall(lua_state, ",argn+1,", ")
-
- -- return value
- if f.type ~= 'void' then
- output("1);")
-
- local t,ct = isbasic(f.type)
- if t and t ~= '' then
- --output("\t\t\treturn ("..rettype..")tolua_to"..t.."(lua_state, top, 0);")
- output("\t\t\t",rettype,"tolua_ret = ("..rettype..")tolua_to"..t.."(lua_state, -1, 0);")
- else
-
- local mod = ""
- if f.ptr ~= "*" then
- mod = "*("..f.type.."*)"
- end
-
- --output("\t\t\treturn ("..rettype..")"..mod.."tolua_tousertype(lua_state, top, 0);")
- output("\t\t\t",rettype,"tolua_ret = ("..rettype..")"..mod.."tolua_tousertype(lua_state, -1, 0);")
- end
- output("\t\t\tlua_pop(lua_state, 1);")
- output("\t\t\treturn tolua_ret;")
- else
- output("0);")
- end
-
- -- handle non-implemeted function
- output("\t\t} else {")
-
- if f.pure_virtual then
-
- output('\t\t\tif (lua_state)')
- --output('\t\t\t\ttolua_error(lua_state, "pure-virtual method '..btype.."::"..f.name..' not implemented.", NULL);')
- output('\t\t\t\tLOG("pure-virtual method '..btype.."::"..f.name..' not implemented.");')
- output('\t\t\telse {')
- output('\t\t\t\tLOG("pure-virtual method '..btype.."::"..f.name..' called with no lua_state. Aborting");')
- output('\t\t\t\t::abort();')
- output('\t\t\t};')
- if( rettype == " std::string " ) then
- output('\t\t\treturn "";')
- else
- output('\t\t\treturn (',rettype,')0;')
- end
- else
-
- output('\t\t\treturn (',rettype,')',btype,'::',f.name,var_list,';')
- end
-
- output("\t\t};")
-
- output("\t};")
-end
-
-function VirtualClass()
-
- local parent = classContainer.curr
- pop()
-
- local name = "Lua__"..parent.original_name
-
- local c = _Class(_Container{name=name, base=parent.name, extra_bases=nil})
- setmetatable(c, classVirtualClass)
-
- local ft = getnamespace(c.parent)..c.original_name
- append_global_type(ft, c)
-
- push(parent)
-
- c.flags.parent_object = parent
- c.methods = {}
-
- push(c)
- c:parse("\nvoid tolua__set_instance(_lstate L, lua_Object lo);\n")
- pop()
-
- return c
-end
-
-
-
-
-
+-- flags
+local disable_virtual_hooks = false
+local enable_pure_virtual = true
+local default_private_access = false
+
+local access = {public = 0, protected = 1, private = 2}
+
+function preparse_hook(p)
+
+ if default_private_access then
+ -- we need to make all structs 'public' by default
+ p.code = string.gsub(p.code, "(struct[^;]*{)", "%1\npublic:\n")
+ end
+end
+
+
+function parser_hook(s)
+
+ local container = classContainer.curr -- get the current container
+
+ if default_private_access then
+ if not container.curr_member_access and container.classtype == 'class' then
+ -- default access for classes is private
+ container.curr_member_access = access.private
+ end
+ end
+
+ -- try labels (public, private, etc)
+ do
+ local b,e,label = string.find(s, "^%s*(%w*)%s*:[^:]") -- we need to check for [^:], otherwise it would match 'namespace::type'
+ if b then
+
+ -- found a label, get the new access value from the global 'access' table
+ if access[label] then
+ container.curr_member_access = access[label]
+ end -- else ?
+
+ return strsub(s, e) -- normally we would use 'e+1', but we need to preserve the [^:]
+ end
+ end
+
+
+ local ret = nil
+
+ if disable_virtual_hooks then
+
+ return ret
+ end
+
+ local b,e,decl,arg = string.find(s, "^%s*virtual%s+([^%({~]+)(%b())")
+ local const
+ if b then
+ local ret = string.sub(s, e+1)
+ if string.find(ret, "^%s*const") then
+ const = "const"
+ ret = string.gsub(ret, "^%s*const", "")
+ end
+ local purev = false
+ if string.find(ret, "^%s*=%s*0") then
+ purev = true
+ ret = string.gsub(ret, "^%s*=%s*0", "")
+ end
+ ret = string.gsub(ret, "^%s*%b{}", "")
+
+ local func = Function(decl, arg, const)
+ func.pure_virtual = purev
+ --func.access = access
+ func.original_sig = decl
+
+ local curflags = classContainer.curr.flags
+ if not curflags.virtual_class then
+
+ curflags.virtual_class = VirtualClass()
+ end
+ curflags.virtual_class:add(func)
+ curflags.pure_virtual = curflags.pure_virtual or purev
+
+ return ret
+ end
+
+ return ret
+end
+
+
+-- class VirtualClass
+classVirtualClass = {
+ classtype = 'class',
+ name = '',
+ base = '',
+ type = '',
+ btype = '',
+ ctype = '',
+}
+classVirtualClass.__index = classVirtualClass
+setmetatable(classVirtualClass,classClass)
+
+function classVirtualClass:add(f)
+
+ local parent = classContainer.curr
+ pop()
+
+ table.insert(self.methods, {f=f})
+
+ local name,sig
+
+ -- doble negative means positive
+ if f.name == 'new' and ((not self.flags.parent_object.flags.pure_virtual) or (enable_pure_virtual)) then
+
+ name = self.original_name
+ elseif f.name == 'delete' then
+ name = '~'..self.original_name
+ else
+ if f.access ~= 2 and (not f.pure_virtual) and f.name ~= 'new' and f.name ~= 'delete' then
+ name = f.mod.." "..f.type..f.ptr.." "..self.flags.parent_object.lname.."__"..f.name
+ end
+ end
+
+ if name then
+ sig = name..self:get_arg_list(f, true)..";\n"
+ push(self)
+ sig = preprocess(sig)
+ self:parse(sig)
+ pop()
+ end
+
+ push(parent)
+end
+
+function preprocess(sig)
+
+ sig = gsub(sig,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
+ sig = gsub(sig,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
+ sig = gsub(sig,"([^%w_])char%s*%*","%1_cstring ") -- substitute 'char*'
+ sig = gsub(sig,"([^%w_])lua_State%s*%*","%1_lstate ") -- substitute 'lua_State*'
+
+ return sig
+end
+
+function classVirtualClass:get_arg_list(f, decl)
+
+ local ret = ""
+ local sep = ""
+ local i=1
+ while f.args[i] do
+
+ local arg = f.args[i]
+ if decl then
+ local ptr
+ if arg.ret ~= '' then
+ ptr = arg.ret
+ else
+ ptr = arg.ptr
+ end
+ local def = ""
+ if arg.def and arg.def ~= "" then
+
+ def = " = "..arg.def
+ end
+ ret = ret..sep..arg.mod.." "..arg.type..ptr.." "..arg.name..def
+ else
+ ret = ret..sep..arg.name
+ end
+
+ sep = ","
+ i = i+1
+ end
+
+ return "("..ret..")"
+end
+
+function classVirtualClass:add_parent_virtual_methods(parent)
+
+ parent = parent or _global_classes[self.flags.parent_object.btype]
+
+ if not parent then return end
+
+ if parent.flags.virtual_class then
+
+ local vclass = parent.flags.virtual_class
+ for k,v in ipairs(vclass.methods) do
+ if v.f.name ~= 'new' and v.f.name ~= 'delete' and (not self:has_method(v.f)) then
+ table.insert(self.methods, {f=v.f})
+ end
+ end
+ end
+
+ parent = _global_classes[parent.btype]
+ if parent then
+ self:add_parent_virtual_methods(parent)
+ end
+end
+
+function classVirtualClass:has_method(f)
+
+ for k,v in pairs(self.methods) do
+ -- just match name for now
+ if v.f.name == f.name then
+ return true
+ end
+ end
+
+ return false
+end
+
+function classVirtualClass:add_constructors()
+
+ local i=1
+ while self.flags.parent_object[i] do
+
+ local v = self.flags.parent_object[i]
+ if getmetatable(v) == classFunction and (v.name == 'new' or v.name == 'delete') then
+
+ self:add(v)
+ end
+
+ i = i+1
+ end
+
+end
+
+--[[
+function classVirtualClass:requirecollection(t)
+
+ self:add_constructors()
+ local req = classClass.requirecollection(self, t)
+ if req then
+ output('class ',self.name,";")
+ end
+ return req
+end
+--]]
+
+function classVirtualClass:supcode()
+
+ -- pure virtual classes can have no default constructors on gcc 4
+
+ if self.flags.parent_object.flags.pure_virtual and not enable_pure_virtual then
+ output('#if (__GNUC__ == 4) || (__GNUC__ > 4 ) // I hope this works on Microsoft Visual studio .net server 2003 XP Compiler\n')
+ end
+
+ local ns
+ if self.prox.classtype == 'namespace' then
+ output('namespace ',self.prox.name, " {")
+ ns = true
+ end
+
+ output("class "..self.original_name.." : public "..self.btype..", public ToluaBase {")
+
+ output("public:\n")
+
+ self:add_parent_virtual_methods()
+
+ self:output_methods(self.btype)
+ self:output_parent_methods()
+
+ self:add_constructors()
+
+ -- no constructor for pure virtual classes
+ if (not self.flags.parent_object.flags.pure_virtual) or enable_pure_virtual then
+
+ self:output_constructors()
+ end
+
+ output("};\n\n")
+
+ if ns then
+ output("};")
+ end
+
+ classClass.supcode(self)
+
+ if self.flags.parent_object.flags.pure_virtual and not enable_pure_virtual then
+ output('#endif // __GNUC__ >= 4\n')
+ end
+
+ -- output collector for custom class if required
+ if self:requirecollection(_collect) and _collect[self.type] then
+
+ output('\n')
+ output('/* function to release collected object via destructor */')
+ output('#ifdef __cplusplus\n')
+ --for i,v in pairs(collect) do
+ i,v = self.type, _collect[self.type]
+ output('\nstatic int '..v..' (lua_State* tolua_S)')
+ output('{')
+ output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);')
+ output(' delete self;')
+ output(' return 0;')
+ output('}')
+ --end
+ output('#endif\n\n')
+ end
+
+end
+
+function classVirtualClass:register(pre)
+
+ -- pure virtual classes can have no default constructors on gcc 4
+ if self.flags.parent_object.flags.pure_virtual and not enable_pure_virtual then
+ output('#if (__GNUC__ == 4) || (__GNUC__ > 4 )\n')
+ end
+
+ classClass.register(self, pre)
+
+ if self.flags.parent_object.flags.pure_virtual and not enable_pure_virtual then
+ output('#endif // __GNUC__ >= 4\n')
+ end
+end
+
+
+--function classVirtualClass:requirecollection(_c)
+-- if self.flags.parent_object.flags.pure_virtual then
+-- return false
+-- end
+-- return classClass.requirecollection(self, _c)
+--end
+
+function classVirtualClass:output_parent_methods()
+
+ for k,v in ipairs(self.methods) do
+
+ if v.f.access ~= 2 and (not v.f.pure_virtual) and v.f.name ~= 'new' and v.f.name ~= 'delete' then
+
+ local rettype = v.f.mod.." "..v.f.type..v.f.ptr.." "
+ local parent_name = rettype..self.btype.."__"..v.f.name
+
+ local par_list = self:get_arg_list(v.f, true)
+ local var_list = self:get_arg_list(v.f, false)
+
+ -- the parent's virtual function
+ output("\t"..parent_name..par_list.." {")
+
+ output("\t\treturn (",rettype,")"..self.btype.."::"..v.f.name..var_list..";")
+ output("\t};")
+ end
+ end
+end
+
+function classVirtualClass:output_methods(btype)
+
+ for k,v in ipairs(self.methods) do
+
+ if v.f.name ~= 'new' and v.f.name ~= 'delete' then
+
+ self:output_method(v.f, btype)
+ end
+ end
+ output("\n")
+end
+
+function classVirtualClass:output_constructors()
+
+ for k,v in ipairs(self.methods) do
+
+ if v.f.name == 'new' then
+
+ local par_list = self:get_arg_list(v.f, true)
+ local var_list = self:get_arg_list(v.f, false)
+
+ output("\t",self.original_name,par_list,":",self.btype,var_list,"{};")
+ end
+ end
+end
+
+function classVirtualClass:output_method(f, btype)
+
+ if f.access == 2 then -- private
+ return
+ end
+
+ local ptr
+ if f.ret ~= '' then
+ ptr = f.ret
+ else
+ ptr = f.ptr
+ end
+
+ local rettype = f.mod.." "..f.type..f.ptr.." "
+ local par_list = self:get_arg_list(f, true)
+ local var_list = self:get_arg_list(f, false)
+
+ if string.find(rettype, "%s*LuaQtGenericFlags%s*") then
+
+ _,_,rettype = string.find(f.original_sig, "^%s*([^%s]+)%s+")
+ end
+
+ -- the caller of the lua method
+ output("\t"..rettype.." "..f.name..par_list..f.const.." {")
+ local fn = f.cname
+ if f.access == 1 then
+ fn = "NULL"
+ end
+ output('\t\tif (push_method("',f.lname,'", ',fn,')) {')
+
+ --if f.type ~= 'void' then
+ -- output("\t\t\tint top = lua_gettop(lua_state)-1;")
+ --end
+
+ -- push the parameters
+ local argn = 0
+ for i,arg in ipairs(f.args) do
+ if arg.type ~= 'void' then
+ local t,ct = isbasic(arg.type)
+ if t and t ~= '' then
+ if arg.ret == "*" then
+ t = 'userdata'
+ ct = 'void*'
+ end
+ output("\t\t\ttolua_push"..t.."(lua_state, ("..ct..")"..arg.name..");");
+ else
+ local m = arg.ptr
+ if m and m~= "" then
+ if m == "*" then m = "" end
+ output("\t\t\ttolua_pushusertype(lua_state, (void*)"..m..arg.name..", \""..arg.type.."\");")
+ else
+ output("\t\t\tvoid* tolua_obj" .. argn .." = (void*)new "..arg.type.."("..arg.name..");\n")
+ output('\t\t\ttolua_pushusertype_and_takeownership(lua_state, tolua_obj' .. argn .. ', "'..arg.type..'");\n')
+ end
+ end
+ argn = argn+1
+ end
+ end
+
+ -- call the function
+ output("\t\t\tToluaBase::dbcall(lua_state, ",argn+1,", ")
+
+ -- return value
+ if f.type ~= 'void' then
+ output("1);")
+
+ local t,ct = isbasic(f.type)
+ if t and t ~= '' then
+ --output("\t\t\treturn ("..rettype..")tolua_to"..t.."(lua_state, top, 0);")
+ output("\t\t\t",rettype,"tolua_ret = ("..rettype..")tolua_to"..t.."(lua_state, -1, 0);")
+ else
+
+ local mod = ""
+ if f.ptr ~= "*" then
+ mod = "*("..f.type.."*)"
+ end
+
+ --output("\t\t\treturn ("..rettype..")"..mod.."tolua_tousertype(lua_state, top, 0);")
+ output("\t\t\t",rettype,"tolua_ret = ("..rettype..")"..mod.."tolua_tousertype(lua_state, -1, 0);")
+ end
+ output("\t\t\tlua_pop(lua_state, 1);")
+ output("\t\t\treturn tolua_ret;")
+ else
+ output("0);")
+ end
+
+ -- handle non-implemeted function
+ output("\t\t} else {")
+
+ if f.pure_virtual then
+
+ output('\t\t\tif (lua_state)')
+ --output('\t\t\t\ttolua_error(lua_state, "pure-virtual method '..btype.."::"..f.name..' not implemented.", NULL);')
+ output('\t\t\t\tLOG("pure-virtual method '..btype.."::"..f.name..' not implemented.");')
+ output('\t\t\telse {')
+ output('\t\t\t\tLOG("pure-virtual method '..btype.."::"..f.name..' called with no lua_state. Aborting");')
+ output('\t\t\t\t::abort();')
+ output('\t\t\t};')
+ if( rettype == " std::string " ) then
+ output('\t\t\treturn "";')
+ else
+ output('\t\t\treturn (',rettype,')0;')
+ end
+ else
+
+ output('\t\t\treturn (',rettype,')',btype,'::',f.name,var_list,';')
+ end
+
+ output("\t\t};")
+
+ output("\t};")
+end
+
+function VirtualClass()
+
+ local parent = classContainer.curr
+ pop()
+
+ local name = "Lua__"..parent.original_name
+
+ local c = _Class(_Container{name=name, base=parent.name, extra_bases=nil})
+ setmetatable(c, classVirtualClass)
+
+ local ft = getnamespace(c.parent)..c.original_name
+ append_global_type(ft, c)
+
+ push(parent)
+
+ c.flags.parent_object = parent
+ c.methods = {}
+
+ push(c)
+ c:parse("\nvoid tolua__set_instance(_lstate L, lua_Object lo);\n")
+ pop()
+
+ return c
+end
+
+
+
+
+
diff --git a/squirrel_3_0_1_stable/sqstdlib/sqstdlib.dsp b/squirrel_3_0_1_stable/sqstdlib/sqstdlib.dsp
index 7453243fe..ef5b7f486 100644
--- a/squirrel_3_0_1_stable/sqstdlib/sqstdlib.dsp
+++ b/squirrel_3_0_1_stable/sqstdlib/sqstdlib.dsp
@@ -1,131 +1,131 @@
-# Microsoft Developer Studio Project File - Name="sqstdlib" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=sqstdlib - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "sqstdlib.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "sqstdlib.mak" CFG="sqstdlib - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "sqstdlib - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "sqstdlib - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_LocalPath ".."
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "sqstdlib - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD BASE RSC /l 0x410 /d "NDEBUG"
-# ADD RSC /l 0x410 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\lib\sqstdlib.lib"
-
-!ELSEIF "$(CFG)" == "sqstdlib - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x410 /d "_DEBUG"
-# ADD RSC /l 0x410 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\lib\sqstdlib.lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "sqstdlib - Win32 Release"
-# Name "sqstdlib - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\sqstdblob.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstdio.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstdmath.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstdrex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstdstream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstdstring.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstdaux.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstdsystem.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\sqstdblobimpl.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstdstream.h
-# End Source File
-# End Group
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="sqstdlib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=sqstdlib - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "sqstdlib.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "sqstdlib.mak" CFG="sqstdlib - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "sqstdlib - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "sqstdlib - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_LocalPath ".."
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "sqstdlib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD BASE RSC /l 0x410 /d "NDEBUG"
+# ADD RSC /l 0x410 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"..\lib\sqstdlib.lib"
+
+!ELSEIF "$(CFG)" == "sqstdlib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x410 /d "_DEBUG"
+# ADD RSC /l 0x410 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"..\lib\sqstdlib.lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "sqstdlib - Win32 Release"
+# Name "sqstdlib - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\sqstdblob.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstdio.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstdmath.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstdrex.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstdstream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstdstring.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstdaux.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstdsystem.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\sqstdblobimpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstdstream.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/squirrel_3_0_1_stable/squirrel.dsw b/squirrel_3_0_1_stable/squirrel.dsw
index db43df68e..721509106 100644
--- a/squirrel_3_0_1_stable/squirrel.dsw
+++ b/squirrel_3_0_1_stable/squirrel.dsw
@@ -1,77 +1,77 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "sq"=.\sq\sq.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
- begin source code control
- .
- end source code control
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name sqlibs
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name squirrel
- End Project Dependency
- Begin Project Dependency
- Project_Dep_Name sqstdlib
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "sqstdlib"=.\sqstdlib\sqstdlib.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
- begin source code control
- "$/squirrel", HAAAAAAA
- .
- end source code control
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "squirrel"=.\squirrel\squirrel.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
- begin source code control
- "$/squirrel", HAAAAAAA
- .
- end source code control
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
- begin source code control
- "$/squirrel", HAAAAAAA
- .
- end source code control
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "sq"=.\sq\sq.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+ begin source code control
+ .
+ end source code control
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name sqlibs
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name squirrel
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name sqstdlib
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "sqstdlib"=.\sqstdlib\sqstdlib.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+ begin source code control
+ "$/squirrel", HAAAAAAA
+ .
+ end source code control
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "squirrel"=.\squirrel\squirrel.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+ begin source code control
+ "$/squirrel", HAAAAAAA
+ .
+ end source code control
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+ begin source code control
+ "$/squirrel", HAAAAAAA
+ .
+ end source code control
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/squirrel_3_0_1_stable/squirrel/squirrel.dsp b/squirrel_3_0_1_stable/squirrel/squirrel.dsp
index 4778b6963..66a84f7dd 100644
--- a/squirrel_3_0_1_stable/squirrel/squirrel.dsp
+++ b/squirrel_3_0_1_stable/squirrel/squirrel.dsp
@@ -1,302 +1,302 @@
-# Microsoft Developer Studio Project File - Name="squirrel" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=squirrel - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "squirrel.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "squirrel.mak" CFG="squirrel - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "squirrel - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "squirrel - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_LocalPath ".."
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "GARBAGE_COLLECTOR" /YX /FD /c
-# ADD BASE RSC /l 0x410 /d "NDEBUG"
-# ADD RSC /l 0x410 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\lib\squirrel.lib"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x410 /d "_DEBUG"
-# ADD RSC /l 0x410 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\lib\squirrel.lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "squirrel - Win32 Release"
-# Name "squirrel - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\sqapi.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqbaselib.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqcompiler.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqdebug.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqfuncstate.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqlexer.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqmem.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqobject.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstate.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqtable.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqclass.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqvm.cpp
-
-!IF "$(CFG)" == "squirrel - Win32 Release"
-
-!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
-
-# ADD CPP /YX"stdafx.h"
-
-!ENDIF
-
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\sqarray.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqclosure.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqcompiler.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqfuncproto.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqfuncstate.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqlexer.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqobject.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqopcodes.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqpcheader.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstate.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqstring.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqtable.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\squserdata.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\squtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqclass.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sqvm.h
-# End Source File
-# End Group
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="squirrel" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=squirrel - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "squirrel.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "squirrel.mak" CFG="squirrel - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "squirrel - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "squirrel - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_LocalPath ".."
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "GARBAGE_COLLECTOR" /YX /FD /c
+# ADD BASE RSC /l 0x410 /d "NDEBUG"
+# ADD RSC /l 0x410 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"..\lib\squirrel.lib"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x410 /d "_DEBUG"
+# ADD RSC /l 0x410 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"..\lib\squirrel.lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "squirrel - Win32 Release"
+# Name "squirrel - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\sqapi.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqbaselib.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqcompiler.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqdebug.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqfuncstate.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqlexer.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqmem.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqobject.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstate.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqtable.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqclass.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqvm.cpp
+
+!IF "$(CFG)" == "squirrel - Win32 Release"
+
+!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
+
+# ADD CPP /YX"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\sqarray.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqclosure.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqcompiler.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqfuncproto.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqfuncstate.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqlexer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqobject.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqopcodes.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqpcheader.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstate.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqstring.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqtable.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\squserdata.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\squtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqclass.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sqvm.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/tolua++-1.0.93/src/bin/lua/compat-5.1.lua b/tolua++-1.0.93/src/bin/lua/compat-5.1.lua
index c2642d3a6..7a2c60b69 100644
--- a/tolua++-1.0.93/src/bin/lua/compat-5.1.lua
+++ b/tolua++-1.0.93/src/bin/lua/compat-5.1.lua
@@ -1,57 +1,57 @@
-if string.find(_VERSION, "5%.0") then
- return
-end
-
--- "loadfile"
-local function pp_dofile(path)
-
- local loaded = false
- local getfile = function()
-
- if loaded then
- return
- else
- local file,err = io.open(path)
- if not file then
- error("error loading file "..path..": "..err)
- end
- local ret = file:read("*a")
- file:close()
-
- ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};")
-
- loaded = true
- return ret
- end
- end
-
- local f = load(getfile, path)
- if not f then
-
- error("error loading file "..path)
- end
- return f()
-end
-
-old_dofile = dofile
-dofile = pp_dofile
-
-
--- string.gsub
---[[
-local ogsub = string.gsub
-local function compgsub(a,b,c,d)
- if type(c) == "function" then
- local oc = c
- c = function (...) return oc(...) or '' end
- end
- return ogsub(a,b,c,d)
-end
-string.repl = ogsub
---]]
-
---string.gsub = compgsub
-
-
-
-
+if string.find(_VERSION, "5%.0") then
+ return
+end
+
+-- "loadfile"
+local function pp_dofile(path)
+
+ local loaded = false
+ local getfile = function()
+
+ if loaded then
+ return
+ else
+ local file,err = io.open(path)
+ if not file then
+ error("error loading file "..path..": "..err)
+ end
+ local ret = file:read("*a")
+ file:close()
+
+ ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};")
+
+ loaded = true
+ return ret
+ end
+ end
+
+ local f = load(getfile, path)
+ if not f then
+
+ error("error loading file "..path)
+ end
+ return f()
+end
+
+old_dofile = dofile
+dofile = pp_dofile
+
+
+-- string.gsub
+--[[
+local ogsub = string.gsub
+local function compgsub(a,b,c,d)
+ if type(c) == "function" then
+ local oc = c
+ c = function (...) return oc(...) or '' end
+ end
+ return ogsub(a,b,c,d)
+end
+string.repl = ogsub
+--]]
+
+--string.gsub = compgsub
+
+
+
+
diff --git a/tolua++-1.0.93/src/bin/lua/custom.lua b/tolua++-1.0.93/src/bin/lua/custom.lua
index 293175ef9..de5912fb3 100644
--- a/tolua++-1.0.93/src/bin/lua/custom.lua
+++ b/tolua++-1.0.93/src/bin/lua/custom.lua
@@ -1,45 +1,45 @@
-
-function extract_code(fn,s)
- local code = ""
- if fn then
- code = '\n$#include "'..fn..'"\n'
- end
- s= "\n" .. s .. "\n" -- add blank lines as sentinels
- local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n")
- while e do
- t = strlower(t)
- if t == "bind_begin" then
- _,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e)
- if not e then
- tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file")
- end
- end
- if t == "bind_class" or t == "bind_block" then
- local b
- _,e,c,b = string.find(s, "([^{]-)(%b{})", e)
- c = c..'{\n'..extract_code(nil, b)..'\n};\n'
- end
- code = code .. c .. "\n"
- _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e)
- end
- return code
-end
-
-function preprocess_hook(p)
-end
-
-function preparse_hook(p)
-end
-
-function include_file_hook(p, filename)
- do return end
---print("FILENAME is "..filename)
- p.code = string.gsub(p.code, "\n%s*SigC::Signal", "\n\ttolua_readonly SigC::Signal")
- p.code = string.gsub(p.code, "#ifdef __cplusplus\nextern \"C\" {\n#endif", "")
- p.code = string.gsub(p.code, "#ifdef __cplusplus\n};?\n#endif", "")
- p.code = string.gsub(p.code, "DECLSPEC", "")
- p.code = string.gsub(p.code, "SDLCALL", "")
- p.code = string.gsub(p.code, "DLLINTERFACE", "")
- p.code = string.gsub(p.code, "#define[^\n]*_[hH]_?%s*\n", "\n")
---print("code is "..p.code)
-end
+
+function extract_code(fn,s)
+ local code = ""
+ if fn then
+ code = '\n$#include "'..fn..'"\n'
+ end
+ s= "\n" .. s .. "\n" -- add blank lines as sentinels
+ local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n")
+ while e do
+ t = strlower(t)
+ if t == "bind_begin" then
+ _,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e)
+ if not e then
+ tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file")
+ end
+ end
+ if t == "bind_class" or t == "bind_block" then
+ local b
+ _,e,c,b = string.find(s, "([^{]-)(%b{})", e)
+ c = c..'{\n'..extract_code(nil, b)..'\n};\n'
+ end
+ code = code .. c .. "\n"
+ _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e)
+ end
+ return code
+end
+
+function preprocess_hook(p)
+end
+
+function preparse_hook(p)
+end
+
+function include_file_hook(p, filename)
+ do return end
+--print("FILENAME is "..filename)
+ p.code = string.gsub(p.code, "\n%s*SigC::Signal", "\n\ttolua_readonly SigC::Signal")
+ p.code = string.gsub(p.code, "#ifdef __cplusplus\nextern \"C\" {\n#endif", "")
+ p.code = string.gsub(p.code, "#ifdef __cplusplus\n};?\n#endif", "")
+ p.code = string.gsub(p.code, "DECLSPEC", "")
+ p.code = string.gsub(p.code, "SDLCALL", "")
+ p.code = string.gsub(p.code, "DLLINTERFACE", "")
+ p.code = string.gsub(p.code, "#define[^\n]*_[hH]_?%s*\n", "\n")
+--print("code is "..p.code)
+end
diff --git a/tolua++-1.0.93/win32/tolualib/tolualib.vcproj b/tolua++-1.0.93/win32/tolualib/tolualib.vcproj
index c33f494b6..598b2d6fe 100644
--- a/tolua++-1.0.93/win32/tolualib/tolualib.vcproj
+++ b/tolua++-1.0.93/win32/tolualib/tolualib.vcproj
@@ -1,197 +1,197 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="tolualib"
- ProjectGUID="{9DDCB327-0D20-460F-A7F8-DE038163CD63}"
- RootNamespace="tolualib"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="&quot;../../../lua-5.1.4/src&quot;;../../include"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="&quot;../../../lua-5.1.4/src&quot;;../../include"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- AdditionalLibraryDirectories="C:\Program Files (x86)\Lua\5.1\lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\..\src\lib\tolua_event.c"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_is.c"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_map.c"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_push.c"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_to.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\..\src\lib\tolua_event.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="tolualib"
+ ProjectGUID="{9DDCB327-0D20-460F-A7F8-DE038163CD63}"
+ RootNamespace="tolualib"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;../../../lua-5.1.4/src&quot;;../../include"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="&quot;../../../lua-5.1.4/src&quot;;../../include"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ AdditionalLibraryDirectories="C:\Program Files (x86)\Lua\5.1\lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\src\lib\tolua_event.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_is.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_map.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_push.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_to.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\src\lib\tolua_event.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/tolua++-1.0.93/win32/tolualib/tolualib.vcproj.LAPTOPF.Kevin.user b/tolua++-1.0.93/win32/tolualib/tolualib.vcproj.LAPTOPF.Kevin.user
index 82b07e6b1..eaf548aa5 100644
--- a/tolua++-1.0.93/win32/tolualib/tolualib.vcproj.LAPTOPF.Kevin.user
+++ b/tolua++-1.0.93/win32/tolualib/tolualib.vcproj.LAPTOPF.Kevin.user
@@ -1,65 +1,65 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioUserFile
- ProjectType="Visual C++"
- Version="9,00"
- ShowAllFiles="false"
- >
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- >
- <DebugSettings
- Command="$(TargetPath)"
- WorkingDirectory=""
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- Remote="1"
- RemoteMachine="LAPTOPF"
- RemoteCommand=""
- HttpUrl=""
- PDBPath=""
- SQLDebugging=""
- Environment=""
- EnvironmentMerge="true"
- DebuggerFlavor=""
- MPIRunCommand=""
- MPIRunArguments=""
- MPIRunWorkingDirectory=""
- ApplicationCommand=""
- ApplicationArguments=""
- ShimCommand=""
- MPIAcceptMode=""
- MPIAcceptFilter=""
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- >
- <DebugSettings
- Command=""
- WorkingDirectory=""
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- Remote="1"
- RemoteMachine="LAPTOPF"
- RemoteCommand=""
- HttpUrl=""
- PDBPath=""
- SQLDebugging=""
- Environment=""
- EnvironmentMerge="true"
- DebuggerFlavor=""
- MPIRunCommand=""
- MPIRunArguments=""
- MPIRunWorkingDirectory=""
- ApplicationCommand=""
- ApplicationArguments=""
- ShimCommand=""
- MPIAcceptMode=""
- MPIAcceptFilter=""
- />
- </Configuration>
- </Configurations>
-</VisualStudioUserFile>
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+ ProjectType="Visual C++"
+ Version="9,00"
+ ShowAllFiles="false"
+ >
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="LAPTOPF"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ >
+ <DebugSettings
+ Command=""
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="LAPTOPF"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ </Configurations>
+</VisualStudioUserFile>
diff --git a/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj b/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj
index 17730685e..f12bfda86 100644
--- a/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj
+++ b/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj
@@ -1,80 +1,80 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{AB745E71-04B2-454F-A806-A0D553DAE08C}</ProjectGuid>
- <RootNamespace>tolualib</RootNamespace>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <TargetName>tolua++</TargetName>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <AdditionalIncludeDirectories>../../include;C:\Program Files (x86)\Lua\5.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalLibraryDirectories>C:\Program Files (x86)\Lua\5.1\lib</AdditionalLibraryDirectories>
- <AdditionalDependencies>lua51.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\src\lib\tolua_event.c" />
- <ClCompile Include="..\..\src\lib\tolua_is.c" />
- <ClCompile Include="..\..\src\lib\tolua_map.c" />
- <ClCompile Include="..\..\src\lib\tolua_push.c" />
- <ClCompile Include="..\..\src\lib\tolua_to.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\src\lib\tolua_event.h" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{AB745E71-04B2-454F-A806-A0D553DAE08C}</ProjectGuid>
+ <RootNamespace>tolualib</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <TargetName>tolua++</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <AdditionalIncludeDirectories>../../include;C:\Program Files (x86)\Lua\5.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>C:\Program Files (x86)\Lua\5.1\lib</AdditionalLibraryDirectories>
+ <AdditionalDependencies>lua51.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\lib\tolua_event.c" />
+ <ClCompile Include="..\..\src\lib\tolua_is.c" />
+ <ClCompile Include="..\..\src\lib\tolua_map.c" />
+ <ClCompile Include="..\..\src\lib\tolua_push.c" />
+ <ClCompile Include="..\..\src\lib\tolua_to.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\src\lib\tolua_event.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
</Project> \ No newline at end of file
diff --git a/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.filters b/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.filters
index 899d07e76..99f8ce3b6 100644
--- a/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.filters
+++ b/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.filters
@@ -1,39 +1,39 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\..\src\lib\tolua_event.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\lib\tolua_is.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\lib\tolua_map.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\lib\tolua_push.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\lib\tolua_to.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\src\lib\tolua_event.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\lib\tolua_event.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\lib\tolua_is.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\lib\tolua_map.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\lib\tolua_push.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\lib\tolua_to.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\src\lib\tolua_event.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.user b/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.user
index 695b5c78b..4c1e1937c 100644
--- a/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.user
+++ b/tolua++-1.0.93/win32/tolualib/tolualib.vcxproj.user
@@ -1,3 +1,3 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project> \ No newline at end of file
diff --git a/tolua++-1.0.93/win32/vc7/clean.bat b/tolua++-1.0.93/win32/vc7/clean.bat
index 96beb28a5..b8f4f2b2f 100644
--- a/tolua++-1.0.93/win32/vc7/clean.bat
+++ b/tolua++-1.0.93/win32/vc7/clean.bat
@@ -1,15 +1,15 @@
-del *.ncb
-del *.ilk
-del *.lib
-del *.exp
-del *.map
-del *.pdb
-del *.bsc
-del applog.txt
-del tmpl83.00c.vcproj.LAPTOPF.Kevin.user
-del *.suo /AH
-del debug\*.* /Q
-del release\*.* /Q
-rd release /Q
-rd debug /Q
-
+del *.ncb
+del *.ilk
+del *.lib
+del *.exp
+del *.map
+del *.pdb
+del *.bsc
+del applog.txt
+del tmpl83.00c.vcproj.LAPTOPF.Kevin.user
+del *.suo /AH
+del debug\*.* /Q
+del release\*.* /Q
+rd release /Q
+rd debug /Q
+
diff --git a/tolua++-1.0.93/win32/vc7/toluapp.sln b/tolua++-1.0.93/win32/vc7/toluapp.sln
index e14ba57c8..1ab8be380 100644
--- a/tolua++-1.0.93/win32/vc7/toluapp.sln
+++ b/tolua++-1.0.93/win32/vc7/toluapp.sln
@@ -1,48 +1,48 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluapp", "toluapp.vcproj", "{71891C1A-E328-4258-AC3F-6F9698C6D8B4}"
- ProjectSection(ProjectDependencies) = postProject
- {9DDCB327-0D20-460F-A7F8-DE038163CD63} = {9DDCB327-0D20-460F-A7F8-DE038163CD63}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolualib", "..\tolualib\tolualib.vcproj", "{9DDCB327-0D20-460F-A7F8-DE038163CD63}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- withLua50_Debug|Win32 = withLua50_Debug|Win32
- withLua50_Release|Win32 = withLua50_Release|Win32
- withLua51_Debug|Win32 = withLua51_Debug|Win32
- withLua51_Release|Win32 = withLua51_Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.Debug|Win32.ActiveCfg = withLua51_Debug|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.Debug|Win32.Build.0 = withLua51_Debug|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.Release|Win32.ActiveCfg = withLua51_Release|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.Release|Win32.Build.0 = withLua51_Release|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Debug|Win32.ActiveCfg = withLua51_Release|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Debug|Win32.Build.0 = withLua51_Release|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Release|Win32.ActiveCfg = withLua51_Release|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Release|Win32.Build.0 = withLua51_Release|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Debug|Win32.ActiveCfg = withLua51_Debug|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Debug|Win32.Build.0 = withLua51_Debug|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Release|Win32.ActiveCfg = withLua51_Release|Win32
- {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Release|Win32.Build.0 = withLua51_Release|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.Debug|Win32.ActiveCfg = Debug|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.Debug|Win32.Build.0 = Debug|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.Release|Win32.ActiveCfg = Release|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.Release|Win32.Build.0 = Release|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua50_Debug|Win32.ActiveCfg = Debug|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua50_Debug|Win32.Build.0 = Debug|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua50_Release|Win32.ActiveCfg = Release|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua50_Release|Win32.Build.0 = Release|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua51_Debug|Win32.ActiveCfg = Debug|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua51_Debug|Win32.Build.0 = Debug|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua51_Release|Win32.ActiveCfg = Release|Win32
- {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua51_Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluapp", "toluapp.vcproj", "{71891C1A-E328-4258-AC3F-6F9698C6D8B4}"
+ ProjectSection(ProjectDependencies) = postProject
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63} = {9DDCB327-0D20-460F-A7F8-DE038163CD63}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolualib", "..\tolualib\tolualib.vcproj", "{9DDCB327-0D20-460F-A7F8-DE038163CD63}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ withLua50_Debug|Win32 = withLua50_Debug|Win32
+ withLua50_Release|Win32 = withLua50_Release|Win32
+ withLua51_Debug|Win32 = withLua51_Debug|Win32
+ withLua51_Release|Win32 = withLua51_Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.Debug|Win32.ActiveCfg = withLua51_Debug|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.Debug|Win32.Build.0 = withLua51_Debug|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.Release|Win32.ActiveCfg = withLua51_Release|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.Release|Win32.Build.0 = withLua51_Release|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Debug|Win32.ActiveCfg = withLua51_Release|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Debug|Win32.Build.0 = withLua51_Release|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Release|Win32.ActiveCfg = withLua51_Release|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Release|Win32.Build.0 = withLua51_Release|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Debug|Win32.ActiveCfg = withLua51_Debug|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Debug|Win32.Build.0 = withLua51_Debug|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Release|Win32.ActiveCfg = withLua51_Release|Win32
+ {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Release|Win32.Build.0 = withLua51_Release|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.Debug|Win32.Build.0 = Debug|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.Release|Win32.ActiveCfg = Release|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.Release|Win32.Build.0 = Release|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua50_Debug|Win32.ActiveCfg = Debug|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua50_Debug|Win32.Build.0 = Debug|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua50_Release|Win32.ActiveCfg = Release|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua50_Release|Win32.Build.0 = Release|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua51_Debug|Win32.ActiveCfg = Debug|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua51_Debug|Win32.Build.0 = Debug|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua51_Release|Win32.ActiveCfg = Release|Win32
+ {9DDCB327-0D20-460F-A7F8-DE038163CD63}.withLua51_Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/tolua++-1.0.93/win32/vc7/toluapp.vcproj b/tolua++-1.0.93/win32/vc7/toluapp.vcproj
index c2540a2bf..285bd2d42 100644
--- a/tolua++-1.0.93/win32/vc7/toluapp.vcproj
+++ b/tolua++-1.0.93/win32/vc7/toluapp.vcproj
@@ -1,439 +1,439 @@
-<?xml version="1.0" encoding="shift_jis"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="toluapp"
- ProjectGUID="{71891C1A-E328-4258-AC3F-6F9698C6D8B4}"
- Keyword="Win32Proj"
- TargetFrameworkVersion="131072"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="withLua51_Debug|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="&quot;../../../lua-5.1.4/src&quot;;../../include"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="..\..\bin\tolua++_d.exe"
- LinkIncremental="2"
- AdditionalLibraryDirectories="..\..\lib"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/tolua++.pdb"
- SubSystem="1"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="withLua51_Release|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;../../../lua-5.1.4/src&quot;;../../include"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="0"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="..\..\bin\tolua++.exe"
- LinkIncremental="1"
- AdditionalLibraryDirectories="..\..\lib;&quot;C:\Program Files (x86)\Lua\5.1\lib&quot;"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="source files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\..\src\bin\tolua.c"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_event.c"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_event.h"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_is.c"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_map.c"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_push.c"
- >
- </File>
- <File
- RelativePath="..\..\src\lib\tolua_to.c"
- >
- </File>
- <File
- RelativePath="..\..\src\bin\toluabind.c"
- >
- </File>
- <Filter
- Name="Lua"
- >
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lapi.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lapi.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lauxlib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lauxlib.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lbaselib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lcode.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lcode.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ldblib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ldebug.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ldebug.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ldo.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ldo.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ldump.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lfunc.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lfunc.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lgc.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lgc.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\linit.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\liolib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\llex.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\llex.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\llimits.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lmathlib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lmem.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lmem.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\loadlib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lobject.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lobject.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lopcodes.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lopcodes.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\loslib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lparser.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lparser.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lstate.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lstate.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lstring.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lstring.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lstrlib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ltable.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ltable.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ltablib.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ltm.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\ltm.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\luac.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\luaconf.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lualib.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lundump.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lundump.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lvm.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lvm.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lzio.c"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\lzio.h"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\Makefile"
- >
- </File>
- <File
- RelativePath="..\..\..\lua-5.1.4\src\print.c"
- >
- </File>
- </Filter>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="toluapp"
+ ProjectGUID="{71891C1A-E328-4258-AC3F-6F9698C6D8B4}"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="withLua51_Debug|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;../../../lua-5.1.4/src&quot;;../../include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\tolua++_d.exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="..\..\lib"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/tolua++.pdb"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="withLua51_Release|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="&quot;../../../lua-5.1.4/src&quot;;../../include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\tolua++.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="..\..\lib;&quot;C:\Program Files (x86)\Lua\5.1\lib&quot;"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="source files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\src\bin\tolua.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_event.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_event.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_is.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_map.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_push.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\lib\tolua_to.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\bin\toluabind.c"
+ >
+ </File>
+ <Filter
+ Name="Lua"
+ >
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lapi.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lapi.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lauxlib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lauxlib.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lbaselib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lcode.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lcode.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ldblib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ldebug.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ldebug.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ldo.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ldo.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ldump.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lfunc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lfunc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lgc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lgc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\linit.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\liolib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\llex.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\llex.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\llimits.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lmathlib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lmem.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lmem.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\loadlib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lobject.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lobject.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lopcodes.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lopcodes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\loslib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lparser.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lparser.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lstate.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lstate.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lstring.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lstring.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lstrlib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ltable.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ltable.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ltablib.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ltm.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\ltm.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\luac.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\luaconf.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lualib.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lundump.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lundump.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lvm.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lvm.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lzio.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\lzio.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\Makefile"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\lua-5.1.4\src\print.c"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/tolua++-1.0.93/win32/vc7/toluapp.vcproj.LAPTOPF.Kevin.user b/tolua++-1.0.93/win32/vc7/toluapp.vcproj.LAPTOPF.Kevin.user
index 46f7034c2..a2de0fbb2 100644
--- a/tolua++-1.0.93/win32/vc7/toluapp.vcproj.LAPTOPF.Kevin.user
+++ b/tolua++-1.0.93/win32/vc7/toluapp.vcproj.LAPTOPF.Kevin.user
@@ -1,121 +1,121 @@
-<?xml version="1.0" encoding="shift_jis"?>
-<VisualStudioUserFile
- ProjectType="Visual C++"
- Version="9,00"
- ShowAllFiles="false"
- >
- <Configurations>
- <Configuration
- Name="withLua50_Debug|Win32"
- >
- <DebugSettings
- Command="$(TargetPath)"
- WorkingDirectory=""
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- Remote="1"
- RemoteMachine="LAPTOPF"
- RemoteCommand=""
- HttpUrl=""
- PDBPath=""
- SQLDebugging=""
- Environment=""
- EnvironmentMerge="true"
- DebuggerFlavor=""
- MPIRunCommand=""
- MPIRunArguments=""
- MPIRunWorkingDirectory=""
- ApplicationCommand=""
- ApplicationArguments=""
- ShimCommand=""
- MPIAcceptMode=""
- MPIAcceptFilter=""
- />
- </Configuration>
- <Configuration
- Name="withLua50_Release|Win32"
- >
- <DebugSettings
- Command="$(TargetPath)"
- WorkingDirectory=""
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- Remote="1"
- RemoteMachine="LAPTOPF"
- RemoteCommand=""
- HttpUrl=""
- PDBPath=""
- SQLDebugging=""
- Environment=""
- EnvironmentMerge="true"
- DebuggerFlavor=""
- MPIRunCommand=""
- MPIRunArguments=""
- MPIRunWorkingDirectory=""
- ApplicationCommand=""
- ApplicationArguments=""
- ShimCommand=""
- MPIAcceptMode=""
- MPIAcceptFilter=""
- />
- </Configuration>
- <Configuration
- Name="withLua51_Debug|Win32"
- >
- <DebugSettings
- Command="$(TargetPath)"
- WorkingDirectory=""
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- Remote="1"
- RemoteMachine="LAPTOPF"
- RemoteCommand=""
- HttpUrl=""
- PDBPath=""
- SQLDebugging=""
- Environment=""
- EnvironmentMerge="true"
- DebuggerFlavor=""
- MPIRunCommand=""
- MPIRunArguments=""
- MPIRunWorkingDirectory=""
- ApplicationCommand=""
- ApplicationArguments=""
- ShimCommand=""
- MPIAcceptMode=""
- MPIAcceptFilter=""
- />
- </Configuration>
- <Configuration
- Name="withLua51_Release|Win32"
- >
- <DebugSettings
- Command="$(TargetPath)"
- WorkingDirectory=""
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- Remote="1"
- RemoteMachine="LAPTOPF"
- RemoteCommand=""
- HttpUrl=""
- PDBPath=""
- SQLDebugging=""
- Environment=""
- EnvironmentMerge="true"
- DebuggerFlavor=""
- MPIRunCommand=""
- MPIRunArguments=""
- MPIRunWorkingDirectory=""
- ApplicationCommand=""
- ApplicationArguments=""
- ShimCommand=""
- MPIAcceptMode=""
- MPIAcceptFilter=""
- />
- </Configuration>
- </Configurations>
-</VisualStudioUserFile>
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioUserFile
+ ProjectType="Visual C++"
+ Version="9,00"
+ ShowAllFiles="false"
+ >
+ <Configurations>
+ <Configuration
+ Name="withLua50_Debug|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="LAPTOPF"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ <Configuration
+ Name="withLua50_Release|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="LAPTOPF"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ <Configuration
+ Name="withLua51_Debug|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="LAPTOPF"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ <Configuration
+ Name="withLua51_Release|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="LAPTOPF"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ </Configurations>
+</VisualStudioUserFile>
diff --git a/tolua++-1.0.93/win32/vc7/toluapp.vcxproj b/tolua++-1.0.93/win32/vc7/toluapp.vcxproj
index 967da40b3..45601b36f 100644
--- a/tolua++-1.0.93/win32/vc7/toluapp.vcxproj
+++ b/tolua++-1.0.93/win32/vc7/toluapp.vcxproj
@@ -1,176 +1,176 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="withLua50_Debug|Win32">
- <Configuration>withLua50_Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="withLua50_Release|Win32">
- <Configuration>withLua50_Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="withLua51_Debug|Win32">
- <Configuration>withLua51_Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="withLua51_Release|Win32">
- <Configuration>withLua51_Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{71891C1A-E328-4258-AC3F-6F9698C6D8B4}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'">Debug\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'">Debug\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'">true</LinkIncremental>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'">Release\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'">Release\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'">false</LinkIncremental>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'">$(Configuration)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'">$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'">true</LinkIncremental>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'">$(Configuration)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'">$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'">false</LinkIncremental>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'">
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <MinimalRebuild>true</MinimalRebuild>
- <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
- </ClCompile>
- <Link>
- <AdditionalDependencies>lua50.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <OutputFile>..\..\bin\tolua++_d.exe</OutputFile>
- <AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ProgramDatabaseFile>$(OutDir)tolua++.pdb</ProgramDatabaseFile>
- <SubSystem>Console</SubSystem>
- <TargetMachine>MachineX86</TargetMachine>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- </ClCompile>
- <Link>
- <AdditionalDependencies>lua50.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <OutputFile>..\..\bin\tolua++.exe</OutputFile>
- <AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- <OptimizeReferences>true</OptimizeReferences>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <TargetMachine>MachineX86</TargetMachine>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'">
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <MinimalRebuild>true</MinimalRebuild>
- <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Lua5.1.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <OutputFile>..\..\bin\tolua++_d.exe</OutputFile>
- <AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ProgramDatabaseFile>$(OutDir)tolua++.pdb</ProgramDatabaseFile>
- <SubSystem>Console</SubSystem>
- <TargetMachine>MachineX86</TargetMachine>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;C:\Program Files (x86)\Lua\5.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- </ClCompile>
- <Link>
- <AdditionalDependencies>lua5.1.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <OutputFile>..\..\bin\tolua++.exe</OutputFile>
- <AdditionalLibraryDirectories>..\..\lib;C:\Program Files (x86)\Lua\5.1\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- <OptimizeReferences>true</OptimizeReferences>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <TargetMachine>MachineX86</TargetMachine>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\src\bin\tolua.c" />
- <ClCompile Include="..\..\src\lib\tolua_event.c" />
- <ClCompile Include="..\..\src\lib\tolua_is.c" />
- <ClCompile Include="..\..\src\lib\tolua_map.c" />
- <ClCompile Include="..\..\src\lib\tolua_push.c" />
- <ClCompile Include="..\..\src\lib\tolua_to.c" />
- <ClCompile Include="..\..\src\bin\toluabind.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\src\lib\tolua_event.h" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="withLua50_Debug|Win32">
+ <Configuration>withLua50_Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="withLua50_Release|Win32">
+ <Configuration>withLua50_Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="withLua51_Debug|Win32">
+ <Configuration>withLua51_Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="withLua51_Release|Win32">
+ <Configuration>withLua51_Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{71891C1A-E328-4258-AC3F-6F9698C6D8B4}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'">Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'">Debug\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'">Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'">Release\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'">$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'">$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>lua50.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>..\..\bin\tolua++_d.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)tolua++.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='withLua50_Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>lua50.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>..\..\bin\tolua++.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>Lua5.1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>..\..\bin\tolua++_d.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)tolua++.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='withLua51_Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\include;C:\Program Files (x86)\Lua\5.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>lua5.1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>..\..\bin\tolua++.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib;C:\Program Files (x86)\Lua\5.1\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\bin\tolua.c" />
+ <ClCompile Include="..\..\src\lib\tolua_event.c" />
+ <ClCompile Include="..\..\src\lib\tolua_is.c" />
+ <ClCompile Include="..\..\src\lib\tolua_map.c" />
+ <ClCompile Include="..\..\src\lib\tolua_push.c" />
+ <ClCompile Include="..\..\src\lib\tolua_to.c" />
+ <ClCompile Include="..\..\src\bin\toluabind.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\src\lib\tolua_event.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
</Project> \ No newline at end of file
diff --git a/tolua++-1.0.93/win32/vc7/toluapp.vcxproj.filters b/tolua++-1.0.93/win32/vc7/toluapp.vcxproj.filters
index b204b932e..c23b20870 100644
--- a/tolua++-1.0.93/win32/vc7/toluapp.vcxproj.filters
+++ b/tolua++-1.0.93/win32/vc7/toluapp.vcxproj.filters
@@ -1,45 +1,45 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="ソース ファイル">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="ヘッダー ファイル">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="リソース ファイル">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\..\src\bin\tolua.c">
- <Filter>ソース ファイル</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\lib\tolua_event.c">
- <Filter>ソース ファイル</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\lib\tolua_is.c">
- <Filter>ソース ファイル</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\lib\tolua_map.c">
- <Filter>ソース ファイル</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\lib\tolua_push.c">
- <Filter>ソース ファイル</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\lib\tolua_to.c">
- <Filter>ソース ファイル</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\bin\toluabind.c">
- <Filter>ソース ファイル</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\src\lib\tolua_event.h">
- <Filter>ソース ファイル</Filter>
- </ClInclude>
- </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="ソース ファイル">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="ヘッダー ファイル">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="リソース ファイル">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\bin\tolua.c">
+ <Filter>ソース ファイル</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\lib\tolua_event.c">
+ <Filter>ソース ファイル</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\lib\tolua_is.c">
+ <Filter>ソース ファイル</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\lib\tolua_map.c">
+ <Filter>ソース ファイル</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\lib\tolua_push.c">
+ <Filter>ソース ファイル</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\lib\tolua_to.c">
+ <Filter>ソース ファイル</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\bin\toluabind.c">
+ <Filter>ソース ファイル</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\src\lib\tolua_event.h">
+ <Filter>ソース ファイル</Filter>
+ </ClInclude>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/tolua++-1.0.93/win32/vc7/toluapp.vcxproj.user b/tolua++-1.0.93/win32/vc7/toluapp.vcxproj.user
index 695b5c78b..4c1e1937c 100644
--- a/tolua++-1.0.93/win32/vc7/toluapp.vcxproj.user
+++ b/tolua++-1.0.93/win32/vc7/toluapp.vcxproj.user
@@ -1,3 +1,3 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project> \ No newline at end of file